1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * USB Wacom tablet support - Wacom specific code
8 #include <linux/input/mt.h>
9 #include <linux/jiffies.h>
11 /* resolution for penabled devices */
12 #define WACOM_PL_RES 20
13 #define WACOM_PENPRTN_RES 40
14 #define WACOM_VOLITO_RES 50
15 #define WACOM_GRAPHIRE_RES 80
16 #define WACOM_INTUOS_RES 100
17 #define WACOM_INTUOS3_RES 200
19 /* Newer Cintiq and DTU have an offset between tablet and screen areas */
20 #define WACOM_DTU_OFFSET 200
21 #define WACOM_CINTIQ_OFFSET 400
24 * Scale factor relating reported contact size to logical contact area.
25 * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo
27 #define WACOM_CONTACT_AREA_SCALE 2607
29 static bool touch_arbitration = 1;
30 module_param(touch_arbitration, bool, 0644);
31 MODULE_PARM_DESC(touch_arbitration, " on (Y) off (N)");
33 static void wacom_report_numbered_buttons(struct input_dev *input_dev,
34 int button_count, int mask);
36 static int wacom_numbered_button_to_key(int n);
38 static void wacom_update_led(struct wacom *wacom, int button_count, int mask,
41 static void wacom_force_proxout(struct wacom_wac *wacom_wac)
43 struct input_dev *input = wacom_wac->pen_input;
45 wacom_wac->shared->stylus_in_proximity = 0;
47 input_report_key(input, BTN_TOUCH, 0);
48 input_report_key(input, BTN_STYLUS, 0);
49 input_report_key(input, BTN_STYLUS2, 0);
50 input_report_key(input, BTN_STYLUS3, 0);
51 input_report_key(input, wacom_wac->tool[0], 0);
52 if (wacom_wac->serial[0]) {
53 input_report_abs(input, ABS_MISC, 0);
55 input_report_abs(input, ABS_PRESSURE, 0);
57 wacom_wac->tool[0] = 0;
59 wacom_wac->serial[0] = 0;
64 void wacom_idleprox_timeout(struct timer_list *list)
66 struct wacom *wacom = from_timer(wacom, list, idleprox_timer);
67 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
69 if (!wacom_wac->hid_data.sense_state) {
73 hid_warn(wacom->hdev, "%s: tool appears to be hung in-prox. forcing it out.\n", __func__);
74 wacom_force_proxout(wacom_wac);
78 * Percent of battery capacity for Graphire.
79 * 8th value means AC online and show 100% capacity.
81 static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
84 * Percent of battery capacity for Intuos4 WL, AC has a separate bit.
86 static unsigned short batcap_i4[8] = { 1, 15, 30, 45, 60, 70, 85, 100 };
88 static void __wacom_notify_battery(struct wacom_battery *battery,
89 int bat_status, int bat_capacity,
90 bool bat_charging, bool bat_connected,
93 bool changed = battery->bat_status != bat_status ||
94 battery->battery_capacity != bat_capacity ||
95 battery->bat_charging != bat_charging ||
96 battery->bat_connected != bat_connected ||
97 battery->ps_connected != ps_connected;
100 battery->bat_status = bat_status;
101 battery->battery_capacity = bat_capacity;
102 battery->bat_charging = bat_charging;
103 battery->bat_connected = bat_connected;
104 battery->ps_connected = ps_connected;
106 if (battery->battery)
107 power_supply_changed(battery->battery);
111 static void wacom_notify_battery(struct wacom_wac *wacom_wac,
112 int bat_status, int bat_capacity, bool bat_charging,
113 bool bat_connected, bool ps_connected)
115 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
117 __wacom_notify_battery(&wacom->battery, bat_status, bat_capacity,
118 bat_charging, bat_connected, ps_connected);
121 static int wacom_penpartner_irq(struct wacom_wac *wacom)
123 unsigned char *data = wacom->data;
124 struct input_dev *input = wacom->pen_input;
128 if (data[5] & 0x80) {
129 wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
130 wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID;
131 input_report_key(input, wacom->tool[0], 1);
132 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
133 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
134 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
135 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
136 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127));
137 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
139 input_report_key(input, wacom->tool[0], 0);
140 input_report_abs(input, ABS_MISC, 0); /* report tool id */
141 input_report_abs(input, ABS_PRESSURE, -1);
142 input_report_key(input, BTN_TOUCH, 0);
147 input_report_key(input, BTN_TOOL_PEN, 1);
148 input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
149 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
150 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
151 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
152 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
153 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
157 dev_dbg(input->dev.parent,
158 "%s: received unknown report #%d\n", __func__, data[0]);
165 static int wacom_pl_irq(struct wacom_wac *wacom)
167 struct wacom_features *features = &wacom->features;
168 unsigned char *data = wacom->data;
169 struct input_dev *input = wacom->pen_input;
172 if (data[0] != WACOM_REPORT_PENABLED) {
173 dev_dbg(input->dev.parent,
174 "%s: received unknown report #%d\n", __func__, data[0]);
178 prox = data[1] & 0x40;
181 if ((data[0] & 0x10) || (data[4] & 0x20)) {
182 wacom->tool[0] = BTN_TOOL_RUBBER;
183 wacom->id[0] = ERASER_DEVICE_ID;
186 wacom->tool[0] = BTN_TOOL_PEN;
187 wacom->id[0] = STYLUS_DEVICE_ID;
191 /* If the eraser is in prox, STYLUS2 is always set. If we
192 * mis-detected the type and notice that STYLUS2 isn't set
193 * then force the eraser out of prox and let the pen in.
195 if (wacom->tool[0] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
196 input_report_key(input, BTN_TOOL_RUBBER, 0);
197 input_report_abs(input, ABS_MISC, 0);
199 wacom->tool[0] = BTN_TOOL_PEN;
200 wacom->id[0] = STYLUS_DEVICE_ID;
204 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
205 if (features->pressure_max > 255)
206 pressure = (pressure << 1) | ((data[4] >> 6) & 1);
207 pressure += (features->pressure_max + 1) / 2;
209 input_report_abs(input, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
210 input_report_abs(input, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
211 input_report_abs(input, ABS_PRESSURE, pressure);
213 input_report_key(input, BTN_TOUCH, data[4] & 0x08);
214 input_report_key(input, BTN_STYLUS, data[4] & 0x10);
215 /* Only allow the stylus2 button to be reported for the pen tool. */
216 input_report_key(input, BTN_STYLUS2, (wacom->tool[0] == BTN_TOOL_PEN) && (data[4] & 0x20));
221 input_report_key(input, wacom->tool[0], prox);
222 input_report_abs(input, ABS_MISC, wacom->id[0]);
226 static int wacom_ptu_irq(struct wacom_wac *wacom)
228 unsigned char *data = wacom->data;
229 struct input_dev *input = wacom->pen_input;
231 if (data[0] != WACOM_REPORT_PENABLED) {
232 dev_dbg(input->dev.parent,
233 "%s: received unknown report #%d\n", __func__, data[0]);
237 if (data[1] & 0x04) {
238 input_report_key(input, BTN_TOOL_RUBBER, data[1] & 0x20);
239 input_report_key(input, BTN_TOUCH, data[1] & 0x08);
240 wacom->id[0] = ERASER_DEVICE_ID;
242 input_report_key(input, BTN_TOOL_PEN, data[1] & 0x20);
243 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
244 wacom->id[0] = STYLUS_DEVICE_ID;
246 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
247 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
248 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
249 input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6]));
250 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
251 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
255 static int wacom_dtu_irq(struct wacom_wac *wacom)
257 unsigned char *data = wacom->data;
258 struct input_dev *input = wacom->pen_input;
259 int prox = data[1] & 0x20;
261 dev_dbg(input->dev.parent,
262 "%s: received report #%d", __func__, data[0]);
265 /* Going into proximity select tool */
266 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
267 if (wacom->tool[0] == BTN_TOOL_PEN)
268 wacom->id[0] = STYLUS_DEVICE_ID;
270 wacom->id[0] = ERASER_DEVICE_ID;
272 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
273 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
274 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
275 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
276 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x01) << 8) | data[6]);
277 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
278 if (!prox) /* out-prox */
280 input_report_key(input, wacom->tool[0], prox);
281 input_report_abs(input, ABS_MISC, wacom->id[0]);
285 static int wacom_dtus_irq(struct wacom_wac *wacom)
287 unsigned char *data = wacom->data;
288 struct input_dev *input = wacom->pen_input;
289 unsigned short prox, pressure = 0;
291 if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) {
292 dev_dbg(input->dev.parent,
293 "%s: received unknown report #%d", __func__, data[0]);
295 } else if (data[0] == WACOM_REPORT_DTUSPAD) {
296 input = wacom->pad_input;
297 input_report_key(input, BTN_0, (data[1] & 0x01));
298 input_report_key(input, BTN_1, (data[1] & 0x02));
299 input_report_key(input, BTN_2, (data[1] & 0x04));
300 input_report_key(input, BTN_3, (data[1] & 0x08));
301 input_report_abs(input, ABS_MISC,
302 data[1] & 0x0f ? PAD_DEVICE_ID : 0);
305 prox = data[1] & 0x80;
307 switch ((data[1] >> 3) & 3) {
309 wacom->tool[0] = BTN_TOOL_RUBBER;
310 wacom->id[0] = ERASER_DEVICE_ID;
314 wacom->tool[0] = BTN_TOOL_PEN;
315 wacom->id[0] = STYLUS_DEVICE_ID;
320 input_report_key(input, BTN_STYLUS, data[1] & 0x20);
321 input_report_key(input, BTN_STYLUS2, data[1] & 0x40);
322 input_report_abs(input, ABS_X, get_unaligned_be16(&data[3]));
323 input_report_abs(input, ABS_Y, get_unaligned_be16(&data[5]));
324 pressure = ((data[1] & 0x03) << 8) | (data[2] & 0xff);
325 input_report_abs(input, ABS_PRESSURE, pressure);
326 input_report_key(input, BTN_TOUCH, pressure > 10);
328 if (!prox) /* out-prox */
330 input_report_key(input, wacom->tool[0], prox);
331 input_report_abs(input, ABS_MISC, wacom->id[0]);
336 static int wacom_graphire_irq(struct wacom_wac *wacom)
338 struct wacom_features *features = &wacom->features;
339 unsigned char *data = wacom->data;
340 struct input_dev *input = wacom->pen_input;
341 struct input_dev *pad_input = wacom->pad_input;
342 int battery_capacity, ps_connected;
347 if (features->type == GRAPHIRE_BT) {
348 if (data[0] != WACOM_REPORT_PENABLED_BT) {
349 dev_dbg(input->dev.parent,
350 "%s: received unknown report #%d\n", __func__,
354 } else if (data[0] != WACOM_REPORT_PENABLED) {
355 dev_dbg(input->dev.parent,
356 "%s: received unknown report #%d\n", __func__, data[0]);
360 prox = data[1] & 0x80;
361 if (prox || wacom->id[0]) {
363 switch ((data[1] >> 5) & 3) {
366 wacom->tool[0] = BTN_TOOL_PEN;
367 wacom->id[0] = STYLUS_DEVICE_ID;
371 wacom->tool[0] = BTN_TOOL_RUBBER;
372 wacom->id[0] = ERASER_DEVICE_ID;
375 case 2: /* Mouse with wheel */
376 input_report_key(input, BTN_MIDDLE, data[1] & 0x04);
379 case 3: /* Mouse without wheel */
380 wacom->tool[0] = BTN_TOOL_MOUSE;
381 wacom->id[0] = CURSOR_DEVICE_ID;
385 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
386 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
387 if (wacom->tool[0] != BTN_TOOL_MOUSE) {
388 if (features->type == GRAPHIRE_BT)
389 input_report_abs(input, ABS_PRESSURE, data[6] |
390 (((__u16) (data[1] & 0x08)) << 5));
392 input_report_abs(input, ABS_PRESSURE, data[6] |
393 ((data[7] & 0x03) << 8));
394 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
395 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
396 input_report_key(input, BTN_STYLUS2, data[1] & 0x04);
398 input_report_key(input, BTN_LEFT, data[1] & 0x01);
399 input_report_key(input, BTN_RIGHT, data[1] & 0x02);
400 if (features->type == WACOM_G4 ||
401 features->type == WACOM_MO) {
402 input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f);
403 rw = (data[7] & 0x04) - (data[7] & 0x03);
404 } else if (features->type == GRAPHIRE_BT) {
405 /* Compute distance between mouse and tablet */
406 rw = 44 - (data[6] >> 2);
407 rw = clamp_val(rw, 0, 31);
408 input_report_abs(input, ABS_DISTANCE, rw);
409 if (((data[1] >> 5) & 3) == 2) {
410 /* Mouse with wheel */
411 input_report_key(input, BTN_MIDDLE,
413 rw = (data[6] & 0x01) ? -1 :
414 (data[6] & 0x02) ? 1 : 0;
419 input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f);
420 rw = -(signed char)data[6];
422 input_report_rel(input, REL_WHEEL, rw);
427 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
428 input_report_key(input, wacom->tool[0], prox);
429 input_sync(input); /* sync last event */
433 switch (features->type) {
435 prox = data[7] & 0xf8;
436 if (prox || wacom->id[1]) {
437 wacom->id[1] = PAD_DEVICE_ID;
438 input_report_key(pad_input, BTN_BACK, (data[7] & 0x40));
439 input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x80));
440 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
441 input_report_rel(pad_input, REL_WHEEL, rw);
444 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
450 prox = (data[7] & 0xf8) || data[8];
451 if (prox || wacom->id[1]) {
452 wacom->id[1] = PAD_DEVICE_ID;
453 input_report_key(pad_input, BTN_BACK, (data[7] & 0x08));
454 input_report_key(pad_input, BTN_LEFT, (data[7] & 0x20));
455 input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x10));
456 input_report_key(pad_input, BTN_RIGHT, (data[7] & 0x40));
457 input_report_abs(pad_input, ABS_WHEEL, (data[8] & 0x7f));
460 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
465 prox = data[7] & 0x03;
466 if (prox || wacom->id[1]) {
467 wacom->id[1] = PAD_DEVICE_ID;
468 input_report_key(pad_input, BTN_0, (data[7] & 0x02));
469 input_report_key(pad_input, BTN_1, (data[7] & 0x01));
472 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
478 /* Store current battery capacity and power supply state */
479 if (features->type == GRAPHIRE_BT) {
480 rw = (data[7] >> 2 & 0x07);
481 battery_capacity = batcap_gr[rw];
482 ps_connected = rw == 7;
483 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
484 battery_capacity, ps_connected, 1,
491 static void wacom_intuos_schedule_prox_event(struct wacom_wac *wacom_wac)
493 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
494 struct wacom_features *features = &wacom_wac->features;
495 struct hid_report *r;
496 struct hid_report_enum *re;
498 re = &(wacom->hdev->report_enum[HID_FEATURE_REPORT]);
499 if (features->type == INTUOSHT2)
500 r = re->report_id_hash[WACOM_REPORT_INTUOSHT2_ID];
502 r = re->report_id_hash[WACOM_REPORT_INTUOS_ID1];
504 hid_hw_request(wacom->hdev, r, HID_REQ_GET_REPORT);
508 static int wacom_intuos_pad(struct wacom_wac *wacom)
510 struct wacom_features *features = &wacom->features;
511 unsigned char *data = wacom->data;
512 struct input_dev *input = wacom->pad_input;
514 int buttons = 0, nbuttons = features->numbered_buttons;
515 int keys = 0, nkeys = 0;
516 int ring1 = 0, ring2 = 0;
517 int strip1 = 0, strip2 = 0;
519 bool wrench = false, keyboard = false, mute_touch = false, menu = false,
522 /* pad packets. Works as a second tool and is always in prox */
523 if (!(data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD ||
524 data[0] == WACOM_REPORT_CINTIQPAD))
527 if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
528 buttons = (data[3] << 1) | (data[2] & 0x01);
530 } else if (features->type == DTK) {
532 } else if (features->type == WACOM_13HD) {
533 buttons = (data[4] << 1) | (data[3] & 0x01);
534 } else if (features->type == WACOM_24HD) {
535 buttons = (data[8] << 8) | data[6];
540 * Three "buttons" are available on the 24HD which are
541 * physically implemented as a touchstrip. Each button
542 * is approximately 3 bits wide with a 2 bit spacing.
543 * The raw touchstrip bits are stored at:
544 * ((data[3] & 0x1f) << 8) | data[4])
547 keys = ((data[3] & 0x1C) ? 1<<2 : 0) |
548 ((data[4] & 0xE0) ? 1<<1 : 0) |
549 ((data[4] & 0x07) ? 1<<0 : 0);
550 keyboard = !!(data[4] & 0xE0);
551 info = !!(data[3] & 0x1C);
553 if (features->oPid) {
554 mute_touch = !!(data[4] & 0x07);
556 wacom->shared->is_touch_on =
557 !wacom->shared->is_touch_on;
559 wrench = !!(data[4] & 0x07);
561 } else if (features->type == WACOM_27QHD) {
563 keys = data[2] & 0x07;
565 wrench = !!(data[2] & 0x01);
566 keyboard = !!(data[2] & 0x02);
568 if (features->oPid) {
569 mute_touch = !!(data[2] & 0x04);
571 wacom->shared->is_touch_on =
572 !wacom->shared->is_touch_on;
574 menu = !!(data[2] & 0x04);
576 input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[4]));
577 input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[6]));
578 input_report_abs(input, ABS_Z, be16_to_cpup((__be16 *)&data[8]));
579 } else if (features->type == CINTIQ_HYBRID) {
581 * Do not send hardware buttons under Android. They
582 * are already sent to the system through GPIO (and
583 * have different meaning).
585 * d-pad right -> data[4] & 0x10
586 * d-pad up -> data[4] & 0x20
587 * d-pad left -> data[4] & 0x40
588 * d-pad down -> data[4] & 0x80
589 * d-pad center -> data[3] & 0x01
591 buttons = (data[4] << 1) | (data[3] & 0x01);
592 } else if (features->type == CINTIQ_COMPANION_2) {
593 /* d-pad right -> data[2] & 0x10
594 * d-pad up -> data[2] & 0x20
595 * d-pad left -> data[2] & 0x40
596 * d-pad down -> data[2] & 0x80
597 * d-pad center -> data[1] & 0x01
599 buttons = ((data[2] >> 4) << 7) |
600 ((data[1] & 0x04) << 4) |
601 ((data[2] & 0x0F) << 2) |
603 } else if (features->type >= INTUOS5S && features->type <= INTUOSPL) {
605 * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in
606 * addition to the mechanical switch. Switch data is
607 * stored in data[4], capacitive data in data[5].
609 * Touch ring mode switch (data[3]) has no capacitive sensor
611 buttons = (data[4] << 1) | (data[3] & 0x01);
614 if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) {
615 buttons = (data[8] << 10) | ((data[7] & 0x01) << 9) |
616 (data[6] << 1) | (data[5] & 0x01);
618 if (features->type == WACOM_22HD) {
620 keys = data[9] & 0x07;
622 info = !!(data[9] & 0x01);
623 wrench = !!(data[9] & 0x02);
626 buttons = ((data[6] & 0x10) << 5) |
627 ((data[5] & 0x10) << 4) |
628 ((data[6] & 0x0F) << 4) |
631 strip1 = ((data[1] & 0x1f) << 8) | data[2];
632 strip2 = ((data[3] & 0x1f) << 8) | data[4];
635 prox = (buttons & ~(~0U << nbuttons)) | (keys & ~(~0U << nkeys)) |
636 (ring1 & 0x80) | (ring2 & 0x80) | strip1 | strip2;
638 wacom_report_numbered_buttons(input, nbuttons, buttons);
640 for (i = 0; i < nkeys; i++)
641 input_report_key(input, KEY_PROG1 + i, keys & (1 << i));
643 input_report_key(input, KEY_BUTTONCONFIG, wrench);
644 input_report_key(input, KEY_ONSCREEN_KEYBOARD, keyboard);
645 input_report_key(input, KEY_CONTROLPANEL, menu);
646 input_report_key(input, KEY_INFO, info);
648 if (wacom->shared && wacom->shared->touch_input) {
649 input_report_switch(wacom->shared->touch_input,
651 !wacom->shared->is_touch_on);
652 input_sync(wacom->shared->touch_input);
655 input_report_abs(input, ABS_RX, strip1);
656 input_report_abs(input, ABS_RY, strip2);
658 input_report_abs(input, ABS_WHEEL, (ring1 & 0x80) ? (ring1 & 0x7f) : 0);
659 input_report_abs(input, ABS_THROTTLE, (ring2 & 0x80) ? (ring2 & 0x7f) : 0);
661 input_report_key(input, wacom->tool[1], prox ? 1 : 0);
662 input_report_abs(input, ABS_MISC, prox ? PAD_DEVICE_ID : 0);
664 input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff);
669 static int wacom_intuos_id_mangle(int tool_id)
671 return (tool_id & ~0xFFF) << 4 | (tool_id & 0xFFF);
674 static bool wacom_is_art_pen(int tool_id)
676 bool is_art_pen = false;
679 case 0x885: /* Intuos3 Marker Pen */
680 case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
681 case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */
688 static int wacom_intuos_get_tool_type(int tool_id)
690 int tool_type = BTN_TOOL_PEN;
692 if (wacom_is_art_pen(tool_id))
696 case 0x812: /* Inking pen */
697 case 0x801: /* Intuos3 Inking pen */
698 case 0x12802: /* Intuos4/5 Inking Pen */
700 tool_type = BTN_TOOL_PENCIL;
703 case 0x822: /* Pen */
706 case 0x823: /* Intuos3 Grip Pen */
707 case 0x813: /* Intuos3 Classic Pen */
708 case 0x802: /* Intuos4/5 13HD/24HD General Pen */
709 case 0x8e2: /* IntuosHT2 pen */
711 case 0x200: /* Pro Pen 3 */
712 case 0x04200: /* Pro Pen 3 */
713 case 0x10842: /* MobileStudio Pro Pro Pen slim */
714 case 0x14802: /* Intuos4/5 13HD/24HD Classic Pen */
715 case 0x16802: /* Cintiq 13HD Pro Pen */
716 case 0x18802: /* DTH2242 Pen */
717 case 0x10802: /* Intuos4/5 13HD/24HD General Pen */
718 case 0x80842: /* Intuos Pro and Cintiq Pro 3D Pen */
719 tool_type = BTN_TOOL_PEN;
722 case 0x832: /* Stroke pen */
724 tool_type = BTN_TOOL_BRUSH;
727 case 0x007: /* Mouse 4D and 2D */
730 case 0x017: /* Intuos3 2D Mouse */
731 case 0x806: /* Intuos4 Mouse */
732 tool_type = BTN_TOOL_MOUSE;
735 case 0x096: /* Lens cursor */
736 case 0x097: /* Intuos3 Lens cursor */
737 case 0x006: /* Intuos4 Lens cursor */
738 tool_type = BTN_TOOL_LENS;
741 case 0x82a: /* Eraser */
747 case 0x82b: /* Intuos3 Grip Pen Eraser */
748 case 0x81b: /* Intuos3 Classic Pen Eraser */
749 case 0x91b: /* Intuos3 Airbrush Eraser */
750 case 0x80c: /* Intuos4/5 13HD/24HD Marker Pen Eraser */
751 case 0x80a: /* Intuos4/5 13HD/24HD General Pen Eraser */
752 case 0x90a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
753 case 0x1480a: /* Intuos4/5 13HD/24HD Classic Pen Eraser */
754 case 0x1090a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
755 case 0x1080c: /* Intuos4/5 13HD/24HD Art Pen Eraser */
756 case 0x1084a: /* MobileStudio Pro Pro Pen slim Eraser */
757 case 0x1680a: /* Cintiq 13HD Pro Pen Eraser */
758 case 0x1880a: /* DTH2242 Eraser */
759 case 0x1080a: /* Intuos4/5 13HD/24HD General Pen Eraser */
760 tool_type = BTN_TOOL_RUBBER;
766 case 0x913: /* Intuos3 Airbrush */
767 case 0x902: /* Intuos4/5 13HD/24HD Airbrush */
768 case 0x10902: /* Intuos4/5 13HD/24HD Airbrush */
769 tool_type = BTN_TOOL_AIRBRUSH;
775 static void wacom_exit_report(struct wacom_wac *wacom)
777 struct input_dev *input = wacom->pen_input;
778 struct wacom_features *features = &wacom->features;
779 unsigned char *data = wacom->data;
780 int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
783 * Reset all states otherwise we lose the initial states
784 * when in-prox next time
786 input_report_abs(input, ABS_X, 0);
787 input_report_abs(input, ABS_Y, 0);
788 input_report_abs(input, ABS_DISTANCE, 0);
789 input_report_abs(input, ABS_TILT_X, 0);
790 input_report_abs(input, ABS_TILT_Y, 0);
791 if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
792 input_report_key(input, BTN_LEFT, 0);
793 input_report_key(input, BTN_MIDDLE, 0);
794 input_report_key(input, BTN_RIGHT, 0);
795 input_report_key(input, BTN_SIDE, 0);
796 input_report_key(input, BTN_EXTRA, 0);
797 input_report_abs(input, ABS_THROTTLE, 0);
798 input_report_abs(input, ABS_RZ, 0);
800 input_report_abs(input, ABS_PRESSURE, 0);
801 input_report_key(input, BTN_STYLUS, 0);
802 input_report_key(input, BTN_STYLUS2, 0);
803 input_report_key(input, BTN_TOUCH, 0);
804 input_report_abs(input, ABS_WHEEL, 0);
805 if (features->type >= INTUOS3S)
806 input_report_abs(input, ABS_Z, 0);
808 input_report_key(input, wacom->tool[idx], 0);
809 input_report_abs(input, ABS_MISC, 0); /* reset tool id */
810 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
814 static int wacom_intuos_inout(struct wacom_wac *wacom)
816 struct wacom_features *features = &wacom->features;
817 unsigned char *data = wacom->data;
818 struct input_dev *input = wacom->pen_input;
819 int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
821 if (!(((data[1] & 0xfc) == 0xc0) || /* in prox */
822 ((data[1] & 0xfe) == 0x20) || /* in range */
823 ((data[1] & 0xfe) == 0x80))) /* out prox */
827 if ((data[1] & 0xfc) == 0xc0) {
828 /* serial number of the tool */
829 wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
830 (data[4] << 20) + (data[5] << 12) +
831 (data[6] << 4) + (data[7] >> 4);
833 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) |
834 ((data[7] & 0x0f) << 16) | ((data[8] & 0xf0) << 8);
836 wacom->tool[idx] = wacom_intuos_get_tool_type(wacom->id[idx]);
838 wacom->shared->stylus_in_proximity = true;
843 if ((data[1] & 0xfe) == 0x20) {
844 if (features->type != INTUOSHT2)
845 wacom->shared->stylus_in_proximity = true;
847 /* in Range while exiting */
848 if (wacom->reporting_data) {
849 input_report_key(input, BTN_TOUCH, 0);
850 input_report_abs(input, ABS_PRESSURE, 0);
851 input_report_abs(input, ABS_DISTANCE, wacom->features.distance_max);
858 if ((data[1] & 0xfe) == 0x80) {
859 wacom->shared->stylus_in_proximity = false;
860 wacom->reporting_data = false;
862 /* don't report exit if we don't know the ID */
866 wacom_exit_report(wacom);
873 static inline bool touch_is_muted(struct wacom_wac *wacom_wac)
875 return wacom_wac->probe_complete &&
876 wacom_wac->shared->has_mute_touch_switch &&
877 !wacom_wac->shared->is_touch_on;
880 static inline bool report_touch_events(struct wacom_wac *wacom)
882 return (touch_arbitration ? !wacom->shared->stylus_in_proximity : 1);
885 static inline bool delay_pen_events(struct wacom_wac *wacom)
887 return (wacom->shared->touch_down && touch_arbitration);
890 static int wacom_intuos_general(struct wacom_wac *wacom)
892 struct wacom_features *features = &wacom->features;
893 unsigned char *data = wacom->data;
894 struct input_dev *input = wacom->pen_input;
895 int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
896 unsigned char type = (data[1] >> 1) & 0x0F;
897 unsigned int x, y, distance, t;
899 if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_CINTIQ &&
900 data[0] != WACOM_REPORT_INTUOS_PEN)
903 if (delay_pen_events(wacom))
906 /* don't report events if we don't know the tool ID */
907 if (!wacom->id[idx]) {
908 /* but reschedule a read of the current tool */
909 wacom_intuos_schedule_prox_event(wacom);
914 * don't report events for invalid data
916 /* older I4 styli don't work with new Cintiqs */
917 if ((!((wacom->id[idx] >> 16) & 0x01) &&
918 (features->type == WACOM_21UX2)) ||
919 /* Only large Intuos support Lense Cursor */
920 (wacom->tool[idx] == BTN_TOOL_LENS &&
921 (features->type == INTUOS3 ||
922 features->type == INTUOS3S ||
923 features->type == INTUOS4 ||
924 features->type == INTUOS4S ||
925 features->type == INTUOS5 ||
926 features->type == INTUOS5S ||
927 features->type == INTUOSPM ||
928 features->type == INTUOSPS)) ||
929 /* Cintiq doesn't send data when RDY bit isn't set */
930 (features->type == CINTIQ && !(data[1] & 0x40)))
933 x = (be16_to_cpup((__be16 *)&data[2]) << 1) | ((data[9] >> 1) & 1);
934 y = (be16_to_cpup((__be16 *)&data[4]) << 1) | (data[9] & 1);
935 distance = data[9] >> 2;
936 if (features->type < INTUOS3S) {
941 if (features->type == INTUOSHT2)
942 distance = features->distance_max - distance;
943 input_report_abs(input, ABS_X, x);
944 input_report_abs(input, ABS_Y, y);
945 input_report_abs(input, ABS_DISTANCE, distance);
952 /* general pen packet */
953 t = (data[6] << 3) | ((data[7] & 0xC0) >> 5) | (data[1] & 1);
954 if (features->pressure_max < 2047)
956 input_report_abs(input, ABS_PRESSURE, t);
957 if (features->type != INTUOSHT2) {
958 input_report_abs(input, ABS_TILT_X,
959 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
960 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
962 input_report_key(input, BTN_STYLUS, data[1] & 2);
963 input_report_key(input, BTN_STYLUS2, data[1] & 4);
964 input_report_key(input, BTN_TOUCH, t > 10);
968 /* airbrush second packet */
969 input_report_abs(input, ABS_WHEEL,
970 (data[6] << 2) | ((data[7] >> 6) & 3));
971 input_report_abs(input, ABS_TILT_X,
972 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
973 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
977 /* Rotation packet */
978 if (features->type >= INTUOS3S) {
979 /* I3 marker pen rotation */
980 t = (data[6] << 3) | ((data[7] >> 5) & 7);
981 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
982 ((t-1) / 2 + 450)) : (450 - t / 2) ;
983 input_report_abs(input, ABS_Z, t);
985 /* 4D mouse 2nd packet */
986 t = (data[6] << 3) | ((data[7] >> 5) & 7);
987 input_report_abs(input, ABS_RZ, (data[7] & 0x20) ?
988 ((t - 1) / 2) : -t / 2);
993 /* 4D mouse 1st packet */
994 input_report_key(input, BTN_LEFT, data[8] & 0x01);
995 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
996 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
998 input_report_key(input, BTN_SIDE, data[8] & 0x20);
999 input_report_key(input, BTN_EXTRA, data[8] & 0x10);
1000 t = (data[6] << 2) | ((data[7] >> 6) & 3);
1001 input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
1006 input_report_key(input, BTN_LEFT, data[6] & 0x01);
1007 input_report_key(input, BTN_MIDDLE, data[6] & 0x02);
1008 input_report_key(input, BTN_RIGHT, data[6] & 0x04);
1009 input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7)
1010 - ((data[7] & 0x40) >> 6));
1011 input_report_key(input, BTN_SIDE, data[6] & 0x08);
1012 input_report_key(input, BTN_EXTRA, data[6] & 0x10);
1014 input_report_abs(input, ABS_TILT_X,
1015 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
1016 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
1020 if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
1021 /* 2D mouse packet */
1022 input_report_key(input, BTN_LEFT, data[8] & 0x04);
1023 input_report_key(input, BTN_MIDDLE, data[8] & 0x08);
1024 input_report_key(input, BTN_RIGHT, data[8] & 0x10);
1025 input_report_rel(input, REL_WHEEL, (data[8] & 0x01)
1026 - ((data[8] & 0x02) >> 1));
1028 /* I3 2D mouse side buttons */
1029 if (features->type >= INTUOS3S && features->type <= INTUOS3L) {
1030 input_report_key(input, BTN_SIDE, data[8] & 0x40);
1031 input_report_key(input, BTN_EXTRA, data[8] & 0x20);
1034 else if (wacom->tool[idx] == BTN_TOOL_LENS) {
1035 /* Lens cursor packets */
1036 input_report_key(input, BTN_LEFT, data[8] & 0x01);
1037 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
1038 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
1039 input_report_key(input, BTN_SIDE, data[8] & 0x10);
1040 input_report_key(input, BTN_EXTRA, data[8] & 0x08);
1055 input_report_abs(input, ABS_MISC,
1056 wacom_intuos_id_mangle(wacom->id[idx])); /* report tool id */
1057 input_report_key(input, wacom->tool[idx], 1);
1058 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
1059 wacom->reporting_data = true;
1063 static int wacom_intuos_irq(struct wacom_wac *wacom)
1065 unsigned char *data = wacom->data;
1066 struct input_dev *input = wacom->pen_input;
1069 if (data[0] != WACOM_REPORT_PENABLED &&
1070 data[0] != WACOM_REPORT_INTUOS_ID1 &&
1071 data[0] != WACOM_REPORT_INTUOS_ID2 &&
1072 data[0] != WACOM_REPORT_INTUOSPAD &&
1073 data[0] != WACOM_REPORT_INTUOS_PEN &&
1074 data[0] != WACOM_REPORT_CINTIQ &&
1075 data[0] != WACOM_REPORT_CINTIQPAD &&
1076 data[0] != WACOM_REPORT_INTUOS5PAD) {
1077 dev_dbg(input->dev.parent,
1078 "%s: received unknown report #%d\n", __func__, data[0]);
1082 /* process pad events */
1083 result = wacom_intuos_pad(wacom);
1087 /* process in/out prox events */
1088 result = wacom_intuos_inout(wacom);
1092 /* process general packets */
1093 result = wacom_intuos_general(wacom);
1100 static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len)
1102 unsigned char *data = wacom_wac->data;
1103 struct input_dev *input;
1104 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
1105 struct wacom_remote *remote = wacom->remote;
1106 int bat_charging, bat_percent, touch_ring_mode;
1109 unsigned long flags;
1111 if (data[0] != WACOM_REPORT_REMOTE) {
1112 hid_dbg(wacom->hdev, "%s: received unknown report #%d",
1117 serial = data[3] + (data[4] << 8) + (data[5] << 16);
1118 wacom_wac->id[0] = PAD_DEVICE_ID;
1120 spin_lock_irqsave(&remote->remote_lock, flags);
1122 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
1123 if (remote->remotes[i].serial == serial) {
1129 if (index < 0 || !remote->remotes[index].registered)
1132 input = remote->remotes[index].input;
1134 input_report_key(input, BTN_0, (data[9] & 0x01));
1135 input_report_key(input, BTN_1, (data[9] & 0x02));
1136 input_report_key(input, BTN_2, (data[9] & 0x04));
1137 input_report_key(input, BTN_3, (data[9] & 0x08));
1138 input_report_key(input, BTN_4, (data[9] & 0x10));
1139 input_report_key(input, BTN_5, (data[9] & 0x20));
1140 input_report_key(input, BTN_6, (data[9] & 0x40));
1141 input_report_key(input, BTN_7, (data[9] & 0x80));
1143 input_report_key(input, BTN_8, (data[10] & 0x01));
1144 input_report_key(input, BTN_9, (data[10] & 0x02));
1145 input_report_key(input, BTN_A, (data[10] & 0x04));
1146 input_report_key(input, BTN_B, (data[10] & 0x08));
1147 input_report_key(input, BTN_C, (data[10] & 0x10));
1148 input_report_key(input, BTN_X, (data[10] & 0x20));
1149 input_report_key(input, BTN_Y, (data[10] & 0x40));
1150 input_report_key(input, BTN_Z, (data[10] & 0x80));
1152 input_report_key(input, BTN_BASE, (data[11] & 0x01));
1153 input_report_key(input, BTN_BASE2, (data[11] & 0x02));
1155 if (data[12] & 0x80)
1156 input_report_abs(input, ABS_WHEEL, (data[12] & 0x7f) - 1);
1158 input_report_abs(input, ABS_WHEEL, 0);
1160 bat_percent = data[7] & 0x7f;
1161 bat_charging = !!(data[7] & 0x80);
1163 if (data[9] | data[10] | (data[11] & 0x03) | data[12])
1164 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
1166 input_report_abs(input, ABS_MISC, 0);
1168 input_event(input, EV_MSC, MSC_SERIAL, serial);
1172 /*Which mode select (LED light) is currently on?*/
1173 touch_ring_mode = (data[11] & 0xC0) >> 6;
1175 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
1176 if (remote->remotes[i].serial == serial)
1177 wacom->led.groups[i].select = touch_ring_mode;
1180 __wacom_notify_battery(&remote->remotes[index].battery,
1181 WACOM_POWER_SUPPLY_STATUS_AUTO, bat_percent,
1182 bat_charging, 1, bat_charging);
1185 spin_unlock_irqrestore(&remote->remote_lock, flags);
1189 static void wacom_remote_status_irq(struct wacom_wac *wacom_wac, size_t len)
1191 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
1192 unsigned char *data = wacom_wac->data;
1193 struct wacom_remote *remote = wacom->remote;
1194 struct wacom_remote_data remote_data;
1195 unsigned long flags;
1198 if (data[0] != WACOM_REPORT_DEVICE_LIST)
1201 memset(&remote_data, 0, sizeof(struct wacom_remote_data));
1203 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
1205 int serial = (data[j+6] << 16) + (data[j+5] << 8) + data[j+4];
1206 bool connected = data[j+2];
1208 remote_data.remote[i].serial = serial;
1209 remote_data.remote[i].connected = connected;
1212 spin_lock_irqsave(&remote->remote_lock, flags);
1214 ret = kfifo_in(&remote->remote_fifo, &remote_data, sizeof(remote_data));
1215 if (ret != sizeof(remote_data)) {
1216 spin_unlock_irqrestore(&remote->remote_lock, flags);
1217 hid_err(wacom->hdev, "Can't queue Remote status event.\n");
1221 spin_unlock_irqrestore(&remote->remote_lock, flags);
1223 wacom_schedule_work(wacom_wac, WACOM_WORKER_REMOTE);
1226 static int int_dist(int x1, int y1, int x2, int y2)
1231 return int_sqrt(x*x + y*y);
1234 static void wacom_intuos_bt_process_data(struct wacom_wac *wacom,
1235 unsigned char *data)
1237 memcpy(wacom->data, data, 10);
1238 wacom_intuos_irq(wacom);
1240 input_sync(wacom->pen_input);
1241 if (wacom->pad_input)
1242 input_sync(wacom->pad_input);
1245 static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
1247 unsigned char data[WACOM_PKGLEN_MAX];
1249 unsigned power_raw, battery_capacity, bat_charging, ps_connected;
1251 memcpy(data, wacom->data, len);
1255 wacom_intuos_bt_process_data(wacom, data + i);
1259 wacom_intuos_bt_process_data(wacom, data + i);
1261 wacom_intuos_bt_process_data(wacom, data + i);
1263 power_raw = data[i];
1264 bat_charging = (power_raw & 0x08) ? 1 : 0;
1265 ps_connected = (power_raw & 0x10) ? 1 : 0;
1266 battery_capacity = batcap_i4[power_raw & 0x07];
1267 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
1268 battery_capacity, bat_charging,
1269 battery_capacity || bat_charging,
1273 dev_dbg(wacom->pen_input->dev.parent,
1274 "Unknown report: %d,%d size:%zu\n",
1275 data[0], data[1], len);
1281 static int wacom_wac_finger_count_touches(struct wacom_wac *wacom)
1283 struct input_dev *input = wacom->touch_input;
1284 unsigned touch_max = wacom->features.touch_max;
1292 return test_bit(BTN_TOUCH, input->key) &&
1293 report_touch_events(wacom);
1295 for (i = 0; i < input->mt->num_slots; i++) {
1296 struct input_mt_slot *ps = &input->mt->slots[i];
1297 int id = input_mt_get_value(ps, ABS_MT_TRACKING_ID);
1305 static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
1307 int pen_frame_len, pen_frames;
1309 struct input_dev *pen_input = wacom->pen_input;
1310 unsigned char *data = wacom->data;
1313 if (wacom->features.type == INTUOSP2_BT ||
1314 wacom->features.type == INTUOSP2S_BT) {
1315 wacom->serial[0] = get_unaligned_le64(&data[99]);
1316 wacom->id[0] = get_unaligned_le16(&data[107]);
1320 wacom->serial[0] = get_unaligned_le64(&data[33]);
1321 wacom->id[0] = get_unaligned_le16(&data[41]);
1326 if (wacom->serial[0] >> 52 == 1) {
1327 /* Add back in missing bits of ID for non-USI pens */
1328 wacom->id[0] |= (wacom->serial[0] >> 32) & 0xFFFFF;
1331 for (i = 0; i < pen_frames; i++) {
1332 unsigned char *frame = &data[i*pen_frame_len + 1];
1333 bool valid = frame[0] & 0x80;
1334 bool prox = frame[0] & 0x40;
1335 bool range = frame[0] & 0x20;
1336 bool invert = frame[0] & 0x10;
1342 wacom->shared->stylus_in_proximity = false;
1343 wacom_exit_report(wacom);
1344 input_sync(pen_input);
1348 wacom->serial[0] = 0;
1353 if (!wacom->tool[0]) { /* first in range */
1354 /* Going into range select tool */
1356 wacom->tool[0] = BTN_TOOL_RUBBER;
1357 else if (wacom->id[0])
1358 wacom->tool[0] = wacom_intuos_get_tool_type(wacom->id[0]);
1360 wacom->tool[0] = BTN_TOOL_PEN;
1363 input_report_abs(pen_input, ABS_X, get_unaligned_le16(&frame[1]));
1364 input_report_abs(pen_input, ABS_Y, get_unaligned_le16(&frame[3]));
1366 if (wacom->features.type == INTUOSP2_BT ||
1367 wacom->features.type == INTUOSP2S_BT) {
1368 /* Fix rotation alignment: userspace expects zero at left */
1370 (int16_t)get_unaligned_le16(&frame[9]);
1376 input_report_abs(pen_input, ABS_TILT_X,
1378 input_report_abs(pen_input, ABS_TILT_Y,
1380 input_report_abs(pen_input, ABS_Z, rotation);
1381 input_report_abs(pen_input, ABS_WHEEL,
1382 get_unaligned_le16(&frame[11]));
1385 if (wacom->tool[0]) {
1386 input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5]));
1387 if (wacom->features.type == INTUOSP2_BT ||
1388 wacom->features.type == INTUOSP2S_BT) {
1389 input_report_abs(pen_input, ABS_DISTANCE,
1390 range ? frame[13] : wacom->features.distance_max);
1392 input_report_abs(pen_input, ABS_DISTANCE,
1393 range ? frame[7] : wacom->features.distance_max);
1396 input_report_key(pen_input, BTN_TOUCH, frame[0] & 0x09);
1397 input_report_key(pen_input, BTN_STYLUS, frame[0] & 0x02);
1398 input_report_key(pen_input, BTN_STYLUS2, frame[0] & 0x04);
1400 input_report_key(pen_input, wacom->tool[0], prox);
1401 input_event(pen_input, EV_MSC, MSC_SERIAL, wacom->serial[0]);
1402 input_report_abs(pen_input, ABS_MISC,
1403 wacom_intuos_id_mangle(wacom->id[0])); /* report tool id */
1406 wacom->shared->stylus_in_proximity = prox;
1408 input_sync(pen_input);
1412 static void wacom_intuos_pro2_bt_touch(struct wacom_wac *wacom)
1414 const int finger_touch_len = 8;
1415 const int finger_frames = 4;
1416 const int finger_frame_len = 43;
1418 struct input_dev *touch_input = wacom->touch_input;
1419 unsigned char *data = wacom->data;
1420 int num_contacts_left = 5;
1423 for (i = 0; i < finger_frames; i++) {
1424 unsigned char *frame = &data[i*finger_frame_len + 109];
1425 int current_num_contacts = frame[0] & 0x7F;
1426 int contacts_to_send;
1428 if (!(frame[0] & 0x80))
1432 * First packet resets the counter since only the first
1433 * packet in series will have non-zero current_num_contacts.
1435 if (current_num_contacts)
1436 wacom->num_contacts_left = current_num_contacts;
1438 contacts_to_send = min(num_contacts_left, wacom->num_contacts_left);
1440 for (j = 0; j < contacts_to_send; j++) {
1441 unsigned char *touch = &frame[j*finger_touch_len + 1];
1442 int slot = input_mt_get_slot_by_key(touch_input, touch[0]);
1443 int x = get_unaligned_le16(&touch[2]);
1444 int y = get_unaligned_le16(&touch[4]);
1445 int w = touch[6] * input_abs_get_res(touch_input, ABS_MT_POSITION_X);
1446 int h = touch[7] * input_abs_get_res(touch_input, ABS_MT_POSITION_Y);
1451 input_mt_slot(touch_input, slot);
1452 input_mt_report_slot_state(touch_input, MT_TOOL_FINGER, touch[1] & 0x01);
1453 input_report_abs(touch_input, ABS_MT_POSITION_X, x);
1454 input_report_abs(touch_input, ABS_MT_POSITION_Y, y);
1455 input_report_abs(touch_input, ABS_MT_TOUCH_MAJOR, max(w, h));
1456 input_report_abs(touch_input, ABS_MT_TOUCH_MINOR, min(w, h));
1457 input_report_abs(touch_input, ABS_MT_ORIENTATION, w > h);
1460 input_mt_sync_frame(touch_input);
1462 wacom->num_contacts_left -= contacts_to_send;
1463 if (wacom->num_contacts_left <= 0) {
1464 wacom->num_contacts_left = 0;
1465 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1466 input_sync(touch_input);
1470 if (wacom->num_contacts_left == 0) {
1471 // Be careful that we don't accidentally call input_sync with
1472 // only a partial set of fingers of processed
1473 input_report_switch(touch_input, SW_MUTE_DEVICE, !(data[281] >> 7));
1474 input_sync(touch_input);
1479 static void wacom_intuos_pro2_bt_pad(struct wacom_wac *wacom)
1481 struct input_dev *pad_input = wacom->pad_input;
1482 unsigned char *data = wacom->data;
1483 int nbuttons = wacom->features.numbered_buttons;
1485 int expresskeys = data[282];
1486 int center = (data[281] & 0x40) >> 6;
1487 int ring = data[285] & 0x7F;
1488 bool ringstatus = data[285] & 0x80;
1489 bool prox = expresskeys || center || ringstatus;
1491 /* Fix touchring data: userspace expects 0 at left and increasing clockwise */
1497 wacom_report_numbered_buttons(pad_input, nbuttons,
1498 expresskeys | (center << (nbuttons - 1)));
1500 input_report_abs(pad_input, ABS_WHEEL, ringstatus ? ring : 0);
1502 input_report_key(pad_input, wacom->tool[1], prox ? 1 : 0);
1503 input_report_abs(pad_input, ABS_MISC, prox ? PAD_DEVICE_ID : 0);
1504 input_event(pad_input, EV_MSC, MSC_SERIAL, 0xffffffff);
1506 input_sync(pad_input);
1509 static void wacom_intuos_pro2_bt_battery(struct wacom_wac *wacom)
1511 unsigned char *data = wacom->data;
1513 bool chg = data[284] & 0x80;
1514 int battery_status = data[284] & 0x7F;
1516 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
1517 battery_status, chg, 1, chg);
1520 static void wacom_intuos_gen3_bt_pad(struct wacom_wac *wacom)
1522 struct input_dev *pad_input = wacom->pad_input;
1523 unsigned char *data = wacom->data;
1525 int buttons = data[44];
1527 wacom_report_numbered_buttons(pad_input, 4, buttons);
1529 input_report_key(pad_input, wacom->tool[1], buttons ? 1 : 0);
1530 input_report_abs(pad_input, ABS_MISC, buttons ? PAD_DEVICE_ID : 0);
1531 input_event(pad_input, EV_MSC, MSC_SERIAL, 0xffffffff);
1533 input_sync(pad_input);
1536 static void wacom_intuos_gen3_bt_battery(struct wacom_wac *wacom)
1538 unsigned char *data = wacom->data;
1540 bool chg = data[45] & 0x80;
1541 int battery_status = data[45] & 0x7F;
1543 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
1544 battery_status, chg, 1, chg);
1547 static int wacom_intuos_pro2_bt_irq(struct wacom_wac *wacom, size_t len)
1549 unsigned char *data = wacom->data;
1551 if (data[0] != 0x80 && data[0] != 0x81) {
1552 dev_dbg(wacom->pen_input->dev.parent,
1553 "%s: received unknown report #%d\n", __func__, data[0]);
1557 wacom_intuos_pro2_bt_pen(wacom);
1558 if (wacom->features.type == INTUOSP2_BT ||
1559 wacom->features.type == INTUOSP2S_BT) {
1560 wacom_intuos_pro2_bt_touch(wacom);
1561 wacom_intuos_pro2_bt_pad(wacom);
1562 wacom_intuos_pro2_bt_battery(wacom);
1564 wacom_intuos_gen3_bt_pad(wacom);
1565 wacom_intuos_gen3_bt_battery(wacom);
1570 static int wacom_24hdt_irq(struct wacom_wac *wacom)
1572 struct input_dev *input = wacom->touch_input;
1573 unsigned char *data = wacom->data;
1575 int current_num_contacts = data[61];
1576 int contacts_to_send = 0;
1577 int num_contacts_left = 4; /* maximum contacts per packet */
1578 int byte_per_packet = WACOM_BYTES_PER_24HDT_PACKET;
1581 if (touch_is_muted(wacom) && !wacom->shared->touch_down)
1584 if (wacom->features.type == WACOM_27QHDT) {
1585 current_num_contacts = data[63];
1586 num_contacts_left = 10;
1587 byte_per_packet = WACOM_BYTES_PER_QHDTHID_PACKET;
1592 * First packet resets the counter since only the first
1593 * packet in series will have non-zero current_num_contacts.
1595 if (current_num_contacts)
1596 wacom->num_contacts_left = current_num_contacts;
1598 contacts_to_send = min(num_contacts_left, wacom->num_contacts_left);
1600 for (i = 0; i < contacts_to_send; i++) {
1601 int offset = (byte_per_packet * i) + 1;
1602 bool touch = (data[offset] & 0x1) && report_touch_events(wacom);
1603 int slot = input_mt_get_slot_by_key(input, data[offset + 1]);
1607 input_mt_slot(input, slot);
1608 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1611 int t_x = get_unaligned_le16(&data[offset + 2]);
1612 int t_y = get_unaligned_le16(&data[offset + 4 + y_offset]);
1614 input_report_abs(input, ABS_MT_POSITION_X, t_x);
1615 input_report_abs(input, ABS_MT_POSITION_Y, t_y);
1617 if (wacom->features.type != WACOM_27QHDT) {
1618 int c_x = get_unaligned_le16(&data[offset + 4]);
1619 int c_y = get_unaligned_le16(&data[offset + 8]);
1620 int w = get_unaligned_le16(&data[offset + 10]);
1621 int h = get_unaligned_le16(&data[offset + 12]);
1623 input_report_abs(input, ABS_MT_TOUCH_MAJOR, min(w,h));
1624 input_report_abs(input, ABS_MT_WIDTH_MAJOR,
1625 min(w, h) + int_dist(t_x, t_y, c_x, c_y));
1626 input_report_abs(input, ABS_MT_WIDTH_MINOR, min(w, h));
1627 input_report_abs(input, ABS_MT_ORIENTATION, w > h);
1631 input_mt_sync_frame(input);
1633 wacom->num_contacts_left -= contacts_to_send;
1634 if (wacom->num_contacts_left <= 0) {
1635 wacom->num_contacts_left = 0;
1636 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1641 static int wacom_mt_touch(struct wacom_wac *wacom)
1643 struct input_dev *input = wacom->touch_input;
1644 unsigned char *data = wacom->data;
1646 int current_num_contacts = data[2];
1647 int contacts_to_send = 0;
1650 /* MTTPC does not support Height and Width */
1651 if (wacom->features.type == MTTPC || wacom->features.type == MTTPC_B)
1655 * First packet resets the counter since only the first
1656 * packet in series will have non-zero current_num_contacts.
1658 if (current_num_contacts)
1659 wacom->num_contacts_left = current_num_contacts;
1661 /* There are at most 5 contacts per packet */
1662 contacts_to_send = min(5, wacom->num_contacts_left);
1664 for (i = 0; i < contacts_to_send; i++) {
1665 int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset) * i + 3;
1666 bool touch = (data[offset] & 0x1) && report_touch_events(wacom);
1667 int id = get_unaligned_le16(&data[offset + 1]);
1668 int slot = input_mt_get_slot_by_key(input, id);
1673 input_mt_slot(input, slot);
1674 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1676 int x = get_unaligned_le16(&data[offset + x_offset + 7]);
1677 int y = get_unaligned_le16(&data[offset + x_offset + 9]);
1678 input_report_abs(input, ABS_MT_POSITION_X, x);
1679 input_report_abs(input, ABS_MT_POSITION_Y, y);
1682 input_mt_sync_frame(input);
1684 wacom->num_contacts_left -= contacts_to_send;
1685 if (wacom->num_contacts_left <= 0) {
1686 wacom->num_contacts_left = 0;
1687 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1692 static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
1694 struct input_dev *input = wacom->touch_input;
1695 unsigned char *data = wacom->data;
1698 for (i = 0; i < 2; i++) {
1699 int p = data[1] & (1 << i);
1700 bool touch = p && report_touch_events(wacom);
1702 input_mt_slot(input, i);
1703 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1705 int x = le16_to_cpup((__le16 *)&data[i * 2 + 2]) & 0x7fff;
1706 int y = le16_to_cpup((__le16 *)&data[i * 2 + 6]) & 0x7fff;
1708 input_report_abs(input, ABS_MT_POSITION_X, x);
1709 input_report_abs(input, ABS_MT_POSITION_Y, y);
1712 input_mt_sync_frame(input);
1714 /* keep touch state for pen event */
1715 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1720 static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
1722 unsigned char *data = wacom->data;
1723 struct input_dev *input = wacom->touch_input;
1724 bool prox = report_touch_events(wacom);
1727 if (wacom->features.touch_max > 1 || len > WACOM_PKGLEN_TPC2FG)
1730 if (len == WACOM_PKGLEN_TPC1FG) {
1731 prox = prox && (data[0] & 0x01);
1732 x = get_unaligned_le16(&data[1]);
1733 y = get_unaligned_le16(&data[3]);
1734 } else if (len == WACOM_PKGLEN_TPC1FG_B) {
1735 prox = prox && (data[2] & 0x01);
1736 x = get_unaligned_le16(&data[3]);
1737 y = get_unaligned_le16(&data[5]);
1739 prox = prox && (data[1] & 0x01);
1740 x = le16_to_cpup((__le16 *)&data[2]);
1741 y = le16_to_cpup((__le16 *)&data[4]);
1745 input_report_abs(input, ABS_X, x);
1746 input_report_abs(input, ABS_Y, y);
1748 input_report_key(input, BTN_TOUCH, prox);
1750 /* keep touch state for pen events */
1751 wacom->shared->touch_down = prox;
1756 static int wacom_tpc_pen(struct wacom_wac *wacom)
1758 unsigned char *data = wacom->data;
1759 struct input_dev *input = wacom->pen_input;
1760 bool prox = data[1] & 0x20;
1762 if (!wacom->shared->stylus_in_proximity) /* first in prox */
1763 /* Going into proximity select tool */
1764 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
1766 /* keep pen state for touch events */
1767 wacom->shared->stylus_in_proximity = prox;
1769 /* send pen events only when touch is up or forced out
1770 * or touch arbitration is off
1772 if (!delay_pen_events(wacom)) {
1773 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
1774 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
1775 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
1776 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
1777 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x07) << 8) | data[6]);
1778 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
1779 input_report_key(input, wacom->tool[0], prox);
1786 static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
1788 unsigned char *data = wacom->data;
1790 if (wacom->pen_input) {
1791 dev_dbg(wacom->pen_input->dev.parent,
1792 "%s: received report #%d\n", __func__, data[0]);
1794 if (len == WACOM_PKGLEN_PENABLED ||
1795 data[0] == WACOM_REPORT_PENABLED)
1796 return wacom_tpc_pen(wacom);
1798 else if (wacom->touch_input) {
1799 dev_dbg(wacom->touch_input->dev.parent,
1800 "%s: received report #%d\n", __func__, data[0]);
1803 case WACOM_PKGLEN_TPC1FG:
1804 return wacom_tpc_single_touch(wacom, len);
1806 case WACOM_PKGLEN_TPC2FG:
1807 return wacom_tpc_mt_touch(wacom);
1811 case WACOM_REPORT_TPC1FG:
1812 case WACOM_REPORT_TPCHID:
1813 case WACOM_REPORT_TPCST:
1814 case WACOM_REPORT_TPC1FGE:
1815 return wacom_tpc_single_touch(wacom, len);
1817 case WACOM_REPORT_TPCMT:
1818 case WACOM_REPORT_TPCMT2:
1819 return wacom_mt_touch(wacom);
1828 static int wacom_offset_rotation(struct input_dev *input, struct hid_usage *usage,
1829 int value, int num, int denom)
1831 struct input_absinfo *abs = &input->absinfo[usage->code];
1832 int range = (abs->maximum - abs->minimum + 1);
1834 value += num*range/denom;
1835 if (value > abs->maximum)
1837 else if (value < abs->minimum)
1842 int wacom_equivalent_usage(int usage)
1844 if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMDIGITIZER) {
1845 int subpage = (usage & 0xFF00) << 8;
1846 int subusage = (usage & 0xFF);
1848 if (subpage == WACOM_HID_SP_PAD ||
1849 subpage == WACOM_HID_SP_BUTTON ||
1850 subpage == WACOM_HID_SP_DIGITIZER ||
1851 subpage == WACOM_HID_SP_DIGITIZERINFO ||
1852 usage == WACOM_HID_WD_SENSE ||
1853 usage == WACOM_HID_WD_SERIALHI ||
1854 usage == WACOM_HID_WD_TOOLTYPE ||
1855 usage == WACOM_HID_WD_DISTANCE ||
1856 usage == WACOM_HID_WD_TOUCHSTRIP ||
1857 usage == WACOM_HID_WD_TOUCHSTRIP2 ||
1858 usage == WACOM_HID_WD_TOUCHRING ||
1859 usage == WACOM_HID_WD_TOUCHRINGSTATUS ||
1860 usage == WACOM_HID_WD_REPORT_VALID ||
1861 usage == WACOM_HID_WD_BARRELSWITCH3 ||
1862 usage == WACOM_HID_WD_SEQUENCENUMBER) {
1866 if (subpage == HID_UP_UNDEFINED)
1867 subpage = HID_UP_DIGITIZER;
1869 return subpage | subusage;
1872 if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMTOUCH) {
1873 int subpage = (usage & 0xFF00) << 8;
1874 int subusage = (usage & 0xFF);
1876 if (usage == WACOM_HID_WT_REPORT_VALID)
1879 if (subpage == HID_UP_UNDEFINED)
1880 subpage = WACOM_HID_SP_DIGITIZER;
1882 return subpage | subusage;
1888 static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
1889 struct hid_field *field, __u8 type, __u16 code, int fuzz)
1891 struct wacom *wacom = input_get_drvdata(input);
1892 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1893 struct wacom_features *features = &wacom_wac->features;
1894 int fmin = field->logical_minimum;
1895 int fmax = field->logical_maximum;
1896 unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid);
1897 int resolution_code = code;
1899 if (equivalent_usage == HID_DG_TWIST) {
1900 resolution_code = ABS_RZ;
1903 if (equivalent_usage == HID_GD_X) {
1904 fmin += features->offset_left;
1905 fmax -= features->offset_right;
1907 if (equivalent_usage == HID_GD_Y) {
1908 fmin += features->offset_top;
1909 fmax -= features->offset_bottom;
1917 input_set_abs_params(input, code, fmin, fmax, fuzz, 0);
1918 input_abs_set_res(input, code,
1919 hidinput_calc_abs_res(field, resolution_code));
1924 input_set_capability(input, type, code);
1929 static void wacom_wac_battery_usage_mapping(struct hid_device *hdev,
1930 struct hid_field *field, struct hid_usage *usage)
1932 struct wacom *wacom = hid_get_drvdata(hdev);
1933 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1934 struct wacom_features *features = &wacom_wac->features;
1935 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
1937 switch (equivalent_usage) {
1938 case HID_DG_BATTERYSTRENGTH:
1939 case WACOM_HID_WD_BATTERY_LEVEL:
1940 case WACOM_HID_WD_BATTERY_CHARGING:
1941 features->quirks |= WACOM_QUIRK_BATTERY;
1946 static void wacom_wac_battery_event(struct hid_device *hdev, struct hid_field *field,
1947 struct hid_usage *usage, __s32 value)
1949 struct wacom *wacom = hid_get_drvdata(hdev);
1950 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1951 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
1953 switch (equivalent_usage) {
1954 case HID_DG_BATTERYSTRENGTH:
1956 wacom_wac->hid_data.bat_status = POWER_SUPPLY_STATUS_UNKNOWN;
1959 value = value * 100 / (field->logical_maximum - field->logical_minimum);
1960 wacom_wac->hid_data.battery_capacity = value;
1961 wacom_wac->hid_data.bat_connected = 1;
1962 wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
1965 case WACOM_HID_WD_BATTERY_LEVEL:
1966 value = value * 100 / (field->logical_maximum - field->logical_minimum);
1967 wacom_wac->hid_data.battery_capacity = value;
1968 wacom_wac->hid_data.bat_connected = 1;
1969 wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
1971 case WACOM_HID_WD_BATTERY_CHARGING:
1972 wacom_wac->hid_data.bat_charging = value;
1973 wacom_wac->hid_data.ps_connected = value;
1974 wacom_wac->hid_data.bat_connected = 1;
1975 wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
1980 static void wacom_wac_battery_pre_report(struct hid_device *hdev,
1981 struct hid_report *report)
1986 static void wacom_wac_battery_report(struct hid_device *hdev,
1987 struct hid_report *report)
1989 struct wacom *wacom = hid_get_drvdata(hdev);
1990 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1991 struct wacom_features *features = &wacom_wac->features;
1993 if (features->quirks & WACOM_QUIRK_BATTERY) {
1994 int status = wacom_wac->hid_data.bat_status;
1995 int capacity = wacom_wac->hid_data.battery_capacity;
1996 bool charging = wacom_wac->hid_data.bat_charging;
1997 bool connected = wacom_wac->hid_data.bat_connected;
1998 bool powered = wacom_wac->hid_data.ps_connected;
2000 wacom_notify_battery(wacom_wac, status, capacity, charging,
2001 connected, powered);
2005 static void wacom_wac_pad_usage_mapping(struct hid_device *hdev,
2006 struct hid_field *field, struct hid_usage *usage)
2008 struct wacom *wacom = hid_get_drvdata(hdev);
2009 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2010 struct wacom_features *features = &wacom_wac->features;
2011 struct input_dev *input = wacom_wac->pad_input;
2012 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2014 switch (equivalent_usage) {
2015 case WACOM_HID_WD_ACCELEROMETER_X:
2016 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
2017 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 0);
2018 features->device_type |= WACOM_DEVICETYPE_PAD;
2020 case WACOM_HID_WD_ACCELEROMETER_Y:
2021 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
2022 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 0);
2023 features->device_type |= WACOM_DEVICETYPE_PAD;
2025 case WACOM_HID_WD_ACCELEROMETER_Z:
2026 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
2027 wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0);
2028 features->device_type |= WACOM_DEVICETYPE_PAD;
2030 case WACOM_HID_WD_BUTTONCENTER:
2031 case WACOM_HID_WD_BUTTONHOME:
2032 case WACOM_HID_WD_BUTTONUP:
2033 case WACOM_HID_WD_BUTTONDOWN:
2034 case WACOM_HID_WD_BUTTONLEFT:
2035 case WACOM_HID_WD_BUTTONRIGHT:
2036 wacom_map_usage(input, usage, field, EV_KEY,
2037 wacom_numbered_button_to_key(features->numbered_buttons),
2039 features->numbered_buttons++;
2040 features->device_type |= WACOM_DEVICETYPE_PAD;
2042 case WACOM_HID_WD_MUTE_DEVICE:
2043 /* softkey touch switch */
2044 wacom_wac->is_soft_touch_switch = true;
2046 case WACOM_HID_WD_TOUCHONOFF:
2048 * These two usages, which are used to mute touch events, come
2049 * from the pad packet, but are reported on the touch
2050 * interface. Because the touch interface may not have
2051 * been created yet, we cannot call wacom_map_usage(). In
2052 * order to process the usages when we receive them, we set
2053 * the usage type and code directly.
2055 wacom_wac->has_mute_touch_switch = true;
2056 usage->type = EV_SW;
2057 usage->code = SW_MUTE_DEVICE;
2059 case WACOM_HID_WD_TOUCHSTRIP:
2060 wacom_map_usage(input, usage, field, EV_ABS, ABS_RX, 0);
2061 features->device_type |= WACOM_DEVICETYPE_PAD;
2063 case WACOM_HID_WD_TOUCHSTRIP2:
2064 wacom_map_usage(input, usage, field, EV_ABS, ABS_RY, 0);
2065 features->device_type |= WACOM_DEVICETYPE_PAD;
2067 case WACOM_HID_WD_TOUCHRING:
2068 wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
2069 features->device_type |= WACOM_DEVICETYPE_PAD;
2071 case WACOM_HID_WD_TOUCHRINGSTATUS:
2073 * Only set up type/code association. Completely mapping
2074 * this usage may overwrite the axis resolution and range.
2076 usage->type = EV_ABS;
2077 usage->code = ABS_WHEEL;
2078 set_bit(EV_ABS, input->evbit);
2079 features->device_type |= WACOM_DEVICETYPE_PAD;
2081 case WACOM_HID_WD_BUTTONCONFIG:
2082 wacom_map_usage(input, usage, field, EV_KEY, KEY_BUTTONCONFIG, 0);
2083 features->device_type |= WACOM_DEVICETYPE_PAD;
2085 case WACOM_HID_WD_ONSCREEN_KEYBOARD:
2086 wacom_map_usage(input, usage, field, EV_KEY, KEY_ONSCREEN_KEYBOARD, 0);
2087 features->device_type |= WACOM_DEVICETYPE_PAD;
2089 case WACOM_HID_WD_CONTROLPANEL:
2090 wacom_map_usage(input, usage, field, EV_KEY, KEY_CONTROLPANEL, 0);
2091 features->device_type |= WACOM_DEVICETYPE_PAD;
2093 case WACOM_HID_WD_MODE_CHANGE:
2094 /* do not overwrite previous data */
2095 if (!wacom_wac->has_mode_change) {
2096 wacom_wac->has_mode_change = true;
2097 wacom_wac->is_direct_mode = true;
2099 features->device_type |= WACOM_DEVICETYPE_PAD;
2103 switch (equivalent_usage & 0xfffffff0) {
2104 case WACOM_HID_WD_EXPRESSKEY00:
2105 wacom_map_usage(input, usage, field, EV_KEY,
2106 wacom_numbered_button_to_key(features->numbered_buttons),
2108 features->numbered_buttons++;
2109 features->device_type |= WACOM_DEVICETYPE_PAD;
2114 static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field,
2115 struct hid_usage *usage, __s32 value)
2117 struct wacom *wacom = hid_get_drvdata(hdev);
2118 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2119 struct input_dev *input = wacom_wac->pad_input;
2120 struct wacom_features *features = &wacom_wac->features;
2121 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2123 bool do_report = false;
2126 * Avoid reporting this event and setting inrange_state if this usage
2127 * hasn't been mapped.
2129 if (!usage->type && equivalent_usage != WACOM_HID_WD_MODE_CHANGE)
2132 if (wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY) {
2133 if (usage->hid != WACOM_HID_WD_TOUCHRING)
2134 wacom_wac->hid_data.inrange_state |= value;
2137 /* Process touch switch state first since it is reported through touch interface,
2138 * which is indepentent of pad interface. In the case when there are no other pad
2139 * events, the pad interface will not even be created.
2141 if ((equivalent_usage == WACOM_HID_WD_MUTE_DEVICE) ||
2142 (equivalent_usage == WACOM_HID_WD_TOUCHONOFF)) {
2143 if (wacom_wac->shared->touch_input) {
2144 bool *is_touch_on = &wacom_wac->shared->is_touch_on;
2146 if (equivalent_usage == WACOM_HID_WD_MUTE_DEVICE && value)
2147 *is_touch_on = !(*is_touch_on);
2148 else if (equivalent_usage == WACOM_HID_WD_TOUCHONOFF)
2149 *is_touch_on = value;
2151 input_report_switch(wacom_wac->shared->touch_input,
2152 SW_MUTE_DEVICE, !(*is_touch_on));
2153 input_sync(wacom_wac->shared->touch_input);
2161 switch (equivalent_usage) {
2162 case WACOM_HID_WD_TOUCHRING:
2164 * Userspace expects touchrings to increase in value with
2165 * clockwise gestures and have their zero point at the
2166 * tablet's left. HID events "should" be clockwise-
2167 * increasing and zero at top, though the MobileStudio
2168 * Pro and 2nd-gen Intuos Pro don't do this...
2170 if (hdev->vendor == 0x56a &&
2171 (hdev->product == 0x34d || hdev->product == 0x34e || /* MobileStudio Pro */
2172 hdev->product == 0x357 || hdev->product == 0x358 || /* Intuos Pro 2 */
2173 hdev->product == 0x392 || /* Intuos Pro 2 */
2174 hdev->product == 0x398 || hdev->product == 0x399 || /* MobileStudio Pro */
2175 hdev->product == 0x3AA)) { /* MobileStudio Pro */
2176 value = (field->logical_maximum - value);
2178 if (hdev->product == 0x357 || hdev->product == 0x358 ||
2179 hdev->product == 0x392)
2180 value = wacom_offset_rotation(input, usage, value, 3, 16);
2181 else if (hdev->product == 0x34d || hdev->product == 0x34e ||
2182 hdev->product == 0x398 || hdev->product == 0x399 ||
2183 hdev->product == 0x3AA)
2184 value = wacom_offset_rotation(input, usage, value, 1, 2);
2187 value = wacom_offset_rotation(input, usage, value, 1, 4);
2191 case WACOM_HID_WD_TOUCHRINGSTATUS:
2193 input_event(input, usage->type, usage->code, 0);
2196 case WACOM_HID_WD_MODE_CHANGE:
2197 if (wacom_wac->is_direct_mode != value) {
2198 wacom_wac->is_direct_mode = value;
2199 wacom_schedule_work(&wacom->wacom_wac, WACOM_WORKER_MODE_CHANGE);
2203 case WACOM_HID_WD_BUTTONCENTER:
2204 for (i = 0; i < wacom->led.count; i++)
2205 wacom_update_led(wacom, features->numbered_buttons,
2214 input_event(input, usage->type, usage->code, value);
2216 wacom_wac->hid_data.pad_input_event_flag = true;
2220 static void wacom_wac_pad_pre_report(struct hid_device *hdev,
2221 struct hid_report *report)
2223 struct wacom *wacom = hid_get_drvdata(hdev);
2224 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2226 wacom_wac->hid_data.inrange_state = 0;
2229 static void wacom_wac_pad_report(struct hid_device *hdev,
2230 struct hid_report *report, struct hid_field *field)
2232 struct wacom *wacom = hid_get_drvdata(hdev);
2233 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2234 struct input_dev *input = wacom_wac->pad_input;
2235 bool active = wacom_wac->hid_data.inrange_state != 0;
2237 /* report prox for expresskey events */
2238 if (wacom_wac->hid_data.pad_input_event_flag) {
2239 input_event(input, EV_ABS, ABS_MISC, active ? PAD_DEVICE_ID : 0);
2242 wacom_wac->hid_data.pad_input_event_flag = false;
2246 static void wacom_set_barrel_switch3_usage(struct wacom_wac *wacom_wac)
2248 struct input_dev *input = wacom_wac->pen_input;
2249 struct wacom_features *features = &wacom_wac->features;
2251 if (!(features->quirks & WACOM_QUIRK_AESPEN) &&
2252 wacom_wac->hid_data.barrelswitch &&
2253 wacom_wac->hid_data.barrelswitch2 &&
2254 wacom_wac->hid_data.serialhi &&
2255 !wacom_wac->hid_data.barrelswitch3) {
2256 input_set_capability(input, EV_KEY, BTN_STYLUS3);
2257 features->quirks |= WACOM_QUIRK_PEN_BUTTON3;
2261 static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
2262 struct hid_field *field, struct hid_usage *usage)
2264 struct wacom *wacom = hid_get_drvdata(hdev);
2265 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2266 struct wacom_features *features = &wacom_wac->features;
2267 struct input_dev *input = wacom_wac->pen_input;
2268 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2270 switch (equivalent_usage) {
2272 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
2275 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
2277 case WACOM_HID_WD_DISTANCE:
2279 wacom_map_usage(input, usage, field, EV_ABS, ABS_DISTANCE, 0);
2281 case HID_DG_TIPPRESSURE:
2282 wacom_map_usage(input, usage, field, EV_ABS, ABS_PRESSURE, 0);
2284 case HID_DG_INRANGE:
2285 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
2288 wacom_map_usage(input, usage, field, EV_KEY,
2289 BTN_TOOL_RUBBER, 0);
2292 wacom_map_usage(input, usage, field, EV_ABS, ABS_TILT_X, 0);
2295 wacom_map_usage(input, usage, field, EV_ABS, ABS_TILT_Y, 0);
2298 wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0);
2301 input_set_capability(input, EV_KEY, BTN_TOOL_RUBBER);
2302 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
2304 case HID_DG_TIPSWITCH:
2305 input_set_capability(input, EV_KEY, BTN_TOOL_PEN);
2306 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
2308 case HID_DG_BARRELSWITCH:
2309 wacom_wac->hid_data.barrelswitch = true;
2310 wacom_set_barrel_switch3_usage(wacom_wac);
2311 wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS, 0);
2313 case HID_DG_BARRELSWITCH2:
2314 wacom_wac->hid_data.barrelswitch2 = true;
2315 wacom_set_barrel_switch3_usage(wacom_wac);
2316 wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS2, 0);
2318 case HID_DG_TOOLSERIALNUMBER:
2319 features->quirks |= WACOM_QUIRK_TOOLSERIAL;
2320 wacom_map_usage(input, usage, field, EV_MSC, MSC_SERIAL, 0);
2322 case HID_DG_SCANTIME:
2323 wacom_map_usage(input, usage, field, EV_MSC, MSC_TIMESTAMP, 0);
2325 case WACOM_HID_WD_SENSE:
2326 features->quirks |= WACOM_QUIRK_SENSE;
2327 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
2329 case WACOM_HID_WD_SERIALHI:
2330 wacom_wac->hid_data.serialhi = true;
2331 wacom_set_barrel_switch3_usage(wacom_wac);
2332 wacom_map_usage(input, usage, field, EV_ABS, ABS_MISC, 0);
2334 case WACOM_HID_WD_FINGERWHEEL:
2335 input_set_capability(input, EV_KEY, BTN_TOOL_AIRBRUSH);
2336 wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
2338 case WACOM_HID_WD_BARRELSWITCH3:
2339 wacom_wac->hid_data.barrelswitch3 = true;
2340 wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS3, 0);
2341 features->quirks &= ~WACOM_QUIRK_PEN_BUTTON3;
2346 static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field,
2347 struct hid_usage *usage, __s32 value)
2349 struct wacom *wacom = hid_get_drvdata(hdev);
2350 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2351 struct wacom_features *features = &wacom_wac->features;
2352 struct input_dev *input = wacom_wac->pen_input;
2353 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2355 if (wacom_wac->is_invalid_bt_frame)
2358 switch (equivalent_usage) {
2361 * HID_GD_Z "should increase as the control's position is
2362 * moved from high to low", while ABS_DISTANCE instead
2363 * increases in value as the tool moves from low to high.
2365 value = field->logical_maximum - value;
2367 case HID_DG_INRANGE:
2368 mod_timer(&wacom->idleprox_timer, jiffies + msecs_to_jiffies(100));
2369 wacom_wac->hid_data.inrange_state = value;
2370 if (!(features->quirks & WACOM_QUIRK_SENSE))
2371 wacom_wac->hid_data.sense_state = value;
2374 wacom_wac->hid_data.invert_state = value;
2377 case HID_DG_TIPSWITCH:
2378 wacom_wac->hid_data.tipswitch |= value;
2380 case HID_DG_BARRELSWITCH:
2381 wacom_wac->hid_data.barrelswitch = value;
2383 case HID_DG_BARRELSWITCH2:
2384 wacom_wac->hid_data.barrelswitch2 = value;
2386 case HID_DG_TOOLSERIALNUMBER:
2388 wacom_wac->serial[0] = (wacom_wac->serial[0] & ~0xFFFFFFFFULL);
2389 wacom_wac->serial[0] |= wacom_s32tou(value, field->report_size);
2393 /* don't modify the value if the pen doesn't support the feature */
2394 if (!wacom_is_art_pen(wacom_wac->id[0])) return;
2397 * Userspace expects pen twist to have its zero point when
2398 * the buttons/finger is on the tablet's left. HID values
2399 * are zero when buttons are toward the top.
2401 value = wacom_offset_rotation(input, usage, value, 1, 4);
2403 case WACOM_HID_WD_SENSE:
2404 wacom_wac->hid_data.sense_state = value;
2406 case WACOM_HID_WD_SERIALHI:
2408 __u32 raw_value = wacom_s32tou(value, field->report_size);
2410 wacom_wac->serial[0] = (wacom_wac->serial[0] & 0xFFFFFFFF);
2411 wacom_wac->serial[0] |= ((__u64)raw_value) << 32;
2413 * Non-USI EMR devices may contain additional tool type
2414 * information here. See WACOM_HID_WD_TOOLTYPE case for
2417 if (value >> 20 == 1) {
2418 wacom_wac->id[0] |= raw_value & 0xFFFFF;
2422 case WACOM_HID_WD_TOOLTYPE:
2424 * Some devices (MobileStudio Pro, and possibly later
2425 * devices as well) do not return the complete tool
2426 * type in their WACOM_HID_WD_TOOLTYPE usage. Use a
2427 * bitwise OR so the complete value can be built
2430 wacom_wac->id[0] |= wacom_s32tou(value, field->report_size);
2432 case WACOM_HID_WD_OFFSETLEFT:
2433 if (features->offset_left && value != features->offset_left)
2434 hid_warn(hdev, "%s: overriding existing left offset "
2435 "%d -> %d\n", __func__, value,
2436 features->offset_left);
2437 features->offset_left = value;
2439 case WACOM_HID_WD_OFFSETRIGHT:
2440 if (features->offset_right && value != features->offset_right)
2441 hid_warn(hdev, "%s: overriding existing right offset "
2442 "%d -> %d\n", __func__, value,
2443 features->offset_right);
2444 features->offset_right = value;
2446 case WACOM_HID_WD_OFFSETTOP:
2447 if (features->offset_top && value != features->offset_top)
2448 hid_warn(hdev, "%s: overriding existing top offset "
2449 "%d -> %d\n", __func__, value,
2450 features->offset_top);
2451 features->offset_top = value;
2453 case WACOM_HID_WD_OFFSETBOTTOM:
2454 if (features->offset_bottom && value != features->offset_bottom)
2455 hid_warn(hdev, "%s: overriding existing bottom offset "
2456 "%d -> %d\n", __func__, value,
2457 features->offset_bottom);
2458 features->offset_bottom = value;
2460 case WACOM_HID_WD_REPORT_VALID:
2461 wacom_wac->is_invalid_bt_frame = !value;
2463 case WACOM_HID_WD_BARRELSWITCH3:
2464 wacom_wac->hid_data.barrelswitch3 = value;
2466 case WACOM_HID_WD_SEQUENCENUMBER:
2467 if (wacom_wac->hid_data.sequence_number != value)
2468 hid_warn(hdev, "Dropped %hu packets", (unsigned short)(value - wacom_wac->hid_data.sequence_number));
2469 wacom_wac->hid_data.sequence_number = value + 1;
2473 /* send pen events only when touch is up or forced out
2474 * or touch arbitration is off
2476 if (!usage->type || delay_pen_events(wacom_wac))
2479 /* send pen events only when the pen is in range */
2480 if (wacom_wac->hid_data.inrange_state)
2481 input_event(input, usage->type, usage->code, value);
2482 else if (wacom_wac->shared->stylus_in_proximity && !wacom_wac->hid_data.sense_state)
2483 input_event(input, usage->type, usage->code, 0);
2486 static void wacom_wac_pen_pre_report(struct hid_device *hdev,
2487 struct hid_report *report)
2489 struct wacom *wacom = hid_get_drvdata(hdev);
2490 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2492 wacom_wac->is_invalid_bt_frame = false;
2496 static void wacom_wac_pen_report(struct hid_device *hdev,
2497 struct hid_report *report)
2499 struct wacom *wacom = hid_get_drvdata(hdev);
2500 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2501 struct input_dev *input = wacom_wac->pen_input;
2502 bool range = wacom_wac->hid_data.inrange_state;
2503 bool sense = wacom_wac->hid_data.sense_state;
2505 if (wacom_wac->is_invalid_bt_frame)
2508 if (!wacom_wac->tool[0] && range) { /* first in range */
2509 /* Going into range select tool */
2510 if (wacom_wac->hid_data.invert_state)
2511 wacom_wac->tool[0] = BTN_TOOL_RUBBER;
2512 else if (wacom_wac->id[0])
2513 wacom_wac->tool[0] = wacom_intuos_get_tool_type(wacom_wac->id[0]);
2515 wacom_wac->tool[0] = BTN_TOOL_PEN;
2518 /* keep pen state for touch events */
2519 wacom_wac->shared->stylus_in_proximity = sense;
2521 if (!delay_pen_events(wacom_wac) && wacom_wac->tool[0]) {
2522 int id = wacom_wac->id[0];
2523 if (wacom_wac->features.quirks & WACOM_QUIRK_PEN_BUTTON3 &&
2524 wacom_wac->hid_data.barrelswitch & wacom_wac->hid_data.barrelswitch2) {
2525 wacom_wac->hid_data.barrelswitch = 0;
2526 wacom_wac->hid_data.barrelswitch2 = 0;
2527 wacom_wac->hid_data.barrelswitch3 = 1;
2529 input_report_key(input, BTN_STYLUS, wacom_wac->hid_data.barrelswitch);
2530 input_report_key(input, BTN_STYLUS2, wacom_wac->hid_data.barrelswitch2);
2531 input_report_key(input, BTN_STYLUS3, wacom_wac->hid_data.barrelswitch3);
2534 * Non-USI EMR tools should have their IDs mangled to
2535 * match the legacy behavior of wacom_intuos_general
2537 if (wacom_wac->serial[0] >> 52 == 1)
2538 id = wacom_intuos_id_mangle(id);
2541 * To ensure compatibility with xf86-input-wacom, we should
2542 * report the BTN_TOOL_* event prior to the ABS_MISC or
2543 * MSC_SERIAL events.
2545 input_report_key(input, BTN_TOUCH,
2546 wacom_wac->hid_data.tipswitch);
2547 input_report_key(input, wacom_wac->tool[0], sense);
2548 if (wacom_wac->serial[0]) {
2549 input_event(input, EV_MSC, MSC_SERIAL, wacom_wac->serial[0]);
2550 input_report_abs(input, ABS_MISC, sense ? id : 0);
2553 wacom_wac->hid_data.tipswitch = false;
2559 wacom_wac->tool[0] = 0;
2560 wacom_wac->id[0] = 0;
2561 wacom_wac->serial[0] = 0;
2565 static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
2566 struct hid_field *field, struct hid_usage *usage)
2568 struct wacom *wacom = hid_get_drvdata(hdev);
2569 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2570 struct input_dev *input = wacom_wac->touch_input;
2571 unsigned touch_max = wacom_wac->features.touch_max;
2572 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2574 switch (equivalent_usage) {
2577 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
2579 wacom_map_usage(input, usage, field, EV_ABS,
2580 ABS_MT_POSITION_X, 4);
2584 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
2586 wacom_map_usage(input, usage, field, EV_ABS,
2587 ABS_MT_POSITION_Y, 4);
2591 wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MAJOR, 0);
2592 wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MINOR, 0);
2593 input_set_abs_params(input, ABS_MT_ORIENTATION, 0, 1, 0, 0);
2595 case HID_DG_TIPSWITCH:
2596 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
2598 case HID_DG_CONTACTCOUNT:
2599 wacom_wac->hid_data.cc_report = field->report->id;
2600 wacom_wac->hid_data.cc_index = field->index;
2601 wacom_wac->hid_data.cc_value_index = usage->usage_index;
2603 case HID_DG_CONTACTID:
2604 if ((field->logical_maximum - field->logical_minimum) < touch_max) {
2606 * The HID descriptor for G11 sensors leaves logical
2607 * maximum set to '1' despite it being a multitouch
2608 * device. Override to a sensible number.
2610 field->logical_maximum = 255;
2613 case HID_DG_SCANTIME:
2614 wacom_map_usage(input, usage, field, EV_MSC, MSC_TIMESTAMP, 0);
2619 static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
2620 struct input_dev *input)
2622 struct hid_data *hid_data = &wacom_wac->hid_data;
2623 bool mt = wacom_wac->features.touch_max > 1;
2624 bool prox = hid_data->tipswitch &&
2625 report_touch_events(wacom_wac);
2627 if (touch_is_muted(wacom_wac)) {
2628 if (!wacom_wac->shared->touch_down)
2633 wacom_wac->hid_data.num_received++;
2634 if (wacom_wac->hid_data.num_received > wacom_wac->hid_data.num_expected)
2640 slot = input_mt_get_slot_by_key(input, hid_data->id);
2644 struct input_mt_slot *ps = &input->mt->slots[slot];
2645 int mt_id = input_mt_get_value(ps, ABS_MT_TRACKING_ID);
2647 if (!prox && mt_id < 0) {
2648 // No data to send for this slot; short-circuit
2653 input_mt_slot(input, slot);
2654 input_mt_report_slot_state(input, MT_TOOL_FINGER, prox);
2657 input_report_key(input, BTN_TOUCH, prox);
2661 input_report_abs(input, mt ? ABS_MT_POSITION_X : ABS_X,
2663 input_report_abs(input, mt ? ABS_MT_POSITION_Y : ABS_Y,
2666 if (test_bit(ABS_MT_TOUCH_MAJOR, input->absbit)) {
2667 input_report_abs(input, ABS_MT_TOUCH_MAJOR, max(hid_data->width, hid_data->height));
2668 input_report_abs(input, ABS_MT_TOUCH_MINOR, min(hid_data->width, hid_data->height));
2669 if (hid_data->width != hid_data->height)
2670 input_report_abs(input, ABS_MT_ORIENTATION, hid_data->width <= hid_data->height ? 0 : 1);
2675 static bool wacom_wac_slot_is_active(struct input_dev *dev, int key)
2677 struct input_mt *mt = dev->mt;
2678 struct input_mt_slot *s;
2683 for (s = mt->slots; s != mt->slots + mt->num_slots; s++) {
2684 if (s->key == key &&
2685 input_mt_get_value(s, ABS_MT_TRACKING_ID) >= 0) {
2693 static void wacom_wac_finger_event(struct hid_device *hdev,
2694 struct hid_field *field, struct hid_usage *usage, __s32 value)
2696 struct wacom *wacom = hid_get_drvdata(hdev);
2697 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2698 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2699 struct wacom_features *features = &wacom->wacom_wac.features;
2701 if (touch_is_muted(wacom_wac) && !wacom_wac->shared->touch_down)
2704 if (wacom_wac->is_invalid_bt_frame)
2707 switch (equivalent_usage) {
2708 case HID_DG_CONFIDENCE:
2709 wacom_wac->hid_data.confidence = value;
2712 wacom_wac->hid_data.x = value;
2715 wacom_wac->hid_data.y = value;
2718 wacom_wac->hid_data.width = value;
2721 wacom_wac->hid_data.height = value;
2723 case HID_DG_CONTACTID:
2724 wacom_wac->hid_data.id = value;
2726 case HID_DG_TIPSWITCH:
2727 wacom_wac->hid_data.tipswitch = value;
2729 case WACOM_HID_WT_REPORT_VALID:
2730 wacom_wac->is_invalid_bt_frame = !value;
2732 case HID_DG_CONTACTMAX:
2733 if (!features->touch_max) {
2734 features->touch_max = value;
2736 hid_warn(hdev, "%s: ignoring attempt to overwrite non-zero touch_max "
2737 "%d -> %d\n", __func__, features->touch_max, value);
2742 if (usage->usage_index + 1 == field->report_count) {
2743 if (equivalent_usage == wacom_wac->hid_data.last_slot_field) {
2744 bool touch_removed = wacom_wac_slot_is_active(wacom_wac->touch_input,
2745 wacom_wac->hid_data.id) && !wacom_wac->hid_data.tipswitch;
2747 if (wacom_wac->hid_data.confidence || touch_removed) {
2748 wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
2754 static void wacom_wac_finger_pre_report(struct hid_device *hdev,
2755 struct hid_report *report)
2757 struct wacom *wacom = hid_get_drvdata(hdev);
2758 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2759 struct hid_data* hid_data = &wacom_wac->hid_data;
2762 if (touch_is_muted(wacom_wac) && !wacom_wac->shared->touch_down)
2765 wacom_wac->is_invalid_bt_frame = false;
2767 hid_data->confidence = true;
2769 hid_data->cc_report = 0;
2770 hid_data->cc_index = -1;
2771 hid_data->cc_value_index = -1;
2773 for (i = 0; i < report->maxfield; i++) {
2774 struct hid_field *field = report->field[i];
2777 for (j = 0; j < field->maxusage; j++) {
2778 struct hid_usage *usage = &field->usage[j];
2779 unsigned int equivalent_usage =
2780 wacom_equivalent_usage(usage->hid);
2782 switch (equivalent_usage) {
2787 case HID_DG_CONTACTID:
2788 case HID_DG_INRANGE:
2790 case HID_DG_TIPSWITCH:
2791 hid_data->last_slot_field = equivalent_usage;
2793 case HID_DG_CONTACTCOUNT:
2794 hid_data->cc_report = report->id;
2795 hid_data->cc_index = i;
2796 hid_data->cc_value_index = j;
2802 if (hid_data->cc_report != 0 &&
2803 hid_data->cc_index >= 0) {
2804 struct hid_field *field = report->field[hid_data->cc_index];
2805 int value = field->value[hid_data->cc_value_index];
2807 hid_data->num_expected = value;
2808 hid_data->num_received = 0;
2812 hid_data->num_expected = wacom_wac->features.touch_max;
2813 hid_data->num_received = 0;
2817 static void wacom_wac_finger_report(struct hid_device *hdev,
2818 struct hid_report *report)
2820 struct wacom *wacom = hid_get_drvdata(hdev);
2821 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2822 struct input_dev *input = wacom_wac->touch_input;
2823 unsigned touch_max = wacom_wac->features.touch_max;
2825 /* if there was nothing to process, don't send an empty sync */
2826 if (wacom_wac->hid_data.num_expected == 0)
2829 /* If more packets of data are expected, give us a chance to
2830 * process them rather than immediately syncing a partial
2833 if (wacom_wac->hid_data.num_received < wacom_wac->hid_data.num_expected)
2837 input_mt_sync_frame(input);
2840 wacom_wac->hid_data.num_received = 0;
2841 wacom_wac->hid_data.num_expected = 0;
2843 /* keep touch state for pen event */
2844 wacom_wac->shared->touch_down = wacom_wac_finger_count_touches(wacom_wac);
2847 void wacom_wac_usage_mapping(struct hid_device *hdev,
2848 struct hid_field *field, struct hid_usage *usage)
2850 struct wacom *wacom = hid_get_drvdata(hdev);
2851 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2852 struct wacom_features *features = &wacom_wac->features;
2854 if (WACOM_DIRECT_DEVICE(field))
2855 features->device_type |= WACOM_DEVICETYPE_DIRECT;
2857 /* usage tests must precede field tests */
2858 if (WACOM_BATTERY_USAGE(usage))
2859 wacom_wac_battery_usage_mapping(hdev, field, usage);
2860 else if (WACOM_PAD_FIELD(field))
2861 wacom_wac_pad_usage_mapping(hdev, field, usage);
2862 else if (WACOM_PEN_FIELD(field))
2863 wacom_wac_pen_usage_mapping(hdev, field, usage);
2864 else if (WACOM_FINGER_FIELD(field))
2865 wacom_wac_finger_usage_mapping(hdev, field, usage);
2868 void wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
2869 struct hid_usage *usage, __s32 value)
2871 struct wacom *wacom = hid_get_drvdata(hdev);
2873 if (wacom->wacom_wac.features.type != HID_GENERIC)
2876 if (value > field->logical_maximum || value < field->logical_minimum)
2879 /* usage tests must precede field tests */
2880 if (WACOM_BATTERY_USAGE(usage))
2881 wacom_wac_battery_event(hdev, field, usage, value);
2882 else if (WACOM_PAD_FIELD(field))
2883 wacom_wac_pad_event(hdev, field, usage, value);
2884 else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
2885 wacom_wac_pen_event(hdev, field, usage, value);
2886 else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
2887 wacom_wac_finger_event(hdev, field, usage, value);
2890 static void wacom_report_events(struct hid_device *hdev,
2891 struct hid_report *report, int collection_index,
2896 for (r = field_index; r < report->maxfield; r++) {
2897 struct hid_field *field;
2900 field = report->field[r];
2901 count = field->report_count;
2903 if (!(HID_MAIN_ITEM_VARIABLE & field->flags))
2906 for (n = 0 ; n < count; n++) {
2907 if (field->usage[n].collection_index == collection_index)
2908 wacom_wac_event(hdev, field, &field->usage[n],
2916 static int wacom_wac_collection(struct hid_device *hdev, struct hid_report *report,
2917 int collection_index, struct hid_field *field,
2920 struct wacom *wacom = hid_get_drvdata(hdev);
2922 wacom_report_events(hdev, report, collection_index, field_index);
2925 * Non-input reports may be sent prior to the device being
2926 * completely initialized. Since only their events need
2927 * to be processed, exit after 'wacom_report_events' has
2928 * been called to prevent potential crashes in the report-
2929 * processing functions.
2931 if (report->type != HID_INPUT_REPORT)
2934 if (WACOM_PAD_FIELD(field))
2936 else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
2937 wacom_wac_pen_report(hdev, report);
2938 else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
2939 wacom_wac_finger_report(hdev, report);
2944 void wacom_wac_report(struct hid_device *hdev, struct hid_report *report)
2946 struct wacom *wacom = hid_get_drvdata(hdev);
2947 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2948 struct hid_field *field;
2949 bool pad_in_hid_field = false, pen_in_hid_field = false,
2950 finger_in_hid_field = false, true_pad = false;
2952 int prev_collection = -1;
2954 if (wacom_wac->features.type != HID_GENERIC)
2957 for (r = 0; r < report->maxfield; r++) {
2958 field = report->field[r];
2960 if (WACOM_PAD_FIELD(field))
2961 pad_in_hid_field = true;
2962 if (WACOM_PEN_FIELD(field))
2963 pen_in_hid_field = true;
2964 if (WACOM_FINGER_FIELD(field))
2965 finger_in_hid_field = true;
2966 if (wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY)
2970 wacom_wac_battery_pre_report(hdev, report);
2972 if (pad_in_hid_field && wacom->wacom_wac.pad_input)
2973 wacom_wac_pad_pre_report(hdev, report);
2974 if (pen_in_hid_field && wacom->wacom_wac.pen_input)
2975 wacom_wac_pen_pre_report(hdev, report);
2976 if (finger_in_hid_field && wacom->wacom_wac.touch_input)
2977 wacom_wac_finger_pre_report(hdev, report);
2979 for (r = 0; r < report->maxfield; r++) {
2980 field = report->field[r];
2982 if (field->usage[0].collection_index != prev_collection) {
2983 if (wacom_wac_collection(hdev, report,
2984 field->usage[0].collection_index, field, r) < 0)
2986 prev_collection = field->usage[0].collection_index;
2990 wacom_wac_battery_report(hdev, report);
2992 if (true_pad && wacom->wacom_wac.pad_input)
2993 wacom_wac_pad_report(hdev, report, field);
2996 static int wacom_bpt_touch(struct wacom_wac *wacom)
2998 struct wacom_features *features = &wacom->features;
2999 struct input_dev *input = wacom->touch_input;
3000 struct input_dev *pad_input = wacom->pad_input;
3001 unsigned char *data = wacom->data;
3004 if (data[0] != 0x02)
3007 for (i = 0; i < 2; i++) {
3008 int offset = (data[1] & 0x80) ? (8 * i) : (9 * i);
3009 bool touch = report_touch_events(wacom)
3010 && (data[offset + 3] & 0x80);
3012 input_mt_slot(input, i);
3013 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
3015 int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff;
3016 int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff;
3017 if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) {
3021 input_report_abs(input, ABS_MT_POSITION_X, x);
3022 input_report_abs(input, ABS_MT_POSITION_Y, y);
3026 input_mt_sync_frame(input);
3028 input_report_key(pad_input, BTN_LEFT, (data[1] & 0x08) != 0);
3029 input_report_key(pad_input, BTN_FORWARD, (data[1] & 0x04) != 0);
3030 input_report_key(pad_input, BTN_BACK, (data[1] & 0x02) != 0);
3031 input_report_key(pad_input, BTN_RIGHT, (data[1] & 0x01) != 0);
3032 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
3037 static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
3039 struct wacom_features *features = &wacom->features;
3040 struct input_dev *input = wacom->touch_input;
3041 bool touch = data[1] & 0x80;
3042 int slot = input_mt_get_slot_by_key(input, data[0]);
3047 touch = touch && report_touch_events(wacom);
3049 input_mt_slot(input, slot);
3050 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
3053 int x = (data[2] << 4) | (data[4] >> 4);
3054 int y = (data[3] << 4) | (data[4] & 0x0f);
3057 if (features->type >= INTUOSPS && features->type <= INTUOSHT2) {
3058 width = data[5] * 100;
3059 height = data[6] * 100;
3062 * "a" is a scaled-down area which we assume is
3063 * roughly circular and which can be described as:
3067 int x_res = input_abs_get_res(input, ABS_MT_POSITION_X);
3068 int y_res = input_abs_get_res(input, ABS_MT_POSITION_Y);
3069 width = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE);
3070 height = width * y_res / x_res;
3073 input_report_abs(input, ABS_MT_POSITION_X, x);
3074 input_report_abs(input, ABS_MT_POSITION_Y, y);
3075 input_report_abs(input, ABS_MT_TOUCH_MAJOR, width);
3076 input_report_abs(input, ABS_MT_TOUCH_MINOR, height);
3080 static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
3082 struct input_dev *input = wacom->pad_input;
3083 struct wacom_features *features = &wacom->features;
3085 if (features->type == INTUOSHT || features->type == INTUOSHT2) {
3086 input_report_key(input, BTN_LEFT, (data[1] & 0x02) != 0);
3087 input_report_key(input, BTN_BACK, (data[1] & 0x08) != 0);
3089 input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
3090 input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
3092 input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
3093 input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
3096 static int wacom_bpt3_touch(struct wacom_wac *wacom)
3098 unsigned char *data = wacom->data;
3099 int count = data[1] & 0x07;
3100 int touch_changed = 0, i;
3102 if (data[0] != 0x02)
3105 /* data has up to 7 fixed sized 8-byte messages starting at data[2] */
3106 for (i = 0; i < count; i++) {
3107 int offset = (8 * i) + 2;
3108 int msg_id = data[offset];
3110 if (msg_id >= 2 && msg_id <= 17) {
3111 wacom_bpt3_touch_msg(wacom, data + offset);
3113 } else if (msg_id == 128)
3114 wacom_bpt3_button_msg(wacom, data + offset);
3118 /* only update touch if we actually have a touchpad and touch data changed */
3119 if (wacom->touch_input && touch_changed) {
3120 input_mt_sync_frame(wacom->touch_input);
3121 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
3127 static int wacom_bpt_pen(struct wacom_wac *wacom)
3129 struct wacom_features *features = &wacom->features;
3130 struct input_dev *input = wacom->pen_input;
3131 unsigned char *data = wacom->data;
3132 int x = 0, y = 0, p = 0, d = 0;
3133 bool pen = false, btn1 = false, btn2 = false;
3134 bool range, prox, rdy;
3136 if (data[0] != WACOM_REPORT_PENABLED)
3139 range = (data[1] & 0x80) == 0x80;
3140 prox = (data[1] & 0x40) == 0x40;
3141 rdy = (data[1] & 0x20) == 0x20;
3143 wacom->shared->stylus_in_proximity = range;
3144 if (delay_pen_events(wacom))
3148 p = le16_to_cpup((__le16 *)&data[6]);
3149 pen = data[1] & 0x01;
3150 btn1 = data[1] & 0x02;
3151 btn2 = data[1] & 0x04;
3154 x = le16_to_cpup((__le16 *)&data[2]);
3155 y = le16_to_cpup((__le16 *)&data[4]);
3157 if (data[1] & 0x08) {
3158 wacom->tool[0] = BTN_TOOL_RUBBER;
3159 wacom->id[0] = ERASER_DEVICE_ID;
3161 wacom->tool[0] = BTN_TOOL_PEN;
3162 wacom->id[0] = STYLUS_DEVICE_ID;
3164 wacom->reporting_data = true;
3168 * Convert distance from out prox to distance from tablet.
3169 * distance will be greater than distance_max once
3170 * touching and applying pressure; do not report negative
3173 if (data[8] <= features->distance_max)
3174 d = features->distance_max - data[8];
3179 if (wacom->reporting_data) {
3180 input_report_key(input, BTN_TOUCH, pen);
3181 input_report_key(input, BTN_STYLUS, btn1);
3182 input_report_key(input, BTN_STYLUS2, btn2);
3184 if (prox || !range) {
3185 input_report_abs(input, ABS_X, x);
3186 input_report_abs(input, ABS_Y, y);
3188 input_report_abs(input, ABS_PRESSURE, p);
3189 input_report_abs(input, ABS_DISTANCE, d);
3191 input_report_key(input, wacom->tool[0], range); /* PEN or RUBBER */
3192 input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
3196 wacom->reporting_data = false;
3202 static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
3204 struct wacom_features *features = &wacom->features;
3206 if ((features->type == INTUOSHT2) &&
3207 (features->device_type & WACOM_DEVICETYPE_PEN))
3208 return wacom_intuos_irq(wacom);
3209 else if (len == WACOM_PKGLEN_BBTOUCH)
3210 return wacom_bpt_touch(wacom);
3211 else if (len == WACOM_PKGLEN_BBTOUCH3)
3212 return wacom_bpt3_touch(wacom);
3213 else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
3214 return wacom_bpt_pen(wacom);
3219 static void wacom_bamboo_pad_pen_event(struct wacom_wac *wacom,
3220 unsigned char *data)
3222 unsigned char prefix;
3225 * We need to reroute the event from the debug interface to the
3227 * We need to add the report ID to the actual pen report, so we
3228 * temporary overwrite the first byte to prevent having to kzalloc/kfree
3229 * and memcpy the report.
3232 data[0] = WACOM_REPORT_BPAD_PEN;
3235 * actually reroute the event.
3236 * No need to check if wacom->shared->pen is valid, hid_input_report()
3237 * will check for us.
3239 hid_input_report(wacom->shared->pen, HID_INPUT_REPORT, data,
3240 WACOM_PKGLEN_PENABLED, 1);
3245 static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom,
3246 unsigned char *data)
3248 struct input_dev *input = wacom->touch_input;
3249 unsigned char *finger_data, prefix;
3256 for (id = 0; id < wacom->features.touch_max; id++) {
3257 valid = !!(prefix & BIT(id)) &&
3258 report_touch_events(wacom);
3260 input_mt_slot(input, id);
3261 input_mt_report_slot_state(input, MT_TOOL_FINGER, valid);
3266 finger_data = data + 1 + id * 3;
3267 x = finger_data[0] | ((finger_data[1] & 0x0f) << 8);
3268 y = (finger_data[2] << 4) | (finger_data[1] >> 4);
3270 input_report_abs(input, ABS_MT_POSITION_X, x);
3271 input_report_abs(input, ABS_MT_POSITION_Y, y);
3274 input_mt_sync_frame(input);
3276 input_report_key(input, BTN_LEFT, prefix & 0x40);
3277 input_report_key(input, BTN_RIGHT, prefix & 0x80);
3279 /* keep touch state for pen event */
3280 wacom->shared->touch_down = !!prefix && report_touch_events(wacom);
3285 static int wacom_bamboo_pad_irq(struct wacom_wac *wacom, size_t len)
3287 unsigned char *data = wacom->data;
3289 if (!((len == WACOM_PKGLEN_BPAD_TOUCH) ||
3290 (len == WACOM_PKGLEN_BPAD_TOUCH_USB)) ||
3291 (data[0] != WACOM_REPORT_BPAD_TOUCH))
3295 wacom_bamboo_pad_pen_event(wacom, &data[1]);
3298 return wacom_bamboo_pad_touch_event(wacom, &data[9]);
3303 static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
3305 unsigned char *data = wacom->data;
3308 if (len != WACOM_PKGLEN_WIRELESS || data[0] != WACOM_REPORT_WL)
3311 connected = data[1] & 0x01;
3313 int pid, battery, charging;
3315 if ((wacom->shared->type == INTUOSHT ||
3316 wacom->shared->type == INTUOSHT2) &&
3317 wacom->shared->touch_input &&
3318 wacom->shared->touch_max) {
3319 input_report_switch(wacom->shared->touch_input,
3320 SW_MUTE_DEVICE, data[5] & 0x40);
3321 input_sync(wacom->shared->touch_input);
3324 pid = get_unaligned_be16(&data[6]);
3325 battery = (data[5] & 0x3f) * 100 / 31;
3326 charging = !!(data[5] & 0x80);
3327 if (wacom->pid != pid) {
3329 wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
3332 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
3333 battery, charging, 1, 0);
3335 } else if (wacom->pid != 0) {
3336 /* disconnected while previously connected */
3338 wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
3339 wacom_notify_battery(wacom, POWER_SUPPLY_STATUS_UNKNOWN, 0, 0, 0, 0);
3345 static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
3347 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
3348 struct wacom_features *features = &wacom_wac->features;
3349 unsigned char *data = wacom_wac->data;
3351 if (data[0] != WACOM_REPORT_USB)
3354 if ((features->type == INTUOSHT ||
3355 features->type == INTUOSHT2) &&
3356 wacom_wac->shared->touch_input &&
3357 features->touch_max) {
3358 input_report_switch(wacom_wac->shared->touch_input,
3359 SW_MUTE_DEVICE, data[8] & 0x40);
3360 input_sync(wacom_wac->shared->touch_input);
3363 if (data[9] & 0x02) { /* wireless module is attached */
3364 int battery = (data[8] & 0x3f) * 100 / 31;
3365 bool charging = !!(data[8] & 0x80);
3367 wacom_notify_battery(wacom_wac, WACOM_POWER_SUPPLY_STATUS_AUTO,
3368 battery, charging, battery || charging, 1);
3370 if (!wacom->battery.battery &&
3371 !(features->quirks & WACOM_QUIRK_BATTERY)) {
3372 features->quirks |= WACOM_QUIRK_BATTERY;
3373 wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
3376 else if ((features->quirks & WACOM_QUIRK_BATTERY) &&
3377 wacom->battery.battery) {
3378 features->quirks &= ~WACOM_QUIRK_BATTERY;
3379 wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
3380 wacom_notify_battery(wacom_wac, POWER_SUPPLY_STATUS_UNKNOWN, 0, 0, 0, 0);
3385 void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
3389 switch (wacom_wac->features.type) {
3391 sync = wacom_penpartner_irq(wacom_wac);
3395 sync = wacom_pl_irq(wacom_wac);
3402 sync = wacom_graphire_irq(wacom_wac);
3406 sync = wacom_ptu_irq(wacom_wac);
3410 sync = wacom_dtu_irq(wacom_wac);
3415 sync = wacom_dtus_irq(wacom_wac);
3434 case CINTIQ_COMPANION_2:
3435 sync = wacom_intuos_irq(wacom_wac);
3439 sync = wacom_intuos_bt_irq(wacom_wac, len);
3444 sync = wacom_24hdt_irq(wacom_wac);
3453 if (len == WACOM_PKGLEN_BBTOUCH3)
3454 sync = wacom_bpt3_touch(wacom_wac);
3455 else if (wacom_wac->data[0] == WACOM_REPORT_USB)
3456 sync = wacom_status_irq(wacom_wac, len);
3458 sync = wacom_intuos_irq(wacom_wac);
3464 sync = wacom_intuos_pro2_bt_irq(wacom_wac, len);
3473 sync = wacom_tpc_irq(wacom_wac, len);
3481 if (wacom_wac->data[0] == WACOM_REPORT_USB)
3482 sync = wacom_status_irq(wacom_wac, len);
3484 sync = wacom_bpt_irq(wacom_wac, len);
3488 sync = wacom_bamboo_pad_irq(wacom_wac, len);
3492 sync = wacom_wireless_irq(wacom_wac, len);
3497 if (wacom_wac->data[0] == WACOM_REPORT_DEVICE_LIST)
3498 wacom_remote_status_irq(wacom_wac, len);
3500 sync = wacom_remote_irq(wacom_wac, len);
3509 if (wacom_wac->pen_input)
3510 input_sync(wacom_wac->pen_input);
3511 if (wacom_wac->touch_input)
3512 input_sync(wacom_wac->touch_input);
3513 if (wacom_wac->pad_input)
3514 input_sync(wacom_wac->pad_input);
3518 static void wacom_setup_basic_pro_pen(struct wacom_wac *wacom_wac)
3520 struct input_dev *input_dev = wacom_wac->pen_input;
3522 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
3524 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3525 __set_bit(BTN_STYLUS, input_dev->keybit);
3526 __set_bit(BTN_STYLUS2, input_dev->keybit);
3528 input_set_abs_params(input_dev, ABS_DISTANCE,
3529 0, wacom_wac->features.distance_max, wacom_wac->features.distance_fuzz, 0);
3532 static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
3534 struct input_dev *input_dev = wacom_wac->pen_input;
3535 struct wacom_features *features = &wacom_wac->features;
3537 wacom_setup_basic_pro_pen(wacom_wac);
3539 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3540 __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
3541 __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
3542 __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
3544 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
3545 input_set_abs_params(input_dev, ABS_TILT_X, -64, 63, features->tilt_fuzz, 0);
3546 input_abs_set_res(input_dev, ABS_TILT_X, 57);
3547 input_set_abs_params(input_dev, ABS_TILT_Y, -64, 63, features->tilt_fuzz, 0);
3548 input_abs_set_res(input_dev, ABS_TILT_Y, 57);
3551 static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
3553 struct input_dev *input_dev = wacom_wac->pen_input;
3555 input_set_capability(input_dev, EV_REL, REL_WHEEL);
3557 wacom_setup_cintiq(wacom_wac);
3559 __set_bit(BTN_LEFT, input_dev->keybit);
3560 __set_bit(BTN_RIGHT, input_dev->keybit);
3561 __set_bit(BTN_MIDDLE, input_dev->keybit);
3562 __set_bit(BTN_SIDE, input_dev->keybit);
3563 __set_bit(BTN_EXTRA, input_dev->keybit);
3564 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
3565 __set_bit(BTN_TOOL_LENS, input_dev->keybit);
3567 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
3568 input_abs_set_res(input_dev, ABS_RZ, 287);
3569 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
3572 void wacom_setup_device_quirks(struct wacom *wacom)
3574 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
3575 struct wacom_features *features = &wacom->wacom_wac.features;
3577 /* The pen and pad share the same interface on most devices */
3578 if (features->type == GRAPHIRE_BT || features->type == WACOM_G4 ||
3579 features->type == DTUS ||
3580 (features->type >= INTUOS3S && features->type <= WACOM_MO)) {
3581 if (features->device_type & WACOM_DEVICETYPE_PEN)
3582 features->device_type |= WACOM_DEVICETYPE_PAD;
3585 /* touch device found but size is not defined. use default */
3586 if (features->device_type & WACOM_DEVICETYPE_TOUCH && !features->x_max) {
3587 features->x_max = 1023;
3588 features->y_max = 1023;
3592 * Intuos5/Pro and Bamboo 3rd gen have no useful data about its
3593 * touch interface in its HID descriptor. If this is the touch
3594 * interface (PacketSize of WACOM_PKGLEN_BBTOUCH3), override the
3597 if ((features->type >= INTUOS5S && features->type <= INTUOSPL) ||
3598 (features->type >= INTUOSHT && features->type <= BAMBOO_PT)) {
3599 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
3600 if (features->touch_max)
3601 features->device_type |= WACOM_DEVICETYPE_TOUCH;
3602 if (features->type >= INTUOSHT && features->type <= BAMBOO_PT)
3603 features->device_type |= WACOM_DEVICETYPE_PAD;
3605 if (features->type == INTUOSHT2) {
3606 features->x_max = features->x_max / 10;
3607 features->y_max = features->y_max / 10;
3610 features->x_max = 4096;
3611 features->y_max = 4096;
3614 else if (features->pktlen == WACOM_PKGLEN_BBTOUCH) {
3615 features->device_type |= WACOM_DEVICETYPE_PAD;
3620 * Hack for the Bamboo One:
3621 * the device presents a PAD/Touch interface as most Bamboos and even
3622 * sends ghosts PAD data on it. However, later, we must disable this
3623 * ghost interface, and we can not detect it unless we set it here
3624 * to WACOM_DEVICETYPE_PAD or WACOM_DEVICETYPE_TOUCH.
3626 if (features->type == BAMBOO_PEN &&
3627 features->pktlen == WACOM_PKGLEN_BBTOUCH3)
3628 features->device_type |= WACOM_DEVICETYPE_PAD;
3631 * Raw Wacom-mode pen and touch events both come from interface
3632 * 0, whose HID descriptor has an application usage of 0xFF0D
3633 * (i.e., WACOM_HID_WD_DIGITIZER). We route pen packets back
3634 * out through the HID_GENERIC device created for interface 1,
3635 * so rewrite this one to be of type WACOM_DEVICETYPE_TOUCH.
3637 if (features->type == BAMBOO_PAD)
3638 features->device_type = WACOM_DEVICETYPE_TOUCH;
3640 if (features->type == REMOTE)
3641 features->device_type = WACOM_DEVICETYPE_PAD;
3643 if (features->type == INTUOSP2_BT ||
3644 features->type == INTUOSP2S_BT) {
3645 features->device_type |= WACOM_DEVICETYPE_PEN |
3646 WACOM_DEVICETYPE_PAD |
3647 WACOM_DEVICETYPE_TOUCH;
3648 features->quirks |= WACOM_QUIRK_BATTERY;
3651 if (features->type == INTUOSHT3_BT) {
3652 features->device_type |= WACOM_DEVICETYPE_PEN |
3653 WACOM_DEVICETYPE_PAD;
3654 features->quirks |= WACOM_QUIRK_BATTERY;
3657 switch (features->type) {
3668 case CINTIQ_COMPANION_2:
3680 features->device_type |= WACOM_DEVICETYPE_DIRECT;
3684 if (wacom->hdev->bus == BUS_BLUETOOTH)
3685 features->quirks |= WACOM_QUIRK_BATTERY;
3687 /* quirk for bamboo touch with 2 low res touches */
3688 if ((features->type == BAMBOO_PT || features->type == BAMBOO_TOUCH) &&
3689 features->pktlen == WACOM_PKGLEN_BBTOUCH) {
3690 features->x_max <<= 5;
3691 features->y_max <<= 5;
3692 features->x_fuzz <<= 5;
3693 features->y_fuzz <<= 5;
3694 features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;
3697 if (features->type == WIRELESS) {
3698 if (features->device_type == WACOM_DEVICETYPE_WL_MONITOR) {
3699 features->quirks |= WACOM_QUIRK_BATTERY;
3703 if (features->type == REMOTE)
3704 features->device_type |= WACOM_DEVICETYPE_WL_MONITOR;
3706 /* HID descriptor for DTK-2451 / DTH-2452 claims to report lots
3707 * of things it shouldn't. Lets fix up the damage...
3709 if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
3710 features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3711 __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3712 __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3713 __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3714 __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3715 __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3716 __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3717 __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3718 __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3719 __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3720 __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3721 __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3725 int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
3726 struct wacom_wac *wacom_wac)
3728 struct wacom_features *features = &wacom_wac->features;
3730 if (!(features->device_type & WACOM_DEVICETYPE_PEN))
3733 if (features->device_type & WACOM_DEVICETYPE_DIRECT)
3734 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
3736 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
3738 if (features->type == HID_GENERIC)
3739 /* setup has already been done */
3742 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3743 __set_bit(BTN_TOUCH, input_dev->keybit);
3744 __set_bit(ABS_MISC, input_dev->absbit);
3746 input_set_abs_params(input_dev, ABS_X, 0 + features->offset_left,
3747 features->x_max - features->offset_right,
3748 features->x_fuzz, 0);
3749 input_set_abs_params(input_dev, ABS_Y, 0 + features->offset_top,
3750 features->y_max - features->offset_bottom,
3751 features->y_fuzz, 0);
3752 input_set_abs_params(input_dev, ABS_PRESSURE, 0,
3753 features->pressure_max, features->pressure_fuzz, 0);
3755 /* penabled devices have fixed resolution for each model */
3756 input_abs_set_res(input_dev, ABS_X, features->x_resolution);
3757 input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
3759 switch (features->type) {
3761 __clear_bit(ABS_MISC, input_dev->absbit);
3766 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3767 features->distance_max,
3768 features->distance_fuzz, 0);
3772 input_set_capability(input_dev, EV_REL, REL_WHEEL);
3774 __set_bit(BTN_LEFT, input_dev->keybit);
3775 __set_bit(BTN_RIGHT, input_dev->keybit);
3776 __set_bit(BTN_MIDDLE, input_dev->keybit);
3778 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3779 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3780 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
3781 __set_bit(BTN_STYLUS, input_dev->keybit);
3782 __set_bit(BTN_STYLUS2, input_dev->keybit);
3794 case CINTIQ_COMPANION_2:
3795 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3796 input_abs_set_res(input_dev, ABS_Z, 287);
3797 wacom_setup_cintiq(wacom_wac);
3807 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3808 input_abs_set_res(input_dev, ABS_Z, 287);
3812 wacom_setup_intuos(wacom_wac);
3823 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3824 features->distance_max,
3825 features->distance_fuzz, 0);
3827 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3828 input_abs_set_res(input_dev, ABS_Z, 287);
3830 wacom_setup_intuos(wacom_wac);
3841 __clear_bit(ABS_MISC, input_dev->absbit);
3848 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3849 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3850 __set_bit(BTN_STYLUS, input_dev->keybit);
3851 __set_bit(BTN_STYLUS2, input_dev->keybit);
3855 __set_bit(BTN_STYLUS2, input_dev->keybit);
3859 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3860 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3861 __set_bit(BTN_STYLUS, input_dev->keybit);
3869 if (features->type == INTUOSHT2 ||
3870 features->type == INTUOSHT3_BT) {
3871 wacom_setup_basic_pro_pen(wacom_wac);
3873 __clear_bit(ABS_MISC, input_dev->absbit);
3874 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3875 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3876 __set_bit(BTN_STYLUS, input_dev->keybit);
3877 __set_bit(BTN_STYLUS2, input_dev->keybit);
3878 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3879 features->distance_max,
3880 features->distance_fuzz, 0);
3884 __clear_bit(ABS_MISC, input_dev->absbit);
3890 int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
3891 struct wacom_wac *wacom_wac)
3893 struct wacom_features *features = &wacom_wac->features;
3895 if (!(features->device_type & WACOM_DEVICETYPE_TOUCH))
3898 if (features->device_type & WACOM_DEVICETYPE_DIRECT)
3899 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
3901 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
3903 if (features->type == HID_GENERIC)
3904 /* setup has already been done */
3907 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3908 __set_bit(BTN_TOUCH, input_dev->keybit);
3910 if (features->touch_max == 1) {
3911 input_set_abs_params(input_dev, ABS_X, 0,
3912 features->x_max, features->x_fuzz, 0);
3913 input_set_abs_params(input_dev, ABS_Y, 0,
3914 features->y_max, features->y_fuzz, 0);
3915 input_abs_set_res(input_dev, ABS_X,
3916 features->x_resolution);
3917 input_abs_set_res(input_dev, ABS_Y,
3918 features->y_resolution);
3920 else if (features->touch_max > 1) {
3921 input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
3922 features->x_max, features->x_fuzz, 0);
3923 input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
3924 features->y_max, features->y_fuzz, 0);
3925 input_abs_set_res(input_dev, ABS_MT_POSITION_X,
3926 features->x_resolution);
3927 input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
3928 features->y_resolution);
3931 switch (features->type) {
3934 input_dev->evbit[0] |= BIT_MASK(EV_SW);
3935 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
3937 if (wacom_wac->shared->touch->product == 0x361) {
3938 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
3940 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
3943 else if (wacom_wac->shared->touch->product == 0x360) {
3944 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
3946 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
3949 else if (wacom_wac->shared->touch->product == 0x393) {
3950 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
3952 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
3955 input_abs_set_res(input_dev, ABS_MT_POSITION_X, 40);
3956 input_abs_set_res(input_dev, ABS_MT_POSITION_Y, 40);
3966 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
3967 input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, features->y_max, 0, 0);
3968 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
3972 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
3973 input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
3974 input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
3975 input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
3979 if (wacom_wac->shared->touch->product == 0x32C ||
3980 wacom_wac->shared->touch->product == 0xF6) {
3981 input_dev->evbit[0] |= BIT_MASK(EV_SW);
3982 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
3983 wacom_wac->has_mute_touch_switch = true;
3984 wacom_wac->is_soft_touch_switch = true;
3992 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT);
4001 input_dev->evbit[0] |= BIT_MASK(EV_SW);
4002 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
4007 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
4008 input_set_abs_params(input_dev,
4010 0, features->x_max, 0, 0);
4011 input_set_abs_params(input_dev,
4013 0, features->y_max, 0, 0);
4015 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
4019 input_mt_init_slots(input_dev, features->touch_max,
4021 __set_bit(BTN_LEFT, input_dev->keybit);
4022 __set_bit(BTN_RIGHT, input_dev->keybit);
4028 static int wacom_numbered_button_to_key(int n)
4033 return BTN_A + (n-10);
4035 return BTN_BASE + (n-16);
4040 static void wacom_setup_numbered_buttons(struct input_dev *input_dev,
4045 for (i = 0; i < button_count; i++) {
4046 int key = wacom_numbered_button_to_key(i);
4049 __set_bit(key, input_dev->keybit);
4053 static void wacom_24hd_update_leds(struct wacom *wacom, int mask, int group)
4055 struct wacom_led *led;
4057 bool updated = false;
4060 * 24HD has LED group 1 to the left and LED group 0 to the right.
4061 * So group 0 matches the second half of the buttons and thus the mask
4062 * needs to be shifted.
4067 for (i = 0; i < 3; i++) {
4068 led = wacom_led_find(wacom, group, i);
4070 hid_err(wacom->hdev, "can't find LED %d in group %d\n",
4074 if (!updated && mask & BIT(i)) {
4076 led_trigger_event(&led->trigger, LED_FULL);
4083 static bool wacom_is_led_toggled(struct wacom *wacom, int button_count,
4084 int mask, int group)
4089 * 21UX2 has LED group 1 to the left and LED group 0
4090 * to the right. We need to reverse the group to match this
4091 * historical behavior.
4093 if (wacom->wacom_wac.features.type == WACOM_21UX2)
4096 group_button = group * (button_count/wacom->led.count);
4098 if (wacom->wacom_wac.features.type == INTUOSP2_BT)
4101 return mask & (1 << group_button);
4104 static void wacom_update_led(struct wacom *wacom, int button_count, int mask,
4107 struct wacom_led *led, *next_led;
4111 if (wacom->wacom_wac.features.type == WACOM_24HD)
4112 return wacom_24hd_update_leds(wacom, mask, group);
4114 pressed = wacom_is_led_toggled(wacom, button_count, mask, group);
4115 cur = wacom->led.groups[group].select;
4117 led = wacom_led_find(wacom, group, cur);
4119 hid_err(wacom->hdev, "can't find current LED %d in group %d\n",
4129 if (led->held && pressed)
4132 next_led = wacom_led_next(wacom, led);
4134 hid_err(wacom->hdev, "can't find next LED in group %d\n",
4138 if (next_led == led)
4141 next_led->held = true;
4142 led_trigger_event(&next_led->trigger,
4143 wacom_leds_brightness_get(next_led));
4146 static void wacom_report_numbered_buttons(struct input_dev *input_dev,
4147 int button_count, int mask)
4149 struct wacom *wacom = input_get_drvdata(input_dev);
4152 for (i = 0; i < wacom->led.count; i++)
4153 wacom_update_led(wacom, button_count, mask, i);
4155 for (i = 0; i < button_count; i++) {
4156 int key = wacom_numbered_button_to_key(i);
4159 input_report_key(input_dev, key, mask & (1 << i));
4163 int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
4164 struct wacom_wac *wacom_wac)
4166 struct wacom_features *features = &wacom_wac->features;
4168 if ((features->type == HID_GENERIC) && features->numbered_buttons > 0)
4169 features->device_type |= WACOM_DEVICETYPE_PAD;
4171 if (!(features->device_type & WACOM_DEVICETYPE_PAD))
4174 if (features->type == REMOTE && input_dev == wacom_wac->pad_input)
4177 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
4179 /* kept for making legacy xf86-input-wacom working with the wheels */
4180 __set_bit(ABS_MISC, input_dev->absbit);
4182 /* kept for making legacy xf86-input-wacom accepting the pad */
4183 if (!(input_dev->absinfo && (input_dev->absinfo[ABS_X].minimum ||
4184 input_dev->absinfo[ABS_X].maximum)))
4185 input_set_abs_params(input_dev, ABS_X, 0, 1, 0, 0);
4186 if (!(input_dev->absinfo && (input_dev->absinfo[ABS_Y].minimum ||
4187 input_dev->absinfo[ABS_Y].maximum)))
4188 input_set_abs_params(input_dev, ABS_Y, 0, 1, 0, 0);
4190 /* kept for making udev and libwacom accepting the pad */
4191 __set_bit(BTN_STYLUS, input_dev->keybit);
4193 wacom_setup_numbered_buttons(input_dev, features->numbered_buttons);
4195 switch (features->type) {
4198 case CINTIQ_COMPANION_2:
4205 __set_bit(BTN_BACK, input_dev->keybit);
4206 __set_bit(BTN_LEFT, input_dev->keybit);
4207 __set_bit(BTN_FORWARD, input_dev->keybit);
4208 __set_bit(BTN_RIGHT, input_dev->keybit);
4209 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4213 __set_bit(BTN_BACK, input_dev->keybit);
4214 __set_bit(BTN_FORWARD, input_dev->keybit);
4215 input_set_capability(input_dev, EV_REL, REL_WHEEL);
4219 __set_bit(KEY_PROG1, input_dev->keybit);
4220 __set_bit(KEY_PROG2, input_dev->keybit);
4221 __set_bit(KEY_PROG3, input_dev->keybit);
4223 __set_bit(KEY_ONSCREEN_KEYBOARD, input_dev->keybit);
4224 __set_bit(KEY_INFO, input_dev->keybit);
4226 if (!features->oPid)
4227 __set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
4229 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4230 input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
4234 __set_bit(KEY_PROG1, input_dev->keybit);
4235 __set_bit(KEY_PROG2, input_dev->keybit);
4236 __set_bit(KEY_PROG3, input_dev->keybit);
4238 __set_bit(KEY_ONSCREEN_KEYBOARD, input_dev->keybit);
4239 __set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
4241 if (!features->oPid)
4242 __set_bit(KEY_CONTROLPANEL, input_dev->keybit);
4243 input_set_abs_params(input_dev, ABS_X, -2048, 2048, 0, 0);
4244 input_abs_set_res(input_dev, ABS_X, 1024); /* points/g */
4245 input_set_abs_params(input_dev, ABS_Y, -2048, 2048, 0, 0);
4246 input_abs_set_res(input_dev, ABS_Y, 1024);
4247 input_set_abs_params(input_dev, ABS_Z, -2048, 2048, 0, 0);
4248 input_abs_set_res(input_dev, ABS_Z, 1024);
4249 __set_bit(INPUT_PROP_ACCELEROMETER, input_dev->propbit);
4253 __set_bit(KEY_PROG1, input_dev->keybit);
4254 __set_bit(KEY_PROG2, input_dev->keybit);
4255 __set_bit(KEY_PROG3, input_dev->keybit);
4257 __set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
4258 __set_bit(KEY_INFO, input_dev->keybit);
4264 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
4265 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
4269 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4274 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
4278 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
4289 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4294 * For Bluetooth devices, the udev rule does not work correctly
4295 * for pads unless we add a stylus capability, which forces
4296 * ID_INPUT_TABLET to be set.
4298 __set_bit(BTN_STYLUS, input_dev->keybit);
4304 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4311 __clear_bit(ABS_MISC, input_dev->absbit);
4313 __set_bit(BTN_LEFT, input_dev->keybit);
4314 __set_bit(BTN_FORWARD, input_dev->keybit);
4315 __set_bit(BTN_BACK, input_dev->keybit);
4316 __set_bit(BTN_RIGHT, input_dev->keybit);
4321 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
4322 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4330 /* no pad supported */
4336 static const struct wacom_features wacom_features_0x00 =
4337 { "Wacom Penpartner", 5040, 3780, 255, 0,
4338 PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
4339 static const struct wacom_features wacom_features_0x10 =
4340 { "Wacom Graphire", 10206, 7422, 511, 63,
4341 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4342 static const struct wacom_features wacom_features_0x81 =
4343 { "Wacom Graphire BT", 16704, 12064, 511, 32,
4344 GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES, 2 };
4345 static const struct wacom_features wacom_features_0x11 =
4346 { "Wacom Graphire2 4x5", 10206, 7422, 511, 63,
4347 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4348 static const struct wacom_features wacom_features_0x12 =
4349 { "Wacom Graphire2 5x7", 13918, 10206, 511, 63,
4350 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4351 static const struct wacom_features wacom_features_0x13 =
4352 { "Wacom Graphire3", 10208, 7424, 511, 63,
4353 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4354 static const struct wacom_features wacom_features_0x14 =
4355 { "Wacom Graphire3 6x8", 16704, 12064, 511, 63,
4356 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4357 static const struct wacom_features wacom_features_0x15 =
4358 { "Wacom Graphire4 4x5", 10208, 7424, 511, 63,
4359 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4360 static const struct wacom_features wacom_features_0x16 =
4361 { "Wacom Graphire4 6x8", 16704, 12064, 511, 63,
4362 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4363 static const struct wacom_features wacom_features_0x17 =
4364 { "Wacom BambooFun 4x5", 14760, 9225, 511, 63,
4365 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4366 static const struct wacom_features wacom_features_0x18 =
4367 { "Wacom BambooFun 6x8", 21648, 13530, 511, 63,
4368 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4369 static const struct wacom_features wacom_features_0x19 =
4370 { "Wacom Bamboo1 Medium", 16704, 12064, 511, 63,
4371 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4372 static const struct wacom_features wacom_features_0x60 =
4373 { "Wacom Volito", 5104, 3712, 511, 63,
4374 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4375 static const struct wacom_features wacom_features_0x61 =
4376 { "Wacom PenStation2", 3250, 2320, 255, 63,
4377 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4378 static const struct wacom_features wacom_features_0x62 =
4379 { "Wacom Volito2 4x5", 5104, 3712, 511, 63,
4380 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4381 static const struct wacom_features wacom_features_0x63 =
4382 { "Wacom Volito2 2x3", 3248, 2320, 511, 63,
4383 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4384 static const struct wacom_features wacom_features_0x64 =
4385 { "Wacom PenPartner2", 3250, 2320, 511, 63,
4386 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4387 static const struct wacom_features wacom_features_0x65 =
4388 { "Wacom Bamboo", 14760, 9225, 511, 63,
4389 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4390 static const struct wacom_features wacom_features_0x69 =
4391 { "Wacom Bamboo1", 5104, 3712, 511, 63,
4392 GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
4393 static const struct wacom_features wacom_features_0x6A =
4394 { "Wacom Bamboo1 4x6", 14760, 9225, 1023, 63,
4395 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4396 static const struct wacom_features wacom_features_0x6B =
4397 { "Wacom Bamboo1 5x8", 21648, 13530, 1023, 63,
4398 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4399 static const struct wacom_features wacom_features_0x20 =
4400 { "Wacom Intuos 4x5", 12700, 10600, 1023, 31,
4401 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4402 static const struct wacom_features wacom_features_0x21 =
4403 { "Wacom Intuos 6x8", 20320, 16240, 1023, 31,
4404 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4405 static const struct wacom_features wacom_features_0x22 =
4406 { "Wacom Intuos 9x12", 30480, 24060, 1023, 31,
4407 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4408 static const struct wacom_features wacom_features_0x23 =
4409 { "Wacom Intuos 12x12", 30480, 31680, 1023, 31,
4410 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4411 static const struct wacom_features wacom_features_0x24 =
4412 { "Wacom Intuos 12x18", 45720, 31680, 1023, 31,
4413 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4414 static const struct wacom_features wacom_features_0x30 =
4415 { "Wacom PL400", 5408, 4056, 255, 0,
4416 PL, WACOM_PL_RES, WACOM_PL_RES };
4417 static const struct wacom_features wacom_features_0x31 =
4418 { "Wacom PL500", 6144, 4608, 255, 0,
4419 PL, WACOM_PL_RES, WACOM_PL_RES };
4420 static const struct wacom_features wacom_features_0x32 =
4421 { "Wacom PL600", 6126, 4604, 255, 0,
4422 PL, WACOM_PL_RES, WACOM_PL_RES };
4423 static const struct wacom_features wacom_features_0x33 =
4424 { "Wacom PL600SX", 6260, 5016, 255, 0,
4425 PL, WACOM_PL_RES, WACOM_PL_RES };
4426 static const struct wacom_features wacom_features_0x34 =
4427 { "Wacom PL550", 6144, 4608, 511, 0,
4428 PL, WACOM_PL_RES, WACOM_PL_RES };
4429 static const struct wacom_features wacom_features_0x35 =
4430 { "Wacom PL800", 7220, 5780, 511, 0,
4431 PL, WACOM_PL_RES, WACOM_PL_RES };
4432 static const struct wacom_features wacom_features_0x37 =
4433 { "Wacom PL700", 6758, 5406, 511, 0,
4434 PL, WACOM_PL_RES, WACOM_PL_RES };
4435 static const struct wacom_features wacom_features_0x38 =
4436 { "Wacom PL510", 6282, 4762, 511, 0,
4437 PL, WACOM_PL_RES, WACOM_PL_RES };
4438 static const struct wacom_features wacom_features_0x39 =
4439 { "Wacom DTU710", 34080, 27660, 511, 0,
4440 PL, WACOM_PL_RES, WACOM_PL_RES };
4441 static const struct wacom_features wacom_features_0xC4 =
4442 { "Wacom DTF521", 6282, 4762, 511, 0,
4443 PL, WACOM_PL_RES, WACOM_PL_RES };
4444 static const struct wacom_features wacom_features_0xC0 =
4445 { "Wacom DTF720", 6858, 5506, 511, 0,
4446 PL, WACOM_PL_RES, WACOM_PL_RES };
4447 static const struct wacom_features wacom_features_0xC2 =
4448 { "Wacom DTF720a", 6858, 5506, 511, 0,
4449 PL, WACOM_PL_RES, WACOM_PL_RES };
4450 static const struct wacom_features wacom_features_0x03 =
4451 { "Wacom Cintiq Partner", 20480, 15360, 511, 0,
4452 PTU, WACOM_PL_RES, WACOM_PL_RES };
4453 static const struct wacom_features wacom_features_0x41 =
4454 { "Wacom Intuos2 4x5", 12700, 10600, 1023, 31,
4455 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4456 static const struct wacom_features wacom_features_0x42 =
4457 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
4458 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4459 static const struct wacom_features wacom_features_0x43 =
4460 { "Wacom Intuos2 9x12", 30480, 24060, 1023, 31,
4461 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4462 static const struct wacom_features wacom_features_0x44 =
4463 { "Wacom Intuos2 12x12", 30480, 31680, 1023, 31,
4464 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4465 static const struct wacom_features wacom_features_0x45 =
4466 { "Wacom Intuos2 12x18", 45720, 31680, 1023, 31,
4467 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4468 static const struct wacom_features wacom_features_0xB0 =
4469 { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63,
4470 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
4471 static const struct wacom_features wacom_features_0xB1 =
4472 { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63,
4473 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4474 static const struct wacom_features wacom_features_0xB2 =
4475 { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63,
4476 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4477 static const struct wacom_features wacom_features_0xB3 =
4478 { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63,
4479 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4480 static const struct wacom_features wacom_features_0xB4 =
4481 { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63,
4482 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4483 static const struct wacom_features wacom_features_0xB5 =
4484 { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63,
4485 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4486 static const struct wacom_features wacom_features_0xB7 =
4487 { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63,
4488 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
4489 static const struct wacom_features wacom_features_0xB8 =
4490 { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63,
4491 INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
4492 static const struct wacom_features wacom_features_0xB9 =
4493 { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63,
4494 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4495 static const struct wacom_features wacom_features_0xBA =
4496 { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63,
4497 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4498 static const struct wacom_features wacom_features_0xBB =
4499 { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63,
4500 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4501 static const struct wacom_features wacom_features_0xBC =
4502 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
4503 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4504 static const struct wacom_features wacom_features_0xBD =
4505 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
4506 INTUOS4WL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4507 static const struct wacom_features wacom_features_0x26 =
4508 { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63,
4509 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16 };
4510 static const struct wacom_features wacom_features_0x27 =
4511 { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63,
4512 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
4513 static const struct wacom_features wacom_features_0x28 =
4514 { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63,
4515 INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
4516 static const struct wacom_features wacom_features_0x29 =
4517 { "Wacom Intuos5 S", 31496, 19685, 2047, 63,
4518 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
4519 static const struct wacom_features wacom_features_0x2A =
4520 { "Wacom Intuos5 M", 44704, 27940, 2047, 63,
4521 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4522 static const struct wacom_features wacom_features_0x314 =
4523 { "Wacom Intuos Pro S", 31496, 19685, 2047, 63,
4524 INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16,
4525 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4526 static const struct wacom_features wacom_features_0x315 =
4527 { "Wacom Intuos Pro M", 44704, 27940, 2047, 63,
4528 INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
4529 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4530 static const struct wacom_features wacom_features_0x317 =
4531 { "Wacom Intuos Pro L", 65024, 40640, 2047, 63,
4532 INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
4533 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4534 static const struct wacom_features wacom_features_0xF4 =
4535 { "Wacom Cintiq 24HD", 104480, 65600, 2047, 63,
4536 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
4537 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4538 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4539 static const struct wacom_features wacom_features_0xF8 =
4540 { "Wacom Cintiq 24HD touch", 104480, 65600, 2047, 63, /* Pen */
4541 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
4542 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4543 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4544 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 };
4545 static const struct wacom_features wacom_features_0xF6 =
4546 { "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */
4547 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10,
4548 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4549 static const struct wacom_features wacom_features_0x32A =
4550 { "Wacom Cintiq 27QHD", 120140, 67920, 2047, 63,
4551 WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
4552 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4553 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4554 static const struct wacom_features wacom_features_0x32B =
4555 { "Wacom Cintiq 27QHD touch", 120140, 67920, 2047, 63,
4556 WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
4557 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4558 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4559 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32C };
4560 static const struct wacom_features wacom_features_0x32C =
4561 { "Wacom Cintiq 27QHD touch", .type = WACOM_27QHDT,
4562 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32B, .touch_max = 10 };
4563 static const struct wacom_features wacom_features_0x3F =
4564 { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63,
4565 CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4566 static const struct wacom_features wacom_features_0xC5 =
4567 { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63,
4568 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
4569 static const struct wacom_features wacom_features_0xC6 =
4570 { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63,
4571 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
4572 static const struct wacom_features wacom_features_0x304 =
4573 { "Wacom Cintiq 13HD", 59552, 33848, 1023, 63,
4574 WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4575 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4576 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4577 static const struct wacom_features wacom_features_0x333 =
4578 { "Wacom Cintiq 13HD touch", 59552, 33848, 2047, 63,
4579 WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4580 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4581 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4582 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x335 };
4583 static const struct wacom_features wacom_features_0x335 =
4584 { "Wacom Cintiq 13HD touch", .type = WACOM_24HDT, /* Touch */
4585 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x333, .touch_max = 10,
4586 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4587 static const struct wacom_features wacom_features_0xC7 =
4588 { "Wacom DTU1931", 37832, 30305, 511, 0,
4589 PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4590 static const struct wacom_features wacom_features_0xCE =
4591 { "Wacom DTU2231", 47864, 27011, 511, 0,
4592 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4593 .check_for_hid_type = true, .hid_type = HID_TYPE_USBMOUSE };
4594 static const struct wacom_features wacom_features_0xF0 =
4595 { "Wacom DTU1631", 34623, 19553, 511, 0,
4596 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4597 static const struct wacom_features wacom_features_0xFB =
4598 { "Wacom DTU1031", 22096, 13960, 511, 0,
4599 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
4600 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4601 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4602 static const struct wacom_features wacom_features_0x32F =
4603 { "Wacom DTU1031X", 22672, 12928, 511, 0,
4604 DTUSX, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 0,
4605 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4606 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4607 static const struct wacom_features wacom_features_0x336 =
4608 { "Wacom DTU1141", 23672, 13403, 1023, 0,
4609 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
4610 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4611 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4612 static const struct wacom_features wacom_features_0x57 =
4613 { "Wacom DTK2241", 95840, 54260, 2047, 63,
4614 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
4615 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4616 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4617 static const struct wacom_features wacom_features_0x59 = /* Pen */
4618 { "Wacom DTH2242", 95840, 54260, 2047, 63,
4619 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
4620 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4621 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4622 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D };
4623 static const struct wacom_features wacom_features_0x5D = /* Touch */
4624 { "Wacom DTH2242", .type = WACOM_24HDT,
4625 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10,
4626 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4627 static const struct wacom_features wacom_features_0xCC =
4628 { "Wacom Cintiq 21UX2", 87200, 65600, 2047, 63,
4629 WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
4630 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4631 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4632 static const struct wacom_features wacom_features_0xFA =
4633 { "Wacom Cintiq 22HD", 95840, 54260, 2047, 63,
4634 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
4635 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4636 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4637 static const struct wacom_features wacom_features_0x5B =
4638 { "Wacom Cintiq 22HDT", 95840, 54260, 2047, 63,
4639 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
4640 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4641 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4642 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e };
4643 static const struct wacom_features wacom_features_0x5E =
4644 { "Wacom Cintiq 22HDT", .type = WACOM_24HDT,
4645 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5b, .touch_max = 10,
4646 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4647 static const struct wacom_features wacom_features_0x90 =
4648 { "Wacom ISDv4 90", 26202, 16325, 255, 0,
4649 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4650 static const struct wacom_features wacom_features_0x93 =
4651 { "Wacom ISDv4 93", 26202, 16325, 255, 0,
4652 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4653 static const struct wacom_features wacom_features_0x97 =
4654 { "Wacom ISDv4 97", 26202, 16325, 511, 0,
4655 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4656 static const struct wacom_features wacom_features_0x9A =
4657 { "Wacom ISDv4 9A", 26202, 16325, 255, 0,
4658 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4659 static const struct wacom_features wacom_features_0x9F =
4660 { "Wacom ISDv4 9F", 26202, 16325, 255, 0,
4661 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4662 static const struct wacom_features wacom_features_0xE2 =
4663 { "Wacom ISDv4 E2", 26202, 16325, 255, 0,
4664 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4665 static const struct wacom_features wacom_features_0xE3 =
4666 { "Wacom ISDv4 E3", 26202, 16325, 255, 0,
4667 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4668 static const struct wacom_features wacom_features_0xE5 =
4669 { "Wacom ISDv4 E5", 26202, 16325, 255, 0,
4670 MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4671 static const struct wacom_features wacom_features_0xE6 =
4672 { "Wacom ISDv4 E6", 27760, 15694, 255, 0,
4673 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4674 static const struct wacom_features wacom_features_0xEC =
4675 { "Wacom ISDv4 EC", 25710, 14500, 255, 0,
4676 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4677 static const struct wacom_features wacom_features_0xED =
4678 { "Wacom ISDv4 ED", 26202, 16325, 255, 0,
4679 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4680 static const struct wacom_features wacom_features_0xEF =
4681 { "Wacom ISDv4 EF", 26202, 16325, 255, 0,
4682 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4683 static const struct wacom_features wacom_features_0x100 =
4684 { "Wacom ISDv4 100", 26202, 16325, 255, 0,
4685 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4686 static const struct wacom_features wacom_features_0x101 =
4687 { "Wacom ISDv4 101", 26202, 16325, 255, 0,
4688 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4689 static const struct wacom_features wacom_features_0x10D =
4690 { "Wacom ISDv4 10D", 26202, 16325, 255, 0,
4691 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4692 static const struct wacom_features wacom_features_0x10E =
4693 { "Wacom ISDv4 10E", 27760, 15694, 255, 0,
4694 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4695 static const struct wacom_features wacom_features_0x10F =
4696 { "Wacom ISDv4 10F", 27760, 15694, 255, 0,
4697 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4698 static const struct wacom_features wacom_features_0x116 =
4699 { "Wacom ISDv4 116", 26202, 16325, 255, 0,
4700 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4701 static const struct wacom_features wacom_features_0x12C =
4702 { "Wacom ISDv4 12C", 27848, 15752, 2047, 0,
4703 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4704 static const struct wacom_features wacom_features_0x4001 =
4705 { "Wacom ISDv4 4001", 26202, 16325, 255, 0,
4706 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4707 static const struct wacom_features wacom_features_0x4004 =
4708 { "Wacom ISDv4 4004", 11060, 6220, 255, 0,
4709 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4710 static const struct wacom_features wacom_features_0x5000 =
4711 { "Wacom ISDv4 5000", 27848, 15752, 1023, 0,
4712 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4713 static const struct wacom_features wacom_features_0x5002 =
4714 { "Wacom ISDv4 5002", 29576, 16724, 1023, 0,
4715 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4716 static const struct wacom_features wacom_features_0x47 =
4717 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
4718 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4719 static const struct wacom_features wacom_features_0x84 =
4720 { "Wacom Wireless Receiver", .type = WIRELESS, .touch_max = 16 };
4721 static const struct wacom_features wacom_features_0xD0 =
4722 { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31,
4723 BAMBOO_TOUCH, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4724 static const struct wacom_features wacom_features_0xD1 =
4725 { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31,
4726 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4727 static const struct wacom_features wacom_features_0xD2 =
4728 { "Wacom Bamboo Craft", 14720, 9200, 1023, 31,
4729 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4730 static const struct wacom_features wacom_features_0xD3 =
4731 { "Wacom Bamboo 2FG 6x8", 21648, 13700, 1023, 31,
4732 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4733 static const struct wacom_features wacom_features_0xD4 =
4734 { "Wacom Bamboo Pen", 14720, 9200, 1023, 31,
4735 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4736 static const struct wacom_features wacom_features_0xD5 =
4737 { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31,
4738 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4739 static const struct wacom_features wacom_features_0xD6 =
4740 { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31,
4741 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4742 static const struct wacom_features wacom_features_0xD7 =
4743 { "Wacom BambooPT 2FG Small", 14720, 9200, 1023, 31,
4744 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4745 static const struct wacom_features wacom_features_0xD8 =
4746 { "Wacom Bamboo Comic 2FG", 21648, 13700, 1023, 31,
4747 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4748 static const struct wacom_features wacom_features_0xDA =
4749 { "Wacom Bamboo 2FG 4x5 SE", 14720, 9200, 1023, 31,
4750 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4751 static const struct wacom_features wacom_features_0xDB =
4752 { "Wacom Bamboo 2FG 6x8 SE", 21648, 13700, 1023, 31,
4753 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4754 static const struct wacom_features wacom_features_0xDD =
4755 { "Wacom Bamboo Connect", 14720, 9200, 1023, 31,
4756 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4757 static const struct wacom_features wacom_features_0xDE =
4758 { "Wacom Bamboo 16FG 4x5", 14720, 9200, 1023, 31,
4759 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
4760 static const struct wacom_features wacom_features_0xDF =
4761 { "Wacom Bamboo 16FG 6x8", 21648, 13700, 1023, 31,
4762 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
4763 static const struct wacom_features wacom_features_0x300 =
4764 { "Wacom Bamboo One S", 14720, 9225, 1023, 31,
4765 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4766 static const struct wacom_features wacom_features_0x301 =
4767 { "Wacom Bamboo One M", 21648, 13530, 1023, 31,
4768 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4769 static const struct wacom_features wacom_features_0x302 =
4770 { "Wacom Intuos PT S", 15200, 9500, 1023, 31,
4771 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4772 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4773 static const struct wacom_features wacom_features_0x303 =
4774 { "Wacom Intuos PT M", 21600, 13500, 1023, 31,
4775 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4776 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4777 static const struct wacom_features wacom_features_0x30E =
4778 { "Wacom Intuos S", 15200, 9500, 1023, 31,
4779 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4780 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4781 static const struct wacom_features wacom_features_0x6004 =
4782 { "ISD-V4", 12800, 8000, 255, 0,
4783 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4784 static const struct wacom_features wacom_features_0x307 =
4785 { "Wacom ISDv5 307", 59552, 33848, 2047, 63,
4786 CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4787 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4788 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4789 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 };
4790 static const struct wacom_features wacom_features_0x309 =
4791 { "Wacom ISDv5 309", .type = WACOM_24HDT, /* Touch */
4792 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x0307, .touch_max = 10,
4793 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4794 static const struct wacom_features wacom_features_0x30A =
4795 { "Wacom ISDv5 30A", 59552, 33848, 2047, 63,
4796 CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4797 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4798 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4799 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30C };
4800 static const struct wacom_features wacom_features_0x30C =
4801 { "Wacom ISDv5 30C", .type = WACOM_24HDT, /* Touch */
4802 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30A, .touch_max = 10,
4803 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4804 static const struct wacom_features wacom_features_0x318 =
4805 { "Wacom USB Bamboo PAD", 4095, 4095, /* Touch */
4806 .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
4807 static const struct wacom_features wacom_features_0x319 =
4808 { "Wacom Wireless Bamboo PAD", 4095, 4095, /* Touch */
4809 .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
4810 static const struct wacom_features wacom_features_0x325 =
4811 { "Wacom ISDv5 325", 59552, 33848, 2047, 63,
4812 CINTIQ_COMPANION_2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 11,
4813 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4814 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4815 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x326 };
4816 static const struct wacom_features wacom_features_0x326 = /* Touch */
4817 { "Wacom ISDv5 326", .type = HID_GENERIC, .oVid = USB_VENDOR_ID_WACOM,
4819 static const struct wacom_features wacom_features_0x323 =
4820 { "Wacom Intuos P M", 21600, 13500, 1023, 31,
4821 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4822 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4823 static const struct wacom_features wacom_features_0x331 =
4824 { "Wacom Express Key Remote", .type = REMOTE,
4825 .numbered_buttons = 18, .check_for_hid_type = true,
4826 .hid_type = HID_TYPE_USBNONE };
4827 static const struct wacom_features wacom_features_0x33B =
4828 { "Wacom Intuos S 2", 15200, 9500, 2047, 63,
4829 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4830 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4831 static const struct wacom_features wacom_features_0x33C =
4832 { "Wacom Intuos PT S 2", 15200, 9500, 2047, 63,
4833 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4834 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4835 static const struct wacom_features wacom_features_0x33D =
4836 { "Wacom Intuos P M 2", 21600, 13500, 2047, 63,
4837 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4838 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4839 static const struct wacom_features wacom_features_0x33E =
4840 { "Wacom Intuos PT M 2", 21600, 13500, 2047, 63,
4841 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4842 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4843 static const struct wacom_features wacom_features_0x343 =
4844 { "Wacom DTK1651", 34816, 19759, 1023, 0,
4845 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
4846 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4847 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4848 static const struct wacom_features wacom_features_0x360 =
4849 { "Wacom Intuos Pro M", 44800, 29600, 8191, 63,
4850 INTUOSP2_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 10 };
4851 static const struct wacom_features wacom_features_0x361 =
4852 { "Wacom Intuos Pro L", 62200, 43200, 8191, 63,
4853 INTUOSP2_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 10 };
4854 static const struct wacom_features wacom_features_0x377 =
4855 { "Wacom Intuos BT S", 15200, 9500, 4095, 63,
4856 INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
4857 static const struct wacom_features wacom_features_0x379 =
4858 { "Wacom Intuos BT M", 21600, 13500, 4095, 63,
4859 INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
4860 static const struct wacom_features wacom_features_0x37A =
4861 { "Wacom One by Wacom S", 15200, 9500, 2047, 63,
4862 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4863 static const struct wacom_features wacom_features_0x37B =
4864 { "Wacom One by Wacom M", 21600, 13500, 2047, 63,
4865 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4866 static const struct wacom_features wacom_features_0x393 =
4867 { "Wacom Intuos Pro S", 31920, 19950, 8191, 63,
4868 INTUOSP2S_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7,
4870 static const struct wacom_features wacom_features_0x3c6 =
4871 { "Wacom Intuos BT S", 15200, 9500, 4095, 63,
4872 INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
4873 static const struct wacom_features wacom_features_0x3c8 =
4874 { "Wacom Intuos BT M", 21600, 13500, 4095, 63,
4875 INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
4876 static const struct wacom_features wacom_features_0x3dd =
4877 { "Wacom Intuos Pro S", 31920, 19950, 8191, 63,
4878 INTUOSP2S_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7,
4881 static const struct wacom_features wacom_features_HID_ANY_ID =
4882 { "Wacom HID", .type = HID_GENERIC, .oVid = HID_ANY_ID, .oPid = HID_ANY_ID };
4884 #define USB_DEVICE_WACOM(prod) \
4885 HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4886 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4888 #define BT_DEVICE_WACOM(prod) \
4889 HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4890 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4892 #define I2C_DEVICE_WACOM(prod) \
4893 HID_DEVICE(BUS_I2C, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4894 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4896 #define USB_DEVICE_LENOVO(prod) \
4897 HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
4898 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4900 const struct hid_device_id wacom_ids[] = {
4901 { USB_DEVICE_WACOM(0x00) },
4902 { USB_DEVICE_WACOM(0x03) },
4903 { USB_DEVICE_WACOM(0x10) },
4904 { USB_DEVICE_WACOM(0x11) },
4905 { USB_DEVICE_WACOM(0x12) },
4906 { USB_DEVICE_WACOM(0x13) },
4907 { USB_DEVICE_WACOM(0x14) },
4908 { USB_DEVICE_WACOM(0x15) },
4909 { USB_DEVICE_WACOM(0x16) },
4910 { USB_DEVICE_WACOM(0x17) },
4911 { USB_DEVICE_WACOM(0x18) },
4912 { USB_DEVICE_WACOM(0x19) },
4913 { USB_DEVICE_WACOM(0x20) },
4914 { USB_DEVICE_WACOM(0x21) },
4915 { USB_DEVICE_WACOM(0x22) },
4916 { USB_DEVICE_WACOM(0x23) },
4917 { USB_DEVICE_WACOM(0x24) },
4918 { USB_DEVICE_WACOM(0x26) },
4919 { USB_DEVICE_WACOM(0x27) },
4920 { USB_DEVICE_WACOM(0x28) },
4921 { USB_DEVICE_WACOM(0x29) },
4922 { USB_DEVICE_WACOM(0x2A) },
4923 { USB_DEVICE_WACOM(0x30) },
4924 { USB_DEVICE_WACOM(0x31) },
4925 { USB_DEVICE_WACOM(0x32) },
4926 { USB_DEVICE_WACOM(0x33) },
4927 { USB_DEVICE_WACOM(0x34) },
4928 { USB_DEVICE_WACOM(0x35) },
4929 { USB_DEVICE_WACOM(0x37) },
4930 { USB_DEVICE_WACOM(0x38) },
4931 { USB_DEVICE_WACOM(0x39) },
4932 { USB_DEVICE_WACOM(0x3F) },
4933 { USB_DEVICE_WACOM(0x41) },
4934 { USB_DEVICE_WACOM(0x42) },
4935 { USB_DEVICE_WACOM(0x43) },
4936 { USB_DEVICE_WACOM(0x44) },
4937 { USB_DEVICE_WACOM(0x45) },
4938 { USB_DEVICE_WACOM(0x47) },
4939 { USB_DEVICE_WACOM(0x57) },
4940 { USB_DEVICE_WACOM(0x59) },
4941 { USB_DEVICE_WACOM(0x5B) },
4942 { USB_DEVICE_WACOM(0x5D) },
4943 { USB_DEVICE_WACOM(0x5E) },
4944 { USB_DEVICE_WACOM(0x60) },
4945 { USB_DEVICE_WACOM(0x61) },
4946 { USB_DEVICE_WACOM(0x62) },
4947 { USB_DEVICE_WACOM(0x63) },
4948 { USB_DEVICE_WACOM(0x64) },
4949 { USB_DEVICE_WACOM(0x65) },
4950 { USB_DEVICE_WACOM(0x69) },
4951 { USB_DEVICE_WACOM(0x6A) },
4952 { USB_DEVICE_WACOM(0x6B) },
4953 { BT_DEVICE_WACOM(0x81) },
4954 { USB_DEVICE_WACOM(0x84) },
4955 { USB_DEVICE_WACOM(0x90) },
4956 { USB_DEVICE_WACOM(0x93) },
4957 { USB_DEVICE_WACOM(0x97) },
4958 { USB_DEVICE_WACOM(0x9A) },
4959 { USB_DEVICE_WACOM(0x9F) },
4960 { USB_DEVICE_WACOM(0xB0) },
4961 { USB_DEVICE_WACOM(0xB1) },
4962 { USB_DEVICE_WACOM(0xB2) },
4963 { USB_DEVICE_WACOM(0xB3) },
4964 { USB_DEVICE_WACOM(0xB4) },
4965 { USB_DEVICE_WACOM(0xB5) },
4966 { USB_DEVICE_WACOM(0xB7) },
4967 { USB_DEVICE_WACOM(0xB8) },
4968 { USB_DEVICE_WACOM(0xB9) },
4969 { USB_DEVICE_WACOM(0xBA) },
4970 { USB_DEVICE_WACOM(0xBB) },
4971 { USB_DEVICE_WACOM(0xBC) },
4972 { BT_DEVICE_WACOM(0xBD) },
4973 { USB_DEVICE_WACOM(0xC0) },
4974 { USB_DEVICE_WACOM(0xC2) },
4975 { USB_DEVICE_WACOM(0xC4) },
4976 { USB_DEVICE_WACOM(0xC5) },
4977 { USB_DEVICE_WACOM(0xC6) },
4978 { USB_DEVICE_WACOM(0xC7) },
4979 { USB_DEVICE_WACOM(0xCC) },
4980 { USB_DEVICE_WACOM(0xCE) },
4981 { USB_DEVICE_WACOM(0xD0) },
4982 { USB_DEVICE_WACOM(0xD1) },
4983 { USB_DEVICE_WACOM(0xD2) },
4984 { USB_DEVICE_WACOM(0xD3) },
4985 { USB_DEVICE_WACOM(0xD4) },
4986 { USB_DEVICE_WACOM(0xD5) },
4987 { USB_DEVICE_WACOM(0xD6) },
4988 { USB_DEVICE_WACOM(0xD7) },
4989 { USB_DEVICE_WACOM(0xD8) },
4990 { USB_DEVICE_WACOM(0xDA) },
4991 { USB_DEVICE_WACOM(0xDB) },
4992 { USB_DEVICE_WACOM(0xDD) },
4993 { USB_DEVICE_WACOM(0xDE) },
4994 { USB_DEVICE_WACOM(0xDF) },
4995 { USB_DEVICE_WACOM(0xE2) },
4996 { USB_DEVICE_WACOM(0xE3) },
4997 { USB_DEVICE_WACOM(0xE5) },
4998 { USB_DEVICE_WACOM(0xE6) },
4999 { USB_DEVICE_WACOM(0xEC) },
5000 { USB_DEVICE_WACOM(0xED) },
5001 { USB_DEVICE_WACOM(0xEF) },
5002 { USB_DEVICE_WACOM(0xF0) },
5003 { USB_DEVICE_WACOM(0xF4) },
5004 { USB_DEVICE_WACOM(0xF6) },
5005 { USB_DEVICE_WACOM(0xF8) },
5006 { USB_DEVICE_WACOM(0xFA) },
5007 { USB_DEVICE_WACOM(0xFB) },
5008 { USB_DEVICE_WACOM(0x100) },
5009 { USB_DEVICE_WACOM(0x101) },
5010 { USB_DEVICE_WACOM(0x10D) },
5011 { USB_DEVICE_WACOM(0x10E) },
5012 { USB_DEVICE_WACOM(0x10F) },
5013 { USB_DEVICE_WACOM(0x116) },
5014 { USB_DEVICE_WACOM(0x12C) },
5015 { USB_DEVICE_WACOM(0x300) },
5016 { USB_DEVICE_WACOM(0x301) },
5017 { USB_DEVICE_WACOM(0x302) },
5018 { USB_DEVICE_WACOM(0x303) },
5019 { USB_DEVICE_WACOM(0x304) },
5020 { USB_DEVICE_WACOM(0x307) },
5021 { USB_DEVICE_WACOM(0x309) },
5022 { USB_DEVICE_WACOM(0x30A) },
5023 { USB_DEVICE_WACOM(0x30C) },
5024 { USB_DEVICE_WACOM(0x30E) },
5025 { USB_DEVICE_WACOM(0x314) },
5026 { USB_DEVICE_WACOM(0x315) },
5027 { USB_DEVICE_WACOM(0x317) },
5028 { USB_DEVICE_WACOM(0x318) },
5029 { USB_DEVICE_WACOM(0x319) },
5030 { USB_DEVICE_WACOM(0x323) },
5031 { USB_DEVICE_WACOM(0x325) },
5032 { USB_DEVICE_WACOM(0x326) },
5033 { USB_DEVICE_WACOM(0x32A) },
5034 { USB_DEVICE_WACOM(0x32B) },
5035 { USB_DEVICE_WACOM(0x32C) },
5036 { USB_DEVICE_WACOM(0x32F) },
5037 { USB_DEVICE_WACOM(0x331) },
5038 { USB_DEVICE_WACOM(0x333) },
5039 { USB_DEVICE_WACOM(0x335) },
5040 { USB_DEVICE_WACOM(0x336) },
5041 { USB_DEVICE_WACOM(0x33B) },
5042 { USB_DEVICE_WACOM(0x33C) },
5043 { USB_DEVICE_WACOM(0x33D) },
5044 { USB_DEVICE_WACOM(0x33E) },
5045 { USB_DEVICE_WACOM(0x343) },
5046 { BT_DEVICE_WACOM(0x360) },
5047 { BT_DEVICE_WACOM(0x361) },
5048 { BT_DEVICE_WACOM(0x377) },
5049 { BT_DEVICE_WACOM(0x379) },
5050 { USB_DEVICE_WACOM(0x37A) },
5051 { USB_DEVICE_WACOM(0x37B) },
5052 { BT_DEVICE_WACOM(0x393) },
5053 { BT_DEVICE_WACOM(0x3c6) },
5054 { BT_DEVICE_WACOM(0x3c8) },
5055 { BT_DEVICE_WACOM(0x3dd) },
5056 { USB_DEVICE_WACOM(0x4001) },
5057 { USB_DEVICE_WACOM(0x4004) },
5058 { USB_DEVICE_WACOM(0x5000) },
5059 { USB_DEVICE_WACOM(0x5002) },
5060 { USB_DEVICE_LENOVO(0x6004) },
5062 { USB_DEVICE_WACOM(HID_ANY_ID) },
5063 { I2C_DEVICE_WACOM(HID_ANY_ID) },
5064 { BT_DEVICE_WACOM(HID_ANY_ID) },
5067 MODULE_DEVICE_TABLE(hid, wacom_ids);