hid-multitouch.c 16 KB

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