blob: 3091355d48df64a28ae1bc704eae4185274975f5 [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +03002/*
3 * HID Driver for ELAN Touchpad
4 *
5 * Currently only supports touchpad found on HP Pavilion X2 10
6 *
7 * Copyright (c) 2016 Alexandrov Stanislav <neko@nya.ai>
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +03008 */
9
10#include <linux/hid.h>
11#include <linux/input/mt.h>
12#include <linux/leds.h>
13#include <linux/module.h>
14#include <linux/usb.h>
15
16#include "hid-ids.h"
17
Hans de Goedee7ad3dc2018-07-11 12:38:37 +020018#define ELAN_MT_I2C 0x5d
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +030019#define ELAN_SINGLE_FINGER 0x81
20#define ELAN_MT_FIRST_FINGER 0x82
21#define ELAN_MT_SECOND_FINGER 0x83
22#define ELAN_INPUT_REPORT_SIZE 8
Hans de Goedee7ad3dc2018-07-11 12:38:37 +020023#define ELAN_I2C_REPORT_SIZE 32
24#define ELAN_FINGER_DATA_LEN 5
Hans de Goede314f04e2018-07-11 12:38:32 +020025#define ELAN_MAX_FINGERS 5
Hans de Goede2f612de2018-07-11 12:38:31 +020026#define ELAN_MAX_PRESSURE 255
Hans de Goede314f04e2018-07-11 12:38:32 +020027#define ELAN_TP_USB_INTF 1
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +030028
Hans de Goede79d11f22018-07-11 12:38:33 +020029#define ELAN_FEATURE_REPORT 0x0d
30#define ELAN_FEATURE_SIZE 5
31#define ELAN_PARAM_MAX_X 6
32#define ELAN_PARAM_MAX_Y 7
33#define ELAN_PARAM_RES 8
34
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +030035#define ELAN_MUTE_LED_REPORT 0xBC
36#define ELAN_LED_REPORT_SIZE 8
37
Hans de Goede7ed3f282018-07-11 12:38:35 +020038#define ELAN_HAS_LED BIT(0)
39
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +030040struct elan_drvdata {
41 struct input_dev *input;
42 u8 prev_report[ELAN_INPUT_REPORT_SIZE];
43 struct led_classdev mute_led;
44 u8 mute_led_state;
Hans de Goede79d11f22018-07-11 12:38:33 +020045 u16 max_x;
46 u16 max_y;
Hans de Goede19588be2018-07-11 12:38:34 +020047 u16 res_x;
48 u16 res_y;
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +030049};
50
51static int is_not_elan_touchpad(struct hid_device *hdev)
52{
Greg Kroah-Hartman93020952021-12-01 19:35:03 +010053 if (hid_is_usb(hdev)) {
Hans de Goedee7ad3dc2018-07-11 12:38:37 +020054 struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +030055
Hans de Goedee7ad3dc2018-07-11 12:38:37 +020056 return (intf->altsetting->desc.bInterfaceNumber !=
57 ELAN_TP_USB_INTF);
58 }
59
60 return 0;
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +030061}
62
63static int elan_input_mapping(struct hid_device *hdev, struct hid_input *hi,
64 struct hid_field *field, struct hid_usage *usage,
65 unsigned long **bit, int *max)
66{
67 if (is_not_elan_touchpad(hdev))
68 return 0;
69
70 if (field->report->id == ELAN_SINGLE_FINGER ||
71 field->report->id == ELAN_MT_FIRST_FINGER ||
Hans de Goedee7ad3dc2018-07-11 12:38:37 +020072 field->report->id == ELAN_MT_SECOND_FINGER ||
73 field->report->id == ELAN_MT_I2C)
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +030074 return -1;
75
76 return 0;
77}
78
Hans de Goede79d11f22018-07-11 12:38:33 +020079static int elan_get_device_param(struct hid_device *hdev,
80 unsigned char *dmabuf, unsigned char param)
81{
82 int ret;
83
84 dmabuf[0] = ELAN_FEATURE_REPORT;
85 dmabuf[1] = 0x05;
86 dmabuf[2] = 0x03;
87 dmabuf[3] = param;
88 dmabuf[4] = 0x01;
89
90 ret = hid_hw_raw_request(hdev, ELAN_FEATURE_REPORT, dmabuf,
91 ELAN_FEATURE_SIZE, HID_FEATURE_REPORT,
92 HID_REQ_SET_REPORT);
93 if (ret != ELAN_FEATURE_SIZE) {
94 hid_err(hdev, "Set report error for parm %d: %d\n", param, ret);
95 return ret;
96 }
97
98 ret = hid_hw_raw_request(hdev, ELAN_FEATURE_REPORT, dmabuf,
99 ELAN_FEATURE_SIZE, HID_FEATURE_REPORT,
100 HID_REQ_GET_REPORT);
101 if (ret != ELAN_FEATURE_SIZE) {
102 hid_err(hdev, "Get report error for parm %d: %d\n", param, ret);
103 return ret;
104 }
105
106 return 0;
107}
108
Hans de Goede19588be2018-07-11 12:38:34 +0200109static unsigned int elan_convert_res(char val)
110{
111 /*
112 * (value from firmware) * 10 + 790 = dpi
113 * dpi * 10 / 254 = dots/mm
114 */
115 return (val * 10 + 790) * 10 / 254;
116}
117
Hans de Goede79d11f22018-07-11 12:38:33 +0200118static int elan_get_device_params(struct hid_device *hdev)
119{
120 struct elan_drvdata *drvdata = hid_get_drvdata(hdev);
121 unsigned char *dmabuf;
122 int ret;
123
124 dmabuf = kmalloc(ELAN_FEATURE_SIZE, GFP_KERNEL);
125 if (!dmabuf)
126 return -ENOMEM;
127
128 ret = elan_get_device_param(hdev, dmabuf, ELAN_PARAM_MAX_X);
129 if (ret)
130 goto err;
131
132 drvdata->max_x = (dmabuf[4] << 8) | dmabuf[3];
133
134 ret = elan_get_device_param(hdev, dmabuf, ELAN_PARAM_MAX_Y);
135 if (ret)
136 goto err;
137
138 drvdata->max_y = (dmabuf[4] << 8) | dmabuf[3];
139
Hans de Goede19588be2018-07-11 12:38:34 +0200140 ret = elan_get_device_param(hdev, dmabuf, ELAN_PARAM_RES);
141 if (ret)
142 goto err;
143
144 drvdata->res_x = elan_convert_res(dmabuf[3]);
145 drvdata->res_y = elan_convert_res(dmabuf[4]);
146
Hans de Goede79d11f22018-07-11 12:38:33 +0200147err:
148 kfree(dmabuf);
149 return ret;
150}
151
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300152static int elan_input_configured(struct hid_device *hdev, struct hid_input *hi)
153{
154 int ret;
155 struct input_dev *input;
156 struct elan_drvdata *drvdata = hid_get_drvdata(hdev);
157
158 if (is_not_elan_touchpad(hdev))
159 return 0;
160
Hans de Goede79d11f22018-07-11 12:38:33 +0200161 ret = elan_get_device_params(hdev);
162 if (ret)
163 return ret;
164
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300165 input = devm_input_allocate_device(&hdev->dev);
166 if (!input)
167 return -ENOMEM;
168
169 input->name = "Elan Touchpad";
170 input->phys = hdev->phys;
171 input->uniq = hdev->uniq;
172 input->id.bustype = hdev->bus;
173 input->id.vendor = hdev->vendor;
174 input->id.product = hdev->product;
175 input->id.version = hdev->version;
176 input->dev.parent = &hdev->dev;
177
Hans de Goede79d11f22018-07-11 12:38:33 +0200178 input_set_abs_params(input, ABS_MT_POSITION_X, 0, drvdata->max_x,
179 0, 0);
180 input_set_abs_params(input, ABS_MT_POSITION_Y, 0, drvdata->max_y,
181 0, 0);
Hans de Goede2f612de2018-07-11 12:38:31 +0200182 input_set_abs_params(input, ABS_MT_PRESSURE, 0, ELAN_MAX_PRESSURE,
183 0, 0);
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300184
185 __set_bit(BTN_LEFT, input->keybit);
186 __set_bit(INPUT_PROP_BUTTONPAD, input->propbit);
187
Hans de Goede314f04e2018-07-11 12:38:32 +0200188 ret = input_mt_init_slots(input, ELAN_MAX_FINGERS, INPUT_MT_POINTER);
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300189 if (ret) {
190 hid_err(hdev, "Failed to init elan MT slots: %d\n", ret);
Dinghao Liub7429ea2020-08-31 17:06:43 +0800191 input_free_device(input);
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300192 return ret;
193 }
194
Hans de Goede19588be2018-07-11 12:38:34 +0200195 input_abs_set_res(input, ABS_X, drvdata->res_x);
196 input_abs_set_res(input, ABS_Y, drvdata->res_y);
197
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300198 ret = input_register_device(input);
199 if (ret) {
200 hid_err(hdev, "Failed to register elan input device: %d\n",
201 ret);
Dinghao Liub7429ea2020-08-31 17:06:43 +0800202 input_mt_destroy_slots(input);
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300203 input_free_device(input);
204 return ret;
205 }
206
207 drvdata->input = input;
208
209 return 0;
210}
211
212static void elan_report_mt_slot(struct elan_drvdata *drvdata, u8 *data,
213 unsigned int slot_num)
214{
215 struct input_dev *input = drvdata->input;
Hans de Goede2f612de2018-07-11 12:38:31 +0200216 int x, y, p;
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300217
218 bool active = !!data;
219
220 input_mt_slot(input, slot_num);
221 input_mt_report_slot_state(input, MT_TOOL_FINGER, active);
222 if (active) {
223 x = ((data[0] & 0xF0) << 4) | data[1];
Hans de Goede79d11f22018-07-11 12:38:33 +0200224 y = drvdata->max_y -
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300225 (((data[0] & 0x07) << 8) | data[2]);
Hans de Goede2f612de2018-07-11 12:38:31 +0200226 p = data[4];
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300227
228 input_report_abs(input, ABS_MT_POSITION_X, x);
229 input_report_abs(input, ABS_MT_POSITION_Y, y);
Hans de Goede2f612de2018-07-11 12:38:31 +0200230 input_report_abs(input, ABS_MT_PRESSURE, p);
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300231 }
232}
233
Hans de Goedee7ad3dc2018-07-11 12:38:37 +0200234static void elan_usb_report_input(struct elan_drvdata *drvdata, u8 *data)
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300235{
236 int i;
237 struct input_dev *input = drvdata->input;
238
239 /*
240 * There is 3 types of reports: for single touch,
241 * for multitouch - first finger and for multitouch - second finger
242 *
243 * packet structure for ELAN_SINGLE_FINGER and ELAN_MT_FIRST_FINGER:
244 *
245 * byte 1: 1 0 0 0 0 0 0 1 // 0x81 or 0x82
246 * byte 2: 0 0 0 0 0 0 0 0 // looks like unused
247 * byte 3: f5 f4 f3 f2 f1 0 0 L
248 * byte 4: x12 x11 x10 x9 0? y11 y10 y9
249 * byte 5: x8 x7 x6 x5 x4 x3 x2 x1
250 * byte 6: y8 y7 y6 y5 y4 y3 y2 y1
251 * byte 7: sy4 sy3 sy2 sy1 sx4 sx3 sx2 sx1
Hans de Goede2f612de2018-07-11 12:38:31 +0200252 * byte 8: p8 p7 p6 p5 p4 p3 p2 p1
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300253 *
254 * packet structure for ELAN_MT_SECOND_FINGER:
255 *
256 * byte 1: 1 0 0 0 0 0 1 1 // 0x83
257 * byte 2: x12 x11 x10 x9 0 y11 y10 y9
258 * byte 3: x8 x7 x6 x5 x4 x3 x2 x1
259 * byte 4: y8 y7 y6 y5 y4 y3 y2 y1
260 * byte 5: sy4 sy3 sy2 sy1 sx4 sx3 sx2 sx1
Hans de Goede2f612de2018-07-11 12:38:31 +0200261 * byte 6: p8 p7 p6 p5 p4 p3 p2 p1
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300262 * byte 7: 0 0 0 0 0 0 0 0
263 * byte 8: 0 0 0 0 0 0 0 0
264 *
265 * f5-f1: finger touch bits
266 * L: clickpad button
Hans de Goede2f612de2018-07-11 12:38:31 +0200267 * sy / sx: finger width / height expressed in traces, the total number
268 * of traces can be queried by doing a HID_REQ_SET_REPORT
269 * { 0x0d, 0x05, 0x03, 0x05, 0x01 } followed by a GET, in the
270 * returned buf, buf[3]=no-x-traces, buf[4]=no-y-traces.
271 * p: pressure
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300272 */
273
274 if (data[0] == ELAN_SINGLE_FINGER) {
Hans de Goede314f04e2018-07-11 12:38:32 +0200275 for (i = 0; i < ELAN_MAX_FINGERS; i++) {
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300276 if (data[2] & BIT(i + 3))
277 elan_report_mt_slot(drvdata, data + 3, i);
278 else
279 elan_report_mt_slot(drvdata, NULL, i);
280 }
281 input_report_key(input, BTN_LEFT, data[2] & 0x01);
282 }
283 /*
284 * When touched with two fingers Elan touchpad will emit two HID reports
285 * first is ELAN_MT_FIRST_FINGER and second is ELAN_MT_SECOND_FINGER
286 * we will save ELAN_MT_FIRST_FINGER report and wait for
287 * ELAN_MT_SECOND_FINGER to finish multitouch
288 */
289 if (data[0] == ELAN_MT_FIRST_FINGER) {
290 memcpy(drvdata->prev_report, data,
291 sizeof(drvdata->prev_report));
292 return;
293 }
294
295 if (data[0] == ELAN_MT_SECOND_FINGER) {
296 int first = 0;
297 u8 *prev_report = drvdata->prev_report;
298
299 if (prev_report[0] != ELAN_MT_FIRST_FINGER)
300 return;
301
Hans de Goede314f04e2018-07-11 12:38:32 +0200302 for (i = 0; i < ELAN_MAX_FINGERS; i++) {
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300303 if (prev_report[2] & BIT(i + 3)) {
304 if (!first) {
305 first = 1;
306 elan_report_mt_slot(drvdata, prev_report + 3, i);
307 } else {
308 elan_report_mt_slot(drvdata, data + 1, i);
309 }
310 } else {
311 elan_report_mt_slot(drvdata, NULL, i);
312 }
313 }
314 input_report_key(input, BTN_LEFT, prev_report[2] & 0x01);
315 }
316
317 input_mt_sync_frame(input);
318 input_sync(input);
319}
320
Hans de Goedee7ad3dc2018-07-11 12:38:37 +0200321static void elan_i2c_report_input(struct elan_drvdata *drvdata, u8 *data)
322{
323 struct input_dev *input = drvdata->input;
324 u8 *finger_data;
325 int i;
326
327 /*
328 * Elan MT touchpads in i2c mode send finger data in the same format
329 * as in USB mode, but then with all fingers in a single packet.
330 *
331 * packet structure for ELAN_MT_I2C:
332 *
333 * byte 1: 1 0 0 1 1 1 0 1 // 0x5d
334 * byte 2: f5 f4 f3 f2 f1 0 0 L
335 * byte 3: x12 x11 x10 x9 0? y11 y10 y9
336 * byte 4: x8 x7 x6 x5 x4 x3 x2 x1
337 * byte 5: y8 y7 y6 y5 y4 y3 y2 y1
338 * byte 6: sy4 sy3 sy2 sy1 sx4 sx3 sx2 sx1
339 * byte 7: p8 p7 p6 p5 p4 p3 p2 p1
340 * byte 8-12: Same as byte 3-7 for second finger down
341 * byte 13-17: Same as byte 3-7 for third finger down
342 * byte 18-22: Same as byte 3-7 for fourth finger down
343 * byte 23-27: Same as byte 3-7 for fifth finger down
344 */
345
346 finger_data = data + 2;
347 for (i = 0; i < ELAN_MAX_FINGERS; i++) {
348 if (data[1] & BIT(i + 3)) {
349 elan_report_mt_slot(drvdata, finger_data, i);
350 finger_data += ELAN_FINGER_DATA_LEN;
351 } else {
352 elan_report_mt_slot(drvdata, NULL, i);
353 }
354 }
355
356 input_report_key(input, BTN_LEFT, data[1] & 0x01);
357 input_mt_sync_frame(input);
358 input_sync(input);
359}
360
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300361static int elan_raw_event(struct hid_device *hdev,
362 struct hid_report *report, u8 *data, int size)
363{
364 struct elan_drvdata *drvdata = hid_get_drvdata(hdev);
365
366 if (is_not_elan_touchpad(hdev))
367 return 0;
368
369 if (data[0] == ELAN_SINGLE_FINGER ||
370 data[0] == ELAN_MT_FIRST_FINGER ||
371 data[0] == ELAN_MT_SECOND_FINGER) {
372 if (size == ELAN_INPUT_REPORT_SIZE) {
Hans de Goedee7ad3dc2018-07-11 12:38:37 +0200373 elan_usb_report_input(drvdata, data);
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300374 return 1;
375 }
376 }
377
Hans de Goedee7ad3dc2018-07-11 12:38:37 +0200378 if (data[0] == ELAN_MT_I2C && size == ELAN_I2C_REPORT_SIZE) {
379 elan_i2c_report_input(drvdata, data);
380 return 1;
381 }
382
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300383 return 0;
384}
385
386static int elan_start_multitouch(struct hid_device *hdev)
387{
388 int ret;
389
390 /*
391 * This byte sequence will enable multitouch mode and disable
392 * mouse emulation
393 */
Colin Ian King84713002019-01-25 16:05:46 +0000394 static const unsigned char buf[] = { 0x0D, 0x00, 0x03, 0x21, 0x00 };
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300395 unsigned char *dmabuf = kmemdup(buf, sizeof(buf), GFP_KERNEL);
396
397 if (!dmabuf)
398 return -ENOMEM;
399
400 ret = hid_hw_raw_request(hdev, dmabuf[0], dmabuf, sizeof(buf),
401 HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
402
403 kfree(dmabuf);
404
405 if (ret != sizeof(buf)) {
406 hid_err(hdev, "Failed to start multitouch: %d\n", ret);
407 return ret;
408 }
409
410 return 0;
411}
412
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300413static int elan_mute_led_set_brigtness(struct led_classdev *led_cdev,
414 enum led_brightness value)
415{
416 int ret;
417 u8 led_state;
418 struct device *dev = led_cdev->dev->parent;
419 struct hid_device *hdev = to_hid_device(dev);
420 struct elan_drvdata *drvdata = hid_get_drvdata(hdev);
421
422 unsigned char *dmabuf = kzalloc(ELAN_LED_REPORT_SIZE, GFP_KERNEL);
423
424 if (!dmabuf)
425 return -ENOMEM;
426
427 led_state = !!value;
428
429 dmabuf[0] = ELAN_MUTE_LED_REPORT;
430 dmabuf[1] = 0x02;
431 dmabuf[2] = led_state;
432
433 ret = hid_hw_raw_request(hdev, dmabuf[0], dmabuf, ELAN_LED_REPORT_SIZE,
434 HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
435
436 kfree(dmabuf);
437
438 if (ret != ELAN_LED_REPORT_SIZE) {
Hans de Goedeefb618fb2021-04-04 09:52:50 +0200439 if (ret != -ENODEV)
440 hid_err(hdev, "Failed to set mute led brightness: %d\n", ret);
441 return ret < 0 ? ret : -EIO;
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300442 }
443
444 drvdata->mute_led_state = led_state;
445 return 0;
446}
447
448static int elan_init_mute_led(struct hid_device *hdev)
449{
450 struct elan_drvdata *drvdata = hid_get_drvdata(hdev);
451 struct led_classdev *mute_led = &drvdata->mute_led;
452
453 mute_led->name = "elan:red:mute";
Hans de Goede26013712021-04-04 09:52:51 +0200454 mute_led->default_trigger = "audio-mute";
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300455 mute_led->brightness_set_blocking = elan_mute_led_set_brigtness;
456 mute_led->max_brightness = LED_ON;
Hans de Goedeefb618fb2021-04-04 09:52:50 +0200457 mute_led->flags = LED_HW_PLUGGABLE;
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300458 mute_led->dev = &hdev->dev;
459
460 return devm_led_classdev_register(&hdev->dev, mute_led);
461}
462
463static int elan_probe(struct hid_device *hdev, const struct hid_device_id *id)
464{
465 int ret;
466 struct elan_drvdata *drvdata;
467
468 drvdata = devm_kzalloc(&hdev->dev, sizeof(*drvdata), GFP_KERNEL);
469
470 if (!drvdata)
471 return -ENOMEM;
472
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300473 hid_set_drvdata(hdev, drvdata);
474
475 ret = hid_parse(hdev);
476 if (ret) {
477 hid_err(hdev, "Hid Parse failed\n");
478 return ret;
479 }
480
481 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
482 if (ret) {
483 hid_err(hdev, "Hid hw start failed\n");
484 return ret;
485 }
486
487 if (is_not_elan_touchpad(hdev))
488 return 0;
489
490 if (!drvdata->input) {
Colin Ian King14f39922018-09-27 15:00:52 +0100491 hid_err(hdev, "Input device is not registered\n");
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300492 ret = -ENAVAIL;
493 goto err;
494 }
495
496 ret = elan_start_multitouch(hdev);
497 if (ret)
498 goto err;
499
Hans de Goede7ed3f282018-07-11 12:38:35 +0200500 if (id->driver_data & ELAN_HAS_LED) {
501 ret = elan_init_mute_led(hdev);
502 if (ret)
503 goto err;
504 }
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300505
506 return 0;
507err:
508 hid_hw_stop(hdev);
509 return ret;
510}
511
512static void elan_remove(struct hid_device *hdev)
513{
514 hid_hw_stop(hdev);
515}
516
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300517static const struct hid_device_id elan_devices[] = {
Hans de Goede6e5dd632018-07-11 12:38:36 +0200518 { HID_USB_DEVICE(USB_VENDOR_ID_ELAN, USB_DEVICE_ID_HP_X2),
519 .driver_data = ELAN_HAS_LED },
Hans de Goede7ed3f282018-07-11 12:38:35 +0200520 { HID_USB_DEVICE(USB_VENDOR_ID_ELAN, USB_DEVICE_ID_HP_X2_10_COVER),
521 .driver_data = ELAN_HAS_LED },
Hans de Goedee7ad3dc2018-07-11 12:38:37 +0200522 { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, USB_DEVICE_ID_TOSHIBA_CLICK_L9W) },
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300523 { }
524};
Alexandrov Stansilav9a6a4192018-01-14 02:33:49 +0300525MODULE_DEVICE_TABLE(hid, elan_devices);
526
527static struct hid_driver elan_driver = {
528 .name = "elan",
529 .id_table = elan_devices,
530 .input_mapping = elan_input_mapping,
531 .input_configured = elan_input_configured,
532 .raw_event = elan_raw_event,
533 .probe = elan_probe,
534 .remove = elan_remove,
535};
536
537module_hid_driver(elan_driver);
538
539MODULE_LICENSE("GPL");
540MODULE_AUTHOR("Alexandrov Stanislav");
541MODULE_DESCRIPTION("Driver for HID ELAN Touchpads");