-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get ACPI notification for brightness keys from GFX0.DD1F/DD02 #22
Conversation
Almost missed a warning. Xcode editor is broken due to a special character and failed to display git revision and warning in that file. |
Hmm, usually people just write a call to PS2K when hitting this notification in their ACPI. At least I did very long ago. Is it really a good idea to change that in the first place? If it is, I strongly do not like hardcoding the ACPI path for the devices. The device should be possible to match by |
My starting point is to eliminate the additional work on SSDT. |
Hmmm, could you provide some ACPI dumps? I wonder if we can at least use some parent device… |
BrightnessSample.zip |
On my Dell Latitude 7480 (i5-6300U/HD520 Skylake based), both DD02 and DD1F devices are defined as external and not found at any of the system ACPI tables. Neither _Q14 or _Q15 methods are available. The only call for brightness adjusts 0x86/0x87 are under BRT6 method. Not sure this would be applicable to all devices out there but to perhaps certain use cases. |
There is one common thing between all these DSDTs. These devices sit on a graphics card, so you could look up a graphics card by a PCI class code (check Lilu code), and then find its child devices. If necessary, we could make VoodooPS2 depend on Lilu actually.
|
Exactly, the majority of the people who will need this, do use IGPU and have custom SSDT/Patch to map to Brightness keys. Because as you said DGPU(s) are more complicated and most of them don't work as they use something like Optimus (nvidia) and the AMD hybrid. Thanks ! |
I do not believe we should completely ignore dGPU machines. E.g. in SNB times there were many machines without IGPU at all. |
No, i actually didn't mean to ignore them, just meant to say that this targets the majority. |
Just realized gIODTPlane might be a good start point and got the following code working on Big Sur (Kernel Collection), but failed for Catalina. Maybe something's wrong with kext loading? I suppose init() should always happen before start().
|
You are doing matching in parallel with IODeviceTree population. It is not instant. If you check e.g. Lilu code it is waiting for devices to publish for that very reason. |
// Waiting for IGPU | ||
size_t counter = 20; | ||
while (counter--) { | ||
if ((entry = IORegistryEntry::fromPath("/PCI0/IGPU", gIODTPlane))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, why not to iterate over the devices and look for an intel-based vendor. This is just ugly, as not all PCI root hubs are named PCI0 even. Have a look at https://github.com/acidanthera/Lilu/blob/master/Lilu/Sources/kern_devinfo.cpp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I have little knowledge with this situation. I found some gen1 laptop examples but the IGPU is still under PCI0
.
My assumption here is that the user either had the old-school GFX0
to IGPU
patch, or adopted WhateverGreen that provided gen1 support recently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like I said, it is not always the case. Especially on devices with multiple PCI lanes and exotic chipsets. Please change that.
Please try the latest addition I pushed in your branch. |
Just fixed my laptop. There's a panic at |
The panic occurs when comparing the casted pointer from |
Not good, I do not think we should avoid
|
My bad, I thought |
So, this looks good to me. Would you update the changelog mentioning Lilu dependency and the new features? Afterwards I will merge. |
Just after found the brightness panel, there was a legacy routine to adjust the brightness via ACPI method. It's only documented in https://www.tonymacx86.com/threads/new-voodoops2controller-keyboard-trackpad.75649/post-560175. Required DSDT patch involves proxy ACPI calls to Should it be depreciated for modern SSDT-PNLF? Or improve that by calling these methods directly? |
Hmm. I might miss something. PNLF SSDT is just the code used to do two things:
Therefore there are two routes to change the brightness:
I think on the laptops you normally feed an SSDT to rebind some OEM keys to macOS brightness keys to make sure that the brightness keys on your keyboard actually cause the backlight change. Now, how does that correlate with these changes? I am starting to wonder why do we need to directly adjust the backlight via ACPI methods?! |
You are right, that's the old way to manipulate |
Yes, I do understand why we need that when the keys are not dispatched via PS/2, and we only get an ACPI notification. I myself patched an ACPI once to achieve exactly that effect instead of changing the driver, but in all other cases it should be pretty much useless. I also wonder whether there are systems that send both a notification and a keycode out of the box. If they do exist, perhaps we should provide a more or less intuitive way to disable the behaviour we have just added? What about a property in the GPU (the one with the panel) and a boot argument? The property could be named |
I think the latter issue is already addressed and tested when the old |
Hmmm, right. Let's assume it is enough to avoid the conflict for now. Please update the changelog and I will merge later today. |
It seems that there's an exception on ICL laptop(s).
Currently following changes work for that laptop, and I'm still finding more samples.
|
However, it's quite weird that if
Per ACPI spec, "If the output connector does not exist (when undocked), _DCS returns 0x00." |
Unpleasant, but I guess we still can add more addresses. At least for now. Please submit a PR when the situation is more clear. |
I suppose there is something wrong with ICL driver when initializing panel or with OEM's configuration. If it's the latter case, I think |
After comparing ioreg from multiple vendors, most of them both failed to set display output device address correctly except Dell. Under Linux, the address for I'm asking for some more reports from Comet Lake ones, but maybe there won't be issues with old generation graphics. So the proposed changes might be
|
EC query for brightness key usually notifies a device under IGPU(GFX0).
For example:
The device usually has an
_ADR
of 0x400 and is named asDD1F
on Haswell+ machines (DD02
for Sandy Bridge). By subscribing to ACPI notification of this device, brightness key will work out of box.According to ACPI Spec Appendix B.6,
0x86
is for Increase Brightness and0x87
is for Decrease Brightness. It also defines0x85
for Cycle Brightness,0x88
for Zero Brightness and0x89
for Display Device Off. However latter ones don't have corresponding ADB key and are rarely used or handled by firmware.For machines with patched DSDT, possible duplicated input will be ignored for compatibility.
There's also
_BCL
,_BCM
,_BQC
method to adjust panel brightness. Are them deprecated now in favor of SSDT-PNLF? Rehabman introducedKBCL
,KBCM
,KBQC
under PS2K to call these methods. But this part haven't been updated for a long time.