[PATCH] Added support for a some new buttons in ideapad-laptop driver Added entries to unsuported wmi codes in ideapad_keymap[] and one check in wmi_nofify in order to get wmi code 0x13d to trigger platform_profile_cycle

Gašper Nemgar posted 1 patch 9 months ago
drivers/platform/x86/ideapad-laptop.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
[PATCH] Added support for a some new buttons in ideapad-laptop driver Added entries to unsuported wmi codes in ideapad_keymap[] and one check in wmi_nofify in order to get wmi code 0x13d to trigger platform_profile_cycle
Posted by Gašper Nemgar 9 months ago
Signed-off-by: Gašper Nemgar <gasper.nemgar@gmail.com>"
---
 drivers/platform/x86/ideapad-laptop.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index 30bd366d7..a03377d87 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -1308,6 +1308,16 @@ static const struct key_entry ideapad_keymap[] = {
 	/* Specific to some newer models */
 	{ KE_KEY,	0x3e | IDEAPAD_WMI_KEY, { KEY_MICMUTE } },
 	{ KE_KEY,	0x3f | IDEAPAD_WMI_KEY, { KEY_RFKILL } },
+	/* Star- (User Asignable Key) */
+	{ KE_KEY,	0x44 | IDEAPAD_WMI_KEY, { KEY_PROG1 } },
+	/* Eye */
+	{ KE_KEY,	0x45 | IDEAPAD_WMI_KEY, { KEY_BRIGHTNESS_CYCLE } },
+	/* Performance toggle also Fn+Q */
+	{ KE_KEY,	0x3d | IDEAPAD_WMI_KEY, { KEY_PROG4 } },
+	/* shift + prtsc */
+	{ KE_KEY,   0x2d | IDEAPAD_WMI_KEY, { KEY_CUT } },
+	{ KE_KEY,   0x29 | IDEAPAD_WMI_KEY, { KEY_TOUCHPAD_TOGGLE } },
+	{ KE_KEY,   0x2a | IDEAPAD_WMI_KEY, { KEY_ROOT_MENU } },
 
 	{ KE_END },
 };
@@ -2093,6 +2103,12 @@ static void ideapad_wmi_notify(struct wmi_device *wdev, union acpi_object *data)
 
 		dev_dbg(&wdev->dev, "WMI fn-key event: 0x%llx\n",
 			data->integer.value);
+				
+		/* performance button triggered by  ...  */
+		if ((data->integer.value | IDEAPAD_WMI_KEY) == 0x13d ) {
+			platform_profile_cycle();
+			break;
+		}
 
 		/* 0x02 FnLock, 0x03 Esc */
 		if (data->integer.value == 0x02 || data->integer.value == 0x03)
-- 
2.34.1

Re: [PATCH] Added support for a some new buttons in ideapad-laptop driver Added entries to unsuported wmi codes in ideapad_keymap[] and one check in wmi_nofify in order to get wmi code 0x13d to trigger platform_profile_cycle
Posted by Hans de Goede 8 months, 3 weeks ago
Hi Gašper,

Than you for the new version.

On 21-Mar-25 09:30, Gašper Nemgar wrote:
> Signed-off-by: Gašper Nemgar <gasper.nemgar@gmail.com>"
> ---
>  drivers/platform/x86/ideapad-laptop.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
> index 30bd366d7..a03377d87 100644
> --- a/drivers/platform/x86/ideapad-laptop.c
> +++ b/drivers/platform/x86/ideapad-laptop.c
> @@ -1308,6 +1308,16 @@ static const struct key_entry ideapad_keymap[] = {
>  	/* Specific to some newer models */
>  	{ KE_KEY,	0x3e | IDEAPAD_WMI_KEY, { KEY_MICMUTE } },
>  	{ KE_KEY,	0x3f | IDEAPAD_WMI_KEY, { KEY_RFKILL } },
> +	/* Star- (User Asignable Key) */
> +	{ KE_KEY,	0x44 | IDEAPAD_WMI_KEY, { KEY_PROG1 } },

Still ack,

> +	/* Eye */
> +	{ KE_KEY,	0x45 | 	, { KEY_BRIGHTNESS_CYCLE } },

According to:

https://ardes.bg/uploads/original/lenovo-yoga-9-2-in-1-14-g9-550178.jpg

there already is brightness up/down on Fn + F5 / Fn + F6, so I would just
map this to a free (not used elsewhere on the keyboard) KEY_PROG#.

> +	/* Performance toggle also Fn+Q */
> +	{ KE_KEY,	0x3d | IDEAPAD_WMI_KEY, { KEY_PROG4 } },

I would make this KE_IGNORE with a comment that this is handled
inside the driver, following how this is done for the 0x02 / 0x03 keycodes:

        /* FnLock (handled by the firmware) */
        { KE_IGNORE,    0x02 | IDEAPAD_WMI_KEY },
        /* Esc (handled by the firmware) */
        { KE_IGNORE,    0x03 | IDEAPAD_WMI_KEY },


> +	/* shift + prtsc */
> +	{ KE_KEY,   0x2d | IDEAPAD_WMI_KEY, { KEY_CUT } },
> +	{ KE_KEY,   0x29 | IDEAPAD_WMI_KEY, { KEY_TOUCHPAD_TOGGLE } },
> +	{ KE_KEY,   0x2a | IDEAPAD_WMI_KEY, { KEY_ROOT_MENU } },
>  
>  	{ KE_END },
>  };
> @@ -2093,6 +2103,12 @@ static void ideapad_wmi_notify(struct wmi_device *wdev, union acpi_object *data)
>  
>  		dev_dbg(&wdev->dev, "WMI fn-key event: 0x%llx\n",
>  			data->integer.value);
> +				
> +		/* performance button triggered by  ...  */
> +		if ((data->integer.value | IDEAPAD_WMI_KEY) == 0x13d ) {

You can drop the  | IDEAPAD_WMI_KEY here and just write:

		if (data->integer.value == 0x3d) {

> +			platform_profile_cycle();
> +			break;
> +		}
>  
>  		/* 0x02 FnLock, 0x03 Esc */
>  		if (data->integer.value == 0x02 || data->integer.value == 0x03)

Regards,

Hans


Re: [PATCH] Added support for a some new buttons in ideapad-laptop driver Added entries to unsuported wmi codes in ideapad_keymap[] and one check in wmi_nofify in order to get wmi code 0x13d to trigger platform_profile_cycle
Posted by Ilpo Järvinen 9 months ago
On Fri, 21 Mar 2025, Gašper Nemgar wrote:

Hi Gasper,

Thanks for the patch. I think the changelog text got messed up during send 
as it should here, not in the subject.

Also please change "Added support" to "Add support", add the correct 
prefix into the shortlog (the line in Subject), and add parenthesis after 
functions in the description.

-- 
 i.

> Signed-off-by: Gašper Nemgar <gasper.nemgar@gmail.com>"
> ---
>  drivers/platform/x86/ideapad-laptop.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
> index 30bd366d7..a03377d87 100644
> --- a/drivers/platform/x86/ideapad-laptop.c
> +++ b/drivers/platform/x86/ideapad-laptop.c
> @@ -1308,6 +1308,16 @@ static const struct key_entry ideapad_keymap[] = {
>  	/* Specific to some newer models */
>  	{ KE_KEY,	0x3e | IDEAPAD_WMI_KEY, { KEY_MICMUTE } },
>  	{ KE_KEY,	0x3f | IDEAPAD_WMI_KEY, { KEY_RFKILL } },
> +	/* Star- (User Asignable Key) */
> +	{ KE_KEY,	0x44 | IDEAPAD_WMI_KEY, { KEY_PROG1 } },
> +	/* Eye */
> +	{ KE_KEY,	0x45 | IDEAPAD_WMI_KEY, { KEY_BRIGHTNESS_CYCLE } },
> +	/* Performance toggle also Fn+Q */
> +	{ KE_KEY,	0x3d | IDEAPAD_WMI_KEY, { KEY_PROG4 } },
> +	/* shift + prtsc */
> +	{ KE_KEY,   0x2d | IDEAPAD_WMI_KEY, { KEY_CUT } },
> +	{ KE_KEY,   0x29 | IDEAPAD_WMI_KEY, { KEY_TOUCHPAD_TOGGLE } },
> +	{ KE_KEY,   0x2a | IDEAPAD_WMI_KEY, { KEY_ROOT_MENU } },
>  
>  	{ KE_END },
>  };
> @@ -2093,6 +2103,12 @@ static void ideapad_wmi_notify(struct wmi_device *wdev, union acpi_object *data)
>  
>  		dev_dbg(&wdev->dev, "WMI fn-key event: 0x%llx\n",
>  			data->integer.value);
> +				
> +		/* performance button triggered by  ...  */
> +		if ((data->integer.value | IDEAPAD_WMI_KEY) == 0x13d ) {
> +			platform_profile_cycle();
> +			break;
> +		}
>  
>  		/* 0x02 FnLock, 0x03 Esc */
>  		if (data->integer.value == 0x02 || data->integer.value == 0x03)
>