platform/x86: thinkpad_acpi: Handle keyboard cover attach/detach events
PATCH v2 1/1 platform/x86: thinkpad_acpi: Handle keyboard cover attach/detach events
Those events occur when a keyboard cover is attached to a ThinkPad X1 Tablet series device. Typically, they are used to switch from normal to tablet mode in userspace; e.g., to offer touch keyboard choices when focus goes to a text box and no keyboard is attached, or to enable autorotation of the display according to the builtin orientation sensor.
intel-vtbn already recognizes those events. To avoid sending duplicate events to userspace, they are simply ignored. Thus, this patch only avoids warnings about unknown and unhandled HKEYs 0x4012 and 0x4013.
For more information about the background and potential improvements for different types of attachment options, such as the Pico cartridge dock module, see
https://lore.kernel.org/platform-driver-x86/[email protected]/
--- drivers/platform/x86/thinkpad_acpi.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/platform/x86/thinkpad_acpi.c +23 -0
@@ -174,6 +174,12 @@ enum tpacpi_hkey_event_t {or port replicator */ TP_HKEY_EV_HOTPLUG_UNDOCK =0x4011 ,/* undocked from hotplug dock or port replicator */ +/* +* Thinkpad X1 Tablet series devices emit 0x4012 and 0x4013 +* when keyboard cover is attached, detached or folded onto the back +*/ +TP_HKEY_EV_KBD_COVER_ATTACH =0x4012 ,/* keyboard cover attached */ +TP_HKEY_EV_KBD_COVER_DETACH =0x4013 ,/* keyboard cover detached or folded back */ /* User-interface events */ TP_HKEY_EV_LID_CLOSE = 0x5001, /* laptop lid closed */
@@ -3990,6 +3996,23 @@ static bool hotkey_notify_dockevent(const u32 hkey,pr_info ("undocked from hotplug port replicator\n" );return true; +/* +* Deliberately ignore attaching and detaching the keybord cover to avoid +* duplicates from intel-vbtn, which already emits SW_TABLET_MODE events +* to userspace. +* +* Please refer to the following thread for more information and a preliminary +* implementation using the GTOP ("Get Tablet OPtions") interface that could be +* extended to other attachment options of the ThinkPad X1 Tablet series, such as +* the Pico cartridge dock module: +* https://lore.kernel.org/platform-driver-x86/[email protected]/ +*/ +case TP_HKEY_EV_KBD_COVER_ATTACH : +case TP_HKEY_EV_KBD_COVER_DETACH : + *send_acpi_ev = false; + *ignore_acpi_ev = true; +return true; +default :return false; }
Signature · 1 line
2.30.1
Hi,
Quoted 10 lines · Alexander Kobel
Those events occur when a keyboard cover is attached to a ThinkPad X1 Tablet series device. Typically, they are used to switch from normal to tablet mode in userspace; e.g., to offer touch keyboard choices when focus goes to a text box and no keyboard is attached, or to enable autorotation of the display according to the builtin orientation sensor.
intel-vtbn already recognizes those events. To avoid sending duplicate events to userspace, they are simply ignored. Thus, this patch only avoids warnings about unknown and unhandled HKEYs
0x4012and0x4013.
Quoted 6 lines
For more information about the background and potential improvements for different types of attachment options, such as the Pico cartridge dock module, see
https://lore.kernel.org/platform-driver-x86/[email protected]/Signed-off-by Alexander Kobel <[email protected]>
Thanks, patch looks good to me:
Note I will merge this into my review-hans branch and eventually pdx86/for-next once 5.12-rc1 is released.
Regards,
Hans
Quoted 46 lines
--- drivers/platform/x86/thinkpad_acpi.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)drivers/platform/x86/thinkpad_acpi.c +23
-0@@ -174,6 +174,12 @@ enum tpacpi_hkey_event_t {or port replicator */ TP_HKEY_EV_HOTPLUG_UNDOCK =0x4011 ,/* undocked from hotplug dock or port replicator */ +/* +* Thinkpad X1 Tablet series devices emit 0x4012 and 0x4013 +* when keyboard cover is attached, detached or folded onto the back +*/ +TP_HKEY_EV_KBD_COVER_ATTACH =0x4012 ,/* keyboard cover attached */ +TP_HKEY_EV_KBD_COVER_DETACH =0x4013 ,/* keyboard cover detached or folded back */ /* User-interface events */ TP_HKEY_EV_LID_CLOSE = 0x5001, /* laptop lid closed */@@ -3990,6 +3996,23 @@ static bool hotkey_notify_dockevent(const u32 hkey,pr_info ("undocked from hotplug port replicator\n" );return true; +/* +* Deliberately ignore attaching and detaching the keybord cover to avoid +* duplicates from intel-vbtn, which already emits SW_TABLET_MODE events +* to userspace. +* +* Please refer to the following thread for more information and a preliminary +* implementation using the GTOP ("Get Tablet OPtions") interface that could be +* extended to other attachment options of the ThinkPad X1 Tablet series, such as +* the Pico cartridge dock module: +* https://lore.kernel.org/platform-driver-x86/[email protected]/ +*/ +case TP_HKEY_EV_KBD_COVER_ATTACH : +case TP_HKEY_EV_KBD_COVER_DETACH : + *send_acpi_ev = false; + *ignore_acpi_ev = true; +return true; +default :return false; }
Hi,
Quoted 10 lines · Alexander Kobel
Those events occur when a keyboard cover is attached to a ThinkPad X1 Tablet series device. Typically, they are used to switch from normal to tablet mode in userspace; e.g., to offer touch keyboard choices when focus goes to a text box and no keyboard is attached, or to enable autorotation of the display according to the builtin orientation sensor.
intel-vtbn already recognizes those events. To avoid sending duplicate events to userspace, they are simply ignored. Thus, this patch only avoids warnings about unknown and unhandled HKEYs
0x4012and0x4013.
Quoted 6 lines
For more information about the background and potential improvements for different types of attachment options, such as the Pico cartridge dock module, see
https://lore.kernel.org/platform-driver-x86/[email protected]/Signed-off-by Alexander Kobel <[email protected]>
Thank you for your patch, I've applied this patch to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.
Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.
Regards,
Hans
Quoted 46 lines
--- drivers/platform/x86/thinkpad_acpi.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)drivers/platform/x86/thinkpad_acpi.c +23
-0@@ -174,6 +174,12 @@ enum tpacpi_hkey_event_t {or port replicator */ TP_HKEY_EV_HOTPLUG_UNDOCK =0x4011 ,/* undocked from hotplug dock or port replicator */ +/* +* Thinkpad X1 Tablet series devices emit 0x4012 and 0x4013 +* when keyboard cover is attached, detached or folded onto the back +*/ +TP_HKEY_EV_KBD_COVER_ATTACH =0x4012 ,/* keyboard cover attached */ +TP_HKEY_EV_KBD_COVER_DETACH =0x4013 ,/* keyboard cover detached or folded back */ /* User-interface events */ TP_HKEY_EV_LID_CLOSE = 0x5001, /* laptop lid closed */@@ -3990,6 +3996,23 @@ static bool hotkey_notify_dockevent(const u32 hkey,pr_info ("undocked from hotplug port replicator\n" );return true; +/* +* Deliberately ignore attaching and detaching the keybord cover to avoid +* duplicates from intel-vbtn, which already emits SW_TABLET_MODE events +* to userspace. +* +* Please refer to the following thread for more information and a preliminary +* implementation using the GTOP ("Get Tablet OPtions") interface that could be +* extended to other attachment options of the ThinkPad X1 Tablet series, such as +* the Pico cartridge dock module: +* https://lore.kernel.org/platform-driver-x86/[email protected]/ +*/ +case TP_HKEY_EV_KBD_COVER_ATTACH : +case TP_HKEY_EV_KBD_COVER_DETACH : + *send_acpi_ev = false; + *ignore_acpi_ev = true; +return true; +default :return false; }