2011-03-10 00:33:46 +05:30
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/usb/input.h>
|
|
|
|
#include <asm/unaligned.h>
|
|
|
|
|
2014-12-17 01:34:50 +05:30
|
|
|
#define DRIVER_VERSION "0.6"
|
2011-03-10 00:33:46 +05:30
|
|
|
#define DRIVER_AUTHOR "Ondra Havel <ondra.havel@gmail.com>"
|
2011-11-14 02:00:01 +05:30
|
|
|
#define DRIVER_DESC "USB Hanvon tablet driver"
|
2011-03-10 00:33:46 +05:30
|
|
|
#define DRIVER_LICENSE "GPL"
|
|
|
|
|
|
|
|
MODULE_AUTHOR(DRIVER_AUTHOR);
|
|
|
|
MODULE_DESCRIPTION(DRIVER_DESC);
|
|
|
|
MODULE_LICENSE(DRIVER_LICENSE);
|
|
|
|
|
|
|
|
#define USB_VENDOR_ID_HANVON 0x0b57
|
2012-12-20 03:37:19 +05:30
|
|
|
#define USB_PRODUCT_ID_AM3M 0x8528
|
2011-11-03 01:09:35 +05:30
|
|
|
#define USB_PRODUCT_ID_AM0806 0x8502
|
2012-06-04 04:06:45 +05:30
|
|
|
#define USB_PRODUCT_ID_AM0605 0x8503
|
2011-11-03 01:56:08 +05:30
|
|
|
#define USB_PRODUCT_ID_AM1107 0x8505
|
2011-11-03 01:09:35 +05:30
|
|
|
#define USB_PRODUCT_ID_AM1209 0x8501
|
2011-11-14 02:00:01 +05:30
|
|
|
#define USB_PRODUCT_ID_RL0604 0x851f
|
2013-01-04 05:30:22 +05:30
|
|
|
#define USB_PRODUCT_ID_RL0504 0x851d
|
|
|
|
#define USB_PRODUCT_ID_GP0806 0x8039
|
2013-06-08 03:13:49 +05:30
|
|
|
#define USB_PRODUCT_ID_GP0806B 0x8511
|
2014-01-27 15:35:12 +05:30
|
|
|
#define USB_PRODUCT_ID_GP0605 0x8512
|
2014-12-17 01:34:50 +05:30
|
|
|
#define USB_PRODUCT_ID_GP0605A 0x803a
|
2013-06-08 03:13:49 +05:30
|
|
|
#define USB_PRODUCT_ID_GP0504 0x8037
|
|
|
|
#define USB_PRODUCT_ID_NXS1513 0x8030
|
2014-12-17 01:34:50 +05:30
|
|
|
#define USB_PRODUCT_ID_GP0906 0x8521
|
|
|
|
#define USB_PRODUCT_ID_APPIV0906 0x8532
|
2011-11-03 01:09:35 +05:30
|
|
|
|
2014-12-17 01:34:50 +05:30
|
|
|
#define USB_AM_PACKET_LEN 10
|
2011-11-03 01:09:35 +05:30
|
|
|
|
2014-12-17 01:34:50 +05:30
|
|
|
static int lbuttons[]={BTN_0,BTN_1,BTN_2,BTN_3}; /* reported on all AMs */
|
|
|
|
static int rbuttons[]={BTN_4,BTN_5,BTN_6,BTN_7}; /* reported on AM1107+ */
|
2011-11-03 01:56:08 +05:30
|
|
|
|
2014-12-17 01:34:50 +05:30
|
|
|
#define AM_WHEEL_THRESHOLD 4
|
2011-11-03 01:09:35 +05:30
|
|
|
|
2014-12-17 01:34:50 +05:30
|
|
|
#define AM_MAX_TILT_X 0x3f
|
|
|
|
#define AM_MAX_TILT_Y 0x7f
|
|
|
|
#define AM_MAX_PRESSURE 0x400
|
2011-03-10 00:33:46 +05:30
|
|
|
|
|
|
|
struct hanvon {
|
|
|
|
unsigned char *data;
|
|
|
|
dma_addr_t data_dma;
|
|
|
|
struct input_dev *dev;
|
|
|
|
struct usb_device *usbdev;
|
|
|
|
struct urb *irq;
|
2011-03-11 01:14:42 +05:30
|
|
|
int old_wheel_pos;
|
2011-03-10 00:33:46 +05:30
|
|
|
char phys[32];
|
|
|
|
};
|
|
|
|
|
2014-12-17 01:34:50 +05:30
|
|
|
static void report_buttons(struct hanvon *hanvon, int buttons[], unsigned char dta)
|
2011-11-03 01:56:08 +05:30
|
|
|
{
|
|
|
|
struct input_dev *dev = hanvon->dev;
|
|
|
|
|
|
|
|
if((dta & 0xf0) == 0xa0) {
|
|
|
|
input_report_key(dev, buttons[1], dta & 0x02);
|
|
|
|
input_report_key(dev, buttons[2], dta & 0x04);
|
|
|
|
input_report_key(dev, buttons[3], dta & 0x08);
|
|
|
|
} else {
|
2014-12-17 01:34:50 +05:30
|
|
|
if(dta <= 0x3f) { /* slider area active */
|
2011-11-03 01:56:08 +05:30
|
|
|
int diff = dta - hanvon->old_wheel_pos;
|
|
|
|
if(abs(diff) < AM_WHEEL_THRESHOLD)
|
|
|
|
input_report_rel(dev, REL_WHEEL, diff);
|
|
|
|
|
|
|
|
hanvon->old_wheel_pos = dta;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:34:50 +05:30
|
|
|
static inline void handle_default(struct hanvon *hanvon)
|
|
|
|
{
|
|
|
|
unsigned char *data = hanvon->data;
|
|
|
|
struct input_dev *dev = hanvon->dev;
|
|
|
|
|
2014-12-18 01:35:29 +05:30
|
|
|
#define AM_MAX_ABS_X 0x27de
|
|
|
|
#define AM_MAX_ABS_Y 0x1cfe
|
|
|
|
|
2014-12-17 01:34:50 +05:30
|
|
|
switch(data[0]) {
|
|
|
|
case 0x01: /* button press */
|
|
|
|
if(data[1]==0x55) /* left side */
|
|
|
|
report_buttons(hanvon, lbuttons,data[2]);
|
|
|
|
|
|
|
|
if(data[3]==0xaa) /* right side (am1107, am1209) */
|
|
|
|
report_buttons(hanvon, rbuttons,data[4]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x02: /* position change */
|
|
|
|
if((data[1] & 0xf0) != 0) {
|
2014-12-18 01:35:29 +05:30
|
|
|
input_report_abs(dev, ABS_X, get_unaligned_be16(&data[2]) * 0xffff / AM_MAX_ABS_X);
|
|
|
|
input_report_abs(dev, ABS_Y, get_unaligned_be16(&data[4]) * 0xffff / AM_MAX_ABS_Y);
|
2014-12-17 01:34:50 +05:30
|
|
|
input_report_abs(dev, ABS_TILT_X, data[7] & 0x3f);
|
|
|
|
input_report_abs(dev, ABS_TILT_Y, data[8]);
|
|
|
|
input_report_abs(dev, ABS_PRESSURE, get_unaligned_be16(&data[6])>>6);
|
|
|
|
}
|
|
|
|
|
2014-12-18 01:35:29 +05:30
|
|
|
input_report_key(dev, BTN_LEFT, data[1] & 0x01); /* pen touches the surface */
|
|
|
|
input_report_key(dev, BTN_RIGHT, data[1] & 0x02); /* stylus button pressed (right click) */
|
|
|
|
input_report_key(dev, lbuttons[0], data[1] & 0x20); /* 'eraser' button */
|
|
|
|
break;
|
2014-12-17 01:34:50 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void handle_gp0906(struct hanvon *hanvon)
|
|
|
|
{
|
|
|
|
unsigned char *data = hanvon->data;
|
|
|
|
struct input_dev *dev = hanvon->dev;
|
|
|
|
/*
|
|
|
|
hanvon graphic pal 3, gp0906!
|
|
|
|
|
|
|
|
- data definition. this is not official...
|
|
|
|
[header, 1Byte][event type, 1Byte][x, 2Bytes][y, 2Bytes][pressure, 2Bytes][tilt, 2Bytes]
|
|
|
|
*/
|
|
|
|
|
|
|
|
switch( data[0] ) {
|
|
|
|
case 0x02: /* pen event */
|
|
|
|
if( ( data[1] & 0xe0) == 0xe0 ) {
|
2014-12-18 01:35:29 +05:30
|
|
|
if( data[1] & 0x01 ) /* pressure change */
|
2014-12-17 01:34:50 +05:30
|
|
|
input_report_abs(dev, ABS_PRESSURE, get_unaligned_be16(&data[6])>>6);
|
|
|
|
|
2014-12-18 01:35:29 +05:30
|
|
|
if( data[1] & 0x04 )
|
2014-12-17 01:34:50 +05:30
|
|
|
input_report_key(dev, BTN_RIGHT, data[1] & 0x2); /* stylus button pressed (right click) */
|
|
|
|
|
2014-12-18 01:35:29 +05:30
|
|
|
input_report_abs(dev, ABS_X, get_unaligned_be16(&data[2]) * 0xffff / AM_MAX_ABS_X);
|
|
|
|
input_report_abs(dev, ABS_Y, get_unaligned_be16(&data[4]) * 0xffff / AM_MAX_ABS_Y);
|
2014-12-17 01:34:50 +05:30
|
|
|
|
|
|
|
input_report_key(dev, lbuttons[0], data[6]);
|
|
|
|
} else {
|
|
|
|
if( data[1] == 0xc2) /* pen enters */
|
|
|
|
{}
|
|
|
|
|
|
|
|
if( data[1] == 0x80) /* pen leaves */
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x0c: /* key press on the tablet */
|
|
|
|
input_report_key(dev, lbuttons[0], data[3] & 0x01);
|
|
|
|
input_report_key(dev, lbuttons[1], data[3] & 0x02);
|
|
|
|
input_report_key(dev, lbuttons[2], data[3] & 0x04);
|
|
|
|
input_report_key(dev, lbuttons[3], data[3] & 0x08);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void handle_appiv0906(struct hanvon *hanvon)
|
2011-03-10 00:33:46 +05:30
|
|
|
{
|
|
|
|
unsigned char *data = hanvon->data;
|
|
|
|
struct input_dev *dev = hanvon->dev;
|
2014-12-17 01:34:50 +05:30
|
|
|
|
2014-12-18 01:35:29 +05:30
|
|
|
#define APPIV_XMAX 0x5750
|
|
|
|
#define APPIV_YMAX 0x3692
|
|
|
|
|
2014-12-17 01:34:50 +05:30
|
|
|
switch(data[0]) {
|
2014-12-18 01:35:29 +05:30
|
|
|
case 0x01: /* pen button event */
|
|
|
|
input_report_abs(dev, ABS_X, get_unaligned_le16(&data[2]) * 0xffff / APPIV_XMAX);
|
|
|
|
input_report_abs(dev, ABS_Y, get_unaligned_le16(&data[4]) * 0xffff / APPIV_YMAX);
|
|
|
|
input_report_key(dev, BTN_LEFT, data[1] & 0x01); /* pen touches the surface */
|
|
|
|
input_report_key(dev, BTN_RIGHT, data[1] & 0x02); /* stylus button pressed (right click) */
|
|
|
|
input_report_key(dev, BTN_MIDDLE, data[1] & 0x04); /* stylus button pressed (right click) */
|
|
|
|
input_report_key(dev, BTN_0, data[1] & 0x08); /* stylus button pressed (right click) */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x02: /* pen event */
|
|
|
|
input_report_abs(dev, ABS_X, get_unaligned_be16(&data[2]) * 0xffff / APPIV_XMAX);
|
|
|
|
input_report_abs(dev, ABS_Y, get_unaligned_be16(&data[4]) * 0xffff / APPIV_YMAX);
|
|
|
|
|
|
|
|
if(data[1] & 1)
|
|
|
|
input_report_abs(dev, ABS_PRESSURE, get_unaligned_be16(&data[6])>>6);
|
|
|
|
|
2014-12-17 01:34:50 +05:30
|
|
|
|
|
|
|
break;
|
|
|
|
|
2014-12-18 01:35:29 +05:30
|
|
|
case 0x0c: /* tablet button event */
|
|
|
|
input_report_key(dev, BTN_1, data[3] & 0x01);
|
|
|
|
input_report_key(dev, BTN_2, data[3] & 0x02);
|
|
|
|
input_report_key(dev, BTN_3, data[3] & 0x04);
|
|
|
|
input_report_key(dev, BTN_4, data[3] & 0x08);
|
|
|
|
input_report_key(dev, BTN_5, data[3] & 0x10);
|
|
|
|
input_report_key(dev, BTN_6, data[3] & 0x20);
|
|
|
|
input_report_key(dev, BTN_7, data[3] & 0x40);
|
2014-12-17 01:34:50 +05:30
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void hanvon_irq(struct urb *urb)
|
|
|
|
{
|
|
|
|
struct hanvon *hanvon = urb->context;
|
2011-03-10 00:33:46 +05:30
|
|
|
int retval;
|
|
|
|
|
|
|
|
switch (urb->status) {
|
|
|
|
case 0:
|
|
|
|
/* success */
|
2014-12-17 01:34:50 +05:30
|
|
|
switch( hanvon->usbdev->descriptor.idProduct ) {
|
|
|
|
case USB_PRODUCT_ID_GP0906:
|
|
|
|
handle_gp0906(hanvon);
|
|
|
|
break;
|
|
|
|
case USB_PRODUCT_ID_APPIV0906:
|
|
|
|
handle_appiv0906(hanvon);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
handle_default(hanvon);
|
|
|
|
break;
|
|
|
|
}
|
2011-03-10 00:33:46 +05:30
|
|
|
break;
|
|
|
|
case -ECONNRESET:
|
|
|
|
case -ENOENT:
|
|
|
|
case -ESHUTDOWN:
|
|
|
|
/* this urb is terminated, clean up */
|
2014-01-27 15:35:12 +05:30
|
|
|
printk("%s - urb shutting down with status: %d", __func__, urb->status);
|
2011-03-10 00:33:46 +05:30
|
|
|
return;
|
|
|
|
default:
|
2014-01-27 15:35:12 +05:30
|
|
|
printk("%s - nonzero urb status received: %d", __func__, urb->status);
|
2014-12-17 01:34:50 +05:30
|
|
|
break;
|
2011-03-10 00:33:46 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-12-17 01:34:50 +05:30
|
|
|
input_sync(hanvon->dev);
|
2011-03-10 00:33:46 +05:30
|
|
|
|
|
|
|
retval = usb_submit_urb (urb, GFP_ATOMIC);
|
|
|
|
if (retval)
|
2014-01-27 15:35:12 +05:30
|
|
|
printk("%s - usb_submit_urb failed with result %d", __func__, retval);
|
2011-03-10 00:33:46 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
static struct usb_device_id hanvon_ids[] = {
|
2012-12-20 03:37:19 +05:30
|
|
|
{ USB_DEVICE(USB_VENDOR_ID_HANVON, USB_PRODUCT_ID_AM3M) },
|
2011-11-03 01:09:35 +05:30
|
|
|
{ USB_DEVICE(USB_VENDOR_ID_HANVON, USB_PRODUCT_ID_AM1209) },
|
2011-11-03 01:56:08 +05:30
|
|
|
{ USB_DEVICE(USB_VENDOR_ID_HANVON, USB_PRODUCT_ID_AM1107) },
|
2011-11-03 01:09:35 +05:30
|
|
|
{ USB_DEVICE(USB_VENDOR_ID_HANVON, USB_PRODUCT_ID_AM0806) },
|
2012-06-01 00:53:12 +05:30
|
|
|
{ USB_DEVICE(USB_VENDOR_ID_HANVON, USB_PRODUCT_ID_AM0605) },
|
2011-11-14 02:00:01 +05:30
|
|
|
{ USB_DEVICE(USB_VENDOR_ID_HANVON, USB_PRODUCT_ID_RL0604) },
|
2012-12-20 03:37:19 +05:30
|
|
|
{ USB_DEVICE(USB_VENDOR_ID_HANVON, USB_PRODUCT_ID_RL0504) },
|
2013-01-04 05:30:22 +05:30
|
|
|
{ USB_DEVICE(USB_VENDOR_ID_HANVON, USB_PRODUCT_ID_GP0806) },
|
2013-06-08 03:13:49 +05:30
|
|
|
{ USB_DEVICE(USB_VENDOR_ID_HANVON, USB_PRODUCT_ID_GP0806B) },
|
2014-01-27 15:35:12 +05:30
|
|
|
{ USB_DEVICE(USB_VENDOR_ID_HANVON, USB_PRODUCT_ID_GP0605) },
|
2014-01-27 15:21:53 +05:30
|
|
|
{ USB_DEVICE(USB_VENDOR_ID_HANVON, USB_PRODUCT_ID_GP0605A) },
|
2013-02-03 21:52:26 +05:30
|
|
|
{ USB_DEVICE(USB_VENDOR_ID_HANVON, USB_PRODUCT_ID_GP0504) },
|
2014-12-17 01:34:50 +05:30
|
|
|
{ USB_DEVICE(USB_VENDOR_ID_HANVON, USB_PRODUCT_ID_NXS1513) },
|
|
|
|
{ USB_DEVICE(USB_VENDOR_ID_HANVON, USB_PRODUCT_ID_GP0906) },
|
|
|
|
{ USB_DEVICE(USB_VENDOR_ID_HANVON, USB_PRODUCT_ID_APPIV0906)},
|
|
|
|
{}
|
2011-03-10 00:33:46 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(usb, hanvon_ids);
|
|
|
|
|
|
|
|
static int hanvon_open(struct input_dev *dev)
|
|
|
|
{
|
|
|
|
struct hanvon *hanvon = input_get_drvdata(dev);
|
|
|
|
|
2011-11-03 01:09:35 +05:30
|
|
|
hanvon->old_wheel_pos = -AM_WHEEL_THRESHOLD-1;
|
2011-03-10 00:33:46 +05:30
|
|
|
hanvon->irq->dev = hanvon->usbdev;
|
2012-03-27 02:41:59 +05:30
|
|
|
if (usb_submit_urb(hanvon->irq, GFP_KERNEL))
|
2012-04-02 03:48:35 +05:30
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
return 0;
|
2011-03-10 00:33:46 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
static void hanvon_close(struct input_dev *dev)
|
|
|
|
{
|
|
|
|
struct hanvon *hanvon = input_get_drvdata(dev);
|
|
|
|
|
|
|
|
usb_kill_urb(hanvon->irq);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int hanvon_probe(struct usb_interface *intf, const struct usb_device_id *id)
|
|
|
|
{
|
|
|
|
struct usb_device *dev = interface_to_usbdev(intf);
|
|
|
|
struct usb_endpoint_descriptor *endpoint;
|
|
|
|
struct hanvon *hanvon;
|
|
|
|
struct input_dev *input_dev;
|
2011-11-03 01:56:08 +05:30
|
|
|
int error = -ENOMEM, i;
|
2011-03-10 00:33:46 +05:30
|
|
|
|
|
|
|
hanvon = kzalloc(sizeof(struct hanvon), GFP_KERNEL);
|
|
|
|
input_dev = input_allocate_device();
|
|
|
|
if (!hanvon || !input_dev)
|
|
|
|
goto fail1;
|
|
|
|
|
2011-11-03 01:09:35 +05:30
|
|
|
hanvon->data = (unsigned char *)usb_alloc_coherent(dev, USB_AM_PACKET_LEN, GFP_KERNEL, &hanvon->data_dma);
|
2011-03-10 00:33:46 +05:30
|
|
|
if (!hanvon->data)
|
|
|
|
goto fail1;
|
|
|
|
|
|
|
|
hanvon->irq = usb_alloc_urb(0, GFP_KERNEL);
|
|
|
|
if (!hanvon->irq)
|
|
|
|
goto fail2;
|
|
|
|
|
|
|
|
hanvon->usbdev = dev;
|
|
|
|
hanvon->dev = input_dev;
|
|
|
|
|
|
|
|
usb_make_path(dev, hanvon->phys, sizeof(hanvon->phys));
|
|
|
|
strlcat(hanvon->phys, "/input0", sizeof(hanvon->phys));
|
|
|
|
|
2014-12-17 01:34:50 +05:30
|
|
|
input_dev->name = "Hanvon tablet";
|
2011-03-10 00:33:46 +05:30
|
|
|
input_dev->phys = hanvon->phys;
|
|
|
|
usb_to_input_id(dev, &input_dev->id);
|
|
|
|
input_dev->dev.parent = &intf->dev;
|
|
|
|
|
|
|
|
input_set_drvdata(input_dev, hanvon);
|
|
|
|
|
|
|
|
input_dev->open = hanvon_open;
|
|
|
|
input_dev->close = hanvon_close;
|
|
|
|
|
2011-06-15 02:14:09 +05:30
|
|
|
input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) | BIT_MASK(EV_REL);
|
2011-06-15 04:35:11 +05:30
|
|
|
input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_PEN) | BIT_MASK(BTN_TOUCH);
|
2014-12-18 01:35:29 +05:30
|
|
|
input_dev->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE);
|
2011-11-03 01:56:08 +05:30
|
|
|
for(i=0;i<sizeof(lbuttons)/sizeof(lbuttons[0]);i++)
|
2014-12-17 01:34:50 +05:30
|
|
|
__set_bit(lbuttons[i], input_dev->keybit);
|
2011-11-03 01:56:08 +05:30
|
|
|
for(i=0;i<sizeof(rbuttons)/sizeof(rbuttons[0]);i++)
|
2014-12-17 01:34:50 +05:30
|
|
|
__set_bit(rbuttons[i], input_dev->keybit);
|
2011-11-03 01:09:35 +05:30
|
|
|
|
2014-12-18 01:35:29 +05:30
|
|
|
input_set_abs_params(input_dev, ABS_X, 0, 0xffff, 4, 0);
|
|
|
|
input_set_abs_params(input_dev, ABS_Y, 0, 0xffff, 4, 0);
|
2011-11-03 01:09:35 +05:30
|
|
|
input_set_abs_params(input_dev, ABS_TILT_X, 0, AM_MAX_TILT_X, 0, 0);
|
|
|
|
input_set_abs_params(input_dev, ABS_TILT_Y, 0, AM_MAX_TILT_Y, 0, 0);
|
|
|
|
input_set_abs_params(input_dev, ABS_PRESSURE, 0, AM_MAX_PRESSURE, 0, 0);
|
2011-06-15 02:14:09 +05:30
|
|
|
input_set_capability(input_dev, EV_REL, REL_WHEEL);
|
2011-03-10 00:33:46 +05:30
|
|
|
|
|
|
|
endpoint = &intf->cur_altsetting->endpoint[0].desc;
|
|
|
|
|
|
|
|
usb_fill_int_urb(hanvon->irq, dev,
|
2014-12-17 01:34:50 +05:30
|
|
|
usb_rcvintpipe(dev, endpoint->bEndpointAddress),
|
|
|
|
hanvon->data, USB_AM_PACKET_LEN,
|
|
|
|
hanvon_irq, hanvon, endpoint->bInterval);
|
2011-03-10 00:33:46 +05:30
|
|
|
hanvon->irq->transfer_dma = hanvon->data_dma;
|
|
|
|
hanvon->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
|
|
|
|
|
|
|
|
error = input_register_device(hanvon->dev);
|
|
|
|
if (error)
|
|
|
|
goto fail3;
|
|
|
|
|
|
|
|
usb_set_intfdata(intf, hanvon);
|
|
|
|
return 0;
|
|
|
|
|
2014-12-17 01:34:50 +05:30
|
|
|
fail3: usb_free_urb(hanvon->irq);
|
|
|
|
fail2: usb_free_coherent(dev, USB_AM_PACKET_LEN, hanvon->data, hanvon->data_dma);
|
|
|
|
fail1: input_free_device(input_dev);
|
2011-03-10 00:33:46 +05:30
|
|
|
kfree(hanvon);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void hanvon_disconnect(struct usb_interface *intf)
|
|
|
|
{
|
|
|
|
struct hanvon *hanvon = usb_get_intfdata(intf);
|
|
|
|
|
2012-03-27 02:41:59 +05:30
|
|
|
usb_set_intfdata(intf, NULL);
|
2011-03-10 00:33:46 +05:30
|
|
|
if (hanvon) {
|
|
|
|
usb_kill_urb(hanvon->irq);
|
|
|
|
input_unregister_device(hanvon->dev);
|
|
|
|
usb_free_urb(hanvon->irq);
|
2011-11-03 01:09:35 +05:30
|
|
|
usb_free_coherent(interface_to_usbdev(intf), USB_AM_PACKET_LEN, hanvon->data, hanvon->data_dma);
|
2011-03-10 00:33:46 +05:30
|
|
|
kfree(hanvon);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct usb_driver hanvon_driver = {
|
2014-12-17 01:34:50 +05:30
|
|
|
.name = "hanvon",
|
2011-03-10 00:33:46 +05:30
|
|
|
.probe = hanvon_probe,
|
|
|
|
.disconnect = hanvon_disconnect,
|
2014-12-17 01:34:50 +05:30
|
|
|
.id_table = hanvon_ids,
|
2011-03-10 00:33:46 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
static int __init hanvon_init(void)
|
|
|
|
{
|
|
|
|
int rv;
|
|
|
|
|
|
|
|
if((rv = usb_register(&hanvon_driver)) != 0)
|
|
|
|
return rv;
|
|
|
|
|
2011-11-03 01:56:08 +05:30
|
|
|
printk(DRIVER_DESC " " DRIVER_VERSION "\n");
|
2011-03-10 00:33:46 +05:30
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit hanvon_exit(void)
|
|
|
|
{
|
|
|
|
usb_deregister(&hanvon_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(hanvon_init);
|
|
|
|
module_exit(hanvon_exit);
|