hid-multitouch.c 21 KB

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