2
* $Id: wacom.c,v 1.9 2004/11/06 04:55:03 pingc Exp $
4
* Copyright (c) 2000-2002 Vojtech Pavlik <vojtech@suse.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) 2002 Christer Nilsson <christer.nilsson@kretskompaniet.se>
12
* Copyright (c) 2002-2004 Ping Cheng <pingc@wacom.com>
13
* Copyright (c) 2002 John Joganic <john@joganic.com>
15
* USB Wacom Graphire and Intuos tablet support
20
* v0.1 (vp) - Initial release
21
* v0.2 (aba) - Support for all buttons / combinations
22
* v0.3 (vp) - Support for Intuos added
23
* v0.4 (sm) - Support for more Intuos models, menustrip
24
* relative mode, proximity.
25
* v0.5 (vp) - Big cleanup, nifty features removed,
26
* they belong in userspace
27
* v1.8 (vp) - Submit URB only when operating, moved to CVS,
28
* use input_report_key instead of report_btn and
30
* v1.11 (vp) - Add URB ->dev setting for new kernels
31
* v1.11 (jb) - Add support for the 4D Mouse & Lens
32
* v1.12 (de) - Add support for two more inking pen IDs
33
* v1.14 (vp) - Use new USB device id probing scheme.
34
* Fix Wacom Graphire mouse wheel
35
* v1.18 (vp) - Fix mouse wheel direction
37
* v1.20 (fl) - Report tool id for Intuos devices
38
* - Multi tools support
39
* - Corrected Intuos protocol decoding (airbrush, 4D mouse, lens cursor...)
40
* - Add PL models support
41
* - Fix Wacom Graphire mouse wheel again
42
* v1.21 (vp) - Removed protocol descriptions
43
* - Added MISC_SERIAL for tool serial numbers
44
* (gb) - Identify version on module load.
45
* v1.21.1 (fl) - added Graphire2 support
46
* v1.21.2 (fl) - added Intuos2 support
47
* - added all the PL ids
48
* v1.21.3 (fl) - added another eraser id from Neil Okamoto
49
* - added smooth filter for Graphire from Peri Hankey
50
* - added PenPartner support from Olaf van Es
51
* - new tool ids from Ole Martin Bjoerndalen
52
* v1.29 (pc) - Add support for more tablets
53
* - Fix pressure reporting
54
* v1.30 (vp) - Merge 2.4 and 2.5 drivers
55
* - Since 2.5 now has input_sync(), remove MSC_SERIAL abuse
56
* - Cleanups here and there
58
* WARNING: THIS IS NOT PART OF THE OFFICIAL KERNEL TREE
59
* THIS IS FOR TESTING PURPOSES
61
* v1.21.3-j0 - fixed absolute x and y for intuos by John Joganic
62
* v1.21.3-j1 - applied Christer Nilsson's patches for 2.4.20
63
* v1.30.1-j0 - applied Ping Cheng's patches for device ranges and caps
64
* v1.30.1-j1 - updated device ranges for Intuos2 12x12 (0x44)
65
* v1.30.1-j2 - updated device ranges for Intuos2 6x8 (0x42)
66
* v1.30-j0.3.1 - fixed pen identifers, 2D mouse handling
67
* v1.30-j0.3.3 - added volito, thanks to Pasi Savolainen; fixed wheel sign
68
* v1.30-j0.3.4 - added Ping Cheng's new tool IDs
69
* v1.30-j0.3.5 - thread for resetting tablet on bad report
70
* v1.30-j0.3.6 - fixed volito ranges, thanks to Pasi Savolainen
71
* v1.30-j0.3.7 - unknown reports are now info, rather than error
72
* v1.30-j0.3.8 - fixed I2 4x5 Y max value, thanks to John New
73
* fixed Intuos and Intuos2 sizes, values from Wacom
74
* v1.30-j0.5.0 - new release
75
* v1.30-j0.5.1 - fixed serial number code for Intuos and Intuos2
76
* v1.30-j0.5.2 - applied Ping Cheng's eraser patch for PL
77
* v1.30-j0.5.3 - reapplied patch for Intuos2 6x8's reportings as (0x47)
78
* v1.30-j0.6.0 - new release
79
* v1.30-j0.6.1 - new release
80
* v1.30-j0.6.2 - new release
81
* v1.30-j0.6.3 - new release
82
* v1.30-j0.6.4 - new release
83
* v1.30-j0.6.5 - added Intuos3
84
* v1.30-j0.6.6 - new release
88
* This program is free software; you can redistribute it and/or modify
89
* it under the terms of the GNU General Public License as published by
90
* the Free Software Foundation; either version 2 of the License, or
91
* (at your option) any later version.
94
#include <linux/autoconf.h>
95
#if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)
100
#include <linux/modversions.h>
103
#include <linux/kernel.h>
104
#include <linux/slab.h>
105
#include <linux/input.h>
106
#include <linux/module.h>
107
#include <linux/init.h>
108
#include <linux/usb.h>
109
#include <linux/smp_lock.h>
110
#include <linux/list.h>
113
* Version Information
115
#define DRIVER_VERSION "v1.30-j0.6.6"
116
#define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@suse.cz>"
118
#define DRIVER_DESC "USB Wacom Graphire and Wacom Intuos tablet driver (LINUXWACOM)"
120
#define DRIVER_DESC "USB Wacom Graphire and Wacom Intuos tablet driver (LINUXWACOM-DEBUG)"
123
MODULE_AUTHOR(DRIVER_AUTHOR);
124
MODULE_DESCRIPTION(DRIVER_DESC);
125
MODULE_LICENSE("GPL");
127
#define USB_VENDOR_ID_WACOM 0x056a
129
static int kwacomd_pid = 0; /* PID of kwacomd */
130
static DECLARE_COMPLETION(kwacomd_exited);
131
static DECLARE_WAIT_QUEUE_HEAD(kwacomd_wait);
132
static LIST_HEAD(wacom_event_list); /* List of tablets needing servicing */
133
static spinlock_t wacom_event_lock = SPIN_LOCK_UNLOCKED;
135
struct wacom_features {
142
void (*irq)(struct urb *urb);
144
unsigned long absbit;
145
unsigned long relbit;
146
unsigned long btnbit;
147
unsigned long digibit;
151
signed char data[10];
152
struct input_dev dev;
153
struct usb_device *usbdev;
155
struct wacom_features *features;
160
struct list_head event_list;
161
struct semaphore kwacomd_sem;
165
static void wacom_request_reset(struct wacom* wacom)
168
spin_lock_irqsave(&wacom_event_lock, flags);
169
if (list_empty(&wacom->event_list))
171
list_add(&wacom->event_list, &wacom_event_list);
172
wake_up(&kwacomd_wait);
174
spin_unlock_irqrestore(&wacom_event_lock, flags);
177
static void wacom_pl_irq(struct urb *urb)
179
struct wacom *wacom = urb->context;
180
unsigned char *data = wacom->data;
181
struct input_dev *dev = &wacom->dev;
184
if (urb->status) return;
186
if (data[0] != 2 && data[0] != 5)
188
printk(KERN_INFO "wacom_pl_irq: received unknown report #%d\n", data[0]);
189
wacom_request_reset(wacom);
193
/* proximity and pressure */
194
prox = data[1] & 0x40;
197
pressure = (signed char) ((data[7] <<1 ) | ((data[4] >> 2) & 1));
198
if ( wacom->features->pressure_max > 350 ) {
199
pressure = (pressure << 1) | ((data[4] >> 6) & 1);
201
pressure += (( wacom->features->pressure_max + 1 )/ 2);
204
* if going from out of proximity into proximity select between the eraser
205
* and the pen based on the state of the stylus2 button, choose eraser if
206
* pressed else choose pen. if not a proximity change from out to in, send
207
* an out of proximity for previous tool then a in for new tool.
209
if (!wacom->tool[0]) {
210
/* Going into proximity select tool */
211
wacom->tool[1] = (data[4] & 0x20)? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
214
/* was entered with stylus2 pressed */
215
if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20) ) {
216
/* report out proximity for previous tool */
217
input_report_key(dev, wacom->tool[1], 0);
218
input_event(dev, EV_MSC, MSC_SERIAL, 0);
219
wacom->tool[1] = BTN_TOOL_PEN;
223
if (wacom->tool[1] != BTN_TOOL_RUBBER) {
224
/* Unknown tool selected default to pen tool */
225
wacom->tool[1] = BTN_TOOL_PEN;
227
input_report_key(dev, wacom->tool[1], prox); /* report in proximity for tool */
229
input_report_abs(dev, ABS_X, data[3] | ((__u32)data[2] << 7) | ((__u32)(data[1] & 0x03) << 14));
230
input_report_abs(dev, ABS_Y, data[6] | ((__u32)data[5] << 7) | ((__u32)(data[4] & 0x03) << 14));
231
input_report_abs(dev, ABS_PRESSURE, pressure);
232
input_report_key(dev, BTN_TOUCH, data[4] & 0x08);
233
input_report_key(dev, BTN_STYLUS, data[4] & 0x10);
234
/* Only allow the stylus2 button to be reported for the pen tool. */
235
input_report_key(dev, BTN_STYLUS2, (wacom->tool[1] == BTN_TOOL_PEN) && (data[4] & 0x20));
238
/* report proximity-out of a (valid) tool */
239
if (wacom->tool[1] != BTN_TOOL_RUBBER) {
240
/* Unknown tool selected default to pen tool */
241
wacom->tool[1] = BTN_TOOL_PEN;
243
input_report_key(dev, wacom->tool[1], prox);
246
wacom->tool[0] = prox; /* Save proximity state */
247
/* end of proximity code */
249
input_event(dev, EV_MSC, MSC_SERIAL, 0);
252
static void wacom_ptu_irq(struct urb *urb)
254
struct wacom *wacom = urb->context;
255
unsigned char *data = wacom->data;
256
struct input_dev *dev = &wacom->dev;
258
if (urb->status) return;
260
if (data[0] != 2 && data[0] != 5)
262
printk(KERN_INFO "wacom_ptu_irq: received unknown report #%d\n", data[0]);
263
wacom_request_reset(wacom);
269
input_report_key(dev, BTN_TOOL_RUBBER, data[1] & 0x20);
270
input_report_key(dev, BTN_TOUCH, data[1] & 0x08);
274
input_report_key(dev, BTN_TOOL_PEN, data[1] & 0x20);
275
input_report_key(dev, BTN_TOUCH, data[1] & 0x01);
277
input_report_abs(dev, ABS_X, data[3] << 8 | data[2]);
278
input_report_abs(dev, ABS_Y, data[5] << 8 | data[4]);
279
input_report_abs(dev, ABS_PRESSURE, (data[6]|data[7] << 8));
280
input_report_key(dev, BTN_STYLUS, data[1] & 0x02);
281
input_report_key(dev, BTN_STYLUS2, data[1] & 0x10);
283
input_event(dev, EV_MSC, MSC_SERIAL, 0);
287
static void wacom_penpartner_irq(struct urb *urb)
289
struct wacom *wacom = urb->context;
290
unsigned char *data = wacom->data;
291
struct input_dev *dev = &wacom->dev;
292
int leftmb = (((signed char)data[6] > -80) && !(data[5] &0x20));
294
if (urb->status) return;
296
if (data[0] != 2 && data[0] != 5)
298
printk(KERN_INFO "wacom_penpartner_irq: received unknown report #%d\n", data[0]);
299
wacom_request_reset(wacom);
303
input_report_key(dev, BTN_TOOL_PEN, 1);
304
input_report_abs(dev, ABS_X, data[2] << 8 | data[1]);
305
input_report_abs(dev, ABS_Y, data[4] << 8 | data[3]);
306
input_report_abs(dev, ABS_PRESSURE, (signed char)data[6] + 127);
307
input_report_key(dev, BTN_TOUCH, leftmb);
308
input_report_key(dev, BTN_STYLUS, (data[5] & 0x40));
310
input_event(dev, EV_MSC, MSC_SERIAL, leftmb);
313
static void wacom_graphire_irq(struct urb *urb)
315
struct wacom *wacom = urb->context;
316
unsigned char *data = wacom->data;
317
struct input_dev *dev = &wacom->dev;
320
if (urb->status) return;
322
if (data[0] != 2 && data[0] != 5 )
324
printk(KERN_INFO "wacom_graphire_irq: received unknown report #%d\n", data[0]);
325
wacom_request_reset(wacom);
329
x = data[2] | ((__u32)data[3] << 8);
330
y = data[4] | ((__u32)data[5] << 8);
332
switch ((data[1] >> 5) & 3) {
335
input_report_key(dev, BTN_TOOL_PEN, data[1] & 0x80);
339
input_report_key(dev, BTN_TOOL_RUBBER, data[1] & 0x80);
342
case 2: /* Mouse with wheel */
343
input_report_key(dev, BTN_MIDDLE, data[1] & 0x04);
344
input_report_rel(dev, REL_WHEEL, (signed char) data[6]);
347
case 3: /* Mouse without wheel */
348
input_report_key(dev, BTN_TOOL_MOUSE, data[7] > 24);
349
input_report_key(dev, BTN_LEFT, data[1] & 0x01);
350
input_report_key(dev, BTN_RIGHT, data[1] & 0x02);
351
input_report_abs(dev, ABS_DISTANCE, data[7]);
353
input_report_abs(dev, ABS_X, x);
354
input_report_abs(dev, ABS_Y, y);
356
input_event(dev, EV_MSC, MSC_SERIAL, data[1] & 0x01);
360
if (data[1] & 0x80) {
361
input_report_abs(dev, ABS_X, x);
362
input_report_abs(dev, ABS_Y, y);
365
input_report_abs(dev, ABS_PRESSURE, data[6] | ((__u32)data[7] << 8));
366
input_report_key(dev, BTN_TOUCH, data[1] & 0x01);
367
input_report_key(dev, BTN_STYLUS, data[1] & 0x02);
368
input_report_key(dev, BTN_STYLUS2, data[1] & 0x04);
370
input_event(dev, EV_MSC, MSC_SERIAL, data[1] & 0x01);
373
static int wacom_intuos_inout(struct urb *urb)
375
struct wacom *wacom = urb->context;
376
unsigned char *data = wacom->data;
377
struct input_dev *dev = &wacom->dev;
381
idx = data[1] & 0x01;
384
if ((data[1] & 0xfc) == 0xc0)
386
/* serial number of the tool */
387
wacom->serial[idx] = ((__u32)(data[3] & 0x0f) << 28) +
388
((__u32)data[4] << 20) + ((__u32)data[5] << 12) +
389
((__u32)data[6] << 4) + ((__u32)data[7] >> 4);
392
printk(KERN_INFO "wacom_intuos_irq: tool change 0x%03X\n",
393
(((__u32)data[2] << 4) | (data[3] >> 4)));
396
switch ((((__u32)data[2] << 4) | (data[3] >> 4)))
398
case 0x812: /* Intuos2 ink pen XP-110-00A */
399
case 0x801: /* Intuos3 Inking pen */
400
case 0x012: /* Inking pen */
401
wacom->tool[idx] = BTN_TOOL_PENCIL; break;
403
case 0x822: /* Intuos Pen GP-300E-01H */
404
case 0x852: /* Intuos2 Grip Pen XP-501E-00A */
405
case 0x842: /* Designer Pen */
406
case 0x823: /* Intuos3 Grip Pen */
407
case 0x813: /* Intuos3 Classic Pen */
408
case 0x885: /* Intuos3 Marker Pen */
410
wacom->tool[idx] = BTN_TOOL_PEN; break;
412
case 0x832: /* Intuos2 stroke pen XP-120-00A */
413
case 0x032: /* Stroke pen */
414
wacom->tool[idx] = BTN_TOOL_BRUSH; break;
416
case 0x007: /* 2D Mouse */
417
case 0x09C: /* ?? Mouse - not a valid code according to Wacom */
418
case 0x094: /* 4D Mouse */
419
case 0x017: /* Intuos3 2D Mouse */
420
wacom->tool[idx] = BTN_TOOL_MOUSE; break;
422
case 0x096: /* Lens cursor */
423
case 0x097: /* Intuos3 Lens cursor */
424
wacom->tool[idx] = BTN_TOOL_LENS; break;
430
case 0x0FA: /* Eraser */
431
case 0x82B: /* Intuos3 Grip Pen Eraser */
432
case 0x81B: /* Intuos3 Classic Pen Eraser */
433
case 0x91B: /* Intuos3 Airbrush Eraser */
434
wacom->tool[idx] = BTN_TOOL_RUBBER; break;
436
case 0x112: /* Airbrush */
437
case 0x912: /* Intuos2 Airbrush */
438
case 0xD12: /* Intuos Airbrush */
439
case 0x913: /* Intuos3 Airbrush */
440
wacom->tool[idx] = BTN_TOOL_AIRBRUSH; break;
442
default: /* Unknown tool */
443
wacom->tool[idx] = BTN_TOOL_PEN; break;
445
input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
450
if ((data[1] & 0xfe) == 0x80)
452
input_report_key(dev, wacom->tool[idx], 0);
453
input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
460
static void wacom_intuos_general(struct urb *urb)
462
struct wacom *wacom = urb->context;
463
unsigned char *data = wacom->data;
464
struct input_dev *dev = &wacom->dev;
467
/* general pen packet */
468
if ((data[1] & 0xb8) == 0xa0)
470
t = ((__u32)data[6] << 2) | ((data[7] >> 6) & 3);
471
input_report_abs(dev, ABS_PRESSURE, t);
472
input_report_abs(dev, ABS_TILT_X,
473
((data[7] << 1) & 0x7e) | (data[8] >> 7));
474
input_report_abs(dev, ABS_TILT_Y, data[8] & 0x7f);
475
input_report_key(dev, BTN_STYLUS, data[1] & 2);
476
input_report_key(dev, BTN_STYLUS2, data[1] & 4);
477
input_report_key(dev, BTN_TOUCH, t > 10);
480
/* airbrush second packet */
481
if ((data[1] & 0xbc) == 0xb4)
483
input_report_abs(dev, ABS_WHEEL,
484
((__u32)data[6] << 2) | ((data[7] >> 6) & 3));
485
input_report_abs(dev, ABS_TILT_X,
486
((data[7] << 1) & 0x7e) | (data[8] >> 7));
487
input_report_abs(dev, ABS_TILT_Y, data[8] & 0x7f);
492
static void wacom_intuos_irq(struct urb *urb)
494
struct wacom *wacom = urb->context;
495
unsigned char *data = wacom->data;
496
struct input_dev *dev = &wacom->dev;
500
if (urb->status) return;
502
/* check for valid report */
503
if (data[0] != 2 && data[0] != 5 && data[0] != 6)
505
printk(KERN_INFO "wacom_intuos_irq: received unknown report #%d\n", data[0]);
506
wacom_request_reset(wacom);
511
idx = data[1] & 0x01;
513
/* process in/out prox events */
514
if (wacom_intuos_inout(urb)) return;
516
input_report_abs(dev, ABS_X, ((__u32)data[2] << 8) | data[3]);
517
input_report_abs(dev, ABS_Y, ((__u32)data[4] << 8) | data[5]);
518
input_report_abs(dev, ABS_DISTANCE, data[9]);
520
/* process general packets */
521
wacom_intuos_general(urb);
523
/* 4D mouse, 2D mouse, or Lens cursor packets */
524
if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0)
526
/* Rotation packet */
529
t = ((__u32)data[6] << 3) | ((data[7] >> 5) & 7);
530
input_report_abs(dev, ABS_RZ, (data[7] & 0x20) ?
531
((t - 1) / 2) : -t / 2);
534
/* 4D mouse packets */
535
else if ((data[1] & 0x10) == 0)
537
input_report_key(dev, BTN_LEFT, data[8] & 0x01);
538
input_report_key(dev, BTN_MIDDLE, data[8] & 0x02);
539
input_report_key(dev, BTN_RIGHT, data[8] & 0x04);
540
input_report_key(dev, BTN_SIDE, data[8] & 0x20);
541
input_report_key(dev, BTN_EXTRA, data[8] & 0x10);
542
/* JEJ - throttle is positive when rolled backwards */
543
t = ((__u32)data[6] << 2) | ((data[7] >> 6) & 3);
544
input_report_abs(dev, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
547
/* 2D mouse packets */
548
else if (wacom->tool[idx] == BTN_TOOL_MOUSE)
550
/* JEJ - validated with 2D Intuos2 mouse */
551
input_report_key(dev, BTN_LEFT, data[8] & 0x04);
552
input_report_key(dev, BTN_MIDDLE, data[8] & 0x08);
553
input_report_key(dev, BTN_RIGHT, data[8] & 0x10);
554
/* JEJ - mouse wheel is positive when rolled backwards */
555
input_report_rel(dev, REL_WHEEL, (__u32)((data[8] & 0x02) >> 1)
556
- (__u32)(data[8] & 0x01));
559
/* lens cursor packets */
562
input_report_key(dev, BTN_LEFT, data[8] & 0x01);
563
input_report_key(dev, BTN_MIDDLE, data[8] & 0x02);
564
input_report_key(dev, BTN_RIGHT, data[8] & 0x04);
565
input_report_key(dev, BTN_SIDE, data[8] & 0x10);
566
input_report_key(dev, BTN_EXTRA, data[8] & 0x08);
570
input_report_key(dev, wacom->tool[idx], 1);
571
input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
574
static void wacom_intuos3_irq(struct urb *urb)
576
struct wacom *wacom = urb->context;
577
unsigned char *data = wacom->data;
578
struct input_dev *dev = &wacom->dev;
582
if (urb->status) return;
584
/* check for valid report */
585
if (data[0] != 2 && data[0] != 5 && data[0] != 12)
587
printk(KERN_INFO "wacom_intuos3_irq: received unknown report #%d\n", data[0]);
588
wacom_request_reset(wacom);
592
/* tool index is always 0 here since there is no dual input tool */
593
idx = data[1] & 0x01;
595
/* pad packets. Works as a second tool and is alway in prox */
598
/* initiate the pad as a device */
599
if (wacom->tool[1] != BTN_TOOL_FINGER)
601
wacom->tool[1] = BTN_TOOL_FINGER;
602
input_report_key(dev, wacom->tool[1], 1);
604
input_report_key(dev, BTN_0, (data[5] & 0x01));
605
input_report_key(dev, BTN_1, (data[5] & 0x02));
606
input_report_key(dev, BTN_2, (data[5] & 0x04));
607
input_report_key(dev, BTN_3, (data[5] & 0x08));
608
input_report_key(dev, BTN_4, (data[6] & 0x01));
609
input_report_key(dev, BTN_5, (data[6] & 0x02));
610
input_report_key(dev, BTN_6, (data[6] & 0x04));
611
input_report_key(dev, BTN_7, (data[6] & 0x08));
612
input_report_abs(dev, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
613
input_report_abs(dev, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
614
input_event(dev, EV_MSC, MSC_SERIAL, 0xffffffff);
618
/* process in/out prox events */
619
if (wacom_intuos_inout(urb)) return;
621
input_report_abs(dev, ABS_X, ((__u32)data[2] << 9) | ((__u32)data[3] << 1) | ((data[9] >> 1) & 1));
622
input_report_abs(dev, ABS_Y, ((__u32)data[4] << 9) | ((__u32)data[5] << 1) | (data[9] & 1));
623
input_report_abs(dev, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
625
/* process general packets */
626
wacom_intuos_general(urb);
628
if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0)
630
/* Marker pen rotation packet. Reported as wheel due to valuator limitation */
633
t = ((__u32)data[6] << 3) | ((data[7] >> 5) & 7);
634
t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
635
((t-1) / 2 + 450)) : (450 - t / 2) ;
636
input_report_abs(dev, ABS_WHEEL, t);
639
/* 2D mouse packets */
640
if (wacom->tool[idx] == BTN_TOOL_MOUSE)
642
input_report_key(dev, BTN_LEFT, data[8] & 0x04);
643
input_report_key(dev, BTN_MIDDLE, data[8] & 0x08);
644
input_report_key(dev, BTN_RIGHT, data[8] & 0x10);
645
input_report_key(dev, BTN_SIDE, data[8] & 0x40);
646
input_report_key(dev, BTN_EXTRA, data[8] & 0x20);
647
/* mouse wheel is positive when rolled backwards */
648
input_report_rel(dev, REL_WHEEL, (__u32)((data[8] & 0x02) >> 1)
649
- (__u32)(data[8] & 0x01));
653
input_report_key(dev, wacom->tool[idx], 1);
654
input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
657
#define WACOM_GRAPHIRE_BITS (BIT(EV_REL))
658
#define WACOM_GRAPHIRE_REL (BIT(REL_WHEEL))
659
#define WACOM_INTUOS_TOOLS (BIT(BTN_TOOL_BRUSH) | BIT(BTN_TOOL_PENCIL) | BIT(BTN_TOOL_AIRBRUSH) | BIT(BTN_TOOL_LENS))
660
#define WACOM_INTUOS3_TOOLS (WACOM_INTUOS_TOOLS | BIT(BTN_TOOL_FINGER))
661
#define WACOM_INTUOS_BUTTONS (BIT(BTN_SIDE) | BIT(BTN_EXTRA))
662
#define WACOM_INTUOS3_BUTTONS (WACOM_INTUOS_BUTTONS | BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7))
663
#define WACOM_INTUOS_BITS (BIT(EV_REL))
664
#define WACOM_INTUOS_REL (BIT(REL_WHEEL))
665
#define WACOM_INTUOS_ABS (BIT(ABS_TILT_X) | BIT(ABS_TILT_Y) | BIT(ABS_RZ) | BIT(ABS_THROTTLE))
666
#define WACOM_INTUOS3_ABS (WACOM_INTUOS_ABS | BIT(ABS_RX) | BIT(ABS_RY))
668
struct wacom_features wacom_features[] = {
671
/* 0 */ { "Wacom Penpartner", 7, 5040, 3780, 255, 32,
672
wacom_penpartner_irq, 0, 0, 0, 0 },
675
/* 1 */ { "Wacom Graphire", 8, 10206, 7422, 511, 32,
676
wacom_graphire_irq, WACOM_GRAPHIRE_BITS, 0, WACOM_GRAPHIRE_REL, 0 },
677
/* 2 */ { "Wacom Graphire2 4x5", 8, 10206, 7422, 511, 32,
678
wacom_graphire_irq, WACOM_GRAPHIRE_BITS, 0, WACOM_GRAPHIRE_REL, 0 },
679
/* 3 */ { "Wacom Graphire2 5x7", 8, 13918, 10206, 511, 32,
680
wacom_graphire_irq, WACOM_GRAPHIRE_BITS, 0, WACOM_GRAPHIRE_REL, 0 },
683
/* 4 */ { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 15,
684
wacom_intuos_irq, WACOM_INTUOS_BITS, WACOM_INTUOS_ABS,
685
WACOM_INTUOS_REL, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
686
/* JEJ - confirmed X and Y range from test tablet */
687
/* 5 */ { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 15,
688
wacom_intuos_irq, WACOM_INTUOS_BITS, WACOM_INTUOS_ABS,
689
WACOM_INTUOS_REL, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
690
/* 6 */ { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 15,
691
wacom_intuos_irq, WACOM_INTUOS_BITS, WACOM_INTUOS_ABS,
692
WACOM_INTUOS_REL, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
693
/* 7 */ { "Wacom Intuos 12x12", 10, 30480, 31680, 1023, 15,
694
wacom_intuos_irq, WACOM_INTUOS_BITS, WACOM_INTUOS_ABS,
695
WACOM_INTUOS_REL, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
696
/* 8 */ { "Wacom Intuos 12x18", 10, 45720, 31680, 1023, 15,
697
wacom_intuos_irq, WACOM_INTUOS_BITS, WACOM_INTUOS_ABS,
698
WACOM_INTUOS_REL, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
701
/* 9 */ { "Wacom PL400", 8, 5408, 4056, 255, 32,
702
wacom_pl_irq, 0, 0, 0, 0 },
703
/* 10 */ { "Wacom PL500", 8, 6144, 4608, 255, 32,
704
wacom_pl_irq, 0, 0, 0, 0 },
705
/* 11 */ { "Wacom PL600", 8, 6126, 4604, 255, 32,
706
wacom_pl_irq, 0, 0, 0, 0 },
707
/* 12 */ { "Wacom PL600SX", 8, 6260, 5016, 255, 32,
708
wacom_pl_irq, 0, 0, 0, 0 },
709
/* 13 */ { "Wacom PL550", 8, 6144, 4608, 511, 32,
710
wacom_pl_irq, 0, 0, 0, 0 },
711
/* 14 */ { "Wacom PL800", 8, 7220, 5780, 511, 32,
712
wacom_pl_irq, 0, 0, 0, 0 },
715
/* JEJ - confirmed X and Y range from J.N. tablet */
716
/* 15 */ { "Wacom Intuos2 4x5", 10, 12700, 10600, 1023, 15,
717
wacom_intuos_irq, WACOM_INTUOS_BITS, WACOM_INTUOS_ABS,
718
WACOM_INTUOS_REL, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
719
/* JEJ - confirmed X and Y range from R.T. and J.S. tablets */
720
/* 16 */ { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15,
721
wacom_intuos_irq, WACOM_INTUOS_BITS, WACOM_INTUOS_ABS,
722
WACOM_INTUOS_REL, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
723
/* JEJ - values from serial 9x12 */
724
/* 17 */ { "Wacom Intuos2 9x12", 10, 30480, 24060, 1023, 15,
725
wacom_intuos_irq, WACOM_INTUOS_BITS, WACOM_INTUOS_ABS,
726
WACOM_INTUOS_REL, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
727
/* JEJ - confirmed X and Y range from J.J. tablet */
728
/* 18 */ { "Wacom Intuos2 12x12", 10, 30480, 31680, 1023, 15,
729
wacom_intuos_irq, WACOM_INTUOS_BITS, WACOM_INTUOS_ABS,
730
WACOM_INTUOS_REL, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
731
/* 19 */ { "Wacom Intuos2 12x18", 10, 45720, 31680, 1023, 15,
732
wacom_intuos_irq, WACOM_INTUOS_BITS, WACOM_INTUOS_ABS,
733
WACOM_INTUOS_REL, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
734
/* Volito - (Graphire2 4x5 no mouse wheel) */
735
/* 20 */ { "Wacom Volito", 8, 5104, 3712, 511, 32,
736
wacom_graphire_irq, WACOM_GRAPHIRE_BITS, 0, 0, 0 },
737
/* 21 */ { "Wacom Graphire3 4x5", 8, 10208, 7424, 511, 32,
738
wacom_graphire_irq, WACOM_GRAPHIRE_BITS, 0, WACOM_GRAPHIRE_REL, 0 },
739
/* 22 */ { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 32,
740
wacom_graphire_irq, WACOM_GRAPHIRE_BITS, 0, WACOM_GRAPHIRE_REL, 0 },
741
/* 23 */ { "Wacom Cintiq Partner", 8, 20480, 15360, 511, 32,
742
wacom_ptu_irq, 0, 0, 0, 0 },
744
/* 24 */ { "Wacom Intuos3 4x5", 10, 25400, 20320, 1023, 15,
745
wacom_intuos3_irq, WACOM_INTUOS_BITS, WACOM_INTUOS3_ABS,
746
WACOM_INTUOS_REL, WACOM_INTUOS3_BUTTONS, WACOM_INTUOS3_TOOLS },
747
/* 25 */ { "Wacom Intuos3 6x8", 10, 40640, 30480, 1023, 15,
748
wacom_intuos3_irq, WACOM_INTUOS_BITS, WACOM_INTUOS3_ABS,
749
WACOM_INTUOS_REL, WACOM_INTUOS3_BUTTONS, WACOM_INTUOS3_TOOLS },
750
/* 26 */ { "Wacom Intuos3 9x12", 10, 60960, 45720, 1023, 15,
751
wacom_intuos3_irq, WACOM_INTUOS_BITS, WACOM_INTUOS3_ABS,
752
WACOM_INTUOS_REL, WACOM_INTUOS3_BUTTONS, WACOM_INTUOS3_TOOLS },
757
struct usb_device_id wacom_ids[] = {
758
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x00), driver_info: 0 },
759
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x10), driver_info: 1 },
760
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x11), driver_info: 2 },
761
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x12), driver_info: 3 },
762
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x20), driver_info: 4 },
763
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x21), driver_info: 5 },
764
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x22), driver_info: 6 },
765
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x23), driver_info: 7 },
766
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x24), driver_info: 8 },
767
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x30), driver_info: 9 },
768
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x31), driver_info: 10 },
769
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x32), driver_info: 11 },
770
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x33), driver_info: 12 },
771
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x34), driver_info: 13 },
772
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x35), driver_info: 14 },
773
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x41), driver_info: 15 },
774
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x42), driver_info: 16 },
775
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x43), driver_info: 17 },
776
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x44), driver_info: 18 },
777
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x45), driver_info: 19 },
778
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60), driver_info: 20 },
779
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x13), driver_info: 21 },
780
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x14), driver_info: 22 },
781
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x03), driver_info: 23 },
782
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB0), driver_info: 24 },
783
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB1), driver_info: 25 },
784
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB2), driver_info: 26 },
786
/* some Intuos2 6x8's erroneously report as 0x47;
787
* multiple confirmed examples exist. */
788
{ USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47), driver_info: 16 },
793
MODULE_DEVICE_TABLE(usb, wacom_ids);
795
static int wacom_open(struct input_dev *dev)
797
struct wacom *wacom = dev->private;
802
wacom->irq.dev = wacom->usbdev;
803
if (usb_submit_urb(&wacom->irq))
809
static void wacom_close(struct input_dev *dev)
811
struct wacom *wacom = dev->private;
814
usb_unlink_urb(&wacom->irq);
817
static void wacom_reset(struct wacom* wacom)
819
unsigned char edata[2], limit=0;
821
printk(KERN_INFO __FILE__ ": Setting tablet report for tablet data\n");
824
/* ask the tablet to report tablet data. repeats until it succeeds */
828
usb_set_report(wacom->usbdev, wacom->ifnum, 3, 2, edata, 2);
829
usb_get_report(wacom->usbdev, wacom->ifnum, 3, 2, edata, 2);
830
} while (edata[1] != 2 && limit++ < 5);
833
static void *wacom_probe(struct usb_device *dev, unsigned int ifnum, const struct usb_device_id *id)
835
struct usb_endpoint_descriptor *endpoint;
838
if (!(wacom = kmalloc(sizeof(struct wacom), GFP_KERNEL))) return NULL;
839
memset(wacom, 0, sizeof(struct wacom));
841
wacom->features = wacom_features + id->driver_info;
843
wacom->dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC) |
844
wacom->features->evbit;
845
wacom->dev.absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE) |
846
BIT(ABS_DISTANCE) | BIT(ABS_WHEEL) | wacom->features->absbit;
847
wacom->dev.relbit[0] |= wacom->features->relbit;
848
wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) |
849
BIT(BTN_MIDDLE) | wacom->features->btnbit;
850
wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) |
851
BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) |
852
BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2) |
853
wacom->features->digibit;
854
wacom->dev.mscbit[0] |= BIT(MSC_SERIAL);
857
printk(KERN_INFO "Reporting max %d, %d\n",
858
wacom->features->x_max, wacom->features->y_max);
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
wacom->dev.name = wacom->features->name;
884
wacom->dev.idbus = BUS_USB;
885
wacom->dev.idvendor = dev->descriptor.idVendor;
886
wacom->dev.idproduct = dev->descriptor.idProduct;
887
wacom->dev.idversion = dev->descriptor.bcdDevice;
889
wacom->ifnum = ifnum;
891
INIT_LIST_HEAD(&wacom->event_list);
892
init_MUTEX(&wacom->kwacomd_sem);
894
endpoint = dev->config[0].interface[ifnum].altsetting[0].endpoint + 0;
896
usb_set_idle(dev, dev->config[0].interface[ifnum].altsetting[0].bInterfaceNumber, 0, 0);
898
FILL_INT_URB(&wacom->irq, dev, usb_rcvintpipe(dev,
899
endpoint->bEndpointAddress), wacom->data, wacom->features->pktlen,
900
wacom->features->irq, wacom, endpoint->bInterval);
902
input_register_device(&wacom->dev);
906
printk(KERN_INFO __FILE__ ": input%d: %s on usb%d:%d.%d\n",
907
wacom->dev.number, wacom->features->name, dev->bus->busnum,
913
static void wacom_disconnect(struct usb_device *dev, void *ptr)
916
struct wacom *wacom = ptr;
919
spin_lock_irqsave(&wacom_event_lock, flags);
920
list_del(&wacom->event_list);
921
INIT_LIST_HEAD(&wacom->event_list);
922
spin_unlock_irqrestore(&wacom_event_lock, flags);
924
/* Wait for kwacomd to leave this tablet alone. */
925
down(&wacom->kwacomd_sem);
926
up(&wacom->kwacomd_sem);
928
usb_unlink_urb(&wacom->irq);
929
input_unregister_device(&wacom->dev);
934
static void wacom_events(void)
938
struct list_head *tmp;
940
printk(KERN_INFO "wacom_events\n");
944
spin_lock_irqsave(&wacom_event_lock, flags);
946
if (list_empty(&wacom_event_list))
949
/* Grab the next entry from the beginning of the list */
950
tmp = wacom_event_list.next;
951
wacom = list_entry(tmp, struct wacom, event_list);
953
list_del(tmp); /* dequeue tablet */
956
if (down_trylock(&wacom->kwacomd_sem) != 0) BUG(); /* never blocks */
957
spin_unlock_irqrestore(&wacom_event_lock, flags);
961
up(&wacom->kwacomd_sem); /* mark tablet free */
963
spin_unlock_irqrestore(&wacom_event_lock, flags);
966
static int wacom_thread(void* pv)
971
/* Setup a nice name */
972
strcpy(current->comm, "kwacomd");
974
/* Send me a signal to get me die (for debugging) */
975
while (!signal_pending(current))
978
wait_event_interruptible(kwacomd_wait, !list_empty(&wacom_event_list));
981
complete_and_exit(&kwacomd_exited, 0);
985
static struct usb_driver wacom_driver = {
988
disconnect: wacom_disconnect,
992
static int __init wacom_init(void)
996
usb_register(&wacom_driver);
997
info(DRIVER_VERSION " " DRIVER_AUTHOR);
1000
pid = kernel_thread(wacom_thread, NULL,
1001
CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
1009
/* Fall through if kernel_thread failed */
1010
usb_deregister(&wacom_driver);
1011
err("failed to start wacom_thread");
1016
static void __exit wacom_exit(void)
1020
/* Kill the thread */
1021
ret = kill_proc(kwacomd_pid, SIGTERM, 1);
1022
wait_for_completion(&kwacomd_exited);
1024
usb_deregister(&wacom_driver);
1027
module_init(wacom_init);
1028
module_exit(wacom_exit);