Skip to contentSkip to conversation

thinkpad_acpi: Add support for HKEY version 0x200

PATCH In review Lyude Paul 4 participants 11 messages Jun 7, 2016 – Jun 9, 2016 x86 platform drivers

lore
Share & tools
lore

Lyude Paul

author
#0 lore raw

Since nothing's really happened with this patch for a while I figured I'd take over trying to get this upstream.

Regarding testing: This seems to work fine on the 60 series laptops, and works fine on previous generations. The one thing I haven't been able to test is an X1 carbon with an adaptive keyboard since I don't seem to have one readily available here. I'm doing a search around the office to try to find someone who didn't throw theirs away yet so hopefully I should be able to get back to you on that soon.

To Dennis: I took the liberty of doing a review of your patch and some testing. There's a few things that need changing, I've outlined them below: (for the future, it's recommended to send patches for the kernel inline in emails to make them easier to review).

Quoted 39 lines

From 8a67f5db1d2918c46b7fa2168e3d0aab2ba92731 Mon Sep 17 00:00:00 2001
From: Dennis Wassenberg <[email protected]>
Date: Wed, 13 Apr 2016 13:46:55 +0200
Subject: [PATCH] thinkpad_acpi: Add support for HKEY version 0x200

Lenovo Thinkpad devices T460, T460s, T460p, T560, X260 use HKEY version 0x200 without adaptive keyboard.

HKEY version 0x200 has method MHKA with one parameter value. Passing parameter value 1 will get hotkey_all_mask (the same like HKEY version 0x100 without parameter). Passing parameter value 2 to MHKA method will retrieve hotkey_all_adaptive_mask. If 0 is returned in that case there is no adaptive keyboard available.

---
 drivers/platform/x86/thinkpad_acpi.c | 88 ++++++++++++++++++++++++++--------- -

 1 file changed, 64 insertions(+), 24 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +0 -0
index a268a7a..0e72857 100644
@@ -2043,6 +2043,7 @@ static int hotkey_autosleep_ack;


 static u32 hotkey_orig_mask; /* events the BIOS had enabled */
 static u32 hotkey_all_mask; /* all events supported in fw */
+static u32 hotkey_adaptive_all_mask; /* all adaptive events supported
in fw */
 static u32 hotkey_reserved_mask; /* events better left disabled */
 static u32 hotkey_driver_mask; /* events needed by the driver
*/
 static u32 hotkey_user_mask; /* events visible to userspace */

drivers/platform/x86/thinkpad_acpi.c +0 -0
@@ -2742,6 +2743,17 @@ static ssize_t hotkey_all_mask_show(struct device *dev,


 static DEVICE_ATTR_RO(hotkey_all_mask);

drivers/platform/x86/thinkpad_acpi.c

Quoted 7 lines
drivers/platform/x86/thinkpad_acpi.c +7 -0
+/* sysfs hotkey all_mask ----------------------------------------------- */
+static ssize_t hotkey_adaptive_all_mask_show(struct device *dev,
+			   struct device_attribute *attr,
+			   char *buf)
+{
+	return snprintf(buf, PAGE_SIZE, "0x%08x\n",
+				hotkey_adaptive_all_mask | hotkey_source_mask);

Make sure when you're indent function calls that split like this onto another line you indent it like this:

        return snprintf(buf, PAGE_SIZE, "0x%08x\n", hotkey_adaptive_all_mask | hotkey_source_mask);

So that "hotkey_adaptive_all_mask" starts on the column after the starting paranthesis.

Quoted 46 lines
drivers/platform/x86/thinkpad_acpi.c +4 -0
+}
+
+static DEVICE_ATTR_RO(hotkey_adaptive_all_mask);
+

 /* sysfs hotkey recommended_mask --------------------------------------- */ static ssize_t hotkey_recommended_mask_show(struct device *dev, struct device_attribute *attr,

drivers/platform/x86/thinkpad_acpi.c +1 -0
@@ -2985,6 +2997,7 @@ static struct attribute *hotkey_attributes[] __initdata
 = {
  	&dev_attr_wakeup_hotunplug_complete.attr,
  	&dev_attr_hotkey_mask.attr,
  	&dev_attr_hotkey_all_mask.attr,
+	&dev_attr_hotkey_adaptive_all_mask.attr,
  	&dev_attr_hotkey_recommended_mask.attr,
  #ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL

  &dev_attr_hotkey_source_mask.attr,

drivers/platform/x86/thinkpad_acpi.c +0 -0
@@ -3321,20 +3334,6 @@ static int __init hotkey_init(struct ibm_init_struct
 *iibm)
  	if (!tp_features.hotkey)
  		return 1;

drivers/platform/x86/thinkpad_acpi.c +0 -14
-	/*
-	 * Check if we have an adaptive keyboard, like on the
-	 * Lenovo Carbon X1 2014 (2nd Gen).
-	 */
-	if (acpi_evalf(hkey_handle, &hkeyv, "MHKV", "qd")) {
-		if ((hkeyv >> 8) == 2) {
-			tp_features.has_adaptive_kbd = true;
-			res = sysfs_create_group(&tpacpi_pdev->dev.kobj,
-					&adaptive_kbd_attr_group);
-			if (res)
-				goto err_exit;
-		}
-	}
-

  quirks = tpacpi_check_quirks(tpacpi_hotkey_qtable, ARRAY_SIZE(tpacpi_hotkey_qtable));

drivers/platform/x86/thinkpad_acpi.c +0 -0
@@ -3357,30 +3356,71 @@ static int __init hotkey_init(struct ibm_init_struct
 *iibm)

     A30, R30, R31, T20-22, X20-21, X22-24.  Detected by checking for HKEY interface version 0x100 */
  if (acpi_evalf(hkey_handle, &hkeyv, "MHKV", "qd")) {

drivers/platform/x86/thinkpad_acpi.c +0 -2
-		if ((hkeyv >> 8) != 1) {
-			pr_err("unknown version of the HKEY interface:

0x%x\n",

drivers/platform/x86/thinkpad_acpi.c

Quoted 6 lines
drivers/platform/x86/thinkpad_acpi.c +3 -3
-			       hkeyv);
-			pr_err("please report this to %s\n", TPACPI_MAIL);
-		} else {
+		vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY,
+			"firmware HKEY interface version: 0x%x\n",
+			hkeyv);

The indenting here wasn't correct to begin with, but since we're changing it we might as well fix it.

Quoted 14 lines
drivers/platform/x86/thinkpad_acpi.c +2 -0
+		switch (hkeyv >> 8) {
+		case 1:

  /*
   * MHKV 0x100 in A31, R40, R40e,
   * T4x, X31, and later */

drivers/platform/x86/thinkpad_acpi.c +0 -3
-			vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY,
-				"firmware HKEY interface version: 0x%x\n",
-				hkeyv);


  /* Paranoia check AND init hotkey_all_mask */ if (!acpi_evalf(hkey_handle, &hotkey_all_mask, "MHKA", "qd")) { pr_err("missing MHKA handler, "

drivers/platform/x86/thinkpad_acpi.c

Quoted 4 lines
drivers/platform/x86/thinkpad_acpi.c +2 -2
-				       "please report this to %s\n",
-				       TPACPI_MAIL);
+				        "please report this to %s\n",
+				        TPACPI_MAIL);

The indenting here doesn't need to be changed

Quoted 8 lines
drivers/platform/x86/thinkpad_acpi.c +8 -0
+				/* Fallback: pre-init for FN+F3,F4,F12 */
+				hotkey_all_mask = 0x080cU;
+			} else {
+				tp_features.hotkey_mask = 1;
+			}
+			break;
+
+		case 2:

drivers/platform/x86/thinkpad_acpi.c

Quoted 10 lines
drivers/platform/x86/thinkpad_acpi.c +10 -0
+			/*
+			 * MHKV 0x200 in X1, T460s, X260, T560, X1 Tablet (2016)
+			 */
+
+			/* Paranoia check AND init hotkey_all_mask */
+			if (!acpi_evalf(hkey_handle, &hotkey_all_mask,
+				"MHKA", "dd", 1)) {
+				pr_err("missing MHKA handler, "
+					"please report this to %s\n",
+					TPACPI_MAIL);

This indenting needs to be fixed as well

Once all those fixes are made and I get that extra testing done we should be ablew to send it upstream, assuming it doesn't break the X1…

Cheers,
Lyude

drivers/platform/x86/thinkpad_acpi.c

Quoted 12 lines

  /* Fallback: pre-init for FN+F3,F4,F12 */ hotkey_all_mask = 0x080cU;
  } else {
  tp_features.hotkey_mask = 1; }

drivers/platform/x86/thinkpad_acpi.c +7 -0
+
+			/*
+			 * Check if we have an adaptive keyboard, like on the
+			 * Lenovo Carbon X1 2014 (2nd Gen).
+			 */
+			if (acpi_evalf(hkey_handle,&hotkey_adaptive_all_mask,
+				"MHKA", "dd", 2)) {

Indentation needs to be fixed here as well

Quoted 25 lines
drivers/platform/x86/thinkpad_acpi.c +16 -0
+				if (hotkey_adaptive_all_mask != 0) {
+					tp_features.has_adaptive_kbd = true;
+					res = sysfs_create_group(
+						&tpacpi_pdev->dev.kobj,
+						&adaptive_kbd_attr_group);
+					if (res)
+						goto err_exit;
+				}
+			} else {
+				tp_features.has_adaptive_kbd = false;
+				hotkey_adaptive_all_mask = 0x0U;
+			}
+			break;
+
+		default:
+			pr_err("unknown version of the HKEY interface:

0x%x\n",

drivers/platform/x86/thinkpad_acpi.c +3 -0
+			       hkeyv);
+			pr_err("please report this to %s\n", TPACPI_MAIL);
+			break;

  }
  }

--
2.1.4

author Tested-by
#1 lore raw

Managed to find someone in the office with one of these laptops and it looks like the adaptive keyboard works perfectly with this patch, so I can give my t- b:

Cheers,
Lyude

Quoted 244 lines · Lyude Paul

Since nothing's really happened with this patch for a while I figured I'd take over trying to get this upstream.

Regarding testing: This seems to work fine on the 60 series laptops, and works fine on previous generations. The one thing I haven't been able to test is an X1
carbon with an adaptive keyboard since I don't seem to have one readily available here. I'm doing a search around the office to try to find someone who
didn't throw theirs away yet so hopefully I should be able to get back to you on
that soon.

To Dennis: I took the liberty of doing a review of your patch and some testing.
There's a few things that need changing, I've outlined them below: (for the future, it's recommended to send patches for the kernel inline in emails to make
them easier to review).

Quoted 53 lines

From 8a67f5db1d2918c46b7fa2168e3d0aab2ba92731 Mon Sep 17 00:00:00 2001
From: Dennis Wassenberg <[email protected]>
Date: Wed, 13 Apr 2016 13:46:55 +0200
Subject: [PATCH] thinkpad_acpi: Add support for HKEY version 0x200

Lenovo Thinkpad devices T460, T460s, T460p, T560, X260 use HKEY version 0x200 without adaptive keyboard.

HKEY version 0x200 has method MHKA with one parameter value. Passing parameter value 1 will get hotkey_all_mask (the same like HKEY version 0x100 without parameter). Passing parameter value 2 to MHKA method will retrieve hotkey_all_adaptive_mask. If 0 is returned in that case there is no adaptive keyboard available.

---
 drivers/platform/x86/thinkpad_acpi.c | 88 ++++++++++++++++++++++++++------- --
-

 1 file changed, 64 insertions(+), 24 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +0 -0
index a268a7a..0e72857 100644
@@ -2043,6 +2043,7 @@ static int hotkey_autosleep_ack;


 static u32 hotkey_orig_mask; /* events the BIOS had enabled
*/
 static u32 hotkey_all_mask; /* all events supported in fw */
+static u32 hotkey_adaptive_all_mask; /* all adaptive events
supported
in fw */
 static u32 hotkey_reserved_mask; /* events better left disabled */
 static u32 hotkey_driver_mask; /* events needed by the
driver
*/
 static u32 hotkey_user_mask; /* events visible to userspace
*/

drivers/platform/x86/thinkpad_acpi.c +0 -0
@@ -2742,6 +2743,17 @@ static ssize_t hotkey_all_mask_show(struct device
 *dev,


 static DEVICE_ATTR_RO(hotkey_all_mask);

drivers/platform/x86/thinkpad_acpi.c +7 -0
+/* sysfs hotkey all_mask ----------------------------------------------- */
+static ssize_t hotkey_adaptive_all_mask_show(struct device *dev,
+			   struct device_attribute *attr,
+			   char *buf)
+{
+	return snprintf(buf, PAGE_SIZE, "0x%08x\n",
+				hotkey_adaptive_all_mask |
Quoted 1 line

hotkey_source_mask);

Make sure when you're indent function calls that split like this onto another line you indent it like this:

        return snprintf(buf, PAGE_SIZE, "0x%08x\n", hotkey_adaptive_all_mask | hotkey_source_mask);

So that "hotkey_adaptive_all_mask" starts on the column after the starting paranthesis.

Quoted 48 lines
drivers/platform/x86/thinkpad_acpi.c +4 -0
+}
+
+static DEVICE_ATTR_RO(hotkey_adaptive_all_mask);
+

 /* sysfs hotkey recommended_mask --------------------------------------- */ static ssize_t hotkey_recommended_mask_show(struct device *dev, struct device_attribute *attr,

drivers/platform/x86/thinkpad_acpi.c +0 -0
@@ -2985,6 +2997,7 @@ static struct attribute *hotkey_attributes[]

__initdata
= {
  &dev_attr_wakeup_hotunplug_complete.attr,
  &dev_attr_hotkey_mask.attr,
  &dev_attr_hotkey_all_mask.attr,

drivers/platform/x86/thinkpad_acpi.c +1 -0
+	&dev_attr_hotkey_adaptive_all_mask.attr,

  &dev_attr_hotkey_recommended_mask.attr,
 #ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL
  &dev_attr_hotkey_source_mask.attr,

drivers/platform/x86/thinkpad_acpi.c +0 -0
@@ -3321,20 +3334,6 @@ static int __init hotkey_init(struct ibm_init_struct
 *iibm)
  	if (!tp_features.hotkey)
  		return 1;

drivers/platform/x86/thinkpad_acpi.c +0 -14
-	/*
-	 * Check if we have an adaptive keyboard, like on the
-	 * Lenovo Carbon X1 2014 (2nd Gen).
-	 */
-	if (acpi_evalf(hkey_handle, &hkeyv, "MHKV", "qd")) {
-		if ((hkeyv >> 8) == 2) {
-			tp_features.has_adaptive_kbd = true;
-			res = sysfs_create_group(&tpacpi_pdev->dev.kobj,
-					&adaptive_kbd_attr_group);
-			if (res)
-				goto err_exit;
-		}
-	}
-

  quirks = tpacpi_check_quirks(tpacpi_hotkey_qtable, ARRAY_SIZE(tpacpi_hotkey_qtable));

drivers/platform/x86/thinkpad_acpi.c +0 -0
@@ -3357,30 +3356,71 @@ static int __init hotkey_init(struct ibm_init_struct
 *iibm)

     A30, R30, R31, T20-22, X20-21, X22-24.  Detected by checking for HKEY interface version 0x100 */
  if (acpi_evalf(hkey_handle, &hkeyv, "MHKV", "qd")) {

drivers/platform/x86/thinkpad_acpi.c +0 -2
-		if ((hkeyv >> 8) != 1) {
-			pr_err("unknown version of the HKEY interface:

0x%x\n",

drivers/platform/x86/thinkpad_acpi.c

Quoted 6 lines
drivers/platform/x86/thinkpad_acpi.c +3 -3
-			       hkeyv);
-			pr_err("please report this to %s\n", TPACPI_MAIL);
-		} else {
+		vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY,
+			"firmware HKEY interface version: 0x%x\n",
+			hkeyv);

The indenting here wasn't correct to begin with, but since we're changing it we
might as well fix it.

Quoted 15 lines
drivers/platform/x86/thinkpad_acpi.c +2 -0
+		switch (hkeyv >> 8) {
+		case 1:

  /*
   * MHKV 0x100 in A31, R40, R40e,
   * T4x, X31, and later */

drivers/platform/x86/thinkpad_acpi.c +0 -3
-			vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY,
-				"firmware HKEY interface version: 0x%x\n",
-				hkeyv);


  /* Paranoia check AND init hotkey_all_mask */ if (!acpi_evalf(hkey_handle, &hotkey_all_mask, "MHKA", "qd")) { pr_err("missing MHKA handler, "

drivers/platform/x86/thinkpad_acpi.c

Quoted 4 lines
drivers/platform/x86/thinkpad_acpi.c +2 -2
-				       "please report this to %s\n",
-				       TPACPI_MAIL);
+				        "please report this to %s\n",
+				        TPACPI_MAIL);

The indenting here doesn't need to be changed

Quoted 12 lines
drivers/platform/x86/thinkpad_acpi.c +10 -0
+				/* Fallback: pre-init for FN+F3,F4,F12 */
+				hotkey_all_mask = 0x080cU;
+			} else {
+				tp_features.hotkey_mask = 1;
+			}
+			break;
+
+		case 2:
+			/*
+			 * MHKV 0x200 in X1, T460s, X260, T560, X1 Tablet

(2016)

drivers/platform/x86/thinkpad_acpi.c

Quoted 8 lines
drivers/platform/x86/thinkpad_acpi.c +8 -0
+			 */
+
+			/* Paranoia check AND init hotkey_all_mask */
+			if (!acpi_evalf(hkey_handle, &hotkey_all_mask,
+				"MHKA", "dd", 1)) {
+				pr_err("missing MHKA handler, "
+					"please report this to %s\n",
+					TPACPI_MAIL);

This indenting needs to be fixed as well

Once all those fixes are made and I get that extra testing done we should be ablew to send it upstream, assuming it doesn't break the X1…

Cheers,
Lyude

Quoted 14 lines

  /* Fallback: pre-init for FN+F3,F4,F12 */ hotkey_all_mask = 0x080cU;
  } else {
  tp_features.hotkey_mask = 1; }

drivers/platform/x86/thinkpad_acpi.c +3 -0
+
+			/*
+			 * Check if we have an adaptive keyboard, like on

the

drivers/platform/x86/thinkpad_acpi.c +3 -0
+			 * Lenovo Carbon X1 2014 (2nd Gen).
+			 */
+			if

(acpi_evalf(hkey_handle,&hotkey_adaptive_all_mask,

drivers/platform/x86/thinkpad_acpi.c

Quoted 1 line
drivers/platform/x86/thinkpad_acpi.c +1 -0
+				"MHKA", "dd", 2)) {

Indentation needs to be fixed here as well

Quoted 22 lines
drivers/platform/x86/thinkpad_acpi.c +2 -0
+				if (hotkey_adaptive_all_mask != 0) {
+					tp_features.has_adaptive_kbd =

true;

drivers/platform/x86/thinkpad_acpi.c +14 -0
+					res = sysfs_create_group(
+						&tpacpi_pdev->dev.kobj,
+						&adaptive_kbd_attr_group);
+					if (res)
+						goto err_exit;
+				}
+			} else {
+				tp_features.has_adaptive_kbd = false;
+				hotkey_adaptive_all_mask = 0x0U;
+			}
+			break;
+
+		default:
+			pr_err("unknown version of the HKEY interface:

0x%x\n",

drivers/platform/x86/thinkpad_acpi.c +3 -0
+			       hkeyv);
+			pr_err("please report this to %s\n", TPACPI_MAIL);
+			break;
Quoted 5 lines

  }
  }

--
2.1.4

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
_______________________________________________
ibm-acpi-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel

#2 lore raw
Quoted 4 lines · Lyude Paul

Managed to find someone in the office with one of these laptops and it looks like the adaptive keyboard works perfectly with this patch, so I can give my t- b:

Quoted 25 lines

Cheers,
Lyude

Quoted 19 lines · Lyude Paul

Since nothing's really happened with this patch for a while I figured I'd take over trying to get this upstream.

Regarding testing: This seems to work fine on the 60 series laptops, and works fine on previous generations. The one thing I haven't been able to test is an X1
carbon with an adaptive keyboard since I don't seem to have one readily available here. I'm doing a search around the office to try to find someone who
didn't throw theirs away yet so hopefully I should be able to get back to you on
that soon.

To Dennis: I took the liberty of doing a review of your patch and some testing.
There's a few things that need changing, I've outlined them below: (for the future, it's recommended to send patches for the kernel inline in emails to make
them easier to review).

If someone would please update the patch with any pending changes from review and so it follows the rules in Documentation/SubmittingPatches, including the complete list of recipients on Cc, we can move this forward.

Regards,

Signature · 2 lines
Darren Hart
Intel Open Source Technology Center
#4 lore raw
Quoted 11 lines · Marco Trevisan (Treviño)

2016-06-07 17:10 GMT-04:00 Lyude Paul <[email protected]>:

Quoted 6 lines

Managed to find someone in the office with one of these laptops and it looks like the adaptive keyboard works perfectly with this patch, so I can give my t- b:

I can confirm it works too.

Ok, looks like the patch is safe. Let's fix the boring details (formating, etc), and then merge it.

Signature · 4 lines
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh
author
#5 lore raw

PATCH v2 1/1 thinkpad_acpi: Add support for HKEY version 0x200

From: Dennis Wassenberg <[email protected]>

Lenovo Thinkpad devices T460, T460s, T460p, T560, X260 use HKEY version 0x200 without adaptive keyboard.

HKEY version 0x200 has method MHKA with one parameter value. Passing parameter value 1 will get hotkey_all_mask (the same like HKEY version 0x100 without parameter). Passing parameter value 2 to MHKA method will retrieve hotkey_all_adaptive_mask. If 0 is returned in that case there is no adaptive keyboard available.

---
Changes since v1:
- Fix all of the indenting issues
- Add appropriate Tested-by's, Signed-off's, etc.

 drivers/platform/x86/thinkpad_acpi.c | 85 ++++++++++++++++++++++++++----------
 1 file changed, 63 insertions(+), 22 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +63 -22
index 9255ff3..210ecf5 100644
@@ -2043,6 +2043,7 @@ static int hotkey_autosleep_ack;
 
 static u32 hotkey_orig_mask;		/* events the BIOS had enabled */
 static u32 hotkey_all_mask;		/* all events supported in fw */
+static u32 hotkey_adaptive_all_mask;	/* all adaptive events supported in fw */
 static u32 hotkey_reserved_mask;	/* events better left disabled */
 static u32 hotkey_driver_mask;		/* events needed by the driver */
 static u32 hotkey_user_mask;		/* events visible to userspace */
@@ -2742,6 +2743,17 @@ static ssize_t hotkey_all_mask_show(struct device *dev,
 
 static DEVICE_ATTR_RO(hotkey_all_mask);
 
+/* sysfs hotkey all_mask ----------------------------------------------- */
+static ssize_t hotkey_adaptive_all_mask_show(struct device *dev,
+			   struct device_attribute *attr,
+			   char *buf)
+{
+	return snprintf(buf, PAGE_SIZE, "0x%08x\n",
+			hotkey_adaptive_all_mask | hotkey_source_mask);
+}
+
+static DEVICE_ATTR_RO(hotkey_adaptive_all_mask);
+
 /* sysfs hotkey recommended_mask --------------------------------------- */
 static ssize_t hotkey_recommended_mask_show(struct device *dev,
 					    struct device_attribute *attr,
@@ -2985,6 +2997,7 @@ static struct attribute *hotkey_attributes[] __initdata = {
 	&dev_attr_wakeup_hotunplug_complete.attr,
 	&dev_attr_hotkey_mask.attr,
 	&dev_attr_hotkey_all_mask.attr,
+	&dev_attr_hotkey_adaptive_all_mask.attr,
 	&dev_attr_hotkey_recommended_mask.attr,
 #ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL
 	&dev_attr_hotkey_source_mask.attr,
@@ -3321,20 +3334,6 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
 	if (!tp_features.hotkey)
 		return 1;
 
-	/*
-	 * Check if we have an adaptive keyboard, like on the
-	 * Lenovo Carbon X1 2014 (2nd Gen).
-	 */
-	if (acpi_evalf(hkey_handle, &hkeyv, "MHKV", "qd")) {
-		if ((hkeyv >> 8) == 2) {
-			tp_features.has_adaptive_kbd = true;
-			res = sysfs_create_group(&tpacpi_pdev->dev.kobj,
-					&adaptive_kbd_attr_group);
-			if (res)
-				goto err_exit;
-		}
-	}
-
 	quirks = tpacpi_check_quirks(tpacpi_hotkey_qtable,
 				     ARRAY_SIZE(tpacpi_hotkey_qtable));
 
@@ -3357,18 +3356,16 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
 	   A30, R30, R31, T20-22, X20-21, X22-24.  Detected by checking
 	   for HKEY interface version 0x100 */
 	if (acpi_evalf(hkey_handle, &hkeyv, "MHKV", "qd")) {
-		if ((hkeyv >> 8) != 1) {
-			pr_err("unknown version of the HKEY interface: 0x%x\n",
-			       hkeyv);
-			pr_err("please report this to %s\n", TPACPI_MAIL);
-		} else {
+		vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY,
+			    "firmware HKEY interface version: 0x%x\n",
+			    hkeyv);
+
+		switch (hkeyv >> 8) {
+		case 1:
 			/*
 			 * MHKV 0x100 in A31, R40, R40e,
 			 * T4x, X31, and later
 			 */
-			vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY,
-				"firmware HKEY interface version: 0x%x\n",
-				hkeyv);
 
 			/* Paranoia check AND init hotkey_all_mask */
 			if (!acpi_evalf(hkey_handle, &hotkey_all_mask,
@@ -3381,6 +3378,50 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
 			} else {
 				tp_features.hotkey_mask = 1;
 			}
+			break;
+
+		case 2:
+			/*
+			 * MHKV 0x200 in X1, T460s, X260, T560, X1 Tablet (2016)
+			 */
+
+			/* Paranoia check AND init hotkey_all_mask */
+			if (!acpi_evalf(hkey_handle, &hotkey_all_mask,
+					"MHKA", "dd", 1)) {
+				pr_err("missing MHKA handler, "
+				       "please report this to %s\n",
+				       TPACPI_MAIL);
+				/* Fallback: pre-init for FN+F3,F4,F12 */
+				hotkey_all_mask = 0x080cU;
+			} else {
+				tp_features.hotkey_mask = 1;
+			}
+
+			/*
+			 * Check if we have an adaptive keyboard, like on the
+			 * Lenovo Carbon X1 2014 (2nd Gen).
+			 */
+			if (acpi_evalf(hkey_handle, &hotkey_adaptive_all_mask,
+				       "MHKA", "dd", 2)) {
+				if (hotkey_adaptive_all_mask != 0) {
+					tp_features.has_adaptive_kbd = true;
+					res = sysfs_create_group(
+						&tpacpi_pdev->dev.kobj,
+						&adaptive_kbd_attr_group);
+					if (res)
+						goto err_exit;
+				}
+			} else {
+				tp_features.has_adaptive_kbd = false;
+				hotkey_adaptive_all_mask = 0x0U;
+			}
+			break;
+
+		default:
+			pr_err("unknown version of the HKEY interface: 0x%x\n",
+			       hkeyv);
+			pr_err("please report this to %s\n", TPACPI_MAIL);
+			break;
 		}
 	}
 
Signature · 1 line
2.5.5
#6 lore raw
Quoted 114 lines · Lyude

From: Dennis Wassenberg <[email protected]>

Lenovo Thinkpad devices T460, T460s, T460p, T560, X260 use HKEY version 0x200 without adaptive keyboard.

HKEY version 0x200 has method MHKA with one parameter value. Passing parameter value 1 will get hotkey_all_mask (the same like HKEY version 0x100 without parameter). Passing parameter value 2 to MHKA method will retrieve hotkey_all_adaptive_mask. If 0 is returned in that case there is no adaptive keyboard available.

---
Changes since v1:
- Fix all of the indenting issues
- Add appropriate Tested-by's, Signed-off's, etc.

 drivers/platform/x86/thinkpad_acpi.c | 85 ++++++++++++++++++++++++++----------
 1 file changed, 63 insertions(+), 22 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +21 -22
index 9255ff3..210ecf5 100644
@@ -2043,6 +2043,7 @@ static int hotkey_autosleep_ack;
 
 static u32 hotkey_orig_mask;		/* events the BIOS had enabled */
 static u32 hotkey_all_mask;		/* all events supported in fw */
+static u32 hotkey_adaptive_all_mask;	/* all adaptive events supported in fw */
 static u32 hotkey_reserved_mask;	/* events better left disabled */
 static u32 hotkey_driver_mask;		/* events needed by the driver */
 static u32 hotkey_user_mask;		/* events visible to userspace */
@@ -2742,6 +2743,17 @@ static ssize_t hotkey_all_mask_show(struct device *dev,
 
 static DEVICE_ATTR_RO(hotkey_all_mask);
 
+/* sysfs hotkey all_mask ----------------------------------------------- */
+static ssize_t hotkey_adaptive_all_mask_show(struct device *dev,
+			   struct device_attribute *attr,
+			   char *buf)
+{
+	return snprintf(buf, PAGE_SIZE, "0x%08x\n",
+			hotkey_adaptive_all_mask | hotkey_source_mask);
+}
+
+static DEVICE_ATTR_RO(hotkey_adaptive_all_mask);
+
 /* sysfs hotkey recommended_mask --------------------------------------- */
 static ssize_t hotkey_recommended_mask_show(struct device *dev,
 					    struct device_attribute *attr,
@@ -2985,6 +2997,7 @@ static struct attribute *hotkey_attributes[] __initdata = {
 	&dev_attr_wakeup_hotunplug_complete.attr,
 	&dev_attr_hotkey_mask.attr,
 	&dev_attr_hotkey_all_mask.attr,
+	&dev_attr_hotkey_adaptive_all_mask.attr,
 	&dev_attr_hotkey_recommended_mask.attr,
 #ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL
 	&dev_attr_hotkey_source_mask.attr,
@@ -3321,20 +3334,6 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
 	if (!tp_features.hotkey)
 		return 1;
 
-	/*
-	 * Check if we have an adaptive keyboard, like on the
-	 * Lenovo Carbon X1 2014 (2nd Gen).
-	 */
-	if (acpi_evalf(hkey_handle, &hkeyv, "MHKV", "qd")) {
-		if ((hkeyv >> 8) == 2) {
-			tp_features.has_adaptive_kbd = true;
-			res = sysfs_create_group(&tpacpi_pdev->dev.kobj,
-					&adaptive_kbd_attr_group);
-			if (res)
-				goto err_exit;
-		}
-	}
-
 	quirks = tpacpi_check_quirks(tpacpi_hotkey_qtable,
 				     ARRAY_SIZE(tpacpi_hotkey_qtable));
 
@@ -3357,18 +3356,16 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
 	   A30, R30, R31, T20-22, X20-21, X22-24.  Detected by checking
 	   for HKEY interface version 0x100 */
 	if (acpi_evalf(hkey_handle, &hkeyv, "MHKV", "qd")) {
-		if ((hkeyv >> 8) != 1) {
-			pr_err("unknown version of the HKEY interface: 0x%x\n",
-			       hkeyv);
-			pr_err("please report this to %s\n", TPACPI_MAIL);
-		} else {
+		vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY,
+			    "firmware HKEY interface version: 0x%x\n",
+			    hkeyv);
+
+		switch (hkeyv >> 8) {
+		case 1:
 			/*
 			 * MHKV 0x100 in A31, R40, R40e,
 			 * T4x, X31, and later
 			 */
-			vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY,
-				"firmware HKEY interface version: 0x%x\n",
-				hkeyv);
 
 			/* Paranoia check AND init hotkey_all_mask */
 			if (!acpi_evalf(hkey_handle, &hotkey_all_mask,
@@ -3381,6 +3378,50 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
 			} else {
 				tp_features.hotkey_mask = 1;
 			}
+			break;
+

drivers/platform/x86/thinkpad_acpi.c static int __init hotkey_init(struct ibm_init_struct *iibm) · line 3392

Quoted 10 lines
drivers/platform/x86/thinkpad_acpi.c +10 -0
+		case 2:
+			/*
+			 * MHKV 0x200 in X1, T460s, X260, T560, X1 Tablet (2016)
+			 */
+
+			/* Paranoia check AND init hotkey_all_mask */
+			if (!acpi_evalf(hkey_handle, &hotkey_all_mask,
+					"MHKA", "dd", 1)) {
+				pr_err("missing MHKA handler, "
+				       "please report this to %s\n",

Strings should be kept on the same line so they can be searched for in the sources. I've corrected this here as well as the existing duplicate message in case 1.

Otherwise, queued for 4.8. Thanks.

Signature · 9 lines
Darren Hart
Intel Open Source Technology Center

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
#7 lore raw
In reply to Lyude

2016-06-08 10:54 GMT-04:00 Lyude <[email protected]>:

Quoted 11 lines

From: Dennis Wassenberg <[email protected]>

Lenovo Thinkpad devices T460, T460s, T460p, T560, X260 use HKEY version 0x200 without adaptive keyboard.

HKEY version 0x200 has method MHKA with one parameter value. Passing parameter value 1 will get hotkey_all_mask (the same like HKEY version 0x100 without parameter). Passing parameter value 2 to MHKA method will retrieve hotkey_all_adaptive_mask. If 0 is returned in that case there is no adaptive keyboard available.

Quoted 5 lines

Can you also Cc: [email protected] so that it can be imported there once merged?

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e

#8 lore raw
Quoted 12 lines · Marco Trevisan (Treviño)

2016-06-08 10:54 GMT-04:00 Lyude <[email protected]>:

Quoted 11 lines

From: Dennis Wassenberg <[email protected]>

Lenovo Thinkpad devices T460, T460s, T460p, T560, X260 use HKEY version 0x200 without adaptive keyboard.

HKEY version 0x200 has method MHKA with one parameter value. Passing parameter value 1 will get hotkey_all_mask (the same like HKEY version 0x100 without parameter). Passing parameter value 2 to MHKA method will retrieve hotkey_all_adaptive_mask. If 0 is returned in that case there is no adaptive keyboard available.

Quoted 8 lines
Quoted 5 lines

Can you also Cc: [email protected] so that it can be imported there once merged?

It doesn't meet stable kernel rules unfortunately, with 143 lines diff.

Henrique, do you want to weigh in on whether this goes back to stable?

One thing I could do is include this in my 4.7-rc fixes branch instead of waiting for 4.8.

Signature · 2 lines
Darren Hart
Intel Open Source Technology Center
#9 lore raw
Quoted 19 lines · Darren Hart
Quoted 18 lines · Marco Trevisan (Treviño)

2016-06-08 10:54 GMT-04:00 Lyude <[email protected]>:

Quoted 16 lines

From: Dennis Wassenberg <[email protected]>

Lenovo Thinkpad devices T460, T460s, T460p, T560, X260 use HKEY version 0x200 without adaptive keyboard.

HKEY version 0x200 has method MHKA with one parameter value. Passing parameter value 1 will get hotkey_all_mask (the same like HKEY version 0x100 without parameter). Passing parameter value 2 to MHKA method will retrieve hotkey_all_adaptive_mask. If 0 is returned in that case there is no adaptive keyboard available.

Quoted 6 lines
Quoted 2 lines

Can you also Cc: [email protected] so that it can be imported there once merged?

It doesn't meet stable kernel rules unfortunately, with 143 lines diff.

Henrique, do you want to weigh in on whether this goes back to stable?

It should be in a bunch of -rc kernel releases before we even consider it.

Quoted 2 lines

One thing I could do is include this in my 4.7-rc fixes branch instead of waiting for 4.8.

If Linus will take it, I don't see a problem with that.

Signature · 11 lines
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
#10 lore raw
Quoted 27 lines · Henrique de Moraes Holschuh
Quoted 19 lines · Darren Hart
Quoted 18 lines · Marco Trevisan (Treviño)

2016-06-08 10:54 GMT-04:00 Lyude <[email protected]>:

Quoted 16 lines

From: Dennis Wassenberg <[email protected]>

Lenovo Thinkpad devices T460, T460s, T460p, T560, X260 use HKEY version 0x200 without adaptive keyboard.

HKEY version 0x200 has method MHKA with one parameter value. Passing parameter value 1 will get hotkey_all_mask (the same like HKEY version 0x100 without parameter). Passing parameter value 2 to MHKA method will retrieve hotkey_all_adaptive_mask. If 0 is returned in that case there is no adaptive keyboard available.

Quoted 6 lines
Quoted 2 lines

Can you also Cc: [email protected] so that it can be imported there once merged?

It doesn't meet stable kernel rules unfortunately, with 143 lines diff.

Henrique, do you want to weigh in on whether this goes back to stable?

Quoted 7 lines

It should be in a bunch of -rc kernel releases before we even consider it.

Quoted 2 lines

One thing I could do is include this in my 4.7-rc fixes branch instead of waiting for 4.8.

If Linus will take it, I don't see a problem with that.

I'll do that.

Signature · 9 lines
Darren Hart
Intel Open Source Technology Center

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e