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-2005 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, ...
54 * v1.43 (pc) - Added support for Cintiq 21UX
55 - Fixed a Graphire bug
56 - Merged wacom_intuos3_irq into wacom_intuos_irq
60 * This program is free software; you can redistribute it and/or modify
61 * it under the terms of the GNU General Public License as published by
62 * the Free Software Foundation; either version 2 of the License, or
63 * (at your option) any later version.
66 #include <linux/kernel.h>
67 #include <linux/slab.h>
68 #include <linux/input.h>
69 #include <linux/module.h>
70 #include <linux/init.h>
71 #include <linux/usb.h>
72 #include <linux/usb_input.h>
73 #include <asm/unaligned.h>
74 #include <asm/byteorder.h>
79 #define DRIVER_VERSION "v1.43"
80 #define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@ucw.cz>"
81 #define DRIVER_DESC "USB Wacom Graphire and Wacom Intuos tablet driver"
82 #define DRIVER_LICENSE "GPL"
84 MODULE_AUTHOR(DRIVER_AUTHOR
);
85 MODULE_DESCRIPTION(DRIVER_DESC
);
86 MODULE_LICENSE(DRIVER_LICENSE
);
88 #define USB_VENDOR_ID_WACOM 0x056a
100 struct wacom_features
{
114 struct input_dev dev
;
115 struct usb_device
*usbdev
;
117 struct wacom_features
*features
;
123 #define USB_REQ_SET_REPORT 0x09
124 static int usb_set_report(struct usb_interface
*intf
, unsigned char type
,
125 unsigned char id
, void *buf
, int size
)
127 return usb_control_msg(interface_to_usbdev(intf
),
128 usb_sndctrlpipe(interface_to_usbdev(intf
), 0),
129 USB_REQ_SET_REPORT
, USB_TYPE_CLASS
| USB_RECIP_INTERFACE
,
130 (type
<< 8) + id
, intf
->altsetting
[0].desc
.bInterfaceNumber
,
134 static void wacom_pl_irq(struct urb
*urb
, struct pt_regs
*regs
)
136 struct wacom
*wacom
= urb
->context
;
137 unsigned char *data
= wacom
->data
;
138 struct input_dev
*dev
= &wacom
->dev
;
142 switch (urb
->status
) {
149 /* this urb is terminated, clean up */
150 dbg("%s - urb shutting down with status: %d", __FUNCTION__
, urb
->status
);
153 dbg("%s - nonzero urb status received: %d", __FUNCTION__
, urb
->status
);
158 dbg("wacom_pl_irq: received unknown report #%d", data
[0]);
162 prox
= data
[1] & 0x40;
164 input_regs(dev
, regs
);
168 pressure
= (signed char)((data
[7] << 1) | ((data
[4] >> 2) & 1));
169 if (wacom
->features
->pressure_max
> 255)
170 pressure
= (pressure
<< 1) | ((data
[4] >> 6) & 1);
171 pressure
+= (wacom
->features
->pressure_max
+ 1) / 2;
174 * if going from out of proximity into proximity select between the eraser
175 * and the pen based on the state of the stylus2 button, choose eraser if
176 * pressed else choose pen. if not a proximity change from out to in, send
177 * an out of proximity for previous tool then a in for new tool.
179 if (!wacom
->tool
[0]) {
180 /* Going into proximity select tool */
181 wacom
->tool
[1] = (data
[4] & 0x20)? BTN_TOOL_RUBBER
: BTN_TOOL_PEN
;
183 /* was entered with stylus2 pressed */
184 if (wacom
->tool
[1] == BTN_TOOL_RUBBER
&& !(data
[4] & 0x20) ) {
185 /* report out proximity for previous tool */
186 input_report_key(dev
, wacom
->tool
[1], 0);
188 wacom
->tool
[1] = BTN_TOOL_PEN
;
192 if (wacom
->tool
[1] != BTN_TOOL_RUBBER
) {
193 /* Unknown tool selected default to pen tool */
194 wacom
->tool
[1] = BTN_TOOL_PEN
;
196 input_report_key(dev
, wacom
->tool
[1], prox
); /* report in proximity for tool */
197 input_report_abs(dev
, ABS_X
, data
[3] | (data
[2] << 7) | ((data
[1] & 0x03) << 14));
198 input_report_abs(dev
, ABS_Y
, data
[6] | (data
[5] << 7) | ((data
[4] & 0x03) << 14));
199 input_report_abs(dev
, ABS_PRESSURE
, pressure
);
201 input_report_key(dev
, BTN_TOUCH
, data
[4] & 0x08);
202 input_report_key(dev
, BTN_STYLUS
, data
[4] & 0x10);
203 /* Only allow the stylus2 button to be reported for the pen tool. */
204 input_report_key(dev
, BTN_STYLUS2
, (wacom
->tool
[1] == BTN_TOOL_PEN
) && (data
[4] & 0x20));
206 /* report proximity-out of a (valid) tool */
207 if (wacom
->tool
[1] != BTN_TOOL_RUBBER
) {
208 /* Unknown tool selected default to pen tool */
209 wacom
->tool
[1] = BTN_TOOL_PEN
;
211 input_report_key(dev
, wacom
->tool
[1], prox
);
214 wacom
->tool
[0] = prox
; /* Save proximity state */
218 retval
= usb_submit_urb (urb
, GFP_ATOMIC
);
220 err ("%s - usb_submit_urb failed with result %d",
221 __FUNCTION__
, retval
);
224 static void wacom_ptu_irq(struct urb
*urb
, struct pt_regs
*regs
)
226 struct wacom
*wacom
= urb
->context
;
227 unsigned char *data
= wacom
->data
;
228 struct input_dev
*dev
= &wacom
->dev
;
231 switch (urb
->status
) {
238 /* this urb is terminated, clean up */
239 dbg("%s - urb shutting down with status: %d", __FUNCTION__
, urb
->status
);
242 dbg("%s - nonzero urb status received: %d", __FUNCTION__
, urb
->status
);
247 printk(KERN_INFO
"wacom_ptu_irq: received unknown report #%d\n", data
[0]);
251 input_regs(dev
, regs
);
252 if (data
[1] & 0x04) {
253 input_report_key(dev
, BTN_TOOL_RUBBER
, data
[1] & 0x20);
254 input_report_key(dev
, BTN_TOUCH
, data
[1] & 0x08);
256 input_report_key(dev
, BTN_TOOL_PEN
, data
[1] & 0x20);
257 input_report_key(dev
, BTN_TOUCH
, data
[1] & 0x01);
259 input_report_abs(dev
, ABS_X
, le16_to_cpu(*(__le16
*) &data
[2]));
260 input_report_abs(dev
, ABS_Y
, le16_to_cpu(*(__le16
*) &data
[4]));
261 input_report_abs(dev
, ABS_PRESSURE
, le16_to_cpu(*(__le16
*) &data
[6]));
262 input_report_key(dev
, BTN_STYLUS
, data
[1] & 0x02);
263 input_report_key(dev
, BTN_STYLUS2
, data
[1] & 0x10);
268 retval
= usb_submit_urb (urb
, GFP_ATOMIC
);
270 err ("%s - usb_submit_urb failed with result %d",
271 __FUNCTION__
, retval
);
274 static void wacom_penpartner_irq(struct urb
*urb
, struct pt_regs
*regs
)
276 struct wacom
*wacom
= urb
->context
;
277 unsigned char *data
= wacom
->data
;
278 struct input_dev
*dev
= &wacom
->dev
;
281 switch (urb
->status
) {
288 /* this urb is terminated, clean up */
289 dbg("%s - urb shutting down with status: %d", __FUNCTION__
, urb
->status
);
292 dbg("%s - nonzero urb status received: %d", __FUNCTION__
, urb
->status
);
297 printk(KERN_INFO
"wacom_penpartner_irq: received unknown report #%d\n", data
[0]);
301 input_regs(dev
, regs
);
302 input_report_key(dev
, BTN_TOOL_PEN
, 1);
303 input_report_abs(dev
, ABS_X
, le16_to_cpu(*(__le16
*) &data
[1]));
304 input_report_abs(dev
, ABS_Y
, le16_to_cpu(*(__le16
*) &data
[3]));
305 input_report_abs(dev
, ABS_PRESSURE
, (signed char)data
[6] + 127);
306 input_report_key(dev
, BTN_TOUCH
, ((signed char)data
[6] > -80) && !(data
[5] & 0x20));
307 input_report_key(dev
, BTN_STYLUS
, (data
[5] & 0x40));
311 retval
= usb_submit_urb (urb
, GFP_ATOMIC
);
313 err ("%s - usb_submit_urb failed with result %d",
314 __FUNCTION__
, retval
);
317 static void wacom_graphire_irq(struct urb
*urb
, struct pt_regs
*regs
)
319 struct wacom
*wacom
= urb
->context
;
320 unsigned char *data
= wacom
->data
;
321 struct input_dev
*dev
= &wacom
->dev
;
325 switch (urb
->status
) {
332 /* this urb is terminated, clean up */
333 dbg("%s - urb shutting down with status: %d", __FUNCTION__
, urb
->status
);
336 dbg("%s - nonzero urb status received: %d", __FUNCTION__
, urb
->status
);
341 dbg("wacom_graphire_irq: received unknown report #%d", data
[0]);
345 input_regs(dev
, regs
);
347 if (data
[1] & 0x10) { /* in prox */
349 switch ((data
[1] >> 5) & 3) {
352 wacom
->tool
[0] = BTN_TOOL_PEN
;
356 wacom
->tool
[0] = BTN_TOOL_RUBBER
;
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 wacom
->tool
[0] = BTN_TOOL_MOUSE
;
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]);
373 if (data
[1] & 0x90) {
374 x
= le16_to_cpu(*(__le16
*) &data
[2]);
375 y
= le16_to_cpu(*(__le16
*) &data
[4]);
376 input_report_abs(dev
, ABS_X
, x
);
377 input_report_abs(dev
, ABS_Y
, y
);
378 if (wacom
->tool
[0] != BTN_TOOL_MOUSE
) {
379 input_report_abs(dev
, ABS_PRESSURE
, le16_to_cpu(*(__le16
*) &data
[6]));
380 input_report_key(dev
, BTN_TOUCH
, data
[1] & 0x01);
381 input_report_key(dev
, BTN_STYLUS
, data
[1] & 0x02);
382 input_report_key(dev
, BTN_STYLUS2
, data
[1] & 0x04);
386 input_report_key(dev
, wacom
->tool
[0], data
[1] & 0x10);
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) {
408 /* serial number of the tool */
409 wacom
->serial
[idx
] = ((data
[3] & 0x0f) << 28) +
410 (data
[4] << 20) + (data
[5] << 12) +
411 (data
[6] << 4) + (data
[7] >> 4);
413 switch ((data
[2] << 4) | (data
[3] >> 4)) {
414 case 0x812: /* Inking pen */
415 case 0x801: /* Intuos3 Inking pen */
417 wacom
->tool
[idx
] = BTN_TOOL_PENCIL
;
419 case 0x822: /* Pen */
422 case 0x823: /* Intuos3 Grip Pen */
423 case 0x813: /* Intuos3 Classic Pen */
424 case 0x885: /* Intuos3 Marker Pen */
426 wacom
->tool
[idx
] = BTN_TOOL_PEN
;
428 case 0x832: /* Stroke pen */
430 wacom
->tool
[idx
] = BTN_TOOL_BRUSH
;
432 case 0x007: /* Mouse 4D and 2D */
435 case 0x017: /* Intuos3 2D Mouse */
436 wacom
->tool
[idx
] = BTN_TOOL_MOUSE
;
438 case 0x096: /* Lens cursor */
439 case 0x097: /* Intuos3 Lens cursor */
440 wacom
->tool
[idx
] = BTN_TOOL_LENS
;
442 case 0x82a: /* Eraser */
447 case 0x82b: /* Intuos3 Grip Pen Eraser */
448 case 0x81b: /* Intuos3 Classic Pen Eraser */
449 case 0x91b: /* Intuos3 Airbrush Eraser */
450 wacom
->tool
[idx
] = BTN_TOOL_RUBBER
;
455 case 0x913: /* Intuos3 Airbrush */
456 wacom
->tool
[idx
] = BTN_TOOL_AIRBRUSH
;
458 default: /* Unknown tool */
459 wacom
->tool
[idx
] = BTN_TOOL_PEN
;
461 input_report_key(dev
, wacom
->tool
[idx
], 1);
462 input_event(dev
, EV_MSC
, MSC_SERIAL
, wacom
->serial
[idx
]);
468 if ((data
[1] & 0xfe) == 0x80) {
469 input_report_key(dev
, wacom
->tool
[idx
], 0);
470 input_event(dev
, EV_MSC
, MSC_SERIAL
, wacom
->serial
[idx
]);
478 static void wacom_intuos_general(struct urb
*urb
)
480 struct wacom
*wacom
= urb
->context
;
481 unsigned char *data
= wacom
->data
;
482 struct input_dev
*dev
= &wacom
->dev
;
485 /* general pen packet */
486 if ((data
[1] & 0xb8) == 0xa0) {
487 t
= (data
[6] << 2) | ((data
[7] >> 6) & 3);
488 input_report_abs(dev
, ABS_PRESSURE
, t
);
489 input_report_abs(dev
, ABS_TILT_X
,
490 ((data
[7] << 1) & 0x7e) | (data
[8] >> 7));
491 input_report_abs(dev
, ABS_TILT_Y
, data
[8] & 0x7f);
492 input_report_key(dev
, BTN_STYLUS
, data
[1] & 2);
493 input_report_key(dev
, BTN_STYLUS2
, data
[1] & 4);
494 input_report_key(dev
, BTN_TOUCH
, t
> 10);
497 /* airbrush second packet */
498 if ((data
[1] & 0xbc) == 0xb4) {
499 input_report_abs(dev
, ABS_WHEEL
,
500 (data
[6] << 2) | ((data
[7] >> 6) & 3));
501 input_report_abs(dev
, ABS_TILT_X
,
502 ((data
[7] << 1) & 0x7e) | (data
[8] >> 7));
503 input_report_abs(dev
, ABS_TILT_Y
, data
[8] & 0x7f);
508 static void wacom_intuos_irq(struct urb
*urb
, struct pt_regs
*regs
)
510 struct wacom
*wacom
= urb
->context
;
511 unsigned char *data
= wacom
->data
;
512 struct input_dev
*dev
= &wacom
->dev
;
517 switch (urb
->status
) {
524 /* this urb is terminated, clean up */
525 dbg("%s - urb shutting down with status: %d", __FUNCTION__
, urb
->status
);
528 dbg("%s - nonzero urb status received: %d", __FUNCTION__
, urb
->status
);
532 if (data
[0] != 2 && data
[0] != 5 && data
[0] != 6 && data
[0] != 12) {
533 dbg("wacom_intuos_irq: received unknown report #%d", data
[0]);
537 input_regs(dev
, regs
);
540 idx
= data
[1] & 0x01;
542 /* pad packets. Works as a second tool and is always in prox */
544 /* initiate the pad as a device */
545 if (wacom
->tool
[1] != BTN_TOOL_FINGER
) {
546 wacom
->tool
[1] = BTN_TOOL_FINGER
;
547 input_report_key(dev
, wacom
->tool
[1], 1);
549 input_report_key(dev
, BTN_0
, (data
[5] & 0x01));
550 input_report_key(dev
, BTN_1
, (data
[5] & 0x02));
551 input_report_key(dev
, BTN_2
, (data
[5] & 0x04));
552 input_report_key(dev
, BTN_3
, (data
[5] & 0x08));
553 input_report_key(dev
, BTN_4
, (data
[6] & 0x01));
554 input_report_key(dev
, BTN_5
, (data
[6] & 0x02));
555 input_report_key(dev
, BTN_6
, (data
[6] & 0x04));
556 input_report_key(dev
, BTN_7
, (data
[6] & 0x08));
557 input_report_abs(dev
, ABS_RX
, ((data
[1] & 0x1f) << 8) | data
[2]);
558 input_report_abs(dev
, ABS_RY
, ((data
[3] & 0x1f) << 8) | data
[4]);
559 input_event(dev
, EV_MSC
, MSC_SERIAL
, 0xffffffff);
564 /* process in/out prox events */
565 if (wacom_intuos_inout(urb
))
568 /* Cintiq doesn't send data when RDY bit isn't set */
569 if ((wacom
->features
->type
== CINTIQ
) && !(data
[1] & 0x40))
572 if (wacom
->features
->type
>= INTUOS3
) {
573 input_report_abs(dev
, ABS_X
, (data
[2] << 9) | (data
[3] << 1) | ((data
[9] >> 1) & 1));
574 input_report_abs(dev
, ABS_Y
, (data
[4] << 9) | (data
[5] << 1) | (data
[9] & 1));
575 input_report_abs(dev
, ABS_DISTANCE
, ((data
[9] >> 2) & 0x3f));
577 input_report_abs(dev
, ABS_X
, be16_to_cpu(*(__be16
*) &data
[2]));
578 input_report_abs(dev
, ABS_Y
, be16_to_cpu(*(__be16
*) &data
[4]));
579 input_report_abs(dev
, ABS_DISTANCE
, ((data
[9] >> 3) & 0x1f));
582 /* process general packets */
583 wacom_intuos_general(urb
);
585 /* 4D mouse, 2D mouse, marker pen rotation, or Lens cursor packets */
586 if ((data
[1] & 0xbc) == 0xa8 || (data
[1] & 0xbe) == 0xb0) {
588 if (data
[1] & 0x02) {
589 /* Rotation packet */
590 if (wacom
->features
->type
>= INTUOS3
) {
591 /* I3 marker pen rotation reported as wheel
592 * due to valuator limitation
594 t
= (data
[6] << 3) | ((data
[7] >> 5) & 7);
595 t
= (data
[7] & 0x20) ? ((t
> 900) ? ((t
-1) / 2 - 1350) :
596 ((t
-1) / 2 + 450)) : (450 - t
/ 2) ;
597 input_report_abs(dev
, ABS_WHEEL
, t
);
599 /* 4D mouse rotation packet */
600 t
= (data
[6] << 3) | ((data
[7] >> 5) & 7);
601 input_report_abs(dev
, ABS_RZ
, (data
[7] & 0x20) ?
602 ((t
- 1) / 2) : -t
/ 2);
605 } else if (!(data
[1] & 0x10) && wacom
->features
->type
< INTUOS3
) {
606 /* 4D mouse packet */
607 input_report_key(dev
, BTN_LEFT
, data
[8] & 0x01);
608 input_report_key(dev
, BTN_MIDDLE
, data
[8] & 0x02);
609 input_report_key(dev
, BTN_RIGHT
, data
[8] & 0x04);
611 input_report_key(dev
, BTN_SIDE
, data
[8] & 0x20);
612 input_report_key(dev
, BTN_EXTRA
, data
[8] & 0x10);
613 t
= (data
[6] << 2) | ((data
[7] >> 6) & 3);
614 input_report_abs(dev
, ABS_THROTTLE
, (data
[8] & 0x08) ? -t
: t
);
616 } else if (wacom
->tool
[idx
] == BTN_TOOL_MOUSE
) {
617 /* 2D mouse packet */
618 input_report_key(dev
, BTN_LEFT
, data
[8] & 0x04);
619 input_report_key(dev
, BTN_MIDDLE
, data
[8] & 0x08);
620 input_report_key(dev
, BTN_RIGHT
, data
[8] & 0x10);
621 input_report_rel(dev
, REL_WHEEL
, ((data
[8] & 0x02) >> 1)
624 /* I3 2D mouse side buttons */
625 if (wacom
->features
->type
== INTUOS3
) {
626 input_report_key(dev
, BTN_SIDE
, data
[8] & 0x40);
627 input_report_key(dev
, BTN_EXTRA
, data
[8] & 0x20);
630 } else if (wacom
->features
->type
< INTUOS3
) {
631 /* Lens cursor packets */
632 input_report_key(dev
, BTN_LEFT
, data
[8] & 0x01);
633 input_report_key(dev
, BTN_MIDDLE
, data
[8] & 0x02);
634 input_report_key(dev
, BTN_RIGHT
, data
[8] & 0x04);
635 input_report_key(dev
, BTN_SIDE
, data
[8] & 0x10);
636 input_report_key(dev
, BTN_EXTRA
, data
[8] & 0x08);
640 input_report_key(dev
, wacom
->tool
[idx
], 1);
641 input_event(dev
, EV_MSC
, MSC_SERIAL
, wacom
->serial
[idx
]);
645 retval
= usb_submit_urb (urb
, GFP_ATOMIC
);
647 err ("%s - usb_submit_urb failed with result %d",
648 __FUNCTION__
, retval
);
651 static struct wacom_features wacom_features
[] = {
652 { "Wacom Penpartner", 7, 5040, 3780, 255, 32, PENPARTNER
, wacom_penpartner_irq
},
653 { "Wacom Graphire", 8, 10206, 7422, 511, 32, GRAPHIRE
, wacom_graphire_irq
},
654 { "Wacom Graphire2 4x5", 8, 10206, 7422, 511, 32, GRAPHIRE
, wacom_graphire_irq
},
655 { "Wacom Graphire2 5x7", 8, 13918, 10206, 511, 32, GRAPHIRE
, wacom_graphire_irq
},
656 { "Wacom Graphire3", 8, 10208, 7424, 511, 32, GRAPHIRE
, wacom_graphire_irq
},
657 { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 32, GRAPHIRE
, wacom_graphire_irq
},
658 { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 15, INTUOS
, wacom_intuos_irq
},
659 { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 15, INTUOS
, wacom_intuos_irq
},
660 { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 15, INTUOS
, wacom_intuos_irq
},
661 { "Wacom Intuos 12x12", 10, 30480, 31680, 1023, 15, INTUOS
, wacom_intuos_irq
},
662 { "Wacom Intuos 12x18", 10, 45720, 31680, 1023, 15, INTUOS
, wacom_intuos_irq
},
663 { "Wacom PL400", 8, 5408, 4056, 255, 32, PL
, wacom_pl_irq
},
664 { "Wacom PL500", 8, 6144, 4608, 255, 32, PL
, wacom_pl_irq
},
665 { "Wacom PL600", 8, 6126, 4604, 255, 32, PL
, wacom_pl_irq
},
666 { "Wacom PL600SX", 8, 6260, 5016, 255, 32, PL
, wacom_pl_irq
},
667 { "Wacom PL550", 8, 6144, 4608, 511, 32, PL
, wacom_pl_irq
},
668 { "Wacom PL800", 8, 7220, 5780, 511, 32, PL
, wacom_pl_irq
},
669 { "Wacom Intuos2 4x5", 10, 12700, 10600, 1023, 15, INTUOS
, wacom_intuos_irq
},
670 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, INTUOS
, wacom_intuos_irq
},
671 { "Wacom Intuos2 9x12", 10, 30480, 24060, 1023, 15, INTUOS
, wacom_intuos_irq
},
672 { "Wacom Intuos2 12x12", 10, 30480, 31680, 1023, 15, INTUOS
, wacom_intuos_irq
},
673 { "Wacom Intuos2 12x18", 10, 45720, 31680, 1023, 15, INTUOS
, wacom_intuos_irq
},
674 { "Wacom Volito", 8, 5104, 3712, 511, 32, GRAPHIRE
, wacom_graphire_irq
},
675 { "Wacom Cintiq Partner",8, 20480, 15360, 511, 32, PL
, wacom_ptu_irq
},
676 { "Wacom Intuos3 4x5", 10, 25400, 20320, 1023, 15, INTUOS3
, wacom_intuos_irq
},
677 { "Wacom Intuos3 6x8", 10, 40640, 30480, 1023, 15, INTUOS3
, wacom_intuos_irq
},
678 { "Wacom Intuos3 9x12", 10, 60960, 45720, 1023, 15, INTUOS3
, wacom_intuos_irq
},
679 { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 15, CINTIQ
, wacom_intuos_irq
},
680 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, INTUOS
, wacom_intuos_irq
},
684 static struct usb_device_id wacom_ids
[] = {
685 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0x00) },
686 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0x10) },
687 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0x11) },
688 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0x12) },
689 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0x13) },
690 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0x14) },
691 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0x20) },
692 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0x21) },
693 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0x22) },
694 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0x23) },
695 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0x24) },
696 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0x30) },
697 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0x31) },
698 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0x32) },
699 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0x33) },
700 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0x34) },
701 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0x35) },
702 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0x41) },
703 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0x42) },
704 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0x43) },
705 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0x44) },
706 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0x45) },
707 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0x60) },
708 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0x03) },
709 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0xB0) },
710 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0xB1) },
711 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0xB2) },
712 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0x3F) },
713 { USB_DEVICE(USB_VENDOR_ID_WACOM
, 0x47) },
717 MODULE_DEVICE_TABLE(usb
, wacom_ids
);
719 static int wacom_open(struct input_dev
*dev
)
721 struct wacom
*wacom
= dev
->private;
723 wacom
->irq
->dev
= wacom
->usbdev
;
724 if (usb_submit_urb(wacom
->irq
, GFP_KERNEL
))
730 static void wacom_close(struct input_dev
*dev
)
732 struct wacom
*wacom
= dev
->private;
734 usb_kill_urb(wacom
->irq
);
737 static int wacom_probe(struct usb_interface
*intf
, const struct usb_device_id
*id
)
739 struct usb_device
*dev
= interface_to_usbdev(intf
);
740 struct usb_endpoint_descriptor
*endpoint
;
741 char rep_data
[2] = {0x02, 0x02};
745 if (!(wacom
= kmalloc(sizeof(struct wacom
), GFP_KERNEL
)))
747 memset(wacom
, 0, sizeof(struct wacom
));
749 wacom
->data
= usb_buffer_alloc(dev
, 10, GFP_KERNEL
, &wacom
->data_dma
);
755 wacom
->irq
= usb_alloc_urb(0, GFP_KERNEL
);
757 usb_buffer_free(dev
, 10, wacom
->data
, wacom
->data_dma
);
762 wacom
->features
= wacom_features
+ (id
- wacom_ids
);
764 wacom
->dev
.evbit
[0] |= BIT(EV_KEY
) | BIT(EV_ABS
);
765 wacom
->dev
.absbit
[0] |= BIT(ABS_X
) | BIT(ABS_Y
) | BIT(ABS_PRESSURE
);
766 wacom
->dev
.keybit
[LONG(BTN_DIGI
)] |= BIT(BTN_TOOL_PEN
) | BIT(BTN_TOUCH
) | BIT(BTN_STYLUS
);
768 switch (wacom
->features
->type
) {
770 wacom
->dev
.evbit
[0] |= BIT(EV_REL
);
771 wacom
->dev
.relbit
[0] |= BIT(REL_WHEEL
);
772 wacom
->dev
.absbit
[0] |= BIT(ABS_DISTANCE
);
773 wacom
->dev
.keybit
[LONG(BTN_LEFT
)] |= BIT(BTN_LEFT
) | BIT(BTN_RIGHT
) | BIT(BTN_MIDDLE
);
774 wacom
->dev
.keybit
[LONG(BTN_DIGI
)] |= BIT(BTN_TOOL_RUBBER
) | BIT(BTN_TOOL_MOUSE
) | BIT(BTN_STYLUS2
);
779 wacom
->dev
.keybit
[LONG(BTN_DIGI
)] |= BIT(BTN_TOOL_FINGER
);
780 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
);
781 wacom
->dev
.absbit
[0] |= BIT(ABS_RX
) | BIT(ABS_RY
);
785 wacom
->dev
.evbit
[0] |= BIT(EV_MSC
) | BIT(EV_REL
);
786 wacom
->dev
.mscbit
[0] |= BIT(MSC_SERIAL
);
787 wacom
->dev
.relbit
[0] |= BIT(REL_WHEEL
);
788 wacom
->dev
.keybit
[LONG(BTN_LEFT
)] |= BIT(BTN_LEFT
) | BIT(BTN_RIGHT
) | BIT(BTN_MIDDLE
) | BIT(BTN_SIDE
) | BIT(BTN_EXTRA
);
789 wacom
->dev
.keybit
[LONG(BTN_DIGI
)] |= BIT(BTN_TOOL_RUBBER
) | BIT(BTN_TOOL_MOUSE
) | BIT(BTN_TOOL_BRUSH
)
790 | BIT(BTN_TOOL_PENCIL
) | BIT(BTN_TOOL_AIRBRUSH
) | BIT(BTN_TOOL_LENS
) | BIT(BTN_STYLUS2
);
791 wacom
->dev
.absbit
[0] |= BIT(ABS_DISTANCE
) | BIT(ABS_WHEEL
) | BIT(ABS_TILT_X
) | BIT(ABS_TILT_Y
) | BIT(ABS_RZ
) | BIT(ABS_THROTTLE
);
795 wacom
->dev
.keybit
[LONG(BTN_DIGI
)] |= BIT(BTN_STYLUS2
) | BIT(BTN_TOOL_RUBBER
);
799 wacom
->dev
.absmax
[ABS_X
] = wacom
->features
->x_max
;
800 wacom
->dev
.absmax
[ABS_Y
] = wacom
->features
->y_max
;
801 wacom
->dev
.absmax
[ABS_PRESSURE
] = wacom
->features
->pressure_max
;
802 wacom
->dev
.absmax
[ABS_DISTANCE
] = wacom
->features
->distance_max
;
803 wacom
->dev
.absmax
[ABS_TILT_X
] = 127;
804 wacom
->dev
.absmax
[ABS_TILT_Y
] = 127;
805 wacom
->dev
.absmax
[ABS_WHEEL
] = 1023;
807 wacom
->dev
.absmax
[ABS_RX
] = 4097;
808 wacom
->dev
.absmax
[ABS_RY
] = 4097;
809 wacom
->dev
.absmin
[ABS_RZ
] = -900;
810 wacom
->dev
.absmax
[ABS_RZ
] = 899;
811 wacom
->dev
.absmin
[ABS_THROTTLE
] = -1023;
812 wacom
->dev
.absmax
[ABS_THROTTLE
] = 1023;
814 wacom
->dev
.absfuzz
[ABS_X
] = 4;
815 wacom
->dev
.absfuzz
[ABS_Y
] = 4;
817 wacom
->dev
.private = wacom
;
818 wacom
->dev
.open
= wacom_open
;
819 wacom
->dev
.close
= wacom_close
;
821 usb_make_path(dev
, path
, 64);
822 sprintf(wacom
->phys
, "%s/input0", path
);
824 wacom
->dev
.name
= wacom
->features
->name
;
825 wacom
->dev
.phys
= wacom
->phys
;
826 usb_to_input_id(dev
, &wacom
->dev
.id
);
827 wacom
->dev
.dev
= &intf
->dev
;
830 endpoint
= &intf
->cur_altsetting
->endpoint
[0].desc
;
832 if (wacom
->features
->pktlen
> 10)
835 usb_fill_int_urb(wacom
->irq
, dev
,
836 usb_rcvintpipe(dev
, endpoint
->bEndpointAddress
),
837 wacom
->data
, wacom
->features
->pktlen
,
838 wacom
->features
->irq
, wacom
, endpoint
->bInterval
);
839 wacom
->irq
->transfer_dma
= wacom
->data_dma
;
840 wacom
->irq
->transfer_flags
|= URB_NO_TRANSFER_DMA_MAP
;
842 input_register_device(&wacom
->dev
);
844 /* ask the tablet to report tablet data */
845 usb_set_report(intf
, 3, 2, rep_data
, 2);
846 /* repeat once (not sure why the first call often fails) */
847 usb_set_report(intf
, 3, 2, rep_data
, 2);
849 printk(KERN_INFO
"input: %s on %s\n", wacom
->features
->name
, path
);
851 usb_set_intfdata(intf
, wacom
);
856 static void wacom_disconnect(struct usb_interface
*intf
)
858 struct wacom
*wacom
= usb_get_intfdata (intf
);
860 usb_set_intfdata(intf
, NULL
);
862 usb_kill_urb(wacom
->irq
);
863 input_unregister_device(&wacom
->dev
);
864 usb_free_urb(wacom
->irq
);
865 usb_buffer_free(interface_to_usbdev(intf
), 10, wacom
->data
, wacom
->data_dma
);
870 static struct usb_driver wacom_driver
= {
871 .owner
= THIS_MODULE
,
873 .probe
= wacom_probe
,
874 .disconnect
= wacom_disconnect
,
875 .id_table
= wacom_ids
,
878 static int __init
wacom_init(void)
880 int result
= usb_register(&wacom_driver
);
882 info(DRIVER_VERSION
":" DRIVER_DESC
);
886 static void __exit
wacom_exit(void)
888 usb_deregister(&wacom_driver
);
891 module_init(wacom_init
);
892 module_exit(wacom_exit
);