platform/x86: redmi-wmi: Add mic-mute key mapping
Subsystems (2)
PATCH 1/1 platform/x86: redmi-wmi: Add mic-mute key mapping
The mic-mute key (F4) on the Xiaomi RedmiBook Pro 16 produces WMI events that were not present in the keymap, so the key did nothing under Linux.
The firmware reports the resulting mute state in the scancode, emitting one event per press: 0x00002101 when it transitions to muted and 0x00012101 when it transitions to unmuted. Map both to KEY_MICMUTE so each press is reported as a single mic-mute keypress to userspace.
---
Link to the discussion that motivated this, including the redmi-wmi / bitland-mifs-wmi event-GUID overlap:
https://lore.kernel.org/all/[email protected]/
drivers/platform/x86/redmi-wmi.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/platform/x86/redmi-wmi.c +4 -0
@@ -25,6 +25,10 @@ static const struct key_entry redmi_wmi_keymap[] = { {KE_KEY, 0x00010101, {KEY_SWITCHVIDEOMODE}}, {KE_KEY, 0x00001a01, {KEY_REFRESH_RATE_TOGGLE}}, +/* Mic-mute key */ + {KE_KEY, 0x00002101, {KEY_MICMUTE}}, + {KE_KEY, 0x00012101, {KEY_MICMUTE}}, +/* AI button has code for each position */ {KE_KEY, 0x00011801, {KEY_ASSISTANT}}, {KE_KEY, 0x00011901, {KEY_ASSISTANT}},
Signature · 1 line
2.51.2
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 2 lines · Ilya Gladyshev
Is this a hardware mic switch that just notifies userspace, or does the hardware just make an assumption about the current state of the user's mic?
It's not a hardware switch: pressing the key only sends a key event; userspace (GNOME) does the actual muting, which I've tested works.
Quoted 2 lines
Because for the first case, I am a bit afraid of bad UX if the hardware switch and userspace state get desynchronized :)
You're right that the LED can drift out of sync with the real mute state. The root cause is that the firmware reports an absolute state (muted/unmuted, via the two scancodes) while KEY_MICMUTE is a toggle, so that information is lost -- and there's no KEY_MICUNMUTE to preserve it.
That said, before this patch the key does nothing, so the mic never mutes and the firmware's LED toggling is meaningless. With it, the key works and the LED is correct except for an initial-alignment edge case. I'd therefore like the keymap fix to land on its own, and address the LED separately. I'm preparing that as a follow-up -- the LED state is the EC field MIUT, settable through the same WMAA control device that bitland-mifs-wmi already wraps.
Signature · 1 line
Nika Krasnova
A message that is not in the archive (sent off-list or not yet received): [email protected]
Nika Krasnova
Reviewed-by Gladyshev IlyaQuoted 5 lines · Ilya Gladyshev
Yeah, if the key itself does nothing then desync isn't scary. Thanks for clarifying and
Reviewed-by Gladyshev Ilya <[email protected]>(I am aware that lore.kernel.org will filter out this email. I will fix this issue ASAP [thanks for letting me know]
Thanks for the review! Relaying your tag here so it's archived:
Signature · 1 line
Nika Krasnova