hid-multitouch.c 18 KB

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