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
{
110 unsigned char *buffer
;
113 struct usb_interface
*interface
;
114 struct input_dev
*input
;
115 struct usbtouch_device_info
*type
;
136 DEVTYPE_IRTOUCH_HIRES
,
138 DEVTYPE_GENERAL_TOUCH
,
149 #define USB_DEVICE_HID_CLASS(vend, prod) \
150 .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS \
151 | USB_DEVICE_ID_MATCH_DEVICE, \
152 .idVendor = (vend), \
153 .idProduct = (prod), \
154 .bInterfaceClass = USB_INTERFACE_CLASS_HID
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
},
203 {USB_DEVICE(0x6615, 0x0012), .driver_info
= DEVTYPE_IRTOUCH_HIRES
},
206 #ifdef CONFIG_TOUCHSCREEN_USB_IDEALTEK
207 {USB_DEVICE(0x1391, 0x1000), .driver_info
= DEVTYPE_IDEALTEK
},
210 #ifdef CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH
211 {USB_DEVICE(0x0dfc, 0x0001), .driver_info
= DEVTYPE_GENERAL_TOUCH
},
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
},
220 #ifdef CONFIG_TOUCHSCREEN_USB_JASTEC
221 {USB_DEVICE(0x0f92, 0x0001), .driver_info
= DEVTYPE_JASTEC
},
224 #ifdef CONFIG_TOUCHSCREEN_USB_E2I
225 {USB_DEVICE(0x1ac7, 0x0001), .driver_info
= DEVTYPE_E2I
},
228 #ifdef CONFIG_TOUCHSCREEN_USB_ZYTRONIC
229 {USB_DEVICE(0x14c8, 0x0003), .driver_info
= DEVTYPE_ZYTRONIC
},
232 #ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC45USB
234 {USB_DEVICE(0x0664, 0x0309), .driver_info
= DEVTYPE_TC45USB
},
236 {USB_DEVICE(0x0664, 0x0306), .driver_info
= DEVTYPE_TC45USB
},
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
},
247 #ifdef CONFIG_TOUCHSCREEN_USB_ELO
248 {USB_DEVICE(0x04e7, 0x0020), .driver_info
= DEVTYPE_ELO
},
251 #ifdef CONFIG_TOUCHSCREEN_USB_EASYTOUCH
252 {USB_DEVICE(0x7374, 0x0001), .driver_info
= DEVTYPE_ETOUCH
},
259 /*****************************************************************************
263 #ifdef CONFIG_TOUCHSCREEN_USB_E2I
264 static int e2i_init(struct usbtouch_usb
*usbtouch
)
267 struct usb_device
*udev
= interface_to_usbdev(usbtouch
->interface
);
269 ret
= usb_control_msg(udev
, usb_rcvctrlpipe(udev
, 0),
270 0x01, 0x02, 0x0000, 0x0081,
271 NULL
, 0, USB_CTRL_SET_TIMEOUT
);
273 dev_dbg(&usbtouch
->interface
->dev
,
274 "%s - usb_control_msg - E2I_RESET - bytes|err: %d\n",
279 static int e2i_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
281 int tmp
= (pkt
[0] << 8) | pkt
[1];
282 dev
->x
= (pkt
[2] << 8) | pkt
[3];
283 dev
->y
= (pkt
[4] << 8) | pkt
[5];
286 dev
->touch
= (tmp
> 0);
287 dev
->press
= (tmp
> 0 ? tmp
: 0);
294 /*****************************************************************************
298 #ifdef CONFIG_TOUCHSCREEN_USB_EGALAX
304 #define EGALAX_PKT_TYPE_MASK 0xFE
305 #define EGALAX_PKT_TYPE_REPT 0x80
306 #define EGALAX_PKT_TYPE_DIAG 0x0A
308 static int egalax_init(struct usbtouch_usb
*usbtouch
)
312 struct usb_device
*udev
= interface_to_usbdev(usbtouch
->interface
);
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.
320 buf
= kmalloc(3, GFP_KERNEL
);
324 buf
[0] = EGALAX_PKT_TYPE_DIAG
;
325 buf
[1] = 1; /* length */
326 buf
[2] = 'A'; /* command - check active */
328 for (i
= 0; i
< 3; i
++) {
329 ret
= usb_control_msg(udev
, usb_sndctrlpipe(udev
, 0),
331 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
333 USB_CTRL_SET_TIMEOUT
);
347 static int egalax_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
349 if ((pkt
[0] & EGALAX_PKT_TYPE_MASK
) != EGALAX_PKT_TYPE_REPT
)
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;
359 static int egalax_get_pkt_len(unsigned char *buf
, int len
)
361 switch (buf
[0] & EGALAX_PKT_TYPE_MASK
) {
362 case EGALAX_PKT_TYPE_REPT
:
365 case EGALAX_PKT_TYPE_DIAG
:
376 /*****************************************************************************
380 #ifdef CONFIG_TOUCHSCREEN_USB_EASYTOUCH
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
391 static int etouch_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
393 if ((pkt
[0] & ETOUCH_PKT_TYPE_MASK
) != ETOUCH_PKT_TYPE_REPT
&&
394 (pkt
[0] & ETOUCH_PKT_TYPE_MASK
) != ETOUCH_PKT_TYPE_REPT2
)
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;
404 static int etouch_get_pkt_len(unsigned char *buf
, int len
)
406 switch (buf
[0] & ETOUCH_PKT_TYPE_MASK
) {
407 case ETOUCH_PKT_TYPE_REPT
:
408 case ETOUCH_PKT_TYPE_REPT2
:
411 case ETOUCH_PKT_TYPE_DIAG
:
422 /*****************************************************************************
425 #ifdef CONFIG_TOUCHSCREEN_USB_PANJIT
426 static int panjit_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
428 dev
->x
= ((pkt
[2] & 0x0F) << 8) | pkt
[1];
429 dev
->y
= ((pkt
[4] & 0x0F) << 8) | pkt
[3];
430 dev
->touch
= pkt
[0] & 0x01;
437 /*****************************************************************************
440 #ifdef CONFIG_TOUCHSCREEN_USB_3M
442 #define MTOUCHUSB_ASYNC_REPORT 1
443 #define MTOUCHUSB_RESET 7
444 #define MTOUCHUSB_REQ_CTRLLR_ID 10
446 static int mtouch_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
449 dev
->x
= (pkt
[4] << 8) | pkt
[3];
450 dev
->y
= 0xffff - ((pkt
[6] << 8) | pkt
[5]);
452 dev
->x
= (pkt
[8] << 8) | pkt
[7];
453 dev
->y
= (pkt
[10] << 8) | pkt
[9];
455 dev
->touch
= (pkt
[2] & 0x40) ? 1 : 0;
460 static int mtouch_init(struct usbtouch_usb
*usbtouch
)
463 struct usb_device
*udev
= interface_to_usbdev(usbtouch
->interface
);
465 ret
= usb_control_msg(udev
, usb_rcvctrlpipe(udev
, 0),
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",
476 for (i
= 0; i
< 3; i
++) {
477 ret
= usb_control_msg(udev
, usb_rcvctrlpipe(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",
490 /* Default min/max xy are the raw values, override if using hw-calib */
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);
501 /*****************************************************************************
504 #ifdef CONFIG_TOUCHSCREEN_USB_ITM
505 static int itm_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
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.
514 dev
->press
= ((pkt
[2] & 0x01) << 7) | (pkt
[5] & 0x7F);
516 touch
= ~pkt
[7] & 0x20;
526 dev
->x
= ((pkt
[0] & 0x1F) << 7) | (pkt
[3] & 0x7F);
527 dev
->y
= ((pkt
[1] & 0x1F) << 7) | (pkt
[4] & 0x7F);
535 /*****************************************************************************
538 #ifdef CONFIG_TOUCHSCREEN_USB_ETURBO
542 static int eturbo_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
546 /* packets should start with sync */
547 if (!(pkt
[0] & 0x80))
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;
558 static int eturbo_get_pkt_len(unsigned char *buf
, int len
)
569 /*****************************************************************************
572 #ifdef CONFIG_TOUCHSCREEN_USB_GUNZE
573 static int gunze_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
575 if (!(pkt
[0] & 0x80) || ((pkt
[1] | pkt
[2] | pkt
[3]) & 0x80))
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;
586 /*****************************************************************************
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
593 #ifdef CONFIG_TOUCHSCREEN_USB_DMC_TSC10
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
605 #define TSC10_CMD_RESET 0x55
606 #define TSC10_CMD_RATE 0x05
607 #define TSC10_CMD_DATA1 0x01
609 static int dmc_tsc10_init(struct usbtouch_usb
*usbtouch
)
611 struct usb_device
*dev
= interface_to_usbdev(usbtouch
->interface
);
615 buf
= kmalloc(2, GFP_NOIO
);
619 buf
[0] = buf
[1] = 0xFF;
620 ret
= usb_control_msg(dev
, usb_rcvctrlpipe (dev
, 0),
622 USB_DIR_IN
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
623 0, 0, buf
, 2, USB_CTRL_SET_TIMEOUT
);
626 if (buf
[0] != 0x06) {
631 /* TSC-25 data sheet specifies a delay after the RESET command */
634 /* set coordinate output rate */
635 buf
[0] = buf
[1] = 0xFF;
636 ret
= usb_control_msg(dev
, usb_rcvctrlpipe (dev
, 0),
638 USB_DIR_IN
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
639 TSC10_RATE_150
, 0, buf
, 2, USB_CTRL_SET_TIMEOUT
);
642 if ((buf
[0] != 0x06) && (buf
[0] != 0x15 || buf
[1] != 0x01)) {
647 /* start sending data */
648 ret
= usb_control_msg(dev
, usb_rcvctrlpipe (dev
, 0),
650 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
651 0, 0, NULL
, 0, USB_CTRL_SET_TIMEOUT
);
659 static int dmc_tsc10_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
661 dev
->x
= ((pkt
[2] & 0x03) << 8) | pkt
[1];
662 dev
->y
= ((pkt
[4] & 0x03) << 8) | pkt
[3];
663 dev
->touch
= pkt
[0] & 0x01;
670 /*****************************************************************************
673 #ifdef CONFIG_TOUCHSCREEN_USB_IRTOUCH
674 static int irtouch_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
676 dev
->x
= (pkt
[3] << 8) | pkt
[2];
677 dev
->y
= (pkt
[5] << 8) | pkt
[4];
678 dev
->touch
= (pkt
[1] & 0x03) ? 1 : 0;
684 /*****************************************************************************
685 * ET&T TC5UH/TC4UM part
687 #ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC45USB
688 static int tc45usb_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
690 dev
->x
= ((pkt
[2] & 0x0F) << 8) | pkt
[1];
691 dev
->y
= ((pkt
[4] & 0x0F) << 8) | pkt
[3];
692 dev
->touch
= pkt
[0] & 0x01;
698 /*****************************************************************************
699 * IdealTEK URTC1000 Part
701 #ifdef CONFIG_TOUCHSCREEN_USB_IDEALTEK
705 static int idealtek_get_pkt_len(unsigned char *buf
, int len
)
714 static int idealtek_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
716 switch (pkt
[0] & 0x98) {
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;
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;
737 /*****************************************************************************
740 #ifdef CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH
741 static int general_touch_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
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;
752 /*****************************************************************************
755 #ifdef CONFIG_TOUCHSCREEN_USB_GOTOP
756 static int gotop_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
758 dev
->x
= ((pkt
[1] & 0x38) << 4) | pkt
[2];
759 dev
->y
= ((pkt
[1] & 0x07) << 7) | pkt
[3];
760 dev
->touch
= pkt
[0] & 0x01;
766 /*****************************************************************************
769 #ifdef CONFIG_TOUCHSCREEN_USB_JASTEC
770 static int jastec_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
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;
780 /*****************************************************************************
783 #ifdef CONFIG_TOUCHSCREEN_USB_ZYTRONIC
784 static int zytronic_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
786 struct usb_interface
*intf
= dev
->interface
;
789 case 0x3A: /* command response */
790 dev_dbg(&intf
->dev
, "%s: Command response %d\n", __func__
, pkt
[1]);
793 case 0xC0: /* down */
794 dev
->x
= (pkt
[1] & 0x7f) | ((pkt
[2] & 0x07) << 7);
795 dev
->y
= (pkt
[3] & 0x7f) | ((pkt
[4] & 0x07) << 7);
797 dev_dbg(&intf
->dev
, "%s: down %d,%d\n", __func__
, dev
->x
, dev
->y
);
801 dev
->x
= (pkt
[1] & 0x7f) | ((pkt
[2] & 0x07) << 7);
802 dev
->y
= (pkt
[3] & 0x7f) | ((pkt
[4] & 0x07) << 7);
804 dev_dbg(&intf
->dev
, "%s: up %d,%d\n", __func__
, dev
->x
, dev
->y
);
808 dev_dbg(&intf
->dev
, "%s: Unknown return %d\n", __func__
, pkt
[0]);
816 /*****************************************************************************
819 #ifdef CONFIG_TOUCHSCREEN_USB_NEXIO
821 #define NEXIO_TIMEOUT 5000
822 #define NEXIO_BUFSIZE 1024
823 #define NEXIO_THRESHOLD 50
827 unsigned char *ack_buf
;
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 */
836 } __attribute__ ((packed
));
838 static unsigned char nexio_ack_pkt
[2] = { 0xaa, 0x02 };
839 static unsigned char nexio_init_pkt
[4] = { 0x82, 0x04, 0x0a, 0x0f };
841 static void nexio_ack_complete(struct urb
*urb
)
845 static int nexio_alloc(struct usbtouch_usb
*usbtouch
)
847 struct nexio_priv
*priv
;
850 usbtouch
->priv
= kmalloc(sizeof(struct nexio_priv
), GFP_KERNEL
);
854 priv
= usbtouch
->priv
;
856 priv
->ack_buf
= kmemdup(nexio_ack_pkt
, sizeof(nexio_ack_pkt
),
861 priv
->ack
= usb_alloc_urb(0, GFP_KERNEL
);
863 dev_dbg(&usbtouch
->interface
->dev
,
864 "%s - usb_alloc_urb failed: usbtouch->ack\n", __func__
);
871 kfree(priv
->ack_buf
);
878 static int nexio_init(struct usbtouch_usb
*usbtouch
)
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
;
886 char *firmware_ver
= NULL
, *device_name
= NULL
;
887 int input_ep
= 0, output_ep
= 0;
889 /* find first input and output endpoint */
890 for (i
= 0; i
< interface
->desc
.bNumEndpoints
; i
++) {
892 usb_endpoint_dir_in(&interface
->endpoint
[i
].desc
))
893 input_ep
= interface
->endpoint
[i
].desc
.bEndpointAddress
;
895 usb_endpoint_dir_out(&interface
->endpoint
[i
].desc
))
896 output_ep
= interface
->endpoint
[i
].desc
.bEndpointAddress
;
898 if (!input_ep
|| !output_ep
)
901 buf
= kmalloc(NEXIO_BUFSIZE
, GFP_NOIO
);
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
,
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
,
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
,
928 if (ret
< 0 || actual_len
< 1 || buf
[1] != actual_len
)
931 case 0x83: /* firmware version */
933 firmware_ver
= kstrdup(&buf
[2], GFP_NOIO
);
935 case 0x84: /* device name */
937 device_name
= kstrdup(&buf
[2], GFP_NOIO
);
942 printk(KERN_INFO
"Nexio device: %s, firmware version: %s\n",
943 device_name
, firmware_ver
);
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
);
958 static void nexio_exit(struct usbtouch_usb
*usbtouch
)
960 struct nexio_priv
*priv
= usbtouch
->priv
;
962 usb_kill_urb(priv
->ack
);
963 usb_free_urb(priv
->ack
);
964 kfree(priv
->ack_buf
);
968 static int nexio_read_data(struct usbtouch_usb
*usbtouch
, unsigned char *pkt
)
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
;
977 /* got touch data? */
978 if ((pkt
[0] & 0xe0) != 0xe0)
987 ret
= usb_submit_urb(priv
->ack
, GFP_ATOMIC
);
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);
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.
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
) {
1010 if (end_x
== -1 && begin_x
!= -1 && packet
->data
[x
] < NEXIO_THRESHOLD
) {
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
;
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
;
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
);
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;
1044 begin_x
= end_x
= -1;
1053 /*****************************************************************************
1057 #ifdef CONFIG_TOUCHSCREEN_USB_ELO
1059 static int elo_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
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];
1071 /*****************************************************************************
1072 * the different device descriptors
1075 static void usbtouch_process_multi(struct usbtouch_usb
*usbtouch
,
1076 unsigned char *pkt
, int len
);
1079 static struct usbtouch_device_info usbtouch_dev_info
[] = {
1080 #ifdef CONFIG_TOUCHSCREEN_USB_ELO
1088 .read_data
= elo_read_data
,
1092 #ifdef CONFIG_TOUCHSCREEN_USB_EGALAX
1093 [DEVTYPE_EGALAX
] = {
1099 .process_pkt
= usbtouch_process_multi
,
1100 .get_pkt_len
= egalax_get_pkt_len
,
1101 .read_data
= egalax_read_data
,
1102 .init
= egalax_init
,
1106 #ifdef CONFIG_TOUCHSCREEN_USB_PANJIT
1107 [DEVTYPE_PANJIT
] = {
1113 .read_data
= panjit_read_data
,
1117 #ifdef CONFIG_TOUCHSCREEN_USB_3M
1124 .read_data
= mtouch_read_data
,
1125 .init
= mtouch_init
,
1129 #ifdef CONFIG_TOUCHSCREEN_USB_ITM
1137 .read_data
= itm_read_data
,
1141 #ifdef CONFIG_TOUCHSCREEN_USB_ETURBO
1142 [DEVTYPE_ETURBO
] = {
1148 .process_pkt
= usbtouch_process_multi
,
1149 .get_pkt_len
= eturbo_get_pkt_len
,
1150 .read_data
= eturbo_read_data
,
1154 #ifdef CONFIG_TOUCHSCREEN_USB_GUNZE
1161 .read_data
= gunze_read_data
,
1165 #ifdef CONFIG_TOUCHSCREEN_USB_DMC_TSC10
1166 [DEVTYPE_DMC_TSC10
] = {
1172 .init
= dmc_tsc10_init
,
1173 .read_data
= dmc_tsc10_read_data
,
1177 #ifdef CONFIG_TOUCHSCREEN_USB_IRTOUCH
1178 [DEVTYPE_IRTOUCH
] = {
1184 .read_data
= irtouch_read_data
,
1187 [DEVTYPE_IRTOUCH_HIRES
] = {
1193 .read_data
= irtouch_read_data
,
1197 #ifdef CONFIG_TOUCHSCREEN_USB_IDEALTEK
1198 [DEVTYPE_IDEALTEK
] = {
1204 .process_pkt
= usbtouch_process_multi
,
1205 .get_pkt_len
= idealtek_get_pkt_len
,
1206 .read_data
= idealtek_read_data
,
1210 #ifdef CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH
1211 [DEVTYPE_GENERAL_TOUCH
] = {
1217 .read_data
= general_touch_read_data
,
1221 #ifdef CONFIG_TOUCHSCREEN_USB_GOTOP
1228 .read_data
= gotop_read_data
,
1232 #ifdef CONFIG_TOUCHSCREEN_USB_JASTEC
1233 [DEVTYPE_JASTEC
] = {
1239 .read_data
= jastec_read_data
,
1243 #ifdef CONFIG_TOUCHSCREEN_USB_E2I
1251 .read_data
= e2i_read_data
,
1255 #ifdef CONFIG_TOUCHSCREEN_USB_ZYTRONIC
1256 [DEVTYPE_ZYTRONIC
] = {
1262 .read_data
= zytronic_read_data
,
1267 #ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC45USB
1268 [DEVTYPE_TC45USB
] = {
1274 .read_data
= tc45usb_read_data
,
1278 #ifdef CONFIG_TOUCHSCREEN_USB_NEXIO
1282 .read_data
= nexio_read_data
,
1283 .alloc
= nexio_alloc
,
1288 #ifdef CONFIG_TOUCHSCREEN_USB_EASYTOUCH
1289 [DEVTYPE_ETOUCH
] = {
1295 .process_pkt
= usbtouch_process_multi
,
1296 .get_pkt_len
= etouch_get_pkt_len
,
1297 .read_data
= etouch_read_data
,
1303 /*****************************************************************************
1306 static void usbtouch_process_pkt(struct usbtouch_usb
*usbtouch
,
1307 unsigned char *pkt
, int len
)
1309 struct usbtouch_device_info
*type
= usbtouch
->type
;
1311 if (!type
->read_data(usbtouch
, pkt
))
1314 input_report_key(usbtouch
->input
, BTN_TOUCH
, usbtouch
->touch
);
1317 input_report_abs(usbtouch
->input
, ABS_X
, usbtouch
->y
);
1318 input_report_abs(usbtouch
->input
, ABS_Y
, usbtouch
->x
);
1320 input_report_abs(usbtouch
->input
, ABS_X
, usbtouch
->x
);
1321 input_report_abs(usbtouch
->input
, ABS_Y
, usbtouch
->y
);
1323 if (type
->max_press
)
1324 input_report_abs(usbtouch
->input
, ABS_PRESSURE
, usbtouch
->press
);
1325 input_sync(usbtouch
->input
);
1330 static void usbtouch_process_multi(struct usbtouch_usb
*usbtouch
,
1331 unsigned char *pkt
, int len
)
1333 unsigned char *buffer
;
1334 int pkt_len
, pos
, buf_len
, tmp
;
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
);
1343 if (unlikely(!pkt_len
))
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
))
1351 if (usbtouch
->buf_len
+ append
>= usbtouch
->type
->rept_size
)
1353 memcpy(usbtouch
->buffer
+ usbtouch
->buf_len
, pkt
, append
);
1354 usbtouch
->buf_len
+= append
;
1356 pkt_len
= usbtouch
->type
->get_pkt_len(
1357 usbtouch
->buffer
, usbtouch
->buf_len
);
1363 tmp
= pkt_len
- usbtouch
->buf_len
;
1364 if (usbtouch
->buf_len
+ tmp
>= usbtouch
->type
->rept_size
)
1366 memcpy(usbtouch
->buffer
+ usbtouch
->buf_len
, pkt
, tmp
);
1367 usbtouch_process_pkt(usbtouch
, usbtouch
->buffer
, pkt_len
);
1370 buf_len
= len
- tmp
;
1376 /* loop over the received packet, process */
1378 while (pos
< buf_len
) {
1379 /* get packet len */
1380 pkt_len
= usbtouch
->type
->get_pkt_len(buffer
+ pos
,
1383 /* unknown packet: skip one byte */
1384 if (unlikely(!pkt_len
)) {
1389 /* full packet: process */
1390 if (likely((pkt_len
> 0) && (pkt_len
<= buf_len
- pos
))) {
1391 usbtouch_process_pkt(usbtouch
, buffer
+ pos
, pkt_len
);
1393 /* incomplete packet: save in buffer */
1394 memcpy(usbtouch
->buffer
, buffer
+ pos
, buf_len
- pos
);
1395 usbtouch
->buf_len
= buf_len
- pos
;
1402 usbtouch
->buf_len
= 0;
1408 static void usbtouch_irq(struct urb
*urb
)
1410 struct usbtouch_usb
*usbtouch
= urb
->context
;
1411 struct device
*dev
= &usbtouch
->interface
->dev
;
1414 switch (urb
->status
) {
1419 /* this urb is timing out */
1421 "%s - urb timed out - was the device unplugged?\n",
1428 /* this urb is terminated, clean up */
1429 dev_dbg(dev
, "%s - urb shutting down with status: %d\n",
1430 __func__
, urb
->status
);
1433 dev_dbg(dev
, "%s - nonzero urb status received: %d\n",
1434 __func__
, urb
->status
);
1438 usbtouch
->type
->process_pkt(usbtouch
, usbtouch
->data
, urb
->actual_length
);
1441 usb_mark_last_busy(interface_to_usbdev(usbtouch
->interface
));
1442 retval
= usb_submit_urb(urb
, GFP_ATOMIC
);
1444 dev_err(dev
, "%s - usb_submit_urb failed with result: %d\n",
1448 static int usbtouch_open(struct input_dev
*input
)
1450 struct usbtouch_usb
*usbtouch
= input_get_drvdata(input
);
1453 usbtouch
->irq
->dev
= interface_to_usbdev(usbtouch
->interface
);
1455 r
= usb_autopm_get_interface(usbtouch
->interface
) ? -EIO
: 0;
1459 if (!usbtouch
->type
->irq_always
) {
1460 if (usb_submit_urb(usbtouch
->irq
, GFP_KERNEL
)) {
1466 usbtouch
->interface
->needs_remote_wakeup
= 1;
1468 usb_autopm_put_interface(usbtouch
->interface
);
1473 static void usbtouch_close(struct input_dev
*input
)
1475 struct usbtouch_usb
*usbtouch
= input_get_drvdata(input
);
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;
1483 usb_autopm_put_interface(usbtouch
->interface
);
1486 static int usbtouch_suspend
1487 (struct usb_interface
*intf
, pm_message_t message
)
1489 struct usbtouch_usb
*usbtouch
= usb_get_intfdata(intf
);
1491 usb_kill_urb(usbtouch
->irq
);
1496 static int usbtouch_resume(struct usb_interface
*intf
)
1498 struct usbtouch_usb
*usbtouch
= usb_get_intfdata(intf
);
1499 struct input_dev
*input
= usbtouch
->input
;
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
);
1510 static int usbtouch_reset_resume(struct usb_interface
*intf
)
1512 struct usbtouch_usb
*usbtouch
= usb_get_intfdata(intf
);
1513 struct input_dev
*input
= usbtouch
->input
;
1516 /* reinit the device */
1517 if (usbtouch
->type
->init
) {
1518 err
= usbtouch
->type
->init(usbtouch
);
1521 "%s - type->init() failed, err: %d\n",
1527 /* restart IO if needed */
1528 mutex_lock(&input
->mutex
);
1530 err
= usb_submit_urb(usbtouch
->irq
, GFP_NOIO
);
1531 mutex_unlock(&input
->mutex
);
1536 static void usbtouch_free_buffers(struct usb_device
*udev
,
1537 struct usbtouch_usb
*usbtouch
)
1539 usb_free_coherent(udev
, usbtouch
->data_size
,
1540 usbtouch
->data
, usbtouch
->data_dma
);
1541 kfree(usbtouch
->buffer
);
1544 static struct usb_endpoint_descriptor
*
1545 usbtouch_get_input_endpoint(struct usb_host_interface
*interface
)
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
;
1556 static int usbtouch_probe(struct usb_interface
*intf
,
1557 const struct usb_device_id
*id
)
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
;
1566 /* some devices are ignored */
1567 if (id
->driver_info
== DEVTYPE_IGNORE
)
1570 endpoint
= usbtouch_get_input_endpoint(intf
->cur_altsetting
);
1574 usbtouch
= kzalloc(sizeof(struct usbtouch_usb
), GFP_KERNEL
);
1575 input_dev
= input_allocate_device();
1576 if (!usbtouch
|| !input_dev
)
1579 type
= &usbtouch_dev_info
[id
->driver_info
];
1580 usbtouch
->type
= type
;
1581 if (!type
->process_pkt
)
1582 type
->process_pkt
= usbtouch_process_pkt
;
1584 usbtouch
->data_size
= type
->rept_size
;
1585 if (type
->get_pkt_len
) {
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
1593 usbtouch
->data_size
= min(usbtouch
->data_size
,
1594 usb_endpoint_maxp(endpoint
));
1597 usbtouch
->data
= usb_alloc_coherent(udev
, usbtouch
->data_size
,
1598 GFP_KERNEL
, &usbtouch
->data_dma
);
1599 if (!usbtouch
->data
)
1602 if (type
->get_pkt_len
) {
1603 usbtouch
->buffer
= kmalloc(type
->rept_size
, GFP_KERNEL
);
1604 if (!usbtouch
->buffer
)
1605 goto out_free_buffers
;
1608 usbtouch
->irq
= usb_alloc_urb(0, GFP_KERNEL
);
1609 if (!usbtouch
->irq
) {
1611 "%s - usb_alloc_urb failed: usbtouch->irq\n", __func__
);
1612 goto out_free_buffers
;
1615 usbtouch
->interface
= intf
;
1616 usbtouch
->input
= input_dev
;
1618 if (udev
->manufacturer
)
1619 strlcpy(usbtouch
->name
, udev
->manufacturer
, sizeof(usbtouch
->name
));
1621 if (udev
->product
) {
1622 if (udev
->manufacturer
)
1623 strlcat(usbtouch
->name
, " ", sizeof(usbtouch
->name
));
1624 strlcat(usbtouch
->name
, udev
->product
, sizeof(usbtouch
->name
));
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
));
1633 usb_make_path(udev
, usbtouch
->phys
, sizeof(usbtouch
->phys
));
1634 strlcat(usbtouch
->phys
, "/input0", sizeof(usbtouch
->phys
));
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
;
1641 input_set_drvdata(input_dev
, usbtouch
);
1643 input_dev
->open
= usbtouch_open
;
1644 input_dev
->close
= usbtouch_close
;
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);
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
);
1660 usb_fill_bulk_urb(usbtouch
->irq
, udev
,
1661 usb_rcvbulkpipe(udev
, endpoint
->bEndpointAddress
),
1662 usbtouch
->data
, usbtouch
->data_size
,
1663 usbtouch_irq
, usbtouch
);
1665 usbtouch
->irq
->dev
= udev
;
1666 usbtouch
->irq
->transfer_dma
= usbtouch
->data_dma
;
1667 usbtouch
->irq
->transfer_flags
|= URB_NO_TRANSFER_DMA_MAP
;
1669 /* device specific allocations */
1671 err
= type
->alloc(usbtouch
);
1674 "%s - type->alloc() failed, err: %d\n",
1680 /* device specific initialisation*/
1682 err
= type
->init(usbtouch
);
1685 "%s - type->init() failed, err: %d\n",
1691 err
= input_register_device(usbtouch
->input
);
1694 "%s - input_register_device failed, err: %d\n",
1699 usb_set_intfdata(intf
, usbtouch
);
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
);
1706 usb_autopm_put_interface(intf
);
1708 "%s - usb_submit_urb failed with result: %d\n",
1710 goto out_unregister_input
;
1716 out_unregister_input
:
1717 input_unregister_device(input_dev
);
1721 type
->exit(usbtouch
);
1723 usb_free_urb(usbtouch
->irq
);
1725 usbtouch_free_buffers(udev
, usbtouch
);
1727 input_free_device(input_dev
);
1732 static void usbtouch_disconnect(struct usb_interface
*intf
)
1734 struct usbtouch_usb
*usbtouch
= usb_get_intfdata(intf
);
1740 "%s - usbtouch is initialized, cleaning up\n", __func__
);
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
);
1752 MODULE_DEVICE_TABLE(usb
, usbtouch_devices
);
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,
1765 module_usb_driver(usbtouch_driver
);
1767 MODULE_AUTHOR(DRIVER_AUTHOR
);
1768 MODULE_DESCRIPTION(DRIVER_DESC
);
1769 MODULE_LICENSE("GPL");
1771 MODULE_ALIAS("touchkitusb");
1772 MODULE_ALIAS("itmtouch");
1773 MODULE_ALIAS("mtouchusb");