Contribute
Register

[Guide] Laptop backlight control using AppleBacklightFixup.kext

Mac OS:10.13.5

I download Xcode and Compile success.
--> Compilation complete. 0 Errors, 0 Warnings, 0 Remarks, 0 Optimizations

and run:
sudo cp -R ~/Projects/probook.git/kexts/AppleBacklightInjector.kext /Library/Extensions
sudo kextcache -I /

Then:
/ locked; waiting for lock.

Lock acquired; proceeding.

Kext with invalid signatured (-67062) allowed: <OSKext 0x7fdcf8d07940 [0x7fff93597af0]> { URL = "AppleBacklightInjector.kext/ -- file:///Library/Extensions/", ID = "org.rehabman.injector.AppleBacklightInjector" }

KernelCache ID: 96383C200EA9A2BFDD057C71E209F319

Kext with invalid signatured (-67062) allowed: <OSKext 0x7fb04982d0a0 [0x7fff93597af0]> { URL = "AppleBacklightInjector.kext/ -- file:///Library/Extensions/", ID = "org.rehabman.injector.AppleBacklightInjector" }

What's wrong!
Please help!

No "Problem Reporting" files attached.
Read FAQ, "Problem Reporting" again. Carefully. Attach all requested files/output.
https://www.tonymacx86.com/threads/faq-read-first-laptop-frequent-questions.164990/
Use the gen_debug.sh tool mentioned in the FAQ, that way it is less likely you'll omit something.
 
I followed this guide, but the backlight panel still doesn't work, and in fact the slider moves by itself when you have the panel open.
I attach here the output of the gen script, my EFI minus themes, and a copy of my dsdt patched to remove auto backlight files (which is apparently not working as the slider is moving itself).
 

Attachments

  • debug_28502.zip
    4 MB · Views: 194
  • clover minus themes.zip
    1.6 MB · Views: 207
  • DSDTwithbatteryandigpu.dsl
    1.2 MB · Views: 103
I followed this guide, but the backlight panel still doesn't work, and in fact the slider moves by itself when you have the panel open.
I attach here the output of the gen script, my EFI minus themes, and a copy of my dsdt patched to remove auto backlight files (which is apparently not working as the slider is moving itself).

Read post #1 regarding Fake ALS.

Note: You should remove SSDT-1-SaSsdt.aml from ACPI/patched. It serves no purpose at all there.
 
Read post #1 regarding Fake ALS.

Note: You should remove SSDT-1-SaSsdt.aml from ACPI/patched. It serves no purpose at all there.
Thank you for the hint, Fake ALS has stopped the auto adjustment, but still no brightness control.

I deleted SSDT-1, I put it there as I renamed the GPU to IGPU, and it was also present in SSDT-1, I thought having it defined different ways in DSDT and SSDT might have caused problems.
 
Thank you for the hint, Fake ALS has stopped the auto adjustment, but still no brightness control.

I deleted SSDT-1, I put it there as I renamed the GPU to IGPU, and it was also present in SSDT-1, I thought having it defined different ways in DSDT and SSDT might have caused problems.

No "Problem Reporting" files attached.
Read FAQ, "Problem Reporting" again. Carefully. Attach all requested files/output.
https://www.tonymacx86.com/threads/faq-read-first-laptop-frequent-questions.164990/
Use the gen_debug.sh tool mentioned in the FAQ, that way it is less likely you'll omit something.
 
Overview

This is going to be a quick guide for how to implement backlight control for laptop internal displays on macOS/OS X.

There is the original backlight guide using ACPIBacklight.kext or IntelBacklight.kext here: https://www.tonymacx86.com/threads/guide-patching-dsdt-ssdt-for-laptop-backlight-control.152659/

Note: The guide above is still useful for mapping your brightness keys. After you have working brightness via SysPrefs->Displays, refer to the original guide for activating the brightness keys.

But as you probably already know, IntelBacklight.kext and ACPIBacklight.kext were broken by the 10.12.4 update.

I wrote about how to use a patched AppleBacklight.kext or AppleBacklightInjector.kext a while ago: https://www.tonymacx86.com/threads/...een-using-patched-applebacklight-kext.121031/

That guide can be a bit complex for the novice. This guide will simplify it by using three components that all work together to create the solution:

- a single pre-built AppleBacklightInjector.kext
- a patch for AppleBacklight in config.plist/KernelAndKextPatches/KextsToPatch
- SSDT-PNLF.aml to activate the AppleBacklight kext


Requirements

This guide is only for Intel graphics laptops.
It will work with Arrandale, Sandy Bridge, Ivy Bridge, Haswell, Broadwell, Skylake and Kaby Lake.

Preparation

For brevity, we are going to use Terminal to acquire the files...

To start, make sure you have the Xcode command line tools. At a fresh install, you can just attempt to use 'git' in Terminal:

Code:
git

The system will prompt you to download and install the tools.

After you have downloaded and installed the developer tools, we can use them to acquire the various github content we need for this guide.

Make the Projects directory if you haven't already:
Code:
mkdir ~/Projects
cd ~/Projects

Clone the probook repo (if you haven't already)
Code:
cd ~/Projects
git clone https://github.com/RehabMan/HP-ProBook-4x30s-DSDT-Patch probook.git

Clone the guide/plist repo (if you haven't already)
Code:
cd ~/Projects
git clone https://github.com/RehabMan/OS-X-Clover-Laptop-Config.git guide.git

If you haven't already, make sure you have iasl installed as per ACPI patching guide: https://www.tonymacx86.com/threads/guide-patching-laptop-dsdt-ssdts.152573/

Alternatively, you could download and install iasl with Terminal:
Code:
cd ~/Downloads
curl --remote-name --progress-bar --location https://bitbucket.org/RehabMan/acpica/downloads/iasl.zip
unzip iasl.zip
sudo cp iasl /usr/bin

Now we will build SSDT-PNLF.aml:
Code:
cd ~/Projects/guide.git
make

You will find the resulting SSDT-PNLF.aml at ~/Projects/guide.git/build/SSDT-PNLF.aml.
AppleBacklightInjector.kext is at ~/Projects/probook.git/kexts/AppleBacklightInjector.kext.
And the patch required is in ~/Projects/guide/config_patches.plist.


Installation

To use this technique requires three components:
- SSDT-PNLF.aml in ACPI/patched
- AppleBacklight patch in config.plist/KernelAndKextPatches/KextsToPatch
- AppleBacklightInjector.kext installed to /L/E

Note: If you already have patched your DSDT (or SSDT) with a "Brightness" patch (PNLF), you must remove it! Same if you're using Clover's AddPNLF_1000000.

Also Note: The SSDT-PNLF.aml assumes that GFX0 (or VID on Thinkpads) is already renamed to IGPU. It will not work if your IGPU is not at _SB.PCI0.IGPU.

Copy the SSDT-PNLF.aml from ~/Projects/guide.git/build/SSDT-PNLF.aml to your EFI/Clover/ACPI/patched. If you're using SortedOrder in your config.plist, make sure you add SSDT-PNLF.aml to it. Also, it must be loaded *after* the OEM SSDTs. For many laptops, the IGPU (formerly GFX0) device is defined in an SSDT, not DSDT, and since SSDT-PNLF is dependent on this device already being defined, the SSDT-PNLF.aml must load after the OEM SSDT that defines it.

Add the patch marked with comment "change F%uT%04x to F%uTxxxx in AppleBacklightInjector.kext (credit RehabMan)" from ~/Projects/guide.git/config_patches.plist to your own config.plist at EFI/Clover/config.plist. Use a plist editor such as Xcode or PlistEdit Pro to copy/paste. DO NOT use Clover Configurator.

Install AppleBacklightInjector.kext to /L/E:
Code:
sudo cp -R ~/Projects/probook.git/kexts/AppleBacklightInjector.kext /Library/Extensions

And I feel like I shouldn't even need to mention this, as it is obvious... but you must remove IntelBacklight.kext (and/or ACPIBacklight.kext) from wherever you installed it.

And since after doing all these tasks it will be the first time you are loading AppleBacklight.kext, and this fix involves a Clover hotpatch, you will likely not have it working on first reboot. So right after booting with all components in place, rebuild cache:

Code:
sudo kextcache -i /

Then reboot.

Clover can only patch kexts in kernel cache, and upon first reboot, it will not be in cache, which is why the rebuild cache and reboot is required.


Customization

In certain cases, you may wish to modify the PWMMax value used to match the specifics of your framebuffer. This is especially true if you're not using the typical ig-platform-id and your ig-platform-id uses a different PWMMax.

One example would be Haswell ig-platform-id 0xa2e0008, which uses 0x56c instead of the typical 0xad9 (as used by 0xa260006).

In this case you will need to provide a custom LMAX, since the PWMMax determined based on device-id will not match your ig-platform-id.

This can be done by providing an SSDT-RMCF.aml in ACPI/patched. You will find SSDT-RMCF.aml at ~/Projects/guide.git/build/SSDT-RMCF.aml.

For example, the backlight PWMMax is configured by changing:
Code:
        // LMAX: Backlight PWM MAX.  Must match framebuffer in use.
        //
        // Ones: Default will be used (0x710 for Ivy/Sandy, 0xad9 for Haswell/Broadwell)
        // Other values: must match framebuffer
        Name(LMAX, Ones)

To:
Code:
        // LMAX: Backlight PWM MAX.  Must match framebuffer in use.
        //
        // Ones: Default will be used (0x710 for Ivy/Sandy, 0xad9 for Haswell/Broadwell)
        // Other values: must match framebuffer
        Name(LMAX, 0x56c)


Display ID dependencies

Some product/display-IDs as published in EDID present a problem. Although the patches used here will accomplish the correct FxxTxxxx profile selection in AppleBacklight, certain IDs have special case code (somewhere) that cause the backlight to not work.

To fix it, you must inject a patched EDID...

If Clover can automatically detect your EDID, the easy fix is to change your config.plist such that Clover automatically injects a custom EDID with patched product-id. The product-id known to work is 0x9c7c. Just set config.plist/Graphics/EDID/Inject=true, and config.plist/Graphics/EDID/ProductID=0x9c7c.

For some laptops (Sony, Fujitsu, to name a couple of common ones), Clover cannot detect your EDID. You will notice it in your Clover bootlog that detected EDID size is zero. For these laptops you are probably already injecting a custom EDID which you extracted (otherwise your internal display would not work). Simply change the product-id in the EDID data to 0x9c7c. Although macOS/OS X does not seem to check it, you should also update the checksum of the EDID to match the new checksum after patching.

Note: You cannot patch a custom EDID with the EDID/ProductID setting. That setting is ignored if you're specifying an EDID via config.plist/Graphics/CustomEDID or config.plist/Graphics/EDID/Custom. You must patch the actual EDID data itself.

Forum user @tosbaha has created a Ruby script that can patch your EDID with the 0x9c7c product id. You can find instructions here: https://www.tonymacx86.com/threads/fixing-brightness-with-custom-edid.219413/


Saving and restoring backlight level across restarts

AppleBacklight.kext stores the current brightness level in NVRAM for restoration across a reboot. It stores it in NVRAM variable 'backlight-level'.

In order for save/restore to work, you must have properly implemented NVRAM. For some laptops native NVRAM does not work, so you need EmuVariableUefi-64.efi. Without EmuVariableUefi-64.efi in drivers64UEFI, native NVRAM is used. With it, emulated NVRAM is used, saved to disk (nvram.plist) at shutdown, and loaded at startup. In order for emulated NVRAM to work, you must have installed "RC scripts" within the Clover installer. Failure to install "RC scripts", but having EmuVariableUefi-64.efi present in drivers64UEFI will cause NVRAM settings to never be saved in nvram.plist.

For some computers, you may be able to get native NVRAM working (without EmuVariableUefi-64.efi) if you use AptioMemoryFix.efi instead of OsxAptioFix*.efi. So AptioMemoryFix.efi is also something to try. Keep in mind AptioMemoryFix.efi is relatively new, so it may not work for everyone.

Also, make sure config.plist/SystemParameters/BacklightLevel is NOT present in your config.plist. You don't want Clover setting the backlight-level to something other than the NVRAM value.

Keep in mind that if you visit Clover Options -> Graphics Injector, that the default for Backlight Level will likely show as 0xFFFF. If you return from there, Clover *will* inject that value, overriding the NVRAM, which is probably not what you expect. To avoid that problem, always blank the setting before exiting from the Options -> Graphics Injector screen.


Ambient Light Sensor

Some laptops have an ambient light sensor device defined in DSDT. This will interfere with backlight restore as they don't tend to be compatible with macOS/OS X ambient light sensor driver (those drivers have Mac SMC dependencies).

Such devices should be disabled by causing _STA to return zero.

You can check your DSDT for an ambient light sensor (could be in an SSDT too) by looking for its _HID identifier: ACPI0008.

For example:
Code:
    Device (ALSD)
    {
        Name (_HID, "ACPI0008")  // _HID: Hardware ID
        Method (_STA, 0, NotSerialized)  // _STA: Status
        {
            If ((ALSE == 0x02))
            {
                Return (0x0B)
            }

            Return (Zero)
        }
...

You can edit the _STA method so it returns zero:
Code:
    Device (ALSD)
    {
        Name (_HID, "ACPI0008")  // _HID: Hardware ID
        Method (_STA, 0, NotSerialized)  // _STA: Status
        {
            Return (0)
        }
...

For some systems, you may need a Fake ALS device (one that never changes) and the appropriate version of FakeSMC.

Read here: https://www.tonymacx86.com/threads/...ghtness-not-saved.222952/page-14#post-1516295

Original info/discovery from @KNNSpeed that lead to the solution here: https://www.tonymacx86.com/threads/...ghtness-not-saved.222952/page-10#post-1515156


Problem Reporting

Read FAQ, "Problem Reporting"
https://www.tonymacx86.com/threads/faq-read-first-laptop-frequent-questions.164990/
Hello,
I tried to follow the guide however the keys for illuminating the keyboard and brightness do not work. Now, however, those of the volume work. How can I solve?
I posted the debug.
 

Attachments

  • debug_21337.zip
    1.4 MB · Views: 173

Attachments

  • clover minus themes.zip
    1.6 MB · Views: 179
  • debug_23282.zip
    2 MB · Views: 189
I am trying to enable brightness control on a MacBook Pro 2011 undergone a EFI variable fix due to the faulty GPU, for some reason when updating to High Sierra the brightness control is malfunctioned and the keys remain unresponsive. Interestingly enough after installing the IntelBacklightl.kext the brightness keys are responsive yet the brightnesss level remains the same. I think I may be on to something. Thanks for the IntelBacklightl.kext upload.
 
Hello,
I tried to follow the guide however the keys for illuminating the keyboard and brightness do not work. Now, however, those of the volume work. How can I solve?
I posted the debug.

Link for key binding is provided in post #1.
Read it carefully.
 
Back
Top