Contribute
Register

[Guide] Patching DSDT/SSDT for LAPTOP backlight control

Actually I didn't install Clover yet on my system 'til it's not completely stable. Can I install those scripts on my usb stick ?
 
Actually I didn't install Clover yet on my system 'til it's not completely stable. Can I install those scripts on my usb stick ?

I don't know if the "RC scripts" work on the USB. I've never tried it. You're welcome to try. But NVRAM with EmuVariable will not work without them.
 
I installed clover on my hdd, and brightness is kept between reboots :headbang:
 
I can't seem to get this working on my laptop. I've extracted my native dsdt/ssdt files using linux and disassembled them using iasl. I then opened the dsl files and applied the patches, compiled with no errors and saved as acpi binary. What am I doing wrong? I applied the haswell patches to the correct ssdt file containing gfx0 and 0x00020000 also rename gfx0 to igpu to both dsdt and ssdt. Both files are placed in efi/clover/acpi/patched
 
I can't seem to get this working on my laptop. I've extracted my native dsdt/ssdt files using linux and disassembled them using iasl. I then opened the dsl files and applied the patches, compiled with no errors and saved as acpi binary. What am I doing wrong? I applied the haswell patches to the correct ssdt file containing gfx0 and 0x00020000 also rename gfx0 to igpu to both dsdt and ssdt. Both files are placed in efi/clover/acpi/patched

Read the guide carefully.

- Did you save them to the correct location with correct names, such that they load via the bootloader?
- If you're using Clover, did you set the order with SortedOrder?
- Did you drop the corresponding OEM tables (DropOem=true or DropSSDT=Yes depending on bootloader)
- If your laptop has nvidia, did you disable it?
- Do you see a brightness slider in SysPrefs->Displays
- Do you have already QE/CI implemented (it is a pre-requisite)
 
Read the guide carefully.

- Did you save them to the correct location with correct names, such that they load via the bootloader?
- If you're using Clover, did you set the order with SortedOrder?
- Did you drop the corresponding OEM tables (DropOem=true or DropSSDT=Yes depending on bootloader)
- If your laptop has nvidia, did you disable it?
- Do you see a brightness slider in SysPrefs->Displays
- Do you have already QE/CI implemented (it is a pre-requisite)


Ahh I didn't drop OEM tables. Backlight control is working now, Thank you.
 
Hello I am trying to follow your guide but I can not complete a pass!

I extract the DSDT AND SSDT from clover, I applied the patch with verie maciASL both the DSDT that the SSDT-7 (contains graphics) and the brightness and the video card that has a HD4400 is recognized regularly, while the brightness adjustment using fn + f11-f12 no!

I can not figure out where to apply the patch

Also I've found the code generated by using ACPI keys ....

February 14 00:44:25 Air-to-Tonino kernel [0]: ACPIDebug: "EC _Q1C enter"
February 14 00:44:25 Air-to-Tonino kernel [0]: ACPIDebug: "EC _Q1C exit"
February 14 00:44:30 Air-to-Tonino kernel [0]: ACPIDebug: "EC _Q1D enter"
February 14 00:44:30 Air-to-Tonino kernel [0]: ACPIDebug: "EC _Q1D exit"

I can not go on ????
 

Attachments

  • SSDT-7.dsl
    107.1 KB · Views: 223
  • SSDT-13.dsl
    113.7 KB · Views: 217
Hello I am trying to follow your guide but I can not complete a pass!

I extract the DSDT AND SSDT from clover, I applied the patch with verie maciASL both the DSDT that the SSDT-7 (contains graphics) and the brightness and the video card that has a HD4400 is recognized regularly, while the brightness adjustment using fn + f11-f12 no!

I can not figure out where to apply the patch

Also I've found the code generated by using ACPI keys ....

February 14 00:44:25 Air-to-Tonino kernel [0]: ACPIDebug: "EC _Q1C enter"
February 14 00:44:25 Air-to-Tonino kernel [0]: ACPIDebug: "EC _Q1C exit"
February 14 00:44:30 Air-to-Tonino kernel [0]: ACPIDebug: "EC _Q1D enter"
February 14 00:44:30 Air-to-Tonino kernel [0]: ACPIDebug: "EC _Q1D exit"

I can not go on ????

For the brightness *keys* you patch DSDT (that's where the EC queries _Q1C/_Q1D are located).
 
Here are some hints as to how one can align BIOS backlight levels with what ACPIBacklight sets upon reading value from nvram so that it's consistent. If you are in a boat like me, when writing LEVL value to registers used by BIOS on boot doesn’t really play that well, because it ends up lost not knowing that to set. (Yes, I had to study this all over again, after what I had posed in keyboard thread)

My BIOS can support only 16 levels (0x00 to 0x0F) of brightness, which are set 6% apart. To preserve the levels for COLD BOOT (actually, soft boot too, the reg is just called CBLV) I now use the newly added SAVE feature, which works wonders. Here’s the code if someone finds it useful .. How BIOS remaps the levels at boot was reverse engendered by performing a lot of debug sessions, thanks for ACPIDebug btw.

Code:
            Name (STPS, 0x04)  // STPS: number of steps in between for one level
            Name (CBAR, Package ()  // Cold Boot BIOS Backlight Levels
            {
                0x06, 0x06, 0x0C, 0x12, 0x18, 0x1E, 0x24, 0x2A, 0x30,
                0x36, 0x3C, 0x42, 0x48, 0x4E, 0x54, 0x5A, 0x64 
            })
            
            Name (ECAR, Package ()  // EC Backlight Levels
            {
                0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 
                0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F 
            })

            Name (_BCL, Package (0x43)  // _BCL: Brightness Control Levels
            {
                1807, 479, //ac + dc level group
                0, 25, 53, 81, 109, //0x00 level group
                137, 165, 193, 221, //0x01 level group
                249, 277, 305, 333, //0x02 level group
                361, 389, 417, 445, //0x03 level group
                473, 501, 529, 557, //0x04 level group
                585, 613, 641, 669, //0x05 level group
                697, 725, 753, 781, //0x06 level group
                809, 837, 865, 893, //0x07 level group
                921, 949, 977, 1005, //0x08 level group
                1033, 1061, 1089, 1117, //0x09 level group
                1145, 1173, 1201, 1229, //0x0a level group
                1257, 1285, 1313, 1341, //0x0b level group
                1369, 1397, 1425, 1453, //0x0c level group
                1481, 1509, 1537, 1565, //0x0d level group
                1593, 1621, 1649, 1677, //0x0e level group
                1705, 1733, 1761, 1808  //0x0f level group
            })

            // preserve brightness level for BIOS
            Method (SAVE, 1, NotSerialized)
            {
                // get level position in _BCL array
                Store (Match (_BCL, MGE, Arg0, MTR, Zero, 0x02), Local0)
                If (LEqual (Local0,Ones))
                {
                    Subtract (SizeOf (_BCL), One, Local0)
                }
                
                // divide index by the number of steps for one level
                // determine reg values for cold boot level consistency
                Divide (Local0, STPS,, Local0)
                Store (DerefOf (Index (ECAR, Local0)), Local1)
                Store (DerefOf (Index (CBAR, Local0)), Local2)
                Xor (Local2, 0x80000000, Local2)
                
                // write register values
                Store (Local2, \_SB.PCI0.IGPU.CBLV)
                // determine power source used, different regs for ac/dc power
                If (PWRS) 
                {
                    Store (Local1,BRGA)
                }
                Else 
                {
                    Store (Local1,BRGD)
                }
            }
What used to happen was - as soon as ACPIBacklight attaches, there used to be a flash where screen image disappeared for half a second, then a slight decrease in backlight level would happen, which was visible to the naked eye. I have written myself a simple bash script (attached. before you say anything - yes it’s ugly and lacks idiot-proofness) that would allow me to generate an array of backlight levels to use for _BCL, to which I can specify the start level and consistent step. No matter how long I played with _BCL output of the script, there was always this decrease in brightness level which seems to be one and a half level drop. When the panel is at full brightness at reboot (0x0F and 0x8...64) there's no drop. So I’ve decided to see that really happens there ...

rebooting with panel at full brightness:
Code:
 ACPIBacklightPanel::loadFromNVRAM()
 ACPIBacklightPanel: no /chosen/nvram, trying IODTNVRAM
 ACPIBacklightPanel: read level from nvram = 1024
 ACPIBacklightPanel: loadFromNVRAM returns 1024
 ACPIBacklightPanel: findIndexForLevel(1808) is 63
 ACPIBacklightPanel: current brightness: 1024 (1808)
 ACPIBacklightPanel: setting to value from nvram 1024nACPIBacklightPanel::setBrightnessLevelSmooth(1024)

 ACPIBacklightPanel: saveACPIBrightnessLevel SAVE(1808)
 ACPIBacklightPanel::doIntegerSet("flush", 0)
 ACPIDebug: { "SAVE Called", 0x710, }
 ACPIDebug: { "CBLV", 0x80000064, }
 ACPIDebug: { "BRGA", 0xf, }
rebooting with brightness at 2 bars - dims from 404 to 221:
Code:
 ACPIBacklightPanel::loadFromNVRAM()
 ACPIBacklightPanel: no /chosen/nvram, trying IODTNVRAM
 ACPIBacklightPanel: read level from nvram = 128
 ACPIBacklightPanel: loadFromNVRAM returns 128
 ACPIBacklightPanel: findIndexForLevel(404) is 14
 ACPIBacklightPanel: current brightness: 232 (404)
 ACPIBacklightPanel: setting to value from nvram 128nACPIBacklightPanel::setBrightnessLevelSmooth(128)
 ACPIBacklightPanel: min = 0, max = 64

 ACPIBacklightPanel: saveACPIBrightnessLevel SAVE(221)
 ACPIBacklightPanel::doIntegerSet("flush", 0)
 ACPIDebug: { "SAVE Called", 0xdd, }
 ACPIDebug: { "CBLV", 0x8000000c, }
 ACPIDebug: { "BRGA", 0x1, }

Technically, I use 17 levels, because there's no dedicated display-off button. So, same as on my MacBook Pro, the lowest possible settings turns off display backlight.

So having the information that 2 bars (level 1 for BIOS) is OSX brightness 404 I had pulled my script again ./bcl.sh -n 229 25 and I get:
Code:
                1807, 479, //ac + dc level group
                0, 229, 254, 279, 304, //0x00 level group
                329, 354, 379, 404, //0x01 level group
                429, 454, 479, 504, //0x02 level group
                529, 554, 579, 604, //0x03 level group
                629, 654, 679, 704, //0x04 level group
                729, 754, 779, 804, //0x05 level group
                829, 854, 879, 904, //0x06 level group
                929, 954, 979, 1004, //0x07 level group
                1029, 1054, 1079, 1104, //0x08 level group
                1129, 1154, 1179, 1204, //0x09 level group
                1229, 1254, 1279, 1304, //0x0a level group
                1329, 1354, 1379, 1404, //0x0b level group
                1429, 1454, 1479, 1504, //0x0c level group
                1529, 1554, 1579, 1604, //0x0d level group
                1629, 1654, 1679, 1704, //0x0e level group
                1729, 1754, 1779, 1808  //0x0f level group
Notice 404 is the set target value for 0x01 group. Recompile, replace, reboot - voila. No more screen flash and no more dimming, regardless of the level of brightness I reboot with. So.. brightness on this DELL is lvl_int*0x64+0x130.

One may think display has gotten brighter at lower levels, but it was actually too dark before, so I can’t complain at all.


Edit:
I just realized that your PNLF code on your repo has been updated to include the LMAX feature, which can scale the _BCL range based on the value read from LEVX, which then aligns everything by itself. When you had mentioned that I never bothered to look at the repo to see that it actually was. Ignorance has wasted me a couple of hours I could spare for something else.. but oh well.
 

Attachments

  • bcl.sh.zip
    1.2 KB · Views: 156
Hello thanks for the reply!
I think I found the code to be changed, but I do not know how to do that line of code I need to change?

My DSDT:
Method (_Q1C, 0, NotSerialized) // _Qxx: EC Query
{
Store (0x1C, P80H)
If (LEqual (OSTY, 0x41))
{
SMI (0xCC, One)
}

Notify (^^^IGPU.DD1F, 0x86)
}

Method (_Q1D, 0, NotSerialized) // _Qxx: EC Query
{
Store (0x1D, P80H)
If (LEqual (OSTY, 0x41))
{
SMI (0xCC, 0x02)
}

Notify (^^^IGPU.DD1F, 0x87)
}


I use this?

into method label _Q13 parent_label H_EC replace_content
begin
Store(HKNO, Local0)\n
If (LEqual(Local0,7))\n
{\n
// Brightness Down\n
Notify(\_SB.PCI0.LPCB.PS2K, 0x0205)\n
Notify(\_SB.PCI0.LPCB.PS2K, 0x0285)\n
}\n
If (LEqual(Local0,8))\n
{\n
// Brightness Up\n
Notify(\_SB.PCI0.LPCB.PS2K, 0x0206)\n
Notify(\_SB.PCI0.LPCB.PS2K, 0x0286)\n
}\n
If (LEqual(Local0,4))\n
{\n
// Mirror toggle\n
Notify(\_SB.PCI0.LPCB.PS2K, 0x026e)\n
Notify(\_SB.PCI0.LPCB.PS2K, 0x02ee)\n
}\n
end;
 
Back
Top