* [PATCH] KB Gear JamStudio USB Tablet
@ 2002-10-25 7:04 Josh Myer
2002-10-25 7:25 ` Brad Hards
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Josh Myer @ 2002-10-25 7:04 UTC (permalink / raw)
To: linux-usb-devel, linux-kernel
[-- Attachment #1: Type: TEXT/PLAIN, Size: 821 bytes --]
Attached is a patch against 2.4.19 for basic support of the KB Gear
JamStudio USB tablet (it's a decent enough 30$ tablet--not quite wacom
quality, but definitely not wacom pricing).
Comments highly encouraged, thanks. I'd like to get this driver cleaned up
a little before submitting, but I'm not quite certain where to start.
The code is based heavily on the wacom driver, and a big "You Rule!" to
Pavel and anyone else involved with the Input layer. It may be a little
convoluted, and slightly non-intuitive, but it's a hell of a lot better
than the USB HID spec!
--
/jbm, but you can call me Josh. Really, you can!
this signature brought to you by the phrase,
"this signature brought to you by the phrase,
'...' and contributions by viewers like you"
7958 1C1C 306A CDF8 4468 3EDE 1F93 F49D 5FA1 49C4
[-- Attachment #2: Type: TEXT/plain, Size: 6838 bytes --]
diff -urN linux-2.4.19/Documentation/Configure.help linux-2.4.19-kb/Documentation/Configure.help
--- linux-2.4.19/Documentation/Configure.help 2002-08-02 20:39:42.000000000 -0400
+++ linux-2.4.19-kb/Documentation/Configure.help 2002-10-25 01:58:24.000000000 -0400
@@ -13108,6 +13108,17 @@
The module will be called wacom.o. If you want to compile it as a
module, say M here and read <file:Documentation/modules.txt>.
+KB Gear JamStudio tablet support
+CONFIG_USB_KBGEAR
+ Say Y here if you want to use the KB Gear JamStudio USB Tablet.
+ Make sure to say Y to "Mouse support" (CONFIG_INPUT_MOUSEDEV)
+ and/or "Event interface support" (CONFIG_INPUT_EVDEV) as well.
+
+ This driver is also available as a module ( = code which can be
+ inserted in and removed from the running kernel whenever you want).
+ The module will be called wacom.o. If you want to compile it as a
+ module, say M here and read <file:Documentation/modules.txt>.
+
Aiptek 8000U tablet support
CONFIG_USB_AIPTEK
Say Y here if you want to use the USB version of the Aiptek 8000U
diff -urN linux-2.4.19/drivers/usb/Config.in linux-2.4.19-kb/drivers/usb/Config.in
--- linux-2.4.19/drivers/usb/Config.in 2002-08-02 20:39:44.000000000 -0400
+++ linux-2.4.19-kb/drivers/usb/Config.in 2002-10-25 01:56:40.000000000 -0400
@@ -60,6 +60,7 @@
dep_tristate ' USB HIDBP Mouse (basic) support' CONFIG_USB_MOUSE $CONFIG_USB $CONFIG_INPUT
fi
dep_tristate ' Wacom Intuos/Graphire tablet support' CONFIG_USB_WACOM $CONFIG_USB $CONFIG_INPUT
+ dep_tristate ' KB Gear JamStudio tablet support' CONFIG_USB_KBGEAR $CONFIG_USB $CONFIG_INPUT
comment 'USB Imaging devices'
dep_tristate ' USB Kodak DC-2xx Camera support' CONFIG_USB_DC2XX $CONFIG_USB
diff -urN linux-2.4.19/drivers/usb/Makefile linux-2.4.19-kb/drivers/usb/Makefile
--- linux-2.4.19/drivers/usb/Makefile 2002-08-02 20:39:44.000000000 -0400
+++ linux-2.4.19-kb/drivers/usb/Makefile 2002-10-25 02:04:51.000000000 -0400
@@ -63,6 +63,7 @@
obj-$(CONFIG_USB_HID) += hid.o
obj-$(CONFIG_USB_KBD) += usbkbd.o
obj-$(CONFIG_USB_WACOM) += wacom.o
+obj-$(CONFIG_USB_KBGEAR) += kbpad.o
obj-$(CONFIG_USB_SCANNER) += scanner.o
obj-$(CONFIG_USB_ACM) += acm.o
--- linux-2.4.19/drivers/usb/kbpad.c 1969-12-31 19:00:00.000000000 -0500
+++ linux-2.4.19-kb/drivers/usb/kbpad.c 2002-10-25 02:03:32.000000000 -0400
@@ -0,0 +1,174 @@
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/input.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/usb.h>
+
+/*
+ * Version Information
+ */
+#define DRIVER_VERSION "v0.0.1"
+#define DRIVER_AUTHOR "Josh Myer <josh@joshisanerd.com>"
+#define DRIVER_DESC "KB Gear Jam Studio Tablet Driver"
+
+MODULE_AUTHOR( DRIVER_AUTHOR );
+MODULE_DESCRIPTION( DRIVER_DESC );
+MODULE_LICENSE("GPL");
+
+#define USB_VENDOR_ID_KBTAB 0x84e
+
+struct kbtab {
+ signed char data[8];
+ struct input_dev dev;
+ struct usb_device *usbdev;
+ struct urb irq;
+ int open;
+ int x, y;
+ int button;
+ int pressure;
+};
+
+static void kbtab_irq(struct urb *urb)
+{
+
+ struct kbtab *tab = urb->context;
+ unsigned char *data = tab->data;
+ struct input_dev *dev = &tab->dev;
+
+ if(urb->status)
+ return;
+
+ tab->x = (data[2] << 8) + data[1];
+ tab->y = (data[4] << 8) + data[3];
+
+ tab->pressure = (data[5]);
+
+ /* XXX: don't report unless actual change */
+
+ input_report_abs(dev, ABS_X, tab->x);
+ input_report_abs(dev, ABS_Y, tab->y);
+ input_report_abs(dev, ABS_PRESSURE, tab->pressure);
+
+ input_report_key(dev, BTN_STYLUS, (data[0] & 2));
+ input_report_key(dev, BTN_TOUCH, (data[0] & 1));
+ input_report_key(dev, BTN_LEFT, (tab->pressure > 0x10) ? 1 : 0);
+
+ input_event(dev, EV_MSC, MSC_SERIAL, 0);
+}
+
+struct usb_device_id kbtab_ids[] = {
+ { USB_DEVICE(USB_VENDOR_ID_KBTAB, 0x1001), driver_info : 0 },
+ { }
+};
+
+MODULE_DEVICE_TABLE(usb, kbtab_ids);
+
+static int kbtab_open(struct input_dev *dev)
+{
+ struct kbtab *kbtab = dev->private;
+
+ if(kbtab->open++)
+ return 0;
+
+ kbtab->irq.dev = kbtab->usbdev;
+ if(usb_submit_urb(&kbtab->irq))
+ return -EIO;
+
+ return 0;
+}
+
+static void kbtab_close(struct input_dev *dev)
+{
+ struct kbtab *kbtab = dev->private;
+
+ if(!--kbtab->open)
+ usb_unlink_urb(&kbtab->irq);
+}
+
+static void *kbtab_probe(struct usb_device *dev, unsigned int ifnum, const struct usb_device_id *id)
+{
+ struct usb_endpoint_descriptor *endpoint;
+ struct kbtab *kbtab;
+
+ if(!(kbtab = kmalloc(sizeof(struct kbtab), GFP_KERNEL)))
+ return NULL;
+
+ memset(kbtab, 0, sizeof(struct kbtab));
+
+ kbtab->dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC);
+ kbtab->dev.absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE);
+
+ kbtab->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE);
+ kbtab->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_STYLUS);
+
+ kbtab->dev.mscbit[0] |= BIT(MSC_SERIAL);
+
+ kbtab->dev.absmax[ABS_X] = 0x2000;
+ kbtab->dev.absmax[ABS_Y] = 0x1750;
+
+ kbtab->dev.absmax[ABS_PRESSURE] = 0xff;
+
+ kbtab->dev.absfuzz[ABS_X] = 4;
+ kbtab->dev.absfuzz[ABS_Y] = 4;
+
+ kbtab->dev.private = kbtab;
+
+ kbtab->dev.open = kbtab_open;
+ kbtab->dev.close = kbtab_close;
+
+ kbtab->dev.name = "KB Gear Tablet";
+ kbtab->dev.idbus = BUS_USB;
+
+ kbtab->dev.idvendor = dev->descriptor.idVendor;
+ kbtab->dev.idproduct = dev->descriptor.idProduct;
+ kbtab->dev.idversion = dev->descriptor.bcdDevice;
+ kbtab->usbdev = dev;
+
+
+ endpoint = dev->config[0].interface[ifnum].altsetting[0].endpoint + 0;
+
+ usb_set_idle(dev, dev->config[0].interface[ifnum].altsetting[0].bInterfaceNumber, 0, 0);
+
+ FILL_INT_URB(&kbtab->irq, dev, usb_rcvintpipe(dev, endpoint->bEndpointAddress),
+ kbtab->data, 8, kbtab_irq, kbtab, endpoint->bInterval);
+
+ input_register_device(&kbtab->dev);
+
+ printk(KERN_INFO "input%d: KB Gear Tablet on usb%d:%d.%d\n",
+ kbtab->dev.number, dev->bus->busnum, dev->devnum, ifnum);
+
+ return kbtab;
+
+}
+
+static void kbtab_disconnect(struct usb_device *dev, void *ptr)
+{
+ struct kbtab *kbtab = ptr;
+ usb_unlink_urb(&kbtab->irq);
+ input_unregister_device(&kbtab->dev);
+ kfree(kbtab);
+}
+
+static struct usb_driver kbtab_driver = {
+ name: "kbtab",
+ probe: kbtab_probe,
+ disconnect: kbtab_disconnect,
+ id_table: kbtab_ids,
+};
+
+static int __init kbtab_init(void)
+{
+ usb_register(&kbtab_driver);
+ info(DRIVER_VERSION " " DRIVER_AUTHOR);
+ info(DRIVER_DESC);
+ return 0;
+}
+
+static void __exit kbtab_exit(void)
+{
+ usb_deregister(&kbtab_driver);
+}
+
+module_init(kbtab_init);
+module_exit(kbtab_exit);
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] KB Gear JamStudio USB Tablet
2002-10-25 7:04 [PATCH] KB Gear JamStudio USB Tablet Josh Myer
@ 2002-10-25 7:25 ` Brad Hards
2002-10-25 17:17 ` [linux-usb-devel] " Greg KH
2002-10-25 19:39 ` Stephen Wille Padnos
2 siblings, 0 replies; 5+ messages in thread
From: Brad Hards @ 2002-10-25 7:25 UTC (permalink / raw)
To: Josh Myer, linux-usb-devel, linux-kernel
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Fri, 25 Oct 2002 17:04, Josh Myer wrote:
> Comments highly encouraged, thanks. I'd like to get this driver cleaned up
> a little before submitting, but I'm not quite certain where to start.
My initial thought is you are missing an input_sync() call in your irq()
function.
When you go to 2.5, you also need the new input_init_dev() call.
Maybe a physical path? [ might need 2.5 for that too ]
> The code is based heavily on the wacom driver, and a big "You Rule!" to
> Pavel and anyone else involved with the Input layer. It may be a little
Vojtech is the man.
> convoluted, and slightly non-intuitive, but it's a hell of a lot better
> than the USB HID spec!
Anything looks good if you compare it to a low enough standard :)
- --
http://linux.conf.au. 22-25Jan2003. Perth, Aust. I'm registered. Are you?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE9uPHQW6pHgIdAuOMRAhSxAJ94t+o/pc+XulH6ExISIpqN0lW+rQCgh8l1
kSFzdywZDVJpBN5+EcBUvPw=
=NuuF
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [linux-usb-devel] [PATCH] KB Gear JamStudio USB Tablet
2002-10-25 7:04 [PATCH] KB Gear JamStudio USB Tablet Josh Myer
2002-10-25 7:25 ` Brad Hards
@ 2002-10-25 17:17 ` Greg KH
2002-10-25 19:39 ` Stephen Wille Padnos
2 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2002-10-25 17:17 UTC (permalink / raw)
To: Josh Myer; +Cc: linux-usb-devel, linux-kernel
On Fri, Oct 25, 2002 at 02:04:25AM -0500, Josh Myer wrote:
> +static void kbtab_irq(struct urb *urb)
> +{
> +
> + struct kbtab *tab = urb->context;
> + unsigned char *data = tab->data;
> + struct input_dev *dev = &tab->dev;
> +
> + if(urb->status)
> + return;
Please use tabs instead of spaces. Documentation/CodingStyle has these
rules if you haven't read it yet.
> + FILL_INT_URB(&kbtab->irq, dev, usb_rcvintpipe(dev, endpoint->bEndpointAddress),
> + kbtab->data, 8, kbtab_irq, kbtab, endpoint->bInterval);
Please use usb_fill_int_urb() for all new code, and don't use the
"old-style" macros.
> +static struct usb_driver kbtab_driver = {
> + name: "kbtab",
> + probe: kbtab_probe,
> + disconnect: kbtab_disconnect,
> + id_table: kbtab_ids,
> +};
C99 style initializers are a good idea:
> +static struct usb_driver kbtab_driver = {
> + .name = "kbtab",
> + .probe = kbtab_probe,
> + .disconnect = kbtab_disconnect,
> + .id_table = kbtab_ids,
> +};
Other than those minor things, looks good.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] KB Gear JamStudio USB Tablet
2002-10-25 7:04 [PATCH] KB Gear JamStudio USB Tablet Josh Myer
2002-10-25 7:25 ` Brad Hards
2002-10-25 17:17 ` [linux-usb-devel] " Greg KH
@ 2002-10-25 19:39 ` Stephen Wille Padnos
2002-10-25 16:44 ` Josh Myer
2 siblings, 1 reply; 5+ messages in thread
From: Stephen Wille Padnos @ 2002-10-25 19:39 UTC (permalink / raw)
To: Josh Myer; +Cc: linux-usb-devel, linux-kernel
It might not hurt to change the configure help text so that the correct
module name is displayed :)
- The module will be called wacom.o. If you want to compile it as a
+ The module will be called kbpad.o. If you want to compile it as a
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] KB Gear JamStudio USB Tablet
2002-10-25 19:39 ` Stephen Wille Padnos
@ 2002-10-25 16:44 ` Josh Myer
0 siblings, 0 replies; 5+ messages in thread
From: Josh Myer @ 2002-10-25 16:44 UTC (permalink / raw)
To: Stephen Wille Padnos; +Cc: linux-usb-devel, linux-kernel
You know, that might not hurt. Applied.
I didn't just cut and paste that bit. Really... *innocent whistling*
--
/jbm, but you can call me Josh. Really, you can!
this signature brought to you by the phrase,
"this signature brought to you by the phrase,
'...' and contributions by viewers like you"
7958 1C1C 306A CDF8 4468 3EDE 1F93 F49D 5FA1 49C4
On Fri, 25 Oct 2002, Stephen Wille Padnos wrote:
> It might not hurt to change the configure help text so that the correct
> module name is displayed :)
>
> - The module will be called wacom.o. If you want to compile it as a
> + The module will be called kbpad.o. If you want to compile it as a
>
>
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-10-25 17:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-25 7:04 [PATCH] KB Gear JamStudio USB Tablet Josh Myer
2002-10-25 7:25 ` Brad Hards
2002-10-25 17:17 ` [linux-usb-devel] " Greg KH
2002-10-25 19:39 ` Stephen Wille Padnos
2002-10-25 16:44 ` Josh Myer
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.