public inbox for linux-input@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/4] HID: asus: Add Fn+F5 fan control key support for ROG laptops
@ 2026-01-07 15:22 Ionut Nechita (Sunlight Linux)
  2026-01-07 15:22 ` [PATCH v3 1/4] HID: asus: Replace magic number with HID_UP_ASUSVENDOR constant Ionut Nechita (Sunlight Linux)
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Ionut Nechita (Sunlight Linux) @ 2026-01-07 15:22 UTC (permalink / raw)
  To: benato.denis96, jikos, bentiss
  Cc: ionut_n2001, linux-input, linux-kernel, sunlightlinux, superm1

From: Ionut Nechita <ionut_n2001@yahoo.com>

This series adds support for the Fn+F5 fan control key on Asus ROG
laptops and addresses spurious HID vendor codes that cause kernel log
spam on these devices.

The series introduces:
1. Code cleanup by replacing a magic number with an existing constant
2. Filtering of spurious HID vendor usage codes on ROG laptops
3. Infrastructure for HID-to-WMI communication with proper build guards
4. Fn+F5 fan control key handler with userspace fallback support

The Fn+F5 key handler attempts to forward events to asus-wmi when
available. If asus-wmi is unavailable or fails, the event is passed
to userspace via evdev, allowing userspace fan control implementations.

Tested on Asus ROG series laptops.

Changes in v3:
- Added IS_REACHABLE(CONFIG_ASUS_WMI) conditional compilation guards
  to prevent build failures when asus-wmi is not compiled (patch 3)
- Modified Fn+F5 handler to pass events to userspace when asus-wmi is
  unavailable or fails, enabling userspace fan control (patch 4)
- Updated comments and commit message to reflect that spurious codes
  affect all ROG laptops, not just G14/G15, and occur during normal
  operation, not just on keypresses (patch 2)
- Simplified commit message for WMI infrastructure patch (patch 3)
- Added Reviewed-by tag from Denis Benato
- Removed Change-Id tags

Changes in v2:
- Split the original patch into a logical series of 4 patches
- Improved code organization and commit messages

Ionut Nechita (4):
  HID: asus: Replace magic number with HID_UP_ASUSVENDOR constant
  HID: asus: Filter spurious HID vendor codes on ROG laptops
  HID: asus: Add WMI communication infrastructure
  HID: asus: Implement Fn+F5 fan control key handler

 drivers/hid/hid-asus.c                     | 80 +++++++++++++++++++++-
 include/linux/platform_data/x86/asus-wmi.h |  1 +
 2 files changed, 80 insertions(+), 1 deletion(-)

--
2.52.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v3 1/4] HID: asus: Replace magic number with HID_UP_ASUSVENDOR constant
  2026-01-07 15:22 [PATCH v3 0/4] HID: asus: Add Fn+F5 fan control key support for ROG laptops Ionut Nechita (Sunlight Linux)
@ 2026-01-07 15:22 ` Ionut Nechita (Sunlight Linux)
  2026-01-07 15:22 ` [PATCH v3 2/4] HID: asus: Filter spurious HID vendor codes on ROG laptops Ionut Nechita (Sunlight Linux)
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Ionut Nechita (Sunlight Linux) @ 2026-01-07 15:22 UTC (permalink / raw)
  To: benato.denis96, jikos, bentiss
  Cc: ionut_n2001, linux-input, linux-kernel, sunlightlinux, superm1

From: Ionut Nechita <ionut_n2001@yahoo.com>

Use the existing HID_UP_ASUSVENDOR constant instead of the magic number
0xff310000 for better code clarity and maintainability.

Reviewed-by: Denis Benato <benato.denis96@gmail.com>
Signed-off-by: Ionut Nechita <ionut_n2001@yahoo.com>
---
 drivers/hid/hid-asus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index 472bca54642b9..eb14b9d13823b 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -317,7 +317,7 @@ static int asus_e1239t_event(struct asus_drvdata *drvdat, u8 *data, int size)
 static int asus_event(struct hid_device *hdev, struct hid_field *field,
 		      struct hid_usage *usage, __s32 value)
 {
-	if ((usage->hid & HID_USAGE_PAGE) == 0xff310000 &&
+	if ((usage->hid & HID_USAGE_PAGE) == HID_UP_ASUSVENDOR &&
 	    (usage->hid & HID_USAGE) != 0x00 &&
 	    (usage->hid & HID_USAGE) != 0xff && !usage->type) {
 		hid_warn(hdev, "Unmapped Asus vendor usagepage code 0x%02x\n",
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v3 2/4] HID: asus: Filter spurious HID vendor codes on ROG laptops
  2026-01-07 15:22 [PATCH v3 0/4] HID: asus: Add Fn+F5 fan control key support for ROG laptops Ionut Nechita (Sunlight Linux)
  2026-01-07 15:22 ` [PATCH v3 1/4] HID: asus: Replace magic number with HID_UP_ASUSVENDOR constant Ionut Nechita (Sunlight Linux)
@ 2026-01-07 15:22 ` Ionut Nechita (Sunlight Linux)
  2026-01-07 15:22 ` [PATCH v3 3/4] HID: asus: Add WMI communication infrastructure Ionut Nechita (Sunlight Linux)
  2026-01-07 15:22 ` [PATCH v3 4/4] HID: asus: Implement Fn+F5 fan control key handler Ionut Nechita (Sunlight Linux)
  3 siblings, 0 replies; 6+ messages in thread
From: Ionut Nechita (Sunlight Linux) @ 2026-01-07 15:22 UTC (permalink / raw)
  To: benato.denis96, jikos, bentiss
  Cc: ionut_n2001, linux-input, linux-kernel, sunlightlinux, superm1

From: Ionut Nechita <ionut_n2001@yahoo.com>

On Asus ROG laptops, several HID vendor usage codes (0xea, 0xec, 0x02,
0x8a, 0x9e) are sent during normal operation without a clear purpose,
generating unwanted "Unmapped Asus vendor usagepage code" warnings in
dmesg.

Add definitions for these codes and filter them out in asus_raw_event()
to prevent kernel log spam.

Tested on Asus ROG series laptops.

Reviewed-by: Denis Benato <benato.denis96@gmail.com>
Signed-off-by: Ionut Nechita <ionut_n2001@yahoo.com>
---
 drivers/hid/hid-asus.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index eb14b9d13823b..15c24d5812763 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -57,6 +57,13 @@ MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad");
 #define ROG_ALLY_X_MIN_MCU 313
 #define ROG_ALLY_MIN_MCU 319
 
+/* Spurious HID codes sent by QUIRK_ROG_NKEY_KEYBOARD devices */
+#define ASUS_SPURIOUS_CODE_0XEA 0xea
+#define ASUS_SPURIOUS_CODE_0XEC 0xec
+#define ASUS_SPURIOUS_CODE_0X02 0x02
+#define ASUS_SPURIOUS_CODE_0X8A 0x8a
+#define ASUS_SPURIOUS_CODE_0X9E 0x9e
+
 #define SUPPORT_KBD_BACKLIGHT BIT(0)
 
 #define MAX_TOUCH_MAJOR 8
@@ -348,6 +355,21 @@ static int asus_raw_event(struct hid_device *hdev,
 	if (report->id == FEATURE_KBD_LED_REPORT_ID1 || report->id == FEATURE_KBD_LED_REPORT_ID2)
 		return -1;
 	if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD) {
+		/*
+		 * ASUS ROG laptops send these codes during normal operation
+		 * with no discernable reason. Filter them out to avoid
+		 * unmapped warning messages.
+		 */
+		if (report->id == FEATURE_KBD_REPORT_ID) {
+			if (data[1] == ASUS_SPURIOUS_CODE_0XEA ||
+			    data[1] == ASUS_SPURIOUS_CODE_0XEC ||
+			    data[1] == ASUS_SPURIOUS_CODE_0X02 ||
+			    data[1] == ASUS_SPURIOUS_CODE_0X8A ||
+			    data[1] == ASUS_SPURIOUS_CODE_0X9E) {
+				return -1;
+			}
+		}
+
 		/*
 		 * G713 and G733 send these codes on some keypresses, depending on
 		 * the key pressed it can trigger a shutdown event if not caught.
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v3 3/4] HID: asus: Add WMI communication infrastructure
  2026-01-07 15:22 [PATCH v3 0/4] HID: asus: Add Fn+F5 fan control key support for ROG laptops Ionut Nechita (Sunlight Linux)
  2026-01-07 15:22 ` [PATCH v3 1/4] HID: asus: Replace magic number with HID_UP_ASUSVENDOR constant Ionut Nechita (Sunlight Linux)
  2026-01-07 15:22 ` [PATCH v3 2/4] HID: asus: Filter spurious HID vendor codes on ROG laptops Ionut Nechita (Sunlight Linux)
@ 2026-01-07 15:22 ` Ionut Nechita (Sunlight Linux)
  2026-01-07 15:26   ` Mario Limonciello
  2026-01-07 15:22 ` [PATCH v3 4/4] HID: asus: Implement Fn+F5 fan control key handler Ionut Nechita (Sunlight Linux)
  3 siblings, 1 reply; 6+ messages in thread
From: Ionut Nechita (Sunlight Linux) @ 2026-01-07 15:22 UTC (permalink / raw)
  To: benato.denis96, jikos, bentiss
  Cc: ionut_n2001, linux-input, linux-kernel, sunlightlinux, superm1

From: Ionut Nechita <ionut_n2001@yahoo.com>

Add infrastructure for the HID driver to communicate with the asus-wmi
driver for handling special keys that require WMI communication.

This includes:
- Define ASUS_WMI_METHODID_NOTIF method ID in asus-wmi.h
- Implement asus_wmi_send_event() function with proper conditional
  compilation guards for when asus-wmi is not available

Reviewed-by: Denis Benato <benato.denis96@gmail.com>
Signed-off-by: Ionut Nechita <ionut_n2001@yahoo.com>
---
 drivers/hid/hid-asus.c                     | 31 ++++++++++++++++++++++
 include/linux/platform_data/x86/asus-wmi.h |  1 +
 2 files changed, 32 insertions(+)

diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index 15c24d5812763..8828a3b3054fa 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -23,6 +23,7 @@
 /*
  */
 
+#include <linux/acpi.h>
 #include <linux/dmi.h>
 #include <linux/hid.h>
 #include <linux/module.h>
@@ -321,6 +322,36 @@ static int asus_e1239t_event(struct asus_drvdata *drvdat, u8 *data, int size)
 	return 0;
 }
 
+/*
+ * Send events to asus-wmi driver for handling special keys
+ */
+#if IS_REACHABLE(CONFIG_ASUS_WMI)
+static int asus_wmi_send_event(struct asus_drvdata *drvdata, u8 code)
+{
+	int err;
+	u32 retval;
+
+	err = asus_wmi_evaluate_method(ASUS_WMI_METHODID_DEVS,
+				       ASUS_WMI_METHODID_NOTIF, code, &retval);
+	if (err) {
+		pr_warn("Failed to notify asus-wmi: %d\n", err);
+		return err;
+	}
+
+	if (retval != 0) {
+		pr_warn("Failed to notify asus-wmi (retval): 0x%x\n", retval);
+		return -EIO;
+	}
+
+	return 0;
+}
+#else
+static inline int asus_wmi_send_event(struct asus_drvdata *drvdata, u8 code)
+{
+	return -ENODEV;
+}
+#endif
+
 static int asus_event(struct hid_device *hdev, struct hid_field *field,
 		      struct hid_usage *usage, __s32 value)
 {
diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h
index 419491d4abca1..516538b5a527e 100644
--- a/include/linux/platform_data/x86/asus-wmi.h
+++ b/include/linux/platform_data/x86/asus-wmi.h
@@ -29,6 +29,7 @@
 #define ASUS_WMI_METHODID_KBFT		0x5446424B /* KeyBoard FilTer */
 #define ASUS_WMI_METHODID_INIT		0x54494E49 /* INITialize */
 #define ASUS_WMI_METHODID_HKEY		0x59454B48 /* Hot KEY ?? */
+#define ASUS_WMI_METHODID_NOTIF		0x00100021 /* Notify method */
 
 #define ASUS_WMI_UNSUPPORTED_METHOD	0xFFFFFFFE
 
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v3 4/4] HID: asus: Implement Fn+F5 fan control key handler
  2026-01-07 15:22 [PATCH v3 0/4] HID: asus: Add Fn+F5 fan control key support for ROG laptops Ionut Nechita (Sunlight Linux)
                   ` (2 preceding siblings ...)
  2026-01-07 15:22 ` [PATCH v3 3/4] HID: asus: Add WMI communication infrastructure Ionut Nechita (Sunlight Linux)
@ 2026-01-07 15:22 ` Ionut Nechita (Sunlight Linux)
  3 siblings, 0 replies; 6+ messages in thread
From: Ionut Nechita (Sunlight Linux) @ 2026-01-07 15:22 UTC (permalink / raw)
  To: benato.denis96, jikos, bentiss
  Cc: ionut_n2001, linux-input, linux-kernel, sunlightlinux, superm1

From: Ionut Nechita <ionut_n2001@yahoo.com>

On Asus ROG laptops, the Fn+F5 key (HID code 0xae) is used to cycle
through fan modes. This key press needs to be forwarded to the asus-wmi
driver to actually change the fan mode.

Add ASUS_FAN_CTRL_KEY_CODE define and implement the handler in
asus_raw_event() to send WMI events when this key is pressed.

When asus-wmi successfully handles the event, it is blocked from reaching
userspace. If asus-wmi is unavailable or fails, the event is passed to
userspace via evdev, allowing userspace implementations of fan control.

Tested on Asus ROG G14/G15 series laptops.

Reviewed-by: Denis Benato <benato.denis96@gmail.com>
Signed-off-by: Ionut Nechita <ionut_n2001@yahoo.com>
---
 drivers/hid/hid-asus.c | 35 ++++++++++++++++++++++++++++++-----
 1 file changed, 30 insertions(+), 5 deletions(-)

diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index 8828a3b3054fa..d6f0050fd441b 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -65,6 +65,9 @@ MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad");
 #define ASUS_SPURIOUS_CODE_0X8A 0x8a
 #define ASUS_SPURIOUS_CODE_0X9E 0x9e
 
+/* Special key codes */
+#define ASUS_FAN_CTRL_KEY_CODE 0xae
+
 #define SUPPORT_KBD_BACKLIGHT BIT(0)
 
 #define MAX_TOUCH_MAJOR 8
@@ -386,12 +389,34 @@ static int asus_raw_event(struct hid_device *hdev,
 	if (report->id == FEATURE_KBD_LED_REPORT_ID1 || report->id == FEATURE_KBD_LED_REPORT_ID2)
 		return -1;
 	if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD) {
-		/*
-		 * ASUS ROG laptops send these codes during normal operation
-		 * with no discernable reason. Filter them out to avoid
-		 * unmapped warning messages.
-		 */
 		if (report->id == FEATURE_KBD_REPORT_ID) {
+			/*
+			 * Fn+F5 fan control key - try to send WMI event to toggle fan mode.
+			 * If successful, block the event from reaching userspace.
+			 * If asus-wmi is unavailable or the call fails, let the event
+			 * pass to userspace so it can implement its own fan control.
+			 */
+			if (data[1] == ASUS_FAN_CTRL_KEY_CODE) {
+				int ret = asus_wmi_send_event(drvdata, ASUS_FAN_CTRL_KEY_CODE);
+
+				if (ret == 0) {
+					/* Successfully handled by asus-wmi, block event */
+					return -1;
+				}
+
+				/*
+				 * Warn if asus-wmi failed (but not if it's unavailable).
+				 * Let the event reach userspace in all failure cases.
+				 */
+				if (ret != -ENODEV)
+					hid_warn(hdev, "Failed to notify asus-wmi: %d\n", ret);
+			}
+
+			/*
+			 * ASUS ROG laptops send these codes during normal operation
+			 * with no discernable reason. Filter them out to avoid
+			 * unmapped warning messages.
+			 */
 			if (data[1] == ASUS_SPURIOUS_CODE_0XEA ||
 			    data[1] == ASUS_SPURIOUS_CODE_0XEC ||
 			    data[1] == ASUS_SPURIOUS_CODE_0X02 ||
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v3 3/4] HID: asus: Add WMI communication infrastructure
  2026-01-07 15:22 ` [PATCH v3 3/4] HID: asus: Add WMI communication infrastructure Ionut Nechita (Sunlight Linux)
@ 2026-01-07 15:26   ` Mario Limonciello
  0 siblings, 0 replies; 6+ messages in thread
From: Mario Limonciello @ 2026-01-07 15:26 UTC (permalink / raw)
  To: Ionut Nechita (Sunlight Linux), benato.denis96, jikos, bentiss
  Cc: ionut_n2001, linux-input, linux-kernel

On 1/7/26 9:22 AM, Ionut Nechita (Sunlight Linux) wrote:
> From: Ionut Nechita <ionut_n2001@yahoo.com>
> 
> Add infrastructure for the HID driver to communicate with the asus-wmi
> driver for handling special keys that require WMI communication.
> 
> This includes:
> - Define ASUS_WMI_METHODID_NOTIF method ID in asus-wmi.h
> - Implement asus_wmi_send_event() function with proper conditional
>    compilation guards for when asus-wmi is not available
> 
> Reviewed-by: Denis Benato <benato.denis96@gmail.com>
> Signed-off-by: Ionut Nechita <ionut_n2001@yahoo.com>
> ---
>   drivers/hid/hid-asus.c                     | 31 ++++++++++++++++++++++
>   include/linux/platform_data/x86/asus-wmi.h |  1 +
>   2 files changed, 32 insertions(+)
> 
> diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
> index 15c24d5812763..8828a3b3054fa 100644
> --- a/drivers/hid/hid-asus.c
> +++ b/drivers/hid/hid-asus.c
> @@ -23,6 +23,7 @@
>   /*
>    */
>   
> +#include <linux/acpi.h>
>   #include <linux/dmi.h>
>   #include <linux/hid.h>
>   #include <linux/module.h>
> @@ -321,6 +322,36 @@ static int asus_e1239t_event(struct asus_drvdata *drvdat, u8 *data, int size)
>   	return 0;
>   }
>   
> +/*
> + * Send events to asus-wmi driver for handling special keys
> + */
> +#if IS_REACHABLE(CONFIG_ASUS_WMI)
I think this specific IS_REACHABLE isn't needed.

asus_wmi_evaluate_method() will return -ENODEV in that case already.

I think the warning you have below is actually helpful too because it 
will be obvious to a user they forgot to enable asus-wmi in their kernel 
config.

> +static int asus_wmi_send_event(struct asus_drvdata *drvdata, u8 code)
> +{
> +	int err;
> +	u32 retval;
> +
> +	err = asus_wmi_evaluate_method(ASUS_WMI_METHODID_DEVS,
> +				       ASUS_WMI_METHODID_NOTIF, code, &retval);
> +	if (err) {
> +		pr_warn("Failed to notify asus-wmi: %d\n", err);
> +		return err;
> +	}
> +
> +	if (retval != 0) {
> +		pr_warn("Failed to notify asus-wmi (retval): 0x%x\n", retval);
> +		return -EIO;
> +	}
> +
> +	return 0;
> +}
> +#else
> +static inline int asus_wmi_send_event(struct asus_drvdata *drvdata, u8 code)
> +{
> +	return -ENODEV;
> +}
> +#endif
> +
>   static int asus_event(struct hid_device *hdev, struct hid_field *field,
>   		      struct hid_usage *usage, __s32 value)
>   {
> diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h
> index 419491d4abca1..516538b5a527e 100644
> --- a/include/linux/platform_data/x86/asus-wmi.h
> +++ b/include/linux/platform_data/x86/asus-wmi.h
> @@ -29,6 +29,7 @@
>   #define ASUS_WMI_METHODID_KBFT		0x5446424B /* KeyBoard FilTer */
>   #define ASUS_WMI_METHODID_INIT		0x54494E49 /* INITialize */
>   #define ASUS_WMI_METHODID_HKEY		0x59454B48 /* Hot KEY ?? */
> +#define ASUS_WMI_METHODID_NOTIF		0x00100021 /* Notify method */
>   
>   #define ASUS_WMI_UNSUPPORTED_METHOD	0xFFFFFFFE
>   


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-01-07 15:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-07 15:22 [PATCH v3 0/4] HID: asus: Add Fn+F5 fan control key support for ROG laptops Ionut Nechita (Sunlight Linux)
2026-01-07 15:22 ` [PATCH v3 1/4] HID: asus: Replace magic number with HID_UP_ASUSVENDOR constant Ionut Nechita (Sunlight Linux)
2026-01-07 15:22 ` [PATCH v3 2/4] HID: asus: Filter spurious HID vendor codes on ROG laptops Ionut Nechita (Sunlight Linux)
2026-01-07 15:22 ` [PATCH v3 3/4] HID: asus: Add WMI communication infrastructure Ionut Nechita (Sunlight Linux)
2026-01-07 15:26   ` Mario Limonciello
2026-01-07 15:22 ` [PATCH v3 4/4] HID: asus: Implement Fn+F5 fan control key handler Ionut Nechita (Sunlight Linux)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox