1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * HID driver for Asus notebook built-in keyboard.
4 * Fixes small logical maximum to match usage maximum.
5 *
6 * Currently supported devices are:
7 * EeeBook X205TA
8 * VivoBook E200HA
9 *
10 * Copyright (c) 2016 Yusuke Fujimaki <usk.fujimaki@gmail.com>
11 *
12 * This module based on hid-ortek by
13 * Copyright (c) 2010 Johnathon Harris <jmharris@gmail.com>
14 * Copyright (c) 2011 Jiri Kosina
15 *
16 * This module has been updated to add support for Asus i2c touchpad.
17 *
18 * Copyright (c) 2016 Brendan McGrath <redmcg@redmandi.dyndns.org>
19 * Copyright (c) 2016 Victor Vlasenko <victor.vlasenko@sysgears.com>
20 * Copyright (c) 2016 Frederik Wenigwieser <frederik.wenigwieser@gmail.com>
21 */
22
23 /*
24 */
25
26 #include <linux/dmi.h>
27 #include <linux/hid.h>
28 #include <linux/module.h>
29 #include <linux/platform_data/x86/asus-wmi.h>
30 #include <linux/input/mt.h>
31 #include <linux/usb.h> /* For to_usb_interface for T100 touchpad intf check */
32 #include <linux/power_supply.h>
33
34 #include "hid-ids.h"
35
36 MODULE_AUTHOR("Yusuke Fujimaki <usk.fujimaki@gmail.com>");
37 MODULE_AUTHOR("Brendan McGrath <redmcg@redmandi.dyndns.org>");
38 MODULE_AUTHOR("Victor Vlasenko <victor.vlasenko@sysgears.com>");
39 MODULE_AUTHOR("Frederik Wenigwieser <frederik.wenigwieser@gmail.com>");
40 MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad");
41
42 #define T100_TPAD_INTF 2
43 #define MEDION_E1239T_TPAD_INTF 1
44
45 #define E1239T_TP_TOGGLE_REPORT_ID 0x05
46 #define T100CHI_MOUSE_REPORT_ID 0x06
47 #define FEATURE_REPORT_ID 0x0d
48 #define INPUT_REPORT_ID 0x5d
49 #define FEATURE_KBD_REPORT_ID 0x5a
50 #define FEATURE_KBD_REPORT_SIZE 16
51
52 #define SUPPORT_KBD_BACKLIGHT BIT(0)
53
54 #define MAX_TOUCH_MAJOR 8
55 #define MAX_PRESSURE 128
56
57 #define BTN_LEFT_MASK 0x01
58 #define CONTACT_TOOL_TYPE_MASK 0x80
59 #define CONTACT_X_MSB_MASK 0xf0
60 #define CONTACT_Y_MSB_MASK 0x0f
61 #define CONTACT_TOUCH_MAJOR_MASK 0x07
62 #define CONTACT_PRESSURE_MASK 0x7f
63
64 #define BATTERY_REPORT_ID (0x03)
65 #define BATTERY_REPORT_SIZE (1 + 8)
66 #define BATTERY_LEVEL_MAX ((u8)255)
67 #define BATTERY_STAT_DISCONNECT (0)
68 #define BATTERY_STAT_CHARGING (1)
69 #define BATTERY_STAT_FULL (2)
70
71 #define QUIRK_FIX_NOTEBOOK_REPORT BIT(0)
72 #define QUIRK_NO_INIT_REPORTS BIT(1)
73 #define QUIRK_SKIP_INPUT_MAPPING BIT(2)
74 #define QUIRK_IS_MULTITOUCH BIT(3)
75 #define QUIRK_NO_CONSUMER_USAGES BIT(4)
76 #define QUIRK_USE_KBD_BACKLIGHT BIT(5)
77 #define QUIRK_T100_KEYBOARD BIT(6)
78 #define QUIRK_T100CHI BIT(7)
79 #define QUIRK_G752_KEYBOARD BIT(8)
80 #define QUIRK_T101HA_DOCK BIT(9)
81 #define QUIRK_T90CHI BIT(10)
82 #define QUIRK_MEDION_E1239T BIT(11)
83
84 #define I2C_KEYBOARD_QUIRKS (QUIRK_FIX_NOTEBOOK_REPORT | \
85 QUIRK_NO_INIT_REPORTS | \
86 QUIRK_NO_CONSUMER_USAGES)
87 #define I2C_TOUCHPAD_QUIRKS (QUIRK_NO_INIT_REPORTS | \
88 QUIRK_SKIP_INPUT_MAPPING | \
89 QUIRK_IS_MULTITOUCH)
90
91 #define TRKID_SGN ((TRKID_MAX + 1) >> 1)
92
93 struct asus_kbd_leds {
94 struct led_classdev cdev;
95 struct hid_device *hdev;
96 struct work_struct work;
97 unsigned int brightness;
98 spinlock_t lock;
99 bool removed;
100 };
101
102 struct asus_touchpad_info {
103 int max_x;
104 int max_y;
105 int res_x;
106 int res_y;
107 int contact_size;
108 int max_contacts;
109 int report_size;
110 };
111
112 struct asus_drvdata {
113 unsigned long quirks;
114 struct hid_device *hdev;
115 struct input_dev *input;
116 struct input_dev *tp_kbd_input;
117 struct asus_kbd_leds *kbd_backlight;
118 const struct asus_touchpad_info *tp;
119 bool enable_backlight;
120 struct power_supply *battery;
121 struct power_supply_desc battery_desc;
122 int battery_capacity;
123 int battery_stat;
124 bool battery_in_query;
125 unsigned long battery_next_query;
126 };
127
128 static int asus_report_battery(struct asus_drvdata *, u8 *, int);
129
130 static const struct asus_touchpad_info asus_i2c_tp = {
131 .max_x = 2794,
132 .max_y = 1758,
133 .contact_size = 5,
134 .max_contacts = 5,
135 .report_size = 28 /* 2 byte header + 5 * 5 + 1 byte footer */,
136 };
137
138 static const struct asus_touchpad_info asus_t100ta_tp = {
139 .max_x = 2240,
140 .max_y = 1120,
141 .res_x = 30, /* units/mm */
142 .res_y = 27, /* units/mm */
143 .contact_size = 5,
144 .max_contacts = 5,
145 .report_size = 28 /* 2 byte header + 5 * 5 + 1 byte footer */,
146 };
147
148 static const struct asus_touchpad_info asus_t100ha_tp = {
149 .max_x = 2640,
150 .max_y = 1320,
151 .res_x = 30, /* units/mm */
152 .res_y = 29, /* units/mm */
153 .contact_size = 5,
154 .max_contacts = 5,
155 .report_size = 28 /* 2 byte header + 5 * 5 + 1 byte footer */,
156 };
157
158 static const struct asus_touchpad_info asus_t200ta_tp = {
159 .max_x = 3120,
160 .max_y = 1716,
161 .res_x = 30, /* units/mm */
162 .res_y = 28, /* units/mm */
163 .contact_size = 5,
164 .max_contacts = 5,
165 .report_size = 28 /* 2 byte header + 5 * 5 + 1 byte footer */,
166 };
167
168 static const struct asus_touchpad_info asus_t100chi_tp = {
169 .max_x = 2640,
170 .max_y = 1320,
171 .res_x = 31, /* units/mm */
172 .res_y = 29, /* units/mm */
173 .contact_size = 3,
174 .max_contacts = 4,
175 .report_size = 15 /* 2 byte header + 3 * 4 + 1 byte footer */,
176 };
177
178 static const struct asus_touchpad_info medion_e1239t_tp = {
179 .max_x = 2640,
180 .max_y = 1380,
181 .res_x = 29, /* units/mm */
182 .res_y = 28, /* units/mm */
183 .contact_size = 5,
184 .max_contacts = 5,
185 .report_size = 32 /* 2 byte header + 5 * 5 + 5 byte footer */,
186 };
187
asus_report_contact_down(struct asus_drvdata * drvdat,int toolType,u8 * data)188 static void asus_report_contact_down(struct asus_drvdata *drvdat,
189 int toolType, u8 *data)
190 {
191 struct input_dev *input = drvdat->input;
192 int touch_major, pressure, x, y;
193
194 x = (data[0] & CONTACT_X_MSB_MASK) << 4 | data[1];
195 y = drvdat->tp->max_y - ((data[0] & CONTACT_Y_MSB_MASK) << 8 | data[2]);
196
197 input_report_abs(input, ABS_MT_POSITION_X, x);
198 input_report_abs(input, ABS_MT_POSITION_Y, y);
199
200 if (drvdat->tp->contact_size < 5)
201 return;
202
203 if (toolType == MT_TOOL_PALM) {
204 touch_major = MAX_TOUCH_MAJOR;
205 pressure = MAX_PRESSURE;
206 } else {
207 touch_major = (data[3] >> 4) & CONTACT_TOUCH_MAJOR_MASK;
208 pressure = data[4] & CONTACT_PRESSURE_MASK;
209 }
210
211 input_report_abs(input, ABS_MT_TOUCH_MAJOR, touch_major);
212 input_report_abs(input, ABS_MT_PRESSURE, pressure);
213 }
214
215 /* Required for Synaptics Palm Detection */
asus_report_tool_width(struct asus_drvdata * drvdat)216 static void asus_report_tool_width(struct asus_drvdata *drvdat)
217 {
218 struct input_mt *mt = drvdat->input->mt;
219 struct input_mt_slot *oldest;
220 int oldid, count, i;
221
222 if (drvdat->tp->contact_size < 5)
223 return;
224
225 oldest = NULL;
226 oldid = mt->trkid;
227 count = 0;
228
229 for (i = 0; i < mt->num_slots; ++i) {
230 struct input_mt_slot *ps = &mt->slots[i];
231 int id = input_mt_get_value(ps, ABS_MT_TRACKING_ID);
232
233 if (id < 0)
234 continue;
235 if ((id - oldid) & TRKID_SGN) {
236 oldest = ps;
237 oldid = id;
238 }
239 count++;
240 }
241
242 if (oldest) {
243 input_report_abs(drvdat->input, ABS_TOOL_WIDTH,
244 input_mt_get_value(oldest, ABS_MT_TOUCH_MAJOR));
245 }
246 }
247
asus_report_input(struct asus_drvdata * drvdat,u8 * data,int size)248 static int asus_report_input(struct asus_drvdata *drvdat, u8 *data, int size)
249 {
250 int i, toolType = MT_TOOL_FINGER;
251 u8 *contactData = data + 2;
252
253 if (size != drvdat->tp->report_size)
254 return 0;
255
256 for (i = 0; i < drvdat->tp->max_contacts; i++) {
257 bool down = !!(data[1] & BIT(i+3));
258
259 if (drvdat->tp->contact_size >= 5)
260 toolType = contactData[3] & CONTACT_TOOL_TYPE_MASK ?
261 MT_TOOL_PALM : MT_TOOL_FINGER;
262
263 input_mt_slot(drvdat->input, i);
264 input_mt_report_slot_state(drvdat->input, toolType, down);
265
266 if (down) {
267 asus_report_contact_down(drvdat, toolType, contactData);
268 contactData += drvdat->tp->contact_size;
269 }
270 }
271
272 input_report_key(drvdat->input, BTN_LEFT, data[1] & BTN_LEFT_MASK);
273 asus_report_tool_width(drvdat);
274
275 input_mt_sync_frame(drvdat->input);
276 input_sync(drvdat->input);
277
278 return 1;
279 }
280
asus_e1239t_event(struct asus_drvdata * drvdat,u8 * data,int size)281 static int asus_e1239t_event(struct asus_drvdata *drvdat, u8 *data, int size)
282 {
283 if (size != 3)
284 return 0;
285
286 /* Handle broken mute key which only sends press events */
287 if (!drvdat->tp &&
288 data[0] == 0x02 && data[1] == 0xe2 && data[2] == 0x00) {
289 input_report_key(drvdat->input, KEY_MUTE, 1);
290 input_sync(drvdat->input);
291 input_report_key(drvdat->input, KEY_MUTE, 0);
292 input_sync(drvdat->input);
293 return 1;
294 }
295
296 /* Handle custom touchpad toggle key which only sends press events */
297 if (drvdat->tp_kbd_input &&
298 data[0] == 0x05 && data[1] == 0x02 && data[2] == 0x28) {
299 input_report_key(drvdat->tp_kbd_input, KEY_F21, 1);
300 input_sync(drvdat->tp_kbd_input);
301 input_report_key(drvdat->tp_kbd_input, KEY_F21, 0);
302 input_sync(drvdat->tp_kbd_input);
303 return 1;
304 }
305
306 return 0;
307 }
308
asus_event(struct hid_device * hdev,struct hid_field * field,struct hid_usage * usage,__s32 value)309 static int asus_event(struct hid_device *hdev, struct hid_field *field,
310 struct hid_usage *usage, __s32 value)
311 {
312 if ((usage->hid & HID_USAGE_PAGE) == 0xff310000 &&
313 (usage->hid & HID_USAGE) != 0x00 &&
314 (usage->hid & HID_USAGE) != 0xff && !usage->type) {
315 hid_warn(hdev, "Unmapped Asus vendor usagepage code 0x%02x\n",
316 usage->hid & HID_USAGE);
317 }
318
319 return 0;
320 }
321
asus_raw_event(struct hid_device * hdev,struct hid_report * report,u8 * data,int size)322 static int asus_raw_event(struct hid_device *hdev,
323 struct hid_report *report, u8 *data, int size)
324 {
325 struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
326
327 if (drvdata->battery && data[0] == BATTERY_REPORT_ID)
328 return asus_report_battery(drvdata, data, size);
329
330 if (drvdata->tp && data[0] == INPUT_REPORT_ID)
331 return asus_report_input(drvdata, data, size);
332
333 if (drvdata->quirks & QUIRK_MEDION_E1239T)
334 return asus_e1239t_event(drvdata, data, size);
335
336 return 0;
337 }
338
asus_kbd_set_report(struct hid_device * hdev,u8 * buf,size_t buf_size)339 static int asus_kbd_set_report(struct hid_device *hdev, u8 *buf, size_t buf_size)
340 {
341 unsigned char *dmabuf;
342 int ret;
343
344 dmabuf = kmemdup(buf, buf_size, GFP_KERNEL);
345 if (!dmabuf)
346 return -ENOMEM;
347
348 ret = hid_hw_raw_request(hdev, FEATURE_KBD_REPORT_ID, dmabuf,
349 buf_size, HID_FEATURE_REPORT,
350 HID_REQ_SET_REPORT);
351 kfree(dmabuf);
352
353 return ret;
354 }
355
asus_kbd_init(struct hid_device * hdev)356 static int asus_kbd_init(struct hid_device *hdev)
357 {
358 u8 buf[] = { FEATURE_KBD_REPORT_ID, 0x41, 0x53, 0x55, 0x53, 0x20, 0x54,
359 0x65, 0x63, 0x68, 0x2e, 0x49, 0x6e, 0x63, 0x2e, 0x00 };
360 int ret;
361
362 ret = asus_kbd_set_report(hdev, buf, sizeof(buf));
363 if (ret < 0)
364 hid_err(hdev, "Asus failed to send init command: %d\n", ret);
365
366 return ret;
367 }
368
asus_kbd_get_functions(struct hid_device * hdev,unsigned char * kbd_func)369 static int asus_kbd_get_functions(struct hid_device *hdev,
370 unsigned char *kbd_func)
371 {
372 u8 buf[] = { FEATURE_KBD_REPORT_ID, 0x05, 0x20, 0x31, 0x00, 0x08 };
373 u8 *readbuf;
374 int ret;
375
376 ret = asus_kbd_set_report(hdev, buf, sizeof(buf));
377 if (ret < 0) {
378 hid_err(hdev, "Asus failed to send configuration command: %d\n", ret);
379 return ret;
380 }
381
382 readbuf = kzalloc(FEATURE_KBD_REPORT_SIZE, GFP_KERNEL);
383 if (!readbuf)
384 return -ENOMEM;
385
386 ret = hid_hw_raw_request(hdev, FEATURE_KBD_REPORT_ID, readbuf,
387 FEATURE_KBD_REPORT_SIZE, HID_FEATURE_REPORT,
388 HID_REQ_GET_REPORT);
389 if (ret < 0) {
390 hid_err(hdev, "Asus failed to request functions: %d\n", ret);
391 kfree(readbuf);
392 return ret;
393 }
394
395 *kbd_func = readbuf[6];
396
397 kfree(readbuf);
398 return ret;
399 }
400
asus_schedule_work(struct asus_kbd_leds * led)401 static void asus_schedule_work(struct asus_kbd_leds *led)
402 {
403 unsigned long flags;
404
405 spin_lock_irqsave(&led->lock, flags);
406 if (!led->removed)
407 schedule_work(&led->work);
408 spin_unlock_irqrestore(&led->lock, flags);
409 }
410
asus_kbd_backlight_set(struct led_classdev * led_cdev,enum led_brightness brightness)411 static void asus_kbd_backlight_set(struct led_classdev *led_cdev,
412 enum led_brightness brightness)
413 {
414 struct asus_kbd_leds *led = container_of(led_cdev, struct asus_kbd_leds,
415 cdev);
416 unsigned long flags;
417
418 spin_lock_irqsave(&led->lock, flags);
419 led->brightness = brightness;
420 spin_unlock_irqrestore(&led->lock, flags);
421
422 asus_schedule_work(led);
423 }
424
asus_kbd_backlight_get(struct led_classdev * led_cdev)425 static enum led_brightness asus_kbd_backlight_get(struct led_classdev *led_cdev)
426 {
427 struct asus_kbd_leds *led = container_of(led_cdev, struct asus_kbd_leds,
428 cdev);
429 enum led_brightness brightness;
430 unsigned long flags;
431
432 spin_lock_irqsave(&led->lock, flags);
433 brightness = led->brightness;
434 spin_unlock_irqrestore(&led->lock, flags);
435
436 return brightness;
437 }
438
asus_kbd_backlight_work(struct work_struct * work)439 static void asus_kbd_backlight_work(struct work_struct *work)
440 {
441 struct asus_kbd_leds *led = container_of(work, struct asus_kbd_leds, work);
442 u8 buf[] = { FEATURE_KBD_REPORT_ID, 0xba, 0xc5, 0xc4, 0x00 };
443 int ret;
444 unsigned long flags;
445
446 spin_lock_irqsave(&led->lock, flags);
447 buf[4] = led->brightness;
448 spin_unlock_irqrestore(&led->lock, flags);
449
450 ret = asus_kbd_set_report(led->hdev, buf, sizeof(buf));
451 if (ret < 0)
452 hid_err(led->hdev, "Asus failed to set keyboard backlight: %d\n", ret);
453 }
454
455 /* WMI-based keyboard backlight LED control (via asus-wmi driver) takes
456 * precedence. We only activate HID-based backlight control when the
457 * WMI control is not available.
458 */
asus_kbd_wmi_led_control_present(struct hid_device * hdev)459 static bool asus_kbd_wmi_led_control_present(struct hid_device *hdev)
460 {
461 u32 value;
462 int ret;
463
464 if (!IS_ENABLED(CONFIG_ASUS_WMI))
465 return false;
466
467 ret = asus_wmi_evaluate_method(ASUS_WMI_METHODID_DSTS,
468 ASUS_WMI_DEVID_KBD_BACKLIGHT, 0, &value);
469 hid_dbg(hdev, "WMI backlight check: rc %d value %x", ret, value);
470 if (ret)
471 return false;
472
473 return !!(value & ASUS_WMI_DSTS_PRESENCE_BIT);
474 }
475
asus_kbd_register_leds(struct hid_device * hdev)476 static int asus_kbd_register_leds(struct hid_device *hdev)
477 {
478 struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
479 unsigned char kbd_func;
480 int ret;
481
482 /* Initialize keyboard */
483 ret = asus_kbd_init(hdev);
484 if (ret < 0)
485 return ret;
486
487 /* Get keyboard functions */
488 ret = asus_kbd_get_functions(hdev, &kbd_func);
489 if (ret < 0)
490 return ret;
491
492 /* Check for backlight support */
493 if (!(kbd_func & SUPPORT_KBD_BACKLIGHT))
494 return -ENODEV;
495
496 drvdata->kbd_backlight = devm_kzalloc(&hdev->dev,
497 sizeof(struct asus_kbd_leds),
498 GFP_KERNEL);
499 if (!drvdata->kbd_backlight)
500 return -ENOMEM;
501
502 drvdata->kbd_backlight->removed = false;
503 drvdata->kbd_backlight->brightness = 0;
504 drvdata->kbd_backlight->hdev = hdev;
505 drvdata->kbd_backlight->cdev.name = "asus::kbd_backlight";
506 drvdata->kbd_backlight->cdev.max_brightness = 3;
507 drvdata->kbd_backlight->cdev.brightness_set = asus_kbd_backlight_set;
508 drvdata->kbd_backlight->cdev.brightness_get = asus_kbd_backlight_get;
509 INIT_WORK(&drvdata->kbd_backlight->work, asus_kbd_backlight_work);
510 spin_lock_init(&drvdata->kbd_backlight->lock);
511
512 ret = devm_led_classdev_register(&hdev->dev, &drvdata->kbd_backlight->cdev);
513 if (ret < 0) {
514 /* No need to have this still around */
515 devm_kfree(&hdev->dev, drvdata->kbd_backlight);
516 }
517
518 return ret;
519 }
520
521 /*
522 * [0] REPORT_ID (same value defined in report descriptor)
523 * [1] rest battery level. range [0..255]
524 * [2]..[7] Bluetooth hardware address (MAC address)
525 * [8] charging status
526 * = 0 : AC offline / discharging
527 * = 1 : AC online / charging
528 * = 2 : AC online / fully charged
529 */
asus_parse_battery(struct asus_drvdata * drvdata,u8 * data,int size)530 static int asus_parse_battery(struct asus_drvdata *drvdata, u8 *data, int size)
531 {
532 u8 sts;
533 u8 lvl;
534 int val;
535
536 lvl = data[1];
537 sts = data[8];
538
539 drvdata->battery_capacity = ((int)lvl * 100) / (int)BATTERY_LEVEL_MAX;
540
541 switch (sts) {
542 case BATTERY_STAT_CHARGING:
543 val = POWER_SUPPLY_STATUS_CHARGING;
544 break;
545 case BATTERY_STAT_FULL:
546 val = POWER_SUPPLY_STATUS_FULL;
547 break;
548 case BATTERY_STAT_DISCONNECT:
549 default:
550 val = POWER_SUPPLY_STATUS_DISCHARGING;
551 break;
552 }
553 drvdata->battery_stat = val;
554
555 return 0;
556 }
557
asus_report_battery(struct asus_drvdata * drvdata,u8 * data,int size)558 static int asus_report_battery(struct asus_drvdata *drvdata, u8 *data, int size)
559 {
560 /* notify only the autonomous event by device */
561 if ((drvdata->battery_in_query == false) &&
562 (size == BATTERY_REPORT_SIZE))
563 power_supply_changed(drvdata->battery);
564
565 return 0;
566 }
567
asus_battery_query(struct asus_drvdata * drvdata)568 static int asus_battery_query(struct asus_drvdata *drvdata)
569 {
570 u8 *buf;
571 int ret = 0;
572
573 buf = kmalloc(BATTERY_REPORT_SIZE, GFP_KERNEL);
574 if (!buf)
575 return -ENOMEM;
576
577 drvdata->battery_in_query = true;
578 ret = hid_hw_raw_request(drvdata->hdev, BATTERY_REPORT_ID,
579 buf, BATTERY_REPORT_SIZE,
580 HID_INPUT_REPORT, HID_REQ_GET_REPORT);
581 drvdata->battery_in_query = false;
582 if (ret == BATTERY_REPORT_SIZE)
583 ret = asus_parse_battery(drvdata, buf, BATTERY_REPORT_SIZE);
584 else
585 ret = -ENODATA;
586
587 kfree(buf);
588
589 return ret;
590 }
591
592 static enum power_supply_property asus_battery_props[] = {
593 POWER_SUPPLY_PROP_STATUS,
594 POWER_SUPPLY_PROP_PRESENT,
595 POWER_SUPPLY_PROP_CAPACITY,
596 POWER_SUPPLY_PROP_SCOPE,
597 POWER_SUPPLY_PROP_MODEL_NAME,
598 };
599
600 #define QUERY_MIN_INTERVAL (60 * HZ) /* 60[sec] */
601
asus_battery_get_property(struct power_supply * psy,enum power_supply_property psp,union power_supply_propval * val)602 static int asus_battery_get_property(struct power_supply *psy,
603 enum power_supply_property psp,
604 union power_supply_propval *val)
605 {
606 struct asus_drvdata *drvdata = power_supply_get_drvdata(psy);
607 int ret = 0;
608
609 switch (psp) {
610 case POWER_SUPPLY_PROP_STATUS:
611 case POWER_SUPPLY_PROP_CAPACITY:
612 if (time_before(drvdata->battery_next_query, jiffies)) {
613 drvdata->battery_next_query =
614 jiffies + QUERY_MIN_INTERVAL;
615 ret = asus_battery_query(drvdata);
616 if (ret)
617 return ret;
618 }
619 if (psp == POWER_SUPPLY_PROP_STATUS)
620 val->intval = drvdata->battery_stat;
621 else
622 val->intval = drvdata->battery_capacity;
623 break;
624 case POWER_SUPPLY_PROP_PRESENT:
625 val->intval = 1;
626 break;
627 case POWER_SUPPLY_PROP_SCOPE:
628 val->intval = POWER_SUPPLY_SCOPE_DEVICE;
629 break;
630 case POWER_SUPPLY_PROP_MODEL_NAME:
631 val->strval = drvdata->hdev->name;
632 break;
633 default:
634 ret = -EINVAL;
635 break;
636 }
637
638 return ret;
639 }
640
asus_battery_probe(struct hid_device * hdev)641 static int asus_battery_probe(struct hid_device *hdev)
642 {
643 struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
644 struct power_supply_config pscfg = { .drv_data = drvdata };
645 int ret = 0;
646
647 drvdata->battery_capacity = 0;
648 drvdata->battery_stat = POWER_SUPPLY_STATUS_UNKNOWN;
649 drvdata->battery_in_query = false;
650
651 drvdata->battery_desc.properties = asus_battery_props;
652 drvdata->battery_desc.num_properties = ARRAY_SIZE(asus_battery_props);
653 drvdata->battery_desc.get_property = asus_battery_get_property;
654 drvdata->battery_desc.type = POWER_SUPPLY_TYPE_BATTERY;
655 drvdata->battery_desc.use_for_apm = 0;
656 drvdata->battery_desc.name = devm_kasprintf(&hdev->dev, GFP_KERNEL,
657 "asus-keyboard-%s-battery",
658 strlen(hdev->uniq) ?
659 hdev->uniq : dev_name(&hdev->dev));
660 if (!drvdata->battery_desc.name)
661 return -ENOMEM;
662
663 drvdata->battery_next_query = jiffies;
664
665 drvdata->battery = devm_power_supply_register(&hdev->dev,
666 &(drvdata->battery_desc), &pscfg);
667 if (IS_ERR(drvdata->battery)) {
668 ret = PTR_ERR(drvdata->battery);
669 drvdata->battery = NULL;
670 hid_err(hdev, "Unable to register battery device\n");
671 return ret;
672 }
673
674 power_supply_powers(drvdata->battery, &hdev->dev);
675
676 return ret;
677 }
678
asus_input_configured(struct hid_device * hdev,struct hid_input * hi)679 static int asus_input_configured(struct hid_device *hdev, struct hid_input *hi)
680 {
681 struct input_dev *input = hi->input;
682 struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
683
684 /* T100CHI uses MULTI_INPUT, bind the touchpad to the mouse hid_input */
685 if (drvdata->quirks & QUIRK_T100CHI &&
686 hi->report->id != T100CHI_MOUSE_REPORT_ID)
687 return 0;
688
689 /* Handle MULTI_INPUT on E1239T mouse/touchpad USB interface */
690 if (drvdata->tp && (drvdata->quirks & QUIRK_MEDION_E1239T)) {
691 switch (hi->report->id) {
692 case E1239T_TP_TOGGLE_REPORT_ID:
693 input_set_capability(input, EV_KEY, KEY_F21);
694 input->name = "Asus Touchpad Keys";
695 drvdata->tp_kbd_input = input;
696 return 0;
697 case INPUT_REPORT_ID:
698 break; /* Touchpad report, handled below */
699 default:
700 return 0; /* Ignore other reports */
701 }
702 }
703
704 if (drvdata->tp) {
705 int ret;
706
707 input_set_abs_params(input, ABS_MT_POSITION_X, 0,
708 drvdata->tp->max_x, 0, 0);
709 input_set_abs_params(input, ABS_MT_POSITION_Y, 0,
710 drvdata->tp->max_y, 0, 0);
711 input_abs_set_res(input, ABS_MT_POSITION_X, drvdata->tp->res_x);
712 input_abs_set_res(input, ABS_MT_POSITION_Y, drvdata->tp->res_y);
713
714 if (drvdata->tp->contact_size >= 5) {
715 input_set_abs_params(input, ABS_TOOL_WIDTH, 0,
716 MAX_TOUCH_MAJOR, 0, 0);
717 input_set_abs_params(input, ABS_MT_TOUCH_MAJOR, 0,
718 MAX_TOUCH_MAJOR, 0, 0);
719 input_set_abs_params(input, ABS_MT_PRESSURE, 0,
720 MAX_PRESSURE, 0, 0);
721 }
722
723 __set_bit(BTN_LEFT, input->keybit);
724 __set_bit(INPUT_PROP_BUTTONPAD, input->propbit);
725
726 ret = input_mt_init_slots(input, drvdata->tp->max_contacts,
727 INPUT_MT_POINTER);
728
729 if (ret) {
730 hid_err(hdev, "Asus input mt init slots failed: %d\n", ret);
731 return ret;
732 }
733 }
734
735 drvdata->input = input;
736
737 if (drvdata->enable_backlight &&
738 !asus_kbd_wmi_led_control_present(hdev) &&
739 asus_kbd_register_leds(hdev))
740 hid_warn(hdev, "Failed to initialize backlight.\n");
741
742 return 0;
743 }
744
745 #define asus_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, \
746 max, EV_KEY, (c))
asus_input_mapping(struct hid_device * hdev,struct hid_input * hi,struct hid_field * field,struct hid_usage * usage,unsigned long ** bit,int * max)747 static int asus_input_mapping(struct hid_device *hdev,
748 struct hid_input *hi, struct hid_field *field,
749 struct hid_usage *usage, unsigned long **bit,
750 int *max)
751 {
752 struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
753
754 if (drvdata->quirks & QUIRK_SKIP_INPUT_MAPPING) {
755 /* Don't map anything from the HID report.
756 * We do it all manually in asus_input_configured
757 */
758 return -1;
759 }
760
761 /*
762 * Ignore a bunch of bogus collections in the T100CHI descriptor.
763 * This avoids a bunch of non-functional hid_input devices getting
764 * created because of the T100CHI using HID_QUIRK_MULTI_INPUT.
765 */
766 if ((drvdata->quirks & (QUIRK_T100CHI | QUIRK_T90CHI)) &&
767 (field->application == (HID_UP_GENDESK | 0x0080) ||
768 field->application == HID_GD_MOUSE ||
769 usage->hid == (HID_UP_GENDEVCTRLS | 0x0024) ||
770 usage->hid == (HID_UP_GENDEVCTRLS | 0x0025) ||
771 usage->hid == (HID_UP_GENDEVCTRLS | 0x0026)))
772 return -1;
773
774 /* ASUS-specific keyboard hotkeys */
775 if ((usage->hid & HID_USAGE_PAGE) == 0xff310000) {
776 switch (usage->hid & HID_USAGE) {
777 case 0x10: asus_map_key_clear(KEY_BRIGHTNESSDOWN); break;
778 case 0x20: asus_map_key_clear(KEY_BRIGHTNESSUP); break;
779 case 0x35: asus_map_key_clear(KEY_DISPLAY_OFF); break;
780 case 0x6c: asus_map_key_clear(KEY_SLEEP); break;
781 case 0x7c: asus_map_key_clear(KEY_MICMUTE); break;
782 case 0x82: asus_map_key_clear(KEY_CAMERA); break;
783 case 0x88: asus_map_key_clear(KEY_RFKILL); break;
784 case 0xb5: asus_map_key_clear(KEY_CALC); break;
785 case 0xc4: asus_map_key_clear(KEY_KBDILLUMUP); break;
786 case 0xc5: asus_map_key_clear(KEY_KBDILLUMDOWN); break;
787
788 /* ASUS touchpad toggle */
789 case 0x6b: asus_map_key_clear(KEY_F21); break;
790
791 /* ROG key */
792 case 0x38: asus_map_key_clear(KEY_PROG1); break;
793
794 /* Fn+C ASUS Splendid */
795 case 0xba: asus_map_key_clear(KEY_PROG2); break;
796
797 /* Fn+Space Power4Gear Hybrid */
798 case 0x5c: asus_map_key_clear(KEY_PROG3); break;
799
800 /* Fn+F5 "fan" symbol on FX503VD */
801 case 0x99: asus_map_key_clear(KEY_PROG4); break;
802
803 default:
804 /* ASUS lazily declares 256 usages, ignore the rest,
805 * as some make the keyboard appear as a pointer device. */
806 return -1;
807 }
808
809 /*
810 * Check and enable backlight only on devices with UsagePage ==
811 * 0xff31 to avoid initializing the keyboard firmware multiple
812 * times on devices with multiple HID descriptors but same
813 * PID/VID.
814 */
815 if (drvdata->quirks & QUIRK_USE_KBD_BACKLIGHT)
816 drvdata->enable_backlight = true;
817
818 set_bit(EV_REP, hi->input->evbit);
819 return 1;
820 }
821
822 if ((usage->hid & HID_USAGE_PAGE) == HID_UP_MSVENDOR) {
823 switch (usage->hid & HID_USAGE) {
824 case 0xff01: asus_map_key_clear(BTN_1); break;
825 case 0xff02: asus_map_key_clear(BTN_2); break;
826 case 0xff03: asus_map_key_clear(BTN_3); break;
827 case 0xff04: asus_map_key_clear(BTN_4); break;
828 case 0xff05: asus_map_key_clear(BTN_5); break;
829 case 0xff06: asus_map_key_clear(BTN_6); break;
830 case 0xff07: asus_map_key_clear(BTN_7); break;
831 case 0xff08: asus_map_key_clear(BTN_8); break;
832 case 0xff09: asus_map_key_clear(BTN_9); break;
833 case 0xff0a: asus_map_key_clear(BTN_A); break;
834 case 0xff0b: asus_map_key_clear(BTN_B); break;
835 case 0x00f1: asus_map_key_clear(KEY_WLAN); break;
836 case 0x00f2: asus_map_key_clear(KEY_BRIGHTNESSDOWN); break;
837 case 0x00f3: asus_map_key_clear(KEY_BRIGHTNESSUP); break;
838 case 0x00f4: asus_map_key_clear(KEY_DISPLAY_OFF); break;
839 case 0x00f7: asus_map_key_clear(KEY_CAMERA); break;
840 case 0x00f8: asus_map_key_clear(KEY_PROG1); break;
841 default:
842 return 0;
843 }
844
845 set_bit(EV_REP, hi->input->evbit);
846 return 1;
847 }
848
849 if (drvdata->quirks & QUIRK_NO_CONSUMER_USAGES &&
850 (usage->hid & HID_USAGE_PAGE) == HID_UP_CONSUMER) {
851 switch (usage->hid & HID_USAGE) {
852 case 0xe2: /* Mute */
853 case 0xe9: /* Volume up */
854 case 0xea: /* Volume down */
855 return 0;
856 default:
857 /* Ignore dummy Consumer usages which make the
858 * keyboard incorrectly appear as a pointer device.
859 */
860 return -1;
861 }
862 }
863
864 /*
865 * The mute button is broken and only sends press events, we
866 * deal with this in our raw_event handler, so do not map it.
867 */
868 if ((drvdata->quirks & QUIRK_MEDION_E1239T) &&
869 usage->hid == (HID_UP_CONSUMER | 0xe2)) {
870 input_set_capability(hi->input, EV_KEY, KEY_MUTE);
871 return -1;
872 }
873
874 return 0;
875 }
876
asus_start_multitouch(struct hid_device * hdev)877 static int asus_start_multitouch(struct hid_device *hdev)
878 {
879 int ret;
880 static const unsigned char buf[] = {
881 FEATURE_REPORT_ID, 0x00, 0x03, 0x01, 0x00
882 };
883 unsigned char *dmabuf = kmemdup(buf, sizeof(buf), GFP_KERNEL);
884
885 if (!dmabuf) {
886 ret = -ENOMEM;
887 hid_err(hdev, "Asus failed to alloc dma buf: %d\n", ret);
888 return ret;
889 }
890
891 ret = hid_hw_raw_request(hdev, dmabuf[0], dmabuf, sizeof(buf),
892 HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
893
894 kfree(dmabuf);
895
896 if (ret != sizeof(buf)) {
897 hid_err(hdev, "Asus failed to start multitouch: %d\n", ret);
898 return ret;
899 }
900
901 return 0;
902 }
903
asus_reset_resume(struct hid_device * hdev)904 static int __maybe_unused asus_reset_resume(struct hid_device *hdev)
905 {
906 struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
907
908 if (drvdata->tp)
909 return asus_start_multitouch(hdev);
910
911 return 0;
912 }
913
asus_probe(struct hid_device * hdev,const struct hid_device_id * id)914 static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
915 {
916 int ret;
917 struct asus_drvdata *drvdata;
918
919 drvdata = devm_kzalloc(&hdev->dev, sizeof(*drvdata), GFP_KERNEL);
920 if (drvdata == NULL) {
921 hid_err(hdev, "Can't alloc Asus descriptor\n");
922 return -ENOMEM;
923 }
924
925 hid_set_drvdata(hdev, drvdata);
926
927 drvdata->quirks = id->driver_data;
928
929 /*
930 * T90CHI's keyboard dock returns same ID values as T100CHI's dock.
931 * Thus, identify T90CHI dock with product name string.
932 */
933 if (strstr(hdev->name, "T90CHI")) {
934 drvdata->quirks &= ~QUIRK_T100CHI;
935 drvdata->quirks |= QUIRK_T90CHI;
936 }
937
938 if (drvdata->quirks & QUIRK_IS_MULTITOUCH)
939 drvdata->tp = &asus_i2c_tp;
940
941 if ((drvdata->quirks & QUIRK_T100_KEYBOARD) && hid_is_usb(hdev)) {
942 struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
943
944 if (intf->altsetting->desc.bInterfaceNumber == T100_TPAD_INTF) {
945 drvdata->quirks = QUIRK_SKIP_INPUT_MAPPING;
946 /*
947 * The T100HA uses the same USB-ids as the T100TAF and
948 * the T200TA uses the same USB-ids as the T100TA, while
949 * both have different max x/y values as the T100TA[F].
950 */
951 if (dmi_match(DMI_PRODUCT_NAME, "T100HAN"))
952 drvdata->tp = &asus_t100ha_tp;
953 else if (dmi_match(DMI_PRODUCT_NAME, "T200TA"))
954 drvdata->tp = &asus_t200ta_tp;
955 else
956 drvdata->tp = &asus_t100ta_tp;
957 }
958 }
959
960 if (drvdata->quirks & QUIRK_T100CHI) {
961 /*
962 * All functionality is on a single HID interface and for
963 * userspace the touchpad must be a separate input_dev.
964 */
965 hdev->quirks |= HID_QUIRK_MULTI_INPUT;
966 drvdata->tp = &asus_t100chi_tp;
967 }
968
969 if ((drvdata->quirks & QUIRK_MEDION_E1239T) && hid_is_usb(hdev)) {
970 struct usb_host_interface *alt =
971 to_usb_interface(hdev->dev.parent)->altsetting;
972
973 if (alt->desc.bInterfaceNumber == MEDION_E1239T_TPAD_INTF) {
974 /* For separate input-devs for tp and tp toggle key */
975 hdev->quirks |= HID_QUIRK_MULTI_INPUT;
976 drvdata->quirks |= QUIRK_SKIP_INPUT_MAPPING;
977 drvdata->tp = &medion_e1239t_tp;
978 }
979 }
980
981 if (drvdata->quirks & QUIRK_NO_INIT_REPORTS)
982 hdev->quirks |= HID_QUIRK_NO_INIT_REPORTS;
983
984 drvdata->hdev = hdev;
985
986 if (drvdata->quirks & (QUIRK_T100CHI | QUIRK_T90CHI)) {
987 ret = asus_battery_probe(hdev);
988 if (ret) {
989 hid_err(hdev,
990 "Asus hid battery_probe failed: %d\n", ret);
991 return ret;
992 }
993 }
994
995 ret = hid_parse(hdev);
996 if (ret) {
997 hid_err(hdev, "Asus hid parse failed: %d\n", ret);
998 return ret;
999 }
1000
1001 /* use hid-multitouch for T101HA touchpad */
1002 if (id->driver_data & QUIRK_T101HA_DOCK &&
1003 hdev->collection->usage == HID_GD_MOUSE)
1004 return -ENODEV;
1005
1006 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
1007 if (ret) {
1008 hid_err(hdev, "Asus hw start failed: %d\n", ret);
1009 return ret;
1010 }
1011
1012 if (!drvdata->input) {
1013 hid_err(hdev, "Asus input not registered\n");
1014 ret = -ENOMEM;
1015 goto err_stop_hw;
1016 }
1017
1018 if (drvdata->tp) {
1019 drvdata->input->name = "Asus TouchPad";
1020 } else {
1021 drvdata->input->name = "Asus Keyboard";
1022 }
1023
1024 if (drvdata->tp) {
1025 ret = asus_start_multitouch(hdev);
1026 if (ret)
1027 goto err_stop_hw;
1028 }
1029
1030 return 0;
1031 err_stop_hw:
1032 hid_hw_stop(hdev);
1033 return ret;
1034 }
1035
asus_remove(struct hid_device * hdev)1036 static void asus_remove(struct hid_device *hdev)
1037 {
1038 struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
1039 unsigned long flags;
1040
1041 if (drvdata->kbd_backlight) {
1042 spin_lock_irqsave(&drvdata->kbd_backlight->lock, flags);
1043 drvdata->kbd_backlight->removed = true;
1044 spin_unlock_irqrestore(&drvdata->kbd_backlight->lock, flags);
1045
1046 cancel_work_sync(&drvdata->kbd_backlight->work);
1047 }
1048
1049 hid_hw_stop(hdev);
1050 }
1051
1052 static const __u8 asus_g752_fixed_rdesc[] = {
1053 0x19, 0x00, /* Usage Minimum (0x00) */
1054 0x2A, 0xFF, 0x00, /* Usage Maximum (0xFF) */
1055 };
1056
asus_report_fixup(struct hid_device * hdev,__u8 * rdesc,unsigned int * rsize)1057 static __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc,
1058 unsigned int *rsize)
1059 {
1060 struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
1061
1062 if (drvdata->quirks & QUIRK_FIX_NOTEBOOK_REPORT &&
1063 *rsize >= 56 && rdesc[54] == 0x25 && rdesc[55] == 0x65) {
1064 hid_info(hdev, "Fixing up Asus notebook report descriptor\n");
1065 rdesc[55] = 0xdd;
1066 }
1067 /* For the T100TA/T200TA keyboard dock */
1068 if (drvdata->quirks & QUIRK_T100_KEYBOARD &&
1069 (*rsize == 76 || *rsize == 101) &&
1070 rdesc[73] == 0x81 && rdesc[74] == 0x01) {
1071 hid_info(hdev, "Fixing up Asus T100 keyb report descriptor\n");
1072 rdesc[74] &= ~HID_MAIN_ITEM_CONSTANT;
1073 }
1074 /* For the T100CHI/T90CHI keyboard dock */
1075 if (drvdata->quirks & (QUIRK_T100CHI | QUIRK_T90CHI)) {
1076 int rsize_orig;
1077 int offs;
1078
1079 if (drvdata->quirks & QUIRK_T100CHI) {
1080 rsize_orig = 403;
1081 offs = 388;
1082 } else {
1083 rsize_orig = 306;
1084 offs = 291;
1085 }
1086
1087 /*
1088 * Change Usage (76h) to Usage Minimum (00h), Usage Maximum
1089 * (FFh) and clear the flags in the Input() byte.
1090 * Note the descriptor has a bogus 0 byte at the end so we
1091 * only need 1 extra byte.
1092 */
1093 if (*rsize == rsize_orig &&
1094 rdesc[offs] == 0x09 && rdesc[offs + 1] == 0x76) {
1095 *rsize = rsize_orig + 1;
1096 rdesc = kmemdup(rdesc, *rsize, GFP_KERNEL);
1097 if (!rdesc)
1098 return NULL;
1099
1100 hid_info(hdev, "Fixing up %s keyb report descriptor\n",
1101 drvdata->quirks & QUIRK_T100CHI ?
1102 "T100CHI" : "T90CHI");
1103 memmove(rdesc + offs + 4, rdesc + offs + 2, 12);
1104 rdesc[offs] = 0x19;
1105 rdesc[offs + 1] = 0x00;
1106 rdesc[offs + 2] = 0x29;
1107 rdesc[offs + 3] = 0xff;
1108 rdesc[offs + 14] = 0x00;
1109 }
1110 }
1111
1112 if (drvdata->quirks & QUIRK_G752_KEYBOARD &&
1113 *rsize == 75 && rdesc[61] == 0x15 && rdesc[62] == 0x00) {
1114 /* report is missing usage mninum and maximum */
1115 __u8 *new_rdesc;
1116 size_t new_size = *rsize + sizeof(asus_g752_fixed_rdesc);
1117
1118 new_rdesc = devm_kzalloc(&hdev->dev, new_size, GFP_KERNEL);
1119 if (new_rdesc == NULL)
1120 return rdesc;
1121
1122 hid_info(hdev, "Fixing up Asus G752 keyb report descriptor\n");
1123 /* copy the valid part */
1124 memcpy(new_rdesc, rdesc, 61);
1125 /* insert missing part */
1126 memcpy(new_rdesc + 61, asus_g752_fixed_rdesc, sizeof(asus_g752_fixed_rdesc));
1127 /* copy remaining data */
1128 memcpy(new_rdesc + 61 + sizeof(asus_g752_fixed_rdesc), rdesc + 61, *rsize - 61);
1129
1130 *rsize = new_size;
1131 rdesc = new_rdesc;
1132 }
1133
1134 return rdesc;
1135 }
1136
1137 static const struct hid_device_id asus_devices[] = {
1138 { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK,
1139 USB_DEVICE_ID_ASUSTEK_I2C_KEYBOARD), I2C_KEYBOARD_QUIRKS},
1140 { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK,
1141 USB_DEVICE_ID_ASUSTEK_I2C_TOUCHPAD), I2C_TOUCHPAD_QUIRKS },
1142 { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
1143 USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD1), QUIRK_USE_KBD_BACKLIGHT },
1144 { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
1145 USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD2), QUIRK_USE_KBD_BACKLIGHT },
1146 { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
1147 USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD3), QUIRK_G752_KEYBOARD },
1148 { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
1149 USB_DEVICE_ID_ASUSTEK_FX503VD_KEYBOARD),
1150 QUIRK_USE_KBD_BACKLIGHT },
1151 { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
1152 USB_DEVICE_ID_ASUSTEK_T100TA_KEYBOARD),
1153 QUIRK_T100_KEYBOARD | QUIRK_NO_CONSUMER_USAGES },
1154 { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
1155 USB_DEVICE_ID_ASUSTEK_T100TAF_KEYBOARD),
1156 QUIRK_T100_KEYBOARD | QUIRK_NO_CONSUMER_USAGES },
1157 { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
1158 USB_DEVICE_ID_ASUSTEK_T101HA_KEYBOARD), QUIRK_T101HA_DOCK },
1159 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_ASUS_AK1D) },
1160 { HID_USB_DEVICE(USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_ASUS_MD_5110) },
1161 { HID_USB_DEVICE(USB_VENDOR_ID_JESS, USB_DEVICE_ID_ASUS_MD_5112) },
1162 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ASUSTEK,
1163 USB_DEVICE_ID_ASUSTEK_T100CHI_KEYBOARD), QUIRK_T100CHI },
1164 { HID_USB_DEVICE(USB_VENDOR_ID_ITE, USB_DEVICE_ID_ITE_MEDION_E1239T),
1165 QUIRK_MEDION_E1239T },
1166 { }
1167 };
1168 MODULE_DEVICE_TABLE(hid, asus_devices);
1169
1170 static struct hid_driver asus_driver = {
1171 .name = "asus",
1172 .id_table = asus_devices,
1173 .report_fixup = asus_report_fixup,
1174 .probe = asus_probe,
1175 .remove = asus_remove,
1176 .input_mapping = asus_input_mapping,
1177 .input_configured = asus_input_configured,
1178 #ifdef CONFIG_PM
1179 .reset_resume = asus_reset_resume,
1180 #endif
1181 .event = asus_event,
1182 .raw_event = asus_raw_event
1183 };
1184 module_hid_driver(asus_driver);
1185
1186 MODULE_LICENSE("GPL");
1187