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

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

 



Dang, first ever patch and a typo crept in right before the commit... :-/ Corrected patch here:


Those events occur when a keyboard cover is attached to a ThinkPad
Tablet 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.

No attempt is taken to emit an EV_SW event for SW_TABLET_MODE; this is
left to userspace.  So this patch is mainly to avoid warnings about
unknown and unhandled events, which are now reported as:

* Event 0x4012: attached keyboard cover
* Event 0x4013: detached keyboard cover

Tested as working on a ThinkPad X1 Tablet Gen 2, 20JCS00C00, and as
non-interfering with a ThinkPad X1 Carbon 7th, 20QESABM02 (normal
clamshell, so it does not have a keyboard cover).

Signed-off-by: Alexander Kobel <a-kobel@xxxxxxxxxx>
---
 drivers/platform/x86/thinkpad_acpi.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index c404706379d9..c16fd8c9d2fa 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -174,6 +174,8 @@ enum tpacpi_hkey_event_t {
 						     or port replicator */
 	TP_HKEY_EV_HOTPLUG_UNDOCK	= 0x4011, /* undocked from hotplug
 						     dock or port replicator */
+	TP_HKEY_EV_KBD_COVER_ATTACH	= 0x4012, /* attached keyboard cover */
+	TP_HKEY_EV_KBD_COVER_DETACH	= 0x4013, /* detached keyboard cover */

 	/* User-interface events */
 	TP_HKEY_EV_LID_CLOSE		= 0x5001, /* laptop lid closed */
@@ -3989,6 +3991,12 @@ static bool hotkey_notify_dockevent(const u32 hkey,
 	case TP_HKEY_EV_HOTPLUG_UNDOCK: /* undocked from port replicator */
 		pr_info("undocked from hotplug port replicator\n");
 		return true;
+	case TP_HKEY_EV_KBD_COVER_ATTACH: /* attached keyboard cover */
+		pr_info("attached keyboard cover\n");
+		return true;
+	case TP_HKEY_EV_KBD_COVER_DETACH: /* detached keyboard cover */
+		pr_info("detached keyboard cover\n");
+		return true;

 	default:
 		return false;
--
2.30.0



On 1/18/21 6:26 PM, Alexander Kobel wrote:
Those events occur when a keyboard cover is attached to a ThinkPad
Tablet 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.

No attempt is taken to emit an EV_SW event for SW_TABLET_MODE; this is
left to userspace.  So this patch is mainly to avoid warnings about
unknown and unhandled events, which are now reported as:

* Event 0x4012: attached keyboard cover
* Event 0x4013: detached keyboard cover

Tested as working on a ThinkPad X1 Tablet Gen 2, 20JCS00C00, and as
non-interfering with a ThinkPad X1 Carbon 7th, 20QESABM02 (normal
clamshell, so it does not have a keyboard cover).

Signed-off-by: Alexander Kobel <a-kobel@xxxxxxxxxx>
---
  drivers/platform/x86/thinkpad_acpi.c | 10 +++++++++-
  1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index c404706379d9..e3b5f02bafa6 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -174,6 +174,8 @@ enum tpacpi_hkey_event_t {
                               or port replicator */
      TP_HKEY_EV_HOTPLUG_UNDOCK    = 0x4011, /* undocked from hotplug
                               dock or port replicator */
+    TP_HKEY_EV_KBD_COVER_ATTACH    = 0x4012, /* attached keyboard cover */
+    TP_HKEY_EV_KBD_COVER_DETACH    = 0x4013, /* detached keyboard cover */

      /* User-interface events */
      TP_HKEY_EV_LID_CLOSE        = 0x5001, /* laptop lid closed */
@@ -3976,7 +3978,7 @@ static bool hotkey_notify_dockevent(const u32 hkey,
      *ignore_acpi_ev = false;

      switch (hkey) {
-    case TP_HKEY_EV_UNDOCK_ACK:
+    case TP_HKEY_EV_UNDOCK_ACK cover:
          /* ACPI undock operation completed after wakeup */
          hotkey_autosleep_ack = 1;
          pr_info("undocked\n");
@@ -3989,6 +3991,12 @@ static bool hotkey_notify_dockevent(const u32 hkey,
      case TP_HKEY_EV_HOTPLUG_UNDOCK: /* undocked from port replicator */
          pr_info("undocked from hotplug port replicator\n");
          return true;
+    case TP_HKEY_EV_KBD_COVER_ATTACH: /* attached keyboard cover */
+        pr_info("attached keyboard cover\n");
+        return true;
+    case TP_HKEY_EV_KBD_COVER_DETACH: /* detached keyboard cover */
+        pr_info("detached keyboard cover\n");
+        return true;

      default:
          return false;


_______________________________________________
ibm-acpi-devel mailing list
ibm-acpi-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


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

_______________________________________________
ibm-acpi-devel mailing list
ibm-acpi-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel

[Index of Archives]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Photo]     [Yosemite Photos]     [Yosemite Advice]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux