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 int sw_state = wacom_wac->hid_data.barrelswitch |
2525 (wacom_wac->hid_data.barrelswitch2 << 1);
2526 wacom_wac->hid_data.barrelswitch = sw_state == 1;
2527 wacom_wac->hid_data.barrelswitch2 = sw_state == 2;
2528 wacom_wac->hid_data.barrelswitch3 = sw_state == 3;
2530 input_report_key(input, BTN_STYLUS, wacom_wac->hid_data.barrelswitch);
2531 input_report_key(input, BTN_STYLUS2, wacom_wac->hid_data.barrelswitch2);
2532 input_report_key(input, BTN_STYLUS3, wacom_wac->hid_data.barrelswitch3);
2535 * Non-USI EMR tools should have their IDs mangled to
2536 * match the legacy behavior of wacom_intuos_general
2538 if (wacom_wac->serial[0] >> 52 == 1)
2539 id = wacom_intuos_id_mangle(id);
2542 * To ensure compatibility with xf86-input-wacom, we should
2543 * report the BTN_TOOL_* event prior to the ABS_MISC or
2544 * MSC_SERIAL events.
2546 input_report_key(input, BTN_TOUCH,
2547 wacom_wac->hid_data.tipswitch);
2548 input_report_key(input, wacom_wac->tool[0], sense);
2549 if (wacom_wac->serial[0]) {
2550 input_event(input, EV_MSC, MSC_SERIAL, wacom_wac->serial[0]);
2551 input_report_abs(input, ABS_MISC, sense ? id : 0);
2554 wacom_wac->hid_data.tipswitch = false;
2560 wacom_wac->tool[0] = 0;
2561 wacom_wac->id[0] = 0;
2562 wacom_wac->serial[0] = 0;
2566 static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
2567 struct hid_field *field, struct hid_usage *usage)
2569 struct wacom *wacom = hid_get_drvdata(hdev);
2570 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2571 struct input_dev *input = wacom_wac->touch_input;
2572 unsigned touch_max = wacom_wac->features.touch_max;
2573 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2575 switch (equivalent_usage) {
2578 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
2580 wacom_map_usage(input, usage, field, EV_ABS,
2581 ABS_MT_POSITION_X, 4);
2585 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
2587 wacom_map_usage(input, usage, field, EV_ABS,
2588 ABS_MT_POSITION_Y, 4);
2592 wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MAJOR, 0);
2593 wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MINOR, 0);
2594 input_set_abs_params(input, ABS_MT_ORIENTATION, 0, 1, 0, 0);
2596 case HID_DG_TIPSWITCH:
2597 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
2599 case HID_DG_CONTACTCOUNT:
2600 wacom_wac->hid_data.cc_report = field->report->id;
2601 wacom_wac->hid_data.cc_index = field->index;
2602 wacom_wac->hid_data.cc_value_index = usage->usage_index;
2604 case HID_DG_CONTACTID:
2605 if ((field->logical_maximum - field->logical_minimum) < touch_max) {
2607 * The HID descriptor for G11 sensors leaves logical
2608 * maximum set to '1' despite it being a multitouch
2609 * device. Override to a sensible number.
2611 field->logical_maximum = 255;
2614 case HID_DG_SCANTIME:
2615 wacom_map_usage(input, usage, field, EV_MSC, MSC_TIMESTAMP, 0);
2620 static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
2621 struct input_dev *input)
2623 struct hid_data *hid_data = &wacom_wac->hid_data;
2624 bool mt = wacom_wac->features.touch_max > 1;
2625 bool prox = hid_data->tipswitch &&
2626 report_touch_events(wacom_wac);
2628 if (touch_is_muted(wacom_wac)) {
2629 if (!wacom_wac->shared->touch_down)
2634 wacom_wac->hid_data.num_received++;
2635 if (wacom_wac->hid_data.num_received > wacom_wac->hid_data.num_expected)
2641 slot = input_mt_get_slot_by_key(input, hid_data->id);
2645 struct input_mt_slot *ps = &input->mt->slots[slot];
2646 int mt_id = input_mt_get_value(ps, ABS_MT_TRACKING_ID);
2648 if (!prox && mt_id < 0) {
2649 // No data to send for this slot; short-circuit
2654 input_mt_slot(input, slot);
2655 input_mt_report_slot_state(input, MT_TOOL_FINGER, prox);
2658 input_report_key(input, BTN_TOUCH, prox);
2662 input_report_abs(input, mt ? ABS_MT_POSITION_X : ABS_X,
2664 input_report_abs(input, mt ? ABS_MT_POSITION_Y : ABS_Y,
2667 if (test_bit(ABS_MT_TOUCH_MAJOR, input->absbit)) {
2668 input_report_abs(input, ABS_MT_TOUCH_MAJOR, max(hid_data->width, hid_data->height));
2669 input_report_abs(input, ABS_MT_TOUCH_MINOR, min(hid_data->width, hid_data->height));
2670 if (hid_data->width != hid_data->height)
2671 input_report_abs(input, ABS_MT_ORIENTATION, hid_data->width <= hid_data->height ? 0 : 1);
2676 static bool wacom_wac_slot_is_active(struct input_dev *dev, int key)
2678 struct input_mt *mt = dev->mt;
2679 struct input_mt_slot *s;
2684 for (s = mt->slots; s != mt->slots + mt->num_slots; s++) {
2685 if (s->key == key &&
2686 input_mt_get_value(s, ABS_MT_TRACKING_ID) >= 0) {
2694 static void wacom_wac_finger_event(struct hid_device *hdev,
2695 struct hid_field *field, struct hid_usage *usage, __s32 value)
2697 struct wacom *wacom = hid_get_drvdata(hdev);
2698 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2699 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2700 struct wacom_features *features = &wacom->wacom_wac.features;
2702 if (touch_is_muted(wacom_wac) && !wacom_wac->shared->touch_down)
2705 if (wacom_wac->is_invalid_bt_frame)
2708 switch (equivalent_usage) {
2709 case HID_DG_CONFIDENCE:
2710 wacom_wac->hid_data.confidence = value;
2713 wacom_wac->hid_data.x = value;
2716 wacom_wac->hid_data.y = value;
2719 wacom_wac->hid_data.width = value;
2722 wacom_wac->hid_data.height = value;
2724 case HID_DG_CONTACTID:
2725 wacom_wac->hid_data.id = value;
2727 case HID_DG_TIPSWITCH:
2728 wacom_wac->hid_data.tipswitch = value;
2730 case WACOM_HID_WT_REPORT_VALID:
2731 wacom_wac->is_invalid_bt_frame = !value;
2733 case HID_DG_CONTACTMAX:
2734 if (!features->touch_max) {
2735 features->touch_max = value;
2737 hid_warn(hdev, "%s: ignoring attempt to overwrite non-zero touch_max "
2738 "%d -> %d\n", __func__, features->touch_max, value);
2743 if (usage->usage_index + 1 == field->report_count) {
2744 if (equivalent_usage == wacom_wac->hid_data.last_slot_field) {
2745 bool touch_removed = wacom_wac_slot_is_active(wacom_wac->touch_input,
2746 wacom_wac->hid_data.id) && !wacom_wac->hid_data.tipswitch;
2748 if (wacom_wac->hid_data.confidence || touch_removed) {
2749 wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
2755 static void wacom_wac_finger_pre_report(struct hid_device *hdev,
2756 struct hid_report *report)
2758 struct wacom *wacom = hid_get_drvdata(hdev);
2759 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2760 struct hid_data* hid_data = &wacom_wac->hid_data;
2763 if (touch_is_muted(wacom_wac) && !wacom_wac->shared->touch_down)
2766 wacom_wac->is_invalid_bt_frame = false;
2768 hid_data->confidence = true;
2770 hid_data->cc_report = 0;
2771 hid_data->cc_index = -1;
2772 hid_data->cc_value_index = -1;
2774 for (i = 0; i < report->maxfield; i++) {
2775 struct hid_field *field = report->field[i];
2778 for (j = 0; j < field->maxusage; j++) {
2779 struct hid_usage *usage = &field->usage[j];
2780 unsigned int equivalent_usage =
2781 wacom_equivalent_usage(usage->hid);
2783 switch (equivalent_usage) {
2788 case HID_DG_CONTACTID:
2789 case HID_DG_INRANGE:
2791 case HID_DG_TIPSWITCH:
2792 hid_data->last_slot_field = equivalent_usage;
2794 case HID_DG_CONTACTCOUNT:
2795 hid_data->cc_report = report->id;
2796 hid_data->cc_index = i;
2797 hid_data->cc_value_index = j;
2803 if (hid_data->cc_report != 0 &&
2804 hid_data->cc_index >= 0) {
2805 struct hid_field *field = report->field[hid_data->cc_index];
2806 int value = field->value[hid_data->cc_value_index];
2808 hid_data->num_expected = value;
2809 hid_data->num_received = 0;
2813 hid_data->num_expected = wacom_wac->features.touch_max;
2814 hid_data->num_received = 0;
2818 static void wacom_wac_finger_report(struct hid_device *hdev,
2819 struct hid_report *report)
2821 struct wacom *wacom = hid_get_drvdata(hdev);
2822 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2823 struct input_dev *input = wacom_wac->touch_input;
2824 unsigned touch_max = wacom_wac->features.touch_max;
2826 /* if there was nothing to process, don't send an empty sync */
2827 if (wacom_wac->hid_data.num_expected == 0)
2830 /* If more packets of data are expected, give us a chance to
2831 * process them rather than immediately syncing a partial
2834 if (wacom_wac->hid_data.num_received < wacom_wac->hid_data.num_expected)
2838 input_mt_sync_frame(input);
2841 wacom_wac->hid_data.num_received = 0;
2842 wacom_wac->hid_data.num_expected = 0;
2844 /* keep touch state for pen event */
2845 wacom_wac->shared->touch_down = wacom_wac_finger_count_touches(wacom_wac);
2848 void wacom_wac_usage_mapping(struct hid_device *hdev,
2849 struct hid_field *field, struct hid_usage *usage)
2851 struct wacom *wacom = hid_get_drvdata(hdev);
2852 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2853 struct wacom_features *features = &wacom_wac->features;
2855 if (WACOM_DIRECT_DEVICE(field))
2856 features->device_type |= WACOM_DEVICETYPE_DIRECT;
2858 /* usage tests must precede field tests */
2859 if (WACOM_BATTERY_USAGE(usage))
2860 wacom_wac_battery_usage_mapping(hdev, field, usage);
2861 else if (WACOM_PAD_FIELD(field))
2862 wacom_wac_pad_usage_mapping(hdev, field, usage);
2863 else if (WACOM_PEN_FIELD(field))
2864 wacom_wac_pen_usage_mapping(hdev, field, usage);
2865 else if (WACOM_FINGER_FIELD(field))
2866 wacom_wac_finger_usage_mapping(hdev, field, usage);
2869 void wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
2870 struct hid_usage *usage, __s32 value)
2872 struct wacom *wacom = hid_get_drvdata(hdev);
2874 if (wacom->wacom_wac.features.type != HID_GENERIC)
2877 if (value > field->logical_maximum || value < field->logical_minimum)
2880 /* usage tests must precede field tests */
2881 if (WACOM_BATTERY_USAGE(usage))
2882 wacom_wac_battery_event(hdev, field, usage, value);
2883 else if (WACOM_PAD_FIELD(field))
2884 wacom_wac_pad_event(hdev, field, usage, value);
2885 else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
2886 wacom_wac_pen_event(hdev, field, usage, value);
2887 else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
2888 wacom_wac_finger_event(hdev, field, usage, value);
2891 static void wacom_report_events(struct hid_device *hdev,
2892 struct hid_report *report, int collection_index,
2897 for (r = field_index; r < report->maxfield; r++) {
2898 struct hid_field *field;
2901 field = report->field[r];
2902 count = field->report_count;
2904 if (!(HID_MAIN_ITEM_VARIABLE & field->flags))
2907 for (n = 0 ; n < count; n++) {
2908 if (field->usage[n].collection_index == collection_index)
2909 wacom_wac_event(hdev, field, &field->usage[n],
2917 static int wacom_wac_collection(struct hid_device *hdev, struct hid_report *report,
2918 int collection_index, struct hid_field *field,
2921 struct wacom *wacom = hid_get_drvdata(hdev);
2923 wacom_report_events(hdev, report, collection_index, field_index);
2926 * Non-input reports may be sent prior to the device being
2927 * completely initialized. Since only their events need
2928 * to be processed, exit after 'wacom_report_events' has
2929 * been called to prevent potential crashes in the report-
2930 * processing functions.
2932 if (report->type != HID_INPUT_REPORT)
2935 if (WACOM_PAD_FIELD(field))
2937 else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
2938 wacom_wac_pen_report(hdev, report);
2939 else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
2940 wacom_wac_finger_report(hdev, report);
2945 void wacom_wac_report(struct hid_device *hdev, struct hid_report *report)
2947 struct wacom *wacom = hid_get_drvdata(hdev);
2948 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2949 struct hid_field *field;
2950 bool pad_in_hid_field = false, pen_in_hid_field = false,
2951 finger_in_hid_field = false, true_pad = false;
2953 int prev_collection = -1;
2955 if (wacom_wac->features.type != HID_GENERIC)
2958 for (r = 0; r < report->maxfield; r++) {
2959 field = report->field[r];
2961 if (WACOM_PAD_FIELD(field))
2962 pad_in_hid_field = true;
2963 if (WACOM_PEN_FIELD(field))
2964 pen_in_hid_field = true;
2965 if (WACOM_FINGER_FIELD(field))
2966 finger_in_hid_field = true;
2967 if (wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY)
2971 wacom_wac_battery_pre_report(hdev, report);
2973 if (pad_in_hid_field && wacom->wacom_wac.pad_input)
2974 wacom_wac_pad_pre_report(hdev, report);
2975 if (pen_in_hid_field && wacom->wacom_wac.pen_input)
2976 wacom_wac_pen_pre_report(hdev, report);
2977 if (finger_in_hid_field && wacom->wacom_wac.touch_input)
2978 wacom_wac_finger_pre_report(hdev, report);
2980 for (r = 0; r < report->maxfield; r++) {
2981 field = report->field[r];
2983 if (field->usage[0].collection_index != prev_collection) {
2984 if (wacom_wac_collection(hdev, report,
2985 field->usage[0].collection_index, field, r) < 0)
2987 prev_collection = field->usage[0].collection_index;
2991 wacom_wac_battery_report(hdev, report);
2993 if (true_pad && wacom->wacom_wac.pad_input)
2994 wacom_wac_pad_report(hdev, report, field);
2997 static int wacom_bpt_touch(struct wacom_wac *wacom)
2999 struct wacom_features *features = &wacom->features;
3000 struct input_dev *input = wacom->touch_input;
3001 struct input_dev *pad_input = wacom->pad_input;
3002 unsigned char *data = wacom->data;
3005 if (data[0] != 0x02)
3008 for (i = 0; i < 2; i++) {
3009 int offset = (data[1] & 0x80) ? (8 * i) : (9 * i);
3010 bool touch = report_touch_events(wacom)
3011 && (data[offset + 3] & 0x80);
3013 input_mt_slot(input, i);
3014 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
3016 int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff;
3017 int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff;
3018 if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) {
3022 input_report_abs(input, ABS_MT_POSITION_X, x);
3023 input_report_abs(input, ABS_MT_POSITION_Y, y);
3027 input_mt_sync_frame(input);
3029 input_report_key(pad_input, BTN_LEFT, (data[1] & 0x08) != 0);
3030 input_report_key(pad_input, BTN_FORWARD, (data[1] & 0x04) != 0);
3031 input_report_key(pad_input, BTN_BACK, (data[1] & 0x02) != 0);
3032 input_report_key(pad_input, BTN_RIGHT, (data[1] & 0x01) != 0);
3033 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
3038 static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
3040 struct wacom_features *features = &wacom->features;
3041 struct input_dev *input = wacom->touch_input;
3042 bool touch = data[1] & 0x80;
3043 int slot = input_mt_get_slot_by_key(input, data[0]);
3048 touch = touch && report_touch_events(wacom);
3050 input_mt_slot(input, slot);
3051 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
3054 int x = (data[2] << 4) | (data[4] >> 4);
3055 int y = (data[3] << 4) | (data[4] & 0x0f);
3058 if (features->type >= INTUOSPS && features->type <= INTUOSHT2) {
3059 width = data[5] * 100;
3060 height = data[6] * 100;
3063 * "a" is a scaled-down area which we assume is
3064 * roughly circular and which can be described as:
3068 int x_res = input_abs_get_res(input, ABS_MT_POSITION_X);
3069 int y_res = input_abs_get_res(input, ABS_MT_POSITION_Y);
3070 width = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE);
3071 height = width * y_res / x_res;
3074 input_report_abs(input, ABS_MT_POSITION_X, x);
3075 input_report_abs(input, ABS_MT_POSITION_Y, y);
3076 input_report_abs(input, ABS_MT_TOUCH_MAJOR, width);
3077 input_report_abs(input, ABS_MT_TOUCH_MINOR, height);
3081 static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
3083 struct input_dev *input = wacom->pad_input;
3084 struct wacom_features *features = &wacom->features;
3086 if (features->type == INTUOSHT || features->type == INTUOSHT2) {
3087 input_report_key(input, BTN_LEFT, (data[1] & 0x02) != 0);
3088 input_report_key(input, BTN_BACK, (data[1] & 0x08) != 0);
3090 input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
3091 input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
3093 input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
3094 input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
3097 static int wacom_bpt3_touch(struct wacom_wac *wacom)
3099 unsigned char *data = wacom->data;
3100 int count = data[1] & 0x07;
3101 int touch_changed = 0, i;
3103 if (data[0] != 0x02)
3106 /* data has up to 7 fixed sized 8-byte messages starting at data[2] */
3107 for (i = 0; i < count; i++) {
3108 int offset = (8 * i) + 2;
3109 int msg_id = data[offset];
3111 if (msg_id >= 2 && msg_id <= 17) {
3112 wacom_bpt3_touch_msg(wacom, data + offset);
3114 } else if (msg_id == 128)
3115 wacom_bpt3_button_msg(wacom, data + offset);
3119 /* only update touch if we actually have a touchpad and touch data changed */
3120 if (wacom->touch_input && touch_changed) {
3121 input_mt_sync_frame(wacom->touch_input);
3122 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
3128 static int wacom_bpt_pen(struct wacom_wac *wacom)
3130 struct wacom_features *features = &wacom->features;
3131 struct input_dev *input = wacom->pen_input;
3132 unsigned char *data = wacom->data;
3133 int x = 0, y = 0, p = 0, d = 0;
3134 bool pen = false, btn1 = false, btn2 = false;
3135 bool range, prox, rdy;
3137 if (data[0] != WACOM_REPORT_PENABLED)
3140 range = (data[1] & 0x80) == 0x80;
3141 prox = (data[1] & 0x40) == 0x40;
3142 rdy = (data[1] & 0x20) == 0x20;
3144 wacom->shared->stylus_in_proximity = range;
3145 if (delay_pen_events(wacom))
3149 p = le16_to_cpup((__le16 *)&data[6]);
3150 pen = data[1] & 0x01;
3151 btn1 = data[1] & 0x02;
3152 btn2 = data[1] & 0x04;
3155 x = le16_to_cpup((__le16 *)&data[2]);
3156 y = le16_to_cpup((__le16 *)&data[4]);
3158 if (data[1] & 0x08) {
3159 wacom->tool[0] = BTN_TOOL_RUBBER;
3160 wacom->id[0] = ERASER_DEVICE_ID;
3162 wacom->tool[0] = BTN_TOOL_PEN;
3163 wacom->id[0] = STYLUS_DEVICE_ID;
3165 wacom->reporting_data = true;
3169 * Convert distance from out prox to distance from tablet.
3170 * distance will be greater than distance_max once
3171 * touching and applying pressure; do not report negative
3174 if (data[8] <= features->distance_max)
3175 d = features->distance_max - data[8];
3180 if (wacom->reporting_data) {
3181 input_report_key(input, BTN_TOUCH, pen);
3182 input_report_key(input, BTN_STYLUS, btn1);
3183 input_report_key(input, BTN_STYLUS2, btn2);
3185 if (prox || !range) {
3186 input_report_abs(input, ABS_X, x);
3187 input_report_abs(input, ABS_Y, y);
3189 input_report_abs(input, ABS_PRESSURE, p);
3190 input_report_abs(input, ABS_DISTANCE, d);
3192 input_report_key(input, wacom->tool[0], range); /* PEN or RUBBER */
3193 input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
3197 wacom->reporting_data = false;
3203 static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
3205 struct wacom_features *features = &wacom->features;
3207 if ((features->type == INTUOSHT2) &&
3208 (features->device_type & WACOM_DEVICETYPE_PEN))
3209 return wacom_intuos_irq(wacom);
3210 else if (len == WACOM_PKGLEN_BBTOUCH)
3211 return wacom_bpt_touch(wacom);
3212 else if (len == WACOM_PKGLEN_BBTOUCH3)
3213 return wacom_bpt3_touch(wacom);
3214 else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
3215 return wacom_bpt_pen(wacom);
3220 static void wacom_bamboo_pad_pen_event(struct wacom_wac *wacom,
3221 unsigned char *data)
3223 unsigned char prefix;
3226 * We need to reroute the event from the debug interface to the
3228 * We need to add the report ID to the actual pen report, so we
3229 * temporary overwrite the first byte to prevent having to kzalloc/kfree
3230 * and memcpy the report.
3233 data[0] = WACOM_REPORT_BPAD_PEN;
3236 * actually reroute the event.
3237 * No need to check if wacom->shared->pen is valid, hid_input_report()
3238 * will check for us.
3240 hid_input_report(wacom->shared->pen, HID_INPUT_REPORT, data,
3241 WACOM_PKGLEN_PENABLED, 1);
3246 static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom,
3247 unsigned char *data)
3249 struct input_dev *input = wacom->touch_input;
3250 unsigned char *finger_data, prefix;
3257 for (id = 0; id < wacom->features.touch_max; id++) {
3258 valid = !!(prefix & BIT(id)) &&
3259 report_touch_events(wacom);
3261 input_mt_slot(input, id);
3262 input_mt_report_slot_state(input, MT_TOOL_FINGER, valid);
3267 finger_data = data + 1 + id * 3;
3268 x = finger_data[0] | ((finger_data[1] & 0x0f) << 8);
3269 y = (finger_data[2] << 4) | (finger_data[1] >> 4);
3271 input_report_abs(input, ABS_MT_POSITION_X, x);
3272 input_report_abs(input, ABS_MT_POSITION_Y, y);
3275 input_mt_sync_frame(input);
3277 input_report_key(input, BTN_LEFT, prefix & 0x40);
3278 input_report_key(input, BTN_RIGHT, prefix & 0x80);
3280 /* keep touch state for pen event */
3281 wacom->shared->touch_down = !!prefix && report_touch_events(wacom);
3286 static int wacom_bamboo_pad_irq(struct wacom_wac *wacom, size_t len)
3288 unsigned char *data = wacom->data;
3290 if (!((len == WACOM_PKGLEN_BPAD_TOUCH) ||
3291 (len == WACOM_PKGLEN_BPAD_TOUCH_USB)) ||
3292 (data[0] != WACOM_REPORT_BPAD_TOUCH))
3296 wacom_bamboo_pad_pen_event(wacom, &data[1]);
3299 return wacom_bamboo_pad_touch_event(wacom, &data[9]);
3304 static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
3306 unsigned char *data = wacom->data;
3309 if (len != WACOM_PKGLEN_WIRELESS || data[0] != WACOM_REPORT_WL)
3312 connected = data[1] & 0x01;
3314 int pid, battery, charging;
3316 if ((wacom->shared->type == INTUOSHT ||
3317 wacom->shared->type == INTUOSHT2) &&
3318 wacom->shared->touch_input &&
3319 wacom->shared->touch_max) {
3320 input_report_switch(wacom->shared->touch_input,
3321 SW_MUTE_DEVICE, data[5] & 0x40);
3322 input_sync(wacom->shared->touch_input);
3325 pid = get_unaligned_be16(&data[6]);
3326 battery = (data[5] & 0x3f) * 100 / 31;
3327 charging = !!(data[5] & 0x80);
3328 if (wacom->pid != pid) {
3330 wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
3333 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
3334 battery, charging, 1, 0);
3336 } else if (wacom->pid != 0) {
3337 /* disconnected while previously connected */
3339 wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
3340 wacom_notify_battery(wacom, POWER_SUPPLY_STATUS_UNKNOWN, 0, 0, 0, 0);
3346 static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
3348 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
3349 struct wacom_features *features = &wacom_wac->features;
3350 unsigned char *data = wacom_wac->data;
3352 if (data[0] != WACOM_REPORT_USB)
3355 if ((features->type == INTUOSHT ||
3356 features->type == INTUOSHT2) &&
3357 wacom_wac->shared->touch_input &&
3358 features->touch_max) {
3359 input_report_switch(wacom_wac->shared->touch_input,
3360 SW_MUTE_DEVICE, data[8] & 0x40);
3361 input_sync(wacom_wac->shared->touch_input);
3364 if (data[9] & 0x02) { /* wireless module is attached */
3365 int battery = (data[8] & 0x3f) * 100 / 31;
3366 bool charging = !!(data[8] & 0x80);
3368 wacom_notify_battery(wacom_wac, WACOM_POWER_SUPPLY_STATUS_AUTO,
3369 battery, charging, battery || charging, 1);
3371 if (!wacom->battery.battery &&
3372 !(features->quirks & WACOM_QUIRK_BATTERY)) {
3373 features->quirks |= WACOM_QUIRK_BATTERY;
3374 wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
3377 else if ((features->quirks & WACOM_QUIRK_BATTERY) &&
3378 wacom->battery.battery) {
3379 features->quirks &= ~WACOM_QUIRK_BATTERY;
3380 wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
3381 wacom_notify_battery(wacom_wac, POWER_SUPPLY_STATUS_UNKNOWN, 0, 0, 0, 0);
3386 void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
3390 switch (wacom_wac->features.type) {
3392 sync = wacom_penpartner_irq(wacom_wac);
3396 sync = wacom_pl_irq(wacom_wac);
3403 sync = wacom_graphire_irq(wacom_wac);
3407 sync = wacom_ptu_irq(wacom_wac);
3411 sync = wacom_dtu_irq(wacom_wac);
3416 sync = wacom_dtus_irq(wacom_wac);
3435 case CINTIQ_COMPANION_2:
3436 sync = wacom_intuos_irq(wacom_wac);
3440 sync = wacom_intuos_bt_irq(wacom_wac, len);
3445 sync = wacom_24hdt_irq(wacom_wac);
3454 if (len == WACOM_PKGLEN_BBTOUCH3)
3455 sync = wacom_bpt3_touch(wacom_wac);
3456 else if (wacom_wac->data[0] == WACOM_REPORT_USB)
3457 sync = wacom_status_irq(wacom_wac, len);
3459 sync = wacom_intuos_irq(wacom_wac);
3465 sync = wacom_intuos_pro2_bt_irq(wacom_wac, len);
3474 sync = wacom_tpc_irq(wacom_wac, len);
3482 if (wacom_wac->data[0] == WACOM_REPORT_USB)
3483 sync = wacom_status_irq(wacom_wac, len);
3485 sync = wacom_bpt_irq(wacom_wac, len);
3489 sync = wacom_bamboo_pad_irq(wacom_wac, len);
3493 sync = wacom_wireless_irq(wacom_wac, len);
3498 if (wacom_wac->data[0] == WACOM_REPORT_DEVICE_LIST)
3499 wacom_remote_status_irq(wacom_wac, len);
3501 sync = wacom_remote_irq(wacom_wac, len);
3510 if (wacom_wac->pen_input)
3511 input_sync(wacom_wac->pen_input);
3512 if (wacom_wac->touch_input)
3513 input_sync(wacom_wac->touch_input);
3514 if (wacom_wac->pad_input)
3515 input_sync(wacom_wac->pad_input);
3519 static void wacom_setup_basic_pro_pen(struct wacom_wac *wacom_wac)
3521 struct input_dev *input_dev = wacom_wac->pen_input;
3523 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
3525 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3526 __set_bit(BTN_STYLUS, input_dev->keybit);
3527 __set_bit(BTN_STYLUS2, input_dev->keybit);
3529 input_set_abs_params(input_dev, ABS_DISTANCE,
3530 0, wacom_wac->features.distance_max, wacom_wac->features.distance_fuzz, 0);
3533 static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
3535 struct input_dev *input_dev = wacom_wac->pen_input;
3536 struct wacom_features *features = &wacom_wac->features;
3538 wacom_setup_basic_pro_pen(wacom_wac);
3540 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3541 __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
3542 __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
3543 __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
3545 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
3546 input_set_abs_params(input_dev, ABS_TILT_X, -64, 63, features->tilt_fuzz, 0);
3547 input_abs_set_res(input_dev, ABS_TILT_X, 57);
3548 input_set_abs_params(input_dev, ABS_TILT_Y, -64, 63, features->tilt_fuzz, 0);
3549 input_abs_set_res(input_dev, ABS_TILT_Y, 57);
3552 static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
3554 struct input_dev *input_dev = wacom_wac->pen_input;
3556 input_set_capability(input_dev, EV_REL, REL_WHEEL);
3558 wacom_setup_cintiq(wacom_wac);
3560 __set_bit(BTN_LEFT, input_dev->keybit);
3561 __set_bit(BTN_RIGHT, input_dev->keybit);
3562 __set_bit(BTN_MIDDLE, input_dev->keybit);
3563 __set_bit(BTN_SIDE, input_dev->keybit);
3564 __set_bit(BTN_EXTRA, input_dev->keybit);
3565 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
3566 __set_bit(BTN_TOOL_LENS, input_dev->keybit);
3568 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
3569 input_abs_set_res(input_dev, ABS_RZ, 287);
3570 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
3573 void wacom_setup_device_quirks(struct wacom *wacom)
3575 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
3576 struct wacom_features *features = &wacom->wacom_wac.features;
3578 /* The pen and pad share the same interface on most devices */
3579 if (features->type == GRAPHIRE_BT || features->type == WACOM_G4 ||
3580 features->type == DTUS ||
3581 (features->type >= INTUOS3S && features->type <= WACOM_MO)) {
3582 if (features->device_type & WACOM_DEVICETYPE_PEN)
3583 features->device_type |= WACOM_DEVICETYPE_PAD;
3586 /* touch device found but size is not defined. use default */
3587 if (features->device_type & WACOM_DEVICETYPE_TOUCH && !features->x_max) {
3588 features->x_max = 1023;
3589 features->y_max = 1023;
3593 * Intuos5/Pro and Bamboo 3rd gen have no useful data about its
3594 * touch interface in its HID descriptor. If this is the touch
3595 * interface (PacketSize of WACOM_PKGLEN_BBTOUCH3), override the
3598 if ((features->type >= INTUOS5S && features->type <= INTUOSPL) ||
3599 (features->type >= INTUOSHT && features->type <= BAMBOO_PT)) {
3600 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
3601 if (features->touch_max)
3602 features->device_type |= WACOM_DEVICETYPE_TOUCH;
3603 if (features->type >= INTUOSHT && features->type <= BAMBOO_PT)
3604 features->device_type |= WACOM_DEVICETYPE_PAD;
3606 if (features->type == INTUOSHT2) {
3607 features->x_max = features->x_max / 10;
3608 features->y_max = features->y_max / 10;
3611 features->x_max = 4096;
3612 features->y_max = 4096;
3615 else if (features->pktlen == WACOM_PKGLEN_BBTOUCH) {
3616 features->device_type |= WACOM_DEVICETYPE_PAD;
3621 * Hack for the Bamboo One:
3622 * the device presents a PAD/Touch interface as most Bamboos and even
3623 * sends ghosts PAD data on it. However, later, we must disable this
3624 * ghost interface, and we can not detect it unless we set it here
3625 * to WACOM_DEVICETYPE_PAD or WACOM_DEVICETYPE_TOUCH.
3627 if (features->type == BAMBOO_PEN &&
3628 features->pktlen == WACOM_PKGLEN_BBTOUCH3)
3629 features->device_type |= WACOM_DEVICETYPE_PAD;
3632 * Raw Wacom-mode pen and touch events both come from interface
3633 * 0, whose HID descriptor has an application usage of 0xFF0D
3634 * (i.e., WACOM_HID_WD_DIGITIZER). We route pen packets back
3635 * out through the HID_GENERIC device created for interface 1,
3636 * so rewrite this one to be of type WACOM_DEVICETYPE_TOUCH.
3638 if (features->type == BAMBOO_PAD)
3639 features->device_type = WACOM_DEVICETYPE_TOUCH;
3641 if (features->type == REMOTE)
3642 features->device_type = WACOM_DEVICETYPE_PAD;
3644 if (features->type == INTUOSP2_BT ||
3645 features->type == INTUOSP2S_BT) {
3646 features->device_type |= WACOM_DEVICETYPE_PEN |
3647 WACOM_DEVICETYPE_PAD |
3648 WACOM_DEVICETYPE_TOUCH;
3649 features->quirks |= WACOM_QUIRK_BATTERY;
3652 if (features->type == INTUOSHT3_BT) {
3653 features->device_type |= WACOM_DEVICETYPE_PEN |
3654 WACOM_DEVICETYPE_PAD;
3655 features->quirks |= WACOM_QUIRK_BATTERY;
3658 switch (features->type) {
3669 case CINTIQ_COMPANION_2:
3681 features->device_type |= WACOM_DEVICETYPE_DIRECT;
3685 if (wacom->hdev->bus == BUS_BLUETOOTH)
3686 features->quirks |= WACOM_QUIRK_BATTERY;
3688 /* quirk for bamboo touch with 2 low res touches */
3689 if ((features->type == BAMBOO_PT || features->type == BAMBOO_TOUCH) &&
3690 features->pktlen == WACOM_PKGLEN_BBTOUCH) {
3691 features->x_max <<= 5;
3692 features->y_max <<= 5;
3693 features->x_fuzz <<= 5;
3694 features->y_fuzz <<= 5;
3695 features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;
3698 if (features->type == WIRELESS) {
3699 if (features->device_type == WACOM_DEVICETYPE_WL_MONITOR) {
3700 features->quirks |= WACOM_QUIRK_BATTERY;
3704 if (features->type == REMOTE)
3705 features->device_type |= WACOM_DEVICETYPE_WL_MONITOR;
3707 /* HID descriptor for DTK-2451 / DTH-2452 claims to report lots
3708 * of things it shouldn't. Lets fix up the damage...
3710 if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
3711 features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3712 __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3713 __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3714 __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3715 __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3716 __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3717 __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3718 __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3719 __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3720 __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3721 __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3722 __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3726 int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
3727 struct wacom_wac *wacom_wac)
3729 struct wacom_features *features = &wacom_wac->features;
3731 if (!(features->device_type & WACOM_DEVICETYPE_PEN))
3734 if (features->device_type & WACOM_DEVICETYPE_DIRECT)
3735 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
3737 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
3739 if (features->type == HID_GENERIC)
3740 /* setup has already been done */
3743 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3744 __set_bit(BTN_TOUCH, input_dev->keybit);
3745 __set_bit(ABS_MISC, input_dev->absbit);
3747 input_set_abs_params(input_dev, ABS_X, 0 + features->offset_left,
3748 features->x_max - features->offset_right,
3749 features->x_fuzz, 0);
3750 input_set_abs_params(input_dev, ABS_Y, 0 + features->offset_top,
3751 features->y_max - features->offset_bottom,
3752 features->y_fuzz, 0);
3753 input_set_abs_params(input_dev, ABS_PRESSURE, 0,
3754 features->pressure_max, features->pressure_fuzz, 0);
3756 /* penabled devices have fixed resolution for each model */
3757 input_abs_set_res(input_dev, ABS_X, features->x_resolution);
3758 input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
3760 switch (features->type) {
3762 __clear_bit(ABS_MISC, input_dev->absbit);
3767 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3768 features->distance_max,
3769 features->distance_fuzz, 0);
3773 input_set_capability(input_dev, EV_REL, REL_WHEEL);
3775 __set_bit(BTN_LEFT, input_dev->keybit);
3776 __set_bit(BTN_RIGHT, input_dev->keybit);
3777 __set_bit(BTN_MIDDLE, input_dev->keybit);
3779 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3780 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3781 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
3782 __set_bit(BTN_STYLUS, input_dev->keybit);
3783 __set_bit(BTN_STYLUS2, input_dev->keybit);
3795 case CINTIQ_COMPANION_2:
3796 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3797 input_abs_set_res(input_dev, ABS_Z, 287);
3798 wacom_setup_cintiq(wacom_wac);
3808 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3809 input_abs_set_res(input_dev, ABS_Z, 287);
3813 wacom_setup_intuos(wacom_wac);
3824 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3825 features->distance_max,
3826 features->distance_fuzz, 0);
3828 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3829 input_abs_set_res(input_dev, ABS_Z, 287);
3831 wacom_setup_intuos(wacom_wac);
3842 __clear_bit(ABS_MISC, input_dev->absbit);
3849 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3850 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3851 __set_bit(BTN_STYLUS, input_dev->keybit);
3852 __set_bit(BTN_STYLUS2, input_dev->keybit);
3856 __set_bit(BTN_STYLUS2, input_dev->keybit);
3860 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3861 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3862 __set_bit(BTN_STYLUS, input_dev->keybit);
3870 if (features->type == INTUOSHT2 ||
3871 features->type == INTUOSHT3_BT) {
3872 wacom_setup_basic_pro_pen(wacom_wac);
3874 __clear_bit(ABS_MISC, input_dev->absbit);
3875 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3876 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3877 __set_bit(BTN_STYLUS, input_dev->keybit);
3878 __set_bit(BTN_STYLUS2, input_dev->keybit);
3879 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3880 features->distance_max,
3881 features->distance_fuzz, 0);
3885 __clear_bit(ABS_MISC, input_dev->absbit);
3891 int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
3892 struct wacom_wac *wacom_wac)
3894 struct wacom_features *features = &wacom_wac->features;
3896 if (!(features->device_type & WACOM_DEVICETYPE_TOUCH))
3899 if (features->device_type & WACOM_DEVICETYPE_DIRECT)
3900 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
3902 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
3904 if (features->type == HID_GENERIC)
3905 /* setup has already been done */
3908 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3909 __set_bit(BTN_TOUCH, input_dev->keybit);
3911 if (features->touch_max == 1) {
3912 input_set_abs_params(input_dev, ABS_X, 0,
3913 features->x_max, features->x_fuzz, 0);
3914 input_set_abs_params(input_dev, ABS_Y, 0,
3915 features->y_max, features->y_fuzz, 0);
3916 input_abs_set_res(input_dev, ABS_X,
3917 features->x_resolution);
3918 input_abs_set_res(input_dev, ABS_Y,
3919 features->y_resolution);
3921 else if (features->touch_max > 1) {
3922 input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
3923 features->x_max, features->x_fuzz, 0);
3924 input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
3925 features->y_max, features->y_fuzz, 0);
3926 input_abs_set_res(input_dev, ABS_MT_POSITION_X,
3927 features->x_resolution);
3928 input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
3929 features->y_resolution);
3932 switch (features->type) {
3935 input_dev->evbit[0] |= BIT_MASK(EV_SW);
3936 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
3938 if (wacom_wac->shared->touch->product == 0x361) {
3939 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
3941 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
3944 else if (wacom_wac->shared->touch->product == 0x360) {
3945 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
3947 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
3950 else if (wacom_wac->shared->touch->product == 0x393) {
3951 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
3953 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
3956 input_abs_set_res(input_dev, ABS_MT_POSITION_X, 40);
3957 input_abs_set_res(input_dev, ABS_MT_POSITION_Y, 40);
3967 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
3968 input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, features->y_max, 0, 0);
3969 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
3973 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
3974 input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
3975 input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
3976 input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
3980 if (wacom_wac->shared->touch->product == 0x32C ||
3981 wacom_wac->shared->touch->product == 0xF6) {
3982 input_dev->evbit[0] |= BIT_MASK(EV_SW);
3983 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
3984 wacom_wac->has_mute_touch_switch = true;
3985 wacom_wac->is_soft_touch_switch = true;
3993 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT);
4002 input_dev->evbit[0] |= BIT_MASK(EV_SW);
4003 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
4008 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
4009 input_set_abs_params(input_dev,
4011 0, features->x_max, 0, 0);
4012 input_set_abs_params(input_dev,
4014 0, features->y_max, 0, 0);
4016 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
4020 input_mt_init_slots(input_dev, features->touch_max,
4022 __set_bit(BTN_LEFT, input_dev->keybit);
4023 __set_bit(BTN_RIGHT, input_dev->keybit);
4029 static int wacom_numbered_button_to_key(int n)
4034 return BTN_A + (n-10);
4036 return BTN_BASE + (n-16);
4041 static void wacom_setup_numbered_buttons(struct input_dev *input_dev,
4046 for (i = 0; i < button_count; i++) {
4047 int key = wacom_numbered_button_to_key(i);
4050 __set_bit(key, input_dev->keybit);
4054 static void wacom_24hd_update_leds(struct wacom *wacom, int mask, int group)
4056 struct wacom_led *led;
4058 bool updated = false;
4061 * 24HD has LED group 1 to the left and LED group 0 to the right.
4062 * So group 0 matches the second half of the buttons and thus the mask
4063 * needs to be shifted.
4068 for (i = 0; i < 3; i++) {
4069 led = wacom_led_find(wacom, group, i);
4071 hid_err(wacom->hdev, "can't find LED %d in group %d\n",
4075 if (!updated && mask & BIT(i)) {
4077 led_trigger_event(&led->trigger, LED_FULL);
4084 static bool wacom_is_led_toggled(struct wacom *wacom, int button_count,
4085 int mask, int group)
4090 * 21UX2 has LED group 1 to the left and LED group 0
4091 * to the right. We need to reverse the group to match this
4092 * historical behavior.
4094 if (wacom->wacom_wac.features.type == WACOM_21UX2)
4097 group_button = group * (button_count/wacom->led.count);
4099 if (wacom->wacom_wac.features.type == INTUOSP2_BT)
4102 return mask & (1 << group_button);
4105 static void wacom_update_led(struct wacom *wacom, int button_count, int mask,
4108 struct wacom_led *led, *next_led;
4112 if (wacom->wacom_wac.features.type == WACOM_24HD)
4113 return wacom_24hd_update_leds(wacom, mask, group);
4115 pressed = wacom_is_led_toggled(wacom, button_count, mask, group);
4116 cur = wacom->led.groups[group].select;
4118 led = wacom_led_find(wacom, group, cur);
4120 hid_err(wacom->hdev, "can't find current LED %d in group %d\n",
4130 if (led->held && pressed)
4133 next_led = wacom_led_next(wacom, led);
4135 hid_err(wacom->hdev, "can't find next LED in group %d\n",
4139 if (next_led == led)
4142 next_led->held = true;
4143 led_trigger_event(&next_led->trigger,
4144 wacom_leds_brightness_get(next_led));
4147 static void wacom_report_numbered_buttons(struct input_dev *input_dev,
4148 int button_count, int mask)
4150 struct wacom *wacom = input_get_drvdata(input_dev);
4153 for (i = 0; i < wacom->led.count; i++)
4154 wacom_update_led(wacom, button_count, mask, i);
4156 for (i = 0; i < button_count; i++) {
4157 int key = wacom_numbered_button_to_key(i);
4160 input_report_key(input_dev, key, mask & (1 << i));
4164 int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
4165 struct wacom_wac *wacom_wac)
4167 struct wacom_features *features = &wacom_wac->features;
4169 if ((features->type == HID_GENERIC) && features->numbered_buttons > 0)
4170 features->device_type |= WACOM_DEVICETYPE_PAD;
4172 if (!(features->device_type & WACOM_DEVICETYPE_PAD))
4175 if (features->type == REMOTE && input_dev == wacom_wac->pad_input)
4178 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
4180 /* kept for making legacy xf86-input-wacom working with the wheels */
4181 __set_bit(ABS_MISC, input_dev->absbit);
4183 /* kept for making legacy xf86-input-wacom accepting the pad */
4184 if (!(input_dev->absinfo && (input_dev->absinfo[ABS_X].minimum ||
4185 input_dev->absinfo[ABS_X].maximum)))
4186 input_set_abs_params(input_dev, ABS_X, 0, 1, 0, 0);
4187 if (!(input_dev->absinfo && (input_dev->absinfo[ABS_Y].minimum ||
4188 input_dev->absinfo[ABS_Y].maximum)))
4189 input_set_abs_params(input_dev, ABS_Y, 0, 1, 0, 0);
4191 /* kept for making udev and libwacom accepting the pad */
4192 __set_bit(BTN_STYLUS, input_dev->keybit);
4194 wacom_setup_numbered_buttons(input_dev, features->numbered_buttons);
4196 switch (features->type) {
4199 case CINTIQ_COMPANION_2:
4206 __set_bit(BTN_BACK, input_dev->keybit);
4207 __set_bit(BTN_LEFT, input_dev->keybit);
4208 __set_bit(BTN_FORWARD, input_dev->keybit);
4209 __set_bit(BTN_RIGHT, input_dev->keybit);
4210 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4214 __set_bit(BTN_BACK, input_dev->keybit);
4215 __set_bit(BTN_FORWARD, input_dev->keybit);
4216 input_set_capability(input_dev, EV_REL, REL_WHEEL);
4220 __set_bit(KEY_PROG1, input_dev->keybit);
4221 __set_bit(KEY_PROG2, input_dev->keybit);
4222 __set_bit(KEY_PROG3, input_dev->keybit);
4224 __set_bit(KEY_ONSCREEN_KEYBOARD, input_dev->keybit);
4225 __set_bit(KEY_INFO, input_dev->keybit);
4227 if (!features->oPid)
4228 __set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
4230 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4231 input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
4235 __set_bit(KEY_PROG1, input_dev->keybit);
4236 __set_bit(KEY_PROG2, input_dev->keybit);
4237 __set_bit(KEY_PROG3, input_dev->keybit);
4239 __set_bit(KEY_ONSCREEN_KEYBOARD, input_dev->keybit);
4240 __set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
4242 if (!features->oPid)
4243 __set_bit(KEY_CONTROLPANEL, input_dev->keybit);
4244 input_set_abs_params(input_dev, ABS_X, -2048, 2048, 0, 0);
4245 input_abs_set_res(input_dev, ABS_X, 1024); /* points/g */
4246 input_set_abs_params(input_dev, ABS_Y, -2048, 2048, 0, 0);
4247 input_abs_set_res(input_dev, ABS_Y, 1024);
4248 input_set_abs_params(input_dev, ABS_Z, -2048, 2048, 0, 0);
4249 input_abs_set_res(input_dev, ABS_Z, 1024);
4250 __set_bit(INPUT_PROP_ACCELEROMETER, input_dev->propbit);
4254 __set_bit(KEY_PROG1, input_dev->keybit);
4255 __set_bit(KEY_PROG2, input_dev->keybit);
4256 __set_bit(KEY_PROG3, input_dev->keybit);
4258 __set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
4259 __set_bit(KEY_INFO, input_dev->keybit);
4265 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
4266 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
4270 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4275 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
4279 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
4290 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4295 * For Bluetooth devices, the udev rule does not work correctly
4296 * for pads unless we add a stylus capability, which forces
4297 * ID_INPUT_TABLET to be set.
4299 __set_bit(BTN_STYLUS, input_dev->keybit);
4305 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4312 __clear_bit(ABS_MISC, input_dev->absbit);
4314 __set_bit(BTN_LEFT, input_dev->keybit);
4315 __set_bit(BTN_FORWARD, input_dev->keybit);
4316 __set_bit(BTN_BACK, input_dev->keybit);
4317 __set_bit(BTN_RIGHT, input_dev->keybit);
4322 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
4323 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4331 /* no pad supported */
4337 static const struct wacom_features wacom_features_0x00 =
4338 { "Wacom Penpartner", 5040, 3780, 255, 0,
4339 PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
4340 static const struct wacom_features wacom_features_0x10 =
4341 { "Wacom Graphire", 10206, 7422, 511, 63,
4342 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4343 static const struct wacom_features wacom_features_0x81 =
4344 { "Wacom Graphire BT", 16704, 12064, 511, 32,
4345 GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES, 2 };
4346 static const struct wacom_features wacom_features_0x11 =
4347 { "Wacom Graphire2 4x5", 10206, 7422, 511, 63,
4348 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4349 static const struct wacom_features wacom_features_0x12 =
4350 { "Wacom Graphire2 5x7", 13918, 10206, 511, 63,
4351 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4352 static const struct wacom_features wacom_features_0x13 =
4353 { "Wacom Graphire3", 10208, 7424, 511, 63,
4354 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4355 static const struct wacom_features wacom_features_0x14 =
4356 { "Wacom Graphire3 6x8", 16704, 12064, 511, 63,
4357 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4358 static const struct wacom_features wacom_features_0x15 =
4359 { "Wacom Graphire4 4x5", 10208, 7424, 511, 63,
4360 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4361 static const struct wacom_features wacom_features_0x16 =
4362 { "Wacom Graphire4 6x8", 16704, 12064, 511, 63,
4363 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4364 static const struct wacom_features wacom_features_0x17 =
4365 { "Wacom BambooFun 4x5", 14760, 9225, 511, 63,
4366 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4367 static const struct wacom_features wacom_features_0x18 =
4368 { "Wacom BambooFun 6x8", 21648, 13530, 511, 63,
4369 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4370 static const struct wacom_features wacom_features_0x19 =
4371 { "Wacom Bamboo1 Medium", 16704, 12064, 511, 63,
4372 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4373 static const struct wacom_features wacom_features_0x60 =
4374 { "Wacom Volito", 5104, 3712, 511, 63,
4375 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4376 static const struct wacom_features wacom_features_0x61 =
4377 { "Wacom PenStation2", 3250, 2320, 255, 63,
4378 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4379 static const struct wacom_features wacom_features_0x62 =
4380 { "Wacom Volito2 4x5", 5104, 3712, 511, 63,
4381 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4382 static const struct wacom_features wacom_features_0x63 =
4383 { "Wacom Volito2 2x3", 3248, 2320, 511, 63,
4384 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4385 static const struct wacom_features wacom_features_0x64 =
4386 { "Wacom PenPartner2", 3250, 2320, 511, 63,
4387 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4388 static const struct wacom_features wacom_features_0x65 =
4389 { "Wacom Bamboo", 14760, 9225, 511, 63,
4390 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4391 static const struct wacom_features wacom_features_0x69 =
4392 { "Wacom Bamboo1", 5104, 3712, 511, 63,
4393 GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
4394 static const struct wacom_features wacom_features_0x6A =
4395 { "Wacom Bamboo1 4x6", 14760, 9225, 1023, 63,
4396 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4397 static const struct wacom_features wacom_features_0x6B =
4398 { "Wacom Bamboo1 5x8", 21648, 13530, 1023, 63,
4399 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4400 static const struct wacom_features wacom_features_0x20 =
4401 { "Wacom Intuos 4x5", 12700, 10600, 1023, 31,
4402 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4403 static const struct wacom_features wacom_features_0x21 =
4404 { "Wacom Intuos 6x8", 20320, 16240, 1023, 31,
4405 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4406 static const struct wacom_features wacom_features_0x22 =
4407 { "Wacom Intuos 9x12", 30480, 24060, 1023, 31,
4408 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4409 static const struct wacom_features wacom_features_0x23 =
4410 { "Wacom Intuos 12x12", 30480, 31680, 1023, 31,
4411 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4412 static const struct wacom_features wacom_features_0x24 =
4413 { "Wacom Intuos 12x18", 45720, 31680, 1023, 31,
4414 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4415 static const struct wacom_features wacom_features_0x30 =
4416 { "Wacom PL400", 5408, 4056, 255, 0,
4417 PL, WACOM_PL_RES, WACOM_PL_RES };
4418 static const struct wacom_features wacom_features_0x31 =
4419 { "Wacom PL500", 6144, 4608, 255, 0,
4420 PL, WACOM_PL_RES, WACOM_PL_RES };
4421 static const struct wacom_features wacom_features_0x32 =
4422 { "Wacom PL600", 6126, 4604, 255, 0,
4423 PL, WACOM_PL_RES, WACOM_PL_RES };
4424 static const struct wacom_features wacom_features_0x33 =
4425 { "Wacom PL600SX", 6260, 5016, 255, 0,
4426 PL, WACOM_PL_RES, WACOM_PL_RES };
4427 static const struct wacom_features wacom_features_0x34 =
4428 { "Wacom PL550", 6144, 4608, 511, 0,
4429 PL, WACOM_PL_RES, WACOM_PL_RES };
4430 static const struct wacom_features wacom_features_0x35 =
4431 { "Wacom PL800", 7220, 5780, 511, 0,
4432 PL, WACOM_PL_RES, WACOM_PL_RES };
4433 static const struct wacom_features wacom_features_0x37 =
4434 { "Wacom PL700", 6758, 5406, 511, 0,
4435 PL, WACOM_PL_RES, WACOM_PL_RES };
4436 static const struct wacom_features wacom_features_0x38 =
4437 { "Wacom PL510", 6282, 4762, 511, 0,
4438 PL, WACOM_PL_RES, WACOM_PL_RES };
4439 static const struct wacom_features wacom_features_0x39 =
4440 { "Wacom DTU710", 34080, 27660, 511, 0,
4441 PL, WACOM_PL_RES, WACOM_PL_RES };
4442 static const struct wacom_features wacom_features_0xC4 =
4443 { "Wacom DTF521", 6282, 4762, 511, 0,
4444 PL, WACOM_PL_RES, WACOM_PL_RES };
4445 static const struct wacom_features wacom_features_0xC0 =
4446 { "Wacom DTF720", 6858, 5506, 511, 0,
4447 PL, WACOM_PL_RES, WACOM_PL_RES };
4448 static const struct wacom_features wacom_features_0xC2 =
4449 { "Wacom DTF720a", 6858, 5506, 511, 0,
4450 PL, WACOM_PL_RES, WACOM_PL_RES };
4451 static const struct wacom_features wacom_features_0x03 =
4452 { "Wacom Cintiq Partner", 20480, 15360, 511, 0,
4453 PTU, WACOM_PL_RES, WACOM_PL_RES };
4454 static const struct wacom_features wacom_features_0x41 =
4455 { "Wacom Intuos2 4x5", 12700, 10600, 1023, 31,
4456 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4457 static const struct wacom_features wacom_features_0x42 =
4458 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
4459 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4460 static const struct wacom_features wacom_features_0x43 =
4461 { "Wacom Intuos2 9x12", 30480, 24060, 1023, 31,
4462 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4463 static const struct wacom_features wacom_features_0x44 =
4464 { "Wacom Intuos2 12x12", 30480, 31680, 1023, 31,
4465 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4466 static const struct wacom_features wacom_features_0x45 =
4467 { "Wacom Intuos2 12x18", 45720, 31680, 1023, 31,
4468 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4469 static const struct wacom_features wacom_features_0xB0 =
4470 { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63,
4471 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
4472 static const struct wacom_features wacom_features_0xB1 =
4473 { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63,
4474 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4475 static const struct wacom_features wacom_features_0xB2 =
4476 { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63,
4477 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4478 static const struct wacom_features wacom_features_0xB3 =
4479 { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63,
4480 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4481 static const struct wacom_features wacom_features_0xB4 =
4482 { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63,
4483 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4484 static const struct wacom_features wacom_features_0xB5 =
4485 { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63,
4486 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4487 static const struct wacom_features wacom_features_0xB7 =
4488 { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63,
4489 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
4490 static const struct wacom_features wacom_features_0xB8 =
4491 { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63,
4492 INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
4493 static const struct wacom_features wacom_features_0xB9 =
4494 { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63,
4495 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4496 static const struct wacom_features wacom_features_0xBA =
4497 { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63,
4498 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4499 static const struct wacom_features wacom_features_0xBB =
4500 { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63,
4501 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4502 static const struct wacom_features wacom_features_0xBC =
4503 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
4504 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4505 static const struct wacom_features wacom_features_0xBD =
4506 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
4507 INTUOS4WL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4508 static const struct wacom_features wacom_features_0x26 =
4509 { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63,
4510 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16 };
4511 static const struct wacom_features wacom_features_0x27 =
4512 { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63,
4513 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
4514 static const struct wacom_features wacom_features_0x28 =
4515 { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63,
4516 INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
4517 static const struct wacom_features wacom_features_0x29 =
4518 { "Wacom Intuos5 S", 31496, 19685, 2047, 63,
4519 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
4520 static const struct wacom_features wacom_features_0x2A =
4521 { "Wacom Intuos5 M", 44704, 27940, 2047, 63,
4522 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4523 static const struct wacom_features wacom_features_0x314 =
4524 { "Wacom Intuos Pro S", 31496, 19685, 2047, 63,
4525 INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16,
4526 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4527 static const struct wacom_features wacom_features_0x315 =
4528 { "Wacom Intuos Pro M", 44704, 27940, 2047, 63,
4529 INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
4530 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4531 static const struct wacom_features wacom_features_0x317 =
4532 { "Wacom Intuos Pro L", 65024, 40640, 2047, 63,
4533 INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
4534 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4535 static const struct wacom_features wacom_features_0xF4 =
4536 { "Wacom Cintiq 24HD", 104480, 65600, 2047, 63,
4537 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
4538 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4539 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4540 static const struct wacom_features wacom_features_0xF8 =
4541 { "Wacom Cintiq 24HD touch", 104480, 65600, 2047, 63, /* Pen */
4542 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
4543 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4544 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4545 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 };
4546 static const struct wacom_features wacom_features_0xF6 =
4547 { "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */
4548 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10,
4549 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4550 static const struct wacom_features wacom_features_0x32A =
4551 { "Wacom Cintiq 27QHD", 120140, 67920, 2047, 63,
4552 WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
4553 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4554 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4555 static const struct wacom_features wacom_features_0x32B =
4556 { "Wacom Cintiq 27QHD touch", 120140, 67920, 2047, 63,
4557 WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
4558 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4559 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4560 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32C };
4561 static const struct wacom_features wacom_features_0x32C =
4562 { "Wacom Cintiq 27QHD touch", .type = WACOM_27QHDT,
4563 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32B, .touch_max = 10 };
4564 static const struct wacom_features wacom_features_0x3F =
4565 { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63,
4566 CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4567 static const struct wacom_features wacom_features_0xC5 =
4568 { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63,
4569 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
4570 static const struct wacom_features wacom_features_0xC6 =
4571 { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63,
4572 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
4573 static const struct wacom_features wacom_features_0x304 =
4574 { "Wacom Cintiq 13HD", 59552, 33848, 1023, 63,
4575 WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4576 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4577 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4578 static const struct wacom_features wacom_features_0x333 =
4579 { "Wacom Cintiq 13HD touch", 59552, 33848, 2047, 63,
4580 WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4581 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4582 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4583 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x335 };
4584 static const struct wacom_features wacom_features_0x335 =
4585 { "Wacom Cintiq 13HD touch", .type = WACOM_24HDT, /* Touch */
4586 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x333, .touch_max = 10,
4587 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4588 static const struct wacom_features wacom_features_0xC7 =
4589 { "Wacom DTU1931", 37832, 30305, 511, 0,
4590 PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4591 static const struct wacom_features wacom_features_0xCE =
4592 { "Wacom DTU2231", 47864, 27011, 511, 0,
4593 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4594 .check_for_hid_type = true, .hid_type = HID_TYPE_USBMOUSE };
4595 static const struct wacom_features wacom_features_0xF0 =
4596 { "Wacom DTU1631", 34623, 19553, 511, 0,
4597 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4598 static const struct wacom_features wacom_features_0xFB =
4599 { "Wacom DTU1031", 22096, 13960, 511, 0,
4600 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
4601 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4602 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4603 static const struct wacom_features wacom_features_0x32F =
4604 { "Wacom DTU1031X", 22672, 12928, 511, 0,
4605 DTUSX, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 0,
4606 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4607 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4608 static const struct wacom_features wacom_features_0x336 =
4609 { "Wacom DTU1141", 23672, 13403, 1023, 0,
4610 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
4611 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4612 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4613 static const struct wacom_features wacom_features_0x57 =
4614 { "Wacom DTK2241", 95840, 54260, 2047, 63,
4615 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
4616 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4617 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4618 static const struct wacom_features wacom_features_0x59 = /* Pen */
4619 { "Wacom DTH2242", 95840, 54260, 2047, 63,
4620 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
4621 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4622 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4623 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D };
4624 static const struct wacom_features wacom_features_0x5D = /* Touch */
4625 { "Wacom DTH2242", .type = WACOM_24HDT,
4626 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10,
4627 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4628 static const struct wacom_features wacom_features_0xCC =
4629 { "Wacom Cintiq 21UX2", 87200, 65600, 2047, 63,
4630 WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
4631 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4632 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4633 static const struct wacom_features wacom_features_0xFA =
4634 { "Wacom Cintiq 22HD", 95840, 54260, 2047, 63,
4635 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
4636 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4637 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4638 static const struct wacom_features wacom_features_0x5B =
4639 { "Wacom Cintiq 22HDT", 95840, 54260, 2047, 63,
4640 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
4641 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4642 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4643 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e };
4644 static const struct wacom_features wacom_features_0x5E =
4645 { "Wacom Cintiq 22HDT", .type = WACOM_24HDT,
4646 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5b, .touch_max = 10,
4647 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4648 static const struct wacom_features wacom_features_0x90 =
4649 { "Wacom ISDv4 90", 26202, 16325, 255, 0,
4650 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4651 static const struct wacom_features wacom_features_0x93 =
4652 { "Wacom ISDv4 93", 26202, 16325, 255, 0,
4653 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4654 static const struct wacom_features wacom_features_0x97 =
4655 { "Wacom ISDv4 97", 26202, 16325, 511, 0,
4656 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4657 static const struct wacom_features wacom_features_0x9A =
4658 { "Wacom ISDv4 9A", 26202, 16325, 255, 0,
4659 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4660 static const struct wacom_features wacom_features_0x9F =
4661 { "Wacom ISDv4 9F", 26202, 16325, 255, 0,
4662 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4663 static const struct wacom_features wacom_features_0xE2 =
4664 { "Wacom ISDv4 E2", 26202, 16325, 255, 0,
4665 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4666 static const struct wacom_features wacom_features_0xE3 =
4667 { "Wacom ISDv4 E3", 26202, 16325, 255, 0,
4668 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4669 static const struct wacom_features wacom_features_0xE5 =
4670 { "Wacom ISDv4 E5", 26202, 16325, 255, 0,
4671 MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4672 static const struct wacom_features wacom_features_0xE6 =
4673 { "Wacom ISDv4 E6", 27760, 15694, 255, 0,
4674 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4675 static const struct wacom_features wacom_features_0xEC =
4676 { "Wacom ISDv4 EC", 25710, 14500, 255, 0,
4677 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4678 static const struct wacom_features wacom_features_0xED =
4679 { "Wacom ISDv4 ED", 26202, 16325, 255, 0,
4680 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4681 static const struct wacom_features wacom_features_0xEF =
4682 { "Wacom ISDv4 EF", 26202, 16325, 255, 0,
4683 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4684 static const struct wacom_features wacom_features_0x100 =
4685 { "Wacom ISDv4 100", 26202, 16325, 255, 0,
4686 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4687 static const struct wacom_features wacom_features_0x101 =
4688 { "Wacom ISDv4 101", 26202, 16325, 255, 0,
4689 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4690 static const struct wacom_features wacom_features_0x10D =
4691 { "Wacom ISDv4 10D", 26202, 16325, 255, 0,
4692 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4693 static const struct wacom_features wacom_features_0x10E =
4694 { "Wacom ISDv4 10E", 27760, 15694, 255, 0,
4695 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4696 static const struct wacom_features wacom_features_0x10F =
4697 { "Wacom ISDv4 10F", 27760, 15694, 255, 0,
4698 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4699 static const struct wacom_features wacom_features_0x116 =
4700 { "Wacom ISDv4 116", 26202, 16325, 255, 0,
4701 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4702 static const struct wacom_features wacom_features_0x12C =
4703 { "Wacom ISDv4 12C", 27848, 15752, 2047, 0,
4704 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4705 static const struct wacom_features wacom_features_0x4001 =
4706 { "Wacom ISDv4 4001", 26202, 16325, 255, 0,
4707 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4708 static const struct wacom_features wacom_features_0x4004 =
4709 { "Wacom ISDv4 4004", 11060, 6220, 255, 0,
4710 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4711 static const struct wacom_features wacom_features_0x5000 =
4712 { "Wacom ISDv4 5000", 27848, 15752, 1023, 0,
4713 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4714 static const struct wacom_features wacom_features_0x5002 =
4715 { "Wacom ISDv4 5002", 29576, 16724, 1023, 0,
4716 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4717 static const struct wacom_features wacom_features_0x47 =
4718 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
4719 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4720 static const struct wacom_features wacom_features_0x84 =
4721 { "Wacom Wireless Receiver", .type = WIRELESS, .touch_max = 16 };
4722 static const struct wacom_features wacom_features_0xD0 =
4723 { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31,
4724 BAMBOO_TOUCH, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4725 static const struct wacom_features wacom_features_0xD1 =
4726 { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31,
4727 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4728 static const struct wacom_features wacom_features_0xD2 =
4729 { "Wacom Bamboo Craft", 14720, 9200, 1023, 31,
4730 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4731 static const struct wacom_features wacom_features_0xD3 =
4732 { "Wacom Bamboo 2FG 6x8", 21648, 13700, 1023, 31,
4733 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4734 static const struct wacom_features wacom_features_0xD4 =
4735 { "Wacom Bamboo Pen", 14720, 9200, 1023, 31,
4736 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4737 static const struct wacom_features wacom_features_0xD5 =
4738 { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31,
4739 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4740 static const struct wacom_features wacom_features_0xD6 =
4741 { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31,
4742 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4743 static const struct wacom_features wacom_features_0xD7 =
4744 { "Wacom BambooPT 2FG Small", 14720, 9200, 1023, 31,
4745 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4746 static const struct wacom_features wacom_features_0xD8 =
4747 { "Wacom Bamboo Comic 2FG", 21648, 13700, 1023, 31,
4748 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4749 static const struct wacom_features wacom_features_0xDA =
4750 { "Wacom Bamboo 2FG 4x5 SE", 14720, 9200, 1023, 31,
4751 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4752 static const struct wacom_features wacom_features_0xDB =
4753 { "Wacom Bamboo 2FG 6x8 SE", 21648, 13700, 1023, 31,
4754 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4755 static const struct wacom_features wacom_features_0xDD =
4756 { "Wacom Bamboo Connect", 14720, 9200, 1023, 31,
4757 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4758 static const struct wacom_features wacom_features_0xDE =
4759 { "Wacom Bamboo 16FG 4x5", 14720, 9200, 1023, 31,
4760 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
4761 static const struct wacom_features wacom_features_0xDF =
4762 { "Wacom Bamboo 16FG 6x8", 21648, 13700, 1023, 31,
4763 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
4764 static const struct wacom_features wacom_features_0x300 =
4765 { "Wacom Bamboo One S", 14720, 9225, 1023, 31,
4766 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4767 static const struct wacom_features wacom_features_0x301 =
4768 { "Wacom Bamboo One M", 21648, 13530, 1023, 31,
4769 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4770 static const struct wacom_features wacom_features_0x302 =
4771 { "Wacom Intuos PT S", 15200, 9500, 1023, 31,
4772 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4773 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4774 static const struct wacom_features wacom_features_0x303 =
4775 { "Wacom Intuos PT M", 21600, 13500, 1023, 31,
4776 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4777 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4778 static const struct wacom_features wacom_features_0x30E =
4779 { "Wacom Intuos S", 15200, 9500, 1023, 31,
4780 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4781 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4782 static const struct wacom_features wacom_features_0x6004 =
4783 { "ISD-V4", 12800, 8000, 255, 0,
4784 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4785 static const struct wacom_features wacom_features_0x307 =
4786 { "Wacom ISDv5 307", 59552, 33848, 2047, 63,
4787 CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4788 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4789 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4790 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 };
4791 static const struct wacom_features wacom_features_0x309 =
4792 { "Wacom ISDv5 309", .type = WACOM_24HDT, /* Touch */
4793 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x0307, .touch_max = 10,
4794 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4795 static const struct wacom_features wacom_features_0x30A =
4796 { "Wacom ISDv5 30A", 59552, 33848, 2047, 63,
4797 CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4798 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4799 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4800 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30C };
4801 static const struct wacom_features wacom_features_0x30C =
4802 { "Wacom ISDv5 30C", .type = WACOM_24HDT, /* Touch */
4803 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30A, .touch_max = 10,
4804 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4805 static const struct wacom_features wacom_features_0x318 =
4806 { "Wacom USB Bamboo PAD", 4095, 4095, /* Touch */
4807 .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
4808 static const struct wacom_features wacom_features_0x319 =
4809 { "Wacom Wireless Bamboo PAD", 4095, 4095, /* Touch */
4810 .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
4811 static const struct wacom_features wacom_features_0x325 =
4812 { "Wacom ISDv5 325", 59552, 33848, 2047, 63,
4813 CINTIQ_COMPANION_2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 11,
4814 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4815 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4816 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x326 };
4817 static const struct wacom_features wacom_features_0x326 = /* Touch */
4818 { "Wacom ISDv5 326", .type = HID_GENERIC, .oVid = USB_VENDOR_ID_WACOM,
4820 static const struct wacom_features wacom_features_0x323 =
4821 { "Wacom Intuos P M", 21600, 13500, 1023, 31,
4822 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4823 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4824 static const struct wacom_features wacom_features_0x331 =
4825 { "Wacom Express Key Remote", .type = REMOTE,
4826 .numbered_buttons = 18, .check_for_hid_type = true,
4827 .hid_type = HID_TYPE_USBNONE };
4828 static const struct wacom_features wacom_features_0x33B =
4829 { "Wacom Intuos S 2", 15200, 9500, 2047, 63,
4830 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4831 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4832 static const struct wacom_features wacom_features_0x33C =
4833 { "Wacom Intuos PT S 2", 15200, 9500, 2047, 63,
4834 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4835 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4836 static const struct wacom_features wacom_features_0x33D =
4837 { "Wacom Intuos P M 2", 21600, 13500, 2047, 63,
4838 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4839 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4840 static const struct wacom_features wacom_features_0x33E =
4841 { "Wacom Intuos PT M 2", 21600, 13500, 2047, 63,
4842 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4843 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4844 static const struct wacom_features wacom_features_0x343 =
4845 { "Wacom DTK1651", 34816, 19759, 1023, 0,
4846 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
4847 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4848 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4849 static const struct wacom_features wacom_features_0x360 =
4850 { "Wacom Intuos Pro M", 44800, 29600, 8191, 63,
4851 INTUOSP2_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 10 };
4852 static const struct wacom_features wacom_features_0x361 =
4853 { "Wacom Intuos Pro L", 62200, 43200, 8191, 63,
4854 INTUOSP2_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 10 };
4855 static const struct wacom_features wacom_features_0x377 =
4856 { "Wacom Intuos BT S", 15200, 9500, 4095, 63,
4857 INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
4858 static const struct wacom_features wacom_features_0x379 =
4859 { "Wacom Intuos BT M", 21600, 13500, 4095, 63,
4860 INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
4861 static const struct wacom_features wacom_features_0x37A =
4862 { "Wacom One by Wacom S", 15200, 9500, 2047, 63,
4863 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4864 static const struct wacom_features wacom_features_0x37B =
4865 { "Wacom One by Wacom M", 21600, 13500, 2047, 63,
4866 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4867 static const struct wacom_features wacom_features_0x393 =
4868 { "Wacom Intuos Pro S", 31920, 19950, 8191, 63,
4869 INTUOSP2S_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7,
4871 static const struct wacom_features wacom_features_0x3c6 =
4872 { "Wacom Intuos BT S", 15200, 9500, 4095, 63,
4873 INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
4874 static const struct wacom_features wacom_features_0x3c8 =
4875 { "Wacom Intuos BT M", 21600, 13500, 4095, 63,
4876 INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
4877 static const struct wacom_features wacom_features_0x3dd =
4878 { "Wacom Intuos Pro S", 31920, 19950, 8191, 63,
4879 INTUOSP2S_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7,
4882 static const struct wacom_features wacom_features_HID_ANY_ID =
4883 { "Wacom HID", .type = HID_GENERIC, .oVid = HID_ANY_ID, .oPid = HID_ANY_ID };
4885 #define USB_DEVICE_WACOM(prod) \
4886 HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4887 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4889 #define BT_DEVICE_WACOM(prod) \
4890 HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4891 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4893 #define I2C_DEVICE_WACOM(prod) \
4894 HID_DEVICE(BUS_I2C, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4895 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4897 #define USB_DEVICE_LENOVO(prod) \
4898 HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
4899 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4901 const struct hid_device_id wacom_ids[] = {
4902 { USB_DEVICE_WACOM(0x00) },
4903 { USB_DEVICE_WACOM(0x03) },
4904 { USB_DEVICE_WACOM(0x10) },
4905 { USB_DEVICE_WACOM(0x11) },
4906 { USB_DEVICE_WACOM(0x12) },
4907 { USB_DEVICE_WACOM(0x13) },
4908 { USB_DEVICE_WACOM(0x14) },
4909 { USB_DEVICE_WACOM(0x15) },
4910 { USB_DEVICE_WACOM(0x16) },
4911 { USB_DEVICE_WACOM(0x17) },
4912 { USB_DEVICE_WACOM(0x18) },
4913 { USB_DEVICE_WACOM(0x19) },
4914 { USB_DEVICE_WACOM(0x20) },
4915 { USB_DEVICE_WACOM(0x21) },
4916 { USB_DEVICE_WACOM(0x22) },
4917 { USB_DEVICE_WACOM(0x23) },
4918 { USB_DEVICE_WACOM(0x24) },
4919 { USB_DEVICE_WACOM(0x26) },
4920 { USB_DEVICE_WACOM(0x27) },
4921 { USB_DEVICE_WACOM(0x28) },
4922 { USB_DEVICE_WACOM(0x29) },
4923 { USB_DEVICE_WACOM(0x2A) },
4924 { USB_DEVICE_WACOM(0x30) },
4925 { USB_DEVICE_WACOM(0x31) },
4926 { USB_DEVICE_WACOM(0x32) },
4927 { USB_DEVICE_WACOM(0x33) },
4928 { USB_DEVICE_WACOM(0x34) },
4929 { USB_DEVICE_WACOM(0x35) },
4930 { USB_DEVICE_WACOM(0x37) },
4931 { USB_DEVICE_WACOM(0x38) },
4932 { USB_DEVICE_WACOM(0x39) },
4933 { USB_DEVICE_WACOM(0x3F) },
4934 { USB_DEVICE_WACOM(0x41) },
4935 { USB_DEVICE_WACOM(0x42) },
4936 { USB_DEVICE_WACOM(0x43) },
4937 { USB_DEVICE_WACOM(0x44) },
4938 { USB_DEVICE_WACOM(0x45) },
4939 { USB_DEVICE_WACOM(0x47) },
4940 { USB_DEVICE_WACOM(0x57) },
4941 { USB_DEVICE_WACOM(0x59) },
4942 { USB_DEVICE_WACOM(0x5B) },
4943 { USB_DEVICE_WACOM(0x5D) },
4944 { USB_DEVICE_WACOM(0x5E) },
4945 { USB_DEVICE_WACOM(0x60) },
4946 { USB_DEVICE_WACOM(0x61) },
4947 { USB_DEVICE_WACOM(0x62) },
4948 { USB_DEVICE_WACOM(0x63) },
4949 { USB_DEVICE_WACOM(0x64) },
4950 { USB_DEVICE_WACOM(0x65) },
4951 { USB_DEVICE_WACOM(0x69) },
4952 { USB_DEVICE_WACOM(0x6A) },
4953 { USB_DEVICE_WACOM(0x6B) },
4954 { BT_DEVICE_WACOM(0x81) },
4955 { USB_DEVICE_WACOM(0x84) },
4956 { USB_DEVICE_WACOM(0x90) },
4957 { USB_DEVICE_WACOM(0x93) },
4958 { USB_DEVICE_WACOM(0x97) },
4959 { USB_DEVICE_WACOM(0x9A) },
4960 { USB_DEVICE_WACOM(0x9F) },
4961 { USB_DEVICE_WACOM(0xB0) },
4962 { USB_DEVICE_WACOM(0xB1) },
4963 { USB_DEVICE_WACOM(0xB2) },
4964 { USB_DEVICE_WACOM(0xB3) },
4965 { USB_DEVICE_WACOM(0xB4) },
4966 { USB_DEVICE_WACOM(0xB5) },
4967 { USB_DEVICE_WACOM(0xB7) },
4968 { USB_DEVICE_WACOM(0xB8) },
4969 { USB_DEVICE_WACOM(0xB9) },
4970 { USB_DEVICE_WACOM(0xBA) },
4971 { USB_DEVICE_WACOM(0xBB) },
4972 { USB_DEVICE_WACOM(0xBC) },
4973 { BT_DEVICE_WACOM(0xBD) },
4974 { USB_DEVICE_WACOM(0xC0) },
4975 { USB_DEVICE_WACOM(0xC2) },
4976 { USB_DEVICE_WACOM(0xC4) },
4977 { USB_DEVICE_WACOM(0xC5) },
4978 { USB_DEVICE_WACOM(0xC6) },
4979 { USB_DEVICE_WACOM(0xC7) },
4980 { USB_DEVICE_WACOM(0xCC) },
4981 { USB_DEVICE_WACOM(0xCE) },
4982 { USB_DEVICE_WACOM(0xD0) },
4983 { USB_DEVICE_WACOM(0xD1) },
4984 { USB_DEVICE_WACOM(0xD2) },
4985 { USB_DEVICE_WACOM(0xD3) },
4986 { USB_DEVICE_WACOM(0xD4) },
4987 { USB_DEVICE_WACOM(0xD5) },
4988 { USB_DEVICE_WACOM(0xD6) },
4989 { USB_DEVICE_WACOM(0xD7) },
4990 { USB_DEVICE_WACOM(0xD8) },
4991 { USB_DEVICE_WACOM(0xDA) },
4992 { USB_DEVICE_WACOM(0xDB) },
4993 { USB_DEVICE_WACOM(0xDD) },
4994 { USB_DEVICE_WACOM(0xDE) },
4995 { USB_DEVICE_WACOM(0xDF) },
4996 { USB_DEVICE_WACOM(0xE2) },
4997 { USB_DEVICE_WACOM(0xE3) },
4998 { USB_DEVICE_WACOM(0xE5) },
4999 { USB_DEVICE_WACOM(0xE6) },
5000 { USB_DEVICE_WACOM(0xEC) },
5001 { USB_DEVICE_WACOM(0xED) },
5002 { USB_DEVICE_WACOM(0xEF) },
5003 { USB_DEVICE_WACOM(0xF0) },
5004 { USB_DEVICE_WACOM(0xF4) },
5005 { USB_DEVICE_WACOM(0xF6) },
5006 { USB_DEVICE_WACOM(0xF8) },
5007 { USB_DEVICE_WACOM(0xFA) },
5008 { USB_DEVICE_WACOM(0xFB) },
5009 { USB_DEVICE_WACOM(0x100) },
5010 { USB_DEVICE_WACOM(0x101) },
5011 { USB_DEVICE_WACOM(0x10D) },
5012 { USB_DEVICE_WACOM(0x10E) },
5013 { USB_DEVICE_WACOM(0x10F) },
5014 { USB_DEVICE_WACOM(0x116) },
5015 { USB_DEVICE_WACOM(0x12C) },
5016 { USB_DEVICE_WACOM(0x300) },
5017 { USB_DEVICE_WACOM(0x301) },
5018 { USB_DEVICE_WACOM(0x302) },
5019 { USB_DEVICE_WACOM(0x303) },
5020 { USB_DEVICE_WACOM(0x304) },
5021 { USB_DEVICE_WACOM(0x307) },
5022 { USB_DEVICE_WACOM(0x309) },
5023 { USB_DEVICE_WACOM(0x30A) },
5024 { USB_DEVICE_WACOM(0x30C) },
5025 { USB_DEVICE_WACOM(0x30E) },
5026 { USB_DEVICE_WACOM(0x314) },
5027 { USB_DEVICE_WACOM(0x315) },
5028 { USB_DEVICE_WACOM(0x317) },
5029 { USB_DEVICE_WACOM(0x318) },
5030 { USB_DEVICE_WACOM(0x319) },
5031 { USB_DEVICE_WACOM(0x323) },
5032 { USB_DEVICE_WACOM(0x325) },
5033 { USB_DEVICE_WACOM(0x326) },
5034 { USB_DEVICE_WACOM(0x32A) },
5035 { USB_DEVICE_WACOM(0x32B) },
5036 { USB_DEVICE_WACOM(0x32C) },
5037 { USB_DEVICE_WACOM(0x32F) },
5038 { USB_DEVICE_WACOM(0x331) },
5039 { USB_DEVICE_WACOM(0x333) },
5040 { USB_DEVICE_WACOM(0x335) },
5041 { USB_DEVICE_WACOM(0x336) },
5042 { USB_DEVICE_WACOM(0x33B) },
5043 { USB_DEVICE_WACOM(0x33C) },
5044 { USB_DEVICE_WACOM(0x33D) },
5045 { USB_DEVICE_WACOM(0x33E) },
5046 { USB_DEVICE_WACOM(0x343) },
5047 { BT_DEVICE_WACOM(0x360) },
5048 { BT_DEVICE_WACOM(0x361) },
5049 { BT_DEVICE_WACOM(0x377) },
5050 { BT_DEVICE_WACOM(0x379) },
5051 { USB_DEVICE_WACOM(0x37A) },
5052 { USB_DEVICE_WACOM(0x37B) },
5053 { BT_DEVICE_WACOM(0x393) },
5054 { BT_DEVICE_WACOM(0x3c6) },
5055 { BT_DEVICE_WACOM(0x3c8) },
5056 { BT_DEVICE_WACOM(0x3dd) },
5057 { USB_DEVICE_WACOM(0x4001) },
5058 { USB_DEVICE_WACOM(0x4004) },
5059 { USB_DEVICE_WACOM(0x5000) },
5060 { USB_DEVICE_WACOM(0x5002) },
5061 { USB_DEVICE_LENOVO(0x6004) },
5063 { USB_DEVICE_WACOM(HID_ANY_ID) },
5064 { I2C_DEVICE_WACOM(HID_ANY_ID) },
5065 { BT_DEVICE_WACOM(HID_ANY_ID) },
5068 MODULE_DEVICE_TABLE(hid, wacom_ids);