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 * Copyright (C) 2004-2006 by Daniel Ritz <daniel.ritz@gmx.ch>
16 * Copyright (C) by Todd E. Johnson (mtouchusb.c)
18 * This program is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public License as
20 * published by the Free Software Foundation; either version 2 of the
21 * License, or (at your option) any later version.
23 * This program is distributed in the hope that it will be useful, but
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 * General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32 * Driver is based on touchkitusb.c
33 * - ITM parts are from itmtouch.c
34 * - 3M parts are from mtouchusb.c
35 * - PanJit parts are from an unmerged driver by Lanslott Gish
36 * - DMC TSC 10/25 are from Holger Schurig, with ideas from an unmerged
37 * driver from Marius Vollmer
39 *****************************************************************************/
43 #include <linux/kernel.h>
44 #include <linux/slab.h>
45 #include <linux/input.h>
46 #include <linux/module.h>
47 #include <linux/init.h>
48 #include <linux/usb.h>
49 #include <linux/usb/input.h>
52 #define DRIVER_VERSION "v0.5"
53 #define DRIVER_AUTHOR "Daniel Ritz <daniel.ritz@gmx.ch>"
54 #define DRIVER_DESC "USB Touchscreen Driver"
57 module_param(swap_xy
, bool, 0644);
58 MODULE_PARM_DESC(swap_xy
, "If set X and Y axes are swapped.");
60 /* device specifc data/functions */
62 struct usbtouch_device_info
{
65 int min_press
, max_press
;
69 void (*process_pkt
) (struct usbtouch_usb
*usbtouch
, unsigned char *pkt
, int len
);
70 int (*get_pkt_len
) (unsigned char *pkt
, int len
);
71 int (*read_data
) (struct usbtouch_usb
*usbtouch
, unsigned char *pkt
);
72 int (*init
) (struct usbtouch_usb
*usbtouch
);
75 #define USBTOUCH_FLG_BUFFER 0x01
78 /* a usbtouch device */
82 unsigned char *buffer
;
85 struct usb_device
*udev
;
86 struct input_dev
*input
;
87 struct usbtouch_device_info
*type
;
96 #if defined(CONFIG_TOUCHSCREEN_USB_EGALAX) || defined(CONFIG_TOUCHSCREEN_USB_ETURBO) || defined(CONFIG_TOUCHSCREEN_USB_IDEALTEK)
101 static void usbtouch_process_multi(struct usbtouch_usb
*usbtouch
,
102 unsigned char *pkt
, int len
);
119 static struct usb_device_id usbtouch_devices
[] = {
120 #ifdef CONFIG_TOUCHSCREEN_USB_EGALAX
121 {USB_DEVICE(0x3823, 0x0001), .driver_info
= DEVTYPE_EGALAX
},
122 {USB_DEVICE(0x3823, 0x0002), .driver_info
= DEVTYPE_EGALAX
},
123 {USB_DEVICE(0x0123, 0x0001), .driver_info
= DEVTYPE_EGALAX
},
124 {USB_DEVICE(0x0eef, 0x0001), .driver_info
= DEVTYPE_EGALAX
},
125 {USB_DEVICE(0x0eef, 0x0002), .driver_info
= DEVTYPE_EGALAX
},
126 {USB_DEVICE(0x1234, 0x0001), .driver_info
= DEVTYPE_EGALAX
},
127 {USB_DEVICE(0x1234, 0x0002), .driver_info
= DEVTYPE_EGALAX
},
130 #ifdef CONFIG_TOUCHSCREEN_USB_PANJIT
131 {USB_DEVICE(0x134c, 0x0001), .driver_info
= DEVTYPE_PANJIT
},
132 {USB_DEVICE(0x134c, 0x0002), .driver_info
= DEVTYPE_PANJIT
},
133 {USB_DEVICE(0x134c, 0x0003), .driver_info
= DEVTYPE_PANJIT
},
134 {USB_DEVICE(0x134c, 0x0004), .driver_info
= DEVTYPE_PANJIT
},
137 #ifdef CONFIG_TOUCHSCREEN_USB_3M
138 {USB_DEVICE(0x0596, 0x0001), .driver_info
= DEVTYPE_3M
},
141 #ifdef CONFIG_TOUCHSCREEN_USB_ITM
142 {USB_DEVICE(0x0403, 0xf9e9), .driver_info
= DEVTYPE_ITM
},
145 #ifdef CONFIG_TOUCHSCREEN_USB_ETURBO
146 {USB_DEVICE(0x1234, 0x5678), .driver_info
= DEVTYPE_ETURBO
},
149 #ifdef CONFIG_TOUCHSCREEN_USB_GUNZE
150 {USB_DEVICE(0x0637, 0x0001), .driver_info
= DEVTYPE_GUNZE
},
153 #ifdef CONFIG_TOUCHSCREEN_USB_DMC_TSC10
154 {USB_DEVICE(0x0afa, 0x03e8), .driver_info
= DEVTYPE_DMC_TSC10
},
157 #ifdef CONFIG_TOUCHSCREEN_USB_IRTOUCH
158 {USB_DEVICE(0x595a, 0x0001), .driver_info
= DEVTYPE_IRTOUCH
},
159 {USB_DEVICE(0x6615, 0x0001), .driver_info
= DEVTYPE_IRTOUCH
},
162 #ifdef CONFIG_TOUCHSCREEN_USB_IDEALTEK
163 {USB_DEVICE(0x1391, 0x1000), .driver_info
= DEVTYPE_IDEALTEK
},
170 /*****************************************************************************
174 #ifdef CONFIG_TOUCHSCREEN_USB_EGALAX
176 #define EGALAX_PKT_TYPE_MASK 0xFE
177 #define EGALAX_PKT_TYPE_REPT 0x80
178 #define EGALAX_PKT_TYPE_DIAG 0x0A
180 static int egalax_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
182 if ((pkt
[0] & EGALAX_PKT_TYPE_MASK
) != EGALAX_PKT_TYPE_REPT
)
185 dev
->x
= ((pkt
[3] & 0x0F) << 7) | (pkt
[4] & 0x7F);
186 dev
->y
= ((pkt
[1] & 0x0F) << 7) | (pkt
[2] & 0x7F);
187 dev
->touch
= pkt
[0] & 0x01;
192 static int egalax_get_pkt_len(unsigned char *buf
, int len
)
194 switch (buf
[0] & EGALAX_PKT_TYPE_MASK
) {
195 case EGALAX_PKT_TYPE_REPT
:
198 case EGALAX_PKT_TYPE_DIAG
:
210 /*****************************************************************************
213 #ifdef CONFIG_TOUCHSCREEN_USB_PANJIT
214 static int panjit_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
216 dev
->x
= ((pkt
[2] & 0x0F) << 8) | pkt
[1];
217 dev
->y
= ((pkt
[4] & 0x0F) << 8) | pkt
[3];
218 dev
->touch
= pkt
[0] & 0x01;
225 /*****************************************************************************
228 #ifdef CONFIG_TOUCHSCREEN_USB_3M
230 #define MTOUCHUSB_ASYNC_REPORT 1
231 #define MTOUCHUSB_RESET 7
232 #define MTOUCHUSB_REQ_CTRLLR_ID 10
234 static int mtouch_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
236 dev
->x
= (pkt
[8] << 8) | pkt
[7];
237 dev
->y
= (pkt
[10] << 8) | pkt
[9];
238 dev
->touch
= (pkt
[2] & 0x40) ? 1 : 0;
243 static int mtouch_init(struct usbtouch_usb
*usbtouch
)
247 ret
= usb_control_msg(usbtouch
->udev
, usb_rcvctrlpipe(usbtouch
->udev
, 0),
249 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
250 1, 0, NULL
, 0, USB_CTRL_SET_TIMEOUT
);
251 dbg("%s - usb_control_msg - MTOUCHUSB_RESET - bytes|err: %d",
257 for (i
= 0; i
< 3; i
++) {
258 ret
= usb_control_msg(usbtouch
->udev
, usb_rcvctrlpipe(usbtouch
->udev
, 0),
259 MTOUCHUSB_ASYNC_REPORT
,
260 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
261 1, 1, NULL
, 0, USB_CTRL_SET_TIMEOUT
);
262 dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d",
275 /*****************************************************************************
278 #ifdef CONFIG_TOUCHSCREEN_USB_ITM
279 static int itm_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
283 * ITM devices report invalid x/y data if not touched.
284 * if the screen was touched before but is not touched any more
285 * report touch as 0 with the last valid x/y data once. then stop
286 * reporting data until touched again.
288 dev
->press
= ((pkt
[2] & 0x01) << 7) | (pkt
[5] & 0x7F);
290 touch
= ~pkt
[7] & 0x20;
300 dev
->x
= ((pkt
[0] & 0x1F) << 7) | (pkt
[3] & 0x7F);
301 dev
->y
= ((pkt
[1] & 0x1F) << 7) | (pkt
[4] & 0x7F);
309 /*****************************************************************************
312 #ifdef CONFIG_TOUCHSCREEN_USB_ETURBO
313 static int eturbo_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
317 /* packets should start with sync */
318 if (!(pkt
[0] & 0x80))
321 shift
= (6 - (pkt
[0] & 0x03));
322 dev
->x
= ((pkt
[3] << 7) | pkt
[4]) >> shift
;
323 dev
->y
= ((pkt
[1] << 7) | pkt
[2]) >> shift
;
324 dev
->touch
= (pkt
[0] & 0x10) ? 1 : 0;
329 static int eturbo_get_pkt_len(unsigned char *buf
, int len
)
340 /*****************************************************************************
343 #ifdef CONFIG_TOUCHSCREEN_USB_GUNZE
344 static int gunze_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
346 if (!(pkt
[0] & 0x80) || ((pkt
[1] | pkt
[2] | pkt
[3]) & 0x80))
349 dev
->x
= ((pkt
[0] & 0x1F) << 7) | (pkt
[2] & 0x7F);
350 dev
->y
= ((pkt
[1] & 0x1F) << 7) | (pkt
[3] & 0x7F);
351 dev
->touch
= pkt
[0] & 0x20;
357 /*****************************************************************************
360 * Documentation about the controller and it's protocol can be found at
361 * http://www.dmccoltd.com/files/controler/tsc10usb_pi_e.pdf
362 * http://www.dmccoltd.com/files/controler/tsc25_usb_e.pdf
364 #ifdef CONFIG_TOUCHSCREEN_USB_DMC_TSC10
366 /* supported data rates. currently using 130 */
367 #define TSC10_RATE_POINT 0x50
368 #define TSC10_RATE_30 0x40
369 #define TSC10_RATE_50 0x41
370 #define TSC10_RATE_80 0x42
371 #define TSC10_RATE_100 0x43
372 #define TSC10_RATE_130 0x44
373 #define TSC10_RATE_150 0x45
376 #define TSC10_CMD_RESET 0x55
377 #define TSC10_CMD_RATE 0x05
378 #define TSC10_CMD_DATA1 0x01
380 static int dmc_tsc10_init(struct usbtouch_usb
*usbtouch
)
382 struct usb_device
*dev
= usbtouch
->udev
;
384 unsigned char buf
[2];
387 buf
[0] = buf
[1] = 0xFF;
388 ret
= usb_control_msg(dev
, usb_rcvctrlpipe (dev
, 0),
390 USB_DIR_IN
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
391 0, 0, buf
, 2, USB_CTRL_SET_TIMEOUT
);
394 if (buf
[0] != 0x06 || buf
[1] != 0x00)
397 /* set coordinate output rate */
398 buf
[0] = buf
[1] = 0xFF;
399 ret
= usb_control_msg(dev
, usb_rcvctrlpipe (dev
, 0),
401 USB_DIR_IN
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
402 TSC10_RATE_150
, 0, buf
, 2, USB_CTRL_SET_TIMEOUT
);
405 if ((buf
[0] != 0x06 || buf
[1] != 0x00) &&
406 (buf
[0] != 0x15 || buf
[1] != 0x01))
409 /* start sending data */
410 ret
= usb_control_msg(dev
, usb_rcvctrlpipe (dev
, 0),
412 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_DEVICE
,
413 0, 0, NULL
, 0, USB_CTRL_SET_TIMEOUT
);
421 static int dmc_tsc10_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
423 dev
->x
= ((pkt
[2] & 0x03) << 8) | pkt
[1];
424 dev
->y
= ((pkt
[4] & 0x03) << 8) | pkt
[3];
425 dev
->touch
= pkt
[0] & 0x01;
432 /*****************************************************************************
435 #ifdef CONFIG_TOUCHSCREEN_USB_IRTOUCH
436 static int irtouch_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
438 dev
->x
= (pkt
[3] << 8) | pkt
[2];
439 dev
->y
= (pkt
[5] << 8) | pkt
[4];
440 dev
->touch
= (pkt
[1] & 0x03) ? 1 : 0;
447 /*****************************************************************************
448 * IdealTEK URTC1000 Part
450 #ifdef CONFIG_TOUCHSCREEN_USB_IDEALTEK
451 static int idealtek_get_pkt_len(unsigned char *buf
, int len
)
460 static int idealtek_read_data(struct usbtouch_usb
*dev
, unsigned char *pkt
)
462 switch (pkt
[0] & 0x98) {
464 /* touch data in IdealTEK mode */
465 dev
->x
= (pkt
[1] << 5) | (pkt
[2] >> 2);
466 dev
->y
= (pkt
[3] << 5) | (pkt
[4] >> 2);
467 dev
->touch
= (pkt
[0] & 0x40) ? 1 : 0;
471 /* touch data in MT emulation mode */
472 dev
->x
= (pkt
[2] << 5) | (pkt
[1] >> 2);
473 dev
->y
= (pkt
[4] << 5) | (pkt
[3] >> 2);
474 dev
->touch
= (pkt
[0] & 0x40) ? 1 : 0;
484 /*****************************************************************************
485 * the different device descriptors
487 static struct usbtouch_device_info usbtouch_dev_info
[] = {
488 #ifdef CONFIG_TOUCHSCREEN_USB_EGALAX
495 .flags
= USBTOUCH_FLG_BUFFER
,
496 .process_pkt
= usbtouch_process_multi
,
497 .get_pkt_len
= egalax_get_pkt_len
,
498 .read_data
= egalax_read_data
,
502 #ifdef CONFIG_TOUCHSCREEN_USB_PANJIT
509 .read_data
= panjit_read_data
,
513 #ifdef CONFIG_TOUCHSCREEN_USB_3M
520 .read_data
= mtouch_read_data
,
525 #ifdef CONFIG_TOUCHSCREEN_USB_ITM
533 .read_data
= itm_read_data
,
537 #ifdef CONFIG_TOUCHSCREEN_USB_ETURBO
544 .flags
= USBTOUCH_FLG_BUFFER
,
545 .process_pkt
= usbtouch_process_multi
,
546 .get_pkt_len
= eturbo_get_pkt_len
,
547 .read_data
= eturbo_read_data
,
551 #ifdef CONFIG_TOUCHSCREEN_USB_GUNZE
558 .read_data
= gunze_read_data
,
562 #ifdef CONFIG_TOUCHSCREEN_USB_DMC_TSC10
563 [DEVTYPE_DMC_TSC10
] = {
569 .init
= dmc_tsc10_init
,
570 .read_data
= dmc_tsc10_read_data
,
574 #ifdef CONFIG_TOUCHSCREEN_USB_IRTOUCH
575 [DEVTYPE_IRTOUCH
] = {
581 .read_data
= irtouch_read_data
,
585 #ifdef CONFIG_TOUCHSCREEN_USB_IDEALTEK
586 [DEVTYPE_IDEALTEK
] = {
592 .flags
= USBTOUCH_FLG_BUFFER
,
593 .process_pkt
= usbtouch_process_multi
,
594 .get_pkt_len
= idealtek_get_pkt_len
,
595 .read_data
= idealtek_read_data
,
601 /*****************************************************************************
604 static void usbtouch_process_pkt(struct usbtouch_usb
*usbtouch
,
605 unsigned char *pkt
, int len
)
607 struct usbtouch_device_info
*type
= usbtouch
->type
;
609 if (!type
->read_data(usbtouch
, pkt
))
612 input_report_key(usbtouch
->input
, BTN_TOUCH
, usbtouch
->touch
);
615 input_report_abs(usbtouch
->input
, ABS_X
, usbtouch
->y
);
616 input_report_abs(usbtouch
->input
, ABS_Y
, usbtouch
->x
);
618 input_report_abs(usbtouch
->input
, ABS_X
, usbtouch
->x
);
619 input_report_abs(usbtouch
->input
, ABS_Y
, usbtouch
->y
);
622 input_report_abs(usbtouch
->input
, ABS_PRESSURE
, usbtouch
->press
);
623 input_sync(usbtouch
->input
);
628 static void usbtouch_process_multi(struct usbtouch_usb
*usbtouch
,
629 unsigned char *pkt
, int len
)
631 unsigned char *buffer
;
632 int pkt_len
, pos
, buf_len
, tmp
;
635 if (unlikely(usbtouch
->buf_len
)) {
636 /* try to get size */
637 pkt_len
= usbtouch
->type
->get_pkt_len(
638 usbtouch
->buffer
, usbtouch
->buf_len
);
641 if (unlikely(!pkt_len
))
644 /* need to append -pkt_len bytes before able to get size */
645 if (unlikely(pkt_len
< 0)) {
646 int append
= -pkt_len
;
647 if (unlikely(append
> len
))
649 if (usbtouch
->buf_len
+ append
>= usbtouch
->type
->rept_size
)
651 memcpy(usbtouch
->buffer
+ usbtouch
->buf_len
, pkt
, append
);
652 usbtouch
->buf_len
+= append
;
654 pkt_len
= usbtouch
->type
->get_pkt_len(
655 usbtouch
->buffer
, usbtouch
->buf_len
);
661 tmp
= pkt_len
- usbtouch
->buf_len
;
662 if (usbtouch
->buf_len
+ tmp
>= usbtouch
->type
->rept_size
)
664 memcpy(usbtouch
->buffer
+ usbtouch
->buf_len
, pkt
, tmp
);
665 usbtouch_process_pkt(usbtouch
, usbtouch
->buffer
, pkt_len
);
674 /* loop over the received packet, process */
676 while (pos
< buf_len
) {
678 pkt_len
= usbtouch
->type
->get_pkt_len(buffer
+ pos
, len
);
680 /* unknown packet: drop everything */
681 if (unlikely(!pkt_len
))
684 /* full packet: process */
685 if (likely((pkt_len
> 0) && (pkt_len
<= buf_len
- pos
))) {
686 usbtouch_process_pkt(usbtouch
, buffer
+ pos
, pkt_len
);
688 /* incomplete packet: save in buffer */
689 memcpy(usbtouch
->buffer
, buffer
+ pos
, buf_len
- pos
);
690 usbtouch
->buf_len
= buf_len
- pos
;
697 usbtouch
->buf_len
= 0;
703 static void usbtouch_irq(struct urb
*urb
)
705 struct usbtouch_usb
*usbtouch
= urb
->context
;
708 switch (urb
->status
) {
713 /* this urb is timing out */
714 dbg("%s - urb timed out - was the device unplugged?",
720 /* this urb is terminated, clean up */
721 dbg("%s - urb shutting down with status: %d",
722 __FUNCTION__
, urb
->status
);
725 dbg("%s - nonzero urb status received: %d",
726 __FUNCTION__
, urb
->status
);
730 usbtouch
->type
->process_pkt(usbtouch
, usbtouch
->data
, urb
->actual_length
);
733 retval
= usb_submit_urb(urb
, GFP_ATOMIC
);
735 err("%s - usb_submit_urb failed with result: %d",
736 __FUNCTION__
, retval
);
739 static int usbtouch_open(struct input_dev
*input
)
741 struct usbtouch_usb
*usbtouch
= input_get_drvdata(input
);
743 usbtouch
->irq
->dev
= usbtouch
->udev
;
745 if (usb_submit_urb(usbtouch
->irq
, GFP_KERNEL
))
751 static void usbtouch_close(struct input_dev
*input
)
753 struct usbtouch_usb
*usbtouch
= input_get_drvdata(input
);
755 usb_kill_urb(usbtouch
->irq
);
759 static void usbtouch_free_buffers(struct usb_device
*udev
,
760 struct usbtouch_usb
*usbtouch
)
762 usb_buffer_free(udev
, usbtouch
->type
->rept_size
,
763 usbtouch
->data
, usbtouch
->data_dma
);
764 kfree(usbtouch
->buffer
);
768 static int usbtouch_probe(struct usb_interface
*intf
,
769 const struct usb_device_id
*id
)
771 struct usbtouch_usb
*usbtouch
;
772 struct input_dev
*input_dev
;
773 struct usb_host_interface
*interface
;
774 struct usb_endpoint_descriptor
*endpoint
;
775 struct usb_device
*udev
= interface_to_usbdev(intf
);
776 struct usbtouch_device_info
*type
;
779 interface
= intf
->cur_altsetting
;
780 endpoint
= &interface
->endpoint
[0].desc
;
782 usbtouch
= kzalloc(sizeof(struct usbtouch_usb
), GFP_KERNEL
);
783 input_dev
= input_allocate_device();
784 if (!usbtouch
|| !input_dev
)
787 type
= &usbtouch_dev_info
[id
->driver_info
];
788 usbtouch
->type
= type
;
789 if (!type
->process_pkt
)
790 type
->process_pkt
= usbtouch_process_pkt
;
792 usbtouch
->data
= usb_buffer_alloc(udev
, type
->rept_size
,
793 GFP_KERNEL
, &usbtouch
->data_dma
);
797 if (type
->flags
& USBTOUCH_FLG_BUFFER
) {
798 usbtouch
->buffer
= kmalloc(type
->rept_size
, GFP_KERNEL
);
799 if (!usbtouch
->buffer
)
800 goto out_free_buffers
;
803 usbtouch
->irq
= usb_alloc_urb(0, GFP_KERNEL
);
804 if (!usbtouch
->irq
) {
805 dbg("%s - usb_alloc_urb failed: usbtouch->irq", __FUNCTION__
);
806 goto out_free_buffers
;
809 usbtouch
->udev
= udev
;
810 usbtouch
->input
= input_dev
;
812 if (udev
->manufacturer
)
813 strlcpy(usbtouch
->name
, udev
->manufacturer
, sizeof(usbtouch
->name
));
816 if (udev
->manufacturer
)
817 strlcat(usbtouch
->name
, " ", sizeof(usbtouch
->name
));
818 strlcat(usbtouch
->name
, udev
->product
, sizeof(usbtouch
->name
));
821 if (!strlen(usbtouch
->name
))
822 snprintf(usbtouch
->name
, sizeof(usbtouch
->name
),
823 "USB Touchscreen %04x:%04x",
824 le16_to_cpu(udev
->descriptor
.idVendor
),
825 le16_to_cpu(udev
->descriptor
.idProduct
));
827 usb_make_path(udev
, usbtouch
->phys
, sizeof(usbtouch
->phys
));
828 strlcpy(usbtouch
->phys
, "/input0", sizeof(usbtouch
->phys
));
830 input_dev
->name
= usbtouch
->name
;
831 input_dev
->phys
= usbtouch
->phys
;
832 usb_to_input_id(udev
, &input_dev
->id
);
833 input_dev
->dev
.parent
= &intf
->dev
;
835 input_set_drvdata(input_dev
, usbtouch
);
837 input_dev
->open
= usbtouch_open
;
838 input_dev
->close
= usbtouch_close
;
840 input_dev
->evbit
[0] = BIT(EV_KEY
) | BIT(EV_ABS
);
841 input_dev
->keybit
[LONG(BTN_TOUCH
)] = BIT(BTN_TOUCH
);
842 input_set_abs_params(input_dev
, ABS_X
, type
->min_xc
, type
->max_xc
, 0, 0);
843 input_set_abs_params(input_dev
, ABS_Y
, type
->min_yc
, type
->max_yc
, 0, 0);
845 input_set_abs_params(input_dev
, ABS_PRESSURE
, type
->min_press
,
846 type
->max_press
, 0, 0);
848 usb_fill_int_urb(usbtouch
->irq
, usbtouch
->udev
,
849 usb_rcvintpipe(usbtouch
->udev
, endpoint
->bEndpointAddress
),
850 usbtouch
->data
, type
->rept_size
,
851 usbtouch_irq
, usbtouch
, endpoint
->bInterval
);
853 usbtouch
->irq
->dev
= usbtouch
->udev
;
854 usbtouch
->irq
->transfer_dma
= usbtouch
->data_dma
;
855 usbtouch
->irq
->transfer_flags
|= URB_NO_TRANSFER_DMA_MAP
;
857 /* device specific init */
859 err
= type
->init(usbtouch
);
861 dbg("%s - type->init() failed, err: %d", __FUNCTION__
, err
);
862 goto out_free_buffers
;
866 err
= input_register_device(usbtouch
->input
);
868 dbg("%s - input_register_device failed, err: %d", __FUNCTION__
, err
);
869 goto out_free_buffers
;
872 usb_set_intfdata(intf
, usbtouch
);
877 usbtouch_free_buffers(udev
, usbtouch
);
879 input_free_device(input_dev
);
884 static void usbtouch_disconnect(struct usb_interface
*intf
)
886 struct usbtouch_usb
*usbtouch
= usb_get_intfdata(intf
);
888 dbg("%s - called", __FUNCTION__
);
893 dbg("%s - usbtouch is initialized, cleaning up", __FUNCTION__
);
894 usb_set_intfdata(intf
, NULL
);
895 usb_kill_urb(usbtouch
->irq
);
896 input_unregister_device(usbtouch
->input
);
897 usb_free_urb(usbtouch
->irq
);
898 usbtouch_free_buffers(interface_to_usbdev(intf
), usbtouch
);
902 MODULE_DEVICE_TABLE(usb
, usbtouch_devices
);
904 static struct usb_driver usbtouch_driver
= {
905 .name
= "usbtouchscreen",
906 .probe
= usbtouch_probe
,
907 .disconnect
= usbtouch_disconnect
,
908 .id_table
= usbtouch_devices
,
911 static int __init
usbtouch_init(void)
913 return usb_register(&usbtouch_driver
);
916 static void __exit
usbtouch_cleanup(void)
918 usb_deregister(&usbtouch_driver
);
921 module_init(usbtouch_init
);
922 module_exit(usbtouch_cleanup
);
924 MODULE_AUTHOR(DRIVER_AUTHOR
);
925 MODULE_DESCRIPTION(DRIVER_DESC
);
926 MODULE_LICENSE("GPL");
928 MODULE_ALIAS("touchkitusb");
929 MODULE_ALIAS("itmtouch");
930 MODULE_ALIAS("mtouchusb");