1 /******************************************************************************
3 * Driver for USB Touchscreens, supporting those devices:
5 * includes eTurboTouch CT-410/510/700
6 * - 3M/Microtouch EX II series
12 * - IRTOUCHSYSTEMS/UNITOP
15 * - GoTop Super_Q2/GogoPen/PenPower tablets
16 * - JASTEC USB touch controller/DigiTech DTR-02U
17 * - Zytronic capacitive touchscreen
19 * - Elo TouchSystems 2700 IntelliTouch
20 * - EasyTouch USB Dual/Multi touch controller from Data Modul
22 * Copyright (C) 2004-2007 by Daniel Ritz <daniel.ritz@gmx.ch>
23 * Copyright (C) by Todd E. Johnson (mtouchusb.c)
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.
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.
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.
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
46 *****************************************************************************/
50 #include <linux/kernel.h>
51 #include <linux/slab.h>
52 #include <linux/input.h>
53 #include <linux/module.h>
54 #include <linux/init.h>
55 #include <linux/usb.h>
56 #include <linux/usb/input.h>
57 #include <linux/hid.h>
60 #define DRIVER_VERSION "v0.6"
61 #define DRIVER_AUTHOR "Daniel Ritz <daniel.ritz@gmx.ch>"
62 #define DRIVER_DESC "USB Touchscreen Driver"
65 module_param(swap_xy
, bool, 0644);
66 MODULE_PARM_DESC(swap_xy
, "If set X and Y axes are swapped.");
68 static bool hwcalib_xy
;
69 module_param(hwcalib_xy
, bool, 0644);
70 MODULE_PARM_DESC(hwcalib_xy
, "If set hw-calibrated X/Y are used if available");
72 /* device specifc data/functions */
74 struct usbtouch_device_info
{
77 int min_press
, max_press
;
81 * Always service the USB devices irq not just when the input device is
82 * open. This is useful when devices have a watchdog which prevents us
83 * from periodically polling the device. Leave this unset unless your
84 * touchscreen device requires it, as it does consume more of the USB
89 void (*process_pkt
) (struct usbtouch_usb
*usbtouch
, unsigned char *pkt
, int len
);
92 * used to get the packet len. possible return values:
95 * < 0: -return value more bytes needed
97 int (*get_pkt_len
) (unsigned char *pkt
, int len
);
99 int (*read_data
) (struct usbtouch_usb
*usbtouch
, unsigned char *pkt
);
100 int (*alloc
) (struct usbtouch_usb
*usbtouch
);
101 int (*init
) (struct usbtouch_usb
*usbtouch
);
102 void (*exit
) (struct usbtouch_usb
*usbtouch
);
105 /* a usbtouch device */
106 struct usbtouch_usb
{
109 unsigned char *buffer
;
112 struct usb_interface
*interface
;
113 struct input_dev
*input
;
114 struct usbtouch_device_info
*type
;
136 DEVTYPE_GENERAL_TOUCH
,
147 #define USB_DEVICE_HID_CLASS(vend, prod) \
148 .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS \
149 | USB_DEVICE_ID_MATCH_INT_PROTOCOL \
150 | USB_DEVICE_ID_MATCH_DEVICE, \
151 .idVendor = (vend), \
152 .idProduct = (prod), \
153 .bInterfaceClass = USB_INTERFACE_CLASS_HID, \
154 .bInterfaceProtocol = USB_INTERFACE_PROTOCOL_MOUSE
156 static const struct usb_device_id usbtouch_devices
[] = {
157 #ifdef CONFIG_TOUCHSCREEN_USB_EGALAX
158 /* ignore the HID capable devices, handled by usbhid */
159 {USB_DEVICE_HID_CLASS(0x0eef, 0x0001), .driver_info
= DEVTYPE_IGNORE
},
160 {USB_DEVICE_HID_CLASS(0x0eef, 0x0002), .driver_info
= DEVTYPE_IGNORE
},
162 /* normal device IDs */
163 {USB_DEVICE(0x3823, 0x0001), .driver_info
= DEVTYPE_EGALAX
},
164 {USB_DEVICE(0x3823, 0x0002), .driver_info
= DEVTYPE_EGALAX
},
165 {USB_DEVICE(0x0123, 0x0001), .driver_info
= DEVTYPE_EGALAX
},
166 {USB_DEVICE(0x0eef, 0x0001), .driver_info
= DEVTYPE_EGALAX
},
167 {USB_DEVICE(0x0eef, 0x0002), .driver_info
= DEVTYPE_EGALAX
},
168 {USB_DEVICE(0x1234, 0x0001), .driver_info
= DEVTYPE_EGALAX
},
169 {USB_DEVICE(0x1234, 0x0002), .driver_info
= DEVTYPE_EGALAX
},
172 #ifdef CONFIG_TOUCHSCREEN_USB_PANJIT
173 {USB_DEVICE(0x134c, 0x0001), .driver_info
= DEVTYPE_PANJIT
},
174 {USB_DEVICE(0x134c, 0x0002), .driver_info
= DEVTYPE_PANJIT
},
175 {USB_DEVICE(0x134c, 0x0003), .driver_info
= DEVTYPE_PANJIT
},
176 {USB_DEVICE(0x134c, 0x0004), .driver_info
= DEVTYPE_PANJIT
},
179 #ifdef CONFIG_TOUCHSCREEN_USB_3M
180 {USB_DEVICE(0x0596, 0x0001), .driver_info
= DEVTYPE_3M
},
183 #ifdef CONFIG_TOUCHSCREEN_USB_ITM
184 {USB_DEVICE(0x0403, 0xf9e9), .driver_info
= DEVTYPE_ITM
},
185 {USB_DEVICE(0x16e3, 0xf9e9), .driver_info
= DEVTYPE_ITM
},
188 #ifdef CONFIG_TOUCHSCREEN_USB_ETURBO
189 {USB_DEVICE(0x1234, 0x5678), .driver_info
= DEVTYPE_ETURBO
},
192 #ifdef CONFIG_TOUCHSCREEN_USB_GUNZE
193 {USB_DEVICE(0x0637, 0x0001), .driver_info
= DEVTYPE_GUNZE
},
196 #ifdef CONFIG_TOUCHSCREEN_USB_DMC_TSC10
197 {USB_DEVICE(0x0afa, 0x03e8), .driver_info
= DEVTYPE_DMC_TSC10
},
200 #ifdef CONFIG_TOUCHSCREEN_USB_IRTOUCH
201 {USB_DEVICE(0x595a, 0x0001), .driver_info
= DEVTYPE_IRTOUCH
},
202 {USB_DEVICE(0x6615, 0x0001), .driver_info
= DEVTYPE_IRTOUCH
},
205 #ifdef CONFIG_TOUCHSCREEN_USB_IDEALTEK
206 {USB_DEVICE(0x1391, 0x1000), .driver_info
= DEVTYPE_IDEALTEK
},
209 #ifdef CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH
210 {USB_DEVICE(0x0dfc, 0x0001), .driver_info
= DEVTYPE_GENERAL_TOUCH
},
213 #ifdef CONFIG_TOUCHSCREEN_USB_GOTOP
214 {USB_DEVICE(0x08f2, 0x007f), .driver_info
= DEVTYPE_GOTOP
},
215 {USB_DEVICE(0x08f2, 0x00ce), .driver_info
= DEVTYPE_GOTOP
},
216 {USB_DEVICE(0x08f2, 0x00f4), .driver_info
= DEVTYPE_GOTOP
},
219 #ifdef CONFIG_TOUCHSCREEN_USB_JASTEC
220 {USB_DEVICE(0x0f92, 0x0001), .driver_info
= DEVTYPE_JASTEC
},
223 #ifdef CONFIG_TOUCHSCREEN_USB_E2I
224 {USB_DEVICE(0x1ac7, 0x0001), .driver_info
= DEVTYPE_E2I
},
227 #ifdef CONFIG_TOUCHSCREEN_USB_ZYTRONIC
228 {USB_DEVICE(0x14c8, 0x0003), .driver_info
= DEVTYPE_ZYTRONIC
},
231 #ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC45USB
233 {USB_DEVICE(0x0664, 0x0309), .driver_info
= DEVTYPE_TC45USB
},
235 {USB_DEVICE(0x0664, 0x0306), .driver_info
= DEVTYPE_TC45USB
},
238 #ifdef CONFIG_TOUCHSCREEN_USB_NEXIO
239 /* data interface only */
240 {USB_DEVICE_AND_INTERFACE_INFO(0x10f0, 0x2002, 0x0a, 0x00, 0x00),
241 .driver_info
= DEVTYPE_NEXIO
},
242 {USB_DEVICE_AND_INTERFACE_INFO(0x1870, 0x0001, 0x0a, 0x00, 0x00),
243 .driver_info
= DEVTYPE_NEXIO
},
246 #ifdef CONFIG_TOUCHSCREEN_USB_ELO
247 {USB_DEVICE(0x04e7, 0x0020), .driver_info
= DEVTYPE_ELO
},
250 #ifdef CONFIG_TOUCHSCREEN_USB_EASYTOUCH
251 {USB_DEVICE(0x7374, 0x0001), .driver_info
= DEVTYPE_ETOUCH
},
258 /*****************************************************************************
262 #ifdef CONFIG_TOUCHSCREEN_USB_E2I
263 static int e2i_init(struct usbtouch_usb
*usbtouch
)
266 struct usb_device
*udev
= interface_to_usbdev(usbtouch
->interface
);
268 ret
= usb_control_msg(udev
, usb_rcvctrlpipe(udev
, 0),
269 0x01, 0x02, 0x0000, 0x0081,
270 NULL
, 0, USB_CTRL_SET_TIMEOUT
);
272 dbg("%s - usb_control_msg - E2I_RESET - bytes|err: %d",
277 static int e2i_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
279 int tmp
= (pkt
[0] << 8) | pkt
[1];
280 dev
->x
= (pkt
[2] << 8) | pkt
[3];
281 dev
->y
= (pkt
[4] << 8) | pkt
[5];
284 dev
->touch
= (tmp
> 0);
285 dev
->press
= (tmp
> 0 ? tmp
: 0);
292 /*****************************************************************************
296 #ifdef CONFIG_TOUCHSCREEN_USB_EGALAX
302 #define EGALAX_PKT_TYPE_MASK 0xFE
303 #define EGALAX_PKT_TYPE_REPT 0x80
304 #define EGALAX_PKT_TYPE_DIAG 0x0A
306 static int egalax_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
308 if ((pkt
[0] & EGALAX_PKT_TYPE_MASK
) != EGALAX_PKT_TYPE_REPT
)
311 dev
->x
= ((pkt
[3] & 0x0F) << 7) | (pkt
[4] & 0x7F);
312 dev
->y
= ((pkt
[1] & 0x0F) << 7) | (pkt
[2] & 0x7F);
313 dev
->touch
= pkt
[0] & 0x01;
318 static int egalax_get_pkt_len(unsigned char *buf
, int len
)
320 switch (buf
[0] & EGALAX_PKT_TYPE_MASK
) {
321 case EGALAX_PKT_TYPE_REPT
:
324 case EGALAX_PKT_TYPE_DIAG
:
335 /*****************************************************************************
339 #ifdef CONFIG_TOUCHSCREEN_USB_EASYTOUCH
345 #define ETOUCH_PKT_TYPE_MASK 0xFE
346 #define ETOUCH_PKT_TYPE_REPT 0x80
347 #define ETOUCH_PKT_TYPE_REPT2 0xB0
348 #define ETOUCH_PKT_TYPE_DIAG 0x0A
350 static int etouch_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
352 if ((pkt
[0] & ETOUCH_PKT_TYPE_MASK
) != ETOUCH_PKT_TYPE_REPT
&&
353 (pkt
[0] & ETOUCH_PKT_TYPE_MASK
) != ETOUCH_PKT_TYPE_REPT2
)
356 dev
->x
= ((pkt
[1] & 0x1F) << 7) | (pkt
[2] & 0x7F);
357 dev
->y
= ((pkt
[3] & 0x1F) << 7) | (pkt
[4] & 0x7F);
358 dev
->touch
= pkt
[0] & 0x01;
363 static int etouch_get_pkt_len(unsigned char *buf
, int len
)
365 switch (buf
[0] & ETOUCH_PKT_TYPE_MASK
) {
366 case ETOUCH_PKT_TYPE_REPT
:
367 case ETOUCH_PKT_TYPE_REPT2
:
370 case ETOUCH_PKT_TYPE_DIAG
:
381 /*****************************************************************************
384 #ifdef CONFIG_TOUCHSCREEN_USB_PANJIT
385 static int panjit_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
387 dev
->x
= ((pkt
[2] & 0x0F) << 8) | pkt
[1];
388 dev
->y
= ((pkt
[4] & 0x0F) << 8) | pkt
[3];
389 dev
->touch
= pkt
[0] & 0x01;
396 /*****************************************************************************
399 #ifdef CONFIG_TOUCHSCREEN_USB_3M
401 #define MTOUCHUSB_ASYNC_REPORT 1
402 #define MTOUCHUSB_RESET 7
403 #define MTOUCHUSB_REQ_CTRLLR_ID 10
405 static int mtouch_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
408 dev
->x
= (pkt
[4] << 8) | pkt
[3];
409 dev
->y
= 0xffff - ((pkt
[6] << 8) | pkt
[5]);
411 dev
->x
= (pkt
[8] << 8) | pkt
[7];
412 dev
->y
= (pkt
[10] << 8) | pkt
[9];
414 dev
->touch
= (pkt
[2] & 0x40) ? 1 : 0;
419 static int mtouch_init(struct usbtouch_usb
*usbtouch
)
422 struct usb_device
*udev
= interface_to_usbdev(usbtouch
->interface
);
424 ret
= usb_control_msg(udev
, usb_rcvctrlpipe(udev
, 0),
426 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
427 1, 0, NULL
, 0, USB_CTRL_SET_TIMEOUT
);
428 dbg("%s - usb_control_msg - MTOUCHUSB_RESET - bytes|err: %d",
434 for (i
= 0; i
< 3; i
++) {
435 ret
= usb_control_msg(udev
, usb_rcvctrlpipe(udev
, 0),
436 MTOUCHUSB_ASYNC_REPORT
,
437 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
438 1, 1, NULL
, 0, USB_CTRL_SET_TIMEOUT
);
439 dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d",
447 /* Default min/max xy are the raw values, override if using hw-calib */
449 input_set_abs_params(usbtouch
->input
, ABS_X
, 0, 0xffff, 0, 0);
450 input_set_abs_params(usbtouch
->input
, ABS_Y
, 0, 0xffff, 0, 0);
458 /*****************************************************************************
461 #ifdef CONFIG_TOUCHSCREEN_USB_ITM
462 static int itm_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
466 * ITM devices report invalid x/y data if not touched.
467 * if the screen was touched before but is not touched any more
468 * report touch as 0 with the last valid x/y data once. then stop
469 * reporting data until touched again.
471 dev
->press
= ((pkt
[2] & 0x01) << 7) | (pkt
[5] & 0x7F);
473 touch
= ~pkt
[7] & 0x20;
483 dev
->x
= ((pkt
[0] & 0x1F) << 7) | (pkt
[3] & 0x7F);
484 dev
->y
= ((pkt
[1] & 0x1F) << 7) | (pkt
[4] & 0x7F);
492 /*****************************************************************************
495 #ifdef CONFIG_TOUCHSCREEN_USB_ETURBO
499 static int eturbo_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
503 /* packets should start with sync */
504 if (!(pkt
[0] & 0x80))
507 shift
= (6 - (pkt
[0] & 0x03));
508 dev
->x
= ((pkt
[3] << 7) | pkt
[4]) >> shift
;
509 dev
->y
= ((pkt
[1] << 7) | pkt
[2]) >> shift
;
510 dev
->touch
= (pkt
[0] & 0x10) ? 1 : 0;
515 static int eturbo_get_pkt_len(unsigned char *buf
, int len
)
526 /*****************************************************************************
529 #ifdef CONFIG_TOUCHSCREEN_USB_GUNZE
530 static int gunze_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
532 if (!(pkt
[0] & 0x80) || ((pkt
[1] | pkt
[2] | pkt
[3]) & 0x80))
535 dev
->x
= ((pkt
[0] & 0x1F) << 7) | (pkt
[2] & 0x7F);
536 dev
->y
= ((pkt
[1] & 0x1F) << 7) | (pkt
[3] & 0x7F);
537 dev
->touch
= pkt
[0] & 0x20;
543 /*****************************************************************************
546 * Documentation about the controller and it's protocol can be found at
547 * http://www.dmccoltd.com/files/controler/tsc10usb_pi_e.pdf
548 * http://www.dmccoltd.com/files/controler/tsc25_usb_e.pdf
550 #ifdef CONFIG_TOUCHSCREEN_USB_DMC_TSC10
552 /* supported data rates. currently using 130 */
553 #define TSC10_RATE_POINT 0x50
554 #define TSC10_RATE_30 0x40
555 #define TSC10_RATE_50 0x41
556 #define TSC10_RATE_80 0x42
557 #define TSC10_RATE_100 0x43
558 #define TSC10_RATE_130 0x44
559 #define TSC10_RATE_150 0x45
562 #define TSC10_CMD_RESET 0x55
563 #define TSC10_CMD_RATE 0x05
564 #define TSC10_CMD_DATA1 0x01
566 static int dmc_tsc10_init(struct usbtouch_usb
*usbtouch
)
568 struct usb_device
*dev
= interface_to_usbdev(usbtouch
->interface
);
572 buf
= kmalloc(2, GFP_NOIO
);
576 buf
[0] = buf
[1] = 0xFF;
577 ret
= usb_control_msg(dev
, usb_rcvctrlpipe (dev
, 0),
579 USB_DIR_IN
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
580 0, 0, buf
, 2, USB_CTRL_SET_TIMEOUT
);
583 if (buf
[0] != 0x06) {
588 /* set coordinate output rate */
589 buf
[0] = buf
[1] = 0xFF;
590 ret
= usb_control_msg(dev
, usb_rcvctrlpipe (dev
, 0),
592 USB_DIR_IN
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
593 TSC10_RATE_150
, 0, buf
, 2, USB_CTRL_SET_TIMEOUT
);
596 if ((buf
[0] != 0x06) && (buf
[0] != 0x15 || buf
[1] != 0x01)) {
601 /* start sending data */
602 ret
= usb_control_msg(dev
, usb_rcvctrlpipe (dev
, 0),
604 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
605 0, 0, NULL
, 0, USB_CTRL_SET_TIMEOUT
);
613 static int dmc_tsc10_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
615 dev
->x
= ((pkt
[2] & 0x03) << 8) | pkt
[1];
616 dev
->y
= ((pkt
[4] & 0x03) << 8) | pkt
[3];
617 dev
->touch
= pkt
[0] & 0x01;
624 /*****************************************************************************
627 #ifdef CONFIG_TOUCHSCREEN_USB_IRTOUCH
628 static int irtouch_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
630 dev
->x
= (pkt
[3] << 8) | pkt
[2];
631 dev
->y
= (pkt
[5] << 8) | pkt
[4];
632 dev
->touch
= (pkt
[1] & 0x03) ? 1 : 0;
638 /*****************************************************************************
639 * ET&T TC5UH/TC4UM part
641 #ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC45USB
642 static int tc45usb_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
644 dev
->x
= ((pkt
[2] & 0x0F) << 8) | pkt
[1];
645 dev
->y
= ((pkt
[4] & 0x0F) << 8) | pkt
[3];
646 dev
->touch
= pkt
[0] & 0x01;
652 /*****************************************************************************
653 * IdealTEK URTC1000 Part
655 #ifdef CONFIG_TOUCHSCREEN_USB_IDEALTEK
659 static int idealtek_get_pkt_len(unsigned char *buf
, int len
)
668 static int idealtek_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
670 switch (pkt
[0] & 0x98) {
672 /* touch data in IdealTEK mode */
673 dev
->x
= (pkt
[1] << 5) | (pkt
[2] >> 2);
674 dev
->y
= (pkt
[3] << 5) | (pkt
[4] >> 2);
675 dev
->touch
= (pkt
[0] & 0x40) ? 1 : 0;
679 /* touch data in MT emulation mode */
680 dev
->x
= (pkt
[2] << 5) | (pkt
[1] >> 2);
681 dev
->y
= (pkt
[4] << 5) | (pkt
[3] >> 2);
682 dev
->touch
= (pkt
[0] & 0x40) ? 1 : 0;
691 /*****************************************************************************
694 #ifdef CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH
695 static int general_touch_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
697 dev
->x
= (pkt
[2] << 8) | pkt
[1];
698 dev
->y
= (pkt
[4] << 8) | pkt
[3];
699 dev
->press
= pkt
[5] & 0xff;
700 dev
->touch
= pkt
[0] & 0x01;
706 /*****************************************************************************
709 #ifdef CONFIG_TOUCHSCREEN_USB_GOTOP
710 static int gotop_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
712 dev
->x
= ((pkt
[1] & 0x38) << 4) | pkt
[2];
713 dev
->y
= ((pkt
[1] & 0x07) << 7) | pkt
[3];
714 dev
->touch
= pkt
[0] & 0x01;
720 /*****************************************************************************
723 #ifdef CONFIG_TOUCHSCREEN_USB_JASTEC
724 static int jastec_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
726 dev
->x
= ((pkt
[0] & 0x3f) << 6) | (pkt
[2] & 0x3f);
727 dev
->y
= ((pkt
[1] & 0x3f) << 6) | (pkt
[3] & 0x3f);
728 dev
->touch
= (pkt
[0] & 0x40) >> 6;
734 /*****************************************************************************
737 #ifdef CONFIG_TOUCHSCREEN_USB_ZYTRONIC
738 static int zytronic_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
741 case 0x3A: /* command response */
742 dbg("%s: Command response %d", __func__
, pkt
[1]);
745 case 0xC0: /* down */
746 dev
->x
= (pkt
[1] & 0x7f) | ((pkt
[2] & 0x07) << 7);
747 dev
->y
= (pkt
[3] & 0x7f) | ((pkt
[4] & 0x07) << 7);
749 dbg("%s: down %d,%d", __func__
, dev
->x
, dev
->y
);
753 dev
->x
= (pkt
[1] & 0x7f) | ((pkt
[2] & 0x07) << 7);
754 dev
->y
= (pkt
[3] & 0x7f) | ((pkt
[4] & 0x07) << 7);
756 dbg("%s: up %d,%d", __func__
, dev
->x
, dev
->y
);
760 dbg("%s: Unknown return %d", __func__
, pkt
[0]);
768 /*****************************************************************************
771 #ifdef CONFIG_TOUCHSCREEN_USB_NEXIO
773 #define NEXIO_TIMEOUT 5000
774 #define NEXIO_BUFSIZE 1024
775 #define NEXIO_THRESHOLD 50
779 unsigned char *ack_buf
;
782 struct nexio_touch_packet
{
783 u8 flags
; /* 0xe1 = touch, 0xe1 = release */
784 __be16 data_len
; /* total bytes of touch data */
785 __be16 x_len
; /* bytes for X axis */
786 __be16 y_len
; /* bytes for Y axis */
788 } __attribute__ ((packed
));
790 static unsigned char nexio_ack_pkt
[2] = { 0xaa, 0x02 };
791 static unsigned char nexio_init_pkt
[4] = { 0x82, 0x04, 0x0a, 0x0f };
793 static void nexio_ack_complete(struct urb
*urb
)
797 static int nexio_alloc(struct usbtouch_usb
*usbtouch
)
799 struct nexio_priv
*priv
;
802 usbtouch
->priv
= kmalloc(sizeof(struct nexio_priv
), GFP_KERNEL
);
806 priv
= usbtouch
->priv
;
808 priv
->ack_buf
= kmemdup(nexio_ack_pkt
, sizeof(nexio_ack_pkt
),
813 priv
->ack
= usb_alloc_urb(0, GFP_KERNEL
);
815 dbg("%s - usb_alloc_urb failed: usbtouch->ack", __func__
);
822 kfree(priv
->ack_buf
);
829 static int nexio_init(struct usbtouch_usb
*usbtouch
)
831 struct usb_device
*dev
= interface_to_usbdev(usbtouch
->interface
);
832 struct usb_host_interface
*interface
= usbtouch
->interface
->cur_altsetting
;
833 struct nexio_priv
*priv
= usbtouch
->priv
;
837 char *firmware_ver
= NULL
, *device_name
= NULL
;
838 int input_ep
= 0, output_ep
= 0;
840 /* find first input and output endpoint */
841 for (i
= 0; i
< interface
->desc
.bNumEndpoints
; i
++) {
843 usb_endpoint_dir_in(&interface
->endpoint
[i
].desc
))
844 input_ep
= interface
->endpoint
[i
].desc
.bEndpointAddress
;
846 usb_endpoint_dir_out(&interface
->endpoint
[i
].desc
))
847 output_ep
= interface
->endpoint
[i
].desc
.bEndpointAddress
;
849 if (!input_ep
|| !output_ep
)
852 buf
= kmalloc(NEXIO_BUFSIZE
, GFP_NOIO
);
856 /* two empty reads */
857 for (i
= 0; i
< 2; i
++) {
858 ret
= usb_bulk_msg(dev
, usb_rcvbulkpipe(dev
, input_ep
),
859 buf
, NEXIO_BUFSIZE
, &actual_len
,
865 /* send init command */
866 memcpy(buf
, nexio_init_pkt
, sizeof(nexio_init_pkt
));
867 ret
= usb_bulk_msg(dev
, usb_sndbulkpipe(dev
, output_ep
),
868 buf
, sizeof(nexio_init_pkt
), &actual_len
,
874 for (i
= 0; i
< 3; i
++) {
875 memset(buf
, 0, NEXIO_BUFSIZE
);
876 ret
= usb_bulk_msg(dev
, usb_rcvbulkpipe(dev
, input_ep
),
877 buf
, NEXIO_BUFSIZE
, &actual_len
,
879 if (ret
< 0 || actual_len
< 1 || buf
[1] != actual_len
)
882 case 0x83: /* firmware version */
884 firmware_ver
= kstrdup(&buf
[2], GFP_NOIO
);
886 case 0x84: /* device name */
888 device_name
= kstrdup(&buf
[2], GFP_NOIO
);
893 printk(KERN_INFO
"Nexio device: %s, firmware version: %s\n",
894 device_name
, firmware_ver
);
899 usb_fill_bulk_urb(priv
->ack
, dev
, usb_sndbulkpipe(dev
, output_ep
),
900 priv
->ack_buf
, sizeof(nexio_ack_pkt
),
901 nexio_ack_complete
, usbtouch
);
909 static void nexio_exit(struct usbtouch_usb
*usbtouch
)
911 struct nexio_priv
*priv
= usbtouch
->priv
;
913 usb_kill_urb(priv
->ack
);
914 usb_free_urb(priv
->ack
);
915 kfree(priv
->ack_buf
);
919 static int nexio_read_data(struct usbtouch_usb
*usbtouch
, unsigned char *pkt
)
921 struct nexio_touch_packet
*packet
= (void *) pkt
;
922 struct nexio_priv
*priv
= usbtouch
->priv
;
923 unsigned int data_len
= be16_to_cpu(packet
->data_len
);
924 unsigned int x_len
= be16_to_cpu(packet
->x_len
);
925 unsigned int y_len
= be16_to_cpu(packet
->y_len
);
926 int x
, y
, begin_x
, begin_y
, end_x
, end_y
, w
, h
, ret
;
928 /* got touch data? */
929 if ((pkt
[0] & 0xe0) != 0xe0)
938 ret
= usb_submit_urb(priv
->ack
, GFP_ATOMIC
);
940 if (!usbtouch
->type
->max_xc
) {
941 usbtouch
->type
->max_xc
= 2 * x_len
;
942 input_set_abs_params(usbtouch
->input
, ABS_X
,
943 0, usbtouch
->type
->max_xc
, 0, 0);
944 usbtouch
->type
->max_yc
= 2 * y_len
;
945 input_set_abs_params(usbtouch
->input
, ABS_Y
,
946 0, usbtouch
->type
->max_yc
, 0, 0);
949 * The device reports state of IR sensors on X and Y axes.
950 * Each byte represents "darkness" percentage (0-100) of one element.
951 * 17" touchscreen reports only 64 x 52 bytes so the resolution is low.
952 * This also means that there's a limited multi-touch capability but
953 * it's disabled (and untested) here as there's no X driver for that.
955 begin_x
= end_x
= begin_y
= end_y
= -1;
956 for (x
= 0; x
< x_len
; x
++) {
957 if (begin_x
== -1 && packet
->data
[x
] > NEXIO_THRESHOLD
) {
961 if (end_x
== -1 && begin_x
!= -1 && packet
->data
[x
] < NEXIO_THRESHOLD
) {
963 for (y
= x_len
; y
< data_len
; y
++) {
964 if (begin_y
== -1 && packet
->data
[y
] > NEXIO_THRESHOLD
) {
969 begin_y
!= -1 && packet
->data
[y
] < NEXIO_THRESHOLD
) {
970 end_y
= y
- 1 - x_len
;
975 input_report_abs(usbtouch
->input
,
976 ABS_MT_TOUCH_MAJOR
, max(w
,h
));
977 input_report_abs(usbtouch
->input
,
978 ABS_MT_TOUCH_MINOR
, min(x
,h
));
979 input_report_abs(usbtouch
->input
,
980 ABS_MT_POSITION_X
, 2*begin_x
+w
);
981 input_report_abs(usbtouch
->input
,
982 ABS_MT_POSITION_Y
, 2*begin_y
+h
);
983 input_report_abs(usbtouch
->input
,
984 ABS_MT_ORIENTATION
, w
> h
);
985 input_mt_sync(usbtouch
->input
);
988 usbtouch
->x
= 2 * begin_x
+ w
;
989 usbtouch
->y
= 2 * begin_y
+ h
;
990 usbtouch
->touch
= packet
->flags
& 0x01;
991 begin_y
= end_y
= -1;
995 begin_x
= end_x
= -1;
1004 /*****************************************************************************
1008 #ifdef CONFIG_TOUCHSCREEN_USB_ELO
1010 static int elo_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
1012 dev
->x
= (pkt
[3] << 8) | pkt
[2];
1013 dev
->y
= (pkt
[5] << 8) | pkt
[4];
1014 dev
->touch
= pkt
[6] > 0;
1015 dev
->press
= pkt
[6];
1022 /*****************************************************************************
1023 * the different device descriptors
1026 static void usbtouch_process_multi(struct usbtouch_usb
*usbtouch
,
1027 unsigned char *pkt
, int len
);
1030 static struct usbtouch_device_info usbtouch_dev_info
[] = {
1031 #ifdef CONFIG_TOUCHSCREEN_USB_ELO
1039 .read_data
= elo_read_data
,
1043 #ifdef CONFIG_TOUCHSCREEN_USB_EGALAX
1044 [DEVTYPE_EGALAX
] = {
1050 .process_pkt
= usbtouch_process_multi
,
1051 .get_pkt_len
= egalax_get_pkt_len
,
1052 .read_data
= egalax_read_data
,
1056 #ifdef CONFIG_TOUCHSCREEN_USB_PANJIT
1057 [DEVTYPE_PANJIT
] = {
1063 .read_data
= panjit_read_data
,
1067 #ifdef CONFIG_TOUCHSCREEN_USB_3M
1074 .read_data
= mtouch_read_data
,
1075 .init
= mtouch_init
,
1079 #ifdef CONFIG_TOUCHSCREEN_USB_ITM
1087 .read_data
= itm_read_data
,
1091 #ifdef CONFIG_TOUCHSCREEN_USB_ETURBO
1092 [DEVTYPE_ETURBO
] = {
1098 .process_pkt
= usbtouch_process_multi
,
1099 .get_pkt_len
= eturbo_get_pkt_len
,
1100 .read_data
= eturbo_read_data
,
1104 #ifdef CONFIG_TOUCHSCREEN_USB_GUNZE
1111 .read_data
= gunze_read_data
,
1115 #ifdef CONFIG_TOUCHSCREEN_USB_DMC_TSC10
1116 [DEVTYPE_DMC_TSC10
] = {
1122 .init
= dmc_tsc10_init
,
1123 .read_data
= dmc_tsc10_read_data
,
1127 #ifdef CONFIG_TOUCHSCREEN_USB_IRTOUCH
1128 [DEVTYPE_IRTOUCH
] = {
1134 .read_data
= irtouch_read_data
,
1138 #ifdef CONFIG_TOUCHSCREEN_USB_IDEALTEK
1139 [DEVTYPE_IDEALTEK
] = {
1145 .process_pkt
= usbtouch_process_multi
,
1146 .get_pkt_len
= idealtek_get_pkt_len
,
1147 .read_data
= idealtek_read_data
,
1151 #ifdef CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH
1152 [DEVTYPE_GENERAL_TOUCH
] = {
1158 .read_data
= general_touch_read_data
,
1162 #ifdef CONFIG_TOUCHSCREEN_USB_GOTOP
1169 .read_data
= gotop_read_data
,
1173 #ifdef CONFIG_TOUCHSCREEN_USB_JASTEC
1174 [DEVTYPE_JASTEC
] = {
1180 .read_data
= jastec_read_data
,
1184 #ifdef CONFIG_TOUCHSCREEN_USB_E2I
1192 .read_data
= e2i_read_data
,
1196 #ifdef CONFIG_TOUCHSCREEN_USB_ZYTRONIC
1197 [DEVTYPE_ZYTRONIC
] = {
1203 .read_data
= zytronic_read_data
,
1208 #ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC45USB
1209 [DEVTYPE_TC45USB
] = {
1215 .read_data
= tc45usb_read_data
,
1219 #ifdef CONFIG_TOUCHSCREEN_USB_NEXIO
1223 .read_data
= nexio_read_data
,
1224 .alloc
= nexio_alloc
,
1229 #ifdef CONFIG_TOUCHSCREEN_USB_EASYTOUCH
1230 [DEVTYPE_ETOUCH
] = {
1236 .process_pkt
= usbtouch_process_multi
,
1237 .get_pkt_len
= etouch_get_pkt_len
,
1238 .read_data
= etouch_read_data
,
1244 /*****************************************************************************
1247 static void usbtouch_process_pkt(struct usbtouch_usb
*usbtouch
,
1248 unsigned char *pkt
, int len
)
1250 struct usbtouch_device_info
*type
= usbtouch
->type
;
1252 if (!type
->read_data(usbtouch
, pkt
))
1255 input_report_key(usbtouch
->input
, BTN_TOUCH
, usbtouch
->touch
);
1258 input_report_abs(usbtouch
->input
, ABS_X
, usbtouch
->y
);
1259 input_report_abs(usbtouch
->input
, ABS_Y
, usbtouch
->x
);
1261 input_report_abs(usbtouch
->input
, ABS_X
, usbtouch
->x
);
1262 input_report_abs(usbtouch
->input
, ABS_Y
, usbtouch
->y
);
1264 if (type
->max_press
)
1265 input_report_abs(usbtouch
->input
, ABS_PRESSURE
, usbtouch
->press
);
1266 input_sync(usbtouch
->input
);
1271 static void usbtouch_process_multi(struct usbtouch_usb
*usbtouch
,
1272 unsigned char *pkt
, int len
)
1274 unsigned char *buffer
;
1275 int pkt_len
, pos
, buf_len
, tmp
;
1277 /* process buffer */
1278 if (unlikely(usbtouch
->buf_len
)) {
1279 /* try to get size */
1280 pkt_len
= usbtouch
->type
->get_pkt_len(
1281 usbtouch
->buffer
, usbtouch
->buf_len
);
1284 if (unlikely(!pkt_len
))
1287 /* need to append -pkt_len bytes before able to get size */
1288 if (unlikely(pkt_len
< 0)) {
1289 int append
= -pkt_len
;
1290 if (unlikely(append
> len
))
1292 if (usbtouch
->buf_len
+ append
>= usbtouch
->type
->rept_size
)
1294 memcpy(usbtouch
->buffer
+ usbtouch
->buf_len
, pkt
, append
);
1295 usbtouch
->buf_len
+= append
;
1297 pkt_len
= usbtouch
->type
->get_pkt_len(
1298 usbtouch
->buffer
, usbtouch
->buf_len
);
1304 tmp
= pkt_len
- usbtouch
->buf_len
;
1305 if (usbtouch
->buf_len
+ tmp
>= usbtouch
->type
->rept_size
)
1307 memcpy(usbtouch
->buffer
+ usbtouch
->buf_len
, pkt
, tmp
);
1308 usbtouch_process_pkt(usbtouch
, usbtouch
->buffer
, pkt_len
);
1311 buf_len
= len
- tmp
;
1317 /* loop over the received packet, process */
1319 while (pos
< buf_len
) {
1320 /* get packet len */
1321 pkt_len
= usbtouch
->type
->get_pkt_len(buffer
+ pos
,
1324 /* unknown packet: skip one byte */
1325 if (unlikely(!pkt_len
)) {
1330 /* full packet: process */
1331 if (likely((pkt_len
> 0) && (pkt_len
<= buf_len
- pos
))) {
1332 usbtouch_process_pkt(usbtouch
, buffer
+ pos
, pkt_len
);
1334 /* incomplete packet: save in buffer */
1335 memcpy(usbtouch
->buffer
, buffer
+ pos
, buf_len
- pos
);
1336 usbtouch
->buf_len
= buf_len
- pos
;
1343 usbtouch
->buf_len
= 0;
1349 static void usbtouch_irq(struct urb
*urb
)
1351 struct usbtouch_usb
*usbtouch
= urb
->context
;
1354 switch (urb
->status
) {
1359 /* this urb is timing out */
1360 dbg("%s - urb timed out - was the device unplugged?",
1367 /* this urb is terminated, clean up */
1368 dbg("%s - urb shutting down with status: %d",
1369 __func__
, urb
->status
);
1372 dbg("%s - nonzero urb status received: %d",
1373 __func__
, urb
->status
);
1377 usbtouch
->type
->process_pkt(usbtouch
, usbtouch
->data
, urb
->actual_length
);
1380 usb_mark_last_busy(interface_to_usbdev(usbtouch
->interface
));
1381 retval
= usb_submit_urb(urb
, GFP_ATOMIC
);
1383 err("%s - usb_submit_urb failed with result: %d",
1387 static int usbtouch_open(struct input_dev
*input
)
1389 struct usbtouch_usb
*usbtouch
= input_get_drvdata(input
);
1392 usbtouch
->irq
->dev
= interface_to_usbdev(usbtouch
->interface
);
1394 r
= usb_autopm_get_interface(usbtouch
->interface
) ? -EIO
: 0;
1398 if (!usbtouch
->type
->irq_always
) {
1399 if (usb_submit_urb(usbtouch
->irq
, GFP_KERNEL
)) {
1405 usbtouch
->interface
->needs_remote_wakeup
= 1;
1407 usb_autopm_put_interface(usbtouch
->interface
);
1412 static void usbtouch_close(struct input_dev
*input
)
1414 struct usbtouch_usb
*usbtouch
= input_get_drvdata(input
);
1417 if (!usbtouch
->type
->irq_always
)
1418 usb_kill_urb(usbtouch
->irq
);
1419 r
= usb_autopm_get_interface(usbtouch
->interface
);
1420 usbtouch
->interface
->needs_remote_wakeup
= 0;
1422 usb_autopm_put_interface(usbtouch
->interface
);
1425 static int usbtouch_suspend
1426 (struct usb_interface
*intf
, pm_message_t message
)
1428 struct usbtouch_usb
*usbtouch
= usb_get_intfdata(intf
);
1430 usb_kill_urb(usbtouch
->irq
);
1435 static int usbtouch_resume(struct usb_interface
*intf
)
1437 struct usbtouch_usb
*usbtouch
= usb_get_intfdata(intf
);
1438 struct input_dev
*input
= usbtouch
->input
;
1441 mutex_lock(&input
->mutex
);
1442 if (input
->users
|| usbtouch
->type
->irq_always
)
1443 result
= usb_submit_urb(usbtouch
->irq
, GFP_NOIO
);
1444 mutex_unlock(&input
->mutex
);
1449 static int usbtouch_reset_resume(struct usb_interface
*intf
)
1451 struct usbtouch_usb
*usbtouch
= usb_get_intfdata(intf
);
1452 struct input_dev
*input
= usbtouch
->input
;
1455 /* reinit the device */
1456 if (usbtouch
->type
->init
) {
1457 err
= usbtouch
->type
->init(usbtouch
);
1459 dbg("%s - type->init() failed, err: %d",
1465 /* restart IO if needed */
1466 mutex_lock(&input
->mutex
);
1468 err
= usb_submit_urb(usbtouch
->irq
, GFP_NOIO
);
1469 mutex_unlock(&input
->mutex
);
1474 static void usbtouch_free_buffers(struct usb_device
*udev
,
1475 struct usbtouch_usb
*usbtouch
)
1477 usb_free_coherent(udev
, usbtouch
->type
->rept_size
,
1478 usbtouch
->data
, usbtouch
->data_dma
);
1479 kfree(usbtouch
->buffer
);
1482 static struct usb_endpoint_descriptor
*
1483 usbtouch_get_input_endpoint(struct usb_host_interface
*interface
)
1487 for (i
= 0; i
< interface
->desc
.bNumEndpoints
; i
++)
1488 if (usb_endpoint_dir_in(&interface
->endpoint
[i
].desc
))
1489 return &interface
->endpoint
[i
].desc
;
1494 static int usbtouch_probe(struct usb_interface
*intf
,
1495 const struct usb_device_id
*id
)
1497 struct usbtouch_usb
*usbtouch
;
1498 struct input_dev
*input_dev
;
1499 struct usb_endpoint_descriptor
*endpoint
;
1500 struct usb_device
*udev
= interface_to_usbdev(intf
);
1501 struct usbtouch_device_info
*type
;
1504 /* some devices are ignored */
1505 if (id
->driver_info
== DEVTYPE_IGNORE
)
1508 endpoint
= usbtouch_get_input_endpoint(intf
->cur_altsetting
);
1512 usbtouch
= kzalloc(sizeof(struct usbtouch_usb
), GFP_KERNEL
);
1513 input_dev
= input_allocate_device();
1514 if (!usbtouch
|| !input_dev
)
1517 type
= &usbtouch_dev_info
[id
->driver_info
];
1518 usbtouch
->type
= type
;
1519 if (!type
->process_pkt
)
1520 type
->process_pkt
= usbtouch_process_pkt
;
1522 usbtouch
->data
= usb_alloc_coherent(udev
, type
->rept_size
,
1523 GFP_KERNEL
, &usbtouch
->data_dma
);
1524 if (!usbtouch
->data
)
1527 if (type
->get_pkt_len
) {
1528 usbtouch
->buffer
= kmalloc(type
->rept_size
, GFP_KERNEL
);
1529 if (!usbtouch
->buffer
)
1530 goto out_free_buffers
;
1533 usbtouch
->irq
= usb_alloc_urb(0, GFP_KERNEL
);
1534 if (!usbtouch
->irq
) {
1535 dbg("%s - usb_alloc_urb failed: usbtouch->irq", __func__
);
1536 goto out_free_buffers
;
1539 usbtouch
->interface
= intf
;
1540 usbtouch
->input
= input_dev
;
1542 if (udev
->manufacturer
)
1543 strlcpy(usbtouch
->name
, udev
->manufacturer
, sizeof(usbtouch
->name
));
1545 if (udev
->product
) {
1546 if (udev
->manufacturer
)
1547 strlcat(usbtouch
->name
, " ", sizeof(usbtouch
->name
));
1548 strlcat(usbtouch
->name
, udev
->product
, sizeof(usbtouch
->name
));
1551 if (!strlen(usbtouch
->name
))
1552 snprintf(usbtouch
->name
, sizeof(usbtouch
->name
),
1553 "USB Touchscreen %04x:%04x",
1554 le16_to_cpu(udev
->descriptor
.idVendor
),
1555 le16_to_cpu(udev
->descriptor
.idProduct
));
1557 usb_make_path(udev
, usbtouch
->phys
, sizeof(usbtouch
->phys
));
1558 strlcat(usbtouch
->phys
, "/input0", sizeof(usbtouch
->phys
));
1560 input_dev
->name
= usbtouch
->name
;
1561 input_dev
->phys
= usbtouch
->phys
;
1562 usb_to_input_id(udev
, &input_dev
->id
);
1563 input_dev
->dev
.parent
= &intf
->dev
;
1565 input_set_drvdata(input_dev
, usbtouch
);
1567 input_dev
->open
= usbtouch_open
;
1568 input_dev
->close
= usbtouch_close
;
1570 input_dev
->evbit
[0] = BIT_MASK(EV_KEY
) | BIT_MASK(EV_ABS
);
1571 input_dev
->keybit
[BIT_WORD(BTN_TOUCH
)] = BIT_MASK(BTN_TOUCH
);
1572 input_set_abs_params(input_dev
, ABS_X
, type
->min_xc
, type
->max_xc
, 0, 0);
1573 input_set_abs_params(input_dev
, ABS_Y
, type
->min_yc
, type
->max_yc
, 0, 0);
1574 if (type
->max_press
)
1575 input_set_abs_params(input_dev
, ABS_PRESSURE
, type
->min_press
,
1576 type
->max_press
, 0, 0);
1578 if (usb_endpoint_type(endpoint
) == USB_ENDPOINT_XFER_INT
)
1579 usb_fill_int_urb(usbtouch
->irq
, udev
,
1580 usb_rcvintpipe(udev
, endpoint
->bEndpointAddress
),
1581 usbtouch
->data
, type
->rept_size
,
1582 usbtouch_irq
, usbtouch
, endpoint
->bInterval
);
1584 usb_fill_bulk_urb(usbtouch
->irq
, udev
,
1585 usb_rcvbulkpipe(udev
, endpoint
->bEndpointAddress
),
1586 usbtouch
->data
, type
->rept_size
,
1587 usbtouch_irq
, usbtouch
);
1589 usbtouch
->irq
->dev
= udev
;
1590 usbtouch
->irq
->transfer_dma
= usbtouch
->data_dma
;
1591 usbtouch
->irq
->transfer_flags
|= URB_NO_TRANSFER_DMA_MAP
;
1593 /* device specific allocations */
1595 err
= type
->alloc(usbtouch
);
1597 dbg("%s - type->alloc() failed, err: %d", __func__
, err
);
1602 /* device specific initialisation*/
1604 err
= type
->init(usbtouch
);
1606 dbg("%s - type->init() failed, err: %d", __func__
, err
);
1611 err
= input_register_device(usbtouch
->input
);
1613 dbg("%s - input_register_device failed, err: %d", __func__
, err
);
1617 usb_set_intfdata(intf
, usbtouch
);
1619 if (usbtouch
->type
->irq_always
) {
1620 /* this can't fail */
1621 usb_autopm_get_interface(intf
);
1622 err
= usb_submit_urb(usbtouch
->irq
, GFP_KERNEL
);
1624 usb_autopm_put_interface(intf
);
1625 err("%s - usb_submit_urb failed with result: %d",
1627 goto out_unregister_input
;
1633 out_unregister_input
:
1634 input_unregister_device(input_dev
);
1638 type
->exit(usbtouch
);
1640 usb_free_urb(usbtouch
->irq
);
1642 usbtouch_free_buffers(udev
, usbtouch
);
1644 input_free_device(input_dev
);
1649 static void usbtouch_disconnect(struct usb_interface
*intf
)
1651 struct usbtouch_usb
*usbtouch
= usb_get_intfdata(intf
);
1653 dbg("%s - called", __func__
);
1658 dbg("%s - usbtouch is initialized, cleaning up", __func__
);
1659 usb_set_intfdata(intf
, NULL
);
1660 /* this will stop IO via close */
1661 input_unregister_device(usbtouch
->input
);
1662 usb_free_urb(usbtouch
->irq
);
1663 if (usbtouch
->type
->exit
)
1664 usbtouch
->type
->exit(usbtouch
);
1665 usbtouch_free_buffers(interface_to_usbdev(intf
), usbtouch
);
1669 MODULE_DEVICE_TABLE(usb
, usbtouch_devices
);
1671 static struct usb_driver usbtouch_driver
= {
1672 .name
= "usbtouchscreen",
1673 .probe
= usbtouch_probe
,
1674 .disconnect
= usbtouch_disconnect
,
1675 .suspend
= usbtouch_suspend
,
1676 .resume
= usbtouch_resume
,
1677 .reset_resume
= usbtouch_reset_resume
,
1678 .id_table
= usbtouch_devices
,
1679 .supports_autosuspend
= 1,
1682 module_usb_driver(usbtouch_driver
);
1684 MODULE_AUTHOR(DRIVER_AUTHOR
);
1685 MODULE_DESCRIPTION(DRIVER_DESC
);
1686 MODULE_LICENSE("GPL");
1688 MODULE_ALIAS("touchkitusb");
1689 MODULE_ALIAS("itmtouch");
1690 MODULE_ALIAS("mtouchusb");