HID: hid-multitouch: class MT_CLS_STANTUM is redundant with MT_CLS_CONFIDENCE
[linux-2.6.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_VALID_IS_INRANGE       (1 << 4)
51 #define MT_QUIRK_VALID_IS_CONFIDENCE    (1 << 5)
52 #define MT_QUIRK_EGALAX_XYZ_FIXUP       (1 << 6)
53 #define MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE    (1 << 7)
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_device {
63         struct mt_slot curdata; /* placeholder of incoming data */
64         struct mt_class *mtclass;       /* our mt device class */
65         unsigned last_field_index;      /* last field index of the report */
66         unsigned last_slot_field;       /* the last field of a slot */
67         __s8 inputmode;         /* InputMode HID feature, -1 if non-existent */
68         __u8 num_received;      /* how many contacts we received */
69         __u8 num_expected;      /* expected last contact index */
70         __u8 maxcontacts;
71         bool curvalid;          /* is the current contact valid? */
72         struct mt_slot *slots;
73 };
74
75 struct mt_class {
76         __s32 name;     /* MT_CLS */
77         __s32 quirks;
78         __s32 sn_move;  /* Signal/noise ratio for move events */
79         __s32 sn_width; /* Signal/noise ratio for width events */
80         __s32 sn_height;        /* Signal/noise ratio for height events */
81         __s32 sn_pressure;      /* Signal/noise ratio for pressure events */
82         __u8 maxcontacts;
83 };
84
85 /* classes of device behavior */
86 #define MT_CLS_DEFAULT                          1
87 #define MT_CLS_DUAL_INRANGE_CONTACTID           2
88 #define MT_CLS_DUAL_INRANGE_CONTACTNUMBER       3
89 #define MT_CLS_CYPRESS                          4
90 #define MT_CLS_EGALAX                           5
91 #define MT_CLS_3M                               7
92 #define MT_CLS_CONFIDENCE                       8
93 #define MT_CLS_CONFIDENCE_MINUS_ONE             9
94 #define MT_CLS_DUAL_NSMU_CONTACTID              10
95
96 #define MT_DEFAULT_MAXCONTACT   10
97
98 /*
99  * these device-dependent functions determine what slot corresponds
100  * to a valid contact that was just read.
101  */
102
103 static int cypress_compute_slot(struct mt_device *td)
104 {
105         if (td->curdata.contactid != 0 || td->num_received == 0)
106                 return td->curdata.contactid;
107         else
108                 return -1;
109 }
110
111 static int find_slot_from_contactid(struct mt_device *td)
112 {
113         int i;
114         for (i = 0; i < td->maxcontacts; ++i) {
115                 if (td->slots[i].contactid == td->curdata.contactid &&
116                         td->slots[i].touch_state)
117                         return i;
118         }
119         for (i = 0; i < td->maxcontacts; ++i) {
120                 if (!td->slots[i].seen_in_this_frame &&
121                         !td->slots[i].touch_state)
122                         return i;
123         }
124         /* should not occurs. If this happens that means
125          * that the device sent more touches that it says
126          * in the report descriptor. It is ignored then. */
127         return -1;
128 }
129
130 struct mt_class mt_classes[] = {
131         { .name = MT_CLS_DEFAULT,
132                 .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP },
133         { .name = MT_CLS_DUAL_INRANGE_CONTACTID,
134                 .quirks = MT_QUIRK_VALID_IS_INRANGE |
135                         MT_QUIRK_SLOT_IS_CONTACTID,
136                 .maxcontacts = 2 },
137         { .name = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
138                 .quirks = MT_QUIRK_VALID_IS_INRANGE |
139                         MT_QUIRK_SLOT_IS_CONTACTNUMBER,
140                 .maxcontacts = 2 },
141         { .name = MT_CLS_CYPRESS,
142                 .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP |
143                         MT_QUIRK_CYPRESS,
144                 .maxcontacts = 10 },
145         { .name = MT_CLS_CONFIDENCE_MINUS_ONE,
146                 .quirks = MT_QUIRK_VALID_IS_CONFIDENCE |
147                         MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE },
148         { .name = MT_CLS_EGALAX,
149                 .quirks =  MT_QUIRK_SLOT_IS_CONTACTID |
150                         MT_QUIRK_VALID_IS_INRANGE |
151                         MT_QUIRK_EGALAX_XYZ_FIXUP,
152                 .maxcontacts = 2,
153                 .sn_move = 4096,
154                 .sn_pressure = 32,
155         },
156         { .name = MT_CLS_3M,
157                 .quirks = MT_QUIRK_VALID_IS_CONFIDENCE |
158                         MT_QUIRK_SLOT_IS_CONTACTID,
159                 .sn_move = 2048,
160                 .sn_width = 128,
161                 .sn_height = 128 },
162         { .name = MT_CLS_CONFIDENCE,
163                 .quirks = MT_QUIRK_VALID_IS_CONFIDENCE },
164         { .name = MT_CLS_DUAL_NSMU_CONTACTID,
165                 .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP |
166                         MT_QUIRK_SLOT_IS_CONTACTID,
167                 .maxcontacts = 2 },
168
169         { }
170 };
171
172 static void mt_feature_mapping(struct hid_device *hdev,
173                 struct hid_field *field, struct hid_usage *usage)
174 {
175         struct mt_device *td = hid_get_drvdata(hdev);
176
177         switch (usage->hid) {
178         case HID_DG_INPUTMODE:
179                 td->inputmode = field->report->id;
180                 break;
181         case HID_DG_CONTACTMAX:
182                 td->maxcontacts = field->value[0];
183                 if (td->mtclass->maxcontacts)
184                         /* check if the maxcontacts is given by the class */
185                         td->maxcontacts = td->mtclass->maxcontacts;
186
187                 break;
188         }
189 }
190
191 static void set_abs(struct input_dev *input, unsigned int code,
192                 struct hid_field *field, int snratio)
193 {
194         int fmin = field->logical_minimum;
195         int fmax = field->logical_maximum;
196         int fuzz = snratio ? (fmax - fmin) / snratio : 0;
197         input_set_abs_params(input, code, fmin, fmax, fuzz, 0);
198 }
199
200 static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
201                 struct hid_field *field, struct hid_usage *usage,
202                 unsigned long **bit, int *max)
203 {
204         struct mt_device *td = hid_get_drvdata(hdev);
205         struct mt_class *cls = td->mtclass;
206         __s32 quirks = cls->quirks;
207
208         switch (usage->hid & HID_USAGE_PAGE) {
209
210         case HID_UP_GENDESK:
211                 switch (usage->hid) {
212                 case HID_GD_X:
213                         if (quirks & MT_QUIRK_EGALAX_XYZ_FIXUP)
214                                 field->logical_maximum = 32760;
215                         hid_map_usage(hi, usage, bit, max,
216                                         EV_ABS, ABS_MT_POSITION_X);
217                         set_abs(hi->input, ABS_MT_POSITION_X, field,
218                                 cls->sn_move);
219                         /* touchscreen emulation */
220                         set_abs(hi->input, ABS_X, field, cls->sn_move);
221                         td->last_slot_field = usage->hid;
222                         td->last_field_index = field->index;
223                         return 1;
224                 case HID_GD_Y:
225                         if (quirks & MT_QUIRK_EGALAX_XYZ_FIXUP)
226                                 field->logical_maximum = 32760;
227                         hid_map_usage(hi, usage, bit, max,
228                                         EV_ABS, ABS_MT_POSITION_Y);
229                         set_abs(hi->input, ABS_MT_POSITION_Y, field,
230                                 cls->sn_move);
231                         /* touchscreen emulation */
232                         set_abs(hi->input, ABS_Y, field, cls->sn_move);
233                         td->last_slot_field = usage->hid;
234                         td->last_field_index = field->index;
235                         return 1;
236                 }
237                 return 0;
238
239         case HID_UP_DIGITIZER:
240                 switch (usage->hid) {
241                 case HID_DG_INRANGE:
242                         td->last_slot_field = usage->hid;
243                         td->last_field_index = field->index;
244                         return 1;
245                 case HID_DG_CONFIDENCE:
246                         td->last_slot_field = usage->hid;
247                         td->last_field_index = field->index;
248                         return 1;
249                 case HID_DG_TIPSWITCH:
250                         hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH);
251                         input_set_capability(hi->input, EV_KEY, BTN_TOUCH);
252                         td->last_slot_field = usage->hid;
253                         td->last_field_index = field->index;
254                         return 1;
255                 case HID_DG_CONTACTID:
256                         input_mt_init_slots(hi->input, td->maxcontacts);
257                         td->last_slot_field = usage->hid;
258                         td->last_field_index = field->index;
259                         return 1;
260                 case HID_DG_WIDTH:
261                         hid_map_usage(hi, usage, bit, max,
262                                         EV_ABS, ABS_MT_TOUCH_MAJOR);
263                         set_abs(hi->input, ABS_MT_TOUCH_MAJOR, field,
264                                 cls->sn_width);
265                         td->last_slot_field = usage->hid;
266                         td->last_field_index = field->index;
267                         return 1;
268                 case HID_DG_HEIGHT:
269                         hid_map_usage(hi, usage, bit, max,
270                                         EV_ABS, ABS_MT_TOUCH_MINOR);
271                         set_abs(hi->input, ABS_MT_TOUCH_MINOR, field,
272                                 cls->sn_height);
273                         input_set_abs_params(hi->input,
274                                         ABS_MT_ORIENTATION, 0, 1, 0, 0);
275                         td->last_slot_field = usage->hid;
276                         td->last_field_index = field->index;
277                         return 1;
278                 case HID_DG_TIPPRESSURE:
279                         if (quirks & MT_QUIRK_EGALAX_XYZ_FIXUP)
280                                 field->logical_minimum = 0;
281                         hid_map_usage(hi, usage, bit, max,
282                                         EV_ABS, ABS_MT_PRESSURE);
283                         set_abs(hi->input, ABS_MT_PRESSURE, field,
284                                 cls->sn_pressure);
285                         /* touchscreen emulation */
286                         set_abs(hi->input, ABS_PRESSURE, field,
287                                 cls->sn_pressure);
288                         td->last_slot_field = usage->hid;
289                         td->last_field_index = field->index;
290                         return 1;
291                 case HID_DG_CONTACTCOUNT:
292                         td->last_field_index = field->index;
293                         return 1;
294                 case HID_DG_CONTACTMAX:
295                         /* we don't set td->last_slot_field as contactcount and
296                          * contact max are global to the report */
297                         td->last_field_index = field->index;
298                         return -1;
299                 }
300                 /* let hid-input decide for the others */
301                 return 0;
302
303         case 0xff000000:
304                 /* we do not want to map these: no input-oriented meaning */
305                 return -1;
306         }
307
308         return 0;
309 }
310
311 static int mt_input_mapped(struct hid_device *hdev, struct hid_input *hi,
312                 struct hid_field *field, struct hid_usage *usage,
313                 unsigned long **bit, int *max)
314 {
315         if (usage->type == EV_KEY || usage->type == EV_ABS)
316                 set_bit(usage->type, hi->input->evbit);
317
318         return -1;
319 }
320
321 static int mt_compute_slot(struct mt_device *td)
322 {
323         __s32 quirks = td->mtclass->quirks;
324
325         if (quirks & MT_QUIRK_SLOT_IS_CONTACTID)
326                 return td->curdata.contactid;
327
328         if (quirks & MT_QUIRK_CYPRESS)
329                 return cypress_compute_slot(td);
330
331         if (quirks & MT_QUIRK_SLOT_IS_CONTACTNUMBER)
332                 return td->num_received;
333
334         if (quirks & MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE)
335                 return td->curdata.contactid - 1;
336
337         return find_slot_from_contactid(td);
338 }
339
340 /*
341  * this function is called when a whole contact has been processed,
342  * so that it can assign it to a slot and store the data there
343  */
344 static void mt_complete_slot(struct mt_device *td)
345 {
346         td->curdata.seen_in_this_frame = true;
347         if (td->curvalid) {
348                 int slotnum = mt_compute_slot(td);
349
350                 if (slotnum >= 0 && slotnum < td->maxcontacts)
351                         td->slots[slotnum] = td->curdata;
352         }
353         td->num_received++;
354 }
355
356
357 /*
358  * this function is called when a whole packet has been received and processed,
359  * so that it can decide what to send to the input layer.
360  */
361 static void mt_emit_event(struct mt_device *td, struct input_dev *input)
362 {
363         int i;
364
365         for (i = 0; i < td->maxcontacts; ++i) {
366                 struct mt_slot *s = &(td->slots[i]);
367                 if ((td->mtclass->quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) &&
368                         !s->seen_in_this_frame) {
369                         s->touch_state = false;
370                 }
371
372                 input_mt_slot(input, i);
373                 input_mt_report_slot_state(input, MT_TOOL_FINGER,
374                         s->touch_state);
375                 if (s->touch_state) {
376                         /* this finger is on the screen */
377                         int wide = (s->w > s->h);
378                         /* divided by two to match visual scale of touch */
379                         int major = max(s->w, s->h) >> 1;
380                         int minor = min(s->w, s->h) >> 1;
381
382                         input_event(input, EV_ABS, ABS_MT_POSITION_X, s->x);
383                         input_event(input, EV_ABS, ABS_MT_POSITION_Y, s->y);
384                         input_event(input, EV_ABS, ABS_MT_ORIENTATION, wide);
385                         input_event(input, EV_ABS, ABS_MT_PRESSURE, s->p);
386                         input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, major);
387                         input_event(input, EV_ABS, ABS_MT_TOUCH_MINOR, minor);
388                 }
389                 s->seen_in_this_frame = false;
390
391         }
392
393         input_mt_report_pointer_emulation(input, true);
394         input_sync(input);
395         td->num_received = 0;
396 }
397
398
399
400 static int mt_event(struct hid_device *hid, struct hid_field *field,
401                                 struct hid_usage *usage, __s32 value)
402 {
403         struct mt_device *td = hid_get_drvdata(hid);
404         __s32 quirks = td->mtclass->quirks;
405
406         if (hid->claimed & HID_CLAIMED_INPUT && td->slots) {
407                 switch (usage->hid) {
408                 case HID_DG_INRANGE:
409                         if (quirks & MT_QUIRK_VALID_IS_INRANGE)
410                                 td->curvalid = value;
411                         break;
412                 case HID_DG_TIPSWITCH:
413                         if (quirks & MT_QUIRK_NOT_SEEN_MEANS_UP)
414                                 td->curvalid = value;
415                         td->curdata.touch_state = value;
416                         break;
417                 case HID_DG_CONFIDENCE:
418                         if (quirks & MT_QUIRK_VALID_IS_CONFIDENCE)
419                                 td->curvalid = value;
420                         break;
421                 case HID_DG_CONTACTID:
422                         td->curdata.contactid = value;
423                         break;
424                 case HID_DG_TIPPRESSURE:
425                         td->curdata.p = value;
426                         break;
427                 case HID_GD_X:
428                         td->curdata.x = value;
429                         break;
430                 case HID_GD_Y:
431                         td->curdata.y = value;
432                         break;
433                 case HID_DG_WIDTH:
434                         td->curdata.w = value;
435                         break;
436                 case HID_DG_HEIGHT:
437                         td->curdata.h = value;
438                         break;
439                 case HID_DG_CONTACTCOUNT:
440                         /*
441                          * Includes multi-packet support where subsequent
442                          * packets are sent with zero contactcount.
443                          */
444                         if (value)
445                                 td->num_expected = value;
446                         break;
447
448                 default:
449                         /* fallback to the generic hidinput handling */
450                         return 0;
451                 }
452
453                 if (usage->hid == td->last_slot_field) {
454                         mt_complete_slot(td);
455                 }
456
457                 if (field->index == td->last_field_index
458                         && td->num_received >= td->num_expected)
459                         mt_emit_event(td, field->hidinput->input);
460
461         }
462
463         /* we have handled the hidinput part, now remains hiddev */
464         if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event)
465                 hid->hiddev_hid_event(hid, field, usage, value);
466
467         return 1;
468 }
469
470 static void mt_set_input_mode(struct hid_device *hdev)
471 {
472         struct mt_device *td = hid_get_drvdata(hdev);
473         struct hid_report *r;
474         struct hid_report_enum *re;
475
476         if (td->inputmode < 0)
477                 return;
478
479         re = &(hdev->report_enum[HID_FEATURE_REPORT]);
480         r = re->report_id_hash[td->inputmode];
481         if (r) {
482                 r->field[0]->value[0] = 0x02;
483                 usbhid_submit_report(hdev, r, USB_DIR_OUT);
484         }
485 }
486
487 static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
488 {
489         int ret, i;
490         struct mt_device *td;
491         struct mt_class *mtclass = mt_classes; /* MT_CLS_DEFAULT */
492
493         for (i = 0; mt_classes[i].name ; i++) {
494                 if (id->driver_data == mt_classes[i].name) {
495                         mtclass = &(mt_classes[i]);
496                         break;
497                 }
498         }
499
500         /* This allows the driver to correctly support devices
501          * that emit events over several HID messages.
502          */
503         hdev->quirks |= HID_QUIRK_NO_INPUT_SYNC;
504
505         td = kzalloc(sizeof(struct mt_device), GFP_KERNEL);
506         if (!td) {
507                 dev_err(&hdev->dev, "cannot allocate multitouch data\n");
508                 return -ENOMEM;
509         }
510         td->mtclass = mtclass;
511         td->inputmode = -1;
512         hid_set_drvdata(hdev, td);
513
514         ret = hid_parse(hdev);
515         if (ret != 0)
516                 goto fail;
517
518         ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
519         if (ret)
520                 goto fail;
521
522         if (!td->maxcontacts)
523                 td->maxcontacts = MT_DEFAULT_MAXCONTACT;
524
525         td->slots = kzalloc(td->maxcontacts * sizeof(struct mt_slot),
526                                 GFP_KERNEL);
527         if (!td->slots) {
528                 dev_err(&hdev->dev, "cannot allocate multitouch slots\n");
529                 hid_hw_stop(hdev);
530                 ret = -ENOMEM;
531                 goto fail;
532         }
533
534         mt_set_input_mode(hdev);
535
536         return 0;
537
538 fail:
539         kfree(td);
540         return ret;
541 }
542
543 #ifdef CONFIG_PM
544 static int mt_reset_resume(struct hid_device *hdev)
545 {
546         mt_set_input_mode(hdev);
547         return 0;
548 }
549 #endif
550
551 static void mt_remove(struct hid_device *hdev)
552 {
553         struct mt_device *td = hid_get_drvdata(hdev);
554         hid_hw_stop(hdev);
555         kfree(td->slots);
556         kfree(td);
557         hid_set_drvdata(hdev, NULL);
558 }
559
560 static const struct hid_device_id mt_devices[] = {
561
562         /* 3M panels */
563         { .driver_data = MT_CLS_3M,
564                 HID_USB_DEVICE(USB_VENDOR_ID_3M,
565                         USB_DEVICE_ID_3M1968) },
566         { .driver_data = MT_CLS_3M,
567                 HID_USB_DEVICE(USB_VENDOR_ID_3M,
568                         USB_DEVICE_ID_3M2256) },
569
570         /* ActionStar panels */
571         { .driver_data = MT_CLS_DEFAULT,
572                 HID_USB_DEVICE(USB_VENDOR_ID_ACTIONSTAR,
573                         USB_DEVICE_ID_ACTIONSTAR_1011) },
574
575         /* Cando panels */
576         { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
577                 HID_USB_DEVICE(USB_VENDOR_ID_CANDO,
578                         USB_DEVICE_ID_CANDO_MULTI_TOUCH) },
579         { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
580                 HID_USB_DEVICE(USB_VENDOR_ID_CANDO,
581                         USB_DEVICE_ID_CANDO_MULTI_TOUCH_10_1) },
582         { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
583                 HID_USB_DEVICE(USB_VENDOR_ID_CANDO,
584                         USB_DEVICE_ID_CANDO_MULTI_TOUCH_11_6) },
585         { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
586                 HID_USB_DEVICE(USB_VENDOR_ID_CANDO,
587                         USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6) },
588
589         /* CVTouch panels */
590         { .driver_data = MT_CLS_DEFAULT,
591                 HID_USB_DEVICE(USB_VENDOR_ID_CVTOUCH,
592                         USB_DEVICE_ID_CVTOUCH_SCREEN) },
593
594         /* Cypress panel */
595         { .driver_data = MT_CLS_CYPRESS,
596                 HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS,
597                         USB_DEVICE_ID_CYPRESS_TRUETOUCH) },
598
599         /* Elo TouchSystems IntelliTouch Plus panel */
600         { .driver_data = MT_CLS_DUAL_NSMU_CONTACTID,
601                 HID_USB_DEVICE(USB_VENDOR_ID_ELO,
602                         USB_DEVICE_ID_ELO_TS2515) },
603
604         /* GeneralTouch panel */
605         { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
606                 HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH,
607                         USB_DEVICE_ID_GENERAL_TOUCH_WIN7_TWOFINGERS) },
608
609         /* GoodTouch panels */
610         { .driver_data = MT_CLS_DEFAULT,
611                 HID_USB_DEVICE(USB_VENDOR_ID_GOODTOUCH,
612                         USB_DEVICE_ID_GOODTOUCH_000f) },
613
614         /* Ilitek dual touch panel */
615         {  .driver_data = MT_CLS_DEFAULT,
616                 HID_USB_DEVICE(USB_VENDOR_ID_ILITEK,
617                         USB_DEVICE_ID_ILITEK_MULTITOUCH) },
618
619         /* IRTOUCH panels */
620         { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID,
621                 HID_USB_DEVICE(USB_VENDOR_ID_IRTOUCHSYSTEMS,
622                         USB_DEVICE_ID_IRTOUCH_INFRARED_USB) },
623
624         /* Lumio panels */
625         { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
626                 HID_USB_DEVICE(USB_VENDOR_ID_LUMIO,
627                         USB_DEVICE_ID_CRYSTALTOUCH) },
628
629         /* MosArt panels */
630         { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
631                 HID_USB_DEVICE(USB_VENDOR_ID_ASUS,
632                         USB_DEVICE_ID_ASUS_T91MT)},
633         { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
634                 HID_USB_DEVICE(USB_VENDOR_ID_ASUS,
635                         USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO) },
636         { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
637                 HID_USB_DEVICE(USB_VENDOR_ID_TURBOX,
638                         USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART) },
639
640         /* PenMount panels */
641         { .driver_data = MT_CLS_CONFIDENCE,
642                 HID_USB_DEVICE(USB_VENDOR_ID_PENMOUNT,
643                         USB_DEVICE_ID_PENMOUNT_PCI) },
644
645         /* PixCir-based panels */
646         { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID,
647                 HID_USB_DEVICE(USB_VENDOR_ID_HANVON,
648                         USB_DEVICE_ID_HANVON_MULTITOUCH) },
649         { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID,
650                 HID_USB_DEVICE(USB_VENDOR_ID_CANDO,
651                         USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH) },
652
653         /* Resistive eGalax devices */
654         {  .driver_data = MT_CLS_EGALAX,
655                 HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
656                         USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH) },
657         {  .driver_data = MT_CLS_EGALAX,
658                 HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
659                         USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH3) },
660
661         /* Capacitive eGalax devices */
662         {  .driver_data = MT_CLS_EGALAX,
663                 HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
664                         USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH1) },
665         {  .driver_data = MT_CLS_EGALAX,
666                 HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
667                         USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH2) },
668         {  .driver_data = MT_CLS_EGALAX,
669                 HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
670                         USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH4) },
671
672         /* Stantum panels */
673         { .driver_data = MT_CLS_CONFIDENCE,
674                 HID_USB_DEVICE(USB_VENDOR_ID_STANTUM,
675                         USB_DEVICE_ID_MTP)},
676         { .driver_data = MT_CLS_CONFIDENCE,
677                 HID_USB_DEVICE(USB_VENDOR_ID_STANTUM,
678                         USB_DEVICE_ID_MTP_STM)},
679         { .driver_data = MT_CLS_CONFIDENCE,
680                 HID_USB_DEVICE(USB_VENDOR_ID_STANTUM,
681                         USB_DEVICE_ID_MTP_SITRONIX)},
682
683         /* Touch International panels */
684         { .driver_data = MT_CLS_DEFAULT,
685                 HID_USB_DEVICE(USB_VENDOR_ID_TOUCH_INTL,
686                         USB_DEVICE_ID_TOUCH_INTL_MULTI_TOUCH) },
687
688         /* Unitec panels */
689         { .driver_data = MT_CLS_DEFAULT,
690                 HID_USB_DEVICE(USB_VENDOR_ID_UNITEC,
691                         USB_DEVICE_ID_UNITEC_USB_TOUCH_0709) },
692         { .driver_data = MT_CLS_DEFAULT,
693                 HID_USB_DEVICE(USB_VENDOR_ID_UNITEC,
694                         USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19) },
695
696         { }
697 };
698 MODULE_DEVICE_TABLE(hid, mt_devices);
699
700 static const struct hid_usage_id mt_grabbed_usages[] = {
701         { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID },
702         { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}
703 };
704
705 static struct hid_driver mt_driver = {
706         .name = "hid-multitouch",
707         .id_table = mt_devices,
708         .probe = mt_probe,
709         .remove = mt_remove,
710         .input_mapping = mt_input_mapping,
711         .input_mapped = mt_input_mapped,
712         .feature_mapping = mt_feature_mapping,
713         .usage_table = mt_grabbed_usages,
714         .event = mt_event,
715 #ifdef CONFIG_PM
716         .reset_resume = mt_reset_resume,
717 #endif
718 };
719
720 static int __init mt_init(void)
721 {
722         return hid_register_driver(&mt_driver);
723 }
724
725 static void __exit mt_exit(void)
726 {
727         hid_unregister_driver(&mt_driver);
728 }
729
730 module_init(mt_init);
731 module_exit(mt_exit);