[PATCH] Input: atkbd - filter buggy codes on ASUS Q500A

Subsystems: input (keyboard, mouse, joystick, touchscreen) drivers, the rest

STALE3601d

3 messages, 2 authors, 2016-09-09 · open the first message on its own page

[PATCH] Input: atkbd - filter buggy codes on ASUS Q500A

From: Oleksij Rempel <hidden>
Date: 2016-07-29 19:41:58

Some revision of ASUS Q500A series have keyboard related
issue which is reproducible only if Windows with installed ASUS
tools was ever started.
In this case the Linux side will have blocked keyboard or
report wrong or incomplete hotkey events.
To make Linux work properly again complete power down
(unplug power supply and remove battery) should be made.

Linux/atkbd after clean start will get fallowing code on VOLUME_UP
key: {0xe0, 0x30, 0xe0, 0xb0}. After Windows, same key will generate this
codes: {0xe1, 0x23, 0xe0, 0x30, 0xe0, 0xb0}. As result atkdb will
be confused by buggy codes.

This patch is filtering this buggy code out.

https://bugzilla.kernel.org/show_bug.cgi?id=119391

Signed-off-by: Oleksij Rempel <redacted>
Sponsored-by: Alex Henrie [off-list ref]
CC: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/keyboard/atkbd.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index ec876b5..949c199 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -996,6 +996,17 @@ static unsigned int atkbd_oqo_01plus_scancode_fixup(struct atkbd *atkbd,
 	return code;
 }
 
+static unsigned int atkbd_asus_q500a_scancode_fixup(struct atkbd *atkbd,
+						    unsigned int code)
+{
+	if (atkbd->translated && atkbd->emul == 2 && code == 0x23) {
+		atkbd->emul = 0;
+		return ATKBD_RET_ERR;
+	}
+
+	return code;
+}
+
 /*
  * atkbd_set_keycode_table() initializes keyboard's keycode table
  * according to the selected scancode set
@@ -1802,6 +1813,14 @@ static const struct dmi_system_id atkbd_dmi_quirk_table[] __initconst = {
 		},
 		.callback = atkbd_deactivate_fixup,
 	},
+	{
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "Q500A"),
+		},
+		.callback = atkbd_setup_scancode_fixup,
+		.driver_data = atkbd_asus_q500a_scancode_fixup,
+	},
 	{ }
 };
 
-- 
2.7.4

Re: [PATCH] Input: atkbd - filter buggy codes on ASUS Q500A

From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: 2016-08-04 00:51:04

Hi Oleksij,

On Fri, Jul 29, 2016 at 09:41:44PM +0200, Oleksij Rempel wrote:
Some revision of ASUS Q500A series have keyboard related
issue which is reproducible only if Windows with installed ASUS
tools was ever started.
In this case the Linux side will have blocked keyboard or
report wrong or incomplete hotkey events.
To make Linux work properly again complete power down
(unplug power supply and remove battery) should be made.

Linux/atkbd after clean start will get fallowing code on VOLUME_UP
key: {0xe0, 0x30, 0xe0, 0xb0}. After Windows, same key will generate this
codes: {0xe1, 0x23, 0xe0, 0x30, 0xe0, 0xb0}. As result atkdb will
be confused by buggy codes.

This patch is filtering this buggy code out.

https://bugzilla.kernel.org/show_bug.cgi?id=119391

Signed-off-by: Oleksij Rempel <redacted>
Sponsored-by: Alex Henrie [off-list ref]
CC: Dmitry Torokhov <dmitry.torokhov@gmail.com>
I'd prefer it was done as a i8042_filter() installed in a platform
driver (asus-laptop.c?). I a filter you'd need to note the fact that you
received e1 and when you receive next character you either swallo both
or re-inject e1 and the new character. See filter implementation in
./drivers/input/misc/ideapad_slidebar.c.

The scancode fixup method is quite old and is better suited when you
actually want to use the scancode, just a different one. Here you are
forced to user ATKBD_RET_ERR which causes debug messages and increment
error counter.

Thanks.
quoted hunk
---
 drivers/input/keyboard/atkbd.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index ec876b5..949c199 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -996,6 +996,17 @@ static unsigned int atkbd_oqo_01plus_scancode_fixup(struct atkbd *atkbd,
 	return code;
 }
 
+static unsigned int atkbd_asus_q500a_scancode_fixup(struct atkbd *atkbd,
+						    unsigned int code)
+{
+	if (atkbd->translated && atkbd->emul == 2 && code == 0x23) {
+		atkbd->emul = 0;
+		return ATKBD_RET_ERR;
+	}
+
+	return code;
+}
+
 /*
  * atkbd_set_keycode_table() initializes keyboard's keycode table
  * according to the selected scancode set
@@ -1802,6 +1813,14 @@ static const struct dmi_system_id atkbd_dmi_quirk_table[] __initconst = {
 		},
 		.callback = atkbd_deactivate_fixup,
 	},
+	{
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "Q500A"),
+		},
+		.callback = atkbd_setup_scancode_fixup,
+		.driver_data = atkbd_asus_q500a_scancode_fixup,
+	},
 	{ }
 };
 
-- 
2.7.4
-- 
Dmitry

Re: [PATCH] Input: atkbd - filter buggy codes on ASUS Q500A

From: Oleksij Rempel <hidden>
Date: 2016-09-09 08:27:36

Am 04.08.2016 um 02:50 schrieb Dmitry Torokhov:
Hi Oleksij,

On Fri, Jul 29, 2016 at 09:41:44PM +0200, Oleksij Rempel wrote:
quoted
Some revision of ASUS Q500A series have keyboard related
issue which is reproducible only if Windows with installed ASUS
tools was ever started.
In this case the Linux side will have blocked keyboard or
report wrong or incomplete hotkey events.
To make Linux work properly again complete power down
(unplug power supply and remove battery) should be made.

Linux/atkbd after clean start will get fallowing code on VOLUME_UP
key: {0xe0, 0x30, 0xe0, 0xb0}. After Windows, same key will generate this
codes: {0xe1, 0x23, 0xe0, 0x30, 0xe0, 0xb0}. As result atkdb will
be confused by buggy codes.

This patch is filtering this buggy code out.

https://bugzilla.kernel.org/show_bug.cgi?id=119391

Signed-off-by: Oleksij Rempel <redacted>
Sponsored-by: Alex Henrie [off-list ref]
CC: Dmitry Torokhov <dmitry.torokhov@gmail.com>
I'd prefer it was done as a i8042_filter() installed in a platform
driver (asus-laptop.c?). I a filter you'd need to note the fact that you
received e1 and when you receive next character you either swallo both
or re-inject e1 and the new character. See filter implementation in
./drivers/input/misc/ideapad_slidebar.c.

The scancode fixup method is quite old and is better suited when you
actually want to use the scancode, just a different one. Here you are
forced to user ATKBD_RET_ERR which causes debug messages and increment
error counter.
Hm... i was seeking for a proper place for this filter and noticed
fallowing issue. If asus_nb_wmi driver is loaded and machine is in bad
state after windows start i get this scan codes:

0x5f 0xdf
0x5f 0xdf 0x23
0x5f 0xdf
0x5f 0xdf 0x23
0xe0 0x1f 0xe0 0x9f
0xe0 0x1f 0xe0 0x9f 0x23
0xe0 0x1f 0xe0 0x9f
0xe0 0x1f 0xe0 0x9f 0x23
0xe0 0x3b 0xe0 0xbb
0xe0 0x3b 0xe0 0xbb 0x23
0xe0 0x3b 0xe0 0xbb
0xe0 0x3b 0xe0 0xbb 0x23
--- 0x23 is a good indicator for previously described corrupted codes.
If i remove asus_nb_wmi driver, i'll get only 0x23 on each second hot
kay event:

0x23
0x23
0x23

I ask my self if it make any sense to filter it in platform driver.
Because in case it is not loaded i still have broken keyboard. If atkbd
is not load, there is no issue - it is just not working ;)

Thanks.
quoted
---
 drivers/input/keyboard/atkbd.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index ec876b5..949c199 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -996,6 +996,17 @@ static unsigned int atkbd_oqo_01plus_scancode_fixup(struct atkbd *atkbd,
 	return code;
 }
 
+static unsigned int atkbd_asus_q500a_scancode_fixup(struct atkbd *atkbd,
+						    unsigned int code)
+{
+	if (atkbd->translated && atkbd->emul == 2 && code == 0x23) {
+		atkbd->emul = 0;
+		return ATKBD_RET_ERR;
+	}
+
+	return code;
+}
+
 /*
  * atkbd_set_keycode_table() initializes keyboard's keycode table
  * according to the selected scancode set
@@ -1802,6 +1813,14 @@ static const struct dmi_system_id atkbd_dmi_quirk_table[] __initconst = {
 		},
 		.callback = atkbd_deactivate_fixup,
 	},
+	{
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "Q500A"),
+		},
+		.callback = atkbd_setup_scancode_fixup,
+		.driver_data = atkbd_asus_q500a_scancode_fixup,
+	},
 	{ }
 };
 
-- 
2.7.4

-- 
Regards,
Oleksij
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help