1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * drivers/input/tablet/wacom_wac.c
5 * USB Wacom tablet support - Wacom specific code
11 #include "wacom_wac.h"
13 #include <linux/input/mt.h>
15 /* resolution for penabled devices */
16 #define WACOM_PL_RES 20
17 #define WACOM_PENPRTN_RES 40
18 #define WACOM_VOLITO_RES 50
19 #define WACOM_GRAPHIRE_RES 80
20 #define WACOM_INTUOS_RES 100
21 #define WACOM_INTUOS3_RES 200
23 /* Newer Cintiq and DTU have an offset between tablet and screen areas */
24 #define WACOM_DTU_OFFSET 200
25 #define WACOM_CINTIQ_OFFSET 400
28 * Scale factor relating reported contact size to logical contact area.
29 * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo
31 #define WACOM_CONTACT_AREA_SCALE 2607
33 static bool touch_arbitration = 1;
34 module_param(touch_arbitration, bool, 0644);
35 MODULE_PARM_DESC(touch_arbitration, " on (Y) off (N)");
37 static void wacom_report_numbered_buttons(struct input_dev *input_dev,
38 int button_count, int mask);
40 static int wacom_numbered_button_to_key(int n);
42 static void wacom_update_led(struct wacom *wacom, int button_count, int mask,
45 * Percent of battery capacity for Graphire.
46 * 8th value means AC online and show 100% capacity.
48 static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
51 * Percent of battery capacity for Intuos4 WL, AC has a separate bit.
53 static unsigned short batcap_i4[8] = { 1, 15, 30, 45, 60, 70, 85, 100 };
55 static void __wacom_notify_battery(struct wacom_battery *battery,
56 int bat_status, int bat_capacity,
57 bool bat_charging, bool bat_connected,
60 bool changed = battery->bat_status != bat_status ||
61 battery->battery_capacity != bat_capacity ||
62 battery->bat_charging != bat_charging ||
63 battery->bat_connected != bat_connected ||
64 battery->ps_connected != ps_connected;
67 battery->bat_status = bat_status;
68 battery->battery_capacity = bat_capacity;
69 battery->bat_charging = bat_charging;
70 battery->bat_connected = bat_connected;
71 battery->ps_connected = ps_connected;
74 power_supply_changed(battery->battery);
78 static void wacom_notify_battery(struct wacom_wac *wacom_wac,
79 int bat_status, int bat_capacity, bool bat_charging,
80 bool bat_connected, bool ps_connected)
82 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
84 __wacom_notify_battery(&wacom->battery, bat_status, bat_capacity,
85 bat_charging, bat_connected, ps_connected);
88 static int wacom_penpartner_irq(struct wacom_wac *wacom)
90 unsigned char *data = wacom->data;
91 struct input_dev *input = wacom->pen_input;
96 wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
97 wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID;
98 input_report_key(input, wacom->tool[0], 1);
99 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
100 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
101 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
102 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
103 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127));
104 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
106 input_report_key(input, wacom->tool[0], 0);
107 input_report_abs(input, ABS_MISC, 0); /* report tool id */
108 input_report_abs(input, ABS_PRESSURE, -1);
109 input_report_key(input, BTN_TOUCH, 0);
114 input_report_key(input, BTN_TOOL_PEN, 1);
115 input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
116 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
117 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
118 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
119 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
120 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
124 dev_dbg(input->dev.parent,
125 "%s: received unknown report #%d\n", __func__, data[0]);
132 static int wacom_pl_irq(struct wacom_wac *wacom)
134 struct wacom_features *features = &wacom->features;
135 unsigned char *data = wacom->data;
136 struct input_dev *input = wacom->pen_input;
139 if (data[0] != WACOM_REPORT_PENABLED) {
140 dev_dbg(input->dev.parent,
141 "%s: received unknown report #%d\n", __func__, data[0]);
145 prox = data[1] & 0x40;
148 if ((data[0] & 0x10) || (data[4] & 0x20)) {
149 wacom->tool[0] = BTN_TOOL_RUBBER;
150 wacom->id[0] = ERASER_DEVICE_ID;
153 wacom->tool[0] = BTN_TOOL_PEN;
154 wacom->id[0] = STYLUS_DEVICE_ID;
158 /* If the eraser is in prox, STYLUS2 is always set. If we
159 * mis-detected the type and notice that STYLUS2 isn't set
160 * then force the eraser out of prox and let the pen in.
162 if (wacom->tool[0] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
163 input_report_key(input, BTN_TOOL_RUBBER, 0);
164 input_report_abs(input, ABS_MISC, 0);
166 wacom->tool[0] = BTN_TOOL_PEN;
167 wacom->id[0] = STYLUS_DEVICE_ID;
171 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
172 if (features->pressure_max > 255)
173 pressure = (pressure << 1) | ((data[4] >> 6) & 1);
174 pressure += (features->pressure_max + 1) / 2;
176 input_report_abs(input, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
177 input_report_abs(input, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
178 input_report_abs(input, ABS_PRESSURE, pressure);
180 input_report_key(input, BTN_TOUCH, data[4] & 0x08);
181 input_report_key(input, BTN_STYLUS, data[4] & 0x10);
182 /* Only allow the stylus2 button to be reported for the pen tool. */
183 input_report_key(input, BTN_STYLUS2, (wacom->tool[0] == BTN_TOOL_PEN) && (data[4] & 0x20));
188 input_report_key(input, wacom->tool[0], prox);
189 input_report_abs(input, ABS_MISC, wacom->id[0]);
193 static int wacom_ptu_irq(struct wacom_wac *wacom)
195 unsigned char *data = wacom->data;
196 struct input_dev *input = wacom->pen_input;
198 if (data[0] != WACOM_REPORT_PENABLED) {
199 dev_dbg(input->dev.parent,
200 "%s: received unknown report #%d\n", __func__, data[0]);
204 if (data[1] & 0x04) {
205 input_report_key(input, BTN_TOOL_RUBBER, data[1] & 0x20);
206 input_report_key(input, BTN_TOUCH, data[1] & 0x08);
207 wacom->id[0] = ERASER_DEVICE_ID;
209 input_report_key(input, BTN_TOOL_PEN, data[1] & 0x20);
210 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
211 wacom->id[0] = STYLUS_DEVICE_ID;
213 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
214 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
215 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
216 input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6]));
217 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
218 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
222 static int wacom_dtu_irq(struct wacom_wac *wacom)
224 unsigned char *data = wacom->data;
225 struct input_dev *input = wacom->pen_input;
226 int prox = data[1] & 0x20;
228 dev_dbg(input->dev.parent,
229 "%s: received report #%d", __func__, data[0]);
232 /* Going into proximity select tool */
233 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
234 if (wacom->tool[0] == BTN_TOOL_PEN)
235 wacom->id[0] = STYLUS_DEVICE_ID;
237 wacom->id[0] = ERASER_DEVICE_ID;
239 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
240 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
241 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
242 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
243 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x01) << 8) | data[6]);
244 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
245 if (!prox) /* out-prox */
247 input_report_key(input, wacom->tool[0], prox);
248 input_report_abs(input, ABS_MISC, wacom->id[0]);
252 static int wacom_dtus_irq(struct wacom_wac *wacom)
254 unsigned char *data = wacom->data;
255 struct input_dev *input = wacom->pen_input;
256 unsigned short prox, pressure = 0;
258 if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) {
259 dev_dbg(input->dev.parent,
260 "%s: received unknown report #%d", __func__, data[0]);
262 } else if (data[0] == WACOM_REPORT_DTUSPAD) {
263 input = wacom->pad_input;
264 input_report_key(input, BTN_0, (data[1] & 0x01));
265 input_report_key(input, BTN_1, (data[1] & 0x02));
266 input_report_key(input, BTN_2, (data[1] & 0x04));
267 input_report_key(input, BTN_3, (data[1] & 0x08));
268 input_report_abs(input, ABS_MISC,
269 data[1] & 0x0f ? PAD_DEVICE_ID : 0);
272 prox = data[1] & 0x80;
274 switch ((data[1] >> 3) & 3) {
276 wacom->tool[0] = BTN_TOOL_RUBBER;
277 wacom->id[0] = ERASER_DEVICE_ID;
281 wacom->tool[0] = BTN_TOOL_PEN;
282 wacom->id[0] = STYLUS_DEVICE_ID;
287 input_report_key(input, BTN_STYLUS, data[1] & 0x20);
288 input_report_key(input, BTN_STYLUS2, data[1] & 0x40);
289 input_report_abs(input, ABS_X, get_unaligned_be16(&data[3]));
290 input_report_abs(input, ABS_Y, get_unaligned_be16(&data[5]));
291 pressure = ((data[1] & 0x03) << 8) | (data[2] & 0xff);
292 input_report_abs(input, ABS_PRESSURE, pressure);
293 input_report_key(input, BTN_TOUCH, pressure > 10);
295 if (!prox) /* out-prox */
297 input_report_key(input, wacom->tool[0], prox);
298 input_report_abs(input, ABS_MISC, wacom->id[0]);
303 static int wacom_graphire_irq(struct wacom_wac *wacom)
305 struct wacom_features *features = &wacom->features;
306 unsigned char *data = wacom->data;
307 struct input_dev *input = wacom->pen_input;
308 struct input_dev *pad_input = wacom->pad_input;
309 int battery_capacity, ps_connected;
314 if (features->type == GRAPHIRE_BT) {
315 if (data[0] != WACOM_REPORT_PENABLED_BT) {
316 dev_dbg(input->dev.parent,
317 "%s: received unknown report #%d\n", __func__,
321 } else if (data[0] != WACOM_REPORT_PENABLED) {
322 dev_dbg(input->dev.parent,
323 "%s: received unknown report #%d\n", __func__, data[0]);
327 prox = data[1] & 0x80;
328 if (prox || wacom->id[0]) {
330 switch ((data[1] >> 5) & 3) {
333 wacom->tool[0] = BTN_TOOL_PEN;
334 wacom->id[0] = STYLUS_DEVICE_ID;
338 wacom->tool[0] = BTN_TOOL_RUBBER;
339 wacom->id[0] = ERASER_DEVICE_ID;
342 case 2: /* Mouse with wheel */
343 input_report_key(input, BTN_MIDDLE, data[1] & 0x04);
346 case 3: /* Mouse without wheel */
347 wacom->tool[0] = BTN_TOOL_MOUSE;
348 wacom->id[0] = CURSOR_DEVICE_ID;
352 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
353 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
354 if (wacom->tool[0] != BTN_TOOL_MOUSE) {
355 if (features->type == GRAPHIRE_BT)
356 input_report_abs(input, ABS_PRESSURE, data[6] |
357 (((__u16) (data[1] & 0x08)) << 5));
359 input_report_abs(input, ABS_PRESSURE, data[6] |
360 ((data[7] & 0x03) << 8));
361 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
362 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
363 input_report_key(input, BTN_STYLUS2, data[1] & 0x04);
365 input_report_key(input, BTN_LEFT, data[1] & 0x01);
366 input_report_key(input, BTN_RIGHT, data[1] & 0x02);
367 if (features->type == WACOM_G4 ||
368 features->type == WACOM_MO) {
369 input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f);
370 rw = (data[7] & 0x04) - (data[7] & 0x03);
371 } else if (features->type == GRAPHIRE_BT) {
372 /* Compute distance between mouse and tablet */
373 rw = 44 - (data[6] >> 2);
374 rw = clamp_val(rw, 0, 31);
375 input_report_abs(input, ABS_DISTANCE, rw);
376 if (((data[1] >> 5) & 3) == 2) {
377 /* Mouse with wheel */
378 input_report_key(input, BTN_MIDDLE,
380 rw = (data[6] & 0x01) ? -1 :
381 (data[6] & 0x02) ? 1 : 0;
386 input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f);
387 rw = -(signed char)data[6];
389 input_report_rel(input, REL_WHEEL, rw);
394 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
395 input_report_key(input, wacom->tool[0], prox);
396 input_sync(input); /* sync last event */
400 switch (features->type) {
402 prox = data[7] & 0xf8;
403 if (prox || wacom->id[1]) {
404 wacom->id[1] = PAD_DEVICE_ID;
405 input_report_key(pad_input, BTN_BACK, (data[7] & 0x40));
406 input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x80));
407 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
408 input_report_rel(pad_input, REL_WHEEL, rw);
411 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
417 prox = (data[7] & 0xf8) || data[8];
418 if (prox || wacom->id[1]) {
419 wacom->id[1] = PAD_DEVICE_ID;
420 input_report_key(pad_input, BTN_BACK, (data[7] & 0x08));
421 input_report_key(pad_input, BTN_LEFT, (data[7] & 0x20));
422 input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x10));
423 input_report_key(pad_input, BTN_RIGHT, (data[7] & 0x40));
424 input_report_abs(pad_input, ABS_WHEEL, (data[8] & 0x7f));
427 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
432 prox = data[7] & 0x03;
433 if (prox || wacom->id[1]) {
434 wacom->id[1] = PAD_DEVICE_ID;
435 input_report_key(pad_input, BTN_0, (data[7] & 0x02));
436 input_report_key(pad_input, BTN_1, (data[7] & 0x01));
439 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
445 /* Store current battery capacity and power supply state */
446 if (features->type == GRAPHIRE_BT) {
447 rw = (data[7] >> 2 & 0x07);
448 battery_capacity = batcap_gr[rw];
449 ps_connected = rw == 7;
450 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
451 battery_capacity, ps_connected, 1,
458 static void wacom_intuos_schedule_prox_event(struct wacom_wac *wacom_wac)
460 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
461 struct wacom_features *features = &wacom_wac->features;
462 struct hid_report *r;
463 struct hid_report_enum *re;
465 re = &(wacom->hdev->report_enum[HID_FEATURE_REPORT]);
466 if (features->type == INTUOSHT2)
467 r = re->report_id_hash[WACOM_REPORT_INTUOSHT2_ID];
469 r = re->report_id_hash[WACOM_REPORT_INTUOS_ID1];
471 hid_hw_request(wacom->hdev, r, HID_REQ_GET_REPORT);
475 static int wacom_intuos_pad(struct wacom_wac *wacom)
477 struct wacom_features *features = &wacom->features;
478 unsigned char *data = wacom->data;
479 struct input_dev *input = wacom->pad_input;
481 int buttons = 0, nbuttons = features->numbered_buttons;
482 int keys = 0, nkeys = 0;
483 int ring1 = 0, ring2 = 0;
484 int strip1 = 0, strip2 = 0;
486 bool wrench = false, keyboard = false, mute_touch = false, menu = false,
489 /* pad packets. Works as a second tool and is always in prox */
490 if (!(data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD ||
491 data[0] == WACOM_REPORT_CINTIQPAD))
494 if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
495 buttons = (data[3] << 1) | (data[2] & 0x01);
497 } else if (features->type == DTK) {
499 } else if (features->type == WACOM_13HD) {
500 buttons = (data[4] << 1) | (data[3] & 0x01);
501 } else if (features->type == WACOM_24HD) {
502 buttons = (data[8] << 8) | data[6];
507 * Three "buttons" are available on the 24HD which are
508 * physically implemented as a touchstrip. Each button
509 * is approximately 3 bits wide with a 2 bit spacing.
510 * The raw touchstrip bits are stored at:
511 * ((data[3] & 0x1f) << 8) | data[4])
514 keys = ((data[3] & 0x1C) ? 1<<2 : 0) |
515 ((data[4] & 0xE0) ? 1<<1 : 0) |
516 ((data[4] & 0x07) ? 1<<0 : 0);
517 keyboard = !!(data[4] & 0xE0);
518 info = !!(data[3] & 0x1C);
520 if (features->oPid) {
521 mute_touch = !!(data[4] & 0x07);
523 wacom->shared->is_touch_on =
524 !wacom->shared->is_touch_on;
526 wrench = !!(data[4] & 0x07);
528 } else if (features->type == WACOM_27QHD) {
530 keys = data[2] & 0x07;
532 wrench = !!(data[2] & 0x01);
533 keyboard = !!(data[2] & 0x02);
535 if (features->oPid) {
536 mute_touch = !!(data[2] & 0x04);
538 wacom->shared->is_touch_on =
539 !wacom->shared->is_touch_on;
541 menu = !!(data[2] & 0x04);
543 input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[4]));
544 input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[6]));
545 input_report_abs(input, ABS_Z, be16_to_cpup((__be16 *)&data[8]));
546 } else if (features->type == CINTIQ_HYBRID) {
548 * Do not send hardware buttons under Android. They
549 * are already sent to the system through GPIO (and
550 * have different meaning).
552 * d-pad right -> data[4] & 0x10
553 * d-pad up -> data[4] & 0x20
554 * d-pad left -> data[4] & 0x40
555 * d-pad down -> data[4] & 0x80
556 * d-pad center -> data[3] & 0x01
558 buttons = (data[4] << 1) | (data[3] & 0x01);
559 } else if (features->type == CINTIQ_COMPANION_2) {
560 /* d-pad right -> data[2] & 0x10
561 * d-pad up -> data[2] & 0x20
562 * d-pad left -> data[2] & 0x40
563 * d-pad down -> data[2] & 0x80
564 * d-pad center -> data[1] & 0x01
566 buttons = ((data[2] >> 4) << 7) |
567 ((data[1] & 0x04) << 4) |
568 ((data[2] & 0x0F) << 2) |
570 } else if (features->type >= INTUOS5S && features->type <= INTUOSPL) {
572 * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in
573 * addition to the mechanical switch. Switch data is
574 * stored in data[4], capacitive data in data[5].
576 * Touch ring mode switch (data[3]) has no capacitive sensor
578 buttons = (data[4] << 1) | (data[3] & 0x01);
581 if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) {
582 buttons = (data[8] << 10) | ((data[7] & 0x01) << 9) |
583 (data[6] << 1) | (data[5] & 0x01);
585 if (features->type == WACOM_22HD) {
587 keys = data[9] & 0x07;
589 info = !!(data[9] & 0x01);
590 wrench = !!(data[9] & 0x02);
593 buttons = ((data[6] & 0x10) << 5) |
594 ((data[5] & 0x10) << 4) |
595 ((data[6] & 0x0F) << 4) |
598 strip1 = ((data[1] & 0x1f) << 8) | data[2];
599 strip2 = ((data[3] & 0x1f) << 8) | data[4];
602 prox = (buttons & ~(~0U << nbuttons)) | (keys & ~(~0U << nkeys)) |
603 (ring1 & 0x80) | (ring2 & 0x80) | strip1 | strip2;
605 wacom_report_numbered_buttons(input, nbuttons, buttons);
607 for (i = 0; i < nkeys; i++)
608 input_report_key(input, KEY_PROG1 + i, keys & (1 << i));
610 input_report_key(input, KEY_BUTTONCONFIG, wrench);
611 input_report_key(input, KEY_ONSCREEN_KEYBOARD, keyboard);
612 input_report_key(input, KEY_CONTROLPANEL, menu);
613 input_report_key(input, KEY_INFO, info);
615 if (wacom->shared && wacom->shared->touch_input) {
616 input_report_switch(wacom->shared->touch_input,
618 !wacom->shared->is_touch_on);
619 input_sync(wacom->shared->touch_input);
622 input_report_abs(input, ABS_RX, strip1);
623 input_report_abs(input, ABS_RY, strip2);
625 input_report_abs(input, ABS_WHEEL, (ring1 & 0x80) ? (ring1 & 0x7f) : 0);
626 input_report_abs(input, ABS_THROTTLE, (ring2 & 0x80) ? (ring2 & 0x7f) : 0);
628 input_report_key(input, wacom->tool[1], prox ? 1 : 0);
629 input_report_abs(input, ABS_MISC, prox ? PAD_DEVICE_ID : 0);
631 input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff);
636 static int wacom_intuos_id_mangle(int tool_id)
638 return (tool_id & ~0xFFF) << 4 | (tool_id & 0xFFF);
641 static int wacom_intuos_get_tool_type(int tool_id)
646 case 0x812: /* Inking pen */
647 case 0x801: /* Intuos3 Inking pen */
648 case 0x12802: /* Intuos4/5 Inking Pen */
650 tool_type = BTN_TOOL_PENCIL;
653 case 0x822: /* Pen */
656 case 0x823: /* Intuos3 Grip Pen */
657 case 0x813: /* Intuos3 Classic Pen */
658 case 0x885: /* Intuos3 Marker Pen */
659 case 0x802: /* Intuos4/5 13HD/24HD General Pen */
660 case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
661 case 0x8e2: /* IntuosHT2 pen */
663 case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */
664 case 0x10842: /* MobileStudio Pro Pro Pen slim */
665 case 0x14802: /* Intuos4/5 13HD/24HD Classic Pen */
666 case 0x16802: /* Cintiq 13HD Pro Pen */
667 case 0x18802: /* DTH2242 Pen */
668 case 0x10802: /* Intuos4/5 13HD/24HD General Pen */
669 tool_type = BTN_TOOL_PEN;
672 case 0x832: /* Stroke pen */
674 tool_type = BTN_TOOL_BRUSH;
677 case 0x007: /* Mouse 4D and 2D */
680 case 0x017: /* Intuos3 2D Mouse */
681 case 0x806: /* Intuos4 Mouse */
682 tool_type = BTN_TOOL_MOUSE;
685 case 0x096: /* Lens cursor */
686 case 0x097: /* Intuos3 Lens cursor */
687 case 0x006: /* Intuos4 Lens cursor */
688 tool_type = BTN_TOOL_LENS;
691 case 0x82a: /* Eraser */
697 case 0x82b: /* Intuos3 Grip Pen Eraser */
698 case 0x81b: /* Intuos3 Classic Pen Eraser */
699 case 0x91b: /* Intuos3 Airbrush Eraser */
700 case 0x80c: /* Intuos4/5 13HD/24HD Marker Pen Eraser */
701 case 0x80a: /* Intuos4/5 13HD/24HD General Pen Eraser */
702 case 0x90a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
703 case 0x1480a: /* Intuos4/5 13HD/24HD Classic Pen Eraser */
704 case 0x1090a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
705 case 0x1080c: /* Intuos4/5 13HD/24HD Art Pen Eraser */
706 case 0x1084a: /* MobileStudio Pro Pro Pen slim Eraser */
707 case 0x1680a: /* Cintiq 13HD Pro Pen Eraser */
708 case 0x1880a: /* DTH2242 Eraser */
709 case 0x1080a: /* Intuos4/5 13HD/24HD General Pen Eraser */
710 tool_type = BTN_TOOL_RUBBER;
716 case 0x913: /* Intuos3 Airbrush */
717 case 0x902: /* Intuos4/5 13HD/24HD Airbrush */
718 case 0x10902: /* Intuos4/5 13HD/24HD Airbrush */
719 tool_type = BTN_TOOL_AIRBRUSH;
722 default: /* Unknown tool */
723 tool_type = BTN_TOOL_PEN;
729 static void wacom_exit_report(struct wacom_wac *wacom)
731 struct input_dev *input = wacom->pen_input;
732 struct wacom_features *features = &wacom->features;
733 unsigned char *data = wacom->data;
734 int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
737 * Reset all states otherwise we lose the initial states
738 * when in-prox next time
740 input_report_abs(input, ABS_X, 0);
741 input_report_abs(input, ABS_Y, 0);
742 input_report_abs(input, ABS_DISTANCE, 0);
743 input_report_abs(input, ABS_TILT_X, 0);
744 input_report_abs(input, ABS_TILT_Y, 0);
745 if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
746 input_report_key(input, BTN_LEFT, 0);
747 input_report_key(input, BTN_MIDDLE, 0);
748 input_report_key(input, BTN_RIGHT, 0);
749 input_report_key(input, BTN_SIDE, 0);
750 input_report_key(input, BTN_EXTRA, 0);
751 input_report_abs(input, ABS_THROTTLE, 0);
752 input_report_abs(input, ABS_RZ, 0);
754 input_report_abs(input, ABS_PRESSURE, 0);
755 input_report_key(input, BTN_STYLUS, 0);
756 input_report_key(input, BTN_STYLUS2, 0);
757 input_report_key(input, BTN_TOUCH, 0);
758 input_report_abs(input, ABS_WHEEL, 0);
759 if (features->type >= INTUOS3S)
760 input_report_abs(input, ABS_Z, 0);
762 input_report_key(input, wacom->tool[idx], 0);
763 input_report_abs(input, ABS_MISC, 0); /* reset tool id */
764 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
768 static int wacom_intuos_inout(struct wacom_wac *wacom)
770 struct wacom_features *features = &wacom->features;
771 unsigned char *data = wacom->data;
772 struct input_dev *input = wacom->pen_input;
773 int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
775 if (!(((data[1] & 0xfc) == 0xc0) || /* in prox */
776 ((data[1] & 0xfe) == 0x20) || /* in range */
777 ((data[1] & 0xfe) == 0x80))) /* out prox */
781 if ((data[1] & 0xfc) == 0xc0) {
782 /* serial number of the tool */
783 wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
784 (data[4] << 20) + (data[5] << 12) +
785 (data[6] << 4) + (data[7] >> 4);
787 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) |
788 ((data[7] & 0x0f) << 16) | ((data[8] & 0xf0) << 8);
790 wacom->tool[idx] = wacom_intuos_get_tool_type(wacom->id[idx]);
792 wacom->shared->stylus_in_proximity = true;
797 if ((data[1] & 0xfe) == 0x20) {
798 if (features->type != INTUOSHT2)
799 wacom->shared->stylus_in_proximity = true;
801 /* in Range while exiting */
802 if (wacom->reporting_data) {
803 input_report_key(input, BTN_TOUCH, 0);
804 input_report_abs(input, ABS_PRESSURE, 0);
805 input_report_abs(input, ABS_DISTANCE, wacom->features.distance_max);
812 if ((data[1] & 0xfe) == 0x80) {
813 wacom->shared->stylus_in_proximity = false;
814 wacom->reporting_data = false;
816 /* don't report exit if we don't know the ID */
820 wacom_exit_report(wacom);
827 static inline bool report_touch_events(struct wacom_wac *wacom)
829 return (touch_arbitration ? !wacom->shared->stylus_in_proximity : 1);
832 static inline bool delay_pen_events(struct wacom_wac *wacom)
834 return (wacom->shared->touch_down && touch_arbitration);
837 static int wacom_intuos_general(struct wacom_wac *wacom)
839 struct wacom_features *features = &wacom->features;
840 unsigned char *data = wacom->data;
841 struct input_dev *input = wacom->pen_input;
842 int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
843 unsigned char type = (data[1] >> 1) & 0x0F;
844 unsigned int x, y, distance, t;
846 if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_CINTIQ &&
847 data[0] != WACOM_REPORT_INTUOS_PEN)
850 if (delay_pen_events(wacom))
853 /* don't report events if we don't know the tool ID */
854 if (!wacom->id[idx]) {
855 /* but reschedule a read of the current tool */
856 wacom_intuos_schedule_prox_event(wacom);
861 * don't report events for invalid data
863 /* older I4 styli don't work with new Cintiqs */
864 if ((!((wacom->id[idx] >> 16) & 0x01) &&
865 (features->type == WACOM_21UX2)) ||
866 /* Only large Intuos support Lense Cursor */
867 (wacom->tool[idx] == BTN_TOOL_LENS &&
868 (features->type == INTUOS3 ||
869 features->type == INTUOS3S ||
870 features->type == INTUOS4 ||
871 features->type == INTUOS4S ||
872 features->type == INTUOS5 ||
873 features->type == INTUOS5S ||
874 features->type == INTUOSPM ||
875 features->type == INTUOSPS)) ||
876 /* Cintiq doesn't send data when RDY bit isn't set */
877 (features->type == CINTIQ && !(data[1] & 0x40)))
880 x = (be16_to_cpup((__be16 *)&data[2]) << 1) | ((data[9] >> 1) & 1);
881 y = (be16_to_cpup((__be16 *)&data[4]) << 1) | (data[9] & 1);
882 distance = data[9] >> 2;
883 if (features->type < INTUOS3S) {
888 if (features->type == INTUOSHT2)
889 distance = features->distance_max - distance;
890 input_report_abs(input, ABS_X, x);
891 input_report_abs(input, ABS_Y, y);
892 input_report_abs(input, ABS_DISTANCE, distance);
899 /* general pen packet */
900 t = (data[6] << 3) | ((data[7] & 0xC0) >> 5) | (data[1] & 1);
901 if (features->pressure_max < 2047)
903 input_report_abs(input, ABS_PRESSURE, t);
904 if (features->type != INTUOSHT2) {
905 input_report_abs(input, ABS_TILT_X,
906 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
907 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
909 input_report_key(input, BTN_STYLUS, data[1] & 2);
910 input_report_key(input, BTN_STYLUS2, data[1] & 4);
911 input_report_key(input, BTN_TOUCH, t > 10);
915 /* airbrush second packet */
916 input_report_abs(input, ABS_WHEEL,
917 (data[6] << 2) | ((data[7] >> 6) & 3));
918 input_report_abs(input, ABS_TILT_X,
919 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
920 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
924 /* Rotation packet */
925 if (features->type >= INTUOS3S) {
926 /* I3 marker pen rotation */
927 t = (data[6] << 3) | ((data[7] >> 5) & 7);
928 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
929 ((t-1) / 2 + 450)) : (450 - t / 2) ;
930 input_report_abs(input, ABS_Z, t);
932 /* 4D mouse 2nd packet */
933 t = (data[6] << 3) | ((data[7] >> 5) & 7);
934 input_report_abs(input, ABS_RZ, (data[7] & 0x20) ?
935 ((t - 1) / 2) : -t / 2);
940 /* 4D mouse 1st packet */
941 input_report_key(input, BTN_LEFT, data[8] & 0x01);
942 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
943 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
945 input_report_key(input, BTN_SIDE, data[8] & 0x20);
946 input_report_key(input, BTN_EXTRA, data[8] & 0x10);
947 t = (data[6] << 2) | ((data[7] >> 6) & 3);
948 input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
953 input_report_key(input, BTN_LEFT, data[6] & 0x01);
954 input_report_key(input, BTN_MIDDLE, data[6] & 0x02);
955 input_report_key(input, BTN_RIGHT, data[6] & 0x04);
956 input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7)
957 - ((data[7] & 0x40) >> 6));
958 input_report_key(input, BTN_SIDE, data[6] & 0x08);
959 input_report_key(input, BTN_EXTRA, data[6] & 0x10);
961 input_report_abs(input, ABS_TILT_X,
962 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
963 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
967 if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
968 /* 2D mouse packet */
969 input_report_key(input, BTN_LEFT, data[8] & 0x04);
970 input_report_key(input, BTN_MIDDLE, data[8] & 0x08);
971 input_report_key(input, BTN_RIGHT, data[8] & 0x10);
972 input_report_rel(input, REL_WHEEL, (data[8] & 0x01)
973 - ((data[8] & 0x02) >> 1));
975 /* I3 2D mouse side buttons */
976 if (features->type >= INTUOS3S && features->type <= INTUOS3L) {
977 input_report_key(input, BTN_SIDE, data[8] & 0x40);
978 input_report_key(input, BTN_EXTRA, data[8] & 0x20);
981 else if (wacom->tool[idx] == BTN_TOOL_LENS) {
982 /* Lens cursor packets */
983 input_report_key(input, BTN_LEFT, data[8] & 0x01);
984 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
985 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
986 input_report_key(input, BTN_SIDE, data[8] & 0x10);
987 input_report_key(input, BTN_EXTRA, data[8] & 0x08);
1002 input_report_abs(input, ABS_MISC,
1003 wacom_intuos_id_mangle(wacom->id[idx])); /* report tool id */
1004 input_report_key(input, wacom->tool[idx], 1);
1005 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
1006 wacom->reporting_data = true;
1010 static int wacom_intuos_irq(struct wacom_wac *wacom)
1012 unsigned char *data = wacom->data;
1013 struct input_dev *input = wacom->pen_input;
1016 if (data[0] != WACOM_REPORT_PENABLED &&
1017 data[0] != WACOM_REPORT_INTUOS_ID1 &&
1018 data[0] != WACOM_REPORT_INTUOS_ID2 &&
1019 data[0] != WACOM_REPORT_INTUOSPAD &&
1020 data[0] != WACOM_REPORT_INTUOS_PEN &&
1021 data[0] != WACOM_REPORT_CINTIQ &&
1022 data[0] != WACOM_REPORT_CINTIQPAD &&
1023 data[0] != WACOM_REPORT_INTUOS5PAD) {
1024 dev_dbg(input->dev.parent,
1025 "%s: received unknown report #%d\n", __func__, data[0]);
1029 /* process pad events */
1030 result = wacom_intuos_pad(wacom);
1034 /* process in/out prox events */
1035 result = wacom_intuos_inout(wacom);
1039 /* process general packets */
1040 result = wacom_intuos_general(wacom);
1047 static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len)
1049 unsigned char *data = wacom_wac->data;
1050 struct input_dev *input;
1051 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
1052 struct wacom_remote *remote = wacom->remote;
1053 int bat_charging, bat_percent, touch_ring_mode;
1056 unsigned long flags;
1058 if (data[0] != WACOM_REPORT_REMOTE) {
1059 hid_dbg(wacom->hdev, "%s: received unknown report #%d",
1064 serial = data[3] + (data[4] << 8) + (data[5] << 16);
1065 wacom_wac->id[0] = PAD_DEVICE_ID;
1067 spin_lock_irqsave(&remote->remote_lock, flags);
1069 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
1070 if (remote->remotes[i].serial == serial) {
1076 if (index < 0 || !remote->remotes[index].registered)
1079 input = remote->remotes[index].input;
1081 input_report_key(input, BTN_0, (data[9] & 0x01));
1082 input_report_key(input, BTN_1, (data[9] & 0x02));
1083 input_report_key(input, BTN_2, (data[9] & 0x04));
1084 input_report_key(input, BTN_3, (data[9] & 0x08));
1085 input_report_key(input, BTN_4, (data[9] & 0x10));
1086 input_report_key(input, BTN_5, (data[9] & 0x20));
1087 input_report_key(input, BTN_6, (data[9] & 0x40));
1088 input_report_key(input, BTN_7, (data[9] & 0x80));
1090 input_report_key(input, BTN_8, (data[10] & 0x01));
1091 input_report_key(input, BTN_9, (data[10] & 0x02));
1092 input_report_key(input, BTN_A, (data[10] & 0x04));
1093 input_report_key(input, BTN_B, (data[10] & 0x08));
1094 input_report_key(input, BTN_C, (data[10] & 0x10));
1095 input_report_key(input, BTN_X, (data[10] & 0x20));
1096 input_report_key(input, BTN_Y, (data[10] & 0x40));
1097 input_report_key(input, BTN_Z, (data[10] & 0x80));
1099 input_report_key(input, BTN_BASE, (data[11] & 0x01));
1100 input_report_key(input, BTN_BASE2, (data[11] & 0x02));
1102 if (data[12] & 0x80)
1103 input_report_abs(input, ABS_WHEEL, (data[12] & 0x7f) - 1);
1105 input_report_abs(input, ABS_WHEEL, 0);
1107 bat_percent = data[7] & 0x7f;
1108 bat_charging = !!(data[7] & 0x80);
1110 if (data[9] | data[10] | (data[11] & 0x03) | data[12])
1111 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
1113 input_report_abs(input, ABS_MISC, 0);
1115 input_event(input, EV_MSC, MSC_SERIAL, serial);
1119 /*Which mode select (LED light) is currently on?*/
1120 touch_ring_mode = (data[11] & 0xC0) >> 6;
1122 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
1123 if (remote->remotes[i].serial == serial)
1124 wacom->led.groups[i].select = touch_ring_mode;
1127 __wacom_notify_battery(&remote->remotes[index].battery,
1128 WACOM_POWER_SUPPLY_STATUS_AUTO, bat_percent,
1129 bat_charging, 1, bat_charging);
1132 spin_unlock_irqrestore(&remote->remote_lock, flags);
1136 static void wacom_remote_status_irq(struct wacom_wac *wacom_wac, size_t len)
1138 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
1139 unsigned char *data = wacom_wac->data;
1140 struct wacom_remote *remote = wacom->remote;
1141 struct wacom_remote_data remote_data;
1142 unsigned long flags;
1145 if (data[0] != WACOM_REPORT_DEVICE_LIST)
1148 memset(&remote_data, 0, sizeof(struct wacom_remote_data));
1150 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
1152 int serial = (data[j+6] << 16) + (data[j+5] << 8) + data[j+4];
1153 bool connected = data[j+2];
1155 remote_data.remote[i].serial = serial;
1156 remote_data.remote[i].connected = connected;
1159 spin_lock_irqsave(&remote->remote_lock, flags);
1161 ret = kfifo_in(&remote->remote_fifo, &remote_data, sizeof(remote_data));
1162 if (ret != sizeof(remote_data)) {
1163 spin_unlock_irqrestore(&remote->remote_lock, flags);
1164 hid_err(wacom->hdev, "Can't queue Remote status event.\n");
1168 spin_unlock_irqrestore(&remote->remote_lock, flags);
1170 wacom_schedule_work(wacom_wac, WACOM_WORKER_REMOTE);
1173 static int int_dist(int x1, int y1, int x2, int y2)
1178 return int_sqrt(x*x + y*y);
1181 static void wacom_intuos_bt_process_data(struct wacom_wac *wacom,
1182 unsigned char *data)
1184 memcpy(wacom->data, data, 10);
1185 wacom_intuos_irq(wacom);
1187 input_sync(wacom->pen_input);
1188 if (wacom->pad_input)
1189 input_sync(wacom->pad_input);
1192 static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
1194 unsigned char data[WACOM_PKGLEN_MAX];
1196 unsigned power_raw, battery_capacity, bat_charging, ps_connected;
1198 memcpy(data, wacom->data, len);
1202 wacom_intuos_bt_process_data(wacom, data + i);
1206 wacom_intuos_bt_process_data(wacom, data + i);
1208 wacom_intuos_bt_process_data(wacom, data + i);
1210 power_raw = data[i];
1211 bat_charging = (power_raw & 0x08) ? 1 : 0;
1212 ps_connected = (power_raw & 0x10) ? 1 : 0;
1213 battery_capacity = batcap_i4[power_raw & 0x07];
1214 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
1215 battery_capacity, bat_charging,
1216 battery_capacity || bat_charging,
1220 dev_dbg(wacom->pen_input->dev.parent,
1221 "Unknown report: %d,%d size:%zu\n",
1222 data[0], data[1], len);
1228 static int wacom_wac_finger_count_touches(struct wacom_wac *wacom)
1230 struct input_dev *input = wacom->touch_input;
1231 unsigned touch_max = wacom->features.touch_max;
1239 return test_bit(BTN_TOUCH, input->key) &&
1240 report_touch_events(wacom);
1242 for (i = 0; i < input->mt->num_slots; i++) {
1243 struct input_mt_slot *ps = &input->mt->slots[i];
1244 int id = input_mt_get_value(ps, ABS_MT_TRACKING_ID);
1252 static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
1254 int pen_frame_len, pen_frames;
1256 struct input_dev *pen_input = wacom->pen_input;
1257 unsigned char *data = wacom->data;
1260 if (wacom->features.type == INTUOSP2_BT ||
1261 wacom->features.type == INTUOSP2S_BT) {
1262 wacom->serial[0] = get_unaligned_le64(&data[99]);
1263 wacom->id[0] = get_unaligned_le16(&data[107]);
1267 wacom->serial[0] = get_unaligned_le64(&data[33]);
1268 wacom->id[0] = get_unaligned_le16(&data[41]);
1273 if (wacom->serial[0] >> 52 == 1) {
1274 /* Add back in missing bits of ID for non-USI pens */
1275 wacom->id[0] |= (wacom->serial[0] >> 32) & 0xFFFFF;
1278 for (i = 0; i < pen_frames; i++) {
1279 unsigned char *frame = &data[i*pen_frame_len + 1];
1280 bool valid = frame[0] & 0x80;
1281 bool prox = frame[0] & 0x40;
1282 bool range = frame[0] & 0x20;
1283 bool invert = frame[0] & 0x10;
1289 wacom->shared->stylus_in_proximity = false;
1290 wacom_exit_report(wacom);
1291 input_sync(pen_input);
1295 wacom->serial[0] = 0;
1300 if (!wacom->tool[0]) { /* first in range */
1301 /* Going into range select tool */
1303 wacom->tool[0] = BTN_TOOL_RUBBER;
1304 else if (wacom->id[0])
1305 wacom->tool[0] = wacom_intuos_get_tool_type(wacom->id[0]);
1307 wacom->tool[0] = BTN_TOOL_PEN;
1310 input_report_abs(pen_input, ABS_X, get_unaligned_le16(&frame[1]));
1311 input_report_abs(pen_input, ABS_Y, get_unaligned_le16(&frame[3]));
1313 if (wacom->features.type == INTUOSP2_BT ||
1314 wacom->features.type == INTUOSP2S_BT) {
1315 /* Fix rotation alignment: userspace expects zero at left */
1317 (int16_t)get_unaligned_le16(&frame[9]);
1323 input_report_abs(pen_input, ABS_TILT_X,
1325 input_report_abs(pen_input, ABS_TILT_Y,
1327 input_report_abs(pen_input, ABS_Z, rotation);
1328 input_report_abs(pen_input, ABS_WHEEL,
1329 get_unaligned_le16(&frame[11]));
1332 if (wacom->tool[0]) {
1333 input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5]));
1334 if (wacom->features.type == INTUOSP2_BT ||
1335 wacom->features.type == INTUOSP2S_BT) {
1336 input_report_abs(pen_input, ABS_DISTANCE,
1337 range ? frame[13] : wacom->features.distance_max);
1339 input_report_abs(pen_input, ABS_DISTANCE,
1340 range ? frame[7] : wacom->features.distance_max);
1343 input_report_key(pen_input, BTN_TOUCH, frame[0] & 0x09);
1344 input_report_key(pen_input, BTN_STYLUS, frame[0] & 0x02);
1345 input_report_key(pen_input, BTN_STYLUS2, frame[0] & 0x04);
1347 input_report_key(pen_input, wacom->tool[0], prox);
1348 input_event(pen_input, EV_MSC, MSC_SERIAL, wacom->serial[0]);
1349 input_report_abs(pen_input, ABS_MISC,
1350 wacom_intuos_id_mangle(wacom->id[0])); /* report tool id */
1353 wacom->shared->stylus_in_proximity = prox;
1355 input_sync(pen_input);
1359 static void wacom_intuos_pro2_bt_touch(struct wacom_wac *wacom)
1361 const int finger_touch_len = 8;
1362 const int finger_frames = 4;
1363 const int finger_frame_len = 43;
1365 struct input_dev *touch_input = wacom->touch_input;
1366 unsigned char *data = wacom->data;
1367 int num_contacts_left = 5;
1370 for (i = 0; i < finger_frames; i++) {
1371 unsigned char *frame = &data[i*finger_frame_len + 109];
1372 int current_num_contacts = frame[0] & 0x7F;
1373 int contacts_to_send;
1375 if (!(frame[0] & 0x80))
1379 * First packet resets the counter since only the first
1380 * packet in series will have non-zero current_num_contacts.
1382 if (current_num_contacts)
1383 wacom->num_contacts_left = current_num_contacts;
1385 contacts_to_send = min(num_contacts_left, wacom->num_contacts_left);
1387 for (j = 0; j < contacts_to_send; j++) {
1388 unsigned char *touch = &frame[j*finger_touch_len + 1];
1389 int slot = input_mt_get_slot_by_key(touch_input, touch[0]);
1390 int x = get_unaligned_le16(&touch[2]);
1391 int y = get_unaligned_le16(&touch[4]);
1392 int w = touch[6] * input_abs_get_res(touch_input, ABS_MT_POSITION_X);
1393 int h = touch[7] * input_abs_get_res(touch_input, ABS_MT_POSITION_Y);
1398 input_mt_slot(touch_input, slot);
1399 input_mt_report_slot_state(touch_input, MT_TOOL_FINGER, touch[1] & 0x01);
1400 input_report_abs(touch_input, ABS_MT_POSITION_X, x);
1401 input_report_abs(touch_input, ABS_MT_POSITION_Y, y);
1402 input_report_abs(touch_input, ABS_MT_TOUCH_MAJOR, max(w, h));
1403 input_report_abs(touch_input, ABS_MT_TOUCH_MINOR, min(w, h));
1404 input_report_abs(touch_input, ABS_MT_ORIENTATION, w > h);
1407 input_mt_sync_frame(touch_input);
1409 wacom->num_contacts_left -= contacts_to_send;
1410 if (wacom->num_contacts_left <= 0) {
1411 wacom->num_contacts_left = 0;
1412 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1413 input_sync(touch_input);
1417 if (wacom->num_contacts_left == 0) {
1418 // Be careful that we don't accidentally call input_sync with
1419 // only a partial set of fingers of processed
1420 input_report_switch(touch_input, SW_MUTE_DEVICE, !(data[281] >> 7));
1421 input_sync(touch_input);
1426 static void wacom_intuos_pro2_bt_pad(struct wacom_wac *wacom)
1428 struct input_dev *pad_input = wacom->pad_input;
1429 unsigned char *data = wacom->data;
1430 int nbuttons = wacom->features.numbered_buttons;
1432 int expresskeys = data[282];
1433 int center = (data[281] & 0x40) >> 6;
1434 int ring = data[285] & 0x7F;
1435 bool ringstatus = data[285] & 0x80;
1436 bool prox = expresskeys || center || ringstatus;
1438 /* Fix touchring data: userspace expects 0 at left and increasing clockwise */
1444 wacom_report_numbered_buttons(pad_input, nbuttons,
1445 expresskeys | (center << (nbuttons - 1)));
1447 input_report_abs(pad_input, ABS_WHEEL, ringstatus ? ring : 0);
1449 input_report_key(pad_input, wacom->tool[1], prox ? 1 : 0);
1450 input_report_abs(pad_input, ABS_MISC, prox ? PAD_DEVICE_ID : 0);
1451 input_event(pad_input, EV_MSC, MSC_SERIAL, 0xffffffff);
1453 input_sync(pad_input);
1456 static void wacom_intuos_pro2_bt_battery(struct wacom_wac *wacom)
1458 unsigned char *data = wacom->data;
1460 bool chg = data[284] & 0x80;
1461 int battery_status = data[284] & 0x7F;
1463 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
1464 battery_status, chg, 1, chg);
1467 static void wacom_intuos_gen3_bt_pad(struct wacom_wac *wacom)
1469 struct input_dev *pad_input = wacom->pad_input;
1470 unsigned char *data = wacom->data;
1472 int buttons = data[44];
1474 wacom_report_numbered_buttons(pad_input, 4, buttons);
1476 input_report_key(pad_input, wacom->tool[1], buttons ? 1 : 0);
1477 input_report_abs(pad_input, ABS_MISC, buttons ? PAD_DEVICE_ID : 0);
1478 input_event(pad_input, EV_MSC, MSC_SERIAL, 0xffffffff);
1480 input_sync(pad_input);
1483 static void wacom_intuos_gen3_bt_battery(struct wacom_wac *wacom)
1485 unsigned char *data = wacom->data;
1487 bool chg = data[45] & 0x80;
1488 int battery_status = data[45] & 0x7F;
1490 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
1491 battery_status, chg, 1, chg);
1494 static int wacom_intuos_pro2_bt_irq(struct wacom_wac *wacom, size_t len)
1496 unsigned char *data = wacom->data;
1498 if (data[0] != 0x80 && data[0] != 0x81) {
1499 dev_dbg(wacom->pen_input->dev.parent,
1500 "%s: received unknown report #%d\n", __func__, data[0]);
1504 wacom_intuos_pro2_bt_pen(wacom);
1505 if (wacom->features.type == INTUOSP2_BT ||
1506 wacom->features.type == INTUOSP2S_BT) {
1507 wacom_intuos_pro2_bt_touch(wacom);
1508 wacom_intuos_pro2_bt_pad(wacom);
1509 wacom_intuos_pro2_bt_battery(wacom);
1511 wacom_intuos_gen3_bt_pad(wacom);
1512 wacom_intuos_gen3_bt_battery(wacom);
1517 static int wacom_24hdt_irq(struct wacom_wac *wacom)
1519 struct input_dev *input = wacom->touch_input;
1520 unsigned char *data = wacom->data;
1522 int current_num_contacts = data[61];
1523 int contacts_to_send = 0;
1524 int num_contacts_left = 4; /* maximum contacts per packet */
1525 int byte_per_packet = WACOM_BYTES_PER_24HDT_PACKET;
1528 if (wacom->shared->has_mute_touch_switch &&
1529 !wacom->shared->is_touch_on) {
1530 if (!wacom->shared->touch_down)
1534 if (wacom->features.type == WACOM_27QHDT) {
1535 current_num_contacts = data[63];
1536 num_contacts_left = 10;
1537 byte_per_packet = WACOM_BYTES_PER_QHDTHID_PACKET;
1542 * First packet resets the counter since only the first
1543 * packet in series will have non-zero current_num_contacts.
1545 if (current_num_contacts)
1546 wacom->num_contacts_left = current_num_contacts;
1548 contacts_to_send = min(num_contacts_left, wacom->num_contacts_left);
1550 for (i = 0; i < contacts_to_send; i++) {
1551 int offset = (byte_per_packet * i) + 1;
1552 bool touch = (data[offset] & 0x1) && report_touch_events(wacom);
1553 int slot = input_mt_get_slot_by_key(input, data[offset + 1]);
1557 input_mt_slot(input, slot);
1558 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1561 int t_x = get_unaligned_le16(&data[offset + 2]);
1562 int t_y = get_unaligned_le16(&data[offset + 4 + y_offset]);
1564 input_report_abs(input, ABS_MT_POSITION_X, t_x);
1565 input_report_abs(input, ABS_MT_POSITION_Y, t_y);
1567 if (wacom->features.type != WACOM_27QHDT) {
1568 int c_x = get_unaligned_le16(&data[offset + 4]);
1569 int c_y = get_unaligned_le16(&data[offset + 8]);
1570 int w = get_unaligned_le16(&data[offset + 10]);
1571 int h = get_unaligned_le16(&data[offset + 12]);
1573 input_report_abs(input, ABS_MT_TOUCH_MAJOR, min(w,h));
1574 input_report_abs(input, ABS_MT_WIDTH_MAJOR,
1575 min(w, h) + int_dist(t_x, t_y, c_x, c_y));
1576 input_report_abs(input, ABS_MT_WIDTH_MINOR, min(w, h));
1577 input_report_abs(input, ABS_MT_ORIENTATION, w > h);
1581 input_mt_sync_frame(input);
1583 wacom->num_contacts_left -= contacts_to_send;
1584 if (wacom->num_contacts_left <= 0) {
1585 wacom->num_contacts_left = 0;
1586 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1591 static int wacom_mt_touch(struct wacom_wac *wacom)
1593 struct input_dev *input = wacom->touch_input;
1594 unsigned char *data = wacom->data;
1596 int current_num_contacts = data[2];
1597 int contacts_to_send = 0;
1600 /* MTTPC does not support Height and Width */
1601 if (wacom->features.type == MTTPC || wacom->features.type == MTTPC_B)
1605 * First packet resets the counter since only the first
1606 * packet in series will have non-zero current_num_contacts.
1608 if (current_num_contacts)
1609 wacom->num_contacts_left = current_num_contacts;
1611 /* There are at most 5 contacts per packet */
1612 contacts_to_send = min(5, wacom->num_contacts_left);
1614 for (i = 0; i < contacts_to_send; i++) {
1615 int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset) * i + 3;
1616 bool touch = (data[offset] & 0x1) && report_touch_events(wacom);
1617 int id = get_unaligned_le16(&data[offset + 1]);
1618 int slot = input_mt_get_slot_by_key(input, id);
1623 input_mt_slot(input, slot);
1624 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1626 int x = get_unaligned_le16(&data[offset + x_offset + 7]);
1627 int y = get_unaligned_le16(&data[offset + x_offset + 9]);
1628 input_report_abs(input, ABS_MT_POSITION_X, x);
1629 input_report_abs(input, ABS_MT_POSITION_Y, y);
1632 input_mt_sync_frame(input);
1634 wacom->num_contacts_left -= contacts_to_send;
1635 if (wacom->num_contacts_left <= 0) {
1636 wacom->num_contacts_left = 0;
1637 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1642 static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
1644 struct input_dev *input = wacom->touch_input;
1645 unsigned char *data = wacom->data;
1648 for (i = 0; i < 2; i++) {
1649 int p = data[1] & (1 << i);
1650 bool touch = p && report_touch_events(wacom);
1652 input_mt_slot(input, i);
1653 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1655 int x = le16_to_cpup((__le16 *)&data[i * 2 + 2]) & 0x7fff;
1656 int y = le16_to_cpup((__le16 *)&data[i * 2 + 6]) & 0x7fff;
1658 input_report_abs(input, ABS_MT_POSITION_X, x);
1659 input_report_abs(input, ABS_MT_POSITION_Y, y);
1662 input_mt_sync_frame(input);
1664 /* keep touch state for pen event */
1665 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1670 static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
1672 unsigned char *data = wacom->data;
1673 struct input_dev *input = wacom->touch_input;
1674 bool prox = report_touch_events(wacom);
1677 if (wacom->features.touch_max > 1 || len > WACOM_PKGLEN_TPC2FG)
1680 if (len == WACOM_PKGLEN_TPC1FG) {
1681 prox = prox && (data[0] & 0x01);
1682 x = get_unaligned_le16(&data[1]);
1683 y = get_unaligned_le16(&data[3]);
1684 } else if (len == WACOM_PKGLEN_TPC1FG_B) {
1685 prox = prox && (data[2] & 0x01);
1686 x = get_unaligned_le16(&data[3]);
1687 y = get_unaligned_le16(&data[5]);
1689 prox = prox && (data[1] & 0x01);
1690 x = le16_to_cpup((__le16 *)&data[2]);
1691 y = le16_to_cpup((__le16 *)&data[4]);
1695 input_report_abs(input, ABS_X, x);
1696 input_report_abs(input, ABS_Y, y);
1698 input_report_key(input, BTN_TOUCH, prox);
1700 /* keep touch state for pen events */
1701 wacom->shared->touch_down = prox;
1706 static int wacom_tpc_pen(struct wacom_wac *wacom)
1708 unsigned char *data = wacom->data;
1709 struct input_dev *input = wacom->pen_input;
1710 bool prox = data[1] & 0x20;
1712 if (!wacom->shared->stylus_in_proximity) /* first in prox */
1713 /* Going into proximity select tool */
1714 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
1716 /* keep pen state for touch events */
1717 wacom->shared->stylus_in_proximity = prox;
1719 /* send pen events only when touch is up or forced out
1720 * or touch arbitration is off
1722 if (!delay_pen_events(wacom)) {
1723 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
1724 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
1725 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
1726 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
1727 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x07) << 8) | data[6]);
1728 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
1729 input_report_key(input, wacom->tool[0], prox);
1736 static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
1738 unsigned char *data = wacom->data;
1740 if (wacom->pen_input) {
1741 dev_dbg(wacom->pen_input->dev.parent,
1742 "%s: received report #%d\n", __func__, data[0]);
1744 if (len == WACOM_PKGLEN_PENABLED ||
1745 data[0] == WACOM_REPORT_PENABLED)
1746 return wacom_tpc_pen(wacom);
1748 else if (wacom->touch_input) {
1749 dev_dbg(wacom->touch_input->dev.parent,
1750 "%s: received report #%d\n", __func__, data[0]);
1753 case WACOM_PKGLEN_TPC1FG:
1754 return wacom_tpc_single_touch(wacom, len);
1756 case WACOM_PKGLEN_TPC2FG:
1757 return wacom_tpc_mt_touch(wacom);
1761 case WACOM_REPORT_TPC1FG:
1762 case WACOM_REPORT_TPCHID:
1763 case WACOM_REPORT_TPCST:
1764 case WACOM_REPORT_TPC1FGE:
1765 return wacom_tpc_single_touch(wacom, len);
1767 case WACOM_REPORT_TPCMT:
1768 case WACOM_REPORT_TPCMT2:
1769 return wacom_mt_touch(wacom);
1778 static int wacom_offset_rotation(struct input_dev *input, struct hid_usage *usage,
1779 int value, int num, int denom)
1781 struct input_absinfo *abs = &input->absinfo[usage->code];
1782 int range = (abs->maximum - abs->minimum + 1);
1784 value += num*range/denom;
1785 if (value > abs->maximum)
1787 else if (value < abs->minimum)
1792 int wacom_equivalent_usage(int usage)
1794 if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMDIGITIZER) {
1795 int subpage = (usage & 0xFF00) << 8;
1796 int subusage = (usage & 0xFF);
1798 if (subpage == WACOM_HID_SP_PAD ||
1799 subpage == WACOM_HID_SP_BUTTON ||
1800 subpage == WACOM_HID_SP_DIGITIZER ||
1801 subpage == WACOM_HID_SP_DIGITIZERINFO ||
1802 usage == WACOM_HID_WD_SENSE ||
1803 usage == WACOM_HID_WD_SERIALHI ||
1804 usage == WACOM_HID_WD_TOOLTYPE ||
1805 usage == WACOM_HID_WD_DISTANCE ||
1806 usage == WACOM_HID_WD_TOUCHSTRIP ||
1807 usage == WACOM_HID_WD_TOUCHSTRIP2 ||
1808 usage == WACOM_HID_WD_TOUCHRING ||
1809 usage == WACOM_HID_WD_TOUCHRINGSTATUS ||
1810 usage == WACOM_HID_WD_REPORT_VALID) {
1814 if (subpage == HID_UP_UNDEFINED)
1815 subpage = HID_UP_DIGITIZER;
1817 return subpage | subusage;
1820 if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMTOUCH) {
1821 int subpage = (usage & 0xFF00) << 8;
1822 int subusage = (usage & 0xFF);
1824 if (usage == WACOM_HID_WT_REPORT_VALID)
1827 if (subpage == HID_UP_UNDEFINED)
1828 subpage = WACOM_HID_SP_DIGITIZER;
1830 return subpage | subusage;
1836 static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
1837 struct hid_field *field, __u8 type, __u16 code, int fuzz)
1839 struct wacom *wacom = input_get_drvdata(input);
1840 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1841 struct wacom_features *features = &wacom_wac->features;
1842 int fmin = field->logical_minimum;
1843 int fmax = field->logical_maximum;
1844 unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid);
1845 int resolution_code = code;
1847 if (equivalent_usage == HID_DG_TWIST) {
1848 resolution_code = ABS_RZ;
1851 if (equivalent_usage == HID_GD_X) {
1852 fmin += features->offset_left;
1853 fmax -= features->offset_right;
1855 if (equivalent_usage == HID_GD_Y) {
1856 fmin += features->offset_top;
1857 fmax -= features->offset_bottom;
1863 set_bit(type, input->evbit);
1867 input_set_abs_params(input, code, fmin, fmax, fuzz, 0);
1868 input_abs_set_res(input, code,
1869 hidinput_calc_abs_res(field, resolution_code));
1872 input_set_capability(input, EV_KEY, code);
1875 input_set_capability(input, EV_MSC, code);
1878 input_set_capability(input, EV_SW, code);
1883 static void wacom_wac_battery_usage_mapping(struct hid_device *hdev,
1884 struct hid_field *field, struct hid_usage *usage)
1886 struct wacom *wacom = hid_get_drvdata(hdev);
1887 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1888 struct wacom_features *features = &wacom_wac->features;
1889 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
1891 switch (equivalent_usage) {
1892 case HID_DG_BATTERYSTRENGTH:
1893 case WACOM_HID_WD_BATTERY_LEVEL:
1894 case WACOM_HID_WD_BATTERY_CHARGING:
1895 features->quirks |= WACOM_QUIRK_BATTERY;
1900 static void wacom_wac_battery_event(struct hid_device *hdev, struct hid_field *field,
1901 struct hid_usage *usage, __s32 value)
1903 struct wacom *wacom = hid_get_drvdata(hdev);
1904 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1905 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
1907 switch (equivalent_usage) {
1908 case HID_DG_BATTERYSTRENGTH:
1910 wacom_wac->hid_data.bat_status = POWER_SUPPLY_STATUS_UNKNOWN;
1913 value = value * 100 / (field->logical_maximum - field->logical_minimum);
1914 wacom_wac->hid_data.battery_capacity = value;
1915 wacom_wac->hid_data.bat_connected = 1;
1916 wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
1919 case WACOM_HID_WD_BATTERY_LEVEL:
1920 value = value * 100 / (field->logical_maximum - field->logical_minimum);
1921 wacom_wac->hid_data.battery_capacity = value;
1922 wacom_wac->hid_data.bat_connected = 1;
1923 wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
1925 case WACOM_HID_WD_BATTERY_CHARGING:
1926 wacom_wac->hid_data.bat_charging = value;
1927 wacom_wac->hid_data.ps_connected = value;
1928 wacom_wac->hid_data.bat_connected = 1;
1929 wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
1934 static void wacom_wac_battery_pre_report(struct hid_device *hdev,
1935 struct hid_report *report)
1940 static void wacom_wac_battery_report(struct hid_device *hdev,
1941 struct hid_report *report)
1943 struct wacom *wacom = hid_get_drvdata(hdev);
1944 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1945 struct wacom_features *features = &wacom_wac->features;
1947 if (features->quirks & WACOM_QUIRK_BATTERY) {
1948 int status = wacom_wac->hid_data.bat_status;
1949 int capacity = wacom_wac->hid_data.battery_capacity;
1950 bool charging = wacom_wac->hid_data.bat_charging;
1951 bool connected = wacom_wac->hid_data.bat_connected;
1952 bool powered = wacom_wac->hid_data.ps_connected;
1954 wacom_notify_battery(wacom_wac, status, capacity, charging,
1955 connected, powered);
1959 static void wacom_wac_pad_usage_mapping(struct hid_device *hdev,
1960 struct hid_field *field, struct hid_usage *usage)
1962 struct wacom *wacom = hid_get_drvdata(hdev);
1963 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1964 struct wacom_features *features = &wacom_wac->features;
1965 struct input_dev *input = wacom_wac->pad_input;
1966 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
1968 switch (equivalent_usage) {
1969 case WACOM_HID_WD_ACCELEROMETER_X:
1970 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
1971 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 0);
1972 features->device_type |= WACOM_DEVICETYPE_PAD;
1974 case WACOM_HID_WD_ACCELEROMETER_Y:
1975 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
1976 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 0);
1977 features->device_type |= WACOM_DEVICETYPE_PAD;
1979 case WACOM_HID_WD_ACCELEROMETER_Z:
1980 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
1981 wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0);
1982 features->device_type |= WACOM_DEVICETYPE_PAD;
1984 case WACOM_HID_WD_BUTTONCENTER:
1985 case WACOM_HID_WD_BUTTONHOME:
1986 case WACOM_HID_WD_BUTTONUP:
1987 case WACOM_HID_WD_BUTTONDOWN:
1988 case WACOM_HID_WD_BUTTONLEFT:
1989 case WACOM_HID_WD_BUTTONRIGHT:
1990 wacom_map_usage(input, usage, field, EV_KEY,
1991 wacom_numbered_button_to_key(features->numbered_buttons),
1993 features->numbered_buttons++;
1994 features->device_type |= WACOM_DEVICETYPE_PAD;
1996 case WACOM_HID_WD_TOUCHONOFF:
1997 case WACOM_HID_WD_MUTE_DEVICE:
1999 * This usage, which is used to mute touch events, comes
2000 * from the pad packet, but is reported on the touch
2001 * interface. Because the touch interface may not have
2002 * been created yet, we cannot call wacom_map_usage(). In
2003 * order to process this usage when we receive it, we set
2004 * the usage type and code directly.
2006 wacom_wac->has_mute_touch_switch = true;
2007 usage->type = EV_SW;
2008 usage->code = SW_MUTE_DEVICE;
2009 features->device_type |= WACOM_DEVICETYPE_PAD;
2011 case WACOM_HID_WD_TOUCHSTRIP:
2012 wacom_map_usage(input, usage, field, EV_ABS, ABS_RX, 0);
2013 features->device_type |= WACOM_DEVICETYPE_PAD;
2015 case WACOM_HID_WD_TOUCHSTRIP2:
2016 wacom_map_usage(input, usage, field, EV_ABS, ABS_RY, 0);
2017 features->device_type |= WACOM_DEVICETYPE_PAD;
2019 case WACOM_HID_WD_TOUCHRING:
2020 wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
2021 features->device_type |= WACOM_DEVICETYPE_PAD;
2023 case WACOM_HID_WD_TOUCHRINGSTATUS:
2025 * Only set up type/code association. Completely mapping
2026 * this usage may overwrite the axis resolution and range.
2028 usage->type = EV_ABS;
2029 usage->code = ABS_WHEEL;
2030 set_bit(EV_ABS, input->evbit);
2031 features->device_type |= WACOM_DEVICETYPE_PAD;
2033 case WACOM_HID_WD_BUTTONCONFIG:
2034 wacom_map_usage(input, usage, field, EV_KEY, KEY_BUTTONCONFIG, 0);
2035 features->device_type |= WACOM_DEVICETYPE_PAD;
2037 case WACOM_HID_WD_ONSCREEN_KEYBOARD:
2038 wacom_map_usage(input, usage, field, EV_KEY, KEY_ONSCREEN_KEYBOARD, 0);
2039 features->device_type |= WACOM_DEVICETYPE_PAD;
2041 case WACOM_HID_WD_CONTROLPANEL:
2042 wacom_map_usage(input, usage, field, EV_KEY, KEY_CONTROLPANEL, 0);
2043 features->device_type |= WACOM_DEVICETYPE_PAD;
2045 case WACOM_HID_WD_MODE_CHANGE:
2046 /* do not overwrite previous data */
2047 if (!wacom_wac->has_mode_change) {
2048 wacom_wac->has_mode_change = true;
2049 wacom_wac->is_direct_mode = true;
2051 features->device_type |= WACOM_DEVICETYPE_PAD;
2055 switch (equivalent_usage & 0xfffffff0) {
2056 case WACOM_HID_WD_EXPRESSKEY00:
2057 wacom_map_usage(input, usage, field, EV_KEY,
2058 wacom_numbered_button_to_key(features->numbered_buttons),
2060 features->numbered_buttons++;
2061 features->device_type |= WACOM_DEVICETYPE_PAD;
2066 static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field,
2067 struct hid_usage *usage, __s32 value)
2069 struct wacom *wacom = hid_get_drvdata(hdev);
2070 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2071 struct input_dev *input = wacom_wac->pad_input;
2072 struct wacom_features *features = &wacom_wac->features;
2073 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2075 bool do_report = false;
2078 * Avoid reporting this event and setting inrange_state if this usage
2079 * hasn't been mapped.
2081 if (!usage->type && equivalent_usage != WACOM_HID_WD_MODE_CHANGE)
2084 if (wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY) {
2085 if (usage->hid != WACOM_HID_WD_TOUCHRING)
2086 wacom_wac->hid_data.inrange_state |= value;
2089 switch (equivalent_usage) {
2090 case WACOM_HID_WD_TOUCHRING:
2092 * Userspace expects touchrings to increase in value with
2093 * clockwise gestures and have their zero point at the
2094 * tablet's left. HID events "should" be clockwise-
2095 * increasing and zero at top, though the MobileStudio
2096 * Pro and 2nd-gen Intuos Pro don't do this...
2098 if (hdev->vendor == 0x56a &&
2099 (hdev->product == 0x34d || hdev->product == 0x34e || /* MobileStudio Pro */
2100 hdev->product == 0x357 || hdev->product == 0x358 || /* Intuos Pro 2 */
2101 hdev->product == 0x392 || /* Intuos Pro 2 */
2102 hdev->product == 0x398 || hdev->product == 0x399 || /* MobileStudio Pro */
2103 hdev->product == 0x3AA)) { /* MobileStudio Pro */
2104 value = (field->logical_maximum - value);
2106 if (hdev->product == 0x357 || hdev->product == 0x358 ||
2107 hdev->product == 0x392)
2108 value = wacom_offset_rotation(input, usage, value, 3, 16);
2109 else if (hdev->product == 0x34d || hdev->product == 0x34e ||
2110 hdev->product == 0x398 || hdev->product == 0x399 ||
2111 hdev->product == 0x3AA)
2112 value = wacom_offset_rotation(input, usage, value, 1, 2);
2115 value = wacom_offset_rotation(input, usage, value, 1, 4);
2119 case WACOM_HID_WD_TOUCHRINGSTATUS:
2121 input_event(input, usage->type, usage->code, 0);
2124 case WACOM_HID_WD_MUTE_DEVICE:
2125 case WACOM_HID_WD_TOUCHONOFF:
2126 if (wacom_wac->shared->touch_input) {
2127 bool *is_touch_on = &wacom_wac->shared->is_touch_on;
2129 if (equivalent_usage == WACOM_HID_WD_MUTE_DEVICE && value)
2130 *is_touch_on = !(*is_touch_on);
2131 else if (equivalent_usage == WACOM_HID_WD_TOUCHONOFF)
2132 *is_touch_on = value;
2134 input_report_switch(wacom_wac->shared->touch_input,
2135 SW_MUTE_DEVICE, !(*is_touch_on));
2136 input_sync(wacom_wac->shared->touch_input);
2140 case WACOM_HID_WD_MODE_CHANGE:
2141 if (wacom_wac->is_direct_mode != value) {
2142 wacom_wac->is_direct_mode = value;
2143 wacom_schedule_work(&wacom->wacom_wac, WACOM_WORKER_MODE_CHANGE);
2147 case WACOM_HID_WD_BUTTONCENTER:
2148 for (i = 0; i < wacom->led.count; i++)
2149 wacom_update_led(wacom, features->numbered_buttons,
2158 input_event(input, usage->type, usage->code, value);
2160 wacom_wac->hid_data.pad_input_event_flag = true;
2164 static void wacom_wac_pad_pre_report(struct hid_device *hdev,
2165 struct hid_report *report)
2167 struct wacom *wacom = hid_get_drvdata(hdev);
2168 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2170 wacom_wac->hid_data.inrange_state = 0;
2173 static void wacom_wac_pad_report(struct hid_device *hdev,
2174 struct hid_report *report, struct hid_field *field)
2176 struct wacom *wacom = hid_get_drvdata(hdev);
2177 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2178 struct input_dev *input = wacom_wac->pad_input;
2179 bool active = wacom_wac->hid_data.inrange_state != 0;
2181 /* report prox for expresskey events */
2182 if (wacom_wac->hid_data.pad_input_event_flag) {
2183 input_event(input, EV_ABS, ABS_MISC, active ? PAD_DEVICE_ID : 0);
2186 wacom_wac->hid_data.pad_input_event_flag = false;
2190 static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
2191 struct hid_field *field, struct hid_usage *usage)
2193 struct wacom *wacom = hid_get_drvdata(hdev);
2194 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2195 struct wacom_features *features = &wacom_wac->features;
2196 struct input_dev *input = wacom_wac->pen_input;
2197 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2199 switch (equivalent_usage) {
2201 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
2204 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
2206 case WACOM_HID_WD_DISTANCE:
2208 wacom_map_usage(input, usage, field, EV_ABS, ABS_DISTANCE, 0);
2210 case HID_DG_TIPPRESSURE:
2211 wacom_map_usage(input, usage, field, EV_ABS, ABS_PRESSURE, 0);
2213 case HID_DG_INRANGE:
2214 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
2217 wacom_map_usage(input, usage, field, EV_KEY,
2218 BTN_TOOL_RUBBER, 0);
2221 wacom_map_usage(input, usage, field, EV_ABS, ABS_TILT_X, 0);
2224 wacom_map_usage(input, usage, field, EV_ABS, ABS_TILT_Y, 0);
2227 wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0);
2230 case HID_DG_TIPSWITCH:
2231 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
2233 case HID_DG_BARRELSWITCH:
2234 wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS, 0);
2236 case HID_DG_BARRELSWITCH2:
2237 wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS2, 0);
2239 case HID_DG_TOOLSERIALNUMBER:
2240 features->quirks |= WACOM_QUIRK_TOOLSERIAL;
2241 wacom_map_usage(input, usage, field, EV_MSC, MSC_SERIAL, 0);
2243 case WACOM_HID_WD_SENSE:
2244 features->quirks |= WACOM_QUIRK_SENSE;
2245 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
2247 case WACOM_HID_WD_SERIALHI:
2248 wacom_map_usage(input, usage, field, EV_ABS, ABS_MISC, 0);
2250 if (!(features->quirks & WACOM_QUIRK_AESPEN)) {
2251 set_bit(EV_KEY, input->evbit);
2252 input_set_capability(input, EV_KEY, BTN_TOOL_PEN);
2253 input_set_capability(input, EV_KEY, BTN_TOOL_RUBBER);
2254 input_set_capability(input, EV_KEY, BTN_TOOL_BRUSH);
2255 input_set_capability(input, EV_KEY, BTN_TOOL_PENCIL);
2256 input_set_capability(input, EV_KEY, BTN_TOOL_AIRBRUSH);
2257 if (!(features->device_type & WACOM_DEVICETYPE_DIRECT)) {
2258 input_set_capability(input, EV_KEY, BTN_TOOL_MOUSE);
2259 input_set_capability(input, EV_KEY, BTN_TOOL_LENS);
2263 case WACOM_HID_WD_FINGERWHEEL:
2264 wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
2269 static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field,
2270 struct hid_usage *usage, __s32 value)
2272 struct wacom *wacom = hid_get_drvdata(hdev);
2273 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2274 struct wacom_features *features = &wacom_wac->features;
2275 struct input_dev *input = wacom_wac->pen_input;
2276 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2278 if (wacom_wac->is_invalid_bt_frame)
2281 switch (equivalent_usage) {
2284 * HID_GD_Z "should increase as the control's position is
2285 * moved from high to low", while ABS_DISTANCE instead
2286 * increases in value as the tool moves from low to high.
2288 value = field->logical_maximum - value;
2290 case HID_DG_INRANGE:
2291 wacom_wac->hid_data.inrange_state = value;
2292 if (!(features->quirks & WACOM_QUIRK_SENSE))
2293 wacom_wac->hid_data.sense_state = value;
2296 wacom_wac->hid_data.invert_state = value;
2299 case HID_DG_TIPSWITCH:
2300 wacom_wac->hid_data.tipswitch |= value;
2302 case HID_DG_BARRELSWITCH:
2303 wacom_wac->hid_data.barrelswitch = value;
2305 case HID_DG_BARRELSWITCH2:
2306 wacom_wac->hid_data.barrelswitch2 = value;
2308 case HID_DG_TOOLSERIALNUMBER:
2310 wacom_wac->serial[0] = (wacom_wac->serial[0] & ~0xFFFFFFFFULL);
2311 wacom_wac->serial[0] |= wacom_s32tou(value, field->report_size);
2316 * Userspace expects pen twist to have its zero point when
2317 * the buttons/finger is on the tablet's left. HID values
2318 * are zero when buttons are toward the top.
2320 value = wacom_offset_rotation(input, usage, value, 1, 4);
2322 case WACOM_HID_WD_SENSE:
2323 wacom_wac->hid_data.sense_state = value;
2325 case WACOM_HID_WD_SERIALHI:
2327 __u32 raw_value = wacom_s32tou(value, field->report_size);
2329 wacom_wac->serial[0] = (wacom_wac->serial[0] & 0xFFFFFFFF);
2330 wacom_wac->serial[0] |= ((__u64)raw_value) << 32;
2332 * Non-USI EMR devices may contain additional tool type
2333 * information here. See WACOM_HID_WD_TOOLTYPE case for
2336 if (value >> 20 == 1) {
2337 wacom_wac->id[0] |= raw_value & 0xFFFFF;
2341 case WACOM_HID_WD_TOOLTYPE:
2343 * Some devices (MobileStudio Pro, and possibly later
2344 * devices as well) do not return the complete tool
2345 * type in their WACOM_HID_WD_TOOLTYPE usage. Use a
2346 * bitwise OR so the complete value can be built
2349 wacom_wac->id[0] |= wacom_s32tou(value, field->report_size);
2351 case WACOM_HID_WD_OFFSETLEFT:
2352 if (features->offset_left && value != features->offset_left)
2353 hid_warn(hdev, "%s: overriding existing left offset "
2354 "%d -> %d\n", __func__, value,
2355 features->offset_left);
2356 features->offset_left = value;
2358 case WACOM_HID_WD_OFFSETRIGHT:
2359 if (features->offset_right && value != features->offset_right)
2360 hid_warn(hdev, "%s: overriding existing right offset "
2361 "%d -> %d\n", __func__, value,
2362 features->offset_right);
2363 features->offset_right = value;
2365 case WACOM_HID_WD_OFFSETTOP:
2366 if (features->offset_top && value != features->offset_top)
2367 hid_warn(hdev, "%s: overriding existing top offset "
2368 "%d -> %d\n", __func__, value,
2369 features->offset_top);
2370 features->offset_top = value;
2372 case WACOM_HID_WD_OFFSETBOTTOM:
2373 if (features->offset_bottom && value != features->offset_bottom)
2374 hid_warn(hdev, "%s: overriding existing bottom offset "
2375 "%d -> %d\n", __func__, value,
2376 features->offset_bottom);
2377 features->offset_bottom = value;
2379 case WACOM_HID_WD_REPORT_VALID:
2380 wacom_wac->is_invalid_bt_frame = !value;
2384 /* send pen events only when touch is up or forced out
2385 * or touch arbitration is off
2387 if (!usage->type || delay_pen_events(wacom_wac))
2390 /* send pen events only when the pen is in range */
2391 if (wacom_wac->hid_data.inrange_state)
2392 input_event(input, usage->type, usage->code, value);
2393 else if (wacom_wac->shared->stylus_in_proximity && !wacom_wac->hid_data.sense_state)
2394 input_event(input, usage->type, usage->code, 0);
2397 static void wacom_wac_pen_pre_report(struct hid_device *hdev,
2398 struct hid_report *report)
2400 struct wacom *wacom = hid_get_drvdata(hdev);
2401 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2403 wacom_wac->is_invalid_bt_frame = false;
2407 static void wacom_wac_pen_report(struct hid_device *hdev,
2408 struct hid_report *report)
2410 struct wacom *wacom = hid_get_drvdata(hdev);
2411 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2412 struct input_dev *input = wacom_wac->pen_input;
2413 bool range = wacom_wac->hid_data.inrange_state;
2414 bool sense = wacom_wac->hid_data.sense_state;
2416 if (wacom_wac->is_invalid_bt_frame)
2419 if (!wacom_wac->tool[0] && range) { /* first in range */
2420 /* Going into range select tool */
2421 if (wacom_wac->hid_data.invert_state)
2422 wacom_wac->tool[0] = BTN_TOOL_RUBBER;
2423 else if (wacom_wac->id[0])
2424 wacom_wac->tool[0] = wacom_intuos_get_tool_type(wacom_wac->id[0]);
2426 wacom_wac->tool[0] = BTN_TOOL_PEN;
2429 /* keep pen state for touch events */
2430 wacom_wac->shared->stylus_in_proximity = sense;
2432 if (!delay_pen_events(wacom_wac) && wacom_wac->tool[0]) {
2433 int id = wacom_wac->id[0];
2434 int sw_state = wacom_wac->hid_data.barrelswitch |
2435 (wacom_wac->hid_data.barrelswitch2 << 1);
2437 input_report_key(input, BTN_STYLUS, sw_state == 1);
2438 input_report_key(input, BTN_STYLUS2, sw_state == 2);
2439 input_report_key(input, BTN_STYLUS3, sw_state == 3);
2442 * Non-USI EMR tools should have their IDs mangled to
2443 * match the legacy behavior of wacom_intuos_general
2445 if (wacom_wac->serial[0] >> 52 == 1)
2446 id = wacom_intuos_id_mangle(id);
2449 * To ensure compatibility with xf86-input-wacom, we should
2450 * report the BTN_TOOL_* event prior to the ABS_MISC or
2451 * MSC_SERIAL events.
2453 input_report_key(input, BTN_TOUCH,
2454 wacom_wac->hid_data.tipswitch);
2455 input_report_key(input, wacom_wac->tool[0], sense);
2456 if (wacom_wac->serial[0]) {
2457 input_event(input, EV_MSC, MSC_SERIAL, wacom_wac->serial[0]);
2458 input_report_abs(input, ABS_MISC, sense ? id : 0);
2461 wacom_wac->hid_data.tipswitch = false;
2467 wacom_wac->tool[0] = 0;
2468 wacom_wac->id[0] = 0;
2469 wacom_wac->serial[0] = 0;
2473 static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
2474 struct hid_field *field, struct hid_usage *usage)
2476 struct wacom *wacom = hid_get_drvdata(hdev);
2477 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2478 struct input_dev *input = wacom_wac->touch_input;
2479 unsigned touch_max = wacom_wac->features.touch_max;
2480 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2482 switch (equivalent_usage) {
2485 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
2487 wacom_map_usage(input, usage, field, EV_ABS,
2488 ABS_MT_POSITION_X, 4);
2492 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
2494 wacom_map_usage(input, usage, field, EV_ABS,
2495 ABS_MT_POSITION_Y, 4);
2499 wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MAJOR, 0);
2500 wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MINOR, 0);
2501 input_set_abs_params(input, ABS_MT_ORIENTATION, 0, 1, 0, 0);
2503 case HID_DG_TIPSWITCH:
2504 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
2506 case HID_DG_CONTACTCOUNT:
2507 wacom_wac->hid_data.cc_report = field->report->id;
2508 wacom_wac->hid_data.cc_index = field->index;
2509 wacom_wac->hid_data.cc_value_index = usage->usage_index;
2511 case HID_DG_CONTACTID:
2512 if ((field->logical_maximum - field->logical_minimum) < touch_max) {
2514 * The HID descriptor for G11 sensors leaves logical
2515 * maximum set to '1' despite it being a multitouch
2516 * device. Override to a sensible number.
2518 field->logical_maximum = 255;
2524 static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
2525 struct input_dev *input)
2527 struct hid_data *hid_data = &wacom_wac->hid_data;
2528 bool mt = wacom_wac->features.touch_max > 1;
2529 bool prox = hid_data->tipswitch &&
2530 report_touch_events(wacom_wac);
2532 if (wacom_wac->shared->has_mute_touch_switch &&
2533 !wacom_wac->shared->is_touch_on) {
2534 if (!wacom_wac->shared->touch_down)
2539 wacom_wac->hid_data.num_received++;
2540 if (wacom_wac->hid_data.num_received > wacom_wac->hid_data.num_expected)
2546 slot = input_mt_get_slot_by_key(input, hid_data->id);
2547 input_mt_slot(input, slot);
2548 input_mt_report_slot_state(input, MT_TOOL_FINGER, prox);
2551 input_report_key(input, BTN_TOUCH, prox);
2555 input_report_abs(input, mt ? ABS_MT_POSITION_X : ABS_X,
2557 input_report_abs(input, mt ? ABS_MT_POSITION_Y : ABS_Y,
2560 if (test_bit(ABS_MT_TOUCH_MAJOR, input->absbit)) {
2561 input_report_abs(input, ABS_MT_TOUCH_MAJOR, max(hid_data->width, hid_data->height));
2562 input_report_abs(input, ABS_MT_TOUCH_MINOR, min(hid_data->width, hid_data->height));
2563 if (hid_data->width != hid_data->height)
2564 input_report_abs(input, ABS_MT_ORIENTATION, hid_data->width <= hid_data->height ? 0 : 1);
2569 static void wacom_wac_finger_event(struct hid_device *hdev,
2570 struct hid_field *field, struct hid_usage *usage, __s32 value)
2572 struct wacom *wacom = hid_get_drvdata(hdev);
2573 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2574 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2575 struct wacom_features *features = &wacom->wacom_wac.features;
2577 if (wacom_wac->is_invalid_bt_frame)
2580 switch (equivalent_usage) {
2582 wacom_wac->hid_data.x = value;
2585 wacom_wac->hid_data.y = value;
2588 wacom_wac->hid_data.width = value;
2591 wacom_wac->hid_data.height = value;
2593 case HID_DG_CONTACTID:
2594 wacom_wac->hid_data.id = value;
2596 case HID_DG_TIPSWITCH:
2597 wacom_wac->hid_data.tipswitch = value;
2599 case WACOM_HID_WT_REPORT_VALID:
2600 wacom_wac->is_invalid_bt_frame = !value;
2602 case HID_DG_CONTACTMAX:
2603 if (!features->touch_max) {
2604 features->touch_max = value;
2606 hid_warn(hdev, "%s: ignoring attempt to overwrite non-zero touch_max "
2607 "%d -> %d\n", __func__, features->touch_max, value);
2612 if (usage->usage_index + 1 == field->report_count) {
2613 if (equivalent_usage == wacom_wac->hid_data.last_slot_field)
2614 wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
2618 static void wacom_wac_finger_pre_report(struct hid_device *hdev,
2619 struct hid_report *report)
2621 struct wacom *wacom = hid_get_drvdata(hdev);
2622 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2623 struct hid_data* hid_data = &wacom_wac->hid_data;
2626 wacom_wac->is_invalid_bt_frame = false;
2628 for (i = 0; i < report->maxfield; i++) {
2629 struct hid_field *field = report->field[i];
2632 for (j = 0; j < field->maxusage; j++) {
2633 struct hid_usage *usage = &field->usage[j];
2634 unsigned int equivalent_usage =
2635 wacom_equivalent_usage(usage->hid);
2637 switch (equivalent_usage) {
2642 case HID_DG_CONTACTID:
2643 case HID_DG_INRANGE:
2645 case HID_DG_TIPSWITCH:
2646 hid_data->last_slot_field = equivalent_usage;
2648 case HID_DG_CONTACTCOUNT:
2649 hid_data->cc_report = report->id;
2650 hid_data->cc_index = i;
2651 hid_data->cc_value_index = j;
2657 if (hid_data->cc_report != 0 &&
2658 hid_data->cc_index >= 0) {
2659 struct hid_field *field = report->field[hid_data->cc_index];
2660 int value = field->value[hid_data->cc_value_index];
2662 hid_data->num_expected = value;
2665 hid_data->num_expected = wacom_wac->features.touch_max;
2669 static void wacom_wac_finger_report(struct hid_device *hdev,
2670 struct hid_report *report)
2672 struct wacom *wacom = hid_get_drvdata(hdev);
2673 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2674 struct input_dev *input = wacom_wac->touch_input;
2675 unsigned touch_max = wacom_wac->features.touch_max;
2677 /* If more packets of data are expected, give us a chance to
2678 * process them rather than immediately syncing a partial
2681 if (wacom_wac->hid_data.num_received < wacom_wac->hid_data.num_expected)
2685 input_mt_sync_frame(input);
2688 wacom_wac->hid_data.num_received = 0;
2690 /* keep touch state for pen event */
2691 wacom_wac->shared->touch_down = wacom_wac_finger_count_touches(wacom_wac);
2694 void wacom_wac_usage_mapping(struct hid_device *hdev,
2695 struct hid_field *field, struct hid_usage *usage)
2697 struct wacom *wacom = hid_get_drvdata(hdev);
2698 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2699 struct wacom_features *features = &wacom_wac->features;
2701 if (WACOM_DIRECT_DEVICE(field))
2702 features->device_type |= WACOM_DEVICETYPE_DIRECT;
2704 /* usage tests must precede field tests */
2705 if (WACOM_BATTERY_USAGE(usage))
2706 wacom_wac_battery_usage_mapping(hdev, field, usage);
2707 else if (WACOM_PAD_FIELD(field))
2708 wacom_wac_pad_usage_mapping(hdev, field, usage);
2709 else if (WACOM_PEN_FIELD(field))
2710 wacom_wac_pen_usage_mapping(hdev, field, usage);
2711 else if (WACOM_FINGER_FIELD(field))
2712 wacom_wac_finger_usage_mapping(hdev, field, usage);
2715 void wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
2716 struct hid_usage *usage, __s32 value)
2718 struct wacom *wacom = hid_get_drvdata(hdev);
2720 if (wacom->wacom_wac.features.type != HID_GENERIC)
2723 if (value > field->logical_maximum || value < field->logical_minimum)
2726 /* usage tests must precede field tests */
2727 if (WACOM_BATTERY_USAGE(usage))
2728 wacom_wac_battery_event(hdev, field, usage, value);
2729 else if (WACOM_PAD_FIELD(field) && wacom->wacom_wac.pad_input)
2730 wacom_wac_pad_event(hdev, field, usage, value);
2731 else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
2732 wacom_wac_pen_event(hdev, field, usage, value);
2733 else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
2734 wacom_wac_finger_event(hdev, field, usage, value);
2737 static void wacom_report_events(struct hid_device *hdev,
2738 struct hid_report *report, int collection_index,
2743 for (r = field_index; r < report->maxfield; r++) {
2744 struct hid_field *field;
2747 field = report->field[r];
2748 count = field->report_count;
2750 if (!(HID_MAIN_ITEM_VARIABLE & field->flags))
2753 for (n = 0 ; n < count; n++) {
2754 if (field->usage[n].collection_index == collection_index)
2755 wacom_wac_event(hdev, field, &field->usage[n],
2763 static int wacom_wac_collection(struct hid_device *hdev, struct hid_report *report,
2764 int collection_index, struct hid_field *field,
2767 struct wacom *wacom = hid_get_drvdata(hdev);
2769 wacom_report_events(hdev, report, collection_index, field_index);
2772 * Non-input reports may be sent prior to the device being
2773 * completely initialized. Since only their events need
2774 * to be processed, exit after 'wacom_report_events' has
2775 * been called to prevent potential crashes in the report-
2776 * processing functions.
2778 if (report->type != HID_INPUT_REPORT)
2781 if (WACOM_PAD_FIELD(field))
2783 else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
2784 wacom_wac_pen_report(hdev, report);
2785 else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
2786 wacom_wac_finger_report(hdev, report);
2791 void wacom_wac_report(struct hid_device *hdev, struct hid_report *report)
2793 struct wacom *wacom = hid_get_drvdata(hdev);
2794 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2795 struct hid_field *field;
2796 bool pad_in_hid_field = false, pen_in_hid_field = false,
2797 finger_in_hid_field = false, true_pad = false;
2799 int prev_collection = -1;
2801 if (wacom_wac->features.type != HID_GENERIC)
2804 for (r = 0; r < report->maxfield; r++) {
2805 field = report->field[r];
2807 if (WACOM_PAD_FIELD(field))
2808 pad_in_hid_field = true;
2809 if (WACOM_PEN_FIELD(field))
2810 pen_in_hid_field = true;
2811 if (WACOM_FINGER_FIELD(field))
2812 finger_in_hid_field = true;
2813 if (wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY)
2817 wacom_wac_battery_pre_report(hdev, report);
2819 if (pad_in_hid_field && wacom->wacom_wac.pad_input)
2820 wacom_wac_pad_pre_report(hdev, report);
2821 if (pen_in_hid_field && wacom->wacom_wac.pen_input)
2822 wacom_wac_pen_pre_report(hdev, report);
2823 if (finger_in_hid_field && wacom->wacom_wac.touch_input)
2824 wacom_wac_finger_pre_report(hdev, report);
2826 for (r = 0; r < report->maxfield; r++) {
2827 field = report->field[r];
2829 if (field->usage[0].collection_index != prev_collection) {
2830 if (wacom_wac_collection(hdev, report,
2831 field->usage[0].collection_index, field, r) < 0)
2833 prev_collection = field->usage[0].collection_index;
2837 wacom_wac_battery_report(hdev, report);
2839 if (true_pad && wacom->wacom_wac.pad_input)
2840 wacom_wac_pad_report(hdev, report, field);
2843 static int wacom_bpt_touch(struct wacom_wac *wacom)
2845 struct wacom_features *features = &wacom->features;
2846 struct input_dev *input = wacom->touch_input;
2847 struct input_dev *pad_input = wacom->pad_input;
2848 unsigned char *data = wacom->data;
2851 if (data[0] != 0x02)
2854 for (i = 0; i < 2; i++) {
2855 int offset = (data[1] & 0x80) ? (8 * i) : (9 * i);
2856 bool touch = report_touch_events(wacom)
2857 && (data[offset + 3] & 0x80);
2859 input_mt_slot(input, i);
2860 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
2862 int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff;
2863 int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff;
2864 if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) {
2868 input_report_abs(input, ABS_MT_POSITION_X, x);
2869 input_report_abs(input, ABS_MT_POSITION_Y, y);
2873 input_mt_sync_frame(input);
2875 input_report_key(pad_input, BTN_LEFT, (data[1] & 0x08) != 0);
2876 input_report_key(pad_input, BTN_FORWARD, (data[1] & 0x04) != 0);
2877 input_report_key(pad_input, BTN_BACK, (data[1] & 0x02) != 0);
2878 input_report_key(pad_input, BTN_RIGHT, (data[1] & 0x01) != 0);
2879 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
2884 static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
2886 struct wacom_features *features = &wacom->features;
2887 struct input_dev *input = wacom->touch_input;
2888 bool touch = data[1] & 0x80;
2889 int slot = input_mt_get_slot_by_key(input, data[0]);
2894 touch = touch && report_touch_events(wacom);
2896 input_mt_slot(input, slot);
2897 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
2900 int x = (data[2] << 4) | (data[4] >> 4);
2901 int y = (data[3] << 4) | (data[4] & 0x0f);
2904 if (features->type >= INTUOSPS && features->type <= INTUOSHT2) {
2905 width = data[5] * 100;
2906 height = data[6] * 100;
2909 * "a" is a scaled-down area which we assume is
2910 * roughly circular and which can be described as:
2914 int x_res = input_abs_get_res(input, ABS_MT_POSITION_X);
2915 int y_res = input_abs_get_res(input, ABS_MT_POSITION_Y);
2916 width = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE);
2917 height = width * y_res / x_res;
2920 input_report_abs(input, ABS_MT_POSITION_X, x);
2921 input_report_abs(input, ABS_MT_POSITION_Y, y);
2922 input_report_abs(input, ABS_MT_TOUCH_MAJOR, width);
2923 input_report_abs(input, ABS_MT_TOUCH_MINOR, height);
2927 static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
2929 struct input_dev *input = wacom->pad_input;
2930 struct wacom_features *features = &wacom->features;
2932 if (features->type == INTUOSHT || features->type == INTUOSHT2) {
2933 input_report_key(input, BTN_LEFT, (data[1] & 0x02) != 0);
2934 input_report_key(input, BTN_BACK, (data[1] & 0x08) != 0);
2936 input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
2937 input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
2939 input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
2940 input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
2943 static int wacom_bpt3_touch(struct wacom_wac *wacom)
2945 unsigned char *data = wacom->data;
2946 int count = data[1] & 0x07;
2947 int touch_changed = 0, i;
2949 if (data[0] != 0x02)
2952 /* data has up to 7 fixed sized 8-byte messages starting at data[2] */
2953 for (i = 0; i < count; i++) {
2954 int offset = (8 * i) + 2;
2955 int msg_id = data[offset];
2957 if (msg_id >= 2 && msg_id <= 17) {
2958 wacom_bpt3_touch_msg(wacom, data + offset);
2960 } else if (msg_id == 128)
2961 wacom_bpt3_button_msg(wacom, data + offset);
2965 /* only update touch if we actually have a touchpad and touch data changed */
2966 if (wacom->touch_input && touch_changed) {
2967 input_mt_sync_frame(wacom->touch_input);
2968 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
2974 static int wacom_bpt_pen(struct wacom_wac *wacom)
2976 struct wacom_features *features = &wacom->features;
2977 struct input_dev *input = wacom->pen_input;
2978 unsigned char *data = wacom->data;
2979 int x = 0, y = 0, p = 0, d = 0;
2980 bool pen = false, btn1 = false, btn2 = false;
2981 bool range, prox, rdy;
2983 if (data[0] != WACOM_REPORT_PENABLED)
2986 range = (data[1] & 0x80) == 0x80;
2987 prox = (data[1] & 0x40) == 0x40;
2988 rdy = (data[1] & 0x20) == 0x20;
2990 wacom->shared->stylus_in_proximity = range;
2991 if (delay_pen_events(wacom))
2995 p = le16_to_cpup((__le16 *)&data[6]);
2996 pen = data[1] & 0x01;
2997 btn1 = data[1] & 0x02;
2998 btn2 = data[1] & 0x04;
3001 x = le16_to_cpup((__le16 *)&data[2]);
3002 y = le16_to_cpup((__le16 *)&data[4]);
3004 if (data[1] & 0x08) {
3005 wacom->tool[0] = BTN_TOOL_RUBBER;
3006 wacom->id[0] = ERASER_DEVICE_ID;
3008 wacom->tool[0] = BTN_TOOL_PEN;
3009 wacom->id[0] = STYLUS_DEVICE_ID;
3011 wacom->reporting_data = true;
3015 * Convert distance from out prox to distance from tablet.
3016 * distance will be greater than distance_max once
3017 * touching and applying pressure; do not report negative
3020 if (data[8] <= features->distance_max)
3021 d = features->distance_max - data[8];
3026 if (wacom->reporting_data) {
3027 input_report_key(input, BTN_TOUCH, pen);
3028 input_report_key(input, BTN_STYLUS, btn1);
3029 input_report_key(input, BTN_STYLUS2, btn2);
3031 if (prox || !range) {
3032 input_report_abs(input, ABS_X, x);
3033 input_report_abs(input, ABS_Y, y);
3035 input_report_abs(input, ABS_PRESSURE, p);
3036 input_report_abs(input, ABS_DISTANCE, d);
3038 input_report_key(input, wacom->tool[0], range); /* PEN or RUBBER */
3039 input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
3043 wacom->reporting_data = false;
3049 static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
3051 struct wacom_features *features = &wacom->features;
3053 if ((features->type == INTUOSHT2) &&
3054 (features->device_type & WACOM_DEVICETYPE_PEN))
3055 return wacom_intuos_irq(wacom);
3056 else if (len == WACOM_PKGLEN_BBTOUCH)
3057 return wacom_bpt_touch(wacom);
3058 else if (len == WACOM_PKGLEN_BBTOUCH3)
3059 return wacom_bpt3_touch(wacom);
3060 else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
3061 return wacom_bpt_pen(wacom);
3066 static void wacom_bamboo_pad_pen_event(struct wacom_wac *wacom,
3067 unsigned char *data)
3069 unsigned char prefix;
3072 * We need to reroute the event from the debug interface to the
3074 * We need to add the report ID to the actual pen report, so we
3075 * temporary overwrite the first byte to prevent having to kzalloc/kfree
3076 * and memcpy the report.
3079 data[0] = WACOM_REPORT_BPAD_PEN;
3082 * actually reroute the event.
3083 * No need to check if wacom->shared->pen is valid, hid_input_report()
3084 * will check for us.
3086 hid_input_report(wacom->shared->pen, HID_INPUT_REPORT, data,
3087 WACOM_PKGLEN_PENABLED, 1);
3092 static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom,
3093 unsigned char *data)
3095 struct input_dev *input = wacom->touch_input;
3096 unsigned char *finger_data, prefix;
3103 for (id = 0; id < wacom->features.touch_max; id++) {
3104 valid = !!(prefix & BIT(id)) &&
3105 report_touch_events(wacom);
3107 input_mt_slot(input, id);
3108 input_mt_report_slot_state(input, MT_TOOL_FINGER, valid);
3113 finger_data = data + 1 + id * 3;
3114 x = finger_data[0] | ((finger_data[1] & 0x0f) << 8);
3115 y = (finger_data[2] << 4) | (finger_data[1] >> 4);
3117 input_report_abs(input, ABS_MT_POSITION_X, x);
3118 input_report_abs(input, ABS_MT_POSITION_Y, y);
3121 input_mt_sync_frame(input);
3123 input_report_key(input, BTN_LEFT, prefix & 0x40);
3124 input_report_key(input, BTN_RIGHT, prefix & 0x80);
3126 /* keep touch state for pen event */
3127 wacom->shared->touch_down = !!prefix && report_touch_events(wacom);
3132 static int wacom_bamboo_pad_irq(struct wacom_wac *wacom, size_t len)
3134 unsigned char *data = wacom->data;
3136 if (!((len == WACOM_PKGLEN_BPAD_TOUCH) ||
3137 (len == WACOM_PKGLEN_BPAD_TOUCH_USB)) ||
3138 (data[0] != WACOM_REPORT_BPAD_TOUCH))
3142 wacom_bamboo_pad_pen_event(wacom, &data[1]);
3145 return wacom_bamboo_pad_touch_event(wacom, &data[9]);
3150 static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
3152 unsigned char *data = wacom->data;
3155 if (len != WACOM_PKGLEN_WIRELESS || data[0] != WACOM_REPORT_WL)
3158 connected = data[1] & 0x01;
3160 int pid, battery, charging;
3162 if ((wacom->shared->type == INTUOSHT ||
3163 wacom->shared->type == INTUOSHT2) &&
3164 wacom->shared->touch_input &&
3165 wacom->shared->touch_max) {
3166 input_report_switch(wacom->shared->touch_input,
3167 SW_MUTE_DEVICE, data[5] & 0x40);
3168 input_sync(wacom->shared->touch_input);
3171 pid = get_unaligned_be16(&data[6]);
3172 battery = (data[5] & 0x3f) * 100 / 31;
3173 charging = !!(data[5] & 0x80);
3174 if (wacom->pid != pid) {
3176 wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
3179 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
3180 battery, charging, 1, 0);
3182 } else if (wacom->pid != 0) {
3183 /* disconnected while previously connected */
3185 wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
3186 wacom_notify_battery(wacom, POWER_SUPPLY_STATUS_UNKNOWN, 0, 0, 0, 0);
3192 static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
3194 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
3195 struct wacom_features *features = &wacom_wac->features;
3196 unsigned char *data = wacom_wac->data;
3198 if (data[0] != WACOM_REPORT_USB)
3201 if ((features->type == INTUOSHT ||
3202 features->type == INTUOSHT2) &&
3203 wacom_wac->shared->touch_input &&
3204 features->touch_max) {
3205 input_report_switch(wacom_wac->shared->touch_input,
3206 SW_MUTE_DEVICE, data[8] & 0x40);
3207 input_sync(wacom_wac->shared->touch_input);
3210 if (data[9] & 0x02) { /* wireless module is attached */
3211 int battery = (data[8] & 0x3f) * 100 / 31;
3212 bool charging = !!(data[8] & 0x80);
3214 wacom_notify_battery(wacom_wac, WACOM_POWER_SUPPLY_STATUS_AUTO,
3215 battery, charging, battery || charging, 1);
3217 if (!wacom->battery.battery &&
3218 !(features->quirks & WACOM_QUIRK_BATTERY)) {
3219 features->quirks |= WACOM_QUIRK_BATTERY;
3220 wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
3223 else if ((features->quirks & WACOM_QUIRK_BATTERY) &&
3224 wacom->battery.battery) {
3225 features->quirks &= ~WACOM_QUIRK_BATTERY;
3226 wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
3227 wacom_notify_battery(wacom_wac, POWER_SUPPLY_STATUS_UNKNOWN, 0, 0, 0, 0);
3232 void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
3236 switch (wacom_wac->features.type) {
3238 sync = wacom_penpartner_irq(wacom_wac);
3242 sync = wacom_pl_irq(wacom_wac);
3249 sync = wacom_graphire_irq(wacom_wac);
3253 sync = wacom_ptu_irq(wacom_wac);
3257 sync = wacom_dtu_irq(wacom_wac);
3262 sync = wacom_dtus_irq(wacom_wac);
3281 case CINTIQ_COMPANION_2:
3282 sync = wacom_intuos_irq(wacom_wac);
3286 sync = wacom_intuos_bt_irq(wacom_wac, len);
3291 sync = wacom_24hdt_irq(wacom_wac);
3300 if (len == WACOM_PKGLEN_BBTOUCH3)
3301 sync = wacom_bpt3_touch(wacom_wac);
3302 else if (wacom_wac->data[0] == WACOM_REPORT_USB)
3303 sync = wacom_status_irq(wacom_wac, len);
3305 sync = wacom_intuos_irq(wacom_wac);
3311 sync = wacom_intuos_pro2_bt_irq(wacom_wac, len);
3320 sync = wacom_tpc_irq(wacom_wac, len);
3328 if (wacom_wac->data[0] == WACOM_REPORT_USB)
3329 sync = wacom_status_irq(wacom_wac, len);
3331 sync = wacom_bpt_irq(wacom_wac, len);
3335 sync = wacom_bamboo_pad_irq(wacom_wac, len);
3339 sync = wacom_wireless_irq(wacom_wac, len);
3344 if (wacom_wac->data[0] == WACOM_REPORT_DEVICE_LIST)
3345 wacom_remote_status_irq(wacom_wac, len);
3347 sync = wacom_remote_irq(wacom_wac, len);
3356 if (wacom_wac->pen_input)
3357 input_sync(wacom_wac->pen_input);
3358 if (wacom_wac->touch_input)
3359 input_sync(wacom_wac->touch_input);
3360 if (wacom_wac->pad_input)
3361 input_sync(wacom_wac->pad_input);
3365 static void wacom_setup_basic_pro_pen(struct wacom_wac *wacom_wac)
3367 struct input_dev *input_dev = wacom_wac->pen_input;
3369 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
3371 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3372 __set_bit(BTN_STYLUS, input_dev->keybit);
3373 __set_bit(BTN_STYLUS2, input_dev->keybit);
3375 input_set_abs_params(input_dev, ABS_DISTANCE,
3376 0, wacom_wac->features.distance_max, wacom_wac->features.distance_fuzz, 0);
3379 static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
3381 struct input_dev *input_dev = wacom_wac->pen_input;
3382 struct wacom_features *features = &wacom_wac->features;
3384 wacom_setup_basic_pro_pen(wacom_wac);
3386 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3387 __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
3388 __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
3389 __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
3391 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
3392 input_set_abs_params(input_dev, ABS_TILT_X, -64, 63, features->tilt_fuzz, 0);
3393 input_abs_set_res(input_dev, ABS_TILT_X, 57);
3394 input_set_abs_params(input_dev, ABS_TILT_Y, -64, 63, features->tilt_fuzz, 0);
3395 input_abs_set_res(input_dev, ABS_TILT_Y, 57);
3398 static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
3400 struct input_dev *input_dev = wacom_wac->pen_input;
3402 input_set_capability(input_dev, EV_REL, REL_WHEEL);
3404 wacom_setup_cintiq(wacom_wac);
3406 __set_bit(BTN_LEFT, input_dev->keybit);
3407 __set_bit(BTN_RIGHT, input_dev->keybit);
3408 __set_bit(BTN_MIDDLE, input_dev->keybit);
3409 __set_bit(BTN_SIDE, input_dev->keybit);
3410 __set_bit(BTN_EXTRA, input_dev->keybit);
3411 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
3412 __set_bit(BTN_TOOL_LENS, input_dev->keybit);
3414 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
3415 input_abs_set_res(input_dev, ABS_RZ, 287);
3416 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
3419 void wacom_setup_device_quirks(struct wacom *wacom)
3421 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
3422 struct wacom_features *features = &wacom->wacom_wac.features;
3424 /* The pen and pad share the same interface on most devices */
3425 if (features->type == GRAPHIRE_BT || features->type == WACOM_G4 ||
3426 features->type == DTUS ||
3427 (features->type >= INTUOS3S && features->type <= WACOM_MO)) {
3428 if (features->device_type & WACOM_DEVICETYPE_PEN)
3429 features->device_type |= WACOM_DEVICETYPE_PAD;
3432 /* touch device found but size is not defined. use default */
3433 if (features->device_type & WACOM_DEVICETYPE_TOUCH && !features->x_max) {
3434 features->x_max = 1023;
3435 features->y_max = 1023;
3439 * Intuos5/Pro and Bamboo 3rd gen have no useful data about its
3440 * touch interface in its HID descriptor. If this is the touch
3441 * interface (PacketSize of WACOM_PKGLEN_BBTOUCH3), override the
3444 if ((features->type >= INTUOS5S && features->type <= INTUOSPL) ||
3445 (features->type >= INTUOSHT && features->type <= BAMBOO_PT)) {
3446 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
3447 if (features->touch_max)
3448 features->device_type |= WACOM_DEVICETYPE_TOUCH;
3449 if (features->type >= INTUOSHT && features->type <= BAMBOO_PT)
3450 features->device_type |= WACOM_DEVICETYPE_PAD;
3452 if (features->type == INTUOSHT2) {
3453 features->x_max = features->x_max / 10;
3454 features->y_max = features->y_max / 10;
3457 features->x_max = 4096;
3458 features->y_max = 4096;
3461 else if (features->pktlen == WACOM_PKGLEN_BBTOUCH) {
3462 features->device_type |= WACOM_DEVICETYPE_PAD;
3467 * Hack for the Bamboo One:
3468 * the device presents a PAD/Touch interface as most Bamboos and even
3469 * sends ghosts PAD data on it. However, later, we must disable this
3470 * ghost interface, and we can not detect it unless we set it here
3471 * to WACOM_DEVICETYPE_PAD or WACOM_DEVICETYPE_TOUCH.
3473 if (features->type == BAMBOO_PEN &&
3474 features->pktlen == WACOM_PKGLEN_BBTOUCH3)
3475 features->device_type |= WACOM_DEVICETYPE_PAD;
3478 * Raw Wacom-mode pen and touch events both come from interface
3479 * 0, whose HID descriptor has an application usage of 0xFF0D
3480 * (i.e., WACOM_HID_WD_DIGITIZER). We route pen packets back
3481 * out through the HID_GENERIC device created for interface 1,
3482 * so rewrite this one to be of type WACOM_DEVICETYPE_TOUCH.
3484 if (features->type == BAMBOO_PAD)
3485 features->device_type = WACOM_DEVICETYPE_TOUCH;
3487 if (features->type == REMOTE)
3488 features->device_type = WACOM_DEVICETYPE_PAD;
3490 if (features->type == INTUOSP2_BT ||
3491 features->type == INTUOSP2S_BT) {
3492 features->device_type |= WACOM_DEVICETYPE_PEN |
3493 WACOM_DEVICETYPE_PAD |
3494 WACOM_DEVICETYPE_TOUCH;
3495 features->quirks |= WACOM_QUIRK_BATTERY;
3498 if (features->type == INTUOSHT3_BT) {
3499 features->device_type |= WACOM_DEVICETYPE_PEN |
3500 WACOM_DEVICETYPE_PAD;
3501 features->quirks |= WACOM_QUIRK_BATTERY;
3504 switch (features->type) {
3515 case CINTIQ_COMPANION_2:
3527 features->device_type |= WACOM_DEVICETYPE_DIRECT;
3531 if (wacom->hdev->bus == BUS_BLUETOOTH)
3532 features->quirks |= WACOM_QUIRK_BATTERY;
3534 /* quirk for bamboo touch with 2 low res touches */
3535 if ((features->type == BAMBOO_PT || features->type == BAMBOO_TOUCH) &&
3536 features->pktlen == WACOM_PKGLEN_BBTOUCH) {
3537 features->x_max <<= 5;
3538 features->y_max <<= 5;
3539 features->x_fuzz <<= 5;
3540 features->y_fuzz <<= 5;
3541 features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;
3544 if (features->type == WIRELESS) {
3545 if (features->device_type == WACOM_DEVICETYPE_WL_MONITOR) {
3546 features->quirks |= WACOM_QUIRK_BATTERY;
3550 if (features->type == REMOTE)
3551 features->device_type |= WACOM_DEVICETYPE_WL_MONITOR;
3553 /* HID descriptor for DTK-2451 / DTH-2452 claims to report lots
3554 * of things it shouldn't. Lets fix up the damage...
3556 if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
3557 features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3558 __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3559 __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3560 __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3561 __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3562 __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3563 __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3564 __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3565 __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3566 __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3567 __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3568 __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3572 int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
3573 struct wacom_wac *wacom_wac)
3575 struct wacom_features *features = &wacom_wac->features;
3577 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3579 if (!(features->device_type & WACOM_DEVICETYPE_PEN))
3582 if (features->device_type & WACOM_DEVICETYPE_DIRECT)
3583 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
3585 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
3587 if (features->type == HID_GENERIC) {
3588 /* setup has already been done; apply otherwise-undetectible quirks */
3589 input_set_capability(input_dev, EV_KEY, BTN_STYLUS3);
3593 __set_bit(BTN_TOUCH, input_dev->keybit);
3594 __set_bit(ABS_MISC, input_dev->absbit);
3596 input_set_abs_params(input_dev, ABS_X, 0 + features->offset_left,
3597 features->x_max - features->offset_right,
3598 features->x_fuzz, 0);
3599 input_set_abs_params(input_dev, ABS_Y, 0 + features->offset_top,
3600 features->y_max - features->offset_bottom,
3601 features->y_fuzz, 0);
3602 input_set_abs_params(input_dev, ABS_PRESSURE, 0,
3603 features->pressure_max, features->pressure_fuzz, 0);
3605 /* penabled devices have fixed resolution for each model */
3606 input_abs_set_res(input_dev, ABS_X, features->x_resolution);
3607 input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
3609 switch (features->type) {
3611 __clear_bit(ABS_MISC, input_dev->absbit);
3616 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3617 features->distance_max,
3618 features->distance_fuzz, 0);
3622 input_set_capability(input_dev, EV_REL, REL_WHEEL);
3624 __set_bit(BTN_LEFT, input_dev->keybit);
3625 __set_bit(BTN_RIGHT, input_dev->keybit);
3626 __set_bit(BTN_MIDDLE, input_dev->keybit);
3628 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3629 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3630 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
3631 __set_bit(BTN_STYLUS, input_dev->keybit);
3632 __set_bit(BTN_STYLUS2, input_dev->keybit);
3644 case CINTIQ_COMPANION_2:
3645 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3646 input_abs_set_res(input_dev, ABS_Z, 287);
3647 wacom_setup_cintiq(wacom_wac);
3657 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3658 input_abs_set_res(input_dev, ABS_Z, 287);
3662 wacom_setup_intuos(wacom_wac);
3673 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3674 features->distance_max,
3675 features->distance_fuzz, 0);
3677 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3678 input_abs_set_res(input_dev, ABS_Z, 287);
3680 wacom_setup_intuos(wacom_wac);
3691 __clear_bit(ABS_MISC, input_dev->absbit);
3698 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3699 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3700 __set_bit(BTN_STYLUS, input_dev->keybit);
3701 __set_bit(BTN_STYLUS2, input_dev->keybit);
3705 __set_bit(BTN_STYLUS2, input_dev->keybit);
3709 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3710 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3711 __set_bit(BTN_STYLUS, input_dev->keybit);
3719 if (features->type == INTUOSHT2 ||
3720 features->type == INTUOSHT3_BT) {
3721 wacom_setup_basic_pro_pen(wacom_wac);
3723 __clear_bit(ABS_MISC, input_dev->absbit);
3724 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3725 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3726 __set_bit(BTN_STYLUS, input_dev->keybit);
3727 __set_bit(BTN_STYLUS2, input_dev->keybit);
3728 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3729 features->distance_max,
3730 features->distance_fuzz, 0);
3734 __clear_bit(ABS_MISC, input_dev->absbit);
3740 int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
3741 struct wacom_wac *wacom_wac)
3743 struct wacom_features *features = &wacom_wac->features;
3745 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3747 if (!(features->device_type & WACOM_DEVICETYPE_TOUCH))
3750 if (features->device_type & WACOM_DEVICETYPE_DIRECT)
3751 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
3753 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
3755 if (features->type == HID_GENERIC)
3756 /* setup has already been done */
3759 __set_bit(BTN_TOUCH, input_dev->keybit);
3761 if (features->touch_max == 1) {
3762 input_set_abs_params(input_dev, ABS_X, 0,
3763 features->x_max, features->x_fuzz, 0);
3764 input_set_abs_params(input_dev, ABS_Y, 0,
3765 features->y_max, features->y_fuzz, 0);
3766 input_abs_set_res(input_dev, ABS_X,
3767 features->x_resolution);
3768 input_abs_set_res(input_dev, ABS_Y,
3769 features->y_resolution);
3771 else if (features->touch_max > 1) {
3772 input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
3773 features->x_max, features->x_fuzz, 0);
3774 input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
3775 features->y_max, features->y_fuzz, 0);
3776 input_abs_set_res(input_dev, ABS_MT_POSITION_X,
3777 features->x_resolution);
3778 input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
3779 features->y_resolution);
3782 switch (features->type) {
3785 input_dev->evbit[0] |= BIT_MASK(EV_SW);
3786 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
3788 if (wacom_wac->shared->touch->product == 0x361) {
3789 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
3791 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
3794 else if (wacom_wac->shared->touch->product == 0x360) {
3795 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
3797 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
3800 else if (wacom_wac->shared->touch->product == 0x393) {
3801 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
3803 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
3806 input_abs_set_res(input_dev, ABS_MT_POSITION_X, 40);
3807 input_abs_set_res(input_dev, ABS_MT_POSITION_Y, 40);
3817 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
3818 input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, features->y_max, 0, 0);
3819 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
3823 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
3824 input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
3825 input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
3826 input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
3830 if (wacom_wac->shared->touch->product == 0x32C ||
3831 wacom_wac->shared->touch->product == 0xF6) {
3832 input_dev->evbit[0] |= BIT_MASK(EV_SW);
3833 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
3834 wacom_wac->shared->has_mute_touch_switch = true;
3842 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT);
3851 input_dev->evbit[0] |= BIT_MASK(EV_SW);
3852 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
3857 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
3858 input_set_abs_params(input_dev,
3860 0, features->x_max, 0, 0);
3861 input_set_abs_params(input_dev,
3863 0, features->y_max, 0, 0);
3865 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
3869 input_mt_init_slots(input_dev, features->touch_max,
3871 __set_bit(BTN_LEFT, input_dev->keybit);
3872 __set_bit(BTN_RIGHT, input_dev->keybit);
3878 static int wacom_numbered_button_to_key(int n)
3883 return BTN_A + (n-10);
3885 return BTN_BASE + (n-16);
3890 static void wacom_setup_numbered_buttons(struct input_dev *input_dev,
3895 for (i = 0; i < button_count; i++) {
3896 int key = wacom_numbered_button_to_key(i);
3899 __set_bit(key, input_dev->keybit);
3903 static void wacom_24hd_update_leds(struct wacom *wacom, int mask, int group)
3905 struct wacom_led *led;
3907 bool updated = false;
3910 * 24HD has LED group 1 to the left and LED group 0 to the right.
3911 * So group 0 matches the second half of the buttons and thus the mask
3912 * needs to be shifted.
3917 for (i = 0; i < 3; i++) {
3918 led = wacom_led_find(wacom, group, i);
3920 hid_err(wacom->hdev, "can't find LED %d in group %d\n",
3924 if (!updated && mask & BIT(i)) {
3926 led_trigger_event(&led->trigger, LED_FULL);
3933 static bool wacom_is_led_toggled(struct wacom *wacom, int button_count,
3934 int mask, int group)
3939 * 21UX2 has LED group 1 to the left and LED group 0
3940 * to the right. We need to reverse the group to match this
3941 * historical behavior.
3943 if (wacom->wacom_wac.features.type == WACOM_21UX2)
3946 group_button = group * (button_count/wacom->led.count);
3948 if (wacom->wacom_wac.features.type == INTUOSP2_BT)
3951 return mask & (1 << group_button);
3954 static void wacom_update_led(struct wacom *wacom, int button_count, int mask,
3957 struct wacom_led *led, *next_led;
3961 if (wacom->wacom_wac.features.type == WACOM_24HD)
3962 return wacom_24hd_update_leds(wacom, mask, group);
3964 pressed = wacom_is_led_toggled(wacom, button_count, mask, group);
3965 cur = wacom->led.groups[group].select;
3967 led = wacom_led_find(wacom, group, cur);
3969 hid_err(wacom->hdev, "can't find current LED %d in group %d\n",
3979 if (led->held && pressed)
3982 next_led = wacom_led_next(wacom, led);
3984 hid_err(wacom->hdev, "can't find next LED in group %d\n",
3988 if (next_led == led)
3991 next_led->held = true;
3992 led_trigger_event(&next_led->trigger,
3993 wacom_leds_brightness_get(next_led));
3996 static void wacom_report_numbered_buttons(struct input_dev *input_dev,
3997 int button_count, int mask)
3999 struct wacom *wacom = input_get_drvdata(input_dev);
4002 for (i = 0; i < wacom->led.count; i++)
4003 wacom_update_led(wacom, button_count, mask, i);
4005 for (i = 0; i < button_count; i++) {
4006 int key = wacom_numbered_button_to_key(i);
4009 input_report_key(input_dev, key, mask & (1 << i));
4013 int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
4014 struct wacom_wac *wacom_wac)
4016 struct wacom_features *features = &wacom_wac->features;
4018 if ((features->type == HID_GENERIC) && features->numbered_buttons > 0)
4019 features->device_type |= WACOM_DEVICETYPE_PAD;
4021 if (!(features->device_type & WACOM_DEVICETYPE_PAD))
4024 if (features->type == REMOTE && input_dev == wacom_wac->pad_input)
4027 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
4029 /* kept for making legacy xf86-input-wacom working with the wheels */
4030 __set_bit(ABS_MISC, input_dev->absbit);
4032 /* kept for making legacy xf86-input-wacom accepting the pad */
4033 if (!(input_dev->absinfo && (input_dev->absinfo[ABS_X].minimum ||
4034 input_dev->absinfo[ABS_X].maximum)))
4035 input_set_abs_params(input_dev, ABS_X, 0, 1, 0, 0);
4036 if (!(input_dev->absinfo && (input_dev->absinfo[ABS_Y].minimum ||
4037 input_dev->absinfo[ABS_Y].maximum)))
4038 input_set_abs_params(input_dev, ABS_Y, 0, 1, 0, 0);
4040 /* kept for making udev and libwacom accepting the pad */
4041 __set_bit(BTN_STYLUS, input_dev->keybit);
4043 wacom_setup_numbered_buttons(input_dev, features->numbered_buttons);
4045 switch (features->type) {
4048 case CINTIQ_COMPANION_2:
4055 __set_bit(BTN_BACK, input_dev->keybit);
4056 __set_bit(BTN_LEFT, input_dev->keybit);
4057 __set_bit(BTN_FORWARD, input_dev->keybit);
4058 __set_bit(BTN_RIGHT, input_dev->keybit);
4059 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4063 __set_bit(BTN_BACK, input_dev->keybit);
4064 __set_bit(BTN_FORWARD, input_dev->keybit);
4065 input_set_capability(input_dev, EV_REL, REL_WHEEL);
4069 __set_bit(KEY_PROG1, input_dev->keybit);
4070 __set_bit(KEY_PROG2, input_dev->keybit);
4071 __set_bit(KEY_PROG3, input_dev->keybit);
4073 __set_bit(KEY_ONSCREEN_KEYBOARD, input_dev->keybit);
4074 __set_bit(KEY_INFO, input_dev->keybit);
4076 if (!features->oPid)
4077 __set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
4079 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4080 input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
4084 __set_bit(KEY_PROG1, input_dev->keybit);
4085 __set_bit(KEY_PROG2, input_dev->keybit);
4086 __set_bit(KEY_PROG3, input_dev->keybit);
4088 __set_bit(KEY_ONSCREEN_KEYBOARD, input_dev->keybit);
4089 __set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
4091 if (!features->oPid)
4092 __set_bit(KEY_CONTROLPANEL, input_dev->keybit);
4093 input_set_abs_params(input_dev, ABS_X, -2048, 2048, 0, 0);
4094 input_abs_set_res(input_dev, ABS_X, 1024); /* points/g */
4095 input_set_abs_params(input_dev, ABS_Y, -2048, 2048, 0, 0);
4096 input_abs_set_res(input_dev, ABS_Y, 1024);
4097 input_set_abs_params(input_dev, ABS_Z, -2048, 2048, 0, 0);
4098 input_abs_set_res(input_dev, ABS_Z, 1024);
4099 __set_bit(INPUT_PROP_ACCELEROMETER, input_dev->propbit);
4103 __set_bit(KEY_PROG1, input_dev->keybit);
4104 __set_bit(KEY_PROG2, input_dev->keybit);
4105 __set_bit(KEY_PROG3, input_dev->keybit);
4107 __set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
4108 __set_bit(KEY_INFO, input_dev->keybit);
4114 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
4115 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
4119 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4124 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
4128 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
4139 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4144 * For Bluetooth devices, the udev rule does not work correctly
4145 * for pads unless we add a stylus capability, which forces
4146 * ID_INPUT_TABLET to be set.
4148 __set_bit(BTN_STYLUS, input_dev->keybit);
4154 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4161 __clear_bit(ABS_MISC, input_dev->absbit);
4163 __set_bit(BTN_LEFT, input_dev->keybit);
4164 __set_bit(BTN_FORWARD, input_dev->keybit);
4165 __set_bit(BTN_BACK, input_dev->keybit);
4166 __set_bit(BTN_RIGHT, input_dev->keybit);
4171 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
4172 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4180 /* no pad supported */
4186 static const struct wacom_features wacom_features_0x00 =
4187 { "Wacom Penpartner", 5040, 3780, 255, 0,
4188 PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
4189 static const struct wacom_features wacom_features_0x10 =
4190 { "Wacom Graphire", 10206, 7422, 511, 63,
4191 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4192 static const struct wacom_features wacom_features_0x81 =
4193 { "Wacom Graphire BT", 16704, 12064, 511, 32,
4194 GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES, 2 };
4195 static const struct wacom_features wacom_features_0x11 =
4196 { "Wacom Graphire2 4x5", 10206, 7422, 511, 63,
4197 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4198 static const struct wacom_features wacom_features_0x12 =
4199 { "Wacom Graphire2 5x7", 13918, 10206, 511, 63,
4200 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4201 static const struct wacom_features wacom_features_0x13 =
4202 { "Wacom Graphire3", 10208, 7424, 511, 63,
4203 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4204 static const struct wacom_features wacom_features_0x14 =
4205 { "Wacom Graphire3 6x8", 16704, 12064, 511, 63,
4206 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4207 static const struct wacom_features wacom_features_0x15 =
4208 { "Wacom Graphire4 4x5", 10208, 7424, 511, 63,
4209 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4210 static const struct wacom_features wacom_features_0x16 =
4211 { "Wacom Graphire4 6x8", 16704, 12064, 511, 63,
4212 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4213 static const struct wacom_features wacom_features_0x17 =
4214 { "Wacom BambooFun 4x5", 14760, 9225, 511, 63,
4215 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4216 static const struct wacom_features wacom_features_0x18 =
4217 { "Wacom BambooFun 6x8", 21648, 13530, 511, 63,
4218 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4219 static const struct wacom_features wacom_features_0x19 =
4220 { "Wacom Bamboo1 Medium", 16704, 12064, 511, 63,
4221 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4222 static const struct wacom_features wacom_features_0x60 =
4223 { "Wacom Volito", 5104, 3712, 511, 63,
4224 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4225 static const struct wacom_features wacom_features_0x61 =
4226 { "Wacom PenStation2", 3250, 2320, 255, 63,
4227 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4228 static const struct wacom_features wacom_features_0x62 =
4229 { "Wacom Volito2 4x5", 5104, 3712, 511, 63,
4230 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4231 static const struct wacom_features wacom_features_0x63 =
4232 { "Wacom Volito2 2x3", 3248, 2320, 511, 63,
4233 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4234 static const struct wacom_features wacom_features_0x64 =
4235 { "Wacom PenPartner2", 3250, 2320, 511, 63,
4236 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4237 static const struct wacom_features wacom_features_0x65 =
4238 { "Wacom Bamboo", 14760, 9225, 511, 63,
4239 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4240 static const struct wacom_features wacom_features_0x69 =
4241 { "Wacom Bamboo1", 5104, 3712, 511, 63,
4242 GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
4243 static const struct wacom_features wacom_features_0x6A =
4244 { "Wacom Bamboo1 4x6", 14760, 9225, 1023, 63,
4245 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4246 static const struct wacom_features wacom_features_0x6B =
4247 { "Wacom Bamboo1 5x8", 21648, 13530, 1023, 63,
4248 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4249 static const struct wacom_features wacom_features_0x20 =
4250 { "Wacom Intuos 4x5", 12700, 10600, 1023, 31,
4251 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4252 static const struct wacom_features wacom_features_0x21 =
4253 { "Wacom Intuos 6x8", 20320, 16240, 1023, 31,
4254 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4255 static const struct wacom_features wacom_features_0x22 =
4256 { "Wacom Intuos 9x12", 30480, 24060, 1023, 31,
4257 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4258 static const struct wacom_features wacom_features_0x23 =
4259 { "Wacom Intuos 12x12", 30480, 31680, 1023, 31,
4260 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4261 static const struct wacom_features wacom_features_0x24 =
4262 { "Wacom Intuos 12x18", 45720, 31680, 1023, 31,
4263 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4264 static const struct wacom_features wacom_features_0x30 =
4265 { "Wacom PL400", 5408, 4056, 255, 0,
4266 PL, WACOM_PL_RES, WACOM_PL_RES };
4267 static const struct wacom_features wacom_features_0x31 =
4268 { "Wacom PL500", 6144, 4608, 255, 0,
4269 PL, WACOM_PL_RES, WACOM_PL_RES };
4270 static const struct wacom_features wacom_features_0x32 =
4271 { "Wacom PL600", 6126, 4604, 255, 0,
4272 PL, WACOM_PL_RES, WACOM_PL_RES };
4273 static const struct wacom_features wacom_features_0x33 =
4274 { "Wacom PL600SX", 6260, 5016, 255, 0,
4275 PL, WACOM_PL_RES, WACOM_PL_RES };
4276 static const struct wacom_features wacom_features_0x34 =
4277 { "Wacom PL550", 6144, 4608, 511, 0,
4278 PL, WACOM_PL_RES, WACOM_PL_RES };
4279 static const struct wacom_features wacom_features_0x35 =
4280 { "Wacom PL800", 7220, 5780, 511, 0,
4281 PL, WACOM_PL_RES, WACOM_PL_RES };
4282 static const struct wacom_features wacom_features_0x37 =
4283 { "Wacom PL700", 6758, 5406, 511, 0,
4284 PL, WACOM_PL_RES, WACOM_PL_RES };
4285 static const struct wacom_features wacom_features_0x38 =
4286 { "Wacom PL510", 6282, 4762, 511, 0,
4287 PL, WACOM_PL_RES, WACOM_PL_RES };
4288 static const struct wacom_features wacom_features_0x39 =
4289 { "Wacom DTU710", 34080, 27660, 511, 0,
4290 PL, WACOM_PL_RES, WACOM_PL_RES };
4291 static const struct wacom_features wacom_features_0xC4 =
4292 { "Wacom DTF521", 6282, 4762, 511, 0,
4293 PL, WACOM_PL_RES, WACOM_PL_RES };
4294 static const struct wacom_features wacom_features_0xC0 =
4295 { "Wacom DTF720", 6858, 5506, 511, 0,
4296 PL, WACOM_PL_RES, WACOM_PL_RES };
4297 static const struct wacom_features wacom_features_0xC2 =
4298 { "Wacom DTF720a", 6858, 5506, 511, 0,
4299 PL, WACOM_PL_RES, WACOM_PL_RES };
4300 static const struct wacom_features wacom_features_0x03 =
4301 { "Wacom Cintiq Partner", 20480, 15360, 511, 0,
4302 PTU, WACOM_PL_RES, WACOM_PL_RES };
4303 static const struct wacom_features wacom_features_0x41 =
4304 { "Wacom Intuos2 4x5", 12700, 10600, 1023, 31,
4305 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4306 static const struct wacom_features wacom_features_0x42 =
4307 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
4308 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4309 static const struct wacom_features wacom_features_0x43 =
4310 { "Wacom Intuos2 9x12", 30480, 24060, 1023, 31,
4311 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4312 static const struct wacom_features wacom_features_0x44 =
4313 { "Wacom Intuos2 12x12", 30480, 31680, 1023, 31,
4314 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4315 static const struct wacom_features wacom_features_0x45 =
4316 { "Wacom Intuos2 12x18", 45720, 31680, 1023, 31,
4317 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4318 static const struct wacom_features wacom_features_0xB0 =
4319 { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63,
4320 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
4321 static const struct wacom_features wacom_features_0xB1 =
4322 { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63,
4323 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4324 static const struct wacom_features wacom_features_0xB2 =
4325 { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63,
4326 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4327 static const struct wacom_features wacom_features_0xB3 =
4328 { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63,
4329 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4330 static const struct wacom_features wacom_features_0xB4 =
4331 { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63,
4332 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4333 static const struct wacom_features wacom_features_0xB5 =
4334 { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63,
4335 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4336 static const struct wacom_features wacom_features_0xB7 =
4337 { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63,
4338 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
4339 static const struct wacom_features wacom_features_0xB8 =
4340 { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63,
4341 INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
4342 static const struct wacom_features wacom_features_0xB9 =
4343 { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63,
4344 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4345 static const struct wacom_features wacom_features_0xBA =
4346 { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63,
4347 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4348 static const struct wacom_features wacom_features_0xBB =
4349 { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63,
4350 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4351 static const struct wacom_features wacom_features_0xBC =
4352 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
4353 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4354 static const struct wacom_features wacom_features_0xBD =
4355 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
4356 INTUOS4WL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4357 static const struct wacom_features wacom_features_0x26 =
4358 { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63,
4359 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16 };
4360 static const struct wacom_features wacom_features_0x27 =
4361 { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63,
4362 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
4363 static const struct wacom_features wacom_features_0x28 =
4364 { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63,
4365 INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
4366 static const struct wacom_features wacom_features_0x29 =
4367 { "Wacom Intuos5 S", 31496, 19685, 2047, 63,
4368 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
4369 static const struct wacom_features wacom_features_0x2A =
4370 { "Wacom Intuos5 M", 44704, 27940, 2047, 63,
4371 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4372 static const struct wacom_features wacom_features_0x314 =
4373 { "Wacom Intuos Pro S", 31496, 19685, 2047, 63,
4374 INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16,
4375 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4376 static const struct wacom_features wacom_features_0x315 =
4377 { "Wacom Intuos Pro M", 44704, 27940, 2047, 63,
4378 INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
4379 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4380 static const struct wacom_features wacom_features_0x317 =
4381 { "Wacom Intuos Pro L", 65024, 40640, 2047, 63,
4382 INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
4383 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4384 static const struct wacom_features wacom_features_0xF4 =
4385 { "Wacom Cintiq 24HD", 104480, 65600, 2047, 63,
4386 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
4387 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4388 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4389 static const struct wacom_features wacom_features_0xF8 =
4390 { "Wacom Cintiq 24HD touch", 104480, 65600, 2047, 63, /* Pen */
4391 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
4392 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4393 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4394 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 };
4395 static const struct wacom_features wacom_features_0xF6 =
4396 { "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */
4397 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10,
4398 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4399 static const struct wacom_features wacom_features_0x32A =
4400 { "Wacom Cintiq 27QHD", 120140, 67920, 2047, 63,
4401 WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
4402 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4403 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4404 static const struct wacom_features wacom_features_0x32B =
4405 { "Wacom Cintiq 27QHD touch", 120140, 67920, 2047, 63,
4406 WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
4407 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4408 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4409 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32C };
4410 static const struct wacom_features wacom_features_0x32C =
4411 { "Wacom Cintiq 27QHD touch", .type = WACOM_27QHDT,
4412 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32B, .touch_max = 10 };
4413 static const struct wacom_features wacom_features_0x3F =
4414 { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63,
4415 CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4416 static const struct wacom_features wacom_features_0xC5 =
4417 { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63,
4418 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
4419 static const struct wacom_features wacom_features_0xC6 =
4420 { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63,
4421 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
4422 static const struct wacom_features wacom_features_0x304 =
4423 { "Wacom Cintiq 13HD", 59552, 33848, 1023, 63,
4424 WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4425 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4426 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4427 static const struct wacom_features wacom_features_0x333 =
4428 { "Wacom Cintiq 13HD touch", 59552, 33848, 2047, 63,
4429 WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4430 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4431 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4432 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x335 };
4433 static const struct wacom_features wacom_features_0x335 =
4434 { "Wacom Cintiq 13HD touch", .type = WACOM_24HDT, /* Touch */
4435 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x333, .touch_max = 10,
4436 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4437 static const struct wacom_features wacom_features_0xC7 =
4438 { "Wacom DTU1931", 37832, 30305, 511, 0,
4439 PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4440 static const struct wacom_features wacom_features_0xCE =
4441 { "Wacom DTU2231", 47864, 27011, 511, 0,
4442 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4443 .check_for_hid_type = true, .hid_type = HID_TYPE_USBMOUSE };
4444 static const struct wacom_features wacom_features_0xF0 =
4445 { "Wacom DTU1631", 34623, 19553, 511, 0,
4446 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4447 static const struct wacom_features wacom_features_0xFB =
4448 { "Wacom DTU1031", 22096, 13960, 511, 0,
4449 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
4450 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4451 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4452 static const struct wacom_features wacom_features_0x32F =
4453 { "Wacom DTU1031X", 22672, 12928, 511, 0,
4454 DTUSX, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 0,
4455 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4456 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4457 static const struct wacom_features wacom_features_0x336 =
4458 { "Wacom DTU1141", 23672, 13403, 1023, 0,
4459 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
4460 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4461 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4462 static const struct wacom_features wacom_features_0x57 =
4463 { "Wacom DTK2241", 95840, 54260, 2047, 63,
4464 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
4465 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4466 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4467 static const struct wacom_features wacom_features_0x59 = /* Pen */
4468 { "Wacom DTH2242", 95840, 54260, 2047, 63,
4469 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
4470 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4471 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4472 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D };
4473 static const struct wacom_features wacom_features_0x5D = /* Touch */
4474 { "Wacom DTH2242", .type = WACOM_24HDT,
4475 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10,
4476 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4477 static const struct wacom_features wacom_features_0xCC =
4478 { "Wacom Cintiq 21UX2", 87200, 65600, 2047, 63,
4479 WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
4480 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4481 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4482 static const struct wacom_features wacom_features_0xFA =
4483 { "Wacom Cintiq 22HD", 95840, 54260, 2047, 63,
4484 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
4485 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4486 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4487 static const struct wacom_features wacom_features_0x5B =
4488 { "Wacom Cintiq 22HDT", 95840, 54260, 2047, 63,
4489 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
4490 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4491 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4492 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e };
4493 static const struct wacom_features wacom_features_0x5E =
4494 { "Wacom Cintiq 22HDT", .type = WACOM_24HDT,
4495 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5b, .touch_max = 10,
4496 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4497 static const struct wacom_features wacom_features_0x90 =
4498 { "Wacom ISDv4 90", 26202, 16325, 255, 0,
4499 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4500 static const struct wacom_features wacom_features_0x93 =
4501 { "Wacom ISDv4 93", 26202, 16325, 255, 0,
4502 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4503 static const struct wacom_features wacom_features_0x97 =
4504 { "Wacom ISDv4 97", 26202, 16325, 511, 0,
4505 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4506 static const struct wacom_features wacom_features_0x9A =
4507 { "Wacom ISDv4 9A", 26202, 16325, 255, 0,
4508 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4509 static const struct wacom_features wacom_features_0x9F =
4510 { "Wacom ISDv4 9F", 26202, 16325, 255, 0,
4511 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4512 static const struct wacom_features wacom_features_0xE2 =
4513 { "Wacom ISDv4 E2", 26202, 16325, 255, 0,
4514 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4515 static const struct wacom_features wacom_features_0xE3 =
4516 { "Wacom ISDv4 E3", 26202, 16325, 255, 0,
4517 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4518 static const struct wacom_features wacom_features_0xE5 =
4519 { "Wacom ISDv4 E5", 26202, 16325, 255, 0,
4520 MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4521 static const struct wacom_features wacom_features_0xE6 =
4522 { "Wacom ISDv4 E6", 27760, 15694, 255, 0,
4523 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4524 static const struct wacom_features wacom_features_0xEC =
4525 { "Wacom ISDv4 EC", 25710, 14500, 255, 0,
4526 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4527 static const struct wacom_features wacom_features_0xED =
4528 { "Wacom ISDv4 ED", 26202, 16325, 255, 0,
4529 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4530 static const struct wacom_features wacom_features_0xEF =
4531 { "Wacom ISDv4 EF", 26202, 16325, 255, 0,
4532 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4533 static const struct wacom_features wacom_features_0x100 =
4534 { "Wacom ISDv4 100", 26202, 16325, 255, 0,
4535 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4536 static const struct wacom_features wacom_features_0x101 =
4537 { "Wacom ISDv4 101", 26202, 16325, 255, 0,
4538 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4539 static const struct wacom_features wacom_features_0x10D =
4540 { "Wacom ISDv4 10D", 26202, 16325, 255, 0,
4541 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4542 static const struct wacom_features wacom_features_0x10E =
4543 { "Wacom ISDv4 10E", 27760, 15694, 255, 0,
4544 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4545 static const struct wacom_features wacom_features_0x10F =
4546 { "Wacom ISDv4 10F", 27760, 15694, 255, 0,
4547 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4548 static const struct wacom_features wacom_features_0x116 =
4549 { "Wacom ISDv4 116", 26202, 16325, 255, 0,
4550 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4551 static const struct wacom_features wacom_features_0x12C =
4552 { "Wacom ISDv4 12C", 27848, 15752, 2047, 0,
4553 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4554 static const struct wacom_features wacom_features_0x4001 =
4555 { "Wacom ISDv4 4001", 26202, 16325, 255, 0,
4556 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4557 static const struct wacom_features wacom_features_0x4004 =
4558 { "Wacom ISDv4 4004", 11060, 6220, 255, 0,
4559 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4560 static const struct wacom_features wacom_features_0x5000 =
4561 { "Wacom ISDv4 5000", 27848, 15752, 1023, 0,
4562 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4563 static const struct wacom_features wacom_features_0x5002 =
4564 { "Wacom ISDv4 5002", 29576, 16724, 1023, 0,
4565 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4566 static const struct wacom_features wacom_features_0x47 =
4567 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
4568 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4569 static const struct wacom_features wacom_features_0x84 =
4570 { "Wacom Wireless Receiver", .type = WIRELESS, .touch_max = 16 };
4571 static const struct wacom_features wacom_features_0xD0 =
4572 { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31,
4573 BAMBOO_TOUCH, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4574 static const struct wacom_features wacom_features_0xD1 =
4575 { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31,
4576 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4577 static const struct wacom_features wacom_features_0xD2 =
4578 { "Wacom Bamboo Craft", 14720, 9200, 1023, 31,
4579 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4580 static const struct wacom_features wacom_features_0xD3 =
4581 { "Wacom Bamboo 2FG 6x8", 21648, 13700, 1023, 31,
4582 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4583 static const struct wacom_features wacom_features_0xD4 =
4584 { "Wacom Bamboo Pen", 14720, 9200, 1023, 31,
4585 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4586 static const struct wacom_features wacom_features_0xD5 =
4587 { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31,
4588 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4589 static const struct wacom_features wacom_features_0xD6 =
4590 { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31,
4591 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4592 static const struct wacom_features wacom_features_0xD7 =
4593 { "Wacom BambooPT 2FG Small", 14720, 9200, 1023, 31,
4594 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4595 static const struct wacom_features wacom_features_0xD8 =
4596 { "Wacom Bamboo Comic 2FG", 21648, 13700, 1023, 31,
4597 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4598 static const struct wacom_features wacom_features_0xDA =
4599 { "Wacom Bamboo 2FG 4x5 SE", 14720, 9200, 1023, 31,
4600 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4601 static const struct wacom_features wacom_features_0xDB =
4602 { "Wacom Bamboo 2FG 6x8 SE", 21648, 13700, 1023, 31,
4603 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4604 static const struct wacom_features wacom_features_0xDD =
4605 { "Wacom Bamboo Connect", 14720, 9200, 1023, 31,
4606 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4607 static const struct wacom_features wacom_features_0xDE =
4608 { "Wacom Bamboo 16FG 4x5", 14720, 9200, 1023, 31,
4609 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
4610 static const struct wacom_features wacom_features_0xDF =
4611 { "Wacom Bamboo 16FG 6x8", 21648, 13700, 1023, 31,
4612 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
4613 static const struct wacom_features wacom_features_0x300 =
4614 { "Wacom Bamboo One S", 14720, 9225, 1023, 31,
4615 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4616 static const struct wacom_features wacom_features_0x301 =
4617 { "Wacom Bamboo One M", 21648, 13530, 1023, 31,
4618 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4619 static const struct wacom_features wacom_features_0x302 =
4620 { "Wacom Intuos PT S", 15200, 9500, 1023, 31,
4621 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4622 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4623 static const struct wacom_features wacom_features_0x303 =
4624 { "Wacom Intuos PT M", 21600, 13500, 1023, 31,
4625 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4626 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4627 static const struct wacom_features wacom_features_0x30E =
4628 { "Wacom Intuos S", 15200, 9500, 1023, 31,
4629 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4630 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4631 static const struct wacom_features wacom_features_0x6004 =
4632 { "ISD-V4", 12800, 8000, 255, 0,
4633 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4634 static const struct wacom_features wacom_features_0x307 =
4635 { "Wacom ISDv5 307", 59552, 33848, 2047, 63,
4636 CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4637 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4638 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4639 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 };
4640 static const struct wacom_features wacom_features_0x309 =
4641 { "Wacom ISDv5 309", .type = WACOM_24HDT, /* Touch */
4642 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x0307, .touch_max = 10,
4643 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4644 static const struct wacom_features wacom_features_0x30A =
4645 { "Wacom ISDv5 30A", 59552, 33848, 2047, 63,
4646 CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4647 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4648 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4649 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30C };
4650 static const struct wacom_features wacom_features_0x30C =
4651 { "Wacom ISDv5 30C", .type = WACOM_24HDT, /* Touch */
4652 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30A, .touch_max = 10,
4653 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4654 static const struct wacom_features wacom_features_0x318 =
4655 { "Wacom USB Bamboo PAD", 4095, 4095, /* Touch */
4656 .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
4657 static const struct wacom_features wacom_features_0x319 =
4658 { "Wacom Wireless Bamboo PAD", 4095, 4095, /* Touch */
4659 .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
4660 static const struct wacom_features wacom_features_0x325 =
4661 { "Wacom ISDv5 325", 59552, 33848, 2047, 63,
4662 CINTIQ_COMPANION_2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 11,
4663 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4664 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4665 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x326 };
4666 static const struct wacom_features wacom_features_0x326 = /* Touch */
4667 { "Wacom ISDv5 326", .type = HID_GENERIC, .oVid = USB_VENDOR_ID_WACOM,
4669 static const struct wacom_features wacom_features_0x323 =
4670 { "Wacom Intuos P M", 21600, 13500, 1023, 31,
4671 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4672 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4673 static const struct wacom_features wacom_features_0x331 =
4674 { "Wacom Express Key Remote", .type = REMOTE,
4675 .numbered_buttons = 18, .check_for_hid_type = true,
4676 .hid_type = HID_TYPE_USBNONE };
4677 static const struct wacom_features wacom_features_0x33B =
4678 { "Wacom Intuos S 2", 15200, 9500, 2047, 63,
4679 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4680 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4681 static const struct wacom_features wacom_features_0x33C =
4682 { "Wacom Intuos PT S 2", 15200, 9500, 2047, 63,
4683 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4684 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4685 static const struct wacom_features wacom_features_0x33D =
4686 { "Wacom Intuos P M 2", 21600, 13500, 2047, 63,
4687 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4688 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4689 static const struct wacom_features wacom_features_0x33E =
4690 { "Wacom Intuos PT M 2", 21600, 13500, 2047, 63,
4691 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4692 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4693 static const struct wacom_features wacom_features_0x343 =
4694 { "Wacom DTK1651", 34816, 19759, 1023, 0,
4695 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
4696 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4697 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4698 static const struct wacom_features wacom_features_0x360 =
4699 { "Wacom Intuos Pro M", 44800, 29600, 8191, 63,
4700 INTUOSP2_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 10 };
4701 static const struct wacom_features wacom_features_0x361 =
4702 { "Wacom Intuos Pro L", 62200, 43200, 8191, 63,
4703 INTUOSP2_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 10 };
4704 static const struct wacom_features wacom_features_0x377 =
4705 { "Wacom Intuos BT S", 15200, 9500, 4095, 63,
4706 INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
4707 static const struct wacom_features wacom_features_0x379 =
4708 { "Wacom Intuos BT M", 21600, 13500, 4095, 63,
4709 INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
4710 static const struct wacom_features wacom_features_0x37A =
4711 { "Wacom One by Wacom S", 15200, 9500, 2047, 63,
4712 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4713 static const struct wacom_features wacom_features_0x37B =
4714 { "Wacom One by Wacom M", 21600, 13500, 2047, 63,
4715 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4716 static const struct wacom_features wacom_features_0x393 =
4717 { "Wacom Intuos Pro S", 31920, 19950, 8191, 63,
4718 INTUOSP2S_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7,
4721 static const struct wacom_features wacom_features_HID_ANY_ID =
4722 { "Wacom HID", .type = HID_GENERIC, .oVid = HID_ANY_ID, .oPid = HID_ANY_ID };
4724 #define USB_DEVICE_WACOM(prod) \
4725 HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4726 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4728 #define BT_DEVICE_WACOM(prod) \
4729 HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4730 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4732 #define I2C_DEVICE_WACOM(prod) \
4733 HID_DEVICE(BUS_I2C, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4734 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4736 #define USB_DEVICE_LENOVO(prod) \
4737 HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
4738 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4740 const struct hid_device_id wacom_ids[] = {
4741 { USB_DEVICE_WACOM(0x00) },
4742 { USB_DEVICE_WACOM(0x03) },
4743 { USB_DEVICE_WACOM(0x10) },
4744 { USB_DEVICE_WACOM(0x11) },
4745 { USB_DEVICE_WACOM(0x12) },
4746 { USB_DEVICE_WACOM(0x13) },
4747 { USB_DEVICE_WACOM(0x14) },
4748 { USB_DEVICE_WACOM(0x15) },
4749 { USB_DEVICE_WACOM(0x16) },
4750 { USB_DEVICE_WACOM(0x17) },
4751 { USB_DEVICE_WACOM(0x18) },
4752 { USB_DEVICE_WACOM(0x19) },
4753 { USB_DEVICE_WACOM(0x20) },
4754 { USB_DEVICE_WACOM(0x21) },
4755 { USB_DEVICE_WACOM(0x22) },
4756 { USB_DEVICE_WACOM(0x23) },
4757 { USB_DEVICE_WACOM(0x24) },
4758 { USB_DEVICE_WACOM(0x26) },
4759 { USB_DEVICE_WACOM(0x27) },
4760 { USB_DEVICE_WACOM(0x28) },
4761 { USB_DEVICE_WACOM(0x29) },
4762 { USB_DEVICE_WACOM(0x2A) },
4763 { USB_DEVICE_WACOM(0x30) },
4764 { USB_DEVICE_WACOM(0x31) },
4765 { USB_DEVICE_WACOM(0x32) },
4766 { USB_DEVICE_WACOM(0x33) },
4767 { USB_DEVICE_WACOM(0x34) },
4768 { USB_DEVICE_WACOM(0x35) },
4769 { USB_DEVICE_WACOM(0x37) },
4770 { USB_DEVICE_WACOM(0x38) },
4771 { USB_DEVICE_WACOM(0x39) },
4772 { USB_DEVICE_WACOM(0x3F) },
4773 { USB_DEVICE_WACOM(0x41) },
4774 { USB_DEVICE_WACOM(0x42) },
4775 { USB_DEVICE_WACOM(0x43) },
4776 { USB_DEVICE_WACOM(0x44) },
4777 { USB_DEVICE_WACOM(0x45) },
4778 { USB_DEVICE_WACOM(0x47) },
4779 { USB_DEVICE_WACOM(0x57) },
4780 { USB_DEVICE_WACOM(0x59) },
4781 { USB_DEVICE_WACOM(0x5B) },
4782 { USB_DEVICE_WACOM(0x5D) },
4783 { USB_DEVICE_WACOM(0x5E) },
4784 { USB_DEVICE_WACOM(0x60) },
4785 { USB_DEVICE_WACOM(0x61) },
4786 { USB_DEVICE_WACOM(0x62) },
4787 { USB_DEVICE_WACOM(0x63) },
4788 { USB_DEVICE_WACOM(0x64) },
4789 { USB_DEVICE_WACOM(0x65) },
4790 { USB_DEVICE_WACOM(0x69) },
4791 { USB_DEVICE_WACOM(0x6A) },
4792 { USB_DEVICE_WACOM(0x6B) },
4793 { BT_DEVICE_WACOM(0x81) },
4794 { USB_DEVICE_WACOM(0x84) },
4795 { USB_DEVICE_WACOM(0x90) },
4796 { USB_DEVICE_WACOM(0x93) },
4797 { USB_DEVICE_WACOM(0x97) },
4798 { USB_DEVICE_WACOM(0x9A) },
4799 { USB_DEVICE_WACOM(0x9F) },
4800 { USB_DEVICE_WACOM(0xB0) },
4801 { USB_DEVICE_WACOM(0xB1) },
4802 { USB_DEVICE_WACOM(0xB2) },
4803 { USB_DEVICE_WACOM(0xB3) },
4804 { USB_DEVICE_WACOM(0xB4) },
4805 { USB_DEVICE_WACOM(0xB5) },
4806 { USB_DEVICE_WACOM(0xB7) },
4807 { USB_DEVICE_WACOM(0xB8) },
4808 { USB_DEVICE_WACOM(0xB9) },
4809 { USB_DEVICE_WACOM(0xBA) },
4810 { USB_DEVICE_WACOM(0xBB) },
4811 { USB_DEVICE_WACOM(0xBC) },
4812 { BT_DEVICE_WACOM(0xBD) },
4813 { USB_DEVICE_WACOM(0xC0) },
4814 { USB_DEVICE_WACOM(0xC2) },
4815 { USB_DEVICE_WACOM(0xC4) },
4816 { USB_DEVICE_WACOM(0xC5) },
4817 { USB_DEVICE_WACOM(0xC6) },
4818 { USB_DEVICE_WACOM(0xC7) },
4819 { USB_DEVICE_WACOM(0xCC) },
4820 { USB_DEVICE_WACOM(0xCE) },
4821 { USB_DEVICE_WACOM(0xD0) },
4822 { USB_DEVICE_WACOM(0xD1) },
4823 { USB_DEVICE_WACOM(0xD2) },
4824 { USB_DEVICE_WACOM(0xD3) },
4825 { USB_DEVICE_WACOM(0xD4) },
4826 { USB_DEVICE_WACOM(0xD5) },
4827 { USB_DEVICE_WACOM(0xD6) },
4828 { USB_DEVICE_WACOM(0xD7) },
4829 { USB_DEVICE_WACOM(0xD8) },
4830 { USB_DEVICE_WACOM(0xDA) },
4831 { USB_DEVICE_WACOM(0xDB) },
4832 { USB_DEVICE_WACOM(0xDD) },
4833 { USB_DEVICE_WACOM(0xDE) },
4834 { USB_DEVICE_WACOM(0xDF) },
4835 { USB_DEVICE_WACOM(0xE2) },
4836 { USB_DEVICE_WACOM(0xE3) },
4837 { USB_DEVICE_WACOM(0xE5) },
4838 { USB_DEVICE_WACOM(0xE6) },
4839 { USB_DEVICE_WACOM(0xEC) },
4840 { USB_DEVICE_WACOM(0xED) },
4841 { USB_DEVICE_WACOM(0xEF) },
4842 { USB_DEVICE_WACOM(0xF0) },
4843 { USB_DEVICE_WACOM(0xF4) },
4844 { USB_DEVICE_WACOM(0xF6) },
4845 { USB_DEVICE_WACOM(0xF8) },
4846 { USB_DEVICE_WACOM(0xFA) },
4847 { USB_DEVICE_WACOM(0xFB) },
4848 { USB_DEVICE_WACOM(0x100) },
4849 { USB_DEVICE_WACOM(0x101) },
4850 { USB_DEVICE_WACOM(0x10D) },
4851 { USB_DEVICE_WACOM(0x10E) },
4852 { USB_DEVICE_WACOM(0x10F) },
4853 { USB_DEVICE_WACOM(0x116) },
4854 { USB_DEVICE_WACOM(0x12C) },
4855 { USB_DEVICE_WACOM(0x300) },
4856 { USB_DEVICE_WACOM(0x301) },
4857 { USB_DEVICE_WACOM(0x302) },
4858 { USB_DEVICE_WACOM(0x303) },
4859 { USB_DEVICE_WACOM(0x304) },
4860 { USB_DEVICE_WACOM(0x307) },
4861 { USB_DEVICE_WACOM(0x309) },
4862 { USB_DEVICE_WACOM(0x30A) },
4863 { USB_DEVICE_WACOM(0x30C) },
4864 { USB_DEVICE_WACOM(0x30E) },
4865 { USB_DEVICE_WACOM(0x314) },
4866 { USB_DEVICE_WACOM(0x315) },
4867 { USB_DEVICE_WACOM(0x317) },
4868 { USB_DEVICE_WACOM(0x318) },
4869 { USB_DEVICE_WACOM(0x319) },
4870 { USB_DEVICE_WACOM(0x323) },
4871 { USB_DEVICE_WACOM(0x325) },
4872 { USB_DEVICE_WACOM(0x326) },
4873 { USB_DEVICE_WACOM(0x32A) },
4874 { USB_DEVICE_WACOM(0x32B) },
4875 { USB_DEVICE_WACOM(0x32C) },
4876 { USB_DEVICE_WACOM(0x32F) },
4877 { USB_DEVICE_WACOM(0x331) },
4878 { USB_DEVICE_WACOM(0x333) },
4879 { USB_DEVICE_WACOM(0x335) },
4880 { USB_DEVICE_WACOM(0x336) },
4881 { USB_DEVICE_WACOM(0x33B) },
4882 { USB_DEVICE_WACOM(0x33C) },
4883 { USB_DEVICE_WACOM(0x33D) },
4884 { USB_DEVICE_WACOM(0x33E) },
4885 { USB_DEVICE_WACOM(0x343) },
4886 { BT_DEVICE_WACOM(0x360) },
4887 { BT_DEVICE_WACOM(0x361) },
4888 { BT_DEVICE_WACOM(0x377) },
4889 { BT_DEVICE_WACOM(0x379) },
4890 { USB_DEVICE_WACOM(0x37A) },
4891 { USB_DEVICE_WACOM(0x37B) },
4892 { BT_DEVICE_WACOM(0x393) },
4893 { USB_DEVICE_WACOM(0x4001) },
4894 { USB_DEVICE_WACOM(0x4004) },
4895 { USB_DEVICE_WACOM(0x5000) },
4896 { USB_DEVICE_WACOM(0x5002) },
4897 { USB_DEVICE_LENOVO(0x6004) },
4899 { USB_DEVICE_WACOM(HID_ANY_ID) },
4900 { I2C_DEVICE_WACOM(HID_ANY_ID) },
4901 { BT_DEVICE_WACOM(HID_ANY_ID) },
4904 MODULE_DEVICE_TABLE(hid, wacom_ids);