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