|
29 | 29 | #include <linux/dmi.h>
|
30 | 30 | #include <linux/hid.h>
|
31 | 31 | #include <linux/module.h>
|
| 32 | +#include <linux/platform_data/x86/asus-wmi.h> |
32 | 33 | #include <linux/input/mt.h>
|
33 | 34 | #include <linux/usb.h> /* For to_usb_interface for T100 touchpad intf check */
|
34 | 35 |
|
@@ -349,6 +350,24 @@ static void asus_kbd_backlight_work(struct work_struct *work)
|
349 | 350 | hid_err(led->hdev, "Asus failed to set keyboard backlight: %d\n", ret);
|
350 | 351 | }
|
351 | 352 |
|
| 353 | +/* WMI-based keyboard backlight LED control (via asus-wmi driver) takes |
| 354 | + * precedence. We only activate HID-based backlight control when the |
| 355 | + * WMI control is not available. |
| 356 | + */ |
| 357 | +static bool asus_kbd_wmi_led_control_present(struct hid_device *hdev) |
| 358 | +{ |
| 359 | + u32 value; |
| 360 | + int ret; |
| 361 | + |
| 362 | + ret = asus_wmi_evaluate_method(ASUS_WMI_METHODID_DSTS2, |
| 363 | + ASUS_WMI_DEVID_KBD_BACKLIGHT, 0, &value); |
| 364 | + hid_dbg(hdev, "WMI backlight check: rc %d value %x", ret, value); |
| 365 | + if (ret) |
| 366 | + return false; |
| 367 | + |
| 368 | + return !!(value & ASUS_WMI_DSTS_PRESENCE_BIT); |
| 369 | +} |
| 370 | + |
352 | 371 | static int asus_kbd_register_leds(struct hid_device *hdev)
|
353 | 372 | {
|
354 | 373 | struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
|
@@ -436,7 +455,9 @@ static int asus_input_configured(struct hid_device *hdev, struct hid_input *hi)
|
436 | 455 |
|
437 | 456 | drvdata->input = input;
|
438 | 457 |
|
439 |
| - if (drvdata->enable_backlight && asus_kbd_register_leds(hdev)) |
| 458 | + if (drvdata->enable_backlight && |
| 459 | + !asus_kbd_wmi_led_control_present(hdev) && |
| 460 | + asus_kbd_register_leds(hdev)) |
440 | 461 | hid_warn(hdev, "Failed to initialize backlight.\n");
|
441 | 462 |
|
442 | 463 | return 0;
|
|
0 commit comments