Skip to contentSkip to conversation

platform/x86: lenovo/ymc: Only match lower byte in WMI lid switch response

PATCH Superseded Julian Haarmann 2 participants 2 messages May 31 – Jun 8

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86: lenovo/ymc: Only match lower byte in WMI lid switch response

On newer Lenovo Yoga devices like the "Yoga 9 2-in-1 14IPH11 - Type 83SE", the hinge switch WMI query returns extra data in the upper bits (e.g. 0x50001 laptop mode, 0x50002 tablet mode, ect.).

The driver previously checked for exact matches (0x01 laptop, 0x02 tablet, ect.) causing newer switches to not work.

Mask the WMI query result to only match the lower byte and ignore upper bits.

---

Hi everyone,

I just recieved this laptop and am trying to get it to work.
FYI: To get tablet mode to work fully you might need to extract the Intel ISH firmware from the Windows driver.
This is my first patch, so I hope the way I've solved this is up to standard.

 drivers/platform/x86/lenovo/ymc.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/platform/x86/lenovo/ymc.c +3 -0
index 1b73a55f1b89..ffeca452b392 100644
@@ -87,6 +87,9 @@ static void lenovo_ymc_notify(struct wmi_device *wdev, union acpi_object *data)
 	}
 	code = obj->integer.value;
 
+	/* strip upper bits (e.g. 0x50000) on newer devices */
+	code &= 0xFF;
+
 	if (!sparse_keymap_report_event(priv->input_dev, code, 1, true))
 		dev_warn(&wdev->dev, "Unknown key %d pressed\n", code);
 
Signature · 1 line
2.54.0
maintainer
#1 lore raw
Quoted 29 lines · Julian Haarmann

On newer Lenovo Yoga devices like the "Yoga 9 2-in-1 14IPH11 - Type 83SE", the hinge switch WMI query returns extra data in the upper bits (e.g. 0x50001 laptop mode, 0x50002 tablet mode, ect.).

The driver previously checked for exact matches (0x01 laptop, 0x02 tablet, ect.) causing newer switches to not work.

Mask the WMI query result to only match the lower byte and ignore upper bits.

---

Hi everyone,

I just recieved this laptop and am trying to get it to work.
FYI: To get tablet mode to work fully you might need to extract the Intel ISH firmware from the Windows driver.
This is my first patch, so I hope the way I've solved this is up to standard.

 drivers/platform/x86/lenovo/ymc.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/platform/x86/lenovo/ymc.c +0 -0
index 1b73a55f1b89..ffeca452b392 100644

drivers/platform/x86/lenovo/ymc.c static void lenovo_ymc_notify(struct wmi_device *wdev, union acpi_object *data) · line 91

Quoted 5 lines
drivers/platform/x86/lenovo/ymc.c +2 -0
@@ -87,6 +87,9 @@ static void lenovo_ymc_notify(struct wmi_device *wdev, union acpi_object *data)
 	}
 	code = obj->integer.value;
 
+	/* strip upper bits (e.g. 0x50000) on newer devices */
+	code &= 0xFF;

Thanks for the patch.

As it looks like there are now multiple fields in the value, it is better to add a define with GENMASK() and use FIELD_GET() to extract the field.

Please also remember to add bits.h and bitfield.h includes when using those macros.

Signature · 1 line
 i.