Skip to content

Commit 2b6aa66

Browse files
committed
platform/x86: lenovo-ymc: Only bind on machines with a convertible DMI chassis-type
The lenovo-ymc driver is causing the keyboard + touchpad to stop working on some regular laptop models such as the Lenovo ThinkBook 13s G2 ITL 20V9. The problem is that there are YMC WMI GUID methods in the ACPI tables of these laptops, despite them not being Yogas and lenovo-ymc loading causes libinput to see a SW_TABLET_MODE switch with state 1. This in turn causes libinput to ignore events from the builtin keyboard and touchpad, since it filters those out for a Yoga in tablet mode. Similar issues with false-positive SW_TABLET_MODE=1 reporting have been seen with the intel-hid driver. Copy the intel-hid driver approach to fix this and only bind to the WMI device on machines where the DMI chassis-type indicates the machine is a convertible. Add a 'force' module parameter to allow overriding the chassis-type check so that users can easily test if the YMC interface works on models which report an unexpected chassis-type. Fixes: e82882c ("platform/x86: Add driver for Yoga Tablet Mode switch") Link: https://bugzilla.redhat.com/show_bug.cgi?id=2229373 Cc: André Apitzsch <git@apitzsch.eu> Cc: stable@vger.kernel.org Tested-by: Andrew Kallmeyer <kallmeyeras@gmail.com> Tested-by: Gergő Köteles <soyer@irl.hu> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20230812144818.383230-1-hdegoede@redhat.com
1 parent d66a8aa commit 2b6aa66

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

drivers/platform/x86/lenovo-ymc.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ static bool ec_trigger __read_mostly;
2424
module_param(ec_trigger, bool, 0444);
2525
MODULE_PARM_DESC(ec_trigger, "Enable EC triggering work-around to force emitting tablet mode events");
2626

27+
static bool force;
28+
module_param(force, bool, 0444);
29+
MODULE_PARM_DESC(force, "Force loading on boards without a convertible DMI chassis-type");
30+
2731
static const struct dmi_system_id ec_trigger_quirk_dmi_table[] = {
2832
{
2933
/* Lenovo Yoga 7 14ARB7 */
@@ -35,6 +39,20 @@ static const struct dmi_system_id ec_trigger_quirk_dmi_table[] = {
3539
{ }
3640
};
3741

42+
static const struct dmi_system_id allowed_chasis_types_dmi_table[] = {
43+
{
44+
.matches = {
45+
DMI_EXACT_MATCH(DMI_CHASSIS_TYPE, "31" /* Convertible */),
46+
},
47+
},
48+
{
49+
.matches = {
50+
DMI_EXACT_MATCH(DMI_CHASSIS_TYPE, "32" /* Detachable */),
51+
},
52+
},
53+
{ }
54+
};
55+
3856
struct lenovo_ymc_private {
3957
struct input_dev *input_dev;
4058
struct acpi_device *ec_acpi_dev;
@@ -111,6 +129,13 @@ static int lenovo_ymc_probe(struct wmi_device *wdev, const void *ctx)
111129
struct input_dev *input_dev;
112130
int err;
113131

132+
if (!dmi_check_system(allowed_chasis_types_dmi_table)) {
133+
if (force)
134+
dev_info(&wdev->dev, "Force loading Lenovo YMC support\n");
135+
else
136+
return -ENODEV;
137+
}
138+
114139
ec_trigger |= dmi_check_system(ec_trigger_quirk_dmi_table);
115140

116141
priv = devm_kzalloc(&wdev->dev, sizeof(*priv), GFP_KERNEL);

0 commit comments

Comments
 (0)