94756d28af59f05f64767465c4483cfd84f9ac55
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / hid / hid-multitouch.c
1 /*
2 * HID driver for multitouch panels
3 *
4 * Copyright (c) 2010-2011 Stephane Chatty <chatty@enac.fr>
5 * Copyright (c) 2010-2011 Benjamin Tissoires <benjamin.tissoires@gmail.com>
6 * Copyright (c) 2010-2011 Ecole Nationale de l'Aviation Civile, France
7 *
8 * This code is partly based on hid-egalax.c:
9 *
10 * Copyright (c) 2010 Stephane Chatty <chatty@enac.fr>
11 * Copyright (c) 2010 Henrik Rydberg <rydberg@euromail.se>
12 * Copyright (c) 2010 Canonical, Ltd.
13 *
14 * This code is partly based on hid-3m-pct.c:
15 *
16 * Copyright (c) 2009-2010 Stephane Chatty <chatty@enac.fr>
17 * Copyright (c) 2010 Henrik Rydberg <rydberg@euromail.se>
18 * Copyright (c) 2010 Canonical, Ltd.
19 *
20 */
21
22 /*
23 * This program is free software; you can redistribute it and/or modify it
24 * under the terms of the GNU General Public License as published by the Free
25 * Software Foundation; either version 2 of the License, or (at your option)
26 * any later version.
27 */
28
29 #include <linux/device.h>
30 #include <linux/hid.h>
31 #include <linux/module.h>
32 #include <linux/slab.h>
33 #include <linux/usb.h>
34 #include <linux/input/mt.h>
35 #include "usbhid/usbhid.h"
36
37
38 MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>");
39 MODULE_AUTHOR("Benjamin Tissoires <benjamin.tissoires@gmail.com>");
40 MODULE_DESCRIPTION("HID multitouch panels");
41 MODULE_LICENSE("GPL");
42
43 #include "hid-ids.h"
44
45 /* quirks to control the device */
46 #define MT_QUIRK_NOT_SEEN_MEANS_UP (1 << 0)
47 #define MT_QUIRK_SLOT_IS_CONTACTID (1 << 1)
48 #define MT_QUIRK_CYPRESS (1 << 2)
49 #define MT_QUIRK_SLOT_IS_CONTACTNUMBER (1 << 3)
50 #define MT_QUIRK_ALWAYS_VALID (1 << 4)
51 #define MT_QUIRK_VALID_IS_INRANGE (1 << 5)
52 #define MT_QUIRK_VALID_IS_CONFIDENCE (1 << 6)
53 #define MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE (1 << 8)
54
55 struct mt_slot {
56 __s32 x, y, p, w, h;
57 __s32 contactid; /* the device ContactID assigned to this slot */
58 bool touch_state; /* is the touch valid? */
59 bool seen_in_this_frame;/* has this slot been updated */
60 };
61
62 struct mt_class {
63 __s32 name; /* MT_CLS */
64 __s32 quirks;
65 __s32 sn_move; /* Signal/noise ratio for move events */
66 __s32 sn_width; /* Signal/noise ratio for width events */
67 __s32 sn_height; /* Signal/noise ratio for height events */
68 __s32 sn_pressure; /* Signal/noise ratio for pressure events */
69 __u8 maxcontacts;
70 };
71
72 struct mt_device {
73 struct mt_slot curdata; /* placeholder of incoming data */
74 struct mt_class mtclass; /* our mt device class */
75 unsigned last_field_index; /* last field index of the report */
76 unsigned last_slot_field; /* the last field of a slot */
77 int last_mt_collection; /* last known mt-related collection */
78 __s8 inputmode; /* InputMode HID feature, -1 if non-existent */
79 __u8 num_received; /* how many contacts we received */
80 __u8 num_expected; /* expected last contact index */
81 __u8 maxcontacts;
82 bool curvalid; /* is the current contact valid? */
83 struct mt_slot *slots;
84 };
85
86 /* classes of device behavior */
87 #define MT_CLS_DEFAULT 0x0001
88
89 #define MT_CLS_SERIAL 0x0002
90 #define MT_CLS_CONFIDENCE 0x0003
91 #define MT_CLS_CONFIDENCE_MINUS_ONE 0x0004
92 #define MT_CLS_DUAL_INRANGE_CONTACTID 0x0005
93 #define MT_CLS_DUAL_INRANGE_CONTACTNUMBER 0x0006
94 #define MT_CLS_DUAL_NSMU_CONTACTID 0x0007
95
96 /* vendor specific classes */
97 #define MT_CLS_3M 0x0101
98 #define MT_CLS_CYPRESS 0x0102
99 #define MT_CLS_EGALAX 0x0103
100
101 #define MT_DEFAULT_MAXCONTACT 10
102
103 /*
104 * these device-dependent functions determine what slot corresponds
105 * to a valid contact that was just read.
106 */
107
108 static int cypress_compute_slot(struct mt_device *td)
109 {
110 if (td->curdata.contactid != 0 || td->num_received == 0)
111 return td->curdata.contactid;
112 else
113 return -1;
114 }
115
116 static int find_slot_from_contactid(struct mt_device *td)
117 {
118 int i;
119 for (i = 0; i < td->maxcontacts; ++i) {
120 if (td->slots[i].contactid == td->curdata.contactid &&
121 td->slots[i].touch_state)
122 return i;
123 }
124 for (i = 0; i < td->maxcontacts; ++i) {
125 if (!td->slots[i].seen_in_this_frame &&
126 !td->slots[i].touch_state)
127 return i;
128 }
129 /* should not occurs. If this happens that means
130 * that the device sent more touches that it says
131 * in the report descriptor. It is ignored then. */
132 return -1;
133 }
134
135 struct mt_class mt_classes[] = {
136 { .name = MT_CLS_DEFAULT,
137 .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP },
138 { .name = MT_CLS_SERIAL,
139 .quirks = MT_QUIRK_ALWAYS_VALID},
140 { .name = MT_CLS_CONFIDENCE,
141 .quirks = MT_QUIRK_VALID_IS_CONFIDENCE },
142 { .name = MT_CLS_CONFIDENCE_MINUS_ONE,
143 .quirks = MT_QUIRK_VALID_IS_CONFIDENCE |
144 MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE },
145 { .name = MT_CLS_DUAL_INRANGE_CONTACTID,
146 .quirks = MT_QUIRK_VALID_IS_INRANGE |
147 MT_QUIRK_SLOT_IS_CONTACTID,
148 .maxcontacts = 2 },
149 { .name = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
150 .quirks = MT_QUIRK_VALID_IS_INRANGE |
151 MT_QUIRK_SLOT_IS_CONTACTNUMBER,
152 .maxcontacts = 2 },
153 { .name = MT_CLS_DUAL_NSMU_CONTACTID,
154 .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP |
155 MT_QUIRK_SLOT_IS_CONTACTID,
156 .maxcontacts = 2 },
157
158 /*
159 * vendor specific classes
160 */
161 { .name = MT_CLS_3M,
162 .quirks = MT_QUIRK_VALID_IS_CONFIDENCE |
163 MT_QUIRK_SLOT_IS_CONTACTID,
164 .sn_move = 2048,
165 .sn_width = 128,
166 .sn_height = 128 },
167 { .name = MT_CLS_CYPRESS,
168 .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP |
169 MT_QUIRK_CYPRESS,
170 .maxcontacts = 10 },
171 { .name = MT_CLS_EGALAX,
172 .quirks = MT_QUIRK_SLOT_IS_CONTACTID |
173 MT_QUIRK_VALID_IS_INRANGE,
174 .maxcontacts = 2,
175 .sn_move = 4096,
176 .sn_pressure = 32,
177 },
178
179 { }
180 };
181
182 static ssize_t mt_show_quirks(struct device *dev,
183 struct device_attribute *attr,
184 char *buf)
185 {
186 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
187 struct mt_device *td = hid_get_drvdata(hdev);
188
189 return sprintf(buf, "%u\n", td->mtclass.quirks);
190 }
191
192 static ssize_t mt_set_quirks(struct device *dev,
193 struct device_attribute *attr,
194 const char *buf, size_t count)
195 {
196 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
197 struct mt_device *td = hid_get_drvdata(hdev);
198
199 unsigned long val;
200
201 if (kstrtoul(buf, 0, &val))
202 return -EINVAL;
203
204 td->mtclass.quirks = val;
205
206 return count;
207 }
208
209 static DEVICE_ATTR(quirks, S_IWUSR | S_IRUGO, mt_show_quirks, mt_set_quirks);
210
211 static struct attribute *sysfs_attrs[] = {
212 &dev_attr_quirks.attr,
213 NULL
214 };
215
216 static struct attribute_group mt_attribute_group = {
217 .attrs = sysfs_attrs
218 };
219
220 static void mt_feature_mapping(struct hid_device *hdev,
221 struct hid_field *field, struct hid_usage *usage)
222 {
223 struct mt_device *td = hid_get_drvdata(hdev);
224
225 switch (usage->hid) {
226 case HID_DG_INPUTMODE:
227 td->inputmode = field->report->id;
228 break;
229 case HID_DG_CONTACTMAX:
230 td->maxcontacts = field->value[0];
231 if (td->mtclass.maxcontacts)
232 /* check if the maxcontacts is given by the class */
233 td->maxcontacts = td->mtclass.maxcontacts;
234
235 break;
236 }
237 }
238
239 static void set_abs(struct input_dev *input, unsigned int code,
240 struct hid_field *field, int snratio)
241 {
242 int fmin = field->logical_minimum;
243 int fmax = field->logical_maximum;
244 int fuzz = snratio ? (fmax - fmin) / snratio : 0;
245 input_set_abs_params(input, code, fmin, fmax, fuzz, 0);
246 }
247
248 static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
249 struct hid_field *field, struct hid_usage *usage,
250 unsigned long **bit, int *max)
251 {
252 struct mt_device *td = hid_get_drvdata(hdev);
253 struct mt_class *cls = &td->mtclass;
254
255 /* Only map fields from TouchScreen or TouchPad collections.
256 * We need to ignore fields that belong to other collections
257 * such as Mouse that might have the same GenericDesktop usages. */
258 if (field->application == HID_DG_TOUCHSCREEN)
259 set_bit(INPUT_PROP_DIRECT, hi->input->propbit);
260 else if (field->application == HID_DG_TOUCHPAD)
261 set_bit(INPUT_PROP_POINTER, hi->input->propbit);
262 else
263 return 0;
264
265 /* eGalax devices provide a Digitizer.Stylus input which overrides
266 * the correct Digitizers.Finger X/Y ranges.
267 * Let's just ignore this input. */
268 if (field->physical == HID_DG_STYLUS)
269 return -1;
270
271 switch (usage->hid & HID_USAGE_PAGE) {
272
273 case HID_UP_GENDESK:
274 switch (usage->hid) {
275 case HID_GD_X:
276 hid_map_usage(hi, usage, bit, max,
277 EV_ABS, ABS_MT_POSITION_X);
278 set_abs(hi->input, ABS_MT_POSITION_X, field,
279 cls->sn_move);
280 /* touchscreen emulation */
281 set_abs(hi->input, ABS_X, field, cls->sn_move);
282 if (td->last_mt_collection == usage->collection_index) {
283 td->last_slot_field = usage->hid;
284 td->last_field_index = field->index;
285 }
286 return 1;
287 case HID_GD_Y:
288 hid_map_usage(hi, usage, bit, max,
289 EV_ABS, ABS_MT_POSITION_Y);
290 set_abs(hi->input, ABS_MT_POSITION_Y, field,
291 cls->sn_move);
292 /* touchscreen emulation */
293 set_abs(hi->input, ABS_Y, field, cls->sn_move);
294 if (td->last_mt_collection == usage->collection_index) {
295 td->last_slot_field = usage->hid;
296 td->last_field_index = field->index;
297 }
298 return 1;
299 }
300 return 0;
301
302 case HID_UP_DIGITIZER:
303 switch (usage->hid) {
304 case HID_DG_INRANGE:
305 if (td->last_mt_collection == usage->collection_index) {
306 td->last_slot_field = usage->hid;
307 td->last_field_index = field->index;
308 }
309 return 1;
310 case HID_DG_CONFIDENCE:
311 if (td->last_mt_collection == usage->collection_index) {
312 td->last_slot_field = usage->hid;
313 td->last_field_index = field->index;
314 }
315 return 1;
316 case HID_DG_TIPSWITCH:
317 hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH);
318 input_set_capability(hi->input, EV_KEY, BTN_TOUCH);
319 if (td->last_mt_collection == usage->collection_index) {
320 td->last_slot_field = usage->hid;
321 td->last_field_index = field->index;
322 }
323 return 1;
324 case HID_DG_CONTACTID:
325 if (!td->maxcontacts)
326 td->maxcontacts = MT_DEFAULT_MAXCONTACT;
327 input_mt_init_slots(hi->input, td->maxcontacts);
328 td->last_slot_field = usage->hid;
329 td->last_field_index = field->index;
330 td->last_mt_collection = usage->collection_index;
331 return 1;
332 case HID_DG_WIDTH:
333 hid_map_usage(hi, usage, bit, max,
334 EV_ABS, ABS_MT_TOUCH_MAJOR);
335 set_abs(hi->input, ABS_MT_TOUCH_MAJOR, field,
336 cls->sn_width);
337 if (td->last_mt_collection == usage->collection_index) {
338 td->last_slot_field = usage->hid;
339 td->last_field_index = field->index;
340 }
341 return 1;
342 case HID_DG_HEIGHT:
343 hid_map_usage(hi, usage, bit, max,
344 EV_ABS, ABS_MT_TOUCH_MINOR);
345 set_abs(hi->input, ABS_MT_TOUCH_MINOR, field,
346 cls->sn_height);
347 input_set_abs_params(hi->input,
348 ABS_MT_ORIENTATION, 0, 1, 0, 0);
349 if (td->last_mt_collection == usage->collection_index) {
350 td->last_slot_field = usage->hid;
351 td->last_field_index = field->index;
352 }
353 return 1;
354 case HID_DG_TIPPRESSURE:
355 hid_map_usage(hi, usage, bit, max,
356 EV_ABS, ABS_MT_PRESSURE);
357 set_abs(hi->input, ABS_MT_PRESSURE, field,
358 cls->sn_pressure);
359 /* touchscreen emulation */
360 set_abs(hi->input, ABS_PRESSURE, field,
361 cls->sn_pressure);
362 if (td->last_mt_collection == usage->collection_index) {
363 td->last_slot_field = usage->hid;
364 td->last_field_index = field->index;
365 }
366 return 1;
367 case HID_DG_CONTACTCOUNT:
368 if (td->last_mt_collection == usage->collection_index)
369 td->last_field_index = field->index;
370 return 1;
371 case HID_DG_CONTACTMAX:
372 /* we don't set td->last_slot_field as contactcount and
373 * contact max are global to the report */
374 if (td->last_mt_collection == usage->collection_index)
375 td->last_field_index = field->index;
376 return -1;
377 }
378 /* let hid-input decide for the others */
379 return 0;
380
381 case 0xff000000:
382 /* we do not want to map these: no input-oriented meaning */
383 return -1;
384 }
385
386 return 0;
387 }
388
389 static int mt_input_mapped(struct hid_device *hdev, struct hid_input *hi,
390 struct hid_field *field, struct hid_usage *usage,
391 unsigned long **bit, int *max)
392 {
393 if (usage->type == EV_KEY || usage->type == EV_ABS)
394 set_bit(usage->type, hi->input->evbit);
395
396 return -1;
397 }
398
399 static int mt_compute_slot(struct mt_device *td)
400 {
401 __s32 quirks = td->mtclass.quirks;
402
403 if (quirks & MT_QUIRK_SLOT_IS_CONTACTID)
404 return td->curdata.contactid;
405
406 if (quirks & MT_QUIRK_CYPRESS)
407 return cypress_compute_slot(td);
408
409 if (quirks & MT_QUIRK_SLOT_IS_CONTACTNUMBER)
410 return td->num_received;
411
412 if (quirks & MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE)
413 return td->curdata.contactid - 1;
414
415 return find_slot_from_contactid(td);
416 }
417
418 /*
419 * this function is called when a whole contact has been processed,
420 * so that it can assign it to a slot and store the data there
421 */
422 static void mt_complete_slot(struct mt_device *td)
423 {
424 td->curdata.seen_in_this_frame = true;
425 if (td->curvalid) {
426 int slotnum = mt_compute_slot(td);
427
428 if (slotnum >= 0 && slotnum < td->maxcontacts)
429 td->slots[slotnum] = td->curdata;
430 }
431 td->num_received++;
432 }
433
434
435 /*
436 * this function is called when a whole packet has been received and processed,
437 * so that it can decide what to send to the input layer.
438 */
439 static void mt_emit_event(struct mt_device *td, struct input_dev *input)
440 {
441 int i;
442
443 for (i = 0; i < td->maxcontacts; ++i) {
444 struct mt_slot *s = &(td->slots[i]);
445 if ((td->mtclass.quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) &&
446 !s->seen_in_this_frame) {
447 s->touch_state = false;
448 }
449
450 input_mt_slot(input, i);
451 input_mt_report_slot_state(input, MT_TOOL_FINGER,
452 s->touch_state);
453 if (s->touch_state) {
454 /* this finger is on the screen */
455 int wide = (s->w > s->h);
456 /* divided by two to match visual scale of touch */
457 int major = max(s->w, s->h) >> 1;
458 int minor = min(s->w, s->h) >> 1;
459
460 input_event(input, EV_ABS, ABS_MT_POSITION_X, s->x);
461 input_event(input, EV_ABS, ABS_MT_POSITION_Y, s->y);
462 input_event(input, EV_ABS, ABS_MT_ORIENTATION, wide);
463 input_event(input, EV_ABS, ABS_MT_PRESSURE, s->p);
464 input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, major);
465 input_event(input, EV_ABS, ABS_MT_TOUCH_MINOR, minor);
466 }
467 s->seen_in_this_frame = false;
468
469 }
470
471 input_mt_report_pointer_emulation(input, true);
472 input_sync(input);
473 td->num_received = 0;
474 }
475
476
477
478 static int mt_event(struct hid_device *hid, struct hid_field *field,
479 struct hid_usage *usage, __s32 value)
480 {
481 struct mt_device *td = hid_get_drvdata(hid);
482 __s32 quirks = td->mtclass.quirks;
483
484 if (hid->claimed & HID_CLAIMED_INPUT && td->slots) {
485 switch (usage->hid) {
486 case HID_DG_INRANGE:
487 if (quirks & MT_QUIRK_ALWAYS_VALID)
488 td->curvalid = true;
489 else if (quirks & MT_QUIRK_VALID_IS_INRANGE)
490 td->curvalid = value;
491 break;
492 case HID_DG_TIPSWITCH:
493 if (quirks & MT_QUIRK_NOT_SEEN_MEANS_UP)
494 td->curvalid = value;
495 td->curdata.touch_state = value;
496 break;
497 case HID_DG_CONFIDENCE:
498 if (quirks & MT_QUIRK_VALID_IS_CONFIDENCE)
499 td->curvalid = value;
500 break;
501 case HID_DG_CONTACTID:
502 td->curdata.contactid = value;
503 break;
504 case HID_DG_TIPPRESSURE:
505 td->curdata.p = value;
506 break;
507 case HID_GD_X:
508 td->curdata.x = value;
509 break;
510 case HID_GD_Y:
511 td->curdata.y = value;
512 break;
513 case HID_DG_WIDTH:
514 td->curdata.w = value;
515 break;
516 case HID_DG_HEIGHT:
517 td->curdata.h = value;
518 break;
519 case HID_DG_CONTACTCOUNT:
520 /*
521 * Includes multi-packet support where subsequent
522 * packets are sent with zero contactcount.
523 */
524 if (value)
525 td->num_expected = value;
526 break;
527
528 default:
529 /* fallback to the generic hidinput handling */
530 return 0;
531 }
532
533 if (usage->hid == td->last_slot_field) {
534 mt_complete_slot(td);
535 }
536
537 if (field->index == td->last_field_index
538 && td->num_received >= td->num_expected)
539 mt_emit_event(td, field->hidinput->input);
540
541 }
542
543 /* we have handled the hidinput part, now remains hiddev */
544 if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event)
545 hid->hiddev_hid_event(hid, field, usage, value);
546
547 return 1;
548 }
549
550 static void mt_set_input_mode(struct hid_device *hdev)
551 {
552 struct mt_device *td = hid_get_drvdata(hdev);
553 struct hid_report *r;
554 struct hid_report_enum *re;
555
556 if (td->inputmode < 0)
557 return;
558
559 re = &(hdev->report_enum[HID_FEATURE_REPORT]);
560 r = re->report_id_hash[td->inputmode];
561 if (r) {
562 r->field[0]->value[0] = 0x02;
563 usbhid_submit_report(hdev, r, USB_DIR_OUT);
564 }
565 }
566
567 static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
568 {
569 int ret, i;
570 struct mt_device *td;
571 struct mt_class *mtclass = mt_classes; /* MT_CLS_DEFAULT */
572
573 for (i = 0; mt_classes[i].name ; i++) {
574 if (id->driver_data == mt_classes[i].name) {
575 mtclass = &(mt_classes[i]);
576 break;
577 }
578 }
579
580 /* This allows the driver to correctly support devices
581 * that emit events over several HID messages.
582 */
583 hdev->quirks |= HID_QUIRK_NO_INPUT_SYNC;
584
585 td = kzalloc(sizeof(struct mt_device), GFP_KERNEL);
586 if (!td) {
587 dev_err(&hdev->dev, "cannot allocate multitouch data\n");
588 return -ENOMEM;
589 }
590 td->mtclass = *mtclass;
591 td->inputmode = -1;
592 td->last_mt_collection = -1;
593 hid_set_drvdata(hdev, td);
594
595 ret = hid_parse(hdev);
596 if (ret != 0)
597 goto fail;
598
599 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
600 if (ret)
601 goto fail;
602
603 td->slots = kzalloc(td->maxcontacts * sizeof(struct mt_slot),
604 GFP_KERNEL);
605 if (!td->slots) {
606 dev_err(&hdev->dev, "cannot allocate multitouch slots\n");
607 hid_hw_stop(hdev);
608 ret = -ENOMEM;
609 goto fail;
610 }
611
612 ret = sysfs_create_group(&hdev->dev.kobj, &mt_attribute_group);
613
614 mt_set_input_mode(hdev);
615
616 return 0;
617
618 fail:
619 kfree(td);
620 return ret;
621 }
622
623 #ifdef CONFIG_PM
624 static int mt_reset_resume(struct hid_device *hdev)
625 {
626 mt_set_input_mode(hdev);
627 return 0;
628 }
629 #endif
630
631 static void mt_remove(struct hid_device *hdev)
632 {
633 struct mt_device *td = hid_get_drvdata(hdev);
634 sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group);
635 hid_hw_stop(hdev);
636 kfree(td->slots);
637 kfree(td);
638 hid_set_drvdata(hdev, NULL);
639 }
640
641 static const struct hid_device_id mt_devices[] = {
642
643 /* 3M panels */
644 { .driver_data = MT_CLS_3M,
645 HID_USB_DEVICE(USB_VENDOR_ID_3M,
646 USB_DEVICE_ID_3M1968) },
647 { .driver_data = MT_CLS_3M,
648 HID_USB_DEVICE(USB_VENDOR_ID_3M,
649 USB_DEVICE_ID_3M2256) },
650
651 /* ActionStar panels */
652 { .driver_data = MT_CLS_DEFAULT,
653 HID_USB_DEVICE(USB_VENDOR_ID_ACTIONSTAR,
654 USB_DEVICE_ID_ACTIONSTAR_1011) },
655
656 /* Cando panels */
657 { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
658 HID_USB_DEVICE(USB_VENDOR_ID_CANDO,
659 USB_DEVICE_ID_CANDO_MULTI_TOUCH) },
660 { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
661 HID_USB_DEVICE(USB_VENDOR_ID_CANDO,
662 USB_DEVICE_ID_CANDO_MULTI_TOUCH_10_1) },
663 { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
664 HID_USB_DEVICE(USB_VENDOR_ID_CANDO,
665 USB_DEVICE_ID_CANDO_MULTI_TOUCH_11_6) },
666 { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
667 HID_USB_DEVICE(USB_VENDOR_ID_CANDO,
668 USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6) },
669
670 /* Chunghwa Telecom touch panels */
671 { .driver_data = MT_CLS_DEFAULT,
672 HID_USB_DEVICE(USB_VENDOR_ID_CHUNGHWAT,
673 USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH) },
674
675 /* CVTouch panels */
676 { .driver_data = MT_CLS_DEFAULT,
677 HID_USB_DEVICE(USB_VENDOR_ID_CVTOUCH,
678 USB_DEVICE_ID_CVTOUCH_SCREEN) },
679
680 /* Cypress panel */
681 { .driver_data = MT_CLS_CYPRESS,
682 HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS,
683 USB_DEVICE_ID_CYPRESS_TRUETOUCH) },
684
685 /* eGalax devices (resistive) */
686 { .driver_data = MT_CLS_EGALAX,
687 HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
688 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH) },
689 { .driver_data = MT_CLS_EGALAX,
690 HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
691 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH3) },
692
693 /* eGalax devices (capacitive) */
694 { .driver_data = MT_CLS_EGALAX,
695 HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
696 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH1) },
697 { .driver_data = MT_CLS_EGALAX,
698 HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
699 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH2) },
700 { .driver_data = MT_CLS_EGALAX,
701 HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
702 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH4) },
703 { .driver_data = MT_CLS_EGALAX,
704 HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
705 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH5) },
706
707 /* Elo TouchSystems IntelliTouch Plus panel */
708 { .driver_data = MT_CLS_DUAL_NSMU_CONTACTID,
709 HID_USB_DEVICE(USB_VENDOR_ID_ELO,
710 USB_DEVICE_ID_ELO_TS2515) },
711
712 /* GeneralTouch panel */
713 { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
714 HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH,
715 USB_DEVICE_ID_GENERAL_TOUCH_WIN7_TWOFINGERS) },
716
717 /* GoodTouch panels */
718 { .driver_data = MT_CLS_DEFAULT,
719 HID_USB_DEVICE(USB_VENDOR_ID_GOODTOUCH,
720 USB_DEVICE_ID_GOODTOUCH_000f) },
721
722 /* Ideacom panel */
723 { .driver_data = MT_CLS_SERIAL,
724 HID_USB_DEVICE(USB_VENDOR_ID_IDEACOM,
725 USB_DEVICE_ID_IDEACOM_IDC6650) },
726
727 /* Ilitek dual touch panel */
728 { .driver_data = MT_CLS_DEFAULT,
729 HID_USB_DEVICE(USB_VENDOR_ID_ILITEK,
730 USB_DEVICE_ID_ILITEK_MULTITOUCH) },
731
732 /* IRTOUCH panels */
733 { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID,
734 HID_USB_DEVICE(USB_VENDOR_ID_IRTOUCHSYSTEMS,
735 USB_DEVICE_ID_IRTOUCH_INFRARED_USB) },
736
737 /* LG Display panels */
738 { .driver_data = MT_CLS_DEFAULT,
739 HID_USB_DEVICE(USB_VENDOR_ID_LG,
740 USB_DEVICE_ID_LG_MULTITOUCH) },
741
742 /* Lumio panels */
743 { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
744 HID_USB_DEVICE(USB_VENDOR_ID_LUMIO,
745 USB_DEVICE_ID_CRYSTALTOUCH) },
746 { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
747 HID_USB_DEVICE(USB_VENDOR_ID_LUMIO,
748 USB_DEVICE_ID_CRYSTALTOUCH_DUAL) },
749
750 /* MosArt panels */
751 { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
752 HID_USB_DEVICE(USB_VENDOR_ID_ASUS,
753 USB_DEVICE_ID_ASUS_T91MT)},
754 { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
755 HID_USB_DEVICE(USB_VENDOR_ID_ASUS,
756 USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO) },
757 { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
758 HID_USB_DEVICE(USB_VENDOR_ID_TURBOX,
759 USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART) },
760
761 /* PenMount panels */
762 { .driver_data = MT_CLS_CONFIDENCE,
763 HID_USB_DEVICE(USB_VENDOR_ID_PENMOUNT,
764 USB_DEVICE_ID_PENMOUNT_PCI) },
765
766 /* PixCir-based panels */
767 { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID,
768 HID_USB_DEVICE(USB_VENDOR_ID_HANVON,
769 USB_DEVICE_ID_HANVON_MULTITOUCH) },
770 { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID,
771 HID_USB_DEVICE(USB_VENDOR_ID_CANDO,
772 USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH) },
773
774 /* Stantum panels */
775 { .driver_data = MT_CLS_CONFIDENCE,
776 HID_USB_DEVICE(USB_VENDOR_ID_STANTUM,
777 USB_DEVICE_ID_MTP)},
778 { .driver_data = MT_CLS_CONFIDENCE,
779 HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM,
780 USB_DEVICE_ID_MTP_STM)},
781 { .driver_data = MT_CLS_CONFIDENCE,
782 HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_SITRONIX,
783 USB_DEVICE_ID_MTP_SITRONIX)},
784
785 /* Touch International panels */
786 { .driver_data = MT_CLS_DEFAULT,
787 HID_USB_DEVICE(USB_VENDOR_ID_TOUCH_INTL,
788 USB_DEVICE_ID_TOUCH_INTL_MULTI_TOUCH) },
789
790 /* Unitec panels */
791 { .driver_data = MT_CLS_DEFAULT,
792 HID_USB_DEVICE(USB_VENDOR_ID_UNITEC,
793 USB_DEVICE_ID_UNITEC_USB_TOUCH_0709) },
794 { .driver_data = MT_CLS_DEFAULT,
795 HID_USB_DEVICE(USB_VENDOR_ID_UNITEC,
796 USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19) },
797 /* XAT */
798 { .driver_data = MT_CLS_DEFAULT,
799 HID_USB_DEVICE(USB_VENDOR_ID_XAT,
800 USB_DEVICE_ID_XAT_CSR) },
801
802 { }
803 };
804 MODULE_DEVICE_TABLE(hid, mt_devices);
805
806 static const struct hid_usage_id mt_grabbed_usages[] = {
807 { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID },
808 { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}
809 };
810
811 static struct hid_driver mt_driver = {
812 .name = "hid-multitouch",
813 .id_table = mt_devices,
814 .probe = mt_probe,
815 .remove = mt_remove,
816 .input_mapping = mt_input_mapping,
817 .input_mapped = mt_input_mapped,
818 .feature_mapping = mt_feature_mapping,
819 .usage_table = mt_grabbed_usages,
820 .event = mt_event,
821 #ifdef CONFIG_PM
822 .reset_resume = mt_reset_resume,
823 #endif
824 };
825
826 static int __init mt_init(void)
827 {
828 return hid_register_driver(&mt_driver);
829 }
830
831 static void __exit mt_exit(void)
832 {
833 hid_unregister_driver(&mt_driver);
834 }
835
836 module_init(mt_init);
837 module_exit(mt_exit);