1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * drivers/input/tablet/wacom_wac.c
5 * USB Wacom tablet support - Wacom specific code
11 #include "wacom_wac.h"
13 #include <linux/input/mt.h>
14 #include <linux/jiffies.h>
16 /* resolution for penabled devices */
17 #define WACOM_PL_RES 20
18 #define WACOM_PENPRTN_RES 40
19 #define WACOM_VOLITO_RES 50
20 #define WACOM_GRAPHIRE_RES 80
21 #define WACOM_INTUOS_RES 100
22 #define WACOM_INTUOS3_RES 200
24 /* Newer Cintiq and DTU have an offset between tablet and screen areas */
25 #define WACOM_DTU_OFFSET 200
26 #define WACOM_CINTIQ_OFFSET 400
29 * Scale factor relating reported contact size to logical contact area.
30 * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo
32 #define WACOM_CONTACT_AREA_SCALE 2607
34 static bool touch_arbitration = 1;
35 module_param(touch_arbitration, bool, 0644);
36 MODULE_PARM_DESC(touch_arbitration, " on (Y) off (N)");
38 static void wacom_report_numbered_buttons(struct input_dev *input_dev,
39 int button_count, int mask);
41 static int wacom_numbered_button_to_key(int n);
43 static void wacom_update_led(struct wacom *wacom, int button_count, int mask,
46 static void wacom_force_proxout(struct wacom_wac *wacom_wac)
48 struct input_dev *input = wacom_wac->pen_input;
50 wacom_wac->shared->stylus_in_proximity = 0;
52 input_report_key(input, BTN_TOUCH, 0);
53 input_report_key(input, BTN_STYLUS, 0);
54 input_report_key(input, BTN_STYLUS2, 0);
55 input_report_key(input, BTN_STYLUS3, 0);
56 input_report_key(input, wacom_wac->tool[0], 0);
57 if (wacom_wac->serial[0]) {
58 input_report_abs(input, ABS_MISC, 0);
60 input_report_abs(input, ABS_PRESSURE, 0);
62 wacom_wac->tool[0] = 0;
64 wacom_wac->serial[0] = 0;
69 void wacom_idleprox_timeout(struct timer_list *list)
71 struct wacom *wacom = from_timer(wacom, list, idleprox_timer);
72 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
74 if (!wacom_wac->hid_data.sense_state) {
78 hid_warn(wacom->hdev, "%s: tool appears to be hung in-prox. forcing it out.\n", __func__);
79 wacom_force_proxout(wacom_wac);
83 * Percent of battery capacity for Graphire.
84 * 8th value means AC online and show 100% capacity.
86 static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
89 * Percent of battery capacity for Intuos4 WL, AC has a separate bit.
91 static unsigned short batcap_i4[8] = { 1, 15, 30, 45, 60, 70, 85, 100 };
93 static void __wacom_notify_battery(struct wacom_battery *battery,
94 int bat_status, int bat_capacity,
95 bool bat_charging, bool bat_connected,
98 bool changed = battery->bat_status != bat_status ||
99 battery->battery_capacity != bat_capacity ||
100 battery->bat_charging != bat_charging ||
101 battery->bat_connected != bat_connected ||
102 battery->ps_connected != ps_connected;
105 battery->bat_status = bat_status;
106 battery->battery_capacity = bat_capacity;
107 battery->bat_charging = bat_charging;
108 battery->bat_connected = bat_connected;
109 battery->ps_connected = ps_connected;
111 if (battery->battery)
112 power_supply_changed(battery->battery);
116 static void wacom_notify_battery(struct wacom_wac *wacom_wac,
117 int bat_status, int bat_capacity, bool bat_charging,
118 bool bat_connected, bool ps_connected)
120 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
122 __wacom_notify_battery(&wacom->battery, bat_status, bat_capacity,
123 bat_charging, bat_connected, ps_connected);
126 static int wacom_penpartner_irq(struct wacom_wac *wacom)
128 unsigned char *data = wacom->data;
129 struct input_dev *input = wacom->pen_input;
133 if (data[5] & 0x80) {
134 wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
135 wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID;
136 input_report_key(input, wacom->tool[0], 1);
137 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
138 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
139 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
140 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
141 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127));
142 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
144 input_report_key(input, wacom->tool[0], 0);
145 input_report_abs(input, ABS_MISC, 0); /* report tool id */
146 input_report_abs(input, ABS_PRESSURE, -1);
147 input_report_key(input, BTN_TOUCH, 0);
152 input_report_key(input, BTN_TOOL_PEN, 1);
153 input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
154 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
155 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
156 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
157 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
158 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
162 dev_dbg(input->dev.parent,
163 "%s: received unknown report #%d\n", __func__, data[0]);
170 static int wacom_pl_irq(struct wacom_wac *wacom)
172 struct wacom_features *features = &wacom->features;
173 unsigned char *data = wacom->data;
174 struct input_dev *input = wacom->pen_input;
177 if (data[0] != WACOM_REPORT_PENABLED) {
178 dev_dbg(input->dev.parent,
179 "%s: received unknown report #%d\n", __func__, data[0]);
183 prox = data[1] & 0x40;
186 if ((data[0] & 0x10) || (data[4] & 0x20)) {
187 wacom->tool[0] = BTN_TOOL_RUBBER;
188 wacom->id[0] = ERASER_DEVICE_ID;
191 wacom->tool[0] = BTN_TOOL_PEN;
192 wacom->id[0] = STYLUS_DEVICE_ID;
196 /* If the eraser is in prox, STYLUS2 is always set. If we
197 * mis-detected the type and notice that STYLUS2 isn't set
198 * then force the eraser out of prox and let the pen in.
200 if (wacom->tool[0] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
201 input_report_key(input, BTN_TOOL_RUBBER, 0);
202 input_report_abs(input, ABS_MISC, 0);
204 wacom->tool[0] = BTN_TOOL_PEN;
205 wacom->id[0] = STYLUS_DEVICE_ID;
209 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
210 if (features->pressure_max > 255)
211 pressure = (pressure << 1) | ((data[4] >> 6) & 1);
212 pressure += (features->pressure_max + 1) / 2;
214 input_report_abs(input, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
215 input_report_abs(input, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
216 input_report_abs(input, ABS_PRESSURE, pressure);
218 input_report_key(input, BTN_TOUCH, data[4] & 0x08);
219 input_report_key(input, BTN_STYLUS, data[4] & 0x10);
220 /* Only allow the stylus2 button to be reported for the pen tool. */
221 input_report_key(input, BTN_STYLUS2, (wacom->tool[0] == BTN_TOOL_PEN) && (data[4] & 0x20));
226 input_report_key(input, wacom->tool[0], prox);
227 input_report_abs(input, ABS_MISC, wacom->id[0]);
231 static int wacom_ptu_irq(struct wacom_wac *wacom)
233 unsigned char *data = wacom->data;
234 struct input_dev *input = wacom->pen_input;
236 if (data[0] != WACOM_REPORT_PENABLED) {
237 dev_dbg(input->dev.parent,
238 "%s: received unknown report #%d\n", __func__, data[0]);
242 if (data[1] & 0x04) {
243 input_report_key(input, BTN_TOOL_RUBBER, data[1] & 0x20);
244 input_report_key(input, BTN_TOUCH, data[1] & 0x08);
245 wacom->id[0] = ERASER_DEVICE_ID;
247 input_report_key(input, BTN_TOOL_PEN, data[1] & 0x20);
248 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
249 wacom->id[0] = STYLUS_DEVICE_ID;
251 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
252 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
253 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
254 input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6]));
255 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
256 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
260 static int wacom_dtu_irq(struct wacom_wac *wacom)
262 unsigned char *data = wacom->data;
263 struct input_dev *input = wacom->pen_input;
264 int prox = data[1] & 0x20;
266 dev_dbg(input->dev.parent,
267 "%s: received report #%d", __func__, data[0]);
270 /* Going into proximity select tool */
271 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
272 if (wacom->tool[0] == BTN_TOOL_PEN)
273 wacom->id[0] = STYLUS_DEVICE_ID;
275 wacom->id[0] = ERASER_DEVICE_ID;
277 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
278 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
279 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
280 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
281 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x01) << 8) | data[6]);
282 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
283 if (!prox) /* out-prox */
285 input_report_key(input, wacom->tool[0], prox);
286 input_report_abs(input, ABS_MISC, wacom->id[0]);
290 static int wacom_dtus_irq(struct wacom_wac *wacom)
292 unsigned char *data = wacom->data;
293 struct input_dev *input = wacom->pen_input;
294 unsigned short prox, pressure = 0;
296 if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) {
297 dev_dbg(input->dev.parent,
298 "%s: received unknown report #%d", __func__, data[0]);
300 } else if (data[0] == WACOM_REPORT_DTUSPAD) {
301 input = wacom->pad_input;
302 input_report_key(input, BTN_0, (data[1] & 0x01));
303 input_report_key(input, BTN_1, (data[1] & 0x02));
304 input_report_key(input, BTN_2, (data[1] & 0x04));
305 input_report_key(input, BTN_3, (data[1] & 0x08));
306 input_report_abs(input, ABS_MISC,
307 data[1] & 0x0f ? PAD_DEVICE_ID : 0);
310 prox = data[1] & 0x80;
312 switch ((data[1] >> 3) & 3) {
314 wacom->tool[0] = BTN_TOOL_RUBBER;
315 wacom->id[0] = ERASER_DEVICE_ID;
319 wacom->tool[0] = BTN_TOOL_PEN;
320 wacom->id[0] = STYLUS_DEVICE_ID;
325 input_report_key(input, BTN_STYLUS, data[1] & 0x20);
326 input_report_key(input, BTN_STYLUS2, data[1] & 0x40);
327 input_report_abs(input, ABS_X, get_unaligned_be16(&data[3]));
328 input_report_abs(input, ABS_Y, get_unaligned_be16(&data[5]));
329 pressure = ((data[1] & 0x03) << 8) | (data[2] & 0xff);
330 input_report_abs(input, ABS_PRESSURE, pressure);
331 input_report_key(input, BTN_TOUCH, pressure > 10);
333 if (!prox) /* out-prox */
335 input_report_key(input, wacom->tool[0], prox);
336 input_report_abs(input, ABS_MISC, wacom->id[0]);
341 static int wacom_graphire_irq(struct wacom_wac *wacom)
343 struct wacom_features *features = &wacom->features;
344 unsigned char *data = wacom->data;
345 struct input_dev *input = wacom->pen_input;
346 struct input_dev *pad_input = wacom->pad_input;
347 int battery_capacity, ps_connected;
352 if (features->type == GRAPHIRE_BT) {
353 if (data[0] != WACOM_REPORT_PENABLED_BT) {
354 dev_dbg(input->dev.parent,
355 "%s: received unknown report #%d\n", __func__,
359 } else if (data[0] != WACOM_REPORT_PENABLED) {
360 dev_dbg(input->dev.parent,
361 "%s: received unknown report #%d\n", __func__, data[0]);
365 prox = data[1] & 0x80;
366 if (prox || wacom->id[0]) {
368 switch ((data[1] >> 5) & 3) {
371 wacom->tool[0] = BTN_TOOL_PEN;
372 wacom->id[0] = STYLUS_DEVICE_ID;
376 wacom->tool[0] = BTN_TOOL_RUBBER;
377 wacom->id[0] = ERASER_DEVICE_ID;
380 case 2: /* Mouse with wheel */
381 input_report_key(input, BTN_MIDDLE, data[1] & 0x04);
384 case 3: /* Mouse without wheel */
385 wacom->tool[0] = BTN_TOOL_MOUSE;
386 wacom->id[0] = CURSOR_DEVICE_ID;
390 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
391 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
392 if (wacom->tool[0] != BTN_TOOL_MOUSE) {
393 if (features->type == GRAPHIRE_BT)
394 input_report_abs(input, ABS_PRESSURE, data[6] |
395 (((__u16) (data[1] & 0x08)) << 5));
397 input_report_abs(input, ABS_PRESSURE, data[6] |
398 ((data[7] & 0x03) << 8));
399 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
400 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
401 input_report_key(input, BTN_STYLUS2, data[1] & 0x04);
403 input_report_key(input, BTN_LEFT, data[1] & 0x01);
404 input_report_key(input, BTN_RIGHT, data[1] & 0x02);
405 if (features->type == WACOM_G4 ||
406 features->type == WACOM_MO) {
407 input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f);
408 rw = (data[7] & 0x04) - (data[7] & 0x03);
409 } else if (features->type == GRAPHIRE_BT) {
410 /* Compute distance between mouse and tablet */
411 rw = 44 - (data[6] >> 2);
412 rw = clamp_val(rw, 0, 31);
413 input_report_abs(input, ABS_DISTANCE, rw);
414 if (((data[1] >> 5) & 3) == 2) {
415 /* Mouse with wheel */
416 input_report_key(input, BTN_MIDDLE,
418 rw = (data[6] & 0x01) ? -1 :
419 (data[6] & 0x02) ? 1 : 0;
424 input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f);
425 rw = -(signed char)data[6];
427 input_report_rel(input, REL_WHEEL, rw);
432 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
433 input_report_key(input, wacom->tool[0], prox);
434 input_sync(input); /* sync last event */
438 switch (features->type) {
440 prox = data[7] & 0xf8;
441 if (prox || wacom->id[1]) {
442 wacom->id[1] = PAD_DEVICE_ID;
443 input_report_key(pad_input, BTN_BACK, (data[7] & 0x40));
444 input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x80));
445 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
446 input_report_rel(pad_input, REL_WHEEL, rw);
449 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
455 prox = (data[7] & 0xf8) || data[8];
456 if (prox || wacom->id[1]) {
457 wacom->id[1] = PAD_DEVICE_ID;
458 input_report_key(pad_input, BTN_BACK, (data[7] & 0x08));
459 input_report_key(pad_input, BTN_LEFT, (data[7] & 0x20));
460 input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x10));
461 input_report_key(pad_input, BTN_RIGHT, (data[7] & 0x40));
462 input_report_abs(pad_input, ABS_WHEEL, (data[8] & 0x7f));
465 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
470 prox = data[7] & 0x03;
471 if (prox || wacom->id[1]) {
472 wacom->id[1] = PAD_DEVICE_ID;
473 input_report_key(pad_input, BTN_0, (data[7] & 0x02));
474 input_report_key(pad_input, BTN_1, (data[7] & 0x01));
477 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
483 /* Store current battery capacity and power supply state */
484 if (features->type == GRAPHIRE_BT) {
485 rw = (data[7] >> 2 & 0x07);
486 battery_capacity = batcap_gr[rw];
487 ps_connected = rw == 7;
488 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
489 battery_capacity, ps_connected, 1,
496 static void wacom_intuos_schedule_prox_event(struct wacom_wac *wacom_wac)
498 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
499 struct wacom_features *features = &wacom_wac->features;
500 struct hid_report *r;
501 struct hid_report_enum *re;
503 re = &(wacom->hdev->report_enum[HID_FEATURE_REPORT]);
504 if (features->type == INTUOSHT2)
505 r = re->report_id_hash[WACOM_REPORT_INTUOSHT2_ID];
507 r = re->report_id_hash[WACOM_REPORT_INTUOS_ID1];
509 hid_hw_request(wacom->hdev, r, HID_REQ_GET_REPORT);
513 static int wacom_intuos_pad(struct wacom_wac *wacom)
515 struct wacom_features *features = &wacom->features;
516 unsigned char *data = wacom->data;
517 struct input_dev *input = wacom->pad_input;
519 int buttons = 0, nbuttons = features->numbered_buttons;
520 int keys = 0, nkeys = 0;
521 int ring1 = 0, ring2 = 0;
522 int strip1 = 0, strip2 = 0;
524 bool wrench = false, keyboard = false, mute_touch = false, menu = false,
527 /* pad packets. Works as a second tool and is always in prox */
528 if (!(data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD ||
529 data[0] == WACOM_REPORT_CINTIQPAD))
532 if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
533 buttons = (data[3] << 1) | (data[2] & 0x01);
535 } else if (features->type == DTK) {
537 } else if (features->type == WACOM_13HD) {
538 buttons = (data[4] << 1) | (data[3] & 0x01);
539 } else if (features->type == WACOM_24HD) {
540 buttons = (data[8] << 8) | data[6];
545 * Three "buttons" are available on the 24HD which are
546 * physically implemented as a touchstrip. Each button
547 * is approximately 3 bits wide with a 2 bit spacing.
548 * The raw touchstrip bits are stored at:
549 * ((data[3] & 0x1f) << 8) | data[4])
552 keys = ((data[3] & 0x1C) ? 1<<2 : 0) |
553 ((data[4] & 0xE0) ? 1<<1 : 0) |
554 ((data[4] & 0x07) ? 1<<0 : 0);
555 keyboard = !!(data[4] & 0xE0);
556 info = !!(data[3] & 0x1C);
558 if (features->oPid) {
559 mute_touch = !!(data[4] & 0x07);
561 wacom->shared->is_touch_on =
562 !wacom->shared->is_touch_on;
564 wrench = !!(data[4] & 0x07);
566 } else if (features->type == WACOM_27QHD) {
568 keys = data[2] & 0x07;
570 wrench = !!(data[2] & 0x01);
571 keyboard = !!(data[2] & 0x02);
573 if (features->oPid) {
574 mute_touch = !!(data[2] & 0x04);
576 wacom->shared->is_touch_on =
577 !wacom->shared->is_touch_on;
579 menu = !!(data[2] & 0x04);
581 input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[4]));
582 input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[6]));
583 input_report_abs(input, ABS_Z, be16_to_cpup((__be16 *)&data[8]));
584 } else if (features->type == CINTIQ_HYBRID) {
586 * Do not send hardware buttons under Android. They
587 * are already sent to the system through GPIO (and
588 * have different meaning).
590 * d-pad right -> data[4] & 0x10
591 * d-pad up -> data[4] & 0x20
592 * d-pad left -> data[4] & 0x40
593 * d-pad down -> data[4] & 0x80
594 * d-pad center -> data[3] & 0x01
596 buttons = (data[4] << 1) | (data[3] & 0x01);
597 } else if (features->type == CINTIQ_COMPANION_2) {
598 /* d-pad right -> data[2] & 0x10
599 * d-pad up -> data[2] & 0x20
600 * d-pad left -> data[2] & 0x40
601 * d-pad down -> data[2] & 0x80
602 * d-pad center -> data[1] & 0x01
604 buttons = ((data[2] >> 4) << 7) |
605 ((data[1] & 0x04) << 4) |
606 ((data[2] & 0x0F) << 2) |
608 } else if (features->type >= INTUOS5S && features->type <= INTUOSPL) {
610 * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in
611 * addition to the mechanical switch. Switch data is
612 * stored in data[4], capacitive data in data[5].
614 * Touch ring mode switch (data[3]) has no capacitive sensor
616 buttons = (data[4] << 1) | (data[3] & 0x01);
619 if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) {
620 buttons = (data[8] << 10) | ((data[7] & 0x01) << 9) |
621 (data[6] << 1) | (data[5] & 0x01);
623 if (features->type == WACOM_22HD) {
625 keys = data[9] & 0x07;
627 info = !!(data[9] & 0x01);
628 wrench = !!(data[9] & 0x02);
631 buttons = ((data[6] & 0x10) << 5) |
632 ((data[5] & 0x10) << 4) |
633 ((data[6] & 0x0F) << 4) |
636 strip1 = ((data[1] & 0x1f) << 8) | data[2];
637 strip2 = ((data[3] & 0x1f) << 8) | data[4];
640 prox = (buttons & ~(~0U << nbuttons)) | (keys & ~(~0U << nkeys)) |
641 (ring1 & 0x80) | (ring2 & 0x80) | strip1 | strip2;
643 wacom_report_numbered_buttons(input, nbuttons, buttons);
645 for (i = 0; i < nkeys; i++)
646 input_report_key(input, KEY_PROG1 + i, keys & (1 << i));
648 input_report_key(input, KEY_BUTTONCONFIG, wrench);
649 input_report_key(input, KEY_ONSCREEN_KEYBOARD, keyboard);
650 input_report_key(input, KEY_CONTROLPANEL, menu);
651 input_report_key(input, KEY_INFO, info);
653 if (wacom->shared && wacom->shared->touch_input) {
654 input_report_switch(wacom->shared->touch_input,
656 !wacom->shared->is_touch_on);
657 input_sync(wacom->shared->touch_input);
660 input_report_abs(input, ABS_RX, strip1);
661 input_report_abs(input, ABS_RY, strip2);
663 input_report_abs(input, ABS_WHEEL, (ring1 & 0x80) ? (ring1 & 0x7f) : 0);
664 input_report_abs(input, ABS_THROTTLE, (ring2 & 0x80) ? (ring2 & 0x7f) : 0);
666 input_report_key(input, wacom->tool[1], prox ? 1 : 0);
667 input_report_abs(input, ABS_MISC, prox ? PAD_DEVICE_ID : 0);
669 input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff);
674 static int wacom_intuos_id_mangle(int tool_id)
676 return (tool_id & ~0xFFF) << 4 | (tool_id & 0xFFF);
679 static bool wacom_is_art_pen(int tool_id)
681 bool is_art_pen = false;
684 case 0x885: /* Intuos3 Marker Pen */
685 case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
686 case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */
693 static int wacom_intuos_get_tool_type(int tool_id)
695 int tool_type = BTN_TOOL_PEN;
697 if (wacom_is_art_pen(tool_id))
701 case 0x812: /* Inking pen */
702 case 0x801: /* Intuos3 Inking pen */
703 case 0x12802: /* Intuos4/5 Inking Pen */
705 tool_type = BTN_TOOL_PENCIL;
708 case 0x822: /* Pen */
711 case 0x823: /* Intuos3 Grip Pen */
712 case 0x813: /* Intuos3 Classic Pen */
713 case 0x802: /* Intuos4/5 13HD/24HD General Pen */
714 case 0x8e2: /* IntuosHT2 pen */
716 case 0x10842: /* MobileStudio Pro Pro Pen slim */
717 case 0x14802: /* Intuos4/5 13HD/24HD Classic Pen */
718 case 0x16802: /* Cintiq 13HD Pro Pen */
719 case 0x18802: /* DTH2242 Pen */
720 case 0x10802: /* Intuos4/5 13HD/24HD General Pen */
721 tool_type = BTN_TOOL_PEN;
724 case 0x832: /* Stroke pen */
726 tool_type = BTN_TOOL_BRUSH;
729 case 0x007: /* Mouse 4D and 2D */
732 case 0x017: /* Intuos3 2D Mouse */
733 case 0x806: /* Intuos4 Mouse */
734 tool_type = BTN_TOOL_MOUSE;
737 case 0x096: /* Lens cursor */
738 case 0x097: /* Intuos3 Lens cursor */
739 case 0x006: /* Intuos4 Lens cursor */
740 tool_type = BTN_TOOL_LENS;
743 case 0x82a: /* Eraser */
749 case 0x82b: /* Intuos3 Grip Pen Eraser */
750 case 0x81b: /* Intuos3 Classic Pen Eraser */
751 case 0x91b: /* Intuos3 Airbrush Eraser */
752 case 0x80c: /* Intuos4/5 13HD/24HD Marker Pen Eraser */
753 case 0x80a: /* Intuos4/5 13HD/24HD General Pen Eraser */
754 case 0x90a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
755 case 0x1480a: /* Intuos4/5 13HD/24HD Classic Pen Eraser */
756 case 0x1090a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
757 case 0x1080c: /* Intuos4/5 13HD/24HD Art Pen Eraser */
758 case 0x1084a: /* MobileStudio Pro Pro Pen slim Eraser */
759 case 0x1680a: /* Cintiq 13HD Pro Pen Eraser */
760 case 0x1880a: /* DTH2242 Eraser */
761 case 0x1080a: /* Intuos4/5 13HD/24HD General Pen Eraser */
762 tool_type = BTN_TOOL_RUBBER;
768 case 0x913: /* Intuos3 Airbrush */
769 case 0x902: /* Intuos4/5 13HD/24HD Airbrush */
770 case 0x10902: /* Intuos4/5 13HD/24HD Airbrush */
771 tool_type = BTN_TOOL_AIRBRUSH;
777 static void wacom_exit_report(struct wacom_wac *wacom)
779 struct input_dev *input = wacom->pen_input;
780 struct wacom_features *features = &wacom->features;
781 unsigned char *data = wacom->data;
782 int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
785 * Reset all states otherwise we lose the initial states
786 * when in-prox next time
788 input_report_abs(input, ABS_X, 0);
789 input_report_abs(input, ABS_Y, 0);
790 input_report_abs(input, ABS_DISTANCE, 0);
791 input_report_abs(input, ABS_TILT_X, 0);
792 input_report_abs(input, ABS_TILT_Y, 0);
793 if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
794 input_report_key(input, BTN_LEFT, 0);
795 input_report_key(input, BTN_MIDDLE, 0);
796 input_report_key(input, BTN_RIGHT, 0);
797 input_report_key(input, BTN_SIDE, 0);
798 input_report_key(input, BTN_EXTRA, 0);
799 input_report_abs(input, ABS_THROTTLE, 0);
800 input_report_abs(input, ABS_RZ, 0);
802 input_report_abs(input, ABS_PRESSURE, 0);
803 input_report_key(input, BTN_STYLUS, 0);
804 input_report_key(input, BTN_STYLUS2, 0);
805 input_report_key(input, BTN_TOUCH, 0);
806 input_report_abs(input, ABS_WHEEL, 0);
807 if (features->type >= INTUOS3S)
808 input_report_abs(input, ABS_Z, 0);
810 input_report_key(input, wacom->tool[idx], 0);
811 input_report_abs(input, ABS_MISC, 0); /* reset tool id */
812 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
816 static int wacom_intuos_inout(struct wacom_wac *wacom)
818 struct wacom_features *features = &wacom->features;
819 unsigned char *data = wacom->data;
820 struct input_dev *input = wacom->pen_input;
821 int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
823 if (!(((data[1] & 0xfc) == 0xc0) || /* in prox */
824 ((data[1] & 0xfe) == 0x20) || /* in range */
825 ((data[1] & 0xfe) == 0x80))) /* out prox */
829 if ((data[1] & 0xfc) == 0xc0) {
830 /* serial number of the tool */
831 wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
832 (data[4] << 20) + (data[5] << 12) +
833 (data[6] << 4) + (data[7] >> 4);
835 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) |
836 ((data[7] & 0x0f) << 16) | ((data[8] & 0xf0) << 8);
838 wacom->tool[idx] = wacom_intuos_get_tool_type(wacom->id[idx]);
840 wacom->shared->stylus_in_proximity = true;
845 if ((data[1] & 0xfe) == 0x20) {
846 if (features->type != INTUOSHT2)
847 wacom->shared->stylus_in_proximity = true;
849 /* in Range while exiting */
850 if (wacom->reporting_data) {
851 input_report_key(input, BTN_TOUCH, 0);
852 input_report_abs(input, ABS_PRESSURE, 0);
853 input_report_abs(input, ABS_DISTANCE, wacom->features.distance_max);
860 if ((data[1] & 0xfe) == 0x80) {
861 wacom->shared->stylus_in_proximity = false;
862 wacom->reporting_data = false;
864 /* don't report exit if we don't know the ID */
868 wacom_exit_report(wacom);
875 static inline bool touch_is_muted(struct wacom_wac *wacom_wac)
877 return wacom_wac->probe_complete &&
878 wacom_wac->shared->has_mute_touch_switch &&
879 !wacom_wac->shared->is_touch_on;
882 static inline bool report_touch_events(struct wacom_wac *wacom)
884 return (touch_arbitration ? !wacom->shared->stylus_in_proximity : 1);
887 static inline bool delay_pen_events(struct wacom_wac *wacom)
889 return (wacom->shared->touch_down && touch_arbitration);
892 static int wacom_intuos_general(struct wacom_wac *wacom)
894 struct wacom_features *features = &wacom->features;
895 unsigned char *data = wacom->data;
896 struct input_dev *input = wacom->pen_input;
897 int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
898 unsigned char type = (data[1] >> 1) & 0x0F;
899 unsigned int x, y, distance, t;
901 if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_CINTIQ &&
902 data[0] != WACOM_REPORT_INTUOS_PEN)
905 if (delay_pen_events(wacom))
908 /* don't report events if we don't know the tool ID */
909 if (!wacom->id[idx]) {
910 /* but reschedule a read of the current tool */
911 wacom_intuos_schedule_prox_event(wacom);
916 * don't report events for invalid data
918 /* older I4 styli don't work with new Cintiqs */
919 if ((!((wacom->id[idx] >> 16) & 0x01) &&
920 (features->type == WACOM_21UX2)) ||
921 /* Only large Intuos support Lense Cursor */
922 (wacom->tool[idx] == BTN_TOOL_LENS &&
923 (features->type == INTUOS3 ||
924 features->type == INTUOS3S ||
925 features->type == INTUOS4 ||
926 features->type == INTUOS4S ||
927 features->type == INTUOS5 ||
928 features->type == INTUOS5S ||
929 features->type == INTUOSPM ||
930 features->type == INTUOSPS)) ||
931 /* Cintiq doesn't send data when RDY bit isn't set */
932 (features->type == CINTIQ && !(data[1] & 0x40)))
935 x = (be16_to_cpup((__be16 *)&data[2]) << 1) | ((data[9] >> 1) & 1);
936 y = (be16_to_cpup((__be16 *)&data[4]) << 1) | (data[9] & 1);
937 distance = data[9] >> 2;
938 if (features->type < INTUOS3S) {
943 if (features->type == INTUOSHT2)
944 distance = features->distance_max - distance;
945 input_report_abs(input, ABS_X, x);
946 input_report_abs(input, ABS_Y, y);
947 input_report_abs(input, ABS_DISTANCE, distance);
954 /* general pen packet */
955 t = (data[6] << 3) | ((data[7] & 0xC0) >> 5) | (data[1] & 1);
956 if (features->pressure_max < 2047)
958 input_report_abs(input, ABS_PRESSURE, t);
959 if (features->type != INTUOSHT2) {
960 input_report_abs(input, ABS_TILT_X,
961 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
962 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
964 input_report_key(input, BTN_STYLUS, data[1] & 2);
965 input_report_key(input, BTN_STYLUS2, data[1] & 4);
966 input_report_key(input, BTN_TOUCH, t > 10);
970 /* airbrush second packet */
971 input_report_abs(input, ABS_WHEEL,
972 (data[6] << 2) | ((data[7] >> 6) & 3));
973 input_report_abs(input, ABS_TILT_X,
974 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
975 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
979 /* Rotation packet */
980 if (features->type >= INTUOS3S) {
981 /* I3 marker pen rotation */
982 t = (data[6] << 3) | ((data[7] >> 5) & 7);
983 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
984 ((t-1) / 2 + 450)) : (450 - t / 2) ;
985 input_report_abs(input, ABS_Z, t);
987 /* 4D mouse 2nd packet */
988 t = (data[6] << 3) | ((data[7] >> 5) & 7);
989 input_report_abs(input, ABS_RZ, (data[7] & 0x20) ?
990 ((t - 1) / 2) : -t / 2);
995 /* 4D mouse 1st packet */
996 input_report_key(input, BTN_LEFT, data[8] & 0x01);
997 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
998 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
1000 input_report_key(input, BTN_SIDE, data[8] & 0x20);
1001 input_report_key(input, BTN_EXTRA, data[8] & 0x10);
1002 t = (data[6] << 2) | ((data[7] >> 6) & 3);
1003 input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
1008 input_report_key(input, BTN_LEFT, data[6] & 0x01);
1009 input_report_key(input, BTN_MIDDLE, data[6] & 0x02);
1010 input_report_key(input, BTN_RIGHT, data[6] & 0x04);
1011 input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7)
1012 - ((data[7] & 0x40) >> 6));
1013 input_report_key(input, BTN_SIDE, data[6] & 0x08);
1014 input_report_key(input, BTN_EXTRA, data[6] & 0x10);
1016 input_report_abs(input, ABS_TILT_X,
1017 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
1018 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
1022 if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
1023 /* 2D mouse packet */
1024 input_report_key(input, BTN_LEFT, data[8] & 0x04);
1025 input_report_key(input, BTN_MIDDLE, data[8] & 0x08);
1026 input_report_key(input, BTN_RIGHT, data[8] & 0x10);
1027 input_report_rel(input, REL_WHEEL, (data[8] & 0x01)
1028 - ((data[8] & 0x02) >> 1));
1030 /* I3 2D mouse side buttons */
1031 if (features->type >= INTUOS3S && features->type <= INTUOS3L) {
1032 input_report_key(input, BTN_SIDE, data[8] & 0x40);
1033 input_report_key(input, BTN_EXTRA, data[8] & 0x20);
1036 else if (wacom->tool[idx] == BTN_TOOL_LENS) {
1037 /* Lens cursor packets */
1038 input_report_key(input, BTN_LEFT, data[8] & 0x01);
1039 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
1040 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
1041 input_report_key(input, BTN_SIDE, data[8] & 0x10);
1042 input_report_key(input, BTN_EXTRA, data[8] & 0x08);
1057 input_report_abs(input, ABS_MISC,
1058 wacom_intuos_id_mangle(wacom->id[idx])); /* report tool id */
1059 input_report_key(input, wacom->tool[idx], 1);
1060 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
1061 wacom->reporting_data = true;
1065 static int wacom_intuos_irq(struct wacom_wac *wacom)
1067 unsigned char *data = wacom->data;
1068 struct input_dev *input = wacom->pen_input;
1071 if (data[0] != WACOM_REPORT_PENABLED &&
1072 data[0] != WACOM_REPORT_INTUOS_ID1 &&
1073 data[0] != WACOM_REPORT_INTUOS_ID2 &&
1074 data[0] != WACOM_REPORT_INTUOSPAD &&
1075 data[0] != WACOM_REPORT_INTUOS_PEN &&
1076 data[0] != WACOM_REPORT_CINTIQ &&
1077 data[0] != WACOM_REPORT_CINTIQPAD &&
1078 data[0] != WACOM_REPORT_INTUOS5PAD) {
1079 dev_dbg(input->dev.parent,
1080 "%s: received unknown report #%d\n", __func__, data[0]);
1084 /* process pad events */
1085 result = wacom_intuos_pad(wacom);
1089 /* process in/out prox events */
1090 result = wacom_intuos_inout(wacom);
1094 /* process general packets */
1095 result = wacom_intuos_general(wacom);
1102 static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len)
1104 unsigned char *data = wacom_wac->data;
1105 struct input_dev *input;
1106 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
1107 struct wacom_remote *remote = wacom->remote;
1108 int bat_charging, bat_percent, touch_ring_mode;
1111 unsigned long flags;
1113 if (data[0] != WACOM_REPORT_REMOTE) {
1114 hid_dbg(wacom->hdev, "%s: received unknown report #%d",
1119 serial = data[3] + (data[4] << 8) + (data[5] << 16);
1120 wacom_wac->id[0] = PAD_DEVICE_ID;
1122 spin_lock_irqsave(&remote->remote_lock, flags);
1124 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
1125 if (remote->remotes[i].serial == serial) {
1131 if (index < 0 || !remote->remotes[index].registered)
1134 input = remote->remotes[index].input;
1136 input_report_key(input, BTN_0, (data[9] & 0x01));
1137 input_report_key(input, BTN_1, (data[9] & 0x02));
1138 input_report_key(input, BTN_2, (data[9] & 0x04));
1139 input_report_key(input, BTN_3, (data[9] & 0x08));
1140 input_report_key(input, BTN_4, (data[9] & 0x10));
1141 input_report_key(input, BTN_5, (data[9] & 0x20));
1142 input_report_key(input, BTN_6, (data[9] & 0x40));
1143 input_report_key(input, BTN_7, (data[9] & 0x80));
1145 input_report_key(input, BTN_8, (data[10] & 0x01));
1146 input_report_key(input, BTN_9, (data[10] & 0x02));
1147 input_report_key(input, BTN_A, (data[10] & 0x04));
1148 input_report_key(input, BTN_B, (data[10] & 0x08));
1149 input_report_key(input, BTN_C, (data[10] & 0x10));
1150 input_report_key(input, BTN_X, (data[10] & 0x20));
1151 input_report_key(input, BTN_Y, (data[10] & 0x40));
1152 input_report_key(input, BTN_Z, (data[10] & 0x80));
1154 input_report_key(input, BTN_BASE, (data[11] & 0x01));
1155 input_report_key(input, BTN_BASE2, (data[11] & 0x02));
1157 if (data[12] & 0x80)
1158 input_report_abs(input, ABS_WHEEL, (data[12] & 0x7f) - 1);
1160 input_report_abs(input, ABS_WHEEL, 0);
1162 bat_percent = data[7] & 0x7f;
1163 bat_charging = !!(data[7] & 0x80);
1165 if (data[9] | data[10] | (data[11] & 0x03) | data[12])
1166 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
1168 input_report_abs(input, ABS_MISC, 0);
1170 input_event(input, EV_MSC, MSC_SERIAL, serial);
1174 /*Which mode select (LED light) is currently on?*/
1175 touch_ring_mode = (data[11] & 0xC0) >> 6;
1177 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
1178 if (remote->remotes[i].serial == serial)
1179 wacom->led.groups[i].select = touch_ring_mode;
1182 __wacom_notify_battery(&remote->remotes[index].battery,
1183 WACOM_POWER_SUPPLY_STATUS_AUTO, bat_percent,
1184 bat_charging, 1, bat_charging);
1187 spin_unlock_irqrestore(&remote->remote_lock, flags);
1191 static void wacom_remote_status_irq(struct wacom_wac *wacom_wac, size_t len)
1193 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
1194 unsigned char *data = wacom_wac->data;
1195 struct wacom_remote *remote = wacom->remote;
1196 struct wacom_remote_data remote_data;
1197 unsigned long flags;
1200 if (data[0] != WACOM_REPORT_DEVICE_LIST)
1203 memset(&remote_data, 0, sizeof(struct wacom_remote_data));
1205 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
1207 int serial = (data[j+6] << 16) + (data[j+5] << 8) + data[j+4];
1208 bool connected = data[j+2];
1210 remote_data.remote[i].serial = serial;
1211 remote_data.remote[i].connected = connected;
1214 spin_lock_irqsave(&remote->remote_lock, flags);
1216 ret = kfifo_in(&remote->remote_fifo, &remote_data, sizeof(remote_data));
1217 if (ret != sizeof(remote_data)) {
1218 spin_unlock_irqrestore(&remote->remote_lock, flags);
1219 hid_err(wacom->hdev, "Can't queue Remote status event.\n");
1223 spin_unlock_irqrestore(&remote->remote_lock, flags);
1225 wacom_schedule_work(wacom_wac, WACOM_WORKER_REMOTE);
1228 static int int_dist(int x1, int y1, int x2, int y2)
1233 return int_sqrt(x*x + y*y);
1236 static void wacom_intuos_bt_process_data(struct wacom_wac *wacom,
1237 unsigned char *data)
1239 memcpy(wacom->data, data, 10);
1240 wacom_intuos_irq(wacom);
1242 input_sync(wacom->pen_input);
1243 if (wacom->pad_input)
1244 input_sync(wacom->pad_input);
1247 static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
1249 unsigned char data[WACOM_PKGLEN_MAX];
1251 unsigned power_raw, battery_capacity, bat_charging, ps_connected;
1253 memcpy(data, wacom->data, len);
1257 wacom_intuos_bt_process_data(wacom, data + i);
1261 wacom_intuos_bt_process_data(wacom, data + i);
1263 wacom_intuos_bt_process_data(wacom, data + i);
1265 power_raw = data[i];
1266 bat_charging = (power_raw & 0x08) ? 1 : 0;
1267 ps_connected = (power_raw & 0x10) ? 1 : 0;
1268 battery_capacity = batcap_i4[power_raw & 0x07];
1269 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
1270 battery_capacity, bat_charging,
1271 battery_capacity || bat_charging,
1275 dev_dbg(wacom->pen_input->dev.parent,
1276 "Unknown report: %d,%d size:%zu\n",
1277 data[0], data[1], len);
1283 static int wacom_wac_finger_count_touches(struct wacom_wac *wacom)
1285 struct input_dev *input = wacom->touch_input;
1286 unsigned touch_max = wacom->features.touch_max;
1294 return test_bit(BTN_TOUCH, input->key) &&
1295 report_touch_events(wacom);
1297 for (i = 0; i < input->mt->num_slots; i++) {
1298 struct input_mt_slot *ps = &input->mt->slots[i];
1299 int id = input_mt_get_value(ps, ABS_MT_TRACKING_ID);
1307 static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
1309 int pen_frame_len, pen_frames;
1311 struct input_dev *pen_input = wacom->pen_input;
1312 unsigned char *data = wacom->data;
1315 if (wacom->features.type == INTUOSP2_BT ||
1316 wacom->features.type == INTUOSP2S_BT) {
1317 wacom->serial[0] = get_unaligned_le64(&data[99]);
1318 wacom->id[0] = get_unaligned_le16(&data[107]);
1322 wacom->serial[0] = get_unaligned_le64(&data[33]);
1323 wacom->id[0] = get_unaligned_le16(&data[41]);
1328 if (wacom->serial[0] >> 52 == 1) {
1329 /* Add back in missing bits of ID for non-USI pens */
1330 wacom->id[0] |= (wacom->serial[0] >> 32) & 0xFFFFF;
1333 for (i = 0; i < pen_frames; i++) {
1334 unsigned char *frame = &data[i*pen_frame_len + 1];
1335 bool valid = frame[0] & 0x80;
1336 bool prox = frame[0] & 0x40;
1337 bool range = frame[0] & 0x20;
1338 bool invert = frame[0] & 0x10;
1344 wacom->shared->stylus_in_proximity = false;
1345 wacom_exit_report(wacom);
1346 input_sync(pen_input);
1350 wacom->serial[0] = 0;
1355 if (!wacom->tool[0]) { /* first in range */
1356 /* Going into range select tool */
1358 wacom->tool[0] = BTN_TOOL_RUBBER;
1359 else if (wacom->id[0])
1360 wacom->tool[0] = wacom_intuos_get_tool_type(wacom->id[0]);
1362 wacom->tool[0] = BTN_TOOL_PEN;
1365 input_report_abs(pen_input, ABS_X, get_unaligned_le16(&frame[1]));
1366 input_report_abs(pen_input, ABS_Y, get_unaligned_le16(&frame[3]));
1368 if (wacom->features.type == INTUOSP2_BT ||
1369 wacom->features.type == INTUOSP2S_BT) {
1370 /* Fix rotation alignment: userspace expects zero at left */
1372 (int16_t)get_unaligned_le16(&frame[9]);
1378 input_report_abs(pen_input, ABS_TILT_X,
1380 input_report_abs(pen_input, ABS_TILT_Y,
1382 input_report_abs(pen_input, ABS_Z, rotation);
1383 input_report_abs(pen_input, ABS_WHEEL,
1384 get_unaligned_le16(&frame[11]));
1387 if (wacom->tool[0]) {
1388 input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5]));
1389 if (wacom->features.type == INTUOSP2_BT ||
1390 wacom->features.type == INTUOSP2S_BT) {
1391 input_report_abs(pen_input, ABS_DISTANCE,
1392 range ? frame[13] : wacom->features.distance_max);
1394 input_report_abs(pen_input, ABS_DISTANCE,
1395 range ? frame[7] : wacom->features.distance_max);
1398 input_report_key(pen_input, BTN_TOUCH, frame[0] & 0x09);
1399 input_report_key(pen_input, BTN_STYLUS, frame[0] & 0x02);
1400 input_report_key(pen_input, BTN_STYLUS2, frame[0] & 0x04);
1402 input_report_key(pen_input, wacom->tool[0], prox);
1403 input_event(pen_input, EV_MSC, MSC_SERIAL, wacom->serial[0]);
1404 input_report_abs(pen_input, ABS_MISC,
1405 wacom_intuos_id_mangle(wacom->id[0])); /* report tool id */
1408 wacom->shared->stylus_in_proximity = prox;
1410 input_sync(pen_input);
1414 static void wacom_intuos_pro2_bt_touch(struct wacom_wac *wacom)
1416 const int finger_touch_len = 8;
1417 const int finger_frames = 4;
1418 const int finger_frame_len = 43;
1420 struct input_dev *touch_input = wacom->touch_input;
1421 unsigned char *data = wacom->data;
1422 int num_contacts_left = 5;
1425 for (i = 0; i < finger_frames; i++) {
1426 unsigned char *frame = &data[i*finger_frame_len + 109];
1427 int current_num_contacts = frame[0] & 0x7F;
1428 int contacts_to_send;
1430 if (!(frame[0] & 0x80))
1434 * First packet resets the counter since only the first
1435 * packet in series will have non-zero current_num_contacts.
1437 if (current_num_contacts)
1438 wacom->num_contacts_left = current_num_contacts;
1440 contacts_to_send = min(num_contacts_left, wacom->num_contacts_left);
1442 for (j = 0; j < contacts_to_send; j++) {
1443 unsigned char *touch = &frame[j*finger_touch_len + 1];
1444 int slot = input_mt_get_slot_by_key(touch_input, touch[0]);
1445 int x = get_unaligned_le16(&touch[2]);
1446 int y = get_unaligned_le16(&touch[4]);
1447 int w = touch[6] * input_abs_get_res(touch_input, ABS_MT_POSITION_X);
1448 int h = touch[7] * input_abs_get_res(touch_input, ABS_MT_POSITION_Y);
1453 input_mt_slot(touch_input, slot);
1454 input_mt_report_slot_state(touch_input, MT_TOOL_FINGER, touch[1] & 0x01);
1455 input_report_abs(touch_input, ABS_MT_POSITION_X, x);
1456 input_report_abs(touch_input, ABS_MT_POSITION_Y, y);
1457 input_report_abs(touch_input, ABS_MT_TOUCH_MAJOR, max(w, h));
1458 input_report_abs(touch_input, ABS_MT_TOUCH_MINOR, min(w, h));
1459 input_report_abs(touch_input, ABS_MT_ORIENTATION, w > h);
1462 input_mt_sync_frame(touch_input);
1464 wacom->num_contacts_left -= contacts_to_send;
1465 if (wacom->num_contacts_left <= 0) {
1466 wacom->num_contacts_left = 0;
1467 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1468 input_sync(touch_input);
1472 if (wacom->num_contacts_left == 0) {
1473 // Be careful that we don't accidentally call input_sync with
1474 // only a partial set of fingers of processed
1475 input_report_switch(touch_input, SW_MUTE_DEVICE, !(data[281] >> 7));
1476 input_sync(touch_input);
1481 static void wacom_intuos_pro2_bt_pad(struct wacom_wac *wacom)
1483 struct input_dev *pad_input = wacom->pad_input;
1484 unsigned char *data = wacom->data;
1485 int nbuttons = wacom->features.numbered_buttons;
1487 int expresskeys = data[282];
1488 int center = (data[281] & 0x40) >> 6;
1489 int ring = data[285] & 0x7F;
1490 bool ringstatus = data[285] & 0x80;
1491 bool prox = expresskeys || center || ringstatus;
1493 /* Fix touchring data: userspace expects 0 at left and increasing clockwise */
1499 wacom_report_numbered_buttons(pad_input, nbuttons,
1500 expresskeys | (center << (nbuttons - 1)));
1502 input_report_abs(pad_input, ABS_WHEEL, ringstatus ? ring : 0);
1504 input_report_key(pad_input, wacom->tool[1], prox ? 1 : 0);
1505 input_report_abs(pad_input, ABS_MISC, prox ? PAD_DEVICE_ID : 0);
1506 input_event(pad_input, EV_MSC, MSC_SERIAL, 0xffffffff);
1508 input_sync(pad_input);
1511 static void wacom_intuos_pro2_bt_battery(struct wacom_wac *wacom)
1513 unsigned char *data = wacom->data;
1515 bool chg = data[284] & 0x80;
1516 int battery_status = data[284] & 0x7F;
1518 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
1519 battery_status, chg, 1, chg);
1522 static void wacom_intuos_gen3_bt_pad(struct wacom_wac *wacom)
1524 struct input_dev *pad_input = wacom->pad_input;
1525 unsigned char *data = wacom->data;
1527 int buttons = data[44];
1529 wacom_report_numbered_buttons(pad_input, 4, buttons);
1531 input_report_key(pad_input, wacom->tool[1], buttons ? 1 : 0);
1532 input_report_abs(pad_input, ABS_MISC, buttons ? PAD_DEVICE_ID : 0);
1533 input_event(pad_input, EV_MSC, MSC_SERIAL, 0xffffffff);
1535 input_sync(pad_input);
1538 static void wacom_intuos_gen3_bt_battery(struct wacom_wac *wacom)
1540 unsigned char *data = wacom->data;
1542 bool chg = data[45] & 0x80;
1543 int battery_status = data[45] & 0x7F;
1545 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
1546 battery_status, chg, 1, chg);
1549 static int wacom_intuos_pro2_bt_irq(struct wacom_wac *wacom, size_t len)
1551 unsigned char *data = wacom->data;
1553 if (data[0] != 0x80 && data[0] != 0x81) {
1554 dev_dbg(wacom->pen_input->dev.parent,
1555 "%s: received unknown report #%d\n", __func__, data[0]);
1559 wacom_intuos_pro2_bt_pen(wacom);
1560 if (wacom->features.type == INTUOSP2_BT ||
1561 wacom->features.type == INTUOSP2S_BT) {
1562 wacom_intuos_pro2_bt_touch(wacom);
1563 wacom_intuos_pro2_bt_pad(wacom);
1564 wacom_intuos_pro2_bt_battery(wacom);
1566 wacom_intuos_gen3_bt_pad(wacom);
1567 wacom_intuos_gen3_bt_battery(wacom);
1572 static int wacom_24hdt_irq(struct wacom_wac *wacom)
1574 struct input_dev *input = wacom->touch_input;
1575 unsigned char *data = wacom->data;
1577 int current_num_contacts = data[61];
1578 int contacts_to_send = 0;
1579 int num_contacts_left = 4; /* maximum contacts per packet */
1580 int byte_per_packet = WACOM_BYTES_PER_24HDT_PACKET;
1583 if (touch_is_muted(wacom) && !wacom->shared->touch_down)
1586 if (wacom->features.type == WACOM_27QHDT) {
1587 current_num_contacts = data[63];
1588 num_contacts_left = 10;
1589 byte_per_packet = WACOM_BYTES_PER_QHDTHID_PACKET;
1594 * First packet resets the counter since only the first
1595 * packet in series will have non-zero current_num_contacts.
1597 if (current_num_contacts)
1598 wacom->num_contacts_left = current_num_contacts;
1600 contacts_to_send = min(num_contacts_left, wacom->num_contacts_left);
1602 for (i = 0; i < contacts_to_send; i++) {
1603 int offset = (byte_per_packet * i) + 1;
1604 bool touch = (data[offset] & 0x1) && report_touch_events(wacom);
1605 int slot = input_mt_get_slot_by_key(input, data[offset + 1]);
1609 input_mt_slot(input, slot);
1610 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1613 int t_x = get_unaligned_le16(&data[offset + 2]);
1614 int t_y = get_unaligned_le16(&data[offset + 4 + y_offset]);
1616 input_report_abs(input, ABS_MT_POSITION_X, t_x);
1617 input_report_abs(input, ABS_MT_POSITION_Y, t_y);
1619 if (wacom->features.type != WACOM_27QHDT) {
1620 int c_x = get_unaligned_le16(&data[offset + 4]);
1621 int c_y = get_unaligned_le16(&data[offset + 8]);
1622 int w = get_unaligned_le16(&data[offset + 10]);
1623 int h = get_unaligned_le16(&data[offset + 12]);
1625 input_report_abs(input, ABS_MT_TOUCH_MAJOR, min(w,h));
1626 input_report_abs(input, ABS_MT_WIDTH_MAJOR,
1627 min(w, h) + int_dist(t_x, t_y, c_x, c_y));
1628 input_report_abs(input, ABS_MT_WIDTH_MINOR, min(w, h));
1629 input_report_abs(input, ABS_MT_ORIENTATION, w > h);
1633 input_mt_sync_frame(input);
1635 wacom->num_contacts_left -= contacts_to_send;
1636 if (wacom->num_contacts_left <= 0) {
1637 wacom->num_contacts_left = 0;
1638 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1643 static int wacom_mt_touch(struct wacom_wac *wacom)
1645 struct input_dev *input = wacom->touch_input;
1646 unsigned char *data = wacom->data;
1648 int current_num_contacts = data[2];
1649 int contacts_to_send = 0;
1652 /* MTTPC does not support Height and Width */
1653 if (wacom->features.type == MTTPC || wacom->features.type == MTTPC_B)
1657 * First packet resets the counter since only the first
1658 * packet in series will have non-zero current_num_contacts.
1660 if (current_num_contacts)
1661 wacom->num_contacts_left = current_num_contacts;
1663 /* There are at most 5 contacts per packet */
1664 contacts_to_send = min(5, wacom->num_contacts_left);
1666 for (i = 0; i < contacts_to_send; i++) {
1667 int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset) * i + 3;
1668 bool touch = (data[offset] & 0x1) && report_touch_events(wacom);
1669 int id = get_unaligned_le16(&data[offset + 1]);
1670 int slot = input_mt_get_slot_by_key(input, id);
1675 input_mt_slot(input, slot);
1676 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1678 int x = get_unaligned_le16(&data[offset + x_offset + 7]);
1679 int y = get_unaligned_le16(&data[offset + x_offset + 9]);
1680 input_report_abs(input, ABS_MT_POSITION_X, x);
1681 input_report_abs(input, ABS_MT_POSITION_Y, y);
1684 input_mt_sync_frame(input);
1686 wacom->num_contacts_left -= contacts_to_send;
1687 if (wacom->num_contacts_left <= 0) {
1688 wacom->num_contacts_left = 0;
1689 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1694 static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
1696 struct input_dev *input = wacom->touch_input;
1697 unsigned char *data = wacom->data;
1700 for (i = 0; i < 2; i++) {
1701 int p = data[1] & (1 << i);
1702 bool touch = p && report_touch_events(wacom);
1704 input_mt_slot(input, i);
1705 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1707 int x = le16_to_cpup((__le16 *)&data[i * 2 + 2]) & 0x7fff;
1708 int y = le16_to_cpup((__le16 *)&data[i * 2 + 6]) & 0x7fff;
1710 input_report_abs(input, ABS_MT_POSITION_X, x);
1711 input_report_abs(input, ABS_MT_POSITION_Y, y);
1714 input_mt_sync_frame(input);
1716 /* keep touch state for pen event */
1717 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1722 static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
1724 unsigned char *data = wacom->data;
1725 struct input_dev *input = wacom->touch_input;
1726 bool prox = report_touch_events(wacom);
1729 if (wacom->features.touch_max > 1 || len > WACOM_PKGLEN_TPC2FG)
1732 if (len == WACOM_PKGLEN_TPC1FG) {
1733 prox = prox && (data[0] & 0x01);
1734 x = get_unaligned_le16(&data[1]);
1735 y = get_unaligned_le16(&data[3]);
1736 } else if (len == WACOM_PKGLEN_TPC1FG_B) {
1737 prox = prox && (data[2] & 0x01);
1738 x = get_unaligned_le16(&data[3]);
1739 y = get_unaligned_le16(&data[5]);
1741 prox = prox && (data[1] & 0x01);
1742 x = le16_to_cpup((__le16 *)&data[2]);
1743 y = le16_to_cpup((__le16 *)&data[4]);
1747 input_report_abs(input, ABS_X, x);
1748 input_report_abs(input, ABS_Y, y);
1750 input_report_key(input, BTN_TOUCH, prox);
1752 /* keep touch state for pen events */
1753 wacom->shared->touch_down = prox;
1758 static int wacom_tpc_pen(struct wacom_wac *wacom)
1760 unsigned char *data = wacom->data;
1761 struct input_dev *input = wacom->pen_input;
1762 bool prox = data[1] & 0x20;
1764 if (!wacom->shared->stylus_in_proximity) /* first in prox */
1765 /* Going into proximity select tool */
1766 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
1768 /* keep pen state for touch events */
1769 wacom->shared->stylus_in_proximity = prox;
1771 /* send pen events only when touch is up or forced out
1772 * or touch arbitration is off
1774 if (!delay_pen_events(wacom)) {
1775 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
1776 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
1777 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
1778 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
1779 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x07) << 8) | data[6]);
1780 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
1781 input_report_key(input, wacom->tool[0], prox);
1788 static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
1790 unsigned char *data = wacom->data;
1792 if (wacom->pen_input) {
1793 dev_dbg(wacom->pen_input->dev.parent,
1794 "%s: received report #%d\n", __func__, data[0]);
1796 if (len == WACOM_PKGLEN_PENABLED ||
1797 data[0] == WACOM_REPORT_PENABLED)
1798 return wacom_tpc_pen(wacom);
1800 else if (wacom->touch_input) {
1801 dev_dbg(wacom->touch_input->dev.parent,
1802 "%s: received report #%d\n", __func__, data[0]);
1805 case WACOM_PKGLEN_TPC1FG:
1806 return wacom_tpc_single_touch(wacom, len);
1808 case WACOM_PKGLEN_TPC2FG:
1809 return wacom_tpc_mt_touch(wacom);
1813 case WACOM_REPORT_TPC1FG:
1814 case WACOM_REPORT_TPCHID:
1815 case WACOM_REPORT_TPCST:
1816 case WACOM_REPORT_TPC1FGE:
1817 return wacom_tpc_single_touch(wacom, len);
1819 case WACOM_REPORT_TPCMT:
1820 case WACOM_REPORT_TPCMT2:
1821 return wacom_mt_touch(wacom);
1830 static int wacom_offset_rotation(struct input_dev *input, struct hid_usage *usage,
1831 int value, int num, int denom)
1833 struct input_absinfo *abs = &input->absinfo[usage->code];
1834 int range = (abs->maximum - abs->minimum + 1);
1836 value += num*range/denom;
1837 if (value > abs->maximum)
1839 else if (value < abs->minimum)
1844 int wacom_equivalent_usage(int usage)
1846 if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMDIGITIZER) {
1847 int subpage = (usage & 0xFF00) << 8;
1848 int subusage = (usage & 0xFF);
1850 if (subpage == WACOM_HID_SP_PAD ||
1851 subpage == WACOM_HID_SP_BUTTON ||
1852 subpage == WACOM_HID_SP_DIGITIZER ||
1853 subpage == WACOM_HID_SP_DIGITIZERINFO ||
1854 usage == WACOM_HID_WD_SENSE ||
1855 usage == WACOM_HID_WD_SERIALHI ||
1856 usage == WACOM_HID_WD_TOOLTYPE ||
1857 usage == WACOM_HID_WD_DISTANCE ||
1858 usage == WACOM_HID_WD_TOUCHSTRIP ||
1859 usage == WACOM_HID_WD_TOUCHSTRIP2 ||
1860 usage == WACOM_HID_WD_TOUCHRING ||
1861 usage == WACOM_HID_WD_TOUCHRINGSTATUS ||
1862 usage == WACOM_HID_WD_REPORT_VALID ||
1863 usage == WACOM_HID_WD_BARRELSWITCH3 ||
1864 usage == WACOM_HID_WD_SEQUENCENUMBER) {
1868 if (subpage == HID_UP_UNDEFINED)
1869 subpage = HID_UP_DIGITIZER;
1871 return subpage | subusage;
1874 if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMTOUCH) {
1875 int subpage = (usage & 0xFF00) << 8;
1876 int subusage = (usage & 0xFF);
1878 if (usage == WACOM_HID_WT_REPORT_VALID)
1881 if (subpage == HID_UP_UNDEFINED)
1882 subpage = WACOM_HID_SP_DIGITIZER;
1884 return subpage | subusage;
1890 static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
1891 struct hid_field *field, __u8 type, __u16 code, int fuzz)
1893 struct wacom *wacom = input_get_drvdata(input);
1894 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1895 struct wacom_features *features = &wacom_wac->features;
1896 int fmin = field->logical_minimum;
1897 int fmax = field->logical_maximum;
1898 unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid);
1899 int resolution_code = code;
1901 if (equivalent_usage == HID_DG_TWIST) {
1902 resolution_code = ABS_RZ;
1905 if (equivalent_usage == HID_GD_X) {
1906 fmin += features->offset_left;
1907 fmax -= features->offset_right;
1909 if (equivalent_usage == HID_GD_Y) {
1910 fmin += features->offset_top;
1911 fmax -= features->offset_bottom;
1919 input_set_abs_params(input, code, fmin, fmax, fuzz, 0);
1920 input_abs_set_res(input, code,
1921 hidinput_calc_abs_res(field, resolution_code));
1926 input_set_capability(input, type, code);
1931 static void wacom_wac_battery_usage_mapping(struct hid_device *hdev,
1932 struct hid_field *field, struct hid_usage *usage)
1934 struct wacom *wacom = hid_get_drvdata(hdev);
1935 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1936 struct wacom_features *features = &wacom_wac->features;
1937 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
1939 switch (equivalent_usage) {
1940 case HID_DG_BATTERYSTRENGTH:
1941 case WACOM_HID_WD_BATTERY_LEVEL:
1942 case WACOM_HID_WD_BATTERY_CHARGING:
1943 features->quirks |= WACOM_QUIRK_BATTERY;
1948 static void wacom_wac_battery_event(struct hid_device *hdev, struct hid_field *field,
1949 struct hid_usage *usage, __s32 value)
1951 struct wacom *wacom = hid_get_drvdata(hdev);
1952 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1953 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
1955 switch (equivalent_usage) {
1956 case HID_DG_BATTERYSTRENGTH:
1958 wacom_wac->hid_data.bat_status = POWER_SUPPLY_STATUS_UNKNOWN;
1961 value = value * 100 / (field->logical_maximum - field->logical_minimum);
1962 wacom_wac->hid_data.battery_capacity = value;
1963 wacom_wac->hid_data.bat_connected = 1;
1964 wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
1967 case WACOM_HID_WD_BATTERY_LEVEL:
1968 value = value * 100 / (field->logical_maximum - field->logical_minimum);
1969 wacom_wac->hid_data.battery_capacity = value;
1970 wacom_wac->hid_data.bat_connected = 1;
1971 wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
1973 case WACOM_HID_WD_BATTERY_CHARGING:
1974 wacom_wac->hid_data.bat_charging = value;
1975 wacom_wac->hid_data.ps_connected = value;
1976 wacom_wac->hid_data.bat_connected = 1;
1977 wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
1982 static void wacom_wac_battery_pre_report(struct hid_device *hdev,
1983 struct hid_report *report)
1988 static void wacom_wac_battery_report(struct hid_device *hdev,
1989 struct hid_report *report)
1991 struct wacom *wacom = hid_get_drvdata(hdev);
1992 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1993 struct wacom_features *features = &wacom_wac->features;
1995 if (features->quirks & WACOM_QUIRK_BATTERY) {
1996 int status = wacom_wac->hid_data.bat_status;
1997 int capacity = wacom_wac->hid_data.battery_capacity;
1998 bool charging = wacom_wac->hid_data.bat_charging;
1999 bool connected = wacom_wac->hid_data.bat_connected;
2000 bool powered = wacom_wac->hid_data.ps_connected;
2002 wacom_notify_battery(wacom_wac, status, capacity, charging,
2003 connected, powered);
2007 static void wacom_wac_pad_usage_mapping(struct hid_device *hdev,
2008 struct hid_field *field, struct hid_usage *usage)
2010 struct wacom *wacom = hid_get_drvdata(hdev);
2011 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2012 struct wacom_features *features = &wacom_wac->features;
2013 struct input_dev *input = wacom_wac->pad_input;
2014 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2016 switch (equivalent_usage) {
2017 case WACOM_HID_WD_ACCELEROMETER_X:
2018 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
2019 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 0);
2020 features->device_type |= WACOM_DEVICETYPE_PAD;
2022 case WACOM_HID_WD_ACCELEROMETER_Y:
2023 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
2024 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 0);
2025 features->device_type |= WACOM_DEVICETYPE_PAD;
2027 case WACOM_HID_WD_ACCELEROMETER_Z:
2028 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
2029 wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0);
2030 features->device_type |= WACOM_DEVICETYPE_PAD;
2032 case WACOM_HID_WD_BUTTONCENTER:
2033 case WACOM_HID_WD_BUTTONHOME:
2034 case WACOM_HID_WD_BUTTONUP:
2035 case WACOM_HID_WD_BUTTONDOWN:
2036 case WACOM_HID_WD_BUTTONLEFT:
2037 case WACOM_HID_WD_BUTTONRIGHT:
2038 wacom_map_usage(input, usage, field, EV_KEY,
2039 wacom_numbered_button_to_key(features->numbered_buttons),
2041 features->numbered_buttons++;
2042 features->device_type |= WACOM_DEVICETYPE_PAD;
2044 case WACOM_HID_WD_MUTE_DEVICE:
2045 /* softkey touch switch */
2046 wacom_wac->is_soft_touch_switch = true;
2048 case WACOM_HID_WD_TOUCHONOFF:
2050 * These two usages, which are used to mute touch events, come
2051 * from the pad packet, but are reported on the touch
2052 * interface. Because the touch interface may not have
2053 * been created yet, we cannot call wacom_map_usage(). In
2054 * order to process the usages when we receive them, we set
2055 * the usage type and code directly.
2057 wacom_wac->has_mute_touch_switch = true;
2058 usage->type = EV_SW;
2059 usage->code = SW_MUTE_DEVICE;
2061 case WACOM_HID_WD_TOUCHSTRIP:
2062 wacom_map_usage(input, usage, field, EV_ABS, ABS_RX, 0);
2063 features->device_type |= WACOM_DEVICETYPE_PAD;
2065 case WACOM_HID_WD_TOUCHSTRIP2:
2066 wacom_map_usage(input, usage, field, EV_ABS, ABS_RY, 0);
2067 features->device_type |= WACOM_DEVICETYPE_PAD;
2069 case WACOM_HID_WD_TOUCHRING:
2070 wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
2071 features->device_type |= WACOM_DEVICETYPE_PAD;
2073 case WACOM_HID_WD_TOUCHRINGSTATUS:
2075 * Only set up type/code association. Completely mapping
2076 * this usage may overwrite the axis resolution and range.
2078 usage->type = EV_ABS;
2079 usage->code = ABS_WHEEL;
2080 set_bit(EV_ABS, input->evbit);
2081 features->device_type |= WACOM_DEVICETYPE_PAD;
2083 case WACOM_HID_WD_BUTTONCONFIG:
2084 wacom_map_usage(input, usage, field, EV_KEY, KEY_BUTTONCONFIG, 0);
2085 features->device_type |= WACOM_DEVICETYPE_PAD;
2087 case WACOM_HID_WD_ONSCREEN_KEYBOARD:
2088 wacom_map_usage(input, usage, field, EV_KEY, KEY_ONSCREEN_KEYBOARD, 0);
2089 features->device_type |= WACOM_DEVICETYPE_PAD;
2091 case WACOM_HID_WD_CONTROLPANEL:
2092 wacom_map_usage(input, usage, field, EV_KEY, KEY_CONTROLPANEL, 0);
2093 features->device_type |= WACOM_DEVICETYPE_PAD;
2095 case WACOM_HID_WD_MODE_CHANGE:
2096 /* do not overwrite previous data */
2097 if (!wacom_wac->has_mode_change) {
2098 wacom_wac->has_mode_change = true;
2099 wacom_wac->is_direct_mode = true;
2101 features->device_type |= WACOM_DEVICETYPE_PAD;
2105 switch (equivalent_usage & 0xfffffff0) {
2106 case WACOM_HID_WD_EXPRESSKEY00:
2107 wacom_map_usage(input, usage, field, EV_KEY,
2108 wacom_numbered_button_to_key(features->numbered_buttons),
2110 features->numbered_buttons++;
2111 features->device_type |= WACOM_DEVICETYPE_PAD;
2116 static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field,
2117 struct hid_usage *usage, __s32 value)
2119 struct wacom *wacom = hid_get_drvdata(hdev);
2120 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2121 struct input_dev *input = wacom_wac->pad_input;
2122 struct wacom_features *features = &wacom_wac->features;
2123 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2125 bool do_report = false;
2128 * Avoid reporting this event and setting inrange_state if this usage
2129 * hasn't been mapped.
2131 if (!usage->type && equivalent_usage != WACOM_HID_WD_MODE_CHANGE)
2134 if (wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY) {
2135 if (usage->hid != WACOM_HID_WD_TOUCHRING)
2136 wacom_wac->hid_data.inrange_state |= value;
2139 /* Process touch switch state first since it is reported through touch interface,
2140 * which is indepentent of pad interface. In the case when there are no other pad
2141 * events, the pad interface will not even be created.
2143 if ((equivalent_usage == WACOM_HID_WD_MUTE_DEVICE) ||
2144 (equivalent_usage == WACOM_HID_WD_TOUCHONOFF)) {
2145 if (wacom_wac->shared->touch_input) {
2146 bool *is_touch_on = &wacom_wac->shared->is_touch_on;
2148 if (equivalent_usage == WACOM_HID_WD_MUTE_DEVICE && value)
2149 *is_touch_on = !(*is_touch_on);
2150 else if (equivalent_usage == WACOM_HID_WD_TOUCHONOFF)
2151 *is_touch_on = value;
2153 input_report_switch(wacom_wac->shared->touch_input,
2154 SW_MUTE_DEVICE, !(*is_touch_on));
2155 input_sync(wacom_wac->shared->touch_input);
2163 switch (equivalent_usage) {
2164 case WACOM_HID_WD_TOUCHRING:
2166 * Userspace expects touchrings to increase in value with
2167 * clockwise gestures and have their zero point at the
2168 * tablet's left. HID events "should" be clockwise-
2169 * increasing and zero at top, though the MobileStudio
2170 * Pro and 2nd-gen Intuos Pro don't do this...
2172 if (hdev->vendor == 0x56a &&
2173 (hdev->product == 0x34d || hdev->product == 0x34e || /* MobileStudio Pro */
2174 hdev->product == 0x357 || hdev->product == 0x358 || /* Intuos Pro 2 */
2175 hdev->product == 0x392 || /* Intuos Pro 2 */
2176 hdev->product == 0x398 || hdev->product == 0x399 || /* MobileStudio Pro */
2177 hdev->product == 0x3AA)) { /* MobileStudio Pro */
2178 value = (field->logical_maximum - value);
2180 if (hdev->product == 0x357 || hdev->product == 0x358 ||
2181 hdev->product == 0x392)
2182 value = wacom_offset_rotation(input, usage, value, 3, 16);
2183 else if (hdev->product == 0x34d || hdev->product == 0x34e ||
2184 hdev->product == 0x398 || hdev->product == 0x399 ||
2185 hdev->product == 0x3AA)
2186 value = wacom_offset_rotation(input, usage, value, 1, 2);
2189 value = wacom_offset_rotation(input, usage, value, 1, 4);
2193 case WACOM_HID_WD_TOUCHRINGSTATUS:
2195 input_event(input, usage->type, usage->code, 0);
2198 case WACOM_HID_WD_MODE_CHANGE:
2199 if (wacom_wac->is_direct_mode != value) {
2200 wacom_wac->is_direct_mode = value;
2201 wacom_schedule_work(&wacom->wacom_wac, WACOM_WORKER_MODE_CHANGE);
2205 case WACOM_HID_WD_BUTTONCENTER:
2206 for (i = 0; i < wacom->led.count; i++)
2207 wacom_update_led(wacom, features->numbered_buttons,
2216 input_event(input, usage->type, usage->code, value);
2218 wacom_wac->hid_data.pad_input_event_flag = true;
2222 static void wacom_wac_pad_pre_report(struct hid_device *hdev,
2223 struct hid_report *report)
2225 struct wacom *wacom = hid_get_drvdata(hdev);
2226 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2228 wacom_wac->hid_data.inrange_state = 0;
2231 static void wacom_wac_pad_report(struct hid_device *hdev,
2232 struct hid_report *report, struct hid_field *field)
2234 struct wacom *wacom = hid_get_drvdata(hdev);
2235 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2236 struct input_dev *input = wacom_wac->pad_input;
2237 bool active = wacom_wac->hid_data.inrange_state != 0;
2239 /* report prox for expresskey events */
2240 if (wacom_wac->hid_data.pad_input_event_flag) {
2241 input_event(input, EV_ABS, ABS_MISC, active ? PAD_DEVICE_ID : 0);
2244 wacom_wac->hid_data.pad_input_event_flag = false;
2248 static void wacom_set_barrel_switch3_usage(struct wacom_wac *wacom_wac)
2250 struct input_dev *input = wacom_wac->pen_input;
2251 struct wacom_features *features = &wacom_wac->features;
2253 if (!(features->quirks & WACOM_QUIRK_AESPEN) &&
2254 wacom_wac->hid_data.barrelswitch &&
2255 wacom_wac->hid_data.barrelswitch2 &&
2256 wacom_wac->hid_data.serialhi &&
2257 !wacom_wac->hid_data.barrelswitch3) {
2258 input_set_capability(input, EV_KEY, BTN_STYLUS3);
2259 features->quirks |= WACOM_QUIRK_PEN_BUTTON3;
2263 static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
2264 struct hid_field *field, struct hid_usage *usage)
2266 struct wacom *wacom = hid_get_drvdata(hdev);
2267 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2268 struct wacom_features *features = &wacom_wac->features;
2269 struct input_dev *input = wacom_wac->pen_input;
2270 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2272 switch (equivalent_usage) {
2274 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
2277 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
2279 case WACOM_HID_WD_DISTANCE:
2281 wacom_map_usage(input, usage, field, EV_ABS, ABS_DISTANCE, 0);
2283 case HID_DG_TIPPRESSURE:
2284 wacom_map_usage(input, usage, field, EV_ABS, ABS_PRESSURE, 0);
2286 case HID_DG_INRANGE:
2287 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
2290 wacom_map_usage(input, usage, field, EV_KEY,
2291 BTN_TOOL_RUBBER, 0);
2294 wacom_map_usage(input, usage, field, EV_ABS, ABS_TILT_X, 0);
2297 wacom_map_usage(input, usage, field, EV_ABS, ABS_TILT_Y, 0);
2300 wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0);
2303 input_set_capability(input, EV_KEY, BTN_TOOL_RUBBER);
2304 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
2306 case HID_DG_TIPSWITCH:
2307 input_set_capability(input, EV_KEY, BTN_TOOL_PEN);
2308 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
2310 case HID_DG_BARRELSWITCH:
2311 wacom_wac->hid_data.barrelswitch = true;
2312 wacom_set_barrel_switch3_usage(wacom_wac);
2313 wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS, 0);
2315 case HID_DG_BARRELSWITCH2:
2316 wacom_wac->hid_data.barrelswitch2 = true;
2317 wacom_set_barrel_switch3_usage(wacom_wac);
2318 wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS2, 0);
2320 case HID_DG_TOOLSERIALNUMBER:
2321 features->quirks |= WACOM_QUIRK_TOOLSERIAL;
2322 wacom_map_usage(input, usage, field, EV_MSC, MSC_SERIAL, 0);
2324 case HID_DG_SCANTIME:
2325 wacom_map_usage(input, usage, field, EV_MSC, MSC_TIMESTAMP, 0);
2327 case WACOM_HID_WD_SENSE:
2328 features->quirks |= WACOM_QUIRK_SENSE;
2329 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
2331 case WACOM_HID_WD_SERIALHI:
2332 wacom_wac->hid_data.serialhi = true;
2333 wacom_set_barrel_switch3_usage(wacom_wac);
2334 wacom_map_usage(input, usage, field, EV_ABS, ABS_MISC, 0);
2336 case WACOM_HID_WD_FINGERWHEEL:
2337 input_set_capability(input, EV_KEY, BTN_TOOL_AIRBRUSH);
2338 wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
2340 case WACOM_HID_WD_BARRELSWITCH3:
2341 wacom_wac->hid_data.barrelswitch3 = true;
2342 wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS3, 0);
2343 features->quirks &= ~WACOM_QUIRK_PEN_BUTTON3;
2348 static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field,
2349 struct hid_usage *usage, __s32 value)
2351 struct wacom *wacom = hid_get_drvdata(hdev);
2352 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2353 struct wacom_features *features = &wacom_wac->features;
2354 struct input_dev *input = wacom_wac->pen_input;
2355 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2357 if (wacom_wac->is_invalid_bt_frame)
2360 switch (equivalent_usage) {
2363 * HID_GD_Z "should increase as the control's position is
2364 * moved from high to low", while ABS_DISTANCE instead
2365 * increases in value as the tool moves from low to high.
2367 value = field->logical_maximum - value;
2369 case HID_DG_INRANGE:
2370 mod_timer(&wacom->idleprox_timer, jiffies + msecs_to_jiffies(100));
2371 wacom_wac->hid_data.inrange_state = value;
2372 if (!(features->quirks & WACOM_QUIRK_SENSE))
2373 wacom_wac->hid_data.sense_state = value;
2376 wacom_wac->hid_data.invert_state = value;
2379 case HID_DG_TIPSWITCH:
2380 wacom_wac->hid_data.tipswitch |= value;
2382 case HID_DG_BARRELSWITCH:
2383 wacom_wac->hid_data.barrelswitch = value;
2385 case HID_DG_BARRELSWITCH2:
2386 wacom_wac->hid_data.barrelswitch2 = value;
2388 case HID_DG_TOOLSERIALNUMBER:
2390 wacom_wac->serial[0] = (wacom_wac->serial[0] & ~0xFFFFFFFFULL);
2391 wacom_wac->serial[0] |= wacom_s32tou(value, field->report_size);
2395 /* don't modify the value if the pen doesn't support the feature */
2396 if (!wacom_is_art_pen(wacom_wac->id[0])) return;
2399 * Userspace expects pen twist to have its zero point when
2400 * the buttons/finger is on the tablet's left. HID values
2401 * are zero when buttons are toward the top.
2403 value = wacom_offset_rotation(input, usage, value, 1, 4);
2405 case WACOM_HID_WD_SENSE:
2406 wacom_wac->hid_data.sense_state = value;
2408 case WACOM_HID_WD_SERIALHI:
2410 __u32 raw_value = wacom_s32tou(value, field->report_size);
2412 wacom_wac->serial[0] = (wacom_wac->serial[0] & 0xFFFFFFFF);
2413 wacom_wac->serial[0] |= ((__u64)raw_value) << 32;
2415 * Non-USI EMR devices may contain additional tool type
2416 * information here. See WACOM_HID_WD_TOOLTYPE case for
2419 if (value >> 20 == 1) {
2420 wacom_wac->id[0] |= raw_value & 0xFFFFF;
2424 case WACOM_HID_WD_TOOLTYPE:
2426 * Some devices (MobileStudio Pro, and possibly later
2427 * devices as well) do not return the complete tool
2428 * type in their WACOM_HID_WD_TOOLTYPE usage. Use a
2429 * bitwise OR so the complete value can be built
2432 wacom_wac->id[0] |= wacom_s32tou(value, field->report_size);
2434 case WACOM_HID_WD_OFFSETLEFT:
2435 if (features->offset_left && value != features->offset_left)
2436 hid_warn(hdev, "%s: overriding existing left offset "
2437 "%d -> %d\n", __func__, value,
2438 features->offset_left);
2439 features->offset_left = value;
2441 case WACOM_HID_WD_OFFSETRIGHT:
2442 if (features->offset_right && value != features->offset_right)
2443 hid_warn(hdev, "%s: overriding existing right offset "
2444 "%d -> %d\n", __func__, value,
2445 features->offset_right);
2446 features->offset_right = value;
2448 case WACOM_HID_WD_OFFSETTOP:
2449 if (features->offset_top && value != features->offset_top)
2450 hid_warn(hdev, "%s: overriding existing top offset "
2451 "%d -> %d\n", __func__, value,
2452 features->offset_top);
2453 features->offset_top = value;
2455 case WACOM_HID_WD_OFFSETBOTTOM:
2456 if (features->offset_bottom && value != features->offset_bottom)
2457 hid_warn(hdev, "%s: overriding existing bottom offset "
2458 "%d -> %d\n", __func__, value,
2459 features->offset_bottom);
2460 features->offset_bottom = value;
2462 case WACOM_HID_WD_REPORT_VALID:
2463 wacom_wac->is_invalid_bt_frame = !value;
2465 case WACOM_HID_WD_BARRELSWITCH3:
2466 wacom_wac->hid_data.barrelswitch3 = value;
2468 case WACOM_HID_WD_SEQUENCENUMBER:
2469 if (wacom_wac->hid_data.sequence_number != value)
2470 hid_warn(hdev, "Dropped %hu packets", (unsigned short)(value - wacom_wac->hid_data.sequence_number));
2471 wacom_wac->hid_data.sequence_number = value + 1;
2475 /* send pen events only when touch is up or forced out
2476 * or touch arbitration is off
2478 if (!usage->type || delay_pen_events(wacom_wac))
2481 /* send pen events only when the pen is in range */
2482 if (wacom_wac->hid_data.inrange_state)
2483 input_event(input, usage->type, usage->code, value);
2484 else if (wacom_wac->shared->stylus_in_proximity && !wacom_wac->hid_data.sense_state)
2485 input_event(input, usage->type, usage->code, 0);
2488 static void wacom_wac_pen_pre_report(struct hid_device *hdev,
2489 struct hid_report *report)
2491 struct wacom *wacom = hid_get_drvdata(hdev);
2492 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2494 wacom_wac->is_invalid_bt_frame = false;
2498 static void wacom_wac_pen_report(struct hid_device *hdev,
2499 struct hid_report *report)
2501 struct wacom *wacom = hid_get_drvdata(hdev);
2502 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2503 struct input_dev *input = wacom_wac->pen_input;
2504 bool range = wacom_wac->hid_data.inrange_state;
2505 bool sense = wacom_wac->hid_data.sense_state;
2507 if (wacom_wac->is_invalid_bt_frame)
2510 if (!wacom_wac->tool[0] && range) { /* first in range */
2511 /* Going into range select tool */
2512 if (wacom_wac->hid_data.invert_state)
2513 wacom_wac->tool[0] = BTN_TOOL_RUBBER;
2514 else if (wacom_wac->id[0])
2515 wacom_wac->tool[0] = wacom_intuos_get_tool_type(wacom_wac->id[0]);
2517 wacom_wac->tool[0] = BTN_TOOL_PEN;
2520 /* keep pen state for touch events */
2521 wacom_wac->shared->stylus_in_proximity = sense;
2523 if (!delay_pen_events(wacom_wac) && wacom_wac->tool[0]) {
2524 int id = wacom_wac->id[0];
2525 if (wacom_wac->features.quirks & WACOM_QUIRK_PEN_BUTTON3 &&
2526 wacom_wac->hid_data.barrelswitch & wacom_wac->hid_data.barrelswitch2) {
2527 wacom_wac->hid_data.barrelswitch = 0;
2528 wacom_wac->hid_data.barrelswitch2 = 0;
2529 wacom_wac->hid_data.barrelswitch3 = 1;
2531 input_report_key(input, BTN_STYLUS, wacom_wac->hid_data.barrelswitch);
2532 input_report_key(input, BTN_STYLUS2, wacom_wac->hid_data.barrelswitch2);
2533 input_report_key(input, BTN_STYLUS3, wacom_wac->hid_data.barrelswitch3);
2536 * Non-USI EMR tools should have their IDs mangled to
2537 * match the legacy behavior of wacom_intuos_general
2539 if (wacom_wac->serial[0] >> 52 == 1)
2540 id = wacom_intuos_id_mangle(id);
2543 * To ensure compatibility with xf86-input-wacom, we should
2544 * report the BTN_TOOL_* event prior to the ABS_MISC or
2545 * MSC_SERIAL events.
2547 input_report_key(input, BTN_TOUCH,
2548 wacom_wac->hid_data.tipswitch);
2549 input_report_key(input, wacom_wac->tool[0], sense);
2550 if (wacom_wac->serial[0]) {
2551 input_event(input, EV_MSC, MSC_SERIAL, wacom_wac->serial[0]);
2552 input_report_abs(input, ABS_MISC, sense ? id : 0);
2555 wacom_wac->hid_data.tipswitch = false;
2561 wacom_wac->tool[0] = 0;
2562 wacom_wac->id[0] = 0;
2563 wacom_wac->serial[0] = 0;
2567 static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
2568 struct hid_field *field, struct hid_usage *usage)
2570 struct wacom *wacom = hid_get_drvdata(hdev);
2571 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2572 struct input_dev *input = wacom_wac->touch_input;
2573 unsigned touch_max = wacom_wac->features.touch_max;
2574 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2576 switch (equivalent_usage) {
2579 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
2581 wacom_map_usage(input, usage, field, EV_ABS,
2582 ABS_MT_POSITION_X, 4);
2586 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
2588 wacom_map_usage(input, usage, field, EV_ABS,
2589 ABS_MT_POSITION_Y, 4);
2593 wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MAJOR, 0);
2594 wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MINOR, 0);
2595 input_set_abs_params(input, ABS_MT_ORIENTATION, 0, 1, 0, 0);
2597 case HID_DG_TIPSWITCH:
2598 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
2600 case HID_DG_CONTACTCOUNT:
2601 wacom_wac->hid_data.cc_report = field->report->id;
2602 wacom_wac->hid_data.cc_index = field->index;
2603 wacom_wac->hid_data.cc_value_index = usage->usage_index;
2605 case HID_DG_CONTACTID:
2606 if ((field->logical_maximum - field->logical_minimum) < touch_max) {
2608 * The HID descriptor for G11 sensors leaves logical
2609 * maximum set to '1' despite it being a multitouch
2610 * device. Override to a sensible number.
2612 field->logical_maximum = 255;
2615 case HID_DG_SCANTIME:
2616 wacom_map_usage(input, usage, field, EV_MSC, MSC_TIMESTAMP, 0);
2621 static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
2622 struct input_dev *input)
2624 struct hid_data *hid_data = &wacom_wac->hid_data;
2625 bool mt = wacom_wac->features.touch_max > 1;
2626 bool prox = hid_data->tipswitch &&
2627 report_touch_events(wacom_wac);
2629 if (touch_is_muted(wacom_wac)) {
2630 if (!wacom_wac->shared->touch_down)
2635 wacom_wac->hid_data.num_received++;
2636 if (wacom_wac->hid_data.num_received > wacom_wac->hid_data.num_expected)
2642 slot = input_mt_get_slot_by_key(input, hid_data->id);
2646 struct input_mt_slot *ps = &input->mt->slots[slot];
2647 int mt_id = input_mt_get_value(ps, ABS_MT_TRACKING_ID);
2649 if (!prox && mt_id < 0) {
2650 // No data to send for this slot; short-circuit
2655 input_mt_slot(input, slot);
2656 input_mt_report_slot_state(input, MT_TOOL_FINGER, prox);
2659 input_report_key(input, BTN_TOUCH, prox);
2663 input_report_abs(input, mt ? ABS_MT_POSITION_X : ABS_X,
2665 input_report_abs(input, mt ? ABS_MT_POSITION_Y : ABS_Y,
2668 if (test_bit(ABS_MT_TOUCH_MAJOR, input->absbit)) {
2669 input_report_abs(input, ABS_MT_TOUCH_MAJOR, max(hid_data->width, hid_data->height));
2670 input_report_abs(input, ABS_MT_TOUCH_MINOR, min(hid_data->width, hid_data->height));
2671 if (hid_data->width != hid_data->height)
2672 input_report_abs(input, ABS_MT_ORIENTATION, hid_data->width <= hid_data->height ? 0 : 1);
2677 static bool wacom_wac_slot_is_active(struct input_dev *dev, int key)
2679 struct input_mt *mt = dev->mt;
2680 struct input_mt_slot *s;
2685 for (s = mt->slots; s != mt->slots + mt->num_slots; s++) {
2686 if (s->key == key &&
2687 input_mt_get_value(s, ABS_MT_TRACKING_ID) >= 0) {
2695 static void wacom_wac_finger_event(struct hid_device *hdev,
2696 struct hid_field *field, struct hid_usage *usage, __s32 value)
2698 struct wacom *wacom = hid_get_drvdata(hdev);
2699 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2700 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2701 struct wacom_features *features = &wacom->wacom_wac.features;
2703 if (touch_is_muted(wacom_wac) && !wacom_wac->shared->touch_down)
2706 if (wacom_wac->is_invalid_bt_frame)
2709 switch (equivalent_usage) {
2710 case HID_DG_CONFIDENCE:
2711 wacom_wac->hid_data.confidence = value;
2714 wacom_wac->hid_data.x = value;
2717 wacom_wac->hid_data.y = value;
2720 wacom_wac->hid_data.width = value;
2723 wacom_wac->hid_data.height = value;
2725 case HID_DG_CONTACTID:
2726 wacom_wac->hid_data.id = value;
2728 case HID_DG_TIPSWITCH:
2729 wacom_wac->hid_data.tipswitch = value;
2731 case WACOM_HID_WT_REPORT_VALID:
2732 wacom_wac->is_invalid_bt_frame = !value;
2734 case HID_DG_CONTACTMAX:
2735 if (!features->touch_max) {
2736 features->touch_max = value;
2738 hid_warn(hdev, "%s: ignoring attempt to overwrite non-zero touch_max "
2739 "%d -> %d\n", __func__, features->touch_max, value);
2744 if (usage->usage_index + 1 == field->report_count) {
2745 if (equivalent_usage == wacom_wac->hid_data.last_slot_field) {
2746 bool touch_removed = wacom_wac_slot_is_active(wacom_wac->touch_input,
2747 wacom_wac->hid_data.id) && !wacom_wac->hid_data.tipswitch;
2749 if (wacom_wac->hid_data.confidence || touch_removed) {
2750 wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
2756 static void wacom_wac_finger_pre_report(struct hid_device *hdev,
2757 struct hid_report *report)
2759 struct wacom *wacom = hid_get_drvdata(hdev);
2760 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2761 struct hid_data* hid_data = &wacom_wac->hid_data;
2764 if (touch_is_muted(wacom_wac) && !wacom_wac->shared->touch_down)
2767 wacom_wac->is_invalid_bt_frame = false;
2769 hid_data->confidence = true;
2771 hid_data->cc_report = 0;
2772 hid_data->cc_index = -1;
2773 hid_data->cc_value_index = -1;
2775 for (i = 0; i < report->maxfield; i++) {
2776 struct hid_field *field = report->field[i];
2779 for (j = 0; j < field->maxusage; j++) {
2780 struct hid_usage *usage = &field->usage[j];
2781 unsigned int equivalent_usage =
2782 wacom_equivalent_usage(usage->hid);
2784 switch (equivalent_usage) {
2789 case HID_DG_CONTACTID:
2790 case HID_DG_INRANGE:
2792 case HID_DG_TIPSWITCH:
2793 hid_data->last_slot_field = equivalent_usage;
2795 case HID_DG_CONTACTCOUNT:
2796 hid_data->cc_report = report->id;
2797 hid_data->cc_index = i;
2798 hid_data->cc_value_index = j;
2804 if (hid_data->cc_report != 0 &&
2805 hid_data->cc_index >= 0) {
2806 struct hid_field *field = report->field[hid_data->cc_index];
2807 int value = field->value[hid_data->cc_value_index];
2809 hid_data->num_expected = value;
2810 hid_data->num_received = 0;
2814 hid_data->num_expected = wacom_wac->features.touch_max;
2815 hid_data->num_received = 0;
2819 static void wacom_wac_finger_report(struct hid_device *hdev,
2820 struct hid_report *report)
2822 struct wacom *wacom = hid_get_drvdata(hdev);
2823 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2824 struct input_dev *input = wacom_wac->touch_input;
2825 unsigned touch_max = wacom_wac->features.touch_max;
2827 /* if there was nothing to process, don't send an empty sync */
2828 if (wacom_wac->hid_data.num_expected == 0)
2831 /* If more packets of data are expected, give us a chance to
2832 * process them rather than immediately syncing a partial
2835 if (wacom_wac->hid_data.num_received < wacom_wac->hid_data.num_expected)
2839 input_mt_sync_frame(input);
2842 wacom_wac->hid_data.num_received = 0;
2843 wacom_wac->hid_data.num_expected = 0;
2845 /* keep touch state for pen event */
2846 wacom_wac->shared->touch_down = wacom_wac_finger_count_touches(wacom_wac);
2849 void wacom_wac_usage_mapping(struct hid_device *hdev,
2850 struct hid_field *field, struct hid_usage *usage)
2852 struct wacom *wacom = hid_get_drvdata(hdev);
2853 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2854 struct wacom_features *features = &wacom_wac->features;
2856 if (WACOM_DIRECT_DEVICE(field))
2857 features->device_type |= WACOM_DEVICETYPE_DIRECT;
2859 /* usage tests must precede field tests */
2860 if (WACOM_BATTERY_USAGE(usage))
2861 wacom_wac_battery_usage_mapping(hdev, field, usage);
2862 else if (WACOM_PAD_FIELD(field))
2863 wacom_wac_pad_usage_mapping(hdev, field, usage);
2864 else if (WACOM_PEN_FIELD(field))
2865 wacom_wac_pen_usage_mapping(hdev, field, usage);
2866 else if (WACOM_FINGER_FIELD(field))
2867 wacom_wac_finger_usage_mapping(hdev, field, usage);
2870 void wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
2871 struct hid_usage *usage, __s32 value)
2873 struct wacom *wacom = hid_get_drvdata(hdev);
2875 if (wacom->wacom_wac.features.type != HID_GENERIC)
2878 if (value > field->logical_maximum || value < field->logical_minimum)
2881 /* usage tests must precede field tests */
2882 if (WACOM_BATTERY_USAGE(usage))
2883 wacom_wac_battery_event(hdev, field, usage, value);
2884 else if (WACOM_PAD_FIELD(field))
2885 wacom_wac_pad_event(hdev, field, usage, value);
2886 else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
2887 wacom_wac_pen_event(hdev, field, usage, value);
2888 else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
2889 wacom_wac_finger_event(hdev, field, usage, value);
2892 static void wacom_report_events(struct hid_device *hdev,
2893 struct hid_report *report, int collection_index,
2898 for (r = field_index; r < report->maxfield; r++) {
2899 struct hid_field *field;
2902 field = report->field[r];
2903 count = field->report_count;
2905 if (!(HID_MAIN_ITEM_VARIABLE & field->flags))
2908 for (n = 0 ; n < count; n++) {
2909 if (field->usage[n].collection_index == collection_index)
2910 wacom_wac_event(hdev, field, &field->usage[n],
2918 static int wacom_wac_collection(struct hid_device *hdev, struct hid_report *report,
2919 int collection_index, struct hid_field *field,
2922 struct wacom *wacom = hid_get_drvdata(hdev);
2924 wacom_report_events(hdev, report, collection_index, field_index);
2927 * Non-input reports may be sent prior to the device being
2928 * completely initialized. Since only their events need
2929 * to be processed, exit after 'wacom_report_events' has
2930 * been called to prevent potential crashes in the report-
2931 * processing functions.
2933 if (report->type != HID_INPUT_REPORT)
2936 if (WACOM_PAD_FIELD(field))
2938 else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
2939 wacom_wac_pen_report(hdev, report);
2940 else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
2941 wacom_wac_finger_report(hdev, report);
2946 void wacom_wac_report(struct hid_device *hdev, struct hid_report *report)
2948 struct wacom *wacom = hid_get_drvdata(hdev);
2949 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2950 struct hid_field *field;
2951 bool pad_in_hid_field = false, pen_in_hid_field = false,
2952 finger_in_hid_field = false, true_pad = false;
2954 int prev_collection = -1;
2956 if (wacom_wac->features.type != HID_GENERIC)
2959 for (r = 0; r < report->maxfield; r++) {
2960 field = report->field[r];
2962 if (WACOM_PAD_FIELD(field))
2963 pad_in_hid_field = true;
2964 if (WACOM_PEN_FIELD(field))
2965 pen_in_hid_field = true;
2966 if (WACOM_FINGER_FIELD(field))
2967 finger_in_hid_field = true;
2968 if (wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY)
2972 wacom_wac_battery_pre_report(hdev, report);
2974 if (pad_in_hid_field && wacom->wacom_wac.pad_input)
2975 wacom_wac_pad_pre_report(hdev, report);
2976 if (pen_in_hid_field && wacom->wacom_wac.pen_input)
2977 wacom_wac_pen_pre_report(hdev, report);
2978 if (finger_in_hid_field && wacom->wacom_wac.touch_input)
2979 wacom_wac_finger_pre_report(hdev, report);
2981 for (r = 0; r < report->maxfield; r++) {
2982 field = report->field[r];
2984 if (field->usage[0].collection_index != prev_collection) {
2985 if (wacom_wac_collection(hdev, report,
2986 field->usage[0].collection_index, field, r) < 0)
2988 prev_collection = field->usage[0].collection_index;
2992 wacom_wac_battery_report(hdev, report);
2994 if (true_pad && wacom->wacom_wac.pad_input)
2995 wacom_wac_pad_report(hdev, report, field);
2998 static int wacom_bpt_touch(struct wacom_wac *wacom)
3000 struct wacom_features *features = &wacom->features;
3001 struct input_dev *input = wacom->touch_input;
3002 struct input_dev *pad_input = wacom->pad_input;
3003 unsigned char *data = wacom->data;
3006 if (data[0] != 0x02)
3009 for (i = 0; i < 2; i++) {
3010 int offset = (data[1] & 0x80) ? (8 * i) : (9 * i);
3011 bool touch = report_touch_events(wacom)
3012 && (data[offset + 3] & 0x80);
3014 input_mt_slot(input, i);
3015 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
3017 int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff;
3018 int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff;
3019 if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) {
3023 input_report_abs(input, ABS_MT_POSITION_X, x);
3024 input_report_abs(input, ABS_MT_POSITION_Y, y);
3028 input_mt_sync_frame(input);
3030 input_report_key(pad_input, BTN_LEFT, (data[1] & 0x08) != 0);
3031 input_report_key(pad_input, BTN_FORWARD, (data[1] & 0x04) != 0);
3032 input_report_key(pad_input, BTN_BACK, (data[1] & 0x02) != 0);
3033 input_report_key(pad_input, BTN_RIGHT, (data[1] & 0x01) != 0);
3034 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
3039 static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
3041 struct wacom_features *features = &wacom->features;
3042 struct input_dev *input = wacom->touch_input;
3043 bool touch = data[1] & 0x80;
3044 int slot = input_mt_get_slot_by_key(input, data[0]);
3049 touch = touch && report_touch_events(wacom);
3051 input_mt_slot(input, slot);
3052 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
3055 int x = (data[2] << 4) | (data[4] >> 4);
3056 int y = (data[3] << 4) | (data[4] & 0x0f);
3059 if (features->type >= INTUOSPS && features->type <= INTUOSHT2) {
3060 width = data[5] * 100;
3061 height = data[6] * 100;
3064 * "a" is a scaled-down area which we assume is
3065 * roughly circular and which can be described as:
3069 int x_res = input_abs_get_res(input, ABS_MT_POSITION_X);
3070 int y_res = input_abs_get_res(input, ABS_MT_POSITION_Y);
3071 width = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE);
3072 height = width * y_res / x_res;
3075 input_report_abs(input, ABS_MT_POSITION_X, x);
3076 input_report_abs(input, ABS_MT_POSITION_Y, y);
3077 input_report_abs(input, ABS_MT_TOUCH_MAJOR, width);
3078 input_report_abs(input, ABS_MT_TOUCH_MINOR, height);
3082 static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
3084 struct input_dev *input = wacom->pad_input;
3085 struct wacom_features *features = &wacom->features;
3087 if (features->type == INTUOSHT || features->type == INTUOSHT2) {
3088 input_report_key(input, BTN_LEFT, (data[1] & 0x02) != 0);
3089 input_report_key(input, BTN_BACK, (data[1] & 0x08) != 0);
3091 input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
3092 input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
3094 input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
3095 input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
3098 static int wacom_bpt3_touch(struct wacom_wac *wacom)
3100 unsigned char *data = wacom->data;
3101 int count = data[1] & 0x07;
3102 int touch_changed = 0, i;
3104 if (data[0] != 0x02)
3107 /* data has up to 7 fixed sized 8-byte messages starting at data[2] */
3108 for (i = 0; i < count; i++) {
3109 int offset = (8 * i) + 2;
3110 int msg_id = data[offset];
3112 if (msg_id >= 2 && msg_id <= 17) {
3113 wacom_bpt3_touch_msg(wacom, data + offset);
3115 } else if (msg_id == 128)
3116 wacom_bpt3_button_msg(wacom, data + offset);
3120 /* only update touch if we actually have a touchpad and touch data changed */
3121 if (wacom->touch_input && touch_changed) {
3122 input_mt_sync_frame(wacom->touch_input);
3123 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
3129 static int wacom_bpt_pen(struct wacom_wac *wacom)
3131 struct wacom_features *features = &wacom->features;
3132 struct input_dev *input = wacom->pen_input;
3133 unsigned char *data = wacom->data;
3134 int x = 0, y = 0, p = 0, d = 0;
3135 bool pen = false, btn1 = false, btn2 = false;
3136 bool range, prox, rdy;
3138 if (data[0] != WACOM_REPORT_PENABLED)
3141 range = (data[1] & 0x80) == 0x80;
3142 prox = (data[1] & 0x40) == 0x40;
3143 rdy = (data[1] & 0x20) == 0x20;
3145 wacom->shared->stylus_in_proximity = range;
3146 if (delay_pen_events(wacom))
3150 p = le16_to_cpup((__le16 *)&data[6]);
3151 pen = data[1] & 0x01;
3152 btn1 = data[1] & 0x02;
3153 btn2 = data[1] & 0x04;
3156 x = le16_to_cpup((__le16 *)&data[2]);
3157 y = le16_to_cpup((__le16 *)&data[4]);
3159 if (data[1] & 0x08) {
3160 wacom->tool[0] = BTN_TOOL_RUBBER;
3161 wacom->id[0] = ERASER_DEVICE_ID;
3163 wacom->tool[0] = BTN_TOOL_PEN;
3164 wacom->id[0] = STYLUS_DEVICE_ID;
3166 wacom->reporting_data = true;
3170 * Convert distance from out prox to distance from tablet.
3171 * distance will be greater than distance_max once
3172 * touching and applying pressure; do not report negative
3175 if (data[8] <= features->distance_max)
3176 d = features->distance_max - data[8];
3181 if (wacom->reporting_data) {
3182 input_report_key(input, BTN_TOUCH, pen);
3183 input_report_key(input, BTN_STYLUS, btn1);
3184 input_report_key(input, BTN_STYLUS2, btn2);
3186 if (prox || !range) {
3187 input_report_abs(input, ABS_X, x);
3188 input_report_abs(input, ABS_Y, y);
3190 input_report_abs(input, ABS_PRESSURE, p);
3191 input_report_abs(input, ABS_DISTANCE, d);
3193 input_report_key(input, wacom->tool[0], range); /* PEN or RUBBER */
3194 input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
3198 wacom->reporting_data = false;
3204 static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
3206 struct wacom_features *features = &wacom->features;
3208 if ((features->type == INTUOSHT2) &&
3209 (features->device_type & WACOM_DEVICETYPE_PEN))
3210 return wacom_intuos_irq(wacom);
3211 else if (len == WACOM_PKGLEN_BBTOUCH)
3212 return wacom_bpt_touch(wacom);
3213 else if (len == WACOM_PKGLEN_BBTOUCH3)
3214 return wacom_bpt3_touch(wacom);
3215 else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
3216 return wacom_bpt_pen(wacom);
3221 static void wacom_bamboo_pad_pen_event(struct wacom_wac *wacom,
3222 unsigned char *data)
3224 unsigned char prefix;
3227 * We need to reroute the event from the debug interface to the
3229 * We need to add the report ID to the actual pen report, so we
3230 * temporary overwrite the first byte to prevent having to kzalloc/kfree
3231 * and memcpy the report.
3234 data[0] = WACOM_REPORT_BPAD_PEN;
3237 * actually reroute the event.
3238 * No need to check if wacom->shared->pen is valid, hid_input_report()
3239 * will check for us.
3241 hid_input_report(wacom->shared->pen, HID_INPUT_REPORT, data,
3242 WACOM_PKGLEN_PENABLED, 1);
3247 static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom,
3248 unsigned char *data)
3250 struct input_dev *input = wacom->touch_input;
3251 unsigned char *finger_data, prefix;
3258 for (id = 0; id < wacom->features.touch_max; id++) {
3259 valid = !!(prefix & BIT(id)) &&
3260 report_touch_events(wacom);
3262 input_mt_slot(input, id);
3263 input_mt_report_slot_state(input, MT_TOOL_FINGER, valid);
3268 finger_data = data + 1 + id * 3;
3269 x = finger_data[0] | ((finger_data[1] & 0x0f) << 8);
3270 y = (finger_data[2] << 4) | (finger_data[1] >> 4);
3272 input_report_abs(input, ABS_MT_POSITION_X, x);
3273 input_report_abs(input, ABS_MT_POSITION_Y, y);
3276 input_mt_sync_frame(input);
3278 input_report_key(input, BTN_LEFT, prefix & 0x40);
3279 input_report_key(input, BTN_RIGHT, prefix & 0x80);
3281 /* keep touch state for pen event */
3282 wacom->shared->touch_down = !!prefix && report_touch_events(wacom);
3287 static int wacom_bamboo_pad_irq(struct wacom_wac *wacom, size_t len)
3289 unsigned char *data = wacom->data;
3291 if (!((len == WACOM_PKGLEN_BPAD_TOUCH) ||
3292 (len == WACOM_PKGLEN_BPAD_TOUCH_USB)) ||
3293 (data[0] != WACOM_REPORT_BPAD_TOUCH))
3297 wacom_bamboo_pad_pen_event(wacom, &data[1]);
3300 return wacom_bamboo_pad_touch_event(wacom, &data[9]);
3305 static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
3307 unsigned char *data = wacom->data;
3310 if (len != WACOM_PKGLEN_WIRELESS || data[0] != WACOM_REPORT_WL)
3313 connected = data[1] & 0x01;
3315 int pid, battery, charging;
3317 if ((wacom->shared->type == INTUOSHT ||
3318 wacom->shared->type == INTUOSHT2) &&
3319 wacom->shared->touch_input &&
3320 wacom->shared->touch_max) {
3321 input_report_switch(wacom->shared->touch_input,
3322 SW_MUTE_DEVICE, data[5] & 0x40);
3323 input_sync(wacom->shared->touch_input);
3326 pid = get_unaligned_be16(&data[6]);
3327 battery = (data[5] & 0x3f) * 100 / 31;
3328 charging = !!(data[5] & 0x80);
3329 if (wacom->pid != pid) {
3331 wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
3334 wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
3335 battery, charging, 1, 0);
3337 } else if (wacom->pid != 0) {
3338 /* disconnected while previously connected */
3340 wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
3341 wacom_notify_battery(wacom, POWER_SUPPLY_STATUS_UNKNOWN, 0, 0, 0, 0);
3347 static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
3349 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
3350 struct wacom_features *features = &wacom_wac->features;
3351 unsigned char *data = wacom_wac->data;
3353 if (data[0] != WACOM_REPORT_USB)
3356 if ((features->type == INTUOSHT ||
3357 features->type == INTUOSHT2) &&
3358 wacom_wac->shared->touch_input &&
3359 features->touch_max) {
3360 input_report_switch(wacom_wac->shared->touch_input,
3361 SW_MUTE_DEVICE, data[8] & 0x40);
3362 input_sync(wacom_wac->shared->touch_input);
3365 if (data[9] & 0x02) { /* wireless module is attached */
3366 int battery = (data[8] & 0x3f) * 100 / 31;
3367 bool charging = !!(data[8] & 0x80);
3369 wacom_notify_battery(wacom_wac, WACOM_POWER_SUPPLY_STATUS_AUTO,
3370 battery, charging, battery || charging, 1);
3372 if (!wacom->battery.battery &&
3373 !(features->quirks & WACOM_QUIRK_BATTERY)) {
3374 features->quirks |= WACOM_QUIRK_BATTERY;
3375 wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
3378 else if ((features->quirks & WACOM_QUIRK_BATTERY) &&
3379 wacom->battery.battery) {
3380 features->quirks &= ~WACOM_QUIRK_BATTERY;
3381 wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
3382 wacom_notify_battery(wacom_wac, POWER_SUPPLY_STATUS_UNKNOWN, 0, 0, 0, 0);
3387 void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
3391 switch (wacom_wac->features.type) {
3393 sync = wacom_penpartner_irq(wacom_wac);
3397 sync = wacom_pl_irq(wacom_wac);
3404 sync = wacom_graphire_irq(wacom_wac);
3408 sync = wacom_ptu_irq(wacom_wac);
3412 sync = wacom_dtu_irq(wacom_wac);
3417 sync = wacom_dtus_irq(wacom_wac);
3436 case CINTIQ_COMPANION_2:
3437 sync = wacom_intuos_irq(wacom_wac);
3441 sync = wacom_intuos_bt_irq(wacom_wac, len);
3446 sync = wacom_24hdt_irq(wacom_wac);
3455 if (len == WACOM_PKGLEN_BBTOUCH3)
3456 sync = wacom_bpt3_touch(wacom_wac);
3457 else if (wacom_wac->data[0] == WACOM_REPORT_USB)
3458 sync = wacom_status_irq(wacom_wac, len);
3460 sync = wacom_intuos_irq(wacom_wac);
3466 sync = wacom_intuos_pro2_bt_irq(wacom_wac, len);
3475 sync = wacom_tpc_irq(wacom_wac, len);
3483 if (wacom_wac->data[0] == WACOM_REPORT_USB)
3484 sync = wacom_status_irq(wacom_wac, len);
3486 sync = wacom_bpt_irq(wacom_wac, len);
3490 sync = wacom_bamboo_pad_irq(wacom_wac, len);
3494 sync = wacom_wireless_irq(wacom_wac, len);
3499 if (wacom_wac->data[0] == WACOM_REPORT_DEVICE_LIST)
3500 wacom_remote_status_irq(wacom_wac, len);
3502 sync = wacom_remote_irq(wacom_wac, len);
3511 if (wacom_wac->pen_input)
3512 input_sync(wacom_wac->pen_input);
3513 if (wacom_wac->touch_input)
3514 input_sync(wacom_wac->touch_input);
3515 if (wacom_wac->pad_input)
3516 input_sync(wacom_wac->pad_input);
3520 static void wacom_setup_basic_pro_pen(struct wacom_wac *wacom_wac)
3522 struct input_dev *input_dev = wacom_wac->pen_input;
3524 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
3526 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3527 __set_bit(BTN_STYLUS, input_dev->keybit);
3528 __set_bit(BTN_STYLUS2, input_dev->keybit);
3530 input_set_abs_params(input_dev, ABS_DISTANCE,
3531 0, wacom_wac->features.distance_max, wacom_wac->features.distance_fuzz, 0);
3534 static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
3536 struct input_dev *input_dev = wacom_wac->pen_input;
3537 struct wacom_features *features = &wacom_wac->features;
3539 wacom_setup_basic_pro_pen(wacom_wac);
3541 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3542 __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
3543 __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
3544 __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
3546 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
3547 input_set_abs_params(input_dev, ABS_TILT_X, -64, 63, features->tilt_fuzz, 0);
3548 input_abs_set_res(input_dev, ABS_TILT_X, 57);
3549 input_set_abs_params(input_dev, ABS_TILT_Y, -64, 63, features->tilt_fuzz, 0);
3550 input_abs_set_res(input_dev, ABS_TILT_Y, 57);
3553 static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
3555 struct input_dev *input_dev = wacom_wac->pen_input;
3557 input_set_capability(input_dev, EV_REL, REL_WHEEL);
3559 wacom_setup_cintiq(wacom_wac);
3561 __set_bit(BTN_LEFT, input_dev->keybit);
3562 __set_bit(BTN_RIGHT, input_dev->keybit);
3563 __set_bit(BTN_MIDDLE, input_dev->keybit);
3564 __set_bit(BTN_SIDE, input_dev->keybit);
3565 __set_bit(BTN_EXTRA, input_dev->keybit);
3566 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
3567 __set_bit(BTN_TOOL_LENS, input_dev->keybit);
3569 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
3570 input_abs_set_res(input_dev, ABS_RZ, 287);
3571 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
3574 void wacom_setup_device_quirks(struct wacom *wacom)
3576 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
3577 struct wacom_features *features = &wacom->wacom_wac.features;
3579 /* The pen and pad share the same interface on most devices */
3580 if (features->type == GRAPHIRE_BT || features->type == WACOM_G4 ||
3581 features->type == DTUS ||
3582 (features->type >= INTUOS3S && features->type <= WACOM_MO)) {
3583 if (features->device_type & WACOM_DEVICETYPE_PEN)
3584 features->device_type |= WACOM_DEVICETYPE_PAD;
3587 /* touch device found but size is not defined. use default */
3588 if (features->device_type & WACOM_DEVICETYPE_TOUCH && !features->x_max) {
3589 features->x_max = 1023;
3590 features->y_max = 1023;
3594 * Intuos5/Pro and Bamboo 3rd gen have no useful data about its
3595 * touch interface in its HID descriptor. If this is the touch
3596 * interface (PacketSize of WACOM_PKGLEN_BBTOUCH3), override the
3599 if ((features->type >= INTUOS5S && features->type <= INTUOSPL) ||
3600 (features->type >= INTUOSHT && features->type <= BAMBOO_PT)) {
3601 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
3602 if (features->touch_max)
3603 features->device_type |= WACOM_DEVICETYPE_TOUCH;
3604 if (features->type >= INTUOSHT && features->type <= BAMBOO_PT)
3605 features->device_type |= WACOM_DEVICETYPE_PAD;
3607 if (features->type == INTUOSHT2) {
3608 features->x_max = features->x_max / 10;
3609 features->y_max = features->y_max / 10;
3612 features->x_max = 4096;
3613 features->y_max = 4096;
3616 else if (features->pktlen == WACOM_PKGLEN_BBTOUCH) {
3617 features->device_type |= WACOM_DEVICETYPE_PAD;
3622 * Hack for the Bamboo One:
3623 * the device presents a PAD/Touch interface as most Bamboos and even
3624 * sends ghosts PAD data on it. However, later, we must disable this
3625 * ghost interface, and we can not detect it unless we set it here
3626 * to WACOM_DEVICETYPE_PAD or WACOM_DEVICETYPE_TOUCH.
3628 if (features->type == BAMBOO_PEN &&
3629 features->pktlen == WACOM_PKGLEN_BBTOUCH3)
3630 features->device_type |= WACOM_DEVICETYPE_PAD;
3633 * Raw Wacom-mode pen and touch events both come from interface
3634 * 0, whose HID descriptor has an application usage of 0xFF0D
3635 * (i.e., WACOM_HID_WD_DIGITIZER). We route pen packets back
3636 * out through the HID_GENERIC device created for interface 1,
3637 * so rewrite this one to be of type WACOM_DEVICETYPE_TOUCH.
3639 if (features->type == BAMBOO_PAD)
3640 features->device_type = WACOM_DEVICETYPE_TOUCH;
3642 if (features->type == REMOTE)
3643 features->device_type = WACOM_DEVICETYPE_PAD;
3645 if (features->type == INTUOSP2_BT ||
3646 features->type == INTUOSP2S_BT) {
3647 features->device_type |= WACOM_DEVICETYPE_PEN |
3648 WACOM_DEVICETYPE_PAD |
3649 WACOM_DEVICETYPE_TOUCH;
3650 features->quirks |= WACOM_QUIRK_BATTERY;
3653 if (features->type == INTUOSHT3_BT) {
3654 features->device_type |= WACOM_DEVICETYPE_PEN |
3655 WACOM_DEVICETYPE_PAD;
3656 features->quirks |= WACOM_QUIRK_BATTERY;
3659 switch (features->type) {
3670 case CINTIQ_COMPANION_2:
3682 features->device_type |= WACOM_DEVICETYPE_DIRECT;
3686 if (wacom->hdev->bus == BUS_BLUETOOTH)
3687 features->quirks |= WACOM_QUIRK_BATTERY;
3689 /* quirk for bamboo touch with 2 low res touches */
3690 if ((features->type == BAMBOO_PT || features->type == BAMBOO_TOUCH) &&
3691 features->pktlen == WACOM_PKGLEN_BBTOUCH) {
3692 features->x_max <<= 5;
3693 features->y_max <<= 5;
3694 features->x_fuzz <<= 5;
3695 features->y_fuzz <<= 5;
3696 features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;
3699 if (features->type == WIRELESS) {
3700 if (features->device_type == WACOM_DEVICETYPE_WL_MONITOR) {
3701 features->quirks |= WACOM_QUIRK_BATTERY;
3705 if (features->type == REMOTE)
3706 features->device_type |= WACOM_DEVICETYPE_WL_MONITOR;
3708 /* HID descriptor for DTK-2451 / DTH-2452 claims to report lots
3709 * of things it shouldn't. Lets fix up the damage...
3711 if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
3712 features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
3713 __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
3714 __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
3715 __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
3716 __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
3717 __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
3718 __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
3719 __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
3720 __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
3721 __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
3722 __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
3723 __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
3727 int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
3728 struct wacom_wac *wacom_wac)
3730 struct wacom_features *features = &wacom_wac->features;
3732 if (!(features->device_type & WACOM_DEVICETYPE_PEN))
3735 if (features->device_type & WACOM_DEVICETYPE_DIRECT)
3736 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
3738 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
3740 if (features->type == HID_GENERIC)
3741 /* setup has already been done */
3744 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3745 __set_bit(BTN_TOUCH, input_dev->keybit);
3746 __set_bit(ABS_MISC, input_dev->absbit);
3748 input_set_abs_params(input_dev, ABS_X, 0 + features->offset_left,
3749 features->x_max - features->offset_right,
3750 features->x_fuzz, 0);
3751 input_set_abs_params(input_dev, ABS_Y, 0 + features->offset_top,
3752 features->y_max - features->offset_bottom,
3753 features->y_fuzz, 0);
3754 input_set_abs_params(input_dev, ABS_PRESSURE, 0,
3755 features->pressure_max, features->pressure_fuzz, 0);
3757 /* penabled devices have fixed resolution for each model */
3758 input_abs_set_res(input_dev, ABS_X, features->x_resolution);
3759 input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
3761 switch (features->type) {
3763 __clear_bit(ABS_MISC, input_dev->absbit);
3768 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3769 features->distance_max,
3770 features->distance_fuzz, 0);
3774 input_set_capability(input_dev, EV_REL, REL_WHEEL);
3776 __set_bit(BTN_LEFT, input_dev->keybit);
3777 __set_bit(BTN_RIGHT, input_dev->keybit);
3778 __set_bit(BTN_MIDDLE, input_dev->keybit);
3780 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3781 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3782 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
3783 __set_bit(BTN_STYLUS, input_dev->keybit);
3784 __set_bit(BTN_STYLUS2, input_dev->keybit);
3796 case CINTIQ_COMPANION_2:
3797 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3798 input_abs_set_res(input_dev, ABS_Z, 287);
3799 wacom_setup_cintiq(wacom_wac);
3809 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3810 input_abs_set_res(input_dev, ABS_Z, 287);
3814 wacom_setup_intuos(wacom_wac);
3825 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3826 features->distance_max,
3827 features->distance_fuzz, 0);
3829 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3830 input_abs_set_res(input_dev, ABS_Z, 287);
3832 wacom_setup_intuos(wacom_wac);
3843 __clear_bit(ABS_MISC, input_dev->absbit);
3850 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3851 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3852 __set_bit(BTN_STYLUS, input_dev->keybit);
3853 __set_bit(BTN_STYLUS2, input_dev->keybit);
3857 __set_bit(BTN_STYLUS2, input_dev->keybit);
3861 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3862 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3863 __set_bit(BTN_STYLUS, input_dev->keybit);
3871 if (features->type == INTUOSHT2 ||
3872 features->type == INTUOSHT3_BT) {
3873 wacom_setup_basic_pro_pen(wacom_wac);
3875 __clear_bit(ABS_MISC, input_dev->absbit);
3876 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3877 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3878 __set_bit(BTN_STYLUS, input_dev->keybit);
3879 __set_bit(BTN_STYLUS2, input_dev->keybit);
3880 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3881 features->distance_max,
3882 features->distance_fuzz, 0);
3886 __clear_bit(ABS_MISC, input_dev->absbit);
3892 int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
3893 struct wacom_wac *wacom_wac)
3895 struct wacom_features *features = &wacom_wac->features;
3897 if (!(features->device_type & WACOM_DEVICETYPE_TOUCH))
3900 if (features->device_type & WACOM_DEVICETYPE_DIRECT)
3901 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
3903 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
3905 if (features->type == HID_GENERIC)
3906 /* setup has already been done */
3909 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3910 __set_bit(BTN_TOUCH, input_dev->keybit);
3912 if (features->touch_max == 1) {
3913 input_set_abs_params(input_dev, ABS_X, 0,
3914 features->x_max, features->x_fuzz, 0);
3915 input_set_abs_params(input_dev, ABS_Y, 0,
3916 features->y_max, features->y_fuzz, 0);
3917 input_abs_set_res(input_dev, ABS_X,
3918 features->x_resolution);
3919 input_abs_set_res(input_dev, ABS_Y,
3920 features->y_resolution);
3922 else if (features->touch_max > 1) {
3923 input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
3924 features->x_max, features->x_fuzz, 0);
3925 input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
3926 features->y_max, features->y_fuzz, 0);
3927 input_abs_set_res(input_dev, ABS_MT_POSITION_X,
3928 features->x_resolution);
3929 input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
3930 features->y_resolution);
3933 switch (features->type) {
3936 input_dev->evbit[0] |= BIT_MASK(EV_SW);
3937 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
3939 if (wacom_wac->shared->touch->product == 0x361) {
3940 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
3942 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
3945 else if (wacom_wac->shared->touch->product == 0x360) {
3946 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
3948 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
3951 else if (wacom_wac->shared->touch->product == 0x393) {
3952 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
3954 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
3957 input_abs_set_res(input_dev, ABS_MT_POSITION_X, 40);
3958 input_abs_set_res(input_dev, ABS_MT_POSITION_Y, 40);
3968 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
3969 input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, features->y_max, 0, 0);
3970 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
3974 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
3975 input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
3976 input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
3977 input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
3981 if (wacom_wac->shared->touch->product == 0x32C ||
3982 wacom_wac->shared->touch->product == 0xF6) {
3983 input_dev->evbit[0] |= BIT_MASK(EV_SW);
3984 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
3985 wacom_wac->has_mute_touch_switch = true;
3986 wacom_wac->is_soft_touch_switch = true;
3994 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT);
4003 input_dev->evbit[0] |= BIT_MASK(EV_SW);
4004 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
4009 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
4010 input_set_abs_params(input_dev,
4012 0, features->x_max, 0, 0);
4013 input_set_abs_params(input_dev,
4015 0, features->y_max, 0, 0);
4017 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
4021 input_mt_init_slots(input_dev, features->touch_max,
4023 __set_bit(BTN_LEFT, input_dev->keybit);
4024 __set_bit(BTN_RIGHT, input_dev->keybit);
4030 static int wacom_numbered_button_to_key(int n)
4035 return BTN_A + (n-10);
4037 return BTN_BASE + (n-16);
4042 static void wacom_setup_numbered_buttons(struct input_dev *input_dev,
4047 for (i = 0; i < button_count; i++) {
4048 int key = wacom_numbered_button_to_key(i);
4051 __set_bit(key, input_dev->keybit);
4055 static void wacom_24hd_update_leds(struct wacom *wacom, int mask, int group)
4057 struct wacom_led *led;
4059 bool updated = false;
4062 * 24HD has LED group 1 to the left and LED group 0 to the right.
4063 * So group 0 matches the second half of the buttons and thus the mask
4064 * needs to be shifted.
4069 for (i = 0; i < 3; i++) {
4070 led = wacom_led_find(wacom, group, i);
4072 hid_err(wacom->hdev, "can't find LED %d in group %d\n",
4076 if (!updated && mask & BIT(i)) {
4078 led_trigger_event(&led->trigger, LED_FULL);
4085 static bool wacom_is_led_toggled(struct wacom *wacom, int button_count,
4086 int mask, int group)
4091 * 21UX2 has LED group 1 to the left and LED group 0
4092 * to the right. We need to reverse the group to match this
4093 * historical behavior.
4095 if (wacom->wacom_wac.features.type == WACOM_21UX2)
4098 group_button = group * (button_count/wacom->led.count);
4100 if (wacom->wacom_wac.features.type == INTUOSP2_BT)
4103 return mask & (1 << group_button);
4106 static void wacom_update_led(struct wacom *wacom, int button_count, int mask,
4109 struct wacom_led *led, *next_led;
4113 if (wacom->wacom_wac.features.type == WACOM_24HD)
4114 return wacom_24hd_update_leds(wacom, mask, group);
4116 pressed = wacom_is_led_toggled(wacom, button_count, mask, group);
4117 cur = wacom->led.groups[group].select;
4119 led = wacom_led_find(wacom, group, cur);
4121 hid_err(wacom->hdev, "can't find current LED %d in group %d\n",
4131 if (led->held && pressed)
4134 next_led = wacom_led_next(wacom, led);
4136 hid_err(wacom->hdev, "can't find next LED in group %d\n",
4140 if (next_led == led)
4143 next_led->held = true;
4144 led_trigger_event(&next_led->trigger,
4145 wacom_leds_brightness_get(next_led));
4148 static void wacom_report_numbered_buttons(struct input_dev *input_dev,
4149 int button_count, int mask)
4151 struct wacom *wacom = input_get_drvdata(input_dev);
4154 for (i = 0; i < wacom->led.count; i++)
4155 wacom_update_led(wacom, button_count, mask, i);
4157 for (i = 0; i < button_count; i++) {
4158 int key = wacom_numbered_button_to_key(i);
4161 input_report_key(input_dev, key, mask & (1 << i));
4165 int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
4166 struct wacom_wac *wacom_wac)
4168 struct wacom_features *features = &wacom_wac->features;
4170 if ((features->type == HID_GENERIC) && features->numbered_buttons > 0)
4171 features->device_type |= WACOM_DEVICETYPE_PAD;
4173 if (!(features->device_type & WACOM_DEVICETYPE_PAD))
4176 if (features->type == REMOTE && input_dev == wacom_wac->pad_input)
4179 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
4181 /* kept for making legacy xf86-input-wacom working with the wheels */
4182 __set_bit(ABS_MISC, input_dev->absbit);
4184 /* kept for making legacy xf86-input-wacom accepting the pad */
4185 if (!(input_dev->absinfo && (input_dev->absinfo[ABS_X].minimum ||
4186 input_dev->absinfo[ABS_X].maximum)))
4187 input_set_abs_params(input_dev, ABS_X, 0, 1, 0, 0);
4188 if (!(input_dev->absinfo && (input_dev->absinfo[ABS_Y].minimum ||
4189 input_dev->absinfo[ABS_Y].maximum)))
4190 input_set_abs_params(input_dev, ABS_Y, 0, 1, 0, 0);
4192 /* kept for making udev and libwacom accepting the pad */
4193 __set_bit(BTN_STYLUS, input_dev->keybit);
4195 wacom_setup_numbered_buttons(input_dev, features->numbered_buttons);
4197 switch (features->type) {
4200 case CINTIQ_COMPANION_2:
4207 __set_bit(BTN_BACK, input_dev->keybit);
4208 __set_bit(BTN_LEFT, input_dev->keybit);
4209 __set_bit(BTN_FORWARD, input_dev->keybit);
4210 __set_bit(BTN_RIGHT, input_dev->keybit);
4211 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4215 __set_bit(BTN_BACK, input_dev->keybit);
4216 __set_bit(BTN_FORWARD, input_dev->keybit);
4217 input_set_capability(input_dev, EV_REL, REL_WHEEL);
4221 __set_bit(KEY_PROG1, input_dev->keybit);
4222 __set_bit(KEY_PROG2, input_dev->keybit);
4223 __set_bit(KEY_PROG3, input_dev->keybit);
4225 __set_bit(KEY_ONSCREEN_KEYBOARD, input_dev->keybit);
4226 __set_bit(KEY_INFO, input_dev->keybit);
4228 if (!features->oPid)
4229 __set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
4231 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4232 input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
4236 __set_bit(KEY_PROG1, input_dev->keybit);
4237 __set_bit(KEY_PROG2, input_dev->keybit);
4238 __set_bit(KEY_PROG3, input_dev->keybit);
4240 __set_bit(KEY_ONSCREEN_KEYBOARD, input_dev->keybit);
4241 __set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
4243 if (!features->oPid)
4244 __set_bit(KEY_CONTROLPANEL, input_dev->keybit);
4245 input_set_abs_params(input_dev, ABS_X, -2048, 2048, 0, 0);
4246 input_abs_set_res(input_dev, ABS_X, 1024); /* points/g */
4247 input_set_abs_params(input_dev, ABS_Y, -2048, 2048, 0, 0);
4248 input_abs_set_res(input_dev, ABS_Y, 1024);
4249 input_set_abs_params(input_dev, ABS_Z, -2048, 2048, 0, 0);
4250 input_abs_set_res(input_dev, ABS_Z, 1024);
4251 __set_bit(INPUT_PROP_ACCELEROMETER, input_dev->propbit);
4255 __set_bit(KEY_PROG1, input_dev->keybit);
4256 __set_bit(KEY_PROG2, input_dev->keybit);
4257 __set_bit(KEY_PROG3, input_dev->keybit);
4259 __set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
4260 __set_bit(KEY_INFO, input_dev->keybit);
4266 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
4267 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
4271 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4276 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
4280 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
4291 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4296 * For Bluetooth devices, the udev rule does not work correctly
4297 * for pads unless we add a stylus capability, which forces
4298 * ID_INPUT_TABLET to be set.
4300 __set_bit(BTN_STYLUS, input_dev->keybit);
4306 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4313 __clear_bit(ABS_MISC, input_dev->absbit);
4315 __set_bit(BTN_LEFT, input_dev->keybit);
4316 __set_bit(BTN_FORWARD, input_dev->keybit);
4317 __set_bit(BTN_BACK, input_dev->keybit);
4318 __set_bit(BTN_RIGHT, input_dev->keybit);
4323 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
4324 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
4332 /* no pad supported */
4338 static const struct wacom_features wacom_features_0x00 =
4339 { "Wacom Penpartner", 5040, 3780, 255, 0,
4340 PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
4341 static const struct wacom_features wacom_features_0x10 =
4342 { "Wacom Graphire", 10206, 7422, 511, 63,
4343 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4344 static const struct wacom_features wacom_features_0x81 =
4345 { "Wacom Graphire BT", 16704, 12064, 511, 32,
4346 GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES, 2 };
4347 static const struct wacom_features wacom_features_0x11 =
4348 { "Wacom Graphire2 4x5", 10206, 7422, 511, 63,
4349 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4350 static const struct wacom_features wacom_features_0x12 =
4351 { "Wacom Graphire2 5x7", 13918, 10206, 511, 63,
4352 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4353 static const struct wacom_features wacom_features_0x13 =
4354 { "Wacom Graphire3", 10208, 7424, 511, 63,
4355 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4356 static const struct wacom_features wacom_features_0x14 =
4357 { "Wacom Graphire3 6x8", 16704, 12064, 511, 63,
4358 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4359 static const struct wacom_features wacom_features_0x15 =
4360 { "Wacom Graphire4 4x5", 10208, 7424, 511, 63,
4361 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4362 static const struct wacom_features wacom_features_0x16 =
4363 { "Wacom Graphire4 6x8", 16704, 12064, 511, 63,
4364 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4365 static const struct wacom_features wacom_features_0x17 =
4366 { "Wacom BambooFun 4x5", 14760, 9225, 511, 63,
4367 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4368 static const struct wacom_features wacom_features_0x18 =
4369 { "Wacom BambooFun 6x8", 21648, 13530, 511, 63,
4370 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4371 static const struct wacom_features wacom_features_0x19 =
4372 { "Wacom Bamboo1 Medium", 16704, 12064, 511, 63,
4373 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
4374 static const struct wacom_features wacom_features_0x60 =
4375 { "Wacom Volito", 5104, 3712, 511, 63,
4376 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4377 static const struct wacom_features wacom_features_0x61 =
4378 { "Wacom PenStation2", 3250, 2320, 255, 63,
4379 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4380 static const struct wacom_features wacom_features_0x62 =
4381 { "Wacom Volito2 4x5", 5104, 3712, 511, 63,
4382 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4383 static const struct wacom_features wacom_features_0x63 =
4384 { "Wacom Volito2 2x3", 3248, 2320, 511, 63,
4385 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4386 static const struct wacom_features wacom_features_0x64 =
4387 { "Wacom PenPartner2", 3250, 2320, 511, 63,
4388 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
4389 static const struct wacom_features wacom_features_0x65 =
4390 { "Wacom Bamboo", 14760, 9225, 511, 63,
4391 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4392 static const struct wacom_features wacom_features_0x69 =
4393 { "Wacom Bamboo1", 5104, 3712, 511, 63,
4394 GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
4395 static const struct wacom_features wacom_features_0x6A =
4396 { "Wacom Bamboo1 4x6", 14760, 9225, 1023, 63,
4397 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4398 static const struct wacom_features wacom_features_0x6B =
4399 { "Wacom Bamboo1 5x8", 21648, 13530, 1023, 63,
4400 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4401 static const struct wacom_features wacom_features_0x20 =
4402 { "Wacom Intuos 4x5", 12700, 10600, 1023, 31,
4403 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4404 static const struct wacom_features wacom_features_0x21 =
4405 { "Wacom Intuos 6x8", 20320, 16240, 1023, 31,
4406 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4407 static const struct wacom_features wacom_features_0x22 =
4408 { "Wacom Intuos 9x12", 30480, 24060, 1023, 31,
4409 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4410 static const struct wacom_features wacom_features_0x23 =
4411 { "Wacom Intuos 12x12", 30480, 31680, 1023, 31,
4412 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4413 static const struct wacom_features wacom_features_0x24 =
4414 { "Wacom Intuos 12x18", 45720, 31680, 1023, 31,
4415 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4416 static const struct wacom_features wacom_features_0x30 =
4417 { "Wacom PL400", 5408, 4056, 255, 0,
4418 PL, WACOM_PL_RES, WACOM_PL_RES };
4419 static const struct wacom_features wacom_features_0x31 =
4420 { "Wacom PL500", 6144, 4608, 255, 0,
4421 PL, WACOM_PL_RES, WACOM_PL_RES };
4422 static const struct wacom_features wacom_features_0x32 =
4423 { "Wacom PL600", 6126, 4604, 255, 0,
4424 PL, WACOM_PL_RES, WACOM_PL_RES };
4425 static const struct wacom_features wacom_features_0x33 =
4426 { "Wacom PL600SX", 6260, 5016, 255, 0,
4427 PL, WACOM_PL_RES, WACOM_PL_RES };
4428 static const struct wacom_features wacom_features_0x34 =
4429 { "Wacom PL550", 6144, 4608, 511, 0,
4430 PL, WACOM_PL_RES, WACOM_PL_RES };
4431 static const struct wacom_features wacom_features_0x35 =
4432 { "Wacom PL800", 7220, 5780, 511, 0,
4433 PL, WACOM_PL_RES, WACOM_PL_RES };
4434 static const struct wacom_features wacom_features_0x37 =
4435 { "Wacom PL700", 6758, 5406, 511, 0,
4436 PL, WACOM_PL_RES, WACOM_PL_RES };
4437 static const struct wacom_features wacom_features_0x38 =
4438 { "Wacom PL510", 6282, 4762, 511, 0,
4439 PL, WACOM_PL_RES, WACOM_PL_RES };
4440 static const struct wacom_features wacom_features_0x39 =
4441 { "Wacom DTU710", 34080, 27660, 511, 0,
4442 PL, WACOM_PL_RES, WACOM_PL_RES };
4443 static const struct wacom_features wacom_features_0xC4 =
4444 { "Wacom DTF521", 6282, 4762, 511, 0,
4445 PL, WACOM_PL_RES, WACOM_PL_RES };
4446 static const struct wacom_features wacom_features_0xC0 =
4447 { "Wacom DTF720", 6858, 5506, 511, 0,
4448 PL, WACOM_PL_RES, WACOM_PL_RES };
4449 static const struct wacom_features wacom_features_0xC2 =
4450 { "Wacom DTF720a", 6858, 5506, 511, 0,
4451 PL, WACOM_PL_RES, WACOM_PL_RES };
4452 static const struct wacom_features wacom_features_0x03 =
4453 { "Wacom Cintiq Partner", 20480, 15360, 511, 0,
4454 PTU, WACOM_PL_RES, WACOM_PL_RES };
4455 static const struct wacom_features wacom_features_0x41 =
4456 { "Wacom Intuos2 4x5", 12700, 10600, 1023, 31,
4457 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4458 static const struct wacom_features wacom_features_0x42 =
4459 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
4460 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4461 static const struct wacom_features wacom_features_0x43 =
4462 { "Wacom Intuos2 9x12", 30480, 24060, 1023, 31,
4463 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4464 static const struct wacom_features wacom_features_0x44 =
4465 { "Wacom Intuos2 12x12", 30480, 31680, 1023, 31,
4466 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4467 static const struct wacom_features wacom_features_0x45 =
4468 { "Wacom Intuos2 12x18", 45720, 31680, 1023, 31,
4469 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4470 static const struct wacom_features wacom_features_0xB0 =
4471 { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63,
4472 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
4473 static const struct wacom_features wacom_features_0xB1 =
4474 { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63,
4475 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4476 static const struct wacom_features wacom_features_0xB2 =
4477 { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63,
4478 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4479 static const struct wacom_features wacom_features_0xB3 =
4480 { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63,
4481 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4482 static const struct wacom_features wacom_features_0xB4 =
4483 { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63,
4484 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4485 static const struct wacom_features wacom_features_0xB5 =
4486 { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63,
4487 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4488 static const struct wacom_features wacom_features_0xB7 =
4489 { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63,
4490 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
4491 static const struct wacom_features wacom_features_0xB8 =
4492 { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63,
4493 INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
4494 static const struct wacom_features wacom_features_0xB9 =
4495 { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63,
4496 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4497 static const struct wacom_features wacom_features_0xBA =
4498 { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63,
4499 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4500 static const struct wacom_features wacom_features_0xBB =
4501 { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63,
4502 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4503 static const struct wacom_features wacom_features_0xBC =
4504 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
4505 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4506 static const struct wacom_features wacom_features_0xBD =
4507 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
4508 INTUOS4WL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4509 static const struct wacom_features wacom_features_0x26 =
4510 { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63,
4511 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16 };
4512 static const struct wacom_features wacom_features_0x27 =
4513 { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63,
4514 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
4515 static const struct wacom_features wacom_features_0x28 =
4516 { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63,
4517 INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
4518 static const struct wacom_features wacom_features_0x29 =
4519 { "Wacom Intuos5 S", 31496, 19685, 2047, 63,
4520 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
4521 static const struct wacom_features wacom_features_0x2A =
4522 { "Wacom Intuos5 M", 44704, 27940, 2047, 63,
4523 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
4524 static const struct wacom_features wacom_features_0x314 =
4525 { "Wacom Intuos Pro S", 31496, 19685, 2047, 63,
4526 INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16,
4527 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4528 static const struct wacom_features wacom_features_0x315 =
4529 { "Wacom Intuos Pro M", 44704, 27940, 2047, 63,
4530 INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
4531 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4532 static const struct wacom_features wacom_features_0x317 =
4533 { "Wacom Intuos Pro L", 65024, 40640, 2047, 63,
4534 INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
4535 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4536 static const struct wacom_features wacom_features_0xF4 =
4537 { "Wacom Cintiq 24HD", 104480, 65600, 2047, 63,
4538 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
4539 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4540 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4541 static const struct wacom_features wacom_features_0xF8 =
4542 { "Wacom Cintiq 24HD touch", 104480, 65600, 2047, 63, /* Pen */
4543 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
4544 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4545 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4546 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 };
4547 static const struct wacom_features wacom_features_0xF6 =
4548 { "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */
4549 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10,
4550 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4551 static const struct wacom_features wacom_features_0x32A =
4552 { "Wacom Cintiq 27QHD", 120140, 67920, 2047, 63,
4553 WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
4554 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4555 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4556 static const struct wacom_features wacom_features_0x32B =
4557 { "Wacom Cintiq 27QHD touch", 120140, 67920, 2047, 63,
4558 WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
4559 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4560 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4561 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32C };
4562 static const struct wacom_features wacom_features_0x32C =
4563 { "Wacom Cintiq 27QHD touch", .type = WACOM_27QHDT,
4564 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32B, .touch_max = 10 };
4565 static const struct wacom_features wacom_features_0x3F =
4566 { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63,
4567 CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
4568 static const struct wacom_features wacom_features_0xC5 =
4569 { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63,
4570 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
4571 static const struct wacom_features wacom_features_0xC6 =
4572 { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63,
4573 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
4574 static const struct wacom_features wacom_features_0x304 =
4575 { "Wacom Cintiq 13HD", 59552, 33848, 1023, 63,
4576 WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4577 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4578 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4579 static const struct wacom_features wacom_features_0x333 =
4580 { "Wacom Cintiq 13HD touch", 59552, 33848, 2047, 63,
4581 WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4582 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4583 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4584 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x335 };
4585 static const struct wacom_features wacom_features_0x335 =
4586 { "Wacom Cintiq 13HD touch", .type = WACOM_24HDT, /* Touch */
4587 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x333, .touch_max = 10,
4588 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4589 static const struct wacom_features wacom_features_0xC7 =
4590 { "Wacom DTU1931", 37832, 30305, 511, 0,
4591 PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4592 static const struct wacom_features wacom_features_0xCE =
4593 { "Wacom DTU2231", 47864, 27011, 511, 0,
4594 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4595 .check_for_hid_type = true, .hid_type = HID_TYPE_USBMOUSE };
4596 static const struct wacom_features wacom_features_0xF0 =
4597 { "Wacom DTU1631", 34623, 19553, 511, 0,
4598 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4599 static const struct wacom_features wacom_features_0xFB =
4600 { "Wacom DTU1031", 22096, 13960, 511, 0,
4601 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
4602 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4603 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4604 static const struct wacom_features wacom_features_0x32F =
4605 { "Wacom DTU1031X", 22672, 12928, 511, 0,
4606 DTUSX, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 0,
4607 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4608 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4609 static const struct wacom_features wacom_features_0x336 =
4610 { "Wacom DTU1141", 23672, 13403, 1023, 0,
4611 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
4612 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4613 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4614 static const struct wacom_features wacom_features_0x57 =
4615 { "Wacom DTK2241", 95840, 54260, 2047, 63,
4616 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
4617 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4618 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4619 static const struct wacom_features wacom_features_0x59 = /* Pen */
4620 { "Wacom DTH2242", 95840, 54260, 2047, 63,
4621 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
4622 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4623 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4624 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D };
4625 static const struct wacom_features wacom_features_0x5D = /* Touch */
4626 { "Wacom DTH2242", .type = WACOM_24HDT,
4627 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10,
4628 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4629 static const struct wacom_features wacom_features_0xCC =
4630 { "Wacom Cintiq 21UX2", 87200, 65600, 2047, 63,
4631 WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
4632 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4633 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4634 static const struct wacom_features wacom_features_0xFA =
4635 { "Wacom Cintiq 22HD", 95840, 54260, 2047, 63,
4636 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
4637 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4638 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
4639 static const struct wacom_features wacom_features_0x5B =
4640 { "Wacom Cintiq 22HDT", 95840, 54260, 2047, 63,
4641 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
4642 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4643 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4644 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e };
4645 static const struct wacom_features wacom_features_0x5E =
4646 { "Wacom Cintiq 22HDT", .type = WACOM_24HDT,
4647 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5b, .touch_max = 10,
4648 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4649 static const struct wacom_features wacom_features_0x90 =
4650 { "Wacom ISDv4 90", 26202, 16325, 255, 0,
4651 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4652 static const struct wacom_features wacom_features_0x93 =
4653 { "Wacom ISDv4 93", 26202, 16325, 255, 0,
4654 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4655 static const struct wacom_features wacom_features_0x97 =
4656 { "Wacom ISDv4 97", 26202, 16325, 511, 0,
4657 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4658 static const struct wacom_features wacom_features_0x9A =
4659 { "Wacom ISDv4 9A", 26202, 16325, 255, 0,
4660 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4661 static const struct wacom_features wacom_features_0x9F =
4662 { "Wacom ISDv4 9F", 26202, 16325, 255, 0,
4663 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4664 static const struct wacom_features wacom_features_0xE2 =
4665 { "Wacom ISDv4 E2", 26202, 16325, 255, 0,
4666 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4667 static const struct wacom_features wacom_features_0xE3 =
4668 { "Wacom ISDv4 E3", 26202, 16325, 255, 0,
4669 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4670 static const struct wacom_features wacom_features_0xE5 =
4671 { "Wacom ISDv4 E5", 26202, 16325, 255, 0,
4672 MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4673 static const struct wacom_features wacom_features_0xE6 =
4674 { "Wacom ISDv4 E6", 27760, 15694, 255, 0,
4675 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4676 static const struct wacom_features wacom_features_0xEC =
4677 { "Wacom ISDv4 EC", 25710, 14500, 255, 0,
4678 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4679 static const struct wacom_features wacom_features_0xED =
4680 { "Wacom ISDv4 ED", 26202, 16325, 255, 0,
4681 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4682 static const struct wacom_features wacom_features_0xEF =
4683 { "Wacom ISDv4 EF", 26202, 16325, 255, 0,
4684 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4685 static const struct wacom_features wacom_features_0x100 =
4686 { "Wacom ISDv4 100", 26202, 16325, 255, 0,
4687 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4688 static const struct wacom_features wacom_features_0x101 =
4689 { "Wacom ISDv4 101", 26202, 16325, 255, 0,
4690 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4691 static const struct wacom_features wacom_features_0x10D =
4692 { "Wacom ISDv4 10D", 26202, 16325, 255, 0,
4693 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4694 static const struct wacom_features wacom_features_0x10E =
4695 { "Wacom ISDv4 10E", 27760, 15694, 255, 0,
4696 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4697 static const struct wacom_features wacom_features_0x10F =
4698 { "Wacom ISDv4 10F", 27760, 15694, 255, 0,
4699 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4700 static const struct wacom_features wacom_features_0x116 =
4701 { "Wacom ISDv4 116", 26202, 16325, 255, 0,
4702 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
4703 static const struct wacom_features wacom_features_0x12C =
4704 { "Wacom ISDv4 12C", 27848, 15752, 2047, 0,
4705 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
4706 static const struct wacom_features wacom_features_0x4001 =
4707 { "Wacom ISDv4 4001", 26202, 16325, 255, 0,
4708 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4709 static const struct wacom_features wacom_features_0x4004 =
4710 { "Wacom ISDv4 4004", 11060, 6220, 255, 0,
4711 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4712 static const struct wacom_features wacom_features_0x5000 =
4713 { "Wacom ISDv4 5000", 27848, 15752, 1023, 0,
4714 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4715 static const struct wacom_features wacom_features_0x5002 =
4716 { "Wacom ISDv4 5002", 29576, 16724, 1023, 0,
4717 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4718 static const struct wacom_features wacom_features_0x47 =
4719 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
4720 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4721 static const struct wacom_features wacom_features_0x84 =
4722 { "Wacom Wireless Receiver", .type = WIRELESS, .touch_max = 16 };
4723 static const struct wacom_features wacom_features_0xD0 =
4724 { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31,
4725 BAMBOO_TOUCH, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4726 static const struct wacom_features wacom_features_0xD1 =
4727 { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31,
4728 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4729 static const struct wacom_features wacom_features_0xD2 =
4730 { "Wacom Bamboo Craft", 14720, 9200, 1023, 31,
4731 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4732 static const struct wacom_features wacom_features_0xD3 =
4733 { "Wacom Bamboo 2FG 6x8", 21648, 13700, 1023, 31,
4734 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4735 static const struct wacom_features wacom_features_0xD4 =
4736 { "Wacom Bamboo Pen", 14720, 9200, 1023, 31,
4737 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4738 static const struct wacom_features wacom_features_0xD5 =
4739 { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31,
4740 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4741 static const struct wacom_features wacom_features_0xD6 =
4742 { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31,
4743 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4744 static const struct wacom_features wacom_features_0xD7 =
4745 { "Wacom BambooPT 2FG Small", 14720, 9200, 1023, 31,
4746 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4747 static const struct wacom_features wacom_features_0xD8 =
4748 { "Wacom Bamboo Comic 2FG", 21648, 13700, 1023, 31,
4749 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4750 static const struct wacom_features wacom_features_0xDA =
4751 { "Wacom Bamboo 2FG 4x5 SE", 14720, 9200, 1023, 31,
4752 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4753 static const struct wacom_features wacom_features_0xDB =
4754 { "Wacom Bamboo 2FG 6x8 SE", 21648, 13700, 1023, 31,
4755 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4756 static const struct wacom_features wacom_features_0xDD =
4757 { "Wacom Bamboo Connect", 14720, 9200, 1023, 31,
4758 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4759 static const struct wacom_features wacom_features_0xDE =
4760 { "Wacom Bamboo 16FG 4x5", 14720, 9200, 1023, 31,
4761 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
4762 static const struct wacom_features wacom_features_0xDF =
4763 { "Wacom Bamboo 16FG 6x8", 21648, 13700, 1023, 31,
4764 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
4765 static const struct wacom_features wacom_features_0x300 =
4766 { "Wacom Bamboo One S", 14720, 9225, 1023, 31,
4767 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4768 static const struct wacom_features wacom_features_0x301 =
4769 { "Wacom Bamboo One M", 21648, 13530, 1023, 31,
4770 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4771 static const struct wacom_features wacom_features_0x302 =
4772 { "Wacom Intuos PT S", 15200, 9500, 1023, 31,
4773 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4774 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4775 static const struct wacom_features wacom_features_0x303 =
4776 { "Wacom Intuos PT M", 21600, 13500, 1023, 31,
4777 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4778 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4779 static const struct wacom_features wacom_features_0x30E =
4780 { "Wacom Intuos S", 15200, 9500, 1023, 31,
4781 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4782 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4783 static const struct wacom_features wacom_features_0x6004 =
4784 { "ISD-V4", 12800, 8000, 255, 0,
4785 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4786 static const struct wacom_features wacom_features_0x307 =
4787 { "Wacom ISDv5 307", 59552, 33848, 2047, 63,
4788 CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4789 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4790 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4791 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 };
4792 static const struct wacom_features wacom_features_0x309 =
4793 { "Wacom ISDv5 309", .type = WACOM_24HDT, /* Touch */
4794 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x0307, .touch_max = 10,
4795 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4796 static const struct wacom_features wacom_features_0x30A =
4797 { "Wacom ISDv5 30A", 59552, 33848, 2047, 63,
4798 CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4799 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4800 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4801 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30C };
4802 static const struct wacom_features wacom_features_0x30C =
4803 { "Wacom ISDv5 30C", .type = WACOM_24HDT, /* Touch */
4804 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30A, .touch_max = 10,
4805 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4806 static const struct wacom_features wacom_features_0x318 =
4807 { "Wacom USB Bamboo PAD", 4095, 4095, /* Touch */
4808 .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
4809 static const struct wacom_features wacom_features_0x319 =
4810 { "Wacom Wireless Bamboo PAD", 4095, 4095, /* Touch */
4811 .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
4812 static const struct wacom_features wacom_features_0x325 =
4813 { "Wacom ISDv5 325", 59552, 33848, 2047, 63,
4814 CINTIQ_COMPANION_2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 11,
4815 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4816 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4817 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x326 };
4818 static const struct wacom_features wacom_features_0x326 = /* Touch */
4819 { "Wacom ISDv5 326", .type = HID_GENERIC, .oVid = USB_VENDOR_ID_WACOM,
4821 static const struct wacom_features wacom_features_0x323 =
4822 { "Wacom Intuos P M", 21600, 13500, 1023, 31,
4823 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4824 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4825 static const struct wacom_features wacom_features_0x331 =
4826 { "Wacom Express Key Remote", .type = REMOTE,
4827 .numbered_buttons = 18, .check_for_hid_type = true,
4828 .hid_type = HID_TYPE_USBNONE };
4829 static const struct wacom_features wacom_features_0x33B =
4830 { "Wacom Intuos S 2", 15200, 9500, 2047, 63,
4831 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4832 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4833 static const struct wacom_features wacom_features_0x33C =
4834 { "Wacom Intuos PT S 2", 15200, 9500, 2047, 63,
4835 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4836 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4837 static const struct wacom_features wacom_features_0x33D =
4838 { "Wacom Intuos P M 2", 21600, 13500, 2047, 63,
4839 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4840 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4841 static const struct wacom_features wacom_features_0x33E =
4842 { "Wacom Intuos PT M 2", 21600, 13500, 2047, 63,
4843 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4844 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4845 static const struct wacom_features wacom_features_0x343 =
4846 { "Wacom DTK1651", 34816, 19759, 1023, 0,
4847 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
4848 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4849 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4850 static const struct wacom_features wacom_features_0x360 =
4851 { "Wacom Intuos Pro M", 44800, 29600, 8191, 63,
4852 INTUOSP2_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 10 };
4853 static const struct wacom_features wacom_features_0x361 =
4854 { "Wacom Intuos Pro L", 62200, 43200, 8191, 63,
4855 INTUOSP2_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 10 };
4856 static const struct wacom_features wacom_features_0x377 =
4857 { "Wacom Intuos BT S", 15200, 9500, 4095, 63,
4858 INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
4859 static const struct wacom_features wacom_features_0x379 =
4860 { "Wacom Intuos BT M", 21600, 13500, 4095, 63,
4861 INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
4862 static const struct wacom_features wacom_features_0x37A =
4863 { "Wacom One by Wacom S", 15200, 9500, 2047, 63,
4864 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4865 static const struct wacom_features wacom_features_0x37B =
4866 { "Wacom One by Wacom M", 21600, 13500, 2047, 63,
4867 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4868 static const struct wacom_features wacom_features_0x393 =
4869 { "Wacom Intuos Pro S", 31920, 19950, 8191, 63,
4870 INTUOSP2S_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7,
4872 static const struct wacom_features wacom_features_0x3c6 =
4873 { "Wacom Intuos BT S", 15200, 9500, 4095, 63,
4874 INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
4875 static const struct wacom_features wacom_features_0x3c8 =
4876 { "Wacom Intuos BT M", 21600, 13500, 4095, 63,
4877 INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
4879 static const struct wacom_features wacom_features_HID_ANY_ID =
4880 { "Wacom HID", .type = HID_GENERIC, .oVid = HID_ANY_ID, .oPid = HID_ANY_ID };
4882 #define USB_DEVICE_WACOM(prod) \
4883 HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4884 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4886 #define BT_DEVICE_WACOM(prod) \
4887 HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4888 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4890 #define I2C_DEVICE_WACOM(prod) \
4891 HID_DEVICE(BUS_I2C, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4892 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4894 #define USB_DEVICE_LENOVO(prod) \
4895 HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
4896 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4898 const struct hid_device_id wacom_ids[] = {
4899 { USB_DEVICE_WACOM(0x00) },
4900 { USB_DEVICE_WACOM(0x03) },
4901 { USB_DEVICE_WACOM(0x10) },
4902 { USB_DEVICE_WACOM(0x11) },
4903 { USB_DEVICE_WACOM(0x12) },
4904 { USB_DEVICE_WACOM(0x13) },
4905 { USB_DEVICE_WACOM(0x14) },
4906 { USB_DEVICE_WACOM(0x15) },
4907 { USB_DEVICE_WACOM(0x16) },
4908 { USB_DEVICE_WACOM(0x17) },
4909 { USB_DEVICE_WACOM(0x18) },
4910 { USB_DEVICE_WACOM(0x19) },
4911 { USB_DEVICE_WACOM(0x20) },
4912 { USB_DEVICE_WACOM(0x21) },
4913 { USB_DEVICE_WACOM(0x22) },
4914 { USB_DEVICE_WACOM(0x23) },
4915 { USB_DEVICE_WACOM(0x24) },
4916 { USB_DEVICE_WACOM(0x26) },
4917 { USB_DEVICE_WACOM(0x27) },
4918 { USB_DEVICE_WACOM(0x28) },
4919 { USB_DEVICE_WACOM(0x29) },
4920 { USB_DEVICE_WACOM(0x2A) },
4921 { USB_DEVICE_WACOM(0x30) },
4922 { USB_DEVICE_WACOM(0x31) },
4923 { USB_DEVICE_WACOM(0x32) },
4924 { USB_DEVICE_WACOM(0x33) },
4925 { USB_DEVICE_WACOM(0x34) },
4926 { USB_DEVICE_WACOM(0x35) },
4927 { USB_DEVICE_WACOM(0x37) },
4928 { USB_DEVICE_WACOM(0x38) },
4929 { USB_DEVICE_WACOM(0x39) },
4930 { USB_DEVICE_WACOM(0x3F) },
4931 { USB_DEVICE_WACOM(0x41) },
4932 { USB_DEVICE_WACOM(0x42) },
4933 { USB_DEVICE_WACOM(0x43) },
4934 { USB_DEVICE_WACOM(0x44) },
4935 { USB_DEVICE_WACOM(0x45) },
4936 { USB_DEVICE_WACOM(0x47) },
4937 { USB_DEVICE_WACOM(0x57) },
4938 { USB_DEVICE_WACOM(0x59) },
4939 { USB_DEVICE_WACOM(0x5B) },
4940 { USB_DEVICE_WACOM(0x5D) },
4941 { USB_DEVICE_WACOM(0x5E) },
4942 { USB_DEVICE_WACOM(0x60) },
4943 { USB_DEVICE_WACOM(0x61) },
4944 { USB_DEVICE_WACOM(0x62) },
4945 { USB_DEVICE_WACOM(0x63) },
4946 { USB_DEVICE_WACOM(0x64) },
4947 { USB_DEVICE_WACOM(0x65) },
4948 { USB_DEVICE_WACOM(0x69) },
4949 { USB_DEVICE_WACOM(0x6A) },
4950 { USB_DEVICE_WACOM(0x6B) },
4951 { BT_DEVICE_WACOM(0x81) },
4952 { USB_DEVICE_WACOM(0x84) },
4953 { USB_DEVICE_WACOM(0x90) },
4954 { USB_DEVICE_WACOM(0x93) },
4955 { USB_DEVICE_WACOM(0x97) },
4956 { USB_DEVICE_WACOM(0x9A) },
4957 { USB_DEVICE_WACOM(0x9F) },
4958 { USB_DEVICE_WACOM(0xB0) },
4959 { USB_DEVICE_WACOM(0xB1) },
4960 { USB_DEVICE_WACOM(0xB2) },
4961 { USB_DEVICE_WACOM(0xB3) },
4962 { USB_DEVICE_WACOM(0xB4) },
4963 { USB_DEVICE_WACOM(0xB5) },
4964 { USB_DEVICE_WACOM(0xB7) },
4965 { USB_DEVICE_WACOM(0xB8) },
4966 { USB_DEVICE_WACOM(0xB9) },
4967 { USB_DEVICE_WACOM(0xBA) },
4968 { USB_DEVICE_WACOM(0xBB) },
4969 { USB_DEVICE_WACOM(0xBC) },
4970 { BT_DEVICE_WACOM(0xBD) },
4971 { USB_DEVICE_WACOM(0xC0) },
4972 { USB_DEVICE_WACOM(0xC2) },
4973 { USB_DEVICE_WACOM(0xC4) },
4974 { USB_DEVICE_WACOM(0xC5) },
4975 { USB_DEVICE_WACOM(0xC6) },
4976 { USB_DEVICE_WACOM(0xC7) },
4977 { USB_DEVICE_WACOM(0xCC) },
4978 { USB_DEVICE_WACOM(0xCE) },
4979 { USB_DEVICE_WACOM(0xD0) },
4980 { USB_DEVICE_WACOM(0xD1) },
4981 { USB_DEVICE_WACOM(0xD2) },
4982 { USB_DEVICE_WACOM(0xD3) },
4983 { USB_DEVICE_WACOM(0xD4) },
4984 { USB_DEVICE_WACOM(0xD5) },
4985 { USB_DEVICE_WACOM(0xD6) },
4986 { USB_DEVICE_WACOM(0xD7) },
4987 { USB_DEVICE_WACOM(0xD8) },
4988 { USB_DEVICE_WACOM(0xDA) },
4989 { USB_DEVICE_WACOM(0xDB) },
4990 { USB_DEVICE_WACOM(0xDD) },
4991 { USB_DEVICE_WACOM(0xDE) },
4992 { USB_DEVICE_WACOM(0xDF) },
4993 { USB_DEVICE_WACOM(0xE2) },
4994 { USB_DEVICE_WACOM(0xE3) },
4995 { USB_DEVICE_WACOM(0xE5) },
4996 { USB_DEVICE_WACOM(0xE6) },
4997 { USB_DEVICE_WACOM(0xEC) },
4998 { USB_DEVICE_WACOM(0xED) },
4999 { USB_DEVICE_WACOM(0xEF) },
5000 { USB_DEVICE_WACOM(0xF0) },
5001 { USB_DEVICE_WACOM(0xF4) },
5002 { USB_DEVICE_WACOM(0xF6) },
5003 { USB_DEVICE_WACOM(0xF8) },
5004 { USB_DEVICE_WACOM(0xFA) },
5005 { USB_DEVICE_WACOM(0xFB) },
5006 { USB_DEVICE_WACOM(0x100) },
5007 { USB_DEVICE_WACOM(0x101) },
5008 { USB_DEVICE_WACOM(0x10D) },
5009 { USB_DEVICE_WACOM(0x10E) },
5010 { USB_DEVICE_WACOM(0x10F) },
5011 { USB_DEVICE_WACOM(0x116) },
5012 { USB_DEVICE_WACOM(0x12C) },
5013 { USB_DEVICE_WACOM(0x300) },
5014 { USB_DEVICE_WACOM(0x301) },
5015 { USB_DEVICE_WACOM(0x302) },
5016 { USB_DEVICE_WACOM(0x303) },
5017 { USB_DEVICE_WACOM(0x304) },
5018 { USB_DEVICE_WACOM(0x307) },
5019 { USB_DEVICE_WACOM(0x309) },
5020 { USB_DEVICE_WACOM(0x30A) },
5021 { USB_DEVICE_WACOM(0x30C) },
5022 { USB_DEVICE_WACOM(0x30E) },
5023 { USB_DEVICE_WACOM(0x314) },
5024 { USB_DEVICE_WACOM(0x315) },
5025 { USB_DEVICE_WACOM(0x317) },
5026 { USB_DEVICE_WACOM(0x318) },
5027 { USB_DEVICE_WACOM(0x319) },
5028 { USB_DEVICE_WACOM(0x323) },
5029 { USB_DEVICE_WACOM(0x325) },
5030 { USB_DEVICE_WACOM(0x326) },
5031 { USB_DEVICE_WACOM(0x32A) },
5032 { USB_DEVICE_WACOM(0x32B) },
5033 { USB_DEVICE_WACOM(0x32C) },
5034 { USB_DEVICE_WACOM(0x32F) },
5035 { USB_DEVICE_WACOM(0x331) },
5036 { USB_DEVICE_WACOM(0x333) },
5037 { USB_DEVICE_WACOM(0x335) },
5038 { USB_DEVICE_WACOM(0x336) },
5039 { USB_DEVICE_WACOM(0x33B) },
5040 { USB_DEVICE_WACOM(0x33C) },
5041 { USB_DEVICE_WACOM(0x33D) },
5042 { USB_DEVICE_WACOM(0x33E) },
5043 { USB_DEVICE_WACOM(0x343) },
5044 { BT_DEVICE_WACOM(0x360) },
5045 { BT_DEVICE_WACOM(0x361) },
5046 { BT_DEVICE_WACOM(0x377) },
5047 { BT_DEVICE_WACOM(0x379) },
5048 { USB_DEVICE_WACOM(0x37A) },
5049 { USB_DEVICE_WACOM(0x37B) },
5050 { BT_DEVICE_WACOM(0x393) },
5051 { BT_DEVICE_WACOM(0x3c6) },
5052 { BT_DEVICE_WACOM(0x3c8) },
5053 { USB_DEVICE_WACOM(0x4001) },
5054 { USB_DEVICE_WACOM(0x4004) },
5055 { USB_DEVICE_WACOM(0x5000) },
5056 { USB_DEVICE_WACOM(0x5002) },
5057 { USB_DEVICE_LENOVO(0x6004) },
5059 { USB_DEVICE_WACOM(HID_ANY_ID) },
5060 { I2C_DEVICE_WACOM(HID_ANY_ID) },
5061 { BT_DEVICE_WACOM(HID_ANY_ID) },
5064 MODULE_DEVICE_TABLE(hid, wacom_ids);