* updated kmbox (21.12.1 -> 21.12.2), untested
[t2-trunk.git] / package / x11 / linuxwacom / wacom_24.diff
blob78ba2c9daaf49d7549c0ccde330f188ac67f21b5
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
3 #
4 # T2 SDE: package/.../linuxwacom/wacom_24.diff
5 # Copyright (C) 2004 - 2005 The T2 SDE Project
6 #
7 # More information can be found in the files COPYING and README.
8 #
9 # This patch file is dual-licensed. It is available under the license the
10 # patched project is licensed under, as long as it is an OpenSource license
11 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
12 # of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
14 # version.
15 # --- T2-COPYRIGHT-NOTE-END ---
16 diff -Naur linux-2.4.30_orig/drivers/usb/wacom.c linux-2.4.30/drivers/usb/wacom.c
17 --- linux-2.4.30_orig/drivers/usb/wacom.c 2002-11-29 00:53:15.000000000 +0100
18 +++ linux-2.4.30/drivers/usb/wacom.c 2005-03-29 00:52:09.000000000 +0200
19 @@ -1,15 +1,18 @@
21 - * $Id: wacom.c,v 1.23 2001/05/29 12:57:18 vojtech Exp $
22 + * $Id: wacom.c,v 1.12 2005/03/18 18:17:44 pingc Exp $
24 - * Copyright (c) 2000-2001 Vojtech Pavlik <vojtech@suse.cz>
25 - * Copyright (c) 2000 Andreas Bach Aaen <abach@stofanet.dk>
26 - * Copyright (c) 2000 Clifford Wolf <clifford@clifford.at>
27 - * Copyright (c) 2000 Sam Mosel <sam.mosel@computer.org>
28 - * Copyright (c) 2000 James E. Blair <corvus@gnu.org>
29 - * Copyright (c) 2000 Daniel Egger <egger@suse.de>
30 - * Copyright (c) 2001 Frederic Lepied <flepied@mandrakesoft.com>
31 + * Copyright (c) 2000-2002 Vojtech Pavlik <vojtech@suse.cz>
32 + * Copyright (c) 2000 Andreas Bach Aaen <abach@stofanet.dk>
33 + * Copyright (c) 2000 Clifford Wolf <clifford@clifford.at>
34 + * Copyright (c) 2000 Sam Mosel <sam.mosel@computer.org>
35 + * Copyright (c) 2000 James E. Blair <corvus@gnu.org>
36 + * Copyright (c) 2000 Daniel Egger <egger@suse.de>
37 + * Copyright (c) 2001 Frederic Lepied <flepied@mandrakesoft.com>
38 + * Copyright (c) 2002 Christer Nilsson <christer.nilsson@kretskompaniet.se>
39 + * Copyright (c) 2002-2005 Ping Cheng <pingc@wacom.com>
40 + * Copyright (c) 2002 John Joganic <john@joganic.com>
42 - * USB Wacom Graphire and Wacom Intuos tablet support
43 + * USB Wacom Graphire and Intuos tablet support
45 * Sponsored by SuSE
47 @@ -46,6 +49,41 @@
48 * - added smooth filter for Graphire from Peri Hankey
49 * - added PenPartner support from Olaf van Es
50 * - new tool ids from Ole Martin Bjoerndalen
51 + * v1.29 (pc) - Add support for more tablets
52 + * - Fix pressure reporting
53 + * v1.30 (vp) - Merge 2.4 and 2.5 drivers
54 + * - Since 2.5 now has input_sync(), remove MSC_SERIAL abuse
55 + * - Cleanups here and there
56 + *
57 + * WARNING: THIS IS NOT PART OF THE OFFICIAL KERNEL TREE
58 + * THIS IS FOR TESTING PURPOSES
59 + *
60 + * v1.21.3-j0 - fixed absolute x and y for intuos by John Joganic
61 + * v1.21.3-j1 - applied Christer Nilsson's patches for 2.4.20
62 + * v1.30.1-j0 - applied Ping Cheng's patches for device ranges and caps
63 + * v1.30.1-j1 - updated device ranges for Intuos2 12x12 (0x44)
64 + * v1.30.1-j2 - updated device ranges for Intuos2 6x8 (0x42)
65 + * v1.30-j0.3.1 - fixed pen identifers, 2D mouse handling
66 + * v1.30-j0.3.3 - added volito, thanks to Pasi Savolainen; fixed wheel sign
67 + * v1.30-j0.3.4 - added Ping Cheng's new tool IDs
68 + * v1.30-j0.3.5 - thread for resetting tablet on bad report
69 + * v1.30-j0.3.6 - fixed volito ranges, thanks to Pasi Savolainen
70 + * v1.30-j0.3.7 - unknown reports are now info, rather than error
71 + * v1.30-j0.3.8 - fixed I2 4x5 Y max value, thanks to John New
72 + * fixed Intuos and Intuos2 sizes, values from Wacom
73 + * v1.30-j0.5.0 - new release
74 + * v1.30-j0.5.1 - fixed serial number code for Intuos and Intuos2
75 + * v1.30-j0.5.2 - applied Ping Cheng's eraser patch for PL
76 + * v1.30-j0.5.3 - reapplied patch for Intuos2 6x8's reportings as (0x47)
77 + * v1.30-j0.6.0 - new release
78 + * v1.30-j0.6.1 - new release
79 + * v1.30-j0.6.2 - new release
80 + * v1.30-j0.6.3 - new release
81 + * v1.30-j0.6.4 - new release
82 + * v1.30-j0.6.5 - added Intuos3
83 + * v1.30-j0.6.6 - new release
84 + * v1.30-j0.6.7 - fixed a Graphire bug
85 + * v1.30-j0.6.8 - added Cintiq 21UX
89 @@ -53,41 +91,49 @@
90 * it under the terms of the GNU General Public License as published by
91 * the Free Software Foundation; either version 2 of the License, or
92 * (at your option) any later version.
93 - *
94 - * This program is distributed in the hope that it will be useful,
95 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
96 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
97 - * GNU General Public License for more details.
98 - *
99 - * You should have received a copy of the GNU General Public License
100 - * along with this program; if not, write to the Free Software
101 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
103 - * Should you need to contact me, the author, you can do so either by
104 - * e-mail - mail your message to <vojtech@suse.cz>, or by paper mail:
105 - * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic
108 +#include <linux/autoconf.h>
109 +#if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)
110 +# define MODVERSIONS
111 +#endif
113 +#ifdef MODVERSIONS
114 +#include <linux/modversions.h>
115 +#endif
117 #include <linux/kernel.h>
118 #include <linux/slab.h>
119 #include <linux/input.h>
120 #include <linux/module.h>
121 #include <linux/init.h>
122 #include <linux/usb.h>
123 +#include <linux/smp_lock.h>
124 +#include <linux/list.h>
127 * Version Information
129 -#define DRIVER_VERSION "v1.21.3"
130 +#define DRIVER_VERSION "v1.30-j0.6.8"
131 #define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@suse.cz>"
132 -#define DRIVER_DESC "USB Wacom Graphire and Wacom Intuos tablet driver"
133 +#ifndef __JEJ_DEBUG
134 +#define DRIVER_DESC "USB Wacom Graphire and Wacom Intuos tablet driver (LINUXWACOM)"
135 +#else
136 +#define DRIVER_DESC "USB Wacom Graphire and Wacom Intuos tablet driver (LINUXWACOM-DEBUG)"
137 +#endif
139 -MODULE_AUTHOR( DRIVER_AUTHOR );
140 -MODULE_DESCRIPTION( DRIVER_DESC );
141 +MODULE_AUTHOR(DRIVER_AUTHOR);
142 +MODULE_DESCRIPTION(DRIVER_DESC);
143 MODULE_LICENSE("GPL");
145 #define USB_VENDOR_ID_WACOM 0x056a
147 +static int kwacomd_pid = 0; /* PID of kwacomd */
148 +static DECLARE_COMPLETION(kwacomd_exited);
149 +static DECLARE_WAIT_QUEUE_HEAD(kwacomd_wait);
150 +static LIST_HEAD(wacom_event_list); /* List of tablets needing servicing */
151 +static spinlock_t wacom_event_lock = SPIN_LOCK_UNLOCKED;
153 struct wacom_features {
154 char *name;
155 int pktlen;
156 @@ -112,64 +158,157 @@
157 int tool[2];
158 int open;
159 __u32 serial[2];
161 + struct list_head event_list;
162 + struct semaphore kwacomd_sem;
163 + unsigned int ifnum;
166 +static void wacom_request_reset(struct wacom* wacom)
168 + unsigned long flags;
169 + spin_lock_irqsave(&wacom_event_lock, flags);
170 + if (list_empty(&wacom->event_list))
172 + list_add(&wacom->event_list, &wacom_event_list);
173 + wake_up(&kwacomd_wait);
175 + spin_unlock_irqrestore(&wacom_event_lock, flags);
178 static void wacom_pl_irq(struct urb *urb)
180 struct wacom *wacom = urb->context;
181 unsigned char *data = wacom->data;
182 struct input_dev *dev = &wacom->dev;
183 - int prox;
184 + int prox, pressure;
186 if (urb->status) return;
188 - if (data[0] != 2) {
189 - printk(KERN_ERR "wacom_pl_irq: received unknown report #%d\n", data[0]);
190 + if (data[0] != 2 && data[0] != 5)
192 + printk(KERN_INFO "wacom_pl_irq: received unknown report #%d\n", data[0]);
193 + wacom_request_reset(wacom);
194 return;
197 - prox = data[1] & 0x20;
199 - input_report_key(dev, BTN_TOOL_PEN, prox);
201 + /* proximity and pressure */
202 + prox = data[1] & 0x40;
204 if (prox) {
205 - int pressure = (data[4] & 0x04) >> 2 | ((__u32)(data[7] & 0x7f) << 1);
206 + pressure = (signed char) ((data[7] <<1 ) | ((data[4] >> 2) & 1));
207 + if ( wacom->features->pressure_max > 350 ) {
208 + pressure = (pressure << 1) | ((data[4] >> 6) & 1);
209 + }
210 + pressure += (( wacom->features->pressure_max + 1 )/ 2);
212 + /*
213 + * if going from out of proximity into proximity select between the eraser
214 + * and the pen based on the state of the stylus2 button, choose eraser if
215 + * pressed else choose pen. if not a proximity change from out to in, send
216 + * an out of proximity for previous tool then a in for new tool.
217 + */
218 + if (!wacom->tool[0]) {
219 + /* Going into proximity select tool */
220 + wacom->tool[1] = (data[4] & 0x20)? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
222 + else {
223 + /* was entered with stylus2 pressed */
224 + if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20) ) {
225 + /* report out proximity for previous tool */
226 + input_report_key(dev, wacom->tool[1], 0);
227 + input_event(dev, EV_MSC, MSC_SERIAL, 0);
228 + wacom->tool[1] = BTN_TOOL_PEN;
229 + return;
232 + if (wacom->tool[1] != BTN_TOOL_RUBBER) {
233 + /* Unknown tool selected default to pen tool */
234 + wacom->tool[1] = BTN_TOOL_PEN;
236 + input_report_key(dev, wacom->tool[1], prox); /* report in proximity for tool */
238 - input_report_abs(dev, ABS_X, data[3] | ((__u32)data[2] << 8) | ((__u32)(data[1] & 0x03) << 16));
239 - input_report_abs(dev, ABS_Y, data[6] | ((__u32)data[5] << 8) | ((__u32)(data[4] & 0x03) << 8));
240 - input_report_abs(dev, ABS_PRESSURE, (data[7] & 0x80) ? (255 - pressure) : (pressure + 255));
241 + input_report_abs(dev, ABS_X, data[3] | ((__u32)data[2] << 7) | ((__u32)(data[1] & 0x03) << 14));
242 + input_report_abs(dev, ABS_Y, data[6] | ((__u32)data[5] << 7) | ((__u32)(data[4] & 0x03) << 14));
243 + input_report_abs(dev, ABS_PRESSURE, pressure);
244 input_report_key(dev, BTN_TOUCH, data[4] & 0x08);
245 input_report_key(dev, BTN_STYLUS, data[4] & 0x10);
246 - input_report_key(dev, BTN_STYLUS2, data[4] & 0x20);
247 + /* Only allow the stylus2 button to be reported for the pen tool. */
248 + input_report_key(dev, BTN_STYLUS2, (wacom->tool[1] == BTN_TOOL_PEN) && (data[4] & 0x20));
250 + else {
251 + /* report proximity-out of a (valid) tool */
252 + if (wacom->tool[1] != BTN_TOOL_RUBBER) {
253 + /* Unknown tool selected default to pen tool */
254 + wacom->tool[1] = BTN_TOOL_PEN;
256 + input_report_key(dev, wacom->tool[1], prox);
259 + wacom->tool[0] = prox; /* Save proximity state */
260 + /* end of proximity code */
262 input_event(dev, EV_MSC, MSC_SERIAL, 0);
265 +static void wacom_ptu_irq(struct urb *urb)
267 + struct wacom *wacom = urb->context;
268 + unsigned char *data = wacom->data;
269 + struct input_dev *dev = &wacom->dev;
271 + if (urb->status) return;
273 + if (data[0] != 2 && data[0] != 5)
275 + printk(KERN_INFO "wacom_ptu_irq: received unknown report #%d\n", data[0]);
276 + wacom_request_reset(wacom);
277 + return;
280 + if (data[1] & 0x04)
282 + input_report_key(dev, BTN_TOOL_RUBBER, data[1] & 0x20);
283 + input_report_key(dev, BTN_TOUCH, data[1] & 0x08);
285 + else
287 + input_report_key(dev, BTN_TOOL_PEN, data[1] & 0x20);
288 + input_report_key(dev, BTN_TOUCH, data[1] & 0x01);
290 + input_report_abs(dev, ABS_X, data[3] << 8 | data[2]);
291 + input_report_abs(dev, ABS_Y, data[5] << 8 | data[4]);
292 + input_report_abs(dev, ABS_PRESSURE, (data[6]|data[7] << 8));
293 + input_report_key(dev, BTN_STYLUS, data[1] & 0x02);
294 + input_report_key(dev, BTN_STYLUS2, data[1] & 0x10);
296 + input_event(dev, EV_MSC, MSC_SERIAL, 0);
300 static void wacom_penpartner_irq(struct urb *urb)
302 struct wacom *wacom = urb->context;
303 unsigned char *data = wacom->data;
304 struct input_dev *dev = &wacom->dev;
305 - int x, y;
306 - char pressure;
307 - int leftmb;
308 + int leftmb = (((signed char)data[6] > -80) && !(data[5] &0x20));
310 if (urb->status) return;
312 - x = data[2] << 8 | data[1];
313 - y = data[4] << 8 | data[3];
314 - pressure = data[6];
315 - leftmb = ((pressure > -80) && !(data[5] &20));
316 + if (data[0] != 2 && data[0] != 5)
318 + printk(KERN_INFO "wacom_penpartner_irq: received unknown report #%d\n", data[0]);
319 + wacom_request_reset(wacom);
320 + return;
323 input_report_key(dev, BTN_TOOL_PEN, 1);
324 + input_report_abs(dev, ABS_X, data[2] << 8 | data[1]);
325 + input_report_abs(dev, ABS_Y, data[4] << 8 | data[3]);
326 + input_report_abs(dev, ABS_PRESSURE, (signed char)data[6] + 127);
327 + input_report_key(dev, BTN_TOUCH, leftmb);
328 + input_report_key(dev, BTN_STYLUS, (data[5] & 0x40));
330 - input_report_abs(dev, ABS_X, x);
331 - input_report_abs(dev, ABS_Y, y);
332 - input_report_abs(dev, ABS_PRESSURE, pressure+127);
333 - input_report_key(dev, BTN_LEFT, leftmb);
334 - input_report_key(dev, BTN_RIGHT, (data[5] & 0x40));
336 input_event(dev, EV_MSC, MSC_SERIAL, leftmb);
339 @@ -182,204 +321,412 @@
341 if (urb->status) return;
343 - if (data[0] != 2) {
344 - printk(KERN_ERR "wacom_graphire_irq: received unknown report #%d\n", data[0]);
345 + if (data[0] != 2)
347 + printk(KERN_INFO "wacom_graphire_irq: received unknown report #%d\n", data[0]);
348 + wacom_request_reset(wacom);
349 return;
352 - x = data[2] | ((__u32)data[3] << 8);
353 - y = data[4] | ((__u32)data[5] << 8);
355 - switch ((data[1] >> 5) & 3) {
357 - case 0: /* Pen */
358 - input_report_key(dev, BTN_TOOL_PEN, data[1] & 0x80);
359 - break;
361 - case 1: /* Rubber */
362 - input_report_key(dev, BTN_TOOL_RUBBER, data[1] & 0x80);
363 - break;
365 - case 2: /* Mouse */
366 - input_report_key(dev, BTN_TOOL_MOUSE, data[7] > 24);
367 - input_report_key(dev, BTN_LEFT, data[1] & 0x01);
368 - input_report_key(dev, BTN_RIGHT, data[1] & 0x02);
369 - input_report_key(dev, BTN_MIDDLE, data[1] & 0x04);
370 - input_report_abs(dev, ABS_DISTANCE, data[7]);
371 - input_report_rel(dev, REL_WHEEL, (signed char) data[6]);
373 - input_report_abs(dev, ABS_X, x);
374 - input_report_abs(dev, ABS_Y, y);
376 - input_event(dev, EV_MSC, MSC_SERIAL, data[1] & 0x01);
377 - return;
378 + if ( data[1] & 0x10 ) /* in prox */
380 + switch ((data[1] >> 5) & 3) {
382 + case 0: /* Pen */
383 + wacom->tool[0] = BTN_TOOL_PEN;
384 + break;
386 + case 1: /* Rubber */
387 + wacom->tool[0] = BTN_TOOL_RUBBER;
388 + break;
390 + case 2: /* Mouse with wheel */
391 + input_report_key(dev, BTN_MIDDLE, data[1] & 0x04);
392 + input_report_rel(dev, REL_WHEEL, (signed char) data[6]);
393 + /* fall through */
395 + case 3: /* Mouse without wheel */
396 + wacom->tool[0] = BTN_TOOL_MOUSE;
397 + input_report_key(dev, BTN_LEFT, data[1] & 0x01);
398 + input_report_key(dev, BTN_RIGHT, data[1] & 0x02);
399 + input_report_abs(dev, ABS_DISTANCE, data[7]);
400 + break;
404 if (data[1] & 0x80) {
405 + x = data[2] | ((__u32)data[3] << 8);
406 + y = data[4] | ((__u32)data[5] << 8);
407 input_report_abs(dev, ABS_X, x);
408 input_report_abs(dev, ABS_Y, y);
411 - input_report_abs(dev, ABS_PRESSURE, data[6] | ((__u32)data[7] << 8));
412 - input_report_key(dev, BTN_TOUCH, data[1] & 0x01);
413 - input_report_key(dev, BTN_STYLUS, data[1] & 0x02);
414 - input_report_key(dev, BTN_STYLUS2, data[1] & 0x04);
416 + if (wacom->tool[0] != BTN_TOOL_MOUSE) {
417 + input_report_abs(dev, ABS_PRESSURE, data[6] | ((__u32)data[7] << 8));
418 + input_report_key(dev, BTN_TOUCH, data[1] & 0x01);
419 + input_report_key(dev, BTN_STYLUS, data[1] & 0x02);
420 + input_report_key(dev, BTN_STYLUS2, data[1] & 0x04);
422 + input_report_key(dev, wacom->tool[0], data[1] & 0x10);
423 input_event(dev, EV_MSC, MSC_SERIAL, data[1] & 0x01);
426 -static void wacom_intuos_irq(struct urb *urb)
427 +static int wacom_intuos_inout(struct urb *urb)
429 struct wacom *wacom = urb->context;
430 unsigned char *data = wacom->data;
431 struct input_dev *dev = &wacom->dev;
432 - unsigned int t;
433 int idx;
435 - if (urb->status) return;
437 - if (data[0] != 2) {
438 - printk(KERN_ERR "wacom_intuos_irq: received unknown report #%d\n", data[0]);
439 - return;
442 /* tool number */
443 idx = data[1] & 0x01;
445 - if ((data[1] & 0xfc) == 0xc0) { /* Enter report */
446 + /* Enter report */
447 + if ((data[1] & 0xfc) == 0xc0)
449 + /* serial number of the tool */
450 + wacom->serial[idx] = ((__u32)(data[3] & 0x0f) << 28) +
451 + ((__u32)data[4] << 20) + ((__u32)data[5] << 12) +
452 + ((__u32)data[6] << 4) + ((__u32)data[7] >> 4);
454 + #ifdef __JEJ_DEBUG
455 + printk(KERN_INFO "wacom_intuos_irq: tool change 0x%03X\n",
456 + (((__u32)data[2] << 4) | (data[3] >> 4)));
457 + #endif
459 + switch ((((__u32)data[2] << 4) | (data[3] >> 4)))
461 + case 0x812: /* Intuos2 ink pen XP-110-00A */
462 + case 0x801: /* Intuos3 Inking pen */
463 + case 0x012: /* Inking pen */
464 + wacom->tool[idx] = BTN_TOOL_PENCIL; break;
466 + case 0x822: /* Intuos Pen GP-300E-01H */
467 + case 0x852: /* Intuos2 Grip Pen XP-501E-00A */
468 + case 0x842: /* Designer Pen */
469 + case 0x823: /* Intuos3 Grip Pen */
470 + case 0x813: /* Intuos3 Classic Pen */
471 + case 0x885: /* Intuos3 Marker Pen */
472 + case 0x022:
473 + wacom->tool[idx] = BTN_TOOL_PEN; break;
475 + case 0x832: /* Intuos2 stroke pen XP-120-00A */
476 + case 0x032: /* Stroke pen */
477 + wacom->tool[idx] = BTN_TOOL_BRUSH; break;
479 + case 0x007: /* 2D Mouse */
480 + case 0x09C: /* ?? Mouse - not a valid code according to Wacom */
481 + case 0x094: /* 4D Mouse */
482 + case 0x017: /* Intuos3 2D Mouse */
483 + wacom->tool[idx] = BTN_TOOL_MOUSE; break;
485 + case 0x096: /* Lens cursor */
486 + case 0x097: /* Intuos3 Lens cursor */
487 + wacom->tool[idx] = BTN_TOOL_LENS; break;
489 + case 0x82A:
490 + case 0x85A:
491 + case 0x91A:
492 + case 0xD1A:
493 + case 0x0FA: /* Eraser */
494 + case 0x82B: /* Intuos3 Grip Pen Eraser */
495 + case 0x81B: /* Intuos3 Classic Pen Eraser */
496 + case 0x91B: /* Intuos3 Airbrush Eraser */
497 + wacom->tool[idx] = BTN_TOOL_RUBBER; break;
499 + case 0x112: /* Airbrush */
500 + case 0x912: /* Intuos2 Airbrush */
501 + case 0xD12: /* Intuos Airbrush */
502 + case 0x913: /* Intuos3 Airbrush */
503 + wacom->tool[idx] = BTN_TOOL_AIRBRUSH; break;
505 - wacom->serial[idx] = ((__u32)(data[3] & 0x0f) << 4) + /* serial number of the tool */
506 - ((__u32)data[4] << 16) + ((__u32)data[5] << 12) +
507 - ((__u32)data[6] << 4) + (data[7] >> 4);
509 - switch (((__u32)data[2] << 4) | (data[3] >> 4)) {
510 - case 0x832:
511 - case 0x012: wacom->tool[idx] = BTN_TOOL_PENCIL; break; /* Inking pen */
512 - case 0x822:
513 - case 0x852:
514 - case 0x022: wacom->tool[idx] = BTN_TOOL_PEN; break; /* Pen */
515 - case 0x812:
516 - case 0x032: wacom->tool[idx] = BTN_TOOL_BRUSH; break; /* Stroke pen */
517 - case 0x09c:
518 - case 0x007:
519 - case 0x094: wacom->tool[idx] = BTN_TOOL_MOUSE; break; /* Mouse 4D */
520 - case 0x096: wacom->tool[idx] = BTN_TOOL_LENS; break; /* Lens cursor */
521 - case 0x82a:
522 - case 0x85a:
523 - case 0x91a:
524 - case 0x0fa: wacom->tool[idx] = BTN_TOOL_RUBBER; break; /* Eraser */
525 - case 0x112: wacom->tool[idx] = BTN_TOOL_AIRBRUSH; break; /* Airbrush */
526 - default: wacom->tool[idx] = BTN_TOOL_PEN; break; /* Unknown tool */
527 + default: /* Unknown tool */
528 + wacom->tool[idx] = BTN_TOOL_PEN; break;
531 - input_report_key(dev, wacom->tool[idx], 1);
532 input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
533 - return;
534 + return 1;
537 - if ((data[1] & 0xfe) == 0x80) { /* Exit report */
538 + /* Exit report */
539 + if ((data[1] & 0xfe) == 0x80)
541 input_report_key(dev, wacom->tool[idx], 0);
542 input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
543 - return;
544 + return 1;
547 - input_report_abs(dev, ABS_X, ((__u32)data[2] << 8) | data[3]);
548 - input_report_abs(dev, ABS_Y, ((__u32)data[4] << 8) | data[5]);
549 - input_report_abs(dev, ABS_DISTANCE, data[9] >> 4);
551 - if ((data[1] & 0xb8) == 0xa0) { /* general pen packet */
552 - input_report_abs(dev, ABS_PRESSURE, t = ((__u32)data[6] << 2) | ((data[7] >> 6) & 3));
553 - input_report_abs(dev, ABS_TILT_X, ((data[7] << 1) & 0x7e) | (data[8] >> 7));
554 + return 0;
557 +static void wacom_intuos_general(struct urb *urb)
559 + struct wacom *wacom = urb->context;
560 + unsigned char *data = wacom->data;
561 + struct input_dev *dev = &wacom->dev;
562 + unsigned int t;
564 + /* general pen packet */
565 + if ((data[1] & 0xb8) == 0xa0)
567 + t = ((__u32)data[6] << 2) | ((data[7] >> 6) & 3);
568 + input_report_abs(dev, ABS_PRESSURE, t);
569 + input_report_abs(dev, ABS_TILT_X,
570 + ((data[7] << 1) & 0x7e) | (data[8] >> 7));
571 input_report_abs(dev, ABS_TILT_Y, data[8] & 0x7f);
572 input_report_key(dev, BTN_STYLUS, data[1] & 2);
573 input_report_key(dev, BTN_STYLUS2, data[1] & 4);
574 input_report_key(dev, BTN_TOUCH, t > 10);
577 - if ((data[1] & 0xbc) == 0xb4) { /* airbrush second packet */
578 - input_report_abs(dev, ABS_WHEEL, ((__u32)data[6] << 2) | ((data[7] >> 6) & 3));
579 - input_report_abs(dev, ABS_TILT_X, ((data[7] << 1) & 0x7e) | (data[8] >> 7));
580 + /* airbrush second packet */
581 + if ((data[1] & 0xbc) == 0xb4)
583 + input_report_abs(dev, ABS_WHEEL,
584 + ((__u32)data[6] << 2) | ((data[7] >> 6) & 3));
585 + input_report_abs(dev, ABS_TILT_X,
586 + ((data[7] << 1) & 0x7e) | (data[8] >> 7));
587 input_report_abs(dev, ABS_TILT_Y, data[8] & 0x7f);
589 + return;
592 +static void wacom_intuos_irq(struct urb *urb)
594 + struct wacom *wacom = urb->context;
595 + unsigned char *data = wacom->data;
596 + struct input_dev *dev = &wacom->dev;
597 + unsigned int t;
598 + int idx;
600 + if (urb->status) return;
602 + /* check for valid report */
603 + if (data[0] != 2 && data[0] != 5 && data[0] != 6 && data[0] != 12)
605 + printk(KERN_INFO "wacom_intuos_irq: received unknown report #%d\n", data[0]);
606 + wacom_request_reset(wacom);
607 + return;
610 - if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0) { /* 4D mouse or Lens cursor packets */
611 + /* tool index */
612 + idx = data[1] & 0x01;
614 - if (data[1] & 0x02) { /* Rotation packet */
615 + /* pad packets. Works as a second tool and is alway in prox */
616 + if (data[0] == 12)
618 + /* initiate the pad as a device */
619 + if (wacom->tool[1] != BTN_TOOL_FINGER)
621 + wacom->tool[1] = BTN_TOOL_FINGER;
622 + input_report_key(dev, wacom->tool[1], 1);
624 + input_report_key(dev, BTN_0, (data[5] & 0x01));
625 + input_report_key(dev, BTN_1, (data[5] & 0x02));
626 + input_report_key(dev, BTN_2, (data[5] & 0x04));
627 + input_report_key(dev, BTN_3, (data[5] & 0x08));
628 + input_report_key(dev, BTN_4, (data[6] & 0x01));
629 + input_report_key(dev, BTN_5, (data[6] & 0x02));
630 + input_report_key(dev, BTN_6, (data[6] & 0x04));
631 + input_report_key(dev, BTN_7, (data[6] & 0x08));
632 + input_report_abs(dev, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
633 + input_report_abs(dev, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
634 + input_event(dev, EV_MSC, MSC_SERIAL, 0xffffffff);
635 + return;
638 - input_report_abs(dev, ABS_RZ, (data[7] & 0x20) ?
639 - ((__u32)data[6] << 2) | ((data[7] >> 6) & 3):
640 - (-(((__u32)data[6] << 2) | ((data[7] >> 6) & 3))) - 1);
641 + /* process in/out prox events */
642 + if (wacom_intuos_inout(urb)) return;
644 - } else {
645 + /* Cintiq doesn't send data when RDY bit isn't set */
646 + if (strstr(wacom->features->name, "Cintiq") && !(data[1] & 0x40)) return;
648 + if(strstr(wacom->features->name, "Intuos3") || strstr(wacom->features->name, "Cintiq"))
650 + input_report_abs(dev, ABS_X, ((__u32)data[2] << 9) | ((__u32)data[3] << 1) | ((data[9] >> 1) & 1));
651 + input_report_abs(dev, ABS_Y, ((__u32)data[4] << 9) | ((__u32)data[5] << 1) | (data[9] & 1));
652 + input_report_abs(dev, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
654 + else
656 + input_report_abs(dev, ABS_X, ((__u32)data[2] << 8) | data[3]);
657 + input_report_abs(dev, ABS_Y, ((__u32)data[4] << 8) | data[5]);
658 + input_report_abs(dev, ABS_DISTANCE, ((data[9] >> 3) & 0x1f));
661 + /* process general packets */
662 + wacom_intuos_general(urb);
664 + /* 4D mouse, 2D mouse, marker pen rotation, or Lens cursor packets */
665 + if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0)
667 + /* Rotation packet */
668 + if (data[1] & 0x02)
670 + if(strstr(wacom->features->name, "Intuos3") ||
671 + strstr(wacom->features->name, "Cintiq"))
673 + /* I3 marker pen rotation reported as wheel
674 + * due to valuator limitation
675 + */
676 + t = ((__u32)data[6] << 3) | ((data[7] >> 5) & 7);
677 + t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
678 + ((t-1) / 2 + 450)) : (450 - t / 2) ;
679 + input_report_abs(dev, ABS_WHEEL, t);
681 + else
683 + /* 4D mouse rotation packet */
684 + t = ((__u32)data[6] << 3) | ((data[7] >> 5) & 7);
685 + input_report_abs(dev, ABS_RZ, (data[7] & 0x20) ?
686 + ((t - 1) / 2) : -t / 2);
690 + /* 4D mouse packets */
691 + else if ( !(data[1] & 0x10) && !strstr(wacom->features->name, "Intuos3"))
693 input_report_key(dev, BTN_LEFT, data[8] & 0x01);
694 input_report_key(dev, BTN_MIDDLE, data[8] & 0x02);
695 input_report_key(dev, BTN_RIGHT, data[8] & 0x04);
696 + input_report_key(dev, BTN_SIDE, data[8] & 0x20);
697 + input_report_key(dev, BTN_EXTRA, data[8] & 0x10);
698 + /* throttle is positive when rolled backwards */
699 + t = ((__u32)data[6] << 2) | ((data[7] >> 6) & 3);
700 + input_report_abs(dev, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
703 - if ((data[1] & 0x10) == 0) { /* 4D mouse packets */
705 - input_report_key(dev, BTN_SIDE, data[8] & 0x20);
706 - input_report_key(dev, BTN_EXTRA, data[8] & 0x10);
707 - input_report_abs(dev, ABS_THROTTLE, (data[8] & 0x08) ?
708 - ((__u32)data[6] << 2) | ((data[7] >> 6) & 3) :
709 - -((__u32)data[6] << 2) | ((data[7] >> 6) & 3));
711 - } else { /* Lens cursor packets */
713 - input_report_key(dev, BTN_SIDE, data[8] & 0x10);
714 - input_report_key(dev, BTN_EXTRA, data[8] & 0x08);
715 + /* 2D mouse packets */
716 + else if (wacom->tool[idx] == BTN_TOOL_MOUSE)
718 + input_report_key(dev, BTN_LEFT, data[8] & 0x04);
719 + input_report_key(dev, BTN_MIDDLE, data[8] & 0x08);
720 + input_report_key(dev, BTN_RIGHT, data[8] & 0x10);
721 + /* mouse wheel is positive when rolled backwards */
722 + input_report_rel(dev, REL_WHEEL, (__u32)((data[8] & 0x02) >> 1)
723 + - (__u32)(data[8] & 0x01));
725 + /* I3 2D mouse side buttons */
726 + if (strstr(wacom->features->name, "Intuos3"))
728 + input_report_key(dev, BTN_SIDE, data[8] & 0x40);
729 + input_report_key(dev, BTN_EXTRA, data[8] & 0x20);
732 + /* lens cursor packets */
733 + else if ( !strstr(wacom->features->name, "Intuos3") )
735 + input_report_key(dev, BTN_LEFT, data[8] & 0x01);
736 + input_report_key(dev, BTN_MIDDLE, data[8] & 0x02);
737 + input_report_key(dev, BTN_RIGHT, data[8] & 0x04);
738 + input_report_key(dev, BTN_SIDE, data[8] & 0x10);
739 + input_report_key(dev, BTN_EXTRA, data[8] & 0x08);
744 + input_report_key(dev, wacom->tool[idx], 1);
745 input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
748 +#define WACOM_GRAPHIRE_BITS (BIT(EV_REL))
749 +#define WACOM_GRAPHIRE_REL (BIT(REL_WHEEL))
750 #define WACOM_INTUOS_TOOLS (BIT(BTN_TOOL_BRUSH) | BIT(BTN_TOOL_PENCIL) | BIT(BTN_TOOL_AIRBRUSH) | BIT(BTN_TOOL_LENS))
751 +#define WACOM_INTUOS3_TOOLS (WACOM_INTUOS_TOOLS | BIT(BTN_TOOL_FINGER))
752 #define WACOM_INTUOS_BUTTONS (BIT(BTN_SIDE) | BIT(BTN_EXTRA))
753 +#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))
754 +#define WACOM_INTUOS_BITS (BIT(EV_REL))
755 +#define WACOM_INTUOS_REL (BIT(REL_WHEEL))
756 #define WACOM_INTUOS_ABS (BIT(ABS_TILT_X) | BIT(ABS_TILT_Y) | BIT(ABS_RZ) | BIT(ABS_THROTTLE))
757 +#define WACOM_INTUOS3_ABS (WACOM_INTUOS_ABS | BIT(ABS_RX) | BIT(ABS_RY))
759 struct wacom_features wacom_features[] = {
760 - { "Wacom Penpartner", 7, 5040, 3780, 255, 32, wacom_penpartner_irq,
761 - 0, 0, 0, 0 },
762 - { "Wacom Graphire", 8, 10206, 7422, 511, 32, wacom_graphire_irq,
763 - BIT(EV_REL), 0, BIT(REL_WHEEL), 0 },
764 - { "Wacom Graphire2 4x5", 8, 10206, 7422, 511, 32, wacom_graphire_irq,
765 - BIT(EV_REL), 0, BIT(REL_WHEEL), 0 },
766 - { "Wacom Graphire2 5x7", 8, 10206, 7422, 511, 32, wacom_graphire_irq,
767 - BIT(EV_REL), 0, BIT(REL_WHEEL), 0 },
768 - { "Wacom Intuos 4x5", 10, 12700, 10360, 1023, 15, wacom_intuos_irq,
769 - 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
770 - { "Wacom Intuos 6x8", 10, 20320, 15040, 1023, 15, wacom_intuos_irq,
771 - 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
772 - { "Wacom Intuos 9x12", 10, 30480, 23060, 1023, 15, wacom_intuos_irq,
773 - 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
774 - { "Wacom Intuos 12x12", 10, 30480, 30480, 1023, 15, wacom_intuos_irq,
775 - 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
776 - { "Wacom Intuos 12x18", 10, 47720, 30480, 1023, 15, wacom_intuos_irq,
777 - 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
778 - { "Wacom PL400", 8, 12328, 9256, 511, 32, wacom_pl_irq,
779 - 0, 0, 0, 0 },
780 - { "Wacom PL500", 8, 12328, 9256, 511, 32, wacom_pl_irq,
781 - 0, 0, 0, 0 },
782 - { "Wacom PL600", 8, 12328, 9256, 511, 32, wacom_pl_irq,
783 - 0, 0, 0, 0 },
784 - { "Wacom PL600SX", 8, 12328, 9256, 511, 32, wacom_pl_irq,
785 - 0, 0, 0, 0 },
786 - { "Wacom PL550", 8, 12328, 9256, 511, 32, wacom_pl_irq,
787 - 0, 0, 0, 0 },
788 - { "Wacom PL800", 8, 12328, 9256, 511, 32, wacom_pl_irq,
789 - 0, 0, 0, 0 },
790 - { "Wacom Intuos2 4x5", 10, 12700, 10360, 1023, 15, wacom_intuos_irq,
791 - 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
792 - { "Wacom Intuos2 6x8", 10, 20320, 15040, 1023, 15, wacom_intuos_irq,
793 - 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
794 - { "Wacom Intuos2 9x12", 10, 30480, 23060, 1023, 15, wacom_intuos_irq,
795 - 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
796 - { "Wacom Intuos2 12x12", 10, 30480, 30480, 1023, 15, wacom_intuos_irq,
797 - 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
798 - { "Wacom Intuos2 12x18", 10, 47720, 30480, 1023, 15, wacom_intuos_irq,
799 - 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
801 + /* PenPartner */
802 + /* 0 */ { "Wacom Penpartner", 7, 5040, 3780, 255, 32,
803 + wacom_penpartner_irq, 0, 0, 0, 0 },
805 + /* Graphire */
806 + /* 1 */ { "Wacom Graphire", 8, 10206, 7422, 511, 32,
807 + wacom_graphire_irq, WACOM_GRAPHIRE_BITS, 0, WACOM_GRAPHIRE_REL, 0 },
808 + /* 2 */ { "Wacom Graphire2 4x5", 8, 10206, 7422, 511, 32,
809 + wacom_graphire_irq, WACOM_GRAPHIRE_BITS, 0, WACOM_GRAPHIRE_REL, 0 },
810 + /* 3 */ { "Wacom Graphire2 5x7", 8, 13918, 10206, 511, 32,
811 + wacom_graphire_irq, WACOM_GRAPHIRE_BITS, 0, WACOM_GRAPHIRE_REL, 0 },
813 + /* Intuos */
814 + /* 4 */ { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 15,
815 + wacom_intuos_irq, WACOM_INTUOS_BITS, WACOM_INTUOS_ABS,
816 + WACOM_INTUOS_REL, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
817 + /* JEJ - confirmed X and Y range from test tablet */
818 + /* 5 */ { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 15,
819 + wacom_intuos_irq, WACOM_INTUOS_BITS, WACOM_INTUOS_ABS,
820 + WACOM_INTUOS_REL, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
821 + /* 6 */ { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 15,
822 + wacom_intuos_irq, WACOM_INTUOS_BITS, WACOM_INTUOS_ABS,
823 + WACOM_INTUOS_REL, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
824 + /* 7 */ { "Wacom Intuos 12x12", 10, 30480, 31680, 1023, 15,
825 + wacom_intuos_irq, WACOM_INTUOS_BITS, WACOM_INTUOS_ABS,
826 + WACOM_INTUOS_REL, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
827 + /* 8 */ { "Wacom Intuos 12x18", 10, 45720, 31680, 1023, 15,
828 + wacom_intuos_irq, WACOM_INTUOS_BITS, WACOM_INTUOS_ABS,
829 + WACOM_INTUOS_REL, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
831 + /* PL - Cintiq */
832 + /* 9 */ { "Wacom PL400", 8, 5408, 4056, 255, 32,
833 + wacom_pl_irq, 0, 0, 0, 0 },
834 + /* 10 */ { "Wacom PL500", 8, 6144, 4608, 255, 32,
835 + wacom_pl_irq, 0, 0, 0, 0 },
836 + /* 11 */ { "Wacom PL600", 8, 6126, 4604, 255, 32,
837 + wacom_pl_irq, 0, 0, 0, 0 },
838 + /* 12 */ { "Wacom PL600SX", 8, 6260, 5016, 255, 32,
839 + wacom_pl_irq, 0, 0, 0, 0 },
840 + /* 13 */ { "Wacom PL550", 8, 6144, 4608, 511, 32,
841 + wacom_pl_irq, 0, 0, 0, 0 },
842 + /* 14 */ { "Wacom PL800", 8, 7220, 5780, 511, 32,
843 + wacom_pl_irq, 0, 0, 0, 0 },
845 + /* Intuos2 */
846 + /* JEJ - confirmed X and Y range from J.N. tablet */
847 + /* 15 */ { "Wacom Intuos2 4x5", 10, 12700, 10600, 1023, 15,
848 + wacom_intuos_irq, WACOM_INTUOS_BITS, WACOM_INTUOS_ABS,
849 + WACOM_INTUOS_REL, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
850 + /* JEJ - confirmed X and Y range from R.T. and J.S. tablets */
851 + /* 16 */ { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15,
852 + wacom_intuos_irq, WACOM_INTUOS_BITS, WACOM_INTUOS_ABS,
853 + WACOM_INTUOS_REL, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
854 + /* JEJ - values from serial 9x12 */
855 + /* 17 */ { "Wacom Intuos2 9x12", 10, 30480, 24060, 1023, 15,
856 + wacom_intuos_irq, WACOM_INTUOS_BITS, WACOM_INTUOS_ABS,
857 + WACOM_INTUOS_REL, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
858 + /* JEJ - confirmed X and Y range from J.J. tablet */
859 + /* 18 */ { "Wacom Intuos2 12x12", 10, 30480, 31680, 1023, 15,
860 + wacom_intuos_irq, WACOM_INTUOS_BITS, WACOM_INTUOS_ABS,
861 + WACOM_INTUOS_REL, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
862 + /* 19 */ { "Wacom Intuos2 12x18", 10, 45720, 31680, 1023, 15,
863 + wacom_intuos_irq, WACOM_INTUOS_BITS, WACOM_INTUOS_ABS,
864 + WACOM_INTUOS_REL, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
865 + /* Volito - (Graphire2 4x5 no mouse wheel) */
866 + /* 20 */ { "Wacom Volito", 8, 5104, 3712, 511, 32,
867 + wacom_graphire_irq, WACOM_GRAPHIRE_BITS, 0, 0, 0 },
868 + /* 21 */ { "Wacom Graphire3 4x5", 8, 10208, 7424, 511, 32,
869 + wacom_graphire_irq, WACOM_GRAPHIRE_BITS, 0, WACOM_GRAPHIRE_REL, 0 },
870 + /* 22 */ { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 32,
871 + wacom_graphire_irq, WACOM_GRAPHIRE_BITS, 0, WACOM_GRAPHIRE_REL, 0 },
872 + /* 23 */ { "Wacom Cintiq Partner", 8, 20480, 15360, 511, 32,
873 + wacom_ptu_irq, 0, 0, 0, 0 },
874 + /* Intuos3 */
875 + /* 24 */ { "Wacom Intuos3 4x5", 10, 25400, 20320, 1023, 15,
876 + wacom_intuos_irq, WACOM_INTUOS_BITS, WACOM_INTUOS3_ABS,
877 + WACOM_INTUOS_REL, WACOM_INTUOS3_BUTTONS, WACOM_INTUOS3_TOOLS },
878 + /* 25 */ { "Wacom Intuos3 6x8", 10, 40640, 30480, 1023, 15,
879 + wacom_intuos_irq, WACOM_INTUOS_BITS, WACOM_INTUOS3_ABS,
880 + WACOM_INTUOS_REL, WACOM_INTUOS3_BUTTONS, WACOM_INTUOS3_TOOLS },
881 + /* 26 */ { "Wacom Intuos3 9x12", 10, 60960, 45720, 1023, 15,
882 + wacom_intuos_irq, WACOM_INTUOS_BITS, WACOM_INTUOS3_ABS,
883 + WACOM_INTUOS_REL, WACOM_INTUOS3_BUTTONS, WACOM_INTUOS3_TOOLS },
884 + /* Protocol 5 Cintiq */
885 + /* 27 */ { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 15,
886 + wacom_intuos_irq, WACOM_INTUOS_BITS, WACOM_INTUOS3_ABS,
887 + WACOM_INTUOS_REL, WACOM_INTUOS3_BUTTONS, WACOM_INTUOS3_TOOLS },
889 { NULL , 0 }
892 @@ -404,6 +751,19 @@
893 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x43), driver_info: 17 },
894 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x44), driver_info: 18 },
895 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x45), driver_info: 19 },
896 + { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60), driver_info: 20 },
897 + { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x13), driver_info: 21 },
898 + { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x14), driver_info: 22 },
899 + { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x03), driver_info: 23 },
900 + { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB0), driver_info: 24 },
901 + { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB1), driver_info: 25 },
902 + { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB2), driver_info: 26 },
903 + { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F), driver_info: 27 },
905 + /* some Intuos2 6x8's erroneously report as 0x47;
906 + * multiple confirmed examples exist. */
907 + { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47), driver_info: 16 },
912 @@ -431,25 +791,50 @@
913 usb_unlink_urb(&wacom->irq);
916 +static void wacom_reset(struct wacom* wacom)
918 + unsigned char edata[2], limit=0;
919 + #ifdef __JEJ_DEBUG
920 + printk(KERN_INFO __FILE__ ": Setting tablet report for tablet data\n");
921 + #endif
923 + /* ask the tablet to report tablet data. repeats until it succeeds */
924 + do {
925 + edata[0] = 2;
926 + edata[1] = 2;
927 + usb_set_report(wacom->usbdev, wacom->ifnum, 3, 2, edata, 2);
928 + usb_get_report(wacom->usbdev, wacom->ifnum, 3, 2, edata, 2);
929 + } while (edata[1] != 2 && limit++ < 5);
932 static void *wacom_probe(struct usb_device *dev, unsigned int ifnum, const struct usb_device_id *id)
934 struct usb_endpoint_descriptor *endpoint;
935 struct wacom *wacom;
936 - char rep_data[2] = {0x02, 0x02};
939 if (!(wacom = kmalloc(sizeof(struct wacom), GFP_KERNEL))) return NULL;
940 memset(wacom, 0, sizeof(struct wacom));
942 wacom->features = wacom_features + id->driver_info;
944 - wacom->dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC) | wacom->features->evbit;
945 - wacom->dev.absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE) | BIT(ABS_DISTANCE) | BIT(ABS_WHEEL) | wacom->features->absbit;
946 + wacom->dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC) |
947 + wacom->features->evbit;
948 + wacom->dev.absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE) |
949 + BIT(ABS_DISTANCE) | BIT(ABS_WHEEL) | wacom->features->absbit;
950 wacom->dev.relbit[0] |= wacom->features->relbit;
951 - wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE) | wacom->features->btnbit;
952 - wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) |
953 - BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2) | wacom->features->digibit;
954 + wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) |
955 + BIT(BTN_MIDDLE) | wacom->features->btnbit;
956 + wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) |
957 + BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) |
958 + BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2) |
959 + wacom->features->digibit;
960 wacom->dev.mscbit[0] |= BIT(MSC_SERIAL);
962 + #ifdef __JEJ_DEBUG
963 + printk(KERN_INFO __FILE__ ": Reporting max %d, %d\n",
964 + wacom->features->x_max, wacom->features->y_max);
965 + #endif
967 wacom->dev.absmax[ABS_X] = wacom->features->x_max;
968 wacom->dev.absmax[ABS_Y] = wacom->features->y_max;
969 wacom->dev.absmax[ABS_PRESSURE] = wacom->features->pressure_max;
970 @@ -458,6 +843,8 @@
971 wacom->dev.absmax[ABS_TILT_Y] = 127;
972 wacom->dev.absmax[ABS_WHEEL] = 1023;
974 + wacom->dev.absmax[ABS_RX] = 4097;
975 + wacom->dev.absmax[ABS_RY] = 4097;
976 wacom->dev.absmin[ABS_RZ] = -900;
977 wacom->dev.absmax[ABS_RZ] = 899;
978 wacom->dev.absmin[ABS_THROTTLE] = -1023;
979 @@ -476,35 +863,102 @@
980 wacom->dev.idproduct = dev->descriptor.idProduct;
981 wacom->dev.idversion = dev->descriptor.bcdDevice;
982 wacom->usbdev = dev;
983 + wacom->ifnum = ifnum;
985 + INIT_LIST_HEAD(&wacom->event_list);
986 + init_MUTEX(&wacom->kwacomd_sem);
988 endpoint = dev->config[0].interface[ifnum].altsetting[0].endpoint + 0;
990 usb_set_idle(dev, dev->config[0].interface[ifnum].altsetting[0].bInterfaceNumber, 0, 0);
992 - FILL_INT_URB(&wacom->irq, dev, usb_rcvintpipe(dev, endpoint->bEndpointAddress),
993 - wacom->data, wacom->features->pktlen, wacom->features->irq, wacom, endpoint->bInterval);
994 + FILL_INT_URB(&wacom->irq, dev, usb_rcvintpipe(dev,
995 + endpoint->bEndpointAddress), wacom->data, wacom->features->pktlen,
996 + wacom->features->irq, wacom, endpoint->bInterval);
998 input_register_device(&wacom->dev);
1000 - /* ask the tablet to report tablet data */
1001 - usb_set_report(dev, ifnum, 3, 2, rep_data, 2);
1002 - usb_set_report(dev, ifnum, 3, 5, rep_data, 0);
1003 - usb_set_report(dev, ifnum, 3, 6, rep_data, 0);
1005 - printk(KERN_INFO "input%d: %s on usb%d:%d.%d\n",
1006 - wacom->dev.number, wacom->features->name, dev->bus->busnum, dev->devnum, ifnum);
1007 + wacom_reset(wacom);
1009 + printk(KERN_INFO __FILE__ ": input%d: %s on usb%d:%d.%d\n",
1010 + wacom->dev.number, wacom->features->name, dev->bus->busnum,
1011 + dev->devnum, ifnum);
1013 return wacom;
1016 static void wacom_disconnect(struct usb_device *dev, void *ptr)
1018 + unsigned int flags;
1019 struct wacom *wacom = ptr;
1020 - usb_unlink_urb(&wacom->irq);
1021 - input_unregister_device(&wacom->dev);
1022 - kfree(wacom);
1023 + if (wacom)
1025 + spin_lock_irqsave(&wacom_event_lock, flags);
1026 + list_del(&wacom->event_list);
1027 + INIT_LIST_HEAD(&wacom->event_list);
1028 + spin_unlock_irqrestore(&wacom_event_lock, flags);
1030 + /* Wait for kwacomd to leave this tablet alone. */
1031 + down(&wacom->kwacomd_sem);
1032 + up(&wacom->kwacomd_sem);
1034 + usb_unlink_urb(&wacom->irq);
1035 + input_unregister_device(&wacom->dev);
1036 + kfree(wacom);
1040 +static void wacom_events(void)
1042 + struct wacom* wacom;
1043 + unsigned int flags;
1044 + struct list_head *tmp;
1046 + printk(KERN_INFO "wacom_events\n");
1048 + while (1)
1050 + spin_lock_irqsave(&wacom_event_lock, flags);
1052 + if (list_empty(&wacom_event_list))
1053 + break;
1055 + /* Grab the next entry from the beginning of the list */
1056 + tmp = wacom_event_list.next;
1057 + wacom = list_entry(tmp, struct wacom, event_list);
1059 + list_del(tmp); /* dequeue tablet */
1060 + INIT_LIST_HEAD(tmp);
1062 + if (down_trylock(&wacom->kwacomd_sem) != 0) BUG(); /* never blocks */
1063 + spin_unlock_irqrestore(&wacom_event_lock, flags);
1065 + wacom_reset(wacom);
1067 + up(&wacom->kwacomd_sem); /* mark tablet free */
1069 + spin_unlock_irqrestore(&wacom_event_lock, flags);
1072 +static int wacom_thread(void* pv)
1074 + daemonize();
1075 + reparent_to_init();
1077 + /* Setup a nice name */
1078 + strcpy(current->comm, "kwacomd");
1080 + /* Send me a signal to get me die (for debugging) */
1081 + while (!signal_pending(current))
1083 + wacom_events();
1084 + wait_event_interruptible(kwacomd_wait, !list_empty(&wacom_event_list));
1087 + complete_and_exit(&kwacomd_exited, 0);
1091 static struct usb_driver wacom_driver = {
1092 name: "wacom",
1093 probe: wacom_probe,
1094 @@ -514,14 +968,36 @@
1096 static int __init wacom_init(void)
1098 + int pid;
1100 usb_register(&wacom_driver);
1101 info(DRIVER_VERSION " " DRIVER_AUTHOR);
1102 info(DRIVER_DESC);
1103 - return 0;
1105 + pid = kernel_thread(wacom_thread, NULL,
1106 + CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
1108 + if (pid >= 0)
1110 + kwacomd_pid = pid;
1111 + return 0;
1114 + /* Fall through if kernel_thread failed */
1115 + usb_deregister(&wacom_driver);
1116 + err("failed to start wacom_thread");
1118 + return -1;
1121 static void __exit wacom_exit(void)
1123 + int ret;
1125 + /* Kill the thread */
1126 + ret = kill_proc(kwacomd_pid, SIGTERM, 1);
1127 + wait_for_completion(&kwacomd_exited);
1129 usb_deregister(&wacom_driver);