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
;
170 pressure
= (signed char)((data
[7] << 1) | ((data
[4] >> 2) & 1));
171 if (features
->pressure_max
> 255)
172 pressure
= (pressure
<< 1) | ((data
[4] >> 6) & 1);
173 pressure
+= (features
->pressure_max
+ 1) / 2;
175 input_report_abs(input
, ABS_X
, data
[3] | (data
[2] << 7) | ((data
[1] & 0x03) << 14));
176 input_report_abs(input
, ABS_Y
, data
[6] | (data
[5] << 7) | ((data
[4] & 0x03) << 14));
177 input_report_abs(input
, ABS_PRESSURE
, pressure
);
179 input_report_key(input
, BTN_TOUCH
, data
[4] & 0x08);
180 input_report_key(input
, BTN_STYLUS
, data
[4] & 0x10);
181 /* Only allow the stylus2 button to be reported for the pen tool. */
182 input_report_key(input
, BTN_STYLUS2
, (wacom
->tool
[0] == BTN_TOOL_PEN
) && (data
[4] & 0x20));
187 input_report_key(input
, wacom
->tool
[0], prox
);
188 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]);
192 static int wacom_ptu_irq(struct wacom_wac
*wacom
)
194 unsigned char *data
= wacom
->data
;
195 struct input_dev
*input
= wacom
->pen_input
;
197 if (data
[0] != WACOM_REPORT_PENABLED
) {
198 dev_dbg(input
->dev
.parent
,
199 "%s: received unknown report #%d\n", __func__
, data
[0]);
203 if (data
[1] & 0x04) {
204 input_report_key(input
, BTN_TOOL_RUBBER
, data
[1] & 0x20);
205 input_report_key(input
, BTN_TOUCH
, data
[1] & 0x08);
206 wacom
->id
[0] = ERASER_DEVICE_ID
;
208 input_report_key(input
, BTN_TOOL_PEN
, data
[1] & 0x20);
209 input_report_key(input
, BTN_TOUCH
, data
[1] & 0x01);
210 wacom
->id
[0] = STYLUS_DEVICE_ID
;
212 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]); /* report tool id */
213 input_report_abs(input
, ABS_X
, le16_to_cpup((__le16
*)&data
[2]));
214 input_report_abs(input
, ABS_Y
, le16_to_cpup((__le16
*)&data
[4]));
215 input_report_abs(input
, ABS_PRESSURE
, le16_to_cpup((__le16
*)&data
[6]));
216 input_report_key(input
, BTN_STYLUS
, data
[1] & 0x02);
217 input_report_key(input
, BTN_STYLUS2
, data
[1] & 0x10);
221 static int wacom_dtu_irq(struct wacom_wac
*wacom
)
223 unsigned char *data
= wacom
->data
;
224 struct input_dev
*input
= wacom
->pen_input
;
225 int prox
= data
[1] & 0x20;
227 dev_dbg(input
->dev
.parent
,
228 "%s: received report #%d", __func__
, data
[0]);
231 /* Going into proximity select tool */
232 wacom
->tool
[0] = (data
[1] & 0x0c) ? BTN_TOOL_RUBBER
: BTN_TOOL_PEN
;
233 if (wacom
->tool
[0] == BTN_TOOL_PEN
)
234 wacom
->id
[0] = STYLUS_DEVICE_ID
;
236 wacom
->id
[0] = ERASER_DEVICE_ID
;
238 input_report_key(input
, BTN_STYLUS
, data
[1] & 0x02);
239 input_report_key(input
, BTN_STYLUS2
, data
[1] & 0x10);
240 input_report_abs(input
, ABS_X
, le16_to_cpup((__le16
*)&data
[2]));
241 input_report_abs(input
, ABS_Y
, le16_to_cpup((__le16
*)&data
[4]));
242 input_report_abs(input
, ABS_PRESSURE
, ((data
[7] & 0x01) << 8) | data
[6]);
243 input_report_key(input
, BTN_TOUCH
, data
[1] & 0x05);
244 if (!prox
) /* out-prox */
246 input_report_key(input
, wacom
->tool
[0], prox
);
247 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]);
251 static int wacom_dtus_irq(struct wacom_wac
*wacom
)
253 char *data
= wacom
->data
;
254 struct input_dev
*input
= wacom
->pen_input
;
255 unsigned short prox
, pressure
= 0;
257 if (data
[0] != WACOM_REPORT_DTUS
&& data
[0] != WACOM_REPORT_DTUSPAD
) {
258 dev_dbg(input
->dev
.parent
,
259 "%s: received unknown report #%d", __func__
, data
[0]);
261 } else if (data
[0] == WACOM_REPORT_DTUSPAD
) {
262 input
= wacom
->pad_input
;
263 input_report_key(input
, BTN_0
, (data
[1] & 0x01));
264 input_report_key(input
, BTN_1
, (data
[1] & 0x02));
265 input_report_key(input
, BTN_2
, (data
[1] & 0x04));
266 input_report_key(input
, BTN_3
, (data
[1] & 0x08));
267 input_report_abs(input
, ABS_MISC
,
268 data
[1] & 0x0f ? PAD_DEVICE_ID
: 0);
271 prox
= data
[1] & 0x80;
273 switch ((data
[1] >> 3) & 3) {
275 wacom
->tool
[0] = BTN_TOOL_RUBBER
;
276 wacom
->id
[0] = ERASER_DEVICE_ID
;
280 wacom
->tool
[0] = BTN_TOOL_PEN
;
281 wacom
->id
[0] = STYLUS_DEVICE_ID
;
286 input_report_key(input
, BTN_STYLUS
, data
[1] & 0x20);
287 input_report_key(input
, BTN_STYLUS2
, data
[1] & 0x40);
288 input_report_abs(input
, ABS_X
, get_unaligned_be16(&data
[3]));
289 input_report_abs(input
, ABS_Y
, get_unaligned_be16(&data
[5]));
290 pressure
= ((data
[1] & 0x03) << 8) | (data
[2] & 0xff);
291 input_report_abs(input
, ABS_PRESSURE
, pressure
);
292 input_report_key(input
, BTN_TOUCH
, pressure
> 10);
294 if (!prox
) /* out-prox */
296 input_report_key(input
, wacom
->tool
[0], prox
);
297 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]);
302 static int wacom_graphire_irq(struct wacom_wac
*wacom
)
304 struct wacom_features
*features
= &wacom
->features
;
305 unsigned char *data
= wacom
->data
;
306 struct input_dev
*input
= wacom
->pen_input
;
307 struct input_dev
*pad_input
= wacom
->pad_input
;
308 int battery_capacity
, ps_connected
;
313 if (features
->type
== GRAPHIRE_BT
) {
314 if (data
[0] != WACOM_REPORT_PENABLED_BT
) {
315 dev_dbg(input
->dev
.parent
,
316 "%s: received unknown report #%d\n", __func__
,
320 } else if (data
[0] != WACOM_REPORT_PENABLED
) {
321 dev_dbg(input
->dev
.parent
,
322 "%s: received unknown report #%d\n", __func__
, data
[0]);
326 prox
= data
[1] & 0x80;
327 if (prox
|| wacom
->id
[0]) {
329 switch ((data
[1] >> 5) & 3) {
332 wacom
->tool
[0] = BTN_TOOL_PEN
;
333 wacom
->id
[0] = STYLUS_DEVICE_ID
;
337 wacom
->tool
[0] = BTN_TOOL_RUBBER
;
338 wacom
->id
[0] = ERASER_DEVICE_ID
;
341 case 2: /* Mouse with wheel */
342 input_report_key(input
, BTN_MIDDLE
, data
[1] & 0x04);
345 case 3: /* Mouse without wheel */
346 wacom
->tool
[0] = BTN_TOOL_MOUSE
;
347 wacom
->id
[0] = CURSOR_DEVICE_ID
;
351 input_report_abs(input
, ABS_X
, le16_to_cpup((__le16
*)&data
[2]));
352 input_report_abs(input
, ABS_Y
, le16_to_cpup((__le16
*)&data
[4]));
353 if (wacom
->tool
[0] != BTN_TOOL_MOUSE
) {
354 if (features
->type
== GRAPHIRE_BT
)
355 input_report_abs(input
, ABS_PRESSURE
, data
[6] |
356 (((__u16
) (data
[1] & 0x08)) << 5));
358 input_report_abs(input
, ABS_PRESSURE
, data
[6] |
359 ((data
[7] & 0x03) << 8));
360 input_report_key(input
, BTN_TOUCH
, data
[1] & 0x01);
361 input_report_key(input
, BTN_STYLUS
, data
[1] & 0x02);
362 input_report_key(input
, BTN_STYLUS2
, data
[1] & 0x04);
364 input_report_key(input
, BTN_LEFT
, data
[1] & 0x01);
365 input_report_key(input
, BTN_RIGHT
, data
[1] & 0x02);
366 if (features
->type
== WACOM_G4
||
367 features
->type
== WACOM_MO
) {
368 input_report_abs(input
, ABS_DISTANCE
, data
[6] & 0x3f);
369 rw
= (data
[7] & 0x04) - (data
[7] & 0x03);
370 } else if (features
->type
== GRAPHIRE_BT
) {
371 /* Compute distance between mouse and tablet */
372 rw
= 44 - (data
[6] >> 2);
373 rw
= clamp_val(rw
, 0, 31);
374 input_report_abs(input
, ABS_DISTANCE
, rw
);
375 if (((data
[1] >> 5) & 3) == 2) {
376 /* Mouse with wheel */
377 input_report_key(input
, BTN_MIDDLE
,
379 rw
= (data
[6] & 0x01) ? -1 :
380 (data
[6] & 0x02) ? 1 : 0;
385 input_report_abs(input
, ABS_DISTANCE
, data
[7] & 0x3f);
386 rw
= -(signed char)data
[6];
388 input_report_rel(input
, REL_WHEEL
, rw
);
393 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]); /* report tool id */
394 input_report_key(input
, wacom
->tool
[0], prox
);
395 input_sync(input
); /* sync last event */
399 switch (features
->type
) {
401 prox
= data
[7] & 0xf8;
402 if (prox
|| wacom
->id
[1]) {
403 wacom
->id
[1] = PAD_DEVICE_ID
;
404 input_report_key(pad_input
, BTN_BACK
, (data
[7] & 0x40));
405 input_report_key(pad_input
, BTN_FORWARD
, (data
[7] & 0x80));
406 rw
= ((data
[7] & 0x18) >> 3) - ((data
[7] & 0x20) >> 3);
407 input_report_rel(pad_input
, REL_WHEEL
, rw
);
410 input_report_abs(pad_input
, ABS_MISC
, wacom
->id
[1]);
416 prox
= (data
[7] & 0xf8) || data
[8];
417 if (prox
|| wacom
->id
[1]) {
418 wacom
->id
[1] = PAD_DEVICE_ID
;
419 input_report_key(pad_input
, BTN_BACK
, (data
[7] & 0x08));
420 input_report_key(pad_input
, BTN_LEFT
, (data
[7] & 0x20));
421 input_report_key(pad_input
, BTN_FORWARD
, (data
[7] & 0x10));
422 input_report_key(pad_input
, BTN_RIGHT
, (data
[7] & 0x40));
423 input_report_abs(pad_input
, ABS_WHEEL
, (data
[8] & 0x7f));
426 input_report_abs(pad_input
, ABS_MISC
, wacom
->id
[1]);
431 prox
= data
[7] & 0x03;
432 if (prox
|| wacom
->id
[1]) {
433 wacom
->id
[1] = PAD_DEVICE_ID
;
434 input_report_key(pad_input
, BTN_0
, (data
[7] & 0x02));
435 input_report_key(pad_input
, BTN_1
, (data
[7] & 0x01));
438 input_report_abs(pad_input
, ABS_MISC
, wacom
->id
[1]);
444 /* Store current battery capacity and power supply state */
445 if (features
->type
== GRAPHIRE_BT
) {
446 rw
= (data
[7] >> 2 & 0x07);
447 battery_capacity
= batcap_gr
[rw
];
448 ps_connected
= rw
== 7;
449 wacom_notify_battery(wacom
, battery_capacity
, ps_connected
,
456 static void wacom_intuos_schedule_prox_event(struct wacom_wac
*wacom_wac
)
458 struct wacom
*wacom
= container_of(wacom_wac
, struct wacom
, wacom_wac
);
459 struct wacom_features
*features
= &wacom_wac
->features
;
460 struct hid_report
*r
;
461 struct hid_report_enum
*re
;
463 re
= &(wacom
->hdev
->report_enum
[HID_FEATURE_REPORT
]);
464 if (features
->type
== INTUOSHT2
)
465 r
= re
->report_id_hash
[WACOM_REPORT_INTUOSHT2_ID
];
467 r
= re
->report_id_hash
[WACOM_REPORT_INTUOS_ID1
];
469 hid_hw_request(wacom
->hdev
, r
, HID_REQ_GET_REPORT
);
473 static int wacom_intuos_pad(struct wacom_wac
*wacom
)
475 struct wacom_features
*features
= &wacom
->features
;
476 unsigned char *data
= wacom
->data
;
477 struct input_dev
*input
= wacom
->pad_input
;
479 int buttons
= 0, nbuttons
= features
->numbered_buttons
;
480 int keys
= 0, nkeys
= 0;
481 int ring1
= 0, ring2
= 0;
482 int strip1
= 0, strip2
= 0;
485 /* pad packets. Works as a second tool and is always in prox */
486 if (!(data
[0] == WACOM_REPORT_INTUOSPAD
|| data
[0] == WACOM_REPORT_INTUOS5PAD
||
487 data
[0] == WACOM_REPORT_CINTIQPAD
))
490 if (features
->type
>= INTUOS4S
&& features
->type
<= INTUOS4L
) {
491 buttons
= (data
[3] << 1) | (data
[2] & 0x01);
493 } else if (features
->type
== DTK
) {
495 } else if (features
->type
== WACOM_13HD
) {
496 buttons
= (data
[4] << 1) | (data
[3] & 0x01);
497 } else if (features
->type
== WACOM_24HD
) {
498 buttons
= (data
[8] << 8) | data
[6];
503 * Three "buttons" are available on the 24HD which are
504 * physically implemented as a touchstrip. Each button
505 * is approximately 3 bits wide with a 2 bit spacing.
506 * The raw touchstrip bits are stored at:
507 * ((data[3] & 0x1f) << 8) | data[4])
510 keys
= ((data
[3] & 0x1C) ? 1<<2 : 0) |
511 ((data
[4] & 0xE0) ? 1<<1 : 0) |
512 ((data
[4] & 0x07) ? 1<<0 : 0);
513 } else if (features
->type
== WACOM_27QHD
) {
515 keys
= data
[2] & 0x07;
517 input_report_abs(input
, ABS_X
, be16_to_cpup((__be16
*)&data
[4]));
518 input_report_abs(input
, ABS_Y
, be16_to_cpup((__be16
*)&data
[6]));
519 input_report_abs(input
, ABS_Z
, be16_to_cpup((__be16
*)&data
[8]));
520 } else if (features
->type
== CINTIQ_HYBRID
) {
522 * Do not send hardware buttons under Android. They
523 * are already sent to the system through GPIO (and
524 * have different meaning).
526 * d-pad right -> data[4] & 0x10
527 * d-pad up -> data[4] & 0x20
528 * d-pad left -> data[4] & 0x40
529 * d-pad down -> data[4] & 0x80
530 * d-pad center -> data[3] & 0x01
532 buttons
= (data
[4] << 1) | (data
[3] & 0x01);
533 } else if (features
->type
== CINTIQ_COMPANION_2
) {
534 /* d-pad right -> data[4] & 0x10
535 * d-pad up -> data[4] & 0x20
536 * d-pad left -> data[4] & 0x40
537 * d-pad down -> data[4] & 0x80
538 * d-pad center -> data[3] & 0x01
540 buttons
= ((data
[2] >> 4) << 7) |
541 ((data
[1] & 0x04) << 6) |
542 ((data
[2] & 0x0F) << 2) |
544 } else if (features
->type
>= INTUOS5S
&& features
->type
<= INTUOSPL
) {
546 * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in
547 * addition to the mechanical switch. Switch data is
548 * stored in data[4], capacitive data in data[5].
550 * Touch ring mode switch (data[3]) has no capacitive sensor
552 buttons
= (data
[4] << 1) | (data
[3] & 0x01);
555 if (features
->type
== WACOM_21UX2
|| features
->type
== WACOM_22HD
) {
556 buttons
= (data
[8] << 10) | ((data
[7] & 0x01) << 9) |
557 (data
[6] << 1) | (data
[5] & 0x01);
559 if (features
->type
== WACOM_22HD
) {
561 keys
= data
[9] & 0x07;
564 buttons
= ((data
[6] & 0x10) << 10) |
565 ((data
[5] & 0x10) << 9) |
566 ((data
[6] & 0x0F) << 4) |
569 strip1
= ((data
[1] & 0x1f) << 8) | data
[2];
570 strip2
= ((data
[3] & 0x1f) << 8) | data
[4];
573 prox
= (buttons
& ~(~0 << nbuttons
)) | (keys
& ~(~0 << nkeys
)) |
574 (ring1
& 0x80) | (ring2
& 0x80) | strip1
| strip2
;
576 wacom_report_numbered_buttons(input
, nbuttons
, buttons
);
578 for (i
= 0; i
< nkeys
; i
++)
579 input_report_key(input
, KEY_PROG1
+ i
, keys
& (1 << i
));
581 input_report_abs(input
, ABS_RX
, strip1
);
582 input_report_abs(input
, ABS_RY
, strip2
);
584 input_report_abs(input
, ABS_WHEEL
, (ring1
& 0x80) ? (ring1
& 0x7f) : 0);
585 input_report_abs(input
, ABS_THROTTLE
, (ring2
& 0x80) ? (ring2
& 0x7f) : 0);
587 input_report_key(input
, wacom
->tool
[1], prox
? 1 : 0);
588 input_report_abs(input
, ABS_MISC
, prox
? PAD_DEVICE_ID
: 0);
590 input_event(input
, EV_MSC
, MSC_SERIAL
, 0xffffffff);
595 static int wacom_intuos_id_mangle(int tool_id
)
597 return (tool_id
& ~0xFFF) << 4 | (tool_id
& 0xFFF);
600 static int wacom_intuos_get_tool_type(int tool_id
)
605 case 0x812: /* Inking pen */
606 case 0x801: /* Intuos3 Inking pen */
607 case 0x12802: /* Intuos4/5 Inking Pen */
609 tool_type
= BTN_TOOL_PENCIL
;
612 case 0x822: /* Pen */
615 case 0x823: /* Intuos3 Grip Pen */
616 case 0x813: /* Intuos3 Classic Pen */
617 case 0x885: /* Intuos3 Marker Pen */
618 case 0x802: /* Intuos4/5 13HD/24HD General Pen */
619 case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
620 case 0x8e2: /* IntuosHT2 pen */
622 case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */
623 case 0x14802: /* Intuos4/5 13HD/24HD Classic Pen */
624 case 0x16802: /* Cintiq 13HD Pro Pen */
625 case 0x18802: /* DTH2242 Pen */
626 case 0x10802: /* Intuos4/5 13HD/24HD General Pen */
627 tool_type
= BTN_TOOL_PEN
;
630 case 0x832: /* Stroke pen */
632 tool_type
= BTN_TOOL_BRUSH
;
635 case 0x007: /* Mouse 4D and 2D */
638 case 0x017: /* Intuos3 2D Mouse */
639 case 0x806: /* Intuos4 Mouse */
640 tool_type
= BTN_TOOL_MOUSE
;
643 case 0x096: /* Lens cursor */
644 case 0x097: /* Intuos3 Lens cursor */
645 case 0x006: /* Intuos4 Lens cursor */
646 tool_type
= BTN_TOOL_LENS
;
649 case 0x82a: /* Eraser */
655 case 0x82b: /* Intuos3 Grip Pen Eraser */
656 case 0x81b: /* Intuos3 Classic Pen Eraser */
657 case 0x91b: /* Intuos3 Airbrush Eraser */
658 case 0x80c: /* Intuos4/5 13HD/24HD Marker Pen Eraser */
659 case 0x80a: /* Intuos4/5 13HD/24HD General Pen Eraser */
660 case 0x90a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
661 case 0x1480a: /* Intuos4/5 13HD/24HD Classic Pen Eraser */
662 case 0x1090a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
663 case 0x1080c: /* Intuos4/5 13HD/24HD Art Pen Eraser */
664 case 0x1680a: /* Cintiq 13HD Pro Pen Eraser */
665 case 0x1880a: /* DTH2242 Eraser */
666 case 0x1080a: /* Intuos4/5 13HD/24HD General Pen Eraser */
667 tool_type
= BTN_TOOL_RUBBER
;
673 case 0x913: /* Intuos3 Airbrush */
674 case 0x902: /* Intuos4/5 13HD/24HD Airbrush */
675 case 0x10902: /* Intuos4/5 13HD/24HD Airbrush */
676 tool_type
= BTN_TOOL_AIRBRUSH
;
679 default: /* Unknown tool */
680 tool_type
= BTN_TOOL_PEN
;
686 static int wacom_intuos_inout(struct wacom_wac
*wacom
)
688 struct wacom_features
*features
= &wacom
->features
;
689 unsigned char *data
= wacom
->data
;
690 struct input_dev
*input
= wacom
->pen_input
;
691 int idx
= (features
->type
== INTUOS
) ? (data
[1] & 0x01) : 0;
693 if (!(((data
[1] & 0xfc) == 0xc0) || /* in prox */
694 ((data
[1] & 0xfe) == 0x20) || /* in range */
695 ((data
[1] & 0xfe) == 0x80))) /* out prox */
699 if ((data
[1] & 0xfc) == 0xc0) {
700 /* serial number of the tool */
701 wacom
->serial
[idx
] = ((data
[3] & 0x0f) << 28) +
702 (data
[4] << 20) + (data
[5] << 12) +
703 (data
[6] << 4) + (data
[7] >> 4);
705 wacom
->id
[idx
] = (data
[2] << 4) | (data
[3] >> 4) |
706 ((data
[7] & 0x0f) << 16) | ((data
[8] & 0xf0) << 8);
708 wacom
->tool
[idx
] = wacom_intuos_get_tool_type(wacom
->id
[idx
]);
710 wacom
->shared
->stylus_in_proximity
= true;
715 if ((data
[1] & 0xfe) == 0x20) {
716 if (features
->type
!= INTUOSHT2
)
717 wacom
->shared
->stylus_in_proximity
= true;
719 /* in Range while exiting */
720 if (wacom
->reporting_data
) {
721 input_report_key(input
, BTN_TOUCH
, 0);
722 input_report_abs(input
, ABS_PRESSURE
, 0);
723 input_report_abs(input
, ABS_DISTANCE
, wacom
->features
.distance_max
);
730 if ((data
[1] & 0xfe) == 0x80) {
731 wacom
->shared
->stylus_in_proximity
= false;
732 wacom
->reporting_data
= false;
734 /* don't report exit if we don't know the ID */
739 * Reset all states otherwise we lose the initial states
740 * when in-prox next time
742 input_report_abs(input
, ABS_X
, 0);
743 input_report_abs(input
, ABS_Y
, 0);
744 input_report_abs(input
, ABS_DISTANCE
, 0);
745 input_report_abs(input
, ABS_TILT_X
, 0);
746 input_report_abs(input
, ABS_TILT_Y
, 0);
747 if (wacom
->tool
[idx
] >= BTN_TOOL_MOUSE
) {
748 input_report_key(input
, BTN_LEFT
, 0);
749 input_report_key(input
, BTN_MIDDLE
, 0);
750 input_report_key(input
, BTN_RIGHT
, 0);
751 input_report_key(input
, BTN_SIDE
, 0);
752 input_report_key(input
, BTN_EXTRA
, 0);
753 input_report_abs(input
, ABS_THROTTLE
, 0);
754 input_report_abs(input
, ABS_RZ
, 0);
756 input_report_abs(input
, ABS_PRESSURE
, 0);
757 input_report_key(input
, BTN_STYLUS
, 0);
758 input_report_key(input
, BTN_STYLUS2
, 0);
759 input_report_key(input
, BTN_TOUCH
, 0);
760 input_report_abs(input
, ABS_WHEEL
, 0);
761 if (features
->type
>= INTUOS3S
)
762 input_report_abs(input
, ABS_Z
, 0);
764 input_report_key(input
, wacom
->tool
[idx
], 0);
765 input_report_abs(input
, ABS_MISC
, 0); /* reset tool id */
766 input_event(input
, EV_MSC
, MSC_SERIAL
, wacom
->serial
[idx
]);
774 static int wacom_remote_irq(struct wacom_wac
*wacom_wac
, size_t len
)
776 unsigned char *data
= wacom_wac
->data
;
777 struct input_dev
*input
;
778 struct wacom
*wacom
= container_of(wacom_wac
, struct wacom
, wacom_wac
);
779 struct wacom_remote
*remote
= wacom
->remote
;
780 int bat_charging
, bat_percent
, touch_ring_mode
;
785 if (data
[0] != WACOM_REPORT_REMOTE
) {
786 hid_dbg(wacom
->hdev
, "%s: received unknown report #%d",
791 serial
= data
[3] + (data
[4] << 8) + (data
[5] << 16);
792 wacom_wac
->id
[0] = PAD_DEVICE_ID
;
794 spin_lock_irqsave(&remote
->remote_lock
, flags
);
796 for (i
= 0; i
< WACOM_MAX_REMOTES
; i
++) {
797 if (remote
->remotes
[i
].serial
== serial
) {
803 if (index
< 0 || !remote
->remotes
[index
].registered
)
806 input
= remote
->remotes
[index
].input
;
808 input_report_key(input
, BTN_0
, (data
[9] & 0x01));
809 input_report_key(input
, BTN_1
, (data
[9] & 0x02));
810 input_report_key(input
, BTN_2
, (data
[9] & 0x04));
811 input_report_key(input
, BTN_3
, (data
[9] & 0x08));
812 input_report_key(input
, BTN_4
, (data
[9] & 0x10));
813 input_report_key(input
, BTN_5
, (data
[9] & 0x20));
814 input_report_key(input
, BTN_6
, (data
[9] & 0x40));
815 input_report_key(input
, BTN_7
, (data
[9] & 0x80));
817 input_report_key(input
, BTN_8
, (data
[10] & 0x01));
818 input_report_key(input
, BTN_9
, (data
[10] & 0x02));
819 input_report_key(input
, BTN_A
, (data
[10] & 0x04));
820 input_report_key(input
, BTN_B
, (data
[10] & 0x08));
821 input_report_key(input
, BTN_C
, (data
[10] & 0x10));
822 input_report_key(input
, BTN_X
, (data
[10] & 0x20));
823 input_report_key(input
, BTN_Y
, (data
[10] & 0x40));
824 input_report_key(input
, BTN_Z
, (data
[10] & 0x80));
826 input_report_key(input
, BTN_BASE
, (data
[11] & 0x01));
827 input_report_key(input
, BTN_BASE2
, (data
[11] & 0x02));
830 input_report_abs(input
, ABS_WHEEL
, (data
[12] & 0x7f));
832 input_report_abs(input
, ABS_WHEEL
, 0);
834 bat_percent
= data
[7] & 0x7f;
835 bat_charging
= !!(data
[7] & 0x80);
837 if (data
[9] | data
[10] | (data
[11] & 0x03) | data
[12])
838 input_report_abs(input
, ABS_MISC
, PAD_DEVICE_ID
);
840 input_report_abs(input
, ABS_MISC
, 0);
842 input_event(input
, EV_MSC
, MSC_SERIAL
, serial
);
846 /*Which mode select (LED light) is currently on?*/
847 touch_ring_mode
= (data
[11] & 0xC0) >> 6;
849 for (i
= 0; i
< WACOM_MAX_REMOTES
; i
++) {
850 if (remote
->remotes
[i
].serial
== serial
)
851 wacom
->led
.groups
[i
].select
= touch_ring_mode
;
854 __wacom_notify_battery(&remote
->remotes
[index
].battery
, bat_percent
,
855 bat_charging
, 1, bat_charging
);
858 spin_unlock_irqrestore(&remote
->remote_lock
, flags
);
862 static void wacom_remote_status_irq(struct wacom_wac
*wacom_wac
, size_t len
)
864 struct wacom
*wacom
= container_of(wacom_wac
, struct wacom
, wacom_wac
);
865 unsigned char *data
= wacom_wac
->data
;
866 struct wacom_remote
*remote
= wacom
->remote
;
867 struct wacom_remote_data remote_data
;
871 if (data
[0] != WACOM_REPORT_DEVICE_LIST
)
874 memset(&remote_data
, 0, sizeof(struct wacom_remote_data
));
876 for (i
= 0; i
< WACOM_MAX_REMOTES
; i
++) {
878 int serial
= (data
[j
+6] << 16) + (data
[j
+5] << 8) + data
[j
+4];
879 bool connected
= data
[j
+2];
881 remote_data
.remote
[i
].serial
= serial
;
882 remote_data
.remote
[i
].connected
= connected
;
885 spin_lock_irqsave(&remote
->remote_lock
, flags
);
887 ret
= kfifo_in(&remote
->remote_fifo
, &remote_data
, sizeof(remote_data
));
888 if (ret
!= sizeof(remote_data
)) {
889 spin_unlock_irqrestore(&remote
->remote_lock
, flags
);
890 hid_err(wacom
->hdev
, "Can't queue Remote status event.\n");
894 spin_unlock_irqrestore(&remote
->remote_lock
, flags
);
896 wacom_schedule_work(wacom_wac
, WACOM_WORKER_REMOTE
);
899 static inline bool report_touch_events(struct wacom_wac
*wacom
)
901 return (touch_arbitration
? !wacom
->shared
->stylus_in_proximity
: 1);
904 static inline bool delay_pen_events(struct wacom_wac
*wacom
)
906 return (wacom
->shared
->touch_down
&& touch_arbitration
);
909 static int wacom_intuos_general(struct wacom_wac
*wacom
)
911 struct wacom_features
*features
= &wacom
->features
;
912 unsigned char *data
= wacom
->data
;
913 struct input_dev
*input
= wacom
->pen_input
;
914 int idx
= (features
->type
== INTUOS
) ? (data
[1] & 0x01) : 0;
915 unsigned char type
= (data
[1] >> 1) & 0x0F;
916 unsigned int x
, y
, distance
, t
;
918 if (data
[0] != WACOM_REPORT_PENABLED
&& data
[0] != WACOM_REPORT_CINTIQ
&&
919 data
[0] != WACOM_REPORT_INTUOS_PEN
)
922 if (delay_pen_events(wacom
))
925 /* don't report events if we don't know the tool ID */
926 if (!wacom
->id
[idx
]) {
927 /* but reschedule a read of the current tool */
928 wacom_intuos_schedule_prox_event(wacom
);
933 * don't report events for invalid data
935 /* older I4 styli don't work with new Cintiqs */
936 if ((!((wacom
->id
[idx
] >> 16) & 0x01) &&
937 (features
->type
== WACOM_21UX2
)) ||
938 /* Only large Intuos support Lense Cursor */
939 (wacom
->tool
[idx
] == BTN_TOOL_LENS
&&
940 (features
->type
== INTUOS3
||
941 features
->type
== INTUOS3S
||
942 features
->type
== INTUOS4
||
943 features
->type
== INTUOS4S
||
944 features
->type
== INTUOS5
||
945 features
->type
== INTUOS5S
||
946 features
->type
== INTUOSPM
||
947 features
->type
== INTUOSPS
)) ||
948 /* Cintiq doesn't send data when RDY bit isn't set */
949 (features
->type
== CINTIQ
&& !(data
[1] & 0x40)))
952 x
= (be16_to_cpup((__be16
*)&data
[2]) << 1) | ((data
[9] >> 1) & 1);
953 y
= (be16_to_cpup((__be16
*)&data
[4]) << 1) | (data
[9] & 1);
954 distance
= data
[9] >> 2;
955 if (features
->type
< INTUOS3S
) {
960 input_report_abs(input
, ABS_X
, x
);
961 input_report_abs(input
, ABS_Y
, y
);
962 input_report_abs(input
, ABS_DISTANCE
, distance
);
969 /* general pen packet */
970 t
= (data
[6] << 3) | ((data
[7] & 0xC0) >> 5) | (data
[1] & 1);
971 if (features
->pressure_max
< 2047)
973 input_report_abs(input
, ABS_PRESSURE
, t
);
974 if (features
->type
!= INTUOSHT2
) {
975 input_report_abs(input
, ABS_TILT_X
,
976 (((data
[7] << 1) & 0x7e) | (data
[8] >> 7)) - 64);
977 input_report_abs(input
, ABS_TILT_Y
, (data
[8] & 0x7f) - 64);
979 input_report_key(input
, BTN_STYLUS
, data
[1] & 2);
980 input_report_key(input
, BTN_STYLUS2
, data
[1] & 4);
981 input_report_key(input
, BTN_TOUCH
, t
> 10);
985 /* airbrush second packet */
986 input_report_abs(input
, ABS_WHEEL
,
987 (data
[6] << 2) | ((data
[7] >> 6) & 3));
988 input_report_abs(input
, ABS_TILT_X
,
989 (((data
[7] << 1) & 0x7e) | (data
[8] >> 7)) - 64);
990 input_report_abs(input
, ABS_TILT_Y
, (data
[8] & 0x7f) - 64);
994 /* Rotation packet */
995 if (features
->type
>= INTUOS3S
) {
996 /* I3 marker pen rotation */
997 t
= (data
[6] << 3) | ((data
[7] >> 5) & 7);
998 t
= (data
[7] & 0x20) ? ((t
> 900) ? ((t
-1) / 2 - 1350) :
999 ((t
-1) / 2 + 450)) : (450 - t
/ 2) ;
1000 input_report_abs(input
, ABS_Z
, t
);
1002 /* 4D mouse 2nd packet */
1003 t
= (data
[6] << 3) | ((data
[7] >> 5) & 7);
1004 input_report_abs(input
, ABS_RZ
, (data
[7] & 0x20) ?
1005 ((t
- 1) / 2) : -t
/ 2);
1010 /* 4D mouse 1st packet */
1011 input_report_key(input
, BTN_LEFT
, data
[8] & 0x01);
1012 input_report_key(input
, BTN_MIDDLE
, data
[8] & 0x02);
1013 input_report_key(input
, BTN_RIGHT
, data
[8] & 0x04);
1015 input_report_key(input
, BTN_SIDE
, data
[8] & 0x20);
1016 input_report_key(input
, BTN_EXTRA
, data
[8] & 0x10);
1017 t
= (data
[6] << 2) | ((data
[7] >> 6) & 3);
1018 input_report_abs(input
, ABS_THROTTLE
, (data
[8] & 0x08) ? -t
: t
);
1023 input_report_key(input
, BTN_LEFT
, data
[6] & 0x01);
1024 input_report_key(input
, BTN_MIDDLE
, data
[6] & 0x02);
1025 input_report_key(input
, BTN_RIGHT
, data
[6] & 0x04);
1026 input_report_rel(input
, REL_WHEEL
, ((data
[7] & 0x80) >> 7)
1027 - ((data
[7] & 0x40) >> 6));
1028 input_report_key(input
, BTN_SIDE
, data
[6] & 0x08);
1029 input_report_key(input
, BTN_EXTRA
, data
[6] & 0x10);
1031 input_report_abs(input
, ABS_TILT_X
,
1032 (((data
[7] << 1) & 0x7e) | (data
[8] >> 7)) - 64);
1033 input_report_abs(input
, ABS_TILT_Y
, (data
[8] & 0x7f) - 64);
1037 if (wacom
->tool
[idx
] == BTN_TOOL_MOUSE
) {
1038 /* 2D mouse packet */
1039 input_report_key(input
, BTN_LEFT
, data
[8] & 0x04);
1040 input_report_key(input
, BTN_MIDDLE
, data
[8] & 0x08);
1041 input_report_key(input
, BTN_RIGHT
, data
[8] & 0x10);
1042 input_report_rel(input
, REL_WHEEL
, (data
[8] & 0x01)
1043 - ((data
[8] & 0x02) >> 1));
1045 /* I3 2D mouse side buttons */
1046 if (features
->type
>= INTUOS3S
&& features
->type
<= INTUOS3L
) {
1047 input_report_key(input
, BTN_SIDE
, data
[8] & 0x40);
1048 input_report_key(input
, BTN_EXTRA
, data
[8] & 0x20);
1051 else if (wacom
->tool
[idx
] == BTN_TOOL_LENS
) {
1052 /* Lens cursor packets */
1053 input_report_key(input
, BTN_LEFT
, data
[8] & 0x01);
1054 input_report_key(input
, BTN_MIDDLE
, data
[8] & 0x02);
1055 input_report_key(input
, BTN_RIGHT
, data
[8] & 0x04);
1056 input_report_key(input
, BTN_SIDE
, data
[8] & 0x10);
1057 input_report_key(input
, BTN_EXTRA
, data
[8] & 0x08);
1072 input_report_abs(input
, ABS_MISC
,
1073 wacom_intuos_id_mangle(wacom
->id
[idx
])); /* report tool id */
1074 input_report_key(input
, wacom
->tool
[idx
], 1);
1075 input_event(input
, EV_MSC
, MSC_SERIAL
, wacom
->serial
[idx
]);
1076 wacom
->reporting_data
= true;
1080 static int wacom_intuos_irq(struct wacom_wac
*wacom
)
1082 unsigned char *data
= wacom
->data
;
1083 struct input_dev
*input
= wacom
->pen_input
;
1086 if (data
[0] != WACOM_REPORT_PENABLED
&&
1087 data
[0] != WACOM_REPORT_INTUOS_ID1
&&
1088 data
[0] != WACOM_REPORT_INTUOS_ID2
&&
1089 data
[0] != WACOM_REPORT_INTUOSPAD
&&
1090 data
[0] != WACOM_REPORT_INTUOS_PEN
&&
1091 data
[0] != WACOM_REPORT_CINTIQ
&&
1092 data
[0] != WACOM_REPORT_CINTIQPAD
&&
1093 data
[0] != WACOM_REPORT_INTUOS5PAD
) {
1094 dev_dbg(input
->dev
.parent
,
1095 "%s: received unknown report #%d\n", __func__
, data
[0]);
1099 /* process pad events */
1100 result
= wacom_intuos_pad(wacom
);
1104 /* process in/out prox events */
1105 result
= wacom_intuos_inout(wacom
);
1109 /* process general packets */
1110 result
= wacom_intuos_general(wacom
);
1117 static int int_dist(int x1
, int y1
, int x2
, int y2
)
1122 return int_sqrt(x
*x
+ y
*y
);
1125 static void wacom_intuos_bt_process_data(struct wacom_wac
*wacom
,
1126 unsigned char *data
)
1128 memcpy(wacom
->data
, data
, 10);
1129 wacom_intuos_irq(wacom
);
1131 input_sync(wacom
->pen_input
);
1132 if (wacom
->pad_input
)
1133 input_sync(wacom
->pad_input
);
1136 static int wacom_intuos_bt_irq(struct wacom_wac
*wacom
, size_t len
)
1138 unsigned char data
[WACOM_PKGLEN_MAX
];
1140 unsigned power_raw
, battery_capacity
, bat_charging
, ps_connected
;
1142 memcpy(data
, wacom
->data
, len
);
1146 wacom_intuos_bt_process_data(wacom
, data
+ i
);
1150 wacom_intuos_bt_process_data(wacom
, data
+ i
);
1152 wacom_intuos_bt_process_data(wacom
, data
+ i
);
1154 power_raw
= data
[i
];
1155 bat_charging
= (power_raw
& 0x08) ? 1 : 0;
1156 ps_connected
= (power_raw
& 0x10) ? 1 : 0;
1157 battery_capacity
= batcap_i4
[power_raw
& 0x07];
1158 wacom_notify_battery(wacom
, battery_capacity
, bat_charging
,
1159 battery_capacity
|| bat_charging
,
1163 dev_dbg(wacom
->pen_input
->dev
.parent
,
1164 "Unknown report: %d,%d size:%zu\n",
1165 data
[0], data
[1], len
);
1171 static int wacom_wac_finger_count_touches(struct wacom_wac
*wacom
)
1173 struct input_dev
*input
= wacom
->touch_input
;
1174 unsigned touch_max
= wacom
->features
.touch_max
;
1182 return test_bit(BTN_TOUCH
, input
->key
) &&
1183 report_touch_events(wacom
);
1185 for (i
= 0; i
< input
->mt
->num_slots
; i
++) {
1186 struct input_mt_slot
*ps
= &input
->mt
->slots
[i
];
1187 int id
= input_mt_get_value(ps
, ABS_MT_TRACKING_ID
);
1195 static int wacom_24hdt_irq(struct wacom_wac
*wacom
)
1197 struct input_dev
*input
= wacom
->touch_input
;
1198 unsigned char *data
= wacom
->data
;
1200 int current_num_contacts
= data
[61];
1201 int contacts_to_send
= 0;
1202 int num_contacts_left
= 4; /* maximum contacts per packet */
1203 int byte_per_packet
= WACOM_BYTES_PER_24HDT_PACKET
;
1206 if (wacom
->features
.type
== WACOM_27QHDT
) {
1207 current_num_contacts
= data
[63];
1208 num_contacts_left
= 10;
1209 byte_per_packet
= WACOM_BYTES_PER_QHDTHID_PACKET
;
1214 * First packet resets the counter since only the first
1215 * packet in series will have non-zero current_num_contacts.
1217 if (current_num_contacts
)
1218 wacom
->num_contacts_left
= current_num_contacts
;
1220 contacts_to_send
= min(num_contacts_left
, wacom
->num_contacts_left
);
1222 for (i
= 0; i
< contacts_to_send
; i
++) {
1223 int offset
= (byte_per_packet
* i
) + 1;
1224 bool touch
= (data
[offset
] & 0x1) && report_touch_events(wacom
);
1225 int slot
= input_mt_get_slot_by_key(input
, data
[offset
+ 1]);
1229 input_mt_slot(input
, slot
);
1230 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, touch
);
1233 int t_x
= get_unaligned_le16(&data
[offset
+ 2]);
1234 int t_y
= get_unaligned_le16(&data
[offset
+ 4 + y_offset
]);
1236 input_report_abs(input
, ABS_MT_POSITION_X
, t_x
);
1237 input_report_abs(input
, ABS_MT_POSITION_Y
, t_y
);
1239 if (wacom
->features
.type
!= WACOM_27QHDT
) {
1240 int c_x
= get_unaligned_le16(&data
[offset
+ 4]);
1241 int c_y
= get_unaligned_le16(&data
[offset
+ 8]);
1242 int w
= get_unaligned_le16(&data
[offset
+ 10]);
1243 int h
= get_unaligned_le16(&data
[offset
+ 12]);
1245 input_report_abs(input
, ABS_MT_TOUCH_MAJOR
, min(w
,h
));
1246 input_report_abs(input
, ABS_MT_WIDTH_MAJOR
,
1247 min(w
, h
) + int_dist(t_x
, t_y
, c_x
, c_y
));
1248 input_report_abs(input
, ABS_MT_WIDTH_MINOR
, min(w
, h
));
1249 input_report_abs(input
, ABS_MT_ORIENTATION
, w
> h
);
1253 input_mt_sync_frame(input
);
1255 wacom
->num_contacts_left
-= contacts_to_send
;
1256 if (wacom
->num_contacts_left
<= 0) {
1257 wacom
->num_contacts_left
= 0;
1258 wacom
->shared
->touch_down
= wacom_wac_finger_count_touches(wacom
);
1263 static int wacom_mt_touch(struct wacom_wac
*wacom
)
1265 struct input_dev
*input
= wacom
->touch_input
;
1266 unsigned char *data
= wacom
->data
;
1268 int current_num_contacts
= data
[2];
1269 int contacts_to_send
= 0;
1272 /* MTTPC does not support Height and Width */
1273 if (wacom
->features
.type
== MTTPC
|| wacom
->features
.type
== MTTPC_B
)
1277 * First packet resets the counter since only the first
1278 * packet in series will have non-zero current_num_contacts.
1280 if (current_num_contacts
)
1281 wacom
->num_contacts_left
= current_num_contacts
;
1283 /* There are at most 5 contacts per packet */
1284 contacts_to_send
= min(5, wacom
->num_contacts_left
);
1286 for (i
= 0; i
< contacts_to_send
; i
++) {
1287 int offset
= (WACOM_BYTES_PER_MT_PACKET
+ x_offset
) * i
+ 3;
1288 bool touch
= (data
[offset
] & 0x1) && report_touch_events(wacom
);
1289 int id
= get_unaligned_le16(&data
[offset
+ 1]);
1290 int slot
= input_mt_get_slot_by_key(input
, id
);
1295 input_mt_slot(input
, slot
);
1296 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, touch
);
1298 int x
= get_unaligned_le16(&data
[offset
+ x_offset
+ 7]);
1299 int y
= get_unaligned_le16(&data
[offset
+ x_offset
+ 9]);
1300 input_report_abs(input
, ABS_MT_POSITION_X
, x
);
1301 input_report_abs(input
, ABS_MT_POSITION_Y
, y
);
1304 input_mt_sync_frame(input
);
1306 wacom
->num_contacts_left
-= contacts_to_send
;
1307 if (wacom
->num_contacts_left
<= 0) {
1308 wacom
->num_contacts_left
= 0;
1309 wacom
->shared
->touch_down
= wacom_wac_finger_count_touches(wacom
);
1314 static int wacom_tpc_mt_touch(struct wacom_wac
*wacom
)
1316 struct input_dev
*input
= wacom
->touch_input
;
1317 unsigned char *data
= wacom
->data
;
1320 for (i
= 0; i
< 2; i
++) {
1321 int p
= data
[1] & (1 << i
);
1322 bool touch
= p
&& report_touch_events(wacom
);
1324 input_mt_slot(input
, i
);
1325 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, touch
);
1327 int x
= le16_to_cpup((__le16
*)&data
[i
* 2 + 2]) & 0x7fff;
1328 int y
= le16_to_cpup((__le16
*)&data
[i
* 2 + 6]) & 0x7fff;
1330 input_report_abs(input
, ABS_MT_POSITION_X
, x
);
1331 input_report_abs(input
, ABS_MT_POSITION_Y
, y
);
1334 input_mt_sync_frame(input
);
1336 /* keep touch state for pen event */
1337 wacom
->shared
->touch_down
= wacom_wac_finger_count_touches(wacom
);
1342 static int wacom_tpc_single_touch(struct wacom_wac
*wacom
, size_t len
)
1344 unsigned char *data
= wacom
->data
;
1345 struct input_dev
*input
= wacom
->touch_input
;
1346 bool prox
= report_touch_events(wacom
);
1349 if (wacom
->features
.touch_max
> 1 || len
> WACOM_PKGLEN_TPC2FG
)
1352 if (len
== WACOM_PKGLEN_TPC1FG
) {
1353 prox
= prox
&& (data
[0] & 0x01);
1354 x
= get_unaligned_le16(&data
[1]);
1355 y
= get_unaligned_le16(&data
[3]);
1356 } else if (len
== WACOM_PKGLEN_TPC1FG_B
) {
1357 prox
= prox
&& (data
[2] & 0x01);
1358 x
= get_unaligned_le16(&data
[3]);
1359 y
= get_unaligned_le16(&data
[5]);
1361 prox
= prox
&& (data
[1] & 0x01);
1362 x
= le16_to_cpup((__le16
*)&data
[2]);
1363 y
= le16_to_cpup((__le16
*)&data
[4]);
1367 input_report_abs(input
, ABS_X
, x
);
1368 input_report_abs(input
, ABS_Y
, y
);
1370 input_report_key(input
, BTN_TOUCH
, prox
);
1372 /* keep touch state for pen events */
1373 wacom
->shared
->touch_down
= prox
;
1378 static int wacom_tpc_pen(struct wacom_wac
*wacom
)
1380 unsigned char *data
= wacom
->data
;
1381 struct input_dev
*input
= wacom
->pen_input
;
1382 bool prox
= data
[1] & 0x20;
1384 if (!wacom
->shared
->stylus_in_proximity
) /* first in prox */
1385 /* Going into proximity select tool */
1386 wacom
->tool
[0] = (data
[1] & 0x0c) ? BTN_TOOL_RUBBER
: BTN_TOOL_PEN
;
1388 /* keep pen state for touch events */
1389 wacom
->shared
->stylus_in_proximity
= prox
;
1391 /* send pen events only when touch is up or forced out
1392 * or touch arbitration is off
1394 if (!delay_pen_events(wacom
)) {
1395 input_report_key(input
, BTN_STYLUS
, data
[1] & 0x02);
1396 input_report_key(input
, BTN_STYLUS2
, data
[1] & 0x10);
1397 input_report_abs(input
, ABS_X
, le16_to_cpup((__le16
*)&data
[2]));
1398 input_report_abs(input
, ABS_Y
, le16_to_cpup((__le16
*)&data
[4]));
1399 input_report_abs(input
, ABS_PRESSURE
, ((data
[7] & 0x07) << 8) | data
[6]);
1400 input_report_key(input
, BTN_TOUCH
, data
[1] & 0x05);
1401 input_report_key(input
, wacom
->tool
[0], prox
);
1408 static int wacom_tpc_irq(struct wacom_wac
*wacom
, size_t len
)
1410 unsigned char *data
= wacom
->data
;
1412 if (wacom
->pen_input
)
1413 dev_dbg(wacom
->pen_input
->dev
.parent
,
1414 "%s: received report #%d\n", __func__
, data
[0]);
1415 else if (wacom
->touch_input
)
1416 dev_dbg(wacom
->touch_input
->dev
.parent
,
1417 "%s: received report #%d\n", __func__
, data
[0]);
1420 case WACOM_PKGLEN_TPC1FG
:
1421 return wacom_tpc_single_touch(wacom
, len
);
1423 case WACOM_PKGLEN_TPC2FG
:
1424 return wacom_tpc_mt_touch(wacom
);
1426 case WACOM_PKGLEN_PENABLED
:
1427 return wacom_tpc_pen(wacom
);
1431 case WACOM_REPORT_TPC1FG
:
1432 case WACOM_REPORT_TPCHID
:
1433 case WACOM_REPORT_TPCST
:
1434 case WACOM_REPORT_TPC1FGE
:
1435 return wacom_tpc_single_touch(wacom
, len
);
1437 case WACOM_REPORT_TPCMT
:
1438 case WACOM_REPORT_TPCMT2
:
1439 return wacom_mt_touch(wacom
);
1441 case WACOM_REPORT_PENABLED
:
1442 return wacom_tpc_pen(wacom
);
1449 static int wacom_equivalent_usage(int usage
)
1451 if ((usage
& HID_USAGE_PAGE
) == WACOM_HID_UP_WACOMDIGITIZER
) {
1452 int subpage
= (usage
& 0xFF00) << 8;
1453 int subusage
= (usage
& 0xFF);
1455 if (subpage
== WACOM_HID_SP_PAD
||
1456 subpage
== WACOM_HID_SP_BUTTON
||
1457 subpage
== WACOM_HID_SP_DIGITIZER
||
1458 subpage
== WACOM_HID_SP_DIGITIZERINFO
||
1459 usage
== WACOM_HID_WD_SENSE
||
1460 usage
== WACOM_HID_WD_SERIALHI
||
1461 usage
== WACOM_HID_WD_TOOLTYPE
||
1462 usage
== WACOM_HID_WD_DISTANCE
||
1463 usage
== WACOM_HID_WD_TOUCHSTRIP
||
1464 usage
== WACOM_HID_WD_TOUCHSTRIP2
||
1465 usage
== WACOM_HID_WD_TOUCHRING
||
1466 usage
== WACOM_HID_WD_TOUCHRINGSTATUS
) {
1470 if (subpage
== HID_UP_UNDEFINED
)
1471 subpage
= HID_UP_DIGITIZER
;
1473 return subpage
| subusage
;
1479 static void wacom_map_usage(struct input_dev
*input
, struct hid_usage
*usage
,
1480 struct hid_field
*field
, __u8 type
, __u16 code
, int fuzz
)
1482 struct wacom
*wacom
= input_get_drvdata(input
);
1483 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1484 struct wacom_features
*features
= &wacom_wac
->features
;
1485 int fmin
= field
->logical_minimum
;
1486 int fmax
= field
->logical_maximum
;
1487 unsigned int equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
1488 int resolution_code
= code
;
1490 if (equivalent_usage
== HID_DG_TWIST
) {
1491 resolution_code
= ABS_RZ
;
1494 if (equivalent_usage
== HID_GD_X
) {
1495 fmin
+= features
->offset_left
;
1496 fmax
-= features
->offset_right
;
1498 if (equivalent_usage
== HID_GD_Y
) {
1499 fmin
+= features
->offset_top
;
1500 fmax
-= features
->offset_bottom
;
1506 set_bit(type
, input
->evbit
);
1510 input_set_abs_params(input
, code
, fmin
, fmax
, fuzz
, 0);
1511 input_abs_set_res(input
, code
,
1512 hidinput_calc_abs_res(field
, resolution_code
));
1515 input_set_capability(input
, EV_KEY
, code
);
1518 input_set_capability(input
, EV_MSC
, code
);
1521 input_set_capability(input
, EV_SW
, code
);
1526 static void wacom_wac_pad_usage_mapping(struct hid_device
*hdev
,
1527 struct hid_field
*field
, struct hid_usage
*usage
)
1529 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1530 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1531 struct wacom_features
*features
= &wacom_wac
->features
;
1532 struct input_dev
*input
= wacom_wac
->pad_input
;
1533 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
1535 switch (equivalent_usage
) {
1536 case WACOM_HID_WD_BATTERY_LEVEL
:
1537 case WACOM_HID_WD_BATTERY_CHARGING
:
1538 features
->quirks
|= WACOM_QUIRK_BATTERY
;
1540 case WACOM_HID_WD_ACCELEROMETER_X
:
1541 __set_bit(INPUT_PROP_ACCELEROMETER
, input
->propbit
);
1542 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_X
, 0);
1543 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1545 case WACOM_HID_WD_ACCELEROMETER_Y
:
1546 __set_bit(INPUT_PROP_ACCELEROMETER
, input
->propbit
);
1547 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_Y
, 0);
1548 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1550 case WACOM_HID_WD_ACCELEROMETER_Z
:
1551 __set_bit(INPUT_PROP_ACCELEROMETER
, input
->propbit
);
1552 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_Z
, 0);
1553 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1555 case WACOM_HID_WD_BUTTONHOME
:
1556 case WACOM_HID_WD_BUTTONUP
:
1557 case WACOM_HID_WD_BUTTONDOWN
:
1558 case WACOM_HID_WD_BUTTONLEFT
:
1559 case WACOM_HID_WD_BUTTONRIGHT
:
1560 case WACOM_HID_WD_BUTTONCENTER
:
1561 wacom_map_usage(input
, usage
, field
, EV_KEY
,
1562 wacom_numbered_button_to_key(features
->numbered_buttons
),
1564 features
->numbered_buttons
++;
1565 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1567 case WACOM_HID_WD_TOUCHONOFF
:
1568 wacom_map_usage(input
, usage
, field
, EV_SW
, SW_MUTE_DEVICE
, 0);
1569 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1571 case WACOM_HID_WD_TOUCHSTRIP
:
1572 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_RX
, 0);
1573 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1575 case WACOM_HID_WD_TOUCHSTRIP2
:
1576 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_RY
, 0);
1577 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1579 case WACOM_HID_WD_TOUCHRING
:
1580 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_WHEEL
, 0);
1581 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1585 switch (equivalent_usage
& 0xfffffff0) {
1586 case WACOM_HID_WD_EXPRESSKEY00
:
1587 wacom_map_usage(input
, usage
, field
, EV_KEY
,
1588 wacom_numbered_button_to_key(features
->numbered_buttons
),
1590 features
->numbered_buttons
++;
1591 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1596 static void wacom_wac_pad_battery_event(struct hid_device
*hdev
, struct hid_field
*field
,
1597 struct hid_usage
*usage
, __s32 value
)
1599 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1600 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1601 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
1603 switch (equivalent_usage
) {
1604 case WACOM_HID_WD_BATTERY_LEVEL
:
1605 wacom_wac
->hid_data
.battery_capacity
= value
;
1606 wacom_wac
->hid_data
.bat_connected
= 1;
1609 case WACOM_HID_WD_BATTERY_CHARGING
:
1610 wacom_wac
->hid_data
.bat_charging
= value
;
1611 wacom_wac
->hid_data
.ps_connected
= value
;
1612 wacom_wac
->hid_data
.bat_connected
= 1;
1617 static void wacom_wac_pad_event(struct hid_device
*hdev
, struct hid_field
*field
,
1618 struct hid_usage
*usage
, __s32 value
)
1620 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1621 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1622 struct input_dev
*input
= wacom_wac
->pad_input
;
1623 struct wacom_features
*features
= &wacom_wac
->features
;
1624 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
1626 if (wacom_equivalent_usage(field
->physical
) == HID_DG_TABLETFUNCTIONKEY
) {
1627 wacom_wac
->hid_data
.inrange_state
|= value
;
1630 switch (equivalent_usage
) {
1631 case WACOM_HID_WD_TOUCHRINGSTATUS
:
1635 features
->input_event_flag
= true;
1636 input_event(input
, usage
->type
, usage
->code
, value
);
1641 static void wacom_wac_pad_pre_report(struct hid_device
*hdev
,
1642 struct hid_report
*report
)
1644 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1645 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1647 wacom_wac
->hid_data
.inrange_state
= 0;
1650 static void wacom_wac_pad_battery_report(struct hid_device
*hdev
,
1651 struct hid_report
*report
)
1653 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1654 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1655 struct wacom_features
*features
= &wacom_wac
->features
;
1657 if (features
->quirks
& WACOM_QUIRK_BATTERY
) {
1658 int capacity
= wacom_wac
->hid_data
.battery_capacity
;
1659 bool charging
= wacom_wac
->hid_data
.bat_charging
;
1660 bool connected
= wacom_wac
->hid_data
.bat_connected
;
1661 bool powered
= wacom_wac
->hid_data
.ps_connected
;
1663 wacom_notify_battery(wacom_wac
, capacity
, charging
,
1664 connected
, powered
);
1668 static void wacom_wac_pad_report(struct hid_device
*hdev
,
1669 struct hid_report
*report
)
1671 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1672 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1673 struct wacom_features
*features
= &wacom_wac
->features
;
1674 struct input_dev
*input
= wacom_wac
->pad_input
;
1675 bool active
= wacom_wac
->hid_data
.inrange_state
!= 0;
1677 /* report prox for expresskey events */
1678 if (wacom_equivalent_usage(report
->field
[0]->physical
) == HID_DG_TABLETFUNCTIONKEY
) {
1679 features
->input_event_flag
= true;
1680 input_event(input
, EV_ABS
, ABS_MISC
, active
? PAD_DEVICE_ID
: 0);
1683 if (features
->input_event_flag
) {
1684 features
->input_event_flag
= false;
1689 static void wacom_wac_pen_usage_mapping(struct hid_device
*hdev
,
1690 struct hid_field
*field
, struct hid_usage
*usage
)
1692 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1693 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1694 struct wacom_features
*features
= &wacom_wac
->features
;
1695 struct input_dev
*input
= wacom_wac
->pen_input
;
1696 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
1698 switch (equivalent_usage
) {
1700 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_X
, 4);
1703 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_Y
, 4);
1705 case WACOM_HID_WD_DISTANCE
:
1707 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_DISTANCE
, 0);
1709 case HID_DG_TIPPRESSURE
:
1710 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_PRESSURE
, 0);
1712 case HID_DG_INRANGE
:
1713 wacom_map_usage(input
, usage
, field
, EV_KEY
, BTN_TOOL_PEN
, 0);
1715 case HID_DG_BATTERYSTRENGTH
:
1716 features
->quirks
|= WACOM_QUIRK_BATTERY
;
1719 wacom_map_usage(input
, usage
, field
, EV_KEY
,
1720 BTN_TOOL_RUBBER
, 0);
1723 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_TILT_X
, 0);
1726 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_TILT_Y
, 0);
1729 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_Z
, 0);
1732 case HID_DG_TIPSWITCH
:
1733 wacom_map_usage(input
, usage
, field
, EV_KEY
, BTN_TOUCH
, 0);
1735 case HID_DG_BARRELSWITCH
:
1736 wacom_map_usage(input
, usage
, field
, EV_KEY
, BTN_STYLUS
, 0);
1738 case HID_DG_BARRELSWITCH2
:
1739 wacom_map_usage(input
, usage
, field
, EV_KEY
, BTN_STYLUS2
, 0);
1741 case HID_DG_TOOLSERIALNUMBER
:
1742 wacom_map_usage(input
, usage
, field
, EV_MSC
, MSC_SERIAL
, 0);
1744 case WACOM_HID_WD_SENSE
:
1745 features
->quirks
|= WACOM_QUIRK_SENSE
;
1746 wacom_map_usage(input
, usage
, field
, EV_KEY
, BTN_TOOL_PEN
, 0);
1748 case WACOM_HID_WD_SERIALHI
:
1749 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_MISC
, 0);
1750 set_bit(EV_KEY
, input
->evbit
);
1751 input_set_capability(input
, EV_KEY
, BTN_TOOL_PEN
);
1752 input_set_capability(input
, EV_KEY
, BTN_TOOL_RUBBER
);
1753 input_set_capability(input
, EV_KEY
, BTN_TOOL_BRUSH
);
1754 input_set_capability(input
, EV_KEY
, BTN_TOOL_PENCIL
);
1755 input_set_capability(input
, EV_KEY
, BTN_TOOL_AIRBRUSH
);
1756 input_set_capability(input
, EV_KEY
, BTN_TOOL_MOUSE
);
1757 input_set_capability(input
, EV_KEY
, BTN_TOOL_LENS
);
1759 case WACOM_HID_WD_FINGERWHEEL
:
1760 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_WHEEL
, 0);
1765 static void wacom_wac_pen_event(struct hid_device
*hdev
, struct hid_field
*field
,
1766 struct hid_usage
*usage
, __s32 value
)
1768 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1769 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1770 struct wacom_features
*features
= &wacom_wac
->features
;
1771 struct input_dev
*input
= wacom_wac
->pen_input
;
1772 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
1774 switch (equivalent_usage
) {
1777 * HID_GD_Z "should increase as the control's position is
1778 * moved from high to low", while ABS_DISTANCE instead
1779 * increases in value as the tool moves from low to high.
1781 value
= field
->logical_maximum
- value
;
1783 case HID_DG_INRANGE
:
1784 wacom_wac
->hid_data
.inrange_state
= value
;
1785 if (!(features
->quirks
& WACOM_QUIRK_SENSE
))
1786 wacom_wac
->hid_data
.sense_state
= value
;
1788 case HID_DG_BATTERYSTRENGTH
:
1789 wacom_wac
->hid_data
.battery_capacity
= value
;
1790 wacom_wac
->hid_data
.bat_connected
= 1;
1793 wacom_wac
->hid_data
.invert_state
= value
;
1796 case HID_DG_TIPSWITCH
:
1797 wacom_wac
->hid_data
.tipswitch
|= value
;
1799 case HID_DG_TOOLSERIALNUMBER
:
1800 wacom_wac
->serial
[0] = (wacom_wac
->serial
[0] & ~0xFFFFFFFFULL
);
1801 wacom_wac
->serial
[0] |= value
;
1803 case WACOM_HID_WD_SENSE
:
1804 wacom_wac
->hid_data
.sense_state
= value
;
1806 case WACOM_HID_WD_SERIALHI
:
1807 wacom_wac
->serial
[0] = (wacom_wac
->serial
[0] & 0xFFFFFFFF);
1808 wacom_wac
->serial
[0] |= ((__u64
)value
) << 32;
1810 * Non-USI EMR devices may contain additional tool type
1811 * information here. See WACOM_HID_WD_TOOLTYPE case for
1814 if (value
>> 20 == 1) {
1815 wacom_wac
->id
[0] |= value
& 0xFFFFF;
1818 case WACOM_HID_WD_TOOLTYPE
:
1820 * Some devices (MobileStudio Pro, and possibly later
1821 * devices as well) do not return the complete tool
1822 * type in their WACOM_HID_WD_TOOLTYPE usage. Use a
1823 * bitwise OR so the complete value can be built
1826 wacom_wac
->id
[0] |= value
;
1828 case WACOM_HID_WD_OFFSETLEFT
:
1829 if (features
->offset_left
&& value
!= features
->offset_left
)
1830 hid_warn(hdev
, "%s: overriding exising left offset "
1831 "%d -> %d\n", __func__
, value
,
1832 features
->offset_left
);
1833 features
->offset_left
= value
;
1835 case WACOM_HID_WD_OFFSETRIGHT
:
1836 if (features
->offset_right
&& value
!= features
->offset_right
)
1837 hid_warn(hdev
, "%s: overriding exising right offset "
1838 "%d -> %d\n", __func__
, value
,
1839 features
->offset_right
);
1840 features
->offset_right
= value
;
1842 case WACOM_HID_WD_OFFSETTOP
:
1843 if (features
->offset_top
&& value
!= features
->offset_top
)
1844 hid_warn(hdev
, "%s: overriding exising top offset "
1845 "%d -> %d\n", __func__
, value
,
1846 features
->offset_top
);
1847 features
->offset_top
= value
;
1849 case WACOM_HID_WD_OFFSETBOTTOM
:
1850 if (features
->offset_bottom
&& value
!= features
->offset_bottom
)
1851 hid_warn(hdev
, "%s: overriding exising bottom offset "
1852 "%d -> %d\n", __func__
, value
,
1853 features
->offset_bottom
);
1854 features
->offset_bottom
= value
;
1858 /* send pen events only when touch is up or forced out
1859 * or touch arbitration is off
1861 if (!usage
->type
|| delay_pen_events(wacom_wac
))
1864 /* send pen events only when the pen is in/entering/leaving proximity */
1865 if (!wacom_wac
->hid_data
.inrange_state
&& !wacom_wac
->tool
[0])
1868 input_event(input
, usage
->type
, usage
->code
, value
);
1871 static void wacom_wac_pen_pre_report(struct hid_device
*hdev
,
1872 struct hid_report
*report
)
1877 static void wacom_wac_pen_report(struct hid_device
*hdev
,
1878 struct hid_report
*report
)
1880 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1881 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1882 struct input_dev
*input
= wacom_wac
->pen_input
;
1883 bool prox
= wacom_wac
->hid_data
.inrange_state
;
1884 bool range
= wacom_wac
->hid_data
.sense_state
;
1886 if (!wacom_wac
->tool
[0] && prox
) { /* first in prox */
1887 /* Going into proximity select tool */
1888 if (wacom_wac
->hid_data
.invert_state
)
1889 wacom_wac
->tool
[0] = BTN_TOOL_RUBBER
;
1890 else if (wacom_wac
->id
[0])
1891 wacom_wac
->tool
[0] = wacom_intuos_get_tool_type(wacom_wac
->id
[0]);
1893 wacom_wac
->tool
[0] = BTN_TOOL_PEN
;
1896 /* keep pen state for touch events */
1897 wacom_wac
->shared
->stylus_in_proximity
= range
;
1899 if (!delay_pen_events(wacom_wac
) && wacom_wac
->tool
[0]) {
1900 int id
= wacom_wac
->id
[0];
1903 * Non-USI EMR tools should have their IDs mangled to
1904 * match the legacy behavior of wacom_intuos_general
1906 if (wacom_wac
->serial
[0] >> 52 == 1)
1907 id
= wacom_intuos_id_mangle(id
);
1910 * To ensure compatibility with xf86-input-wacom, we should
1911 * report the BTN_TOOL_* event prior to the ABS_MISC or
1912 * MSC_SERIAL events.
1914 input_report_key(input
, BTN_TOUCH
,
1915 wacom_wac
->hid_data
.tipswitch
);
1916 input_report_key(input
, wacom_wac
->tool
[0], prox
);
1917 if (wacom_wac
->serial
[0]) {
1918 input_event(input
, EV_MSC
, MSC_SERIAL
, wacom_wac
->serial
[0]);
1919 input_report_abs(input
, ABS_MISC
, id
);
1922 wacom_wac
->hid_data
.tipswitch
= false;
1928 wacom_wac
->tool
[0] = 0;
1929 wacom_wac
->id
[0] = 0;
1933 static void wacom_wac_finger_usage_mapping(struct hid_device
*hdev
,
1934 struct hid_field
*field
, struct hid_usage
*usage
)
1936 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1937 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1938 struct input_dev
*input
= wacom_wac
->touch_input
;
1939 unsigned touch_max
= wacom_wac
->features
.touch_max
;
1940 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
1942 switch (equivalent_usage
) {
1945 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_X
, 4);
1947 wacom_map_usage(input
, usage
, field
, EV_ABS
,
1948 ABS_MT_POSITION_X
, 4);
1952 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_Y
, 4);
1954 wacom_map_usage(input
, usage
, field
, EV_ABS
,
1955 ABS_MT_POSITION_Y
, 4);
1959 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_MT_TOUCH_MAJOR
, 0);
1960 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_MT_TOUCH_MINOR
, 0);
1961 input_set_abs_params(input
, ABS_MT_ORIENTATION
, 0, 1, 0, 0);
1963 case HID_DG_TIPSWITCH
:
1964 wacom_map_usage(input
, usage
, field
, EV_KEY
, BTN_TOUCH
, 0);
1966 case HID_DG_CONTACTCOUNT
:
1967 wacom_wac
->hid_data
.cc_report
= field
->report
->id
;
1968 wacom_wac
->hid_data
.cc_index
= field
->index
;
1969 wacom_wac
->hid_data
.cc_value_index
= usage
->usage_index
;
1974 static void wacom_wac_finger_slot(struct wacom_wac
*wacom_wac
,
1975 struct input_dev
*input
)
1977 struct hid_data
*hid_data
= &wacom_wac
->hid_data
;
1978 bool mt
= wacom_wac
->features
.touch_max
> 1;
1979 bool prox
= hid_data
->tipswitch
&&
1980 report_touch_events(wacom_wac
);
1982 wacom_wac
->hid_data
.num_received
++;
1983 if (wacom_wac
->hid_data
.num_received
> wacom_wac
->hid_data
.num_expected
)
1989 slot
= input_mt_get_slot_by_key(input
, hid_data
->id
);
1990 input_mt_slot(input
, slot
);
1991 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, prox
);
1994 input_report_key(input
, BTN_TOUCH
, prox
);
1998 input_report_abs(input
, mt
? ABS_MT_POSITION_X
: ABS_X
,
2000 input_report_abs(input
, mt
? ABS_MT_POSITION_Y
: ABS_Y
,
2003 if (test_bit(ABS_MT_TOUCH_MAJOR
, input
->absbit
)) {
2004 input_report_abs(input
, ABS_MT_TOUCH_MAJOR
, max(hid_data
->width
, hid_data
->height
));
2005 input_report_abs(input
, ABS_MT_TOUCH_MINOR
, min(hid_data
->width
, hid_data
->height
));
2006 if (hid_data
->width
!= hid_data
->height
)
2007 input_report_abs(input
, ABS_MT_ORIENTATION
, hid_data
->width
<= hid_data
->height
? 0 : 1);
2012 static void wacom_wac_finger_event(struct hid_device
*hdev
,
2013 struct hid_field
*field
, struct hid_usage
*usage
, __s32 value
)
2015 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2016 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2017 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
2019 switch (equivalent_usage
) {
2021 wacom_wac
->hid_data
.x
= value
;
2024 wacom_wac
->hid_data
.y
= value
;
2027 wacom_wac
->hid_data
.width
= value
;
2030 wacom_wac
->hid_data
.height
= value
;
2032 case HID_DG_CONTACTID
:
2033 wacom_wac
->hid_data
.id
= value
;
2035 case HID_DG_TIPSWITCH
:
2036 wacom_wac
->hid_data
.tipswitch
= value
;
2041 if (usage
->usage_index
+ 1 == field
->report_count
) {
2042 if (equivalent_usage
== wacom_wac
->hid_data
.last_slot_field
)
2043 wacom_wac_finger_slot(wacom_wac
, wacom_wac
->touch_input
);
2047 static void wacom_wac_finger_pre_report(struct hid_device
*hdev
,
2048 struct hid_report
*report
)
2050 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2051 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2052 struct hid_data
* hid_data
= &wacom_wac
->hid_data
;
2055 for (i
= 0; i
< report
->maxfield
; i
++) {
2056 struct hid_field
*field
= report
->field
[i
];
2059 for (j
= 0; j
< field
->maxusage
; j
++) {
2060 struct hid_usage
*usage
= &field
->usage
[j
];
2062 switch (usage
->hid
) {
2067 case HID_DG_CONTACTID
:
2068 case HID_DG_INRANGE
:
2070 case HID_DG_TIPSWITCH
:
2071 hid_data
->last_slot_field
= usage
->hid
;
2073 case HID_DG_CONTACTCOUNT
:
2074 hid_data
->cc_report
= report
->id
;
2075 hid_data
->cc_index
= i
;
2076 hid_data
->cc_value_index
= j
;
2082 if (hid_data
->cc_report
!= 0 &&
2083 hid_data
->cc_index
>= 0) {
2084 struct hid_field
*field
= report
->field
[hid_data
->cc_index
];
2085 int value
= field
->value
[hid_data
->cc_value_index
];
2087 hid_data
->num_expected
= value
;
2090 hid_data
->num_expected
= wacom_wac
->features
.touch_max
;
2094 static void wacom_wac_finger_report(struct hid_device
*hdev
,
2095 struct hid_report
*report
)
2097 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2098 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2099 struct input_dev
*input
= wacom_wac
->touch_input
;
2100 unsigned touch_max
= wacom_wac
->features
.touch_max
;
2102 /* If more packets of data are expected, give us a chance to
2103 * process them rather than immediately syncing a partial
2106 if (wacom_wac
->hid_data
.num_received
< wacom_wac
->hid_data
.num_expected
)
2110 input_mt_sync_frame(input
);
2113 wacom_wac
->hid_data
.num_received
= 0;
2115 /* keep touch state for pen event */
2116 wacom_wac
->shared
->touch_down
= wacom_wac_finger_count_touches(wacom_wac
);
2119 void wacom_wac_usage_mapping(struct hid_device
*hdev
,
2120 struct hid_field
*field
, struct hid_usage
*usage
)
2122 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2123 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2124 struct wacom_features
*features
= &wacom_wac
->features
;
2126 /* currently, only direct devices have proper hid report descriptors */
2127 features
->device_type
|= WACOM_DEVICETYPE_DIRECT
;
2129 if (WACOM_PAD_FIELD(field
))
2130 wacom_wac_pad_usage_mapping(hdev
, field
, usage
);
2131 else if (WACOM_PEN_FIELD(field
))
2132 wacom_wac_pen_usage_mapping(hdev
, field
, usage
);
2133 else if (WACOM_FINGER_FIELD(field
))
2134 wacom_wac_finger_usage_mapping(hdev
, field
, usage
);
2137 void wacom_wac_event(struct hid_device
*hdev
, struct hid_field
*field
,
2138 struct hid_usage
*usage
, __s32 value
)
2140 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2142 if (wacom
->wacom_wac
.features
.type
!= HID_GENERIC
)
2145 if (WACOM_PAD_FIELD(field
)) {
2146 wacom_wac_pad_battery_event(hdev
, field
, usage
, value
);
2147 if (wacom
->wacom_wac
.pad_input
)
2148 wacom_wac_pad_event(hdev
, field
, usage
, value
);
2149 } else if (WACOM_PEN_FIELD(field
) && wacom
->wacom_wac
.pen_input
)
2150 wacom_wac_pen_event(hdev
, field
, usage
, value
);
2151 else if (WACOM_FINGER_FIELD(field
) && wacom
->wacom_wac
.touch_input
)
2152 wacom_wac_finger_event(hdev
, field
, usage
, value
);
2155 static void wacom_report_events(struct hid_device
*hdev
, struct hid_report
*report
)
2159 for (r
= 0; r
< report
->maxfield
; r
++) {
2160 struct hid_field
*field
;
2163 field
= report
->field
[r
];
2164 count
= field
->report_count
;
2166 if (!(HID_MAIN_ITEM_VARIABLE
& field
->flags
))
2169 for (n
= 0; n
< count
; n
++)
2170 wacom_wac_event(hdev
, field
, &field
->usage
[n
], field
->value
[n
]);
2174 void wacom_wac_report(struct hid_device
*hdev
, struct hid_report
*report
)
2176 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2177 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2178 struct hid_field
*field
= report
->field
[0];
2180 if (wacom_wac
->features
.type
!= HID_GENERIC
)
2183 if (WACOM_PAD_FIELD(field
) && wacom
->wacom_wac
.pad_input
)
2184 wacom_wac_pad_pre_report(hdev
, report
);
2185 else if (WACOM_PEN_FIELD(field
) && wacom
->wacom_wac
.pen_input
)
2186 wacom_wac_pen_pre_report(hdev
, report
);
2187 else if (WACOM_FINGER_FIELD(field
) && wacom
->wacom_wac
.touch_input
)
2188 wacom_wac_finger_pre_report(hdev
, report
);
2190 wacom_report_events(hdev
, report
);
2193 * Non-input reports may be sent prior to the device being
2194 * completely initialized. Since only their events need
2195 * to be processed, exit after 'wacom_report_events' has
2196 * been called to prevent potential crashes in the report-
2197 * processing functions.
2199 if (report
->type
!= HID_INPUT_REPORT
)
2202 if (WACOM_PAD_FIELD(field
)) {
2203 wacom_wac_pad_battery_report(hdev
, report
);
2204 if (wacom
->wacom_wac
.pad_input
)
2205 wacom_wac_pad_report(hdev
, report
);
2206 } else if (WACOM_PEN_FIELD(field
) && wacom
->wacom_wac
.pen_input
)
2207 wacom_wac_pen_report(hdev
, report
);
2208 else if (WACOM_FINGER_FIELD(field
) && wacom
->wacom_wac
.touch_input
)
2209 wacom_wac_finger_report(hdev
, report
);
2212 static int wacom_bpt_touch(struct wacom_wac
*wacom
)
2214 struct wacom_features
*features
= &wacom
->features
;
2215 struct input_dev
*input
= wacom
->touch_input
;
2216 struct input_dev
*pad_input
= wacom
->pad_input
;
2217 unsigned char *data
= wacom
->data
;
2220 if (data
[0] != 0x02)
2223 for (i
= 0; i
< 2; i
++) {
2224 int offset
= (data
[1] & 0x80) ? (8 * i
) : (9 * i
);
2225 bool touch
= report_touch_events(wacom
)
2226 && (data
[offset
+ 3] & 0x80);
2228 input_mt_slot(input
, i
);
2229 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, touch
);
2231 int x
= get_unaligned_be16(&data
[offset
+ 3]) & 0x7ff;
2232 int y
= get_unaligned_be16(&data
[offset
+ 5]) & 0x7ff;
2233 if (features
->quirks
& WACOM_QUIRK_BBTOUCH_LOWRES
) {
2237 input_report_abs(input
, ABS_MT_POSITION_X
, x
);
2238 input_report_abs(input
, ABS_MT_POSITION_Y
, y
);
2242 input_mt_sync_frame(input
);
2244 input_report_key(pad_input
, BTN_LEFT
, (data
[1] & 0x08) != 0);
2245 input_report_key(pad_input
, BTN_FORWARD
, (data
[1] & 0x04) != 0);
2246 input_report_key(pad_input
, BTN_BACK
, (data
[1] & 0x02) != 0);
2247 input_report_key(pad_input
, BTN_RIGHT
, (data
[1] & 0x01) != 0);
2248 wacom
->shared
->touch_down
= wacom_wac_finger_count_touches(wacom
);
2253 static void wacom_bpt3_touch_msg(struct wacom_wac
*wacom
, unsigned char *data
)
2255 struct wacom_features
*features
= &wacom
->features
;
2256 struct input_dev
*input
= wacom
->touch_input
;
2257 bool touch
= data
[1] & 0x80;
2258 int slot
= input_mt_get_slot_by_key(input
, data
[0]);
2263 touch
= touch
&& report_touch_events(wacom
);
2265 input_mt_slot(input
, slot
);
2266 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, touch
);
2269 int x
= (data
[2] << 4) | (data
[4] >> 4);
2270 int y
= (data
[3] << 4) | (data
[4] & 0x0f);
2273 if (features
->type
>= INTUOSPS
&& features
->type
<= INTUOSHT2
) {
2274 width
= data
[5] * 100;
2275 height
= data
[6] * 100;
2278 * "a" is a scaled-down area which we assume is
2279 * roughly circular and which can be described as:
2283 int x_res
= input_abs_get_res(input
, ABS_MT_POSITION_X
);
2284 int y_res
= input_abs_get_res(input
, ABS_MT_POSITION_Y
);
2285 width
= 2 * int_sqrt(a
* WACOM_CONTACT_AREA_SCALE
);
2286 height
= width
* y_res
/ x_res
;
2289 input_report_abs(input
, ABS_MT_POSITION_X
, x
);
2290 input_report_abs(input
, ABS_MT_POSITION_Y
, y
);
2291 input_report_abs(input
, ABS_MT_TOUCH_MAJOR
, width
);
2292 input_report_abs(input
, ABS_MT_TOUCH_MINOR
, height
);
2296 static void wacom_bpt3_button_msg(struct wacom_wac
*wacom
, unsigned char *data
)
2298 struct input_dev
*input
= wacom
->pad_input
;
2299 struct wacom_features
*features
= &wacom
->features
;
2301 if (features
->type
== INTUOSHT
|| features
->type
== INTUOSHT2
) {
2302 input_report_key(input
, BTN_LEFT
, (data
[1] & 0x02) != 0);
2303 input_report_key(input
, BTN_BACK
, (data
[1] & 0x08) != 0);
2305 input_report_key(input
, BTN_BACK
, (data
[1] & 0x02) != 0);
2306 input_report_key(input
, BTN_LEFT
, (data
[1] & 0x08) != 0);
2308 input_report_key(input
, BTN_FORWARD
, (data
[1] & 0x04) != 0);
2309 input_report_key(input
, BTN_RIGHT
, (data
[1] & 0x01) != 0);
2312 static int wacom_bpt3_touch(struct wacom_wac
*wacom
)
2314 unsigned char *data
= wacom
->data
;
2315 int count
= data
[1] & 0x07;
2316 int touch_changed
= 0, i
;
2318 if (data
[0] != 0x02)
2321 /* data has up to 7 fixed sized 8-byte messages starting at data[2] */
2322 for (i
= 0; i
< count
; i
++) {
2323 int offset
= (8 * i
) + 2;
2324 int msg_id
= data
[offset
];
2326 if (msg_id
>= 2 && msg_id
<= 17) {
2327 wacom_bpt3_touch_msg(wacom
, data
+ offset
);
2329 } else if (msg_id
== 128)
2330 wacom_bpt3_button_msg(wacom
, data
+ offset
);
2334 /* only update touch if we actually have a touchpad and touch data changed */
2335 if (wacom
->touch_input
&& touch_changed
) {
2336 input_mt_sync_frame(wacom
->touch_input
);
2337 wacom
->shared
->touch_down
= wacom_wac_finger_count_touches(wacom
);
2343 static int wacom_bpt_pen(struct wacom_wac
*wacom
)
2345 struct wacom_features
*features
= &wacom
->features
;
2346 struct input_dev
*input
= wacom
->pen_input
;
2347 unsigned char *data
= wacom
->data
;
2348 int prox
= 0, x
= 0, y
= 0, p
= 0, d
= 0, pen
= 0, btn1
= 0, btn2
= 0;
2350 if (data
[0] != WACOM_REPORT_PENABLED
)
2353 prox
= (data
[1] & 0x20) == 0x20;
2356 * All reports shared between PEN and RUBBER tool must be
2357 * forced to a known starting value (zero) when transitioning to
2360 * If not reset then, to userspace, it will look like lost events
2361 * if new tool comes in-prox with same values as previous tool sent.
2363 * Hardware does report zero in most out-of-prox cases but not all.
2365 if (!wacom
->shared
->stylus_in_proximity
) {
2366 if (data
[1] & 0x08) {
2367 wacom
->tool
[0] = BTN_TOOL_RUBBER
;
2368 wacom
->id
[0] = ERASER_DEVICE_ID
;
2370 wacom
->tool
[0] = BTN_TOOL_PEN
;
2371 wacom
->id
[0] = STYLUS_DEVICE_ID
;
2375 wacom
->shared
->stylus_in_proximity
= prox
;
2376 if (delay_pen_events(wacom
))
2380 x
= le16_to_cpup((__le16
*)&data
[2]);
2381 y
= le16_to_cpup((__le16
*)&data
[4]);
2382 p
= le16_to_cpup((__le16
*)&data
[6]);
2384 * Convert distance from out prox to distance from tablet.
2385 * distance will be greater than distance_max once
2386 * touching and applying pressure; do not report negative
2389 if (data
[8] <= features
->distance_max
)
2390 d
= features
->distance_max
- data
[8];
2392 pen
= data
[1] & 0x01;
2393 btn1
= data
[1] & 0x02;
2394 btn2
= data
[1] & 0x04;
2399 input_report_key(input
, BTN_TOUCH
, pen
);
2400 input_report_key(input
, BTN_STYLUS
, btn1
);
2401 input_report_key(input
, BTN_STYLUS2
, btn2
);
2403 input_report_abs(input
, ABS_X
, x
);
2404 input_report_abs(input
, ABS_Y
, y
);
2405 input_report_abs(input
, ABS_PRESSURE
, p
);
2406 input_report_abs(input
, ABS_DISTANCE
, d
);
2408 input_report_key(input
, wacom
->tool
[0], prox
); /* PEN or RUBBER */
2409 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]); /* TOOL ID */
2414 static int wacom_bpt_irq(struct wacom_wac
*wacom
, size_t len
)
2416 struct wacom_features
*features
= &wacom
->features
;
2418 if ((features
->type
== INTUOSHT2
) &&
2419 (features
->device_type
& WACOM_DEVICETYPE_PEN
))
2420 return wacom_intuos_irq(wacom
);
2421 else if (len
== WACOM_PKGLEN_BBTOUCH
)
2422 return wacom_bpt_touch(wacom
);
2423 else if (len
== WACOM_PKGLEN_BBTOUCH3
)
2424 return wacom_bpt3_touch(wacom
);
2425 else if (len
== WACOM_PKGLEN_BBFUN
|| len
== WACOM_PKGLEN_BBPEN
)
2426 return wacom_bpt_pen(wacom
);
2431 static void wacom_bamboo_pad_pen_event(struct wacom_wac
*wacom
,
2432 unsigned char *data
)
2434 unsigned char prefix
;
2437 * We need to reroute the event from the debug interface to the
2439 * We need to add the report ID to the actual pen report, so we
2440 * temporary overwrite the first byte to prevent having to kzalloc/kfree
2441 * and memcpy the report.
2444 data
[0] = WACOM_REPORT_BPAD_PEN
;
2447 * actually reroute the event.
2448 * No need to check if wacom->shared->pen is valid, hid_input_report()
2449 * will check for us.
2451 hid_input_report(wacom
->shared
->pen
, HID_INPUT_REPORT
, data
,
2452 WACOM_PKGLEN_PENABLED
, 1);
2457 static int wacom_bamboo_pad_touch_event(struct wacom_wac
*wacom
,
2458 unsigned char *data
)
2460 struct input_dev
*input
= wacom
->touch_input
;
2461 unsigned char *finger_data
, prefix
;
2468 for (id
= 0; id
< wacom
->features
.touch_max
; id
++) {
2469 valid
= !!(prefix
& BIT(id
)) &&
2470 report_touch_events(wacom
);
2472 input_mt_slot(input
, id
);
2473 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, valid
);
2478 finger_data
= data
+ 1 + id
* 3;
2479 x
= finger_data
[0] | ((finger_data
[1] & 0x0f) << 8);
2480 y
= (finger_data
[2] << 4) | (finger_data
[1] >> 4);
2482 input_report_abs(input
, ABS_MT_POSITION_X
, x
);
2483 input_report_abs(input
, ABS_MT_POSITION_Y
, y
);
2486 input_mt_sync_frame(input
);
2488 input_report_key(input
, BTN_LEFT
, prefix
& 0x40);
2489 input_report_key(input
, BTN_RIGHT
, prefix
& 0x80);
2491 /* keep touch state for pen event */
2492 wacom
->shared
->touch_down
= !!prefix
&& report_touch_events(wacom
);
2497 static int wacom_bamboo_pad_irq(struct wacom_wac
*wacom
, size_t len
)
2499 unsigned char *data
= wacom
->data
;
2501 if (!((len
== WACOM_PKGLEN_BPAD_TOUCH
) ||
2502 (len
== WACOM_PKGLEN_BPAD_TOUCH_USB
)) ||
2503 (data
[0] != WACOM_REPORT_BPAD_TOUCH
))
2507 wacom_bamboo_pad_pen_event(wacom
, &data
[1]);
2510 return wacom_bamboo_pad_touch_event(wacom
, &data
[9]);
2515 static int wacom_wireless_irq(struct wacom_wac
*wacom
, size_t len
)
2517 unsigned char *data
= wacom
->data
;
2520 if (len
!= WACOM_PKGLEN_WIRELESS
|| data
[0] != WACOM_REPORT_WL
)
2523 connected
= data
[1] & 0x01;
2525 int pid
, battery
, charging
;
2527 if ((wacom
->shared
->type
== INTUOSHT
||
2528 wacom
->shared
->type
== INTUOSHT2
) &&
2529 wacom
->shared
->touch_input
&&
2530 wacom
->shared
->touch_max
) {
2531 input_report_switch(wacom
->shared
->touch_input
,
2532 SW_MUTE_DEVICE
, data
[5] & 0x40);
2533 input_sync(wacom
->shared
->touch_input
);
2536 pid
= get_unaligned_be16(&data
[6]);
2537 battery
= (data
[5] & 0x3f) * 100 / 31;
2538 charging
= !!(data
[5] & 0x80);
2539 if (wacom
->pid
!= pid
) {
2541 wacom_schedule_work(wacom
, WACOM_WORKER_WIRELESS
);
2544 wacom_notify_battery(wacom
, battery
, charging
, 1, 0);
2546 } else if (wacom
->pid
!= 0) {
2547 /* disconnected while previously connected */
2549 wacom_schedule_work(wacom
, WACOM_WORKER_WIRELESS
);
2550 wacom_notify_battery(wacom
, 0, 0, 0, 0);
2556 static int wacom_status_irq(struct wacom_wac
*wacom_wac
, size_t len
)
2558 struct wacom
*wacom
= container_of(wacom_wac
, struct wacom
, wacom_wac
);
2559 struct wacom_features
*features
= &wacom_wac
->features
;
2560 unsigned char *data
= wacom_wac
->data
;
2562 if (data
[0] != WACOM_REPORT_USB
)
2565 if ((features
->type
== INTUOSHT
||
2566 features
->type
== INTUOSHT2
) &&
2567 wacom_wac
->shared
->touch_input
&&
2568 features
->touch_max
) {
2569 input_report_switch(wacom_wac
->shared
->touch_input
,
2570 SW_MUTE_DEVICE
, data
[8] & 0x40);
2571 input_sync(wacom_wac
->shared
->touch_input
);
2574 if (data
[9] & 0x02) { /* wireless module is attached */
2575 int battery
= (data
[8] & 0x3f) * 100 / 31;
2576 bool charging
= !!(data
[8] & 0x80);
2578 wacom_notify_battery(wacom_wac
, battery
, charging
,
2579 battery
|| charging
, 1);
2581 if (!wacom
->battery
.battery
&&
2582 !(features
->quirks
& WACOM_QUIRK_BATTERY
)) {
2583 features
->quirks
|= WACOM_QUIRK_BATTERY
;
2584 wacom_schedule_work(wacom_wac
, WACOM_WORKER_BATTERY
);
2587 else if ((features
->quirks
& WACOM_QUIRK_BATTERY
) &&
2588 wacom
->battery
.battery
) {
2589 features
->quirks
&= ~WACOM_QUIRK_BATTERY
;
2590 wacom_schedule_work(wacom_wac
, WACOM_WORKER_BATTERY
);
2591 wacom_notify_battery(wacom_wac
, 0, 0, 0, 0);
2596 void wacom_wac_irq(struct wacom_wac
*wacom_wac
, size_t len
)
2600 switch (wacom_wac
->features
.type
) {
2602 sync
= wacom_penpartner_irq(wacom_wac
);
2606 sync
= wacom_pl_irq(wacom_wac
);
2613 sync
= wacom_graphire_irq(wacom_wac
);
2617 sync
= wacom_ptu_irq(wacom_wac
);
2621 sync
= wacom_dtu_irq(wacom_wac
);
2626 sync
= wacom_dtus_irq(wacom_wac
);
2645 case CINTIQ_COMPANION_2
:
2646 sync
= wacom_intuos_irq(wacom_wac
);
2650 sync
= wacom_intuos_bt_irq(wacom_wac
, len
);
2655 sync
= wacom_24hdt_irq(wacom_wac
);
2664 if (len
== WACOM_PKGLEN_BBTOUCH3
)
2665 sync
= wacom_bpt3_touch(wacom_wac
);
2666 else if (wacom_wac
->data
[0] == WACOM_REPORT_USB
)
2667 sync
= wacom_status_irq(wacom_wac
, len
);
2669 sync
= wacom_intuos_irq(wacom_wac
);
2678 sync
= wacom_tpc_irq(wacom_wac
, len
);
2686 if (wacom_wac
->data
[0] == WACOM_REPORT_USB
)
2687 sync
= wacom_status_irq(wacom_wac
, len
);
2689 sync
= wacom_bpt_irq(wacom_wac
, len
);
2693 sync
= wacom_bamboo_pad_irq(wacom_wac
, len
);
2697 sync
= wacom_wireless_irq(wacom_wac
, len
);
2702 if (wacom_wac
->data
[0] == WACOM_REPORT_DEVICE_LIST
)
2703 wacom_remote_status_irq(wacom_wac
, len
);
2705 sync
= wacom_remote_irq(wacom_wac
, len
);
2714 if (wacom_wac
->pen_input
)
2715 input_sync(wacom_wac
->pen_input
);
2716 if (wacom_wac
->touch_input
)
2717 input_sync(wacom_wac
->touch_input
);
2718 if (wacom_wac
->pad_input
)
2719 input_sync(wacom_wac
->pad_input
);
2723 static void wacom_setup_basic_pro_pen(struct wacom_wac
*wacom_wac
)
2725 struct input_dev
*input_dev
= wacom_wac
->pen_input
;
2727 input_set_capability(input_dev
, EV_MSC
, MSC_SERIAL
);
2729 __set_bit(BTN_TOOL_PEN
, input_dev
->keybit
);
2730 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
2731 __set_bit(BTN_STYLUS2
, input_dev
->keybit
);
2733 input_set_abs_params(input_dev
, ABS_DISTANCE
,
2734 0, wacom_wac
->features
.distance_max
, wacom_wac
->features
.distance_fuzz
, 0);
2737 static void wacom_setup_cintiq(struct wacom_wac
*wacom_wac
)
2739 struct input_dev
*input_dev
= wacom_wac
->pen_input
;
2740 struct wacom_features
*features
= &wacom_wac
->features
;
2742 wacom_setup_basic_pro_pen(wacom_wac
);
2744 __set_bit(BTN_TOOL_RUBBER
, input_dev
->keybit
);
2745 __set_bit(BTN_TOOL_BRUSH
, input_dev
->keybit
);
2746 __set_bit(BTN_TOOL_PENCIL
, input_dev
->keybit
);
2747 __set_bit(BTN_TOOL_AIRBRUSH
, input_dev
->keybit
);
2749 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 1023, 0, 0);
2750 input_set_abs_params(input_dev
, ABS_TILT_X
, -64, 63, features
->tilt_fuzz
, 0);
2751 input_abs_set_res(input_dev
, ABS_TILT_X
, 57);
2752 input_set_abs_params(input_dev
, ABS_TILT_Y
, -64, 63, features
->tilt_fuzz
, 0);
2753 input_abs_set_res(input_dev
, ABS_TILT_Y
, 57);
2756 static void wacom_setup_intuos(struct wacom_wac
*wacom_wac
)
2758 struct input_dev
*input_dev
= wacom_wac
->pen_input
;
2760 input_set_capability(input_dev
, EV_REL
, REL_WHEEL
);
2762 wacom_setup_cintiq(wacom_wac
);
2764 __set_bit(BTN_LEFT
, input_dev
->keybit
);
2765 __set_bit(BTN_RIGHT
, input_dev
->keybit
);
2766 __set_bit(BTN_MIDDLE
, input_dev
->keybit
);
2767 __set_bit(BTN_SIDE
, input_dev
->keybit
);
2768 __set_bit(BTN_EXTRA
, input_dev
->keybit
);
2769 __set_bit(BTN_TOOL_MOUSE
, input_dev
->keybit
);
2770 __set_bit(BTN_TOOL_LENS
, input_dev
->keybit
);
2772 input_set_abs_params(input_dev
, ABS_RZ
, -900, 899, 0, 0);
2773 input_abs_set_res(input_dev
, ABS_RZ
, 287);
2774 input_set_abs_params(input_dev
, ABS_THROTTLE
, -1023, 1023, 0, 0);
2777 void wacom_setup_device_quirks(struct wacom
*wacom
)
2779 struct wacom_features
*features
= &wacom
->wacom_wac
.features
;
2781 /* The pen and pad share the same interface on most devices */
2782 if (features
->numbered_buttons
> 0)
2783 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
2784 if (features
->type
== GRAPHIRE_BT
|| features
->type
== WACOM_G4
||
2785 features
->type
== DTUS
||
2786 (features
->type
>= INTUOS3S
&& features
->type
<= WACOM_MO
)) {
2787 if (features
->device_type
& WACOM_DEVICETYPE_PEN
)
2788 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
2791 /* touch device found but size is not defined. use default */
2792 if (features
->device_type
& WACOM_DEVICETYPE_TOUCH
&& !features
->x_max
) {
2793 features
->x_max
= 1023;
2794 features
->y_max
= 1023;
2798 * Intuos5/Pro and Bamboo 3rd gen have no useful data about its
2799 * touch interface in its HID descriptor. If this is the touch
2800 * interface (PacketSize of WACOM_PKGLEN_BBTOUCH3), override the
2803 if ((features
->type
>= INTUOS5S
&& features
->type
<= INTUOSPL
) ||
2804 (features
->type
>= INTUOSHT
&& features
->type
<= BAMBOO_PT
)) {
2805 if (features
->pktlen
== WACOM_PKGLEN_BBTOUCH3
) {
2806 if (features
->touch_max
)
2807 features
->device_type
|= WACOM_DEVICETYPE_TOUCH
;
2808 if (features
->type
>= INTUOSHT
&& features
->type
<= BAMBOO_PT
)
2809 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
2811 features
->x_max
= 4096;
2812 features
->y_max
= 4096;
2814 else if (features
->pktlen
== WACOM_PKGLEN_BBTOUCH
) {
2815 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
2820 * Hack for the Bamboo One:
2821 * the device presents a PAD/Touch interface as most Bamboos and even
2822 * sends ghosts PAD data on it. However, later, we must disable this
2823 * ghost interface, and we can not detect it unless we set it here
2824 * to WACOM_DEVICETYPE_PAD or WACOM_DEVICETYPE_TOUCH.
2826 if (features
->type
== BAMBOO_PEN
&&
2827 features
->pktlen
== WACOM_PKGLEN_BBTOUCH3
)
2828 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
2831 * Raw Wacom-mode pen and touch events both come from interface
2832 * 0, whose HID descriptor has an application usage of 0xFF0D
2833 * (i.e., WACOM_HID_WD_DIGITIZER). We route pen packets back
2834 * out through the HID_GENERIC device created for interface 1,
2835 * so rewrite this one to be of type WACOM_DEVICETYPE_TOUCH.
2837 if (features
->type
== BAMBOO_PAD
)
2838 features
->device_type
= WACOM_DEVICETYPE_TOUCH
;
2840 if (features
->type
== REMOTE
)
2841 features
->device_type
= WACOM_DEVICETYPE_PAD
;
2843 switch (features
->type
) {
2854 case CINTIQ_COMPANION_2
:
2866 features
->device_type
|= WACOM_DEVICETYPE_DIRECT
;
2870 if (wacom
->hdev
->bus
== BUS_BLUETOOTH
)
2871 features
->quirks
|= WACOM_QUIRK_BATTERY
;
2873 /* quirk for bamboo touch with 2 low res touches */
2874 if ((features
->type
== BAMBOO_PT
|| features
->type
== BAMBOO_TOUCH
) &&
2875 features
->pktlen
== WACOM_PKGLEN_BBTOUCH
) {
2876 features
->x_max
<<= 5;
2877 features
->y_max
<<= 5;
2878 features
->x_fuzz
<<= 5;
2879 features
->y_fuzz
<<= 5;
2880 features
->quirks
|= WACOM_QUIRK_BBTOUCH_LOWRES
;
2883 if (features
->type
== WIRELESS
) {
2884 if (features
->device_type
== WACOM_DEVICETYPE_WL_MONITOR
) {
2885 features
->quirks
|= WACOM_QUIRK_BATTERY
;
2889 if (features
->type
== REMOTE
)
2890 features
->device_type
|= WACOM_DEVICETYPE_WL_MONITOR
;
2893 int wacom_setup_pen_input_capabilities(struct input_dev
*input_dev
,
2894 struct wacom_wac
*wacom_wac
)
2896 struct wacom_features
*features
= &wacom_wac
->features
;
2898 input_dev
->evbit
[0] |= BIT_MASK(EV_KEY
) | BIT_MASK(EV_ABS
);
2900 if (!(features
->device_type
& WACOM_DEVICETYPE_PEN
))
2903 if (features
->device_type
& WACOM_DEVICETYPE_DIRECT
)
2904 __set_bit(INPUT_PROP_DIRECT
, input_dev
->propbit
);
2906 __set_bit(INPUT_PROP_POINTER
, input_dev
->propbit
);
2908 if (features
->type
== HID_GENERIC
)
2909 /* setup has already been done */
2912 __set_bit(BTN_TOUCH
, input_dev
->keybit
);
2913 __set_bit(ABS_MISC
, input_dev
->absbit
);
2915 input_set_abs_params(input_dev
, ABS_X
, 0 + features
->offset_left
,
2916 features
->x_max
- features
->offset_right
,
2917 features
->x_fuzz
, 0);
2918 input_set_abs_params(input_dev
, ABS_Y
, 0 + features
->offset_top
,
2919 features
->y_max
- features
->offset_bottom
,
2920 features
->y_fuzz
, 0);
2921 input_set_abs_params(input_dev
, ABS_PRESSURE
, 0,
2922 features
->pressure_max
, features
->pressure_fuzz
, 0);
2924 /* penabled devices have fixed resolution for each model */
2925 input_abs_set_res(input_dev
, ABS_X
, features
->x_resolution
);
2926 input_abs_set_res(input_dev
, ABS_Y
, features
->y_resolution
);
2928 switch (features
->type
) {
2930 __clear_bit(ABS_MISC
, input_dev
->absbit
);
2934 input_set_abs_params(input_dev
, ABS_DISTANCE
, 0,
2935 features
->distance_max
,
2936 features
->distance_fuzz
, 0);
2940 input_set_capability(input_dev
, EV_REL
, REL_WHEEL
);
2942 __set_bit(BTN_LEFT
, input_dev
->keybit
);
2943 __set_bit(BTN_RIGHT
, input_dev
->keybit
);
2944 __set_bit(BTN_MIDDLE
, input_dev
->keybit
);
2946 __set_bit(BTN_TOOL_RUBBER
, input_dev
->keybit
);
2947 __set_bit(BTN_TOOL_PEN
, input_dev
->keybit
);
2948 __set_bit(BTN_TOOL_MOUSE
, input_dev
->keybit
);
2949 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
2950 __set_bit(BTN_STYLUS2
, input_dev
->keybit
);
2962 case CINTIQ_COMPANION_2
:
2963 input_set_abs_params(input_dev
, ABS_Z
, -900, 899, 0, 0);
2964 input_abs_set_res(input_dev
, ABS_Z
, 287);
2965 wacom_setup_cintiq(wacom_wac
);
2975 input_set_abs_params(input_dev
, ABS_Z
, -900, 899, 0, 0);
2976 input_abs_set_res(input_dev
, ABS_Z
, 287);
2980 wacom_setup_intuos(wacom_wac
);
2989 input_set_abs_params(input_dev
, ABS_DISTANCE
, 0,
2990 features
->distance_max
,
2991 features
->distance_fuzz
, 0);
2993 input_set_abs_params(input_dev
, ABS_Z
, -900, 899, 0, 0);
2994 input_abs_set_res(input_dev
, ABS_Z
, 287);
2996 wacom_setup_intuos(wacom_wac
);
3007 __clear_bit(ABS_MISC
, input_dev
->absbit
);
3014 __set_bit(BTN_TOOL_PEN
, input_dev
->keybit
);
3015 __set_bit(BTN_TOOL_RUBBER
, input_dev
->keybit
);
3016 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
3017 __set_bit(BTN_STYLUS2
, input_dev
->keybit
);
3021 __set_bit(BTN_STYLUS2
, input_dev
->keybit
);
3025 __set_bit(BTN_TOOL_PEN
, input_dev
->keybit
);
3026 __set_bit(BTN_TOOL_RUBBER
, input_dev
->keybit
);
3027 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
3034 if (features
->type
== INTUOSHT2
) {
3035 wacom_setup_basic_pro_pen(wacom_wac
);
3037 __clear_bit(ABS_MISC
, input_dev
->absbit
);
3038 __set_bit(BTN_TOOL_PEN
, input_dev
->keybit
);
3039 __set_bit(BTN_TOOL_RUBBER
, input_dev
->keybit
);
3040 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
3041 __set_bit(BTN_STYLUS2
, input_dev
->keybit
);
3042 input_set_abs_params(input_dev
, ABS_DISTANCE
, 0,
3043 features
->distance_max
,
3044 features
->distance_fuzz
, 0);
3048 __clear_bit(ABS_MISC
, input_dev
->absbit
);
3054 int wacom_setup_touch_input_capabilities(struct input_dev
*input_dev
,
3055 struct wacom_wac
*wacom_wac
)
3057 struct wacom_features
*features
= &wacom_wac
->features
;
3059 input_dev
->evbit
[0] |= BIT_MASK(EV_KEY
) | BIT_MASK(EV_ABS
);
3061 if (!(features
->device_type
& WACOM_DEVICETYPE_TOUCH
))
3064 if (features
->device_type
& WACOM_DEVICETYPE_DIRECT
)
3065 __set_bit(INPUT_PROP_DIRECT
, input_dev
->propbit
);
3067 __set_bit(INPUT_PROP_POINTER
, input_dev
->propbit
);
3069 if (features
->type
== HID_GENERIC
)
3070 /* setup has already been done */
3073 __set_bit(BTN_TOUCH
, input_dev
->keybit
);
3075 if (features
->touch_max
== 1) {
3076 input_set_abs_params(input_dev
, ABS_X
, 0,
3077 features
->x_max
, features
->x_fuzz
, 0);
3078 input_set_abs_params(input_dev
, ABS_Y
, 0,
3079 features
->y_max
, features
->y_fuzz
, 0);
3080 input_abs_set_res(input_dev
, ABS_X
,
3081 features
->x_resolution
);
3082 input_abs_set_res(input_dev
, ABS_Y
,
3083 features
->y_resolution
);
3085 else if (features
->touch_max
> 1) {
3086 input_set_abs_params(input_dev
, ABS_MT_POSITION_X
, 0,
3087 features
->x_max
, features
->x_fuzz
, 0);
3088 input_set_abs_params(input_dev
, ABS_MT_POSITION_Y
, 0,
3089 features
->y_max
, features
->y_fuzz
, 0);
3090 input_abs_set_res(input_dev
, ABS_MT_POSITION_X
,
3091 features
->x_resolution
);
3092 input_abs_set_res(input_dev
, ABS_MT_POSITION_Y
,
3093 features
->y_resolution
);
3096 switch (features
->type
) {
3103 input_set_abs_params(input_dev
, ABS_MT_TOUCH_MAJOR
, 0, features
->x_max
, 0, 0);
3104 input_set_abs_params(input_dev
, ABS_MT_TOUCH_MINOR
, 0, features
->y_max
, 0, 0);
3105 input_mt_init_slots(input_dev
, features
->touch_max
, INPUT_MT_POINTER
);
3109 input_set_abs_params(input_dev
, ABS_MT_TOUCH_MAJOR
, 0, features
->x_max
, 0, 0);
3110 input_set_abs_params(input_dev
, ABS_MT_WIDTH_MAJOR
, 0, features
->x_max
, 0, 0);
3111 input_set_abs_params(input_dev
, ABS_MT_WIDTH_MINOR
, 0, features
->y_max
, 0, 0);
3112 input_set_abs_params(input_dev
, ABS_MT_ORIENTATION
, 0, 1, 0, 0);
3120 input_mt_init_slots(input_dev
, features
->touch_max
, INPUT_MT_DIRECT
);
3129 input_dev
->evbit
[0] |= BIT_MASK(EV_SW
);
3130 __set_bit(SW_MUTE_DEVICE
, input_dev
->swbit
);
3135 if (features
->pktlen
== WACOM_PKGLEN_BBTOUCH3
) {
3136 input_set_abs_params(input_dev
,
3138 0, features
->x_max
, 0, 0);
3139 input_set_abs_params(input_dev
,
3141 0, features
->y_max
, 0, 0);
3143 input_mt_init_slots(input_dev
, features
->touch_max
, INPUT_MT_POINTER
);
3147 input_mt_init_slots(input_dev
, features
->touch_max
,
3149 __set_bit(BTN_LEFT
, input_dev
->keybit
);
3150 __set_bit(BTN_RIGHT
, input_dev
->keybit
);
3156 static int wacom_numbered_button_to_key(int n
)
3161 return BTN_A
+ (n
-10);
3163 return BTN_BASE
+ (n
-16);
3168 static void wacom_setup_numbered_buttons(struct input_dev
*input_dev
,
3173 for (i
= 0; i
< button_count
; i
++) {
3174 int key
= wacom_numbered_button_to_key(i
);
3177 __set_bit(key
, input_dev
->keybit
);
3181 static void wacom_24hd_update_leds(struct wacom
*wacom
, int mask
, int group
)
3183 struct wacom_led
*led
;
3185 bool updated
= false;
3188 * 24HD has LED group 1 to the left and LED group 0 to the right.
3189 * So group 0 matches the second half of the buttons and thus the mask
3190 * needs to be shifted.
3195 for (i
= 0; i
< 3; i
++) {
3196 led
= wacom_led_find(wacom
, group
, i
);
3198 hid_err(wacom
->hdev
, "can't find LED %d in group %d\n",
3202 if (!updated
&& mask
& BIT(i
)) {
3204 led_trigger_event(&led
->trigger
, LED_FULL
);
3211 static bool wacom_is_led_toggled(struct wacom
*wacom
, int button_count
,
3212 int mask
, int group
)
3214 int button_per_group
;
3217 * 21UX2 has LED group 1 to the left and LED group 0
3218 * to the right. We need to reverse the group to match this
3219 * historical behavior.
3221 if (wacom
->wacom_wac
.features
.type
== WACOM_21UX2
)
3224 button_per_group
= button_count
/wacom
->led
.count
;
3226 return mask
& (1 << (group
* button_per_group
));
3229 static void wacom_update_led(struct wacom
*wacom
, int button_count
, int mask
,
3232 struct wacom_led
*led
, *next_led
;
3236 if (wacom
->wacom_wac
.features
.type
== WACOM_24HD
)
3237 return wacom_24hd_update_leds(wacom
, mask
, group
);
3239 pressed
= wacom_is_led_toggled(wacom
, button_count
, mask
, group
);
3240 cur
= wacom
->led
.groups
[group
].select
;
3242 led
= wacom_led_find(wacom
, group
, cur
);
3244 hid_err(wacom
->hdev
, "can't find current LED %d in group %d\n",
3254 if (led
->held
&& pressed
)
3257 next_led
= wacom_led_next(wacom
, led
);
3259 hid_err(wacom
->hdev
, "can't find next LED in group %d\n",
3263 if (next_led
== led
)
3266 next_led
->held
= true;
3267 led_trigger_event(&next_led
->trigger
,
3268 wacom_leds_brightness_get(next_led
));
3271 static void wacom_report_numbered_buttons(struct input_dev
*input_dev
,
3272 int button_count
, int mask
)
3274 struct wacom
*wacom
= input_get_drvdata(input_dev
);
3277 for (i
= 0; i
< wacom
->led
.count
; i
++)
3278 wacom_update_led(wacom
, button_count
, mask
, i
);
3280 for (i
= 0; i
< button_count
; i
++) {
3281 int key
= wacom_numbered_button_to_key(i
);
3284 input_report_key(input_dev
, key
, mask
& (1 << i
));
3288 int wacom_setup_pad_input_capabilities(struct input_dev
*input_dev
,
3289 struct wacom_wac
*wacom_wac
)
3291 struct wacom_features
*features
= &wacom_wac
->features
;
3293 if (!(features
->device_type
& WACOM_DEVICETYPE_PAD
))
3296 if (features
->type
== REMOTE
&& input_dev
== wacom_wac
->pad_input
)
3299 input_dev
->evbit
[0] |= BIT_MASK(EV_KEY
) | BIT_MASK(EV_ABS
);
3301 /* kept for making legacy xf86-input-wacom working with the wheels */
3302 __set_bit(ABS_MISC
, input_dev
->absbit
);
3304 /* kept for making legacy xf86-input-wacom accepting the pad */
3305 if (!(input_dev
->absinfo
&& (input_dev
->absinfo
[ABS_X
].minimum
||
3306 input_dev
->absinfo
[ABS_X
].maximum
)))
3307 input_set_abs_params(input_dev
, ABS_X
, 0, 1, 0, 0);
3308 if (!(input_dev
->absinfo
&& (input_dev
->absinfo
[ABS_Y
].minimum
||
3309 input_dev
->absinfo
[ABS_Y
].maximum
)))
3310 input_set_abs_params(input_dev
, ABS_Y
, 0, 1, 0, 0);
3312 /* kept for making udev and libwacom accepting the pad */
3313 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
3315 wacom_setup_numbered_buttons(input_dev
, features
->numbered_buttons
);
3317 switch (features
->type
) {
3320 case CINTIQ_COMPANION_2
:
3327 __set_bit(BTN_BACK
, input_dev
->keybit
);
3328 __set_bit(BTN_LEFT
, input_dev
->keybit
);
3329 __set_bit(BTN_FORWARD
, input_dev
->keybit
);
3330 __set_bit(BTN_RIGHT
, input_dev
->keybit
);
3331 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
3335 __set_bit(BTN_BACK
, input_dev
->keybit
);
3336 __set_bit(BTN_FORWARD
, input_dev
->keybit
);
3337 input_set_capability(input_dev
, EV_REL
, REL_WHEEL
);
3341 __set_bit(KEY_PROG1
, input_dev
->keybit
);
3342 __set_bit(KEY_PROG2
, input_dev
->keybit
);
3343 __set_bit(KEY_PROG3
, input_dev
->keybit
);
3345 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
3346 input_set_abs_params(input_dev
, ABS_THROTTLE
, 0, 71, 0, 0);
3350 __set_bit(KEY_PROG1
, input_dev
->keybit
);
3351 __set_bit(KEY_PROG2
, input_dev
->keybit
);
3352 __set_bit(KEY_PROG3
, input_dev
->keybit
);
3353 input_set_abs_params(input_dev
, ABS_X
, -2048, 2048, 0, 0);
3354 input_abs_set_res(input_dev
, ABS_X
, 1024); /* points/g */
3355 input_set_abs_params(input_dev
, ABS_Y
, -2048, 2048, 0, 0);
3356 input_abs_set_res(input_dev
, ABS_Y
, 1024);
3357 input_set_abs_params(input_dev
, ABS_Z
, -2048, 2048, 0, 0);
3358 input_abs_set_res(input_dev
, ABS_Z
, 1024);
3359 __set_bit(INPUT_PROP_ACCELEROMETER
, input_dev
->propbit
);
3363 __set_bit(KEY_PROG1
, input_dev
->keybit
);
3364 __set_bit(KEY_PROG2
, input_dev
->keybit
);
3365 __set_bit(KEY_PROG3
, input_dev
->keybit
);
3371 input_set_abs_params(input_dev
, ABS_RX
, 0, 4096, 0, 0);
3372 input_set_abs_params(input_dev
, ABS_RY
, 0, 4096, 0, 0);
3376 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
3381 input_set_abs_params(input_dev
, ABS_RY
, 0, 4096, 0, 0);
3385 input_set_abs_params(input_dev
, ABS_RX
, 0, 4096, 0, 0);
3394 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
3399 * For Bluetooth devices, the udev rule does not work correctly
3400 * for pads unless we add a stylus capability, which forces
3401 * ID_INPUT_TABLET to be set.
3403 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
3409 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
3416 __clear_bit(ABS_MISC
, input_dev
->absbit
);
3418 __set_bit(BTN_LEFT
, input_dev
->keybit
);
3419 __set_bit(BTN_FORWARD
, input_dev
->keybit
);
3420 __set_bit(BTN_BACK
, input_dev
->keybit
);
3421 __set_bit(BTN_RIGHT
, input_dev
->keybit
);
3426 input_set_capability(input_dev
, EV_MSC
, MSC_SERIAL
);
3427 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
3434 /* no pad supported */
3440 static const struct wacom_features wacom_features_0x00
=
3441 { "Wacom Penpartner", 5040, 3780, 255, 0,
3442 PENPARTNER
, WACOM_PENPRTN_RES
, WACOM_PENPRTN_RES
};
3443 static const struct wacom_features wacom_features_0x10
=
3444 { "Wacom Graphire", 10206, 7422, 511, 63,
3445 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
3446 static const struct wacom_features wacom_features_0x81
=
3447 { "Wacom Graphire BT", 16704, 12064, 511, 32,
3448 GRAPHIRE_BT
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
, 2 };
3449 static const struct wacom_features wacom_features_0x11
=
3450 { "Wacom Graphire2 4x5", 10206, 7422, 511, 63,
3451 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
3452 static const struct wacom_features wacom_features_0x12
=
3453 { "Wacom Graphire2 5x7", 13918, 10206, 511, 63,
3454 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
3455 static const struct wacom_features wacom_features_0x13
=
3456 { "Wacom Graphire3", 10208, 7424, 511, 63,
3457 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
3458 static const struct wacom_features wacom_features_0x14
=
3459 { "Wacom Graphire3 6x8", 16704, 12064, 511, 63,
3460 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
3461 static const struct wacom_features wacom_features_0x15
=
3462 { "Wacom Graphire4 4x5", 10208, 7424, 511, 63,
3463 WACOM_G4
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
3464 static const struct wacom_features wacom_features_0x16
=
3465 { "Wacom Graphire4 6x8", 16704, 12064, 511, 63,
3466 WACOM_G4
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
3467 static const struct wacom_features wacom_features_0x17
=
3468 { "Wacom BambooFun 4x5", 14760, 9225, 511, 63,
3469 WACOM_MO
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3470 static const struct wacom_features wacom_features_0x18
=
3471 { "Wacom BambooFun 6x8", 21648, 13530, 511, 63,
3472 WACOM_MO
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3473 static const struct wacom_features wacom_features_0x19
=
3474 { "Wacom Bamboo1 Medium", 16704, 12064, 511, 63,
3475 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
3476 static const struct wacom_features wacom_features_0x60
=
3477 { "Wacom Volito", 5104, 3712, 511, 63,
3478 GRAPHIRE
, WACOM_VOLITO_RES
, WACOM_VOLITO_RES
};
3479 static const struct wacom_features wacom_features_0x61
=
3480 { "Wacom PenStation2", 3250, 2320, 255, 63,
3481 GRAPHIRE
, WACOM_VOLITO_RES
, WACOM_VOLITO_RES
};
3482 static const struct wacom_features wacom_features_0x62
=
3483 { "Wacom Volito2 4x5", 5104, 3712, 511, 63,
3484 GRAPHIRE
, WACOM_VOLITO_RES
, WACOM_VOLITO_RES
};
3485 static const struct wacom_features wacom_features_0x63
=
3486 { "Wacom Volito2 2x3", 3248, 2320, 511, 63,
3487 GRAPHIRE
, WACOM_VOLITO_RES
, WACOM_VOLITO_RES
};
3488 static const struct wacom_features wacom_features_0x64
=
3489 { "Wacom PenPartner2", 3250, 2320, 511, 63,
3490 GRAPHIRE
, WACOM_VOLITO_RES
, WACOM_VOLITO_RES
};
3491 static const struct wacom_features wacom_features_0x65
=
3492 { "Wacom Bamboo", 14760, 9225, 511, 63,
3493 WACOM_MO
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3494 static const struct wacom_features wacom_features_0x69
=
3495 { "Wacom Bamboo1", 5104, 3712, 511, 63,
3496 GRAPHIRE
, WACOM_PENPRTN_RES
, WACOM_PENPRTN_RES
};
3497 static const struct wacom_features wacom_features_0x6A
=
3498 { "Wacom Bamboo1 4x6", 14760, 9225, 1023, 63,
3499 GRAPHIRE
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3500 static const struct wacom_features wacom_features_0x6B
=
3501 { "Wacom Bamboo1 5x8", 21648, 13530, 1023, 63,
3502 GRAPHIRE
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3503 static const struct wacom_features wacom_features_0x20
=
3504 { "Wacom Intuos 4x5", 12700, 10600, 1023, 31,
3505 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3506 static const struct wacom_features wacom_features_0x21
=
3507 { "Wacom Intuos 6x8", 20320, 16240, 1023, 31,
3508 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3509 static const struct wacom_features wacom_features_0x22
=
3510 { "Wacom Intuos 9x12", 30480, 24060, 1023, 31,
3511 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3512 static const struct wacom_features wacom_features_0x23
=
3513 { "Wacom Intuos 12x12", 30480, 31680, 1023, 31,
3514 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3515 static const struct wacom_features wacom_features_0x24
=
3516 { "Wacom Intuos 12x18", 45720, 31680, 1023, 31,
3517 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3518 static const struct wacom_features wacom_features_0x30
=
3519 { "Wacom PL400", 5408, 4056, 255, 0,
3520 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
3521 static const struct wacom_features wacom_features_0x31
=
3522 { "Wacom PL500", 6144, 4608, 255, 0,
3523 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
3524 static const struct wacom_features wacom_features_0x32
=
3525 { "Wacom PL600", 6126, 4604, 255, 0,
3526 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
3527 static const struct wacom_features wacom_features_0x33
=
3528 { "Wacom PL600SX", 6260, 5016, 255, 0,
3529 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
3530 static const struct wacom_features wacom_features_0x34
=
3531 { "Wacom PL550", 6144, 4608, 511, 0,
3532 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
3533 static const struct wacom_features wacom_features_0x35
=
3534 { "Wacom PL800", 7220, 5780, 511, 0,
3535 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
3536 static const struct wacom_features wacom_features_0x37
=
3537 { "Wacom PL700", 6758, 5406, 511, 0,
3538 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
3539 static const struct wacom_features wacom_features_0x38
=
3540 { "Wacom PL510", 6282, 4762, 511, 0,
3541 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
3542 static const struct wacom_features wacom_features_0x39
=
3543 { "Wacom DTU710", 34080, 27660, 511, 0,
3544 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
3545 static const struct wacom_features wacom_features_0xC4
=
3546 { "Wacom DTF521", 6282, 4762, 511, 0,
3547 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
3548 static const struct wacom_features wacom_features_0xC0
=
3549 { "Wacom DTF720", 6858, 5506, 511, 0,
3550 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
3551 static const struct wacom_features wacom_features_0xC2
=
3552 { "Wacom DTF720a", 6858, 5506, 511, 0,
3553 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
3554 static const struct wacom_features wacom_features_0x03
=
3555 { "Wacom Cintiq Partner", 20480, 15360, 511, 0,
3556 PTU
, WACOM_PL_RES
, WACOM_PL_RES
};
3557 static const struct wacom_features wacom_features_0x41
=
3558 { "Wacom Intuos2 4x5", 12700, 10600, 1023, 31,
3559 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3560 static const struct wacom_features wacom_features_0x42
=
3561 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
3562 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3563 static const struct wacom_features wacom_features_0x43
=
3564 { "Wacom Intuos2 9x12", 30480, 24060, 1023, 31,
3565 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3566 static const struct wacom_features wacom_features_0x44
=
3567 { "Wacom Intuos2 12x12", 30480, 31680, 1023, 31,
3568 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3569 static const struct wacom_features wacom_features_0x45
=
3570 { "Wacom Intuos2 12x18", 45720, 31680, 1023, 31,
3571 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3572 static const struct wacom_features wacom_features_0xB0
=
3573 { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63,
3574 INTUOS3S
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 4 };
3575 static const struct wacom_features wacom_features_0xB1
=
3576 { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63,
3577 INTUOS3
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 8 };
3578 static const struct wacom_features wacom_features_0xB2
=
3579 { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63,
3580 INTUOS3
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 8 };
3581 static const struct wacom_features wacom_features_0xB3
=
3582 { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63,
3583 INTUOS3L
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 8 };
3584 static const struct wacom_features wacom_features_0xB4
=
3585 { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63,
3586 INTUOS3L
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 8 };
3587 static const struct wacom_features wacom_features_0xB5
=
3588 { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63,
3589 INTUOS3
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 8 };
3590 static const struct wacom_features wacom_features_0xB7
=
3591 { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63,
3592 INTUOS3S
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 4 };
3593 static const struct wacom_features wacom_features_0xB8
=
3594 { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63,
3595 INTUOS4S
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 7 };
3596 static const struct wacom_features wacom_features_0xB9
=
3597 { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63,
3598 INTUOS4
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9 };
3599 static const struct wacom_features wacom_features_0xBA
=
3600 { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63,
3601 INTUOS4L
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9 };
3602 static const struct wacom_features wacom_features_0xBB
=
3603 { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63,
3604 INTUOS4L
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9 };
3605 static const struct wacom_features wacom_features_0xBC
=
3606 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
3607 INTUOS4
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9 };
3608 static const struct wacom_features wacom_features_0xBD
=
3609 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
3610 INTUOS4WL
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9 };
3611 static const struct wacom_features wacom_features_0x26
=
3612 { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63,
3613 INTUOS5S
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 7, .touch_max
= 16 };
3614 static const struct wacom_features wacom_features_0x27
=
3615 { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63,
3616 INTUOS5
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9, .touch_max
= 16 };
3617 static const struct wacom_features wacom_features_0x28
=
3618 { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63,
3619 INTUOS5L
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9, .touch_max
= 16 };
3620 static const struct wacom_features wacom_features_0x29
=
3621 { "Wacom Intuos5 S", 31496, 19685, 2047, 63,
3622 INTUOS5S
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 7 };
3623 static const struct wacom_features wacom_features_0x2A
=
3624 { "Wacom Intuos5 M", 44704, 27940, 2047, 63,
3625 INTUOS5
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9 };
3626 static const struct wacom_features wacom_features_0x314
=
3627 { "Wacom Intuos Pro S", 31496, 19685, 2047, 63,
3628 INTUOSPS
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 7, .touch_max
= 16,
3629 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3630 static const struct wacom_features wacom_features_0x315
=
3631 { "Wacom Intuos Pro M", 44704, 27940, 2047, 63,
3632 INTUOSPM
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9, .touch_max
= 16,
3633 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3634 static const struct wacom_features wacom_features_0x317
=
3635 { "Wacom Intuos Pro L", 65024, 40640, 2047, 63,
3636 INTUOSPL
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9, .touch_max
= 16,
3637 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3638 static const struct wacom_features wacom_features_0xF4
=
3639 { "Wacom Cintiq 24HD", 104480, 65600, 2047, 63,
3640 WACOM_24HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 16,
3641 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3642 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
3643 static const struct wacom_features wacom_features_0xF8
=
3644 { "Wacom Cintiq 24HD touch", 104480, 65600, 2047, 63, /* Pen */
3645 WACOM_24HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 16,
3646 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3647 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3648 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0xf6 };
3649 static const struct wacom_features wacom_features_0xF6
=
3650 { "Wacom Cintiq 24HD touch", .type
= WACOM_24HDT
, /* Touch */
3651 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0xf8, .touch_max
= 10,
3652 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3653 static const struct wacom_features wacom_features_0x32A
=
3654 { "Wacom Cintiq 27QHD", 120140, 67920, 2047, 63,
3655 WACOM_27QHD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 0,
3656 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3657 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
3658 static const struct wacom_features wacom_features_0x32B
=
3659 { "Wacom Cintiq 27QHD touch", 120140, 67920, 2047, 63,
3660 WACOM_27QHD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 0,
3661 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3662 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3663 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x32C };
3664 static const struct wacom_features wacom_features_0x32C
=
3665 { "Wacom Cintiq 27QHD touch", .type
= WACOM_27QHDT
,
3666 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x32B, .touch_max
= 10 };
3667 static const struct wacom_features wacom_features_0x3F
=
3668 { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63,
3669 CINTIQ
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 8 };
3670 static const struct wacom_features wacom_features_0xC5
=
3671 { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63,
3672 WACOM_BEE
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 10 };
3673 static const struct wacom_features wacom_features_0xC6
=
3674 { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63,
3675 WACOM_BEE
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 10 };
3676 static const struct wacom_features wacom_features_0x304
=
3677 { "Wacom Cintiq 13HD", 59552, 33848, 1023, 63,
3678 WACOM_13HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9,
3679 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3680 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
3681 static const struct wacom_features wacom_features_0x333
=
3682 { "Wacom Cintiq 13HD touch", 59552, 33848, 2047, 63,
3683 WACOM_13HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9,
3684 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3685 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3686 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x335 };
3687 static const struct wacom_features wacom_features_0x335
=
3688 { "Wacom Cintiq 13HD touch", .type
= WACOM_24HDT
, /* Touch */
3689 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x333, .touch_max
= 10,
3690 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3691 static const struct wacom_features wacom_features_0xC7
=
3692 { "Wacom DTU1931", 37832, 30305, 511, 0,
3693 PL
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3694 static const struct wacom_features wacom_features_0xCE
=
3695 { "Wacom DTU2231", 47864, 27011, 511, 0,
3696 DTU
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
,
3697 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBMOUSE
};
3698 static const struct wacom_features wacom_features_0xF0
=
3699 { "Wacom DTU1631", 34623, 19553, 511, 0,
3700 DTU
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3701 static const struct wacom_features wacom_features_0xFB
=
3702 { "Wacom DTU1031", 22096, 13960, 511, 0,
3703 DTUS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, 4,
3704 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
,
3705 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
};
3706 static const struct wacom_features wacom_features_0x32F
=
3707 { "Wacom DTU1031X", 22672, 12928, 511, 0,
3708 DTUSX
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, 0,
3709 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
,
3710 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
};
3711 static const struct wacom_features wacom_features_0x336
=
3712 { "Wacom DTU1141", 23672, 13403, 1023, 0,
3713 DTUS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, 4,
3714 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
,
3715 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
};
3716 static const struct wacom_features wacom_features_0x57
=
3717 { "Wacom DTK2241", 95840, 54260, 2047, 63,
3718 DTK
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 6,
3719 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3720 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
3721 static const struct wacom_features wacom_features_0x59
= /* Pen */
3722 { "Wacom DTH2242", 95840, 54260, 2047, 63,
3723 DTK
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 6,
3724 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3725 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3726 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x5D };
3727 static const struct wacom_features wacom_features_0x5D
= /* Touch */
3728 { "Wacom DTH2242", .type
= WACOM_24HDT
,
3729 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x59, .touch_max
= 10,
3730 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3731 static const struct wacom_features wacom_features_0xCC
=
3732 { "Wacom Cintiq 21UX2", 87200, 65600, 2047, 63,
3733 WACOM_21UX2
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 18,
3734 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3735 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
3736 static const struct wacom_features wacom_features_0xFA
=
3737 { "Wacom Cintiq 22HD", 95840, 54260, 2047, 63,
3738 WACOM_22HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 18,
3739 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3740 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
3741 static const struct wacom_features wacom_features_0x5B
=
3742 { "Wacom Cintiq 22HDT", 95840, 54260, 2047, 63,
3743 WACOM_22HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 18,
3744 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3745 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3746 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x5e };
3747 static const struct wacom_features wacom_features_0x5E
=
3748 { "Wacom Cintiq 22HDT", .type
= WACOM_24HDT
,
3749 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x5b, .touch_max
= 10,
3750 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3751 static const struct wacom_features wacom_features_0x90
=
3752 { "Wacom ISDv4 90", 26202, 16325, 255, 0,
3753 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3754 static const struct wacom_features wacom_features_0x93
=
3755 { "Wacom ISDv4 93", 26202, 16325, 255, 0,
3756 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3757 static const struct wacom_features wacom_features_0x97
=
3758 { "Wacom ISDv4 97", 26202, 16325, 511, 0,
3759 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3760 static const struct wacom_features wacom_features_0x9A
=
3761 { "Wacom ISDv4 9A", 26202, 16325, 255, 0,
3762 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3763 static const struct wacom_features wacom_features_0x9F
=
3764 { "Wacom ISDv4 9F", 26202, 16325, 255, 0,
3765 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3766 static const struct wacom_features wacom_features_0xE2
=
3767 { "Wacom ISDv4 E2", 26202, 16325, 255, 0,
3768 TABLETPC2FG
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
3769 static const struct wacom_features wacom_features_0xE3
=
3770 { "Wacom ISDv4 E3", 26202, 16325, 255, 0,
3771 TABLETPC2FG
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
3772 static const struct wacom_features wacom_features_0xE5
=
3773 { "Wacom ISDv4 E5", 26202, 16325, 255, 0,
3774 MTSCREEN
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3775 static const struct wacom_features wacom_features_0xE6
=
3776 { "Wacom ISDv4 E6", 27760, 15694, 255, 0,
3777 TABLETPC2FG
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
3778 static const struct wacom_features wacom_features_0xEC
=
3779 { "Wacom ISDv4 EC", 25710, 14500, 255, 0,
3780 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3781 static const struct wacom_features wacom_features_0xED
=
3782 { "Wacom ISDv4 ED", 26202, 16325, 255, 0,
3783 TABLETPCE
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3784 static const struct wacom_features wacom_features_0xEF
=
3785 { "Wacom ISDv4 EF", 26202, 16325, 255, 0,
3786 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3787 static const struct wacom_features wacom_features_0x100
=
3788 { "Wacom ISDv4 100", 26202, 16325, 255, 0,
3789 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3790 static const struct wacom_features wacom_features_0x101
=
3791 { "Wacom ISDv4 101", 26202, 16325, 255, 0,
3792 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3793 static const struct wacom_features wacom_features_0x10D
=
3794 { "Wacom ISDv4 10D", 26202, 16325, 255, 0,
3795 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3796 static const struct wacom_features wacom_features_0x10E
=
3797 { "Wacom ISDv4 10E", 27760, 15694, 255, 0,
3798 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3799 static const struct wacom_features wacom_features_0x10F
=
3800 { "Wacom ISDv4 10F", 27760, 15694, 255, 0,
3801 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3802 static const struct wacom_features wacom_features_0x116
=
3803 { "Wacom ISDv4 116", 26202, 16325, 255, 0,
3804 TABLETPCE
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3805 static const struct wacom_features wacom_features_0x12C
=
3806 { "Wacom ISDv4 12C", 27848, 15752, 2047, 0,
3807 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3808 static const struct wacom_features wacom_features_0x4001
=
3809 { "Wacom ISDv4 4001", 26202, 16325, 255, 0,
3810 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3811 static const struct wacom_features wacom_features_0x4004
=
3812 { "Wacom ISDv4 4004", 11060, 6220, 255, 0,
3813 MTTPC_B
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3814 static const struct wacom_features wacom_features_0x5000
=
3815 { "Wacom ISDv4 5000", 27848, 15752, 1023, 0,
3816 MTTPC_B
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3817 static const struct wacom_features wacom_features_0x5002
=
3818 { "Wacom ISDv4 5002", 29576, 16724, 1023, 0,
3819 MTTPC_B
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3820 static const struct wacom_features wacom_features_0x47
=
3821 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
3822 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3823 static const struct wacom_features wacom_features_0x84
=
3824 { "Wacom Wireless Receiver", .type
= WIRELESS
, .touch_max
= 16 };
3825 static const struct wacom_features wacom_features_0xD0
=
3826 { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31,
3827 BAMBOO_TOUCH
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
3828 static const struct wacom_features wacom_features_0xD1
=
3829 { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31,
3830 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
3831 static const struct wacom_features wacom_features_0xD2
=
3832 { "Wacom Bamboo Craft", 14720, 9200, 1023, 31,
3833 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
3834 static const struct wacom_features wacom_features_0xD3
=
3835 { "Wacom Bamboo 2FG 6x8", 21648, 13700, 1023, 31,
3836 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
3837 static const struct wacom_features wacom_features_0xD4
=
3838 { "Wacom Bamboo Pen", 14720, 9200, 1023, 31,
3839 BAMBOO_PEN
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3840 static const struct wacom_features wacom_features_0xD5
=
3841 { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31,
3842 BAMBOO_PEN
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3843 static const struct wacom_features wacom_features_0xD6
=
3844 { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31,
3845 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
3846 static const struct wacom_features wacom_features_0xD7
=
3847 { "Wacom BambooPT 2FG Small", 14720, 9200, 1023, 31,
3848 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
3849 static const struct wacom_features wacom_features_0xD8
=
3850 { "Wacom Bamboo Comic 2FG", 21648, 13700, 1023, 31,
3851 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
3852 static const struct wacom_features wacom_features_0xDA
=
3853 { "Wacom Bamboo 2FG 4x5 SE", 14720, 9200, 1023, 31,
3854 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
3855 static const struct wacom_features wacom_features_0xDB
=
3856 { "Wacom Bamboo 2FG 6x8 SE", 21648, 13700, 1023, 31,
3857 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
3858 static const struct wacom_features wacom_features_0xDD
=
3859 { "Wacom Bamboo Connect", 14720, 9200, 1023, 31,
3860 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3861 static const struct wacom_features wacom_features_0xDE
=
3862 { "Wacom Bamboo 16FG 4x5", 14720, 9200, 1023, 31,
3863 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 16 };
3864 static const struct wacom_features wacom_features_0xDF
=
3865 { "Wacom Bamboo 16FG 6x8", 21648, 13700, 1023, 31,
3866 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 16 };
3867 static const struct wacom_features wacom_features_0x300
=
3868 { "Wacom Bamboo One S", 14720, 9225, 1023, 31,
3869 BAMBOO_PEN
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3870 static const struct wacom_features wacom_features_0x301
=
3871 { "Wacom Bamboo One M", 21648, 13530, 1023, 31,
3872 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3873 static const struct wacom_features wacom_features_0x302
=
3874 { "Wacom Intuos PT S", 15200, 9500, 1023, 31,
3875 INTUOSHT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 16,
3876 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3877 static const struct wacom_features wacom_features_0x303
=
3878 { "Wacom Intuos PT M", 21600, 13500, 1023, 31,
3879 INTUOSHT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 16,
3880 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3881 static const struct wacom_features wacom_features_0x30E
=
3882 { "Wacom Intuos S", 15200, 9500, 1023, 31,
3883 INTUOSHT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
,
3884 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3885 static const struct wacom_features wacom_features_0x6004
=
3886 { "ISD-V4", 12800, 8000, 255, 0,
3887 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
3888 static const struct wacom_features wacom_features_0x307
=
3889 { "Wacom ISDv5 307", 59552, 33848, 2047, 63,
3890 CINTIQ_HYBRID
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9,
3891 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3892 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3893 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x309 };
3894 static const struct wacom_features wacom_features_0x309
=
3895 { "Wacom ISDv5 309", .type
= WACOM_24HDT
, /* Touch */
3896 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x0307, .touch_max
= 10,
3897 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3898 static const struct wacom_features wacom_features_0x30A
=
3899 { "Wacom ISDv5 30A", 59552, 33848, 2047, 63,
3900 CINTIQ_HYBRID
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9,
3901 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3902 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3903 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x30C };
3904 static const struct wacom_features wacom_features_0x30C
=
3905 { "Wacom ISDv5 30C", .type
= WACOM_24HDT
, /* Touch */
3906 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x30A, .touch_max
= 10,
3907 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3908 static const struct wacom_features wacom_features_0x318
=
3909 { "Wacom USB Bamboo PAD", 4095, 4095, /* Touch */
3910 .type
= BAMBOO_PAD
, 35, 48, .touch_max
= 4 };
3911 static const struct wacom_features wacom_features_0x319
=
3912 { "Wacom Wireless Bamboo PAD", 4095, 4095, /* Touch */
3913 .type
= BAMBOO_PAD
, 35, 48, .touch_max
= 4 };
3914 static const struct wacom_features wacom_features_0x325
=
3915 { "Wacom ISDv5 325", 59552, 33848, 2047, 63,
3916 CINTIQ_COMPANION_2
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 11,
3917 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3918 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
3919 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x326 };
3920 static const struct wacom_features wacom_features_0x326
= /* Touch */
3921 { "Wacom ISDv5 326", .type
= HID_GENERIC
, .oVid
= USB_VENDOR_ID_WACOM
,
3923 static const struct wacom_features wacom_features_0x323
=
3924 { "Wacom Intuos P M", 21600, 13500, 1023, 31,
3925 INTUOSHT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
,
3926 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3927 static const struct wacom_features wacom_features_0x331
=
3928 { "Wacom Express Key Remote", .type
= REMOTE
,
3929 .numbered_buttons
= 18, .check_for_hid_type
= true,
3930 .hid_type
= HID_TYPE_USBNONE
};
3931 static const struct wacom_features wacom_features_0x33B
=
3932 { "Wacom Intuos S 2", 15200, 9500, 2047, 63,
3933 INTUOSHT2
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
,
3934 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3935 static const struct wacom_features wacom_features_0x33C
=
3936 { "Wacom Intuos PT S 2", 15200, 9500, 2047, 63,
3937 INTUOSHT2
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 16,
3938 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3939 static const struct wacom_features wacom_features_0x33D
=
3940 { "Wacom Intuos P M 2", 21600, 13500, 2047, 63,
3941 INTUOSHT2
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
,
3942 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3943 static const struct wacom_features wacom_features_0x33E
=
3944 { "Wacom Intuos PT M 2", 21600, 13500, 2047, 63,
3945 INTUOSHT2
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 16,
3946 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
3947 static const struct wacom_features wacom_features_0x343
=
3948 { "Wacom DTK1651", 34816, 19759, 1023, 0,
3949 DTUS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, 4,
3950 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
,
3951 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
};
3953 static const struct wacom_features wacom_features_HID_ANY_ID
=
3954 { "Wacom HID", .type
= HID_GENERIC
, .oVid
= HID_ANY_ID
, .oPid
= HID_ANY_ID
};
3956 #define USB_DEVICE_WACOM(prod) \
3957 HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
3958 .driver_data = (kernel_ulong_t)&wacom_features_##prod
3960 #define BT_DEVICE_WACOM(prod) \
3961 HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
3962 .driver_data = (kernel_ulong_t)&wacom_features_##prod
3964 #define I2C_DEVICE_WACOM(prod) \
3965 HID_DEVICE(BUS_I2C, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
3966 .driver_data = (kernel_ulong_t)&wacom_features_##prod
3968 #define USB_DEVICE_LENOVO(prod) \
3969 HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
3970 .driver_data = (kernel_ulong_t)&wacom_features_##prod
3972 const struct hid_device_id wacom_ids
[] = {
3973 { USB_DEVICE_WACOM(0x00) },
3974 { USB_DEVICE_WACOM(0x03) },
3975 { USB_DEVICE_WACOM(0x10) },
3976 { USB_DEVICE_WACOM(0x11) },
3977 { USB_DEVICE_WACOM(0x12) },
3978 { USB_DEVICE_WACOM(0x13) },
3979 { USB_DEVICE_WACOM(0x14) },
3980 { USB_DEVICE_WACOM(0x15) },
3981 { USB_DEVICE_WACOM(0x16) },
3982 { USB_DEVICE_WACOM(0x17) },
3983 { USB_DEVICE_WACOM(0x18) },
3984 { USB_DEVICE_WACOM(0x19) },
3985 { USB_DEVICE_WACOM(0x20) },
3986 { USB_DEVICE_WACOM(0x21) },
3987 { USB_DEVICE_WACOM(0x22) },
3988 { USB_DEVICE_WACOM(0x23) },
3989 { USB_DEVICE_WACOM(0x24) },
3990 { USB_DEVICE_WACOM(0x26) },
3991 { USB_DEVICE_WACOM(0x27) },
3992 { USB_DEVICE_WACOM(0x28) },
3993 { USB_DEVICE_WACOM(0x29) },
3994 { USB_DEVICE_WACOM(0x2A) },
3995 { USB_DEVICE_WACOM(0x30) },
3996 { USB_DEVICE_WACOM(0x31) },
3997 { USB_DEVICE_WACOM(0x32) },
3998 { USB_DEVICE_WACOM(0x33) },
3999 { USB_DEVICE_WACOM(0x34) },
4000 { USB_DEVICE_WACOM(0x35) },
4001 { USB_DEVICE_WACOM(0x37) },
4002 { USB_DEVICE_WACOM(0x38) },
4003 { USB_DEVICE_WACOM(0x39) },
4004 { USB_DEVICE_WACOM(0x3F) },
4005 { USB_DEVICE_WACOM(0x41) },
4006 { USB_DEVICE_WACOM(0x42) },
4007 { USB_DEVICE_WACOM(0x43) },
4008 { USB_DEVICE_WACOM(0x44) },
4009 { USB_DEVICE_WACOM(0x45) },
4010 { USB_DEVICE_WACOM(0x47) },
4011 { USB_DEVICE_WACOM(0x57) },
4012 { USB_DEVICE_WACOM(0x59) },
4013 { USB_DEVICE_WACOM(0x5B) },
4014 { USB_DEVICE_WACOM(0x5D) },
4015 { USB_DEVICE_WACOM(0x5E) },
4016 { USB_DEVICE_WACOM(0x60) },
4017 { USB_DEVICE_WACOM(0x61) },
4018 { USB_DEVICE_WACOM(0x62) },
4019 { USB_DEVICE_WACOM(0x63) },
4020 { USB_DEVICE_WACOM(0x64) },
4021 { USB_DEVICE_WACOM(0x65) },
4022 { USB_DEVICE_WACOM(0x69) },
4023 { USB_DEVICE_WACOM(0x6A) },
4024 { USB_DEVICE_WACOM(0x6B) },
4025 { BT_DEVICE_WACOM(0x81) },
4026 { USB_DEVICE_WACOM(0x84) },
4027 { USB_DEVICE_WACOM(0x90) },
4028 { USB_DEVICE_WACOM(0x93) },
4029 { USB_DEVICE_WACOM(0x97) },
4030 { USB_DEVICE_WACOM(0x9A) },
4031 { USB_DEVICE_WACOM(0x9F) },
4032 { USB_DEVICE_WACOM(0xB0) },
4033 { USB_DEVICE_WACOM(0xB1) },
4034 { USB_DEVICE_WACOM(0xB2) },
4035 { USB_DEVICE_WACOM(0xB3) },
4036 { USB_DEVICE_WACOM(0xB4) },
4037 { USB_DEVICE_WACOM(0xB5) },
4038 { USB_DEVICE_WACOM(0xB7) },
4039 { USB_DEVICE_WACOM(0xB8) },
4040 { USB_DEVICE_WACOM(0xB9) },
4041 { USB_DEVICE_WACOM(0xBA) },
4042 { USB_DEVICE_WACOM(0xBB) },
4043 { USB_DEVICE_WACOM(0xBC) },
4044 { BT_DEVICE_WACOM(0xBD) },
4045 { USB_DEVICE_WACOM(0xC0) },
4046 { USB_DEVICE_WACOM(0xC2) },
4047 { USB_DEVICE_WACOM(0xC4) },
4048 { USB_DEVICE_WACOM(0xC5) },
4049 { USB_DEVICE_WACOM(0xC6) },
4050 { USB_DEVICE_WACOM(0xC7) },
4051 { USB_DEVICE_WACOM(0xCC) },
4052 { USB_DEVICE_WACOM(0xCE) },
4053 { USB_DEVICE_WACOM(0xD0) },
4054 { USB_DEVICE_WACOM(0xD1) },
4055 { USB_DEVICE_WACOM(0xD2) },
4056 { USB_DEVICE_WACOM(0xD3) },
4057 { USB_DEVICE_WACOM(0xD4) },
4058 { USB_DEVICE_WACOM(0xD5) },
4059 { USB_DEVICE_WACOM(0xD6) },
4060 { USB_DEVICE_WACOM(0xD7) },
4061 { USB_DEVICE_WACOM(0xD8) },
4062 { USB_DEVICE_WACOM(0xDA) },
4063 { USB_DEVICE_WACOM(0xDB) },
4064 { USB_DEVICE_WACOM(0xDD) },
4065 { USB_DEVICE_WACOM(0xDE) },
4066 { USB_DEVICE_WACOM(0xDF) },
4067 { USB_DEVICE_WACOM(0xE2) },
4068 { USB_DEVICE_WACOM(0xE3) },
4069 { USB_DEVICE_WACOM(0xE5) },
4070 { USB_DEVICE_WACOM(0xE6) },
4071 { USB_DEVICE_WACOM(0xEC) },
4072 { USB_DEVICE_WACOM(0xED) },
4073 { USB_DEVICE_WACOM(0xEF) },
4074 { USB_DEVICE_WACOM(0xF0) },
4075 { USB_DEVICE_WACOM(0xF4) },
4076 { USB_DEVICE_WACOM(0xF6) },
4077 { USB_DEVICE_WACOM(0xF8) },
4078 { USB_DEVICE_WACOM(0xFA) },
4079 { USB_DEVICE_WACOM(0xFB) },
4080 { USB_DEVICE_WACOM(0x100) },
4081 { USB_DEVICE_WACOM(0x101) },
4082 { USB_DEVICE_WACOM(0x10D) },
4083 { USB_DEVICE_WACOM(0x10E) },
4084 { USB_DEVICE_WACOM(0x10F) },
4085 { USB_DEVICE_WACOM(0x116) },
4086 { USB_DEVICE_WACOM(0x12C) },
4087 { USB_DEVICE_WACOM(0x300) },
4088 { USB_DEVICE_WACOM(0x301) },
4089 { USB_DEVICE_WACOM(0x302) },
4090 { USB_DEVICE_WACOM(0x303) },
4091 { USB_DEVICE_WACOM(0x304) },
4092 { USB_DEVICE_WACOM(0x307) },
4093 { USB_DEVICE_WACOM(0x309) },
4094 { USB_DEVICE_WACOM(0x30A) },
4095 { USB_DEVICE_WACOM(0x30C) },
4096 { USB_DEVICE_WACOM(0x30E) },
4097 { USB_DEVICE_WACOM(0x314) },
4098 { USB_DEVICE_WACOM(0x315) },
4099 { USB_DEVICE_WACOM(0x317) },
4100 { USB_DEVICE_WACOM(0x318) },
4101 { USB_DEVICE_WACOM(0x319) },
4102 { USB_DEVICE_WACOM(0x323) },
4103 { USB_DEVICE_WACOM(0x325) },
4104 { USB_DEVICE_WACOM(0x326) },
4105 { USB_DEVICE_WACOM(0x32A) },
4106 { USB_DEVICE_WACOM(0x32B) },
4107 { USB_DEVICE_WACOM(0x32C) },
4108 { USB_DEVICE_WACOM(0x32F) },
4109 { USB_DEVICE_WACOM(0x331) },
4110 { USB_DEVICE_WACOM(0x333) },
4111 { USB_DEVICE_WACOM(0x335) },
4112 { USB_DEVICE_WACOM(0x336) },
4113 { USB_DEVICE_WACOM(0x33B) },
4114 { USB_DEVICE_WACOM(0x33C) },
4115 { USB_DEVICE_WACOM(0x33D) },
4116 { USB_DEVICE_WACOM(0x33E) },
4117 { USB_DEVICE_WACOM(0x343) },
4118 { USB_DEVICE_WACOM(0x4001) },
4119 { USB_DEVICE_WACOM(0x4004) },
4120 { USB_DEVICE_WACOM(0x5000) },
4121 { USB_DEVICE_WACOM(0x5002) },
4122 { USB_DEVICE_LENOVO(0x6004) },
4124 { USB_DEVICE_WACOM(HID_ANY_ID
) },
4125 { I2C_DEVICE_WACOM(HID_ANY_ID
) },
4128 MODULE_DEVICE_TABLE(hid
, wacom_ids
);