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
);
47 * Percent of battery capacity for Graphire.
48 * 8th value means AC online and show 100% capacity.
50 static unsigned short batcap_gr
[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
53 * Percent of battery capacity for Intuos4 WL, AC has a separate bit.
55 static unsigned short batcap_i4
[8] = { 1, 15, 30, 45, 60, 70, 85, 100 };
57 static void __wacom_notify_battery(struct wacom_battery
*battery
,
58 int bat_capacity
, bool bat_charging
,
59 bool bat_connected
, bool ps_connected
)
61 bool changed
= battery
->battery_capacity
!= bat_capacity
||
62 battery
->bat_charging
!= bat_charging
||
63 battery
->bat_connected
!= bat_connected
||
64 battery
->ps_connected
!= ps_connected
;
67 battery
->battery_capacity
= bat_capacity
;
68 battery
->bat_charging
= bat_charging
;
69 battery
->bat_connected
= bat_connected
;
70 battery
->ps_connected
= ps_connected
;
73 power_supply_changed(battery
->battery
);
77 static void wacom_notify_battery(struct wacom_wac
*wacom_wac
,
78 int bat_capacity
, bool bat_charging
, bool bat_connected
,
81 struct wacom
*wacom
= container_of(wacom_wac
, struct wacom
, wacom_wac
);
83 __wacom_notify_battery(&wacom
->battery
, bat_capacity
, bat_charging
,
84 bat_connected
, ps_connected
);
87 static int wacom_penpartner_irq(struct wacom_wac
*wacom
)
89 unsigned char *data
= wacom
->data
;
90 struct input_dev
*input
= wacom
->pen_input
;
95 wacom
->tool
[0] = (data
[5] & 0x20) ? BTN_TOOL_RUBBER
: BTN_TOOL_PEN
;
96 wacom
->id
[0] = (data
[5] & 0x20) ? ERASER_DEVICE_ID
: STYLUS_DEVICE_ID
;
97 input_report_key(input
, wacom
->tool
[0], 1);
98 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]); /* report tool id */
99 input_report_abs(input
, ABS_X
, get_unaligned_le16(&data
[1]));
100 input_report_abs(input
, ABS_Y
, get_unaligned_le16(&data
[3]));
101 input_report_abs(input
, ABS_PRESSURE
, (signed char)data
[6] + 127);
102 input_report_key(input
, BTN_TOUCH
, ((signed char)data
[6] > -127));
103 input_report_key(input
, BTN_STYLUS
, (data
[5] & 0x40));
105 input_report_key(input
, wacom
->tool
[0], 0);
106 input_report_abs(input
, ABS_MISC
, 0); /* report tool id */
107 input_report_abs(input
, ABS_PRESSURE
, -1);
108 input_report_key(input
, BTN_TOUCH
, 0);
113 input_report_key(input
, BTN_TOOL_PEN
, 1);
114 input_report_abs(input
, ABS_MISC
, STYLUS_DEVICE_ID
); /* report tool id */
115 input_report_abs(input
, ABS_X
, get_unaligned_le16(&data
[1]));
116 input_report_abs(input
, ABS_Y
, get_unaligned_le16(&data
[3]));
117 input_report_abs(input
, ABS_PRESSURE
, (signed char)data
[6] + 127);
118 input_report_key(input
, BTN_TOUCH
, ((signed char)data
[6] > -80) && !(data
[5] & 0x20));
119 input_report_key(input
, BTN_STYLUS
, (data
[5] & 0x40));
123 dev_dbg(input
->dev
.parent
,
124 "%s: received unknown report #%d\n", __func__
, data
[0]);
131 static int wacom_pl_irq(struct wacom_wac
*wacom
)
133 struct wacom_features
*features
= &wacom
->features
;
134 unsigned char *data
= wacom
->data
;
135 struct input_dev
*input
= wacom
->pen_input
;
138 if (data
[0] != WACOM_REPORT_PENABLED
) {
139 dev_dbg(input
->dev
.parent
,
140 "%s: received unknown report #%d\n", __func__
, data
[0]);
144 prox
= data
[1] & 0x40;
147 if ((data
[0] & 0x10) || (data
[4] & 0x20)) {
148 wacom
->tool
[0] = BTN_TOOL_RUBBER
;
149 wacom
->id
[0] = ERASER_DEVICE_ID
;
152 wacom
->tool
[0] = BTN_TOOL_PEN
;
153 wacom
->id
[0] = STYLUS_DEVICE_ID
;
157 /* If the eraser is in prox, STYLUS2 is always set. If we
158 * mis-detected the type and notice that STYLUS2 isn't set
159 * then force the eraser out of prox and let the pen in.
161 if (wacom
->tool
[0] == BTN_TOOL_RUBBER
&& !(data
[4] & 0x20)) {
162 input_report_key(input
, BTN_TOOL_RUBBER
, 0);
163 input_report_abs(input
, ABS_MISC
, 0);
165 wacom
->tool
[0] = BTN_TOOL_PEN
;
166 wacom
->id
[0] = STYLUS_DEVICE_ID
;
169 pressure
= (signed char)((data
[7] << 1) | ((data
[4] >> 2) & 1));
170 if (features
->pressure_max
> 255)
171 pressure
= (pressure
<< 1) | ((data
[4] >> 6) & 1);
172 pressure
+= (features
->pressure_max
+ 1) / 2;
174 input_report_abs(input
, ABS_X
, data
[3] | (data
[2] << 7) | ((data
[1] & 0x03) << 14));
175 input_report_abs(input
, ABS_Y
, data
[6] | (data
[5] << 7) | ((data
[4] & 0x03) << 14));
176 input_report_abs(input
, ABS_PRESSURE
, pressure
);
178 input_report_key(input
, BTN_TOUCH
, data
[4] & 0x08);
179 input_report_key(input
, BTN_STYLUS
, data
[4] & 0x10);
180 /* Only allow the stylus2 button to be reported for the pen tool. */
181 input_report_key(input
, BTN_STYLUS2
, (wacom
->tool
[0] == BTN_TOOL_PEN
) && (data
[4] & 0x20));
185 input_report_key(input
, wacom
->tool
[0], prox
);
186 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]);
190 static int wacom_ptu_irq(struct wacom_wac
*wacom
)
192 unsigned char *data
= wacom
->data
;
193 struct input_dev
*input
= wacom
->pen_input
;
195 if (data
[0] != WACOM_REPORT_PENABLED
) {
196 dev_dbg(input
->dev
.parent
,
197 "%s: received unknown report #%d\n", __func__
, data
[0]);
201 if (data
[1] & 0x04) {
202 input_report_key(input
, BTN_TOOL_RUBBER
, data
[1] & 0x20);
203 input_report_key(input
, BTN_TOUCH
, data
[1] & 0x08);
204 wacom
->id
[0] = ERASER_DEVICE_ID
;
206 input_report_key(input
, BTN_TOOL_PEN
, data
[1] & 0x20);
207 input_report_key(input
, BTN_TOUCH
, data
[1] & 0x01);
208 wacom
->id
[0] = STYLUS_DEVICE_ID
;
210 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]); /* report tool id */
211 input_report_abs(input
, ABS_X
, le16_to_cpup((__le16
*)&data
[2]));
212 input_report_abs(input
, ABS_Y
, le16_to_cpup((__le16
*)&data
[4]));
213 input_report_abs(input
, ABS_PRESSURE
, le16_to_cpup((__le16
*)&data
[6]));
214 input_report_key(input
, BTN_STYLUS
, data
[1] & 0x02);
215 input_report_key(input
, BTN_STYLUS2
, data
[1] & 0x10);
219 static int wacom_dtu_irq(struct wacom_wac
*wacom
)
221 unsigned char *data
= wacom
->data
;
222 struct input_dev
*input
= wacom
->pen_input
;
223 int prox
= data
[1] & 0x20;
225 dev_dbg(input
->dev
.parent
,
226 "%s: received report #%d", __func__
, data
[0]);
229 /* Going into proximity select tool */
230 wacom
->tool
[0] = (data
[1] & 0x0c) ? BTN_TOOL_RUBBER
: BTN_TOOL_PEN
;
231 if (wacom
->tool
[0] == BTN_TOOL_PEN
)
232 wacom
->id
[0] = STYLUS_DEVICE_ID
;
234 wacom
->id
[0] = ERASER_DEVICE_ID
;
236 input_report_key(input
, BTN_STYLUS
, data
[1] & 0x02);
237 input_report_key(input
, BTN_STYLUS2
, data
[1] & 0x10);
238 input_report_abs(input
, ABS_X
, le16_to_cpup((__le16
*)&data
[2]));
239 input_report_abs(input
, ABS_Y
, le16_to_cpup((__le16
*)&data
[4]));
240 input_report_abs(input
, ABS_PRESSURE
, ((data
[7] & 0x01) << 8) | data
[6]);
241 input_report_key(input
, BTN_TOUCH
, data
[1] & 0x05);
242 if (!prox
) /* out-prox */
244 input_report_key(input
, wacom
->tool
[0], prox
);
245 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]);
249 static int wacom_dtus_irq(struct wacom_wac
*wacom
)
251 char *data
= wacom
->data
;
252 struct input_dev
*input
= wacom
->pen_input
;
253 unsigned short prox
, pressure
= 0;
255 if (data
[0] != WACOM_REPORT_DTUS
&& data
[0] != WACOM_REPORT_DTUSPAD
) {
256 dev_dbg(input
->dev
.parent
,
257 "%s: received unknown report #%d", __func__
, data
[0]);
259 } else if (data
[0] == WACOM_REPORT_DTUSPAD
) {
260 input
= wacom
->pad_input
;
261 input_report_key(input
, BTN_0
, (data
[1] & 0x01));
262 input_report_key(input
, BTN_1
, (data
[1] & 0x02));
263 input_report_key(input
, BTN_2
, (data
[1] & 0x04));
264 input_report_key(input
, BTN_3
, (data
[1] & 0x08));
265 input_report_abs(input
, ABS_MISC
,
266 data
[1] & 0x0f ? PAD_DEVICE_ID
: 0);
269 prox
= data
[1] & 0x80;
271 switch ((data
[1] >> 3) & 3) {
273 wacom
->tool
[0] = BTN_TOOL_RUBBER
;
274 wacom
->id
[0] = ERASER_DEVICE_ID
;
278 wacom
->tool
[0] = BTN_TOOL_PEN
;
279 wacom
->id
[0] = STYLUS_DEVICE_ID
;
284 input_report_key(input
, BTN_STYLUS
, data
[1] & 0x20);
285 input_report_key(input
, BTN_STYLUS2
, data
[1] & 0x40);
286 input_report_abs(input
, ABS_X
, get_unaligned_be16(&data
[3]));
287 input_report_abs(input
, ABS_Y
, get_unaligned_be16(&data
[5]));
288 pressure
= ((data
[1] & 0x03) << 8) | (data
[2] & 0xff);
289 input_report_abs(input
, ABS_PRESSURE
, pressure
);
290 input_report_key(input
, BTN_TOUCH
, pressure
> 10);
292 if (!prox
) /* out-prox */
294 input_report_key(input
, wacom
->tool
[0], prox
);
295 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]);
300 static int wacom_graphire_irq(struct wacom_wac
*wacom
)
302 struct wacom_features
*features
= &wacom
->features
;
303 unsigned char *data
= wacom
->data
;
304 struct input_dev
*input
= wacom
->pen_input
;
305 struct input_dev
*pad_input
= wacom
->pad_input
;
306 int battery_capacity
, ps_connected
;
311 if (features
->type
== GRAPHIRE_BT
) {
312 if (data
[0] != WACOM_REPORT_PENABLED_BT
) {
313 dev_dbg(input
->dev
.parent
,
314 "%s: received unknown report #%d\n", __func__
,
318 } else if (data
[0] != WACOM_REPORT_PENABLED
) {
319 dev_dbg(input
->dev
.parent
,
320 "%s: received unknown report #%d\n", __func__
, data
[0]);
324 prox
= data
[1] & 0x80;
325 if (prox
|| wacom
->id
[0]) {
327 switch ((data
[1] >> 5) & 3) {
330 wacom
->tool
[0] = BTN_TOOL_PEN
;
331 wacom
->id
[0] = STYLUS_DEVICE_ID
;
335 wacom
->tool
[0] = BTN_TOOL_RUBBER
;
336 wacom
->id
[0] = ERASER_DEVICE_ID
;
339 case 2: /* Mouse with wheel */
340 input_report_key(input
, BTN_MIDDLE
, data
[1] & 0x04);
343 case 3: /* Mouse without wheel */
344 wacom
->tool
[0] = BTN_TOOL_MOUSE
;
345 wacom
->id
[0] = CURSOR_DEVICE_ID
;
349 input_report_abs(input
, ABS_X
, le16_to_cpup((__le16
*)&data
[2]));
350 input_report_abs(input
, ABS_Y
, le16_to_cpup((__le16
*)&data
[4]));
351 if (wacom
->tool
[0] != BTN_TOOL_MOUSE
) {
352 if (features
->type
== GRAPHIRE_BT
)
353 input_report_abs(input
, ABS_PRESSURE
, data
[6] |
354 (((__u16
) (data
[1] & 0x08)) << 5));
356 input_report_abs(input
, ABS_PRESSURE
, data
[6] |
357 ((data
[7] & 0x03) << 8));
358 input_report_key(input
, BTN_TOUCH
, data
[1] & 0x01);
359 input_report_key(input
, BTN_STYLUS
, data
[1] & 0x02);
360 input_report_key(input
, BTN_STYLUS2
, data
[1] & 0x04);
362 input_report_key(input
, BTN_LEFT
, data
[1] & 0x01);
363 input_report_key(input
, BTN_RIGHT
, data
[1] & 0x02);
364 if (features
->type
== WACOM_G4
||
365 features
->type
== WACOM_MO
) {
366 input_report_abs(input
, ABS_DISTANCE
, data
[6] & 0x3f);
367 rw
= (data
[7] & 0x04) - (data
[7] & 0x03);
368 } else if (features
->type
== GRAPHIRE_BT
) {
369 /* Compute distance between mouse and tablet */
370 rw
= 44 - (data
[6] >> 2);
371 rw
= clamp_val(rw
, 0, 31);
372 input_report_abs(input
, ABS_DISTANCE
, rw
);
373 if (((data
[1] >> 5) & 3) == 2) {
374 /* Mouse with wheel */
375 input_report_key(input
, BTN_MIDDLE
,
377 rw
= (data
[6] & 0x01) ? -1 :
378 (data
[6] & 0x02) ? 1 : 0;
383 input_report_abs(input
, ABS_DISTANCE
, data
[7] & 0x3f);
384 rw
= -(signed char)data
[6];
386 input_report_rel(input
, REL_WHEEL
, rw
);
391 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]); /* report tool id */
392 input_report_key(input
, wacom
->tool
[0], prox
);
393 input_sync(input
); /* sync last event */
397 switch (features
->type
) {
399 prox
= data
[7] & 0xf8;
400 if (prox
|| wacom
->id
[1]) {
401 wacom
->id
[1] = PAD_DEVICE_ID
;
402 input_report_key(pad_input
, BTN_BACK
, (data
[7] & 0x40));
403 input_report_key(pad_input
, BTN_FORWARD
, (data
[7] & 0x80));
404 rw
= ((data
[7] & 0x18) >> 3) - ((data
[7] & 0x20) >> 3);
405 input_report_rel(pad_input
, REL_WHEEL
, rw
);
408 input_report_abs(pad_input
, ABS_MISC
, wacom
->id
[1]);
414 prox
= (data
[7] & 0xf8) || data
[8];
415 if (prox
|| wacom
->id
[1]) {
416 wacom
->id
[1] = PAD_DEVICE_ID
;
417 input_report_key(pad_input
, BTN_BACK
, (data
[7] & 0x08));
418 input_report_key(pad_input
, BTN_LEFT
, (data
[7] & 0x20));
419 input_report_key(pad_input
, BTN_FORWARD
, (data
[7] & 0x10));
420 input_report_key(pad_input
, BTN_RIGHT
, (data
[7] & 0x40));
421 input_report_abs(pad_input
, ABS_WHEEL
, (data
[8] & 0x7f));
424 input_report_abs(pad_input
, ABS_MISC
, wacom
->id
[1]);
429 prox
= data
[7] & 0x03;
430 if (prox
|| wacom
->id
[1]) {
431 wacom
->id
[1] = PAD_DEVICE_ID
;
432 input_report_key(pad_input
, BTN_0
, (data
[7] & 0x02));
433 input_report_key(pad_input
, BTN_1
, (data
[7] & 0x01));
436 input_report_abs(pad_input
, ABS_MISC
, wacom
->id
[1]);
442 /* Store current battery capacity and power supply state */
443 if (features
->type
== GRAPHIRE_BT
) {
444 rw
= (data
[7] >> 2 & 0x07);
445 battery_capacity
= batcap_gr
[rw
];
446 ps_connected
= rw
== 7;
447 wacom_notify_battery(wacom
, battery_capacity
, ps_connected
,
454 static void wacom_intuos_schedule_prox_event(struct wacom_wac
*wacom_wac
)
456 struct wacom
*wacom
= container_of(wacom_wac
, struct wacom
, wacom_wac
);
457 struct wacom_features
*features
= &wacom_wac
->features
;
458 struct hid_report
*r
;
459 struct hid_report_enum
*re
;
461 re
= &(wacom
->hdev
->report_enum
[HID_FEATURE_REPORT
]);
462 if (features
->type
== INTUOSHT2
)
463 r
= re
->report_id_hash
[WACOM_REPORT_INTUOSHT2_ID
];
465 r
= re
->report_id_hash
[WACOM_REPORT_INTUOS_ID1
];
467 hid_hw_request(wacom
->hdev
, r
, HID_REQ_GET_REPORT
);
471 static int wacom_intuos_pad(struct wacom_wac
*wacom
)
473 struct wacom_features
*features
= &wacom
->features
;
474 unsigned char *data
= wacom
->data
;
475 struct input_dev
*input
= wacom
->pad_input
;
477 int buttons
= 0, nbuttons
= features
->numbered_buttons
;
478 int keys
= 0, nkeys
= 0;
479 int ring1
= 0, ring2
= 0;
480 int strip1
= 0, strip2
= 0;
483 /* pad packets. Works as a second tool and is always in prox */
484 if (!(data
[0] == WACOM_REPORT_INTUOSPAD
|| data
[0] == WACOM_REPORT_INTUOS5PAD
||
485 data
[0] == WACOM_REPORT_CINTIQPAD
))
488 if (features
->type
>= INTUOS4S
&& features
->type
<= INTUOS4L
) {
489 buttons
= (data
[3] << 1) | (data
[2] & 0x01);
491 } else if (features
->type
== DTK
) {
493 } else if (features
->type
== WACOM_13HD
) {
494 buttons
= (data
[4] << 1) | (data
[3] & 0x01);
495 } else if (features
->type
== WACOM_24HD
) {
496 buttons
= (data
[8] << 8) | data
[6];
501 * Three "buttons" are available on the 24HD which are
502 * physically implemented as a touchstrip. Each button
503 * is approximately 3 bits wide with a 2 bit spacing.
504 * The raw touchstrip bits are stored at:
505 * ((data[3] & 0x1f) << 8) | data[4])
508 keys
= ((data
[3] & 0x1C) ? 1<<2 : 0) |
509 ((data
[4] & 0xE0) ? 1<<1 : 0) |
510 ((data
[4] & 0x07) ? 1<<0 : 0);
511 } else if (features
->type
== WACOM_27QHD
) {
513 keys
= data
[2] & 0x07;
515 input_report_abs(input
, ABS_X
, be16_to_cpup((__be16
*)&data
[4]));
516 input_report_abs(input
, ABS_Y
, be16_to_cpup((__be16
*)&data
[6]));
517 input_report_abs(input
, ABS_Z
, be16_to_cpup((__be16
*)&data
[8]));
518 } else if (features
->type
== CINTIQ_HYBRID
) {
520 * Do not send hardware buttons under Android. They
521 * are already sent to the system through GPIO (and
522 * have different meaning).
524 * d-pad right -> data[4] & 0x10
525 * d-pad up -> data[4] & 0x20
526 * d-pad left -> data[4] & 0x40
527 * d-pad down -> data[4] & 0x80
528 * d-pad center -> data[3] & 0x01
530 buttons
= (data
[4] << 1) | (data
[3] & 0x01);
531 } else if (features
->type
== CINTIQ_COMPANION_2
) {
532 /* d-pad right -> data[4] & 0x10
533 * d-pad up -> data[4] & 0x20
534 * d-pad left -> data[4] & 0x40
535 * d-pad down -> data[4] & 0x80
536 * d-pad center -> data[3] & 0x01
538 buttons
= ((data
[2] >> 4) << 7) |
539 ((data
[1] & 0x04) << 6) |
540 ((data
[2] & 0x0F) << 2) |
542 } else if (features
->type
>= INTUOS5S
&& features
->type
<= INTUOSPL
) {
544 * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in
545 * addition to the mechanical switch. Switch data is
546 * stored in data[4], capacitive data in data[5].
548 * Touch ring mode switch (data[3]) has no capacitive sensor
550 buttons
= (data
[4] << 1) | (data
[3] & 0x01);
553 if (features
->type
== WACOM_21UX2
|| features
->type
== WACOM_22HD
) {
554 buttons
= (data
[8] << 10) | ((data
[7] & 0x01) << 9) |
555 (data
[6] << 1) | (data
[5] & 0x01);
557 if (features
->type
== WACOM_22HD
) {
559 keys
= data
[9] & 0x07;
562 buttons
= ((data
[6] & 0x10) << 10) |
563 ((data
[5] & 0x10) << 9) |
564 ((data
[6] & 0x0F) << 4) |
567 strip1
= ((data
[1] & 0x1f) << 8) | data
[2];
568 strip2
= ((data
[3] & 0x1f) << 8) | data
[4];
571 prox
= (buttons
& ~(~0 << nbuttons
)) | (keys
& ~(~0 << nkeys
)) |
572 (ring1
& 0x80) | (ring2
& 0x80) | strip1
| strip2
;
574 wacom_report_numbered_buttons(input
, nbuttons
, buttons
);
576 for (i
= 0; i
< nkeys
; i
++)
577 input_report_key(input
, KEY_PROG1
+ i
, keys
& (1 << i
));
579 input_report_abs(input
, ABS_RX
, strip1
);
580 input_report_abs(input
, ABS_RY
, strip2
);
582 input_report_abs(input
, ABS_WHEEL
, (ring1
& 0x80) ? (ring1
& 0x7f) : 0);
583 input_report_abs(input
, ABS_THROTTLE
, (ring2
& 0x80) ? (ring2
& 0x7f) : 0);
585 input_report_key(input
, wacom
->tool
[1], prox
? 1 : 0);
586 input_report_abs(input
, ABS_MISC
, prox
? PAD_DEVICE_ID
: 0);
588 input_event(input
, EV_MSC
, MSC_SERIAL
, 0xffffffff);
593 static int wacom_intuos_id_mangle(int tool_id
)
595 return (tool_id
& ~0xFFF) << 4 | (tool_id
& 0xFFF);
598 static int wacom_intuos_get_tool_type(int tool_id
)
603 case 0x812: /* Inking pen */
604 case 0x801: /* Intuos3 Inking pen */
605 case 0x12802: /* Intuos4/5 Inking Pen */
607 tool_type
= BTN_TOOL_PENCIL
;
610 case 0x822: /* Pen */
613 case 0x823: /* Intuos3 Grip Pen */
614 case 0x813: /* Intuos3 Classic Pen */
615 case 0x885: /* Intuos3 Marker Pen */
616 case 0x802: /* Intuos4/5 13HD/24HD General Pen */
617 case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
618 case 0x8e2: /* IntuosHT2 pen */
620 case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */
621 case 0x14802: /* Intuos4/5 13HD/24HD Classic Pen */
622 case 0x16802: /* Cintiq 13HD Pro Pen */
623 case 0x18802: /* DTH2242 Pen */
624 case 0x10802: /* Intuos4/5 13HD/24HD General Pen */
625 tool_type
= BTN_TOOL_PEN
;
628 case 0x832: /* Stroke pen */
630 tool_type
= BTN_TOOL_BRUSH
;
633 case 0x007: /* Mouse 4D and 2D */
636 case 0x017: /* Intuos3 2D Mouse */
637 case 0x806: /* Intuos4 Mouse */
638 tool_type
= BTN_TOOL_MOUSE
;
641 case 0x096: /* Lens cursor */
642 case 0x097: /* Intuos3 Lens cursor */
643 case 0x006: /* Intuos4 Lens cursor */
644 tool_type
= BTN_TOOL_LENS
;
647 case 0x82a: /* Eraser */
653 case 0x82b: /* Intuos3 Grip Pen Eraser */
654 case 0x81b: /* Intuos3 Classic Pen Eraser */
655 case 0x91b: /* Intuos3 Airbrush Eraser */
656 case 0x80c: /* Intuos4/5 13HD/24HD Marker Pen Eraser */
657 case 0x80a: /* Intuos4/5 13HD/24HD General Pen Eraser */
658 case 0x90a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
659 case 0x1480a: /* Intuos4/5 13HD/24HD Classic Pen Eraser */
660 case 0x1090a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
661 case 0x1080c: /* Intuos4/5 13HD/24HD Art Pen Eraser */
662 case 0x1680a: /* Cintiq 13HD Pro Pen Eraser */
663 case 0x1880a: /* DTH2242 Eraser */
664 case 0x1080a: /* Intuos4/5 13HD/24HD General Pen Eraser */
665 tool_type
= BTN_TOOL_RUBBER
;
671 case 0x913: /* Intuos3 Airbrush */
672 case 0x902: /* Intuos4/5 13HD/24HD Airbrush */
673 case 0x10902: /* Intuos4/5 13HD/24HD Airbrush */
674 tool_type
= BTN_TOOL_AIRBRUSH
;
677 default: /* Unknown tool */
678 tool_type
= BTN_TOOL_PEN
;
684 static int wacom_intuos_inout(struct wacom_wac
*wacom
)
686 struct wacom_features
*features
= &wacom
->features
;
687 unsigned char *data
= wacom
->data
;
688 struct input_dev
*input
= wacom
->pen_input
;
689 int idx
= (features
->type
== INTUOS
) ? (data
[1] & 0x01) : 0;
691 if (!(((data
[1] & 0xfc) == 0xc0) || /* in prox */
692 ((data
[1] & 0xfe) == 0x20) || /* in range */
693 ((data
[1] & 0xfe) == 0x80))) /* out prox */
697 if ((data
[1] & 0xfc) == 0xc0) {
698 /* serial number of the tool */
699 wacom
->serial
[idx
] = ((data
[3] & 0x0f) << 28) +
700 (data
[4] << 20) + (data
[5] << 12) +
701 (data
[6] << 4) + (data
[7] >> 4);
703 wacom
->id
[idx
] = (data
[2] << 4) | (data
[3] >> 4) |
704 ((data
[7] & 0x0f) << 16) | ((data
[8] & 0xf0) << 8);
706 wacom
->tool
[idx
] = wacom_intuos_get_tool_type(wacom
->id
[idx
]);
708 wacom
->shared
->stylus_in_proximity
= true;
713 if ((data
[1] & 0xfe) == 0x20) {
714 if (features
->type
!= INTUOSHT2
)
715 wacom
->shared
->stylus_in_proximity
= true;
717 /* in Range while exiting */
718 if (wacom
->reporting_data
) {
719 input_report_key(input
, BTN_TOUCH
, 0);
720 input_report_abs(input
, ABS_PRESSURE
, 0);
721 input_report_abs(input
, ABS_DISTANCE
, wacom
->features
.distance_max
);
728 if ((data
[1] & 0xfe) == 0x80) {
729 wacom
->shared
->stylus_in_proximity
= false;
730 wacom
->reporting_data
= false;
732 /* don't report exit if we don't know the ID */
737 * Reset all states otherwise we lose the initial states
738 * when in-prox next time
740 input_report_abs(input
, ABS_X
, 0);
741 input_report_abs(input
, ABS_Y
, 0);
742 input_report_abs(input
, ABS_DISTANCE
, 0);
743 input_report_abs(input
, ABS_TILT_X
, 0);
744 input_report_abs(input
, ABS_TILT_Y
, 0);
745 if (wacom
->tool
[idx
] >= BTN_TOOL_MOUSE
) {
746 input_report_key(input
, BTN_LEFT
, 0);
747 input_report_key(input
, BTN_MIDDLE
, 0);
748 input_report_key(input
, BTN_RIGHT
, 0);
749 input_report_key(input
, BTN_SIDE
, 0);
750 input_report_key(input
, BTN_EXTRA
, 0);
751 input_report_abs(input
, ABS_THROTTLE
, 0);
752 input_report_abs(input
, ABS_RZ
, 0);
754 input_report_abs(input
, ABS_PRESSURE
, 0);
755 input_report_key(input
, BTN_STYLUS
, 0);
756 input_report_key(input
, BTN_STYLUS2
, 0);
757 input_report_key(input
, BTN_TOUCH
, 0);
758 input_report_abs(input
, ABS_WHEEL
, 0);
759 if (features
->type
>= INTUOS3S
)
760 input_report_abs(input
, ABS_Z
, 0);
762 input_report_key(input
, wacom
->tool
[idx
], 0);
763 input_report_abs(input
, ABS_MISC
, 0); /* reset tool id */
764 input_event(input
, EV_MSC
, MSC_SERIAL
, wacom
->serial
[idx
]);
772 static int wacom_remote_irq(struct wacom_wac
*wacom_wac
, size_t len
)
774 unsigned char *data
= wacom_wac
->data
;
775 struct input_dev
*input
;
776 struct wacom
*wacom
= container_of(wacom_wac
, struct wacom
, wacom_wac
);
777 struct wacom_remote
*remote
= wacom
->remote
;
778 int bat_charging
, bat_percent
, touch_ring_mode
;
783 if (data
[0] != WACOM_REPORT_REMOTE
) {
784 hid_dbg(wacom
->hdev
, "%s: received unknown report #%d",
789 serial
= data
[3] + (data
[4] << 8) + (data
[5] << 16);
790 wacom_wac
->id
[0] = PAD_DEVICE_ID
;
792 spin_lock_irqsave(&remote
->remote_lock
, flags
);
794 for (i
= 0; i
< WACOM_MAX_REMOTES
; i
++) {
795 if (remote
->remotes
[i
].serial
== serial
) {
801 if (index
< 0 || !remote
->remotes
[index
].registered
)
804 input
= remote
->remotes
[index
].input
;
806 input_report_key(input
, BTN_0
, (data
[9] & 0x01));
807 input_report_key(input
, BTN_1
, (data
[9] & 0x02));
808 input_report_key(input
, BTN_2
, (data
[9] & 0x04));
809 input_report_key(input
, BTN_3
, (data
[9] & 0x08));
810 input_report_key(input
, BTN_4
, (data
[9] & 0x10));
811 input_report_key(input
, BTN_5
, (data
[9] & 0x20));
812 input_report_key(input
, BTN_6
, (data
[9] & 0x40));
813 input_report_key(input
, BTN_7
, (data
[9] & 0x80));
815 input_report_key(input
, BTN_8
, (data
[10] & 0x01));
816 input_report_key(input
, BTN_9
, (data
[10] & 0x02));
817 input_report_key(input
, BTN_A
, (data
[10] & 0x04));
818 input_report_key(input
, BTN_B
, (data
[10] & 0x08));
819 input_report_key(input
, BTN_C
, (data
[10] & 0x10));
820 input_report_key(input
, BTN_X
, (data
[10] & 0x20));
821 input_report_key(input
, BTN_Y
, (data
[10] & 0x40));
822 input_report_key(input
, BTN_Z
, (data
[10] & 0x80));
824 input_report_key(input
, BTN_BASE
, (data
[11] & 0x01));
825 input_report_key(input
, BTN_BASE2
, (data
[11] & 0x02));
828 input_report_abs(input
, ABS_WHEEL
, (data
[12] & 0x7f));
830 input_report_abs(input
, ABS_WHEEL
, 0);
832 bat_percent
= data
[7] & 0x7f;
833 bat_charging
= !!(data
[7] & 0x80);
835 if (data
[9] | data
[10] | (data
[11] & 0x03) | data
[12])
836 input_report_abs(input
, ABS_MISC
, PAD_DEVICE_ID
);
838 input_report_abs(input
, ABS_MISC
, 0);
840 input_event(input
, EV_MSC
, MSC_SERIAL
, serial
);
844 /*Which mode select (LED light) is currently on?*/
845 touch_ring_mode
= (data
[11] & 0xC0) >> 6;
847 for (i
= 0; i
< WACOM_MAX_REMOTES
; i
++) {
848 if (remote
->remotes
[i
].serial
== serial
)
849 wacom
->led
.groups
[i
].select
= touch_ring_mode
;
852 __wacom_notify_battery(&remote
->remotes
[index
].battery
, bat_percent
,
853 bat_charging
, 1, bat_charging
);
856 spin_unlock_irqrestore(&remote
->remote_lock
, flags
);
860 static void wacom_remote_status_irq(struct wacom_wac
*wacom_wac
, size_t len
)
862 struct wacom
*wacom
= container_of(wacom_wac
, struct wacom
, wacom_wac
);
863 unsigned char *data
= wacom_wac
->data
;
864 struct wacom_remote
*remote
= wacom
->remote
;
865 struct wacom_remote_data remote_data
;
869 if (data
[0] != WACOM_REPORT_DEVICE_LIST
)
872 memset(&remote_data
, 0, sizeof(struct wacom_remote_data
));
874 for (i
= 0; i
< WACOM_MAX_REMOTES
; i
++) {
876 int serial
= (data
[j
+6] << 16) + (data
[j
+5] << 8) + data
[j
+4];
877 bool connected
= data
[j
+2];
879 remote_data
.remote
[i
].serial
= serial
;
880 remote_data
.remote
[i
].connected
= connected
;
883 spin_lock_irqsave(&remote
->remote_lock
, flags
);
885 ret
= kfifo_in(&remote
->remote_fifo
, &remote_data
, sizeof(remote_data
));
886 if (ret
!= sizeof(remote_data
)) {
887 spin_unlock_irqrestore(&remote
->remote_lock
, flags
);
888 hid_err(wacom
->hdev
, "Can't queue Remote status event.\n");
892 spin_unlock_irqrestore(&remote
->remote_lock
, flags
);
894 wacom_schedule_work(wacom_wac
, WACOM_WORKER_REMOTE
);
897 static inline bool report_touch_events(struct wacom_wac
*wacom
)
899 return (touch_arbitration
? !wacom
->shared
->stylus_in_proximity
: 1);
902 static inline bool delay_pen_events(struct wacom_wac
*wacom
)
904 return (wacom
->shared
->touch_down
&& touch_arbitration
);
907 static int wacom_intuos_general(struct wacom_wac
*wacom
)
909 struct wacom_features
*features
= &wacom
->features
;
910 unsigned char *data
= wacom
->data
;
911 struct input_dev
*input
= wacom
->pen_input
;
912 int idx
= (features
->type
== INTUOS
) ? (data
[1] & 0x01) : 0;
913 unsigned char type
= (data
[1] >> 1) & 0x0F;
914 unsigned int x
, y
, distance
, t
;
916 if (data
[0] != WACOM_REPORT_PENABLED
&& data
[0] != WACOM_REPORT_CINTIQ
&&
917 data
[0] != WACOM_REPORT_INTUOS_PEN
)
920 if (delay_pen_events(wacom
))
923 /* don't report events if we don't know the tool ID */
924 if (!wacom
->id
[idx
]) {
925 /* but reschedule a read of the current tool */
926 wacom_intuos_schedule_prox_event(wacom
);
931 * don't report events for invalid data
933 /* older I4 styli don't work with new Cintiqs */
934 if ((!((wacom
->id
[idx
] >> 16) & 0x01) &&
935 (features
->type
== WACOM_21UX2
)) ||
936 /* Only large Intuos support Lense Cursor */
937 (wacom
->tool
[idx
] == BTN_TOOL_LENS
&&
938 (features
->type
== INTUOS3
||
939 features
->type
== INTUOS3S
||
940 features
->type
== INTUOS4
||
941 features
->type
== INTUOS4S
||
942 features
->type
== INTUOS5
||
943 features
->type
== INTUOS5S
||
944 features
->type
== INTUOSPM
||
945 features
->type
== INTUOSPS
)) ||
946 /* Cintiq doesn't send data when RDY bit isn't set */
947 (features
->type
== CINTIQ
&& !(data
[1] & 0x40)))
950 x
= (be16_to_cpup((__be16
*)&data
[2]) << 1) | ((data
[9] >> 1) & 1);
951 y
= (be16_to_cpup((__be16
*)&data
[4]) << 1) | (data
[9] & 1);
952 distance
= data
[9] >> 2;
953 if (features
->type
< INTUOS3S
) {
958 input_report_abs(input
, ABS_X
, x
);
959 input_report_abs(input
, ABS_Y
, y
);
960 input_report_abs(input
, ABS_DISTANCE
, distance
);
967 /* general pen packet */
968 t
= (data
[6] << 3) | ((data
[7] & 0xC0) >> 5) | (data
[1] & 1);
969 if (features
->pressure_max
< 2047)
971 input_report_abs(input
, ABS_PRESSURE
, t
);
972 if (features
->type
!= INTUOSHT2
) {
973 input_report_abs(input
, ABS_TILT_X
,
974 (((data
[7] << 1) & 0x7e) | (data
[8] >> 7)) - 64);
975 input_report_abs(input
, ABS_TILT_Y
, (data
[8] & 0x7f) - 64);
977 input_report_key(input
, BTN_STYLUS
, data
[1] & 2);
978 input_report_key(input
, BTN_STYLUS2
, data
[1] & 4);
979 input_report_key(input
, BTN_TOUCH
, t
> 10);
983 /* airbrush second packet */
984 input_report_abs(input
, ABS_WHEEL
,
985 (data
[6] << 2) | ((data
[7] >> 6) & 3));
986 input_report_abs(input
, ABS_TILT_X
,
987 (((data
[7] << 1) & 0x7e) | (data
[8] >> 7)) - 64);
988 input_report_abs(input
, ABS_TILT_Y
, (data
[8] & 0x7f) - 64);
992 /* Rotation packet */
993 if (features
->type
>= INTUOS3S
) {
994 /* I3 marker pen rotation */
995 t
= (data
[6] << 3) | ((data
[7] >> 5) & 7);
996 t
= (data
[7] & 0x20) ? ((t
> 900) ? ((t
-1) / 2 - 1350) :
997 ((t
-1) / 2 + 450)) : (450 - t
/ 2) ;
998 input_report_abs(input
, ABS_Z
, t
);
1000 /* 4D mouse 2nd packet */
1001 t
= (data
[6] << 3) | ((data
[7] >> 5) & 7);
1002 input_report_abs(input
, ABS_RZ
, (data
[7] & 0x20) ?
1003 ((t
- 1) / 2) : -t
/ 2);
1008 /* 4D mouse 1st packet */
1009 input_report_key(input
, BTN_LEFT
, data
[8] & 0x01);
1010 input_report_key(input
, BTN_MIDDLE
, data
[8] & 0x02);
1011 input_report_key(input
, BTN_RIGHT
, data
[8] & 0x04);
1013 input_report_key(input
, BTN_SIDE
, data
[8] & 0x20);
1014 input_report_key(input
, BTN_EXTRA
, data
[8] & 0x10);
1015 t
= (data
[6] << 2) | ((data
[7] >> 6) & 3);
1016 input_report_abs(input
, ABS_THROTTLE
, (data
[8] & 0x08) ? -t
: t
);
1021 input_report_key(input
, BTN_LEFT
, data
[6] & 0x01);
1022 input_report_key(input
, BTN_MIDDLE
, data
[6] & 0x02);
1023 input_report_key(input
, BTN_RIGHT
, data
[6] & 0x04);
1024 input_report_rel(input
, REL_WHEEL
, ((data
[7] & 0x80) >> 7)
1025 - ((data
[7] & 0x40) >> 6));
1026 input_report_key(input
, BTN_SIDE
, data
[6] & 0x08);
1027 input_report_key(input
, BTN_EXTRA
, data
[6] & 0x10);
1029 input_report_abs(input
, ABS_TILT_X
,
1030 (((data
[7] << 1) & 0x7e) | (data
[8] >> 7)) - 64);
1031 input_report_abs(input
, ABS_TILT_Y
, (data
[8] & 0x7f) - 64);
1035 if (wacom
->tool
[idx
] == BTN_TOOL_MOUSE
) {
1036 /* 2D mouse packet */
1037 input_report_key(input
, BTN_LEFT
, data
[8] & 0x04);
1038 input_report_key(input
, BTN_MIDDLE
, data
[8] & 0x08);
1039 input_report_key(input
, BTN_RIGHT
, data
[8] & 0x10);
1040 input_report_rel(input
, REL_WHEEL
, (data
[8] & 0x01)
1041 - ((data
[8] & 0x02) >> 1));
1043 /* I3 2D mouse side buttons */
1044 if (features
->type
>= INTUOS3S
&& features
->type
<= INTUOS3L
) {
1045 input_report_key(input
, BTN_SIDE
, data
[8] & 0x40);
1046 input_report_key(input
, BTN_EXTRA
, data
[8] & 0x20);
1049 else if (wacom
->tool
[idx
] == BTN_TOOL_LENS
) {
1050 /* Lens cursor packets */
1051 input_report_key(input
, BTN_LEFT
, data
[8] & 0x01);
1052 input_report_key(input
, BTN_MIDDLE
, data
[8] & 0x02);
1053 input_report_key(input
, BTN_RIGHT
, data
[8] & 0x04);
1054 input_report_key(input
, BTN_SIDE
, data
[8] & 0x10);
1055 input_report_key(input
, BTN_EXTRA
, data
[8] & 0x08);
1070 input_report_abs(input
, ABS_MISC
,
1071 wacom_intuos_id_mangle(wacom
->id
[idx
])); /* report tool id */
1072 input_report_key(input
, wacom
->tool
[idx
], 1);
1073 input_event(input
, EV_MSC
, MSC_SERIAL
, wacom
->serial
[idx
]);
1074 wacom
->reporting_data
= true;
1078 static int wacom_intuos_irq(struct wacom_wac
*wacom
)
1080 unsigned char *data
= wacom
->data
;
1081 struct input_dev
*input
= wacom
->pen_input
;
1084 if (data
[0] != WACOM_REPORT_PENABLED
&&
1085 data
[0] != WACOM_REPORT_INTUOS_ID1
&&
1086 data
[0] != WACOM_REPORT_INTUOS_ID2
&&
1087 data
[0] != WACOM_REPORT_INTUOSPAD
&&
1088 data
[0] != WACOM_REPORT_INTUOS_PEN
&&
1089 data
[0] != WACOM_REPORT_CINTIQ
&&
1090 data
[0] != WACOM_REPORT_CINTIQPAD
&&
1091 data
[0] != WACOM_REPORT_INTUOS5PAD
) {
1092 dev_dbg(input
->dev
.parent
,
1093 "%s: received unknown report #%d\n", __func__
, data
[0]);
1097 /* process pad events */
1098 result
= wacom_intuos_pad(wacom
);
1102 /* process in/out prox events */
1103 result
= wacom_intuos_inout(wacom
);
1107 /* process general packets */
1108 result
= wacom_intuos_general(wacom
);
1115 static int int_dist(int x1
, int y1
, int x2
, int y2
)
1120 return int_sqrt(x
*x
+ y
*y
);
1123 static void wacom_intuos_bt_process_data(struct wacom_wac
*wacom
,
1124 unsigned char *data
)
1126 memcpy(wacom
->data
, data
, 10);
1127 wacom_intuos_irq(wacom
);
1129 input_sync(wacom
->pen_input
);
1130 if (wacom
->pad_input
)
1131 input_sync(wacom
->pad_input
);
1134 static int wacom_intuos_bt_irq(struct wacom_wac
*wacom
, size_t len
)
1136 unsigned char data
[WACOM_PKGLEN_MAX
];
1138 unsigned power_raw
, battery_capacity
, bat_charging
, ps_connected
;
1140 memcpy(data
, wacom
->data
, len
);
1144 wacom_intuos_bt_process_data(wacom
, data
+ i
);
1148 wacom_intuos_bt_process_data(wacom
, data
+ i
);
1150 wacom_intuos_bt_process_data(wacom
, data
+ i
);
1152 power_raw
= data
[i
];
1153 bat_charging
= (power_raw
& 0x08) ? 1 : 0;
1154 ps_connected
= (power_raw
& 0x10) ? 1 : 0;
1155 battery_capacity
= batcap_i4
[power_raw
& 0x07];
1156 wacom_notify_battery(wacom
, battery_capacity
, bat_charging
,
1157 battery_capacity
|| bat_charging
,
1161 dev_dbg(wacom
->pen_input
->dev
.parent
,
1162 "Unknown report: %d,%d size:%zu\n",
1163 data
[0], data
[1], len
);
1169 static int wacom_wac_finger_count_touches(struct wacom_wac
*wacom
)
1171 struct input_dev
*input
= wacom
->touch_input
;
1172 unsigned touch_max
= wacom
->features
.touch_max
;
1180 return test_bit(BTN_TOUCH
, input
->key
) &&
1181 report_touch_events(wacom
);
1183 for (i
= 0; i
< input
->mt
->num_slots
; i
++) {
1184 struct input_mt_slot
*ps
= &input
->mt
->slots
[i
];
1185 int id
= input_mt_get_value(ps
, ABS_MT_TRACKING_ID
);
1193 static int wacom_24hdt_irq(struct wacom_wac
*wacom
)
1195 struct input_dev
*input
= wacom
->touch_input
;
1196 unsigned char *data
= wacom
->data
;
1198 int current_num_contacts
= data
[61];
1199 int contacts_to_send
= 0;
1200 int num_contacts_left
= 4; /* maximum contacts per packet */
1201 int byte_per_packet
= WACOM_BYTES_PER_24HDT_PACKET
;
1204 if (wacom
->features
.type
== WACOM_27QHDT
) {
1205 current_num_contacts
= data
[63];
1206 num_contacts_left
= 10;
1207 byte_per_packet
= WACOM_BYTES_PER_QHDTHID_PACKET
;
1212 * First packet resets the counter since only the first
1213 * packet in series will have non-zero current_num_contacts.
1215 if (current_num_contacts
)
1216 wacom
->num_contacts_left
= current_num_contacts
;
1218 contacts_to_send
= min(num_contacts_left
, wacom
->num_contacts_left
);
1220 for (i
= 0; i
< contacts_to_send
; i
++) {
1221 int offset
= (byte_per_packet
* i
) + 1;
1222 bool touch
= (data
[offset
] & 0x1) && report_touch_events(wacom
);
1223 int slot
= input_mt_get_slot_by_key(input
, data
[offset
+ 1]);
1227 input_mt_slot(input
, slot
);
1228 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, touch
);
1231 int t_x
= get_unaligned_le16(&data
[offset
+ 2]);
1232 int t_y
= get_unaligned_le16(&data
[offset
+ 4 + y_offset
]);
1234 input_report_abs(input
, ABS_MT_POSITION_X
, t_x
);
1235 input_report_abs(input
, ABS_MT_POSITION_Y
, t_y
);
1237 if (wacom
->features
.type
!= WACOM_27QHDT
) {
1238 int c_x
= get_unaligned_le16(&data
[offset
+ 4]);
1239 int c_y
= get_unaligned_le16(&data
[offset
+ 8]);
1240 int w
= get_unaligned_le16(&data
[offset
+ 10]);
1241 int h
= get_unaligned_le16(&data
[offset
+ 12]);
1243 input_report_abs(input
, ABS_MT_TOUCH_MAJOR
, min(w
,h
));
1244 input_report_abs(input
, ABS_MT_WIDTH_MAJOR
,
1245 min(w
, h
) + int_dist(t_x
, t_y
, c_x
, c_y
));
1246 input_report_abs(input
, ABS_MT_WIDTH_MINOR
, min(w
, h
));
1247 input_report_abs(input
, ABS_MT_ORIENTATION
, w
> h
);
1251 input_mt_sync_frame(input
);
1253 wacom
->num_contacts_left
-= contacts_to_send
;
1254 if (wacom
->num_contacts_left
<= 0) {
1255 wacom
->num_contacts_left
= 0;
1256 wacom
->shared
->touch_down
= wacom_wac_finger_count_touches(wacom
);
1261 static int wacom_mt_touch(struct wacom_wac
*wacom
)
1263 struct input_dev
*input
= wacom
->touch_input
;
1264 unsigned char *data
= wacom
->data
;
1266 int current_num_contacts
= data
[2];
1267 int contacts_to_send
= 0;
1270 /* MTTPC does not support Height and Width */
1271 if (wacom
->features
.type
== MTTPC
|| wacom
->features
.type
== MTTPC_B
)
1275 * First packet resets the counter since only the first
1276 * packet in series will have non-zero current_num_contacts.
1278 if (current_num_contacts
)
1279 wacom
->num_contacts_left
= current_num_contacts
;
1281 /* There are at most 5 contacts per packet */
1282 contacts_to_send
= min(5, wacom
->num_contacts_left
);
1284 for (i
= 0; i
< contacts_to_send
; i
++) {
1285 int offset
= (WACOM_BYTES_PER_MT_PACKET
+ x_offset
) * i
+ 3;
1286 bool touch
= (data
[offset
] & 0x1) && report_touch_events(wacom
);
1287 int id
= get_unaligned_le16(&data
[offset
+ 1]);
1288 int slot
= input_mt_get_slot_by_key(input
, id
);
1293 input_mt_slot(input
, slot
);
1294 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, touch
);
1296 int x
= get_unaligned_le16(&data
[offset
+ x_offset
+ 7]);
1297 int y
= get_unaligned_le16(&data
[offset
+ x_offset
+ 9]);
1298 input_report_abs(input
, ABS_MT_POSITION_X
, x
);
1299 input_report_abs(input
, ABS_MT_POSITION_Y
, y
);
1302 input_mt_sync_frame(input
);
1304 wacom
->num_contacts_left
-= contacts_to_send
;
1305 if (wacom
->num_contacts_left
<= 0) {
1306 wacom
->num_contacts_left
= 0;
1307 wacom
->shared
->touch_down
= wacom_wac_finger_count_touches(wacom
);
1312 static int wacom_tpc_mt_touch(struct wacom_wac
*wacom
)
1314 struct input_dev
*input
= wacom
->touch_input
;
1315 unsigned char *data
= wacom
->data
;
1318 for (i
= 0; i
< 2; i
++) {
1319 int p
= data
[1] & (1 << i
);
1320 bool touch
= p
&& report_touch_events(wacom
);
1322 input_mt_slot(input
, i
);
1323 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, touch
);
1325 int x
= le16_to_cpup((__le16
*)&data
[i
* 2 + 2]) & 0x7fff;
1326 int y
= le16_to_cpup((__le16
*)&data
[i
* 2 + 6]) & 0x7fff;
1328 input_report_abs(input
, ABS_MT_POSITION_X
, x
);
1329 input_report_abs(input
, ABS_MT_POSITION_Y
, y
);
1332 input_mt_sync_frame(input
);
1334 /* keep touch state for pen event */
1335 wacom
->shared
->touch_down
= wacom_wac_finger_count_touches(wacom
);
1340 static int wacom_tpc_single_touch(struct wacom_wac
*wacom
, size_t len
)
1342 unsigned char *data
= wacom
->data
;
1343 struct input_dev
*input
= wacom
->touch_input
;
1344 bool prox
= report_touch_events(wacom
);
1347 if (wacom
->features
.touch_max
> 1 || len
> WACOM_PKGLEN_TPC2FG
)
1350 if (len
== WACOM_PKGLEN_TPC1FG
) {
1351 prox
= prox
&& (data
[0] & 0x01);
1352 x
= get_unaligned_le16(&data
[1]);
1353 y
= get_unaligned_le16(&data
[3]);
1354 } else if (len
== WACOM_PKGLEN_TPC1FG_B
) {
1355 prox
= prox
&& (data
[2] & 0x01);
1356 x
= get_unaligned_le16(&data
[3]);
1357 y
= get_unaligned_le16(&data
[5]);
1359 prox
= prox
&& (data
[1] & 0x01);
1360 x
= le16_to_cpup((__le16
*)&data
[2]);
1361 y
= le16_to_cpup((__le16
*)&data
[4]);
1365 input_report_abs(input
, ABS_X
, x
);
1366 input_report_abs(input
, ABS_Y
, y
);
1368 input_report_key(input
, BTN_TOUCH
, prox
);
1370 /* keep touch state for pen events */
1371 wacom
->shared
->touch_down
= prox
;
1376 static int wacom_tpc_pen(struct wacom_wac
*wacom
)
1378 unsigned char *data
= wacom
->data
;
1379 struct input_dev
*input
= wacom
->pen_input
;
1380 bool prox
= data
[1] & 0x20;
1382 if (!wacom
->shared
->stylus_in_proximity
) /* first in prox */
1383 /* Going into proximity select tool */
1384 wacom
->tool
[0] = (data
[1] & 0x0c) ? BTN_TOOL_RUBBER
: BTN_TOOL_PEN
;
1386 /* keep pen state for touch events */
1387 wacom
->shared
->stylus_in_proximity
= prox
;
1389 /* send pen events only when touch is up or forced out
1390 * or touch arbitration is off
1392 if (!delay_pen_events(wacom
)) {
1393 input_report_key(input
, BTN_STYLUS
, data
[1] & 0x02);
1394 input_report_key(input
, BTN_STYLUS2
, data
[1] & 0x10);
1395 input_report_abs(input
, ABS_X
, le16_to_cpup((__le16
*)&data
[2]));
1396 input_report_abs(input
, ABS_Y
, le16_to_cpup((__le16
*)&data
[4]));
1397 input_report_abs(input
, ABS_PRESSURE
, ((data
[7] & 0x07) << 8) | data
[6]);
1398 input_report_key(input
, BTN_TOUCH
, data
[1] & 0x05);
1399 input_report_key(input
, wacom
->tool
[0], prox
);
1406 static int wacom_tpc_irq(struct wacom_wac
*wacom
, size_t len
)
1408 unsigned char *data
= wacom
->data
;
1410 if (wacom
->pen_input
)
1411 dev_dbg(wacom
->pen_input
->dev
.parent
,
1412 "%s: received report #%d\n", __func__
, data
[0]);
1413 else if (wacom
->touch_input
)
1414 dev_dbg(wacom
->touch_input
->dev
.parent
,
1415 "%s: received report #%d\n", __func__
, data
[0]);
1418 case WACOM_PKGLEN_TPC1FG
:
1419 return wacom_tpc_single_touch(wacom
, len
);
1421 case WACOM_PKGLEN_TPC2FG
:
1422 return wacom_tpc_mt_touch(wacom
);
1424 case WACOM_PKGLEN_PENABLED
:
1425 return wacom_tpc_pen(wacom
);
1429 case WACOM_REPORT_TPC1FG
:
1430 case WACOM_REPORT_TPCHID
:
1431 case WACOM_REPORT_TPCST
:
1432 case WACOM_REPORT_TPC1FGE
:
1433 return wacom_tpc_single_touch(wacom
, len
);
1435 case WACOM_REPORT_TPCMT
:
1436 case WACOM_REPORT_TPCMT2
:
1437 return wacom_mt_touch(wacom
);
1439 case WACOM_REPORT_PENABLED
:
1440 return wacom_tpc_pen(wacom
);
1447 static int wacom_equivalent_usage(int usage
)
1449 if ((usage
& HID_USAGE_PAGE
) == WACOM_HID_UP_WACOMDIGITIZER
) {
1450 int subpage
= (usage
& 0xFF00) << 8;
1451 int subusage
= (usage
& 0xFF);
1453 if (subpage
== WACOM_HID_SP_PAD
||
1454 subpage
== WACOM_HID_SP_BUTTON
||
1455 subpage
== WACOM_HID_SP_DIGITIZER
||
1456 subpage
== WACOM_HID_SP_DIGITIZERINFO
||
1457 usage
== WACOM_HID_WD_SENSE
||
1458 usage
== WACOM_HID_WD_SERIALHI
||
1459 usage
== WACOM_HID_WD_TOOLTYPE
||
1460 usage
== WACOM_HID_WD_DISTANCE
||
1461 usage
== WACOM_HID_WD_TOUCHSTRIP
||
1462 usage
== WACOM_HID_WD_TOUCHSTRIP2
||
1463 usage
== WACOM_HID_WD_TOUCHRING
||
1464 usage
== WACOM_HID_WD_TOUCHRINGSTATUS
) {
1468 if (subpage
== HID_UP_UNDEFINED
)
1469 subpage
= HID_UP_DIGITIZER
;
1471 return subpage
| subusage
;
1477 static void wacom_map_usage(struct input_dev
*input
, struct hid_usage
*usage
,
1478 struct hid_field
*field
, __u8 type
, __u16 code
, int fuzz
)
1480 struct wacom
*wacom
= input_get_drvdata(input
);
1481 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1482 struct wacom_features
*features
= &wacom_wac
->features
;
1483 int fmin
= field
->logical_minimum
;
1484 int fmax
= field
->logical_maximum
;
1485 unsigned int equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
1486 int resolution_code
= code
;
1488 if (equivalent_usage
== HID_DG_TWIST
) {
1489 resolution_code
= ABS_RZ
;
1492 if (equivalent_usage
== HID_GD_X
) {
1493 fmin
+= features
->offset_left
;
1494 fmax
-= features
->offset_right
;
1496 if (equivalent_usage
== HID_GD_Y
) {
1497 fmin
+= features
->offset_top
;
1498 fmax
-= features
->offset_bottom
;
1504 set_bit(type
, input
->evbit
);
1508 input_set_abs_params(input
, code
, fmin
, fmax
, fuzz
, 0);
1509 input_abs_set_res(input
, code
,
1510 hidinput_calc_abs_res(field
, resolution_code
));
1513 input_set_capability(input
, EV_KEY
, code
);
1516 input_set_capability(input
, EV_MSC
, code
);
1519 input_set_capability(input
, EV_SW
, code
);
1524 static void wacom_wac_pad_usage_mapping(struct hid_device
*hdev
,
1525 struct hid_field
*field
, struct hid_usage
*usage
)
1527 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1528 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1529 struct wacom_features
*features
= &wacom_wac
->features
;
1530 struct input_dev
*input
= wacom_wac
->pad_input
;
1531 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
1533 switch (equivalent_usage
) {
1534 case WACOM_HID_WD_BATTERY_LEVEL
:
1535 case WACOM_HID_WD_BATTERY_CHARGING
:
1536 features
->quirks
|= WACOM_QUIRK_BATTERY
;
1538 case WACOM_HID_WD_ACCELEROMETER_X
:
1539 __set_bit(INPUT_PROP_ACCELEROMETER
, input
->propbit
);
1540 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_X
, 0);
1542 case WACOM_HID_WD_ACCELEROMETER_Y
:
1543 __set_bit(INPUT_PROP_ACCELEROMETER
, input
->propbit
);
1544 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_Y
, 0);
1546 case WACOM_HID_WD_ACCELEROMETER_Z
:
1547 __set_bit(INPUT_PROP_ACCELEROMETER
, input
->propbit
);
1548 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_Z
, 0);
1550 case WACOM_HID_WD_BUTTONHOME
:
1551 case WACOM_HID_WD_BUTTONUP
:
1552 case WACOM_HID_WD_BUTTONDOWN
:
1553 case WACOM_HID_WD_BUTTONLEFT
:
1554 case WACOM_HID_WD_BUTTONRIGHT
:
1555 case WACOM_HID_WD_BUTTONCENTER
:
1556 wacom_map_usage(input
, usage
, field
, EV_KEY
,
1557 wacom_numbered_button_to_key(features
->numbered_buttons
),
1559 features
->numbered_buttons
++;
1561 case WACOM_HID_WD_TOUCHONOFF
:
1562 wacom_map_usage(input
, usage
, field
, EV_SW
, SW_MUTE_DEVICE
, 0);
1564 case WACOM_HID_WD_TOUCHSTRIP
:
1565 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_RX
, 0);
1567 case WACOM_HID_WD_TOUCHSTRIP2
:
1568 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_RY
, 0);
1570 case WACOM_HID_WD_TOUCHRING
:
1571 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_WHEEL
, 0);
1575 switch (equivalent_usage
& 0xfffffff0) {
1576 case WACOM_HID_WD_EXPRESSKEY00
:
1577 wacom_map_usage(input
, usage
, field
, EV_KEY
,
1578 wacom_numbered_button_to_key(features
->numbered_buttons
),
1580 features
->numbered_buttons
++;
1585 static void wacom_wac_pad_event(struct hid_device
*hdev
, struct hid_field
*field
,
1586 struct hid_usage
*usage
, __s32 value
)
1588 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1589 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1590 struct input_dev
*input
= wacom_wac
->pad_input
;
1591 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
1593 if (wacom_equivalent_usage(field
->physical
) == HID_DG_TABLETFUNCTIONKEY
) {
1594 wacom_wac
->hid_data
.inrange_state
|= value
;
1597 switch (equivalent_usage
) {
1598 case WACOM_HID_WD_BATTERY_LEVEL
:
1599 wacom_wac
->hid_data
.battery_capacity
= value
;
1600 wacom_wac
->hid_data
.bat_connected
= 1;
1603 case WACOM_HID_WD_BATTERY_CHARGING
:
1604 wacom_wac
->hid_data
.bat_charging
= value
;
1605 wacom_wac
->hid_data
.ps_connected
= value
;
1606 wacom_wac
->hid_data
.bat_connected
= 1;
1609 case WACOM_HID_WD_TOUCHRINGSTATUS
:
1613 input_event(input
, usage
->type
, usage
->code
, value
);
1618 static void wacom_wac_pad_pre_report(struct hid_device
*hdev
,
1619 struct hid_report
*report
)
1621 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1622 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1624 wacom_wac
->hid_data
.inrange_state
= 0;
1627 static void wacom_wac_pad_report(struct hid_device
*hdev
,
1628 struct hid_report
*report
)
1630 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1631 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1632 struct wacom_features
*features
= &wacom_wac
->features
;
1633 struct input_dev
*input
= wacom_wac
->pad_input
;
1634 bool active
= wacom_wac
->hid_data
.inrange_state
!= 0;
1637 * don't report prox for events like accelerometer
1640 if (wacom_equivalent_usage(report
->field
[0]->physical
) == HID_DG_TABLETFUNCTIONKEY
)
1641 input_event(input
, EV_ABS
, ABS_MISC
, active
? PAD_DEVICE_ID
: 0);
1643 if (features
->quirks
& WACOM_QUIRK_BATTERY
) {
1644 int capacity
= wacom_wac
->hid_data
.battery_capacity
;
1645 bool charging
= wacom_wac
->hid_data
.bat_charging
;
1646 bool connected
= wacom_wac
->hid_data
.bat_connected
;
1647 bool powered
= wacom_wac
->hid_data
.ps_connected
;
1649 wacom_notify_battery(wacom_wac
, capacity
, charging
,
1650 connected
, powered
);
1656 static void wacom_wac_pen_usage_mapping(struct hid_device
*hdev
,
1657 struct hid_field
*field
, struct hid_usage
*usage
)
1659 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1660 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1661 struct wacom_features
*features
= &wacom_wac
->features
;
1662 struct input_dev
*input
= wacom_wac
->pen_input
;
1663 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
1665 switch (equivalent_usage
) {
1667 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_X
, 4);
1670 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_Y
, 4);
1672 case WACOM_HID_WD_DISTANCE
:
1674 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_DISTANCE
, 0);
1676 case HID_DG_TIPPRESSURE
:
1677 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_PRESSURE
, 0);
1679 case HID_DG_INRANGE
:
1680 wacom_map_usage(input
, usage
, field
, EV_KEY
, BTN_TOOL_PEN
, 0);
1682 case HID_DG_BATTERYSTRENGTH
:
1683 features
->quirks
|= WACOM_QUIRK_BATTERY
;
1686 wacom_map_usage(input
, usage
, field
, EV_KEY
,
1687 BTN_TOOL_RUBBER
, 0);
1690 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_TILT_X
, 0);
1693 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_TILT_Y
, 0);
1696 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_Z
, 0);
1699 case HID_DG_TIPSWITCH
:
1700 wacom_map_usage(input
, usage
, field
, EV_KEY
, BTN_TOUCH
, 0);
1702 case HID_DG_BARRELSWITCH
:
1703 wacom_map_usage(input
, usage
, field
, EV_KEY
, BTN_STYLUS
, 0);
1705 case HID_DG_BARRELSWITCH2
:
1706 wacom_map_usage(input
, usage
, field
, EV_KEY
, BTN_STYLUS2
, 0);
1708 case HID_DG_TOOLSERIALNUMBER
:
1709 wacom_map_usage(input
, usage
, field
, EV_MSC
, MSC_SERIAL
, 0);
1711 case WACOM_HID_WD_SENSE
:
1712 features
->quirks
|= WACOM_QUIRK_SENSE
;
1713 wacom_map_usage(input
, usage
, field
, EV_KEY
, BTN_TOOL_PEN
, 0);
1715 case WACOM_HID_WD_SERIALHI
:
1716 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_MISC
, 0);
1717 set_bit(EV_KEY
, input
->evbit
);
1718 input_set_capability(input
, EV_KEY
, BTN_TOOL_PEN
);
1719 input_set_capability(input
, EV_KEY
, BTN_TOOL_RUBBER
);
1720 input_set_capability(input
, EV_KEY
, BTN_TOOL_BRUSH
);
1721 input_set_capability(input
, EV_KEY
, BTN_TOOL_PENCIL
);
1722 input_set_capability(input
, EV_KEY
, BTN_TOOL_AIRBRUSH
);
1723 input_set_capability(input
, EV_KEY
, BTN_TOOL_MOUSE
);
1724 input_set_capability(input
, EV_KEY
, BTN_TOOL_LENS
);
1726 case WACOM_HID_WD_FINGERWHEEL
:
1727 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_WHEEL
, 0);
1732 static void wacom_wac_pen_event(struct hid_device
*hdev
, struct hid_field
*field
,
1733 struct hid_usage
*usage
, __s32 value
)
1735 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1736 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1737 struct wacom_features
*features
= &wacom_wac
->features
;
1738 struct input_dev
*input
= wacom_wac
->pen_input
;
1739 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
1741 switch (equivalent_usage
) {
1744 * HID_GD_Z "should increase as the control's position is
1745 * moved from high to low", while ABS_DISTANCE instead
1746 * increases in value as the tool moves from low to high.
1748 value
= field
->logical_maximum
- value
;
1750 case HID_DG_INRANGE
:
1751 wacom_wac
->hid_data
.inrange_state
= value
;
1752 if (!(features
->quirks
& WACOM_QUIRK_SENSE
))
1753 wacom_wac
->hid_data
.sense_state
= value
;
1755 case HID_DG_BATTERYSTRENGTH
:
1756 wacom_wac
->hid_data
.battery_capacity
= value
;
1757 wacom_wac
->hid_data
.bat_connected
= 1;
1760 wacom_wac
->hid_data
.invert_state
= value
;
1763 case HID_DG_TIPSWITCH
:
1764 wacom_wac
->hid_data
.tipswitch
|= value
;
1766 case HID_DG_TOOLSERIALNUMBER
:
1767 wacom_wac
->serial
[0] = (wacom_wac
->serial
[0] & ~0xFFFFFFFFULL
);
1768 wacom_wac
->serial
[0] |= value
;
1770 case WACOM_HID_WD_SENSE
:
1771 wacom_wac
->hid_data
.sense_state
= value
;
1773 case WACOM_HID_WD_SERIALHI
:
1774 wacom_wac
->serial
[0] = (wacom_wac
->serial
[0] & 0xFFFFFFFF);
1775 wacom_wac
->serial
[0] |= ((__u64
)value
) << 32;
1777 * Non-USI EMR devices may contain additional tool type
1778 * information here. See WACOM_HID_WD_TOOLTYPE case for
1781 if (value
>> 20 == 1) {
1782 wacom_wac
->id
[0] |= value
& 0xFFFFF;
1785 case WACOM_HID_WD_TOOLTYPE
:
1787 * Some devices (MobileStudio Pro, and possibly later
1788 * devices as well) do not return the complete tool
1789 * type in their WACOM_HID_WD_TOOLTYPE usage. Use a
1790 * bitwise OR so the complete value can be built
1793 wacom_wac
->id
[0] |= value
;
1795 case WACOM_HID_WD_OFFSETLEFT
:
1796 if (features
->offset_left
&& value
!= features
->offset_left
)
1797 hid_warn(hdev
, "%s: overriding exising left offset "
1798 "%d -> %d\n", __func__
, value
,
1799 features
->offset_left
);
1800 features
->offset_left
= value
;
1802 case WACOM_HID_WD_OFFSETRIGHT
:
1803 if (features
->offset_right
&& value
!= features
->offset_right
)
1804 hid_warn(hdev
, "%s: overriding exising right offset "
1805 "%d -> %d\n", __func__
, value
,
1806 features
->offset_right
);
1807 features
->offset_right
= value
;
1809 case WACOM_HID_WD_OFFSETTOP
:
1810 if (features
->offset_top
&& value
!= features
->offset_top
)
1811 hid_warn(hdev
, "%s: overriding exising top offset "
1812 "%d -> %d\n", __func__
, value
,
1813 features
->offset_top
);
1814 features
->offset_top
= value
;
1816 case WACOM_HID_WD_OFFSETBOTTOM
:
1817 if (features
->offset_bottom
&& value
!= features
->offset_bottom
)
1818 hid_warn(hdev
, "%s: overriding exising bottom offset "
1819 "%d -> %d\n", __func__
, value
,
1820 features
->offset_bottom
);
1821 features
->offset_bottom
= value
;
1825 /* send pen events only when touch is up or forced out
1826 * or touch arbitration is off
1828 if (!usage
->type
|| delay_pen_events(wacom_wac
))
1831 /* send pen events only when the pen is in/entering/leaving proximity */
1832 if (!wacom_wac
->hid_data
.inrange_state
&& !wacom_wac
->tool
[0])
1835 input_event(input
, usage
->type
, usage
->code
, value
);
1838 static void wacom_wac_pen_pre_report(struct hid_device
*hdev
,
1839 struct hid_report
*report
)
1844 static void wacom_wac_pen_report(struct hid_device
*hdev
,
1845 struct hid_report
*report
)
1847 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1848 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1849 struct input_dev
*input
= wacom_wac
->pen_input
;
1850 bool prox
= wacom_wac
->hid_data
.inrange_state
;
1851 bool range
= wacom_wac
->hid_data
.sense_state
;
1853 if (!wacom_wac
->tool
[0] && prox
) { /* first in prox */
1854 /* Going into proximity select tool */
1855 if (wacom_wac
->hid_data
.invert_state
)
1856 wacom_wac
->tool
[0] = BTN_TOOL_RUBBER
;
1857 else if (wacom_wac
->id
[0])
1858 wacom_wac
->tool
[0] = wacom_intuos_get_tool_type(wacom_wac
->id
[0]);
1860 wacom_wac
->tool
[0] = BTN_TOOL_PEN
;
1863 /* keep pen state for touch events */
1864 wacom_wac
->shared
->stylus_in_proximity
= range
;
1866 if (!delay_pen_events(wacom_wac
) && wacom_wac
->tool
[0]) {
1867 int id
= wacom_wac
->id
[0];
1870 * Non-USI EMR tools should have their IDs mangled to
1871 * match the legacy behavior of wacom_intuos_general
1873 if (wacom_wac
->serial
[0] >> 52 == 1)
1874 id
= wacom_intuos_id_mangle(id
);
1877 * To ensure compatibility with xf86-input-wacom, we should
1878 * report the BTN_TOOL_* event prior to the ABS_MISC or
1879 * MSC_SERIAL events.
1881 input_report_key(input
, BTN_TOUCH
,
1882 wacom_wac
->hid_data
.tipswitch
);
1883 input_report_key(input
, wacom_wac
->tool
[0], prox
);
1884 if (wacom_wac
->serial
[0]) {
1885 input_event(input
, EV_MSC
, MSC_SERIAL
, wacom_wac
->serial
[0]);
1886 input_report_abs(input
, ABS_MISC
, id
);
1889 wacom_wac
->hid_data
.tipswitch
= false;
1895 wacom_wac
->tool
[0] = 0;
1896 wacom_wac
->id
[0] = 0;
1900 static void wacom_wac_finger_usage_mapping(struct hid_device
*hdev
,
1901 struct hid_field
*field
, struct hid_usage
*usage
)
1903 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1904 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1905 struct input_dev
*input
= wacom_wac
->touch_input
;
1906 unsigned touch_max
= wacom_wac
->features
.touch_max
;
1907 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
1909 switch (equivalent_usage
) {
1912 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_X
, 4);
1914 wacom_map_usage(input
, usage
, field
, EV_ABS
,
1915 ABS_MT_POSITION_X
, 4);
1919 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_Y
, 4);
1921 wacom_map_usage(input
, usage
, field
, EV_ABS
,
1922 ABS_MT_POSITION_Y
, 4);
1926 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_MT_TOUCH_MAJOR
, 0);
1927 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_MT_TOUCH_MINOR
, 0);
1928 input_set_abs_params(input
, ABS_MT_ORIENTATION
, 0, 1, 0, 0);
1930 case HID_DG_TIPSWITCH
:
1931 wacom_map_usage(input
, usage
, field
, EV_KEY
, BTN_TOUCH
, 0);
1933 case HID_DG_CONTACTCOUNT
:
1934 wacom_wac
->hid_data
.cc_report
= field
->report
->id
;
1935 wacom_wac
->hid_data
.cc_index
= field
->index
;
1936 wacom_wac
->hid_data
.cc_value_index
= usage
->usage_index
;
1941 static void wacom_wac_finger_slot(struct wacom_wac
*wacom_wac
,
1942 struct input_dev
*input
)
1944 struct hid_data
*hid_data
= &wacom_wac
->hid_data
;
1945 bool mt
= wacom_wac
->features
.touch_max
> 1;
1946 bool prox
= hid_data
->tipswitch
&&
1947 report_touch_events(wacom_wac
);
1949 wacom_wac
->hid_data
.num_received
++;
1950 if (wacom_wac
->hid_data
.num_received
> wacom_wac
->hid_data
.num_expected
)
1956 slot
= input_mt_get_slot_by_key(input
, hid_data
->id
);
1957 input_mt_slot(input
, slot
);
1958 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, prox
);
1961 input_report_key(input
, BTN_TOUCH
, prox
);
1965 input_report_abs(input
, mt
? ABS_MT_POSITION_X
: ABS_X
,
1967 input_report_abs(input
, mt
? ABS_MT_POSITION_Y
: ABS_Y
,
1970 if (test_bit(ABS_MT_TOUCH_MAJOR
, input
->absbit
)) {
1971 input_report_abs(input
, ABS_MT_TOUCH_MAJOR
, max(hid_data
->width
, hid_data
->height
));
1972 input_report_abs(input
, ABS_MT_TOUCH_MINOR
, min(hid_data
->width
, hid_data
->height
));
1973 if (hid_data
->width
!= hid_data
->height
)
1974 input_report_abs(input
, ABS_MT_ORIENTATION
, hid_data
->width
<= hid_data
->height
? 0 : 1);
1979 static void wacom_wac_finger_event(struct hid_device
*hdev
,
1980 struct hid_field
*field
, struct hid_usage
*usage
, __s32 value
)
1982 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1983 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1984 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
1986 switch (equivalent_usage
) {
1988 wacom_wac
->hid_data
.x
= value
;
1991 wacom_wac
->hid_data
.y
= value
;
1994 wacom_wac
->hid_data
.width
= value
;
1997 wacom_wac
->hid_data
.height
= value
;
1999 case HID_DG_CONTACTID
:
2000 wacom_wac
->hid_data
.id
= value
;
2002 case HID_DG_TIPSWITCH
:
2003 wacom_wac
->hid_data
.tipswitch
= value
;
2008 if (usage
->usage_index
+ 1 == field
->report_count
) {
2009 if (equivalent_usage
== wacom_wac
->hid_data
.last_slot_field
)
2010 wacom_wac_finger_slot(wacom_wac
, wacom_wac
->touch_input
);
2014 static void wacom_wac_finger_pre_report(struct hid_device
*hdev
,
2015 struct hid_report
*report
)
2017 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2018 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2019 struct hid_data
* hid_data
= &wacom_wac
->hid_data
;
2022 for (i
= 0; i
< report
->maxfield
; i
++) {
2023 struct hid_field
*field
= report
->field
[i
];
2026 for (j
= 0; j
< field
->maxusage
; j
++) {
2027 struct hid_usage
*usage
= &field
->usage
[j
];
2029 switch (usage
->hid
) {
2034 case HID_DG_CONTACTID
:
2035 case HID_DG_INRANGE
:
2037 case HID_DG_TIPSWITCH
:
2038 hid_data
->last_slot_field
= usage
->hid
;
2040 case HID_DG_CONTACTCOUNT
:
2041 hid_data
->cc_report
= report
->id
;
2042 hid_data
->cc_index
= i
;
2043 hid_data
->cc_value_index
= j
;
2049 if (hid_data
->cc_report
!= 0 &&
2050 hid_data
->cc_index
>= 0) {
2051 struct hid_field
*field
= report
->field
[hid_data
->cc_index
];
2052 int value
= field
->value
[hid_data
->cc_value_index
];
2054 hid_data
->num_expected
= value
;
2057 hid_data
->num_expected
= wacom_wac
->features
.touch_max
;
2061 static void wacom_wac_finger_report(struct hid_device
*hdev
,
2062 struct hid_report
*report
)
2064 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2065 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2066 struct input_dev
*input
= wacom_wac
->touch_input
;
2067 unsigned touch_max
= wacom_wac
->features
.touch_max
;
2069 /* If more packets of data are expected, give us a chance to
2070 * process them rather than immediately syncing a partial
2073 if (wacom_wac
->hid_data
.num_received
< wacom_wac
->hid_data
.num_expected
)
2077 input_mt_sync_frame(input
);
2080 wacom_wac
->hid_data
.num_received
= 0;
2082 /* keep touch state for pen event */
2083 wacom_wac
->shared
->touch_down
= wacom_wac_finger_count_touches(wacom_wac
);
2086 void wacom_wac_usage_mapping(struct hid_device
*hdev
,
2087 struct hid_field
*field
, struct hid_usage
*usage
)
2089 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2090 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2091 struct wacom_features
*features
= &wacom_wac
->features
;
2093 /* currently, only direct devices have proper hid report descriptors */
2094 features
->device_type
|= WACOM_DEVICETYPE_DIRECT
;
2096 if (WACOM_PAD_FIELD(field
))
2097 wacom_wac_pad_usage_mapping(hdev
, field
, usage
);
2098 else if (WACOM_PEN_FIELD(field
))
2099 wacom_wac_pen_usage_mapping(hdev
, field
, usage
);
2100 else if (WACOM_FINGER_FIELD(field
))
2101 wacom_wac_finger_usage_mapping(hdev
, field
, usage
);
2104 void wacom_wac_event(struct hid_device
*hdev
, struct hid_field
*field
,
2105 struct hid_usage
*usage
, __s32 value
)
2107 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2109 if (wacom
->wacom_wac
.features
.type
!= HID_GENERIC
)
2112 if (WACOM_PAD_FIELD(field
) && wacom
->wacom_wac
.pad_input
)
2113 wacom_wac_pad_event(hdev
, field
, usage
, value
);
2114 else if (WACOM_PEN_FIELD(field
) && wacom
->wacom_wac
.pen_input
)
2115 wacom_wac_pen_event(hdev
, field
, usage
, value
);
2116 else if (WACOM_FINGER_FIELD(field
) && wacom
->wacom_wac
.touch_input
)
2117 wacom_wac_finger_event(hdev
, field
, usage
, value
);
2120 static void wacom_report_events(struct hid_device
*hdev
, struct hid_report
*report
)
2124 for (r
= 0; r
< report
->maxfield
; r
++) {
2125 struct hid_field
*field
;
2128 field
= report
->field
[r
];
2129 count
= field
->report_count
;
2131 if (!(HID_MAIN_ITEM_VARIABLE
& field
->flags
))
2134 for (n
= 0; n
< count
; n
++)
2135 wacom_wac_event(hdev
, field
, &field
->usage
[n
], field
->value
[n
]);
2139 void wacom_wac_report(struct hid_device
*hdev
, struct hid_report
*report
)
2141 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2142 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2143 struct hid_field
*field
= report
->field
[0];
2145 if (wacom_wac
->features
.type
!= HID_GENERIC
)
2148 if (WACOM_PAD_FIELD(field
) && wacom
->wacom_wac
.pad_input
)
2149 wacom_wac_pad_pre_report(hdev
, report
);
2150 else if (WACOM_PEN_FIELD(field
) && wacom
->wacom_wac
.pen_input
)
2151 wacom_wac_pen_pre_report(hdev
, report
);
2152 else if (WACOM_FINGER_FIELD(field
) && wacom
->wacom_wac
.touch_input
)
2153 wacom_wac_finger_pre_report(hdev
, report
);
2155 wacom_report_events(hdev
, report
);
2157 if (WACOM_PAD_FIELD(field
) && wacom
->wacom_wac
.pad_input
)
2158 return wacom_wac_pad_report(hdev
, report
);
2159 else if (WACOM_PEN_FIELD(field
) && wacom
->wacom_wac
.pen_input
)
2160 return wacom_wac_pen_report(hdev
, report
);
2161 else if (WACOM_FINGER_FIELD(field
) && wacom
->wacom_wac
.touch_input
)
2162 return wacom_wac_finger_report(hdev
, report
);
2165 static int wacom_bpt_touch(struct wacom_wac
*wacom
)
2167 struct wacom_features
*features
= &wacom
->features
;
2168 struct input_dev
*input
= wacom
->touch_input
;
2169 struct input_dev
*pad_input
= wacom
->pad_input
;
2170 unsigned char *data
= wacom
->data
;
2173 if (data
[0] != 0x02)
2176 for (i
= 0; i
< 2; i
++) {
2177 int offset
= (data
[1] & 0x80) ? (8 * i
) : (9 * i
);
2178 bool touch
= report_touch_events(wacom
)
2179 && (data
[offset
+ 3] & 0x80);
2181 input_mt_slot(input
, i
);
2182 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, touch
);
2184 int x
= get_unaligned_be16(&data
[offset
+ 3]) & 0x7ff;
2185 int y
= get_unaligned_be16(&data
[offset
+ 5]) & 0x7ff;
2186 if (features
->quirks
& WACOM_QUIRK_BBTOUCH_LOWRES
) {
2190 input_report_abs(input
, ABS_MT_POSITION_X
, x
);
2191 input_report_abs(input
, ABS_MT_POSITION_Y
, y
);
2195 input_mt_sync_frame(input
);
2197 input_report_key(pad_input
, BTN_LEFT
, (data
[1] & 0x08) != 0);
2198 input_report_key(pad_input
, BTN_FORWARD
, (data
[1] & 0x04) != 0);
2199 input_report_key(pad_input
, BTN_BACK
, (data
[1] & 0x02) != 0);
2200 input_report_key(pad_input
, BTN_RIGHT
, (data
[1] & 0x01) != 0);
2201 wacom
->shared
->touch_down
= wacom_wac_finger_count_touches(wacom
);
2206 static void wacom_bpt3_touch_msg(struct wacom_wac
*wacom
, unsigned char *data
)
2208 struct wacom_features
*features
= &wacom
->features
;
2209 struct input_dev
*input
= wacom
->touch_input
;
2210 bool touch
= data
[1] & 0x80;
2211 int slot
= input_mt_get_slot_by_key(input
, data
[0]);
2216 touch
= touch
&& report_touch_events(wacom
);
2218 input_mt_slot(input
, slot
);
2219 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, touch
);
2222 int x
= (data
[2] << 4) | (data
[4] >> 4);
2223 int y
= (data
[3] << 4) | (data
[4] & 0x0f);
2226 if (features
->type
>= INTUOSPS
&& features
->type
<= INTUOSHT2
) {
2227 width
= data
[5] * 100;
2228 height
= data
[6] * 100;
2231 * "a" is a scaled-down area which we assume is
2232 * roughly circular and which can be described as:
2236 int x_res
= input_abs_get_res(input
, ABS_MT_POSITION_X
);
2237 int y_res
= input_abs_get_res(input
, ABS_MT_POSITION_Y
);
2238 width
= 2 * int_sqrt(a
* WACOM_CONTACT_AREA_SCALE
);
2239 height
= width
* y_res
/ x_res
;
2242 input_report_abs(input
, ABS_MT_POSITION_X
, x
);
2243 input_report_abs(input
, ABS_MT_POSITION_Y
, y
);
2244 input_report_abs(input
, ABS_MT_TOUCH_MAJOR
, width
);
2245 input_report_abs(input
, ABS_MT_TOUCH_MINOR
, height
);
2249 static void wacom_bpt3_button_msg(struct wacom_wac
*wacom
, unsigned char *data
)
2251 struct input_dev
*input
= wacom
->pad_input
;
2252 struct wacom_features
*features
= &wacom
->features
;
2254 if (features
->type
== INTUOSHT
|| features
->type
== INTUOSHT2
) {
2255 input_report_key(input
, BTN_LEFT
, (data
[1] & 0x02) != 0);
2256 input_report_key(input
, BTN_BACK
, (data
[1] & 0x08) != 0);
2258 input_report_key(input
, BTN_BACK
, (data
[1] & 0x02) != 0);
2259 input_report_key(input
, BTN_LEFT
, (data
[1] & 0x08) != 0);
2261 input_report_key(input
, BTN_FORWARD
, (data
[1] & 0x04) != 0);
2262 input_report_key(input
, BTN_RIGHT
, (data
[1] & 0x01) != 0);
2265 static int wacom_bpt3_touch(struct wacom_wac
*wacom
)
2267 unsigned char *data
= wacom
->data
;
2268 int count
= data
[1] & 0x07;
2269 int touch_changed
= 0, i
;
2271 if (data
[0] != 0x02)
2274 /* data has up to 7 fixed sized 8-byte messages starting at data[2] */
2275 for (i
= 0; i
< count
; i
++) {
2276 int offset
= (8 * i
) + 2;
2277 int msg_id
= data
[offset
];
2279 if (msg_id
>= 2 && msg_id
<= 17) {
2280 wacom_bpt3_touch_msg(wacom
, data
+ offset
);
2282 } else if (msg_id
== 128)
2283 wacom_bpt3_button_msg(wacom
, data
+ offset
);
2287 /* only update touch if we actually have a touchpad and touch data changed */
2288 if (wacom
->touch_input
&& touch_changed
) {
2289 input_mt_sync_frame(wacom
->touch_input
);
2290 wacom
->shared
->touch_down
= wacom_wac_finger_count_touches(wacom
);
2296 static int wacom_bpt_pen(struct wacom_wac
*wacom
)
2298 struct wacom_features
*features
= &wacom
->features
;
2299 struct input_dev
*input
= wacom
->pen_input
;
2300 unsigned char *data
= wacom
->data
;
2301 int prox
= 0, x
= 0, y
= 0, p
= 0, d
= 0, pen
= 0, btn1
= 0, btn2
= 0;
2303 if (data
[0] != WACOM_REPORT_PENABLED
)
2306 prox
= (data
[1] & 0x20) == 0x20;
2309 * All reports shared between PEN and RUBBER tool must be
2310 * forced to a known starting value (zero) when transitioning to
2313 * If not reset then, to userspace, it will look like lost events
2314 * if new tool comes in-prox with same values as previous tool sent.
2316 * Hardware does report zero in most out-of-prox cases but not all.
2318 if (!wacom
->shared
->stylus_in_proximity
) {
2319 if (data
[1] & 0x08) {
2320 wacom
->tool
[0] = BTN_TOOL_RUBBER
;
2321 wacom
->id
[0] = ERASER_DEVICE_ID
;
2323 wacom
->tool
[0] = BTN_TOOL_PEN
;
2324 wacom
->id
[0] = STYLUS_DEVICE_ID
;
2328 wacom
->shared
->stylus_in_proximity
= prox
;
2329 if (delay_pen_events(wacom
))
2333 x
= le16_to_cpup((__le16
*)&data
[2]);
2334 y
= le16_to_cpup((__le16
*)&data
[4]);
2335 p
= le16_to_cpup((__le16
*)&data
[6]);
2337 * Convert distance from out prox to distance from tablet.
2338 * distance will be greater than distance_max once
2339 * touching and applying pressure; do not report negative
2342 if (data
[8] <= features
->distance_max
)
2343 d
= features
->distance_max
- data
[8];
2345 pen
= data
[1] & 0x01;
2346 btn1
= data
[1] & 0x02;
2347 btn2
= data
[1] & 0x04;
2352 input_report_key(input
, BTN_TOUCH
, pen
);
2353 input_report_key(input
, BTN_STYLUS
, btn1
);
2354 input_report_key(input
, BTN_STYLUS2
, btn2
);
2356 input_report_abs(input
, ABS_X
, x
);
2357 input_report_abs(input
, ABS_Y
, y
);
2358 input_report_abs(input
, ABS_PRESSURE
, p
);
2359 input_report_abs(input
, ABS_DISTANCE
, d
);
2361 input_report_key(input
, wacom
->tool
[0], prox
); /* PEN or RUBBER */
2362 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]); /* TOOL ID */
2367 static int wacom_bpt_irq(struct wacom_wac
*wacom
, size_t len
)
2369 struct wacom_features
*features
= &wacom
->features
;
2371 if ((features
->type
== INTUOSHT2
) &&
2372 (features
->device_type
& WACOM_DEVICETYPE_PEN
))
2373 return wacom_intuos_irq(wacom
);
2374 else if (len
== WACOM_PKGLEN_BBTOUCH
)
2375 return wacom_bpt_touch(wacom
);
2376 else if (len
== WACOM_PKGLEN_BBTOUCH3
)
2377 return wacom_bpt3_touch(wacom
);
2378 else if (len
== WACOM_PKGLEN_BBFUN
|| len
== WACOM_PKGLEN_BBPEN
)
2379 return wacom_bpt_pen(wacom
);
2384 static void wacom_bamboo_pad_pen_event(struct wacom_wac
*wacom
,
2385 unsigned char *data
)
2387 unsigned char prefix
;
2390 * We need to reroute the event from the debug interface to the
2392 * We need to add the report ID to the actual pen report, so we
2393 * temporary overwrite the first byte to prevent having to kzalloc/kfree
2394 * and memcpy the report.
2397 data
[0] = WACOM_REPORT_BPAD_PEN
;
2400 * actually reroute the event.
2401 * No need to check if wacom->shared->pen is valid, hid_input_report()
2402 * will check for us.
2404 hid_input_report(wacom
->shared
->pen
, HID_INPUT_REPORT
, data
,
2405 WACOM_PKGLEN_PENABLED
, 1);
2410 static int wacom_bamboo_pad_touch_event(struct wacom_wac
*wacom
,
2411 unsigned char *data
)
2413 struct input_dev
*input
= wacom
->touch_input
;
2414 unsigned char *finger_data
, prefix
;
2421 for (id
= 0; id
< wacom
->features
.touch_max
; id
++) {
2422 valid
= !!(prefix
& BIT(id
)) &&
2423 report_touch_events(wacom
);
2425 input_mt_slot(input
, id
);
2426 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, valid
);
2431 finger_data
= data
+ 1 + id
* 3;
2432 x
= finger_data
[0] | ((finger_data
[1] & 0x0f) << 8);
2433 y
= (finger_data
[2] << 4) | (finger_data
[1] >> 4);
2435 input_report_abs(input
, ABS_MT_POSITION_X
, x
);
2436 input_report_abs(input
, ABS_MT_POSITION_Y
, y
);
2439 input_mt_sync_frame(input
);
2441 input_report_key(input
, BTN_LEFT
, prefix
& 0x40);
2442 input_report_key(input
, BTN_RIGHT
, prefix
& 0x80);
2444 /* keep touch state for pen event */
2445 wacom
->shared
->touch_down
= !!prefix
&& report_touch_events(wacom
);
2450 static int wacom_bamboo_pad_irq(struct wacom_wac
*wacom
, size_t len
)
2452 unsigned char *data
= wacom
->data
;
2454 if (!((len
== WACOM_PKGLEN_BPAD_TOUCH
) ||
2455 (len
== WACOM_PKGLEN_BPAD_TOUCH_USB
)) ||
2456 (data
[0] != WACOM_REPORT_BPAD_TOUCH
))
2460 wacom_bamboo_pad_pen_event(wacom
, &data
[1]);
2463 return wacom_bamboo_pad_touch_event(wacom
, &data
[9]);
2468 static int wacom_wireless_irq(struct wacom_wac
*wacom
, size_t len
)
2470 unsigned char *data
= wacom
->data
;
2473 if (len
!= WACOM_PKGLEN_WIRELESS
|| data
[0] != WACOM_REPORT_WL
)
2476 connected
= data
[1] & 0x01;
2478 int pid
, battery
, charging
;
2480 if ((wacom
->shared
->type
== INTUOSHT
||
2481 wacom
->shared
->type
== INTUOSHT2
) &&
2482 wacom
->shared
->touch_input
&&
2483 wacom
->shared
->touch_max
) {
2484 input_report_switch(wacom
->shared
->touch_input
,
2485 SW_MUTE_DEVICE
, data
[5] & 0x40);
2486 input_sync(wacom
->shared
->touch_input
);
2489 pid
= get_unaligned_be16(&data
[6]);
2490 battery
= (data
[5] & 0x3f) * 100 / 31;
2491 charging
= !!(data
[5] & 0x80);
2492 if (wacom
->pid
!= pid
) {
2494 wacom_schedule_work(wacom
, WACOM_WORKER_WIRELESS
);
2497 wacom_notify_battery(wacom
, battery
, charging
, 1, 0);
2499 } else if (wacom
->pid
!= 0) {
2500 /* disconnected while previously connected */
2502 wacom_schedule_work(wacom
, WACOM_WORKER_WIRELESS
);
2503 wacom_notify_battery(wacom
, 0, 0, 0, 0);
2509 static int wacom_status_irq(struct wacom_wac
*wacom_wac
, size_t len
)
2511 struct wacom
*wacom
= container_of(wacom_wac
, struct wacom
, wacom_wac
);
2512 struct wacom_features
*features
= &wacom_wac
->features
;
2513 unsigned char *data
= wacom_wac
->data
;
2515 if (data
[0] != WACOM_REPORT_USB
)
2518 if ((features
->type
== INTUOSHT
||
2519 features
->type
== INTUOSHT2
) &&
2520 wacom_wac
->shared
->touch_input
&&
2521 features
->touch_max
) {
2522 input_report_switch(wacom_wac
->shared
->touch_input
,
2523 SW_MUTE_DEVICE
, data
[8] & 0x40);
2524 input_sync(wacom_wac
->shared
->touch_input
);
2527 if (data
[9] & 0x02) { /* wireless module is attached */
2528 int battery
= (data
[8] & 0x3f) * 100 / 31;
2529 bool charging
= !!(data
[8] & 0x80);
2531 wacom_notify_battery(wacom_wac
, battery
, charging
,
2532 battery
|| charging
, 1);
2534 if (!wacom
->battery
.battery
&&
2535 !(features
->quirks
& WACOM_QUIRK_BATTERY
)) {
2536 features
->quirks
|= WACOM_QUIRK_BATTERY
;
2537 wacom_schedule_work(wacom_wac
, WACOM_WORKER_BATTERY
);
2540 else if ((features
->quirks
& WACOM_QUIRK_BATTERY
) &&
2541 wacom
->battery
.battery
) {
2542 features
->quirks
&= ~WACOM_QUIRK_BATTERY
;
2543 wacom_schedule_work(wacom_wac
, WACOM_WORKER_BATTERY
);
2544 wacom_notify_battery(wacom_wac
, 0, 0, 0, 0);
2549 void wacom_wac_irq(struct wacom_wac
*wacom_wac
, size_t len
)
2553 switch (wacom_wac
->features
.type
) {
2555 sync
= wacom_penpartner_irq(wacom_wac
);
2559 sync
= wacom_pl_irq(wacom_wac
);
2566 sync
= wacom_graphire_irq(wacom_wac
);
2570 sync
= wacom_ptu_irq(wacom_wac
);
2574 sync
= wacom_dtu_irq(wacom_wac
);
2579 sync
= wacom_dtus_irq(wacom_wac
);
2598 case CINTIQ_COMPANION_2
:
2599 sync
= wacom_intuos_irq(wacom_wac
);
2603 sync
= wacom_intuos_bt_irq(wacom_wac
, len
);
2608 sync
= wacom_24hdt_irq(wacom_wac
);
2617 if (len
== WACOM_PKGLEN_BBTOUCH3
)
2618 sync
= wacom_bpt3_touch(wacom_wac
);
2619 else if (wacom_wac
->data
[0] == WACOM_REPORT_USB
)
2620 sync
= wacom_status_irq(wacom_wac
, len
);
2622 sync
= wacom_intuos_irq(wacom_wac
);
2631 sync
= wacom_tpc_irq(wacom_wac
, len
);
2639 if (wacom_wac
->data
[0] == WACOM_REPORT_USB
)
2640 sync
= wacom_status_irq(wacom_wac
, len
);
2642 sync
= wacom_bpt_irq(wacom_wac
, len
);
2646 sync
= wacom_bamboo_pad_irq(wacom_wac
, len
);
2650 sync
= wacom_wireless_irq(wacom_wac
, len
);
2655 if (wacom_wac
->data
[0] == WACOM_REPORT_DEVICE_LIST
)
2656 wacom_remote_status_irq(wacom_wac
, len
);
2658 sync
= wacom_remote_irq(wacom_wac
, len
);
2667 if (wacom_wac
->pen_input
)
2668 input_sync(wacom_wac
->pen_input
);
2669 if (wacom_wac
->touch_input
)
2670 input_sync(wacom_wac
->touch_input
);
2671 if (wacom_wac
->pad_input
)
2672 input_sync(wacom_wac
->pad_input
);
2676 static void wacom_setup_basic_pro_pen(struct wacom_wac
*wacom_wac
)
2678 struct input_dev
*input_dev
= wacom_wac
->pen_input
;
2680 input_set_capability(input_dev
, EV_MSC
, MSC_SERIAL
);
2682 __set_bit(BTN_TOOL_PEN
, input_dev
->keybit
);
2683 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
2684 __set_bit(BTN_STYLUS2
, input_dev
->keybit
);
2686 input_set_abs_params(input_dev
, ABS_DISTANCE
,
2687 0, wacom_wac
->features
.distance_max
, wacom_wac
->features
.distance_fuzz
, 0);
2690 static void wacom_setup_cintiq(struct wacom_wac
*wacom_wac
)
2692 struct input_dev
*input_dev
= wacom_wac
->pen_input
;
2693 struct wacom_features
*features
= &wacom_wac
->features
;
2695 wacom_setup_basic_pro_pen(wacom_wac
);
2697 __set_bit(BTN_TOOL_RUBBER
, input_dev
->keybit
);
2698 __set_bit(BTN_TOOL_BRUSH
, input_dev
->keybit
);
2699 __set_bit(BTN_TOOL_PENCIL
, input_dev
->keybit
);
2700 __set_bit(BTN_TOOL_AIRBRUSH
, input_dev
->keybit
);
2702 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 1023, 0, 0);
2703 input_set_abs_params(input_dev
, ABS_TILT_X
, -64, 63, features
->tilt_fuzz
, 0);
2704 input_abs_set_res(input_dev
, ABS_TILT_X
, 57);
2705 input_set_abs_params(input_dev
, ABS_TILT_Y
, -64, 63, features
->tilt_fuzz
, 0);
2706 input_abs_set_res(input_dev
, ABS_TILT_Y
, 57);
2709 static void wacom_setup_intuos(struct wacom_wac
*wacom_wac
)
2711 struct input_dev
*input_dev
= wacom_wac
->pen_input
;
2713 input_set_capability(input_dev
, EV_REL
, REL_WHEEL
);
2715 wacom_setup_cintiq(wacom_wac
);
2717 __set_bit(BTN_LEFT
, input_dev
->keybit
);
2718 __set_bit(BTN_RIGHT
, input_dev
->keybit
);
2719 __set_bit(BTN_MIDDLE
, input_dev
->keybit
);
2720 __set_bit(BTN_SIDE
, input_dev
->keybit
);
2721 __set_bit(BTN_EXTRA
, input_dev
->keybit
);
2722 __set_bit(BTN_TOOL_MOUSE
, input_dev
->keybit
);
2723 __set_bit(BTN_TOOL_LENS
, input_dev
->keybit
);
2725 input_set_abs_params(input_dev
, ABS_RZ
, -900, 899, 0, 0);
2726 input_abs_set_res(input_dev
, ABS_RZ
, 287);
2727 input_set_abs_params(input_dev
, ABS_THROTTLE
, -1023, 1023, 0, 0);
2730 void wacom_setup_device_quirks(struct wacom
*wacom
)
2732 struct wacom_features
*features
= &wacom
->wacom_wac
.features
;
2734 /* The pen and pad share the same interface on most devices */
2735 if (features
->numbered_buttons
> 0)
2736 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
2737 if (features
->type
== GRAPHIRE_BT
|| features
->type
== WACOM_G4
||
2738 features
->type
== DTUS
||
2739 (features
->type
>= INTUOS3S
&& features
->type
<= WACOM_MO
)) {
2740 if (features
->device_type
& WACOM_DEVICETYPE_PEN
)
2741 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
2744 /* touch device found but size is not defined. use default */
2745 if (features
->device_type
& WACOM_DEVICETYPE_TOUCH
&& !features
->x_max
) {
2746 features
->x_max
= 1023;
2747 features
->y_max
= 1023;
2751 * Intuos5/Pro and Bamboo 3rd gen have no useful data about its
2752 * touch interface in its HID descriptor. If this is the touch
2753 * interface (PacketSize of WACOM_PKGLEN_BBTOUCH3), override the
2756 if ((features
->type
>= INTUOS5S
&& features
->type
<= INTUOSPL
) ||
2757 (features
->type
>= INTUOSHT
&& features
->type
<= BAMBOO_PT
)) {
2758 if (features
->pktlen
== WACOM_PKGLEN_BBTOUCH3
) {
2759 if (features
->touch_max
)
2760 features
->device_type
|= WACOM_DEVICETYPE_TOUCH
;
2761 if (features
->type
>= INTUOSHT
&& features
->type
<= BAMBOO_PT
)
2762 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
2764 features
->x_max
= 4096;
2765 features
->y_max
= 4096;
2767 else if (features
->pktlen
== WACOM_PKGLEN_BBTOUCH
) {
2768 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
2773 * Hack for the Bamboo One:
2774 * the device presents a PAD/Touch interface as most Bamboos and even
2775 * sends ghosts PAD data on it. However, later, we must disable this
2776 * ghost interface, and we can not detect it unless we set it here
2777 * to WACOM_DEVICETYPE_PAD or WACOM_DEVICETYPE_TOUCH.
2779 if (features
->type
== BAMBOO_PEN
&&
2780 features
->pktlen
== WACOM_PKGLEN_BBTOUCH3
)
2781 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
2784 * Raw Wacom-mode pen and touch events both come from interface
2785 * 0, whose HID descriptor has an application usage of 0xFF0D
2786 * (i.e., WACOM_HID_WD_DIGITIZER). We route pen packets back
2787 * out through the HID_GENERIC device created for interface 1,
2788 * so rewrite this one to be of type WACOM_DEVICETYPE_TOUCH.
2790 if (features
->type
== BAMBOO_PAD
)
2791 features
->device_type
= WACOM_DEVICETYPE_TOUCH
;
2793 if (features
->type
== REMOTE
)
2794 features
->device_type
= WACOM_DEVICETYPE_PAD
;
2796 switch (features
->type
) {
2807 case CINTIQ_COMPANION_2
:
2819 features
->device_type
|= WACOM_DEVICETYPE_DIRECT
;
2823 if (wacom
->hdev
->bus
== BUS_BLUETOOTH
)
2824 features
->quirks
|= WACOM_QUIRK_BATTERY
;
2826 /* quirk for bamboo touch with 2 low res touches */
2827 if ((features
->type
== BAMBOO_PT
|| features
->type
== BAMBOO_TOUCH
) &&
2828 features
->pktlen
== WACOM_PKGLEN_BBTOUCH
) {
2829 features
->x_max
<<= 5;
2830 features
->y_max
<<= 5;
2831 features
->x_fuzz
<<= 5;
2832 features
->y_fuzz
<<= 5;
2833 features
->quirks
|= WACOM_QUIRK_BBTOUCH_LOWRES
;
2836 if (features
->type
== WIRELESS
) {
2837 if (features
->device_type
== WACOM_DEVICETYPE_WL_MONITOR
) {
2838 features
->quirks
|= WACOM_QUIRK_BATTERY
;
2842 if (features
->type
== REMOTE
)
2843 features
->device_type
|= WACOM_DEVICETYPE_WL_MONITOR
;
2846 int wacom_setup_pen_input_capabilities(struct input_dev
*input_dev
,
2847 struct wacom_wac
*wacom_wac
)
2849 struct wacom_features
*features
= &wacom_wac
->features
;
2851 input_dev
->evbit
[0] |= BIT_MASK(EV_KEY
) | BIT_MASK(EV_ABS
);
2853 if (!(features
->device_type
& WACOM_DEVICETYPE_PEN
))
2856 if (features
->device_type
& WACOM_DEVICETYPE_DIRECT
)
2857 __set_bit(INPUT_PROP_DIRECT
, input_dev
->propbit
);
2859 __set_bit(INPUT_PROP_POINTER
, input_dev
->propbit
);
2861 if (features
->type
== HID_GENERIC
)
2862 /* setup has already been done */
2865 __set_bit(BTN_TOUCH
, input_dev
->keybit
);
2866 __set_bit(ABS_MISC
, input_dev
->absbit
);
2868 input_set_abs_params(input_dev
, ABS_X
, 0 + features
->offset_left
,
2869 features
->x_max
- features
->offset_right
,
2870 features
->x_fuzz
, 0);
2871 input_set_abs_params(input_dev
, ABS_Y
, 0 + features
->offset_top
,
2872 features
->y_max
- features
->offset_bottom
,
2873 features
->y_fuzz
, 0);
2874 input_set_abs_params(input_dev
, ABS_PRESSURE
, 0,
2875 features
->pressure_max
, features
->pressure_fuzz
, 0);
2877 /* penabled devices have fixed resolution for each model */
2878 input_abs_set_res(input_dev
, ABS_X
, features
->x_resolution
);
2879 input_abs_set_res(input_dev
, ABS_Y
, features
->y_resolution
);
2881 switch (features
->type
) {
2883 __clear_bit(ABS_MISC
, input_dev
->absbit
);
2887 input_set_abs_params(input_dev
, ABS_DISTANCE
, 0,
2888 features
->distance_max
,
2889 features
->distance_fuzz
, 0);
2893 input_set_capability(input_dev
, EV_REL
, REL_WHEEL
);
2895 __set_bit(BTN_LEFT
, input_dev
->keybit
);
2896 __set_bit(BTN_RIGHT
, input_dev
->keybit
);
2897 __set_bit(BTN_MIDDLE
, input_dev
->keybit
);
2899 __set_bit(BTN_TOOL_RUBBER
, input_dev
->keybit
);
2900 __set_bit(BTN_TOOL_PEN
, input_dev
->keybit
);
2901 __set_bit(BTN_TOOL_MOUSE
, input_dev
->keybit
);
2902 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
2903 __set_bit(BTN_STYLUS2
, input_dev
->keybit
);
2915 case CINTIQ_COMPANION_2
:
2916 input_set_abs_params(input_dev
, ABS_Z
, -900, 899, 0, 0);
2917 input_abs_set_res(input_dev
, ABS_Z
, 287);
2918 wacom_setup_cintiq(wacom_wac
);
2928 input_set_abs_params(input_dev
, ABS_Z
, -900, 899, 0, 0);
2929 input_abs_set_res(input_dev
, ABS_Z
, 287);
2933 wacom_setup_intuos(wacom_wac
);
2942 input_set_abs_params(input_dev
, ABS_DISTANCE
, 0,
2943 features
->distance_max
,
2944 features
->distance_fuzz
, 0);
2946 input_set_abs_params(input_dev
, ABS_Z
, -900, 899, 0, 0);
2947 input_abs_set_res(input_dev
, ABS_Z
, 287);
2949 wacom_setup_intuos(wacom_wac
);
2960 __clear_bit(ABS_MISC
, input_dev
->absbit
);
2967 __set_bit(BTN_TOOL_PEN
, input_dev
->keybit
);
2968 __set_bit(BTN_TOOL_RUBBER
, input_dev
->keybit
);
2969 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
2970 __set_bit(BTN_STYLUS2
, input_dev
->keybit
);
2974 __set_bit(BTN_STYLUS2
, input_dev
->keybit
);
2978 __set_bit(BTN_TOOL_PEN
, input_dev
->keybit
);
2979 __set_bit(BTN_TOOL_RUBBER
, input_dev
->keybit
);
2980 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
2987 if (features
->type
== INTUOSHT2
) {
2988 wacom_setup_basic_pro_pen(wacom_wac
);
2990 __clear_bit(ABS_MISC
, input_dev
->absbit
);
2991 __set_bit(BTN_TOOL_PEN
, input_dev
->keybit
);
2992 __set_bit(BTN_TOOL_RUBBER
, input_dev
->keybit
);
2993 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
2994 __set_bit(BTN_STYLUS2
, input_dev
->keybit
);
2995 input_set_abs_params(input_dev
, ABS_DISTANCE
, 0,
2996 features
->distance_max
,
2997 features
->distance_fuzz
, 0);
3001 __clear_bit(ABS_MISC
, input_dev
->absbit
);
3007 int wacom_setup_touch_input_capabilities(struct input_dev
*input_dev
,
3008 struct wacom_wac
*wacom_wac
)
3010 struct wacom_features
*features
= &wacom_wac
->features
;
3012 input_dev
->evbit
[0] |= BIT_MASK(EV_KEY
) | BIT_MASK(EV_ABS
);
3014 if (!(features
->device_type
& WACOM_DEVICETYPE_TOUCH
))
3017 if (features
->device_type
& WACOM_DEVICETYPE_DIRECT
)
3018 __set_bit(INPUT_PROP_DIRECT
, input_dev
->propbit
);
3020 __set_bit(INPUT_PROP_POINTER
, input_dev
->propbit
);
3022 if (features
->type
== HID_GENERIC
)
3023 /* setup has already been done */
3026 __set_bit(BTN_TOUCH
, input_dev
->keybit
);
3028 if (features
->touch_max
== 1) {
3029 input_set_abs_params(input_dev
, ABS_X
, 0,
3030 features
->x_max
, features
->x_fuzz
, 0);
3031 input_set_abs_params(input_dev
, ABS_Y
, 0,
3032 features
->y_max
, features
->y_fuzz
, 0);
3033 input_abs_set_res(input_dev
, ABS_X
,
3034 features
->x_resolution
);
3035 input_abs_set_res(input_dev
, ABS_Y
,
3036 features
->y_resolution
);
3038 else if (features
->touch_max
> 1) {
3039 input_set_abs_params(input_dev
, ABS_MT_POSITION_X
, 0,
3040 features
->x_max
, features
->x_fuzz
, 0);
3041 input_set_abs_params(input_dev
, ABS_MT_POSITION_Y
, 0,
3042 features
->y_max
, features
->y_fuzz
, 0);
3043 input_abs_set_res(input_dev
, ABS_MT_POSITION_X
,
3044 features
->x_resolution
);
3045 input_abs_set_res(input_dev
, ABS_MT_POSITION_Y
,
3046 features
->y_resolution
);
3049 switch (features
->type
) {
3056 input_set_abs_params(input_dev
, ABS_MT_TOUCH_MAJOR
, 0, features
->x_max
, 0, 0);
3057 input_set_abs_params(input_dev
, ABS_MT_TOUCH_MINOR
, 0, features
->y_max
, 0, 0);
3058 input_mt_init_slots(input_dev
, features
->touch_max
, INPUT_MT_POINTER
);
3062 input_set_abs_params(input_dev
, ABS_MT_TOUCH_MAJOR
, 0, features
->x_max
, 0, 0);
3063 input_set_abs_params(input_dev
, ABS_MT_WIDTH_MAJOR
, 0, features
->x_max
, 0, 0);
3064 input_set_abs_params(input_dev
, ABS_MT_WIDTH_MINOR
, 0, features
->y_max
, 0, 0);
3065 input_set_abs_params(input_dev
, ABS_MT_ORIENTATION
, 0, 1, 0, 0);
3073 input_mt_init_slots(input_dev
, features
->touch_max
, INPUT_MT_DIRECT
);
3082 input_dev
->evbit
[0] |= BIT_MASK(EV_SW
);
3083 __set_bit(SW_MUTE_DEVICE
, input_dev
->swbit
);
3088 if (features
->pktlen
== WACOM_PKGLEN_BBTOUCH3
) {
3089 input_set_abs_params(input_dev
,
3091 0, features
->x_max
, 0, 0);
3092 input_set_abs_params(input_dev
,
3094 0, features
->y_max
, 0, 0);
3096 input_mt_init_slots(input_dev
, features
->touch_max
, INPUT_MT_POINTER
);
3100 input_mt_init_slots(input_dev
, features
->touch_max
,
3102 __set_bit(BTN_LEFT
, input_dev
->keybit
);
3103 __set_bit(BTN_RIGHT
, input_dev
->keybit
);
3109 static int wacom_numbered_button_to_key(int n
)
3114 return BTN_A
+ (n
-10);
3116 return BTN_BASE
+ (n
-16);
3121 static void wacom_setup_numbered_buttons(struct input_dev
*input_dev
,
3126 for (i
= 0; i
< button_count
; i
++) {
3127 int key
= wacom_numbered_button_to_key(i
);
3130 __set_bit(key
, input_dev
->keybit
);
3134 static void wacom_24hd_update_leds(struct wacom
*wacom
, int mask
, int group
)
3136 struct wacom_led
*led
;
3138 bool updated
= false;
3141 * 24HD has LED group 1 to the left and LED group 0 to the right.
3142 * So group 0 matches the second half of the buttons and thus the mask
3143 * needs to be shifted.
3148 for (i
= 0; i
< 3; i
++) {
3149 led
= wacom_led_find(wacom
, group
, i
);
3151 hid_err(wacom
->hdev
, "can't find LED %d in group %d\n",
3155 if (!updated
&& mask
& BIT(i
)) {
3157 led_trigger_event(&led
->trigger
, LED_FULL
);
3164 static bool wacom_is_led_toggled(struct wacom
*wacom
, int button_count
,
3165 int mask
, int group
)
3167 int button_per_group
;
3170 * 21UX2 has LED group 1 to the left and LED group 0
3171 * to the right. We need to reverse the group to match this
3172 * historical behavior.
3174 if (wacom
->wacom_wac
.features
.type
== WACOM_21UX2
)
3177 button_per_group
= button_count
/wacom
->led
.count
;
3179 return mask
& (1 << (group
* button_per_group
));
3182 static void wacom_update_led(struct wacom
*wacom
, int button_count
, int mask
,
3185 struct wacom_led
*led
, *next_led
;
3189 if (wacom
->wacom_wac
.features
.type
== WACOM_24HD
)
3190 return wacom_24hd_update_leds(wacom
, mask
, group
);
3192 pressed
= wacom_is_led_toggled(wacom
, button_count
, mask
, group
);
3193 cur
= wacom
->led
.groups
[group
].select
;
3195 led
= wacom_led_find(wacom
, group
, cur
);
3197 hid_err(wacom
->hdev
, "can't find current LED %d in group %d\n",
3207 if (led
->held
&& pressed
)
3210 next_led
= wacom_led_next(wacom
, led
);
3212 hid_err(wacom
->hdev
, "can't find next LED in group %d\n",
3216 if (next_led
== led
)
3219 next_led
->held
= true;
3220 led_trigger_event(&next_led
->trigger
,
3221 wacom_leds_brightness_get(next_led
));
3224 static void wacom_report_numbered_buttons(struct input_dev
*input_dev
,
3225 int button_count
, int mask
)
3227 struct wacom
*wacom
= input_get_drvdata(input_dev
);
3230 for (i
= 0; i
< wacom
->led
.count
; i
++)
3231 wacom_update_led(wacom
, button_count
, mask
, i
);
3233 for (i
= 0; i
< button_count
; i
++) {
3234 int key
= wacom_numbered_button_to_key(i
);
3237 input_report_key(input_dev
, key
, mask
& (1 << i
));
3241 int wacom_setup_pad_input_capabilities(struct input_dev
*input_dev
,
3242 struct wacom_wac
*wacom_wac
)
3244 struct wacom_features
*features
= &wacom_wac
->features
;
3246 if (!(features
->device_type
& WACOM_DEVICETYPE_PAD
))
3249 if (features
->type
== REMOTE
&& input_dev
== wacom_wac
->pad_input
)
3252 input_dev
->evbit
[0] |= BIT_MASK(EV_KEY
) | BIT_MASK(EV_ABS
);
3254 /* kept for making legacy xf86-input-wacom working with the wheels */
3255 __set_bit(ABS_MISC
, input_dev
->absbit
);
3257 /* kept for making legacy xf86-input-wacom accepting the pad */
3258 if (!(input_dev
->absinfo
&& (input_dev
->absinfo
[ABS_X
].minimum
||
3259 input_dev
->absinfo
[ABS_X
].maximum
)))
3260 input_set_abs_params(input_dev
, ABS_X
, 0, 1, 0, 0);
3261 if (!(input_dev
->absinfo
&& (input_dev
->absinfo
[ABS_Y
].minimum
||
3262 input_dev
->absinfo
[ABS_Y
].maximum
)))
3263 input_set_abs_params(input_dev
, ABS_Y
, 0, 1, 0, 0);
3265 /* kept for making udev and libwacom accepting the pad */
3266 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
3268 wacom_setup_numbered_buttons(input_dev
, features
->numbered_buttons
);
3270 switch (features
->type
) {
3273 case CINTIQ_COMPANION_2
:
3280 __set_bit(BTN_BACK
, input_dev
->keybit
);
3281 __set_bit(BTN_LEFT
, input_dev
->keybit
);
3282 __set_bit(BTN_FORWARD
, input_dev
->keybit
);
3283 __set_bit(BTN_RIGHT
, input_dev
->keybit
);
3284 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
3288 __set_bit(BTN_BACK
, input_dev
->keybit
);
3289 __set_bit(BTN_FORWARD
, input_dev
->keybit
);
3290 input_set_capability(input_dev
, EV_REL
, REL_WHEEL
);
3294 __set_bit(KEY_PROG1
, input_dev
->keybit
);
3295 __set_bit(KEY_PROG2
, input_dev
->keybit
);
3296 __set_bit(KEY_PROG3
, input_dev
->keybit
);
3298 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
3299 input_set_abs_params(input_dev
, ABS_THROTTLE
, 0, 71, 0, 0);
3303 __set_bit(KEY_PROG1
, input_dev
->keybit
);
3304 __set_bit(KEY_PROG2
, input_dev
->keybit
);
3305 __set_bit(KEY_PROG3
, input_dev
->keybit
);
3306 input_set_abs_params(input_dev
, ABS_X
, -2048, 2048, 0, 0);
3307 input_abs_set_res(input_dev
, ABS_X
, 1024); /* points/g */
3308 input_set_abs_params(input_dev
, ABS_Y
, -2048, 2048, 0, 0);
3309 input_abs_set_res(input_dev
, ABS_Y
, 1024);
3310 input_set_abs_params(input_dev
, ABS_Z
, -2048, 2048, 0, 0);
3311 input_abs_set_res(input_dev
, ABS_Z
, 1024);
3312 __set_bit(INPUT_PROP_ACCELEROMETER
, input_dev
->propbit
);
3316 __set_bit(KEY_PROG1
, input_dev
->keybit
);
3317 __set_bit(KEY_PROG2
, input_dev
->keybit
);
3318 __set_bit(KEY_PROG3
, input_dev
->keybit
);
3324 input_set_abs_params(input_dev
, ABS_RX
, 0, 4096, 0, 0);
3325 input_set_abs_params(input_dev
, ABS_RY
, 0, 4096, 0, 0);
3329 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
3334 input_set_abs_params(input_dev
, ABS_RY
, 0, 4096, 0, 0);
3338 input_set_abs_params(input_dev
, ABS_RX
, 0, 4096, 0, 0);
3347 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
3352 * For Bluetooth devices, the udev rule does not work correctly
3353 * for pads unless we add a stylus capability, which forces
3354 * ID_INPUT_TABLET to be set.
3356 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
3362 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
3369 __clear_bit(ABS_MISC
, input_dev
->absbit
);
3371 __set_bit(BTN_LEFT
, input_dev
->keybit
);
3372 __set_bit(BTN_FORWARD
, input_dev
->keybit
);
3373 __set_bit(BTN_BACK
, input_dev
->keybit
);
3374 __set_bit(BTN_RIGHT
, input_dev
->keybit
);
3379 input_set_capability(input_dev
, EV_MSC
, MSC_SERIAL
);
3380 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
3387 /* no pad supported */
3393 static const struct wacom_features wacom_features_0x00
=
3394 { "Wacom Penpartner", 5040, 3780, 255, 0,
3395 PENPARTNER
, WACOM_PENPRTN_RES
, WACOM_PENPRTN_RES
};
3396 static const struct wacom_features wacom_features_0x10
=
3397 { "Wacom Graphire", 10206, 7422, 511, 63,
3398 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
3399 static const struct wacom_features wacom_features_0x81
=
3400 { "Wacom Graphire BT", 16704, 12064, 511, 32,
3401 GRAPHIRE_BT
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
, 2 };
3402 static const struct wacom_features wacom_features_0x11
=
3403 { "Wacom Graphire2 4x5", 10206, 7422, 511, 63,
3404 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
3405 static const struct wacom_features wacom_features_0x12
=
3406 { "Wacom Graphire2 5x7", 13918, 10206, 511, 63,
3407 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
3408 static const struct wacom_features wacom_features_0x13
=
3409 { "Wacom Graphire3", 10208, 7424, 511, 63,
3410 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
3411 static const struct wacom_features wacom_features_0x14
=
3412 { "Wacom Graphire3 6x8", 16704, 12064, 511, 63,
3413 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
3414 static const struct wacom_features wacom_features_0x15
=
3415 { "Wacom Graphire4 4x5", 10208, 7424, 511, 63,
3416 WACOM_G4
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
3417 static const struct wacom_features wacom_features_0x16
=
3418 { "Wacom Graphire4 6x8", 16704, 12064, 511, 63,
3419 WACOM_G4
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
3420 static const struct wacom_features wacom_features_0x17
=
3421 { "Wacom BambooFun 4x5", 14760, 9225, 511, 63,
3422 WACOM_MO
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3423 static const struct wacom_features wacom_features_0x18
=
3424 { "Wacom BambooFun 6x8", 21648, 13530, 511, 63,
3425 WACOM_MO
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3426 static const struct wacom_features wacom_features_0x19
=
3427 { "Wacom Bamboo1 Medium", 16704, 12064, 511, 63,
3428 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
3429 static const struct wacom_features wacom_features_0x60
=
3430 { "Wacom Volito", 5104, 3712, 511, 63,
3431 GRAPHIRE
, WACOM_VOLITO_RES
, WACOM_VOLITO_RES
};
3432 static const struct wacom_features wacom_features_0x61
=
3433 { "Wacom PenStation2", 3250, 2320, 255, 63,
3434 GRAPHIRE
, WACOM_VOLITO_RES
, WACOM_VOLITO_RES
};
3435 static const struct wacom_features wacom_features_0x62
=
3436 { "Wacom Volito2 4x5", 5104, 3712, 511, 63,
3437 GRAPHIRE
, WACOM_VOLITO_RES
, WACOM_VOLITO_RES
};
3438 static const struct wacom_features wacom_features_0x63
=
3439 { "Wacom Volito2 2x3", 3248, 2320, 511, 63,
3440 GRAPHIRE
, WACOM_VOLITO_RES
, WACOM_VOLITO_RES
};
3441 static const struct wacom_features wacom_features_0x64
=
3442 { "Wacom PenPartner2", 3250, 2320, 511, 63,
3443 GRAPHIRE
, WACOM_VOLITO_RES
, WACOM_VOLITO_RES
};
3444 static const struct wacom_features wacom_features_0x65
=
3445 { "Wacom Bamboo", 14760, 9225, 511, 63,
3446 WACOM_MO
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3447 static const struct wacom_features wacom_features_0x69
=
3448 { "Wacom Bamboo1", 5104, 3712, 511, 63,
3449 GRAPHIRE
, WACOM_PENPRTN_RES
, WACOM_PENPRTN_RES
};
3450 static const struct wacom_features wacom_features_0x6A
=
3451 { "Wacom Bamboo1 4x6", 14760, 9225, 1023, 63,
3452 GRAPHIRE
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3453 static const struct wacom_features wacom_features_0x6B
=
3454 { "Wacom Bamboo1 5x8", 21648, 13530, 1023, 63,
3455 GRAPHIRE
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3456 static const struct wacom_features wacom_features_0x20
=
3457 { "Wacom Intuos 4x5", 12700, 10600, 1023, 31,
3458 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3459 static const struct wacom_features wacom_features_0x21
=
3460 { "Wacom Intuos 6x8", 20320, 16240, 1023, 31,
3461 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3462 static const struct wacom_features wacom_features_0x22
=
3463 { "Wacom Intuos 9x12", 30480, 24060, 1023, 31,
3464 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3465 static const struct wacom_features wacom_features_0x23
=
3466 { "Wacom Intuos 12x12", 30480, 31680, 1023, 31,
3467 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3468 static const struct wacom_features wacom_features_0x24
=
3469 { "Wacom Intuos 12x18", 45720, 31680, 1023, 31,
3470 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3471 static const struct wacom_features wacom_features_0x30
=
3472 { "Wacom PL400", 5408, 4056, 255, 0,
3473 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
3474 static const struct wacom_features wacom_features_0x31
=
3475 { "Wacom PL500", 6144, 4608, 255, 0,
3476 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
3477 static const struct wacom_features wacom_features_0x32
=
3478 { "Wacom PL600", 6126, 4604, 255, 0,
3479 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
3480 static const struct wacom_features wacom_features_0x33
=
3481 { "Wacom PL600SX", 6260, 5016, 255, 0,
3482 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
3483 static const struct wacom_features wacom_features_0x34
=
3484 { "Wacom PL550", 6144, 4608, 511, 0,
3485 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
3486 static const struct wacom_features wacom_features_0x35
=
3487 { "Wacom PL800", 7220, 5780, 511, 0,
3488 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
3489 static const struct wacom_features wacom_features_0x37
=
3490 { "Wacom PL700", 6758, 5406, 511, 0,
3491 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
3492 static const struct wacom_features wacom_features_0x38
=
3493 { "Wacom PL510", 6282, 4762, 511, 0,
3494 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
3495 static const struct wacom_features wacom_features_0x39
=
3496 { "Wacom DTU710", 34080, 27660, 511, 0,
3497 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
3498 static const struct wacom_features wacom_features_0xC4
=
3499 { "Wacom DTF521", 6282, 4762, 511, 0,
3500 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
3501 static const struct wacom_features wacom_features_0xC0
=
3502 { "Wacom DTF720", 6858, 5506, 511, 0,
3503 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
3504 static const struct wacom_features wacom_features_0xC2
=
3505 { "Wacom DTF720a", 6858, 5506, 511, 0,
3506 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
3507 static const struct wacom_features wacom_features_0x03
=
3508 { "Wacom Cintiq Partner", 20480, 15360, 511, 0,
3509 PTU
, WACOM_PL_RES
, WACOM_PL_RES
};
3510 static const struct wacom_features wacom_features_0x41
=
3511 { "Wacom Intuos2 4x5", 12700, 10600, 1023, 31,
3512 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3513 static const struct wacom_features wacom_features_0x42
=
3514 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
3515 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3516 static const struct wacom_features wacom_features_0x43
=
3517 { "Wacom Intuos2 9x12", 30480, 24060, 1023, 31,
3518 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3519 static const struct wacom_features wacom_features_0x44
=
3520 { "Wacom Intuos2 12x12", 30480, 31680, 1023, 31,
3521 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3522 static const struct wacom_features wacom_features_0x45
=
3523 { "Wacom Intuos2 12x18", 45720, 31680, 1023, 31,
3524 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3525 static const struct wacom_features wacom_features_0xB0
=
3526 { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63,
3527 INTUOS3S
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 4 };
3528 static const struct wacom_features wacom_features_0xB1
=
3529 { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63,
3530 INTUOS3
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 8 };
3531 static const struct wacom_features wacom_features_0xB2
=
3532 { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63,
3533 INTUOS3
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 8 };
3534 static const struct wacom_features wacom_features_0xB3
=
3535 { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63,
3536 INTUOS3L
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 8 };
3537 static const struct wacom_features wacom_features_0xB4
=
3538 { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63,
3539 INTUOS3L
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 8 };
3540 static const struct wacom_features wacom_features_0xB5
=
3541 { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63,
3542 INTUOS3
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 8 };
3543 static const struct wacom_features wacom_features_0xB7
=
3544 { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63,
3545 INTUOS3S
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 4 };
3546 static const struct wacom_features wacom_features_0xB8
=
3547 { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63,
3548 INTUOS4S
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 7 };
3549 static const struct wacom_features wacom_features_0xB9
=
3550 { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63,
3551 INTUOS4
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9 };
3552 static const struct wacom_features wacom_features_0xBA
=
3553 { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63,
3554 INTUOS4L
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9 };
3555 static const struct wacom_features wacom_features_0xBB
=
3556 { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63,
3557 INTUOS4L
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9 };
3558 static const struct wacom_features wacom_features_0xBC
=
3559 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
3560 INTUOS4
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9 };
3561 static const struct wacom_features wacom_features_0xBD
=
3562 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
3563 INTUOS4WL
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9 };
3564 static const struct wacom_features wacom_features_0x26
=
3565 { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63,
3566 INTUOS5S
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 7, .touch_max
= 16 };
3567 static const struct wacom_features wacom_features_0x27
=
3568 { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63,
3569 INTUOS5
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9, .touch_max
= 16 };
3570 static const struct wacom_features wacom_features_0x28
=
3571 { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63,
3572 INTUOS5L
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9, .touch_max
= 16 };
3573 static const struct wacom_features wacom_features_0x29
=
3574 { "Wacom Intuos5 S", 31496, 19685, 2047, 63,
3575 INTUOS5S
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 7 };
3576 static const struct wacom_features wacom_features_0x2A
=
3577 { "Wacom Intuos5 M", 44704, 27940, 2047, 63,
3578 INTUOS5
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9 };
3579 static const struct wacom_features wacom_features_0x314
=
3580 { "Wacom Intuos Pro S", 31496, 19685, 2047, 63,
3581 INTUOSPS
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 7, .touch_max
= 16,
3582 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3583 static const struct wacom_features wacom_features_0x315
=
3584 { "Wacom Intuos Pro M", 44704, 27940, 2047, 63,
3585 INTUOSPM
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9, .touch_max
= 16,
3586 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3587 static const struct wacom_features wacom_features_0x317
=
3588 { "Wacom Intuos Pro L", 65024, 40640, 2047, 63,
3589 INTUOSPL
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9, .touch_max
= 16,
3590 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3591 static const struct wacom_features wacom_features_0xF4
=
3592 { "Wacom Cintiq 24HD", 104480, 65600, 2047, 63,
3593 WACOM_24HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 16,
3594 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3595 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
3596 static const struct wacom_features wacom_features_0xF8
=
3597 { "Wacom Cintiq 24HD touch", 104480, 65600, 2047, 63, /* Pen */
3598 WACOM_24HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 16,
3599 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3600 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3601 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0xf6 };
3602 static const struct wacom_features wacom_features_0xF6
=
3603 { "Wacom Cintiq 24HD touch", .type
= WACOM_24HDT
, /* Touch */
3604 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0xf8, .touch_max
= 10,
3605 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3606 static const struct wacom_features wacom_features_0x32A
=
3607 { "Wacom Cintiq 27QHD", 120140, 67920, 2047, 63,
3608 WACOM_27QHD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 0,
3609 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3610 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
3611 static const struct wacom_features wacom_features_0x32B
=
3612 { "Wacom Cintiq 27QHD touch", 120140, 67920, 2047, 63,
3613 WACOM_27QHD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 0,
3614 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3615 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3616 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x32C };
3617 static const struct wacom_features wacom_features_0x32C
=
3618 { "Wacom Cintiq 27QHD touch", .type
= WACOM_27QHDT
,
3619 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x32B, .touch_max
= 10 };
3620 static const struct wacom_features wacom_features_0x3F
=
3621 { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63,
3622 CINTIQ
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 8 };
3623 static const struct wacom_features wacom_features_0xC5
=
3624 { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63,
3625 WACOM_BEE
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 10 };
3626 static const struct wacom_features wacom_features_0xC6
=
3627 { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63,
3628 WACOM_BEE
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 10 };
3629 static const struct wacom_features wacom_features_0x304
=
3630 { "Wacom Cintiq 13HD", 59552, 33848, 1023, 63,
3631 WACOM_13HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9,
3632 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3633 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
3634 static const struct wacom_features wacom_features_0x333
=
3635 { "Wacom Cintiq 13HD touch", 59552, 33848, 2047, 63,
3636 WACOM_13HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9,
3637 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3638 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3639 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x335 };
3640 static const struct wacom_features wacom_features_0x335
=
3641 { "Wacom Cintiq 13HD touch", .type
= WACOM_24HDT
, /* Touch */
3642 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x333, .touch_max
= 10,
3643 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3644 static const struct wacom_features wacom_features_0xC7
=
3645 { "Wacom DTU1931", 37832, 30305, 511, 0,
3646 PL
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3647 static const struct wacom_features wacom_features_0xCE
=
3648 { "Wacom DTU2231", 47864, 27011, 511, 0,
3649 DTU
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
,
3650 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBMOUSE
};
3651 static const struct wacom_features wacom_features_0xF0
=
3652 { "Wacom DTU1631", 34623, 19553, 511, 0,
3653 DTU
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3654 static const struct wacom_features wacom_features_0xFB
=
3655 { "Wacom DTU1031", 22096, 13960, 511, 0,
3656 DTUS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, 4,
3657 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
,
3658 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
};
3659 static const struct wacom_features wacom_features_0x32F
=
3660 { "Wacom DTU1031X", 22672, 12928, 511, 0,
3661 DTUSX
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, 0,
3662 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
,
3663 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
};
3664 static const struct wacom_features wacom_features_0x336
=
3665 { "Wacom DTU1141", 23672, 13403, 1023, 0,
3666 DTUS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, 4,
3667 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
,
3668 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
};
3669 static const struct wacom_features wacom_features_0x57
=
3670 { "Wacom DTK2241", 95840, 54260, 2047, 63,
3671 DTK
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 6,
3672 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3673 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
3674 static const struct wacom_features wacom_features_0x59
= /* Pen */
3675 { "Wacom DTH2242", 95840, 54260, 2047, 63,
3676 DTK
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 6,
3677 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3678 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3679 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x5D };
3680 static const struct wacom_features wacom_features_0x5D
= /* Touch */
3681 { "Wacom DTH2242", .type
= WACOM_24HDT
,
3682 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x59, .touch_max
= 10,
3683 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3684 static const struct wacom_features wacom_features_0xCC
=
3685 { "Wacom Cintiq 21UX2", 87200, 65600, 2047, 63,
3686 WACOM_21UX2
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 18,
3687 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3688 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
3689 static const struct wacom_features wacom_features_0xFA
=
3690 { "Wacom Cintiq 22HD", 95840, 54260, 2047, 63,
3691 WACOM_22HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 18,
3692 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3693 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
3694 static const struct wacom_features wacom_features_0x5B
=
3695 { "Wacom Cintiq 22HDT", 95840, 54260, 2047, 63,
3696 WACOM_22HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 18,
3697 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3698 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3699 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x5e };
3700 static const struct wacom_features wacom_features_0x5E
=
3701 { "Wacom Cintiq 22HDT", .type
= WACOM_24HDT
,
3702 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x5b, .touch_max
= 10,
3703 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3704 static const struct wacom_features wacom_features_0x90
=
3705 { "Wacom ISDv4 90", 26202, 16325, 255, 0,
3706 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3707 static const struct wacom_features wacom_features_0x93
=
3708 { "Wacom ISDv4 93", 26202, 16325, 255, 0,
3709 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3710 static const struct wacom_features wacom_features_0x97
=
3711 { "Wacom ISDv4 97", 26202, 16325, 511, 0,
3712 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3713 static const struct wacom_features wacom_features_0x9A
=
3714 { "Wacom ISDv4 9A", 26202, 16325, 255, 0,
3715 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3716 static const struct wacom_features wacom_features_0x9F
=
3717 { "Wacom ISDv4 9F", 26202, 16325, 255, 0,
3718 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3719 static const struct wacom_features wacom_features_0xE2
=
3720 { "Wacom ISDv4 E2", 26202, 16325, 255, 0,
3721 TABLETPC2FG
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
3722 static const struct wacom_features wacom_features_0xE3
=
3723 { "Wacom ISDv4 E3", 26202, 16325, 255, 0,
3724 TABLETPC2FG
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
3725 static const struct wacom_features wacom_features_0xE5
=
3726 { "Wacom ISDv4 E5", 26202, 16325, 255, 0,
3727 MTSCREEN
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3728 static const struct wacom_features wacom_features_0xE6
=
3729 { "Wacom ISDv4 E6", 27760, 15694, 255, 0,
3730 TABLETPC2FG
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
3731 static const struct wacom_features wacom_features_0xEC
=
3732 { "Wacom ISDv4 EC", 25710, 14500, 255, 0,
3733 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3734 static const struct wacom_features wacom_features_0xED
=
3735 { "Wacom ISDv4 ED", 26202, 16325, 255, 0,
3736 TABLETPCE
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3737 static const struct wacom_features wacom_features_0xEF
=
3738 { "Wacom ISDv4 EF", 26202, 16325, 255, 0,
3739 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3740 static const struct wacom_features wacom_features_0x100
=
3741 { "Wacom ISDv4 100", 26202, 16325, 255, 0,
3742 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3743 static const struct wacom_features wacom_features_0x101
=
3744 { "Wacom ISDv4 101", 26202, 16325, 255, 0,
3745 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3746 static const struct wacom_features wacom_features_0x10D
=
3747 { "Wacom ISDv4 10D", 26202, 16325, 255, 0,
3748 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3749 static const struct wacom_features wacom_features_0x10E
=
3750 { "Wacom ISDv4 10E", 27760, 15694, 255, 0,
3751 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3752 static const struct wacom_features wacom_features_0x10F
=
3753 { "Wacom ISDv4 10F", 27760, 15694, 255, 0,
3754 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3755 static const struct wacom_features wacom_features_0x116
=
3756 { "Wacom ISDv4 116", 26202, 16325, 255, 0,
3757 TABLETPCE
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3758 static const struct wacom_features wacom_features_0x12C
=
3759 { "Wacom ISDv4 12C", 27848, 15752, 2047, 0,
3760 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3761 static const struct wacom_features wacom_features_0x4001
=
3762 { "Wacom ISDv4 4001", 26202, 16325, 255, 0,
3763 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3764 static const struct wacom_features wacom_features_0x4004
=
3765 { "Wacom ISDv4 4004", 11060, 6220, 255, 0,
3766 MTTPC_B
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3767 static const struct wacom_features wacom_features_0x5000
=
3768 { "Wacom ISDv4 5000", 27848, 15752, 1023, 0,
3769 MTTPC_B
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3770 static const struct wacom_features wacom_features_0x5002
=
3771 { "Wacom ISDv4 5002", 29576, 16724, 1023, 0,
3772 MTTPC_B
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3773 static const struct wacom_features wacom_features_0x47
=
3774 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
3775 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3776 static const struct wacom_features wacom_features_0x84
=
3777 { "Wacom Wireless Receiver", .type
= WIRELESS
, .touch_max
= 16 };
3778 static const struct wacom_features wacom_features_0xD0
=
3779 { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31,
3780 BAMBOO_TOUCH
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
3781 static const struct wacom_features wacom_features_0xD1
=
3782 { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31,
3783 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
3784 static const struct wacom_features wacom_features_0xD2
=
3785 { "Wacom Bamboo Craft", 14720, 9200, 1023, 31,
3786 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
3787 static const struct wacom_features wacom_features_0xD3
=
3788 { "Wacom Bamboo 2FG 6x8", 21648, 13700, 1023, 31,
3789 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
3790 static const struct wacom_features wacom_features_0xD4
=
3791 { "Wacom Bamboo Pen", 14720, 9200, 1023, 31,
3792 BAMBOO_PEN
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3793 static const struct wacom_features wacom_features_0xD5
=
3794 { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31,
3795 BAMBOO_PEN
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3796 static const struct wacom_features wacom_features_0xD6
=
3797 { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31,
3798 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
3799 static const struct wacom_features wacom_features_0xD7
=
3800 { "Wacom BambooPT 2FG Small", 14720, 9200, 1023, 31,
3801 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
3802 static const struct wacom_features wacom_features_0xD8
=
3803 { "Wacom Bamboo Comic 2FG", 21648, 13700, 1023, 31,
3804 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
3805 static const struct wacom_features wacom_features_0xDA
=
3806 { "Wacom Bamboo 2FG 4x5 SE", 14720, 9200, 1023, 31,
3807 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
3808 static const struct wacom_features wacom_features_0xDB
=
3809 { "Wacom Bamboo 2FG 6x8 SE", 21648, 13700, 1023, 31,
3810 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
3811 static const struct wacom_features wacom_features_0xDD
=
3812 { "Wacom Bamboo Connect", 14720, 9200, 1023, 31,
3813 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3814 static const struct wacom_features wacom_features_0xDE
=
3815 { "Wacom Bamboo 16FG 4x5", 14720, 9200, 1023, 31,
3816 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 16 };
3817 static const struct wacom_features wacom_features_0xDF
=
3818 { "Wacom Bamboo 16FG 6x8", 21648, 13700, 1023, 31,
3819 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 16 };
3820 static const struct wacom_features wacom_features_0x300
=
3821 { "Wacom Bamboo One S", 14720, 9225, 1023, 31,
3822 BAMBOO_PEN
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3823 static const struct wacom_features wacom_features_0x301
=
3824 { "Wacom Bamboo One M", 21648, 13530, 1023, 31,
3825 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3826 static const struct wacom_features wacom_features_0x302
=
3827 { "Wacom Intuos PT S", 15200, 9500, 1023, 31,
3828 INTUOSHT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 16,
3829 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3830 static const struct wacom_features wacom_features_0x303
=
3831 { "Wacom Intuos PT M", 21600, 13500, 1023, 31,
3832 INTUOSHT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 16,
3833 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3834 static const struct wacom_features wacom_features_0x30E
=
3835 { "Wacom Intuos S", 15200, 9500, 1023, 31,
3836 INTUOSHT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
,
3837 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3838 static const struct wacom_features wacom_features_0x6004
=
3839 { "ISD-V4", 12800, 8000, 255, 0,
3840 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3841 static const struct wacom_features wacom_features_0x307
=
3842 { "Wacom ISDv5 307", 59552, 33848, 2047, 63,
3843 CINTIQ_HYBRID
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9,
3844 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3845 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3846 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x309 };
3847 static const struct wacom_features wacom_features_0x309
=
3848 { "Wacom ISDv5 309", .type
= WACOM_24HDT
, /* Touch */
3849 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x0307, .touch_max
= 10,
3850 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3851 static const struct wacom_features wacom_features_0x30A
=
3852 { "Wacom ISDv5 30A", 59552, 33848, 2047, 63,
3853 CINTIQ_HYBRID
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9,
3854 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3855 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3856 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x30C };
3857 static const struct wacom_features wacom_features_0x30C
=
3858 { "Wacom ISDv5 30C", .type
= WACOM_24HDT
, /* Touch */
3859 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x30A, .touch_max
= 10,
3860 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3861 static const struct wacom_features wacom_features_0x318
=
3862 { "Wacom USB Bamboo PAD", 4095, 4095, /* Touch */
3863 .type
= BAMBOO_PAD
, 35, 48, .touch_max
= 4 };
3864 static const struct wacom_features wacom_features_0x319
=
3865 { "Wacom Wireless Bamboo PAD", 4095, 4095, /* Touch */
3866 .type
= BAMBOO_PAD
, 35, 48, .touch_max
= 4 };
3867 static const struct wacom_features wacom_features_0x325
=
3868 { "Wacom ISDv5 325", 59552, 33848, 2047, 63,
3869 CINTIQ_COMPANION_2
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 11,
3870 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3871 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3872 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x326 };
3873 static const struct wacom_features wacom_features_0x326
= /* Touch */
3874 { "Wacom ISDv5 326", .type
= HID_GENERIC
, .oVid
= USB_VENDOR_ID_WACOM
,
3876 static const struct wacom_features wacom_features_0x323
=
3877 { "Wacom Intuos P M", 21600, 13500, 1023, 31,
3878 INTUOSHT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
,
3879 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3880 static const struct wacom_features wacom_features_0x331
=
3881 { "Wacom Express Key Remote", .type
= REMOTE
,
3882 .numbered_buttons
= 18, .check_for_hid_type
= true,
3883 .hid_type
= HID_TYPE_USBNONE
};
3884 static const struct wacom_features wacom_features_0x33B
=
3885 { "Wacom Intuos S 2", 15200, 9500, 2047, 63,
3886 INTUOSHT2
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
,
3887 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3888 static const struct wacom_features wacom_features_0x33C
=
3889 { "Wacom Intuos PT S 2", 15200, 9500, 2047, 63,
3890 INTUOSHT2
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 16,
3891 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3892 static const struct wacom_features wacom_features_0x33D
=
3893 { "Wacom Intuos P M 2", 21600, 13500, 2047, 63,
3894 INTUOSHT2
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
,
3895 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3896 static const struct wacom_features wacom_features_0x33E
=
3897 { "Wacom Intuos PT M 2", 21600, 13500, 2047, 63,
3898 INTUOSHT2
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 16,
3899 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3900 static const struct wacom_features wacom_features_0x343
=
3901 { "Wacom DTK1651", 34816, 19759, 1023, 0,
3902 DTUS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, 4,
3903 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
,
3904 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
};
3906 static const struct wacom_features wacom_features_HID_ANY_ID
=
3907 { "Wacom HID", .type
= HID_GENERIC
, .oVid
= HID_ANY_ID
, .oPid
= HID_ANY_ID
};
3909 #define USB_DEVICE_WACOM(prod) \
3910 HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
3911 .driver_data = (kernel_ulong_t)&wacom_features_##prod
3913 #define BT_DEVICE_WACOM(prod) \
3914 HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
3915 .driver_data = (kernel_ulong_t)&wacom_features_##prod
3917 #define I2C_DEVICE_WACOM(prod) \
3918 HID_DEVICE(BUS_I2C, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
3919 .driver_data = (kernel_ulong_t)&wacom_features_##prod
3921 #define USB_DEVICE_LENOVO(prod) \
3922 HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
3923 .driver_data = (kernel_ulong_t)&wacom_features_##prod
3925 const struct hid_device_id wacom_ids
[] = {
3926 { USB_DEVICE_WACOM(0x00) },
3927 { USB_DEVICE_WACOM(0x03) },
3928 { USB_DEVICE_WACOM(0x10) },
3929 { USB_DEVICE_WACOM(0x11) },
3930 { USB_DEVICE_WACOM(0x12) },
3931 { USB_DEVICE_WACOM(0x13) },
3932 { USB_DEVICE_WACOM(0x14) },
3933 { USB_DEVICE_WACOM(0x15) },
3934 { USB_DEVICE_WACOM(0x16) },
3935 { USB_DEVICE_WACOM(0x17) },
3936 { USB_DEVICE_WACOM(0x18) },
3937 { USB_DEVICE_WACOM(0x19) },
3938 { USB_DEVICE_WACOM(0x20) },
3939 { USB_DEVICE_WACOM(0x21) },
3940 { USB_DEVICE_WACOM(0x22) },
3941 { USB_DEVICE_WACOM(0x23) },
3942 { USB_DEVICE_WACOM(0x24) },
3943 { USB_DEVICE_WACOM(0x26) },
3944 { USB_DEVICE_WACOM(0x27) },
3945 { USB_DEVICE_WACOM(0x28) },
3946 { USB_DEVICE_WACOM(0x29) },
3947 { USB_DEVICE_WACOM(0x2A) },
3948 { USB_DEVICE_WACOM(0x30) },
3949 { USB_DEVICE_WACOM(0x31) },
3950 { USB_DEVICE_WACOM(0x32) },
3951 { USB_DEVICE_WACOM(0x33) },
3952 { USB_DEVICE_WACOM(0x34) },
3953 { USB_DEVICE_WACOM(0x35) },
3954 { USB_DEVICE_WACOM(0x37) },
3955 { USB_DEVICE_WACOM(0x38) },
3956 { USB_DEVICE_WACOM(0x39) },
3957 { USB_DEVICE_WACOM(0x3F) },
3958 { USB_DEVICE_WACOM(0x41) },
3959 { USB_DEVICE_WACOM(0x42) },
3960 { USB_DEVICE_WACOM(0x43) },
3961 { USB_DEVICE_WACOM(0x44) },
3962 { USB_DEVICE_WACOM(0x45) },
3963 { USB_DEVICE_WACOM(0x47) },
3964 { USB_DEVICE_WACOM(0x57) },
3965 { USB_DEVICE_WACOM(0x59) },
3966 { USB_DEVICE_WACOM(0x5B) },
3967 { USB_DEVICE_WACOM(0x5D) },
3968 { USB_DEVICE_WACOM(0x5E) },
3969 { USB_DEVICE_WACOM(0x60) },
3970 { USB_DEVICE_WACOM(0x61) },
3971 { USB_DEVICE_WACOM(0x62) },
3972 { USB_DEVICE_WACOM(0x63) },
3973 { USB_DEVICE_WACOM(0x64) },
3974 { USB_DEVICE_WACOM(0x65) },
3975 { USB_DEVICE_WACOM(0x69) },
3976 { USB_DEVICE_WACOM(0x6A) },
3977 { USB_DEVICE_WACOM(0x6B) },
3978 { BT_DEVICE_WACOM(0x81) },
3979 { USB_DEVICE_WACOM(0x84) },
3980 { USB_DEVICE_WACOM(0x90) },
3981 { USB_DEVICE_WACOM(0x93) },
3982 { USB_DEVICE_WACOM(0x97) },
3983 { USB_DEVICE_WACOM(0x9A) },
3984 { USB_DEVICE_WACOM(0x9F) },
3985 { USB_DEVICE_WACOM(0xB0) },
3986 { USB_DEVICE_WACOM(0xB1) },
3987 { USB_DEVICE_WACOM(0xB2) },
3988 { USB_DEVICE_WACOM(0xB3) },
3989 { USB_DEVICE_WACOM(0xB4) },
3990 { USB_DEVICE_WACOM(0xB5) },
3991 { USB_DEVICE_WACOM(0xB7) },
3992 { USB_DEVICE_WACOM(0xB8) },
3993 { USB_DEVICE_WACOM(0xB9) },
3994 { USB_DEVICE_WACOM(0xBA) },
3995 { USB_DEVICE_WACOM(0xBB) },
3996 { USB_DEVICE_WACOM(0xBC) },
3997 { BT_DEVICE_WACOM(0xBD) },
3998 { USB_DEVICE_WACOM(0xC0) },
3999 { USB_DEVICE_WACOM(0xC2) },
4000 { USB_DEVICE_WACOM(0xC4) },
4001 { USB_DEVICE_WACOM(0xC5) },
4002 { USB_DEVICE_WACOM(0xC6) },
4003 { USB_DEVICE_WACOM(0xC7) },
4004 { USB_DEVICE_WACOM(0xCC) },
4005 { USB_DEVICE_WACOM(0xCE) },
4006 { USB_DEVICE_WACOM(0xD0) },
4007 { USB_DEVICE_WACOM(0xD1) },
4008 { USB_DEVICE_WACOM(0xD2) },
4009 { USB_DEVICE_WACOM(0xD3) },
4010 { USB_DEVICE_WACOM(0xD4) },
4011 { USB_DEVICE_WACOM(0xD5) },
4012 { USB_DEVICE_WACOM(0xD6) },
4013 { USB_DEVICE_WACOM(0xD7) },
4014 { USB_DEVICE_WACOM(0xD8) },
4015 { USB_DEVICE_WACOM(0xDA) },
4016 { USB_DEVICE_WACOM(0xDB) },
4017 { USB_DEVICE_WACOM(0xDD) },
4018 { USB_DEVICE_WACOM(0xDE) },
4019 { USB_DEVICE_WACOM(0xDF) },
4020 { USB_DEVICE_WACOM(0xE2) },
4021 { USB_DEVICE_WACOM(0xE3) },
4022 { USB_DEVICE_WACOM(0xE5) },
4023 { USB_DEVICE_WACOM(0xE6) },
4024 { USB_DEVICE_WACOM(0xEC) },
4025 { USB_DEVICE_WACOM(0xED) },
4026 { USB_DEVICE_WACOM(0xEF) },
4027 { USB_DEVICE_WACOM(0xF0) },
4028 { USB_DEVICE_WACOM(0xF4) },
4029 { USB_DEVICE_WACOM(0xF6) },
4030 { USB_DEVICE_WACOM(0xF8) },
4031 { USB_DEVICE_WACOM(0xFA) },
4032 { USB_DEVICE_WACOM(0xFB) },
4033 { USB_DEVICE_WACOM(0x100) },
4034 { USB_DEVICE_WACOM(0x101) },
4035 { USB_DEVICE_WACOM(0x10D) },
4036 { USB_DEVICE_WACOM(0x10E) },
4037 { USB_DEVICE_WACOM(0x10F) },
4038 { USB_DEVICE_WACOM(0x116) },
4039 { USB_DEVICE_WACOM(0x12C) },
4040 { USB_DEVICE_WACOM(0x300) },
4041 { USB_DEVICE_WACOM(0x301) },
4042 { USB_DEVICE_WACOM(0x302) },
4043 { USB_DEVICE_WACOM(0x303) },
4044 { USB_DEVICE_WACOM(0x304) },
4045 { USB_DEVICE_WACOM(0x307) },
4046 { USB_DEVICE_WACOM(0x309) },
4047 { USB_DEVICE_WACOM(0x30A) },
4048 { USB_DEVICE_WACOM(0x30C) },
4049 { USB_DEVICE_WACOM(0x30E) },
4050 { USB_DEVICE_WACOM(0x314) },
4051 { USB_DEVICE_WACOM(0x315) },
4052 { USB_DEVICE_WACOM(0x317) },
4053 { USB_DEVICE_WACOM(0x318) },
4054 { USB_DEVICE_WACOM(0x319) },
4055 { USB_DEVICE_WACOM(0x323) },
4056 { USB_DEVICE_WACOM(0x325) },
4057 { USB_DEVICE_WACOM(0x326) },
4058 { USB_DEVICE_WACOM(0x32A) },
4059 { USB_DEVICE_WACOM(0x32B) },
4060 { USB_DEVICE_WACOM(0x32C) },
4061 { USB_DEVICE_WACOM(0x32F) },
4062 { USB_DEVICE_WACOM(0x331) },
4063 { USB_DEVICE_WACOM(0x333) },
4064 { USB_DEVICE_WACOM(0x335) },
4065 { USB_DEVICE_WACOM(0x336) },
4066 { USB_DEVICE_WACOM(0x33B) },
4067 { USB_DEVICE_WACOM(0x33C) },
4068 { USB_DEVICE_WACOM(0x33D) },
4069 { USB_DEVICE_WACOM(0x33E) },
4070 { USB_DEVICE_WACOM(0x343) },
4071 { USB_DEVICE_WACOM(0x4001) },
4072 { USB_DEVICE_WACOM(0x4004) },
4073 { USB_DEVICE_WACOM(0x5000) },
4074 { USB_DEVICE_WACOM(0x5002) },
4075 { USB_DEVICE_LENOVO(0x6004) },
4077 { USB_DEVICE_WACOM(HID_ANY_ID
) },
4078 { I2C_DEVICE_WACOM(HID_ANY_ID
) },
4081 MODULE_DEVICE_TABLE(hid
, wacom_ids
);