xref: /kernel/linux/linux-5.10/drivers/hid/hid-asus.c (revision 8c2ecf20)
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
36MODULE_AUTHOR("Yusuke Fujimaki <usk.fujimaki@gmail.com>");
37MODULE_AUTHOR("Brendan McGrath <redmcg@redmandi.dyndns.org>");
38MODULE_AUTHOR("Victor Vlasenko <victor.vlasenko@sysgears.com>");
39MODULE_AUTHOR("Frederik Wenigwieser <frederik.wenigwieser@gmail.com>");
40MODULE_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
93struct 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
102struct 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
112struct 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
128static int asus_report_battery(struct asus_drvdata *, u8 *, int);
129
130static 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
138static 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
148static 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
158static 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
168static 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
178static 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
188static 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 */
216static 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
248static 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
281static 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
309static 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
322static 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
339static int asus_kbd_set_report(struct hid_device *hdev, const 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
356static int asus_kbd_init(struct hid_device *hdev)
357{
358	const 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
369static int asus_kbd_get_functions(struct hid_device *hdev,
370				  unsigned char *kbd_func)
371{
372	const 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
401static 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
411static 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
425static 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
439static 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 */
459static 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
476static 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 */
530static 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
558static 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
568static 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
592static 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
602static 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
641static 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
679static 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))
747static 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
877static 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
904static int __maybe_unused asus_resume(struct hid_device *hdev) {
905	struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
906	int ret = 0;
907
908	if (drvdata->kbd_backlight) {
909		const u8 buf[] = { FEATURE_KBD_REPORT_ID, 0xba, 0xc5, 0xc4,
910				drvdata->kbd_backlight->cdev.brightness };
911		ret = asus_kbd_set_report(hdev, buf, sizeof(buf));
912		if (ret < 0) {
913			hid_err(hdev, "Asus failed to set keyboard backlight: %d\n", ret);
914			goto asus_resume_err;
915		}
916	}
917
918asus_resume_err:
919	return ret;
920}
921
922static int __maybe_unused asus_reset_resume(struct hid_device *hdev)
923{
924	struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
925
926	if (drvdata->tp)
927		return asus_start_multitouch(hdev);
928
929	return 0;
930}
931
932static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
933{
934	int ret;
935	struct asus_drvdata *drvdata;
936
937	drvdata = devm_kzalloc(&hdev->dev, sizeof(*drvdata), GFP_KERNEL);
938	if (drvdata == NULL) {
939		hid_err(hdev, "Can't alloc Asus descriptor\n");
940		return -ENOMEM;
941	}
942
943	hid_set_drvdata(hdev, drvdata);
944
945	drvdata->quirks = id->driver_data;
946
947	/*
948	 * T90CHI's keyboard dock returns same ID values as T100CHI's dock.
949	 * Thus, identify T90CHI dock with product name string.
950	 */
951	if (strstr(hdev->name, "T90CHI")) {
952		drvdata->quirks &= ~QUIRK_T100CHI;
953		drvdata->quirks |= QUIRK_T90CHI;
954	}
955
956	if (drvdata->quirks & QUIRK_IS_MULTITOUCH)
957		drvdata->tp = &asus_i2c_tp;
958
959	if ((drvdata->quirks & QUIRK_T100_KEYBOARD) && hid_is_usb(hdev)) {
960		struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
961
962		if (intf->altsetting->desc.bInterfaceNumber == T100_TPAD_INTF) {
963			drvdata->quirks = QUIRK_SKIP_INPUT_MAPPING;
964			/*
965			 * The T100HA uses the same USB-ids as the T100TAF and
966			 * the T200TA uses the same USB-ids as the T100TA, while
967			 * both have different max x/y values as the T100TA[F].
968			 */
969			if (dmi_match(DMI_PRODUCT_NAME, "T100HAN"))
970				drvdata->tp = &asus_t100ha_tp;
971			else if (dmi_match(DMI_PRODUCT_NAME, "T200TA"))
972				drvdata->tp = &asus_t200ta_tp;
973			else
974				drvdata->tp = &asus_t100ta_tp;
975		}
976	}
977
978	if (drvdata->quirks & QUIRK_T100CHI) {
979		/*
980		 * All functionality is on a single HID interface and for
981		 * userspace the touchpad must be a separate input_dev.
982		 */
983		hdev->quirks |= HID_QUIRK_MULTI_INPUT;
984		drvdata->tp = &asus_t100chi_tp;
985	}
986
987	if ((drvdata->quirks & QUIRK_MEDION_E1239T) && hid_is_usb(hdev)) {
988		struct usb_host_interface *alt =
989			to_usb_interface(hdev->dev.parent)->altsetting;
990
991		if (alt->desc.bInterfaceNumber == MEDION_E1239T_TPAD_INTF) {
992			/* For separate input-devs for tp and tp toggle key */
993			hdev->quirks |= HID_QUIRK_MULTI_INPUT;
994			drvdata->quirks |= QUIRK_SKIP_INPUT_MAPPING;
995			drvdata->tp = &medion_e1239t_tp;
996		}
997	}
998
999	if (drvdata->quirks & QUIRK_NO_INIT_REPORTS)
1000		hdev->quirks |= HID_QUIRK_NO_INIT_REPORTS;
1001
1002	drvdata->hdev = hdev;
1003
1004	if (drvdata->quirks & (QUIRK_T100CHI | QUIRK_T90CHI)) {
1005		ret = asus_battery_probe(hdev);
1006		if (ret) {
1007			hid_err(hdev,
1008			    "Asus hid battery_probe failed: %d\n", ret);
1009			return ret;
1010		}
1011	}
1012
1013	ret = hid_parse(hdev);
1014	if (ret) {
1015		hid_err(hdev, "Asus hid parse failed: %d\n", ret);
1016		return ret;
1017	}
1018
1019	/* use hid-multitouch for T101HA touchpad */
1020	if (id->driver_data & QUIRK_T101HA_DOCK &&
1021	    hdev->collection->usage == HID_GD_MOUSE)
1022		return -ENODEV;
1023
1024	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
1025	if (ret) {
1026		hid_err(hdev, "Asus hw start failed: %d\n", ret);
1027		return ret;
1028	}
1029
1030	if (!drvdata->input) {
1031		hid_err(hdev, "Asus input not registered\n");
1032		ret = -ENOMEM;
1033		goto err_stop_hw;
1034	}
1035
1036	if (drvdata->tp) {
1037		drvdata->input->name = "Asus TouchPad";
1038	} else {
1039		drvdata->input->name = "Asus Keyboard";
1040	}
1041
1042	if (drvdata->tp) {
1043		ret = asus_start_multitouch(hdev);
1044		if (ret)
1045			goto err_stop_hw;
1046	}
1047
1048	return 0;
1049err_stop_hw:
1050	hid_hw_stop(hdev);
1051	return ret;
1052}
1053
1054static void asus_remove(struct hid_device *hdev)
1055{
1056	struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
1057	unsigned long flags;
1058
1059	if (drvdata->kbd_backlight) {
1060		spin_lock_irqsave(&drvdata->kbd_backlight->lock, flags);
1061		drvdata->kbd_backlight->removed = true;
1062		spin_unlock_irqrestore(&drvdata->kbd_backlight->lock, flags);
1063
1064		cancel_work_sync(&drvdata->kbd_backlight->work);
1065	}
1066
1067	hid_hw_stop(hdev);
1068}
1069
1070static const __u8 asus_g752_fixed_rdesc[] = {
1071        0x19, 0x00,			/*   Usage Minimum (0x00)       */
1072        0x2A, 0xFF, 0x00,		/*   Usage Maximum (0xFF)       */
1073};
1074
1075static __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc,
1076		unsigned int *rsize)
1077{
1078	struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
1079
1080	if (drvdata->quirks & QUIRK_FIX_NOTEBOOK_REPORT &&
1081			*rsize >= 56 && rdesc[54] == 0x25 && rdesc[55] == 0x65) {
1082		hid_info(hdev, "Fixing up Asus notebook report descriptor\n");
1083		rdesc[55] = 0xdd;
1084	}
1085	/* For the T100TA/T200TA keyboard dock */
1086	if (drvdata->quirks & QUIRK_T100_KEYBOARD &&
1087		 (*rsize == 76 || *rsize == 101) &&
1088		 rdesc[73] == 0x81 && rdesc[74] == 0x01) {
1089		hid_info(hdev, "Fixing up Asus T100 keyb report descriptor\n");
1090		rdesc[74] &= ~HID_MAIN_ITEM_CONSTANT;
1091	}
1092	/* For the T100CHI/T90CHI keyboard dock */
1093	if (drvdata->quirks & (QUIRK_T100CHI | QUIRK_T90CHI)) {
1094		int rsize_orig;
1095		int offs;
1096
1097		if (drvdata->quirks & QUIRK_T100CHI) {
1098			rsize_orig = 403;
1099			offs = 388;
1100		} else {
1101			rsize_orig = 306;
1102			offs = 291;
1103		}
1104
1105		/*
1106		 * Change Usage (76h) to Usage Minimum (00h), Usage Maximum
1107		 * (FFh) and clear the flags in the Input() byte.
1108		 * Note the descriptor has a bogus 0 byte at the end so we
1109		 * only need 1 extra byte.
1110		 */
1111		if (*rsize == rsize_orig &&
1112			rdesc[offs] == 0x09 && rdesc[offs + 1] == 0x76) {
1113			*rsize = rsize_orig + 1;
1114			rdesc = kmemdup(rdesc, *rsize, GFP_KERNEL);
1115			if (!rdesc)
1116				return NULL;
1117
1118			hid_info(hdev, "Fixing up %s keyb report descriptor\n",
1119				drvdata->quirks & QUIRK_T100CHI ?
1120				"T100CHI" : "T90CHI");
1121			memmove(rdesc + offs + 4, rdesc + offs + 2, 12);
1122			rdesc[offs] = 0x19;
1123			rdesc[offs + 1] = 0x00;
1124			rdesc[offs + 2] = 0x29;
1125			rdesc[offs + 3] = 0xff;
1126			rdesc[offs + 14] = 0x00;
1127		}
1128	}
1129
1130	if (drvdata->quirks & QUIRK_G752_KEYBOARD &&
1131		 *rsize == 75 && rdesc[61] == 0x15 && rdesc[62] == 0x00) {
1132		/* report is missing usage mninum and maximum */
1133		__u8 *new_rdesc;
1134		size_t new_size = *rsize + sizeof(asus_g752_fixed_rdesc);
1135
1136		new_rdesc = devm_kzalloc(&hdev->dev, new_size, GFP_KERNEL);
1137		if (new_rdesc == NULL)
1138			return rdesc;
1139
1140		hid_info(hdev, "Fixing up Asus G752 keyb report descriptor\n");
1141		/* copy the valid part */
1142		memcpy(new_rdesc, rdesc, 61);
1143		/* insert missing part */
1144		memcpy(new_rdesc + 61, asus_g752_fixed_rdesc, sizeof(asus_g752_fixed_rdesc));
1145		/* copy remaining data */
1146		memcpy(new_rdesc + 61 + sizeof(asus_g752_fixed_rdesc), rdesc + 61, *rsize - 61);
1147
1148		*rsize = new_size;
1149		rdesc = new_rdesc;
1150	}
1151
1152	return rdesc;
1153}
1154
1155static const struct hid_device_id asus_devices[] = {
1156	{ HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK,
1157		USB_DEVICE_ID_ASUSTEK_I2C_KEYBOARD), I2C_KEYBOARD_QUIRKS},
1158	{ HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK,
1159		USB_DEVICE_ID_ASUSTEK_I2C_TOUCHPAD), I2C_TOUCHPAD_QUIRKS },
1160	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
1161		USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD1), QUIRK_USE_KBD_BACKLIGHT },
1162	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
1163		USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD2), QUIRK_USE_KBD_BACKLIGHT },
1164	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
1165		USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD3), QUIRK_G752_KEYBOARD },
1166	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
1167		USB_DEVICE_ID_ASUSTEK_FX503VD_KEYBOARD),
1168	  QUIRK_USE_KBD_BACKLIGHT },
1169	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
1170		USB_DEVICE_ID_ASUSTEK_T100TA_KEYBOARD),
1171	  QUIRK_T100_KEYBOARD | QUIRK_NO_CONSUMER_USAGES },
1172	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
1173		USB_DEVICE_ID_ASUSTEK_T100TAF_KEYBOARD),
1174	  QUIRK_T100_KEYBOARD | QUIRK_NO_CONSUMER_USAGES },
1175	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
1176		USB_DEVICE_ID_ASUSTEK_T101HA_KEYBOARD), QUIRK_T101HA_DOCK },
1177	{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_ASUS_AK1D) },
1178	{ HID_USB_DEVICE(USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_ASUS_MD_5110) },
1179	{ HID_USB_DEVICE(USB_VENDOR_ID_JESS, USB_DEVICE_ID_ASUS_MD_5112) },
1180	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ASUSTEK,
1181		USB_DEVICE_ID_ASUSTEK_T100CHI_KEYBOARD), QUIRK_T100CHI },
1182	{ HID_USB_DEVICE(USB_VENDOR_ID_ITE, USB_DEVICE_ID_ITE_MEDION_E1239T),
1183		QUIRK_MEDION_E1239T },
1184	{ }
1185};
1186MODULE_DEVICE_TABLE(hid, asus_devices);
1187
1188static struct hid_driver asus_driver = {
1189	.name			= "asus",
1190	.id_table		= asus_devices,
1191	.report_fixup		= asus_report_fixup,
1192	.probe                  = asus_probe,
1193	.remove			= asus_remove,
1194	.input_mapping          = asus_input_mapping,
1195	.input_configured       = asus_input_configured,
1196#ifdef CONFIG_PM
1197	.reset_resume           = asus_reset_resume,
1198	.resume					= asus_resume,
1199#endif
1200	.event			= asus_event,
1201	.raw_event		= asus_raw_event
1202};
1203module_hid_driver(asus_driver);
1204
1205MODULE_LICENSE("GPL");
1206