usbtouchscreen.c 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /******************************************************************************
  3. * usbtouchscreen.c
  4. * Driver for USB Touchscreens, supporting those devices:
  5. * - eGalax Touchkit
  6. * includes eTurboTouch CT-410/510/700
  7. * - 3M/Microtouch EX II series
  8. * - ITM
  9. * - PanJit TouchSet
  10. * - eTurboTouch
  11. * - Gunze AHL61
  12. * - DMC TSC-10/25
  13. * - IRTOUCHSYSTEMS/UNITOP
  14. * - IdealTEK URTC1000
  15. * - General Touch
  16. * - GoTop Super_Q2/GogoPen/PenPower tablets
  17. * - JASTEC USB touch controller/DigiTech DTR-02U
  18. * - Zytronic capacitive touchscreen
  19. * - NEXIO/iNexio
  20. * - Elo TouchSystems 2700 IntelliTouch
  21. * - EasyTouch USB Dual/Multi touch controller from Data Modul
  22. *
  23. * Copyright (C) 2004-2007 by Daniel Ritz <daniel.ritz@gmx.ch>
  24. * Copyright (C) by Todd E. Johnson (mtouchusb.c)
  25. *
  26. * Driver is based on touchkitusb.c
  27. * - ITM parts are from itmtouch.c
  28. * - 3M parts are from mtouchusb.c
  29. * - PanJit parts are from an unmerged driver by Lanslott Gish
  30. * - DMC TSC 10/25 are from Holger Schurig, with ideas from an unmerged
  31. * driver from Marius Vollmer
  32. *
  33. *****************************************************************************/
  34. //#define DEBUG
  35. #include <linux/kernel.h>
  36. #include <linux/slab.h>
  37. #include <linux/input.h>
  38. #include <linux/module.h>
  39. #include <linux/usb.h>
  40. #include <linux/usb/input.h>
  41. #include <linux/hid.h>
  42. #include <linux/mutex.h>
  43. static bool swap_xy;
  44. module_param(swap_xy, bool, 0644);
  45. MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped.");
  46. static bool hwcalib_xy;
  47. module_param(hwcalib_xy, bool, 0644);
  48. MODULE_PARM_DESC(hwcalib_xy, "If set hw-calibrated X/Y are used if available");
  49. /* device specifc data/functions */
  50. struct usbtouch_usb;
  51. struct usbtouch_device_info {
  52. int min_xc, max_xc;
  53. int min_yc, max_yc;
  54. int min_press, max_press;
  55. int rept_size;
  56. /*
  57. * Always service the USB devices irq not just when the input device is
  58. * open. This is useful when devices have a watchdog which prevents us
  59. * from periodically polling the device. Leave this unset unless your
  60. * touchscreen device requires it, as it does consume more of the USB
  61. * bandwidth.
  62. */
  63. bool irq_always;
  64. /*
  65. * used to get the packet len. possible return values:
  66. * > 0: packet len
  67. * = 0: skip one byte
  68. * < 0: -return value more bytes needed
  69. */
  70. int (*get_pkt_len) (unsigned char *pkt, int len);
  71. int (*read_data) (struct usbtouch_usb *usbtouch, unsigned char *pkt);
  72. int (*alloc) (struct usbtouch_usb *usbtouch);
  73. int (*init) (struct usbtouch_usb *usbtouch);
  74. void (*exit) (struct usbtouch_usb *usbtouch);
  75. };
  76. /* a usbtouch device */
  77. struct usbtouch_usb {
  78. unsigned char *data;
  79. dma_addr_t data_dma;
  80. int data_size;
  81. unsigned char *buffer;
  82. int buf_len;
  83. struct urb *irq;
  84. struct usb_interface *interface;
  85. struct input_dev *input;
  86. const struct usbtouch_device_info *type;
  87. struct mutex pm_mutex; /* serialize access to open/suspend */
  88. bool is_open;
  89. char name[128];
  90. char phys[64];
  91. void *priv;
  92. int x, y;
  93. int touch, press;
  94. void (*process_pkt)(struct usbtouch_usb *usbtouch, unsigned char *pkt, int len);
  95. };
  96. /*****************************************************************************
  97. * e2i Part
  98. */
  99. #ifdef CONFIG_TOUCHSCREEN_USB_E2I
  100. static int e2i_init(struct usbtouch_usb *usbtouch)
  101. {
  102. int ret;
  103. struct usb_device *udev = interface_to_usbdev(usbtouch->interface);
  104. ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
  105. 0x01, 0x02, 0x0000, 0x0081,
  106. NULL, 0, USB_CTRL_SET_TIMEOUT);
  107. dev_dbg(&usbtouch->interface->dev,
  108. "%s - usb_control_msg - E2I_RESET - bytes|err: %d\n",
  109. __func__, ret);
  110. return ret;
  111. }
  112. static int e2i_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
  113. {
  114. int tmp = (pkt[0] << 8) | pkt[1];
  115. dev->x = (pkt[2] << 8) | pkt[3];
  116. dev->y = (pkt[4] << 8) | pkt[5];
  117. tmp = tmp - 0xA000;
  118. dev->touch = (tmp > 0);
  119. dev->press = (tmp > 0 ? tmp : 0);
  120. return 1;
  121. }
  122. static const struct usbtouch_device_info e2i_dev_info = {
  123. .min_xc = 0x0,
  124. .max_xc = 0x7fff,
  125. .min_yc = 0x0,
  126. .max_yc = 0x7fff,
  127. .rept_size = 6,
  128. .init = e2i_init,
  129. .read_data = e2i_read_data,
  130. };
  131. #endif
  132. /*****************************************************************************
  133. * eGalax part
  134. */
  135. #ifdef CONFIG_TOUCHSCREEN_USB_EGALAX
  136. #ifndef MULTI_PACKET
  137. #define MULTI_PACKET
  138. #endif
  139. #define EGALAX_PKT_TYPE_MASK 0xFE
  140. #define EGALAX_PKT_TYPE_REPT 0x80
  141. #define EGALAX_PKT_TYPE_DIAG 0x0A
  142. static int egalax_init(struct usbtouch_usb *usbtouch)
  143. {
  144. struct usb_device *udev = interface_to_usbdev(usbtouch->interface);
  145. int ret, i;
  146. /*
  147. * An eGalax diagnostic packet kicks the device into using the right
  148. * protocol. We send a "check active" packet. The response will be
  149. * read later and ignored.
  150. */
  151. u8 *buf __free(kfree) = kmalloc(3, GFP_KERNEL);
  152. if (!buf)
  153. return -ENOMEM;
  154. buf[0] = EGALAX_PKT_TYPE_DIAG;
  155. buf[1] = 1; /* length */
  156. buf[2] = 'A'; /* command - check active */
  157. for (i = 0; i < 3; i++) {
  158. ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
  159. 0,
  160. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  161. 0, 0, buf, 3,
  162. USB_CTRL_SET_TIMEOUT);
  163. if (ret != -EPIPE)
  164. break;
  165. }
  166. return ret < 0 ? ret : 0;
  167. }
  168. static int egalax_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
  169. {
  170. if ((pkt[0] & EGALAX_PKT_TYPE_MASK) != EGALAX_PKT_TYPE_REPT)
  171. return 0;
  172. dev->x = ((pkt[3] & 0x0F) << 7) | (pkt[4] & 0x7F);
  173. dev->y = ((pkt[1] & 0x0F) << 7) | (pkt[2] & 0x7F);
  174. dev->touch = pkt[0] & 0x01;
  175. return 1;
  176. }
  177. static int egalax_get_pkt_len(unsigned char *buf, int len)
  178. {
  179. switch (buf[0] & EGALAX_PKT_TYPE_MASK) {
  180. case EGALAX_PKT_TYPE_REPT:
  181. return 5;
  182. case EGALAX_PKT_TYPE_DIAG:
  183. if (len < 2)
  184. return -1;
  185. return buf[1] + 2;
  186. }
  187. return 0;
  188. }
  189. static const struct usbtouch_device_info egalax_dev_info = {
  190. .min_xc = 0x0,
  191. .max_xc = 0x07ff,
  192. .min_yc = 0x0,
  193. .max_yc = 0x07ff,
  194. .rept_size = 16,
  195. .get_pkt_len = egalax_get_pkt_len,
  196. .read_data = egalax_read_data,
  197. .init = egalax_init,
  198. };
  199. #endif
  200. /*****************************************************************************
  201. * EasyTouch part
  202. */
  203. #ifdef CONFIG_TOUCHSCREEN_USB_EASYTOUCH
  204. #ifndef MULTI_PACKET
  205. #define MULTI_PACKET
  206. #endif
  207. #define ETOUCH_PKT_TYPE_MASK 0xFE
  208. #define ETOUCH_PKT_TYPE_REPT 0x80
  209. #define ETOUCH_PKT_TYPE_REPT2 0xB0
  210. #define ETOUCH_PKT_TYPE_DIAG 0x0A
  211. static int etouch_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
  212. {
  213. if ((pkt[0] & ETOUCH_PKT_TYPE_MASK) != ETOUCH_PKT_TYPE_REPT &&
  214. (pkt[0] & ETOUCH_PKT_TYPE_MASK) != ETOUCH_PKT_TYPE_REPT2)
  215. return 0;
  216. dev->x = ((pkt[1] & 0x1F) << 7) | (pkt[2] & 0x7F);
  217. dev->y = ((pkt[3] & 0x1F) << 7) | (pkt[4] & 0x7F);
  218. dev->touch = pkt[0] & 0x01;
  219. return 1;
  220. }
  221. static int etouch_get_pkt_len(unsigned char *buf, int len)
  222. {
  223. switch (buf[0] & ETOUCH_PKT_TYPE_MASK) {
  224. case ETOUCH_PKT_TYPE_REPT:
  225. case ETOUCH_PKT_TYPE_REPT2:
  226. return 5;
  227. case ETOUCH_PKT_TYPE_DIAG:
  228. if (len < 2)
  229. return -1;
  230. return buf[1] + 2;
  231. }
  232. return 0;
  233. }
  234. static const struct usbtouch_device_info etouch_dev_info = {
  235. .min_xc = 0x0,
  236. .max_xc = 0x07ff,
  237. .min_yc = 0x0,
  238. .max_yc = 0x07ff,
  239. .rept_size = 16,
  240. .get_pkt_len = etouch_get_pkt_len,
  241. .read_data = etouch_read_data,
  242. };
  243. #endif
  244. /*****************************************************************************
  245. * PanJit Part
  246. */
  247. #ifdef CONFIG_TOUCHSCREEN_USB_PANJIT
  248. static int panjit_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
  249. {
  250. dev->x = ((pkt[2] & 0x0F) << 8) | pkt[1];
  251. dev->y = ((pkt[4] & 0x0F) << 8) | pkt[3];
  252. dev->touch = pkt[0] & 0x01;
  253. return 1;
  254. }
  255. static const struct usbtouch_device_info panjit_dev_info = {
  256. .min_xc = 0x0,
  257. .max_xc = 0x0fff,
  258. .min_yc = 0x0,
  259. .max_yc = 0x0fff,
  260. .rept_size = 8,
  261. .read_data = panjit_read_data,
  262. };
  263. #endif
  264. /*****************************************************************************
  265. * 3M/Microtouch Part
  266. */
  267. #ifdef CONFIG_TOUCHSCREEN_USB_3M
  268. #define MTOUCHUSB_ASYNC_REPORT 1
  269. #define MTOUCHUSB_RESET 7
  270. #define MTOUCHUSB_REQ_CTRLLR_ID 10
  271. #define MTOUCHUSB_REQ_CTRLLR_ID_LEN 16
  272. static int mtouch_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
  273. {
  274. if (hwcalib_xy) {
  275. dev->x = (pkt[4] << 8) | pkt[3];
  276. dev->y = 0xffff - ((pkt[6] << 8) | pkt[5]);
  277. } else {
  278. dev->x = (pkt[8] << 8) | pkt[7];
  279. dev->y = (pkt[10] << 8) | pkt[9];
  280. }
  281. dev->touch = (pkt[2] & 0x40) ? 1 : 0;
  282. return 1;
  283. }
  284. struct mtouch_priv {
  285. u8 fw_rev_major;
  286. u8 fw_rev_minor;
  287. };
  288. static int mtouch_get_fw_revision(struct usbtouch_usb *usbtouch)
  289. {
  290. struct usb_device *udev = interface_to_usbdev(usbtouch->interface);
  291. struct mtouch_priv *priv = usbtouch->priv;
  292. int ret;
  293. u8 *buf __free(kfree) = kzalloc(MTOUCHUSB_REQ_CTRLLR_ID_LEN, GFP_NOIO);
  294. if (!buf)
  295. return -ENOMEM;
  296. ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
  297. MTOUCHUSB_REQ_CTRLLR_ID,
  298. USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  299. 0, 0, buf, MTOUCHUSB_REQ_CTRLLR_ID_LEN,
  300. USB_CTRL_SET_TIMEOUT);
  301. if (ret != MTOUCHUSB_REQ_CTRLLR_ID_LEN) {
  302. dev_warn(&usbtouch->interface->dev,
  303. "Failed to read FW rev: %d\n", ret);
  304. return ret < 0 ? ret : -EIO;
  305. }
  306. priv->fw_rev_major = buf[3];
  307. priv->fw_rev_minor = buf[4];
  308. return 0;
  309. }
  310. static int mtouch_alloc(struct usbtouch_usb *usbtouch)
  311. {
  312. struct mtouch_priv *priv;
  313. priv = kmalloc_obj(*priv);
  314. if (!priv)
  315. return -ENOMEM;
  316. usbtouch->priv = priv;
  317. return 0;
  318. }
  319. static int mtouch_init(struct usbtouch_usb *usbtouch)
  320. {
  321. int ret, i;
  322. struct usb_device *udev = interface_to_usbdev(usbtouch->interface);
  323. ret = mtouch_get_fw_revision(usbtouch);
  324. if (ret)
  325. return ret;
  326. ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
  327. MTOUCHUSB_RESET,
  328. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  329. 1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT);
  330. dev_dbg(&usbtouch->interface->dev,
  331. "%s - usb_control_msg - MTOUCHUSB_RESET - bytes|err: %d\n",
  332. __func__, ret);
  333. if (ret < 0)
  334. return ret;
  335. msleep(150);
  336. for (i = 0; i < 3; i++) {
  337. ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
  338. MTOUCHUSB_ASYNC_REPORT,
  339. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  340. 1, 1, NULL, 0, USB_CTRL_SET_TIMEOUT);
  341. dev_dbg(&usbtouch->interface->dev,
  342. "%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d\n",
  343. __func__, ret);
  344. if (ret >= 0)
  345. break;
  346. if (ret != -EPIPE)
  347. return ret;
  348. }
  349. /* Default min/max xy are the raw values, override if using hw-calib */
  350. if (hwcalib_xy) {
  351. input_set_abs_params(usbtouch->input, ABS_X, 0, 0xffff, 0, 0);
  352. input_set_abs_params(usbtouch->input, ABS_Y, 0, 0xffff, 0, 0);
  353. }
  354. return 0;
  355. }
  356. static void mtouch_exit(struct usbtouch_usb *usbtouch)
  357. {
  358. struct mtouch_priv *priv = usbtouch->priv;
  359. kfree(priv);
  360. }
  361. static struct usbtouch_device_info mtouch_dev_info = {
  362. .min_xc = 0x0,
  363. .max_xc = 0x4000,
  364. .min_yc = 0x0,
  365. .max_yc = 0x4000,
  366. .rept_size = 11,
  367. .read_data = mtouch_read_data,
  368. .alloc = mtouch_alloc,
  369. .init = mtouch_init,
  370. .exit = mtouch_exit,
  371. };
  372. static ssize_t mtouch_firmware_rev_show(struct device *dev,
  373. struct device_attribute *attr, char *output)
  374. {
  375. struct usb_interface *intf = to_usb_interface(dev);
  376. struct usbtouch_usb *usbtouch = usb_get_intfdata(intf);
  377. struct mtouch_priv *priv = usbtouch->priv;
  378. return sysfs_emit(output, "%1x.%1x\n",
  379. priv->fw_rev_major, priv->fw_rev_minor);
  380. }
  381. static DEVICE_ATTR(firmware_rev, 0444, mtouch_firmware_rev_show, NULL);
  382. static struct attribute *mtouch_attrs[] = {
  383. &dev_attr_firmware_rev.attr,
  384. NULL
  385. };
  386. static bool mtouch_group_visible(struct kobject *kobj)
  387. {
  388. struct device *dev = kobj_to_dev(kobj);
  389. struct usb_interface *intf = to_usb_interface(dev);
  390. struct usbtouch_usb *usbtouch = usb_get_intfdata(intf);
  391. return usbtouch->type == &mtouch_dev_info;
  392. }
  393. DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(mtouch);
  394. static const struct attribute_group mtouch_attr_group = {
  395. .is_visible = SYSFS_GROUP_VISIBLE(mtouch),
  396. .attrs = mtouch_attrs,
  397. };
  398. #endif
  399. /*****************************************************************************
  400. * ITM Part
  401. */
  402. #ifdef CONFIG_TOUCHSCREEN_USB_ITM
  403. static int itm_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
  404. {
  405. int touch;
  406. /*
  407. * ITM devices report invalid x/y data if not touched.
  408. * if the screen was touched before but is not touched any more
  409. * report touch as 0 with the last valid x/y data once. then stop
  410. * reporting data until touched again.
  411. */
  412. dev->press = ((pkt[2] & 0x01) << 7) | (pkt[5] & 0x7F);
  413. touch = ~pkt[7] & 0x20;
  414. if (!touch) {
  415. if (dev->touch) {
  416. dev->touch = 0;
  417. return 1;
  418. }
  419. return 0;
  420. }
  421. dev->x = ((pkt[0] & 0x1F) << 7) | (pkt[3] & 0x7F);
  422. dev->y = ((pkt[1] & 0x1F) << 7) | (pkt[4] & 0x7F);
  423. dev->touch = touch;
  424. return 1;
  425. }
  426. static const struct usbtouch_device_info itm_dev_info = {
  427. .min_xc = 0x0,
  428. .max_xc = 0x0fff,
  429. .min_yc = 0x0,
  430. .max_yc = 0x0fff,
  431. .max_press = 0xff,
  432. .rept_size = 8,
  433. .read_data = itm_read_data,
  434. };
  435. #endif
  436. /*****************************************************************************
  437. * eTurboTouch part
  438. */
  439. #ifdef CONFIG_TOUCHSCREEN_USB_ETURBO
  440. #ifndef MULTI_PACKET
  441. #define MULTI_PACKET
  442. #endif
  443. static int eturbo_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
  444. {
  445. unsigned int shift;
  446. /* packets should start with sync */
  447. if (!(pkt[0] & 0x80))
  448. return 0;
  449. shift = (6 - (pkt[0] & 0x03));
  450. dev->x = ((pkt[3] << 7) | pkt[4]) >> shift;
  451. dev->y = ((pkt[1] << 7) | pkt[2]) >> shift;
  452. dev->touch = (pkt[0] & 0x10) ? 1 : 0;
  453. return 1;
  454. }
  455. static int eturbo_get_pkt_len(unsigned char *buf, int len)
  456. {
  457. if (buf[0] & 0x80)
  458. return 5;
  459. if (buf[0] == 0x01)
  460. return 3;
  461. return 0;
  462. }
  463. static const struct usbtouch_device_info eturbo_dev_info = {
  464. .min_xc = 0x0,
  465. .max_xc = 0x07ff,
  466. .min_yc = 0x0,
  467. .max_yc = 0x07ff,
  468. .rept_size = 8,
  469. .get_pkt_len = eturbo_get_pkt_len,
  470. .read_data = eturbo_read_data,
  471. };
  472. #endif
  473. /*****************************************************************************
  474. * Gunze part
  475. */
  476. #ifdef CONFIG_TOUCHSCREEN_USB_GUNZE
  477. static int gunze_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
  478. {
  479. if (!(pkt[0] & 0x80) || ((pkt[1] | pkt[2] | pkt[3]) & 0x80))
  480. return 0;
  481. dev->x = ((pkt[0] & 0x1F) << 7) | (pkt[2] & 0x7F);
  482. dev->y = ((pkt[1] & 0x1F) << 7) | (pkt[3] & 0x7F);
  483. dev->touch = pkt[0] & 0x20;
  484. return 1;
  485. }
  486. static const struct usbtouch_device_info gunze_dev_info = {
  487. .min_xc = 0x0,
  488. .max_xc = 0x0fff,
  489. .min_yc = 0x0,
  490. .max_yc = 0x0fff,
  491. .rept_size = 4,
  492. .read_data = gunze_read_data,
  493. };
  494. #endif
  495. /*****************************************************************************
  496. * DMC TSC-10/25 Part
  497. *
  498. * Documentation about the controller and it's protocol can be found at
  499. * http://www.dmccoltd.com/files/controler/tsc10usb_pi_e.pdf
  500. * http://www.dmccoltd.com/files/controler/tsc25_usb_e.pdf
  501. */
  502. #ifdef CONFIG_TOUCHSCREEN_USB_DMC_TSC10
  503. /* supported data rates. currently using 130 */
  504. #define TSC10_RATE_POINT 0x50
  505. #define TSC10_RATE_30 0x40
  506. #define TSC10_RATE_50 0x41
  507. #define TSC10_RATE_80 0x42
  508. #define TSC10_RATE_100 0x43
  509. #define TSC10_RATE_130 0x44
  510. #define TSC10_RATE_150 0x45
  511. /* commands */
  512. #define TSC10_CMD_RESET 0x55
  513. #define TSC10_CMD_RATE 0x05
  514. #define TSC10_CMD_DATA1 0x01
  515. static int dmc_tsc10_init(struct usbtouch_usb *usbtouch)
  516. {
  517. struct usb_device *dev = interface_to_usbdev(usbtouch->interface);
  518. int ret;
  519. u8 *buf __free(kfree) = kmalloc(2, GFP_NOIO);
  520. if (!buf)
  521. return -ENOMEM;
  522. /* reset */
  523. buf[0] = buf[1] = 0xFF;
  524. ret = usb_control_msg(dev, usb_rcvctrlpipe (dev, 0),
  525. TSC10_CMD_RESET,
  526. USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  527. 0, 0, buf, 2, USB_CTRL_SET_TIMEOUT);
  528. if (ret < 0)
  529. return ret;
  530. if (buf[0] != 0x06)
  531. return -ENODEV;
  532. /* TSC-25 data sheet specifies a delay after the RESET command */
  533. msleep(150);
  534. /* set coordinate output rate */
  535. buf[0] = buf[1] = 0xFF;
  536. ret = usb_control_msg(dev, usb_rcvctrlpipe (dev, 0),
  537. TSC10_CMD_RATE,
  538. USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  539. TSC10_RATE_150, 0, buf, 2, USB_CTRL_SET_TIMEOUT);
  540. if (ret < 0)
  541. return ret;
  542. if (buf[0] != 0x06 && (buf[0] != 0x15 || buf[1] != 0x01))
  543. return -ENODEV;
  544. /* start sending data */
  545. return usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
  546. TSC10_CMD_DATA1,
  547. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  548. 0, 0, NULL, 0, USB_CTRL_SET_TIMEOUT);
  549. }
  550. static int dmc_tsc10_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
  551. {
  552. dev->x = ((pkt[2] & 0x03) << 8) | pkt[1];
  553. dev->y = ((pkt[4] & 0x03) << 8) | pkt[3];
  554. dev->touch = pkt[0] & 0x01;
  555. return 1;
  556. }
  557. static const struct usbtouch_device_info dmc_tsc10_dev_info = {
  558. .min_xc = 0x0,
  559. .max_xc = 0x03ff,
  560. .min_yc = 0x0,
  561. .max_yc = 0x03ff,
  562. .rept_size = 5,
  563. .init = dmc_tsc10_init,
  564. .read_data = dmc_tsc10_read_data,
  565. };
  566. #endif
  567. /*****************************************************************************
  568. * IRTOUCH Part
  569. */
  570. #ifdef CONFIG_TOUCHSCREEN_USB_IRTOUCH
  571. static int irtouch_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
  572. {
  573. dev->x = (pkt[3] << 8) | pkt[2];
  574. dev->y = (pkt[5] << 8) | pkt[4];
  575. dev->touch = (pkt[1] & 0x03) ? 1 : 0;
  576. return 1;
  577. }
  578. static const struct usbtouch_device_info irtouch_dev_info = {
  579. .min_xc = 0x0,
  580. .max_xc = 0x0fff,
  581. .min_yc = 0x0,
  582. .max_yc = 0x0fff,
  583. .rept_size = 8,
  584. .read_data = irtouch_read_data,
  585. };
  586. static const struct usbtouch_device_info irtouch_hires_dev_info = {
  587. .min_xc = 0x0,
  588. .max_xc = 0x7fff,
  589. .min_yc = 0x0,
  590. .max_yc = 0x7fff,
  591. .rept_size = 8,
  592. .read_data = irtouch_read_data,
  593. };
  594. #endif
  595. /*****************************************************************************
  596. * ET&T TC5UH/TC4UM part
  597. */
  598. #ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC45USB
  599. static int tc45usb_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
  600. {
  601. dev->x = ((pkt[2] & 0x0F) << 8) | pkt[1];
  602. dev->y = ((pkt[4] & 0x0F) << 8) | pkt[3];
  603. dev->touch = pkt[0] & 0x01;
  604. return 1;
  605. }
  606. static const struct usbtouch_device_info tc45usb_dev_info = {
  607. .min_xc = 0x0,
  608. .max_xc = 0x0fff,
  609. .min_yc = 0x0,
  610. .max_yc = 0x0fff,
  611. .rept_size = 5,
  612. .read_data = tc45usb_read_data,
  613. };
  614. #endif
  615. /*****************************************************************************
  616. * IdealTEK URTC1000 Part
  617. */
  618. #ifdef CONFIG_TOUCHSCREEN_USB_IDEALTEK
  619. #ifndef MULTI_PACKET
  620. #define MULTI_PACKET
  621. #endif
  622. static int idealtek_get_pkt_len(unsigned char *buf, int len)
  623. {
  624. if (buf[0] & 0x80)
  625. return 5;
  626. if (buf[0] == 0x01)
  627. return len;
  628. return 0;
  629. }
  630. static int idealtek_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
  631. {
  632. switch (pkt[0] & 0x98) {
  633. case 0x88:
  634. /* touch data in IdealTEK mode */
  635. dev->x = (pkt[1] << 5) | (pkt[2] >> 2);
  636. dev->y = (pkt[3] << 5) | (pkt[4] >> 2);
  637. dev->touch = (pkt[0] & 0x40) ? 1 : 0;
  638. return 1;
  639. case 0x98:
  640. /* touch data in MT emulation mode */
  641. dev->x = (pkt[2] << 5) | (pkt[1] >> 2);
  642. dev->y = (pkt[4] << 5) | (pkt[3] >> 2);
  643. dev->touch = (pkt[0] & 0x40) ? 1 : 0;
  644. return 1;
  645. default:
  646. return 0;
  647. }
  648. }
  649. static const struct usbtouch_device_info idealtek_dev_info = {
  650. .min_xc = 0x0,
  651. .max_xc = 0x0fff,
  652. .min_yc = 0x0,
  653. .max_yc = 0x0fff,
  654. .rept_size = 8,
  655. .get_pkt_len = idealtek_get_pkt_len,
  656. .read_data = idealtek_read_data,
  657. };
  658. #endif
  659. /*****************************************************************************
  660. * General Touch Part
  661. */
  662. #ifdef CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH
  663. static int general_touch_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
  664. {
  665. dev->x = (pkt[2] << 8) | pkt[1];
  666. dev->y = (pkt[4] << 8) | pkt[3];
  667. dev->press = pkt[5] & 0xff;
  668. dev->touch = pkt[0] & 0x01;
  669. return 1;
  670. }
  671. static const struct usbtouch_device_info general_touch_dev_info = {
  672. .min_xc = 0x0,
  673. .max_xc = 0x7fff,
  674. .min_yc = 0x0,
  675. .max_yc = 0x7fff,
  676. .rept_size = 7,
  677. .read_data = general_touch_read_data,
  678. };
  679. #endif
  680. /*****************************************************************************
  681. * GoTop Part
  682. */
  683. #ifdef CONFIG_TOUCHSCREEN_USB_GOTOP
  684. static int gotop_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
  685. {
  686. dev->x = ((pkt[1] & 0x38) << 4) | pkt[2];
  687. dev->y = ((pkt[1] & 0x07) << 7) | pkt[3];
  688. dev->touch = pkt[0] & 0x01;
  689. return 1;
  690. }
  691. static const struct usbtouch_device_info gotop_dev_info = {
  692. .min_xc = 0x0,
  693. .max_xc = 0x03ff,
  694. .min_yc = 0x0,
  695. .max_yc = 0x03ff,
  696. .rept_size = 4,
  697. .read_data = gotop_read_data,
  698. };
  699. #endif
  700. /*****************************************************************************
  701. * JASTEC Part
  702. */
  703. #ifdef CONFIG_TOUCHSCREEN_USB_JASTEC
  704. static int jastec_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
  705. {
  706. dev->x = ((pkt[0] & 0x3f) << 6) | (pkt[2] & 0x3f);
  707. dev->y = ((pkt[1] & 0x3f) << 6) | (pkt[3] & 0x3f);
  708. dev->touch = (pkt[0] & 0x40) >> 6;
  709. return 1;
  710. }
  711. static const struct usbtouch_device_info jastec_dev_info = {
  712. .min_xc = 0x0,
  713. .max_xc = 0x0fff,
  714. .min_yc = 0x0,
  715. .max_yc = 0x0fff,
  716. .rept_size = 4,
  717. .read_data = jastec_read_data,
  718. };
  719. #endif
  720. /*****************************************************************************
  721. * Zytronic Part
  722. */
  723. #ifdef CONFIG_TOUCHSCREEN_USB_ZYTRONIC
  724. static int zytronic_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
  725. {
  726. struct usb_interface *intf = dev->interface;
  727. switch (pkt[0]) {
  728. case 0x3A: /* command response */
  729. dev_dbg(&intf->dev, "%s: Command response %d\n", __func__, pkt[1]);
  730. break;
  731. case 0xC0: /* down */
  732. dev->x = (pkt[1] & 0x7f) | ((pkt[2] & 0x07) << 7);
  733. dev->y = (pkt[3] & 0x7f) | ((pkt[4] & 0x07) << 7);
  734. dev->touch = 1;
  735. dev_dbg(&intf->dev, "%s: down %d,%d\n", __func__, dev->x, dev->y);
  736. return 1;
  737. case 0x80: /* up */
  738. dev->x = (pkt[1] & 0x7f) | ((pkt[2] & 0x07) << 7);
  739. dev->y = (pkt[3] & 0x7f) | ((pkt[4] & 0x07) << 7);
  740. dev->touch = 0;
  741. dev_dbg(&intf->dev, "%s: up %d,%d\n", __func__, dev->x, dev->y);
  742. return 1;
  743. default:
  744. dev_dbg(&intf->dev, "%s: Unknown return %d\n", __func__, pkt[0]);
  745. break;
  746. }
  747. return 0;
  748. }
  749. static const struct usbtouch_device_info zytronic_dev_info = {
  750. .min_xc = 0x0,
  751. .max_xc = 0x03ff,
  752. .min_yc = 0x0,
  753. .max_yc = 0x03ff,
  754. .rept_size = 5,
  755. .read_data = zytronic_read_data,
  756. .irq_always = true,
  757. };
  758. #endif
  759. /*****************************************************************************
  760. * NEXIO Part
  761. */
  762. #ifdef CONFIG_TOUCHSCREEN_USB_NEXIO
  763. #define NEXIO_TIMEOUT 5000
  764. #define NEXIO_BUFSIZE 1024
  765. #define NEXIO_THRESHOLD 50
  766. struct nexio_priv {
  767. struct urb *ack;
  768. unsigned char *ack_buf;
  769. };
  770. struct nexio_touch_packet {
  771. u8 flags; /* 0xe1 = touch, 0xe1 = release */
  772. __be16 data_len; /* total bytes of touch data */
  773. __be16 x_len; /* bytes for X axis */
  774. __be16 y_len; /* bytes for Y axis */
  775. u8 data[];
  776. } __attribute__ ((packed));
  777. static unsigned char nexio_ack_pkt[2] = { 0xaa, 0x02 };
  778. static unsigned char nexio_init_pkt[4] = { 0x82, 0x04, 0x0a, 0x0f };
  779. static void nexio_ack_complete(struct urb *urb)
  780. {
  781. }
  782. static int nexio_alloc(struct usbtouch_usb *usbtouch)
  783. {
  784. struct nexio_priv *priv;
  785. int ret = -ENOMEM;
  786. priv = kmalloc_obj(*priv);
  787. if (!priv)
  788. goto out_buf;
  789. usbtouch->priv = priv;
  790. priv->ack_buf = kmemdup(nexio_ack_pkt, sizeof(nexio_ack_pkt),
  791. GFP_KERNEL);
  792. if (!priv->ack_buf)
  793. goto err_priv;
  794. priv->ack = usb_alloc_urb(0, GFP_KERNEL);
  795. if (!priv->ack) {
  796. dev_dbg(&usbtouch->interface->dev,
  797. "%s - usb_alloc_urb failed: usbtouch->ack\n", __func__);
  798. goto err_ack_buf;
  799. }
  800. return 0;
  801. err_ack_buf:
  802. kfree(priv->ack_buf);
  803. err_priv:
  804. kfree(priv);
  805. out_buf:
  806. return ret;
  807. }
  808. static int nexio_init(struct usbtouch_usb *usbtouch)
  809. {
  810. struct usb_device *dev = interface_to_usbdev(usbtouch->interface);
  811. struct usb_host_interface *interface = usbtouch->interface->cur_altsetting;
  812. struct nexio_priv *priv = usbtouch->priv;
  813. int ret = -ENOMEM;
  814. int actual_len, i;
  815. char *firmware_ver = NULL, *device_name = NULL;
  816. int input_ep = 0, output_ep = 0;
  817. /* find first input and output endpoint */
  818. for (i = 0; i < interface->desc.bNumEndpoints; i++) {
  819. if (!input_ep &&
  820. usb_endpoint_dir_in(&interface->endpoint[i].desc))
  821. input_ep = interface->endpoint[i].desc.bEndpointAddress;
  822. if (!output_ep &&
  823. usb_endpoint_dir_out(&interface->endpoint[i].desc))
  824. output_ep = interface->endpoint[i].desc.bEndpointAddress;
  825. }
  826. if (!input_ep || !output_ep)
  827. return -ENXIO;
  828. u8 *buf __free(kfree) = kmalloc(NEXIO_BUFSIZE, GFP_NOIO);
  829. if (!buf)
  830. return -ENOMEM;
  831. /* two empty reads */
  832. for (i = 0; i < 2; i++) {
  833. ret = usb_bulk_msg(dev, usb_rcvbulkpipe(dev, input_ep),
  834. buf, NEXIO_BUFSIZE, &actual_len,
  835. NEXIO_TIMEOUT);
  836. if (ret < 0)
  837. return ret;
  838. }
  839. /* send init command */
  840. memcpy(buf, nexio_init_pkt, sizeof(nexio_init_pkt));
  841. ret = usb_bulk_msg(dev, usb_sndbulkpipe(dev, output_ep),
  842. buf, sizeof(nexio_init_pkt), &actual_len,
  843. NEXIO_TIMEOUT);
  844. if (ret < 0)
  845. return ret;
  846. /* read replies */
  847. for (i = 0; i < 3; i++) {
  848. memset(buf, 0, NEXIO_BUFSIZE);
  849. ret = usb_bulk_msg(dev, usb_rcvbulkpipe(dev, input_ep),
  850. buf, NEXIO_BUFSIZE, &actual_len,
  851. NEXIO_TIMEOUT);
  852. if (ret < 0 || actual_len < 1 || buf[1] != actual_len)
  853. continue;
  854. switch (buf[0]) {
  855. case 0x83: /* firmware version */
  856. if (!firmware_ver)
  857. firmware_ver = kstrdup(&buf[2], GFP_NOIO);
  858. break;
  859. case 0x84: /* device name */
  860. if (!device_name)
  861. device_name = kstrdup(&buf[2], GFP_NOIO);
  862. break;
  863. }
  864. }
  865. printk(KERN_INFO "Nexio device: %s, firmware version: %s\n",
  866. device_name, firmware_ver);
  867. kfree(firmware_ver);
  868. kfree(device_name);
  869. usb_fill_bulk_urb(priv->ack, dev, usb_sndbulkpipe(dev, output_ep),
  870. priv->ack_buf, sizeof(nexio_ack_pkt),
  871. nexio_ack_complete, usbtouch);
  872. return 0;
  873. }
  874. static void nexio_exit(struct usbtouch_usb *usbtouch)
  875. {
  876. struct nexio_priv *priv = usbtouch->priv;
  877. usb_kill_urb(priv->ack);
  878. usb_free_urb(priv->ack);
  879. kfree(priv->ack_buf);
  880. kfree(priv);
  881. }
  882. static int nexio_read_data(struct usbtouch_usb *usbtouch, unsigned char *pkt)
  883. {
  884. struct device *dev = &usbtouch->interface->dev;
  885. struct nexio_touch_packet *packet = (void *) pkt;
  886. struct nexio_priv *priv = usbtouch->priv;
  887. unsigned int data_len = be16_to_cpu(packet->data_len);
  888. unsigned int x_len = be16_to_cpu(packet->x_len);
  889. unsigned int y_len = be16_to_cpu(packet->y_len);
  890. int x, y, begin_x, begin_y, end_x, end_y, w, h, ret;
  891. /* got touch data? */
  892. if ((pkt[0] & 0xe0) != 0xe0)
  893. return 0;
  894. if (data_len > 0xff)
  895. data_len -= 0x100;
  896. if (x_len > 0xff)
  897. x_len -= 0x80;
  898. /* send ACK */
  899. ret = usb_submit_urb(priv->ack, GFP_ATOMIC);
  900. if (ret)
  901. dev_warn(dev, "Failed to submit ACK URB: %d\n", ret);
  902. if (!input_abs_get_max(usbtouch->input, ABS_X)) {
  903. input_set_abs_params(usbtouch->input, ABS_X,
  904. 0, 2 * x_len, 0, 0);
  905. input_set_abs_params(usbtouch->input, ABS_Y,
  906. 0, 2 * y_len, 0, 0);
  907. }
  908. /*
  909. * The device reports state of IR sensors on X and Y axes.
  910. * Each byte represents "darkness" percentage (0-100) of one element.
  911. * 17" touchscreen reports only 64 x 52 bytes so the resolution is low.
  912. * This also means that there's a limited multi-touch capability but
  913. * it's disabled (and untested) here as there's no X driver for that.
  914. */
  915. begin_x = end_x = begin_y = end_y = -1;
  916. for (x = 0; x < x_len; x++) {
  917. if (begin_x == -1 && packet->data[x] > NEXIO_THRESHOLD) {
  918. begin_x = x;
  919. continue;
  920. }
  921. if (end_x == -1 && begin_x != -1 && packet->data[x] < NEXIO_THRESHOLD) {
  922. end_x = x - 1;
  923. for (y = x_len; y < data_len; y++) {
  924. if (begin_y == -1 && packet->data[y] > NEXIO_THRESHOLD) {
  925. begin_y = y - x_len;
  926. continue;
  927. }
  928. if (end_y == -1 &&
  929. begin_y != -1 && packet->data[y] < NEXIO_THRESHOLD) {
  930. end_y = y - 1 - x_len;
  931. w = end_x - begin_x;
  932. h = end_y - begin_y;
  933. #if 0
  934. /* multi-touch */
  935. input_report_abs(usbtouch->input,
  936. ABS_MT_TOUCH_MAJOR, max(w,h));
  937. input_report_abs(usbtouch->input,
  938. ABS_MT_TOUCH_MINOR, min(x,h));
  939. input_report_abs(usbtouch->input,
  940. ABS_MT_POSITION_X, 2*begin_x+w);
  941. input_report_abs(usbtouch->input,
  942. ABS_MT_POSITION_Y, 2*begin_y+h);
  943. input_report_abs(usbtouch->input,
  944. ABS_MT_ORIENTATION, w > h);
  945. input_mt_sync(usbtouch->input);
  946. #endif
  947. /* single touch */
  948. usbtouch->x = 2 * begin_x + w;
  949. usbtouch->y = 2 * begin_y + h;
  950. usbtouch->touch = packet->flags & 0x01;
  951. begin_y = end_y = -1;
  952. return 1;
  953. }
  954. }
  955. begin_x = end_x = -1;
  956. }
  957. }
  958. return 0;
  959. }
  960. static const struct usbtouch_device_info nexio_dev_info = {
  961. .rept_size = 1024,
  962. .irq_always = true,
  963. .read_data = nexio_read_data,
  964. .alloc = nexio_alloc,
  965. .init = nexio_init,
  966. .exit = nexio_exit,
  967. };
  968. #endif
  969. /*****************************************************************************
  970. * ELO part
  971. */
  972. #ifdef CONFIG_TOUCHSCREEN_USB_ELO
  973. static int elo_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
  974. {
  975. dev->x = (pkt[3] << 8) | pkt[2];
  976. dev->y = (pkt[5] << 8) | pkt[4];
  977. dev->touch = pkt[6] > 0;
  978. dev->press = pkt[6];
  979. return 1;
  980. }
  981. static const struct usbtouch_device_info elo_dev_info = {
  982. .min_xc = 0x0,
  983. .max_xc = 0x0fff,
  984. .min_yc = 0x0,
  985. .max_yc = 0x0fff,
  986. .max_press = 0xff,
  987. .rept_size = 8,
  988. .read_data = elo_read_data,
  989. };
  990. #endif
  991. /*****************************************************************************
  992. * Generic Part
  993. */
  994. static void usbtouch_process_pkt(struct usbtouch_usb *usbtouch,
  995. unsigned char *pkt, int len)
  996. {
  997. const struct usbtouch_device_info *type = usbtouch->type;
  998. if (!type->read_data(usbtouch, pkt))
  999. return;
  1000. input_report_key(usbtouch->input, BTN_TOUCH, usbtouch->touch);
  1001. if (swap_xy) {
  1002. input_report_abs(usbtouch->input, ABS_X, usbtouch->y);
  1003. input_report_abs(usbtouch->input, ABS_Y, usbtouch->x);
  1004. } else {
  1005. input_report_abs(usbtouch->input, ABS_X, usbtouch->x);
  1006. input_report_abs(usbtouch->input, ABS_Y, usbtouch->y);
  1007. }
  1008. if (type->max_press)
  1009. input_report_abs(usbtouch->input, ABS_PRESSURE, usbtouch->press);
  1010. input_sync(usbtouch->input);
  1011. }
  1012. #ifdef MULTI_PACKET
  1013. static void usbtouch_process_multi(struct usbtouch_usb *usbtouch,
  1014. unsigned char *pkt, int len)
  1015. {
  1016. unsigned char *buffer;
  1017. int pkt_len, pos, buf_len, tmp;
  1018. /* process buffer */
  1019. if (unlikely(usbtouch->buf_len)) {
  1020. /* try to get size */
  1021. pkt_len = usbtouch->type->get_pkt_len(
  1022. usbtouch->buffer, usbtouch->buf_len);
  1023. /* drop? */
  1024. if (unlikely(!pkt_len))
  1025. goto out_flush_buf;
  1026. /* need to append -pkt_len bytes before able to get size */
  1027. if (unlikely(pkt_len < 0)) {
  1028. int append = -pkt_len;
  1029. if (unlikely(append > len))
  1030. append = len;
  1031. if (usbtouch->buf_len + append >= usbtouch->type->rept_size)
  1032. goto out_flush_buf;
  1033. memcpy(usbtouch->buffer + usbtouch->buf_len, pkt, append);
  1034. usbtouch->buf_len += append;
  1035. pkt_len = usbtouch->type->get_pkt_len(
  1036. usbtouch->buffer, usbtouch->buf_len);
  1037. if (pkt_len < 0)
  1038. return;
  1039. }
  1040. /* append */
  1041. tmp = pkt_len - usbtouch->buf_len;
  1042. if (usbtouch->buf_len + tmp >= usbtouch->type->rept_size)
  1043. goto out_flush_buf;
  1044. memcpy(usbtouch->buffer + usbtouch->buf_len, pkt, tmp);
  1045. usbtouch_process_pkt(usbtouch, usbtouch->buffer, pkt_len);
  1046. buffer = pkt + tmp;
  1047. buf_len = len - tmp;
  1048. } else {
  1049. buffer = pkt;
  1050. buf_len = len;
  1051. }
  1052. /* loop over the received packet, process */
  1053. pos = 0;
  1054. while (pos < buf_len) {
  1055. /* get packet len */
  1056. pkt_len = usbtouch->type->get_pkt_len(buffer + pos,
  1057. buf_len - pos);
  1058. /* unknown packet: skip one byte */
  1059. if (unlikely(!pkt_len)) {
  1060. pos++;
  1061. continue;
  1062. }
  1063. /* full packet: process */
  1064. if (likely((pkt_len > 0) && (pkt_len <= buf_len - pos))) {
  1065. usbtouch_process_pkt(usbtouch, buffer + pos, pkt_len);
  1066. } else {
  1067. /* incomplete packet: save in buffer */
  1068. memcpy(usbtouch->buffer, buffer + pos, buf_len - pos);
  1069. usbtouch->buf_len = buf_len - pos;
  1070. return;
  1071. }
  1072. pos += pkt_len;
  1073. }
  1074. out_flush_buf:
  1075. usbtouch->buf_len = 0;
  1076. return;
  1077. }
  1078. #else
  1079. static void usbtouch_process_multi(struct usbtouch_usb *usbtouch,
  1080. unsigned char *pkt, int len)
  1081. {
  1082. dev_WARN_ONCE(&usbtouch->interface->dev, 1,
  1083. "Protocol has ->get_pkt_len() without #define MULTI_PACKET");
  1084. }
  1085. #endif
  1086. static void usbtouch_irq(struct urb *urb)
  1087. {
  1088. struct usbtouch_usb *usbtouch = urb->context;
  1089. struct device *dev = &usbtouch->interface->dev;
  1090. int retval;
  1091. switch (urb->status) {
  1092. case 0:
  1093. /* success */
  1094. break;
  1095. case -ETIME:
  1096. /* this urb is timing out */
  1097. dev_dbg(dev,
  1098. "%s - urb timed out - was the device unplugged?\n",
  1099. __func__);
  1100. return;
  1101. case -ECONNRESET:
  1102. case -ENOENT:
  1103. case -ESHUTDOWN:
  1104. case -EPIPE:
  1105. /* this urb is terminated, clean up */
  1106. dev_dbg(dev, "%s - urb shutting down with status: %d\n",
  1107. __func__, urb->status);
  1108. return;
  1109. default:
  1110. dev_dbg(dev, "%s - nonzero urb status received: %d\n",
  1111. __func__, urb->status);
  1112. goto exit;
  1113. }
  1114. usbtouch->process_pkt(usbtouch, usbtouch->data, urb->actual_length);
  1115. exit:
  1116. usb_mark_last_busy(interface_to_usbdev(usbtouch->interface));
  1117. retval = usb_submit_urb(urb, GFP_ATOMIC);
  1118. if (retval)
  1119. dev_err(dev, "%s - usb_submit_urb failed with result: %d\n",
  1120. __func__, retval);
  1121. }
  1122. static int usbtouch_start_io(struct usbtouch_usb *usbtouch)
  1123. {
  1124. guard(mutex)(&usbtouch->pm_mutex);
  1125. if (!usbtouch->type->irq_always)
  1126. if (usb_submit_urb(usbtouch->irq, GFP_KERNEL))
  1127. return -EIO;
  1128. usbtouch->interface->needs_remote_wakeup = 1;
  1129. usbtouch->is_open = true;
  1130. return 0;
  1131. }
  1132. static int usbtouch_open(struct input_dev *input)
  1133. {
  1134. struct usbtouch_usb *usbtouch = input_get_drvdata(input);
  1135. int r;
  1136. usbtouch->irq->dev = interface_to_usbdev(usbtouch->interface);
  1137. r = usb_autopm_get_interface(usbtouch->interface) ? -EIO : 0;
  1138. if (r)
  1139. return r;
  1140. r = usbtouch_start_io(usbtouch);
  1141. usb_autopm_put_interface(usbtouch->interface);
  1142. return r;
  1143. }
  1144. static void usbtouch_close(struct input_dev *input)
  1145. {
  1146. struct usbtouch_usb *usbtouch = input_get_drvdata(input);
  1147. int r;
  1148. scoped_guard(mutex, &usbtouch->pm_mutex) {
  1149. if (!usbtouch->type->irq_always)
  1150. usb_kill_urb(usbtouch->irq);
  1151. usbtouch->is_open = false;
  1152. }
  1153. r = usb_autopm_get_interface(usbtouch->interface);
  1154. usbtouch->interface->needs_remote_wakeup = 0;
  1155. if (!r)
  1156. usb_autopm_put_interface(usbtouch->interface);
  1157. }
  1158. static int usbtouch_suspend(struct usb_interface *intf, pm_message_t message)
  1159. {
  1160. struct usbtouch_usb *usbtouch = usb_get_intfdata(intf);
  1161. usb_kill_urb(usbtouch->irq);
  1162. return 0;
  1163. }
  1164. static int usbtouch_resume(struct usb_interface *intf)
  1165. {
  1166. struct usbtouch_usb *usbtouch = usb_get_intfdata(intf);
  1167. guard(mutex)(&usbtouch->pm_mutex);
  1168. if (usbtouch->is_open || usbtouch->type->irq_always)
  1169. return usb_submit_urb(usbtouch->irq, GFP_NOIO);
  1170. return 0;
  1171. }
  1172. static int usbtouch_reset_resume(struct usb_interface *intf)
  1173. {
  1174. struct usbtouch_usb *usbtouch = usb_get_intfdata(intf);
  1175. int err;
  1176. /* reinit the device */
  1177. if (usbtouch->type->init) {
  1178. err = usbtouch->type->init(usbtouch);
  1179. if (err) {
  1180. dev_dbg(&intf->dev,
  1181. "%s - type->init() failed, err: %d\n",
  1182. __func__, err);
  1183. return err;
  1184. }
  1185. }
  1186. /* restart IO if needed */
  1187. guard(mutex)(&usbtouch->pm_mutex);
  1188. if (usbtouch->is_open)
  1189. return usb_submit_urb(usbtouch->irq, GFP_NOIO);
  1190. return 0;
  1191. }
  1192. static void usbtouch_free_buffers(struct usb_device *udev,
  1193. struct usbtouch_usb *usbtouch)
  1194. {
  1195. usb_free_coherent(udev, usbtouch->data_size,
  1196. usbtouch->data, usbtouch->data_dma);
  1197. kfree(usbtouch->buffer);
  1198. }
  1199. static struct usb_endpoint_descriptor *
  1200. usbtouch_get_input_endpoint(struct usb_host_interface *interface)
  1201. {
  1202. int i;
  1203. for (i = 0; i < interface->desc.bNumEndpoints; i++)
  1204. if (usb_endpoint_dir_in(&interface->endpoint[i].desc))
  1205. return &interface->endpoint[i].desc;
  1206. return NULL;
  1207. }
  1208. static int usbtouch_probe(struct usb_interface *intf,
  1209. const struct usb_device_id *id)
  1210. {
  1211. struct usbtouch_usb *usbtouch;
  1212. struct input_dev *input_dev;
  1213. struct usb_endpoint_descriptor *endpoint;
  1214. struct usb_device *udev = interface_to_usbdev(intf);
  1215. const struct usbtouch_device_info *type;
  1216. int err = -ENOMEM;
  1217. /* some devices are ignored */
  1218. type = (const struct usbtouch_device_info *)id->driver_info;
  1219. if (!type)
  1220. return -ENODEV;
  1221. endpoint = usbtouch_get_input_endpoint(intf->cur_altsetting);
  1222. if (!endpoint)
  1223. return -ENXIO;
  1224. usbtouch = kzalloc_obj(*usbtouch);
  1225. input_dev = input_allocate_device();
  1226. if (!usbtouch || !input_dev)
  1227. goto out_free;
  1228. mutex_init(&usbtouch->pm_mutex);
  1229. usbtouch->type = type;
  1230. usbtouch->data_size = type->rept_size;
  1231. if (type->get_pkt_len) {
  1232. /*
  1233. * When dealing with variable-length packets we should
  1234. * not request more than wMaxPacketSize bytes at once
  1235. * as we do not know if there is more data coming or
  1236. * we filled exactly wMaxPacketSize bytes and there is
  1237. * nothing else.
  1238. */
  1239. usbtouch->data_size = min(usbtouch->data_size,
  1240. usb_endpoint_maxp(endpoint));
  1241. }
  1242. usbtouch->data = usb_alloc_coherent(udev, usbtouch->data_size,
  1243. GFP_KERNEL, &usbtouch->data_dma);
  1244. if (!usbtouch->data)
  1245. goto out_free;
  1246. if (type->get_pkt_len) {
  1247. usbtouch->buffer = kmalloc(type->rept_size, GFP_KERNEL);
  1248. if (!usbtouch->buffer)
  1249. goto out_free_buffers;
  1250. usbtouch->process_pkt = usbtouch_process_multi;
  1251. } else {
  1252. usbtouch->process_pkt = usbtouch_process_pkt;
  1253. }
  1254. usbtouch->irq = usb_alloc_urb(0, GFP_KERNEL);
  1255. if (!usbtouch->irq) {
  1256. dev_dbg(&intf->dev,
  1257. "%s - usb_alloc_urb failed: usbtouch->irq\n", __func__);
  1258. goto out_free_buffers;
  1259. }
  1260. usbtouch->interface = intf;
  1261. usbtouch->input = input_dev;
  1262. if (udev->manufacturer)
  1263. strscpy(usbtouch->name, udev->manufacturer, sizeof(usbtouch->name));
  1264. if (udev->product) {
  1265. if (udev->manufacturer)
  1266. strlcat(usbtouch->name, " ", sizeof(usbtouch->name));
  1267. strlcat(usbtouch->name, udev->product, sizeof(usbtouch->name));
  1268. }
  1269. if (!strlen(usbtouch->name))
  1270. snprintf(usbtouch->name, sizeof(usbtouch->name),
  1271. "USB Touchscreen %04x:%04x",
  1272. le16_to_cpu(udev->descriptor.idVendor),
  1273. le16_to_cpu(udev->descriptor.idProduct));
  1274. usb_make_path(udev, usbtouch->phys, sizeof(usbtouch->phys));
  1275. strlcat(usbtouch->phys, "/input0", sizeof(usbtouch->phys));
  1276. input_dev->name = usbtouch->name;
  1277. input_dev->phys = usbtouch->phys;
  1278. usb_to_input_id(udev, &input_dev->id);
  1279. input_dev->dev.parent = &intf->dev;
  1280. input_set_drvdata(input_dev, usbtouch);
  1281. input_dev->open = usbtouch_open;
  1282. input_dev->close = usbtouch_close;
  1283. input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
  1284. input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
  1285. input_set_abs_params(input_dev, ABS_X, type->min_xc, type->max_xc, 0, 0);
  1286. input_set_abs_params(input_dev, ABS_Y, type->min_yc, type->max_yc, 0, 0);
  1287. if (type->max_press)
  1288. input_set_abs_params(input_dev, ABS_PRESSURE, type->min_press,
  1289. type->max_press, 0, 0);
  1290. if (usb_endpoint_type(endpoint) == USB_ENDPOINT_XFER_INT)
  1291. usb_fill_int_urb(usbtouch->irq, udev,
  1292. usb_rcvintpipe(udev, endpoint->bEndpointAddress),
  1293. usbtouch->data, usbtouch->data_size,
  1294. usbtouch_irq, usbtouch, endpoint->bInterval);
  1295. else
  1296. usb_fill_bulk_urb(usbtouch->irq, udev,
  1297. usb_rcvbulkpipe(udev, endpoint->bEndpointAddress),
  1298. usbtouch->data, usbtouch->data_size,
  1299. usbtouch_irq, usbtouch);
  1300. usbtouch->irq->dev = udev;
  1301. usbtouch->irq->transfer_dma = usbtouch->data_dma;
  1302. usbtouch->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
  1303. /* device specific allocations */
  1304. if (type->alloc) {
  1305. err = type->alloc(usbtouch);
  1306. if (err) {
  1307. dev_dbg(&intf->dev,
  1308. "%s - type->alloc() failed, err: %d\n",
  1309. __func__, err);
  1310. goto out_free_urb;
  1311. }
  1312. }
  1313. /* device specific initialisation*/
  1314. if (type->init) {
  1315. err = type->init(usbtouch);
  1316. if (err) {
  1317. dev_dbg(&intf->dev,
  1318. "%s - type->init() failed, err: %d\n",
  1319. __func__, err);
  1320. goto out_do_exit;
  1321. }
  1322. }
  1323. err = input_register_device(usbtouch->input);
  1324. if (err) {
  1325. dev_dbg(&intf->dev,
  1326. "%s - input_register_device failed, err: %d\n",
  1327. __func__, err);
  1328. goto out_do_exit;
  1329. }
  1330. usb_set_intfdata(intf, usbtouch);
  1331. if (usbtouch->type->irq_always) {
  1332. /* this can't fail */
  1333. usb_autopm_get_interface(intf);
  1334. err = usb_submit_urb(usbtouch->irq, GFP_KERNEL);
  1335. if (err) {
  1336. usb_autopm_put_interface(intf);
  1337. dev_err(&intf->dev,
  1338. "%s - usb_submit_urb failed with result: %d\n",
  1339. __func__, err);
  1340. goto out_unregister_input;
  1341. }
  1342. }
  1343. return 0;
  1344. out_unregister_input:
  1345. input_unregister_device(input_dev);
  1346. input_dev = NULL;
  1347. out_do_exit:
  1348. if (type->exit)
  1349. type->exit(usbtouch);
  1350. out_free_urb:
  1351. usb_free_urb(usbtouch->irq);
  1352. out_free_buffers:
  1353. usbtouch_free_buffers(udev, usbtouch);
  1354. out_free:
  1355. input_free_device(input_dev);
  1356. kfree(usbtouch);
  1357. return err;
  1358. }
  1359. static void usbtouch_disconnect(struct usb_interface *intf)
  1360. {
  1361. struct usbtouch_usb *usbtouch = usb_get_intfdata(intf);
  1362. if (!usbtouch)
  1363. return;
  1364. dev_dbg(&intf->dev,
  1365. "%s - usbtouch is initialized, cleaning up\n", __func__);
  1366. usb_set_intfdata(intf, NULL);
  1367. /* this will stop IO via close */
  1368. input_unregister_device(usbtouch->input);
  1369. usb_free_urb(usbtouch->irq);
  1370. if (usbtouch->type->exit)
  1371. usbtouch->type->exit(usbtouch);
  1372. usbtouch_free_buffers(interface_to_usbdev(intf), usbtouch);
  1373. kfree(usbtouch);
  1374. }
  1375. static const struct attribute_group *usbtouch_groups[] = {
  1376. #ifdef CONFIG_TOUCHSCREEN_USB_3M
  1377. &mtouch_attr_group,
  1378. #endif
  1379. NULL
  1380. };
  1381. static const struct usb_device_id usbtouch_devices[] = {
  1382. #ifdef CONFIG_TOUCHSCREEN_USB_EGALAX
  1383. /* ignore the HID capable devices, handled by usbhid */
  1384. { USB_DEVICE_INTERFACE_CLASS(0x0eef, 0x0001, USB_INTERFACE_CLASS_HID),
  1385. .driver_info = 0 },
  1386. { USB_DEVICE_INTERFACE_CLASS(0x0eef, 0x0002, USB_INTERFACE_CLASS_HID),
  1387. .driver_info = 0 },
  1388. /* normal device IDs */
  1389. { USB_DEVICE(0x3823, 0x0001),
  1390. .driver_info = (kernel_ulong_t)&egalax_dev_info },
  1391. { USB_DEVICE(0x3823, 0x0002),
  1392. .driver_info = (kernel_ulong_t)&egalax_dev_info },
  1393. { USB_DEVICE(0x0123, 0x0001),
  1394. .driver_info = (kernel_ulong_t)&egalax_dev_info },
  1395. { USB_DEVICE(0x0eef, 0x0001),
  1396. .driver_info = (kernel_ulong_t)&egalax_dev_info },
  1397. { USB_DEVICE(0x0eef, 0x0002),
  1398. .driver_info = (kernel_ulong_t)&egalax_dev_info },
  1399. { USB_DEVICE(0x1234, 0x0001),
  1400. .driver_info = (kernel_ulong_t)&egalax_dev_info },
  1401. { USB_DEVICE(0x1234, 0x0002),
  1402. .driver_info = (kernel_ulong_t)&egalax_dev_info },
  1403. #endif
  1404. #ifdef CONFIG_TOUCHSCREEN_USB_PANJIT
  1405. { USB_DEVICE(0x134c, 0x0001),
  1406. .driver_info = (kernel_ulong_t)&panjit_dev_info },
  1407. { USB_DEVICE(0x134c, 0x0002),
  1408. .driver_info = (kernel_ulong_t)&panjit_dev_info },
  1409. { USB_DEVICE(0x134c, 0x0003),
  1410. .driver_info = (kernel_ulong_t)&panjit_dev_info },
  1411. { USB_DEVICE(0x134c, 0x0004),
  1412. .driver_info = (kernel_ulong_t)&panjit_dev_info },
  1413. #endif
  1414. #ifdef CONFIG_TOUCHSCREEN_USB_3M
  1415. { USB_DEVICE(0x0596, 0x0001),
  1416. .driver_info = (kernel_ulong_t)&mtouch_dev_info },
  1417. #endif
  1418. #ifdef CONFIG_TOUCHSCREEN_USB_ITM
  1419. { USB_DEVICE(0x0403, 0xf9e9),
  1420. .driver_info = (kernel_ulong_t)&itm_dev_info },
  1421. { USB_DEVICE(0x16e3, 0xf9e9),
  1422. .driver_info = (kernel_ulong_t)&itm_dev_info },
  1423. #endif
  1424. #ifdef CONFIG_TOUCHSCREEN_USB_ETURBO
  1425. { USB_DEVICE(0x1234, 0x5678),
  1426. .driver_info = (kernel_ulong_t)&eturbo_dev_info },
  1427. #endif
  1428. #ifdef CONFIG_TOUCHSCREEN_USB_GUNZE
  1429. { USB_DEVICE(0x0637, 0x0001),
  1430. .driver_info = (kernel_ulong_t)&gunze_dev_info },
  1431. #endif
  1432. #ifdef CONFIG_TOUCHSCREEN_USB_DMC_TSC10
  1433. { USB_DEVICE(0x0afa, 0x03e8),
  1434. .driver_info = (kernel_ulong_t)&dmc_tsc10_dev_info },
  1435. #endif
  1436. #ifdef CONFIG_TOUCHSCREEN_USB_IRTOUCH
  1437. { USB_DEVICE(0x255e, 0x0001),
  1438. .driver_info = (kernel_ulong_t)&irtouch_dev_info },
  1439. { USB_DEVICE(0x595a, 0x0001),
  1440. .driver_info = (kernel_ulong_t)&irtouch_dev_info },
  1441. { USB_DEVICE(0x6615, 0x0001),
  1442. .driver_info = (kernel_ulong_t)&irtouch_dev_info },
  1443. { USB_DEVICE(0x6615, 0x0012),
  1444. .driver_info = (kernel_ulong_t)&irtouch_hires_dev_info },
  1445. #endif
  1446. #ifdef CONFIG_TOUCHSCREEN_USB_IDEALTEK
  1447. { USB_DEVICE(0x1391, 0x1000),
  1448. .driver_info = (kernel_ulong_t)&idealtek_dev_info },
  1449. #endif
  1450. #ifdef CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH
  1451. { USB_DEVICE(0x0dfc, 0x0001),
  1452. .driver_info = (kernel_ulong_t)&general_touch_dev_info },
  1453. #endif
  1454. #ifdef CONFIG_TOUCHSCREEN_USB_GOTOP
  1455. { USB_DEVICE(0x08f2, 0x007f),
  1456. .driver_info = (kernel_ulong_t)&gotop_dev_info },
  1457. { USB_DEVICE(0x08f2, 0x00ce),
  1458. .driver_info = (kernel_ulong_t)&gotop_dev_info },
  1459. { USB_DEVICE(0x08f2, 0x00f4),
  1460. .driver_info = (kernel_ulong_t)&gotop_dev_info },
  1461. #endif
  1462. #ifdef CONFIG_TOUCHSCREEN_USB_JASTEC
  1463. { USB_DEVICE(0x0f92, 0x0001),
  1464. .driver_info = (kernel_ulong_t)&jastec_dev_info },
  1465. #endif
  1466. #ifdef CONFIG_TOUCHSCREEN_USB_E2I
  1467. { USB_DEVICE(0x1ac7, 0x0001),
  1468. .driver_info = (kernel_ulong_t)&e2i_dev_info },
  1469. #endif
  1470. #ifdef CONFIG_TOUCHSCREEN_USB_ZYTRONIC
  1471. { USB_DEVICE(0x14c8, 0x0003),
  1472. .driver_info = (kernel_ulong_t)&zytronic_dev_info },
  1473. #endif
  1474. #ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC45USB
  1475. /* TC5UH */
  1476. { USB_DEVICE(0x0664, 0x0309),
  1477. .driver_info = (kernel_ulong_t)&tc45usb_dev_info },
  1478. /* TC4UM */
  1479. { USB_DEVICE(0x0664, 0x0306),
  1480. .driver_info = (kernel_ulong_t)&tc45usb_dev_info },
  1481. #endif
  1482. #ifdef CONFIG_TOUCHSCREEN_USB_NEXIO
  1483. /* data interface only */
  1484. { USB_DEVICE_AND_INTERFACE_INFO(0x10f0, 0x2002, 0x0a, 0x00, 0x00),
  1485. .driver_info = (kernel_ulong_t)&nexio_dev_info },
  1486. { USB_DEVICE_AND_INTERFACE_INFO(0x1870, 0x0001, 0x0a, 0x00, 0x00),
  1487. .driver_info = (kernel_ulong_t)&nexio_dev_info },
  1488. #endif
  1489. #ifdef CONFIG_TOUCHSCREEN_USB_ELO
  1490. { USB_DEVICE(0x04e7, 0x0020),
  1491. .driver_info = (kernel_ulong_t)&elo_dev_info },
  1492. #endif
  1493. #ifdef CONFIG_TOUCHSCREEN_USB_EASYTOUCH
  1494. { USB_DEVICE(0x7374, 0x0001),
  1495. .driver_info = (kernel_ulong_t)&etouch_dev_info },
  1496. #endif
  1497. { }
  1498. };
  1499. MODULE_DEVICE_TABLE(usb, usbtouch_devices);
  1500. static struct usb_driver usbtouch_driver = {
  1501. .name = "usbtouchscreen",
  1502. .probe = usbtouch_probe,
  1503. .disconnect = usbtouch_disconnect,
  1504. .suspend = usbtouch_suspend,
  1505. .resume = usbtouch_resume,
  1506. .reset_resume = usbtouch_reset_resume,
  1507. .id_table = usbtouch_devices,
  1508. .dev_groups = usbtouch_groups,
  1509. .supports_autosuspend = 1,
  1510. };
  1511. module_usb_driver(usbtouch_driver);
  1512. MODULE_AUTHOR("Daniel Ritz <daniel.ritz@gmx.ch>");
  1513. MODULE_DESCRIPTION("USB Touchscreen Driver");
  1514. MODULE_LICENSE("GPL");
  1515. MODULE_ALIAS("touchkitusb");
  1516. MODULE_ALIAS("itmtouch");
  1517. MODULE_ALIAS("mtouchusb");