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 bool wacom_is_art_pen(int tool_id)
643 bool is_art_pen = false;
646 case 0x885: /* Intuos3 Marker Pen */
647 case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
648 case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */
655 static int wacom_intuos_get_tool_type(int tool_id)
657 int tool_type = BTN_TOOL_PEN;
659 if (wacom_is_art_pen(tool_id))
663 case 0x812: /* Inking pen */
664 case 0x801: /* Intuos3 Inking pen */
665 case 0x12802: /* Intuos4/5 Inking Pen */
667 tool_type = BTN_TOOL_PENCIL;
670 case 0x822: /* Pen */
673 case 0x823: /* Intuos3 Grip Pen */
674 case 0x813: /* Intuos3 Classic Pen */
675 case 0x802: /* Intuos4/5 13HD/24HD General Pen */
676 case 0x8e2: /* IntuosHT2 pen */
678 case 0x10842: /* MobileStudio Pro Pro Pen slim */
679 case 0x14802: /* Intuos4/5 13HD/24HD Classic Pen */
680 case 0x16802: /* Cintiq 13HD Pro Pen */
681 case 0x18802: /* DTH2242 Pen */
682 case 0x10802: /* Intuos4/5 13HD/24HD General Pen */
683 tool_type = BTN_TOOL_PEN;
686 case 0x832: /* Stroke pen */
688 tool_type = BTN_TOOL_BRUSH;
691 case 0x007: /* Mouse 4D and 2D */
694 case 0x017: /* Intuos3 2D Mouse */
695 case 0x806: /* Intuos4 Mouse */
696 tool_type = BTN_TOOL_MOUSE;
699 case 0x096: /* Lens cursor */
700 case 0x097: /* Intuos3 Lens cursor */
701 case 0x006: /* Intuos4 Lens cursor */
702 tool_type = BTN_TOOL_LENS;
705 case 0x82a: /* Eraser */
711 case 0x82b: /* Intuos3 Grip Pen Eraser */
712 case 0x81b: /* Intuos3 Classic Pen Eraser */
713 case 0x91b: /* Intuos3 Airbrush Eraser */
714 case 0x80c: /* Intuos4/5 13HD/24HD Marker Pen Eraser */
715 case 0x80a: /* Intuos4/5 13HD/24HD General Pen Eraser */
716 case 0x90a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
717 case 0x1480a: /* Intuos4/5 13HD/24HD Classic Pen Eraser */
718 case 0x1090a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
719 case 0x1080c: /* Intuos4/5 13HD/24HD Art Pen Eraser */
720 case 0x1084a: /* MobileStudio Pro Pro Pen slim Eraser */
721 case 0x1680a: /* Cintiq 13HD Pro Pen Eraser */
722 case 0x1880a: /* DTH2242 Eraser */
723 case 0x1080a: /* Intuos4/5 13HD/24HD General Pen Eraser */
724 tool_type = BTN_TOOL_RUBBER;
730 case 0x913: /* Intuos3 Airbrush */
731 case 0x902: /* Intuos4/5 13HD/24HD Airbrush */
732 case 0x10902: /* Intuos4/5 13HD/24HD Airbrush */
733 tool_type = BTN_TOOL_AIRBRUSH;
739 static void wacom_exit_report(struct wacom_wac *wacom)
741 struct input_dev *input = wacom->pen_input;
742 struct wacom_features *features = &wacom->features;
743 unsigned char *data = wacom->data;
744 int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
747 * Reset all states otherwise we lose the initial states
748 * when in-prox next time
750 input_report_abs(input, ABS_X, 0);
751 input_report_abs(input, ABS_Y, 0);
752 input_report_abs(input, ABS_DISTANCE, 0);
753 input_report_abs(input, ABS_TILT_X, 0);
754 input_report_abs(input, ABS_TILT_Y, 0);
755 if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
756 input_report_key(input, BTN_LEFT, 0);
757 input_report_key(input, BTN_MIDDLE, 0);
758 input_report_key(input, BTN_RIGHT, 0);
759 input_report_key(input, BTN_SIDE, 0);
760 input_report_key(input, BTN_EXTRA, 0);
761 input_report_abs(input, ABS_THROTTLE, 0);
762 input_report_abs(input, ABS_RZ, 0);
764 input_report_abs(input, ABS_PRESSURE, 0);
765 input_report_key(input, BTN_STYLUS, 0);
766 input_report_key(input, BTN_STYLUS2, 0);
767 input_report_key(input, BTN_TOUCH, 0);
768 input_report_abs(input, ABS_WHEEL, 0);
769 if (features->type >= INTUOS3S)
770 input_report_abs(input, ABS_Z, 0);
772 input_report_key(input, wacom->tool[idx], 0);
773 input_report_abs(input, ABS_MISC, 0); /* reset tool id */
774 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
778 static int wacom_intuos_inout(struct wacom_wac *wacom)
780 struct wacom_features *features = &wacom->features;
781 unsigned char *data = wacom->data;
782 struct input_dev *input = wacom->pen_input;
783 int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
785 if (!(((data[1] & 0xfc) == 0xc0) || /* in prox */
786 ((data[1] & 0xfe) == 0x20) || /* in range */
787 ((data[1] & 0xfe) == 0x80))) /* out prox */
791 if ((data[1] & 0xfc) == 0xc0) {
792 /* serial number of the tool */
793 wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
794 (data[4] << 20) + (data[5] << 12) +
795 (data[6] << 4) + (data[7] >> 4);
797 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) |
798 ((data[7] & 0x0f) << 16) | ((data[8] & 0xf0) << 8);
800 wacom->tool[idx] = wacom_intuos_get_tool_type(wacom->id[idx]);
802 wacom->shared->stylus_in_proximity = true;
807 if ((data[1] & 0xfe) == 0x20) {
808 if (features->type != INTUOSHT2)
809 wacom->shared->stylus_in_proximity = true;
811 /* in Range while exiting */
812 if (wacom->reporting_data) {
813 input_report_key(input, BTN_TOUCH, 0);
814 input_report_abs(input, ABS_PRESSURE, 0);
815 input_report_abs(input, ABS_DISTANCE, wacom->features.distance_max);
822 if ((data[1] & 0xfe) == 0x80) {
823 wacom->shared->stylus_in_proximity = false;
824 wacom->reporting_data = false;
826 /* don't report exit if we don't know the ID */
830 wacom_exit_report(wacom);
837 static inline bool touch_is_muted(struct wacom_wac *wacom_wac)
839 return wacom_wac->probe_complete &&
840 wacom_wac->shared->has_mute_touch_switch &&
841 !wacom_wac->shared->is_touch_on;
844 static inline bool report_touch_events(struct wacom_wac *wacom)
846 return (touch_arbitration ? !wacom->shared->stylus_in_proximity : 1);
849 static inline bool delay_pen_events(struct wacom_wac *wacom)
851 return (wacom->shared->touch_down && touch_arbitration);
854 static int wacom_intuos_general(struct wacom_wac *wacom)
856 struct wacom_features *features = &wacom->features;
857 unsigned char *data = wacom->data;
858 struct input_dev *input = wacom->pen_input;
859 int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
860 unsigned char type = (data[1] >> 1) & 0x0F;
861 unsigned int x, y, distance, t;
863 if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_CINTIQ &&
864 data[0] != WACOM_REPORT_INTUOS_PEN)
867 if (delay_pen_events(wacom))
870 /* don't report events if we don't know the tool ID */
871 if (!wacom->id[idx]) {
872 /* but reschedule a read of the current tool */
873 wacom_intuos_schedule_prox_event(wacom);
878 * don't report events for invalid data
880 /* older I4 styli don't work with new Cintiqs */
881 if ((!((wacom->id[idx] >> 16) & 0x01) &&
882 (features->type == WACOM_21UX2)) ||
883 /* Only large Intuos support Lense Cursor */
884 (wacom->tool[idx] == BTN_TOOL_LENS &&
885 (features->type == INTUOS3 ||
886 features->type == INTUOS3S ||
887 features->type == INTUOS4 ||
888 features->type == INTUOS4S ||
889 features->type == INTUOS5 ||
890 features->type == INTUOS5S ||
891 features->type == INTUOSPM ||
892 features->type == INTUOSPS)) ||
893 /* Cintiq doesn't send data when RDY bit isn't set */
894 (features->type == CINTIQ && !(data[1] & 0x40)))
897 x = (be16_to_cpup((__be16 *)&data[2]) << 1) | ((data[9] >> 1) & 1);
898 y = (be16_to_cpup((__be16 *)&data[4]) << 1) | (data[9] & 1);
899 distance = data[9] >> 2;
900 if (features->type < INTUOS3S) {
905 if (features->type == INTUOSHT2)
906 distance = features->distance_max - distance;
907 input_report_abs(input, ABS_X, x);
908 input_report_abs(input, ABS_Y, y);
909 input_report_abs(input, ABS_DISTANCE, distance);
916 /* general pen packet */
917 t = (data[6] << 3) | ((data[7] & 0xC0) >> 5) | (data[1] & 1);
918 if (features->pressure_max < 2047)
920 input_report_abs(input, ABS_PRESSURE, t);
921 if (features->type != INTUOSHT2) {
922 input_report_abs(input, ABS_TILT_X,
923 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
924 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
926 input_report_key(input, BTN_STYLUS, data[1] & 2);
927 input_report_key(input, BTN_STYLUS2, data[1] & 4);
928 input_report_key(input, BTN_TOUCH, t > 10);
932 /* airbrush second packet */
933 input_report_abs(input, ABS_WHEEL,
934 (data[6] << 2) | ((data[7] >> 6) & 3));
935 input_report_abs(input, ABS_TILT_X,
936 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
937 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
941 /* Rotation packet */
942 if (features->type >= INTUOS3S) {
943 /* I3 marker pen rotation */
944 t = (data[6] << 3) | ((data[7] >> 5) & 7);
945 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
946 ((t-1) / 2 + 450)) : (450 - t / 2) ;
947 input_report_abs(input, ABS_Z, t);
949 /* 4D mouse 2nd packet */
950 t = (data[6] << 3) | ((data[7] >> 5) & 7);
951 input_report_abs(input, ABS_RZ, (data[7] & 0x20) ?
952 ((t - 1) / 2) : -t / 2);
957 /* 4D mouse 1st packet */
958 input_report_key(input, BTN_LEFT, data[8] & 0x01);
959 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
960 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
962 input_report_key(input, BTN_SIDE, data[8] & 0x20);
963 input_report_key(input, BTN_EXTRA, data[8] & 0x10);
964 t = (data[6] << 2) | ((data[7] >> 6) & 3);
965 input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
970 input_report_key(input, BTN_LEFT, data[6] & 0x01);
971 input_report_key(input, BTN_MIDDLE, data[6] & 0x02);
972 input_report_key(input, BTN_RIGHT, data[6] & 0x04);
973 input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7)
974 - ((data[7] & 0x40) >> 6));
975 input_report_key(input, BTN_SIDE, data[6] & 0x08);
976 input_report_key(input, BTN_EXTRA, data[6] & 0x10);
978 input_report_abs(input, ABS_TILT_X,
979 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
980 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
984 if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
985 /* 2D mouse packet */
986 input_report_key(input, BTN_LEFT, data[8] & 0x04);
987 input_report_key(input, BTN_MIDDLE, data[8] & 0x08);
988 input_report_key(input, BTN_RIGHT, data[8] & 0x10);
989 input_report_rel(input, REL_WHEEL, (data[8] & 0x01)
990 - ((data[8] & 0x02) >> 1));
992 /* I3 2D mouse side buttons */
993 if (features->type >= INTUOS3S && features->type <= INTUOS3L) {
994 input_report_key(input, BTN_SIDE, data[8] & 0x40);
995 input_report_key(input, BTN_EXTRA, data[8] & 0x20);
998 else if (wacom->tool[idx] == BTN_TOOL_LENS) {
999 /* Lens cursor packets */
1000 input_report_key(input, BTN_LEFT, data[8] & 0x01);
1001 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
1002 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
1003 input_report_key(input, BTN_SIDE, data[8] & 0x10);
1004 input_report_key(input, BTN_EXTRA, data[8] & 0x08);
1019 input_report_abs(input, ABS_MISC,
1020 wacom_intuos_id_mangle(wacom->id[idx])); /* report tool id */
1021 input_report_key(input, wacom->tool[idx], 1);
1022 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
1023 wacom->reporting_data = true;
1027 static int wacom_intuos_irq(struct wacom_wac *wacom)
1029 unsigned char *data = wacom->data;
1030 struct input_dev *input = wacom->pen_input;
1033 if (data[0] != WACOM_REPORT_PENABLED &&
1034 data[0] != WACOM_REPORT_INTUOS_ID1 &&
1035 data[0] != WACOM_REPORT_INTUOS_ID2 &&
1036 data[0] != WACOM_REPORT_INTUOSPAD &&
1037 data[0] != WACOM_REPORT_INTUOS_PEN &&
1038 data[0] != WACOM_REPORT_CINTIQ &&
1039 data[0] != WACOM_REPORT_CINTIQPAD &&
1040 data[0] != WACOM_REPORT_INTUOS5PAD) {
1041 dev_dbg(input->dev.parent,
1042 "%s: received unknown report #%d\n", __func__, data[0]);
1046 /* process pad events */
1047 result = wacom_intuos_pad(wacom);
1051 /* process in/out prox events */
1052 result = wacom_intuos_inout(wacom);
1056 /* process general packets */
1057 result = wacom_intuos_general(wacom);
1064 static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len)
1066 unsigned char *data = wacom_wac->data;
1067 struct input_dev *input;
1068 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
1069 struct wacom_remote *remote = wacom->remote;
1070 int bat_charging, bat_percent, touch_ring_mode;
1073 unsigned long flags;
1075 if (data[0] != WACOM_REPORT_REMOTE) {
1076 hid_dbg(wacom->hdev, "%s: received unknown report #%d",
1081 serial = data[3] + (data[4] << 8) + (data[5] << 16);
1082 wacom_wac->id[0] = PAD_DEVICE_ID;
1084 spin_lock_irqsave(&remote->remote_lock, flags);
1086 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
1087 if (remote->remotes[i].serial == serial) {
1093 if (index < 0 || !remote->remotes[index].registered)
1096 input = remote->remotes[index].input;
1098 input_report_key(input, BTN_0, (data[9] & 0x01));
1099 input_report_key(input, BTN_1, (data[9] & 0x02));
1100 input_report_key(input, BTN_2, (data[9] & 0x04));
1101 input_report_key(input, BTN_3, (data[9] & 0x08));
1102 input_report_key(input, BTN_4, (data[9] & 0x10));
1103 input_report_key(input, BTN_5, (data[9] & 0x20));
1104 input_report_key(input, BTN_6, (data[9] & 0x40));
1105 input_report_key(input, BTN_7, (data[9] & 0x80));
1107 input_report_key(input, BTN_8, (data[10] & 0x01));
1108 input_report_key(input, BTN_9, (data[10] & 0x02));
1109 input_report_key(input, BTN_A, (data[10] & 0x04));
1110 input_report_key(input, BTN_B, (data[10] & 0x08));
1111 input_report_key(input, BTN_C, (data[10] & 0x10));
1112 input_report_key(input, BTN_X, (data[10] & 0x20));
1113 input_report_key(input, BTN_Y, (data[10] & 0x40));
1114 input_report_key(input, BTN_Z, (data[10] & 0x80));
1116 input_report_key(input, BTN_BASE, (data[11] & 0x01));
1117 input_report_key(input, BTN_BASE2, (data[11] & 0x02));
1119 if (data[12] & 0x80)
1120 input_report_abs(input, ABS_WHEEL, (data[12] & 0x7f) - 1);
1122 input_report_abs(input, ABS_WHEEL, 0);
1124 bat_percent = data[7] & 0x7f;
1125 bat_charging = !!(data[7] & 0x80);
1127 if (data[9] | data[10] | (data[11] & 0x03) | data[12])
1128 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
1130 input_report_abs(input, ABS_MISC, 0);
1132 input_event(input, EV_MSC, MSC_SERIAL, serial);
1136 /*Which mode select (LED light) is currently on?*/
1137 touch_ring_mode = (data[11] & 0xC0) >> 6;
1139 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
1140 if (remote->remotes[i].serial == serial)
1141 wacom->led.groups[i].select = touch_ring_mode;
1144 __wacom_notify_battery(&remote->remotes[index].battery,
1145 WACOM_POWER_SUPPLY_STATUS_AUTO, bat_percent,
1146 bat_charging, 1, bat_charging);
1149 spin_unlock_irqrestore(&remote->remote_lock, flags);
1153 static void wacom_remote_status_irq(struct wacom_wac *wacom_wac, size_t len)
1155 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
1156 unsigned char *data = wacom_wac->data;
1157 struct wacom_remote *remote = wacom->remote;
1158 struct wacom_remote_data remote_data;
1159 unsigned long flags;
1162 if (data[0] != WACOM_REPORT_DEVICE_LIST)
1165 memset(&remote_data, 0, sizeof(struct wacom_remote_data));
1167 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
1169 int serial = (data[j+6] << 16) + (data[j+5] << 8) + data[j+4];
1170 bool connected = data[j+2];
1172 remote_data.remote[i].serial = serial;
1173 remote_data.remote[i].connected = connected;
1176 spin_lock_irqsave(&remote->remote_lock, flags);
1178 ret = kfifo_in(&remote->remote_fifo, &remote_data, sizeof(remote_data));
1179 if (ret != sizeof(remote_data)) {
1180 spin_unlock_irqrestore(&remote->remote_lock, flags);
1181 hid_err(wacom->hdev, "Can't queue Remote status event.\n");
1185 spin_unlock_irqrestore(&remote->remote_lock, flags);
1187 wacom_schedule_work(wacom_wac, WACOM_WORKER_REMOTE);
1190 static int int_dist(int x1, int y1, int x2, int y2)
1195 return int_sqrt(x*x + y*y);
1198 static void wacom_intuos_bt_process_data(struct wacom_wac *wacom,
1199 unsigned char *data)
1201 memcpy(wacom->data, data, 10);
1202 wacom_intuos_irq(wacom);
1204 input_sync(wacom->pen_input);
1205 if (wacom->pad_input)
1206 input_sync(wacom->pad_input);
1209 static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
1211 unsigned char data[WACOM_PKGLEN_MAX];
1213 unsigned power_raw, battery_capacity, bat_charging, ps_connected;
1215 memcpy(data, wacom->data, len);
1219 wacom_intuos_bt_process_data(wacom, data + i);
1223 wacom_intuos_bt_process_data(wacom, data + i);
1225 wacom_intuos_bt_process_data(wacom, data + i);
1227 power_raw = data[i];
1228 bat_charging = (power_raw & 0x08) ? 1 : 0;
1229 ps_connected = (power_raw & 0x10) ? 1 : 0;
1230 battery_capacity = batcap_i4[power_raw & 0x07];
1231 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
1232 battery_capacity, bat_charging,
1233 battery_capacity || bat_charging,
1237 dev_dbg(wacom->pen_input->dev.parent,
1238 "Unknown report: %d,%d size:%zu\n",
1239 data[0], data[1], len);
1245 static int wacom_wac_finger_count_touches(struct wacom_wac *wacom)
1247 struct input_dev *input = wacom->touch_input;
1248 unsigned touch_max = wacom->features.touch_max;
1256 return test_bit(BTN_TOUCH, input->key) &&
1257 report_touch_events(wacom);
1259 for (i = 0; i < input->mt->num_slots; i++) {
1260 struct input_mt_slot *ps = &input->mt->slots[i];
1261 int id = input_mt_get_value(ps, ABS_MT_TRACKING_ID);
1269 static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
1271 int pen_frame_len, pen_frames;
1273 struct input_dev *pen_input = wacom->pen_input;
1274 unsigned char *data = wacom->data;
1277 if (wacom->features.type == INTUOSP2_BT ||
1278 wacom->features.type == INTUOSP2S_BT) {
1279 wacom->serial[0] = get_unaligned_le64(&data[99]);
1280 wacom->id[0] = get_unaligned_le16(&data[107]);
1284 wacom->serial[0] = get_unaligned_le64(&data[33]);
1285 wacom->id[0] = get_unaligned_le16(&data[41]);
1290 if (wacom->serial[0] >> 52 == 1) {
1291 /* Add back in missing bits of ID for non-USI pens */
1292 wacom->id[0] |= (wacom->serial[0] >> 32) & 0xFFFFF;
1295 for (i = 0; i < pen_frames; i++) {
1296 unsigned char *frame = &data[i*pen_frame_len + 1];
1297 bool valid = frame[0] & 0x80;
1298 bool prox = frame[0] & 0x40;
1299 bool range = frame[0] & 0x20;
1300 bool invert = frame[0] & 0x10;
1306 wacom->shared->stylus_in_proximity = false;
1307 wacom_exit_report(wacom);
1308 input_sync(pen_input);
1312 wacom->serial[0] = 0;
1317 if (!wacom->tool[0]) { /* first in range */
1318 /* Going into range select tool */
1320 wacom->tool[0] = BTN_TOOL_RUBBER;
1321 else if (wacom->id[0])
1322 wacom->tool[0] = wacom_intuos_get_tool_type(wacom->id[0]);
1324 wacom->tool[0] = BTN_TOOL_PEN;
1327 input_report_abs(pen_input, ABS_X, get_unaligned_le16(&frame[1]));
1328 input_report_abs(pen_input, ABS_Y, get_unaligned_le16(&frame[3]));
1330 if (wacom->features.type == INTUOSP2_BT ||
1331 wacom->features.type == INTUOSP2S_BT) {
1332 /* Fix rotation alignment: userspace expects zero at left */
1334 (int16_t)get_unaligned_le16(&frame[9]);
1340 input_report_abs(pen_input, ABS_TILT_X,
1342 input_report_abs(pen_input, ABS_TILT_Y,
1344 input_report_abs(pen_input, ABS_Z, rotation);
1345 input_report_abs(pen_input, ABS_WHEEL,
1346 get_unaligned_le16(&frame[11]));
1349 if (wacom->tool[0]) {
1350 input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5]));
1351 if (wacom->features.type == INTUOSP2_BT ||
1352 wacom->features.type == INTUOSP2S_BT) {
1353 input_report_abs(pen_input, ABS_DISTANCE,
1354 range ? frame[13] : wacom->features.distance_max);
1356 input_report_abs(pen_input, ABS_DISTANCE,
1357 range ? frame[7] : wacom->features.distance_max);
1360 input_report_key(pen_input, BTN_TOUCH, frame[0] & 0x09);
1361 input_report_key(pen_input, BTN_STYLUS, frame[0] & 0x02);
1362 input_report_key(pen_input, BTN_STYLUS2, frame[0] & 0x04);
1364 input_report_key(pen_input, wacom->tool[0], prox);
1365 input_event(pen_input, EV_MSC, MSC_SERIAL, wacom->serial[0]);
1366 input_report_abs(pen_input, ABS_MISC,
1367 wacom_intuos_id_mangle(wacom->id[0])); /* report tool id */
1370 wacom->shared->stylus_in_proximity = prox;
1372 input_sync(pen_input);
1376 static void wacom_intuos_pro2_bt_touch(struct wacom_wac *wacom)
1378 const int finger_touch_len = 8;
1379 const int finger_frames = 4;
1380 const int finger_frame_len = 43;
1382 struct input_dev *touch_input = wacom->touch_input;
1383 unsigned char *data = wacom->data;
1384 int num_contacts_left = 5;
1387 for (i = 0; i < finger_frames; i++) {
1388 unsigned char *frame = &data[i*finger_frame_len + 109];
1389 int current_num_contacts = frame[0] & 0x7F;
1390 int contacts_to_send;
1392 if (!(frame[0] & 0x80))
1396 * First packet resets the counter since only the first
1397 * packet in series will have non-zero current_num_contacts.
1399 if (current_num_contacts)
1400 wacom->num_contacts_left = current_num_contacts;
1402 contacts_to_send = min(num_contacts_left, wacom->num_contacts_left);
1404 for (j = 0; j < contacts_to_send; j++) {
1405 unsigned char *touch = &frame[j*finger_touch_len + 1];
1406 int slot = input_mt_get_slot_by_key(touch_input, touch[0]);
1407 int x = get_unaligned_le16(&touch[2]);
1408 int y = get_unaligned_le16(&touch[4]);
1409 int w = touch[6] * input_abs_get_res(touch_input, ABS_MT_POSITION_X);
1410 int h = touch[7] * input_abs_get_res(touch_input, ABS_MT_POSITION_Y);
1415 input_mt_slot(touch_input, slot);
1416 input_mt_report_slot_state(touch_input, MT_TOOL_FINGER, touch[1] & 0x01);
1417 input_report_abs(touch_input, ABS_MT_POSITION_X, x);
1418 input_report_abs(touch_input, ABS_MT_POSITION_Y, y);
1419 input_report_abs(touch_input, ABS_MT_TOUCH_MAJOR, max(w, h));
1420 input_report_abs(touch_input, ABS_MT_TOUCH_MINOR, min(w, h));
1421 input_report_abs(touch_input, ABS_MT_ORIENTATION, w > h);
1424 input_mt_sync_frame(touch_input);
1426 wacom->num_contacts_left -= contacts_to_send;
1427 if (wacom->num_contacts_left <= 0) {
1428 wacom->num_contacts_left = 0;
1429 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1430 input_sync(touch_input);
1434 if (wacom->num_contacts_left == 0) {
1435 // Be careful that we don't accidentally call input_sync with
1436 // only a partial set of fingers of processed
1437 input_report_switch(touch_input, SW_MUTE_DEVICE, !(data[281] >> 7));
1438 input_sync(touch_input);
1443 static void wacom_intuos_pro2_bt_pad(struct wacom_wac *wacom)
1445 struct input_dev *pad_input = wacom->pad_input;
1446 unsigned char *data = wacom->data;
1447 int nbuttons = wacom->features.numbered_buttons;
1449 int expresskeys = data[282];
1450 int center = (data[281] & 0x40) >> 6;
1451 int ring = data[285] & 0x7F;
1452 bool ringstatus = data[285] & 0x80;
1453 bool prox = expresskeys || center || ringstatus;
1455 /* Fix touchring data: userspace expects 0 at left and increasing clockwise */
1461 wacom_report_numbered_buttons(pad_input, nbuttons,
1462 expresskeys | (center << (nbuttons - 1)));
1464 input_report_abs(pad_input, ABS_WHEEL, ringstatus ? ring : 0);
1466 input_report_key(pad_input, wacom->tool[1], prox ? 1 : 0);
1467 input_report_abs(pad_input, ABS_MISC, prox ? PAD_DEVICE_ID : 0);
1468 input_event(pad_input, EV_MSC, MSC_SERIAL, 0xffffffff);
1470 input_sync(pad_input);
1473 static void wacom_intuos_pro2_bt_battery(struct wacom_wac *wacom)
1475 unsigned char *data = wacom->data;
1477 bool chg = data[284] & 0x80;
1478 int battery_status = data[284] & 0x7F;
1480 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
1481 battery_status, chg, 1, chg);
1484 static void wacom_intuos_gen3_bt_pad(struct wacom_wac *wacom)
1486 struct input_dev *pad_input = wacom->pad_input;
1487 unsigned char *data = wacom->data;
1489 int buttons = data[44];
1491 wacom_report_numbered_buttons(pad_input, 4, buttons);
1493 input_report_key(pad_input, wacom->tool[1], buttons ? 1 : 0);
1494 input_report_abs(pad_input, ABS_MISC, buttons ? PAD_DEVICE_ID : 0);
1495 input_event(pad_input, EV_MSC, MSC_SERIAL, 0xffffffff);
1497 input_sync(pad_input);
1500 static void wacom_intuos_gen3_bt_battery(struct wacom_wac *wacom)
1502 unsigned char *data = wacom->data;
1504 bool chg = data[45] & 0x80;
1505 int battery_status = data[45] & 0x7F;
1507 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
1508 battery_status, chg, 1, chg);
1511 static int wacom_intuos_pro2_bt_irq(struct wacom_wac *wacom, size_t len)
1513 unsigned char *data = wacom->data;
1515 if (data[0] != 0x80 && data[0] != 0x81) {
1516 dev_dbg(wacom->pen_input->dev.parent,
1517 "%s: received unknown report #%d\n", __func__, data[0]);
1521 wacom_intuos_pro2_bt_pen(wacom);
1522 if (wacom->features.type == INTUOSP2_BT ||
1523 wacom->features.type == INTUOSP2S_BT) {
1524 wacom_intuos_pro2_bt_touch(wacom);
1525 wacom_intuos_pro2_bt_pad(wacom);
1526 wacom_intuos_pro2_bt_battery(wacom);
1528 wacom_intuos_gen3_bt_pad(wacom);
1529 wacom_intuos_gen3_bt_battery(wacom);
1534 static int wacom_24hdt_irq(struct wacom_wac *wacom)
1536 struct input_dev *input = wacom->touch_input;
1537 unsigned char *data = wacom->data;
1539 int current_num_contacts = data[61];
1540 int contacts_to_send = 0;
1541 int num_contacts_left = 4; /* maximum contacts per packet */
1542 int byte_per_packet = WACOM_BYTES_PER_24HDT_PACKET;
1545 if (touch_is_muted(wacom) && !wacom->shared->touch_down)
1548 if (wacom->features.type == WACOM_27QHDT) {
1549 current_num_contacts = data[63];
1550 num_contacts_left = 10;
1551 byte_per_packet = WACOM_BYTES_PER_QHDTHID_PACKET;
1556 * First packet resets the counter since only the first
1557 * packet in series will have non-zero current_num_contacts.
1559 if (current_num_contacts)
1560 wacom->num_contacts_left = current_num_contacts;
1562 contacts_to_send = min(num_contacts_left, wacom->num_contacts_left);
1564 for (i = 0; i < contacts_to_send; i++) {
1565 int offset = (byte_per_packet * i) + 1;
1566 bool touch = (data[offset] & 0x1) && report_touch_events(wacom);
1567 int slot = input_mt_get_slot_by_key(input, data[offset + 1]);
1571 input_mt_slot(input, slot);
1572 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1575 int t_x = get_unaligned_le16(&data[offset + 2]);
1576 int t_y = get_unaligned_le16(&data[offset + 4 + y_offset]);
1578 input_report_abs(input, ABS_MT_POSITION_X, t_x);
1579 input_report_abs(input, ABS_MT_POSITION_Y, t_y);
1581 if (wacom->features.type != WACOM_27QHDT) {
1582 int c_x = get_unaligned_le16(&data[offset + 4]);
1583 int c_y = get_unaligned_le16(&data[offset + 8]);
1584 int w = get_unaligned_le16(&data[offset + 10]);
1585 int h = get_unaligned_le16(&data[offset + 12]);
1587 input_report_abs(input, ABS_MT_TOUCH_MAJOR, min(w,h));
1588 input_report_abs(input, ABS_MT_WIDTH_MAJOR,
1589 min(w, h) + int_dist(t_x, t_y, c_x, c_y));
1590 input_report_abs(input, ABS_MT_WIDTH_MINOR, min(w, h));
1591 input_report_abs(input, ABS_MT_ORIENTATION, w > h);
1595 input_mt_sync_frame(input);
1597 wacom->num_contacts_left -= contacts_to_send;
1598 if (wacom->num_contacts_left <= 0) {
1599 wacom->num_contacts_left = 0;
1600 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1605 static int wacom_mt_touch(struct wacom_wac *wacom)
1607 struct input_dev *input = wacom->touch_input;
1608 unsigned char *data = wacom->data;
1610 int current_num_contacts = data[2];
1611 int contacts_to_send = 0;
1614 /* MTTPC does not support Height and Width */
1615 if (wacom->features.type == MTTPC || wacom->features.type == MTTPC_B)
1619 * First packet resets the counter since only the first
1620 * packet in series will have non-zero current_num_contacts.
1622 if (current_num_contacts)
1623 wacom->num_contacts_left = current_num_contacts;
1625 /* There are at most 5 contacts per packet */
1626 contacts_to_send = min(5, wacom->num_contacts_left);
1628 for (i = 0; i < contacts_to_send; i++) {
1629 int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset) * i + 3;
1630 bool touch = (data[offset] & 0x1) && report_touch_events(wacom);
1631 int id = get_unaligned_le16(&data[offset + 1]);
1632 int slot = input_mt_get_slot_by_key(input, id);
1637 input_mt_slot(input, slot);
1638 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1640 int x = get_unaligned_le16(&data[offset + x_offset + 7]);
1641 int y = get_unaligned_le16(&data[offset + x_offset + 9]);
1642 input_report_abs(input, ABS_MT_POSITION_X, x);
1643 input_report_abs(input, ABS_MT_POSITION_Y, y);
1646 input_mt_sync_frame(input);
1648 wacom->num_contacts_left -= contacts_to_send;
1649 if (wacom->num_contacts_left <= 0) {
1650 wacom->num_contacts_left = 0;
1651 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1656 static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
1658 struct input_dev *input = wacom->touch_input;
1659 unsigned char *data = wacom->data;
1662 for (i = 0; i < 2; i++) {
1663 int p = data[1] & (1 << i);
1664 bool touch = p && report_touch_events(wacom);
1666 input_mt_slot(input, i);
1667 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1669 int x = le16_to_cpup((__le16 *)&data[i * 2 + 2]) & 0x7fff;
1670 int y = le16_to_cpup((__le16 *)&data[i * 2 + 6]) & 0x7fff;
1672 input_report_abs(input, ABS_MT_POSITION_X, x);
1673 input_report_abs(input, ABS_MT_POSITION_Y, y);
1676 input_mt_sync_frame(input);
1678 /* keep touch state for pen event */
1679 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1684 static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
1686 unsigned char *data = wacom->data;
1687 struct input_dev *input = wacom->touch_input;
1688 bool prox = report_touch_events(wacom);
1691 if (wacom->features.touch_max > 1 || len > WACOM_PKGLEN_TPC2FG)
1694 if (len == WACOM_PKGLEN_TPC1FG) {
1695 prox = prox && (data[0] & 0x01);
1696 x = get_unaligned_le16(&data[1]);
1697 y = get_unaligned_le16(&data[3]);
1698 } else if (len == WACOM_PKGLEN_TPC1FG_B) {
1699 prox = prox && (data[2] & 0x01);
1700 x = get_unaligned_le16(&data[3]);
1701 y = get_unaligned_le16(&data[5]);
1703 prox = prox && (data[1] & 0x01);
1704 x = le16_to_cpup((__le16 *)&data[2]);
1705 y = le16_to_cpup((__le16 *)&data[4]);
1709 input_report_abs(input, ABS_X, x);
1710 input_report_abs(input, ABS_Y, y);
1712 input_report_key(input, BTN_TOUCH, prox);
1714 /* keep touch state for pen events */
1715 wacom->shared->touch_down = prox;
1720 static int wacom_tpc_pen(struct wacom_wac *wacom)
1722 unsigned char *data = wacom->data;
1723 struct input_dev *input = wacom->pen_input;
1724 bool prox = data[1] & 0x20;
1726 if (!wacom->shared->stylus_in_proximity) /* first in prox */
1727 /* Going into proximity select tool */
1728 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
1730 /* keep pen state for touch events */
1731 wacom->shared->stylus_in_proximity = prox;
1733 /* send pen events only when touch is up or forced out
1734 * or touch arbitration is off
1736 if (!delay_pen_events(wacom)) {
1737 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
1738 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
1739 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
1740 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
1741 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x07) << 8) | data[6]);
1742 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
1743 input_report_key(input, wacom->tool[0], prox);
1750 static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
1752 unsigned char *data = wacom->data;
1754 if (wacom->pen_input) {
1755 dev_dbg(wacom->pen_input->dev.parent,
1756 "%s: received report #%d\n", __func__, data[0]);
1758 if (len == WACOM_PKGLEN_PENABLED ||
1759 data[0] == WACOM_REPORT_PENABLED)
1760 return wacom_tpc_pen(wacom);
1762 else if (wacom->touch_input) {
1763 dev_dbg(wacom->touch_input->dev.parent,
1764 "%s: received report #%d\n", __func__, data[0]);
1767 case WACOM_PKGLEN_TPC1FG:
1768 return wacom_tpc_single_touch(wacom, len);
1770 case WACOM_PKGLEN_TPC2FG:
1771 return wacom_tpc_mt_touch(wacom);
1775 case WACOM_REPORT_TPC1FG:
1776 case WACOM_REPORT_TPCHID:
1777 case WACOM_REPORT_TPCST:
1778 case WACOM_REPORT_TPC1FGE:
1779 return wacom_tpc_single_touch(wacom, len);
1781 case WACOM_REPORT_TPCMT:
1782 case WACOM_REPORT_TPCMT2:
1783 return wacom_mt_touch(wacom);
1792 static int wacom_offset_rotation(struct input_dev *input, struct hid_usage *usage,
1793 int value, int num, int denom)
1795 struct input_absinfo *abs = &input->absinfo[usage->code];
1796 int range = (abs->maximum - abs->minimum + 1);
1798 value += num*range/denom;
1799 if (value > abs->maximum)
1801 else if (value < abs->minimum)
1806 int wacom_equivalent_usage(int usage)
1808 if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMDIGITIZER) {
1809 int subpage = (usage & 0xFF00) << 8;
1810 int subusage = (usage & 0xFF);
1812 if (subpage == WACOM_HID_SP_PAD ||
1813 subpage == WACOM_HID_SP_BUTTON ||
1814 subpage == WACOM_HID_SP_DIGITIZER ||
1815 subpage == WACOM_HID_SP_DIGITIZERINFO ||
1816 usage == WACOM_HID_WD_SENSE ||
1817 usage == WACOM_HID_WD_SERIALHI ||
1818 usage == WACOM_HID_WD_TOOLTYPE ||
1819 usage == WACOM_HID_WD_DISTANCE ||
1820 usage == WACOM_HID_WD_TOUCHSTRIP ||
1821 usage == WACOM_HID_WD_TOUCHSTRIP2 ||
1822 usage == WACOM_HID_WD_TOUCHRING ||
1823 usage == WACOM_HID_WD_TOUCHRINGSTATUS ||
1824 usage == WACOM_HID_WD_REPORT_VALID) {
1828 if (subpage == HID_UP_UNDEFINED)
1829 subpage = HID_UP_DIGITIZER;
1831 return subpage | subusage;
1834 if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMTOUCH) {
1835 int subpage = (usage & 0xFF00) << 8;
1836 int subusage = (usage & 0xFF);
1838 if (usage == WACOM_HID_WT_REPORT_VALID)
1841 if (subpage == HID_UP_UNDEFINED)
1842 subpage = WACOM_HID_SP_DIGITIZER;
1844 return subpage | subusage;
1850 static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
1851 struct hid_field *field, __u8 type, __u16 code, int fuzz)
1853 struct wacom *wacom = input_get_drvdata(input);
1854 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1855 struct wacom_features *features = &wacom_wac->features;
1856 int fmin = field->logical_minimum;
1857 int fmax = field->logical_maximum;
1858 unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid);
1859 int resolution_code = code;
1861 if (equivalent_usage == HID_DG_TWIST) {
1862 resolution_code = ABS_RZ;
1865 if (equivalent_usage == HID_GD_X) {
1866 fmin += features->offset_left;
1867 fmax -= features->offset_right;
1869 if (equivalent_usage == HID_GD_Y) {
1870 fmin += features->offset_top;
1871 fmax -= features->offset_bottom;
1879 input_set_abs_params(input, code, fmin, fmax, fuzz, 0);
1880 input_abs_set_res(input, code,
1881 hidinput_calc_abs_res(field, resolution_code));
1886 input_set_capability(input, type, code);
1891 static void wacom_wac_battery_usage_mapping(struct hid_device *hdev,
1892 struct hid_field *field, struct hid_usage *usage)
1894 struct wacom *wacom = hid_get_drvdata(hdev);
1895 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1896 struct wacom_features *features = &wacom_wac->features;
1897 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
1899 switch (equivalent_usage) {
1900 case HID_DG_BATTERYSTRENGTH:
1901 case WACOM_HID_WD_BATTERY_LEVEL:
1902 case WACOM_HID_WD_BATTERY_CHARGING:
1903 features->quirks |= WACOM_QUIRK_BATTERY;
1908 static void wacom_wac_battery_event(struct hid_device *hdev, struct hid_field *field,
1909 struct hid_usage *usage, __s32 value)
1911 struct wacom *wacom = hid_get_drvdata(hdev);
1912 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1913 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
1915 switch (equivalent_usage) {
1916 case HID_DG_BATTERYSTRENGTH:
1918 wacom_wac->hid_data.bat_status = POWER_SUPPLY_STATUS_UNKNOWN;
1921 value = value * 100 / (field->logical_maximum - field->logical_minimum);
1922 wacom_wac->hid_data.battery_capacity = value;
1923 wacom_wac->hid_data.bat_connected = 1;
1924 wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
1927 case WACOM_HID_WD_BATTERY_LEVEL:
1928 value = value * 100 / (field->logical_maximum - field->logical_minimum);
1929 wacom_wac->hid_data.battery_capacity = value;
1930 wacom_wac->hid_data.bat_connected = 1;
1931 wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
1933 case WACOM_HID_WD_BATTERY_CHARGING:
1934 wacom_wac->hid_data.bat_charging = value;
1935 wacom_wac->hid_data.ps_connected = value;
1936 wacom_wac->hid_data.bat_connected = 1;
1937 wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
1942 static void wacom_wac_battery_pre_report(struct hid_device *hdev,
1943 struct hid_report *report)
1948 static void wacom_wac_battery_report(struct hid_device *hdev,
1949 struct hid_report *report)
1951 struct wacom *wacom = hid_get_drvdata(hdev);
1952 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1953 struct wacom_features *features = &wacom_wac->features;
1955 if (features->quirks & WACOM_QUIRK_BATTERY) {
1956 int status = wacom_wac->hid_data.bat_status;
1957 int capacity = wacom_wac->hid_data.battery_capacity;
1958 bool charging = wacom_wac->hid_data.bat_charging;
1959 bool connected = wacom_wac->hid_data.bat_connected;
1960 bool powered = wacom_wac->hid_data.ps_connected;
1962 wacom_notify_battery(wacom_wac, status, capacity, charging,
1963 connected, powered);
1967 static void wacom_wac_pad_usage_mapping(struct hid_device *hdev,
1968 struct hid_field *field, struct hid_usage *usage)
1970 struct wacom *wacom = hid_get_drvdata(hdev);
1971 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1972 struct wacom_features *features = &wacom_wac->features;
1973 struct input_dev *input = wacom_wac->pad_input;
1974 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
1976 switch (equivalent_usage) {
1977 case WACOM_HID_WD_ACCELEROMETER_X:
1978 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
1979 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 0);
1980 features->device_type |= WACOM_DEVICETYPE_PAD;
1982 case WACOM_HID_WD_ACCELEROMETER_Y:
1983 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
1984 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 0);
1985 features->device_type |= WACOM_DEVICETYPE_PAD;
1987 case WACOM_HID_WD_ACCELEROMETER_Z:
1988 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
1989 wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0);
1990 features->device_type |= WACOM_DEVICETYPE_PAD;
1992 case WACOM_HID_WD_BUTTONCENTER:
1993 case WACOM_HID_WD_BUTTONHOME:
1994 case WACOM_HID_WD_BUTTONUP:
1995 case WACOM_HID_WD_BUTTONDOWN:
1996 case WACOM_HID_WD_BUTTONLEFT:
1997 case WACOM_HID_WD_BUTTONRIGHT:
1998 wacom_map_usage(input, usage, field, EV_KEY,
1999 wacom_numbered_button_to_key(features->numbered_buttons),
2001 features->numbered_buttons++;
2002 features->device_type |= WACOM_DEVICETYPE_PAD;
2004 case WACOM_HID_WD_MUTE_DEVICE:
2005 /* softkey touch switch */
2006 wacom_wac->is_soft_touch_switch = true;
2008 case WACOM_HID_WD_TOUCHONOFF:
2010 * These two usages, which are used to mute touch events, come
2011 * from the pad packet, but are reported on the touch
2012 * interface. Because the touch interface may not have
2013 * been created yet, we cannot call wacom_map_usage(). In
2014 * order to process the usages when we receive them, we set
2015 * the usage type and code directly.
2017 wacom_wac->has_mute_touch_switch = true;
2018 usage->type = EV_SW;
2019 usage->code = SW_MUTE_DEVICE;
2021 case WACOM_HID_WD_TOUCHSTRIP:
2022 wacom_map_usage(input, usage, field, EV_ABS, ABS_RX, 0);
2023 features->device_type |= WACOM_DEVICETYPE_PAD;
2025 case WACOM_HID_WD_TOUCHSTRIP2:
2026 wacom_map_usage(input, usage, field, EV_ABS, ABS_RY, 0);
2027 features->device_type |= WACOM_DEVICETYPE_PAD;
2029 case WACOM_HID_WD_TOUCHRING:
2030 wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
2031 features->device_type |= WACOM_DEVICETYPE_PAD;
2033 case WACOM_HID_WD_TOUCHRINGSTATUS:
2035 * Only set up type/code association. Completely mapping
2036 * this usage may overwrite the axis resolution and range.
2038 usage->type = EV_ABS;
2039 usage->code = ABS_WHEEL;
2040 set_bit(EV_ABS, input->evbit);
2041 features->device_type |= WACOM_DEVICETYPE_PAD;
2043 case WACOM_HID_WD_BUTTONCONFIG:
2044 wacom_map_usage(input, usage, field, EV_KEY, KEY_BUTTONCONFIG, 0);
2045 features->device_type |= WACOM_DEVICETYPE_PAD;
2047 case WACOM_HID_WD_ONSCREEN_KEYBOARD:
2048 wacom_map_usage(input, usage, field, EV_KEY, KEY_ONSCREEN_KEYBOARD, 0);
2049 features->device_type |= WACOM_DEVICETYPE_PAD;
2051 case WACOM_HID_WD_CONTROLPANEL:
2052 wacom_map_usage(input, usage, field, EV_KEY, KEY_CONTROLPANEL, 0);
2053 features->device_type |= WACOM_DEVICETYPE_PAD;
2055 case WACOM_HID_WD_MODE_CHANGE:
2056 /* do not overwrite previous data */
2057 if (!wacom_wac->has_mode_change) {
2058 wacom_wac->has_mode_change = true;
2059 wacom_wac->is_direct_mode = true;
2061 features->device_type |= WACOM_DEVICETYPE_PAD;
2065 switch (equivalent_usage & 0xfffffff0) {
2066 case WACOM_HID_WD_EXPRESSKEY00:
2067 wacom_map_usage(input, usage, field, EV_KEY,
2068 wacom_numbered_button_to_key(features->numbered_buttons),
2070 features->numbered_buttons++;
2071 features->device_type |= WACOM_DEVICETYPE_PAD;
2076 static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field,
2077 struct hid_usage *usage, __s32 value)
2079 struct wacom *wacom = hid_get_drvdata(hdev);
2080 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2081 struct input_dev *input = wacom_wac->pad_input;
2082 struct wacom_features *features = &wacom_wac->features;
2083 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2085 bool do_report = false;
2088 * Avoid reporting this event and setting inrange_state if this usage
2089 * hasn't been mapped.
2091 if (!usage->type && equivalent_usage != WACOM_HID_WD_MODE_CHANGE)
2094 if (wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY) {
2095 if (usage->hid != WACOM_HID_WD_TOUCHRING)
2096 wacom_wac->hid_data.inrange_state |= value;
2099 /* Process touch switch state first since it is reported through touch interface,
2100 * which is indepentent of pad interface. In the case when there are no other pad
2101 * events, the pad interface will not even be created.
2103 if ((equivalent_usage == WACOM_HID_WD_MUTE_DEVICE) ||
2104 (equivalent_usage == WACOM_HID_WD_TOUCHONOFF)) {
2105 if (wacom_wac->shared->touch_input) {
2106 bool *is_touch_on = &wacom_wac->shared->is_touch_on;
2108 if (equivalent_usage == WACOM_HID_WD_MUTE_DEVICE && value)
2109 *is_touch_on = !(*is_touch_on);
2110 else if (equivalent_usage == WACOM_HID_WD_TOUCHONOFF)
2111 *is_touch_on = value;
2113 input_report_switch(wacom_wac->shared->touch_input,
2114 SW_MUTE_DEVICE, !(*is_touch_on));
2115 input_sync(wacom_wac->shared->touch_input);
2123 switch (equivalent_usage) {
2124 case WACOM_HID_WD_TOUCHRING:
2126 * Userspace expects touchrings to increase in value with
2127 * clockwise gestures and have their zero point at the
2128 * tablet's left. HID events "should" be clockwise-
2129 * increasing and zero at top, though the MobileStudio
2130 * Pro and 2nd-gen Intuos Pro don't do this...
2132 if (hdev->vendor == 0x56a &&
2133 (hdev->product == 0x34d || hdev->product == 0x34e || /* MobileStudio Pro */
2134 hdev->product == 0x357 || hdev->product == 0x358 || /* Intuos Pro 2 */
2135 hdev->product == 0x392 || /* Intuos Pro 2 */
2136 hdev->product == 0x398 || hdev->product == 0x399 || /* MobileStudio Pro */
2137 hdev->product == 0x3AA)) { /* MobileStudio Pro */
2138 value = (field->logical_maximum - value);
2140 if (hdev->product == 0x357 || hdev->product == 0x358 ||
2141 hdev->product == 0x392)
2142 value = wacom_offset_rotation(input, usage, value, 3, 16);
2143 else if (hdev->product == 0x34d || hdev->product == 0x34e ||
2144 hdev->product == 0x398 || hdev->product == 0x399 ||
2145 hdev->product == 0x3AA)
2146 value = wacom_offset_rotation(input, usage, value, 1, 2);
2149 value = wacom_offset_rotation(input, usage, value, 1, 4);
2153 case WACOM_HID_WD_TOUCHRINGSTATUS:
2155 input_event(input, usage->type, usage->code, 0);
2158 case WACOM_HID_WD_MODE_CHANGE:
2159 if (wacom_wac->is_direct_mode != value) {
2160 wacom_wac->is_direct_mode = value;
2161 wacom_schedule_work(&wacom->wacom_wac, WACOM_WORKER_MODE_CHANGE);
2165 case WACOM_HID_WD_BUTTONCENTER:
2166 for (i = 0; i < wacom->led.count; i++)
2167 wacom_update_led(wacom, features->numbered_buttons,
2176 input_event(input, usage->type, usage->code, value);
2178 wacom_wac->hid_data.pad_input_event_flag = true;
2182 static void wacom_wac_pad_pre_report(struct hid_device *hdev,
2183 struct hid_report *report)
2185 struct wacom *wacom = hid_get_drvdata(hdev);
2186 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2188 wacom_wac->hid_data.inrange_state = 0;
2191 static void wacom_wac_pad_report(struct hid_device *hdev,
2192 struct hid_report *report, struct hid_field *field)
2194 struct wacom *wacom = hid_get_drvdata(hdev);
2195 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2196 struct input_dev *input = wacom_wac->pad_input;
2197 bool active = wacom_wac->hid_data.inrange_state != 0;
2199 /* report prox for expresskey events */
2200 if (wacom_wac->hid_data.pad_input_event_flag) {
2201 input_event(input, EV_ABS, ABS_MISC, active ? PAD_DEVICE_ID : 0);
2204 wacom_wac->hid_data.pad_input_event_flag = false;
2208 static void wacom_set_barrel_switch3_usage(struct wacom_wac *wacom_wac)
2210 struct input_dev *input = wacom_wac->pen_input;
2211 struct wacom_features *features = &wacom_wac->features;
2213 if (!(features->quirks & WACOM_QUIRK_AESPEN) &&
2214 wacom_wac->hid_data.barrelswitch &&
2215 wacom_wac->hid_data.barrelswitch2 &&
2216 wacom_wac->hid_data.serialhi)
2217 input_set_capability(input, EV_KEY, BTN_STYLUS3);
2220 static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
2221 struct hid_field *field, struct hid_usage *usage)
2223 struct wacom *wacom = hid_get_drvdata(hdev);
2224 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2225 struct wacom_features *features = &wacom_wac->features;
2226 struct input_dev *input = wacom_wac->pen_input;
2227 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2229 switch (equivalent_usage) {
2231 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
2234 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
2236 case WACOM_HID_WD_DISTANCE:
2238 wacom_map_usage(input, usage, field, EV_ABS, ABS_DISTANCE, 0);
2240 case HID_DG_TIPPRESSURE:
2241 wacom_map_usage(input, usage, field, EV_ABS, ABS_PRESSURE, 0);
2243 case HID_DG_INRANGE:
2244 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
2247 wacom_map_usage(input, usage, field, EV_KEY,
2248 BTN_TOOL_RUBBER, 0);
2251 wacom_map_usage(input, usage, field, EV_ABS, ABS_TILT_X, 0);
2254 wacom_map_usage(input, usage, field, EV_ABS, ABS_TILT_Y, 0);
2257 wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0);
2260 input_set_capability(input, EV_KEY, BTN_TOOL_RUBBER);
2261 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
2263 case HID_DG_TIPSWITCH:
2264 input_set_capability(input, EV_KEY, BTN_TOOL_PEN);
2265 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
2267 case HID_DG_BARRELSWITCH:
2268 wacom_wac->hid_data.barrelswitch = true;
2269 wacom_set_barrel_switch3_usage(wacom_wac);
2270 wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS, 0);
2272 case HID_DG_BARRELSWITCH2:
2273 wacom_wac->hid_data.barrelswitch2 = true;
2274 wacom_set_barrel_switch3_usage(wacom_wac);
2275 wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS2, 0);
2277 case HID_DG_TOOLSERIALNUMBER:
2278 features->quirks |= WACOM_QUIRK_TOOLSERIAL;
2279 wacom_map_usage(input, usage, field, EV_MSC, MSC_SERIAL, 0);
2281 case WACOM_HID_WD_SENSE:
2282 features->quirks |= WACOM_QUIRK_SENSE;
2283 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
2285 case WACOM_HID_WD_SERIALHI:
2286 wacom_wac->hid_data.serialhi = true;
2287 wacom_set_barrel_switch3_usage(wacom_wac);
2288 wacom_map_usage(input, usage, field, EV_ABS, ABS_MISC, 0);
2290 case WACOM_HID_WD_FINGERWHEEL:
2291 input_set_capability(input, EV_KEY, BTN_TOOL_AIRBRUSH);
2292 wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
2297 static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field,
2298 struct hid_usage *usage, __s32 value)
2300 struct wacom *wacom = hid_get_drvdata(hdev);
2301 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2302 struct wacom_features *features = &wacom_wac->features;
2303 struct input_dev *input = wacom_wac->pen_input;
2304 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2306 if (wacom_wac->is_invalid_bt_frame)
2309 switch (equivalent_usage) {
2312 * HID_GD_Z "should increase as the control's position is
2313 * moved from high to low", while ABS_DISTANCE instead
2314 * increases in value as the tool moves from low to high.
2316 value = field->logical_maximum - value;
2318 case HID_DG_INRANGE:
2319 wacom_wac->hid_data.inrange_state = value;
2320 if (!(features->quirks & WACOM_QUIRK_SENSE))
2321 wacom_wac->hid_data.sense_state = value;
2324 wacom_wac->hid_data.invert_state = value;
2327 case HID_DG_TIPSWITCH:
2328 wacom_wac->hid_data.tipswitch |= value;
2330 case HID_DG_BARRELSWITCH:
2331 wacom_wac->hid_data.barrelswitch = value;
2333 case HID_DG_BARRELSWITCH2:
2334 wacom_wac->hid_data.barrelswitch2 = value;
2336 case HID_DG_TOOLSERIALNUMBER:
2338 wacom_wac->serial[0] = (wacom_wac->serial[0] & ~0xFFFFFFFFULL);
2339 wacom_wac->serial[0] |= wacom_s32tou(value, field->report_size);
2343 /* don't modify the value if the pen doesn't support the feature */
2344 if (!wacom_is_art_pen(wacom_wac->id[0])) return;
2347 * Userspace expects pen twist to have its zero point when
2348 * the buttons/finger is on the tablet's left. HID values
2349 * are zero when buttons are toward the top.
2351 value = wacom_offset_rotation(input, usage, value, 1, 4);
2353 case WACOM_HID_WD_SENSE:
2354 wacom_wac->hid_data.sense_state = value;
2356 case WACOM_HID_WD_SERIALHI:
2358 __u32 raw_value = wacom_s32tou(value, field->report_size);
2360 wacom_wac->serial[0] = (wacom_wac->serial[0] & 0xFFFFFFFF);
2361 wacom_wac->serial[0] |= ((__u64)raw_value) << 32;
2363 * Non-USI EMR devices may contain additional tool type
2364 * information here. See WACOM_HID_WD_TOOLTYPE case for
2367 if (value >> 20 == 1) {
2368 wacom_wac->id[0] |= raw_value & 0xFFFFF;
2372 case WACOM_HID_WD_TOOLTYPE:
2374 * Some devices (MobileStudio Pro, and possibly later
2375 * devices as well) do not return the complete tool
2376 * type in their WACOM_HID_WD_TOOLTYPE usage. Use a
2377 * bitwise OR so the complete value can be built
2380 wacom_wac->id[0] |= wacom_s32tou(value, field->report_size);
2382 case WACOM_HID_WD_OFFSETLEFT:
2383 if (features->offset_left && value != features->offset_left)
2384 hid_warn(hdev, "%s: overriding existing left offset "
2385 "%d -> %d\n", __func__, value,
2386 features->offset_left);
2387 features->offset_left = value;
2389 case WACOM_HID_WD_OFFSETRIGHT:
2390 if (features->offset_right && value != features->offset_right)
2391 hid_warn(hdev, "%s: overriding existing right offset "
2392 "%d -> %d\n", __func__, value,
2393 features->offset_right);
2394 features->offset_right = value;
2396 case WACOM_HID_WD_OFFSETTOP:
2397 if (features->offset_top && value != features->offset_top)
2398 hid_warn(hdev, "%s: overriding existing top offset "
2399 "%d -> %d\n", __func__, value,
2400 features->offset_top);
2401 features->offset_top = value;
2403 case WACOM_HID_WD_OFFSETBOTTOM:
2404 if (features->offset_bottom && value != features->offset_bottom)
2405 hid_warn(hdev, "%s: overriding existing bottom offset "
2406 "%d -> %d\n", __func__, value,
2407 features->offset_bottom);
2408 features->offset_bottom = value;
2410 case WACOM_HID_WD_REPORT_VALID:
2411 wacom_wac->is_invalid_bt_frame = !value;
2415 /* send pen events only when touch is up or forced out
2416 * or touch arbitration is off
2418 if (!usage->type || delay_pen_events(wacom_wac))
2421 /* send pen events only when the pen is in range */
2422 if (wacom_wac->hid_data.inrange_state)
2423 input_event(input, usage->type, usage->code, value);
2424 else if (wacom_wac->shared->stylus_in_proximity && !wacom_wac->hid_data.sense_state)
2425 input_event(input, usage->type, usage->code, 0);
2428 static void wacom_wac_pen_pre_report(struct hid_device *hdev,
2429 struct hid_report *report)
2431 struct wacom *wacom = hid_get_drvdata(hdev);
2432 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2434 wacom_wac->is_invalid_bt_frame = false;
2438 static void wacom_wac_pen_report(struct hid_device *hdev,
2439 struct hid_report *report)
2441 struct wacom *wacom = hid_get_drvdata(hdev);
2442 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2443 struct input_dev *input = wacom_wac->pen_input;
2444 bool range = wacom_wac->hid_data.inrange_state;
2445 bool sense = wacom_wac->hid_data.sense_state;
2447 if (wacom_wac->is_invalid_bt_frame)
2450 if (!wacom_wac->tool[0] && range) { /* first in range */
2451 /* Going into range select tool */
2452 if (wacom_wac->hid_data.invert_state)
2453 wacom_wac->tool[0] = BTN_TOOL_RUBBER;
2454 else if (wacom_wac->id[0])
2455 wacom_wac->tool[0] = wacom_intuos_get_tool_type(wacom_wac->id[0]);
2457 wacom_wac->tool[0] = BTN_TOOL_PEN;
2460 /* keep pen state for touch events */
2461 wacom_wac->shared->stylus_in_proximity = sense;
2463 if (!delay_pen_events(wacom_wac) && wacom_wac->tool[0]) {
2464 int id = wacom_wac->id[0];
2465 int sw_state = wacom_wac->hid_data.barrelswitch |
2466 (wacom_wac->hid_data.barrelswitch2 << 1);
2468 input_report_key(input, BTN_STYLUS, sw_state == 1);
2469 input_report_key(input, BTN_STYLUS2, sw_state == 2);
2470 input_report_key(input, BTN_STYLUS3, sw_state == 3);
2473 * Non-USI EMR tools should have their IDs mangled to
2474 * match the legacy behavior of wacom_intuos_general
2476 if (wacom_wac->serial[0] >> 52 == 1)
2477 id = wacom_intuos_id_mangle(id);
2480 * To ensure compatibility with xf86-input-wacom, we should
2481 * report the BTN_TOOL_* event prior to the ABS_MISC or
2482 * MSC_SERIAL events.
2484 input_report_key(input, BTN_TOUCH,
2485 wacom_wac->hid_data.tipswitch);
2486 input_report_key(input, wacom_wac->tool[0], sense);
2487 if (wacom_wac->serial[0]) {
2488 input_event(input, EV_MSC, MSC_SERIAL, wacom_wac->serial[0]);
2489 input_report_abs(input, ABS_MISC, sense ? id : 0);
2492 wacom_wac->hid_data.tipswitch = false;
2498 wacom_wac->tool[0] = 0;
2499 wacom_wac->id[0] = 0;
2500 wacom_wac->serial[0] = 0;
2504 static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
2505 struct hid_field *field, struct hid_usage *usage)
2507 struct wacom *wacom = hid_get_drvdata(hdev);
2508 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2509 struct input_dev *input = wacom_wac->touch_input;
2510 unsigned touch_max = wacom_wac->features.touch_max;
2511 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2513 switch (equivalent_usage) {
2516 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
2518 wacom_map_usage(input, usage, field, EV_ABS,
2519 ABS_MT_POSITION_X, 4);
2523 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
2525 wacom_map_usage(input, usage, field, EV_ABS,
2526 ABS_MT_POSITION_Y, 4);
2530 wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MAJOR, 0);
2531 wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MINOR, 0);
2532 input_set_abs_params(input, ABS_MT_ORIENTATION, 0, 1, 0, 0);
2534 case HID_DG_TIPSWITCH:
2535 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
2537 case HID_DG_CONTACTCOUNT:
2538 wacom_wac->hid_data.cc_report = field->report->id;
2539 wacom_wac->hid_data.cc_index = field->index;
2540 wacom_wac->hid_data.cc_value_index = usage->usage_index;
2542 case HID_DG_CONTACTID:
2543 if ((field->logical_maximum - field->logical_minimum) < touch_max) {
2545 * The HID descriptor for G11 sensors leaves logical
2546 * maximum set to '1' despite it being a multitouch
2547 * device. Override to a sensible number.
2549 field->logical_maximum = 255;
2555 static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
2556 struct input_dev *input)
2558 struct hid_data *hid_data = &wacom_wac->hid_data;
2559 bool mt = wacom_wac->features.touch_max > 1;
2560 bool prox = hid_data->tipswitch &&
2561 report_touch_events(wacom_wac);
2563 if (touch_is_muted(wacom_wac)) {
2564 if (!wacom_wac->shared->touch_down)
2569 wacom_wac->hid_data.num_received++;
2570 if (wacom_wac->hid_data.num_received > wacom_wac->hid_data.num_expected)
2576 slot = input_mt_get_slot_by_key(input, hid_data->id);
2580 struct input_mt_slot *ps = &input->mt->slots[slot];
2581 int mt_id = input_mt_get_value(ps, ABS_MT_TRACKING_ID);
2583 if (!prox && mt_id < 0) {
2584 // No data to send for this slot; short-circuit
2589 input_mt_slot(input, slot);
2590 input_mt_report_slot_state(input, MT_TOOL_FINGER, prox);
2593 input_report_key(input, BTN_TOUCH, prox);
2597 input_report_abs(input, mt ? ABS_MT_POSITION_X : ABS_X,
2599 input_report_abs(input, mt ? ABS_MT_POSITION_Y : ABS_Y,
2602 if (test_bit(ABS_MT_TOUCH_MAJOR, input->absbit)) {
2603 input_report_abs(input, ABS_MT_TOUCH_MAJOR, max(hid_data->width, hid_data->height));
2604 input_report_abs(input, ABS_MT_TOUCH_MINOR, min(hid_data->width, hid_data->height));
2605 if (hid_data->width != hid_data->height)
2606 input_report_abs(input, ABS_MT_ORIENTATION, hid_data->width <= hid_data->height ? 0 : 1);
2611 static bool wacom_wac_slot_is_active(struct input_dev *dev, int key)
2613 struct input_mt *mt = dev->mt;
2614 struct input_mt_slot *s;
2619 for (s = mt->slots; s != mt->slots + mt->num_slots; s++) {
2620 if (s->key == key &&
2621 input_mt_get_value(s, ABS_MT_TRACKING_ID) >= 0) {
2629 static void wacom_wac_finger_event(struct hid_device *hdev,
2630 struct hid_field *field, struct hid_usage *usage, __s32 value)
2632 struct wacom *wacom = hid_get_drvdata(hdev);
2633 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2634 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2635 struct wacom_features *features = &wacom->wacom_wac.features;
2637 if (touch_is_muted(wacom_wac) && !wacom_wac->shared->touch_down)
2640 if (wacom_wac->is_invalid_bt_frame)
2643 switch (equivalent_usage) {
2644 case HID_DG_CONFIDENCE:
2645 wacom_wac->hid_data.confidence = value;
2648 wacom_wac->hid_data.x = value;
2651 wacom_wac->hid_data.y = value;
2654 wacom_wac->hid_data.width = value;
2657 wacom_wac->hid_data.height = value;
2659 case HID_DG_CONTACTID:
2660 wacom_wac->hid_data.id = value;
2662 case HID_DG_TIPSWITCH:
2663 wacom_wac->hid_data.tipswitch = value;
2665 case WACOM_HID_WT_REPORT_VALID:
2666 wacom_wac->is_invalid_bt_frame = !value;
2668 case HID_DG_CONTACTMAX:
2669 if (!features->touch_max) {
2670 features->touch_max = value;
2672 hid_warn(hdev, "%s: ignoring attempt to overwrite non-zero touch_max "
2673 "%d -> %d\n", __func__, features->touch_max, value);
2678 if (usage->usage_index + 1 == field->report_count) {
2679 if (equivalent_usage == wacom_wac->hid_data.last_slot_field) {
2680 bool touch_removed = wacom_wac_slot_is_active(wacom_wac->touch_input,
2681 wacom_wac->hid_data.id) && !wacom_wac->hid_data.tipswitch;
2683 if (wacom_wac->hid_data.confidence || touch_removed) {
2684 wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
2690 static void wacom_wac_finger_pre_report(struct hid_device *hdev,
2691 struct hid_report *report)
2693 struct wacom *wacom = hid_get_drvdata(hdev);
2694 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2695 struct hid_data* hid_data = &wacom_wac->hid_data;
2698 if (touch_is_muted(wacom_wac) && !wacom_wac->shared->touch_down)
2701 wacom_wac->is_invalid_bt_frame = false;
2703 hid_data->confidence = true;
2705 hid_data->cc_report = 0;
2706 hid_data->cc_index = -1;
2707 hid_data->cc_value_index = -1;
2709 for (i = 0; i < report->maxfield; i++) {
2710 struct hid_field *field = report->field[i];
2713 for (j = 0; j < field->maxusage; j++) {
2714 struct hid_usage *usage = &field->usage[j];
2715 unsigned int equivalent_usage =
2716 wacom_equivalent_usage(usage->hid);
2718 switch (equivalent_usage) {
2723 case HID_DG_CONTACTID:
2724 case HID_DG_INRANGE:
2726 case HID_DG_TIPSWITCH:
2727 hid_data->last_slot_field = equivalent_usage;
2729 case HID_DG_CONTACTCOUNT:
2730 hid_data->cc_report = report->id;
2731 hid_data->cc_index = i;
2732 hid_data->cc_value_index = j;
2738 if (hid_data->cc_report != 0 &&
2739 hid_data->cc_index >= 0) {
2740 struct hid_field *field = report->field[hid_data->cc_index];
2741 int value = field->value[hid_data->cc_value_index];
2743 hid_data->num_expected = value;
2744 hid_data->num_received = 0;
2748 hid_data->num_expected = wacom_wac->features.touch_max;
2749 hid_data->num_received = 0;
2753 static void wacom_wac_finger_report(struct hid_device *hdev,
2754 struct hid_report *report)
2756 struct wacom *wacom = hid_get_drvdata(hdev);
2757 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2758 struct input_dev *input = wacom_wac->touch_input;
2759 unsigned touch_max = wacom_wac->features.touch_max;
2761 /* if there was nothing to process, don't send an empty sync */
2762 if (wacom_wac->hid_data.num_expected == 0)
2765 /* If more packets of data are expected, give us a chance to
2766 * process them rather than immediately syncing a partial
2769 if (wacom_wac->hid_data.num_received < wacom_wac->hid_data.num_expected)
2773 input_mt_sync_frame(input);
2776 wacom_wac->hid_data.num_received = 0;
2777 wacom_wac->hid_data.num_expected = 0;
2779 /* keep touch state for pen event */
2780 wacom_wac->shared->touch_down = wacom_wac_finger_count_touches(wacom_wac);
2783 void wacom_wac_usage_mapping(struct hid_device *hdev,
2784 struct hid_field *field, struct hid_usage *usage)
2786 struct wacom *wacom = hid_get_drvdata(hdev);
2787 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2788 struct wacom_features *features = &wacom_wac->features;
2790 if (WACOM_DIRECT_DEVICE(field))
2791 features->device_type |= WACOM_DEVICETYPE_DIRECT;
2793 /* usage tests must precede field tests */
2794 if (WACOM_BATTERY_USAGE(usage))
2795 wacom_wac_battery_usage_mapping(hdev, field, usage);
2796 else if (WACOM_PAD_FIELD(field))
2797 wacom_wac_pad_usage_mapping(hdev, field, usage);
2798 else if (WACOM_PEN_FIELD(field))
2799 wacom_wac_pen_usage_mapping(hdev, field, usage);
2800 else if (WACOM_FINGER_FIELD(field))
2801 wacom_wac_finger_usage_mapping(hdev, field, usage);
2804 void wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
2805 struct hid_usage *usage, __s32 value)
2807 struct wacom *wacom = hid_get_drvdata(hdev);
2809 if (wacom->wacom_wac.features.type != HID_GENERIC)
2812 if (value > field->logical_maximum || value < field->logical_minimum)
2815 /* usage tests must precede field tests */
2816 if (WACOM_BATTERY_USAGE(usage))
2817 wacom_wac_battery_event(hdev, field, usage, value);
2818 else if (WACOM_PAD_FIELD(field))
2819 wacom_wac_pad_event(hdev, field, usage, value);
2820 else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
2821 wacom_wac_pen_event(hdev, field, usage, value);
2822 else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
2823 wacom_wac_finger_event(hdev, field, usage, value);
2826 static void wacom_report_events(struct hid_device *hdev,
2827 struct hid_report *report, int collection_index,
2832 for (r = field_index; r < report->maxfield; r++) {
2833 struct hid_field *field;
2836 field = report->field[r];
2837 count = field->report_count;
2839 if (!(HID_MAIN_ITEM_VARIABLE & field->flags))
2842 for (n = 0 ; n < count; n++) {
2843 if (field->usage[n].collection_index == collection_index)
2844 wacom_wac_event(hdev, field, &field->usage[n],
2852 static int wacom_wac_collection(struct hid_device *hdev, struct hid_report *report,
2853 int collection_index, struct hid_field *field,
2856 struct wacom *wacom = hid_get_drvdata(hdev);
2858 wacom_report_events(hdev, report, collection_index, field_index);
2861 * Non-input reports may be sent prior to the device being
2862 * completely initialized. Since only their events need
2863 * to be processed, exit after 'wacom_report_events' has
2864 * been called to prevent potential crashes in the report-
2865 * processing functions.
2867 if (report->type != HID_INPUT_REPORT)
2870 if (WACOM_PAD_FIELD(field))
2872 else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
2873 wacom_wac_pen_report(hdev, report);
2874 else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
2875 wacom_wac_finger_report(hdev, report);
2880 void wacom_wac_report(struct hid_device *hdev, struct hid_report *report)
2882 struct wacom *wacom = hid_get_drvdata(hdev);
2883 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2884 struct hid_field *field;
2885 bool pad_in_hid_field = false, pen_in_hid_field = false,
2886 finger_in_hid_field = false, true_pad = false;
2888 int prev_collection = -1;
2890 if (wacom_wac->features.type != HID_GENERIC)
2893 for (r = 0; r < report->maxfield; r++) {
2894 field = report->field[r];
2896 if (WACOM_PAD_FIELD(field))
2897 pad_in_hid_field = true;
2898 if (WACOM_PEN_FIELD(field))
2899 pen_in_hid_field = true;
2900 if (WACOM_FINGER_FIELD(field))
2901 finger_in_hid_field = true;
2902 if (wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY)
2906 wacom_wac_battery_pre_report(hdev, report);
2908 if (pad_in_hid_field && wacom->wacom_wac.pad_input)
2909 wacom_wac_pad_pre_report(hdev, report);
2910 if (pen_in_hid_field && wacom->wacom_wac.pen_input)
2911 wacom_wac_pen_pre_report(hdev, report);
2912 if (finger_in_hid_field && wacom->wacom_wac.touch_input)
2913 wacom_wac_finger_pre_report(hdev, report);
2915 for (r = 0; r < report->maxfield; r++) {
2916 field = report->field[r];
2918 if (field->usage[0].collection_index != prev_collection) {
2919 if (wacom_wac_collection(hdev, report,
2920 field->usage[0].collection_index, field, r) < 0)
2922 prev_collection = field->usage[0].collection_index;
2926 wacom_wac_battery_report(hdev, report);
2928 if (true_pad && wacom->wacom_wac.pad_input)
2929 wacom_wac_pad_report(hdev, report, field);
2932 static int wacom_bpt_touch(struct wacom_wac *wacom)
2934 struct wacom_features *features = &wacom->features;
2935 struct input_dev *input = wacom->touch_input;
2936 struct input_dev *pad_input = wacom->pad_input;
2937 unsigned char *data = wacom->data;
2940 if (data[0] != 0x02)
2943 for (i = 0; i < 2; i++) {
2944 int offset = (data[1] & 0x80) ? (8 * i) : (9 * i);
2945 bool touch = report_touch_events(wacom)
2946 && (data[offset + 3] & 0x80);
2948 input_mt_slot(input, i);
2949 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
2951 int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff;
2952 int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff;
2953 if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) {
2957 input_report_abs(input, ABS_MT_POSITION_X, x);
2958 input_report_abs(input, ABS_MT_POSITION_Y, y);
2962 input_mt_sync_frame(input);
2964 input_report_key(pad_input, BTN_LEFT, (data[1] & 0x08) != 0);
2965 input_report_key(pad_input, BTN_FORWARD, (data[1] & 0x04) != 0);
2966 input_report_key(pad_input, BTN_BACK, (data[1] & 0x02) != 0);
2967 input_report_key(pad_input, BTN_RIGHT, (data[1] & 0x01) != 0);
2968 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
2973 static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
2975 struct wacom_features *features = &wacom->features;
2976 struct input_dev *input = wacom->touch_input;
2977 bool touch = data[1] & 0x80;
2978 int slot = input_mt_get_slot_by_key(input, data[0]);
2983 touch = touch && report_touch_events(wacom);
2985 input_mt_slot(input, slot);
2986 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
2989 int x = (data[2] << 4) | (data[4] >> 4);
2990 int y = (data[3] << 4) | (data[4] & 0x0f);
2993 if (features->type >= INTUOSPS && features->type <= INTUOSHT2) {
2994 width = data[5] * 100;
2995 height = data[6] * 100;
2998 * "a" is a scaled-down area which we assume is
2999 * roughly circular and which can be described as:
3003 int x_res = input_abs_get_res(input, ABS_MT_POSITION_X);
3004 int y_res = input_abs_get_res(input, ABS_MT_POSITION_Y);
3005 width = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE);
3006 height = width * y_res / x_res;
3009 input_report_abs(input, ABS_MT_POSITION_X, x);
3010 input_report_abs(input, ABS_MT_POSITION_Y, y);
3011 input_report_abs(input, ABS_MT_TOUCH_MAJOR, width);
3012 input_report_abs(input, ABS_MT_TOUCH_MINOR, height);
3016 static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
3018 struct input_dev *input = wacom->pad_input;
3019 struct wacom_features *features = &wacom->features;
3021 if (features->type == INTUOSHT || features->type == INTUOSHT2) {
3022 input_report_key(input, BTN_LEFT, (data[1] & 0x02) != 0);
3023 input_report_key(input, BTN_BACK, (data[1] & 0x08) != 0);
3025 input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
3026 input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
3028 input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
3029 input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
3032 static int wacom_bpt3_touch(struct wacom_wac *wacom)
3034 unsigned char *data = wacom->data;
3035 int count = data[1] & 0x07;
3036 int touch_changed = 0, i;
3038 if (data[0] != 0x02)
3041 /* data has up to 7 fixed sized 8-byte messages starting at data[2] */
3042 for (i = 0; i < count; i++) {
3043 int offset = (8 * i) + 2;
3044 int msg_id = data[offset];
3046 if (msg_id >= 2 && msg_id <= 17) {
3047 wacom_bpt3_touch_msg(wacom, data + offset);
3049 } else if (msg_id == 128)
3050 wacom_bpt3_button_msg(wacom, data + offset);
3054 /* only update touch if we actually have a touchpad and touch data changed */
3055 if (wacom->touch_input && touch_changed) {
3056 input_mt_sync_frame(wacom->touch_input);
3057 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
3063 static int wacom_bpt_pen(struct wacom_wac *wacom)
3065 struct wacom_features *features = &wacom->features;
3066 struct input_dev *input = wacom->pen_input;
3067 unsigned char *data = wacom->data;
3068 int x = 0, y = 0, p = 0, d = 0;
3069 bool pen = false, btn1 = false, btn2 = false;
3070 bool range, prox, rdy;
3072 if (data[0] != WACOM_REPORT_PENABLED)
3075 range = (data[1] & 0x80) == 0x80;
3076 prox = (data[1] & 0x40) == 0x40;
3077 rdy = (data[1] & 0x20) == 0x20;
3079 wacom->shared->stylus_in_proximity = range;
3080 if (delay_pen_events(wacom))
3084 p = le16_to_cpup((__le16 *)&data[6]);
3085 pen = data[1] & 0x01;
3086 btn1 = data[1] & 0x02;
3087 btn2 = data[1] & 0x04;
3090 x = le16_to_cpup((__le16 *)&data[2]);
3091 y = le16_to_cpup((__le16 *)&data[4]);
3093 if (data[1] & 0x08) {
3094 wacom->tool[0] = BTN_TOOL_RUBBER;
3095 wacom->id[0] = ERASER_DEVICE_ID;
3097 wacom->tool[0] = BTN_TOOL_PEN;
3098 wacom->id[0] = STYLUS_DEVICE_ID;
3100 wacom->reporting_data = true;
3104 * Convert distance from out prox to distance from tablet.
3105 * distance will be greater than distance_max once
3106 * touching and applying pressure; do not report negative
3109 if (data[8] <= features->distance_max)
3110 d = features->distance_max - data[8];
3115 if (wacom->reporting_data) {
3116 input_report_key(input, BTN_TOUCH, pen);
3117 input_report_key(input, BTN_STYLUS, btn1);
3118 input_report_key(input, BTN_STYLUS2, btn2);
3120 if (prox || !range) {
3121 input_report_abs(input, ABS_X, x);
3122 input_report_abs(input, ABS_Y, y);
3124 input_report_abs(input, ABS_PRESSURE, p);
3125 input_report_abs(input, ABS_DISTANCE, d);
3127 input_report_key(input, wacom->tool[0], range); /* PEN or RUBBER */
3128 input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
3132 wacom->reporting_data = false;
3138 static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
3140 struct wacom_features *features = &wacom->features;
3142 if ((features->type == INTUOSHT2) &&
3143 (features->device_type & WACOM_DEVICETYPE_PEN))
3144 return wacom_intuos_irq(wacom);
3145 else if (len == WACOM_PKGLEN_BBTOUCH)
3146 return wacom_bpt_touch(wacom);
3147 else if (len == WACOM_PKGLEN_BBTOUCH3)
3148 return wacom_bpt3_touch(wacom);
3149 else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
3150 return wacom_bpt_pen(wacom);
3155 static void wacom_bamboo_pad_pen_event(struct wacom_wac *wacom,
3156 unsigned char *data)
3158 unsigned char prefix;
3161 * We need to reroute the event from the debug interface to the
3163 * We need to add the report ID to the actual pen report, so we
3164 * temporary overwrite the first byte to prevent having to kzalloc/kfree
3165 * and memcpy the report.
3168 data[0] = WACOM_REPORT_BPAD_PEN;
3171 * actually reroute the event.
3172 * No need to check if wacom->shared->pen is valid, hid_input_report()
3173 * will check for us.
3175 hid_input_report(wacom->shared->pen, HID_INPUT_REPORT, data,
3176 WACOM_PKGLEN_PENABLED, 1);
3181 static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom,
3182 unsigned char *data)
3184 struct input_dev *input = wacom->touch_input;
3185 unsigned char *finger_data, prefix;
3192 for (id = 0; id < wacom->features.touch_max; id++) {
3193 valid = !!(prefix & BIT(id)) &&
3194 report_touch_events(wacom);
3196 input_mt_slot(input, id);
3197 input_mt_report_slot_state(input, MT_TOOL_FINGER, valid);
3202 finger_data = data + 1 + id * 3;
3203 x = finger_data[0] | ((finger_data[1] & 0x0f) << 8);
3204 y = (finger_data[2] << 4) | (finger_data[1] >> 4);
3206 input_report_abs(input, ABS_MT_POSITION_X, x);
3207 input_report_abs(input, ABS_MT_POSITION_Y, y);
3210 input_mt_sync_frame(input);
3212 input_report_key(input, BTN_LEFT, prefix & 0x40);
3213 input_report_key(input, BTN_RIGHT, prefix & 0x80);
3215 /* keep touch state for pen event */
3216 wacom->shared->touch_down = !!prefix && report_touch_events(wacom);
3221 static int wacom_bamboo_pad_irq(struct wacom_wac *wacom, size_t len)
3223 unsigned char *data = wacom->data;
3225 if (!((len == WACOM_PKGLEN_BPAD_TOUCH) ||
3226 (len == WACOM_PKGLEN_BPAD_TOUCH_USB)) ||
3227 (data[0] != WACOM_REPORT_BPAD_TOUCH))
3231 wacom_bamboo_pad_pen_event(wacom, &data[1]);
3234 return wacom_bamboo_pad_touch_event(wacom, &data[9]);
3239 static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
3241 unsigned char *data = wacom->data;
3244 if (len != WACOM_PKGLEN_WIRELESS || data[0] != WACOM_REPORT_WL)
3247 connected = data[1] & 0x01;
3249 int pid, battery, charging;
3251 if ((wacom->shared->type == INTUOSHT ||
3252 wacom->shared->type == INTUOSHT2) &&
3253 wacom->shared->touch_input &&
3254 wacom->shared->touch_max) {
3255 input_report_switch(wacom->shared->touch_input,
3256 SW_MUTE_DEVICE, data[5] & 0x40);
3257 input_sync(wacom->shared->touch_input);
3260 pid = get_unaligned_be16(&data[6]);
3261 battery = (data[5] & 0x3f) * 100 / 31;
3262 charging = !!(data[5] & 0x80);
3263 if (wacom->pid != pid) {
3265 wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
3268 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
3269 battery, charging, 1, 0);
3271 } else if (wacom->pid != 0) {
3272 /* disconnected while previously connected */
3274 wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
3275 wacom_notify_battery(wacom, POWER_SUPPLY_STATUS_UNKNOWN, 0, 0, 0, 0);
3281 static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
3283 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
3284 struct wacom_features *features = &wacom_wac->features;
3285 unsigned char *data = wacom_wac->data;
3287 if (data[0] != WACOM_REPORT_USB)
3290 if ((features->type == INTUOSHT ||
3291 features->type == INTUOSHT2) &&
3292 wacom_wac->shared->touch_input &&
3293 features->touch_max) {
3294 input_report_switch(wacom_wac->shared->touch_input,
3295 SW_MUTE_DEVICE, data[8] & 0x40);
3296 input_sync(wacom_wac->shared->touch_input);
3299 if (data[9] & 0x02) { /* wireless module is attached */
3300 int battery = (data[8] & 0x3f) * 100 / 31;
3301 bool charging = !!(data[8] & 0x80);
3303 wacom_notify_battery(wacom_wac, WACOM_POWER_SUPPLY_STATUS_AUTO,
3304 battery, charging, battery || charging, 1);
3306 if (!wacom->battery.battery &&
3307 !(features->quirks & WACOM_QUIRK_BATTERY)) {
3308 features->quirks |= WACOM_QUIRK_BATTERY;
3309 wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
3312 else if ((features->quirks & WACOM_QUIRK_BATTERY) &&
3313 wacom->battery.battery) {
3314 features->quirks &= ~WACOM_QUIRK_BATTERY;
3315 wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
3316 wacom_notify_battery(wacom_wac, POWER_SUPPLY_STATUS_UNKNOWN, 0, 0, 0, 0);
3321 void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
3325 switch (wacom_wac->features.type) {
3327 sync = wacom_penpartner_irq(wacom_wac);
3331 sync = wacom_pl_irq(wacom_wac);
3338 sync = wacom_graphire_irq(wacom_wac);
3342 sync = wacom_ptu_irq(wacom_wac);
3346 sync = wacom_dtu_irq(wacom_wac);
3351 sync = wacom_dtus_irq(wacom_wac);
3370 case CINTIQ_COMPANION_2:
3371 sync = wacom_intuos_irq(wacom_wac);
3375 sync = wacom_intuos_bt_irq(wacom_wac, len);
3380 sync = wacom_24hdt_irq(wacom_wac);
3389 if (len == WACOM_PKGLEN_BBTOUCH3)
3390 sync = wacom_bpt3_touch(wacom_wac);
3391 else if (wacom_wac->data[0] == WACOM_REPORT_USB)
3392 sync = wacom_status_irq(wacom_wac, len);
3394 sync = wacom_intuos_irq(wacom_wac);
3400 sync = wacom_intuos_pro2_bt_irq(wacom_wac, len);
3409 sync = wacom_tpc_irq(wacom_wac, len);
3417 if (wacom_wac->data[0] == WACOM_REPORT_USB)
3418 sync = wacom_status_irq(wacom_wac, len);
3420 sync = wacom_bpt_irq(wacom_wac, len);
3424 sync = wacom_bamboo_pad_irq(wacom_wac, len);
3428 sync = wacom_wireless_irq(wacom_wac, len);
3433 if (wacom_wac->data[0] == WACOM_REPORT_DEVICE_LIST)
3434 wacom_remote_status_irq(wacom_wac, len);
3436 sync = wacom_remote_irq(wacom_wac, len);
3445 if (wacom_wac->pen_input)
3446 input_sync(wacom_wac->pen_input);
3447 if (wacom_wac->touch_input)
3448 input_sync(wacom_wac->touch_input);
3449 if (wacom_wac->pad_input)
3450 input_sync(wacom_wac->pad_input);
3454 static void wacom_setup_basic_pro_pen(struct wacom_wac *wacom_wac)
3456 struct input_dev *input_dev = wacom_wac->pen_input;
3458 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
3460 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3461 __set_bit(BTN_STYLUS, input_dev->keybit);
3462 __set_bit(BTN_STYLUS2, input_dev->keybit);
3464 input_set_abs_params(input_dev, ABS_DISTANCE,
3465 0, wacom_wac->features.distance_max, wacom_wac->features.distance_fuzz, 0);
3468 static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
3470 struct input_dev *input_dev = wacom_wac->pen_input;
3471 struct wacom_features *features = &wacom_wac->features;
3473 wacom_setup_basic_pro_pen(wacom_wac);
3475 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3476 __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
3477 __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
3478 __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
3480 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
3481 input_set_abs_params(input_dev, ABS_TILT_X, -64, 63, features->tilt_fuzz, 0);
3482 input_abs_set_res(input_dev, ABS_TILT_X, 57);
3483 input_set_abs_params(input_dev, ABS_TILT_Y, -64, 63, features->tilt_fuzz, 0);
3484 input_abs_set_res(input_dev, ABS_TILT_Y, 57);
3487 static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
3489 struct input_dev *input_dev = wacom_wac->pen_input;
3491 input_set_capability(input_dev, EV_REL, REL_WHEEL);
3493 wacom_setup_cintiq(wacom_wac);
3495 __set_bit(BTN_LEFT, input_dev->keybit);
3496 __set_bit(BTN_RIGHT, input_dev->keybit);
3497 __set_bit(BTN_MIDDLE, input_dev->keybit);
3498 __set_bit(BTN_SIDE, input_dev->keybit);
3499 __set_bit(BTN_EXTRA, input_dev->keybit);
3500 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
3501 __set_bit(BTN_TOOL_LENS, input_dev->keybit);
3503 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
3504 input_abs_set_res(input_dev, ABS_RZ, 287);
3505 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
3508 void wacom_setup_device_quirks(struct wacom *wacom)
3510 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
3511 struct wacom_features *features = &wacom->wacom_wac.features;
3513 /* The pen and pad share the same interface on most devices */
3514 if (features->type == GRAPHIRE_BT || features->type == WACOM_G4 ||
3515 features->type == DTUS ||
3516 (features->type >= INTUOS3S && features->type <= WACOM_MO)) {
3517 if (features->device_type & WACOM_DEVICETYPE_PEN)
3518 features->device_type |= WACOM_DEVICETYPE_PAD;
3521 /* touch device found but size is not defined. use default */
3522 if (features->device_type & WACOM_DEVICETYPE_TOUCH && !features->x_max) {
3523 features->x_max = 1023;
3524 features->y_max = 1023;
3528 * Intuos5/Pro and Bamboo 3rd gen have no useful data about its
3529 * touch interface in its HID descriptor. If this is the touch
3530 * interface (PacketSize of WACOM_PKGLEN_BBTOUCH3), override the
3533 if ((features->type >= INTUOS5S && features->type <= INTUOSPL) ||
3534 (features->type >= INTUOSHT && features->type <= BAMBOO_PT)) {
3535 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
3536 if (features->touch_max)
3537 features->device_type |= WACOM_DEVICETYPE_TOUCH;
3538 if (features->type >= INTUOSHT && features->type <= BAMBOO_PT)
3539 features->device_type |= WACOM_DEVICETYPE_PAD;
3541 if (features->type == INTUOSHT2) {
3542 features->x_max = features->x_max / 10;
3543 features->y_max = features->y_max / 10;
3546 features->x_max = 4096;
3547 features->y_max = 4096;
3550 else if (features->pktlen == WACOM_PKGLEN_BBTOUCH) {
3551 features->device_type |= WACOM_DEVICETYPE_PAD;
3556 * Hack for the Bamboo One:
3557 * the device presents a PAD/Touch interface as most Bamboos and even
3558 * sends ghosts PAD data on it. However, later, we must disable this
3559 * ghost interface, and we can not detect it unless we set it here
3560 * to WACOM_DEVICETYPE_PAD or WACOM_DEVICETYPE_TOUCH.
3562 if (features->type == BAMBOO_PEN &&
3563 features->pktlen == WACOM_PKGLEN_BBTOUCH3)
3564 features->device_type |= WACOM_DEVICETYPE_PAD;
3567 * Raw Wacom-mode pen and touch events both come from interface
3568 * 0, whose HID descriptor has an application usage of 0xFF0D
3569 * (i.e., WACOM_HID_WD_DIGITIZER). We route pen packets back
3570 * out through the HID_GENERIC device created for interface 1,
3571 * so rewrite this one to be of type WACOM_DEVICETYPE_TOUCH.
3573 if (features->type == BAMBOO_PAD)
3574 features->device_type = WACOM_DEVICETYPE_TOUCH;
3576 if (features->type == REMOTE)
3577 features->device_type = WACOM_DEVICETYPE_PAD;
3579 if (features->type == INTUOSP2_BT ||
3580 features->type == INTUOSP2S_BT) {
3581 features->device_type |= WACOM_DEVICETYPE_PEN |
3582 WACOM_DEVICETYPE_PAD |
3583 WACOM_DEVICETYPE_TOUCH;
3584 features->quirks |= WACOM_QUIRK_BATTERY;
3587 if (features->type == INTUOSHT3_BT) {
3588 features->device_type |= WACOM_DEVICETYPE_PEN |
3589 WACOM_DEVICETYPE_PAD;
3590 features->quirks |= WACOM_QUIRK_BATTERY;
3593 switch (features->type) {
3604 case CINTIQ_COMPANION_2:
3616 features->device_type |= WACOM_DEVICETYPE_DIRECT;
3620 if (wacom->hdev->bus == BUS_BLUETOOTH)
3621 features->quirks |= WACOM_QUIRK_BATTERY;
3623 /* quirk for bamboo touch with 2 low res touches */
3624 if ((features->type == BAMBOO_PT || features->type == BAMBOO_TOUCH) &&
3625 features->pktlen == WACOM_PKGLEN_BBTOUCH) {
3626 features->x_max <<= 5;
3627 features->y_max <<= 5;
3628 features->x_fuzz <<= 5;
3629 features->y_fuzz <<= 5;
3630 features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;
3633 if (features->type == WIRELESS) {
3634 if (features->device_type == WACOM_DEVICETYPE_WL_MONITOR) {
3635 features->quirks |= WACOM_QUIRK_BATTERY;
3639 if (features->type == REMOTE)
3640 features->device_type |= WACOM_DEVICETYPE_WL_MONITOR;
3642 /* HID descriptor for DTK-2451 / DTH-2452 claims to report lots
3643 * of things it shouldn't. Lets fix up the damage...
3645 if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
3646 features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3647 __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3648 __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3649 __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3650 __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3651 __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3652 __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3653 __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3654 __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3655 __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3656 __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3657 __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3661 int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
3662 struct wacom_wac *wacom_wac)
3664 struct wacom_features *features = &wacom_wac->features;
3666 if (!(features->device_type & WACOM_DEVICETYPE_PEN))
3669 if (features->device_type & WACOM_DEVICETYPE_DIRECT)
3670 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
3672 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
3674 if (features->type == HID_GENERIC)
3675 /* setup has already been done */
3678 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3679 __set_bit(BTN_TOUCH, input_dev->keybit);
3680 __set_bit(ABS_MISC, input_dev->absbit);
3682 input_set_abs_params(input_dev, ABS_X, 0 + features->offset_left,
3683 features->x_max - features->offset_right,
3684 features->x_fuzz, 0);
3685 input_set_abs_params(input_dev, ABS_Y, 0 + features->offset_top,
3686 features->y_max - features->offset_bottom,
3687 features->y_fuzz, 0);
3688 input_set_abs_params(input_dev, ABS_PRESSURE, 0,
3689 features->pressure_max, features->pressure_fuzz, 0);
3691 /* penabled devices have fixed resolution for each model */
3692 input_abs_set_res(input_dev, ABS_X, features->x_resolution);
3693 input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
3695 switch (features->type) {
3697 __clear_bit(ABS_MISC, input_dev->absbit);
3702 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3703 features->distance_max,
3704 features->distance_fuzz, 0);
3708 input_set_capability(input_dev, EV_REL, REL_WHEEL);
3710 __set_bit(BTN_LEFT, input_dev->keybit);
3711 __set_bit(BTN_RIGHT, input_dev->keybit);
3712 __set_bit(BTN_MIDDLE, input_dev->keybit);
3714 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3715 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3716 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
3717 __set_bit(BTN_STYLUS, input_dev->keybit);
3718 __set_bit(BTN_STYLUS2, input_dev->keybit);
3730 case CINTIQ_COMPANION_2:
3731 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3732 input_abs_set_res(input_dev, ABS_Z, 287);
3733 wacom_setup_cintiq(wacom_wac);
3743 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3744 input_abs_set_res(input_dev, ABS_Z, 287);
3748 wacom_setup_intuos(wacom_wac);
3759 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3760 features->distance_max,
3761 features->distance_fuzz, 0);
3763 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3764 input_abs_set_res(input_dev, ABS_Z, 287);
3766 wacom_setup_intuos(wacom_wac);
3777 __clear_bit(ABS_MISC, input_dev->absbit);
3784 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3785 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3786 __set_bit(BTN_STYLUS, input_dev->keybit);
3787 __set_bit(BTN_STYLUS2, input_dev->keybit);
3791 __set_bit(BTN_STYLUS2, input_dev->keybit);
3795 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3796 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3797 __set_bit(BTN_STYLUS, input_dev->keybit);
3805 if (features->type == INTUOSHT2 ||
3806 features->type == INTUOSHT3_BT) {
3807 wacom_setup_basic_pro_pen(wacom_wac);
3809 __clear_bit(ABS_MISC, input_dev->absbit);
3810 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3811 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3812 __set_bit(BTN_STYLUS, input_dev->keybit);
3813 __set_bit(BTN_STYLUS2, input_dev->keybit);
3814 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3815 features->distance_max,
3816 features->distance_fuzz, 0);
3820 __clear_bit(ABS_MISC, input_dev->absbit);
3826 int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
3827 struct wacom_wac *wacom_wac)
3829 struct wacom_features *features = &wacom_wac->features;
3831 if (!(features->device_type & WACOM_DEVICETYPE_TOUCH))
3834 if (features->device_type & WACOM_DEVICETYPE_DIRECT)
3835 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
3837 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
3839 if (features->type == HID_GENERIC)
3840 /* setup has already been done */
3843 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3844 __set_bit(BTN_TOUCH, input_dev->keybit);
3846 if (features->touch_max == 1) {
3847 input_set_abs_params(input_dev, ABS_X, 0,
3848 features->x_max, features->x_fuzz, 0);
3849 input_set_abs_params(input_dev, ABS_Y, 0,
3850 features->y_max, features->y_fuzz, 0);
3851 input_abs_set_res(input_dev, ABS_X,
3852 features->x_resolution);
3853 input_abs_set_res(input_dev, ABS_Y,
3854 features->y_resolution);
3856 else if (features->touch_max > 1) {
3857 input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
3858 features->x_max, features->x_fuzz, 0);
3859 input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
3860 features->y_max, features->y_fuzz, 0);
3861 input_abs_set_res(input_dev, ABS_MT_POSITION_X,
3862 features->x_resolution);
3863 input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
3864 features->y_resolution);
3867 switch (features->type) {
3870 input_dev->evbit[0] |= BIT_MASK(EV_SW);
3871 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
3873 if (wacom_wac->shared->touch->product == 0x361) {
3874 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
3876 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
3879 else if (wacom_wac->shared->touch->product == 0x360) {
3880 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
3882 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
3885 else if (wacom_wac->shared->touch->product == 0x393) {
3886 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
3888 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
3891 input_abs_set_res(input_dev, ABS_MT_POSITION_X, 40);
3892 input_abs_set_res(input_dev, ABS_MT_POSITION_Y, 40);
3902 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
3903 input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, features->y_max, 0, 0);
3904 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
3908 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
3909 input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
3910 input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
3911 input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
3915 if (wacom_wac->shared->touch->product == 0x32C ||
3916 wacom_wac->shared->touch->product == 0xF6) {
3917 input_dev->evbit[0] |= BIT_MASK(EV_SW);
3918 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
3919 wacom_wac->has_mute_touch_switch = true;
3920 wacom_wac->is_soft_touch_switch = true;
3928 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT);
3937 input_dev->evbit[0] |= BIT_MASK(EV_SW);
3938 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
3943 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
3944 input_set_abs_params(input_dev,
3946 0, features->x_max, 0, 0);
3947 input_set_abs_params(input_dev,
3949 0, features->y_max, 0, 0);
3951 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
3955 input_mt_init_slots(input_dev, features->touch_max,
3957 __set_bit(BTN_LEFT, input_dev->keybit);
3958 __set_bit(BTN_RIGHT, input_dev->keybit);
3964 static int wacom_numbered_button_to_key(int n)
3969 return BTN_A + (n-10);
3971 return BTN_BASE + (n-16);
3976 static void wacom_setup_numbered_buttons(struct input_dev *input_dev,
3981 for (i = 0; i < button_count; i++) {
3982 int key = wacom_numbered_button_to_key(i);
3985 __set_bit(key, input_dev->keybit);
3989 static void wacom_24hd_update_leds(struct wacom *wacom, int mask, int group)
3991 struct wacom_led *led;
3993 bool updated = false;
3996 * 24HD has LED group 1 to the left and LED group 0 to the right.
3997 * So group 0 matches the second half of the buttons and thus the mask
3998 * needs to be shifted.
4003 for (i = 0; i < 3; i++) {
4004 led = wacom_led_find(wacom, group, i);
4006 hid_err(wacom->hdev, "can't find LED %d in group %d\n",
4010 if (!updated && mask & BIT(i)) {
4012 led_trigger_event(&led->trigger, LED_FULL);
4019 static bool wacom_is_led_toggled(struct wacom *wacom, int button_count,
4020 int mask, int group)
4025 * 21UX2 has LED group 1 to the left and LED group 0
4026 * to the right. We need to reverse the group to match this
4027 * historical behavior.
4029 if (wacom->wacom_wac.features.type == WACOM_21UX2)
4032 group_button = group * (button_count/wacom->led.count);
4034 if (wacom->wacom_wac.features.type == INTUOSP2_BT)
4037 return mask & (1 << group_button);
4040 static void wacom_update_led(struct wacom *wacom, int button_count, int mask,
4043 struct wacom_led *led, *next_led;
4047 if (wacom->wacom_wac.features.type == WACOM_24HD)
4048 return wacom_24hd_update_leds(wacom, mask, group);
4050 pressed = wacom_is_led_toggled(wacom, button_count, mask, group);
4051 cur = wacom->led.groups[group].select;
4053 led = wacom_led_find(wacom, group, cur);
4055 hid_err(wacom->hdev, "can't find current LED %d in group %d\n",
4065 if (led->held && pressed)
4068 next_led = wacom_led_next(wacom, led);
4070 hid_err(wacom->hdev, "can't find next LED in group %d\n",
4074 if (next_led == led)
4077 next_led->held = true;
4078 led_trigger_event(&next_led->trigger,
4079 wacom_leds_brightness_get(next_led));
4082 static void wacom_report_numbered_buttons(struct input_dev *input_dev,
4083 int button_count, int mask)
4085 struct wacom *wacom = input_get_drvdata(input_dev);
4088 for (i = 0; i < wacom->led.count; i++)
4089 wacom_update_led(wacom, button_count, mask, i);
4091 for (i = 0; i < button_count; i++) {
4092 int key = wacom_numbered_button_to_key(i);
4095 input_report_key(input_dev, key, mask & (1 << i));
4099 int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
4100 struct wacom_wac *wacom_wac)
4102 struct wacom_features *features = &wacom_wac->features;
4104 if ((features->type == HID_GENERIC) && features->numbered_buttons > 0)
4105 features->device_type |= WACOM_DEVICETYPE_PAD;
4107 if (!(features->device_type & WACOM_DEVICETYPE_PAD))
4110 if (features->type == REMOTE && input_dev == wacom_wac->pad_input)
4113 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
4115 /* kept for making legacy xf86-input-wacom working with the wheels */
4116 __set_bit(ABS_MISC, input_dev->absbit);
4118 /* kept for making legacy xf86-input-wacom accepting the pad */
4119 if (!(input_dev->absinfo && (input_dev->absinfo[ABS_X].minimum ||
4120 input_dev->absinfo[ABS_X].maximum)))
4121 input_set_abs_params(input_dev, ABS_X, 0, 1, 0, 0);
4122 if (!(input_dev->absinfo && (input_dev->absinfo[ABS_Y].minimum ||
4123 input_dev->absinfo[ABS_Y].maximum)))
4124 input_set_abs_params(input_dev, ABS_Y, 0, 1, 0, 0);
4126 /* kept for making udev and libwacom accepting the pad */
4127 __set_bit(BTN_STYLUS, input_dev->keybit);
4129 wacom_setup_numbered_buttons(input_dev, features->numbered_buttons);
4131 switch (features->type) {
4134 case CINTIQ_COMPANION_2:
4141 __set_bit(BTN_BACK, input_dev->keybit);
4142 __set_bit(BTN_LEFT, input_dev->keybit);
4143 __set_bit(BTN_FORWARD, input_dev->keybit);
4144 __set_bit(BTN_RIGHT, input_dev->keybit);
4145 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4149 __set_bit(BTN_BACK, input_dev->keybit);
4150 __set_bit(BTN_FORWARD, input_dev->keybit);
4151 input_set_capability(input_dev, EV_REL, REL_WHEEL);
4155 __set_bit(KEY_PROG1, input_dev->keybit);
4156 __set_bit(KEY_PROG2, input_dev->keybit);
4157 __set_bit(KEY_PROG3, input_dev->keybit);
4159 __set_bit(KEY_ONSCREEN_KEYBOARD, input_dev->keybit);
4160 __set_bit(KEY_INFO, input_dev->keybit);
4162 if (!features->oPid)
4163 __set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
4165 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4166 input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
4170 __set_bit(KEY_PROG1, input_dev->keybit);
4171 __set_bit(KEY_PROG2, input_dev->keybit);
4172 __set_bit(KEY_PROG3, input_dev->keybit);
4174 __set_bit(KEY_ONSCREEN_KEYBOARD, input_dev->keybit);
4175 __set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
4177 if (!features->oPid)
4178 __set_bit(KEY_CONTROLPANEL, input_dev->keybit);
4179 input_set_abs_params(input_dev, ABS_X, -2048, 2048, 0, 0);
4180 input_abs_set_res(input_dev, ABS_X, 1024); /* points/g */
4181 input_set_abs_params(input_dev, ABS_Y, -2048, 2048, 0, 0);
4182 input_abs_set_res(input_dev, ABS_Y, 1024);
4183 input_set_abs_params(input_dev, ABS_Z, -2048, 2048, 0, 0);
4184 input_abs_set_res(input_dev, ABS_Z, 1024);
4185 __set_bit(INPUT_PROP_ACCELEROMETER, input_dev->propbit);
4189 __set_bit(KEY_PROG1, input_dev->keybit);
4190 __set_bit(KEY_PROG2, input_dev->keybit);
4191 __set_bit(KEY_PROG3, input_dev->keybit);
4193 __set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
4194 __set_bit(KEY_INFO, input_dev->keybit);
4200 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
4201 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
4205 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4210 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
4214 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
4225 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4230 * For Bluetooth devices, the udev rule does not work correctly
4231 * for pads unless we add a stylus capability, which forces
4232 * ID_INPUT_TABLET to be set.
4234 __set_bit(BTN_STYLUS, input_dev->keybit);
4240 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4247 __clear_bit(ABS_MISC, input_dev->absbit);
4249 __set_bit(BTN_LEFT, input_dev->keybit);
4250 __set_bit(BTN_FORWARD, input_dev->keybit);
4251 __set_bit(BTN_BACK, input_dev->keybit);
4252 __set_bit(BTN_RIGHT, input_dev->keybit);
4257 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
4258 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4266 /* no pad supported */
4272 static const struct wacom_features wacom_features_0x00 =
4273 { "Wacom Penpartner", 5040, 3780, 255, 0,
4274 PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
4275 static const struct wacom_features wacom_features_0x10 =
4276 { "Wacom Graphire", 10206, 7422, 511, 63,
4277 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4278 static const struct wacom_features wacom_features_0x81 =
4279 { "Wacom Graphire BT", 16704, 12064, 511, 32,
4280 GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES, 2 };
4281 static const struct wacom_features wacom_features_0x11 =
4282 { "Wacom Graphire2 4x5", 10206, 7422, 511, 63,
4283 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4284 static const struct wacom_features wacom_features_0x12 =
4285 { "Wacom Graphire2 5x7", 13918, 10206, 511, 63,
4286 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4287 static const struct wacom_features wacom_features_0x13 =
4288 { "Wacom Graphire3", 10208, 7424, 511, 63,
4289 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4290 static const struct wacom_features wacom_features_0x14 =
4291 { "Wacom Graphire3 6x8", 16704, 12064, 511, 63,
4292 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4293 static const struct wacom_features wacom_features_0x15 =
4294 { "Wacom Graphire4 4x5", 10208, 7424, 511, 63,
4295 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4296 static const struct wacom_features wacom_features_0x16 =
4297 { "Wacom Graphire4 6x8", 16704, 12064, 511, 63,
4298 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4299 static const struct wacom_features wacom_features_0x17 =
4300 { "Wacom BambooFun 4x5", 14760, 9225, 511, 63,
4301 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4302 static const struct wacom_features wacom_features_0x18 =
4303 { "Wacom BambooFun 6x8", 21648, 13530, 511, 63,
4304 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4305 static const struct wacom_features wacom_features_0x19 =
4306 { "Wacom Bamboo1 Medium", 16704, 12064, 511, 63,
4307 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4308 static const struct wacom_features wacom_features_0x60 =
4309 { "Wacom Volito", 5104, 3712, 511, 63,
4310 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4311 static const struct wacom_features wacom_features_0x61 =
4312 { "Wacom PenStation2", 3250, 2320, 255, 63,
4313 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4314 static const struct wacom_features wacom_features_0x62 =
4315 { "Wacom Volito2 4x5", 5104, 3712, 511, 63,
4316 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4317 static const struct wacom_features wacom_features_0x63 =
4318 { "Wacom Volito2 2x3", 3248, 2320, 511, 63,
4319 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4320 static const struct wacom_features wacom_features_0x64 =
4321 { "Wacom PenPartner2", 3250, 2320, 511, 63,
4322 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4323 static const struct wacom_features wacom_features_0x65 =
4324 { "Wacom Bamboo", 14760, 9225, 511, 63,
4325 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4326 static const struct wacom_features wacom_features_0x69 =
4327 { "Wacom Bamboo1", 5104, 3712, 511, 63,
4328 GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
4329 static const struct wacom_features wacom_features_0x6A =
4330 { "Wacom Bamboo1 4x6", 14760, 9225, 1023, 63,
4331 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4332 static const struct wacom_features wacom_features_0x6B =
4333 { "Wacom Bamboo1 5x8", 21648, 13530, 1023, 63,
4334 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4335 static const struct wacom_features wacom_features_0x20 =
4336 { "Wacom Intuos 4x5", 12700, 10600, 1023, 31,
4337 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4338 static const struct wacom_features wacom_features_0x21 =
4339 { "Wacom Intuos 6x8", 20320, 16240, 1023, 31,
4340 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4341 static const struct wacom_features wacom_features_0x22 =
4342 { "Wacom Intuos 9x12", 30480, 24060, 1023, 31,
4343 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4344 static const struct wacom_features wacom_features_0x23 =
4345 { "Wacom Intuos 12x12", 30480, 31680, 1023, 31,
4346 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4347 static const struct wacom_features wacom_features_0x24 =
4348 { "Wacom Intuos 12x18", 45720, 31680, 1023, 31,
4349 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4350 static const struct wacom_features wacom_features_0x30 =
4351 { "Wacom PL400", 5408, 4056, 255, 0,
4352 PL, WACOM_PL_RES, WACOM_PL_RES };
4353 static const struct wacom_features wacom_features_0x31 =
4354 { "Wacom PL500", 6144, 4608, 255, 0,
4355 PL, WACOM_PL_RES, WACOM_PL_RES };
4356 static const struct wacom_features wacom_features_0x32 =
4357 { "Wacom PL600", 6126, 4604, 255, 0,
4358 PL, WACOM_PL_RES, WACOM_PL_RES };
4359 static const struct wacom_features wacom_features_0x33 =
4360 { "Wacom PL600SX", 6260, 5016, 255, 0,
4361 PL, WACOM_PL_RES, WACOM_PL_RES };
4362 static const struct wacom_features wacom_features_0x34 =
4363 { "Wacom PL550", 6144, 4608, 511, 0,
4364 PL, WACOM_PL_RES, WACOM_PL_RES };
4365 static const struct wacom_features wacom_features_0x35 =
4366 { "Wacom PL800", 7220, 5780, 511, 0,
4367 PL, WACOM_PL_RES, WACOM_PL_RES };
4368 static const struct wacom_features wacom_features_0x37 =
4369 { "Wacom PL700", 6758, 5406, 511, 0,
4370 PL, WACOM_PL_RES, WACOM_PL_RES };
4371 static const struct wacom_features wacom_features_0x38 =
4372 { "Wacom PL510", 6282, 4762, 511, 0,
4373 PL, WACOM_PL_RES, WACOM_PL_RES };
4374 static const struct wacom_features wacom_features_0x39 =
4375 { "Wacom DTU710", 34080, 27660, 511, 0,
4376 PL, WACOM_PL_RES, WACOM_PL_RES };
4377 static const struct wacom_features wacom_features_0xC4 =
4378 { "Wacom DTF521", 6282, 4762, 511, 0,
4379 PL, WACOM_PL_RES, WACOM_PL_RES };
4380 static const struct wacom_features wacom_features_0xC0 =
4381 { "Wacom DTF720", 6858, 5506, 511, 0,
4382 PL, WACOM_PL_RES, WACOM_PL_RES };
4383 static const struct wacom_features wacom_features_0xC2 =
4384 { "Wacom DTF720a", 6858, 5506, 511, 0,
4385 PL, WACOM_PL_RES, WACOM_PL_RES };
4386 static const struct wacom_features wacom_features_0x03 =
4387 { "Wacom Cintiq Partner", 20480, 15360, 511, 0,
4388 PTU, WACOM_PL_RES, WACOM_PL_RES };
4389 static const struct wacom_features wacom_features_0x41 =
4390 { "Wacom Intuos2 4x5", 12700, 10600, 1023, 31,
4391 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4392 static const struct wacom_features wacom_features_0x42 =
4393 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
4394 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4395 static const struct wacom_features wacom_features_0x43 =
4396 { "Wacom Intuos2 9x12", 30480, 24060, 1023, 31,
4397 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4398 static const struct wacom_features wacom_features_0x44 =
4399 { "Wacom Intuos2 12x12", 30480, 31680, 1023, 31,
4400 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4401 static const struct wacom_features wacom_features_0x45 =
4402 { "Wacom Intuos2 12x18", 45720, 31680, 1023, 31,
4403 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4404 static const struct wacom_features wacom_features_0xB0 =
4405 { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63,
4406 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
4407 static const struct wacom_features wacom_features_0xB1 =
4408 { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63,
4409 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4410 static const struct wacom_features wacom_features_0xB2 =
4411 { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63,
4412 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4413 static const struct wacom_features wacom_features_0xB3 =
4414 { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63,
4415 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4416 static const struct wacom_features wacom_features_0xB4 =
4417 { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63,
4418 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4419 static const struct wacom_features wacom_features_0xB5 =
4420 { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63,
4421 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4422 static const struct wacom_features wacom_features_0xB7 =
4423 { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63,
4424 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
4425 static const struct wacom_features wacom_features_0xB8 =
4426 { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63,
4427 INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
4428 static const struct wacom_features wacom_features_0xB9 =
4429 { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63,
4430 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4431 static const struct wacom_features wacom_features_0xBA =
4432 { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63,
4433 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4434 static const struct wacom_features wacom_features_0xBB =
4435 { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63,
4436 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4437 static const struct wacom_features wacom_features_0xBC =
4438 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
4439 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4440 static const struct wacom_features wacom_features_0xBD =
4441 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
4442 INTUOS4WL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4443 static const struct wacom_features wacom_features_0x26 =
4444 { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63,
4445 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16 };
4446 static const struct wacom_features wacom_features_0x27 =
4447 { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63,
4448 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
4449 static const struct wacom_features wacom_features_0x28 =
4450 { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63,
4451 INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
4452 static const struct wacom_features wacom_features_0x29 =
4453 { "Wacom Intuos5 S", 31496, 19685, 2047, 63,
4454 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
4455 static const struct wacom_features wacom_features_0x2A =
4456 { "Wacom Intuos5 M", 44704, 27940, 2047, 63,
4457 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4458 static const struct wacom_features wacom_features_0x314 =
4459 { "Wacom Intuos Pro S", 31496, 19685, 2047, 63,
4460 INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16,
4461 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4462 static const struct wacom_features wacom_features_0x315 =
4463 { "Wacom Intuos Pro M", 44704, 27940, 2047, 63,
4464 INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
4465 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4466 static const struct wacom_features wacom_features_0x317 =
4467 { "Wacom Intuos Pro L", 65024, 40640, 2047, 63,
4468 INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
4469 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4470 static const struct wacom_features wacom_features_0xF4 =
4471 { "Wacom Cintiq 24HD", 104480, 65600, 2047, 63,
4472 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
4473 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4474 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4475 static const struct wacom_features wacom_features_0xF8 =
4476 { "Wacom Cintiq 24HD touch", 104480, 65600, 2047, 63, /* Pen */
4477 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
4478 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4479 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4480 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 };
4481 static const struct wacom_features wacom_features_0xF6 =
4482 { "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */
4483 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10,
4484 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4485 static const struct wacom_features wacom_features_0x32A =
4486 { "Wacom Cintiq 27QHD", 120140, 67920, 2047, 63,
4487 WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
4488 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4489 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4490 static const struct wacom_features wacom_features_0x32B =
4491 { "Wacom Cintiq 27QHD touch", 120140, 67920, 2047, 63,
4492 WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
4493 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4494 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4495 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32C };
4496 static const struct wacom_features wacom_features_0x32C =
4497 { "Wacom Cintiq 27QHD touch", .type = WACOM_27QHDT,
4498 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32B, .touch_max = 10 };
4499 static const struct wacom_features wacom_features_0x3F =
4500 { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63,
4501 CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4502 static const struct wacom_features wacom_features_0xC5 =
4503 { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63,
4504 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
4505 static const struct wacom_features wacom_features_0xC6 =
4506 { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63,
4507 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
4508 static const struct wacom_features wacom_features_0x304 =
4509 { "Wacom Cintiq 13HD", 59552, 33848, 1023, 63,
4510 WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4511 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4512 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4513 static const struct wacom_features wacom_features_0x333 =
4514 { "Wacom Cintiq 13HD touch", 59552, 33848, 2047, 63,
4515 WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4516 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4517 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4518 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x335 };
4519 static const struct wacom_features wacom_features_0x335 =
4520 { "Wacom Cintiq 13HD touch", .type = WACOM_24HDT, /* Touch */
4521 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x333, .touch_max = 10,
4522 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4523 static const struct wacom_features wacom_features_0xC7 =
4524 { "Wacom DTU1931", 37832, 30305, 511, 0,
4525 PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4526 static const struct wacom_features wacom_features_0xCE =
4527 { "Wacom DTU2231", 47864, 27011, 511, 0,
4528 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4529 .check_for_hid_type = true, .hid_type = HID_TYPE_USBMOUSE };
4530 static const struct wacom_features wacom_features_0xF0 =
4531 { "Wacom DTU1631", 34623, 19553, 511, 0,
4532 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4533 static const struct wacom_features wacom_features_0xFB =
4534 { "Wacom DTU1031", 22096, 13960, 511, 0,
4535 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
4536 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4537 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4538 static const struct wacom_features wacom_features_0x32F =
4539 { "Wacom DTU1031X", 22672, 12928, 511, 0,
4540 DTUSX, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 0,
4541 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4542 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4543 static const struct wacom_features wacom_features_0x336 =
4544 { "Wacom DTU1141", 23672, 13403, 1023, 0,
4545 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
4546 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4547 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4548 static const struct wacom_features wacom_features_0x57 =
4549 { "Wacom DTK2241", 95840, 54260, 2047, 63,
4550 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
4551 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4552 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4553 static const struct wacom_features wacom_features_0x59 = /* Pen */
4554 { "Wacom DTH2242", 95840, 54260, 2047, 63,
4555 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
4556 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4557 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4558 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D };
4559 static const struct wacom_features wacom_features_0x5D = /* Touch */
4560 { "Wacom DTH2242", .type = WACOM_24HDT,
4561 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10,
4562 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4563 static const struct wacom_features wacom_features_0xCC =
4564 { "Wacom Cintiq 21UX2", 87200, 65600, 2047, 63,
4565 WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
4566 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4567 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4568 static const struct wacom_features wacom_features_0xFA =
4569 { "Wacom Cintiq 22HD", 95840, 54260, 2047, 63,
4570 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
4571 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4572 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4573 static const struct wacom_features wacom_features_0x5B =
4574 { "Wacom Cintiq 22HDT", 95840, 54260, 2047, 63,
4575 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
4576 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4577 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4578 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e };
4579 static const struct wacom_features wacom_features_0x5E =
4580 { "Wacom Cintiq 22HDT", .type = WACOM_24HDT,
4581 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5b, .touch_max = 10,
4582 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4583 static const struct wacom_features wacom_features_0x90 =
4584 { "Wacom ISDv4 90", 26202, 16325, 255, 0,
4585 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4586 static const struct wacom_features wacom_features_0x93 =
4587 { "Wacom ISDv4 93", 26202, 16325, 255, 0,
4588 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4589 static const struct wacom_features wacom_features_0x97 =
4590 { "Wacom ISDv4 97", 26202, 16325, 511, 0,
4591 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4592 static const struct wacom_features wacom_features_0x9A =
4593 { "Wacom ISDv4 9A", 26202, 16325, 255, 0,
4594 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4595 static const struct wacom_features wacom_features_0x9F =
4596 { "Wacom ISDv4 9F", 26202, 16325, 255, 0,
4597 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4598 static const struct wacom_features wacom_features_0xE2 =
4599 { "Wacom ISDv4 E2", 26202, 16325, 255, 0,
4600 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4601 static const struct wacom_features wacom_features_0xE3 =
4602 { "Wacom ISDv4 E3", 26202, 16325, 255, 0,
4603 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4604 static const struct wacom_features wacom_features_0xE5 =
4605 { "Wacom ISDv4 E5", 26202, 16325, 255, 0,
4606 MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4607 static const struct wacom_features wacom_features_0xE6 =
4608 { "Wacom ISDv4 E6", 27760, 15694, 255, 0,
4609 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4610 static const struct wacom_features wacom_features_0xEC =
4611 { "Wacom ISDv4 EC", 25710, 14500, 255, 0,
4612 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4613 static const struct wacom_features wacom_features_0xED =
4614 { "Wacom ISDv4 ED", 26202, 16325, 255, 0,
4615 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4616 static const struct wacom_features wacom_features_0xEF =
4617 { "Wacom ISDv4 EF", 26202, 16325, 255, 0,
4618 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4619 static const struct wacom_features wacom_features_0x100 =
4620 { "Wacom ISDv4 100", 26202, 16325, 255, 0,
4621 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4622 static const struct wacom_features wacom_features_0x101 =
4623 { "Wacom ISDv4 101", 26202, 16325, 255, 0,
4624 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4625 static const struct wacom_features wacom_features_0x10D =
4626 { "Wacom ISDv4 10D", 26202, 16325, 255, 0,
4627 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4628 static const struct wacom_features wacom_features_0x10E =
4629 { "Wacom ISDv4 10E", 27760, 15694, 255, 0,
4630 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4631 static const struct wacom_features wacom_features_0x10F =
4632 { "Wacom ISDv4 10F", 27760, 15694, 255, 0,
4633 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4634 static const struct wacom_features wacom_features_0x116 =
4635 { "Wacom ISDv4 116", 26202, 16325, 255, 0,
4636 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4637 static const struct wacom_features wacom_features_0x12C =
4638 { "Wacom ISDv4 12C", 27848, 15752, 2047, 0,
4639 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4640 static const struct wacom_features wacom_features_0x4001 =
4641 { "Wacom ISDv4 4001", 26202, 16325, 255, 0,
4642 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4643 static const struct wacom_features wacom_features_0x4004 =
4644 { "Wacom ISDv4 4004", 11060, 6220, 255, 0,
4645 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4646 static const struct wacom_features wacom_features_0x5000 =
4647 { "Wacom ISDv4 5000", 27848, 15752, 1023, 0,
4648 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4649 static const struct wacom_features wacom_features_0x5002 =
4650 { "Wacom ISDv4 5002", 29576, 16724, 1023, 0,
4651 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4652 static const struct wacom_features wacom_features_0x47 =
4653 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
4654 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4655 static const struct wacom_features wacom_features_0x84 =
4656 { "Wacom Wireless Receiver", .type = WIRELESS, .touch_max = 16 };
4657 static const struct wacom_features wacom_features_0xD0 =
4658 { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31,
4659 BAMBOO_TOUCH, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4660 static const struct wacom_features wacom_features_0xD1 =
4661 { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31,
4662 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4663 static const struct wacom_features wacom_features_0xD2 =
4664 { "Wacom Bamboo Craft", 14720, 9200, 1023, 31,
4665 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4666 static const struct wacom_features wacom_features_0xD3 =
4667 { "Wacom Bamboo 2FG 6x8", 21648, 13700, 1023, 31,
4668 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4669 static const struct wacom_features wacom_features_0xD4 =
4670 { "Wacom Bamboo Pen", 14720, 9200, 1023, 31,
4671 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4672 static const struct wacom_features wacom_features_0xD5 =
4673 { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31,
4674 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4675 static const struct wacom_features wacom_features_0xD6 =
4676 { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31,
4677 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4678 static const struct wacom_features wacom_features_0xD7 =
4679 { "Wacom BambooPT 2FG Small", 14720, 9200, 1023, 31,
4680 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4681 static const struct wacom_features wacom_features_0xD8 =
4682 { "Wacom Bamboo Comic 2FG", 21648, 13700, 1023, 31,
4683 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4684 static const struct wacom_features wacom_features_0xDA =
4685 { "Wacom Bamboo 2FG 4x5 SE", 14720, 9200, 1023, 31,
4686 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4687 static const struct wacom_features wacom_features_0xDB =
4688 { "Wacom Bamboo 2FG 6x8 SE", 21648, 13700, 1023, 31,
4689 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4690 static const struct wacom_features wacom_features_0xDD =
4691 { "Wacom Bamboo Connect", 14720, 9200, 1023, 31,
4692 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4693 static const struct wacom_features wacom_features_0xDE =
4694 { "Wacom Bamboo 16FG 4x5", 14720, 9200, 1023, 31,
4695 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
4696 static const struct wacom_features wacom_features_0xDF =
4697 { "Wacom Bamboo 16FG 6x8", 21648, 13700, 1023, 31,
4698 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
4699 static const struct wacom_features wacom_features_0x300 =
4700 { "Wacom Bamboo One S", 14720, 9225, 1023, 31,
4701 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4702 static const struct wacom_features wacom_features_0x301 =
4703 { "Wacom Bamboo One M", 21648, 13530, 1023, 31,
4704 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4705 static const struct wacom_features wacom_features_0x302 =
4706 { "Wacom Intuos PT S", 15200, 9500, 1023, 31,
4707 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4708 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4709 static const struct wacom_features wacom_features_0x303 =
4710 { "Wacom Intuos PT M", 21600, 13500, 1023, 31,
4711 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4712 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4713 static const struct wacom_features wacom_features_0x30E =
4714 { "Wacom Intuos S", 15200, 9500, 1023, 31,
4715 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4716 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4717 static const struct wacom_features wacom_features_0x6004 =
4718 { "ISD-V4", 12800, 8000, 255, 0,
4719 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4720 static const struct wacom_features wacom_features_0x307 =
4721 { "Wacom ISDv5 307", 59552, 33848, 2047, 63,
4722 CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4723 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4724 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4725 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 };
4726 static const struct wacom_features wacom_features_0x309 =
4727 { "Wacom ISDv5 309", .type = WACOM_24HDT, /* Touch */
4728 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x0307, .touch_max = 10,
4729 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4730 static const struct wacom_features wacom_features_0x30A =
4731 { "Wacom ISDv5 30A", 59552, 33848, 2047, 63,
4732 CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4733 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4734 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4735 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30C };
4736 static const struct wacom_features wacom_features_0x30C =
4737 { "Wacom ISDv5 30C", .type = WACOM_24HDT, /* Touch */
4738 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30A, .touch_max = 10,
4739 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4740 static const struct wacom_features wacom_features_0x318 =
4741 { "Wacom USB Bamboo PAD", 4095, 4095, /* Touch */
4742 .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
4743 static const struct wacom_features wacom_features_0x319 =
4744 { "Wacom Wireless Bamboo PAD", 4095, 4095, /* Touch */
4745 .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
4746 static const struct wacom_features wacom_features_0x325 =
4747 { "Wacom ISDv5 325", 59552, 33848, 2047, 63,
4748 CINTIQ_COMPANION_2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 11,
4749 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4750 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4751 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x326 };
4752 static const struct wacom_features wacom_features_0x326 = /* Touch */
4753 { "Wacom ISDv5 326", .type = HID_GENERIC, .oVid = USB_VENDOR_ID_WACOM,
4755 static const struct wacom_features wacom_features_0x323 =
4756 { "Wacom Intuos P M", 21600, 13500, 1023, 31,
4757 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4758 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4759 static const struct wacom_features wacom_features_0x331 =
4760 { "Wacom Express Key Remote", .type = REMOTE,
4761 .numbered_buttons = 18, .check_for_hid_type = true,
4762 .hid_type = HID_TYPE_USBNONE };
4763 static const struct wacom_features wacom_features_0x33B =
4764 { "Wacom Intuos S 2", 15200, 9500, 2047, 63,
4765 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4766 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4767 static const struct wacom_features wacom_features_0x33C =
4768 { "Wacom Intuos PT S 2", 15200, 9500, 2047, 63,
4769 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4770 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4771 static const struct wacom_features wacom_features_0x33D =
4772 { "Wacom Intuos P M 2", 21600, 13500, 2047, 63,
4773 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4774 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4775 static const struct wacom_features wacom_features_0x33E =
4776 { "Wacom Intuos PT M 2", 21600, 13500, 2047, 63,
4777 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4778 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4779 static const struct wacom_features wacom_features_0x343 =
4780 { "Wacom DTK1651", 34816, 19759, 1023, 0,
4781 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
4782 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4783 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4784 static const struct wacom_features wacom_features_0x360 =
4785 { "Wacom Intuos Pro M", 44800, 29600, 8191, 63,
4786 INTUOSP2_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 10 };
4787 static const struct wacom_features wacom_features_0x361 =
4788 { "Wacom Intuos Pro L", 62200, 43200, 8191, 63,
4789 INTUOSP2_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 10 };
4790 static const struct wacom_features wacom_features_0x377 =
4791 { "Wacom Intuos BT S", 15200, 9500, 4095, 63,
4792 INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
4793 static const struct wacom_features wacom_features_0x379 =
4794 { "Wacom Intuos BT M", 21600, 13500, 4095, 63,
4795 INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
4796 static const struct wacom_features wacom_features_0x37A =
4797 { "Wacom One by Wacom S", 15200, 9500, 2047, 63,
4798 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4799 static const struct wacom_features wacom_features_0x37B =
4800 { "Wacom One by Wacom M", 21600, 13500, 2047, 63,
4801 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4802 static const struct wacom_features wacom_features_0x393 =
4803 { "Wacom Intuos Pro S", 31920, 19950, 8191, 63,
4804 INTUOSP2S_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7,
4806 static const struct wacom_features wacom_features_0x3c6 =
4807 { "Wacom Intuos BT S", 15200, 9500, 4095, 63,
4808 INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
4809 static const struct wacom_features wacom_features_0x3c8 =
4810 { "Wacom Intuos BT M", 21600, 13500, 4095, 63,
4811 INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
4813 static const struct wacom_features wacom_features_HID_ANY_ID =
4814 { "Wacom HID", .type = HID_GENERIC, .oVid = HID_ANY_ID, .oPid = HID_ANY_ID };
4816 static const struct wacom_features wacom_features_0x94 =
4817 { "Wacom Bootloader", .type = BOOTLOADER };
4819 #define USB_DEVICE_WACOM(prod) \
4820 HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4821 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4823 #define BT_DEVICE_WACOM(prod) \
4824 HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4825 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4827 #define I2C_DEVICE_WACOM(prod) \
4828 HID_DEVICE(BUS_I2C, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4829 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4831 #define USB_DEVICE_LENOVO(prod) \
4832 HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
4833 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4835 const struct hid_device_id wacom_ids[] = {
4836 { USB_DEVICE_WACOM(0x00) },
4837 { USB_DEVICE_WACOM(0x03) },
4838 { USB_DEVICE_WACOM(0x10) },
4839 { USB_DEVICE_WACOM(0x11) },
4840 { USB_DEVICE_WACOM(0x12) },
4841 { USB_DEVICE_WACOM(0x13) },
4842 { USB_DEVICE_WACOM(0x14) },
4843 { USB_DEVICE_WACOM(0x15) },
4844 { USB_DEVICE_WACOM(0x16) },
4845 { USB_DEVICE_WACOM(0x17) },
4846 { USB_DEVICE_WACOM(0x18) },
4847 { USB_DEVICE_WACOM(0x19) },
4848 { USB_DEVICE_WACOM(0x20) },
4849 { USB_DEVICE_WACOM(0x21) },
4850 { USB_DEVICE_WACOM(0x22) },
4851 { USB_DEVICE_WACOM(0x23) },
4852 { USB_DEVICE_WACOM(0x24) },
4853 { USB_DEVICE_WACOM(0x26) },
4854 { USB_DEVICE_WACOM(0x27) },
4855 { USB_DEVICE_WACOM(0x28) },
4856 { USB_DEVICE_WACOM(0x29) },
4857 { USB_DEVICE_WACOM(0x2A) },
4858 { USB_DEVICE_WACOM(0x30) },
4859 { USB_DEVICE_WACOM(0x31) },
4860 { USB_DEVICE_WACOM(0x32) },
4861 { USB_DEVICE_WACOM(0x33) },
4862 { USB_DEVICE_WACOM(0x34) },
4863 { USB_DEVICE_WACOM(0x35) },
4864 { USB_DEVICE_WACOM(0x37) },
4865 { USB_DEVICE_WACOM(0x38) },
4866 { USB_DEVICE_WACOM(0x39) },
4867 { USB_DEVICE_WACOM(0x3F) },
4868 { USB_DEVICE_WACOM(0x41) },
4869 { USB_DEVICE_WACOM(0x42) },
4870 { USB_DEVICE_WACOM(0x43) },
4871 { USB_DEVICE_WACOM(0x44) },
4872 { USB_DEVICE_WACOM(0x45) },
4873 { USB_DEVICE_WACOM(0x47) },
4874 { USB_DEVICE_WACOM(0x57) },
4875 { USB_DEVICE_WACOM(0x59) },
4876 { USB_DEVICE_WACOM(0x5B) },
4877 { USB_DEVICE_WACOM(0x5D) },
4878 { USB_DEVICE_WACOM(0x5E) },
4879 { USB_DEVICE_WACOM(0x60) },
4880 { USB_DEVICE_WACOM(0x61) },
4881 { USB_DEVICE_WACOM(0x62) },
4882 { USB_DEVICE_WACOM(0x63) },
4883 { USB_DEVICE_WACOM(0x64) },
4884 { USB_DEVICE_WACOM(0x65) },
4885 { USB_DEVICE_WACOM(0x69) },
4886 { USB_DEVICE_WACOM(0x6A) },
4887 { USB_DEVICE_WACOM(0x6B) },
4888 { BT_DEVICE_WACOM(0x81) },
4889 { USB_DEVICE_WACOM(0x84) },
4890 { USB_DEVICE_WACOM(0x90) },
4891 { USB_DEVICE_WACOM(0x93) },
4892 { USB_DEVICE_WACOM(0x94) },
4893 { USB_DEVICE_WACOM(0x97) },
4894 { USB_DEVICE_WACOM(0x9A) },
4895 { USB_DEVICE_WACOM(0x9F) },
4896 { USB_DEVICE_WACOM(0xB0) },
4897 { USB_DEVICE_WACOM(0xB1) },
4898 { USB_DEVICE_WACOM(0xB2) },
4899 { USB_DEVICE_WACOM(0xB3) },
4900 { USB_DEVICE_WACOM(0xB4) },
4901 { USB_DEVICE_WACOM(0xB5) },
4902 { USB_DEVICE_WACOM(0xB7) },
4903 { USB_DEVICE_WACOM(0xB8) },
4904 { USB_DEVICE_WACOM(0xB9) },
4905 { USB_DEVICE_WACOM(0xBA) },
4906 { USB_DEVICE_WACOM(0xBB) },
4907 { USB_DEVICE_WACOM(0xBC) },
4908 { BT_DEVICE_WACOM(0xBD) },
4909 { USB_DEVICE_WACOM(0xC0) },
4910 { USB_DEVICE_WACOM(0xC2) },
4911 { USB_DEVICE_WACOM(0xC4) },
4912 { USB_DEVICE_WACOM(0xC5) },
4913 { USB_DEVICE_WACOM(0xC6) },
4914 { USB_DEVICE_WACOM(0xC7) },
4915 { USB_DEVICE_WACOM(0xCC) },
4916 { USB_DEVICE_WACOM(0xCE) },
4917 { USB_DEVICE_WACOM(0xD0) },
4918 { USB_DEVICE_WACOM(0xD1) },
4919 { USB_DEVICE_WACOM(0xD2) },
4920 { USB_DEVICE_WACOM(0xD3) },
4921 { USB_DEVICE_WACOM(0xD4) },
4922 { USB_DEVICE_WACOM(0xD5) },
4923 { USB_DEVICE_WACOM(0xD6) },
4924 { USB_DEVICE_WACOM(0xD7) },
4925 { USB_DEVICE_WACOM(0xD8) },
4926 { USB_DEVICE_WACOM(0xDA) },
4927 { USB_DEVICE_WACOM(0xDB) },
4928 { USB_DEVICE_WACOM(0xDD) },
4929 { USB_DEVICE_WACOM(0xDE) },
4930 { USB_DEVICE_WACOM(0xDF) },
4931 { USB_DEVICE_WACOM(0xE2) },
4932 { USB_DEVICE_WACOM(0xE3) },
4933 { USB_DEVICE_WACOM(0xE5) },
4934 { USB_DEVICE_WACOM(0xE6) },
4935 { USB_DEVICE_WACOM(0xEC) },
4936 { USB_DEVICE_WACOM(0xED) },
4937 { USB_DEVICE_WACOM(0xEF) },
4938 { USB_DEVICE_WACOM(0xF0) },
4939 { USB_DEVICE_WACOM(0xF4) },
4940 { USB_DEVICE_WACOM(0xF6) },
4941 { USB_DEVICE_WACOM(0xF8) },
4942 { USB_DEVICE_WACOM(0xFA) },
4943 { USB_DEVICE_WACOM(0xFB) },
4944 { USB_DEVICE_WACOM(0x100) },
4945 { USB_DEVICE_WACOM(0x101) },
4946 { USB_DEVICE_WACOM(0x10D) },
4947 { USB_DEVICE_WACOM(0x10E) },
4948 { USB_DEVICE_WACOM(0x10F) },
4949 { USB_DEVICE_WACOM(0x116) },
4950 { USB_DEVICE_WACOM(0x12C) },
4951 { USB_DEVICE_WACOM(0x300) },
4952 { USB_DEVICE_WACOM(0x301) },
4953 { USB_DEVICE_WACOM(0x302) },
4954 { USB_DEVICE_WACOM(0x303) },
4955 { USB_DEVICE_WACOM(0x304) },
4956 { USB_DEVICE_WACOM(0x307) },
4957 { USB_DEVICE_WACOM(0x309) },
4958 { USB_DEVICE_WACOM(0x30A) },
4959 { USB_DEVICE_WACOM(0x30C) },
4960 { USB_DEVICE_WACOM(0x30E) },
4961 { USB_DEVICE_WACOM(0x314) },
4962 { USB_DEVICE_WACOM(0x315) },
4963 { USB_DEVICE_WACOM(0x317) },
4964 { USB_DEVICE_WACOM(0x318) },
4965 { USB_DEVICE_WACOM(0x319) },
4966 { USB_DEVICE_WACOM(0x323) },
4967 { USB_DEVICE_WACOM(0x325) },
4968 { USB_DEVICE_WACOM(0x326) },
4969 { USB_DEVICE_WACOM(0x32A) },
4970 { USB_DEVICE_WACOM(0x32B) },
4971 { USB_DEVICE_WACOM(0x32C) },
4972 { USB_DEVICE_WACOM(0x32F) },
4973 { USB_DEVICE_WACOM(0x331) },
4974 { USB_DEVICE_WACOM(0x333) },
4975 { USB_DEVICE_WACOM(0x335) },
4976 { USB_DEVICE_WACOM(0x336) },
4977 { USB_DEVICE_WACOM(0x33B) },
4978 { USB_DEVICE_WACOM(0x33C) },
4979 { USB_DEVICE_WACOM(0x33D) },
4980 { USB_DEVICE_WACOM(0x33E) },
4981 { USB_DEVICE_WACOM(0x343) },
4982 { BT_DEVICE_WACOM(0x360) },
4983 { BT_DEVICE_WACOM(0x361) },
4984 { BT_DEVICE_WACOM(0x377) },
4985 { BT_DEVICE_WACOM(0x379) },
4986 { USB_DEVICE_WACOM(0x37A) },
4987 { USB_DEVICE_WACOM(0x37B) },
4988 { BT_DEVICE_WACOM(0x393) },
4989 { BT_DEVICE_WACOM(0x3c6) },
4990 { BT_DEVICE_WACOM(0x3c8) },
4991 { USB_DEVICE_WACOM(0x4001) },
4992 { USB_DEVICE_WACOM(0x4004) },
4993 { USB_DEVICE_WACOM(0x5000) },
4994 { USB_DEVICE_WACOM(0x5002) },
4995 { USB_DEVICE_LENOVO(0x6004) },
4997 { USB_DEVICE_WACOM(HID_ANY_ID) },
4998 { I2C_DEVICE_WACOM(HID_ANY_ID) },
4999 { BT_DEVICE_WACOM(HID_ANY_ID) },
5002 MODULE_DEVICE_TABLE(hid, wacom_ids);