hid-multitouch.c 19 KB

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