* [RFC PATCH 0/3] platform: lenovo: architecture independent home for the Lenovo WMI drivers
@ 2026-11-13 22:27 David Cemin
2026-11-13 22:27 ` [RFC PATCH 1/3] platform: lenovo: move the architecture independent WMI drivers out of x86 David Cemin
` (4 more replies)
0 siblings, 5 replies; 27+ messages in thread
From: David Cemin @ 2026-11-13 22:27 UTC (permalink / raw)
To: hansg, ilpo.jarvinen, W_Armin
Cc: mpearson-lenovo, derekjohn.clark, xy-jackie, ikepanhc,
platform-driver-x86, linux-kernel, ldemarchi
Lenovo now ships ACPI based arm64 laptops whose firmware exposes the
same ACPI-WMI interfaces as the x86 IdeaPad and Legion machines: the Fn
key event GUID consumed by ideapad-laptop, the hotkey utility GUID used
for the microphone mute LED, and the GameZone, Other Mode and capability
data GUIDs behind the thermal operation modes. Since 884d53763d30
("platform/wmi: Remove dependency on CONFIG_X86") the ACPI-WMI core
builds on arm64, but the Lenovo WMI drivers still live under
drivers/platform/x86, which is gated by X86_PLATFORM_DEVICES, so none of
that code can be used where the firmware is.
This series:
1. moves the architecture independent Lenovo WMI drivers into a new
drivers/platform/lenovo directory, following drivers/platform/surface
which exists for the same reason (Surface ships x86 and arm64);
ideapad-laptop, thinkpad_acpi, think-lmi and the Yoga tablet drivers
stay under x86 because they need i8042, port I/O or x86 only devices;
2. adds a small WMI hotkeys driver for the Fn key event GUID on machines
where ideapad-laptop cannot bind;
3. makes ideapad-laptop's own WMI event driver decline the GUIDs when
the IdeaPad VPC device is absent, since it can never report events
there.
Patch 2 was tested on a Lenovo Yoga 9 2-in-1 16 (arm64): microphone
mute, airplane mode, the Smart Key, the Smart Connect key and the Fn+Q
operation mode key all report input events. The same key set is dead on
a Lenovo Yoga Pro 9 (arm64) today and uses the same GUID.
Patches 1 and 3 are compile tested on x86_64 and arm64 (defconfig plus
all LENOVO_WMI options as modules).
Two questions I would like the maintainers' view on before this goes
further:
a. Is a vendor directory (drivers/platform/lenovo, like surface) the
right home, or should the architecture independent Lenovo WMI
drivers move under drivers/platform/wmi next to the core instead?
b. Should the Fn key event handling stay a separate small driver, or
be factored out of ideapad-laptop so x86 and arm64 share one path?
ideapad-laptop handles the event only when its VPC platform driver
is bound, and the arm64 machines expose none of the VPC interface
it is built on (no _CFG, VPCR/VPCW, DYTC or HALS/SALS), so making
it the single driver means gating most of its probe. Two smaller
options: lift ideapad-laptop's own Fn key wmi_driver and keymap
into this file and let ideapad-laptop register for the events it
still wants (Fn lock LED, DYTC cycle), or the hid-asus/asus-wmi
shape where a companion WMI module exports the event to a
subsystem driver. The keymap in patch 2 duplicates entries of
ideapad-laptop's table on purpose until that is decided.
Patch 2 declines to bind when the IdeaPad VPC device (VPC2004) is
present, so machines handled by ideapad-laptop keep it; patch 3 is the
mirror on the ideapad-laptop side. The new MAINTAINERS entry uses
platform-driver-x86, the list that already covers drivers/platform/arm64,
the ACPI-WMI core and the other Lenovo WMI drivers.
David Cemin (3):
platform: lenovo: move the architecture independent WMI drivers out of
x86
platform: lenovo: add WMI hotkeys driver
platform/x86: ideapad-laptop: do not bind the WMI event devices
without the VPC
MAINTAINERS | 9 +-
drivers/platform/Kconfig | 2 +
drivers/platform/Makefile | 1 +
drivers/platform/lenovo/Kconfig | 101 ++++++++++++
drivers/platform/lenovo/Makefile | 23 +++
.../platform/{x86 => }/lenovo/wmi-camera.c | 0
.../platform/{x86 => }/lenovo/wmi-capdata.c | 0
.../platform/{x86 => }/lenovo/wmi-capdata.h | 0
.../platform/{x86 => }/lenovo/wmi-events.c | 0
.../platform/{x86 => }/lenovo/wmi-events.h | 0
.../platform/{x86 => }/lenovo/wmi-gamezone.c | 0
.../platform/{x86 => }/lenovo/wmi-helpers.c | 0
.../platform/{x86 => }/lenovo/wmi-helpers.h | 0
.../{x86 => }/lenovo/wmi-hotkey-utilities.c | 0
drivers/platform/lenovo/wmi-hotkeys.c | 151 ++++++++++++++++++
drivers/platform/{x86 => }/lenovo/wmi-other.c | 0
drivers/platform/x86/lenovo/Kconfig | 67 --------
drivers/platform/x86/lenovo/Makefile | 7 -
drivers/platform/x86/lenovo/ideapad-laptop.c | 8 +
19 files changed, 294 insertions(+), 75 deletions(-)
create mode 100644 drivers/platform/lenovo/Kconfig
create mode 100644 drivers/platform/lenovo/Makefile
rename drivers/platform/{x86 => }/lenovo/wmi-camera.c (100%)
rename drivers/platform/{x86 => }/lenovo/wmi-capdata.c (100%)
rename drivers/platform/{x86 => }/lenovo/wmi-capdata.h (100%)
rename drivers/platform/{x86 => }/lenovo/wmi-events.c (100%)
rename drivers/platform/{x86 => }/lenovo/wmi-events.h (100%)
rename drivers/platform/{x86 => }/lenovo/wmi-gamezone.c (100%)
rename drivers/platform/{x86 => }/lenovo/wmi-helpers.c (100%)
rename drivers/platform/{x86 => }/lenovo/wmi-helpers.h (100%)
rename drivers/platform/{x86 => }/lenovo/wmi-hotkey-utilities.c (100%)
create mode 100644 drivers/platform/lenovo/wmi-hotkeys.c
rename drivers/platform/{x86 => }/lenovo/wmi-other.c (100%)
base-commit: 2800868f63227c8237d70c41e70d441c919620d6
--
2.56.1
^ permalink raw reply [flat|nested] 27+ messages in thread* [RFC PATCH 1/3] platform: lenovo: move the architecture independent WMI drivers out of x86 2026-11-13 22:27 [RFC PATCH 0/3] platform: lenovo: architecture independent home for the Lenovo WMI drivers David Cemin @ 2026-11-13 22:27 ` David Cemin 2026-11-15 21:50 ` Mark Pearson 2026-11-13 22:27 ` [RFC PATCH 2/3] platform: lenovo: add WMI hotkeys driver David Cemin ` (3 subsequent siblings) 4 siblings, 1 reply; 27+ messages in thread From: David Cemin @ 2026-11-13 22:27 UTC (permalink / raw) To: hansg, ilpo.jarvinen, W_Armin Cc: mpearson-lenovo, derekjohn.clark, xy-jackie, ikepanhc, platform-driver-x86, linux-kernel, ldemarchi The Lenovo WMI drivers (events, helpers, capability data, GameZone, Other Mode, hotkey utilities and camera button) contain no x86 specific code: they talk to firmware through the ACPI-WMI core only. They live under drivers/platform/x86 because that is where Lenovo drivers were collected, and X86_PLATFORM_DEVICES keeps them off every other architecture. Lenovo now ships ACPI based arm64 laptops whose firmware exposes the same WMI GUIDs (the Fn key events, the mic mute LED method, GameZone and Other Mode). Give these drivers an architecture independent home, drivers/platform/lenovo, following the layout of drivers/platform/surface which exists for the same reason, so they can be built wherever the WMI core is available. ideapad-laptop, thinkpad_acpi, think-lmi, yogabook and the Yoga Tablet drivers stay under x86: they depend on i8042, port I/O or x86 only ACPI devices. Pure code motion: the files, their Kconfig entries and the module naming scheme are unchanged. MAINTAINERS entries are updated for the new paths. Signed-off-by: David Cemin <dcemin@nvidia.com> --- MAINTAINERS | 3 +- drivers/platform/Kconfig | 2 + drivers/platform/Makefile | 1 + drivers/platform/lenovo/Kconfig | 87 +++++++++++++++++++ drivers/platform/lenovo/Makefile | 22 +++++ .../platform/{x86 => }/lenovo/wmi-camera.c | 0 .../platform/{x86 => }/lenovo/wmi-capdata.c | 0 .../platform/{x86 => }/lenovo/wmi-capdata.h | 0 .../platform/{x86 => }/lenovo/wmi-events.c | 0 .../platform/{x86 => }/lenovo/wmi-events.h | 0 .../platform/{x86 => }/lenovo/wmi-gamezone.c | 0 .../platform/{x86 => }/lenovo/wmi-helpers.c | 0 .../platform/{x86 => }/lenovo/wmi-helpers.h | 0 .../{x86 => }/lenovo/wmi-hotkey-utilities.c | 0 drivers/platform/{x86 => }/lenovo/wmi-other.c | 0 drivers/platform/x86/lenovo/Kconfig | 67 -------------- drivers/platform/x86/lenovo/Makefile | 7 -- 17 files changed, 114 insertions(+), 75 deletions(-) create mode 100644 drivers/platform/lenovo/Kconfig create mode 100644 drivers/platform/lenovo/Makefile rename drivers/platform/{x86 => }/lenovo/wmi-camera.c (100%) rename drivers/platform/{x86 => }/lenovo/wmi-capdata.c (100%) rename drivers/platform/{x86 => }/lenovo/wmi-capdata.h (100%) rename drivers/platform/{x86 => }/lenovo/wmi-events.c (100%) rename drivers/platform/{x86 => }/lenovo/wmi-events.h (100%) rename drivers/platform/{x86 => }/lenovo/wmi-gamezone.c (100%) rename drivers/platform/{x86 => }/lenovo/wmi-helpers.c (100%) rename drivers/platform/{x86 => }/lenovo/wmi-helpers.h (100%) rename drivers/platform/{x86 => }/lenovo/wmi-hotkey-utilities.c (100%) rename drivers/platform/{x86 => }/lenovo/wmi-other.c (100%) diff --git a/MAINTAINERS b/MAINTAINERS index 056408bc086e..3b0ad5a3debe 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -15170,13 +15170,14 @@ L: platform-driver-x86@vger.kernel.org S: Maintained F: Documentation/wmi/devices/lenovo-wmi-gamezone.rst F: Documentation/wmi/devices/lenovo-wmi-other.rst +F: drivers/platform/lenovo/ F: drivers/platform/x86/lenovo/* LENOVO WMI HOTKEY UTILITIES DRIVER M: Jackie Dong <xy-jackie@139.com> L: platform-driver-x86@vger.kernel.org S: Maintained -F: drivers/platform/x86/lenovo/wmi-hotkey-utilities.c +F: drivers/platform/lenovo/wmi-hotkey-utilities.c LENOVO HID drivers M: Derek J. Clark <derekjohn.clark@gmail.com> diff --git a/drivers/platform/Kconfig b/drivers/platform/Kconfig index 312788f249c9..80b2b83b69e5 100644 --- a/drivers/platform/Kconfig +++ b/drivers/platform/Kconfig @@ -15,6 +15,8 @@ source "drivers/platform/olpc/Kconfig" source "drivers/platform/surface/Kconfig" +source "drivers/platform/lenovo/Kconfig" + source "drivers/platform/x86/Kconfig" source "drivers/platform/arm64/Kconfig" diff --git a/drivers/platform/Makefile b/drivers/platform/Makefile index fa322e7f8716..0144f88ff6db 100644 --- a/drivers/platform/Makefile +++ b/drivers/platform/Makefile @@ -12,6 +12,7 @@ obj-$(CONFIG_GOLDFISH) += goldfish/ obj-$(CONFIG_CHROME_PLATFORMS) += chrome/ obj-$(CONFIG_CZNIC_PLATFORMS) += cznic/ obj-$(CONFIG_SURFACE_PLATFORMS) += surface/ +obj-$(CONFIG_LENOVO_PLATFORMS) += lenovo/ obj-$(CONFIG_ARM64_PLATFORM_DEVICES) += arm64/ obj-$(CONFIG_BCM2835_VCHIQ) += raspberrypi/ obj-$(CONFIG_ACPI_WMI) += wmi/ diff --git a/drivers/platform/lenovo/Kconfig b/drivers/platform/lenovo/Kconfig new file mode 100644 index 000000000000..8222322ca671 --- /dev/null +++ b/drivers/platform/lenovo/Kconfig @@ -0,0 +1,87 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Lenovo Platform-Specific Drivers +# + +menuconfig LENOVO_PLATFORMS + bool "Lenovo Platform-Specific Device Drivers" + depends on ARM64 || X86 || COMPILE_TEST + default y if ARM64 || X86 + help + Say Y here to get to see options for platform-specific device drivers + for Lenovo devices that do not depend on the CPU architecture, such + as the ACPI-WMI based drivers used on both x86 and arm64 laptops. + This option alone does not add any kernel code. + + If you say N, all options in this submenu will be skipped and disabled. + +if LENOVO_PLATFORMS + +config LENOVO_WMI_HELPERS + tristate + depends on ACPI_WMI + +config LENOVO_WMI_EVENTS + tristate + depends on ACPI_WMI + +config LENOVO_WMI_CAPDATA + tristate + depends on ACPI_WMI + depends on LENOVO_WMI_HELPERS + +config LENOVO_WMI_HOTKEY_UTILITIES + tristate "Lenovo Hotkey Utility WMI extras driver" + depends on ACPI_WMI + select NEW_LEDS + select LEDS_CLASS + imply IDEAPAD_LAPTOP + help + This driver provides WMI support for Lenovo customized hotkeys function, + such as LED control for audio/mic mute event for Ideapad, YOGA, XiaoXin, + Gaming, ThinkBook and so on. + +config LENOVO_WMI_CAMERA + tristate "Lenovo WMI Camera Button driver" + depends on ACPI_WMI + depends on INPUT + help + This driver provides support for Lenovo camera button. The Camera + button is a GPIO device. This driver receives ACPI notifications when + the camera button is switched on/off. + + To compile this driver as a module, choose M here: the module + will be called lenovo-wmi-camera. + +config LENOVO_WMI_GAMEZONE + tristate "Lenovo GameZone WMI Driver" + depends on ACPI_WMI + depends on DMI + select ACPI_PLATFORM_PROFILE + select LENOVO_WMI_EVENTS + select LENOVO_WMI_HELPERS + help + Say Y here if you have a WMI aware Lenovo Legion device and would like to use the + platform-profile firmware interface to manage power usage. + + To compile this driver as a module, choose M here: the module will + be called lenovo-wmi-gamezone. + +config LENOVO_WMI_TUNING + tristate "Lenovo Other Mode WMI Driver" + depends on ACPI_WMI + depends on ACPI_BATTERY + select HWMON + select FW_ATTR_CLASS + select LENOVO_WMI_CAPDATA + select LENOVO_WMI_EVENTS + select LENOVO_WMI_HELPERS + help + Say Y here if you have a WMI aware Lenovo Legion device and would like to use the + firmware_attributes API to control various tunable settings typically exposed by + Lenovo software in Windows. + + To compile this driver as a module, choose M here: the module will + be called lenovo-wmi-other. + +endif # LENOVO_PLATFORMS diff --git a/drivers/platform/lenovo/Makefile b/drivers/platform/lenovo/Makefile new file mode 100644 index 000000000000..1cac115dd735 --- /dev/null +++ b/drivers/platform/lenovo/Makefile @@ -0,0 +1,22 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for linux/drivers/platform/lenovo +# Lenovo Platform Specific Drivers (architecture independent) +# + +lenovo-target-$(CONFIG_LENOVO_WMI_HELPERS) += wmi-helpers.o +lenovo-target-$(CONFIG_LENOVO_WMI_EVENTS) += wmi-events.o +lenovo-target-$(CONFIG_LENOVO_WMI_CAPDATA) += wmi-capdata.o +lenovo-target-$(CONFIG_LENOVO_WMI_HOTKEY_UTILITIES) += wmi-hotkey-utilities.o +lenovo-target-$(CONFIG_LENOVO_WMI_CAMERA) += wmi-camera.o +lenovo-target-$(CONFIG_LENOVO_WMI_GAMEZONE) += wmi-gamezone.o +lenovo-target-$(CONFIG_LENOVO_WMI_TUNING) += wmi-other.o + +# Add 'lenovo' prefix to each module listed in lenovo-target-* +define LENOVO_OBJ_TARGET +lenovo-$(1)-y := $(1).o +obj-$(2) += lenovo-$(1).o +endef + +$(foreach target, $(basename $(lenovo-target-y)), $(eval $(call LENOVO_OBJ_TARGET,$(target),y))) +$(foreach target, $(basename $(lenovo-target-m)), $(eval $(call LENOVO_OBJ_TARGET,$(target),m))) diff --git a/drivers/platform/x86/lenovo/wmi-camera.c b/drivers/platform/lenovo/wmi-camera.c similarity index 100% rename from drivers/platform/x86/lenovo/wmi-camera.c rename to drivers/platform/lenovo/wmi-camera.c diff --git a/drivers/platform/x86/lenovo/wmi-capdata.c b/drivers/platform/lenovo/wmi-capdata.c similarity index 100% rename from drivers/platform/x86/lenovo/wmi-capdata.c rename to drivers/platform/lenovo/wmi-capdata.c diff --git a/drivers/platform/x86/lenovo/wmi-capdata.h b/drivers/platform/lenovo/wmi-capdata.h similarity index 100% rename from drivers/platform/x86/lenovo/wmi-capdata.h rename to drivers/platform/lenovo/wmi-capdata.h diff --git a/drivers/platform/x86/lenovo/wmi-events.c b/drivers/platform/lenovo/wmi-events.c similarity index 100% rename from drivers/platform/x86/lenovo/wmi-events.c rename to drivers/platform/lenovo/wmi-events.c diff --git a/drivers/platform/x86/lenovo/wmi-events.h b/drivers/platform/lenovo/wmi-events.h similarity index 100% rename from drivers/platform/x86/lenovo/wmi-events.h rename to drivers/platform/lenovo/wmi-events.h diff --git a/drivers/platform/x86/lenovo/wmi-gamezone.c b/drivers/platform/lenovo/wmi-gamezone.c similarity index 100% rename from drivers/platform/x86/lenovo/wmi-gamezone.c rename to drivers/platform/lenovo/wmi-gamezone.c diff --git a/drivers/platform/x86/lenovo/wmi-helpers.c b/drivers/platform/lenovo/wmi-helpers.c similarity index 100% rename from drivers/platform/x86/lenovo/wmi-helpers.c rename to drivers/platform/lenovo/wmi-helpers.c diff --git a/drivers/platform/x86/lenovo/wmi-helpers.h b/drivers/platform/lenovo/wmi-helpers.h similarity index 100% rename from drivers/platform/x86/lenovo/wmi-helpers.h rename to drivers/platform/lenovo/wmi-helpers.h diff --git a/drivers/platform/x86/lenovo/wmi-hotkey-utilities.c b/drivers/platform/lenovo/wmi-hotkey-utilities.c similarity index 100% rename from drivers/platform/x86/lenovo/wmi-hotkey-utilities.c rename to drivers/platform/lenovo/wmi-hotkey-utilities.c diff --git a/drivers/platform/x86/lenovo/wmi-other.c b/drivers/platform/lenovo/wmi-other.c similarity index 100% rename from drivers/platform/x86/lenovo/wmi-other.c rename to drivers/platform/lenovo/wmi-other.c diff --git a/drivers/platform/x86/lenovo/Kconfig b/drivers/platform/x86/lenovo/Kconfig index 516594993073..36bcefb61805 100644 --- a/drivers/platform/x86/lenovo/Kconfig +++ b/drivers/platform/x86/lenovo/Kconfig @@ -20,29 +20,6 @@ config IDEAPAD_LAPTOP This is a driver for Lenovo IdeaPad netbooks contains drivers for rfkill switch, hotkey, fan control and backlight control. -config LENOVO_WMI_HOTKEY_UTILITIES - tristate "Lenovo Hotkey Utility WMI extras driver" - depends on ACPI_WMI - select NEW_LEDS - select LEDS_CLASS - imply IDEAPAD_LAPTOP - help - This driver provides WMI support for Lenovo customized hotkeys function, - such as LED control for audio/mic mute event for Ideapad, YOGA, XiaoXin, - Gaming, ThinkBook and so on. - -config LENOVO_WMI_CAMERA - tristate "Lenovo WMI Camera Button driver" - depends on ACPI_WMI - depends on INPUT - help - This driver provides support for Lenovo camera button. The Camera - button is a GPIO device. This driver receives ACPI notifications when - the camera button is switched on/off. - - To compile this driver as a module, choose M here: the module - will be called lenovo-wmi-camera. - config LENOVO_YB9_KBDOCK tristate "Lenovo Yoga Book 9 keyboard dock detection" depends on ACPI_WMI @@ -246,47 +223,3 @@ config YT2_1380 To compile this driver as a module, choose M here: the module will be called lenovo-yogabook. - -config LENOVO_WMI_CAPDATA - tristate - depends on ACPI_WMI - depends on LENOVO_WMI_HELPERS - -config LENOVO_WMI_EVENTS - tristate - depends on ACPI_WMI - -config LENOVO_WMI_HELPERS - tristate - depends on ACPI_WMI - -config LENOVO_WMI_GAMEZONE - tristate "Lenovo GameZone WMI Driver" - depends on ACPI_WMI - depends on DMI - select ACPI_PLATFORM_PROFILE - select LENOVO_WMI_EVENTS - select LENOVO_WMI_HELPERS - help - Say Y here if you have a WMI aware Lenovo Legion device and would like to use the - platform-profile firmware interface to manage power usage. - - To compile this driver as a module, choose M here: the module will - be called lenovo-wmi-gamezone. - -config LENOVO_WMI_TUNING - tristate "Lenovo Other Mode WMI Driver" - depends on ACPI_WMI - depends on ACPI_BATTERY - select HWMON - select FW_ATTR_CLASS - select LENOVO_WMI_CAPDATA - select LENOVO_WMI_EVENTS - select LENOVO_WMI_HELPERS - help - Say Y here if you have a WMI aware Lenovo Legion device and would like to use the - firmware_attributes API to control various tunable settings typically exposed by - Lenovo software in Windows. - - To compile this driver as a module, choose M here: the module will - be called lenovo-wmi-other. diff --git a/drivers/platform/x86/lenovo/Makefile b/drivers/platform/x86/lenovo/Makefile index 12816d8d5e24..758c36cedee8 100644 --- a/drivers/platform/x86/lenovo/Makefile +++ b/drivers/platform/x86/lenovo/Makefile @@ -7,17 +7,10 @@ obj-$(CONFIG_IDEAPAD_LAPTOP) += ideapad-laptop.o obj-$(CONFIG_THINKPAD_LMI) += think-lmi.o obj-$(CONFIG_THINKPAD_ACPI) += thinkpad_acpi.o -lenovo-target-$(CONFIG_LENOVO_WMI_HOTKEY_UTILITIES) += wmi-hotkey-utilities.o lenovo-target-$(CONFIG_LENOVO_YB9_KBDOCK) += yb9-kbdock.o lenovo-target-$(CONFIG_LENOVO_YMC) += ymc.o lenovo-target-$(CONFIG_YOGABOOK) += yogabook.o lenovo-target-$(CONFIG_YT2_1380) += yoga-tab2-pro-1380-fastcharger.o -lenovo-target-$(CONFIG_LENOVO_WMI_CAMERA) += wmi-camera.o -lenovo-target-$(CONFIG_LENOVO_WMI_CAPDATA) += wmi-capdata.o -lenovo-target-$(CONFIG_LENOVO_WMI_EVENTS) += wmi-events.o -lenovo-target-$(CONFIG_LENOVO_WMI_HELPERS) += wmi-helpers.o -lenovo-target-$(CONFIG_LENOVO_WMI_GAMEZONE) += wmi-gamezone.o -lenovo-target-$(CONFIG_LENOVO_WMI_TUNING) += wmi-other.o # Add 'lenovo' prefix to each module listed in lenovo-target-* define LENOVO_OBJ_TARGET -- 2.56.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH 1/3] platform: lenovo: move the architecture independent WMI drivers out of x86 2026-11-13 22:27 ` [RFC PATCH 1/3] platform: lenovo: move the architecture independent WMI drivers out of x86 David Cemin @ 2026-11-15 21:50 ` Mark Pearson 2026-11-16 4:42 ` David Cemin 2026-11-17 2:27 ` Jackie Dong 0 siblings, 2 replies; 27+ messages in thread From: Mark Pearson @ 2026-11-15 21:50 UTC (permalink / raw) To: David Cemin, Hans de Goede, Ilpo Järvinen, Armin Wolf Cc: Derek J . Clark, Jackie Dong, Ike Panhc, platform-driver-x86, linux-kernel, ldemarchi On Fri, Nov 13, 2026, at 5:27 PM, David Cemin wrote: > The Lenovo WMI drivers (events, helpers, capability data, GameZone, > Other Mode, hotkey utilities and camera button) contain no x86 specific > code: they talk to firmware through the ACPI-WMI core only. They live > under drivers/platform/x86 because that is where Lenovo drivers were > collected, and X86_PLATFORM_DEVICES keeps them off every other > architecture. > > Lenovo now ships ACPI based arm64 laptops whose firmware exposes the > same WMI GUIDs (the Fn key events, the mic mute LED method, GameZone and > Other Mode). Give these drivers an architecture independent home, > drivers/platform/lenovo, following the layout of drivers/platform/surface > which exists for the same reason, so they can be built wherever the WMI > core is available. ideapad-laptop, thinkpad_acpi, think-lmi, yogabook and > the Yoga Tablet drivers stay under x86: they depend on i8042, port I/O or > x86 only ACPI devices. > > Pure code motion: the files, their Kconfig entries and the module naming > scheme are unchanged. MAINTAINERS entries are updated for the new paths. > > Signed-off-by: David Cemin <dcemin@nvidia.com> > --- > MAINTAINERS | 3 +- > drivers/platform/Kconfig | 2 + > drivers/platform/Makefile | 1 + > drivers/platform/lenovo/Kconfig | 87 +++++++++++++++++++ > drivers/platform/lenovo/Makefile | 22 +++++ > .../platform/{x86 => }/lenovo/wmi-camera.c | 0 > .../platform/{x86 => }/lenovo/wmi-capdata.c | 0 > .../platform/{x86 => }/lenovo/wmi-capdata.h | 0 > .../platform/{x86 => }/lenovo/wmi-events.c | 0 > .../platform/{x86 => }/lenovo/wmi-events.h | 0 > .../platform/{x86 => }/lenovo/wmi-gamezone.c | 0 > .../platform/{x86 => }/lenovo/wmi-helpers.c | 0 > .../platform/{x86 => }/lenovo/wmi-helpers.h | 0 > .../{x86 => }/lenovo/wmi-hotkey-utilities.c | 0 > drivers/platform/{x86 => }/lenovo/wmi-other.c | 0 > drivers/platform/x86/lenovo/Kconfig | 67 -------------- > drivers/platform/x86/lenovo/Makefile | 7 -- > 17 files changed, 114 insertions(+), 75 deletions(-) > create mode 100644 drivers/platform/lenovo/Kconfig > create mode 100644 drivers/platform/lenovo/Makefile > rename drivers/platform/{x86 => }/lenovo/wmi-camera.c (100%) > rename drivers/platform/{x86 => }/lenovo/wmi-capdata.c (100%) > rename drivers/platform/{x86 => }/lenovo/wmi-capdata.h (100%) > rename drivers/platform/{x86 => }/lenovo/wmi-events.c (100%) > rename drivers/platform/{x86 => }/lenovo/wmi-events.h (100%) > rename drivers/platform/{x86 => }/lenovo/wmi-gamezone.c (100%) > rename drivers/platform/{x86 => }/lenovo/wmi-helpers.c (100%) > rename drivers/platform/{x86 => }/lenovo/wmi-helpers.h (100%) > rename drivers/platform/{x86 => }/lenovo/wmi-hotkey-utilities.c (100%) > rename drivers/platform/{x86 => }/lenovo/wmi-other.c (100%) > > diff --git a/MAINTAINERS b/MAINTAINERS > index 056408bc086e..3b0ad5a3debe 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -15170,13 +15170,14 @@ L: platform-driver-x86@vger.kernel.org > S: Maintained > F: Documentation/wmi/devices/lenovo-wmi-gamezone.rst > F: Documentation/wmi/devices/lenovo-wmi-other.rst > +F: drivers/platform/lenovo/ > F: drivers/platform/x86/lenovo/* > > LENOVO WMI HOTKEY UTILITIES DRIVER > M: Jackie Dong <xy-jackie@139.com> > L: platform-driver-x86@vger.kernel.org > S: Maintained > -F: drivers/platform/x86/lenovo/wmi-hotkey-utilities.c > +F: drivers/platform/lenovo/wmi-hotkey-utilities.c > > LENOVO HID drivers > M: Derek J. Clark <derekjohn.clark@gmail.com> > diff --git a/drivers/platform/Kconfig b/drivers/platform/Kconfig > index 312788f249c9..80b2b83b69e5 100644 > --- a/drivers/platform/Kconfig > +++ b/drivers/platform/Kconfig > @@ -15,6 +15,8 @@ source "drivers/platform/olpc/Kconfig" > > source "drivers/platform/surface/Kconfig" > > +source "drivers/platform/lenovo/Kconfig" > + > source "drivers/platform/x86/Kconfig" > > source "drivers/platform/arm64/Kconfig" > diff --git a/drivers/platform/Makefile b/drivers/platform/Makefile > index fa322e7f8716..0144f88ff6db 100644 > --- a/drivers/platform/Makefile > +++ b/drivers/platform/Makefile > @@ -12,6 +12,7 @@ obj-$(CONFIG_GOLDFISH) += goldfish/ > obj-$(CONFIG_CHROME_PLATFORMS) += chrome/ > obj-$(CONFIG_CZNIC_PLATFORMS) += cznic/ > obj-$(CONFIG_SURFACE_PLATFORMS) += surface/ > +obj-$(CONFIG_LENOVO_PLATFORMS) += lenovo/ > obj-$(CONFIG_ARM64_PLATFORM_DEVICES) += arm64/ > obj-$(CONFIG_BCM2835_VCHIQ) += raspberrypi/ > obj-$(CONFIG_ACPI_WMI) += wmi/ > diff --git a/drivers/platform/lenovo/Kconfig > b/drivers/platform/lenovo/Kconfig > new file mode 100644 > index 000000000000..8222322ca671 > --- /dev/null > +++ b/drivers/platform/lenovo/Kconfig > @@ -0,0 +1,87 @@ > +# SPDX-License-Identifier: GPL-2.0-only > +# > +# Lenovo Platform-Specific Drivers > +# > + > +menuconfig LENOVO_PLATFORMS > + bool "Lenovo Platform-Specific Device Drivers" > + depends on ARM64 || X86 || COMPILE_TEST > + default y if ARM64 || X86 > + help > + Say Y here to get to see options for platform-specific device > drivers > + for Lenovo devices that do not depend on the CPU architecture, such > + as the ACPI-WMI based drivers used on both x86 and arm64 laptops. > + This option alone does not add any kernel code. > + > + If you say N, all options in this submenu will be skipped and > disabled. > + > +if LENOVO_PLATFORMS > + > +config LENOVO_WMI_HELPERS > + tristate > + depends on ACPI_WMI > + > +config LENOVO_WMI_EVENTS > + tristate > + depends on ACPI_WMI > + > +config LENOVO_WMI_CAPDATA > + tristate > + depends on ACPI_WMI > + depends on LENOVO_WMI_HELPERS > + > +config LENOVO_WMI_HOTKEY_UTILITIES > + tristate "Lenovo Hotkey Utility WMI extras driver" > + depends on ACPI_WMI > + select NEW_LEDS > + select LEDS_CLASS > + imply IDEAPAD_LAPTOP > + help > + This driver provides WMI support for Lenovo customized hotkeys > function, > + such as LED control for audio/mic mute event for Ideapad, YOGA, > XiaoXin, > + Gaming, ThinkBook and so on. > + > +config LENOVO_WMI_CAMERA > + tristate "Lenovo WMI Camera Button driver" > + depends on ACPI_WMI > + depends on INPUT > + help > + This driver provides support for Lenovo camera button. The Camera > + button is a GPIO device. This driver receives ACPI notifications > when > + the camera button is switched on/off. > + > + To compile this driver as a module, choose M here: the module > + will be called lenovo-wmi-camera. > + > +config LENOVO_WMI_GAMEZONE > + tristate "Lenovo GameZone WMI Driver" > + depends on ACPI_WMI > + depends on DMI > + select ACPI_PLATFORM_PROFILE > + select LENOVO_WMI_EVENTS > + select LENOVO_WMI_HELPERS > + help > + Say Y here if you have a WMI aware Lenovo Legion device and would > like to use the > + platform-profile firmware interface to manage power usage. > + > + To compile this driver as a module, choose M here: the module will > + be called lenovo-wmi-gamezone. > + > +config LENOVO_WMI_TUNING > + tristate "Lenovo Other Mode WMI Driver" > + depends on ACPI_WMI > + depends on ACPI_BATTERY > + select HWMON > + select FW_ATTR_CLASS > + select LENOVO_WMI_CAPDATA > + select LENOVO_WMI_EVENTS > + select LENOVO_WMI_HELPERS > + help > + Say Y here if you have a WMI aware Lenovo Legion device and would > like to use the > + firmware_attributes API to control various tunable settings > typically exposed by > + Lenovo software in Windows. > + > + To compile this driver as a module, choose M here: the module will > + be called lenovo-wmi-other. > + > +endif # LENOVO_PLATFORMS > diff --git a/drivers/platform/lenovo/Makefile > b/drivers/platform/lenovo/Makefile > new file mode 100644 > index 000000000000..1cac115dd735 > --- /dev/null > +++ b/drivers/platform/lenovo/Makefile > @@ -0,0 +1,22 @@ > +# SPDX-License-Identifier: GPL-2.0 > +# > +# Makefile for linux/drivers/platform/lenovo > +# Lenovo Platform Specific Drivers (architecture independent) > +# > + > +lenovo-target-$(CONFIG_LENOVO_WMI_HELPERS) += wmi-helpers.o > +lenovo-target-$(CONFIG_LENOVO_WMI_EVENTS) += wmi-events.o > +lenovo-target-$(CONFIG_LENOVO_WMI_CAPDATA) += wmi-capdata.o > +lenovo-target-$(CONFIG_LENOVO_WMI_HOTKEY_UTILITIES) += > wmi-hotkey-utilities.o > +lenovo-target-$(CONFIG_LENOVO_WMI_CAMERA) += wmi-camera.o > +lenovo-target-$(CONFIG_LENOVO_WMI_GAMEZONE) += wmi-gamezone.o > +lenovo-target-$(CONFIG_LENOVO_WMI_TUNING) += wmi-other.o > + > +# Add 'lenovo' prefix to each module listed in lenovo-target-* > +define LENOVO_OBJ_TARGET > +lenovo-$(1)-y := $(1).o > +obj-$(2) += lenovo-$(1).o > +endef > + > +$(foreach target, $(basename $(lenovo-target-y)), $(eval $(call > LENOVO_OBJ_TARGET,$(target),y))) > +$(foreach target, $(basename $(lenovo-target-m)), $(eval $(call > LENOVO_OBJ_TARGET,$(target),m))) > diff --git a/drivers/platform/x86/lenovo/wmi-camera.c > b/drivers/platform/lenovo/wmi-camera.c > similarity index 100% > rename from drivers/platform/x86/lenovo/wmi-camera.c > rename to drivers/platform/lenovo/wmi-camera.c > diff --git a/drivers/platform/x86/lenovo/wmi-capdata.c > b/drivers/platform/lenovo/wmi-capdata.c > similarity index 100% > rename from drivers/platform/x86/lenovo/wmi-capdata.c > rename to drivers/platform/lenovo/wmi-capdata.c > diff --git a/drivers/platform/x86/lenovo/wmi-capdata.h > b/drivers/platform/lenovo/wmi-capdata.h > similarity index 100% > rename from drivers/platform/x86/lenovo/wmi-capdata.h > rename to drivers/platform/lenovo/wmi-capdata.h > diff --git a/drivers/platform/x86/lenovo/wmi-events.c > b/drivers/platform/lenovo/wmi-events.c > similarity index 100% > rename from drivers/platform/x86/lenovo/wmi-events.c > rename to drivers/platform/lenovo/wmi-events.c > diff --git a/drivers/platform/x86/lenovo/wmi-events.h > b/drivers/platform/lenovo/wmi-events.h > similarity index 100% > rename from drivers/platform/x86/lenovo/wmi-events.h > rename to drivers/platform/lenovo/wmi-events.h > diff --git a/drivers/platform/x86/lenovo/wmi-gamezone.c > b/drivers/platform/lenovo/wmi-gamezone.c > similarity index 100% > rename from drivers/platform/x86/lenovo/wmi-gamezone.c > rename to drivers/platform/lenovo/wmi-gamezone.c > diff --git a/drivers/platform/x86/lenovo/wmi-helpers.c > b/drivers/platform/lenovo/wmi-helpers.c > similarity index 100% > rename from drivers/platform/x86/lenovo/wmi-helpers.c > rename to drivers/platform/lenovo/wmi-helpers.c > diff --git a/drivers/platform/x86/lenovo/wmi-helpers.h > b/drivers/platform/lenovo/wmi-helpers.h > similarity index 100% > rename from drivers/platform/x86/lenovo/wmi-helpers.h > rename to drivers/platform/lenovo/wmi-helpers.h > diff --git a/drivers/platform/x86/lenovo/wmi-hotkey-utilities.c > b/drivers/platform/lenovo/wmi-hotkey-utilities.c > similarity index 100% > rename from drivers/platform/x86/lenovo/wmi-hotkey-utilities.c > rename to drivers/platform/lenovo/wmi-hotkey-utilities.c > diff --git a/drivers/platform/x86/lenovo/wmi-other.c > b/drivers/platform/lenovo/wmi-other.c > similarity index 100% > rename from drivers/platform/x86/lenovo/wmi-other.c > rename to drivers/platform/lenovo/wmi-other.c > diff --git a/drivers/platform/x86/lenovo/Kconfig > b/drivers/platform/x86/lenovo/Kconfig > index 516594993073..36bcefb61805 100644 > --- a/drivers/platform/x86/lenovo/Kconfig > +++ b/drivers/platform/x86/lenovo/Kconfig > @@ -20,29 +20,6 @@ config IDEAPAD_LAPTOP > This is a driver for Lenovo IdeaPad netbooks contains drivers for > rfkill switch, hotkey, fan control and backlight control. > > -config LENOVO_WMI_HOTKEY_UTILITIES > - tristate "Lenovo Hotkey Utility WMI extras driver" > - depends on ACPI_WMI > - select NEW_LEDS > - select LEDS_CLASS > - imply IDEAPAD_LAPTOP > - help > - This driver provides WMI support for Lenovo customized hotkeys function, > - such as LED control for audio/mic mute event for Ideapad, YOGA, XiaoXin, > - Gaming, ThinkBook and so on. > - > -config LENOVO_WMI_CAMERA > - tristate "Lenovo WMI Camera Button driver" > - depends on ACPI_WMI > - depends on INPUT > - help > - This driver provides support for Lenovo camera button. The Camera > - button is a GPIO device. This driver receives ACPI notifications when > - the camera button is switched on/off. > - > - To compile this driver as a module, choose M here: the module > - will be called lenovo-wmi-camera. > - > config LENOVO_YB9_KBDOCK > tristate "Lenovo Yoga Book 9 keyboard dock detection" > depends on ACPI_WMI > @@ -246,47 +223,3 @@ config YT2_1380 > > To compile this driver as a module, choose M here: the module will > be called lenovo-yogabook. > - > -config LENOVO_WMI_CAPDATA > - tristate > - depends on ACPI_WMI > - depends on LENOVO_WMI_HELPERS > - > -config LENOVO_WMI_EVENTS > - tristate > - depends on ACPI_WMI > - > -config LENOVO_WMI_HELPERS > - tristate > - depends on ACPI_WMI > - > -config LENOVO_WMI_GAMEZONE > - tristate "Lenovo GameZone WMI Driver" > - depends on ACPI_WMI > - depends on DMI > - select ACPI_PLATFORM_PROFILE > - select LENOVO_WMI_EVENTS > - select LENOVO_WMI_HELPERS > - help > - Say Y here if you have a WMI aware Lenovo Legion device and would > like to use the > - platform-profile firmware interface to manage power usage. > - > - To compile this driver as a module, choose M here: the module will > - be called lenovo-wmi-gamezone. > - > -config LENOVO_WMI_TUNING > - tristate "Lenovo Other Mode WMI Driver" > - depends on ACPI_WMI > - depends on ACPI_BATTERY > - select HWMON > - select FW_ATTR_CLASS > - select LENOVO_WMI_CAPDATA > - select LENOVO_WMI_EVENTS > - select LENOVO_WMI_HELPERS > - help > - Say Y here if you have a WMI aware Lenovo Legion device and would > like to use the > - firmware_attributes API to control various tunable settings > typically exposed by > - Lenovo software in Windows. > - > - To compile this driver as a module, choose M here: the module will > - be called lenovo-wmi-other. > diff --git a/drivers/platform/x86/lenovo/Makefile > b/drivers/platform/x86/lenovo/Makefile > index 12816d8d5e24..758c36cedee8 100644 > --- a/drivers/platform/x86/lenovo/Makefile > +++ b/drivers/platform/x86/lenovo/Makefile > @@ -7,17 +7,10 @@ obj-$(CONFIG_IDEAPAD_LAPTOP) += ideapad-laptop.o > obj-$(CONFIG_THINKPAD_LMI) += think-lmi.o > obj-$(CONFIG_THINKPAD_ACPI) += thinkpad_acpi.o > > -lenovo-target-$(CONFIG_LENOVO_WMI_HOTKEY_UTILITIES) += wmi-hotkey-utilities.o > lenovo-target-$(CONFIG_LENOVO_YB9_KBDOCK) += yb9-kbdock.o > lenovo-target-$(CONFIG_LENOVO_YMC) += ymc.o > lenovo-target-$(CONFIG_YOGABOOK) += yogabook.o > lenovo-target-$(CONFIG_YT2_1380) += yoga-tab2-pro-1380-fastcharger.o > -lenovo-target-$(CONFIG_LENOVO_WMI_CAMERA) += wmi-camera.o > -lenovo-target-$(CONFIG_LENOVO_WMI_CAPDATA) += wmi-capdata.o > -lenovo-target-$(CONFIG_LENOVO_WMI_EVENTS) += wmi-events.o > -lenovo-target-$(CONFIG_LENOVO_WMI_HELPERS) += wmi-helpers.o > -lenovo-target-$(CONFIG_LENOVO_WMI_GAMEZONE) += wmi-gamezone.o > -lenovo-target-$(CONFIG_LENOVO_WMI_TUNING) += wmi-other.o > > # Add 'lenovo' prefix to each module listed in lenovo-target-* > define LENOVO_OBJ_TARGET > -- > 2.56.1 Looks good to me. Will the MAINTAINERS file need updating? Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca> Mark ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH 1/3] platform: lenovo: move the architecture independent WMI drivers out of x86 2026-11-15 21:50 ` Mark Pearson @ 2026-11-16 4:42 ` David Cemin 2026-11-16 16:59 ` Mark Pearson 2026-11-17 2:27 ` Jackie Dong 1 sibling, 1 reply; 27+ messages in thread From: David Cemin @ 2026-11-16 4:42 UTC (permalink / raw) To: Mark Pearson Cc: Hans de Goede, Ilpo Jarvinen, Armin Wolf, Derek J. Clark, Jackie Dong, Ike Panhc, platform-driver-x86, linux-kernel, Lucas De Marchi Hi Mark, Thanks for the review. Patch 1 moves the MAINTAINERS paths for the moved files and adds the new entry; I will double check the entries for the files you listed in v2. Happy to see think-lmi follow once your tlmi series is out. Thanks, David ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH 1/3] platform: lenovo: move the architecture independent WMI drivers out of x86 2026-11-16 4:42 ` David Cemin @ 2026-11-16 16:59 ` Mark Pearson 0 siblings, 0 replies; 27+ messages in thread From: Mark Pearson @ 2026-11-16 16:59 UTC (permalink / raw) To: David Cemin Cc: Hans de Goede, Ilpo Järvinen, Armin Wolf, Derek J . Clark, Jackie Dong, Ike Panhc, platform-driver-x86, linux-kernel, Lucas De Marchi On Sun, Nov 15, 2026, at 11:42 PM, David Cemin wrote: > Hi Mark, > > Thanks for the review. Patch 1 moves the MAINTAINERS paths for the moved > files and adds the new entry; I will double check the entries for the > files you listed in v2. Happy to see think-lmi follow once your tlmi > series is out. > Doh - my apologies. Not sure how I missed that. Thanks Mark ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH 1/3] platform: lenovo: move the architecture independent WMI drivers out of x86 2026-11-15 21:50 ` Mark Pearson 2026-11-16 4:42 ` David Cemin @ 2026-11-17 2:27 ` Jackie Dong 1 sibling, 0 replies; 27+ messages in thread From: Jackie Dong @ 2026-11-17 2:27 UTC (permalink / raw) To: Mark Pearson, David Cemin, Hans de Goede, Ilpo Järvinen, Armin Wolf Cc: Derek J . Clark, Ike Panhc, platform-driver-x86, linux-kernel, ldemarchi On Sun, 2026-11-15 at 16:50 -0500, Mark Pearson wrote: > > > On Fri, Nov 13, 2026, at 5:27 PM, David Cemin wrote: > > The Lenovo WMI drivers (events, helpers, capability data, GameZone, > > Other Mode, hotkey utilities and camera button) contain no x86 > > specific > > code: they talk to firmware through the ACPI-WMI core only. They > > live > > under drivers/platform/x86 because that is where Lenovo drivers > > were > > collected, and X86_PLATFORM_DEVICES keeps them off every other > > architecture. > > > > Lenovo now ships ACPI based arm64 laptops whose firmware exposes > > the > > same WMI GUIDs (the Fn key events, the mic mute LED method, > > GameZone and > > Other Mode). Give these drivers an architecture independent home, > > drivers/platform/lenovo, following the layout of > > drivers/platform/surface > > which exists for the same reason, so they can be built wherever the > > WMI > > core is available. ideapad-laptop, thinkpad_acpi, think-lmi, > > yogabook and > > the Yoga Tablet drivers stay under x86: they depend on i8042, port > > I/O or > > x86 only ACPI devices. > > > > Pure code motion: the files, their Kconfig entries and the module > > naming > > scheme are unchanged. MAINTAINERS entries are updated for the new > > paths. > > > > Signed-off-by: David Cemin <dcemin@nvidia.com> > > --- > > MAINTAINERS | 3 +- > > drivers/platform/Kconfig | 2 + > > drivers/platform/Makefile | 1 + > > drivers/platform/lenovo/Kconfig | 87 > > +++++++++++++++++++ > > drivers/platform/lenovo/Makefile | 22 +++++ > > .../platform/{x86 => }/lenovo/wmi-camera.c | 0 > > .../platform/{x86 => }/lenovo/wmi-capdata.c | 0 > > .../platform/{x86 => }/lenovo/wmi-capdata.h | 0 > > .../platform/{x86 => }/lenovo/wmi-events.c | 0 > > .../platform/{x86 => }/lenovo/wmi-events.h | 0 > > .../platform/{x86 => }/lenovo/wmi-gamezone.c | 0 > > .../platform/{x86 => }/lenovo/wmi-helpers.c | 0 > > .../platform/{x86 => }/lenovo/wmi-helpers.h | 0 > > .../{x86 => }/lenovo/wmi-hotkey-utilities.c | 0 > > drivers/platform/{x86 => }/lenovo/wmi-other.c | 0 > > drivers/platform/x86/lenovo/Kconfig | 67 -------------- > > drivers/platform/x86/lenovo/Makefile | 7 -- > > 17 files changed, 114 insertions(+), 75 deletions(-) > > create mode 100644 drivers/platform/lenovo/Kconfig > > create mode 100644 drivers/platform/lenovo/Makefile > > rename drivers/platform/{x86 => }/lenovo/wmi-camera.c (100%) > > rename drivers/platform/{x86 => }/lenovo/wmi-capdata.c (100%) > > rename drivers/platform/{x86 => }/lenovo/wmi-capdata.h (100%) > > rename drivers/platform/{x86 => }/lenovo/wmi-events.c (100%) > > rename drivers/platform/{x86 => }/lenovo/wmi-events.h (100%) > > rename drivers/platform/{x86 => }/lenovo/wmi-gamezone.c (100%) > > rename drivers/platform/{x86 => }/lenovo/wmi-helpers.c (100%) > > rename drivers/platform/{x86 => }/lenovo/wmi-helpers.h (100%) > > rename drivers/platform/{x86 => }/lenovo/wmi-hotkey-utilities.c > > (100%) > > rename drivers/platform/{x86 => }/lenovo/wmi-other.c (100%) > > > > diff --git a/MAINTAINERS b/MAINTAINERS > > index 056408bc086e..3b0ad5a3debe 100644 > > --- a/MAINTAINERS > > +++ b/MAINTAINERS > > @@ -15170,13 +15170,14 @@ > > L: platform-driver-x86@vger.kernel.org > > S: Maintained > > F: Documentation/wmi/devices/lenovo-wmi-gamezone.rst > > F: Documentation/wmi/devices/lenovo-wmi-other.rst > > +F: drivers/platform/lenovo/ > > F: drivers/platform/x86/lenovo/* > > > > LENOVO WMI HOTKEY UTILITIES DRIVER > > M: Jackie Dong <xy-jackie@139.com> > > L: platform-driver-x86@vger.kernel.org > > S: Maintained > > -F: drivers/platform/x86/lenovo/wmi-hotkey-utilities.c > > +F: drivers/platform/lenovo/wmi-hotkey-utilities.c > > > > LENOVO HID drivers > > M: Derek J. Clark <derekjohn.clark@gmail.com> > > diff --git a/drivers/platform/Kconfig b/drivers/platform/Kconfig > > index 312788f249c9..80b2b83b69e5 100644 > > --- a/drivers/platform/Kconfig > > +++ b/drivers/platform/Kconfig > > @@ -15,6 +15,8 @@ source "drivers/platform/olpc/Kconfig" > > > > source "drivers/platform/surface/Kconfig" > > > > +source "drivers/platform/lenovo/Kconfig" > > + > > source "drivers/platform/x86/Kconfig" > > > > source "drivers/platform/arm64/Kconfig" > > diff --git a/drivers/platform/Makefile b/drivers/platform/Makefile > > index fa322e7f8716..0144f88ff6db 100644 > > --- a/drivers/platform/Makefile > > +++ b/drivers/platform/Makefile > > @@ -12,6 +12,7 @@ obj-$(CONFIG_GOLDFISH) += > > goldfish/ > > obj-$(CONFIG_CHROME_PLATFORMS) += chrome/ > > obj-$(CONFIG_CZNIC_PLATFORMS) += cznic/ > > obj-$(CONFIG_SURFACE_PLATFORMS) += surface/ > > +obj-$(CONFIG_LENOVO_PLATFORMS) += lenovo/ > > obj-$(CONFIG_ARM64_PLATFORM_DEVICES) += arm64/ > > obj-$(CONFIG_BCM2835_VCHIQ) += raspberrypi/ > > obj-$(CONFIG_ACPI_WMI) += wmi/ > > diff --git a/drivers/platform/lenovo/Kconfig > > b/drivers/platform/lenovo/Kconfig > > new file mode 100644 > > index 000000000000..8222322ca671 > > --- /dev/null > > +++ b/drivers/platform/lenovo/Kconfig > > @@ -0,0 +1,87 @@ > > +# SPDX-License-Identifier: GPL-2.0-only > > +# > > +# Lenovo Platform-Specific Drivers > > +# > > + > > +menuconfig LENOVO_PLATFORMS > > + bool "Lenovo Platform-Specific Device Drivers" > > + depends on ARM64 || X86 || COMPILE_TEST > > + default y if ARM64 || X86 > > + help > > + Say Y here to get to see options for platform-specific > > device > > drivers > > + for Lenovo devices that do not depend on the CPU > > architecture, such > > + as the ACPI-WMI based drivers used on both x86 and arm64 > > laptops. > > + This option alone does not add any kernel code. > > + > > + If you say N, all options in this submenu will be > > skipped and > > disabled. > > + > > +if LENOVO_PLATFORMS > > + > > +config LENOVO_WMI_HELPERS > > + tristate > > + depends on ACPI_WMI > > + > > +config LENOVO_WMI_EVENTS > > + tristate > > + depends on ACPI_WMI > > + > > +config LENOVO_WMI_CAPDATA > > + tristate > > + depends on ACPI_WMI > > + depends on LENOVO_WMI_HELPERS > > + > > +config LENOVO_WMI_HOTKEY_UTILITIES > > + tristate "Lenovo Hotkey Utility WMI extras driver" > > + depends on ACPI_WMI > > + select NEW_LEDS > > + select LEDS_CLASS > > + imply IDEAPAD_LAPTOP > > + help > > + This driver provides WMI support for Lenovo customized > > hotkeys > > function, > > + such as LED control for audio/mic mute event for > > Ideapad, YOGA, > > XiaoXin, > > + Gaming, ThinkBook and so on. > > + > > +config LENOVO_WMI_CAMERA > > + tristate "Lenovo WMI Camera Button driver" > > + depends on ACPI_WMI > > + depends on INPUT > > + help > > + This driver provides support for Lenovo camera button. > > The Camera > > + button is a GPIO device. This driver receives ACPI > > notifications > > when > > + the camera button is switched on/off. > > + > > + To compile this driver as a module, choose M here: the > > module > > + will be called lenovo-wmi-camera. > > + > > +config LENOVO_WMI_GAMEZONE > > + tristate "Lenovo GameZone WMI Driver" > > + depends on ACPI_WMI > > + depends on DMI > > + select ACPI_PLATFORM_PROFILE > > + select LENOVO_WMI_EVENTS > > + select LENOVO_WMI_HELPERS > > + help > > + Say Y here if you have a WMI aware Lenovo Legion device > > and would > > like to use the > > + platform-profile firmware interface to manage power > > usage. > > + > > + To compile this driver as a module, choose M here: the > > module will > > + be called lenovo-wmi-gamezone. > > + > > +config LENOVO_WMI_TUNING > > + tristate "Lenovo Other Mode WMI Driver" > > + depends on ACPI_WMI > > + depends on ACPI_BATTERY > > + select HWMON > > + select FW_ATTR_CLASS > > + select LENOVO_WMI_CAPDATA > > + select LENOVO_WMI_EVENTS > > + select LENOVO_WMI_HELPERS > > + help > > + Say Y here if you have a WMI aware Lenovo Legion device > > and would > > like to use the > > + firmware_attributes API to control various tunable > > settings > > typically exposed by > > + Lenovo software in Windows. > > + > > + To compile this driver as a module, choose M here: the > > module will > > + be called lenovo-wmi-other. > > + > > +endif # LENOVO_PLATFORMS > > diff --git a/drivers/platform/lenovo/Makefile > > b/drivers/platform/lenovo/Makefile > > new file mode 100644 > > index 000000000000..1cac115dd735 > > --- /dev/null > > +++ b/drivers/platform/lenovo/Makefile > > @@ -0,0 +1,22 @@ > > +# SPDX-License-Identifier: GPL-2.0 > > +# > > +# Makefile for linux/drivers/platform/lenovo > > +# Lenovo Platform Specific Drivers (architecture independent) > > +# > > + > > +lenovo-target-$(CONFIG_LENOVO_WMI_HELPERS) += wmi-helpers.o > > +lenovo-target-$(CONFIG_LENOVO_WMI_EVENTS) += wmi-events.o > > +lenovo-target-$(CONFIG_LENOVO_WMI_CAPDATA) += wmi-capdata.o > > +lenovo-target-$(CONFIG_LENOVO_WMI_HOTKEY_UTILITIES) += > > wmi-hotkey-utilities.o > > +lenovo-target-$(CONFIG_LENOVO_WMI_CAMERA) += wmi-camera.o > > +lenovo-target-$(CONFIG_LENOVO_WMI_GAMEZONE) += wmi-gamezone.o > > +lenovo-target-$(CONFIG_LENOVO_WMI_TUNING) += wmi-other.o > > + > > +# Add 'lenovo' prefix to each module listed in lenovo-target-* > > +define LENOVO_OBJ_TARGET > > +lenovo-$(1)-y := $(1).o > > +obj-$(2) += lenovo-$(1).o > > +endef > > + > > +$(foreach target, $(basename $(lenovo-target-y)), $(eval $(call > > LENOVO_OBJ_TARGET,$(target),y))) > > +$(foreach target, $(basename $(lenovo-target-m)), $(eval $(call > > LENOVO_OBJ_TARGET,$(target),m))) > > diff --git a/drivers/platform/x86/lenovo/wmi-camera.c > > b/drivers/platform/lenovo/wmi-camera.c > > similarity index 100% > > rename from drivers/platform/x86/lenovo/wmi-camera.c > > rename to drivers/platform/lenovo/wmi-camera.c > > diff --git a/drivers/platform/x86/lenovo/wmi-capdata.c > > b/drivers/platform/lenovo/wmi-capdata.c > > similarity index 100% > > rename from drivers/platform/x86/lenovo/wmi-capdata.c > > rename to drivers/platform/lenovo/wmi-capdata.c > > diff --git a/drivers/platform/x86/lenovo/wmi-capdata.h > > b/drivers/platform/lenovo/wmi-capdata.h > > similarity index 100% > > rename from drivers/platform/x86/lenovo/wmi-capdata.h > > rename to drivers/platform/lenovo/wmi-capdata.h > > diff --git a/drivers/platform/x86/lenovo/wmi-events.c > > b/drivers/platform/lenovo/wmi-events.c > > similarity index 100% > > rename from drivers/platform/x86/lenovo/wmi-events.c > > rename to drivers/platform/lenovo/wmi-events.c > > diff --git a/drivers/platform/x86/lenovo/wmi-events.h > > b/drivers/platform/lenovo/wmi-events.h > > similarity index 100% > > rename from drivers/platform/x86/lenovo/wmi-events.h > > rename to drivers/platform/lenovo/wmi-events.h > > diff --git a/drivers/platform/x86/lenovo/wmi-gamezone.c > > b/drivers/platform/lenovo/wmi-gamezone.c > > similarity index 100% > > rename from drivers/platform/x86/lenovo/wmi-gamezone.c > > rename to drivers/platform/lenovo/wmi-gamezone.c > > diff --git a/drivers/platform/x86/lenovo/wmi-helpers.c > > b/drivers/platform/lenovo/wmi-helpers.c > > similarity index 100% > > rename from drivers/platform/x86/lenovo/wmi-helpers.c > > rename to drivers/platform/lenovo/wmi-helpers.c > > diff --git a/drivers/platform/x86/lenovo/wmi-helpers.h > > b/drivers/platform/lenovo/wmi-helpers.h > > similarity index 100% > > rename from drivers/platform/x86/lenovo/wmi-helpers.h > > rename to drivers/platform/lenovo/wmi-helpers.h > > diff --git a/drivers/platform/x86/lenovo/wmi-hotkey-utilities.c > > b/drivers/platform/lenovo/wmi-hotkey-utilities.c > > similarity index 100% > > rename from drivers/platform/x86/lenovo/wmi-hotkey-utilities.c > > rename to drivers/platform/lenovo/wmi-hotkey-utilities.c > > diff --git a/drivers/platform/x86/lenovo/wmi-other.c > > b/drivers/platform/lenovo/wmi-other.c > > similarity index 100% > > rename from drivers/platform/x86/lenovo/wmi-other.c > > rename to drivers/platform/lenovo/wmi-other.c > > diff --git a/drivers/platform/x86/lenovo/Kconfig > > b/drivers/platform/x86/lenovo/Kconfig > > index 516594993073..36bcefb61805 100644 > > --- a/drivers/platform/x86/lenovo/Kconfig > > +++ b/drivers/platform/x86/lenovo/Kconfig > > @@ -20,29 +20,6 @@ config IDEAPAD_LAPTOP > > This is a driver for Lenovo IdeaPad netbooks contains > > drivers for > > rfkill switch, hotkey, fan control and backlight > > control. > > > > -config LENOVO_WMI_HOTKEY_UTILITIES > > - tristate "Lenovo Hotkey Utility WMI extras driver" > > - depends on ACPI_WMI > > - select NEW_LEDS > > - select LEDS_CLASS > > - imply IDEAPAD_LAPTOP > > - help > > - This driver provides WMI support for Lenovo customized > > hotkeys function, > > - such as LED control for audio/mic mute event for > > Ideapad, YOGA, XiaoXin, > > - Gaming, ThinkBook and so on. > > - > > -config LENOVO_WMI_CAMERA > > - tristate "Lenovo WMI Camera Button driver" > > - depends on ACPI_WMI > > - depends on INPUT > > - help > > - This driver provides support for Lenovo camera button. > > The Camera > > - button is a GPIO device. This driver receives ACPI > > notifications when > > - the camera button is switched on/off. > > - > > - To compile this driver as a module, choose M here: the > > module > > - will be called lenovo-wmi-camera. > > - > > config LENOVO_YB9_KBDOCK > > tristate "Lenovo Yoga Book 9 keyboard dock detection" > > depends on ACPI_WMI > > @@ -246,47 +223,3 @@ config YT2_1380 > > > > To compile this driver as a module, choose M here: the > > module will > > be called lenovo-yogabook. > > - > > -config LENOVO_WMI_CAPDATA > > - tristate > > - depends on ACPI_WMI > > - depends on LENOVO_WMI_HELPERS > > - > > -config LENOVO_WMI_EVENTS > > - tristate > > - depends on ACPI_WMI > > - > > -config LENOVO_WMI_HELPERS > > - tristate > > - depends on ACPI_WMI > > - > > -config LENOVO_WMI_GAMEZONE > > - tristate "Lenovo GameZone WMI Driver" > > - depends on ACPI_WMI > > - depends on DMI > > - select ACPI_PLATFORM_PROFILE > > - select LENOVO_WMI_EVENTS > > - select LENOVO_WMI_HELPERS > > - help > > - Say Y here if you have a WMI aware Lenovo Legion device > > and would > > like to use the > > - platform-profile firmware interface to manage power > > usage. > > - > > - To compile this driver as a module, choose M here: the > > module will > > - be called lenovo-wmi-gamezone. > > - > > -config LENOVO_WMI_TUNING > > - tristate "Lenovo Other Mode WMI Driver" > > - depends on ACPI_WMI > > - depends on ACPI_BATTERY > > - select HWMON > > - select FW_ATTR_CLASS > > - select LENOVO_WMI_CAPDATA > > - select LENOVO_WMI_EVENTS > > - select LENOVO_WMI_HELPERS > > - help > > - Say Y here if you have a WMI aware Lenovo Legion device > > and would > > like to use the > > - firmware_attributes API to control various tunable > > settings > > typically exposed by > > - Lenovo software in Windows. > > - > > - To compile this driver as a module, choose M here: the > > module will > > - be called lenovo-wmi-other. > > diff --git a/drivers/platform/x86/lenovo/Makefile > > b/drivers/platform/x86/lenovo/Makefile > > index 12816d8d5e24..758c36cedee8 100644 > > --- a/drivers/platform/x86/lenovo/Makefile > > +++ b/drivers/platform/x86/lenovo/Makefile > > @@ -7,17 +7,10 @@ obj-$(CONFIG_IDEAPAD_LAPTOP) += ideapad- > > laptop.o > > obj-$(CONFIG_THINKPAD_LMI) += think-lmi.o > > obj-$(CONFIG_THINKPAD_ACPI) += thinkpad_acpi.o > > > > -lenovo-target-$(CONFIG_LENOVO_WMI_HOTKEY_UTILITIES) += wmi- > > hotkey-utilities.o > > lenovo-target-$(CONFIG_LENOVO_YB9_KBDOCK) += yb9-kbdock.o > > lenovo-target-$(CONFIG_LENOVO_YMC) += ymc.o > > lenovo-target-$(CONFIG_YOGABOOK) += yogabook.o > > lenovo-target-$(CONFIG_YT2_1380) += yoga-tab2-pro-1380- > > fastcharger.o > > -lenovo-target-$(CONFIG_LENOVO_WMI_CAMERA) += wmi-camera.o > > -lenovo-target-$(CONFIG_LENOVO_WMI_CAPDATA) += wmi-capdata.o > > -lenovo-target-$(CONFIG_LENOVO_WMI_EVENTS) += wmi-events.o > > -lenovo-target-$(CONFIG_LENOVO_WMI_HELPERS) += wmi-helpers.o > > -lenovo-target-$(CONFIG_LENOVO_WMI_GAMEZONE) += wmi-gamezone.o > > -lenovo-target-$(CONFIG_LENOVO_WMI_TUNING) += wmi-other.o > > > > # Add 'lenovo' prefix to each module listed in lenovo-target-* > > define LENOVO_OBJ_TARGET > > -- > > 2.56.1 > > Looks good to me. > Will the MAINTAINERS file need updating? > > Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca> > Mark It's a good idea that the Lenovo WMI drivers codes are in one lenovo directory for different architecture. It's OK for me. Reviewed-by: Jackie Dong <xy-jackie@139.com> Jackie ^ permalink raw reply [flat|nested] 27+ messages in thread
* [RFC PATCH 2/3] platform: lenovo: add WMI hotkeys driver 2026-11-13 22:27 [RFC PATCH 0/3] platform: lenovo: architecture independent home for the Lenovo WMI drivers David Cemin 2026-11-13 22:27 ` [RFC PATCH 1/3] platform: lenovo: move the architecture independent WMI drivers out of x86 David Cemin @ 2026-11-13 22:27 ` David Cemin 2026-11-15 16:12 ` Armin Wolf ` (3 more replies) 2026-11-13 22:27 ` [RFC PATCH 3/3] platform/x86: ideapad-laptop: do not bind the WMI event devices without the VPC David Cemin ` (2 subsequent siblings) 4 siblings, 4 replies; 27+ messages in thread From: David Cemin @ 2026-11-13 22:27 UTC (permalink / raw) To: hansg, ilpo.jarvinen, W_Armin Cc: mpearson-lenovo, derekjohn.clark, xy-jackie, ikepanhc, platform-driver-x86, linux-kernel, ldemarchi Lenovo consumer laptops deliver their vendor specific Fn keys (microphone mute, airplane mode, performance mode, the Smart Key and Smart Connect keys) as WMI events on GUID 8FC0DE0C-B4E4-43FD-B0F3-8871711C1294 instead of keyboard usages. On x86, ideapad-laptop consumes these events, but it depends on i8042 and on the IdeaPad VPC ACPI device, neither of which exist on the ACPI based arm64 models. Add a small WMI driver that reports the same key codes through a sparse keymap, so desktops see the generic input events. The key map follows ideapad-laptop. One code seen on the Yoga 9 2-in-1 16 (arm64) is new: 0x48 for the Smart Connect key. Both drivers match the same GUID. The probe declines when the IdeaPad VPC device (VPC2004) is present, so machines handled by ideapad-laptop, including its Fn lock LED and DYTC performance mode handling, keep that driver. Signed-off-by: David Cemin <dcemin@nvidia.com> --- MAINTAINERS | 6 + drivers/platform/lenovo/Kconfig | 14 +++ drivers/platform/lenovo/Makefile | 1 + drivers/platform/lenovo/wmi-hotkeys.c | 151 ++++++++++++++++++++++++++ 4 files changed, 172 insertions(+) create mode 100644 drivers/platform/lenovo/wmi-hotkeys.c diff --git a/MAINTAINERS b/MAINTAINERS index 3b0ad5a3debe..207684aeaf69 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -15173,6 +15173,12 @@ F: Documentation/wmi/devices/lenovo-wmi-other.rst F: drivers/platform/lenovo/ F: drivers/platform/x86/lenovo/* +LENOVO WMI HOTKEYS DRIVER +M: David Cemin <dcemin@nvidia.com> +L: platform-driver-x86@vger.kernel.org +S: Maintained +F: drivers/platform/lenovo/wmi-hotkeys.c + LENOVO WMI HOTKEY UTILITIES DRIVER M: Jackie Dong <xy-jackie@139.com> L: platform-driver-x86@vger.kernel.org diff --git a/drivers/platform/lenovo/Kconfig b/drivers/platform/lenovo/Kconfig index 8222322ca671..ba4248d56e5f 100644 --- a/drivers/platform/lenovo/Kconfig +++ b/drivers/platform/lenovo/Kconfig @@ -41,6 +41,20 @@ config LENOVO_WMI_HOTKEY_UTILITIES such as LED control for audio/mic mute event for Ideapad, YOGA, XiaoXin, Gaming, ThinkBook and so on. +config LENOVO_WMI_HOTKEYS + tristate "Lenovo WMI hotkeys driver" + depends on ACPI_WMI + depends on INPUT + select INPUT_SPARSEKMAP + help + Say Y or M here to enable the vendor specific Fn keys (microphone + mute, airplane mode, performance mode, star key) on Lenovo laptops + that deliver them as WMI events and are not handled by the + ideapad-laptop driver, such as the ACPI based arm64 models. + + To compile this driver as a module, choose M here: the module will + be called lenovo-wmi-hotkeys. + config LENOVO_WMI_CAMERA tristate "Lenovo WMI Camera Button driver" depends on ACPI_WMI diff --git a/drivers/platform/lenovo/Makefile b/drivers/platform/lenovo/Makefile index 1cac115dd735..d3f5e3ac14c2 100644 --- a/drivers/platform/lenovo/Makefile +++ b/drivers/platform/lenovo/Makefile @@ -8,6 +8,7 @@ lenovo-target-$(CONFIG_LENOVO_WMI_HELPERS) += wmi-helpers.o lenovo-target-$(CONFIG_LENOVO_WMI_EVENTS) += wmi-events.o lenovo-target-$(CONFIG_LENOVO_WMI_CAPDATA) += wmi-capdata.o lenovo-target-$(CONFIG_LENOVO_WMI_HOTKEY_UTILITIES) += wmi-hotkey-utilities.o +lenovo-target-$(CONFIG_LENOVO_WMI_HOTKEYS) += wmi-hotkeys.o lenovo-target-$(CONFIG_LENOVO_WMI_CAMERA) += wmi-camera.o lenovo-target-$(CONFIG_LENOVO_WMI_GAMEZONE) += wmi-gamezone.o lenovo-target-$(CONFIG_LENOVO_WMI_TUNING) += wmi-other.o diff --git a/drivers/platform/lenovo/wmi-hotkeys.c b/drivers/platform/lenovo/wmi-hotkeys.c new file mode 100644 index 000000000000..fc18867d8144 --- /dev/null +++ b/drivers/platform/lenovo/wmi-hotkeys.c @@ -0,0 +1,151 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Lenovo WMI hotkey driver + * + * Lenovo consumer laptops deliver their vendor specific Fn keys (microphone + * mute, airplane mode, performance mode, the star key and others) as WMI + * events on GUID 8FC0DE0C-B4E4-43FD-B0F3-8871711C1294 instead of keyboard + * usages. On x86 ideapad-laptop consumes these events; that driver depends + * on i8042 and the IdeaPad VPC device, neither of which exist on the arm64 + * platforms. This driver consumes the same event and reports the keys the + * same way, so desktops see the usual generic key codes. + * + * The key codes follow the mapping used by ideapad-laptop. + */ + +#include <linux/acpi.h> +#include <linux/input.h> +#include <linux/input/sparse-keymap.h> +#include <linux/module.h> +#include <linux/wmi.h> + +#define LENOVO_FN_KEYS_WMI_GUID "8FC0DE0C-B4E4-43FD-B0F3-8871711C1294" + +static const struct key_entry lenovo_wmi_hotkeys_keymap[] = { + /* Customizable Lenovo Hotkey ("star" with 'S' inside) */ + { KE_KEY, 0x01, { KEY_FAVORITES } }, + /* Fn lock toggled on / off, firmware handles the LED */ + { KE_IGNORE, 0x02 }, + { KE_IGNORE, 0x03 }, + { KE_KEY, 0x04, { KEY_SELECTIVE_SCREENSHOT } }, + /* Lenovo Support */ + { KE_KEY, 0x07, { KEY_HELP } }, + { KE_KEY, 0x0a, { KEY_REFRESH_RATE_TOGGLE } }, + { KE_KEY, 0x0e, { KEY_PICKUP_PHONE } }, + { KE_KEY, 0x0f, { KEY_HANGUP_PHONE } }, + { KE_KEY, 0x10, { KEY_REFRESH_RATE_TOGGLE } }, + /* Sound profile switch */ + { KE_KEY, 0x12, { KEY_PROG2 } }, + /* Dark mode toggle */ + { KE_KEY, 0x13, { KEY_PROG1 } }, + /* Lenovo Support */ + { KE_KEY, 0x27, { KEY_HELP } }, + /* Lenovo Virtual Background application */ + { KE_KEY, 0x28, { KEY_PROG3 } }, + { KE_KEY, 0x29, { KEY_TOUCHPAD_TOGGLE } }, + { KE_KEY, 0x2a, { KEY_ROOT_MENU } }, + /* Shift + PrtSc */ + { KE_KEY, 0x2d, { KEY_SELECTIVE_SCREENSHOT } }, + /* Performance mode, Fn+Q */ + { KE_KEY, 0x3d, { KEY_PROG4 } }, + { KE_KEY, 0x3e, { KEY_MICMUTE } }, + { KE_KEY, 0x3f, { KEY_RFKILL } }, + /* + * Keyboard backlight level after Fn+Space, handled by the firmware: + * 0x40 off, 0x41 low, 0x42 high, 0x43 also seen + */ + { KE_IGNORE, 0x40 }, + { KE_IGNORE, 0x41 }, + { KE_IGNORE, 0x42 }, + { KE_IGNORE, 0x43 }, + /* Star, user assignable key */ + { KE_KEY, 0x44, { KEY_PROG1 } }, + /* Eye care */ + { KE_KEY, 0x45, { KEY_PROG3 } }, + /* Smart Connect, phone to PC link */ + { KE_KEY, 0x48, { KEY_PROG2 } }, + { KE_END }, +}; + +struct lenovo_wmi_hotkeys { + struct input_dev *input; +}; + +static int lenovo_wmi_hotkeys_probe(struct wmi_device *wdev, const void *context) +{ + struct lenovo_wmi_hotkeys *priv; + int ret; + + /* + * ideapad-laptop binds the same GUID and handles these events together + * with the IdeaPad VPC device (Fn lock LED, DYTC performance mode + * cycling). Leave those machines to it. + */ + if (acpi_dev_found("VPC2004")) { + dev_dbg(&wdev->dev, "IdeaPad VPC present, deferring to ideapad-laptop\n"); + return -ENODEV; + } + + priv = devm_kzalloc(&wdev->dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->input = devm_input_allocate_device(&wdev->dev); + if (!priv->input) + return -ENOMEM; + + priv->input->name = "Lenovo WMI hotkeys"; + priv->input->phys = "wmi/input0"; + priv->input->id.bustype = BUS_HOST; + priv->input->dev.parent = &wdev->dev; + + ret = sparse_keymap_setup(priv->input, lenovo_wmi_hotkeys_keymap, NULL); + if (ret) + return ret; + + ret = input_register_device(priv->input); + if (ret) + return ret; + + dev_set_drvdata(&wdev->dev, priv); + + return 0; +} + +static void lenovo_wmi_hotkeys_notify(struct wmi_device *wdev, union acpi_object *data) +{ + struct lenovo_wmi_hotkeys *priv = dev_get_drvdata(&wdev->dev); + u32 code; + + if (!data || data->type != ACPI_TYPE_INTEGER) { + dev_dbg(&wdev->dev, "event data is not an integer\n"); + return; + } + + code = data->integer.value; + dev_dbg(&wdev->dev, "hotkey event 0x%x\n", code); + + if (!sparse_keymap_report_event(priv->input, code, 1, true)) + dev_info_ratelimited(&wdev->dev, "unknown hotkey event 0x%x\n", code); +} + +static const struct wmi_device_id lenovo_wmi_hotkeys_id_table[] = { + { LENOVO_FN_KEYS_WMI_GUID, NULL }, + { } +}; +MODULE_DEVICE_TABLE(wmi, lenovo_wmi_hotkeys_id_table); + +static struct wmi_driver lenovo_wmi_hotkeys_driver = { + .driver = { + .name = "lenovo-wmi-hotkeys", + .probe_type = PROBE_PREFER_ASYNCHRONOUS, + }, + .id_table = lenovo_wmi_hotkeys_id_table, + .probe = lenovo_wmi_hotkeys_probe, + .notify = lenovo_wmi_hotkeys_notify, + .no_singleton = true, +}; +module_wmi_driver(lenovo_wmi_hotkeys_driver); + +MODULE_DESCRIPTION("Lenovo WMI hotkey driver"); +MODULE_LICENSE("GPL"); -- 2.56.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH 2/3] platform: lenovo: add WMI hotkeys driver 2026-11-13 22:27 ` [RFC PATCH 2/3] platform: lenovo: add WMI hotkeys driver David Cemin @ 2026-11-15 16:12 ` Armin Wolf 2026-11-16 4:42 ` David Cemin 2026-11-16 10:55 ` Marco Giunta ` (2 subsequent siblings) 3 siblings, 1 reply; 27+ messages in thread From: Armin Wolf @ 2026-11-15 16:12 UTC (permalink / raw) To: David Cemin, hansg, ilpo.jarvinen Cc: mpearson-lenovo, derekjohn.clark, xy-jackie, ikepanhc, platform-driver-x86, linux-kernel, ldemarchi Am 13.11.26 um 23:27 schrieb David Cemin: > Lenovo consumer laptops deliver their vendor specific Fn keys (microphone > mute, airplane mode, performance mode, the Smart Key and Smart Connect > keys) as WMI events on GUID 8FC0DE0C-B4E4-43FD-B0F3-8871711C1294 instead > of keyboard usages. On x86, ideapad-laptop consumes these events, but it > depends on i8042 and on the IdeaPad VPC ACPI device, neither of which > exist on the ACPI based arm64 models. Add a small WMI driver that reports > the same key codes through a sparse keymap, so desktops see the generic > input events. > > The key map follows ideapad-laptop. One code seen on the Yoga 9 2-in-1 > 16 (arm64) is new: 0x48 for the Smart Connect key. > > Both drivers match the same GUID. The probe declines when the IdeaPad > VPC device (VPC2004) is present, so machines handled by ideapad-laptop, > including its Fn lock LED and DYTC performance mode handling, keep that > driver. > > Signed-off-by: David Cemin <dcemin@nvidia.com> > --- > MAINTAINERS | 6 + > drivers/platform/lenovo/Kconfig | 14 +++ > drivers/platform/lenovo/Makefile | 1 + > drivers/platform/lenovo/wmi-hotkeys.c | 151 ++++++++++++++++++++++++++ > 4 files changed, 172 insertions(+) > create mode 100644 drivers/platform/lenovo/wmi-hotkeys.c > > diff --git a/MAINTAINERS b/MAINTAINERS > index 3b0ad5a3debe..207684aeaf69 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -15173,6 +15173,12 @@ F: Documentation/wmi/devices/lenovo-wmi-other.rst > F: drivers/platform/lenovo/ > F: drivers/platform/x86/lenovo/* > > +LENOVO WMI HOTKEYS DRIVER > +M: David Cemin <dcemin@nvidia.com> > +L: platform-driver-x86@vger.kernel.org > +S: Maintained > +F: drivers/platform/lenovo/wmi-hotkeys.c > + > LENOVO WMI HOTKEY UTILITIES DRIVER > M: Jackie Dong <xy-jackie@139.com> > L: platform-driver-x86@vger.kernel.org > diff --git a/drivers/platform/lenovo/Kconfig b/drivers/platform/lenovo/Kconfig > index 8222322ca671..ba4248d56e5f 100644 > --- a/drivers/platform/lenovo/Kconfig > +++ b/drivers/platform/lenovo/Kconfig > @@ -41,6 +41,20 @@ config LENOVO_WMI_HOTKEY_UTILITIES > such as LED control for audio/mic mute event for Ideapad, YOGA, XiaoXin, > Gaming, ThinkBook and so on. > > +config LENOVO_WMI_HOTKEYS > + tristate "Lenovo WMI hotkeys driver" > + depends on ACPI_WMI > + depends on INPUT > + select INPUT_SPARSEKMAP > + help > + Say Y or M here to enable the vendor specific Fn keys (microphone > + mute, airplane mode, performance mode, star key) on Lenovo laptops > + that deliver them as WMI events and are not handled by the > + ideapad-laptop driver, such as the ACPI based arm64 models. > + > + To compile this driver as a module, choose M here: the module will > + be called lenovo-wmi-hotkeys. > + > config LENOVO_WMI_CAMERA > tristate "Lenovo WMI Camera Button driver" > depends on ACPI_WMI > diff --git a/drivers/platform/lenovo/Makefile b/drivers/platform/lenovo/Makefile > index 1cac115dd735..d3f5e3ac14c2 100644 > --- a/drivers/platform/lenovo/Makefile > +++ b/drivers/platform/lenovo/Makefile > @@ -8,6 +8,7 @@ lenovo-target-$(CONFIG_LENOVO_WMI_HELPERS) += wmi-helpers.o > lenovo-target-$(CONFIG_LENOVO_WMI_EVENTS) += wmi-events.o > lenovo-target-$(CONFIG_LENOVO_WMI_CAPDATA) += wmi-capdata.o > lenovo-target-$(CONFIG_LENOVO_WMI_HOTKEY_UTILITIES) += wmi-hotkey-utilities.o > +lenovo-target-$(CONFIG_LENOVO_WMI_HOTKEYS) += wmi-hotkeys.o > lenovo-target-$(CONFIG_LENOVO_WMI_CAMERA) += wmi-camera.o > lenovo-target-$(CONFIG_LENOVO_WMI_GAMEZONE) += wmi-gamezone.o > lenovo-target-$(CONFIG_LENOVO_WMI_TUNING) += wmi-other.o > diff --git a/drivers/platform/lenovo/wmi-hotkeys.c b/drivers/platform/lenovo/wmi-hotkeys.c > new file mode 100644 > index 000000000000..fc18867d8144 > --- /dev/null > +++ b/drivers/platform/lenovo/wmi-hotkeys.c > @@ -0,0 +1,151 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Lenovo WMI hotkey driver > + * > + * Lenovo consumer laptops deliver their vendor specific Fn keys (microphone > + * mute, airplane mode, performance mode, the star key and others) as WMI > + * events on GUID 8FC0DE0C-B4E4-43FD-B0F3-8871711C1294 instead of keyboard > + * usages. On x86 ideapad-laptop consumes these events; that driver depends > + * on i8042 and the IdeaPad VPC device, neither of which exist on the arm64 > + * platforms. This driver consumes the same event and reports the keys the > + * same way, so desktops see the usual generic key codes. > + * > + * The key codes follow the mapping used by ideapad-laptop. > + */ > + > +#include <linux/acpi.h> > +#include <linux/input.h> > +#include <linux/input/sparse-keymap.h> > +#include <linux/module.h> > +#include <linux/wmi.h> > + > +#define LENOVO_FN_KEYS_WMI_GUID "8FC0DE0C-B4E4-43FD-B0F3-8871711C1294" > + > +static const struct key_entry lenovo_wmi_hotkeys_keymap[] = { > + /* Customizable Lenovo Hotkey ("star" with 'S' inside) */ > + { KE_KEY, 0x01, { KEY_FAVORITES } }, > + /* Fn lock toggled on / off, firmware handles the LED */ > + { KE_IGNORE, 0x02 }, > + { KE_IGNORE, 0x03 }, > + { KE_KEY, 0x04, { KEY_SELECTIVE_SCREENSHOT } }, > + /* Lenovo Support */ > + { KE_KEY, 0x07, { KEY_HELP } }, > + { KE_KEY, 0x0a, { KEY_REFRESH_RATE_TOGGLE } }, > + { KE_KEY, 0x0e, { KEY_PICKUP_PHONE } }, > + { KE_KEY, 0x0f, { KEY_HANGUP_PHONE } }, > + { KE_KEY, 0x10, { KEY_REFRESH_RATE_TOGGLE } }, > + /* Sound profile switch */ > + { KE_KEY, 0x12, { KEY_PROG2 } }, > + /* Dark mode toggle */ > + { KE_KEY, 0x13, { KEY_PROG1 } }, > + /* Lenovo Support */ > + { KE_KEY, 0x27, { KEY_HELP } }, > + /* Lenovo Virtual Background application */ > + { KE_KEY, 0x28, { KEY_PROG3 } }, > + { KE_KEY, 0x29, { KEY_TOUCHPAD_TOGGLE } }, > + { KE_KEY, 0x2a, { KEY_ROOT_MENU } }, > + /* Shift + PrtSc */ > + { KE_KEY, 0x2d, { KEY_SELECTIVE_SCREENSHOT } }, > + /* Performance mode, Fn+Q */ > + { KE_KEY, 0x3d, { KEY_PROG4 } }, Hi, please consider using KEY_PERFORMANCE instead. > + { KE_KEY, 0x3e, { KEY_MICMUTE } }, > + { KE_KEY, 0x3f, { KEY_RFKILL } }, > + /* > + * Keyboard backlight level after Fn+Space, handled by the firmware: > + * 0x40 off, 0x41 low, 0x42 high, 0x43 also seen > + */ > + { KE_IGNORE, 0x40 }, > + { KE_IGNORE, 0x41 }, > + { KE_IGNORE, 0x42 }, > + { KE_IGNORE, 0x43 }, > + /* Star, user assignable key */ > + { KE_KEY, 0x44, { KEY_PROG1 } }, > + /* Eye care */ > + { KE_KEY, 0x45, { KEY_PROG3 } }, > + /* Smart Connect, phone to PC link */ > + { KE_KEY, 0x48, { KEY_PROG2 } }, > + { KE_END }, > +}; > + > +struct lenovo_wmi_hotkeys { > + struct input_dev *input; > +}; > + > +static int lenovo_wmi_hotkeys_probe(struct wmi_device *wdev, const void *context) > +{ > + struct lenovo_wmi_hotkeys *priv; > + int ret; > + > + /* > + * ideapad-laptop binds the same GUID and handles these events together > + * with the IdeaPad VPC device (Fn lock LED, DYTC performance mode > + * cycling). Leave those machines to it. > + */ > + if (acpi_dev_found("VPC2004")) { > + dev_dbg(&wdev->dev, "IdeaPad VPC present, deferring to ideapad-laptop\n"); > + return -ENODEV; > + } Please use a notifier chain to allow the ideapad-laptop driver to consume WMI events. This avoids code duplication and ensures that the WMI event GUIDs are only handled by a single driver. You can use drivers/platform/x86/uniwill/uniwill-wmi.c as a inspiration, except that in this case the sparse keymap resides in this driver. > + > + priv = devm_kzalloc(&wdev->dev, sizeof(*priv), GFP_KERNEL); > + if (!priv) > + return -ENOMEM; Please use devm_kzalloc_obj() instead. > + > + priv->input = devm_input_allocate_device(&wdev->dev); > + if (!priv->input) > + return -ENOMEM; > + > + priv->input->name = "Lenovo WMI hotkeys"; > + priv->input->phys = "wmi/input0"; > + priv->input->id.bustype = BUS_HOST; > + priv->input->dev.parent = &wdev->dev; > + > + ret = sparse_keymap_setup(priv->input, lenovo_wmi_hotkeys_keymap, NULL); > + if (ret) > + return ret; > + > + ret = input_register_device(priv->input); > + if (ret) > + return ret; > + > + dev_set_drvdata(&wdev->dev, priv); Please set drvdata before registering the input device, otherwise a WMI event arriving between input_register_device() and dev_set_drvdata() will cause a kernel panic by dereferencing NULL. > + > + return 0; > +} > + > +static void lenovo_wmi_hotkeys_notify(struct wmi_device *wdev, union acpi_object *data) > +{ > + struct lenovo_wmi_hotkeys *priv = dev_get_drvdata(&wdev->dev); > + u32 code; > + > + if (!data || data->type != ACPI_TYPE_INTEGER) { > + dev_dbg(&wdev->dev, "event data is not an integer\n"); > + return; > + } > + > + code = data->integer.value; > + dev_dbg(&wdev->dev, "hotkey event 0x%x\n", code); > + > + if (!sparse_keymap_report_event(priv->input, code, 1, true)) > + dev_info_ratelimited(&wdev->dev, "unknown hotkey event 0x%x\n", code); > +} > + > +static const struct wmi_device_id lenovo_wmi_hotkeys_id_table[] = { > + { LENOVO_FN_KEYS_WMI_GUID, NULL }, What about the GUIDs for handling the Esc keys? > + { } > +}; > +MODULE_DEVICE_TABLE(wmi, lenovo_wmi_hotkeys_id_table); > + > +static struct wmi_driver lenovo_wmi_hotkeys_driver = { > + .driver = { > + .name = "lenovo-wmi-hotkeys", > + .probe_type = PROBE_PREFER_ASYNCHRONOUS, > + }, > + .id_table = lenovo_wmi_hotkeys_id_table, > + .probe = lenovo_wmi_hotkeys_probe, > + .notify = lenovo_wmi_hotkeys_notify, Please use .notify_new instead. This will also allow you to get rid of any ACPI-related code in this driver. What is the WMI data type of the event payload? Thanks, Armin Wolf > + .no_singleton = true, > +}; > +module_wmi_driver(lenovo_wmi_hotkeys_driver); > + > +MODULE_DESCRIPTION("Lenovo WMI hotkey driver"); > +MODULE_LICENSE("GPL"); ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH 2/3] platform: lenovo: add WMI hotkeys driver 2026-11-15 16:12 ` Armin Wolf @ 2026-11-16 4:42 ` David Cemin 2026-11-17 1:39 ` Armin Wolf 0 siblings, 1 reply; 27+ messages in thread From: David Cemin @ 2026-11-16 4:42 UTC (permalink / raw) To: Armin Wolf Cc: Hans de Goede, Ilpo Jarvinen, Mark Pearson, Derek J. Clark, Jackie Dong, Ike Panhc, platform-driver-x86, linux-kernel, Lucas De Marchi Hi Armin, Thanks, all taken for v2: KEY_PERFORMANCE for 0x3D, devm_kzalloc_obj, drvdata set before registering the input device, notify_new, and the events delivered through the lenovo-wmi-events notifier chain with NOTIFY_STOP honoured. The payload is a single integer, the key code, so with notify_new it is a 4 byte little endian value. On the Esc GUIDs: the arm64 firmware here exposes 8FC0DE0C for the Fn keys but neither 26CAB2E5 nor 56322276, so the new driver claims only the Fn key GUID and the Esc GUIDs stay with ideapad-laptop. Thanks, David ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH 2/3] platform: lenovo: add WMI hotkeys driver 2026-11-16 4:42 ` David Cemin @ 2026-11-17 1:39 ` Armin Wolf 0 siblings, 0 replies; 27+ messages in thread From: Armin Wolf @ 2026-11-17 1:39 UTC (permalink / raw) To: David Cemin Cc: Hans de Goede, Ilpo Jarvinen, Mark Pearson, Derek J. Clark, Jackie Dong, Ike Panhc, platform-driver-x86, linux-kernel, Lucas De Marchi Am 16.11.26 um 05:42 schrieb David Cemin: > Hi Armin, > > Thanks, all taken for v2: KEY_PERFORMANCE for 0x3D, devm_kzalloc_obj, > drvdata set before registering the input device, notify_new, and the > events delivered through the lenovo-wmi-events notifier chain with > NOTIFY_STOP honoured. The payload is a single integer, the key code, so > with notify_new it is a 4 byte little endian value. > > On the Esc GUIDs: the arm64 firmware here exposes 8FC0DE0C for the Fn > keys but neither 26CAB2E5 nor 56322276, so the new driver claims only > the Fn key GUID and the Esc GUIDs stay with ideapad-laptop. > > Thanks, > David Hi, i think that we should still move the handling of the Esc GUIDs into the new event driver, so that ideapad-laptop is free from any WMI event drivers. Thanks, Armin Wolf ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH 2/3] platform: lenovo: add WMI hotkeys driver 2026-11-13 22:27 ` [RFC PATCH 2/3] platform: lenovo: add WMI hotkeys driver David Cemin 2026-11-15 16:12 ` Armin Wolf @ 2026-11-16 10:55 ` Marco Giunta 2026-11-17 3:27 ` Jackie Dong 2026-11-19 2:29 ` David Cemin 3 siblings, 0 replies; 27+ messages in thread From: Marco Giunta @ 2026-11-16 10:55 UTC (permalink / raw) To: dcemin Cc: W_Armin, derekjohn.clark, hansg, ikepanhc, ilpo.jarvinen, ldemarchi, linux-kernel, mpearson-lenovo, platform-driver-x86, xy-jackie, marco_giunta Hi David, just a quick comment that this: > The key map follows ideapad-laptop. One code seen on the Yoga 9 2-in-1 > 16 (arm64) is new: 0x48 for the Smart Connect key. isn't quite right; the ideapad-laptop driver has covered the smart connect key/event 0x48 since commit ccc8c8481c1f ("platform/x86: ideapad-laptop: Map Smart Connect hotkey to KEY_LINK_PHONE"), which is in 7.4-rc1+. > + /* Smart Connect, phone to PC link */ > + { KE_KEY, 0x48, { KEY_PROG2 } }, Similarly to that commit, I would suggest using KEY_LINK_PHONE here instead. Best regards, Marco ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH 2/3] platform: lenovo: add WMI hotkeys driver 2026-11-13 22:27 ` [RFC PATCH 2/3] platform: lenovo: add WMI hotkeys driver David Cemin 2026-11-15 16:12 ` Armin Wolf 2026-11-16 10:55 ` Marco Giunta @ 2026-11-17 3:27 ` Jackie Dong 2026-11-19 2:29 ` David Cemin 3 siblings, 0 replies; 27+ messages in thread From: Jackie Dong @ 2026-11-17 3:27 UTC (permalink / raw) To: David Cemin, hansg, ilpo.jarvinen, W_Armin Cc: mpearson-lenovo, derekjohn.clark, ikepanhc, platform-driver-x86, linux-kernel, ldemarchi On Fri, 2026-11-13 at 14:27 -0800, David Cemin wrote: > Lenovo consumer laptops deliver their vendor specific Fn keys > (microphone > mute, airplane mode, performance mode, the Smart Key and Smart > Connect > keys) as WMI events on GUID 8FC0DE0C-B4E4-43FD-B0F3-8871711C1294 > instead > of keyboard usages. On x86, ideapad-laptop consumes these events, but > it > depends on i8042 and on the IdeaPad VPC ACPI device, neither of which > exist on the ACPI based arm64 models. Add a small WMI driver that > reports > the same key codes through a sparse keymap, so desktops see the > generic > input events. > > The key map follows ideapad-laptop. One code seen on the Yoga 9 2-in- > 1 > 16 (arm64) is new: 0x48 for the Smart Connect key. > > Both drivers match the same GUID. The probe declines when the IdeaPad > VPC device (VPC2004) is present, so machines handled by ideapad- > laptop, > including its Fn lock LED and DYTC performance mode handling, keep > that > driver. > > Signed-off-by: David Cemin <dcemin@nvidia.com> > --- > MAINTAINERS | 6 + > drivers/platform/lenovo/Kconfig | 14 +++ > drivers/platform/lenovo/Makefile | 1 + > drivers/platform/lenovo/wmi-hotkeys.c | 151 > ++++++++++++++++++++++++++ > 4 files changed, 172 insertions(+) > create mode 100644 drivers/platform/lenovo/wmi-hotkeys.c > > diff --git a/MAINTAINERS b/MAINTAINERS > index 3b0ad5a3debe..207684aeaf69 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -15173,6 +15173,12 @@ F: Documentation/wmi/devices/lenovo- > wmi-other.rst > F: drivers/platform/lenovo/ > F: drivers/platform/x86/lenovo/* > > +LENOVO WMI HOTKEYS DRIVER > +M: David Cemin <dcemin@nvidia.com> > +L: platform-driver-x86@vger.kernel.org > +S: Maintained > +F: drivers/platform/lenovo/wmi-hotkeys.c > + > LENOVO WMI HOTKEY UTILITIES DRIVER > M: Jackie Dong <xy-jackie@139.com> > L: platform-driver-x86@vger.kernel.org > diff --git a/drivers/platform/lenovo/Kconfig > b/drivers/platform/lenovo/Kconfig > index 8222322ca671..ba4248d56e5f 100644 > --- a/drivers/platform/lenovo/Kconfig > +++ b/drivers/platform/lenovo/Kconfig > @@ -41,6 +41,20 @@ config LENOVO_WMI_HOTKEY_UTILITIES > such as LED control for audio/mic mute event for Ideapad, > YOGA, XiaoXin, > Gaming, ThinkBook and so on. > > +config LENOVO_WMI_HOTKEYS > + tristate "Lenovo WMI hotkeys driver" > + depends on ACPI_WMI > + depends on INPUT > + select INPUT_SPARSEKMAP > + help > + Say Y or M here to enable the vendor specific Fn keys > (microphone > + mute, airplane mode, performance mode, star key) on Lenovo > laptops > + that deliver them as WMI events and are not handled by the > + ideapad-laptop driver, such as the ACPI based arm64 > models. > + > + To compile this driver as a module, choose M here: the > module will > + be called lenovo-wmi-hotkeys. > + > config LENOVO_WMI_CAMERA > tristate "Lenovo WMI Camera Button driver" > depends on ACPI_WMI > diff --git a/drivers/platform/lenovo/Makefile > b/drivers/platform/lenovo/Makefile > index 1cac115dd735..d3f5e3ac14c2 100644 > --- a/drivers/platform/lenovo/Makefile > +++ b/drivers/platform/lenovo/Makefile > @@ -8,6 +8,7 @@ lenovo-target-$(CONFIG_LENOVO_WMI_HELPERS) += > wmi-helpers.o > lenovo-target-$(CONFIG_LENOVO_WMI_EVENTS) += wmi-events.o > lenovo-target-$(CONFIG_LENOVO_WMI_CAPDATA) += wmi-capdata.o > lenovo-target-$(CONFIG_LENOVO_WMI_HOTKEY_UTILITIES) += wmi- > hotkey-utilities.o > +lenovo-target-$(CONFIG_LENOVO_WMI_HOTKEYS) += wmi-hotkeys.o > lenovo-target-$(CONFIG_LENOVO_WMI_CAMERA) += wmi-camera.o > lenovo-target-$(CONFIG_LENOVO_WMI_GAMEZONE) += wmi-gamezone.o > lenovo-target-$(CONFIG_LENOVO_WMI_TUNING) += wmi-other.o > diff --git a/drivers/platform/lenovo/wmi-hotkeys.c > b/drivers/platform/lenovo/wmi-hotkeys.c > new file mode 100644 > index 000000000000..fc18867d8144 > --- /dev/null > +++ b/drivers/platform/lenovo/wmi-hotkeys.c > @@ -0,0 +1,151 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Lenovo WMI hotkey driver > + * > + * Lenovo consumer laptops deliver their vendor specific Fn keys > (microphone > + * mute, airplane mode, performance mode, the star key and others) > as WMI > + * events on GUID 8FC0DE0C-B4E4-43FD-B0F3-8871711C1294 instead of > keyboard > + * usages. On x86 ideapad-laptop consumes these events; that driver > depends > + * on i8042 and the IdeaPad VPC device, neither of which exist on > the arm64 > + * platforms. This driver consumes the same event and reports the > keys the > + * same way, so desktops see the usual generic key codes. > + * > + * The key codes follow the mapping used by ideapad-laptop. > + */ > + > +#include <linux/acpi.h> > +#include <linux/input.h> > +#include <linux/input/sparse-keymap.h> > +#include <linux/module.h> > +#include <linux/wmi.h> > + > +#define LENOVO_FN_KEYS_WMI_GUID "8FC0DE0C-B4E4-43FD-B0F3- > 8871711C1294" > + > +static const struct key_entry lenovo_wmi_hotkeys_keymap[] = { > + /* Customizable Lenovo Hotkey ("star" with 'S' inside) */ > + { KE_KEY, 0x01, { KEY_FAVORITES } }, > + /* Fn lock toggled on / off, firmware handles the LED */ > + { KE_IGNORE, 0x02 }, > + { KE_IGNORE, 0x03 }, > + { KE_KEY, 0x04, { KEY_SELECTIVE_SCREENSHOT } }, > + /* Lenovo Support */ > + { KE_KEY, 0x07, { KEY_HELP } }, > + { KE_KEY, 0x0a, { KEY_REFRESH_RATE_TOGGLE } }, > + { KE_KEY, 0x0e, { KEY_PICKUP_PHONE } }, > + { KE_KEY, 0x0f, { KEY_HANGUP_PHONE } }, > + { KE_KEY, 0x10, { KEY_REFRESH_RATE_TOGGLE } }, > + /* Sound profile switch */ > + { KE_KEY, 0x12, { KEY_PROG2 } }, > + /* Dark mode toggle */ > + { KE_KEY, 0x13, { KEY_PROG1 } }, > + /* Lenovo Support */ > + { KE_KEY, 0x27, { KEY_HELP } }, > + /* Lenovo Virtual Background application */ > + { KE_KEY, 0x28, { KEY_PROG3 } }, > + { KE_KEY, 0x29, { KEY_TOUCHPAD_TOGGLE } }, > + { KE_KEY, 0x2a, { KEY_ROOT_MENU } }, > + /* Shift + PrtSc */ > + { KE_KEY, 0x2d, { KEY_SELECTIVE_SCREENSHOT } }, > + /* Performance mode, Fn+Q */ > + { KE_KEY, 0x3d, { KEY_PROG4 } }, > + { KE_KEY, 0x3e, { KEY_MICMUTE } }, > + { KE_KEY, 0x3f, { KEY_RFKILL } }, > + /* > + * Keyboard backlight level after Fn+Space, handled by the > firmware: > + * 0x40 off, 0x41 low, 0x42 high, 0x43 also seen > + */ > + { KE_IGNORE, 0x40 }, > + { KE_IGNORE, 0x41 }, > + { KE_IGNORE, 0x42 }, > + { KE_IGNORE, 0x43 }, > + /* Star, user assignable key */ > + { KE_KEY, 0x44, { KEY_PROG1 } }, > + /* Eye care */ > + { KE_KEY, 0x45, { KEY_PROG3 } }, > + /* Smart Connect, phone to PC link */ > + { KE_KEY, 0x48, { KEY_PROG2 } }, > + { KE_END }, > +}; > + > +struct lenovo_wmi_hotkeys { > + struct input_dev *input; > +}; > + > +static int lenovo_wmi_hotkeys_probe(struct wmi_device *wdev, const > void *context) > +{ > + struct lenovo_wmi_hotkeys *priv; > + int ret; > + > + /* > + * ideapad-laptop binds the same GUID and handles these > events together > + * with the IdeaPad VPC device (Fn lock LED, DYTC > performance mode > + * cycling). Leave those machines to it. > + */ > + if (acpi_dev_found("VPC2004")) { > + dev_dbg(&wdev->dev, "IdeaPad VPC present, deferring > to ideapad-laptop\n"); > + return -ENODEV; > + } > + > + priv = devm_kzalloc(&wdev->dev, sizeof(*priv), GFP_KERNEL); > + if (!priv) > + return -ENOMEM; > + > + priv->input = devm_input_allocate_device(&wdev->dev); > + if (!priv->input) > + return -ENOMEM; > + > + priv->input->name = "Lenovo WMI hotkeys"; > + priv->input->phys = "wmi/input0"; > + priv->input->id.bustype = BUS_HOST; > + priv->input->dev.parent = &wdev->dev; > + > + ret = sparse_keymap_setup(priv->input, > lenovo_wmi_hotkeys_keymap, NULL); > + if (ret) > + return ret; > + > + ret = input_register_device(priv->input); > + if (ret) > + return ret; > + > + dev_set_drvdata(&wdev->dev, priv); > + > + return 0; > +} > + > +static void lenovo_wmi_hotkeys_notify(struct wmi_device *wdev, union > acpi_object *data) > +{ > + struct lenovo_wmi_hotkeys *priv = dev_get_drvdata(&wdev- > >dev); > + u32 code; > + > + if (!data || data->type != ACPI_TYPE_INTEGER) { > + dev_dbg(&wdev->dev, "event data is not an > integer\n"); > + return; > + } > + > + code = data->integer.value; > + dev_dbg(&wdev->dev, "hotkey event 0x%x\n", code); > + > + if (!sparse_keymap_report_event(priv->input, code, 1, true)) > + dev_info_ratelimited(&wdev->dev, "unknown hotkey > event 0x%x\n", code); > +} > + > +static const struct wmi_device_id lenovo_wmi_hotkeys_id_table[] = { > + { LENOVO_FN_KEYS_WMI_GUID, NULL }, > + { } > +}; > +MODULE_DEVICE_TABLE(wmi, lenovo_wmi_hotkeys_id_table); > + > +static struct wmi_driver lenovo_wmi_hotkeys_driver = { > + .driver = { > + .name = "lenovo-wmi-hotkeys", > + .probe_type = PROBE_PREFER_ASYNCHRONOUS, > + }, > + .id_table = lenovo_wmi_hotkeys_id_table, > + .probe = lenovo_wmi_hotkeys_probe, > + .notify = lenovo_wmi_hotkeys_notify, > + .no_singleton = true, > +}; > +module_wmi_driver(lenovo_wmi_hotkeys_driver); > + > +MODULE_DESCRIPTION("Lenovo WMI hotkey driver"); > +MODULE_LICENSE("GPL"); Hi David, This wmi-hotkeys.c is for suspecific Fn keys(microphone mute, airplane mode, performance mode, the star key and others) with WMI and wmi- hotkey-utilities.c is the same target. Now the two file names are similar and easy to confuse for developers and maintainer. Would you merge them into one file? If yes, developers can support Lenovo product other hotkeys and new functions by wmi in one file in future. Jackie Dong ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH 2/3] platform: lenovo: add WMI hotkeys driver 2026-11-13 22:27 ` [RFC PATCH 2/3] platform: lenovo: add WMI hotkeys driver David Cemin ` (2 preceding siblings ...) 2026-11-17 3:27 ` Jackie Dong @ 2026-11-19 2:29 ` David Cemin 3 siblings, 0 replies; 27+ messages in thread From: David Cemin @ 2026-11-19 2:29 UTC (permalink / raw) To: xy-jackie Cc: hansg, ilpo.jarvinen, W_Armin, mpearson-lenovo, derekjohn.clark, ikepanhc, platform-driver-x86, linux-kernel, ldemarchi Hi Jackie, Thanks for the review and the Reviewed-by on patch 1. On merging wmi-hotkeys.c with wmi-hotkey-utilities.c: I kept them separate because they are different interfaces. wmi-hotkey-utilities.c drives the method GUID (microphone mute LED, Fn lock state), while wmi-hotkeys.c owns the event GUIDs and only turns events into input reports; the notifier chain is how the two sides meet, and ideapad-laptop uses it. If the maintainers prefer a single file the merge is mechanical and I am happy to do it in v3; otherwise I would keep the method and event sides apart, as the other Lenovo WMI drivers do. v2 is out as 20261119022719.3089229-1-dcemin@nvidia.com and includes your tag. Thanks, David ^ permalink raw reply [flat|nested] 27+ messages in thread
* [RFC PATCH 3/3] platform/x86: ideapad-laptop: do not bind the WMI event devices without the VPC 2026-11-13 22:27 [RFC PATCH 0/3] platform: lenovo: architecture independent home for the Lenovo WMI drivers David Cemin 2026-11-13 22:27 ` [RFC PATCH 1/3] platform: lenovo: move the architecture independent WMI drivers out of x86 David Cemin 2026-11-13 22:27 ` [RFC PATCH 2/3] platform: lenovo: add WMI hotkeys driver David Cemin @ 2026-11-13 22:27 ` David Cemin 2026-11-15 15:33 ` [RFC PATCH 0/3] platform: lenovo: architecture independent home for the Lenovo WMI drivers Hans de Goede 2026-11-19 2:27 ` [PATCH v2 " David Cemin 4 siblings, 0 replies; 27+ messages in thread From: David Cemin @ 2026-11-13 22:27 UTC (permalink / raw) To: hansg, ilpo.jarvinen, W_Armin Cc: mpearson-lenovo, derekjohn.clark, xy-jackie, ikepanhc, platform-driver-x86, linux-kernel, ldemarchi ideapad-laptop binds the Fn key and Esc WMI event GUIDs unconditionally, but ideapad_wmi_notify() only acts when the VPC platform driver has probed and set ideapad_shared. On machines that expose the WMI GUIDs without the IdeaPad VPC device (VPC2004) the driver claims the WMI device and then drops every event. Decline the WMI devices when there is no VPC2004, so the device stays free for a consumer that can report the events, such as the Lenovo WMI hotkeys driver. Signed-off-by: David Cemin <dcemin@nvidia.com> --- drivers/platform/x86/lenovo/ideapad-laptop.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/platform/x86/lenovo/ideapad-laptop.c b/drivers/platform/x86/lenovo/ideapad-laptop.c index 91a8d11c79c5..44ae248c5a4d 100644 --- a/drivers/platform/x86/lenovo/ideapad-laptop.c +++ b/drivers/platform/x86/lenovo/ideapad-laptop.c @@ -2278,6 +2278,14 @@ static int ideapad_wmi_probe(struct wmi_device *wdev, const void *context) { struct ideapad_wmi_private *wpriv; + /* + * The events are only delivered once the VPC platform driver is bound + * (ideapad_shared). Without the VPC device this driver can never + * report them, so leave the WMI device to another consumer. + */ + if (!acpi_dev_found("VPC2004")) + return -ENODEV; + wpriv = devm_kzalloc_obj(&wdev->dev, *wpriv); if (!wpriv) return -ENOMEM; -- 2.56.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH 0/3] platform: lenovo: architecture independent home for the Lenovo WMI drivers 2026-11-13 22:27 [RFC PATCH 0/3] platform: lenovo: architecture independent home for the Lenovo WMI drivers David Cemin ` (2 preceding siblings ...) 2026-11-13 22:27 ` [RFC PATCH 3/3] platform/x86: ideapad-laptop: do not bind the WMI event devices without the VPC David Cemin @ 2026-11-15 15:33 ` Hans de Goede 2026-11-15 16:02 ` Armin Wolf 2026-11-15 20:10 ` Hans de Goede 2026-11-19 2:27 ` [PATCH v2 " David Cemin 4 siblings, 2 replies; 27+ messages in thread From: Hans de Goede @ 2026-11-15 15:33 UTC (permalink / raw) To: David Cemin, ilpo.jarvinen, W_Armin Cc: mpearson-lenovo, derekjohn.clark, xy-jackie, ikepanhc, platform-driver-x86, linux-kernel, ldemarchi <sorry for any double-send (first reply incomplete) Thunderbird has a new Ctrl+s send shortcut which I sometimes fat-finger when copy/pasting> Hi, On 13-Nov-26 23:27, David Cemin wrote: > Lenovo now ships ACPI based arm64 laptops whose firmware exposes the > same ACPI-WMI interfaces as the x86 IdeaPad and Legion machines: the Fn > key event GUID consumed by ideapad-laptop, the hotkey utility GUID used > for the microphone mute LED, and the GameZone, Other Mode and capability > data GUIDs behind the thermal operation modes. Since 884d53763d30 > ("platform/wmi: Remove dependency on CONFIG_X86") the ACPI-WMI core > builds on arm64, but the Lenovo WMI drivers still live under > drivers/platform/x86, which is gated by X86_PLATFORM_DEVICES, so none of > that code can be used where the firmware is. > > This series: > 1. moves the architecture independent Lenovo WMI drivers into a new > drivers/platform/lenovo directory, following drivers/platform/surface > which exists for the same reason (Surface ships x86 and arm64); > ideapad-laptop, thinkpad_acpi, think-lmi and the Yoga tablet drivers > stay under x86 because they need i8042, port I/O or x86 only devices; > 2. adds a small WMI hotkeys driver for the Fn key event GUID on machines> where ideapad-laptop cannot bind; > 3. makes ideapad-laptop's own WMI event driver decline the GUIDs when > the IdeaPad VPC device is absent, since it can never report events > there. > > Patch 2 was tested on a Lenovo Yoga 9 2-in-1 16 (arm64): microphone > mute, airplane mode, the Smart Key, the Smart Connect key and the Fn+Q > operation mode key all report input events. The same key set is dead on > a Lenovo Yoga Pro 9 (arm64) today and uses the same GUID. > Patches 1 and 3 are compile tested on x86_64 and arm64 (defconfig plus > all LENOVO_WMI options as modules). > > Two questions I would like the maintainers' view on before this goes > further: > > a. Is a vendor directory (drivers/platform/lenovo, like surface) the > right home, or should the architecture independent Lenovo WMI > drivers move under drivers/platform/wmi next to the core instead? I think that drivers/platform/lenovo makes sense since eventually we may want more then just WMI drivers, e.g. the thinkpad_acpi driver which actually sort of works on Qualcomm Snapdragon laptops when booting these with my experimental DT-ACPI hybrid mode patches: https://github.com/jwrdegoede/linux-sunxi/commits/acpi-dt-hybrid-v0.4/ > b. Should the Fn key event handling stay a separate small driver, or > be factored out of ideapad-laptop so x86 and arm64 share one path? > ideapad-laptop handles the event only when its VPC platform driver > is bound, and the arm64 machines expose none of the VPC interface > it is built on (no _CFG, VPCR/VPCW, DYTC or HALS/SALS), so making > it the single driver means gating most of its probe. Two smaller > options: lift ideapad-laptop's own Fn key wmi_driver and keymap > into this file and let ideapad-laptop register for the events it > still wants (Fn lock LED, DYTC cycle), or the hid-asus/asus-wmi > shape where a companion WMI module exports the event to a > subsystem driver. The keymap in patch 2 duplicates entries of > ideapad-laptop's table on purpose until that is decided. IIRC the ideapad-laptop driver is a bit of a mess atm, so factoring a common handling for the the Fn key events out of this and sharing that sounds like a nice cleanup. I see that patch 2/3 uses the new wmi-driver/-bus infra which is nice and clean. So maybe just keep your existing stand-alone driver for both x86_64 + arm64 and drop the WMI event handling from ideapad-laptop. I guess this may hit some problems where WMI event handlig is used in ideapad-laptops integrating with some VPC functionality. For that purpose I think that the new drivers/platform/lenovo/wmi-hotkeys.c could maybe expose some notifier and call that for events it does not handle itself and then ideapad-laptop can depend on some function to register a listener on that notifier (1) and register a notifier handler staying out of WMI handling itself. No idea if this is feasible / how clean the end result will be, just brainstorming and saying yes to doing some refactoring of the somewhat messy ideapad-laptop code. Note that https://github.com/systemd/systemd/blob/main/hwdb.d/60-keyboard.hwdb has some mappings for "Ideapad extra buttons" input devices (+ DMI match), so if any of the buttons remapped there end up under the new WMI driver then that should probably give its input device the same name, to make sure those mappings still apply. Regards, Hans 1) +Kconfig dep, which will also avoid regressions by wrong Kconfig > > Patch 2 declines to bind when the IdeaPad VPC device (VPC2004) is > present, so machines handled by ideapad-laptop keep it; patch 3 is the > mirror on the ideapad-laptop side. The new MAINTAINERS entry uses > platform-driver-x86, the list that already covers drivers/platform/arm64, > the ACPI-WMI core and the other Lenovo WMI drivers. > > > David Cemin (3): > platform: lenovo: move the architecture independent WMI drivers out of > x86 > platform: lenovo: add WMI hotkeys driver > platform/x86: ideapad-laptop: do not bind the WMI event devices > without the VPC > > MAINTAINERS | 9 +- > drivers/platform/Kconfig | 2 + > drivers/platform/Makefile | 1 + > drivers/platform/lenovo/Kconfig | 101 ++++++++++++ > drivers/platform/lenovo/Makefile | 23 +++ > .../platform/{x86 => }/lenovo/wmi-camera.c | 0 > .../platform/{x86 => }/lenovo/wmi-capdata.c | 0 > .../platform/{x86 => }/lenovo/wmi-capdata.h | 0 > .../platform/{x86 => }/lenovo/wmi-events.c | 0 > .../platform/{x86 => }/lenovo/wmi-events.h | 0 > .../platform/{x86 => }/lenovo/wmi-gamezone.c | 0 > .../platform/{x86 => }/lenovo/wmi-helpers.c | 0 > .../platform/{x86 => }/lenovo/wmi-helpers.h | 0 > .../{x86 => }/lenovo/wmi-hotkey-utilities.c | 0 > drivers/platform/lenovo/wmi-hotkeys.c | 151 ++++++++++++++++++ > drivers/platform/{x86 => }/lenovo/wmi-other.c | 0 > drivers/platform/x86/lenovo/Kconfig | 67 -------- > drivers/platform/x86/lenovo/Makefile | 7 - > drivers/platform/x86/lenovo/ideapad-laptop.c | 8 + > 19 files changed, 294 insertions(+), 75 deletions(-) > create mode 100644 drivers/platform/lenovo/Kconfig > create mode 100644 drivers/platform/lenovo/Makefile > rename drivers/platform/{x86 => }/lenovo/wmi-camera.c (100%) > rename drivers/platform/{x86 => }/lenovo/wmi-capdata.c (100%) > rename drivers/platform/{x86 => }/lenovo/wmi-capdata.h (100%) > rename drivers/platform/{x86 => }/lenovo/wmi-events.c (100%) > rename drivers/platform/{x86 => }/lenovo/wmi-events.h (100%) > rename drivers/platform/{x86 => }/lenovo/wmi-gamezone.c (100%) > rename drivers/platform/{x86 => }/lenovo/wmi-helpers.c (100%) > rename drivers/platform/{x86 => }/lenovo/wmi-helpers.h (100%) > rename drivers/platform/{x86 => }/lenovo/wmi-hotkey-utilities.c (100%) > create mode 100644 drivers/platform/lenovo/wmi-hotkeys.c > rename drivers/platform/{x86 => }/lenovo/wmi-other.c (100%) > > > base-commit: 2800868f63227c8237d70c41e70d441c919620d6 ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH 0/3] platform: lenovo: architecture independent home for the Lenovo WMI drivers 2026-11-15 15:33 ` [RFC PATCH 0/3] platform: lenovo: architecture independent home for the Lenovo WMI drivers Hans de Goede @ 2026-11-15 16:02 ` Armin Wolf 2026-11-15 18:02 ` Hans de Goede 2026-11-15 20:10 ` Hans de Goede 1 sibling, 1 reply; 27+ messages in thread From: Armin Wolf @ 2026-11-15 16:02 UTC (permalink / raw) To: Hans de Goede, David Cemin, ilpo.jarvinen Cc: mpearson-lenovo, derekjohn.clark, xy-jackie, ikepanhc, platform-driver-x86, linux-kernel, ldemarchi Am 15.11.26 um 16:33 schrieb Hans de Goede: > <sorry for any double-send (first reply incomplete) Thunderbird has a new Ctrl+s send > shortcut which I sometimes fat-finger when copy/pasting> > > Hi, > > On 13-Nov-26 23:27, David Cemin wrote: >> Lenovo now ships ACPI based arm64 laptops whose firmware exposes the >> same ACPI-WMI interfaces as the x86 IdeaPad and Legion machines: the Fn >> key event GUID consumed by ideapad-laptop, the hotkey utility GUID used >> for the microphone mute LED, and the GameZone, Other Mode and capability >> data GUIDs behind the thermal operation modes. Since 884d53763d30 >> ("platform/wmi: Remove dependency on CONFIG_X86") the ACPI-WMI core >> builds on arm64, but the Lenovo WMI drivers still live under >> drivers/platform/x86, which is gated by X86_PLATFORM_DEVICES, so none of >> that code can be used where the firmware is. >> >> This series: >> 1. moves the architecture independent Lenovo WMI drivers into a new >> drivers/platform/lenovo directory, following drivers/platform/surface >> which exists for the same reason (Surface ships x86 and arm64); >> ideapad-laptop, thinkpad_acpi, think-lmi and the Yoga tablet drivers >> stay under x86 because they need i8042, port I/O or x86 only devices; >> 2. adds a small WMI hotkeys driver for the Fn key event GUID on machines> where ideapad-laptop cannot bind; >> 3. makes ideapad-laptop's own WMI event driver decline the GUIDs when >> the IdeaPad VPC device is absent, since it can never report events >> there. >> >> Patch 2 was tested on a Lenovo Yoga 9 2-in-1 16 (arm64): microphone >> mute, airplane mode, the Smart Key, the Smart Connect key and the Fn+Q >> operation mode key all report input events. The same key set is dead on >> a Lenovo Yoga Pro 9 (arm64) today and uses the same GUID. >> Patches 1 and 3 are compile tested on x86_64 and arm64 (defconfig plus >> all LENOVO_WMI options as modules). >> >> Two questions I would like the maintainers' view on before this goes >> further: >> >> a. Is a vendor directory (drivers/platform/lenovo, like surface) the >> right home, or should the architecture independent Lenovo WMI >> drivers move under drivers/platform/wmi next to the core instead? > I think that drivers/platform/lenovo makes sense since eventually we may > want more then just WMI drivers, e.g. the thinkpad_acpi driver which > actually sort of works on Qualcomm Snapdragon laptops when booting these > with my experimental DT-ACPI hybrid mode patches: > > https://github.com/jwrdegoede/linux-sunxi/commits/acpi-dt-hybrid-v0.4/ Agreed, the drivers/platform/wmi directory should only contain core WMI infrastructure code and maybe some generic drivers like wmi-bmof. >> b. Should the Fn key event handling stay a separate small driver, or >> be factored out of ideapad-laptop so x86 and arm64 share one path? >> ideapad-laptop handles the event only when its VPC platform driver >> is bound, and the arm64 machines expose none of the VPC interface >> it is built on (no _CFG, VPCR/VPCW, DYTC or HALS/SALS), so making >> it the single driver means gating most of its probe. Two smaller >> options: lift ideapad-laptop's own Fn key wmi_driver and keymap >> into this file and let ideapad-laptop register for the events it >> still wants (Fn lock LED, DYTC cycle), or the hid-asus/asus-wmi >> shape where a companion WMI module exports the event to a >> subsystem driver. The keymap in patch 2 duplicates entries of >> ideapad-laptop's table on purpose until that is decided. > IIRC the ideapad-laptop driver is a bit of a mess atm, so factoring > a common handling for the the Fn key events out of this and sharing > that sounds like a nice cleanup. > > I see that patch 2/3 uses the new wmi-driver/-bus infra which is > nice and clean. > > So maybe just keep your existing stand-alone driver for both x86_64 + > arm64 and drop the WMI event handling from ideapad-laptop. > > I guess this may hit some problems where WMI event handlig is used > in ideapad-laptops integrating with some VPC functionality. > > For that purpose I think that the new > drivers/platform/lenovo/wmi-hotkeys.c could maybe expose some > notifier and call that for events it does not handle itself > and then ideapad-laptop can depend on some function to register > a listener on that notifier (1) and register a notifier handler > staying out of WMI handling itself. > > No idea if this is feasible / how clean the end result will be, > just brainstorming and saying yes to doing some refactoring of > the somewhat messy ideapad-laptop code. > > Note that https://github.com/systemd/systemd/blob/main/hwdb.d/60-keyboard.hwdb > has some mappings for "Ideapad extra buttons" input devices > (+ DMI match), so if any of the buttons remapped there end up > under the new WMI driver then that should probably give its > input device the same name, to make sure those mappings still > apply. > > Regards, > > Hans I like the idea of using a notifier to allow ideapad-laptop to consume WMI events from wmi-hotkeys. This would even allow ideapad-laptop to override the sparse keymap inside wmi-hotkeys by simply returning NOTIFY_STOP when "catching" an WMI event that has to be handled internally (like event 0x3D (Performance Key)). wmi-hotkeys can check for this return value and not emit a key code in such a case. Thanks, Armin Wolf > > 1) +Kconfig dep, which will also avoid regressions by wrong > Kconfig > >> Patch 2 declines to bind when the IdeaPad VPC device (VPC2004) is >> present, so machines handled by ideapad-laptop keep it; patch 3 is the >> mirror on the ideapad-laptop side. The new MAINTAINERS entry uses >> platform-driver-x86, the list that already covers drivers/platform/arm64, >> the ACPI-WMI core and the other Lenovo WMI drivers. >> >> >> David Cemin (3): >> platform: lenovo: move the architecture independent WMI drivers out of >> x86 >> platform: lenovo: add WMI hotkeys driver >> platform/x86: ideapad-laptop: do not bind the WMI event devices >> without the VPC >> >> MAINTAINERS | 9 +- >> drivers/platform/Kconfig | 2 + >> drivers/platform/Makefile | 1 + >> drivers/platform/lenovo/Kconfig | 101 ++++++++++++ >> drivers/platform/lenovo/Makefile | 23 +++ >> .../platform/{x86 => }/lenovo/wmi-camera.c | 0 >> .../platform/{x86 => }/lenovo/wmi-capdata.c | 0 >> .../platform/{x86 => }/lenovo/wmi-capdata.h | 0 >> .../platform/{x86 => }/lenovo/wmi-events.c | 0 >> .../platform/{x86 => }/lenovo/wmi-events.h | 0 >> .../platform/{x86 => }/lenovo/wmi-gamezone.c | 0 >> .../platform/{x86 => }/lenovo/wmi-helpers.c | 0 >> .../platform/{x86 => }/lenovo/wmi-helpers.h | 0 >> .../{x86 => }/lenovo/wmi-hotkey-utilities.c | 0 >> drivers/platform/lenovo/wmi-hotkeys.c | 151 ++++++++++++++++++ >> drivers/platform/{x86 => }/lenovo/wmi-other.c | 0 >> drivers/platform/x86/lenovo/Kconfig | 67 -------- >> drivers/platform/x86/lenovo/Makefile | 7 - >> drivers/platform/x86/lenovo/ideapad-laptop.c | 8 + >> 19 files changed, 294 insertions(+), 75 deletions(-) >> create mode 100644 drivers/platform/lenovo/Kconfig >> create mode 100644 drivers/platform/lenovo/Makefile >> rename drivers/platform/{x86 => }/lenovo/wmi-camera.c (100%) >> rename drivers/platform/{x86 => }/lenovo/wmi-capdata.c (100%) >> rename drivers/platform/{x86 => }/lenovo/wmi-capdata.h (100%) >> rename drivers/platform/{x86 => }/lenovo/wmi-events.c (100%) >> rename drivers/platform/{x86 => }/lenovo/wmi-events.h (100%) >> rename drivers/platform/{x86 => }/lenovo/wmi-gamezone.c (100%) >> rename drivers/platform/{x86 => }/lenovo/wmi-helpers.c (100%) >> rename drivers/platform/{x86 => }/lenovo/wmi-helpers.h (100%) >> rename drivers/platform/{x86 => }/lenovo/wmi-hotkey-utilities.c (100%) >> create mode 100644 drivers/platform/lenovo/wmi-hotkeys.c >> rename drivers/platform/{x86 => }/lenovo/wmi-other.c (100%) >> >> >> base-commit: 2800868f63227c8237d70c41e70d441c919620d6 ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH 0/3] platform: lenovo: architecture independent home for the Lenovo WMI drivers 2026-11-15 16:02 ` Armin Wolf @ 2026-11-15 18:02 ` Hans de Goede 0 siblings, 0 replies; 27+ messages in thread From: Hans de Goede @ 2026-11-15 18:02 UTC (permalink / raw) To: Armin Wolf, David Cemin, ilpo.jarvinen Cc: mpearson-lenovo, derekjohn.clark, xy-jackie, ikepanhc, platform-driver-x86, linux-kernel, ldemarchi Hi, On 15-Nov-26 17:02, Armin Wolf wrote: > Am 15.11.26 um 16:33 schrieb Hans de Goede: > >> <sorry for any double-send (first reply incomplete) Thunderbird has a new Ctrl+s send >> shortcut which I sometimes fat-finger when copy/pasting> >> >> Hi, >> >> On 13-Nov-26 23:27, David Cemin wrote: >>> Lenovo now ships ACPI based arm64 laptops whose firmware exposes the >>> same ACPI-WMI interfaces as the x86 IdeaPad and Legion machines: the Fn >>> key event GUID consumed by ideapad-laptop, the hotkey utility GUID used >>> for the microphone mute LED, and the GameZone, Other Mode and capability >>> data GUIDs behind the thermal operation modes. Since 884d53763d30 >>> ("platform/wmi: Remove dependency on CONFIG_X86") the ACPI-WMI core >>> builds on arm64, but the Lenovo WMI drivers still live under >>> drivers/platform/x86, which is gated by X86_PLATFORM_DEVICES, so none of >>> that code can be used where the firmware is. >>> >>> This series: >>> 1. moves the architecture independent Lenovo WMI drivers into a new >>> drivers/platform/lenovo directory, following drivers/platform/surface >>> which exists for the same reason (Surface ships x86 and arm64); >>> ideapad-laptop, thinkpad_acpi, think-lmi and the Yoga tablet drivers >>> stay under x86 because they need i8042, port I/O or x86 only devices; >>> 2. adds a small WMI hotkeys driver for the Fn key event GUID on machines> where ideapad-laptop cannot bind; >>> 3. makes ideapad-laptop's own WMI event driver decline the GUIDs when >>> the IdeaPad VPC device is absent, since it can never report events >>> there. >>> >>> Patch 2 was tested on a Lenovo Yoga 9 2-in-1 16 (arm64): microphone >>> mute, airplane mode, the Smart Key, the Smart Connect key and the Fn+Q >>> operation mode key all report input events. The same key set is dead on >>> a Lenovo Yoga Pro 9 (arm64) today and uses the same GUID. >>> Patches 1 and 3 are compile tested on x86_64 and arm64 (defconfig plus >>> all LENOVO_WMI options as modules). >>> >>> Two questions I would like the maintainers' view on before this goes >>> further: >>> >>> a. Is a vendor directory (drivers/platform/lenovo, like surface) the >>> right home, or should the architecture independent Lenovo WMI >>> drivers move under drivers/platform/wmi next to the core instead? >> I think that drivers/platform/lenovo makes sense since eventually we may >> want more then just WMI drivers, e.g. the thinkpad_acpi driver which >> actually sort of works on Qualcomm Snapdragon laptops when booting these >> with my experimental DT-ACPI hybrid mode patches: >> >> https://github.com/jwrdegoede/linux-sunxi/commits/acpi-dt-hybrid-v0.4/ > > Agreed, the drivers/platform/wmi directory should only contain core WMI > infrastructure code and maybe some generic drivers like wmi-bmof. > >>> b. Should the Fn key event handling stay a separate small driver, or >>> be factored out of ideapad-laptop so x86 and arm64 share one path? >>> ideapad-laptop handles the event only when its VPC platform driver >>> is bound, and the arm64 machines expose none of the VPC interface >>> it is built on (no _CFG, VPCR/VPCW, DYTC or HALS/SALS), so making >>> it the single driver means gating most of its probe. Two smaller >>> options: lift ideapad-laptop's own Fn key wmi_driver and keymap >>> into this file and let ideapad-laptop register for the events it >>> still wants (Fn lock LED, DYTC cycle), or the hid-asus/asus-wmi >>> shape where a companion WMI module exports the event to a >>> subsystem driver. The keymap in patch 2 duplicates entries of >>> ideapad-laptop's table on purpose until that is decided. >> IIRC the ideapad-laptop driver is a bit of a mess atm, so factoring >> a common handling for the the Fn key events out of this and sharing >> that sounds like a nice cleanup. >> >> I see that patch 2/3 uses the new wmi-driver/-bus infra which is >> nice and clean. >> >> So maybe just keep your existing stand-alone driver for both x86_64 + >> arm64 and drop the WMI event handling from ideapad-laptop. >> >> I guess this may hit some problems where WMI event handlig is used >> in ideapad-laptops integrating with some VPC functionality. >> >> For that purpose I think that the new >> drivers/platform/lenovo/wmi-hotkeys.c could maybe expose some >> notifier and call that for events it does not handle itself >> and then ideapad-laptop can depend on some function to register >> a listener on that notifier (1) and register a notifier handler >> staying out of WMI handling itself. >> >> No idea if this is feasible / how clean the end result will be, >> just brainstorming and saying yes to doing some refactoring of >> the somewhat messy ideapad-laptop code. >> >> Note that https://github.com/systemd/systemd/blob/main/hwdb.d/60-keyboard.hwdb >> has some mappings for "Ideapad extra buttons" input devices >> (+ DMI match), so if any of the buttons remapped there end up >> under the new WMI driver then that should probably give its >> input device the same name, to make sure those mappings still >> apply. >> >> Regards, >> >> Hans > > I like the idea of using a notifier to allow ideapad-laptop to consume WMI > events from wmi-hotkeys. This would even allow ideapad-laptop to override the > sparse keymap inside wmi-hotkeys by simply returning NOTIFY_STOP when "catching" > an WMI event that has to be handled internally (like event 0x3D (Performance Key)). > wmi-hotkeys can check for this return value and not emit a key code in such a case. Ah yes, I was thinking about only calling the notifier after not finding an entry in the sparse keymap, but calling it before allowing notifier handlers to return NOTIFY_STOP and filter out further processing is a good idea. Regards, Hans ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH 0/3] platform: lenovo: architecture independent home for the Lenovo WMI drivers 2026-11-15 15:33 ` [RFC PATCH 0/3] platform: lenovo: architecture independent home for the Lenovo WMI drivers Hans de Goede 2026-11-15 16:02 ` Armin Wolf @ 2026-11-15 20:10 ` Hans de Goede 2026-11-15 20:12 ` Hans de Goede 1 sibling, 1 reply; 27+ messages in thread From: Hans de Goede @ 2026-11-15 20:10 UTC (permalink / raw) To: David Cemin, ilpo.jarvinen, W_Armin Cc: mpearson-lenovo, derekjohn.clark, xy-jackie, ikepanhc, platform-driver-x86, linux-kernel, ldemarchi On 15-Nov-26 16:33, Hans de Goede wrote: <snip> >> b. Should the Fn key event handling stay a separate small driver, or >> be factored out of ideapad-laptop so x86 and arm64 share one path? >> ideapad-laptop handles the event only when its VPC platform driver >> is bound, and the arm64 machines expose none of the VPC interface >> it is built on (no _CFG, VPCR/VPCW, DYTC or HALS/SALS), so making >> it the single driver means gating most of its probe. Two smaller >> options: lift ideapad-laptop's own Fn key wmi_driver and keymap >> into this file and let ideapad-laptop register for the events it >> still wants (Fn lock LED, DYTC cycle), or the hid-asus/asus-wmi >> shape where a companion WMI module exports the event to a >> subsystem driver. The keymap in patch 2 duplicates entries of >> ideapad-laptop's table on purpose until that is decided. > > IIRC the ideapad-laptop driver is a bit of a mess atm, so factoring > a common handling for the the Fn key events out of this and sharing > that sounds like a nice cleanup. > > I see that patch 2/3 uses the new wmi-driver/-bus infra which is > nice and clean. > > So maybe just keep your existing stand-alone driver for both x86_64 + > arm64 and drop the WMI event handling from ideapad-laptop. > > I guess this may hit some problems where WMI event handlig is used > in ideapad-laptops integrating with some VPC functionality. > > For that purpose I think that the new > drivers/platform/lenovo/wmi-hotkeys.c could maybe expose some > notifier and call that for events it does not handle itself > and then ideapad-laptop can depend on some function to register > a listener on that notifier (1) and register a notifier handler > staying out of WMI handling itself. > > No idea if this is feasible / how clean the end result will be, > just brainstorming and saying yes to doing some refactoring of > the somewhat messy ideapad-laptop code. > > Note that https://github.com/systemd/systemd/blob/main/hwdb.d/60-keyboard.hwdb > has some mappings for "Ideapad extra buttons" input devices > (+ DMI match), so if any of the buttons remapped there end up > under the new WMI driver then that should probably give its > input device the same name, to make sure those mappings still > apply. Also see this just posted ideapad-laptop series which does something similar for handling YMC events: https://lore.kernel.org/platform-driver-x86/20261116-ymc-82yl-v1-0-fac1a2b01a84@rong.moe/ Regards, Hans > 1) +Kconfig dep, which will also avoid regressions by wrong > Kconfig ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH 0/3] platform: lenovo: architecture independent home for the Lenovo WMI drivers 2026-11-15 20:10 ` Hans de Goede @ 2026-11-15 20:12 ` Hans de Goede 2026-11-15 21:48 ` Mark Pearson 2026-11-16 4:42 ` David Cemin 0 siblings, 2 replies; 27+ messages in thread From: Hans de Goede @ 2026-11-15 20:12 UTC (permalink / raw) To: David Cemin, ilpo.jarvinen, W_Armin Cc: mpearson-lenovo, derekjohn.clark, xy-jackie, ikepanhc, platform-driver-x86, linux-kernel, ldemarchi p.s. On 15-Nov-26 21:10, Hans de Goede wrote: > On 15-Nov-26 16:33, Hans de Goede wrote: > > <snip> > >>> b. Should the Fn key event handling stay a separate small driver, or >>> be factored out of ideapad-laptop so x86 and arm64 share one path? >>> ideapad-laptop handles the event only when its VPC platform driver >>> is bound, and the arm64 machines expose none of the VPC interface >>> it is built on (no _CFG, VPCR/VPCW, DYTC or HALS/SALS), so making >>> it the single driver means gating most of its probe. Two smaller >>> options: lift ideapad-laptop's own Fn key wmi_driver and keymap >>> into this file and let ideapad-laptop register for the events it >>> still wants (Fn lock LED, DYTC cycle), or the hid-asus/asus-wmi >>> shape where a companion WMI module exports the event to a >>> subsystem driver. The keymap in patch 2 duplicates entries of >>> ideapad-laptop's table on purpose until that is decided. >> >> IIRC the ideapad-laptop driver is a bit of a mess atm, so factoring >> a common handling for the the Fn key events out of this and sharing >> that sounds like a nice cleanup. >> >> I see that patch 2/3 uses the new wmi-driver/-bus infra which is >> nice and clean. >> >> So maybe just keep your existing stand-alone driver for both x86_64 + >> arm64 and drop the WMI event handling from ideapad-laptop. >> >> I guess this may hit some problems where WMI event handlig is used >> in ideapad-laptops integrating with some VPC functionality. >> >> For that purpose I think that the new >> drivers/platform/lenovo/wmi-hotkeys.c could maybe expose some >> notifier and call that for events it does not handle itself >> and then ideapad-laptop can depend on some function to register >> a listener on that notifier (1) and register a notifier handler >> staying out of WMI handling itself. >> >> No idea if this is feasible / how clean the end result will be, >> just brainstorming and saying yes to doing some refactoring of >> the somewhat messy ideapad-laptop code. >> >> Note that https://github.com/systemd/systemd/blob/main/hwdb.d/60-keyboard.hwdb >> has some mappings for "Ideapad extra buttons" input devices >> (+ DMI match), so if any of the buttons remapped there end up >> under the new WMI driver then that should probably give its >> input device the same name, to make sure those mappings still >> apply. > > Also see this just posted ideapad-laptop series which does > something similar for handling YMC events: > > https://lore.kernel.org/platform-driver-x86/20261116-ymc-82yl-v1-0-fac1a2b01a84@rong.moe/ I see that this routes everything through a new lenovo wmi-events helper which uses a single notifier to which interested parties like ideapad-laptop can subscribe. I think this models could be extended to also handle the hotkeys, assuming all the base bits are moved into the new drivers/platform/lenovo/ dir. Regards, Hans ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH 0/3] platform: lenovo: architecture independent home for the Lenovo WMI drivers 2026-11-15 20:12 ` Hans de Goede @ 2026-11-15 21:48 ` Mark Pearson 2026-11-16 4:42 ` David Cemin 1 sibling, 0 replies; 27+ messages in thread From: Mark Pearson @ 2026-11-15 21:48 UTC (permalink / raw) To: Hans de Goede, David Cemin, Ilpo Järvinen, Armin Wolf Cc: Derek J . Clark, Jackie Dong, Ike Panhc, platform-driver-x86, linux-kernel, ldemarchi On Sun, Nov 15, 2026, at 3:12 PM, Hans de Goede wrote: > p.s. > > On 15-Nov-26 21:10, Hans de Goede wrote: >> On 15-Nov-26 16:33, Hans de Goede wrote: >> >> <snip> >> >>>> b. Should the Fn key event handling stay a separate small driver, or >>>> be factored out of ideapad-laptop so x86 and arm64 share one path? >>>> ideapad-laptop handles the event only when its VPC platform driver >>>> is bound, and the arm64 machines expose none of the VPC interface >>>> it is built on (no _CFG, VPCR/VPCW, DYTC or HALS/SALS), so making >>>> it the single driver means gating most of its probe. Two smaller >>>> options: lift ideapad-laptop's own Fn key wmi_driver and keymap >>>> into this file and let ideapad-laptop register for the events it >>>> still wants (Fn lock LED, DYTC cycle), or the hid-asus/asus-wmi >>>> shape where a companion WMI module exports the event to a >>>> subsystem driver. The keymap in patch 2 duplicates entries of >>>> ideapad-laptop's table on purpose until that is decided. >>> >>> IIRC the ideapad-laptop driver is a bit of a mess atm, so factoring >>> a common handling for the the Fn key events out of this and sharing >>> that sounds like a nice cleanup. >>> >>> I see that patch 2/3 uses the new wmi-driver/-bus infra which is >>> nice and clean. >>> >>> So maybe just keep your existing stand-alone driver for both x86_64 + >>> arm64 and drop the WMI event handling from ideapad-laptop. >>> >>> I guess this may hit some problems where WMI event handlig is used >>> in ideapad-laptops integrating with some VPC functionality. >>> >>> For that purpose I think that the new >>> drivers/platform/lenovo/wmi-hotkeys.c could maybe expose some >>> notifier and call that for events it does not handle itself >>> and then ideapad-laptop can depend on some function to register >>> a listener on that notifier (1) and register a notifier handler >>> staying out of WMI handling itself. >>> >>> No idea if this is feasible / how clean the end result will be, >>> just brainstorming and saying yes to doing some refactoring of >>> the somewhat messy ideapad-laptop code. >>> >>> Note that https://github.com/systemd/systemd/blob/main/hwdb.d/60-keyboard.hwdb >>> has some mappings for "Ideapad extra buttons" input devices >>> (+ DMI match), so if any of the buttons remapped there end up >>> under the new WMI driver then that should probably give its >>> input device the same name, to make sure those mappings still >>> apply. >> >> Also see this just posted ideapad-laptop series which does >> something similar for handling YMC events: >> >> https://lore.kernel.org/platform-driver-x86/20261116-ymc-82yl-v1-0-fac1a2b01a84@rong.moe/ > > I see that this routes everything through a new lenovo wmi-events > helper which uses a single notifier to which interested parties > like ideapad-laptop can subscribe. I think this models could > be extended to also handle the hotkeys, assuming all the base > bits are moved into the new drivers/platform/lenovo/ dir. > This all sounds good to me. I would quite like to break thinkpad_apci up a bit ultimately too....just tough finding the time. The think-lmi driver should likely move here (and a newer version tlmi-* that I should be posting for review next week, fingers crossed). Mark ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [RFC PATCH 0/3] platform: lenovo: architecture independent home for the Lenovo WMI drivers 2026-11-15 20:12 ` Hans de Goede 2026-11-15 21:48 ` Mark Pearson @ 2026-11-16 4:42 ` David Cemin 1 sibling, 0 replies; 27+ messages in thread From: David Cemin @ 2026-11-16 4:42 UTC (permalink / raw) To: Hans de Goede Cc: Ilpo Jarvinen, Armin Wolf, Mark Pearson, Derek J. Clark, Jackie Dong, Ike Panhc, platform-driver-x86, linux-kernel, Lucas De Marchi Hi Hans, Thanks, agreed on all points. For v2 I will keep wmi-hotkeys as the single driver for the Fn key GUID on both architectures, route its events through the lenovo-wmi-events notifier so ideapad-laptop subscribes instead of binding the GUIDs itself, call the chain before the keymap lookup so NOTIFY_STOP suppresses the key, and keep the input device name compatible with the hwdb entries. I will look at Rong Zhang's series and base on it or coordinate so we do not collide. The ideapad-laptop side I can only compile test, I have no x86 IdeaPad here, so I will ask for testers with v2. Thanks, David ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v2 0/3] platform: lenovo: architecture independent home for the Lenovo WMI drivers 2026-11-13 22:27 [RFC PATCH 0/3] platform: lenovo: architecture independent home for the Lenovo WMI drivers David Cemin ` (3 preceding siblings ...) 2026-11-15 15:33 ` [RFC PATCH 0/3] platform: lenovo: architecture independent home for the Lenovo WMI drivers Hans de Goede @ 2026-11-19 2:27 ` David Cemin 2026-11-19 2:27 ` [PATCH v2 1/3] platform: lenovo: move the architecture independent WMI drivers out of x86 David Cemin ` (2 more replies) 4 siblings, 3 replies; 27+ messages in thread From: David Cemin @ 2026-11-19 2:27 UTC (permalink / raw) To: hansg, ilpo.jarvinen, W_Armin Cc: mpearson-lenovo, derekjohn.clark, xy-jackie, ikepanhc, i, marco_giunta, platform-driver-x86, linux-kernel, ldemarchi Lenovo now ships ACPI based arm64 laptops whose firmware exposes the same ACPI-WMI interfaces as the x86 IdeaPad and Legion machines: the Fn key event GUID consumed by ideapad-laptop, the hotkey utility GUID used for the microphone mute LED, and the GameZone, Other Mode and capability data GUIDs behind the thermal operation modes. Since 884d53763d30 ("platform/wmi: Remove dependency on CONFIG_X86") the ACPI-WMI core builds on arm64, but the Lenovo WMI drivers still live under drivers/platform/x86, which is gated by X86_PLATFORM_DEVICES. This series: 1. moves the architecture independent Lenovo WMI drivers into a new drivers/platform/lenovo directory, following drivers/platform/surface; ideapad-laptop, thinkpad_acpi, think-lmi and the Yoga tablet drivers stay under x86 because they need i8042, port I/O or x86 only devices; 2. adds a WMI hotkeys driver that owns the Fn key and Fn+Esc event GUIDs on every architecture, reports the keys through a sparse keymap and offers a notifier chain to drivers with platform knowledge; 3. makes ideapad-laptop drop its WMI event driver and subscribe to that notifier instead, keeping its Fn lock LED and DYTC performance mode handling. The series applies on top of Rong Zhang's "platform/x86: ideapad-laptop: Trigger the EC on YMC events" (20261116-ymc-82yl-v1-0-fac1a2b01a84@rong.moe) because both touch the ideapad-laptop WMI code and that series modernizes the lenovo-wmi-events helper. Patch 2 was tested on a Lenovo Yoga 9 2-in-1 16 (arm64): microphone mute, airplane mode, the Smart Key, the Smart Connect key and the Fn+Q performance key report input events. The Fn+Esc GUIDs are not exposed by that firmware. Patch 3 is compile tested on x86_64 only, I do not have an x86 IdeaPad; a test on a Yoga 3 or Yoga 700 (Fn+Esc) and on a machine where ideapad-laptop handles the Fn lock LED or DYTC would be appreciated. Changes in v2: - dropped the WMI core Kconfig patch, 884d53763d30 covers it (Armin) - wmi-hotkeys: notify_new with the wmi_buffer, devm_kzalloc_obj, drvdata set before input registration, KEY_PERFORMANCE for 0x3d (Armin) - wmi-hotkeys: notifier chain called before the keymap lookup, NOTIFY_STOP suppresses the key (Hans, Armin); input device named like the ideapad-laptop one so the hwdb mappings keep applying (Hans) - wmi-hotkeys: camera lens cover switch events moved here with the rest of the Fn key GUID handling - the VPC guard patch is replaced by ideapad-laptop subscribing to the notifier and dropping its own Fn key WMI driver and keymap entries - wmi-hotkeys: the Fn+Esc event GUIDs move here as well, so that ideapad-laptop registers no WMI event driver at all (Armin); they carry no data and are reported under code 128 as before - commit message: 0x48 (Smart Connect) was already KEY_LINK_PHONE in ideapad-laptop since ccc8c8481c1f, the keymap follows it (Marco Giunta) - collected Mark's and Jackie's Reviewed-by on patch 1 David Cemin (3): platform: lenovo: move the architecture independent WMI drivers out of x86 platform: lenovo: add WMI hotkeys driver platform/x86: ideapad-laptop: consume the Fn key events from the WMI hotkeys driver MAINTAINERS | 10 +- drivers/platform/Kconfig | 2 + drivers/platform/Makefile | 1 + drivers/platform/lenovo/Kconfig | 101 ++++++++ drivers/platform/lenovo/Makefile | 23 ++ .../platform/{x86 => }/lenovo/wmi-camera.c | 0 .../platform/{x86 => }/lenovo/wmi-capdata.c | 0 .../platform/{x86 => }/lenovo/wmi-capdata.h | 0 .../platform/{x86 => }/lenovo/wmi-events.c | 0 .../platform/{x86 => }/lenovo/wmi-events.h | 0 .../platform/{x86 => }/lenovo/wmi-gamezone.c | 0 .../platform/{x86 => }/lenovo/wmi-helpers.c | 0 .../platform/{x86 => }/lenovo/wmi-helpers.h | 0 .../{x86 => }/lenovo/wmi-hotkey-utilities.c | 0 drivers/platform/lenovo/wmi-hotkeys.c | 244 ++++++++++++++++++ drivers/platform/{x86 => }/lenovo/wmi-other.c | 0 drivers/platform/x86/lenovo/Kconfig | 68 +---- drivers/platform/x86/lenovo/Makefile | 7 - drivers/platform/x86/lenovo/ideapad-laptop.c | 225 +++------------- .../platform_data/x86/lenovo-wmi-hotkeys.h | 28 ++ 20 files changed, 447 insertions(+), 262 deletions(-) create mode 100644 drivers/platform/lenovo/Kconfig create mode 100644 drivers/platform/lenovo/Makefile rename drivers/platform/{x86 => }/lenovo/wmi-camera.c (100%) rename drivers/platform/{x86 => }/lenovo/wmi-capdata.c (100%) rename drivers/platform/{x86 => }/lenovo/wmi-capdata.h (100%) rename drivers/platform/{x86 => }/lenovo/wmi-events.c (100%) rename drivers/platform/{x86 => }/lenovo/wmi-events.h (100%) rename drivers/platform/{x86 => }/lenovo/wmi-gamezone.c (100%) rename drivers/platform/{x86 => }/lenovo/wmi-helpers.c (100%) rename drivers/platform/{x86 => }/lenovo/wmi-helpers.h (100%) rename drivers/platform/{x86 => }/lenovo/wmi-hotkey-utilities.c (100%) create mode 100644 drivers/platform/lenovo/wmi-hotkeys.c rename drivers/platform/{x86 => }/lenovo/wmi-other.c (100%) create mode 100644 include/linux/platform_data/x86/lenovo-wmi-hotkeys.h -- 2.56.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v2 1/3] platform: lenovo: move the architecture independent WMI drivers out of x86 2026-11-19 2:27 ` [PATCH v2 " David Cemin @ 2026-11-19 2:27 ` David Cemin 2026-11-19 2:27 ` [PATCH v2 2/3] platform: lenovo: add WMI hotkeys driver David Cemin 2026-11-19 2:27 ` [PATCH v2 3/3] platform/x86: ideapad-laptop: consume the Fn key events from the " David Cemin 2 siblings, 0 replies; 27+ messages in thread From: David Cemin @ 2026-11-19 2:27 UTC (permalink / raw) To: hansg, ilpo.jarvinen, W_Armin Cc: mpearson-lenovo, derekjohn.clark, xy-jackie, ikepanhc, i, marco_giunta, platform-driver-x86, linux-kernel, ldemarchi The Lenovo WMI drivers (events, helpers, capability data, GameZone, Other Mode, hotkey utilities and camera button) contain no x86 specific code: they talk to firmware through the ACPI-WMI core only. They live under drivers/platform/x86 because that is where Lenovo drivers were collected, and X86_PLATFORM_DEVICES keeps them off every other architecture. Lenovo now ships ACPI based arm64 laptops whose firmware exposes the same WMI GUIDs (the Fn key events, the mic mute LED method, GameZone and Other Mode). Give these drivers an architecture independent home, drivers/platform/lenovo, following the layout of drivers/platform/surface which exists for the same reason, so they can be built wherever the WMI core is available. ideapad-laptop, thinkpad_acpi, think-lmi, yogabook and the Yoga Tablet drivers stay under x86: they depend on i8042, port I/O or x86 only ACPI devices. Pure code motion: the files, their Kconfig entries and the module naming scheme are unchanged. MAINTAINERS entries are updated for the new paths. Signed-off-by: David Cemin <dcemin@nvidia.com> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca> Reviewed-by: Jackie Dong <xy-jackie@139.com> --- MAINTAINERS | 3 +- drivers/platform/Kconfig | 2 + drivers/platform/Makefile | 1 + drivers/platform/lenovo/Kconfig | 87 +++++++++++++++++++ drivers/platform/lenovo/Makefile | 22 +++++ .../platform/{x86 => }/lenovo/wmi-camera.c | 0 .../platform/{x86 => }/lenovo/wmi-capdata.c | 0 .../platform/{x86 => }/lenovo/wmi-capdata.h | 0 .../platform/{x86 => }/lenovo/wmi-events.c | 0 .../platform/{x86 => }/lenovo/wmi-events.h | 0 .../platform/{x86 => }/lenovo/wmi-gamezone.c | 0 .../platform/{x86 => }/lenovo/wmi-helpers.c | 0 .../platform/{x86 => }/lenovo/wmi-helpers.h | 0 .../{x86 => }/lenovo/wmi-hotkey-utilities.c | 0 drivers/platform/{x86 => }/lenovo/wmi-other.c | 0 drivers/platform/x86/lenovo/Kconfig | 67 -------------- drivers/platform/x86/lenovo/Makefile | 7 -- 17 files changed, 114 insertions(+), 75 deletions(-) create mode 100644 drivers/platform/lenovo/Kconfig create mode 100644 drivers/platform/lenovo/Makefile rename drivers/platform/{x86 => }/lenovo/wmi-camera.c (100%) rename drivers/platform/{x86 => }/lenovo/wmi-capdata.c (100%) rename drivers/platform/{x86 => }/lenovo/wmi-capdata.h (100%) rename drivers/platform/{x86 => }/lenovo/wmi-events.c (100%) rename drivers/platform/{x86 => }/lenovo/wmi-events.h (100%) rename drivers/platform/{x86 => }/lenovo/wmi-gamezone.c (100%) rename drivers/platform/{x86 => }/lenovo/wmi-helpers.c (100%) rename drivers/platform/{x86 => }/lenovo/wmi-helpers.h (100%) rename drivers/platform/{x86 => }/lenovo/wmi-hotkey-utilities.c (100%) rename drivers/platform/{x86 => }/lenovo/wmi-other.c (100%) diff --git a/MAINTAINERS b/MAINTAINERS index 056408bc086e..3b0ad5a3debe 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -15170,13 +15170,14 @@ L: platform-driver-x86@vger.kernel.org S: Maintained F: Documentation/wmi/devices/lenovo-wmi-gamezone.rst F: Documentation/wmi/devices/lenovo-wmi-other.rst +F: drivers/platform/lenovo/ F: drivers/platform/x86/lenovo/* LENOVO WMI HOTKEY UTILITIES DRIVER M: Jackie Dong <xy-jackie@139.com> L: platform-driver-x86@vger.kernel.org S: Maintained -F: drivers/platform/x86/lenovo/wmi-hotkey-utilities.c +F: drivers/platform/lenovo/wmi-hotkey-utilities.c LENOVO HID drivers M: Derek J. Clark <derekjohn.clark@gmail.com> diff --git a/drivers/platform/Kconfig b/drivers/platform/Kconfig index 312788f249c9..80b2b83b69e5 100644 --- a/drivers/platform/Kconfig +++ b/drivers/platform/Kconfig @@ -15,6 +15,8 @@ source "drivers/platform/olpc/Kconfig" source "drivers/platform/surface/Kconfig" +source "drivers/platform/lenovo/Kconfig" + source "drivers/platform/x86/Kconfig" source "drivers/platform/arm64/Kconfig" diff --git a/drivers/platform/Makefile b/drivers/platform/Makefile index fa322e7f8716..0144f88ff6db 100644 --- a/drivers/platform/Makefile +++ b/drivers/platform/Makefile @@ -12,6 +12,7 @@ obj-$(CONFIG_GOLDFISH) += goldfish/ obj-$(CONFIG_CHROME_PLATFORMS) += chrome/ obj-$(CONFIG_CZNIC_PLATFORMS) += cznic/ obj-$(CONFIG_SURFACE_PLATFORMS) += surface/ +obj-$(CONFIG_LENOVO_PLATFORMS) += lenovo/ obj-$(CONFIG_ARM64_PLATFORM_DEVICES) += arm64/ obj-$(CONFIG_BCM2835_VCHIQ) += raspberrypi/ obj-$(CONFIG_ACPI_WMI) += wmi/ diff --git a/drivers/platform/lenovo/Kconfig b/drivers/platform/lenovo/Kconfig new file mode 100644 index 000000000000..8222322ca671 --- /dev/null +++ b/drivers/platform/lenovo/Kconfig @@ -0,0 +1,87 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Lenovo Platform-Specific Drivers +# + +menuconfig LENOVO_PLATFORMS + bool "Lenovo Platform-Specific Device Drivers" + depends on ARM64 || X86 || COMPILE_TEST + default y if ARM64 || X86 + help + Say Y here to get to see options for platform-specific device drivers + for Lenovo devices that do not depend on the CPU architecture, such + as the ACPI-WMI based drivers used on both x86 and arm64 laptops. + This option alone does not add any kernel code. + + If you say N, all options in this submenu will be skipped and disabled. + +if LENOVO_PLATFORMS + +config LENOVO_WMI_HELPERS + tristate + depends on ACPI_WMI + +config LENOVO_WMI_EVENTS + tristate + depends on ACPI_WMI + +config LENOVO_WMI_CAPDATA + tristate + depends on ACPI_WMI + depends on LENOVO_WMI_HELPERS + +config LENOVO_WMI_HOTKEY_UTILITIES + tristate "Lenovo Hotkey Utility WMI extras driver" + depends on ACPI_WMI + select NEW_LEDS + select LEDS_CLASS + imply IDEAPAD_LAPTOP + help + This driver provides WMI support for Lenovo customized hotkeys function, + such as LED control for audio/mic mute event for Ideapad, YOGA, XiaoXin, + Gaming, ThinkBook and so on. + +config LENOVO_WMI_CAMERA + tristate "Lenovo WMI Camera Button driver" + depends on ACPI_WMI + depends on INPUT + help + This driver provides support for Lenovo camera button. The Camera + button is a GPIO device. This driver receives ACPI notifications when + the camera button is switched on/off. + + To compile this driver as a module, choose M here: the module + will be called lenovo-wmi-camera. + +config LENOVO_WMI_GAMEZONE + tristate "Lenovo GameZone WMI Driver" + depends on ACPI_WMI + depends on DMI + select ACPI_PLATFORM_PROFILE + select LENOVO_WMI_EVENTS + select LENOVO_WMI_HELPERS + help + Say Y here if you have a WMI aware Lenovo Legion device and would like to use the + platform-profile firmware interface to manage power usage. + + To compile this driver as a module, choose M here: the module will + be called lenovo-wmi-gamezone. + +config LENOVO_WMI_TUNING + tristate "Lenovo Other Mode WMI Driver" + depends on ACPI_WMI + depends on ACPI_BATTERY + select HWMON + select FW_ATTR_CLASS + select LENOVO_WMI_CAPDATA + select LENOVO_WMI_EVENTS + select LENOVO_WMI_HELPERS + help + Say Y here if you have a WMI aware Lenovo Legion device and would like to use the + firmware_attributes API to control various tunable settings typically exposed by + Lenovo software in Windows. + + To compile this driver as a module, choose M here: the module will + be called lenovo-wmi-other. + +endif # LENOVO_PLATFORMS diff --git a/drivers/platform/lenovo/Makefile b/drivers/platform/lenovo/Makefile new file mode 100644 index 000000000000..1cac115dd735 --- /dev/null +++ b/drivers/platform/lenovo/Makefile @@ -0,0 +1,22 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for linux/drivers/platform/lenovo +# Lenovo Platform Specific Drivers (architecture independent) +# + +lenovo-target-$(CONFIG_LENOVO_WMI_HELPERS) += wmi-helpers.o +lenovo-target-$(CONFIG_LENOVO_WMI_EVENTS) += wmi-events.o +lenovo-target-$(CONFIG_LENOVO_WMI_CAPDATA) += wmi-capdata.o +lenovo-target-$(CONFIG_LENOVO_WMI_HOTKEY_UTILITIES) += wmi-hotkey-utilities.o +lenovo-target-$(CONFIG_LENOVO_WMI_CAMERA) += wmi-camera.o +lenovo-target-$(CONFIG_LENOVO_WMI_GAMEZONE) += wmi-gamezone.o +lenovo-target-$(CONFIG_LENOVO_WMI_TUNING) += wmi-other.o + +# Add 'lenovo' prefix to each module listed in lenovo-target-* +define LENOVO_OBJ_TARGET +lenovo-$(1)-y := $(1).o +obj-$(2) += lenovo-$(1).o +endef + +$(foreach target, $(basename $(lenovo-target-y)), $(eval $(call LENOVO_OBJ_TARGET,$(target),y))) +$(foreach target, $(basename $(lenovo-target-m)), $(eval $(call LENOVO_OBJ_TARGET,$(target),m))) diff --git a/drivers/platform/x86/lenovo/wmi-camera.c b/drivers/platform/lenovo/wmi-camera.c similarity index 100% rename from drivers/platform/x86/lenovo/wmi-camera.c rename to drivers/platform/lenovo/wmi-camera.c diff --git a/drivers/platform/x86/lenovo/wmi-capdata.c b/drivers/platform/lenovo/wmi-capdata.c similarity index 100% rename from drivers/platform/x86/lenovo/wmi-capdata.c rename to drivers/platform/lenovo/wmi-capdata.c diff --git a/drivers/platform/x86/lenovo/wmi-capdata.h b/drivers/platform/lenovo/wmi-capdata.h similarity index 100% rename from drivers/platform/x86/lenovo/wmi-capdata.h rename to drivers/platform/lenovo/wmi-capdata.h diff --git a/drivers/platform/x86/lenovo/wmi-events.c b/drivers/platform/lenovo/wmi-events.c similarity index 100% rename from drivers/platform/x86/lenovo/wmi-events.c rename to drivers/platform/lenovo/wmi-events.c diff --git a/drivers/platform/x86/lenovo/wmi-events.h b/drivers/platform/lenovo/wmi-events.h similarity index 100% rename from drivers/platform/x86/lenovo/wmi-events.h rename to drivers/platform/lenovo/wmi-events.h diff --git a/drivers/platform/x86/lenovo/wmi-gamezone.c b/drivers/platform/lenovo/wmi-gamezone.c similarity index 100% rename from drivers/platform/x86/lenovo/wmi-gamezone.c rename to drivers/platform/lenovo/wmi-gamezone.c diff --git a/drivers/platform/x86/lenovo/wmi-helpers.c b/drivers/platform/lenovo/wmi-helpers.c similarity index 100% rename from drivers/platform/x86/lenovo/wmi-helpers.c rename to drivers/platform/lenovo/wmi-helpers.c diff --git a/drivers/platform/x86/lenovo/wmi-helpers.h b/drivers/platform/lenovo/wmi-helpers.h similarity index 100% rename from drivers/platform/x86/lenovo/wmi-helpers.h rename to drivers/platform/lenovo/wmi-helpers.h diff --git a/drivers/platform/x86/lenovo/wmi-hotkey-utilities.c b/drivers/platform/lenovo/wmi-hotkey-utilities.c similarity index 100% rename from drivers/platform/x86/lenovo/wmi-hotkey-utilities.c rename to drivers/platform/lenovo/wmi-hotkey-utilities.c diff --git a/drivers/platform/x86/lenovo/wmi-other.c b/drivers/platform/lenovo/wmi-other.c similarity index 100% rename from drivers/platform/x86/lenovo/wmi-other.c rename to drivers/platform/lenovo/wmi-other.c diff --git a/drivers/platform/x86/lenovo/Kconfig b/drivers/platform/x86/lenovo/Kconfig index f16b09bab082..4d9a25d0e3b5 100644 --- a/drivers/platform/x86/lenovo/Kconfig +++ b/drivers/platform/x86/lenovo/Kconfig @@ -20,29 +20,6 @@ config IDEAPAD_LAPTOP This is a driver for Lenovo IdeaPad netbooks contains drivers for rfkill switch, hotkey, fan control and backlight control. -config LENOVO_WMI_HOTKEY_UTILITIES - tristate "Lenovo Hotkey Utility WMI extras driver" - depends on ACPI_WMI - select NEW_LEDS - select LEDS_CLASS - imply IDEAPAD_LAPTOP - help - This driver provides WMI support for Lenovo customized hotkeys function, - such as LED control for audio/mic mute event for Ideapad, YOGA, XiaoXin, - Gaming, ThinkBook and so on. - -config LENOVO_WMI_CAMERA - tristate "Lenovo WMI Camera Button driver" - depends on ACPI_WMI - depends on INPUT - help - This driver provides support for Lenovo camera button. The Camera - button is a GPIO device. This driver receives ACPI notifications when - the camera button is switched on/off. - - To compile this driver as a module, choose M here: the module - will be called lenovo-wmi-camera. - config LENOVO_YB9_KBDOCK tristate "Lenovo Yoga Book 9 keyboard dock detection" depends on ACPI_WMI @@ -248,47 +225,3 @@ config YT2_1380 To compile this driver as a module, choose M here: the module will be called lenovo-yogabook. - -config LENOVO_WMI_CAPDATA - tristate - depends on ACPI_WMI - depends on LENOVO_WMI_HELPERS - -config LENOVO_WMI_EVENTS - tristate - depends on ACPI_WMI - -config LENOVO_WMI_HELPERS - tristate - depends on ACPI_WMI - -config LENOVO_WMI_GAMEZONE - tristate "Lenovo GameZone WMI Driver" - depends on ACPI_WMI - depends on DMI - select ACPI_PLATFORM_PROFILE - select LENOVO_WMI_EVENTS - select LENOVO_WMI_HELPERS - help - Say Y here if you have a WMI aware Lenovo Legion device and would like to use the - platform-profile firmware interface to manage power usage. - - To compile this driver as a module, choose M here: the module will - be called lenovo-wmi-gamezone. - -config LENOVO_WMI_TUNING - tristate "Lenovo Other Mode WMI Driver" - depends on ACPI_WMI - depends on ACPI_BATTERY - select HWMON - select FW_ATTR_CLASS - select LENOVO_WMI_CAPDATA - select LENOVO_WMI_EVENTS - select LENOVO_WMI_HELPERS - help - Say Y here if you have a WMI aware Lenovo Legion device and would like to use the - firmware_attributes API to control various tunable settings typically exposed by - Lenovo software in Windows. - - To compile this driver as a module, choose M here: the module will - be called lenovo-wmi-other. diff --git a/drivers/platform/x86/lenovo/Makefile b/drivers/platform/x86/lenovo/Makefile index 12816d8d5e24..758c36cedee8 100644 --- a/drivers/platform/x86/lenovo/Makefile +++ b/drivers/platform/x86/lenovo/Makefile @@ -7,17 +7,10 @@ obj-$(CONFIG_IDEAPAD_LAPTOP) += ideapad-laptop.o obj-$(CONFIG_THINKPAD_LMI) += think-lmi.o obj-$(CONFIG_THINKPAD_ACPI) += thinkpad_acpi.o -lenovo-target-$(CONFIG_LENOVO_WMI_HOTKEY_UTILITIES) += wmi-hotkey-utilities.o lenovo-target-$(CONFIG_LENOVO_YB9_KBDOCK) += yb9-kbdock.o lenovo-target-$(CONFIG_LENOVO_YMC) += ymc.o lenovo-target-$(CONFIG_YOGABOOK) += yogabook.o lenovo-target-$(CONFIG_YT2_1380) += yoga-tab2-pro-1380-fastcharger.o -lenovo-target-$(CONFIG_LENOVO_WMI_CAMERA) += wmi-camera.o -lenovo-target-$(CONFIG_LENOVO_WMI_CAPDATA) += wmi-capdata.o -lenovo-target-$(CONFIG_LENOVO_WMI_EVENTS) += wmi-events.o -lenovo-target-$(CONFIG_LENOVO_WMI_HELPERS) += wmi-helpers.o -lenovo-target-$(CONFIG_LENOVO_WMI_GAMEZONE) += wmi-gamezone.o -lenovo-target-$(CONFIG_LENOVO_WMI_TUNING) += wmi-other.o # Add 'lenovo' prefix to each module listed in lenovo-target-* define LENOVO_OBJ_TARGET -- 2.56.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v2 2/3] platform: lenovo: add WMI hotkeys driver 2026-11-19 2:27 ` [PATCH v2 " David Cemin 2026-11-19 2:27 ` [PATCH v2 1/3] platform: lenovo: move the architecture independent WMI drivers out of x86 David Cemin @ 2026-11-19 2:27 ` David Cemin 2026-11-19 6:10 ` Armin Wolf 2026-11-19 2:27 ` [PATCH v2 3/3] platform/x86: ideapad-laptop: consume the Fn key events from the " David Cemin 2 siblings, 1 reply; 27+ messages in thread From: David Cemin @ 2026-11-19 2:27 UTC (permalink / raw) To: hansg, ilpo.jarvinen, W_Armin Cc: mpearson-lenovo, derekjohn.clark, xy-jackie, ikepanhc, i, marco_giunta, platform-driver-x86, linux-kernel, ldemarchi Lenovo consumer laptops deliver their vendor specific Fn keys (microphone mute, airplane mode, performance mode, the Smart Key, Smart Connect and others) as WMI events on GUID 8FC0DE0C-B4E4-43FD-B0F3-8871711C1294 instead of keyboard usages, and the Yoga 3 and Yoga 700 generations report Fn+Esc on two dedicated event GUIDs that carry no data. On x86 ideapad-laptop consumes these events together with the IdeaPad VPC device; that driver depends on i8042 and the VPC, neither of which exist on the ACPI based arm64 models, so the keys do nothing there. Add a small WMI driver that owns these event GUIDs on every architecture and reports the keys through a sparse keymap, using the key codes ideapad-laptop has used for them, including code 128 for the Fn+Esc events. The input device keeps the ideapad-laptop name so that the existing hwdb mappings for these keys continue to apply. Drivers with platform knowledge can subscribe to a notifier chain that is called with the event code before the key is reported; a subscriber that handles the event itself returns NOTIFY_STOP and no key is reported. ideapad-laptop uses this for the Fn lock LED and the performance mode button, which cycles the platform profile instead of producing a key. The camera lens cover switch (events 0x0c and 0x0d) is reported as SW_CAMERA_LENS_COVER, as ideapad-laptop does today. Tested on a Lenovo Yoga 9 2-in-1 16 (arm64): microphone mute, airplane mode, the Smart Key, the Smart Connect key and the Fn+Q performance key report input events. The Esc event GUIDs are not exposed by that firmware, so that path is compile tested only. Signed-off-by: David Cemin <dcemin@nvidia.com> --- MAINTAINERS | 7 + drivers/platform/lenovo/Kconfig | 14 + drivers/platform/lenovo/Makefile | 1 + drivers/platform/lenovo/wmi-hotkeys.c | 244 ++++++++++++++++++ .../platform_data/x86/lenovo-wmi-hotkeys.h | 28 ++ 5 files changed, 294 insertions(+) create mode 100644 drivers/platform/lenovo/wmi-hotkeys.c create mode 100644 include/linux/platform_data/x86/lenovo-wmi-hotkeys.h diff --git a/MAINTAINERS b/MAINTAINERS index 3b0ad5a3debe..1d5b08c033b1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -15173,6 +15173,13 @@ F: Documentation/wmi/devices/lenovo-wmi-other.rst F: drivers/platform/lenovo/ F: drivers/platform/x86/lenovo/* +LENOVO WMI HOTKEYS DRIVER +M: David Cemin <dcemin@nvidia.com> +L: platform-driver-x86@vger.kernel.org +S: Maintained +F: drivers/platform/lenovo/wmi-hotkeys.c +F: include/linux/platform_data/x86/lenovo-wmi-hotkeys.h + LENOVO WMI HOTKEY UTILITIES DRIVER M: Jackie Dong <xy-jackie@139.com> L: platform-driver-x86@vger.kernel.org diff --git a/drivers/platform/lenovo/Kconfig b/drivers/platform/lenovo/Kconfig index 8222322ca671..2810c995ee8c 100644 --- a/drivers/platform/lenovo/Kconfig +++ b/drivers/platform/lenovo/Kconfig @@ -41,6 +41,20 @@ config LENOVO_WMI_HOTKEY_UTILITIES such as LED control for audio/mic mute event for Ideapad, YOGA, XiaoXin, Gaming, ThinkBook and so on. +config LENOVO_WMI_HOTKEYS + tristate "Lenovo WMI hotkeys driver" + depends on ACPI_WMI + depends on INPUT + select INPUT_SPARSEKMAP + help + Say Y or M here to enable the vendor specific Fn keys (microphone + mute, airplane mode, performance mode, star key, Fn+Esc) on Lenovo + laptops that deliver them as WMI events. ideapad-laptop subscribes + to this driver for its Fn lock LED and performance mode handling. + + To compile this driver as a module, choose M here: the module will + be called lenovo-wmi-hotkeys. + config LENOVO_WMI_CAMERA tristate "Lenovo WMI Camera Button driver" depends on ACPI_WMI diff --git a/drivers/platform/lenovo/Makefile b/drivers/platform/lenovo/Makefile index 1cac115dd735..d3f5e3ac14c2 100644 --- a/drivers/platform/lenovo/Makefile +++ b/drivers/platform/lenovo/Makefile @@ -8,6 +8,7 @@ lenovo-target-$(CONFIG_LENOVO_WMI_HELPERS) += wmi-helpers.o lenovo-target-$(CONFIG_LENOVO_WMI_EVENTS) += wmi-events.o lenovo-target-$(CONFIG_LENOVO_WMI_CAPDATA) += wmi-capdata.o lenovo-target-$(CONFIG_LENOVO_WMI_HOTKEY_UTILITIES) += wmi-hotkey-utilities.o +lenovo-target-$(CONFIG_LENOVO_WMI_HOTKEYS) += wmi-hotkeys.o lenovo-target-$(CONFIG_LENOVO_WMI_CAMERA) += wmi-camera.o lenovo-target-$(CONFIG_LENOVO_WMI_GAMEZONE) += wmi-gamezone.o lenovo-target-$(CONFIG_LENOVO_WMI_TUNING) += wmi-other.o diff --git a/drivers/platform/lenovo/wmi-hotkeys.c b/drivers/platform/lenovo/wmi-hotkeys.c new file mode 100644 index 000000000000..f412652e9f72 --- /dev/null +++ b/drivers/platform/lenovo/wmi-hotkeys.c @@ -0,0 +1,244 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Lenovo WMI hotkeys driver + * + * Lenovo consumer laptops deliver their vendor specific Fn keys (microphone + * mute, airplane mode, performance mode, the star key and others) as WMI + * events on GUID 8FC0DE0C-B4E4-43FD-B0F3-8871711C1294 instead of keyboard + * usages, and the older Yoga models report Fn+Esc on two dedicated event + * GUIDs that carry no data. This driver owns these event GUIDs on every + * architecture and reports the keys through a sparse keymap. Drivers with + * platform knowledge, such as ideapad-laptop, subscribe to the notifier chain + * to act on an event and may stop the key from being reported. + * + * The key codes follow the mapping historically used by ideapad-laptop. + */ + +#include <linux/device.h> +#include <linux/export.h> +#include <linux/input.h> +#include <linux/input/sparse-keymap.h> +#include <linux/module.h> +#include <linux/notifier.h> +#include <linux/platform_data/x86/lenovo-wmi-hotkeys.h> +#include <linux/types.h> +#include <linux/wmi.h> + +#include <asm/byteorder.h> + +#define LENOVO_FN_KEYS_WMI_GUID "8FC0DE0C-B4E4-43FD-B0F3-8871711C1294" +/* Fn+Esc on the Yoga 3 and Yoga 700 generations, no event data */ +#define LENOVO_ESC_WMI_GUID_YOGA3 "26CAB2E5-5CF1-46AE-AAC3-4A12B6BA50E6" +#define LENOVO_ESC_WMI_GUID_YOGA700 "56322276-8493-4CE8-A783-98C991274F5E" + +/* + * The Esc event GUIDs carry no key code; they are reported under + * LENOVO_WMI_HOTKEYS_ESC_CODE, the code ideapad-laptop has always used for + * them, so the existing hwdb mappings keep applying. The Fn key GUID codes + * are all below 0x80. + */ + +enum lenovo_wmi_hotkeys_type { + LENOVO_WMI_HOTKEYS_FN_KEYS, + LENOVO_WMI_HOTKEYS_ESC, +}; + +static const enum lenovo_wmi_hotkeys_type lenovo_wmi_hotkeys_fn_keys = LENOVO_WMI_HOTKEYS_FN_KEYS; +static const enum lenovo_wmi_hotkeys_type lenovo_wmi_hotkeys_esc = LENOVO_WMI_HOTKEYS_ESC; + +static BLOCKING_NOTIFIER_HEAD(lenovo_wmi_hotkeys_chain); + +static const struct key_entry lenovo_wmi_hotkeys_keymap[] = { + /* Fn+Esc from the Esc event GUIDs */ + { KE_KEY, LENOVO_WMI_HOTKEYS_ESC_CODE, { KEY_ESC } }, + /* Customizable Lenovo Hotkey ("star" with 'S' inside) */ + { KE_KEY, 0x01, { KEY_FAVORITES } }, + /* Fn lock toggled on / off, handled by the firmware */ + { KE_IGNORE, 0x02 }, + /* Esc, handled by the firmware */ + { KE_IGNORE, 0x03 }, + { KE_KEY, 0x04, { KEY_SELECTIVE_SCREENSHOT } }, + /* Lenovo Support */ + { KE_KEY, 0x07, { KEY_HELP } }, + /* Refresh Rate Toggle */ + { KE_KEY, 0x0a, { KEY_REFRESH_RATE_TOGGLE } }, + /* Camera lens cover closed / opened */ + { KE_SW, 0x0c, .sw = { SW_CAMERA_LENS_COVER, 0 } }, + { KE_SW, 0x0d, .sw = { SW_CAMERA_LENS_COVER, 1 } }, + { KE_KEY, 0x0e, { KEY_PICKUP_PHONE } }, + { KE_KEY, 0x0f, { KEY_HANGUP_PHONE } }, + /* Refresh Rate Toggle (Fn+R) */ + { KE_KEY, 0x10, { KEY_REFRESH_RATE_TOGGLE } }, + /* Sound profile switch */ + { KE_KEY, 0x12, { KEY_PROG2 } }, + /* Dark mode toggle */ + { KE_KEY, 0x13, { KEY_PROG1 } }, + /* Lenovo Support */ + { KE_KEY, 0x27, { KEY_HELP } }, + /* Lenovo Virtual Background application */ + { KE_KEY, 0x28, { KEY_PROG3 } }, + { KE_KEY, 0x29, { KEY_TOUCHPAD_TOGGLE } }, + { KE_KEY, 0x2a, { KEY_ROOT_MENU } }, + /* Shift + PrtSc */ + { KE_KEY, 0x2d, { KEY_SELECTIVE_SCREENSHOT } }, + /* Performance mode toggle, Fn+Q */ + { KE_KEY, 0x3d, { KEY_PERFORMANCE } }, + { KE_KEY, 0x3e, { KEY_MICMUTE } }, + { KE_KEY, 0x3f, { KEY_RFKILL } }, + /* + * Keyboard backlight level after Fn+Space, handled by the firmware: + * 0x40 off, 0x41 low, 0x42 high, 0x43 also seen + */ + { KE_IGNORE, 0x40 }, + { KE_IGNORE, 0x41 }, + { KE_IGNORE, 0x42 }, + { KE_IGNORE, 0x43 }, + /* Star, user assignable key */ + { KE_KEY, 0x44, { KEY_PROG1 } }, + /* Eye care */ + { KE_KEY, 0x45, { KEY_PROG3 } }, + /* Mode, opens a profile chooser; the Fn+Q button cycles the profile */ + { KE_KEY, 0x46, { KEY_PROG4 } }, + /* Lenovo Smart Connect */ + { KE_KEY, 0x48, { KEY_LINK_PHONE } }, + { KE_END }, +}; + +struct lenovo_wmi_hotkeys { + struct input_dev *input; + enum lenovo_wmi_hotkeys_type type; +}; + +/** + * lenovo_wmi_hotkeys_register_notifier() - Subscribe to the hotkey events. + * @nb: The notifier_block to register. + * + * The callback runs in process context with the WMI event code as the + * action. Return NOTIFY_STOP from the callback to consume the event. + * + * Return: 0 on success, or a negative error code. + */ +int lenovo_wmi_hotkeys_register_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_register(&lenovo_wmi_hotkeys_chain, nb); +} +EXPORT_SYMBOL_NS_GPL(lenovo_wmi_hotkeys_register_notifier, "LENOVO_WMI_HOTKEYS"); + +/** + * lenovo_wmi_hotkeys_unregister_notifier() - Unsubscribe from the hotkey events. + * @nb: The notifier_block to unregister. + * + * Return: 0 on success, or a negative error code. + */ +int lenovo_wmi_hotkeys_unregister_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_unregister(&lenovo_wmi_hotkeys_chain, nb); +} +EXPORT_SYMBOL_NS_GPL(lenovo_wmi_hotkeys_unregister_notifier, "LENOVO_WMI_HOTKEYS"); + +static void devm_lenovo_wmi_hotkeys_unregister_notifier(void *data) +{ + lenovo_wmi_hotkeys_unregister_notifier(data); +} + +/** + * devm_lenovo_wmi_hotkeys_register_notifier() - Device managed subscription. + * @dev: The device whose lifetime bounds the subscription. + * @nb: The notifier_block to register. + * + * Return: 0 on success, or a negative error code. + */ +int devm_lenovo_wmi_hotkeys_register_notifier(struct device *dev, + struct notifier_block *nb) +{ + int ret; + + ret = lenovo_wmi_hotkeys_register_notifier(nb); + if (ret) + return ret; + + return devm_add_action_or_reset(dev, devm_lenovo_wmi_hotkeys_unregister_notifier, nb); +} +EXPORT_SYMBOL_NS_GPL(devm_lenovo_wmi_hotkeys_register_notifier, "LENOVO_WMI_HOTKEYS"); + +static int lenovo_wmi_hotkeys_probe(struct wmi_device *wdev, const void *context) +{ + struct lenovo_wmi_hotkeys *priv; + int ret; + + priv = devm_kzalloc_obj(&wdev->dev, *priv); + if (!priv) + return -ENOMEM; + + priv->type = *(const enum lenovo_wmi_hotkeys_type *)context; + + priv->input = devm_input_allocate_device(&wdev->dev); + if (!priv->input) + return -ENOMEM; + + /* + * Same name as the ideapad-laptop input device so that the existing + * hwdb keyboard mappings for these keys keep applying. + */ + priv->input->name = "Ideapad extra buttons"; + priv->input->phys = priv->type == LENOVO_WMI_HOTKEYS_ESC ? "wmi/input1" : "wmi/input0"; + priv->input->id.bustype = BUS_HOST; + priv->input->dev.parent = &wdev->dev; + + ret = sparse_keymap_setup(priv->input, lenovo_wmi_hotkeys_keymap, NULL); + if (ret) + return ret; + + dev_set_drvdata(&wdev->dev, priv); + + return input_register_device(priv->input); +} + +static void lenovo_wmi_hotkeys_notify(struct wmi_device *wdev, const struct wmi_buffer *buf) +{ + struct lenovo_wmi_hotkeys *priv = dev_get_drvdata(&wdev->dev); + u32 code; + int ret; + + if (priv->type == LENOVO_WMI_HOTKEYS_ESC) { + code = LENOVO_WMI_HOTKEYS_ESC_CODE; + } else { + if (buf->length < sizeof(u32)) { + dev_dbg(&wdev->dev, "short hotkey event (%zu bytes)\n", buf->length); + return; + } + code = le32_to_cpup(buf->data); + } + + dev_dbg(&wdev->dev, "hotkey event 0x%x\n", code); + + ret = blocking_notifier_call_chain(&lenovo_wmi_hotkeys_chain, code, NULL); + if (ret & NOTIFY_STOP_MASK) + return; + + if (!sparse_keymap_report_event(priv->input, code, 1, true)) + dev_info_ratelimited(&wdev->dev, "unknown hotkey event 0x%x\n", code); +} + +static const struct wmi_device_id lenovo_wmi_hotkeys_id_table[] = { + { LENOVO_FN_KEYS_WMI_GUID, &lenovo_wmi_hotkeys_fn_keys }, + { LENOVO_ESC_WMI_GUID_YOGA3, &lenovo_wmi_hotkeys_esc }, + { LENOVO_ESC_WMI_GUID_YOGA700, &lenovo_wmi_hotkeys_esc }, + { } +}; +MODULE_DEVICE_TABLE(wmi, lenovo_wmi_hotkeys_id_table); + +static struct wmi_driver lenovo_wmi_hotkeys_driver = { + .driver = { + .name = "lenovo-wmi-hotkeys", + .probe_type = PROBE_PREFER_ASYNCHRONOUS, + }, + .id_table = lenovo_wmi_hotkeys_id_table, + .probe = lenovo_wmi_hotkeys_probe, + .notify_new = lenovo_wmi_hotkeys_notify, + .no_singleton = true, +}; +module_wmi_driver(lenovo_wmi_hotkeys_driver); + +MODULE_DESCRIPTION("Lenovo WMI hotkeys driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/platform_data/x86/lenovo-wmi-hotkeys.h b/include/linux/platform_data/x86/lenovo-wmi-hotkeys.h new file mode 100644 index 000000000000..cf07eb00f3bb --- /dev/null +++ b/include/linux/platform_data/x86/lenovo-wmi-hotkeys.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Lenovo WMI hotkeys driver, notifier interface for drivers that want to act + * on the vendor specific Fn key events before a key is reported. + */ + +#ifndef _LENOVO_WMI_HOTKEYS_H_ +#define _LENOVO_WMI_HOTKEYS_H_ + +struct device; +struct notifier_block; + +/* Code reported for the Fn+Esc event GUIDs, as ideapad-laptop always did */ +#define LENOVO_WMI_HOTKEYS_ESC_CODE 128 + +/* + * Notifier callbacks receive the WMI event code as the action and no data: + * the Fn key code from the Fn key event GUID, or LENOVO_WMI_HOTKEYS_ESC_CODE + * for the Fn+Esc event GUIDs, which carry none. A callback that handles the + * event itself returns NOTIFY_STOP to suppress the input report; NOTIFY_OK or + * NOTIFY_DONE let it through. + */ +int lenovo_wmi_hotkeys_register_notifier(struct notifier_block *nb); +int lenovo_wmi_hotkeys_unregister_notifier(struct notifier_block *nb); +int devm_lenovo_wmi_hotkeys_register_notifier(struct device *dev, + struct notifier_block *nb); + +#endif /* _LENOVO_WMI_HOTKEYS_H_ */ -- 2.56.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v2 2/3] platform: lenovo: add WMI hotkeys driver 2026-11-19 2:27 ` [PATCH v2 2/3] platform: lenovo: add WMI hotkeys driver David Cemin @ 2026-11-19 6:10 ` Armin Wolf 0 siblings, 0 replies; 27+ messages in thread From: Armin Wolf @ 2026-11-19 6:10 UTC (permalink / raw) To: David Cemin, hansg, ilpo.jarvinen Cc: mpearson-lenovo, derekjohn.clark, xy-jackie, ikepanhc, i, marco_giunta, platform-driver-x86, linux-kernel, ldemarchi Am 19.11.26 um 03:27 schrieb David Cemin: > Lenovo consumer laptops deliver their vendor specific Fn keys (microphone > mute, airplane mode, performance mode, the Smart Key, Smart Connect and > others) as WMI events on GUID 8FC0DE0C-B4E4-43FD-B0F3-8871711C1294 > instead of keyboard usages, and the Yoga 3 and Yoga 700 generations > report Fn+Esc on two dedicated event GUIDs that carry no data. On x86 > ideapad-laptop consumes these events together with the IdeaPad VPC > device; that driver depends on i8042 and the VPC, neither of which exist > on the ACPI based arm64 models, so the keys do nothing there. > > Add a small WMI driver that owns these event GUIDs on every architecture > and reports the keys through a sparse keymap, using the key codes > ideapad-laptop has used for them, including code 128 for the Fn+Esc > events. The input device keeps the ideapad-laptop name so that the > existing hwdb mappings for these keys continue to apply. > > Drivers with platform knowledge can subscribe to a notifier chain that > is called with the event code before the key is reported; a subscriber > that handles the event itself returns NOTIFY_STOP and no key is > reported. ideapad-laptop uses this for the Fn lock LED and the > performance mode button, which cycles the platform profile instead of > producing a key. > > The camera lens cover switch (events 0x0c and 0x0d) is reported as > SW_CAMERA_LENS_COVER, as ideapad-laptop does today. > > Tested on a Lenovo Yoga 9 2-in-1 16 (arm64): microphone mute, airplane > mode, the Smart Key, the Smart Connect key and the Fn+Q performance key > report input events. The Esc event GUIDs are not exposed by that > firmware, so that path is compile tested only. Reviewed-by: Armin Wolf <W_Armin@gmx.de> > Signed-off-by: David Cemin <dcemin@nvidia.com> > --- > MAINTAINERS | 7 + > drivers/platform/lenovo/Kconfig | 14 + > drivers/platform/lenovo/Makefile | 1 + > drivers/platform/lenovo/wmi-hotkeys.c | 244 ++++++++++++++++++ > .../platform_data/x86/lenovo-wmi-hotkeys.h | 28 ++ > 5 files changed, 294 insertions(+) > create mode 100644 drivers/platform/lenovo/wmi-hotkeys.c > create mode 100644 include/linux/platform_data/x86/lenovo-wmi-hotkeys.h > > diff --git a/MAINTAINERS b/MAINTAINERS > index 3b0ad5a3debe..1d5b08c033b1 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -15173,6 +15173,13 @@ F: Documentation/wmi/devices/lenovo-wmi-other.rst > F: drivers/platform/lenovo/ > F: drivers/platform/x86/lenovo/* > > +LENOVO WMI HOTKEYS DRIVER > +M: David Cemin <dcemin@nvidia.com> > +L: platform-driver-x86@vger.kernel.org > +S: Maintained > +F: drivers/platform/lenovo/wmi-hotkeys.c > +F: include/linux/platform_data/x86/lenovo-wmi-hotkeys.h > + > LENOVO WMI HOTKEY UTILITIES DRIVER > M: Jackie Dong <xy-jackie@139.com> > L: platform-driver-x86@vger.kernel.org > diff --git a/drivers/platform/lenovo/Kconfig b/drivers/platform/lenovo/Kconfig > index 8222322ca671..2810c995ee8c 100644 > --- a/drivers/platform/lenovo/Kconfig > +++ b/drivers/platform/lenovo/Kconfig > @@ -41,6 +41,20 @@ config LENOVO_WMI_HOTKEY_UTILITIES > such as LED control for audio/mic mute event for Ideapad, YOGA, XiaoXin, > Gaming, ThinkBook and so on. > > +config LENOVO_WMI_HOTKEYS > + tristate "Lenovo WMI hotkeys driver" > + depends on ACPI_WMI > + depends on INPUT > + select INPUT_SPARSEKMAP > + help > + Say Y or M here to enable the vendor specific Fn keys (microphone > + mute, airplane mode, performance mode, star key, Fn+Esc) on Lenovo > + laptops that deliver them as WMI events. ideapad-laptop subscribes > + to this driver for its Fn lock LED and performance mode handling. > + > + To compile this driver as a module, choose M here: the module will > + be called lenovo-wmi-hotkeys. > + > config LENOVO_WMI_CAMERA > tristate "Lenovo WMI Camera Button driver" > depends on ACPI_WMI > diff --git a/drivers/platform/lenovo/Makefile b/drivers/platform/lenovo/Makefile > index 1cac115dd735..d3f5e3ac14c2 100644 > --- a/drivers/platform/lenovo/Makefile > +++ b/drivers/platform/lenovo/Makefile > @@ -8,6 +8,7 @@ lenovo-target-$(CONFIG_LENOVO_WMI_HELPERS) += wmi-helpers.o > lenovo-target-$(CONFIG_LENOVO_WMI_EVENTS) += wmi-events.o > lenovo-target-$(CONFIG_LENOVO_WMI_CAPDATA) += wmi-capdata.o > lenovo-target-$(CONFIG_LENOVO_WMI_HOTKEY_UTILITIES) += wmi-hotkey-utilities.o > +lenovo-target-$(CONFIG_LENOVO_WMI_HOTKEYS) += wmi-hotkeys.o > lenovo-target-$(CONFIG_LENOVO_WMI_CAMERA) += wmi-camera.o > lenovo-target-$(CONFIG_LENOVO_WMI_GAMEZONE) += wmi-gamezone.o > lenovo-target-$(CONFIG_LENOVO_WMI_TUNING) += wmi-other.o > diff --git a/drivers/platform/lenovo/wmi-hotkeys.c b/drivers/platform/lenovo/wmi-hotkeys.c > new file mode 100644 > index 000000000000..f412652e9f72 > --- /dev/null > +++ b/drivers/platform/lenovo/wmi-hotkeys.c > @@ -0,0 +1,244 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Lenovo WMI hotkeys driver > + * > + * Lenovo consumer laptops deliver their vendor specific Fn keys (microphone > + * mute, airplane mode, performance mode, the star key and others) as WMI > + * events on GUID 8FC0DE0C-B4E4-43FD-B0F3-8871711C1294 instead of keyboard > + * usages, and the older Yoga models report Fn+Esc on two dedicated event > + * GUIDs that carry no data. This driver owns these event GUIDs on every > + * architecture and reports the keys through a sparse keymap. Drivers with > + * platform knowledge, such as ideapad-laptop, subscribe to the notifier chain > + * to act on an event and may stop the key from being reported. > + * > + * The key codes follow the mapping historically used by ideapad-laptop. > + */ > + > +#include <linux/device.h> > +#include <linux/export.h> > +#include <linux/input.h> > +#include <linux/input/sparse-keymap.h> > +#include <linux/module.h> > +#include <linux/notifier.h> > +#include <linux/platform_data/x86/lenovo-wmi-hotkeys.h> > +#include <linux/types.h> > +#include <linux/wmi.h> > + > +#include <asm/byteorder.h> > + > +#define LENOVO_FN_KEYS_WMI_GUID "8FC0DE0C-B4E4-43FD-B0F3-8871711C1294" > +/* Fn+Esc on the Yoga 3 and Yoga 700 generations, no event data */ > +#define LENOVO_ESC_WMI_GUID_YOGA3 "26CAB2E5-5CF1-46AE-AAC3-4A12B6BA50E6" > +#define LENOVO_ESC_WMI_GUID_YOGA700 "56322276-8493-4CE8-A783-98C991274F5E" > + > +/* > + * The Esc event GUIDs carry no key code; they are reported under > + * LENOVO_WMI_HOTKEYS_ESC_CODE, the code ideapad-laptop has always used for > + * them, so the existing hwdb mappings keep applying. The Fn key GUID codes > + * are all below 0x80. > + */ > + > +enum lenovo_wmi_hotkeys_type { > + LENOVO_WMI_HOTKEYS_FN_KEYS, > + LENOVO_WMI_HOTKEYS_ESC, > +}; > + > +static const enum lenovo_wmi_hotkeys_type lenovo_wmi_hotkeys_fn_keys = LENOVO_WMI_HOTKEYS_FN_KEYS; > +static const enum lenovo_wmi_hotkeys_type lenovo_wmi_hotkeys_esc = LENOVO_WMI_HOTKEYS_ESC; > + > +static BLOCKING_NOTIFIER_HEAD(lenovo_wmi_hotkeys_chain); > + > +static const struct key_entry lenovo_wmi_hotkeys_keymap[] = { > + /* Fn+Esc from the Esc event GUIDs */ > + { KE_KEY, LENOVO_WMI_HOTKEYS_ESC_CODE, { KEY_ESC } }, > + /* Customizable Lenovo Hotkey ("star" with 'S' inside) */ > + { KE_KEY, 0x01, { KEY_FAVORITES } }, > + /* Fn lock toggled on / off, handled by the firmware */ > + { KE_IGNORE, 0x02 }, > + /* Esc, handled by the firmware */ > + { KE_IGNORE, 0x03 }, > + { KE_KEY, 0x04, { KEY_SELECTIVE_SCREENSHOT } }, > + /* Lenovo Support */ > + { KE_KEY, 0x07, { KEY_HELP } }, > + /* Refresh Rate Toggle */ > + { KE_KEY, 0x0a, { KEY_REFRESH_RATE_TOGGLE } }, > + /* Camera lens cover closed / opened */ > + { KE_SW, 0x0c, .sw = { SW_CAMERA_LENS_COVER, 0 } }, > + { KE_SW, 0x0d, .sw = { SW_CAMERA_LENS_COVER, 1 } }, > + { KE_KEY, 0x0e, { KEY_PICKUP_PHONE } }, > + { KE_KEY, 0x0f, { KEY_HANGUP_PHONE } }, > + /* Refresh Rate Toggle (Fn+R) */ > + { KE_KEY, 0x10, { KEY_REFRESH_RATE_TOGGLE } }, > + /* Sound profile switch */ > + { KE_KEY, 0x12, { KEY_PROG2 } }, > + /* Dark mode toggle */ > + { KE_KEY, 0x13, { KEY_PROG1 } }, > + /* Lenovo Support */ > + { KE_KEY, 0x27, { KEY_HELP } }, > + /* Lenovo Virtual Background application */ > + { KE_KEY, 0x28, { KEY_PROG3 } }, > + { KE_KEY, 0x29, { KEY_TOUCHPAD_TOGGLE } }, > + { KE_KEY, 0x2a, { KEY_ROOT_MENU } }, > + /* Shift + PrtSc */ > + { KE_KEY, 0x2d, { KEY_SELECTIVE_SCREENSHOT } }, > + /* Performance mode toggle, Fn+Q */ > + { KE_KEY, 0x3d, { KEY_PERFORMANCE } }, > + { KE_KEY, 0x3e, { KEY_MICMUTE } }, > + { KE_KEY, 0x3f, { KEY_RFKILL } }, > + /* > + * Keyboard backlight level after Fn+Space, handled by the firmware: > + * 0x40 off, 0x41 low, 0x42 high, 0x43 also seen > + */ > + { KE_IGNORE, 0x40 }, > + { KE_IGNORE, 0x41 }, > + { KE_IGNORE, 0x42 }, > + { KE_IGNORE, 0x43 }, > + /* Star, user assignable key */ > + { KE_KEY, 0x44, { KEY_PROG1 } }, > + /* Eye care */ > + { KE_KEY, 0x45, { KEY_PROG3 } }, > + /* Mode, opens a profile chooser; the Fn+Q button cycles the profile */ > + { KE_KEY, 0x46, { KEY_PROG4 } }, > + /* Lenovo Smart Connect */ > + { KE_KEY, 0x48, { KEY_LINK_PHONE } }, > + { KE_END }, > +}; > + > +struct lenovo_wmi_hotkeys { > + struct input_dev *input; > + enum lenovo_wmi_hotkeys_type type; > +}; > + > +/** > + * lenovo_wmi_hotkeys_register_notifier() - Subscribe to the hotkey events. > + * @nb: The notifier_block to register. > + * > + * The callback runs in process context with the WMI event code as the > + * action. Return NOTIFY_STOP from the callback to consume the event. > + * > + * Return: 0 on success, or a negative error code. > + */ > +int lenovo_wmi_hotkeys_register_notifier(struct notifier_block *nb) > +{ > + return blocking_notifier_chain_register(&lenovo_wmi_hotkeys_chain, nb); > +} > +EXPORT_SYMBOL_NS_GPL(lenovo_wmi_hotkeys_register_notifier, "LENOVO_WMI_HOTKEYS"); > + > +/** > + * lenovo_wmi_hotkeys_unregister_notifier() - Unsubscribe from the hotkey events. > + * @nb: The notifier_block to unregister. > + * > + * Return: 0 on success, or a negative error code. > + */ > +int lenovo_wmi_hotkeys_unregister_notifier(struct notifier_block *nb) > +{ > + return blocking_notifier_chain_unregister(&lenovo_wmi_hotkeys_chain, nb); > +} > +EXPORT_SYMBOL_NS_GPL(lenovo_wmi_hotkeys_unregister_notifier, "LENOVO_WMI_HOTKEYS"); > > +static void devm_lenovo_wmi_hotkeys_unregister_notifier(void *data) > +{ > + lenovo_wmi_hotkeys_unregister_notifier(data); > +} > + > +/** > + * devm_lenovo_wmi_hotkeys_register_notifier() - Device managed subscription. > + * @dev: The device whose lifetime bounds the subscription. > + * @nb: The notifier_block to register. > + * > + * Return: 0 on success, or a negative error code. > + */ > +int devm_lenovo_wmi_hotkeys_register_notifier(struct device *dev, > + struct notifier_block *nb) > +{ > + int ret; > + > + ret = lenovo_wmi_hotkeys_register_notifier(nb); > + if (ret) > + return ret; > + > + return devm_add_action_or_reset(dev, devm_lenovo_wmi_hotkeys_unregister_notifier, nb); > +} > +EXPORT_SYMBOL_NS_GPL(devm_lenovo_wmi_hotkeys_register_notifier, "LENOVO_WMI_HOTKEYS"); > + > +static int lenovo_wmi_hotkeys_probe(struct wmi_device *wdev, const void *context) > +{ > + struct lenovo_wmi_hotkeys *priv; > + int ret; > + > + priv = devm_kzalloc_obj(&wdev->dev, *priv); > + if (!priv) > + return -ENOMEM; > + > + priv->type = *(const enum lenovo_wmi_hotkeys_type *)context; > + > + priv->input = devm_input_allocate_device(&wdev->dev); > + if (!priv->input) > + return -ENOMEM; > + > + /* > + * Same name as the ideapad-laptop input device so that the existing > + * hwdb keyboard mappings for these keys keep applying. > + */ > + priv->input->name = "Ideapad extra buttons"; > + priv->input->phys = priv->type == LENOVO_WMI_HOTKEYS_ESC ? "wmi/input1" : "wmi/input0"; > + priv->input->id.bustype = BUS_HOST; > + priv->input->dev.parent = &wdev->dev; > + > + ret = sparse_keymap_setup(priv->input, lenovo_wmi_hotkeys_keymap, NULL); > + if (ret) > + return ret; > + > + dev_set_drvdata(&wdev->dev, priv); > + > + return input_register_device(priv->input); > +} > + > +static void lenovo_wmi_hotkeys_notify(struct wmi_device *wdev, const struct wmi_buffer *buf) > +{ > + struct lenovo_wmi_hotkeys *priv = dev_get_drvdata(&wdev->dev); > + u32 code; > + int ret; > + > + if (priv->type == LENOVO_WMI_HOTKEYS_ESC) { > + code = LENOVO_WMI_HOTKEYS_ESC_CODE; > + } else { > + if (buf->length < sizeof(u32)) { > + dev_dbg(&wdev->dev, "short hotkey event (%zu bytes)\n", buf->length); > + return; > + } > + code = le32_to_cpup(buf->data); > + } > + > + dev_dbg(&wdev->dev, "hotkey event 0x%x\n", code); > + > + ret = blocking_notifier_call_chain(&lenovo_wmi_hotkeys_chain, code, NULL); > + if (ret & NOTIFY_STOP_MASK) > + return; > + > + if (!sparse_keymap_report_event(priv->input, code, 1, true)) > + dev_info_ratelimited(&wdev->dev, "unknown hotkey event 0x%x\n", code); > +} > + > +static const struct wmi_device_id lenovo_wmi_hotkeys_id_table[] = { > + { LENOVO_FN_KEYS_WMI_GUID, &lenovo_wmi_hotkeys_fn_keys }, > + { LENOVO_ESC_WMI_GUID_YOGA3, &lenovo_wmi_hotkeys_esc }, > + { LENOVO_ESC_WMI_GUID_YOGA700, &lenovo_wmi_hotkeys_esc }, > + { } > +}; > +MODULE_DEVICE_TABLE(wmi, lenovo_wmi_hotkeys_id_table); > + > +static struct wmi_driver lenovo_wmi_hotkeys_driver = { > + .driver = { > + .name = "lenovo-wmi-hotkeys", > + .probe_type = PROBE_PREFER_ASYNCHRONOUS, > + }, > + .id_table = lenovo_wmi_hotkeys_id_table, > + .probe = lenovo_wmi_hotkeys_probe, > + .notify_new = lenovo_wmi_hotkeys_notify, > + .no_singleton = true, > +}; > +module_wmi_driver(lenovo_wmi_hotkeys_driver); > + > +MODULE_DESCRIPTION("Lenovo WMI hotkeys driver"); > +MODULE_LICENSE("GPL"); > diff --git a/include/linux/platform_data/x86/lenovo-wmi-hotkeys.h b/include/linux/platform_data/x86/lenovo-wmi-hotkeys.h > new file mode 100644 > index 000000000000..cf07eb00f3bb > --- /dev/null > +++ b/include/linux/platform_data/x86/lenovo-wmi-hotkeys.h > @@ -0,0 +1,28 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +/* > + * Lenovo WMI hotkeys driver, notifier interface for drivers that want to act > + * on the vendor specific Fn key events before a key is reported. > + */ > + > +#ifndef _LENOVO_WMI_HOTKEYS_H_ > +#define _LENOVO_WMI_HOTKEYS_H_ > + > +struct device; > +struct notifier_block; > + > +/* Code reported for the Fn+Esc event GUIDs, as ideapad-laptop always did */ > +#define LENOVO_WMI_HOTKEYS_ESC_CODE 128 > + > +/* > + * Notifier callbacks receive the WMI event code as the action and no data: > + * the Fn key code from the Fn key event GUID, or LENOVO_WMI_HOTKEYS_ESC_CODE > + * for the Fn+Esc event GUIDs, which carry none. A callback that handles the > + * event itself returns NOTIFY_STOP to suppress the input report; NOTIFY_OK or > + * NOTIFY_DONE let it through. > + */ > +int lenovo_wmi_hotkeys_register_notifier(struct notifier_block *nb); > +int lenovo_wmi_hotkeys_unregister_notifier(struct notifier_block *nb); > +int devm_lenovo_wmi_hotkeys_register_notifier(struct device *dev, > + struct notifier_block *nb); > + > +#endif /* _LENOVO_WMI_HOTKEYS_H_ */ ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v2 3/3] platform/x86: ideapad-laptop: consume the Fn key events from the WMI hotkeys driver 2026-11-19 2:27 ` [PATCH v2 " David Cemin 2026-11-19 2:27 ` [PATCH v2 1/3] platform: lenovo: move the architecture independent WMI drivers out of x86 David Cemin 2026-11-19 2:27 ` [PATCH v2 2/3] platform: lenovo: add WMI hotkeys driver David Cemin @ 2026-11-19 2:27 ` David Cemin 2026-11-19 6:16 ` Armin Wolf 2 siblings, 1 reply; 27+ messages in thread From: David Cemin @ 2026-11-19 2:27 UTC (permalink / raw) To: hansg, ilpo.jarvinen, W_Armin Cc: mpearson-lenovo, derekjohn.clark, xy-jackie, ikepanhc, i, marco_giunta, platform-driver-x86, linux-kernel, ldemarchi ideapad-laptop binds the Fn key and Fn+Esc WMI event GUIDs itself and reports the keys through its own keymap, but the arm64 Lenovo laptops expose the Fn key GUID without the VPC device this driver is built on, and now have the lenovo-wmi-hotkeys driver reporting those keys on every architecture. Drop the WMI event driver from ideapad-laptop and subscribe to the lenovo-wmi-hotkeys notifier instead. The notifier callback keeps the two platform specific behaviours: it refreshes the Fn lock LED from the EC on every event, and on the performance button (0x3d) it cycles the platform profile through DYTC and returns NOTIFY_STOP so that no key is reported, as before. All other key codes, the Fn+Esc events and the camera lens cover switch are reported by lenovo-wmi-hotkeys with the same key codes this driver used, so the WMI entries of the keymap are dropped and ideapad-laptop no longer registers any WMI driver. ideapad-laptop now depends on LENOVO_WMI_HOTKEYS being enabled or disabled consistently; without it the Fn keys are not reported, as on a kernel without ACPI_WMI. Signed-off-by: David Cemin <dcemin@nvidia.com> --- drivers/platform/x86/lenovo/Kconfig | 1 + drivers/platform/x86/lenovo/ideapad-laptop.c | 225 ++++--------------- 2 files changed, 39 insertions(+), 187 deletions(-) diff --git a/drivers/platform/x86/lenovo/Kconfig b/drivers/platform/x86/lenovo/Kconfig index 4d9a25d0e3b5..25817e2f0e1a 100644 --- a/drivers/platform/x86/lenovo/Kconfig +++ b/drivers/platform/x86/lenovo/Kconfig @@ -12,6 +12,7 @@ config IDEAPAD_LAPTOP depends on BACKLIGHT_CLASS_DEVICE depends on ACPI_VIDEO || ACPI_VIDEO = n depends on ACPI_WMI || ACPI_WMI = n + depends on LENOVO_WMI_HOTKEYS || LENOVO_WMI_HOTKEYS = n select ACPI_PLATFORM_PROFILE select INPUT_SPARSEKMAP select NEW_LEDS diff --git a/drivers/platform/x86/lenovo/ideapad-laptop.c b/drivers/platform/x86/lenovo/ideapad-laptop.c index f9453de6df76..7461f4a59347 100644 --- a/drivers/platform/x86/lenovo/ideapad-laptop.c +++ b/drivers/platform/x86/lenovo/ideapad-laptop.c @@ -34,7 +34,7 @@ #include <linux/string_choices.h> #include <linux/sysfs.h> #include <linux/types.h> -#include <linux/wmi.h> +#include <linux/platform_data/x86/lenovo-wmi-hotkeys.h> #include "ideapad-laptop.h" #include <acpi/battery.h> @@ -185,6 +185,7 @@ struct ideapad_private { struct input_dev *inputdev; struct backlight_device *blightdev; struct ideapad_dytc_priv *dytc; + struct notifier_block hotkeys_nb; struct dentry *debug; struct acpi_battery_hook battery_hook; const struct power_supply_ext *battery_ext; @@ -1317,8 +1318,6 @@ static void ideapad_unregister_rfkill(struct ideapad_private *priv, int dev) /* * input device */ -#define IDEAPAD_WMI_KEY 0x100 - static const struct key_entry ideapad_keymap[] = { { KE_KEY, 6, { KEY_SWITCHVIDEOMODE } }, { KE_KEY, 7, { KEY_CAMERA } }, @@ -1331,65 +1330,6 @@ static const struct key_entry ideapad_keymap[] = { { KE_KEY, 65, { KEY_PROG4 } }, { KE_KEY, 66, { KEY_TOUCHPAD_OFF } }, { KE_KEY, 67, { KEY_TOUCHPAD_ON } }, - { KE_KEY, 128, { KEY_ESC } }, - - /* - * WMI keys - */ - - /* FnLock (handled by the firmware) */ - { KE_IGNORE, 0x02 | IDEAPAD_WMI_KEY }, - /* Esc (handled by the firmware) */ - { KE_IGNORE, 0x03 | IDEAPAD_WMI_KEY }, - /* Customizable Lenovo Hotkey ("star" with 'S' inside) */ - { KE_KEY, 0x01 | IDEAPAD_WMI_KEY, { KEY_FAVORITES } }, - { KE_KEY, 0x04 | IDEAPAD_WMI_KEY, { KEY_SELECTIVE_SCREENSHOT } }, - /* Lenovo Support */ - { KE_KEY, 0x07 | IDEAPAD_WMI_KEY, { KEY_HELP } }, - { KE_KEY, 0x0e | IDEAPAD_WMI_KEY, { KEY_PICKUP_PHONE } }, - { KE_KEY, 0x0f | IDEAPAD_WMI_KEY, { KEY_HANGUP_PHONE } }, - /* Refresh Rate Toggle (Fn+R) */ - { KE_KEY, 0x10 | IDEAPAD_WMI_KEY, { KEY_REFRESH_RATE_TOGGLE } }, - /* Dark mode toggle */ - { KE_KEY, 0x13 | IDEAPAD_WMI_KEY, { KEY_PROG1 } }, - /* Sound profile switch */ - { KE_KEY, 0x12 | IDEAPAD_WMI_KEY, { KEY_PROG2 } }, - /* Lenovo Virtual Background application */ - { KE_KEY, 0x28 | IDEAPAD_WMI_KEY, { KEY_PROG3 } }, - /* Lenovo Support */ - { KE_KEY, 0x27 | IDEAPAD_WMI_KEY, { KEY_HELP } }, - /* Refresh Rate Toggle */ - { KE_KEY, 0x0a | IDEAPAD_WMI_KEY, { KEY_REFRESH_RATE_TOGGLE } }, - /* Specific to some newer models */ - { KE_KEY, 0x3e | IDEAPAD_WMI_KEY, { KEY_MICMUTE } }, - { KE_KEY, 0x3f | IDEAPAD_WMI_KEY, { KEY_RFKILL } }, - /* Star- (User Assignable Key) */ - { KE_KEY, 0x44 | IDEAPAD_WMI_KEY, { KEY_PROG1 } }, - /* Eye */ - { KE_KEY, 0x45 | IDEAPAD_WMI_KEY, { KEY_PROG3 } }, - /* Lenovo Smart Connect */ - { KE_KEY, 0x48 | IDEAPAD_WMI_KEY, { KEY_LINK_PHONE } }, - /* Performance toggle also Fn+Q, handled inside ideapad_wmi_notify() */ - { KE_KEY, 0x3d | IDEAPAD_WMI_KEY, { KEY_PROG4 } }, - /* Mode, opens a profile chooser; the Fn+Q button cycles the profile */ - { KE_KEY, 0x46 | IDEAPAD_WMI_KEY, { KEY_PROG4 } }, - /* shift + prtsc */ - { KE_KEY, 0x2d | IDEAPAD_WMI_KEY, { KEY_SELECTIVE_SCREENSHOT } }, - { KE_KEY, 0x29 | IDEAPAD_WMI_KEY, { KEY_TOUCHPAD_TOGGLE } }, - { KE_KEY, 0x2a | IDEAPAD_WMI_KEY, { KEY_ROOT_MENU } }, - - /* - * WMI switches - * - * Some devices come with physical switches. Whenever a switch is - * toggled, an WMI event is emitted to inform the software about the - * switch's latest state. - */ - - /* Camera switch */ - { KE_SW, 0x0c | IDEAPAD_WMI_KEY, .sw = { SW_CAMERA_LENS_COVER, 0 } }, - { KE_SW, 0x0d | IDEAPAD_WMI_KEY, .sw = { SW_CAMERA_LENS_COVER, 1 } }, - { KE_END }, }; @@ -2297,123 +2237,52 @@ static int ideapad_check_features(struct ideapad_private *priv) return 0; } -#if IS_ENABLED(CONFIG_ACPI_WMI) +#if IS_ENABLED(CONFIG_LENOVO_WMI_HOTKEYS) /* - * WMI driver + * The vendor specific Fn keys arrive as WMI events owned by the Lenovo WMI + * hotkeys driver, which reports them as input events. Subscribe to act on the + * ones that touch the VPC state: the Fn lock LED and the performance mode + * button, which cycles the platform profile through DYTC instead of + * reporting a key. */ -enum ideapad_wmi_event_type { - IDEAPAD_WMI_EVENT_ESC, - IDEAPAD_WMI_EVENT_FN_KEYS, -}; - -struct ideapad_wmi_private { - enum ideapad_wmi_event_type event; -}; - -static int ideapad_wmi_probe(struct wmi_device *wdev, const void *context) -{ - struct ideapad_wmi_private *wpriv; - - wpriv = devm_kzalloc_obj(&wdev->dev, *wpriv); - if (!wpriv) - return -ENOMEM; - - *wpriv = *(const struct ideapad_wmi_private *)context; - - dev_set_drvdata(&wdev->dev, wpriv); - return 0; -} - -static void ideapad_wmi_notify(struct wmi_device *wdev, union acpi_object *data) +static int ideapad_hotkeys_notify(struct notifier_block *nb, unsigned long code, + void *data) { - struct ideapad_wmi_private *wpriv = dev_get_drvdata(&wdev->dev); - struct ideapad_private *priv; - - guard(mutex)(&ideapad_shared_mutex); - - priv = ideapad_shared; - if (!priv) - return; + struct ideapad_private *priv = container_of(nb, struct ideapad_private, hotkeys_nb); - switch (wpriv->event) { - case IDEAPAD_WMI_EVENT_ESC: - ideapad_input_report(priv, 128); - break; - case IDEAPAD_WMI_EVENT_FN_KEYS: - if (priv->features.set_fn_lock_led) { - int brightness = ideapad_fn_lock_get(priv); + if (priv->features.set_fn_lock_led) { + int brightness = ideapad_fn_lock_get(priv); - if (brightness >= 0) { - ideapad_fn_lock_set(priv, brightness); - ideapad_fn_lock_led_notify(priv, brightness); - } + if (brightness >= 0) { + ideapad_fn_lock_set(priv, brightness); + ideapad_fn_lock_led_notify(priv, brightness); } - - if (data->type != ACPI_TYPE_INTEGER) { - dev_warn(&wdev->dev, - "WMI event data is not an integer\n"); - break; - } - - dev_dbg(&wdev->dev, "WMI fn-key event: 0x%llx\n", - data->integer.value); - - /* performance button triggered by 0x3d */ - if (data->integer.value == 0x3d && priv->dytc) { - platform_profile_cycle(); - break; - } - - /* 0x02 FnLock, 0x03 Esc */ - if (data->integer.value == 0x02 || data->integer.value == 0x03) - ideapad_fn_lock_led_notify(priv, data->integer.value == 0x02); - - ideapad_input_report(priv, - data->integer.value | IDEAPAD_WMI_KEY); - - break; } -} - -static const struct ideapad_wmi_private ideapad_wmi_context_esc = { - .event = IDEAPAD_WMI_EVENT_ESC -}; -static const struct ideapad_wmi_private ideapad_wmi_context_fn_keys = { - .event = IDEAPAD_WMI_EVENT_FN_KEYS -}; + dev_dbg(&priv->platform_device->dev, "WMI fn-key event: 0x%lx\n", code); -static const struct wmi_device_id ideapad_wmi_ids[] = { - { "26CAB2E5-5CF1-46AE-AAC3-4A12B6BA50E6", &ideapad_wmi_context_esc }, /* Yoga 3 */ - { "56322276-8493-4CE8-A783-98C991274F5E", &ideapad_wmi_context_esc }, /* Yoga 700 */ - { "8FC0DE0C-B4E4-43FD-B0F3-8871711C1294", &ideapad_wmi_context_fn_keys }, /* Legion 5 */ - {}, -}; -MODULE_DEVICE_TABLE(wmi, ideapad_wmi_ids); + /* performance button triggered by 0x3d */ + if (code == 0x3d && priv->dytc) { + platform_profile_cycle(); + return NOTIFY_STOP; + } -static struct wmi_driver ideapad_wmi_driver = { - .driver = { - .name = "ideapad_wmi", - }, - .id_table = ideapad_wmi_ids, - .min_event_size = sizeof(u32), - .probe = ideapad_wmi_probe, - .notify = ideapad_wmi_notify, -}; + /* 0x02 FnLock, 0x03 Esc */ + if (code == 0x02 || code == 0x03) + ideapad_fn_lock_led_notify(priv, code == 0x02); -static int ideapad_wmi_driver_register(void) -{ - return wmi_driver_register(&ideapad_wmi_driver); + return NOTIFY_OK; } -static void ideapad_wmi_driver_unregister(void) +static int ideapad_hotkeys_register(struct ideapad_private *priv) { - return wmi_driver_unregister(&ideapad_wmi_driver); -} + priv->hotkeys_nb.notifier_call = ideapad_hotkeys_notify; + return devm_lenovo_wmi_hotkeys_register_notifier(&priv->platform_device->dev, + &priv->hotkeys_nb); +} #else -static inline int ideapad_wmi_driver_register(void) { return 0; } -static inline void ideapad_wmi_driver_unregister(void) { } +static inline int ideapad_hotkeys_register(struct ideapad_private *priv) { return 0; } #endif /* @@ -2496,6 +2365,10 @@ static int ideapad_acpi_add(struct platform_device *pdev) dev_info(&pdev->dev, "DYTC interface is not available\n"); } + err = ideapad_hotkeys_register(priv); + if (err) + dev_warn(&pdev->dev, "Could not subscribe to the WMI hotkey events: %d\n", err); + if (acpi_video_get_backlight_type() == acpi_backlight_vendor) { err = ideapad_backlight_init(priv); if (err && err != -ENODEV) @@ -2600,31 +2473,9 @@ static struct platform_driver ideapad_acpi_driver = { }, }; -static int __init ideapad_laptop_init(void) -{ - int err; - - err = ideapad_wmi_driver_register(); - if (err) - return err; - - err = platform_driver_register(&ideapad_acpi_driver); - if (err) { - ideapad_wmi_driver_unregister(); - return err; - } - - return 0; -} -module_init(ideapad_laptop_init) - -static void __exit ideapad_laptop_exit(void) -{ - platform_driver_unregister(&ideapad_acpi_driver); - ideapad_wmi_driver_unregister(); -} -module_exit(ideapad_laptop_exit) +module_platform_driver(ideapad_acpi_driver); MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>"); MODULE_DESCRIPTION("IdeaPad ACPI Extras"); +MODULE_IMPORT_NS("LENOVO_WMI_HOTKEYS"); MODULE_LICENSE("GPL"); -- 2.56.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v2 3/3] platform/x86: ideapad-laptop: consume the Fn key events from the WMI hotkeys driver 2026-11-19 2:27 ` [PATCH v2 3/3] platform/x86: ideapad-laptop: consume the Fn key events from the " David Cemin @ 2026-11-19 6:16 ` Armin Wolf 0 siblings, 0 replies; 27+ messages in thread From: Armin Wolf @ 2026-11-19 6:16 UTC (permalink / raw) To: David Cemin, hansg, ilpo.jarvinen Cc: mpearson-lenovo, derekjohn.clark, xy-jackie, ikepanhc, i, marco_giunta, platform-driver-x86, linux-kernel, ldemarchi Am 19.11.26 um 03:27 schrieb David Cemin: > ideapad-laptop binds the Fn key and Fn+Esc WMI event GUIDs itself and > reports the keys through its own keymap, but the arm64 Lenovo laptops > expose the Fn key GUID without the VPC device this driver is built on, > and now have the lenovo-wmi-hotkeys driver reporting those keys on every > architecture. > > Drop the WMI event driver from ideapad-laptop and subscribe to the > lenovo-wmi-hotkeys notifier instead. The notifier callback keeps the two > platform specific behaviours: it refreshes the Fn lock LED from the EC > on every event, and on the performance button (0x3d) it cycles the > platform profile through DYTC and returns NOTIFY_STOP so that no key is > reported, as before. All other key codes, the Fn+Esc events and the > camera lens cover switch are reported by lenovo-wmi-hotkeys with the > same key codes this driver used, so the WMI entries of the keymap are > dropped and ideapad-laptop no longer registers any WMI driver. > > ideapad-laptop now depends on LENOVO_WMI_HOTKEYS being enabled or > disabled consistently; without it the Fn keys are not reported, as on a > kernel without ACPI_WMI. > > Signed-off-by: David Cemin <dcemin@nvidia.com> > --- > drivers/platform/x86/lenovo/Kconfig | 1 + > drivers/platform/x86/lenovo/ideapad-laptop.c | 225 ++++--------------- > 2 files changed, 39 insertions(+), 187 deletions(-) > > diff --git a/drivers/platform/x86/lenovo/Kconfig b/drivers/platform/x86/lenovo/Kconfig > index 4d9a25d0e3b5..25817e2f0e1a 100644 > --- a/drivers/platform/x86/lenovo/Kconfig > +++ b/drivers/platform/x86/lenovo/Kconfig > @@ -12,6 +12,7 @@ config IDEAPAD_LAPTOP > depends on BACKLIGHT_CLASS_DEVICE > depends on ACPI_VIDEO || ACPI_VIDEO = n > depends on ACPI_WMI || ACPI_WMI = n Hi, i think you can drop the dependency on ACPI_WMI here now, because LENOVO_WMI_HOTKEYS already takes care of that. With this being addressed: Reviewed-by: Armin Wolf <W_Armin@gmx.de> > + depends on LENOVO_WMI_HOTKEYS || LENOVO_WMI_HOTKEYS = n > select ACPI_PLATFORM_PROFILE > select INPUT_SPARSEKMAP > select NEW_LEDS > diff --git a/drivers/platform/x86/lenovo/ideapad-laptop.c b/drivers/platform/x86/lenovo/ideapad-laptop.c > index f9453de6df76..7461f4a59347 100644 > --- a/drivers/platform/x86/lenovo/ideapad-laptop.c > +++ b/drivers/platform/x86/lenovo/ideapad-laptop.c > @@ -34,7 +34,7 @@ > #include <linux/string_choices.h> > #include <linux/sysfs.h> > #include <linux/types.h> > -#include <linux/wmi.h> > +#include <linux/platform_data/x86/lenovo-wmi-hotkeys.h> > #include "ideapad-laptop.h" > > #include <acpi/battery.h> > @@ -185,6 +185,7 @@ struct ideapad_private { > struct input_dev *inputdev; > struct backlight_device *blightdev; > struct ideapad_dytc_priv *dytc; > + struct notifier_block hotkeys_nb; > struct dentry *debug; > struct acpi_battery_hook battery_hook; > const struct power_supply_ext *battery_ext; > @@ -1317,8 +1318,6 @@ static void ideapad_unregister_rfkill(struct ideapad_private *priv, int dev) > /* > * input device > */ > -#define IDEAPAD_WMI_KEY 0x100 > - > static const struct key_entry ideapad_keymap[] = { > { KE_KEY, 6, { KEY_SWITCHVIDEOMODE } }, > { KE_KEY, 7, { KEY_CAMERA } }, > @@ -1331,65 +1330,6 @@ static const struct key_entry ideapad_keymap[] = { > { KE_KEY, 65, { KEY_PROG4 } }, > { KE_KEY, 66, { KEY_TOUCHPAD_OFF } }, > { KE_KEY, 67, { KEY_TOUCHPAD_ON } }, > - { KE_KEY, 128, { KEY_ESC } }, > - > - /* > - * WMI keys > - */ > - > - /* FnLock (handled by the firmware) */ > - { KE_IGNORE, 0x02 | IDEAPAD_WMI_KEY }, > - /* Esc (handled by the firmware) */ > - { KE_IGNORE, 0x03 | IDEAPAD_WMI_KEY }, > - /* Customizable Lenovo Hotkey ("star" with 'S' inside) */ > - { KE_KEY, 0x01 | IDEAPAD_WMI_KEY, { KEY_FAVORITES } }, > - { KE_KEY, 0x04 | IDEAPAD_WMI_KEY, { KEY_SELECTIVE_SCREENSHOT } }, > - /* Lenovo Support */ > - { KE_KEY, 0x07 | IDEAPAD_WMI_KEY, { KEY_HELP } }, > - { KE_KEY, 0x0e | IDEAPAD_WMI_KEY, { KEY_PICKUP_PHONE } }, > - { KE_KEY, 0x0f | IDEAPAD_WMI_KEY, { KEY_HANGUP_PHONE } }, > - /* Refresh Rate Toggle (Fn+R) */ > - { KE_KEY, 0x10 | IDEAPAD_WMI_KEY, { KEY_REFRESH_RATE_TOGGLE } }, > - /* Dark mode toggle */ > - { KE_KEY, 0x13 | IDEAPAD_WMI_KEY, { KEY_PROG1 } }, > - /* Sound profile switch */ > - { KE_KEY, 0x12 | IDEAPAD_WMI_KEY, { KEY_PROG2 } }, > - /* Lenovo Virtual Background application */ > - { KE_KEY, 0x28 | IDEAPAD_WMI_KEY, { KEY_PROG3 } }, > - /* Lenovo Support */ > - { KE_KEY, 0x27 | IDEAPAD_WMI_KEY, { KEY_HELP } }, > - /* Refresh Rate Toggle */ > - { KE_KEY, 0x0a | IDEAPAD_WMI_KEY, { KEY_REFRESH_RATE_TOGGLE } }, > - /* Specific to some newer models */ > - { KE_KEY, 0x3e | IDEAPAD_WMI_KEY, { KEY_MICMUTE } }, > - { KE_KEY, 0x3f | IDEAPAD_WMI_KEY, { KEY_RFKILL } }, > - /* Star- (User Assignable Key) */ > - { KE_KEY, 0x44 | IDEAPAD_WMI_KEY, { KEY_PROG1 } }, > - /* Eye */ > - { KE_KEY, 0x45 | IDEAPAD_WMI_KEY, { KEY_PROG3 } }, > - /* Lenovo Smart Connect */ > - { KE_KEY, 0x48 | IDEAPAD_WMI_KEY, { KEY_LINK_PHONE } }, > - /* Performance toggle also Fn+Q, handled inside ideapad_wmi_notify() */ > - { KE_KEY, 0x3d | IDEAPAD_WMI_KEY, { KEY_PROG4 } }, > - /* Mode, opens a profile chooser; the Fn+Q button cycles the profile */ > - { KE_KEY, 0x46 | IDEAPAD_WMI_KEY, { KEY_PROG4 } }, > - /* shift + prtsc */ > - { KE_KEY, 0x2d | IDEAPAD_WMI_KEY, { KEY_SELECTIVE_SCREENSHOT } }, > - { KE_KEY, 0x29 | IDEAPAD_WMI_KEY, { KEY_TOUCHPAD_TOGGLE } }, > - { KE_KEY, 0x2a | IDEAPAD_WMI_KEY, { KEY_ROOT_MENU } }, > - > - /* > - * WMI switches > - * > - * Some devices come with physical switches. Whenever a switch is > - * toggled, an WMI event is emitted to inform the software about the > - * switch's latest state. > - */ > - > - /* Camera switch */ > - { KE_SW, 0x0c | IDEAPAD_WMI_KEY, .sw = { SW_CAMERA_LENS_COVER, 0 } }, > - { KE_SW, 0x0d | IDEAPAD_WMI_KEY, .sw = { SW_CAMERA_LENS_COVER, 1 } }, > - > { KE_END }, > }; > > @@ -2297,123 +2237,52 @@ static int ideapad_check_features(struct ideapad_private *priv) > return 0; > } > > -#if IS_ENABLED(CONFIG_ACPI_WMI) > +#if IS_ENABLED(CONFIG_LENOVO_WMI_HOTKEYS) > /* > - * WMI driver > + * The vendor specific Fn keys arrive as WMI events owned by the Lenovo WMI > + * hotkeys driver, which reports them as input events. Subscribe to act on the > + * ones that touch the VPC state: the Fn lock LED and the performance mode > + * button, which cycles the platform profile through DYTC instead of > + * reporting a key. > */ > -enum ideapad_wmi_event_type { > - IDEAPAD_WMI_EVENT_ESC, > - IDEAPAD_WMI_EVENT_FN_KEYS, > -}; > - > -struct ideapad_wmi_private { > - enum ideapad_wmi_event_type event; > -}; > - > -static int ideapad_wmi_probe(struct wmi_device *wdev, const void *context) > -{ > - struct ideapad_wmi_private *wpriv; > - > - wpriv = devm_kzalloc_obj(&wdev->dev, *wpriv); > - if (!wpriv) > - return -ENOMEM; > - > - *wpriv = *(const struct ideapad_wmi_private *)context; > - > - dev_set_drvdata(&wdev->dev, wpriv); > - return 0; > -} > - > -static void ideapad_wmi_notify(struct wmi_device *wdev, union acpi_object *data) > +static int ideapad_hotkeys_notify(struct notifier_block *nb, unsigned long code, > + void *data) > { > - struct ideapad_wmi_private *wpriv = dev_get_drvdata(&wdev->dev); > - struct ideapad_private *priv; > - > - guard(mutex)(&ideapad_shared_mutex); > - > - priv = ideapad_shared; > - if (!priv) > - return; > + struct ideapad_private *priv = container_of(nb, struct ideapad_private, hotkeys_nb); > > - switch (wpriv->event) { > - case IDEAPAD_WMI_EVENT_ESC: > - ideapad_input_report(priv, 128); > - break; > - case IDEAPAD_WMI_EVENT_FN_KEYS: > - if (priv->features.set_fn_lock_led) { > - int brightness = ideapad_fn_lock_get(priv); > + if (priv->features.set_fn_lock_led) { > + int brightness = ideapad_fn_lock_get(priv); > > - if (brightness >= 0) { > - ideapad_fn_lock_set(priv, brightness); > - ideapad_fn_lock_led_notify(priv, brightness); > - } > + if (brightness >= 0) { > + ideapad_fn_lock_set(priv, brightness); > + ideapad_fn_lock_led_notify(priv, brightness); > } > - > - if (data->type != ACPI_TYPE_INTEGER) { > - dev_warn(&wdev->dev, > - "WMI event data is not an integer\n"); > - break; > - } > - > - dev_dbg(&wdev->dev, "WMI fn-key event: 0x%llx\n", > - data->integer.value); > - > - /* performance button triggered by 0x3d */ > - if (data->integer.value == 0x3d && priv->dytc) { > - platform_profile_cycle(); > - break; > - } > - > - /* 0x02 FnLock, 0x03 Esc */ > - if (data->integer.value == 0x02 || data->integer.value == 0x03) > - ideapad_fn_lock_led_notify(priv, data->integer.value == 0x02); > - > - ideapad_input_report(priv, > - data->integer.value | IDEAPAD_WMI_KEY); > - > - break; > } > -} > - > -static const struct ideapad_wmi_private ideapad_wmi_context_esc = { > - .event = IDEAPAD_WMI_EVENT_ESC > -}; > > -static const struct ideapad_wmi_private ideapad_wmi_context_fn_keys = { > - .event = IDEAPAD_WMI_EVENT_FN_KEYS > -}; > + dev_dbg(&priv->platform_device->dev, "WMI fn-key event: 0x%lx\n", code); > > -static const struct wmi_device_id ideapad_wmi_ids[] = { > - { "26CAB2E5-5CF1-46AE-AAC3-4A12B6BA50E6", &ideapad_wmi_context_esc }, /* Yoga 3 */ > - { "56322276-8493-4CE8-A783-98C991274F5E", &ideapad_wmi_context_esc }, /* Yoga 700 */ > - { "8FC0DE0C-B4E4-43FD-B0F3-8871711C1294", &ideapad_wmi_context_fn_keys }, /* Legion 5 */ > - {}, > -}; > -MODULE_DEVICE_TABLE(wmi, ideapad_wmi_ids); > + /* performance button triggered by 0x3d */ > + if (code == 0x3d && priv->dytc) { > + platform_profile_cycle(); > + return NOTIFY_STOP; > + } > > -static struct wmi_driver ideapad_wmi_driver = { > - .driver = { > - .name = "ideapad_wmi", > - }, > - .id_table = ideapad_wmi_ids, > - .min_event_size = sizeof(u32), > - .probe = ideapad_wmi_probe, > - .notify = ideapad_wmi_notify, > -}; > + /* 0x02 FnLock, 0x03 Esc */ > + if (code == 0x02 || code == 0x03) > + ideapad_fn_lock_led_notify(priv, code == 0x02); > > -static int ideapad_wmi_driver_register(void) > -{ > - return wmi_driver_register(&ideapad_wmi_driver); > + return NOTIFY_OK; > } > > -static void ideapad_wmi_driver_unregister(void) > +static int ideapad_hotkeys_register(struct ideapad_private *priv) > { > - return wmi_driver_unregister(&ideapad_wmi_driver); > -} > + priv->hotkeys_nb.notifier_call = ideapad_hotkeys_notify; > > + return devm_lenovo_wmi_hotkeys_register_notifier(&priv->platform_device->dev, > + &priv->hotkeys_nb); > +} > #else > -static inline int ideapad_wmi_driver_register(void) { return 0; } > -static inline void ideapad_wmi_driver_unregister(void) { } > +static inline int ideapad_hotkeys_register(struct ideapad_private *priv) { return 0; } > #endif > > /* > @@ -2496,6 +2365,10 @@ static int ideapad_acpi_add(struct platform_device *pdev) > dev_info(&pdev->dev, "DYTC interface is not available\n"); > } > > + err = ideapad_hotkeys_register(priv); > + if (err) > + dev_warn(&pdev->dev, "Could not subscribe to the WMI hotkey events: %d\n", err); > + > if (acpi_video_get_backlight_type() == acpi_backlight_vendor) { > err = ideapad_backlight_init(priv); > if (err && err != -ENODEV) > @@ -2600,31 +2473,9 @@ static struct platform_driver ideapad_acpi_driver = { > }, > }; > > -static int __init ideapad_laptop_init(void) > -{ > - int err; > - > - err = ideapad_wmi_driver_register(); > - if (err) > - return err; > - > - err = platform_driver_register(&ideapad_acpi_driver); > - if (err) { > - ideapad_wmi_driver_unregister(); > - return err; > - } > - > - return 0; > -} > -module_init(ideapad_laptop_init) > - > -static void __exit ideapad_laptop_exit(void) > -{ > - platform_driver_unregister(&ideapad_acpi_driver); > - ideapad_wmi_driver_unregister(); > -} > -module_exit(ideapad_laptop_exit) > +module_platform_driver(ideapad_acpi_driver); > > MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>"); > MODULE_DESCRIPTION("IdeaPad ACPI Extras"); > +MODULE_IMPORT_NS("LENOVO_WMI_HOTKEYS"); > MODULE_LICENSE("GPL"); ^ permalink raw reply [flat|nested] 27+ messages in thread
end of thread, other threads:[~2026-11-19 6:16 UTC | newest] Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2026-11-13 22:27 [RFC PATCH 0/3] platform: lenovo: architecture independent home for the Lenovo WMI drivers David Cemin 2026-11-13 22:27 ` [RFC PATCH 1/3] platform: lenovo: move the architecture independent WMI drivers out of x86 David Cemin 2026-11-15 21:50 ` Mark Pearson 2026-11-16 4:42 ` David Cemin 2026-11-16 16:59 ` Mark Pearson 2026-11-17 2:27 ` Jackie Dong 2026-11-13 22:27 ` [RFC PATCH 2/3] platform: lenovo: add WMI hotkeys driver David Cemin 2026-11-15 16:12 ` Armin Wolf 2026-11-16 4:42 ` David Cemin 2026-11-17 1:39 ` Armin Wolf 2026-11-16 10:55 ` Marco Giunta 2026-11-17 3:27 ` Jackie Dong 2026-11-19 2:29 ` David Cemin 2026-11-13 22:27 ` [RFC PATCH 3/3] platform/x86: ideapad-laptop: do not bind the WMI event devices without the VPC David Cemin 2026-11-15 15:33 ` [RFC PATCH 0/3] platform: lenovo: architecture independent home for the Lenovo WMI drivers Hans de Goede 2026-11-15 16:02 ` Armin Wolf 2026-11-15 18:02 ` Hans de Goede 2026-11-15 20:10 ` Hans de Goede 2026-11-15 20:12 ` Hans de Goede 2026-11-15 21:48 ` Mark Pearson 2026-11-16 4:42 ` David Cemin 2026-11-19 2:27 ` [PATCH v2 " David Cemin 2026-11-19 2:27 ` [PATCH v2 1/3] platform: lenovo: move the architecture independent WMI drivers out of x86 David Cemin 2026-11-19 2:27 ` [PATCH v2 2/3] platform: lenovo: add WMI hotkeys driver David Cemin 2026-11-19 6:10 ` Armin Wolf 2026-11-19 2:27 ` [PATCH v2 3/3] platform/x86: ideapad-laptop: consume the Fn key events from the " David Cemin 2026-11-19 6:16 ` Armin Wolf
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®