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