hid-multitouch.c 20 KB

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