MSzturc / ThinkpadAssistant

An Assistant Application that allows you to use all your Function Keys on a T-Series Thinkpad Laptop
124 stars 13 forks source link

T480 compatibility #8

Closed EETagent closed 4 years ago

EETagent commented 4 years ago

Hello, I would like to ask you for little assistance with the T480 keyboard mapping to make it work with the Thinkpad Assistant. I'm quite a noob when it comes to the ACPI patches.

DSDT.zip config.zip SSDT-BKeyQ14Q15-TP-LPCB.zip

Keys currently works as normal FN keys with backlight control using BKeyQ14Q15-TP-LPCB

Keyboard part (?) from my DSDT


Method (XQ14, 0, NotSerialized)
            {
                If (\_SB.PCI0.LPCB.EC.HKEY.MHKK (0x01, 0x8000))
                {
                    \_SB.PCI0.LPCB.EC.HKEY.MHKQ (0x1010)
                }

                If (\VIGD)
                {
                    Notify (\_SB.PCI0.GFX0.DD1F, 0x86) // Device-Specific
                }
            }

            Method (XQ15, 0, NotSerialized)
            {
                If (\_SB.PCI0.LPCB.EC.HKEY.MHKK (0x01, 0x00010000))
                {
                    \_SB.PCI0.LPCB.EC.HKEY.MHKQ (0x1011)
                }

                If (\VIGD)
                {
                    Notify (\_SB.PCI0.GFX0.DD1F, 0x87) // Device-Specific
                }

                Return (Zero)
            }

            Method (BRNS, 0, NotSerialized)
            {
                Local0 = (\BRLV + 0x02)
                Local3 = \BNTN
                If (\_SB.PCI0.GFX0.DRDY)
                {
                    Local2 = DerefOf (DerefOf (BRTB [Local3]) [Local0])
                    \_SB.PCI0.GFX0.AINT (0x01, Local2)
                }
            }

            Method (BFRQ, 0, NotSerialized)
            {
                Local0 = 0x80000100
                Local1 = DerefOf (DerefOf (BRTB [\BNTN]) [0x13])
                Local0 |= (Local1 << 0x09)
                Local1 = DerefOf (DerefOf (BRTB [\BNTN]) [0x15])
                Local0 |= Local1
                Return (Local0)
            }
        }

        Scope (\_SB.PCI0.LPCB.EC)
        {
            Name (BDEV, 0xFF)
            Name (BSTS, 0x00)
            Name (BHKE, 0x00)
            Method (_Q2C, 0, NotSerialized)  // _Qxx: EC Query, xx=0x00-0xFF
            {
                If ((BSTS == 0x00))
                {
                    BDEV = BGID (0x00)
                    NBRE (BDEV)
                }
            }

            Method (_Q2D, 0, NotSerialized)  // _Qxx: EC Query, xx=0x00-0xFF
            {
                BDEV = BGID (0x00)
                NBIN (BDEV)
            }

            Method (_Q38, 0, NotSerialized)  // _Qxx: EC Query, xx=0x00-0xFF
            {
                Local0 = BGID (0x00)
                If ((Local0 == 0x0F))
                {
                    BDIS ()
                    \BHDP (0x01, 0x00)
                    NBEJ (BDEV)
                    BDEV = Local0
                    If ((\BIDE == 0x03))
                    {
                        \_SB.PCI0.SAT0.PRIM.GTME = 0x00
                        \_SB.PCI0.SAT0.SCND.GTME = 0x00
                    }
                }
                ElseIf (HPBU){}
                Else
                {
                    BDEV = Local0
                    NBIN (Local0)
                }
            }

Thanks for help

MSzturc commented 4 years ago

Try this:

image

EETagent commented 4 years ago

@MSzturc Thanks for response

I added those renames and KBRD.aml to my EFI and it resulted in Kernel Panic. My DSDT uses LPCB instead of LPC so I replaced that. I've got also compile error in the highlighted section, removing __ after LPCB solved that Snímek obrazovky 2020-05-22 v 16 26 53

DSDT.dsl.zip config.plist.zip SSDT-KBRD.aml.zip

MSzturc commented 4 years ago

Thx for the working configurations. Added them as samples for users in the future

EETagent commented 4 years ago

@MSzturc I apologize for the misunderstanding. I probably wrote it wrong. This config does not work. It resulted in kernel panic like I wrote above.

MSzturc commented 4 years ago

There has to be a typo in your ssdt but i see it right now. I would suggest that you try the ssdt from @xma https://github.com/xma/T480-Clover/blob/master/CLOVER/ACPI/patched/SSDT-KBD.dsl He maps only two keys right now but if it works it could be a good starting point to go further.

EETagent commented 4 years ago

@MSzturc Thanks, nice find. It's working well now. As soon as I have time I will try to add Bluetooth and screen extending/mirroring support.

xma commented 4 years ago

Yeah it's working fine for a T480 with clover, would you mind adding a link to my repo it in README.md ? thank you

xma commented 4 years ago

Thanks for the link. I've added missing keys onto T480 - layout is same as X1C6, it works really well !

MSzturc commented 4 years ago

Updated Readme with new samples

@EETagent please check if all Function Keys are working

EETagent commented 4 years ago

@xma @MSzturc Thanks for help

MSzturc commented 4 years ago

Are you able to switch modes by Airplay Sidecar Menu Bar Entry?

image

image

EETagent commented 4 years ago

@MSzturc

No. But I'm able to change mode using display settings Snímek obrazovky 2020-05-25 v 23 42 44

MSzturc commented 4 years ago

I don't have a multi monitor setup here to test it. I would guess that this line causes the problem:

image

Are you able to start Thinkpad Assistant out of XCode and try it from there? I put assertion inside the Code. You should see Log in the Console if an Error happens

EETagent commented 4 years ago

@MSzturc Here are the logs.

2020-05-27 12:09:25.052942+0200 ThinkpadAssistant[1501:36218] Metal API Validation Enabled
2020-05-27 12:09:33.882870+0200 ThinkpadAssistant[1501:36218] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x6000002560e0> F8BB1C28-BAE8-11D6-9C31-00039315CD46
2020-05-27 12:09:33.924972+0200 ThinkpadAssistant[1501:36218]  HALC_ShellDriverPlugIn::Open: Can't get a pointer to the Open routine
2020-05-27 12:09:33.925543+0200 ThinkpadAssistant[1501:36218]  HALC_ShellDriverPlugIn::Open: Can't get a pointer to the Open routine
2020-05-27 12:09:33.925989+0200 ThinkpadAssistant[1501:36218]  HALC_ShellDriverPlugIn::Open: Can't get a pointer to the Open routine
2020-05-27 12:10:07.292030+0200 ThinkpadAssistant[1501:36678]  HALC_ShellDriverPlugIn::Open: Can't get a pointer to the Open routine

They are printed once when using Bluetooth or monitor mirroring. When switching back to an extending, nothing is listed as if the application did not even notice it

PS: Backlight GUI is really cool. I'm looking forward to use it in the app.

MSzturc commented 4 years ago

Hmm that's a strange behaviour.

The Code of the DisplayManager is based on this tool: https://github.com/fcanas/mirror-displays Basically it's a enhanced port of it to Swift. Can you check if you are able to switch between mirroring and extending with this tool. I want to make sure that it behaves diffrent.

EETagent commented 4 years ago

@MSzturc Downloaded mirror executable, and it works. I am able to switch between mirroring and extending.

EETagent commented 4 years ago

No logs were displayed this time. Only Metal Validation appeared when I clicked on app icon. The application is compiled correctly. It works otherwise normally.

Snímek obrazovky 2020-05-27 v 12 34 31

MSzturc commented 4 years ago

fixed with 1ae384ea2e6b0a3f9a1d6cc0cd7640eeadb89370

I will release a new version as soon as i finished the keyboard backlight feature

EETagent commented 4 years ago

fixed with 1ae384e

I will release a new version as soon as i finished the keyboard backlight feature

I can confirm that this is fixed. Snímek obrazovky 2020-05-27 v 14 01 17

EETagent commented 4 years ago

@MSzturc

Thanks to @xma I realised my previous mistakes with KBRD.aml and was successfuly able to add your recent ACPI patch for backlight control. Is there currently some way how to test if it works?

EDIT: Tested in shortcut manager. Backlight 1 - Shift F16, Backlight 2 - Shift F19, Backlight Off - Shift F16

MSzturc commented 4 years ago

I've commited samples for T460 and the Backlight functionality. Have fun testing ;-)

EETagent commented 4 years ago

@MSzturc It works great.

Constructive criticism: Personally, I'm not a fan of current icons. I think something like this would be much better

MSzturc commented 4 years ago

Closed since it's working with v1.7.0. Moved the discussion about the HUD Layout to a new central topic #16