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>
19 /* resolution for penabled devices */
20 #define WACOM_PL_RES 20
21 #define WACOM_PENPRTN_RES 40
22 #define WACOM_VOLITO_RES 50
23 #define WACOM_GRAPHIRE_RES 80
24 #define WACOM_INTUOS_RES 100
25 #define WACOM_INTUOS3_RES 200
27 /* Newer Cintiq and DTU have an offset between tablet and screen areas */
28 #define WACOM_DTU_OFFSET 200
29 #define WACOM_CINTIQ_OFFSET 400
32 * Scale factor relating reported contact size to logical contact area.
33 * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo
35 #define WACOM_CONTACT_AREA_SCALE 2607
37 static bool touch_arbitration = 1;
38 module_param(touch_arbitration, bool, 0644);
39 MODULE_PARM_DESC(touch_arbitration, " on (Y) off (N)");
41 static void wacom_report_numbered_buttons(struct input_dev *input_dev,
42 int button_count, int mask);
44 static int wacom_numbered_button_to_key(int n);
46 static void wacom_update_led(struct wacom *wacom, int button_count, int mask,
49 * Percent of battery capacity for Graphire.
50 * 8th value means AC online and show 100% capacity.
52 static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
55 * Percent of battery capacity for Intuos4 WL, AC has a separate bit.
57 static unsigned short batcap_i4[8] = { 1, 15, 30, 45, 60, 70, 85, 100 };
59 static void __wacom_notify_battery(struct wacom_battery *battery,
60 int bat_status, int bat_capacity,
61 bool bat_charging, bool bat_connected,
64 bool changed = battery->bat_status != bat_status ||
65 battery->battery_capacity != bat_capacity ||
66 battery->bat_charging != bat_charging ||
67 battery->bat_connected != bat_connected ||
68 battery->ps_connected != ps_connected;
71 battery->bat_status = bat_status;
72 battery->battery_capacity = bat_capacity;
73 battery->bat_charging = bat_charging;
74 battery->bat_connected = bat_connected;
75 battery->ps_connected = ps_connected;
78 power_supply_changed(battery->battery);
82 static void wacom_notify_battery(struct wacom_wac *wacom_wac,
83 int bat_status, int bat_capacity, bool bat_charging,
84 bool bat_connected, bool ps_connected)
86 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
88 __wacom_notify_battery(&wacom->battery, bat_status, bat_capacity,
89 bat_charging, bat_connected, ps_connected);
92 static int wacom_penpartner_irq(struct wacom_wac *wacom)
94 unsigned char *data = wacom->data;
95 struct input_dev *input = wacom->pen_input;
100 wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
101 wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID;
102 input_report_key(input, wacom->tool[0], 1);
103 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
104 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
105 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
106 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
107 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127));
108 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
110 input_report_key(input, wacom->tool[0], 0);
111 input_report_abs(input, ABS_MISC, 0); /* report tool id */
112 input_report_abs(input, ABS_PRESSURE, -1);
113 input_report_key(input, BTN_TOUCH, 0);
118 input_report_key(input, BTN_TOOL_PEN, 1);
119 input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
120 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
121 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
122 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
123 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
124 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
128 dev_dbg(input->dev.parent,
129 "%s: received unknown report #%d\n", __func__, data[0]);
136 static int wacom_pl_irq(struct wacom_wac *wacom)
138 struct wacom_features *features = &wacom->features;
139 unsigned char *data = wacom->data;
140 struct input_dev *input = wacom->pen_input;
143 if (data[0] != WACOM_REPORT_PENABLED) {
144 dev_dbg(input->dev.parent,
145 "%s: received unknown report #%d\n", __func__, data[0]);
149 prox = data[1] & 0x40;
152 if ((data[0] & 0x10) || (data[4] & 0x20)) {
153 wacom->tool[0] = BTN_TOOL_RUBBER;
154 wacom->id[0] = ERASER_DEVICE_ID;
157 wacom->tool[0] = BTN_TOOL_PEN;
158 wacom->id[0] = STYLUS_DEVICE_ID;
162 /* If the eraser is in prox, STYLUS2 is always set. If we
163 * mis-detected the type and notice that STYLUS2 isn't set
164 * then force the eraser out of prox and let the pen in.
166 if (wacom->tool[0] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
167 input_report_key(input, BTN_TOOL_RUBBER, 0);
168 input_report_abs(input, ABS_MISC, 0);
170 wacom->tool[0] = BTN_TOOL_PEN;
171 wacom->id[0] = STYLUS_DEVICE_ID;
175 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
176 if (features->pressure_max > 255)
177 pressure = (pressure << 1) | ((data[4] >> 6) & 1);
178 pressure += (features->pressure_max + 1) / 2;
180 input_report_abs(input, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
181 input_report_abs(input, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
182 input_report_abs(input, ABS_PRESSURE, pressure);
184 input_report_key(input, BTN_TOUCH, data[4] & 0x08);
185 input_report_key(input, BTN_STYLUS, data[4] & 0x10);
186 /* Only allow the stylus2 button to be reported for the pen tool. */
187 input_report_key(input, BTN_STYLUS2, (wacom->tool[0] == BTN_TOOL_PEN) && (data[4] & 0x20));
192 input_report_key(input, wacom->tool[0], prox);
193 input_report_abs(input, ABS_MISC, wacom->id[0]);
197 static int wacom_ptu_irq(struct wacom_wac *wacom)
199 unsigned char *data = wacom->data;
200 struct input_dev *input = wacom->pen_input;
202 if (data[0] != WACOM_REPORT_PENABLED) {
203 dev_dbg(input->dev.parent,
204 "%s: received unknown report #%d\n", __func__, data[0]);
208 if (data[1] & 0x04) {
209 input_report_key(input, BTN_TOOL_RUBBER, data[1] & 0x20);
210 input_report_key(input, BTN_TOUCH, data[1] & 0x08);
211 wacom->id[0] = ERASER_DEVICE_ID;
213 input_report_key(input, BTN_TOOL_PEN, data[1] & 0x20);
214 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
215 wacom->id[0] = STYLUS_DEVICE_ID;
217 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
218 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
219 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
220 input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6]));
221 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
222 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
226 static int wacom_dtu_irq(struct wacom_wac *wacom)
228 unsigned char *data = wacom->data;
229 struct input_dev *input = wacom->pen_input;
230 int prox = data[1] & 0x20;
232 dev_dbg(input->dev.parent,
233 "%s: received report #%d", __func__, data[0]);
236 /* Going into proximity select tool */
237 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
238 if (wacom->tool[0] == BTN_TOOL_PEN)
239 wacom->id[0] = STYLUS_DEVICE_ID;
241 wacom->id[0] = ERASER_DEVICE_ID;
243 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
244 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
245 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
246 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
247 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x01) << 8) | data[6]);
248 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
249 if (!prox) /* out-prox */
251 input_report_key(input, wacom->tool[0], prox);
252 input_report_abs(input, ABS_MISC, wacom->id[0]);
256 static int wacom_dtus_irq(struct wacom_wac *wacom)
258 unsigned char *data = wacom->data;
259 struct input_dev *input = wacom->pen_input;
260 unsigned short prox, pressure = 0;
262 if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) {
263 dev_dbg(input->dev.parent,
264 "%s: received unknown report #%d", __func__, data[0]);
266 } else if (data[0] == WACOM_REPORT_DTUSPAD) {
267 input = wacom->pad_input;
268 input_report_key(input, BTN_0, (data[1] & 0x01));
269 input_report_key(input, BTN_1, (data[1] & 0x02));
270 input_report_key(input, BTN_2, (data[1] & 0x04));
271 input_report_key(input, BTN_3, (data[1] & 0x08));
272 input_report_abs(input, ABS_MISC,
273 data[1] & 0x0f ? PAD_DEVICE_ID : 0);
276 prox = data[1] & 0x80;
278 switch ((data[1] >> 3) & 3) {
280 wacom->tool[0] = BTN_TOOL_RUBBER;
281 wacom->id[0] = ERASER_DEVICE_ID;
285 wacom->tool[0] = BTN_TOOL_PEN;
286 wacom->id[0] = STYLUS_DEVICE_ID;
291 input_report_key(input, BTN_STYLUS, data[1] & 0x20);
292 input_report_key(input, BTN_STYLUS2, data[1] & 0x40);
293 input_report_abs(input, ABS_X, get_unaligned_be16(&data[3]));
294 input_report_abs(input, ABS_Y, get_unaligned_be16(&data[5]));
295 pressure = ((data[1] & 0x03) << 8) | (data[2] & 0xff);
296 input_report_abs(input, ABS_PRESSURE, pressure);
297 input_report_key(input, BTN_TOUCH, pressure > 10);
299 if (!prox) /* out-prox */
301 input_report_key(input, wacom->tool[0], prox);
302 input_report_abs(input, ABS_MISC, wacom->id[0]);
307 static int wacom_graphire_irq(struct wacom_wac *wacom)
309 struct wacom_features *features = &wacom->features;
310 unsigned char *data = wacom->data;
311 struct input_dev *input = wacom->pen_input;
312 struct input_dev *pad_input = wacom->pad_input;
313 int battery_capacity, ps_connected;
318 if (features->type == GRAPHIRE_BT) {
319 if (data[0] != WACOM_REPORT_PENABLED_BT) {
320 dev_dbg(input->dev.parent,
321 "%s: received unknown report #%d\n", __func__,
325 } else if (data[0] != WACOM_REPORT_PENABLED) {
326 dev_dbg(input->dev.parent,
327 "%s: received unknown report #%d\n", __func__, data[0]);
331 prox = data[1] & 0x80;
332 if (prox || wacom->id[0]) {
334 switch ((data[1] >> 5) & 3) {
337 wacom->tool[0] = BTN_TOOL_PEN;
338 wacom->id[0] = STYLUS_DEVICE_ID;
342 wacom->tool[0] = BTN_TOOL_RUBBER;
343 wacom->id[0] = ERASER_DEVICE_ID;
346 case 2: /* Mouse with wheel */
347 input_report_key(input, BTN_MIDDLE, data[1] & 0x04);
350 case 3: /* Mouse without wheel */
351 wacom->tool[0] = BTN_TOOL_MOUSE;
352 wacom->id[0] = CURSOR_DEVICE_ID;
356 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
357 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
358 if (wacom->tool[0] != BTN_TOOL_MOUSE) {
359 if (features->type == GRAPHIRE_BT)
360 input_report_abs(input, ABS_PRESSURE, data[6] |
361 (((__u16) (data[1] & 0x08)) << 5));
363 input_report_abs(input, ABS_PRESSURE, data[6] |
364 ((data[7] & 0x03) << 8));
365 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
366 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
367 input_report_key(input, BTN_STYLUS2, data[1] & 0x04);
369 input_report_key(input, BTN_LEFT, data[1] & 0x01);
370 input_report_key(input, BTN_RIGHT, data[1] & 0x02);
371 if (features->type == WACOM_G4 ||
372 features->type == WACOM_MO) {
373 input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f);
374 rw = (data[7] & 0x04) - (data[7] & 0x03);
375 } else if (features->type == GRAPHIRE_BT) {
376 /* Compute distance between mouse and tablet */
377 rw = 44 - (data[6] >> 2);
378 rw = clamp_val(rw, 0, 31);
379 input_report_abs(input, ABS_DISTANCE, rw);
380 if (((data[1] >> 5) & 3) == 2) {
381 /* Mouse with wheel */
382 input_report_key(input, BTN_MIDDLE,
384 rw = (data[6] & 0x01) ? -1 :
385 (data[6] & 0x02) ? 1 : 0;
390 input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f);
391 rw = -(signed char)data[6];
393 input_report_rel(input, REL_WHEEL, rw);
398 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
399 input_report_key(input, wacom->tool[0], prox);
400 input_sync(input); /* sync last event */
404 switch (features->type) {
406 prox = data[7] & 0xf8;
407 if (prox || wacom->id[1]) {
408 wacom->id[1] = PAD_DEVICE_ID;
409 input_report_key(pad_input, BTN_BACK, (data[7] & 0x40));
410 input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x80));
411 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
412 input_report_rel(pad_input, REL_WHEEL, rw);
415 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
421 prox = (data[7] & 0xf8) || data[8];
422 if (prox || wacom->id[1]) {
423 wacom->id[1] = PAD_DEVICE_ID;
424 input_report_key(pad_input, BTN_BACK, (data[7] & 0x08));
425 input_report_key(pad_input, BTN_LEFT, (data[7] & 0x20));
426 input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x10));
427 input_report_key(pad_input, BTN_RIGHT, (data[7] & 0x40));
428 input_report_abs(pad_input, ABS_WHEEL, (data[8] & 0x7f));
431 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
436 prox = data[7] & 0x03;
437 if (prox || wacom->id[1]) {
438 wacom->id[1] = PAD_DEVICE_ID;
439 input_report_key(pad_input, BTN_0, (data[7] & 0x02));
440 input_report_key(pad_input, BTN_1, (data[7] & 0x01));
443 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
449 /* Store current battery capacity and power supply state */
450 if (features->type == GRAPHIRE_BT) {
451 rw = (data[7] >> 2 & 0x07);
452 battery_capacity = batcap_gr[rw];
453 ps_connected = rw == 7;
454 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
455 battery_capacity, ps_connected, 1,
462 static void wacom_intuos_schedule_prox_event(struct wacom_wac *wacom_wac)
464 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
465 struct wacom_features *features = &wacom_wac->features;
466 struct hid_report *r;
467 struct hid_report_enum *re;
469 re = &(wacom->hdev->report_enum[HID_FEATURE_REPORT]);
470 if (features->type == INTUOSHT2)
471 r = re->report_id_hash[WACOM_REPORT_INTUOSHT2_ID];
473 r = re->report_id_hash[WACOM_REPORT_INTUOS_ID1];
475 hid_hw_request(wacom->hdev, r, HID_REQ_GET_REPORT);
479 static int wacom_intuos_pad(struct wacom_wac *wacom)
481 struct wacom_features *features = &wacom->features;
482 unsigned char *data = wacom->data;
483 struct input_dev *input = wacom->pad_input;
485 int buttons = 0, nbuttons = features->numbered_buttons;
486 int keys = 0, nkeys = 0;
487 int ring1 = 0, ring2 = 0;
488 int strip1 = 0, strip2 = 0;
491 /* pad packets. Works as a second tool and is always in prox */
492 if (!(data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD ||
493 data[0] == WACOM_REPORT_CINTIQPAD))
496 if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
497 buttons = (data[3] << 1) | (data[2] & 0x01);
499 } else if (features->type == DTK) {
501 } else if (features->type == WACOM_13HD) {
502 buttons = (data[4] << 1) | (data[3] & 0x01);
503 } else if (features->type == WACOM_24HD) {
504 buttons = (data[8] << 8) | data[6];
509 * Three "buttons" are available on the 24HD which are
510 * physically implemented as a touchstrip. Each button
511 * is approximately 3 bits wide with a 2 bit spacing.
512 * The raw touchstrip bits are stored at:
513 * ((data[3] & 0x1f) << 8) | data[4])
516 keys = ((data[3] & 0x1C) ? 1<<2 : 0) |
517 ((data[4] & 0xE0) ? 1<<1 : 0) |
518 ((data[4] & 0x07) ? 1<<0 : 0);
519 } else if (features->type == WACOM_27QHD) {
521 keys = data[2] & 0x07;
523 input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[4]));
524 input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[6]));
525 input_report_abs(input, ABS_Z, be16_to_cpup((__be16 *)&data[8]));
526 } else if (features->type == CINTIQ_HYBRID) {
528 * Do not send hardware buttons under Android. They
529 * are already sent to the system through GPIO (and
530 * have different meaning).
532 * d-pad right -> data[4] & 0x10
533 * d-pad up -> data[4] & 0x20
534 * d-pad left -> data[4] & 0x40
535 * d-pad down -> data[4] & 0x80
536 * d-pad center -> data[3] & 0x01
538 buttons = (data[4] << 1) | (data[3] & 0x01);
539 } else if (features->type == CINTIQ_COMPANION_2) {
540 /* d-pad right -> data[2] & 0x10
541 * d-pad up -> data[2] & 0x20
542 * d-pad left -> data[2] & 0x40
543 * d-pad down -> data[2] & 0x80
544 * d-pad center -> data[1] & 0x01
546 buttons = ((data[2] >> 4) << 7) |
547 ((data[1] & 0x04) << 4) |
548 ((data[2] & 0x0F) << 2) |
550 } else if (features->type >= INTUOS5S && features->type <= INTUOSPL) {
552 * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in
553 * addition to the mechanical switch. Switch data is
554 * stored in data[4], capacitive data in data[5].
556 * Touch ring mode switch (data[3]) has no capacitive sensor
558 buttons = (data[4] << 1) | (data[3] & 0x01);
561 if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) {
562 buttons = (data[8] << 10) | ((data[7] & 0x01) << 9) |
563 (data[6] << 1) | (data[5] & 0x01);
565 if (features->type == WACOM_22HD) {
567 keys = data[9] & 0x07;
570 buttons = ((data[6] & 0x10) << 5) |
571 ((data[5] & 0x10) << 4) |
572 ((data[6] & 0x0F) << 4) |
575 strip1 = ((data[1] & 0x1f) << 8) | data[2];
576 strip2 = ((data[3] & 0x1f) << 8) | data[4];
579 prox = (buttons & ~(~0U << nbuttons)) | (keys & ~(~0U << nkeys)) |
580 (ring1 & 0x80) | (ring2 & 0x80) | strip1 | strip2;
582 wacom_report_numbered_buttons(input, nbuttons, buttons);
584 for (i = 0; i < nkeys; i++)
585 input_report_key(input, KEY_PROG1 + i, keys & (1 << i));
587 input_report_abs(input, ABS_RX, strip1);
588 input_report_abs(input, ABS_RY, strip2);
590 input_report_abs(input, ABS_WHEEL, (ring1 & 0x80) ? (ring1 & 0x7f) : 0);
591 input_report_abs(input, ABS_THROTTLE, (ring2 & 0x80) ? (ring2 & 0x7f) : 0);
593 input_report_key(input, wacom->tool[1], prox ? 1 : 0);
594 input_report_abs(input, ABS_MISC, prox ? PAD_DEVICE_ID : 0);
596 input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff);
601 static int wacom_intuos_id_mangle(int tool_id)
603 return (tool_id & ~0xFFF) << 4 | (tool_id & 0xFFF);
606 static int wacom_intuos_get_tool_type(int tool_id)
611 case 0x812: /* Inking pen */
612 case 0x801: /* Intuos3 Inking pen */
613 case 0x12802: /* Intuos4/5 Inking Pen */
615 tool_type = BTN_TOOL_PENCIL;
618 case 0x822: /* Pen */
621 case 0x823: /* Intuos3 Grip Pen */
622 case 0x813: /* Intuos3 Classic Pen */
623 case 0x885: /* Intuos3 Marker Pen */
624 case 0x802: /* Intuos4/5 13HD/24HD General Pen */
625 case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
626 case 0x8e2: /* IntuosHT2 pen */
628 case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */
629 case 0x14802: /* Intuos4/5 13HD/24HD Classic Pen */
630 case 0x16802: /* Cintiq 13HD Pro Pen */
631 case 0x18802: /* DTH2242 Pen */
632 case 0x10802: /* Intuos4/5 13HD/24HD General Pen */
633 tool_type = BTN_TOOL_PEN;
636 case 0x832: /* Stroke pen */
638 tool_type = BTN_TOOL_BRUSH;
641 case 0x007: /* Mouse 4D and 2D */
644 case 0x017: /* Intuos3 2D Mouse */
645 case 0x806: /* Intuos4 Mouse */
646 tool_type = BTN_TOOL_MOUSE;
649 case 0x096: /* Lens cursor */
650 case 0x097: /* Intuos3 Lens cursor */
651 case 0x006: /* Intuos4 Lens cursor */
652 tool_type = BTN_TOOL_LENS;
655 case 0x82a: /* Eraser */
661 case 0x82b: /* Intuos3 Grip Pen Eraser */
662 case 0x81b: /* Intuos3 Classic Pen Eraser */
663 case 0x91b: /* Intuos3 Airbrush Eraser */
664 case 0x80c: /* Intuos4/5 13HD/24HD Marker Pen Eraser */
665 case 0x80a: /* Intuos4/5 13HD/24HD General Pen Eraser */
666 case 0x90a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
667 case 0x1480a: /* Intuos4/5 13HD/24HD Classic Pen Eraser */
668 case 0x1090a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
669 case 0x1080c: /* Intuos4/5 13HD/24HD Art Pen Eraser */
670 case 0x1680a: /* Cintiq 13HD Pro Pen Eraser */
671 case 0x1880a: /* DTH2242 Eraser */
672 case 0x1080a: /* Intuos4/5 13HD/24HD General Pen Eraser */
673 tool_type = BTN_TOOL_RUBBER;
679 case 0x913: /* Intuos3 Airbrush */
680 case 0x902: /* Intuos4/5 13HD/24HD Airbrush */
681 case 0x10902: /* Intuos4/5 13HD/24HD Airbrush */
682 tool_type = BTN_TOOL_AIRBRUSH;
685 default: /* Unknown tool */
686 tool_type = BTN_TOOL_PEN;
692 static void wacom_exit_report(struct wacom_wac *wacom)
694 struct input_dev *input = wacom->pen_input;
695 struct wacom_features *features = &wacom->features;
696 unsigned char *data = wacom->data;
697 int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
700 * Reset all states otherwise we lose the initial states
701 * when in-prox next time
703 input_report_abs(input, ABS_X, 0);
704 input_report_abs(input, ABS_Y, 0);
705 input_report_abs(input, ABS_DISTANCE, 0);
706 input_report_abs(input, ABS_TILT_X, 0);
707 input_report_abs(input, ABS_TILT_Y, 0);
708 if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
709 input_report_key(input, BTN_LEFT, 0);
710 input_report_key(input, BTN_MIDDLE, 0);
711 input_report_key(input, BTN_RIGHT, 0);
712 input_report_key(input, BTN_SIDE, 0);
713 input_report_key(input, BTN_EXTRA, 0);
714 input_report_abs(input, ABS_THROTTLE, 0);
715 input_report_abs(input, ABS_RZ, 0);
717 input_report_abs(input, ABS_PRESSURE, 0);
718 input_report_key(input, BTN_STYLUS, 0);
719 input_report_key(input, BTN_STYLUS2, 0);
720 input_report_key(input, BTN_TOUCH, 0);
721 input_report_abs(input, ABS_WHEEL, 0);
722 if (features->type >= INTUOS3S)
723 input_report_abs(input, ABS_Z, 0);
725 input_report_key(input, wacom->tool[idx], 0);
726 input_report_abs(input, ABS_MISC, 0); /* reset tool id */
727 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
731 static int wacom_intuos_inout(struct wacom_wac *wacom)
733 struct wacom_features *features = &wacom->features;
734 unsigned char *data = wacom->data;
735 struct input_dev *input = wacom->pen_input;
736 int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
738 if (!(((data[1] & 0xfc) == 0xc0) || /* in prox */
739 ((data[1] & 0xfe) == 0x20) || /* in range */
740 ((data[1] & 0xfe) == 0x80))) /* out prox */
744 if ((data[1] & 0xfc) == 0xc0) {
745 /* serial number of the tool */
746 wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
747 (data[4] << 20) + (data[5] << 12) +
748 (data[6] << 4) + (data[7] >> 4);
750 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) |
751 ((data[7] & 0x0f) << 16) | ((data[8] & 0xf0) << 8);
753 wacom->tool[idx] = wacom_intuos_get_tool_type(wacom->id[idx]);
755 wacom->shared->stylus_in_proximity = true;
760 if ((data[1] & 0xfe) == 0x20) {
761 if (features->type != INTUOSHT2)
762 wacom->shared->stylus_in_proximity = true;
764 /* in Range while exiting */
765 if (wacom->reporting_data) {
766 input_report_key(input, BTN_TOUCH, 0);
767 input_report_abs(input, ABS_PRESSURE, 0);
768 input_report_abs(input, ABS_DISTANCE, wacom->features.distance_max);
775 if ((data[1] & 0xfe) == 0x80) {
776 wacom->shared->stylus_in_proximity = false;
777 wacom->reporting_data = false;
779 /* don't report exit if we don't know the ID */
783 wacom_exit_report(wacom);
790 static inline bool report_touch_events(struct wacom_wac *wacom)
792 return (touch_arbitration ? !wacom->shared->stylus_in_proximity : 1);
795 static inline bool delay_pen_events(struct wacom_wac *wacom)
797 return (wacom->shared->touch_down && touch_arbitration);
800 static int wacom_intuos_general(struct wacom_wac *wacom)
802 struct wacom_features *features = &wacom->features;
803 unsigned char *data = wacom->data;
804 struct input_dev *input = wacom->pen_input;
805 int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
806 unsigned char type = (data[1] >> 1) & 0x0F;
807 unsigned int x, y, distance, t;
809 if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_CINTIQ &&
810 data[0] != WACOM_REPORT_INTUOS_PEN)
813 if (delay_pen_events(wacom))
816 /* don't report events if we don't know the tool ID */
817 if (!wacom->id[idx]) {
818 /* but reschedule a read of the current tool */
819 wacom_intuos_schedule_prox_event(wacom);
824 * don't report events for invalid data
826 /* older I4 styli don't work with new Cintiqs */
827 if ((!((wacom->id[idx] >> 16) & 0x01) &&
828 (features->type == WACOM_21UX2)) ||
829 /* Only large Intuos support Lense Cursor */
830 (wacom->tool[idx] == BTN_TOOL_LENS &&
831 (features->type == INTUOS3 ||
832 features->type == INTUOS3S ||
833 features->type == INTUOS4 ||
834 features->type == INTUOS4S ||
835 features->type == INTUOS5 ||
836 features->type == INTUOS5S ||
837 features->type == INTUOSPM ||
838 features->type == INTUOSPS)) ||
839 /* Cintiq doesn't send data when RDY bit isn't set */
840 (features->type == CINTIQ && !(data[1] & 0x40)))
843 x = (be16_to_cpup((__be16 *)&data[2]) << 1) | ((data[9] >> 1) & 1);
844 y = (be16_to_cpup((__be16 *)&data[4]) << 1) | (data[9] & 1);
845 distance = data[9] >> 2;
846 if (features->type < INTUOS3S) {
851 if (features->type == INTUOSHT2)
852 distance = features->distance_max - distance;
853 input_report_abs(input, ABS_X, x);
854 input_report_abs(input, ABS_Y, y);
855 input_report_abs(input, ABS_DISTANCE, distance);
862 /* general pen packet */
863 t = (data[6] << 3) | ((data[7] & 0xC0) >> 5) | (data[1] & 1);
864 if (features->pressure_max < 2047)
866 input_report_abs(input, ABS_PRESSURE, t);
867 if (features->type != INTUOSHT2) {
868 input_report_abs(input, ABS_TILT_X,
869 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
870 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
872 input_report_key(input, BTN_STYLUS, data[1] & 2);
873 input_report_key(input, BTN_STYLUS2, data[1] & 4);
874 input_report_key(input, BTN_TOUCH, t > 10);
878 /* airbrush second packet */
879 input_report_abs(input, ABS_WHEEL,
880 (data[6] << 2) | ((data[7] >> 6) & 3));
881 input_report_abs(input, ABS_TILT_X,
882 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
883 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
887 /* Rotation packet */
888 if (features->type >= INTUOS3S) {
889 /* I3 marker pen rotation */
890 t = (data[6] << 3) | ((data[7] >> 5) & 7);
891 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
892 ((t-1) / 2 + 450)) : (450 - t / 2) ;
893 input_report_abs(input, ABS_Z, t);
895 /* 4D mouse 2nd packet */
896 t = (data[6] << 3) | ((data[7] >> 5) & 7);
897 input_report_abs(input, ABS_RZ, (data[7] & 0x20) ?
898 ((t - 1) / 2) : -t / 2);
903 /* 4D mouse 1st packet */
904 input_report_key(input, BTN_LEFT, data[8] & 0x01);
905 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
906 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
908 input_report_key(input, BTN_SIDE, data[8] & 0x20);
909 input_report_key(input, BTN_EXTRA, data[8] & 0x10);
910 t = (data[6] << 2) | ((data[7] >> 6) & 3);
911 input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
916 input_report_key(input, BTN_LEFT, data[6] & 0x01);
917 input_report_key(input, BTN_MIDDLE, data[6] & 0x02);
918 input_report_key(input, BTN_RIGHT, data[6] & 0x04);
919 input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7)
920 - ((data[7] & 0x40) >> 6));
921 input_report_key(input, BTN_SIDE, data[6] & 0x08);
922 input_report_key(input, BTN_EXTRA, data[6] & 0x10);
924 input_report_abs(input, ABS_TILT_X,
925 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
926 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
930 if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
931 /* 2D mouse packet */
932 input_report_key(input, BTN_LEFT, data[8] & 0x04);
933 input_report_key(input, BTN_MIDDLE, data[8] & 0x08);
934 input_report_key(input, BTN_RIGHT, data[8] & 0x10);
935 input_report_rel(input, REL_WHEEL, (data[8] & 0x01)
936 - ((data[8] & 0x02) >> 1));
938 /* I3 2D mouse side buttons */
939 if (features->type >= INTUOS3S && features->type <= INTUOS3L) {
940 input_report_key(input, BTN_SIDE, data[8] & 0x40);
941 input_report_key(input, BTN_EXTRA, data[8] & 0x20);
944 else if (wacom->tool[idx] == BTN_TOOL_LENS) {
945 /* Lens cursor packets */
946 input_report_key(input, BTN_LEFT, data[8] & 0x01);
947 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
948 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
949 input_report_key(input, BTN_SIDE, data[8] & 0x10);
950 input_report_key(input, BTN_EXTRA, data[8] & 0x08);
965 input_report_abs(input, ABS_MISC,
966 wacom_intuos_id_mangle(wacom->id[idx])); /* report tool id */
967 input_report_key(input, wacom->tool[idx], 1);
968 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
969 wacom->reporting_data = true;
973 static int wacom_intuos_irq(struct wacom_wac *wacom)
975 unsigned char *data = wacom->data;
976 struct input_dev *input = wacom->pen_input;
979 if (data[0] != WACOM_REPORT_PENABLED &&
980 data[0] != WACOM_REPORT_INTUOS_ID1 &&
981 data[0] != WACOM_REPORT_INTUOS_ID2 &&
982 data[0] != WACOM_REPORT_INTUOSPAD &&
983 data[0] != WACOM_REPORT_INTUOS_PEN &&
984 data[0] != WACOM_REPORT_CINTIQ &&
985 data[0] != WACOM_REPORT_CINTIQPAD &&
986 data[0] != WACOM_REPORT_INTUOS5PAD) {
987 dev_dbg(input->dev.parent,
988 "%s: received unknown report #%d\n", __func__, data[0]);
992 /* process pad events */
993 result = wacom_intuos_pad(wacom);
997 /* process in/out prox events */
998 result = wacom_intuos_inout(wacom);
1002 /* process general packets */
1003 result = wacom_intuos_general(wacom);
1010 static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len)
1012 unsigned char *data = wacom_wac->data;
1013 struct input_dev *input;
1014 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
1015 struct wacom_remote *remote = wacom->remote;
1016 int bat_charging, bat_percent, touch_ring_mode;
1019 unsigned long flags;
1021 if (data[0] != WACOM_REPORT_REMOTE) {
1022 hid_dbg(wacom->hdev, "%s: received unknown report #%d",
1027 serial = data[3] + (data[4] << 8) + (data[5] << 16);
1028 wacom_wac->id[0] = PAD_DEVICE_ID;
1030 spin_lock_irqsave(&remote->remote_lock, flags);
1032 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
1033 if (remote->remotes[i].serial == serial) {
1039 if (index < 0 || !remote->remotes[index].registered)
1042 input = remote->remotes[index].input;
1044 input_report_key(input, BTN_0, (data[9] & 0x01));
1045 input_report_key(input, BTN_1, (data[9] & 0x02));
1046 input_report_key(input, BTN_2, (data[9] & 0x04));
1047 input_report_key(input, BTN_3, (data[9] & 0x08));
1048 input_report_key(input, BTN_4, (data[9] & 0x10));
1049 input_report_key(input, BTN_5, (data[9] & 0x20));
1050 input_report_key(input, BTN_6, (data[9] & 0x40));
1051 input_report_key(input, BTN_7, (data[9] & 0x80));
1053 input_report_key(input, BTN_8, (data[10] & 0x01));
1054 input_report_key(input, BTN_9, (data[10] & 0x02));
1055 input_report_key(input, BTN_A, (data[10] & 0x04));
1056 input_report_key(input, BTN_B, (data[10] & 0x08));
1057 input_report_key(input, BTN_C, (data[10] & 0x10));
1058 input_report_key(input, BTN_X, (data[10] & 0x20));
1059 input_report_key(input, BTN_Y, (data[10] & 0x40));
1060 input_report_key(input, BTN_Z, (data[10] & 0x80));
1062 input_report_key(input, BTN_BASE, (data[11] & 0x01));
1063 input_report_key(input, BTN_BASE2, (data[11] & 0x02));
1065 if (data[12] & 0x80)
1066 input_report_abs(input, ABS_WHEEL, (data[12] & 0x7f) - 1);
1068 input_report_abs(input, ABS_WHEEL, 0);
1070 bat_percent = data[7] & 0x7f;
1071 bat_charging = !!(data[7] & 0x80);
1073 if (data[9] | data[10] | (data[11] & 0x03) | data[12])
1074 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
1076 input_report_abs(input, ABS_MISC, 0);
1078 input_event(input, EV_MSC, MSC_SERIAL, serial);
1082 /*Which mode select (LED light) is currently on?*/
1083 touch_ring_mode = (data[11] & 0xC0) >> 6;
1085 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
1086 if (remote->remotes[i].serial == serial)
1087 wacom->led.groups[i].select = touch_ring_mode;
1090 __wacom_notify_battery(&remote->remotes[index].battery,
1091 WACOM_POWER_SUPPLY_STATUS_AUTO, bat_percent,
1092 bat_charging, 1, bat_charging);
1095 spin_unlock_irqrestore(&remote->remote_lock, flags);
1099 static void wacom_remote_status_irq(struct wacom_wac *wacom_wac, size_t len)
1101 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
1102 unsigned char *data = wacom_wac->data;
1103 struct wacom_remote *remote = wacom->remote;
1104 struct wacom_remote_data remote_data;
1105 unsigned long flags;
1108 if (data[0] != WACOM_REPORT_DEVICE_LIST)
1111 memset(&remote_data, 0, sizeof(struct wacom_remote_data));
1113 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
1115 int serial = (data[j+6] << 16) + (data[j+5] << 8) + data[j+4];
1116 bool connected = data[j+2];
1118 remote_data.remote[i].serial = serial;
1119 remote_data.remote[i].connected = connected;
1122 spin_lock_irqsave(&remote->remote_lock, flags);
1124 ret = kfifo_in(&remote->remote_fifo, &remote_data, sizeof(remote_data));
1125 if (ret != sizeof(remote_data)) {
1126 spin_unlock_irqrestore(&remote->remote_lock, flags);
1127 hid_err(wacom->hdev, "Can't queue Remote status event.\n");
1131 spin_unlock_irqrestore(&remote->remote_lock, flags);
1133 wacom_schedule_work(wacom_wac, WACOM_WORKER_REMOTE);
1136 static int int_dist(int x1, int y1, int x2, int y2)
1141 return int_sqrt(x*x + y*y);
1144 static void wacom_intuos_bt_process_data(struct wacom_wac *wacom,
1145 unsigned char *data)
1147 memcpy(wacom->data, data, 10);
1148 wacom_intuos_irq(wacom);
1150 input_sync(wacom->pen_input);
1151 if (wacom->pad_input)
1152 input_sync(wacom->pad_input);
1155 static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
1157 unsigned char data[WACOM_PKGLEN_MAX];
1159 unsigned power_raw, battery_capacity, bat_charging, ps_connected;
1161 memcpy(data, wacom->data, len);
1165 wacom_intuos_bt_process_data(wacom, data + i);
1169 wacom_intuos_bt_process_data(wacom, data + i);
1171 wacom_intuos_bt_process_data(wacom, data + i);
1173 power_raw = data[i];
1174 bat_charging = (power_raw & 0x08) ? 1 : 0;
1175 ps_connected = (power_raw & 0x10) ? 1 : 0;
1176 battery_capacity = batcap_i4[power_raw & 0x07];
1177 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
1178 battery_capacity, bat_charging,
1179 battery_capacity || bat_charging,
1183 dev_dbg(wacom->pen_input->dev.parent,
1184 "Unknown report: %d,%d size:%zu\n",
1185 data[0], data[1], len);
1191 static int wacom_wac_finger_count_touches(struct wacom_wac *wacom)
1193 struct input_dev *input = wacom->touch_input;
1194 unsigned touch_max = wacom->features.touch_max;
1202 return test_bit(BTN_TOUCH, input->key) &&
1203 report_touch_events(wacom);
1205 for (i = 0; i < input->mt->num_slots; i++) {
1206 struct input_mt_slot *ps = &input->mt->slots[i];
1207 int id = input_mt_get_value(ps, ABS_MT_TRACKING_ID);
1215 static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
1217 int pen_frame_len, pen_frames;
1219 struct input_dev *pen_input = wacom->pen_input;
1220 unsigned char *data = wacom->data;
1223 if (wacom->features.type == INTUOSP2_BT) {
1224 wacom->serial[0] = get_unaligned_le64(&data[99]);
1225 wacom->id[0] = get_unaligned_le16(&data[107]);
1229 wacom->serial[0] = get_unaligned_le64(&data[33]);
1230 wacom->id[0] = get_unaligned_le16(&data[41]);
1235 if (wacom->serial[0] >> 52 == 1) {
1236 /* Add back in missing bits of ID for non-USI pens */
1237 wacom->id[0] |= (wacom->serial[0] >> 32) & 0xFFFFF;
1240 for (i = 0; i < pen_frames; i++) {
1241 unsigned char *frame = &data[i*pen_frame_len + 1];
1242 bool valid = frame[0] & 0x80;
1243 bool prox = frame[0] & 0x40;
1244 bool range = frame[0] & 0x20;
1245 bool invert = frame[0] & 0x10;
1251 wacom->shared->stylus_in_proximity = false;
1252 wacom_exit_report(wacom);
1253 input_sync(pen_input);
1257 wacom->serial[0] = 0;
1262 if (!wacom->tool[0]) { /* first in range */
1263 /* Going into range select tool */
1265 wacom->tool[0] = BTN_TOOL_RUBBER;
1266 else if (wacom->id[0])
1267 wacom->tool[0] = wacom_intuos_get_tool_type(wacom->id[0]);
1269 wacom->tool[0] = BTN_TOOL_PEN;
1272 input_report_abs(pen_input, ABS_X, get_unaligned_le16(&frame[1]));
1273 input_report_abs(pen_input, ABS_Y, get_unaligned_le16(&frame[3]));
1275 if (wacom->features.type == INTUOSP2_BT) {
1276 /* Fix rotation alignment: userspace expects zero at left */
1278 (int16_t)get_unaligned_le16(&frame[9]);
1284 input_report_abs(pen_input, ABS_TILT_X,
1286 input_report_abs(pen_input, ABS_TILT_Y,
1288 input_report_abs(pen_input, ABS_Z, rotation);
1289 input_report_abs(pen_input, ABS_WHEEL,
1290 get_unaligned_le16(&frame[11]));
1294 if (wacom->tool[0]) {
1295 input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5]));
1296 if (wacom->features.type == INTUOSP2_BT) {
1297 input_report_abs(pen_input, ABS_DISTANCE,
1298 range ? frame[13] : wacom->features.distance_max);
1300 input_report_abs(pen_input, ABS_DISTANCE,
1301 range ? frame[7] : wacom->features.distance_max);
1304 input_report_key(pen_input, BTN_TOUCH, frame[0] & 0x09);
1305 input_report_key(pen_input, BTN_STYLUS, frame[0] & 0x02);
1306 input_report_key(pen_input, BTN_STYLUS2, frame[0] & 0x04);
1308 input_report_key(pen_input, wacom->tool[0], prox);
1309 input_event(pen_input, EV_MSC, MSC_SERIAL, wacom->serial[0]);
1310 input_report_abs(pen_input, ABS_MISC,
1311 wacom_intuos_id_mangle(wacom->id[0])); /* report tool id */
1314 wacom->shared->stylus_in_proximity = prox;
1316 input_sync(pen_input);
1320 static void wacom_intuos_pro2_bt_touch(struct wacom_wac *wacom)
1322 const int finger_touch_len = 8;
1323 const int finger_frames = 4;
1324 const int finger_frame_len = 43;
1326 struct input_dev *touch_input = wacom->touch_input;
1327 unsigned char *data = wacom->data;
1328 int num_contacts_left = 5;
1331 for (i = 0; i < finger_frames; i++) {
1332 unsigned char *frame = &data[i*finger_frame_len + 109];
1333 int current_num_contacts = frame[0] & 0x7F;
1334 int contacts_to_send;
1336 if (!(frame[0] & 0x80))
1340 * First packet resets the counter since only the first
1341 * packet in series will have non-zero current_num_contacts.
1343 if (current_num_contacts)
1344 wacom->num_contacts_left = current_num_contacts;
1346 contacts_to_send = min(num_contacts_left, wacom->num_contacts_left);
1348 for (j = 0; j < contacts_to_send; j++) {
1349 unsigned char *touch = &frame[j*finger_touch_len + 1];
1350 int slot = input_mt_get_slot_by_key(touch_input, touch[0]);
1351 int x = get_unaligned_le16(&touch[2]);
1352 int y = get_unaligned_le16(&touch[4]);
1353 int w = touch[6] * input_abs_get_res(touch_input, ABS_MT_POSITION_X);
1354 int h = touch[7] * input_abs_get_res(touch_input, ABS_MT_POSITION_Y);
1359 input_mt_slot(touch_input, slot);
1360 input_mt_report_slot_state(touch_input, MT_TOOL_FINGER, touch[1] & 0x01);
1361 input_report_abs(touch_input, ABS_MT_POSITION_X, x);
1362 input_report_abs(touch_input, ABS_MT_POSITION_Y, y);
1363 input_report_abs(touch_input, ABS_MT_TOUCH_MAJOR, max(w, h));
1364 input_report_abs(touch_input, ABS_MT_TOUCH_MINOR, min(w, h));
1365 input_report_abs(touch_input, ABS_MT_ORIENTATION, w > h);
1368 input_mt_sync_frame(touch_input);
1370 wacom->num_contacts_left -= contacts_to_send;
1371 if (wacom->num_contacts_left <= 0) {
1372 wacom->num_contacts_left = 0;
1373 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1374 input_sync(touch_input);
1378 if (wacom->num_contacts_left == 0) {
1379 // Be careful that we don't accidentally call input_sync with
1380 // only a partial set of fingers of processed
1381 input_report_switch(touch_input, SW_MUTE_DEVICE, !(data[281] >> 7));
1382 input_sync(touch_input);
1387 static void wacom_intuos_pro2_bt_pad(struct wacom_wac *wacom)
1389 struct input_dev *pad_input = wacom->pad_input;
1390 unsigned char *data = wacom->data;
1392 int buttons = data[282] | ((data[281] & 0x40) << 2);
1393 int ring = data[285] & 0x7F;
1394 bool ringstatus = data[285] & 0x80;
1395 bool prox = buttons || ringstatus;
1397 /* Fix touchring data: userspace expects 0 at left and increasing clockwise */
1403 wacom_report_numbered_buttons(pad_input, 9, buttons);
1405 input_report_abs(pad_input, ABS_WHEEL, ringstatus ? ring : 0);
1407 input_report_key(pad_input, wacom->tool[1], prox ? 1 : 0);
1408 input_report_abs(pad_input, ABS_MISC, prox ? PAD_DEVICE_ID : 0);
1409 input_event(pad_input, EV_MSC, MSC_SERIAL, 0xffffffff);
1411 input_sync(pad_input);
1414 static void wacom_intuos_pro2_bt_battery(struct wacom_wac *wacom)
1416 unsigned char *data = wacom->data;
1418 bool chg = data[284] & 0x80;
1419 int battery_status = data[284] & 0x7F;
1421 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
1422 battery_status, chg, 1, chg);
1425 static void wacom_intuos_gen3_bt_pad(struct wacom_wac *wacom)
1427 struct input_dev *pad_input = wacom->pad_input;
1428 unsigned char *data = wacom->data;
1430 int buttons = data[44];
1432 wacom_report_numbered_buttons(pad_input, 4, buttons);
1434 input_report_key(pad_input, wacom->tool[1], buttons ? 1 : 0);
1435 input_report_abs(pad_input, ABS_MISC, buttons ? PAD_DEVICE_ID : 0);
1436 input_event(pad_input, EV_MSC, MSC_SERIAL, 0xffffffff);
1438 input_sync(pad_input);
1441 static void wacom_intuos_gen3_bt_battery(struct wacom_wac *wacom)
1443 unsigned char *data = wacom->data;
1445 bool chg = data[45] & 0x80;
1446 int battery_status = data[45] & 0x7F;
1448 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
1449 battery_status, chg, 1, chg);
1452 static int wacom_intuos_pro2_bt_irq(struct wacom_wac *wacom, size_t len)
1454 unsigned char *data = wacom->data;
1456 if (data[0] != 0x80 && data[0] != 0x81) {
1457 dev_dbg(wacom->pen_input->dev.parent,
1458 "%s: received unknown report #%d\n", __func__, data[0]);
1462 wacom_intuos_pro2_bt_pen(wacom);
1463 if (wacom->features.type == INTUOSP2_BT) {
1464 wacom_intuos_pro2_bt_touch(wacom);
1465 wacom_intuos_pro2_bt_pad(wacom);
1466 wacom_intuos_pro2_bt_battery(wacom);
1468 wacom_intuos_gen3_bt_pad(wacom);
1469 wacom_intuos_gen3_bt_battery(wacom);
1474 static int wacom_24hdt_irq(struct wacom_wac *wacom)
1476 struct input_dev *input = wacom->touch_input;
1477 unsigned char *data = wacom->data;
1479 int current_num_contacts = data[61];
1480 int contacts_to_send = 0;
1481 int num_contacts_left = 4; /* maximum contacts per packet */
1482 int byte_per_packet = WACOM_BYTES_PER_24HDT_PACKET;
1485 if (wacom->features.type == WACOM_27QHDT) {
1486 current_num_contacts = data[63];
1487 num_contacts_left = 10;
1488 byte_per_packet = WACOM_BYTES_PER_QHDTHID_PACKET;
1493 * First packet resets the counter since only the first
1494 * packet in series will have non-zero current_num_contacts.
1496 if (current_num_contacts)
1497 wacom->num_contacts_left = current_num_contacts;
1499 contacts_to_send = min(num_contacts_left, wacom->num_contacts_left);
1501 for (i = 0; i < contacts_to_send; i++) {
1502 int offset = (byte_per_packet * i) + 1;
1503 bool touch = (data[offset] & 0x1) && report_touch_events(wacom);
1504 int slot = input_mt_get_slot_by_key(input, data[offset + 1]);
1508 input_mt_slot(input, slot);
1509 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1512 int t_x = get_unaligned_le16(&data[offset + 2]);
1513 int t_y = get_unaligned_le16(&data[offset + 4 + y_offset]);
1515 input_report_abs(input, ABS_MT_POSITION_X, t_x);
1516 input_report_abs(input, ABS_MT_POSITION_Y, t_y);
1518 if (wacom->features.type != WACOM_27QHDT) {
1519 int c_x = get_unaligned_le16(&data[offset + 4]);
1520 int c_y = get_unaligned_le16(&data[offset + 8]);
1521 int w = get_unaligned_le16(&data[offset + 10]);
1522 int h = get_unaligned_le16(&data[offset + 12]);
1524 input_report_abs(input, ABS_MT_TOUCH_MAJOR, min(w,h));
1525 input_report_abs(input, ABS_MT_WIDTH_MAJOR,
1526 min(w, h) + int_dist(t_x, t_y, c_x, c_y));
1527 input_report_abs(input, ABS_MT_WIDTH_MINOR, min(w, h));
1528 input_report_abs(input, ABS_MT_ORIENTATION, w > h);
1532 input_mt_sync_frame(input);
1534 wacom->num_contacts_left -= contacts_to_send;
1535 if (wacom->num_contacts_left <= 0) {
1536 wacom->num_contacts_left = 0;
1537 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1542 static int wacom_mt_touch(struct wacom_wac *wacom)
1544 struct input_dev *input = wacom->touch_input;
1545 unsigned char *data = wacom->data;
1547 int current_num_contacts = data[2];
1548 int contacts_to_send = 0;
1551 /* MTTPC does not support Height and Width */
1552 if (wacom->features.type == MTTPC || wacom->features.type == MTTPC_B)
1556 * First packet resets the counter since only the first
1557 * packet in series will have non-zero current_num_contacts.
1559 if (current_num_contacts)
1560 wacom->num_contacts_left = current_num_contacts;
1562 /* There are at most 5 contacts per packet */
1563 contacts_to_send = min(5, wacom->num_contacts_left);
1565 for (i = 0; i < contacts_to_send; i++) {
1566 int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset) * i + 3;
1567 bool touch = (data[offset] & 0x1) && report_touch_events(wacom);
1568 int id = get_unaligned_le16(&data[offset + 1]);
1569 int slot = input_mt_get_slot_by_key(input, id);
1574 input_mt_slot(input, slot);
1575 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1577 int x = get_unaligned_le16(&data[offset + x_offset + 7]);
1578 int y = get_unaligned_le16(&data[offset + x_offset + 9]);
1579 input_report_abs(input, ABS_MT_POSITION_X, x);
1580 input_report_abs(input, ABS_MT_POSITION_Y, y);
1583 input_mt_sync_frame(input);
1585 wacom->num_contacts_left -= contacts_to_send;
1586 if (wacom->num_contacts_left <= 0) {
1587 wacom->num_contacts_left = 0;
1588 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1593 static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
1595 struct input_dev *input = wacom->touch_input;
1596 unsigned char *data = wacom->data;
1599 for (i = 0; i < 2; i++) {
1600 int p = data[1] & (1 << i);
1601 bool touch = p && report_touch_events(wacom);
1603 input_mt_slot(input, i);
1604 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1606 int x = le16_to_cpup((__le16 *)&data[i * 2 + 2]) & 0x7fff;
1607 int y = le16_to_cpup((__le16 *)&data[i * 2 + 6]) & 0x7fff;
1609 input_report_abs(input, ABS_MT_POSITION_X, x);
1610 input_report_abs(input, ABS_MT_POSITION_Y, y);
1613 input_mt_sync_frame(input);
1615 /* keep touch state for pen event */
1616 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1621 static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
1623 unsigned char *data = wacom->data;
1624 struct input_dev *input = wacom->touch_input;
1625 bool prox = report_touch_events(wacom);
1628 if (wacom->features.touch_max > 1 || len > WACOM_PKGLEN_TPC2FG)
1631 if (len == WACOM_PKGLEN_TPC1FG) {
1632 prox = prox && (data[0] & 0x01);
1633 x = get_unaligned_le16(&data[1]);
1634 y = get_unaligned_le16(&data[3]);
1635 } else if (len == WACOM_PKGLEN_TPC1FG_B) {
1636 prox = prox && (data[2] & 0x01);
1637 x = get_unaligned_le16(&data[3]);
1638 y = get_unaligned_le16(&data[5]);
1640 prox = prox && (data[1] & 0x01);
1641 x = le16_to_cpup((__le16 *)&data[2]);
1642 y = le16_to_cpup((__le16 *)&data[4]);
1646 input_report_abs(input, ABS_X, x);
1647 input_report_abs(input, ABS_Y, y);
1649 input_report_key(input, BTN_TOUCH, prox);
1651 /* keep touch state for pen events */
1652 wacom->shared->touch_down = prox;
1657 static int wacom_tpc_pen(struct wacom_wac *wacom)
1659 unsigned char *data = wacom->data;
1660 struct input_dev *input = wacom->pen_input;
1661 bool prox = data[1] & 0x20;
1663 if (!wacom->shared->stylus_in_proximity) /* first in prox */
1664 /* Going into proximity select tool */
1665 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
1667 /* keep pen state for touch events */
1668 wacom->shared->stylus_in_proximity = prox;
1670 /* send pen events only when touch is up or forced out
1671 * or touch arbitration is off
1673 if (!delay_pen_events(wacom)) {
1674 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
1675 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
1676 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
1677 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
1678 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x07) << 8) | data[6]);
1679 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
1680 input_report_key(input, wacom->tool[0], prox);
1687 static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
1689 unsigned char *data = wacom->data;
1691 if (wacom->pen_input) {
1692 dev_dbg(wacom->pen_input->dev.parent,
1693 "%s: received report #%d\n", __func__, data[0]);
1695 if (len == WACOM_PKGLEN_PENABLED ||
1696 data[0] == WACOM_REPORT_PENABLED)
1697 return wacom_tpc_pen(wacom);
1699 else if (wacom->touch_input) {
1700 dev_dbg(wacom->touch_input->dev.parent,
1701 "%s: received report #%d\n", __func__, data[0]);
1704 case WACOM_PKGLEN_TPC1FG:
1705 return wacom_tpc_single_touch(wacom, len);
1707 case WACOM_PKGLEN_TPC2FG:
1708 return wacom_tpc_mt_touch(wacom);
1712 case WACOM_REPORT_TPC1FG:
1713 case WACOM_REPORT_TPCHID:
1714 case WACOM_REPORT_TPCST:
1715 case WACOM_REPORT_TPC1FGE:
1716 return wacom_tpc_single_touch(wacom, len);
1718 case WACOM_REPORT_TPCMT:
1719 case WACOM_REPORT_TPCMT2:
1720 return wacom_mt_touch(wacom);
1729 static int wacom_offset_rotation(struct input_dev *input, struct hid_usage *usage,
1730 int value, int num, int denom)
1732 struct input_absinfo *abs = &input->absinfo[usage->code];
1733 int range = (abs->maximum - abs->minimum + 1);
1735 value += num*range/denom;
1736 if (value > abs->maximum)
1738 else if (value < abs->minimum)
1743 int wacom_equivalent_usage(int usage)
1745 if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMDIGITIZER) {
1746 int subpage = (usage & 0xFF00) << 8;
1747 int subusage = (usage & 0xFF);
1749 if (subpage == WACOM_HID_SP_PAD ||
1750 subpage == WACOM_HID_SP_BUTTON ||
1751 subpage == WACOM_HID_SP_DIGITIZER ||
1752 subpage == WACOM_HID_SP_DIGITIZERINFO ||
1753 usage == WACOM_HID_WD_SENSE ||
1754 usage == WACOM_HID_WD_SERIALHI ||
1755 usage == WACOM_HID_WD_TOOLTYPE ||
1756 usage == WACOM_HID_WD_DISTANCE ||
1757 usage == WACOM_HID_WD_TOUCHSTRIP ||
1758 usage == WACOM_HID_WD_TOUCHSTRIP2 ||
1759 usage == WACOM_HID_WD_TOUCHRING ||
1760 usage == WACOM_HID_WD_TOUCHRINGSTATUS ||
1761 usage == WACOM_HID_WD_REPORT_VALID) {
1765 if (subpage == HID_UP_UNDEFINED)
1766 subpage = HID_UP_DIGITIZER;
1768 return subpage | subusage;
1771 if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMTOUCH) {
1772 int subpage = (usage & 0xFF00) << 8;
1773 int subusage = (usage & 0xFF);
1775 if (subpage == HID_UP_UNDEFINED)
1776 subpage = WACOM_HID_SP_DIGITIZER;
1778 return subpage | subusage;
1784 static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
1785 struct hid_field *field, __u8 type, __u16 code, int fuzz)
1787 struct wacom *wacom = input_get_drvdata(input);
1788 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1789 struct wacom_features *features = &wacom_wac->features;
1790 int fmin = field->logical_minimum;
1791 int fmax = field->logical_maximum;
1792 unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid);
1793 int resolution_code = code;
1795 if (equivalent_usage == HID_DG_TWIST) {
1796 resolution_code = ABS_RZ;
1799 if (equivalent_usage == HID_GD_X) {
1800 fmin += features->offset_left;
1801 fmax -= features->offset_right;
1803 if (equivalent_usage == HID_GD_Y) {
1804 fmin += features->offset_top;
1805 fmax -= features->offset_bottom;
1811 set_bit(type, input->evbit);
1815 input_set_abs_params(input, code, fmin, fmax, fuzz, 0);
1816 input_abs_set_res(input, code,
1817 hidinput_calc_abs_res(field, resolution_code));
1820 input_set_capability(input, EV_KEY, code);
1823 input_set_capability(input, EV_MSC, code);
1826 input_set_capability(input, EV_SW, code);
1831 static void wacom_wac_battery_usage_mapping(struct hid_device *hdev,
1832 struct hid_field *field, struct hid_usage *usage)
1834 struct wacom *wacom = hid_get_drvdata(hdev);
1835 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1836 struct wacom_features *features = &wacom_wac->features;
1837 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
1839 switch (equivalent_usage) {
1840 case HID_DG_BATTERYSTRENGTH:
1841 case WACOM_HID_WD_BATTERY_LEVEL:
1842 case WACOM_HID_WD_BATTERY_CHARGING:
1843 features->quirks |= WACOM_QUIRK_BATTERY;
1848 static void wacom_wac_battery_event(struct hid_device *hdev, struct hid_field *field,
1849 struct hid_usage *usage, __s32 value)
1851 struct wacom *wacom = hid_get_drvdata(hdev);
1852 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1853 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
1855 switch (equivalent_usage) {
1856 case HID_DG_BATTERYSTRENGTH:
1858 wacom_wac->hid_data.bat_status = POWER_SUPPLY_STATUS_UNKNOWN;
1861 value = value * 100 / (field->logical_maximum - field->logical_minimum);
1862 wacom_wac->hid_data.battery_capacity = value;
1863 wacom_wac->hid_data.bat_connected = 1;
1864 wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
1867 case WACOM_HID_WD_BATTERY_LEVEL:
1868 value = value * 100 / (field->logical_maximum - field->logical_minimum);
1869 wacom_wac->hid_data.battery_capacity = value;
1870 wacom_wac->hid_data.bat_connected = 1;
1871 wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
1873 case WACOM_HID_WD_BATTERY_CHARGING:
1874 wacom_wac->hid_data.bat_charging = value;
1875 wacom_wac->hid_data.ps_connected = value;
1876 wacom_wac->hid_data.bat_connected = 1;
1877 wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
1882 static void wacom_wac_battery_pre_report(struct hid_device *hdev,
1883 struct hid_report *report)
1888 static void wacom_wac_battery_report(struct hid_device *hdev,
1889 struct hid_report *report)
1891 struct wacom *wacom = hid_get_drvdata(hdev);
1892 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1893 struct wacom_features *features = &wacom_wac->features;
1895 if (features->quirks & WACOM_QUIRK_BATTERY) {
1896 int status = wacom_wac->hid_data.bat_status;
1897 int capacity = wacom_wac->hid_data.battery_capacity;
1898 bool charging = wacom_wac->hid_data.bat_charging;
1899 bool connected = wacom_wac->hid_data.bat_connected;
1900 bool powered = wacom_wac->hid_data.ps_connected;
1902 wacom_notify_battery(wacom_wac, status, capacity, charging,
1903 connected, powered);
1907 static void wacom_wac_pad_usage_mapping(struct hid_device *hdev,
1908 struct hid_field *field, struct hid_usage *usage)
1910 struct wacom *wacom = hid_get_drvdata(hdev);
1911 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1912 struct wacom_features *features = &wacom_wac->features;
1913 struct input_dev *input = wacom_wac->pad_input;
1914 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
1916 switch (equivalent_usage) {
1917 case WACOM_HID_WD_ACCELEROMETER_X:
1918 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
1919 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 0);
1920 features->device_type |= WACOM_DEVICETYPE_PAD;
1922 case WACOM_HID_WD_ACCELEROMETER_Y:
1923 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
1924 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 0);
1925 features->device_type |= WACOM_DEVICETYPE_PAD;
1927 case WACOM_HID_WD_ACCELEROMETER_Z:
1928 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
1929 wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0);
1930 features->device_type |= WACOM_DEVICETYPE_PAD;
1932 case WACOM_HID_WD_BUTTONCENTER:
1933 case WACOM_HID_WD_BUTTONHOME:
1934 case WACOM_HID_WD_BUTTONUP:
1935 case WACOM_HID_WD_BUTTONDOWN:
1936 case WACOM_HID_WD_BUTTONLEFT:
1937 case WACOM_HID_WD_BUTTONRIGHT:
1938 wacom_map_usage(input, usage, field, EV_KEY,
1939 wacom_numbered_button_to_key(features->numbered_buttons),
1941 features->numbered_buttons++;
1942 features->device_type |= WACOM_DEVICETYPE_PAD;
1944 case WACOM_HID_WD_TOUCHONOFF:
1945 case WACOM_HID_WD_MUTE_DEVICE:
1947 * This usage, which is used to mute touch events, comes
1948 * from the pad packet, but is reported on the touch
1949 * interface. Because the touch interface may not have
1950 * been created yet, we cannot call wacom_map_usage(). In
1951 * order to process this usage when we receive it, we set
1952 * the usage type and code directly.
1954 wacom_wac->has_mute_touch_switch = true;
1955 usage->type = EV_SW;
1956 usage->code = SW_MUTE_DEVICE;
1958 case WACOM_HID_WD_TOUCHSTRIP:
1959 wacom_map_usage(input, usage, field, EV_ABS, ABS_RX, 0);
1960 features->device_type |= WACOM_DEVICETYPE_PAD;
1962 case WACOM_HID_WD_TOUCHSTRIP2:
1963 wacom_map_usage(input, usage, field, EV_ABS, ABS_RY, 0);
1964 features->device_type |= WACOM_DEVICETYPE_PAD;
1966 case WACOM_HID_WD_TOUCHRING:
1967 wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
1968 features->device_type |= WACOM_DEVICETYPE_PAD;
1970 case WACOM_HID_WD_TOUCHRINGSTATUS:
1972 * Only set up type/code association. Completely mapping
1973 * this usage may overwrite the axis resolution and range.
1975 usage->type = EV_ABS;
1976 usage->code = ABS_WHEEL;
1977 set_bit(EV_ABS, input->evbit);
1978 features->device_type |= WACOM_DEVICETYPE_PAD;
1980 case WACOM_HID_WD_BUTTONCONFIG:
1981 wacom_map_usage(input, usage, field, EV_KEY, KEY_BUTTONCONFIG, 0);
1982 features->device_type |= WACOM_DEVICETYPE_PAD;
1984 case WACOM_HID_WD_ONSCREEN_KEYBOARD:
1985 wacom_map_usage(input, usage, field, EV_KEY, KEY_ONSCREEN_KEYBOARD, 0);
1986 features->device_type |= WACOM_DEVICETYPE_PAD;
1988 case WACOM_HID_WD_CONTROLPANEL:
1989 wacom_map_usage(input, usage, field, EV_KEY, KEY_CONTROLPANEL, 0);
1990 features->device_type |= WACOM_DEVICETYPE_PAD;
1992 case WACOM_HID_WD_MODE_CHANGE:
1993 /* do not overwrite previous data */
1994 if (!wacom_wac->has_mode_change) {
1995 wacom_wac->has_mode_change = true;
1996 wacom_wac->is_direct_mode = true;
1998 features->device_type |= WACOM_DEVICETYPE_PAD;
2002 switch (equivalent_usage & 0xfffffff0) {
2003 case WACOM_HID_WD_EXPRESSKEY00:
2004 wacom_map_usage(input, usage, field, EV_KEY,
2005 wacom_numbered_button_to_key(features->numbered_buttons),
2007 features->numbered_buttons++;
2008 features->device_type |= WACOM_DEVICETYPE_PAD;
2013 static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field,
2014 struct hid_usage *usage, __s32 value)
2016 struct wacom *wacom = hid_get_drvdata(hdev);
2017 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2018 struct input_dev *input = wacom_wac->pad_input;
2019 struct wacom_features *features = &wacom_wac->features;
2020 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2022 bool do_report = false;
2025 * Avoid reporting this event and setting inrange_state if this usage
2026 * hasn't been mapped.
2028 if (!usage->type && equivalent_usage != WACOM_HID_WD_MODE_CHANGE)
2031 if (wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY) {
2032 if (usage->hid != WACOM_HID_WD_TOUCHRING)
2033 wacom_wac->hid_data.inrange_state |= value;
2036 /* Process touch switch state first since it is reported through touch interface,
2037 * which is indepentent of pad interface. In the case when there are no other pad
2038 * events, the pad interface will not even be created.
2040 if ((equivalent_usage == WACOM_HID_WD_MUTE_DEVICE) ||
2041 (equivalent_usage == WACOM_HID_WD_TOUCHONOFF)) {
2042 if (wacom_wac->shared->touch_input) {
2043 bool *is_touch_on = &wacom_wac->shared->is_touch_on;
2045 if (equivalent_usage == WACOM_HID_WD_MUTE_DEVICE && value)
2046 *is_touch_on = !(*is_touch_on);
2047 else if (equivalent_usage == WACOM_HID_WD_TOUCHONOFF)
2048 *is_touch_on = value;
2050 input_report_switch(wacom_wac->shared->touch_input,
2051 SW_MUTE_DEVICE, !(*is_touch_on));
2052 input_sync(wacom_wac->shared->touch_input);
2060 switch (equivalent_usage) {
2061 case WACOM_HID_WD_TOUCHRING:
2063 * Userspace expects touchrings to increase in value with
2064 * clockwise gestures and have their zero point at the
2065 * tablet's left. HID events "should" be clockwise-
2066 * increasing and zero at top, though the MobileStudio
2067 * Pro and 2nd-gen Intuos Pro don't do this...
2069 if (hdev->vendor == 0x56a &&
2070 (hdev->product == 0x34d || hdev->product == 0x34e || /* MobileStudio Pro */
2071 hdev->product == 0x357 || hdev->product == 0x358)) { /* Intuos Pro 2 */
2072 value = (field->logical_maximum - value);
2074 if (hdev->product == 0x357 || hdev->product == 0x358)
2075 value = wacom_offset_rotation(input, usage, value, 3, 16);
2076 else if (hdev->product == 0x34d || hdev->product == 0x34e)
2077 value = wacom_offset_rotation(input, usage, value, 1, 2);
2080 value = wacom_offset_rotation(input, usage, value, 1, 4);
2084 case WACOM_HID_WD_TOUCHRINGSTATUS:
2086 input_event(input, usage->type, usage->code, 0);
2089 case WACOM_HID_WD_MODE_CHANGE:
2090 if (wacom_wac->is_direct_mode != value) {
2091 wacom_wac->is_direct_mode = value;
2092 wacom_schedule_work(&wacom->wacom_wac, WACOM_WORKER_MODE_CHANGE);
2096 case WACOM_HID_WD_BUTTONCENTER:
2097 for (i = 0; i < wacom->led.count; i++)
2098 wacom_update_led(wacom, features->numbered_buttons,
2107 input_event(input, usage->type, usage->code, value);
2109 wacom_wac->hid_data.pad_input_event_flag = true;
2113 static void wacom_wac_pad_pre_report(struct hid_device *hdev,
2114 struct hid_report *report)
2116 struct wacom *wacom = hid_get_drvdata(hdev);
2117 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2119 wacom_wac->hid_data.inrange_state = 0;
2122 static void wacom_wac_pad_report(struct hid_device *hdev,
2123 struct hid_report *report, struct hid_field *field)
2125 struct wacom *wacom = hid_get_drvdata(hdev);
2126 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2127 struct input_dev *input = wacom_wac->pad_input;
2128 bool active = wacom_wac->hid_data.inrange_state != 0;
2130 /* report prox for expresskey events */
2131 if (wacom_wac->hid_data.pad_input_event_flag) {
2132 input_event(input, EV_ABS, ABS_MISC, active ? PAD_DEVICE_ID : 0);
2135 wacom_wac->hid_data.pad_input_event_flag = false;
2139 static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
2140 struct hid_field *field, struct hid_usage *usage)
2142 struct wacom *wacom = hid_get_drvdata(hdev);
2143 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2144 struct wacom_features *features = &wacom_wac->features;
2145 struct input_dev *input = wacom_wac->pen_input;
2146 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2148 switch (equivalent_usage) {
2150 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
2153 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
2155 case WACOM_HID_WD_DISTANCE:
2157 wacom_map_usage(input, usage, field, EV_ABS, ABS_DISTANCE, 0);
2159 case HID_DG_TIPPRESSURE:
2160 wacom_map_usage(input, usage, field, EV_ABS, ABS_PRESSURE, 0);
2162 case HID_DG_INRANGE:
2163 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
2166 wacom_map_usage(input, usage, field, EV_KEY,
2167 BTN_TOOL_RUBBER, 0);
2170 wacom_map_usage(input, usage, field, EV_ABS, ABS_TILT_X, 0);
2173 wacom_map_usage(input, usage, field, EV_ABS, ABS_TILT_Y, 0);
2176 wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0);
2179 case HID_DG_TIPSWITCH:
2180 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
2182 case HID_DG_BARRELSWITCH:
2183 wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS, 0);
2185 case HID_DG_BARRELSWITCH2:
2186 wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS2, 0);
2188 case HID_DG_TOOLSERIALNUMBER:
2189 features->quirks |= WACOM_QUIRK_TOOLSERIAL;
2190 wacom_map_usage(input, usage, field, EV_MSC, MSC_SERIAL, 0);
2192 /* Adjust AES usages to match modern convention */
2193 if (usage->hid == WACOM_HID_WT_SERIALNUMBER && field->report_size == 16) {
2194 if (field->index + 2 < field->report->maxfield) {
2195 struct hid_field *a = field->report->field[field->index + 1];
2196 struct hid_field *b = field->report->field[field->index + 2];
2198 if (a->maxusage > 0 && a->usage[0].hid == HID_DG_TOOLSERIALNUMBER && a->report_size == 32 &&
2199 b->maxusage > 0 && b->usage[0].hid == 0xFF000000 && b->report_size == 8) {
2200 features->quirks |= WACOM_QUIRK_AESPEN;
2201 usage->hid = WACOM_HID_WD_TOOLTYPE;
2202 field->logical_minimum = S16_MIN;
2203 field->logical_maximum = S16_MAX;
2204 a->logical_minimum = S32_MIN;
2205 a->logical_maximum = S32_MAX;
2206 b->usage[0].hid = WACOM_HID_WD_SERIALHI;
2207 b->logical_minimum = 0;
2208 b->logical_maximum = U8_MAX;
2213 case WACOM_HID_WD_SENSE:
2214 features->quirks |= WACOM_QUIRK_SENSE;
2215 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
2217 case WACOM_HID_WD_SERIALHI:
2218 wacom_map_usage(input, usage, field, EV_ABS, ABS_MISC, 0);
2220 if (!(features->quirks & WACOM_QUIRK_AESPEN)) {
2221 set_bit(EV_KEY, input->evbit);
2222 input_set_capability(input, EV_KEY, BTN_TOOL_PEN);
2223 input_set_capability(input, EV_KEY, BTN_TOOL_RUBBER);
2224 input_set_capability(input, EV_KEY, BTN_TOOL_BRUSH);
2225 input_set_capability(input, EV_KEY, BTN_TOOL_PENCIL);
2226 input_set_capability(input, EV_KEY, BTN_TOOL_AIRBRUSH);
2227 if (!(features->device_type & WACOM_DEVICETYPE_DIRECT)) {
2228 input_set_capability(input, EV_KEY, BTN_TOOL_MOUSE);
2229 input_set_capability(input, EV_KEY, BTN_TOOL_LENS);
2233 case WACOM_HID_WD_FINGERWHEEL:
2234 wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
2239 static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field,
2240 struct hid_usage *usage, __s32 value)
2242 struct wacom *wacom = hid_get_drvdata(hdev);
2243 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2244 struct wacom_features *features = &wacom_wac->features;
2245 struct input_dev *input = wacom_wac->pen_input;
2246 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2248 if (wacom_wac->is_invalid_bt_frame)
2251 switch (equivalent_usage) {
2254 * HID_GD_Z "should increase as the control's position is
2255 * moved from high to low", while ABS_DISTANCE instead
2256 * increases in value as the tool moves from low to high.
2258 value = field->logical_maximum - value;
2260 case HID_DG_INRANGE:
2261 wacom_wac->hid_data.inrange_state = value;
2262 if (!(features->quirks & WACOM_QUIRK_SENSE))
2263 wacom_wac->hid_data.sense_state = value;
2266 wacom_wac->hid_data.invert_state = value;
2269 case HID_DG_TIPSWITCH:
2270 wacom_wac->hid_data.tipswitch |= value;
2272 case HID_DG_BARRELSWITCH:
2273 wacom_wac->hid_data.barrelswitch = value;
2275 case HID_DG_BARRELSWITCH2:
2276 wacom_wac->hid_data.barrelswitch2 = value;
2278 case HID_DG_TOOLSERIALNUMBER:
2280 wacom_wac->serial[0] = (wacom_wac->serial[0] & ~0xFFFFFFFFULL);
2281 wacom_wac->serial[0] |= wacom_s32tou(value, field->report_size);
2286 * Userspace expects pen twist to have its zero point when
2287 * the buttons/finger is on the tablet's left. HID values
2288 * are zero when buttons are toward the top.
2290 value = wacom_offset_rotation(input, usage, value, 1, 4);
2292 case WACOM_HID_WD_SENSE:
2293 wacom_wac->hid_data.sense_state = value;
2295 case WACOM_HID_WD_SERIALHI:
2297 __u32 raw_value = wacom_s32tou(value, field->report_size);
2299 wacom_wac->serial[0] = (wacom_wac->serial[0] & 0xFFFFFFFF);
2300 wacom_wac->serial[0] |= ((__u64)raw_value) << 32;
2302 * Non-USI EMR devices may contain additional tool type
2303 * information here. See WACOM_HID_WD_TOOLTYPE case for
2306 if (value >> 20 == 1) {
2307 wacom_wac->id[0] |= raw_value & 0xFFFFF;
2311 case WACOM_HID_WD_TOOLTYPE:
2313 * Some devices (MobileStudio Pro, and possibly later
2314 * devices as well) do not return the complete tool
2315 * type in their WACOM_HID_WD_TOOLTYPE usage. Use a
2316 * bitwise OR so the complete value can be built
2319 wacom_wac->id[0] |= wacom_s32tou(value, field->report_size);
2321 case WACOM_HID_WD_OFFSETLEFT:
2322 if (features->offset_left && value != features->offset_left)
2323 hid_warn(hdev, "%s: overriding existing left offset "
2324 "%d -> %d\n", __func__, value,
2325 features->offset_left);
2326 features->offset_left = value;
2328 case WACOM_HID_WD_OFFSETRIGHT:
2329 if (features->offset_right && value != features->offset_right)
2330 hid_warn(hdev, "%s: overriding existing right offset "
2331 "%d -> %d\n", __func__, value,
2332 features->offset_right);
2333 features->offset_right = value;
2335 case WACOM_HID_WD_OFFSETTOP:
2336 if (features->offset_top && value != features->offset_top)
2337 hid_warn(hdev, "%s: overriding existing top offset "
2338 "%d -> %d\n", __func__, value,
2339 features->offset_top);
2340 features->offset_top = value;
2342 case WACOM_HID_WD_OFFSETBOTTOM:
2343 if (features->offset_bottom && value != features->offset_bottom)
2344 hid_warn(hdev, "%s: overriding existing bottom offset "
2345 "%d -> %d\n", __func__, value,
2346 features->offset_bottom);
2347 features->offset_bottom = value;
2349 case WACOM_HID_WD_REPORT_VALID:
2350 wacom_wac->is_invalid_bt_frame = !value;
2354 /* send pen events only when touch is up or forced out
2355 * or touch arbitration is off
2357 if (!usage->type || delay_pen_events(wacom_wac))
2360 /* send pen events only when the pen is in range */
2361 if (wacom_wac->hid_data.inrange_state)
2362 input_event(input, usage->type, usage->code, value);
2363 else if (wacom_wac->shared->stylus_in_proximity && !wacom_wac->hid_data.sense_state)
2364 input_event(input, usage->type, usage->code, 0);
2367 static void wacom_wac_pen_pre_report(struct hid_device *hdev,
2368 struct hid_report *report)
2370 struct wacom *wacom = hid_get_drvdata(hdev);
2371 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2373 wacom_wac->is_invalid_bt_frame = false;
2377 static void wacom_wac_pen_report(struct hid_device *hdev,
2378 struct hid_report *report)
2380 struct wacom *wacom = hid_get_drvdata(hdev);
2381 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2382 struct input_dev *input = wacom_wac->pen_input;
2383 bool range = wacom_wac->hid_data.inrange_state;
2384 bool sense = wacom_wac->hid_data.sense_state;
2386 if (wacom_wac->is_invalid_bt_frame)
2389 if (!wacom_wac->tool[0] && range) { /* first in range */
2390 /* Going into range select tool */
2391 if (wacom_wac->hid_data.invert_state)
2392 wacom_wac->tool[0] = BTN_TOOL_RUBBER;
2393 else if (wacom_wac->id[0])
2394 wacom_wac->tool[0] = wacom_intuos_get_tool_type(wacom_wac->id[0]);
2396 wacom_wac->tool[0] = BTN_TOOL_PEN;
2399 /* keep pen state for touch events */
2400 wacom_wac->shared->stylus_in_proximity = sense;
2402 if (!delay_pen_events(wacom_wac) && wacom_wac->tool[0]) {
2403 int id = wacom_wac->id[0];
2404 int sw_state = wacom_wac->hid_data.barrelswitch |
2405 (wacom_wac->hid_data.barrelswitch2 << 1);
2407 input_report_key(input, BTN_STYLUS, sw_state == 1);
2408 input_report_key(input, BTN_STYLUS2, sw_state == 2);
2409 input_report_key(input, BTN_STYLUS3, sw_state == 3);
2412 * Non-USI EMR tools should have their IDs mangled to
2413 * match the legacy behavior of wacom_intuos_general
2415 if (wacom_wac->serial[0] >> 52 == 1)
2416 id = wacom_intuos_id_mangle(id);
2419 * To ensure compatibility with xf86-input-wacom, we should
2420 * report the BTN_TOOL_* event prior to the ABS_MISC or
2421 * MSC_SERIAL events.
2423 input_report_key(input, BTN_TOUCH,
2424 wacom_wac->hid_data.tipswitch);
2425 input_report_key(input, wacom_wac->tool[0], sense);
2426 if (wacom_wac->serial[0]) {
2427 input_event(input, EV_MSC, MSC_SERIAL, wacom_wac->serial[0]);
2428 input_report_abs(input, ABS_MISC, sense ? id : 0);
2431 wacom_wac->hid_data.tipswitch = false;
2437 wacom_wac->tool[0] = 0;
2438 wacom_wac->id[0] = 0;
2439 wacom_wac->serial[0] = 0;
2443 static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
2444 struct hid_field *field, struct hid_usage *usage)
2446 struct wacom *wacom = hid_get_drvdata(hdev);
2447 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2448 struct input_dev *input = wacom_wac->touch_input;
2449 unsigned touch_max = wacom_wac->features.touch_max;
2450 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2452 switch (equivalent_usage) {
2455 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
2457 wacom_map_usage(input, usage, field, EV_ABS,
2458 ABS_MT_POSITION_X, 4);
2462 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
2464 wacom_map_usage(input, usage, field, EV_ABS,
2465 ABS_MT_POSITION_Y, 4);
2469 wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MAJOR, 0);
2470 wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MINOR, 0);
2471 input_set_abs_params(input, ABS_MT_ORIENTATION, 0, 1, 0, 0);
2473 case HID_DG_TIPSWITCH:
2474 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
2476 case HID_DG_CONTACTCOUNT:
2477 wacom_wac->hid_data.cc_report = field->report->id;
2478 wacom_wac->hid_data.cc_index = field->index;
2479 wacom_wac->hid_data.cc_value_index = usage->usage_index;
2481 case HID_DG_CONTACTID:
2482 if ((field->logical_maximum - field->logical_minimum) < touch_max) {
2484 * The HID descriptor for G11 sensors leaves logical
2485 * maximum set to '1' despite it being a multitouch
2486 * device. Override to a sensible number.
2488 field->logical_maximum = 255;
2494 static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
2495 struct input_dev *input)
2497 struct hid_data *hid_data = &wacom_wac->hid_data;
2498 bool mt = wacom_wac->features.touch_max > 1;
2499 bool prox = hid_data->tipswitch &&
2500 report_touch_events(wacom_wac);
2502 if (wacom_wac->shared->has_mute_touch_switch &&
2503 !wacom_wac->shared->is_touch_on) {
2504 if (!wacom_wac->shared->touch_down)
2509 wacom_wac->hid_data.num_received++;
2510 if (wacom_wac->hid_data.num_received > wacom_wac->hid_data.num_expected)
2516 slot = input_mt_get_slot_by_key(input, hid_data->id);
2517 input_mt_slot(input, slot);
2518 input_mt_report_slot_state(input, MT_TOOL_FINGER, prox);
2521 input_report_key(input, BTN_TOUCH, prox);
2525 input_report_abs(input, mt ? ABS_MT_POSITION_X : ABS_X,
2527 input_report_abs(input, mt ? ABS_MT_POSITION_Y : ABS_Y,
2530 if (test_bit(ABS_MT_TOUCH_MAJOR, input->absbit)) {
2531 input_report_abs(input, ABS_MT_TOUCH_MAJOR, max(hid_data->width, hid_data->height));
2532 input_report_abs(input, ABS_MT_TOUCH_MINOR, min(hid_data->width, hid_data->height));
2533 if (hid_data->width != hid_data->height)
2534 input_report_abs(input, ABS_MT_ORIENTATION, hid_data->width <= hid_data->height ? 0 : 1);
2539 static bool wacom_wac_slot_is_active(struct input_dev *dev, int key)
2541 struct input_mt *mt = dev->mt;
2542 struct input_mt_slot *s;
2547 for (s = mt->slots; s != mt->slots + mt->num_slots; s++) {
2548 if (s->key == key &&
2549 input_mt_get_value(s, ABS_MT_TRACKING_ID) >= 0) {
2557 static void wacom_wac_finger_event(struct hid_device *hdev,
2558 struct hid_field *field, struct hid_usage *usage, __s32 value)
2560 struct wacom *wacom = hid_get_drvdata(hdev);
2561 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2562 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2563 struct wacom_features *features = &wacom->wacom_wac.features;
2565 switch (equivalent_usage) {
2566 case HID_DG_CONFIDENCE:
2567 wacom_wac->hid_data.confidence = value;
2570 wacom_wac->hid_data.x = value;
2573 wacom_wac->hid_data.y = value;
2576 wacom_wac->hid_data.width = value;
2579 wacom_wac->hid_data.height = value;
2581 case HID_DG_CONTACTID:
2582 wacom_wac->hid_data.id = value;
2584 case HID_DG_TIPSWITCH:
2585 wacom_wac->hid_data.tipswitch = value;
2587 case HID_DG_CONTACTMAX:
2588 if (!features->touch_max) {
2589 features->touch_max = value;
2591 hid_warn(hdev, "%s: ignoring attempt to overwrite non-zero touch_max "
2592 "%d -> %d\n", __func__, features->touch_max, value);
2598 if (usage->usage_index + 1 == field->report_count) {
2599 if (equivalent_usage == wacom_wac->hid_data.last_slot_field) {
2600 bool touch_removed = wacom_wac_slot_is_active(wacom_wac->touch_input,
2601 wacom_wac->hid_data.id) && !wacom_wac->hid_data.tipswitch;
2603 if (wacom_wac->hid_data.confidence || touch_removed) {
2604 wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
2610 static void wacom_wac_finger_pre_report(struct hid_device *hdev,
2611 struct hid_report *report)
2613 struct wacom *wacom = hid_get_drvdata(hdev);
2614 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2615 struct hid_data* hid_data = &wacom_wac->hid_data;
2618 hid_data->confidence = true;
2620 hid_data->cc_report = 0;
2621 hid_data->cc_index = -1;
2622 hid_data->cc_value_index = -1;
2624 for (i = 0; i < report->maxfield; i++) {
2625 struct hid_field *field = report->field[i];
2628 for (j = 0; j < field->maxusage; j++) {
2629 struct hid_usage *usage = &field->usage[j];
2630 unsigned int equivalent_usage =
2631 wacom_equivalent_usage(usage->hid);
2633 switch (equivalent_usage) {
2638 case HID_DG_CONTACTID:
2639 case HID_DG_INRANGE:
2641 case HID_DG_TIPSWITCH:
2642 hid_data->last_slot_field = equivalent_usage;
2644 case HID_DG_CONTACTCOUNT:
2645 hid_data->cc_report = report->id;
2646 hid_data->cc_index = i;
2647 hid_data->cc_value_index = j;
2653 if (hid_data->cc_report != 0 &&
2654 hid_data->cc_index >= 0) {
2655 struct hid_field *field = report->field[hid_data->cc_index];
2656 int value = field->value[hid_data->cc_value_index];
2658 hid_data->num_expected = value;
2659 hid_data->num_received = 0;
2663 hid_data->num_expected = wacom_wac->features.touch_max;
2664 hid_data->num_received = 0;
2668 static void wacom_wac_finger_report(struct hid_device *hdev,
2669 struct hid_report *report)
2671 struct wacom *wacom = hid_get_drvdata(hdev);
2672 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2673 struct input_dev *input = wacom_wac->touch_input;
2674 unsigned touch_max = wacom_wac->features.touch_max;
2676 /* If more packets of data are expected, give us a chance to
2677 * process them rather than immediately syncing a partial
2680 if (wacom_wac->hid_data.num_received < wacom_wac->hid_data.num_expected)
2684 input_mt_sync_frame(input);
2687 wacom_wac->hid_data.num_received = 0;
2688 wacom_wac->hid_data.num_expected = 0;
2690 /* keep touch state for pen event */
2691 wacom_wac->shared->touch_down = wacom_wac_finger_count_touches(wacom_wac);
2694 void wacom_wac_usage_mapping(struct hid_device *hdev,
2695 struct hid_field *field, struct hid_usage *usage)
2697 struct wacom *wacom = hid_get_drvdata(hdev);
2698 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2699 struct wacom_features *features = &wacom_wac->features;
2701 if (WACOM_DIRECT_DEVICE(field))
2702 features->device_type |= WACOM_DEVICETYPE_DIRECT;
2704 /* usage tests must precede field tests */
2705 if (WACOM_BATTERY_USAGE(usage))
2706 wacom_wac_battery_usage_mapping(hdev, field, usage);
2707 else if (WACOM_PAD_FIELD(field))
2708 wacom_wac_pad_usage_mapping(hdev, field, usage);
2709 else if (WACOM_PEN_FIELD(field))
2710 wacom_wac_pen_usage_mapping(hdev, field, usage);
2711 else if (WACOM_FINGER_FIELD(field))
2712 wacom_wac_finger_usage_mapping(hdev, field, usage);
2715 void wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
2716 struct hid_usage *usage, __s32 value)
2718 struct wacom *wacom = hid_get_drvdata(hdev);
2720 if (wacom->wacom_wac.features.type != HID_GENERIC)
2723 if (value > field->logical_maximum || value < field->logical_minimum)
2726 /* usage tests must precede field tests */
2727 if (WACOM_BATTERY_USAGE(usage))
2728 wacom_wac_battery_event(hdev, field, usage, value);
2729 else if (WACOM_PAD_FIELD(field))
2730 wacom_wac_pad_event(hdev, field, usage, value);
2731 else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
2732 wacom_wac_pen_event(hdev, field, usage, value);
2733 else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
2734 wacom_wac_finger_event(hdev, field, usage, value);
2737 static void wacom_report_events(struct hid_device *hdev,
2738 struct hid_report *report, int collection_index,
2743 for (r = field_index; r < report->maxfield; r++) {
2744 struct hid_field *field;
2747 field = report->field[r];
2748 count = field->report_count;
2750 if (!(HID_MAIN_ITEM_VARIABLE & field->flags))
2753 for (n = 0 ; n < count; n++) {
2754 if (field->usage[n].collection_index == collection_index)
2755 wacom_wac_event(hdev, field, &field->usage[n],
2763 static int wacom_wac_collection(struct hid_device *hdev, struct hid_report *report,
2764 int collection_index, struct hid_field *field,
2767 struct wacom *wacom = hid_get_drvdata(hdev);
2769 wacom_report_events(hdev, report, collection_index, field_index);
2772 * Non-input reports may be sent prior to the device being
2773 * completely initialized. Since only their events need
2774 * to be processed, exit after 'wacom_report_events' has
2775 * been called to prevent potential crashes in the report-
2776 * processing functions.
2778 if (report->type != HID_INPUT_REPORT)
2781 if (WACOM_PAD_FIELD(field))
2783 else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
2784 wacom_wac_pen_report(hdev, report);
2785 else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
2786 wacom_wac_finger_report(hdev, report);
2791 void wacom_wac_report(struct hid_device *hdev, struct hid_report *report)
2793 struct wacom *wacom = hid_get_drvdata(hdev);
2794 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2795 struct hid_field *field;
2796 bool pad_in_hid_field = false, pen_in_hid_field = false,
2797 finger_in_hid_field = false, true_pad = false;
2799 int prev_collection = -1;
2801 if (wacom_wac->features.type != HID_GENERIC)
2804 for (r = 0; r < report->maxfield; r++) {
2805 field = report->field[r];
2807 if (WACOM_PAD_FIELD(field))
2808 pad_in_hid_field = true;
2809 if (WACOM_PEN_FIELD(field))
2810 pen_in_hid_field = true;
2811 if (WACOM_FINGER_FIELD(field))
2812 finger_in_hid_field = true;
2813 if (wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY)
2817 wacom_wac_battery_pre_report(hdev, report);
2819 if (pad_in_hid_field && wacom->wacom_wac.pad_input)
2820 wacom_wac_pad_pre_report(hdev, report);
2821 if (pen_in_hid_field && wacom->wacom_wac.pen_input)
2822 wacom_wac_pen_pre_report(hdev, report);
2823 if (finger_in_hid_field && wacom->wacom_wac.touch_input)
2824 wacom_wac_finger_pre_report(hdev, report);
2826 for (r = 0; r < report->maxfield; r++) {
2827 field = report->field[r];
2829 if (field->usage[0].collection_index != prev_collection) {
2830 if (wacom_wac_collection(hdev, report,
2831 field->usage[0].collection_index, field, r) < 0)
2833 prev_collection = field->usage[0].collection_index;
2837 wacom_wac_battery_report(hdev, report);
2839 if (true_pad && wacom->wacom_wac.pad_input)
2840 wacom_wac_pad_report(hdev, report, field);
2843 static int wacom_bpt_touch(struct wacom_wac *wacom)
2845 struct wacom_features *features = &wacom->features;
2846 struct input_dev *input = wacom->touch_input;
2847 struct input_dev *pad_input = wacom->pad_input;
2848 unsigned char *data = wacom->data;
2851 if (data[0] != 0x02)
2854 for (i = 0; i < 2; i++) {
2855 int offset = (data[1] & 0x80) ? (8 * i) : (9 * i);
2856 bool touch = report_touch_events(wacom)
2857 && (data[offset + 3] & 0x80);
2859 input_mt_slot(input, i);
2860 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
2862 int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff;
2863 int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff;
2864 if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) {
2868 input_report_abs(input, ABS_MT_POSITION_X, x);
2869 input_report_abs(input, ABS_MT_POSITION_Y, y);
2873 input_mt_sync_frame(input);
2875 input_report_key(pad_input, BTN_LEFT, (data[1] & 0x08) != 0);
2876 input_report_key(pad_input, BTN_FORWARD, (data[1] & 0x04) != 0);
2877 input_report_key(pad_input, BTN_BACK, (data[1] & 0x02) != 0);
2878 input_report_key(pad_input, BTN_RIGHT, (data[1] & 0x01) != 0);
2879 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
2884 static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
2886 struct wacom_features *features = &wacom->features;
2887 struct input_dev *input = wacom->touch_input;
2888 bool touch = data[1] & 0x80;
2889 int slot = input_mt_get_slot_by_key(input, data[0]);
2894 touch = touch && report_touch_events(wacom);
2896 input_mt_slot(input, slot);
2897 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
2900 int x = (data[2] << 4) | (data[4] >> 4);
2901 int y = (data[3] << 4) | (data[4] & 0x0f);
2904 if (features->type >= INTUOSPS && features->type <= INTUOSHT2) {
2905 width = data[5] * 100;
2906 height = data[6] * 100;
2909 * "a" is a scaled-down area which we assume is
2910 * roughly circular and which can be described as:
2914 int x_res = input_abs_get_res(input, ABS_MT_POSITION_X);
2915 int y_res = input_abs_get_res(input, ABS_MT_POSITION_Y);
2916 width = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE);
2917 height = width * y_res / x_res;
2920 input_report_abs(input, ABS_MT_POSITION_X, x);
2921 input_report_abs(input, ABS_MT_POSITION_Y, y);
2922 input_report_abs(input, ABS_MT_TOUCH_MAJOR, width);
2923 input_report_abs(input, ABS_MT_TOUCH_MINOR, height);
2927 static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
2929 struct input_dev *input = wacom->pad_input;
2930 struct wacom_features *features = &wacom->features;
2932 if (features->type == INTUOSHT || features->type == INTUOSHT2) {
2933 input_report_key(input, BTN_LEFT, (data[1] & 0x02) != 0);
2934 input_report_key(input, BTN_BACK, (data[1] & 0x08) != 0);
2936 input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
2937 input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
2939 input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
2940 input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
2943 static int wacom_bpt3_touch(struct wacom_wac *wacom)
2945 unsigned char *data = wacom->data;
2946 int count = data[1] & 0x07;
2947 int touch_changed = 0, i;
2949 if (data[0] != 0x02)
2952 /* data has up to 7 fixed sized 8-byte messages starting at data[2] */
2953 for (i = 0; i < count; i++) {
2954 int offset = (8 * i) + 2;
2955 int msg_id = data[offset];
2957 if (msg_id >= 2 && msg_id <= 17) {
2958 wacom_bpt3_touch_msg(wacom, data + offset);
2960 } else if (msg_id == 128)
2961 wacom_bpt3_button_msg(wacom, data + offset);
2965 /* only update touch if we actually have a touchpad and touch data changed */
2966 if (wacom->touch_input && touch_changed) {
2967 input_mt_sync_frame(wacom->touch_input);
2968 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
2974 static int wacom_bpt_pen(struct wacom_wac *wacom)
2976 struct wacom_features *features = &wacom->features;
2977 struct input_dev *input = wacom->pen_input;
2978 unsigned char *data = wacom->data;
2979 int x = 0, y = 0, p = 0, d = 0;
2980 bool pen = false, btn1 = false, btn2 = false;
2981 bool range, prox, rdy;
2983 if (data[0] != WACOM_REPORT_PENABLED)
2986 range = (data[1] & 0x80) == 0x80;
2987 prox = (data[1] & 0x40) == 0x40;
2988 rdy = (data[1] & 0x20) == 0x20;
2990 wacom->shared->stylus_in_proximity = range;
2991 if (delay_pen_events(wacom))
2995 p = le16_to_cpup((__le16 *)&data[6]);
2996 pen = data[1] & 0x01;
2997 btn1 = data[1] & 0x02;
2998 btn2 = data[1] & 0x04;
3001 x = le16_to_cpup((__le16 *)&data[2]);
3002 y = le16_to_cpup((__le16 *)&data[4]);
3004 if (data[1] & 0x08) {
3005 wacom->tool[0] = BTN_TOOL_RUBBER;
3006 wacom->id[0] = ERASER_DEVICE_ID;
3008 wacom->tool[0] = BTN_TOOL_PEN;
3009 wacom->id[0] = STYLUS_DEVICE_ID;
3011 wacom->reporting_data = true;
3015 * Convert distance from out prox to distance from tablet.
3016 * distance will be greater than distance_max once
3017 * touching and applying pressure; do not report negative
3020 if (data[8] <= features->distance_max)
3021 d = features->distance_max - data[8];
3026 if (wacom->reporting_data) {
3027 input_report_key(input, BTN_TOUCH, pen);
3028 input_report_key(input, BTN_STYLUS, btn1);
3029 input_report_key(input, BTN_STYLUS2, btn2);
3031 if (prox || !range) {
3032 input_report_abs(input, ABS_X, x);
3033 input_report_abs(input, ABS_Y, y);
3035 input_report_abs(input, ABS_PRESSURE, p);
3036 input_report_abs(input, ABS_DISTANCE, d);
3038 input_report_key(input, wacom->tool[0], range); /* PEN or RUBBER */
3039 input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
3043 wacom->reporting_data = false;
3049 static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
3051 struct wacom_features *features = &wacom->features;
3053 if ((features->type == INTUOSHT2) &&
3054 (features->device_type & WACOM_DEVICETYPE_PEN))
3055 return wacom_intuos_irq(wacom);
3056 else if (len == WACOM_PKGLEN_BBTOUCH)
3057 return wacom_bpt_touch(wacom);
3058 else if (len == WACOM_PKGLEN_BBTOUCH3)
3059 return wacom_bpt3_touch(wacom);
3060 else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
3061 return wacom_bpt_pen(wacom);
3066 static void wacom_bamboo_pad_pen_event(struct wacom_wac *wacom,
3067 unsigned char *data)
3069 unsigned char prefix;
3072 * We need to reroute the event from the debug interface to the
3074 * We need to add the report ID to the actual pen report, so we
3075 * temporary overwrite the first byte to prevent having to kzalloc/kfree
3076 * and memcpy the report.
3079 data[0] = WACOM_REPORT_BPAD_PEN;
3082 * actually reroute the event.
3083 * No need to check if wacom->shared->pen is valid, hid_input_report()
3084 * will check for us.
3086 hid_input_report(wacom->shared->pen, HID_INPUT_REPORT, data,
3087 WACOM_PKGLEN_PENABLED, 1);
3092 static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom,
3093 unsigned char *data)
3095 struct input_dev *input = wacom->touch_input;
3096 unsigned char *finger_data, prefix;
3103 for (id = 0; id < wacom->features.touch_max; id++) {
3104 valid = !!(prefix & BIT(id)) &&
3105 report_touch_events(wacom);
3107 input_mt_slot(input, id);
3108 input_mt_report_slot_state(input, MT_TOOL_FINGER, valid);
3113 finger_data = data + 1 + id * 3;
3114 x = finger_data[0] | ((finger_data[1] & 0x0f) << 8);
3115 y = (finger_data[2] << 4) | (finger_data[1] >> 4);
3117 input_report_abs(input, ABS_MT_POSITION_X, x);
3118 input_report_abs(input, ABS_MT_POSITION_Y, y);
3121 input_mt_sync_frame(input);
3123 input_report_key(input, BTN_LEFT, prefix & 0x40);
3124 input_report_key(input, BTN_RIGHT, prefix & 0x80);
3126 /* keep touch state for pen event */
3127 wacom->shared->touch_down = !!prefix && report_touch_events(wacom);
3132 static int wacom_bamboo_pad_irq(struct wacom_wac *wacom, size_t len)
3134 unsigned char *data = wacom->data;
3136 if (!((len == WACOM_PKGLEN_BPAD_TOUCH) ||
3137 (len == WACOM_PKGLEN_BPAD_TOUCH_USB)) ||
3138 (data[0] != WACOM_REPORT_BPAD_TOUCH))
3142 wacom_bamboo_pad_pen_event(wacom, &data[1]);
3145 return wacom_bamboo_pad_touch_event(wacom, &data[9]);
3150 static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
3152 unsigned char *data = wacom->data;
3155 if (len != WACOM_PKGLEN_WIRELESS || data[0] != WACOM_REPORT_WL)
3158 connected = data[1] & 0x01;
3160 int pid, battery, charging;
3162 if ((wacom->shared->type == INTUOSHT ||
3163 wacom->shared->type == INTUOSHT2) &&
3164 wacom->shared->touch_input &&
3165 wacom->shared->touch_max) {
3166 input_report_switch(wacom->shared->touch_input,
3167 SW_MUTE_DEVICE, data[5] & 0x40);
3168 input_sync(wacom->shared->touch_input);
3171 pid = get_unaligned_be16(&data[6]);
3172 battery = (data[5] & 0x3f) * 100 / 31;
3173 charging = !!(data[5] & 0x80);
3174 if (wacom->pid != pid) {
3176 wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
3179 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
3180 battery, charging, 1, 0);
3182 } else if (wacom->pid != 0) {
3183 /* disconnected while previously connected */
3185 wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
3186 wacom_notify_battery(wacom, POWER_SUPPLY_STATUS_UNKNOWN, 0, 0, 0, 0);
3192 static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
3194 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
3195 struct wacom_features *features = &wacom_wac->features;
3196 unsigned char *data = wacom_wac->data;
3198 if (data[0] != WACOM_REPORT_USB)
3201 if ((features->type == INTUOSHT ||
3202 features->type == INTUOSHT2) &&
3203 wacom_wac->shared->touch_input &&
3204 features->touch_max) {
3205 input_report_switch(wacom_wac->shared->touch_input,
3206 SW_MUTE_DEVICE, data[8] & 0x40);
3207 input_sync(wacom_wac->shared->touch_input);
3210 if (data[9] & 0x02) { /* wireless module is attached */
3211 int battery = (data[8] & 0x3f) * 100 / 31;
3212 bool charging = !!(data[8] & 0x80);
3214 wacom_notify_battery(wacom_wac, WACOM_POWER_SUPPLY_STATUS_AUTO,
3215 battery, charging, battery || charging, 1);
3217 if (!wacom->battery.battery &&
3218 !(features->quirks & WACOM_QUIRK_BATTERY)) {
3219 features->quirks |= WACOM_QUIRK_BATTERY;
3220 wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
3223 else if ((features->quirks & WACOM_QUIRK_BATTERY) &&
3224 wacom->battery.battery) {
3225 features->quirks &= ~WACOM_QUIRK_BATTERY;
3226 wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
3227 wacom_notify_battery(wacom_wac, POWER_SUPPLY_STATUS_UNKNOWN, 0, 0, 0, 0);
3232 void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
3236 switch (wacom_wac->features.type) {
3238 sync = wacom_penpartner_irq(wacom_wac);
3242 sync = wacom_pl_irq(wacom_wac);
3249 sync = wacom_graphire_irq(wacom_wac);
3253 sync = wacom_ptu_irq(wacom_wac);
3257 sync = wacom_dtu_irq(wacom_wac);
3262 sync = wacom_dtus_irq(wacom_wac);
3281 case CINTIQ_COMPANION_2:
3282 sync = wacom_intuos_irq(wacom_wac);
3286 sync = wacom_intuos_bt_irq(wacom_wac, len);
3291 sync = wacom_24hdt_irq(wacom_wac);
3300 if (len == WACOM_PKGLEN_BBTOUCH3)
3301 sync = wacom_bpt3_touch(wacom_wac);
3302 else if (wacom_wac->data[0] == WACOM_REPORT_USB)
3303 sync = wacom_status_irq(wacom_wac, len);
3305 sync = wacom_intuos_irq(wacom_wac);
3310 sync = wacom_intuos_pro2_bt_irq(wacom_wac, len);
3319 sync = wacom_tpc_irq(wacom_wac, len);
3327 if (wacom_wac->data[0] == WACOM_REPORT_USB)
3328 sync = wacom_status_irq(wacom_wac, len);
3330 sync = wacom_bpt_irq(wacom_wac, len);
3334 sync = wacom_bamboo_pad_irq(wacom_wac, len);
3338 sync = wacom_wireless_irq(wacom_wac, len);
3343 if (wacom_wac->data[0] == WACOM_REPORT_DEVICE_LIST)
3344 wacom_remote_status_irq(wacom_wac, len);
3346 sync = wacom_remote_irq(wacom_wac, len);
3355 if (wacom_wac->pen_input)
3356 input_sync(wacom_wac->pen_input);
3357 if (wacom_wac->touch_input)
3358 input_sync(wacom_wac->touch_input);
3359 if (wacom_wac->pad_input)
3360 input_sync(wacom_wac->pad_input);
3364 static void wacom_setup_basic_pro_pen(struct wacom_wac *wacom_wac)
3366 struct input_dev *input_dev = wacom_wac->pen_input;
3368 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
3370 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3371 __set_bit(BTN_STYLUS, input_dev->keybit);
3372 __set_bit(BTN_STYLUS2, input_dev->keybit);
3374 input_set_abs_params(input_dev, ABS_DISTANCE,
3375 0, wacom_wac->features.distance_max, wacom_wac->features.distance_fuzz, 0);
3378 static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
3380 struct input_dev *input_dev = wacom_wac->pen_input;
3381 struct wacom_features *features = &wacom_wac->features;
3383 wacom_setup_basic_pro_pen(wacom_wac);
3385 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3386 __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
3387 __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
3388 __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
3390 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
3391 input_set_abs_params(input_dev, ABS_TILT_X, -64, 63, features->tilt_fuzz, 0);
3392 input_abs_set_res(input_dev, ABS_TILT_X, 57);
3393 input_set_abs_params(input_dev, ABS_TILT_Y, -64, 63, features->tilt_fuzz, 0);
3394 input_abs_set_res(input_dev, ABS_TILT_Y, 57);
3397 static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
3399 struct input_dev *input_dev = wacom_wac->pen_input;
3401 input_set_capability(input_dev, EV_REL, REL_WHEEL);
3403 wacom_setup_cintiq(wacom_wac);
3405 __set_bit(BTN_LEFT, input_dev->keybit);
3406 __set_bit(BTN_RIGHT, input_dev->keybit);
3407 __set_bit(BTN_MIDDLE, input_dev->keybit);
3408 __set_bit(BTN_SIDE, input_dev->keybit);
3409 __set_bit(BTN_EXTRA, input_dev->keybit);
3410 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
3411 __set_bit(BTN_TOOL_LENS, input_dev->keybit);
3413 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
3414 input_abs_set_res(input_dev, ABS_RZ, 287);
3415 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
3418 void wacom_setup_device_quirks(struct wacom *wacom)
3420 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
3421 struct wacom_features *features = &wacom->wacom_wac.features;
3423 /* The pen and pad share the same interface on most devices */
3424 if (features->type == GRAPHIRE_BT || features->type == WACOM_G4 ||
3425 features->type == DTUS ||
3426 (features->type >= INTUOS3S && features->type <= WACOM_MO)) {
3427 if (features->device_type & WACOM_DEVICETYPE_PEN)
3428 features->device_type |= WACOM_DEVICETYPE_PAD;
3431 /* touch device found but size is not defined. use default */
3432 if (features->device_type & WACOM_DEVICETYPE_TOUCH && !features->x_max) {
3433 features->x_max = 1023;
3434 features->y_max = 1023;
3438 * Intuos5/Pro and Bamboo 3rd gen have no useful data about its
3439 * touch interface in its HID descriptor. If this is the touch
3440 * interface (PacketSize of WACOM_PKGLEN_BBTOUCH3), override the
3443 if ((features->type >= INTUOS5S && features->type <= INTUOSPL) ||
3444 (features->type >= INTUOSHT && features->type <= BAMBOO_PT)) {
3445 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
3446 if (features->touch_max)
3447 features->device_type |= WACOM_DEVICETYPE_TOUCH;
3448 if (features->type >= INTUOSHT && features->type <= BAMBOO_PT)
3449 features->device_type |= WACOM_DEVICETYPE_PAD;
3451 if (features->type == INTUOSHT2) {
3452 features->x_max = features->x_max / 10;
3453 features->y_max = features->y_max / 10;
3456 features->x_max = 4096;
3457 features->y_max = 4096;
3460 else if (features->pktlen == WACOM_PKGLEN_BBTOUCH) {
3461 features->device_type |= WACOM_DEVICETYPE_PAD;
3466 * Hack for the Bamboo One:
3467 * the device presents a PAD/Touch interface as most Bamboos and even
3468 * sends ghosts PAD data on it. However, later, we must disable this
3469 * ghost interface, and we can not detect it unless we set it here
3470 * to WACOM_DEVICETYPE_PAD or WACOM_DEVICETYPE_TOUCH.
3472 if (features->type == BAMBOO_PEN &&
3473 features->pktlen == WACOM_PKGLEN_BBTOUCH3)
3474 features->device_type |= WACOM_DEVICETYPE_PAD;
3477 * Raw Wacom-mode pen and touch events both come from interface
3478 * 0, whose HID descriptor has an application usage of 0xFF0D
3479 * (i.e., WACOM_HID_WD_DIGITIZER). We route pen packets back
3480 * out through the HID_GENERIC device created for interface 1,
3481 * so rewrite this one to be of type WACOM_DEVICETYPE_TOUCH.
3483 if (features->type == BAMBOO_PAD)
3484 features->device_type = WACOM_DEVICETYPE_TOUCH;
3486 if (features->type == REMOTE)
3487 features->device_type = WACOM_DEVICETYPE_PAD;
3489 if (features->type == INTUOSP2_BT) {
3490 features->device_type |= WACOM_DEVICETYPE_PEN |
3491 WACOM_DEVICETYPE_PAD |
3492 WACOM_DEVICETYPE_TOUCH;
3493 features->quirks |= WACOM_QUIRK_BATTERY;
3496 if (features->type == INTUOSHT3_BT) {
3497 features->device_type |= WACOM_DEVICETYPE_PEN |
3498 WACOM_DEVICETYPE_PAD;
3499 features->quirks |= WACOM_QUIRK_BATTERY;
3502 switch (features->type) {
3513 case CINTIQ_COMPANION_2:
3525 features->device_type |= WACOM_DEVICETYPE_DIRECT;
3529 if (wacom->hdev->bus == BUS_BLUETOOTH)
3530 features->quirks |= WACOM_QUIRK_BATTERY;
3532 /* quirk for bamboo touch with 2 low res touches */
3533 if ((features->type == BAMBOO_PT || features->type == BAMBOO_TOUCH) &&
3534 features->pktlen == WACOM_PKGLEN_BBTOUCH) {
3535 features->x_max <<= 5;
3536 features->y_max <<= 5;
3537 features->x_fuzz <<= 5;
3538 features->y_fuzz <<= 5;
3539 features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;
3542 if (features->type == WIRELESS) {
3543 if (features->device_type == WACOM_DEVICETYPE_WL_MONITOR) {
3544 features->quirks |= WACOM_QUIRK_BATTERY;
3548 if (features->type == REMOTE)
3549 features->device_type |= WACOM_DEVICETYPE_WL_MONITOR;
3551 /* HID descriptor for DTK-2451 / DTH-2452 claims to report lots
3552 * of things it shouldn't. Lets fix up the damage...
3554 if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
3555 features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3556 __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3557 __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3558 __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3559 __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3560 __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3561 __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3562 __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3563 __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3564 __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3565 __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3566 __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3570 int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
3571 struct wacom_wac *wacom_wac)
3573 struct wacom_features *features = &wacom_wac->features;
3575 if (!(features->device_type & WACOM_DEVICETYPE_PEN))
3578 if (features->device_type & WACOM_DEVICETYPE_DIRECT)
3579 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
3581 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
3583 if (features->type == HID_GENERIC) {
3584 /* setup has already been done; apply otherwise-undetectible quirks */
3585 input_set_capability(input_dev, EV_KEY, BTN_STYLUS3);
3589 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3590 __set_bit(BTN_TOUCH, input_dev->keybit);
3591 __set_bit(ABS_MISC, input_dev->absbit);
3593 input_set_abs_params(input_dev, ABS_X, 0 + features->offset_left,
3594 features->x_max - features->offset_right,
3595 features->x_fuzz, 0);
3596 input_set_abs_params(input_dev, ABS_Y, 0 + features->offset_top,
3597 features->y_max - features->offset_bottom,
3598 features->y_fuzz, 0);
3599 input_set_abs_params(input_dev, ABS_PRESSURE, 0,
3600 features->pressure_max, features->pressure_fuzz, 0);
3602 /* penabled devices have fixed resolution for each model */
3603 input_abs_set_res(input_dev, ABS_X, features->x_resolution);
3604 input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
3606 switch (features->type) {
3608 __clear_bit(ABS_MISC, input_dev->absbit);
3612 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3613 features->distance_max,
3614 features->distance_fuzz, 0);
3618 input_set_capability(input_dev, EV_REL, REL_WHEEL);
3620 __set_bit(BTN_LEFT, input_dev->keybit);
3621 __set_bit(BTN_RIGHT, input_dev->keybit);
3622 __set_bit(BTN_MIDDLE, input_dev->keybit);
3624 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3625 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3626 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
3627 __set_bit(BTN_STYLUS, input_dev->keybit);
3628 __set_bit(BTN_STYLUS2, input_dev->keybit);
3640 case CINTIQ_COMPANION_2:
3641 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3642 input_abs_set_res(input_dev, ABS_Z, 287);
3643 wacom_setup_cintiq(wacom_wac);
3653 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3654 input_abs_set_res(input_dev, ABS_Z, 287);
3658 wacom_setup_intuos(wacom_wac);
3668 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3669 features->distance_max,
3670 features->distance_fuzz, 0);
3672 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3673 input_abs_set_res(input_dev, ABS_Z, 287);
3675 wacom_setup_intuos(wacom_wac);
3686 __clear_bit(ABS_MISC, input_dev->absbit);
3693 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3694 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3695 __set_bit(BTN_STYLUS, input_dev->keybit);
3696 __set_bit(BTN_STYLUS2, input_dev->keybit);
3700 __set_bit(BTN_STYLUS2, input_dev->keybit);
3704 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3705 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3706 __set_bit(BTN_STYLUS, input_dev->keybit);
3714 if (features->type == INTUOSHT2 ||
3715 features->type == INTUOSHT3_BT) {
3716 wacom_setup_basic_pro_pen(wacom_wac);
3718 __clear_bit(ABS_MISC, input_dev->absbit);
3719 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3720 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3721 __set_bit(BTN_STYLUS, input_dev->keybit);
3722 __set_bit(BTN_STYLUS2, input_dev->keybit);
3723 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3724 features->distance_max,
3725 features->distance_fuzz, 0);
3729 __clear_bit(ABS_MISC, input_dev->absbit);
3735 int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
3736 struct wacom_wac *wacom_wac)
3738 struct wacom_features *features = &wacom_wac->features;
3740 if (!(features->device_type & WACOM_DEVICETYPE_TOUCH))
3743 if (features->device_type & WACOM_DEVICETYPE_DIRECT)
3744 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
3746 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
3748 if (features->type == HID_GENERIC)
3749 /* setup has already been done */
3752 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3753 __set_bit(BTN_TOUCH, input_dev->keybit);
3755 if (features->touch_max == 1) {
3756 input_set_abs_params(input_dev, ABS_X, 0,
3757 features->x_max, features->x_fuzz, 0);
3758 input_set_abs_params(input_dev, ABS_Y, 0,
3759 features->y_max, features->y_fuzz, 0);
3760 input_abs_set_res(input_dev, ABS_X,
3761 features->x_resolution);
3762 input_abs_set_res(input_dev, ABS_Y,
3763 features->y_resolution);
3765 else if (features->touch_max > 1) {
3766 input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
3767 features->x_max, features->x_fuzz, 0);
3768 input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
3769 features->y_max, features->y_fuzz, 0);
3770 input_abs_set_res(input_dev, ABS_MT_POSITION_X,
3771 features->x_resolution);
3772 input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
3773 features->y_resolution);
3776 switch (features->type) {
3778 input_dev->evbit[0] |= BIT_MASK(EV_SW);
3779 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
3781 if (wacom_wac->shared->touch->product == 0x361) {
3782 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
3784 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
3787 else if (wacom_wac->shared->touch->product == 0x360) {
3788 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
3790 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
3793 input_abs_set_res(input_dev, ABS_MT_POSITION_X, 40);
3794 input_abs_set_res(input_dev, ABS_MT_POSITION_Y, 40);
3804 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
3805 input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, features->y_max, 0, 0);
3806 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
3810 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
3811 input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
3812 input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
3813 input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
3821 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT);
3830 input_dev->evbit[0] |= BIT_MASK(EV_SW);
3831 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
3836 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
3837 input_set_abs_params(input_dev,
3839 0, features->x_max, 0, 0);
3840 input_set_abs_params(input_dev,
3842 0, features->y_max, 0, 0);
3844 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
3848 input_mt_init_slots(input_dev, features->touch_max,
3850 __set_bit(BTN_LEFT, input_dev->keybit);
3851 __set_bit(BTN_RIGHT, input_dev->keybit);
3857 static int wacom_numbered_button_to_key(int n)
3862 return BTN_A + (n-10);
3864 return BTN_BASE + (n-16);
3869 static void wacom_setup_numbered_buttons(struct input_dev *input_dev,
3874 for (i = 0; i < button_count; i++) {
3875 int key = wacom_numbered_button_to_key(i);
3878 __set_bit(key, input_dev->keybit);
3882 static void wacom_24hd_update_leds(struct wacom *wacom, int mask, int group)
3884 struct wacom_led *led;
3886 bool updated = false;
3889 * 24HD has LED group 1 to the left and LED group 0 to the right.
3890 * So group 0 matches the second half of the buttons and thus the mask
3891 * needs to be shifted.
3896 for (i = 0; i < 3; i++) {
3897 led = wacom_led_find(wacom, group, i);
3899 hid_err(wacom->hdev, "can't find LED %d in group %d\n",
3903 if (!updated && mask & BIT(i)) {
3905 led_trigger_event(&led->trigger, LED_FULL);
3912 static bool wacom_is_led_toggled(struct wacom *wacom, int button_count,
3913 int mask, int group)
3918 * 21UX2 has LED group 1 to the left and LED group 0
3919 * to the right. We need to reverse the group to match this
3920 * historical behavior.
3922 if (wacom->wacom_wac.features.type == WACOM_21UX2)
3925 group_button = group * (button_count/wacom->led.count);
3927 if (wacom->wacom_wac.features.type == INTUOSP2_BT)
3930 return mask & (1 << group_button);
3933 static void wacom_update_led(struct wacom *wacom, int button_count, int mask,
3936 struct wacom_led *led, *next_led;
3940 if (wacom->wacom_wac.features.type == WACOM_24HD)
3941 return wacom_24hd_update_leds(wacom, mask, group);
3943 pressed = wacom_is_led_toggled(wacom, button_count, mask, group);
3944 cur = wacom->led.groups[group].select;
3946 led = wacom_led_find(wacom, group, cur);
3948 hid_err(wacom->hdev, "can't find current LED %d in group %d\n",
3958 if (led->held && pressed)
3961 next_led = wacom_led_next(wacom, led);
3963 hid_err(wacom->hdev, "can't find next LED in group %d\n",
3967 if (next_led == led)
3970 next_led->held = true;
3971 led_trigger_event(&next_led->trigger,
3972 wacom_leds_brightness_get(next_led));
3975 static void wacom_report_numbered_buttons(struct input_dev *input_dev,
3976 int button_count, int mask)
3978 struct wacom *wacom = input_get_drvdata(input_dev);
3981 for (i = 0; i < wacom->led.count; i++)
3982 wacom_update_led(wacom, button_count, mask, i);
3984 for (i = 0; i < button_count; i++) {
3985 int key = wacom_numbered_button_to_key(i);
3988 input_report_key(input_dev, key, mask & (1 << i));
3992 int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
3993 struct wacom_wac *wacom_wac)
3995 struct wacom_features *features = &wacom_wac->features;
3997 if ((features->type == HID_GENERIC) && features->numbered_buttons > 0)
3998 features->device_type |= WACOM_DEVICETYPE_PAD;
4000 if (!(features->device_type & WACOM_DEVICETYPE_PAD))
4003 if (features->type == REMOTE && input_dev == wacom_wac->pad_input)
4006 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
4008 /* kept for making legacy xf86-input-wacom working with the wheels */
4009 __set_bit(ABS_MISC, input_dev->absbit);
4011 /* kept for making legacy xf86-input-wacom accepting the pad */
4012 if (!(input_dev->absinfo && (input_dev->absinfo[ABS_X].minimum ||
4013 input_dev->absinfo[ABS_X].maximum)))
4014 input_set_abs_params(input_dev, ABS_X, 0, 1, 0, 0);
4015 if (!(input_dev->absinfo && (input_dev->absinfo[ABS_Y].minimum ||
4016 input_dev->absinfo[ABS_Y].maximum)))
4017 input_set_abs_params(input_dev, ABS_Y, 0, 1, 0, 0);
4019 /* kept for making udev and libwacom accepting the pad */
4020 __set_bit(BTN_STYLUS, input_dev->keybit);
4022 wacom_setup_numbered_buttons(input_dev, features->numbered_buttons);
4024 switch (features->type) {
4027 case CINTIQ_COMPANION_2:
4034 __set_bit(BTN_BACK, input_dev->keybit);
4035 __set_bit(BTN_LEFT, input_dev->keybit);
4036 __set_bit(BTN_FORWARD, input_dev->keybit);
4037 __set_bit(BTN_RIGHT, input_dev->keybit);
4038 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4042 __set_bit(BTN_BACK, input_dev->keybit);
4043 __set_bit(BTN_FORWARD, input_dev->keybit);
4044 input_set_capability(input_dev, EV_REL, REL_WHEEL);
4048 __set_bit(KEY_PROG1, input_dev->keybit);
4049 __set_bit(KEY_PROG2, input_dev->keybit);
4050 __set_bit(KEY_PROG3, input_dev->keybit);
4052 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4053 input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
4057 __set_bit(KEY_PROG1, input_dev->keybit);
4058 __set_bit(KEY_PROG2, input_dev->keybit);
4059 __set_bit(KEY_PROG3, input_dev->keybit);
4060 input_set_abs_params(input_dev, ABS_X, -2048, 2048, 0, 0);
4061 input_abs_set_res(input_dev, ABS_X, 1024); /* points/g */
4062 input_set_abs_params(input_dev, ABS_Y, -2048, 2048, 0, 0);
4063 input_abs_set_res(input_dev, ABS_Y, 1024);
4064 input_set_abs_params(input_dev, ABS_Z, -2048, 2048, 0, 0);
4065 input_abs_set_res(input_dev, ABS_Z, 1024);
4066 __set_bit(INPUT_PROP_ACCELEROMETER, input_dev->propbit);
4070 __set_bit(KEY_PROG1, input_dev->keybit);
4071 __set_bit(KEY_PROG2, input_dev->keybit);
4072 __set_bit(KEY_PROG3, input_dev->keybit);
4078 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
4079 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
4083 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4088 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
4092 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
4102 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4107 * For Bluetooth devices, the udev rule does not work correctly
4108 * for pads unless we add a stylus capability, which forces
4109 * ID_INPUT_TABLET to be set.
4111 __set_bit(BTN_STYLUS, input_dev->keybit);
4117 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4124 __clear_bit(ABS_MISC, input_dev->absbit);
4126 __set_bit(BTN_LEFT, input_dev->keybit);
4127 __set_bit(BTN_FORWARD, input_dev->keybit);
4128 __set_bit(BTN_BACK, input_dev->keybit);
4129 __set_bit(BTN_RIGHT, input_dev->keybit);
4134 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
4135 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4143 /* no pad supported */
4149 static const struct wacom_features wacom_features_0x00 =
4150 { "Wacom Penpartner", 5040, 3780, 255, 0,
4151 PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
4152 static const struct wacom_features wacom_features_0x10 =
4153 { "Wacom Graphire", 10206, 7422, 511, 63,
4154 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4155 static const struct wacom_features wacom_features_0x81 =
4156 { "Wacom Graphire BT", 16704, 12064, 511, 32,
4157 GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES, 2 };
4158 static const struct wacom_features wacom_features_0x11 =
4159 { "Wacom Graphire2 4x5", 10206, 7422, 511, 63,
4160 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4161 static const struct wacom_features wacom_features_0x12 =
4162 { "Wacom Graphire2 5x7", 13918, 10206, 511, 63,
4163 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4164 static const struct wacom_features wacom_features_0x13 =
4165 { "Wacom Graphire3", 10208, 7424, 511, 63,
4166 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4167 static const struct wacom_features wacom_features_0x14 =
4168 { "Wacom Graphire3 6x8", 16704, 12064, 511, 63,
4169 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4170 static const struct wacom_features wacom_features_0x15 =
4171 { "Wacom Graphire4 4x5", 10208, 7424, 511, 63,
4172 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4173 static const struct wacom_features wacom_features_0x16 =
4174 { "Wacom Graphire4 6x8", 16704, 12064, 511, 63,
4175 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4176 static const struct wacom_features wacom_features_0x17 =
4177 { "Wacom BambooFun 4x5", 14760, 9225, 511, 63,
4178 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4179 static const struct wacom_features wacom_features_0x18 =
4180 { "Wacom BambooFun 6x8", 21648, 13530, 511, 63,
4181 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4182 static const struct wacom_features wacom_features_0x19 =
4183 { "Wacom Bamboo1 Medium", 16704, 12064, 511, 63,
4184 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4185 static const struct wacom_features wacom_features_0x60 =
4186 { "Wacom Volito", 5104, 3712, 511, 63,
4187 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4188 static const struct wacom_features wacom_features_0x61 =
4189 { "Wacom PenStation2", 3250, 2320, 255, 63,
4190 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4191 static const struct wacom_features wacom_features_0x62 =
4192 { "Wacom Volito2 4x5", 5104, 3712, 511, 63,
4193 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4194 static const struct wacom_features wacom_features_0x63 =
4195 { "Wacom Volito2 2x3", 3248, 2320, 511, 63,
4196 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4197 static const struct wacom_features wacom_features_0x64 =
4198 { "Wacom PenPartner2", 3250, 2320, 511, 63,
4199 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4200 static const struct wacom_features wacom_features_0x65 =
4201 { "Wacom Bamboo", 14760, 9225, 511, 63,
4202 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4203 static const struct wacom_features wacom_features_0x69 =
4204 { "Wacom Bamboo1", 5104, 3712, 511, 63,
4205 GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
4206 static const struct wacom_features wacom_features_0x6A =
4207 { "Wacom Bamboo1 4x6", 14760, 9225, 1023, 63,
4208 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4209 static const struct wacom_features wacom_features_0x6B =
4210 { "Wacom Bamboo1 5x8", 21648, 13530, 1023, 63,
4211 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4212 static const struct wacom_features wacom_features_0x20 =
4213 { "Wacom Intuos 4x5", 12700, 10600, 1023, 31,
4214 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4215 static const struct wacom_features wacom_features_0x21 =
4216 { "Wacom Intuos 6x8", 20320, 16240, 1023, 31,
4217 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4218 static const struct wacom_features wacom_features_0x22 =
4219 { "Wacom Intuos 9x12", 30480, 24060, 1023, 31,
4220 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4221 static const struct wacom_features wacom_features_0x23 =
4222 { "Wacom Intuos 12x12", 30480, 31680, 1023, 31,
4223 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4224 static const struct wacom_features wacom_features_0x24 =
4225 { "Wacom Intuos 12x18", 45720, 31680, 1023, 31,
4226 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4227 static const struct wacom_features wacom_features_0x30 =
4228 { "Wacom PL400", 5408, 4056, 255, 0,
4229 PL, WACOM_PL_RES, WACOM_PL_RES };
4230 static const struct wacom_features wacom_features_0x31 =
4231 { "Wacom PL500", 6144, 4608, 255, 0,
4232 PL, WACOM_PL_RES, WACOM_PL_RES };
4233 static const struct wacom_features wacom_features_0x32 =
4234 { "Wacom PL600", 6126, 4604, 255, 0,
4235 PL, WACOM_PL_RES, WACOM_PL_RES };
4236 static const struct wacom_features wacom_features_0x33 =
4237 { "Wacom PL600SX", 6260, 5016, 255, 0,
4238 PL, WACOM_PL_RES, WACOM_PL_RES };
4239 static const struct wacom_features wacom_features_0x34 =
4240 { "Wacom PL550", 6144, 4608, 511, 0,
4241 PL, WACOM_PL_RES, WACOM_PL_RES };
4242 static const struct wacom_features wacom_features_0x35 =
4243 { "Wacom PL800", 7220, 5780, 511, 0,
4244 PL, WACOM_PL_RES, WACOM_PL_RES };
4245 static const struct wacom_features wacom_features_0x37 =
4246 { "Wacom PL700", 6758, 5406, 511, 0,
4247 PL, WACOM_PL_RES, WACOM_PL_RES };
4248 static const struct wacom_features wacom_features_0x38 =
4249 { "Wacom PL510", 6282, 4762, 511, 0,
4250 PL, WACOM_PL_RES, WACOM_PL_RES };
4251 static const struct wacom_features wacom_features_0x39 =
4252 { "Wacom DTU710", 34080, 27660, 511, 0,
4253 PL, WACOM_PL_RES, WACOM_PL_RES };
4254 static const struct wacom_features wacom_features_0xC4 =
4255 { "Wacom DTF521", 6282, 4762, 511, 0,
4256 PL, WACOM_PL_RES, WACOM_PL_RES };
4257 static const struct wacom_features wacom_features_0xC0 =
4258 { "Wacom DTF720", 6858, 5506, 511, 0,
4259 PL, WACOM_PL_RES, WACOM_PL_RES };
4260 static const struct wacom_features wacom_features_0xC2 =
4261 { "Wacom DTF720a", 6858, 5506, 511, 0,
4262 PL, WACOM_PL_RES, WACOM_PL_RES };
4263 static const struct wacom_features wacom_features_0x03 =
4264 { "Wacom Cintiq Partner", 20480, 15360, 511, 0,
4265 PTU, WACOM_PL_RES, WACOM_PL_RES };
4266 static const struct wacom_features wacom_features_0x41 =
4267 { "Wacom Intuos2 4x5", 12700, 10600, 1023, 31,
4268 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4269 static const struct wacom_features wacom_features_0x42 =
4270 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
4271 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4272 static const struct wacom_features wacom_features_0x43 =
4273 { "Wacom Intuos2 9x12", 30480, 24060, 1023, 31,
4274 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4275 static const struct wacom_features wacom_features_0x44 =
4276 { "Wacom Intuos2 12x12", 30480, 31680, 1023, 31,
4277 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4278 static const struct wacom_features wacom_features_0x45 =
4279 { "Wacom Intuos2 12x18", 45720, 31680, 1023, 31,
4280 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4281 static const struct wacom_features wacom_features_0xB0 =
4282 { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63,
4283 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
4284 static const struct wacom_features wacom_features_0xB1 =
4285 { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63,
4286 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4287 static const struct wacom_features wacom_features_0xB2 =
4288 { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63,
4289 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4290 static const struct wacom_features wacom_features_0xB3 =
4291 { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63,
4292 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4293 static const struct wacom_features wacom_features_0xB4 =
4294 { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63,
4295 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4296 static const struct wacom_features wacom_features_0xB5 =
4297 { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63,
4298 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4299 static const struct wacom_features wacom_features_0xB7 =
4300 { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63,
4301 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
4302 static const struct wacom_features wacom_features_0xB8 =
4303 { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63,
4304 INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
4305 static const struct wacom_features wacom_features_0xB9 =
4306 { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63,
4307 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4308 static const struct wacom_features wacom_features_0xBA =
4309 { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63,
4310 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4311 static const struct wacom_features wacom_features_0xBB =
4312 { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63,
4313 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4314 static const struct wacom_features wacom_features_0xBC =
4315 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
4316 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4317 static const struct wacom_features wacom_features_0xBD =
4318 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
4319 INTUOS4WL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4320 static const struct wacom_features wacom_features_0x26 =
4321 { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63,
4322 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16 };
4323 static const struct wacom_features wacom_features_0x27 =
4324 { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63,
4325 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
4326 static const struct wacom_features wacom_features_0x28 =
4327 { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63,
4328 INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
4329 static const struct wacom_features wacom_features_0x29 =
4330 { "Wacom Intuos5 S", 31496, 19685, 2047, 63,
4331 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
4332 static const struct wacom_features wacom_features_0x2A =
4333 { "Wacom Intuos5 M", 44704, 27940, 2047, 63,
4334 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4335 static const struct wacom_features wacom_features_0x314 =
4336 { "Wacom Intuos Pro S", 31496, 19685, 2047, 63,
4337 INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16,
4338 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4339 static const struct wacom_features wacom_features_0x315 =
4340 { "Wacom Intuos Pro M", 44704, 27940, 2047, 63,
4341 INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
4342 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4343 static const struct wacom_features wacom_features_0x317 =
4344 { "Wacom Intuos Pro L", 65024, 40640, 2047, 63,
4345 INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
4346 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4347 static const struct wacom_features wacom_features_0xF4 =
4348 { "Wacom Cintiq 24HD", 104480, 65600, 2047, 63,
4349 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
4350 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4351 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4352 static const struct wacom_features wacom_features_0xF8 =
4353 { "Wacom Cintiq 24HD touch", 104480, 65600, 2047, 63, /* Pen */
4354 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
4355 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4356 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4357 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 };
4358 static const struct wacom_features wacom_features_0xF6 =
4359 { "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */
4360 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10,
4361 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4362 static const struct wacom_features wacom_features_0x32A =
4363 { "Wacom Cintiq 27QHD", 120140, 67920, 2047, 63,
4364 WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
4365 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4366 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4367 static const struct wacom_features wacom_features_0x32B =
4368 { "Wacom Cintiq 27QHD touch", 120140, 67920, 2047, 63,
4369 WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
4370 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4371 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4372 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32C };
4373 static const struct wacom_features wacom_features_0x32C =
4374 { "Wacom Cintiq 27QHD touch", .type = WACOM_27QHDT,
4375 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32B, .touch_max = 10 };
4376 static const struct wacom_features wacom_features_0x3F =
4377 { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63,
4378 CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4379 static const struct wacom_features wacom_features_0xC5 =
4380 { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63,
4381 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
4382 static const struct wacom_features wacom_features_0xC6 =
4383 { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63,
4384 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
4385 static const struct wacom_features wacom_features_0x304 =
4386 { "Wacom Cintiq 13HD", 59552, 33848, 1023, 63,
4387 WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4388 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4389 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4390 static const struct wacom_features wacom_features_0x333 =
4391 { "Wacom Cintiq 13HD touch", 59552, 33848, 2047, 63,
4392 WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4393 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4394 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4395 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x335 };
4396 static const struct wacom_features wacom_features_0x335 =
4397 { "Wacom Cintiq 13HD touch", .type = WACOM_24HDT, /* Touch */
4398 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x333, .touch_max = 10,
4399 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4400 static const struct wacom_features wacom_features_0xC7 =
4401 { "Wacom DTU1931", 37832, 30305, 511, 0,
4402 PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4403 static const struct wacom_features wacom_features_0xCE =
4404 { "Wacom DTU2231", 47864, 27011, 511, 0,
4405 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4406 .check_for_hid_type = true, .hid_type = HID_TYPE_USBMOUSE };
4407 static const struct wacom_features wacom_features_0xF0 =
4408 { "Wacom DTU1631", 34623, 19553, 511, 0,
4409 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4410 static const struct wacom_features wacom_features_0xFB =
4411 { "Wacom DTU1031", 22096, 13960, 511, 0,
4412 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
4413 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4414 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4415 static const struct wacom_features wacom_features_0x32F =
4416 { "Wacom DTU1031X", 22672, 12928, 511, 0,
4417 DTUSX, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 0,
4418 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4419 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4420 static const struct wacom_features wacom_features_0x336 =
4421 { "Wacom DTU1141", 23672, 13403, 1023, 0,
4422 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
4423 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4424 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4425 static const struct wacom_features wacom_features_0x57 =
4426 { "Wacom DTK2241", 95840, 54260, 2047, 63,
4427 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
4428 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4429 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4430 static const struct wacom_features wacom_features_0x59 = /* Pen */
4431 { "Wacom DTH2242", 95840, 54260, 2047, 63,
4432 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
4433 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4434 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4435 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D };
4436 static const struct wacom_features wacom_features_0x5D = /* Touch */
4437 { "Wacom DTH2242", .type = WACOM_24HDT,
4438 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10,
4439 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4440 static const struct wacom_features wacom_features_0xCC =
4441 { "Wacom Cintiq 21UX2", 87200, 65600, 2047, 63,
4442 WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
4443 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4444 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4445 static const struct wacom_features wacom_features_0xFA =
4446 { "Wacom Cintiq 22HD", 95840, 54260, 2047, 63,
4447 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
4448 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4449 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4450 static const struct wacom_features wacom_features_0x5B =
4451 { "Wacom Cintiq 22HDT", 95840, 54260, 2047, 63,
4452 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
4453 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4454 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4455 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e };
4456 static const struct wacom_features wacom_features_0x5E =
4457 { "Wacom Cintiq 22HDT", .type = WACOM_24HDT,
4458 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5b, .touch_max = 10,
4459 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4460 static const struct wacom_features wacom_features_0x90 =
4461 { "Wacom ISDv4 90", 26202, 16325, 255, 0,
4462 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4463 static const struct wacom_features wacom_features_0x93 =
4464 { "Wacom ISDv4 93", 26202, 16325, 255, 0,
4465 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4466 static const struct wacom_features wacom_features_0x97 =
4467 { "Wacom ISDv4 97", 26202, 16325, 511, 0,
4468 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4469 static const struct wacom_features wacom_features_0x9A =
4470 { "Wacom ISDv4 9A", 26202, 16325, 255, 0,
4471 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4472 static const struct wacom_features wacom_features_0x9F =
4473 { "Wacom ISDv4 9F", 26202, 16325, 255, 0,
4474 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4475 static const struct wacom_features wacom_features_0xE2 =
4476 { "Wacom ISDv4 E2", 26202, 16325, 255, 0,
4477 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4478 static const struct wacom_features wacom_features_0xE3 =
4479 { "Wacom ISDv4 E3", 26202, 16325, 255, 0,
4480 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4481 static const struct wacom_features wacom_features_0xE5 =
4482 { "Wacom ISDv4 E5", 26202, 16325, 255, 0,
4483 MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4484 static const struct wacom_features wacom_features_0xE6 =
4485 { "Wacom ISDv4 E6", 27760, 15694, 255, 0,
4486 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4487 static const struct wacom_features wacom_features_0xEC =
4488 { "Wacom ISDv4 EC", 25710, 14500, 255, 0,
4489 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4490 static const struct wacom_features wacom_features_0xED =
4491 { "Wacom ISDv4 ED", 26202, 16325, 255, 0,
4492 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4493 static const struct wacom_features wacom_features_0xEF =
4494 { "Wacom ISDv4 EF", 26202, 16325, 255, 0,
4495 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4496 static const struct wacom_features wacom_features_0x100 =
4497 { "Wacom ISDv4 100", 26202, 16325, 255, 0,
4498 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4499 static const struct wacom_features wacom_features_0x101 =
4500 { "Wacom ISDv4 101", 26202, 16325, 255, 0,
4501 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4502 static const struct wacom_features wacom_features_0x10D =
4503 { "Wacom ISDv4 10D", 26202, 16325, 255, 0,
4504 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4505 static const struct wacom_features wacom_features_0x10E =
4506 { "Wacom ISDv4 10E", 27760, 15694, 255, 0,
4507 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4508 static const struct wacom_features wacom_features_0x10F =
4509 { "Wacom ISDv4 10F", 27760, 15694, 255, 0,
4510 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4511 static const struct wacom_features wacom_features_0x116 =
4512 { "Wacom ISDv4 116", 26202, 16325, 255, 0,
4513 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4514 static const struct wacom_features wacom_features_0x12C =
4515 { "Wacom ISDv4 12C", 27848, 15752, 2047, 0,
4516 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4517 static const struct wacom_features wacom_features_0x4001 =
4518 { "Wacom ISDv4 4001", 26202, 16325, 255, 0,
4519 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4520 static const struct wacom_features wacom_features_0x4004 =
4521 { "Wacom ISDv4 4004", 11060, 6220, 255, 0,
4522 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4523 static const struct wacom_features wacom_features_0x5000 =
4524 { "Wacom ISDv4 5000", 27848, 15752, 1023, 0,
4525 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4526 static const struct wacom_features wacom_features_0x5002 =
4527 { "Wacom ISDv4 5002", 29576, 16724, 1023, 0,
4528 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4529 static const struct wacom_features wacom_features_0x47 =
4530 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
4531 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4532 static const struct wacom_features wacom_features_0x84 =
4533 { "Wacom Wireless Receiver", .type = WIRELESS, .touch_max = 16 };
4534 static const struct wacom_features wacom_features_0xD0 =
4535 { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31,
4536 BAMBOO_TOUCH, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4537 static const struct wacom_features wacom_features_0xD1 =
4538 { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31,
4539 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4540 static const struct wacom_features wacom_features_0xD2 =
4541 { "Wacom Bamboo Craft", 14720, 9200, 1023, 31,
4542 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4543 static const struct wacom_features wacom_features_0xD3 =
4544 { "Wacom Bamboo 2FG 6x8", 21648, 13700, 1023, 31,
4545 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4546 static const struct wacom_features wacom_features_0xD4 =
4547 { "Wacom Bamboo Pen", 14720, 9200, 1023, 31,
4548 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4549 static const struct wacom_features wacom_features_0xD5 =
4550 { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31,
4551 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4552 static const struct wacom_features wacom_features_0xD6 =
4553 { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31,
4554 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4555 static const struct wacom_features wacom_features_0xD7 =
4556 { "Wacom BambooPT 2FG Small", 14720, 9200, 1023, 31,
4557 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4558 static const struct wacom_features wacom_features_0xD8 =
4559 { "Wacom Bamboo Comic 2FG", 21648, 13700, 1023, 31,
4560 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4561 static const struct wacom_features wacom_features_0xDA =
4562 { "Wacom Bamboo 2FG 4x5 SE", 14720, 9200, 1023, 31,
4563 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4564 static const struct wacom_features wacom_features_0xDB =
4565 { "Wacom Bamboo 2FG 6x8 SE", 21648, 13700, 1023, 31,
4566 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4567 static const struct wacom_features wacom_features_0xDD =
4568 { "Wacom Bamboo Connect", 14720, 9200, 1023, 31,
4569 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4570 static const struct wacom_features wacom_features_0xDE =
4571 { "Wacom Bamboo 16FG 4x5", 14720, 9200, 1023, 31,
4572 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
4573 static const struct wacom_features wacom_features_0xDF =
4574 { "Wacom Bamboo 16FG 6x8", 21648, 13700, 1023, 31,
4575 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
4576 static const struct wacom_features wacom_features_0x300 =
4577 { "Wacom Bamboo One S", 14720, 9225, 1023, 31,
4578 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4579 static const struct wacom_features wacom_features_0x301 =
4580 { "Wacom Bamboo One M", 21648, 13530, 1023, 31,
4581 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4582 static const struct wacom_features wacom_features_0x302 =
4583 { "Wacom Intuos PT S", 15200, 9500, 1023, 31,
4584 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4585 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4586 static const struct wacom_features wacom_features_0x303 =
4587 { "Wacom Intuos PT M", 21600, 13500, 1023, 31,
4588 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4589 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4590 static const struct wacom_features wacom_features_0x30E =
4591 { "Wacom Intuos S", 15200, 9500, 1023, 31,
4592 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4593 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4594 static const struct wacom_features wacom_features_0x6004 =
4595 { "ISD-V4", 12800, 8000, 255, 0,
4596 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4597 static const struct wacom_features wacom_features_0x307 =
4598 { "Wacom ISDv5 307", 59552, 33848, 2047, 63,
4599 CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4600 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4601 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4602 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 };
4603 static const struct wacom_features wacom_features_0x309 =
4604 { "Wacom ISDv5 309", .type = WACOM_24HDT, /* Touch */
4605 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x0307, .touch_max = 10,
4606 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4607 static const struct wacom_features wacom_features_0x30A =
4608 { "Wacom ISDv5 30A", 59552, 33848, 2047, 63,
4609 CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4610 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4611 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4612 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30C };
4613 static const struct wacom_features wacom_features_0x30C =
4614 { "Wacom ISDv5 30C", .type = WACOM_24HDT, /* Touch */
4615 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30A, .touch_max = 10,
4616 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4617 static const struct wacom_features wacom_features_0x318 =
4618 { "Wacom USB Bamboo PAD", 4095, 4095, /* Touch */
4619 .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
4620 static const struct wacom_features wacom_features_0x319 =
4621 { "Wacom Wireless Bamboo PAD", 4095, 4095, /* Touch */
4622 .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
4623 static const struct wacom_features wacom_features_0x325 =
4624 { "Wacom ISDv5 325", 59552, 33848, 2047, 63,
4625 CINTIQ_COMPANION_2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 11,
4626 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4627 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4628 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x326 };
4629 static const struct wacom_features wacom_features_0x326 = /* Touch */
4630 { "Wacom ISDv5 326", .type = HID_GENERIC, .oVid = USB_VENDOR_ID_WACOM,
4632 static const struct wacom_features wacom_features_0x323 =
4633 { "Wacom Intuos P M", 21600, 13500, 1023, 31,
4634 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4635 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4636 static const struct wacom_features wacom_features_0x331 =
4637 { "Wacom Express Key Remote", .type = REMOTE,
4638 .numbered_buttons = 18, .check_for_hid_type = true,
4639 .hid_type = HID_TYPE_USBNONE };
4640 static const struct wacom_features wacom_features_0x33B =
4641 { "Wacom Intuos S 2", 15200, 9500, 2047, 63,
4642 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4643 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4644 static const struct wacom_features wacom_features_0x33C =
4645 { "Wacom Intuos PT S 2", 15200, 9500, 2047, 63,
4646 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4647 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4648 static const struct wacom_features wacom_features_0x33D =
4649 { "Wacom Intuos P M 2", 21600, 13500, 2047, 63,
4650 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4651 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4652 static const struct wacom_features wacom_features_0x33E =
4653 { "Wacom Intuos PT M 2", 21600, 13500, 2047, 63,
4654 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4655 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4656 static const struct wacom_features wacom_features_0x343 =
4657 { "Wacom DTK1651", 34816, 19759, 1023, 0,
4658 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
4659 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4660 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4661 static const struct wacom_features wacom_features_0x360 =
4662 { "Wacom Intuos Pro M", 44800, 29600, 8191, 63,
4663 INTUOSP2_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 10 };
4664 static const struct wacom_features wacom_features_0x361 =
4665 { "Wacom Intuos Pro L", 62200, 43200, 8191, 63,
4666 INTUOSP2_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 10 };
4667 static const struct wacom_features wacom_features_0x377 =
4668 { "Wacom Intuos BT S", 15200, 9500, 4095, 63,
4669 INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
4670 static const struct wacom_features wacom_features_0x379 =
4671 { "Wacom Intuos BT M", 21600, 13500, 4095, 63,
4672 INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
4673 static const struct wacom_features wacom_features_0x37A =
4674 { "Wacom One by Wacom S", 15200, 9500, 2047, 63,
4675 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4676 static const struct wacom_features wacom_features_0x37B =
4677 { "Wacom One by Wacom M", 21600, 13500, 2047, 63,
4678 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4680 static const struct wacom_features wacom_features_HID_ANY_ID =
4681 { "Wacom HID", .type = HID_GENERIC, .oVid = HID_ANY_ID, .oPid = HID_ANY_ID };
4683 #define USB_DEVICE_WACOM(prod) \
4684 HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4685 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4687 #define BT_DEVICE_WACOM(prod) \
4688 HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4689 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4691 #define I2C_DEVICE_WACOM(prod) \
4692 HID_DEVICE(BUS_I2C, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4693 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4695 #define USB_DEVICE_LENOVO(prod) \
4696 HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
4697 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4699 const struct hid_device_id wacom_ids[] = {
4700 { USB_DEVICE_WACOM(0x00) },
4701 { USB_DEVICE_WACOM(0x03) },
4702 { USB_DEVICE_WACOM(0x10) },
4703 { USB_DEVICE_WACOM(0x11) },
4704 { USB_DEVICE_WACOM(0x12) },
4705 { USB_DEVICE_WACOM(0x13) },
4706 { USB_DEVICE_WACOM(0x14) },
4707 { USB_DEVICE_WACOM(0x15) },
4708 { USB_DEVICE_WACOM(0x16) },
4709 { USB_DEVICE_WACOM(0x17) },
4710 { USB_DEVICE_WACOM(0x18) },
4711 { USB_DEVICE_WACOM(0x19) },
4712 { USB_DEVICE_WACOM(0x20) },
4713 { USB_DEVICE_WACOM(0x21) },
4714 { USB_DEVICE_WACOM(0x22) },
4715 { USB_DEVICE_WACOM(0x23) },
4716 { USB_DEVICE_WACOM(0x24) },
4717 { USB_DEVICE_WACOM(0x26) },
4718 { USB_DEVICE_WACOM(0x27) },
4719 { USB_DEVICE_WACOM(0x28) },
4720 { USB_DEVICE_WACOM(0x29) },
4721 { USB_DEVICE_WACOM(0x2A) },
4722 { USB_DEVICE_WACOM(0x30) },
4723 { USB_DEVICE_WACOM(0x31) },
4724 { USB_DEVICE_WACOM(0x32) },
4725 { USB_DEVICE_WACOM(0x33) },
4726 { USB_DEVICE_WACOM(0x34) },
4727 { USB_DEVICE_WACOM(0x35) },
4728 { USB_DEVICE_WACOM(0x37) },
4729 { USB_DEVICE_WACOM(0x38) },
4730 { USB_DEVICE_WACOM(0x39) },
4731 { USB_DEVICE_WACOM(0x3F) },
4732 { USB_DEVICE_WACOM(0x41) },
4733 { USB_DEVICE_WACOM(0x42) },
4734 { USB_DEVICE_WACOM(0x43) },
4735 { USB_DEVICE_WACOM(0x44) },
4736 { USB_DEVICE_WACOM(0x45) },
4737 { USB_DEVICE_WACOM(0x47) },
4738 { USB_DEVICE_WACOM(0x57) },
4739 { USB_DEVICE_WACOM(0x59) },
4740 { USB_DEVICE_WACOM(0x5B) },
4741 { USB_DEVICE_WACOM(0x5D) },
4742 { USB_DEVICE_WACOM(0x5E) },
4743 { USB_DEVICE_WACOM(0x60) },
4744 { USB_DEVICE_WACOM(0x61) },
4745 { USB_DEVICE_WACOM(0x62) },
4746 { USB_DEVICE_WACOM(0x63) },
4747 { USB_DEVICE_WACOM(0x64) },
4748 { USB_DEVICE_WACOM(0x65) },
4749 { USB_DEVICE_WACOM(0x69) },
4750 { USB_DEVICE_WACOM(0x6A) },
4751 { USB_DEVICE_WACOM(0x6B) },
4752 { BT_DEVICE_WACOM(0x81) },
4753 { USB_DEVICE_WACOM(0x84) },
4754 { USB_DEVICE_WACOM(0x90) },
4755 { USB_DEVICE_WACOM(0x93) },
4756 { USB_DEVICE_WACOM(0x97) },
4757 { USB_DEVICE_WACOM(0x9A) },
4758 { USB_DEVICE_WACOM(0x9F) },
4759 { USB_DEVICE_WACOM(0xB0) },
4760 { USB_DEVICE_WACOM(0xB1) },
4761 { USB_DEVICE_WACOM(0xB2) },
4762 { USB_DEVICE_WACOM(0xB3) },
4763 { USB_DEVICE_WACOM(0xB4) },
4764 { USB_DEVICE_WACOM(0xB5) },
4765 { USB_DEVICE_WACOM(0xB7) },
4766 { USB_DEVICE_WACOM(0xB8) },
4767 { USB_DEVICE_WACOM(0xB9) },
4768 { USB_DEVICE_WACOM(0xBA) },
4769 { USB_DEVICE_WACOM(0xBB) },
4770 { USB_DEVICE_WACOM(0xBC) },
4771 { BT_DEVICE_WACOM(0xBD) },
4772 { USB_DEVICE_WACOM(0xC0) },
4773 { USB_DEVICE_WACOM(0xC2) },
4774 { USB_DEVICE_WACOM(0xC4) },
4775 { USB_DEVICE_WACOM(0xC5) },
4776 { USB_DEVICE_WACOM(0xC6) },
4777 { USB_DEVICE_WACOM(0xC7) },
4778 { USB_DEVICE_WACOM(0xCC) },
4779 { USB_DEVICE_WACOM(0xCE) },
4780 { USB_DEVICE_WACOM(0xD0) },
4781 { USB_DEVICE_WACOM(0xD1) },
4782 { USB_DEVICE_WACOM(0xD2) },
4783 { USB_DEVICE_WACOM(0xD3) },
4784 { USB_DEVICE_WACOM(0xD4) },
4785 { USB_DEVICE_WACOM(0xD5) },
4786 { USB_DEVICE_WACOM(0xD6) },
4787 { USB_DEVICE_WACOM(0xD7) },
4788 { USB_DEVICE_WACOM(0xD8) },
4789 { USB_DEVICE_WACOM(0xDA) },
4790 { USB_DEVICE_WACOM(0xDB) },
4791 { USB_DEVICE_WACOM(0xDD) },
4792 { USB_DEVICE_WACOM(0xDE) },
4793 { USB_DEVICE_WACOM(0xDF) },
4794 { USB_DEVICE_WACOM(0xE2) },
4795 { USB_DEVICE_WACOM(0xE3) },
4796 { USB_DEVICE_WACOM(0xE5) },
4797 { USB_DEVICE_WACOM(0xE6) },
4798 { USB_DEVICE_WACOM(0xEC) },
4799 { USB_DEVICE_WACOM(0xED) },
4800 { USB_DEVICE_WACOM(0xEF) },
4801 { USB_DEVICE_WACOM(0xF0) },
4802 { USB_DEVICE_WACOM(0xF4) },
4803 { USB_DEVICE_WACOM(0xF6) },
4804 { USB_DEVICE_WACOM(0xF8) },
4805 { USB_DEVICE_WACOM(0xFA) },
4806 { USB_DEVICE_WACOM(0xFB) },
4807 { USB_DEVICE_WACOM(0x100) },
4808 { USB_DEVICE_WACOM(0x101) },
4809 { USB_DEVICE_WACOM(0x10D) },
4810 { USB_DEVICE_WACOM(0x10E) },
4811 { USB_DEVICE_WACOM(0x10F) },
4812 { USB_DEVICE_WACOM(0x116) },
4813 { USB_DEVICE_WACOM(0x12C) },
4814 { USB_DEVICE_WACOM(0x300) },
4815 { USB_DEVICE_WACOM(0x301) },
4816 { USB_DEVICE_WACOM(0x302) },
4817 { USB_DEVICE_WACOM(0x303) },
4818 { USB_DEVICE_WACOM(0x304) },
4819 { USB_DEVICE_WACOM(0x307) },
4820 { USB_DEVICE_WACOM(0x309) },
4821 { USB_DEVICE_WACOM(0x30A) },
4822 { USB_DEVICE_WACOM(0x30C) },
4823 { USB_DEVICE_WACOM(0x30E) },
4824 { USB_DEVICE_WACOM(0x314) },
4825 { USB_DEVICE_WACOM(0x315) },
4826 { USB_DEVICE_WACOM(0x317) },
4827 { USB_DEVICE_WACOM(0x318) },
4828 { USB_DEVICE_WACOM(0x319) },
4829 { USB_DEVICE_WACOM(0x323) },
4830 { USB_DEVICE_WACOM(0x325) },
4831 { USB_DEVICE_WACOM(0x326) },
4832 { USB_DEVICE_WACOM(0x32A) },
4833 { USB_DEVICE_WACOM(0x32B) },
4834 { USB_DEVICE_WACOM(0x32C) },
4835 { USB_DEVICE_WACOM(0x32F) },
4836 { USB_DEVICE_WACOM(0x331) },
4837 { USB_DEVICE_WACOM(0x333) },
4838 { USB_DEVICE_WACOM(0x335) },
4839 { USB_DEVICE_WACOM(0x336) },
4840 { USB_DEVICE_WACOM(0x33B) },
4841 { USB_DEVICE_WACOM(0x33C) },
4842 { USB_DEVICE_WACOM(0x33D) },
4843 { USB_DEVICE_WACOM(0x33E) },
4844 { USB_DEVICE_WACOM(0x343) },
4845 { BT_DEVICE_WACOM(0x360) },
4846 { BT_DEVICE_WACOM(0x361) },
4847 { BT_DEVICE_WACOM(0x377) },
4848 { BT_DEVICE_WACOM(0x379) },
4849 { USB_DEVICE_WACOM(0x37A) },
4850 { USB_DEVICE_WACOM(0x37B) },
4851 { USB_DEVICE_WACOM(0x4001) },
4852 { USB_DEVICE_WACOM(0x4004) },
4853 { USB_DEVICE_WACOM(0x5000) },
4854 { USB_DEVICE_WACOM(0x5002) },
4855 { USB_DEVICE_LENOVO(0x6004) },
4857 { USB_DEVICE_WACOM(HID_ANY_ID) },
4858 { I2C_DEVICE_WACOM(HID_ANY_ID) },
4859 { BT_DEVICE_WACOM(HID_ANY_ID) },
4862 MODULE_DEVICE_TABLE(hid, wacom_ids);