Skip to content
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

DSDT hotpatch to remove the OSID check in SMEE before calling EV13 (brightness key function) #5

Open
hacker1024 opened this issue Nov 9, 2021 · 1 comment

Comments

@hacker1024
Copy link
Owner

As the moment, _OSI patching is required to enable the brightness keys (00532c7).
This is not recommended by Dortania, due to the problems it can cause with other operating systems.

It would be better if a DSDT hotpatch was implemented to remove the check. Here's the relevant DSDT code:

Method (SMEE, 1, NotSerialized)
{
    Local0 = Arg0
    Local0 = GENS (0x11, Zero, Zero)
    If ((\_SB.OSID () >= 0x20))
    {
        If ((Local0 & 0x04))
        {
            EV13 (One, Zero)
        }

        If ((Local0 & 0x02))
        {
            EV13 (0x02, Zero)
        }
    }

    If ((Local0 & 0x08))
    {
        Local0 = GENS (0x1D, Zero, Zero)
        EV14 (Local0, Zero)
    }
}

The idea is to change If ((\_SB.OSID () >= 0x20)) to If (One), similarly to the existing I2C patch.

Here's what the binary looks like:

   57801:          If ((\_SB.OSID () >= 0x20))

0003E982:  A0 2A 92 95 ............    ".*.."
0003E986:  5C 2E 5F 53 42 5F 4F 53     "\._SB_OS"
0003E98E:  49 44 0A 20 ............    "ID. "

And with If (One):

   57801:          If (One)

0003E982:  A0 1D 01 ...............    "..."

My initial thought was to simply make a find/replace based on these differing binary snippets. Several variants are possible, depending on the positions of NoopOps:

   Find: A02A9295 5C2E5F53425F4F53 49440A20
Replace: A02A01A3 A3A3A3A3A3A3A3A3 A3A3A3A3
   Find: A02A9295 5C2E5F53425F4F53 49440A20
Replace: A3A3A3A3 A3A3A3A3A3A3A3A3 A3A01D01

My experience with this sort of binary code is mainly in the Android field, with Dalvik opcodes. I'm not sure if instruction alignment is as important in ACPI land as it is in Dalvik, but I think it's possible that one of these patches is invalid due to weird A0 IfOp positions. I need to look into the ACPI specification more.

Neither of these hotpatches work at the moment. When enabled, the "System DSDT" view in MaciASL shows what I expect - If (One) and a bunch of NoopOps - but the brightness keys don't work.

I'm probably misunderstanding the way these binary if statements work. I'll look into the ACPI specification and see if I can work out what's going on, just like @al3xtjames did on Reddit for the I2C patch.

(Btw @al3xtjames, if you notice anything immediately fixable with the patches above, I'd really appreciate your input. I haven't tried very hard myself to solve the problem yet though, so no pressure.)

@hacker1024 hacker1024 pinned this issue Nov 9, 2021
@hacker1024
Copy link
Owner Author

Weird - with the current fix added in 00532c7, the brightness keys stop working if the EC fan control is disabled...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant