Skip to content

Commit b564353

Browse files
oleremdvhart
authored andcommitted
platform/x86: asus-wmi: Filter buggy scan codes on ASUS Q500A
Some revisions of the ASUS Q500A series have a keyboard related issue which is reproducible only after Windows with installed ASUS tools is started. In this case the Linux side will have a blocked keyboard or report incorrect or incomplete hotkey events. To make Linux work properly again, a complete power down (unplug power supply and remove battery) is needed. Linux/atkbd after a clean start will get the following code on VOLUME_UP key: {0xe0, 0x30, 0xe0, 0xb0}. After Windows, the 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 <linux@rempel-privat.de> Cc: Alex Henrie <alexhenrie24@gmail.com> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com> Cc: Corentin Chary <corentin.chary@gmail.com> Cc: acpi4asus-user@lists.sourceforge.net Cc: platform-driver-x86@vger.kernel.org Cc: linux-kernel@vger.kernel.org [dvhart: Add return after pr_warn to avoid false confirmation of filter] Signed-off-by: Darren Hart <dvhart@linux.intel.com>
1 parent 28e476d commit b564353

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

drivers/platform/x86/asus-nb-wmi.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <linux/input/sparse-keymap.h>
2828
#include <linux/fb.h>
2929
#include <linux/dmi.h>
30+
#include <linux/i8042.h>
3031

3132
#include "asus-wmi.h"
3233

@@ -55,10 +56,34 @@ MODULE_PARM_DESC(wapf, "WAPF value");
5556

5657
static struct quirk_entry *quirks;
5758

59+
static bool asus_q500a_i8042_filter(unsigned char data, unsigned char str,
60+
struct serio *port)
61+
{
62+
static bool extended;
63+
bool ret = false;
64+
65+
if (str & I8042_STR_AUXDATA)
66+
return false;
67+
68+
if (unlikely(data == 0xe1)) {
69+
extended = true;
70+
ret = true;
71+
} else if (unlikely(extended)) {
72+
extended = false;
73+
ret = true;
74+
}
75+
76+
return ret;
77+
}
78+
5879
static struct quirk_entry quirk_asus_unknown = {
5980
.wapf = 0,
6081
};
6182

83+
static struct quirk_entry quirk_asus_q500a = {
84+
.i8042_filter = asus_q500a_i8042_filter,
85+
};
86+
6287
/*
6388
* For those machines that need software to control bt/wifi status
6489
* and can't adjust brightness through ACPI interface
@@ -98,6 +123,15 @@ static int dmi_matched(const struct dmi_system_id *dmi)
98123
}
99124

100125
static const struct dmi_system_id asus_quirks[] = {
126+
{
127+
.callback = dmi_matched,
128+
.ident = "ASUSTeK COMPUTER INC. Q500A",
129+
.matches = {
130+
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
131+
DMI_MATCH(DMI_PRODUCT_NAME, "Q500A"),
132+
},
133+
.driver_data = &quirk_asus_q500a,
134+
},
101135
{
102136
.callback = dmi_matched,
103137
.ident = "ASUSTeK COMPUTER INC. U32U",
@@ -369,6 +403,8 @@ static const struct dmi_system_id asus_quirks[] = {
369403

370404
static void asus_nb_wmi_quirks(struct asus_wmi_driver *driver)
371405
{
406+
int ret;
407+
372408
quirks = &quirk_asus_unknown;
373409
dmi_check_system(asus_quirks);
374410

@@ -380,6 +416,15 @@ static void asus_nb_wmi_quirks(struct asus_wmi_driver *driver)
380416
quirks->wapf = wapf;
381417
else
382418
wapf = quirks->wapf;
419+
420+
if (quirks->i8042_filter) {
421+
ret = i8042_install_filter(quirks->i8042_filter);
422+
if (ret) {
423+
pr_warn("Unable to install key filter\n");
424+
return;
425+
}
426+
pr_info("Using i8042 filter function for receiving events\n");
427+
}
383428
}
384429

385430
static const struct key_entry asus_nb_wmi_keymap[] = {

drivers/platform/x86/asus-wmi.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#define _ASUS_WMI_H_
2929

3030
#include <linux/platform_device.h>
31+
#include <linux/i8042.h>
3132

3233
#define ASUS_WMI_KEY_IGNORE (-1)
3334
#define ASUS_WMI_BRN_DOWN 0x20
@@ -52,6 +53,9 @@ struct quirk_entry {
5253
* and let the ACPI interrupt to send out the key event.
5354
*/
5455
int no_display_toggle;
56+
57+
bool (*i8042_filter)(unsigned char data, unsigned char str,
58+
struct serio *serio);
5559
};
5660

5761
struct asus_wmi_driver {

0 commit comments

Comments
 (0)