2 * drivers/input/tablet/wacom_wac.c
4 * USB Wacom tablet support - Wacom specific code
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.
15 #include "wacom_wac.h"
17 #include <linux/input/mt.h>
18 #include <linux/hid.h>
20 /* resolution for penabled devices */
21 #define WACOM_PL_RES 20
22 #define WACOM_PENPRTN_RES 40
23 #define WACOM_VOLITO_RES 50
24 #define WACOM_GRAPHIRE_RES 80
25 #define WACOM_INTUOS_RES 100
26 #define WACOM_INTUOS3_RES 200
28 /* Scale factor relating reported contact size to logical contact area.
29 * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo
31 #define WACOM_CONTACT_AREA_SCALE 2607
33 static int wacom_penpartner_irq(struct wacom_wac *wacom)
35 unsigned char *data = wacom->data;
36 struct input_dev *input = wacom->input;
41 wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
42 wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID;
43 input_report_key(input, wacom->tool[0], 1);
44 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
45 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
46 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
47 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
48 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127));
49 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
51 input_report_key(input, wacom->tool[0], 0);
52 input_report_abs(input, ABS_MISC, 0); /* report tool id */
53 input_report_abs(input, ABS_PRESSURE, -1);
54 input_report_key(input, BTN_TOUCH, 0);
59 input_report_key(input, BTN_TOOL_PEN, 1);
60 input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
61 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
62 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
63 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
64 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
65 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
69 dev_dbg(input->dev.parent,
70 "%s: received unknown report #%d\n", __func__, data[0]);
77 static int wacom_pl_irq(struct wacom_wac *wacom)
79 struct wacom_features *features = &wacom->features;
80 unsigned char *data = wacom->data;
81 struct input_dev *input = wacom->input;
84 if (data[0] != WACOM_REPORT_PENABLED) {
85 dev_dbg(input->dev.parent,
86 "%s: received unknown report #%d\n", __func__, data[0]);
90 prox = data[1] & 0x40;
93 wacom->id[0] = ERASER_DEVICE_ID;
94 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
95 if (features->pressure_max > 255)
96 pressure = (pressure << 1) | ((data[4] >> 6) & 1);
97 pressure += (features->pressure_max + 1) / 2;
100 * if going from out of proximity into proximity select between the eraser
101 * and the pen based on the state of the stylus2 button, choose eraser if
102 * pressed else choose pen. if not a proximity change from out to in, send
103 * an out of proximity for previous tool then a in for new tool.
105 if (!wacom->tool[0]) {
106 /* Eraser bit set for DTF */
108 wacom->tool[1] = BTN_TOOL_RUBBER;
110 /* Going into proximity select tool */
111 wacom->tool[1] = (data[4] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
113 /* was entered with stylus2 pressed */
114 if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
115 /* report out proximity for previous tool */
116 input_report_key(input, wacom->tool[1], 0);
118 wacom->tool[1] = BTN_TOOL_PEN;
122 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
123 /* Unknown tool selected default to pen tool */
124 wacom->tool[1] = BTN_TOOL_PEN;
125 wacom->id[0] = STYLUS_DEVICE_ID;
127 input_report_key(input, wacom->tool[1], prox); /* report in proximity for tool */
128 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
129 input_report_abs(input, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
130 input_report_abs(input, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
131 input_report_abs(input, ABS_PRESSURE, pressure);
133 input_report_key(input, BTN_TOUCH, data[4] & 0x08);
134 input_report_key(input, BTN_STYLUS, data[4] & 0x10);
135 /* Only allow the stylus2 button to be reported for the pen tool. */
136 input_report_key(input, BTN_STYLUS2, (wacom->tool[1] == BTN_TOOL_PEN) && (data[4] & 0x20));
138 /* report proximity-out of a (valid) tool */
139 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
140 /* Unknown tool selected default to pen tool */
141 wacom->tool[1] = BTN_TOOL_PEN;
143 input_report_key(input, wacom->tool[1], prox);
146 wacom->tool[0] = prox; /* Save proximity state */
150 static int wacom_ptu_irq(struct wacom_wac *wacom)
152 unsigned char *data = wacom->data;
153 struct input_dev *input = wacom->input;
155 if (data[0] != WACOM_REPORT_PENABLED) {
156 dev_dbg(input->dev.parent,
157 "%s: received unknown report #%d\n", __func__, data[0]);
161 if (data[1] & 0x04) {
162 input_report_key(input, BTN_TOOL_RUBBER, data[1] & 0x20);
163 input_report_key(input, BTN_TOUCH, data[1] & 0x08);
164 wacom->id[0] = ERASER_DEVICE_ID;
166 input_report_key(input, BTN_TOOL_PEN, data[1] & 0x20);
167 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
168 wacom->id[0] = STYLUS_DEVICE_ID;
170 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
171 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
172 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
173 input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6]));
174 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
175 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
179 static int wacom_dtu_irq(struct wacom_wac *wacom)
181 struct wacom_features *features = &wacom->features;
182 char *data = wacom->data;
183 struct input_dev *input = wacom->input;
184 int prox = data[1] & 0x20, pressure;
186 dev_dbg(input->dev.parent,
187 "%s: received report #%d", __func__, data[0]);
190 /* Going into proximity select tool */
191 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
192 if (wacom->tool[0] == BTN_TOOL_PEN)
193 wacom->id[0] = STYLUS_DEVICE_ID;
195 wacom->id[0] = ERASER_DEVICE_ID;
197 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
198 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
199 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
200 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
201 pressure = ((data[7] & 0x01) << 8) | data[6];
203 pressure = features->pressure_max + pressure + 1;
204 input_report_abs(input, ABS_PRESSURE, pressure);
205 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
206 if (!prox) /* out-prox */
208 input_report_key(input, wacom->tool[0], prox);
209 input_report_abs(input, ABS_MISC, wacom->id[0]);
213 static int wacom_graphire_irq(struct wacom_wac *wacom)
215 struct wacom_features *features = &wacom->features;
216 unsigned char *data = wacom->data;
217 struct input_dev *input = wacom->input;
222 if (data[0] != WACOM_REPORT_PENABLED) {
223 dev_dbg(input->dev.parent,
224 "%s: received unknown report #%d\n", __func__, data[0]);
228 prox = data[1] & 0x80;
229 if (prox || wacom->id[0]) {
231 switch ((data[1] >> 5) & 3) {
234 wacom->tool[0] = BTN_TOOL_PEN;
235 wacom->id[0] = STYLUS_DEVICE_ID;
239 wacom->tool[0] = BTN_TOOL_RUBBER;
240 wacom->id[0] = ERASER_DEVICE_ID;
243 case 2: /* Mouse with wheel */
244 input_report_key(input, BTN_MIDDLE, data[1] & 0x04);
247 case 3: /* Mouse without wheel */
248 wacom->tool[0] = BTN_TOOL_MOUSE;
249 wacom->id[0] = CURSOR_DEVICE_ID;
253 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
254 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
255 if (wacom->tool[0] != BTN_TOOL_MOUSE) {
256 input_report_abs(input, ABS_PRESSURE, data[6] | ((data[7] & 0x03) << 8));
257 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
258 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
259 input_report_key(input, BTN_STYLUS2, data[1] & 0x04);
261 input_report_key(input, BTN_LEFT, data[1] & 0x01);
262 input_report_key(input, BTN_RIGHT, data[1] & 0x02);
263 if (features->type == WACOM_G4 ||
264 features->type == WACOM_MO) {
265 input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f);
266 rw = (data[7] & 0x04) - (data[7] & 0x03);
268 input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f);
269 rw = -(signed char)data[6];
271 input_report_rel(input, REL_WHEEL, rw);
276 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
277 input_report_key(input, wacom->tool[0], prox);
278 input_event(input, EV_MSC, MSC_SERIAL, 1);
279 input_sync(input); /* sync last event */
283 switch (features->type) {
285 prox = data[7] & 0xf8;
286 if (prox || wacom->id[1]) {
287 wacom->id[1] = PAD_DEVICE_ID;
288 input_report_key(input, BTN_BACK, (data[7] & 0x40));
289 input_report_key(input, BTN_FORWARD, (data[7] & 0x80));
290 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
291 input_report_rel(input, REL_WHEEL, rw);
294 input_report_abs(input, ABS_MISC, wacom->id[1]);
295 input_event(input, EV_MSC, MSC_SERIAL, 0xf0);
301 prox = (data[7] & 0xf8) || data[8];
302 if (prox || wacom->id[1]) {
303 wacom->id[1] = PAD_DEVICE_ID;
304 input_report_key(input, BTN_BACK, (data[7] & 0x08));
305 input_report_key(input, BTN_LEFT, (data[7] & 0x20));
306 input_report_key(input, BTN_FORWARD, (data[7] & 0x10));
307 input_report_key(input, BTN_RIGHT, (data[7] & 0x40));
308 input_report_abs(input, ABS_WHEEL, (data[8] & 0x7f));
311 input_report_abs(input, ABS_MISC, wacom->id[1]);
312 input_event(input, EV_MSC, MSC_SERIAL, 0xf0);
321 static int wacom_intuos_inout(struct wacom_wac *wacom)
323 struct wacom_features *features = &wacom->features;
324 unsigned char *data = wacom->data;
325 struct input_dev *input = wacom->input;
329 if (features->type == INTUOS)
330 idx = data[1] & 0x01;
333 if ((data[1] & 0xfc) == 0xc0) {
334 if (features->quirks == WACOM_QUIRK_MULTI_INPUT)
335 wacom->shared->stylus_in_proximity = true;
337 /* serial number of the tool */
338 wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
339 (data[4] << 20) + (data[5] << 12) +
340 (data[6] << 4) + (data[7] >> 4);
342 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) |
343 ((data[7] & 0x0f) << 20) | ((data[8] & 0xf0) << 12);
345 switch (wacom->id[idx] & 0xfffff) {
346 case 0x812: /* Inking pen */
347 case 0x801: /* Intuos3 Inking pen */
348 case 0x20802: /* Intuos4 Inking Pen */
350 wacom->tool[idx] = BTN_TOOL_PENCIL;
353 case 0x822: /* Pen */
356 case 0x823: /* Intuos3 Grip Pen */
357 case 0x813: /* Intuos3 Classic Pen */
358 case 0x885: /* Intuos3 Marker Pen */
359 case 0x802: /* Intuos4 General Pen */
360 case 0x804: /* Intuos4 Marker Pen */
361 case 0x40802: /* Intuos4 Classic Pen */
363 wacom->tool[idx] = BTN_TOOL_PEN;
366 case 0x832: /* Stroke pen */
368 wacom->tool[idx] = BTN_TOOL_BRUSH;
371 case 0x007: /* Mouse 4D and 2D */
374 case 0x017: /* Intuos3 2D Mouse */
375 case 0x806: /* Intuos4 Mouse */
376 wacom->tool[idx] = BTN_TOOL_MOUSE;
379 case 0x096: /* Lens cursor */
380 case 0x097: /* Intuos3 Lens cursor */
381 case 0x006: /* Intuos4 Lens cursor */
382 wacom->tool[idx] = BTN_TOOL_LENS;
385 case 0x82a: /* Eraser */
390 case 0x82b: /* Intuos3 Grip Pen Eraser */
391 case 0x81b: /* Intuos3 Classic Pen Eraser */
392 case 0x91b: /* Intuos3 Airbrush Eraser */
393 case 0x80c: /* Intuos4 Marker Pen Eraser */
394 case 0x80a: /* Intuos4 General Pen Eraser */
395 case 0x4080a: /* Intuos4 Classic Pen Eraser */
396 case 0x90a: /* Intuos4 Airbrush Eraser */
397 wacom->tool[idx] = BTN_TOOL_RUBBER;
403 case 0x913: /* Intuos3 Airbrush */
404 case 0x902: /* Intuos4 Airbrush */
405 wacom->tool[idx] = BTN_TOOL_AIRBRUSH;
408 default: /* Unknown tool */
409 wacom->tool[idx] = BTN_TOOL_PEN;
415 /* older I4 styli don't work with new Cintiqs */
416 if (!((wacom->id[idx] >> 20) & 0x01) &&
417 (features->type == WACOM_21UX2))
421 if ((data[1] & 0xfe) == 0x80) {
422 if (features->quirks == WACOM_QUIRK_MULTI_INPUT)
423 wacom->shared->stylus_in_proximity = false;
426 * Reset all states otherwise we lose the initial states
427 * when in-prox next time
429 input_report_abs(input, ABS_X, 0);
430 input_report_abs(input, ABS_Y, 0);
431 input_report_abs(input, ABS_DISTANCE, 0);
432 input_report_abs(input, ABS_TILT_X, 0);
433 input_report_abs(input, ABS_TILT_Y, 0);
434 if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
435 input_report_key(input, BTN_LEFT, 0);
436 input_report_key(input, BTN_MIDDLE, 0);
437 input_report_key(input, BTN_RIGHT, 0);
438 input_report_key(input, BTN_SIDE, 0);
439 input_report_key(input, BTN_EXTRA, 0);
440 input_report_abs(input, ABS_THROTTLE, 0);
441 input_report_abs(input, ABS_RZ, 0);
443 input_report_abs(input, ABS_PRESSURE, 0);
444 input_report_key(input, BTN_STYLUS, 0);
445 input_report_key(input, BTN_STYLUS2, 0);
446 input_report_key(input, BTN_TOUCH, 0);
447 input_report_abs(input, ABS_WHEEL, 0);
448 if (features->type >= INTUOS3S)
449 input_report_abs(input, ABS_Z, 0);
451 input_report_key(input, wacom->tool[idx], 0);
452 input_report_abs(input, ABS_MISC, 0); /* reset tool id */
453 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
460 static void wacom_intuos_general(struct wacom_wac *wacom)
462 struct wacom_features *features = &wacom->features;
463 unsigned char *data = wacom->data;
464 struct input_dev *input = wacom->input;
467 /* general pen packet */
468 if ((data[1] & 0xb8) == 0xa0) {
469 t = (data[6] << 2) | ((data[7] >> 6) & 3);
470 if ((features->type >= INTUOS4S && features->type <= INTUOS4L) ||
471 (features->type >= INTUOS5S && features->type <= INTUOS5L) ||
472 (features->type >= WACOM_21UX2 && features->type <= WACOM_24HD)) {
473 t = (t << 1) | (data[1] & 1);
475 input_report_abs(input, ABS_PRESSURE, t);
476 input_report_abs(input, ABS_TILT_X,
477 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
478 input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f);
479 input_report_key(input, BTN_STYLUS, data[1] & 2);
480 input_report_key(input, BTN_STYLUS2, data[1] & 4);
481 input_report_key(input, BTN_TOUCH, t > 10);
484 /* airbrush second packet */
485 if ((data[1] & 0xbc) == 0xb4) {
486 input_report_abs(input, ABS_WHEEL,
487 (data[6] << 2) | ((data[7] >> 6) & 3));
488 input_report_abs(input, ABS_TILT_X,
489 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
490 input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f);
494 static int wacom_intuos_irq(struct wacom_wac *wacom)
496 struct wacom_features *features = &wacom->features;
497 unsigned char *data = wacom->data;
498 struct input_dev *input = wacom->input;
502 if (data[0] != WACOM_REPORT_PENABLED &&
503 data[0] != WACOM_REPORT_INTUOSREAD &&
504 data[0] != WACOM_REPORT_INTUOSWRITE &&
505 data[0] != WACOM_REPORT_INTUOSPAD &&
506 data[0] != WACOM_REPORT_INTUOS5PAD) {
507 dev_dbg(input->dev.parent,
508 "%s: received unknown report #%d\n", __func__, data[0]);
513 if (features->type == INTUOS)
514 idx = data[1] & 0x01;
516 /* pad packets. Works as a second tool and is always in prox */
517 if (data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD) {
518 if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
519 input_report_key(input, BTN_0, (data[2] & 0x01));
520 input_report_key(input, BTN_1, (data[3] & 0x01));
521 input_report_key(input, BTN_2, (data[3] & 0x02));
522 input_report_key(input, BTN_3, (data[3] & 0x04));
523 input_report_key(input, BTN_4, (data[3] & 0x08));
524 input_report_key(input, BTN_5, (data[3] & 0x10));
525 input_report_key(input, BTN_6, (data[3] & 0x20));
526 if (data[1] & 0x80) {
527 input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f));
529 /* Out of proximity, clear wheel value. */
530 input_report_abs(input, ABS_WHEEL, 0);
532 if (features->type != INTUOS4S) {
533 input_report_key(input, BTN_7, (data[3] & 0x40));
534 input_report_key(input, BTN_8, (data[3] & 0x80));
536 if (data[1] | (data[2] & 0x01) | data[3]) {
537 input_report_key(input, wacom->tool[1], 1);
538 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
540 input_report_key(input, wacom->tool[1], 0);
541 input_report_abs(input, ABS_MISC, 0);
543 } else if (features->type == WACOM_24HD) {
544 input_report_key(input, BTN_0, (data[6] & 0x01));
545 input_report_key(input, BTN_1, (data[6] & 0x02));
546 input_report_key(input, BTN_2, (data[6] & 0x04));
547 input_report_key(input, BTN_3, (data[6] & 0x08));
548 input_report_key(input, BTN_4, (data[6] & 0x10));
549 input_report_key(input, BTN_5, (data[6] & 0x20));
550 input_report_key(input, BTN_6, (data[6] & 0x40));
551 input_report_key(input, BTN_7, (data[6] & 0x80));
552 input_report_key(input, BTN_8, (data[8] & 0x01));
553 input_report_key(input, BTN_9, (data[8] & 0x02));
554 input_report_key(input, BTN_A, (data[8] & 0x04));
555 input_report_key(input, BTN_B, (data[8] & 0x08));
556 input_report_key(input, BTN_C, (data[8] & 0x10));
557 input_report_key(input, BTN_X, (data[8] & 0x20));
558 input_report_key(input, BTN_Y, (data[8] & 0x40));
559 input_report_key(input, BTN_Z, (data[8] & 0x80));
562 * Three "buttons" are available on the 24HD which are
563 * physically implemented as a touchstrip. Each button
564 * is approximately 3 bits wide with a 2 bit spacing.
565 * The raw touchstrip bits are stored at:
566 * ((data[3] & 0x1f) << 8) | data[4])
568 input_report_key(input, KEY_PROG1, data[4] & 0x07);
569 input_report_key(input, KEY_PROG2, data[4] & 0xE0);
570 input_report_key(input, KEY_PROG3, data[3] & 0x1C);
572 if (data[1] & 0x80) {
573 input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f));
575 /* Out of proximity, clear wheel value. */
576 input_report_abs(input, ABS_WHEEL, 0);
579 if (data[2] & 0x80) {
580 input_report_abs(input, ABS_THROTTLE, (data[2] & 0x7f));
582 /* Out of proximity, clear second wheel value. */
583 input_report_abs(input, ABS_THROTTLE, 0);
586 if (data[1] | data[2] | (data[3] & 0x1f) | data[4] | data[6] | data[8]) {
587 input_report_key(input, wacom->tool[1], 1);
588 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
590 input_report_key(input, wacom->tool[1], 0);
591 input_report_abs(input, ABS_MISC, 0);
593 } else if (features->type >= INTUOS5S && features->type <= INTUOS5L) {
596 /* Touch ring mode switch has no capacitive sensor */
597 input_report_key(input, BTN_0, (data[3] & 0x01));
600 * ExpressKeys on Intuos5 have a capacitive sensor in
601 * addition to the mechanical switch. Switch data is
602 * stored in data[4], capacitive data in data[5].
604 for (i = 0; i < 8; i++)
605 input_report_key(input, BTN_1 + i, data[4] & (1 << i));
607 if (data[2] & 0x80) {
608 input_report_abs(input, ABS_WHEEL, (data[2] & 0x7f));
610 /* Out of proximity, clear wheel value. */
611 input_report_abs(input, ABS_WHEEL, 0);
614 if (data[2] | (data[3] & 0x01) | data[4] | data[5]) {
615 input_report_key(input, wacom->tool[1], 1);
616 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
618 input_report_key(input, wacom->tool[1], 0);
619 input_report_abs(input, ABS_MISC, 0);
622 if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) {
623 input_report_key(input, BTN_0, (data[5] & 0x01));
624 input_report_key(input, BTN_1, (data[6] & 0x01));
625 input_report_key(input, BTN_2, (data[6] & 0x02));
626 input_report_key(input, BTN_3, (data[6] & 0x04));
627 input_report_key(input, BTN_4, (data[6] & 0x08));
628 input_report_key(input, BTN_5, (data[6] & 0x10));
629 input_report_key(input, BTN_6, (data[6] & 0x20));
630 input_report_key(input, BTN_7, (data[6] & 0x40));
631 input_report_key(input, BTN_8, (data[6] & 0x80));
632 input_report_key(input, BTN_9, (data[7] & 0x01));
633 input_report_key(input, BTN_A, (data[8] & 0x01));
634 input_report_key(input, BTN_B, (data[8] & 0x02));
635 input_report_key(input, BTN_C, (data[8] & 0x04));
636 input_report_key(input, BTN_X, (data[8] & 0x08));
637 input_report_key(input, BTN_Y, (data[8] & 0x10));
638 input_report_key(input, BTN_Z, (data[8] & 0x20));
639 input_report_key(input, BTN_BASE, (data[8] & 0x40));
640 input_report_key(input, BTN_BASE2, (data[8] & 0x80));
642 if (features->type == WACOM_22HD) {
643 input_report_key(input, KEY_PROG1, data[9] & 0x01);
644 input_report_key(input, KEY_PROG2, data[9] & 0x02);
645 input_report_key(input, KEY_PROG3, data[9] & 0x04);
648 input_report_key(input, BTN_0, (data[5] & 0x01));
649 input_report_key(input, BTN_1, (data[5] & 0x02));
650 input_report_key(input, BTN_2, (data[5] & 0x04));
651 input_report_key(input, BTN_3, (data[5] & 0x08));
652 input_report_key(input, BTN_4, (data[6] & 0x01));
653 input_report_key(input, BTN_5, (data[6] & 0x02));
654 input_report_key(input, BTN_6, (data[6] & 0x04));
655 input_report_key(input, BTN_7, (data[6] & 0x08));
656 input_report_key(input, BTN_8, (data[5] & 0x10));
657 input_report_key(input, BTN_9, (data[6] & 0x10));
659 input_report_abs(input, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
660 input_report_abs(input, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
662 if ((data[5] & 0x1f) | data[6] | (data[1] & 0x1f) |
663 data[2] | (data[3] & 0x1f) | data[4] | data[8] |
665 input_report_key(input, wacom->tool[1], 1);
666 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
668 input_report_key(input, wacom->tool[1], 0);
669 input_report_abs(input, ABS_MISC, 0);
672 input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff);
676 /* process in/out prox events */
677 result = wacom_intuos_inout(wacom);
681 /* don't proceed if we don't know the ID */
685 /* Only large Intuos support Lense Cursor */
686 if (wacom->tool[idx] == BTN_TOOL_LENS &&
687 (features->type == INTUOS3 ||
688 features->type == INTUOS3S ||
689 features->type == INTUOS4 ||
690 features->type == INTUOS4S ||
691 features->type == INTUOS5 ||
692 features->type == INTUOS5S)) {
697 /* Cintiq doesn't send data when RDY bit isn't set */
698 if (features->type == CINTIQ && !(data[1] & 0x40))
701 if (features->type >= INTUOS3S) {
702 input_report_abs(input, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
703 input_report_abs(input, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
704 input_report_abs(input, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
706 input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[2]));
707 input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[4]));
708 input_report_abs(input, ABS_DISTANCE, ((data[9] >> 3) & 0x1f));
711 /* process general packets */
712 wacom_intuos_general(wacom);
714 /* 4D mouse, 2D mouse, marker pen rotation, tilt mouse, or Lens cursor packets */
715 if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0 || (data[1] & 0xbc) == 0xac) {
717 if (data[1] & 0x02) {
718 /* Rotation packet */
719 if (features->type >= INTUOS3S) {
720 /* I3 marker pen rotation */
721 t = (data[6] << 3) | ((data[7] >> 5) & 7);
722 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
723 ((t-1) / 2 + 450)) : (450 - t / 2) ;
724 input_report_abs(input, ABS_Z, t);
726 /* 4D mouse rotation packet */
727 t = (data[6] << 3) | ((data[7] >> 5) & 7);
728 input_report_abs(input, ABS_RZ, (data[7] & 0x20) ?
729 ((t - 1) / 2) : -t / 2);
732 } else if (!(data[1] & 0x10) && features->type < INTUOS3S) {
733 /* 4D mouse packet */
734 input_report_key(input, BTN_LEFT, data[8] & 0x01);
735 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
736 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
738 input_report_key(input, BTN_SIDE, data[8] & 0x20);
739 input_report_key(input, BTN_EXTRA, data[8] & 0x10);
740 t = (data[6] << 2) | ((data[7] >> 6) & 3);
741 input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
743 } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
745 if ((features->type >= INTUOS4S && features->type <= INTUOS4L) ||
746 (features->type >= INTUOS5S && features->type <= INTUOS5L)) {
747 input_report_key(input, BTN_LEFT, data[6] & 0x01);
748 input_report_key(input, BTN_MIDDLE, data[6] & 0x02);
749 input_report_key(input, BTN_RIGHT, data[6] & 0x04);
750 input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7)
751 - ((data[7] & 0x40) >> 6));
752 input_report_key(input, BTN_SIDE, data[6] & 0x08);
753 input_report_key(input, BTN_EXTRA, data[6] & 0x10);
755 input_report_abs(input, ABS_TILT_X,
756 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
757 input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f);
759 /* 2D mouse packet */
760 input_report_key(input, BTN_LEFT, data[8] & 0x04);
761 input_report_key(input, BTN_MIDDLE, data[8] & 0x08);
762 input_report_key(input, BTN_RIGHT, data[8] & 0x10);
763 input_report_rel(input, REL_WHEEL, (data[8] & 0x01)
764 - ((data[8] & 0x02) >> 1));
766 /* I3 2D mouse side buttons */
767 if (features->type >= INTUOS3S && features->type <= INTUOS3L) {
768 input_report_key(input, BTN_SIDE, data[8] & 0x40);
769 input_report_key(input, BTN_EXTRA, data[8] & 0x20);
772 } else if ((features->type < INTUOS3S || features->type == INTUOS3L ||
773 features->type == INTUOS4L || features->type == INTUOS5L) &&
774 wacom->tool[idx] == BTN_TOOL_LENS) {
775 /* Lens cursor packets */
776 input_report_key(input, BTN_LEFT, data[8] & 0x01);
777 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
778 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
779 input_report_key(input, BTN_SIDE, data[8] & 0x10);
780 input_report_key(input, BTN_EXTRA, data[8] & 0x08);
784 input_report_abs(input, ABS_MISC, wacom->id[idx]); /* report tool id */
785 input_report_key(input, wacom->tool[idx], 1);
786 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
790 static int find_slot_from_contactid(struct wacom_wac *wacom, int contactid)
792 int touch_max = wacom->features.touch_max;
798 for (i = 0; i < touch_max; ++i) {
799 if (wacom->slots[i] == contactid)
802 for (i = 0; i < touch_max; ++i) {
803 if (wacom->slots[i] == -1)
809 static int wacom_mt_touch(struct wacom_wac *wacom)
811 struct input_dev *input = wacom->input;
812 char *data = wacom->data;
814 int current_num_contacts = data[2];
815 int contacts_to_send = 0;
818 * First packet resets the counter since only the first
819 * packet in series will have non-zero current_num_contacts.
821 if (current_num_contacts)
822 wacom->num_contacts_left = current_num_contacts;
824 /* There are at most 5 contacts per packet */
825 contacts_to_send = min(5, wacom->num_contacts_left);
827 for (i = 0; i < contacts_to_send; i++) {
828 int offset = (WACOM_BYTES_PER_MT_PACKET * i) + 3;
829 bool touch = data[offset] & 0x1;
830 int id = le16_to_cpup((__le16 *)&data[offset + 1]);
831 int slot = find_slot_from_contactid(wacom, id);
836 input_mt_slot(input, slot);
837 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
839 int x = le16_to_cpup((__le16 *)&data[offset + 7]);
840 int y = le16_to_cpup((__le16 *)&data[offset + 9]);
841 input_report_abs(input, ABS_MT_POSITION_X, x);
842 input_report_abs(input, ABS_MT_POSITION_Y, y);
844 wacom->slots[slot] = touch ? id : -1;
847 input_mt_report_pointer_emulation(input, true);
849 wacom->num_contacts_left -= contacts_to_send;
850 if (wacom->num_contacts_left < 0)
851 wacom->num_contacts_left = 0;
856 static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
858 struct input_dev *input = wacom->input;
859 unsigned char *data = wacom->data;
860 int contact_with_no_pen_down_count = 0;
863 for (i = 0; i < 2; i++) {
864 int p = data[1] & (1 << i);
865 bool touch = p && !wacom->shared->stylus_in_proximity;
867 input_mt_slot(input, i);
868 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
870 int x = le16_to_cpup((__le16 *)&data[i * 2 + 2]) & 0x7fff;
871 int y = le16_to_cpup((__le16 *)&data[i * 2 + 6]) & 0x7fff;
873 input_report_abs(input, ABS_MT_POSITION_X, x);
874 input_report_abs(input, ABS_MT_POSITION_Y, y);
875 contact_with_no_pen_down_count++;
879 /* keep touch state for pen event */
880 wacom->shared->touch_down = (contact_with_no_pen_down_count > 0);
882 input_mt_report_pointer_emulation(input, true);
887 static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
889 char *data = wacom->data;
890 struct input_dev *input = wacom->input;
894 if (wacom->features.touch_max > 1 || len > WACOM_PKGLEN_TPC2FG)
897 if (!wacom->shared->stylus_in_proximity) {
898 if (len == WACOM_PKGLEN_TPC1FG) {
899 prox = data[0] & 0x01;
900 x = get_unaligned_le16(&data[1]);
901 y = get_unaligned_le16(&data[3]);
903 prox = data[1] & 0x01;
904 x = le16_to_cpup((__le16 *)&data[2]);
905 y = le16_to_cpup((__le16 *)&data[4]);
908 /* force touch out when pen is in prox */
912 input_report_abs(input, ABS_X, x);
913 input_report_abs(input, ABS_Y, y);
915 input_report_key(input, BTN_TOUCH, prox);
917 /* keep touch state for pen events */
918 wacom->shared->touch_down = prox;
923 static int wacom_tpc_pen(struct wacom_wac *wacom)
925 struct wacom_features *features = &wacom->features;
926 char *data = wacom->data;
927 struct input_dev *input = wacom->input;
929 bool prox = data[1] & 0x20;
931 if (!wacom->shared->stylus_in_proximity) /* first in prox */
932 /* Going into proximity select tool */
933 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
935 /* keep pen state for touch events */
936 wacom->shared->stylus_in_proximity = prox;
938 /* send pen events only when touch is up or forced out */
939 if (!wacom->shared->touch_down) {
940 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
941 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
942 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
943 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
944 pressure = ((data[7] & 0x01) << 8) | data[6];
946 pressure = features->pressure_max + pressure + 1;
947 input_report_abs(input, ABS_PRESSURE, pressure);
948 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
949 input_report_key(input, wacom->tool[0], prox);
956 static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
958 char *data = wacom->data;
960 dev_dbg(wacom->input->dev.parent,
961 "%s: received report #%d\n", __func__, data[0]);
964 case WACOM_PKGLEN_TPC1FG:
965 return wacom_tpc_single_touch(wacom, len);
967 case WACOM_PKGLEN_TPC2FG:
968 return wacom_tpc_mt_touch(wacom);
972 case WACOM_REPORT_TPC1FG:
973 case WACOM_REPORT_TPCHID:
974 case WACOM_REPORT_TPCST:
975 case WACOM_REPORT_TPC1FGE:
976 return wacom_tpc_single_touch(wacom, len);
978 case WACOM_REPORT_TPCMT:
979 return wacom_mt_touch(wacom);
981 case WACOM_REPORT_PENABLED:
982 return wacom_tpc_pen(wacom);
989 static int wacom_bpt_touch(struct wacom_wac *wacom)
991 struct wacom_features *features = &wacom->features;
992 struct input_dev *input = wacom->input;
993 unsigned char *data = wacom->data;
999 for (i = 0; i < 2; i++) {
1000 int offset = (data[1] & 0x80) ? (8 * i) : (9 * i);
1001 bool touch = data[offset + 3] & 0x80;
1004 * Touch events need to be disabled while stylus is
1005 * in proximity because user's hand is resting on touchpad
1006 * and sending unwanted events. User expects tablet buttons
1007 * to continue working though.
1009 touch = touch && !wacom->shared->stylus_in_proximity;
1011 input_mt_slot(input, i);
1012 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1014 int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff;
1015 int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff;
1016 if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) {
1020 input_report_abs(input, ABS_MT_POSITION_X, x);
1021 input_report_abs(input, ABS_MT_POSITION_Y, y);
1025 input_mt_report_pointer_emulation(input, true);
1027 input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
1028 input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
1029 input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
1030 input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
1037 static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
1039 struct input_dev *input = wacom->input;
1040 int slot_id = data[0] - 2; /* data[0] is between 2 and 17 */
1041 bool touch = data[1] & 0x80;
1043 touch = touch && !wacom->shared->stylus_in_proximity;
1045 input_mt_slot(input, slot_id);
1046 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1049 int x = (data[2] << 4) | (data[4] >> 4);
1050 int y = (data[3] << 4) | (data[4] & 0x0f);
1053 // "a" is a scaled-down area which we assume is roughly
1054 // circular and which can be described as: a=(pi*r^2)/C.
1055 int x_res = input_abs_get_res(input, ABS_X);
1056 int y_res = input_abs_get_res(input, ABS_Y);
1057 int width = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE);
1058 int height = width * y_res / x_res;
1060 input_report_abs(input, ABS_MT_POSITION_X, x);
1061 input_report_abs(input, ABS_MT_POSITION_Y, y);
1062 input_report_abs(input, ABS_MT_TOUCH_MAJOR, width);
1063 input_report_abs(input, ABS_MT_TOUCH_MINOR, height);
1067 static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
1069 struct input_dev *input = wacom->input;
1071 input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
1072 input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
1073 input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
1074 input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
1077 static int wacom_bpt3_touch(struct wacom_wac *wacom)
1079 struct input_dev *input = wacom->input;
1080 unsigned char *data = wacom->data;
1081 int count = data[1] & 0x07;
1084 if (data[0] != 0x02)
1087 /* data has up to 7 fixed sized 8-byte messages starting at data[2] */
1088 for (i = 0; i < count; i++) {
1089 int offset = (8 * i) + 2;
1090 int msg_id = data[offset];
1092 if (msg_id >= 2 && msg_id <= 17)
1093 wacom_bpt3_touch_msg(wacom, data + offset);
1094 else if (msg_id == 128)
1095 wacom_bpt3_button_msg(wacom, data + offset);
1099 input_mt_report_pointer_emulation(input, true);
1106 static int wacom_bpt_pen(struct wacom_wac *wacom)
1108 struct input_dev *input = wacom->input;
1109 unsigned char *data = wacom->data;
1110 int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
1112 if (data[0] != 0x02)
1115 prox = (data[1] & 0x20) == 0x20;
1118 * All reports shared between PEN and RUBBER tool must be
1119 * forced to a known starting value (zero) when transitioning to
1122 * If not reset then, to userspace, it will look like lost events
1123 * if new tool comes in-prox with same values as previous tool sent.
1125 * Hardware does report zero in most out-of-prox cases but not all.
1128 if (!wacom->shared->stylus_in_proximity) {
1129 if (data[1] & 0x08) {
1130 wacom->tool[0] = BTN_TOOL_RUBBER;
1131 wacom->id[0] = ERASER_DEVICE_ID;
1133 wacom->tool[0] = BTN_TOOL_PEN;
1134 wacom->id[0] = STYLUS_DEVICE_ID;
1136 wacom->shared->stylus_in_proximity = true;
1138 x = le16_to_cpup((__le16 *)&data[2]);
1139 y = le16_to_cpup((__le16 *)&data[4]);
1140 p = le16_to_cpup((__le16 *)&data[6]);
1142 * Convert distance from out prox to distance from tablet.
1143 * distance will be greater than distance_max once
1144 * touching and applying pressure; do not report negative
1147 if (data[8] <= wacom->features.distance_max)
1148 d = wacom->features.distance_max - data[8];
1150 pen = data[1] & 0x01;
1151 btn1 = data[1] & 0x02;
1152 btn2 = data[1] & 0x04;
1155 input_report_key(input, BTN_TOUCH, pen);
1156 input_report_key(input, BTN_STYLUS, btn1);
1157 input_report_key(input, BTN_STYLUS2, btn2);
1159 input_report_abs(input, ABS_X, x);
1160 input_report_abs(input, ABS_Y, y);
1161 input_report_abs(input, ABS_PRESSURE, p);
1162 input_report_abs(input, ABS_DISTANCE, d);
1166 wacom->shared->stylus_in_proximity = false;
1169 input_report_key(input, wacom->tool[0], prox); /* PEN or RUBBER */
1170 input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
1175 static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
1177 if (len == WACOM_PKGLEN_BBTOUCH)
1178 return wacom_bpt_touch(wacom);
1179 else if (len == WACOM_PKGLEN_BBTOUCH3)
1180 return wacom_bpt3_touch(wacom);
1181 else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
1182 return wacom_bpt_pen(wacom);
1187 static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
1189 unsigned char *data = wacom->data;
1192 if (len != WACOM_PKGLEN_WIRELESS || data[0] != 0x80)
1195 connected = data[1] & 0x01;
1199 pid = get_unaligned_be16(&data[6]);
1200 battery = data[5] & 0x3f;
1201 if (wacom->pid != pid) {
1203 wacom_schedule_work(wacom);
1205 wacom->battery_capacity = battery;
1206 } else if (wacom->pid != 0) {
1207 /* disconnected while previously connected */
1209 wacom_schedule_work(wacom);
1210 wacom->battery_capacity = 0;
1216 void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
1220 switch (wacom_wac->features.type) {
1222 sync = wacom_penpartner_irq(wacom_wac);
1226 sync = wacom_pl_irq(wacom_wac);
1232 sync = wacom_graphire_irq(wacom_wac);
1236 sync = wacom_ptu_irq(wacom_wac);
1240 sync = wacom_dtu_irq(wacom_wac);
1255 sync = wacom_intuos_irq(wacom_wac);
1261 if (len == WACOM_PKGLEN_BBTOUCH3)
1262 sync = wacom_bpt3_touch(wacom_wac);
1264 sync = wacom_intuos_irq(wacom_wac);
1271 sync = wacom_tpc_irq(wacom_wac, len);
1275 sync = wacom_bpt_irq(wacom_wac, len);
1279 sync = wacom_wireless_irq(wacom_wac, len);
1288 input_sync(wacom_wac->input);
1291 static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
1293 struct input_dev *input_dev = wacom_wac->input;
1295 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
1297 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1298 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
1299 __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
1300 __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
1301 __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
1302 __set_bit(BTN_STYLUS, input_dev->keybit);
1303 __set_bit(BTN_STYLUS2, input_dev->keybit);
1305 input_set_abs_params(input_dev, ABS_DISTANCE,
1306 0, wacom_wac->features.distance_max, 0, 0);
1307 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
1308 input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0);
1309 input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0);
1312 static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
1314 struct input_dev *input_dev = wacom_wac->input;
1316 input_set_capability(input_dev, EV_REL, REL_WHEEL);
1318 wacom_setup_cintiq(wacom_wac);
1320 __set_bit(BTN_LEFT, input_dev->keybit);
1321 __set_bit(BTN_RIGHT, input_dev->keybit);
1322 __set_bit(BTN_MIDDLE, input_dev->keybit);
1323 __set_bit(BTN_SIDE, input_dev->keybit);
1324 __set_bit(BTN_EXTRA, input_dev->keybit);
1325 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
1326 __set_bit(BTN_TOOL_LENS, input_dev->keybit);
1328 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
1329 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
1332 void wacom_setup_device_quirks(struct wacom_features *features)
1335 /* touch device found but size is not defined. use default */
1336 if (features->device_type == BTN_TOOL_FINGER && !features->x_max) {
1337 features->x_max = 1023;
1338 features->y_max = 1023;
1341 /* these device have multiple inputs */
1342 if (features->type >= WIRELESS ||
1343 (features->type >= INTUOS5S && features->type <= INTUOS5L) ||
1344 (features->oVid && features->oPid))
1345 features->quirks |= WACOM_QUIRK_MULTI_INPUT;
1347 /* quirk for bamboo touch with 2 low res touches */
1348 if (features->type == BAMBOO_PT &&
1349 features->pktlen == WACOM_PKGLEN_BBTOUCH) {
1350 features->x_max <<= 5;
1351 features->y_max <<= 5;
1352 features->x_fuzz <<= 5;
1353 features->y_fuzz <<= 5;
1354 features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;
1357 if (features->type == WIRELESS) {
1359 /* monitor never has input and pen/touch have delayed create */
1360 features->quirks |= WACOM_QUIRK_NO_INPUT;
1362 /* must be monitor interface if no device_type set */
1363 if (!features->device_type)
1364 features->quirks |= WACOM_QUIRK_MONITOR;
1368 static unsigned int wacom_calculate_touch_res(unsigned int logical_max,
1369 unsigned int physical_max)
1371 /* Touch physical dimensions are in 100th of mm */
1372 return (logical_max * 100) / physical_max;
1375 int wacom_setup_input_capabilities(struct input_dev *input_dev,
1376 struct wacom_wac *wacom_wac)
1378 struct wacom_features *features = &wacom_wac->features;
1381 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
1383 __set_bit(BTN_TOUCH, input_dev->keybit);
1385 input_set_abs_params(input_dev, ABS_X, 0, features->x_max,
1386 features->x_fuzz, 0);
1387 input_set_abs_params(input_dev, ABS_Y, 0, features->y_max,
1388 features->y_fuzz, 0);
1390 if (features->device_type == BTN_TOOL_PEN) {
1391 input_set_abs_params(input_dev, ABS_PRESSURE, 0, features->pressure_max,
1392 features->pressure_fuzz, 0);
1394 /* penabled devices have fixed resolution for each model */
1395 input_abs_set_res(input_dev, ABS_X, features->x_resolution);
1396 input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
1398 input_abs_set_res(input_dev, ABS_X,
1399 wacom_calculate_touch_res(features->x_max,
1401 input_abs_set_res(input_dev, ABS_Y,
1402 wacom_calculate_touch_res(features->y_max,
1406 __set_bit(ABS_MISC, input_dev->absbit);
1408 switch (wacom_wac->features.type) {
1410 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
1414 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
1416 __set_bit(BTN_BACK, input_dev->keybit);
1417 __set_bit(BTN_FORWARD, input_dev->keybit);
1421 input_set_capability(input_dev, EV_REL, REL_WHEEL);
1423 __set_bit(BTN_LEFT, input_dev->keybit);
1424 __set_bit(BTN_RIGHT, input_dev->keybit);
1425 __set_bit(BTN_MIDDLE, input_dev->keybit);
1427 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1428 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
1429 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
1430 __set_bit(BTN_STYLUS, input_dev->keybit);
1431 __set_bit(BTN_STYLUS2, input_dev->keybit);
1433 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1437 __set_bit(BTN_A, input_dev->keybit);
1438 __set_bit(BTN_B, input_dev->keybit);
1439 __set_bit(BTN_C, input_dev->keybit);
1440 __set_bit(BTN_X, input_dev->keybit);
1441 __set_bit(BTN_Y, input_dev->keybit);
1442 __set_bit(BTN_Z, input_dev->keybit);
1444 for (i = 0; i < 10; i++)
1445 __set_bit(BTN_0 + i, input_dev->keybit);
1447 __set_bit(KEY_PROG1, input_dev->keybit);
1448 __set_bit(KEY_PROG2, input_dev->keybit);
1449 __set_bit(KEY_PROG3, input_dev->keybit);
1451 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
1452 input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
1453 wacom_setup_cintiq(wacom_wac);
1457 __set_bit(KEY_PROG1, input_dev->keybit);
1458 __set_bit(KEY_PROG2, input_dev->keybit);
1459 __set_bit(KEY_PROG3, input_dev->keybit);
1463 __set_bit(BTN_A, input_dev->keybit);
1464 __set_bit(BTN_B, input_dev->keybit);
1465 __set_bit(BTN_C, input_dev->keybit);
1466 __set_bit(BTN_X, input_dev->keybit);
1467 __set_bit(BTN_Y, input_dev->keybit);
1468 __set_bit(BTN_Z, input_dev->keybit);
1469 __set_bit(BTN_BASE, input_dev->keybit);
1470 __set_bit(BTN_BASE2, input_dev->keybit);
1474 __set_bit(BTN_8, input_dev->keybit);
1475 __set_bit(BTN_9, input_dev->keybit);
1479 for (i = 0; i < 8; i++)
1480 __set_bit(BTN_0 + i, input_dev->keybit);
1482 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
1483 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
1484 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
1486 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
1488 wacom_setup_cintiq(wacom_wac);
1493 __set_bit(BTN_4, input_dev->keybit);
1494 __set_bit(BTN_5, input_dev->keybit);
1495 __set_bit(BTN_6, input_dev->keybit);
1496 __set_bit(BTN_7, input_dev->keybit);
1498 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
1502 __set_bit(BTN_0, input_dev->keybit);
1503 __set_bit(BTN_1, input_dev->keybit);
1504 __set_bit(BTN_2, input_dev->keybit);
1505 __set_bit(BTN_3, input_dev->keybit);
1507 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
1508 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
1512 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1514 wacom_setup_intuos(wacom_wac);
1519 if (features->device_type == BTN_TOOL_PEN) {
1520 __set_bit(BTN_7, input_dev->keybit);
1521 __set_bit(BTN_8, input_dev->keybit);
1526 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1528 if (features->device_type == BTN_TOOL_PEN) {
1529 for (i = 0; i < 7; i++)
1530 __set_bit(BTN_0 + i, input_dev->keybit);
1532 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
1533 features->distance_max,
1536 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
1538 wacom_setup_intuos(wacom_wac);
1539 } else if (features->device_type == BTN_TOOL_FINGER) {
1540 __clear_bit(ABS_MISC, input_dev->absbit);
1542 __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
1543 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
1544 __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit);
1545 __set_bit(BTN_TOOL_QUADTAP, input_dev->keybit);
1547 input_mt_init_slots(input_dev, features->touch_max, 0);
1549 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
1550 0, features->x_max, 0, 0);
1551 input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR,
1552 0, features->y_max, 0, 0);
1554 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
1556 features->x_fuzz, 0);
1557 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
1559 features->y_fuzz, 0);
1565 __set_bit(BTN_7, input_dev->keybit);
1566 __set_bit(BTN_8, input_dev->keybit);
1570 for (i = 0; i < 7; i++)
1571 __set_bit(BTN_0 + i, input_dev->keybit);
1573 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
1574 wacom_setup_intuos(wacom_wac);
1576 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1580 if (features->device_type == BTN_TOOL_FINGER) {
1581 wacom_wac->slots = kmalloc(features->touch_max *
1584 if (!wacom_wac->slots)
1587 for (i = 0; i < features->touch_max; i++)
1588 wacom_wac->slots[i] = -1;
1593 if (features->device_type == BTN_TOOL_FINGER) {
1594 input_mt_init_slots(input_dev, features->touch_max, 0);
1595 input_set_abs_params(input_dev, ABS_MT_TOOL_TYPE,
1596 0, MT_TOOL_MAX, 0, 0);
1597 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
1598 0, features->x_max, 0, 0);
1599 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
1600 0, features->y_max, 0, 0);
1606 __clear_bit(ABS_MISC, input_dev->absbit);
1608 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
1610 if (features->device_type != BTN_TOOL_PEN)
1611 break; /* no need to process stylus stuff */
1617 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
1618 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1619 __set_bit(BTN_STYLUS, input_dev->keybit);
1620 __set_bit(BTN_STYLUS2, input_dev->keybit);
1622 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
1626 __set_bit(BTN_STYLUS2, input_dev->keybit);
1630 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
1631 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1632 __set_bit(BTN_STYLUS, input_dev->keybit);
1634 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1638 __clear_bit(ABS_MISC, input_dev->absbit);
1640 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1642 if (features->device_type == BTN_TOOL_FINGER) {
1643 __set_bit(BTN_LEFT, input_dev->keybit);
1644 __set_bit(BTN_FORWARD, input_dev->keybit);
1645 __set_bit(BTN_BACK, input_dev->keybit);
1646 __set_bit(BTN_RIGHT, input_dev->keybit);
1648 __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
1649 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
1650 input_mt_init_slots(input_dev, features->touch_max, 0);
1652 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
1653 __set_bit(BTN_TOOL_TRIPLETAP,
1655 __set_bit(BTN_TOOL_QUADTAP,
1658 input_set_abs_params(input_dev,
1660 0, features->x_max, 0, 0);
1661 input_set_abs_params(input_dev,
1663 0, features->y_max, 0, 0);
1666 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
1668 features->x_fuzz, 0);
1669 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
1671 features->y_fuzz, 0);
1672 } else if (features->device_type == BTN_TOOL_PEN) {
1673 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1674 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
1675 __set_bit(BTN_STYLUS, input_dev->keybit);
1676 __set_bit(BTN_STYLUS2, input_dev->keybit);
1677 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
1678 features->distance_max,
1686 static const struct wacom_features wacom_features_0x00 =
1687 { "Wacom Penpartner", WACOM_PKGLEN_PENPRTN, 5040, 3780, 255,
1688 0, PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
1689 static const struct wacom_features wacom_features_0x10 =
1690 { "Wacom Graphire", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511,
1691 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
1692 static const struct wacom_features wacom_features_0x11 =
1693 { "Wacom Graphire2 4x5", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511,
1694 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
1695 static const struct wacom_features wacom_features_0x12 =
1696 { "Wacom Graphire2 5x7", WACOM_PKGLEN_GRAPHIRE, 13918, 10206, 511,
1697 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
1698 static const struct wacom_features wacom_features_0x13 =
1699 { "Wacom Graphire3", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511,
1700 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
1701 static const struct wacom_features wacom_features_0x14 =
1702 { "Wacom Graphire3 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511,
1703 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
1704 static const struct wacom_features wacom_features_0x15 =
1705 { "Wacom Graphire4 4x5", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511,
1706 63, WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
1707 static const struct wacom_features wacom_features_0x16 =
1708 { "Wacom Graphire4 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511,
1709 63, WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
1710 static const struct wacom_features wacom_features_0x17 =
1711 { "Wacom BambooFun 4x5", WACOM_PKGLEN_BBFUN, 14760, 9225, 511,
1712 63, WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1713 static const struct wacom_features wacom_features_0x18 =
1714 { "Wacom BambooFun 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 511,
1715 63, WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1716 static const struct wacom_features wacom_features_0x19 =
1717 { "Wacom Bamboo1 Medium", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511,
1718 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
1719 static const struct wacom_features wacom_features_0x60 =
1720 { "Wacom Volito", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511,
1721 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
1722 static const struct wacom_features wacom_features_0x61 =
1723 { "Wacom PenStation2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 255,
1724 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
1725 static const struct wacom_features wacom_features_0x62 =
1726 { "Wacom Volito2 4x5", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511,
1727 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
1728 static const struct wacom_features wacom_features_0x63 =
1729 { "Wacom Volito2 2x3", WACOM_PKGLEN_GRAPHIRE, 3248, 2320, 511,
1730 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
1731 static const struct wacom_features wacom_features_0x64 =
1732 { "Wacom PenPartner2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 511,
1733 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
1734 static const struct wacom_features wacom_features_0x65 =
1735 { "Wacom Bamboo", WACOM_PKGLEN_BBFUN, 14760, 9225, 511,
1736 63, WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1737 static const struct wacom_features wacom_features_0x69 =
1738 { "Wacom Bamboo1", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511,
1739 63, GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
1740 static const struct wacom_features wacom_features_0x6A =
1741 { "Wacom Bamboo1 4x6", WACOM_PKGLEN_GRAPHIRE, 14760, 9225, 1023,
1742 63, GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1743 static const struct wacom_features wacom_features_0x6B =
1744 { "Wacom Bamboo1 5x8", WACOM_PKGLEN_GRAPHIRE, 21648, 13530, 1023,
1745 63, GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1746 static const struct wacom_features wacom_features_0x20 =
1747 { "Wacom Intuos 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023,
1748 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1749 static const struct wacom_features wacom_features_0x21 =
1750 { "Wacom Intuos 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023,
1751 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1752 static const struct wacom_features wacom_features_0x22 =
1753 { "Wacom Intuos 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023,
1754 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1755 static const struct wacom_features wacom_features_0x23 =
1756 { "Wacom Intuos 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023,
1757 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1758 static const struct wacom_features wacom_features_0x24 =
1759 { "Wacom Intuos 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023,
1760 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1761 static const struct wacom_features wacom_features_0x30 =
1762 { "Wacom PL400", WACOM_PKGLEN_GRAPHIRE, 5408, 4056, 255,
1763 0, PL, WACOM_PL_RES, WACOM_PL_RES };
1764 static const struct wacom_features wacom_features_0x31 =
1765 { "Wacom PL500", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 255,
1766 0, PL, WACOM_PL_RES, WACOM_PL_RES };
1767 static const struct wacom_features wacom_features_0x32 =
1768 { "Wacom PL600", WACOM_PKGLEN_GRAPHIRE, 6126, 4604, 255,
1769 0, PL, WACOM_PL_RES, WACOM_PL_RES };
1770 static const struct wacom_features wacom_features_0x33 =
1771 { "Wacom PL600SX", WACOM_PKGLEN_GRAPHIRE, 6260, 5016, 255,
1772 0, PL, WACOM_PL_RES, WACOM_PL_RES };
1773 static const struct wacom_features wacom_features_0x34 =
1774 { "Wacom PL550", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 511,
1775 0, PL, WACOM_PL_RES, WACOM_PL_RES };
1776 static const struct wacom_features wacom_features_0x35 =
1777 { "Wacom PL800", WACOM_PKGLEN_GRAPHIRE, 7220, 5780, 511,
1778 0, PL, WACOM_PL_RES, WACOM_PL_RES };
1779 static const struct wacom_features wacom_features_0x37 =
1780 { "Wacom PL700", WACOM_PKGLEN_GRAPHIRE, 6758, 5406, 511,
1781 0, PL, WACOM_PL_RES, WACOM_PL_RES };
1782 static const struct wacom_features wacom_features_0x38 =
1783 { "Wacom PL510", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511,
1784 0, PL, WACOM_PL_RES, WACOM_PL_RES };
1785 static const struct wacom_features wacom_features_0x39 =
1786 { "Wacom DTU710", WACOM_PKGLEN_GRAPHIRE, 34080, 27660, 511,
1787 0, PL, WACOM_PL_RES, WACOM_PL_RES };
1788 static const struct wacom_features wacom_features_0xC4 =
1789 { "Wacom DTF521", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511,
1790 0, PL, WACOM_PL_RES, WACOM_PL_RES };
1791 static const struct wacom_features wacom_features_0xC0 =
1792 { "Wacom DTF720", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511,
1793 0, PL, WACOM_PL_RES, WACOM_PL_RES };
1794 static const struct wacom_features wacom_features_0xC2 =
1795 { "Wacom DTF720a", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511,
1796 0, PL, WACOM_PL_RES, WACOM_PL_RES };
1797 static const struct wacom_features wacom_features_0x03 =
1798 { "Wacom Cintiq Partner", WACOM_PKGLEN_GRAPHIRE, 20480, 15360, 511,
1799 0, PTU, WACOM_PL_RES, WACOM_PL_RES };
1800 static const struct wacom_features wacom_features_0x41 =
1801 { "Wacom Intuos2 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023,
1802 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1803 static const struct wacom_features wacom_features_0x42 =
1804 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023,
1805 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1806 static const struct wacom_features wacom_features_0x43 =
1807 { "Wacom Intuos2 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023,
1808 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1809 static const struct wacom_features wacom_features_0x44 =
1810 { "Wacom Intuos2 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023,
1811 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1812 static const struct wacom_features wacom_features_0x45 =
1813 { "Wacom Intuos2 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023,
1814 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1815 static const struct wacom_features wacom_features_0xB0 =
1816 { "Wacom Intuos3 4x5", WACOM_PKGLEN_INTUOS, 25400, 20320, 1023,
1817 63, INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1818 static const struct wacom_features wacom_features_0xB1 =
1819 { "Wacom Intuos3 6x8", WACOM_PKGLEN_INTUOS, 40640, 30480, 1023,
1820 63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1821 static const struct wacom_features wacom_features_0xB2 =
1822 { "Wacom Intuos3 9x12", WACOM_PKGLEN_INTUOS, 60960, 45720, 1023,
1823 63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1824 static const struct wacom_features wacom_features_0xB3 =
1825 { "Wacom Intuos3 12x12", WACOM_PKGLEN_INTUOS, 60960, 60960, 1023,
1826 63, INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1827 static const struct wacom_features wacom_features_0xB4 =
1828 { "Wacom Intuos3 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 1023,
1829 63, INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1830 static const struct wacom_features wacom_features_0xB5 =
1831 { "Wacom Intuos3 6x11", WACOM_PKGLEN_INTUOS, 54204, 31750, 1023,
1832 63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1833 static const struct wacom_features wacom_features_0xB7 =
1834 { "Wacom Intuos3 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 1023,
1835 63, INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1836 static const struct wacom_features wacom_features_0xB8 =
1837 { "Wacom Intuos4 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047,
1838 63, INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1839 static const struct wacom_features wacom_features_0xB9 =
1840 { "Wacom Intuos4 6x9", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047,
1841 63, INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1842 static const struct wacom_features wacom_features_0xBA =
1843 { "Wacom Intuos4 8x13", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047,
1844 63, INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1845 static const struct wacom_features wacom_features_0xBB =
1846 { "Wacom Intuos4 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 2047,
1847 63, INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1848 static const struct wacom_features wacom_features_0xBC =
1849 { "Wacom Intuos4 WL", WACOM_PKGLEN_INTUOS, 40840, 25400, 2047,
1850 63, INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1851 static const struct wacom_features wacom_features_0x26 =
1852 { "Wacom Intuos5 touch S", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047,
1853 63, INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
1855 static const struct wacom_features wacom_features_0x27 =
1856 { "Wacom Intuos5 touch M", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047,
1857 63, INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
1859 static const struct wacom_features wacom_features_0x28 =
1860 { "Wacom Intuos5 touch L", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047,
1861 63, INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
1863 static const struct wacom_features wacom_features_0x29 =
1864 { "Wacom Intuos5 S", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047,
1865 63, INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1866 static const struct wacom_features wacom_features_0x2A =
1867 { "Wacom Intuos5 M", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047,
1868 63, INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1869 static const struct wacom_features wacom_features_0xF4 =
1870 { "Wacom Cintiq 24HD", WACOM_PKGLEN_INTUOS, 104480, 65600, 2047,
1871 63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1872 static const struct wacom_features wacom_features_0xF8 =
1873 { "Wacom Cintiq 24HD touch", WACOM_PKGLEN_INTUOS, 104480, 65600, 2047,
1874 63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1875 static const struct wacom_features wacom_features_0x3F =
1876 { "Wacom Cintiq 21UX", WACOM_PKGLEN_INTUOS, 87200, 65600, 1023,
1877 63, CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1878 static const struct wacom_features wacom_features_0xC5 =
1879 { "Wacom Cintiq 20WSX", WACOM_PKGLEN_INTUOS, 86680, 54180, 1023,
1880 63, WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1881 static const struct wacom_features wacom_features_0xC6 =
1882 { "Wacom Cintiq 12WX", WACOM_PKGLEN_INTUOS, 53020, 33440, 1023,
1883 63, WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1884 static const struct wacom_features wacom_features_0xC7 =
1885 { "Wacom DTU1931", WACOM_PKGLEN_GRAPHIRE, 37832, 30305, 511,
1886 0, PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1887 static const struct wacom_features wacom_features_0xCE =
1888 { "Wacom DTU2231", WACOM_PKGLEN_GRAPHIRE, 47864, 27011, 511,
1889 0, DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1890 static const struct wacom_features wacom_features_0xF0 =
1891 { "Wacom DTU1631", WACOM_PKGLEN_GRAPHIRE, 34623, 19553, 511,
1892 0, DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1893 static const struct wacom_features wacom_features_0xCC =
1894 { "Wacom Cintiq 21UX2", WACOM_PKGLEN_INTUOS, 87200, 65600, 2047,
1895 63, WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1896 static const struct wacom_features wacom_features_0xFA =
1897 { "Wacom Cintiq 22HD", WACOM_PKGLEN_INTUOS, 95840, 54260, 2047,
1898 63, WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1899 static const struct wacom_features wacom_features_0x90 =
1900 { "Wacom ISDv4 90", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1901 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1902 static const struct wacom_features wacom_features_0x93 =
1903 { "Wacom ISDv4 93", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1904 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1905 static const struct wacom_features wacom_features_0x97 =
1906 { "Wacom ISDv4 97", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 511,
1907 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1908 static const struct wacom_features wacom_features_0x9A =
1909 { "Wacom ISDv4 9A", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1910 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1911 static const struct wacom_features wacom_features_0x9F =
1912 { "Wacom ISDv4 9F", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1913 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1914 static const struct wacom_features wacom_features_0xE2 =
1915 { "Wacom ISDv4 E2", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255,
1916 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1918 static const struct wacom_features wacom_features_0xE3 =
1919 { "Wacom ISDv4 E3", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255,
1920 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1922 static const struct wacom_features wacom_features_0xE5 =
1923 { "Wacom ISDv4 E5", WACOM_PKGLEN_MTOUCH, 26202, 16325, 255,
1924 0, MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1925 static const struct wacom_features wacom_features_0xE6 =
1926 { "Wacom ISDv4 E6", WACOM_PKGLEN_TPC2FG, 27760, 15694, 255,
1927 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1929 static const struct wacom_features wacom_features_0xEC =
1930 { "Wacom ISDv4 EC", WACOM_PKGLEN_GRAPHIRE, 25710, 14500, 255,
1931 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1932 static const struct wacom_features wacom_features_0xED =
1933 { "Wacom ISDv4 ED", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1934 0, TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1935 static const struct wacom_features wacom_features_0xEF =
1936 { "Wacom ISDv4 EF", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1937 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1938 static const struct wacom_features wacom_features_0x47 =
1939 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023,
1940 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1941 static const struct wacom_features wacom_features_0x84 =
1942 { "Wacom Wireless Receiver", WACOM_PKGLEN_WIRELESS, 0, 0, 0,
1943 0, WIRELESS, 0, 0, .touch_max = 16 };
1944 static const struct wacom_features wacom_features_0xD0 =
1945 { "Wacom Bamboo 2FG", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
1946 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1948 static const struct wacom_features wacom_features_0xD1 =
1949 { "Wacom Bamboo 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
1950 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1952 static const struct wacom_features wacom_features_0xD2 =
1953 { "Wacom Bamboo Craft", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
1954 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1955 static const struct wacom_features wacom_features_0xD3 =
1956 { "Wacom Bamboo 2FG 6x8", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023,
1957 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1959 static const struct wacom_features wacom_features_0xD4 =
1960 { "Wacom Bamboo Pen", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
1961 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1962 static const struct wacom_features wacom_features_0xD5 =
1963 { "Wacom Bamboo Pen 6x8", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023,
1964 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1965 static const struct wacom_features wacom_features_0xD6 =
1966 { "Wacom BambooPT 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
1967 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1969 static const struct wacom_features wacom_features_0xD7 =
1970 { "Wacom BambooPT 2FG Small", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
1971 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1973 static const struct wacom_features wacom_features_0xD8 =
1974 { "Wacom Bamboo Comic 2FG", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023,
1975 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1977 static const struct wacom_features wacom_features_0xDA =
1978 { "Wacom Bamboo 2FG 4x5 SE", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
1979 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1981 static struct wacom_features wacom_features_0xDB =
1982 { "Wacom Bamboo 2FG 6x8 SE", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023,
1983 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1985 static const struct wacom_features wacom_features_0xDD =
1986 { "Wacom Bamboo Connect", WACOM_PKGLEN_BBPEN, 14720, 9200, 1023,
1987 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
1988 static const struct wacom_features wacom_features_0xDE =
1989 { "Wacom Bamboo 16FG 4x5", WACOM_PKGLEN_BBPEN, 14720, 9200, 1023,
1990 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1992 static const struct wacom_features wacom_features_0xDF =
1993 { "Wacom Bamboo 16FG 6x8", WACOM_PKGLEN_BBPEN, 21648, 13700, 1023,
1994 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
1996 static const struct wacom_features wacom_features_0x6004 =
1997 { "ISD-V4", WACOM_PKGLEN_GRAPHIRE, 12800, 8000, 255,
1998 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2000 #define USB_DEVICE_WACOM(prod) \
2001 USB_DEVICE(USB_VENDOR_ID_WACOM, prod), \
2002 .driver_info = (kernel_ulong_t)&wacom_features_##prod
2004 #define USB_DEVICE_DETAILED(prod, class, sub, proto) \
2005 USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_WACOM, prod, class, \
2007 .driver_info = (kernel_ulong_t)&wacom_features_##prod
2009 #define USB_DEVICE_LENOVO(prod) \
2010 USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
2011 .driver_info = (kernel_ulong_t)&wacom_features_##prod
2013 const struct usb_device_id wacom_ids[] = {
2014 { USB_DEVICE_WACOM(0x00) },
2015 { USB_DEVICE_WACOM(0x10) },
2016 { USB_DEVICE_WACOM(0x11) },
2017 { USB_DEVICE_WACOM(0x12) },
2018 { USB_DEVICE_WACOM(0x13) },
2019 { USB_DEVICE_WACOM(0x14) },
2020 { USB_DEVICE_WACOM(0x15) },
2021 { USB_DEVICE_WACOM(0x16) },
2022 { USB_DEVICE_WACOM(0x17) },
2023 { USB_DEVICE_WACOM(0x18) },
2024 { USB_DEVICE_WACOM(0x19) },
2025 { USB_DEVICE_WACOM(0x60) },
2026 { USB_DEVICE_WACOM(0x61) },
2027 { USB_DEVICE_WACOM(0x62) },
2028 { USB_DEVICE_WACOM(0x63) },
2029 { USB_DEVICE_WACOM(0x64) },
2030 { USB_DEVICE_WACOM(0x65) },
2031 { USB_DEVICE_WACOM(0x69) },
2032 { USB_DEVICE_WACOM(0x6A) },
2033 { USB_DEVICE_WACOM(0x6B) },
2034 { USB_DEVICE_WACOM(0x20) },
2035 { USB_DEVICE_WACOM(0x21) },
2036 { USB_DEVICE_WACOM(0x22) },
2037 { USB_DEVICE_WACOM(0x23) },
2038 { USB_DEVICE_WACOM(0x24) },
2039 { USB_DEVICE_WACOM(0x30) },
2040 { USB_DEVICE_WACOM(0x31) },
2041 { USB_DEVICE_WACOM(0x32) },
2042 { USB_DEVICE_WACOM(0x33) },
2043 { USB_DEVICE_WACOM(0x34) },
2044 { USB_DEVICE_WACOM(0x35) },
2045 { USB_DEVICE_WACOM(0x37) },
2046 { USB_DEVICE_WACOM(0x38) },
2047 { USB_DEVICE_WACOM(0x39) },
2048 { USB_DEVICE_WACOM(0xC4) },
2049 { USB_DEVICE_WACOM(0xC0) },
2050 { USB_DEVICE_WACOM(0xC2) },
2051 { USB_DEVICE_WACOM(0x03) },
2052 { USB_DEVICE_WACOM(0x41) },
2053 { USB_DEVICE_WACOM(0x42) },
2054 { USB_DEVICE_WACOM(0x43) },
2055 { USB_DEVICE_WACOM(0x44) },
2056 { USB_DEVICE_WACOM(0x45) },
2057 { USB_DEVICE_WACOM(0xB0) },
2058 { USB_DEVICE_WACOM(0xB1) },
2059 { USB_DEVICE_WACOM(0xB2) },
2060 { USB_DEVICE_WACOM(0xB3) },
2061 { USB_DEVICE_WACOM(0xB4) },
2062 { USB_DEVICE_WACOM(0xB5) },
2063 { USB_DEVICE_WACOM(0xB7) },
2064 { USB_DEVICE_WACOM(0xB8) },
2065 { USB_DEVICE_WACOM(0xB9) },
2066 { USB_DEVICE_WACOM(0xBA) },
2067 { USB_DEVICE_WACOM(0xBB) },
2068 { USB_DEVICE_WACOM(0xBC) },
2069 { USB_DEVICE_WACOM(0x26) },
2070 { USB_DEVICE_WACOM(0x27) },
2071 { USB_DEVICE_WACOM(0x28) },
2072 { USB_DEVICE_WACOM(0x29) },
2073 { USB_DEVICE_WACOM(0x2A) },
2074 { USB_DEVICE_WACOM(0x3F) },
2075 { USB_DEVICE_WACOM(0xC5) },
2076 { USB_DEVICE_WACOM(0xC6) },
2077 { USB_DEVICE_WACOM(0xC7) },
2079 * DTU-2231 has two interfaces on the same configuration,
2082 { USB_DEVICE_DETAILED(0xCE, USB_CLASS_HID,
2083 USB_INTERFACE_SUBCLASS_BOOT,
2084 USB_INTERFACE_PROTOCOL_MOUSE) },
2085 { USB_DEVICE_WACOM(0x84) },
2086 { USB_DEVICE_WACOM(0xD0) },
2087 { USB_DEVICE_WACOM(0xD1) },
2088 { USB_DEVICE_WACOM(0xD2) },
2089 { USB_DEVICE_WACOM(0xD3) },
2090 { USB_DEVICE_WACOM(0xD4) },
2091 { USB_DEVICE_WACOM(0xD5) },
2092 { USB_DEVICE_WACOM(0xD6) },
2093 { USB_DEVICE_WACOM(0xD7) },
2094 { USB_DEVICE_WACOM(0xD8) },
2095 { USB_DEVICE_WACOM(0xDA) },
2096 { USB_DEVICE_WACOM(0xDB) },
2097 { USB_DEVICE_WACOM(0xDD) },
2098 { USB_DEVICE_WACOM(0xDE) },
2099 { USB_DEVICE_WACOM(0xDF) },
2100 { USB_DEVICE_WACOM(0xF0) },
2101 { USB_DEVICE_WACOM(0xCC) },
2102 { USB_DEVICE_WACOM(0x90) },
2103 { USB_DEVICE_WACOM(0x93) },
2104 { USB_DEVICE_WACOM(0x97) },
2105 { USB_DEVICE_WACOM(0x9A) },
2106 { USB_DEVICE_WACOM(0x9F) },
2107 { USB_DEVICE_WACOM(0xE2) },
2108 { USB_DEVICE_WACOM(0xE3) },
2109 { USB_DEVICE_WACOM(0xE5) },
2110 { USB_DEVICE_WACOM(0xE6) },
2111 { USB_DEVICE_WACOM(0xEC) },
2112 { USB_DEVICE_WACOM(0xED) },
2113 { USB_DEVICE_WACOM(0xEF) },
2114 { USB_DEVICE_WACOM(0x47) },
2115 { USB_DEVICE_WACOM(0xF4) },
2116 { USB_DEVICE_WACOM(0xF8) },
2117 { USB_DEVICE_WACOM(0xFA) },
2118 { USB_DEVICE_LENOVO(0x6004) },
2121 MODULE_DEVICE_TABLE(usb, wacom_ids);