HID: wacom: Move Intuos pad handling code into dedicated function
[linux-block.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>
3bea733a 18
e35fb8c1
PC
19/* resolution for penabled devices */
20#define WACOM_PL_RES 20
21#define WACOM_PENPRTN_RES 40
22#define WACOM_VOLITO_RES 50
23#define WACOM_GRAPHIRE_RES 80
24#define WACOM_INTUOS_RES 100
25#define WACOM_INTUOS3_RES 200
26
fa770340
PC
27/* Newer Cintiq and DTU have an offset between tablet and screen areas */
28#define WACOM_DTU_OFFSET 200
29#define WACOM_CINTIQ_OFFSET 400
30
387142bb
BT
31/*
32 * Scale factor relating reported contact size to logical contact area.
4e904954
JG
33 * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo
34 */
35#define WACOM_CONTACT_AREA_SCALE 2607
36
387142bb
BT
37/*
38 * Percent of battery capacity for Graphire.
39 * 8th value means AC online and show 100% capacity.
40 */
41static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
42
81af7e61
BT
43/*
44 * Percent of battery capacity for Intuos4 WL, AC has a separate bit.
45 */
46static unsigned short batcap_i4[8] = { 1, 15, 30, 45, 60, 70, 85, 100 };
47
953f2c5f 48static void wacom_notify_battery(struct wacom_wac *wacom_wac,
71fa641e
JG
49 int bat_capacity, bool bat_charging, bool bat_connected,
50 bool ps_connected)
953f2c5f
JG
51{
52 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
53 bool changed = wacom_wac->battery_capacity != bat_capacity ||
54 wacom_wac->bat_charging != bat_charging ||
71fa641e 55 wacom_wac->bat_connected != bat_connected ||
953f2c5f
JG
56 wacom_wac->ps_connected != ps_connected;
57
58 if (changed) {
59 wacom_wac->battery_capacity = bat_capacity;
60 wacom_wac->bat_charging = bat_charging;
71fa641e 61 wacom_wac->bat_connected = bat_connected;
953f2c5f
JG
62 wacom_wac->ps_connected = ps_connected;
63
8de29a35
LT
64 if (wacom->battery)
65 power_supply_changed(wacom->battery);
953f2c5f
JG
66 }
67}
68
95dd3b30 69static int wacom_penpartner_irq(struct wacom_wac *wacom)
3bea733a
PC
70{
71 unsigned char *data = wacom->data;
2a6cdbdd 72 struct input_dev *input = wacom->pen_input;
3bea733a
PC
73
74 switch (data[0]) {
73a97f4f
DT
75 case 1:
76 if (data[5] & 0x80) {
77 wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
78 wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID;
8da23fc1
DT
79 input_report_key(input, wacom->tool[0], 1);
80 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
252f7769
DT
81 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
82 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
8da23fc1
DT
83 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
84 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127));
85 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
73a97f4f 86 } else {
8da23fc1
DT
87 input_report_key(input, wacom->tool[0], 0);
88 input_report_abs(input, ABS_MISC, 0); /* report tool id */
89 input_report_abs(input, ABS_PRESSURE, -1);
90 input_report_key(input, BTN_TOUCH, 0);
73a97f4f
DT
91 }
92 break;
8da23fc1 93
73a97f4f 94 case 2:
8da23fc1
DT
95 input_report_key(input, BTN_TOOL_PEN, 1);
96 input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
252f7769
DT
97 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
98 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
8da23fc1
DT
99 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
100 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
101 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
73a97f4f 102 break;
8da23fc1 103
73a97f4f 104 default:
eb71d1bb
DT
105 dev_dbg(input->dev.parent,
106 "%s: received unknown report #%d\n", __func__, data[0]);
73a97f4f 107 return 0;
3bea733a 108 }
8da23fc1 109
3bea733a
PC
110 return 1;
111}
112
95dd3b30 113static int wacom_pl_irq(struct wacom_wac *wacom)
3bea733a 114{
e33da8a5 115 struct wacom_features *features = &wacom->features;
3bea733a 116 unsigned char *data = wacom->data;
2a6cdbdd 117 struct input_dev *input = wacom->pen_input;
e34b9d2f 118 int prox, pressure;
3bea733a 119
cad74700 120 if (data[0] != WACOM_REPORT_PENABLED) {
eb71d1bb
DT
121 dev_dbg(input->dev.parent,
122 "%s: received unknown report #%d\n", __func__, data[0]);
3bea733a
PC
123 return 0;
124 }
125
126 prox = data[1] & 0x40;
127
025bcc15
JG
128 if (!wacom->id[0]) {
129 if ((data[0] & 0x10) || (data[4] & 0x20)) {
130 wacom->tool[0] = BTN_TOOL_RUBBER;
131 wacom->id[0] = ERASER_DEVICE_ID;
3bea733a 132 }
025bcc15
JG
133 else {
134 wacom->tool[0] = BTN_TOOL_PEN;
e34b9d2f 135 wacom->id[0] = STYLUS_DEVICE_ID;
3bea733a 136 }
3bea733a 137 }
8da23fc1 138
025bcc15
JG
139 /* If the eraser is in prox, STYLUS2 is always set. If we
140 * mis-detected the type and notice that STYLUS2 isn't set
141 * then force the eraser out of prox and let the pen in.
142 */
143 if (wacom->tool[0] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
144 input_report_key(input, BTN_TOOL_RUBBER, 0);
145 input_report_abs(input, ABS_MISC, 0);
146 input_sync(input);
147 wacom->tool[0] = BTN_TOOL_PEN;
148 wacom->id[0] = STYLUS_DEVICE_ID;
3bea733a
PC
149 }
150
025bcc15
JG
151 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
152 if (features->pressure_max > 255)
153 pressure = (pressure << 1) | ((data[4] >> 6) & 1);
154 pressure += (features->pressure_max + 1) / 2;
155
156 input_report_abs(input, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
157 input_report_abs(input, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
158 input_report_abs(input, ABS_PRESSURE, pressure);
159
160 input_report_key(input, BTN_TOUCH, data[4] & 0x08);
161 input_report_key(input, BTN_STYLUS, data[4] & 0x10);
162 /* Only allow the stylus2 button to be reported for the pen tool. */
163 input_report_key(input, BTN_STYLUS2, (wacom->tool[0] == BTN_TOOL_PEN) && (data[4] & 0x20));
164
165 if (!prox)
166 wacom->id[0] = 0;
167 input_report_key(input, wacom->tool[0], prox);
168 input_report_abs(input, ABS_MISC, wacom->id[0]);
3bea733a
PC
169 return 1;
170}
171
95dd3b30 172static int wacom_ptu_irq(struct wacom_wac *wacom)
3bea733a
PC
173{
174 unsigned char *data = wacom->data;
2a6cdbdd 175 struct input_dev *input = wacom->pen_input;
3bea733a 176
cad74700 177 if (data[0] != WACOM_REPORT_PENABLED) {
eb71d1bb
DT
178 dev_dbg(input->dev.parent,
179 "%s: received unknown report #%d\n", __func__, data[0]);
3bea733a
PC
180 return 0;
181 }
182
3bea733a 183 if (data[1] & 0x04) {
8da23fc1
DT
184 input_report_key(input, BTN_TOOL_RUBBER, data[1] & 0x20);
185 input_report_key(input, BTN_TOUCH, data[1] & 0x08);
e34b9d2f 186 wacom->id[0] = ERASER_DEVICE_ID;
3bea733a 187 } else {
8da23fc1
DT
188 input_report_key(input, BTN_TOOL_PEN, data[1] & 0x20);
189 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
e34b9d2f 190 wacom->id[0] = STYLUS_DEVICE_ID;
3bea733a 191 }
8da23fc1 192 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
252f7769
DT
193 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
194 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
195 input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6]));
8da23fc1
DT
196 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
197 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
3bea733a
PC
198 return 1;
199}
200
c8f2edc5
PC
201static int wacom_dtu_irq(struct wacom_wac *wacom)
202{
74b63417 203 unsigned char *data = wacom->data;
2a6cdbdd 204 struct input_dev *input = wacom->pen_input;
74b63417 205 int prox = data[1] & 0x20;
c8f2edc5 206
eb71d1bb
DT
207 dev_dbg(input->dev.parent,
208 "%s: received report #%d", __func__, data[0]);
c8f2edc5
PC
209
210 if (prox) {
211 /* Going into proximity select tool */
212 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
213 if (wacom->tool[0] == BTN_TOOL_PEN)
214 wacom->id[0] = STYLUS_DEVICE_ID;
215 else
216 wacom->id[0] = ERASER_DEVICE_ID;
217 }
218 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
219 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
220 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
221 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
74b63417 222 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x01) << 8) | data[6]);
c8f2edc5
PC
223 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
224 if (!prox) /* out-prox */
225 wacom->id[0] = 0;
226 input_report_key(input, wacom->tool[0], prox);
227 input_report_abs(input, ABS_MISC, wacom->id[0]);
228 return 1;
229}
230
497ab1f2
PC
231static int wacom_dtus_irq(struct wacom_wac *wacom)
232{
233 char *data = wacom->data;
2a6cdbdd 234 struct input_dev *input = wacom->pen_input;
497ab1f2
PC
235 unsigned short prox, pressure = 0;
236
237 if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) {
238 dev_dbg(input->dev.parent,
239 "%s: received unknown report #%d", __func__, data[0]);
240 return 0;
241 } else if (data[0] == WACOM_REPORT_DTUSPAD) {
422b0314 242 input = wacom->pad_input;
497ab1f2
PC
243 input_report_key(input, BTN_0, (data[1] & 0x01));
244 input_report_key(input, BTN_1, (data[1] & 0x02));
245 input_report_key(input, BTN_2, (data[1] & 0x04));
246 input_report_key(input, BTN_3, (data[1] & 0x08));
247 input_report_abs(input, ABS_MISC,
248 data[1] & 0x0f ? PAD_DEVICE_ID : 0);
497ab1f2
PC
249 return 1;
250 } else {
251 prox = data[1] & 0x80;
252 if (prox) {
253 switch ((data[1] >> 3) & 3) {
254 case 1: /* Rubber */
255 wacom->tool[0] = BTN_TOOL_RUBBER;
256 wacom->id[0] = ERASER_DEVICE_ID;
257 break;
258
259 case 2: /* Pen */
260 wacom->tool[0] = BTN_TOOL_PEN;
261 wacom->id[0] = STYLUS_DEVICE_ID;
262 break;
263 }
264 }
265
266 input_report_key(input, BTN_STYLUS, data[1] & 0x20);
267 input_report_key(input, BTN_STYLUS2, data[1] & 0x40);
268 input_report_abs(input, ABS_X, get_unaligned_be16(&data[3]));
269 input_report_abs(input, ABS_Y, get_unaligned_be16(&data[5]));
270 pressure = ((data[1] & 0x03) << 8) | (data[2] & 0xff);
271 input_report_abs(input, ABS_PRESSURE, pressure);
272 input_report_key(input, BTN_TOUCH, pressure > 10);
273
274 if (!prox) /* out-prox */
275 wacom->id[0] = 0;
276 input_report_key(input, wacom->tool[0], prox);
277 input_report_abs(input, ABS_MISC, wacom->id[0]);
497ab1f2
PC
278 return 1;
279 }
280}
281
95dd3b30 282static int wacom_graphire_irq(struct wacom_wac *wacom)
3bea733a 283{
e33da8a5 284 struct wacom_features *features = &wacom->features;
3bea733a 285 unsigned char *data = wacom->data;
2a6cdbdd 286 struct input_dev *input = wacom->pen_input;
3813810c 287 struct input_dev *pad_input = wacom->pad_input;
387142bb 288 int battery_capacity, ps_connected;
252f7769 289 int prox;
3b57ca0f
PC
290 int rw = 0;
291 int retval = 0;
3bea733a 292
387142bb
BT
293 if (features->type == GRAPHIRE_BT) {
294 if (data[0] != WACOM_REPORT_PENABLED_BT) {
295 dev_dbg(input->dev.parent,
296 "%s: received unknown report #%d\n", __func__,
297 data[0]);
298 goto exit;
299 }
300 } else if (data[0] != WACOM_REPORT_PENABLED) {
eb71d1bb
DT
301 dev_dbg(input->dev.parent,
302 "%s: received unknown report #%d\n", __func__, data[0]);
3b57ca0f 303 goto exit;
3bea733a
PC
304 }
305
3b57ca0f
PC
306 prox = data[1] & 0x80;
307 if (prox || wacom->id[0]) {
308 if (prox) {
309 switch ((data[1] >> 5) & 3) {
3bea733a
PC
310
311 case 0: /* Pen */
312 wacom->tool[0] = BTN_TOOL_PEN;
e34b9d2f 313 wacom->id[0] = STYLUS_DEVICE_ID;
3bea733a
PC
314 break;
315
316 case 1: /* Rubber */
317 wacom->tool[0] = BTN_TOOL_RUBBER;
e34b9d2f 318 wacom->id[0] = ERASER_DEVICE_ID;
3bea733a
PC
319 break;
320
321 case 2: /* Mouse with wheel */
8da23fc1 322 input_report_key(input, BTN_MIDDLE, data[1] & 0x04);
3bea733a
PC
323 /* fall through */
324
325 case 3: /* Mouse without wheel */
326 wacom->tool[0] = BTN_TOOL_MOUSE;
e34b9d2f 327 wacom->id[0] = CURSOR_DEVICE_ID;
3bea733a 328 break;
3b57ca0f 329 }
3bea733a 330 }
252f7769
DT
331 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
332 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
3bea733a 333 if (wacom->tool[0] != BTN_TOOL_MOUSE) {
387142bb
BT
334 if (features->type == GRAPHIRE_BT)
335 input_report_abs(input, ABS_PRESSURE, data[6] |
336 (((__u16) (data[1] & 0x08)) << 5));
337 else
338 input_report_abs(input, ABS_PRESSURE, data[6] |
339 ((data[7] & 0x03) << 8));
8da23fc1
DT
340 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
341 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
342 input_report_key(input, BTN_STYLUS2, data[1] & 0x04);
afb567e3 343 } else {
8da23fc1
DT
344 input_report_key(input, BTN_LEFT, data[1] & 0x01);
345 input_report_key(input, BTN_RIGHT, data[1] & 0x02);
3b57ca0f
PC
346 if (features->type == WACOM_G4 ||
347 features->type == WACOM_MO) {
8da23fc1 348 input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f);
d9f66c1a 349 rw = (data[7] & 0x04) - (data[7] & 0x03);
387142bb
BT
350 } else if (features->type == GRAPHIRE_BT) {
351 /* Compute distance between mouse and tablet */
352 rw = 44 - (data[6] >> 2);
353 rw = clamp_val(rw, 0, 31);
354 input_report_abs(input, ABS_DISTANCE, rw);
355 if (((data[1] >> 5) & 3) == 2) {
356 /* Mouse with wheel */
357 input_report_key(input, BTN_MIDDLE,
358 data[1] & 0x04);
359 rw = (data[6] & 0x01) ? -1 :
360 (data[6] & 0x02) ? 1 : 0;
361 } else {
362 rw = 0;
363 }
3b57ca0f 364 } else {
8da23fc1 365 input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f);
d9f66c1a 366 rw = -(signed char)data[6];
3b57ca0f 367 }
8da23fc1 368 input_report_rel(input, REL_WHEEL, rw);
afb567e3 369 }
3b57ca0f
PC
370
371 if (!prox)
372 wacom->id[0] = 0;
8da23fc1
DT
373 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
374 input_report_key(input, wacom->tool[0], prox);
375 input_sync(input); /* sync last event */
80d4e8e9 376 }
3bea733a
PC
377
378 /* send pad data */
e33da8a5 379 switch (features->type) {
73a97f4f 380 case WACOM_G4:
3b57ca0f
PC
381 prox = data[7] & 0xf8;
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] & 0x40));
385 input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x80));
3bea733a 386 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
3813810c 387 input_report_rel(pad_input, REL_WHEEL, rw);
3b57ca0f
PC
388 if (!prox)
389 wacom->id[1] = 0;
3813810c 390 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
ab687b18 391 retval = 1;
3bea733a 392 }
7ecfbfd3 393 break;
73a97f4f
DT
394
395 case WACOM_MO:
3b57ca0f
PC
396 prox = (data[7] & 0xf8) || data[8];
397 if (prox || wacom->id[1]) {
e34b9d2f 398 wacom->id[1] = PAD_DEVICE_ID;
3813810c
BT
399 input_report_key(pad_input, BTN_BACK, (data[7] & 0x08));
400 input_report_key(pad_input, BTN_LEFT, (data[7] & 0x20));
401 input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x10));
402 input_report_key(pad_input, BTN_RIGHT, (data[7] & 0x40));
403 input_report_abs(pad_input, ABS_WHEEL, (data[8] & 0x7f));
3b57ca0f
PC
404 if (!prox)
405 wacom->id[1] = 0;
3813810c 406 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
84460014 407 retval = 1;
7ecfbfd3
PC
408 }
409 break;
387142bb
BT
410 case GRAPHIRE_BT:
411 prox = data[7] & 0x03;
412 if (prox || wacom->id[1]) {
413 wacom->id[1] = PAD_DEVICE_ID;
414 input_report_key(pad_input, BTN_0, (data[7] & 0x02));
415 input_report_key(pad_input, BTN_1, (data[7] & 0x01));
3b57ca0f
PC
416 if (!prox)
417 wacom->id[1] = 0;
387142bb 418 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
84460014 419 retval = 1;
7ecfbfd3
PC
420 }
421 break;
3bea733a 422 }
387142bb
BT
423
424 /* Store current battery capacity and power supply state */
425 if (features->type == GRAPHIRE_BT) {
426 rw = (data[7] >> 2 & 0x07);
427 battery_capacity = batcap_gr[rw];
428 ps_connected = rw == 7;
953f2c5f 429 wacom_notify_battery(wacom, battery_capacity, ps_connected,
71fa641e 430 1, ps_connected);
3bea733a 431 }
3b57ca0f
PC
432exit:
433 return retval;
3bea733a
PC
434}
435
5fcad167
BT
436static void wacom_intuos_schedule_prox_event(struct wacom_wac *wacom_wac)
437{
438 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
439 struct hid_report *r;
440 struct hid_report_enum *re;
441
442 re = &(wacom->hdev->report_enum[HID_FEATURE_REPORT]);
443 r = re->report_id_hash[WACOM_REPORT_INTUOSREAD];
444 if (r) {
445 hid_hw_request(wacom->hdev, r, HID_REQ_GET_REPORT);
446 }
447}
448
fb013a01
JG
449static int wacom_intuos_pad(struct wacom_wac *wacom)
450{
451 struct wacom_features *features = &wacom->features;
452 unsigned char *data = wacom->data;
453 struct input_dev *input = wacom->pad_input;
454
455 /* pad packets. Works as a second tool and is always in prox */
456 if (!(data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD ||
457 data[0] == WACOM_REPORT_CINTIQPAD))
458 return 0;
459
460 if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
461 input_report_key(input, BTN_0, (data[2] & 0x01));
462 input_report_key(input, BTN_1, (data[3] & 0x01));
463 input_report_key(input, BTN_2, (data[3] & 0x02));
464 input_report_key(input, BTN_3, (data[3] & 0x04));
465 input_report_key(input, BTN_4, (data[3] & 0x08));
466 input_report_key(input, BTN_5, (data[3] & 0x10));
467 input_report_key(input, BTN_6, (data[3] & 0x20));
468 if (data[1] & 0x80) {
469 input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f));
470 } else {
471 /* Out of proximity, clear wheel value. */
472 input_report_abs(input, ABS_WHEEL, 0);
473 }
474 if (features->type != INTUOS4S) {
475 input_report_key(input, BTN_7, (data[3] & 0x40));
476 input_report_key(input, BTN_8, (data[3] & 0x80));
477 }
478 if (data[1] | (data[2] & 0x01) | data[3]) {
479 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
480 } else {
481 input_report_abs(input, ABS_MISC, 0);
482 }
483 } else if (features->type == DTK) {
484 input_report_key(input, BTN_0, (data[6] & 0x01));
485 input_report_key(input, BTN_1, (data[6] & 0x02));
486 input_report_key(input, BTN_2, (data[6] & 0x04));
487 input_report_key(input, BTN_3, (data[6] & 0x08));
488 input_report_key(input, BTN_4, (data[6] & 0x10));
489 input_report_key(input, BTN_5, (data[6] & 0x20));
490 if (data[6] & 0x3f) {
491 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
492 } else {
493 input_report_abs(input, ABS_MISC, 0);
494 }
495 } else if (features->type == WACOM_13HD) {
496 input_report_key(input, BTN_0, (data[3] & 0x01));
497 input_report_key(input, BTN_1, (data[4] & 0x01));
498 input_report_key(input, BTN_2, (data[4] & 0x02));
499 input_report_key(input, BTN_3, (data[4] & 0x04));
500 input_report_key(input, BTN_4, (data[4] & 0x08));
501 input_report_key(input, BTN_5, (data[4] & 0x10));
502 input_report_key(input, BTN_6, (data[4] & 0x20));
503 input_report_key(input, BTN_7, (data[4] & 0x40));
504 input_report_key(input, BTN_8, (data[4] & 0x80));
505 if ((data[3] & 0x01) | data[4]) {
506 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
507 } else {
508 input_report_abs(input, ABS_MISC, 0);
509 }
510 } else if (features->type == WACOM_24HD) {
511 input_report_key(input, BTN_0, (data[6] & 0x01));
512 input_report_key(input, BTN_1, (data[6] & 0x02));
513 input_report_key(input, BTN_2, (data[6] & 0x04));
514 input_report_key(input, BTN_3, (data[6] & 0x08));
515 input_report_key(input, BTN_4, (data[6] & 0x10));
516 input_report_key(input, BTN_5, (data[6] & 0x20));
517 input_report_key(input, BTN_6, (data[6] & 0x40));
518 input_report_key(input, BTN_7, (data[6] & 0x80));
519 input_report_key(input, BTN_8, (data[8] & 0x01));
520 input_report_key(input, BTN_9, (data[8] & 0x02));
521 input_report_key(input, BTN_A, (data[8] & 0x04));
522 input_report_key(input, BTN_B, (data[8] & 0x08));
523 input_report_key(input, BTN_C, (data[8] & 0x10));
524 input_report_key(input, BTN_X, (data[8] & 0x20));
525 input_report_key(input, BTN_Y, (data[8] & 0x40));
526 input_report_key(input, BTN_Z, (data[8] & 0x80));
527
528 /*
529 * Three "buttons" are available on the 24HD which are
530 * physically implemented as a touchstrip. Each button
531 * is approximately 3 bits wide with a 2 bit spacing.
532 * The raw touchstrip bits are stored at:
533 * ((data[3] & 0x1f) << 8) | data[4])
534 */
535 input_report_key(input, KEY_PROG1, data[4] & 0x07);
536 input_report_key(input, KEY_PROG2, data[4] & 0xE0);
537 input_report_key(input, KEY_PROG3, data[3] & 0x1C);
538
539 if (data[1] & 0x80) {
540 input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f));
541 } else {
542 /* Out of proximity, clear wheel value. */
543 input_report_abs(input, ABS_WHEEL, 0);
544 }
545
546 if (data[2] & 0x80) {
547 input_report_abs(input, ABS_THROTTLE, (data[2] & 0x7f));
548 } else {
549 /* Out of proximity, clear second wheel value. */
550 input_report_abs(input, ABS_THROTTLE, 0);
551 }
552
553 if (data[1] | data[2] | (data[3] & 0x1f) | data[4] | data[6] | data[8]) {
554 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
555 } else {
556 input_report_abs(input, ABS_MISC, 0);
557 }
558 } else if (features->type == WACOM_27QHD) {
559 input_report_key(input, KEY_PROG1, data[2] & 0x01);
560 input_report_key(input, KEY_PROG2, data[2] & 0x02);
561 input_report_key(input, KEY_PROG3, data[2] & 0x04);
562
563 input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[4]));
564 input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[6]));
565 input_report_abs(input, ABS_Z, be16_to_cpup((__be16 *)&data[8]));
566 if ((data[2] & 0x07) | data[4] | data[5] | data[6] | data[7] | data[8] | data[9]) {
567 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
568 } else {
569 input_report_abs(input, ABS_MISC, 0);
570 }
571 } else if (features->type == CINTIQ_HYBRID) {
572 /*
573 * Do not send hardware buttons under Android. They
574 * are already sent to the system through GPIO (and
575 * have different meaning).
576 */
577 input_report_key(input, BTN_1, (data[4] & 0x01));
578 input_report_key(input, BTN_2, (data[4] & 0x02));
579 input_report_key(input, BTN_3, (data[4] & 0x04));
580 input_report_key(input, BTN_4, (data[4] & 0x08));
581
582 input_report_key(input, BTN_5, (data[4] & 0x10)); /* Right */
583 input_report_key(input, BTN_6, (data[4] & 0x20)); /* Up */
584 input_report_key(input, BTN_7, (data[4] & 0x40)); /* Left */
585 input_report_key(input, BTN_8, (data[4] & 0x80)); /* Down */
586 input_report_key(input, BTN_0, (data[3] & 0x01)); /* Center */
587
588 if (data[4] | (data[3] & 0x01)) {
589 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
590 } else {
591 input_report_abs(input, ABS_MISC, 0);
592 }
593
594 } else if (features->type == CINTIQ_COMPANION_2) {
595 input_report_key(input, BTN_1, (data[1] & 0x02));
596 input_report_key(input, BTN_2, (data[2] & 0x01));
597 input_report_key(input, BTN_3, (data[2] & 0x02));
598 input_report_key(input, BTN_4, (data[2] & 0x04));
599 input_report_key(input, BTN_5, (data[2] & 0x08));
600 input_report_key(input, BTN_6, (data[1] & 0x04));
601
602 input_report_key(input, BTN_7, (data[2] & 0x10)); /* Right */
603 input_report_key(input, BTN_8, (data[2] & 0x20)); /* Up */
604 input_report_key(input, BTN_9, (data[2] & 0x40)); /* Left */
605 input_report_key(input, BTN_A, (data[2] & 0x80)); /* Down */
606 input_report_key(input, BTN_0, (data[1] & 0x01)); /* Center */
607
608 if (data[2] | (data[1] & 0x07)) {
609 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
610 } else {
611 input_report_abs(input, ABS_MISC, 0);
612 }
613
614 } else if (features->type >= INTUOS5S && features->type <= INTUOSPL) {
615 int i;
616
617 /* Touch ring mode switch has no capacitive sensor */
618 input_report_key(input, BTN_0, (data[3] & 0x01));
619
620 /*
621 * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in
622 * addition to the mechanical switch. Switch data is
623 * stored in data[4], capacitive data in data[5].
624 */
625 for (i = 0; i < 8; i++)
626 input_report_key(input, BTN_1 + i, data[4] & (1 << i));
627
628 if (data[2] & 0x80) {
629 input_report_abs(input, ABS_WHEEL, (data[2] & 0x7f));
630 } else {
631 /* Out of proximity, clear wheel value. */
632 input_report_abs(input, ABS_WHEEL, 0);
633 }
634
635 if (data[2] | (data[3] & 0x01) | data[4] | data[5]) {
636 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
637 } else {
638 input_report_abs(input, ABS_MISC, 0);
639 }
640 } else {
641 if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) {
642 input_report_key(input, BTN_0, (data[5] & 0x01));
643 input_report_key(input, BTN_1, (data[6] & 0x01));
644 input_report_key(input, BTN_2, (data[6] & 0x02));
645 input_report_key(input, BTN_3, (data[6] & 0x04));
646 input_report_key(input, BTN_4, (data[6] & 0x08));
647 input_report_key(input, BTN_5, (data[6] & 0x10));
648 input_report_key(input, BTN_6, (data[6] & 0x20));
649 input_report_key(input, BTN_7, (data[6] & 0x40));
650 input_report_key(input, BTN_8, (data[6] & 0x80));
651 input_report_key(input, BTN_9, (data[7] & 0x01));
652 input_report_key(input, BTN_A, (data[8] & 0x01));
653 input_report_key(input, BTN_B, (data[8] & 0x02));
654 input_report_key(input, BTN_C, (data[8] & 0x04));
655 input_report_key(input, BTN_X, (data[8] & 0x08));
656 input_report_key(input, BTN_Y, (data[8] & 0x10));
657 input_report_key(input, BTN_Z, (data[8] & 0x20));
658 input_report_key(input, BTN_BASE, (data[8] & 0x40));
659 input_report_key(input, BTN_BASE2, (data[8] & 0x80));
660
661 if (features->type == WACOM_22HD) {
662 input_report_key(input, KEY_PROG1, data[9] & 0x01);
663 input_report_key(input, KEY_PROG2, data[9] & 0x02);
664 input_report_key(input, KEY_PROG3, data[9] & 0x04);
665 }
666 } else {
667 input_report_key(input, BTN_0, (data[5] & 0x01));
668 input_report_key(input, BTN_1, (data[5] & 0x02));
669 input_report_key(input, BTN_2, (data[5] & 0x04));
670 input_report_key(input, BTN_3, (data[5] & 0x08));
671 input_report_key(input, BTN_4, (data[6] & 0x01));
672 input_report_key(input, BTN_5, (data[6] & 0x02));
673 input_report_key(input, BTN_6, (data[6] & 0x04));
674 input_report_key(input, BTN_7, (data[6] & 0x08));
675 input_report_key(input, BTN_8, (data[5] & 0x10));
676 input_report_key(input, BTN_9, (data[6] & 0x10));
677 }
678 input_report_abs(input, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
679 input_report_abs(input, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
680
681 if ((data[5] & 0x1f) | data[6] | (data[1] & 0x1f) |
682 data[2] | (data[3] & 0x1f) | data[4] | data[8] |
683 (data[7] & 0x01)) {
684 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
685 } else {
686 input_report_abs(input, ABS_MISC, 0);
687 }
688 }
689 return 1;
690}
691
95dd3b30 692static int wacom_intuos_inout(struct wacom_wac *wacom)
3bea733a 693{
e33da8a5 694 struct wacom_features *features = &wacom->features;
3bea733a 695 unsigned char *data = wacom->data;
2a6cdbdd 696 struct input_dev *input = wacom->pen_input;
6f660f12 697 int idx = 0;
3bea733a
PC
698
699 /* tool number */
e33da8a5 700 if (features->type == INTUOS)
6f660f12 701 idx = data[1] & 0x01;
3bea733a
PC
702
703 /* Enter report */
704 if ((data[1] & 0xfc) == 0xc0) {
705 /* serial number of the tool */
706 wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
707 (data[4] << 20) + (data[5] << 12) +
708 (data[6] << 4) + (data[7] >> 4);
709
493630b2
PC
710 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) |
711 ((data[7] & 0x0f) << 20) | ((data[8] & 0xf0) << 12);
73a97f4f 712
f0aaceac 713 switch (wacom->id[idx]) {
73a97f4f
DT
714 case 0x812: /* Inking pen */
715 case 0x801: /* Intuos3 Inking pen */
f0aaceac 716 case 0x120802: /* Intuos4/5 Inking Pen */
73a97f4f
DT
717 case 0x012:
718 wacom->tool[idx] = BTN_TOOL_PENCIL;
719 break;
720
721 case 0x822: /* Pen */
722 case 0x842:
723 case 0x852:
724 case 0x823: /* Intuos3 Grip Pen */
725 case 0x813: /* Intuos3 Classic Pen */
726 case 0x885: /* Intuos3 Marker Pen */
f0aaceac
PC
727 case 0x802: /* Intuos4/5 13HD/24HD General Pen */
728 case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
73a97f4f 729 case 0x022:
f0aaceac
PC
730 case 0x100804: /* Intuos4/5 13HD/24HD Art Pen */
731 case 0x140802: /* Intuos4/5 13HD/24HD Classic Pen */
732 case 0x160802: /* Cintiq 13HD Pro Pen */
c73a1afb 733 case 0x180802: /* DTH2242 Pen */
7d753b0d 734 case 0x100802: /* Intuos4/5 13HD/24HD General Pen */
73a97f4f
DT
735 wacom->tool[idx] = BTN_TOOL_PEN;
736 break;
737
738 case 0x832: /* Stroke pen */
739 case 0x032:
740 wacom->tool[idx] = BTN_TOOL_BRUSH;
741 break;
742
743 case 0x007: /* Mouse 4D and 2D */
744 case 0x09c:
745 case 0x094:
746 case 0x017: /* Intuos3 2D Mouse */
747 case 0x806: /* Intuos4 Mouse */
748 wacom->tool[idx] = BTN_TOOL_MOUSE;
749 break;
750
751 case 0x096: /* Lens cursor */
752 case 0x097: /* Intuos3 Lens cursor */
753 case 0x006: /* Intuos4 Lens cursor */
754 wacom->tool[idx] = BTN_TOOL_LENS;
755 break;
756
757 case 0x82a: /* Eraser */
758 case 0x85a:
759 case 0x91a:
760 case 0xd1a:
761 case 0x0fa:
762 case 0x82b: /* Intuos3 Grip Pen Eraser */
763 case 0x81b: /* Intuos3 Classic Pen Eraser */
764 case 0x91b: /* Intuos3 Airbrush Eraser */
f0aaceac
PC
765 case 0x80c: /* Intuos4/5 13HD/24HD Marker Pen Eraser */
766 case 0x80a: /* Intuos4/5 13HD/24HD General Pen Eraser */
767 case 0x90a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
768 case 0x14080a: /* Intuos4/5 13HD/24HD Classic Pen Eraser */
769 case 0x10090a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
770 case 0x10080c: /* Intuos4/5 13HD/24HD Art Pen Eraser */
771 case 0x16080a: /* Cintiq 13HD Pro Pen Eraser */
c73a1afb 772 case 0x18080a: /* DTH2242 Eraser */
7d753b0d 773 case 0x10080a: /* Intuos4/5 13HD/24HD General Pen Eraser */
73a97f4f
DT
774 wacom->tool[idx] = BTN_TOOL_RUBBER;
775 break;
776
777 case 0xd12:
778 case 0x912:
779 case 0x112:
780 case 0x913: /* Intuos3 Airbrush */
f0aaceac
PC
781 case 0x902: /* Intuos4/5 13HD/24HD Airbrush */
782 case 0x100902: /* Intuos4/5 13HD/24HD Airbrush */
73a97f4f
DT
783 wacom->tool[idx] = BTN_TOOL_AIRBRUSH;
784 break;
785
786 default: /* Unknown tool */
787 wacom->tool[idx] = BTN_TOOL_PEN;
788 break;
3bea733a 789 }
3bea733a
PC
790 return 1;
791 }
792
373a5356
PC
793 /*
794 * don't report events for invalid data
795 */
3a4b4aaa 796 /* older I4 styli don't work with new Cintiqs */
373a5356
PC
797 if ((!((wacom->id[idx] >> 20) & 0x01) &&
798 (features->type == WACOM_21UX2)) ||
799 /* Only large Intuos support Lense Cursor */
800 (wacom->tool[idx] == BTN_TOOL_LENS &&
801 (features->type == INTUOS3 ||
802 features->type == INTUOS3S ||
803 features->type == INTUOS4 ||
804 features->type == INTUOS4S ||
805 features->type == INTUOS5 ||
806 features->type == INTUOS5S ||
807 features->type == INTUOSPM ||
808 features->type == INTUOSPS)) ||
809 /* Cintiq doesn't send data when RDY bit isn't set */
810 (features->type == CINTIQ && !(data[1] & 0x40)))
3a4b4aaa
PC
811 return 1;
812
f3586d2f
PC
813 wacom->shared->stylus_in_proximity = true;
814 if (wacom->shared->touch_down)
815 return 1;
486b908d 816
b3bd7ef3
PC
817 /* in Range while exiting */
818 if (((data[1] & 0xfe) == 0x20) && wacom->reporting_data) {
4eb1830b
JG
819 input_report_key(input, BTN_TOUCH, 0);
820 input_report_abs(input, ABS_PRESSURE, 0);
821 input_report_abs(input, ABS_DISTANCE, wacom->features.distance_max);
b3bd7ef3 822 return 2;
4eb1830b
JG
823 }
824
3bea733a
PC
825 /* Exit report */
826 if ((data[1] & 0xfe) == 0x80) {
f3586d2f 827 wacom->shared->stylus_in_proximity = false;
b3bd7ef3 828 wacom->reporting_data = false;
ae584ca4 829
373a5356
PC
830 /* don't report exit if we don't know the ID */
831 if (!wacom->id[idx])
832 return 1;
833
6f660f12
PC
834 /*
835 * Reset all states otherwise we lose the initial states
836 * when in-prox next time
837 */
8da23fc1
DT
838 input_report_abs(input, ABS_X, 0);
839 input_report_abs(input, ABS_Y, 0);
840 input_report_abs(input, ABS_DISTANCE, 0);
841 input_report_abs(input, ABS_TILT_X, 0);
842 input_report_abs(input, ABS_TILT_Y, 0);
80d4e8e9 843 if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
8da23fc1
DT
844 input_report_key(input, BTN_LEFT, 0);
845 input_report_key(input, BTN_MIDDLE, 0);
846 input_report_key(input, BTN_RIGHT, 0);
847 input_report_key(input, BTN_SIDE, 0);
848 input_report_key(input, BTN_EXTRA, 0);
849 input_report_abs(input, ABS_THROTTLE, 0);
850 input_report_abs(input, ABS_RZ, 0);
7ecfbfd3 851 } else {
8da23fc1
DT
852 input_report_abs(input, ABS_PRESSURE, 0);
853 input_report_key(input, BTN_STYLUS, 0);
854 input_report_key(input, BTN_STYLUS2, 0);
855 input_report_key(input, BTN_TOUCH, 0);
856 input_report_abs(input, ABS_WHEEL, 0);
e33da8a5 857 if (features->type >= INTUOS3S)
8da23fc1 858 input_report_abs(input, ABS_Z, 0);
8d32e3ae 859 }
8da23fc1
DT
860 input_report_key(input, wacom->tool[idx], 0);
861 input_report_abs(input, ABS_MISC, 0); /* reset tool id */
862 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
6f660f12 863 wacom->id[idx] = 0;
80d4e8e9 864 return 2;
3bea733a 865 }
373a5356
PC
866
867 /* don't report other events if we don't know the ID */
5fcad167
BT
868 if (!wacom->id[idx]) {
869 /* but reschedule a read of the current tool */
870 wacom_intuos_schedule_prox_event(wacom);
373a5356 871 return 1;
5fcad167 872 }
373a5356 873
3bea733a
PC
874 return 0;
875}
876
72b236d6
AS
877static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len)
878{
879 unsigned char *data = wacom_wac->data;
880 struct input_dev *input = wacom_wac->pad_input;
881 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
882 struct wacom_features *features = &wacom_wac->features;
883 int bat_charging, bat_percent, touch_ring_mode;
884 __u32 serial;
885 int i;
886
887 if (data[0] != WACOM_REPORT_REMOTE) {
888 dev_dbg(input->dev.parent,
889 "%s: received unknown report #%d", __func__, data[0]);
890 return 0;
891 }
892
893 serial = data[3] + (data[4] << 8) + (data[5] << 16);
894 wacom_wac->id[0] = PAD_DEVICE_ID;
895
896 input_report_key(input, BTN_0, (data[9] & 0x01));
897 input_report_key(input, BTN_1, (data[9] & 0x02));
898 input_report_key(input, BTN_2, (data[9] & 0x04));
899 input_report_key(input, BTN_3, (data[9] & 0x08));
900 input_report_key(input, BTN_4, (data[9] & 0x10));
901 input_report_key(input, BTN_5, (data[9] & 0x20));
902 input_report_key(input, BTN_6, (data[9] & 0x40));
903 input_report_key(input, BTN_7, (data[9] & 0x80));
904
905 input_report_key(input, BTN_8, (data[10] & 0x01));
906 input_report_key(input, BTN_9, (data[10] & 0x02));
907 input_report_key(input, BTN_A, (data[10] & 0x04));
908 input_report_key(input, BTN_B, (data[10] & 0x08));
909 input_report_key(input, BTN_C, (data[10] & 0x10));
910 input_report_key(input, BTN_X, (data[10] & 0x20));
911 input_report_key(input, BTN_Y, (data[10] & 0x40));
912 input_report_key(input, BTN_Z, (data[10] & 0x80));
913
914 input_report_key(input, BTN_BASE, (data[11] & 0x01));
915 input_report_key(input, BTN_BASE2, (data[11] & 0x02));
916
917 if (data[12] & 0x80)
918 input_report_abs(input, ABS_WHEEL, (data[12] & 0x7f));
919 else
920 input_report_abs(input, ABS_WHEEL, 0);
921
922 bat_percent = data[7] & 0x7f;
923 bat_charging = !!(data[7] & 0x80);
924
925 if (data[9] | data[10] | (data[11] & 0x03) | data[12])
926 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
927 else
928 input_report_abs(input, ABS_MISC, 0);
929
930 input_event(input, EV_MSC, MSC_SERIAL, serial);
931
932 /*Which mode select (LED light) is currently on?*/
933 touch_ring_mode = (data[11] & 0xC0) >> 6;
934
935 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
936 if (wacom_wac->serial[i] == serial)
937 wacom->led.select[i] = touch_ring_mode;
938 }
939
940 if (!wacom->battery &&
941 !(features->quirks & WACOM_QUIRK_BATTERY)) {
942 features->quirks |= WACOM_QUIRK_BATTERY;
943 INIT_WORK(&wacom->work, wacom_battery_work);
944 wacom_schedule_work(wacom_wac);
945 }
946
947 wacom_notify_battery(wacom_wac, bat_percent, bat_charging, 1,
948 bat_charging);
949
950 return 1;
951}
952
953static int wacom_remote_status_irq(struct wacom_wac *wacom_wac, size_t len)
954{
955 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
956 unsigned char *data = wacom_wac->data;
957 int i;
958
959 if (data[0] != WACOM_REPORT_DEVICE_LIST)
960 return 0;
961
962 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
963 int j = i * 6;
964 int serial = (data[j+6] << 16) + (data[j+5] << 8) + data[j+4];
965 bool connected = data[j+2];
966
967 if (connected) {
968 int k;
969
970 if (wacom_wac->serial[i] == serial)
971 continue;
972
973 if (wacom_wac->serial[i]) {
974 wacom_remote_destroy_attr_group(wacom,
975 wacom_wac->serial[i]);
976 }
977
978 /* A remote can pair more than once with an EKR,
979 * check to make sure this serial isn't already paired.
980 */
981 for (k = 0; k < WACOM_MAX_REMOTES; k++) {
982 if (wacom_wac->serial[k] == serial)
983 break;
984 }
985
986 if (k < WACOM_MAX_REMOTES) {
987 wacom_wac->serial[i] = serial;
988 continue;
989 }
990 wacom_remote_create_attr_group(wacom, serial, i);
991
992 } else if (wacom_wac->serial[i]) {
993 wacom_remote_destroy_attr_group(wacom,
994 wacom_wac->serial[i]);
995 }
996 }
997
998 return 0;
999}
1000
95dd3b30 1001static void wacom_intuos_general(struct wacom_wac *wacom)
3bea733a 1002{
e33da8a5 1003 struct wacom_features *features = &wacom->features;
3bea733a 1004 unsigned char *data = wacom->data;
2a6cdbdd 1005 struct input_dev *input = wacom->pen_input;
3bea733a
PC
1006 unsigned int t;
1007
1008 /* general pen packet */
1009 if ((data[1] & 0xb8) == 0xa0) {
1010 t = (data[6] << 2) | ((data[7] >> 6) & 3);
8d515fda 1011 if (features->pressure_max == 2047) {
6f660f12 1012 t = (t << 1) | (data[1] & 1);
ca047fed 1013 }
8da23fc1 1014 input_report_abs(input, ABS_PRESSURE, t);
eda01dab
PC
1015 if (features->type != INTUOSHT2) {
1016 input_report_abs(input, ABS_TILT_X,
ec5fc1c1 1017 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
eda01dab
PC
1018 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
1019 }
8da23fc1
DT
1020 input_report_key(input, BTN_STYLUS, data[1] & 2);
1021 input_report_key(input, BTN_STYLUS2, data[1] & 4);
1022 input_report_key(input, BTN_TOUCH, t > 10);
3bea733a
PC
1023 }
1024
1025 /* airbrush second packet */
1026 if ((data[1] & 0xbc) == 0xb4) {
8da23fc1 1027 input_report_abs(input, ABS_WHEEL,
3bea733a 1028 (data[6] << 2) | ((data[7] >> 6) & 3));
8da23fc1 1029 input_report_abs(input, ABS_TILT_X,
ec5fc1c1
JG
1030 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
1031 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
3bea733a 1032 }
3bea733a
PC
1033}
1034
95dd3b30 1035static int wacom_intuos_irq(struct wacom_wac *wacom)
3bea733a 1036{
e33da8a5 1037 struct wacom_features *features = &wacom->features;
3bea733a 1038 unsigned char *data = wacom->data;
2a6cdbdd 1039 struct input_dev *input = wacom->pen_input;
3bea733a 1040 unsigned int t;
6f660f12 1041 int idx = 0, result;
3bea733a 1042
eb71d1bb
DT
1043 if (data[0] != WACOM_REPORT_PENABLED &&
1044 data[0] != WACOM_REPORT_INTUOSREAD &&
1045 data[0] != WACOM_REPORT_INTUOSWRITE &&
1046 data[0] != WACOM_REPORT_INTUOSPAD &&
eda01dab 1047 data[0] != WACOM_REPORT_INTUOS_PEN &&
500d4160
PC
1048 data[0] != WACOM_REPORT_CINTIQ &&
1049 data[0] != WACOM_REPORT_CINTIQPAD &&
eb71d1bb
DT
1050 data[0] != WACOM_REPORT_INTUOS5PAD) {
1051 dev_dbg(input->dev.parent,
1052 "%s: received unknown report #%d\n", __func__, data[0]);
3bea733a
PC
1053 return 0;
1054 }
1055
3bea733a 1056 /* tool number */
e33da8a5 1057 if (features->type == INTUOS)
6f660f12 1058 idx = data[1] & 0x01;
3bea733a 1059
fb013a01
JG
1060 /* process pad events */
1061 result = wacom_intuos_pad(wacom);
1062 if (result)
1063 return result;
3bea733a
PC
1064
1065 /* process in/out prox events */
95dd3b30 1066 result = wacom_intuos_inout(wacom);
3bea733a 1067 if (result)
73a97f4f 1068 return result - 1;
3bea733a 1069
e33da8a5 1070 if (features->type >= INTUOS3S) {
8da23fc1
DT
1071 input_report_abs(input, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
1072 input_report_abs(input, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
1073 input_report_abs(input, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
3bea733a 1074 } else {
252f7769
DT
1075 input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[2]));
1076 input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[4]));
8da23fc1 1077 input_report_abs(input, ABS_DISTANCE, ((data[9] >> 3) & 0x1f));
3bea733a
PC
1078 }
1079
1080 /* process general packets */
95dd3b30 1081 wacom_intuos_general(wacom);
3bea733a 1082
6f660f12
PC
1083 /* 4D mouse, 2D mouse, marker pen rotation, tilt mouse, or Lens cursor packets */
1084 if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0 || (data[1] & 0xbc) == 0xac) {
3bea733a
PC
1085
1086 if (data[1] & 0x02) {
1087 /* Rotation packet */
e33da8a5 1088 if (features->type >= INTUOS3S) {
0e1763f5 1089 /* I3 marker pen rotation */
3bea733a
PC
1090 t = (data[6] << 3) | ((data[7] >> 5) & 7);
1091 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
1092 ((t-1) / 2 + 450)) : (450 - t / 2) ;
8da23fc1 1093 input_report_abs(input, ABS_Z, t);
3bea733a
PC
1094 } else {
1095 /* 4D mouse rotation packet */
1096 t = (data[6] << 3) | ((data[7] >> 5) & 7);
8da23fc1 1097 input_report_abs(input, ABS_RZ, (data[7] & 0x20) ?
3bea733a
PC
1098 ((t - 1) / 2) : -t / 2);
1099 }
1100
e33da8a5 1101 } else if (!(data[1] & 0x10) && features->type < INTUOS3S) {
3bea733a 1102 /* 4D mouse packet */
8da23fc1
DT
1103 input_report_key(input, BTN_LEFT, data[8] & 0x01);
1104 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
1105 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
3bea733a 1106
8da23fc1
DT
1107 input_report_key(input, BTN_SIDE, data[8] & 0x20);
1108 input_report_key(input, BTN_EXTRA, data[8] & 0x10);
3bea733a 1109 t = (data[6] << 2) | ((data[7] >> 6) & 3);
8da23fc1 1110 input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
3bea733a
PC
1111
1112 } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
6f660f12 1113 /* I4 mouse */
9a35c411 1114 if (features->type >= INTUOS4S && features->type <= INTUOSPL) {
8da23fc1
DT
1115 input_report_key(input, BTN_LEFT, data[6] & 0x01);
1116 input_report_key(input, BTN_MIDDLE, data[6] & 0x02);
1117 input_report_key(input, BTN_RIGHT, data[6] & 0x04);
1118 input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7)
6f660f12 1119 - ((data[7] & 0x40) >> 6));
8da23fc1
DT
1120 input_report_key(input, BTN_SIDE, data[6] & 0x08);
1121 input_report_key(input, BTN_EXTRA, data[6] & 0x10);
6f660f12 1122
8da23fc1 1123 input_report_abs(input, ABS_TILT_X,
ec5fc1c1
JG
1124 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
1125 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
6f660f12
PC
1126 } else {
1127 /* 2D mouse packet */
8da23fc1
DT
1128 input_report_key(input, BTN_LEFT, data[8] & 0x04);
1129 input_report_key(input, BTN_MIDDLE, data[8] & 0x08);
1130 input_report_key(input, BTN_RIGHT, data[8] & 0x10);
1131 input_report_rel(input, REL_WHEEL, (data[8] & 0x01)
3bea733a
PC
1132 - ((data[8] & 0x02) >> 1));
1133
6f660f12 1134 /* I3 2D mouse side buttons */
e33da8a5 1135 if (features->type >= INTUOS3S && features->type <= INTUOS3L) {
8da23fc1
DT
1136 input_report_key(input, BTN_SIDE, data[8] & 0x40);
1137 input_report_key(input, BTN_EXTRA, data[8] & 0x20);
6f660f12 1138 }
3bea733a 1139 }
e33da8a5 1140 } else if ((features->type < INTUOS3S || features->type == INTUOS3L ||
9a35c411
PC
1141 features->type == INTUOS4L || features->type == INTUOS5L ||
1142 features->type == INTUOSPL) &&
6f660f12 1143 wacom->tool[idx] == BTN_TOOL_LENS) {
3bea733a 1144 /* Lens cursor packets */
8da23fc1
DT
1145 input_report_key(input, BTN_LEFT, data[8] & 0x01);
1146 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
1147 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
1148 input_report_key(input, BTN_SIDE, data[8] & 0x10);
1149 input_report_key(input, BTN_EXTRA, data[8] & 0x08);
3bea733a
PC
1150 }
1151 }
1152
8da23fc1
DT
1153 input_report_abs(input, ABS_MISC, wacom->id[idx]); /* report tool id */
1154 input_report_key(input, wacom->tool[idx], 1);
1155 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
b3bd7ef3 1156 wacom->reporting_data = true;
3bea733a
PC
1157 return 1;
1158}
1159
b1e4279e
JG
1160static int int_dist(int x1, int y1, int x2, int y2)
1161{
1162 int x = x2 - x1;
1163 int y = y2 - y1;
1164
1165 return int_sqrt(x*x + y*y);
1166}
1167
81af7e61
BT
1168static void wacom_intuos_bt_process_data(struct wacom_wac *wacom,
1169 unsigned char *data)
1170{
1171 memcpy(wacom->data, data, 10);
1172 wacom_intuos_irq(wacom);
1173
2a6cdbdd 1174 input_sync(wacom->pen_input);
81af7e61
BT
1175 if (wacom->pad_input)
1176 input_sync(wacom->pad_input);
1177}
1178
1179static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
1180{
1181 unsigned char data[WACOM_PKGLEN_MAX];
1182 int i = 1;
1183 unsigned power_raw, battery_capacity, bat_charging, ps_connected;
1184
1185 memcpy(data, wacom->data, len);
1186
1187 switch (data[0]) {
1188 case 0x04:
1189 wacom_intuos_bt_process_data(wacom, data + i);
1190 i += 10;
1191 /* fall through */
1192 case 0x03:
1193 wacom_intuos_bt_process_data(wacom, data + i);
1194 i += 10;
1195 wacom_intuos_bt_process_data(wacom, data + i);
1196 i += 10;
1197 power_raw = data[i];
1198 bat_charging = (power_raw & 0x08) ? 1 : 0;
1199 ps_connected = (power_raw & 0x10) ? 1 : 0;
1200 battery_capacity = batcap_i4[power_raw & 0x07];
953f2c5f 1201 wacom_notify_battery(wacom, battery_capacity, bat_charging,
71fa641e 1202 battery_capacity || bat_charging,
953f2c5f 1203 ps_connected);
81af7e61
BT
1204 break;
1205 default:
2a6cdbdd 1206 dev_dbg(wacom->pen_input->dev.parent,
81af7e61
BT
1207 "Unknown report: %d,%d size:%zu\n",
1208 data[0], data[1], len);
1209 return 0;
1210 }
1211 return 0;
1212}
1213
7d059ed0
PC
1214static int wacom_wac_finger_count_touches(struct wacom_wac *wacom)
1215{
2a6cdbdd 1216 struct input_dev *input = wacom->touch_input;
7d059ed0
PC
1217 unsigned touch_max = wacom->features.touch_max;
1218 int count = 0;
1219 int i;
1220
26ba61f8
PC
1221 if (!touch_max)
1222 return 0;
1223
71b5c476
JG
1224 if (touch_max == 1)
1225 return test_bit(BTN_TOUCH, input->key) &&
7d059ed0
PC
1226 !wacom->shared->stylus_in_proximity;
1227
1228 for (i = 0; i < input->mt->num_slots; i++) {
1229 struct input_mt_slot *ps = &input->mt->slots[i];
1230 int id = input_mt_get_value(ps, ABS_MT_TRACKING_ID);
1231 if (id >= 0)
1232 count++;
1233 }
1234
1235 return count;
1236}
1237
b1e4279e
JG
1238static int wacom_24hdt_irq(struct wacom_wac *wacom)
1239{
2a6cdbdd 1240 struct input_dev *input = wacom->touch_input;
74b63417 1241 unsigned char *data = wacom->data;
b1e4279e 1242 int i;
e0d41fd4 1243 int current_num_contacts = data[61];
b1e4279e 1244 int contacts_to_send = 0;
500d4160
PC
1245 int num_contacts_left = 4; /* maximum contacts per packet */
1246 int byte_per_packet = WACOM_BYTES_PER_24HDT_PACKET;
1247 int y_offset = 2;
1248
1249 if (wacom->features.type == WACOM_27QHDT) {
1250 current_num_contacts = data[63];
1251 num_contacts_left = 10;
1252 byte_per_packet = WACOM_BYTES_PER_QHDTHID_PACKET;
1253 y_offset = 0;
500d4160 1254 }
b1e4279e
JG
1255
1256 /*
1257 * First packet resets the counter since only the first
1258 * packet in series will have non-zero current_num_contacts.
1259 */
7d059ed0 1260 if (current_num_contacts)
b1e4279e
JG
1261 wacom->num_contacts_left = current_num_contacts;
1262
500d4160 1263 contacts_to_send = min(num_contacts_left, wacom->num_contacts_left);
b1e4279e
JG
1264
1265 for (i = 0; i < contacts_to_send; i++) {
500d4160 1266 int offset = (byte_per_packet * i) + 1;
9b61aa86 1267 bool touch = (data[offset] & 0x1) && !wacom->shared->stylus_in_proximity;
02295e68 1268 int slot = input_mt_get_slot_by_key(input, data[offset + 1]);
b1e4279e
JG
1269
1270 if (slot < 0)
1271 continue;
1272 input_mt_slot(input, slot);
1273 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1274
1275 if (touch) {
edc8e20a 1276 int t_x = get_unaligned_le16(&data[offset + 2]);
500d4160 1277 int t_y = get_unaligned_le16(&data[offset + 4 + y_offset]);
b1e4279e
JG
1278
1279 input_report_abs(input, ABS_MT_POSITION_X, t_x);
1280 input_report_abs(input, ABS_MT_POSITION_Y, t_y);
500d4160
PC
1281
1282 if (wacom->features.type != WACOM_27QHDT) {
1283 int c_x = get_unaligned_le16(&data[offset + 4]);
1284 int c_y = get_unaligned_le16(&data[offset + 8]);
1285 int w = get_unaligned_le16(&data[offset + 10]);
1286 int h = get_unaligned_le16(&data[offset + 12]);
1287
1288 input_report_abs(input, ABS_MT_TOUCH_MAJOR, min(w,h));
1289 input_report_abs(input, ABS_MT_WIDTH_MAJOR,
1290 min(w, h) + int_dist(t_x, t_y, c_x, c_y));
1291 input_report_abs(input, ABS_MT_WIDTH_MINOR, min(w, h));
1292 input_report_abs(input, ABS_MT_ORIENTATION, w > h);
1293 }
b1e4279e 1294 }
b1e4279e 1295 }
9a1c0012 1296 input_mt_sync_frame(input);
b1e4279e
JG
1297
1298 wacom->num_contacts_left -= contacts_to_send;
e0d41fd4 1299 if (wacom->num_contacts_left <= 0) {
b1e4279e 1300 wacom->num_contacts_left = 0;
7d059ed0 1301 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
e0d41fd4 1302 }
b1e4279e
JG
1303 return 1;
1304}
1305
1963518b
PC
1306static int wacom_mt_touch(struct wacom_wac *wacom)
1307{
2a6cdbdd 1308 struct input_dev *input = wacom->touch_input;
74b63417 1309 unsigned char *data = wacom->data;
1963518b
PC
1310 int i;
1311 int current_num_contacts = data[2];
1312 int contacts_to_send = 0;
6afdc289
PC
1313 int x_offset = 0;
1314
1315 /* MTTPC does not support Height and Width */
d51ddb2b 1316 if (wacom->features.type == MTTPC || wacom->features.type == MTTPC_B)
6afdc289 1317 x_offset = -4;
1963518b
PC
1318
1319 /*
1320 * First packet resets the counter since only the first
1321 * packet in series will have non-zero current_num_contacts.
1322 */
7d059ed0 1323 if (current_num_contacts)
1963518b
PC
1324 wacom->num_contacts_left = current_num_contacts;
1325
1326 /* There are at most 5 contacts per packet */
1327 contacts_to_send = min(5, wacom->num_contacts_left);
1328
1329 for (i = 0; i < contacts_to_send; i++) {
6afdc289 1330 int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset) * i + 3;
9b61aa86 1331 bool touch = (data[offset] & 0x1) && !wacom->shared->stylus_in_proximity;
edc8e20a 1332 int id = get_unaligned_le16(&data[offset + 1]);
02295e68 1333 int slot = input_mt_get_slot_by_key(input, id);
1963518b
PC
1334
1335 if (slot < 0)
1336 continue;
1337
1338 input_mt_slot(input, slot);
1339 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1340 if (touch) {
edc8e20a
JG
1341 int x = get_unaligned_le16(&data[offset + x_offset + 7]);
1342 int y = get_unaligned_le16(&data[offset + x_offset + 9]);
1963518b
PC
1343 input_report_abs(input, ABS_MT_POSITION_X, x);
1344 input_report_abs(input, ABS_MT_POSITION_Y, y);
1345 }
1963518b 1346 }
9a1c0012 1347 input_mt_sync_frame(input);
1963518b
PC
1348
1349 wacom->num_contacts_left -= contacts_to_send;
e0d41fd4 1350 if (wacom->num_contacts_left <= 0) {
1963518b 1351 wacom->num_contacts_left = 0;
7d059ed0 1352 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
e0d41fd4 1353 }
1963518b
PC
1354 return 1;
1355}
1356
84eb5aa6
PC
1357static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
1358{
2a6cdbdd 1359 struct input_dev *input = wacom->touch_input;
84eb5aa6 1360 unsigned char *data = wacom->data;
84eb5aa6
PC
1361 int i;
1362
1363 for (i = 0; i < 2; i++) {
1364 int p = data[1] & (1 << i);
1365 bool touch = p && !wacom->shared->stylus_in_proximity;
1366
1367 input_mt_slot(input, i);
1368 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1369 if (touch) {
1370 int x = le16_to_cpup((__le16 *)&data[i * 2 + 2]) & 0x7fff;
1371 int y = le16_to_cpup((__le16 *)&data[i * 2 + 6]) & 0x7fff;
1372
1373 input_report_abs(input, ABS_MT_POSITION_X, x);
1374 input_report_abs(input, ABS_MT_POSITION_Y, y);
84eb5aa6
PC
1375 }
1376 }
9a1c0012 1377 input_mt_sync_frame(input);
84eb5aa6
PC
1378
1379 /* keep touch state for pen event */
7d059ed0 1380 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
84eb5aa6 1381
84eb5aa6
PC
1382 return 1;
1383}
1384
a43c7c53 1385static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
ec67bbed 1386{
74b63417 1387 unsigned char *data = wacom->data;
2a6cdbdd 1388 struct input_dev *input = wacom->touch_input;
e0d41fd4 1389 bool prox = !wacom->shared->stylus_in_proximity;
a43c7c53 1390 int x = 0, y = 0;
ec67bbed 1391
1963518b
PC
1392 if (wacom->features.touch_max > 1 || len > WACOM_PKGLEN_TPC2FG)
1393 return 0;
1394
e0d41fd4
PC
1395 if (len == WACOM_PKGLEN_TPC1FG) {
1396 prox = prox && (data[0] & 0x01);
1397 x = get_unaligned_le16(&data[1]);
1398 y = get_unaligned_le16(&data[3]);
1399 } else if (len == WACOM_PKGLEN_TPC1FG_B) {
1400 prox = prox && (data[2] & 0x01);
1401 x = get_unaligned_le16(&data[3]);
1402 y = get_unaligned_le16(&data[5]);
1403 } else {
1404 prox = prox && (data[1] & 0x01);
1405 x = le16_to_cpup((__le16 *)&data[2]);
1406 y = le16_to_cpup((__le16 *)&data[4]);
1407 }
ec67bbed 1408
a43c7c53
PC
1409 if (prox) {
1410 input_report_abs(input, ABS_X, x);
1411 input_report_abs(input, ABS_Y, y);
1412 }
1413 input_report_key(input, BTN_TOUCH, prox);
73a97f4f 1414
a43c7c53
PC
1415 /* keep touch state for pen events */
1416 wacom->shared->touch_down = prox;
ec67bbed 1417
a43c7c53 1418 return 1;
ec67bbed
PC
1419}
1420
8aa9a9ac 1421static int wacom_tpc_pen(struct wacom_wac *wacom)
545f4e99 1422{
74b63417 1423 unsigned char *data = wacom->data;
2a6cdbdd 1424 struct input_dev *input = wacom->pen_input;
a43c7c53 1425 bool prox = data[1] & 0x20;
8aa9a9ac 1426
a43c7c53 1427 if (!wacom->shared->stylus_in_proximity) /* first in prox */
8aa9a9ac
PC
1428 /* Going into proximity select tool */
1429 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
8aa9a9ac 1430
a43c7c53
PC
1431 /* keep pen state for touch events */
1432 wacom->shared->stylus_in_proximity = prox;
1433
1434 /* send pen events only when touch is up or forced out */
1435 if (!wacom->shared->touch_down) {
1436 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
1437 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
1438 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
1439 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
0b335cad 1440 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x07) << 8) | data[6]);
a43c7c53
PC
1441 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
1442 input_report_key(input, wacom->tool[0], prox);
1443 return 1;
8aa9a9ac 1444 }
8aa9a9ac 1445
a43c7c53 1446 return 0;
8aa9a9ac
PC
1447}
1448
1449static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
1450{
74b63417 1451 unsigned char *data = wacom->data;
545f4e99 1452
2a6cdbdd
JG
1453 if (wacom->pen_input)
1454 dev_dbg(wacom->pen_input->dev.parent,
1455 "%s: received report #%d\n", __func__, data[0]);
1456 else if (wacom->touch_input)
1457 dev_dbg(wacom->touch_input->dev.parent,
1458 "%s: received report #%d\n", __func__, data[0]);
545f4e99 1459
31175a83
PC
1460 switch (len) {
1461 case WACOM_PKGLEN_TPC1FG:
1963518b 1462 return wacom_tpc_single_touch(wacom, len);
31175a83
PC
1463
1464 case WACOM_PKGLEN_TPC2FG:
1963518b 1465 return wacom_tpc_mt_touch(wacom);
31175a83 1466
d51ddb2b
JG
1467 case WACOM_PKGLEN_PENABLED:
1468 return wacom_tpc_pen(wacom);
1469
31175a83
PC
1470 default:
1471 switch (data[0]) {
1472 case WACOM_REPORT_TPC1FG:
1473 case WACOM_REPORT_TPCHID:
1474 case WACOM_REPORT_TPCST:
ac173837 1475 case WACOM_REPORT_TPC1FGE:
31175a83
PC
1476 return wacom_tpc_single_touch(wacom, len);
1477
1963518b 1478 case WACOM_REPORT_TPCMT:
d51ddb2b 1479 case WACOM_REPORT_TPCMT2:
1963518b
PC
1480 return wacom_mt_touch(wacom);
1481
31175a83
PC
1482 case WACOM_REPORT_PENABLED:
1483 return wacom_tpc_pen(wacom);
1484 }
1485 }
4492efff 1486
8aa9a9ac 1487 return 0;
545f4e99
PC
1488}
1489
2a6cdbdd 1490static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
7704ac93
BT
1491 struct hid_field *field, __u8 type, __u16 code, int fuzz)
1492{
7704ac93
BT
1493 int fmin = field->logical_minimum;
1494 int fmax = field->logical_maximum;
1495
1496 usage->type = type;
1497 usage->code = code;
1498
1499 set_bit(type, input->evbit);
1500
1501 switch (type) {
1502 case EV_ABS:
1503 input_set_abs_params(input, code, fmin, fmax, fuzz, 0);
1504 input_abs_set_res(input, code,
1505 hidinput_calc_abs_res(field, code));
1506 break;
1507 case EV_KEY:
1508 input_set_capability(input, EV_KEY, code);
1509 break;
1510 case EV_MSC:
1511 input_set_capability(input, EV_MSC, code);
1512 break;
1513 }
1514}
1515
1516static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
1517 struct hid_field *field, struct hid_usage *usage)
1518{
1519 struct wacom *wacom = hid_get_drvdata(hdev);
2a6cdbdd
JG
1520 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1521 struct input_dev *input = wacom_wac->pen_input;
7704ac93
BT
1522
1523 switch (usage->hid) {
1524 case HID_GD_X:
2a6cdbdd 1525 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
7704ac93
BT
1526 break;
1527 case HID_GD_Y:
2a6cdbdd 1528 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
7704ac93
BT
1529 break;
1530 case HID_DG_TIPPRESSURE:
2a6cdbdd 1531 wacom_map_usage(input, usage, field, EV_ABS, ABS_PRESSURE, 0);
7704ac93
BT
1532 break;
1533 case HID_DG_INRANGE:
2a6cdbdd 1534 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
7704ac93
BT
1535 break;
1536 case HID_DG_INVERT:
2a6cdbdd 1537 wacom_map_usage(input, usage, field, EV_KEY,
7704ac93
BT
1538 BTN_TOOL_RUBBER, 0);
1539 break;
1540 case HID_DG_ERASER:
1541 case HID_DG_TIPSWITCH:
2a6cdbdd 1542 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
7704ac93
BT
1543 break;
1544 case HID_DG_BARRELSWITCH:
2a6cdbdd 1545 wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS, 0);
7704ac93
BT
1546 break;
1547 case HID_DG_BARRELSWITCH2:
2a6cdbdd 1548 wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS2, 0);
7704ac93
BT
1549 break;
1550 case HID_DG_TOOLSERIALNUMBER:
2a6cdbdd 1551 wacom_map_usage(input, usage, field, EV_MSC, MSC_SERIAL, 0);
7704ac93
BT
1552 break;
1553 }
1554}
1555
1556static int wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field,
1557 struct hid_usage *usage, __s32 value)
1558{
1559 struct wacom *wacom = hid_get_drvdata(hdev);
1560 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2a6cdbdd 1561 struct input_dev *input = wacom_wac->pen_input;
7704ac93
BT
1562
1563 /* checking which Tool / tip switch to send */
1564 switch (usage->hid) {
1565 case HID_DG_INRANGE:
1566 wacom_wac->hid_data.inrange_state = value;
1567 return 0;
1568 case HID_DG_INVERT:
1569 wacom_wac->hid_data.invert_state = value;
1570 return 0;
1571 case HID_DG_ERASER:
1572 case HID_DG_TIPSWITCH:
1573 wacom_wac->hid_data.tipswitch |= value;
1574 return 0;
1575 }
1576
1577 /* send pen events only when touch is up or forced out */
1578 if (!usage->type || wacom_wac->shared->touch_down)
1579 return 0;
1580
1581 input_event(input, usage->type, usage->code, value);
1582
1583 return 0;
1584}
1585
06324e0c
JG
1586static void wacom_wac_pen_pre_report(struct hid_device *hdev,
1587 struct hid_report *report)
1588{
1589 return;
1590}
1591
7704ac93
BT
1592static void wacom_wac_pen_report(struct hid_device *hdev,
1593 struct hid_report *report)
1594{
1595 struct wacom *wacom = hid_get_drvdata(hdev);
1596 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2a6cdbdd 1597 struct input_dev *input = wacom_wac->pen_input;
7704ac93
BT
1598 bool prox = wacom_wac->hid_data.inrange_state;
1599
1600 if (!wacom_wac->shared->stylus_in_proximity) /* first in prox */
1601 /* Going into proximity select tool */
1602 wacom_wac->tool[0] = wacom_wac->hid_data.invert_state ?
1603 BTN_TOOL_RUBBER : BTN_TOOL_PEN;
1604
1605 /* keep pen state for touch events */
1606 wacom_wac->shared->stylus_in_proximity = prox;
1607
1608 /* send pen events only when touch is up or forced out */
1609 if (!wacom_wac->shared->touch_down) {
1610 input_report_key(input, BTN_TOUCH,
1611 wacom_wac->hid_data.tipswitch);
1612 input_report_key(input, wacom_wac->tool[0], prox);
1613
1614 wacom_wac->hid_data.tipswitch = false;
1615
1616 input_sync(input);
1617 }
1618}
1619
5ae6e89f
BT
1620static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
1621 struct hid_field *field, struct hid_usage *usage)
1622{
1623 struct wacom *wacom = hid_get_drvdata(hdev);
1624 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
601a22f3 1625 struct wacom_features *features = &wacom_wac->features;
2a6cdbdd 1626 struct input_dev *input = wacom_wac->touch_input;
5ae6e89f
BT
1627 unsigned touch_max = wacom_wac->features.touch_max;
1628
1629 switch (usage->hid) {
1630 case HID_GD_X:
601a22f3 1631 features->last_slot_field = usage->hid;
5ae6e89f 1632 if (touch_max == 1)
2a6cdbdd 1633 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
5ae6e89f 1634 else
2a6cdbdd 1635 wacom_map_usage(input, usage, field, EV_ABS,
5ae6e89f
BT
1636 ABS_MT_POSITION_X, 4);
1637 break;
1638 case HID_GD_Y:
601a22f3 1639 features->last_slot_field = usage->hid;
5ae6e89f 1640 if (touch_max == 1)
2a6cdbdd 1641 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
5ae6e89f 1642 else
2a6cdbdd 1643 wacom_map_usage(input, usage, field, EV_ABS,
5ae6e89f
BT
1644 ABS_MT_POSITION_Y, 4);
1645 break;
488abb5c
JG
1646 case HID_DG_WIDTH:
1647 case HID_DG_HEIGHT:
1648 features->last_slot_field = usage->hid;
1649 wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MAJOR, 0);
1650 wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MINOR, 0);
1651 input_set_abs_params(input, ABS_MT_ORIENTATION, 0, 1, 0, 0);
1652 break;
5ae6e89f 1653 case HID_DG_CONTACTID:
601a22f3 1654 features->last_slot_field = usage->hid;
5ae6e89f
BT
1655 break;
1656 case HID_DG_INRANGE:
601a22f3 1657 features->last_slot_field = usage->hid;
5ae6e89f
BT
1658 break;
1659 case HID_DG_INVERT:
601a22f3 1660 features->last_slot_field = usage->hid;
5ae6e89f
BT
1661 break;
1662 case HID_DG_TIPSWITCH:
601a22f3 1663 features->last_slot_field = usage->hid;
2a6cdbdd 1664 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
5ae6e89f 1665 break;
1b5d514a 1666 case HID_DG_CONTACTCOUNT:
499522c8 1667 wacom_wac->hid_data.cc_report = field->report->id;
1b5d514a
JG
1668 wacom_wac->hid_data.cc_index = field->index;
1669 wacom_wac->hid_data.cc_value_index = usage->usage_index;
1670 break;
5ae6e89f
BT
1671 }
1672}
1673
601a22f3
JG
1674static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
1675 struct input_dev *input)
1676{
1677 struct hid_data *hid_data = &wacom_wac->hid_data;
1678 bool mt = wacom_wac->features.touch_max > 1;
1679 bool prox = hid_data->tipswitch &&
1680 !wacom_wac->shared->stylus_in_proximity;
1681
1b5d514a
JG
1682 wacom_wac->hid_data.num_received++;
1683 if (wacom_wac->hid_data.num_received > wacom_wac->hid_data.num_expected)
1684 return;
1685
601a22f3
JG
1686 if (mt) {
1687 int slot;
1688
1689 slot = input_mt_get_slot_by_key(input, hid_data->id);
1690 input_mt_slot(input, slot);
1691 input_mt_report_slot_state(input, MT_TOOL_FINGER, prox);
1692 }
1693 else {
1694 input_report_key(input, BTN_TOUCH, prox);
1695 }
1696
1697 if (prox) {
1698 input_report_abs(input, mt ? ABS_MT_POSITION_X : ABS_X,
1699 hid_data->x);
1700 input_report_abs(input, mt ? ABS_MT_POSITION_Y : ABS_Y,
1701 hid_data->y);
488abb5c
JG
1702
1703 if (test_bit(ABS_MT_TOUCH_MAJOR, input->absbit)) {
1704 input_report_abs(input, ABS_MT_TOUCH_MAJOR, max(hid_data->width, hid_data->height));
1705 input_report_abs(input, ABS_MT_TOUCH_MINOR, min(hid_data->width, hid_data->height));
1706 if (hid_data->width != hid_data->height)
1707 input_report_abs(input, ABS_MT_ORIENTATION, hid_data->width <= hid_data->height ? 0 : 1);
1708 }
601a22f3
JG
1709 }
1710}
1711
5ae6e89f
BT
1712static int wacom_wac_finger_event(struct hid_device *hdev,
1713 struct hid_field *field, struct hid_usage *usage, __s32 value)
1714{
1715 struct wacom *wacom = hid_get_drvdata(hdev);
1716 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1717
1718 switch (usage->hid) {
1719 case HID_GD_X:
1720 wacom_wac->hid_data.x = value;
1721 break;
1722 case HID_GD_Y:
1723 wacom_wac->hid_data.y = value;
1724 break;
488abb5c
JG
1725 case HID_DG_WIDTH:
1726 wacom_wac->hid_data.width = value;
1727 break;
1728 case HID_DG_HEIGHT:
1729 wacom_wac->hid_data.height = value;
1730 break;
5ae6e89f
BT
1731 case HID_DG_CONTACTID:
1732 wacom_wac->hid_data.id = value;
1733 break;
1734 case HID_DG_TIPSWITCH:
1735 wacom_wac->hid_data.tipswitch = value;
1736 break;
1737 }
1738
1739
601a22f3
JG
1740 if (usage->usage_index + 1 == field->report_count) {
1741 if (usage->hid == wacom_wac->features.last_slot_field)
2a6cdbdd 1742 wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
601a22f3
JG
1743 }
1744
5ae6e89f
BT
1745 return 0;
1746}
1747
06324e0c
JG
1748static void wacom_wac_finger_pre_report(struct hid_device *hdev,
1749 struct hid_report *report)
1750{
1b5d514a
JG
1751 struct wacom *wacom = hid_get_drvdata(hdev);
1752 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1753 struct hid_data* hid_data = &wacom_wac->hid_data;
1754
499522c8
JG
1755 if (hid_data->cc_report != 0 &&
1756 hid_data->cc_report != report->id) {
1757 int i;
1758
1759 hid_data->cc_report = report->id;
1760 hid_data->cc_index = -1;
1761 hid_data->cc_value_index = -1;
1762
1763 for (i = 0; i < report->maxfield; i++) {
1764 struct hid_field *field = report->field[i];
1765 int j;
1766
1767 for (j = 0; j < field->maxusage; j++) {
1768 if (field->usage[j].hid == HID_DG_CONTACTCOUNT) {
1769 hid_data->cc_index = i;
1770 hid_data->cc_value_index = j;
1771
1772 /* break */
1773 i = report->maxfield;
1774 j = field->maxusage;
1775 }
1776 }
1777 }
1778 }
df707938
JG
1779 if (hid_data->cc_report != 0 &&
1780 hid_data->cc_index >= 0) {
1b5d514a
JG
1781 struct hid_field *field = report->field[hid_data->cc_index];
1782 int value = field->value[hid_data->cc_value_index];
1783 if (value)
1784 hid_data->num_expected = value;
1785 }
1786 else {
1787 hid_data->num_expected = wacom_wac->features.touch_max;
1788 }
06324e0c
JG
1789}
1790
5ae6e89f
BT
1791static void wacom_wac_finger_report(struct hid_device *hdev,
1792 struct hid_report *report)
1793{
1794 struct wacom *wacom = hid_get_drvdata(hdev);
1795 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2a6cdbdd 1796 struct input_dev *input = wacom_wac->touch_input;
5ae6e89f
BT
1797 unsigned touch_max = wacom_wac->features.touch_max;
1798
1b5d514a
JG
1799 /* If more packets of data are expected, give us a chance to
1800 * process them rather than immediately syncing a partial
1801 * update.
1802 */
1803 if (wacom_wac->hid_data.num_received < wacom_wac->hid_data.num_expected)
1804 return;
1805
5ae6e89f 1806 if (touch_max > 1)
601a22f3
JG
1807 input_mt_sync_frame(input);
1808
5ae6e89f 1809 input_sync(input);
1b5d514a 1810 wacom_wac->hid_data.num_received = 0;
5ae6e89f
BT
1811
1812 /* keep touch state for pen event */
7d059ed0 1813 wacom_wac->shared->touch_down = wacom_wac_finger_count_touches(wacom_wac);
5ae6e89f
BT
1814}
1815
7704ac93
BT
1816void wacom_wac_usage_mapping(struct hid_device *hdev,
1817 struct hid_field *field, struct hid_usage *usage)
1818{
1819 struct wacom *wacom = hid_get_drvdata(hdev);
1820 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
7704ac93
BT
1821
1822 /* currently, only direct devices have proper hid report descriptors */
2a6cdbdd
JG
1823 __set_bit(INPUT_PROP_DIRECT, wacom_wac->pen_input->propbit);
1824 __set_bit(INPUT_PROP_DIRECT, wacom_wac->touch_input->propbit);
7704ac93
BT
1825
1826 if (WACOM_PEN_FIELD(field))
1827 return wacom_wac_pen_usage_mapping(hdev, field, usage);
5ae6e89f
BT
1828
1829 if (WACOM_FINGER_FIELD(field))
1830 return wacom_wac_finger_usage_mapping(hdev, field, usage);
7704ac93
BT
1831}
1832
1833int wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
1834 struct hid_usage *usage, __s32 value)
1835{
1836 struct wacom *wacom = hid_get_drvdata(hdev);
1837
1838 if (wacom->wacom_wac.features.type != HID_GENERIC)
1839 return 0;
1840
1841 if (WACOM_PEN_FIELD(field))
1842 return wacom_wac_pen_event(hdev, field, usage, value);
1843
5ae6e89f
BT
1844 if (WACOM_FINGER_FIELD(field))
1845 return wacom_wac_finger_event(hdev, field, usage, value);
1846
7704ac93
BT
1847 return 0;
1848}
1849
06324e0c
JG
1850static void wacom_report_events(struct hid_device *hdev, struct hid_report *report)
1851{
1852 int r;
1853
1854 for (r = 0; r < report->maxfield; r++) {
1855 struct hid_field *field;
1856 unsigned count, n;
1857
1858 field = report->field[r];
1859 count = field->report_count;
1860
1861 if (!(HID_MAIN_ITEM_VARIABLE & field->flags))
1862 continue;
1863
1864 for (n = 0; n < count; n++)
1865 wacom_wac_event(hdev, field, &field->usage[n], field->value[n]);
1866 }
1867}
1868
7704ac93
BT
1869void wacom_wac_report(struct hid_device *hdev, struct hid_report *report)
1870{
1871 struct wacom *wacom = hid_get_drvdata(hdev);
1872 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1873 struct hid_field *field = report->field[0];
1874
1875 if (wacom_wac->features.type != HID_GENERIC)
1876 return;
1877
06324e0c
JG
1878 if (WACOM_PEN_FIELD(field))
1879 wacom_wac_pen_pre_report(hdev, report);
1880
1881 if (WACOM_FINGER_FIELD(field))
1882 wacom_wac_finger_pre_report(hdev, report);
1883
1884 wacom_report_events(hdev, report);
1885
7704ac93
BT
1886 if (WACOM_PEN_FIELD(field))
1887 return wacom_wac_pen_report(hdev, report);
5ae6e89f
BT
1888
1889 if (WACOM_FINGER_FIELD(field))
1890 return wacom_wac_finger_report(hdev, report);
7704ac93
BT
1891}
1892
e1d38e49 1893static int wacom_bpt_touch(struct wacom_wac *wacom)
cb734c03 1894{
f4ccbef2 1895 struct wacom_features *features = &wacom->features;
2a6cdbdd 1896 struct input_dev *input = wacom->touch_input;
3116871f 1897 struct input_dev *pad_input = wacom->pad_input;
cb734c03 1898 unsigned char *data = wacom->data;
cb734c03
HR
1899 int i;
1900
5a6c865d
CB
1901 if (data[0] != 0x02)
1902 return 0;
1903
cb734c03 1904 for (i = 0; i < 2; i++) {
8f906860
CB
1905 int offset = (data[1] & 0x80) ? (8 * i) : (9 * i);
1906 bool touch = data[offset + 3] & 0x80;
c5f4dec1 1907
33d5f713
CB
1908 /*
1909 * Touch events need to be disabled while stylus is
1910 * in proximity because user's hand is resting on touchpad
1911 * and sending unwanted events. User expects tablet buttons
1912 * to continue working though.
1913 */
8f906860
CB
1914 touch = touch && !wacom->shared->stylus_in_proximity;
1915
1916 input_mt_slot(input, i);
1917 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
c5f4dec1 1918 if (touch) {
8f906860
CB
1919 int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff;
1920 int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff;
f4ccbef2
HR
1921 if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) {
1922 x <<= 5;
1923 y <<= 5;
1924 }
cb734c03
HR
1925 input_report_abs(input, ABS_MT_POSITION_X, x);
1926 input_report_abs(input, ABS_MT_POSITION_Y, y);
cb734c03 1927 }
cb734c03
HR
1928 }
1929
9a1c0012 1930 input_mt_sync_frame(input);
cb734c03 1931
3116871f
BT
1932 input_report_key(pad_input, BTN_LEFT, (data[1] & 0x08) != 0);
1933 input_report_key(pad_input, BTN_FORWARD, (data[1] & 0x04) != 0);
1934 input_report_key(pad_input, BTN_BACK, (data[1] & 0x02) != 0);
1935 input_report_key(pad_input, BTN_RIGHT, (data[1] & 0x01) != 0);
7d059ed0 1936 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
cb734c03 1937
3116871f 1938 return 1;
cb734c03
HR
1939}
1940
7d059ed0 1941static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
73149ab8 1942{
9a35c411 1943 struct wacom_features *features = &wacom->features;
2a6cdbdd 1944 struct input_dev *input = wacom->touch_input;
73149ab8 1945 bool touch = data[1] & 0x80;
02295e68
PC
1946 int slot = input_mt_get_slot_by_key(input, data[0]);
1947
1948 if (slot < 0)
7d059ed0 1949 return;
73149ab8
CB
1950
1951 touch = touch && !wacom->shared->stylus_in_proximity;
1952
02295e68 1953 input_mt_slot(input, slot);
73149ab8
CB
1954 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1955
1956 if (touch) {
1957 int x = (data[2] << 4) | (data[4] >> 4);
1958 int y = (data[3] << 4) | (data[4] & 0x0f);
9a35c411 1959 int width, height;
4e904954 1960
eda01dab 1961 if (features->type >= INTUOSPS && features->type <= INTUOSHT2) {
0b279da7
JG
1962 width = data[5] * 100;
1963 height = data[6] * 100;
9a35c411
PC
1964 } else {
1965 /*
1966 * "a" is a scaled-down area which we assume is
1967 * roughly circular and which can be described as:
1968 * a=(pi*r^2)/C.
1969 */
1970 int a = data[5];
d7da3a3c
PC
1971 int x_res = input_abs_get_res(input, ABS_MT_POSITION_X);
1972 int y_res = input_abs_get_res(input, ABS_MT_POSITION_Y);
1973 width = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE);
9a35c411
PC
1974 height = width * y_res / x_res;
1975 }
73149ab8
CB
1976
1977 input_report_abs(input, ABS_MT_POSITION_X, x);
1978 input_report_abs(input, ABS_MT_POSITION_Y, y);
4e904954
JG
1979 input_report_abs(input, ABS_MT_TOUCH_MAJOR, width);
1980 input_report_abs(input, ABS_MT_TOUCH_MINOR, height);
73149ab8
CB
1981 }
1982}
1983
1984static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
1985{
3116871f 1986 struct input_dev *input = wacom->pad_input;
b5fd2a3e 1987 struct wacom_features *features = &wacom->features;
73149ab8 1988
eda01dab 1989 if (features->type == INTUOSHT || features->type == INTUOSHT2) {
b5fd2a3e
PC
1990 input_report_key(input, BTN_LEFT, (data[1] & 0x02) != 0);
1991 input_report_key(input, BTN_BACK, (data[1] & 0x08) != 0);
1992 } else {
1993 input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
1994 input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
1995 }
73149ab8 1996 input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
73149ab8
CB
1997 input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
1998}
1999
2000static int wacom_bpt3_touch(struct wacom_wac *wacom)
2001{
73149ab8 2002 unsigned char *data = wacom->data;
19d57d3a 2003 int count = data[1] & 0x07;
eda01dab 2004 int touch_changed = 0, i;
73149ab8 2005
5a6c865d
CB
2006 if (data[0] != 0x02)
2007 return 0;
2008
73149ab8
CB
2009 /* data has up to 7 fixed sized 8-byte messages starting at data[2] */
2010 for (i = 0; i < count; i++) {
2011 int offset = (8 * i) + 2;
2012 int msg_id = data[offset];
2013
eda01dab 2014 if (msg_id >= 2 && msg_id <= 17) {
7d059ed0 2015 wacom_bpt3_touch_msg(wacom, data + offset);
eda01dab
PC
2016 touch_changed++;
2017 } else if (msg_id == 128)
73149ab8
CB
2018 wacom_bpt3_button_msg(wacom, data + offset);
2019
2020 }
2a6cdbdd 2021
eda01dab
PC
2022 /* only update touch if we actually have a touchpad and touch data changed */
2023 if (wacom->touch_registered && touch_changed) {
2a6cdbdd
JG
2024 input_mt_sync_frame(wacom->touch_input);
2025 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
2026 }
73149ab8 2027
3116871f 2028 return 1;
73149ab8
CB
2029}
2030
2aaacb15
CB
2031static int wacom_bpt_pen(struct wacom_wac *wacom)
2032{
961794a0 2033 struct wacom_features *features = &wacom->features;
2a6cdbdd 2034 struct input_dev *input = wacom->pen_input;
2aaacb15
CB
2035 unsigned char *data = wacom->data;
2036 int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
2037
4ca4ec71 2038 if (data[0] != WACOM_REPORT_PENABLED)
5a6c865d
CB
2039 return 0;
2040
c5981411 2041 prox = (data[1] & 0x20) == 0x20;
2aaacb15
CB
2042
2043 /*
2044 * All reports shared between PEN and RUBBER tool must be
2045 * forced to a known starting value (zero) when transitioning to
2046 * out-of-prox.
2047 *
2048 * If not reset then, to userspace, it will look like lost events
2049 * if new tool comes in-prox with same values as previous tool sent.
2050 *
2051 * Hardware does report zero in most out-of-prox cases but not all.
2052 */
0149931e
PC
2053 if (!wacom->shared->stylus_in_proximity) {
2054 if (data[1] & 0x08) {
2055 wacom->tool[0] = BTN_TOOL_RUBBER;
2056 wacom->id[0] = ERASER_DEVICE_ID;
2057 } else {
2058 wacom->tool[0] = BTN_TOOL_PEN;
2059 wacom->id[0] = STYLUS_DEVICE_ID;
2aaacb15 2060 }
0149931e
PC
2061 }
2062
2063 wacom->shared->stylus_in_proximity = prox;
2064 if (wacom->shared->touch_down)
2065 return 0;
2066
2067 if (prox) {
2aaacb15
CB
2068 x = le16_to_cpup((__le16 *)&data[2]);
2069 y = le16_to_cpup((__le16 *)&data[4]);
2070 p = le16_to_cpup((__le16 *)&data[6]);
c18c2cec
CB
2071 /*
2072 * Convert distance from out prox to distance from tablet.
2073 * distance will be greater than distance_max once
2074 * touching and applying pressure; do not report negative
2075 * distance.
2076 */
961794a0
PC
2077 if (data[8] <= features->distance_max)
2078 d = features->distance_max - data[8];
c18c2cec 2079
2aaacb15
CB
2080 pen = data[1] & 0x01;
2081 btn1 = data[1] & 0x02;
2082 btn2 = data[1] & 0x04;
0149931e
PC
2083 } else {
2084 wacom->id[0] = 0;
2aaacb15
CB
2085 }
2086
2087 input_report_key(input, BTN_TOUCH, pen);
2088 input_report_key(input, BTN_STYLUS, btn1);
2089 input_report_key(input, BTN_STYLUS2, btn2);
2090
2091 input_report_abs(input, ABS_X, x);
2092 input_report_abs(input, ABS_Y, y);
2093 input_report_abs(input, ABS_PRESSURE, p);
2094 input_report_abs(input, ABS_DISTANCE, d);
2095
2aaacb15
CB
2096 input_report_key(input, wacom->tool[0], prox); /* PEN or RUBBER */
2097 input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
2098
2099 return 1;
2100}
2101
e1d38e49
CB
2102static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
2103{
eda01dab
PC
2104 struct wacom_features *features = &wacom->features;
2105
2106 if ((features->type == INTUOSHT2) &&
eda01dab
PC
2107 (features->device_type & WACOM_DEVICETYPE_PEN))
2108 return wacom_intuos_irq(wacom);
2109 else if (len == WACOM_PKGLEN_BBTOUCH)
e1d38e49 2110 return wacom_bpt_touch(wacom);
73149ab8
CB
2111 else if (len == WACOM_PKGLEN_BBTOUCH3)
2112 return wacom_bpt3_touch(wacom);
2113 else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
2aaacb15 2114 return wacom_bpt_pen(wacom);
e1d38e49
CB
2115
2116 return 0;
2117}
2118
8c97a765
BT
2119static void wacom_bamboo_pad_pen_event(struct wacom_wac *wacom,
2120 unsigned char *data)
2121{
2122 unsigned char prefix;
2123
2124 /*
2125 * We need to reroute the event from the debug interface to the
2126 * pen interface.
2127 * We need to add the report ID to the actual pen report, so we
2128 * temporary overwrite the first byte to prevent having to kzalloc/kfree
2129 * and memcpy the report.
2130 */
2131 prefix = data[0];
2132 data[0] = WACOM_REPORT_BPAD_PEN;
2133
2134 /*
2135 * actually reroute the event.
2136 * No need to check if wacom->shared->pen is valid, hid_input_report()
2137 * will check for us.
2138 */
2139 hid_input_report(wacom->shared->pen, HID_INPUT_REPORT, data,
2140 WACOM_PKGLEN_PENABLED, 1);
2141
2142 data[0] = prefix;
2143}
2144
2145static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom,
2146 unsigned char *data)
2147{
2a6cdbdd 2148 struct input_dev *input = wacom->touch_input;
8c97a765
BT
2149 unsigned char *finger_data, prefix;
2150 unsigned id;
2151 int x, y;
2152 bool valid;
2153
2154 prefix = data[0];
2155
2156 for (id = 0; id < wacom->features.touch_max; id++) {
2157 valid = !!(prefix & BIT(id)) &&
2158 !wacom->shared->stylus_in_proximity;
2159
2160 input_mt_slot(input, id);
2161 input_mt_report_slot_state(input, MT_TOOL_FINGER, valid);
2162
2163 if (!valid)
2164 continue;
2165
2166 finger_data = data + 1 + id * 3;
2167 x = finger_data[0] | ((finger_data[1] & 0x0f) << 8);
2168 y = (finger_data[2] << 4) | (finger_data[1] >> 4);
2169
2170 input_report_abs(input, ABS_MT_POSITION_X, x);
2171 input_report_abs(input, ABS_MT_POSITION_Y, y);
2172 }
2173
2174 input_mt_sync_frame(input);
2175
2176 input_report_key(input, BTN_LEFT, prefix & 0x40);
2177 input_report_key(input, BTN_RIGHT, prefix & 0x80);
2178
2179 /* keep touch state for pen event */
2180 wacom->shared->touch_down = !!prefix &&
2181 !wacom->shared->stylus_in_proximity;
2182
2183 return 1;
2184}
2185
2186static int wacom_bamboo_pad_irq(struct wacom_wac *wacom, size_t len)
2187{
2188 unsigned char *data = wacom->data;
2189
2190 if (!((len == WACOM_PKGLEN_BPAD_TOUCH) ||
2191 (len == WACOM_PKGLEN_BPAD_TOUCH_USB)) ||
2192 (data[0] != WACOM_REPORT_BPAD_TOUCH))
2193 return 0;
2194
2195 if (data[1] & 0x01)
2196 wacom_bamboo_pad_pen_event(wacom, &data[1]);
2197
2198 if (data[1] & 0x02)
2199 return wacom_bamboo_pad_touch_event(wacom, &data[9]);
2200
2201 return 0;
2202}
2203
d3825d51
CB
2204static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
2205{
16bf288c
CB
2206 unsigned char *data = wacom->data;
2207 int connected;
2208
b5fd2a3e 2209 if (len != WACOM_PKGLEN_WIRELESS || data[0] != WACOM_REPORT_WL)
d3825d51
CB
2210 return 0;
2211
16bf288c
CB
2212 connected = data[1] & 0x01;
2213 if (connected) {
b0882cb7 2214 int pid, battery, charging;
16bf288c 2215
eda01dab
PC
2216 if ((wacom->shared->type == INTUOSHT ||
2217 wacom->shared->type == INTUOSHT2) &&
44b96838
PC
2218 wacom->shared->touch_input &&
2219 wacom->shared->touch_max) {
961794a0
PC
2220 input_report_switch(wacom->shared->touch_input,
2221 SW_MUTE_DEVICE, data[5] & 0x40);
2222 input_sync(wacom->shared->touch_input);
2223 }
2224
16bf288c 2225 pid = get_unaligned_be16(&data[6]);
ac8d1010 2226 battery = (data[5] & 0x3f) * 100 / 31;
b0882cb7 2227 charging = !!(data[5] & 0x80);
16bf288c
CB
2228 if (wacom->pid != pid) {
2229 wacom->pid = pid;
2230 wacom_schedule_work(wacom);
2231 }
ac8d1010 2232
953f2c5f 2233 if (wacom->shared->type)
71fa641e 2234 wacom_notify_battery(wacom, battery, charging, 1, 0);
953f2c5f 2235
16bf288c
CB
2236 } else if (wacom->pid != 0) {
2237 /* disconnected while previously connected */
2238 wacom->pid = 0;
2239 wacom_schedule_work(wacom);
71fa641e 2240 wacom_notify_battery(wacom, 0, 0, 0, 0);
16bf288c
CB
2241 }
2242
d3825d51
CB
2243 return 0;
2244}
2245
4ca4ec71
JG
2246static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
2247{
8f93b0b2 2248 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
4ca4ec71
JG
2249 struct wacom_features *features = &wacom_wac->features;
2250 unsigned char *data = wacom_wac->data;
2251
2252 if (data[0] != WACOM_REPORT_USB)
2253 return 0;
2254
eda01dab
PC
2255 if ((features->type == INTUOSHT ||
2256 features->type == INTUOSHT2) &&
4ca4ec71
JG
2257 wacom_wac->shared->touch_input &&
2258 features->touch_max) {
2259 input_report_switch(wacom_wac->shared->touch_input,
2260 SW_MUTE_DEVICE, data[8] & 0x40);
2261 input_sync(wacom_wac->shared->touch_input);
16bf288c
CB
2262 }
2263
8f93b0b2
JG
2264 if (data[9] & 0x02) { /* wireless module is attached */
2265 int battery = (data[8] & 0x3f) * 100 / 31;
b0882cb7 2266 bool charging = !!(data[8] & 0x80);
8f93b0b2
JG
2267
2268 wacom_notify_battery(wacom_wac, battery, charging,
71fa641e 2269 battery || charging, 1);
8f93b0b2 2270
8de29a35 2271 if (!wacom->battery &&
8f93b0b2
JG
2272 !(features->quirks & WACOM_QUIRK_BATTERY)) {
2273 features->quirks |= WACOM_QUIRK_BATTERY;
2274 INIT_WORK(&wacom->work, wacom_battery_work);
2275 wacom_schedule_work(wacom_wac);
2276 }
2277 }
2278 else if ((features->quirks & WACOM_QUIRK_BATTERY) &&
8de29a35 2279 wacom->battery) {
8f93b0b2
JG
2280 features->quirks &= ~WACOM_QUIRK_BATTERY;
2281 INIT_WORK(&wacom->work, wacom_battery_work);
2282 wacom_schedule_work(wacom_wac);
71fa641e 2283 wacom_notify_battery(wacom_wac, 0, 0, 0, 0);
8f93b0b2 2284 }
d3825d51
CB
2285 return 0;
2286}
2287
95dd3b30 2288void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
3bea733a 2289{
95dd3b30
DT
2290 bool sync;
2291
e33da8a5 2292 switch (wacom_wac->features.type) {
73a97f4f 2293 case PENPARTNER:
95dd3b30
DT
2294 sync = wacom_penpartner_irq(wacom_wac);
2295 break;
73a97f4f
DT
2296
2297 case PL:
95dd3b30
DT
2298 sync = wacom_pl_irq(wacom_wac);
2299 break;
73a97f4f
DT
2300
2301 case WACOM_G4:
2302 case GRAPHIRE:
387142bb 2303 case GRAPHIRE_BT:
73a97f4f 2304 case WACOM_MO:
95dd3b30
DT
2305 sync = wacom_graphire_irq(wacom_wac);
2306 break;
73a97f4f
DT
2307
2308 case PTU:
95dd3b30
DT
2309 sync = wacom_ptu_irq(wacom_wac);
2310 break;
73a97f4f 2311
c8f2edc5
PC
2312 case DTU:
2313 sync = wacom_dtu_irq(wacom_wac);
2314 break;
2315
497ab1f2 2316 case DTUS:
fff00bf8 2317 case DTUSX:
497ab1f2
PC
2318 sync = wacom_dtus_irq(wacom_wac);
2319 break;
2320
73a97f4f
DT
2321 case INTUOS:
2322 case INTUOS3S:
2323 case INTUOS3:
2324 case INTUOS3L:
2325 case INTUOS4S:
2326 case INTUOS4:
2327 case INTUOS4L:
2328 case CINTIQ:
2329 case WACOM_BEE:
56218563 2330 case WACOM_13HD:
3a4b4aaa 2331 case WACOM_21UX2:
d838c644 2332 case WACOM_22HD:
803296b6 2333 case WACOM_24HD:
500d4160 2334 case WACOM_27QHD:
a112e9fd 2335 case DTK:
36d3c510 2336 case CINTIQ_HYBRID:
f7acb55c 2337 case CINTIQ_COMPANION_2:
95dd3b30
DT
2338 sync = wacom_intuos_irq(wacom_wac);
2339 break;
73a97f4f 2340
81af7e61
BT
2341 case INTUOS4WL:
2342 sync = wacom_intuos_bt_irq(wacom_wac, len);
2343 break;
2344
b1e4279e 2345 case WACOM_24HDT:
500d4160 2346 case WACOM_27QHDT:
b1e4279e
JG
2347 sync = wacom_24hdt_irq(wacom_wac);
2348 break;
2349
ae584ca4
JG
2350 case INTUOS5S:
2351 case INTUOS5:
2352 case INTUOS5L:
9a35c411
PC
2353 case INTUOSPS:
2354 case INTUOSPM:
2355 case INTUOSPL:
ae584ca4
JG
2356 if (len == WACOM_PKGLEN_BBTOUCH3)
2357 sync = wacom_bpt3_touch(wacom_wac);
2d13a438
JG
2358 else if (wacom_wac->data[0] == WACOM_REPORT_USB)
2359 sync = wacom_status_irq(wacom_wac, len);
ae584ca4
JG
2360 else
2361 sync = wacom_intuos_irq(wacom_wac);
2362 break;
2363
73a97f4f 2364 case TABLETPC:
ac173837 2365 case TABLETPCE:
73a97f4f 2366 case TABLETPC2FG:
1963518b 2367 case MTSCREEN:
6afdc289 2368 case MTTPC:
d51ddb2b 2369 case MTTPC_B:
95dd3b30
DT
2370 sync = wacom_tpc_irq(wacom_wac, len);
2371 break;
73a97f4f 2372
cb734c03 2373 case BAMBOO_PT:
3b164a00
PC
2374 case BAMBOO_PEN:
2375 case BAMBOO_TOUCH:
b5fd2a3e 2376 case INTUOSHT:
eda01dab 2377 case INTUOSHT2:
4ca4ec71
JG
2378 if (wacom_wac->data[0] == WACOM_REPORT_USB)
2379 sync = wacom_status_irq(wacom_wac, len);
2380 else
2381 sync = wacom_bpt_irq(wacom_wac, len);
cb734c03
HR
2382 break;
2383
8c97a765
BT
2384 case BAMBOO_PAD:
2385 sync = wacom_bamboo_pad_irq(wacom_wac, len);
cb734c03
HR
2386 break;
2387
d3825d51
CB
2388 case WIRELESS:
2389 sync = wacom_wireless_irq(wacom_wac, len);
2390 break;
2391
72b236d6
AS
2392 case REMOTE:
2393 if (wacom_wac->data[0] == WACOM_REPORT_DEVICE_LIST)
2394 sync = wacom_remote_status_irq(wacom_wac, len);
2395 else
2396 sync = wacom_remote_irq(wacom_wac, len);
2397 break;
2398
73a97f4f 2399 default:
95dd3b30
DT
2400 sync = false;
2401 break;
3bea733a 2402 }
95dd3b30 2403
d2d13f18 2404 if (sync) {
2a6cdbdd
JG
2405 if (wacom_wac->pen_input)
2406 input_sync(wacom_wac->pen_input);
2407 if (wacom_wac->touch_input)
2408 input_sync(wacom_wac->touch_input);
d2d13f18
BT
2409 if (wacom_wac->pad_input)
2410 input_sync(wacom_wac->pad_input);
2411 }
3bea733a
PC
2412}
2413
eda01dab 2414static void wacom_setup_basic_pro_pen(struct wacom_wac *wacom_wac)
8da23fc1 2415{
2a6cdbdd 2416 struct input_dev *input_dev = wacom_wac->pen_input;
8da23fc1
DT
2417
2418 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
8da23fc1 2419
8da23fc1 2420 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
8da23fc1
DT
2421 __set_bit(BTN_STYLUS, input_dev->keybit);
2422 __set_bit(BTN_STYLUS2, input_dev->keybit);
2423
2424 input_set_abs_params(input_dev, ABS_DISTANCE,
2425 0, wacom_wac->features.distance_max, 0, 0);
eda01dab
PC
2426}
2427
2428static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
2429{
2430 struct input_dev *input_dev = wacom_wac->pen_input;
2431
2432 wacom_setup_basic_pro_pen(wacom_wac);
2433
2434 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
2435 __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
2436 __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
2437 __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
2438
8da23fc1 2439 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
ec5fc1c1 2440 input_set_abs_params(input_dev, ABS_TILT_X, -64, 63, 0, 0);
26fe4124 2441 input_abs_set_res(input_dev, ABS_TILT_X, 57);
ec5fc1c1 2442 input_set_abs_params(input_dev, ABS_TILT_Y, -64, 63, 0, 0);
26fe4124 2443 input_abs_set_res(input_dev, ABS_TILT_Y, 57);
6521d0bf
PC
2444}
2445
2446static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
2447{
2a6cdbdd 2448 struct input_dev *input_dev = wacom_wac->pen_input;
6521d0bf
PC
2449
2450 input_set_capability(input_dev, EV_REL, REL_WHEEL);
2451
2452 wacom_setup_cintiq(wacom_wac);
2453
2454 __set_bit(BTN_LEFT, input_dev->keybit);
2455 __set_bit(BTN_RIGHT, input_dev->keybit);
2456 __set_bit(BTN_MIDDLE, input_dev->keybit);
2457 __set_bit(BTN_SIDE, input_dev->keybit);
2458 __set_bit(BTN_EXTRA, input_dev->keybit);
2459 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
2460 __set_bit(BTN_TOOL_LENS, input_dev->keybit);
2461
8da23fc1 2462 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
26fe4124 2463 input_abs_set_res(input_dev, ABS_RZ, 287);
8da23fc1
DT
2464 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
2465}
2466
42f4f272 2467void wacom_setup_device_quirks(struct wacom *wacom)
bc73dd39 2468{
42f4f272 2469 struct wacom_features *features = &wacom->wacom_wac.features;
bc73dd39 2470
862cf553
JG
2471 /* The pen and pad share the same interface on most devices */
2472 if (features->type == GRAPHIRE_BT || features->type == WACOM_G4 ||
3b164a00
PC
2473 features->type == DTUS ||
2474 (features->type >= INTUOS3S && features->type <= WACOM_MO)) {
862cf553
JG
2475 if (features->device_type & WACOM_DEVICETYPE_PEN)
2476 features->device_type |= WACOM_DEVICETYPE_PAD;
2477 }
bc73dd39
HR
2478
2479 /* touch device found but size is not defined. use default */
aa86b18c 2480 if (features->device_type & WACOM_DEVICETYPE_TOUCH && !features->x_max) {
bc73dd39
HR
2481 features->x_max = 1023;
2482 features->y_max = 1023;
2483 }
2484
42f4f272
PC
2485 /*
2486 * Intuos5/Pro and Bamboo 3rd gen have no useful data about its
2487 * touch interface in its HID descriptor. If this is the touch
2488 * interface (PacketSize of WACOM_PKGLEN_BBTOUCH3), override the
2489 * tablet values.
2490 */
3b164a00
PC
2491 if ((features->type >= INTUOS5S && features->type <= INTUOSPL) ||
2492 (features->type >= INTUOSHT && features->type <= BAMBOO_PT)) {
42f4f272 2493 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
862cf553
JG
2494 if (features->touch_max)
2495 features->device_type |= WACOM_DEVICETYPE_TOUCH;
3b164a00 2496 if (features->type >= INTUOSHT || features->type <= BAMBOO_PT)
862cf553 2497 features->device_type |= WACOM_DEVICETYPE_PAD;
42f4f272
PC
2498
2499 features->x_max = 4096;
2500 features->y_max = 4096;
42f4f272 2501 }
9633920e
JG
2502 else if (features->pktlen == WACOM_PKGLEN_BBTOUCH) {
2503 features->device_type |= WACOM_DEVICETYPE_PAD;
2504 }
42f4f272
PC
2505 }
2506
2507 /*
042628ab
JG
2508 * Raw Wacom-mode pen and touch events both come from interface
2509 * 0, whose HID descriptor has an application usage of 0xFF0D
2510 * (i.e., WACOM_VENDORDEFINED_PEN). We route pen packets back
2511 * out through the HID_GENERIC device created for interface 1,
70caee0a 2512 * so rewrite this one to be of type WACOM_DEVICETYPE_TOUCH.
42f4f272
PC
2513 */
2514 if (features->type == BAMBOO_PAD)
70caee0a 2515 features->device_type = WACOM_DEVICETYPE_TOUCH;
42f4f272 2516
72b236d6
AS
2517 if (features->type == REMOTE)
2518 features->device_type = WACOM_DEVICETYPE_PAD;
42f4f272
PC
2519
2520 if (wacom->hdev->bus == BUS_BLUETOOTH)
2521 features->quirks |= WACOM_QUIRK_BATTERY;
2522
73149ab8 2523 /* quirk for bamboo touch with 2 low res touches */
cb734c03 2524 if (features->type == BAMBOO_PT &&
73149ab8 2525 features->pktlen == WACOM_PKGLEN_BBTOUCH) {
f4ccbef2
HR
2526 features->x_max <<= 5;
2527 features->y_max <<= 5;
2528 features->x_fuzz <<= 5;
2529 features->y_fuzz <<= 5;
f4ccbef2 2530 features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;
cb734c03 2531 }
d3825d51
CB
2532
2533 if (features->type == WIRELESS) {
ccad85cc 2534 if (features->device_type == WACOM_DEVICETYPE_WL_MONITOR) {
ac8d1010
BT
2535 features->quirks |= WACOM_QUIRK_BATTERY;
2536 }
d3825d51 2537 }
bc73dd39
HR
2538}
2539
2636a3f2 2540int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
8c0e0a4f
PC
2541 struct wacom_wac *wacom_wac)
2542{
2543 struct wacom_features *features = &wacom_wac->features;
8c0e0a4f
PC
2544
2545 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
2546
2636a3f2
JG
2547 if (!(features->device_type & WACOM_DEVICETYPE_PEN))
2548 return -ENODEV;
2549
7704ac93
BT
2550 if (features->type == HID_GENERIC)
2551 /* setup has already been done */
2552 return 0;
2553
8c0e0a4f 2554 __set_bit(BTN_TOUCH, input_dev->keybit);
8da23fc1
DT
2555 __set_bit(ABS_MISC, input_dev->absbit);
2556
2636a3f2
JG
2557 input_set_abs_params(input_dev, ABS_X, features->x_min,
2558 features->x_max, features->x_fuzz, 0);
2559 input_set_abs_params(input_dev, ABS_Y, features->y_min,
2560 features->y_max, features->y_fuzz, 0);
2561 input_set_abs_params(input_dev, ABS_PRESSURE, 0,
2562 features->pressure_max, features->pressure_fuzz, 0);
2563
2564 /* penabled devices have fixed resolution for each model */
2565 input_abs_set_res(input_dev, ABS_X, features->x_resolution);
2566 input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
2567
8c0e0a4f 2568
497ab1f2 2569 switch (features->type) {
387142bb
BT
2570 case GRAPHIRE_BT:
2571 __clear_bit(ABS_MISC, input_dev->absbit);
a2f71c6c
PC
2572
2573 case WACOM_MO:
2574 case WACOM_G4:
387142bb
BT
2575 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
2576 features->distance_max,
2577 0, 0);
a2f71c6c 2578 /* fall through */
803296b6 2579
a2f71c6c 2580 case GRAPHIRE:
387142bb 2581 input_set_capability(input_dev, EV_REL, REL_WHEEL);
803296b6 2582
387142bb
BT
2583 __set_bit(BTN_LEFT, input_dev->keybit);
2584 __set_bit(BTN_RIGHT, input_dev->keybit);
2585 __set_bit(BTN_MIDDLE, input_dev->keybit);
2586
2587 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
2588 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
2589 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
2590 __set_bit(BTN_STYLUS, input_dev->keybit);
2591 __set_bit(BTN_STYLUS2, input_dev->keybit);
2592
2593 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
2594 break;
c73a1afb 2595
500d4160 2596 case WACOM_27QHD:
803296b6 2597 case WACOM_24HD:
a112e9fd 2598 case DTK:
d838c644 2599 case WACOM_22HD:
3a4b4aaa 2600 case WACOM_21UX2:
73a97f4f 2601 case WACOM_BEE:
6521d0bf 2602 case CINTIQ:
56218563 2603 case WACOM_13HD:
a2f71c6c 2604 case CINTIQ_HYBRID:
f7acb55c 2605 case CINTIQ_COMPANION_2:
56218563 2606 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
26fe4124 2607 input_abs_set_res(input_dev, ABS_Z, 287);
56218563
PC
2608 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
2609 wacom_setup_cintiq(wacom_wac);
2610 break;
2611
73a97f4f
DT
2612 case INTUOS3:
2613 case INTUOS3L:
73a97f4f 2614 case INTUOS3S:
a2f71c6c
PC
2615 case INTUOS4:
2616 case INTUOS4WL:
2617 case INTUOS4L:
2618 case INTUOS4S:
8da23fc1 2619 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
26fe4124 2620 input_abs_set_res(input_dev, ABS_Z, 287);
73a97f4f
DT
2621 /* fall through */
2622
2623 case INTUOS:
3512069e
JG
2624 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
2625
8da23fc1 2626 wacom_setup_intuos(wacom_wac);
73a97f4f
DT
2627 break;
2628
9fee6195
JG
2629 case INTUOS5:
2630 case INTUOS5L:
9a35c411
PC
2631 case INTUOSPM:
2632 case INTUOSPL:
ae584ca4 2633 case INTUOS5S:
9a35c411 2634 case INTUOSPS:
ae584ca4
JG
2635 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
2636
2636a3f2
JG
2637 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
2638 features->distance_max,
2639 0, 0);
ae584ca4 2640
2636a3f2
JG
2641 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
2642 input_abs_set_res(input_dev, ABS_Z, 287);
ae584ca4 2643
2636a3f2 2644 wacom_setup_intuos(wacom_wac);
ae584ca4
JG
2645 break;
2646
b1e4279e 2647 case WACOM_24HDT:
500d4160 2648 case WACOM_27QHDT:
1963518b 2649 case MTSCREEN:
6afdc289 2650 case MTTPC:
d51ddb2b 2651 case MTTPC_B:
6795a524 2652 case TABLETPC2FG:
73a97f4f 2653 case TABLETPC:
ac173837 2654 case TABLETPCE:
a43c7c53 2655 __clear_bit(ABS_MISC, input_dev->absbit);
73a97f4f
DT
2656 /* fall through */
2657
497ab1f2 2658 case DTUS:
fff00bf8 2659 case DTUSX:
73a97f4f 2660 case PL:
c8f2edc5 2661 case DTU:
8da23fc1 2662 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3512069e 2663 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
8da23fc1
DT
2664 __set_bit(BTN_STYLUS, input_dev->keybit);
2665 __set_bit(BTN_STYLUS2, input_dev->keybit);
3512069e
JG
2666
2667 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
2668 break;
2669
2670 case PTU:
8da23fc1 2671 __set_bit(BTN_STYLUS2, input_dev->keybit);
73a97f4f
DT
2672 /* fall through */
2673
2674 case PENPARTNER:
1fab84aa 2675 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
8da23fc1 2676 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1fab84aa 2677 __set_bit(BTN_STYLUS, input_dev->keybit);
3512069e
JG
2678
2679 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
73a97f4f 2680 break;
cb734c03 2681
b5fd2a3e 2682 case INTUOSHT:
cb734c03 2683 case BAMBOO_PT:
3b164a00 2684 case BAMBOO_PEN:
eda01dab 2685 case INTUOSHT2:
2636a3f2 2686 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
eda01dab
PC
2687
2688 if (features->type == INTUOSHT2) {
2689 wacom_setup_basic_pro_pen(wacom_wac);
2690 } else {
2691 __clear_bit(ABS_MISC, input_dev->absbit);
2692 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
2693 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
2694 __set_bit(BTN_STYLUS, input_dev->keybit);
2695 __set_bit(BTN_STYLUS2, input_dev->keybit);
2696 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
2636a3f2
JG
2697 features->distance_max,
2698 0, 0);
eda01dab 2699 }
2636a3f2
JG
2700 break;
2701 case BAMBOO_PAD:
2702 __clear_bit(ABS_MISC, input_dev->absbit);
2703 break;
2704 }
2705 return 0;
2706}
02295e68 2707
2636a3f2
JG
2708int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
2709 struct wacom_wac *wacom_wac)
2710{
2711 struct wacom_features *features = &wacom_wac->features;
30ebc1ae 2712
2636a3f2
JG
2713 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
2714
2715 if (!(features->device_type & WACOM_DEVICETYPE_TOUCH))
2716 return -ENODEV;
2717
2718 if (features->type == HID_GENERIC)
2719 /* setup has already been done */
2720 return 0;
2721
2722 __set_bit(BTN_TOUCH, input_dev->keybit);
2723
2724 if (features->touch_max == 1) {
2725 input_set_abs_params(input_dev, ABS_X, 0,
2726 features->x_max, features->x_fuzz, 0);
2727 input_set_abs_params(input_dev, ABS_Y, 0,
2728 features->y_max, features->y_fuzz, 0);
2729 input_abs_set_res(input_dev, ABS_X,
2730 features->x_resolution);
2731 input_abs_set_res(input_dev, ABS_Y,
2732 features->y_resolution);
2733 }
2734 else if (features->touch_max > 1) {
2735 input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
2736 features->x_max, features->x_fuzz, 0);
2737 input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
2738 features->y_max, features->y_fuzz, 0);
2739 input_abs_set_res(input_dev, ABS_MT_POSITION_X,
2740 features->x_resolution);
2741 input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
2742 features->y_resolution);
2743 }
2744
2745 switch (features->type) {
2746 case INTUOS5:
2747 case INTUOS5L:
2748 case INTUOSPM:
2749 case INTUOSPL:
2750 case INTUOS5S:
2751 case INTUOSPS:
2752 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
2753
2754 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
2755 input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, features->y_max, 0, 0);
2756 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
2757 break;
2758
2759 case WACOM_24HDT:
2760 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
2761 input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
2762 input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
2763 input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
2764 /* fall through */
2765
2766 case WACOM_27QHDT:
2767 case MTSCREEN:
2768 case MTTPC:
2769 case MTTPC_B:
2770 case TABLETPC2FG:
2771 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT);
2772 /*fall through */
2773
2774 case TABLETPC:
2775 case TABLETPCE:
2776 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
2777 break;
2778
2779 case INTUOSHT:
eda01dab 2780 case INTUOSHT2:
2636a3f2
JG
2781 input_dev->evbit[0] |= BIT_MASK(EV_SW);
2782 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
2783 /* fall through */
2784
2785 case BAMBOO_PT:
3b164a00 2786 case BAMBOO_TOUCH:
2636a3f2
JG
2787 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
2788 input_set_abs_params(input_dev,
2789 ABS_MT_TOUCH_MAJOR,
2790 0, features->x_max, 0, 0);
2791 input_set_abs_params(input_dev,
2792 ABS_MT_TOUCH_MINOR,
2793 0, features->y_max, 0, 0);
cb734c03 2794 }
2636a3f2 2795 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
cb734c03 2796 break;
2636a3f2 2797
8c97a765 2798 case BAMBOO_PAD:
8c97a765
BT
2799 input_mt_init_slots(input_dev, features->touch_max,
2800 INPUT_MT_POINTER);
2801 __set_bit(BTN_LEFT, input_dev->keybit);
2802 __set_bit(BTN_RIGHT, input_dev->keybit);
2803 break;
3bea733a 2804 }
1963518b 2805 return 0;
3bea733a
PC
2806}
2807
5397df15 2808static void wacom_setup_numbered_buttons(struct input_dev *input_dev,
70ee06c5
AS
2809 int button_count)
2810{
2811 int i;
2812
2813 for (i = 0; i < button_count && i < 10; i++)
2814 __set_bit(BTN_0 + i, input_dev->keybit);
2815 for (i = 10; i < button_count && i < 16; i++)
2816 __set_bit(BTN_A + (i-10), input_dev->keybit);
2817 for (i = 16; i < button_count && i < 18; i++)
2818 __set_bit(BTN_BASE + (i-16), input_dev->keybit);
2819}
2820
d2d13f18
BT
2821int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
2822 struct wacom_wac *wacom_wac)
2823{
2824 struct wacom_features *features = &wacom_wac->features;
2825
862cf553
JG
2826 if (!(features->device_type & WACOM_DEVICETYPE_PAD))
2827 return -ENODEV;
2828
d2d13f18
BT
2829 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
2830
2831 /* kept for making legacy xf86-input-wacom working with the wheels */
2832 __set_bit(ABS_MISC, input_dev->absbit);
2833
2834 /* kept for making legacy xf86-input-wacom accepting the pad */
2835 input_set_abs_params(input_dev, ABS_X, 0, 1, 0, 0);
2836 input_set_abs_params(input_dev, ABS_Y, 0, 1, 0, 0);
2837
12969e3b
BT
2838 /* kept for making udev and libwacom accepting the pad */
2839 __set_bit(BTN_STYLUS, input_dev->keybit);
2840
70ee06c5
AS
2841 wacom_setup_numbered_buttons(input_dev, features->numbered_buttons);
2842
d2d13f18 2843 switch (features->type) {
70ee06c5
AS
2844
2845 case CINTIQ_HYBRID:
f7acb55c 2846 case CINTIQ_COMPANION_2:
70ee06c5
AS
2847 case DTK:
2848 case DTUS:
387142bb 2849 case GRAPHIRE_BT:
387142bb
BT
2850 break;
2851
3813810c
BT
2852 case WACOM_MO:
2853 __set_bit(BTN_BACK, input_dev->keybit);
2854 __set_bit(BTN_LEFT, input_dev->keybit);
2855 __set_bit(BTN_FORWARD, input_dev->keybit);
2856 __set_bit(BTN_RIGHT, input_dev->keybit);
2857 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
2858 break;
2859
2860 case WACOM_G4:
2861 __set_bit(BTN_BACK, input_dev->keybit);
3813810c 2862 __set_bit(BTN_FORWARD, input_dev->keybit);
3813810c
BT
2863 input_set_capability(input_dev, EV_REL, REL_WHEEL);
2864 break;
2865
10059cdc 2866 case WACOM_24HD:
10059cdc
BT
2867 __set_bit(KEY_PROG1, input_dev->keybit);
2868 __set_bit(KEY_PROG2, input_dev->keybit);
2869 __set_bit(KEY_PROG3, input_dev->keybit);
2870
2871 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
2872 input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
2873 break;
2874
500d4160
PC
2875 case WACOM_27QHD:
2876 __set_bit(KEY_PROG1, input_dev->keybit);
2877 __set_bit(KEY_PROG2, input_dev->keybit);
2878 __set_bit(KEY_PROG3, input_dev->keybit);
2879 input_set_abs_params(input_dev, ABS_X, -2048, 2048, 0, 0);
2880 input_abs_set_res(input_dev, ABS_X, 1024); /* points/g */
2881 input_set_abs_params(input_dev, ABS_Y, -2048, 2048, 0, 0);
2882 input_abs_set_res(input_dev, ABS_Y, 1024);
2883 input_set_abs_params(input_dev, ABS_Z, -2048, 2048, 0, 0);
2884 input_abs_set_res(input_dev, ABS_Z, 1024);
2885 __set_bit(INPUT_PROP_ACCELEROMETER, input_dev->propbit);
2886 break;
2887
10059cdc
BT
2888 case WACOM_22HD:
2889 __set_bit(KEY_PROG1, input_dev->keybit);
2890 __set_bit(KEY_PROG2, input_dev->keybit);
2891 __set_bit(KEY_PROG3, input_dev->keybit);
2892 /* fall through */
2893
2894 case WACOM_21UX2:
10059cdc 2895 case WACOM_BEE:
10059cdc 2896 case CINTIQ:
10059cdc
BT
2897 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
2898 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
2899 break;
2900
2901 case WACOM_13HD:
10059cdc
BT
2902 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
2903 break;
2904
2905 case INTUOS3:
2906 case INTUOS3L:
10059cdc
BT
2907 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
2908 /* fall through */
2909
2910 case INTUOS3S:
10059cdc
BT
2911 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
2912 break;
36d3c510 2913
10059cdc
BT
2914 case INTUOS5:
2915 case INTUOS5L:
2916 case INTUOSPM:
2917 case INTUOSPL:
10059cdc
BT
2918 case INTUOS5S:
2919 case INTUOSPS:
10059cdc 2920 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
36d3c510 2921 break;
10059cdc 2922
81af7e61
BT
2923 case INTUOS4WL:
2924 /*
2925 * For Bluetooth devices, the udev rule does not work correctly
2926 * for pads unless we add a stylus capability, which forces
2927 * ID_INPUT_TABLET to be set.
2928 */
2929 __set_bit(BTN_STYLUS, input_dev->keybit);
2930 /* fall through */
2931
10059cdc
BT
2932 case INTUOS4:
2933 case INTUOS4L:
10059cdc 2934 case INTUOS4S:
10059cdc
BT
2935 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
2936 break;
2937
3116871f
BT
2938 case INTUOSHT:
2939 case BAMBOO_PT:
3b164a00 2940 case BAMBOO_TOUCH:
eda01dab 2941 case INTUOSHT2:
3116871f
BT
2942 __clear_bit(ABS_MISC, input_dev->absbit);
2943
2944 __set_bit(BTN_LEFT, input_dev->keybit);
2945 __set_bit(BTN_FORWARD, input_dev->keybit);
2946 __set_bit(BTN_BACK, input_dev->keybit);
2947 __set_bit(BTN_RIGHT, input_dev->keybit);
2948
2949 break;
2950
72b236d6
AS
2951 case REMOTE:
2952 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
2953 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
2954 break;
2955
d2d13f18
BT
2956 default:
2957 /* no pad supported */
b3c8e93f 2958 return -ENODEV;
3bea733a 2959 }
1963518b 2960 return 0;
3bea733a
PC
2961}
2962
e87a344d 2963static const struct wacom_features wacom_features_0x00 =
80befa93
BT
2964 { "Wacom Penpartner", 5040, 3780, 255, 0,
2965 PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
e87a344d 2966static const struct wacom_features wacom_features_0x10 =
80befa93
BT
2967 { "Wacom Graphire", 10206, 7422, 511, 63,
2968 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
387142bb
BT
2969static const struct wacom_features wacom_features_0x81 =
2970 { "Wacom Graphire BT", 16704, 12064, 511, 32,
70ee06c5 2971 GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES, 2 };
e87a344d 2972static const struct wacom_features wacom_features_0x11 =
80befa93
BT
2973 { "Wacom Graphire2 4x5", 10206, 7422, 511, 63,
2974 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
e87a344d 2975static const struct wacom_features wacom_features_0x12 =
80befa93
BT
2976 { "Wacom Graphire2 5x7", 13918, 10206, 511, 63,
2977 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
e87a344d 2978static const struct wacom_features wacom_features_0x13 =
80befa93
BT
2979 { "Wacom Graphire3", 10208, 7424, 511, 63,
2980 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
e87a344d 2981static const struct wacom_features wacom_features_0x14 =
80befa93
BT
2982 { "Wacom Graphire3 6x8", 16704, 12064, 511, 63,
2983 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
e87a344d 2984static const struct wacom_features wacom_features_0x15 =
80befa93
BT
2985 { "Wacom Graphire4 4x5", 10208, 7424, 511, 63,
2986 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
e87a344d 2987static const struct wacom_features wacom_features_0x16 =
80befa93
BT
2988 { "Wacom Graphire4 6x8", 16704, 12064, 511, 63,
2989 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
e87a344d 2990static const struct wacom_features wacom_features_0x17 =
80befa93
BT
2991 { "Wacom BambooFun 4x5", 14760, 9225, 511, 63,
2992 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 2993static const struct wacom_features wacom_features_0x18 =
80befa93
BT
2994 { "Wacom BambooFun 6x8", 21648, 13530, 511, 63,
2995 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 2996static const struct wacom_features wacom_features_0x19 =
80befa93
BT
2997 { "Wacom Bamboo1 Medium", 16704, 12064, 511, 63,
2998 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
e87a344d 2999static const struct wacom_features wacom_features_0x60 =
80befa93
BT
3000 { "Wacom Volito", 5104, 3712, 511, 63,
3001 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
e87a344d 3002static const struct wacom_features wacom_features_0x61 =
80befa93
BT
3003 { "Wacom PenStation2", 3250, 2320, 255, 63,
3004 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
e87a344d 3005static const struct wacom_features wacom_features_0x62 =
80befa93
BT
3006 { "Wacom Volito2 4x5", 5104, 3712, 511, 63,
3007 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
e87a344d 3008static const struct wacom_features wacom_features_0x63 =
80befa93
BT
3009 { "Wacom Volito2 2x3", 3248, 2320, 511, 63,
3010 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
e87a344d 3011static const struct wacom_features wacom_features_0x64 =
80befa93
BT
3012 { "Wacom PenPartner2", 3250, 2320, 511, 63,
3013 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
e87a344d 3014static const struct wacom_features wacom_features_0x65 =
80befa93
BT
3015 { "Wacom Bamboo", 14760, 9225, 511, 63,
3016 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 3017static const struct wacom_features wacom_features_0x69 =
80befa93
BT
3018 { "Wacom Bamboo1", 5104, 3712, 511, 63,
3019 GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
11d0cf88 3020static const struct wacom_features wacom_features_0x6A =
80befa93
BT
3021 { "Wacom Bamboo1 4x6", 14760, 9225, 1023, 63,
3022 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
11d0cf88 3023static const struct wacom_features wacom_features_0x6B =
80befa93
BT
3024 { "Wacom Bamboo1 5x8", 21648, 13530, 1023, 63,
3025 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 3026static const struct wacom_features wacom_features_0x20 =
80befa93
BT
3027 { "Wacom Intuos 4x5", 12700, 10600, 1023, 31,
3028 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 3029static const struct wacom_features wacom_features_0x21 =
80befa93
BT
3030 { "Wacom Intuos 6x8", 20320, 16240, 1023, 31,
3031 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 3032static const struct wacom_features wacom_features_0x22 =
80befa93
BT
3033 { "Wacom Intuos 9x12", 30480, 24060, 1023, 31,
3034 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 3035static const struct wacom_features wacom_features_0x23 =
80befa93
BT
3036 { "Wacom Intuos 12x12", 30480, 31680, 1023, 31,
3037 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 3038static const struct wacom_features wacom_features_0x24 =
80befa93
BT
3039 { "Wacom Intuos 12x18", 45720, 31680, 1023, 31,
3040 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 3041static const struct wacom_features wacom_features_0x30 =
80befa93
BT
3042 { "Wacom PL400", 5408, 4056, 255, 0,
3043 PL, WACOM_PL_RES, WACOM_PL_RES };
e87a344d 3044static const struct wacom_features wacom_features_0x31 =
80befa93
BT
3045 { "Wacom PL500", 6144, 4608, 255, 0,
3046 PL, WACOM_PL_RES, WACOM_PL_RES };
e87a344d 3047static const struct wacom_features wacom_features_0x32 =
80befa93
BT
3048 { "Wacom PL600", 6126, 4604, 255, 0,
3049 PL, WACOM_PL_RES, WACOM_PL_RES };
e87a344d 3050static const struct wacom_features wacom_features_0x33 =
80befa93
BT
3051 { "Wacom PL600SX", 6260, 5016, 255, 0,
3052 PL, WACOM_PL_RES, WACOM_PL_RES };
e87a344d 3053static const struct wacom_features wacom_features_0x34 =
80befa93
BT
3054 { "Wacom PL550", 6144, 4608, 511, 0,
3055 PL, WACOM_PL_RES, WACOM_PL_RES };
e87a344d 3056static const struct wacom_features wacom_features_0x35 =
80befa93
BT
3057 { "Wacom PL800", 7220, 5780, 511, 0,
3058 PL, WACOM_PL_RES, WACOM_PL_RES };
e87a344d 3059static const struct wacom_features wacom_features_0x37 =
80befa93
BT
3060 { "Wacom PL700", 6758, 5406, 511, 0,
3061 PL, WACOM_PL_RES, WACOM_PL_RES };
e87a344d 3062static const struct wacom_features wacom_features_0x38 =
80befa93
BT
3063 { "Wacom PL510", 6282, 4762, 511, 0,
3064 PL, WACOM_PL_RES, WACOM_PL_RES };
e87a344d 3065static const struct wacom_features wacom_features_0x39 =
80befa93
BT
3066 { "Wacom DTU710", 34080, 27660, 511, 0,
3067 PL, WACOM_PL_RES, WACOM_PL_RES };
e87a344d 3068static const struct wacom_features wacom_features_0xC4 =
80befa93
BT
3069 { "Wacom DTF521", 6282, 4762, 511, 0,
3070 PL, WACOM_PL_RES, WACOM_PL_RES };
e87a344d 3071static const struct wacom_features wacom_features_0xC0 =
80befa93
BT
3072 { "Wacom DTF720", 6858, 5506, 511, 0,
3073 PL, WACOM_PL_RES, WACOM_PL_RES };
e87a344d 3074static const struct wacom_features wacom_features_0xC2 =
80befa93
BT
3075 { "Wacom DTF720a", 6858, 5506, 511, 0,
3076 PL, WACOM_PL_RES, WACOM_PL_RES };
e87a344d 3077static const struct wacom_features wacom_features_0x03 =
80befa93
BT
3078 { "Wacom Cintiq Partner", 20480, 15360, 511, 0,
3079 PTU, WACOM_PL_RES, WACOM_PL_RES };
e87a344d 3080static const struct wacom_features wacom_features_0x41 =
80befa93
BT
3081 { "Wacom Intuos2 4x5", 12700, 10600, 1023, 31,
3082 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 3083static const struct wacom_features wacom_features_0x42 =
80befa93
BT
3084 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
3085 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 3086static const struct wacom_features wacom_features_0x43 =
80befa93
BT
3087 { "Wacom Intuos2 9x12", 30480, 24060, 1023, 31,
3088 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 3089static const struct wacom_features wacom_features_0x44 =
80befa93
BT
3090 { "Wacom Intuos2 12x12", 30480, 31680, 1023, 31,
3091 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 3092static const struct wacom_features wacom_features_0x45 =
80befa93
BT
3093 { "Wacom Intuos2 12x18", 45720, 31680, 1023, 31,
3094 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 3095static const struct wacom_features wacom_features_0xB0 =
80befa93 3096 { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63,
70ee06c5 3097 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
e87a344d 3098static const struct wacom_features wacom_features_0xB1 =
80befa93 3099 { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63,
70ee06c5 3100 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
e87a344d 3101static const struct wacom_features wacom_features_0xB2 =
80befa93 3102 { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63,
70ee06c5 3103 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
e87a344d 3104static const struct wacom_features wacom_features_0xB3 =
80befa93 3105 { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63,
70ee06c5 3106 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
e87a344d 3107static const struct wacom_features wacom_features_0xB4 =
80befa93 3108 { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63,
70ee06c5 3109 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
e87a344d 3110static const struct wacom_features wacom_features_0xB5 =
80befa93 3111 { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63,
70ee06c5 3112 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
e87a344d 3113static const struct wacom_features wacom_features_0xB7 =
80befa93 3114 { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63,
70ee06c5 3115 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
e87a344d 3116static const struct wacom_features wacom_features_0xB8 =
80befa93 3117 { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63,
70ee06c5 3118 INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
e87a344d 3119static const struct wacom_features wacom_features_0xB9 =
80befa93 3120 { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63,
70ee06c5 3121 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
e87a344d 3122static const struct wacom_features wacom_features_0xBA =
80befa93 3123 { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63,
70ee06c5 3124 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
e87a344d 3125static const struct wacom_features wacom_features_0xBB =
80befa93 3126 { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63,
70ee06c5 3127 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
3a4b4aaa 3128static const struct wacom_features wacom_features_0xBC =
80befa93 3129 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
70ee06c5 3130 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
81af7e61
BT
3131static const struct wacom_features wacom_features_0xBD =
3132 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
70ee06c5 3133 INTUOS4WL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
9fee6195 3134static const struct wacom_features wacom_features_0x26 =
80befa93 3135 { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63,
70ee06c5 3136 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16 };
9fee6195 3137static const struct wacom_features wacom_features_0x27 =
80befa93 3138 { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63,
70ee06c5 3139 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
9fee6195 3140static const struct wacom_features wacom_features_0x28 =
80befa93 3141 { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63,
70ee06c5 3142 INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
9fee6195 3143static const struct wacom_features wacom_features_0x29 =
80befa93 3144 { "Wacom Intuos5 S", 31496, 19685, 2047, 63,
70ee06c5 3145 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
9fee6195 3146static const struct wacom_features wacom_features_0x2A =
80befa93 3147 { "Wacom Intuos5 M", 44704, 27940, 2047, 63,
70ee06c5 3148 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
9a35c411 3149static const struct wacom_features wacom_features_0x314 =
80befa93 3150 { "Wacom Intuos Pro S", 31496, 19685, 2047, 63,
70ee06c5 3151 INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16,
29b47391 3152 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
9a35c411 3153static const struct wacom_features wacom_features_0x315 =
80befa93 3154 { "Wacom Intuos Pro M", 44704, 27940, 2047, 63,
70ee06c5 3155 INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
29b47391 3156 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
9a35c411 3157static const struct wacom_features wacom_features_0x317 =
80befa93 3158 { "Wacom Intuos Pro L", 65024, 40640, 2047, 63,
70ee06c5 3159 INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
29b47391 3160 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
803296b6 3161static const struct wacom_features wacom_features_0xF4 =
ecd618dc 3162 { "Wacom Cintiq 24HD", 104080, 65200, 2047, 63,
70ee06c5 3163 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
fa770340 3164 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
6f4d0382 3165static const struct wacom_features wacom_features_0xF8 =
ecd618dc 3166 { "Wacom Cintiq 24HD touch", 104080, 65200, 2047, 63, /* Pen */
70ee06c5 3167 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
fa770340 3168 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
3bd1f7e2 3169 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 };
b1e4279e
JG
3170static const struct wacom_features wacom_features_0xF6 =
3171 { "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */
29b47391
BT
3172 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10,
3173 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
500d4160 3174static const struct wacom_features wacom_features_0x32A =
a7e6645e 3175 { "Wacom Cintiq 27QHD", 119740, 67520, 2047, 63,
70ee06c5 3176 WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
a7e6645e 3177 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
500d4160
PC
3178static const struct wacom_features wacom_features_0x32B =
3179 { "Wacom Cintiq 27QHD touch", 119740, 67520, 2047, 63,
70ee06c5 3180 WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
500d4160
PC
3181 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
3182 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32C };
3183static const struct wacom_features wacom_features_0x32C =
3184 { "Wacom Cintiq 27QHD touch", .type = WACOM_27QHDT,
3185 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32B, .touch_max = 10 };
e87a344d 3186static const struct wacom_features wacom_features_0x3F =
80befa93 3187 { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63,
70ee06c5 3188 CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
e87a344d 3189static const struct wacom_features wacom_features_0xC5 =
80befa93 3190 { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63,
70ee06c5 3191 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
e87a344d 3192static const struct wacom_features wacom_features_0xC6 =
80befa93 3193 { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63,
70ee06c5 3194 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
56218563 3195static const struct wacom_features wacom_features_0x304 =
ecd618dc 3196 { "Wacom Cintiq 13HD", 59152, 33448, 1023, 63,
70ee06c5 3197 WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
fa770340 3198 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
b4bf2120
PC
3199static const struct wacom_features wacom_features_0x333 =
3200 { "Wacom Cintiq 13HD touch", 59152, 33448, 2047, 63,
70ee06c5 3201 WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
b4bf2120
PC
3202 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
3203 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x335 };
3204static const struct wacom_features wacom_features_0x335 =
3205 { "Wacom Cintiq 13HD touch", .type = WACOM_24HDT, /* Touch */
3206 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x333, .touch_max = 10,
3207 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
e87a344d 3208static const struct wacom_features wacom_features_0xC7 =
80befa93
BT
3209 { "Wacom DTU1931", 37832, 30305, 511, 0,
3210 PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
c8f2edc5 3211static const struct wacom_features wacom_features_0xCE =
80befa93
BT
3212 { "Wacom DTU2231", 47864, 27011, 511, 0,
3213 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
29b47391 3214 .check_for_hid_type = true, .hid_type = HID_TYPE_USBMOUSE };
c8f2edc5 3215static const struct wacom_features wacom_features_0xF0 =
80befa93
BT
3216 { "Wacom DTU1631", 34623, 19553, 511, 0,
3217 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
497ab1f2 3218static const struct wacom_features wacom_features_0xFB =
ecd618dc 3219 { "Wacom DTU1031", 21896, 13760, 511, 0,
70ee06c5 3220 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
fa770340 3221 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
fff00bf8
PC
3222static const struct wacom_features wacom_features_0x32F =
3223 { "Wacom DTU1031X", 22472, 12728, 511, 0,
70ee06c5 3224 DTUSX, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 0,
fff00bf8 3225 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
007760cf
AS
3226static const struct wacom_features wacom_features_0x336 =
3227 { "Wacom DTU1141", 23472, 13203, 1023, 0,
70ee06c5 3228 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
56218563 3229static const struct wacom_features wacom_features_0x57 =
80befa93 3230 { "Wacom DTK2241", 95640, 54060, 2047, 63,
70ee06c5 3231 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
fa770340 3232 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
a112e9fd 3233static const struct wacom_features wacom_features_0x59 = /* Pen */
80befa93 3234 { "Wacom DTH2242", 95640, 54060, 2047, 63,
70ee06c5 3235 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
fa770340 3236 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
a112e9fd
PC
3237 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D };
3238static const struct wacom_features wacom_features_0x5D = /* Touch */
3239 { "Wacom DTH2242", .type = WACOM_24HDT,
29b47391
BT
3240 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10,
3241 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
3a4b4aaa 3242static const struct wacom_features wacom_features_0xCC =
ecd618dc 3243 { "Wacom Cintiq 21UX2", 86800, 65200, 2047, 63,
70ee06c5 3244 WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
fa770340 3245 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
d838c644 3246static const struct wacom_features wacom_features_0xFA =
ecd618dc 3247 { "Wacom Cintiq 22HD", 95440, 53860, 2047, 63,
70ee06c5 3248 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
fa770340 3249 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
56218563 3250static const struct wacom_features wacom_features_0x5B =
ecd618dc 3251 { "Wacom Cintiq 22HDT", 95440, 53860, 2047, 63,
70ee06c5 3252 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
fa770340 3253 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
3bd1f7e2 3254 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e };
56218563
PC
3255static const struct wacom_features wacom_features_0x5E =
3256 { "Wacom Cintiq 22HDT", .type = WACOM_24HDT,
29b47391
BT
3257 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5b, .touch_max = 10,
3258 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
e87a344d 3259static const struct wacom_features wacom_features_0x90 =
80befa93
BT
3260 { "Wacom ISDv4 90", 26202, 16325, 255, 0,
3261 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 3262static const struct wacom_features wacom_features_0x93 =
80befa93
BT
3263 { "Wacom ISDv4 93", 26202, 16325, 255, 0,
3264 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
11d0cf88 3265static const struct wacom_features wacom_features_0x97 =
80befa93
BT
3266 { "Wacom ISDv4 97", 26202, 16325, 511, 0,
3267 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 3268static const struct wacom_features wacom_features_0x9A =
80befa93
BT
3269 { "Wacom ISDv4 9A", 26202, 16325, 255, 0,
3270 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 3271static const struct wacom_features wacom_features_0x9F =
80befa93
BT
3272 { "Wacom ISDv4 9F", 26202, 16325, 255, 0,
3273 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 3274static const struct wacom_features wacom_features_0xE2 =
80befa93
BT
3275 { "Wacom ISDv4 E2", 26202, 16325, 255, 0,
3276 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
e87a344d 3277static const struct wacom_features wacom_features_0xE3 =
80befa93
BT
3278 { "Wacom ISDv4 E3", 26202, 16325, 255, 0,
3279 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
1963518b 3280static const struct wacom_features wacom_features_0xE5 =
80befa93
BT
3281 { "Wacom ISDv4 E5", 26202, 16325, 255, 0,
3282 MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
26fcd2a7 3283static const struct wacom_features wacom_features_0xE6 =
80befa93
BT
3284 { "Wacom ISDv4 E6", 27760, 15694, 255, 0,
3285 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
0d0e3064 3286static const struct wacom_features wacom_features_0xEC =
80befa93
BT
3287 { "Wacom ISDv4 EC", 25710, 14500, 255, 0,
3288 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
ac173837 3289static const struct wacom_features wacom_features_0xED =
80befa93
BT
3290 { "Wacom ISDv4 ED", 26202, 16325, 255, 0,
3291 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
ac173837 3292static const struct wacom_features wacom_features_0xEF =
80befa93
BT
3293 { "Wacom ISDv4 EF", 26202, 16325, 255, 0,
3294 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
6afdc289 3295static const struct wacom_features wacom_features_0x100 =
80befa93
BT
3296 { "Wacom ISDv4 100", 26202, 16325, 255, 0,
3297 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
6afdc289 3298static const struct wacom_features wacom_features_0x101 =
80befa93
BT
3299 { "Wacom ISDv4 101", 26202, 16325, 255, 0,
3300 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
58694837 3301static const struct wacom_features wacom_features_0x10D =
80befa93
BT
3302 { "Wacom ISDv4 10D", 26202, 16325, 255, 0,
3303 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
2d3163f1 3304static const struct wacom_features wacom_features_0x10E =
80befa93
BT
3305 { "Wacom ISDv4 10E", 27760, 15694, 255, 0,
3306 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
9b4f60e5 3307static const struct wacom_features wacom_features_0x10F =
80befa93
BT
3308 { "Wacom ISDv4 10F", 27760, 15694, 255, 0,
3309 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
61616ed0 3310static const struct wacom_features wacom_features_0x116 =
80befa93
BT
3311 { "Wacom ISDv4 116", 26202, 16325, 255, 0,
3312 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
aeaf50d4
JG
3313static const struct wacom_features wacom_features_0x12C =
3314 { "Wacom ISDv4 12C", 27848, 15752, 2047, 0,
3315 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
edbe265d 3316static const struct wacom_features wacom_features_0x4001 =
80befa93
BT
3317 { "Wacom ISDv4 4001", 26202, 16325, 255, 0,
3318 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
d51ddb2b 3319static const struct wacom_features wacom_features_0x4004 =
80befa93
BT
3320 { "Wacom ISDv4 4004", 11060, 6220, 255, 0,
3321 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
d51ddb2b 3322static const struct wacom_features wacom_features_0x5000 =
80befa93
BT
3323 { "Wacom ISDv4 5000", 27848, 15752, 1023, 0,
3324 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
d51ddb2b 3325static const struct wacom_features wacom_features_0x5002 =
80befa93
BT
3326 { "Wacom ISDv4 5002", 29576, 16724, 1023, 0,
3327 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
e87a344d 3328static const struct wacom_features wacom_features_0x47 =
80befa93
BT
3329 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
3330 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
d3825d51 3331static const struct wacom_features wacom_features_0x84 =
3b164a00 3332 { "Wacom Wireless Receiver", .type = WIRELESS, .touch_max = 16 };
7b824bbd 3333static const struct wacom_features wacom_features_0xD0 =
80befa93 3334 { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31,
3b164a00 3335 BAMBOO_TOUCH, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
7b824bbd 3336static const struct wacom_features wacom_features_0xD1 =
80befa93
BT
3337 { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31,
3338 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
7b824bbd 3339static const struct wacom_features wacom_features_0xD2 =
80befa93
BT
3340 { "Wacom Bamboo Craft", 14720, 9200, 1023, 31,
3341 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
7b824bbd 3342static const struct wacom_features wacom_features_0xD3 =
80befa93
BT
3343 { "Wacom Bamboo 2FG 6x8", 21648, 13700, 1023, 31,
3344 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
57a7872f 3345static const struct wacom_features wacom_features_0xD4 =
80befa93 3346 { "Wacom Bamboo Pen", 14720, 9200, 1023, 31,
3b164a00 3347 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
18adad1c 3348static const struct wacom_features wacom_features_0xD5 =
80befa93 3349 { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31,
3b164a00 3350 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
7b824bbd 3351static const struct wacom_features wacom_features_0xD6 =
80befa93
BT
3352 { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31,
3353 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
7b824bbd 3354static const struct wacom_features wacom_features_0xD7 =
80befa93
BT
3355 { "Wacom BambooPT 2FG Small", 14720, 9200, 1023, 31,
3356 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
7b824bbd 3357static const struct wacom_features wacom_features_0xD8 =
80befa93
BT
3358 { "Wacom Bamboo Comic 2FG", 21648, 13700, 1023, 31,
3359 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
7b824bbd 3360static const struct wacom_features wacom_features_0xDA =
80befa93
BT
3361 { "Wacom Bamboo 2FG 4x5 SE", 14720, 9200, 1023, 31,
3362 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
f41a64ee 3363static const struct wacom_features wacom_features_0xDB =
80befa93
BT
3364 { "Wacom Bamboo 2FG 6x8 SE", 21648, 13700, 1023, 31,
3365 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
73149ab8 3366static const struct wacom_features wacom_features_0xDD =
80befa93
BT
3367 { "Wacom Bamboo Connect", 14720, 9200, 1023, 31,
3368 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
73149ab8 3369static const struct wacom_features wacom_features_0xDE =
80befa93
BT
3370 { "Wacom Bamboo 16FG 4x5", 14720, 9200, 1023, 31,
3371 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
73149ab8 3372static const struct wacom_features wacom_features_0xDF =
80befa93
BT
3373 { "Wacom Bamboo 16FG 6x8", 21648, 13700, 1023, 31,
3374 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
f41a64ee 3375static const struct wacom_features wacom_features_0x300 =
80befa93 3376 { "Wacom Bamboo One S", 14720, 9225, 1023, 31,
3b164a00 3377 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
f41a64ee 3378static const struct wacom_features wacom_features_0x301 =
80befa93
BT
3379 { "Wacom Bamboo One M", 21648, 13530, 1023, 31,
3380 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
b5fd2a3e 3381static const struct wacom_features wacom_features_0x302 =
80befa93
BT
3382 { "Wacom Intuos PT S", 15200, 9500, 1023, 31,
3383 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
29b47391 3384 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
b5fd2a3e 3385static const struct wacom_features wacom_features_0x303 =
80befa93
BT
3386 { "Wacom Intuos PT M", 21600, 13500, 1023, 31,
3387 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
29b47391 3388 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
b5fd2a3e 3389static const struct wacom_features wacom_features_0x30E =
80befa93
BT
3390 { "Wacom Intuos S", 15200, 9500, 1023, 31,
3391 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
29b47391 3392 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
7b4b3068 3393static const struct wacom_features wacom_features_0x6004 =
80befa93
BT
3394 { "ISD-V4", 12800, 8000, 255, 0,
3395 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
a3e6f654 3396static const struct wacom_features wacom_features_0x307 =
ecd618dc 3397 { "Wacom ISDv5 307", 59152, 33448, 2047, 63,
70ee06c5 3398 CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
fa770340 3399 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
36d3c510 3400 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 };
a3e6f654 3401static const struct wacom_features wacom_features_0x309 =
36d3c510 3402 { "Wacom ISDv5 309", .type = WACOM_24HDT, /* Touch */
29b47391
BT
3403 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x0307, .touch_max = 10,
3404 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
89f2ab55 3405static const struct wacom_features wacom_features_0x30A =
ecd618dc 3406 { "Wacom ISDv5 30A", 59152, 33448, 2047, 63,
70ee06c5 3407 CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
fa770340 3408 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
89f2ab55
BT
3409 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30C };
3410static const struct wacom_features wacom_features_0x30C =
3411 { "Wacom ISDv5 30C", .type = WACOM_24HDT, /* Touch */
3412 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30A, .touch_max = 10,
3413 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
8c97a765
BT
3414static const struct wacom_features wacom_features_0x318 =
3415 { "Wacom USB Bamboo PAD", 4095, 4095, /* Touch */
3416 .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
3417static const struct wacom_features wacom_features_0x319 =
3418 { "Wacom Wireless Bamboo PAD", 4095, 4095, /* Touch */
3419 .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
f7acb55c
JG
3420static const struct wacom_features wacom_features_0x325 =
3421 { "Wacom ISDv5 325", 59552, 33848, 2047, 63,
3422 CINTIQ_COMPANION_2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 11,
3423 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
3424 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x326 };
3425static const struct wacom_features wacom_features_0x326 = /* Touch */
3426 { "Wacom ISDv5 326", .type = HID_GENERIC, .oVid = USB_VENDOR_ID_WACOM,
3427 .oPid = 0x325 };
fefb391f
PC
3428static const struct wacom_features wacom_features_0x323 =
3429 { "Wacom Intuos P M", 21600, 13500, 1023, 31,
3430 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
3431 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
72b236d6 3432static const struct wacom_features wacom_features_0x331 =
3b164a00
PC
3433 { "Wacom Express Key Remote", .type = REMOTE,
3434 .numbered_buttons = 18, .check_for_hid_type = true,
72b236d6 3435 .hid_type = HID_TYPE_USBNONE };
eda01dab
PC
3436static const struct wacom_features wacom_features_0x33B =
3437 { "Wacom Intuos S 2", 15200, 9500, 2047, 63,
3438 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
3439 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
3440static const struct wacom_features wacom_features_0x33C =
3441 { "Wacom Intuos PT S 2", 15200, 9500, 2047, 63,
3442 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
3443 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
3444static const struct wacom_features wacom_features_0x33D =
3445 { "Wacom Intuos P M 2", 21600, 13500, 2047, 63,
3446 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
3447 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
3448static const struct wacom_features wacom_features_0x33E =
3449 { "Wacom Intuos PT M 2", 21600, 13500, 2047, 63,
3450 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
3451 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
b036f6fb 3452
7704ac93
BT
3453static const struct wacom_features wacom_features_HID_ANY_ID =
3454 { "Wacom HID", .type = HID_GENERIC };
3455
29b47391
BT
3456#define USB_DEVICE_WACOM(prod) \
3457 HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
3458 .driver_data = (kernel_ulong_t)&wacom_features_##prod
b036f6fb 3459
387142bb
BT
3460#define BT_DEVICE_WACOM(prod) \
3461 HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
3462 .driver_data = (kernel_ulong_t)&wacom_features_##prod
1483f551 3463
eef23a84
MW
3464#define I2C_DEVICE_WACOM(prod) \
3465 HID_DEVICE(BUS_I2C, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
3466 .driver_data = (kernel_ulong_t)&wacom_features_##prod
3467
7b4b3068 3468#define USB_DEVICE_LENOVO(prod) \
29b47391
BT
3469 HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
3470 .driver_data = (kernel_ulong_t)&wacom_features_##prod
7b4b3068 3471
29b47391 3472const struct hid_device_id wacom_ids[] = {
b036f6fb 3473 { USB_DEVICE_WACOM(0x00) },
a3e6f654 3474 { USB_DEVICE_WACOM(0x03) },
b036f6fb
BB
3475 { USB_DEVICE_WACOM(0x10) },
3476 { USB_DEVICE_WACOM(0x11) },
3477 { USB_DEVICE_WACOM(0x12) },
3478 { USB_DEVICE_WACOM(0x13) },
3479 { USB_DEVICE_WACOM(0x14) },
3480 { USB_DEVICE_WACOM(0x15) },
3481 { USB_DEVICE_WACOM(0x16) },
3482 { USB_DEVICE_WACOM(0x17) },
3483 { USB_DEVICE_WACOM(0x18) },
3484 { USB_DEVICE_WACOM(0x19) },
b036f6fb
BB
3485 { USB_DEVICE_WACOM(0x20) },
3486 { USB_DEVICE_WACOM(0x21) },
3487 { USB_DEVICE_WACOM(0x22) },
3488 { USB_DEVICE_WACOM(0x23) },
3489 { USB_DEVICE_WACOM(0x24) },
a3e6f654
BT
3490 { USB_DEVICE_WACOM(0x26) },
3491 { USB_DEVICE_WACOM(0x27) },
3492 { USB_DEVICE_WACOM(0x28) },
3493 { USB_DEVICE_WACOM(0x29) },
3494 { USB_DEVICE_WACOM(0x2A) },
b036f6fb
BB
3495 { USB_DEVICE_WACOM(0x30) },
3496 { USB_DEVICE_WACOM(0x31) },
3497 { USB_DEVICE_WACOM(0x32) },
3498 { USB_DEVICE_WACOM(0x33) },
3499 { USB_DEVICE_WACOM(0x34) },
3500 { USB_DEVICE_WACOM(0x35) },
3501 { USB_DEVICE_WACOM(0x37) },
3502 { USB_DEVICE_WACOM(0x38) },
3503 { USB_DEVICE_WACOM(0x39) },
a3e6f654 3504 { USB_DEVICE_WACOM(0x3F) },
b036f6fb
BB
3505 { USB_DEVICE_WACOM(0x41) },
3506 { USB_DEVICE_WACOM(0x42) },
3507 { USB_DEVICE_WACOM(0x43) },
3508 { USB_DEVICE_WACOM(0x44) },
3509 { USB_DEVICE_WACOM(0x45) },
a3e6f654 3510 { USB_DEVICE_WACOM(0x47) },
56218563 3511 { USB_DEVICE_WACOM(0x57) },
a112e9fd 3512 { USB_DEVICE_WACOM(0x59) },
56218563 3513 { USB_DEVICE_WACOM(0x5B) },
a3e6f654 3514 { USB_DEVICE_WACOM(0x5D) },
29b47391 3515 { USB_DEVICE_WACOM(0x5E) },
a3e6f654
BT
3516 { USB_DEVICE_WACOM(0x60) },
3517 { USB_DEVICE_WACOM(0x61) },
3518 { USB_DEVICE_WACOM(0x62) },
3519 { USB_DEVICE_WACOM(0x63) },
3520 { USB_DEVICE_WACOM(0x64) },
3521 { USB_DEVICE_WACOM(0x65) },
3522 { USB_DEVICE_WACOM(0x69) },
3523 { USB_DEVICE_WACOM(0x6A) },
3524 { USB_DEVICE_WACOM(0x6B) },
387142bb 3525 { BT_DEVICE_WACOM(0x81) },
a3e6f654
BT
3526 { USB_DEVICE_WACOM(0x84) },
3527 { USB_DEVICE_WACOM(0x90) },
3528 { USB_DEVICE_WACOM(0x93) },
3529 { USB_DEVICE_WACOM(0x97) },
3530 { USB_DEVICE_WACOM(0x9A) },
3531 { USB_DEVICE_WACOM(0x9F) },
b036f6fb
BB
3532 { USB_DEVICE_WACOM(0xB0) },
3533 { USB_DEVICE_WACOM(0xB1) },
3534 { USB_DEVICE_WACOM(0xB2) },
3535 { USB_DEVICE_WACOM(0xB3) },
3536 { USB_DEVICE_WACOM(0xB4) },
3537 { USB_DEVICE_WACOM(0xB5) },
3538 { USB_DEVICE_WACOM(0xB7) },
3539 { USB_DEVICE_WACOM(0xB8) },
3540 { USB_DEVICE_WACOM(0xB9) },
3541 { USB_DEVICE_WACOM(0xBA) },
3542 { USB_DEVICE_WACOM(0xBB) },
3a4b4aaa 3543 { USB_DEVICE_WACOM(0xBC) },
81af7e61 3544 { BT_DEVICE_WACOM(0xBD) },
a3e6f654
BT
3545 { USB_DEVICE_WACOM(0xC0) },
3546 { USB_DEVICE_WACOM(0xC2) },
3547 { USB_DEVICE_WACOM(0xC4) },
b036f6fb
BB
3548 { USB_DEVICE_WACOM(0xC5) },
3549 { USB_DEVICE_WACOM(0xC6) },
3550 { USB_DEVICE_WACOM(0xC7) },
a3e6f654 3551 { USB_DEVICE_WACOM(0xCC) },
29b47391 3552 { USB_DEVICE_WACOM(0xCE) },
cb734c03 3553 { USB_DEVICE_WACOM(0xD0) },
2aaacb15
CB
3554 { USB_DEVICE_WACOM(0xD1) },
3555 { USB_DEVICE_WACOM(0xD2) },
3556 { USB_DEVICE_WACOM(0xD3) },
57a7872f 3557 { USB_DEVICE_WACOM(0xD4) },
18adad1c 3558 { USB_DEVICE_WACOM(0xD5) },
d38acb49
PC
3559 { USB_DEVICE_WACOM(0xD6) },
3560 { USB_DEVICE_WACOM(0xD7) },
a318e6b1
DF
3561 { USB_DEVICE_WACOM(0xD8) },
3562 { USB_DEVICE_WACOM(0xDA) },
47d09235 3563 { USB_DEVICE_WACOM(0xDB) },
73149ab8
CB
3564 { USB_DEVICE_WACOM(0xDD) },
3565 { USB_DEVICE_WACOM(0xDE) },
3566 { USB_DEVICE_WACOM(0xDF) },
b036f6fb
BB
3567 { USB_DEVICE_WACOM(0xE2) },
3568 { USB_DEVICE_WACOM(0xE3) },
1963518b 3569 { USB_DEVICE_WACOM(0xE5) },
26fcd2a7 3570 { USB_DEVICE_WACOM(0xE6) },
0d0e3064 3571 { USB_DEVICE_WACOM(0xEC) },
ac173837
PC
3572 { USB_DEVICE_WACOM(0xED) },
3573 { USB_DEVICE_WACOM(0xEF) },
a3e6f654
BT
3574 { USB_DEVICE_WACOM(0xF0) },
3575 { USB_DEVICE_WACOM(0xF4) },
3576 { USB_DEVICE_WACOM(0xF6) },
3577 { USB_DEVICE_WACOM(0xF8) },
3578 { USB_DEVICE_WACOM(0xFA) },
3579 { USB_DEVICE_WACOM(0xFB) },
6afdc289
PC
3580 { USB_DEVICE_WACOM(0x100) },
3581 { USB_DEVICE_WACOM(0x101) },
58694837 3582 { USB_DEVICE_WACOM(0x10D) },
2d3163f1 3583 { USB_DEVICE_WACOM(0x10E) },
9b4f60e5 3584 { USB_DEVICE_WACOM(0x10F) },
61616ed0 3585 { USB_DEVICE_WACOM(0x116) },
aeaf50d4 3586 { USB_DEVICE_WACOM(0x12C) },
f41a64ee
PC
3587 { USB_DEVICE_WACOM(0x300) },
3588 { USB_DEVICE_WACOM(0x301) },
29b47391
BT
3589 { USB_DEVICE_WACOM(0x302) },
3590 { USB_DEVICE_WACOM(0x303) },
56218563 3591 { USB_DEVICE_WACOM(0x304) },
a3e6f654
BT
3592 { USB_DEVICE_WACOM(0x307) },
3593 { USB_DEVICE_WACOM(0x309) },
89f2ab55
BT
3594 { USB_DEVICE_WACOM(0x30A) },
3595 { USB_DEVICE_WACOM(0x30C) },
a3e6f654 3596 { USB_DEVICE_WACOM(0x30E) },
29b47391
BT
3597 { USB_DEVICE_WACOM(0x314) },
3598 { USB_DEVICE_WACOM(0x315) },
3599 { USB_DEVICE_WACOM(0x317) },
8c97a765
BT
3600 { USB_DEVICE_WACOM(0x318) },
3601 { USB_DEVICE_WACOM(0x319) },
fefb391f 3602 { USB_DEVICE_WACOM(0x323) },
f7acb55c
JG
3603 { USB_DEVICE_WACOM(0x325) },
3604 { USB_DEVICE_WACOM(0x326) },
500d4160
PC
3605 { USB_DEVICE_WACOM(0x32A) },
3606 { USB_DEVICE_WACOM(0x32B) },
3607 { USB_DEVICE_WACOM(0x32C) },
fff00bf8 3608 { USB_DEVICE_WACOM(0x32F) },
72b236d6 3609 { USB_DEVICE_WACOM(0x331) },
b4bf2120
PC
3610 { USB_DEVICE_WACOM(0x333) },
3611 { USB_DEVICE_WACOM(0x335) },
007760cf 3612 { USB_DEVICE_WACOM(0x336) },
eda01dab
PC
3613 { USB_DEVICE_WACOM(0x33B) },
3614 { USB_DEVICE_WACOM(0x33C) },
3615 { USB_DEVICE_WACOM(0x33D) },
3616 { USB_DEVICE_WACOM(0x33E) },
edbe265d 3617 { USB_DEVICE_WACOM(0x4001) },
d51ddb2b
JG
3618 { USB_DEVICE_WACOM(0x4004) },
3619 { USB_DEVICE_WACOM(0x5000) },
3620 { USB_DEVICE_WACOM(0x5002) },
00d6f227 3621 { USB_DEVICE_LENOVO(0x6004) },
7704ac93
BT
3622
3623 { USB_DEVICE_WACOM(HID_ANY_ID) },
eef23a84 3624 { I2C_DEVICE_WACOM(HID_ANY_ID) },
3bea733a
PC
3625 { }
3626};
29b47391 3627MODULE_DEVICE_TABLE(hid, wacom_ids);