GNU Linux-libre 5.4.241-gnu1
[releases.git] / drivers / hid / hid-asus.c
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
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 */
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
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
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
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
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
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
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
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
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
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
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
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  */
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
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  */
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
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
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
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
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
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))
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                 if (field->application == (HID_UP_GENDESK | 0x0080) ||
768                     usage->hid == (HID_UP_GENDEVCTRLS | 0x0024) ||
769                     usage->hid == (HID_UP_GENDEVCTRLS | 0x0025) ||
770                     usage->hid == (HID_UP_GENDEVCTRLS | 0x0026))
771                         return -1;
772                 /*
773                  * We use the hid_input for the mouse report for the touchpad,
774                  * keep the left button, to avoid the core removing it.
775                  */
776                 if (field->application == HID_GD_MOUSE &&
777                     usage->hid != (HID_UP_BUTTON | 1))
778                         return -1;
779         }
780
781         /* ASUS-specific keyboard hotkeys */
782         if ((usage->hid & HID_USAGE_PAGE) == 0xff310000) {
783                 switch (usage->hid & HID_USAGE) {
784                 case 0x10: asus_map_key_clear(KEY_BRIGHTNESSDOWN);      break;
785                 case 0x20: asus_map_key_clear(KEY_BRIGHTNESSUP);                break;
786                 case 0x35: asus_map_key_clear(KEY_DISPLAY_OFF);         break;
787                 case 0x6c: asus_map_key_clear(KEY_SLEEP);               break;
788                 case 0x7c: asus_map_key_clear(KEY_MICMUTE);             break;
789                 case 0x82: asus_map_key_clear(KEY_CAMERA);              break;
790                 case 0x88: asus_map_key_clear(KEY_RFKILL);                      break;
791                 case 0xb5: asus_map_key_clear(KEY_CALC);                        break;
792                 case 0xc4: asus_map_key_clear(KEY_KBDILLUMUP);          break;
793                 case 0xc5: asus_map_key_clear(KEY_KBDILLUMDOWN);                break;
794
795                 /* ASUS touchpad toggle */
796                 case 0x6b: asus_map_key_clear(KEY_F21);                 break;
797
798                 /* ROG key */
799                 case 0x38: asus_map_key_clear(KEY_PROG1);               break;
800
801                 /* Fn+C ASUS Splendid */
802                 case 0xba: asus_map_key_clear(KEY_PROG2);               break;
803
804                 /* Fn+Space Power4Gear Hybrid */
805                 case 0x5c: asus_map_key_clear(KEY_PROG3);               break;
806
807                 /* Fn+F5 "fan" symbol on FX503VD */
808                 case 0x99: asus_map_key_clear(KEY_PROG4);               break;
809
810                 default:
811                         /* ASUS lazily declares 256 usages, ignore the rest,
812                          * as some make the keyboard appear as a pointer device. */
813                         return -1;
814                 }
815
816                 /*
817                  * Check and enable backlight only on devices with UsagePage ==
818                  * 0xff31 to avoid initializing the keyboard firmware multiple
819                  * times on devices with multiple HID descriptors but same
820                  * PID/VID.
821                  */
822                 if (drvdata->quirks & QUIRK_USE_KBD_BACKLIGHT)
823                         drvdata->enable_backlight = true;
824
825                 set_bit(EV_REP, hi->input->evbit);
826                 return 1;
827         }
828
829         if ((usage->hid & HID_USAGE_PAGE) == HID_UP_MSVENDOR) {
830                 switch (usage->hid & HID_USAGE) {
831                 case 0xff01: asus_map_key_clear(BTN_1); break;
832                 case 0xff02: asus_map_key_clear(BTN_2); break;
833                 case 0xff03: asus_map_key_clear(BTN_3); break;
834                 case 0xff04: asus_map_key_clear(BTN_4); break;
835                 case 0xff05: asus_map_key_clear(BTN_5); break;
836                 case 0xff06: asus_map_key_clear(BTN_6); break;
837                 case 0xff07: asus_map_key_clear(BTN_7); break;
838                 case 0xff08: asus_map_key_clear(BTN_8); break;
839                 case 0xff09: asus_map_key_clear(BTN_9); break;
840                 case 0xff0a: asus_map_key_clear(BTN_A); break;
841                 case 0xff0b: asus_map_key_clear(BTN_B); break;
842                 case 0x00f1: asus_map_key_clear(KEY_WLAN);      break;
843                 case 0x00f2: asus_map_key_clear(KEY_BRIGHTNESSDOWN);    break;
844                 case 0x00f3: asus_map_key_clear(KEY_BRIGHTNESSUP);      break;
845                 case 0x00f4: asus_map_key_clear(KEY_DISPLAY_OFF);       break;
846                 case 0x00f7: asus_map_key_clear(KEY_CAMERA);    break;
847                 case 0x00f8: asus_map_key_clear(KEY_PROG1);     break;
848                 default:
849                         return 0;
850                 }
851
852                 set_bit(EV_REP, hi->input->evbit);
853                 return 1;
854         }
855
856         if (drvdata->quirks & QUIRK_NO_CONSUMER_USAGES &&
857                 (usage->hid & HID_USAGE_PAGE) == HID_UP_CONSUMER) {
858                 switch (usage->hid & HID_USAGE) {
859                 case 0xe2: /* Mute */
860                 case 0xe9: /* Volume up */
861                 case 0xea: /* Volume down */
862                         return 0;
863                 default:
864                         /* Ignore dummy Consumer usages which make the
865                          * keyboard incorrectly appear as a pointer device.
866                          */
867                         return -1;
868                 }
869         }
870
871         /*
872          * The mute button is broken and only sends press events, we
873          * deal with this in our raw_event handler, so do not map it.
874          */
875         if ((drvdata->quirks & QUIRK_MEDION_E1239T) &&
876             usage->hid == (HID_UP_CONSUMER | 0xe2)) {
877                 input_set_capability(hi->input, EV_KEY, KEY_MUTE);
878                 return -1;
879         }
880
881         return 0;
882 }
883
884 static int asus_start_multitouch(struct hid_device *hdev)
885 {
886         int ret;
887         static const unsigned char buf[] = {
888                 FEATURE_REPORT_ID, 0x00, 0x03, 0x01, 0x00
889         };
890         unsigned char *dmabuf = kmemdup(buf, sizeof(buf), GFP_KERNEL);
891
892         if (!dmabuf) {
893                 ret = -ENOMEM;
894                 hid_err(hdev, "Asus failed to alloc dma buf: %d\n", ret);
895                 return ret;
896         }
897
898         ret = hid_hw_raw_request(hdev, dmabuf[0], dmabuf, sizeof(buf),
899                                         HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
900
901         kfree(dmabuf);
902
903         if (ret != sizeof(buf)) {
904                 hid_err(hdev, "Asus failed to start multitouch: %d\n", ret);
905                 return ret;
906         }
907
908         return 0;
909 }
910
911 static int __maybe_unused asus_reset_resume(struct hid_device *hdev)
912 {
913         struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
914
915         if (drvdata->tp)
916                 return asus_start_multitouch(hdev);
917
918         return 0;
919 }
920
921 static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
922 {
923         int ret;
924         struct asus_drvdata *drvdata;
925
926         drvdata = devm_kzalloc(&hdev->dev, sizeof(*drvdata), GFP_KERNEL);
927         if (drvdata == NULL) {
928                 hid_err(hdev, "Can't alloc Asus descriptor\n");
929                 return -ENOMEM;
930         }
931
932         hid_set_drvdata(hdev, drvdata);
933
934         drvdata->quirks = id->driver_data;
935
936         /*
937          * T90CHI's keyboard dock returns same ID values as T100CHI's dock.
938          * Thus, identify T90CHI dock with product name string.
939          */
940         if (strstr(hdev->name, "T90CHI")) {
941                 drvdata->quirks &= ~QUIRK_T100CHI;
942                 drvdata->quirks |= QUIRK_T90CHI;
943         }
944
945         if (drvdata->quirks & QUIRK_IS_MULTITOUCH)
946                 drvdata->tp = &asus_i2c_tp;
947
948         if ((drvdata->quirks & QUIRK_T100_KEYBOARD) && hid_is_usb(hdev)) {
949                 struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
950
951                 if (intf->altsetting->desc.bInterfaceNumber == T100_TPAD_INTF) {
952                         drvdata->quirks = QUIRK_SKIP_INPUT_MAPPING;
953                         /*
954                          * The T100HA uses the same USB-ids as the T100TAF and
955                          * the T200TA uses the same USB-ids as the T100TA, while
956                          * both have different max x/y values as the T100TA[F].
957                          */
958                         if (dmi_match(DMI_PRODUCT_NAME, "T100HAN"))
959                                 drvdata->tp = &asus_t100ha_tp;
960                         else if (dmi_match(DMI_PRODUCT_NAME, "T200TA"))
961                                 drvdata->tp = &asus_t200ta_tp;
962                         else
963                                 drvdata->tp = &asus_t100ta_tp;
964                 }
965         }
966
967         if (drvdata->quirks & QUIRK_T100CHI) {
968                 /*
969                  * All functionality is on a single HID interface and for
970                  * userspace the touchpad must be a separate input_dev.
971                  */
972                 hdev->quirks |= HID_QUIRK_MULTI_INPUT;
973                 drvdata->tp = &asus_t100chi_tp;
974         }
975
976         if ((drvdata->quirks & QUIRK_MEDION_E1239T) &&
977             hid_is_using_ll_driver(hdev, &usb_hid_driver)) {
978                 struct usb_host_interface *alt =
979                         to_usb_interface(hdev->dev.parent)->altsetting;
980
981                 if (alt->desc.bInterfaceNumber == MEDION_E1239T_TPAD_INTF) {
982                         /* For separate input-devs for tp and tp toggle key */
983                         hdev->quirks |= HID_QUIRK_MULTI_INPUT;
984                         drvdata->quirks |= QUIRK_SKIP_INPUT_MAPPING;
985                         drvdata->tp = &medion_e1239t_tp;
986                 }
987         }
988
989         if (drvdata->quirks & QUIRK_NO_INIT_REPORTS)
990                 hdev->quirks |= HID_QUIRK_NO_INIT_REPORTS;
991
992         drvdata->hdev = hdev;
993
994         if (drvdata->quirks & (QUIRK_T100CHI | QUIRK_T90CHI)) {
995                 ret = asus_battery_probe(hdev);
996                 if (ret) {
997                         hid_err(hdev,
998                             "Asus hid battery_probe failed: %d\n", ret);
999                         return ret;
1000                 }
1001         }
1002
1003         ret = hid_parse(hdev);
1004         if (ret) {
1005                 hid_err(hdev, "Asus hid parse failed: %d\n", ret);
1006                 return ret;
1007         }
1008
1009         /* use hid-multitouch for T101HA touchpad */
1010         if (id->driver_data & QUIRK_T101HA_DOCK &&
1011             hdev->collection->usage == HID_GD_MOUSE)
1012                 return -ENODEV;
1013
1014         ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
1015         if (ret) {
1016                 hid_err(hdev, "Asus hw start failed: %d\n", ret);
1017                 return ret;
1018         }
1019
1020         if (!drvdata->input) {
1021                 hid_err(hdev, "Asus input not registered\n");
1022                 ret = -ENOMEM;
1023                 goto err_stop_hw;
1024         }
1025
1026         if (drvdata->tp) {
1027                 drvdata->input->name = "Asus TouchPad";
1028         } else {
1029                 drvdata->input->name = "Asus Keyboard";
1030         }
1031
1032         if (drvdata->tp) {
1033                 ret = asus_start_multitouch(hdev);
1034                 if (ret)
1035                         goto err_stop_hw;
1036         }
1037
1038         return 0;
1039 err_stop_hw:
1040         hid_hw_stop(hdev);
1041         return ret;
1042 }
1043
1044 static void asus_remove(struct hid_device *hdev)
1045 {
1046         struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
1047         unsigned long flags;
1048
1049         if (drvdata->kbd_backlight) {
1050                 spin_lock_irqsave(&drvdata->kbd_backlight->lock, flags);
1051                 drvdata->kbd_backlight->removed = true;
1052                 spin_unlock_irqrestore(&drvdata->kbd_backlight->lock, flags);
1053
1054                 cancel_work_sync(&drvdata->kbd_backlight->work);
1055         }
1056
1057         hid_hw_stop(hdev);
1058 }
1059
1060 static const __u8 asus_g752_fixed_rdesc[] = {
1061         0x19, 0x00,                     /*   Usage Minimum (0x00)       */
1062         0x2A, 0xFF, 0x00,               /*   Usage Maximum (0xFF)       */
1063 };
1064
1065 static __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc,
1066                 unsigned int *rsize)
1067 {
1068         struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
1069
1070         if (drvdata->quirks & QUIRK_FIX_NOTEBOOK_REPORT &&
1071                         *rsize >= 56 && rdesc[54] == 0x25 && rdesc[55] == 0x65) {
1072                 hid_info(hdev, "Fixing up Asus notebook report descriptor\n");
1073                 rdesc[55] = 0xdd;
1074         }
1075         /* For the T100TA/T200TA keyboard dock */
1076         if (drvdata->quirks & QUIRK_T100_KEYBOARD &&
1077                  (*rsize == 76 || *rsize == 101) &&
1078                  rdesc[73] == 0x81 && rdesc[74] == 0x01) {
1079                 hid_info(hdev, "Fixing up Asus T100 keyb report descriptor\n");
1080                 rdesc[74] &= ~HID_MAIN_ITEM_CONSTANT;
1081         }
1082         /* For the T100CHI/T90CHI keyboard dock */
1083         if (drvdata->quirks & (QUIRK_T100CHI | QUIRK_T90CHI)) {
1084                 int rsize_orig;
1085                 int offs;
1086
1087                 if (drvdata->quirks & QUIRK_T100CHI) {
1088                         rsize_orig = 403;
1089                         offs = 388;
1090                 } else {
1091                         rsize_orig = 306;
1092                         offs = 291;
1093                 }
1094
1095                 /*
1096                  * Change Usage (76h) to Usage Minimum (00h), Usage Maximum
1097                  * (FFh) and clear the flags in the Input() byte.
1098                  * Note the descriptor has a bogus 0 byte at the end so we
1099                  * only need 1 extra byte.
1100                  */
1101                 if (*rsize == rsize_orig &&
1102                         rdesc[offs] == 0x09 && rdesc[offs + 1] == 0x76) {
1103                         *rsize = rsize_orig + 1;
1104                         rdesc = kmemdup(rdesc, *rsize, GFP_KERNEL);
1105                         if (!rdesc)
1106                                 return NULL;
1107
1108                         hid_info(hdev, "Fixing up %s keyb report descriptor\n",
1109                                 drvdata->quirks & QUIRK_T100CHI ?
1110                                 "T100CHI" : "T90CHI");
1111                         memmove(rdesc + offs + 4, rdesc + offs + 2, 12);
1112                         rdesc[offs] = 0x19;
1113                         rdesc[offs + 1] = 0x00;
1114                         rdesc[offs + 2] = 0x29;
1115                         rdesc[offs + 3] = 0xff;
1116                         rdesc[offs + 14] = 0x00;
1117                 }
1118         }
1119
1120         if (drvdata->quirks & QUIRK_G752_KEYBOARD &&
1121                  *rsize == 75 && rdesc[61] == 0x15 && rdesc[62] == 0x00) {
1122                 /* report is missing usage mninum and maximum */
1123                 __u8 *new_rdesc;
1124                 size_t new_size = *rsize + sizeof(asus_g752_fixed_rdesc);
1125
1126                 new_rdesc = devm_kzalloc(&hdev->dev, new_size, GFP_KERNEL);
1127                 if (new_rdesc == NULL)
1128                         return rdesc;
1129
1130                 hid_info(hdev, "Fixing up Asus G752 keyb report descriptor\n");
1131                 /* copy the valid part */
1132                 memcpy(new_rdesc, rdesc, 61);
1133                 /* insert missing part */
1134                 memcpy(new_rdesc + 61, asus_g752_fixed_rdesc, sizeof(asus_g752_fixed_rdesc));
1135                 /* copy remaining data */
1136                 memcpy(new_rdesc + 61 + sizeof(asus_g752_fixed_rdesc), rdesc + 61, *rsize - 61);
1137
1138                 *rsize = new_size;
1139                 rdesc = new_rdesc;
1140         }
1141
1142         return rdesc;
1143 }
1144
1145 static const struct hid_device_id asus_devices[] = {
1146         { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK,
1147                 USB_DEVICE_ID_ASUSTEK_I2C_KEYBOARD), I2C_KEYBOARD_QUIRKS},
1148         { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK,
1149                 USB_DEVICE_ID_ASUSTEK_I2C_TOUCHPAD), I2C_TOUCHPAD_QUIRKS },
1150         { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
1151                 USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD1), QUIRK_USE_KBD_BACKLIGHT },
1152         { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
1153                 USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD2), QUIRK_USE_KBD_BACKLIGHT },
1154         { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
1155                 USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD3), QUIRK_G752_KEYBOARD },
1156         { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
1157                 USB_DEVICE_ID_ASUSTEK_FX503VD_KEYBOARD),
1158           QUIRK_USE_KBD_BACKLIGHT },
1159         { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
1160                 USB_DEVICE_ID_ASUSTEK_T100TA_KEYBOARD),
1161           QUIRK_T100_KEYBOARD | QUIRK_NO_CONSUMER_USAGES },
1162         { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
1163                 USB_DEVICE_ID_ASUSTEK_T100TAF_KEYBOARD),
1164           QUIRK_T100_KEYBOARD | QUIRK_NO_CONSUMER_USAGES },
1165         { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
1166                 USB_DEVICE_ID_ASUSTEK_T101HA_KEYBOARD), QUIRK_T101HA_DOCK },
1167         { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_ASUS_AK1D) },
1168         { HID_USB_DEVICE(USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_ASUS_MD_5110) },
1169         { HID_USB_DEVICE(USB_VENDOR_ID_JESS, USB_DEVICE_ID_ASUS_MD_5112) },
1170         { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ASUSTEK,
1171                 USB_DEVICE_ID_ASUSTEK_T100CHI_KEYBOARD), QUIRK_T100CHI },
1172         { HID_USB_DEVICE(USB_VENDOR_ID_ITE, USB_DEVICE_ID_ITE_MEDION_E1239T),
1173                 QUIRK_MEDION_E1239T },
1174         { }
1175 };
1176 MODULE_DEVICE_TABLE(hid, asus_devices);
1177
1178 static struct hid_driver asus_driver = {
1179         .name                   = "asus",
1180         .id_table               = asus_devices,
1181         .report_fixup           = asus_report_fixup,
1182         .probe                  = asus_probe,
1183         .remove                 = asus_remove,
1184         .input_mapping          = asus_input_mapping,
1185         .input_configured       = asus_input_configured,
1186 #ifdef CONFIG_PM
1187         .reset_resume           = asus_reset_resume,
1188 #endif
1189         .event                  = asus_event,
1190         .raw_event              = asus_raw_event
1191 };
1192 module_hid_driver(asus_driver);
1193
1194 MODULE_LICENSE("GPL");