linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 0/4] HID: asus: Add Fn+F5 fan control key support for ROG laptops
@ 2026-01-07 15:42 Ionut Nechita (Sunlight Linux)
  2026-01-07 15:42 ` [PATCH v5 1/4] HID: asus: Replace magic number with HID_UP_ASUSVENDOR constant Ionut Nechita (Sunlight Linux)
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Ionut Nechita (Sunlight Linux) @ 2026-01-07 15:42 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
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 v5:
- Removed IS_REACHABLE(CONFIG_ASUS_WMI) guards from patch 3 as
  asus_wmi_evaluate_method() already returns -ENODEV when asus-wmi
  is not available, and the warning is helpful for users (Mario's feedback)
- Updated commit message for patch 3 to reflect the removal of
  conditional compilation guards

Changes in v4:
- Added Reviewed-by tag from Mario Limonciello (AMD) to all patches

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                     | 73 +++++++++++++++++++++-
 include/linux/platform_data/x86/asus-wmi.h |  1 +
 2 files changed, 73 insertions(+), 1 deletion(-)

--
2.52.0


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

* [PATCH v5 1/4] HID: asus: Replace magic number with HID_UP_ASUSVENDOR constant
  2026-01-07 15:42 [PATCH v5 0/4] HID: asus: Add Fn+F5 fan control key support for ROG laptops Ionut Nechita (Sunlight Linux)
@ 2026-01-07 15:42 ` Ionut Nechita (Sunlight Linux)
  2026-01-07 15:42 ` [PATCH v5 2/4] HID: asus: Filter spurious HID vendor codes on ROG laptops Ionut Nechita (Sunlight Linux)
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Ionut Nechita (Sunlight Linux) @ 2026-01-07 15:42 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>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
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] 7+ messages in thread

* [PATCH v5 2/4] HID: asus: Filter spurious HID vendor codes on ROG laptops
  2026-01-07 15:42 [PATCH v5 0/4] HID: asus: Add Fn+F5 fan control key support for ROG laptops Ionut Nechita (Sunlight Linux)
  2026-01-07 15:42 ` [PATCH v5 1/4] HID: asus: Replace magic number with HID_UP_ASUSVENDOR constant Ionut Nechita (Sunlight Linux)
@ 2026-01-07 15:42 ` Ionut Nechita (Sunlight Linux)
  2026-01-07 15:42 ` [PATCH v5 3/4] HID: asus: Add WMI communication infrastructure Ionut Nechita (Sunlight Linux)
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Ionut Nechita (Sunlight Linux) @ 2026-01-07 15:42 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>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
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] 7+ messages in thread

* [PATCH v5 3/4] HID: asus: Add WMI communication infrastructure
  2026-01-07 15:42 [PATCH v5 0/4] HID: asus: Add Fn+F5 fan control key support for ROG laptops Ionut Nechita (Sunlight Linux)
  2026-01-07 15:42 ` [PATCH v5 1/4] HID: asus: Replace magic number with HID_UP_ASUSVENDOR constant Ionut Nechita (Sunlight Linux)
  2026-01-07 15:42 ` [PATCH v5 2/4] HID: asus: Filter spurious HID vendor codes on ROG laptops Ionut Nechita (Sunlight Linux)
@ 2026-01-07 15:42 ` Ionut Nechita (Sunlight Linux)
  2026-01-07 15:42 ` [PATCH v5 4/4] HID: asus: Implement Fn+F5 fan control key handler Ionut Nechita (Sunlight Linux)
  2026-01-08  7:40 ` [PATCH v5 0/4] HID: asus: Add Fn+F5 fan control key support for ROG laptops Ionut Nechita (Sunlight Linux)
  4 siblings, 0 replies; 7+ messages in thread
From: Ionut Nechita (Sunlight Linux) @ 2026-01-07 15:42 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 to send events to asus-wmi

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

diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index 15c24d5812763..6fcd3213857cf 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,29 @@ 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
+ */
+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;
+}
+
 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] 7+ messages in thread

* [PATCH v5 4/4] HID: asus: Implement Fn+F5 fan control key handler
  2026-01-07 15:42 [PATCH v5 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:42 ` [PATCH v5 3/4] HID: asus: Add WMI communication infrastructure Ionut Nechita (Sunlight Linux)
@ 2026-01-07 15:42 ` Ionut Nechita (Sunlight Linux)
  2026-01-08  7:40 ` [PATCH v5 0/4] HID: asus: Add Fn+F5 fan control key support for ROG laptops Ionut Nechita (Sunlight Linux)
  4 siblings, 0 replies; 7+ messages in thread
From: Ionut Nechita (Sunlight Linux) @ 2026-01-07 15:42 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>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
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 6fcd3213857cf..06f32a39c0cf7 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
@@ -379,12 +382,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] 7+ messages in thread

* Re: [PATCH v5 0/4] HID: asus: Add Fn+F5 fan control key support for ROG laptops
  2026-01-07 15:42 [PATCH v5 0/4] HID: asus: Add Fn+F5 fan control key support for ROG laptops Ionut Nechita (Sunlight Linux)
                   ` (3 preceding siblings ...)
  2026-01-07 15:42 ` [PATCH v5 4/4] HID: asus: Implement Fn+F5 fan control key handler Ionut Nechita (Sunlight Linux)
@ 2026-01-08  7:40 ` Ionut Nechita (Sunlight Linux)
  2026-01-08 11:17   ` Jiri Kosina
  4 siblings, 1 reply; 7+ messages in thread
From: Ionut Nechita (Sunlight Linux) @ 2026-01-08  7:40 UTC (permalink / raw)
  To: jikos, bentiss
  Cc: benato.denis96, ionut_n2001, Ionut Nechita, linux-input,
	linux-kernel, superm1

Hello,

I hope this email finds you well. I wanted to follow up on my v5 patch
series for Fn+F5 fan control key support on Asus ROG laptops, which I
submitted on January 7th.

The series has received Reviewed-by tags from both Mario Limonciello
(AMD) and Denis Benato, and I've addressed all the feedback from
previous versions, including the removal of IS_REACHABLE guards as
suggested by Mario.

I wanted to check if there are any additional changes or improvements
you'd like me to make before this series can be considered for merging
into mainline. I'm happy to address any further feedback.

Also, if you could let me know what the next steps are in the process,
I would appreciate it.

Thank you for your time and guidance.

Best regards,
Ionut

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

* Re: [PATCH v5 0/4] HID: asus: Add Fn+F5 fan control key support for ROG laptops
  2026-01-08  7:40 ` [PATCH v5 0/4] HID: asus: Add Fn+F5 fan control key support for ROG laptops Ionut Nechita (Sunlight Linux)
@ 2026-01-08 11:17   ` Jiri Kosina
  0 siblings, 0 replies; 7+ messages in thread
From: Jiri Kosina @ 2026-01-08 11:17 UTC (permalink / raw)
  To: Ionut Nechita (Sunlight Linux)
  Cc: bentiss, benato.denis96, ionut_n2001, linux-input, linux-kernel,
	superm1

On Thu, 8 Jan 2026, Ionut Nechita (Sunlight Linux) wrote:

> I hope this email finds you well. I wanted to follow up on my v5 patch
> series for Fn+F5 fan control key support on Asus ROG laptops, which I
> submitted on January 7th.
> 
> The series has received Reviewed-by tags from both Mario Limonciello
> (AMD) and Denis Benato, and I've addressed all the feedback from
> previous versions, including the removal of IS_REACHABLE guards as
> suggested by Mario.
> 
> I wanted to check if there are any additional changes or improvements
> you'd like me to make before this series can be considered for merging
> into mainline. I'm happy to address any further feedback.
> 
> Also, if you could let me know what the next steps are in the process,
> I would appreciate it.

It took me some time to go through the iterations, feedback and review the 
patch, now applied to hid.git#for-6.20/asus, thanks.

-- 
Jiri Kosina
SUSE Labs


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

end of thread, other threads:[~2026-01-08 11:18 UTC | newest]

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).