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/usb.h>
55 #include <linux/usb/input.h>
56 #include <linux/hid.h>
59 module_param(swap_xy
, bool, 0644);
60 MODULE_PARM_DESC(swap_xy
, "If set X and Y axes are swapped.");
62 static bool hwcalib_xy
;
63 module_param(hwcalib_xy
, bool, 0644);
64 MODULE_PARM_DESC(hwcalib_xy
, "If set hw-calibrated X/Y are used if available");
66 /* device specifc data/functions */
68 struct usbtouch_device_info
{
71 int min_press
, max_press
;
75 * Always service the USB devices irq not just when the input device is
76 * open. This is useful when devices have a watchdog which prevents us
77 * from periodically polling the device. Leave this unset unless your
78 * touchscreen device requires it, as it does consume more of the USB
83 void (*process_pkt
) (struct usbtouch_usb
*usbtouch
, unsigned char *pkt
, int len
);
86 * used to get the packet len. possible return values:
89 * < 0: -return value more bytes needed
91 int (*get_pkt_len
) (unsigned char *pkt
, int len
);
93 int (*read_data
) (struct usbtouch_usb
*usbtouch
, unsigned char *pkt
);
94 int (*alloc
) (struct usbtouch_usb
*usbtouch
);
95 int (*init
) (struct usbtouch_usb
*usbtouch
);
96 void (*exit
) (struct usbtouch_usb
*usbtouch
);
99 /* a usbtouch device */
100 struct usbtouch_usb
{
104 unsigned char *buffer
;
107 struct usb_interface
*interface
;
108 struct input_dev
*input
;
109 struct usbtouch_device_info
*type
;
130 DEVTYPE_IRTOUCH_HIRES
,
132 DEVTYPE_GENERAL_TOUCH
,
143 #define USB_DEVICE_HID_CLASS(vend, prod) \
144 .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS \
145 | USB_DEVICE_ID_MATCH_DEVICE, \
146 .idVendor = (vend), \
147 .idProduct = (prod), \
148 .bInterfaceClass = USB_INTERFACE_CLASS_HID
150 static const struct usb_device_id usbtouch_devices
[] = {
151 #ifdef CONFIG_TOUCHSCREEN_USB_EGALAX
152 /* ignore the HID capable devices, handled by usbhid */
153 {USB_DEVICE_HID_CLASS(0x0eef, 0x0001), .driver_info
= DEVTYPE_IGNORE
},
154 {USB_DEVICE_HID_CLASS(0x0eef, 0x0002), .driver_info
= DEVTYPE_IGNORE
},
156 /* normal device IDs */
157 {USB_DEVICE(0x3823, 0x0001), .driver_info
= DEVTYPE_EGALAX
},
158 {USB_DEVICE(0x3823, 0x0002), .driver_info
= DEVTYPE_EGALAX
},
159 {USB_DEVICE(0x0123, 0x0001), .driver_info
= DEVTYPE_EGALAX
},
160 {USB_DEVICE(0x0eef, 0x0001), .driver_info
= DEVTYPE_EGALAX
},
161 {USB_DEVICE(0x0eef, 0x0002), .driver_info
= DEVTYPE_EGALAX
},
162 {USB_DEVICE(0x1234, 0x0001), .driver_info
= DEVTYPE_EGALAX
},
163 {USB_DEVICE(0x1234, 0x0002), .driver_info
= DEVTYPE_EGALAX
},
166 #ifdef CONFIG_TOUCHSCREEN_USB_PANJIT
167 {USB_DEVICE(0x134c, 0x0001), .driver_info
= DEVTYPE_PANJIT
},
168 {USB_DEVICE(0x134c, 0x0002), .driver_info
= DEVTYPE_PANJIT
},
169 {USB_DEVICE(0x134c, 0x0003), .driver_info
= DEVTYPE_PANJIT
},
170 {USB_DEVICE(0x134c, 0x0004), .driver_info
= DEVTYPE_PANJIT
},
173 #ifdef CONFIG_TOUCHSCREEN_USB_3M
174 {USB_DEVICE(0x0596, 0x0001), .driver_info
= DEVTYPE_3M
},
177 #ifdef CONFIG_TOUCHSCREEN_USB_ITM
178 {USB_DEVICE(0x0403, 0xf9e9), .driver_info
= DEVTYPE_ITM
},
179 {USB_DEVICE(0x16e3, 0xf9e9), .driver_info
= DEVTYPE_ITM
},
182 #ifdef CONFIG_TOUCHSCREEN_USB_ETURBO
183 {USB_DEVICE(0x1234, 0x5678), .driver_info
= DEVTYPE_ETURBO
},
186 #ifdef CONFIG_TOUCHSCREEN_USB_GUNZE
187 {USB_DEVICE(0x0637, 0x0001), .driver_info
= DEVTYPE_GUNZE
},
190 #ifdef CONFIG_TOUCHSCREEN_USB_DMC_TSC10
191 {USB_DEVICE(0x0afa, 0x03e8), .driver_info
= DEVTYPE_DMC_TSC10
},
194 #ifdef CONFIG_TOUCHSCREEN_USB_IRTOUCH
195 {USB_DEVICE(0x595a, 0x0001), .driver_info
= DEVTYPE_IRTOUCH
},
196 {USB_DEVICE(0x6615, 0x0001), .driver_info
= DEVTYPE_IRTOUCH
},
197 {USB_DEVICE(0x6615, 0x0012), .driver_info
= DEVTYPE_IRTOUCH_HIRES
},
200 #ifdef CONFIG_TOUCHSCREEN_USB_IDEALTEK
201 {USB_DEVICE(0x1391, 0x1000), .driver_info
= DEVTYPE_IDEALTEK
},
204 #ifdef CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH
205 {USB_DEVICE(0x0dfc, 0x0001), .driver_info
= DEVTYPE_GENERAL_TOUCH
},
208 #ifdef CONFIG_TOUCHSCREEN_USB_GOTOP
209 {USB_DEVICE(0x08f2, 0x007f), .driver_info
= DEVTYPE_GOTOP
},
210 {USB_DEVICE(0x08f2, 0x00ce), .driver_info
= DEVTYPE_GOTOP
},
211 {USB_DEVICE(0x08f2, 0x00f4), .driver_info
= DEVTYPE_GOTOP
},
214 #ifdef CONFIG_TOUCHSCREEN_USB_JASTEC
215 {USB_DEVICE(0x0f92, 0x0001), .driver_info
= DEVTYPE_JASTEC
},
218 #ifdef CONFIG_TOUCHSCREEN_USB_E2I
219 {USB_DEVICE(0x1ac7, 0x0001), .driver_info
= DEVTYPE_E2I
},
222 #ifdef CONFIG_TOUCHSCREEN_USB_ZYTRONIC
223 {USB_DEVICE(0x14c8, 0x0003), .driver_info
= DEVTYPE_ZYTRONIC
},
226 #ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC45USB
228 {USB_DEVICE(0x0664, 0x0309), .driver_info
= DEVTYPE_TC45USB
},
230 {USB_DEVICE(0x0664, 0x0306), .driver_info
= DEVTYPE_TC45USB
},
233 #ifdef CONFIG_TOUCHSCREEN_USB_NEXIO
234 /* data interface only */
235 {USB_DEVICE_AND_INTERFACE_INFO(0x10f0, 0x2002, 0x0a, 0x00, 0x00),
236 .driver_info
= DEVTYPE_NEXIO
},
237 {USB_DEVICE_AND_INTERFACE_INFO(0x1870, 0x0001, 0x0a, 0x00, 0x00),
238 .driver_info
= DEVTYPE_NEXIO
},
241 #ifdef CONFIG_TOUCHSCREEN_USB_ELO
242 {USB_DEVICE(0x04e7, 0x0020), .driver_info
= DEVTYPE_ELO
},
245 #ifdef CONFIG_TOUCHSCREEN_USB_EASYTOUCH
246 {USB_DEVICE(0x7374, 0x0001), .driver_info
= DEVTYPE_ETOUCH
},
253 /*****************************************************************************
257 #ifdef CONFIG_TOUCHSCREEN_USB_E2I
258 static int e2i_init(struct usbtouch_usb
*usbtouch
)
261 struct usb_device
*udev
= interface_to_usbdev(usbtouch
->interface
);
263 ret
= usb_control_msg(udev
, usb_rcvctrlpipe(udev
, 0),
264 0x01, 0x02, 0x0000, 0x0081,
265 NULL
, 0, USB_CTRL_SET_TIMEOUT
);
267 dev_dbg(&usbtouch
->interface
->dev
,
268 "%s - usb_control_msg - E2I_RESET - bytes|err: %d\n",
273 static int e2i_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
275 int tmp
= (pkt
[0] << 8) | pkt
[1];
276 dev
->x
= (pkt
[2] << 8) | pkt
[3];
277 dev
->y
= (pkt
[4] << 8) | pkt
[5];
280 dev
->touch
= (tmp
> 0);
281 dev
->press
= (tmp
> 0 ? tmp
: 0);
288 /*****************************************************************************
292 #ifdef CONFIG_TOUCHSCREEN_USB_EGALAX
298 #define EGALAX_PKT_TYPE_MASK 0xFE
299 #define EGALAX_PKT_TYPE_REPT 0x80
300 #define EGALAX_PKT_TYPE_DIAG 0x0A
302 static int egalax_init(struct usbtouch_usb
*usbtouch
)
306 struct usb_device
*udev
= interface_to_usbdev(usbtouch
->interface
);
309 * An eGalax diagnostic packet kicks the device into using the right
310 * protocol. We send a "check active" packet. The response will be
311 * read later and ignored.
314 buf
= kmalloc(3, GFP_KERNEL
);
318 buf
[0] = EGALAX_PKT_TYPE_DIAG
;
319 buf
[1] = 1; /* length */
320 buf
[2] = 'A'; /* command - check active */
322 for (i
= 0; i
< 3; i
++) {
323 ret
= usb_control_msg(udev
, usb_sndctrlpipe(udev
, 0),
325 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
327 USB_CTRL_SET_TIMEOUT
);
341 static int egalax_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
343 if ((pkt
[0] & EGALAX_PKT_TYPE_MASK
) != EGALAX_PKT_TYPE_REPT
)
346 dev
->x
= ((pkt
[3] & 0x0F) << 7) | (pkt
[4] & 0x7F);
347 dev
->y
= ((pkt
[1] & 0x0F) << 7) | (pkt
[2] & 0x7F);
348 dev
->touch
= pkt
[0] & 0x01;
353 static int egalax_get_pkt_len(unsigned char *buf
, int len
)
355 switch (buf
[0] & EGALAX_PKT_TYPE_MASK
) {
356 case EGALAX_PKT_TYPE_REPT
:
359 case EGALAX_PKT_TYPE_DIAG
:
370 /*****************************************************************************
374 #ifdef CONFIG_TOUCHSCREEN_USB_EASYTOUCH
380 #define ETOUCH_PKT_TYPE_MASK 0xFE
381 #define ETOUCH_PKT_TYPE_REPT 0x80
382 #define ETOUCH_PKT_TYPE_REPT2 0xB0
383 #define ETOUCH_PKT_TYPE_DIAG 0x0A
385 static int etouch_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
387 if ((pkt
[0] & ETOUCH_PKT_TYPE_MASK
) != ETOUCH_PKT_TYPE_REPT
&&
388 (pkt
[0] & ETOUCH_PKT_TYPE_MASK
) != ETOUCH_PKT_TYPE_REPT2
)
391 dev
->x
= ((pkt
[1] & 0x1F) << 7) | (pkt
[2] & 0x7F);
392 dev
->y
= ((pkt
[3] & 0x1F) << 7) | (pkt
[4] & 0x7F);
393 dev
->touch
= pkt
[0] & 0x01;
398 static int etouch_get_pkt_len(unsigned char *buf
, int len
)
400 switch (buf
[0] & ETOUCH_PKT_TYPE_MASK
) {
401 case ETOUCH_PKT_TYPE_REPT
:
402 case ETOUCH_PKT_TYPE_REPT2
:
405 case ETOUCH_PKT_TYPE_DIAG
:
416 /*****************************************************************************
419 #ifdef CONFIG_TOUCHSCREEN_USB_PANJIT
420 static int panjit_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
422 dev
->x
= ((pkt
[2] & 0x0F) << 8) | pkt
[1];
423 dev
->y
= ((pkt
[4] & 0x0F) << 8) | pkt
[3];
424 dev
->touch
= pkt
[0] & 0x01;
431 /*****************************************************************************
434 #ifdef CONFIG_TOUCHSCREEN_USB_3M
436 #define MTOUCHUSB_ASYNC_REPORT 1
437 #define MTOUCHUSB_RESET 7
438 #define MTOUCHUSB_REQ_CTRLLR_ID 10
440 static int mtouch_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
443 dev
->x
= (pkt
[4] << 8) | pkt
[3];
444 dev
->y
= 0xffff - ((pkt
[6] << 8) | pkt
[5]);
446 dev
->x
= (pkt
[8] << 8) | pkt
[7];
447 dev
->y
= (pkt
[10] << 8) | pkt
[9];
449 dev
->touch
= (pkt
[2] & 0x40) ? 1 : 0;
454 static int mtouch_init(struct usbtouch_usb
*usbtouch
)
457 struct usb_device
*udev
= interface_to_usbdev(usbtouch
->interface
);
459 ret
= usb_control_msg(udev
, usb_rcvctrlpipe(udev
, 0),
461 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
462 1, 0, NULL
, 0, USB_CTRL_SET_TIMEOUT
);
463 dev_dbg(&usbtouch
->interface
->dev
,
464 "%s - usb_control_msg - MTOUCHUSB_RESET - bytes|err: %d\n",
470 for (i
= 0; i
< 3; i
++) {
471 ret
= usb_control_msg(udev
, usb_rcvctrlpipe(udev
, 0),
472 MTOUCHUSB_ASYNC_REPORT
,
473 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
474 1, 1, NULL
, 0, USB_CTRL_SET_TIMEOUT
);
475 dev_dbg(&usbtouch
->interface
->dev
,
476 "%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d\n",
484 /* Default min/max xy are the raw values, override if using hw-calib */
486 input_set_abs_params(usbtouch
->input
, ABS_X
, 0, 0xffff, 0, 0);
487 input_set_abs_params(usbtouch
->input
, ABS_Y
, 0, 0xffff, 0, 0);
495 /*****************************************************************************
498 #ifdef CONFIG_TOUCHSCREEN_USB_ITM
499 static int itm_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
503 * ITM devices report invalid x/y data if not touched.
504 * if the screen was touched before but is not touched any more
505 * report touch as 0 with the last valid x/y data once. then stop
506 * reporting data until touched again.
508 dev
->press
= ((pkt
[2] & 0x01) << 7) | (pkt
[5] & 0x7F);
510 touch
= ~pkt
[7] & 0x20;
520 dev
->x
= ((pkt
[0] & 0x1F) << 7) | (pkt
[3] & 0x7F);
521 dev
->y
= ((pkt
[1] & 0x1F) << 7) | (pkt
[4] & 0x7F);
529 /*****************************************************************************
532 #ifdef CONFIG_TOUCHSCREEN_USB_ETURBO
536 static int eturbo_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
540 /* packets should start with sync */
541 if (!(pkt
[0] & 0x80))
544 shift
= (6 - (pkt
[0] & 0x03));
545 dev
->x
= ((pkt
[3] << 7) | pkt
[4]) >> shift
;
546 dev
->y
= ((pkt
[1] << 7) | pkt
[2]) >> shift
;
547 dev
->touch
= (pkt
[0] & 0x10) ? 1 : 0;
552 static int eturbo_get_pkt_len(unsigned char *buf
, int len
)
563 /*****************************************************************************
566 #ifdef CONFIG_TOUCHSCREEN_USB_GUNZE
567 static int gunze_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
569 if (!(pkt
[0] & 0x80) || ((pkt
[1] | pkt
[2] | pkt
[3]) & 0x80))
572 dev
->x
= ((pkt
[0] & 0x1F) << 7) | (pkt
[2] & 0x7F);
573 dev
->y
= ((pkt
[1] & 0x1F) << 7) | (pkt
[3] & 0x7F);
574 dev
->touch
= pkt
[0] & 0x20;
580 /*****************************************************************************
583 * Documentation about the controller and it's protocol can be found at
584 * http://www.dmccoltd.com/files/controler/tsc10usb_pi_e.pdf
585 * http://www.dmccoltd.com/files/controler/tsc25_usb_e.pdf
587 #ifdef CONFIG_TOUCHSCREEN_USB_DMC_TSC10
589 /* supported data rates. currently using 130 */
590 #define TSC10_RATE_POINT 0x50
591 #define TSC10_RATE_30 0x40
592 #define TSC10_RATE_50 0x41
593 #define TSC10_RATE_80 0x42
594 #define TSC10_RATE_100 0x43
595 #define TSC10_RATE_130 0x44
596 #define TSC10_RATE_150 0x45
599 #define TSC10_CMD_RESET 0x55
600 #define TSC10_CMD_RATE 0x05
601 #define TSC10_CMD_DATA1 0x01
603 static int dmc_tsc10_init(struct usbtouch_usb
*usbtouch
)
605 struct usb_device
*dev
= interface_to_usbdev(usbtouch
->interface
);
609 buf
= kmalloc(2, GFP_NOIO
);
613 buf
[0] = buf
[1] = 0xFF;
614 ret
= usb_control_msg(dev
, usb_rcvctrlpipe (dev
, 0),
616 USB_DIR_IN
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
617 0, 0, buf
, 2, USB_CTRL_SET_TIMEOUT
);
620 if (buf
[0] != 0x06) {
625 /* TSC-25 data sheet specifies a delay after the RESET command */
628 /* set coordinate output rate */
629 buf
[0] = buf
[1] = 0xFF;
630 ret
= usb_control_msg(dev
, usb_rcvctrlpipe (dev
, 0),
632 USB_DIR_IN
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
633 TSC10_RATE_150
, 0, buf
, 2, USB_CTRL_SET_TIMEOUT
);
636 if ((buf
[0] != 0x06) && (buf
[0] != 0x15 || buf
[1] != 0x01)) {
641 /* start sending data */
642 ret
= usb_control_msg(dev
, usb_rcvctrlpipe (dev
, 0),
644 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
645 0, 0, NULL
, 0, USB_CTRL_SET_TIMEOUT
);
653 static int dmc_tsc10_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
655 dev
->x
= ((pkt
[2] & 0x03) << 8) | pkt
[1];
656 dev
->y
= ((pkt
[4] & 0x03) << 8) | pkt
[3];
657 dev
->touch
= pkt
[0] & 0x01;
664 /*****************************************************************************
667 #ifdef CONFIG_TOUCHSCREEN_USB_IRTOUCH
668 static int irtouch_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
670 dev
->x
= (pkt
[3] << 8) | pkt
[2];
671 dev
->y
= (pkt
[5] << 8) | pkt
[4];
672 dev
->touch
= (pkt
[1] & 0x03) ? 1 : 0;
678 /*****************************************************************************
679 * ET&T TC5UH/TC4UM part
681 #ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC45USB
682 static int tc45usb_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
684 dev
->x
= ((pkt
[2] & 0x0F) << 8) | pkt
[1];
685 dev
->y
= ((pkt
[4] & 0x0F) << 8) | pkt
[3];
686 dev
->touch
= pkt
[0] & 0x01;
692 /*****************************************************************************
693 * IdealTEK URTC1000 Part
695 #ifdef CONFIG_TOUCHSCREEN_USB_IDEALTEK
699 static int idealtek_get_pkt_len(unsigned char *buf
, int len
)
708 static int idealtek_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
710 switch (pkt
[0] & 0x98) {
712 /* touch data in IdealTEK mode */
713 dev
->x
= (pkt
[1] << 5) | (pkt
[2] >> 2);
714 dev
->y
= (pkt
[3] << 5) | (pkt
[4] >> 2);
715 dev
->touch
= (pkt
[0] & 0x40) ? 1 : 0;
719 /* touch data in MT emulation mode */
720 dev
->x
= (pkt
[2] << 5) | (pkt
[1] >> 2);
721 dev
->y
= (pkt
[4] << 5) | (pkt
[3] >> 2);
722 dev
->touch
= (pkt
[0] & 0x40) ? 1 : 0;
731 /*****************************************************************************
734 #ifdef CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH
735 static int general_touch_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
737 dev
->x
= (pkt
[2] << 8) | pkt
[1];
738 dev
->y
= (pkt
[4] << 8) | pkt
[3];
739 dev
->press
= pkt
[5] & 0xff;
740 dev
->touch
= pkt
[0] & 0x01;
746 /*****************************************************************************
749 #ifdef CONFIG_TOUCHSCREEN_USB_GOTOP
750 static int gotop_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
752 dev
->x
= ((pkt
[1] & 0x38) << 4) | pkt
[2];
753 dev
->y
= ((pkt
[1] & 0x07) << 7) | pkt
[3];
754 dev
->touch
= pkt
[0] & 0x01;
760 /*****************************************************************************
763 #ifdef CONFIG_TOUCHSCREEN_USB_JASTEC
764 static int jastec_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
766 dev
->x
= ((pkt
[0] & 0x3f) << 6) | (pkt
[2] & 0x3f);
767 dev
->y
= ((pkt
[1] & 0x3f) << 6) | (pkt
[3] & 0x3f);
768 dev
->touch
= (pkt
[0] & 0x40) >> 6;
774 /*****************************************************************************
777 #ifdef CONFIG_TOUCHSCREEN_USB_ZYTRONIC
778 static int zytronic_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
780 struct usb_interface
*intf
= dev
->interface
;
783 case 0x3A: /* command response */
784 dev_dbg(&intf
->dev
, "%s: Command response %d\n", __func__
, pkt
[1]);
787 case 0xC0: /* down */
788 dev
->x
= (pkt
[1] & 0x7f) | ((pkt
[2] & 0x07) << 7);
789 dev
->y
= (pkt
[3] & 0x7f) | ((pkt
[4] & 0x07) << 7);
791 dev_dbg(&intf
->dev
, "%s: down %d,%d\n", __func__
, dev
->x
, dev
->y
);
795 dev
->x
= (pkt
[1] & 0x7f) | ((pkt
[2] & 0x07) << 7);
796 dev
->y
= (pkt
[3] & 0x7f) | ((pkt
[4] & 0x07) << 7);
798 dev_dbg(&intf
->dev
, "%s: up %d,%d\n", __func__
, dev
->x
, dev
->y
);
802 dev_dbg(&intf
->dev
, "%s: Unknown return %d\n", __func__
, pkt
[0]);
810 /*****************************************************************************
813 #ifdef CONFIG_TOUCHSCREEN_USB_NEXIO
815 #define NEXIO_TIMEOUT 5000
816 #define NEXIO_BUFSIZE 1024
817 #define NEXIO_THRESHOLD 50
821 unsigned char *ack_buf
;
824 struct nexio_touch_packet
{
825 u8 flags
; /* 0xe1 = touch, 0xe1 = release */
826 __be16 data_len
; /* total bytes of touch data */
827 __be16 x_len
; /* bytes for X axis */
828 __be16 y_len
; /* bytes for Y axis */
830 } __attribute__ ((packed
));
832 static unsigned char nexio_ack_pkt
[2] = { 0xaa, 0x02 };
833 static unsigned char nexio_init_pkt
[4] = { 0x82, 0x04, 0x0a, 0x0f };
835 static void nexio_ack_complete(struct urb
*urb
)
839 static int nexio_alloc(struct usbtouch_usb
*usbtouch
)
841 struct nexio_priv
*priv
;
844 usbtouch
->priv
= kmalloc(sizeof(struct nexio_priv
), GFP_KERNEL
);
848 priv
= usbtouch
->priv
;
850 priv
->ack_buf
= kmemdup(nexio_ack_pkt
, sizeof(nexio_ack_pkt
),
855 priv
->ack
= usb_alloc_urb(0, GFP_KERNEL
);
857 dev_dbg(&usbtouch
->interface
->dev
,
858 "%s - usb_alloc_urb failed: usbtouch->ack\n", __func__
);
865 kfree(priv
->ack_buf
);
872 static int nexio_init(struct usbtouch_usb
*usbtouch
)
874 struct usb_device
*dev
= interface_to_usbdev(usbtouch
->interface
);
875 struct usb_host_interface
*interface
= usbtouch
->interface
->cur_altsetting
;
876 struct nexio_priv
*priv
= usbtouch
->priv
;
880 char *firmware_ver
= NULL
, *device_name
= NULL
;
881 int input_ep
= 0, output_ep
= 0;
883 /* find first input and output endpoint */
884 for (i
= 0; i
< interface
->desc
.bNumEndpoints
; i
++) {
886 usb_endpoint_dir_in(&interface
->endpoint
[i
].desc
))
887 input_ep
= interface
->endpoint
[i
].desc
.bEndpointAddress
;
889 usb_endpoint_dir_out(&interface
->endpoint
[i
].desc
))
890 output_ep
= interface
->endpoint
[i
].desc
.bEndpointAddress
;
892 if (!input_ep
|| !output_ep
)
895 buf
= kmalloc(NEXIO_BUFSIZE
, GFP_NOIO
);
899 /* two empty reads */
900 for (i
= 0; i
< 2; i
++) {
901 ret
= usb_bulk_msg(dev
, usb_rcvbulkpipe(dev
, input_ep
),
902 buf
, NEXIO_BUFSIZE
, &actual_len
,
908 /* send init command */
909 memcpy(buf
, nexio_init_pkt
, sizeof(nexio_init_pkt
));
910 ret
= usb_bulk_msg(dev
, usb_sndbulkpipe(dev
, output_ep
),
911 buf
, sizeof(nexio_init_pkt
), &actual_len
,
917 for (i
= 0; i
< 3; i
++) {
918 memset(buf
, 0, NEXIO_BUFSIZE
);
919 ret
= usb_bulk_msg(dev
, usb_rcvbulkpipe(dev
, input_ep
),
920 buf
, NEXIO_BUFSIZE
, &actual_len
,
922 if (ret
< 0 || actual_len
< 1 || buf
[1] != actual_len
)
925 case 0x83: /* firmware version */
927 firmware_ver
= kstrdup(&buf
[2], GFP_NOIO
);
929 case 0x84: /* device name */
931 device_name
= kstrdup(&buf
[2], GFP_NOIO
);
936 printk(KERN_INFO
"Nexio device: %s, firmware version: %s\n",
937 device_name
, firmware_ver
);
942 usb_fill_bulk_urb(priv
->ack
, dev
, usb_sndbulkpipe(dev
, output_ep
),
943 priv
->ack_buf
, sizeof(nexio_ack_pkt
),
944 nexio_ack_complete
, usbtouch
);
952 static void nexio_exit(struct usbtouch_usb
*usbtouch
)
954 struct nexio_priv
*priv
= usbtouch
->priv
;
956 usb_kill_urb(priv
->ack
);
957 usb_free_urb(priv
->ack
);
958 kfree(priv
->ack_buf
);
962 static int nexio_read_data(struct usbtouch_usb
*usbtouch
, unsigned char *pkt
)
964 struct nexio_touch_packet
*packet
= (void *) pkt
;
965 struct nexio_priv
*priv
= usbtouch
->priv
;
966 unsigned int data_len
= be16_to_cpu(packet
->data_len
);
967 unsigned int x_len
= be16_to_cpu(packet
->x_len
);
968 unsigned int y_len
= be16_to_cpu(packet
->y_len
);
969 int x
, y
, begin_x
, begin_y
, end_x
, end_y
, w
, h
, ret
;
971 /* got touch data? */
972 if ((pkt
[0] & 0xe0) != 0xe0)
981 ret
= usb_submit_urb(priv
->ack
, GFP_ATOMIC
);
983 if (!usbtouch
->type
->max_xc
) {
984 usbtouch
->type
->max_xc
= 2 * x_len
;
985 input_set_abs_params(usbtouch
->input
, ABS_X
,
986 0, usbtouch
->type
->max_xc
, 0, 0);
987 usbtouch
->type
->max_yc
= 2 * y_len
;
988 input_set_abs_params(usbtouch
->input
, ABS_Y
,
989 0, usbtouch
->type
->max_yc
, 0, 0);
992 * The device reports state of IR sensors on X and Y axes.
993 * Each byte represents "darkness" percentage (0-100) of one element.
994 * 17" touchscreen reports only 64 x 52 bytes so the resolution is low.
995 * This also means that there's a limited multi-touch capability but
996 * it's disabled (and untested) here as there's no X driver for that.
998 begin_x
= end_x
= begin_y
= end_y
= -1;
999 for (x
= 0; x
< x_len
; x
++) {
1000 if (begin_x
== -1 && packet
->data
[x
] > NEXIO_THRESHOLD
) {
1004 if (end_x
== -1 && begin_x
!= -1 && packet
->data
[x
] < NEXIO_THRESHOLD
) {
1006 for (y
= x_len
; y
< data_len
; y
++) {
1007 if (begin_y
== -1 && packet
->data
[y
] > NEXIO_THRESHOLD
) {
1008 begin_y
= y
- x_len
;
1012 begin_y
!= -1 && packet
->data
[y
] < NEXIO_THRESHOLD
) {
1013 end_y
= y
- 1 - x_len
;
1014 w
= end_x
- begin_x
;
1015 h
= end_y
- begin_y
;
1018 input_report_abs(usbtouch
->input
,
1019 ABS_MT_TOUCH_MAJOR
, max(w
,h
));
1020 input_report_abs(usbtouch
->input
,
1021 ABS_MT_TOUCH_MINOR
, min(x
,h
));
1022 input_report_abs(usbtouch
->input
,
1023 ABS_MT_POSITION_X
, 2*begin_x
+w
);
1024 input_report_abs(usbtouch
->input
,
1025 ABS_MT_POSITION_Y
, 2*begin_y
+h
);
1026 input_report_abs(usbtouch
->input
,
1027 ABS_MT_ORIENTATION
, w
> h
);
1028 input_mt_sync(usbtouch
->input
);
1031 usbtouch
->x
= 2 * begin_x
+ w
;
1032 usbtouch
->y
= 2 * begin_y
+ h
;
1033 usbtouch
->touch
= packet
->flags
& 0x01;
1034 begin_y
= end_y
= -1;
1038 begin_x
= end_x
= -1;
1047 /*****************************************************************************
1051 #ifdef CONFIG_TOUCHSCREEN_USB_ELO
1053 static int elo_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
1055 dev
->x
= (pkt
[3] << 8) | pkt
[2];
1056 dev
->y
= (pkt
[5] << 8) | pkt
[4];
1057 dev
->touch
= pkt
[6] > 0;
1058 dev
->press
= pkt
[6];
1065 /*****************************************************************************
1066 * the different device descriptors
1069 static void usbtouch_process_multi(struct usbtouch_usb
*usbtouch
,
1070 unsigned char *pkt
, int len
);
1073 static struct usbtouch_device_info usbtouch_dev_info
[] = {
1074 #ifdef CONFIG_TOUCHSCREEN_USB_ELO
1082 .read_data
= elo_read_data
,
1086 #ifdef CONFIG_TOUCHSCREEN_USB_EGALAX
1087 [DEVTYPE_EGALAX
] = {
1093 .process_pkt
= usbtouch_process_multi
,
1094 .get_pkt_len
= egalax_get_pkt_len
,
1095 .read_data
= egalax_read_data
,
1096 .init
= egalax_init
,
1100 #ifdef CONFIG_TOUCHSCREEN_USB_PANJIT
1101 [DEVTYPE_PANJIT
] = {
1107 .read_data
= panjit_read_data
,
1111 #ifdef CONFIG_TOUCHSCREEN_USB_3M
1118 .read_data
= mtouch_read_data
,
1119 .init
= mtouch_init
,
1123 #ifdef CONFIG_TOUCHSCREEN_USB_ITM
1131 .read_data
= itm_read_data
,
1135 #ifdef CONFIG_TOUCHSCREEN_USB_ETURBO
1136 [DEVTYPE_ETURBO
] = {
1142 .process_pkt
= usbtouch_process_multi
,
1143 .get_pkt_len
= eturbo_get_pkt_len
,
1144 .read_data
= eturbo_read_data
,
1148 #ifdef CONFIG_TOUCHSCREEN_USB_GUNZE
1155 .read_data
= gunze_read_data
,
1159 #ifdef CONFIG_TOUCHSCREEN_USB_DMC_TSC10
1160 [DEVTYPE_DMC_TSC10
] = {
1166 .init
= dmc_tsc10_init
,
1167 .read_data
= dmc_tsc10_read_data
,
1171 #ifdef CONFIG_TOUCHSCREEN_USB_IRTOUCH
1172 [DEVTYPE_IRTOUCH
] = {
1178 .read_data
= irtouch_read_data
,
1181 [DEVTYPE_IRTOUCH_HIRES
] = {
1187 .read_data
= irtouch_read_data
,
1191 #ifdef CONFIG_TOUCHSCREEN_USB_IDEALTEK
1192 [DEVTYPE_IDEALTEK
] = {
1198 .process_pkt
= usbtouch_process_multi
,
1199 .get_pkt_len
= idealtek_get_pkt_len
,
1200 .read_data
= idealtek_read_data
,
1204 #ifdef CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH
1205 [DEVTYPE_GENERAL_TOUCH
] = {
1211 .read_data
= general_touch_read_data
,
1215 #ifdef CONFIG_TOUCHSCREEN_USB_GOTOP
1222 .read_data
= gotop_read_data
,
1226 #ifdef CONFIG_TOUCHSCREEN_USB_JASTEC
1227 [DEVTYPE_JASTEC
] = {
1233 .read_data
= jastec_read_data
,
1237 #ifdef CONFIG_TOUCHSCREEN_USB_E2I
1245 .read_data
= e2i_read_data
,
1249 #ifdef CONFIG_TOUCHSCREEN_USB_ZYTRONIC
1250 [DEVTYPE_ZYTRONIC
] = {
1256 .read_data
= zytronic_read_data
,
1261 #ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC45USB
1262 [DEVTYPE_TC45USB
] = {
1268 .read_data
= tc45usb_read_data
,
1272 #ifdef CONFIG_TOUCHSCREEN_USB_NEXIO
1276 .read_data
= nexio_read_data
,
1277 .alloc
= nexio_alloc
,
1282 #ifdef CONFIG_TOUCHSCREEN_USB_EASYTOUCH
1283 [DEVTYPE_ETOUCH
] = {
1289 .process_pkt
= usbtouch_process_multi
,
1290 .get_pkt_len
= etouch_get_pkt_len
,
1291 .read_data
= etouch_read_data
,
1297 /*****************************************************************************
1300 static void usbtouch_process_pkt(struct usbtouch_usb
*usbtouch
,
1301 unsigned char *pkt
, int len
)
1303 struct usbtouch_device_info
*type
= usbtouch
->type
;
1305 if (!type
->read_data(usbtouch
, pkt
))
1308 input_report_key(usbtouch
->input
, BTN_TOUCH
, usbtouch
->touch
);
1311 input_report_abs(usbtouch
->input
, ABS_X
, usbtouch
->y
);
1312 input_report_abs(usbtouch
->input
, ABS_Y
, usbtouch
->x
);
1314 input_report_abs(usbtouch
->input
, ABS_X
, usbtouch
->x
);
1315 input_report_abs(usbtouch
->input
, ABS_Y
, usbtouch
->y
);
1317 if (type
->max_press
)
1318 input_report_abs(usbtouch
->input
, ABS_PRESSURE
, usbtouch
->press
);
1319 input_sync(usbtouch
->input
);
1324 static void usbtouch_process_multi(struct usbtouch_usb
*usbtouch
,
1325 unsigned char *pkt
, int len
)
1327 unsigned char *buffer
;
1328 int pkt_len
, pos
, buf_len
, tmp
;
1330 /* process buffer */
1331 if (unlikely(usbtouch
->buf_len
)) {
1332 /* try to get size */
1333 pkt_len
= usbtouch
->type
->get_pkt_len(
1334 usbtouch
->buffer
, usbtouch
->buf_len
);
1337 if (unlikely(!pkt_len
))
1340 /* need to append -pkt_len bytes before able to get size */
1341 if (unlikely(pkt_len
< 0)) {
1342 int append
= -pkt_len
;
1343 if (unlikely(append
> len
))
1345 if (usbtouch
->buf_len
+ append
>= usbtouch
->type
->rept_size
)
1347 memcpy(usbtouch
->buffer
+ usbtouch
->buf_len
, pkt
, append
);
1348 usbtouch
->buf_len
+= append
;
1350 pkt_len
= usbtouch
->type
->get_pkt_len(
1351 usbtouch
->buffer
, usbtouch
->buf_len
);
1357 tmp
= pkt_len
- usbtouch
->buf_len
;
1358 if (usbtouch
->buf_len
+ tmp
>= usbtouch
->type
->rept_size
)
1360 memcpy(usbtouch
->buffer
+ usbtouch
->buf_len
, pkt
, tmp
);
1361 usbtouch_process_pkt(usbtouch
, usbtouch
->buffer
, pkt_len
);
1364 buf_len
= len
- tmp
;
1370 /* loop over the received packet, process */
1372 while (pos
< buf_len
) {
1373 /* get packet len */
1374 pkt_len
= usbtouch
->type
->get_pkt_len(buffer
+ pos
,
1377 /* unknown packet: skip one byte */
1378 if (unlikely(!pkt_len
)) {
1383 /* full packet: process */
1384 if (likely((pkt_len
> 0) && (pkt_len
<= buf_len
- pos
))) {
1385 usbtouch_process_pkt(usbtouch
, buffer
+ pos
, pkt_len
);
1387 /* incomplete packet: save in buffer */
1388 memcpy(usbtouch
->buffer
, buffer
+ pos
, buf_len
- pos
);
1389 usbtouch
->buf_len
= buf_len
- pos
;
1396 usbtouch
->buf_len
= 0;
1402 static void usbtouch_irq(struct urb
*urb
)
1404 struct usbtouch_usb
*usbtouch
= urb
->context
;
1405 struct device
*dev
= &usbtouch
->interface
->dev
;
1408 switch (urb
->status
) {
1413 /* this urb is timing out */
1415 "%s - urb timed out - was the device unplugged?\n",
1422 /* this urb is terminated, clean up */
1423 dev_dbg(dev
, "%s - urb shutting down with status: %d\n",
1424 __func__
, urb
->status
);
1427 dev_dbg(dev
, "%s - nonzero urb status received: %d\n",
1428 __func__
, urb
->status
);
1432 usbtouch
->type
->process_pkt(usbtouch
, usbtouch
->data
, urb
->actual_length
);
1435 usb_mark_last_busy(interface_to_usbdev(usbtouch
->interface
));
1436 retval
= usb_submit_urb(urb
, GFP_ATOMIC
);
1438 dev_err(dev
, "%s - usb_submit_urb failed with result: %d\n",
1442 static int usbtouch_open(struct input_dev
*input
)
1444 struct usbtouch_usb
*usbtouch
= input_get_drvdata(input
);
1447 usbtouch
->irq
->dev
= interface_to_usbdev(usbtouch
->interface
);
1449 r
= usb_autopm_get_interface(usbtouch
->interface
) ? -EIO
: 0;
1453 if (!usbtouch
->type
->irq_always
) {
1454 if (usb_submit_urb(usbtouch
->irq
, GFP_KERNEL
)) {
1460 usbtouch
->interface
->needs_remote_wakeup
= 1;
1462 usb_autopm_put_interface(usbtouch
->interface
);
1467 static void usbtouch_close(struct input_dev
*input
)
1469 struct usbtouch_usb
*usbtouch
= input_get_drvdata(input
);
1472 if (!usbtouch
->type
->irq_always
)
1473 usb_kill_urb(usbtouch
->irq
);
1474 r
= usb_autopm_get_interface(usbtouch
->interface
);
1475 usbtouch
->interface
->needs_remote_wakeup
= 0;
1477 usb_autopm_put_interface(usbtouch
->interface
);
1480 static int usbtouch_suspend
1481 (struct usb_interface
*intf
, pm_message_t message
)
1483 struct usbtouch_usb
*usbtouch
= usb_get_intfdata(intf
);
1485 usb_kill_urb(usbtouch
->irq
);
1490 static int usbtouch_resume(struct usb_interface
*intf
)
1492 struct usbtouch_usb
*usbtouch
= usb_get_intfdata(intf
);
1493 struct input_dev
*input
= usbtouch
->input
;
1496 mutex_lock(&input
->mutex
);
1497 if (input
->users
|| usbtouch
->type
->irq_always
)
1498 result
= usb_submit_urb(usbtouch
->irq
, GFP_NOIO
);
1499 mutex_unlock(&input
->mutex
);
1504 static int usbtouch_reset_resume(struct usb_interface
*intf
)
1506 struct usbtouch_usb
*usbtouch
= usb_get_intfdata(intf
);
1507 struct input_dev
*input
= usbtouch
->input
;
1510 /* reinit the device */
1511 if (usbtouch
->type
->init
) {
1512 err
= usbtouch
->type
->init(usbtouch
);
1515 "%s - type->init() failed, err: %d\n",
1521 /* restart IO if needed */
1522 mutex_lock(&input
->mutex
);
1524 err
= usb_submit_urb(usbtouch
->irq
, GFP_NOIO
);
1525 mutex_unlock(&input
->mutex
);
1530 static void usbtouch_free_buffers(struct usb_device
*udev
,
1531 struct usbtouch_usb
*usbtouch
)
1533 usb_free_coherent(udev
, usbtouch
->data_size
,
1534 usbtouch
->data
, usbtouch
->data_dma
);
1535 kfree(usbtouch
->buffer
);
1538 static struct usb_endpoint_descriptor
*
1539 usbtouch_get_input_endpoint(struct usb_host_interface
*interface
)
1543 for (i
= 0; i
< interface
->desc
.bNumEndpoints
; i
++)
1544 if (usb_endpoint_dir_in(&interface
->endpoint
[i
].desc
))
1545 return &interface
->endpoint
[i
].desc
;
1550 static int usbtouch_probe(struct usb_interface
*intf
,
1551 const struct usb_device_id
*id
)
1553 struct usbtouch_usb
*usbtouch
;
1554 struct input_dev
*input_dev
;
1555 struct usb_endpoint_descriptor
*endpoint
;
1556 struct usb_device
*udev
= interface_to_usbdev(intf
);
1557 struct usbtouch_device_info
*type
;
1560 /* some devices are ignored */
1561 if (id
->driver_info
== DEVTYPE_IGNORE
)
1564 endpoint
= usbtouch_get_input_endpoint(intf
->cur_altsetting
);
1568 usbtouch
= kzalloc(sizeof(struct usbtouch_usb
), GFP_KERNEL
);
1569 input_dev
= input_allocate_device();
1570 if (!usbtouch
|| !input_dev
)
1573 type
= &usbtouch_dev_info
[id
->driver_info
];
1574 usbtouch
->type
= type
;
1575 if (!type
->process_pkt
)
1576 type
->process_pkt
= usbtouch_process_pkt
;
1578 usbtouch
->data_size
= type
->rept_size
;
1579 if (type
->get_pkt_len
) {
1581 * When dealing with variable-length packets we should
1582 * not request more than wMaxPacketSize bytes at once
1583 * as we do not know if there is more data coming or
1584 * we filled exactly wMaxPacketSize bytes and there is
1587 usbtouch
->data_size
= min(usbtouch
->data_size
,
1588 usb_endpoint_maxp(endpoint
));
1591 usbtouch
->data
= usb_alloc_coherent(udev
, usbtouch
->data_size
,
1592 GFP_KERNEL
, &usbtouch
->data_dma
);
1593 if (!usbtouch
->data
)
1596 if (type
->get_pkt_len
) {
1597 usbtouch
->buffer
= kmalloc(type
->rept_size
, GFP_KERNEL
);
1598 if (!usbtouch
->buffer
)
1599 goto out_free_buffers
;
1602 usbtouch
->irq
= usb_alloc_urb(0, GFP_KERNEL
);
1603 if (!usbtouch
->irq
) {
1605 "%s - usb_alloc_urb failed: usbtouch->irq\n", __func__
);
1606 goto out_free_buffers
;
1609 usbtouch
->interface
= intf
;
1610 usbtouch
->input
= input_dev
;
1612 if (udev
->manufacturer
)
1613 strlcpy(usbtouch
->name
, udev
->manufacturer
, sizeof(usbtouch
->name
));
1615 if (udev
->product
) {
1616 if (udev
->manufacturer
)
1617 strlcat(usbtouch
->name
, " ", sizeof(usbtouch
->name
));
1618 strlcat(usbtouch
->name
, udev
->product
, sizeof(usbtouch
->name
));
1621 if (!strlen(usbtouch
->name
))
1622 snprintf(usbtouch
->name
, sizeof(usbtouch
->name
),
1623 "USB Touchscreen %04x:%04x",
1624 le16_to_cpu(udev
->descriptor
.idVendor
),
1625 le16_to_cpu(udev
->descriptor
.idProduct
));
1627 usb_make_path(udev
, usbtouch
->phys
, sizeof(usbtouch
->phys
));
1628 strlcat(usbtouch
->phys
, "/input0", sizeof(usbtouch
->phys
));
1630 input_dev
->name
= usbtouch
->name
;
1631 input_dev
->phys
= usbtouch
->phys
;
1632 usb_to_input_id(udev
, &input_dev
->id
);
1633 input_dev
->dev
.parent
= &intf
->dev
;
1635 input_set_drvdata(input_dev
, usbtouch
);
1637 input_dev
->open
= usbtouch_open
;
1638 input_dev
->close
= usbtouch_close
;
1640 input_dev
->evbit
[0] = BIT_MASK(EV_KEY
) | BIT_MASK(EV_ABS
);
1641 input_dev
->keybit
[BIT_WORD(BTN_TOUCH
)] = BIT_MASK(BTN_TOUCH
);
1642 input_set_abs_params(input_dev
, ABS_X
, type
->min_xc
, type
->max_xc
, 0, 0);
1643 input_set_abs_params(input_dev
, ABS_Y
, type
->min_yc
, type
->max_yc
, 0, 0);
1644 if (type
->max_press
)
1645 input_set_abs_params(input_dev
, ABS_PRESSURE
, type
->min_press
,
1646 type
->max_press
, 0, 0);
1648 if (usb_endpoint_type(endpoint
) == USB_ENDPOINT_XFER_INT
)
1649 usb_fill_int_urb(usbtouch
->irq
, udev
,
1650 usb_rcvintpipe(udev
, endpoint
->bEndpointAddress
),
1651 usbtouch
->data
, usbtouch
->data_size
,
1652 usbtouch_irq
, usbtouch
, endpoint
->bInterval
);
1654 usb_fill_bulk_urb(usbtouch
->irq
, udev
,
1655 usb_rcvbulkpipe(udev
, endpoint
->bEndpointAddress
),
1656 usbtouch
->data
, usbtouch
->data_size
,
1657 usbtouch_irq
, usbtouch
);
1659 usbtouch
->irq
->dev
= udev
;
1660 usbtouch
->irq
->transfer_dma
= usbtouch
->data_dma
;
1661 usbtouch
->irq
->transfer_flags
|= URB_NO_TRANSFER_DMA_MAP
;
1663 /* device specific allocations */
1665 err
= type
->alloc(usbtouch
);
1668 "%s - type->alloc() failed, err: %d\n",
1674 /* device specific initialisation*/
1676 err
= type
->init(usbtouch
);
1679 "%s - type->init() failed, err: %d\n",
1685 err
= input_register_device(usbtouch
->input
);
1688 "%s - input_register_device failed, err: %d\n",
1693 usb_set_intfdata(intf
, usbtouch
);
1695 if (usbtouch
->type
->irq_always
) {
1696 /* this can't fail */
1697 usb_autopm_get_interface(intf
);
1698 err
= usb_submit_urb(usbtouch
->irq
, GFP_KERNEL
);
1700 usb_autopm_put_interface(intf
);
1702 "%s - usb_submit_urb failed with result: %d\n",
1704 goto out_unregister_input
;
1710 out_unregister_input
:
1711 input_unregister_device(input_dev
);
1715 type
->exit(usbtouch
);
1717 usb_free_urb(usbtouch
->irq
);
1719 usbtouch_free_buffers(udev
, usbtouch
);
1721 input_free_device(input_dev
);
1726 static void usbtouch_disconnect(struct usb_interface
*intf
)
1728 struct usbtouch_usb
*usbtouch
= usb_get_intfdata(intf
);
1734 "%s - usbtouch is initialized, cleaning up\n", __func__
);
1736 usb_set_intfdata(intf
, NULL
);
1737 /* this will stop IO via close */
1738 input_unregister_device(usbtouch
->input
);
1739 usb_free_urb(usbtouch
->irq
);
1740 if (usbtouch
->type
->exit
)
1741 usbtouch
->type
->exit(usbtouch
);
1742 usbtouch_free_buffers(interface_to_usbdev(intf
), usbtouch
);
1746 MODULE_DEVICE_TABLE(usb
, usbtouch_devices
);
1748 static struct usb_driver usbtouch_driver
= {
1749 .name
= "usbtouchscreen",
1750 .probe
= usbtouch_probe
,
1751 .disconnect
= usbtouch_disconnect
,
1752 .suspend
= usbtouch_suspend
,
1753 .resume
= usbtouch_resume
,
1754 .reset_resume
= usbtouch_reset_resume
,
1755 .id_table
= usbtouch_devices
,
1756 .supports_autosuspend
= 1,
1759 module_usb_driver(usbtouch_driver
);
1761 MODULE_AUTHOR("Daniel Ritz <daniel.ritz@gmx.ch>");
1762 MODULE_DESCRIPTION("USB Touchscreen Driver");
1763 MODULE_LICENSE("GPL");
1765 MODULE_ALIAS("touchkitusb");
1766 MODULE_ALIAS("itmtouch");
1767 MODULE_ALIAS("mtouchusb");