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