1 #include <linux/kernel.h>
2 #include <linux/slab.h>
3 #include <linux/module.h>
6 #include <asm/unaligned.h>
16 #define DRIVER_VERSION "v0.0.2"
18 #define DRIVER_DESC "USB KB Gear JamStudio Tablet driver"
19 #define DRIVER_LICENSE "GPL"
25 #define USB_VENDOR_ID_KBGEAR 0x084e
27 static int kb_pressure_click = 0x10;
34 struct input_dev *
dev;
41 static void kbtab_irq(
struct urb *
urb)
45 struct input_dev *
dev = kbtab->
dev;
49 switch (urb->status) {
58 "%s - urb shutting down with status: %d\n",
59 __func__, urb->status);
63 "%s - nonzero urb status received: %d\n",
64 __func__, urb->status);
71 input_report_abs(dev,
ABS_X, get_unaligned_le16(&data[1]));
72 input_report_abs(dev,
ABS_Y, get_unaligned_le16(&data[3]));
75 input_report_key(dev,
BTN_RIGHT, data[0] & 0x02);
78 if (kb_pressure_click == -1)
81 input_report_key(dev,
BTN_LEFT, pressure > kb_pressure_click ? 1 : 0);
89 "%s - usb_submit_urb failed with result %d\n",
100 static int kbtab_open(
struct input_dev *dev)
102 struct kbtab *kbtab = input_get_drvdata(dev);
111 static void kbtab_close(
struct input_dev *dev)
113 struct kbtab *kbtab = input_get_drvdata(dev);
120 struct usb_device *dev = interface_to_usbdev(intf);
123 struct input_dev *input_dev;
126 kbtab = kzalloc(
sizeof(
struct kbtab),
GFP_KERNEL);
127 input_dev = input_allocate_device();
128 if (!kbtab || !input_dev)
141 kbtab->
dev = input_dev;
143 usb_make_path(dev, kbtab->
phys,
sizeof(kbtab->
phys));
146 input_dev->name =
"KB Gear Tablet";
147 input_dev->phys = kbtab->
phys;
148 usb_to_input_id(dev, &input_dev->id);
149 input_dev->dev.parent = &intf->dev;
151 input_set_drvdata(input_dev, kbtab);
153 input_dev->open = kbtab_open;
154 input_dev->close = kbtab_close;
161 input_set_abs_params(input_dev,
ABS_X, 0, 0x2000, 4, 0);
162 input_set_abs_params(input_dev,
ABS_Y, 0, 0x1750, 4, 0);
163 input_set_abs_params(input_dev,
ABS_PRESSURE, 0, 0xff, 0, 0);
165 endpoint = &intf->cur_altsetting->endpoint[0].desc;
167 usb_fill_int_urb(kbtab->
irq, dev,
172 kbtab->
irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
174 error = input_register_device(kbtab->
dev);
178 usb_set_intfdata(intf, kbtab);
184 fail1: input_free_device(input_dev);
191 struct kbtab *kbtab = usb_get_intfdata(intf);
193 usb_set_intfdata(intf,
NULL);
195 input_unregister_device(kbtab->
dev);
201 static struct usb_driver kbtab_driver = {
203 .probe = kbtab_probe,
204 .disconnect = kbtab_disconnect,
205 .id_table = kbtab_ids,