patch-2.4.10 linux/drivers/usb/wacom.c
Next file: linux/drivers/video/Config.in
Previous file: linux/drivers/usb/usbvideo.h
Back to the patch index
Back to the overall index
- Lines: 390
- Date:
Mon Sep 17 22:52:35 2001
- Orig file:
v2.4.9/linux/drivers/usb/wacom.c
- Orig date:
Tue Jul 3 17:08:21 2001
diff -u --recursive --new-file v2.4.9/linux/drivers/usb/wacom.c linux/drivers/usb/wacom.c
@@ -1,12 +1,13 @@
/*
- * $Id: wacom.c,v 1.14 2000/11/23 09:34:32 vojtech Exp $
+ * $Id: wacom.c,v 1.22 2001/04/26 11:26:09 vojtech Exp $
*
- * Copyright (c) 2000 Vojtech Pavlik <vojtech@suse.cz>
+ * Copyright (c) 2000-2001 Vojtech Pavlik <vojtech@suse.cz>
* Copyright (c) 2000 Andreas Bach Aaen <abach@stofanet.dk>
* Copyright (c) 2000 Clifford Wolf <clifford@clifford.at>
* Copyright (c) 2000 Sam Mosel <sam.mosel@computer.org>
* Copyright (c) 2000 James E. Blair <corvus@gnu.org>
* Copyright (c) 2000 Daniel Egger <egger@suse.de>
+ * Copyright (c) 2001 Frederic Lepied <flepied@mandrakesoft.com>
*
* USB Wacom Graphire and Wacom Intuos tablet support
*
@@ -28,6 +29,15 @@
* v1.12 (de) - Add support for two more inking pen IDs
* v1.14 (vp) - Use new USB device id probing scheme.
* Fix Wacom Graphire mouse wheel
+ * v1.18 (vp) - Fix mouse wheel direction
+ * Make mouse relative
+ * v1.20 (fl) - Report tool id for Intuos devices
+ * - Multi tools support
+ * - Corrected Intuos protocol decoding (airbrush, 4D mouse, lens cursor...)
+ * - Add PL models support
+ * - Fix Wacom Graphire mouse wheel again
+ * v1.21 (vp) - Removed protocol descriptions
+ * - Added MISC_SERIAL for tool serial numbers
* (gb) - Identify version on module load.
*/
@@ -61,81 +71,13 @@
/*
* Version Information
*/
-#define DRIVER_VERSION "v1.14"
+#define DRIVER_VERSION "v1.21"
#define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@suse.cz>"
#define DRIVER_DESC "USB Wacom Graphire and Wacom Intuos tablet driver"
MODULE_AUTHOR( DRIVER_AUTHOR );
MODULE_DESCRIPTION( DRIVER_DESC );
-
-/*
- * Wacom Graphire packet:
- *
- * byte 0: report ID (2)
- * byte 1: bit7 pointer in range
- * bit5-6 pointer type 0 - pen, 1 - rubber, 2 - mouse
- * bit4 1 ?
- * bit3 0 ?
- * bit2 mouse middle button / pen button2
- * bit1 mouse right button / pen button1
- * bit0 mouse left button / touch
- * byte 2: X low bits
- * byte 3: X high bits
- * byte 4: Y low bits
- * byte 5: Y high bits
- * byte 6: pen pressure low bits / mouse wheel
- * byte 7: pen presure high bits / mouse distance
- *
- * There are also two single-byte feature reports (2 and 3).
- *
- * Wacom Intuos status packet:
- *
- * byte 0: report ID (2)
- * byte 1: bit7 1 - sync bit
- * bit6 pointer in range
- * bit5 pointer type report
- * bit4 0 ?
- * bit3 mouse packet type
- * bit2 pen button2
- * bit1 pen button1
- * bit0 0 ?
- * byte 2: X high bits
- * byte 3: X low bits
- * byte 4: Y high bits
- * byte 5: Y low bits
- *
- * Pen packet:
- *
- * byte 6: bits 0-7: pressure (bits 2-9)
- * byte 7: bits 6-7: pressure (bits 0-1)
- * byte 7: bits 0-5: X tilt (bits 1-6)
- * byte 8: bit 7: X tilt (bit 0)
- * byte 8: bits 0-6: Y tilt (bits 0-6)
- * byte 9: bits 4-7: distance
- *
- * Mouse packet type 0:
- *
- * byte 6: bits 0-7: wheel (bits 2-9)
- * byte 7: bits 6-7: wheel (bits 0-1)
- * byte 7: bits 0-5: 0
- * byte 8: bits 6-7: 0
- * byte 8: bit 5: left extra button
- * byte 8: bit 4: right extra button
- * byte 8: bit 3: wheel (sign)
- * byte 8: bit 2: right button
- * byte 8: bit 1: middle button
- * byte 8: bit 0: left button
- * byte 9: bits 4-7: distance
- *
- * Mouse packet type 1:
- *
- * byte 6: bits 0-7: rotation (bits 2-9)
- * byte 7: bits 6-7: rotation (bits 0-1)
- * byte 7: bit 5: rotation (sign)
- * byte 7: bits 0-4: 0
- * byte 8: bits 0-7: 0
- * byte 9: bits 4-7: distance
- */
+MODULE_LICENSE("GPL");
#define USB_VENDOR_ID_WACOM 0x056a
@@ -160,25 +102,56 @@
struct usb_device *usbdev;
struct urb irq;
struct wacom_features *features;
- int tool;
+ int tool[2];
int open;
+ int x, y;
+ __u32 serial[2];
};
-static void wacom_graphire_irq(struct urb *urb)
+static void wacom_pl_irq(struct urb *urb)
{
struct wacom *wacom = urb->context;
unsigned char *data = wacom->data;
struct input_dev *dev = &wacom->dev;
+ int prox;
if (urb->status) return;
if (data[0] != 2)
dbg("received unknown report #%d", data[0]);
- if ( data[1] & 0x80 ) {
- input_report_abs(dev, ABS_X, data[2] | ((__u32)data[3] << 8));
- input_report_abs(dev, ABS_Y, data[4] | ((__u32)data[5] << 8));
+ prox = data[1] & 0x20;
+
+ input_report_key(dev, BTN_TOOL_PEN, prox);
+
+ if (prox) {
+ int pressure = (data[4] & 0x04) >> 2 | ((__u32)(data[7] & 0x7f) << 1);
+
+ input_report_abs(dev, ABS_X, data[3] | ((__u32)data[2] << 8) | ((__u32)(data[1] & 0x03) << 16));
+ input_report_abs(dev, ABS_Y, data[6] | ((__u32)data[5] << 8) | ((__u32)(data[4] & 0x03) << 8));
+ input_report_abs(dev, ABS_PRESSURE, (data[7] & 0x80) ? (255 - pressure) : (pressure + 255));
+ input_report_key(dev, BTN_TOUCH, data[4] & 0x08);
+ input_report_key(dev, BTN_STYLUS, data[4] & 0x10);
+ input_report_key(dev, BTN_STYLUS2, data[4] & 0x20);
}
+
+ input_event(dev, EV_MSC, MSC_SERIAL, 0);
+}
+
+static void wacom_graphire_irq(struct urb *urb)
+{
+ struct wacom *wacom = urb->context;
+ unsigned char *data = wacom->data;
+ struct input_dev *dev = &wacom->dev;
+ int x, y;
+
+ if (urb->status) return;
+
+ if (data[0] != 2)
+ dbg("received unknown report #%d", data[0]);
+
+ x = data[2] | ((__u32)data[3] << 8);
+ y = data[4] | ((__u32)data[5] << 8);
switch ((data[1] >> 5) & 3) {
@@ -197,14 +170,25 @@
input_report_key(dev, BTN_MIDDLE, data[1] & 0x04);
input_report_abs(dev, ABS_DISTANCE, data[7]);
input_report_rel(dev, REL_WHEEL, (signed char) data[6]);
+
+ input_report_abs(dev, ABS_X, x);
+ input_report_abs(dev, ABS_Y, y);
+
+ input_event(dev, EV_MSC, MSC_SERIAL, data[1] & 0x01);
return;
}
- input_report_abs(dev, ABS_PRESSURE, data[6] | ((__u32)data[7] << 8));
+ if (data[1] & 0x80) {
+ input_report_abs(dev, ABS_X, wacom->x = x);
+ input_report_abs(dev, ABS_Y, wacom->y = y);
+ }
+ input_report_abs(dev, ABS_PRESSURE, data[6] | ((__u32)data[7] << 8));
input_report_key(dev, BTN_TOUCH, data[1] & 0x01);
input_report_key(dev, BTN_STYLUS, data[1] & 0x02);
input_report_key(dev, BTN_STYLUS2, data[1] & 0x04);
+
+ input_event(dev, EV_MSC, MSC_SERIAL, data[1] & 0x01);
}
static void wacom_intuos_irq(struct urb *urb)
@@ -213,35 +197,47 @@
unsigned char *data = wacom->data;
struct input_dev *dev = &wacom->dev;
unsigned int t;
+ int idx;
if (urb->status) return;
if (data[0] != 2)
dbg("received unknown report #%d", data[0]);
- if (((data[1] >> 5) & 0x3) == 0x2) { /* Enter report */
+ /* tool number */
+ idx = data[1] & 0x01;
+
+ if ((data[1] & 0xfc) == 0xc0) { /* Enter report */
+
+ wacom->serial[idx] = ((__u32)(data[3] & 0x0f) << 4) + /* serial number of the tool */
+ ((__u32)data[4] << 16) + ((__u32)data[5] << 12) +
+ ((__u32)data[6] << 4) + (data[7] >> 4);
switch (((__u32)data[2] << 4) | (data[3] >> 4)) {
case 0x832:
- case 0x812:
- case 0x012: wacom->tool = BTN_TOOL_PENCIL; break; /* Inking pen */
+ case 0x012: wacom->tool[idx] = BTN_TOOL_PENCIL; break; /* Inking pen */
case 0x822:
- case 0x022: wacom->tool = BTN_TOOL_PEN; break; /* Pen */
- case 0x032: wacom->tool = BTN_TOOL_BRUSH; break; /* Stroke pen */
- case 0x094: wacom->tool = BTN_TOOL_MOUSE; break; /* Mouse 4D */
- case 0x096: wacom->tool = BTN_TOOL_LENS; break; /* Lens cursor */
+ case 0x022: wacom->tool[idx] = BTN_TOOL_PEN; break; /* Pen */
+ case 0x812:
+ case 0x032: wacom->tool[idx] = BTN_TOOL_BRUSH; break; /* Stroke pen */
+ case 0x09c:
+ case 0x094: wacom->tool[idx] = BTN_TOOL_MOUSE; break; /* Mouse 4D */
+ case 0x096: wacom->tool[idx] = BTN_TOOL_LENS; break; /* Lens cursor */
case 0x82a:
- case 0x0fa: wacom->tool = BTN_TOOL_RUBBER; break; /* Eraser */
- case 0x112: wacom->tool = BTN_TOOL_AIRBRUSH; break; /* Airbrush */
- default: wacom->tool = BTN_TOOL_PEN; break; /* Unknown tool */
+ case 0x91a:
+ case 0x0fa: wacom->tool[idx] = BTN_TOOL_RUBBER; break; /* Eraser */
+ case 0x112: wacom->tool[idx] = BTN_TOOL_AIRBRUSH; break; /* Airbrush */
+ default: wacom->tool[idx] = BTN_TOOL_PEN; break; /* Unknown tool */
}
- input_report_key(dev, wacom->tool, 1);
+
+ input_report_key(dev, wacom->tool[idx], 1);
+ input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
return;
}
- if ((data[1] | data[2] | data[3] | data[4] | data[5] |
- data[6] | data[7] | data[8] | data[9]) == 0x80) { /* Exit report */
- input_report_key(dev, wacom->tool, 0);
+ if ((data[1] & 0xfe) == 0x80) { /* Exit report */
+ input_report_key(dev, wacom->tool[idx], 0);
+ input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
return;
}
@@ -249,42 +245,52 @@
input_report_abs(dev, ABS_Y, ((__u32)data[4] << 8) | data[5]);
input_report_abs(dev, ABS_DISTANCE, data[9] >> 4);
- switch (wacom->tool) {
+ if ((data[1] & 0xb8) == 0xa0) { /* general pen packet */
+ input_report_abs(dev, ABS_PRESSURE, t = ((__u32)data[6] << 2) | ((data[7] >> 6) & 3));
+ input_report_abs(dev, ABS_TILT_X, ((data[7] << 1) & 0x7e) | (data[8] >> 7));
+ input_report_abs(dev, ABS_TILT_Y, data[8] & 0x7f);
+ input_report_key(dev, BTN_STYLUS, data[1] & 2);
+ input_report_key(dev, BTN_STYLUS2, data[1] & 4);
+ input_report_key(dev, BTN_TOUCH, t > 10);
+ }
- case BTN_TOOL_PENCIL:
- case BTN_TOOL_PEN:
- case BTN_TOOL_BRUSH:
- case BTN_TOOL_RUBBER:
- case BTN_TOOL_AIRBRUSH:
-
- input_report_abs(dev, ABS_PRESSURE, t = ((__u32)data[6] << 2) | ((data[7] >> 6) & 3));
- input_report_abs(dev, ABS_TILT_X, ((data[7] << 1) & 0x7e) | (data[8] >> 7));
- input_report_abs(dev, ABS_TILT_Y, data[8] & 0x7f);
- input_report_key(dev, BTN_STYLUS, data[1] & 2);
- input_report_key(dev, BTN_STYLUS2, data[1] & 4);
- input_report_key(dev, BTN_TOUCH, t > 10);
- break;
+ if ((data[1] & 0xbc) == 0xb4) { /* airbrush second packet */
+ input_report_abs(dev, ABS_WHEEL, ((__u32)data[6] << 2) | ((data[7] >> 6) & 3));
+ input_report_abs(dev, ABS_TILT_X, ((data[7] << 1) & 0x7e) | (data[8] >> 7));
+ input_report_abs(dev, ABS_TILT_Y, data[8] & 0x7f);
+ }
+
+ if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0) { /* 4D mouse or Lens cursor packets */
- case BTN_TOOL_MOUSE:
- case BTN_TOOL_LENS:
+ if (data[1] & 0x02) { /* Rotation packet */
- if (data[1] & 0x02) { /* Rotation packet */
- input_report_abs(dev, ABS_RZ, (data[7] & 0x20) ?
- ((__u32)data[6] << 2) | ((data[7] >> 6) & 3):
- (-(((__u32)data[6] << 2) | ((data[7] >> 6) & 3))) - 1);
- break;
- }
+ input_report_abs(dev, ABS_RZ, (data[7] & 0x20) ?
+ ((__u32)data[6] << 2) | ((data[7] >> 6) & 3):
+ (-(((__u32)data[6] << 2) | ((data[7] >> 6) & 3))) - 1);
+
+ } else {
input_report_key(dev, BTN_LEFT, data[8] & 0x01);
input_report_key(dev, BTN_MIDDLE, data[8] & 0x02);
input_report_key(dev, BTN_RIGHT, data[8] & 0x04);
- input_report_key(dev, BTN_SIDE, data[8] & 0x20);
- input_report_key(dev, BTN_EXTRA, data[8] & 0x10);
- input_report_abs(dev, ABS_THROTTLE, (data[8] & 0x08) ?
- ((__u32)data[6] << 2) | ((data[7] >> 6) & 3) :
- -((__u32)data[6] << 2) | ((data[7] >> 6) & 3));
- break;
- }
+
+ if ((data[1] & 0x10) == 0) { /* 4D mouse packets */
+
+ input_report_key(dev, BTN_SIDE, data[8] & 0x20);
+ input_report_key(dev, BTN_EXTRA, data[8] & 0x10);
+ input_report_abs(dev, ABS_THROTTLE, (data[8] & 0x08) ?
+ ((__u32)data[6] << 2) | ((data[7] >> 6) & 3) :
+ -((__u32)data[6] << 2) | ((data[7] >> 6) & 3));
+
+ } else { /* Lens cursor packets */
+
+ input_report_key(dev, BTN_SIDE, data[8] & 0x10);
+ input_report_key(dev, BTN_EXTRA, data[8] & 0x08);
+ }
+ }
+ }
+
+ input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
}
#define WACOM_INTUOS_TOOLS (BIT(BTN_TOOL_BRUSH) | BIT(BTN_TOOL_PENCIL) | BIT(BTN_TOOL_AIRBRUSH) | BIT(BTN_TOOL_LENS))
@@ -304,6 +310,8 @@
0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
{ "Wacom Intuos 12x18", 10, 47720, 30480, 1023, 15, wacom_intuos_irq,
0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
+ { "Wacom PL500", 8, 12328, 9256, 511, 32, wacom_pl_irq,
+ 0, 0, 0, 0 },
{ NULL , 0 }
};
@@ -314,6 +322,7 @@
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x22), driver_info: 3 },
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x23), driver_info: 4 },
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x24), driver_info: 5 },
+ { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x31), driver_info: 6 },
{ }
};
@@ -351,12 +360,13 @@
wacom->features = wacom_features + id->driver_info;
- wacom->dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | wacom->features->evbit;
- wacom->dev.absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE) | BIT(ABS_DISTANCE) | wacom->features->absbit;
+ wacom->dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC) | wacom->features->evbit;
+ wacom->dev.absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE) | BIT(ABS_DISTANCE) | BIT(ABS_WHEEL) | wacom->features->absbit;
wacom->dev.relbit[0] |= wacom->features->relbit;
wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE) | wacom->features->btnbit;
wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) |
BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2) | wacom->features->digibit;
+ wacom->dev.mscbit[0] |= BIT(MSC_SERIAL);
wacom->dev.absmax[ABS_X] = wacom->features->x_max;
wacom->dev.absmax[ABS_Y] = wacom->features->y_max;
@@ -364,6 +374,7 @@
wacom->dev.absmax[ABS_DISTANCE] = wacom->features->distance_max;
wacom->dev.absmax[ABS_TILT_X] = 127;
wacom->dev.absmax[ABS_TILT_Y] = 127;
+ wacom->dev.absmax[ABS_WHEEL] = 1023;
wacom->dev.absmin[ABS_RZ] = -900;
wacom->dev.absmax[ABS_RZ] = 899;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)