1 /******************************************************************************
 
   3  * Driver for USB Touchscreens, supporting those devices:
 
   5  *    includes eTurboTouch CT-410/510/700
 
   6  *  - 3M/Microtouch  EX II series
 
  13  * Copyright (C) 2004-2006 by Daniel Ritz <daniel.ritz@gmx.ch>
 
  14  * Copyright (C) by Todd E. Johnson (mtouchusb.c)
 
  16  * This program is free software; you can redistribute it and/or
 
  17  * modify it under the terms of the GNU General Public License as
 
  18  * published by the Free Software Foundation; either version 2 of the
 
  19  * License, or (at your option) any later version.
 
  21  * This program is distributed in the hope that it will be useful, but
 
  22  * WITHOUT ANY WARRANTY; without even the implied warranty of
 
  23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
  24  * General Public License for more details.
 
  26  * You should have received a copy of the GNU General Public License
 
  27  * along with this program; if not, write to the Free Software
 
  28  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
  30  * Driver is based on touchkitusb.c
 
  31  * - ITM parts are from itmtouch.c
 
  32  * - 3M parts are from mtouchusb.c
 
  33  * - PanJit parts are from an unmerged driver by Lanslott Gish
 
  34  * - DMC TSC 10/25 are from Holger Schurig, with ideas from an unmerged
 
  35  *   driver from Marius Vollmer
 
  37  *****************************************************************************/
 
  41 #include <linux/kernel.h>
 
  42 #include <linux/slab.h>
 
  43 #include <linux/input.h>
 
  44 #include <linux/module.h>
 
  45 #include <linux/init.h>
 
  46 #include <linux/usb.h>
 
  47 #include <linux/usb/input.h>
 
  50 #define DRIVER_VERSION          "v0.5"
 
  51 #define DRIVER_AUTHOR           "Daniel Ritz <daniel.ritz@gmx.ch>"
 
  52 #define DRIVER_DESC             "USB Touchscreen Driver"
 
  55 module_param(swap_xy, bool, 0644);
 
  56 MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped.");
 
  58 /* device specifc data/functions */
 
  60 struct usbtouch_device_info {
 
  63         int min_press, max_press;
 
  67         void (*process_pkt) (struct usbtouch_usb *usbtouch, unsigned char *pkt, int len);
 
  68         int  (*get_pkt_len) (unsigned char *pkt, int len);
 
  69         int  (*read_data)   (unsigned char *pkt, int *x, int *y, int *touch, int *press);
 
  70         int  (*init)        (struct usbtouch_usb *usbtouch);
 
  73 #define USBTOUCH_FLG_BUFFER     0x01
 
  76 /* a usbtouch device */
 
  80         unsigned char *buffer;
 
  83         struct usb_device *udev;
 
  84         struct input_dev *input;
 
  85         struct usbtouch_device_info *type;
 
  91 #if defined(CONFIG_USB_TOUCHSCREEN_EGALAX) || defined(CONFIG_USB_TOUCHSCREEN_ETURBO)
 
  96 static void usbtouch_process_multi(struct usbtouch_usb *usbtouch,
 
  97                                    unsigned char *pkt, int len);
 
 112 static struct usb_device_id usbtouch_devices[] = {
 
 113 #ifdef CONFIG_USB_TOUCHSCREEN_EGALAX
 
 114         {USB_DEVICE(0x3823, 0x0001), .driver_info = DEVTYPE_EGALAX},
 
 115         {USB_DEVICE(0x3823, 0x0002), .driver_info = DEVTYPE_EGALAX},
 
 116         {USB_DEVICE(0x0123, 0x0001), .driver_info = DEVTYPE_EGALAX},
 
 117         {USB_DEVICE(0x0eef, 0x0001), .driver_info = DEVTYPE_EGALAX},
 
 118         {USB_DEVICE(0x0eef, 0x0002), .driver_info = DEVTYPE_EGALAX},
 
 119         {USB_DEVICE(0x1234, 0x0001), .driver_info = DEVTYPE_EGALAX},
 
 120         {USB_DEVICE(0x1234, 0x0002), .driver_info = DEVTYPE_EGALAX},
 
 123 #ifdef CONFIG_USB_TOUCHSCREEN_PANJIT
 
 124         {USB_DEVICE(0x134c, 0x0001), .driver_info = DEVTYPE_PANJIT},
 
 125         {USB_DEVICE(0x134c, 0x0002), .driver_info = DEVTYPE_PANJIT},
 
 126         {USB_DEVICE(0x134c, 0x0003), .driver_info = DEVTYPE_PANJIT},
 
 127         {USB_DEVICE(0x134c, 0x0004), .driver_info = DEVTYPE_PANJIT},
 
 130 #ifdef CONFIG_USB_TOUCHSCREEN_3M
 
 131         {USB_DEVICE(0x0596, 0x0001), .driver_info = DEVTYPE_3M},
 
 134 #ifdef CONFIG_USB_TOUCHSCREEN_ITM
 
 135         {USB_DEVICE(0x0403, 0xf9e9), .driver_info = DEVTYPE_ITM},
 
 138 #ifdef CONFIG_USB_TOUCHSCREEN_ETURBO
 
 139         {USB_DEVICE(0x1234, 0x5678), .driver_info = DEVTYPE_ETURBO},
 
 142 #ifdef CONFIG_USB_TOUCHSCREEN_GUNZE
 
 143         {USB_DEVICE(0x0637, 0x0001), .driver_info = DEVTYPE_GUNZE},
 
 146 #ifdef CONFIG_USB_TOUCHSCREEN_DMC_TSC10
 
 147         {USB_DEVICE(0x0afa, 0x03e8), .driver_info = DEVTYPE_DMC_TSC10},
 
 154 /*****************************************************************************
 
 158 #ifdef CONFIG_USB_TOUCHSCREEN_EGALAX
 
 160 #define EGALAX_PKT_TYPE_MASK            0xFE
 
 161 #define EGALAX_PKT_TYPE_REPT            0x80
 
 162 #define EGALAX_PKT_TYPE_DIAG            0x0A
 
 164 static int egalax_read_data(unsigned char *pkt, int *x, int *y, int *touch, int *press)
 
 166         if ((pkt[0] & EGALAX_PKT_TYPE_MASK) != EGALAX_PKT_TYPE_REPT)
 
 169         *x = ((pkt[3] & 0x0F) << 7) | (pkt[4] & 0x7F);
 
 170         *y = ((pkt[1] & 0x0F) << 7) | (pkt[2] & 0x7F);
 
 171         *touch = pkt[0] & 0x01;
 
 176 static int egalax_get_pkt_len(unsigned char *buf, int len)
 
 178         switch (buf[0] & EGALAX_PKT_TYPE_MASK) {
 
 179         case EGALAX_PKT_TYPE_REPT:
 
 182         case EGALAX_PKT_TYPE_DIAG:
 
 194 /*****************************************************************************
 
 197 #ifdef CONFIG_USB_TOUCHSCREEN_PANJIT
 
 198 static int panjit_read_data(unsigned char *pkt, int *x, int *y, int *touch, int *press)
 
 200         *x = ((pkt[2] & 0x0F) << 8) | pkt[1];
 
 201         *y = ((pkt[4] & 0x0F) << 8) | pkt[3];
 
 202         *touch = pkt[0] & 0x01;
 
 209 /*****************************************************************************
 
 212 #ifdef CONFIG_USB_TOUCHSCREEN_3M
 
 214 #define MTOUCHUSB_ASYNC_REPORT          1
 
 215 #define MTOUCHUSB_RESET                 7
 
 216 #define MTOUCHUSB_REQ_CTRLLR_ID         10
 
 218 static int mtouch_read_data(unsigned char *pkt, int *x, int *y, int *touch, int *press)
 
 220         *x = (pkt[8] << 8) | pkt[7];
 
 221         *y = (pkt[10] << 8) | pkt[9];
 
 222         *touch = (pkt[2] & 0x40) ? 1 : 0;
 
 227 static int mtouch_init(struct usbtouch_usb *usbtouch)
 
 231         ret = usb_control_msg(usbtouch->udev, usb_rcvctrlpipe(usbtouch->udev, 0),
 
 233                               USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
 
 234                               1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT);
 
 235         dbg("%s - usb_control_msg - MTOUCHUSB_RESET - bytes|err: %d",
 
 241         for (i = 0; i < 3; i++) {
 
 242                 ret = usb_control_msg(usbtouch->udev, usb_rcvctrlpipe(usbtouch->udev, 0),
 
 243                                       MTOUCHUSB_ASYNC_REPORT,
 
 244                                       USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
 
 245                                       1, 1, NULL, 0, USB_CTRL_SET_TIMEOUT);
 
 246                 dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d",
 
 259 /*****************************************************************************
 
 262 #ifdef CONFIG_USB_TOUCHSCREEN_ITM
 
 263 static int itm_read_data(unsigned char *pkt, int *x, int *y, int *touch, int *press)
 
 265         *x = ((pkt[0] & 0x1F) << 7) | (pkt[3] & 0x7F);
 
 266         *y = ((pkt[1] & 0x1F) << 7) | (pkt[4] & 0x7F);
 
 267         *press = ((pkt[2] & 0x01) << 7) | (pkt[5] & 0x7F);
 
 268         *touch = ~pkt[7] & 0x20;
 
 275 /*****************************************************************************
 
 278 #ifdef CONFIG_USB_TOUCHSCREEN_ETURBO
 
 279 static int eturbo_read_data(unsigned char *pkt, int *x, int *y, int *touch, int *press)
 
 283         /* packets should start with sync */
 
 284         if (!(pkt[0] & 0x80))
 
 287         shift = (6 - (pkt[0] & 0x03));
 
 288         *x = ((pkt[3] << 7) | pkt[4]) >> shift;
 
 289         *y = ((pkt[1] << 7) | pkt[2]) >> shift;
 
 290         *touch = (pkt[0] & 0x10) ? 1 : 0;
 
 295 static int eturbo_get_pkt_len(unsigned char *buf, int len)
 
 306 /*****************************************************************************
 
 309 #ifdef CONFIG_USB_TOUCHSCREEN_GUNZE
 
 310 static int gunze_read_data(unsigned char *pkt, int *x, int *y, int *touch, int *press)
 
 312         if (!(pkt[0] & 0x80) || ((pkt[1] | pkt[2] | pkt[3]) & 0x80))
 
 315         *x = ((pkt[0] & 0x1F) << 7) | (pkt[2] & 0x7F);
 
 316         *y = ((pkt[1] & 0x1F) << 7) | (pkt[3] & 0x7F);
 
 317         *touch = pkt[0] & 0x20;
 
 323 /*****************************************************************************
 
 326  * Documentation about the controller and it's protocol can be found at
 
 327  *   http://www.dmccoltd.com/files/controler/tsc10usb_pi_e.pdf
 
 328  *   http://www.dmccoltd.com/files/controler/tsc25_usb_e.pdf
 
 330 #ifdef CONFIG_USB_TOUCHSCREEN_DMC_TSC10
 
 332 /* supported data rates. currently using 130 */
 
 333 #define TSC10_RATE_POINT        0x50
 
 334 #define TSC10_RATE_30           0x40
 
 335 #define TSC10_RATE_50           0x41
 
 336 #define TSC10_RATE_80           0x42
 
 337 #define TSC10_RATE_100          0x43
 
 338 #define TSC10_RATE_130          0x44
 
 339 #define TSC10_RATE_150          0x45
 
 342 #define TSC10_CMD_RESET         0x55
 
 343 #define TSC10_CMD_RATE          0x05
 
 344 #define TSC10_CMD_DATA1         0x01
 
 346 static int dmc_tsc10_init(struct usbtouch_usb *usbtouch)
 
 348         struct usb_device *dev = usbtouch->udev;
 
 350         unsigned char buf[2];
 
 353         buf[0] = buf[1] = 0xFF;
 
 354         ret = usb_control_msg(dev, usb_rcvctrlpipe (dev, 0),
 
 356                               USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
 
 357                               0, 0, buf, 2, USB_CTRL_SET_TIMEOUT);
 
 360         if (buf[0] != 0x06 || buf[1] != 0x00)
 
 363         /* set coordinate output rate */
 
 364         buf[0] = buf[1] = 0xFF;
 
 365         ret = usb_control_msg(dev, usb_rcvctrlpipe (dev, 0),
 
 367                               USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
 
 368                               TSC10_RATE_150, 0, buf, 2, USB_CTRL_SET_TIMEOUT);
 
 371         if (buf[0] != 0x06 || buf[1] != 0x00)
 
 374         /* start sending data */
 
 375         ret = usb_control_msg(dev, usb_rcvctrlpipe (dev, 0),
 
 377                               USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
 
 378                               0, 0, NULL, 0, USB_CTRL_SET_TIMEOUT);
 
 386 static int dmc_tsc10_read_data(unsigned char *pkt, int *x, int *y, int *touch, int *press)
 
 388         *x = ((pkt[2] & 0x03) << 8) | pkt[1];
 
 389         *y = ((pkt[4] & 0x03) << 8) | pkt[3];
 
 390         *touch = pkt[0] & 0x01;
 
 397 /*****************************************************************************
 
 398  * the different device descriptors
 
 400 static struct usbtouch_device_info usbtouch_dev_info[] = {
 
 401 #ifdef CONFIG_USB_TOUCHSCREEN_EGALAX
 
 408                 .flags          = USBTOUCH_FLG_BUFFER,
 
 409                 .process_pkt    = usbtouch_process_multi,
 
 410                 .get_pkt_len    = egalax_get_pkt_len,
 
 411                 .read_data      = egalax_read_data,
 
 415 #ifdef CONFIG_USB_TOUCHSCREEN_PANJIT
 
 422                 .read_data      = panjit_read_data,
 
 426 #ifdef CONFIG_USB_TOUCHSCREEN_3M
 
 433                 .read_data      = mtouch_read_data,
 
 438 #ifdef CONFIG_USB_TOUCHSCREEN_ITM
 
 446                 .read_data      = itm_read_data,
 
 450 #ifdef CONFIG_USB_TOUCHSCREEN_ETURBO
 
 457                 .flags          = USBTOUCH_FLG_BUFFER,
 
 458                 .process_pkt    = usbtouch_process_multi,
 
 459                 .get_pkt_len    = eturbo_get_pkt_len,
 
 460                 .read_data      = eturbo_read_data,
 
 464 #ifdef CONFIG_USB_TOUCHSCREEN_GUNZE
 
 471                 .read_data      = gunze_read_data,
 
 475 #ifdef CONFIG_USB_TOUCHSCREEN_DMC_TSC10
 
 476         [DEVTYPE_DMC_TSC10] = {
 
 482                 .init           = dmc_tsc10_init,
 
 483                 .read_data      = dmc_tsc10_read_data,
 
 489 /*****************************************************************************
 
 492 static void usbtouch_process_pkt(struct usbtouch_usb *usbtouch,
 
 493                                  unsigned char *pkt, int len)
 
 495         int x, y, touch, press;
 
 496         struct usbtouch_device_info *type = usbtouch->type;
 
 498         if (!type->read_data(pkt, &x, &y, &touch, &press))
 
 501         input_report_key(usbtouch->input, BTN_TOUCH, touch);
 
 504                 input_report_abs(usbtouch->input, ABS_X, y);
 
 505                 input_report_abs(usbtouch->input, ABS_Y, x);
 
 507                 input_report_abs(usbtouch->input, ABS_X, x);
 
 508                 input_report_abs(usbtouch->input, ABS_Y, y);
 
 511                 input_report_abs(usbtouch->input, ABS_PRESSURE, press);
 
 512         input_sync(usbtouch->input);
 
 517 static void usbtouch_process_multi(struct usbtouch_usb *usbtouch,
 
 518                                    unsigned char *pkt, int len)
 
 520         unsigned char *buffer;
 
 521         int pkt_len, pos, buf_len, tmp;
 
 524         if (unlikely(usbtouch->buf_len)) {
 
 525                 /* try to get size */
 
 526                 pkt_len = usbtouch->type->get_pkt_len(
 
 527                                 usbtouch->buffer, usbtouch->buf_len);
 
 530                 if (unlikely(!pkt_len))
 
 533                 /* need to append -pkt_len bytes before able to get size */
 
 534                 if (unlikely(pkt_len < 0)) {
 
 535                         int append = -pkt_len;
 
 536                         if (unlikely(append > len))
 
 538                         if (usbtouch->buf_len + append >= usbtouch->type->rept_size)
 
 540                         memcpy(usbtouch->buffer + usbtouch->buf_len, pkt, append);
 
 541                         usbtouch->buf_len += append;
 
 543                         pkt_len = usbtouch->type->get_pkt_len(
 
 544                                         usbtouch->buffer, usbtouch->buf_len);
 
 550                 tmp = pkt_len - usbtouch->buf_len;
 
 551                 if (usbtouch->buf_len + tmp >= usbtouch->type->rept_size)
 
 553                 memcpy(usbtouch->buffer + usbtouch->buf_len, pkt, tmp);
 
 554                 usbtouch_process_pkt(usbtouch, usbtouch->buffer, pkt_len);
 
 563         /* loop over the received packet, process */
 
 565         while (pos < buf_len) {
 
 567                 pkt_len = usbtouch->type->get_pkt_len(buffer + pos, len);
 
 569                 /* unknown packet: drop everything */
 
 570                 if (unlikely(!pkt_len))
 
 573                 /* full packet: process */
 
 574                 if (likely((pkt_len > 0) && (pkt_len <= buf_len - pos))) {
 
 575                         usbtouch_process_pkt(usbtouch, buffer + pos, pkt_len);
 
 577                         /* incomplete packet: save in buffer */
 
 578                         memcpy(usbtouch->buffer, buffer + pos, buf_len - pos);
 
 579                         usbtouch->buf_len = buf_len - pos;
 
 586         usbtouch->buf_len = 0;
 
 592 static void usbtouch_irq(struct urb *urb)
 
 594         struct usbtouch_usb *usbtouch = urb->context;
 
 597         switch (urb->status) {
 
 602                 /* this urb is timing out */
 
 603                 dbg("%s - urb timed out - was the device unplugged?",
 
 609                 /* this urb is terminated, clean up */
 
 610                 dbg("%s - urb shutting down with status: %d",
 
 611                     __FUNCTION__, urb->status);
 
 614                 dbg("%s - nonzero urb status received: %d",
 
 615                     __FUNCTION__, urb->status);
 
 619         usbtouch->type->process_pkt(usbtouch, usbtouch->data, urb->actual_length);
 
 622         retval = usb_submit_urb(urb, GFP_ATOMIC);
 
 624                 err("%s - usb_submit_urb failed with result: %d",
 
 625                     __FUNCTION__, retval);
 
 628 static int usbtouch_open(struct input_dev *input)
 
 630         struct usbtouch_usb *usbtouch = input->private;
 
 632         usbtouch->irq->dev = usbtouch->udev;
 
 634         if (usb_submit_urb(usbtouch->irq, GFP_KERNEL))
 
 640 static void usbtouch_close(struct input_dev *input)
 
 642         struct usbtouch_usb *usbtouch = input->private;
 
 644         usb_kill_urb(usbtouch->irq);
 
 648 static void usbtouch_free_buffers(struct usb_device *udev,
 
 649                                   struct usbtouch_usb *usbtouch)
 
 652                 usb_buffer_free(udev, usbtouch->type->rept_size,
 
 653                                 usbtouch->data, usbtouch->data_dma);
 
 654         kfree(usbtouch->buffer);
 
 658 static int usbtouch_probe(struct usb_interface *intf,
 
 659                           const struct usb_device_id *id)
 
 661         struct usbtouch_usb *usbtouch;
 
 662         struct input_dev *input_dev;
 
 663         struct usb_host_interface *interface;
 
 664         struct usb_endpoint_descriptor *endpoint;
 
 665         struct usb_device *udev = interface_to_usbdev(intf);
 
 666         struct usbtouch_device_info *type;
 
 669         interface = intf->cur_altsetting;
 
 670         endpoint = &interface->endpoint[0].desc;
 
 672         usbtouch = kzalloc(sizeof(struct usbtouch_usb), GFP_KERNEL);
 
 673         input_dev = input_allocate_device();
 
 674         if (!usbtouch || !input_dev)
 
 677         type = &usbtouch_dev_info[id->driver_info];
 
 678         usbtouch->type = type;
 
 679         if (!type->process_pkt)
 
 680                 type->process_pkt = usbtouch_process_pkt;
 
 682         usbtouch->data = usb_buffer_alloc(udev, type->rept_size,
 
 683                                           GFP_KERNEL, &usbtouch->data_dma);
 
 687         if (type->flags & USBTOUCH_FLG_BUFFER) {
 
 688                 usbtouch->buffer = kmalloc(type->rept_size, GFP_KERNEL);
 
 689                 if (!usbtouch->buffer)
 
 690                         goto out_free_buffers;
 
 693         usbtouch->irq = usb_alloc_urb(0, GFP_KERNEL);
 
 694         if (!usbtouch->irq) {
 
 695                 dbg("%s - usb_alloc_urb failed: usbtouch->irq", __FUNCTION__);
 
 696                 goto out_free_buffers;
 
 699         usbtouch->udev = udev;
 
 700         usbtouch->input = input_dev;
 
 702         if (udev->manufacturer)
 
 703                 strlcpy(usbtouch->name, udev->manufacturer, sizeof(usbtouch->name));
 
 706                 if (udev->manufacturer)
 
 707                         strlcat(usbtouch->name, " ", sizeof(usbtouch->name));
 
 708                 strlcat(usbtouch->name, udev->product, sizeof(usbtouch->name));
 
 711         if (!strlen(usbtouch->name))
 
 712                 snprintf(usbtouch->name, sizeof(usbtouch->name),
 
 713                         "USB Touchscreen %04x:%04x",
 
 714                          le16_to_cpu(udev->descriptor.idVendor),
 
 715                          le16_to_cpu(udev->descriptor.idProduct));
 
 717         usb_make_path(udev, usbtouch->phys, sizeof(usbtouch->phys));
 
 718         strlcpy(usbtouch->phys, "/input0", sizeof(usbtouch->phys));
 
 720         input_dev->name = usbtouch->name;
 
 721         input_dev->phys = usbtouch->phys;
 
 722         usb_to_input_id(udev, &input_dev->id);
 
 723         input_dev->cdev.dev = &intf->dev;
 
 724         input_dev->private = usbtouch;
 
 725         input_dev->open = usbtouch_open;
 
 726         input_dev->close = usbtouch_close;
 
 728         input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
 
 729         input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
 
 730         input_set_abs_params(input_dev, ABS_X, type->min_xc, type->max_xc, 0, 0);
 
 731         input_set_abs_params(input_dev, ABS_Y, type->min_yc, type->max_yc, 0, 0);
 
 733                 input_set_abs_params(input_dev, ABS_PRESSURE, type->min_press,
 
 734                                      type->max_press, 0, 0);
 
 736         usb_fill_int_urb(usbtouch->irq, usbtouch->udev,
 
 737                          usb_rcvintpipe(usbtouch->udev, endpoint->bEndpointAddress),
 
 738                          usbtouch->data, type->rept_size,
 
 739                          usbtouch_irq, usbtouch, endpoint->bInterval);
 
 741         usbtouch->irq->dev = usbtouch->udev;
 
 742         usbtouch->irq->transfer_dma = usbtouch->data_dma;
 
 743         usbtouch->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
 
 745         /* device specific init */
 
 747                 err = type->init(usbtouch);
 
 749                         dbg("%s - type->init() failed, err: %d", __FUNCTION__, err);
 
 750                         goto out_free_buffers;
 
 754         err = input_register_device(usbtouch->input);
 
 756                 dbg("%s - input_register_device failed, err: %d", __FUNCTION__, err);
 
 757                 goto out_free_buffers;
 
 760         usb_set_intfdata(intf, usbtouch);
 
 765         usbtouch_free_buffers(udev, usbtouch);
 
 767         input_free_device(input_dev);
 
 772 static void usbtouch_disconnect(struct usb_interface *intf)
 
 774         struct usbtouch_usb *usbtouch = usb_get_intfdata(intf);
 
 776         dbg("%s - called", __FUNCTION__);
 
 781         dbg("%s - usbtouch is initialized, cleaning up", __FUNCTION__);
 
 782         usb_set_intfdata(intf, NULL);
 
 783         usb_kill_urb(usbtouch->irq);
 
 784         input_unregister_device(usbtouch->input);
 
 785         usb_free_urb(usbtouch->irq);
 
 786         usbtouch_free_buffers(interface_to_usbdev(intf), usbtouch);
 
 790 MODULE_DEVICE_TABLE(usb, usbtouch_devices);
 
 792 static struct usb_driver usbtouch_driver = {
 
 793         .name           = "usbtouchscreen",
 
 794         .probe          = usbtouch_probe,
 
 795         .disconnect     = usbtouch_disconnect,
 
 796         .id_table       = usbtouch_devices,
 
 799 static int __init usbtouch_init(void)
 
 801         return usb_register(&usbtouch_driver);
 
 804 static void __exit usbtouch_cleanup(void)
 
 806         usb_deregister(&usbtouch_driver);
 
 809 module_init(usbtouch_init);
 
 810 module_exit(usbtouch_cleanup);
 
 812 MODULE_AUTHOR(DRIVER_AUTHOR);
 
 813 MODULE_DESCRIPTION(DRIVER_DESC);
 
 814 MODULE_LICENSE("GPL");
 
 816 MODULE_ALIAS("touchkitusb");
 
 817 MODULE_ALIAS("itmtouch");
 
 818 MODULE_ALIAS("mtouchusb");