Re: [External] Re: [PATCH] platform/x86: thinkpad_acpi: handle HKEY 0x4012, 0x4013 events

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Hans, Nitin,

thanks a lot for your help.

On 2/8/21 10:04 AM, Hans de Goede wrote:
> <snip>
> Alexander, so it looks like we need to do the following to support this properly:

Spot on. Thanks for the detailed guide; I wouldn't have been able to get there in due time without your advise.
I will send the revised patch in a separate mail, but want to highlight few points.

> 1. At a new TP_HOTKEY_TABLET_USES_GTOP to the hotkey_tablet enum
> 2. At probe time in hotkey_init_tablet_mode add a new if / case with I guess
>    the highest prio (so try before GMMS) which does:
>    1. Call GTOP with parameter 0x0000, check return equals 0x0103 (or newer?)
>       Nitin, how should the version check look like here, check that the
>       upper byte == 0x01 and the lower byte >= 0x03 ?

Exactly.

>    2. Call GTOP with parameter 0x0100, check return value equals 4

I also included the simpler "any type" interface which does not report folding to the back. I confirmed that it works on my X1 with limited functionality, but don't have a "any type" device to test available. (In fact, I don't know whether such a device even exists.) IIUC it can also easily cover type 2 "Helix" and type 3 "Thinkpad 10" with the functionality available on those types. Since I cannot test, I didn't enable that in my patch; but it should be a matter of checking for return values 2 and 3 and adding an appropriate case in hotkey_get_tablet_mode.
By the way, Nitin kindly confirmed that I can translate the GTOP reference sheet to source code comments, and provided the mapping between type 2, 3, 4 and series "Helix", "Thinkpad 10" and "X1 Tablet".

>    3. Call GTOP with parameter 0x0200, set in_tablet_mode based on bit 0
>       and bit 16. I think we should report SW_TABLET_MODE=1 when the thin-kbd
>       is attached, but folded to the back

Right.

> 3. Make hotkey_get_tablet_mode support the new TP_HOTKEY_TABLET_USES_GTOP case and
>    make it call GTOP with parameter 0x0200 and check bit 0 + bit 16
> 4. On the events which you identified call tpacpi_input_send_tabletsw()

Works like a charm.
I realized that the device also emits 0x60c0 (TP_HKEY_EV_TABLET_CHANGED) when the keyboard cover is attached or detached, yet *not* when it's folded. I don't quite get why I nevertheless receive only one notification to userspace according to acpi_listen, despite the fact that the 0x60c0 handler also calls tpacpi_input_send_tabletsw and hotkey_tablet_mode_notify_change. Is there a deduplication behind the scenes?

I also realized that intel_vbtn reports the change, too. Would it be in order to modify intel_vbtn in a next step and blacklist this device to avoid duplicates?

On the other hand, userspace should expect duplicate messages to some degree and use a hysteresis approach anyway. Every now and then, the contact of the magnetic plug is not established perfectly on the first attempt. So perhaps not really an issue.


> And can you also check if there are events when folding the kbd behind the tablet?

Works perfectly.


Cheers,
Alex

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux