mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
HID: asus: always fully initialize devices
ASUS has more devices other than laptop keyboards which needs to be initializated: the init sequence is the same as keyboards. ID1 and ID2 are USB report IDs that are correctly enumerated: send init commands to all devices that supports those reports IDs. Signed-off-by: Denis Benato <denis.benato@linux.dev> Signed-off-by: Jiri Kosina <jkosina@suse.com>
This commit is contained in:
committed by
Jiri Kosina
parent
f50822fd86
commit
0919db9f35
+35
-11
@@ -101,7 +101,6 @@ MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad");
|
||||
#define QUIRK_ROG_CLAYMORE_II_KEYBOARD BIT(12)
|
||||
#define QUIRK_ROG_ALLY_XPAD BIT(13)
|
||||
#define QUIRK_HID_FN_LOCK BIT(14)
|
||||
#define QUIRK_ROG_NKEY_ID1ID2_INIT BIT(15)
|
||||
|
||||
#define I2C_KEYBOARD_QUIRKS (QUIRK_FIX_NOTEBOOK_REPORT | \
|
||||
QUIRK_NO_INIT_REPORTS | \
|
||||
@@ -208,6 +207,12 @@ static const struct asus_touchpad_info medion_e1239t_tp = {
|
||||
.report_size = 32 /* 2 byte header + 5 * 5 + 5 byte footer */,
|
||||
};
|
||||
|
||||
static const u8 asus_report_id_init[] = {
|
||||
FEATURE_KBD_REPORT_ID,
|
||||
FEATURE_KBD_LED_REPORT_ID1,
|
||||
FEATURE_KBD_LED_REPORT_ID2
|
||||
};
|
||||
|
||||
static void asus_report_contact_down(struct asus_drvdata *drvdat,
|
||||
int toolType, u8 *data)
|
||||
{
|
||||
@@ -722,6 +727,21 @@ static void validate_mcu_fw_version(struct hid_device *hdev, int idProduct)
|
||||
}
|
||||
}
|
||||
|
||||
static bool asus_has_report_id(struct hid_device *hdev, u16 report_id)
|
||||
{
|
||||
int t, f, u, err = 0;
|
||||
struct hid_report *report;
|
||||
|
||||
for (t = HID_INPUT_REPORT; t <= HID_FEATURE_REPORT; t++) {
|
||||
list_for_each_entry(report, &hdev->report_enum[t].report_list, list) {
|
||||
if (report->id == report_id)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static int asus_kbd_register_leds(struct hid_device *hdev)
|
||||
{
|
||||
struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
|
||||
@@ -730,9 +750,9 @@ static int asus_kbd_register_leds(struct hid_device *hdev)
|
||||
unsigned char kbd_func;
|
||||
int ret;
|
||||
|
||||
ret = asus_kbd_init(hdev, FEATURE_KBD_REPORT_ID);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
/* Laptops keyboard backlight is always at 0x5a */
|
||||
if (asus_has_report_id(hdev, FEATURE_KBD_REPORT_ID))
|
||||
return -ENODEV;
|
||||
|
||||
/* Get keyboard functions */
|
||||
ret = asus_kbd_get_functions(hdev, &kbd_func, FEATURE_KBD_REPORT_ID);
|
||||
@@ -743,11 +763,6 @@ static int asus_kbd_register_leds(struct hid_device *hdev)
|
||||
if (!(kbd_func & SUPPORT_KBD_BACKLIGHT))
|
||||
return -ENODEV;
|
||||
|
||||
if (drvdata->quirks & QUIRK_ROG_NKEY_ID1ID2_INIT) {
|
||||
asus_kbd_init(hdev, FEATURE_KBD_LED_REPORT_ID1);
|
||||
asus_kbd_init(hdev, FEATURE_KBD_LED_REPORT_ID2);
|
||||
}
|
||||
|
||||
if (dmi_match(DMI_PRODUCT_FAMILY, "ProArt P16")) {
|
||||
ret = asus_kbd_disable_oobe(hdev);
|
||||
if (ret < 0)
|
||||
@@ -1294,6 +1309,15 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (int r = 0; r < ARRAY_SIZE(asus_report_id_init); r++) {
|
||||
if (asus_has_report_id(hdev, asus_report_id_init[r])) {
|
||||
ret = asus_kbd_init(hdev, asus_report_id_init[r]);
|
||||
if (ret < 0)
|
||||
hid_warn(hdev, "Failed to initialize 0x%x: %d.\n",
|
||||
asus_report_id_init[r], ret);
|
||||
}
|
||||
}
|
||||
|
||||
if (is_vendor && (drvdata->quirks & QUIRK_USE_KBD_BACKLIGHT) &&
|
||||
asus_kbd_register_leds(hdev))
|
||||
hid_warn(hdev, "Failed to initialize backlight.\n");
|
||||
@@ -1477,10 +1501,10 @@ static const struct hid_device_id asus_devices[] = {
|
||||
QUIRK_USE_KBD_BACKLIGHT },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
|
||||
USB_DEVICE_ID_ASUSTEK_ROG_NKEY_KEYBOARD),
|
||||
QUIRK_USE_KBD_BACKLIGHT | QUIRK_ROG_NKEY_KEYBOARD | QUIRK_ROG_NKEY_ID1ID2_INIT },
|
||||
QUIRK_USE_KBD_BACKLIGHT | QUIRK_ROG_NKEY_KEYBOARD },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
|
||||
USB_DEVICE_ID_ASUSTEK_ROG_NKEY_KEYBOARD2),
|
||||
QUIRK_USE_KBD_BACKLIGHT | QUIRK_ROG_NKEY_KEYBOARD | QUIRK_HID_FN_LOCK | QUIRK_ROG_NKEY_ID1ID2_INIT },
|
||||
QUIRK_USE_KBD_BACKLIGHT | QUIRK_ROG_NKEY_KEYBOARD | QUIRK_HID_FN_LOCK },
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
|
||||
USB_DEVICE_ID_ASUSTEK_ROG_Z13_LIGHTBAR),
|
||||
QUIRK_USE_KBD_BACKLIGHT | QUIRK_ROG_NKEY_KEYBOARD },
|
||||
|
||||
Reference in New Issue
Block a user