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