Sniki Posted January 21, 2020 Share Posted January 21, 2020 (edited) I need some help from someone who knows ACPI: For Brightness keys i rename Method _Q14 to XQ14 and add the patched Q14 method into a SSDT-KBD: // Lenovo ThinkPad X240 Keyboard Map. DefinitionBlock("", "SSDT", 2, "X240", "KBD", 0) { External (_SB.PCI0.LPC.EC, DeviceObj) External (_SB.PCI0.LPC.KBD, DeviceObj) Scope (_SB.PCI0.LPC.EC) { Method (_Q14, 0, NotSerialized) // (F15) - Brightness Up { Notify (KBD, 0x0406) } } } So in order to patch it properly so it only works on macOS and doesn't affect Linux or Windows, i need to add _OSI (Darwin) code so if _OSI is Darwin it returns Notify (KBD, 0x0406) which is brightness Up. But if it is Linux or Windows i need to add the code Else i believe and return the original XQ14 method. So what would be the appropriate call way to call XQ14 without having to paste the entire XQ14 code like this: // Lenovo ThinkPad X240 Keyboard Map. DefinitionBlock("", "SSDT", 2, "X240", "KBD", 0) { External (_SB.PCI0.LPC.EC, DeviceObj) External (_SB.PCI0.LPC.KBD, DeviceObj) External (NBCF, MethodObj) External (VIGD, MethodObj) External (BRLV, MethodObj) External (UCMS, MethodObj) External (BRNS, MethodObj) External (VBRC, MethodObj) External (_SB.PCI0.LPC.EC.HKEY.MHKQ, MethodObj) External (_SB.PCI0.LPC.EC.HKEY.MHKK, MethodObj) External (_SB.PCI0.PEG.VID.LCD0, MethodObj) External (_SB.PCI0.VID.LCD0, MethodObj) Scope (_SB.PCI0.LPC.EC) { Method (_Q14, 0, NotSerialized) // (F15) - Brightness Up { If (_OSI ("Darwin")) { Notify (KBD, 0x0406) } Else { If (^HKEY.MHKK (0x8000)) { ^HKEY.MHKQ (0x1010) } If (NBCF) { If (VIGD) { Notify (^^^VID.LCD0, 0x86) // Device-Specific } Else { Notify (^^^PEG.VID.LCD0, 0x86) // Device-Specific } } Else { Local0 = BRLV /* \BRLV */ If ((Local0 != 0x0F)) { Local0++ BRLV = Local0 } If (VIGD) { UCMS (0x16) BRNS () } Else { VBRC (Local0) } ^HKEY.MHKQ (0x6050) } } } } } As it needs tons of external declarations and a super long SSDT for all the Fn Keyboard Buttons. i need help from someone that knows ACPI. Should it be something like this for example: // Lenovo ThinkPad X240 Keyboard Map. DefinitionBlock("", "SSDT", 2, "X240", "KBD", 0) { External (_SB.PCI0.LPC.EC, DeviceObj) External (_SB.PCI0.LPC.KBD, DeviceObj) External (_SB.PCI0.LPC.EC.XQ14, MethodObj) Scope (_SB.PCI0.LPC.EC) { Method (_Q14, 0, NotSerialized) // (F15) - Brightness Up { If (_OSI ("Darwin")) { Notify (KBD, 0x0406) } Else { \_SB.PCI0.LPC.EC.XQ14 () } } } } Or it is wrong, is there a way to just call the XQ14 method instead of all the code of XQ14. Also second question is, should i add the If (_OSI ("Darwin")) after every method _Qxx or i can add it somewhere in the beginning of the SSDT ? Current SSDT is: // Lenovo ThinkPad X240 Keyboard Map. DefinitionBlock("", "SSDT", 2, "X240", "KBD", 0) { External (_SB.PCI0.LPC.EC, DeviceObj) External (_SB.PCI0.LPC.KBD, DeviceObj) Scope (_SB.PCI0.LPC.EC) { Method (_Q14, 0, NotSerialized) // (F15) - Brightness Up { Notify (KBD, 0x0406) } Method (_Q15, 0, NotSerialized) // (F14) - Brightness Down { Notify (KBD, 0x0405) } Method (_Q6A, 0, NotSerialized) // (F4) Microphone Mute - Siri { Notify (KBD, 0x033E) } Method (_Q16, 0, NotSerialized) // Projector / Mirror mode { Notify (KBD, 0x046E) } Method (_Q64, 0, NotSerialized) // (F8) Radio ON/OFF - Notification Center { Notify (KBD, 0x0342) } Method (_Q66, 0, NotSerialized) // (F16) Settings - System Preferences... { Notify (KBD, 0x0367) } Method (_Q67, 0, NotSerialized) // (F17) Windows Search - Spotlight Search { Notify (KBD, 0x0368) } Method (_Q68, 0, NotSerialized) // (F18) App Switcher - Mission Control { Notify (KBD, 0x0369) } Method (_Q69, 0, NotSerialized) // (F19) Start Menu - Launchpad { Notify (KBD, 0x036A) } } } Thanks ! Edited January 21, 2020 by Sniki 1 Link to comment Share on other sites More sharing options...
Allan Posted January 21, 2020 Share Posted January 21, 2020 2 hours ago, Sniki said: I need some help from someone who knows ACPI: For Brightness keys i rename Method _Q14 to XQ14 and add the patched Q14 method into a SSDT-KBD: // Lenovo ThinkPad X240 Keyboard Map. DefinitionBlock("", "SSDT", 2, "X240", "KBD", 0) { External (_SB.PCI0.LPC.EC, DeviceObj) External (_SB.PCI0.LPC.KBD, DeviceObj) Scope (_SB.PCI0.LPC.EC) { Method (_Q14, 0, NotSerialized) // (F15) - Brightness Up { Notify (KBD, 0x0406) } } } So in order to patch it properly so it only works on macOS and doesn't affect Linux or Windows, i need to add _OSI (Darwin) code so if _OSI is Darwin it returns Notify (KBD, 0x0406) which is brightness Up. But if it is Linux or Windows i need to add the code Else i believe and return the original XQ14 method. So what would be the appropriate call way to call XQ14 without having to paste the entire XQ14 code like this: // Lenovo ThinkPad X240 Keyboard Map. DefinitionBlock("", "SSDT", 2, "X240", "KBD", 0) { External (_SB.PCI0.LPC.EC, DeviceObj) External (_SB.PCI0.LPC.KBD, DeviceObj) External (NBCF, MethodObj) External (VIGD, MethodObj) External (BRLV, MethodObj) External (UCMS, MethodObj) External (BRNS, MethodObj) External (VBRC, MethodObj) External (_SB.PCI0.LPC.EC.HKEY.MHKQ, MethodObj) External (_SB.PCI0.LPC.EC.HKEY.MHKK, MethodObj) External (_SB.PCI0.PEG.VID.LCD0, MethodObj) External (_SB.PCI0.VID.LCD0, MethodObj) Scope (_SB.PCI0.LPC.EC) { Method (_Q14, 0, NotSerialized) // (F15) - Brightness Up { If (_OSI ("Darwin")) { Notify (KBD, 0x0406) } Else { If (^HKEY.MHKK (0x8000)) { ^HKEY.MHKQ (0x1010) } If (NBCF) { If (VIGD) { Notify (^^^VID.LCD0, 0x86) // Device-Specific } Else { Notify (^^^PEG.VID.LCD0, 0x86) // Device-Specific } } Else { Local0 = BRLV /* \BRLV */ If ((Local0 != 0x0F)) { Local0++ BRLV = Local0 } If (VIGD) { UCMS (0x16) BRNS () } Else { VBRC (Local0) } ^HKEY.MHKQ (0x6050) } } } } } As it needs tons of external declarations and a super long SSDT for all the Fn Keyboard Buttons. i need help from someone that knows ACPI. Should it be something like this for example: // Lenovo ThinkPad X240 Keyboard Map. DefinitionBlock("", "SSDT", 2, "X240", "KBD", 0) { External (_SB.PCI0.LPC.EC, DeviceObj) External (_SB.PCI0.LPC.KBD, DeviceObj) External (_SB.PCI0.LPC.EC.XQ14, MethodObj) Scope (_SB.PCI0.LPC.EC) { Method (_Q14, 0, NotSerialized) // (F15) - Brightness Up { If (_OSI ("Darwin")) { Notify (KBD, 0x0406) } Else { \_SB.PCI0.LPC.EC.XQ14 () } } } } Or it is wrong, is there a way to just call the XQ14 method instead of all the code of XQ14. Also second question is, should i add the If (_OSI ("Darwin")) after every method _Qxx or i can add it somewhere in the beginning of the SSDT ? Current SSDT is: // Lenovo ThinkPad X240 Keyboard Map. DefinitionBlock("", "SSDT", 2, "X240", "KBD", 0) { External (_SB.PCI0.LPC.EC, DeviceObj) External (_SB.PCI0.LPC.KBD, DeviceObj) Scope (_SB.PCI0.LPC.EC) { Method (_Q14, 0, NotSerialized) // (F15) - Brightness Up { Notify (KBD, 0x0406) } Method (_Q15, 0, NotSerialized) // (F14) - Brightness Down { Notify (KBD, 0x0405) } Method (_Q6A, 0, NotSerialized) // (F4) Microphone Mute - Siri { Notify (KBD, 0x033E) } Method (_Q16, 0, NotSerialized) // Projector / Mirror mode { Notify (KBD, 0x046E) } Method (_Q64, 0, NotSerialized) // (F8) Radio ON/OFF - Notification Center { Notify (KBD, 0x0342) } Method (_Q66, 0, NotSerialized) // (F16) Settings - System Preferences... { Notify (KBD, 0x0367) } Method (_Q67, 0, NotSerialized) // (F17) Windows Search - Spotlight Search { Notify (KBD, 0x0368) } Method (_Q68, 0, NotSerialized) // (F18) App Switcher - Mission Control { Notify (KBD, 0x0369) } Method (_Q69, 0, NotSerialized) // (F19) Start Menu - Launchpad { Notify (KBD, 0x036A) } } } Thanks ! Your subject there's nothing to do about OC. Topic moved! Link to comment Share on other sites More sharing options...
Guest 5T33Z0 Posted May 23, 2021 Share Posted May 23, 2021 (edited) @Sniki I am trying to fix the same issue on my T530. Brightness keys don't work in WIndows 10 also. My current SSDT for Brightness looks like this: DefinitionBlock ("", "SSDT", 2, "ACDT", "BrightFN", 0x00000000) { External (_SB_.PCI0.LPC_.EC__, DeviceObj) External (_SB_.PCI0.LPC_.EC__.XQ14, MethodObj) // 0 Arguments External (_SB_.PCI0.LPC_.EC__.XQ15, MethodObj) // 0 Arguments External (_SB_.PCI0.LPC_.KBD_, DeviceObj) Scope (_SB.PCI0.LPC.EC) { Method (_Q14, 0, NotSerialized) // _Qxx: EC Query, xx=0x00-0xFF { If (_OSI ("Darwin")) { Notify (KBD, 0x0406) } Else { \_SB.PCI0.LPC.EC.XQ14 () } } Method (_Q15, 0, NotSerialized) // _Qxx: EC Query, xx=0x00-0xFF { If (_OSI ("Darwin")) { Notify (KBD, 0x0405) } Else { \_SB.PCI0.LPC.EC.XQ15 () } } } } My guess ist to disable the binary renames for _Q14 and _Q15 etc and add these renames to this SSDT instead. So it would say something like this: - If OSI is Darwin, rename _Q14 and _Q15 to XQ14 and XQ15 and then do what's in the "Scope". But I don't know how to do it either Edited May 23, 2021 by 5T33Z0 Link to comment Share on other sites More sharing options...
deeveedee Posted May 23, 2021 Share Posted May 23, 2021 (edited) I'm definitely missing something, because I don't understand why your approach doesn't work for you; specifically, renaming _Q14 to XQ14 combined with defining a new _Q14 as you have done: // New _Q14 (requires renaming original _Q14 -> XQ14) Method (_Q14, 0, NotSerialized) { If (_OSI ("Darwin")) { // MacOS brightness code } Else { // If running Windows, call the original _Q14 (renamed to XQ14) \_SB.PCI0.LPC.EC.XQ14 () } } Your new _Q14 is invoked when running both macOS and Windows, but when running Windows, your new _Q14 calls the old _Q14 (which has been renamed to XQ14). Edited May 23, 2021 by tonyx86 Link to comment Share on other sites More sharing options...
Guest 5T33Z0 Posted May 23, 2021 Share Posted May 23, 2021 I don't know either. If I boot windows via the BIOS Boot menu bypassing OpenCore, the Brightness keys work just fine, since nothing is injected. Link to comment Share on other sites More sharing options...
deeveedee Posted May 23, 2021 Share Posted May 23, 2021 Are you able to post your extracted DSDT (before patch), your DSDT after your rename and you SSDT_Q14? Link to comment Share on other sites More sharing options...
vit9696 Posted May 24, 2021 Share Posted May 24, 2021 Use Base and Count: 1. Blindly replacing all the occurancies may result in some code being routed incorrectly. Link to comment Share on other sites More sharing options...
Guest 5T33Z0 Posted May 24, 2021 Share Posted May 24, 2021 Thanks for your replies @vit9696 I modiefied the Renames _Q14 and _Q15 to XQ14 and XQ15: _Q14 to XQ14 Base: \_SB.PCI0.LPC.EC Find: 5F513134 Replace: 58513134 Count: 1 _Q15 to XQ15 Base: \_SB.PCI0.LPC.EC Find: 5F513135 Replace: 58513135 Count: 1 Working fine in macOS, no change in Windows. @tonyx86 Here's zip with the clean dsdt as .aml and the dsdt after OC does its thing (as .dsl) T530_DSDTs.zip Link to comment Share on other sites More sharing options...
deeveedee Posted May 24, 2021 Share Posted May 24, 2021 (edited) @5T33Z0 Have you conducted your test with only your _Q14->XQ14/_Q15->XQ15 rename patches (and associated SSDTs). Your DSDT patches are extensive. I'm wondering if your other patches could be introducing a condition that masks the actual problem. To isolate the _Q14/_Q15 patches, I'd suggest a test that includes only the _Q14/_Q15 renames (and SSDT_Q14/_Q15). If brightness works in Windows with only this patch, then the problem is something else. EDIT: If this simple test does not work in Windows, could you attach your SSDT_Q14 and SSDT_Q15 (extracted with MaciASL from within MacOS using MaciASL->File->New from ACPI)? EDIT2: If this simple test does work in Windows (meaning that your _Q14/_Q15 patches are working), try removing your VID->IGPU rename patch and testing Windows again. Edited May 24, 2021 by tonyx86 Added request for SSDT; Added suggesting to remove IGPU rename Link to comment Share on other sites More sharing options...
Guest 5T33Z0 Posted May 24, 2021 Share Posted May 24, 2021 (edited) @tonyx86 Your guess was right: after I disabled the 2 PCIO.VID to IGPU patches for Thinkpads by Rehabman, Brightness worked in Windows again. But unfortunately Brightness control no longer works in macOS. Theses are the 2 VID to IGPU Patches. I don't really understand how they work considering how they translate back into text which I can't find a single match for in the clean DSDT, but they work. Comment: change PCI.VID to PCI.IGPU#1 Find: 50434930 5649445F >> Translates to: PCI0VID_ Replace: 50434930 49475055 >> Translates to: PCI0IGPU Comment: change PCI.VID to PCI.IGPU#2 Find: 5649445F 085F4144 520C0000 0200 >> Translates to: VID__ADR Replace: 49475055 085F4144 520C0000 0200 >> Translates to Replace: IGPU_ADR I had a look in the clean DSDT and the "Device (VID)" appears in 2 Locations: \_SB.PCI0.VID and \_SB.PCI0.PEG.VID Maybe these renames have to be incorporated in the SSDT instead of using binary renames to resolve the issue? Edited May 24, 2021 by 5T33Z0 Link to comment Share on other sites More sharing options...
deeveedee Posted May 24, 2021 Share Posted May 24, 2021 (edited) I think you need to look more closely at your VID->IGPU rename. You already know that this VID->IGPU rename is not required for WEG. There may be a BASE/Count issue with VID->IGPU that you need to investigate. EDIT: It might help you to search all ACPI for VID (not just DSDT). EDIT2: Note that I do not need to rename VID->IGPU on my HP laptop. Brightness works with just the _Qxx patches. Edited May 24, 2021 by tonyx86 Link to comment Share on other sites More sharing options...
Guest 5T33Z0 Posted May 24, 2021 Share Posted May 24, 2021 It's probably not located in the DSDT, since I can't find these expressions in there. But I don't know where to look. But at the end of the day it's not a big deal, since I rarely use Windows and if I have to, I can always boot it from the BIOS bootmenu. Link to comment Share on other sites More sharing options...
deeveedee Posted May 24, 2021 Share Posted May 24, 2021 (edited) If you want to find references to VID, extract your ACPI using Rehabman's methods and then grep for VID. I think you should be able to find a way to enable MacOS brightness keys without the VID->IGPU rename or by restricting the rename with BASE/Count. Back to the original query - the OC ACPI patches work exactly as intended. What you're finding is that renames can have consequences. EDIT: By the way - my "guess" was based on a diff of your patched and unpatched DSDT. The only difference between the _Q14 and XQ14 methods is VID/IGPU. It was a safe guess. Edited May 24, 2021 by tonyx86 Link to comment Share on other sites More sharing options...
Guest 5T33Z0 Posted May 24, 2021 Share Posted May 24, 2021 (edited) @tonyx86 I had a look through the tables from the dump that I made with clover not too long ago. I think I found the table these renames apply to: SSDT-0-TP-SSDT2.aml So I have to change the base and the Table signature, I guess? Edited May 24, 2021 by 5T33Z0 Link to comment Share on other sites More sharing options...
deeveedee Posted May 24, 2021 Share Posted May 24, 2021 (edited) @5T33Z0 I think it would be easier to figure out why the brightness keys don't work in macOS without the VID rename. Are you familiar with Rehabman's ACPI Debug? I used it extensively when figuring out ACPI patches for my HP laptop and it still works great with OC 0.6.9 and Catalina/Big Sur. It's a bit tedious, but I think it's worth it. Let me know if you need help. Essentially, you're going to place debug statement in each method to determine where your brightness patches fail in macOS. EDIT: a good starting point (one that may offer clues) is for you to diff SSDT-0-TP before and after your VID rename. Do the same diff on other SSDTs that include VID (if there are any). Edited May 24, 2021 by tonyx86 Link to comment Share on other sites More sharing options...
deeveedee Posted May 24, 2021 Share Posted May 24, 2021 (edited) @5T33Z0 Be careful with VID - your ACPI includes two VID devices: one in Scope PCI0.PEG.VID and one in Scope PCIO.VID. Is it possible that you are patching the wrong VID (or confusing the two VIDs in your patches)? Not sure. I remember a Rehabman discussion where there was talk of renaming one VID to GFX0 and one VID to IGPU (to avoid the consusion). EDIT: Note that I'm still not suggesting that the VID->IGPU and/or VID->GFX0 rename is the way to go (I'd prefer to find a solution without renaming). I'm just pointing this out so you're aware of the potential confusion between the two VIDs. Edited May 24, 2021 by tonyx86 Link to comment Share on other sites More sharing options...
Guest 5T33Z0 Posted May 24, 2021 Share Posted May 24, 2021 Uhhh,. I already told you about the 2 different locactions of VID about 2 hours ago… but I will keep it in mind… Link to comment Share on other sites More sharing options...
deeveedee Posted May 24, 2021 Share Posted May 24, 2021 (edited) @5T33Z0 Yes - I see you did. MIssed that. I guess I've reached my limits, but I think you're now on the right track. You're welcome. Edited May 24, 2021 by tonyx86 Link to comment Share on other sites More sharing options...
Guest 5T33Z0 Posted May 24, 2021 Share Posted May 24, 2021 (edited) Thanks for your help stearing me in the rigtht direction! Edited May 24, 2021 by 5T33Z0 Link to comment Share on other sites More sharing options...
deeveedee Posted May 24, 2021 Share Posted May 24, 2021 @5T33Z0 No problem. Your rename patches here are very specific (long hex matches). If you still want to pursue this with VID->IGPU rename, make sure your rename patches are also being applied to SSDT-0-TP. Do the diff (clean and patched) of the SSDT to make sure. Link to comment Share on other sites More sharing options...
Guest 5T33Z0 Posted May 25, 2021 Share Posted May 25, 2021 (edited) @tonyx86 It's fixed. All I had to do was to remove the Table Signature "DSDT" from the renames and now Brightness Keys work fine in Windows as well. @Sniki Here's the Solution: 1. Add these 4 binary renames: Comment: change _Q14 to XQ14 Base: \_SB.PCI0.LPC.EC Find: 5F513134 Replace: 58513134 Count: 1 Comment: change _Q15 to XQ15 Base: \_SB.PCI0.LPC.EC Find: 5F513135 Replace: 58513135 Count: 1 Comment: change PCI.VID to PCI.IGPU#1 Find: 50434930 5649445F Replace: 50434930 49475055 Comment: change PCI.VID to PCI.IGPU#2 Find: 5649445F 085F4144 520C0000 0200 Replace: 49475055 085F4144 520C0000 0200 2. Add this ACPI to ACPI Folder and config.plist: SSDT-BKEYS.aml Edited May 25, 2021 by 5T33Z0 Link to comment Share on other sites More sharing options...
deeveedee Posted May 25, 2021 Share Posted May 25, 2021 @5T33Z0 So you confirmed that the rename was not being applied to the SSDTs. Great detective work! Link to comment Share on other sites More sharing options...
Allan Posted May 27, 2021 Share Posted May 27, 2021 And @Sniki did you solve your problem? To help the other users we can mark this topic as [Solved] Link to comment Share on other sites More sharing options...
Recommended Posts