Jump to content
loibi93

ThinkPad T440s - Brightness Patching

18 posts in this topic

Recommended Posts

Hello !

I tried to patch my ACPI Tables for Brightness fix, but i can't find the BAR1 Method anywhere ! I first do the Rename Patch and then the Hawell Brightness fix, but it always says that the BAR1 Method could not be found. The three Backlight kexts are loading and i have a Slider in SysPref but it doesn't change the Brightness !

Lukass MacBook Pro.acpi.zip

Share this post


Link to post
Share on other sites
Advertisement

Hello !

 

I tried to patch my ACPI Tables for Brightness fix, but i can't find the BAR1 Method anywhere ! I first do the Rename Patch and then the Hawell Brightness fix, but it always says that the BAR1 Method could not be found. The three Backlight kexts are loading and i have a Slider in SysPref but it doesn't change the Brightness !

I assume you're using my patches here: https://github.com/RehabMan/Laptop-DSDT-Patch

 

Your on-board GPU device is defined in SSDT-5. You must rename VID -> IGPU first, then apply the patch to this SSDT.

Share this post


Link to post
Share on other sites

Yeah i added it in MaciASL !

Did it but i get two errors, BAR1 does not exist and _DOS is not accesible !

How do i fix this ?

Share this post


Link to post
Share on other sites

Yeah i added it in MaciASL !

Did it but i get two errors, BAR1 does not exist and _DOS is not accesible !

How do i fix this ?

For your SSDT-5, you need to tweak the patch slightly:

(_SB.PCI0.IGPU._DOS[originally _SB.PCI0.VID._DOS] is external in DSDT)

(your PCI_config is in Scope (\_SB.PCI0.IGPU)

#Maintained by: RehabMan for: Laptop Patches
#graphics_PNLF_haswell.txt

# This patch enables the brightness slider in SysPrefs->Displays
# and will also enable activation of sleep mode by closing
# the laptop lid.
#
# This particular version is intended to be used with ACPIBacklight.kext
# although it can also be used with AppleBacklight.kext,
# provided AppleBacklight.kext is patched to recognize your 
# display or an injector is used to set brightness levels.
#
#
# See this thread for more information:
#     http://www.tonymacx86.com/hp-probook-mavericks/121031-native-brightness-working-without-blinkscreen-using-patched-applebacklight-kext.html
# (also read any linked threads)
#

#
# Note: This patch assumes you have already applied "Rename GFX0 to IGPU"
# and that the IGPU device is accessible.  For some computers this should
# be applied to one of the SSDTs, not DSDT.
#

into scope label \_SB.PCI0.IGPU code_regex (OperationRegion\s\(IGD2,\sPCI_Config[^\}]*\}) remove_matched;
into scope label \_SB.PCI0.IGPU code_regex (OperationRegion\s\(IGDP,\sPCI_Config[^\}]*\}) replace_matched
begin
%1\n
OperationRegion (IGD2, PCI_Config, 0x10, 4)\n
Field (IGD2, AnyAcc, NoLock, Preserve)\n
{\n
	BAR1,32,\n
}\n
end;

into device label PNLF remove_entry;
into definitionblock code_regex . insert
begin
Scope (\_SB)\n
{\n
    Device (PNLF)\n
    {\n
        // normal PNLF declares (note some of this probably not necessary)\n
        Name (_ADR, Zero)\n
        Name (_HID, EisaId ("APP0002"))\n
        Name (_CID, "backlight")\n
        Name (_UID, 10)\n
        Name (_STA, 0x0B)\n
        //define hardware register access for brightness\n
        // you can see BAR1 value in RW-Everything under Bus00,02 Intel VGA controler PCI\n
        // Note: Not sure which one is right here... for now, going with BAR1 masked\n
        //OperationRegion (BRIT, SystemMemory, Subtract(\_SB.PCI0.IGPU.BAR1, 4), 0xe1184)\n
        OperationRegion (BRIT, SystemMemory, And(\_SB.PCI0.IGPU.BAR1, Not(0xF)), 0xe1184)\n
        Field (BRIT, AnyAcc, Lock, Preserve)\n
        {\n
            Offset(0x48250),\n
            LEV2, 32,\n
            LEVL, 32,\n
            Offset(0x70040),\n
            P0BL, 32,\n
            Offset(0xc8250),\n
            LEVW, 32,\n
            LEVX, 32,\n
            Offset(0xe1180),\n
            PCHL, 32,\n
        }\n
        Method (_INI, 0, NotSerialized)\n
        {\n
            // If the BIOS actually sets the values prior to boot, this would be\n
            // how (maybe) to capture them.  My Envy does not have the capability\n
            // to set brightness and I find these values are not set.\n
            // The current value could also be in LEVL, and probably is even\n
            // though OS X seems to manipulate only the low 16-bits of LEVX to\n
            // change brightness.\n
            // Because the low-order 16-bits are set to zero on the Envy, enabling\n
            // this code causes a blank screen before the login screena appears.\n
            //\n
            //Store(LEVX, Local0)\n
            //Store(ShiftRight(Local0,16), Local1)\n
            //Store(And(Local0,0xFFFF), Local2)\n
            //Divide(Multiply(Local2, 0xad9), Local1, Local0)\n
            //Or(Local0, 0xad90000, Local0)\n
            //\n
            //REVIEW: wait for vblank to change things\n
            //While(LEqual (P0BL, Local1)) {}\n
            //\n
            // This is part of the "keep startup level"...\n
            // see comment above.\n
            //Store(Local0, LEVX)\n
            //\n
            // This 0xC value comes from looking what OS X initializes this\n
            // register to after display sleep (using ACPIDebug/ACPIPoller)\n
            Store(0xC0000000, LEVW)\n
            // Because this laptop starts at full brightness, I just set it right\n
            // here.  This is to insure _BQC and XBQC return the correct level\n
            // at startup.\n
            Store(0xad90ad9, LEVX)\n
        }\n
        // _BCM/_BQC: set/get for brightness level\n
        Method (_BCM, 1, NotSerialized)\n
        {\n
            // store new backlight level\n
            Store(Match(_BCL, MGE, Arg0, MTR, 0, 2), Local0)\n
            If (LEqual(Local0, Ones)) { Subtract(SizeOf(_BCL), 1, Local0) }\n
            Store(Or(DerefOf(Index(_BCL,Local0)),And(LEVX,0xFFFF0000)), LEVX)\n
        }\n
        Method (_BQC, 0, NotSerialized)\n
        {\n
            Store(Match(_BCL, MGE, And(LEVX, 0xFFFF), MTR, 0, 2), Local0)\n
            If (LEqual(Local0, Ones)) { Subtract(SizeOf(_BCL), 1, Local0) }\n
            Return(DerefOf(Index(_BCL, Local0)))\n
        }\n
        Method (_DOS, 1, NotSerialized)\n
        {\n
            External(\_SB.PCI0.IGPU._DOS, MethodObj)\n
            ^^PCI0.IGPU._DOS(Arg0)\n
        }\n
        // extended _BCM/_BQC for setting "in between" levels\n
        Method (XBCM, 1, NotSerialized)\n
        {\n
            // store new backlight level\n
            If (LGreater(Arg0, XRGH)) { Store(XRGH, Arg0) }\n
            If (LAnd(Arg0, LLess(Arg0, XRGL))) { Store(XRGL, Arg0) }\n
            Store(Or(Arg0,And(LEVX,0xFFFF0000)), LEVX)\n
        }\n
        Method (XBQC, 0, NotSerialized)\n
        {\n
            Store(And(LEVX,0xFFFF), Local0)\n
            If (LGreater(Local0, XRGH)) { Store(XRGH, Local0) }\n
            If (LAnd(Local0, LLess(Local0, XRGL))) { Store(XRGL, Local0) }\n
            Return(Local0)\n
        }\n
    }\n
}\n
end;

into device label PNLF code_regex Name\s\(_BCL,\sPackage[^\}]*\}\) remove_matched;
into device label PNLF code_regex Name\s\(XOPT,.*\)\n removeall_matched;
into device label PNLF code_regex Name\s\(XRGL,.*\)\n removeall_matched;
into device label PNLF code_regex Name\s\(XRGH,.*\)\n removeall_matched;
into device label PNLF code_regex Name\s\(KLVX,.*\)\n removeall_matched;
into device label PNLF code_regex . insert
begin
    // Use XOPT=1 to disable smooth transitions\n
    Name (XOPT, Zero)\n
    // XRGL/XRGH: defines the valid range\n
    Name (XRGL, 25)\n
    Name (XRGH, 2777)\n
    // _BCL: returns list of valid brightness levels\n
    // first two entries describe ac/battery power levels\n
    Name (_BCL, Package()\n
    {\n
        2777,\n
        748,\n
        0,\n
        35, 39, 44, 50,\n
        58, 67, 77, 88,\n
        101, 115, 130, 147,\n
        165, 184, 204, 226,\n
        249, 273, 299, 326,\n
        354, 383, 414, 446,\n
        479, 514, 549, 587,\n
        625, 665, 706, 748,\n
        791, 836, 882, 930,\n
        978, 1028, 1079, 1132,\n
        1186, 1241, 1297, 1355,\n
        1414, 1474, 1535, 1598,\n
        1662, 1728, 1794, 1862,\n
        1931, 2002, 2074, 2147,\n
        2221, 2296, 2373, 2452,\n
        2531, 2612, 2694, 2777,\n
    })\n
end;

Share this post


Link to post
Share on other sites

Awesome compiles like a charm !

 

Will this fix sleep too ?

If you have issues with sleep, it is more likely related to power management or DSDT/SSDT issues...

Share this post


Link to post
Share on other sites

How do i use the patched ssdt ? I already have one generated for power management

Assuming Chameleon...

 

If you have /Extra/ssdt.aml, place as /Extra/ssdt-1.aml. Don't forget to patch DSDT (with rename).

Share this post


Link to post
Share on other sites

If i patch DSDT with rename patch i get a lot of errors (25) ! Unfortunatelly i absolutely don't know how to fix them :(

Could you do it for me please ? :D

Share this post


Link to post
Share on other sites

If i patch DSDT with rename patch i get a lot of errors (25) ! Unfortunatelly i absolutely don't know how to fix them :(

Could you do it for me please ? :D

Start by extracting native files with Linux (they are at /sys/firmware/acpi/tables, /sys/firmware/acpi/tables/dynamic). Then disassemble with 'iasl -da *) using a recent build of iasl. That will get you an error free DSDT to start with (I just tested it here by extracting the binaries from your 'acpi' file above).

 

But your DSDT contains both a PCI0.VID and a PCI0.PEG.VID, which makes automatic regex search/replace difficult. Rename manually instead, being careful to not rename VID as related to PCI0.PEG.VID, but only PCI0.VID -> PCI0.IGPU.

 

Actually, here is a patch:

into device label VID set_label begin IGPU end;
into_all all code_regex PCI0\.VID_ replaceall_matched begin PCI0.IGPU end;
into_all all code_regex PCI0\.VID replaceall_matched begin PCI0.IGPU end;

Share this post


Link to post
Share on other sites

So PCI0.PEG.VID stays as PCI0.PEG.VID and only PCI0.VID turns into PCI0.IGPU ? (I'm from Austria so i have a little hard time to understand everything exactly as you mean it ;) )

 

Just for interrest since i study software engineering and did regex last year, the problem with regex here is, that it can't "remember" that there was the .PEG Part in front of .VID so it changes ALL .VID to .IGPU !?


I replaced it as you said and there were no errors but when i boot system hangs on IOAPIC version 0x20 vectors 64:103 !?

Share this post


Link to post
Share on other sites

So PCI0.PEG.VID stays as PCI0.PEG.VID and only PCI0.VID turns into PCI0.IGPU ? (I'm from Austria so i have a little hard time to understand everything exactly as you mean it ;) )

 

Just for interrest since i study software engineering and did regex last year, the problem with regex here is, that it can't "remember" that there was the .PEG Part in front of .VID so it changes ALL .VID to .IGPU !?

 

I replaced it as you said and there were no errors but when i boot system hangs on IOAPIC version 0x20 vectors 64:103 !?

See post #10 for automatic patches...

 

Also, make sure your DSDT extract is current. Hang/pause on IOAPIC is a classic sign of using a DSDT out-of-sync with native DSDT, most common when people attempt to use a (patched) DSDT from a different computer than their own.

Share this post


Link to post
Share on other sites

Ahh sorry overlooked that !

 

The DSDT i used for that patch is from the .acpi file i uploaded in post #1 which i created today !

Could it be that there are references to PCI0.VID in one of the other tables and i need to change it there too ?

Share this post


Link to post
Share on other sites

Ahh sorry overlooked that !

 

The DSDT i used for that patch is from the .acpi file i uploaded in post #1 which i created today !

Could it be that there are references to PCI0.VID in one of the other tables and i need to change it there too ?

That file is full of errors if opened in MaciASL...

 

I would start with a clean slate with files extracted from Linux.

 

Any table you plan to include must have renames "balanced". Any rename done to one table must be done to all tables. In addition, to provide patched SSDTs you must use DropSSDT=Yes, otherwise the bootloader will inject both OEM tables and your patched tables.

Share this post


Link to post
Share on other sites

Well i will have to try tomorrow and report back !

 

So i need to look through all the tables if there is the PCI0.VID and replace it with PCI0.IGPU, save all edited files as ssdt-1.aml ssdt-2.aml.....ssdt-x.aml and put them together with dsdt.aml in extra folder.

 

Does DropSSDT=Yes only drop ssdts which are in extra folder or does it drop all tables ? For example if i need to edit ssdt-2 and ssdt-5 save them as ssdt-1 and ssdt-2 do the other ones load ?

Share this post


Link to post
Share on other sites

Well i will have to try tomorrow and report back !

 

So i need to look through all the tables if there is the PCI0.VID and replace it with PCI0.IGPU, save all edited files as ssdt-1.aml ssdt-2.aml.....ssdt-x.aml and put them together with dsdt.aml in extra folder.

Yes. However... generally, you want to exclude SSDTs that are CPU related.

 

Does DropSSDT=Yes only drop ssdts which are in extra folder or does it drop all tables ? For example if i need to edit ssdt-2 and ssdt-5 save them as ssdt-1 and ssdt-2 do the other ones load ?

DropSSDT has nothing to do with SSDTs in /Extra. It has only to do with excluding OEM SSDTs provided by BIOS. By using DropSSDT=Yes, only SSDTs in /Extra will be provided to OS X by Chameleon.

 

In other words...

DropSSDT=Yes: SSDTs in /Extra are provided to OS X by Chameleon.

DropSSDT=No: OEM SSDTs from BIOS and SSDTs in /Extra are provided to OS X by Chameleon (in that order).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×