mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1] platform/x86: redmi-wmi: add display-switch key binding
@ 2026-09-28 22:14 Ilya Gladyshev
  2026-09-29 23:42 ` Антон Карасев
  0 siblings, 1 reply; 3+ messages in thread
From: Ilya Gladyshev @ 2026-09-28 22:14 UTC (permalink / raw)
  To: ilya.gladyshev
  Cc: linux-kernel, platform-driver-x86, ilpo.jarvinen, hansg,
	qby140326, W_Armin, uselessfire, vlku.milos.fun

As reported on the mailing list [1], on the Xiaomi Redmi Book Pro 16
2024, the display-switch key emits 0x101 as a WMI payload. Add a
mapping for it to the keymap.

[1]: https://lore.kernel.org/all/CAFsq4KBXCB=aK8ENHx__6+RcC-ybT7eKjcgsa3TgcJ54x-PLEg@mail.gmail.com/

Reported-by: Антон Карасев <uselessfire@gmail.com>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=222062
Signed-off-by: Ilya Gladyshev <ilya.gladyshev@linux.dev>
---

This patch conflicts with the unification of redmi-wmi and
bitland-mifs-wmi [2]. However, that patch appears to be stuck for now,
so updating a single mapping in the old driver seems acceptable.

Cc its author, Mingyou Chen.

Also, I can only test that it doesn't break on my hardware, so any
additional testing is highly welcome.

[2]: https://lore.kernel.org/all/20260816100813.300450-1-qby140326@gmail.com/
---
 drivers/platform/x86/redmi-wmi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/platform/x86/redmi-wmi.c b/drivers/platform/x86/redmi-wmi.c
index cc82ef502002..155777bf90f3 100644
--- a/drivers/platform/x86/redmi-wmi.c
+++ b/drivers/platform/x86/redmi-wmi.c
@@ -22,6 +22,7 @@ static const struct key_entry redmi_wmi_keymap[] = {
 	{KE_KEY, 0x00000301,	{KEY_ALL_APPLICATIONS}},
 	{KE_KEY, 0x00001b01,	{KEY_CONFIG}},
 	{KE_KEY, 0x00011b01,	{KEY_CONFIG}},
+	{KE_KEY, 0x00000101,	{KEY_SWITCHVIDEOMODE}},
 	{KE_KEY, 0x00010101,	{KEY_SWITCHVIDEOMODE}},
 	{KE_KEY, 0x00001a01,	{KEY_REFRESH_RATE_TOGGLE}},
 
-- 
2.55.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] platform/x86: redmi-wmi: add display-switch key binding
  2026-09-28 22:14 [PATCH v1] platform/x86: redmi-wmi: add display-switch key binding Ilya Gladyshev
@ 2026-09-29 23:42 ` Антон Карасев
  2026-09-30 19:49   ` Ilya Gladyshev
  0 siblings, 1 reply; 3+ messages in thread
From: Антон Карасев @ 2026-09-29 23:42 UTC (permalink / raw)
  To: Ilya Gladyshev
  Cc: linux-kernel, platform-driver-x86, ilpo.jarvinen, hansg,
	qby140326, W_Armin, vlku.milos.fun

Tested-by: Anton Karasev <uselessfire@gmail.com>

Tested on the reporting machine (Xiaomi Redmi Book Pro 16 2024, DMI
XIAOMI/TM2309, BIOS RMAMT6B0P0B0B), kernel 7.2.7, by building redmi-wmi
from mainline with this patch applied and loading it in place of the
in-tree module.

Before: pressing the display-switch key gave "Unknown WMI event with
payload 257" and no input event at all.

After: the key reports KEY_SWITCHVIDEOMODE. The keymap read back from the
device contains both forms now:

  scancode 0x101 -> 227
  scancode 0x10101 -> 227

and the desktop reacts to the key (KDE opens its display-switch menu).
The other hotkeys are unaffected: 0x201 -> KEY_SELECTIVE_SCREENSHOT,
0x1b01 -> KEY_CONFIG, 0x11801/0x11901 -> KEY_ASSISTANT all still work,
and nothing new showed up in dmesg.

Two notes that did not fit the fix, in case they are useful:

1. The merge series "Merge redmi-wmi into bitland-mifs-wmi" (v6,
   20260929134503.17249-1-qby140326@gmail.com) drops redmi-wmi, and its
   combined keymap only carries the long form:

     { KE_KEY, BI_HOTKEY_CODE(WMI_EVENT_RESERVED_1, 1, 0), {
KEY_SWITCHVIDEOMODE } },

   With WMI_EVENT_RESERVED_1 = 1 and WMI_EVENT_TYPE_HOTKEY = 1 that expands
   to 0x00010101; the short 0x00000101 has no entry there. If that series
   lands, this fix is lost again on this model. I am replying to that
   thread separately.

2. Two payloads are still unhandled here: 0x00000901 and 0x00010901. They
   are not key presses -- the EC echoes back the Caps Lock LED state that
   the host itself has just set (third byte 1 = on, 0 = off, the same
   scheme as the Fn Lock events). Verified by switching between windows
   with per-window keyboard layouts, which changes the LED without anyone
   touching the key: the events still arrive, 200-500 ms after the LED
   change. On a system where Caps Lock switches the layout this is a
   steady stream of dev_dbg lines; KE_IGNORE would silence it.

Details and traces: https://bugzilla.kernel.org/show_bug.cgi?id=222062

Thanks for the quick fix!

Anton

вт, 29 сент. 2026 г. в 01:14, Ilya Gladyshev <ilya.gladyshev@linux.dev>:
>
> As reported on the mailing list [1], on the Xiaomi Redmi Book Pro 16
> 2024, the display-switch key emits 0x101 as a WMI payload. Add a
> mapping for it to the keymap.
>
> [1]: https://lore.kernel.org/all/CAFsq4KBXCB=aK8ENHx__6+RcC-ybT7eKjcgsa3TgcJ54x-PLEg@mail.gmail.com/
>
> Reported-by: Антон Карасев <uselessfire@gmail.com>
> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=222062
> Signed-off-by: Ilya Gladyshev <ilya.gladyshev@linux.dev>
> ---
>
> This patch conflicts with the unification of redmi-wmi and
> bitland-mifs-wmi [2]. However, that patch appears to be stuck for now,
> so updating a single mapping in the old driver seems acceptable.
>
> Cc its author, Mingyou Chen.
>
> Also, I can only test that it doesn't break on my hardware, so any
> additional testing is highly welcome.
>
> [2]: https://lore.kernel.org/all/20260816100813.300450-1-qby140326@gmail.com/
> ---
>  drivers/platform/x86/redmi-wmi.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/platform/x86/redmi-wmi.c b/drivers/platform/x86/redmi-wmi.c
> index cc82ef502002..155777bf90f3 100644
> --- a/drivers/platform/x86/redmi-wmi.c
> +++ b/drivers/platform/x86/redmi-wmi.c
> @@ -22,6 +22,7 @@ static const struct key_entry redmi_wmi_keymap[] = {
>         {KE_KEY, 0x00000301,    {KEY_ALL_APPLICATIONS}},
>         {KE_KEY, 0x00001b01,    {KEY_CONFIG}},
>         {KE_KEY, 0x00011b01,    {KEY_CONFIG}},
> +       {KE_KEY, 0x00000101,    {KEY_SWITCHVIDEOMODE}},
>         {KE_KEY, 0x00010101,    {KEY_SWITCHVIDEOMODE}},
>         {KE_KEY, 0x00001a01,    {KEY_REFRESH_RATE_TOGGLE}},
>
> --
> 2.55.0
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] platform/x86: redmi-wmi: add display-switch key  binding
  2026-09-29 23:42 ` Антон Карасев
@ 2026-09-30 19:49   ` Ilya Gladyshev
  0 siblings, 0 replies; 3+ messages in thread
From: Ilya Gladyshev @ 2026-09-30 19:49 UTC (permalink / raw)
  To: Антон
	Карасев
  Cc: linux-kernel, platform-driver-x86, ilpo.jarvinen, hansg,
	qby140326, W_Armin, vlku.milos.fun

On 9/30/26 02:42, Антон Карасев wrote:
> Tested-by: Anton Karasev <uselessfire@gmail.com>

Thanks!

> Tested on the reporting machine (Xiaomi Redmi Book Pro 16 2024, DMI
> XIAOMI/TM2309, BIOS RMAMT6B0P0B0B), kernel 7.2.7, by building redmi-wmi
> from mainline with this patch applied and loading it in place of the
> in-tree module.
> > Before: pressing the display-switch key gave "Unknown WMI event with
> payload 257" and no input event at all.
> > After: the key reports KEY_SWITCHVIDEOMODE. The keymap read back from the
> device contains both forms now:
> >    scancode 0x101 -> 227
>    scancode 0x10101 -> 227
> > and the desktop reacts to the key (KDE opens its display-switch menu).
> The other hotkeys are unaffected: 0x201 -> KEY_SELECTIVE_SCREENSHOT,
> 0x1b01 -> KEY_CONFIG, 0x11801/0x11901 -> KEY_ASSISTANT all still work,
> and nothing new showed up in dmesg.
> > Two notes that did not fit the fix, in case they are useful:
> > 1. The merge series "Merge redmi-wmi into bitland-mifs-wmi" (v6,
>     20260929134503.17249-1-qby140326@gmail.com) drops redmi-wmi, and its
>     combined keymap only carries the long form:

Yes, if Mingyou's patch lands first, I will rebase my patch to target the
bitland-mifs-wmi driver.

>       { KE_KEY, BI_HOTKEY_CODE(WMI_EVENT_RESERVED_1, 1, 0), {
> KEY_SWITCHVIDEOMODE } },
> >     With WMI_EVENT_RESERVED_1 = 1 and WMI_EVENT_TYPE_HOTKEY = 1 that expands
>     to 0x00010101; the short 0x00000101 has no entry there. If that series
>     lands, this fix is lost again on this model. I am replying to that
>     thread separately.
>
> 2. Two payloads are still unhandled here: 0x00000901 and 0x00010901. They
>     are not key presses -- the EC echoes back the Caps Lock LED state that
>     the host itself has just set (third byte 1 = on, 0 = off, the same
>     scheme as the Fn Lock events). Verified by switching between windows
>     with per-window keyboard layouts, which changes the LED without anyone
>     touching the key: the events still arrive, 200-500 ms after the LED
>     change. On a system where Caps Lock switches the layout this is a
>     steady stream of dev_dbg lines; KE_IGNORE would silence it.

IMO, it is better to leave such keycodes unhandled. In practice, dev_dbg()
is a no-op (it is a static key call), so there will be no noise in dmesg.

However, if some future board uses those payloads for something useful,
dev_dbg() will help extract them (just as in your case).

> Details and traces: https://bugzilla.kernel.org/show_bug.cgi?id=222062
> > Thanks for the quick fix!
> > Anton
> > вт, 29 сент. 2026 г. в 01:14, Ilya Gladyshev <ilya.gladyshev@linux.dev>:
>>
>> As reported on the mailing list [1], on the Xiaomi Redmi Book Pro 16
>> 2024, the display-switch key emits 0x101 as a WMI payload. Add a
>> mapping for it to the keymap.
>>
>> [1]: https://lore.kernel.org/all/CAFsq4KBXCB=aK8ENHx__6+RcC-ybT7eKjcgsa3TgcJ54x-PLEg@mail.gmail.com/
>>
>> Reported-by: Антон Карасев <uselessfire@gmail.com>
>> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=222062
>> Signed-off-by: Ilya Gladyshev <ilya.gladyshev@linux.dev>
>> ---
>>
>> This patch conflicts with the unification of redmi-wmi and
>> bitland-mifs-wmi [2]. However, that patch appears to be stuck for now,
>> so updating a single mapping in the old driver seems acceptable.
>>
>> Cc its author, Mingyou Chen.
>>
>> Also, I can only test that it doesn't break on my hardware, so any
>> additional testing is highly welcome.
>>
>> [2]: https://lore.kernel.org/all/20260816100813.300450-1-qby140326@gmail.com/
>> ---
>>   drivers/platform/x86/redmi-wmi.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/platform/x86/redmi-wmi.c b/drivers/platform/x86/redmi-wmi.c
>> index cc82ef502002..155777bf90f3 100644
>> --- a/drivers/platform/x86/redmi-wmi.c
>> +++ b/drivers/platform/x86/redmi-wmi.c
>> @@ -22,6 +22,7 @@ static const struct key_entry redmi_wmi_keymap[] = {
>>          {KE_KEY, 0x00000301,    {KEY_ALL_APPLICATIONS}},
>>          {KE_KEY, 0x00001b01,    {KEY_CONFIG}},
>>          {KE_KEY, 0x00011b01,    {KEY_CONFIG}},
>> +       {KE_KEY, 0x00000101,    {KEY_SWITCHVIDEOMODE}},
>>          {KE_KEY, 0x00010101,    {KEY_SWITCHVIDEOMODE}},
>>          {KE_KEY, 0x00001a01,    {KEY_REFRESH_RATE_TOGGLE}},
>>
>> --
>> 2.55.0
>>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-30 19:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-28 22:14 [PATCH v1] platform/x86: redmi-wmi: add display-switch key binding Ilya Gladyshev
2026-09-29 23:42 ` Антон Карасев
2026-09-30 19:49   ` Ilya Gladyshev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®