Full range of brightness using ACPIBacklight

Discussion in 'HP ProBook - Mavericks' started by pwd, Dec 11, 2013.

  1. pwd

    pwd

    Joined:
    Oct 10, 2013
    Messages:
    21
    Dec 11, 2013 at 12:26 PM #1
    pwd

    pwd

    Joined:
    Oct 10, 2013
    Messages:
    21
    Regarding brightness off display:
    Just found and tested a method and now I'm able to reduce screen brightness to a minimum level, just like in windows.
    Screen Shot 2013-12-11 at 14.21.51.jpg

    The display is still visible even you switched to the lowest illumination step.
    Just follow de following guide and you will se it working. The guide provides all the necessary informations to patch DSDT for an PROBOOK 4540s laptop. I cannot guarantee about it working on some other models.

    Step1:
    Find out our graphics BAR0 register (sometimes known as BAR1 register because some people count from 1...)
    Mine is at 0xC0000004 so you will notice all my "magic numbers" starting with 0xC....
    To find your BAR0/BAR1 address, you will have to look at your integrated graphics PCI configuration space.
    It will usually be the second device on PCI bus 0 (device 00:02:00)
    You can use the 64bit lspci driver from these forums and do it on your Mac.


    Step 2: --- ACTUAL PATCHES---

    Open your DSDT.aml in a DSDT Editor (see other threads for how to use this. MODIFYING DSDT MAY SCREW UP YOUR COMPUTER SO BE SURE YOU KNOW WHAT YOU'RE DOING.)

    The following needs to be placed just before the beginning of " Scope (_SB)" ( before the first occurence of this string in your DSDT). Make sure you change the magic numbers to comply with your BAR0.

    Code (Text):

    OperationRegion (BRIT, SystemMemory, 0xC0048254, 0x04)
    Field (BRIT, AnyAcc, Lock, Preserve)
    {
    LEVL, 32
    }
    OperationRegion (BRI2, SystemMemory, 0xC0048250, 0x04)
    Field (BRI2, AnyAcc, Lock, Preserve)
    {
    LEV2, 32
    }
    OperationRegion (BRI3, SystemMemory, 0xC00C8250, 0x04)
    Field (BRI3, AnyAcc, Lock, Preserve)
    {
    LEVW, 32
    }
    OperationRegion (BRI4, SystemMemory, 0xC00C8254, 0x04)
    Field (BRI4, AnyAcc, Lock, Preserve)
    {
    LEVX, 32
    }


     
    2. Now, the following assumes your graphics module is called GFX0 and that the LCD is listed as the second sub-device of GFX0. To find your graphics module, you can try and look for the line "Name (_ADR, 0x00020000)". The LCD should be the second sub device, mine is called DD02. You can use IOREG to confirm the name of your graphics (eg. GFX0). You can use the following method to identify the LCD sub-device: simply, go to your GFX0 (or equivalent), and
    then under that device, identify the sub-device that has those methods (_BCM, _BCQ, _BCL).
    YOU NEED TO REMEMBER TO NAME THIS SUB- DEVICE by adding the following line:

    Code (Text):
    Device (DD02)
    {
    Name (_HID, EisaId ("LCD1234"))
     

    3. Then, you will need to add a new device PNLF. Usually you will have to add this before the beginning of Scope _PR, or after all other devices. IF YOU ALREADY HAVE ANOTHER PNLF DEVICE, you will need to replace any other PNLF you may already have (delete it and then use my code instead).

    Code (Text):
    Device (PNLF)
    {
    Name (_HID, EisaId ("APP0002"))
    Name (_CID, "backlight")
    Name (_UID, 0x0A)
    Name (_STA, 0x0B)
    Method (_BCL, 0, NotSerialized)
    {
    Return (Package (0x13)
    {
    0x64,
    0x32,
    Zero,
    0x06,
    0x0C,
    0x12,
    0x18,
    0x1E,
    0x24,
    0x2A,
    0x30,
    0x36,
    0x3C,
    0x42,
    0x48,
    0x4E,
    0x54,
    0x5A,
    0x64
    })
    }
    Method (_BCM, 1, NotSerialized)
    {
    Store (0x80000000, LEV2)
    If (LGreaterEqual (Arg0, 0x64))
    {
    Store (0x12FF, LEVL)
    }
    Else
    {
    If (LGreaterEqual (Arg0, 0x5A))
    {
    Store (0x11FF, LEVL)
    }
    Else
    {
    If (LGreaterEqual (Arg0, 0x54))
    {
    Store (0x103A, LEVL)
    }
    Else
    {
    If (LGreaterEqual (Arg0, 0x4E))
    {
    Store (0x0EBB, LEVL)
    }
    Else
    {
    If (LGreaterEqual (Arg0, 0x48))
    {
    Store (0x0B24, LEVL)
    }
    Else
    {
    If (LGreaterEqual (Arg0, 0x42))
    {
    Store (0x0873, LEVL)
    }
    Else
    {
    If (LGreaterEqual (Arg0, 0x3C))
    {
    Store (0x065B, LEVL)
    }
    Else
    {
    If (LGreaterEqual (Arg0, 0x36))
    {
    Store (0x04C8, LEVL)
    }
    Else
    {
    If (LGreaterEqual (Arg0, 0x30))
    {
    Store (0x0396, LEVL)
    }
    Else
    {
    If (LGreaterEqual (Arg0, 0x2A))
    {
    Store (0x02B0, LEVL)
    }
    Else
    {
    If (LGreaterEqual (Arg0, 0x24))
    {
    Store (0x0266, LEVL)
    }
    Else
    {
    If (LGreaterEqual (Arg0, 0x1E))
    {
    Store (0x0218, LEVL)
    }
    Else
    {
    If (LGreaterEqual (Arg0, 0x18))
    {
    Store (0x01D1, LEVL)
    }
    Else
    {
    If (LGreaterEqual (Arg0, 0x12))
    {
    Store (0x0191, LEVL)
    }
    Else
    {
    If (LGreaterEqual (Arg0, 0x0C))
    {
    Store (0x0161, LEVL)
    }
    Else
    {
    If (LGreaterEqual (Arg0, 0x06))
    {
    Store (0x0132, LEVL)
    }
    Else
    {
    If (LGreaterEqual (Arg0, Zero))
    {
    Store (0x82, LEVL)
    }
    Else
    {
    Store (0x11FF, LEVL)
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    Method (_BQC, 0, NotSerialized)
    {
    Return (^^PCI0.IGPU.DD02._BQC ())
    }
    Method (_DOS, 1, NotSerialized)
    {
    ^^PCI0.IGPU._DOS (Arg0)
    }
    }
     
    Provided, the KEXTs were installed, this will enable your brightness slider, and it should work without problems incrementing/decrementing brightness in 17 discrete brightness steps (16 + zero state), and this is the number of steps needed to enable the brightness keys, so they will work now!

    The final step is to enable Backlight after wake-up. The 1st gen HD graphics uses two special registers to achieve this, and the following will fix it for you:
    • Search your DSDT for the method _WAK
    • Add two lines to the beginning, so that it looks like this:
    Code (Text):
    Method (_WAK, 1, Serialized)
    {
         Store (0x80000000, LEVW)
         Store (0x13121312, LEVX)

     

    The original credits for this guide come to mnorthern
    The original guide can be found here: http://www.insanelymac.com/forum/to...ss-for-intel-80860046-1st-gen-hd-gma-5700mhd/

    After you're done with editing just install this kernel extension
    View attachment ACPIBacklight.kext.zip
     
  2. nguyenmac

    nguyenmac

    Joined:
    Oct 22, 2012
    Messages:
    3,503
    Mobo:
    HP Elitebook 8470p
    CPU:
    Intel Core i5 3320M
    Graphics:
    Intel HD 4000, 1600x900
    Mobile Phone:
    iOS
    Dec 11, 2013 at 2:08 PM #2
    nguyenmac

    nguyenmac

    Joined:
    Oct 22, 2012
    Messages:
    3,503
    Mobo:
    HP Elitebook 8470p
    CPU:
    Intel Core i5 3320M
    Graphics:
    Intel HD 4000, 1600x900
    Mobile Phone:
    iOS
    Guide To Install Mavericks with Clover Bootloader

    Thank you for your discovery, pwd. I just test and it works. Here are the patches for others:

    - You have to do step 1 in pwd post to know the address of BAR0 (or BAR1)
    Example: 0xC0000004 or 0xD4000004 (my system)

    - Change the first 3 hex digits address in following patch, and apply to your DSDT:
    Code (Text):
    into definitionblock code_regex . insert
    begin
    OperationRegion (BRIT, SystemMemory, 0x[B]D40[/B]48250, 0x00800008)\n
    Field (BRIT, AnyAcc, Lock, Preserve)\n
    {\n
             LEV2,   32, \n
             LEVL,   32, \n
             Offset (0x80000), \n
             LEVW,   32, \n
             LEVX,   32\n
    }\n
    end;
     
    Apply the following patch to DSDT too:
    Code (Text):
    // may not necessary
    into device label DD02 code_regex Name\s+\(\_HID,\sEisaId\s[\s\S\)]*\)\) remove_matched;
    into device label DD02 insert begin Name (_HID, EisaId ("LCD1234"))\n end;

    // new PNLF method
    into device label PNLF remove_entry;
    into scope label _SB insert
    begin
    Device (PNLF)\n
    {\n
        Name (_HID, EisaId ("APP0002"))\n
        Name (_CID, "backlight")\n
        Name (_UID, 0x0A)\n
        Name (_STA, 0x0B)\n
        Method (_BCL, 0, NotSerialized)\n
        {\n
            Return (Package (0x13)\n
            {\n
                0x64,\n
                0x32,\n
                Zero,\n
                0x06,\n
                0x0C,\n
                0x12,\n
                0x18,\n
                0x1E,\n
                0x24,\n
                0x2A,\n
                0x30,\n
                0x36,\n
                0x3C,\n
                0x42,\n
                0x48,\n
                0x4E,\n
                0x54,\n
                0x5A,\n
                0x64\n
            })\n
        }\n
        Method (_BCM, 1, NotSerialized)\n
        {\n
            Store (0x80000000, LEV2)\n
            If (LGreaterEqual (Arg0, 0x64))\n
            {\n
                Store (0x12FF, LEVL)\n
            }\n
            Else\n
            {\n
                If (LGreaterEqual (Arg0, 0x5A))\n
                {\n
                    Store (0x11FF, LEVL)\n
                }\n
                Else\n
                {\n
                    If (LGreaterEqual (Arg0, 0x54))\n
                    {\n
                        Store (0x103A, LEVL)\n
                    }\n
                    Else\n
                    {\n
                        If (LGreaterEqual (Arg0, 0x4E))\n
                        {\n
                            Store (0x0EBB, LEVL)\n
                        }\n
                        Else\n
                        {\n
                            If (LGreaterEqual (Arg0, 0x48))\n
                            {\n
                                Store (0x0B24, LEVL)\n
                            }\n
                            Else\n
                            {\n
                                If (LGreaterEqual (Arg0, 0x42))\n
                                {\n
                                    Store (0x0873, LEVL)\n
                                }\n
                                Else\n
                                {\n
                                    If (LGreaterEqual (Arg0, 0x3C))\n
                                    {\n
                                        Store (0x065B, LEVL)\n
                                    }\n
                                    Else\n
                                    {\n
                                        If (LGreaterEqual (Arg0, 0x36))\n
                                        {\n
                                            Store (0x04C8, LEVL)\n
                                        }\n
                                        Else\n
                                        {\n
                                            If (LGreaterEqual (Arg0, 0x30))\n
                                            {\n
                                                Store (0x0396, LEVL)\n
                                            }\n
                                            Else\n
                                            {\n
                                                If (LGreaterEqual (Arg0, 0x2A))\n
                                                {\n
                                                    Store (0x02B0, LEVL)\n
                                                }\n
                                                Else\n
                                                {\n
                                                    If (LGreaterEqual (Arg0, 0x24))\n
                                                    {\n
                                                        Store (0x0266, LEVL)\n
                                                    }\n
                                                    Else\n
                                                    {\n
                                                        If (LGreaterEqual (Arg0, 0x1E))\n
                                                        {\n
                                                            Store (0x0218, LEVL)\n
                                                        }\n
                                                        Else\n
                                                        {\n
                                                            If (LGreaterEqual (Arg0, 0x18))\n
                                                            {\n
                                                                Store (0x01D1, LEVL)\n
                                                            }\n
                                                            Else\n
                                                            {\n
                                                                If (LGreaterEqual (Arg0, 0x12))\n
                                                                {\n
                                                                    Store (0x0191, LEVL)\n
                                                                }\n
                                                                Else\n
                                                                {\n
                                                                    If (LGreaterEqual (Arg0, 0x0C))\n
                                                                    {\n
                                                                        Store (0x0161, LEVL)\n
                                                                    }\n
                                                                    Else\n
                                                                    {\n
                                                                        If (LGreaterEqual (Arg0, 0x06))\n
                                                                        {\n
                                                                            Store (0x0132, LEVL)\n
                                                                        }\n
                                                                        Else\n
                                                                        {\n
                                                                            If (LGreaterEqual (Arg0, Zero))\n
                                                                            {\n
                                                                                Store (0x82, LEVL)\n
                                                                            }\n
                                                                            Else\n
                                                                            {\n
                                                                                Store (0x11FF, LEVL)\n
                                                                            }\n
                                                                        }\n
                                                                    }\n
                                                                }\n
                                                            }\n
                                                        }\n
                                                    }\n
                                                }\n
                                            }\n
                                        }\n
                                    }\n
                                }\n
                            }\n
                        }\n
                    }\n
                }\n
            }\n
        }\n
        Method (_BQC, 0, NotSerialized)\n
        {\n
            Return (^^PCI0.IGPU.DD02._BQC ())\n
        }\n
        Method (_DOS, 1, NotSerialized)\n
        {\n
            ^^PCI0.IGPU._DOS (Arg0)\n
        }\n
    }\n
    end;
     
    Install ACPIBacklight.kext and you're good to go!

    What the new brightness patch fixes: Get all-range brightness, from lowest to highest, without having to put display to sleep.

    Issues:
    - Brightness levels are still different between before/after wake display from sleep, and not correct: Before wake: 4 max brightness levels are the same. After wake: 6 max brightness levels are the same.
    - Brightness can't be saved after restart, always at highest brightness level at startup.

    I'd prefer the old way.
     
  3. RehabMan

    RehabMan Moderator

    Joined:
    May 3, 2012
    Messages:
    149,147
    Mobo:
    Intel DH67BL
    CPU:
    Core i7-2600K
    Graphics:
    Intel HD 3000
    Mac:
    MacBook Air
    Mobile Phone:
    iOS
    Dec 11, 2013 at 2:24 PM #3
    RehabMan

    RehabMan Moderator

    Joined:
    May 3, 2012
    Messages:
    149,147
    Mobo:
    Intel DH67BL
    CPU:
    Core i7-2600K
    Graphics:
    Intel HD 3000
    Mac:
    MacBook Air
    Mobile Phone:
    iOS
    This deserves its own thread.

    There may be some improvements that could be made. I've been looking for a reason to fix the bugs in ACPIBacklight.kext...
     
  4. frantisek.nesveda

    frantisek.nesveda

    Joined:
    Jun 25, 2011
    Messages:
    91
    Mobo:
    HP Probook 4530s
    CPU:
    Intel Core i3 2310M
    Graphics:
    Intel HD 3000
    Dec 11, 2013 at 9:39 PM #4
    frantisek.nesveda

    frantisek.nesveda

    Joined:
    Jun 25, 2011
    Messages:
    91
    Mobo:
    HP Probook 4530s
    CPU:
    Intel Core i3 2310M
    Graphics:
    Intel HD 3000
    I can confirm this works on my Probook 4530s, the address of the BAR1 register was 0xC4000004.

    However, I have the same problem with brightness levels as nguyenmac, and I also found out that the quarter-step brightness levels can't be accessed (you can increase/decrease the brightness with Option+Shift+Brightness up/down, it works with volume too), the key combination just doesn't move the brightness slider. This was partially working before the patch (the brightness slider was moving in quarter-steps, but the actual backlight intensity was not changing).

    I'll try to mess with the values in the DSDT sometime tomorrow, I'll see if I can get the levels to scale better.
     
  5. pwd

    pwd

    Joined:
    Oct 10, 2013
    Messages:
    21
    Dec 11, 2013 at 9:47 PM #5
    pwd

    pwd

    Joined:
    Oct 10, 2013
    Messages:
    21

    check this post there seems to be an update to the DSDT algorithm: http://www.insanelymac.com/forum/to...el-80860046-1st-gen-hd-gma-5700mhd/?p=1903273
     
  6. RehabMan

    RehabMan Moderator

    Joined:
    May 3, 2012
    Messages:
    149,147
    Mobo:
    Intel DH67BL
    CPU:
    Core i7-2600K
    Graphics:
    Intel HD 3000
    Mac:
    MacBook Air
    Mobile Phone:
    iOS
    Dec 11, 2013 at 9:52 PM #6
    RehabMan

    RehabMan Moderator

    Joined:
    May 3, 2012
    Messages:
    149,147
    Mobo:
    Intel DH67BL
    CPU:
    Core i7-2600K
    Graphics:
    Intel HD 3000
    Mac:
    MacBook Air
    Mobile Phone:
    iOS
    I think all such problems (and more cool things) can be fixed with changes in ACPIBacklight.kext and DSDT work.
     
  7. RehabMan

    RehabMan Moderator

    Joined:
    May 3, 2012
    Messages:
    149,147
    Mobo:
    Intel DH67BL
    CPU:
    Core i7-2600K
    Graphics:
    Intel HD 3000
    Mac:
    MacBook Air
    Mobile Phone:
    iOS
    Dec 12, 2013 at 1:11 AM #7
    RehabMan

    RehabMan Moderator

    Joined:
    May 3, 2012
    Messages:
    149,147
    Mobo:
    Intel DH67BL
    CPU:
    Core i7-2600K
    Graphics:
    Intel HD 3000
    Mac:
    MacBook Air
    Mobile Phone:
    iOS
  8. frantisek.nesveda

    frantisek.nesveda

    Joined:
    Jun 25, 2011
    Messages:
    91
    Mobo:
    HP Probook 4530s
    CPU:
    Intel Core i3 2310M
    Graphics:
    Intel HD 3000
    Dec 12, 2013 at 10:56 AM #8
    frantisek.nesveda

    frantisek.nesveda

    Joined:
    Jun 25, 2011
    Messages:
    91
    Mobo:
    HP Probook 4530s
    CPU:
    Intel Core i3 2310M
    Graphics:
    Intel HD 3000
    Thanks for the info, this worked well for me. Now the brightness levels before and after display sleep are the same, also every level from 0 to 16 is different. Sadly, the steps are still uneven and the quarter-steps don't work.

    I also have changed the first two brightness values in the DSDT, as they correspond to the brightness set on boot (one for AC power, one for battery), now the brightness is set to the level 1 after boot.

    Some links with interesting info:
    http://www.acpi.info/DOWNLOADS/ACPIspec40a.pdf
    - ACPI specification, on page 704 is the info for brightness methods

    http://whitequark.org/blog/2011/09/04/fixing-acpi-on-samsung-n250/
    - partially explained DSDT brightness patches

    http://tdev.me/2010/12/apple-hardware-dumps/#MacBookPro8,1
    - DSDT dumps from real MacBooks
    - I read MacBookPro8,2 ACPI dump and the original method for brightness level setting is a little more complex than what we are using

    http://www.insanelymac.com/forum/topic/236835-updated-2012-genericbrightnesskext/
    - another brightness kext with sources and utilities (largely similar to the original one)

    I'm attaching my current DSDT.dsl with the new set of patches and changed values, in case anyone wants to take a look. The important parts are on lines 373 - 429 and 2665 - 2703.

    I've also re-compiled the original kext with XCode 5, I don't know if it improves anything, but I'm attaching it here just in case.

    If I have time during the weekend, I will try to write some utility to manually set the brightness intensity hardware level (e.g. 0x012C) from the command line (to test which levels are right for our display), but I don't promise any result just yet, because the exam time is coming and free time is precious these days.

    I hope RehabMan will have some good results with his kext, as he is far more experienced with these matters than I am.
     

    Attached Files:

  9. mr-andrek

    mr-andrek

    Joined:
    Mar 12, 2013
    Messages:
    288
    Mobo:
    HP ProBook 4530s
    CPU:
    Intel Core i3 2330m
    Graphics:
    Intel HD 3000
    Mac:
    MacBook Pro
    Mobile Phone:
    iOS
    Dec 12, 2013 at 11:13 AM #9
    mr-andrek

    mr-andrek

    Joined:
    Mar 12, 2013
    Messages:
    288
    Mobo:
    HP ProBook 4530s
    CPU:
    Intel Core i3 2330m
    Graphics:
    Intel HD 3000
    Mac:
    MacBook Pro
    Mobile Phone:
    iOS
    Fantastic job guys on finding all this stuff, I can't wait to try any simpler solution that I bet someone will come up with. Great job nevertheless and thanks for contributing!
     
  10. frantisek.nesveda

    frantisek.nesveda

    Joined:
    Jun 25, 2011
    Messages:
    91
    Mobo:
    HP Probook 4530s
    CPU:
    Intel Core i3 2310M
    Graphics:
    Intel HD 3000
    Dec 12, 2013 at 1:08 PM #10
    frantisek.nesveda

    frantisek.nesveda

    Joined:
    Jun 25, 2011
    Messages:
    91
    Mobo:
    HP Probook 4530s
    CPU:
    Intel Core i3 2310M
    Graphics:
    Intel HD 3000
    A small progress update:
    The maximum hardware brightness value the display of 4530s supports seems to be 0x0640, any levels higher than that shine the same.
    Also, if you put 67 brightness values in the DSDT (two for default levels on boot and 65 for the actual brightness levels), the quarter-steps work too.

    I tried putting a smaller number of values (25) in the DSDT, and it booted fine, the brightness slider in System Preferences worked fine (e.g. setting the brightness to 50% used a brightness value from the middle of the DSDT packet), but the brightness keys didn't work right, there was probably some ratio division problem because there was more possible values than brightness steps, but too little for the quarter-steps.

    Saving the brightness across reboots still doesn't work, I think we should try to add a SAVE method for the PNLF device. Will look into that in the evening.

    I am attaching my current DSDT.dsl for anyone who wants to take a look. The important parts are on lines 373 - 477 and 2713 - 2750.
     

    Attached Files:

Share This Page