Input: i8042 - fix AUX port detection with some chips
[linux-2.6/verdex.git] / drivers / usb / input / wacom_wac.c
blob4f3e9bc7177d236e9c1575111c0f9b4162d1c359
1 /*
2 * drivers/usb/input/wacom_wac.c
4 * USB Wacom Graphire and Wacom Intuos tablet support - Wacom specific code
6 */
8 /*
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 #include "wacom.h"
15 #include "wacom_wac.h"
17 static int wacom_penpartner_irq(struct wacom_wac *wacom, void *wcombo)
19 unsigned char *data = wacom->data;
21 switch (data[0]) {
22 case 1:
23 if (data[5] & 0x80) {
24 wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
25 wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID;
26 wacom_report_key(wcombo, wacom->tool[0], 1);
27 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); /* report tool id */
28 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[1]));
29 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[3]));
30 wacom_report_abs(wcombo, ABS_PRESSURE, (signed char)data[6] + 127);
31 wacom_report_key(wcombo, BTN_TOUCH, ((signed char)data[6] > -127));
32 wacom_report_key(wcombo, BTN_STYLUS, (data[5] & 0x40));
33 } else {
34 wacom_report_key(wcombo, wacom->tool[0], 0);
35 wacom_report_abs(wcombo, ABS_MISC, 0); /* report tool id */
36 wacom_report_abs(wcombo, ABS_PRESSURE, -1);
37 wacom_report_key(wcombo, BTN_TOUCH, 0);
39 break;
40 case 2:
41 wacom_report_key(wcombo, BTN_TOOL_PEN, 1);
42 wacom_report_abs(wcombo, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
43 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[1]));
44 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[3]));
45 wacom_report_abs(wcombo, ABS_PRESSURE, (signed char)data[6] + 127);
46 wacom_report_key(wcombo, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
47 wacom_report_key(wcombo, BTN_STYLUS, (data[5] & 0x40));
48 break;
49 default:
50 printk(KERN_INFO "wacom_penpartner_irq: received unknown report #%d\n", data[0]);
51 return 0;
53 return 1;
56 static int wacom_pl_irq(struct wacom_wac *wacom, void *wcombo)
58 unsigned char *data = wacom->data;
59 int prox, id, pressure;
61 if (data[0] != 2) {
62 dbg("wacom_pl_irq: received unknown report #%d", data[0]);
63 return 0;
66 prox = data[1] & 0x40;
68 id = ERASER_DEVICE_ID;
69 if (prox) {
71 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
72 if (wacom->features->pressure_max > 255)
73 pressure = (pressure << 1) | ((data[4] >> 6) & 1);
74 pressure += (wacom->features->pressure_max + 1) / 2;
77 * if going from out of proximity into proximity select between the eraser
78 * and the pen based on the state of the stylus2 button, choose eraser if
79 * pressed else choose pen. if not a proximity change from out to in, send
80 * an out of proximity for previous tool then a in for new tool.
82 if (!wacom->tool[0]) {
83 /* Eraser bit set for DTF */
84 if (data[1] & 0x10)
85 wacom->tool[1] = BTN_TOOL_RUBBER;
86 else
87 /* Going into proximity select tool */
88 wacom->tool[1] = (data[4] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
89 } else {
90 /* was entered with stylus2 pressed */
91 if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
92 /* report out proximity for previous tool */
93 wacom_report_key(wcombo, wacom->tool[1], 0);
94 wacom_input_sync(wcombo);
95 wacom->tool[1] = BTN_TOOL_PEN;
96 return 0;
99 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
100 /* Unknown tool selected default to pen tool */
101 wacom->tool[1] = BTN_TOOL_PEN;
102 id = STYLUS_DEVICE_ID;
104 wacom_report_key(wcombo, wacom->tool[1], prox); /* report in proximity for tool */
105 wacom_report_abs(wcombo, ABS_MISC, id); /* report tool id */
106 wacom_report_abs(wcombo, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
107 wacom_report_abs(wcombo, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
108 wacom_report_abs(wcombo, ABS_PRESSURE, pressure);
110 wacom_report_key(wcombo, BTN_TOUCH, data[4] & 0x08);
111 wacom_report_key(wcombo, BTN_STYLUS, data[4] & 0x10);
112 /* Only allow the stylus2 button to be reported for the pen tool. */
113 wacom_report_key(wcombo, BTN_STYLUS2, (wacom->tool[1] == BTN_TOOL_PEN) && (data[4] & 0x20));
114 } else {
115 /* report proximity-out of a (valid) tool */
116 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
117 /* Unknown tool selected default to pen tool */
118 wacom->tool[1] = BTN_TOOL_PEN;
120 wacom_report_key(wcombo, wacom->tool[1], prox);
123 wacom->tool[0] = prox; /* Save proximity state */
124 return 1;
127 static int wacom_ptu_irq(struct wacom_wac *wacom, void *wcombo)
129 unsigned char *data = wacom->data;
130 int id;
132 if (data[0] != 2) {
133 printk(KERN_INFO "wacom_ptu_irq: received unknown report #%d\n", data[0]);
134 return 0;
137 if (data[1] & 0x04) {
138 wacom_report_key(wcombo, BTN_TOOL_RUBBER, data[1] & 0x20);
139 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x08);
140 id = ERASER_DEVICE_ID;
141 } else {
142 wacom_report_key(wcombo, BTN_TOOL_PEN, data[1] & 0x20);
143 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x01);
144 id = STYLUS_DEVICE_ID;
146 wacom_report_abs(wcombo, ABS_MISC, id); /* report tool id */
147 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[2]));
148 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4]));
149 wacom_report_abs(wcombo, ABS_PRESSURE, wacom_le16_to_cpu(&data[6]));
150 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02);
151 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x10);
152 return 1;
155 static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
157 unsigned char *data = wacom->data;
158 int x, y, id, rw;
160 if (data[0] != 2) {
161 dbg("wacom_graphire_irq: received unknown report #%d", data[0]);
162 return 0;
165 id = STYLUS_DEVICE_ID;
166 if (data[1] & 0x80) { /* in prox */
168 switch ((data[1] >> 5) & 3) {
170 case 0: /* Pen */
171 wacom->tool[0] = BTN_TOOL_PEN;
172 break;
174 case 1: /* Rubber */
175 wacom->tool[0] = BTN_TOOL_RUBBER;
176 id = ERASER_DEVICE_ID;
177 break;
179 case 2: /* Mouse with wheel */
180 wacom_report_key(wcombo, BTN_MIDDLE, data[1] & 0x04);
181 if (wacom->features->type == WACOM_G4) {
182 rw = data[7] & 0x04 ? (data[7] & 0x03)-4 : (data[7] & 0x03);
183 wacom_report_rel(wcombo, REL_WHEEL, -rw);
184 } else
185 wacom_report_rel(wcombo, REL_WHEEL, -(signed char) data[6]);
186 /* fall through */
188 case 3: /* Mouse without wheel */
189 wacom->tool[0] = BTN_TOOL_MOUSE;
190 id = CURSOR_DEVICE_ID;
191 wacom_report_key(wcombo, BTN_LEFT, data[1] & 0x01);
192 wacom_report_key(wcombo, BTN_RIGHT, data[1] & 0x02);
193 if (wacom->features->type == WACOM_G4)
194 wacom_report_abs(wcombo, ABS_DISTANCE, data[6] & 0x3f);
195 else
196 wacom_report_abs(wcombo, ABS_DISTANCE, data[7] & 0x3f);
197 break;
199 x = wacom_le16_to_cpu(&data[2]);
200 y = wacom_le16_to_cpu(&data[4]);
201 wacom_report_abs(wcombo, ABS_X, x);
202 wacom_report_abs(wcombo, ABS_Y, y);
203 if (wacom->tool[0] != BTN_TOOL_MOUSE) {
204 wacom_report_abs(wcombo, ABS_PRESSURE, data[6] | ((data[7] & 0x01) << 8));
205 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x01);
206 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02);
207 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x04);
209 wacom_report_abs(wcombo, ABS_MISC, id); /* report tool id */
210 wacom_report_key(wcombo, wacom->tool[0], 1);
211 } else if (!(data[1] & 0x90)) {
212 wacom_report_abs(wcombo, ABS_X, 0);
213 wacom_report_abs(wcombo, ABS_Y, 0);
214 if (wacom->tool[0] == BTN_TOOL_MOUSE) {
215 wacom_report_key(wcombo, BTN_LEFT, 0);
216 wacom_report_key(wcombo, BTN_RIGHT, 0);
217 wacom_report_abs(wcombo, ABS_DISTANCE, 0);
218 } else {
219 wacom_report_abs(wcombo, ABS_PRESSURE, 0);
220 wacom_report_key(wcombo, BTN_TOUCH, 0);
221 wacom_report_key(wcombo, BTN_STYLUS, 0);
222 wacom_report_key(wcombo, BTN_STYLUS2, 0);
224 wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */
225 wacom_report_key(wcombo, wacom->tool[0], 0);
228 /* send pad data */
229 if (wacom->features->type == WACOM_G4) {
230 if (data[7] & 0xf8) {
231 wacom_input_sync(wcombo); /* sync last event */
232 wacom->id[1] = 1;
233 wacom->serial[1] = (data[7] & 0xf8);
234 wacom_report_key(wcombo, BTN_0, (data[7] & 0x40));
235 wacom_report_key(wcombo, BTN_4, (data[7] & 0x80));
236 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
237 wacom_report_rel(wcombo, REL_WHEEL, rw);
238 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0xf0);
239 wacom_report_abs(wcombo, ABS_MISC, PAD_DEVICE_ID);
240 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
241 } else if (wacom->id[1]) {
242 wacom_input_sync(wcombo); /* sync last event */
243 wacom->id[1] = 0;
244 wacom_report_key(wcombo, BTN_0, (data[7] & 0x40));
245 wacom_report_key(wcombo, BTN_4, (data[7] & 0x80));
246 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0);
247 wacom_report_abs(wcombo, ABS_MISC, 0);
248 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
251 return 1;
254 static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
256 unsigned char *data = wacom->data;
257 int idx;
259 /* tool number */
260 idx = data[1] & 0x01;
262 /* Enter report */
263 if ((data[1] & 0xfc) == 0xc0) {
264 /* serial number of the tool */
265 wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
266 (data[4] << 20) + (data[5] << 12) +
267 (data[6] << 4) + (data[7] >> 4);
269 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4);
270 switch (wacom->id[idx]) {
271 case 0x812: /* Inking pen */
272 case 0x801: /* Intuos3 Inking pen */
273 case 0x012:
274 wacom->tool[idx] = BTN_TOOL_PENCIL;
275 break;
276 case 0x822: /* Pen */
277 case 0x842:
278 case 0x852:
279 case 0x823: /* Intuos3 Grip Pen */
280 case 0x813: /* Intuos3 Classic Pen */
281 case 0x885: /* Intuos3 Marker Pen */
282 case 0x022:
283 wacom->tool[idx] = BTN_TOOL_PEN;
284 break;
285 case 0x832: /* Stroke pen */
286 case 0x032:
287 wacom->tool[idx] = BTN_TOOL_BRUSH;
288 break;
289 case 0x007: /* Mouse 4D and 2D */
290 case 0x09c:
291 case 0x094:
292 case 0x017: /* Intuos3 2D Mouse */
293 wacom->tool[idx] = BTN_TOOL_MOUSE;
294 break;
295 case 0x096: /* Lens cursor */
296 case 0x097: /* Intuos3 Lens cursor */
297 wacom->tool[idx] = BTN_TOOL_LENS;
298 break;
299 case 0x82a: /* Eraser */
300 case 0x85a:
301 case 0x91a:
302 case 0xd1a:
303 case 0x0fa:
304 case 0x82b: /* Intuos3 Grip Pen Eraser */
305 case 0x81b: /* Intuos3 Classic Pen Eraser */
306 case 0x91b: /* Intuos3 Airbrush Eraser */
307 wacom->tool[idx] = BTN_TOOL_RUBBER;
308 break;
309 case 0xd12:
310 case 0x912:
311 case 0x112:
312 case 0x913: /* Intuos3 Airbrush */
313 wacom->tool[idx] = BTN_TOOL_AIRBRUSH;
314 break;
315 default: /* Unknown tool */
316 wacom->tool[idx] = BTN_TOOL_PEN;
318 return 1;
321 /* Exit report */
322 if ((data[1] & 0xfe) == 0x80) {
323 wacom_report_abs(wcombo, ABS_X, 0);
324 wacom_report_abs(wcombo, ABS_Y, 0);
325 wacom_report_abs(wcombo, ABS_DISTANCE, 0);
326 if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
327 wacom_report_key(wcombo, BTN_LEFT, 0);
328 wacom_report_key(wcombo, BTN_MIDDLE, 0);
329 wacom_report_key(wcombo, BTN_RIGHT, 0);
330 wacom_report_key(wcombo, BTN_SIDE, 0);
331 wacom_report_key(wcombo, BTN_EXTRA, 0);
332 wacom_report_abs(wcombo, ABS_THROTTLE, 0);
333 wacom_report_abs(wcombo, ABS_RZ, 0);
334 } else {
335 wacom_report_abs(wcombo, ABS_PRESSURE, 0);
336 wacom_report_abs(wcombo, ABS_TILT_X, 0);
337 wacom_report_abs(wcombo, ABS_TILT_Y, 0);
338 wacom_report_key(wcombo, BTN_STYLUS, 0);
339 wacom_report_key(wcombo, BTN_STYLUS2, 0);
340 wacom_report_key(wcombo, BTN_TOUCH, 0);
341 wacom_report_abs(wcombo, ABS_WHEEL, 0);
343 wacom_report_key(wcombo, wacom->tool[idx], 0);
344 wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */
345 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
346 return 2;
348 return 0;
351 static void wacom_intuos_general(struct wacom_wac *wacom, void *wcombo)
353 unsigned char *data = wacom->data;
354 unsigned int t;
356 /* general pen packet */
357 if ((data[1] & 0xb8) == 0xa0) {
358 t = (data[6] << 2) | ((data[7] >> 6) & 3);
359 wacom_report_abs(wcombo, ABS_PRESSURE, t);
360 wacom_report_abs(wcombo, ABS_TILT_X,
361 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
362 wacom_report_abs(wcombo, ABS_TILT_Y, data[8] & 0x7f);
363 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 2);
364 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 4);
365 wacom_report_key(wcombo, BTN_TOUCH, t > 10);
368 /* airbrush second packet */
369 if ((data[1] & 0xbc) == 0xb4) {
370 wacom_report_abs(wcombo, ABS_WHEEL,
371 (data[6] << 2) | ((data[7] >> 6) & 3));
372 wacom_report_abs(wcombo, ABS_TILT_X,
373 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
374 wacom_report_abs(wcombo, ABS_TILT_Y, data[8] & 0x7f);
376 return;
379 static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
381 unsigned char *data = wacom->data;
382 unsigned int t;
383 int idx, result;
385 if (data[0] != 2 && data[0] != 5 && data[0] != 6 && data[0] != 12) {
386 dbg("wacom_intuos_irq: received unknown report #%d", data[0]);
387 return 0;
390 /* tool number */
391 idx = data[1] & 0x01;
393 /* pad packets. Works as a second tool and is always in prox */
394 if (data[0] == 12) {
395 /* initiate the pad as a device */
396 if (wacom->tool[1] != BTN_TOOL_FINGER)
397 wacom->tool[1] = BTN_TOOL_FINGER;
399 wacom_report_key(wcombo, BTN_0, (data[5] & 0x01));
400 wacom_report_key(wcombo, BTN_1, (data[5] & 0x02));
401 wacom_report_key(wcombo, BTN_2, (data[5] & 0x04));
402 wacom_report_key(wcombo, BTN_3, (data[5] & 0x08));
403 wacom_report_key(wcombo, BTN_4, (data[6] & 0x01));
404 wacom_report_key(wcombo, BTN_5, (data[6] & 0x02));
405 wacom_report_key(wcombo, BTN_6, (data[6] & 0x04));
406 wacom_report_key(wcombo, BTN_7, (data[6] & 0x08));
407 wacom_report_abs(wcombo, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
408 wacom_report_abs(wcombo, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
410 if((data[5] & 0x0f) | (data[6] & 0x0f) | (data[1] & 0x1f) |
411 data[2] | (data[3] & 0x1f) | data[4])
412 wacom_report_key(wcombo, wacom->tool[1], 1);
413 else
414 wacom_report_key(wcombo, wacom->tool[1], 0);
415 wacom_report_abs(wcombo, ABS_MISC, PAD_DEVICE_ID);
416 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xffffffff);
417 return 1;
420 /* process in/out prox events */
421 result = wacom_intuos_inout(wacom, wcombo);
422 if (result)
423 return result-1;
425 /* Only large I3 and I1 & I2 support Lense Cursor */
426 if((wacom->tool[idx] == BTN_TOOL_LENS)
427 && ((wacom->features->type == INTUOS3)
428 || (wacom->features->type == INTUOS3S)))
429 return 0;
431 /* Cintiq doesn't send data when RDY bit isn't set */
432 if ((wacom->features->type == CINTIQ) && !(data[1] & 0x40))
433 return 0;
435 if (wacom->features->type >= INTUOS3S) {
436 wacom_report_abs(wcombo, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
437 wacom_report_abs(wcombo, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
438 wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
439 } else {
440 wacom_report_abs(wcombo, ABS_X, wacom_be16_to_cpu(&data[2]));
441 wacom_report_abs(wcombo, ABS_Y, wacom_be16_to_cpu(&data[4]));
442 wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 3) & 0x1f));
445 /* process general packets */
446 wacom_intuos_general(wacom, wcombo);
448 /* 4D mouse, 2D mouse, marker pen rotation, or Lens cursor packets */
449 if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0) {
451 if (data[1] & 0x02) {
452 /* Rotation packet */
453 if (wacom->features->type >= INTUOS3S) {
454 /* I3 marker pen rotation reported as wheel
455 * due to valuator limitation
457 t = (data[6] << 3) | ((data[7] >> 5) & 7);
458 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
459 ((t-1) / 2 + 450)) : (450 - t / 2) ;
460 wacom_report_abs(wcombo, ABS_WHEEL, t);
461 } else {
462 /* 4D mouse rotation packet */
463 t = (data[6] << 3) | ((data[7] >> 5) & 7);
464 wacom_report_abs(wcombo, ABS_RZ, (data[7] & 0x20) ?
465 ((t - 1) / 2) : -t / 2);
468 } else if (!(data[1] & 0x10) && wacom->features->type < INTUOS3S) {
469 /* 4D mouse packet */
470 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
471 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02);
472 wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x04);
474 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x20);
475 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x10);
476 t = (data[6] << 2) | ((data[7] >> 6) & 3);
477 wacom_report_abs(wcombo, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
479 } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
480 /* 2D mouse packet */
481 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x04);
482 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x08);
483 wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x10);
484 wacom_report_rel(wcombo, REL_WHEEL, (data[8] & 0x01)
485 - ((data[8] & 0x02) >> 1));
487 /* I3 2D mouse side buttons */
488 if (wacom->features->type >= INTUOS3S && wacom->features->type <= INTUOS3L) {
489 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x40);
490 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x20);
493 } else if (wacom->features->type < INTUOS3S || wacom->features->type == INTUOS3L) {
494 /* Lens cursor packets */
495 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
496 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02);
497 wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x04);
498 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x10);
499 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x08);
503 wacom_report_abs(wcombo, ABS_MISC, wacom->id[idx]); /* report tool id */
504 wacom_report_key(wcombo, wacom->tool[idx], 1);
505 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
506 return 1;
509 int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo)
511 switch (wacom_wac->features->type) {
512 case PENPARTNER:
513 return (wacom_penpartner_irq(wacom_wac, wcombo));
514 break;
515 case PL:
516 return (wacom_pl_irq(wacom_wac, wcombo));
517 break;
518 case WACOM_G4:
519 case GRAPHIRE:
520 return (wacom_graphire_irq(wacom_wac, wcombo));
521 break;
522 case PTU:
523 return (wacom_ptu_irq(wacom_wac, wcombo));
524 break;
525 case INTUOS:
526 case INTUOS3S:
527 case INTUOS3:
528 case INTUOS3L:
529 case CINTIQ:
530 return (wacom_intuos_irq(wacom_wac, wcombo));
531 break;
532 default:
533 return 0;
535 return 0;
538 void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
540 switch (wacom_wac->features->type) {
541 case WACOM_G4:
542 input_dev_g4(input_dev, wacom_wac);
543 /* fall through */
544 case GRAPHIRE:
545 input_dev_g(input_dev, wacom_wac);
546 break;
547 case INTUOS3:
548 case INTUOS3L:
549 case CINTIQ:
550 input_dev_i3(input_dev, wacom_wac);
551 /* fall through */
552 case INTUOS3S:
553 input_dev_i3s(input_dev, wacom_wac);
554 case INTUOS:
555 input_dev_i(input_dev, wacom_wac);
556 break;
557 case PL:
558 case PTU:
559 input_dev_pl(input_dev, wacom_wac);
560 break;
561 case PENPARTNER:
562 input_dev_pt(input_dev, wacom_wac);
563 break;
565 return;
568 static struct wacom_features wacom_features[] = {
569 { "Wacom Penpartner", 7, 5040, 3780, 255, 0, PENPARTNER },
570 { "Wacom Graphire", 8, 10206, 7422, 511, 63, GRAPHIRE },
571 { "Wacom Graphire2 4x5", 8, 10206, 7422, 511, 63, GRAPHIRE },
572 { "Wacom Graphire2 5x7", 8, 13918, 10206, 511, 63, GRAPHIRE },
573 { "Wacom Graphire3", 8, 10208, 7424, 511, 63, GRAPHIRE },
574 { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 63, GRAPHIRE },
575 { "Wacom Graphire4 4x5", 8, 10208, 7424, 511, 63, WACOM_G4 },
576 { "Wacom Graphire4 6x8", 8, 16704, 12064, 511, 63, WACOM_G4 },
577 { "Wacom Volito", 8, 5104, 3712, 511, 63, GRAPHIRE },
578 { "Wacom PenStation2", 8, 3250, 2320, 255, 63, GRAPHIRE },
579 { "Wacom Volito2 4x5", 8, 5104, 3712, 511, 63, GRAPHIRE },
580 { "Wacom Volito2 2x3", 8, 3248, 2320, 511, 63, GRAPHIRE },
581 { "Wacom PenPartner2", 8, 3250, 2320, 255, 63, GRAPHIRE },
582 { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 31, INTUOS },
583 { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 31, INTUOS },
584 { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 31, INTUOS },
585 { "Wacom Intuos 12x12", 10, 30480, 31680, 1023, 31, INTUOS },
586 { "Wacom Intuos 12x18", 10, 45720, 31680, 1023, 31, INTUOS },
587 { "Wacom PL400", 8, 5408, 4056, 255, 0, PL },
588 { "Wacom PL500", 8, 6144, 4608, 255, 0, PL },
589 { "Wacom PL600", 8, 6126, 4604, 255, 0, PL },
590 { "Wacom PL600SX", 8, 6260, 5016, 255, 0, PL },
591 { "Wacom PL550", 8, 6144, 4608, 511, 0, PL },
592 { "Wacom PL800", 8, 7220, 5780, 511, 0, PL },
593 { "Wacom PL700", 8, 6758, 5406, 511, 0, PL },
594 { "Wacom PL510", 8, 6282, 4762, 511, 0, PL },
595 { "Wacom DTU710", 8, 34080, 27660, 511, 0, PL },
596 { "Wacom DTF521", 8, 6282, 4762, 511, 0, PL },
597 { "Wacom DTF720", 8, 6858, 5506, 511, 0, PL },
598 { "Wacom Cintiq Partner",8, 20480, 15360, 511, 0, PTU },
599 { "Wacom Intuos2 4x5", 10, 12700, 10600, 1023, 31, INTUOS },
600 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 31, INTUOS },
601 { "Wacom Intuos2 9x12", 10, 30480, 24060, 1023, 31, INTUOS },
602 { "Wacom Intuos2 12x12", 10, 30480, 31680, 1023, 31, INTUOS },
603 { "Wacom Intuos2 12x18", 10, 45720, 31680, 1023, 31, INTUOS },
604 { "Wacom Intuos3 4x5", 10, 25400, 20320, 1023, 63, INTUOS3S },
605 { "Wacom Intuos3 6x8", 10, 40640, 30480, 1023, 63, INTUOS3 },
606 { "Wacom Intuos3 9x12", 10, 60960, 45720, 1023, 63, INTUOS3 },
607 { "Wacom Intuos3 12x12", 10, 60960, 60960, 1023, 63, INTUOS3L },
608 { "Wacom Intuos3 12x19", 10, 97536, 60960, 1023, 63, INTUOS3L },
609 { "Wacom Intuos3 6x11", 10, 54204, 31750, 1023, 63, INTUOS3 },
610 { "Wacom Intuos3 4x6", 10, 31496, 19685, 1023, 63, INTUOS3S },
611 { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 63, CINTIQ },
612 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 31, INTUOS },
616 static struct usb_device_id wacom_ids[] = {
617 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x00) },
618 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x10) },
619 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x11) },
620 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x12) },
621 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x13) },
622 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x14) },
623 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x15) },
624 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x16) },
625 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60) },
626 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x61) },
627 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x62) },
628 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x63) },
629 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x64) },
630 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x20) },
631 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x21) },
632 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x22) },
633 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x23) },
634 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x24) },
635 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x30) },
636 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x31) },
637 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x32) },
638 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x33) },
639 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x34) },
640 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x35) },
641 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x37) },
642 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x38) },
643 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x39) },
644 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC0) },
645 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC4) },
646 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x03) },
647 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x41) },
648 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x42) },
649 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x43) },
650 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x44) },
651 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x45) },
652 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB0) },
653 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB1) },
654 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB2) },
655 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB3) },
656 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB4) },
657 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB5) },
658 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB7) },
659 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) },
660 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) },
664 const struct usb_device_id * get_device_table(void) {
665 const struct usb_device_id * id_table = wacom_ids;
666 return id_table;
669 struct wacom_features * get_wacom_feature(const struct usb_device_id * id) {
670 int index = id - wacom_ids;
671 struct wacom_features *wf = &wacom_features[index];
672 return wf;
675 MODULE_DEVICE_TABLE(usb, wacom_ids);