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, ...
57 * This program is free software; you can redistribute it and/or modify
58 * it under the terms of the GNU General Public License as published by
59 * the Free Software Foundation; either version 2 of the License, or
60 * (at your option) any later version.
63 #include <linux/kernel.h>
64 #include <linux/slab.h>
65 #include <linux/input.h>
66 #include <linux/module.h>
67 #include <linux/init.h>
68 #include <linux/usb.h>
69 #include <asm/unaligned.h>
70 #include <asm/byteorder.h>
75 #define DRIVER_VERSION "v1.30"
76 #define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@ucw.cz>"
77 #define DRIVER_DESC "USB Wacom Graphire and Wacom Intuos tablet driver"
78 #define DRIVER_LICENSE "GPL"
80 MODULE_AUTHOR(DRIVER_AUTHOR);
81 MODULE_DESCRIPTION(DRIVER_DESC);
82 MODULE_LICENSE(DRIVER_LICENSE);
84 #define USB_VENDOR_ID_WACOM 0x056a
86 struct wacom_features {
100 struct input_dev dev;
101 struct usb_device *usbdev;
103 struct wacom_features *features;
110 #define USB_REQ_SET_REPORT 0x09
111 static int usb_set_report(struct usb_interface *intf, unsigned char type,
112 unsigned char id, void *buf, int size)
114 return usb_control_msg(interface_to_usbdev(intf),
115 usb_sndctrlpipe(interface_to_usbdev(intf), 0),
116 USB_REQ_SET_REPORT, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
117 (type << 8) + id, intf->altsetting[0].desc.bInterfaceNumber,
121 static void wacom_pl_irq(struct urb *urb, struct pt_regs *regs)
123 struct wacom *wacom = urb->context;
124 unsigned char *data = wacom->data;
125 struct input_dev *dev = &wacom->dev;
129 switch (urb->status) {
136 /* this urb is terminated, clean up */
137 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
140 dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status);
145 dbg("wacom_pl_irq: received unknown report #%d", data[0]);
147 prox = data[1] & 0x40;
149 input_regs(dev, regs);
153 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
154 if (wacom->features->pressure_max > 255)
155 pressure = (pressure << 1) | ((data[4] >> 6) & 1);
156 pressure += (wacom->features->pressure_max + 1) / 2;
159 * if going from out of proximity into proximity select between the eraser
160 * and the pen based on the state of the stylus2 button, choose eraser if
161 * pressed else choose pen. if not a proximity change from out to in, send
162 * an out of proximity for previous tool then a in for new tool.
164 if (!wacom->tool[0]) {
165 /* Going into proximity select tool */
166 wacom->tool[1] = (data[4] & 0x20)? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
169 /* was entered with stylus2 pressed */
170 if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20) ) {
171 /* report out proximity for previous tool */
172 input_report_key(dev, wacom->tool[1], 0);
174 wacom->tool[1] = BTN_TOOL_PEN;
178 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
179 /* Unknown tool selected default to pen tool */
180 wacom->tool[1] = BTN_TOOL_PEN;
182 input_report_key(dev, wacom->tool[1], prox); /* report in proximity for tool */
183 input_report_abs(dev, ABS_X, data[3] | ((__u32)data[2] << 7) | ((__u32)(data[1] & 0x03) << 14));
184 input_report_abs(dev, ABS_Y, data[6] | ((__u32)data[5] << 7) | ((__u32)(data[4] & 0x03) << 14));
185 input_report_abs(dev, ABS_PRESSURE, pressure);
187 input_report_key(dev, BTN_TOUCH, data[4] & 0x08);
188 input_report_key(dev, BTN_STYLUS, data[4] & 0x10);
189 /* Only allow the stylus2 button to be reported for the pen tool. */
190 input_report_key(dev, BTN_STYLUS2, (wacom->tool[1] == BTN_TOOL_PEN) && (data[4] & 0x20));
193 /* report proximity-out of a (valid) tool */
194 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
195 /* Unknown tool selected default to pen tool */
196 wacom->tool[1] = BTN_TOOL_PEN;
198 input_report_key(dev, wacom->tool[1], prox);
201 wacom->tool[0] = prox; /* Save proximity state */
205 retval = usb_submit_urb (urb, GFP_ATOMIC);
207 err ("%s - usb_submit_urb failed with result %d",
208 __FUNCTION__, retval);
211 static void wacom_ptu_irq(struct urb *urb, struct pt_regs *regs)
213 struct wacom *wacom = urb->context;
214 unsigned char *data = wacom->data;
215 struct input_dev *dev = &wacom->dev;
218 switch (urb->status) {
225 /* this urb is terminated, clean up */
226 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
229 dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status);
235 printk(KERN_INFO "wacom_ptu_irq: received unknown report #%d\n", data[0]);
238 input_regs(dev, regs);
241 input_report_key(dev, BTN_TOOL_RUBBER, data[1] & 0x20);
242 input_report_key(dev, BTN_TOUCH, data[1] & 0x08);
246 input_report_key(dev, BTN_TOOL_PEN, data[1] & 0x20);
247 input_report_key(dev, BTN_TOUCH, data[1] & 0x01);
249 input_report_abs(dev, ABS_X, data[3] << 8 | data[2]);
250 input_report_abs(dev, ABS_Y, data[5] << 8 | data[4]);
251 input_report_abs(dev, ABS_PRESSURE, (data[6]|data[7] << 8));
252 input_report_key(dev, BTN_STYLUS, data[1] & 0x02);
253 input_report_key(dev, BTN_STYLUS2, data[1] & 0x10);
258 retval = usb_submit_urb (urb, GFP_ATOMIC);
260 err ("%s - usb_submit_urb failed with result %d",
261 __FUNCTION__, retval);
264 static void wacom_penpartner_irq(struct urb *urb, struct pt_regs *regs)
266 struct wacom *wacom = urb->context;
267 unsigned char *data = wacom->data;
268 struct input_dev *dev = &wacom->dev;
271 switch (urb->status) {
278 /* this urb is terminated, clean up */
279 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
282 dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status);
286 input_regs(dev, regs);
287 input_report_key(dev, BTN_TOOL_PEN, 1);
288 input_report_abs(dev, ABS_X, le16_to_cpu(get_unaligned((u16 *) &data[1])));
289 input_report_abs(dev, ABS_Y, le16_to_cpu(get_unaligned((u16 *) &data[3])));
290 input_report_abs(dev, ABS_PRESSURE, (signed char)data[6] + 127);
291 input_report_key(dev, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
292 input_report_key(dev, BTN_STYLUS, (data[5] & 0x40));
296 retval = usb_submit_urb (urb, GFP_ATOMIC);
298 err ("%s - usb_submit_urb failed with result %d",
299 __FUNCTION__, retval);
302 static void wacom_graphire_irq(struct urb *urb, struct pt_regs *regs)
304 struct wacom *wacom = urb->context;
305 unsigned char *data = wacom->data;
306 struct input_dev *dev = &wacom->dev;
310 switch (urb->status) {
317 /* this urb is terminated, clean up */
318 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
321 dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status);
325 /* check if we can handle the data */
330 dbg("wacom_graphire_irq: received unknown report #%d", data[0]);
332 x = le16_to_cpu(*(u16 *) &data[2]);
333 y = le16_to_cpu(*(u16 *) &data[4]);
335 input_regs(dev, regs);
337 switch ((data[1] >> 5) & 3) {
340 input_report_key(dev, BTN_TOOL_PEN, data[1] & 0x80);
344 input_report_key(dev, BTN_TOOL_RUBBER, data[1] & 0x80);
347 case 2: /* Mouse with wheel */
348 input_report_key(dev, BTN_MIDDLE, data[1] & 0x04);
349 input_report_rel(dev, REL_WHEEL, (signed char) data[6]);
352 case 3: /* Mouse without wheel */
353 input_report_key(dev, BTN_TOOL_MOUSE, data[7] > 24);
354 input_report_key(dev, BTN_LEFT, data[1] & 0x01);
355 input_report_key(dev, BTN_RIGHT, data[1] & 0x02);
356 input_report_abs(dev, ABS_DISTANCE, data[7]);
358 input_report_abs(dev, ABS_X, x);
359 input_report_abs(dev, ABS_Y, y);
365 if (data[1] & 0x80) {
366 input_report_abs(dev, ABS_X, x);
367 input_report_abs(dev, ABS_Y, y);
370 input_report_abs(dev, ABS_PRESSURE, le16_to_cpu(*(u16 *) &data[6]));
371 input_report_key(dev, BTN_TOUCH, data[1] & 0x01);
372 input_report_key(dev, BTN_STYLUS, data[1] & 0x02);
373 input_report_key(dev, BTN_STYLUS2, data[1] & 0x04);
378 retval = usb_submit_urb (urb, GFP_ATOMIC);
380 err ("%s - usb_submit_urb failed with result %d",
381 __FUNCTION__, retval);
384 static void wacom_intuos_irq(struct urb *urb, struct pt_regs *regs)
386 struct wacom *wacom = urb->context;
387 unsigned char *data = wacom->data;
388 struct input_dev *dev = &wacom->dev;
393 switch (urb->status) {
400 /* this urb is terminated, clean up */
401 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
404 dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status);
409 dbg("wacom_intuos_irq: received unknown report #%d", data[0]);
411 input_regs(dev, regs);
414 idx = data[1] & 0x01;
416 if ((data[1] & 0xfc) == 0xc0) { /* Enter report */
418 wacom->serial[idx] = ((__u32)(data[3] & 0x0f) << 28) + /* serial number of the tool */
419 ((__u32)data[4] << 20) + ((__u32)data[5] << 12) +
420 ((__u32)data[6] << 4) + (data[7] >> 4);
422 switch (((__u32)data[2] << 4) | (data[3] >> 4)) {
424 case 0x012: wacom->tool[idx] = BTN_TOOL_PENCIL; break; /* Inking pen */
428 case 0x022: wacom->tool[idx] = BTN_TOOL_PEN; break; /* Pen */
430 case 0x032: wacom->tool[idx] = BTN_TOOL_BRUSH; break; /* Stroke pen */
433 case 0x094: wacom->tool[idx] = BTN_TOOL_MOUSE; break; /* Mouse 4D and 2D */
434 case 0x096: wacom->tool[idx] = BTN_TOOL_LENS; break; /* Lens cursor */
439 case 0x0fa: wacom->tool[idx] = BTN_TOOL_RUBBER; break; /* Eraser */
442 case 0x112: wacom->tool[idx] = BTN_TOOL_AIRBRUSH; break; /* Airbrush */
443 default: wacom->tool[idx] = BTN_TOOL_PEN; break; /* Unknown tool */
446 input_report_key(dev, wacom->tool[idx], 1);
447 input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
452 if ((data[1] & 0xfe) == 0x80) { /* Exit report */
453 input_report_key(dev, wacom->tool[idx], 0);
454 input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
459 input_report_abs(dev, ABS_X, be16_to_cpu(*(u16 *) &data[2]));
460 input_report_abs(dev, ABS_Y, be16_to_cpu(*(u16 *) &data[4]));
461 input_report_abs(dev, ABS_DISTANCE, data[9]);
463 if ((data[1] & 0xb8) == 0xa0) { /* general pen packet */
464 input_report_abs(dev, ABS_PRESSURE, t = ((__u32)data[6] << 2) | ((data[7] >> 6) & 3));
465 input_report_abs(dev, ABS_TILT_X, ((data[7] << 1) & 0x7e) | (data[8] >> 7));
466 input_report_abs(dev, ABS_TILT_Y, data[8] & 0x7f);
467 input_report_key(dev, BTN_STYLUS, data[1] & 2);
468 input_report_key(dev, BTN_STYLUS2, data[1] & 4);
469 input_report_key(dev, BTN_TOUCH, t > 10);
472 if ((data[1] & 0xbc) == 0xb4) { /* airbrush second packet */
473 input_report_abs(dev, ABS_WHEEL, ((__u32)data[6] << 2) | ((data[7] >> 6) & 3));
474 input_report_abs(dev, ABS_TILT_X, ((data[7] << 1) & 0x7e) | (data[8] >> 7));
475 input_report_abs(dev, ABS_TILT_Y, data[8] & 0x7f);
478 if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0) { /* 4D mouse or Lens cursor packets */
480 if (data[1] & 0x02) { /* Rotation packet */
482 input_report_abs(dev, ABS_RZ, (data[7] & 0x20) ?
483 ((__u32)data[6] << 3) | ((data[7] >> 5) & 7):
484 (-(((__u32)data[6] << 3) | ((data[7] >> 5) & 7))) - 1);
488 if ((data[1] & 0x10) == 0) { /* 4D mouse packets */
490 input_report_key(dev, BTN_LEFT, data[8] & 0x01);
491 input_report_key(dev, BTN_MIDDLE, data[8] & 0x02);
492 input_report_key(dev, BTN_RIGHT, data[8] & 0x04);
494 input_report_key(dev, BTN_SIDE, data[8] & 0x20);
495 input_report_key(dev, BTN_EXTRA, data[8] & 0x10);
496 input_report_abs(dev, ABS_THROTTLE, -((data[8] & 0x08) ?
497 ((__u32)data[6] << 2) | ((data[7] >> 6) & 3) :
498 -((__u32)data[6] << 2) | ((data[7] >> 6) & 3)));
501 if (wacom->tool[idx] == BTN_TOOL_MOUSE) { /* 2D mouse packets */
502 input_report_key(dev, BTN_LEFT, data[8] & 0x04);
503 input_report_key(dev, BTN_MIDDLE, data[8] & 0x08);
504 input_report_key(dev, BTN_RIGHT, data[8] & 0x10);
505 input_report_rel(dev, REL_WHEEL,
506 (-(__u32)(data[8] & 0x01) + (__u32)((data[8] & 0x02) >> 1)));
508 else { /* Lens cursor packets */
509 input_report_key(dev, BTN_LEFT, data[8] & 0x01);
510 input_report_key(dev, BTN_MIDDLE, data[8] & 0x02);
511 input_report_key(dev, BTN_RIGHT, data[8] & 0x04);
512 input_report_key(dev, BTN_SIDE, data[8] & 0x10);
513 input_report_key(dev, BTN_EXTRA, data[8] & 0x08);
519 input_report_key(dev, wacom->tool[idx], 1);
520 input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
524 retval = usb_submit_urb (urb, GFP_ATOMIC);
526 err ("%s - usb_submit_urb failed with result %d",
527 __FUNCTION__, retval);
530 struct wacom_features wacom_features[] = {
531 { "Wacom Penpartner", 7, 5040, 3780, 255, 32, 0, wacom_penpartner_irq },
532 { "Wacom Graphire", 8, 10206, 7422, 511, 32, 1, wacom_graphire_irq },
533 { "Wacom Graphire2 4x5", 8, 10206, 7422, 511, 32, 1, wacom_graphire_irq },
534 { "Wacom Graphire2 5x7", 8, 13918, 10206, 511, 32, 1, wacom_graphire_irq },
535 { "Wacom Graphire3", 8, 10208, 7424, 511, 32, 1, wacom_graphire_irq },
536 { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 32, 1, wacom_graphire_irq },
537 { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 15, 2, wacom_intuos_irq },
538 { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 15, 2, wacom_intuos_irq },
539 { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 15, 2, wacom_intuos_irq },
540 { "Wacom Intuos 12x12", 10, 30480, 31680, 1023, 15, 2, wacom_intuos_irq },
541 { "Wacom Intuos 12x18", 10, 45720, 31680, 1023, 15, 2, wacom_intuos_irq },
542 { "Wacom PL400", 8, 5408, 4056, 255, 32, 3, wacom_pl_irq },
543 { "Wacom PL500", 8, 6144, 4608, 255, 32, 3, wacom_pl_irq },
544 { "Wacom PL600", 8, 6126, 4604, 255, 32, 3, wacom_pl_irq },
545 { "Wacom PL600SX", 8, 6260, 5016, 255, 32, 3, wacom_pl_irq },
546 { "Wacom PL550", 8, 6144, 4608, 511, 32, 3, wacom_pl_irq },
547 { "Wacom PL800", 8, 7220, 5780, 511, 32, 3, wacom_pl_irq },
548 { "Wacom Intuos2 4x5", 10, 12700, 10600, 1023, 15, 2, wacom_intuos_irq },
549 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, 2, wacom_intuos_irq },
550 { "Wacom Intuos2 9x12", 10, 30480, 24060, 1023, 15, 2, wacom_intuos_irq },
551 { "Wacom Intuos2 12x12", 10, 30480, 31680, 1023, 15, 2, wacom_intuos_irq },
552 { "Wacom Intuos2 12x18", 10, 45720, 31680, 1023, 15, 2, wacom_intuos_irq },
553 { "Wacom Volito", 8, 5104, 3712, 511, 32, 1, wacom_graphire_irq },
554 { "Wacom Cintiq Partner",8, 20480, 15360, 511, 32, 3, wacom_ptu_irq },
555 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, 2, wacom_intuos_irq },
559 struct usb_device_id wacom_ids[] = {
560 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x00) },
561 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x10) },
562 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x11) },
563 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x12) },
564 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x13) },
565 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x14) },
566 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x20) },
567 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x21) },
568 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x22) },
569 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x23) },
570 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x24) },
571 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x30) },
572 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x31) },
573 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x32) },
574 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x33) },
575 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x34) },
576 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x35) },
577 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x41) },
578 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x42) },
579 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x43) },
580 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x44) },
581 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x45) },
582 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60) },
583 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x03) },
584 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) },
588 MODULE_DEVICE_TABLE(usb, wacom_ids);
590 static int wacom_open(struct input_dev *dev)
592 struct wacom *wacom = dev->private;
597 wacom->irq->dev = wacom->usbdev;
598 if (usb_submit_urb(wacom->irq, GFP_KERNEL)) {
606 static void wacom_close(struct input_dev *dev)
608 struct wacom *wacom = dev->private;
611 usb_unlink_urb(wacom->irq);
614 static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id)
616 struct usb_device *dev = interface_to_usbdev(intf);
617 struct usb_endpoint_descriptor *endpoint;
618 char rep_data[2] = {0x02, 0x02};
622 if (!(wacom = kmalloc(sizeof(struct wacom), GFP_KERNEL)))
624 memset(wacom, 0, sizeof(struct wacom));
626 wacom->data = usb_buffer_alloc(dev, 10, GFP_KERNEL, &wacom->data_dma);
632 wacom->irq = usb_alloc_urb(0, GFP_KERNEL);
634 usb_buffer_free(dev, 10, wacom->data, wacom->data_dma);
639 wacom->features = wacom_features + (id - wacom_ids);
641 wacom->dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS);
642 wacom->dev.absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE);
643 wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH) | BIT(BTN_STYLUS);
645 switch (wacom->features->type) {
647 wacom->dev.evbit[0] |= BIT(EV_REL);
648 wacom->dev.relbit[0] |= BIT(REL_WHEEL);
649 wacom->dev.absbit[0] |= BIT(ABS_DISTANCE);
650 wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE);
651 wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_STYLUS2);
655 wacom->dev.evbit[0] |= BIT(EV_MSC) | BIT(EV_REL);
656 wacom->dev.mscbit[0] |= BIT(MSC_SERIAL);
657 wacom->dev.relbit[0] |= BIT(REL_WHEEL);
658 wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE) | BIT(BTN_SIDE) | BIT(BTN_EXTRA);
659 wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_TOOL_BRUSH)
660 | BIT(BTN_TOOL_PENCIL) | BIT(BTN_TOOL_AIRBRUSH) | BIT(BTN_TOOL_LENS) | BIT(BTN_STYLUS2);
661 wacom->dev.absbit[0] |= BIT(ABS_DISTANCE) | BIT(ABS_WHEEL) | BIT(ABS_TILT_X) | BIT(ABS_TILT_Y) | BIT(ABS_RZ) | BIT(ABS_THROTTLE);
665 wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_STYLUS2);
669 wacom->dev.absmax[ABS_X] = wacom->features->x_max;
670 wacom->dev.absmax[ABS_Y] = wacom->features->y_max;
671 wacom->dev.absmax[ABS_PRESSURE] = wacom->features->pressure_max;
672 wacom->dev.absmax[ABS_DISTANCE] = wacom->features->distance_max;
673 wacom->dev.absmax[ABS_TILT_X] = 127;
674 wacom->dev.absmax[ABS_TILT_Y] = 127;
675 wacom->dev.absmax[ABS_WHEEL] = 1023;
677 wacom->dev.absmin[ABS_RZ] = -900;
678 wacom->dev.absmax[ABS_RZ] = 899;
679 wacom->dev.absmin[ABS_THROTTLE] = -1023;
680 wacom->dev.absmax[ABS_THROTTLE] = 1023;
682 wacom->dev.absfuzz[ABS_X] = 4;
683 wacom->dev.absfuzz[ABS_Y] = 4;
685 wacom->dev.private = wacom;
686 wacom->dev.open = wacom_open;
687 wacom->dev.close = wacom_close;
689 usb_make_path(dev, path, 64);
690 sprintf(wacom->phys, "%s/input0", path);
692 wacom->dev.name = wacom->features->name;
693 wacom->dev.phys = wacom->phys;
694 wacom->dev.id.bustype = BUS_USB;
695 wacom->dev.id.vendor = dev->descriptor.idVendor;
696 wacom->dev.id.product = dev->descriptor.idProduct;
697 wacom->dev.id.version = dev->descriptor.bcdDevice;
698 wacom->dev.dev = &intf->dev;
701 endpoint = &intf->cur_altsetting->endpoint[0].desc;
703 if (wacom->features->pktlen > 10)
706 usb_fill_int_urb(wacom->irq, dev,
707 usb_rcvintpipe(dev, endpoint->bEndpointAddress),
708 wacom->data, wacom->features->pktlen,
709 wacom->features->irq, wacom, endpoint->bInterval);
710 wacom->irq->transfer_dma = wacom->data_dma;
711 wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
713 input_register_device(&wacom->dev);
715 usb_set_report(intf, 3, 2, rep_data, 2);
716 usb_set_report(intf, 3, 5, rep_data, 0);
717 usb_set_report(intf, 3, 6, rep_data, 0);
719 printk(KERN_INFO "input: %s on %s\n", wacom->features->name, path);
721 usb_set_intfdata(intf, wacom);
726 static void wacom_disconnect(struct usb_interface *intf)
728 struct wacom *wacom = usb_get_intfdata (intf);
730 usb_set_intfdata(intf, NULL);
732 usb_unlink_urb(wacom->irq);
733 input_unregister_device(&wacom->dev);
734 usb_free_urb(wacom->irq);
735 usb_buffer_free(interface_to_usbdev(intf), 10, wacom->data, wacom->data_dma);
740 static struct usb_driver wacom_driver = {
741 .owner = THIS_MODULE,
743 .probe = wacom_probe,
744 .disconnect = wacom_disconnect,
745 .id_table = wacom_ids,
748 static int __init wacom_init(void)
750 int result = usb_register(&wacom_driver);
752 info(DRIVER_VERSION ":" DRIVER_DESC);
756 static void __exit wacom_exit(void)
758 usb_deregister(&wacom_driver);
761 module_init(wacom_init);
762 module_exit(wacom_exit);