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