Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * mtouchusb.c -- Driver for Microtouch (Now 3M) USB Touchscreens |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License as |
| 6 | * published by the Free Software Foundation; either version 2 of the |
| 7 | * License, or (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but |
| 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 17 | * |
| 18 | * Based upon original work by Radoslaw Garbacz (usb-support@ite.pl) |
| 19 | * (http://freshmeat.net/projects/3mtouchscreendriver) |
| 20 | * |
| 21 | * History |
| 22 | * |
| 23 | * 0.3 & 0.4 2002 (TEJ) tejohnson@yahoo.com |
| 24 | * Updated to 2.4.18, then 2.4.19 |
| 25 | * Old version still relied on stealing a minor |
| 26 | * |
| 27 | * 0.5 02/26/2004 (TEJ) tejohnson@yahoo.com |
| 28 | * Complete rewrite using Linux Input in 2.6.3 |
| 29 | * Unfortunately no calibration support at this time |
| 30 | * |
| 31 | * 1.4 04/25/2004 (TEJ) tejohnson@yahoo.com |
| 32 | * Changed reset from standard USB dev reset to vendor reset |
| 33 | * Changed data sent to host from compensated to raw coordinates |
| 34 | * Eliminated vendor/product module params |
Steven Cole | 093cf72 | 2005-05-03 19:07:24 -0600 | [diff] [blame] | 35 | * Performed multiple successful tests with an EXII-5010UC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | * |
| 37 | * 1.5 02/27/2005 ddstreet@ieee.org |
| 38 | * Added module parameter to select raw or hw-calibrated coordinate reporting |
| 39 | * |
| 40 | *****************************************************************************/ |
| 41 | |
| 42 | #include <linux/config.h> |
| 43 | |
| 44 | #ifdef CONFIG_USB_DEBUG |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 45 | #define DEBUG |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | #else |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 47 | #undef DEBUG |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | #endif |
| 49 | |
| 50 | #include <linux/kernel.h> |
| 51 | #include <linux/slab.h> |
| 52 | #include <linux/input.h> |
| 53 | #include <linux/module.h> |
| 54 | #include <linux/init.h> |
| 55 | #include <linux/usb.h> |
| 56 | |
| 57 | #define MTOUCHUSB_MIN_XC 0x0 |
| 58 | #define MTOUCHUSB_MAX_RAW_XC 0x4000 |
| 59 | #define MTOUCHUSB_MAX_CALIB_XC 0xffff |
| 60 | #define MTOUCHUSB_XC_FUZZ 0x0 |
| 61 | #define MTOUCHUSB_XC_FLAT 0x0 |
| 62 | #define MTOUCHUSB_MIN_YC 0x0 |
| 63 | #define MTOUCHUSB_MAX_RAW_YC 0x4000 |
| 64 | #define MTOUCHUSB_MAX_CALIB_YC 0xffff |
| 65 | #define MTOUCHUSB_YC_FUZZ 0x0 |
| 66 | #define MTOUCHUSB_YC_FLAT 0x0 |
| 67 | |
| 68 | #define MTOUCHUSB_ASYNC_REPORT 1 |
| 69 | #define MTOUCHUSB_RESET 7 |
| 70 | #define MTOUCHUSB_REPORT_DATA_SIZE 11 |
| 71 | #define MTOUCHUSB_REQ_CTRLLR_ID 10 |
| 72 | |
| 73 | #define MTOUCHUSB_GET_RAW_XC(data) (data[8]<<8 | data[7]) |
| 74 | #define MTOUCHUSB_GET_CALIB_XC(data) (data[4]<<8 | data[3]) |
| 75 | #define MTOUCHUSB_GET_RAW_YC(data) (data[10]<<8 | data[9]) |
| 76 | #define MTOUCHUSB_GET_CALIB_YC(data) (data[6]<<8 | data[5]) |
| 77 | #define MTOUCHUSB_GET_XC(data) (raw_coordinates ? \ |
| 78 | MTOUCHUSB_GET_RAW_XC(data) : \ |
| 79 | MTOUCHUSB_GET_CALIB_XC(data)) |
| 80 | #define MTOUCHUSB_GET_YC(data) (raw_coordinates ? \ |
| 81 | MTOUCHUSB_GET_RAW_YC(data) : \ |
| 82 | MTOUCHUSB_GET_CALIB_YC(data)) |
| 83 | #define MTOUCHUSB_GET_TOUCHED(data) ((data[2] & 0x40) ? 1:0) |
| 84 | |
| 85 | #define DRIVER_VERSION "v1.5" |
| 86 | #define DRIVER_AUTHOR "Todd E. Johnson, tejohnson@yahoo.com" |
| 87 | #define DRIVER_DESC "3M USB Touchscreen Driver" |
| 88 | #define DRIVER_LICENSE "GPL" |
| 89 | |
| 90 | static int raw_coordinates = 1; |
| 91 | |
| 92 | module_param(raw_coordinates, bool, S_IRUGO | S_IWUSR); |
| 93 | MODULE_PARM_DESC(raw_coordinates, "report raw coordinate values (y, default) or hardware-calibrated coordinate values (n)"); |
| 94 | |
| 95 | struct mtouch_usb { |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 96 | unsigned char *data; |
| 97 | dma_addr_t data_dma; |
| 98 | struct urb *irq; |
| 99 | struct usb_device *udev; |
| 100 | struct input_dev input; |
| 101 | int open; |
| 102 | char name[128]; |
| 103 | char phys[64]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | }; |
| 105 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 106 | static struct usb_device_id mtouchusb_devices[] = { |
| 107 | { USB_DEVICE(0x0596, 0x0001) }, |
| 108 | { } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | }; |
| 110 | |
| 111 | static void mtouchusb_irq(struct urb *urb, struct pt_regs *regs) |
| 112 | { |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 113 | struct mtouch_usb *mtouch = urb->context; |
| 114 | int retval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 116 | switch (urb->status) { |
| 117 | case 0: |
| 118 | /* success */ |
| 119 | break; |
| 120 | case -ETIMEDOUT: |
| 121 | /* this urb is timing out */ |
| 122 | dbg("%s - urb timed out - was the device unplugged?", |
| 123 | __FUNCTION__); |
| 124 | return; |
| 125 | case -ECONNRESET: |
| 126 | case -ENOENT: |
| 127 | case -ESHUTDOWN: |
| 128 | /* this urb is terminated, clean up */ |
| 129 | dbg("%s - urb shutting down with status: %d", |
| 130 | __FUNCTION__, urb->status); |
| 131 | return; |
| 132 | default: |
| 133 | dbg("%s - nonzero urb status received: %d", |
| 134 | __FUNCTION__, urb->status); |
| 135 | goto exit; |
| 136 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 138 | input_regs(&mtouch->input, regs); |
| 139 | input_report_key(&mtouch->input, BTN_TOUCH, |
| 140 | MTOUCHUSB_GET_TOUCHED(mtouch->data)); |
| 141 | input_report_abs(&mtouch->input, ABS_X, MTOUCHUSB_GET_XC(mtouch->data)); |
| 142 | input_report_abs(&mtouch->input, ABS_Y, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | (raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC) |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 144 | - MTOUCHUSB_GET_YC(mtouch->data)); |
| 145 | input_sync(&mtouch->input); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | |
| 147 | exit: |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 148 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
| 149 | if (retval) |
| 150 | err("%s - usb_submit_urb failed with result: %d", |
| 151 | __FUNCTION__, retval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | } |
| 153 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 154 | static int mtouchusb_open(struct input_dev *input) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | { |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 156 | struct mtouch_usb *mtouch = input->private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 158 | if (mtouch->open++) |
| 159 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 161 | mtouch->irq->dev = mtouch->udev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 163 | if (usb_submit_urb(mtouch->irq, GFP_ATOMIC)) { |
| 164 | mtouch->open--; |
| 165 | return -EIO; |
| 166 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 168 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | } |
| 170 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 171 | static void mtouchusb_close(struct input_dev *input) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | { |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 173 | struct mtouch_usb *mtouch = input->private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 175 | if (!--mtouch->open) |
| 176 | usb_kill_urb(mtouch->irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | static int mtouchusb_alloc_buffers(struct usb_device *udev, struct mtouch_usb *mtouch) |
| 180 | { |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 181 | dbg("%s - called", __FUNCTION__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 183 | mtouch->data = usb_buffer_alloc(udev, MTOUCHUSB_REPORT_DATA_SIZE, |
| 184 | SLAB_ATOMIC, &mtouch->data_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 186 | if (!mtouch->data) |
| 187 | return -1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 189 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | static void mtouchusb_free_buffers(struct usb_device *udev, struct mtouch_usb *mtouch) |
| 193 | { |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 194 | dbg("%s - called", __FUNCTION__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 196 | if (mtouch->data) |
| 197 | usb_buffer_free(udev, MTOUCHUSB_REPORT_DATA_SIZE, |
| 198 | mtouch->data, mtouch->data_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_id *id) |
| 202 | { |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 203 | struct mtouch_usb *mtouch; |
| 204 | struct usb_host_interface *interface; |
| 205 | struct usb_endpoint_descriptor *endpoint; |
| 206 | struct usb_device *udev = interface_to_usbdev(intf); |
| 207 | char path[64]; |
| 208 | int nRet; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 210 | dbg("%s - called", __FUNCTION__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 212 | dbg("%s - setting interface", __FUNCTION__); |
| 213 | interface = intf->cur_altsetting; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 215 | dbg("%s - setting endpoint", __FUNCTION__); |
| 216 | endpoint = &interface->endpoint[0].desc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 218 | if (!(mtouch = kmalloc(sizeof(struct mtouch_usb), GFP_KERNEL))) { |
| 219 | err("%s - Out of memory.", __FUNCTION__); |
| 220 | return -ENOMEM; |
| 221 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 223 | memset(mtouch, 0, sizeof(struct mtouch_usb)); |
| 224 | mtouch->udev = udev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 226 | dbg("%s - allocating buffers", __FUNCTION__); |
| 227 | if (mtouchusb_alloc_buffers(udev, mtouch)) { |
| 228 | mtouchusb_free_buffers(udev, mtouch); |
| 229 | kfree(mtouch); |
| 230 | return -ENOMEM; |
| 231 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 233 | mtouch->input.private = mtouch; |
| 234 | mtouch->input.open = mtouchusb_open; |
| 235 | mtouch->input.close = mtouchusb_close; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 237 | usb_make_path(udev, path, 64); |
| 238 | sprintf(mtouch->phys, "%s/input0", path); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 240 | mtouch->input.name = mtouch->name; |
| 241 | mtouch->input.phys = mtouch->phys; |
| 242 | mtouch->input.id.bustype = BUS_USB; |
| 243 | mtouch->input.id.vendor = le16_to_cpu(udev->descriptor.idVendor); |
| 244 | mtouch->input.id.product = le16_to_cpu(udev->descriptor.idProduct); |
| 245 | mtouch->input.id.version = le16_to_cpu(udev->descriptor.bcdDevice); |
| 246 | mtouch->input.dev = &intf->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 248 | mtouch->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
| 249 | mtouch->input.absbit[0] = BIT(ABS_X) | BIT(ABS_Y); |
| 250 | mtouch->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 252 | /* Used to Scale Compensated Data and Flip Y */ |
| 253 | mtouch->input.absmin[ABS_X] = MTOUCHUSB_MIN_XC; |
| 254 | mtouch->input.absmax[ABS_X] = raw_coordinates ? |
| 255 | MTOUCHUSB_MAX_RAW_XC : MTOUCHUSB_MAX_CALIB_XC; |
| 256 | mtouch->input.absfuzz[ABS_X] = MTOUCHUSB_XC_FUZZ; |
| 257 | mtouch->input.absflat[ABS_X] = MTOUCHUSB_XC_FLAT; |
| 258 | mtouch->input.absmin[ABS_Y] = MTOUCHUSB_MIN_YC; |
| 259 | mtouch->input.absmax[ABS_Y] = raw_coordinates ? |
| 260 | MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC; |
| 261 | mtouch->input.absfuzz[ABS_Y] = MTOUCHUSB_YC_FUZZ; |
| 262 | mtouch->input.absflat[ABS_Y] = MTOUCHUSB_YC_FLAT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | |
| 264 | if (udev->manufacturer) |
| 265 | strcat(mtouch->name, udev->manufacturer); |
| 266 | if (udev->product) |
| 267 | sprintf(mtouch->name, "%s %s", mtouch->name, udev->product); |
| 268 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 269 | if (!strlen(mtouch->name)) |
| 270 | sprintf(mtouch->name, "USB Touchscreen %04x:%04x", |
| 271 | mtouch->input.id.vendor, mtouch->input.id.product); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 273 | nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0), |
| 274 | MTOUCHUSB_RESET, |
| 275 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
| 276 | 1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); |
| 277 | dbg("%s - usb_control_msg - MTOUCHUSB_RESET - bytes|err: %d", |
| 278 | __FUNCTION__, nRet); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 280 | dbg("%s - usb_alloc_urb: mtouch->irq", __FUNCTION__); |
| 281 | mtouch->irq = usb_alloc_urb(0, GFP_KERNEL); |
| 282 | if (!mtouch->irq) { |
| 283 | dbg("%s - usb_alloc_urb failed: mtouch->irq", __FUNCTION__); |
| 284 | mtouchusb_free_buffers(udev, mtouch); |
| 285 | kfree(mtouch); |
| 286 | return -ENOMEM; |
| 287 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 289 | dbg("%s - usb_fill_int_urb", __FUNCTION__); |
| 290 | usb_fill_int_urb(mtouch->irq, mtouch->udev, |
| 291 | usb_rcvintpipe(mtouch->udev, 0x81), |
| 292 | mtouch->data, MTOUCHUSB_REPORT_DATA_SIZE, |
| 293 | mtouchusb_irq, mtouch, endpoint->bInterval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 295 | dbg("%s - input_register_device", __FUNCTION__); |
| 296 | input_register_device(&mtouch->input); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 298 | nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0), |
| 299 | MTOUCHUSB_ASYNC_REPORT, |
| 300 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
| 301 | 1, 1, NULL, 0, USB_CTRL_SET_TIMEOUT); |
| 302 | dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d", |
| 303 | __FUNCTION__, nRet); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 305 | printk(KERN_INFO "input: %s on %s\n", mtouch->name, path); |
| 306 | usb_set_intfdata(intf, mtouch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 308 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | static void mtouchusb_disconnect(struct usb_interface *intf) |
| 312 | { |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 313 | struct mtouch_usb *mtouch = usb_get_intfdata(intf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 315 | dbg("%s - called", __FUNCTION__); |
| 316 | usb_set_intfdata(intf, NULL); |
| 317 | if (mtouch) { |
| 318 | dbg("%s - mtouch is initialized, cleaning up", __FUNCTION__); |
| 319 | usb_kill_urb(mtouch->irq); |
| 320 | input_unregister_device(&mtouch->input); |
| 321 | usb_free_urb(mtouch->irq); |
| 322 | mtouchusb_free_buffers(interface_to_usbdev(intf), mtouch); |
| 323 | kfree(mtouch); |
| 324 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | } |
| 326 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 327 | MODULE_DEVICE_TABLE(usb, mtouchusb_devices); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | |
| 329 | static struct usb_driver mtouchusb_driver = { |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 330 | .owner = THIS_MODULE, |
| 331 | .name = "mtouchusb", |
| 332 | .probe = mtouchusb_probe, |
| 333 | .disconnect = mtouchusb_disconnect, |
| 334 | .id_table = mtouchusb_devices, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | }; |
| 336 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 337 | static int __init mtouchusb_init(void) |
| 338 | { |
| 339 | dbg("%s - called", __FUNCTION__); |
| 340 | return usb_register(&mtouchusb_driver); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | } |
| 342 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 343 | static void __exit mtouchusb_cleanup(void) |
| 344 | { |
| 345 | dbg("%s - called", __FUNCTION__); |
| 346 | usb_deregister(&mtouchusb_driver); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | } |
| 348 | |
| 349 | module_init(mtouchusb_init); |
| 350 | module_exit(mtouchusb_cleanup); |
| 351 | |
Dmitry Torokhov | 8baf9ed | 2005-05-29 02:29:08 -0500 | [diff] [blame^] | 352 | MODULE_AUTHOR(DRIVER_AUTHOR); |
| 353 | MODULE_DESCRIPTION(DRIVER_DESC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | MODULE_LICENSE("GPL"); |