Skip to contentSkip to conversation

platform/x86: msi-wmi: Ignore WMI events for keys also handled by atkbd

PATCH In review Patryk Pilichowski 2 participants 4 messages Oct 20

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover platform/x86: msi-wmi: Ignore WMI events for keys also handled by atkbd

On MSI notebooks, several keys send a WMI event through the Wind event GUID in addition to a regular AT keyboard event, and each press logs "Unknown key pressed". This series marks those codes as KE_IGNORE.

Patch 1 sorts the existing scancodes numerically with no functional change, as suggested by Ilpo. Patch 2 adds the new entries.

Changes in v2:
- Split into two patches: first sort the existing scancodes numerically, give every entry an explicit value and use lowercase hex (Ilpo)
- Add the new scancodes in sorted order

v1: https://lore.kernel.org/platform-driver-x86/[email protected]/

Patryk Pilichowski (2):
platform/x86: msi-wmi: Sort scancodes numerically platform/x86: msi-wmi: Ignore WMI events for keys also handled by
atkbd

 drivers/platform/x86/msi-wmi.c | 35 +++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)

base-commit: 893018d51f27ec0449155b0afe371aaf65380630

Signature · 1 line
2.56.0
#1 lore raw

PATCH v2 1/2 platform/x86: msi-wmi: Sort scancodes numerically

The scancode enum is grouped by model, so the values are not in order and are hard to follow. The grouping is not meaningful either, as the same event codes are used across MSI models.

Sort the enum by scancode, give every entry an explicit value and use lowercase hex.

No functional change.

---
 drivers/platform/x86/msi-wmi.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)
drivers/platform/x86/msi-wmi.c +10 -13
index 05c35133a1b3..5369ac28f4c5 100644
@@ -33,25 +33,22 @@ MODULE_ALIAS("wmi:" MSIWMI_MSI_EVENT_GUID);
 MODULE_ALIAS("wmi:" MSIWMI_WIND_EVENT_GUID);
 
 enum msi_scancodes {
-	/* Generic MSI keys (not present on MSI Wind) */
-	MSI_KEY_BRIGHTNESSUP	= 0xD0,
-	MSI_KEY_BRIGHTNESSDOWN,
-	MSI_KEY_VOLUMEUP,
-	MSI_KEY_VOLUMEDOWN,
-	MSI_KEY_MUTE,
-	/* MSI Wind keys */
 	WIND_KEY_TOUCHPAD	= 0x08,	/* Fn+F3 touchpad toggle */
-	WIND_KEY_BLUETOOTH	= 0x56,	/* Fn+F11 Bluetooth toggle */
-	WIND_KEY_CAMERA,		/* Fn+F6 webcam toggle */
-	WIND_KEY_WLAN		= 0x5f,	/* Fn+F11 Wi-Fi toggle */
-	WIND_KEY_TURBO,			/* Fn+F10 turbo mode toggle */
-	WIND_KEY_ECO		= 0x69,	/* Fn+F10 ECO mode toggle */
-	/* MSI Claw keys */
 	CLAW_KEY_VOLUMEDOWN	= 0x21,
 	CLAW_KEY_CENTER		= 0x29,	/* MSI M-Center main menu */
 	CLAW_KEY_QUICK_LONG	= 0x2a,	/* MSI M-Center quick access long hold */
 	CLAW_KEY_VOLUMEUP	= 0x32,
+	WIND_KEY_BLUETOOTH	= 0x56,	/* Fn+F11 Bluetooth toggle */
+	WIND_KEY_CAMERA		= 0x57,	/* Fn+F6 webcam toggle */
 	CLAW_KEY_QUICK_SHORT	= 0x58,	/* MSI M-Center quick access short press */
+	WIND_KEY_WLAN		= 0x5f,	/* Fn+F11 Wi-Fi toggle */
+	WIND_KEY_TURBO		= 0x60,	/* Fn+F10 turbo mode toggle */
+	WIND_KEY_ECO		= 0x69,	/* Fn+F10 ECO mode toggle */
+	MSI_KEY_BRIGHTNESSUP	= 0xd0,
+	MSI_KEY_BRIGHTNESSDOWN	= 0xd1,
+	MSI_KEY_VOLUMEUP	= 0xd2,
+	MSI_KEY_VOLUMEDOWN	= 0xd3,
+	MSI_KEY_MUTE		= 0xd4,
 };
 static struct key_entry msi_wmi_keymap[] = {
 	{ KE_KEY, MSI_KEY_BRIGHTNESSUP,		{KEY_BRIGHTNESSUP} },
Signature · 1 line
2.56.0
#2 lore raw

PATCH v2 2/2 platform/x86: msi-wmi: Ignore WMI events for keys also handled by atkbd

In reply to Patryk Pilichowski

On MSI notebooks, several keys generate a WMI event through the Wind event GUID in addition to a regular AT keyboard event. Their event codes are not in the keymap, so every press logs "Unknown key pressed".

These keys already work through the AT keyboard, so mark their WMI codes as KE_IGNORE, as is already done for the MSI Claw. On models where a code does not also produce a keyboard event, the event is already dropped, so the only change there is that the log message goes away.

The Wind event GUID is not specific to the MSI Wind. It is present in 17 of 18 MSI notebooks in the linuxhw ACPI dump collection (2012 to 2024), with the same _WED structure. The codes are shared across models too: the volume keys on the tested notebook send the same codes as the MSI Claw (0x21, 0x32).

Tested on an MSI Katana 15 B13VFK: Fn (0x0b), mic mute (0x19), settings (0x1d), mute (0x23) and Bluetooth (0x78) no longer log unknown key messages, and the keys keep working through atkbd.

---
 drivers/platform/x86/msi-wmi.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/platform/x86/msi-wmi.c +12 -0
index 5369ac28f4c5..dc56e8da0cdb 100644
@@ -34,7 +34,11 @@ MODULE_ALIAS("wmi:" MSIWMI_WIND_EVENT_GUID);
 
 enum msi_scancodes {
 	WIND_KEY_TOUCHPAD	= 0x08,	/* Fn+F3 touchpad toggle */
+	WIND_KEY_FN_NB		= 0x0b,
+	WIND_KEY_MICMUTE_NB	= 0x19,
+	WIND_KEY_SETTINGS_NB	= 0x1d,
 	CLAW_KEY_VOLUMEDOWN	= 0x21,
+	WIND_KEY_MUTE_NB	= 0x23,
 	CLAW_KEY_CENTER		= 0x29,	/* MSI M-Center main menu */
 	CLAW_KEY_QUICK_LONG	= 0x2a,	/* MSI M-Center quick access long hold */
 	CLAW_KEY_VOLUMEUP	= 0x32,
@@ -44,6 +48,7 @@ enum msi_scancodes {
 	WIND_KEY_WLAN		= 0x5f,	/* Fn+F11 Wi-Fi toggle */
 	WIND_KEY_TURBO		= 0x60,	/* Fn+F10 turbo mode toggle */
 	WIND_KEY_ECO		= 0x69,	/* Fn+F10 ECO mode toggle */
+	WIND_KEY_BLUETOOTH_NB	= 0x78,
 	MSI_KEY_BRIGHTNESSUP	= 0xd0,
 	MSI_KEY_BRIGHTNESSDOWN	= 0xd1,
 	MSI_KEY_VOLUMEUP	= 0xd2,
@@ -63,6 +68,13 @@ static struct key_entry msi_wmi_keymap[] = {
 	{ KE_IGNORE, WIND_KEY_CAMERA,		{KEY_CAMERA} },
 	{ KE_IGNORE, WIND_KEY_WLAN,		{KEY_WLAN} },
 
+	/* These MSI Notebook keys work without WMI. Ignore them to avoid double keycodes */
+	{ KE_IGNORE, WIND_KEY_FN_NB },
+	{ KE_IGNORE, WIND_KEY_MICMUTE_NB },
+	{ KE_IGNORE, WIND_KEY_SETTINGS_NB },
+	{ KE_IGNORE, WIND_KEY_MUTE_NB },
+	{ KE_IGNORE, WIND_KEY_BLUETOOTH_NB },
+
 	/* These are unknown WMI events found on MSI Wind */
 	{ KE_IGNORE, 0x00 },
 	{ KE_IGNORE, 0x62 },
Signature · 1 line
2.56.0
maintainer
#3 lore raw
In reply to Patryk Pilichowski
Quoted 8 lines · Patryk Pilichowski

On MSI notebooks, several keys send a WMI event through the Wind event GUID in addition to a regular AT keyboard event, and each press logs "Unknown key pressed". This series marks those codes as KE_IGNORE.

Patch 1 sorts the existing scancodes numerically with no functional change, as suggested by Ilpo. Patch 2 adds the new entries.

[...]

Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.

FYI [if applicable to your patch], as per Linus' policy change, also fixes are mostly routed through for-next unless the fix is for a commit introduced in the most recent cycle or is clearly a regression fix.

The list of commits applied:
[1/2] platform/x86: msi-wmi: Sort scancodes numerically

      commit: c21bef518bc023dfac0f22c9a63a813706e67639
[2/2] platform/x86: msi-wmi: Ignore WMI events for keys also handled by atkbd
      commit: 34f5b0ef61f6366b2bdc9f6d111bc5b225be004f

--
i.