All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anton Karasev <uselessfire@gmail.com>
To: qby140326@gmail.com
Cc: ilpo.jarvinen@linux.intel.com, hansg@kernel.org,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org, ilya.gladyshev@linux.dev,
	foxido@foxido.dev, W_Armin@gmx.de, kento@kekto.ru,
	ericted8810@gmail.com, chris@miget.com,
	matias.civadda2342001@gmail.com, btx342@gmail.com,
	wleizc7319@gmail.com, wolf109909@outlook.com,
	vlku.milos.fun@gmail.com, i@rsplwe.com, bozhenpeng93@gmail.com,
	nika@nikableh.moe
Subject: Re: [PATCH v6 2/5] platform/x86: bitland-mifs-wmi: Merge the function of redmi-wmi into the bitland driver
Date: Wed, 30 Sep 2026 04:58:06 +0300	[thread overview]
Message-ID: <20260930015806.3111929-1-uselessfire@gmail.com> (raw)
In-Reply-To: <20260929134503.17249-3-qby140326@gmail.com>

Hi,

On a Xiaomi Redmi Book Pro 16 2024 (DMI: XIAOMI / TM2309, BIOS
RMAMT6B0P0B0B) the display-switch key sends payload 0x00000101 -- the
short form. The merged keymap in this patch only carries the long one:

  { 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, so on this model the key produces no input event at all:
sparse_keymap_entry_from_scancode() finds nothing and the event is
dropped.

redmi-wmi has exactly the same gap; it is being fixed there by

  https://lore.kernel.org/platform-driver-x86/20260928221417.37875-1-ilya.gladyshev@linux.dev/

which I tested on this machine: with that patch the key reports
KEY_SWITCHVIDEOMODE and the desktop reacts to it. If this series lands as
is, that fix is lost again for this model. The equivalent here would be
one more line:

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

Note that the keymap already carries both forms for the settings key
(0x1b with low 0 and low 1), so the two forms are already known to the
driver; the display-switch key is simply missing its short variant.

While tracing this firmware, two more payloads showed up that neither
driver handles: 0x00000901 and 0x00010901. They are not key presses. The
EC echoes back the Caps Lock LED state that the host itself has just set
-- the third byte carries the new state (1 = on, 0 = off), the same
scheme as the Fn Lock events at 0x00000701 / 0x00010701. 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
keyboard layout, each of them ends up in the "Unknown WMI hotkey"
dev_dbg path. If you agree they are just an echo, KE_IGNORE would
silence them:

  { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_CAPSLOCK_STATE, 0, 0), {} },
  { KE_IGNORE, BI_HOTKEY_CODE(WMI_EVENT_CAPSLOCK_STATE, 1, 0), {} },

Two more things about how this patch treats events from this firmware.
The observations below were made on 7.2.7, with redmi-wmi owning the
event GUID and a local build of bitland-mifs-wmi bound only to the
method GUID, reading the EC registers while doing it; what this patch
would do is from reading it. The ACPI references are to the SSDT with
OEM Table ID XMCC1806 (\_SB.PC00.WMID) and to the DSDT.

1. Fn+K. This firmware never sends WMI_EVENT_PERFORMANCE_PLAN (0x0f);
   QV20(1, 0x0f) is not called anywhere in its tables. A mode change is
   reported as event 0x16 with the new EC mode (register QFAN) in
   value_low: the Fn+K query handler in the DSDT (_Q24) calls
   QV20(1, 0x16) and then NTDP(QFAN), and the MIFS SET of
   WMI_FN_SYSTEM_PER_MODE in WMAA sends the same QV20(1, 0x16) after
   writing QFAN. EV20 fills value_low only for QFAN 1..4, so after a SET
   of 0 -- what the default Bitland map writes for balanced -- the event
   is 0x00001601.

   This patch maps 0x16 with value_low 1..4 to KE_IGNORE, has no entry
   for 0x00001601, and calls platform_profile_notify() only for 0x0f.
   So after Fn+K userspace is told nothing: the EC mode and the DPTF
   policy applied by thermald --adaptive change, and so does the value
   read back from platform_profile, but power-profiles-daemon keeps the
   old profile. That is already the case today; in my test PPD stayed
   on balanced while the EC ran in Turbo. But redmi-wmi at least reports
   KEY_PERFORMANCE for these events, as it reports KEY_KBDILLUMTOGGLE
   and KEY_FN_ESC for the backlight and Fn Lock events. With this patch
   they all become KE_IGNORE, so userspace gets neither a key nor a
   profile notification.

   Treating 0x16 as a profile change -- value_low 0..4, including
   0x00001601 -- and calling platform_profile_notify() for it would
   close the gap. It would also fire after the driver's own writes,
   because the SET sends the same event: when userspace writes the
   profile through bitland-mifs-wmi right after Fn+K, two 0x16 events
   arrive 0.2-1 s apart. That is harmless.

2. Keyboard backlight (F10). On this model the event's value_low
   cycles 0x00 -> 0x05 -> 0x0a -> 0x80 -> 0x00: off, dim with the BIOS
   idle timeout, bright with the idle timeout, bright and always on.
   The EC keeps the same state as 1 / 2 / 4 / 8, and EV20 translates
   it into value_low. In this patch
   BI_HOTKEY_CODE(WMI_EVENT_KBD_BRIGHTNESS, 0, 0x80) is 0x80000501,
   while the firmware (and redmi-wmi's 0x00800501) has 0x80 in
   value_low. All four KBD_BRIGHTNESS entries are unreachable anyway:
   notify() returns for WMI_EVENT_KBD_BRIGHTNESS before the keymap
   lookup, so the KEY_KBDILLUMTOGGLE that redmi-wmi reports today is
   gone. That early path passes value_low (0, 5, 10 or 128) to
   led_classdev_notify_brightness_hw_changed() for an LED with
   max_brightness 3, and on this BIOS the LED has nothing behind it,
   because WMAA does not implement WMI_FN_RGB_KB_BRIGHTNESS (0x12) and
   answers 0xE000.

The full acpidump of this machine is attached to the bug:
https://bugzilla.kernel.org/attachment.cgi?id=310971

Details, traces and the exact verification steps for the key events:
https://bugzilla.kernel.org/show_bug.cgi?id=222062

I am happy to test patches on this model.

Thanks,
Anton Karasev

  reply	other threads:[~2026-09-30  1:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-29 13:44 [PATCH v6 0/5] Merge redmi-wmi into bitland-mifs-wmi Mingyou Chen
2026-09-29 13:44 ` [PATCH v6 1/5] MAINTAINERS: Add maintainer entry of bitland-mifs-wmi driver Mingyou Chen
2026-09-29 13:45 ` [PATCH v6 2/5] platform/x86: bitland-mifs-wmi: Merge the function of redmi-wmi into the bitland driver Mingyou Chen
2026-09-30  1:58   ` Anton Karasev [this message]
2026-09-30 20:53   ` Ilya Gladyshev
2026-09-30 22:01   ` Ilya Gladyshev
2026-09-29 13:45 ` [PATCH v6 3/5] platform/x86: bitland-mifs-wmi: Add Redmi mic-mute key entries Mingyou Chen
2026-09-29 13:45 ` [PATCH v6 4/5] platform/x86: redmi-wmi: Drop redmi-wmi driver Mingyou Chen
2026-09-29 13:45 ` [PATCH v6 5/5] platform/x86: bitland-mifs-wmi: Add per-machine ops table Mingyou Chen
2026-09-30  1:50   ` Anton Karasev
2026-10-02  0:18     ` Miloš Vlku
2026-10-02  0:51       ` Miloš Vlku
2026-10-02  1:15         ` Mingyou Chen
2026-10-02  1:34         ` Mingyou Chen
2026-10-02  9:21         ` Ilpo Järvinen
2026-10-08 15:28         ` Anton Karasev
2026-10-08 22:06           ` Miloš Vlku

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260930015806.3111929-1-uselessfire@gmail.com \
    --to=uselessfire@gmail.com \
    --cc=W_Armin@gmx.de \
    --cc=bozhenpeng93@gmail.com \
    --cc=btx342@gmail.com \
    --cc=chris@miget.com \
    --cc=ericted8810@gmail.com \
    --cc=foxido@foxido.dev \
    --cc=hansg@kernel.org \
    --cc=i@rsplwe.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=ilya.gladyshev@linux.dev \
    --cc=kento@kekto.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matias.civadda2342001@gmail.com \
    --cc=nika@nikableh.moe \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=qby140326@gmail.com \
    --cc=vlku.milos.fun@gmail.com \
    --cc=wleizc7319@gmail.com \
    --cc=wolf109909@outlook.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.