HID: asus: Add ROG laptop HID code filtering and fan control
Subsystems (2)
cover HID: asus: Add ROG laptop HID code filtering and fan control
From: Ionut Nechita <[email protected]>
Hi,
This patch addresses two issues with Asus ROG G14/G15 laptops:
1. Kernel log spam from unmapped HID vendor codes
2. Non-functional Fn+F5 fan control key
Problem:
--------
Asus ROG G14 and G15 laptops send several HID vendor usage codes (0xea, 0xec, 0x02, 0x8a, 0x9e) during normal keypresses with no clear purpose. This generates continuous "Unmapped Asus vendor usagepage code" warnings in dmesg, cluttering the kernel log.
Additionally, the Fn+F5 key (code 0xae) which should cycle through fan modes is not handled, preventing users from controlling fan behavior through the keyboard shortcut.
Solution:
---------
- Filter out the spurious HID codes for ROG N-Key keyboards to eliminate log spam
- Add asus_wmi_send_event() function to enable communication between hid-asus and asus-wmi drivers
- Implement Fn+F5 (0xae) handler that triggers WMI events to toggle fan modes
- Replace magic number with HID_UP_ASUSVENDOR constant for clarity
Testing:
--------
Tested on Asus ROG G14 (2021) and G15 (2022) models:
- Kernel log no longer shows unmapped vendor code warnings
- Fn+F5 key now cycles through fan modes (silent/balanced/performance)
- No regressions observed with other keyboard functionality
Impact:
-------
Affects Asus ROG laptop users who experience:
- Cluttered kernel logs from HID warnings
- Non-functional fan control hotkey
Ionut Nechita (1):
HID: asus: Filter HID vendor codes and add WMI fan control support
for ROG laptops
drivers/hid/hid-asus.c | 48 +++++++++++++++++++++- include/linux/platform_data/x86/asus-wmi.h | 2 + 2 files changed, 49 insertions(+), 1 deletion(-)
--
2.52.0
PATCH 1/1 HID: asus: Filter HID vendor codes and add WMI fan control support for ROG laptops
From: Ionut Nechita <[email protected]>
On Asus ROG G14 and G15 laptops, several HID vendor usage codes are sent during normal operation without a clear purpose, generating unwanted "Unmapped Asus vendor usagepage code" warnings in dmesg.
Additionally, the Fn+F5 fan control key (code 0xae) needs to communicate with the asus-wmi driver to toggle between fan modes, but this was not previously handled.
Changes:
- Filter out spurious HID codes (0xea, 0xec, 0x02, 0x8a, 0x9e) for QUIRK_ROG_NKEY_KEYBOARD devices to prevent kernel log spam
- Add asus_wmi_send_event() function to communicate with asus-wmi driver
- Implement Fn+F5 (0xae) fan control key handler that triggers WMI events
- Replace magic number 0xff310000 with HID_UP_ASUSVENDOR constant for better code clarity
This eliminates unnecessary kernel warnings and enables proper fan control functionality on affected Asus ROG laptops.
Tested on Asus ROG G14/G15 series laptops.
--- drivers/hid/hid-asus.c | 48 +++++++++++++++++++++- include/linux/platform_data/x86/asus-wmi.h | 2 + 2 files changed, 49 insertions(+), 1 deletion(-)
drivers/hid/hid-asus.c +47 -1
@@ -26,6 +26,8 @@#include <linux/dmi.h> #include <linux/hid.h> #include <linux/module.h> + +#include <linux/acpi.h> #include <linux/platform_data/x86/asus-wmi.h> #include <linux/platform_data/x86/asus-wmi-leds-ids.h> #include <linux/input/mt.h>
@@ -314,10 +316,33 @@ static int asus_e1239t_event(struct asus_drvdata *drvdat, u8 *data, int size)return 0 ; } +/* +* This enables triggering events in asus-wmi +*/ +static int asus_wmi_send_event (struct asus_drvdata *drvdat,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) { -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",
@@ -330,6 +355,7 @@ static int asus_event(struct hid_device *hdev, struct hid_field *field,static int asus_raw_event (struct hid_device *hdev,struct hid_report *report,u8 *data,int size) { +int ret;struct asus_drvdata *drvdata =hid_get_drvdata (hdev);if (drvdata->battery && data[0 ] ==BATTERY_REPORT_ID )
@@ -348,6 +374,26 @@ 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 ) { +/* Additional report filtering */ +if (report->id ==FEATURE_KBD_REPORT_ID ) { +/* Fn+F5 "fan" symbol, trigger WMI event to toggle next mode */ +if (data[1 ] ==0xae ) { + ret =asus_wmi_send_event (drvdata,0xae ); +if (ret <0 ) { +hid_warn (hdev,"Asus failed to trigger fan control event" ); + } +return -1 ; +/* +* G14 and G15 send these codes on some keypresses with no +* discernable reason for doing so. We'll filter them out to avoid +* unmapped warning messages later +*/ + }else if (data[1 ] ==0xea || data[1 ] ==0xec || data[1 ] ==0x02 || + data[1 ] ==0x8a || data[1 ] ==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.
include/linux/platform_data/x86/asus-wmi.h +2 -0
@@ -30,6 +30,8 @@#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/* Wireless */
Signature · 1 line
2.52.0
Re: [PATCH] HID: asus: Filter HID vendor codes and add WMI fan control support for ROG laptops
+ Denis Benato
Quoted 10 lines · Ionut Nechita (Sunlight Linux)
From: Ionut Nechita <[email protected]>
On Asus ROG G14 and G15 laptops, several HID vendor usage codes are sent during normal operation without a clear purpose, generating unwanted "Unmapped Asus vendor usagepage code" warnings in dmesg.
Additionally, the Fn+F5 fan control key (code
0xae) needs to communicate with the asus-wmi driver to toggle between fan modes, but this was not previously handled.
Quoted 7 lines
Changes:
- Filter out spurious HID codes (0xea,0xec,0x02,0x8a,0x9e) forQUIRK_ROG_NKEY_KEYBOARDdevices to prevent kernel log spam
- Addasus_wmi_send_event()function to communicate with asus-wmi driver
- Implement Fn+F5 (0xae) fan control key handler that triggers WMI events
- Replace magic number0xff310000withHID_UP_ASUSVENDORconstant for better code clarity
I feel these should be split into smaller logical patches.
Quoted 17 lines
This eliminates unnecessary kernel warnings and enables proper fan control functionality on affected Asus ROG laptops.
Tested on Asus ROG G14/G15 series laptops.
Signed-off-by Ionut Nechita <[email protected]>--- drivers/hid/hid-asus.c | 48 +++++++++++++++++++++- include/linux/platform_data/x86/asus-wmi.h | 2 + 2 files changed, 49 insertions(+), 1 deletion(-)drivers/hid/hid-asus.c +0
-0
drivers/hid/hid-asus.c line 30
Quoted 5 lines
drivers/hid/hid-asus.c +2
-0@@ -26,6 +26,8 @@#include <linux/dmi.h> #include <linux/hid.h> #include <linux/module.h> + +#include <linux/acpi.h>
Shouldn't this be in alphabetical order before linux/dmi.h above?
Quoted 47 lines
drivers/hid/hid-asus.c +25
-1#include <linux/platform_data/x86/asus-wmi.h> #include <linux/platform_data/x86/asus-wmi-leds-ids.h> #include <linux/input/mt.h> @@ -314,10 +316,33 @@ static int asus_e1239t_event(struct asus_drvdata *drvdat, u8 *data, int size)return 0 ; } +/* +* This enables triggering events in asus-wmi +*/ +static int asus_wmi_send_event (struct asus_drvdata *drvdat,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) { -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",@@ -330,6 +355,7 @@ static int asus_event(struct hid_device *hdev, struct hid_field *field,static int asus_raw_event (struct hid_device *hdev,struct hid_report *report,u8 *data,int size) { +int ret;struct asus_drvdata *drvdata =hid_get_drvdata (hdev);if (drvdata->battery && data[0 ] ==BATTERY_REPORT_ID )
drivers/hid/hid-asus.c static int asus_raw_event(struct hid_device *hdev, · line 380
Quoted 7 lines
drivers/hid/hid-asus.c +4
-0@@ -348,6 +374,26 @@ 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 ) { +/* Additional report filtering */ +if (report->id ==FEATURE_KBD_REPORT_ID ) { +/* Fn+F5 "fan" symbol, trigger WMI event to toggle next mode */ +if (data[1 ] ==0xae ) {
As this has a meaning you've identified shouldn't it have a #define as well?
Quoted 32 lines
drivers/hid/hid-asus.c +16
-0+ ret =asus_wmi_send_event (drvdata,0xae ); +if (ret <0 ) { +hid_warn (hdev,"Asus failed to trigger fan control event" ); + } +return -1 ; +/* +* G14 and G15 send these codes on some keypresses with no +* discernable reason for doing so. We'll filter them out to avoid +* unmapped warning messages later +*/ + }else if (data[1 ] ==0xea || data[1 ] ==0xec || data[1 ] ==0x02 || + data[1 ] ==0x8a || data[1 ] ==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. include/linux/platform_data/x86/asus-wmi.h +2
-0@@ -30,6 +30,8 @@#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/* Wireless */
v2 cover HID: asus: Filter HID codes and add WMI fan control for ROG laptops
From: Ionut Nechita <[email protected]>
Hi Mario and maintainers,
Thank you for the review feedback on v1. I've addressed all the issues:
Changes in v2:
- Split the monolithic patch into 4 logical patches as requested
- Fixed include order (linux/acpi.h now before linux/dmi.h)
- Added #define ASUS_FAN_CTRL_KEY_CODE for 0xae instead of magic number
- Added #defines for the filtered spurious codes as well for clarity
The patch series now:
1. Replaces magic number with existing HID_UP_ASUSVENDOR constant
2. Filters spurious HID vendor codes (with proper #defines)
3. Adds WMI communication infrastructure
4. Implements Fn+F5 fan control key handler (using #define)
This eliminates kernel log spam from unmapped HID codes and enables proper fan control functionality on Asus ROG G14/G15 laptops.
Tested on Asus ROG G14/G15 series laptops.
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 | 60 +++++++++++++++++++++- include/linux/platform_data/x86/asus-wmi.h | 1 + 2 files changed, 60 insertions(+), 1 deletion(-)
Signature · 1 line
2.52.0
PATCH v2 1/4 HID: asus: Replace magic number with HID_UP_ASUSVENDOR constant
From: Ionut Nechita <[email protected]>
Use the existing HID_UP_ASUSVENDOR constant instead of the magic number 0xff310000 for better code clarity and maintainability.
--- drivers/hid/hid-asus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-asus.c +1 -1
@@ -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",
Signature · 1 line
2.52.0
PATCH v2 2/4 HID: asus: Filter spurious HID vendor codes on ROG laptops
In reply to Ionut Nechita (Sunlight Linux)From: Ionut Nechita <[email protected]>
On Asus ROG G14 and G15 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 G14/G15 series laptops.
--- drivers/hid/hid-asus.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
drivers/hid/hid-asus.c +22 -0
@@ -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 ) { +/* +* G14 and G15 send these codes on some keypresses with no +* discernable reason for doing so. 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.
Signature · 1 line
2.52.0
PATCH v2 3/4 HID: asus: Add WMI communication infrastructure
In reply to Ionut Nechita (Sunlight Linux)From: Ionut Nechita <[email protected]>
Add the infrastructure needed for the HID driver to communicate with the asus-wmi driver:
- Add linux/acpi.h include (in alphabetical order)
- Define ASUS_WMI_METHODID_NOTIF method ID in asus-wmi.h
- Implement asus_wmi_send_event() function to send events to asus-wmi
This infrastructure will be used to handle special keys that require WMI communication.
--- drivers/hid/hid-asus.c | 24 ++++++++++++++++++++++ include/linux/platform_data/x86/asus-wmi.h | 1 + 2 files changed, 25 insertions(+)
drivers/hid/hid-asus.c +24 -0
@@ -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) {
include/linux/platform_data/x86/asus-wmi.h +1 -0
@@ -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
Signature · 1 line
2.52.0
PATCH v2 4/4 HID: asus: Implement Fn+F5 fan control key handler
In reply to Ionut Nechita (Sunlight Linux)From: Ionut Nechita <[email protected]>
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.
Tested on Asus ROG G14/G15 series laptops.
--- drivers/hid/hid-asus.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
drivers/hid/hid-asus.c +17 -5
@@ -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,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 ) { -/* -* G14 and G15 send these codes on some keypresses with no -* discernable reason for doing so. Filter them out to avoid -* unmapped warning messages. -*/ if (report->id ==FEATURE_KBD_REPORT_ID ) { +/* Fn+F5 fan control key, send WMI event to toggle fan mode */ +if (data[1 ] ==ASUS_FAN_CTRL_KEY_CODE ) { +int ret =asus_wmi_send_event (drvdata,ASUS_FAN_CTRL_KEY_CODE ); + +if (ret <0 ) +hid_warn (hdev,"Failed to trigger fan control event\n" ); +return -1 ; + } + +/* +* G14 and G15 send these codes on some keypresses with no +* discernable reason for doing so. 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 ||
Signature · 1 line
2.52.0
Re: [PATCH v2 0/4] HID: asus: Filter HID codes and add WMI fan control for ROG laptops
In reply to Ionut Nechita (Sunlight Linux)Quoted 3 lines · Ionut Nechita (Sunlight Linux)
From: Ionut Nechita <[email protected]>
Hi Mario and maintainers,
Hi!
Maintainer of asus-wmi here, thanks a lot for your help!
Thanks Mario for including me too to the party!
A note for the future: from my email client it appears as if you sent v2 in reply to the previous patch, I have done that on the iio subsystem and I have been discouraged from doing so because the mail ends up far from the latest received ones and maintainers are more likely to miss it.
Quoted 8 lines
Thank you for the review feedback on v1. I've addressed all the issues:
Changes in v2:
- Split the monolithic patch into 4 logical patches as requested
- Fixed include order (linux/acpi.hnow beforelinux/dmi.h)
- Added #defineASUS_FAN_CTRL_KEY_CODEfor0xaeinstead of magic number
- Added #defines for the filtered spurious codes as well for clarity
Quoted 8 lines
The patch series now:
1. Replaces magic number with existingHID_UP_ASUSVENDORconstant
2. Filters spurious HID vendor codes (with proper #defines)
3. Adds WMI communication infrastructure
4. Implements Fn+F5 fan control key handler (using #define)This eliminates kernel log spam from unmapped HID codes and enables proper fan control functionality on Asus ROG G14/G15 laptops.
From my notes those unmapped codepages is the embedded controller echoing out settings for the Windows application armoury-crate to check if it is still in sync.
Quoted 12 lines
Tested on Asus ROG G14/G15 series laptops.
Ionut Nechita (4):
HID: asus: Replace magic number withHID_UP_ASUSVENDORconstant
HID: asus: Filter spurious HID vendor codes on ROG laptops
HID: asus: Add WMI communication infrastructure
HID: asus: Implement Fn+F5 fan control key handlerdrivers/hid/hid-asus.c | 60 +++++++++++++++++++++- include/linux/platform_data/x86/asus-wmi.h | 1 + 2 files changed, 60 insertions(+), 1 deletion(-)
Re: [PATCH 1/4] HID: asus: Replace magic number with HID_UP_ASUSVENDOR constant
In reply to Ionut Nechita (Sunlight Linux)Quoted 6 lines · Ionut Nechita (Sunlight Linux)
From: Ionut Nechita <[email protected]>
Use the existing
HID_UP_ASUSVENDORconstant instead of the magic number0xff310000for better code clarity and maintainability.Change-Id: I65cf58cd0cd47acc39b755fa9a5fb7f2ad271046
Quoted 18 lines
Signed-off-by Ionut Nechita <[email protected]>--- drivers/hid/hid-asus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/hid/hid-asus.c +1
-1@@ -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",
Re: [PATCH 2/4] HID: asus: Filter spurious HID vendor codes on ROG laptops
In reply to Ionut Nechita (Sunlight Linux)Quoted 7 lines · Ionut Nechita (Sunlight Linux)
From: Ionut Nechita <[email protected]>
On Asus ROG G14 and G15 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.
Quoted 7 lines
Add definitions for these codes and filter them out in
asus_raw_event()to prevent kernel log spam.Tested on Asus ROG G14/G15 series laptops.
Change-Id I3f3b3a1e1698c8689e4c57582635435bfeda5990Signed-off-by Ionut Nechita <[email protected]>
Quoted 9 lines
--- drivers/hid/hid-asus.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)drivers/hid/hid-asus.c +0
-0
drivers/hid/hid-asus.c MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad"); · line 66
Quoted 10 lines
drivers/hid/hid-asus.c +7
-0@@ -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 +
I don't know what's the preferred way to call these, I am happy with any way.
drivers/hid/hid-asus.c static int asus_raw_event(struct hid_device *hdev, · line 362
Quoted 12 lines
drivers/hid/hid-asus.c +5
-0#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 ) { +/* +* G14 and G15 send these codes on some keypresses with no +* discernable reason for doing so. Filter them out to avoid +* unmapped warning messages. +*/
Pretty much all ASUS laptops do, not just G14 or G15, and it's not only on keypresses.
Quoted 13 lines
drivers/hid/hid-asus.c +10
-0+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.
Re: [PATCH 3/4] HID: asus: Add WMI communication infrastructure
In reply to Ionut Nechita (Sunlight Linux)Quoted 6 lines · Ionut Nechita (Sunlight Linux)
From: Ionut Nechita <[email protected]>
Add the infrastructure needed for the HID driver to communicate with the asus-wmi driver:
- Add
linux/acpi.hinclude (in alphabetical order)
Mentioning the addition of acpi.h seems a bit too specific for a commit message, but wait for hid maintainers to tell.
Quoted 29 lines
- Define
ASUS_WMI_METHODID_NOTIFmethod ID inasus-wmi.h
- Implementasus_wmi_send_event()function to send events to asus-wmiThis infrastructure will be used to handle special keys that require WMI communication.
Change-Id Ic4d9b35f8b1f2b48c7c26e7259b4d05951021b58Signed-off-by Ionut Nechita <[email protected]>--- drivers/hid/hid-asus.c | 24 ++++++++++++++++++++++ include/linux/platform_data/x86/asus-wmi.h | 1 + 2 files changed, 25 insertions(+)drivers/hid/hid-asus.c +1
-0@@ -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 ; }
drivers/hid/hid-asus.c static int asus_e1239t_event(struct asus_drvdata *drvdat, u8 *data, int size) · line 334
Quoted 10 lines
drivers/hid/hid-asus.c +10
-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);
This code is based on the fact asus-wmi driver is available:
are you sure this doesn't make the kernel compilation fail if such driver is not enabled?
Quoted 28 lines
drivers/hid/hid-asus.c +13
-0+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) {include/linux/platform_data/x86/asus-wmi.h +1
-0@@ -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
Re: [PATCH 4/4] HID: asus: Implement Fn+F5 fan control key handler
In reply to Ionut Nechita (Sunlight Linux)Quoted 35 lines · Ionut Nechita (Sunlight Linux)
From: Ionut Nechita <[email protected]>
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_CODEdefine and implement the handler inasus_raw_event()to send WMI events when this key is pressed.Tested on Asus ROG G14/G15 series laptops.
Change-Id Ic03df877b71e34c421e992a06e5e706d954e7dbfSigned-off-by Ionut Nechita <[email protected]>--- drivers/hid/hid-asus.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)drivers/hid/hid-asus.c +3
-0@@ -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,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 ) {
drivers/hid/hid-asus.c static int asus_raw_event(struct hid_device *hdev, · line 389
Quoted 10 lines
drivers/hid/hid-asus.c +4
-5-/* -* G14 and G15 send these codes on some keypresses with no -* discernable reason for doing so. Filter them out to avoid -* unmapped warning messages. -*/ if (report->id ==FEATURE_KBD_REPORT_ID ) { +/* Fn+F5 fan control key, send WMI event to toggle fan mode */ +if (data[1 ] ==ASUS_FAN_CTRL_KEY_CODE ) { +int ret =asus_wmi_send_event (drvdata,ASUS_FAN_CTRL_KEY_CODE ); +
What if asus-wmi is not compiled with the kernel?
Would it make sense, in that situation (or in case of a failure) to tell userspace (via evdev) about the button press?
Quoted 13 lines
drivers/hid/hid-asus.c +10
-0+if (ret <0 ) +hid_warn (hdev,"Failed to trigger fan control event\n" ); +return -1 ; + } + +/* +* G14 and G15 send these codes on some keypresses with no +* discernable reason for doing so. 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 ||
Re: [PATCH 2/4] HID: asus: Filter spurious HID vendor codes on ROG laptops
In reply to Ionut Nechita (Sunlight Linux)Quoted 7 lines · Ionut Nechita (Sunlight Linux)
From: Ionut Nechita <[email protected]>
On Asus ROG G14 and G15 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.
Quoted 6 lines
Add definitions for these codes and filter them out in
asus_raw_event()to prevent kernel log spam.Tested on Asus ROG G14/G15 series laptops.
Change-Id: I3f3b3a1e1698c8689e4c57582635435bfeda5990
Please strip Change-Id when sending patches to LKML.
Quoted 1 line
Signed-off-by Ionut Nechita <[email protected]>
Otherwise LGTM, feel free to add to next version.
Quoted 44 lines
--- drivers/hid/hid-asus.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)drivers/hid/hid-asus.c +22
-0@@ -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 ) { +/* +* G14 and G15 send these codes on some keypresses with no +* discernable reason for doing so. 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.
Mario Limonciello
Reviewed-byRe: [PATCH 1/4] HID: asus: Replace magic number with HID_UP_ASUSVENDOR constant
In reply to Denis BenatoQuoted 8 lines · Denis Benato
Quoted 6 lines · Ionut Nechita (Sunlight Linux)
From: Ionut Nechita <[email protected]>
Use the existing
HID_UP_ASUSVENDORconstant instead of the magic number0xff310000for better code clarity and maintainability.Change-Id: I65cf58cd0cd47acc39b755fa9a5fb7f2ad271046
Please strip change-id.
Otherwise LGTM and add to next version:
Quoted 19 lines
Reviewed-by Denis Benato <[email protected]>Quoted 18 lines
Signed-off-by Ionut Nechita <[email protected]>--- drivers/hid/hid-asus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/hid/hid-asus.c +1
-1@@ -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",
Re: [PATCH 3/4] HID: asus: Add WMI communication infrastructure
In reply to Denis BenatoQuoted 40 lines · Denis Benato
Quoted 6 lines · Ionut Nechita (Sunlight Linux)
From: Ionut Nechita <[email protected]>
Add the infrastructure needed for the HID driver to communicate with the asus-wmi driver:
- Add
linux/acpi.hinclude (in alphabetical order)Mentioning the addition of
acpi.hseems a bit too specific for a commit message, but wait for hid maintainers to tell.Quoted 29 lines
- Define
ASUS_WMI_METHODID_NOTIFmethod ID inasus-wmi.h
- Implementasus_wmi_send_event()function to send events to asus-wmiThis infrastructure will be used to handle special keys that require WMI communication.
Change-Id Ic4d9b35f8b1f2b48c7c26e7259b4d05951021b58Signed-off-by Ionut Nechita <[email protected]>--- drivers/hid/hid-asus.c | 24 ++++++++++++++++++++++ include/linux/platform_data/x86/asus-wmi.h | 1 + 2 files changed, 25 insertions(+)drivers/hid/hid-asus.c +1
-0@@ -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 ; }
Quoted 13 lines
drivers/hid/hid-asus.c static int asus_e1239t_event(struct asus_drvdata *drvdat, u8 *data, int size) · line 334
Quoted 10 lines
drivers/hid/hid-asus.c +10
-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);This code is based on the fact asus-wmi driver is available:
are you sure this doesn't make the kernel compilation fail if such driver is not enabled?
asus-wmi.h has conditional behavior already:
#if IS_REACHABLE(CONFIG_ASUS_WMI)
Quoted 28 lines
Quoted 28 lines
drivers/hid/hid-asus.c +13
-0+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) {include/linux/platform_data/x86/asus-wmi.h +1
-0@@ -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
Denis Benato
Reviewed-byRe: [PATCH 3/4] HID: asus: Add WMI communication infrastructure
Quoted 53 lines · Mario Limonciello
Quoted 43 lines · Denis Benato
Quoted 6 lines · Ionut Nechita (Sunlight Linux)
From: Ionut Nechita <[email protected]>
Add the infrastructure needed for the HID driver to communicate with the asus-wmi driver:
- Add
linux/acpi.hinclude (in alphabetical order)Mentioning the addition of
acpi.hseems a bit too specific for a commit message, but wait for hid maintainers to tell.Quoted 32 lines
- Define
ASUS_WMI_METHODID_NOTIFmethod ID inasus-wmi.h
- Implementasus_wmi_send_event()function to send events to asus-wmiThis infrastructure will be used to handle special keys that require WMI communication.
Change-Id Ic4d9b35f8b1f2b48c7c26e7259b4d05951021b58Signed-off-by Ionut Nechita <[email protected]>---
drivers/hid/hid-asus.c | 24 ++++++++++++++++++++++include/linux/platform_data/x86/asus-wmi.h| 1 +2 files changed, 25 insertions(+)drivers/hid/hid-asus.c +0
-0@@ -23,6 +23,7 @@ /**/ +#include <
linux/acpi.h>
#include <linux/dmi.h>
#include <linux/hid.h>
#include <linux/module.h>drivers/hid/hid-asus.c +0
-0@@ -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
+ */drivers/hid/hid-asus.c +2
-0+static int asus_wmi_send_event (struct asus_drvdata *drvdata,u8 code) +{Quoted 8 lines
Quoted 5 lines
+ int err;
+ u32 retval;
+
+ err = asus_wmi_evaluate_method(ASUS_WMI_METHODID_DEVS, +ASUS_WMI_METHODID_NOTIF, code, &retval);This code is based on the fact asus-wmi driver is available:
are you sure this doesn't make the kernel compilation fail if such driver is not enabled?
Quoted 4 lines
asus-wmi.hhas conditional behavior already:#if
IS_REACHABLE(CONFIG_ASUS_WMI)
Ah yes I missed that.
Quoted 28 lines
Quoted 27 lines
Quoted 27 lines
+ if (err) {
+pr_warn("Failed to notify asus-wmi: %d\n", err); + return err;
+ }drivers/hid/hid-asus.c +9
-0+ + 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)
{include/linux/platform_data/x86/asus-wmi.h +1
-0@@ -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