2
* USB Wacom Graphire and Wacom Intuos tablet support
4
* Copyright (c) 2000-2004 Vojtech Pavlik <vojtech@ucw.cz>
5
* Copyright (c) 2000 Andreas Bach Aaen <abach@stofanet.dk>
6
* Copyright (c) 2000 Clifford Wolf <clifford@clifford.at>
7
* Copyright (c) 2000 Sam Mosel <sam.mosel@computer.org>
8
* Copyright (c) 2000 James E. Blair <corvus@gnu.org>
9
* Copyright (c) 2000 Daniel Egger <egger@suse.de>
10
* Copyright (c) 2001 Frederic Lepied <flepied@mandrakesoft.com>
11
* Copyright (c) 2004 Panagiotis Issaris <panagiotis.issaris@mech.kuleuven.ac.be>
12
* Copyright (c) 2002-2004 Ping Cheng <pingc@wacom.com>
15
* v0.1 (vp) - Initial release
16
* v0.2 (aba) - Support for all buttons / combinations
17
* v0.3 (vp) - Support for Intuos added
18
* v0.4 (sm) - Support for more Intuos models, menustrip
19
* relative mode, proximity.
20
* v0.5 (vp) - Big cleanup, nifty features removed,
21
* they belong in userspace
22
* v1.8 (vp) - Submit URB only when operating, moved to CVS,
23
* use input_report_key instead of report_btn and
25
* v1.11 (vp) - Add URB ->dev setting for new kernels
26
* v1.11 (jb) - Add support for the 4D Mouse & Lens
27
* v1.12 (de) - Add support for two more inking pen IDs
28
* v1.14 (vp) - Use new USB device id probing scheme.
29
* Fix Wacom Graphire mouse wheel
30
* v1.18 (vp) - Fix mouse wheel direction
32
* v1.20 (fl) - Report tool id for Intuos devices
33
* - Multi tools support
34
* - Corrected Intuos protocol decoding (airbrush, 4D mouse, lens cursor...)
35
* - Add PL models support
36
* - Fix Wacom Graphire mouse wheel again
37
* v1.21 (vp) - Removed protocol descriptions
38
* - Added MISC_SERIAL for tool serial numbers
39
* (gb) - Identify version on module load.
40
* v1.21.1 (fl) - added Graphire2 support
41
* v1.21.2 (fl) - added Intuos2 support
42
* - added all the PL ids
43
* v1.21.3 (fl) - added another eraser id from Neil Okamoto
44
* - added smooth filter for Graphire from Peri Hankey
45
* - added PenPartner support from Olaf van Es
46
* - new tool ids from Ole Martin Bjoerndalen
47
* v1.29 (pc) - Add support for more tablets
48
* - Fix pressure reporting
49
* v1.30 (vp) - Merge 2.4 and 2.5 drivers
50
* - Since 2.5 now has input_sync(), remove MSC_SERIAL abuse
51
* - Cleanups here and there
52
* v1.30.1 (pi) - Added Graphire3 support
53
* v1.40 (pc) - Add support for several new devices, fix eraser reporting, ...
55
* WARNING: THIS IS NOT PART OF THE OFFICIAL KERNEL TREE
56
* THIS IS FOR TESTING PURPOSES
58
* v1.40-2.6.9-pc-0.1 - incorporate with 2.6.9
59
* v1.40-2.6.9-pc-0.2 - linuxwacom-0.6.6
63
* This program is free software; you can redistribute it and/or modify
64
* it under the terms of the GNU General Public License as published by
65
* the Free Software Foundation; either version 2 of the License, or
66
* (at your option) any later version.
69
#include <linux/kernel.h>
70
#include <linux/slab.h>
71
#include <linux/input.h>
72
#include <linux/module.h>
73
#include <linux/init.h>
74
#include <linux/usb.h>
75
#include <asm/unaligned.h>
76
#include <asm/byteorder.h>
81
#define DRIVER_VERSION "v1.40 - 2.6.9-pc-0.2"
82
#define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@ucw.cz>"
83
#define DRIVER_DESC "USB Wacom Graphire and Wacom Intuos tablet driver"
84
#define DRIVER_LICENSE "GPL"
86
MODULE_AUTHOR(DRIVER_AUTHOR);
87
MODULE_DESCRIPTION(DRIVER_DESC);
88
MODULE_LICENSE(DRIVER_LICENSE);
90
#define USB_VENDOR_ID_WACOM 0x056a
92
struct wacom_features {
106
struct input_dev dev;
107
struct usb_device *usbdev;
109
struct wacom_features *features;
116
#define USB_REQ_SET_REPORT 0x09
117
static int usb_set_report(struct usb_interface *intf, unsigned char type,
118
unsigned char id, void *buf, int size)
120
return usb_control_msg(interface_to_usbdev(intf),
121
usb_sndctrlpipe(interface_to_usbdev(intf), 0),
122
USB_REQ_SET_REPORT, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
123
(type << 8) + id, intf->altsetting[0].desc.bInterfaceNumber,
127
static void wacom_pl_irq(struct urb *urb, struct pt_regs *regs)
129
struct wacom *wacom = urb->context;
130
unsigned char *data = wacom->data;
131
struct input_dev *dev = &wacom->dev;
135
switch (urb->status) {
142
/* this urb is terminated, clean up */
143
dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
146
dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status);
151
dbg("wacom_pl_irq: received unknown report #%d", data[0]);
155
prox = data[1] & 0x40;
157
input_regs(dev, regs);
161
pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
162
if (wacom->features->pressure_max > 255)
163
pressure = (pressure << 1) | ((data[4] >> 6) & 1);
164
pressure += (wacom->features->pressure_max + 1) / 2;
167
* if going from out of proximity into proximity select between the eraser
168
* and the pen based on the state of the stylus2 button, choose eraser if
169
* pressed else choose pen. if not a proximity change from out to in, send
170
* an out of proximity for previous tool then a in for new tool.
172
if (!wacom->tool[0]) {
173
/* Going into proximity select tool */
174
wacom->tool[1] = (data[4] & 0x20)? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
177
/* was entered with stylus2 pressed */
178
if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20) ) {
179
/* report out proximity for previous tool */
180
input_report_key(dev, wacom->tool[1], 0);
182
wacom->tool[1] = BTN_TOOL_PEN;
186
if (wacom->tool[1] != BTN_TOOL_RUBBER) {
187
/* Unknown tool selected default to pen tool */
188
wacom->tool[1] = BTN_TOOL_PEN;
190
input_report_key(dev, wacom->tool[1], prox); /* report in proximity for tool */
191
input_report_abs(dev, ABS_X, data[3] | ((__u32)data[2] << 7) | ((__u32)(data[1] & 0x03) << 14));
192
input_report_abs(dev, ABS_Y, data[6] | ((__u32)data[5] << 7) | ((__u32)(data[4] & 0x03) << 14));
193
input_report_abs(dev, ABS_PRESSURE, pressure);
195
input_report_key(dev, BTN_TOUCH, data[4] & 0x08);
196
input_report_key(dev, BTN_STYLUS, data[4] & 0x10);
197
/* Only allow the stylus2 button to be reported for the pen tool. */
198
input_report_key(dev, BTN_STYLUS2, (wacom->tool[1] == BTN_TOOL_PEN) && (data[4] & 0x20));
201
/* report proximity-out of a (valid) tool */
202
if (wacom->tool[1] != BTN_TOOL_RUBBER) {
203
/* Unknown tool selected default to pen tool */
204
wacom->tool[1] = BTN_TOOL_PEN;
206
input_report_key(dev, wacom->tool[1], prox);
209
wacom->tool[0] = prox; /* Save proximity state */
213
retval = usb_submit_urb (urb, GFP_ATOMIC);
215
err ("%s - usb_submit_urb failed with result %d",
216
__FUNCTION__, retval);
219
static void wacom_ptu_irq(struct urb *urb, struct pt_regs *regs)
221
struct wacom *wacom = urb->context;
222
unsigned char *data = wacom->data;
223
struct input_dev *dev = &wacom->dev;
226
switch (urb->status) {
233
/* this urb is terminated, clean up */
234
dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
237
dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status);
243
printk(KERN_INFO "wacom_ptu_irq: received unknown report #%d\n", data[0]);
247
input_regs(dev, regs);
250
input_report_key(dev, BTN_TOOL_RUBBER, data[1] & 0x20);
251
input_report_key(dev, BTN_TOUCH, data[1] & 0x08);
255
input_report_key(dev, BTN_TOOL_PEN, data[1] & 0x20);
256
input_report_key(dev, BTN_TOUCH, data[1] & 0x01);
258
input_report_abs(dev, ABS_X, le16_to_cpu(*(__le16 *) &data[2]));
259
input_report_abs(dev, ABS_Y, le16_to_cpu(*(__le16 *) &data[4]));
260
input_report_abs(dev, ABS_PRESSURE, le16_to_cpu(*(__le16 *) &data[6]));
261
input_report_key(dev, BTN_STYLUS, data[1] & 0x02);
262
input_report_key(dev, BTN_STYLUS2, data[1] & 0x10);
267
retval = usb_submit_urb (urb, GFP_ATOMIC);
269
err ("%s - usb_submit_urb failed with result %d",
270
__FUNCTION__, retval);
273
static void wacom_penpartner_irq(struct urb *urb, struct pt_regs *regs)
275
struct wacom *wacom = urb->context;
276
unsigned char *data = wacom->data;
277
struct input_dev *dev = &wacom->dev;
280
switch (urb->status) {
287
/* this urb is terminated, clean up */
288
dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
291
dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status);
296
printk(KERN_INFO "wacom_penpartner_irq: received unknown report #%d\n", data[0]);
300
input_regs(dev, regs);
301
input_report_key(dev, BTN_TOOL_PEN, 1);
302
input_report_abs(dev, ABS_X, le16_to_cpu(*(__le16 *) &data[1]));
303
input_report_abs(dev, ABS_Y, le16_to_cpu(*(__le16 *) &data[3]));
304
input_report_abs(dev, ABS_PRESSURE, (signed char)data[6] + 127);
305
input_report_key(dev, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
306
input_report_key(dev, BTN_STYLUS, (data[5] & 0x40));
310
retval = usb_submit_urb (urb, GFP_ATOMIC);
312
err ("%s - usb_submit_urb failed with result %d",
313
__FUNCTION__, retval);
316
static void wacom_graphire_irq(struct urb *urb, struct pt_regs *regs)
318
struct wacom *wacom = urb->context;
319
unsigned char *data = wacom->data;
320
struct input_dev *dev = &wacom->dev;
324
switch (urb->status) {
331
/* this urb is terminated, clean up */
332
dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
335
dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status);
340
dbg("wacom_graphire_irq: received unknown report #%d", data[0]);
344
x = le16_to_cpu(*(__le16 *) &data[2]);
345
y = le16_to_cpu(*(__le16 *) &data[4]);
347
input_regs(dev, regs);
349
switch ((data[1] >> 5) & 3) {
352
input_report_key(dev, BTN_TOOL_PEN, data[1] & 0x80);
356
input_report_key(dev, BTN_TOOL_RUBBER, data[1] & 0x80);
359
case 2: /* Mouse with wheel */
360
input_report_key(dev, BTN_MIDDLE, data[1] & 0x04);
361
input_report_rel(dev, REL_WHEEL, (signed char) data[6]);
364
case 3: /* Mouse without wheel */
365
input_report_key(dev, BTN_TOOL_MOUSE, data[7] > 24);
366
input_report_key(dev, BTN_LEFT, data[1] & 0x01);
367
input_report_key(dev, BTN_RIGHT, data[1] & 0x02);
368
input_report_abs(dev, ABS_DISTANCE, data[7]);
370
input_report_abs(dev, ABS_X, x);
371
input_report_abs(dev, ABS_Y, y);
377
if (data[1] & 0x80) {
378
input_report_abs(dev, ABS_X, x);
379
input_report_abs(dev, ABS_Y, y);
382
input_report_abs(dev, ABS_PRESSURE, le16_to_cpu(*(__le16 *) &data[6]));
383
input_report_key(dev, BTN_TOUCH, data[1] & 0x01);
384
input_report_key(dev, BTN_STYLUS, data[1] & 0x02);
385
input_report_key(dev, BTN_STYLUS2, data[1] & 0x04);
390
retval = usb_submit_urb (urb, GFP_ATOMIC);
392
err ("%s - usb_submit_urb failed with result %d",
393
__FUNCTION__, retval);
396
static int wacom_intuos_inout(struct urb *urb)
398
struct wacom *wacom = urb->context;
399
unsigned char *data = wacom->data;
400
struct input_dev *dev = &wacom->dev;
404
idx = data[1] & 0x01;
407
if ((data[1] & 0xfc) == 0xc0)
409
/* serial number of the tool */
410
wacom->serial[idx] = ((__u32)(data[3] & 0x0f) << 28) +
411
((__u32)data[4] << 20) + ((__u32)data[5] << 12) +
412
((__u32)data[6] << 4) + (data[7] >> 4);
414
switch (((__u32)data[2] << 4) | (data[3] >> 4)) {
415
case 0x812: /* Inking pen */
416
case 0x801: /* Intuos3 Inking pen */
418
wacom->tool[idx] = BTN_TOOL_PENCIL;
420
case 0x822: /* Pen */
423
case 0x823: /* Intuos3 Grip Pen */
424
case 0x813: /* Intuos3 Classic Pen */
425
case 0x885: /* Intuos3 Marker Pen */
427
wacom->tool[idx] = BTN_TOOL_PEN;
429
case 0x832: /* Stroke pen */
431
wacom->tool[idx] = BTN_TOOL_BRUSH;
433
case 0x007: /* Mouse 4D and 2D */
436
case 0x017: /* Intuos3 2D Mouse */
437
wacom->tool[idx] = BTN_TOOL_MOUSE;
439
case 0x096: /* Lens cursor */
440
case 0x097: /* Intuos3 Lens cursor */
441
wacom->tool[idx] = BTN_TOOL_LENS;
443
case 0x82a: /* Eraser */
448
case 0x82b: /* Intuos3 Grip Pen Eraser */
449
case 0x81b: /* Intuos3 Classic Pen Eraser */
450
case 0x91b: /* Intuos3 Airbrush Eraser */
451
wacom->tool[idx] = BTN_TOOL_RUBBER;
453
case 0xd12: /* Airbrush */
456
case 0x913: /* Intuos3 Airbrush */
457
wacom->tool[idx] = BTN_TOOL_AIRBRUSH;
459
default: /* Unknown tool */
460
wacom->tool[idx] = BTN_TOOL_PEN;
462
input_report_key(dev, wacom->tool[idx], 1);
463
input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
469
if ((data[1] & 0xfe) == 0x80) {
470
input_report_key(dev, wacom->tool[idx], 0);
471
input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
479
static void wacom_intuos_general(struct urb *urb)
481
struct wacom *wacom = urb->context;
482
unsigned char *data = wacom->data;
483
struct input_dev *dev = &wacom->dev;
486
/* general pen packet */
487
if ((data[1] & 0xb8) == 0xa0)
489
t = ((__u32)data[6] << 2) | ((data[7] >> 6) & 3);
490
input_report_abs(dev, ABS_PRESSURE, t);
491
input_report_abs(dev, ABS_TILT_X,
492
((data[7] << 1) & 0x7e) | (data[8] >> 7));
493
input_report_abs(dev, ABS_TILT_Y, data[8] & 0x7f);
494
input_report_key(dev, BTN_STYLUS, data[1] & 2);
495
input_report_key(dev, BTN_STYLUS2, data[1] & 4);
496
input_report_key(dev, BTN_TOUCH, t > 10);
499
/* airbrush second packet */
500
if ((data[1] & 0xbc) == 0xb4)
502
input_report_abs(dev, ABS_WHEEL,
503
((__u32)data[6] << 2) | ((data[7] >> 6) & 3));
504
input_report_abs(dev, ABS_TILT_X,
505
((data[7] << 1) & 0x7e) | (data[8] >> 7));
506
input_report_abs(dev, ABS_TILT_Y, data[8] & 0x7f);
511
static void wacom_intuos_irq(struct urb *urb, struct pt_regs *regs)
513
struct wacom *wacom = urb->context;
514
unsigned char *data = wacom->data;
515
struct input_dev *dev = &wacom->dev;
520
switch (urb->status) {
527
/* this urb is terminated, clean up */
528
dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
531
dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status);
535
if (data[0] != 2 && data[0] != 5 && data[0] != 6) {
536
dbg("wacom_intuos_irq: received unknown report #%d", data[0]);
540
input_regs(dev, regs);
543
idx = data[1] & 0x01;
545
/* process in/out prox events */
546
if (wacom_intuos_inout(urb)) goto exit;
548
input_report_abs(dev, ABS_X, be16_to_cpu(*(__be16 *) &data[2]));
549
input_report_abs(dev, ABS_Y, be16_to_cpu(*(__be16 *) &data[4]));
550
input_report_abs(dev, ABS_DISTANCE, data[9]);
552
/* process general packets */
553
wacom_intuos_general(urb);
555
if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0) { /* 4D mouse or Lens cursor packets */
557
if (data[1] & 0x02) { /* Rotation packet */
559
t = ((__u32)data[6] << 3) | ((data[7] >> 5) & 7);
560
input_report_abs(dev, ABS_RZ, (data[7] & 0x20) ? ((t - 1) / 2) : -t / 2);
564
if ((data[1] & 0x10) == 0) { /* 4D mouse packets */
566
input_report_key(dev, BTN_LEFT, data[8] & 0x01);
567
input_report_key(dev, BTN_MIDDLE, data[8] & 0x02);
568
input_report_key(dev, BTN_RIGHT, data[8] & 0x04);
570
input_report_key(dev, BTN_SIDE, data[8] & 0x20);
571
input_report_key(dev, BTN_EXTRA, data[8] & 0x10);
572
t = ((__u32)data[6] << 2) | ((data[7] >> 6) & 3);
573
input_report_abs(dev, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
575
if (wacom->tool[idx] == BTN_TOOL_MOUSE) { /* 2D mouse packets */
576
input_report_key(dev, BTN_LEFT, data[8] & 0x04);
577
input_report_key(dev, BTN_MIDDLE, data[8] & 0x08);
578
input_report_key(dev, BTN_RIGHT, data[8] & 0x10);
579
input_report_rel(dev, REL_WHEEL,
580
(-(__u32)(data[8] & 0x01) + (__u32)((data[8] & 0x02) >> 1)));
582
else { /* Lens cursor packets */
583
input_report_key(dev, BTN_LEFT, data[8] & 0x01);
584
input_report_key(dev, BTN_MIDDLE, data[8] & 0x02);
585
input_report_key(dev, BTN_RIGHT, data[8] & 0x04);
586
input_report_key(dev, BTN_SIDE, data[8] & 0x10);
587
input_report_key(dev, BTN_EXTRA, data[8] & 0x08);
593
input_report_key(dev, wacom->tool[idx], 1);
594
input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
598
retval = usb_submit_urb (urb, GFP_ATOMIC);
600
err ("%s - usb_submit_urb failed with result %d",
601
__FUNCTION__, retval);
604
static void wacom_intuos3_irq(struct urb *urb, struct pt_regs *regs)
606
struct wacom *wacom = urb->context;
607
unsigned char *data = wacom->data;
608
struct input_dev *dev = &wacom->dev;
612
switch (urb->status) {
619
/* this urb is terminated, clean up */
620
dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
623
dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status);
627
/* check for valid report */
628
if (data[0] != 2 && data[0] != 5 && data[0] != 12)
630
printk(KERN_INFO "wacom_intuos3_irq: received unknown report #%d\n", data[0]);
634
input_regs(dev, regs);
636
/* tool index is always 0 here since there is no dual input tool */
637
idx = data[1] & 0x01;
639
/* pad packets. Works as a second tool and is alway in prox */
642
/* initiate the pad as a device */
643
if (wacom->tool[1] != BTN_TOOL_FINGER)
645
wacom->tool[1] = BTN_TOOL_FINGER;
646
input_report_key(dev, wacom->tool[1], 1);
648
input_report_key(dev, BTN_0, (data[5] & 0x01));
649
input_report_key(dev, BTN_1, (data[5] & 0x02));
650
input_report_key(dev, BTN_2, (data[5] & 0x04));
651
input_report_key(dev, BTN_3, (data[5] & 0x08));
652
input_report_key(dev, BTN_4, (data[6] & 0x01));
653
input_report_key(dev, BTN_5, (data[6] & 0x02));
654
input_report_key(dev, BTN_6, (data[6] & 0x04));
655
input_report_key(dev, BTN_7, (data[6] & 0x08));
656
input_report_abs(dev, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
657
input_report_abs(dev, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
658
input_event(dev, EV_MSC, MSC_SERIAL, 0xffffffff);
663
/* process in/out prox events */
664
if (wacom_intuos_inout(urb)) goto exit;
666
input_report_abs(dev, ABS_X, ((__u32)data[2] << 9) | ((__u32)data[3] << 1) | ((data[9] >> 1) & 1));
667
input_report_abs(dev, ABS_Y, ((__u32)data[4] << 9) | ((__u32)data[5] << 1) | (data[9] & 1));
668
input_report_abs(dev, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
670
/* process general packets */
671
wacom_intuos_general(urb);
673
if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0)
675
/* Marker pen rotation packet. Reported as wheel due to valuator limitation */
678
t = ((__u32)data[6] << 3) | ((data[7] >> 5) & 7);
679
t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
680
((t-1) / 2 + 450)) : (450 - t / 2) ;
681
input_report_abs(dev, ABS_WHEEL, t);
684
/* 2D mouse packets */
685
if (wacom->tool[idx] == BTN_TOOL_MOUSE)
687
input_report_key(dev, BTN_LEFT, data[8] & 0x04);
688
input_report_key(dev, BTN_MIDDLE, data[8] & 0x08);
689
input_report_key(dev, BTN_RIGHT, data[8] & 0x10);
690
input_report_key(dev, BTN_SIDE, data[8] & 0x40);
691
input_report_key(dev, BTN_EXTRA, data[8] & 0x20);
692
/* mouse wheel is positive when rolled backwards */
693
input_report_rel(dev, REL_WHEEL, ((__u32)((data[8] & 0x02) >> 1)
694
- (__u32)(data[8] & 0x01)));
698
input_report_key(dev, wacom->tool[idx], 1);
699
input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
703
retval = usb_submit_urb (urb, GFP_ATOMIC);
705
err ("%s - usb_submit_urb failed with result %d",
706
__FUNCTION__, retval);
710
static struct wacom_features wacom_features[] = {
711
{ "Wacom Penpartner", 7, 5040, 3780, 255, 32, 0, wacom_penpartner_irq },
712
{ "Wacom Graphire", 8, 10206, 7422, 511, 32, 1, wacom_graphire_irq },
713
{ "Wacom Graphire2 4x5", 8, 10206, 7422, 511, 32, 1, wacom_graphire_irq },
714
{ "Wacom Graphire2 5x7", 8, 13918, 10206, 511, 32, 1, wacom_graphire_irq },
715
{ "Wacom Graphire3 4x5", 8, 10208, 7424, 511, 32, 1, wacom_graphire_irq },
716
{ "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 32, 1, wacom_graphire_irq },
717
{ "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 15, 2, wacom_intuos_irq },
718
{ "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 15, 2, wacom_intuos_irq },
719
{ "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 15, 2, wacom_intuos_irq },
720
{ "Wacom Intuos 12x12", 10, 30480, 31680, 1023, 15, 2, wacom_intuos_irq },
721
{ "Wacom Intuos 12x18", 10, 45720, 31680, 1023, 15, 2, wacom_intuos_irq },
722
{ "Wacom PL400", 8, 5408, 4056, 255, 32, 3, wacom_pl_irq },
723
{ "Wacom PL500", 8, 6144, 4608, 255, 32, 3, wacom_pl_irq },
724
{ "Wacom PL600", 8, 6126, 4604, 255, 32, 3, wacom_pl_irq },
725
{ "Wacom PL600SX", 8, 6260, 5016, 255, 32, 3, wacom_pl_irq },
726
{ "Wacom PL550", 8, 6144, 4608, 511, 32, 3, wacom_pl_irq },
727
{ "Wacom PL800", 8, 7220, 5780, 511, 32, 3, wacom_pl_irq },
728
{ "Wacom Intuos2 4x5", 10, 12700, 10600, 1023, 15, 2, wacom_intuos_irq },
729
{ "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, 2, wacom_intuos_irq },
730
{ "Wacom Intuos2 9x12", 10, 30480, 24060, 1023, 15, 2, wacom_intuos_irq },
731
{ "Wacom Intuos2 12x12", 10, 30480, 31680, 1023, 15, 2, wacom_intuos_irq },
732
{ "Wacom Intuos2 12x18", 10, 45720, 31680, 1023, 15, 2, wacom_intuos_irq },
733
{ "Wacom Volito", 8, 5104, 3712, 511, 32, 1, wacom_graphire_irq },
734
{ "Wacom Cintiq Partner",8, 20480, 15360, 511, 32, 3, wacom_ptu_irq },
735
{ "Wacom Intuos3 4x5", 10, 25400, 20320, 1023, 15, 4, wacom_intuos3_irq },
736
{ "Wacom Intuos3 6x8", 10, 40640, 30480, 1023, 15, 4, wacom_intuos3_irq },
737
{ "Wacom Intuos3 9x12", 10, 60960, 45720, 1023, 15, 4, wacom_intuos3_irq },
738
{ "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, 2, wacom_intuos_irq },
742
static struct usb_device_id wacom_ids[] = {
743
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x00) },
744
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x10) },
745
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x11) },
746
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x12) },
747
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x13) },
748
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x14) },
749
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x20) },
750
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x21) },
751
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x22) },
752
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x23) },
753
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x24) },
754
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x30) },
755
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x31) },
756
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x32) },
757
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x33) },
758
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x34) },
759
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x35) },
760
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x41) },
761
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x42) },
762
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x43) },
763
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x44) },
764
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x45) },
765
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60) },
766
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x03) },
767
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB0) },
768
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB1) },
769
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB2) },
770
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) },
774
MODULE_DEVICE_TABLE(usb, wacom_ids);
776
static int wacom_open(struct input_dev *dev)
778
struct wacom *wacom = dev->private;
783
wacom->irq->dev = wacom->usbdev;
784
if (usb_submit_urb(wacom->irq, GFP_KERNEL)) {
792
static void wacom_close(struct input_dev *dev)
794
struct wacom *wacom = dev->private;
797
usb_unlink_urb(wacom->irq);
800
static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id)
802
struct usb_device *dev = interface_to_usbdev(intf);
803
struct usb_endpoint_descriptor *endpoint;
804
char rep_data[2] = {0x02, 0x02};
808
if (!(wacom = kmalloc(sizeof(struct wacom), GFP_KERNEL)))
810
memset(wacom, 0, sizeof(struct wacom));
812
wacom->data = usb_buffer_alloc(dev, 10, GFP_KERNEL, &wacom->data_dma);
818
wacom->irq = usb_alloc_urb(0, GFP_KERNEL);
820
usb_buffer_free(dev, 10, wacom->data, wacom->data_dma);
825
wacom->features = wacom_features + (id - wacom_ids);
827
wacom->dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS);
828
wacom->dev.absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE);
829
wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH) | BIT(BTN_STYLUS);
831
switch (wacom->features->type) {
833
wacom->dev.evbit[0] |= BIT(EV_REL);
834
wacom->dev.relbit[0] |= BIT(REL_WHEEL);
835
wacom->dev.absbit[0] |= BIT(ABS_DISTANCE);
836
wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE);
837
wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_STYLUS2);
840
case 4: /* new functions for Intuos3 */
841
wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER);
842
wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7);
843
wacom->dev.absbit[0] |= BIT(ABS_RX) | BIT(ABS_RY);
847
wacom->dev.evbit[0] |= BIT(EV_MSC) | BIT(EV_REL);
848
wacom->dev.mscbit[0] |= BIT(MSC_SERIAL);
849
wacom->dev.relbit[0] |= BIT(REL_WHEEL);
850
wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE) | BIT(BTN_SIDE) | BIT(BTN_EXTRA);
851
wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_TOOL_BRUSH)
852
| BIT(BTN_TOOL_PENCIL) | BIT(BTN_TOOL_AIRBRUSH) | BIT(BTN_TOOL_LENS) | BIT(BTN_STYLUS2);
853
wacom->dev.absbit[0] |= BIT(ABS_DISTANCE) | BIT(ABS_WHEEL) | BIT(ABS_TILT_X) | BIT(ABS_TILT_Y) | BIT(ABS_RZ) | BIT(ABS_THROTTLE);
857
wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_STYLUS2) | BIT(BTN_TOOL_RUBBER);
861
wacom->dev.absmax[ABS_X] = wacom->features->x_max;
862
wacom->dev.absmax[ABS_Y] = wacom->features->y_max;
863
wacom->dev.absmax[ABS_PRESSURE] = wacom->features->pressure_max;
864
wacom->dev.absmax[ABS_DISTANCE] = wacom->features->distance_max;
865
wacom->dev.absmax[ABS_TILT_X] = 127;
866
wacom->dev.absmax[ABS_TILT_Y] = 127;
867
wacom->dev.absmax[ABS_WHEEL] = 1023;
869
wacom->dev.absmax[ABS_RX] = 4097;
870
wacom->dev.absmax[ABS_RY] = 4097;
871
wacom->dev.absmin[ABS_RZ] = -900;
872
wacom->dev.absmax[ABS_RZ] = 899;
873
wacom->dev.absmin[ABS_THROTTLE] = -1023;
874
wacom->dev.absmax[ABS_THROTTLE] = 1023;
876
wacom->dev.absfuzz[ABS_X] = 4;
877
wacom->dev.absfuzz[ABS_Y] = 4;
879
wacom->dev.private = wacom;
880
wacom->dev.open = wacom_open;
881
wacom->dev.close = wacom_close;
883
usb_make_path(dev, path, 64);
884
sprintf(wacom->phys, "%s/input0", path);
886
wacom->dev.name = wacom->features->name;
887
wacom->dev.phys = wacom->phys;
888
wacom->dev.id.bustype = BUS_USB;
889
wacom->dev.id.vendor = dev->descriptor.idVendor;
890
wacom->dev.id.product = dev->descriptor.idProduct;
891
wacom->dev.id.version = dev->descriptor.bcdDevice;
892
wacom->dev.dev = &intf->dev;
895
endpoint = &intf->cur_altsetting->endpoint[0].desc;
897
if (wacom->features->pktlen > 10)
900
usb_fill_int_urb(wacom->irq, dev,
901
usb_rcvintpipe(dev, endpoint->bEndpointAddress),
902
wacom->data, wacom->features->pktlen,
903
wacom->features->irq, wacom, endpoint->bInterval);
904
wacom->irq->transfer_dma = wacom->data_dma;
905
wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
907
input_register_device(&wacom->dev);
909
/* ask the tablet to report tablet data */
910
usb_set_report(intf, 3, 2, rep_data, 2);
911
/* repeat once (not sure why the first call often fails) */
912
usb_set_report(intf, 3, 2, rep_data, 2);
914
printk(KERN_INFO "input: %s on %s\n", wacom->features->name, path);
916
usb_set_intfdata(intf, wacom);
921
static void wacom_disconnect(struct usb_interface *intf)
923
struct wacom *wacom = usb_get_intfdata (intf);
925
usb_set_intfdata(intf, NULL);
927
usb_unlink_urb(wacom->irq);
928
input_unregister_device(&wacom->dev);
929
usb_free_urb(wacom->irq);
930
usb_buffer_free(interface_to_usbdev(intf), 10, wacom->data, wacom->data_dma);
935
static struct usb_driver wacom_driver = {
936
.owner = THIS_MODULE,
938
.probe = wacom_probe,
939
.disconnect = wacom_disconnect,
940
.id_table = wacom_ids,
943
static int __init wacom_init(void)
945
int result = usb_register(&wacom_driver);
947
info(DRIVER_VERSION ":" DRIVER_DESC);
951
static void __exit wacom_exit(void)
953
usb_deregister(&wacom_driver);
956
module_init(wacom_init);
957
module_exit(wacom_exit);