From: Armin Wolf <W_Armin@gmx.de>
To: David Cemin <dcemin@nvidia.com>,
hansg@kernel.org, ilpo.jarvinen@linux.intel.com
Cc: mpearson-lenovo@squebb.ca, derekjohn.clark@gmail.com,
xy-jackie@139.com, ikepanhc@gmail.com, i@rong.moe,
marco_giunta@outlook.it, platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org, ldemarchi@nvidia.com
Subject: Re: [PATCH v2 2/3] platform: lenovo: add WMI hotkeys driver
Date: Thu, 19 Nov 2026 07:10:39 +0100 [thread overview]
Message-ID: <5a959dbd-b8a9-41e9-b829-5ce3a425988d@gmx.de> (raw)
In-Reply-To: <20261119022719.3089229-3-dcemin@nvidia.com>
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_ */
next prev parent reply other threads:[~2026-11-19 6:10 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5a959dbd-b8a9-41e9-b829-5ce3a425988d@gmx.de \
--to=w_armin@gmx.de \
--cc=dcemin@nvidia.com \
--cc=derekjohn.clark@gmail.com \
--cc=hansg@kernel.org \
--cc=i@rong.moe \
--cc=ikepanhc@gmail.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=ldemarchi@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=marco_giunta@outlook.it \
--cc=mpearson-lenovo@squebb.ca \
--cc=platform-driver-x86@vger.kernel.org \
--cc=xy-jackie@139.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is 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®