Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * usbtouchscreen.c |
| 3 | * Driver for USB Touchscreens, supporting those devices: |
| 4 | * - eGalax Touchkit |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 5 | * includes eTurboTouch CT-410/510/700 |
| 6 | * - 3M/Microtouch EX II series |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 7 | * - ITM |
| 8 | * - PanJit TouchSet |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 9 | * - eTurboTouch |
| 10 | * - Gunze AHL61 |
Holger Schurig | 24ced06 | 2006-11-17 22:50:15 +0100 | [diff] [blame] | 11 | * - DMC TSC-10/25 |
Ondrej Zary | df561fc | 2007-07-03 01:55:03 -0400 | [diff] [blame] | 12 | * - IRTOUCHSYSTEMS/UNITOP |
Ondrej Zary | a14a840 | 2007-09-04 23:45:01 -0400 | [diff] [blame] | 13 | * - IdealTEK URTC1000 |
Daniel Ritz | 62aa366 | 2008-01-17 12:01:18 -0500 | [diff] [blame] | 14 | * - General Touch |
Jerrold Jones | 14e4020 | 2007-10-22 00:59:47 -0400 | [diff] [blame] | 15 | * - GoTop Super_Q2/GogoPen/PenPower tablets |
Jim Persson | f737069 | 2009-07-07 22:07:59 -0700 | [diff] [blame^] | 16 | * - JASTEC USB touch controller/DigiTech DTR-02U |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 17 | * |
Jerrold Jones | 14e4020 | 2007-10-22 00:59:47 -0400 | [diff] [blame] | 18 | * Copyright (C) 2004-2007 by Daniel Ritz <daniel.ritz@gmx.ch> |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 19 | * Copyright (C) by Todd E. Johnson (mtouchusb.c) |
| 20 | * |
| 21 | * This program is free software; you can redistribute it and/or |
| 22 | * modify it under the terms of the GNU General Public License as |
| 23 | * published by the Free Software Foundation; either version 2 of the |
| 24 | * License, or (at your option) any later version. |
| 25 | * |
| 26 | * This program is distributed in the hope that it will be useful, but |
| 27 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 29 | * General Public License for more details. |
| 30 | * |
| 31 | * You should have received a copy of the GNU General Public License |
| 32 | * along with this program; if not, write to the Free Software |
| 33 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 34 | * |
| 35 | * Driver is based on touchkitusb.c |
| 36 | * - ITM parts are from itmtouch.c |
| 37 | * - 3M parts are from mtouchusb.c |
| 38 | * - PanJit parts are from an unmerged driver by Lanslott Gish |
Holger Schurig | 24ced06 | 2006-11-17 22:50:15 +0100 | [diff] [blame] | 39 | * - DMC TSC 10/25 are from Holger Schurig, with ideas from an unmerged |
| 40 | * driver from Marius Vollmer |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 41 | * |
| 42 | *****************************************************************************/ |
| 43 | |
| 44 | //#define DEBUG |
| 45 | |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 46 | #include <linux/kernel.h> |
| 47 | #include <linux/slab.h> |
| 48 | #include <linux/input.h> |
| 49 | #include <linux/module.h> |
| 50 | #include <linux/init.h> |
| 51 | #include <linux/usb.h> |
David Brownell | ae0dadc | 2006-06-13 10:04:34 -0700 | [diff] [blame] | 52 | #include <linux/usb/input.h> |
Daniel Ritz | ec42d44 | 2008-07-03 10:45:37 -0400 | [diff] [blame] | 53 | #include <linux/hid.h> |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 54 | |
| 55 | |
Daniel Ritz | 62aa366 | 2008-01-17 12:01:18 -0500 | [diff] [blame] | 56 | #define DRIVER_VERSION "v0.6" |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 57 | #define DRIVER_AUTHOR "Daniel Ritz <daniel.ritz@gmx.ch>" |
| 58 | #define DRIVER_DESC "USB Touchscreen Driver" |
| 59 | |
| 60 | static int swap_xy; |
| 61 | module_param(swap_xy, bool, 0644); |
| 62 | MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped."); |
| 63 | |
Dan Streetman | c9cbf3d | 2009-01-10 23:44:22 -0800 | [diff] [blame] | 64 | static int hwcalib_xy; |
| 65 | module_param(hwcalib_xy, bool, 0644); |
| 66 | MODULE_PARM_DESC(hwcalib_xy, "If set hw-calibrated X/Y are used if available"); |
| 67 | |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 68 | /* device specifc data/functions */ |
| 69 | struct usbtouch_usb; |
| 70 | struct usbtouch_device_info { |
| 71 | int min_xc, max_xc; |
| 72 | int min_yc, max_yc; |
| 73 | int min_press, max_press; |
| 74 | int rept_size; |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 75 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 76 | void (*process_pkt) (struct usbtouch_usb *usbtouch, unsigned char *pkt, int len); |
Daniel Ritz | 62aa366 | 2008-01-17 12:01:18 -0500 | [diff] [blame] | 77 | |
| 78 | /* |
| 79 | * used to get the packet len. possible return values: |
| 80 | * > 0: packet len |
| 81 | * = 0: skip one byte |
| 82 | * < 0: -return value more bytes needed |
| 83 | */ |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 84 | int (*get_pkt_len) (unsigned char *pkt, int len); |
Daniel Ritz | 62aa366 | 2008-01-17 12:01:18 -0500 | [diff] [blame] | 85 | |
Daniel Ritz | c9d8c2b | 2006-12-11 18:17:45 +0100 | [diff] [blame] | 86 | int (*read_data) (struct usbtouch_usb *usbtouch, unsigned char *pkt); |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 87 | int (*init) (struct usbtouch_usb *usbtouch); |
| 88 | }; |
| 89 | |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 90 | /* a usbtouch device */ |
| 91 | struct usbtouch_usb { |
| 92 | unsigned char *data; |
| 93 | dma_addr_t data_dma; |
| 94 | unsigned char *buffer; |
| 95 | int buf_len; |
| 96 | struct urb *irq; |
| 97 | struct usb_device *udev; |
| 98 | struct input_dev *input; |
| 99 | struct usbtouch_device_info *type; |
| 100 | char name[128]; |
| 101 | char phys[64]; |
Daniel Ritz | c9d8c2b | 2006-12-11 18:17:45 +0100 | [diff] [blame] | 102 | |
| 103 | int x, y; |
| 104 | int touch, press; |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 105 | }; |
| 106 | |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 107 | |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 108 | /* device types */ |
| 109 | enum { |
Daniel Ritz | ec42d44 | 2008-07-03 10:45:37 -0400 | [diff] [blame] | 110 | DEVTYPE_IGNORE = -1, |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 111 | DEVTYPE_EGALAX, |
| 112 | DEVTYPE_PANJIT, |
| 113 | DEVTYPE_3M, |
| 114 | DEVTYPE_ITM, |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 115 | DEVTYPE_ETURBO, |
| 116 | DEVTYPE_GUNZE, |
Holger Schurig | 24ced06 | 2006-11-17 22:50:15 +0100 | [diff] [blame] | 117 | DEVTYPE_DMC_TSC10, |
Ondrej Zary | df561fc | 2007-07-03 01:55:03 -0400 | [diff] [blame] | 118 | DEVTYPE_IRTOUCH, |
Ondrej Zary | a14a840 | 2007-09-04 23:45:01 -0400 | [diff] [blame] | 119 | DEVTYPE_IDEALTEK, |
Ilya Frolov | 9d5657d | 2007-10-12 14:19:40 -0400 | [diff] [blame] | 120 | DEVTYPE_GENERAL_TOUCH, |
Jerrold Jones | 14e4020 | 2007-10-22 00:59:47 -0400 | [diff] [blame] | 121 | DEVTYPE_GOTOP, |
Jim Persson | f737069 | 2009-07-07 22:07:59 -0700 | [diff] [blame^] | 122 | DEVTYPE_JASTEC, |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 123 | }; |
| 124 | |
Daniel Ritz | ec42d44 | 2008-07-03 10:45:37 -0400 | [diff] [blame] | 125 | #define USB_DEVICE_HID_CLASS(vend, prod) \ |
| 126 | .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS \ |
Daniel Ritz | 139ebe8 | 2009-02-28 12:50:54 -0800 | [diff] [blame] | 127 | | USB_DEVICE_ID_MATCH_INT_PROTOCOL \ |
Daniel Ritz | ec42d44 | 2008-07-03 10:45:37 -0400 | [diff] [blame] | 128 | | USB_DEVICE_ID_MATCH_DEVICE, \ |
| 129 | .idVendor = (vend), \ |
| 130 | .idProduct = (prod), \ |
| 131 | .bInterfaceClass = USB_INTERFACE_CLASS_HID, \ |
| 132 | .bInterfaceProtocol = USB_INTERFACE_PROTOCOL_MOUSE |
| 133 | |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 134 | static struct usb_device_id usbtouch_devices[] = { |
Ondrej Zary | c6f8d70 | 2007-06-12 00:33:13 -0400 | [diff] [blame] | 135 | #ifdef CONFIG_TOUCHSCREEN_USB_EGALAX |
Daniel Ritz | ec42d44 | 2008-07-03 10:45:37 -0400 | [diff] [blame] | 136 | /* ignore the HID capable devices, handled by usbhid */ |
| 137 | {USB_DEVICE_HID_CLASS(0x0eef, 0x0001), .driver_info = DEVTYPE_IGNORE}, |
| 138 | {USB_DEVICE_HID_CLASS(0x0eef, 0x0002), .driver_info = DEVTYPE_IGNORE}, |
| 139 | |
| 140 | /* normal device IDs */ |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 141 | {USB_DEVICE(0x3823, 0x0001), .driver_info = DEVTYPE_EGALAX}, |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 142 | {USB_DEVICE(0x3823, 0x0002), .driver_info = DEVTYPE_EGALAX}, |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 143 | {USB_DEVICE(0x0123, 0x0001), .driver_info = DEVTYPE_EGALAX}, |
| 144 | {USB_DEVICE(0x0eef, 0x0001), .driver_info = DEVTYPE_EGALAX}, |
| 145 | {USB_DEVICE(0x0eef, 0x0002), .driver_info = DEVTYPE_EGALAX}, |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 146 | {USB_DEVICE(0x1234, 0x0001), .driver_info = DEVTYPE_EGALAX}, |
| 147 | {USB_DEVICE(0x1234, 0x0002), .driver_info = DEVTYPE_EGALAX}, |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 148 | #endif |
| 149 | |
Ondrej Zary | c6f8d70 | 2007-06-12 00:33:13 -0400 | [diff] [blame] | 150 | #ifdef CONFIG_TOUCHSCREEN_USB_PANJIT |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 151 | {USB_DEVICE(0x134c, 0x0001), .driver_info = DEVTYPE_PANJIT}, |
| 152 | {USB_DEVICE(0x134c, 0x0002), .driver_info = DEVTYPE_PANJIT}, |
| 153 | {USB_DEVICE(0x134c, 0x0003), .driver_info = DEVTYPE_PANJIT}, |
| 154 | {USB_DEVICE(0x134c, 0x0004), .driver_info = DEVTYPE_PANJIT}, |
| 155 | #endif |
| 156 | |
Ondrej Zary | c6f8d70 | 2007-06-12 00:33:13 -0400 | [diff] [blame] | 157 | #ifdef CONFIG_TOUCHSCREEN_USB_3M |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 158 | {USB_DEVICE(0x0596, 0x0001), .driver_info = DEVTYPE_3M}, |
| 159 | #endif |
| 160 | |
Ondrej Zary | c6f8d70 | 2007-06-12 00:33:13 -0400 | [diff] [blame] | 161 | #ifdef CONFIG_TOUCHSCREEN_USB_ITM |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 162 | {USB_DEVICE(0x0403, 0xf9e9), .driver_info = DEVTYPE_ITM}, |
| 163 | #endif |
| 164 | |
Ondrej Zary | c6f8d70 | 2007-06-12 00:33:13 -0400 | [diff] [blame] | 165 | #ifdef CONFIG_TOUCHSCREEN_USB_ETURBO |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 166 | {USB_DEVICE(0x1234, 0x5678), .driver_info = DEVTYPE_ETURBO}, |
| 167 | #endif |
| 168 | |
Ondrej Zary | c6f8d70 | 2007-06-12 00:33:13 -0400 | [diff] [blame] | 169 | #ifdef CONFIG_TOUCHSCREEN_USB_GUNZE |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 170 | {USB_DEVICE(0x0637, 0x0001), .driver_info = DEVTYPE_GUNZE}, |
| 171 | #endif |
| 172 | |
Ondrej Zary | c6f8d70 | 2007-06-12 00:33:13 -0400 | [diff] [blame] | 173 | #ifdef CONFIG_TOUCHSCREEN_USB_DMC_TSC10 |
Holger Schurig | 24ced06 | 2006-11-17 22:50:15 +0100 | [diff] [blame] | 174 | {USB_DEVICE(0x0afa, 0x03e8), .driver_info = DEVTYPE_DMC_TSC10}, |
| 175 | #endif |
| 176 | |
Ondrej Zary | df561fc | 2007-07-03 01:55:03 -0400 | [diff] [blame] | 177 | #ifdef CONFIG_TOUCHSCREEN_USB_IRTOUCH |
| 178 | {USB_DEVICE(0x595a, 0x0001), .driver_info = DEVTYPE_IRTOUCH}, |
| 179 | {USB_DEVICE(0x6615, 0x0001), .driver_info = DEVTYPE_IRTOUCH}, |
| 180 | #endif |
| 181 | |
Ondrej Zary | a14a840 | 2007-09-04 23:45:01 -0400 | [diff] [blame] | 182 | #ifdef CONFIG_TOUCHSCREEN_USB_IDEALTEK |
| 183 | {USB_DEVICE(0x1391, 0x1000), .driver_info = DEVTYPE_IDEALTEK}, |
| 184 | #endif |
| 185 | |
Ilya Frolov | 9d5657d | 2007-10-12 14:19:40 -0400 | [diff] [blame] | 186 | #ifdef CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH |
| 187 | {USB_DEVICE(0x0dfc, 0x0001), .driver_info = DEVTYPE_GENERAL_TOUCH}, |
| 188 | #endif |
| 189 | |
Jerrold Jones | 14e4020 | 2007-10-22 00:59:47 -0400 | [diff] [blame] | 190 | #ifdef CONFIG_TOUCHSCREEN_USB_GOTOP |
| 191 | {USB_DEVICE(0x08f2, 0x007f), .driver_info = DEVTYPE_GOTOP}, |
| 192 | {USB_DEVICE(0x08f2, 0x00ce), .driver_info = DEVTYPE_GOTOP}, |
| 193 | {USB_DEVICE(0x08f2, 0x00f4), .driver_info = DEVTYPE_GOTOP}, |
| 194 | #endif |
| 195 | |
Jim Persson | f737069 | 2009-07-07 22:07:59 -0700 | [diff] [blame^] | 196 | #ifdef CONFIG_TOUCHSCREEN_USB_JASTEC |
| 197 | {USB_DEVICE(0x0f92, 0x0001), .driver_info = DEVTYPE_JASTEC}, |
| 198 | #endif |
| 199 | |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 200 | {} |
| 201 | }; |
| 202 | |
| 203 | |
| 204 | /***************************************************************************** |
| 205 | * eGalax part |
| 206 | */ |
| 207 | |
Ondrej Zary | c6f8d70 | 2007-06-12 00:33:13 -0400 | [diff] [blame] | 208 | #ifdef CONFIG_TOUCHSCREEN_USB_EGALAX |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 209 | |
Daniel Ritz | 62aa366 | 2008-01-17 12:01:18 -0500 | [diff] [blame] | 210 | #ifndef MULTI_PACKET |
| 211 | #define MULTI_PACKET |
| 212 | #endif |
| 213 | |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 214 | #define EGALAX_PKT_TYPE_MASK 0xFE |
| 215 | #define EGALAX_PKT_TYPE_REPT 0x80 |
| 216 | #define EGALAX_PKT_TYPE_DIAG 0x0A |
| 217 | |
Daniel Ritz | c9d8c2b | 2006-12-11 18:17:45 +0100 | [diff] [blame] | 218 | static int egalax_read_data(struct usbtouch_usb *dev, unsigned char *pkt) |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 219 | { |
| 220 | if ((pkt[0] & EGALAX_PKT_TYPE_MASK) != EGALAX_PKT_TYPE_REPT) |
| 221 | return 0; |
| 222 | |
Daniel Ritz | c9d8c2b | 2006-12-11 18:17:45 +0100 | [diff] [blame] | 223 | dev->x = ((pkt[3] & 0x0F) << 7) | (pkt[4] & 0x7F); |
| 224 | dev->y = ((pkt[1] & 0x0F) << 7) | (pkt[2] & 0x7F); |
| 225 | dev->touch = pkt[0] & 0x01; |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 226 | |
| 227 | return 1; |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 228 | } |
| 229 | |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 230 | static int egalax_get_pkt_len(unsigned char *buf, int len) |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 231 | { |
| 232 | switch (buf[0] & EGALAX_PKT_TYPE_MASK) { |
| 233 | case EGALAX_PKT_TYPE_REPT: |
| 234 | return 5; |
| 235 | |
| 236 | case EGALAX_PKT_TYPE_DIAG: |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 237 | if (len < 2) |
| 238 | return -1; |
| 239 | |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 240 | return buf[1] + 2; |
| 241 | } |
| 242 | |
| 243 | return 0; |
| 244 | } |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 245 | #endif |
| 246 | |
| 247 | |
| 248 | /***************************************************************************** |
| 249 | * PanJit Part |
| 250 | */ |
Ondrej Zary | c6f8d70 | 2007-06-12 00:33:13 -0400 | [diff] [blame] | 251 | #ifdef CONFIG_TOUCHSCREEN_USB_PANJIT |
Daniel Ritz | c9d8c2b | 2006-12-11 18:17:45 +0100 | [diff] [blame] | 252 | static int panjit_read_data(struct usbtouch_usb *dev, unsigned char *pkt) |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 253 | { |
Daniel Ritz | c9d8c2b | 2006-12-11 18:17:45 +0100 | [diff] [blame] | 254 | dev->x = ((pkt[2] & 0x0F) << 8) | pkt[1]; |
| 255 | dev->y = ((pkt[4] & 0x0F) << 8) | pkt[3]; |
| 256 | dev->touch = pkt[0] & 0x01; |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 257 | |
| 258 | return 1; |
| 259 | } |
| 260 | #endif |
| 261 | |
| 262 | |
| 263 | /***************************************************************************** |
| 264 | * 3M/Microtouch Part |
| 265 | */ |
Ondrej Zary | c6f8d70 | 2007-06-12 00:33:13 -0400 | [diff] [blame] | 266 | #ifdef CONFIG_TOUCHSCREEN_USB_3M |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 267 | |
| 268 | #define MTOUCHUSB_ASYNC_REPORT 1 |
| 269 | #define MTOUCHUSB_RESET 7 |
| 270 | #define MTOUCHUSB_REQ_CTRLLR_ID 10 |
| 271 | |
Daniel Ritz | c9d8c2b | 2006-12-11 18:17:45 +0100 | [diff] [blame] | 272 | static int mtouch_read_data(struct usbtouch_usb *dev, unsigned char *pkt) |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 273 | { |
Dan Streetman | c9cbf3d | 2009-01-10 23:44:22 -0800 | [diff] [blame] | 274 | if (hwcalib_xy) { |
| 275 | dev->x = (pkt[4] << 8) | pkt[3]; |
| 276 | dev->y = 0xffff - ((pkt[6] << 8) | pkt[5]); |
| 277 | } else { |
| 278 | dev->x = (pkt[8] << 8) | pkt[7]; |
| 279 | dev->y = (pkt[10] << 8) | pkt[9]; |
| 280 | } |
Daniel Ritz | c9d8c2b | 2006-12-11 18:17:45 +0100 | [diff] [blame] | 281 | dev->touch = (pkt[2] & 0x40) ? 1 : 0; |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 282 | |
| 283 | return 1; |
| 284 | } |
| 285 | |
| 286 | static int mtouch_init(struct usbtouch_usb *usbtouch) |
| 287 | { |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 288 | int ret, i; |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 289 | |
| 290 | ret = usb_control_msg(usbtouch->udev, usb_rcvctrlpipe(usbtouch->udev, 0), |
| 291 | MTOUCHUSB_RESET, |
| 292 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
| 293 | 1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); |
| 294 | dbg("%s - usb_control_msg - MTOUCHUSB_RESET - bytes|err: %d", |
Harvey Harrison | ea3e6c5 | 2008-05-05 11:36:18 -0400 | [diff] [blame] | 295 | __func__, ret); |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 296 | if (ret < 0) |
| 297 | return ret; |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 298 | msleep(150); |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 299 | |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 300 | for (i = 0; i < 3; i++) { |
| 301 | ret = usb_control_msg(usbtouch->udev, usb_rcvctrlpipe(usbtouch->udev, 0), |
| 302 | MTOUCHUSB_ASYNC_REPORT, |
| 303 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
| 304 | 1, 1, NULL, 0, USB_CTRL_SET_TIMEOUT); |
| 305 | dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d", |
Harvey Harrison | ea3e6c5 | 2008-05-05 11:36:18 -0400 | [diff] [blame] | 306 | __func__, ret); |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 307 | if (ret >= 0) |
| 308 | break; |
| 309 | if (ret != -EPIPE) |
| 310 | return ret; |
| 311 | } |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 312 | |
Dan Streetman | c9cbf3d | 2009-01-10 23:44:22 -0800 | [diff] [blame] | 313 | /* Default min/max xy are the raw values, override if using hw-calib */ |
| 314 | if (hwcalib_xy) { |
| 315 | input_set_abs_params(usbtouch->input, ABS_X, 0, 0xffff, 0, 0); |
| 316 | input_set_abs_params(usbtouch->input, ABS_Y, 0, 0xffff, 0, 0); |
| 317 | } |
| 318 | |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 319 | return 0; |
| 320 | } |
| 321 | #endif |
| 322 | |
| 323 | |
| 324 | /***************************************************************************** |
| 325 | * ITM Part |
| 326 | */ |
Ondrej Zary | c6f8d70 | 2007-06-12 00:33:13 -0400 | [diff] [blame] | 327 | #ifdef CONFIG_TOUCHSCREEN_USB_ITM |
Daniel Ritz | c9d8c2b | 2006-12-11 18:17:45 +0100 | [diff] [blame] | 328 | static int itm_read_data(struct usbtouch_usb *dev, unsigned char *pkt) |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 329 | { |
Daniel Ritz | c9d8c2b | 2006-12-11 18:17:45 +0100 | [diff] [blame] | 330 | int touch; |
| 331 | /* |
| 332 | * ITM devices report invalid x/y data if not touched. |
| 333 | * if the screen was touched before but is not touched any more |
| 334 | * report touch as 0 with the last valid x/y data once. then stop |
| 335 | * reporting data until touched again. |
| 336 | */ |
| 337 | dev->press = ((pkt[2] & 0x01) << 7) | (pkt[5] & 0x7F); |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 338 | |
Daniel Ritz | c9d8c2b | 2006-12-11 18:17:45 +0100 | [diff] [blame] | 339 | touch = ~pkt[7] & 0x20; |
| 340 | if (!touch) { |
| 341 | if (dev->touch) { |
| 342 | dev->touch = 0; |
| 343 | return 1; |
| 344 | } |
| 345 | |
| 346 | return 0; |
| 347 | } |
| 348 | |
| 349 | dev->x = ((pkt[0] & 0x1F) << 7) | (pkt[3] & 0x7F); |
| 350 | dev->y = ((pkt[1] & 0x1F) << 7) | (pkt[4] & 0x7F); |
| 351 | dev->touch = touch; |
| 352 | |
| 353 | return 1; |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 354 | } |
| 355 | #endif |
| 356 | |
| 357 | |
| 358 | /***************************************************************************** |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 359 | * eTurboTouch part |
| 360 | */ |
Ondrej Zary | c6f8d70 | 2007-06-12 00:33:13 -0400 | [diff] [blame] | 361 | #ifdef CONFIG_TOUCHSCREEN_USB_ETURBO |
Daniel Ritz | 62aa366 | 2008-01-17 12:01:18 -0500 | [diff] [blame] | 362 | #ifndef MULTI_PACKET |
| 363 | #define MULTI_PACKET |
| 364 | #endif |
Daniel Ritz | c9d8c2b | 2006-12-11 18:17:45 +0100 | [diff] [blame] | 365 | static int eturbo_read_data(struct usbtouch_usb *dev, unsigned char *pkt) |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 366 | { |
| 367 | unsigned int shift; |
| 368 | |
| 369 | /* packets should start with sync */ |
| 370 | if (!(pkt[0] & 0x80)) |
| 371 | return 0; |
| 372 | |
| 373 | shift = (6 - (pkt[0] & 0x03)); |
Daniel Ritz | c9d8c2b | 2006-12-11 18:17:45 +0100 | [diff] [blame] | 374 | dev->x = ((pkt[3] << 7) | pkt[4]) >> shift; |
| 375 | dev->y = ((pkt[1] << 7) | pkt[2]) >> shift; |
| 376 | dev->touch = (pkt[0] & 0x10) ? 1 : 0; |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 377 | |
| 378 | return 1; |
| 379 | } |
| 380 | |
| 381 | static int eturbo_get_pkt_len(unsigned char *buf, int len) |
| 382 | { |
| 383 | if (buf[0] & 0x80) |
| 384 | return 5; |
| 385 | if (buf[0] == 0x01) |
| 386 | return 3; |
| 387 | return 0; |
| 388 | } |
| 389 | #endif |
| 390 | |
| 391 | |
| 392 | /***************************************************************************** |
| 393 | * Gunze part |
| 394 | */ |
Ondrej Zary | c6f8d70 | 2007-06-12 00:33:13 -0400 | [diff] [blame] | 395 | #ifdef CONFIG_TOUCHSCREEN_USB_GUNZE |
Daniel Ritz | c9d8c2b | 2006-12-11 18:17:45 +0100 | [diff] [blame] | 396 | static int gunze_read_data(struct usbtouch_usb *dev, unsigned char *pkt) |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 397 | { |
| 398 | if (!(pkt[0] & 0x80) || ((pkt[1] | pkt[2] | pkt[3]) & 0x80)) |
| 399 | return 0; |
| 400 | |
Daniel Ritz | c9d8c2b | 2006-12-11 18:17:45 +0100 | [diff] [blame] | 401 | dev->x = ((pkt[0] & 0x1F) << 7) | (pkt[2] & 0x7F); |
| 402 | dev->y = ((pkt[1] & 0x1F) << 7) | (pkt[3] & 0x7F); |
| 403 | dev->touch = pkt[0] & 0x20; |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 404 | |
| 405 | return 1; |
| 406 | } |
| 407 | #endif |
| 408 | |
| 409 | /***************************************************************************** |
Holger Schurig | 24ced06 | 2006-11-17 22:50:15 +0100 | [diff] [blame] | 410 | * DMC TSC-10/25 Part |
| 411 | * |
| 412 | * Documentation about the controller and it's protocol can be found at |
| 413 | * http://www.dmccoltd.com/files/controler/tsc10usb_pi_e.pdf |
| 414 | * http://www.dmccoltd.com/files/controler/tsc25_usb_e.pdf |
| 415 | */ |
Ondrej Zary | c6f8d70 | 2007-06-12 00:33:13 -0400 | [diff] [blame] | 416 | #ifdef CONFIG_TOUCHSCREEN_USB_DMC_TSC10 |
Holger Schurig | 24ced06 | 2006-11-17 22:50:15 +0100 | [diff] [blame] | 417 | |
| 418 | /* supported data rates. currently using 130 */ |
| 419 | #define TSC10_RATE_POINT 0x50 |
| 420 | #define TSC10_RATE_30 0x40 |
| 421 | #define TSC10_RATE_50 0x41 |
| 422 | #define TSC10_RATE_80 0x42 |
| 423 | #define TSC10_RATE_100 0x43 |
| 424 | #define TSC10_RATE_130 0x44 |
| 425 | #define TSC10_RATE_150 0x45 |
| 426 | |
| 427 | /* commands */ |
| 428 | #define TSC10_CMD_RESET 0x55 |
| 429 | #define TSC10_CMD_RATE 0x05 |
| 430 | #define TSC10_CMD_DATA1 0x01 |
| 431 | |
| 432 | static int dmc_tsc10_init(struct usbtouch_usb *usbtouch) |
| 433 | { |
| 434 | struct usb_device *dev = usbtouch->udev; |
Oliver Neukum | 76d057c | 2008-04-04 15:31:47 -0400 | [diff] [blame] | 435 | int ret = -ENOMEM; |
| 436 | unsigned char *buf; |
Holger Schurig | 24ced06 | 2006-11-17 22:50:15 +0100 | [diff] [blame] | 437 | |
Oliver Neukum | 76d057c | 2008-04-04 15:31:47 -0400 | [diff] [blame] | 438 | buf = kmalloc(2, GFP_KERNEL); |
| 439 | if (!buf) |
| 440 | goto err_nobuf; |
Holger Schurig | 24ced06 | 2006-11-17 22:50:15 +0100 | [diff] [blame] | 441 | /* reset */ |
| 442 | buf[0] = buf[1] = 0xFF; |
| 443 | ret = usb_control_msg(dev, usb_rcvctrlpipe (dev, 0), |
| 444 | TSC10_CMD_RESET, |
| 445 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
| 446 | 0, 0, buf, 2, USB_CTRL_SET_TIMEOUT); |
| 447 | if (ret < 0) |
Oliver Neukum | 76d057c | 2008-04-04 15:31:47 -0400 | [diff] [blame] | 448 | goto err_out; |
Nuno Lucas | 2ec6f24 | 2008-11-11 16:48:04 -0500 | [diff] [blame] | 449 | if (buf[0] != 0x06) { |
Oliver Neukum | 76d057c | 2008-04-04 15:31:47 -0400 | [diff] [blame] | 450 | ret = -ENODEV; |
| 451 | goto err_out; |
| 452 | } |
Holger Schurig | 24ced06 | 2006-11-17 22:50:15 +0100 | [diff] [blame] | 453 | |
| 454 | /* set coordinate output rate */ |
| 455 | buf[0] = buf[1] = 0xFF; |
| 456 | ret = usb_control_msg(dev, usb_rcvctrlpipe (dev, 0), |
| 457 | TSC10_CMD_RATE, |
| 458 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
| 459 | TSC10_RATE_150, 0, buf, 2, USB_CTRL_SET_TIMEOUT); |
| 460 | if (ret < 0) |
Oliver Neukum | 76d057c | 2008-04-04 15:31:47 -0400 | [diff] [blame] | 461 | goto err_out; |
Nuno Lucas | 2ec6f24 | 2008-11-11 16:48:04 -0500 | [diff] [blame] | 462 | if ((buf[0] != 0x06) && (buf[0] != 0x15 || buf[1] != 0x01)) { |
Oliver Neukum | 76d057c | 2008-04-04 15:31:47 -0400 | [diff] [blame] | 463 | ret = -ENODEV; |
| 464 | goto err_out; |
| 465 | } |
Holger Schurig | 24ced06 | 2006-11-17 22:50:15 +0100 | [diff] [blame] | 466 | |
| 467 | /* start sending data */ |
| 468 | ret = usb_control_msg(dev, usb_rcvctrlpipe (dev, 0), |
| 469 | TSC10_CMD_DATA1, |
| 470 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
| 471 | 0, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); |
Oliver Neukum | 76d057c | 2008-04-04 15:31:47 -0400 | [diff] [blame] | 472 | err_out: |
| 473 | kfree(buf); |
| 474 | err_nobuf: |
| 475 | return ret; |
Holger Schurig | 24ced06 | 2006-11-17 22:50:15 +0100 | [diff] [blame] | 476 | } |
| 477 | |
| 478 | |
Daniel Ritz | c9d8c2b | 2006-12-11 18:17:45 +0100 | [diff] [blame] | 479 | static int dmc_tsc10_read_data(struct usbtouch_usb *dev, unsigned char *pkt) |
Holger Schurig | 24ced06 | 2006-11-17 22:50:15 +0100 | [diff] [blame] | 480 | { |
Daniel Ritz | c9d8c2b | 2006-12-11 18:17:45 +0100 | [diff] [blame] | 481 | dev->x = ((pkt[2] & 0x03) << 8) | pkt[1]; |
| 482 | dev->y = ((pkt[4] & 0x03) << 8) | pkt[3]; |
| 483 | dev->touch = pkt[0] & 0x01; |
Holger Schurig | 24ced06 | 2006-11-17 22:50:15 +0100 | [diff] [blame] | 484 | |
| 485 | return 1; |
| 486 | } |
| 487 | #endif |
| 488 | |
| 489 | |
| 490 | /***************************************************************************** |
Ondrej Zary | df561fc | 2007-07-03 01:55:03 -0400 | [diff] [blame] | 491 | * IRTOUCH Part |
| 492 | */ |
| 493 | #ifdef CONFIG_TOUCHSCREEN_USB_IRTOUCH |
| 494 | static int irtouch_read_data(struct usbtouch_usb *dev, unsigned char *pkt) |
| 495 | { |
| 496 | dev->x = (pkt[3] << 8) | pkt[2]; |
| 497 | dev->y = (pkt[5] << 8) | pkt[4]; |
| 498 | dev->touch = (pkt[1] & 0x03) ? 1 : 0; |
| 499 | |
| 500 | return 1; |
| 501 | } |
| 502 | #endif |
| 503 | |
| 504 | |
| 505 | /***************************************************************************** |
Ondrej Zary | a14a840 | 2007-09-04 23:45:01 -0400 | [diff] [blame] | 506 | * IdealTEK URTC1000 Part |
| 507 | */ |
| 508 | #ifdef CONFIG_TOUCHSCREEN_USB_IDEALTEK |
Daniel Ritz | 62aa366 | 2008-01-17 12:01:18 -0500 | [diff] [blame] | 509 | #ifndef MULTI_PACKET |
| 510 | #define MULTI_PACKET |
| 511 | #endif |
Ondrej Zary | a14a840 | 2007-09-04 23:45:01 -0400 | [diff] [blame] | 512 | static int idealtek_get_pkt_len(unsigned char *buf, int len) |
| 513 | { |
| 514 | if (buf[0] & 0x80) |
| 515 | return 5; |
| 516 | if (buf[0] == 0x01) |
| 517 | return len; |
| 518 | return 0; |
| 519 | } |
| 520 | |
| 521 | static int idealtek_read_data(struct usbtouch_usb *dev, unsigned char *pkt) |
| 522 | { |
| 523 | switch (pkt[0] & 0x98) { |
| 524 | case 0x88: |
| 525 | /* touch data in IdealTEK mode */ |
| 526 | dev->x = (pkt[1] << 5) | (pkt[2] >> 2); |
| 527 | dev->y = (pkt[3] << 5) | (pkt[4] >> 2); |
| 528 | dev->touch = (pkt[0] & 0x40) ? 1 : 0; |
| 529 | return 1; |
| 530 | |
| 531 | case 0x98: |
| 532 | /* touch data in MT emulation mode */ |
| 533 | dev->x = (pkt[2] << 5) | (pkt[1] >> 2); |
| 534 | dev->y = (pkt[4] << 5) | (pkt[3] >> 2); |
| 535 | dev->touch = (pkt[0] & 0x40) ? 1 : 0; |
| 536 | return 1; |
| 537 | |
| 538 | default: |
| 539 | return 0; |
| 540 | } |
| 541 | } |
| 542 | #endif |
| 543 | |
Ilya Frolov | 9d5657d | 2007-10-12 14:19:40 -0400 | [diff] [blame] | 544 | /***************************************************************************** |
| 545 | * General Touch Part |
| 546 | */ |
| 547 | #ifdef CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH |
| 548 | static int general_touch_read_data(struct usbtouch_usb *dev, unsigned char *pkt) |
| 549 | { |
| 550 | dev->x = ((pkt[2] & 0x0F) << 8) | pkt[1] ; |
| 551 | dev->y = ((pkt[4] & 0x0F) << 8) | pkt[3] ; |
| 552 | dev->press = pkt[5] & 0xff; |
| 553 | dev->touch = pkt[0] & 0x01; |
| 554 | |
| 555 | return 1; |
| 556 | } |
| 557 | #endif |
Ondrej Zary | a14a840 | 2007-09-04 23:45:01 -0400 | [diff] [blame] | 558 | |
| 559 | /***************************************************************************** |
Jerrold Jones | 14e4020 | 2007-10-22 00:59:47 -0400 | [diff] [blame] | 560 | * GoTop Part |
| 561 | */ |
| 562 | #ifdef CONFIG_TOUCHSCREEN_USB_GOTOP |
| 563 | static int gotop_read_data(struct usbtouch_usb *dev, unsigned char *pkt) |
| 564 | { |
| 565 | dev->x = ((pkt[1] & 0x38) << 4) | pkt[2]; |
| 566 | dev->y = ((pkt[1] & 0x07) << 7) | pkt[3]; |
| 567 | dev->touch = pkt[0] & 0x01; |
Jim Persson | f737069 | 2009-07-07 22:07:59 -0700 | [diff] [blame^] | 568 | |
| 569 | return 1; |
| 570 | } |
| 571 | #endif |
| 572 | |
| 573 | /***************************************************************************** |
| 574 | * JASTEC Part |
| 575 | */ |
| 576 | #ifdef CONFIG_TOUCHSCREEN_USB_JASTEC |
| 577 | static int jastec_read_data(struct usbtouch_usb *dev, unsigned char *pkt) |
| 578 | { |
| 579 | dev->x = ((pkt[0] & 0x3f) << 6) | (pkt[2] & 0x3f); |
| 580 | dev->y = ((pkt[1] & 0x3f) << 6) | (pkt[3] & 0x3f); |
| 581 | dev->touch = (pkt[0] & 0x40) >> 6; |
| 582 | |
Jerrold Jones | 14e4020 | 2007-10-22 00:59:47 -0400 | [diff] [blame] | 583 | return 1; |
| 584 | } |
| 585 | #endif |
| 586 | |
| 587 | |
| 588 | /***************************************************************************** |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 589 | * the different device descriptors |
| 590 | */ |
Daniel Ritz | 62aa366 | 2008-01-17 12:01:18 -0500 | [diff] [blame] | 591 | #ifdef MULTI_PACKET |
| 592 | static void usbtouch_process_multi(struct usbtouch_usb *usbtouch, |
| 593 | unsigned char *pkt, int len); |
| 594 | #endif |
| 595 | |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 596 | static struct usbtouch_device_info usbtouch_dev_info[] = { |
Ondrej Zary | c6f8d70 | 2007-06-12 00:33:13 -0400 | [diff] [blame] | 597 | #ifdef CONFIG_TOUCHSCREEN_USB_EGALAX |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 598 | [DEVTYPE_EGALAX] = { |
| 599 | .min_xc = 0x0, |
| 600 | .max_xc = 0x07ff, |
| 601 | .min_yc = 0x0, |
| 602 | .max_yc = 0x07ff, |
| 603 | .rept_size = 16, |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 604 | .process_pkt = usbtouch_process_multi, |
| 605 | .get_pkt_len = egalax_get_pkt_len, |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 606 | .read_data = egalax_read_data, |
| 607 | }, |
| 608 | #endif |
| 609 | |
Ondrej Zary | c6f8d70 | 2007-06-12 00:33:13 -0400 | [diff] [blame] | 610 | #ifdef CONFIG_TOUCHSCREEN_USB_PANJIT |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 611 | [DEVTYPE_PANJIT] = { |
| 612 | .min_xc = 0x0, |
| 613 | .max_xc = 0x0fff, |
| 614 | .min_yc = 0x0, |
| 615 | .max_yc = 0x0fff, |
| 616 | .rept_size = 8, |
| 617 | .read_data = panjit_read_data, |
| 618 | }, |
| 619 | #endif |
| 620 | |
Ondrej Zary | c6f8d70 | 2007-06-12 00:33:13 -0400 | [diff] [blame] | 621 | #ifdef CONFIG_TOUCHSCREEN_USB_3M |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 622 | [DEVTYPE_3M] = { |
| 623 | .min_xc = 0x0, |
| 624 | .max_xc = 0x4000, |
| 625 | .min_yc = 0x0, |
| 626 | .max_yc = 0x4000, |
| 627 | .rept_size = 11, |
| 628 | .read_data = mtouch_read_data, |
| 629 | .init = mtouch_init, |
| 630 | }, |
| 631 | #endif |
| 632 | |
Ondrej Zary | c6f8d70 | 2007-06-12 00:33:13 -0400 | [diff] [blame] | 633 | #ifdef CONFIG_TOUCHSCREEN_USB_ITM |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 634 | [DEVTYPE_ITM] = { |
| 635 | .min_xc = 0x0, |
| 636 | .max_xc = 0x0fff, |
| 637 | .min_yc = 0x0, |
| 638 | .max_yc = 0x0fff, |
| 639 | .max_press = 0xff, |
| 640 | .rept_size = 8, |
| 641 | .read_data = itm_read_data, |
| 642 | }, |
| 643 | #endif |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 644 | |
Ondrej Zary | c6f8d70 | 2007-06-12 00:33:13 -0400 | [diff] [blame] | 645 | #ifdef CONFIG_TOUCHSCREEN_USB_ETURBO |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 646 | [DEVTYPE_ETURBO] = { |
| 647 | .min_xc = 0x0, |
| 648 | .max_xc = 0x07ff, |
| 649 | .min_yc = 0x0, |
| 650 | .max_yc = 0x07ff, |
| 651 | .rept_size = 8, |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 652 | .process_pkt = usbtouch_process_multi, |
| 653 | .get_pkt_len = eturbo_get_pkt_len, |
| 654 | .read_data = eturbo_read_data, |
| 655 | }, |
| 656 | #endif |
| 657 | |
Ondrej Zary | c6f8d70 | 2007-06-12 00:33:13 -0400 | [diff] [blame] | 658 | #ifdef CONFIG_TOUCHSCREEN_USB_GUNZE |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 659 | [DEVTYPE_GUNZE] = { |
| 660 | .min_xc = 0x0, |
| 661 | .max_xc = 0x0fff, |
| 662 | .min_yc = 0x0, |
| 663 | .max_yc = 0x0fff, |
| 664 | .rept_size = 4, |
| 665 | .read_data = gunze_read_data, |
| 666 | }, |
| 667 | #endif |
Holger Schurig | 24ced06 | 2006-11-17 22:50:15 +0100 | [diff] [blame] | 668 | |
Ondrej Zary | c6f8d70 | 2007-06-12 00:33:13 -0400 | [diff] [blame] | 669 | #ifdef CONFIG_TOUCHSCREEN_USB_DMC_TSC10 |
Holger Schurig | 24ced06 | 2006-11-17 22:50:15 +0100 | [diff] [blame] | 670 | [DEVTYPE_DMC_TSC10] = { |
| 671 | .min_xc = 0x0, |
| 672 | .max_xc = 0x03ff, |
| 673 | .min_yc = 0x0, |
| 674 | .max_yc = 0x03ff, |
| 675 | .rept_size = 5, |
| 676 | .init = dmc_tsc10_init, |
| 677 | .read_data = dmc_tsc10_read_data, |
| 678 | }, |
| 679 | #endif |
Ondrej Zary | df561fc | 2007-07-03 01:55:03 -0400 | [diff] [blame] | 680 | |
| 681 | #ifdef CONFIG_TOUCHSCREEN_USB_IRTOUCH |
| 682 | [DEVTYPE_IRTOUCH] = { |
| 683 | .min_xc = 0x0, |
| 684 | .max_xc = 0x0fff, |
| 685 | .min_yc = 0x0, |
| 686 | .max_yc = 0x0fff, |
| 687 | .rept_size = 8, |
| 688 | .read_data = irtouch_read_data, |
| 689 | }, |
| 690 | #endif |
Ondrej Zary | a14a840 | 2007-09-04 23:45:01 -0400 | [diff] [blame] | 691 | |
| 692 | #ifdef CONFIG_TOUCHSCREEN_USB_IDEALTEK |
| 693 | [DEVTYPE_IDEALTEK] = { |
| 694 | .min_xc = 0x0, |
| 695 | .max_xc = 0x0fff, |
| 696 | .min_yc = 0x0, |
| 697 | .max_yc = 0x0fff, |
| 698 | .rept_size = 8, |
Ondrej Zary | a14a840 | 2007-09-04 23:45:01 -0400 | [diff] [blame] | 699 | .process_pkt = usbtouch_process_multi, |
| 700 | .get_pkt_len = idealtek_get_pkt_len, |
| 701 | .read_data = idealtek_read_data, |
| 702 | }, |
| 703 | #endif |
Ilya Frolov | 9d5657d | 2007-10-12 14:19:40 -0400 | [diff] [blame] | 704 | |
| 705 | #ifdef CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH |
| 706 | [DEVTYPE_GENERAL_TOUCH] = { |
| 707 | .min_xc = 0x0, |
| 708 | .max_xc = 0x0500, |
| 709 | .min_yc = 0x0, |
| 710 | .max_yc = 0x0500, |
| 711 | .rept_size = 7, |
| 712 | .read_data = general_touch_read_data, |
Jerrold Jones | 14e4020 | 2007-10-22 00:59:47 -0400 | [diff] [blame] | 713 | }, |
Ilya Frolov | 9d5657d | 2007-10-12 14:19:40 -0400 | [diff] [blame] | 714 | #endif |
| 715 | |
Jerrold Jones | 14e4020 | 2007-10-22 00:59:47 -0400 | [diff] [blame] | 716 | #ifdef CONFIG_TOUCHSCREEN_USB_GOTOP |
| 717 | [DEVTYPE_GOTOP] = { |
| 718 | .min_xc = 0x0, |
| 719 | .max_xc = 0x03ff, |
| 720 | .min_yc = 0x0, |
| 721 | .max_yc = 0x03ff, |
| 722 | .rept_size = 4, |
| 723 | .read_data = gotop_read_data, |
| 724 | }, |
| 725 | #endif |
Jim Persson | f737069 | 2009-07-07 22:07:59 -0700 | [diff] [blame^] | 726 | |
| 727 | #ifdef CONFIG_TOUCHSCREEN_USB_JASTEC |
| 728 | [DEVTYPE_JASTEC] = { |
| 729 | .min_xc = 0x0, |
| 730 | .max_xc = 0x0fff, |
| 731 | .min_yc = 0x0, |
| 732 | .max_yc = 0x0fff, |
| 733 | .rept_size = 4, |
| 734 | .read_data = jastec_read_data, |
| 735 | }, |
| 736 | #endif |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 737 | }; |
| 738 | |
| 739 | |
| 740 | /***************************************************************************** |
| 741 | * Generic Part |
| 742 | */ |
| 743 | static void usbtouch_process_pkt(struct usbtouch_usb *usbtouch, |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 744 | unsigned char *pkt, int len) |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 745 | { |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 746 | struct usbtouch_device_info *type = usbtouch->type; |
| 747 | |
Daniel Ritz | c9d8c2b | 2006-12-11 18:17:45 +0100 | [diff] [blame] | 748 | if (!type->read_data(usbtouch, pkt)) |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 749 | return; |
| 750 | |
Daniel Ritz | c9d8c2b | 2006-12-11 18:17:45 +0100 | [diff] [blame] | 751 | input_report_key(usbtouch->input, BTN_TOUCH, usbtouch->touch); |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 752 | |
| 753 | if (swap_xy) { |
Daniel Ritz | c9d8c2b | 2006-12-11 18:17:45 +0100 | [diff] [blame] | 754 | input_report_abs(usbtouch->input, ABS_X, usbtouch->y); |
| 755 | input_report_abs(usbtouch->input, ABS_Y, usbtouch->x); |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 756 | } else { |
Daniel Ritz | c9d8c2b | 2006-12-11 18:17:45 +0100 | [diff] [blame] | 757 | input_report_abs(usbtouch->input, ABS_X, usbtouch->x); |
| 758 | input_report_abs(usbtouch->input, ABS_Y, usbtouch->y); |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 759 | } |
| 760 | if (type->max_press) |
Daniel Ritz | c9d8c2b | 2006-12-11 18:17:45 +0100 | [diff] [blame] | 761 | input_report_abs(usbtouch->input, ABS_PRESSURE, usbtouch->press); |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 762 | input_sync(usbtouch->input); |
| 763 | } |
| 764 | |
| 765 | |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 766 | #ifdef MULTI_PACKET |
| 767 | static void usbtouch_process_multi(struct usbtouch_usb *usbtouch, |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 768 | unsigned char *pkt, int len) |
| 769 | { |
| 770 | unsigned char *buffer; |
| 771 | int pkt_len, pos, buf_len, tmp; |
| 772 | |
| 773 | /* process buffer */ |
| 774 | if (unlikely(usbtouch->buf_len)) { |
| 775 | /* try to get size */ |
| 776 | pkt_len = usbtouch->type->get_pkt_len( |
| 777 | usbtouch->buffer, usbtouch->buf_len); |
| 778 | |
| 779 | /* drop? */ |
| 780 | if (unlikely(!pkt_len)) |
| 781 | goto out_flush_buf; |
| 782 | |
| 783 | /* need to append -pkt_len bytes before able to get size */ |
| 784 | if (unlikely(pkt_len < 0)) { |
| 785 | int append = -pkt_len; |
| 786 | if (unlikely(append > len)) |
| 787 | append = len; |
| 788 | if (usbtouch->buf_len + append >= usbtouch->type->rept_size) |
| 789 | goto out_flush_buf; |
| 790 | memcpy(usbtouch->buffer + usbtouch->buf_len, pkt, append); |
| 791 | usbtouch->buf_len += append; |
| 792 | |
| 793 | pkt_len = usbtouch->type->get_pkt_len( |
| 794 | usbtouch->buffer, usbtouch->buf_len); |
| 795 | if (pkt_len < 0) |
| 796 | return; |
| 797 | } |
| 798 | |
| 799 | /* append */ |
| 800 | tmp = pkt_len - usbtouch->buf_len; |
| 801 | if (usbtouch->buf_len + tmp >= usbtouch->type->rept_size) |
| 802 | goto out_flush_buf; |
| 803 | memcpy(usbtouch->buffer + usbtouch->buf_len, pkt, tmp); |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 804 | usbtouch_process_pkt(usbtouch, usbtouch->buffer, pkt_len); |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 805 | |
| 806 | buffer = pkt + tmp; |
| 807 | buf_len = len - tmp; |
| 808 | } else { |
| 809 | buffer = pkt; |
| 810 | buf_len = len; |
| 811 | } |
| 812 | |
| 813 | /* loop over the received packet, process */ |
| 814 | pos = 0; |
| 815 | while (pos < buf_len) { |
| 816 | /* get packet len */ |
Daniel Ritz | 62aa366 | 2008-01-17 12:01:18 -0500 | [diff] [blame] | 817 | pkt_len = usbtouch->type->get_pkt_len(buffer + pos, |
| 818 | buf_len - pos); |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 819 | |
Daniel Ritz | 62aa366 | 2008-01-17 12:01:18 -0500 | [diff] [blame] | 820 | /* unknown packet: skip one byte */ |
| 821 | if (unlikely(!pkt_len)) { |
| 822 | pos++; |
| 823 | continue; |
| 824 | } |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 825 | |
| 826 | /* full packet: process */ |
| 827 | if (likely((pkt_len > 0) && (pkt_len <= buf_len - pos))) { |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 828 | usbtouch_process_pkt(usbtouch, buffer + pos, pkt_len); |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 829 | } else { |
| 830 | /* incomplete packet: save in buffer */ |
| 831 | memcpy(usbtouch->buffer, buffer + pos, buf_len - pos); |
| 832 | usbtouch->buf_len = buf_len - pos; |
| 833 | return; |
| 834 | } |
| 835 | pos += pkt_len; |
| 836 | } |
| 837 | |
| 838 | out_flush_buf: |
| 839 | usbtouch->buf_len = 0; |
| 840 | return; |
| 841 | } |
| 842 | #endif |
| 843 | |
| 844 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 845 | static void usbtouch_irq(struct urb *urb) |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 846 | { |
| 847 | struct usbtouch_usb *usbtouch = urb->context; |
| 848 | int retval; |
| 849 | |
| 850 | switch (urb->status) { |
| 851 | case 0: |
| 852 | /* success */ |
| 853 | break; |
Pete Zaitcev | 38e2bfc | 2006-09-18 22:49:02 -0700 | [diff] [blame] | 854 | case -ETIME: |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 855 | /* this urb is timing out */ |
| 856 | dbg("%s - urb timed out - was the device unplugged?", |
Harvey Harrison | ea3e6c5 | 2008-05-05 11:36:18 -0400 | [diff] [blame] | 857 | __func__); |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 858 | return; |
| 859 | case -ECONNRESET: |
| 860 | case -ENOENT: |
| 861 | case -ESHUTDOWN: |
| 862 | /* this urb is terminated, clean up */ |
| 863 | dbg("%s - urb shutting down with status: %d", |
Harvey Harrison | ea3e6c5 | 2008-05-05 11:36:18 -0400 | [diff] [blame] | 864 | __func__, urb->status); |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 865 | return; |
| 866 | default: |
| 867 | dbg("%s - nonzero urb status received: %d", |
Harvey Harrison | ea3e6c5 | 2008-05-05 11:36:18 -0400 | [diff] [blame] | 868 | __func__, urb->status); |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 869 | goto exit; |
| 870 | } |
| 871 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 872 | usbtouch->type->process_pkt(usbtouch, usbtouch->data, urb->actual_length); |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 873 | |
| 874 | exit: |
| 875 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
| 876 | if (retval) |
| 877 | err("%s - usb_submit_urb failed with result: %d", |
Harvey Harrison | ea3e6c5 | 2008-05-05 11:36:18 -0400 | [diff] [blame] | 878 | __func__, retval); |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 879 | } |
| 880 | |
| 881 | static int usbtouch_open(struct input_dev *input) |
| 882 | { |
Dmitry Torokhov | 7791bda | 2007-04-12 01:34:39 -0400 | [diff] [blame] | 883 | struct usbtouch_usb *usbtouch = input_get_drvdata(input); |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 884 | |
| 885 | usbtouch->irq->dev = usbtouch->udev; |
| 886 | |
| 887 | if (usb_submit_urb(usbtouch->irq, GFP_KERNEL)) |
| 888 | return -EIO; |
| 889 | |
| 890 | return 0; |
| 891 | } |
| 892 | |
| 893 | static void usbtouch_close(struct input_dev *input) |
| 894 | { |
Dmitry Torokhov | 7791bda | 2007-04-12 01:34:39 -0400 | [diff] [blame] | 895 | struct usbtouch_usb *usbtouch = input_get_drvdata(input); |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 896 | |
| 897 | usb_kill_urb(usbtouch->irq); |
| 898 | } |
| 899 | |
| 900 | |
| 901 | static void usbtouch_free_buffers(struct usb_device *udev, |
| 902 | struct usbtouch_usb *usbtouch) |
| 903 | { |
Dmitry Torokhov | e37a97d | 2007-05-03 00:57:29 -0400 | [diff] [blame] | 904 | usb_buffer_free(udev, usbtouch->type->rept_size, |
| 905 | usbtouch->data, usbtouch->data_dma); |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 906 | kfree(usbtouch->buffer); |
| 907 | } |
| 908 | |
| 909 | |
| 910 | static int usbtouch_probe(struct usb_interface *intf, |
| 911 | const struct usb_device_id *id) |
| 912 | { |
| 913 | struct usbtouch_usb *usbtouch; |
| 914 | struct input_dev *input_dev; |
| 915 | struct usb_host_interface *interface; |
| 916 | struct usb_endpoint_descriptor *endpoint; |
| 917 | struct usb_device *udev = interface_to_usbdev(intf); |
| 918 | struct usbtouch_device_info *type; |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 919 | int err = -ENOMEM; |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 920 | |
Daniel Ritz | ec42d44 | 2008-07-03 10:45:37 -0400 | [diff] [blame] | 921 | /* some devices are ignored */ |
| 922 | if (id->driver_info == DEVTYPE_IGNORE) |
| 923 | return -ENODEV; |
| 924 | |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 925 | interface = intf->cur_altsetting; |
| 926 | endpoint = &interface->endpoint[0].desc; |
| 927 | |
| 928 | usbtouch = kzalloc(sizeof(struct usbtouch_usb), GFP_KERNEL); |
| 929 | input_dev = input_allocate_device(); |
| 930 | if (!usbtouch || !input_dev) |
| 931 | goto out_free; |
| 932 | |
| 933 | type = &usbtouch_dev_info[id->driver_info]; |
| 934 | usbtouch->type = type; |
| 935 | if (!type->process_pkt) |
| 936 | type->process_pkt = usbtouch_process_pkt; |
| 937 | |
| 938 | usbtouch->data = usb_buffer_alloc(udev, type->rept_size, |
Christoph Lameter | e94b176 | 2006-12-06 20:33:17 -0800 | [diff] [blame] | 939 | GFP_KERNEL, &usbtouch->data_dma); |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 940 | if (!usbtouch->data) |
| 941 | goto out_free; |
| 942 | |
Daniel Ritz | 62aa366 | 2008-01-17 12:01:18 -0500 | [diff] [blame] | 943 | if (type->get_pkt_len) { |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 944 | usbtouch->buffer = kmalloc(type->rept_size, GFP_KERNEL); |
| 945 | if (!usbtouch->buffer) |
| 946 | goto out_free_buffers; |
| 947 | } |
| 948 | |
| 949 | usbtouch->irq = usb_alloc_urb(0, GFP_KERNEL); |
| 950 | if (!usbtouch->irq) { |
Harvey Harrison | ea3e6c5 | 2008-05-05 11:36:18 -0400 | [diff] [blame] | 951 | dbg("%s - usb_alloc_urb failed: usbtouch->irq", __func__); |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 952 | goto out_free_buffers; |
| 953 | } |
| 954 | |
| 955 | usbtouch->udev = udev; |
| 956 | usbtouch->input = input_dev; |
| 957 | |
| 958 | if (udev->manufacturer) |
| 959 | strlcpy(usbtouch->name, udev->manufacturer, sizeof(usbtouch->name)); |
| 960 | |
| 961 | if (udev->product) { |
| 962 | if (udev->manufacturer) |
| 963 | strlcat(usbtouch->name, " ", sizeof(usbtouch->name)); |
| 964 | strlcat(usbtouch->name, udev->product, sizeof(usbtouch->name)); |
| 965 | } |
| 966 | |
| 967 | if (!strlen(usbtouch->name)) |
| 968 | snprintf(usbtouch->name, sizeof(usbtouch->name), |
| 969 | "USB Touchscreen %04x:%04x", |
| 970 | le16_to_cpu(udev->descriptor.idVendor), |
| 971 | le16_to_cpu(udev->descriptor.idProduct)); |
| 972 | |
| 973 | usb_make_path(udev, usbtouch->phys, sizeof(usbtouch->phys)); |
Vladimir Shebordaev | 7b6dff9 | 2007-09-06 21:32:16 -0400 | [diff] [blame] | 974 | strlcat(usbtouch->phys, "/input0", sizeof(usbtouch->phys)); |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 975 | |
| 976 | input_dev->name = usbtouch->name; |
| 977 | input_dev->phys = usbtouch->phys; |
| 978 | usb_to_input_id(udev, &input_dev->id); |
Dmitry Torokhov | c0f82d5 | 2007-04-12 01:35:03 -0400 | [diff] [blame] | 979 | input_dev->dev.parent = &intf->dev; |
Dmitry Torokhov | 7791bda | 2007-04-12 01:34:39 -0400 | [diff] [blame] | 980 | |
| 981 | input_set_drvdata(input_dev, usbtouch); |
| 982 | |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 983 | input_dev->open = usbtouch_open; |
| 984 | input_dev->close = usbtouch_close; |
| 985 | |
Jiri Slaby | 7b19ada | 2007-10-18 23:40:32 -0700 | [diff] [blame] | 986 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
| 987 | input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 988 | input_set_abs_params(input_dev, ABS_X, type->min_xc, type->max_xc, 0, 0); |
| 989 | input_set_abs_params(input_dev, ABS_Y, type->min_yc, type->max_yc, 0, 0); |
| 990 | if (type->max_press) |
| 991 | input_set_abs_params(input_dev, ABS_PRESSURE, type->min_press, |
| 992 | type->max_press, 0, 0); |
| 993 | |
| 994 | usb_fill_int_urb(usbtouch->irq, usbtouch->udev, |
Daniel Ritz | d8fa59a | 2006-10-27 22:46:03 +0200 | [diff] [blame] | 995 | usb_rcvintpipe(usbtouch->udev, endpoint->bEndpointAddress), |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 996 | usbtouch->data, type->rept_size, |
| 997 | usbtouch_irq, usbtouch, endpoint->bInterval); |
| 998 | |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 999 | usbtouch->irq->dev = usbtouch->udev; |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 1000 | usbtouch->irq->transfer_dma = usbtouch->data_dma; |
| 1001 | usbtouch->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
| 1002 | |
| 1003 | /* device specific init */ |
| 1004 | if (type->init) { |
| 1005 | err = type->init(usbtouch); |
| 1006 | if (err) { |
Harvey Harrison | ea3e6c5 | 2008-05-05 11:36:18 -0400 | [diff] [blame] | 1007 | dbg("%s - type->init() failed, err: %d", __func__, err); |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 1008 | goto out_free_buffers; |
| 1009 | } |
| 1010 | } |
| 1011 | |
| 1012 | err = input_register_device(usbtouch->input); |
| 1013 | if (err) { |
Harvey Harrison | ea3e6c5 | 2008-05-05 11:36:18 -0400 | [diff] [blame] | 1014 | dbg("%s - input_register_device failed, err: %d", __func__, err); |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 1015 | goto out_free_buffers; |
| 1016 | } |
| 1017 | |
| 1018 | usb_set_intfdata(intf, usbtouch); |
| 1019 | |
| 1020 | return 0; |
| 1021 | |
| 1022 | out_free_buffers: |
| 1023 | usbtouch_free_buffers(udev, usbtouch); |
| 1024 | out_free: |
| 1025 | input_free_device(input_dev); |
| 1026 | kfree(usbtouch); |
Daniel Ritz | 5d89266 | 2006-07-31 21:43:24 +0200 | [diff] [blame] | 1027 | return err; |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 1028 | } |
| 1029 | |
| 1030 | static void usbtouch_disconnect(struct usb_interface *intf) |
| 1031 | { |
| 1032 | struct usbtouch_usb *usbtouch = usb_get_intfdata(intf); |
| 1033 | |
Harvey Harrison | ea3e6c5 | 2008-05-05 11:36:18 -0400 | [diff] [blame] | 1034 | dbg("%s - called", __func__); |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 1035 | |
| 1036 | if (!usbtouch) |
| 1037 | return; |
| 1038 | |
Harvey Harrison | ea3e6c5 | 2008-05-05 11:36:18 -0400 | [diff] [blame] | 1039 | dbg("%s - usbtouch is initialized, cleaning up", __func__); |
Daniel Ritz | 1d3e202 | 2006-03-29 22:41:07 +0200 | [diff] [blame] | 1040 | usb_set_intfdata(intf, NULL); |
| 1041 | usb_kill_urb(usbtouch->irq); |
| 1042 | input_unregister_device(usbtouch->input); |
| 1043 | usb_free_urb(usbtouch->irq); |
| 1044 | usbtouch_free_buffers(interface_to_usbdev(intf), usbtouch); |
| 1045 | kfree(usbtouch); |
| 1046 | } |
| 1047 | |
| 1048 | MODULE_DEVICE_TABLE(usb, usbtouch_devices); |
| 1049 | |
| 1050 | static struct usb_driver usbtouch_driver = { |
| 1051 | .name = "usbtouchscreen", |
| 1052 | .probe = usbtouch_probe, |
| 1053 | .disconnect = usbtouch_disconnect, |
| 1054 | .id_table = usbtouch_devices, |
| 1055 | }; |
| 1056 | |
| 1057 | static int __init usbtouch_init(void) |
| 1058 | { |
| 1059 | return usb_register(&usbtouch_driver); |
| 1060 | } |
| 1061 | |
| 1062 | static void __exit usbtouch_cleanup(void) |
| 1063 | { |
| 1064 | usb_deregister(&usbtouch_driver); |
| 1065 | } |
| 1066 | |
| 1067 | module_init(usbtouch_init); |
| 1068 | module_exit(usbtouch_cleanup); |
| 1069 | |
| 1070 | MODULE_AUTHOR(DRIVER_AUTHOR); |
| 1071 | MODULE_DESCRIPTION(DRIVER_DESC); |
| 1072 | MODULE_LICENSE("GPL"); |
| 1073 | |
| 1074 | MODULE_ALIAS("touchkitusb"); |
| 1075 | MODULE_ALIAS("itmtouch"); |
| 1076 | MODULE_ALIAS("mtouchusb"); |