hid-multitouch.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106
  1. /*
  2. * HID driver for multitouch panels
  3. *
  4. * Copyright (c) 2010-2012 Stephane Chatty <chatty@enac.fr>
  5. * Copyright (c) 2010-2012 Benjamin Tissoires <benjamin.tissoires@gmail.com>
  6. * Copyright (c) 2010-2012 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_ALWAYS_VALID (1 << 4)
  45. #define MT_QUIRK_VALID_IS_INRANGE (1 << 5)
  46. #define MT_QUIRK_VALID_IS_CONFIDENCE (1 << 6)
  47. #define MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE (1 << 8)
  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_class {
  55. __s32 name; /* MT_CLS */
  56. __s32 quirks;
  57. __s32 sn_move; /* Signal/noise ratio for move events */
  58. __s32 sn_width; /* Signal/noise ratio for width events */
  59. __s32 sn_height; /* Signal/noise ratio for height events */
  60. __s32 sn_pressure; /* Signal/noise ratio for pressure events */
  61. __u8 maxcontacts;
  62. bool is_indirect; /* true for touchpads */
  63. };
  64. struct mt_fields {
  65. unsigned usages[HID_MAX_FIELDS];
  66. unsigned int length;
  67. };
  68. struct mt_device {
  69. struct mt_slot curdata; /* placeholder of incoming data */
  70. struct mt_class mtclass; /* our mt device class */
  71. struct mt_fields *fields; /* temporary placeholder for storing the
  72. multitouch fields */
  73. unsigned last_field_index; /* last field index of the report */
  74. unsigned last_slot_field; /* the last field of a slot */
  75. __s16 inputmode; /* InputMode HID feature, -1 if non-existent */
  76. __s16 maxcontact_report_id; /* Maximum Contact Number HID feature,
  77. -1 if non-existent */
  78. __u8 num_received; /* how many contacts we received */
  79. __u8 num_expected; /* expected last contact index */
  80. __u8 maxcontacts;
  81. __u8 touches_by_report; /* how many touches are present in one report:
  82. * 1 means we should use a serial protocol
  83. * > 1 means hybrid (multitouch) protocol */
  84. bool curvalid; /* is the current contact valid? */
  85. struct mt_slot *slots;
  86. };
  87. /* classes of device behavior */
  88. #define MT_CLS_DEFAULT 0x0001
  89. #define MT_CLS_SERIAL 0x0002
  90. #define MT_CLS_CONFIDENCE 0x0003
  91. #define MT_CLS_CONFIDENCE_CONTACT_ID 0x0004
  92. #define MT_CLS_CONFIDENCE_MINUS_ONE 0x0005
  93. #define MT_CLS_DUAL_INRANGE_CONTACTID 0x0006
  94. #define MT_CLS_DUAL_INRANGE_CONTACTNUMBER 0x0007
  95. #define MT_CLS_DUAL_NSMU_CONTACTID 0x0008
  96. #define MT_CLS_INRANGE_CONTACTNUMBER 0x0009
  97. /* vendor specific classes */
  98. #define MT_CLS_3M 0x0101
  99. #define MT_CLS_CYPRESS 0x0102
  100. #define MT_CLS_EGALAX 0x0103
  101. #define MT_CLS_EGALAX_SERIAL 0x0104
  102. #define MT_CLS_TOPSEED 0x0105
  103. #define MT_CLS_PANASONIC 0x0106
  104. #define MT_DEFAULT_MAXCONTACT 10
  105. #define MT_USB_DEVICE(v, p) HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH, v, p)
  106. #define MT_BT_DEVICE(v, p) HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_MULTITOUCH, v, p)
  107. /*
  108. * these device-dependent functions determine what slot corresponds
  109. * to a valid contact that was just read.
  110. */
  111. static int cypress_compute_slot(struct mt_device *td)
  112. {
  113. if (td->curdata.contactid != 0 || td->num_received == 0)
  114. return td->curdata.contactid;
  115. else
  116. return -1;
  117. }
  118. static int find_slot_from_contactid(struct mt_device *td)
  119. {
  120. int i;
  121. for (i = 0; i < td->maxcontacts; ++i) {
  122. if (td->slots[i].contactid == td->curdata.contactid &&
  123. td->slots[i].touch_state)
  124. return i;
  125. }
  126. for (i = 0; i < td->maxcontacts; ++i) {
  127. if (!td->slots[i].seen_in_this_frame &&
  128. !td->slots[i].touch_state)
  129. return i;
  130. }
  131. /* should not occurs. If this happens that means
  132. * that the device sent more touches that it says
  133. * in the report descriptor. It is ignored then. */
  134. return -1;
  135. }
  136. static struct mt_class mt_classes[] = {
  137. { .name = MT_CLS_DEFAULT,
  138. .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP },
  139. { .name = MT_CLS_SERIAL,
  140. .quirks = MT_QUIRK_ALWAYS_VALID},
  141. { .name = MT_CLS_CONFIDENCE,
  142. .quirks = MT_QUIRK_VALID_IS_CONFIDENCE },
  143. { .name = MT_CLS_CONFIDENCE_CONTACT_ID,
  144. .quirks = MT_QUIRK_VALID_IS_CONFIDENCE |
  145. MT_QUIRK_SLOT_IS_CONTACTID },
  146. { .name = MT_CLS_CONFIDENCE_MINUS_ONE,
  147. .quirks = MT_QUIRK_VALID_IS_CONFIDENCE |
  148. MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE },
  149. { .name = MT_CLS_DUAL_INRANGE_CONTACTID,
  150. .quirks = MT_QUIRK_VALID_IS_INRANGE |
  151. MT_QUIRK_SLOT_IS_CONTACTID,
  152. .maxcontacts = 2 },
  153. { .name = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
  154. .quirks = MT_QUIRK_VALID_IS_INRANGE |
  155. MT_QUIRK_SLOT_IS_CONTACTNUMBER,
  156. .maxcontacts = 2 },
  157. { .name = MT_CLS_DUAL_NSMU_CONTACTID,
  158. .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP |
  159. MT_QUIRK_SLOT_IS_CONTACTID,
  160. .maxcontacts = 2 },
  161. { .name = MT_CLS_INRANGE_CONTACTNUMBER,
  162. .quirks = MT_QUIRK_VALID_IS_INRANGE |
  163. MT_QUIRK_SLOT_IS_CONTACTNUMBER },
  164. /*
  165. * vendor specific classes
  166. */
  167. { .name = MT_CLS_3M,
  168. .quirks = MT_QUIRK_VALID_IS_CONFIDENCE |
  169. MT_QUIRK_SLOT_IS_CONTACTID,
  170. .sn_move = 2048,
  171. .sn_width = 128,
  172. .sn_height = 128 },
  173. { .name = MT_CLS_CYPRESS,
  174. .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP |
  175. MT_QUIRK_CYPRESS,
  176. .maxcontacts = 10 },
  177. { .name = MT_CLS_EGALAX,
  178. .quirks = MT_QUIRK_SLOT_IS_CONTACTID |
  179. MT_QUIRK_VALID_IS_INRANGE,
  180. .sn_move = 4096,
  181. .sn_pressure = 32,
  182. },
  183. { .name = MT_CLS_EGALAX_SERIAL,
  184. .quirks = MT_QUIRK_SLOT_IS_CONTACTID |
  185. MT_QUIRK_ALWAYS_VALID,
  186. .sn_move = 4096,
  187. .sn_pressure = 32,
  188. },
  189. { .name = MT_CLS_TOPSEED,
  190. .quirks = MT_QUIRK_ALWAYS_VALID,
  191. .is_indirect = true,
  192. .maxcontacts = 2,
  193. },
  194. { .name = MT_CLS_PANASONIC,
  195. .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP,
  196. .maxcontacts = 4 },
  197. { }
  198. };
  199. static ssize_t mt_show_quirks(struct device *dev,
  200. struct device_attribute *attr,
  201. char *buf)
  202. {
  203. struct hid_device *hdev = container_of(dev, struct hid_device, dev);
  204. struct mt_device *td = hid_get_drvdata(hdev);
  205. return sprintf(buf, "%u\n", td->mtclass.quirks);
  206. }
  207. static ssize_t mt_set_quirks(struct device *dev,
  208. struct device_attribute *attr,
  209. const char *buf, size_t count)
  210. {
  211. struct hid_device *hdev = container_of(dev, struct hid_device, dev);
  212. struct mt_device *td = hid_get_drvdata(hdev);
  213. unsigned long val;
  214. if (kstrtoul(buf, 0, &val))
  215. return -EINVAL;
  216. td->mtclass.quirks = val;
  217. return count;
  218. }
  219. static DEVICE_ATTR(quirks, S_IWUSR | S_IRUGO, mt_show_quirks, mt_set_quirks);
  220. static struct attribute *sysfs_attrs[] = {
  221. &dev_attr_quirks.attr,
  222. NULL
  223. };
  224. static struct attribute_group mt_attribute_group = {
  225. .attrs = sysfs_attrs
  226. };
  227. static void mt_feature_mapping(struct hid_device *hdev,
  228. struct hid_field *field, struct hid_usage *usage)
  229. {
  230. struct mt_device *td = hid_get_drvdata(hdev);
  231. switch (usage->hid) {
  232. case HID_DG_INPUTMODE:
  233. td->inputmode = field->report->id;
  234. break;
  235. case HID_DG_CONTACTMAX:
  236. td->maxcontact_report_id = field->report->id;
  237. td->maxcontacts = field->value[0];
  238. if (td->mtclass.maxcontacts)
  239. /* check if the maxcontacts is given by the class */
  240. td->maxcontacts = td->mtclass.maxcontacts;
  241. break;
  242. }
  243. }
  244. static void set_abs(struct input_dev *input, unsigned int code,
  245. struct hid_field *field, int snratio)
  246. {
  247. int fmin = field->logical_minimum;
  248. int fmax = field->logical_maximum;
  249. int fuzz = snratio ? (fmax - fmin) / snratio : 0;
  250. input_set_abs_params(input, code, fmin, fmax, fuzz, 0);
  251. }
  252. static void mt_store_field(struct hid_usage *usage, struct mt_device *td,
  253. struct hid_input *hi)
  254. {
  255. struct mt_fields *f = td->fields;
  256. if (f->length >= HID_MAX_FIELDS)
  257. return;
  258. f->usages[f->length++] = usage->hid;
  259. }
  260. static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
  261. struct hid_field *field, struct hid_usage *usage,
  262. unsigned long **bit, int *max)
  263. {
  264. struct mt_device *td = hid_get_drvdata(hdev);
  265. struct mt_class *cls = &td->mtclass;
  266. int code;
  267. /* Only map fields from TouchScreen or TouchPad collections.
  268. * We need to ignore fields that belong to other collections
  269. * such as Mouse that might have the same GenericDesktop usages. */
  270. if (field->application == HID_DG_TOUCHSCREEN)
  271. set_bit(INPUT_PROP_DIRECT, hi->input->propbit);
  272. else if (field->application != HID_DG_TOUCHPAD)
  273. return 0;
  274. /* In case of an indirect device (touchpad), we need to add
  275. * specific BTN_TOOL_* to be handled by the synaptics xorg
  276. * driver.
  277. * We also consider that touchscreens providing buttons are touchpads.
  278. */
  279. if (field->application == HID_DG_TOUCHPAD ||
  280. (usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON ||
  281. cls->is_indirect) {
  282. set_bit(INPUT_PROP_POINTER, hi->input->propbit);
  283. set_bit(BTN_TOOL_FINGER, hi->input->keybit);
  284. set_bit(BTN_TOOL_DOUBLETAP, hi->input->keybit);
  285. set_bit(BTN_TOOL_TRIPLETAP, hi->input->keybit);
  286. set_bit(BTN_TOOL_QUADTAP, hi->input->keybit);
  287. }
  288. /* eGalax devices provide a Digitizer.Stylus input which overrides
  289. * the correct Digitizers.Finger X/Y ranges.
  290. * Let's just ignore this input. */
  291. if (field->physical == HID_DG_STYLUS)
  292. return -1;
  293. /* Only map fields from TouchScreen or TouchPad collections.
  294. * We need to ignore fields that belong to other collections
  295. * such as Mouse that might have the same GenericDesktop usages. */
  296. if (field->application == HID_DG_TOUCHSCREEN)
  297. set_bit(INPUT_PROP_DIRECT, hi->input->propbit);
  298. else if (field->application == HID_DG_TOUCHPAD)
  299. set_bit(INPUT_PROP_POINTER, hi->input->propbit);
  300. else
  301. return 0;
  302. switch (usage->hid & HID_USAGE_PAGE) {
  303. case HID_UP_GENDESK:
  304. switch (usage->hid) {
  305. case HID_GD_X:
  306. hid_map_usage(hi, usage, bit, max,
  307. EV_ABS, ABS_MT_POSITION_X);
  308. set_abs(hi->input, ABS_MT_POSITION_X, field,
  309. cls->sn_move);
  310. /* touchscreen emulation */
  311. set_abs(hi->input, ABS_X, field, cls->sn_move);
  312. mt_store_field(usage, td, hi);
  313. td->last_field_index = field->index;
  314. return 1;
  315. case HID_GD_Y:
  316. hid_map_usage(hi, usage, bit, max,
  317. EV_ABS, ABS_MT_POSITION_Y);
  318. set_abs(hi->input, ABS_MT_POSITION_Y, field,
  319. cls->sn_move);
  320. /* touchscreen emulation */
  321. set_abs(hi->input, ABS_Y, field, cls->sn_move);
  322. mt_store_field(usage, td, hi);
  323. td->last_field_index = field->index;
  324. return 1;
  325. }
  326. return 0;
  327. case HID_UP_DIGITIZER:
  328. switch (usage->hid) {
  329. case HID_DG_INRANGE:
  330. mt_store_field(usage, td, hi);
  331. td->last_field_index = field->index;
  332. return 1;
  333. case HID_DG_CONFIDENCE:
  334. mt_store_field(usage, td, hi);
  335. td->last_field_index = field->index;
  336. return 1;
  337. case HID_DG_TIPSWITCH:
  338. hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH);
  339. input_set_capability(hi->input, EV_KEY, BTN_TOUCH);
  340. mt_store_field(usage, td, hi);
  341. td->last_field_index = field->index;
  342. return 1;
  343. case HID_DG_CONTACTID:
  344. if (!td->maxcontacts)
  345. td->maxcontacts = MT_DEFAULT_MAXCONTACT;
  346. input_mt_init_slots(hi->input, td->maxcontacts);
  347. mt_store_field(usage, td, hi);
  348. td->last_field_index = field->index;
  349. td->touches_by_report++;
  350. return 1;
  351. case HID_DG_WIDTH:
  352. hid_map_usage(hi, usage, bit, max,
  353. EV_ABS, ABS_MT_TOUCH_MAJOR);
  354. set_abs(hi->input, ABS_MT_TOUCH_MAJOR, field,
  355. cls->sn_width);
  356. mt_store_field(usage, td, hi);
  357. td->last_field_index = field->index;
  358. return 1;
  359. case HID_DG_HEIGHT:
  360. hid_map_usage(hi, usage, bit, max,
  361. EV_ABS, ABS_MT_TOUCH_MINOR);
  362. set_abs(hi->input, ABS_MT_TOUCH_MINOR, field,
  363. cls->sn_height);
  364. input_set_abs_params(hi->input,
  365. ABS_MT_ORIENTATION, 0, 1, 0, 0);
  366. mt_store_field(usage, td, hi);
  367. td->last_field_index = field->index;
  368. return 1;
  369. case HID_DG_TIPPRESSURE:
  370. hid_map_usage(hi, usage, bit, max,
  371. EV_ABS, ABS_MT_PRESSURE);
  372. set_abs(hi->input, ABS_MT_PRESSURE, field,
  373. cls->sn_pressure);
  374. /* touchscreen emulation */
  375. set_abs(hi->input, ABS_PRESSURE, field,
  376. cls->sn_pressure);
  377. mt_store_field(usage, td, hi);
  378. td->last_field_index = field->index;
  379. return 1;
  380. case HID_DG_CONTACTCOUNT:
  381. td->last_field_index = field->index;
  382. return 1;
  383. case HID_DG_CONTACTMAX:
  384. /* we don't set td->last_slot_field as contactcount and
  385. * contact max are global to the report */
  386. td->last_field_index = field->index;
  387. return -1;
  388. }
  389. case HID_DG_TOUCH:
  390. /* Legacy devices use TIPSWITCH and not TOUCH.
  391. * Let's just ignore this field. */
  392. return -1;
  393. /* let hid-input decide for the others */
  394. return 0;
  395. case HID_UP_BUTTON:
  396. code = BTN_MOUSE + ((usage->hid - 1) & HID_USAGE);
  397. hid_map_usage(hi, usage, bit, max, EV_KEY, code);
  398. if (!*bit)
  399. return -1;
  400. input_set_capability(hi->input, EV_KEY, code);
  401. return 1;
  402. case 0xff000000:
  403. /* we do not want to map these: no input-oriented meaning */
  404. return -1;
  405. }
  406. return 0;
  407. }
  408. static int mt_input_mapped(struct hid_device *hdev, struct hid_input *hi,
  409. struct hid_field *field, struct hid_usage *usage,
  410. unsigned long **bit, int *max)
  411. {
  412. if (usage->type == EV_KEY || usage->type == EV_ABS)
  413. set_bit(usage->type, hi->input->evbit);
  414. return -1;
  415. }
  416. static int mt_compute_slot(struct mt_device *td)
  417. {
  418. __s32 quirks = td->mtclass.quirks;
  419. if (quirks & MT_QUIRK_SLOT_IS_CONTACTID)
  420. return td->curdata.contactid;
  421. if (quirks & MT_QUIRK_CYPRESS)
  422. return cypress_compute_slot(td);
  423. if (quirks & MT_QUIRK_SLOT_IS_CONTACTNUMBER)
  424. return td->num_received;
  425. if (quirks & MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE)
  426. return td->curdata.contactid - 1;
  427. return find_slot_from_contactid(td);
  428. }
  429. /*
  430. * this function is called when a whole contact has been processed,
  431. * so that it can assign it to a slot and store the data there
  432. */
  433. static void mt_complete_slot(struct mt_device *td)
  434. {
  435. td->curdata.seen_in_this_frame = true;
  436. if (td->curvalid) {
  437. int slotnum = mt_compute_slot(td);
  438. if (slotnum >= 0 && slotnum < td->maxcontacts)
  439. td->slots[slotnum] = td->curdata;
  440. }
  441. td->num_received++;
  442. }
  443. /*
  444. * this function is called when a whole packet has been received and processed,
  445. * so that it can decide what to send to the input layer.
  446. */
  447. static void mt_emit_event(struct mt_device *td, struct input_dev *input)
  448. {
  449. int i;
  450. for (i = 0; i < td->maxcontacts; ++i) {
  451. struct mt_slot *s = &(td->slots[i]);
  452. if ((td->mtclass.quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) &&
  453. !s->seen_in_this_frame) {
  454. s->touch_state = false;
  455. }
  456. input_mt_slot(input, i);
  457. input_mt_report_slot_state(input, MT_TOOL_FINGER,
  458. s->touch_state);
  459. if (s->touch_state) {
  460. /* this finger is on the screen */
  461. int wide = (s->w > s->h);
  462. /* divided by two to match visual scale of touch */
  463. int major = max(s->w, s->h) >> 1;
  464. int minor = min(s->w, s->h) >> 1;
  465. input_event(input, EV_ABS, ABS_MT_POSITION_X, s->x);
  466. input_event(input, EV_ABS, ABS_MT_POSITION_Y, s->y);
  467. input_event(input, EV_ABS, ABS_MT_ORIENTATION, wide);
  468. input_event(input, EV_ABS, ABS_MT_PRESSURE, s->p);
  469. input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, major);
  470. input_event(input, EV_ABS, ABS_MT_TOUCH_MINOR, minor);
  471. }
  472. s->seen_in_this_frame = false;
  473. }
  474. input_mt_report_pointer_emulation(input, true);
  475. input_sync(input);
  476. td->num_received = 0;
  477. }
  478. static int mt_event(struct hid_device *hid, struct hid_field *field,
  479. struct hid_usage *usage, __s32 value)
  480. {
  481. struct mt_device *td = hid_get_drvdata(hid);
  482. __s32 quirks = td->mtclass.quirks;
  483. if (hid->claimed & HID_CLAIMED_INPUT && td->slots) {
  484. switch (usage->hid) {
  485. case HID_DG_INRANGE:
  486. if (quirks & MT_QUIRK_ALWAYS_VALID)
  487. td->curvalid = true;
  488. else if (quirks & MT_QUIRK_VALID_IS_INRANGE)
  489. td->curvalid = value;
  490. break;
  491. case HID_DG_TIPSWITCH:
  492. if (quirks & MT_QUIRK_NOT_SEEN_MEANS_UP)
  493. td->curvalid = value;
  494. td->curdata.touch_state = value;
  495. break;
  496. case HID_DG_CONFIDENCE:
  497. if (quirks & MT_QUIRK_VALID_IS_CONFIDENCE)
  498. td->curvalid = value;
  499. break;
  500. case HID_DG_CONTACTID:
  501. td->curdata.contactid = value;
  502. break;
  503. case HID_DG_TIPPRESSURE:
  504. td->curdata.p = value;
  505. break;
  506. case HID_GD_X:
  507. td->curdata.x = value;
  508. break;
  509. case HID_GD_Y:
  510. td->curdata.y = value;
  511. break;
  512. case HID_DG_WIDTH:
  513. td->curdata.w = value;
  514. break;
  515. case HID_DG_HEIGHT:
  516. td->curdata.h = value;
  517. break;
  518. case HID_DG_CONTACTCOUNT:
  519. /*
  520. * Includes multi-packet support where subsequent
  521. * packets are sent with zero contactcount.
  522. */
  523. if (value)
  524. td->num_expected = value;
  525. break;
  526. case HID_DG_TOUCH:
  527. /* do nothing */
  528. break;
  529. default:
  530. /* fallback to the generic hidinput handling */
  531. return 0;
  532. }
  533. if (usage->hid == td->last_slot_field)
  534. mt_complete_slot(td);
  535. if (field->index == td->last_field_index
  536. && td->num_received >= td->num_expected)
  537. mt_emit_event(td, field->hidinput->input);
  538. }
  539. /* we have handled the hidinput part, now remains hiddev */
  540. if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event)
  541. hid->hiddev_hid_event(hid, field, usage, value);
  542. return 1;
  543. }
  544. static void mt_set_input_mode(struct hid_device *hdev)
  545. {
  546. struct mt_device *td = hid_get_drvdata(hdev);
  547. struct hid_report *r;
  548. struct hid_report_enum *re;
  549. if (td->inputmode < 0)
  550. return;
  551. re = &(hdev->report_enum[HID_FEATURE_REPORT]);
  552. r = re->report_id_hash[td->inputmode];
  553. if (r) {
  554. r->field[0]->value[0] = 0x02;
  555. usbhid_submit_report(hdev, r, USB_DIR_OUT);
  556. }
  557. }
  558. static void mt_set_maxcontacts(struct hid_device *hdev)
  559. {
  560. struct mt_device *td = hid_get_drvdata(hdev);
  561. struct hid_report *r;
  562. struct hid_report_enum *re;
  563. int fieldmax, max;
  564. if (td->maxcontact_report_id < 0)
  565. return;
  566. if (!td->mtclass.maxcontacts)
  567. return;
  568. re = &hdev->report_enum[HID_FEATURE_REPORT];
  569. r = re->report_id_hash[td->maxcontact_report_id];
  570. if (r) {
  571. max = td->mtclass.maxcontacts;
  572. fieldmax = r->field[0]->logical_maximum;
  573. max = min(fieldmax, max);
  574. if (r->field[0]->value[0] != max) {
  575. r->field[0]->value[0] = max;
  576. usbhid_submit_report(hdev, r, USB_DIR_OUT);
  577. }
  578. }
  579. }
  580. static void mt_post_parse_default_settings(struct mt_device *td)
  581. {
  582. __s32 quirks = td->mtclass.quirks;
  583. /* unknown serial device needs special quirks */
  584. if (td->touches_by_report == 1) {
  585. quirks |= MT_QUIRK_ALWAYS_VALID;
  586. quirks &= ~MT_QUIRK_NOT_SEEN_MEANS_UP;
  587. quirks &= ~MT_QUIRK_VALID_IS_INRANGE;
  588. quirks &= ~MT_QUIRK_VALID_IS_CONFIDENCE;
  589. }
  590. td->mtclass.quirks = quirks;
  591. }
  592. static void mt_post_parse(struct mt_device *td)
  593. {
  594. struct mt_fields *f = td->fields;
  595. if (td->touches_by_report > 0) {
  596. int field_count_per_touch = f->length / td->touches_by_report;
  597. td->last_slot_field = f->usages[field_count_per_touch - 1];
  598. }
  599. }
  600. static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
  601. {
  602. int ret, i;
  603. struct mt_device *td;
  604. struct mt_class *mtclass = mt_classes; /* MT_CLS_DEFAULT */
  605. if (id) {
  606. for (i = 0; mt_classes[i].name ; i++) {
  607. if (id->driver_data == mt_classes[i].name) {
  608. mtclass = &(mt_classes[i]);
  609. break;
  610. }
  611. }
  612. }
  613. /* This allows the driver to correctly support devices
  614. * that emit events over several HID messages.
  615. */
  616. hdev->quirks |= HID_QUIRK_NO_INPUT_SYNC;
  617. td = kzalloc(sizeof(struct mt_device), GFP_KERNEL);
  618. if (!td) {
  619. dev_err(&hdev->dev, "cannot allocate multitouch data\n");
  620. return -ENOMEM;
  621. }
  622. td->mtclass = *mtclass;
  623. td->inputmode = -1;
  624. td->maxcontact_report_id = -1;
  625. hid_set_drvdata(hdev, td);
  626. td->fields = kzalloc(sizeof(struct mt_fields), GFP_KERNEL);
  627. if (!td->fields) {
  628. dev_err(&hdev->dev, "cannot allocate multitouch fields data\n");
  629. ret = -ENOMEM;
  630. goto fail;
  631. }
  632. ret = hid_parse(hdev);
  633. if (ret != 0)
  634. goto fail;
  635. ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
  636. if (ret)
  637. goto fail;
  638. mt_post_parse(td);
  639. if (id->vendor == HID_ANY_ID && id->product == HID_ANY_ID)
  640. mt_post_parse_default_settings(td);
  641. td->slots = kzalloc(td->maxcontacts * sizeof(struct mt_slot),
  642. GFP_KERNEL);
  643. if (!td->slots) {
  644. dev_err(&hdev->dev, "cannot allocate multitouch slots\n");
  645. hid_hw_stop(hdev);
  646. ret = -ENOMEM;
  647. goto fail;
  648. }
  649. ret = sysfs_create_group(&hdev->dev.kobj, &mt_attribute_group);
  650. mt_set_maxcontacts(hdev);
  651. mt_set_input_mode(hdev);
  652. kfree(td->fields);
  653. td->fields = NULL;
  654. return 0;
  655. fail:
  656. kfree(td->fields);
  657. kfree(td);
  658. return ret;
  659. }
  660. #ifdef CONFIG_PM
  661. static int mt_reset_resume(struct hid_device *hdev)
  662. {
  663. mt_set_maxcontacts(hdev);
  664. mt_set_input_mode(hdev);
  665. return 0;
  666. }
  667. #endif
  668. static void mt_remove(struct hid_device *hdev)
  669. {
  670. struct mt_device *td = hid_get_drvdata(hdev);
  671. sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group);
  672. hid_hw_stop(hdev);
  673. kfree(td->slots);
  674. kfree(td);
  675. hid_set_drvdata(hdev, NULL);
  676. }
  677. static const struct hid_device_id mt_devices[] = {
  678. /* 3M panels */
  679. { .driver_data = MT_CLS_3M,
  680. MT_USB_DEVICE(USB_VENDOR_ID_3M,
  681. USB_DEVICE_ID_3M1968) },
  682. { .driver_data = MT_CLS_3M,
  683. MT_USB_DEVICE(USB_VENDOR_ID_3M,
  684. USB_DEVICE_ID_3M2256) },
  685. { .driver_data = MT_CLS_3M,
  686. MT_USB_DEVICE(USB_VENDOR_ID_3M,
  687. USB_DEVICE_ID_3M3266) },
  688. /* ActionStar panels */
  689. { .driver_data = MT_CLS_DEFAULT,
  690. MT_USB_DEVICE(USB_VENDOR_ID_ACTIONSTAR,
  691. USB_DEVICE_ID_ACTIONSTAR_1011) },
  692. /* Atmel panels */
  693. { .driver_data = MT_CLS_SERIAL,
  694. MT_USB_DEVICE(USB_VENDOR_ID_ATMEL,
  695. USB_DEVICE_ID_ATMEL_MULTITOUCH) },
  696. { .driver_data = MT_CLS_SERIAL,
  697. MT_USB_DEVICE(USB_VENDOR_ID_ATMEL,
  698. USB_DEVICE_ID_ATMEL_MXT_DIGITIZER) },
  699. /* Baanto multitouch devices */
  700. { .driver_data = MT_CLS_DEFAULT,
  701. MT_USB_DEVICE(USB_VENDOR_ID_BAANTO,
  702. USB_DEVICE_ID_BAANTO_MT_190W2) },
  703. /* Cando panels */
  704. { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
  705. MT_USB_DEVICE(USB_VENDOR_ID_CANDO,
  706. USB_DEVICE_ID_CANDO_MULTI_TOUCH) },
  707. { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
  708. MT_USB_DEVICE(USB_VENDOR_ID_CANDO,
  709. USB_DEVICE_ID_CANDO_MULTI_TOUCH_10_1) },
  710. { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
  711. MT_USB_DEVICE(USB_VENDOR_ID_CANDO,
  712. USB_DEVICE_ID_CANDO_MULTI_TOUCH_11_6) },
  713. { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
  714. MT_USB_DEVICE(USB_VENDOR_ID_CANDO,
  715. USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6) },
  716. /* Chunghwa Telecom touch panels */
  717. { .driver_data = MT_CLS_DEFAULT,
  718. MT_USB_DEVICE(USB_VENDOR_ID_CHUNGHWAT,
  719. USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH) },
  720. /* CVTouch panels */
  721. { .driver_data = MT_CLS_DEFAULT,
  722. MT_USB_DEVICE(USB_VENDOR_ID_CVTOUCH,
  723. USB_DEVICE_ID_CVTOUCH_SCREEN) },
  724. /* Cypress panel */
  725. { .driver_data = MT_CLS_CYPRESS,
  726. HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS,
  727. USB_DEVICE_ID_CYPRESS_TRUETOUCH) },
  728. /* eGalax devices (resistive) */
  729. { .driver_data = MT_CLS_EGALAX,
  730. MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
  731. USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480D) },
  732. { .driver_data = MT_CLS_EGALAX,
  733. MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
  734. USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480E) },
  735. /* eGalax devices (capacitive) */
  736. { .driver_data = MT_CLS_EGALAX,
  737. MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
  738. USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_720C) },
  739. { .driver_data = MT_CLS_EGALAX_SERIAL,
  740. MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
  741. USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7207) },
  742. { .driver_data = MT_CLS_EGALAX_SERIAL,
  743. MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
  744. USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_725E) },
  745. { .driver_data = MT_CLS_EGALAX_SERIAL,
  746. MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
  747. USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7224) },
  748. { .driver_data = MT_CLS_EGALAX_SERIAL,
  749. MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
  750. USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_722A) },
  751. { .driver_data = MT_CLS_EGALAX,
  752. MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
  753. USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_726B) },
  754. { .driver_data = MT_CLS_EGALAX_SERIAL,
  755. MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
  756. USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7262) },
  757. { .driver_data = MT_CLS_EGALAX,
  758. MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
  759. USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72A1) },
  760. { .driver_data = MT_CLS_EGALAX_SERIAL,
  761. MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
  762. USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72AA) },
  763. { .driver_data = MT_CLS_EGALAX,
  764. MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
  765. USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72FA) },
  766. { .driver_data = MT_CLS_EGALAX,
  767. MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
  768. USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7302) },
  769. { .driver_data = MT_CLS_EGALAX_SERIAL,
  770. MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
  771. USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7349) },
  772. { .driver_data = MT_CLS_EGALAX_SERIAL,
  773. MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
  774. USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_A001) },
  775. /* Elo TouchSystems IntelliTouch Plus panel */
  776. { .driver_data = MT_CLS_DUAL_NSMU_CONTACTID,
  777. MT_USB_DEVICE(USB_VENDOR_ID_ELO,
  778. USB_DEVICE_ID_ELO_TS2515) },
  779. /* GeneralTouch panel */
  780. { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
  781. MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH,
  782. USB_DEVICE_ID_GENERAL_TOUCH_WIN7_TWOFINGERS) },
  783. /* Gametel game controller */
  784. { .driver_data = MT_CLS_DEFAULT,
  785. MT_BT_DEVICE(USB_VENDOR_ID_FRUCTEL,
  786. USB_DEVICE_ID_GAMETEL_MT_MODE) },
  787. /* GoodTouch panels */
  788. { .driver_data = MT_CLS_DEFAULT,
  789. MT_USB_DEVICE(USB_VENDOR_ID_GOODTOUCH,
  790. USB_DEVICE_ID_GOODTOUCH_000f) },
  791. /* Hanvon panels */
  792. { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID,
  793. MT_USB_DEVICE(USB_VENDOR_ID_HANVON_ALT,
  794. USB_DEVICE_ID_HANVON_ALT_MULTITOUCH) },
  795. /* Ideacom panel */
  796. { .driver_data = MT_CLS_SERIAL,
  797. MT_USB_DEVICE(USB_VENDOR_ID_IDEACOM,
  798. USB_DEVICE_ID_IDEACOM_IDC6650) },
  799. { .driver_data = MT_CLS_SERIAL,
  800. MT_USB_DEVICE(USB_VENDOR_ID_IDEACOM,
  801. USB_DEVICE_ID_IDEACOM_IDC6651) },
  802. /* Ilitek dual touch panel */
  803. { .driver_data = MT_CLS_DEFAULT,
  804. MT_USB_DEVICE(USB_VENDOR_ID_ILITEK,
  805. USB_DEVICE_ID_ILITEK_MULTITOUCH) },
  806. /* IRTOUCH panels */
  807. { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID,
  808. MT_USB_DEVICE(USB_VENDOR_ID_IRTOUCHSYSTEMS,
  809. USB_DEVICE_ID_IRTOUCH_INFRARED_USB) },
  810. /* LG Display panels */
  811. { .driver_data = MT_CLS_DEFAULT,
  812. MT_USB_DEVICE(USB_VENDOR_ID_LG,
  813. USB_DEVICE_ID_LG_MULTITOUCH) },
  814. /* Lumio panels */
  815. { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
  816. MT_USB_DEVICE(USB_VENDOR_ID_LUMIO,
  817. USB_DEVICE_ID_CRYSTALTOUCH) },
  818. { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
  819. MT_USB_DEVICE(USB_VENDOR_ID_LUMIO,
  820. USB_DEVICE_ID_CRYSTALTOUCH_DUAL) },
  821. /* MosArt panels */
  822. { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
  823. MT_USB_DEVICE(USB_VENDOR_ID_ASUS,
  824. USB_DEVICE_ID_ASUS_T91MT)},
  825. { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
  826. MT_USB_DEVICE(USB_VENDOR_ID_ASUS,
  827. USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO) },
  828. { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
  829. MT_USB_DEVICE(USB_VENDOR_ID_TURBOX,
  830. USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART) },
  831. /* Panasonic panels */
  832. { .driver_data = MT_CLS_PANASONIC,
  833. MT_USB_DEVICE(USB_VENDOR_ID_PANASONIC,
  834. USB_DEVICE_ID_PANABOARD_UBT780) },
  835. { .driver_data = MT_CLS_PANASONIC,
  836. MT_USB_DEVICE(USB_VENDOR_ID_PANASONIC,
  837. USB_DEVICE_ID_PANABOARD_UBT880) },
  838. /* Novatek Panel */
  839. { .driver_data = MT_CLS_DEFAULT,
  840. HID_USB_DEVICE(USB_VENDOR_ID_NOVATEK,
  841. USB_DEVICE_ID_NOVATEK_PCT) },
  842. /* PenMount panels */
  843. { .driver_data = MT_CLS_CONFIDENCE,
  844. MT_USB_DEVICE(USB_VENDOR_ID_PENMOUNT,
  845. USB_DEVICE_ID_PENMOUNT_PCI) },
  846. /* PixArt optical touch screen */
  847. { .driver_data = MT_CLS_INRANGE_CONTACTNUMBER,
  848. MT_USB_DEVICE(USB_VENDOR_ID_PIXART,
  849. USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN) },
  850. { .driver_data = MT_CLS_INRANGE_CONTACTNUMBER,
  851. MT_USB_DEVICE(USB_VENDOR_ID_PIXART,
  852. USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1) },
  853. { .driver_data = MT_CLS_INRANGE_CONTACTNUMBER,
  854. MT_USB_DEVICE(USB_VENDOR_ID_PIXART,
  855. USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2) },
  856. /* PixCir-based panels */
  857. { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID,
  858. MT_USB_DEVICE(USB_VENDOR_ID_HANVON,
  859. USB_DEVICE_ID_HANVON_MULTITOUCH) },
  860. { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID,
  861. MT_USB_DEVICE(USB_VENDOR_ID_CANDO,
  862. USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH) },
  863. /* Quanta-based panels */
  864. { .driver_data = MT_CLS_CONFIDENCE_CONTACT_ID,
  865. MT_USB_DEVICE(USB_VENDOR_ID_QUANTA,
  866. USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) },
  867. { .driver_data = MT_CLS_CONFIDENCE_CONTACT_ID,
  868. MT_USB_DEVICE(USB_VENDOR_ID_QUANTA,
  869. USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3001) },
  870. { .driver_data = MT_CLS_CONFIDENCE_CONTACT_ID,
  871. MT_USB_DEVICE(USB_VENDOR_ID_QUANTA,
  872. USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3008) },
  873. /* Stantum panels */
  874. { .driver_data = MT_CLS_CONFIDENCE,
  875. MT_USB_DEVICE(USB_VENDOR_ID_STANTUM,
  876. USB_DEVICE_ID_MTP)},
  877. { .driver_data = MT_CLS_CONFIDENCE,
  878. MT_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM,
  879. USB_DEVICE_ID_MTP_STM)},
  880. { .driver_data = MT_CLS_CONFIDENCE,
  881. MT_USB_DEVICE(USB_VENDOR_ID_STANTUM_SITRONIX,
  882. USB_DEVICE_ID_MTP_SITRONIX)},
  883. /* TopSeed panels */
  884. { .driver_data = MT_CLS_TOPSEED,
  885. MT_USB_DEVICE(USB_VENDOR_ID_TOPSEED2,
  886. USB_DEVICE_ID_TOPSEED2_PERIPAD_701) },
  887. /* Touch International panels */
  888. { .driver_data = MT_CLS_DEFAULT,
  889. MT_USB_DEVICE(USB_VENDOR_ID_TOUCH_INTL,
  890. USB_DEVICE_ID_TOUCH_INTL_MULTI_TOUCH) },
  891. /* Unitec panels */
  892. { .driver_data = MT_CLS_DEFAULT,
  893. MT_USB_DEVICE(USB_VENDOR_ID_UNITEC,
  894. USB_DEVICE_ID_UNITEC_USB_TOUCH_0709) },
  895. { .driver_data = MT_CLS_DEFAULT,
  896. MT_USB_DEVICE(USB_VENDOR_ID_UNITEC,
  897. USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19) },
  898. /* XAT */
  899. { .driver_data = MT_CLS_DEFAULT,
  900. MT_USB_DEVICE(USB_VENDOR_ID_XAT,
  901. USB_DEVICE_ID_XAT_CSR) },
  902. /* Xiroku */
  903. { .driver_data = MT_CLS_DEFAULT,
  904. MT_USB_DEVICE(USB_VENDOR_ID_XIROKU,
  905. USB_DEVICE_ID_XIROKU_SPX) },
  906. { .driver_data = MT_CLS_DEFAULT,
  907. MT_USB_DEVICE(USB_VENDOR_ID_XIROKU,
  908. USB_DEVICE_ID_XIROKU_MPX) },
  909. { .driver_data = MT_CLS_DEFAULT,
  910. MT_USB_DEVICE(USB_VENDOR_ID_XIROKU,
  911. USB_DEVICE_ID_XIROKU_CSR) },
  912. { .driver_data = MT_CLS_DEFAULT,
  913. MT_USB_DEVICE(USB_VENDOR_ID_XIROKU,
  914. USB_DEVICE_ID_XIROKU_SPX1) },
  915. { .driver_data = MT_CLS_DEFAULT,
  916. MT_USB_DEVICE(USB_VENDOR_ID_XIROKU,
  917. USB_DEVICE_ID_XIROKU_MPX1) },
  918. { .driver_data = MT_CLS_DEFAULT,
  919. MT_USB_DEVICE(USB_VENDOR_ID_XIROKU,
  920. USB_DEVICE_ID_XIROKU_CSR1) },
  921. { .driver_data = MT_CLS_DEFAULT,
  922. MT_USB_DEVICE(USB_VENDOR_ID_XIROKU,
  923. USB_DEVICE_ID_XIROKU_SPX2) },
  924. { .driver_data = MT_CLS_DEFAULT,
  925. MT_USB_DEVICE(USB_VENDOR_ID_XIROKU,
  926. USB_DEVICE_ID_XIROKU_MPX2) },
  927. { .driver_data = MT_CLS_DEFAULT,
  928. MT_USB_DEVICE(USB_VENDOR_ID_XIROKU,
  929. USB_DEVICE_ID_XIROKU_CSR2) },
  930. /* Generic MT device */
  931. { HID_DEVICE(HID_BUS_ANY, HID_GROUP_MULTITOUCH, HID_ANY_ID, HID_ANY_ID) },
  932. { }
  933. };
  934. MODULE_DEVICE_TABLE(hid, mt_devices);
  935. static const struct hid_usage_id mt_grabbed_usages[] = {
  936. { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID },
  937. { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}
  938. };
  939. static struct hid_driver mt_driver = {
  940. .name = "hid-multitouch",
  941. .id_table = mt_devices,
  942. .probe = mt_probe,
  943. .remove = mt_remove,
  944. .input_mapping = mt_input_mapping,
  945. .input_mapped = mt_input_mapped,
  946. .feature_mapping = mt_feature_mapping,
  947. .usage_table = mt_grabbed_usages,
  948. .event = mt_event,
  949. #ifdef CONFIG_PM
  950. .reset_resume = mt_reset_resume,
  951. #endif
  952. };
  953. static int __init mt_init(void)
  954. {
  955. return hid_register_driver(&mt_driver);
  956. }
  957. static void __exit mt_exit(void)
  958. {
  959. hid_unregister_driver(&mt_driver);
  960. }
  961. module_init(mt_init);
  962. module_exit(mt_exit);