]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
hid-asus: use hid for brightness control on keyboard
authorLuke D. Jones <luke@ljones.dev>
Sat, 13 Jul 2024 07:47:33 +0000 (19:47 +1200)
committerHans de Goede <hdegoede@redhat.com>
Mon, 5 Aug 2024 14:56:02 +0000 (16:56 +0200)
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>
drivers/hid/hid-asus.c
drivers/platform/x86/asus-wmi.c
include/linux/platform_data/x86/asus-wmi.h

index 37e6d25593c211d202ccb8f6996b1cd2818ee69e..af57a5f03193b8ffefdd09b9bb1b64c98d1dff2c 100644 (file)
@@ -492,12 +492,19 @@ static void asus_kbd_backlight_work(struct work_struct *work)
  */
 static bool asus_kbd_wmi_led_control_present(struct hid_device *hdev)
 {
+       struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
        u32 value;
        int ret;
 
        if (!IS_ENABLED(CONFIG_ASUS_WMI))
                return false;
 
+       if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD &&
+                       dmi_check_system(asus_use_hid_led_dmi_ids)) {
+               hid_info(hdev, "using HID for asus::kbd_backlight\n");
+               return false;
+       }
+
        ret = asus_wmi_evaluate_method(ASUS_WMI_METHODID_DSTS,
                                       ASUS_WMI_DEVID_KBD_BACKLIGHT, 0, &value);
        hid_dbg(hdev, "WMI backlight check: rc %d value %x", ret, value);
index 00669cf678fb17d1502d69d5c05526fade8331e2..35ebb37f68bfb872e515c69e928f9f420ec32ff0 100644 (file)
@@ -1714,7 +1714,8 @@ static int asus_wmi_led_init(struct asus_wmi *asus)
                        goto error;
        }
 
-       if (!kbd_led_read(asus, &led_val, NULL)) {
+       if (!kbd_led_read(asus, &led_val, NULL) && !dmi_check_system(asus_use_hid_led_dmi_ids)) {
+               pr_info("using asus-wmi for asus::kbd_backlight\n");
                asus->kbd_led_wk = led_val;
                asus->kbd_led.name = "asus::kbd_backlight";
                asus->kbd_led.flags = LED_BRIGHT_HW_CHANGED;
index 5e6f407b2def54d76bb42f9406c6719fcf63ab49..b601b245a035a90be41de2d5615c9bd31b72d2d5 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <linux/errno.h>
 #include <linux/types.h>
+#include <linux/dmi.h>
 
 /* WMI Methods */
 #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,
 }
 #endif
 
+/* To be used by both hid-asus and asus-wmi to determine which controls kbd_brightness */
+static const struct dmi_system_id asus_use_hid_led_dmi_ids[] = {
+       {
+               .matches = {
+                       DMI_MATCH(DMI_PRODUCT_FAMILY, "ROG Zephyrus"),
+               },
+       },
+       {
+               .matches = {
+                       DMI_MATCH(DMI_PRODUCT_FAMILY, "ROG Strix"),
+               },
+       },
+       {
+               .matches = {
+                       DMI_MATCH(DMI_PRODUCT_FAMILY, "ROG Flow"),
+               },
+       },
+       {
+               .matches = {
+                       DMI_MATCH(DMI_BOARD_NAME, "GA403U"),
+               },
+       },
+       {
+               .matches = {
+                       DMI_MATCH(DMI_BOARD_NAME, "GU605M"),
+               },
+       },
+       {
+               .matches = {
+                       DMI_MATCH(DMI_BOARD_NAME, "RC71L"),
+               },
+       },
+       { },
+};
+
 #endif /* __PLATFORM_DATA_X86_ASUS_WMI_H */