HKEY version 0x200

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

 



Hi,

I read your messages regarding hkeyv 0x200 Thinkpads...

I would like to contribute to this topic as well.

I believe (don't know, just guessing) that we should not make the
feature "has_adaptive_kbd" depend on hkeyv 0x200. Instead we should use
the "MHKA" method to evaluate if there is a flags mask set for the
adaptive keyboard. I assume that if we pass "1" to the MHKA method we
will get the hotkey_all_mask. If we pass "2" to the MHKA mask we will
get the hotkey_all_adaptive_mask. Thats my assumption which is based on
the observation of current Lenovo Skylake devices and the Thinkpad X1
Carbon (2014).

I checked it with T460, T460p, T460s, T560, X260 and X1 Tablet (2016).
All of these devices return 0 in that case. Only the X1 Carbon (2014)
will return 0x1FFFFFFF. The Thinkpads L460 and L560 are not covered by
this because they have hkeyv 0x100.

I prepared a patch which does what I described above (attachment). This
works fine in my case with kernel >= 4.3 until 4.6-rc3 for T460, T460p,
T460s, T560, X260. All hkeyv 0x100 Thinkpads should not be affected by
this change. Whats your opinion about this patch?

Testing this with Lenovo Thinkpad X1 Tablet (2016) will make the hotkeys
generate an event but currently there seems to be a mapping issue
because the most events are "KEY_UNKNOWN".

Additionally I observed that the new Skylake Thinkpads have no HKEY
methods GDFR, STRW, GTRW, SBMI, SVOI, GVOI, GCGI, GHOV, NALL, SAPI,
GAPI, SMNC, GMNC, SCMI, GCMI, SCMD, GCMD, GMMS, UAND, DGBL, SDHK, GDHK,
SDFL, GDFL, SDAM, GDAM in contrast to X1 Carbon (2014) with HKEY 0x200.


Best regards,

Dennis

> On Sat, Apr 09, 2016 at 01:54:01PM -0300, Henrique de Moraes Holschuh
> wrote:
> > On Sun, 03 Apr 2016, Yrjan Skrimstad wrote:
> > > I get the following message when booting 4.6-rc1 on my Thinkpad T460s:
> > [    4.067246] thinkpad_acpi: unknown version of the HKEY interface:
0x200
> > > [    4.068819] thinkpad_acpi: please report this to ibm-acpi-devel@...
> > >
> > > I also have a number of hotkeys that will not work unless I change the
> > > code. The code changes I did to test this was very similar to this
> > > patch from 2014:
> > >
> > >
https://sourceforge.net/p/ibm-acpi/mailman/ibm-acpi-devel/thread/531F0073.7060103%40canonical.com/#msg32086976
> > >
> > > However, this patch was never merged and I cannot find the reason for
> > > this. Is there a chance this patch or a similar patch could be
> > > accepted?
> >
> > Yes, but it needs someone that accepts to be responsible for it
(i.e. handle
> > bug reports by helping with the testing) at least until I get a thinkpad
> > that has HKEY 0x200...

> I would very much like to assist here. I'm currently using the patch
on 4.6-rc2, but I wouldn't mind testing it anywhere else it might be needed.

> > > On a sidenote: the feature "has_adaptive_kbd" gets set on this laptop
> > > (possibly all hkeyv 0x200 Thinkpads?). This laptop does not have an
> > > adaptive keyboard, so this seems unintentional. Would there be a way
> > > to better detect if there is an adaptive keyboard?
> >
> > Probably it can be detected through either ACPI method calls, or the
> > presence or non-presence of some ACPI identifier/method.
> >
> > Fix this requires the cooperation of someone with HKEY 0x200 and an
> > adaptative keyboard, and someone with HKEY 0x200 without an adaptative
> > keyboard.
> >
> > Also, it is possible that the thinkpad does have an adaptative
keyboard as
> > far as the firmware is concerned, but no hardware interfaces that
expose it.
> > In that case, you'd have to test the resulting behavior, and report
it in
> > details.  Worse comes to worst case, we can add a
whitelist/blacklist to the
> > driver and keep it up-to-date.  I hope the behavior is "it doesn't do
> > anything nasty" so it becomes a cosmetic issue...

> I have not seen anything nasty that I suspect have anything to do with
this other than errors like this:

> [ 1259.945126] thinkpad_acpi: Cannot read adaptive keyboard mode.
>
> and this:
>
> [ 1260.910584] thinkpad_acpi: Cannot set adaptive keyboard mode.
From 8a67f5db1d2918c46b7fa2168e3d0aab2ba92731 Mon Sep 17 00:00:00 2001
From: Dennis Wassenberg <dennis.wassenberg@xxxxxxxxxxx>
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.

Signed-off-by: Dennis Wassenberg <dennis.wassenberg@xxxxxxxxxxx>
---
 drivers/platform/x86/thinkpad_acpi.c | 88 ++++++++++++++++++++++++++----------
 1 file changed, 64 insertions(+), 24 deletions(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index a268a7a..0e72857 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -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,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")) {
-		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,
 					"MHKA", "qd")) {
 				pr_err("missing MHKA handler, "
-				       "please report this to %s\n",
-				       TPACPI_MAIL);
+				        "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;
+			}
+			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;
 		}
 	}
 
-- 
2.1.4

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
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