Skip to content

Commit a720dee

Browse files
flukejonesjwrdegoede
authored andcommitted
hid-asus: use hid for brightness control on keyboard
On almost all ASUS ROG series laptops the MCU used for the USB keyboard also has a HID packet used for setting the brightness. This is usually the same as the WMI method. But in some laptops the WMI method either is missing or doesn't work, so we should default to the HID control. Signed-off-by: Luke D. Jones <luke@ljones.dev> Acked-by: Benjamin Tissoires <bentiss@kernel.org> Link: https://lore.kernel.org/r/20240713074733.77334-2-luke@ljones.dev Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
1 parent bcbfceb commit a720dee

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

drivers/hid/hid-asus.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,12 +492,19 @@ static void asus_kbd_backlight_work(struct work_struct *work)
492492
*/
493493
static bool asus_kbd_wmi_led_control_present(struct hid_device *hdev)
494494
{
495+
struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
495496
u32 value;
496497
int ret;
497498

498499
if (!IS_ENABLED(CONFIG_ASUS_WMI))
499500
return false;
500501

502+
if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD &&
503+
dmi_check_system(asus_use_hid_led_dmi_ids)) {
504+
hid_info(hdev, "using HID for asus::kbd_backlight\n");
505+
return false;
506+
}
507+
501508
ret = asus_wmi_evaluate_method(ASUS_WMI_METHODID_DSTS,
502509
ASUS_WMI_DEVID_KBD_BACKLIGHT, 0, &value);
503510
hid_dbg(hdev, "WMI backlight check: rc %d value %x", ret, value);

drivers/platform/x86/asus-wmi.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1714,7 +1714,8 @@ static int asus_wmi_led_init(struct asus_wmi *asus)
17141714
goto error;
17151715
}
17161716

1717-
if (!kbd_led_read(asus, &led_val, NULL)) {
1717+
if (!kbd_led_read(asus, &led_val, NULL) && !dmi_check_system(asus_use_hid_led_dmi_ids)) {
1718+
pr_info("using asus-wmi for asus::kbd_backlight\n");
17181719
asus->kbd_led_wk = led_val;
17191720
asus->kbd_led.name = "asus::kbd_backlight";
17201721
asus->kbd_led.flags = LED_BRIGHT_HW_CHANGED;

include/linux/platform_data/x86/asus-wmi.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <linux/errno.h>
66
#include <linux/types.h>
7+
#include <linux/dmi.h>
78

89
/* WMI Methods */
910
#define ASUS_WMI_METHODID_SPEC 0x43455053 /* BIOS SPECification */
@@ -165,4 +166,39 @@ static inline int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1,
165166
}
166167
#endif
167168

169+
/* To be used by both hid-asus and asus-wmi to determine which controls kbd_brightness */
170+
static const struct dmi_system_id asus_use_hid_led_dmi_ids[] = {
171+
{
172+
.matches = {
173+
DMI_MATCH(DMI_PRODUCT_FAMILY, "ROG Zephyrus"),
174+
},
175+
},
176+
{
177+
.matches = {
178+
DMI_MATCH(DMI_PRODUCT_FAMILY, "ROG Strix"),
179+
},
180+
},
181+
{
182+
.matches = {
183+
DMI_MATCH(DMI_PRODUCT_FAMILY, "ROG Flow"),
184+
},
185+
},
186+
{
187+
.matches = {
188+
DMI_MATCH(DMI_BOARD_NAME, "GA403U"),
189+
},
190+
},
191+
{
192+
.matches = {
193+
DMI_MATCH(DMI_BOARD_NAME, "GU605M"),
194+
},
195+
},
196+
{
197+
.matches = {
198+
DMI_MATCH(DMI_BOARD_NAME, "RC71L"),
199+
},
200+
},
201+
{ },
202+
};
203+
168204
#endif /* __PLATFORM_DATA_X86_ASUS_WMI_H */

0 commit comments

Comments
 (0)