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 3/3] platform/x86: ideapad-laptop: consume the Fn key events from the WMI hotkeys driver
Date: Thu, 19 Nov 2026 07:16:07 +0100 [thread overview]
Message-ID: <fd00719e-930e-4f6d-b642-ec3430491fb7@gmx.de> (raw)
In-Reply-To: <20261119022719.3089229-4-dcemin@nvidia.com>
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");
prev parent reply other threads:[~2026-11-19 6:16 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
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 message]
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=fd00719e-930e-4f6d-b642-ec3430491fb7@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®