summaryrefslogtreecommitdiffstats
path: root/pdx86-SW_TABLET_MODE-fixes.patch
blob: 3fa9f843c4f897b58a48d8e53351f51d06f7e3e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
From 9126d28cf4e537ef5e77006c51b1a24ad8e8170b Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Fri, 11 Sep 2020 13:34:42 +0200
Subject: [PATCH 1/2] platform/x86: intel-vbtn: Fix SW_TABLET_MODE always
 reporting 1 on the HP Pavilion 11 x360

Commit cfae58ed681c ("platform/x86: intel-vbtn: Only blacklist
SW_TABLET_MODE on the 9 / "Laptop" chasis-type") restored SW_TABLET_MODE
reporting on the HP stream x360 11 series on which it was previously broken
by commit de9647efeaa9 ("platform/x86: intel-vbtn: Only activate tablet
mode switch on 2-in-1's").

It turns out that enabling SW_TABLET_MODE reporting on devices with a
chassis-type of 10 ("Notebook") causes SW_TABLET_MODE to always report 1
at boot on the HP Pavilion 11 x360, which causes libinput to disable the
kbd and touchpad.

The HP Pavilion 11 x360's ACPI VGBS method sets bit 4 instead of bit 6 when
NOT in tablet mode at boot. Inspecting all the DSDTs in my DSDT collection
shows only one other model, the Medion E1239T ever setting bit 4 and it
always sets this together with bit 6.

So lets treat bit 4 as a second bit which when set indicates the device not
being in tablet-mode, as we already do for bit 6.

While at it also prefix all VGBS constant defines with "VGBS_".

Fixes: cfae58ed681c ("platform/x86: intel-vbtn: Only blacklist SW_TABLET_MODE on the 9 / "Laptop" chasis-type")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---

 drivers/platform/x86/intel-vbtn.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c
index e85d8e58320c..f443619e1e7e 100644
--- a/drivers/platform/x86/intel-vbtn.c

+++ b/drivers/platform/x86/intel-vbtn.c

@@ -15,9 +15,13 @@
 #include <linux/platform_device.h>
 #include <linux/suspend.h>
 
+/* Returned when NOT in tablet mode on some HP Stream x360 11 models */

+#define VGBS_TABLET_MODE_FLAG_ALT	0x10

 /* When NOT in tablet mode, VGBS returns with the flag 0x40 */
-#define TABLET_MODE_FLAG 0x40

-#define DOCK_MODE_FLAG   0x80

+#define VGBS_TABLET_MODE_FLAG		0x40

+#define VGBS_DOCK_MODE_FLAG		0x80

+

+#define VGBS_TABLET_MODE_FLAGS (VGBS_TABLET_MODE_FLAG | VGBS_TABLET_MODE_FLAG_ALT)

 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("AceLan Kao");
@@ -72,9 +76,9 @@ static void detect_tablet_mode(struct platform_device *device)
 	if (ACPI_FAILURE(status))
 		return;
 
-	m = !(vgbs & TABLET_MODE_FLAG);

+	m = !(vgbs & VGBS_TABLET_MODE_FLAGS);

 	input_report_switch(priv->input_dev, SW_TABLET_MODE, m);
-	m = (vgbs & DOCK_MODE_FLAG) ? 1 : 0;

+	m = (vgbs & VGBS_DOCK_MODE_FLAG) ? 1 : 0;

 	input_report_switch(priv->input_dev, SW_DOCK, m);
 }
 
-- 

2.28.0

From d26d82852e926fee13b5fa71cc004da391aaa5e3 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Wed, 16 Sep 2020 16:14:39 +0200
Subject: [PATCH 2/2] platform/x86: asus-wmi: Fix SW_TABLET_MODE always
 reporting 1 on many different models
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Commit b0dbd97de1f1 ("platform/x86: asus-wmi: Add support for
SW_TABLET_MODE") added support for reporting SW_TABLET_MODE using the
Asus 0x00120063 WMI-device-id to see if various transformer models were
docked into their keyboard-dock (SW_TABLET_MODE=0) or if they were
being used as a tablet.

The new SW_TABLET_MODE support (naively?) assumed that non Transformer
devices would either not support the 0x00120063 WMI-device-id at all,
or would NOT set ASUS_WMI_DSTS_PRESENCE_BIT in their reply when querying
the device-id.

Unfortunately this is not true and we have received many bug reports about
this change causing the asus-wmi driver to always report SW_TABLET_MODE=1
on non Transformer devices. This causes libinput to think that these are
360 degree hinges style 2-in-1s folded into tablet-mode. Making libinput
suppress keyboard and touchpad events from the builtin keyboard and
touchpad. So effectively this causes the keyboard and touchpad to not work
on many non Transformer Asus models.

This commit fixes this by using the existing DMI based quirk mechanism in
asus-nb-wmi.c to allow using the 0x00120063 device-id for reporting
SW_TABLET_MODE on Transformer models and ignoring it on all other models.

Fixes: b0dbd97de1f1 ("platform/x86: asus-wmi: Add support for SW_TABLET_MODE")
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=209011
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1875339
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1875828
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1876997
Reported-by: Samuel Čavoj <samuel@cavoj.net>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---

 drivers/platform/x86/asus-nb-wmi.c | 32 ++++++++++++++++++++++++++++++
 drivers/platform/x86/asus-wmi.c    | 16 ++++++++-------
 drivers/platform/x86/asus-wmi.h    |  1 +
 3 files changed, 42 insertions(+), 7 deletions(-)

diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus-nb-wmi.c
index 680c3640e013..1d9fbabd02fb 100644
--- a/drivers/platform/x86/asus-nb-wmi.c

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

@@ -115,6 +115,10 @@ static struct quirk_entry quirk_asus_vendor_backlight = {
 	.wmi_backlight_set_devstate = true,
 };
 
+static struct quirk_entry quirk_asus_use_kbd_dock_devid = {

+	.use_kbd_dock_devid = true,

+};

+

 static int dmi_matched(const struct dmi_system_id *dmi)
 {
 	pr_info("Identified laptop model '%s'\n", dmi->ident);
@@ -488,6 +492,34 @@ static const struct dmi_system_id asus_quirks[] = {
 		},
 		.driver_data = &quirk_asus_ga502i,
 	},
+	{

+		.callback = dmi_matched,

+		.ident = "Asus Transformer T100TA / T100HA / T100CHI",

+		.matches = {

+			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),

+			/* Match *T100* */

+			DMI_MATCH(DMI_PRODUCT_NAME, "T100"),

+		},

+		.driver_data = &quirk_asus_use_kbd_dock_devid,

+	},

+	{

+		.callback = dmi_matched,

+		.ident = "Asus Transformer T101HA",

+		.matches = {

+			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),

+			DMI_MATCH(DMI_PRODUCT_NAME, "T101HA"),

+		},

+		.driver_data = &quirk_asus_use_kbd_dock_devid,

+	},

+	{

+		.callback = dmi_matched,

+		.ident = "Asus Transformer T200TA",

+		.matches = {

+			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),

+			DMI_MATCH(DMI_PRODUCT_NAME, "T200TA"),

+		},

+		.driver_data = &quirk_asus_use_kbd_dock_devid,

+	},

 	{},
 };
 
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 8f4acdc06b13..ae6289d37faf 100644
--- a/drivers/platform/x86/asus-wmi.c

+++ b/drivers/platform/x86/asus-wmi.c

@@ -365,12 +365,14 @@ static int asus_wmi_input_init(struct asus_wmi *asus)
 	if (err)
 		goto err_free_dev;
 
-	result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_KBD_DOCK);

-	if (result >= 0) {

-		input_set_capability(asus->inputdev, EV_SW, SW_TABLET_MODE);

-		input_report_switch(asus->inputdev, SW_TABLET_MODE, !result);

-	} else if (result != -ENODEV) {

-		pr_err("Error checking for keyboard-dock: %d\n", result);

+	if (asus->driver->quirks->use_kbd_dock_devid) {

+		result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_KBD_DOCK);

+		if (result >= 0) {

+			input_set_capability(asus->inputdev, EV_SW, SW_TABLET_MODE);

+			input_report_switch(asus->inputdev, SW_TABLET_MODE, !result);

+		} else if (result != -ENODEV) {

+			pr_err("Error checking for keyboard-dock: %d\n", result);

+		}

 	}
 
 	err = input_register_device(asus->inputdev);
@@ -2114,7 +2116,7 @@ static void asus_wmi_handle_event_code(int code, struct asus_wmi *asus)
 		return;
 	}
 
-	if (code == NOTIFY_KBD_DOCK_CHANGE) {

+	if (asus->driver->quirks->use_kbd_dock_devid && code == NOTIFY_KBD_DOCK_CHANGE) {

 		result = asus_wmi_get_devstate_simple(asus,
 						      ASUS_WMI_DEVID_KBD_DOCK);
 		if (result >= 0) {
diff --git a/drivers/platform/x86/asus-wmi.h b/drivers/platform/x86/asus-wmi.h
index 4f31b68642a0..1a95c172f94b 100644
--- a/drivers/platform/x86/asus-wmi.h

+++ b/drivers/platform/x86/asus-wmi.h

@@ -33,6 +33,7 @@ struct quirk_entry {
 	bool wmi_backlight_native;
 	bool wmi_backlight_set_devstate;
 	bool wmi_force_als_set;
+	bool use_kbd_dock_devid;

 	int wapf;
 	/*
 	 * For machines with AMD graphic chips, it will send out WMI event
-- 

2.28.0