2 * drivers/input/tablet/wacom_wac.c
4 * USB Wacom tablet support - Wacom specific code
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
15 #include "wacom_wac.h"
17 #include <linux/input/mt.h>
19 /* resolution for penabled devices */
20 #define WACOM_PL_RES 20
21 #define WACOM_PENPRTN_RES 40
22 #define WACOM_VOLITO_RES 50
23 #define WACOM_GRAPHIRE_RES 80
24 #define WACOM_INTUOS_RES 100
25 #define WACOM_INTUOS3_RES 200
27 /* Newer Cintiq and DTU have an offset between tablet and screen areas */
28 #define WACOM_DTU_OFFSET 200
29 #define WACOM_CINTIQ_OFFSET 400
32 * Scale factor relating reported contact size to logical contact area.
33 * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo
35 #define WACOM_CONTACT_AREA_SCALE 2607
37 static bool touch_arbitration = 1;
38 module_param(touch_arbitration, bool, 0644);
39 MODULE_PARM_DESC(touch_arbitration, " on (Y) off (N)");
41 static void wacom_report_numbered_buttons(struct input_dev *input_dev,
42 int button_count, int mask);
44 static int wacom_numbered_button_to_key(int n);
46 static void wacom_update_led(struct wacom *wacom, int button_count, int mask,
49 * Percent of battery capacity for Graphire.
50 * 8th value means AC online and show 100% capacity.
52 static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
55 * Percent of battery capacity for Intuos4 WL, AC has a separate bit.
57 static unsigned short batcap_i4[8] = { 1, 15, 30, 45, 60, 70, 85, 100 };
59 static void __wacom_notify_battery(struct wacom_battery *battery,
60 int bat_capacity, bool bat_charging,
61 bool bat_connected, bool ps_connected)
63 bool changed = battery->battery_capacity != bat_capacity ||
64 battery->bat_charging != bat_charging ||
65 battery->bat_connected != bat_connected ||
66 battery->ps_connected != ps_connected;
69 battery->battery_capacity = bat_capacity;
70 battery->bat_charging = bat_charging;
71 battery->bat_connected = bat_connected;
72 battery->ps_connected = ps_connected;
75 power_supply_changed(battery->battery);
79 static void wacom_notify_battery(struct wacom_wac *wacom_wac,
80 int bat_capacity, bool bat_charging, bool bat_connected,
83 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
85 __wacom_notify_battery(&wacom->battery, bat_capacity, bat_charging,
86 bat_connected, ps_connected);
89 static int wacom_penpartner_irq(struct wacom_wac *wacom)
91 unsigned char *data = wacom->data;
92 struct input_dev *input = wacom->pen_input;
97 wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
98 wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID;
99 input_report_key(input, wacom->tool[0], 1);
100 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
101 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
102 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
103 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
104 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127));
105 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
107 input_report_key(input, wacom->tool[0], 0);
108 input_report_abs(input, ABS_MISC, 0); /* report tool id */
109 input_report_abs(input, ABS_PRESSURE, -1);
110 input_report_key(input, BTN_TOUCH, 0);
115 input_report_key(input, BTN_TOOL_PEN, 1);
116 input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
117 input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
118 input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
119 input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
120 input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
121 input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
125 dev_dbg(input->dev.parent,
126 "%s: received unknown report #%d\n", __func__, data[0]);
133 static int wacom_pl_irq(struct wacom_wac *wacom)
135 struct wacom_features *features = &wacom->features;
136 unsigned char *data = wacom->data;
137 struct input_dev *input = wacom->pen_input;
140 if (data[0] != WACOM_REPORT_PENABLED) {
141 dev_dbg(input->dev.parent,
142 "%s: received unknown report #%d\n", __func__, data[0]);
146 prox = data[1] & 0x40;
149 if ((data[0] & 0x10) || (data[4] & 0x20)) {
150 wacom->tool[0] = BTN_TOOL_RUBBER;
151 wacom->id[0] = ERASER_DEVICE_ID;
154 wacom->tool[0] = BTN_TOOL_PEN;
155 wacom->id[0] = STYLUS_DEVICE_ID;
159 /* If the eraser is in prox, STYLUS2 is always set. If we
160 * mis-detected the type and notice that STYLUS2 isn't set
161 * then force the eraser out of prox and let the pen in.
163 if (wacom->tool[0] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
164 input_report_key(input, BTN_TOOL_RUBBER, 0);
165 input_report_abs(input, ABS_MISC, 0);
167 wacom->tool[0] = BTN_TOOL_PEN;
168 wacom->id[0] = STYLUS_DEVICE_ID;
171 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
172 if (features->pressure_max > 255)
173 pressure = (pressure << 1) | ((data[4] >> 6) & 1);
174 pressure += (features->pressure_max + 1) / 2;
176 input_report_abs(input, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
177 input_report_abs(input, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
178 input_report_abs(input, ABS_PRESSURE, pressure);
180 input_report_key(input, BTN_TOUCH, data[4] & 0x08);
181 input_report_key(input, BTN_STYLUS, data[4] & 0x10);
182 /* Only allow the stylus2 button to be reported for the pen tool. */
183 input_report_key(input, BTN_STYLUS2, (wacom->tool[0] == BTN_TOOL_PEN) && (data[4] & 0x20));
187 input_report_key(input, wacom->tool[0], prox);
188 input_report_abs(input, ABS_MISC, wacom->id[0]);
192 static int wacom_ptu_irq(struct wacom_wac *wacom)
194 unsigned char *data = wacom->data;
195 struct input_dev *input = wacom->pen_input;
197 if (data[0] != WACOM_REPORT_PENABLED) {
198 dev_dbg(input->dev.parent,
199 "%s: received unknown report #%d\n", __func__, data[0]);
203 if (data[1] & 0x04) {
204 input_report_key(input, BTN_TOOL_RUBBER, data[1] & 0x20);
205 input_report_key(input, BTN_TOUCH, data[1] & 0x08);
206 wacom->id[0] = ERASER_DEVICE_ID;
208 input_report_key(input, BTN_TOOL_PEN, data[1] & 0x20);
209 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
210 wacom->id[0] = STYLUS_DEVICE_ID;
212 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
213 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
214 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
215 input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6]));
216 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
217 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
221 static int wacom_dtu_irq(struct wacom_wac *wacom)
223 unsigned char *data = wacom->data;
224 struct input_dev *input = wacom->pen_input;
225 int prox = data[1] & 0x20;
227 dev_dbg(input->dev.parent,
228 "%s: received report #%d", __func__, data[0]);
231 /* Going into proximity select tool */
232 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
233 if (wacom->tool[0] == BTN_TOOL_PEN)
234 wacom->id[0] = STYLUS_DEVICE_ID;
236 wacom->id[0] = ERASER_DEVICE_ID;
238 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
239 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
240 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
241 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
242 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x01) << 8) | data[6]);
243 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
244 if (!prox) /* out-prox */
246 input_report_key(input, wacom->tool[0], prox);
247 input_report_abs(input, ABS_MISC, wacom->id[0]);
251 static int wacom_dtus_irq(struct wacom_wac *wacom)
253 char *data = wacom->data;
254 struct input_dev *input = wacom->pen_input;
255 unsigned short prox, pressure = 0;
257 if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) {
258 dev_dbg(input->dev.parent,
259 "%s: received unknown report #%d", __func__, data[0]);
261 } else if (data[0] == WACOM_REPORT_DTUSPAD) {
262 input = wacom->pad_input;
263 input_report_key(input, BTN_0, (data[1] & 0x01));
264 input_report_key(input, BTN_1, (data[1] & 0x02));
265 input_report_key(input, BTN_2, (data[1] & 0x04));
266 input_report_key(input, BTN_3, (data[1] & 0x08));
267 input_report_abs(input, ABS_MISC,
268 data[1] & 0x0f ? PAD_DEVICE_ID : 0);
271 prox = data[1] & 0x80;
273 switch ((data[1] >> 3) & 3) {
275 wacom->tool[0] = BTN_TOOL_RUBBER;
276 wacom->id[0] = ERASER_DEVICE_ID;
280 wacom->tool[0] = BTN_TOOL_PEN;
281 wacom->id[0] = STYLUS_DEVICE_ID;
286 input_report_key(input, BTN_STYLUS, data[1] & 0x20);
287 input_report_key(input, BTN_STYLUS2, data[1] & 0x40);
288 input_report_abs(input, ABS_X, get_unaligned_be16(&data[3]));
289 input_report_abs(input, ABS_Y, get_unaligned_be16(&data[5]));
290 pressure = ((data[1] & 0x03) << 8) | (data[2] & 0xff);
291 input_report_abs(input, ABS_PRESSURE, pressure);
292 input_report_key(input, BTN_TOUCH, pressure > 10);
294 if (!prox) /* out-prox */
296 input_report_key(input, wacom->tool[0], prox);
297 input_report_abs(input, ABS_MISC, wacom->id[0]);
302 static int wacom_graphire_irq(struct wacom_wac *wacom)
304 struct wacom_features *features = &wacom->features;
305 unsigned char *data = wacom->data;
306 struct input_dev *input = wacom->pen_input;
307 struct input_dev *pad_input = wacom->pad_input;
308 int battery_capacity, ps_connected;
313 if (features->type == GRAPHIRE_BT) {
314 if (data[0] != WACOM_REPORT_PENABLED_BT) {
315 dev_dbg(input->dev.parent,
316 "%s: received unknown report #%d\n", __func__,
320 } else if (data[0] != WACOM_REPORT_PENABLED) {
321 dev_dbg(input->dev.parent,
322 "%s: received unknown report #%d\n", __func__, data[0]);
326 prox = data[1] & 0x80;
327 if (prox || wacom->id[0]) {
329 switch ((data[1] >> 5) & 3) {
332 wacom->tool[0] = BTN_TOOL_PEN;
333 wacom->id[0] = STYLUS_DEVICE_ID;
337 wacom->tool[0] = BTN_TOOL_RUBBER;
338 wacom->id[0] = ERASER_DEVICE_ID;
341 case 2: /* Mouse with wheel */
342 input_report_key(input, BTN_MIDDLE, data[1] & 0x04);
345 case 3: /* Mouse without wheel */
346 wacom->tool[0] = BTN_TOOL_MOUSE;
347 wacom->id[0] = CURSOR_DEVICE_ID;
351 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
352 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
353 if (wacom->tool[0] != BTN_TOOL_MOUSE) {
354 if (features->type == GRAPHIRE_BT)
355 input_report_abs(input, ABS_PRESSURE, data[6] |
356 (((__u16) (data[1] & 0x08)) << 5));
358 input_report_abs(input, ABS_PRESSURE, data[6] |
359 ((data[7] & 0x03) << 8));
360 input_report_key(input, BTN_TOUCH, data[1] & 0x01);
361 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
362 input_report_key(input, BTN_STYLUS2, data[1] & 0x04);
364 input_report_key(input, BTN_LEFT, data[1] & 0x01);
365 input_report_key(input, BTN_RIGHT, data[1] & 0x02);
366 if (features->type == WACOM_G4 ||
367 features->type == WACOM_MO) {
368 input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f);
369 rw = (data[7] & 0x04) - (data[7] & 0x03);
370 } else if (features->type == GRAPHIRE_BT) {
371 /* Compute distance between mouse and tablet */
372 rw = 44 - (data[6] >> 2);
373 rw = clamp_val(rw, 0, 31);
374 input_report_abs(input, ABS_DISTANCE, rw);
375 if (((data[1] >> 5) & 3) == 2) {
376 /* Mouse with wheel */
377 input_report_key(input, BTN_MIDDLE,
379 rw = (data[6] & 0x01) ? -1 :
380 (data[6] & 0x02) ? 1 : 0;
385 input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f);
386 rw = -(signed char)data[6];
388 input_report_rel(input, REL_WHEEL, rw);
393 input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
394 input_report_key(input, wacom->tool[0], prox);
395 input_sync(input); /* sync last event */
399 switch (features->type) {
401 prox = data[7] & 0xf8;
402 if (prox || wacom->id[1]) {
403 wacom->id[1] = PAD_DEVICE_ID;
404 input_report_key(pad_input, BTN_BACK, (data[7] & 0x40));
405 input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x80));
406 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
407 input_report_rel(pad_input, REL_WHEEL, rw);
410 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
416 prox = (data[7] & 0xf8) || data[8];
417 if (prox || wacom->id[1]) {
418 wacom->id[1] = PAD_DEVICE_ID;
419 input_report_key(pad_input, BTN_BACK, (data[7] & 0x08));
420 input_report_key(pad_input, BTN_LEFT, (data[7] & 0x20));
421 input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x10));
422 input_report_key(pad_input, BTN_RIGHT, (data[7] & 0x40));
423 input_report_abs(pad_input, ABS_WHEEL, (data[8] & 0x7f));
426 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
431 prox = data[7] & 0x03;
432 if (prox || wacom->id[1]) {
433 wacom->id[1] = PAD_DEVICE_ID;
434 input_report_key(pad_input, BTN_0, (data[7] & 0x02));
435 input_report_key(pad_input, BTN_1, (data[7] & 0x01));
438 input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
444 /* Store current battery capacity and power supply state */
445 if (features->type == GRAPHIRE_BT) {
446 rw = (data[7] >> 2 & 0x07);
447 battery_capacity = batcap_gr[rw];
448 ps_connected = rw == 7;
449 wacom_notify_battery(wacom, battery_capacity, ps_connected,
456 static void wacom_intuos_schedule_prox_event(struct wacom_wac *wacom_wac)
458 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
459 struct wacom_features *features = &wacom_wac->features;
460 struct hid_report *r;
461 struct hid_report_enum *re;
463 re = &(wacom->hdev->report_enum[HID_FEATURE_REPORT]);
464 if (features->type == INTUOSHT2)
465 r = re->report_id_hash[WACOM_REPORT_INTUOSHT2_ID];
467 r = re->report_id_hash[WACOM_REPORT_INTUOS_ID1];
469 hid_hw_request(wacom->hdev, r, HID_REQ_GET_REPORT);
473 static int wacom_intuos_pad(struct wacom_wac *wacom)
475 struct wacom_features *features = &wacom->features;
476 unsigned char *data = wacom->data;
477 struct input_dev *input = wacom->pad_input;
479 int buttons = 0, nbuttons = features->numbered_buttons;
480 int keys = 0, nkeys = 0;
481 int ring1 = 0, ring2 = 0;
482 int strip1 = 0, strip2 = 0;
485 /* pad packets. Works as a second tool and is always in prox */
486 if (!(data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD ||
487 data[0] == WACOM_REPORT_CINTIQPAD))
490 if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
491 buttons = (data[3] << 1) | (data[2] & 0x01);
493 } else if (features->type == DTK) {
495 } else if (features->type == WACOM_13HD) {
496 buttons = (data[4] << 1) | (data[3] & 0x01);
497 } else if (features->type == WACOM_24HD) {
498 buttons = (data[8] << 8) | data[6];
503 * Three "buttons" are available on the 24HD which are
504 * physically implemented as a touchstrip. Each button
505 * is approximately 3 bits wide with a 2 bit spacing.
506 * The raw touchstrip bits are stored at:
507 * ((data[3] & 0x1f) << 8) | data[4])
510 keys = ((data[3] & 0x1C) ? 1<<2 : 0) |
511 ((data[4] & 0xE0) ? 1<<1 : 0) |
512 ((data[4] & 0x07) ? 1<<0 : 0);
513 } else if (features->type == WACOM_27QHD) {
515 keys = data[2] & 0x07;
517 input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[4]));
518 input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[6]));
519 input_report_abs(input, ABS_Z, be16_to_cpup((__be16 *)&data[8]));
520 } else if (features->type == CINTIQ_HYBRID) {
522 * Do not send hardware buttons under Android. They
523 * are already sent to the system through GPIO (and
524 * have different meaning).
526 * d-pad right -> data[4] & 0x10
527 * d-pad up -> data[4] & 0x20
528 * d-pad left -> data[4] & 0x40
529 * d-pad down -> data[4] & 0x80
530 * d-pad center -> data[3] & 0x01
532 buttons = (data[4] << 1) | (data[3] & 0x01);
533 } else if (features->type == CINTIQ_COMPANION_2) {
534 /* d-pad right -> data[4] & 0x10
535 * d-pad up -> data[4] & 0x20
536 * d-pad left -> data[4] & 0x40
537 * d-pad down -> data[4] & 0x80
538 * d-pad center -> data[3] & 0x01
540 buttons = ((data[2] >> 4) << 7) |
541 ((data[1] & 0x04) << 6) |
542 ((data[2] & 0x0F) << 2) |
544 } else if (features->type >= INTUOS5S && features->type <= INTUOSPL) {
546 * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in
547 * addition to the mechanical switch. Switch data is
548 * stored in data[4], capacitive data in data[5].
550 * Touch ring mode switch (data[3]) has no capacitive sensor
552 buttons = (data[4] << 1) | (data[3] & 0x01);
555 if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) {
556 buttons = (data[8] << 10) | ((data[7] & 0x01) << 9) |
557 (data[6] << 1) | (data[5] & 0x01);
559 if (features->type == WACOM_22HD) {
561 keys = data[9] & 0x07;
564 buttons = ((data[6] & 0x10) << 10) |
565 ((data[5] & 0x10) << 9) |
566 ((data[6] & 0x0F) << 4) |
569 strip1 = ((data[1] & 0x1f) << 8) | data[2];
570 strip2 = ((data[3] & 0x1f) << 8) | data[4];
573 prox = (buttons & ~(~0 << nbuttons)) | (keys & ~(~0 << nkeys)) |
574 (ring1 & 0x80) | (ring2 & 0x80) | strip1 | strip2;
576 wacom_report_numbered_buttons(input, nbuttons, buttons);
578 for (i = 0; i < nkeys; i++)
579 input_report_key(input, KEY_PROG1 + i, keys & (1 << i));
581 input_report_abs(input, ABS_RX, strip1);
582 input_report_abs(input, ABS_RY, strip2);
584 input_report_abs(input, ABS_WHEEL, (ring1 & 0x80) ? (ring1 & 0x7f) : 0);
585 input_report_abs(input, ABS_THROTTLE, (ring2 & 0x80) ? (ring2 & 0x7f) : 0);
587 input_report_key(input, wacom->tool[1], prox ? 1 : 0);
588 input_report_abs(input, ABS_MISC, prox ? PAD_DEVICE_ID : 0);
590 input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff);
595 static int wacom_intuos_id_mangle(int tool_id)
597 return (tool_id & ~0xFFF) << 4 | (tool_id & 0xFFF);
600 static int wacom_intuos_get_tool_type(int tool_id)
605 case 0x812: /* Inking pen */
606 case 0x801: /* Intuos3 Inking pen */
607 case 0x12802: /* Intuos4/5 Inking Pen */
609 tool_type = BTN_TOOL_PENCIL;
612 case 0x822: /* Pen */
615 case 0x823: /* Intuos3 Grip Pen */
616 case 0x813: /* Intuos3 Classic Pen */
617 case 0x885: /* Intuos3 Marker Pen */
618 case 0x802: /* Intuos4/5 13HD/24HD General Pen */
619 case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
620 case 0x8e2: /* IntuosHT2 pen */
622 case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */
623 case 0x14802: /* Intuos4/5 13HD/24HD Classic Pen */
624 case 0x16802: /* Cintiq 13HD Pro Pen */
625 case 0x18802: /* DTH2242 Pen */
626 case 0x10802: /* Intuos4/5 13HD/24HD General Pen */
627 tool_type = BTN_TOOL_PEN;
630 case 0x832: /* Stroke pen */
632 tool_type = BTN_TOOL_BRUSH;
635 case 0x007: /* Mouse 4D and 2D */
638 case 0x017: /* Intuos3 2D Mouse */
639 case 0x806: /* Intuos4 Mouse */
640 tool_type = BTN_TOOL_MOUSE;
643 case 0x096: /* Lens cursor */
644 case 0x097: /* Intuos3 Lens cursor */
645 case 0x006: /* Intuos4 Lens cursor */
646 tool_type = BTN_TOOL_LENS;
649 case 0x82a: /* Eraser */
655 case 0x82b: /* Intuos3 Grip Pen Eraser */
656 case 0x81b: /* Intuos3 Classic Pen Eraser */
657 case 0x91b: /* Intuos3 Airbrush Eraser */
658 case 0x80c: /* Intuos4/5 13HD/24HD Marker Pen Eraser */
659 case 0x80a: /* Intuos4/5 13HD/24HD General Pen Eraser */
660 case 0x90a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
661 case 0x1480a: /* Intuos4/5 13HD/24HD Classic Pen Eraser */
662 case 0x1090a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
663 case 0x1080c: /* Intuos4/5 13HD/24HD Art Pen Eraser */
664 case 0x1680a: /* Cintiq 13HD Pro Pen Eraser */
665 case 0x1880a: /* DTH2242 Eraser */
666 case 0x1080a: /* Intuos4/5 13HD/24HD General Pen Eraser */
667 tool_type = BTN_TOOL_RUBBER;
673 case 0x913: /* Intuos3 Airbrush */
674 case 0x902: /* Intuos4/5 13HD/24HD Airbrush */
675 case 0x10902: /* Intuos4/5 13HD/24HD Airbrush */
676 tool_type = BTN_TOOL_AIRBRUSH;
679 default: /* Unknown tool */
680 tool_type = BTN_TOOL_PEN;
686 static int wacom_intuos_inout(struct wacom_wac *wacom)
688 struct wacom_features *features = &wacom->features;
689 unsigned char *data = wacom->data;
690 struct input_dev *input = wacom->pen_input;
691 int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
693 if (!(((data[1] & 0xfc) == 0xc0) || /* in prox */
694 ((data[1] & 0xfe) == 0x20) || /* in range */
695 ((data[1] & 0xfe) == 0x80))) /* out prox */
699 if ((data[1] & 0xfc) == 0xc0) {
700 /* serial number of the tool */
701 wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
702 (data[4] << 20) + (data[5] << 12) +
703 (data[6] << 4) + (data[7] >> 4);
705 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) |
706 ((data[7] & 0x0f) << 16) | ((data[8] & 0xf0) << 8);
708 wacom->tool[idx] = wacom_intuos_get_tool_type(wacom->id[idx]);
710 wacom->shared->stylus_in_proximity = true;
715 if ((data[1] & 0xfe) == 0x20) {
716 if (features->type != INTUOSHT2)
717 wacom->shared->stylus_in_proximity = true;
719 /* in Range while exiting */
720 if (wacom->reporting_data) {
721 input_report_key(input, BTN_TOUCH, 0);
722 input_report_abs(input, ABS_PRESSURE, 0);
723 input_report_abs(input, ABS_DISTANCE, wacom->features.distance_max);
730 if ((data[1] & 0xfe) == 0x80) {
731 wacom->shared->stylus_in_proximity = false;
732 wacom->reporting_data = false;
734 /* don't report exit if we don't know the ID */
739 * Reset all states otherwise we lose the initial states
740 * when in-prox next time
742 input_report_abs(input, ABS_X, 0);
743 input_report_abs(input, ABS_Y, 0);
744 input_report_abs(input, ABS_DISTANCE, 0);
745 input_report_abs(input, ABS_TILT_X, 0);
746 input_report_abs(input, ABS_TILT_Y, 0);
747 if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
748 input_report_key(input, BTN_LEFT, 0);
749 input_report_key(input, BTN_MIDDLE, 0);
750 input_report_key(input, BTN_RIGHT, 0);
751 input_report_key(input, BTN_SIDE, 0);
752 input_report_key(input, BTN_EXTRA, 0);
753 input_report_abs(input, ABS_THROTTLE, 0);
754 input_report_abs(input, ABS_RZ, 0);
756 input_report_abs(input, ABS_PRESSURE, 0);
757 input_report_key(input, BTN_STYLUS, 0);
758 input_report_key(input, BTN_STYLUS2, 0);
759 input_report_key(input, BTN_TOUCH, 0);
760 input_report_abs(input, ABS_WHEEL, 0);
761 if (features->type >= INTUOS3S)
762 input_report_abs(input, ABS_Z, 0);
764 input_report_key(input, wacom->tool[idx], 0);
765 input_report_abs(input, ABS_MISC, 0); /* reset tool id */
766 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
774 static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len)
776 unsigned char *data = wacom_wac->data;
777 struct input_dev *input;
778 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
779 struct wacom_remote *remote = wacom->remote;
780 int bat_charging, bat_percent, touch_ring_mode;
785 if (data[0] != WACOM_REPORT_REMOTE) {
786 hid_dbg(wacom->hdev, "%s: received unknown report #%d",
791 serial = data[3] + (data[4] << 8) + (data[5] << 16);
792 wacom_wac->id[0] = PAD_DEVICE_ID;
794 spin_lock_irqsave(&remote->remote_lock, flags);
796 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
797 if (remote->remotes[i].serial == serial) {
803 if (index < 0 || !remote->remotes[index].registered)
806 input = remote->remotes[index].input;
808 input_report_key(input, BTN_0, (data[9] & 0x01));
809 input_report_key(input, BTN_1, (data[9] & 0x02));
810 input_report_key(input, BTN_2, (data[9] & 0x04));
811 input_report_key(input, BTN_3, (data[9] & 0x08));
812 input_report_key(input, BTN_4, (data[9] & 0x10));
813 input_report_key(input, BTN_5, (data[9] & 0x20));
814 input_report_key(input, BTN_6, (data[9] & 0x40));
815 input_report_key(input, BTN_7, (data[9] & 0x80));
817 input_report_key(input, BTN_8, (data[10] & 0x01));
818 input_report_key(input, BTN_9, (data[10] & 0x02));
819 input_report_key(input, BTN_A, (data[10] & 0x04));
820 input_report_key(input, BTN_B, (data[10] & 0x08));
821 input_report_key(input, BTN_C, (data[10] & 0x10));
822 input_report_key(input, BTN_X, (data[10] & 0x20));
823 input_report_key(input, BTN_Y, (data[10] & 0x40));
824 input_report_key(input, BTN_Z, (data[10] & 0x80));
826 input_report_key(input, BTN_BASE, (data[11] & 0x01));
827 input_report_key(input, BTN_BASE2, (data[11] & 0x02));
830 input_report_abs(input, ABS_WHEEL, (data[12] & 0x7f));
832 input_report_abs(input, ABS_WHEEL, 0);
834 bat_percent = data[7] & 0x7f;
835 bat_charging = !!(data[7] & 0x80);
837 if (data[9] | data[10] | (data[11] & 0x03) | data[12])
838 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
840 input_report_abs(input, ABS_MISC, 0);
842 input_event(input, EV_MSC, MSC_SERIAL, serial);
846 /*Which mode select (LED light) is currently on?*/
847 touch_ring_mode = (data[11] & 0xC0) >> 6;
849 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
850 if (remote->remotes[i].serial == serial)
851 wacom->led.groups[i].select = touch_ring_mode;
854 __wacom_notify_battery(&remote->remotes[index].battery, bat_percent,
855 bat_charging, 1, bat_charging);
858 spin_unlock_irqrestore(&remote->remote_lock, flags);
862 static void wacom_remote_status_irq(struct wacom_wac *wacom_wac, size_t len)
864 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
865 unsigned char *data = wacom_wac->data;
866 struct wacom_remote *remote = wacom->remote;
867 struct wacom_remote_data remote_data;
871 if (data[0] != WACOM_REPORT_DEVICE_LIST)
874 memset(&remote_data, 0, sizeof(struct wacom_remote_data));
876 for (i = 0; i < WACOM_MAX_REMOTES; i++) {
878 int serial = (data[j+6] << 16) + (data[j+5] << 8) + data[j+4];
879 bool connected = data[j+2];
881 remote_data.remote[i].serial = serial;
882 remote_data.remote[i].connected = connected;
885 spin_lock_irqsave(&remote->remote_lock, flags);
887 ret = kfifo_in(&remote->remote_fifo, &remote_data, sizeof(remote_data));
888 if (ret != sizeof(remote_data)) {
889 spin_unlock_irqrestore(&remote->remote_lock, flags);
890 hid_err(wacom->hdev, "Can't queue Remote status event.\n");
894 spin_unlock_irqrestore(&remote->remote_lock, flags);
896 wacom_schedule_work(wacom_wac, WACOM_WORKER_REMOTE);
899 static inline bool report_touch_events(struct wacom_wac *wacom)
901 return (touch_arbitration ? !wacom->shared->stylus_in_proximity : 1);
904 static inline bool delay_pen_events(struct wacom_wac *wacom)
906 return (wacom->shared->touch_down && touch_arbitration);
909 static int wacom_intuos_general(struct wacom_wac *wacom)
911 struct wacom_features *features = &wacom->features;
912 unsigned char *data = wacom->data;
913 struct input_dev *input = wacom->pen_input;
914 int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
915 unsigned char type = (data[1] >> 1) & 0x0F;
916 unsigned int x, y, distance, t;
918 if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_CINTIQ &&
919 data[0] != WACOM_REPORT_INTUOS_PEN)
922 if (delay_pen_events(wacom))
925 /* don't report events if we don't know the tool ID */
926 if (!wacom->id[idx]) {
927 /* but reschedule a read of the current tool */
928 wacom_intuos_schedule_prox_event(wacom);
933 * don't report events for invalid data
935 /* older I4 styli don't work with new Cintiqs */
936 if ((!((wacom->id[idx] >> 16) & 0x01) &&
937 (features->type == WACOM_21UX2)) ||
938 /* Only large Intuos support Lense Cursor */
939 (wacom->tool[idx] == BTN_TOOL_LENS &&
940 (features->type == INTUOS3 ||
941 features->type == INTUOS3S ||
942 features->type == INTUOS4 ||
943 features->type == INTUOS4S ||
944 features->type == INTUOS5 ||
945 features->type == INTUOS5S ||
946 features->type == INTUOSPM ||
947 features->type == INTUOSPS)) ||
948 /* Cintiq doesn't send data when RDY bit isn't set */
949 (features->type == CINTIQ && !(data[1] & 0x40)))
952 x = (be16_to_cpup((__be16 *)&data[2]) << 1) | ((data[9] >> 1) & 1);
953 y = (be16_to_cpup((__be16 *)&data[4]) << 1) | (data[9] & 1);
954 distance = data[9] >> 2;
955 if (features->type < INTUOS3S) {
960 input_report_abs(input, ABS_X, x);
961 input_report_abs(input, ABS_Y, y);
962 input_report_abs(input, ABS_DISTANCE, distance);
969 /* general pen packet */
970 t = (data[6] << 3) | ((data[7] & 0xC0) >> 5) | (data[1] & 1);
971 if (features->pressure_max < 2047)
973 input_report_abs(input, ABS_PRESSURE, t);
974 if (features->type != INTUOSHT2) {
975 input_report_abs(input, ABS_TILT_X,
976 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
977 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
979 input_report_key(input, BTN_STYLUS, data[1] & 2);
980 input_report_key(input, BTN_STYLUS2, data[1] & 4);
981 input_report_key(input, BTN_TOUCH, t > 10);
985 /* airbrush second packet */
986 input_report_abs(input, ABS_WHEEL,
987 (data[6] << 2) | ((data[7] >> 6) & 3));
988 input_report_abs(input, ABS_TILT_X,
989 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
990 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
994 /* Rotation packet */
995 if (features->type >= INTUOS3S) {
996 /* I3 marker pen rotation */
997 t = (data[6] << 3) | ((data[7] >> 5) & 7);
998 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
999 ((t-1) / 2 + 450)) : (450 - t / 2) ;
1000 input_report_abs(input, ABS_Z, t);
1002 /* 4D mouse 2nd packet */
1003 t = (data[6] << 3) | ((data[7] >> 5) & 7);
1004 input_report_abs(input, ABS_RZ, (data[7] & 0x20) ?
1005 ((t - 1) / 2) : -t / 2);
1010 /* 4D mouse 1st packet */
1011 input_report_key(input, BTN_LEFT, data[8] & 0x01);
1012 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
1013 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
1015 input_report_key(input, BTN_SIDE, data[8] & 0x20);
1016 input_report_key(input, BTN_EXTRA, data[8] & 0x10);
1017 t = (data[6] << 2) | ((data[7] >> 6) & 3);
1018 input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
1023 input_report_key(input, BTN_LEFT, data[6] & 0x01);
1024 input_report_key(input, BTN_MIDDLE, data[6] & 0x02);
1025 input_report_key(input, BTN_RIGHT, data[6] & 0x04);
1026 input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7)
1027 - ((data[7] & 0x40) >> 6));
1028 input_report_key(input, BTN_SIDE, data[6] & 0x08);
1029 input_report_key(input, BTN_EXTRA, data[6] & 0x10);
1031 input_report_abs(input, ABS_TILT_X,
1032 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
1033 input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
1037 if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
1038 /* 2D mouse packet */
1039 input_report_key(input, BTN_LEFT, data[8] & 0x04);
1040 input_report_key(input, BTN_MIDDLE, data[8] & 0x08);
1041 input_report_key(input, BTN_RIGHT, data[8] & 0x10);
1042 input_report_rel(input, REL_WHEEL, (data[8] & 0x01)
1043 - ((data[8] & 0x02) >> 1));
1045 /* I3 2D mouse side buttons */
1046 if (features->type >= INTUOS3S && features->type <= INTUOS3L) {
1047 input_report_key(input, BTN_SIDE, data[8] & 0x40);
1048 input_report_key(input, BTN_EXTRA, data[8] & 0x20);
1051 else if (wacom->tool[idx] == BTN_TOOL_LENS) {
1052 /* Lens cursor packets */
1053 input_report_key(input, BTN_LEFT, data[8] & 0x01);
1054 input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
1055 input_report_key(input, BTN_RIGHT, data[8] & 0x04);
1056 input_report_key(input, BTN_SIDE, data[8] & 0x10);
1057 input_report_key(input, BTN_EXTRA, data[8] & 0x08);
1072 input_report_abs(input, ABS_MISC,
1073 wacom_intuos_id_mangle(wacom->id[idx])); /* report tool id */
1074 input_report_key(input, wacom->tool[idx], 1);
1075 input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
1076 wacom->reporting_data = true;
1080 static int wacom_intuos_irq(struct wacom_wac *wacom)
1082 unsigned char *data = wacom->data;
1083 struct input_dev *input = wacom->pen_input;
1086 if (data[0] != WACOM_REPORT_PENABLED &&
1087 data[0] != WACOM_REPORT_INTUOS_ID1 &&
1088 data[0] != WACOM_REPORT_INTUOS_ID2 &&
1089 data[0] != WACOM_REPORT_INTUOSPAD &&
1090 data[0] != WACOM_REPORT_INTUOS_PEN &&
1091 data[0] != WACOM_REPORT_CINTIQ &&
1092 data[0] != WACOM_REPORT_CINTIQPAD &&
1093 data[0] != WACOM_REPORT_INTUOS5PAD) {
1094 dev_dbg(input->dev.parent,
1095 "%s: received unknown report #%d\n", __func__, data[0]);
1099 /* process pad events */
1100 result = wacom_intuos_pad(wacom);
1104 /* process in/out prox events */
1105 result = wacom_intuos_inout(wacom);
1109 /* process general packets */
1110 result = wacom_intuos_general(wacom);
1117 static int int_dist(int x1, int y1, int x2, int y2)
1122 return int_sqrt(x*x + y*y);
1125 static void wacom_intuos_bt_process_data(struct wacom_wac *wacom,
1126 unsigned char *data)
1128 memcpy(wacom->data, data, 10);
1129 wacom_intuos_irq(wacom);
1131 input_sync(wacom->pen_input);
1132 if (wacom->pad_input)
1133 input_sync(wacom->pad_input);
1136 static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
1138 unsigned char data[WACOM_PKGLEN_MAX];
1140 unsigned power_raw, battery_capacity, bat_charging, ps_connected;
1142 memcpy(data, wacom->data, len);
1146 wacom_intuos_bt_process_data(wacom, data + i);
1150 wacom_intuos_bt_process_data(wacom, data + i);
1152 wacom_intuos_bt_process_data(wacom, data + i);
1154 power_raw = data[i];
1155 bat_charging = (power_raw & 0x08) ? 1 : 0;
1156 ps_connected = (power_raw & 0x10) ? 1 : 0;
1157 battery_capacity = batcap_i4[power_raw & 0x07];
1158 wacom_notify_battery(wacom, battery_capacity, bat_charging,
1159 battery_capacity || bat_charging,
1163 dev_dbg(wacom->pen_input->dev.parent,
1164 "Unknown report: %d,%d size:%zu\n",
1165 data[0], data[1], len);
1171 static int wacom_wac_finger_count_touches(struct wacom_wac *wacom)
1173 struct input_dev *input = wacom->touch_input;
1174 unsigned touch_max = wacom->features.touch_max;
1182 return test_bit(BTN_TOUCH, input->key) &&
1183 report_touch_events(wacom);
1185 for (i = 0; i < input->mt->num_slots; i++) {
1186 struct input_mt_slot *ps = &input->mt->slots[i];
1187 int id = input_mt_get_value(ps, ABS_MT_TRACKING_ID);
1195 static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
1197 const int pen_frame_len = 14;
1198 const int pen_frames = 7;
1200 struct input_dev *pen_input = wacom->pen_input;
1201 unsigned char *data = wacom->data;
1204 wacom->serial[0] = get_unaligned_le64(&data[99]);
1205 wacom->id[0] = get_unaligned_le16(&data[107]);
1206 if (wacom->serial[0] >> 52 == 1) {
1207 /* Add back in missing bits of ID for non-USI pens */
1208 wacom->id[0] |= (wacom->serial[0] >> 32) & 0xFFFFF;
1210 wacom->tool[0] = wacom_intuos_get_tool_type(wacom_intuos_id_mangle(wacom->id[0]));
1212 for (i = 0; i < pen_frames; i++) {
1213 unsigned char *frame = &data[i*pen_frame_len + 1];
1215 if (!(frame[0] & 0x80))
1218 input_report_abs(pen_input, ABS_X, get_unaligned_le16(&frame[1]));
1219 input_report_abs(pen_input, ABS_Y, get_unaligned_le16(&frame[3]));
1220 input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5]));
1221 input_report_abs(pen_input, ABS_TILT_X, frame[7]);
1222 input_report_abs(pen_input, ABS_TILT_Y, frame[8]);
1223 input_report_abs(pen_input, ABS_Z, get_unaligned_le16(&frame[9]));
1224 input_report_abs(pen_input, ABS_WHEEL, get_unaligned_le16(&frame[11]));
1225 input_report_abs(pen_input, ABS_DISTANCE, frame[13]);
1227 input_report_key(pen_input, BTN_TOUCH, frame[0] & 0x01);
1228 input_report_key(pen_input, BTN_STYLUS, frame[0] & 0x02);
1229 input_report_key(pen_input, BTN_STYLUS2, frame[0] & 0x04);
1231 input_report_key(pen_input, wacom->tool[0], 1);
1232 input_event(pen_input, EV_MSC, MSC_SERIAL, wacom->serial[0]);
1233 input_report_abs(pen_input, ABS_MISC,
1234 wacom_intuos_id_mangle(wacom->id[0])); /* report tool id */
1236 wacom->shared->stylus_in_proximity = frame[0] & 0x40;
1238 input_sync(pen_input);
1242 static void wacom_intuos_pro2_bt_touch(struct wacom_wac *wacom)
1244 const int finger_touch_len = 8;
1245 const int finger_frames = 4;
1246 const int finger_frame_len = 43;
1248 struct input_dev *touch_input = wacom->touch_input;
1249 unsigned char *data = wacom->data;
1250 int num_contacts_left = 5;
1253 for (i = 0; i < finger_frames; i++) {
1254 unsigned char *frame = &data[i*finger_frame_len + 109];
1255 int current_num_contacts = frame[0] & 0x7F;
1256 int contacts_to_send;
1258 if (!(frame[0] & 0x80))
1262 * First packet resets the counter since only the first
1263 * packet in series will have non-zero current_num_contacts.
1265 if (current_num_contacts)
1266 wacom->num_contacts_left = current_num_contacts;
1268 contacts_to_send = min(num_contacts_left, wacom->num_contacts_left);
1270 for (j = 0; j < contacts_to_send; j++) {
1271 unsigned char *touch = &frame[j*finger_touch_len + 1];
1272 int slot = input_mt_get_slot_by_key(touch_input, touch[0]);
1273 int x = get_unaligned_le16(&touch[2]);
1274 int y = get_unaligned_le16(&touch[4]);
1275 int w = touch[6] * input_abs_get_res(touch_input, ABS_MT_POSITION_X);
1276 int h = touch[7] * input_abs_get_res(touch_input, ABS_MT_POSITION_Y);
1281 input_mt_slot(touch_input, slot);
1282 input_mt_report_slot_state(touch_input, MT_TOOL_FINGER, touch[1] & 0x01);
1283 input_report_abs(touch_input, ABS_MT_POSITION_X, x);
1284 input_report_abs(touch_input, ABS_MT_POSITION_Y, y);
1285 input_report_abs(touch_input, ABS_MT_TOUCH_MAJOR, max(w, h));
1286 input_report_abs(touch_input, ABS_MT_TOUCH_MINOR, min(w, h));
1287 input_report_abs(touch_input, ABS_MT_ORIENTATION, w > h);
1290 input_mt_sync_frame(touch_input);
1292 wacom->num_contacts_left -= contacts_to_send;
1293 if (wacom->num_contacts_left <= 0) {
1294 wacom->num_contacts_left = 0;
1295 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1299 input_report_switch(touch_input, SW_MUTE_DEVICE, !(data[281] >> 7));
1300 input_sync(touch_input);
1303 static void wacom_intuos_pro2_bt_pad(struct wacom_wac *wacom)
1305 struct input_dev *pad_input = wacom->pad_input;
1306 unsigned char *data = wacom->data;
1308 int buttons = (data[282] << 1) | ((data[281] >> 6) & 0x01);
1309 int ring = data[285];
1310 int prox = buttons | (ring & 0x80);
1312 wacom_report_numbered_buttons(pad_input, 9, buttons);
1314 input_report_abs(pad_input, ABS_WHEEL, (ring & 0x80) ? (ring & 0x7f) : 0);
1316 input_report_key(pad_input, wacom->tool[1], prox ? 1 : 0);
1317 input_report_abs(pad_input, ABS_MISC, prox ? PAD_DEVICE_ID : 0);
1318 input_event(pad_input, EV_MSC, MSC_SERIAL, 0xffffffff);
1320 input_sync(pad_input);
1323 static void wacom_intuos_pro2_bt_battery(struct wacom_wac *wacom)
1325 unsigned char *data = wacom->data;
1327 bool chg = data[284] & 0x80;
1328 int battery_status = data[284] & 0x7F;
1330 wacom_notify_battery(wacom, battery_status, chg, 1, chg);
1333 static int wacom_intuos_pro2_bt_irq(struct wacom_wac *wacom, size_t len)
1335 unsigned char *data = wacom->data;
1337 if (data[0] != 0x80) {
1338 dev_dbg(wacom->pen_input->dev.parent,
1339 "%s: received unknown report #%d\n", __func__, data[0]);
1343 wacom_intuos_pro2_bt_pen(wacom);
1344 wacom_intuos_pro2_bt_touch(wacom);
1345 wacom_intuos_pro2_bt_pad(wacom);
1346 wacom_intuos_pro2_bt_battery(wacom);
1350 static int wacom_24hdt_irq(struct wacom_wac *wacom)
1352 struct input_dev *input = wacom->touch_input;
1353 unsigned char *data = wacom->data;
1355 int current_num_contacts = data[61];
1356 int contacts_to_send = 0;
1357 int num_contacts_left = 4; /* maximum contacts per packet */
1358 int byte_per_packet = WACOM_BYTES_PER_24HDT_PACKET;
1361 if (wacom->features.type == WACOM_27QHDT) {
1362 current_num_contacts = data[63];
1363 num_contacts_left = 10;
1364 byte_per_packet = WACOM_BYTES_PER_QHDTHID_PACKET;
1369 * First packet resets the counter since only the first
1370 * packet in series will have non-zero current_num_contacts.
1372 if (current_num_contacts)
1373 wacom->num_contacts_left = current_num_contacts;
1375 contacts_to_send = min(num_contacts_left, wacom->num_contacts_left);
1377 for (i = 0; i < contacts_to_send; i++) {
1378 int offset = (byte_per_packet * i) + 1;
1379 bool touch = (data[offset] & 0x1) && report_touch_events(wacom);
1380 int slot = input_mt_get_slot_by_key(input, data[offset + 1]);
1384 input_mt_slot(input, slot);
1385 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1388 int t_x = get_unaligned_le16(&data[offset + 2]);
1389 int t_y = get_unaligned_le16(&data[offset + 4 + y_offset]);
1391 input_report_abs(input, ABS_MT_POSITION_X, t_x);
1392 input_report_abs(input, ABS_MT_POSITION_Y, t_y);
1394 if (wacom->features.type != WACOM_27QHDT) {
1395 int c_x = get_unaligned_le16(&data[offset + 4]);
1396 int c_y = get_unaligned_le16(&data[offset + 8]);
1397 int w = get_unaligned_le16(&data[offset + 10]);
1398 int h = get_unaligned_le16(&data[offset + 12]);
1400 input_report_abs(input, ABS_MT_TOUCH_MAJOR, min(w,h));
1401 input_report_abs(input, ABS_MT_WIDTH_MAJOR,
1402 min(w, h) + int_dist(t_x, t_y, c_x, c_y));
1403 input_report_abs(input, ABS_MT_WIDTH_MINOR, min(w, h));
1404 input_report_abs(input, ABS_MT_ORIENTATION, w > h);
1408 input_mt_sync_frame(input);
1410 wacom->num_contacts_left -= contacts_to_send;
1411 if (wacom->num_contacts_left <= 0) {
1412 wacom->num_contacts_left = 0;
1413 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1418 static int wacom_mt_touch(struct wacom_wac *wacom)
1420 struct input_dev *input = wacom->touch_input;
1421 unsigned char *data = wacom->data;
1423 int current_num_contacts = data[2];
1424 int contacts_to_send = 0;
1427 /* MTTPC does not support Height and Width */
1428 if (wacom->features.type == MTTPC || wacom->features.type == MTTPC_B)
1432 * First packet resets the counter since only the first
1433 * packet in series will have non-zero current_num_contacts.
1435 if (current_num_contacts)
1436 wacom->num_contacts_left = current_num_contacts;
1438 /* There are at most 5 contacts per packet */
1439 contacts_to_send = min(5, wacom->num_contacts_left);
1441 for (i = 0; i < contacts_to_send; i++) {
1442 int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset) * i + 3;
1443 bool touch = (data[offset] & 0x1) && report_touch_events(wacom);
1444 int id = get_unaligned_le16(&data[offset + 1]);
1445 int slot = input_mt_get_slot_by_key(input, id);
1450 input_mt_slot(input, slot);
1451 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1453 int x = get_unaligned_le16(&data[offset + x_offset + 7]);
1454 int y = get_unaligned_le16(&data[offset + x_offset + 9]);
1455 input_report_abs(input, ABS_MT_POSITION_X, x);
1456 input_report_abs(input, ABS_MT_POSITION_Y, y);
1459 input_mt_sync_frame(input);
1461 wacom->num_contacts_left -= contacts_to_send;
1462 if (wacom->num_contacts_left <= 0) {
1463 wacom->num_contacts_left = 0;
1464 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1469 static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
1471 struct input_dev *input = wacom->touch_input;
1472 unsigned char *data = wacom->data;
1475 for (i = 0; i < 2; i++) {
1476 int p = data[1] & (1 << i);
1477 bool touch = p && report_touch_events(wacom);
1479 input_mt_slot(input, i);
1480 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
1482 int x = le16_to_cpup((__le16 *)&data[i * 2 + 2]) & 0x7fff;
1483 int y = le16_to_cpup((__le16 *)&data[i * 2 + 6]) & 0x7fff;
1485 input_report_abs(input, ABS_MT_POSITION_X, x);
1486 input_report_abs(input, ABS_MT_POSITION_Y, y);
1489 input_mt_sync_frame(input);
1491 /* keep touch state for pen event */
1492 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1497 static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
1499 unsigned char *data = wacom->data;
1500 struct input_dev *input = wacom->touch_input;
1501 bool prox = report_touch_events(wacom);
1504 if (wacom->features.touch_max > 1 || len > WACOM_PKGLEN_TPC2FG)
1507 if (len == WACOM_PKGLEN_TPC1FG) {
1508 prox = prox && (data[0] & 0x01);
1509 x = get_unaligned_le16(&data[1]);
1510 y = get_unaligned_le16(&data[3]);
1511 } else if (len == WACOM_PKGLEN_TPC1FG_B) {
1512 prox = prox && (data[2] & 0x01);
1513 x = get_unaligned_le16(&data[3]);
1514 y = get_unaligned_le16(&data[5]);
1516 prox = prox && (data[1] & 0x01);
1517 x = le16_to_cpup((__le16 *)&data[2]);
1518 y = le16_to_cpup((__le16 *)&data[4]);
1522 input_report_abs(input, ABS_X, x);
1523 input_report_abs(input, ABS_Y, y);
1525 input_report_key(input, BTN_TOUCH, prox);
1527 /* keep touch state for pen events */
1528 wacom->shared->touch_down = prox;
1533 static int wacom_tpc_pen(struct wacom_wac *wacom)
1535 unsigned char *data = wacom->data;
1536 struct input_dev *input = wacom->pen_input;
1537 bool prox = data[1] & 0x20;
1539 if (!wacom->shared->stylus_in_proximity) /* first in prox */
1540 /* Going into proximity select tool */
1541 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
1543 /* keep pen state for touch events */
1544 wacom->shared->stylus_in_proximity = prox;
1546 /* send pen events only when touch is up or forced out
1547 * or touch arbitration is off
1549 if (!delay_pen_events(wacom)) {
1550 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
1551 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
1552 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
1553 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
1554 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x07) << 8) | data[6]);
1555 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
1556 input_report_key(input, wacom->tool[0], prox);
1563 static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
1565 unsigned char *data = wacom->data;
1567 if (wacom->pen_input)
1568 dev_dbg(wacom->pen_input->dev.parent,
1569 "%s: received report #%d\n", __func__, data[0]);
1570 else if (wacom->touch_input)
1571 dev_dbg(wacom->touch_input->dev.parent,
1572 "%s: received report #%d\n", __func__, data[0]);
1575 case WACOM_PKGLEN_TPC1FG:
1576 return wacom_tpc_single_touch(wacom, len);
1578 case WACOM_PKGLEN_TPC2FG:
1579 return wacom_tpc_mt_touch(wacom);
1581 case WACOM_PKGLEN_PENABLED:
1582 return wacom_tpc_pen(wacom);
1586 case WACOM_REPORT_TPC1FG:
1587 case WACOM_REPORT_TPCHID:
1588 case WACOM_REPORT_TPCST:
1589 case WACOM_REPORT_TPC1FGE:
1590 return wacom_tpc_single_touch(wacom, len);
1592 case WACOM_REPORT_TPCMT:
1593 case WACOM_REPORT_TPCMT2:
1594 return wacom_mt_touch(wacom);
1596 case WACOM_REPORT_PENABLED:
1597 return wacom_tpc_pen(wacom);
1604 int wacom_equivalent_usage(int usage)
1606 if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMDIGITIZER) {
1607 int subpage = (usage & 0xFF00) << 8;
1608 int subusage = (usage & 0xFF);
1610 if (subpage == WACOM_HID_SP_PAD ||
1611 subpage == WACOM_HID_SP_BUTTON ||
1612 subpage == WACOM_HID_SP_DIGITIZER ||
1613 subpage == WACOM_HID_SP_DIGITIZERINFO ||
1614 usage == WACOM_HID_WD_SENSE ||
1615 usage == WACOM_HID_WD_SERIALHI ||
1616 usage == WACOM_HID_WD_TOOLTYPE ||
1617 usage == WACOM_HID_WD_DISTANCE ||
1618 usage == WACOM_HID_WD_TOUCHSTRIP ||
1619 usage == WACOM_HID_WD_TOUCHSTRIP2 ||
1620 usage == WACOM_HID_WD_TOUCHRING ||
1621 usage == WACOM_HID_WD_TOUCHRINGSTATUS) {
1625 if (subpage == HID_UP_UNDEFINED)
1626 subpage = HID_UP_DIGITIZER;
1628 return subpage | subusage;
1631 if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMTOUCH) {
1632 int subpage = (usage & 0xFF00) << 8;
1633 int subusage = (usage & 0xFF);
1635 if (subpage == HID_UP_UNDEFINED)
1636 subpage = WACOM_HID_SP_DIGITIZER;
1638 return subpage | subusage;
1644 static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
1645 struct hid_field *field, __u8 type, __u16 code, int fuzz)
1647 struct wacom *wacom = input_get_drvdata(input);
1648 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1649 struct wacom_features *features = &wacom_wac->features;
1650 int fmin = field->logical_minimum;
1651 int fmax = field->logical_maximum;
1652 unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid);
1653 int resolution_code = code;
1655 if (equivalent_usage == HID_DG_TWIST) {
1656 resolution_code = ABS_RZ;
1659 if (equivalent_usage == HID_GD_X) {
1660 fmin += features->offset_left;
1661 fmax -= features->offset_right;
1663 if (equivalent_usage == HID_GD_Y) {
1664 fmin += features->offset_top;
1665 fmax -= features->offset_bottom;
1671 set_bit(type, input->evbit);
1675 input_set_abs_params(input, code, fmin, fmax, fuzz, 0);
1676 input_abs_set_res(input, code,
1677 hidinput_calc_abs_res(field, resolution_code));
1680 input_set_capability(input, EV_KEY, code);
1683 input_set_capability(input, EV_MSC, code);
1686 input_set_capability(input, EV_SW, code);
1691 static void wacom_wac_pad_usage_mapping(struct hid_device *hdev,
1692 struct hid_field *field, struct hid_usage *usage)
1694 struct wacom *wacom = hid_get_drvdata(hdev);
1695 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1696 struct wacom_features *features = &wacom_wac->features;
1697 struct input_dev *input = wacom_wac->pad_input;
1698 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
1700 switch (equivalent_usage) {
1701 case WACOM_HID_WD_BATTERY_LEVEL:
1702 case WACOM_HID_WD_BATTERY_CHARGING:
1703 features->quirks |= WACOM_QUIRK_BATTERY;
1705 case WACOM_HID_WD_ACCELEROMETER_X:
1706 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
1707 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 0);
1708 features->device_type |= WACOM_DEVICETYPE_PAD;
1710 case WACOM_HID_WD_ACCELEROMETER_Y:
1711 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
1712 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 0);
1713 features->device_type |= WACOM_DEVICETYPE_PAD;
1715 case WACOM_HID_WD_ACCELEROMETER_Z:
1716 __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
1717 wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0);
1718 features->device_type |= WACOM_DEVICETYPE_PAD;
1720 case WACOM_HID_WD_BUTTONCENTER:
1721 wacom->generic_has_leds = true;
1723 case WACOM_HID_WD_BUTTONHOME:
1724 case WACOM_HID_WD_BUTTONUP:
1725 case WACOM_HID_WD_BUTTONDOWN:
1726 case WACOM_HID_WD_BUTTONLEFT:
1727 case WACOM_HID_WD_BUTTONRIGHT:
1728 wacom_map_usage(input, usage, field, EV_KEY,
1729 wacom_numbered_button_to_key(features->numbered_buttons),
1731 features->numbered_buttons++;
1732 features->device_type |= WACOM_DEVICETYPE_PAD;
1734 case WACOM_HID_WD_TOUCHONOFF:
1736 * This usage, which is used to mute touch events, comes
1737 * from the pad packet, but is reported on the touch
1738 * interface. Because the touch interface may not have
1739 * been created yet, we cannot call wacom_map_usage(). In
1740 * order to process this usage when we receive it, we set
1741 * the usage type and code directly.
1743 wacom_wac->has_mute_touch_switch = true;
1744 usage->type = EV_SW;
1745 usage->code = SW_MUTE_DEVICE;
1746 features->device_type |= WACOM_DEVICETYPE_PAD;
1748 case WACOM_HID_WD_TOUCHSTRIP:
1749 wacom_map_usage(input, usage, field, EV_ABS, ABS_RX, 0);
1750 features->device_type |= WACOM_DEVICETYPE_PAD;
1752 case WACOM_HID_WD_TOUCHSTRIP2:
1753 wacom_map_usage(input, usage, field, EV_ABS, ABS_RY, 0);
1754 features->device_type |= WACOM_DEVICETYPE_PAD;
1756 case WACOM_HID_WD_TOUCHRING:
1757 wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
1758 features->device_type |= WACOM_DEVICETYPE_PAD;
1760 case WACOM_HID_WD_TOUCHRINGSTATUS:
1761 wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
1762 features->device_type |= WACOM_DEVICETYPE_PAD;
1766 switch (equivalent_usage & 0xfffffff0) {
1767 case WACOM_HID_WD_EXPRESSKEY00:
1768 wacom_map_usage(input, usage, field, EV_KEY,
1769 wacom_numbered_button_to_key(features->numbered_buttons),
1771 features->numbered_buttons++;
1772 features->device_type |= WACOM_DEVICETYPE_PAD;
1777 static void wacom_wac_pad_battery_event(struct hid_device *hdev, struct hid_field *field,
1778 struct hid_usage *usage, __s32 value)
1780 struct wacom *wacom = hid_get_drvdata(hdev);
1781 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1782 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
1784 switch (equivalent_usage) {
1785 case WACOM_HID_WD_BATTERY_LEVEL:
1786 wacom_wac->hid_data.battery_capacity = value;
1787 wacom_wac->hid_data.bat_connected = 1;
1790 case WACOM_HID_WD_BATTERY_CHARGING:
1791 wacom_wac->hid_data.bat_charging = value;
1792 wacom_wac->hid_data.ps_connected = value;
1793 wacom_wac->hid_data.bat_connected = 1;
1798 static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field,
1799 struct hid_usage *usage, __s32 value)
1801 struct wacom *wacom = hid_get_drvdata(hdev);
1802 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1803 struct input_dev *input = wacom_wac->pad_input;
1804 struct wacom_features *features = &wacom_wac->features;
1805 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
1809 * Avoid reporting this event and setting inrange_state if this usage
1810 * hasn't been mapped.
1815 if (wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY) {
1816 if (usage->hid != WACOM_HID_WD_TOUCHRING)
1817 wacom_wac->hid_data.inrange_state |= value;
1820 switch (equivalent_usage) {
1821 case WACOM_HID_WD_TOUCHRINGSTATUS:
1823 input_event(input, usage->type, usage->code, 0);
1826 case WACOM_HID_WD_TOUCHONOFF:
1827 if (wacom_wac->shared->touch_input) {
1828 input_report_switch(wacom_wac->shared->touch_input,
1829 SW_MUTE_DEVICE, !value);
1830 input_sync(wacom_wac->shared->touch_input);
1834 case WACOM_HID_WD_BUTTONCENTER:
1835 for (i = 0; i < wacom->led.count; i++)
1836 wacom_update_led(wacom, features->numbered_buttons,
1840 input_event(input, usage->type, usage->code, value);
1845 static void wacom_wac_pad_pre_report(struct hid_device *hdev,
1846 struct hid_report *report)
1848 struct wacom *wacom = hid_get_drvdata(hdev);
1849 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1851 wacom_wac->hid_data.inrange_state = 0;
1854 static void wacom_wac_pad_battery_report(struct hid_device *hdev,
1855 struct hid_report *report)
1857 struct wacom *wacom = hid_get_drvdata(hdev);
1858 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1859 struct wacom_features *features = &wacom_wac->features;
1861 if (features->quirks & WACOM_QUIRK_BATTERY) {
1862 int capacity = wacom_wac->hid_data.battery_capacity;
1863 bool charging = wacom_wac->hid_data.bat_charging;
1864 bool connected = wacom_wac->hid_data.bat_connected;
1865 bool powered = wacom_wac->hid_data.ps_connected;
1867 wacom_notify_battery(wacom_wac, capacity, charging,
1868 connected, powered);
1872 static void wacom_wac_pad_report(struct hid_device *hdev,
1873 struct hid_report *report)
1875 struct wacom *wacom = hid_get_drvdata(hdev);
1876 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1877 struct input_dev *input = wacom_wac->pad_input;
1878 bool active = wacom_wac->hid_data.inrange_state != 0;
1880 /* report prox for expresskey events */
1881 if (wacom_equivalent_usage(report->field[0]->physical) == HID_DG_TABLETFUNCTIONKEY) {
1882 input_event(input, EV_ABS, ABS_MISC, active ? PAD_DEVICE_ID : 0);
1888 static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
1889 struct hid_field *field, struct hid_usage *usage)
1891 struct wacom *wacom = hid_get_drvdata(hdev);
1892 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1893 struct wacom_features *features = &wacom_wac->features;
1894 struct input_dev *input = wacom_wac->pen_input;
1895 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
1897 switch (equivalent_usage) {
1899 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
1902 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
1904 case WACOM_HID_WD_DISTANCE:
1906 wacom_map_usage(input, usage, field, EV_ABS, ABS_DISTANCE, 0);
1908 case HID_DG_TIPPRESSURE:
1909 wacom_map_usage(input, usage, field, EV_ABS, ABS_PRESSURE, 0);
1911 case HID_DG_INRANGE:
1912 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
1914 case HID_DG_BATTERYSTRENGTH:
1915 features->quirks |= WACOM_QUIRK_BATTERY;
1918 wacom_map_usage(input, usage, field, EV_KEY,
1919 BTN_TOOL_RUBBER, 0);
1922 wacom_map_usage(input, usage, field, EV_ABS, ABS_TILT_X, 0);
1925 wacom_map_usage(input, usage, field, EV_ABS, ABS_TILT_Y, 0);
1928 wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0);
1931 case HID_DG_TIPSWITCH:
1932 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
1934 case HID_DG_BARRELSWITCH:
1935 wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS, 0);
1937 case HID_DG_BARRELSWITCH2:
1938 wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS2, 0);
1940 case HID_DG_TOOLSERIALNUMBER:
1941 wacom_map_usage(input, usage, field, EV_MSC, MSC_SERIAL, 0);
1943 case WACOM_HID_WD_SENSE:
1944 features->quirks |= WACOM_QUIRK_SENSE;
1945 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
1947 case WACOM_HID_WD_SERIALHI:
1948 wacom_map_usage(input, usage, field, EV_ABS, ABS_MISC, 0);
1949 set_bit(EV_KEY, input->evbit);
1950 input_set_capability(input, EV_KEY, BTN_TOOL_PEN);
1951 input_set_capability(input, EV_KEY, BTN_TOOL_RUBBER);
1952 input_set_capability(input, EV_KEY, BTN_TOOL_BRUSH);
1953 input_set_capability(input, EV_KEY, BTN_TOOL_PENCIL);
1954 input_set_capability(input, EV_KEY, BTN_TOOL_AIRBRUSH);
1955 input_set_capability(input, EV_KEY, BTN_TOOL_MOUSE);
1956 input_set_capability(input, EV_KEY, BTN_TOOL_LENS);
1958 case WACOM_HID_WD_FINGERWHEEL:
1959 wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
1964 static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field,
1965 struct hid_usage *usage, __s32 value)
1967 struct wacom *wacom = hid_get_drvdata(hdev);
1968 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1969 struct wacom_features *features = &wacom_wac->features;
1970 struct input_dev *input = wacom_wac->pen_input;
1971 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
1973 switch (equivalent_usage) {
1976 * HID_GD_Z "should increase as the control's position is
1977 * moved from high to low", while ABS_DISTANCE instead
1978 * increases in value as the tool moves from low to high.
1980 value = field->logical_maximum - value;
1982 case HID_DG_INRANGE:
1983 wacom_wac->hid_data.inrange_state = value;
1984 if (!(features->quirks & WACOM_QUIRK_SENSE))
1985 wacom_wac->hid_data.sense_state = value;
1987 case HID_DG_BATTERYSTRENGTH:
1988 wacom_wac->hid_data.battery_capacity = value;
1989 wacom_wac->hid_data.bat_connected = 1;
1992 wacom_wac->hid_data.invert_state = value;
1995 case HID_DG_TIPSWITCH:
1996 wacom_wac->hid_data.tipswitch |= value;
1998 case HID_DG_TOOLSERIALNUMBER:
1999 wacom_wac->serial[0] = (wacom_wac->serial[0] & ~0xFFFFFFFFULL);
2000 wacom_wac->serial[0] |= value;
2002 case WACOM_HID_WD_SENSE:
2003 wacom_wac->hid_data.sense_state = value;
2005 case WACOM_HID_WD_SERIALHI:
2006 wacom_wac->serial[0] = (wacom_wac->serial[0] & 0xFFFFFFFF);
2007 wacom_wac->serial[0] |= ((__u64)value) << 32;
2009 * Non-USI EMR devices may contain additional tool type
2010 * information here. See WACOM_HID_WD_TOOLTYPE case for
2013 if (value >> 20 == 1) {
2014 wacom_wac->id[0] |= value & 0xFFFFF;
2017 case WACOM_HID_WD_TOOLTYPE:
2019 * Some devices (MobileStudio Pro, and possibly later
2020 * devices as well) do not return the complete tool
2021 * type in their WACOM_HID_WD_TOOLTYPE usage. Use a
2022 * bitwise OR so the complete value can be built
2025 wacom_wac->id[0] |= value;
2027 case WACOM_HID_WD_OFFSETLEFT:
2028 if (features->offset_left && value != features->offset_left)
2029 hid_warn(hdev, "%s: overriding exising left offset "
2030 "%d -> %d\n", __func__, value,
2031 features->offset_left);
2032 features->offset_left = value;
2034 case WACOM_HID_WD_OFFSETRIGHT:
2035 if (features->offset_right && value != features->offset_right)
2036 hid_warn(hdev, "%s: overriding exising right offset "
2037 "%d -> %d\n", __func__, value,
2038 features->offset_right);
2039 features->offset_right = value;
2041 case WACOM_HID_WD_OFFSETTOP:
2042 if (features->offset_top && value != features->offset_top)
2043 hid_warn(hdev, "%s: overriding exising top offset "
2044 "%d -> %d\n", __func__, value,
2045 features->offset_top);
2046 features->offset_top = value;
2048 case WACOM_HID_WD_OFFSETBOTTOM:
2049 if (features->offset_bottom && value != features->offset_bottom)
2050 hid_warn(hdev, "%s: overriding exising bottom offset "
2051 "%d -> %d\n", __func__, value,
2052 features->offset_bottom);
2053 features->offset_bottom = value;
2057 /* send pen events only when touch is up or forced out
2058 * or touch arbitration is off
2060 if (!usage->type || delay_pen_events(wacom_wac))
2063 /* send pen events only when the pen is in/entering/leaving proximity */
2064 if (!wacom_wac->hid_data.inrange_state && !wacom_wac->tool[0])
2067 input_event(input, usage->type, usage->code, value);
2070 static void wacom_wac_pen_pre_report(struct hid_device *hdev,
2071 struct hid_report *report)
2076 static void wacom_wac_pen_report(struct hid_device *hdev,
2077 struct hid_report *report)
2079 struct wacom *wacom = hid_get_drvdata(hdev);
2080 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2081 struct input_dev *input = wacom_wac->pen_input;
2082 bool prox = wacom_wac->hid_data.inrange_state;
2083 bool range = wacom_wac->hid_data.sense_state;
2085 if (!wacom_wac->tool[0] && prox) { /* first in prox */
2086 /* Going into proximity select tool */
2087 if (wacom_wac->hid_data.invert_state)
2088 wacom_wac->tool[0] = BTN_TOOL_RUBBER;
2089 else if (wacom_wac->id[0])
2090 wacom_wac->tool[0] = wacom_intuos_get_tool_type(wacom_wac->id[0]);
2092 wacom_wac->tool[0] = BTN_TOOL_PEN;
2095 /* keep pen state for touch events */
2096 wacom_wac->shared->stylus_in_proximity = range;
2098 if (!delay_pen_events(wacom_wac) && wacom_wac->tool[0]) {
2099 int id = wacom_wac->id[0];
2102 * Non-USI EMR tools should have their IDs mangled to
2103 * match the legacy behavior of wacom_intuos_general
2105 if (wacom_wac->serial[0] >> 52 == 1)
2106 id = wacom_intuos_id_mangle(id);
2109 * To ensure compatibility with xf86-input-wacom, we should
2110 * report the BTN_TOOL_* event prior to the ABS_MISC or
2111 * MSC_SERIAL events.
2113 input_report_key(input, BTN_TOUCH,
2114 wacom_wac->hid_data.tipswitch);
2115 input_report_key(input, wacom_wac->tool[0], prox);
2116 if (wacom_wac->serial[0]) {
2117 input_event(input, EV_MSC, MSC_SERIAL, wacom_wac->serial[0]);
2118 input_report_abs(input, ABS_MISC, id);
2121 wacom_wac->hid_data.tipswitch = false;
2127 wacom_wac->tool[0] = 0;
2128 wacom_wac->id[0] = 0;
2132 static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
2133 struct hid_field *field, struct hid_usage *usage)
2135 struct wacom *wacom = hid_get_drvdata(hdev);
2136 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2137 struct input_dev *input = wacom_wac->touch_input;
2138 unsigned touch_max = wacom_wac->features.touch_max;
2139 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2141 switch (equivalent_usage) {
2144 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
2146 wacom_map_usage(input, usage, field, EV_ABS,
2147 ABS_MT_POSITION_X, 4);
2151 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
2153 wacom_map_usage(input, usage, field, EV_ABS,
2154 ABS_MT_POSITION_Y, 4);
2158 wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MAJOR, 0);
2159 wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MINOR, 0);
2160 input_set_abs_params(input, ABS_MT_ORIENTATION, 0, 1, 0, 0);
2162 case HID_DG_TIPSWITCH:
2163 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
2165 case HID_DG_CONTACTCOUNT:
2166 wacom_wac->hid_data.cc_report = field->report->id;
2167 wacom_wac->hid_data.cc_index = field->index;
2168 wacom_wac->hid_data.cc_value_index = usage->usage_index;
2173 static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
2174 struct input_dev *input)
2176 struct hid_data *hid_data = &wacom_wac->hid_data;
2177 bool mt = wacom_wac->features.touch_max > 1;
2178 bool prox = hid_data->tipswitch &&
2179 report_touch_events(wacom_wac);
2181 wacom_wac->hid_data.num_received++;
2182 if (wacom_wac->hid_data.num_received > wacom_wac->hid_data.num_expected)
2188 slot = input_mt_get_slot_by_key(input, hid_data->id);
2189 input_mt_slot(input, slot);
2190 input_mt_report_slot_state(input, MT_TOOL_FINGER, prox);
2193 input_report_key(input, BTN_TOUCH, prox);
2197 input_report_abs(input, mt ? ABS_MT_POSITION_X : ABS_X,
2199 input_report_abs(input, mt ? ABS_MT_POSITION_Y : ABS_Y,
2202 if (test_bit(ABS_MT_TOUCH_MAJOR, input->absbit)) {
2203 input_report_abs(input, ABS_MT_TOUCH_MAJOR, max(hid_data->width, hid_data->height));
2204 input_report_abs(input, ABS_MT_TOUCH_MINOR, min(hid_data->width, hid_data->height));
2205 if (hid_data->width != hid_data->height)
2206 input_report_abs(input, ABS_MT_ORIENTATION, hid_data->width <= hid_data->height ? 0 : 1);
2211 static void wacom_wac_finger_event(struct hid_device *hdev,
2212 struct hid_field *field, struct hid_usage *usage, __s32 value)
2214 struct wacom *wacom = hid_get_drvdata(hdev);
2215 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2216 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
2218 switch (equivalent_usage) {
2220 wacom_wac->hid_data.x = value;
2223 wacom_wac->hid_data.y = value;
2226 wacom_wac->hid_data.width = value;
2229 wacom_wac->hid_data.height = value;
2231 case HID_DG_CONTACTID:
2232 wacom_wac->hid_data.id = value;
2234 case HID_DG_TIPSWITCH:
2235 wacom_wac->hid_data.tipswitch = value;
2240 if (usage->usage_index + 1 == field->report_count) {
2241 if (equivalent_usage == wacom_wac->hid_data.last_slot_field)
2242 wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
2246 static void wacom_wac_finger_pre_report(struct hid_device *hdev,
2247 struct hid_report *report)
2249 struct wacom *wacom = hid_get_drvdata(hdev);
2250 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2251 struct hid_data* hid_data = &wacom_wac->hid_data;
2254 for (i = 0; i < report->maxfield; i++) {
2255 struct hid_field *field = report->field[i];
2258 for (j = 0; j < field->maxusage; j++) {
2259 struct hid_usage *usage = &field->usage[j];
2260 unsigned int equivalent_usage =
2261 wacom_equivalent_usage(usage->hid);
2263 switch (equivalent_usage) {
2268 case HID_DG_CONTACTID:
2269 case HID_DG_INRANGE:
2271 case HID_DG_TIPSWITCH:
2272 hid_data->last_slot_field = equivalent_usage;
2274 case HID_DG_CONTACTCOUNT:
2275 hid_data->cc_report = report->id;
2276 hid_data->cc_index = i;
2277 hid_data->cc_value_index = j;
2283 if (hid_data->cc_report != 0 &&
2284 hid_data->cc_index >= 0) {
2285 struct hid_field *field = report->field[hid_data->cc_index];
2286 int value = field->value[hid_data->cc_value_index];
2288 hid_data->num_expected = value;
2291 hid_data->num_expected = wacom_wac->features.touch_max;
2295 static void wacom_wac_finger_report(struct hid_device *hdev,
2296 struct hid_report *report)
2298 struct wacom *wacom = hid_get_drvdata(hdev);
2299 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2300 struct input_dev *input = wacom_wac->touch_input;
2301 unsigned touch_max = wacom_wac->features.touch_max;
2303 /* If more packets of data are expected, give us a chance to
2304 * process them rather than immediately syncing a partial
2307 if (wacom_wac->hid_data.num_received < wacom_wac->hid_data.num_expected)
2311 input_mt_sync_frame(input);
2314 wacom_wac->hid_data.num_received = 0;
2316 /* keep touch state for pen event */
2317 wacom_wac->shared->touch_down = wacom_wac_finger_count_touches(wacom_wac);
2320 void wacom_wac_usage_mapping(struct hid_device *hdev,
2321 struct hid_field *field, struct hid_usage *usage)
2323 struct wacom *wacom = hid_get_drvdata(hdev);
2324 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2325 struct wacom_features *features = &wacom_wac->features;
2327 if (WACOM_DIRECT_DEVICE(field))
2328 features->device_type |= WACOM_DEVICETYPE_DIRECT;
2330 if (WACOM_PAD_FIELD(field))
2331 wacom_wac_pad_usage_mapping(hdev, field, usage);
2332 else if (WACOM_PEN_FIELD(field))
2333 wacom_wac_pen_usage_mapping(hdev, field, usage);
2334 else if (WACOM_FINGER_FIELD(field))
2335 wacom_wac_finger_usage_mapping(hdev, field, usage);
2338 void wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
2339 struct hid_usage *usage, __s32 value)
2341 struct wacom *wacom = hid_get_drvdata(hdev);
2343 if (wacom->wacom_wac.features.type != HID_GENERIC)
2346 if (value > field->logical_maximum || value < field->logical_minimum)
2349 if (WACOM_PAD_FIELD(field)) {
2350 wacom_wac_pad_battery_event(hdev, field, usage, value);
2351 if (wacom->wacom_wac.pad_input)
2352 wacom_wac_pad_event(hdev, field, usage, value);
2353 } else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
2354 wacom_wac_pen_event(hdev, field, usage, value);
2355 else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
2356 wacom_wac_finger_event(hdev, field, usage, value);
2359 static void wacom_report_events(struct hid_device *hdev, struct hid_report *report)
2363 for (r = 0; r < report->maxfield; r++) {
2364 struct hid_field *field;
2367 field = report->field[r];
2368 count = field->report_count;
2370 if (!(HID_MAIN_ITEM_VARIABLE & field->flags))
2373 for (n = 0; n < count; n++)
2374 wacom_wac_event(hdev, field, &field->usage[n], field->value[n]);
2378 void wacom_wac_report(struct hid_device *hdev, struct hid_report *report)
2380 struct wacom *wacom = hid_get_drvdata(hdev);
2381 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2382 struct hid_field *field = report->field[0];
2384 if (wacom_wac->features.type != HID_GENERIC)
2387 if (WACOM_PAD_FIELD(field) && wacom->wacom_wac.pad_input)
2388 wacom_wac_pad_pre_report(hdev, report);
2389 else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
2390 wacom_wac_pen_pre_report(hdev, report);
2391 else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
2392 wacom_wac_finger_pre_report(hdev, report);
2394 wacom_report_events(hdev, report);
2397 * Non-input reports may be sent prior to the device being
2398 * completely initialized. Since only their events need
2399 * to be processed, exit after 'wacom_report_events' has
2400 * been called to prevent potential crashes in the report-
2401 * processing functions.
2403 if (report->type != HID_INPUT_REPORT)
2406 if (WACOM_PAD_FIELD(field)) {
2407 wacom_wac_pad_battery_report(hdev, report);
2408 if (wacom->wacom_wac.pad_input)
2409 wacom_wac_pad_report(hdev, report);
2410 } else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
2411 wacom_wac_pen_report(hdev, report);
2412 else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
2413 wacom_wac_finger_report(hdev, report);
2416 static int wacom_bpt_touch(struct wacom_wac *wacom)
2418 struct wacom_features *features = &wacom->features;
2419 struct input_dev *input = wacom->touch_input;
2420 struct input_dev *pad_input = wacom->pad_input;
2421 unsigned char *data = wacom->data;
2424 if (data[0] != 0x02)
2427 for (i = 0; i < 2; i++) {
2428 int offset = (data[1] & 0x80) ? (8 * i) : (9 * i);
2429 bool touch = report_touch_events(wacom)
2430 && (data[offset + 3] & 0x80);
2432 input_mt_slot(input, i);
2433 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
2435 int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff;
2436 int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff;
2437 if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) {
2441 input_report_abs(input, ABS_MT_POSITION_X, x);
2442 input_report_abs(input, ABS_MT_POSITION_Y, y);
2446 input_mt_sync_frame(input);
2448 input_report_key(pad_input, BTN_LEFT, (data[1] & 0x08) != 0);
2449 input_report_key(pad_input, BTN_FORWARD, (data[1] & 0x04) != 0);
2450 input_report_key(pad_input, BTN_BACK, (data[1] & 0x02) != 0);
2451 input_report_key(pad_input, BTN_RIGHT, (data[1] & 0x01) != 0);
2452 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
2457 static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
2459 struct wacom_features *features = &wacom->features;
2460 struct input_dev *input = wacom->touch_input;
2461 bool touch = data[1] & 0x80;
2462 int slot = input_mt_get_slot_by_key(input, data[0]);
2467 touch = touch && report_touch_events(wacom);
2469 input_mt_slot(input, slot);
2470 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
2473 int x = (data[2] << 4) | (data[4] >> 4);
2474 int y = (data[3] << 4) | (data[4] & 0x0f);
2477 if (features->type >= INTUOSPS && features->type <= INTUOSHT2) {
2478 width = data[5] * 100;
2479 height = data[6] * 100;
2482 * "a" is a scaled-down area which we assume is
2483 * roughly circular and which can be described as:
2487 int x_res = input_abs_get_res(input, ABS_MT_POSITION_X);
2488 int y_res = input_abs_get_res(input, ABS_MT_POSITION_Y);
2489 width = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE);
2490 height = width * y_res / x_res;
2493 input_report_abs(input, ABS_MT_POSITION_X, x);
2494 input_report_abs(input, ABS_MT_POSITION_Y, y);
2495 input_report_abs(input, ABS_MT_TOUCH_MAJOR, width);
2496 input_report_abs(input, ABS_MT_TOUCH_MINOR, height);
2500 static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
2502 struct input_dev *input = wacom->pad_input;
2503 struct wacom_features *features = &wacom->features;
2505 if (features->type == INTUOSHT || features->type == INTUOSHT2) {
2506 input_report_key(input, BTN_LEFT, (data[1] & 0x02) != 0);
2507 input_report_key(input, BTN_BACK, (data[1] & 0x08) != 0);
2509 input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
2510 input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
2512 input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
2513 input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
2516 static int wacom_bpt3_touch(struct wacom_wac *wacom)
2518 unsigned char *data = wacom->data;
2519 int count = data[1] & 0x07;
2520 int touch_changed = 0, i;
2522 if (data[0] != 0x02)
2525 /* data has up to 7 fixed sized 8-byte messages starting at data[2] */
2526 for (i = 0; i < count; i++) {
2527 int offset = (8 * i) + 2;
2528 int msg_id = data[offset];
2530 if (msg_id >= 2 && msg_id <= 17) {
2531 wacom_bpt3_touch_msg(wacom, data + offset);
2533 } else if (msg_id == 128)
2534 wacom_bpt3_button_msg(wacom, data + offset);
2538 /* only update touch if we actually have a touchpad and touch data changed */
2539 if (wacom->touch_input && touch_changed) {
2540 input_mt_sync_frame(wacom->touch_input);
2541 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
2547 static int wacom_bpt_pen(struct wacom_wac *wacom)
2549 struct wacom_features *features = &wacom->features;
2550 struct input_dev *input = wacom->pen_input;
2551 unsigned char *data = wacom->data;
2552 int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
2554 if (data[0] != WACOM_REPORT_PENABLED)
2557 prox = (data[1] & 0x20) == 0x20;
2560 * All reports shared between PEN and RUBBER tool must be
2561 * forced to a known starting value (zero) when transitioning to
2564 * If not reset then, to userspace, it will look like lost events
2565 * if new tool comes in-prox with same values as previous tool sent.
2567 * Hardware does report zero in most out-of-prox cases but not all.
2569 if (!wacom->shared->stylus_in_proximity) {
2570 if (data[1] & 0x08) {
2571 wacom->tool[0] = BTN_TOOL_RUBBER;
2572 wacom->id[0] = ERASER_DEVICE_ID;
2574 wacom->tool[0] = BTN_TOOL_PEN;
2575 wacom->id[0] = STYLUS_DEVICE_ID;
2579 wacom->shared->stylus_in_proximity = prox;
2580 if (delay_pen_events(wacom))
2584 x = le16_to_cpup((__le16 *)&data[2]);
2585 y = le16_to_cpup((__le16 *)&data[4]);
2586 p = le16_to_cpup((__le16 *)&data[6]);
2588 * Convert distance from out prox to distance from tablet.
2589 * distance will be greater than distance_max once
2590 * touching and applying pressure; do not report negative
2593 if (data[8] <= features->distance_max)
2594 d = features->distance_max - data[8];
2596 pen = data[1] & 0x01;
2597 btn1 = data[1] & 0x02;
2598 btn2 = data[1] & 0x04;
2603 input_report_key(input, BTN_TOUCH, pen);
2604 input_report_key(input, BTN_STYLUS, btn1);
2605 input_report_key(input, BTN_STYLUS2, btn2);
2607 input_report_abs(input, ABS_X, x);
2608 input_report_abs(input, ABS_Y, y);
2609 input_report_abs(input, ABS_PRESSURE, p);
2610 input_report_abs(input, ABS_DISTANCE, d);
2612 input_report_key(input, wacom->tool[0], prox); /* PEN or RUBBER */
2613 input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
2618 static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
2620 struct wacom_features *features = &wacom->features;
2622 if ((features->type == INTUOSHT2) &&
2623 (features->device_type & WACOM_DEVICETYPE_PEN))
2624 return wacom_intuos_irq(wacom);
2625 else if (len == WACOM_PKGLEN_BBTOUCH)
2626 return wacom_bpt_touch(wacom);
2627 else if (len == WACOM_PKGLEN_BBTOUCH3)
2628 return wacom_bpt3_touch(wacom);
2629 else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
2630 return wacom_bpt_pen(wacom);
2635 static void wacom_bamboo_pad_pen_event(struct wacom_wac *wacom,
2636 unsigned char *data)
2638 unsigned char prefix;
2641 * We need to reroute the event from the debug interface to the
2643 * We need to add the report ID to the actual pen report, so we
2644 * temporary overwrite the first byte to prevent having to kzalloc/kfree
2645 * and memcpy the report.
2648 data[0] = WACOM_REPORT_BPAD_PEN;
2651 * actually reroute the event.
2652 * No need to check if wacom->shared->pen is valid, hid_input_report()
2653 * will check for us.
2655 hid_input_report(wacom->shared->pen, HID_INPUT_REPORT, data,
2656 WACOM_PKGLEN_PENABLED, 1);
2661 static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom,
2662 unsigned char *data)
2664 struct input_dev *input = wacom->touch_input;
2665 unsigned char *finger_data, prefix;
2672 for (id = 0; id < wacom->features.touch_max; id++) {
2673 valid = !!(prefix & BIT(id)) &&
2674 report_touch_events(wacom);
2676 input_mt_slot(input, id);
2677 input_mt_report_slot_state(input, MT_TOOL_FINGER, valid);
2682 finger_data = data + 1 + id * 3;
2683 x = finger_data[0] | ((finger_data[1] & 0x0f) << 8);
2684 y = (finger_data[2] << 4) | (finger_data[1] >> 4);
2686 input_report_abs(input, ABS_MT_POSITION_X, x);
2687 input_report_abs(input, ABS_MT_POSITION_Y, y);
2690 input_mt_sync_frame(input);
2692 input_report_key(input, BTN_LEFT, prefix & 0x40);
2693 input_report_key(input, BTN_RIGHT, prefix & 0x80);
2695 /* keep touch state for pen event */
2696 wacom->shared->touch_down = !!prefix && report_touch_events(wacom);
2701 static int wacom_bamboo_pad_irq(struct wacom_wac *wacom, size_t len)
2703 unsigned char *data = wacom->data;
2705 if (!((len == WACOM_PKGLEN_BPAD_TOUCH) ||
2706 (len == WACOM_PKGLEN_BPAD_TOUCH_USB)) ||
2707 (data[0] != WACOM_REPORT_BPAD_TOUCH))
2711 wacom_bamboo_pad_pen_event(wacom, &data[1]);
2714 return wacom_bamboo_pad_touch_event(wacom, &data[9]);
2719 static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
2721 unsigned char *data = wacom->data;
2724 if (len != WACOM_PKGLEN_WIRELESS || data[0] != WACOM_REPORT_WL)
2727 connected = data[1] & 0x01;
2729 int pid, battery, charging;
2731 if ((wacom->shared->type == INTUOSHT ||
2732 wacom->shared->type == INTUOSHT2) &&
2733 wacom->shared->touch_input &&
2734 wacom->shared->touch_max) {
2735 input_report_switch(wacom->shared->touch_input,
2736 SW_MUTE_DEVICE, data[5] & 0x40);
2737 input_sync(wacom->shared->touch_input);
2740 pid = get_unaligned_be16(&data[6]);
2741 battery = (data[5] & 0x3f) * 100 / 31;
2742 charging = !!(data[5] & 0x80);
2743 if (wacom->pid != pid) {
2745 wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
2748 wacom_notify_battery(wacom, battery, charging, 1, 0);
2750 } else if (wacom->pid != 0) {
2751 /* disconnected while previously connected */
2753 wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
2754 wacom_notify_battery(wacom, 0, 0, 0, 0);
2760 static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
2762 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
2763 struct wacom_features *features = &wacom_wac->features;
2764 unsigned char *data = wacom_wac->data;
2766 if (data[0] != WACOM_REPORT_USB)
2769 if ((features->type == INTUOSHT ||
2770 features->type == INTUOSHT2) &&
2771 wacom_wac->shared->touch_input &&
2772 features->touch_max) {
2773 input_report_switch(wacom_wac->shared->touch_input,
2774 SW_MUTE_DEVICE, data[8] & 0x40);
2775 input_sync(wacom_wac->shared->touch_input);
2778 if (data[9] & 0x02) { /* wireless module is attached */
2779 int battery = (data[8] & 0x3f) * 100 / 31;
2780 bool charging = !!(data[8] & 0x80);
2782 wacom_notify_battery(wacom_wac, battery, charging,
2783 battery || charging, 1);
2785 if (!wacom->battery.battery &&
2786 !(features->quirks & WACOM_QUIRK_BATTERY)) {
2787 features->quirks |= WACOM_QUIRK_BATTERY;
2788 wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
2791 else if ((features->quirks & WACOM_QUIRK_BATTERY) &&
2792 wacom->battery.battery) {
2793 features->quirks &= ~WACOM_QUIRK_BATTERY;
2794 wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
2795 wacom_notify_battery(wacom_wac, 0, 0, 0, 0);
2800 void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
2804 switch (wacom_wac->features.type) {
2806 sync = wacom_penpartner_irq(wacom_wac);
2810 sync = wacom_pl_irq(wacom_wac);
2817 sync = wacom_graphire_irq(wacom_wac);
2821 sync = wacom_ptu_irq(wacom_wac);
2825 sync = wacom_dtu_irq(wacom_wac);
2830 sync = wacom_dtus_irq(wacom_wac);
2849 case CINTIQ_COMPANION_2:
2850 sync = wacom_intuos_irq(wacom_wac);
2854 sync = wacom_intuos_bt_irq(wacom_wac, len);
2859 sync = wacom_24hdt_irq(wacom_wac);
2868 if (len == WACOM_PKGLEN_BBTOUCH3)
2869 sync = wacom_bpt3_touch(wacom_wac);
2870 else if (wacom_wac->data[0] == WACOM_REPORT_USB)
2871 sync = wacom_status_irq(wacom_wac, len);
2873 sync = wacom_intuos_irq(wacom_wac);
2877 sync = wacom_intuos_pro2_bt_irq(wacom_wac, len);
2886 sync = wacom_tpc_irq(wacom_wac, len);
2894 if (wacom_wac->data[0] == WACOM_REPORT_USB)
2895 sync = wacom_status_irq(wacom_wac, len);
2897 sync = wacom_bpt_irq(wacom_wac, len);
2901 sync = wacom_bamboo_pad_irq(wacom_wac, len);
2905 sync = wacom_wireless_irq(wacom_wac, len);
2910 if (wacom_wac->data[0] == WACOM_REPORT_DEVICE_LIST)
2911 wacom_remote_status_irq(wacom_wac, len);
2913 sync = wacom_remote_irq(wacom_wac, len);
2922 if (wacom_wac->pen_input)
2923 input_sync(wacom_wac->pen_input);
2924 if (wacom_wac->touch_input)
2925 input_sync(wacom_wac->touch_input);
2926 if (wacom_wac->pad_input)
2927 input_sync(wacom_wac->pad_input);
2931 static void wacom_setup_basic_pro_pen(struct wacom_wac *wacom_wac)
2933 struct input_dev *input_dev = wacom_wac->pen_input;
2935 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
2937 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
2938 __set_bit(BTN_STYLUS, input_dev->keybit);
2939 __set_bit(BTN_STYLUS2, input_dev->keybit);
2941 input_set_abs_params(input_dev, ABS_DISTANCE,
2942 0, wacom_wac->features.distance_max, wacom_wac->features.distance_fuzz, 0);
2945 static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
2947 struct input_dev *input_dev = wacom_wac->pen_input;
2948 struct wacom_features *features = &wacom_wac->features;
2950 wacom_setup_basic_pro_pen(wacom_wac);
2952 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
2953 __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
2954 __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
2955 __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
2957 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
2958 input_set_abs_params(input_dev, ABS_TILT_X, -64, 63, features->tilt_fuzz, 0);
2959 input_abs_set_res(input_dev, ABS_TILT_X, 57);
2960 input_set_abs_params(input_dev, ABS_TILT_Y, -64, 63, features->tilt_fuzz, 0);
2961 input_abs_set_res(input_dev, ABS_TILT_Y, 57);
2964 static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
2966 struct input_dev *input_dev = wacom_wac->pen_input;
2968 input_set_capability(input_dev, EV_REL, REL_WHEEL);
2970 wacom_setup_cintiq(wacom_wac);
2972 __set_bit(BTN_LEFT, input_dev->keybit);
2973 __set_bit(BTN_RIGHT, input_dev->keybit);
2974 __set_bit(BTN_MIDDLE, input_dev->keybit);
2975 __set_bit(BTN_SIDE, input_dev->keybit);
2976 __set_bit(BTN_EXTRA, input_dev->keybit);
2977 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
2978 __set_bit(BTN_TOOL_LENS, input_dev->keybit);
2980 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
2981 input_abs_set_res(input_dev, ABS_RZ, 287);
2982 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
2985 void wacom_setup_device_quirks(struct wacom *wacom)
2987 struct wacom_features *features = &wacom->wacom_wac.features;
2989 /* The pen and pad share the same interface on most devices */
2990 if (features->type == GRAPHIRE_BT || features->type == WACOM_G4 ||
2991 features->type == DTUS ||
2992 (features->type >= INTUOS3S && features->type <= WACOM_MO)) {
2993 if (features->device_type & WACOM_DEVICETYPE_PEN)
2994 features->device_type |= WACOM_DEVICETYPE_PAD;
2997 /* touch device found but size is not defined. use default */
2998 if (features->device_type & WACOM_DEVICETYPE_TOUCH && !features->x_max) {
2999 features->x_max = 1023;
3000 features->y_max = 1023;
3004 * Intuos5/Pro and Bamboo 3rd gen have no useful data about its
3005 * touch interface in its HID descriptor. If this is the touch
3006 * interface (PacketSize of WACOM_PKGLEN_BBTOUCH3), override the
3009 if ((features->type >= INTUOS5S && features->type <= INTUOSPL) ||
3010 (features->type >= INTUOSHT && features->type <= BAMBOO_PT)) {
3011 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
3012 if (features->touch_max)
3013 features->device_type |= WACOM_DEVICETYPE_TOUCH;
3014 if (features->type >= INTUOSHT && features->type <= BAMBOO_PT)
3015 features->device_type |= WACOM_DEVICETYPE_PAD;
3017 features->x_max = 4096;
3018 features->y_max = 4096;
3020 else if (features->pktlen == WACOM_PKGLEN_BBTOUCH) {
3021 features->device_type |= WACOM_DEVICETYPE_PAD;
3026 * Hack for the Bamboo One:
3027 * the device presents a PAD/Touch interface as most Bamboos and even
3028 * sends ghosts PAD data on it. However, later, we must disable this
3029 * ghost interface, and we can not detect it unless we set it here
3030 * to WACOM_DEVICETYPE_PAD or WACOM_DEVICETYPE_TOUCH.
3032 if (features->type == BAMBOO_PEN &&
3033 features->pktlen == WACOM_PKGLEN_BBTOUCH3)
3034 features->device_type |= WACOM_DEVICETYPE_PAD;
3037 * Raw Wacom-mode pen and touch events both come from interface
3038 * 0, whose HID descriptor has an application usage of 0xFF0D
3039 * (i.e., WACOM_HID_WD_DIGITIZER). We route pen packets back
3040 * out through the HID_GENERIC device created for interface 1,
3041 * so rewrite this one to be of type WACOM_DEVICETYPE_TOUCH.
3043 if (features->type == BAMBOO_PAD)
3044 features->device_type = WACOM_DEVICETYPE_TOUCH;
3046 if (features->type == REMOTE)
3047 features->device_type = WACOM_DEVICETYPE_PAD;
3049 if (features->type == INTUOSP2_BT) {
3050 features->device_type |= WACOM_DEVICETYPE_PEN |
3051 WACOM_DEVICETYPE_PAD |
3052 WACOM_DEVICETYPE_TOUCH;
3053 features->quirks |= WACOM_QUIRK_BATTERY;
3056 switch (features->type) {
3067 case CINTIQ_COMPANION_2:
3079 features->device_type |= WACOM_DEVICETYPE_DIRECT;
3083 if (wacom->hdev->bus == BUS_BLUETOOTH)
3084 features->quirks |= WACOM_QUIRK_BATTERY;
3086 /* quirk for bamboo touch with 2 low res touches */
3087 if ((features->type == BAMBOO_PT || features->type == BAMBOO_TOUCH) &&
3088 features->pktlen == WACOM_PKGLEN_BBTOUCH) {
3089 features->x_max <<= 5;
3090 features->y_max <<= 5;
3091 features->x_fuzz <<= 5;
3092 features->y_fuzz <<= 5;
3093 features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;
3096 if (features->type == WIRELESS) {
3097 if (features->device_type == WACOM_DEVICETYPE_WL_MONITOR) {
3098 features->quirks |= WACOM_QUIRK_BATTERY;
3102 if (features->type == REMOTE)
3103 features->device_type |= WACOM_DEVICETYPE_WL_MONITOR;
3106 int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
3107 struct wacom_wac *wacom_wac)
3109 struct wacom_features *features = &wacom_wac->features;
3111 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3113 if (!(features->device_type & WACOM_DEVICETYPE_PEN))
3116 if (features->device_type & WACOM_DEVICETYPE_DIRECT)
3117 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
3119 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
3121 if (features->type == HID_GENERIC)
3122 /* setup has already been done */
3125 __set_bit(BTN_TOUCH, input_dev->keybit);
3126 __set_bit(ABS_MISC, input_dev->absbit);
3128 input_set_abs_params(input_dev, ABS_X, 0 + features->offset_left,
3129 features->x_max - features->offset_right,
3130 features->x_fuzz, 0);
3131 input_set_abs_params(input_dev, ABS_Y, 0 + features->offset_top,
3132 features->y_max - features->offset_bottom,
3133 features->y_fuzz, 0);
3134 input_set_abs_params(input_dev, ABS_PRESSURE, 0,
3135 features->pressure_max, features->pressure_fuzz, 0);
3137 /* penabled devices have fixed resolution for each model */
3138 input_abs_set_res(input_dev, ABS_X, features->x_resolution);
3139 input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
3141 switch (features->type) {
3143 __clear_bit(ABS_MISC, input_dev->absbit);
3147 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3148 features->distance_max,
3149 features->distance_fuzz, 0);
3153 input_set_capability(input_dev, EV_REL, REL_WHEEL);
3155 __set_bit(BTN_LEFT, input_dev->keybit);
3156 __set_bit(BTN_RIGHT, input_dev->keybit);
3157 __set_bit(BTN_MIDDLE, input_dev->keybit);
3159 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3160 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3161 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
3162 __set_bit(BTN_STYLUS, input_dev->keybit);
3163 __set_bit(BTN_STYLUS2, input_dev->keybit);
3175 case CINTIQ_COMPANION_2:
3176 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3177 input_abs_set_res(input_dev, ABS_Z, 287);
3178 wacom_setup_cintiq(wacom_wac);
3188 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3189 input_abs_set_res(input_dev, ABS_Z, 287);
3193 wacom_setup_intuos(wacom_wac);
3203 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3204 features->distance_max,
3205 features->distance_fuzz, 0);
3207 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
3208 input_abs_set_res(input_dev, ABS_Z, 287);
3210 wacom_setup_intuos(wacom_wac);
3221 __clear_bit(ABS_MISC, input_dev->absbit);
3228 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3229 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3230 __set_bit(BTN_STYLUS, input_dev->keybit);
3231 __set_bit(BTN_STYLUS2, input_dev->keybit);
3235 __set_bit(BTN_STYLUS2, input_dev->keybit);
3239 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3240 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3241 __set_bit(BTN_STYLUS, input_dev->keybit);
3248 if (features->type == INTUOSHT2) {
3249 wacom_setup_basic_pro_pen(wacom_wac);
3251 __clear_bit(ABS_MISC, input_dev->absbit);
3252 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
3253 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
3254 __set_bit(BTN_STYLUS, input_dev->keybit);
3255 __set_bit(BTN_STYLUS2, input_dev->keybit);
3256 input_set_abs_params(input_dev, ABS_DISTANCE, 0,
3257 features->distance_max,
3258 features->distance_fuzz, 0);
3262 __clear_bit(ABS_MISC, input_dev->absbit);
3268 int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
3269 struct wacom_wac *wacom_wac)
3271 struct wacom_features *features = &wacom_wac->features;
3273 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3275 if (!(features->device_type & WACOM_DEVICETYPE_TOUCH))
3278 if (features->device_type & WACOM_DEVICETYPE_DIRECT)
3279 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
3281 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
3283 if (features->type == HID_GENERIC)
3284 /* setup has already been done */
3287 __set_bit(BTN_TOUCH, input_dev->keybit);
3289 if (features->touch_max == 1) {
3290 input_set_abs_params(input_dev, ABS_X, 0,
3291 features->x_max, features->x_fuzz, 0);
3292 input_set_abs_params(input_dev, ABS_Y, 0,
3293 features->y_max, features->y_fuzz, 0);
3294 input_abs_set_res(input_dev, ABS_X,
3295 features->x_resolution);
3296 input_abs_set_res(input_dev, ABS_Y,
3297 features->y_resolution);
3299 else if (features->touch_max > 1) {
3300 input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
3301 features->x_max, features->x_fuzz, 0);
3302 input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
3303 features->y_max, features->y_fuzz, 0);
3304 input_abs_set_res(input_dev, ABS_MT_POSITION_X,
3305 features->x_resolution);
3306 input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
3307 features->y_resolution);
3310 switch (features->type) {
3312 input_dev->evbit[0] |= BIT_MASK(EV_SW);
3313 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
3315 if (wacom_wac->shared->touch->product == 0x361) {
3316 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
3318 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
3321 else if (wacom_wac->shared->touch->product == 0x360) {
3322 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
3324 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
3327 input_abs_set_res(input_dev, ABS_MT_POSITION_X, 40);
3328 input_abs_set_res(input_dev, ABS_MT_POSITION_X, 40);
3338 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
3339 input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, features->y_max, 0, 0);
3340 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
3344 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
3345 input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
3346 input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
3347 input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
3355 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT);
3364 input_dev->evbit[0] |= BIT_MASK(EV_SW);
3365 __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
3370 if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
3371 input_set_abs_params(input_dev,
3373 0, features->x_max, 0, 0);
3374 input_set_abs_params(input_dev,
3376 0, features->y_max, 0, 0);
3378 input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
3382 input_mt_init_slots(input_dev, features->touch_max,
3384 __set_bit(BTN_LEFT, input_dev->keybit);
3385 __set_bit(BTN_RIGHT, input_dev->keybit);
3391 static int wacom_numbered_button_to_key(int n)
3396 return BTN_A + (n-10);
3398 return BTN_BASE + (n-16);
3403 static void wacom_setup_numbered_buttons(struct input_dev *input_dev,
3408 for (i = 0; i < button_count; i++) {
3409 int key = wacom_numbered_button_to_key(i);
3412 __set_bit(key, input_dev->keybit);
3416 static void wacom_24hd_update_leds(struct wacom *wacom, int mask, int group)
3418 struct wacom_led *led;
3420 bool updated = false;
3423 * 24HD has LED group 1 to the left and LED group 0 to the right.
3424 * So group 0 matches the second half of the buttons and thus the mask
3425 * needs to be shifted.
3430 for (i = 0; i < 3; i++) {
3431 led = wacom_led_find(wacom, group, i);
3433 hid_err(wacom->hdev, "can't find LED %d in group %d\n",
3437 if (!updated && mask & BIT(i)) {
3439 led_trigger_event(&led->trigger, LED_FULL);
3446 static bool wacom_is_led_toggled(struct wacom *wacom, int button_count,
3447 int mask, int group)
3449 int button_per_group;
3452 * 21UX2 has LED group 1 to the left and LED group 0
3453 * to the right. We need to reverse the group to match this
3454 * historical behavior.
3456 if (wacom->wacom_wac.features.type == WACOM_21UX2)
3459 button_per_group = button_count/wacom->led.count;
3461 return mask & (1 << (group * button_per_group));
3464 static void wacom_update_led(struct wacom *wacom, int button_count, int mask,
3467 struct wacom_led *led, *next_led;
3471 if (wacom->wacom_wac.features.type == WACOM_24HD)
3472 return wacom_24hd_update_leds(wacom, mask, group);
3474 pressed = wacom_is_led_toggled(wacom, button_count, mask, group);
3475 cur = wacom->led.groups[group].select;
3477 led = wacom_led_find(wacom, group, cur);
3479 hid_err(wacom->hdev, "can't find current LED %d in group %d\n",
3489 if (led->held && pressed)
3492 next_led = wacom_led_next(wacom, led);
3494 hid_err(wacom->hdev, "can't find next LED in group %d\n",
3498 if (next_led == led)
3501 next_led->held = true;
3502 led_trigger_event(&next_led->trigger,
3503 wacom_leds_brightness_get(next_led));
3506 static void wacom_report_numbered_buttons(struct input_dev *input_dev,
3507 int button_count, int mask)
3509 struct wacom *wacom = input_get_drvdata(input_dev);
3512 for (i = 0; i < wacom->led.count; i++)
3513 wacom_update_led(wacom, button_count, mask, i);
3515 for (i = 0; i < button_count; i++) {
3516 int key = wacom_numbered_button_to_key(i);
3519 input_report_key(input_dev, key, mask & (1 << i));
3523 int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
3524 struct wacom_wac *wacom_wac)
3526 struct wacom_features *features = &wacom_wac->features;
3528 if ((features->type == HID_GENERIC) && features->numbered_buttons > 0)
3529 features->device_type |= WACOM_DEVICETYPE_PAD;
3531 if (!(features->device_type & WACOM_DEVICETYPE_PAD))
3534 if (features->type == REMOTE && input_dev == wacom_wac->pad_input)
3537 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
3539 /* kept for making legacy xf86-input-wacom working with the wheels */
3540 __set_bit(ABS_MISC, input_dev->absbit);
3542 /* kept for making legacy xf86-input-wacom accepting the pad */
3543 if (!(input_dev->absinfo && (input_dev->absinfo[ABS_X].minimum ||
3544 input_dev->absinfo[ABS_X].maximum)))
3545 input_set_abs_params(input_dev, ABS_X, 0, 1, 0, 0);
3546 if (!(input_dev->absinfo && (input_dev->absinfo[ABS_Y].minimum ||
3547 input_dev->absinfo[ABS_Y].maximum)))
3548 input_set_abs_params(input_dev, ABS_Y, 0, 1, 0, 0);
3550 /* kept for making udev and libwacom accepting the pad */
3551 __set_bit(BTN_STYLUS, input_dev->keybit);
3553 wacom_setup_numbered_buttons(input_dev, features->numbered_buttons);
3555 switch (features->type) {
3558 case CINTIQ_COMPANION_2:
3565 __set_bit(BTN_BACK, input_dev->keybit);
3566 __set_bit(BTN_LEFT, input_dev->keybit);
3567 __set_bit(BTN_FORWARD, input_dev->keybit);
3568 __set_bit(BTN_RIGHT, input_dev->keybit);
3569 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
3573 __set_bit(BTN_BACK, input_dev->keybit);
3574 __set_bit(BTN_FORWARD, input_dev->keybit);
3575 input_set_capability(input_dev, EV_REL, REL_WHEEL);
3579 __set_bit(KEY_PROG1, input_dev->keybit);
3580 __set_bit(KEY_PROG2, input_dev->keybit);
3581 __set_bit(KEY_PROG3, input_dev->keybit);
3583 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
3584 input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
3588 __set_bit(KEY_PROG1, input_dev->keybit);
3589 __set_bit(KEY_PROG2, input_dev->keybit);
3590 __set_bit(KEY_PROG3, input_dev->keybit);
3591 input_set_abs_params(input_dev, ABS_X, -2048, 2048, 0, 0);
3592 input_abs_set_res(input_dev, ABS_X, 1024); /* points/g */
3593 input_set_abs_params(input_dev, ABS_Y, -2048, 2048, 0, 0);
3594 input_abs_set_res(input_dev, ABS_Y, 1024);
3595 input_set_abs_params(input_dev, ABS_Z, -2048, 2048, 0, 0);
3596 input_abs_set_res(input_dev, ABS_Z, 1024);
3597 __set_bit(INPUT_PROP_ACCELEROMETER, input_dev->propbit);
3601 __set_bit(KEY_PROG1, input_dev->keybit);
3602 __set_bit(KEY_PROG2, input_dev->keybit);
3603 __set_bit(KEY_PROG3, input_dev->keybit);
3609 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
3610 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
3614 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
3619 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
3623 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
3633 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
3638 * For Bluetooth devices, the udev rule does not work correctly
3639 * for pads unless we add a stylus capability, which forces
3640 * ID_INPUT_TABLET to be set.
3642 __set_bit(BTN_STYLUS, input_dev->keybit);
3648 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
3655 __clear_bit(ABS_MISC, input_dev->absbit);
3657 __set_bit(BTN_LEFT, input_dev->keybit);
3658 __set_bit(BTN_FORWARD, input_dev->keybit);
3659 __set_bit(BTN_BACK, input_dev->keybit);
3660 __set_bit(BTN_RIGHT, input_dev->keybit);
3665 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
3666 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
3673 /* no pad supported */
3679 static const struct wacom_features wacom_features_0x00 =
3680 { "Wacom Penpartner", 5040, 3780, 255, 0,
3681 PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
3682 static const struct wacom_features wacom_features_0x10 =
3683 { "Wacom Graphire", 10206, 7422, 511, 63,
3684 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
3685 static const struct wacom_features wacom_features_0x81 =
3686 { "Wacom Graphire BT", 16704, 12064, 511, 32,
3687 GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES, 2 };
3688 static const struct wacom_features wacom_features_0x11 =
3689 { "Wacom Graphire2 4x5", 10206, 7422, 511, 63,
3690 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
3691 static const struct wacom_features wacom_features_0x12 =
3692 { "Wacom Graphire2 5x7", 13918, 10206, 511, 63,
3693 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
3694 static const struct wacom_features wacom_features_0x13 =
3695 { "Wacom Graphire3", 10208, 7424, 511, 63,
3696 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
3697 static const struct wacom_features wacom_features_0x14 =
3698 { "Wacom Graphire3 6x8", 16704, 12064, 511, 63,
3699 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
3700 static const struct wacom_features wacom_features_0x15 =
3701 { "Wacom Graphire4 4x5", 10208, 7424, 511, 63,
3702 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
3703 static const struct wacom_features wacom_features_0x16 =
3704 { "Wacom Graphire4 6x8", 16704, 12064, 511, 63,
3705 WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
3706 static const struct wacom_features wacom_features_0x17 =
3707 { "Wacom BambooFun 4x5", 14760, 9225, 511, 63,
3708 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
3709 static const struct wacom_features wacom_features_0x18 =
3710 { "Wacom BambooFun 6x8", 21648, 13530, 511, 63,
3711 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
3712 static const struct wacom_features wacom_features_0x19 =
3713 { "Wacom Bamboo1 Medium", 16704, 12064, 511, 63,
3714 GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
3715 static const struct wacom_features wacom_features_0x60 =
3716 { "Wacom Volito", 5104, 3712, 511, 63,
3717 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
3718 static const struct wacom_features wacom_features_0x61 =
3719 { "Wacom PenStation2", 3250, 2320, 255, 63,
3720 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
3721 static const struct wacom_features wacom_features_0x62 =
3722 { "Wacom Volito2 4x5", 5104, 3712, 511, 63,
3723 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
3724 static const struct wacom_features wacom_features_0x63 =
3725 { "Wacom Volito2 2x3", 3248, 2320, 511, 63,
3726 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
3727 static const struct wacom_features wacom_features_0x64 =
3728 { "Wacom PenPartner2", 3250, 2320, 511, 63,
3729 GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
3730 static const struct wacom_features wacom_features_0x65 =
3731 { "Wacom Bamboo", 14760, 9225, 511, 63,
3732 WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
3733 static const struct wacom_features wacom_features_0x69 =
3734 { "Wacom Bamboo1", 5104, 3712, 511, 63,
3735 GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
3736 static const struct wacom_features wacom_features_0x6A =
3737 { "Wacom Bamboo1 4x6", 14760, 9225, 1023, 63,
3738 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
3739 static const struct wacom_features wacom_features_0x6B =
3740 { "Wacom Bamboo1 5x8", 21648, 13530, 1023, 63,
3741 GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
3742 static const struct wacom_features wacom_features_0x20 =
3743 { "Wacom Intuos 4x5", 12700, 10600, 1023, 31,
3744 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
3745 static const struct wacom_features wacom_features_0x21 =
3746 { "Wacom Intuos 6x8", 20320, 16240, 1023, 31,
3747 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
3748 static const struct wacom_features wacom_features_0x22 =
3749 { "Wacom Intuos 9x12", 30480, 24060, 1023, 31,
3750 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
3751 static const struct wacom_features wacom_features_0x23 =
3752 { "Wacom Intuos 12x12", 30480, 31680, 1023, 31,
3753 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
3754 static const struct wacom_features wacom_features_0x24 =
3755 { "Wacom Intuos 12x18", 45720, 31680, 1023, 31,
3756 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
3757 static const struct wacom_features wacom_features_0x30 =
3758 { "Wacom PL400", 5408, 4056, 255, 0,
3759 PL, WACOM_PL_RES, WACOM_PL_RES };
3760 static const struct wacom_features wacom_features_0x31 =
3761 { "Wacom PL500", 6144, 4608, 255, 0,
3762 PL, WACOM_PL_RES, WACOM_PL_RES };
3763 static const struct wacom_features wacom_features_0x32 =
3764 { "Wacom PL600", 6126, 4604, 255, 0,
3765 PL, WACOM_PL_RES, WACOM_PL_RES };
3766 static const struct wacom_features wacom_features_0x33 =
3767 { "Wacom PL600SX", 6260, 5016, 255, 0,
3768 PL, WACOM_PL_RES, WACOM_PL_RES };
3769 static const struct wacom_features wacom_features_0x34 =
3770 { "Wacom PL550", 6144, 4608, 511, 0,
3771 PL, WACOM_PL_RES, WACOM_PL_RES };
3772 static const struct wacom_features wacom_features_0x35 =
3773 { "Wacom PL800", 7220, 5780, 511, 0,
3774 PL, WACOM_PL_RES, WACOM_PL_RES };
3775 static const struct wacom_features wacom_features_0x37 =
3776 { "Wacom PL700", 6758, 5406, 511, 0,
3777 PL, WACOM_PL_RES, WACOM_PL_RES };
3778 static const struct wacom_features wacom_features_0x38 =
3779 { "Wacom PL510", 6282, 4762, 511, 0,
3780 PL, WACOM_PL_RES, WACOM_PL_RES };
3781 static const struct wacom_features wacom_features_0x39 =
3782 { "Wacom DTU710", 34080, 27660, 511, 0,
3783 PL, WACOM_PL_RES, WACOM_PL_RES };
3784 static const struct wacom_features wacom_features_0xC4 =
3785 { "Wacom DTF521", 6282, 4762, 511, 0,
3786 PL, WACOM_PL_RES, WACOM_PL_RES };
3787 static const struct wacom_features wacom_features_0xC0 =
3788 { "Wacom DTF720", 6858, 5506, 511, 0,
3789 PL, WACOM_PL_RES, WACOM_PL_RES };
3790 static const struct wacom_features wacom_features_0xC2 =
3791 { "Wacom DTF720a", 6858, 5506, 511, 0,
3792 PL, WACOM_PL_RES, WACOM_PL_RES };
3793 static const struct wacom_features wacom_features_0x03 =
3794 { "Wacom Cintiq Partner", 20480, 15360, 511, 0,
3795 PTU, WACOM_PL_RES, WACOM_PL_RES };
3796 static const struct wacom_features wacom_features_0x41 =
3797 { "Wacom Intuos2 4x5", 12700, 10600, 1023, 31,
3798 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
3799 static const struct wacom_features wacom_features_0x42 =
3800 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
3801 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
3802 static const struct wacom_features wacom_features_0x43 =
3803 { "Wacom Intuos2 9x12", 30480, 24060, 1023, 31,
3804 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
3805 static const struct wacom_features wacom_features_0x44 =
3806 { "Wacom Intuos2 12x12", 30480, 31680, 1023, 31,
3807 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
3808 static const struct wacom_features wacom_features_0x45 =
3809 { "Wacom Intuos2 12x18", 45720, 31680, 1023, 31,
3810 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
3811 static const struct wacom_features wacom_features_0xB0 =
3812 { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63,
3813 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
3814 static const struct wacom_features wacom_features_0xB1 =
3815 { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63,
3816 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
3817 static const struct wacom_features wacom_features_0xB2 =
3818 { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63,
3819 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
3820 static const struct wacom_features wacom_features_0xB3 =
3821 { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63,
3822 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
3823 static const struct wacom_features wacom_features_0xB4 =
3824 { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63,
3825 INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
3826 static const struct wacom_features wacom_features_0xB5 =
3827 { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63,
3828 INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
3829 static const struct wacom_features wacom_features_0xB7 =
3830 { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63,
3831 INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
3832 static const struct wacom_features wacom_features_0xB8 =
3833 { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63,
3834 INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
3835 static const struct wacom_features wacom_features_0xB9 =
3836 { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63,
3837 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
3838 static const struct wacom_features wacom_features_0xBA =
3839 { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63,
3840 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
3841 static const struct wacom_features wacom_features_0xBB =
3842 { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63,
3843 INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
3844 static const struct wacom_features wacom_features_0xBC =
3845 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
3846 INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
3847 static const struct wacom_features wacom_features_0xBD =
3848 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
3849 INTUOS4WL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
3850 static const struct wacom_features wacom_features_0x26 =
3851 { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63,
3852 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16 };
3853 static const struct wacom_features wacom_features_0x27 =
3854 { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63,
3855 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
3856 static const struct wacom_features wacom_features_0x28 =
3857 { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63,
3858 INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
3859 static const struct wacom_features wacom_features_0x29 =
3860 { "Wacom Intuos5 S", 31496, 19685, 2047, 63,
3861 INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
3862 static const struct wacom_features wacom_features_0x2A =
3863 { "Wacom Intuos5 M", 44704, 27940, 2047, 63,
3864 INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
3865 static const struct wacom_features wacom_features_0x314 =
3866 { "Wacom Intuos Pro S", 31496, 19685, 2047, 63,
3867 INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16,
3868 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
3869 static const struct wacom_features wacom_features_0x315 =
3870 { "Wacom Intuos Pro M", 44704, 27940, 2047, 63,
3871 INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
3872 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
3873 static const struct wacom_features wacom_features_0x317 =
3874 { "Wacom Intuos Pro L", 65024, 40640, 2047, 63,
3875 INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
3876 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
3877 static const struct wacom_features wacom_features_0xF4 =
3878 { "Wacom Cintiq 24HD", 104480, 65600, 2047, 63,
3879 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
3880 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
3881 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
3882 static const struct wacom_features wacom_features_0xF8 =
3883 { "Wacom Cintiq 24HD touch", 104480, 65600, 2047, 63, /* Pen */
3884 WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
3885 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
3886 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
3887 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 };
3888 static const struct wacom_features wacom_features_0xF6 =
3889 { "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */
3890 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10,
3891 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
3892 static const struct wacom_features wacom_features_0x32A =
3893 { "Wacom Cintiq 27QHD", 120140, 67920, 2047, 63,
3894 WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
3895 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
3896 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
3897 static const struct wacom_features wacom_features_0x32B =
3898 { "Wacom Cintiq 27QHD touch", 120140, 67920, 2047, 63,
3899 WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
3900 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
3901 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
3902 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32C };
3903 static const struct wacom_features wacom_features_0x32C =
3904 { "Wacom Cintiq 27QHD touch", .type = WACOM_27QHDT,
3905 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32B, .touch_max = 10 };
3906 static const struct wacom_features wacom_features_0x3F =
3907 { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63,
3908 CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
3909 static const struct wacom_features wacom_features_0xC5 =
3910 { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63,
3911 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
3912 static const struct wacom_features wacom_features_0xC6 =
3913 { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63,
3914 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
3915 static const struct wacom_features wacom_features_0x304 =
3916 { "Wacom Cintiq 13HD", 59552, 33848, 1023, 63,
3917 WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
3918 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
3919 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
3920 static const struct wacom_features wacom_features_0x333 =
3921 { "Wacom Cintiq 13HD touch", 59552, 33848, 2047, 63,
3922 WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
3923 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
3924 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
3925 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x335 };
3926 static const struct wacom_features wacom_features_0x335 =
3927 { "Wacom Cintiq 13HD touch", .type = WACOM_24HDT, /* Touch */
3928 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x333, .touch_max = 10,
3929 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
3930 static const struct wacom_features wacom_features_0xC7 =
3931 { "Wacom DTU1931", 37832, 30305, 511, 0,
3932 PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
3933 static const struct wacom_features wacom_features_0xCE =
3934 { "Wacom DTU2231", 47864, 27011, 511, 0,
3935 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
3936 .check_for_hid_type = true, .hid_type = HID_TYPE_USBMOUSE };
3937 static const struct wacom_features wacom_features_0xF0 =
3938 { "Wacom DTU1631", 34623, 19553, 511, 0,
3939 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
3940 static const struct wacom_features wacom_features_0xFB =
3941 { "Wacom DTU1031", 22096, 13960, 511, 0,
3942 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
3943 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
3944 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
3945 static const struct wacom_features wacom_features_0x32F =
3946 { "Wacom DTU1031X", 22672, 12928, 511, 0,
3947 DTUSX, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 0,
3948 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
3949 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
3950 static const struct wacom_features wacom_features_0x336 =
3951 { "Wacom DTU1141", 23672, 13403, 1023, 0,
3952 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
3953 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
3954 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
3955 static const struct wacom_features wacom_features_0x57 =
3956 { "Wacom DTK2241", 95840, 54260, 2047, 63,
3957 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
3958 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
3959 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
3960 static const struct wacom_features wacom_features_0x59 = /* Pen */
3961 { "Wacom DTH2242", 95840, 54260, 2047, 63,
3962 DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
3963 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
3964 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
3965 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D };
3966 static const struct wacom_features wacom_features_0x5D = /* Touch */
3967 { "Wacom DTH2242", .type = WACOM_24HDT,
3968 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10,
3969 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
3970 static const struct wacom_features wacom_features_0xCC =
3971 { "Wacom Cintiq 21UX2", 87200, 65600, 2047, 63,
3972 WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
3973 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
3974 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
3975 static const struct wacom_features wacom_features_0xFA =
3976 { "Wacom Cintiq 22HD", 95840, 54260, 2047, 63,
3977 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
3978 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
3979 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
3980 static const struct wacom_features wacom_features_0x5B =
3981 { "Wacom Cintiq 22HDT", 95840, 54260, 2047, 63,
3982 WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
3983 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
3984 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
3985 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e };
3986 static const struct wacom_features wacom_features_0x5E =
3987 { "Wacom Cintiq 22HDT", .type = WACOM_24HDT,
3988 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5b, .touch_max = 10,
3989 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
3990 static const struct wacom_features wacom_features_0x90 =
3991 { "Wacom ISDv4 90", 26202, 16325, 255, 0,
3992 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
3993 static const struct wacom_features wacom_features_0x93 =
3994 { "Wacom ISDv4 93", 26202, 16325, 255, 0,
3995 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
3996 static const struct wacom_features wacom_features_0x97 =
3997 { "Wacom ISDv4 97", 26202, 16325, 511, 0,
3998 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
3999 static const struct wacom_features wacom_features_0x9A =
4000 { "Wacom ISDv4 9A", 26202, 16325, 255, 0,
4001 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4002 static const struct wacom_features wacom_features_0x9F =
4003 { "Wacom ISDv4 9F", 26202, 16325, 255, 0,
4004 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4005 static const struct wacom_features wacom_features_0xE2 =
4006 { "Wacom ISDv4 E2", 26202, 16325, 255, 0,
4007 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4008 static const struct wacom_features wacom_features_0xE3 =
4009 { "Wacom ISDv4 E3", 26202, 16325, 255, 0,
4010 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4011 static const struct wacom_features wacom_features_0xE5 =
4012 { "Wacom ISDv4 E5", 26202, 16325, 255, 0,
4013 MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4014 static const struct wacom_features wacom_features_0xE6 =
4015 { "Wacom ISDv4 E6", 27760, 15694, 255, 0,
4016 TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4017 static const struct wacom_features wacom_features_0xEC =
4018 { "Wacom ISDv4 EC", 25710, 14500, 255, 0,
4019 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4020 static const struct wacom_features wacom_features_0xED =
4021 { "Wacom ISDv4 ED", 26202, 16325, 255, 0,
4022 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4023 static const struct wacom_features wacom_features_0xEF =
4024 { "Wacom ISDv4 EF", 26202, 16325, 255, 0,
4025 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4026 static const struct wacom_features wacom_features_0x100 =
4027 { "Wacom ISDv4 100", 26202, 16325, 255, 0,
4028 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4029 static const struct wacom_features wacom_features_0x101 =
4030 { "Wacom ISDv4 101", 26202, 16325, 255, 0,
4031 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4032 static const struct wacom_features wacom_features_0x10D =
4033 { "Wacom ISDv4 10D", 26202, 16325, 255, 0,
4034 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4035 static const struct wacom_features wacom_features_0x10E =
4036 { "Wacom ISDv4 10E", 27760, 15694, 255, 0,
4037 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4038 static const struct wacom_features wacom_features_0x10F =
4039 { "Wacom ISDv4 10F", 27760, 15694, 255, 0,
4040 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4041 static const struct wacom_features wacom_features_0x116 =
4042 { "Wacom ISDv4 116", 26202, 16325, 255, 0,
4043 TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4044 static const struct wacom_features wacom_features_0x12C =
4045 { "Wacom ISDv4 12C", 27848, 15752, 2047, 0,
4046 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4047 static const struct wacom_features wacom_features_0x4001 =
4048 { "Wacom ISDv4 4001", 26202, 16325, 255, 0,
4049 MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4050 static const struct wacom_features wacom_features_0x4004 =
4051 { "Wacom ISDv4 4004", 11060, 6220, 255, 0,
4052 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4053 static const struct wacom_features wacom_features_0x5000 =
4054 { "Wacom ISDv4 5000", 27848, 15752, 1023, 0,
4055 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4056 static const struct wacom_features wacom_features_0x5002 =
4057 { "Wacom ISDv4 5002", 29576, 16724, 1023, 0,
4058 MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4059 static const struct wacom_features wacom_features_0x47 =
4060 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
4061 INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4062 static const struct wacom_features wacom_features_0x84 =
4063 { "Wacom Wireless Receiver", .type = WIRELESS, .touch_max = 16 };
4064 static const struct wacom_features wacom_features_0xD0 =
4065 { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31,
4066 BAMBOO_TOUCH, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4067 static const struct wacom_features wacom_features_0xD1 =
4068 { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31,
4069 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4070 static const struct wacom_features wacom_features_0xD2 =
4071 { "Wacom Bamboo Craft", 14720, 9200, 1023, 31,
4072 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4073 static const struct wacom_features wacom_features_0xD3 =
4074 { "Wacom Bamboo 2FG 6x8", 21648, 13700, 1023, 31,
4075 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4076 static const struct wacom_features wacom_features_0xD4 =
4077 { "Wacom Bamboo Pen", 14720, 9200, 1023, 31,
4078 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4079 static const struct wacom_features wacom_features_0xD5 =
4080 { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31,
4081 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4082 static const struct wacom_features wacom_features_0xD6 =
4083 { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31,
4084 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4085 static const struct wacom_features wacom_features_0xD7 =
4086 { "Wacom BambooPT 2FG Small", 14720, 9200, 1023, 31,
4087 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4088 static const struct wacom_features wacom_features_0xD8 =
4089 { "Wacom Bamboo Comic 2FG", 21648, 13700, 1023, 31,
4090 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4091 static const struct wacom_features wacom_features_0xDA =
4092 { "Wacom Bamboo 2FG 4x5 SE", 14720, 9200, 1023, 31,
4093 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4094 static const struct wacom_features wacom_features_0xDB =
4095 { "Wacom Bamboo 2FG 6x8 SE", 21648, 13700, 1023, 31,
4096 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
4097 static const struct wacom_features wacom_features_0xDD =
4098 { "Wacom Bamboo Connect", 14720, 9200, 1023, 31,
4099 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4100 static const struct wacom_features wacom_features_0xDE =
4101 { "Wacom Bamboo 16FG 4x5", 14720, 9200, 1023, 31,
4102 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
4103 static const struct wacom_features wacom_features_0xDF =
4104 { "Wacom Bamboo 16FG 6x8", 21648, 13700, 1023, 31,
4105 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
4106 static const struct wacom_features wacom_features_0x300 =
4107 { "Wacom Bamboo One S", 14720, 9225, 1023, 31,
4108 BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4109 static const struct wacom_features wacom_features_0x301 =
4110 { "Wacom Bamboo One M", 21648, 13530, 1023, 31,
4111 BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4112 static const struct wacom_features wacom_features_0x302 =
4113 { "Wacom Intuos PT S", 15200, 9500, 1023, 31,
4114 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4115 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4116 static const struct wacom_features wacom_features_0x303 =
4117 { "Wacom Intuos PT M", 21600, 13500, 1023, 31,
4118 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4119 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4120 static const struct wacom_features wacom_features_0x30E =
4121 { "Wacom Intuos S", 15200, 9500, 1023, 31,
4122 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4123 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4124 static const struct wacom_features wacom_features_0x6004 =
4125 { "ISD-V4", 12800, 8000, 255, 0,
4126 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
4127 static const struct wacom_features wacom_features_0x307 =
4128 { "Wacom ISDv5 307", 59552, 33848, 2047, 63,
4129 CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4130 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4131 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4132 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 };
4133 static const struct wacom_features wacom_features_0x309 =
4134 { "Wacom ISDv5 309", .type = WACOM_24HDT, /* Touch */
4135 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x0307, .touch_max = 10,
4136 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4137 static const struct wacom_features wacom_features_0x30A =
4138 { "Wacom ISDv5 30A", 59552, 33848, 2047, 63,
4139 CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
4140 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4141 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4142 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30C };
4143 static const struct wacom_features wacom_features_0x30C =
4144 { "Wacom ISDv5 30C", .type = WACOM_24HDT, /* Touch */
4145 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30A, .touch_max = 10,
4146 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4147 static const struct wacom_features wacom_features_0x318 =
4148 { "Wacom USB Bamboo PAD", 4095, 4095, /* Touch */
4149 .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
4150 static const struct wacom_features wacom_features_0x319 =
4151 { "Wacom Wireless Bamboo PAD", 4095, 4095, /* Touch */
4152 .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
4153 static const struct wacom_features wacom_features_0x325 =
4154 { "Wacom ISDv5 325", 59552, 33848, 2047, 63,
4155 CINTIQ_COMPANION_2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 11,
4156 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4157 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
4158 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x326 };
4159 static const struct wacom_features wacom_features_0x326 = /* Touch */
4160 { "Wacom ISDv5 326", .type = HID_GENERIC, .oVid = USB_VENDOR_ID_WACOM,
4162 static const struct wacom_features wacom_features_0x323 =
4163 { "Wacom Intuos P M", 21600, 13500, 1023, 31,
4164 INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4165 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4166 static const struct wacom_features wacom_features_0x331 =
4167 { "Wacom Express Key Remote", .type = REMOTE,
4168 .numbered_buttons = 18, .check_for_hid_type = true,
4169 .hid_type = HID_TYPE_USBNONE };
4170 static const struct wacom_features wacom_features_0x33B =
4171 { "Wacom Intuos S 2", 15200, 9500, 2047, 63,
4172 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4173 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4174 static const struct wacom_features wacom_features_0x33C =
4175 { "Wacom Intuos PT S 2", 15200, 9500, 2047, 63,
4176 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4177 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4178 static const struct wacom_features wacom_features_0x33D =
4179 { "Wacom Intuos P M 2", 21600, 13500, 2047, 63,
4180 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
4181 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4182 static const struct wacom_features wacom_features_0x33E =
4183 { "Wacom Intuos PT M 2", 21600, 13500, 2047, 63,
4184 INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
4185 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
4186 static const struct wacom_features wacom_features_0x343 =
4187 { "Wacom DTK1651", 34816, 19759, 1023, 0,
4188 DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
4189 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
4190 WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
4191 static const struct wacom_features wacom_features_0x360 =
4192 { "Wacom Intuos Pro M", 44800, 29600, 8191, 63,
4193 INTUOSP2_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 9, .touch_max = 10 };
4194 static const struct wacom_features wacom_features_0x361 =
4195 { "Wacom Intuos Pro L", 62200, 43200, 8191, 63,
4196 INTUOSP2_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 9, .touch_max = 10 };
4198 static const struct wacom_features wacom_features_HID_ANY_ID =
4199 { "Wacom HID", .type = HID_GENERIC, .oVid = HID_ANY_ID, .oPid = HID_ANY_ID };
4201 #define USB_DEVICE_WACOM(prod) \
4202 HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4203 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4205 #define BT_DEVICE_WACOM(prod) \
4206 HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4207 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4209 #define I2C_DEVICE_WACOM(prod) \
4210 HID_DEVICE(BUS_I2C, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4211 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4213 #define USB_DEVICE_LENOVO(prod) \
4214 HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
4215 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4217 const struct hid_device_id wacom_ids[] = {
4218 { USB_DEVICE_WACOM(0x00) },
4219 { USB_DEVICE_WACOM(0x03) },
4220 { USB_DEVICE_WACOM(0x10) },
4221 { USB_DEVICE_WACOM(0x11) },
4222 { USB_DEVICE_WACOM(0x12) },
4223 { USB_DEVICE_WACOM(0x13) },
4224 { USB_DEVICE_WACOM(0x14) },
4225 { USB_DEVICE_WACOM(0x15) },
4226 { USB_DEVICE_WACOM(0x16) },
4227 { USB_DEVICE_WACOM(0x17) },
4228 { USB_DEVICE_WACOM(0x18) },
4229 { USB_DEVICE_WACOM(0x19) },
4230 { USB_DEVICE_WACOM(0x20) },
4231 { USB_DEVICE_WACOM(0x21) },
4232 { USB_DEVICE_WACOM(0x22) },
4233 { USB_DEVICE_WACOM(0x23) },
4234 { USB_DEVICE_WACOM(0x24) },
4235 { USB_DEVICE_WACOM(0x26) },
4236 { USB_DEVICE_WACOM(0x27) },
4237 { USB_DEVICE_WACOM(0x28) },
4238 { USB_DEVICE_WACOM(0x29) },
4239 { USB_DEVICE_WACOM(0x2A) },
4240 { USB_DEVICE_WACOM(0x30) },
4241 { USB_DEVICE_WACOM(0x31) },
4242 { USB_DEVICE_WACOM(0x32) },
4243 { USB_DEVICE_WACOM(0x33) },
4244 { USB_DEVICE_WACOM(0x34) },
4245 { USB_DEVICE_WACOM(0x35) },
4246 { USB_DEVICE_WACOM(0x37) },
4247 { USB_DEVICE_WACOM(0x38) },
4248 { USB_DEVICE_WACOM(0x39) },
4249 { USB_DEVICE_WACOM(0x3F) },
4250 { USB_DEVICE_WACOM(0x41) },
4251 { USB_DEVICE_WACOM(0x42) },
4252 { USB_DEVICE_WACOM(0x43) },
4253 { USB_DEVICE_WACOM(0x44) },
4254 { USB_DEVICE_WACOM(0x45) },
4255 { USB_DEVICE_WACOM(0x47) },
4256 { USB_DEVICE_WACOM(0x57) },
4257 { USB_DEVICE_WACOM(0x59) },
4258 { USB_DEVICE_WACOM(0x5B) },
4259 { USB_DEVICE_WACOM(0x5D) },
4260 { USB_DEVICE_WACOM(0x5E) },
4261 { USB_DEVICE_WACOM(0x60) },
4262 { USB_DEVICE_WACOM(0x61) },
4263 { USB_DEVICE_WACOM(0x62) },
4264 { USB_DEVICE_WACOM(0x63) },
4265 { USB_DEVICE_WACOM(0x64) },
4266 { USB_DEVICE_WACOM(0x65) },
4267 { USB_DEVICE_WACOM(0x69) },
4268 { USB_DEVICE_WACOM(0x6A) },
4269 { USB_DEVICE_WACOM(0x6B) },
4270 { BT_DEVICE_WACOM(0x81) },
4271 { USB_DEVICE_WACOM(0x84) },
4272 { USB_DEVICE_WACOM(0x90) },
4273 { USB_DEVICE_WACOM(0x93) },
4274 { USB_DEVICE_WACOM(0x97) },
4275 { USB_DEVICE_WACOM(0x9A) },
4276 { USB_DEVICE_WACOM(0x9F) },
4277 { USB_DEVICE_WACOM(0xB0) },
4278 { USB_DEVICE_WACOM(0xB1) },
4279 { USB_DEVICE_WACOM(0xB2) },
4280 { USB_DEVICE_WACOM(0xB3) },
4281 { USB_DEVICE_WACOM(0xB4) },
4282 { USB_DEVICE_WACOM(0xB5) },
4283 { USB_DEVICE_WACOM(0xB7) },
4284 { USB_DEVICE_WACOM(0xB8) },
4285 { USB_DEVICE_WACOM(0xB9) },
4286 { USB_DEVICE_WACOM(0xBA) },
4287 { USB_DEVICE_WACOM(0xBB) },
4288 { USB_DEVICE_WACOM(0xBC) },
4289 { BT_DEVICE_WACOM(0xBD) },
4290 { USB_DEVICE_WACOM(0xC0) },
4291 { USB_DEVICE_WACOM(0xC2) },
4292 { USB_DEVICE_WACOM(0xC4) },
4293 { USB_DEVICE_WACOM(0xC5) },
4294 { USB_DEVICE_WACOM(0xC6) },
4295 { USB_DEVICE_WACOM(0xC7) },
4296 { USB_DEVICE_WACOM(0xCC) },
4297 { USB_DEVICE_WACOM(0xCE) },
4298 { USB_DEVICE_WACOM(0xD0) },
4299 { USB_DEVICE_WACOM(0xD1) },
4300 { USB_DEVICE_WACOM(0xD2) },
4301 { USB_DEVICE_WACOM(0xD3) },
4302 { USB_DEVICE_WACOM(0xD4) },
4303 { USB_DEVICE_WACOM(0xD5) },
4304 { USB_DEVICE_WACOM(0xD6) },
4305 { USB_DEVICE_WACOM(0xD7) },
4306 { USB_DEVICE_WACOM(0xD8) },
4307 { USB_DEVICE_WACOM(0xDA) },
4308 { USB_DEVICE_WACOM(0xDB) },
4309 { USB_DEVICE_WACOM(0xDD) },
4310 { USB_DEVICE_WACOM(0xDE) },
4311 { USB_DEVICE_WACOM(0xDF) },
4312 { USB_DEVICE_WACOM(0xE2) },
4313 { USB_DEVICE_WACOM(0xE3) },
4314 { USB_DEVICE_WACOM(0xE5) },
4315 { USB_DEVICE_WACOM(0xE6) },
4316 { USB_DEVICE_WACOM(0xEC) },
4317 { USB_DEVICE_WACOM(0xED) },
4318 { USB_DEVICE_WACOM(0xEF) },
4319 { USB_DEVICE_WACOM(0xF0) },
4320 { USB_DEVICE_WACOM(0xF4) },
4321 { USB_DEVICE_WACOM(0xF6) },
4322 { USB_DEVICE_WACOM(0xF8) },
4323 { USB_DEVICE_WACOM(0xFA) },
4324 { USB_DEVICE_WACOM(0xFB) },
4325 { USB_DEVICE_WACOM(0x100) },
4326 { USB_DEVICE_WACOM(0x101) },
4327 { USB_DEVICE_WACOM(0x10D) },
4328 { USB_DEVICE_WACOM(0x10E) },
4329 { USB_DEVICE_WACOM(0x10F) },
4330 { USB_DEVICE_WACOM(0x116) },
4331 { USB_DEVICE_WACOM(0x12C) },
4332 { USB_DEVICE_WACOM(0x300) },
4333 { USB_DEVICE_WACOM(0x301) },
4334 { USB_DEVICE_WACOM(0x302) },
4335 { USB_DEVICE_WACOM(0x303) },
4336 { USB_DEVICE_WACOM(0x304) },
4337 { USB_DEVICE_WACOM(0x307) },
4338 { USB_DEVICE_WACOM(0x309) },
4339 { USB_DEVICE_WACOM(0x30A) },
4340 { USB_DEVICE_WACOM(0x30C) },
4341 { USB_DEVICE_WACOM(0x30E) },
4342 { USB_DEVICE_WACOM(0x314) },
4343 { USB_DEVICE_WACOM(0x315) },
4344 { USB_DEVICE_WACOM(0x317) },
4345 { USB_DEVICE_WACOM(0x318) },
4346 { USB_DEVICE_WACOM(0x319) },
4347 { USB_DEVICE_WACOM(0x323) },
4348 { USB_DEVICE_WACOM(0x325) },
4349 { USB_DEVICE_WACOM(0x326) },
4350 { USB_DEVICE_WACOM(0x32A) },
4351 { USB_DEVICE_WACOM(0x32B) },
4352 { USB_DEVICE_WACOM(0x32C) },
4353 { USB_DEVICE_WACOM(0x32F) },
4354 { USB_DEVICE_WACOM(0x331) },
4355 { USB_DEVICE_WACOM(0x333) },
4356 { USB_DEVICE_WACOM(0x335) },
4357 { USB_DEVICE_WACOM(0x336) },
4358 { USB_DEVICE_WACOM(0x33B) },
4359 { USB_DEVICE_WACOM(0x33C) },
4360 { USB_DEVICE_WACOM(0x33D) },
4361 { USB_DEVICE_WACOM(0x33E) },
4362 { USB_DEVICE_WACOM(0x343) },
4363 { BT_DEVICE_WACOM(0x360) },
4364 { BT_DEVICE_WACOM(0x361) },
4365 { USB_DEVICE_WACOM(0x4001) },
4366 { USB_DEVICE_WACOM(0x4004) },
4367 { USB_DEVICE_WACOM(0x5000) },
4368 { USB_DEVICE_WACOM(0x5002) },
4369 { USB_DEVICE_LENOVO(0x6004) },
4371 { USB_DEVICE_WACOM(HID_ANY_ID) },
4372 { I2C_DEVICE_WACOM(HID_ANY_ID) },
4373 { BT_DEVICE_WACOM(HID_ANY_ID) },
4376 MODULE_DEVICE_TABLE(hid, wacom_ids);