]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/hid/wacom_wac.c
Input: wacom - handle Graphire BT tablets in wacom.ko
[mirror_ubuntu-artful-kernel.git] / drivers / hid / wacom_wac.c
1 /*
2 * drivers/input/tablet/wacom_wac.c
3 *
4 * USB Wacom tablet support - Wacom specific code
5 *
6 */
7
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.
13 */
14
15 #include "wacom_wac.h"
16 #include "wacom.h"
17 #include <linux/input/mt.h>
18 #include <linux/hid.h>
19
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
27
28 /*
29 * Scale factor relating reported contact size to logical contact area.
30 * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo
31 */
32 #define WACOM_CONTACT_AREA_SCALE 2607
33
34 /*
35 * Percent of battery capacity for Graphire.
36 * 8th value means AC online and show 100% capacity.
37 */
38 static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
39
40 static int wacom_penpartner_irq(struct wacom_wac *wacom)
41 {
42 unsigned char *data = wacom->data;
43 struct input_dev *input = wacom->input;
44
45 switch (data[0]) {
46 case 1:
47 if (data[5] & 0x80) {
48 wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
49 wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID;
50 input_report_key(input, wacom->tool[0], 1);
51 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
52 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
53 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
54 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
55 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127));
56 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
57 } else {
58 input_report_key(input, wacom->tool[0], 0);
59 input_report_abs(input, ABS_MISC, 0); /* report tool id */
60 input_report_abs(input, ABS_PRESSURE, -1);
61 input_report_key(input, BTN_TOUCH, 0);
62 }
63 break;
64
65 case 2:
66 input_report_key(input, BTN_TOOL_PEN, 1);
67 input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
68 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
69 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
70 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
71 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
72 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
73 break;
74
75 default:
76 dev_dbg(input->dev.parent,
77 "%s: received unknown report #%d\n", __func__, data[0]);
78 return 0;
79 }
80
81 return 1;
82 }
83
84 static int wacom_pl_irq(struct wacom_wac *wacom)
85 {
86 struct wacom_features *features = &wacom->features;
87 unsigned char *data = wacom->data;
88 struct input_dev *input = wacom->input;
89 int prox, pressure;
90
91 if (data[0] != WACOM_REPORT_PENABLED) {
92 dev_dbg(input->dev.parent,
93 "%s: received unknown report #%d\n", __func__, data[0]);
94 return 0;
95 }
96
97 prox = data[1] & 0x40;
98
99 if (prox) {
100 wacom->id[0] = ERASER_DEVICE_ID;
101 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
102 if (features->pressure_max > 255)
103 pressure = (pressure << 1) | ((data[4] >> 6) & 1);
104 pressure += (features->pressure_max + 1) / 2;
105
106 /*
107 * if going from out of proximity into proximity select between the eraser
108 * and the pen based on the state of the stylus2 button, choose eraser if
109 * pressed else choose pen. if not a proximity change from out to in, send
110 * an out of proximity for previous tool then a in for new tool.
111 */
112 if (!wacom->tool[0]) {
113 /* Eraser bit set for DTF */
114 if (data[1] & 0x10)
115 wacom->tool[1] = BTN_TOOL_RUBBER;
116 else
117 /* Going into proximity select tool */
118 wacom->tool[1] = (data[4] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
119 } else {
120 /* was entered with stylus2 pressed */
121 if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
122 /* report out proximity for previous tool */
123 input_report_key(input, wacom->tool[1], 0);
124 input_sync(input);
125 wacom->tool[1] = BTN_TOOL_PEN;
126 return 0;
127 }
128 }
129 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
130 /* Unknown tool selected default to pen tool */
131 wacom->tool[1] = BTN_TOOL_PEN;
132 wacom->id[0] = STYLUS_DEVICE_ID;
133 }
134 input_report_key(input, wacom->tool[1], prox); /* report in proximity for tool */
135 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
136 input_report_abs(input, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
137 input_report_abs(input, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
138 input_report_abs(input, ABS_PRESSURE, pressure);
139
140 input_report_key(input, BTN_TOUCH, data[4] & 0x08);
141 input_report_key(input, BTN_STYLUS, data[4] & 0x10);
142 /* Only allow the stylus2 button to be reported for the pen tool. */
143 input_report_key(input, BTN_STYLUS2, (wacom->tool[1] == BTN_TOOL_PEN) && (data[4] & 0x20));
144 } else {
145 /* report proximity-out of a (valid) tool */
146 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
147 /* Unknown tool selected default to pen tool */
148 wacom->tool[1] = BTN_TOOL_PEN;
149 }
150 input_report_key(input, wacom->tool[1], prox);
151 }
152
153 wacom->tool[0] = prox; /* Save proximity state */
154 return 1;
155 }
156
157 static int wacom_ptu_irq(struct wacom_wac *wacom)
158 {
159 unsigned char *data = wacom->data;
160 struct input_dev *input = wacom->input;
161
162 if (data[0] != WACOM_REPORT_PENABLED) {
163 dev_dbg(input->dev.parent,
164 "%s: received unknown report #%d\n", __func__, data[0]);
165 return 0;
166 }
167
168 if (data[1] & 0x04) {
169 input_report_key(input, BTN_TOOL_RUBBER, data[1] & 0x20);
170 input_report_key(input, BTN_TOUCH, data[1] & 0x08);
171 wacom->id[0] = ERASER_DEVICE_ID;
172 } else {
173 input_report_key(input, BTN_TOOL_PEN, data[1] & 0x20);
174 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
175 wacom->id[0] = STYLUS_DEVICE_ID;
176 }
177 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
178 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
179 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
180 input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6]));
181 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
182 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
183 return 1;
184 }
185
186 static int wacom_dtu_irq(struct wacom_wac *wacom)
187 {
188 unsigned char *data = wacom->data;
189 struct input_dev *input = wacom->input;
190 int prox = data[1] & 0x20;
191
192 dev_dbg(input->dev.parent,
193 "%s: received report #%d", __func__, data[0]);
194
195 if (prox) {
196 /* Going into proximity select tool */
197 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
198 if (wacom->tool[0] == BTN_TOOL_PEN)
199 wacom->id[0] = STYLUS_DEVICE_ID;
200 else
201 wacom->id[0] = ERASER_DEVICE_ID;
202 }
203 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
204 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
205 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
206 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
207 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x01) << 8) | data[6]);
208 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
209 if (!prox) /* out-prox */
210 wacom->id[0] = 0;
211 input_report_key(input, wacom->tool[0], prox);
212 input_report_abs(input, ABS_MISC, wacom->id[0]);
213 return 1;
214 }
215
216 static int wacom_dtus_irq(struct wacom_wac *wacom)
217 {
218 char *data = wacom->data;
219 struct input_dev *input = wacom->input;
220 unsigned short prox, pressure = 0;
221
222 if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) {
223 dev_dbg(input->dev.parent,
224 "%s: received unknown report #%d", __func__, data[0]);
225 return 0;
226 } else if (data[0] == WACOM_REPORT_DTUSPAD) {
227 input = wacom->pad_input;
228 input_report_key(input, BTN_0, (data[1] & 0x01));
229 input_report_key(input, BTN_1, (data[1] & 0x02));
230 input_report_key(input, BTN_2, (data[1] & 0x04));
231 input_report_key(input, BTN_3, (data[1] & 0x08));
232 input_report_abs(input, ABS_MISC,
233 data[1] & 0x0f ? PAD_DEVICE_ID : 0);
234 return 1;
235 } else {
236 prox = data[1] & 0x80;
237 if (prox) {
238 switch ((data[1] >> 3) & 3) {
239 case 1: /* Rubber */
240 wacom->tool[0] = BTN_TOOL_RUBBER;
241 wacom->id[0] = ERASER_DEVICE_ID;
242 break;
243
244 case 2: /* Pen */
245 wacom->tool[0] = BTN_TOOL_PEN;
246 wacom->id[0] = STYLUS_DEVICE_ID;
247 break;
248 }
249 }
250
251 input_report_key(input, BTN_STYLUS, data[1] & 0x20);
252 input_report_key(input, BTN_STYLUS2, data[1] & 0x40);
253 input_report_abs(input, ABS_X, get_unaligned_be16(&data[3]));
254 input_report_abs(input, ABS_Y, get_unaligned_be16(&data[5]));
255 pressure = ((data[1] & 0x03) << 8) | (data[2] & 0xff);
256 input_report_abs(input, ABS_PRESSURE, pressure);
257 input_report_key(input, BTN_TOUCH, pressure > 10);
258
259 if (!prox) /* out-prox */
260 wacom->id[0] = 0;
261 input_report_key(input, wacom->tool[0], prox);
262 input_report_abs(input, ABS_MISC, wacom->id[0]);
263 return 1;
264 }
265 }
266
267 static int wacom_graphire_irq(struct wacom_wac *wacom)
268 {
269 struct wacom_features *features = &wacom->features;
270 unsigned char *data = wacom->data;
271 struct input_dev *input = wacom->input;
272 struct input_dev *pad_input = wacom->pad_input;
273 int battery_capacity, ps_connected;
274 int prox;
275 int rw = 0;
276 int retval = 0;
277
278 if (features->type == GRAPHIRE_BT) {
279 if (data[0] != WACOM_REPORT_PENABLED_BT) {
280 dev_dbg(input->dev.parent,
281 "%s: received unknown report #%d\n", __func__,
282 data[0]);
283 goto exit;
284 }
285 } else if (data[0] != WACOM_REPORT_PENABLED) {
286 dev_dbg(input->dev.parent,
287 "%s: received unknown report #%d\n", __func__, data[0]);
288 goto exit;
289 }
290
291 prox = data[1] & 0x80;
292 if (prox || wacom->id[0]) {
293 if (prox) {
294 switch ((data[1] >> 5) & 3) {
295
296 case 0: /* Pen */
297 wacom->tool[0] = BTN_TOOL_PEN;
298 wacom->id[0] = STYLUS_DEVICE_ID;
299 break;
300
301 case 1: /* Rubber */
302 wacom->tool[0] = BTN_TOOL_RUBBER;
303 wacom->id[0] = ERASER_DEVICE_ID;
304 break;
305
306 case 2: /* Mouse with wheel */
307 input_report_key(input, BTN_MIDDLE, data[1] & 0x04);
308 /* fall through */
309
310 case 3: /* Mouse without wheel */
311 wacom->tool[0] = BTN_TOOL_MOUSE;
312 wacom->id[0] = CURSOR_DEVICE_ID;
313 break;
314 }
315 }
316 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
317 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
318 if (wacom->tool[0] != BTN_TOOL_MOUSE) {
319 if (features->type == GRAPHIRE_BT)
320 input_report_abs(input, ABS_PRESSURE, data[6] |
321 (((__u16) (data[1] & 0x08)) << 5));
322 else
323 input_report_abs(input, ABS_PRESSURE, data[6] |
324 ((data[7] & 0x03) << 8));
325 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
326 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
327 input_report_key(input, BTN_STYLUS2, data[1] & 0x04);
328 } else {
329 input_report_key(input, BTN_LEFT, data[1] & 0x01);
330 input_report_key(input, BTN_RIGHT, data[1] & 0x02);
331 if (features->type == WACOM_G4 ||
332 features->type == WACOM_MO) {
333 input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f);
334 rw = (data[7] & 0x04) - (data[7] & 0x03);
335 } else if (features->type == GRAPHIRE_BT) {
336 /* Compute distance between mouse and tablet */
337 rw = 44 - (data[6] >> 2);
338 rw = clamp_val(rw, 0, 31);
339 input_report_abs(input, ABS_DISTANCE, rw);
340 if (((data[1] >> 5) & 3) == 2) {
341 /* Mouse with wheel */
342 input_report_key(input, BTN_MIDDLE,
343 data[1] & 0x04);
344 rw = (data[6] & 0x01) ? -1 :
345 (data[6] & 0x02) ? 1 : 0;
346 } else {
347 rw = 0;
348 }
349 } else {
350 input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f);
351 rw = -(signed char)data[6];
352 }
353 input_report_rel(input, REL_WHEEL, rw);
354 }
355
356 if (!prox)
357 wacom->id[0] = 0;
358 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
359 input_report_key(input, wacom->tool[0], prox);
360 input_sync(input); /* sync last event */
361 }
362
363 /* send pad data */
364 switch (features->type) {
365 case WACOM_G4:
366 prox = data[7] & 0xf8;
367 if (prox || wacom->id[1]) {
368 wacom->id[1] = PAD_DEVICE_ID;
369 input_report_key(pad_input, BTN_BACK, (data[7] & 0x40));
370 input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x80));
371 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
372 input_report_rel(pad_input, REL_WHEEL, rw);
373 if (!prox)
374 wacom->id[1] = 0;
375 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
376 retval = 1;
377 }
378 break;
379
380 case WACOM_MO:
381 prox = (data[7] & 0xf8) || data[8];
382 if (prox || wacom->id[1]) {
383 wacom->id[1] = PAD_DEVICE_ID;
384 input_report_key(pad_input, BTN_BACK, (data[7] & 0x08));
385 input_report_key(pad_input, BTN_LEFT, (data[7] & 0x20));
386 input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x10));
387 input_report_key(pad_input, BTN_RIGHT, (data[7] & 0x40));
388 input_report_abs(pad_input, ABS_WHEEL, (data[8] & 0x7f));
389 if (!prox)
390 wacom->id[1] = 0;
391 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
392 retval = 1;
393 }
394 break;
395 case GRAPHIRE_BT:
396 prox = data[7] & 0x03;
397 if (prox || wacom->id[1]) {
398 wacom->id[1] = PAD_DEVICE_ID;
399 input_report_key(pad_input, BTN_0, (data[7] & 0x02));
400 input_report_key(pad_input, BTN_1, (data[7] & 0x01));
401 if (!prox)
402 wacom->id[1] = 0;
403 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
404 retval = 1;
405 }
406 break;
407 }
408
409 /* Store current battery capacity and power supply state */
410 if (features->type == GRAPHIRE_BT) {
411 rw = (data[7] >> 2 & 0x07);
412 battery_capacity = batcap_gr[rw];
413 ps_connected = rw == 7;
414 if ((wacom->battery_capacity != battery_capacity) ||
415 (wacom->ps_connected != ps_connected)) {
416 wacom->battery_capacity = battery_capacity;
417 wacom->ps_connected = ps_connected;
418 wacom_notify_battery(wacom);
419 }
420 }
421 exit:
422 return retval;
423 }
424
425 static int wacom_intuos_inout(struct wacom_wac *wacom)
426 {
427 struct wacom_features *features = &wacom->features;
428 unsigned char *data = wacom->data;
429 struct input_dev *input = wacom->input;
430 int idx = 0;
431
432 /* tool number */
433 if (features->type == INTUOS)
434 idx = data[1] & 0x01;
435
436 /* Enter report */
437 if ((data[1] & 0xfc) == 0xc0) {
438 if (features->quirks & WACOM_QUIRK_MULTI_INPUT)
439 wacom->shared->stylus_in_proximity = true;
440
441 /* serial number of the tool */
442 wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
443 (data[4] << 20) + (data[5] << 12) +
444 (data[6] << 4) + (data[7] >> 4);
445
446 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) |
447 ((data[7] & 0x0f) << 20) | ((data[8] & 0xf0) << 12);
448
449 switch (wacom->id[idx]) {
450 case 0x812: /* Inking pen */
451 case 0x801: /* Intuos3 Inking pen */
452 case 0x120802: /* Intuos4/5 Inking Pen */
453 case 0x012:
454 wacom->tool[idx] = BTN_TOOL_PENCIL;
455 break;
456
457 case 0x822: /* Pen */
458 case 0x842:
459 case 0x852:
460 case 0x823: /* Intuos3 Grip Pen */
461 case 0x813: /* Intuos3 Classic Pen */
462 case 0x885: /* Intuos3 Marker Pen */
463 case 0x802: /* Intuos4/5 13HD/24HD General Pen */
464 case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
465 case 0x022:
466 case 0x100804: /* Intuos4/5 13HD/24HD Art Pen */
467 case 0x140802: /* Intuos4/5 13HD/24HD Classic Pen */
468 case 0x160802: /* Cintiq 13HD Pro Pen */
469 case 0x180802: /* DTH2242 Pen */
470 case 0x100802: /* Intuos4/5 13HD/24HD General Pen */
471 wacom->tool[idx] = BTN_TOOL_PEN;
472 break;
473
474 case 0x832: /* Stroke pen */
475 case 0x032:
476 wacom->tool[idx] = BTN_TOOL_BRUSH;
477 break;
478
479 case 0x007: /* Mouse 4D and 2D */
480 case 0x09c:
481 case 0x094:
482 case 0x017: /* Intuos3 2D Mouse */
483 case 0x806: /* Intuos4 Mouse */
484 wacom->tool[idx] = BTN_TOOL_MOUSE;
485 break;
486
487 case 0x096: /* Lens cursor */
488 case 0x097: /* Intuos3 Lens cursor */
489 case 0x006: /* Intuos4 Lens cursor */
490 wacom->tool[idx] = BTN_TOOL_LENS;
491 break;
492
493 case 0x82a: /* Eraser */
494 case 0x85a:
495 case 0x91a:
496 case 0xd1a:
497 case 0x0fa:
498 case 0x82b: /* Intuos3 Grip Pen Eraser */
499 case 0x81b: /* Intuos3 Classic Pen Eraser */
500 case 0x91b: /* Intuos3 Airbrush Eraser */
501 case 0x80c: /* Intuos4/5 13HD/24HD Marker Pen Eraser */
502 case 0x80a: /* Intuos4/5 13HD/24HD General Pen Eraser */
503 case 0x90a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
504 case 0x14080a: /* Intuos4/5 13HD/24HD Classic Pen Eraser */
505 case 0x10090a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
506 case 0x10080c: /* Intuos4/5 13HD/24HD Art Pen Eraser */
507 case 0x16080a: /* Cintiq 13HD Pro Pen Eraser */
508 case 0x18080a: /* DTH2242 Eraser */
509 case 0x10080a: /* Intuos4/5 13HD/24HD General Pen Eraser */
510 wacom->tool[idx] = BTN_TOOL_RUBBER;
511 break;
512
513 case 0xd12:
514 case 0x912:
515 case 0x112:
516 case 0x913: /* Intuos3 Airbrush */
517 case 0x902: /* Intuos4/5 13HD/24HD Airbrush */
518 case 0x100902: /* Intuos4/5 13HD/24HD Airbrush */
519 wacom->tool[idx] = BTN_TOOL_AIRBRUSH;
520 break;
521
522 default: /* Unknown tool */
523 wacom->tool[idx] = BTN_TOOL_PEN;
524 break;
525 }
526 return 1;
527 }
528
529 /* older I4 styli don't work with new Cintiqs */
530 if (!((wacom->id[idx] >> 20) & 0x01) &&
531 (features->type == WACOM_21UX2))
532 return 1;
533
534 /* Range Report */
535 if ((data[1] & 0xfe) == 0x20) {
536 input_report_key(input, BTN_TOUCH, 0);
537 input_report_abs(input, ABS_PRESSURE, 0);
538 input_report_abs(input, ABS_DISTANCE, wacom->features.distance_max);
539 if (features->quirks & WACOM_QUIRK_MULTI_INPUT)
540 wacom->shared->stylus_in_proximity = true;
541 }
542
543 /* Exit report */
544 if ((data[1] & 0xfe) == 0x80) {
545 if (features->quirks & WACOM_QUIRK_MULTI_INPUT)
546 wacom->shared->stylus_in_proximity = false;
547
548 /*
549 * Reset all states otherwise we lose the initial states
550 * when in-prox next time
551 */
552 input_report_abs(input, ABS_X, 0);
553 input_report_abs(input, ABS_Y, 0);
554 input_report_abs(input, ABS_DISTANCE, 0);
555 input_report_abs(input, ABS_TILT_X, 0);
556 input_report_abs(input, ABS_TILT_Y, 0);
557 if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
558 input_report_key(input, BTN_LEFT, 0);
559 input_report_key(input, BTN_MIDDLE, 0);
560 input_report_key(input, BTN_RIGHT, 0);
561 input_report_key(input, BTN_SIDE, 0);
562 input_report_key(input, BTN_EXTRA, 0);
563 input_report_abs(input, ABS_THROTTLE, 0);
564 input_report_abs(input, ABS_RZ, 0);
565 } else {
566 input_report_abs(input, ABS_PRESSURE, 0);
567 input_report_key(input, BTN_STYLUS, 0);
568 input_report_key(input, BTN_STYLUS2, 0);
569 input_report_key(input, BTN_TOUCH, 0);
570 input_report_abs(input, ABS_WHEEL, 0);
571 if (features->type >= INTUOS3S)
572 input_report_abs(input, ABS_Z, 0);
573 }
574 input_report_key(input, wacom->tool[idx], 0);
575 input_report_abs(input, ABS_MISC, 0); /* reset tool id */
576 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
577 wacom->id[idx] = 0;
578 return 2;
579 }
580 return 0;
581 }
582
583 static void wacom_intuos_general(struct wacom_wac *wacom)
584 {
585 struct wacom_features *features = &wacom->features;
586 unsigned char *data = wacom->data;
587 struct input_dev *input = wacom->input;
588 unsigned int t;
589
590 /* general pen packet */
591 if ((data[1] & 0xb8) == 0xa0) {
592 t = (data[6] << 2) | ((data[7] >> 6) & 3);
593 if (features->type >= INTUOS4S && features->type <= CINTIQ_HYBRID) {
594 t = (t << 1) | (data[1] & 1);
595 }
596 input_report_abs(input, ABS_PRESSURE, t);
597 input_report_abs(input, ABS_TILT_X,
598 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
599 input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f);
600 input_report_key(input, BTN_STYLUS, data[1] & 2);
601 input_report_key(input, BTN_STYLUS2, data[1] & 4);
602 input_report_key(input, BTN_TOUCH, t > 10);
603 }
604
605 /* airbrush second packet */
606 if ((data[1] & 0xbc) == 0xb4) {
607 input_report_abs(input, ABS_WHEEL,
608 (data[6] << 2) | ((data[7] >> 6) & 3));
609 input_report_abs(input, ABS_TILT_X,
610 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
611 input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f);
612 }
613 }
614
615 static int wacom_intuos_irq(struct wacom_wac *wacom)
616 {
617 struct wacom_features *features = &wacom->features;
618 unsigned char *data = wacom->data;
619 struct input_dev *input = wacom->input;
620 unsigned int t;
621 int idx = 0, result;
622
623 if (data[0] != WACOM_REPORT_PENABLED &&
624 data[0] != WACOM_REPORT_INTUOSREAD &&
625 data[0] != WACOM_REPORT_INTUOSWRITE &&
626 data[0] != WACOM_REPORT_INTUOSPAD &&
627 data[0] != WACOM_REPORT_INTUOS5PAD) {
628 dev_dbg(input->dev.parent,
629 "%s: received unknown report #%d\n", __func__, data[0]);
630 return 0;
631 }
632
633 /* tool number */
634 if (features->type == INTUOS)
635 idx = data[1] & 0x01;
636
637 /* pad packets. Works as a second tool and is always in prox */
638 if (data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD) {
639 input = wacom->pad_input;
640 if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
641 input_report_key(input, BTN_0, (data[2] & 0x01));
642 input_report_key(input, BTN_1, (data[3] & 0x01));
643 input_report_key(input, BTN_2, (data[3] & 0x02));
644 input_report_key(input, BTN_3, (data[3] & 0x04));
645 input_report_key(input, BTN_4, (data[3] & 0x08));
646 input_report_key(input, BTN_5, (data[3] & 0x10));
647 input_report_key(input, BTN_6, (data[3] & 0x20));
648 if (data[1] & 0x80) {
649 input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f));
650 } else {
651 /* Out of proximity, clear wheel value. */
652 input_report_abs(input, ABS_WHEEL, 0);
653 }
654 if (features->type != INTUOS4S) {
655 input_report_key(input, BTN_7, (data[3] & 0x40));
656 input_report_key(input, BTN_8, (data[3] & 0x80));
657 }
658 if (data[1] | (data[2] & 0x01) | data[3]) {
659 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
660 } else {
661 input_report_abs(input, ABS_MISC, 0);
662 }
663 } else if (features->type == DTK) {
664 input_report_key(input, BTN_0, (data[6] & 0x01));
665 input_report_key(input, BTN_1, (data[6] & 0x02));
666 input_report_key(input, BTN_2, (data[6] & 0x04));
667 input_report_key(input, BTN_3, (data[6] & 0x08));
668 input_report_key(input, BTN_4, (data[6] & 0x10));
669 input_report_key(input, BTN_5, (data[6] & 0x20));
670 if (data[6] & 0x3f) {
671 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
672 } else {
673 input_report_abs(input, ABS_MISC, 0);
674 }
675 } else if (features->type == WACOM_13HD) {
676 input_report_key(input, BTN_0, (data[3] & 0x01));
677 input_report_key(input, BTN_1, (data[4] & 0x01));
678 input_report_key(input, BTN_2, (data[4] & 0x02));
679 input_report_key(input, BTN_3, (data[4] & 0x04));
680 input_report_key(input, BTN_4, (data[4] & 0x08));
681 input_report_key(input, BTN_5, (data[4] & 0x10));
682 input_report_key(input, BTN_6, (data[4] & 0x20));
683 input_report_key(input, BTN_7, (data[4] & 0x40));
684 input_report_key(input, BTN_8, (data[4] & 0x80));
685 if ((data[3] & 0x01) | data[4]) {
686 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
687 } else {
688 input_report_abs(input, ABS_MISC, 0);
689 }
690 } else if (features->type == WACOM_24HD) {
691 input_report_key(input, BTN_0, (data[6] & 0x01));
692 input_report_key(input, BTN_1, (data[6] & 0x02));
693 input_report_key(input, BTN_2, (data[6] & 0x04));
694 input_report_key(input, BTN_3, (data[6] & 0x08));
695 input_report_key(input, BTN_4, (data[6] & 0x10));
696 input_report_key(input, BTN_5, (data[6] & 0x20));
697 input_report_key(input, BTN_6, (data[6] & 0x40));
698 input_report_key(input, BTN_7, (data[6] & 0x80));
699 input_report_key(input, BTN_8, (data[8] & 0x01));
700 input_report_key(input, BTN_9, (data[8] & 0x02));
701 input_report_key(input, BTN_A, (data[8] & 0x04));
702 input_report_key(input, BTN_B, (data[8] & 0x08));
703 input_report_key(input, BTN_C, (data[8] & 0x10));
704 input_report_key(input, BTN_X, (data[8] & 0x20));
705 input_report_key(input, BTN_Y, (data[8] & 0x40));
706 input_report_key(input, BTN_Z, (data[8] & 0x80));
707
708 /*
709 * Three "buttons" are available on the 24HD which are
710 * physically implemented as a touchstrip. Each button
711 * is approximately 3 bits wide with a 2 bit spacing.
712 * The raw touchstrip bits are stored at:
713 * ((data[3] & 0x1f) << 8) | data[4])
714 */
715 input_report_key(input, KEY_PROG1, data[4] & 0x07);
716 input_report_key(input, KEY_PROG2, data[4] & 0xE0);
717 input_report_key(input, KEY_PROG3, data[3] & 0x1C);
718
719 if (data[1] & 0x80) {
720 input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f));
721 } else {
722 /* Out of proximity, clear wheel value. */
723 input_report_abs(input, ABS_WHEEL, 0);
724 }
725
726 if (data[2] & 0x80) {
727 input_report_abs(input, ABS_THROTTLE, (data[2] & 0x7f));
728 } else {
729 /* Out of proximity, clear second wheel value. */
730 input_report_abs(input, ABS_THROTTLE, 0);
731 }
732
733 if (data[1] | data[2] | (data[3] & 0x1f) | data[4] | data[6] | data[8]) {
734 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
735 } else {
736 input_report_abs(input, ABS_MISC, 0);
737 }
738 } else if (features->type == CINTIQ_HYBRID) {
739 /*
740 * Do not send hardware buttons under Android. They
741 * are already sent to the system through GPIO (and
742 * have different meaning).
743 */
744 input_report_key(input, BTN_1, (data[4] & 0x01));
745 input_report_key(input, BTN_2, (data[4] & 0x02));
746 input_report_key(input, BTN_3, (data[4] & 0x04));
747 input_report_key(input, BTN_4, (data[4] & 0x08));
748
749 input_report_key(input, BTN_5, (data[4] & 0x10)); /* Right */
750 input_report_key(input, BTN_6, (data[4] & 0x20)); /* Up */
751 input_report_key(input, BTN_7, (data[4] & 0x40)); /* Left */
752 input_report_key(input, BTN_8, (data[4] & 0x80)); /* Down */
753 input_report_key(input, BTN_0, (data[3] & 0x01)); /* Center */
754 } else if (features->type >= INTUOS5S && features->type <= INTUOSPL) {
755 int i;
756
757 /* Touch ring mode switch has no capacitive sensor */
758 input_report_key(input, BTN_0, (data[3] & 0x01));
759
760 /*
761 * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in
762 * addition to the mechanical switch. Switch data is
763 * stored in data[4], capacitive data in data[5].
764 */
765 for (i = 0; i < 8; i++)
766 input_report_key(input, BTN_1 + i, data[4] & (1 << i));
767
768 if (data[2] & 0x80) {
769 input_report_abs(input, ABS_WHEEL, (data[2] & 0x7f));
770 } else {
771 /* Out of proximity, clear wheel value. */
772 input_report_abs(input, ABS_WHEEL, 0);
773 }
774
775 if (data[2] | (data[3] & 0x01) | data[4] | data[5]) {
776 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
777 } else {
778 input_report_abs(input, ABS_MISC, 0);
779 }
780 } else {
781 if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) {
782 input_report_key(input, BTN_0, (data[5] & 0x01));
783 input_report_key(input, BTN_1, (data[6] & 0x01));
784 input_report_key(input, BTN_2, (data[6] & 0x02));
785 input_report_key(input, BTN_3, (data[6] & 0x04));
786 input_report_key(input, BTN_4, (data[6] & 0x08));
787 input_report_key(input, BTN_5, (data[6] & 0x10));
788 input_report_key(input, BTN_6, (data[6] & 0x20));
789 input_report_key(input, BTN_7, (data[6] & 0x40));
790 input_report_key(input, BTN_8, (data[6] & 0x80));
791 input_report_key(input, BTN_9, (data[7] & 0x01));
792 input_report_key(input, BTN_A, (data[8] & 0x01));
793 input_report_key(input, BTN_B, (data[8] & 0x02));
794 input_report_key(input, BTN_C, (data[8] & 0x04));
795 input_report_key(input, BTN_X, (data[8] & 0x08));
796 input_report_key(input, BTN_Y, (data[8] & 0x10));
797 input_report_key(input, BTN_Z, (data[8] & 0x20));
798 input_report_key(input, BTN_BASE, (data[8] & 0x40));
799 input_report_key(input, BTN_BASE2, (data[8] & 0x80));
800
801 if (features->type == WACOM_22HD) {
802 input_report_key(input, KEY_PROG1, data[9] & 0x01);
803 input_report_key(input, KEY_PROG2, data[9] & 0x02);
804 input_report_key(input, KEY_PROG3, data[9] & 0x04);
805 }
806 } else {
807 input_report_key(input, BTN_0, (data[5] & 0x01));
808 input_report_key(input, BTN_1, (data[5] & 0x02));
809 input_report_key(input, BTN_2, (data[5] & 0x04));
810 input_report_key(input, BTN_3, (data[5] & 0x08));
811 input_report_key(input, BTN_4, (data[6] & 0x01));
812 input_report_key(input, BTN_5, (data[6] & 0x02));
813 input_report_key(input, BTN_6, (data[6] & 0x04));
814 input_report_key(input, BTN_7, (data[6] & 0x08));
815 input_report_key(input, BTN_8, (data[5] & 0x10));
816 input_report_key(input, BTN_9, (data[6] & 0x10));
817 }
818 input_report_abs(input, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
819 input_report_abs(input, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
820
821 if ((data[5] & 0x1f) | data[6] | (data[1] & 0x1f) |
822 data[2] | (data[3] & 0x1f) | data[4] | data[8] |
823 (data[7] & 0x01)) {
824 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
825 } else {
826 input_report_abs(input, ABS_MISC, 0);
827 }
828 }
829 return 1;
830 }
831
832 /* process in/out prox events */
833 result = wacom_intuos_inout(wacom);
834 if (result)
835 return result - 1;
836
837 /* don't proceed if we don't know the ID */
838 if (!wacom->id[idx])
839 return 0;
840
841 /* Only large Intuos support Lense Cursor */
842 if (wacom->tool[idx] == BTN_TOOL_LENS &&
843 (features->type == INTUOS3 ||
844 features->type == INTUOS3S ||
845 features->type == INTUOS4 ||
846 features->type == INTUOS4S ||
847 features->type == INTUOS5 ||
848 features->type == INTUOS5S ||
849 features->type == INTUOSPM ||
850 features->type == INTUOSPS)) {
851
852 return 0;
853 }
854
855 /* Cintiq doesn't send data when RDY bit isn't set */
856 if (features->type == CINTIQ && !(data[1] & 0x40))
857 return 0;
858
859 if (features->type >= INTUOS3S) {
860 input_report_abs(input, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
861 input_report_abs(input, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
862 input_report_abs(input, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
863 } else {
864 input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[2]));
865 input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[4]));
866 input_report_abs(input, ABS_DISTANCE, ((data[9] >> 3) & 0x1f));
867 }
868
869 /* process general packets */
870 wacom_intuos_general(wacom);
871
872 /* 4D mouse, 2D mouse, marker pen rotation, tilt mouse, or Lens cursor packets */
873 if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0 || (data[1] & 0xbc) == 0xac) {
874
875 if (data[1] & 0x02) {
876 /* Rotation packet */
877 if (features->type >= INTUOS3S) {
878 /* I3 marker pen rotation */
879 t = (data[6] << 3) | ((data[7] >> 5) & 7);
880 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
881 ((t-1) / 2 + 450)) : (450 - t / 2) ;
882 input_report_abs(input, ABS_Z, t);
883 } else {
884 /* 4D mouse rotation packet */
885 t = (data[6] << 3) | ((data[7] >> 5) & 7);
886 input_report_abs(input, ABS_RZ, (data[7] & 0x20) ?
887 ((t - 1) / 2) : -t / 2);
888 }
889
890 } else if (!(data[1] & 0x10) && features->type < INTUOS3S) {
891 /* 4D mouse packet */
892 input_report_key(input, BTN_LEFT, data[8] & 0x01);
893 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
894 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
895
896 input_report_key(input, BTN_SIDE, data[8] & 0x20);
897 input_report_key(input, BTN_EXTRA, data[8] & 0x10);
898 t = (data[6] << 2) | ((data[7] >> 6) & 3);
899 input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
900
901 } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
902 /* I4 mouse */
903 if (features->type >= INTUOS4S && features->type <= INTUOSPL) {
904 input_report_key(input, BTN_LEFT, data[6] & 0x01);
905 input_report_key(input, BTN_MIDDLE, data[6] & 0x02);
906 input_report_key(input, BTN_RIGHT, data[6] & 0x04);
907 input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7)
908 - ((data[7] & 0x40) >> 6));
909 input_report_key(input, BTN_SIDE, data[6] & 0x08);
910 input_report_key(input, BTN_EXTRA, data[6] & 0x10);
911
912 input_report_abs(input, ABS_TILT_X,
913 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
914 input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f);
915 } else {
916 /* 2D mouse packet */
917 input_report_key(input, BTN_LEFT, data[8] & 0x04);
918 input_report_key(input, BTN_MIDDLE, data[8] & 0x08);
919 input_report_key(input, BTN_RIGHT, data[8] & 0x10);
920 input_report_rel(input, REL_WHEEL, (data[8] & 0x01)
921 - ((data[8] & 0x02) >> 1));
922
923 /* I3 2D mouse side buttons */
924 if (features->type >= INTUOS3S && features->type <= INTUOS3L) {
925 input_report_key(input, BTN_SIDE, data[8] & 0x40);
926 input_report_key(input, BTN_EXTRA, data[8] & 0x20);
927 }
928 }
929 } else if ((features->type < INTUOS3S || features->type == INTUOS3L ||
930 features->type == INTUOS4L || features->type == INTUOS5L ||
931 features->type == INTUOSPL) &&
932 wacom->tool[idx] == BTN_TOOL_LENS) {
933 /* Lens cursor packets */
934 input_report_key(input, BTN_LEFT, data[8] & 0x01);
935 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
936 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
937 input_report_key(input, BTN_SIDE, data[8] & 0x10);
938 input_report_key(input, BTN_EXTRA, data[8] & 0x08);
939 }
940 }
941
942 input_report_abs(input, ABS_MISC, wacom->id[idx]); /* report tool id */
943 input_report_key(input, wacom->tool[idx], 1);
944 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
945 return 1;
946 }
947
948 static int int_dist(int x1, int y1, int x2, int y2)
949 {
950 int x = x2 - x1;
951 int y = y2 - y1;
952
953 return int_sqrt(x*x + y*y);
954 }
955
956 static int wacom_24hdt_irq(struct wacom_wac *wacom)
957 {
958 struct input_dev *input = wacom->input;
959 unsigned char *data = wacom->data;
960 int i;
961 int current_num_contacts = data[61];
962 int contacts_to_send = 0;
963
964 /*
965 * First packet resets the counter since only the first
966 * packet in series will have non-zero current_num_contacts.
967 */
968 if (current_num_contacts)
969 wacom->num_contacts_left = current_num_contacts;
970
971 /* There are at most 4 contacts per packet */
972 contacts_to_send = min(4, wacom->num_contacts_left);
973
974 for (i = 0; i < contacts_to_send; i++) {
975 int offset = (WACOM_BYTES_PER_24HDT_PACKET * i) + 1;
976 bool touch = data[offset] & 0x1 && !wacom->shared->stylus_in_proximity;
977 int slot = input_mt_get_slot_by_key(input, data[offset + 1]);
978
979 if (slot < 0)
980 continue;
981 input_mt_slot(input, slot);
982 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
983
984 if (touch) {
985 int t_x = get_unaligned_le16(&data[offset + 2]);
986 int c_x = get_unaligned_le16(&data[offset + 4]);
987 int t_y = get_unaligned_le16(&data[offset + 6]);
988 int c_y = get_unaligned_le16(&data[offset + 8]);
989 int w = get_unaligned_le16(&data[offset + 10]);
990 int h = get_unaligned_le16(&data[offset + 12]);
991
992 input_report_abs(input, ABS_MT_POSITION_X, t_x);
993 input_report_abs(input, ABS_MT_POSITION_Y, t_y);
994 input_report_abs(input, ABS_MT_TOUCH_MAJOR, min(w,h));
995 input_report_abs(input, ABS_MT_WIDTH_MAJOR, min(w, h) + int_dist(t_x, t_y, c_x, c_y));
996 input_report_abs(input, ABS_MT_WIDTH_MINOR, min(w, h));
997 input_report_abs(input, ABS_MT_ORIENTATION, w > h);
998 }
999 }
1000 input_mt_report_pointer_emulation(input, true);
1001
1002 wacom->num_contacts_left -= contacts_to_send;
1003 if (wacom->num_contacts_left <= 0)
1004 wacom->num_contacts_left = 0;
1005
1006 return 1;
1007 }
1008
1009 static int wacom_mt_touch(struct wacom_wac *wacom)
1010 {
1011 struct input_dev *input = wacom->input;
1012 unsigned char *data = wacom->data;
1013 int i;
1014 int current_num_contacts = data[2];
1015 int contacts_to_send = 0;
1016 int x_offset = 0;
1017
1018 /* MTTPC does not support Height and Width */
1019 if (wacom->features.type == MTTPC || wacom->features.type == MTTPC_B)
1020 x_offset = -4;
1021
1022 /*
1023 * First packet resets the counter since only the first
1024 * packet in series will have non-zero current_num_contacts.
1025 */
1026 if (current_num_contacts)
1027 wacom->num_contacts_left = current_num_contacts;
1028
1029 /* There are at most 5 contacts per packet */
1030 contacts_to_send = min(5, wacom->num_contacts_left);
1031
1032 for (i = 0; i < contacts_to_send; i++) {
1033 int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset) * i + 3;
1034 bool touch = data[offset] & 0x1;
1035 int id = get_unaligned_le16(&data[offset + 1]);
1036 int slot = input_mt_get_slot_by_key(input, id);
1037
1038 if (slot < 0)
1039 continue;
1040
1041 input_mt_slot(input, slot);
1042 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1043 if (touch) {
1044 int x = get_unaligned_le16(&data[offset + x_offset + 7]);
1045 int y = get_unaligned_le16(&data[offset + x_offset + 9]);
1046 input_report_abs(input, ABS_MT_POSITION_X, x);
1047 input_report_abs(input, ABS_MT_POSITION_Y, y);
1048 }
1049 }
1050 input_mt_report_pointer_emulation(input, true);
1051
1052 wacom->num_contacts_left -= contacts_to_send;
1053 if (wacom->num_contacts_left < 0)
1054 wacom->num_contacts_left = 0;
1055
1056 return 1;
1057 }
1058
1059 static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
1060 {
1061 struct input_dev *input = wacom->input;
1062 unsigned char *data = wacom->data;
1063 int contact_with_no_pen_down_count = 0;
1064 int i;
1065
1066 for (i = 0; i < 2; i++) {
1067 int p = data[1] & (1 << i);
1068 bool touch = p && !wacom->shared->stylus_in_proximity;
1069
1070 input_mt_slot(input, i);
1071 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1072 if (touch) {
1073 int x = le16_to_cpup((__le16 *)&data[i * 2 + 2]) & 0x7fff;
1074 int y = le16_to_cpup((__le16 *)&data[i * 2 + 6]) & 0x7fff;
1075
1076 input_report_abs(input, ABS_MT_POSITION_X, x);
1077 input_report_abs(input, ABS_MT_POSITION_Y, y);
1078 contact_with_no_pen_down_count++;
1079 }
1080 }
1081 input_mt_report_pointer_emulation(input, true);
1082
1083 /* keep touch state for pen event */
1084 wacom->shared->touch_down = (contact_with_no_pen_down_count > 0);
1085
1086 return 1;
1087 }
1088
1089 static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
1090 {
1091 unsigned char *data = wacom->data;
1092 struct input_dev *input = wacom->input;
1093 bool prox;
1094 int x = 0, y = 0;
1095
1096 if (wacom->features.touch_max > 1 || len > WACOM_PKGLEN_TPC2FG)
1097 return 0;
1098
1099 if (!wacom->shared->stylus_in_proximity) {
1100 if (len == WACOM_PKGLEN_TPC1FG) {
1101 prox = data[0] & 0x01;
1102 x = get_unaligned_le16(&data[1]);
1103 y = get_unaligned_le16(&data[3]);
1104 } else if (len == WACOM_PKGLEN_TPC1FG_B) {
1105 prox = data[2] & 0x01;
1106 x = get_unaligned_le16(&data[3]);
1107 y = get_unaligned_le16(&data[5]);
1108 } else {
1109 prox = data[1] & 0x01;
1110 x = le16_to_cpup((__le16 *)&data[2]);
1111 y = le16_to_cpup((__le16 *)&data[4]);
1112 }
1113 } else
1114 /* force touch out when pen is in prox */
1115 prox = 0;
1116
1117 if (prox) {
1118 input_report_abs(input, ABS_X, x);
1119 input_report_abs(input, ABS_Y, y);
1120 }
1121 input_report_key(input, BTN_TOUCH, prox);
1122
1123 /* keep touch state for pen events */
1124 wacom->shared->touch_down = prox;
1125
1126 return 1;
1127 }
1128
1129 static int wacom_tpc_pen(struct wacom_wac *wacom)
1130 {
1131 unsigned char *data = wacom->data;
1132 struct input_dev *input = wacom->input;
1133 bool prox = data[1] & 0x20;
1134
1135 if (!wacom->shared->stylus_in_proximity) /* first in prox */
1136 /* Going into proximity select tool */
1137 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
1138
1139 /* keep pen state for touch events */
1140 wacom->shared->stylus_in_proximity = prox;
1141
1142 /* send pen events only when touch is up or forced out */
1143 if (!wacom->shared->touch_down) {
1144 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
1145 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
1146 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
1147 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
1148 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x07) << 8) | data[6]);
1149 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
1150 input_report_key(input, wacom->tool[0], prox);
1151 return 1;
1152 }
1153
1154 return 0;
1155 }
1156
1157 static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
1158 {
1159 unsigned char *data = wacom->data;
1160
1161 dev_dbg(wacom->input->dev.parent,
1162 "%s: received report #%d\n", __func__, data[0]);
1163
1164 switch (len) {
1165 case WACOM_PKGLEN_TPC1FG:
1166 return wacom_tpc_single_touch(wacom, len);
1167
1168 case WACOM_PKGLEN_TPC2FG:
1169 return wacom_tpc_mt_touch(wacom);
1170
1171 case WACOM_PKGLEN_PENABLED:
1172 return wacom_tpc_pen(wacom);
1173
1174 default:
1175 switch (data[0]) {
1176 case WACOM_REPORT_TPC1FG:
1177 case WACOM_REPORT_TPCHID:
1178 case WACOM_REPORT_TPCST:
1179 case WACOM_REPORT_TPC1FGE:
1180 return wacom_tpc_single_touch(wacom, len);
1181
1182 case WACOM_REPORT_TPCMT:
1183 case WACOM_REPORT_TPCMT2:
1184 return wacom_mt_touch(wacom);
1185
1186 case WACOM_REPORT_PENABLED:
1187 return wacom_tpc_pen(wacom);
1188 }
1189 }
1190
1191 return 0;
1192 }
1193
1194 static int wacom_bpt_touch(struct wacom_wac *wacom)
1195 {
1196 struct wacom_features *features = &wacom->features;
1197 struct input_dev *input = wacom->input;
1198 struct input_dev *pad_input = wacom->pad_input;
1199 unsigned char *data = wacom->data;
1200 int i;
1201
1202 if (data[0] != 0x02)
1203 return 0;
1204
1205 for (i = 0; i < 2; i++) {
1206 int offset = (data[1] & 0x80) ? (8 * i) : (9 * i);
1207 bool touch = data[offset + 3] & 0x80;
1208
1209 /*
1210 * Touch events need to be disabled while stylus is
1211 * in proximity because user's hand is resting on touchpad
1212 * and sending unwanted events. User expects tablet buttons
1213 * to continue working though.
1214 */
1215 touch = touch && !wacom->shared->stylus_in_proximity;
1216
1217 input_mt_slot(input, i);
1218 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1219 if (touch) {
1220 int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff;
1221 int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff;
1222 if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) {
1223 x <<= 5;
1224 y <<= 5;
1225 }
1226 input_report_abs(input, ABS_MT_POSITION_X, x);
1227 input_report_abs(input, ABS_MT_POSITION_Y, y);
1228 }
1229 }
1230
1231 input_mt_report_pointer_emulation(input, true);
1232
1233 input_report_key(pad_input, BTN_LEFT, (data[1] & 0x08) != 0);
1234 input_report_key(pad_input, BTN_FORWARD, (data[1] & 0x04) != 0);
1235 input_report_key(pad_input, BTN_BACK, (data[1] & 0x02) != 0);
1236 input_report_key(pad_input, BTN_RIGHT, (data[1] & 0x01) != 0);
1237
1238 return 1;
1239 }
1240
1241 static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
1242 {
1243 struct wacom_features *features = &wacom->features;
1244 struct input_dev *input = wacom->input;
1245 bool touch = data[1] & 0x80;
1246 int slot = input_mt_get_slot_by_key(input, data[0]);
1247
1248 if (slot < 0)
1249 return;
1250
1251 touch = touch && !wacom->shared->stylus_in_proximity;
1252
1253 input_mt_slot(input, slot);
1254 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1255
1256 if (touch) {
1257 int x = (data[2] << 4) | (data[4] >> 4);
1258 int y = (data[3] << 4) | (data[4] & 0x0f);
1259 int width, height;
1260
1261 if (features->type >= INTUOSPS && features->type <= INTUOSPL) {
1262 width = data[5] * 100;
1263 height = data[6] * 100;
1264 } else {
1265 /*
1266 * "a" is a scaled-down area which we assume is
1267 * roughly circular and which can be described as:
1268 * a=(pi*r^2)/C.
1269 */
1270 int a = data[5];
1271 int x_res = input_abs_get_res(input, ABS_X);
1272 int y_res = input_abs_get_res(input, ABS_Y);
1273 width = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE);
1274 height = width * y_res / x_res;
1275 }
1276
1277 input_report_abs(input, ABS_MT_POSITION_X, x);
1278 input_report_abs(input, ABS_MT_POSITION_Y, y);
1279 input_report_abs(input, ABS_MT_TOUCH_MAJOR, width);
1280 input_report_abs(input, ABS_MT_TOUCH_MINOR, height);
1281 }
1282 }
1283
1284 static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
1285 {
1286 struct input_dev *input = wacom->pad_input;
1287 struct wacom_features *features = &wacom->features;
1288
1289 if (features->type == INTUOSHT) {
1290 input_report_key(input, BTN_LEFT, (data[1] & 0x02) != 0);
1291 input_report_key(input, BTN_BACK, (data[1] & 0x08) != 0);
1292 } else {
1293 input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
1294 input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
1295 }
1296 input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
1297 input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
1298 }
1299
1300 static int wacom_bpt3_touch(struct wacom_wac *wacom)
1301 {
1302 struct input_dev *input = wacom->input;
1303 unsigned char *data = wacom->data;
1304 int count = data[1] & 0x07;
1305 int i;
1306
1307 if (data[0] != 0x02)
1308 return 0;
1309
1310 /* data has up to 7 fixed sized 8-byte messages starting at data[2] */
1311 for (i = 0; i < count; i++) {
1312 int offset = (8 * i) + 2;
1313 int msg_id = data[offset];
1314
1315 if (msg_id >= 2 && msg_id <= 17)
1316 wacom_bpt3_touch_msg(wacom, data + offset);
1317 else if (msg_id == 128)
1318 wacom_bpt3_button_msg(wacom, data + offset);
1319
1320 }
1321 input_mt_report_pointer_emulation(input, true);
1322
1323 return 1;
1324 }
1325
1326 static int wacom_bpt_pen(struct wacom_wac *wacom)
1327 {
1328 struct wacom_features *features = &wacom->features;
1329 struct input_dev *input = wacom->input;
1330 unsigned char *data = wacom->data;
1331 int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
1332
1333 if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_USB)
1334 return 0;
1335
1336 if (data[0] == WACOM_REPORT_USB) {
1337 if (features->type == INTUOSHT && features->touch_max) {
1338 input_report_switch(wacom->shared->touch_input,
1339 SW_MUTE_DEVICE, data[8] & 0x40);
1340 input_sync(wacom->shared->touch_input);
1341 }
1342 return 0;
1343 }
1344
1345 prox = (data[1] & 0x20) == 0x20;
1346
1347 /*
1348 * All reports shared between PEN and RUBBER tool must be
1349 * forced to a known starting value (zero) when transitioning to
1350 * out-of-prox.
1351 *
1352 * If not reset then, to userspace, it will look like lost events
1353 * if new tool comes in-prox with same values as previous tool sent.
1354 *
1355 * Hardware does report zero in most out-of-prox cases but not all.
1356 */
1357 if (prox) {
1358 if (!wacom->shared->stylus_in_proximity) {
1359 if (data[1] & 0x08) {
1360 wacom->tool[0] = BTN_TOOL_RUBBER;
1361 wacom->id[0] = ERASER_DEVICE_ID;
1362 } else {
1363 wacom->tool[0] = BTN_TOOL_PEN;
1364 wacom->id[0] = STYLUS_DEVICE_ID;
1365 }
1366 wacom->shared->stylus_in_proximity = true;
1367 }
1368 x = le16_to_cpup((__le16 *)&data[2]);
1369 y = le16_to_cpup((__le16 *)&data[4]);
1370 p = le16_to_cpup((__le16 *)&data[6]);
1371 /*
1372 * Convert distance from out prox to distance from tablet.
1373 * distance will be greater than distance_max once
1374 * touching and applying pressure; do not report negative
1375 * distance.
1376 */
1377 if (data[8] <= features->distance_max)
1378 d = features->distance_max - data[8];
1379
1380 pen = data[1] & 0x01;
1381 btn1 = data[1] & 0x02;
1382 btn2 = data[1] & 0x04;
1383 }
1384
1385 input_report_key(input, BTN_TOUCH, pen);
1386 input_report_key(input, BTN_STYLUS, btn1);
1387 input_report_key(input, BTN_STYLUS2, btn2);
1388
1389 input_report_abs(input, ABS_X, x);
1390 input_report_abs(input, ABS_Y, y);
1391 input_report_abs(input, ABS_PRESSURE, p);
1392 input_report_abs(input, ABS_DISTANCE, d);
1393
1394 if (!prox) {
1395 wacom->id[0] = 0;
1396 wacom->shared->stylus_in_proximity = false;
1397 }
1398
1399 input_report_key(input, wacom->tool[0], prox); /* PEN or RUBBER */
1400 input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
1401
1402 return 1;
1403 }
1404
1405 static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
1406 {
1407 if (len == WACOM_PKGLEN_BBTOUCH)
1408 return wacom_bpt_touch(wacom);
1409 else if (len == WACOM_PKGLEN_BBTOUCH3)
1410 return wacom_bpt3_touch(wacom);
1411 else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
1412 return wacom_bpt_pen(wacom);
1413
1414 return 0;
1415 }
1416
1417 static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
1418 {
1419 unsigned char *data = wacom->data;
1420 int connected;
1421
1422 if (len != WACOM_PKGLEN_WIRELESS || data[0] != WACOM_REPORT_WL)
1423 return 0;
1424
1425 connected = data[1] & 0x01;
1426 if (connected) {
1427 int pid, battery, ps_connected;
1428
1429 if ((wacom->shared->type == INTUOSHT) &&
1430 wacom->shared->touch_max) {
1431 input_report_switch(wacom->shared->touch_input,
1432 SW_MUTE_DEVICE, data[5] & 0x40);
1433 input_sync(wacom->shared->touch_input);
1434 }
1435
1436 pid = get_unaligned_be16(&data[6]);
1437 battery = (data[5] & 0x3f) * 100 / 31;
1438 ps_connected = !!(data[5] & 0x80);
1439 if (wacom->pid != pid) {
1440 wacom->pid = pid;
1441 wacom_schedule_work(wacom);
1442 }
1443
1444 if (wacom->shared->type &&
1445 (battery != wacom->battery_capacity ||
1446 ps_connected != wacom->ps_connected)) {
1447 wacom->battery_capacity = battery;
1448 wacom->ps_connected = ps_connected;
1449 wacom->bat_charging = ps_connected &&
1450 wacom->battery_capacity < 100;
1451 wacom_notify_battery(wacom);
1452 }
1453 } else if (wacom->pid != 0) {
1454 /* disconnected while previously connected */
1455 wacom->pid = 0;
1456 wacom_schedule_work(wacom);
1457 wacom->battery_capacity = 0;
1458 wacom->bat_charging = 0;
1459 wacom->ps_connected = 0;
1460 }
1461
1462 return 0;
1463 }
1464
1465 void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
1466 {
1467 bool sync;
1468
1469 switch (wacom_wac->features.type) {
1470 case PENPARTNER:
1471 sync = wacom_penpartner_irq(wacom_wac);
1472 break;
1473
1474 case PL:
1475 sync = wacom_pl_irq(wacom_wac);
1476 break;
1477
1478 case WACOM_G4:
1479 case GRAPHIRE:
1480 case GRAPHIRE_BT:
1481 case WACOM_MO:
1482 sync = wacom_graphire_irq(wacom_wac);
1483 break;
1484
1485 case PTU:
1486 sync = wacom_ptu_irq(wacom_wac);
1487 break;
1488
1489 case DTU:
1490 sync = wacom_dtu_irq(wacom_wac);
1491 break;
1492
1493 case DTUS:
1494 sync = wacom_dtus_irq(wacom_wac);
1495 break;
1496
1497 case INTUOS:
1498 case INTUOS3S:
1499 case INTUOS3:
1500 case INTUOS3L:
1501 case INTUOS4S:
1502 case INTUOS4:
1503 case INTUOS4L:
1504 case CINTIQ:
1505 case WACOM_BEE:
1506 case WACOM_13HD:
1507 case WACOM_21UX2:
1508 case WACOM_22HD:
1509 case WACOM_24HD:
1510 case DTK:
1511 case CINTIQ_HYBRID:
1512 sync = wacom_intuos_irq(wacom_wac);
1513 break;
1514
1515 case WACOM_24HDT:
1516 sync = wacom_24hdt_irq(wacom_wac);
1517 break;
1518
1519 case INTUOS5S:
1520 case INTUOS5:
1521 case INTUOS5L:
1522 case INTUOSPS:
1523 case INTUOSPM:
1524 case INTUOSPL:
1525 if (len == WACOM_PKGLEN_BBTOUCH3)
1526 sync = wacom_bpt3_touch(wacom_wac);
1527 else
1528 sync = wacom_intuos_irq(wacom_wac);
1529 break;
1530
1531 case TABLETPC:
1532 case TABLETPCE:
1533 case TABLETPC2FG:
1534 case MTSCREEN:
1535 case MTTPC:
1536 case MTTPC_B:
1537 sync = wacom_tpc_irq(wacom_wac, len);
1538 break;
1539
1540 case BAMBOO_PT:
1541 case INTUOSHT:
1542 sync = wacom_bpt_irq(wacom_wac, len);
1543 break;
1544
1545 case WIRELESS:
1546 sync = wacom_wireless_irq(wacom_wac, len);
1547 break;
1548
1549 default:
1550 sync = false;
1551 break;
1552 }
1553
1554 if (sync) {
1555 input_sync(wacom_wac->input);
1556 if (wacom_wac->pad_input)
1557 input_sync(wacom_wac->pad_input);
1558 }
1559 }
1560
1561 static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
1562 {
1563 struct input_dev *input_dev = wacom_wac->input;
1564
1565 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
1566
1567 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1568 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
1569 __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
1570 __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
1571 __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
1572 __set_bit(BTN_STYLUS, input_dev->keybit);
1573 __set_bit(BTN_STYLUS2, input_dev->keybit);
1574
1575 input_set_abs_params(input_dev, ABS_DISTANCE,
1576 0, wacom_wac->features.distance_max, 0, 0);
1577 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
1578 input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0);
1579 input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0);
1580 }
1581
1582 static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
1583 {
1584 struct input_dev *input_dev = wacom_wac->input;
1585
1586 input_set_capability(input_dev, EV_REL, REL_WHEEL);
1587
1588 wacom_setup_cintiq(wacom_wac);
1589
1590 __set_bit(BTN_LEFT, input_dev->keybit);
1591 __set_bit(BTN_RIGHT, input_dev->keybit);
1592 __set_bit(BTN_MIDDLE, input_dev->keybit);
1593 __set_bit(BTN_SIDE, input_dev->keybit);
1594 __set_bit(BTN_EXTRA, input_dev->keybit);
1595 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
1596 __set_bit(BTN_TOOL_LENS, input_dev->keybit);
1597
1598 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
1599 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
1600 }
1601
1602 void wacom_setup_device_quirks(struct wacom_features *features)
1603 {
1604
1605 /* touch device found but size is not defined. use default */
1606 if (features->device_type == BTN_TOOL_FINGER && !features->x_max) {
1607 features->x_max = 1023;
1608 features->y_max = 1023;
1609 }
1610
1611 /* these device have multiple inputs */
1612 if (features->type >= WIRELESS ||
1613 (features->type >= INTUOS5S && features->type <= INTUOSHT) ||
1614 (features->oVid && features->oPid))
1615 features->quirks |= WACOM_QUIRK_MULTI_INPUT;
1616
1617 /* quirk for bamboo touch with 2 low res touches */
1618 if (features->type == BAMBOO_PT &&
1619 features->pktlen == WACOM_PKGLEN_BBTOUCH) {
1620 features->x_max <<= 5;
1621 features->y_max <<= 5;
1622 features->x_fuzz <<= 5;
1623 features->y_fuzz <<= 5;
1624 features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;
1625 }
1626
1627 if (features->type == WIRELESS) {
1628
1629 /* monitor never has input and pen/touch have delayed create */
1630 features->quirks |= WACOM_QUIRK_NO_INPUT;
1631
1632 /* must be monitor interface if no device_type set */
1633 if (!features->device_type) {
1634 features->quirks |= WACOM_QUIRK_MONITOR;
1635 features->quirks |= WACOM_QUIRK_BATTERY;
1636 }
1637 }
1638 }
1639
1640 static void wacom_abs_set_axis(struct input_dev *input_dev,
1641 struct wacom_wac *wacom_wac)
1642 {
1643 struct wacom_features *features = &wacom_wac->features;
1644
1645 if (features->device_type == BTN_TOOL_PEN) {
1646 input_set_abs_params(input_dev, ABS_X, features->x_min,
1647 features->x_max, features->x_fuzz, 0);
1648 input_set_abs_params(input_dev, ABS_Y, features->y_min,
1649 features->y_max, features->y_fuzz, 0);
1650 input_set_abs_params(input_dev, ABS_PRESSURE, 0,
1651 features->pressure_max, features->pressure_fuzz, 0);
1652
1653 /* penabled devices have fixed resolution for each model */
1654 input_abs_set_res(input_dev, ABS_X, features->x_resolution);
1655 input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
1656 } else {
1657 if (features->touch_max <= 2) {
1658 input_set_abs_params(input_dev, ABS_X, 0,
1659 features->x_max, features->x_fuzz, 0);
1660 input_set_abs_params(input_dev, ABS_Y, 0,
1661 features->y_max, features->y_fuzz, 0);
1662 input_abs_set_res(input_dev, ABS_X,
1663 features->x_resolution);
1664 input_abs_set_res(input_dev, ABS_Y,
1665 features->y_resolution);
1666 }
1667
1668 if (features->touch_max > 1) {
1669 input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
1670 features->x_max, features->x_fuzz, 0);
1671 input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
1672 features->y_max, features->y_fuzz, 0);
1673 input_abs_set_res(input_dev, ABS_MT_POSITION_X,
1674 features->x_resolution);
1675 input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
1676 features->y_resolution);
1677 }
1678 }
1679 }
1680
1681 int wacom_setup_input_capabilities(struct input_dev *input_dev,
1682 struct wacom_wac *wacom_wac)
1683 {
1684 struct wacom_features *features = &wacom_wac->features;
1685
1686 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
1687
1688 __set_bit(BTN_TOUCH, input_dev->keybit);
1689 __set_bit(ABS_MISC, input_dev->absbit);
1690
1691 wacom_abs_set_axis(input_dev, wacom_wac);
1692
1693 switch (features->type) {
1694 case WACOM_MO:
1695 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
1696 /* fall through */
1697
1698 case WACOM_G4:
1699 /* fall through */
1700
1701 case GRAPHIRE:
1702 input_set_capability(input_dev, EV_REL, REL_WHEEL);
1703
1704 __set_bit(BTN_LEFT, input_dev->keybit);
1705 __set_bit(BTN_RIGHT, input_dev->keybit);
1706 __set_bit(BTN_MIDDLE, input_dev->keybit);
1707
1708 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1709 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
1710 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
1711 __set_bit(BTN_STYLUS, input_dev->keybit);
1712 __set_bit(BTN_STYLUS2, input_dev->keybit);
1713
1714 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1715 break;
1716
1717 case GRAPHIRE_BT:
1718 __clear_bit(ABS_MISC, input_dev->absbit);
1719 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
1720 features->distance_max,
1721 0, 0);
1722
1723 input_set_capability(input_dev, EV_REL, REL_WHEEL);
1724
1725 __set_bit(BTN_LEFT, input_dev->keybit);
1726 __set_bit(BTN_RIGHT, input_dev->keybit);
1727 __set_bit(BTN_MIDDLE, input_dev->keybit);
1728
1729 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1730 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
1731 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
1732 __set_bit(BTN_STYLUS, input_dev->keybit);
1733 __set_bit(BTN_STYLUS2, input_dev->keybit);
1734
1735 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1736 break;
1737
1738 case WACOM_24HD:
1739 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
1740 input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
1741 /* fall through */
1742
1743 case DTK:
1744 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
1745
1746 wacom_setup_cintiq(wacom_wac);
1747 break;
1748
1749 case WACOM_22HD:
1750 case WACOM_21UX2:
1751 case WACOM_BEE:
1752 case CINTIQ:
1753 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
1754
1755 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
1756
1757 wacom_setup_cintiq(wacom_wac);
1758 break;
1759
1760 case WACOM_13HD:
1761 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
1762 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
1763 wacom_setup_cintiq(wacom_wac);
1764 break;
1765
1766 case INTUOS3:
1767 case INTUOS3L:
1768 case INTUOS3S:
1769 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
1770 /* fall through */
1771
1772 case INTUOS:
1773 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1774
1775 wacom_setup_intuos(wacom_wac);
1776 break;
1777
1778 case INTUOS5:
1779 case INTUOS5L:
1780 case INTUOSPM:
1781 case INTUOSPL:
1782 case INTUOS5S:
1783 case INTUOSPS:
1784 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1785
1786 if (features->device_type == BTN_TOOL_PEN) {
1787 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
1788 features->distance_max,
1789 0, 0);
1790
1791 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
1792
1793 wacom_setup_intuos(wacom_wac);
1794 } else if (features->device_type == BTN_TOOL_FINGER) {
1795 __clear_bit(ABS_MISC, input_dev->absbit);
1796
1797 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
1798 0, features->x_max, 0, 0);
1799 input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR,
1800 0, features->y_max, 0, 0);
1801 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
1802 }
1803 break;
1804
1805 case INTUOS4:
1806 case INTUOS4L:
1807 case INTUOS4S:
1808 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
1809 wacom_setup_intuos(wacom_wac);
1810
1811 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1812 break;
1813
1814 case WACOM_24HDT:
1815 if (features->device_type == BTN_TOOL_FINGER) {
1816 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
1817 input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
1818 input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
1819 input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
1820 }
1821 /* fall through */
1822
1823 case MTSCREEN:
1824 case MTTPC:
1825 case MTTPC_B:
1826 case TABLETPC2FG:
1827 if (features->device_type == BTN_TOOL_FINGER) {
1828 unsigned int flags = INPUT_MT_DIRECT;
1829
1830 if (wacom_wac->features.type == TABLETPC2FG)
1831 flags = 0;
1832
1833 input_mt_init_slots(input_dev, features->touch_max, flags);
1834 }
1835 /* fall through */
1836
1837 case TABLETPC:
1838 case TABLETPCE:
1839 __clear_bit(ABS_MISC, input_dev->absbit);
1840
1841 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
1842
1843 if (features->device_type != BTN_TOOL_PEN)
1844 break; /* no need to process stylus stuff */
1845
1846 /* fall through */
1847
1848 case DTUS:
1849 case PL:
1850 case DTU:
1851 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
1852 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1853 __set_bit(BTN_STYLUS, input_dev->keybit);
1854 __set_bit(BTN_STYLUS2, input_dev->keybit);
1855
1856 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
1857 break;
1858
1859 case PTU:
1860 __set_bit(BTN_STYLUS2, input_dev->keybit);
1861 /* fall through */
1862
1863 case PENPARTNER:
1864 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
1865 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1866 __set_bit(BTN_STYLUS, input_dev->keybit);
1867
1868 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1869 break;
1870
1871 case INTUOSHT:
1872 if (features->touch_max &&
1873 features->device_type == BTN_TOOL_FINGER) {
1874 input_dev->evbit[0] |= BIT_MASK(EV_SW);
1875 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
1876 }
1877 /* fall through */
1878
1879 case BAMBOO_PT:
1880 __clear_bit(ABS_MISC, input_dev->absbit);
1881
1882 if (features->device_type == BTN_TOOL_FINGER) {
1883
1884 if (features->touch_max) {
1885 /* touch interface */
1886 unsigned int flags = INPUT_MT_POINTER;
1887
1888 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1889 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
1890 input_set_abs_params(input_dev,
1891 ABS_MT_TOUCH_MAJOR,
1892 0, features->x_max, 0, 0);
1893 input_set_abs_params(input_dev,
1894 ABS_MT_TOUCH_MINOR,
1895 0, features->y_max, 0, 0);
1896 } else {
1897 __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
1898 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
1899 flags = 0;
1900 }
1901 input_mt_init_slots(input_dev, features->touch_max, flags);
1902 } else {
1903 /* buttons/keys only interface */
1904 __clear_bit(ABS_X, input_dev->absbit);
1905 __clear_bit(ABS_Y, input_dev->absbit);
1906 __clear_bit(BTN_TOUCH, input_dev->keybit);
1907 }
1908 } else if (features->device_type == BTN_TOOL_PEN) {
1909 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1910 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1911 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
1912 __set_bit(BTN_STYLUS, input_dev->keybit);
1913 __set_bit(BTN_STYLUS2, input_dev->keybit);
1914 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
1915 features->distance_max,
1916 0, 0);
1917 }
1918 break;
1919
1920 case CINTIQ_HYBRID:
1921 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
1922 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
1923
1924 wacom_setup_cintiq(wacom_wac);
1925 break;
1926 }
1927 return 0;
1928 }
1929
1930 int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
1931 struct wacom_wac *wacom_wac)
1932 {
1933 struct wacom_features *features = &wacom_wac->features;
1934 int i;
1935
1936 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
1937
1938 /* kept for making legacy xf86-input-wacom working with the wheels */
1939 __set_bit(ABS_MISC, input_dev->absbit);
1940
1941 /* kept for making legacy xf86-input-wacom accepting the pad */
1942 input_set_abs_params(input_dev, ABS_X, 0, 1, 0, 0);
1943 input_set_abs_params(input_dev, ABS_Y, 0, 1, 0, 0);
1944
1945 switch (features->type) {
1946 case GRAPHIRE_BT:
1947 __set_bit(BTN_0, input_dev->keybit);
1948 __set_bit(BTN_1, input_dev->keybit);
1949 break;
1950
1951 case WACOM_MO:
1952 __set_bit(BTN_BACK, input_dev->keybit);
1953 __set_bit(BTN_LEFT, input_dev->keybit);
1954 __set_bit(BTN_FORWARD, input_dev->keybit);
1955 __set_bit(BTN_RIGHT, input_dev->keybit);
1956 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
1957 break;
1958
1959 case WACOM_G4:
1960 __set_bit(BTN_BACK, input_dev->keybit);
1961 __set_bit(BTN_LEFT, input_dev->keybit);
1962 __set_bit(BTN_FORWARD, input_dev->keybit);
1963 __set_bit(BTN_RIGHT, input_dev->keybit);
1964 input_set_capability(input_dev, EV_REL, REL_WHEEL);
1965 break;
1966
1967 case WACOM_24HD:
1968 __set_bit(BTN_A, input_dev->keybit);
1969 __set_bit(BTN_B, input_dev->keybit);
1970 __set_bit(BTN_C, input_dev->keybit);
1971 __set_bit(BTN_X, input_dev->keybit);
1972 __set_bit(BTN_Y, input_dev->keybit);
1973 __set_bit(BTN_Z, input_dev->keybit);
1974
1975 for (i = 0; i < 10; i++)
1976 __set_bit(BTN_0 + i, input_dev->keybit);
1977
1978 __set_bit(KEY_PROG1, input_dev->keybit);
1979 __set_bit(KEY_PROG2, input_dev->keybit);
1980 __set_bit(KEY_PROG3, input_dev->keybit);
1981
1982 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
1983 input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
1984 break;
1985
1986 case DTK:
1987 for (i = 0; i < 6; i++)
1988 __set_bit(BTN_0 + i, input_dev->keybit);
1989
1990 break;
1991
1992 case WACOM_22HD:
1993 __set_bit(KEY_PROG1, input_dev->keybit);
1994 __set_bit(KEY_PROG2, input_dev->keybit);
1995 __set_bit(KEY_PROG3, input_dev->keybit);
1996 /* fall through */
1997
1998 case WACOM_21UX2:
1999 __set_bit(BTN_A, input_dev->keybit);
2000 __set_bit(BTN_B, input_dev->keybit);
2001 __set_bit(BTN_C, input_dev->keybit);
2002 __set_bit(BTN_X, input_dev->keybit);
2003 __set_bit(BTN_Y, input_dev->keybit);
2004 __set_bit(BTN_Z, input_dev->keybit);
2005 __set_bit(BTN_BASE, input_dev->keybit);
2006 __set_bit(BTN_BASE2, input_dev->keybit);
2007 /* fall through */
2008
2009 case WACOM_BEE:
2010 __set_bit(BTN_8, input_dev->keybit);
2011 __set_bit(BTN_9, input_dev->keybit);
2012 /* fall through */
2013
2014 case CINTIQ:
2015 for (i = 0; i < 8; i++)
2016 __set_bit(BTN_0 + i, input_dev->keybit);
2017
2018 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
2019 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
2020 break;
2021
2022 case WACOM_13HD:
2023 for (i = 0; i < 9; i++)
2024 __set_bit(BTN_0 + i, input_dev->keybit);
2025
2026 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
2027 break;
2028
2029 case INTUOS3:
2030 case INTUOS3L:
2031 __set_bit(BTN_4, input_dev->keybit);
2032 __set_bit(BTN_5, input_dev->keybit);
2033 __set_bit(BTN_6, input_dev->keybit);
2034 __set_bit(BTN_7, input_dev->keybit);
2035
2036 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
2037 /* fall through */
2038
2039 case INTUOS3S:
2040 __set_bit(BTN_0, input_dev->keybit);
2041 __set_bit(BTN_1, input_dev->keybit);
2042 __set_bit(BTN_2, input_dev->keybit);
2043 __set_bit(BTN_3, input_dev->keybit);
2044
2045 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
2046 break;
2047
2048 case INTUOS5:
2049 case INTUOS5L:
2050 case INTUOSPM:
2051 case INTUOSPL:
2052 __set_bit(BTN_7, input_dev->keybit);
2053 __set_bit(BTN_8, input_dev->keybit);
2054 /* fall through */
2055
2056 case INTUOS5S:
2057 case INTUOSPS:
2058 /* touch interface does not have the pad device */
2059 if (features->device_type != BTN_TOOL_PEN)
2060 return 1;
2061
2062 for (i = 0; i < 7; i++)
2063 __set_bit(BTN_0 + i, input_dev->keybit);
2064
2065 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
2066 break;
2067
2068 case INTUOS4:
2069 case INTUOS4L:
2070 __set_bit(BTN_7, input_dev->keybit);
2071 __set_bit(BTN_8, input_dev->keybit);
2072 /* fall through */
2073
2074 case INTUOS4S:
2075 for (i = 0; i < 7; i++)
2076 __set_bit(BTN_0 + i, input_dev->keybit);
2077
2078 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
2079 break;
2080
2081 case CINTIQ_HYBRID:
2082 for (i = 0; i < 9; i++)
2083 __set_bit(BTN_0 + i, input_dev->keybit);
2084
2085 break;
2086
2087 case DTUS:
2088 for (i = 0; i < 4; i++)
2089 __set_bit(BTN_0 + i, input_dev->keybit);
2090 break;
2091
2092 case INTUOSHT:
2093 case BAMBOO_PT:
2094 /* pad device is on the touch interface */
2095 if (features->device_type != BTN_TOOL_FINGER)
2096 return 1;
2097
2098 __clear_bit(ABS_MISC, input_dev->absbit);
2099
2100 __set_bit(BTN_LEFT, input_dev->keybit);
2101 __set_bit(BTN_FORWARD, input_dev->keybit);
2102 __set_bit(BTN_BACK, input_dev->keybit);
2103 __set_bit(BTN_RIGHT, input_dev->keybit);
2104
2105 break;
2106
2107 default:
2108 /* no pad supported */
2109 return 1;
2110 }
2111 return 0;
2112 }
2113
2114 static const struct wacom_features wacom_features_0x00 =
2115 { "Wacom Penpartner", 5040, 3780, 255, 0,
2116 PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
2117 static const struct wacom_features wacom_features_0x10 =
2118 { "Wacom Graphire", 10206, 7422, 511, 63,
2119 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
2120 static const struct wacom_features wacom_features_0x81 =
2121 { "Wacom Graphire BT", 16704, 12064, 511, 32,
2122 GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
2123 static const struct wacom_features wacom_features_0x11 =
2124 { "Wacom Graphire2 4x5", 10206, 7422, 511, 63,
2125 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
2126 static const struct wacom_features wacom_features_0x12 =
2127 { "Wacom Graphire2 5x7", 13918, 10206, 511, 63,
2128 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
2129 static const struct wacom_features wacom_features_0x13 =
2130 { "Wacom Graphire3", 10208, 7424, 511, 63,
2131 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
2132 static const struct wacom_features wacom_features_0x14 =
2133 { "Wacom Graphire3 6x8", 16704, 12064, 511, 63,
2134 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
2135 static const struct wacom_features wacom_features_0x15 =
2136 { "Wacom Graphire4 4x5", 10208, 7424, 511, 63,
2137 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
2138 static const struct wacom_features wacom_features_0x16 =
2139 { "Wacom Graphire4 6x8", 16704, 12064, 511, 63,
2140 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
2141 static const struct wacom_features wacom_features_0x17 =
2142 { "Wacom BambooFun 4x5", 14760, 9225, 511, 63,
2143 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2144 static const struct wacom_features wacom_features_0x18 =
2145 { "Wacom BambooFun 6x8", 21648, 13530, 511, 63,
2146 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2147 static const struct wacom_features wacom_features_0x19 =
2148 { "Wacom Bamboo1 Medium", 16704, 12064, 511, 63,
2149 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
2150 static const struct wacom_features wacom_features_0x60 =
2151 { "Wacom Volito", 5104, 3712, 511, 63,
2152 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
2153 static const struct wacom_features wacom_features_0x61 =
2154 { "Wacom PenStation2", 3250, 2320, 255, 63,
2155 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
2156 static const struct wacom_features wacom_features_0x62 =
2157 { "Wacom Volito2 4x5", 5104, 3712, 511, 63,
2158 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
2159 static const struct wacom_features wacom_features_0x63 =
2160 { "Wacom Volito2 2x3", 3248, 2320, 511, 63,
2161 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
2162 static const struct wacom_features wacom_features_0x64 =
2163 { "Wacom PenPartner2", 3250, 2320, 511, 63,
2164 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
2165 static const struct wacom_features wacom_features_0x65 =
2166 { "Wacom Bamboo", 14760, 9225, 511, 63,
2167 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2168 static const struct wacom_features wacom_features_0x69 =
2169 { "Wacom Bamboo1", 5104, 3712, 511, 63,
2170 GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
2171 static const struct wacom_features wacom_features_0x6A =
2172 { "Wacom Bamboo1 4x6", 14760, 9225, 1023, 63,
2173 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2174 static const struct wacom_features wacom_features_0x6B =
2175 { "Wacom Bamboo1 5x8", 21648, 13530, 1023, 63,
2176 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2177 static const struct wacom_features wacom_features_0x20 =
2178 { "Wacom Intuos 4x5", 12700, 10600, 1023, 31,
2179 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2180 static const struct wacom_features wacom_features_0x21 =
2181 { "Wacom Intuos 6x8", 20320, 16240, 1023, 31,
2182 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2183 static const struct wacom_features wacom_features_0x22 =
2184 { "Wacom Intuos 9x12", 30480, 24060, 1023, 31,
2185 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2186 static const struct wacom_features wacom_features_0x23 =
2187 { "Wacom Intuos 12x12", 30480, 31680, 1023, 31,
2188 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2189 static const struct wacom_features wacom_features_0x24 =
2190 { "Wacom Intuos 12x18", 45720, 31680, 1023, 31,
2191 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2192 static const struct wacom_features wacom_features_0x30 =
2193 { "Wacom PL400", 5408, 4056, 255, 0,
2194 PL, WACOM_PL_RES, WACOM_PL_RES };
2195 static const struct wacom_features wacom_features_0x31 =
2196 { "Wacom PL500", 6144, 4608, 255, 0,
2197 PL, WACOM_PL_RES, WACOM_PL_RES };
2198 static const struct wacom_features wacom_features_0x32 =
2199 { "Wacom PL600", 6126, 4604, 255, 0,
2200 PL, WACOM_PL_RES, WACOM_PL_RES };
2201 static const struct wacom_features wacom_features_0x33 =
2202 { "Wacom PL600SX", 6260, 5016, 255, 0,
2203 PL, WACOM_PL_RES, WACOM_PL_RES };
2204 static const struct wacom_features wacom_features_0x34 =
2205 { "Wacom PL550", 6144, 4608, 511, 0,
2206 PL, WACOM_PL_RES, WACOM_PL_RES };
2207 static const struct wacom_features wacom_features_0x35 =
2208 { "Wacom PL800", 7220, 5780, 511, 0,
2209 PL, WACOM_PL_RES, WACOM_PL_RES };
2210 static const struct wacom_features wacom_features_0x37 =
2211 { "Wacom PL700", 6758, 5406, 511, 0,
2212 PL, WACOM_PL_RES, WACOM_PL_RES };
2213 static const struct wacom_features wacom_features_0x38 =
2214 { "Wacom PL510", 6282, 4762, 511, 0,
2215 PL, WACOM_PL_RES, WACOM_PL_RES };
2216 static const struct wacom_features wacom_features_0x39 =
2217 { "Wacom DTU710", 34080, 27660, 511, 0,
2218 PL, WACOM_PL_RES, WACOM_PL_RES };
2219 static const struct wacom_features wacom_features_0xC4 =
2220 { "Wacom DTF521", 6282, 4762, 511, 0,
2221 PL, WACOM_PL_RES, WACOM_PL_RES };
2222 static const struct wacom_features wacom_features_0xC0 =
2223 { "Wacom DTF720", 6858, 5506, 511, 0,
2224 PL, WACOM_PL_RES, WACOM_PL_RES };
2225 static const struct wacom_features wacom_features_0xC2 =
2226 { "Wacom DTF720a", 6858, 5506, 511, 0,
2227 PL, WACOM_PL_RES, WACOM_PL_RES };
2228 static const struct wacom_features wacom_features_0x03 =
2229 { "Wacom Cintiq Partner", 20480, 15360, 511, 0,
2230 PTU, WACOM_PL_RES, WACOM_PL_RES };
2231 static const struct wacom_features wacom_features_0x41 =
2232 { "Wacom Intuos2 4x5", 12700, 10600, 1023, 31,
2233 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2234 static const struct wacom_features wacom_features_0x42 =
2235 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
2236 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2237 static const struct wacom_features wacom_features_0x43 =
2238 { "Wacom Intuos2 9x12", 30480, 24060, 1023, 31,
2239 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2240 static const struct wacom_features wacom_features_0x44 =
2241 { "Wacom Intuos2 12x12", 30480, 31680, 1023, 31,
2242 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2243 static const struct wacom_features wacom_features_0x45 =
2244 { "Wacom Intuos2 12x18", 45720, 31680, 1023, 31,
2245 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2246 static const struct wacom_features wacom_features_0xB0 =
2247 { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63,
2248 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
2249 static const struct wacom_features wacom_features_0xB1 =
2250 { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63,
2251 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
2252 static const struct wacom_features wacom_features_0xB2 =
2253 { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63,
2254 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
2255 static const struct wacom_features wacom_features_0xB3 =
2256 { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63,
2257 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
2258 static const struct wacom_features wacom_features_0xB4 =
2259 { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63,
2260 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
2261 static const struct wacom_features wacom_features_0xB5 =
2262 { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63,
2263 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
2264 static const struct wacom_features wacom_features_0xB7 =
2265 { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63,
2266 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
2267 static const struct wacom_features wacom_features_0xB8 =
2268 { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63,
2269 INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
2270 static const struct wacom_features wacom_features_0xB9 =
2271 { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63,
2272 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
2273 static const struct wacom_features wacom_features_0xBA =
2274 { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63,
2275 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
2276 static const struct wacom_features wacom_features_0xBB =
2277 { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63,
2278 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
2279 static const struct wacom_features wacom_features_0xBC =
2280 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
2281 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
2282 static const struct wacom_features wacom_features_0x26 =
2283 { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63,
2284 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16 };
2285 static const struct wacom_features wacom_features_0x27 =
2286 { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63,
2287 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16 };
2288 static const struct wacom_features wacom_features_0x28 =
2289 { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63,
2290 INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16 };
2291 static const struct wacom_features wacom_features_0x29 =
2292 { "Wacom Intuos5 S", 31496, 19685, 2047, 63,
2293 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
2294 static const struct wacom_features wacom_features_0x2A =
2295 { "Wacom Intuos5 M", 44704, 27940, 2047, 63,
2296 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
2297 static const struct wacom_features wacom_features_0x314 =
2298 { "Wacom Intuos Pro S", 31496, 19685, 2047, 63,
2299 INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16,
2300 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
2301 static const struct wacom_features wacom_features_0x315 =
2302 { "Wacom Intuos Pro M", 44704, 27940, 2047, 63,
2303 INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16,
2304 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
2305 static const struct wacom_features wacom_features_0x317 =
2306 { "Wacom Intuos Pro L", 65024, 40640, 2047, 63,
2307 INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16,
2308 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
2309 static const struct wacom_features wacom_features_0xF4 =
2310 { "Wacom Cintiq 24HD", 104280, 65400, 2047, 63,
2311 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
2312 static const struct wacom_features wacom_features_0xF8 =
2313 { "Wacom Cintiq 24HD touch", 104280, 65400, 2047, 63, /* Pen */
2314 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
2315 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 };
2316 static const struct wacom_features wacom_features_0xF6 =
2317 { "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */
2318 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10,
2319 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
2320 static const struct wacom_features wacom_features_0x3F =
2321 { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63,
2322 CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
2323 static const struct wacom_features wacom_features_0xC5 =
2324 { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63,
2325 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
2326 static const struct wacom_features wacom_features_0xC6 =
2327 { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63,
2328 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
2329 static const struct wacom_features wacom_features_0x304 =
2330 { "Wacom Cintiq 13HD", 59352, 33648, 1023, 63,
2331 WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
2332 static const struct wacom_features wacom_features_0xC7 =
2333 { "Wacom DTU1931", 37832, 30305, 511, 0,
2334 PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2335 static const struct wacom_features wacom_features_0xCE =
2336 { "Wacom DTU2231", 47864, 27011, 511, 0,
2337 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
2338 .check_for_hid_type = true, .hid_type = HID_TYPE_USBMOUSE };
2339 static const struct wacom_features wacom_features_0xF0 =
2340 { "Wacom DTU1631", 34623, 19553, 511, 0,
2341 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2342 static const struct wacom_features wacom_features_0xFB =
2343 { "Wacom DTU1031", 22096, 13960, 511, 0,
2344 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2345 static const struct wacom_features wacom_features_0x57 =
2346 { "Wacom DTK2241", 95640, 54060, 2047, 63,
2347 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
2348 static const struct wacom_features wacom_features_0x59 = /* Pen */
2349 { "Wacom DTH2242", 95640, 54060, 2047, 63,
2350 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
2351 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D };
2352 static const struct wacom_features wacom_features_0x5D = /* Touch */
2353 { "Wacom DTH2242", .type = WACOM_24HDT,
2354 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10,
2355 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
2356 static const struct wacom_features wacom_features_0xCC =
2357 { "Wacom Cintiq 21UX2", 87000, 65400, 2047, 63,
2358 WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
2359 static const struct wacom_features wacom_features_0xFA =
2360 { "Wacom Cintiq 22HD", 95640, 54060, 2047, 63,
2361 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
2362 static const struct wacom_features wacom_features_0x5B =
2363 { "Wacom Cintiq 22HDT", 95640, 54060, 2047, 63,
2364 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
2365 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e };
2366 static const struct wacom_features wacom_features_0x5E =
2367 { "Wacom Cintiq 22HDT", .type = WACOM_24HDT,
2368 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5b, .touch_max = 10,
2369 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
2370 static const struct wacom_features wacom_features_0x90 =
2371 { "Wacom ISDv4 90", 26202, 16325, 255, 0,
2372 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2373 static const struct wacom_features wacom_features_0x93 =
2374 { "Wacom ISDv4 93", 26202, 16325, 255, 0,
2375 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2376 static const struct wacom_features wacom_features_0x97 =
2377 { "Wacom ISDv4 97", 26202, 16325, 511, 0,
2378 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2379 static const struct wacom_features wacom_features_0x9A =
2380 { "Wacom ISDv4 9A", 26202, 16325, 255, 0,
2381 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2382 static const struct wacom_features wacom_features_0x9F =
2383 { "Wacom ISDv4 9F", 26202, 16325, 255, 0,
2384 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2385 static const struct wacom_features wacom_features_0xE2 =
2386 { "Wacom ISDv4 E2", 26202, 16325, 255, 0,
2387 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
2388 static const struct wacom_features wacom_features_0xE3 =
2389 { "Wacom ISDv4 E3", 26202, 16325, 255, 0,
2390 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
2391 static const struct wacom_features wacom_features_0xE5 =
2392 { "Wacom ISDv4 E5", 26202, 16325, 255, 0,
2393 MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2394 static const struct wacom_features wacom_features_0xE6 =
2395 { "Wacom ISDv4 E6", 27760, 15694, 255, 0,
2396 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
2397 static const struct wacom_features wacom_features_0xEC =
2398 { "Wacom ISDv4 EC", 25710, 14500, 255, 0,
2399 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2400 static const struct wacom_features wacom_features_0xED =
2401 { "Wacom ISDv4 ED", 26202, 16325, 255, 0,
2402 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2403 static const struct wacom_features wacom_features_0xEF =
2404 { "Wacom ISDv4 EF", 26202, 16325, 255, 0,
2405 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2406 static const struct wacom_features wacom_features_0x100 =
2407 { "Wacom ISDv4 100", 26202, 16325, 255, 0,
2408 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2409 static const struct wacom_features wacom_features_0x101 =
2410 { "Wacom ISDv4 101", 26202, 16325, 255, 0,
2411 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2412 static const struct wacom_features wacom_features_0x10D =
2413 { "Wacom ISDv4 10D", 26202, 16325, 255, 0,
2414 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2415 static const struct wacom_features wacom_features_0x10E =
2416 { "Wacom ISDv4 10E", 27760, 15694, 255, 0,
2417 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2418 static const struct wacom_features wacom_features_0x10F =
2419 { "Wacom ISDv4 10F", 27760, 15694, 255, 0,
2420 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2421 static const struct wacom_features wacom_features_0x116 =
2422 { "Wacom ISDv4 116", 26202, 16325, 255, 0,
2423 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2424 static const struct wacom_features wacom_features_0x12C =
2425 { "Wacom ISDv4 12C", 27848, 15752, 2047, 0,
2426 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2427 static const struct wacom_features wacom_features_0x4001 =
2428 { "Wacom ISDv4 4001", 26202, 16325, 255, 0,
2429 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2430 static const struct wacom_features wacom_features_0x4004 =
2431 { "Wacom ISDv4 4004", 11060, 6220, 255, 0,
2432 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2433 static const struct wacom_features wacom_features_0x5000 =
2434 { "Wacom ISDv4 5000", 27848, 15752, 1023, 0,
2435 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2436 static const struct wacom_features wacom_features_0x5002 =
2437 { "Wacom ISDv4 5002", 29576, 16724, 1023, 0,
2438 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2439 static const struct wacom_features wacom_features_0x47 =
2440 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
2441 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2442 static const struct wacom_features wacom_features_0x84 =
2443 { "Wacom Wireless Receiver", 0, 0, 0, 0,
2444 WIRELESS, 0, 0, .touch_max = 16 };
2445 static const struct wacom_features wacom_features_0xD0 =
2446 { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31,
2447 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
2448 static const struct wacom_features wacom_features_0xD1 =
2449 { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31,
2450 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
2451 static const struct wacom_features wacom_features_0xD2 =
2452 { "Wacom Bamboo Craft", 14720, 9200, 1023, 31,
2453 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
2454 static const struct wacom_features wacom_features_0xD3 =
2455 { "Wacom Bamboo 2FG 6x8", 21648, 13700, 1023, 31,
2456 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
2457 static const struct wacom_features wacom_features_0xD4 =
2458 { "Wacom Bamboo Pen", 14720, 9200, 1023, 31,
2459 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2460 static const struct wacom_features wacom_features_0xD5 =
2461 { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31,
2462 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2463 static const struct wacom_features wacom_features_0xD6 =
2464 { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31,
2465 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
2466 static const struct wacom_features wacom_features_0xD7 =
2467 { "Wacom BambooPT 2FG Small", 14720, 9200, 1023, 31,
2468 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
2469 static const struct wacom_features wacom_features_0xD8 =
2470 { "Wacom Bamboo Comic 2FG", 21648, 13700, 1023, 31,
2471 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
2472 static const struct wacom_features wacom_features_0xDA =
2473 { "Wacom Bamboo 2FG 4x5 SE", 14720, 9200, 1023, 31,
2474 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
2475 static const struct wacom_features wacom_features_0xDB =
2476 { "Wacom Bamboo 2FG 6x8 SE", 21648, 13700, 1023, 31,
2477 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
2478 static const struct wacom_features wacom_features_0xDD =
2479 { "Wacom Bamboo Connect", 14720, 9200, 1023, 31,
2480 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2481 static const struct wacom_features wacom_features_0xDE =
2482 { "Wacom Bamboo 16FG 4x5", 14720, 9200, 1023, 31,
2483 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
2484 static const struct wacom_features wacom_features_0xDF =
2485 { "Wacom Bamboo 16FG 6x8", 21648, 13700, 1023, 31,
2486 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
2487 static const struct wacom_features wacom_features_0x300 =
2488 { "Wacom Bamboo One S", 14720, 9225, 1023, 31,
2489 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2490 static const struct wacom_features wacom_features_0x301 =
2491 { "Wacom Bamboo One M", 21648, 13530, 1023, 31,
2492 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2493 static const struct wacom_features wacom_features_0x302 =
2494 { "Wacom Intuos PT S", 15200, 9500, 1023, 31,
2495 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
2496 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
2497 static const struct wacom_features wacom_features_0x303 =
2498 { "Wacom Intuos PT M", 21600, 13500, 1023, 31,
2499 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
2500 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
2501 static const struct wacom_features wacom_features_0x30E =
2502 { "Wacom Intuos S", 15200, 9500, 1023, 31,
2503 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
2504 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
2505 static const struct wacom_features wacom_features_0x6004 =
2506 { "ISD-V4", 12800, 8000, 255, 0,
2507 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2508 static const struct wacom_features wacom_features_0x307 =
2509 { "Wacom ISDv5 307", 59352, 33648, 2047, 63,
2510 CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
2511 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 };
2512 static const struct wacom_features wacom_features_0x309 =
2513 { "Wacom ISDv5 309", .type = WACOM_24HDT, /* Touch */
2514 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x0307, .touch_max = 10,
2515 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
2516
2517 #define USB_DEVICE_WACOM(prod) \
2518 HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
2519 .driver_data = (kernel_ulong_t)&wacom_features_##prod
2520
2521 #define BT_DEVICE_WACOM(prod) \
2522 HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
2523 .driver_data = (kernel_ulong_t)&wacom_features_##prod
2524
2525 #define USB_DEVICE_LENOVO(prod) \
2526 HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
2527 .driver_data = (kernel_ulong_t)&wacom_features_##prod
2528
2529 const struct hid_device_id wacom_ids[] = {
2530 { USB_DEVICE_WACOM(0x00) },
2531 { USB_DEVICE_WACOM(0x03) },
2532 { USB_DEVICE_WACOM(0x10) },
2533 { USB_DEVICE_WACOM(0x11) },
2534 { USB_DEVICE_WACOM(0x12) },
2535 { USB_DEVICE_WACOM(0x13) },
2536 { USB_DEVICE_WACOM(0x14) },
2537 { USB_DEVICE_WACOM(0x15) },
2538 { USB_DEVICE_WACOM(0x16) },
2539 { USB_DEVICE_WACOM(0x17) },
2540 { USB_DEVICE_WACOM(0x18) },
2541 { USB_DEVICE_WACOM(0x19) },
2542 { USB_DEVICE_WACOM(0x20) },
2543 { USB_DEVICE_WACOM(0x21) },
2544 { USB_DEVICE_WACOM(0x22) },
2545 { USB_DEVICE_WACOM(0x23) },
2546 { USB_DEVICE_WACOM(0x24) },
2547 { USB_DEVICE_WACOM(0x26) },
2548 { USB_DEVICE_WACOM(0x27) },
2549 { USB_DEVICE_WACOM(0x28) },
2550 { USB_DEVICE_WACOM(0x29) },
2551 { USB_DEVICE_WACOM(0x2A) },
2552 { USB_DEVICE_WACOM(0x30) },
2553 { USB_DEVICE_WACOM(0x31) },
2554 { USB_DEVICE_WACOM(0x32) },
2555 { USB_DEVICE_WACOM(0x33) },
2556 { USB_DEVICE_WACOM(0x34) },
2557 { USB_DEVICE_WACOM(0x35) },
2558 { USB_DEVICE_WACOM(0x37) },
2559 { USB_DEVICE_WACOM(0x38) },
2560 { USB_DEVICE_WACOM(0x39) },
2561 { USB_DEVICE_WACOM(0x3F) },
2562 { USB_DEVICE_WACOM(0x41) },
2563 { USB_DEVICE_WACOM(0x42) },
2564 { USB_DEVICE_WACOM(0x43) },
2565 { USB_DEVICE_WACOM(0x44) },
2566 { USB_DEVICE_WACOM(0x45) },
2567 { USB_DEVICE_WACOM(0x47) },
2568 { USB_DEVICE_WACOM(0x57) },
2569 { USB_DEVICE_WACOM(0x59) },
2570 { USB_DEVICE_WACOM(0x5B) },
2571 { USB_DEVICE_WACOM(0x5D) },
2572 { USB_DEVICE_WACOM(0x5E) },
2573 { USB_DEVICE_WACOM(0x60) },
2574 { USB_DEVICE_WACOM(0x61) },
2575 { USB_DEVICE_WACOM(0x62) },
2576 { USB_DEVICE_WACOM(0x63) },
2577 { USB_DEVICE_WACOM(0x64) },
2578 { USB_DEVICE_WACOM(0x65) },
2579 { USB_DEVICE_WACOM(0x69) },
2580 { USB_DEVICE_WACOM(0x6A) },
2581 { USB_DEVICE_WACOM(0x6B) },
2582 { BT_DEVICE_WACOM(0x81) },
2583 { USB_DEVICE_WACOM(0x84) },
2584 { USB_DEVICE_WACOM(0x90) },
2585 { USB_DEVICE_WACOM(0x93) },
2586 { USB_DEVICE_WACOM(0x97) },
2587 { USB_DEVICE_WACOM(0x9A) },
2588 { USB_DEVICE_WACOM(0x9F) },
2589 { USB_DEVICE_WACOM(0xB0) },
2590 { USB_DEVICE_WACOM(0xB1) },
2591 { USB_DEVICE_WACOM(0xB2) },
2592 { USB_DEVICE_WACOM(0xB3) },
2593 { USB_DEVICE_WACOM(0xB4) },
2594 { USB_DEVICE_WACOM(0xB5) },
2595 { USB_DEVICE_WACOM(0xB7) },
2596 { USB_DEVICE_WACOM(0xB8) },
2597 { USB_DEVICE_WACOM(0xB9) },
2598 { USB_DEVICE_WACOM(0xBA) },
2599 { USB_DEVICE_WACOM(0xBB) },
2600 { USB_DEVICE_WACOM(0xBC) },
2601 { USB_DEVICE_WACOM(0xC0) },
2602 { USB_DEVICE_WACOM(0xC2) },
2603 { USB_DEVICE_WACOM(0xC4) },
2604 { USB_DEVICE_WACOM(0xC5) },
2605 { USB_DEVICE_WACOM(0xC6) },
2606 { USB_DEVICE_WACOM(0xC7) },
2607 { USB_DEVICE_WACOM(0xCC) },
2608 { USB_DEVICE_WACOM(0xCE) },
2609 { USB_DEVICE_WACOM(0xD0) },
2610 { USB_DEVICE_WACOM(0xD1) },
2611 { USB_DEVICE_WACOM(0xD2) },
2612 { USB_DEVICE_WACOM(0xD3) },
2613 { USB_DEVICE_WACOM(0xD4) },
2614 { USB_DEVICE_WACOM(0xD5) },
2615 { USB_DEVICE_WACOM(0xD6) },
2616 { USB_DEVICE_WACOM(0xD7) },
2617 { USB_DEVICE_WACOM(0xD8) },
2618 { USB_DEVICE_WACOM(0xDA) },
2619 { USB_DEVICE_WACOM(0xDB) },
2620 { USB_DEVICE_WACOM(0xDD) },
2621 { USB_DEVICE_WACOM(0xDE) },
2622 { USB_DEVICE_WACOM(0xDF) },
2623 { USB_DEVICE_WACOM(0xE2) },
2624 { USB_DEVICE_WACOM(0xE3) },
2625 { USB_DEVICE_WACOM(0xE5) },
2626 { USB_DEVICE_WACOM(0xE6) },
2627 { USB_DEVICE_WACOM(0xEC) },
2628 { USB_DEVICE_WACOM(0xED) },
2629 { USB_DEVICE_WACOM(0xEF) },
2630 { USB_DEVICE_WACOM(0xF0) },
2631 { USB_DEVICE_WACOM(0xF4) },
2632 { USB_DEVICE_WACOM(0xF6) },
2633 { USB_DEVICE_WACOM(0xF8) },
2634 { USB_DEVICE_WACOM(0xFA) },
2635 { USB_DEVICE_WACOM(0xFB) },
2636 { USB_DEVICE_WACOM(0x100) },
2637 { USB_DEVICE_WACOM(0x101) },
2638 { USB_DEVICE_WACOM(0x10D) },
2639 { USB_DEVICE_WACOM(0x10E) },
2640 { USB_DEVICE_WACOM(0x10F) },
2641 { USB_DEVICE_WACOM(0x116) },
2642 { USB_DEVICE_WACOM(0x12C) },
2643 { USB_DEVICE_WACOM(0x300) },
2644 { USB_DEVICE_WACOM(0x301) },
2645 { USB_DEVICE_WACOM(0x302) },
2646 { USB_DEVICE_WACOM(0x303) },
2647 { USB_DEVICE_WACOM(0x304) },
2648 { USB_DEVICE_WACOM(0x307) },
2649 { USB_DEVICE_WACOM(0x309) },
2650 { USB_DEVICE_WACOM(0x30E) },
2651 { USB_DEVICE_WACOM(0x314) },
2652 { USB_DEVICE_WACOM(0x315) },
2653 { USB_DEVICE_WACOM(0x317) },
2654 { USB_DEVICE_WACOM(0x4001) },
2655 { USB_DEVICE_WACOM(0x4004) },
2656 { USB_DEVICE_WACOM(0x5000) },
2657 { USB_DEVICE_WACOM(0x5002) },
2658 { }
2659 };
2660 MODULE_DEVICE_TABLE(hid, wacom_ids);