]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/hid/wacom_wac.c
Input: wacom - handle Graphire BT tablets in wacom.ko
[mirror_ubuntu-artful-kernel.git] / drivers / hid / wacom_wac.c
CommitLineData
3bea733a 1/*
4104d13f 2 * drivers/input/tablet/wacom_wac.c
3bea733a 3 *
ee54500d 4 * USB Wacom tablet support - Wacom specific code
3bea733a
PC
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 */
51269fe8 14
3bea733a 15#include "wacom_wac.h"
51269fe8 16#include "wacom.h"
47c78e89 17#include <linux/input/mt.h>
1483f551 18#include <linux/hid.h>
3bea733a 19
e35fb8c1
PC
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
387142bb
BT
28/*
29 * Scale factor relating reported contact size to logical contact area.
4e904954
JG
30 * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo
31 */
32#define WACOM_CONTACT_AREA_SCALE 2607
33
387142bb
BT
34/*
35 * Percent of battery capacity for Graphire.
36 * 8th value means AC online and show 100% capacity.
37 */
38static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
39
95dd3b30 40static int wacom_penpartner_irq(struct wacom_wac *wacom)
3bea733a
PC
41{
42 unsigned char *data = wacom->data;
8da23fc1 43 struct input_dev *input = wacom->input;
3bea733a
PC
44
45 switch (data[0]) {
73a97f4f
DT
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;
8da23fc1
DT
50 input_report_key(input, wacom->tool[0], 1);
51 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
252f7769
DT
52 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
53 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
8da23fc1
DT
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));
73a97f4f 57 } else {
8da23fc1
DT
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);
73a97f4f
DT
62 }
63 break;
8da23fc1 64
73a97f4f 65 case 2:
8da23fc1
DT
66 input_report_key(input, BTN_TOOL_PEN, 1);
67 input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
252f7769
DT
68 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
69 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
8da23fc1
DT
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));
73a97f4f 73 break;
8da23fc1 74
73a97f4f 75 default:
eb71d1bb
DT
76 dev_dbg(input->dev.parent,
77 "%s: received unknown report #%d\n", __func__, data[0]);
73a97f4f 78 return 0;
3bea733a 79 }
8da23fc1 80
3bea733a
PC
81 return 1;
82}
83
95dd3b30 84static int wacom_pl_irq(struct wacom_wac *wacom)
3bea733a 85{
e33da8a5 86 struct wacom_features *features = &wacom->features;
3bea733a 87 unsigned char *data = wacom->data;
8da23fc1 88 struct input_dev *input = wacom->input;
e34b9d2f 89 int prox, pressure;
3bea733a 90
cad74700 91 if (data[0] != WACOM_REPORT_PENABLED) {
eb71d1bb
DT
92 dev_dbg(input->dev.parent,
93 "%s: received unknown report #%d\n", __func__, data[0]);
3bea733a
PC
94 return 0;
95 }
96
97 prox = data[1] & 0x40;
98
3bea733a 99 if (prox) {
ec67bbed 100 wacom->id[0] = ERASER_DEVICE_ID;
3bea733a 101 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
e33da8a5 102 if (features->pressure_max > 255)
3bea733a 103 pressure = (pressure << 1) | ((data[4] >> 6) & 1);
e33da8a5 104 pressure += (features->pressure_max + 1) / 2;
3bea733a
PC
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 */
8da23fc1
DT
123 input_report_key(input, wacom->tool[1], 0);
124 input_sync(input);
3bea733a
PC
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;
e34b9d2f 132 wacom->id[0] = STYLUS_DEVICE_ID;
3bea733a 133 }
8da23fc1
DT
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);
3bea733a 142 /* Only allow the stylus2 button to be reported for the pen tool. */
8da23fc1 143 input_report_key(input, BTN_STYLUS2, (wacom->tool[1] == BTN_TOOL_PEN) && (data[4] & 0x20));
3bea733a
PC
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 }
8da23fc1 150 input_report_key(input, wacom->tool[1], prox);
3bea733a
PC
151 }
152
153 wacom->tool[0] = prox; /* Save proximity state */
154 return 1;
155}
156
95dd3b30 157static int wacom_ptu_irq(struct wacom_wac *wacom)
3bea733a
PC
158{
159 unsigned char *data = wacom->data;
8da23fc1 160 struct input_dev *input = wacom->input;
3bea733a 161
cad74700 162 if (data[0] != WACOM_REPORT_PENABLED) {
eb71d1bb
DT
163 dev_dbg(input->dev.parent,
164 "%s: received unknown report #%d\n", __func__, data[0]);
3bea733a
PC
165 return 0;
166 }
167
3bea733a 168 if (data[1] & 0x04) {
8da23fc1
DT
169 input_report_key(input, BTN_TOOL_RUBBER, data[1] & 0x20);
170 input_report_key(input, BTN_TOUCH, data[1] & 0x08);
e34b9d2f 171 wacom->id[0] = ERASER_DEVICE_ID;
3bea733a 172 } else {
8da23fc1
DT
173 input_report_key(input, BTN_TOOL_PEN, data[1] & 0x20);
174 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
e34b9d2f 175 wacom->id[0] = STYLUS_DEVICE_ID;
3bea733a 176 }
8da23fc1 177 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
252f7769
DT
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]));
8da23fc1
DT
181 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
182 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
3bea733a
PC
183 return 1;
184}
185
c8f2edc5
PC
186static int wacom_dtu_irq(struct wacom_wac *wacom)
187{
74b63417 188 unsigned char *data = wacom->data;
c8f2edc5 189 struct input_dev *input = wacom->input;
74b63417 190 int prox = data[1] & 0x20;
c8f2edc5 191
eb71d1bb
DT
192 dev_dbg(input->dev.parent,
193 "%s: received report #%d", __func__, data[0]);
c8f2edc5
PC
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]));
74b63417 207 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x01) << 8) | data[6]);
c8f2edc5
PC
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
497ab1f2
PC
216static 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) {
422b0314 227 input = wacom->pad_input;
497ab1f2
PC
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);
497ab1f2
PC
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]);
497ab1f2
PC
263 return 1;
264 }
265}
266
95dd3b30 267static int wacom_graphire_irq(struct wacom_wac *wacom)
3bea733a 268{
e33da8a5 269 struct wacom_features *features = &wacom->features;
3bea733a 270 unsigned char *data = wacom->data;
8da23fc1 271 struct input_dev *input = wacom->input;
3813810c 272 struct input_dev *pad_input = wacom->pad_input;
387142bb 273 int battery_capacity, ps_connected;
252f7769 274 int prox;
3b57ca0f
PC
275 int rw = 0;
276 int retval = 0;
3bea733a 277
387142bb
BT
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) {
eb71d1bb
DT
286 dev_dbg(input->dev.parent,
287 "%s: received unknown report #%d\n", __func__, data[0]);
3b57ca0f 288 goto exit;
3bea733a
PC
289 }
290
3b57ca0f
PC
291 prox = data[1] & 0x80;
292 if (prox || wacom->id[0]) {
293 if (prox) {
294 switch ((data[1] >> 5) & 3) {
3bea733a
PC
295
296 case 0: /* Pen */
297 wacom->tool[0] = BTN_TOOL_PEN;
e34b9d2f 298 wacom->id[0] = STYLUS_DEVICE_ID;
3bea733a
PC
299 break;
300
301 case 1: /* Rubber */
302 wacom->tool[0] = BTN_TOOL_RUBBER;
e34b9d2f 303 wacom->id[0] = ERASER_DEVICE_ID;
3bea733a
PC
304 break;
305
306 case 2: /* Mouse with wheel */
8da23fc1 307 input_report_key(input, BTN_MIDDLE, data[1] & 0x04);
3bea733a
PC
308 /* fall through */
309
310 case 3: /* Mouse without wheel */
311 wacom->tool[0] = BTN_TOOL_MOUSE;
e34b9d2f 312 wacom->id[0] = CURSOR_DEVICE_ID;
3bea733a 313 break;
3b57ca0f 314 }
3bea733a 315 }
252f7769
DT
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]));
3bea733a 318 if (wacom->tool[0] != BTN_TOOL_MOUSE) {
387142bb
BT
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));
8da23fc1
DT
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);
afb567e3 328 } else {
8da23fc1
DT
329 input_report_key(input, BTN_LEFT, data[1] & 0x01);
330 input_report_key(input, BTN_RIGHT, data[1] & 0x02);
3b57ca0f
PC
331 if (features->type == WACOM_G4 ||
332 features->type == WACOM_MO) {
8da23fc1 333 input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f);
d9f66c1a 334 rw = (data[7] & 0x04) - (data[7] & 0x03);
387142bb
BT
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 }
3b57ca0f 349 } else {
8da23fc1 350 input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f);
d9f66c1a 351 rw = -(signed char)data[6];
3b57ca0f 352 }
8da23fc1 353 input_report_rel(input, REL_WHEEL, rw);
afb567e3 354 }
3b57ca0f
PC
355
356 if (!prox)
357 wacom->id[0] = 0;
8da23fc1
DT
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 */
80d4e8e9 361 }
3bea733a
PC
362
363 /* send pad data */
e33da8a5 364 switch (features->type) {
73a97f4f 365 case WACOM_G4:
3b57ca0f
PC
366 prox = data[7] & 0xf8;
367 if (prox || wacom->id[1]) {
e34b9d2f 368 wacom->id[1] = PAD_DEVICE_ID;
3813810c
BT
369 input_report_key(pad_input, BTN_BACK, (data[7] & 0x40));
370 input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x80));
3bea733a 371 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
3813810c 372 input_report_rel(pad_input, REL_WHEEL, rw);
3b57ca0f
PC
373 if (!prox)
374 wacom->id[1] = 0;
3813810c 375 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
ab687b18 376 retval = 1;
3bea733a 377 }
7ecfbfd3 378 break;
73a97f4f
DT
379
380 case WACOM_MO:
3b57ca0f
PC
381 prox = (data[7] & 0xf8) || data[8];
382 if (prox || wacom->id[1]) {
e34b9d2f 383 wacom->id[1] = PAD_DEVICE_ID;
3813810c
BT
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));
3b57ca0f
PC
389 if (!prox)
390 wacom->id[1] = 0;
3813810c 391 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
84460014 392 retval = 1;
7ecfbfd3
PC
393 }
394 break;
387142bb
BT
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 }
3bea733a 420 }
3b57ca0f
PC
421exit:
422 return retval;
3bea733a
PC
423}
424
95dd3b30 425static int wacom_intuos_inout(struct wacom_wac *wacom)
3bea733a 426{
e33da8a5 427 struct wacom_features *features = &wacom->features;
3bea733a 428 unsigned char *data = wacom->data;
8da23fc1 429 struct input_dev *input = wacom->input;
6f660f12 430 int idx = 0;
3bea733a
PC
431
432 /* tool number */
e33da8a5 433 if (features->type == INTUOS)
6f660f12 434 idx = data[1] & 0x01;
3bea733a
PC
435
436 /* Enter report */
437 if ((data[1] & 0xfc) == 0xc0) {
71348162 438 if (features->quirks & WACOM_QUIRK_MULTI_INPUT)
ae584ca4
JG
439 wacom->shared->stylus_in_proximity = true;
440
3bea733a
PC
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
493630b2
PC
446 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) |
447 ((data[7] & 0x0f) << 20) | ((data[8] & 0xf0) << 12);
73a97f4f 448
f0aaceac 449 switch (wacom->id[idx]) {
73a97f4f
DT
450 case 0x812: /* Inking pen */
451 case 0x801: /* Intuos3 Inking pen */
f0aaceac 452 case 0x120802: /* Intuos4/5 Inking Pen */
73a97f4f
DT
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 */
f0aaceac
PC
463 case 0x802: /* Intuos4/5 13HD/24HD General Pen */
464 case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
73a97f4f 465 case 0x022:
f0aaceac
PC
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 */
c73a1afb 469 case 0x180802: /* DTH2242 Pen */
7d753b0d 470 case 0x100802: /* Intuos4/5 13HD/24HD General Pen */
73a97f4f
DT
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 */
f0aaceac
PC
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 */
c73a1afb 508 case 0x18080a: /* DTH2242 Eraser */
7d753b0d 509 case 0x10080a: /* Intuos4/5 13HD/24HD General Pen Eraser */
73a97f4f
DT
510 wacom->tool[idx] = BTN_TOOL_RUBBER;
511 break;
512
513 case 0xd12:
514 case 0x912:
515 case 0x112:
516 case 0x913: /* Intuos3 Airbrush */
f0aaceac
PC
517 case 0x902: /* Intuos4/5 13HD/24HD Airbrush */
518 case 0x100902: /* Intuos4/5 13HD/24HD Airbrush */
73a97f4f
DT
519 wacom->tool[idx] = BTN_TOOL_AIRBRUSH;
520 break;
521
522 default: /* Unknown tool */
523 wacom->tool[idx] = BTN_TOOL_PEN;
524 break;
3bea733a 525 }
3bea733a
PC
526 return 1;
527 }
528
3a4b4aaa
PC
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
4eb1830b
JG
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);
805a876a
PC
539 if (features->quirks & WACOM_QUIRK_MULTI_INPUT)
540 wacom->shared->stylus_in_proximity = true;
4eb1830b
JG
541 }
542
3bea733a
PC
543 /* Exit report */
544 if ((data[1] & 0xfe) == 0x80) {
71348162 545 if (features->quirks & WACOM_QUIRK_MULTI_INPUT)
ae584ca4
JG
546 wacom->shared->stylus_in_proximity = false;
547
6f660f12
PC
548 /*
549 * Reset all states otherwise we lose the initial states
550 * when in-prox next time
551 */
8da23fc1
DT
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);
80d4e8e9 557 if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
8da23fc1
DT
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);
7ecfbfd3 565 } else {
8da23fc1
DT
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);
e33da8a5 571 if (features->type >= INTUOS3S)
8da23fc1 572 input_report_abs(input, ABS_Z, 0);
8d32e3ae 573 }
8da23fc1
DT
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]);
6f660f12 577 wacom->id[idx] = 0;
80d4e8e9 578 return 2;
3bea733a
PC
579 }
580 return 0;
581}
582
95dd3b30 583static void wacom_intuos_general(struct wacom_wac *wacom)
3bea733a 584{
e33da8a5 585 struct wacom_features *features = &wacom->features;
3bea733a 586 unsigned char *data = wacom->data;
8da23fc1 587 struct input_dev *input = wacom->input;
3bea733a
PC
588 unsigned int t;
589
590 /* general pen packet */
591 if ((data[1] & 0xb8) == 0xa0) {
592 t = (data[6] << 2) | ((data[7] >> 6) & 3);
36d3c510 593 if (features->type >= INTUOS4S && features->type <= CINTIQ_HYBRID) {
6f660f12 594 t = (t << 1) | (data[1] & 1);
ca047fed 595 }
8da23fc1
DT
596 input_report_abs(input, ABS_PRESSURE, t);
597 input_report_abs(input, ABS_TILT_X,
3bea733a 598 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
8da23fc1
DT
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);
3bea733a
PC
603 }
604
605 /* airbrush second packet */
606 if ((data[1] & 0xbc) == 0xb4) {
8da23fc1 607 input_report_abs(input, ABS_WHEEL,
3bea733a 608 (data[6] << 2) | ((data[7] >> 6) & 3));
8da23fc1 609 input_report_abs(input, ABS_TILT_X,
3bea733a 610 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
8da23fc1 611 input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f);
3bea733a 612 }
3bea733a
PC
613}
614
95dd3b30 615static int wacom_intuos_irq(struct wacom_wac *wacom)
3bea733a 616{
e33da8a5 617 struct wacom_features *features = &wacom->features;
3bea733a 618 unsigned char *data = wacom->data;
8da23fc1 619 struct input_dev *input = wacom->input;
3bea733a 620 unsigned int t;
6f660f12 621 int idx = 0, result;
3bea733a 622
eb71d1bb
DT
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]);
3bea733a
PC
630 return 0;
631 }
632
3bea733a 633 /* tool number */
e33da8a5 634 if (features->type == INTUOS)
6f660f12 635 idx = data[1] & 0x01;
3bea733a
PC
636
637 /* pad packets. Works as a second tool and is always in prox */
f860e581 638 if (data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD) {
10059cdc 639 input = wacom->pad_input;
e33da8a5 640 if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
8da23fc1
DT
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));
6f660f12 648 if (data[1] & 0x80) {
8da23fc1 649 input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f));
a8629528
PC
650 } else {
651 /* Out of proximity, clear wheel value. */
8da23fc1 652 input_report_abs(input, ABS_WHEEL, 0);
6f660f12 653 }
e33da8a5 654 if (features->type != INTUOS4S) {
8da23fc1
DT
655 input_report_key(input, BTN_7, (data[3] & 0x40));
656 input_report_key(input, BTN_8, (data[3] & 0x80));
6f660f12
PC
657 }
658 if (data[1] | (data[2] & 0x01) | data[3]) {
8da23fc1 659 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
6f660f12 660 } else {
8da23fc1 661 input_report_abs(input, ABS_MISC, 0);
6f660f12 662 }
a112e9fd
PC
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));
c73a1afb
PC
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 }
56218563
PC
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));
c73a1afb
PC
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 }
803296b6
JG
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]) {
f860e581
JG
734 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
735 } else {
f860e581
JG
736 input_report_abs(input, ABS_MISC, 0);
737 }
36d3c510
JG
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 */
9a35c411 754 } else if (features->type >= INTUOS5S && features->type <= INTUOSPL) {
f860e581
JG
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 /*
9a35c411 761 * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in
f860e581
JG
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
5e056ef4 775 if (data[2] | (data[3] & 0x01) | data[4] | data[5]) {
803296b6
JG
776 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
777 } else {
803296b6
JG
778 input_report_abs(input, ABS_MISC, 0);
779 }
6f660f12 780 } else {
d838c644 781 if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) {
3a4b4aaa
PC
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));
d838c644
PC
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 }
3a4b4aaa
PC
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 }
8da23fc1
DT
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]);
6f660f12 820
493630b2 821 if ((data[5] & 0x1f) | data[6] | (data[1] & 0x1f) |
3a4b4aaa
PC
822 data[2] | (data[3] & 0x1f) | data[4] | data[8] |
823 (data[7] & 0x01)) {
8da23fc1 824 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
6f660f12 825 } else {
8da23fc1 826 input_report_abs(input, ABS_MISC, 0);
6f660f12
PC
827 }
828 }
3bea733a
PC
829 return 1;
830 }
831
832 /* process in/out prox events */
95dd3b30 833 result = wacom_intuos_inout(wacom);
3bea733a 834 if (result)
73a97f4f 835 return result - 1;
3bea733a 836
6f660f12
PC
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 */
e33da8a5
JC
842 if (wacom->tool[idx] == BTN_TOOL_LENS &&
843 (features->type == INTUOS3 ||
844 features->type == INTUOS3S ||
845 features->type == INTUOS4 ||
9fee6195
JG
846 features->type == INTUOS4S ||
847 features->type == INTUOS5 ||
9a35c411
PC
848 features->type == INTUOS5S ||
849 features->type == INTUOSPM ||
850 features->type == INTUOSPS)) {
e33da8a5 851
80d4e8e9 852 return 0;
e33da8a5 853 }
80d4e8e9 854
3bea733a 855 /* Cintiq doesn't send data when RDY bit isn't set */
e33da8a5 856 if (features->type == CINTIQ && !(data[1] & 0x40))
3bea733a
PC
857 return 0;
858
e33da8a5 859 if (features->type >= INTUOS3S) {
8da23fc1
DT
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));
3bea733a 863 } else {
252f7769
DT
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]));
8da23fc1 866 input_report_abs(input, ABS_DISTANCE, ((data[9] >> 3) & 0x1f));
3bea733a
PC
867 }
868
869 /* process general packets */
95dd3b30 870 wacom_intuos_general(wacom);
3bea733a 871
6f660f12
PC
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) {
3bea733a
PC
874
875 if (data[1] & 0x02) {
876 /* Rotation packet */
e33da8a5 877 if (features->type >= INTUOS3S) {
0e1763f5 878 /* I3 marker pen rotation */
3bea733a
PC
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) ;
8da23fc1 882 input_report_abs(input, ABS_Z, t);
3bea733a
PC
883 } else {
884 /* 4D mouse rotation packet */
885 t = (data[6] << 3) | ((data[7] >> 5) & 7);
8da23fc1 886 input_report_abs(input, ABS_RZ, (data[7] & 0x20) ?
3bea733a
PC
887 ((t - 1) / 2) : -t / 2);
888 }
889
e33da8a5 890 } else if (!(data[1] & 0x10) && features->type < INTUOS3S) {
3bea733a 891 /* 4D mouse packet */
8da23fc1
DT
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);
3bea733a 895
8da23fc1
DT
896 input_report_key(input, BTN_SIDE, data[8] & 0x20);
897 input_report_key(input, BTN_EXTRA, data[8] & 0x10);
3bea733a 898 t = (data[6] << 2) | ((data[7] >> 6) & 3);
8da23fc1 899 input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
3bea733a
PC
900
901 } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
6f660f12 902 /* I4 mouse */
9a35c411 903 if (features->type >= INTUOS4S && features->type <= INTUOSPL) {
8da23fc1
DT
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)
6f660f12 908 - ((data[7] & 0x40) >> 6));
8da23fc1
DT
909 input_report_key(input, BTN_SIDE, data[6] & 0x08);
910 input_report_key(input, BTN_EXTRA, data[6] & 0x10);
6f660f12 911
8da23fc1 912 input_report_abs(input, ABS_TILT_X,
6f660f12 913 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
8da23fc1 914 input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f);
6f660f12
PC
915 } else {
916 /* 2D mouse packet */
8da23fc1
DT
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)
3bea733a
PC
921 - ((data[8] & 0x02) >> 1));
922
6f660f12 923 /* I3 2D mouse side buttons */
e33da8a5 924 if (features->type >= INTUOS3S && features->type <= INTUOS3L) {
8da23fc1
DT
925 input_report_key(input, BTN_SIDE, data[8] & 0x40);
926 input_report_key(input, BTN_EXTRA, data[8] & 0x20);
6f660f12 927 }
3bea733a 928 }
e33da8a5 929 } else if ((features->type < INTUOS3S || features->type == INTUOS3L ||
9a35c411
PC
930 features->type == INTUOS4L || features->type == INTUOS5L ||
931 features->type == INTUOSPL) &&
6f660f12 932 wacom->tool[idx] == BTN_TOOL_LENS) {
3bea733a 933 /* Lens cursor packets */
8da23fc1
DT
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);
3bea733a
PC
939 }
940 }
941
8da23fc1
DT
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]);
3bea733a
PC
945 return 1;
946}
947
b1e4279e
JG
948static 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
956static int wacom_24hdt_irq(struct wacom_wac *wacom)
957{
958 struct input_dev *input = wacom->input;
74b63417 959 unsigned char *data = wacom->data;
b1e4279e
JG
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;
02295e68 977 int slot = input_mt_get_slot_by_key(input, data[offset + 1]);
b1e4279e
JG
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) {
edc8e20a
JG
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]);
b1e4279e
JG
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 }
b1e4279e 999 }
b1e4279e
JG
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
1963518b
PC
1009static int wacom_mt_touch(struct wacom_wac *wacom)
1010{
1011 struct input_dev *input = wacom->input;
74b63417 1012 unsigned char *data = wacom->data;
1963518b
PC
1013 int i;
1014 int current_num_contacts = data[2];
1015 int contacts_to_send = 0;
6afdc289
PC
1016 int x_offset = 0;
1017
1018 /* MTTPC does not support Height and Width */
d51ddb2b 1019 if (wacom->features.type == MTTPC || wacom->features.type == MTTPC_B)
6afdc289 1020 x_offset = -4;
1963518b
PC
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++) {
6afdc289 1033 int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset) * i + 3;
1963518b 1034 bool touch = data[offset] & 0x1;
edc8e20a 1035 int id = get_unaligned_le16(&data[offset + 1]);
02295e68 1036 int slot = input_mt_get_slot_by_key(input, id);
1963518b
PC
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) {
edc8e20a
JG
1044 int x = get_unaligned_le16(&data[offset + x_offset + 7]);
1045 int y = get_unaligned_le16(&data[offset + x_offset + 9]);
1963518b
PC
1046 input_report_abs(input, ABS_MT_POSITION_X, x);
1047 input_report_abs(input, ABS_MT_POSITION_Y, y);
1048 }
1963518b 1049 }
1963518b
PC
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
84eb5aa6
PC
1059static 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 }
02295e68 1081 input_mt_report_pointer_emulation(input, true);
84eb5aa6
PC
1082
1083 /* keep touch state for pen event */
1084 wacom->shared->touch_down = (contact_with_no_pen_down_count > 0);
1085
84eb5aa6
PC
1086 return 1;
1087}
1088
a43c7c53 1089static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
ec67bbed 1090{
74b63417 1091 unsigned char *data = wacom->data;
8da23fc1 1092 struct input_dev *input = wacom->input;
a43c7c53
PC
1093 bool prox;
1094 int x = 0, y = 0;
ec67bbed 1095
1963518b
PC
1096 if (wacom->features.touch_max > 1 || len > WACOM_PKGLEN_TPC2FG)
1097 return 0;
1098
a43c7c53
PC
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]);
61616ed0
JG
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]);
ac173837 1108 } else {
a43c7c53
PC
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;
ec67bbed 1116
a43c7c53
PC
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);
73a97f4f 1122
a43c7c53
PC
1123 /* keep touch state for pen events */
1124 wacom->shared->touch_down = prox;
ec67bbed 1125
a43c7c53 1126 return 1;
ec67bbed
PC
1127}
1128
8aa9a9ac 1129static int wacom_tpc_pen(struct wacom_wac *wacom)
545f4e99 1130{
74b63417 1131 unsigned char *data = wacom->data;
8da23fc1 1132 struct input_dev *input = wacom->input;
a43c7c53 1133 bool prox = data[1] & 0x20;
8aa9a9ac 1134
a43c7c53 1135 if (!wacom->shared->stylus_in_proximity) /* first in prox */
8aa9a9ac
PC
1136 /* Going into proximity select tool */
1137 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
8aa9a9ac 1138
a43c7c53
PC
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]));
0b335cad 1148 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x07) << 8) | data[6]);
a43c7c53
PC
1149 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
1150 input_report_key(input, wacom->tool[0], prox);
1151 return 1;
8aa9a9ac 1152 }
8aa9a9ac 1153
a43c7c53 1154 return 0;
8aa9a9ac
PC
1155}
1156
1157static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
1158{
74b63417 1159 unsigned char *data = wacom->data;
545f4e99 1160
eb71d1bb
DT
1161 dev_dbg(wacom->input->dev.parent,
1162 "%s: received report #%d\n", __func__, data[0]);
545f4e99 1163
31175a83
PC
1164 switch (len) {
1165 case WACOM_PKGLEN_TPC1FG:
1963518b 1166 return wacom_tpc_single_touch(wacom, len);
31175a83
PC
1167
1168 case WACOM_PKGLEN_TPC2FG:
1963518b 1169 return wacom_tpc_mt_touch(wacom);
31175a83 1170
d51ddb2b
JG
1171 case WACOM_PKGLEN_PENABLED:
1172 return wacom_tpc_pen(wacom);
1173
31175a83
PC
1174 default:
1175 switch (data[0]) {
1176 case WACOM_REPORT_TPC1FG:
1177 case WACOM_REPORT_TPCHID:
1178 case WACOM_REPORT_TPCST:
ac173837 1179 case WACOM_REPORT_TPC1FGE:
31175a83
PC
1180 return wacom_tpc_single_touch(wacom, len);
1181
1963518b 1182 case WACOM_REPORT_TPCMT:
d51ddb2b 1183 case WACOM_REPORT_TPCMT2:
1963518b
PC
1184 return wacom_mt_touch(wacom);
1185
31175a83
PC
1186 case WACOM_REPORT_PENABLED:
1187 return wacom_tpc_pen(wacom);
1188 }
1189 }
4492efff 1190
8aa9a9ac 1191 return 0;
545f4e99
PC
1192}
1193
e1d38e49 1194static int wacom_bpt_touch(struct wacom_wac *wacom)
cb734c03 1195{
f4ccbef2 1196 struct wacom_features *features = &wacom->features;
cb734c03 1197 struct input_dev *input = wacom->input;
3116871f 1198 struct input_dev *pad_input = wacom->pad_input;
cb734c03 1199 unsigned char *data = wacom->data;
cb734c03
HR
1200 int i;
1201
5a6c865d
CB
1202 if (data[0] != 0x02)
1203 return 0;
1204
cb734c03 1205 for (i = 0; i < 2; i++) {
8f906860
CB
1206 int offset = (data[1] & 0x80) ? (8 * i) : (9 * i);
1207 bool touch = data[offset + 3] & 0x80;
c5f4dec1 1208
33d5f713
CB
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 */
8f906860
CB
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);
c5f4dec1 1219 if (touch) {
8f906860
CB
1220 int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff;
1221 int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff;
f4ccbef2
HR
1222 if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) {
1223 x <<= 5;
1224 y <<= 5;
1225 }
cb734c03
HR
1226 input_report_abs(input, ABS_MT_POSITION_X, x);
1227 input_report_abs(input, ABS_MT_POSITION_Y, y);
cb734c03 1228 }
cb734c03
HR
1229 }
1230
c5f4dec1 1231 input_mt_report_pointer_emulation(input, true);
cb734c03 1232
3116871f
BT
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);
cb734c03 1237
3116871f 1238 return 1;
cb734c03
HR
1239}
1240
73149ab8
CB
1241static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
1242{
9a35c411 1243 struct wacom_features *features = &wacom->features;
73149ab8 1244 struct input_dev *input = wacom->input;
73149ab8 1245 bool touch = data[1] & 0x80;
02295e68
PC
1246 int slot = input_mt_get_slot_by_key(input, data[0]);
1247
1248 if (slot < 0)
1249 return;
73149ab8
CB
1250
1251 touch = touch && !wacom->shared->stylus_in_proximity;
1252
02295e68 1253 input_mt_slot(input, slot);
73149ab8
CB
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);
9a35c411 1259 int width, height;
4e904954 1260
9a35c411 1261 if (features->type >= INTUOSPS && features->type <= INTUOSPL) {
0b279da7
JG
1262 width = data[5] * 100;
1263 height = data[6] * 100;
9a35c411
PC
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 }
73149ab8
CB
1276
1277 input_report_abs(input, ABS_MT_POSITION_X, x);
1278 input_report_abs(input, ABS_MT_POSITION_Y, y);
4e904954
JG
1279 input_report_abs(input, ABS_MT_TOUCH_MAJOR, width);
1280 input_report_abs(input, ABS_MT_TOUCH_MINOR, height);
73149ab8
CB
1281 }
1282}
1283
1284static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
1285{
3116871f 1286 struct input_dev *input = wacom->pad_input;
b5fd2a3e 1287 struct wacom_features *features = &wacom->features;
73149ab8 1288
b5fd2a3e
PC
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 }
73149ab8 1296 input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
73149ab8
CB
1297 input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
1298}
1299
1300static int wacom_bpt3_touch(struct wacom_wac *wacom)
1301{
1302 struct input_dev *input = wacom->input;
1303 unsigned char *data = wacom->data;
19d57d3a 1304 int count = data[1] & 0x07;
73149ab8
CB
1305 int i;
1306
5a6c865d
CB
1307 if (data[0] != 0x02)
1308 return 0;
1309
73149ab8
CB
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 }
73149ab8
CB
1321 input_mt_report_pointer_emulation(input, true);
1322
3116871f 1323 return 1;
73149ab8
CB
1324}
1325
2aaacb15
CB
1326static int wacom_bpt_pen(struct wacom_wac *wacom)
1327{
961794a0 1328 struct wacom_features *features = &wacom->features;
2aaacb15
CB
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
961794a0 1333 if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_USB)
5a6c865d
CB
1334 return 0;
1335
961794a0
PC
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
c5981411 1345 prox = (data[1] & 0x20) == 0x20;
2aaacb15
CB
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]);
c18c2cec
CB
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 */
961794a0
PC
1377 if (data[8] <= features->distance_max)
1378 d = features->distance_max - data[8];
c18c2cec 1379
2aaacb15
CB
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
e1d38e49
CB
1405static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
1406{
1407 if (len == WACOM_PKGLEN_BBTOUCH)
1408 return wacom_bpt_touch(wacom);
73149ab8
CB
1409 else if (len == WACOM_PKGLEN_BBTOUCH3)
1410 return wacom_bpt3_touch(wacom);
1411 else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
2aaacb15 1412 return wacom_bpt_pen(wacom);
e1d38e49
CB
1413
1414 return 0;
1415}
1416
d3825d51
CB
1417static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
1418{
16bf288c
CB
1419 unsigned char *data = wacom->data;
1420 int connected;
1421
b5fd2a3e 1422 if (len != WACOM_PKGLEN_WIRELESS || data[0] != WACOM_REPORT_WL)
d3825d51
CB
1423 return 0;
1424
16bf288c
CB
1425 connected = data[1] & 0x01;
1426 if (connected) {
ac8d1010 1427 int pid, battery, ps_connected;
16bf288c 1428
961794a0
PC
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
16bf288c 1436 pid = get_unaligned_be16(&data[6]);
ac8d1010
BT
1437 battery = (data[5] & 0x3f) * 100 / 31;
1438 ps_connected = !!(data[5] & 0x80);
16bf288c
CB
1439 if (wacom->pid != pid) {
1440 wacom->pid = pid;
1441 wacom_schedule_work(wacom);
1442 }
ac8d1010
BT
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 }
16bf288c
CB
1453 } else if (wacom->pid != 0) {
1454 /* disconnected while previously connected */
1455 wacom->pid = 0;
1456 wacom_schedule_work(wacom);
a1d552cc 1457 wacom->battery_capacity = 0;
ac8d1010
BT
1458 wacom->bat_charging = 0;
1459 wacom->ps_connected = 0;
16bf288c
CB
1460 }
1461
d3825d51
CB
1462 return 0;
1463}
1464
95dd3b30 1465void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
3bea733a 1466{
95dd3b30
DT
1467 bool sync;
1468
e33da8a5 1469 switch (wacom_wac->features.type) {
73a97f4f 1470 case PENPARTNER:
95dd3b30
DT
1471 sync = wacom_penpartner_irq(wacom_wac);
1472 break;
73a97f4f
DT
1473
1474 case PL:
95dd3b30
DT
1475 sync = wacom_pl_irq(wacom_wac);
1476 break;
73a97f4f
DT
1477
1478 case WACOM_G4:
1479 case GRAPHIRE:
387142bb 1480 case GRAPHIRE_BT:
73a97f4f 1481 case WACOM_MO:
95dd3b30
DT
1482 sync = wacom_graphire_irq(wacom_wac);
1483 break;
73a97f4f
DT
1484
1485 case PTU:
95dd3b30
DT
1486 sync = wacom_ptu_irq(wacom_wac);
1487 break;
73a97f4f 1488
c8f2edc5
PC
1489 case DTU:
1490 sync = wacom_dtu_irq(wacom_wac);
1491 break;
1492
497ab1f2
PC
1493 case DTUS:
1494 sync = wacom_dtus_irq(wacom_wac);
1495 break;
1496
73a97f4f
DT
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:
56218563 1506 case WACOM_13HD:
3a4b4aaa 1507 case WACOM_21UX2:
d838c644 1508 case WACOM_22HD:
803296b6 1509 case WACOM_24HD:
a112e9fd 1510 case DTK:
36d3c510 1511 case CINTIQ_HYBRID:
95dd3b30
DT
1512 sync = wacom_intuos_irq(wacom_wac);
1513 break;
73a97f4f 1514
b1e4279e
JG
1515 case WACOM_24HDT:
1516 sync = wacom_24hdt_irq(wacom_wac);
1517 break;
1518
ae584ca4
JG
1519 case INTUOS5S:
1520 case INTUOS5:
1521 case INTUOS5L:
9a35c411
PC
1522 case INTUOSPS:
1523 case INTUOSPM:
1524 case INTUOSPL:
ae584ca4
JG
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
73a97f4f 1531 case TABLETPC:
ac173837 1532 case TABLETPCE:
73a97f4f 1533 case TABLETPC2FG:
1963518b 1534 case MTSCREEN:
6afdc289 1535 case MTTPC:
d51ddb2b 1536 case MTTPC_B:
95dd3b30
DT
1537 sync = wacom_tpc_irq(wacom_wac, len);
1538 break;
73a97f4f 1539
cb734c03 1540 case BAMBOO_PT:
b5fd2a3e 1541 case INTUOSHT:
cb734c03
HR
1542 sync = wacom_bpt_irq(wacom_wac, len);
1543 break;
1544
d3825d51
CB
1545 case WIRELESS:
1546 sync = wacom_wireless_irq(wacom_wac, len);
1547 break;
1548
73a97f4f 1549 default:
95dd3b30
DT
1550 sync = false;
1551 break;
3bea733a 1552 }
95dd3b30 1553
d2d13f18 1554 if (sync) {
95dd3b30 1555 input_sync(wacom_wac->input);
d2d13f18
BT
1556 if (wacom_wac->pad_input)
1557 input_sync(wacom_wac->pad_input);
1558 }
3bea733a
PC
1559}
1560
6521d0bf 1561static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
8da23fc1
DT
1562{
1563 struct input_dev *input_dev = wacom_wac->input;
1564
1565 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
8da23fc1
DT
1566
1567 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1568 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
8da23fc1
DT
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);
8da23fc1
DT
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);
6521d0bf
PC
1580}
1581
1582static 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
8da23fc1
DT
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
bc73dd39
HR
1602void wacom_setup_device_quirks(struct wacom_features *features)
1603{
1604
1605 /* touch device found but size is not defined. use default */
84eb5aa6 1606 if (features->device_type == BTN_TOOL_FINGER && !features->x_max) {
bc73dd39
HR
1607 features->x_max = 1023;
1608 features->y_max = 1023;
1609 }
1610
1611 /* these device have multiple inputs */
ea2e6024 1612 if (features->type >= WIRELESS ||
b5fd2a3e 1613 (features->type >= INTUOS5S && features->type <= INTUOSHT) ||
aea2bf6a 1614 (features->oVid && features->oPid))
bc73dd39 1615 features->quirks |= WACOM_QUIRK_MULTI_INPUT;
cb734c03 1616
73149ab8 1617 /* quirk for bamboo touch with 2 low res touches */
cb734c03 1618 if (features->type == BAMBOO_PT &&
73149ab8 1619 features->pktlen == WACOM_PKGLEN_BBTOUCH) {
f4ccbef2
HR
1620 features->x_max <<= 5;
1621 features->y_max <<= 5;
1622 features->x_fuzz <<= 5;
1623 features->y_fuzz <<= 5;
f4ccbef2 1624 features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;
cb734c03 1625 }
d3825d51
CB
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 */
ac8d1010 1633 if (!features->device_type) {
d3825d51 1634 features->quirks |= WACOM_QUIRK_MONITOR;
ac8d1010
BT
1635 features->quirks |= WACOM_QUIRK_BATTERY;
1636 }
d3825d51 1637 }
bc73dd39
HR
1638}
1639
8c0e0a4f
PC
1640static void wacom_abs_set_axis(struct input_dev *input_dev,
1641 struct wacom_wac *wacom_wac)
3bea733a 1642{
8da23fc1 1643 struct wacom_features *features = &wacom_wac->features;
8da23fc1 1644
e35fb8c1 1645 if (features->device_type == BTN_TOOL_PEN) {
ac414da3
PC
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);
8c0e0a4f
PC
1650 input_set_abs_params(input_dev, ABS_PRESSURE, 0,
1651 features->pressure_max, features->pressure_fuzz, 0);
cfb7d557 1652
e35fb8c1
PC
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 {
8c0e0a4f
PC
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,
401d7d10 1663 features->x_resolution);
8c0e0a4f 1664 input_abs_set_res(input_dev, ABS_Y,
401d7d10 1665 features->y_resolution);
8c0e0a4f
PC
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,
401d7d10 1674 features->x_resolution);
8c0e0a4f 1675 input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
401d7d10 1676 features->y_resolution);
8c0e0a4f 1677 }
e35fb8c1 1678 }
8c0e0a4f 1679}
e35fb8c1 1680
8c0e0a4f
PC
1681int wacom_setup_input_capabilities(struct input_dev *input_dev,
1682 struct wacom_wac *wacom_wac)
1683{
1684 struct wacom_features *features = &wacom_wac->features;
8c0e0a4f
PC
1685
1686 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
1687
1688 __set_bit(BTN_TOUCH, input_dev->keybit);
8da23fc1
DT
1689 __set_bit(ABS_MISC, input_dev->absbit);
1690
8c0e0a4f
PC
1691 wacom_abs_set_axis(input_dev, wacom_wac);
1692
497ab1f2 1693 switch (features->type) {
73a97f4f 1694 case WACOM_MO:
8da23fc1
DT
1695 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
1696 /* fall through */
73a97f4f
DT
1697
1698 case WACOM_G4:
73a97f4f
DT
1699 /* fall through */
1700
1701 case GRAPHIRE:
8da23fc1
DT
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);
3512069e
JG
1713
1714 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
73a97f4f
DT
1715 break;
1716
387142bb
BT
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
803296b6 1738 case WACOM_24HD:
c73a1afb
PC
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);
a112e9fd
PC
1741 /* fall through */
1742
1743 case DTK:
88fd449e
JG
1744 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
1745
803296b6
JG
1746 wacom_setup_cintiq(wacom_wac);
1747 break;
1748
d838c644 1749 case WACOM_22HD:
3a4b4aaa 1750 case WACOM_21UX2:
73a97f4f 1751 case WACOM_BEE:
6521d0bf 1752 case CINTIQ:
6521d0bf 1753 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3512069e
JG
1754
1755 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
1756
6521d0bf
PC
1757 wacom_setup_cintiq(wacom_wac);
1758 break;
1759
56218563 1760 case WACOM_13HD:
56218563
PC
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
73a97f4f
DT
1766 case INTUOS3:
1767 case INTUOS3L:
73a97f4f 1768 case INTUOS3S:
8da23fc1 1769 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
73a97f4f
DT
1770 /* fall through */
1771
1772 case INTUOS:
3512069e
JG
1773 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1774
8da23fc1 1775 wacom_setup_intuos(wacom_wac);
73a97f4f
DT
1776 break;
1777
9fee6195
JG
1778 case INTUOS5:
1779 case INTUOS5L:
9a35c411
PC
1780 case INTUOSPM:
1781 case INTUOSPL:
ae584ca4 1782 case INTUOS5S:
9a35c411 1783 case INTUOSPS:
ae584ca4
JG
1784 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1785
1786 if (features->device_type == BTN_TOOL_PEN) {
ae584ca4
JG
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
ae584ca4 1797 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
4e904954
JG
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);
02295e68 1801 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
ae584ca4
JG
1802 }
1803 break;
1804
73a97f4f
DT
1805 case INTUOS4:
1806 case INTUOS4L:
73a97f4f 1807 case INTUOS4S:
8da23fc1
DT
1808 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
1809 wacom_setup_intuos(wacom_wac);
3512069e
JG
1810
1811 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
73a97f4f
DT
1812 break;
1813
b1e4279e
JG
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
1963518b 1823 case MTSCREEN:
6afdc289 1824 case MTTPC:
d51ddb2b 1825 case MTTPC_B:
6795a524
PC
1826 case TABLETPC2FG:
1827 if (features->device_type == BTN_TOOL_FINGER) {
02295e68
PC
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);
8da23fc1 1834 }
73a97f4f
DT
1835 /* fall through */
1836
1837 case TABLETPC:
ac173837 1838 case TABLETPCE:
a43c7c53
PC
1839 __clear_bit(ABS_MISC, input_dev->absbit);
1840
3512069e
JG
1841 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
1842
e35fb8c1 1843 if (features->device_type != BTN_TOOL_PEN)
73a97f4f 1844 break; /* no need to process stylus stuff */
e35fb8c1 1845
73a97f4f
DT
1846 /* fall through */
1847
497ab1f2 1848 case DTUS:
73a97f4f 1849 case PL:
c8f2edc5 1850 case DTU:
8da23fc1 1851 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3512069e 1852 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
8da23fc1
DT
1853 __set_bit(BTN_STYLUS, input_dev->keybit);
1854 __set_bit(BTN_STYLUS2, input_dev->keybit);
3512069e
JG
1855
1856 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
1857 break;
1858
1859 case PTU:
8da23fc1 1860 __set_bit(BTN_STYLUS2, input_dev->keybit);
73a97f4f
DT
1861 /* fall through */
1862
1863 case PENPARTNER:
1fab84aa 1864 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
8da23fc1 1865 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1fab84aa 1866 __set_bit(BTN_STYLUS, input_dev->keybit);
3512069e
JG
1867
1868 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
73a97f4f 1869 break;
cb734c03 1870
b5fd2a3e 1871 case INTUOSHT:
961794a0
PC
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
cb734c03
HR
1879 case BAMBOO_PT:
1880 __clear_bit(ABS_MISC, input_dev->absbit);
1881
8b4a0c1f 1882 if (features->device_type == BTN_TOOL_FINGER) {
02295e68 1883
b5fd2a3e
PC
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,
73149ab8 1891 ABS_MT_TOUCH_MAJOR,
4e904954 1892 0, features->x_max, 0, 0);
b5fd2a3e 1893 input_set_abs_params(input_dev,
4e904954
JG
1894 ABS_MT_TOUCH_MINOR,
1895 0, features->y_max, 0, 0);
b5fd2a3e
PC
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);
02295e68 1902 } else {
b5fd2a3e
PC
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);
73149ab8 1907 }
2aaacb15 1908 } else if (features->device_type == BTN_TOOL_PEN) {
b5fd2a3e 1909 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
2aaacb15
CB
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);
c18c2cec
CB
1914 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
1915 features->distance_max,
1916 0, 0);
cb734c03
HR
1917 }
1918 break;
36d3c510
JG
1919
1920 case CINTIQ_HYBRID:
36d3c510
JG
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;
3bea733a 1926 }
1963518b 1927 return 0;
3bea733a
PC
1928}
1929
d2d13f18
BT
1930int 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;
10059cdc 1934 int i;
d2d13f18
BT
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) {
387142bb
BT
1946 case GRAPHIRE_BT:
1947 __set_bit(BTN_0, input_dev->keybit);
1948 __set_bit(BTN_1, input_dev->keybit);
1949 break;
1950
3813810c
BT
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
10059cdc
BT
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
422b0314
BT
2087 case DTUS:
2088 for (i = 0; i < 4; i++)
2089 __set_bit(BTN_0 + i, input_dev->keybit);
2090 break;
2091
3116871f
BT
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
d2d13f18
BT
2107 default:
2108 /* no pad supported */
2109 return 1;
2110 }
2111 return 0;
2112}
2113
e87a344d 2114static const struct wacom_features wacom_features_0x00 =
80befa93
BT
2115 { "Wacom Penpartner", 5040, 3780, 255, 0,
2116 PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
e87a344d 2117static const struct wacom_features wacom_features_0x10 =
80befa93
BT
2118 { "Wacom Graphire", 10206, 7422, 511, 63,
2119 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
387142bb
BT
2120static const struct wacom_features wacom_features_0x81 =
2121 { "Wacom Graphire BT", 16704, 12064, 511, 32,
2122 GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
e87a344d 2123static const struct wacom_features wacom_features_0x11 =
80befa93
BT
2124 { "Wacom Graphire2 4x5", 10206, 7422, 511, 63,
2125 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
e87a344d 2126static const struct wacom_features wacom_features_0x12 =
80befa93
BT
2127 { "Wacom Graphire2 5x7", 13918, 10206, 511, 63,
2128 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
e87a344d 2129static const struct wacom_features wacom_features_0x13 =
80befa93
BT
2130 { "Wacom Graphire3", 10208, 7424, 511, 63,
2131 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
e87a344d 2132static const struct wacom_features wacom_features_0x14 =
80befa93
BT
2133 { "Wacom Graphire3 6x8", 16704, 12064, 511, 63,
2134 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
e87a344d 2135static const struct wacom_features wacom_features_0x15 =
80befa93
BT
2136 { "Wacom Graphire4 4x5", 10208, 7424, 511, 63,
2137 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
e87a344d 2138static const struct wacom_features wacom_features_0x16 =
80befa93
BT
2139 { "Wacom Graphire4 6x8", 16704, 12064, 511, 63,
2140 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
e87a344d 2141static const struct wacom_features wacom_features_0x17 =
80befa93
BT
2142 { "Wacom BambooFun 4x5", 14760, 9225, 511, 63,
2143 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 2144static const struct wacom_features wacom_features_0x18 =
80befa93
BT
2145 { "Wacom BambooFun 6x8", 21648, 13530, 511, 63,
2146 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 2147static const struct wacom_features wacom_features_0x19 =
80befa93
BT
2148 { "Wacom Bamboo1 Medium", 16704, 12064, 511, 63,
2149 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
e87a344d 2150static const struct wacom_features wacom_features_0x60 =
80befa93
BT
2151 { "Wacom Volito", 5104, 3712, 511, 63,
2152 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
e87a344d 2153static const struct wacom_features wacom_features_0x61 =
80befa93
BT
2154 { "Wacom PenStation2", 3250, 2320, 255, 63,
2155 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
e87a344d 2156static const struct wacom_features wacom_features_0x62 =
80befa93
BT
2157 { "Wacom Volito2 4x5", 5104, 3712, 511, 63,
2158 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
e87a344d 2159static const struct wacom_features wacom_features_0x63 =
80befa93
BT
2160 { "Wacom Volito2 2x3", 3248, 2320, 511, 63,
2161 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
e87a344d 2162static const struct wacom_features wacom_features_0x64 =
80befa93
BT
2163 { "Wacom PenPartner2", 3250, 2320, 511, 63,
2164 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
e87a344d 2165static const struct wacom_features wacom_features_0x65 =
80befa93
BT
2166 { "Wacom Bamboo", 14760, 9225, 511, 63,
2167 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 2168static const struct wacom_features wacom_features_0x69 =
80befa93
BT
2169 { "Wacom Bamboo1", 5104, 3712, 511, 63,
2170 GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
11d0cf88 2171static const struct wacom_features wacom_features_0x6A =
80befa93
BT
2172 { "Wacom Bamboo1 4x6", 14760, 9225, 1023, 63,
2173 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
11d0cf88 2174static const struct wacom_features wacom_features_0x6B =
80befa93
BT
2175 { "Wacom Bamboo1 5x8", 21648, 13530, 1023, 63,
2176 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 2177static const struct wacom_features wacom_features_0x20 =
80befa93
BT
2178 { "Wacom Intuos 4x5", 12700, 10600, 1023, 31,
2179 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 2180static const struct wacom_features wacom_features_0x21 =
80befa93
BT
2181 { "Wacom Intuos 6x8", 20320, 16240, 1023, 31,
2182 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 2183static const struct wacom_features wacom_features_0x22 =
80befa93
BT
2184 { "Wacom Intuos 9x12", 30480, 24060, 1023, 31,
2185 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 2186static const struct wacom_features wacom_features_0x23 =
80befa93
BT
2187 { "Wacom Intuos 12x12", 30480, 31680, 1023, 31,
2188 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 2189static const struct wacom_features wacom_features_0x24 =
80befa93
BT
2190 { "Wacom Intuos 12x18", 45720, 31680, 1023, 31,
2191 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 2192static const struct wacom_features wacom_features_0x30 =
80befa93
BT
2193 { "Wacom PL400", 5408, 4056, 255, 0,
2194 PL, WACOM_PL_RES, WACOM_PL_RES };
e87a344d 2195static const struct wacom_features wacom_features_0x31 =
80befa93
BT
2196 { "Wacom PL500", 6144, 4608, 255, 0,
2197 PL, WACOM_PL_RES, WACOM_PL_RES };
e87a344d 2198static const struct wacom_features wacom_features_0x32 =
80befa93
BT
2199 { "Wacom PL600", 6126, 4604, 255, 0,
2200 PL, WACOM_PL_RES, WACOM_PL_RES };
e87a344d 2201static const struct wacom_features wacom_features_0x33 =
80befa93
BT
2202 { "Wacom PL600SX", 6260, 5016, 255, 0,
2203 PL, WACOM_PL_RES, WACOM_PL_RES };
e87a344d 2204static const struct wacom_features wacom_features_0x34 =
80befa93
BT
2205 { "Wacom PL550", 6144, 4608, 511, 0,
2206 PL, WACOM_PL_RES, WACOM_PL_RES };
e87a344d 2207static const struct wacom_features wacom_features_0x35 =
80befa93
BT
2208 { "Wacom PL800", 7220, 5780, 511, 0,
2209 PL, WACOM_PL_RES, WACOM_PL_RES };
e87a344d 2210static const struct wacom_features wacom_features_0x37 =
80befa93
BT
2211 { "Wacom PL700", 6758, 5406, 511, 0,
2212 PL, WACOM_PL_RES, WACOM_PL_RES };
e87a344d 2213static const struct wacom_features wacom_features_0x38 =
80befa93
BT
2214 { "Wacom PL510", 6282, 4762, 511, 0,
2215 PL, WACOM_PL_RES, WACOM_PL_RES };
e87a344d 2216static const struct wacom_features wacom_features_0x39 =
80befa93
BT
2217 { "Wacom DTU710", 34080, 27660, 511, 0,
2218 PL, WACOM_PL_RES, WACOM_PL_RES };
e87a344d 2219static const struct wacom_features wacom_features_0xC4 =
80befa93
BT
2220 { "Wacom DTF521", 6282, 4762, 511, 0,
2221 PL, WACOM_PL_RES, WACOM_PL_RES };
e87a344d 2222static const struct wacom_features wacom_features_0xC0 =
80befa93
BT
2223 { "Wacom DTF720", 6858, 5506, 511, 0,
2224 PL, WACOM_PL_RES, WACOM_PL_RES };
e87a344d 2225static const struct wacom_features wacom_features_0xC2 =
80befa93
BT
2226 { "Wacom DTF720a", 6858, 5506, 511, 0,
2227 PL, WACOM_PL_RES, WACOM_PL_RES };
e87a344d 2228static const struct wacom_features wacom_features_0x03 =
80befa93
BT
2229 { "Wacom Cintiq Partner", 20480, 15360, 511, 0,
2230 PTU, WACOM_PL_RES, WACOM_PL_RES };
e87a344d 2231static const struct wacom_features wacom_features_0x41 =
80befa93
BT
2232 { "Wacom Intuos2 4x5", 12700, 10600, 1023, 31,
2233 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 2234static const struct wacom_features wacom_features_0x42 =
80befa93
BT
2235 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
2236 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 2237static const struct wacom_features wacom_features_0x43 =
80befa93
BT
2238 { "Wacom Intuos2 9x12", 30480, 24060, 1023, 31,
2239 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 2240static const struct wacom_features wacom_features_0x44 =
80befa93
BT
2241 { "Wacom Intuos2 12x12", 30480, 31680, 1023, 31,
2242 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 2243static const struct wacom_features wacom_features_0x45 =
80befa93
BT
2244 { "Wacom Intuos2 12x18", 45720, 31680, 1023, 31,
2245 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 2246static const struct wacom_features wacom_features_0xB0 =
80befa93
BT
2247 { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63,
2248 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
e87a344d 2249static const struct wacom_features wacom_features_0xB1 =
80befa93
BT
2250 { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63,
2251 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
e87a344d 2252static const struct wacom_features wacom_features_0xB2 =
80befa93
BT
2253 { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63,
2254 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
e87a344d 2255static const struct wacom_features wacom_features_0xB3 =
80befa93
BT
2256 { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63,
2257 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
e87a344d 2258static const struct wacom_features wacom_features_0xB4 =
80befa93
BT
2259 { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63,
2260 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
e87a344d 2261static const struct wacom_features wacom_features_0xB5 =
80befa93
BT
2262 { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63,
2263 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
e87a344d 2264static const struct wacom_features wacom_features_0xB7 =
80befa93
BT
2265 { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63,
2266 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
e87a344d 2267static const struct wacom_features wacom_features_0xB8 =
80befa93
BT
2268 { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63,
2269 INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
e87a344d 2270static const struct wacom_features wacom_features_0xB9 =
80befa93
BT
2271 { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63,
2272 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
e87a344d 2273static const struct wacom_features wacom_features_0xBA =
80befa93
BT
2274 { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63,
2275 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
e87a344d 2276static const struct wacom_features wacom_features_0xBB =
80befa93
BT
2277 { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63,
2278 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
3a4b4aaa 2279static const struct wacom_features wacom_features_0xBC =
80befa93
BT
2280 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
2281 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
9fee6195 2282static const struct wacom_features wacom_features_0x26 =
80befa93
BT
2283 { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63,
2284 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16 };
9fee6195 2285static const struct wacom_features wacom_features_0x27 =
80befa93
BT
2286 { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63,
2287 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16 };
9fee6195 2288static const struct wacom_features wacom_features_0x28 =
80befa93
BT
2289 { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63,
2290 INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16 };
9fee6195 2291static const struct wacom_features wacom_features_0x29 =
80befa93
BT
2292 { "Wacom Intuos5 S", 31496, 19685, 2047, 63,
2293 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
9fee6195 2294static const struct wacom_features wacom_features_0x2A =
80befa93
BT
2295 { "Wacom Intuos5 M", 44704, 27940, 2047, 63,
2296 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
9a35c411 2297static const struct wacom_features wacom_features_0x314 =
80befa93
BT
2298 { "Wacom Intuos Pro S", 31496, 19685, 2047, 63,
2299 INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16,
29b47391 2300 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
9a35c411 2301static const struct wacom_features wacom_features_0x315 =
80befa93
BT
2302 { "Wacom Intuos Pro M", 44704, 27940, 2047, 63,
2303 INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16,
29b47391 2304 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
9a35c411 2305static const struct wacom_features wacom_features_0x317 =
80befa93
BT
2306 { "Wacom Intuos Pro L", 65024, 40640, 2047, 63,
2307 INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16,
29b47391 2308 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
803296b6 2309static const struct wacom_features wacom_features_0xF4 =
80befa93
BT
2310 { "Wacom Cintiq 24HD", 104280, 65400, 2047, 63,
2311 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
6f4d0382 2312static const struct wacom_features wacom_features_0xF8 =
80befa93
BT
2313 { "Wacom Cintiq 24HD touch", 104280, 65400, 2047, 63, /* Pen */
2314 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
3bd1f7e2 2315 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 };
b1e4279e
JG
2316static const struct wacom_features wacom_features_0xF6 =
2317 { "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */
29b47391
BT
2318 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10,
2319 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
e87a344d 2320static const struct wacom_features wacom_features_0x3F =
80befa93
BT
2321 { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63,
2322 CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
e87a344d 2323static const struct wacom_features wacom_features_0xC5 =
80befa93
BT
2324 { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63,
2325 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
e87a344d 2326static const struct wacom_features wacom_features_0xC6 =
80befa93
BT
2327 { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63,
2328 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
56218563 2329static const struct wacom_features wacom_features_0x304 =
80befa93
BT
2330 { "Wacom Cintiq 13HD", 59352, 33648, 1023, 63,
2331 WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
e87a344d 2332static const struct wacom_features wacom_features_0xC7 =
80befa93
BT
2333 { "Wacom DTU1931", 37832, 30305, 511, 0,
2334 PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
c8f2edc5 2335static const struct wacom_features wacom_features_0xCE =
80befa93
BT
2336 { "Wacom DTU2231", 47864, 27011, 511, 0,
2337 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
29b47391 2338 .check_for_hid_type = true, .hid_type = HID_TYPE_USBMOUSE };
c8f2edc5 2339static const struct wacom_features wacom_features_0xF0 =
80befa93
BT
2340 { "Wacom DTU1631", 34623, 19553, 511, 0,
2341 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
497ab1f2 2342static const struct wacom_features wacom_features_0xFB =
80befa93
BT
2343 { "Wacom DTU1031", 22096, 13960, 511, 0,
2344 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
56218563 2345static const struct wacom_features wacom_features_0x57 =
80befa93
BT
2346 { "Wacom DTK2241", 95640, 54060, 2047, 63,
2347 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
a112e9fd 2348static const struct wacom_features wacom_features_0x59 = /* Pen */
80befa93
BT
2349 { "Wacom DTH2242", 95640, 54060, 2047, 63,
2350 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
a112e9fd
PC
2351 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D };
2352static const struct wacom_features wacom_features_0x5D = /* Touch */
2353 { "Wacom DTH2242", .type = WACOM_24HDT,
29b47391
BT
2354 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10,
2355 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
3a4b4aaa 2356static const struct wacom_features wacom_features_0xCC =
80befa93
BT
2357 { "Wacom Cintiq 21UX2", 87000, 65400, 2047, 63,
2358 WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
d838c644 2359static const struct wacom_features wacom_features_0xFA =
80befa93
BT
2360 { "Wacom Cintiq 22HD", 95640, 54060, 2047, 63,
2361 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
56218563 2362static const struct wacom_features wacom_features_0x5B =
80befa93
BT
2363 { "Wacom Cintiq 22HDT", 95640, 54060, 2047, 63,
2364 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
3bd1f7e2 2365 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e };
56218563
PC
2366static const struct wacom_features wacom_features_0x5E =
2367 { "Wacom Cintiq 22HDT", .type = WACOM_24HDT,
29b47391
BT
2368 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5b, .touch_max = 10,
2369 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
e87a344d 2370static const struct wacom_features wacom_features_0x90 =
80befa93
BT
2371 { "Wacom ISDv4 90", 26202, 16325, 255, 0,
2372 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 2373static const struct wacom_features wacom_features_0x93 =
80befa93
BT
2374 { "Wacom ISDv4 93", 26202, 16325, 255, 0,
2375 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
11d0cf88 2376static const struct wacom_features wacom_features_0x97 =
80befa93
BT
2377 { "Wacom ISDv4 97", 26202, 16325, 511, 0,
2378 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 2379static const struct wacom_features wacom_features_0x9A =
80befa93
BT
2380 { "Wacom ISDv4 9A", 26202, 16325, 255, 0,
2381 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 2382static const struct wacom_features wacom_features_0x9F =
80befa93
BT
2383 { "Wacom ISDv4 9F", 26202, 16325, 255, 0,
2384 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 2385static const struct wacom_features wacom_features_0xE2 =
80befa93
BT
2386 { "Wacom ISDv4 E2", 26202, 16325, 255, 0,
2387 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
e87a344d 2388static const struct wacom_features wacom_features_0xE3 =
80befa93
BT
2389 { "Wacom ISDv4 E3", 26202, 16325, 255, 0,
2390 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
1963518b 2391static const struct wacom_features wacom_features_0xE5 =
80befa93
BT
2392 { "Wacom ISDv4 E5", 26202, 16325, 255, 0,
2393 MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
26fcd2a7 2394static const struct wacom_features wacom_features_0xE6 =
80befa93
BT
2395 { "Wacom ISDv4 E6", 27760, 15694, 255, 0,
2396 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
0d0e3064 2397static const struct wacom_features wacom_features_0xEC =
80befa93
BT
2398 { "Wacom ISDv4 EC", 25710, 14500, 255, 0,
2399 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
ac173837 2400static const struct wacom_features wacom_features_0xED =
80befa93
BT
2401 { "Wacom ISDv4 ED", 26202, 16325, 255, 0,
2402 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
ac173837 2403static const struct wacom_features wacom_features_0xEF =
80befa93
BT
2404 { "Wacom ISDv4 EF", 26202, 16325, 255, 0,
2405 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
6afdc289 2406static const struct wacom_features wacom_features_0x100 =
80befa93
BT
2407 { "Wacom ISDv4 100", 26202, 16325, 255, 0,
2408 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
6afdc289 2409static const struct wacom_features wacom_features_0x101 =
80befa93
BT
2410 { "Wacom ISDv4 101", 26202, 16325, 255, 0,
2411 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
58694837 2412static const struct wacom_features wacom_features_0x10D =
80befa93
BT
2413 { "Wacom ISDv4 10D", 26202, 16325, 255, 0,
2414 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2d3163f1 2415static const struct wacom_features wacom_features_0x10E =
80befa93
BT
2416 { "Wacom ISDv4 10E", 27760, 15694, 255, 0,
2417 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
9b4f60e5 2418static const struct wacom_features wacom_features_0x10F =
80befa93
BT
2419 { "Wacom ISDv4 10F", 27760, 15694, 255, 0,
2420 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
61616ed0 2421static const struct wacom_features wacom_features_0x116 =
80befa93
BT
2422 { "Wacom ISDv4 116", 26202, 16325, 255, 0,
2423 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
aeaf50d4
JG
2424static const struct wacom_features wacom_features_0x12C =
2425 { "Wacom ISDv4 12C", 27848, 15752, 2047, 0,
2426 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
edbe265d 2427static const struct wacom_features wacom_features_0x4001 =
80befa93
BT
2428 { "Wacom ISDv4 4001", 26202, 16325, 255, 0,
2429 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
d51ddb2b 2430static const struct wacom_features wacom_features_0x4004 =
80befa93
BT
2431 { "Wacom ISDv4 4004", 11060, 6220, 255, 0,
2432 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
d51ddb2b 2433static const struct wacom_features wacom_features_0x5000 =
80befa93
BT
2434 { "Wacom ISDv4 5000", 27848, 15752, 1023, 0,
2435 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
d51ddb2b 2436static const struct wacom_features wacom_features_0x5002 =
80befa93
BT
2437 { "Wacom ISDv4 5002", 29576, 16724, 1023, 0,
2438 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 2439static const struct wacom_features wacom_features_0x47 =
80befa93
BT
2440 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
2441 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
d3825d51 2442static const struct wacom_features wacom_features_0x84 =
80befa93
BT
2443 { "Wacom Wireless Receiver", 0, 0, 0, 0,
2444 WIRELESS, 0, 0, .touch_max = 16 };
7b824bbd 2445static const struct wacom_features wacom_features_0xD0 =
80befa93
BT
2446 { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31,
2447 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
7b824bbd 2448static const struct wacom_features wacom_features_0xD1 =
80befa93
BT
2449 { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31,
2450 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
7b824bbd 2451static const struct wacom_features wacom_features_0xD2 =
80befa93
BT
2452 { "Wacom Bamboo Craft", 14720, 9200, 1023, 31,
2453 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
7b824bbd 2454static const struct wacom_features wacom_features_0xD3 =
80befa93
BT
2455 { "Wacom Bamboo 2FG 6x8", 21648, 13700, 1023, 31,
2456 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
57a7872f 2457static const struct wacom_features wacom_features_0xD4 =
80befa93
BT
2458 { "Wacom Bamboo Pen", 14720, 9200, 1023, 31,
2459 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
18adad1c 2460static const struct wacom_features wacom_features_0xD5 =
80befa93
BT
2461 { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31,
2462 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
7b824bbd 2463static const struct wacom_features wacom_features_0xD6 =
80befa93
BT
2464 { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31,
2465 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
7b824bbd 2466static const struct wacom_features wacom_features_0xD7 =
80befa93
BT
2467 { "Wacom BambooPT 2FG Small", 14720, 9200, 1023, 31,
2468 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
7b824bbd 2469static const struct wacom_features wacom_features_0xD8 =
80befa93
BT
2470 { "Wacom Bamboo Comic 2FG", 21648, 13700, 1023, 31,
2471 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
7b824bbd 2472static const struct wacom_features wacom_features_0xDA =
80befa93
BT
2473 { "Wacom Bamboo 2FG 4x5 SE", 14720, 9200, 1023, 31,
2474 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
f41a64ee 2475static const struct wacom_features wacom_features_0xDB =
80befa93
BT
2476 { "Wacom Bamboo 2FG 6x8 SE", 21648, 13700, 1023, 31,
2477 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
73149ab8 2478static const struct wacom_features wacom_features_0xDD =
80befa93
BT
2479 { "Wacom Bamboo Connect", 14720, 9200, 1023, 31,
2480 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
73149ab8 2481static const struct wacom_features wacom_features_0xDE =
80befa93
BT
2482 { "Wacom Bamboo 16FG 4x5", 14720, 9200, 1023, 31,
2483 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
73149ab8 2484static const struct wacom_features wacom_features_0xDF =
80befa93
BT
2485 { "Wacom Bamboo 16FG 6x8", 21648, 13700, 1023, 31,
2486 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
f41a64ee 2487static const struct wacom_features wacom_features_0x300 =
80befa93
BT
2488 { "Wacom Bamboo One S", 14720, 9225, 1023, 31,
2489 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
f41a64ee 2490static const struct wacom_features wacom_features_0x301 =
80befa93
BT
2491 { "Wacom Bamboo One M", 21648, 13530, 1023, 31,
2492 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
b5fd2a3e 2493static const struct wacom_features wacom_features_0x302 =
80befa93
BT
2494 { "Wacom Intuos PT S", 15200, 9500, 1023, 31,
2495 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
29b47391 2496 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
b5fd2a3e 2497static const struct wacom_features wacom_features_0x303 =
80befa93
BT
2498 { "Wacom Intuos PT M", 21600, 13500, 1023, 31,
2499 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
29b47391 2500 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
b5fd2a3e 2501static const struct wacom_features wacom_features_0x30E =
80befa93
BT
2502 { "Wacom Intuos S", 15200, 9500, 1023, 31,
2503 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
29b47391 2504 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
7b4b3068 2505static const struct wacom_features wacom_features_0x6004 =
80befa93
BT
2506 { "ISD-V4", 12800, 8000, 255, 0,
2507 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
a3e6f654 2508static const struct wacom_features wacom_features_0x307 =
80befa93
BT
2509 { "Wacom ISDv5 307", 59352, 33648, 2047, 63,
2510 CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
36d3c510 2511 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 };
a3e6f654 2512static const struct wacom_features wacom_features_0x309 =
36d3c510 2513 { "Wacom ISDv5 309", .type = WACOM_24HDT, /* Touch */
29b47391
BT
2514 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x0307, .touch_max = 10,
2515 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
b036f6fb 2516
29b47391
BT
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
1483f551 2520
387142bb
BT
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
7b4b3068 2525#define USB_DEVICE_LENOVO(prod) \
29b47391
BT
2526 HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
2527 .driver_data = (kernel_ulong_t)&wacom_features_##prod
7b4b3068 2528
29b47391 2529const struct hid_device_id wacom_ids[] = {
b036f6fb 2530 { USB_DEVICE_WACOM(0x00) },
a3e6f654 2531 { USB_DEVICE_WACOM(0x03) },
b036f6fb
BB
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) },
b036f6fb
BB
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) },
a3e6f654
BT
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) },
b036f6fb
BB
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) },
a3e6f654 2561 { USB_DEVICE_WACOM(0x3F) },
b036f6fb
BB
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) },
a3e6f654 2567 { USB_DEVICE_WACOM(0x47) },
56218563 2568 { USB_DEVICE_WACOM(0x57) },
a112e9fd 2569 { USB_DEVICE_WACOM(0x59) },
56218563 2570 { USB_DEVICE_WACOM(0x5B) },
a3e6f654 2571 { USB_DEVICE_WACOM(0x5D) },
29b47391 2572 { USB_DEVICE_WACOM(0x5E) },
a3e6f654
BT
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) },
387142bb 2582 { BT_DEVICE_WACOM(0x81) },
a3e6f654
BT
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) },
b036f6fb
BB
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) },
3a4b4aaa 2600 { USB_DEVICE_WACOM(0xBC) },
a3e6f654
BT
2601 { USB_DEVICE_WACOM(0xC0) },
2602 { USB_DEVICE_WACOM(0xC2) },
2603 { USB_DEVICE_WACOM(0xC4) },
b036f6fb
BB
2604 { USB_DEVICE_WACOM(0xC5) },
2605 { USB_DEVICE_WACOM(0xC6) },
2606 { USB_DEVICE_WACOM(0xC7) },
a3e6f654 2607 { USB_DEVICE_WACOM(0xCC) },
29b47391 2608 { USB_DEVICE_WACOM(0xCE) },
cb734c03 2609 { USB_DEVICE_WACOM(0xD0) },
2aaacb15
CB
2610 { USB_DEVICE_WACOM(0xD1) },
2611 { USB_DEVICE_WACOM(0xD2) },
2612 { USB_DEVICE_WACOM(0xD3) },
57a7872f 2613 { USB_DEVICE_WACOM(0xD4) },
18adad1c 2614 { USB_DEVICE_WACOM(0xD5) },
d38acb49
PC
2615 { USB_DEVICE_WACOM(0xD6) },
2616 { USB_DEVICE_WACOM(0xD7) },
a318e6b1
DF
2617 { USB_DEVICE_WACOM(0xD8) },
2618 { USB_DEVICE_WACOM(0xDA) },
47d09235 2619 { USB_DEVICE_WACOM(0xDB) },
73149ab8
CB
2620 { USB_DEVICE_WACOM(0xDD) },
2621 { USB_DEVICE_WACOM(0xDE) },
2622 { USB_DEVICE_WACOM(0xDF) },
b036f6fb
BB
2623 { USB_DEVICE_WACOM(0xE2) },
2624 { USB_DEVICE_WACOM(0xE3) },
1963518b 2625 { USB_DEVICE_WACOM(0xE5) },
26fcd2a7 2626 { USB_DEVICE_WACOM(0xE6) },
0d0e3064 2627 { USB_DEVICE_WACOM(0xEC) },
ac173837
PC
2628 { USB_DEVICE_WACOM(0xED) },
2629 { USB_DEVICE_WACOM(0xEF) },
a3e6f654
BT
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) },
6afdc289
PC
2636 { USB_DEVICE_WACOM(0x100) },
2637 { USB_DEVICE_WACOM(0x101) },
58694837 2638 { USB_DEVICE_WACOM(0x10D) },
2d3163f1 2639 { USB_DEVICE_WACOM(0x10E) },
9b4f60e5 2640 { USB_DEVICE_WACOM(0x10F) },
61616ed0 2641 { USB_DEVICE_WACOM(0x116) },
aeaf50d4 2642 { USB_DEVICE_WACOM(0x12C) },
f41a64ee
PC
2643 { USB_DEVICE_WACOM(0x300) },
2644 { USB_DEVICE_WACOM(0x301) },
29b47391
BT
2645 { USB_DEVICE_WACOM(0x302) },
2646 { USB_DEVICE_WACOM(0x303) },
56218563 2647 { USB_DEVICE_WACOM(0x304) },
a3e6f654
BT
2648 { USB_DEVICE_WACOM(0x307) },
2649 { USB_DEVICE_WACOM(0x309) },
2650 { USB_DEVICE_WACOM(0x30E) },
29b47391
BT
2651 { USB_DEVICE_WACOM(0x314) },
2652 { USB_DEVICE_WACOM(0x315) },
2653 { USB_DEVICE_WACOM(0x317) },
edbe265d 2654 { USB_DEVICE_WACOM(0x4001) },
d51ddb2b
JG
2655 { USB_DEVICE_WACOM(0x4004) },
2656 { USB_DEVICE_WACOM(0x5000) },
2657 { USB_DEVICE_WACOM(0x5002) },
3bea733a
PC
2658 { }
2659};
29b47391 2660MODULE_DEVICE_TABLE(hid, wacom_ids);