2 * drivers/input/tablet/wacom_wac.c
4 * USB Wacom tablet support - Wacom specific code
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
15 #include "wacom_wac.h"
17 #include <linux/input/mt.h>
18 #include <linux/jiffies.h>
20 /* resolution for penabled devices */
21 #define WACOM_PL_RES 20
22 #define WACOM_PENPRTN_RES 40
23 #define WACOM_VOLITO_RES 50
24 #define WACOM_GRAPHIRE_RES 80
25 #define WACOM_INTUOS_RES 100
26 #define WACOM_INTUOS3_RES 200
28 /* Newer Cintiq and DTU have an offset between tablet and screen areas */
29 #define WACOM_DTU_OFFSET 200
30 #define WACOM_CINTIQ_OFFSET 400
33 * Scale factor relating reported contact size to logical contact area.
34 * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo
36 #define WACOM_CONTACT_AREA_SCALE 2607
38 static bool touch_arbitration = 1;
39 module_param(touch_arbitration, bool, 0644);
40 MODULE_PARM_DESC(touch_arbitration, " on (Y) off (N)");
42 static void wacom_report_numbered_buttons(struct input_dev *input_dev,
43 int button_count, int mask);
45 static int wacom_numbered_button_to_key(int n);
47 static void wacom_update_led(struct wacom *wacom, int button_count, int mask,
50 static void wacom_force_proxout(struct wacom_wac *wacom_wac)
52 struct input_dev *input = wacom_wac->pen_input;
54 wacom_wac->shared->stylus_in_proximity = 0;
56 input_report_key(input, BTN_TOUCH, 0);
57 input_report_key(input, BTN_STYLUS, 0);
58 input_report_key(input, BTN_STYLUS2, 0);
59 input_report_key(input, BTN_STYLUS3, 0);
60 input_report_key(input, wacom_wac->tool[0], 0);
61 if (wacom_wac->serial[0]) {
62 input_report_abs(input, ABS_MISC, 0);
64 input_report_abs(input, ABS_PRESSURE, 0);
66 wacom_wac->tool[0] = 0;
68 wacom_wac->serial[0] = 0;
73 void wacom_idleprox_timeout(struct timer_list *list)
75 struct wacom *wacom = from_timer(wacom, list, idleprox_timer);
76 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
78 if (!wacom_wac->hid_data.sense_state) {
82 hid_warn(wacom->hdev, "%s: tool appears to be hung in-prox. forcing it out.\n", __func__);
83 wacom_force_proxout(wacom_wac);
87 * Percent of battery capacity for Graphire.
88 * 8th value means AC online and show 100% capacity.
90 static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
93 * Percent of battery capacity for Intuos4 WL, AC has a separate bit.
95 static unsigned short batcap_i4[8] = { 1, 15, 30, 45, 60, 70, 85, 100 };
97 static void __wacom_notify_battery(struct wacom_battery *battery,
98 int bat_status, int bat_capacity,
99 bool bat_charging, bool bat_connected,
102 bool changed = battery->bat_status != bat_status ||
103 battery->battery_capacity != bat_capacity ||
104 battery->bat_charging != bat_charging ||
105 battery->bat_connected != bat_connected ||
106 battery->ps_connected != ps_connected;
109 battery->bat_status = bat_status;
110 battery->battery_capacity = bat_capacity;
111 battery->bat_charging = bat_charging;
112 battery->bat_connected = bat_connected;
113 battery->ps_connected = ps_connected;
115 if (battery->battery)
116 power_supply_changed(battery->battery);
120 static void wacom_notify_battery(struct wacom_wac *wacom_wac,
121 int bat_status, int bat_capacity, bool bat_charging,
122 bool bat_connected, bool ps_connected)
124 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
126 __wacom_notify_battery(&wacom->battery, bat_status, bat_capacity,
127 bat_charging, bat_connected, ps_connected);
130 static int wacom_penpartner_irq(struct wacom_wac *wacom)
132 unsigned char *data = wacom->data;
133 struct input_dev *input = wacom->pen_input;
137 if (data[5] & 0x80) {
138 wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
139 wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID;
140 input_report_key(input, wacom->tool[0], 1);
141 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
142 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
143 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
144 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
145 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127));
146 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
148 input_report_key(input, wacom->tool[0], 0);
149 input_report_abs(input, ABS_MISC, 0); /* report tool id */
150 input_report_abs(input, ABS_PRESSURE, -1);
151 input_report_key(input, BTN_TOUCH, 0);
156 input_report_key(input, BTN_TOOL_PEN, 1);
157 input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
158 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
159 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
160 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
161 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
162 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
166 dev_dbg(input->dev.parent,
167 "%s: received unknown report #%d\n", __func__, data[0]);
174 static int wacom_pl_irq(struct wacom_wac *wacom)
176 struct wacom_features *features = &wacom->features;
177 unsigned char *data = wacom->data;
178 struct input_dev *input = wacom->pen_input;
181 if (data[0] != WACOM_REPORT_PENABLED) {
182 dev_dbg(input->dev.parent,
183 "%s: received unknown report #%d\n", __func__, data[0]);
187 prox = data[1] & 0x40;
190 if ((data[0] & 0x10) || (data[4] & 0x20)) {
191 wacom->tool[0] = BTN_TOOL_RUBBER;
192 wacom->id[0] = ERASER_DEVICE_ID;
195 wacom->tool[0] = BTN_TOOL_PEN;
196 wacom->id[0] = STYLUS_DEVICE_ID;
200 /* If the eraser is in prox, STYLUS2 is always set. If we
201 * mis-detected the type and notice that STYLUS2 isn't set
202 * then force the eraser out of prox and let the pen in.
204 if (wacom->tool[0] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
205 input_report_key(input, BTN_TOOL_RUBBER, 0);
206 input_report_abs(input, ABS_MISC, 0);
208 wacom->tool[0] = BTN_TOOL_PEN;
209 wacom->id[0] = STYLUS_DEVICE_ID;
213 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
214 if (features->pressure_max > 255)
215 pressure = (pressure << 1) | ((data[4] >> 6) & 1);
216 pressure += (features->pressure_max + 1) / 2;
218 input_report_abs(input, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
219 input_report_abs(input, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
220 input_report_abs(input, ABS_PRESSURE, pressure);
222 input_report_key(input, BTN_TOUCH, data[4] & 0x08);
223 input_report_key(input, BTN_STYLUS, data[4] & 0x10);
224 /* Only allow the stylus2 button to be reported for the pen tool. */
225 input_report_key(input, BTN_STYLUS2, (wacom->tool[0] == BTN_TOOL_PEN) && (data[4] & 0x20));
230 input_report_key(input, wacom->tool[0], prox);
231 input_report_abs(input, ABS_MISC, wacom->id[0]);
235 static int wacom_ptu_irq(struct wacom_wac *wacom)
237 unsigned char *data = wacom->data;
238 struct input_dev *input = wacom->pen_input;
240 if (data[0] != WACOM_REPORT_PENABLED) {
241 dev_dbg(input->dev.parent,
242 "%s: received unknown report #%d\n", __func__, data[0]);
246 if (data[1] & 0x04) {
247 input_report_key(input, BTN_TOOL_RUBBER, data[1] & 0x20);
248 input_report_key(input, BTN_TOUCH, data[1] & 0x08);
249 wacom->id[0] = ERASER_DEVICE_ID;
251 input_report_key(input, BTN_TOOL_PEN, data[1] & 0x20);
252 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
253 wacom->id[0] = STYLUS_DEVICE_ID;
255 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
256 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
257 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
258 input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6]));
259 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
260 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
264 static int wacom_dtu_irq(struct wacom_wac *wacom)
266 unsigned char *data = wacom->data;
267 struct input_dev *input = wacom->pen_input;
268 int prox = data[1] & 0x20;
270 dev_dbg(input->dev.parent,
271 "%s: received report #%d", __func__, data[0]);
274 /* Going into proximity select tool */
275 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
276 if (wacom->tool[0] == BTN_TOOL_PEN)
277 wacom->id[0] = STYLUS_DEVICE_ID;
279 wacom->id[0] = ERASER_DEVICE_ID;
281 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
282 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
283 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
284 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
285 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x01) << 8) | data[6]);
286 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
287 if (!prox) /* out-prox */
289 input_report_key(input, wacom->tool[0], prox);
290 input_report_abs(input, ABS_MISC, wacom->id[0]);
294 static int wacom_dtus_irq(struct wacom_wac *wacom)
296 unsigned char *data = wacom->data;
297 struct input_dev *input = wacom->pen_input;
298 unsigned short prox, pressure = 0;
300 if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) {
301 dev_dbg(input->dev.parent,
302 "%s: received unknown report #%d", __func__, data[0]);
304 } else if (data[0] == WACOM_REPORT_DTUSPAD) {
305 input = wacom->pad_input;
306 input_report_key(input, BTN_0, (data[1] & 0x01));
307 input_report_key(input, BTN_1, (data[1] & 0x02));
308 input_report_key(input, BTN_2, (data[1] & 0x04));
309 input_report_key(input, BTN_3, (data[1] & 0x08));
310 input_report_abs(input, ABS_MISC,
311 data[1] & 0x0f ? PAD_DEVICE_ID : 0);
314 prox = data[1] & 0x80;
316 switch ((data[1] >> 3) & 3) {
318 wacom->tool[0] = BTN_TOOL_RUBBER;
319 wacom->id[0] = ERASER_DEVICE_ID;
323 wacom->tool[0] = BTN_TOOL_PEN;
324 wacom->id[0] = STYLUS_DEVICE_ID;
329 input_report_key(input, BTN_STYLUS, data[1] & 0x20);
330 input_report_key(input, BTN_STYLUS2, data[1] & 0x40);
331 input_report_abs(input, ABS_X, get_unaligned_be16(&data[3]));
332 input_report_abs(input, ABS_Y, get_unaligned_be16(&data[5]));
333 pressure = ((data[1] & 0x03) << 8) | (data[2] & 0xff);
334 input_report_abs(input, ABS_PRESSURE, pressure);
335 input_report_key(input, BTN_TOUCH, pressure > 10);
337 if (!prox) /* out-prox */
339 input_report_key(input, wacom->tool[0], prox);
340 input_report_abs(input, ABS_MISC, wacom->id[0]);
345 static int wacom_graphire_irq(struct wacom_wac *wacom)
347 struct wacom_features *features = &wacom->features;
348 unsigned char *data = wacom->data;
349 struct input_dev *input = wacom->pen_input;
350 struct input_dev *pad_input = wacom->pad_input;
351 int battery_capacity, ps_connected;
356 if (features->type == GRAPHIRE_BT) {
357 if (data[0] != WACOM_REPORT_PENABLED_BT) {
358 dev_dbg(input->dev.parent,
359 "%s: received unknown report #%d\n", __func__,
363 } else if (data[0] != WACOM_REPORT_PENABLED) {
364 dev_dbg(input->dev.parent,
365 "%s: received unknown report #%d\n", __func__, data[0]);
369 prox = data[1] & 0x80;
370 if (prox || wacom->id[0]) {
372 switch ((data[1] >> 5) & 3) {
375 wacom->tool[0] = BTN_TOOL_PEN;
376 wacom->id[0] = STYLUS_DEVICE_ID;
380 wacom->tool[0] = BTN_TOOL_RUBBER;
381 wacom->id[0] = ERASER_DEVICE_ID;
384 case 2: /* Mouse with wheel */
385 input_report_key(input, BTN_MIDDLE, data[1] & 0x04);
388 case 3: /* Mouse without wheel */
389 wacom->tool[0] = BTN_TOOL_MOUSE;
390 wacom->id[0] = CURSOR_DEVICE_ID;
394 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
395 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
396 if (wacom->tool[0] != BTN_TOOL_MOUSE) {
397 if (features->type == GRAPHIRE_BT)
398 input_report_abs(input, ABS_PRESSURE, data[6] |
399 (((__u16) (data[1] & 0x08)) << 5));
401 input_report_abs(input, ABS_PRESSURE, data[6] |
402 ((data[7] & 0x03) << 8));
403 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
404 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
405 input_report_key(input, BTN_STYLUS2, data[1] & 0x04);
407 input_report_key(input, BTN_LEFT, data[1] & 0x01);
408 input_report_key(input, BTN_RIGHT, data[1] & 0x02);
409 if (features->type == WACOM_G4 ||
410 features->type == WACOM_MO) {
411 input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f);
412 rw = (data[7] & 0x04) - (data[7] & 0x03);
413 } else if (features->type == GRAPHIRE_BT) {
414 /* Compute distance between mouse and tablet */
415 rw = 44 - (data[6] >> 2);
416 rw = clamp_val(rw, 0, 31);
417 input_report_abs(input, ABS_DISTANCE, rw);
418 if (((data[1] >> 5) & 3) == 2) {
419 /* Mouse with wheel */
420 input_report_key(input, BTN_MIDDLE,
422 rw = (data[6] & 0x01) ? -1 :
423 (data[6] & 0x02) ? 1 : 0;
428 input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f);
429 rw = -(signed char)data[6];
431 input_report_rel(input, REL_WHEEL, rw);
436 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
437 input_report_key(input, wacom->tool[0], prox);
438 input_sync(input); /* sync last event */
442 switch (features->type) {
444 prox = data[7] & 0xf8;
445 if (prox || wacom->id[1]) {
446 wacom->id[1] = PAD_DEVICE_ID;
447 input_report_key(pad_input, BTN_BACK, (data[7] & 0x40));
448 input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x80));
449 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
450 input_report_rel(pad_input, REL_WHEEL, rw);
453 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
459 prox = (data[7] & 0xf8) || data[8];
460 if (prox || wacom->id[1]) {
461 wacom->id[1] = PAD_DEVICE_ID;
462 input_report_key(pad_input, BTN_BACK, (data[7] & 0x08));
463 input_report_key(pad_input, BTN_LEFT, (data[7] & 0x20));
464 input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x10));
465 input_report_key(pad_input, BTN_RIGHT, (data[7] & 0x40));
466 input_report_abs(pad_input, ABS_WHEEL, (data[8] & 0x7f));
469 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
474 prox = data[7] & 0x03;
475 if (prox || wacom->id[1]) {
476 wacom->id[1] = PAD_DEVICE_ID;
477 input_report_key(pad_input, BTN_0, (data[7] & 0x02));
478 input_report_key(pad_input, BTN_1, (data[7] & 0x01));
481 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
487 /* Store current battery capacity and power supply state */
488 if (features->type == GRAPHIRE_BT) {
489 rw = (data[7] >> 2 & 0x07);
490 battery_capacity = batcap_gr[rw];
491 ps_connected = rw == 7;
492 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
493 battery_capacity, ps_connected, 1,
500 static void wacom_intuos_schedule_prox_event(struct wacom_wac *wacom_wac)
502 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
503 struct wacom_features *features = &wacom_wac->features;
504 struct hid_report *r;
505 struct hid_report_enum *re;
507 re = &(wacom->hdev->report_enum[HID_FEATURE_REPORT]);
508 if (features->type == INTUOSHT2)
509 r = re->report_id_hash[WACOM_REPORT_INTUOSHT2_ID];
511 r = re->report_id_hash[WACOM_REPORT_INTUOS_ID1];
513 hid_hw_request(wacom->hdev, r, HID_REQ_GET_REPORT);
517 static int wacom_intuos_pad(struct wacom_wac *wacom)
519 struct wacom_features *features = &wacom->features;
520 unsigned char *data = wacom->data;
521 struct input_dev *input = wacom->pad_input;
523 int buttons = 0, nbuttons = features->numbered_buttons;
524 int keys = 0, nkeys = 0;
525 int ring1 = 0, ring2 = 0;
526 int strip1 = 0, strip2 = 0;
529 /* pad packets. Works as a second tool and is always in prox */
530 if (!(data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD ||
531 data[0] == WACOM_REPORT_CINTIQPAD))
534 if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
535 buttons = (data[3] << 1) | (data[2] & 0x01);
537 } else if (features->type == DTK) {
539 } else if (features->type == WACOM_13HD) {
540 buttons = (data[4] << 1) | (data[3] & 0x01);
541 } else if (features->type == WACOM_24HD) {
542 buttons = (data[8] << 8) | data[6];
547 * Three "buttons" are available on the 24HD which are
548 * physically implemented as a touchstrip. Each button
549 * is approximately 3 bits wide with a 2 bit spacing.
550 * The raw touchstrip bits are stored at:
551 * ((data[3] & 0x1f) << 8) | data[4])
554 keys = ((data[3] & 0x1C) ? 1<<2 : 0) |
555 ((data[4] & 0xE0) ? 1<<1 : 0) |
556 ((data[4] & 0x07) ? 1<<0 : 0);
557 } else if (features->type == WACOM_27QHD) {
559 keys = data[2] & 0x07;
561 input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[4]));
562 input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[6]));
563 input_report_abs(input, ABS_Z, be16_to_cpup((__be16 *)&data[8]));
564 } else if (features->type == CINTIQ_HYBRID) {
566 * Do not send hardware buttons under Android. They
567 * are already sent to the system through GPIO (and
568 * have different meaning).
570 * d-pad right -> data[4] & 0x10
571 * d-pad up -> data[4] & 0x20
572 * d-pad left -> data[4] & 0x40
573 * d-pad down -> data[4] & 0x80
574 * d-pad center -> data[3] & 0x01
576 buttons = (data[4] << 1) | (data[3] & 0x01);
577 } else if (features->type == CINTIQ_COMPANION_2) {
578 /* d-pad right -> data[2] & 0x10
579 * d-pad up -> data[2] & 0x20
580 * d-pad left -> data[2] & 0x40
581 * d-pad down -> data[2] & 0x80
582 * d-pad center -> data[1] & 0x01
584 buttons = ((data[2] >> 4) << 7) |
585 ((data[1] & 0x04) << 4) |
586 ((data[2] & 0x0F) << 2) |
588 } else if (features->type >= INTUOS5S && features->type <= INTUOSPL) {
590 * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in
591 * addition to the mechanical switch. Switch data is
592 * stored in data[4], capacitive data in data[5].
594 * Touch ring mode switch (data[3]) has no capacitive sensor
596 buttons = (data[4] << 1) | (data[3] & 0x01);
599 if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) {
600 buttons = (data[8] << 10) | ((data[7] & 0x01) << 9) |
601 (data[6] << 1) | (data[5] & 0x01);
603 if (features->type == WACOM_22HD) {
605 keys = data[9] & 0x07;
608 buttons = ((data[6] & 0x10) << 5) |
609 ((data[5] & 0x10) << 4) |
610 ((data[6] & 0x0F) << 4) |
613 strip1 = ((data[1] & 0x1f) << 8) | data[2];
614 strip2 = ((data[3] & 0x1f) << 8) | data[4];
617 prox = (buttons & ~(~0U << nbuttons)) | (keys & ~(~0U << nkeys)) |
618 (ring1 & 0x80) | (ring2 & 0x80) | strip1 | strip2;
620 wacom_report_numbered_buttons(input, nbuttons, buttons);
622 for (i = 0; i < nkeys; i++)
623 input_report_key(input, KEY_PROG1 + i, keys & (1 << i));
625 input_report_abs(input, ABS_RX, strip1);
626 input_report_abs(input, ABS_RY, strip2);
628 input_report_abs(input, ABS_WHEEL, (ring1 & 0x80) ? (ring1 & 0x7f) : 0);
629 input_report_abs(input, ABS_THROTTLE, (ring2 & 0x80) ? (ring2 & 0x7f) : 0);
631 input_report_key(input, wacom->tool[1], prox ? 1 : 0);
632 input_report_abs(input, ABS_MISC, prox ? PAD_DEVICE_ID : 0);
634 input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff);
639 static int wacom_intuos_id_mangle(int tool_id)
641 return (tool_id & ~0xFFF) << 4 | (tool_id & 0xFFF);
644 static int wacom_intuos_get_tool_type(int tool_id)
649 case 0x812: /* Inking pen */
650 case 0x801: /* Intuos3 Inking pen */
651 case 0x12802: /* Intuos4/5 Inking Pen */
653 tool_type = BTN_TOOL_PENCIL;
656 case 0x822: /* Pen */
659 case 0x823: /* Intuos3 Grip Pen */
660 case 0x813: /* Intuos3 Classic Pen */
661 case 0x885: /* Intuos3 Marker Pen */
662 case 0x802: /* Intuos4/5 13HD/24HD General Pen */
663 case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
664 case 0x8e2: /* IntuosHT2 pen */
666 case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */
667 case 0x14802: /* Intuos4/5 13HD/24HD Classic Pen */
668 case 0x16802: /* Cintiq 13HD Pro Pen */
669 case 0x18802: /* DTH2242 Pen */
670 case 0x10802: /* Intuos4/5 13HD/24HD General Pen */
671 tool_type = BTN_TOOL_PEN;
674 case 0x832: /* Stroke pen */
676 tool_type = BTN_TOOL_BRUSH;
679 case 0x007: /* Mouse 4D and 2D */
682 case 0x017: /* Intuos3 2D Mouse */
683 case 0x806: /* Intuos4 Mouse */
684 tool_type = BTN_TOOL_MOUSE;
687 case 0x096: /* Lens cursor */
688 case 0x097: /* Intuos3 Lens cursor */
689 case 0x006: /* Intuos4 Lens cursor */
690 tool_type = BTN_TOOL_LENS;
693 case 0x82a: /* Eraser */
699 case 0x82b: /* Intuos3 Grip Pen Eraser */
700 case 0x81b: /* Intuos3 Classic Pen Eraser */
701 case 0x91b: /* Intuos3 Airbrush Eraser */
702 case 0x80c: /* Intuos4/5 13HD/24HD Marker Pen Eraser */
703 case 0x80a: /* Intuos4/5 13HD/24HD General Pen Eraser */
704 case 0x90a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
705 case 0x1480a: /* Intuos4/5 13HD/24HD Classic Pen Eraser */
706 case 0x1090a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
707 case 0x1080c: /* Intuos4/5 13HD/24HD Art Pen Eraser */
708 case 0x1680a: /* Cintiq 13HD Pro Pen Eraser */
709 case 0x1880a: /* DTH2242 Eraser */
710 case 0x1080a: /* Intuos4/5 13HD/24HD General Pen Eraser */
711 tool_type = BTN_TOOL_RUBBER;
717 case 0x913: /* Intuos3 Airbrush */
718 case 0x902: /* Intuos4/5 13HD/24HD Airbrush */
719 case 0x10902: /* Intuos4/5 13HD/24HD Airbrush */
720 tool_type = BTN_TOOL_AIRBRUSH;
723 default: /* Unknown tool */
724 tool_type = BTN_TOOL_PEN;
730 static void wacom_exit_report(struct wacom_wac *wacom)
732 struct input_dev *input = wacom->pen_input;
733 struct wacom_features *features = &wacom->features;
734 unsigned char *data = wacom->data;
735 int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
738 * Reset all states otherwise we lose the initial states
739 * when in-prox next time
741 input_report_abs(input, ABS_X, 0);
742 input_report_abs(input, ABS_Y, 0);
743 input_report_abs(input, ABS_DISTANCE, 0);
744 input_report_abs(input, ABS_TILT_X, 0);
745 input_report_abs(input, ABS_TILT_Y, 0);
746 if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
747 input_report_key(input, BTN_LEFT, 0);
748 input_report_key(input, BTN_MIDDLE, 0);
749 input_report_key(input, BTN_RIGHT, 0);
750 input_report_key(input, BTN_SIDE, 0);
751 input_report_key(input, BTN_EXTRA, 0);
752 input_report_abs(input, ABS_THROTTLE, 0);
753 input_report_abs(input, ABS_RZ, 0);
755 input_report_abs(input, ABS_PRESSURE, 0);
756 input_report_key(input, BTN_STYLUS, 0);
757 input_report_key(input, BTN_STYLUS2, 0);
758 input_report_key(input, BTN_TOUCH, 0);
759 input_report_abs(input, ABS_WHEEL, 0);
760 if (features->type >= INTUOS3S)
761 input_report_abs(input, ABS_Z, 0);
763 input_report_key(input, wacom->tool[idx], 0);
764 input_report_abs(input, ABS_MISC, 0); /* reset tool id */
765 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
769 static int wacom_intuos_inout(struct wacom_wac *wacom)
771 struct wacom_features *features = &wacom->features;
772 unsigned char *data = wacom->data;
773 struct input_dev *input = wacom->pen_input;
774 int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
776 if (!(((data[1] & 0xfc) == 0xc0) || /* in prox */
777 ((data[1] & 0xfe) == 0x20) || /* in range */
778 ((data[1] & 0xfe) == 0x80))) /* out prox */
782 if ((data[1] & 0xfc) == 0xc0) {
783 /* serial number of the tool */
784 wacom->serial[idx] = ((__u64)(data[3] & 0x0f) << 28) +
785 (data[4] << 20) + (data[5] << 12) +
786 (data[6] << 4) + (data[7] >> 4);
788 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) |
789 ((data[7] & 0x0f) << 16) | ((data[8] & 0xf0) << 8);
791 wacom->tool[idx] = wacom_intuos_get_tool_type(wacom->id[idx]);
793 wacom->shared->stylus_in_proximity = true;
798 if ((data[1] & 0xfe) == 0x20) {
799 if (features->type != INTUOSHT2)
800 wacom->shared->stylus_in_proximity = true;
802 /* in Range while exiting */
803 if (wacom->reporting_data) {
804 input_report_key(input, BTN_TOUCH, 0);
805 input_report_abs(input, ABS_PRESSURE, 0);
806 input_report_abs(input, ABS_DISTANCE, wacom->features.distance_max);
813 if ((data[1] & 0xfe) == 0x80) {
814 wacom->shared->stylus_in_proximity = false;
815 wacom->reporting_data = false;
817 /* don't report exit if we don't know the ID */
821 wacom_exit_report(wacom);
828 static inline bool report_touch_events(struct wacom_wac *wacom)
830 return (touch_arbitration ? !wacom->shared->stylus_in_proximity : 1);
833 static inline bool delay_pen_events(struct wacom_wac *wacom)
835 return (wacom->shared->touch_down && touch_arbitration);
838 static int wacom_intuos_general(struct wacom_wac *wacom)
840 struct wacom_features *features = &wacom->features;
841 unsigned char *data = wacom->data;
842 struct input_dev *input = wacom->pen_input;
843 int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
844 unsigned char type = (data[1] >> 1) & 0x0F;
845 unsigned int x, y, distance, t;
847 if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_CINTIQ &&
848 data[0] != WACOM_REPORT_INTUOS_PEN)
851 if (delay_pen_events(wacom))
854 /* don't report events if we don't know the tool ID */
855 if (!wacom->id[idx]) {
856 /* but reschedule a read of the current tool */
857 wacom_intuos_schedule_prox_event(wacom);
862 * don't report events for invalid data
864 /* older I4 styli don't work with new Cintiqs */
865 if ((!((wacom->id[idx] >> 16) & 0x01) &&
866 (features->type == WACOM_21UX2)) ||
867 /* Only large Intuos support Lense Cursor */
868 (wacom->tool[idx] == BTN_TOOL_LENS &&
869 (features->type == INTUOS3 ||
870 features->type == INTUOS3S ||
871 features->type == INTUOS4 ||
872 features->type == INTUOS4S ||
873 features->type == INTUOS5 ||
874 features->type == INTUOS5S ||
875 features->type == INTUOSPM ||
876 features->type == INTUOSPS)) ||
877 /* Cintiq doesn't send data when RDY bit isn't set */
878 (features->type == CINTIQ && !(data[1] & 0x40)))
881 x = (be16_to_cpup((__be16 *)&data[2]) << 1) | ((data[9] >> 1) & 1);
882 y = (be16_to_cpup((__be16 *)&data[4]) << 1) | (data[9] & 1);
883 distance = data[9] >> 2;
884 if (features->type < INTUOS3S) {
889 if (features->type == INTUOSHT2)
890 distance = features->distance_max - distance;
891 input_report_abs(input, ABS_X, x);
892 input_report_abs(input, ABS_Y, y);
893 input_report_abs(input, ABS_DISTANCE, distance);
900 /* general pen packet */
901 t = (data[6] << 3) | ((data[7] & 0xC0) >> 5) | (data[1] & 1);
902 if (features->pressure_max < 2047)
904 input_report_abs(input, ABS_PRESSURE, t);
905 if (features->type != INTUOSHT2) {
906 input_report_abs(input, ABS_TILT_X,
907 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
908 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
910 input_report_key(input, BTN_STYLUS, data[1] & 2);
911 input_report_key(input, BTN_STYLUS2, data[1] & 4);
912 input_report_key(input, BTN_TOUCH, t > 10);
916 /* airbrush second packet */
917 input_report_abs(input, ABS_WHEEL,
918 (data[6] << 2) | ((data[7] >> 6) & 3));
919 input_report_abs(input, ABS_TILT_X,
920 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
921 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
925 /* Rotation packet */
926 if (features->type >= INTUOS3S) {
927 /* I3 marker pen rotation */
928 t = (data[6] << 3) | ((data[7] >> 5) & 7);
929 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
930 ((t-1) / 2 + 450)) : (450 - t / 2) ;
931 input_report_abs(input, ABS_Z, t);
933 /* 4D mouse 2nd packet */
934 t = (data[6] << 3) | ((data[7] >> 5) & 7);
935 input_report_abs(input, ABS_RZ, (data[7] & 0x20) ?
936 ((t - 1) / 2) : -t / 2);
941 /* 4D mouse 1st packet */
942 input_report_key(input, BTN_LEFT, data[8] & 0x01);
943 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
944 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
946 input_report_key(input, BTN_SIDE, data[8] & 0x20);
947 input_report_key(input, BTN_EXTRA, data[8] & 0x10);
948 t = (data[6] << 2) | ((data[7] >> 6) & 3);
949 input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
954 input_report_key(input, BTN_LEFT, data[6] & 0x01);
955 input_report_key(input, BTN_MIDDLE, data[6] & 0x02);
956 input_report_key(input, BTN_RIGHT, data[6] & 0x04);
957 input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7)
958 - ((data[7] & 0x40) >> 6));
959 input_report_key(input, BTN_SIDE, data[6] & 0x08);
960 input_report_key(input, BTN_EXTRA, data[6] & 0x10);
962 input_report_abs(input, ABS_TILT_X,
963 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
964 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
968 if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
969 /* 2D mouse packet */
970 input_report_key(input, BTN_LEFT, data[8] & 0x04);
971 input_report_key(input, BTN_MIDDLE, data[8] & 0x08);
972 input_report_key(input, BTN_RIGHT, data[8] & 0x10);
973 input_report_rel(input, REL_WHEEL, (data[8] & 0x01)
974 - ((data[8] & 0x02) >> 1));
976 /* I3 2D mouse side buttons */
977 if (features->type >= INTUOS3S && features->type <= INTUOS3L) {
978 input_report_key(input, BTN_SIDE, data[8] & 0x40);
979 input_report_key(input, BTN_EXTRA, data[8] & 0x20);
982 else if (wacom->tool[idx] == BTN_TOOL_LENS) {
983 /* Lens cursor packets */
984 input_report_key(input, BTN_LEFT, data[8] & 0x01);
985 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
986 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
987 input_report_key(input, BTN_SIDE, data[8] & 0x10);
988 input_report_key(input, BTN_EXTRA, data[8] & 0x08);
1003 input_report_abs(input, ABS_MISC,
1004 wacom_intuos_id_mangle(wacom->id[idx])); /* report tool id */
1005 input_report_key(input, wacom->tool[idx], 1);
1006 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
1007 wacom->reporting_data = true;
1011 static int wacom_intuos_irq(struct wacom_wac *wacom)
1013 unsigned char *data = wacom->data;
1014 struct input_dev *input = wacom->pen_input;
1017 if (data[0] != WACOM_REPORT_PENABLED &&
1018 data[0] != WACOM_REPORT_INTUOS_ID1 &&
1019 data[0] != WACOM_REPORT_INTUOS_ID2 &&
1020 data[0] != WACOM_REPORT_INTUOSPAD &&
1021 data[0] != WACOM_REPORT_INTUOS_PEN &&
1022 data[0] != WACOM_REPORT_CINTIQ &&
1023 data[0] != WACOM_REPORT_CINTIQPAD &&
1024 data[0] != WACOM_REPORT_INTUOS5PAD) {
1025 dev_dbg(input->dev.parent,
1026 "%s: received unknown report #%d\n", __func__, data[0]);
1030 /* process pad events */
1031 result = wacom_intuos_pad(wacom);
1035 /* process in/out prox events */
1036 result = wacom_intuos_inout(wacom);
1040 /* process general packets */
1041 result = wacom_intuos_general(wacom);
1048 static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len)
1050 unsigned char *data = wacom_wac->data;
1051 struct input_dev *input;
1052 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
1053 struct wacom_remote *remote = wacom->remote;
1054 int bat_charging, bat_percent, touch_ring_mode;
1057 unsigned long flags;
1059 if (data[0] != WACOM_REPORT_REMOTE) {
1060 hid_dbg(wacom->hdev, "%s: received unknown report #%d",
1065 serial = data[3] + (data[4] << 8) + (data[5] << 16);
1066 wacom_wac->id[0] = PAD_DEVICE_ID;
1068 spin_lock_irqsave(&remote->remote_lock, flags);
1070 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
1071 if (remote->remotes[i].serial == serial) {
1077 if (index < 0 || !remote->remotes[index].registered)
1080 remote->remotes[i].active_time = ktime_get();
1081 input = remote->remotes[index].input;
1083 input_report_key(input, BTN_0, (data[9] & 0x01));
1084 input_report_key(input, BTN_1, (data[9] & 0x02));
1085 input_report_key(input, BTN_2, (data[9] & 0x04));
1086 input_report_key(input, BTN_3, (data[9] & 0x08));
1087 input_report_key(input, BTN_4, (data[9] & 0x10));
1088 input_report_key(input, BTN_5, (data[9] & 0x20));
1089 input_report_key(input, BTN_6, (data[9] & 0x40));
1090 input_report_key(input, BTN_7, (data[9] & 0x80));
1092 input_report_key(input, BTN_8, (data[10] & 0x01));
1093 input_report_key(input, BTN_9, (data[10] & 0x02));
1094 input_report_key(input, BTN_A, (data[10] & 0x04));
1095 input_report_key(input, BTN_B, (data[10] & 0x08));
1096 input_report_key(input, BTN_C, (data[10] & 0x10));
1097 input_report_key(input, BTN_X, (data[10] & 0x20));
1098 input_report_key(input, BTN_Y, (data[10] & 0x40));
1099 input_report_key(input, BTN_Z, (data[10] & 0x80));
1101 input_report_key(input, BTN_BASE, (data[11] & 0x01));
1102 input_report_key(input, BTN_BASE2, (data[11] & 0x02));
1104 if (data[12] & 0x80)
1105 input_report_abs(input, ABS_WHEEL, (data[12] & 0x7f) - 1);
1107 input_report_abs(input, ABS_WHEEL, 0);
1109 bat_percent = data[7] & 0x7f;
1110 bat_charging = !!(data[7] & 0x80);
1112 if (data[9] | data[10] | (data[11] & 0x03) | data[12])
1113 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
1115 input_report_abs(input, ABS_MISC, 0);
1117 input_event(input, EV_MSC, MSC_SERIAL, serial);
1121 /*Which mode select (LED light) is currently on?*/
1122 touch_ring_mode = (data[11] & 0xC0) >> 6;
1124 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
1125 if (remote->remotes[i].serial == serial)
1126 wacom->led.groups[i].select = touch_ring_mode;
1129 __wacom_notify_battery(&remote->remotes[index].battery,
1130 WACOM_POWER_SUPPLY_STATUS_AUTO, bat_percent,
1131 bat_charging, 1, bat_charging);
1134 spin_unlock_irqrestore(&remote->remote_lock, flags);
1138 static void wacom_remote_status_irq(struct wacom_wac *wacom_wac, size_t len)
1140 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
1141 unsigned char *data = wacom_wac->data;
1142 struct wacom_remote *remote = wacom->remote;
1143 struct wacom_remote_data remote_data;
1144 unsigned long flags;
1147 if (data[0] != WACOM_REPORT_DEVICE_LIST)
1150 memset(&remote_data, 0, sizeof(struct wacom_remote_data));
1152 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
1154 int serial = (data[j+6] << 16) + (data[j+5] << 8) + data[j+4];
1155 bool connected = data[j+2];
1157 remote_data.remote[i].serial = serial;
1158 remote_data.remote[i].connected = connected;
1161 spin_lock_irqsave(&remote->remote_lock, flags);
1163 ret = kfifo_in(&remote->remote_fifo, &remote_data, sizeof(remote_data));
1164 if (ret != sizeof(remote_data)) {
1165 spin_unlock_irqrestore(&remote->remote_lock, flags);
1166 hid_err(wacom->hdev, "Can't queue Remote status event.\n");
1170 spin_unlock_irqrestore(&remote->remote_lock, flags);
1172 wacom_schedule_work(wacom_wac, WACOM_WORKER_REMOTE);
1175 static int int_dist(int x1, int y1, int x2, int y2)
1180 return int_sqrt(x*x + y*y);
1183 static void wacom_intuos_bt_process_data(struct wacom_wac *wacom,
1184 unsigned char *data)
1186 memcpy(wacom->data, data, 10);
1187 wacom_intuos_irq(wacom);
1189 input_sync(wacom->pen_input);
1190 if (wacom->pad_input)
1191 input_sync(wacom->pad_input);
1194 static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
1196 unsigned char data[WACOM_PKGLEN_MAX];
1198 unsigned power_raw, battery_capacity, bat_charging, ps_connected;
1200 memcpy(data, wacom->data, len);
1204 wacom_intuos_bt_process_data(wacom, data + i);
1208 wacom_intuos_bt_process_data(wacom, data + i);
1210 wacom_intuos_bt_process_data(wacom, data + i);
1212 power_raw = data[i];
1213 bat_charging = (power_raw & 0x08) ? 1 : 0;
1214 ps_connected = (power_raw & 0x10) ? 1 : 0;
1215 battery_capacity = batcap_i4[power_raw & 0x07];
1216 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
1217 battery_capacity, bat_charging,
1218 battery_capacity || bat_charging,
1222 dev_dbg(wacom->pen_input->dev.parent,
1223 "Unknown report: %d,%d size:%zu\n",
1224 data[0], data[1], len);
1230 static int wacom_wac_finger_count_touches(struct wacom_wac *wacom)
1232 struct input_dev *input = wacom->touch_input;
1233 unsigned touch_max = wacom->features.touch_max;
1241 return test_bit(BTN_TOUCH, input->key) &&
1242 report_touch_events(wacom);
1244 for (i = 0; i < input->mt->num_slots; i++) {
1245 struct input_mt_slot *ps = &input->mt->slots[i];
1246 int id = input_mt_get_value(ps, ABS_MT_TRACKING_ID);
1254 static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
1256 int pen_frame_len, pen_frames;
1258 struct input_dev *pen_input = wacom->pen_input;
1259 unsigned char *data = wacom->data;
1262 if (wacom->features.type == INTUOSP2_BT) {
1263 wacom->serial[0] = get_unaligned_le64(&data[99]);
1264 wacom->id[0] = get_unaligned_le16(&data[107]);
1268 wacom->serial[0] = get_unaligned_le64(&data[33]);
1269 wacom->id[0] = get_unaligned_le16(&data[41]);
1274 if (wacom->serial[0] >> 52 == 1) {
1275 /* Add back in missing bits of ID for non-USI pens */
1276 wacom->id[0] |= (wacom->serial[0] >> 32) & 0xFFFFF;
1279 for (i = 0; i < pen_frames; i++) {
1280 unsigned char *frame = &data[i*pen_frame_len + 1];
1281 bool valid = frame[0] & 0x80;
1282 bool prox = frame[0] & 0x40;
1283 bool range = frame[0] & 0x20;
1284 bool invert = frame[0] & 0x10;
1290 wacom->shared->stylus_in_proximity = false;
1291 wacom_exit_report(wacom);
1292 input_sync(pen_input);
1296 wacom->serial[0] = 0;
1301 if (!wacom->tool[0]) { /* first in range */
1302 /* Going into range select tool */
1304 wacom->tool[0] = BTN_TOOL_RUBBER;
1305 else if (wacom->id[0])
1306 wacom->tool[0] = wacom_intuos_get_tool_type(wacom->id[0]);
1308 wacom->tool[0] = BTN_TOOL_PEN;
1311 input_report_abs(pen_input, ABS_X, get_unaligned_le16(&frame[1]));
1312 input_report_abs(pen_input, ABS_Y, get_unaligned_le16(&frame[3]));
1314 if (wacom->features.type == INTUOSP2_BT) {
1315 /* Fix rotation alignment: userspace expects zero at left */
1317 (int16_t)get_unaligned_le16(&frame[9]);
1323 input_report_abs(pen_input, ABS_TILT_X,
1325 input_report_abs(pen_input, ABS_TILT_Y,
1327 input_report_abs(pen_input, ABS_Z, rotation);
1328 input_report_abs(pen_input, ABS_WHEEL,
1329 get_unaligned_le16(&frame[11]));
1333 if (wacom->tool[0]) {
1334 input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5]));
1335 if (wacom->features.type == INTUOSP2_BT) {
1336 input_report_abs(pen_input, ABS_DISTANCE,
1337 range ? frame[13] : wacom->features.distance_max);
1339 input_report_abs(pen_input, ABS_DISTANCE,
1340 range ? frame[7] : wacom->features.distance_max);
1343 input_report_key(pen_input, BTN_TOUCH, frame[0] & 0x09);
1344 input_report_key(pen_input, BTN_STYLUS, frame[0] & 0x02);
1345 input_report_key(pen_input, BTN_STYLUS2, frame[0] & 0x04);
1347 input_report_key(pen_input, wacom->tool[0], prox);
1348 input_event(pen_input, EV_MSC, MSC_SERIAL, wacom->serial[0]);
1349 input_report_abs(pen_input, ABS_MISC,
1350 wacom_intuos_id_mangle(wacom->id[0])); /* report tool id */
1353 wacom->shared->stylus_in_proximity = prox;
1355 input_sync(pen_input);
1359 static void wacom_intuos_pro2_bt_touch(struct wacom_wac *wacom)
1361 const int finger_touch_len = 8;
1362 const int finger_frames = 4;
1363 const int finger_frame_len = 43;
1365 struct input_dev *touch_input = wacom->touch_input;
1366 unsigned char *data = wacom->data;
1367 int num_contacts_left = 5;
1370 for (i = 0; i < finger_frames; i++) {
1371 unsigned char *frame = &data[i*finger_frame_len + 109];
1372 int current_num_contacts = frame[0] & 0x7F;
1373 int contacts_to_send;
1375 if (!(frame[0] & 0x80))
1379 * First packet resets the counter since only the first
1380 * packet in series will have non-zero current_num_contacts.
1382 if (current_num_contacts)
1383 wacom->num_contacts_left = current_num_contacts;
1385 contacts_to_send = min(num_contacts_left, wacom->num_contacts_left);
1387 for (j = 0; j < contacts_to_send; j++) {
1388 unsigned char *touch = &frame[j*finger_touch_len + 1];
1389 int slot = input_mt_get_slot_by_key(touch_input, touch[0]);
1390 int x = get_unaligned_le16(&touch[2]);
1391 int y = get_unaligned_le16(&touch[4]);
1392 int w = touch[6] * input_abs_get_res(touch_input, ABS_MT_POSITION_X);
1393 int h = touch[7] * input_abs_get_res(touch_input, ABS_MT_POSITION_Y);
1398 input_mt_slot(touch_input, slot);
1399 input_mt_report_slot_state(touch_input, MT_TOOL_FINGER, touch[1] & 0x01);
1400 input_report_abs(touch_input, ABS_MT_POSITION_X, x);
1401 input_report_abs(touch_input, ABS_MT_POSITION_Y, y);
1402 input_report_abs(touch_input, ABS_MT_TOUCH_MAJOR, max(w, h));
1403 input_report_abs(touch_input, ABS_MT_TOUCH_MINOR, min(w, h));
1404 input_report_abs(touch_input, ABS_MT_ORIENTATION, w > h);
1407 input_mt_sync_frame(touch_input);
1409 wacom->num_contacts_left -= contacts_to_send;
1410 if (wacom->num_contacts_left <= 0) {
1411 wacom->num_contacts_left = 0;
1412 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1413 input_sync(touch_input);
1417 if (wacom->num_contacts_left == 0) {
1418 // Be careful that we don't accidentally call input_sync with
1419 // only a partial set of fingers of processed
1420 input_report_switch(touch_input, SW_MUTE_DEVICE, !(data[281] >> 7));
1421 input_sync(touch_input);
1426 static void wacom_intuos_pro2_bt_pad(struct wacom_wac *wacom)
1428 struct input_dev *pad_input = wacom->pad_input;
1429 unsigned char *data = wacom->data;
1431 int buttons = data[282] | ((data[281] & 0x40) << 2);
1432 int ring = data[285] & 0x7F;
1433 bool ringstatus = data[285] & 0x80;
1434 bool prox = buttons || ringstatus;
1436 /* Fix touchring data: userspace expects 0 at left and increasing clockwise */
1442 wacom_report_numbered_buttons(pad_input, 9, buttons);
1444 input_report_abs(pad_input, ABS_WHEEL, ringstatus ? ring : 0);
1446 input_report_key(pad_input, wacom->tool[1], prox ? 1 : 0);
1447 input_report_abs(pad_input, ABS_MISC, prox ? PAD_DEVICE_ID : 0);
1448 input_event(pad_input, EV_MSC, MSC_SERIAL, 0xffffffff);
1450 input_sync(pad_input);
1453 static void wacom_intuos_pro2_bt_battery(struct wacom_wac *wacom)
1455 unsigned char *data = wacom->data;
1457 bool chg = data[284] & 0x80;
1458 int battery_status = data[284] & 0x7F;
1460 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
1461 battery_status, chg, 1, chg);
1464 static void wacom_intuos_gen3_bt_pad(struct wacom_wac *wacom)
1466 struct input_dev *pad_input = wacom->pad_input;
1467 unsigned char *data = wacom->data;
1469 int buttons = data[44];
1471 wacom_report_numbered_buttons(pad_input, 4, buttons);
1473 input_report_key(pad_input, wacom->tool[1], buttons ? 1 : 0);
1474 input_report_abs(pad_input, ABS_MISC, buttons ? PAD_DEVICE_ID : 0);
1475 input_event(pad_input, EV_MSC, MSC_SERIAL, 0xffffffff);
1477 input_sync(pad_input);
1480 static void wacom_intuos_gen3_bt_battery(struct wacom_wac *wacom)
1482 unsigned char *data = wacom->data;
1484 bool chg = data[45] & 0x80;
1485 int battery_status = data[45] & 0x7F;
1487 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
1488 battery_status, chg, 1, chg);
1491 static int wacom_intuos_pro2_bt_irq(struct wacom_wac *wacom, size_t len)
1493 unsigned char *data = wacom->data;
1495 if (data[0] != 0x80 && data[0] != 0x81) {
1496 dev_dbg(wacom->pen_input->dev.parent,
1497 "%s: received unknown report #%d\n", __func__, data[0]);
1501 wacom_intuos_pro2_bt_pen(wacom);
1502 if (wacom->features.type == INTUOSP2_BT) {
1503 wacom_intuos_pro2_bt_touch(wacom);
1504 wacom_intuos_pro2_bt_pad(wacom);
1505 wacom_intuos_pro2_bt_battery(wacom);
1507 wacom_intuos_gen3_bt_pad(wacom);
1508 wacom_intuos_gen3_bt_battery(wacom);
1513 static int wacom_24hdt_irq(struct wacom_wac *wacom)
1515 struct input_dev *input = wacom->touch_input;
1516 unsigned char *data = wacom->data;
1518 int current_num_contacts = data[61];
1519 int contacts_to_send = 0;
1520 int num_contacts_left = 4; /* maximum contacts per packet */
1521 int byte_per_packet = WACOM_BYTES_PER_24HDT_PACKET;
1524 if (wacom->features.type == WACOM_27QHDT) {
1525 current_num_contacts = data[63];
1526 num_contacts_left = 10;
1527 byte_per_packet = WACOM_BYTES_PER_QHDTHID_PACKET;
1532 * First packet resets the counter since only the first
1533 * packet in series will have non-zero current_num_contacts.
1535 if (current_num_contacts)
1536 wacom->num_contacts_left = current_num_contacts;
1538 contacts_to_send = min(num_contacts_left, wacom->num_contacts_left);
1540 for (i = 0; i < contacts_to_send; i++) {
1541 int offset = (byte_per_packet * i) + 1;
1542 bool touch = (data[offset] & 0x1) && report_touch_events(wacom);
1543 int slot = input_mt_get_slot_by_key(input, data[offset + 1]);
1547 input_mt_slot(input, slot);
1548 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1551 int t_x = get_unaligned_le16(&data[offset + 2]);
1552 int t_y = get_unaligned_le16(&data[offset + 4 + y_offset]);
1554 input_report_abs(input, ABS_MT_POSITION_X, t_x);
1555 input_report_abs(input, ABS_MT_POSITION_Y, t_y);
1557 if (wacom->features.type != WACOM_27QHDT) {
1558 int c_x = get_unaligned_le16(&data[offset + 4]);
1559 int c_y = get_unaligned_le16(&data[offset + 8]);
1560 int w = get_unaligned_le16(&data[offset + 10]);
1561 int h = get_unaligned_le16(&data[offset + 12]);
1563 input_report_abs(input, ABS_MT_TOUCH_MAJOR, min(w,h));
1564 input_report_abs(input, ABS_MT_WIDTH_MAJOR,
1565 min(w, h) + int_dist(t_x, t_y, c_x, c_y));
1566 input_report_abs(input, ABS_MT_WIDTH_MINOR, min(w, h));
1567 input_report_abs(input, ABS_MT_ORIENTATION, w > h);
1571 input_mt_sync_frame(input);
1573 wacom->num_contacts_left -= contacts_to_send;
1574 if (wacom->num_contacts_left <= 0) {
1575 wacom->num_contacts_left = 0;
1576 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1581 static int wacom_mt_touch(struct wacom_wac *wacom)
1583 struct input_dev *input = wacom->touch_input;
1584 unsigned char *data = wacom->data;
1586 int current_num_contacts = data[2];
1587 int contacts_to_send = 0;
1590 /* MTTPC does not support Height and Width */
1591 if (wacom->features.type == MTTPC || wacom->features.type == MTTPC_B)
1595 * First packet resets the counter since only the first
1596 * packet in series will have non-zero current_num_contacts.
1598 if (current_num_contacts)
1599 wacom->num_contacts_left = current_num_contacts;
1601 /* There are at most 5 contacts per packet */
1602 contacts_to_send = min(5, wacom->num_contacts_left);
1604 for (i = 0; i < contacts_to_send; i++) {
1605 int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset) * i + 3;
1606 bool touch = (data[offset] & 0x1) && report_touch_events(wacom);
1607 int id = get_unaligned_le16(&data[offset + 1]);
1608 int slot = input_mt_get_slot_by_key(input, id);
1613 input_mt_slot(input, slot);
1614 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1616 int x = get_unaligned_le16(&data[offset + x_offset + 7]);
1617 int y = get_unaligned_le16(&data[offset + x_offset + 9]);
1618 input_report_abs(input, ABS_MT_POSITION_X, x);
1619 input_report_abs(input, ABS_MT_POSITION_Y, y);
1622 input_mt_sync_frame(input);
1624 wacom->num_contacts_left -= contacts_to_send;
1625 if (wacom->num_contacts_left <= 0) {
1626 wacom->num_contacts_left = 0;
1627 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1632 static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
1634 struct input_dev *input = wacom->touch_input;
1635 unsigned char *data = wacom->data;
1638 for (i = 0; i < 2; i++) {
1639 int p = data[1] & (1 << i);
1640 bool touch = p && report_touch_events(wacom);
1642 input_mt_slot(input, i);
1643 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1645 int x = le16_to_cpup((__le16 *)&data[i * 2 + 2]) & 0x7fff;
1646 int y = le16_to_cpup((__le16 *)&data[i * 2 + 6]) & 0x7fff;
1648 input_report_abs(input, ABS_MT_POSITION_X, x);
1649 input_report_abs(input, ABS_MT_POSITION_Y, y);
1652 input_mt_sync_frame(input);
1654 /* keep touch state for pen event */
1655 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1660 static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
1662 unsigned char *data = wacom->data;
1663 struct input_dev *input = wacom->touch_input;
1664 bool prox = report_touch_events(wacom);
1667 if (wacom->features.touch_max > 1 || len > WACOM_PKGLEN_TPC2FG)
1670 if (len == WACOM_PKGLEN_TPC1FG) {
1671 prox = prox && (data[0] & 0x01);
1672 x = get_unaligned_le16(&data[1]);
1673 y = get_unaligned_le16(&data[3]);
1674 } else if (len == WACOM_PKGLEN_TPC1FG_B) {
1675 prox = prox && (data[2] & 0x01);
1676 x = get_unaligned_le16(&data[3]);
1677 y = get_unaligned_le16(&data[5]);
1679 prox = prox && (data[1] & 0x01);
1680 x = le16_to_cpup((__le16 *)&data[2]);
1681 y = le16_to_cpup((__le16 *)&data[4]);
1685 input_report_abs(input, ABS_X, x);
1686 input_report_abs(input, ABS_Y, y);
1688 input_report_key(input, BTN_TOUCH, prox);
1690 /* keep touch state for pen events */
1691 wacom->shared->touch_down = prox;
1696 static int wacom_tpc_pen(struct wacom_wac *wacom)
1698 unsigned char *data = wacom->data;
1699 struct input_dev *input = wacom->pen_input;
1700 bool prox = data[1] & 0x20;
1702 if (!wacom->shared->stylus_in_proximity) /* first in prox */
1703 /* Going into proximity select tool */
1704 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
1706 /* keep pen state for touch events */
1707 wacom->shared->stylus_in_proximity = prox;
1709 /* send pen events only when touch is up or forced out
1710 * or touch arbitration is off
1712 if (!delay_pen_events(wacom)) {
1713 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
1714 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
1715 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
1716 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
1717 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x07) << 8) | data[6]);
1718 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
1719 input_report_key(input, wacom->tool[0], prox);
1726 static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
1728 unsigned char *data = wacom->data;
1730 if (wacom->pen_input) {
1731 dev_dbg(wacom->pen_input->dev.parent,
1732 "%s: received report #%d\n", __func__, data[0]);
1734 if (len == WACOM_PKGLEN_PENABLED ||
1735 data[0] == WACOM_REPORT_PENABLED)
1736 return wacom_tpc_pen(wacom);
1738 else if (wacom->touch_input) {
1739 dev_dbg(wacom->touch_input->dev.parent,
1740 "%s: received report #%d\n", __func__, data[0]);
1743 case WACOM_PKGLEN_TPC1FG:
1744 return wacom_tpc_single_touch(wacom, len);
1746 case WACOM_PKGLEN_TPC2FG:
1747 return wacom_tpc_mt_touch(wacom);
1751 case WACOM_REPORT_TPC1FG:
1752 case WACOM_REPORT_TPCHID:
1753 case WACOM_REPORT_TPCST:
1754 case WACOM_REPORT_TPC1FGE:
1755 return wacom_tpc_single_touch(wacom, len);
1757 case WACOM_REPORT_TPCMT:
1758 case WACOM_REPORT_TPCMT2:
1759 return wacom_mt_touch(wacom);
1768 static int wacom_offset_rotation(struct input_dev *input, struct hid_usage *usage,
1769 int value, int num, int denom)
1771 struct input_absinfo *abs = &input->absinfo[usage->code];
1772 int range = (abs->maximum - abs->minimum + 1);
1774 value += num*range/denom;
1775 if (value > abs->maximum)
1777 else if (value < abs->minimum)
1782 int wacom_equivalent_usage(int usage)
1784 if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMDIGITIZER) {
1785 int subpage = (usage & 0xFF00) << 8;
1786 int subusage = (usage & 0xFF);
1788 if (subpage == WACOM_HID_SP_PAD ||
1789 subpage == WACOM_HID_SP_BUTTON ||
1790 subpage == WACOM_HID_SP_DIGITIZER ||
1791 subpage == WACOM_HID_SP_DIGITIZERINFO ||
1792 usage == WACOM_HID_WD_SENSE ||
1793 usage == WACOM_HID_WD_SERIALHI ||
1794 usage == WACOM_HID_WD_TOOLTYPE ||
1795 usage == WACOM_HID_WD_DISTANCE ||
1796 usage == WACOM_HID_WD_TOUCHSTRIP ||
1797 usage == WACOM_HID_WD_TOUCHSTRIP2 ||
1798 usage == WACOM_HID_WD_TOUCHRING ||
1799 usage == WACOM_HID_WD_TOUCHRINGSTATUS ||
1800 usage == WACOM_HID_WD_REPORT_VALID) {
1804 if (subpage == HID_UP_UNDEFINED)
1805 subpage = HID_UP_DIGITIZER;
1807 return subpage | subusage;
1810 if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMTOUCH) {
1811 int subpage = (usage & 0xFF00) << 8;
1812 int subusage = (usage & 0xFF);
1814 if (subpage == HID_UP_UNDEFINED)
1815 subpage = WACOM_HID_SP_DIGITIZER;
1817 return subpage | subusage;
1823 static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
1824 struct hid_field *field, __u8 type, __u16 code, int fuzz)
1826 struct wacom *wacom = input_get_drvdata(input);
1827 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1828 struct wacom_features *features = &wacom_wac->features;
1829 int fmin = field->logical_minimum;
1830 int fmax = field->logical_maximum;
1831 unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid);
1832 int resolution_code = code;
1833 int resolution = hidinput_calc_abs_res(field, resolution_code);
1835 if (equivalent_usage == HID_DG_TWIST) {
1836 resolution_code = ABS_RZ;
1839 if (equivalent_usage == HID_GD_X) {
1840 fmin += features->offset_left;
1841 fmax -= features->offset_right;
1843 if (equivalent_usage == HID_GD_Y) {
1844 fmin += features->offset_top;
1845 fmax -= features->offset_bottom;
1851 set_bit(type, input->evbit);
1855 input_set_abs_params(input, code, fmin, fmax, fuzz, 0);
1857 /* older tablet may miss physical usage */
1858 if ((code == ABS_X || code == ABS_Y) && !resolution) {
1859 resolution = WACOM_INTUOS_RES;
1861 "Wacom usage (%d) missing resolution \n",
1864 input_abs_set_res(input, code, resolution);
1867 input_set_capability(input, EV_KEY, code);
1870 input_set_capability(input, EV_MSC, code);
1873 input_set_capability(input, EV_SW, code);
1878 static void wacom_wac_battery_usage_mapping(struct hid_device *hdev,
1879 struct hid_field *field, struct hid_usage *usage)
1884 static void wacom_wac_battery_event(struct hid_device *hdev, struct hid_field *field,
1885 struct hid_usage *usage, __s32 value)
1887 struct wacom *wacom = hid_get_drvdata(hdev);
1888 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1889 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
1891 switch (equivalent_usage) {
1892 case HID_DG_BATTERYSTRENGTH:
1894 wacom_wac->hid_data.bat_status = POWER_SUPPLY_STATUS_UNKNOWN;
1897 value = value * 100 / (field->logical_maximum - field->logical_minimum);
1898 wacom_wac->hid_data.battery_capacity = value;
1899 wacom_wac->hid_data.bat_connected = 1;
1900 wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
1902 wacom_wac->features.quirks |= WACOM_QUIRK_BATTERY;
1904 case WACOM_HID_WD_BATTERY_LEVEL:
1905 value = value * 100 / (field->logical_maximum - field->logical_minimum);
1906 wacom_wac->hid_data.battery_capacity = value;
1907 wacom_wac->hid_data.bat_connected = 1;
1908 wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
1909 wacom_wac->features.quirks |= WACOM_QUIRK_BATTERY;
1911 case WACOM_HID_WD_BATTERY_CHARGING:
1912 wacom_wac->hid_data.bat_charging = value;
1913 wacom_wac->hid_data.ps_connected = value;
1914 wacom_wac->hid_data.bat_connected = 1;
1915 wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
1916 wacom_wac->features.quirks |= WACOM_QUIRK_BATTERY;
1921 static void wacom_wac_battery_pre_report(struct hid_device *hdev,
1922 struct hid_report *report)
1927 static void wacom_wac_battery_report(struct hid_device *hdev,
1928 struct hid_report *report)
1930 struct wacom *wacom = hid_get_drvdata(hdev);
1931 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1933 int status = wacom_wac->hid_data.bat_status;
1934 int capacity = wacom_wac->hid_data.battery_capacity;
1935 bool charging = wacom_wac->hid_data.bat_charging;
1936 bool connected = wacom_wac->hid_data.bat_connected;
1937 bool powered = wacom_wac->hid_data.ps_connected;
1939 wacom_notify_battery(wacom_wac, status, capacity, charging,
1940 connected, powered);
1943 static void wacom_wac_pad_usage_mapping(struct hid_device *hdev,
1944 struct hid_field *field, struct hid_usage *usage)
1946 struct wacom *wacom = hid_get_drvdata(hdev);
1947 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1948 struct wacom_features *features = &wacom_wac->features;
1949 struct input_dev *input = wacom_wac->pad_input;
1950 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
1952 switch (equivalent_usage) {
1953 case WACOM_HID_WD_ACCELEROMETER_X:
1954 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
1955 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 0);
1956 features->device_type |= WACOM_DEVICETYPE_PAD;
1958 case WACOM_HID_WD_ACCELEROMETER_Y:
1959 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
1960 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 0);
1961 features->device_type |= WACOM_DEVICETYPE_PAD;
1963 case WACOM_HID_WD_ACCELEROMETER_Z:
1964 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
1965 wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0);
1966 features->device_type |= WACOM_DEVICETYPE_PAD;
1968 case WACOM_HID_WD_BUTTONCENTER:
1969 case WACOM_HID_WD_BUTTONHOME:
1970 case WACOM_HID_WD_BUTTONUP:
1971 case WACOM_HID_WD_BUTTONDOWN:
1972 case WACOM_HID_WD_BUTTONLEFT:
1973 case WACOM_HID_WD_BUTTONRIGHT:
1974 wacom_map_usage(input, usage, field, EV_KEY,
1975 wacom_numbered_button_to_key(features->numbered_buttons),
1977 features->numbered_buttons++;
1978 features->device_type |= WACOM_DEVICETYPE_PAD;
1980 case WACOM_HID_WD_TOUCHONOFF:
1981 case WACOM_HID_WD_MUTE_DEVICE:
1983 * This usage, which is used to mute touch events, comes
1984 * from the pad packet, but is reported on the touch
1985 * interface. Because the touch interface may not have
1986 * been created yet, we cannot call wacom_map_usage(). In
1987 * order to process this usage when we receive it, we set
1988 * the usage type and code directly.
1990 wacom_wac->has_mute_touch_switch = true;
1991 usage->type = EV_SW;
1992 usage->code = SW_MUTE_DEVICE;
1994 case WACOM_HID_WD_TOUCHSTRIP:
1995 wacom_map_usage(input, usage, field, EV_ABS, ABS_RX, 0);
1996 features->device_type |= WACOM_DEVICETYPE_PAD;
1998 case WACOM_HID_WD_TOUCHSTRIP2:
1999 wacom_map_usage(input, usage, field, EV_ABS, ABS_RY, 0);
2000 features->device_type |= WACOM_DEVICETYPE_PAD;
2002 case WACOM_HID_WD_TOUCHRING:
2003 wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
2004 features->device_type |= WACOM_DEVICETYPE_PAD;
2006 case WACOM_HID_WD_TOUCHRINGSTATUS:
2008 * Only set up type/code association. Completely mapping
2009 * this usage may overwrite the axis resolution and range.
2011 usage->type = EV_ABS;
2012 usage->code = ABS_WHEEL;
2013 set_bit(EV_ABS, input->evbit);
2014 features->device_type |= WACOM_DEVICETYPE_PAD;
2016 case WACOM_HID_WD_BUTTONCONFIG:
2017 wacom_map_usage(input, usage, field, EV_KEY, KEY_BUTTONCONFIG, 0);
2018 features->device_type |= WACOM_DEVICETYPE_PAD;
2020 case WACOM_HID_WD_ONSCREEN_KEYBOARD:
2021 wacom_map_usage(input, usage, field, EV_KEY, KEY_ONSCREEN_KEYBOARD, 0);
2022 features->device_type |= WACOM_DEVICETYPE_PAD;
2024 case WACOM_HID_WD_CONTROLPANEL:
2025 wacom_map_usage(input, usage, field, EV_KEY, KEY_CONTROLPANEL, 0);
2026 features->device_type |= WACOM_DEVICETYPE_PAD;
2028 case WACOM_HID_WD_MODE_CHANGE:
2029 /* do not overwrite previous data */
2030 if (!wacom_wac->has_mode_change) {
2031 wacom_wac->has_mode_change = true;
2032 wacom_wac->is_direct_mode = true;
2034 features->device_type |= WACOM_DEVICETYPE_PAD;
2038 switch (equivalent_usage & 0xfffffff0) {
2039 case WACOM_HID_WD_EXPRESSKEY00:
2040 wacom_map_usage(input, usage, field, EV_KEY,
2041 wacom_numbered_button_to_key(features->numbered_buttons),
2043 features->numbered_buttons++;
2044 features->device_type |= WACOM_DEVICETYPE_PAD;
2049 static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field,
2050 struct hid_usage *usage, __s32 value)
2052 struct wacom *wacom = hid_get_drvdata(hdev);
2053 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2054 struct input_dev *input = wacom_wac->pad_input;
2055 struct wacom_features *features = &wacom_wac->features;
2056 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2058 bool do_report = false;
2061 * Avoid reporting this event and setting inrange_state if this usage
2062 * hasn't been mapped.
2064 if (!usage->type && equivalent_usage != WACOM_HID_WD_MODE_CHANGE)
2067 if (wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY) {
2068 if (usage->hid != WACOM_HID_WD_TOUCHRING)
2069 wacom_wac->hid_data.inrange_state |= value;
2072 /* Process touch switch state first since it is reported through touch interface,
2073 * which is indepentent of pad interface. In the case when there are no other pad
2074 * events, the pad interface will not even be created.
2076 if ((equivalent_usage == WACOM_HID_WD_MUTE_DEVICE) ||
2077 (equivalent_usage == WACOM_HID_WD_TOUCHONOFF)) {
2078 if (wacom_wac->shared->touch_input) {
2079 bool *is_touch_on = &wacom_wac->shared->is_touch_on;
2081 if (equivalent_usage == WACOM_HID_WD_MUTE_DEVICE && value)
2082 *is_touch_on = !(*is_touch_on);
2083 else if (equivalent_usage == WACOM_HID_WD_TOUCHONOFF)
2084 *is_touch_on = value;
2086 input_report_switch(wacom_wac->shared->touch_input,
2087 SW_MUTE_DEVICE, !(*is_touch_on));
2088 input_sync(wacom_wac->shared->touch_input);
2096 switch (equivalent_usage) {
2097 case WACOM_HID_WD_TOUCHRING:
2099 * Userspace expects touchrings to increase in value with
2100 * clockwise gestures and have their zero point at the
2101 * tablet's left. HID events "should" be clockwise-
2102 * increasing and zero at top, though the MobileStudio
2103 * Pro and 2nd-gen Intuos Pro don't do this...
2105 if (hdev->vendor == 0x56a &&
2106 (hdev->product == 0x34d || hdev->product == 0x34e || /* MobileStudio Pro */
2107 hdev->product == 0x357 || hdev->product == 0x358)) { /* Intuos Pro 2 */
2108 value = (field->logical_maximum - value);
2110 if (hdev->product == 0x357 || hdev->product == 0x358)
2111 value = wacom_offset_rotation(input, usage, value, 3, 16);
2112 else if (hdev->product == 0x34d || hdev->product == 0x34e)
2113 value = wacom_offset_rotation(input, usage, value, 1, 2);
2116 value = wacom_offset_rotation(input, usage, value, 1, 4);
2120 case WACOM_HID_WD_TOUCHRINGSTATUS:
2122 input_event(input, usage->type, usage->code, 0);
2125 case WACOM_HID_WD_MODE_CHANGE:
2126 if (wacom_wac->is_direct_mode != value) {
2127 wacom_wac->is_direct_mode = value;
2128 wacom_schedule_work(&wacom->wacom_wac, WACOM_WORKER_MODE_CHANGE);
2132 case WACOM_HID_WD_BUTTONCENTER:
2133 for (i = 0; i < wacom->led.count; i++)
2134 wacom_update_led(wacom, features->numbered_buttons,
2143 input_event(input, usage->type, usage->code, value);
2145 wacom_wac->hid_data.pad_input_event_flag = true;
2149 static void wacom_wac_pad_pre_report(struct hid_device *hdev,
2150 struct hid_report *report)
2152 struct wacom *wacom = hid_get_drvdata(hdev);
2153 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2155 wacom_wac->hid_data.inrange_state = 0;
2158 static void wacom_wac_pad_report(struct hid_device *hdev,
2159 struct hid_report *report, struct hid_field *field)
2161 struct wacom *wacom = hid_get_drvdata(hdev);
2162 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2163 struct input_dev *input = wacom_wac->pad_input;
2164 bool active = wacom_wac->hid_data.inrange_state != 0;
2166 /* report prox for expresskey events */
2167 if (wacom_wac->hid_data.pad_input_event_flag) {
2168 input_event(input, EV_ABS, ABS_MISC, active ? PAD_DEVICE_ID : 0);
2171 wacom_wac->hid_data.pad_input_event_flag = false;
2175 static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
2176 struct hid_field *field, struct hid_usage *usage)
2178 struct wacom *wacom = hid_get_drvdata(hdev);
2179 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2180 struct wacom_features *features = &wacom_wac->features;
2181 struct input_dev *input = wacom_wac->pen_input;
2182 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2184 switch (equivalent_usage) {
2186 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
2189 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
2191 case WACOM_HID_WD_DISTANCE:
2193 wacom_map_usage(input, usage, field, EV_ABS, ABS_DISTANCE, 0);
2195 case HID_DG_TIPPRESSURE:
2196 wacom_map_usage(input, usage, field, EV_ABS, ABS_PRESSURE, 0);
2198 case HID_DG_INRANGE:
2199 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
2202 wacom_map_usage(input, usage, field, EV_KEY,
2203 BTN_TOOL_RUBBER, 0);
2206 wacom_map_usage(input, usage, field, EV_ABS, ABS_TILT_X, 0);
2209 wacom_map_usage(input, usage, field, EV_ABS, ABS_TILT_Y, 0);
2212 wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0);
2215 case HID_DG_TIPSWITCH:
2216 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
2218 case HID_DG_BARRELSWITCH:
2219 wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS, 0);
2221 case HID_DG_BARRELSWITCH2:
2222 wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS2, 0);
2224 case HID_DG_TOOLSERIALNUMBER:
2225 features->quirks |= WACOM_QUIRK_TOOLSERIAL;
2226 wacom_map_usage(input, usage, field, EV_MSC, MSC_SERIAL, 0);
2228 /* Adjust AES usages to match modern convention */
2229 if (usage->hid == WACOM_HID_WT_SERIALNUMBER && field->report_size == 16) {
2230 if (field->index + 2 < field->report->maxfield) {
2231 struct hid_field *a = field->report->field[field->index + 1];
2232 struct hid_field *b = field->report->field[field->index + 2];
2234 if (a->maxusage > 0 && a->usage[0].hid == HID_DG_TOOLSERIALNUMBER && a->report_size == 32 &&
2235 b->maxusage > 0 && b->usage[0].hid == 0xFF000000 && b->report_size == 8) {
2236 features->quirks |= WACOM_QUIRK_AESPEN;
2237 usage->hid = WACOM_HID_WD_TOOLTYPE;
2238 field->logical_minimum = S16_MIN;
2239 field->logical_maximum = S16_MAX;
2240 a->logical_minimum = S32_MIN;
2241 a->logical_maximum = S32_MAX;
2242 b->usage[0].hid = WACOM_HID_WD_SERIALHI;
2243 b->logical_minimum = 0;
2244 b->logical_maximum = U8_MAX;
2249 case WACOM_HID_WD_SENSE:
2250 features->quirks |= WACOM_QUIRK_SENSE;
2251 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
2253 case WACOM_HID_WD_SERIALHI:
2254 wacom_map_usage(input, usage, field, EV_ABS, ABS_MISC, 0);
2256 if (!(features->quirks & WACOM_QUIRK_AESPEN)) {
2257 set_bit(EV_KEY, input->evbit);
2258 input_set_capability(input, EV_KEY, BTN_TOOL_PEN);
2259 input_set_capability(input, EV_KEY, BTN_TOOL_RUBBER);
2260 input_set_capability(input, EV_KEY, BTN_TOOL_BRUSH);
2261 input_set_capability(input, EV_KEY, BTN_TOOL_PENCIL);
2262 input_set_capability(input, EV_KEY, BTN_TOOL_AIRBRUSH);
2263 if (!(features->device_type & WACOM_DEVICETYPE_DIRECT)) {
2264 input_set_capability(input, EV_KEY, BTN_TOOL_MOUSE);
2265 input_set_capability(input, EV_KEY, BTN_TOOL_LENS);
2269 case WACOM_HID_WD_FINGERWHEEL:
2270 wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
2275 static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field,
2276 struct hid_usage *usage, __s32 value)
2278 struct wacom *wacom = hid_get_drvdata(hdev);
2279 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2280 struct wacom_features *features = &wacom_wac->features;
2281 struct input_dev *input = wacom_wac->pen_input;
2282 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2284 if (wacom_wac->is_invalid_bt_frame)
2287 switch (equivalent_usage) {
2290 * HID_GD_Z "should increase as the control's position is
2291 * moved from high to low", while ABS_DISTANCE instead
2292 * increases in value as the tool moves from low to high.
2294 value = field->logical_maximum - value;
2296 case HID_DG_INRANGE:
2297 mod_timer(&wacom->idleprox_timer, jiffies + msecs_to_jiffies(100));
2298 wacom_wac->hid_data.inrange_state = value;
2299 if (!(features->quirks & WACOM_QUIRK_SENSE))
2300 wacom_wac->hid_data.sense_state = value;
2303 wacom_wac->hid_data.invert_state = value;
2306 case HID_DG_TIPSWITCH:
2307 wacom_wac->hid_data.tipswitch |= value;
2309 case HID_DG_BARRELSWITCH:
2310 wacom_wac->hid_data.barrelswitch = value;
2312 case HID_DG_BARRELSWITCH2:
2313 wacom_wac->hid_data.barrelswitch2 = value;
2315 case HID_DG_TOOLSERIALNUMBER:
2317 wacom_wac->serial[0] = (wacom_wac->serial[0] & ~0xFFFFFFFFULL);
2318 wacom_wac->serial[0] |= wacom_s32tou(value, field->report_size);
2323 * Userspace expects pen twist to have its zero point when
2324 * the buttons/finger is on the tablet's left. HID values
2325 * are zero when buttons are toward the top.
2327 value = wacom_offset_rotation(input, usage, value, 1, 4);
2329 case WACOM_HID_WD_SENSE:
2330 wacom_wac->hid_data.sense_state = value;
2332 case WACOM_HID_WD_SERIALHI:
2334 __u32 raw_value = wacom_s32tou(value, field->report_size);
2336 wacom_wac->serial[0] = (wacom_wac->serial[0] & 0xFFFFFFFF);
2337 wacom_wac->serial[0] |= ((__u64)raw_value) << 32;
2339 * Non-USI EMR devices may contain additional tool type
2340 * information here. See WACOM_HID_WD_TOOLTYPE case for
2343 if (value >> 20 == 1) {
2344 wacom_wac->id[0] |= raw_value & 0xFFFFF;
2348 case WACOM_HID_WD_TOOLTYPE:
2350 * Some devices (MobileStudio Pro, and possibly later
2351 * devices as well) do not return the complete tool
2352 * type in their WACOM_HID_WD_TOOLTYPE usage. Use a
2353 * bitwise OR so the complete value can be built
2356 wacom_wac->id[0] |= wacom_s32tou(value, field->report_size);
2358 case WACOM_HID_WD_OFFSETLEFT:
2359 if (features->offset_left && value != features->offset_left)
2360 hid_warn(hdev, "%s: overriding existing left offset "
2361 "%d -> %d\n", __func__, value,
2362 features->offset_left);
2363 features->offset_left = value;
2365 case WACOM_HID_WD_OFFSETRIGHT:
2366 if (features->offset_right && value != features->offset_right)
2367 hid_warn(hdev, "%s: overriding existing right offset "
2368 "%d -> %d\n", __func__, value,
2369 features->offset_right);
2370 features->offset_right = value;
2372 case WACOM_HID_WD_OFFSETTOP:
2373 if (features->offset_top && value != features->offset_top)
2374 hid_warn(hdev, "%s: overriding existing top offset "
2375 "%d -> %d\n", __func__, value,
2376 features->offset_top);
2377 features->offset_top = value;
2379 case WACOM_HID_WD_OFFSETBOTTOM:
2380 if (features->offset_bottom && value != features->offset_bottom)
2381 hid_warn(hdev, "%s: overriding existing bottom offset "
2382 "%d -> %d\n", __func__, value,
2383 features->offset_bottom);
2384 features->offset_bottom = value;
2386 case WACOM_HID_WD_REPORT_VALID:
2387 wacom_wac->is_invalid_bt_frame = !value;
2391 /* send pen events only when touch is up or forced out
2392 * or touch arbitration is off
2394 if (!usage->type || delay_pen_events(wacom_wac))
2397 /* send pen events only when the pen is in range */
2398 if (wacom_wac->hid_data.inrange_state)
2399 input_event(input, usage->type, usage->code, value);
2400 else if (wacom_wac->shared->stylus_in_proximity && !wacom_wac->hid_data.sense_state)
2401 input_event(input, usage->type, usage->code, 0);
2404 static void wacom_wac_pen_pre_report(struct hid_device *hdev,
2405 struct hid_report *report)
2407 struct wacom *wacom = hid_get_drvdata(hdev);
2408 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2410 wacom_wac->is_invalid_bt_frame = false;
2414 static void wacom_wac_pen_report(struct hid_device *hdev,
2415 struct hid_report *report)
2417 struct wacom *wacom = hid_get_drvdata(hdev);
2418 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2419 struct input_dev *input = wacom_wac->pen_input;
2420 bool range = wacom_wac->hid_data.inrange_state;
2421 bool sense = wacom_wac->hid_data.sense_state;
2423 if (wacom_wac->is_invalid_bt_frame)
2426 if (!wacom_wac->tool[0] && range) { /* first in range */
2427 /* Going into range select tool */
2428 if (wacom_wac->hid_data.invert_state)
2429 wacom_wac->tool[0] = BTN_TOOL_RUBBER;
2430 else if (wacom_wac->id[0])
2431 wacom_wac->tool[0] = wacom_intuos_get_tool_type(wacom_wac->id[0]);
2433 wacom_wac->tool[0] = BTN_TOOL_PEN;
2436 /* keep pen state for touch events */
2437 wacom_wac->shared->stylus_in_proximity = sense;
2439 if (!delay_pen_events(wacom_wac) && wacom_wac->tool[0]) {
2440 int id = wacom_wac->id[0];
2441 int sw_state = wacom_wac->hid_data.barrelswitch |
2442 (wacom_wac->hid_data.barrelswitch2 << 1);
2444 input_report_key(input, BTN_STYLUS, sw_state == 1);
2445 input_report_key(input, BTN_STYLUS2, sw_state == 2);
2446 input_report_key(input, BTN_STYLUS3, sw_state == 3);
2449 * Non-USI EMR tools should have their IDs mangled to
2450 * match the legacy behavior of wacom_intuos_general
2452 if (wacom_wac->serial[0] >> 52 == 1)
2453 id = wacom_intuos_id_mangle(id);
2456 * To ensure compatibility with xf86-input-wacom, we should
2457 * report the BTN_TOOL_* event prior to the ABS_MISC or
2458 * MSC_SERIAL events.
2460 input_report_key(input, BTN_TOUCH,
2461 wacom_wac->hid_data.tipswitch);
2462 input_report_key(input, wacom_wac->tool[0], sense);
2463 if (wacom_wac->serial[0]) {
2464 input_event(input, EV_MSC, MSC_SERIAL, wacom_wac->serial[0]);
2465 input_report_abs(input, ABS_MISC, sense ? id : 0);
2468 wacom_wac->hid_data.tipswitch = false;
2474 wacom_wac->tool[0] = 0;
2475 wacom_wac->id[0] = 0;
2476 wacom_wac->serial[0] = 0;
2480 static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
2481 struct hid_field *field, struct hid_usage *usage)
2483 struct wacom *wacom = hid_get_drvdata(hdev);
2484 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2485 struct input_dev *input = wacom_wac->touch_input;
2486 unsigned touch_max = wacom_wac->features.touch_max;
2487 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2489 switch (equivalent_usage) {
2492 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
2494 wacom_map_usage(input, usage, field, EV_ABS,
2495 ABS_MT_POSITION_X, 4);
2499 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
2501 wacom_map_usage(input, usage, field, EV_ABS,
2502 ABS_MT_POSITION_Y, 4);
2506 wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MAJOR, 0);
2507 wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MINOR, 0);
2508 input_set_abs_params(input, ABS_MT_ORIENTATION, 0, 1, 0, 0);
2510 case HID_DG_TIPSWITCH:
2511 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
2513 case HID_DG_CONTACTCOUNT:
2514 wacom_wac->hid_data.cc_report = field->report->id;
2515 wacom_wac->hid_data.cc_index = field->index;
2516 wacom_wac->hid_data.cc_value_index = usage->usage_index;
2518 case HID_DG_CONTACTID:
2519 if ((field->logical_maximum - field->logical_minimum) < touch_max) {
2521 * The HID descriptor for G11 sensors leaves logical
2522 * maximum set to '1' despite it being a multitouch
2523 * device. Override to a sensible number.
2525 field->logical_maximum = 255;
2531 static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
2532 struct input_dev *input)
2534 struct hid_data *hid_data = &wacom_wac->hid_data;
2535 bool mt = wacom_wac->features.touch_max > 1;
2536 bool prox = hid_data->tipswitch &&
2537 report_touch_events(wacom_wac);
2539 if (wacom_wac->shared->has_mute_touch_switch &&
2540 !wacom_wac->shared->is_touch_on) {
2541 if (!wacom_wac->shared->touch_down)
2546 wacom_wac->hid_data.num_received++;
2547 if (wacom_wac->hid_data.num_received > wacom_wac->hid_data.num_expected)
2553 slot = input_mt_get_slot_by_key(input, hid_data->id);
2554 input_mt_slot(input, slot);
2555 input_mt_report_slot_state(input, MT_TOOL_FINGER, prox);
2558 input_report_key(input, BTN_TOUCH, prox);
2562 input_report_abs(input, mt ? ABS_MT_POSITION_X : ABS_X,
2564 input_report_abs(input, mt ? ABS_MT_POSITION_Y : ABS_Y,
2567 if (test_bit(ABS_MT_TOUCH_MAJOR, input->absbit)) {
2568 input_report_abs(input, ABS_MT_TOUCH_MAJOR, max(hid_data->width, hid_data->height));
2569 input_report_abs(input, ABS_MT_TOUCH_MINOR, min(hid_data->width, hid_data->height));
2570 if (hid_data->width != hid_data->height)
2571 input_report_abs(input, ABS_MT_ORIENTATION, hid_data->width <= hid_data->height ? 0 : 1);
2576 static bool wacom_wac_slot_is_active(struct input_dev *dev, int key)
2578 struct input_mt *mt = dev->mt;
2579 struct input_mt_slot *s;
2584 for (s = mt->slots; s != mt->slots + mt->num_slots; s++) {
2585 if (s->key == key &&
2586 input_mt_get_value(s, ABS_MT_TRACKING_ID) >= 0) {
2594 static void wacom_wac_finger_event(struct hid_device *hdev,
2595 struct hid_field *field, struct hid_usage *usage, __s32 value)
2597 struct wacom *wacom = hid_get_drvdata(hdev);
2598 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2599 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2600 struct wacom_features *features = &wacom->wacom_wac.features;
2602 switch (equivalent_usage) {
2603 case HID_DG_CONFIDENCE:
2604 wacom_wac->hid_data.confidence = value;
2607 wacom_wac->hid_data.x = value;
2610 wacom_wac->hid_data.y = value;
2613 wacom_wac->hid_data.width = value;
2616 wacom_wac->hid_data.height = value;
2618 case HID_DG_CONTACTID:
2619 wacom_wac->hid_data.id = value;
2621 case HID_DG_TIPSWITCH:
2622 wacom_wac->hid_data.tipswitch = value;
2624 case HID_DG_CONTACTMAX:
2625 if (!features->touch_max) {
2626 features->touch_max = value;
2628 hid_warn(hdev, "%s: ignoring attempt to overwrite non-zero touch_max "
2629 "%d -> %d\n", __func__, features->touch_max, value);
2635 if (usage->usage_index + 1 == field->report_count) {
2636 if (equivalent_usage == wacom_wac->hid_data.last_slot_field) {
2637 bool touch_removed = wacom_wac_slot_is_active(wacom_wac->touch_input,
2638 wacom_wac->hid_data.id) && !wacom_wac->hid_data.tipswitch;
2640 if (wacom_wac->hid_data.confidence || touch_removed) {
2641 wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
2647 static void wacom_wac_finger_pre_report(struct hid_device *hdev,
2648 struct hid_report *report)
2650 struct wacom *wacom = hid_get_drvdata(hdev);
2651 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2652 struct hid_data* hid_data = &wacom_wac->hid_data;
2655 hid_data->confidence = true;
2657 hid_data->cc_report = 0;
2658 hid_data->cc_index = -1;
2659 hid_data->cc_value_index = -1;
2661 for (i = 0; i < report->maxfield; i++) {
2662 struct hid_field *field = report->field[i];
2665 for (j = 0; j < field->maxusage; j++) {
2666 struct hid_usage *usage = &field->usage[j];
2667 unsigned int equivalent_usage =
2668 wacom_equivalent_usage(usage->hid);
2670 switch (equivalent_usage) {
2675 case HID_DG_CONTACTID:
2676 case HID_DG_INRANGE:
2678 case HID_DG_TIPSWITCH:
2679 hid_data->last_slot_field = equivalent_usage;
2681 case HID_DG_CONTACTCOUNT:
2682 hid_data->cc_report = report->id;
2683 hid_data->cc_index = i;
2684 hid_data->cc_value_index = j;
2690 if (hid_data->cc_report != 0 &&
2691 hid_data->cc_index >= 0) {
2692 struct hid_field *field = report->field[hid_data->cc_index];
2693 int value = field->value[hid_data->cc_value_index];
2695 hid_data->num_expected = value;
2696 hid_data->num_received = 0;
2700 hid_data->num_expected = wacom_wac->features.touch_max;
2701 hid_data->num_received = 0;
2705 static void wacom_wac_finger_report(struct hid_device *hdev,
2706 struct hid_report *report)
2708 struct wacom *wacom = hid_get_drvdata(hdev);
2709 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2710 struct input_dev *input = wacom_wac->touch_input;
2711 unsigned touch_max = wacom_wac->features.touch_max;
2713 /* If more packets of data are expected, give us a chance to
2714 * process them rather than immediately syncing a partial
2717 if (wacom_wac->hid_data.num_received < wacom_wac->hid_data.num_expected)
2721 input_mt_sync_frame(input);
2724 wacom_wac->hid_data.num_received = 0;
2725 wacom_wac->hid_data.num_expected = 0;
2727 /* keep touch state for pen event */
2728 wacom_wac->shared->touch_down = wacom_wac_finger_count_touches(wacom_wac);
2731 void wacom_wac_usage_mapping(struct hid_device *hdev,
2732 struct hid_field *field, struct hid_usage *usage)
2734 struct wacom *wacom = hid_get_drvdata(hdev);
2735 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2736 struct wacom_features *features = &wacom_wac->features;
2738 if (WACOM_DIRECT_DEVICE(field))
2739 features->device_type |= WACOM_DEVICETYPE_DIRECT;
2741 /* usage tests must precede field tests */
2742 if (WACOM_BATTERY_USAGE(usage))
2743 wacom_wac_battery_usage_mapping(hdev, field, usage);
2744 else if (WACOM_PAD_FIELD(field))
2745 wacom_wac_pad_usage_mapping(hdev, field, usage);
2746 else if (WACOM_PEN_FIELD(field))
2747 wacom_wac_pen_usage_mapping(hdev, field, usage);
2748 else if (WACOM_FINGER_FIELD(field))
2749 wacom_wac_finger_usage_mapping(hdev, field, usage);
2752 void wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
2753 struct hid_usage *usage, __s32 value)
2755 struct wacom *wacom = hid_get_drvdata(hdev);
2757 if (wacom->wacom_wac.features.type != HID_GENERIC)
2760 if (value > field->logical_maximum || value < field->logical_minimum)
2763 /* usage tests must precede field tests */
2764 if (WACOM_BATTERY_USAGE(usage))
2765 wacom_wac_battery_event(hdev, field, usage, value);
2766 else if (WACOM_PAD_FIELD(field))
2767 wacom_wac_pad_event(hdev, field, usage, value);
2768 else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
2769 wacom_wac_pen_event(hdev, field, usage, value);
2770 else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
2771 wacom_wac_finger_event(hdev, field, usage, value);
2774 static void wacom_report_events(struct hid_device *hdev,
2775 struct hid_report *report, int collection_index,
2780 for (r = field_index; r < report->maxfield; r++) {
2781 struct hid_field *field;
2784 field = report->field[r];
2785 count = field->report_count;
2787 if (!(HID_MAIN_ITEM_VARIABLE & field->flags))
2790 for (n = 0 ; n < count; n++) {
2791 if (field->usage[n].collection_index == collection_index)
2792 wacom_wac_event(hdev, field, &field->usage[n],
2800 static int wacom_wac_collection(struct hid_device *hdev, struct hid_report *report,
2801 int collection_index, struct hid_field *field,
2804 struct wacom *wacom = hid_get_drvdata(hdev);
2806 wacom_report_events(hdev, report, collection_index, field_index);
2809 * Non-input reports may be sent prior to the device being
2810 * completely initialized. Since only their events need
2811 * to be processed, exit after 'wacom_report_events' has
2812 * been called to prevent potential crashes in the report-
2813 * processing functions.
2815 if (report->type != HID_INPUT_REPORT)
2818 if (WACOM_PAD_FIELD(field))
2820 else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
2821 wacom_wac_pen_report(hdev, report);
2822 else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
2823 wacom_wac_finger_report(hdev, report);
2828 void wacom_wac_report(struct hid_device *hdev, struct hid_report *report)
2830 struct wacom *wacom = hid_get_drvdata(hdev);
2831 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2832 struct hid_field *field;
2833 bool pad_in_hid_field = false, pen_in_hid_field = false,
2834 finger_in_hid_field = false, true_pad = false;
2836 int prev_collection = -1;
2838 if (wacom_wac->features.type != HID_GENERIC)
2841 for (r = 0; r < report->maxfield; r++) {
2842 field = report->field[r];
2844 if (WACOM_PAD_FIELD(field))
2845 pad_in_hid_field = true;
2846 if (WACOM_PEN_FIELD(field))
2847 pen_in_hid_field = true;
2848 if (WACOM_FINGER_FIELD(field))
2849 finger_in_hid_field = true;
2850 if (wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY)
2854 wacom_wac_battery_pre_report(hdev, report);
2856 if (pad_in_hid_field && wacom->wacom_wac.pad_input)
2857 wacom_wac_pad_pre_report(hdev, report);
2858 if (pen_in_hid_field && wacom->wacom_wac.pen_input)
2859 wacom_wac_pen_pre_report(hdev, report);
2860 if (finger_in_hid_field && wacom->wacom_wac.touch_input)
2861 wacom_wac_finger_pre_report(hdev, report);
2863 for (r = 0; r < report->maxfield; r++) {
2864 field = report->field[r];
2866 if (field->usage[0].collection_index != prev_collection) {
2867 if (wacom_wac_collection(hdev, report,
2868 field->usage[0].collection_index, field, r) < 0)
2870 prev_collection = field->usage[0].collection_index;
2874 wacom_wac_battery_report(hdev, report);
2876 if (true_pad && wacom->wacom_wac.pad_input)
2877 wacom_wac_pad_report(hdev, report, field);
2880 static int wacom_bpt_touch(struct wacom_wac *wacom)
2882 struct wacom_features *features = &wacom->features;
2883 struct input_dev *input = wacom->touch_input;
2884 struct input_dev *pad_input = wacom->pad_input;
2885 unsigned char *data = wacom->data;
2888 if (data[0] != 0x02)
2891 for (i = 0; i < 2; i++) {
2892 int offset = (data[1] & 0x80) ? (8 * i) : (9 * i);
2893 bool touch = report_touch_events(wacom)
2894 && (data[offset + 3] & 0x80);
2896 input_mt_slot(input, i);
2897 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
2899 int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff;
2900 int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff;
2901 if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) {
2905 input_report_abs(input, ABS_MT_POSITION_X, x);
2906 input_report_abs(input, ABS_MT_POSITION_Y, y);
2910 input_mt_sync_frame(input);
2912 input_report_key(pad_input, BTN_LEFT, (data[1] & 0x08) != 0);
2913 input_report_key(pad_input, BTN_FORWARD, (data[1] & 0x04) != 0);
2914 input_report_key(pad_input, BTN_BACK, (data[1] & 0x02) != 0);
2915 input_report_key(pad_input, BTN_RIGHT, (data[1] & 0x01) != 0);
2916 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
2921 static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
2923 struct wacom_features *features = &wacom->features;
2924 struct input_dev *input = wacom->touch_input;
2925 bool touch = data[1] & 0x80;
2926 int slot = input_mt_get_slot_by_key(input, data[0]);
2931 touch = touch && report_touch_events(wacom);
2933 input_mt_slot(input, slot);
2934 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
2937 int x = (data[2] << 4) | (data[4] >> 4);
2938 int y = (data[3] << 4) | (data[4] & 0x0f);
2941 if (features->type >= INTUOSPS && features->type <= INTUOSHT2) {
2942 width = data[5] * 100;
2943 height = data[6] * 100;
2946 * "a" is a scaled-down area which we assume is
2947 * roughly circular and which can be described as:
2951 int x_res = input_abs_get_res(input, ABS_MT_POSITION_X);
2952 int y_res = input_abs_get_res(input, ABS_MT_POSITION_Y);
2953 width = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE);
2954 height = width * y_res / x_res;
2957 input_report_abs(input, ABS_MT_POSITION_X, x);
2958 input_report_abs(input, ABS_MT_POSITION_Y, y);
2959 input_report_abs(input, ABS_MT_TOUCH_MAJOR, width);
2960 input_report_abs(input, ABS_MT_TOUCH_MINOR, height);
2964 static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
2966 struct input_dev *input = wacom->pad_input;
2967 struct wacom_features *features = &wacom->features;
2969 if (features->type == INTUOSHT || features->type == INTUOSHT2) {
2970 input_report_key(input, BTN_LEFT, (data[1] & 0x02) != 0);
2971 input_report_key(input, BTN_BACK, (data[1] & 0x08) != 0);
2973 input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
2974 input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
2976 input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
2977 input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
2980 static int wacom_bpt3_touch(struct wacom_wac *wacom)
2982 unsigned char *data = wacom->data;
2983 int count = data[1] & 0x07;
2984 int touch_changed = 0, i;
2986 if (data[0] != 0x02)
2989 /* data has up to 7 fixed sized 8-byte messages starting at data[2] */
2990 for (i = 0; i < count; i++) {
2991 int offset = (8 * i) + 2;
2992 int msg_id = data[offset];
2994 if (msg_id >= 2 && msg_id <= 17) {
2995 wacom_bpt3_touch_msg(wacom, data + offset);
2997 } else if (msg_id == 128)
2998 wacom_bpt3_button_msg(wacom, data + offset);
3002 /* only update touch if we actually have a touchpad and touch data changed */
3003 if (wacom->touch_input && touch_changed) {
3004 input_mt_sync_frame(wacom->touch_input);
3005 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
3011 static int wacom_bpt_pen(struct wacom_wac *wacom)
3013 struct wacom_features *features = &wacom->features;
3014 struct input_dev *input = wacom->pen_input;
3015 unsigned char *data = wacom->data;
3016 int x = 0, y = 0, p = 0, d = 0;
3017 bool pen = false, btn1 = false, btn2 = false;
3018 bool range, prox, rdy;
3020 if (data[0] != WACOM_REPORT_PENABLED)
3023 range = (data[1] & 0x80) == 0x80;
3024 prox = (data[1] & 0x40) == 0x40;
3025 rdy = (data[1] & 0x20) == 0x20;
3027 wacom->shared->stylus_in_proximity = range;
3028 if (delay_pen_events(wacom))
3032 p = le16_to_cpup((__le16 *)&data[6]);
3033 pen = data[1] & 0x01;
3034 btn1 = data[1] & 0x02;
3035 btn2 = data[1] & 0x04;
3038 x = le16_to_cpup((__le16 *)&data[2]);
3039 y = le16_to_cpup((__le16 *)&data[4]);
3041 if (data[1] & 0x08) {
3042 wacom->tool[0] = BTN_TOOL_RUBBER;
3043 wacom->id[0] = ERASER_DEVICE_ID;
3045 wacom->tool[0] = BTN_TOOL_PEN;
3046 wacom->id[0] = STYLUS_DEVICE_ID;
3048 wacom->reporting_data = true;
3052 * Convert distance from out prox to distance from tablet.
3053 * distance will be greater than distance_max once
3054 * touching and applying pressure; do not report negative
3057 if (data[8] <= features->distance_max)
3058 d = features->distance_max - data[8];
3063 if (wacom->reporting_data) {
3064 input_report_key(input, BTN_TOUCH, pen);
3065 input_report_key(input, BTN_STYLUS, btn1);
3066 input_report_key(input, BTN_STYLUS2, btn2);
3068 if (prox || !range) {
3069 input_report_abs(input, ABS_X, x);
3070 input_report_abs(input, ABS_Y, y);
3072 input_report_abs(input, ABS_PRESSURE, p);
3073 input_report_abs(input, ABS_DISTANCE, d);
3075 input_report_key(input, wacom->tool[0], range); /* PEN or RUBBER */
3076 input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
3080 wacom->reporting_data = false;
3086 static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
3088 struct wacom_features *features = &wacom->features;
3090 if ((features->type == INTUOSHT2) &&
3091 (features->device_type & WACOM_DEVICETYPE_PEN))
3092 return wacom_intuos_irq(wacom);
3093 else if (len == WACOM_PKGLEN_BBTOUCH)
3094 return wacom_bpt_touch(wacom);
3095 else if (len == WACOM_PKGLEN_BBTOUCH3)
3096 return wacom_bpt3_touch(wacom);
3097 else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
3098 return wacom_bpt_pen(wacom);
3103 static void wacom_bamboo_pad_pen_event(struct wacom_wac *wacom,
3104 unsigned char *data)
3106 unsigned char prefix;
3109 * We need to reroute the event from the debug interface to the
3111 * We need to add the report ID to the actual pen report, so we
3112 * temporary overwrite the first byte to prevent having to kzalloc/kfree
3113 * and memcpy the report.
3116 data[0] = WACOM_REPORT_BPAD_PEN;
3119 * actually reroute the event.
3120 * No need to check if wacom->shared->pen is valid, hid_input_report()
3121 * will check for us.
3123 hid_input_report(wacom->shared->pen, HID_INPUT_REPORT, data,
3124 WACOM_PKGLEN_PENABLED, 1);
3129 static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom,
3130 unsigned char *data)
3132 struct input_dev *input = wacom->touch_input;
3133 unsigned char *finger_data, prefix;
3140 for (id = 0; id < wacom->features.touch_max; id++) {
3141 valid = !!(prefix & BIT(id)) &&
3142 report_touch_events(wacom);
3144 input_mt_slot(input, id);
3145 input_mt_report_slot_state(input, MT_TOOL_FINGER, valid);
3150 finger_data = data + 1 + id * 3;
3151 x = finger_data[0] | ((finger_data[1] & 0x0f) << 8);
3152 y = (finger_data[2] << 4) | (finger_data[1] >> 4);
3154 input_report_abs(input, ABS_MT_POSITION_X, x);
3155 input_report_abs(input, ABS_MT_POSITION_Y, y);
3158 input_mt_sync_frame(input);
3160 input_report_key(input, BTN_LEFT, prefix & 0x40);
3161 input_report_key(input, BTN_RIGHT, prefix & 0x80);
3163 /* keep touch state for pen event */
3164 wacom->shared->touch_down = !!prefix && report_touch_events(wacom);
3169 static int wacom_bamboo_pad_irq(struct wacom_wac *wacom, size_t len)
3171 unsigned char *data = wacom->data;
3173 if (!((len == WACOM_PKGLEN_BPAD_TOUCH) ||
3174 (len == WACOM_PKGLEN_BPAD_TOUCH_USB)) ||
3175 (data[0] != WACOM_REPORT_BPAD_TOUCH))
3179 wacom_bamboo_pad_pen_event(wacom, &data[1]);
3182 return wacom_bamboo_pad_touch_event(wacom, &data[9]);
3187 static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
3189 unsigned char *data = wacom->data;
3192 if (len != WACOM_PKGLEN_WIRELESS || data[0] != WACOM_REPORT_WL)
3195 connected = data[1] & 0x01;
3197 int pid, battery, charging;
3199 if ((wacom->shared->type == INTUOSHT ||
3200 wacom->shared->type == INTUOSHT2) &&
3201 wacom->shared->touch_input &&
3202 wacom->shared->touch_max) {
3203 input_report_switch(wacom->shared->touch_input,
3204 SW_MUTE_DEVICE, data[5] & 0x40);
3205 input_sync(wacom->shared->touch_input);
3208 pid = get_unaligned_be16(&data[6]);
3209 battery = (data[5] & 0x3f) * 100 / 31;
3210 charging = !!(data[5] & 0x80);
3211 if (wacom->pid != pid) {
3213 wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
3216 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
3217 battery, charging, 1, 0);
3219 } else if (wacom->pid != 0) {
3220 /* disconnected while previously connected */
3222 wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
3223 wacom_notify_battery(wacom, POWER_SUPPLY_STATUS_UNKNOWN, 0, 0, 0, 0);
3229 static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
3231 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
3232 struct wacom_features *features = &wacom_wac->features;
3233 unsigned char *data = wacom_wac->data;
3235 if (data[0] != WACOM_REPORT_USB)
3238 if ((features->type == INTUOSHT ||
3239 features->type == INTUOSHT2) &&
3240 wacom_wac->shared->touch_input &&
3241 features->touch_max) {
3242 input_report_switch(wacom_wac->shared->touch_input,
3243 SW_MUTE_DEVICE, data[8] & 0x40);
3244 input_sync(wacom_wac->shared->touch_input);
3247 if (data[9] & 0x02) { /* wireless module is attached */
3248 int battery = (data[8] & 0x3f) * 100 / 31;
3249 bool charging = !!(data[8] & 0x80);
3251 wacom_notify_battery(wacom_wac, WACOM_POWER_SUPPLY_STATUS_AUTO,
3252 battery, charging, battery || charging, 1);
3254 if (!wacom->battery.battery &&
3255 !(features->quirks & WACOM_QUIRK_BATTERY)) {
3256 features->quirks |= WACOM_QUIRK_BATTERY;
3257 wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
3260 else if ((features->quirks & WACOM_QUIRK_BATTERY) &&
3261 wacom->battery.battery) {
3262 features->quirks &= ~WACOM_QUIRK_BATTERY;
3263 wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
3264 wacom_notify_battery(wacom_wac, POWER_SUPPLY_STATUS_UNKNOWN, 0, 0, 0, 0);
3269 void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
3273 switch (wacom_wac->features.type) {
3275 sync = wacom_penpartner_irq(wacom_wac);
3279 sync = wacom_pl_irq(wacom_wac);
3286 sync = wacom_graphire_irq(wacom_wac);
3290 sync = wacom_ptu_irq(wacom_wac);
3294 sync = wacom_dtu_irq(wacom_wac);
3299 sync = wacom_dtus_irq(wacom_wac);
3318 case CINTIQ_COMPANION_2:
3319 sync = wacom_intuos_irq(wacom_wac);
3323 sync = wacom_intuos_bt_irq(wacom_wac, len);
3328 sync = wacom_24hdt_irq(wacom_wac);
3337 if (len == WACOM_PKGLEN_BBTOUCH3)
3338 sync = wacom_bpt3_touch(wacom_wac);
3339 else if (wacom_wac->data[0] == WACOM_REPORT_USB)
3340 sync = wacom_status_irq(wacom_wac, len);
3342 sync = wacom_intuos_irq(wacom_wac);
3347 sync = wacom_intuos_pro2_bt_irq(wacom_wac, len);
3356 sync = wacom_tpc_irq(wacom_wac, len);
3364 if (wacom_wac->data[0] == WACOM_REPORT_USB)
3365 sync = wacom_status_irq(wacom_wac, len);
3367 sync = wacom_bpt_irq(wacom_wac, len);
3371 sync = wacom_bamboo_pad_irq(wacom_wac, len);
3375 sync = wacom_wireless_irq(wacom_wac, len);
3380 if (wacom_wac->data[0] == WACOM_REPORT_DEVICE_LIST)
3381 wacom_remote_status_irq(wacom_wac, len);
3383 sync = wacom_remote_irq(wacom_wac, len);
3392 if (wacom_wac->pen_input)
3393 input_sync(wacom_wac->pen_input);
3394 if (wacom_wac->touch_input)
3395 input_sync(wacom_wac->touch_input);
3396 if (wacom_wac->pad_input)
3397 input_sync(wacom_wac->pad_input);
3401 static void wacom_setup_basic_pro_pen(struct wacom_wac *wacom_wac)
3403 struct input_dev *input_dev = wacom_wac->pen_input;
3405 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
3407 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3408 __set_bit(BTN_STYLUS, input_dev->keybit);
3409 __set_bit(BTN_STYLUS2, input_dev->keybit);
3411 input_set_abs_params(input_dev, ABS_DISTANCE,
3412 0, wacom_wac->features.distance_max, wacom_wac->features.distance_fuzz, 0);
3415 static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
3417 struct input_dev *input_dev = wacom_wac->pen_input;
3418 struct wacom_features *features = &wacom_wac->features;
3420 wacom_setup_basic_pro_pen(wacom_wac);
3422 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3423 __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
3424 __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
3425 __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
3427 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
3428 input_set_abs_params(input_dev, ABS_TILT_X, -64, 63, features->tilt_fuzz, 0);
3429 input_abs_set_res(input_dev, ABS_TILT_X, 57);
3430 input_set_abs_params(input_dev, ABS_TILT_Y, -64, 63, features->tilt_fuzz, 0);
3431 input_abs_set_res(input_dev, ABS_TILT_Y, 57);
3434 static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
3436 struct input_dev *input_dev = wacom_wac->pen_input;
3438 input_set_capability(input_dev, EV_REL, REL_WHEEL);
3440 wacom_setup_cintiq(wacom_wac);
3442 __set_bit(BTN_LEFT, input_dev->keybit);
3443 __set_bit(BTN_RIGHT, input_dev->keybit);
3444 __set_bit(BTN_MIDDLE, input_dev->keybit);
3445 __set_bit(BTN_SIDE, input_dev->keybit);
3446 __set_bit(BTN_EXTRA, input_dev->keybit);
3447 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
3448 __set_bit(BTN_TOOL_LENS, input_dev->keybit);
3450 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
3451 input_abs_set_res(input_dev, ABS_RZ, 287);
3452 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
3455 void wacom_setup_device_quirks(struct wacom *wacom)
3457 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
3458 struct wacom_features *features = &wacom->wacom_wac.features;
3460 /* The pen and pad share the same interface on most devices */
3461 if (features->type == GRAPHIRE_BT || features->type == WACOM_G4 ||
3462 features->type == DTUS ||
3463 (features->type >= INTUOS3S && features->type <= WACOM_MO)) {
3464 if (features->device_type & WACOM_DEVICETYPE_PEN)
3465 features->device_type |= WACOM_DEVICETYPE_PAD;
3468 /* touch device found but size is not defined. use default */
3469 if (features->device_type & WACOM_DEVICETYPE_TOUCH && !features->x_max) {
3470 features->x_max = 1023;
3471 features->y_max = 1023;
3475 * Intuos5/Pro and Bamboo 3rd gen have no useful data about its
3476 * touch interface in its HID descriptor. If this is the touch
3477 * interface (PacketSize of WACOM_PKGLEN_BBTOUCH3), override the
3480 if ((features->type >= INTUOS5S && features->type <= INTUOSPL) ||
3481 (features->type >= INTUOSHT && features->type <= BAMBOO_PT)) {
3482 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
3483 if (features->touch_max)
3484 features->device_type |= WACOM_DEVICETYPE_TOUCH;
3485 if (features->type >= INTUOSHT && features->type <= BAMBOO_PT)
3486 features->device_type |= WACOM_DEVICETYPE_PAD;
3488 if (features->type == INTUOSHT2) {
3489 features->x_max = features->x_max / 10;
3490 features->y_max = features->y_max / 10;
3493 features->x_max = 4096;
3494 features->y_max = 4096;
3497 else if (features->pktlen == WACOM_PKGLEN_BBTOUCH) {
3498 features->device_type |= WACOM_DEVICETYPE_PAD;
3503 * Hack for the Bamboo One:
3504 * the device presents a PAD/Touch interface as most Bamboos and even
3505 * sends ghosts PAD data on it. However, later, we must disable this
3506 * ghost interface, and we can not detect it unless we set it here
3507 * to WACOM_DEVICETYPE_PAD or WACOM_DEVICETYPE_TOUCH.
3509 if (features->type == BAMBOO_PEN &&
3510 features->pktlen == WACOM_PKGLEN_BBTOUCH3)
3511 features->device_type |= WACOM_DEVICETYPE_PAD;
3514 * Raw Wacom-mode pen and touch events both come from interface
3515 * 0, whose HID descriptor has an application usage of 0xFF0D
3516 * (i.e., WACOM_HID_WD_DIGITIZER). We route pen packets back
3517 * out through the HID_GENERIC device created for interface 1,
3518 * so rewrite this one to be of type WACOM_DEVICETYPE_TOUCH.
3520 if (features->type == BAMBOO_PAD)
3521 features->device_type = WACOM_DEVICETYPE_TOUCH;
3523 if (features->type == REMOTE)
3524 features->device_type = WACOM_DEVICETYPE_PAD;
3526 if (features->type == INTUOSP2_BT) {
3527 features->device_type |= WACOM_DEVICETYPE_PEN |
3528 WACOM_DEVICETYPE_PAD |
3529 WACOM_DEVICETYPE_TOUCH;
3530 features->quirks |= WACOM_QUIRK_BATTERY;
3533 if (features->type == INTUOSHT3_BT) {
3534 features->device_type |= WACOM_DEVICETYPE_PEN |
3535 WACOM_DEVICETYPE_PAD;
3536 features->quirks |= WACOM_QUIRK_BATTERY;
3539 switch (features->type) {
3550 case CINTIQ_COMPANION_2:
3562 features->device_type |= WACOM_DEVICETYPE_DIRECT;
3566 if (wacom->hdev->bus == BUS_BLUETOOTH)
3567 features->quirks |= WACOM_QUIRK_BATTERY;
3569 /* quirk for bamboo touch with 2 low res touches */
3570 if ((features->type == BAMBOO_PT || features->type == BAMBOO_TOUCH) &&
3571 features->pktlen == WACOM_PKGLEN_BBTOUCH) {
3572 features->x_max <<= 5;
3573 features->y_max <<= 5;
3574 features->x_fuzz <<= 5;
3575 features->y_fuzz <<= 5;
3576 features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;
3579 if (features->type == WIRELESS) {
3580 if (features->device_type == WACOM_DEVICETYPE_WL_MONITOR) {
3581 features->quirks |= WACOM_QUIRK_BATTERY;
3585 if (features->type == REMOTE)
3586 features->device_type |= WACOM_DEVICETYPE_WL_MONITOR;
3588 /* HID descriptor for DTK-2451 / DTH-2452 claims to report lots
3589 * of things it shouldn't. Lets fix up the damage...
3591 if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
3592 features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3593 __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3594 __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3595 __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3596 __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3597 __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3598 __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3599 __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3600 __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3601 __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3602 __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3603 __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3607 int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
3608 struct wacom_wac *wacom_wac)
3610 struct wacom_features *features = &wacom_wac->features;
3612 if (!(features->device_type & WACOM_DEVICETYPE_PEN))
3615 if (features->device_type & WACOM_DEVICETYPE_DIRECT)
3616 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
3618 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
3620 if (features->type == HID_GENERIC) {
3621 /* setup has already been done; apply otherwise-undetectible quirks */
3622 input_set_capability(input_dev, EV_KEY, BTN_STYLUS3);
3626 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3627 __set_bit(BTN_TOUCH, input_dev->keybit);
3628 __set_bit(ABS_MISC, input_dev->absbit);
3630 input_set_abs_params(input_dev, ABS_X, 0 + features->offset_left,
3631 features->x_max - features->offset_right,
3632 features->x_fuzz, 0);
3633 input_set_abs_params(input_dev, ABS_Y, 0 + features->offset_top,
3634 features->y_max - features->offset_bottom,
3635 features->y_fuzz, 0);
3636 input_set_abs_params(input_dev, ABS_PRESSURE, 0,
3637 features->pressure_max, features->pressure_fuzz, 0);
3639 /* penabled devices have fixed resolution for each model */
3640 input_abs_set_res(input_dev, ABS_X, features->x_resolution);
3641 input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
3643 switch (features->type) {
3645 __clear_bit(ABS_MISC, input_dev->absbit);
3649 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3650 features->distance_max,
3651 features->distance_fuzz, 0);
3655 input_set_capability(input_dev, EV_REL, REL_WHEEL);
3657 __set_bit(BTN_LEFT, input_dev->keybit);
3658 __set_bit(BTN_RIGHT, input_dev->keybit);
3659 __set_bit(BTN_MIDDLE, input_dev->keybit);
3661 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3662 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3663 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
3664 __set_bit(BTN_STYLUS, input_dev->keybit);
3665 __set_bit(BTN_STYLUS2, input_dev->keybit);
3677 case CINTIQ_COMPANION_2:
3678 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3679 input_abs_set_res(input_dev, ABS_Z, 287);
3680 wacom_setup_cintiq(wacom_wac);
3690 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3691 input_abs_set_res(input_dev, ABS_Z, 287);
3695 wacom_setup_intuos(wacom_wac);
3705 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3706 features->distance_max,
3707 features->distance_fuzz, 0);
3709 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3710 input_abs_set_res(input_dev, ABS_Z, 287);
3712 wacom_setup_intuos(wacom_wac);
3723 __clear_bit(ABS_MISC, input_dev->absbit);
3730 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3731 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3732 __set_bit(BTN_STYLUS, input_dev->keybit);
3733 __set_bit(BTN_STYLUS2, input_dev->keybit);
3737 __set_bit(BTN_STYLUS2, input_dev->keybit);
3741 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3742 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3743 __set_bit(BTN_STYLUS, input_dev->keybit);
3751 if (features->type == INTUOSHT2 ||
3752 features->type == INTUOSHT3_BT) {
3753 wacom_setup_basic_pro_pen(wacom_wac);
3755 __clear_bit(ABS_MISC, input_dev->absbit);
3756 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3757 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3758 __set_bit(BTN_STYLUS, input_dev->keybit);
3759 __set_bit(BTN_STYLUS2, input_dev->keybit);
3760 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3761 features->distance_max,
3762 features->distance_fuzz, 0);
3766 __clear_bit(ABS_MISC, input_dev->absbit);
3772 int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
3773 struct wacom_wac *wacom_wac)
3775 struct wacom_features *features = &wacom_wac->features;
3777 if (!(features->device_type & WACOM_DEVICETYPE_TOUCH))
3780 if (features->device_type & WACOM_DEVICETYPE_DIRECT)
3781 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
3783 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
3785 if (features->type == HID_GENERIC)
3786 /* setup has already been done */
3789 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3790 __set_bit(BTN_TOUCH, input_dev->keybit);
3792 if (features->touch_max == 1) {
3793 input_set_abs_params(input_dev, ABS_X, 0,
3794 features->x_max, features->x_fuzz, 0);
3795 input_set_abs_params(input_dev, ABS_Y, 0,
3796 features->y_max, features->y_fuzz, 0);
3797 input_abs_set_res(input_dev, ABS_X,
3798 features->x_resolution);
3799 input_abs_set_res(input_dev, ABS_Y,
3800 features->y_resolution);
3802 else if (features->touch_max > 1) {
3803 input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
3804 features->x_max, features->x_fuzz, 0);
3805 input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
3806 features->y_max, features->y_fuzz, 0);
3807 input_abs_set_res(input_dev, ABS_MT_POSITION_X,
3808 features->x_resolution);
3809 input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
3810 features->y_resolution);
3813 switch (features->type) {
3815 input_dev->evbit[0] |= BIT_MASK(EV_SW);
3816 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
3818 if (wacom_wac->shared->touch->product == 0x361) {
3819 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
3821 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
3824 else if (wacom_wac->shared->touch->product == 0x360) {
3825 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
3827 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
3830 input_abs_set_res(input_dev, ABS_MT_POSITION_X, 40);
3831 input_abs_set_res(input_dev, ABS_MT_POSITION_Y, 40);
3841 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
3842 input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, features->y_max, 0, 0);
3843 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
3847 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
3848 input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
3849 input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
3850 input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
3858 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT);
3867 input_dev->evbit[0] |= BIT_MASK(EV_SW);
3868 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
3873 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
3874 input_set_abs_params(input_dev,
3876 0, features->x_max, 0, 0);
3877 input_set_abs_params(input_dev,
3879 0, features->y_max, 0, 0);
3881 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
3885 input_mt_init_slots(input_dev, features->touch_max,
3887 __set_bit(BTN_LEFT, input_dev->keybit);
3888 __set_bit(BTN_RIGHT, input_dev->keybit);
3894 static int wacom_numbered_button_to_key(int n)
3899 return BTN_A + (n-10);
3901 return BTN_BASE + (n-16);
3906 static void wacom_setup_numbered_buttons(struct input_dev *input_dev,
3911 for (i = 0; i < button_count; i++) {
3912 int key = wacom_numbered_button_to_key(i);
3915 __set_bit(key, input_dev->keybit);
3919 static void wacom_24hd_update_leds(struct wacom *wacom, int mask, int group)
3921 struct wacom_led *led;
3923 bool updated = false;
3926 * 24HD has LED group 1 to the left and LED group 0 to the right.
3927 * So group 0 matches the second half of the buttons and thus the mask
3928 * needs to be shifted.
3933 for (i = 0; i < 3; i++) {
3934 led = wacom_led_find(wacom, group, i);
3936 hid_err(wacom->hdev, "can't find LED %d in group %d\n",
3940 if (!updated && mask & BIT(i)) {
3942 led_trigger_event(&led->trigger, LED_FULL);
3949 static bool wacom_is_led_toggled(struct wacom *wacom, int button_count,
3950 int mask, int group)
3955 * 21UX2 has LED group 1 to the left and LED group 0
3956 * to the right. We need to reverse the group to match this
3957 * historical behavior.
3959 if (wacom->wacom_wac.features.type == WACOM_21UX2)
3962 group_button = group * (button_count/wacom->led.count);
3964 if (wacom->wacom_wac.features.type == INTUOSP2_BT)
3967 return mask & (1 << group_button);
3970 static void wacom_update_led(struct wacom *wacom, int button_count, int mask,
3973 struct wacom_led *led, *next_led;
3977 if (wacom->wacom_wac.features.type == WACOM_24HD)
3978 return wacom_24hd_update_leds(wacom, mask, group);
3980 pressed = wacom_is_led_toggled(wacom, button_count, mask, group);
3981 cur = wacom->led.groups[group].select;
3983 led = wacom_led_find(wacom, group, cur);
3985 hid_err(wacom->hdev, "can't find current LED %d in group %d\n",
3995 if (led->held && pressed)
3998 next_led = wacom_led_next(wacom, led);
4000 hid_err(wacom->hdev, "can't find next LED in group %d\n",
4004 if (next_led == led)
4007 next_led->held = true;
4008 led_trigger_event(&next_led->trigger,
4009 wacom_leds_brightness_get(next_led));
4012 static void wacom_report_numbered_buttons(struct input_dev *input_dev,
4013 int button_count, int mask)
4015 struct wacom *wacom = input_get_drvdata(input_dev);
4018 for (i = 0; i < wacom->led.count; i++)
4019 wacom_update_led(wacom, button_count, mask, i);
4021 for (i = 0; i < button_count; i++) {
4022 int key = wacom_numbered_button_to_key(i);
4025 input_report_key(input_dev, key, mask & (1 << i));
4029 int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
4030 struct wacom_wac *wacom_wac)
4032 struct wacom_features *features = &wacom_wac->features;
4034 if ((features->type == HID_GENERIC) && features->numbered_buttons > 0)
4035 features->device_type |= WACOM_DEVICETYPE_PAD;
4037 if (!(features->device_type & WACOM_DEVICETYPE_PAD))
4040 if (features->type == REMOTE && input_dev == wacom_wac->pad_input)
4043 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
4045 /* kept for making legacy xf86-input-wacom working with the wheels */
4046 __set_bit(ABS_MISC, input_dev->absbit);
4048 /* kept for making legacy xf86-input-wacom accepting the pad */
4049 if (!(input_dev->absinfo && (input_dev->absinfo[ABS_X].minimum ||
4050 input_dev->absinfo[ABS_X].maximum)))
4051 input_set_abs_params(input_dev, ABS_X, 0, 1, 0, 0);
4052 if (!(input_dev->absinfo && (input_dev->absinfo[ABS_Y].minimum ||
4053 input_dev->absinfo[ABS_Y].maximum)))
4054 input_set_abs_params(input_dev, ABS_Y, 0, 1, 0, 0);
4056 /* kept for making udev and libwacom accepting the pad */
4057 __set_bit(BTN_STYLUS, input_dev->keybit);
4059 wacom_setup_numbered_buttons(input_dev, features->numbered_buttons);
4061 switch (features->type) {
4064 case CINTIQ_COMPANION_2:
4071 __set_bit(BTN_BACK, input_dev->keybit);
4072 __set_bit(BTN_LEFT, input_dev->keybit);
4073 __set_bit(BTN_FORWARD, input_dev->keybit);
4074 __set_bit(BTN_RIGHT, input_dev->keybit);
4075 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4079 __set_bit(BTN_BACK, input_dev->keybit);
4080 __set_bit(BTN_FORWARD, input_dev->keybit);
4081 input_set_capability(input_dev, EV_REL, REL_WHEEL);
4085 __set_bit(KEY_PROG1, input_dev->keybit);
4086 __set_bit(KEY_PROG2, input_dev->keybit);
4087 __set_bit(KEY_PROG3, input_dev->keybit);
4089 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4090 input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
4094 __set_bit(KEY_PROG1, input_dev->keybit);
4095 __set_bit(KEY_PROG2, input_dev->keybit);
4096 __set_bit(KEY_PROG3, input_dev->keybit);
4097 input_set_abs_params(input_dev, ABS_X, -2048, 2048, 0, 0);
4098 input_abs_set_res(input_dev, ABS_X, 1024); /* points/g */
4099 input_set_abs_params(input_dev, ABS_Y, -2048, 2048, 0, 0);
4100 input_abs_set_res(input_dev, ABS_Y, 1024);
4101 input_set_abs_params(input_dev, ABS_Z, -2048, 2048, 0, 0);
4102 input_abs_set_res(input_dev, ABS_Z, 1024);
4103 __set_bit(INPUT_PROP_ACCELEROMETER, input_dev->propbit);
4107 __set_bit(KEY_PROG1, input_dev->keybit);
4108 __set_bit(KEY_PROG2, input_dev->keybit);
4109 __set_bit(KEY_PROG3, input_dev->keybit);
4115 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
4116 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
4120 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4125 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
4129 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
4139 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4144 * For Bluetooth devices, the udev rule does not work correctly
4145 * for pads unless we add a stylus capability, which forces
4146 * ID_INPUT_TABLET to be set.
4148 __set_bit(BTN_STYLUS, input_dev->keybit);
4154 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4161 __clear_bit(ABS_MISC, input_dev->absbit);
4163 __set_bit(BTN_LEFT, input_dev->keybit);
4164 __set_bit(BTN_FORWARD, input_dev->keybit);
4165 __set_bit(BTN_BACK, input_dev->keybit);
4166 __set_bit(BTN_RIGHT, input_dev->keybit);
4171 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
4172 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4180 /* no pad supported */
4186 static const struct wacom_features wacom_features_0x00 =
4187 { "Wacom Penpartner", 5040, 3780, 255, 0,
4188 PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
4189 static const struct wacom_features wacom_features_0x10 =
4190 { "Wacom Graphire", 10206, 7422, 511, 63,
4191 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4192 static const struct wacom_features wacom_features_0x81 =
4193 { "Wacom Graphire BT", 16704, 12064, 511, 32,
4194 GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES, 2 };
4195 static const struct wacom_features wacom_features_0x11 =
4196 { "Wacom Graphire2 4x5", 10206, 7422, 511, 63,
4197 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4198 static const struct wacom_features wacom_features_0x12 =
4199 { "Wacom Graphire2 5x7", 13918, 10206, 511, 63,
4200 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4201 static const struct wacom_features wacom_features_0x13 =
4202 { "Wacom Graphire3", 10208, 7424, 511, 63,
4203 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4204 static const struct wacom_features wacom_features_0x14 =
4205 { "Wacom Graphire3 6x8", 16704, 12064, 511, 63,
4206 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4207 static const struct wacom_features wacom_features_0x15 =
4208 { "Wacom Graphire4 4x5", 10208, 7424, 511, 63,
4209 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4210 static const struct wacom_features wacom_features_0x16 =
4211 { "Wacom Graphire4 6x8", 16704, 12064, 511, 63,
4212 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4213 static const struct wacom_features wacom_features_0x17 =
4214 { "Wacom BambooFun 4x5", 14760, 9225, 511, 63,
4215 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4216 static const struct wacom_features wacom_features_0x18 =
4217 { "Wacom BambooFun 6x8", 21648, 13530, 511, 63,
4218 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4219 static const struct wacom_features wacom_features_0x19 =
4220 { "Wacom Bamboo1 Medium", 16704, 12064, 511, 63,
4221 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4222 static const struct wacom_features wacom_features_0x60 =
4223 { "Wacom Volito", 5104, 3712, 511, 63,
4224 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4225 static const struct wacom_features wacom_features_0x61 =
4226 { "Wacom PenStation2", 3250, 2320, 255, 63,
4227 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4228 static const struct wacom_features wacom_features_0x62 =
4229 { "Wacom Volito2 4x5", 5104, 3712, 511, 63,
4230 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4231 static const struct wacom_features wacom_features_0x63 =
4232 { "Wacom Volito2 2x3", 3248, 2320, 511, 63,
4233 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4234 static const struct wacom_features wacom_features_0x64 =
4235 { "Wacom PenPartner2", 3250, 2320, 511, 63,
4236 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4237 static const struct wacom_features wacom_features_0x65 =
4238 { "Wacom Bamboo", 14760, 9225, 511, 63,
4239 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4240 static const struct wacom_features wacom_features_0x69 =
4241 { "Wacom Bamboo1", 5104, 3712, 511, 63,
4242 GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
4243 static const struct wacom_features wacom_features_0x6A =
4244 { "Wacom Bamboo1 4x6", 14760, 9225, 1023, 63,
4245 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4246 static const struct wacom_features wacom_features_0x6B =
4247 { "Wacom Bamboo1 5x8", 21648, 13530, 1023, 63,
4248 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4249 static const struct wacom_features wacom_features_0x20 =
4250 { "Wacom Intuos 4x5", 12700, 10600, 1023, 31,
4251 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4252 static const struct wacom_features wacom_features_0x21 =
4253 { "Wacom Intuos 6x8", 20320, 16240, 1023, 31,
4254 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4255 static const struct wacom_features wacom_features_0x22 =
4256 { "Wacom Intuos 9x12", 30480, 24060, 1023, 31,
4257 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4258 static const struct wacom_features wacom_features_0x23 =
4259 { "Wacom Intuos 12x12", 30480, 31680, 1023, 31,
4260 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4261 static const struct wacom_features wacom_features_0x24 =
4262 { "Wacom Intuos 12x18", 45720, 31680, 1023, 31,
4263 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4264 static const struct wacom_features wacom_features_0x30 =
4265 { "Wacom PL400", 5408, 4056, 255, 0,
4266 PL, WACOM_PL_RES, WACOM_PL_RES };
4267 static const struct wacom_features wacom_features_0x31 =
4268 { "Wacom PL500", 6144, 4608, 255, 0,
4269 PL, WACOM_PL_RES, WACOM_PL_RES };
4270 static const struct wacom_features wacom_features_0x32 =
4271 { "Wacom PL600", 6126, 4604, 255, 0,
4272 PL, WACOM_PL_RES, WACOM_PL_RES };
4273 static const struct wacom_features wacom_features_0x33 =
4274 { "Wacom PL600SX", 6260, 5016, 255, 0,
4275 PL, WACOM_PL_RES, WACOM_PL_RES };
4276 static const struct wacom_features wacom_features_0x34 =
4277 { "Wacom PL550", 6144, 4608, 511, 0,
4278 PL, WACOM_PL_RES, WACOM_PL_RES };
4279 static const struct wacom_features wacom_features_0x35 =
4280 { "Wacom PL800", 7220, 5780, 511, 0,
4281 PL, WACOM_PL_RES, WACOM_PL_RES };
4282 static const struct wacom_features wacom_features_0x37 =
4283 { "Wacom PL700", 6758, 5406, 511, 0,
4284 PL, WACOM_PL_RES, WACOM_PL_RES };
4285 static const struct wacom_features wacom_features_0x38 =
4286 { "Wacom PL510", 6282, 4762, 511, 0,
4287 PL, WACOM_PL_RES, WACOM_PL_RES };
4288 static const struct wacom_features wacom_features_0x39 =
4289 { "Wacom DTU710", 34080, 27660, 511, 0,
4290 PL, WACOM_PL_RES, WACOM_PL_RES };
4291 static const struct wacom_features wacom_features_0xC4 =
4292 { "Wacom DTF521", 6282, 4762, 511, 0,
4293 PL, WACOM_PL_RES, WACOM_PL_RES };
4294 static const struct wacom_features wacom_features_0xC0 =
4295 { "Wacom DTF720", 6858, 5506, 511, 0,
4296 PL, WACOM_PL_RES, WACOM_PL_RES };
4297 static const struct wacom_features wacom_features_0xC2 =
4298 { "Wacom DTF720a", 6858, 5506, 511, 0,
4299 PL, WACOM_PL_RES, WACOM_PL_RES };
4300 static const struct wacom_features wacom_features_0x03 =
4301 { "Wacom Cintiq Partner", 20480, 15360, 511, 0,
4302 PTU, WACOM_PL_RES, WACOM_PL_RES };
4303 static const struct wacom_features wacom_features_0x41 =
4304 { "Wacom Intuos2 4x5", 12700, 10600, 1023, 31,
4305 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4306 static const struct wacom_features wacom_features_0x42 =
4307 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
4308 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4309 static const struct wacom_features wacom_features_0x43 =
4310 { "Wacom Intuos2 9x12", 30480, 24060, 1023, 31,
4311 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4312 static const struct wacom_features wacom_features_0x44 =
4313 { "Wacom Intuos2 12x12", 30480, 31680, 1023, 31,
4314 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4315 static const struct wacom_features wacom_features_0x45 =
4316 { "Wacom Intuos2 12x18", 45720, 31680, 1023, 31,
4317 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4318 static const struct wacom_features wacom_features_0xB0 =
4319 { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63,
4320 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
4321 static const struct wacom_features wacom_features_0xB1 =
4322 { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63,
4323 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4324 static const struct wacom_features wacom_features_0xB2 =
4325 { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63,
4326 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4327 static const struct wacom_features wacom_features_0xB3 =
4328 { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63,
4329 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4330 static const struct wacom_features wacom_features_0xB4 =
4331 { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63,
4332 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4333 static const struct wacom_features wacom_features_0xB5 =
4334 { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63,
4335 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4336 static const struct wacom_features wacom_features_0xB7 =
4337 { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63,
4338 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
4339 static const struct wacom_features wacom_features_0xB8 =
4340 { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63,
4341 INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
4342 static const struct wacom_features wacom_features_0xB9 =
4343 { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63,
4344 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4345 static const struct wacom_features wacom_features_0xBA =
4346 { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63,
4347 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4348 static const struct wacom_features wacom_features_0xBB =
4349 { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63,
4350 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4351 static const struct wacom_features wacom_features_0xBC =
4352 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
4353 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4354 static const struct wacom_features wacom_features_0xBD =
4355 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
4356 INTUOS4WL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4357 static const struct wacom_features wacom_features_0x26 =
4358 { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63,
4359 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16 };
4360 static const struct wacom_features wacom_features_0x27 =
4361 { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63,
4362 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
4363 static const struct wacom_features wacom_features_0x28 =
4364 { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63,
4365 INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
4366 static const struct wacom_features wacom_features_0x29 =
4367 { "Wacom Intuos5 S", 31496, 19685, 2047, 63,
4368 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
4369 static const struct wacom_features wacom_features_0x2A =
4370 { "Wacom Intuos5 M", 44704, 27940, 2047, 63,
4371 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4372 static const struct wacom_features wacom_features_0x314 =
4373 { "Wacom Intuos Pro S", 31496, 19685, 2047, 63,
4374 INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16,
4375 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4376 static const struct wacom_features wacom_features_0x315 =
4377 { "Wacom Intuos Pro M", 44704, 27940, 2047, 63,
4378 INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
4379 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4380 static const struct wacom_features wacom_features_0x317 =
4381 { "Wacom Intuos Pro L", 65024, 40640, 2047, 63,
4382 INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
4383 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4384 static const struct wacom_features wacom_features_0xF4 =
4385 { "Wacom Cintiq 24HD", 104480, 65600, 2047, 63,
4386 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
4387 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4388 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4389 static const struct wacom_features wacom_features_0xF8 =
4390 { "Wacom Cintiq 24HD touch", 104480, 65600, 2047, 63, /* Pen */
4391 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
4392 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4393 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4394 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 };
4395 static const struct wacom_features wacom_features_0xF6 =
4396 { "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */
4397 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10,
4398 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4399 static const struct wacom_features wacom_features_0x32A =
4400 { "Wacom Cintiq 27QHD", 120140, 67920, 2047, 63,
4401 WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
4402 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4403 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4404 static const struct wacom_features wacom_features_0x32B =
4405 { "Wacom Cintiq 27QHD touch", 120140, 67920, 2047, 63,
4406 WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
4407 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4408 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4409 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32C };
4410 static const struct wacom_features wacom_features_0x32C =
4411 { "Wacom Cintiq 27QHD touch", .type = WACOM_27QHDT,
4412 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32B, .touch_max = 10 };
4413 static const struct wacom_features wacom_features_0x3F =
4414 { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63,
4415 CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4416 static const struct wacom_features wacom_features_0xC5 =
4417 { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63,
4418 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
4419 static const struct wacom_features wacom_features_0xC6 =
4420 { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63,
4421 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
4422 static const struct wacom_features wacom_features_0x304 =
4423 { "Wacom Cintiq 13HD", 59552, 33848, 1023, 63,
4424 WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4425 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4426 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4427 static const struct wacom_features wacom_features_0x333 =
4428 { "Wacom Cintiq 13HD touch", 59552, 33848, 2047, 63,
4429 WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4430 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4431 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4432 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x335 };
4433 static const struct wacom_features wacom_features_0x335 =
4434 { "Wacom Cintiq 13HD touch", .type = WACOM_24HDT, /* Touch */
4435 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x333, .touch_max = 10,
4436 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4437 static const struct wacom_features wacom_features_0xC7 =
4438 { "Wacom DTU1931", 37832, 30305, 511, 0,
4439 PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4440 static const struct wacom_features wacom_features_0xCE =
4441 { "Wacom DTU2231", 47864, 27011, 511, 0,
4442 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4443 .check_for_hid_type = true, .hid_type = HID_TYPE_USBMOUSE };
4444 static const struct wacom_features wacom_features_0xF0 =
4445 { "Wacom DTU1631", 34623, 19553, 511, 0,
4446 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4447 static const struct wacom_features wacom_features_0xFB =
4448 { "Wacom DTU1031", 22096, 13960, 511, 0,
4449 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
4450 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4451 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4452 static const struct wacom_features wacom_features_0x32F =
4453 { "Wacom DTU1031X", 22672, 12928, 511, 0,
4454 DTUSX, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 0,
4455 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4456 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4457 static const struct wacom_features wacom_features_0x336 =
4458 { "Wacom DTU1141", 23672, 13403, 1023, 0,
4459 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
4460 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4461 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4462 static const struct wacom_features wacom_features_0x57 =
4463 { "Wacom DTK2241", 95840, 54260, 2047, 63,
4464 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
4465 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4466 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4467 static const struct wacom_features wacom_features_0x59 = /* Pen */
4468 { "Wacom DTH2242", 95840, 54260, 2047, 63,
4469 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
4470 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4471 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4472 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D };
4473 static const struct wacom_features wacom_features_0x5D = /* Touch */
4474 { "Wacom DTH2242", .type = WACOM_24HDT,
4475 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10,
4476 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4477 static const struct wacom_features wacom_features_0xCC =
4478 { "Wacom Cintiq 21UX2", 87200, 65600, 2047, 63,
4479 WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
4480 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4481 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4482 static const struct wacom_features wacom_features_0xFA =
4483 { "Wacom Cintiq 22HD", 95840, 54260, 2047, 63,
4484 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
4485 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4486 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4487 static const struct wacom_features wacom_features_0x5B =
4488 { "Wacom Cintiq 22HDT", 95840, 54260, 2047, 63,
4489 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
4490 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4491 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4492 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e };
4493 static const struct wacom_features wacom_features_0x5E =
4494 { "Wacom Cintiq 22HDT", .type = WACOM_24HDT,
4495 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5b, .touch_max = 10,
4496 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4497 static const struct wacom_features wacom_features_0x90 =
4498 { "Wacom ISDv4 90", 26202, 16325, 255, 0,
4499 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4500 static const struct wacom_features wacom_features_0x93 =
4501 { "Wacom ISDv4 93", 26202, 16325, 255, 0,
4502 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4503 static const struct wacom_features wacom_features_0x97 =
4504 { "Wacom ISDv4 97", 26202, 16325, 511, 0,
4505 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4506 static const struct wacom_features wacom_features_0x9A =
4507 { "Wacom ISDv4 9A", 26202, 16325, 255, 0,
4508 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4509 static const struct wacom_features wacom_features_0x9F =
4510 { "Wacom ISDv4 9F", 26202, 16325, 255, 0,
4511 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4512 static const struct wacom_features wacom_features_0xE2 =
4513 { "Wacom ISDv4 E2", 26202, 16325, 255, 0,
4514 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4515 static const struct wacom_features wacom_features_0xE3 =
4516 { "Wacom ISDv4 E3", 26202, 16325, 255, 0,
4517 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4518 static const struct wacom_features wacom_features_0xE5 =
4519 { "Wacom ISDv4 E5", 26202, 16325, 255, 0,
4520 MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4521 static const struct wacom_features wacom_features_0xE6 =
4522 { "Wacom ISDv4 E6", 27760, 15694, 255, 0,
4523 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4524 static const struct wacom_features wacom_features_0xEC =
4525 { "Wacom ISDv4 EC", 25710, 14500, 255, 0,
4526 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4527 static const struct wacom_features wacom_features_0xED =
4528 { "Wacom ISDv4 ED", 26202, 16325, 255, 0,
4529 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4530 static const struct wacom_features wacom_features_0xEF =
4531 { "Wacom ISDv4 EF", 26202, 16325, 255, 0,
4532 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4533 static const struct wacom_features wacom_features_0x100 =
4534 { "Wacom ISDv4 100", 26202, 16325, 255, 0,
4535 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4536 static const struct wacom_features wacom_features_0x101 =
4537 { "Wacom ISDv4 101", 26202, 16325, 255, 0,
4538 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4539 static const struct wacom_features wacom_features_0x10D =
4540 { "Wacom ISDv4 10D", 26202, 16325, 255, 0,
4541 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4542 static const struct wacom_features wacom_features_0x10E =
4543 { "Wacom ISDv4 10E", 27760, 15694, 255, 0,
4544 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4545 static const struct wacom_features wacom_features_0x10F =
4546 { "Wacom ISDv4 10F", 27760, 15694, 255, 0,
4547 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4548 static const struct wacom_features wacom_features_0x116 =
4549 { "Wacom ISDv4 116", 26202, 16325, 255, 0,
4550 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4551 static const struct wacom_features wacom_features_0x12C =
4552 { "Wacom ISDv4 12C", 27848, 15752, 2047, 0,
4553 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4554 static const struct wacom_features wacom_features_0x4001 =
4555 { "Wacom ISDv4 4001", 26202, 16325, 255, 0,
4556 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4557 static const struct wacom_features wacom_features_0x4004 =
4558 { "Wacom ISDv4 4004", 11060, 6220, 255, 0,
4559 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4560 static const struct wacom_features wacom_features_0x5000 =
4561 { "Wacom ISDv4 5000", 27848, 15752, 1023, 0,
4562 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4563 static const struct wacom_features wacom_features_0x5002 =
4564 { "Wacom ISDv4 5002", 29576, 16724, 1023, 0,
4565 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4566 static const struct wacom_features wacom_features_0x47 =
4567 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
4568 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4569 static const struct wacom_features wacom_features_0x84 =
4570 { "Wacom Wireless Receiver", .type = WIRELESS, .touch_max = 16 };
4571 static const struct wacom_features wacom_features_0xD0 =
4572 { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31,
4573 BAMBOO_TOUCH, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4574 static const struct wacom_features wacom_features_0xD1 =
4575 { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31,
4576 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4577 static const struct wacom_features wacom_features_0xD2 =
4578 { "Wacom Bamboo Craft", 14720, 9200, 1023, 31,
4579 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4580 static const struct wacom_features wacom_features_0xD3 =
4581 { "Wacom Bamboo 2FG 6x8", 21648, 13700, 1023, 31,
4582 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4583 static const struct wacom_features wacom_features_0xD4 =
4584 { "Wacom Bamboo Pen", 14720, 9200, 1023, 31,
4585 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4586 static const struct wacom_features wacom_features_0xD5 =
4587 { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31,
4588 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4589 static const struct wacom_features wacom_features_0xD6 =
4590 { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31,
4591 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4592 static const struct wacom_features wacom_features_0xD7 =
4593 { "Wacom BambooPT 2FG Small", 14720, 9200, 1023, 31,
4594 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4595 static const struct wacom_features wacom_features_0xD8 =
4596 { "Wacom Bamboo Comic 2FG", 21648, 13700, 1023, 31,
4597 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4598 static const struct wacom_features wacom_features_0xDA =
4599 { "Wacom Bamboo 2FG 4x5 SE", 14720, 9200, 1023, 31,
4600 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4601 static const struct wacom_features wacom_features_0xDB =
4602 { "Wacom Bamboo 2FG 6x8 SE", 21648, 13700, 1023, 31,
4603 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4604 static const struct wacom_features wacom_features_0xDD =
4605 { "Wacom Bamboo Connect", 14720, 9200, 1023, 31,
4606 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4607 static const struct wacom_features wacom_features_0xDE =
4608 { "Wacom Bamboo 16FG 4x5", 14720, 9200, 1023, 31,
4609 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
4610 static const struct wacom_features wacom_features_0xDF =
4611 { "Wacom Bamboo 16FG 6x8", 21648, 13700, 1023, 31,
4612 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
4613 static const struct wacom_features wacom_features_0x300 =
4614 { "Wacom Bamboo One S", 14720, 9225, 1023, 31,
4615 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4616 static const struct wacom_features wacom_features_0x301 =
4617 { "Wacom Bamboo One M", 21648, 13530, 1023, 31,
4618 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4619 static const struct wacom_features wacom_features_0x302 =
4620 { "Wacom Intuos PT S", 15200, 9500, 1023, 31,
4621 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4622 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4623 static const struct wacom_features wacom_features_0x303 =
4624 { "Wacom Intuos PT M", 21600, 13500, 1023, 31,
4625 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4626 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4627 static const struct wacom_features wacom_features_0x30E =
4628 { "Wacom Intuos S", 15200, 9500, 1023, 31,
4629 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4630 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4631 static const struct wacom_features wacom_features_0x6004 =
4632 { "ISD-V4", 12800, 8000, 255, 0,
4633 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4634 static const struct wacom_features wacom_features_0x307 =
4635 { "Wacom ISDv5 307", 59552, 33848, 2047, 63,
4636 CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4637 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4638 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4639 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 };
4640 static const struct wacom_features wacom_features_0x309 =
4641 { "Wacom ISDv5 309", .type = WACOM_24HDT, /* Touch */
4642 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x0307, .touch_max = 10,
4643 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4644 static const struct wacom_features wacom_features_0x30A =
4645 { "Wacom ISDv5 30A", 59552, 33848, 2047, 63,
4646 CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4647 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4648 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4649 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30C };
4650 static const struct wacom_features wacom_features_0x30C =
4651 { "Wacom ISDv5 30C", .type = WACOM_24HDT, /* Touch */
4652 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30A, .touch_max = 10,
4653 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4654 static const struct wacom_features wacom_features_0x318 =
4655 { "Wacom USB Bamboo PAD", 4095, 4095, /* Touch */
4656 .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
4657 static const struct wacom_features wacom_features_0x319 =
4658 { "Wacom Wireless Bamboo PAD", 4095, 4095, /* Touch */
4659 .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
4660 static const struct wacom_features wacom_features_0x325 =
4661 { "Wacom ISDv5 325", 59552, 33848, 2047, 63,
4662 CINTIQ_COMPANION_2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 11,
4663 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4664 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4665 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x326 };
4666 static const struct wacom_features wacom_features_0x326 = /* Touch */
4667 { "Wacom ISDv5 326", .type = HID_GENERIC, .oVid = USB_VENDOR_ID_WACOM,
4669 static const struct wacom_features wacom_features_0x323 =
4670 { "Wacom Intuos P M", 21600, 13500, 1023, 31,
4671 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4672 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4673 static const struct wacom_features wacom_features_0x331 =
4674 { "Wacom Express Key Remote", .type = REMOTE,
4675 .numbered_buttons = 18, .check_for_hid_type = true,
4676 .hid_type = HID_TYPE_USBNONE };
4677 static const struct wacom_features wacom_features_0x33B =
4678 { "Wacom Intuos S 2", 15200, 9500, 2047, 63,
4679 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4680 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4681 static const struct wacom_features wacom_features_0x33C =
4682 { "Wacom Intuos PT S 2", 15200, 9500, 2047, 63,
4683 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4684 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4685 static const struct wacom_features wacom_features_0x33D =
4686 { "Wacom Intuos P M 2", 21600, 13500, 2047, 63,
4687 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4688 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4689 static const struct wacom_features wacom_features_0x33E =
4690 { "Wacom Intuos PT M 2", 21600, 13500, 2047, 63,
4691 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4692 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4693 static const struct wacom_features wacom_features_0x343 =
4694 { "Wacom DTK1651", 34816, 19759, 1023, 0,
4695 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
4696 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4697 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4698 static const struct wacom_features wacom_features_0x360 =
4699 { "Wacom Intuos Pro M", 44800, 29600, 8191, 63,
4700 INTUOSP2_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 10 };
4701 static const struct wacom_features wacom_features_0x361 =
4702 { "Wacom Intuos Pro L", 62200, 43200, 8191, 63,
4703 INTUOSP2_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 10 };
4704 static const struct wacom_features wacom_features_0x377 =
4705 { "Wacom Intuos BT S", 15200, 9500, 4095, 63,
4706 INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
4707 static const struct wacom_features wacom_features_0x379 =
4708 { "Wacom Intuos BT M", 21600, 13500, 4095, 63,
4709 INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
4710 static const struct wacom_features wacom_features_0x37A =
4711 { "Wacom One by Wacom S", 15200, 9500, 2047, 63,
4712 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4713 static const struct wacom_features wacom_features_0x37B =
4714 { "Wacom One by Wacom M", 21600, 13500, 2047, 63,
4715 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4717 static const struct wacom_features wacom_features_HID_ANY_ID =
4718 { "Wacom HID", .type = HID_GENERIC, .oVid = HID_ANY_ID, .oPid = HID_ANY_ID };
4720 static const struct wacom_features wacom_features_0x94 =
4721 { "Wacom Bootloader", .type = BOOTLOADER };
4723 #define USB_DEVICE_WACOM(prod) \
4724 HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4725 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4727 #define BT_DEVICE_WACOM(prod) \
4728 HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4729 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4731 #define I2C_DEVICE_WACOM(prod) \
4732 HID_DEVICE(BUS_I2C, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4733 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4735 #define USB_DEVICE_LENOVO(prod) \
4736 HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
4737 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4739 const struct hid_device_id wacom_ids[] = {
4740 { USB_DEVICE_WACOM(0x00) },
4741 { USB_DEVICE_WACOM(0x03) },
4742 { USB_DEVICE_WACOM(0x10) },
4743 { USB_DEVICE_WACOM(0x11) },
4744 { USB_DEVICE_WACOM(0x12) },
4745 { USB_DEVICE_WACOM(0x13) },
4746 { USB_DEVICE_WACOM(0x14) },
4747 { USB_DEVICE_WACOM(0x15) },
4748 { USB_DEVICE_WACOM(0x16) },
4749 { USB_DEVICE_WACOM(0x17) },
4750 { USB_DEVICE_WACOM(0x18) },
4751 { USB_DEVICE_WACOM(0x19) },
4752 { USB_DEVICE_WACOM(0x20) },
4753 { USB_DEVICE_WACOM(0x21) },
4754 { USB_DEVICE_WACOM(0x22) },
4755 { USB_DEVICE_WACOM(0x23) },
4756 { USB_DEVICE_WACOM(0x24) },
4757 { USB_DEVICE_WACOM(0x26) },
4758 { USB_DEVICE_WACOM(0x27) },
4759 { USB_DEVICE_WACOM(0x28) },
4760 { USB_DEVICE_WACOM(0x29) },
4761 { USB_DEVICE_WACOM(0x2A) },
4762 { USB_DEVICE_WACOM(0x30) },
4763 { USB_DEVICE_WACOM(0x31) },
4764 { USB_DEVICE_WACOM(0x32) },
4765 { USB_DEVICE_WACOM(0x33) },
4766 { USB_DEVICE_WACOM(0x34) },
4767 { USB_DEVICE_WACOM(0x35) },
4768 { USB_DEVICE_WACOM(0x37) },
4769 { USB_DEVICE_WACOM(0x38) },
4770 { USB_DEVICE_WACOM(0x39) },
4771 { USB_DEVICE_WACOM(0x3F) },
4772 { USB_DEVICE_WACOM(0x41) },
4773 { USB_DEVICE_WACOM(0x42) },
4774 { USB_DEVICE_WACOM(0x43) },
4775 { USB_DEVICE_WACOM(0x44) },
4776 { USB_DEVICE_WACOM(0x45) },
4777 { USB_DEVICE_WACOM(0x47) },
4778 { USB_DEVICE_WACOM(0x57) },
4779 { USB_DEVICE_WACOM(0x59) },
4780 { USB_DEVICE_WACOM(0x5B) },
4781 { USB_DEVICE_WACOM(0x5D) },
4782 { USB_DEVICE_WACOM(0x5E) },
4783 { USB_DEVICE_WACOM(0x60) },
4784 { USB_DEVICE_WACOM(0x61) },
4785 { USB_DEVICE_WACOM(0x62) },
4786 { USB_DEVICE_WACOM(0x63) },
4787 { USB_DEVICE_WACOM(0x64) },
4788 { USB_DEVICE_WACOM(0x65) },
4789 { USB_DEVICE_WACOM(0x69) },
4790 { USB_DEVICE_WACOM(0x6A) },
4791 { USB_DEVICE_WACOM(0x6B) },
4792 { BT_DEVICE_WACOM(0x81) },
4793 { USB_DEVICE_WACOM(0x84) },
4794 { USB_DEVICE_WACOM(0x90) },
4795 { USB_DEVICE_WACOM(0x93) },
4796 { USB_DEVICE_WACOM(0x94) },
4797 { USB_DEVICE_WACOM(0x97) },
4798 { USB_DEVICE_WACOM(0x9A) },
4799 { USB_DEVICE_WACOM(0x9F) },
4800 { USB_DEVICE_WACOM(0xB0) },
4801 { USB_DEVICE_WACOM(0xB1) },
4802 { USB_DEVICE_WACOM(0xB2) },
4803 { USB_DEVICE_WACOM(0xB3) },
4804 { USB_DEVICE_WACOM(0xB4) },
4805 { USB_DEVICE_WACOM(0xB5) },
4806 { USB_DEVICE_WACOM(0xB7) },
4807 { USB_DEVICE_WACOM(0xB8) },
4808 { USB_DEVICE_WACOM(0xB9) },
4809 { USB_DEVICE_WACOM(0xBA) },
4810 { USB_DEVICE_WACOM(0xBB) },
4811 { USB_DEVICE_WACOM(0xBC) },
4812 { BT_DEVICE_WACOM(0xBD) },
4813 { USB_DEVICE_WACOM(0xC0) },
4814 { USB_DEVICE_WACOM(0xC2) },
4815 { USB_DEVICE_WACOM(0xC4) },
4816 { USB_DEVICE_WACOM(0xC5) },
4817 { USB_DEVICE_WACOM(0xC6) },
4818 { USB_DEVICE_WACOM(0xC7) },
4819 { USB_DEVICE_WACOM(0xCC) },
4820 { USB_DEVICE_WACOM(0xCE) },
4821 { USB_DEVICE_WACOM(0xD0) },
4822 { USB_DEVICE_WACOM(0xD1) },
4823 { USB_DEVICE_WACOM(0xD2) },
4824 { USB_DEVICE_WACOM(0xD3) },
4825 { USB_DEVICE_WACOM(0xD4) },
4826 { USB_DEVICE_WACOM(0xD5) },
4827 { USB_DEVICE_WACOM(0xD6) },
4828 { USB_DEVICE_WACOM(0xD7) },
4829 { USB_DEVICE_WACOM(0xD8) },
4830 { USB_DEVICE_WACOM(0xDA) },
4831 { USB_DEVICE_WACOM(0xDB) },
4832 { USB_DEVICE_WACOM(0xDD) },
4833 { USB_DEVICE_WACOM(0xDE) },
4834 { USB_DEVICE_WACOM(0xDF) },
4835 { USB_DEVICE_WACOM(0xE2) },
4836 { USB_DEVICE_WACOM(0xE3) },
4837 { USB_DEVICE_WACOM(0xE5) },
4838 { USB_DEVICE_WACOM(0xE6) },
4839 { USB_DEVICE_WACOM(0xEC) },
4840 { USB_DEVICE_WACOM(0xED) },
4841 { USB_DEVICE_WACOM(0xEF) },
4842 { USB_DEVICE_WACOM(0xF0) },
4843 { USB_DEVICE_WACOM(0xF4) },
4844 { USB_DEVICE_WACOM(0xF6) },
4845 { USB_DEVICE_WACOM(0xF8) },
4846 { USB_DEVICE_WACOM(0xFA) },
4847 { USB_DEVICE_WACOM(0xFB) },
4848 { USB_DEVICE_WACOM(0x100) },
4849 { USB_DEVICE_WACOM(0x101) },
4850 { USB_DEVICE_WACOM(0x10D) },
4851 { USB_DEVICE_WACOM(0x10E) },
4852 { USB_DEVICE_WACOM(0x10F) },
4853 { USB_DEVICE_WACOM(0x116) },
4854 { USB_DEVICE_WACOM(0x12C) },
4855 { USB_DEVICE_WACOM(0x300) },
4856 { USB_DEVICE_WACOM(0x301) },
4857 { USB_DEVICE_WACOM(0x302) },
4858 { USB_DEVICE_WACOM(0x303) },
4859 { USB_DEVICE_WACOM(0x304) },
4860 { USB_DEVICE_WACOM(0x307) },
4861 { USB_DEVICE_WACOM(0x309) },
4862 { USB_DEVICE_WACOM(0x30A) },
4863 { USB_DEVICE_WACOM(0x30C) },
4864 { USB_DEVICE_WACOM(0x30E) },
4865 { USB_DEVICE_WACOM(0x314) },
4866 { USB_DEVICE_WACOM(0x315) },
4867 { USB_DEVICE_WACOM(0x317) },
4868 { USB_DEVICE_WACOM(0x318) },
4869 { USB_DEVICE_WACOM(0x319) },
4870 { USB_DEVICE_WACOM(0x323) },
4871 { USB_DEVICE_WACOM(0x325) },
4872 { USB_DEVICE_WACOM(0x326) },
4873 { USB_DEVICE_WACOM(0x32A) },
4874 { USB_DEVICE_WACOM(0x32B) },
4875 { USB_DEVICE_WACOM(0x32C) },
4876 { USB_DEVICE_WACOM(0x32F) },
4877 { USB_DEVICE_WACOM(0x331) },
4878 { USB_DEVICE_WACOM(0x333) },
4879 { USB_DEVICE_WACOM(0x335) },
4880 { USB_DEVICE_WACOM(0x336) },
4881 { USB_DEVICE_WACOM(0x33B) },
4882 { USB_DEVICE_WACOM(0x33C) },
4883 { USB_DEVICE_WACOM(0x33D) },
4884 { USB_DEVICE_WACOM(0x33E) },
4885 { USB_DEVICE_WACOM(0x343) },
4886 { BT_DEVICE_WACOM(0x360) },
4887 { BT_DEVICE_WACOM(0x361) },
4888 { BT_DEVICE_WACOM(0x377) },
4889 { BT_DEVICE_WACOM(0x379) },
4890 { USB_DEVICE_WACOM(0x37A) },
4891 { USB_DEVICE_WACOM(0x37B) },
4892 { USB_DEVICE_WACOM(0x4001) },
4893 { USB_DEVICE_WACOM(0x4004) },
4894 { USB_DEVICE_WACOM(0x5000) },
4895 { USB_DEVICE_WACOM(0x5002) },
4896 { USB_DEVICE_LENOVO(0x6004) },
4898 { USB_DEVICE_WACOM(HID_ANY_ID) },
4899 { I2C_DEVICE_WACOM(HID_ANY_ID) },
4900 { BT_DEVICE_WACOM(HID_ANY_ID) },
4903 MODULE_DEVICE_TABLE(hid, wacom_ids);