2 * drivers/input/tablet/wacom_wac.c
4 * USB Wacom tablet support - Wacom specific code
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
15 #include "wacom_wac.h"
17 #include <linux/input/mt.h>
19 /* resolution for penabled devices */
20 #define WACOM_PL_RES 20
21 #define WACOM_PENPRTN_RES 40
22 #define WACOM_VOLITO_RES 50
23 #define WACOM_GRAPHIRE_RES 80
24 #define WACOM_INTUOS_RES 100
25 #define WACOM_INTUOS3_RES 200
27 /* Newer Cintiq and DTU have an offset between tablet and screen areas */
28 #define WACOM_DTU_OFFSET 200
29 #define WACOM_CINTIQ_OFFSET 400
32 * Scale factor relating reported contact size to logical contact area.
33 * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo
35 #define WACOM_CONTACT_AREA_SCALE 2607
37 static bool touch_arbitration
= 1;
38 module_param(touch_arbitration
, bool, 0644);
39 MODULE_PARM_DESC(touch_arbitration
, " on (Y) off (N)");
41 static void wacom_report_numbered_buttons(struct input_dev
*input_dev
,
42 int button_count
, int mask
);
44 static int wacom_numbered_button_to_key(int n
);
46 static void wacom_update_led(struct wacom
*wacom
, int button_count
, int mask
,
49 * Percent of battery capacity for Graphire.
50 * 8th value means AC online and show 100% capacity.
52 static unsigned short batcap_gr
[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
55 * Percent of battery capacity for Intuos4 WL, AC has a separate bit.
57 static unsigned short batcap_i4
[8] = { 1, 15, 30, 45, 60, 70, 85, 100 };
59 static void __wacom_notify_battery(struct wacom_battery
*battery
,
60 int bat_status
, int bat_capacity
,
61 bool bat_charging
, bool bat_connected
,
64 bool changed
= battery
->bat_status
!= bat_status
||
65 battery
->battery_capacity
!= bat_capacity
||
66 battery
->bat_charging
!= bat_charging
||
67 battery
->bat_connected
!= bat_connected
||
68 battery
->ps_connected
!= ps_connected
;
71 battery
->bat_status
= bat_status
;
72 battery
->battery_capacity
= bat_capacity
;
73 battery
->bat_charging
= bat_charging
;
74 battery
->bat_connected
= bat_connected
;
75 battery
->ps_connected
= ps_connected
;
78 power_supply_changed(battery
->battery
);
82 static void wacom_notify_battery(struct wacom_wac
*wacom_wac
,
83 int bat_status
, int bat_capacity
, bool bat_charging
,
84 bool bat_connected
, bool ps_connected
)
86 struct wacom
*wacom
= container_of(wacom_wac
, struct wacom
, wacom_wac
);
88 __wacom_notify_battery(&wacom
->battery
, bat_status
, bat_capacity
,
89 bat_charging
, bat_connected
, ps_connected
);
92 static int wacom_penpartner_irq(struct wacom_wac
*wacom
)
94 unsigned char *data
= wacom
->data
;
95 struct input_dev
*input
= wacom
->pen_input
;
100 wacom
->tool
[0] = (data
[5] & 0x20) ? BTN_TOOL_RUBBER
: BTN_TOOL_PEN
;
101 wacom
->id
[0] = (data
[5] & 0x20) ? ERASER_DEVICE_ID
: STYLUS_DEVICE_ID
;
102 input_report_key(input
, wacom
->tool
[0], 1);
103 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]); /* report tool id */
104 input_report_abs(input
, ABS_X
, get_unaligned_le16(&data
[1]));
105 input_report_abs(input
, ABS_Y
, get_unaligned_le16(&data
[3]));
106 input_report_abs(input
, ABS_PRESSURE
, (signed char)data
[6] + 127);
107 input_report_key(input
, BTN_TOUCH
, ((signed char)data
[6] > -127));
108 input_report_key(input
, BTN_STYLUS
, (data
[5] & 0x40));
110 input_report_key(input
, wacom
->tool
[0], 0);
111 input_report_abs(input
, ABS_MISC
, 0); /* report tool id */
112 input_report_abs(input
, ABS_PRESSURE
, -1);
113 input_report_key(input
, BTN_TOUCH
, 0);
118 input_report_key(input
, BTN_TOOL_PEN
, 1);
119 input_report_abs(input
, ABS_MISC
, STYLUS_DEVICE_ID
); /* report tool id */
120 input_report_abs(input
, ABS_X
, get_unaligned_le16(&data
[1]));
121 input_report_abs(input
, ABS_Y
, get_unaligned_le16(&data
[3]));
122 input_report_abs(input
, ABS_PRESSURE
, (signed char)data
[6] + 127);
123 input_report_key(input
, BTN_TOUCH
, ((signed char)data
[6] > -80) && !(data
[5] & 0x20));
124 input_report_key(input
, BTN_STYLUS
, (data
[5] & 0x40));
128 dev_dbg(input
->dev
.parent
,
129 "%s: received unknown report #%d\n", __func__
, data
[0]);
136 static int wacom_pl_irq(struct wacom_wac
*wacom
)
138 struct wacom_features
*features
= &wacom
->features
;
139 unsigned char *data
= wacom
->data
;
140 struct input_dev
*input
= wacom
->pen_input
;
143 if (data
[0] != WACOM_REPORT_PENABLED
) {
144 dev_dbg(input
->dev
.parent
,
145 "%s: received unknown report #%d\n", __func__
, data
[0]);
149 prox
= data
[1] & 0x40;
152 if ((data
[0] & 0x10) || (data
[4] & 0x20)) {
153 wacom
->tool
[0] = BTN_TOOL_RUBBER
;
154 wacom
->id
[0] = ERASER_DEVICE_ID
;
157 wacom
->tool
[0] = BTN_TOOL_PEN
;
158 wacom
->id
[0] = STYLUS_DEVICE_ID
;
162 /* If the eraser is in prox, STYLUS2 is always set. If we
163 * mis-detected the type and notice that STYLUS2 isn't set
164 * then force the eraser out of prox and let the pen in.
166 if (wacom
->tool
[0] == BTN_TOOL_RUBBER
&& !(data
[4] & 0x20)) {
167 input_report_key(input
, BTN_TOOL_RUBBER
, 0);
168 input_report_abs(input
, ABS_MISC
, 0);
170 wacom
->tool
[0] = BTN_TOOL_PEN
;
171 wacom
->id
[0] = STYLUS_DEVICE_ID
;
175 pressure
= (signed char)((data
[7] << 1) | ((data
[4] >> 2) & 1));
176 if (features
->pressure_max
> 255)
177 pressure
= (pressure
<< 1) | ((data
[4] >> 6) & 1);
178 pressure
+= (features
->pressure_max
+ 1) / 2;
180 input_report_abs(input
, ABS_X
, data
[3] | (data
[2] << 7) | ((data
[1] & 0x03) << 14));
181 input_report_abs(input
, ABS_Y
, data
[6] | (data
[5] << 7) | ((data
[4] & 0x03) << 14));
182 input_report_abs(input
, ABS_PRESSURE
, pressure
);
184 input_report_key(input
, BTN_TOUCH
, data
[4] & 0x08);
185 input_report_key(input
, BTN_STYLUS
, data
[4] & 0x10);
186 /* Only allow the stylus2 button to be reported for the pen tool. */
187 input_report_key(input
, BTN_STYLUS2
, (wacom
->tool
[0] == BTN_TOOL_PEN
) && (data
[4] & 0x20));
192 input_report_key(input
, wacom
->tool
[0], prox
);
193 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]);
197 static int wacom_ptu_irq(struct wacom_wac
*wacom
)
199 unsigned char *data
= wacom
->data
;
200 struct input_dev
*input
= wacom
->pen_input
;
202 if (data
[0] != WACOM_REPORT_PENABLED
) {
203 dev_dbg(input
->dev
.parent
,
204 "%s: received unknown report #%d\n", __func__
, data
[0]);
208 if (data
[1] & 0x04) {
209 input_report_key(input
, BTN_TOOL_RUBBER
, data
[1] & 0x20);
210 input_report_key(input
, BTN_TOUCH
, data
[1] & 0x08);
211 wacom
->id
[0] = ERASER_DEVICE_ID
;
213 input_report_key(input
, BTN_TOOL_PEN
, data
[1] & 0x20);
214 input_report_key(input
, BTN_TOUCH
, data
[1] & 0x01);
215 wacom
->id
[0] = STYLUS_DEVICE_ID
;
217 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]); /* report tool id */
218 input_report_abs(input
, ABS_X
, le16_to_cpup((__le16
*)&data
[2]));
219 input_report_abs(input
, ABS_Y
, le16_to_cpup((__le16
*)&data
[4]));
220 input_report_abs(input
, ABS_PRESSURE
, le16_to_cpup((__le16
*)&data
[6]));
221 input_report_key(input
, BTN_STYLUS
, data
[1] & 0x02);
222 input_report_key(input
, BTN_STYLUS2
, data
[1] & 0x10);
226 static int wacom_dtu_irq(struct wacom_wac
*wacom
)
228 unsigned char *data
= wacom
->data
;
229 struct input_dev
*input
= wacom
->pen_input
;
230 int prox
= data
[1] & 0x20;
232 dev_dbg(input
->dev
.parent
,
233 "%s: received report #%d", __func__
, data
[0]);
236 /* Going into proximity select tool */
237 wacom
->tool
[0] = (data
[1] & 0x0c) ? BTN_TOOL_RUBBER
: BTN_TOOL_PEN
;
238 if (wacom
->tool
[0] == BTN_TOOL_PEN
)
239 wacom
->id
[0] = STYLUS_DEVICE_ID
;
241 wacom
->id
[0] = ERASER_DEVICE_ID
;
243 input_report_key(input
, BTN_STYLUS
, data
[1] & 0x02);
244 input_report_key(input
, BTN_STYLUS2
, data
[1] & 0x10);
245 input_report_abs(input
, ABS_X
, le16_to_cpup((__le16
*)&data
[2]));
246 input_report_abs(input
, ABS_Y
, le16_to_cpup((__le16
*)&data
[4]));
247 input_report_abs(input
, ABS_PRESSURE
, ((data
[7] & 0x01) << 8) | data
[6]);
248 input_report_key(input
, BTN_TOUCH
, data
[1] & 0x05);
249 if (!prox
) /* out-prox */
251 input_report_key(input
, wacom
->tool
[0], prox
);
252 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]);
256 static int wacom_dtus_irq(struct wacom_wac
*wacom
)
258 unsigned char *data
= wacom
->data
;
259 struct input_dev
*input
= wacom
->pen_input
;
260 unsigned short prox
, pressure
= 0;
262 if (data
[0] != WACOM_REPORT_DTUS
&& data
[0] != WACOM_REPORT_DTUSPAD
) {
263 dev_dbg(input
->dev
.parent
,
264 "%s: received unknown report #%d", __func__
, data
[0]);
266 } else if (data
[0] == WACOM_REPORT_DTUSPAD
) {
267 input
= wacom
->pad_input
;
268 input_report_key(input
, BTN_0
, (data
[1] & 0x01));
269 input_report_key(input
, BTN_1
, (data
[1] & 0x02));
270 input_report_key(input
, BTN_2
, (data
[1] & 0x04));
271 input_report_key(input
, BTN_3
, (data
[1] & 0x08));
272 input_report_abs(input
, ABS_MISC
,
273 data
[1] & 0x0f ? PAD_DEVICE_ID
: 0);
276 prox
= data
[1] & 0x80;
278 switch ((data
[1] >> 3) & 3) {
280 wacom
->tool
[0] = BTN_TOOL_RUBBER
;
281 wacom
->id
[0] = ERASER_DEVICE_ID
;
285 wacom
->tool
[0] = BTN_TOOL_PEN
;
286 wacom
->id
[0] = STYLUS_DEVICE_ID
;
291 input_report_key(input
, BTN_STYLUS
, data
[1] & 0x20);
292 input_report_key(input
, BTN_STYLUS2
, data
[1] & 0x40);
293 input_report_abs(input
, ABS_X
, get_unaligned_be16(&data
[3]));
294 input_report_abs(input
, ABS_Y
, get_unaligned_be16(&data
[5]));
295 pressure
= ((data
[1] & 0x03) << 8) | (data
[2] & 0xff);
296 input_report_abs(input
, ABS_PRESSURE
, pressure
);
297 input_report_key(input
, BTN_TOUCH
, pressure
> 10);
299 if (!prox
) /* out-prox */
301 input_report_key(input
, wacom
->tool
[0], prox
);
302 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]);
307 static int wacom_graphire_irq(struct wacom_wac
*wacom
)
309 struct wacom_features
*features
= &wacom
->features
;
310 unsigned char *data
= wacom
->data
;
311 struct input_dev
*input
= wacom
->pen_input
;
312 struct input_dev
*pad_input
= wacom
->pad_input
;
313 int battery_capacity
, ps_connected
;
318 if (features
->type
== GRAPHIRE_BT
) {
319 if (data
[0] != WACOM_REPORT_PENABLED_BT
) {
320 dev_dbg(input
->dev
.parent
,
321 "%s: received unknown report #%d\n", __func__
,
325 } else if (data
[0] != WACOM_REPORT_PENABLED
) {
326 dev_dbg(input
->dev
.parent
,
327 "%s: received unknown report #%d\n", __func__
, data
[0]);
331 prox
= data
[1] & 0x80;
332 if (prox
|| wacom
->id
[0]) {
334 switch ((data
[1] >> 5) & 3) {
337 wacom
->tool
[0] = BTN_TOOL_PEN
;
338 wacom
->id
[0] = STYLUS_DEVICE_ID
;
342 wacom
->tool
[0] = BTN_TOOL_RUBBER
;
343 wacom
->id
[0] = ERASER_DEVICE_ID
;
346 case 2: /* Mouse with wheel */
347 input_report_key(input
, BTN_MIDDLE
, data
[1] & 0x04);
350 case 3: /* Mouse without wheel */
351 wacom
->tool
[0] = BTN_TOOL_MOUSE
;
352 wacom
->id
[0] = CURSOR_DEVICE_ID
;
356 input_report_abs(input
, ABS_X
, le16_to_cpup((__le16
*)&data
[2]));
357 input_report_abs(input
, ABS_Y
, le16_to_cpup((__le16
*)&data
[4]));
358 if (wacom
->tool
[0] != BTN_TOOL_MOUSE
) {
359 if (features
->type
== GRAPHIRE_BT
)
360 input_report_abs(input
, ABS_PRESSURE
, data
[6] |
361 (((__u16
) (data
[1] & 0x08)) << 5));
363 input_report_abs(input
, ABS_PRESSURE
, data
[6] |
364 ((data
[7] & 0x03) << 8));
365 input_report_key(input
, BTN_TOUCH
, data
[1] & 0x01);
366 input_report_key(input
, BTN_STYLUS
, data
[1] & 0x02);
367 input_report_key(input
, BTN_STYLUS2
, data
[1] & 0x04);
369 input_report_key(input
, BTN_LEFT
, data
[1] & 0x01);
370 input_report_key(input
, BTN_RIGHT
, data
[1] & 0x02);
371 if (features
->type
== WACOM_G4
||
372 features
->type
== WACOM_MO
) {
373 input_report_abs(input
, ABS_DISTANCE
, data
[6] & 0x3f);
374 rw
= (data
[7] & 0x04) - (data
[7] & 0x03);
375 } else if (features
->type
== GRAPHIRE_BT
) {
376 /* Compute distance between mouse and tablet */
377 rw
= 44 - (data
[6] >> 2);
378 rw
= clamp_val(rw
, 0, 31);
379 input_report_abs(input
, ABS_DISTANCE
, rw
);
380 if (((data
[1] >> 5) & 3) == 2) {
381 /* Mouse with wheel */
382 input_report_key(input
, BTN_MIDDLE
,
384 rw
= (data
[6] & 0x01) ? -1 :
385 (data
[6] & 0x02) ? 1 : 0;
390 input_report_abs(input
, ABS_DISTANCE
, data
[7] & 0x3f);
391 rw
= -(signed char)data
[6];
393 input_report_rel(input
, REL_WHEEL
, rw
);
398 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]); /* report tool id */
399 input_report_key(input
, wacom
->tool
[0], prox
);
400 input_sync(input
); /* sync last event */
404 switch (features
->type
) {
406 prox
= data
[7] & 0xf8;
407 if (prox
|| wacom
->id
[1]) {
408 wacom
->id
[1] = PAD_DEVICE_ID
;
409 input_report_key(pad_input
, BTN_BACK
, (data
[7] & 0x40));
410 input_report_key(pad_input
, BTN_FORWARD
, (data
[7] & 0x80));
411 rw
= ((data
[7] & 0x18) >> 3) - ((data
[7] & 0x20) >> 3);
412 input_report_rel(pad_input
, REL_WHEEL
, rw
);
415 input_report_abs(pad_input
, ABS_MISC
, wacom
->id
[1]);
421 prox
= (data
[7] & 0xf8) || data
[8];
422 if (prox
|| wacom
->id
[1]) {
423 wacom
->id
[1] = PAD_DEVICE_ID
;
424 input_report_key(pad_input
, BTN_BACK
, (data
[7] & 0x08));
425 input_report_key(pad_input
, BTN_LEFT
, (data
[7] & 0x20));
426 input_report_key(pad_input
, BTN_FORWARD
, (data
[7] & 0x10));
427 input_report_key(pad_input
, BTN_RIGHT
, (data
[7] & 0x40));
428 input_report_abs(pad_input
, ABS_WHEEL
, (data
[8] & 0x7f));
431 input_report_abs(pad_input
, ABS_MISC
, wacom
->id
[1]);
436 prox
= data
[7] & 0x03;
437 if (prox
|| wacom
->id
[1]) {
438 wacom
->id
[1] = PAD_DEVICE_ID
;
439 input_report_key(pad_input
, BTN_0
, (data
[7] & 0x02));
440 input_report_key(pad_input
, BTN_1
, (data
[7] & 0x01));
443 input_report_abs(pad_input
, ABS_MISC
, wacom
->id
[1]);
449 /* Store current battery capacity and power supply state */
450 if (features
->type
== GRAPHIRE_BT
) {
451 rw
= (data
[7] >> 2 & 0x07);
452 battery_capacity
= batcap_gr
[rw
];
453 ps_connected
= rw
== 7;
454 wacom_notify_battery(wacom
, WACOM_POWER_SUPPLY_STATUS_AUTO
,
455 battery_capacity
, ps_connected
, 1,
462 static void wacom_intuos_schedule_prox_event(struct wacom_wac
*wacom_wac
)
464 struct wacom
*wacom
= container_of(wacom_wac
, struct wacom
, wacom_wac
);
465 struct wacom_features
*features
= &wacom_wac
->features
;
466 struct hid_report
*r
;
467 struct hid_report_enum
*re
;
469 re
= &(wacom
->hdev
->report_enum
[HID_FEATURE_REPORT
]);
470 if (features
->type
== INTUOSHT2
)
471 r
= re
->report_id_hash
[WACOM_REPORT_INTUOSHT2_ID
];
473 r
= re
->report_id_hash
[WACOM_REPORT_INTUOS_ID1
];
475 hid_hw_request(wacom
->hdev
, r
, HID_REQ_GET_REPORT
);
479 static int wacom_intuos_pad(struct wacom_wac
*wacom
)
481 struct wacom_features
*features
= &wacom
->features
;
482 unsigned char *data
= wacom
->data
;
483 struct input_dev
*input
= wacom
->pad_input
;
485 int buttons
= 0, nbuttons
= features
->numbered_buttons
;
486 int keys
= 0, nkeys
= 0;
487 int ring1
= 0, ring2
= 0;
488 int strip1
= 0, strip2
= 0;
491 /* pad packets. Works as a second tool and is always in prox */
492 if (!(data
[0] == WACOM_REPORT_INTUOSPAD
|| data
[0] == WACOM_REPORT_INTUOS5PAD
||
493 data
[0] == WACOM_REPORT_CINTIQPAD
))
496 if (features
->type
>= INTUOS4S
&& features
->type
<= INTUOS4L
) {
497 buttons
= (data
[3] << 1) | (data
[2] & 0x01);
499 } else if (features
->type
== DTK
) {
501 } else if (features
->type
== WACOM_13HD
) {
502 buttons
= (data
[4] << 1) | (data
[3] & 0x01);
503 } else if (features
->type
== WACOM_24HD
) {
504 buttons
= (data
[8] << 8) | data
[6];
509 * Three "buttons" are available on the 24HD which are
510 * physically implemented as a touchstrip. Each button
511 * is approximately 3 bits wide with a 2 bit spacing.
512 * The raw touchstrip bits are stored at:
513 * ((data[3] & 0x1f) << 8) | data[4])
516 keys
= ((data
[3] & 0x1C) ? 1<<2 : 0) |
517 ((data
[4] & 0xE0) ? 1<<1 : 0) |
518 ((data
[4] & 0x07) ? 1<<0 : 0);
519 } else if (features
->type
== WACOM_27QHD
) {
521 keys
= data
[2] & 0x07;
523 input_report_abs(input
, ABS_X
, be16_to_cpup((__be16
*)&data
[4]));
524 input_report_abs(input
, ABS_Y
, be16_to_cpup((__be16
*)&data
[6]));
525 input_report_abs(input
, ABS_Z
, be16_to_cpup((__be16
*)&data
[8]));
526 } else if (features
->type
== CINTIQ_HYBRID
) {
528 * Do not send hardware buttons under Android. They
529 * are already sent to the system through GPIO (and
530 * have different meaning).
532 * d-pad right -> data[4] & 0x10
533 * d-pad up -> data[4] & 0x20
534 * d-pad left -> data[4] & 0x40
535 * d-pad down -> data[4] & 0x80
536 * d-pad center -> data[3] & 0x01
538 buttons
= (data
[4] << 1) | (data
[3] & 0x01);
539 } else if (features
->type
== CINTIQ_COMPANION_2
) {
540 /* d-pad right -> data[2] & 0x10
541 * d-pad up -> data[2] & 0x20
542 * d-pad left -> data[2] & 0x40
543 * d-pad down -> data[2] & 0x80
544 * d-pad center -> data[1] & 0x01
546 buttons
= ((data
[2] >> 4) << 7) |
547 ((data
[1] & 0x04) << 4) |
548 ((data
[2] & 0x0F) << 2) |
550 } else if (features
->type
>= INTUOS5S
&& features
->type
<= INTUOSPL
) {
552 * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in
553 * addition to the mechanical switch. Switch data is
554 * stored in data[4], capacitive data in data[5].
556 * Touch ring mode switch (data[3]) has no capacitive sensor
558 buttons
= (data
[4] << 1) | (data
[3] & 0x01);
561 if (features
->type
== WACOM_21UX2
|| features
->type
== WACOM_22HD
) {
562 buttons
= (data
[8] << 10) | ((data
[7] & 0x01) << 9) |
563 (data
[6] << 1) | (data
[5] & 0x01);
565 if (features
->type
== WACOM_22HD
) {
567 keys
= data
[9] & 0x07;
570 buttons
= ((data
[6] & 0x10) << 5) |
571 ((data
[5] & 0x10) << 4) |
572 ((data
[6] & 0x0F) << 4) |
575 strip1
= ((data
[1] & 0x1f) << 8) | data
[2];
576 strip2
= ((data
[3] & 0x1f) << 8) | data
[4];
579 prox
= (buttons
& ~(~0U << nbuttons
)) | (keys
& ~(~0U << nkeys
)) |
580 (ring1
& 0x80) | (ring2
& 0x80) | strip1
| strip2
;
582 wacom_report_numbered_buttons(input
, nbuttons
, buttons
);
584 for (i
= 0; i
< nkeys
; i
++)
585 input_report_key(input
, KEY_PROG1
+ i
, keys
& (1 << i
));
587 input_report_abs(input
, ABS_RX
, strip1
);
588 input_report_abs(input
, ABS_RY
, strip2
);
590 input_report_abs(input
, ABS_WHEEL
, (ring1
& 0x80) ? (ring1
& 0x7f) : 0);
591 input_report_abs(input
, ABS_THROTTLE
, (ring2
& 0x80) ? (ring2
& 0x7f) : 0);
593 input_report_key(input
, wacom
->tool
[1], prox
? 1 : 0);
594 input_report_abs(input
, ABS_MISC
, prox
? PAD_DEVICE_ID
: 0);
596 input_event(input
, EV_MSC
, MSC_SERIAL
, 0xffffffff);
601 static int wacom_intuos_id_mangle(int tool_id
)
603 return (tool_id
& ~0xFFF) << 4 | (tool_id
& 0xFFF);
606 static int wacom_intuos_get_tool_type(int tool_id
)
611 case 0x812: /* Inking pen */
612 case 0x801: /* Intuos3 Inking pen */
613 case 0x12802: /* Intuos4/5 Inking Pen */
615 tool_type
= BTN_TOOL_PENCIL
;
618 case 0x822: /* Pen */
621 case 0x823: /* Intuos3 Grip Pen */
622 case 0x813: /* Intuos3 Classic Pen */
623 case 0x885: /* Intuos3 Marker Pen */
624 case 0x802: /* Intuos4/5 13HD/24HD General Pen */
625 case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
626 case 0x8e2: /* IntuosHT2 pen */
628 case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */
629 case 0x14802: /* Intuos4/5 13HD/24HD Classic Pen */
630 case 0x16802: /* Cintiq 13HD Pro Pen */
631 case 0x18802: /* DTH2242 Pen */
632 case 0x10802: /* Intuos4/5 13HD/24HD General Pen */
633 tool_type
= BTN_TOOL_PEN
;
636 case 0x832: /* Stroke pen */
638 tool_type
= BTN_TOOL_BRUSH
;
641 case 0x007: /* Mouse 4D and 2D */
644 case 0x017: /* Intuos3 2D Mouse */
645 case 0x806: /* Intuos4 Mouse */
646 tool_type
= BTN_TOOL_MOUSE
;
649 case 0x096: /* Lens cursor */
650 case 0x097: /* Intuos3 Lens cursor */
651 case 0x006: /* Intuos4 Lens cursor */
652 tool_type
= BTN_TOOL_LENS
;
655 case 0x82a: /* Eraser */
661 case 0x82b: /* Intuos3 Grip Pen Eraser */
662 case 0x81b: /* Intuos3 Classic Pen Eraser */
663 case 0x91b: /* Intuos3 Airbrush Eraser */
664 case 0x80c: /* Intuos4/5 13HD/24HD Marker Pen Eraser */
665 case 0x80a: /* Intuos4/5 13HD/24HD General Pen Eraser */
666 case 0x90a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
667 case 0x1480a: /* Intuos4/5 13HD/24HD Classic Pen Eraser */
668 case 0x1090a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
669 case 0x1080c: /* Intuos4/5 13HD/24HD Art Pen Eraser */
670 case 0x1680a: /* Cintiq 13HD Pro Pen Eraser */
671 case 0x1880a: /* DTH2242 Eraser */
672 case 0x1080a: /* Intuos4/5 13HD/24HD General Pen Eraser */
673 tool_type
= BTN_TOOL_RUBBER
;
679 case 0x913: /* Intuos3 Airbrush */
680 case 0x902: /* Intuos4/5 13HD/24HD Airbrush */
681 case 0x10902: /* Intuos4/5 13HD/24HD Airbrush */
682 tool_type
= BTN_TOOL_AIRBRUSH
;
685 default: /* Unknown tool */
686 tool_type
= BTN_TOOL_PEN
;
692 static void wacom_exit_report(struct wacom_wac
*wacom
)
694 struct input_dev
*input
= wacom
->pen_input
;
695 struct wacom_features
*features
= &wacom
->features
;
696 unsigned char *data
= wacom
->data
;
697 int idx
= (features
->type
== INTUOS
) ? (data
[1] & 0x01) : 0;
700 * Reset all states otherwise we lose the initial states
701 * when in-prox next time
703 input_report_abs(input
, ABS_X
, 0);
704 input_report_abs(input
, ABS_Y
, 0);
705 input_report_abs(input
, ABS_DISTANCE
, 0);
706 input_report_abs(input
, ABS_TILT_X
, 0);
707 input_report_abs(input
, ABS_TILT_Y
, 0);
708 if (wacom
->tool
[idx
] >= BTN_TOOL_MOUSE
) {
709 input_report_key(input
, BTN_LEFT
, 0);
710 input_report_key(input
, BTN_MIDDLE
, 0);
711 input_report_key(input
, BTN_RIGHT
, 0);
712 input_report_key(input
, BTN_SIDE
, 0);
713 input_report_key(input
, BTN_EXTRA
, 0);
714 input_report_abs(input
, ABS_THROTTLE
, 0);
715 input_report_abs(input
, ABS_RZ
, 0);
717 input_report_abs(input
, ABS_PRESSURE
, 0);
718 input_report_key(input
, BTN_STYLUS
, 0);
719 input_report_key(input
, BTN_STYLUS2
, 0);
720 input_report_key(input
, BTN_TOUCH
, 0);
721 input_report_abs(input
, ABS_WHEEL
, 0);
722 if (features
->type
>= INTUOS3S
)
723 input_report_abs(input
, ABS_Z
, 0);
725 input_report_key(input
, wacom
->tool
[idx
], 0);
726 input_report_abs(input
, ABS_MISC
, 0); /* reset tool id */
727 input_event(input
, EV_MSC
, MSC_SERIAL
, wacom
->serial
[idx
]);
731 static int wacom_intuos_inout(struct wacom_wac
*wacom
)
733 struct wacom_features
*features
= &wacom
->features
;
734 unsigned char *data
= wacom
->data
;
735 struct input_dev
*input
= wacom
->pen_input
;
736 int idx
= (features
->type
== INTUOS
) ? (data
[1] & 0x01) : 0;
738 if (!(((data
[1] & 0xfc) == 0xc0) || /* in prox */
739 ((data
[1] & 0xfe) == 0x20) || /* in range */
740 ((data
[1] & 0xfe) == 0x80))) /* out prox */
744 if ((data
[1] & 0xfc) == 0xc0) {
745 /* serial number of the tool */
746 wacom
->serial
[idx
] = ((data
[3] & 0x0f) << 28) +
747 (data
[4] << 20) + (data
[5] << 12) +
748 (data
[6] << 4) + (data
[7] >> 4);
750 wacom
->id
[idx
] = (data
[2] << 4) | (data
[3] >> 4) |
751 ((data
[7] & 0x0f) << 16) | ((data
[8] & 0xf0) << 8);
753 wacom
->tool
[idx
] = wacom_intuos_get_tool_type(wacom
->id
[idx
]);
755 wacom
->shared
->stylus_in_proximity
= true;
760 if ((data
[1] & 0xfe) == 0x20) {
761 if (features
->type
!= INTUOSHT2
)
762 wacom
->shared
->stylus_in_proximity
= true;
764 /* in Range while exiting */
765 if (wacom
->reporting_data
) {
766 input_report_key(input
, BTN_TOUCH
, 0);
767 input_report_abs(input
, ABS_PRESSURE
, 0);
768 input_report_abs(input
, ABS_DISTANCE
, wacom
->features
.distance_max
);
775 if ((data
[1] & 0xfe) == 0x80) {
776 wacom
->shared
->stylus_in_proximity
= false;
777 wacom
->reporting_data
= false;
779 /* don't report exit if we don't know the ID */
783 wacom_exit_report(wacom
);
790 static inline bool report_touch_events(struct wacom_wac
*wacom
)
792 return (touch_arbitration
? !wacom
->shared
->stylus_in_proximity
: 1);
795 static inline bool delay_pen_events(struct wacom_wac
*wacom
)
797 return (wacom
->shared
->touch_down
&& touch_arbitration
);
800 static int wacom_intuos_general(struct wacom_wac
*wacom
)
802 struct wacom_features
*features
= &wacom
->features
;
803 unsigned char *data
= wacom
->data
;
804 struct input_dev
*input
= wacom
->pen_input
;
805 int idx
= (features
->type
== INTUOS
) ? (data
[1] & 0x01) : 0;
806 unsigned char type
= (data
[1] >> 1) & 0x0F;
807 unsigned int x
, y
, distance
, t
;
809 if (data
[0] != WACOM_REPORT_PENABLED
&& data
[0] != WACOM_REPORT_CINTIQ
&&
810 data
[0] != WACOM_REPORT_INTUOS_PEN
)
813 if (delay_pen_events(wacom
))
816 /* don't report events if we don't know the tool ID */
817 if (!wacom
->id
[idx
]) {
818 /* but reschedule a read of the current tool */
819 wacom_intuos_schedule_prox_event(wacom
);
824 * don't report events for invalid data
826 /* older I4 styli don't work with new Cintiqs */
827 if ((!((wacom
->id
[idx
] >> 16) & 0x01) &&
828 (features
->type
== WACOM_21UX2
)) ||
829 /* Only large Intuos support Lense Cursor */
830 (wacom
->tool
[idx
] == BTN_TOOL_LENS
&&
831 (features
->type
== INTUOS3
||
832 features
->type
== INTUOS3S
||
833 features
->type
== INTUOS4
||
834 features
->type
== INTUOS4S
||
835 features
->type
== INTUOS5
||
836 features
->type
== INTUOS5S
||
837 features
->type
== INTUOSPM
||
838 features
->type
== INTUOSPS
)) ||
839 /* Cintiq doesn't send data when RDY bit isn't set */
840 (features
->type
== CINTIQ
&& !(data
[1] & 0x40)))
843 x
= (be16_to_cpup((__be16
*)&data
[2]) << 1) | ((data
[9] >> 1) & 1);
844 y
= (be16_to_cpup((__be16
*)&data
[4]) << 1) | (data
[9] & 1);
845 distance
= data
[9] >> 2;
846 if (features
->type
< INTUOS3S
) {
851 if (features
->type
== INTUOSHT2
)
852 distance
= features
->distance_max
- distance
;
853 input_report_abs(input
, ABS_X
, x
);
854 input_report_abs(input
, ABS_Y
, y
);
855 input_report_abs(input
, ABS_DISTANCE
, distance
);
862 /* general pen packet */
863 t
= (data
[6] << 3) | ((data
[7] & 0xC0) >> 5) | (data
[1] & 1);
864 if (features
->pressure_max
< 2047)
866 input_report_abs(input
, ABS_PRESSURE
, t
);
867 if (features
->type
!= INTUOSHT2
) {
868 input_report_abs(input
, ABS_TILT_X
,
869 (((data
[7] << 1) & 0x7e) | (data
[8] >> 7)) - 64);
870 input_report_abs(input
, ABS_TILT_Y
, (data
[8] & 0x7f) - 64);
872 input_report_key(input
, BTN_STYLUS
, data
[1] & 2);
873 input_report_key(input
, BTN_STYLUS2
, data
[1] & 4);
874 input_report_key(input
, BTN_TOUCH
, t
> 10);
878 /* airbrush second packet */
879 input_report_abs(input
, ABS_WHEEL
,
880 (data
[6] << 2) | ((data
[7] >> 6) & 3));
881 input_report_abs(input
, ABS_TILT_X
,
882 (((data
[7] << 1) & 0x7e) | (data
[8] >> 7)) - 64);
883 input_report_abs(input
, ABS_TILT_Y
, (data
[8] & 0x7f) - 64);
887 /* Rotation packet */
888 if (features
->type
>= INTUOS3S
) {
889 /* I3 marker pen rotation */
890 t
= (data
[6] << 3) | ((data
[7] >> 5) & 7);
891 t
= (data
[7] & 0x20) ? ((t
> 900) ? ((t
-1) / 2 - 1350) :
892 ((t
-1) / 2 + 450)) : (450 - t
/ 2) ;
893 input_report_abs(input
, ABS_Z
, t
);
895 /* 4D mouse 2nd packet */
896 t
= (data
[6] << 3) | ((data
[7] >> 5) & 7);
897 input_report_abs(input
, ABS_RZ
, (data
[7] & 0x20) ?
898 ((t
- 1) / 2) : -t
/ 2);
903 /* 4D mouse 1st packet */
904 input_report_key(input
, BTN_LEFT
, data
[8] & 0x01);
905 input_report_key(input
, BTN_MIDDLE
, data
[8] & 0x02);
906 input_report_key(input
, BTN_RIGHT
, data
[8] & 0x04);
908 input_report_key(input
, BTN_SIDE
, data
[8] & 0x20);
909 input_report_key(input
, BTN_EXTRA
, data
[8] & 0x10);
910 t
= (data
[6] << 2) | ((data
[7] >> 6) & 3);
911 input_report_abs(input
, ABS_THROTTLE
, (data
[8] & 0x08) ? -t
: t
);
916 input_report_key(input
, BTN_LEFT
, data
[6] & 0x01);
917 input_report_key(input
, BTN_MIDDLE
, data
[6] & 0x02);
918 input_report_key(input
, BTN_RIGHT
, data
[6] & 0x04);
919 input_report_rel(input
, REL_WHEEL
, ((data
[7] & 0x80) >> 7)
920 - ((data
[7] & 0x40) >> 6));
921 input_report_key(input
, BTN_SIDE
, data
[6] & 0x08);
922 input_report_key(input
, BTN_EXTRA
, data
[6] & 0x10);
924 input_report_abs(input
, ABS_TILT_X
,
925 (((data
[7] << 1) & 0x7e) | (data
[8] >> 7)) - 64);
926 input_report_abs(input
, ABS_TILT_Y
, (data
[8] & 0x7f) - 64);
930 if (wacom
->tool
[idx
] == BTN_TOOL_MOUSE
) {
931 /* 2D mouse packet */
932 input_report_key(input
, BTN_LEFT
, data
[8] & 0x04);
933 input_report_key(input
, BTN_MIDDLE
, data
[8] & 0x08);
934 input_report_key(input
, BTN_RIGHT
, data
[8] & 0x10);
935 input_report_rel(input
, REL_WHEEL
, (data
[8] & 0x01)
936 - ((data
[8] & 0x02) >> 1));
938 /* I3 2D mouse side buttons */
939 if (features
->type
>= INTUOS3S
&& features
->type
<= INTUOS3L
) {
940 input_report_key(input
, BTN_SIDE
, data
[8] & 0x40);
941 input_report_key(input
, BTN_EXTRA
, data
[8] & 0x20);
944 else if (wacom
->tool
[idx
] == BTN_TOOL_LENS
) {
945 /* Lens cursor packets */
946 input_report_key(input
, BTN_LEFT
, data
[8] & 0x01);
947 input_report_key(input
, BTN_MIDDLE
, data
[8] & 0x02);
948 input_report_key(input
, BTN_RIGHT
, data
[8] & 0x04);
949 input_report_key(input
, BTN_SIDE
, data
[8] & 0x10);
950 input_report_key(input
, BTN_EXTRA
, data
[8] & 0x08);
965 input_report_abs(input
, ABS_MISC
,
966 wacom_intuos_id_mangle(wacom
->id
[idx
])); /* report tool id */
967 input_report_key(input
, wacom
->tool
[idx
], 1);
968 input_event(input
, EV_MSC
, MSC_SERIAL
, wacom
->serial
[idx
]);
969 wacom
->reporting_data
= true;
973 static int wacom_intuos_irq(struct wacom_wac
*wacom
)
975 unsigned char *data
= wacom
->data
;
976 struct input_dev
*input
= wacom
->pen_input
;
979 if (data
[0] != WACOM_REPORT_PENABLED
&&
980 data
[0] != WACOM_REPORT_INTUOS_ID1
&&
981 data
[0] != WACOM_REPORT_INTUOS_ID2
&&
982 data
[0] != WACOM_REPORT_INTUOSPAD
&&
983 data
[0] != WACOM_REPORT_INTUOS_PEN
&&
984 data
[0] != WACOM_REPORT_CINTIQ
&&
985 data
[0] != WACOM_REPORT_CINTIQPAD
&&
986 data
[0] != WACOM_REPORT_INTUOS5PAD
) {
987 dev_dbg(input
->dev
.parent
,
988 "%s: received unknown report #%d\n", __func__
, data
[0]);
992 /* process pad events */
993 result
= wacom_intuos_pad(wacom
);
997 /* process in/out prox events */
998 result
= wacom_intuos_inout(wacom
);
1002 /* process general packets */
1003 result
= wacom_intuos_general(wacom
);
1010 static int wacom_remote_irq(struct wacom_wac
*wacom_wac
, size_t len
)
1012 unsigned char *data
= wacom_wac
->data
;
1013 struct input_dev
*input
;
1014 struct wacom
*wacom
= container_of(wacom_wac
, struct wacom
, wacom_wac
);
1015 struct wacom_remote
*remote
= wacom
->remote
;
1016 int bat_charging
, bat_percent
, touch_ring_mode
;
1019 unsigned long flags
;
1021 if (data
[0] != WACOM_REPORT_REMOTE
) {
1022 hid_dbg(wacom
->hdev
, "%s: received unknown report #%d",
1027 serial
= data
[3] + (data
[4] << 8) + (data
[5] << 16);
1028 wacom_wac
->id
[0] = PAD_DEVICE_ID
;
1030 spin_lock_irqsave(&remote
->remote_lock
, flags
);
1032 for (i
= 0; i
< WACOM_MAX_REMOTES
; i
++) {
1033 if (remote
->remotes
[i
].serial
== serial
) {
1039 if (index
< 0 || !remote
->remotes
[index
].registered
)
1042 input
= remote
->remotes
[index
].input
;
1044 input_report_key(input
, BTN_0
, (data
[9] & 0x01));
1045 input_report_key(input
, BTN_1
, (data
[9] & 0x02));
1046 input_report_key(input
, BTN_2
, (data
[9] & 0x04));
1047 input_report_key(input
, BTN_3
, (data
[9] & 0x08));
1048 input_report_key(input
, BTN_4
, (data
[9] & 0x10));
1049 input_report_key(input
, BTN_5
, (data
[9] & 0x20));
1050 input_report_key(input
, BTN_6
, (data
[9] & 0x40));
1051 input_report_key(input
, BTN_7
, (data
[9] & 0x80));
1053 input_report_key(input
, BTN_8
, (data
[10] & 0x01));
1054 input_report_key(input
, BTN_9
, (data
[10] & 0x02));
1055 input_report_key(input
, BTN_A
, (data
[10] & 0x04));
1056 input_report_key(input
, BTN_B
, (data
[10] & 0x08));
1057 input_report_key(input
, BTN_C
, (data
[10] & 0x10));
1058 input_report_key(input
, BTN_X
, (data
[10] & 0x20));
1059 input_report_key(input
, BTN_Y
, (data
[10] & 0x40));
1060 input_report_key(input
, BTN_Z
, (data
[10] & 0x80));
1062 input_report_key(input
, BTN_BASE
, (data
[11] & 0x01));
1063 input_report_key(input
, BTN_BASE2
, (data
[11] & 0x02));
1065 if (data
[12] & 0x80)
1066 input_report_abs(input
, ABS_WHEEL
, (data
[12] & 0x7f) - 1);
1068 input_report_abs(input
, ABS_WHEEL
, 0);
1070 bat_percent
= data
[7] & 0x7f;
1071 bat_charging
= !!(data
[7] & 0x80);
1073 if (data
[9] | data
[10] | (data
[11] & 0x03) | data
[12])
1074 input_report_abs(input
, ABS_MISC
, PAD_DEVICE_ID
);
1076 input_report_abs(input
, ABS_MISC
, 0);
1078 input_event(input
, EV_MSC
, MSC_SERIAL
, serial
);
1082 /*Which mode select (LED light) is currently on?*/
1083 touch_ring_mode
= (data
[11] & 0xC0) >> 6;
1085 for (i
= 0; i
< WACOM_MAX_REMOTES
; i
++) {
1086 if (remote
->remotes
[i
].serial
== serial
)
1087 wacom
->led
.groups
[i
].select
= touch_ring_mode
;
1090 __wacom_notify_battery(&remote
->remotes
[index
].battery
,
1091 WACOM_POWER_SUPPLY_STATUS_AUTO
, bat_percent
,
1092 bat_charging
, 1, bat_charging
);
1095 spin_unlock_irqrestore(&remote
->remote_lock
, flags
);
1099 static void wacom_remote_status_irq(struct wacom_wac
*wacom_wac
, size_t len
)
1101 struct wacom
*wacom
= container_of(wacom_wac
, struct wacom
, wacom_wac
);
1102 unsigned char *data
= wacom_wac
->data
;
1103 struct wacom_remote
*remote
= wacom
->remote
;
1104 struct wacom_remote_data remote_data
;
1105 unsigned long flags
;
1108 if (data
[0] != WACOM_REPORT_DEVICE_LIST
)
1111 memset(&remote_data
, 0, sizeof(struct wacom_remote_data
));
1113 for (i
= 0; i
< WACOM_MAX_REMOTES
; i
++) {
1115 int serial
= (data
[j
+6] << 16) + (data
[j
+5] << 8) + data
[j
+4];
1116 bool connected
= data
[j
+2];
1118 remote_data
.remote
[i
].serial
= serial
;
1119 remote_data
.remote
[i
].connected
= connected
;
1122 spin_lock_irqsave(&remote
->remote_lock
, flags
);
1124 ret
= kfifo_in(&remote
->remote_fifo
, &remote_data
, sizeof(remote_data
));
1125 if (ret
!= sizeof(remote_data
)) {
1126 spin_unlock_irqrestore(&remote
->remote_lock
, flags
);
1127 hid_err(wacom
->hdev
, "Can't queue Remote status event.\n");
1131 spin_unlock_irqrestore(&remote
->remote_lock
, flags
);
1133 wacom_schedule_work(wacom_wac
, WACOM_WORKER_REMOTE
);
1136 static int int_dist(int x1
, int y1
, int x2
, int y2
)
1141 return int_sqrt(x
*x
+ y
*y
);
1144 static void wacom_intuos_bt_process_data(struct wacom_wac
*wacom
,
1145 unsigned char *data
)
1147 memcpy(wacom
->data
, data
, 10);
1148 wacom_intuos_irq(wacom
);
1150 input_sync(wacom
->pen_input
);
1151 if (wacom
->pad_input
)
1152 input_sync(wacom
->pad_input
);
1155 static int wacom_intuos_bt_irq(struct wacom_wac
*wacom
, size_t len
)
1157 unsigned char data
[WACOM_PKGLEN_MAX
];
1159 unsigned power_raw
, battery_capacity
, bat_charging
, ps_connected
;
1161 memcpy(data
, wacom
->data
, len
);
1165 wacom_intuos_bt_process_data(wacom
, data
+ i
);
1169 wacom_intuos_bt_process_data(wacom
, data
+ i
);
1171 wacom_intuos_bt_process_data(wacom
, data
+ i
);
1173 power_raw
= data
[i
];
1174 bat_charging
= (power_raw
& 0x08) ? 1 : 0;
1175 ps_connected
= (power_raw
& 0x10) ? 1 : 0;
1176 battery_capacity
= batcap_i4
[power_raw
& 0x07];
1177 wacom_notify_battery(wacom
, WACOM_POWER_SUPPLY_STATUS_AUTO
,
1178 battery_capacity
, bat_charging
,
1179 battery_capacity
|| bat_charging
,
1183 dev_dbg(wacom
->pen_input
->dev
.parent
,
1184 "Unknown report: %d,%d size:%zu\n",
1185 data
[0], data
[1], len
);
1191 static int wacom_wac_finger_count_touches(struct wacom_wac
*wacom
)
1193 struct input_dev
*input
= wacom
->touch_input
;
1194 unsigned touch_max
= wacom
->features
.touch_max
;
1202 return test_bit(BTN_TOUCH
, input
->key
) &&
1203 report_touch_events(wacom
);
1205 for (i
= 0; i
< input
->mt
->num_slots
; i
++) {
1206 struct input_mt_slot
*ps
= &input
->mt
->slots
[i
];
1207 int id
= input_mt_get_value(ps
, ABS_MT_TRACKING_ID
);
1215 static void wacom_intuos_pro2_bt_pen(struct wacom_wac
*wacom
)
1217 int pen_frame_len
, pen_frames
;
1219 struct input_dev
*pen_input
= wacom
->pen_input
;
1220 unsigned char *data
= wacom
->data
;
1223 if (wacom
->features
.type
== INTUOSP2_BT
) {
1224 wacom
->serial
[0] = get_unaligned_le64(&data
[99]);
1225 wacom
->id
[0] = get_unaligned_le16(&data
[107]);
1229 wacom
->serial
[0] = get_unaligned_le64(&data
[33]);
1230 wacom
->id
[0] = get_unaligned_le16(&data
[41]);
1235 if (wacom
->serial
[0] >> 52 == 1) {
1236 /* Add back in missing bits of ID for non-USI pens */
1237 wacom
->id
[0] |= (wacom
->serial
[0] >> 32) & 0xFFFFF;
1240 for (i
= 0; i
< pen_frames
; i
++) {
1241 unsigned char *frame
= &data
[i
*pen_frame_len
+ 1];
1242 bool valid
= frame
[0] & 0x80;
1243 bool prox
= frame
[0] & 0x40;
1244 bool range
= frame
[0] & 0x20;
1245 bool invert
= frame
[0] & 0x10;
1251 wacom
->shared
->stylus_in_proximity
= false;
1252 wacom_exit_report(wacom
);
1253 input_sync(pen_input
);
1257 wacom
->serial
[0] = 0;
1262 if (!wacom
->tool
[0]) { /* first in range */
1263 /* Going into range select tool */
1265 wacom
->tool
[0] = BTN_TOOL_RUBBER
;
1266 else if (wacom
->id
[0])
1267 wacom
->tool
[0] = wacom_intuos_get_tool_type(wacom
->id
[0]);
1269 wacom
->tool
[0] = BTN_TOOL_PEN
;
1272 input_report_abs(pen_input
, ABS_X
, get_unaligned_le16(&frame
[1]));
1273 input_report_abs(pen_input
, ABS_Y
, get_unaligned_le16(&frame
[3]));
1275 if (wacom
->features
.type
== INTUOSP2_BT
) {
1276 /* Fix rotation alignment: userspace expects zero at left */
1278 (int16_t)get_unaligned_le16(&frame
[9]);
1284 input_report_abs(pen_input
, ABS_TILT_X
,
1286 input_report_abs(pen_input
, ABS_TILT_Y
,
1288 input_report_abs(pen_input
, ABS_Z
, rotation
);
1289 input_report_abs(pen_input
, ABS_WHEEL
,
1290 get_unaligned_le16(&frame
[11]));
1294 if (wacom
->tool
[0]) {
1295 input_report_abs(pen_input
, ABS_PRESSURE
, get_unaligned_le16(&frame
[5]));
1296 if (wacom
->features
.type
== INTUOSP2_BT
) {
1297 input_report_abs(pen_input
, ABS_DISTANCE
,
1298 range
? frame
[13] : wacom
->features
.distance_max
);
1300 input_report_abs(pen_input
, ABS_DISTANCE
,
1301 range
? frame
[7] : wacom
->features
.distance_max
);
1304 input_report_key(pen_input
, BTN_TOUCH
, frame
[0] & 0x09);
1305 input_report_key(pen_input
, BTN_STYLUS
, frame
[0] & 0x02);
1306 input_report_key(pen_input
, BTN_STYLUS2
, frame
[0] & 0x04);
1308 input_report_key(pen_input
, wacom
->tool
[0], prox
);
1309 input_event(pen_input
, EV_MSC
, MSC_SERIAL
, wacom
->serial
[0]);
1310 input_report_abs(pen_input
, ABS_MISC
,
1311 wacom_intuos_id_mangle(wacom
->id
[0])); /* report tool id */
1314 wacom
->shared
->stylus_in_proximity
= prox
;
1316 input_sync(pen_input
);
1320 static void wacom_intuos_pro2_bt_touch(struct wacom_wac
*wacom
)
1322 const int finger_touch_len
= 8;
1323 const int finger_frames
= 4;
1324 const int finger_frame_len
= 43;
1326 struct input_dev
*touch_input
= wacom
->touch_input
;
1327 unsigned char *data
= wacom
->data
;
1328 int num_contacts_left
= 5;
1331 for (i
= 0; i
< finger_frames
; i
++) {
1332 unsigned char *frame
= &data
[i
*finger_frame_len
+ 109];
1333 int current_num_contacts
= frame
[0] & 0x7F;
1334 int contacts_to_send
;
1336 if (!(frame
[0] & 0x80))
1340 * First packet resets the counter since only the first
1341 * packet in series will have non-zero current_num_contacts.
1343 if (current_num_contacts
)
1344 wacom
->num_contacts_left
= current_num_contacts
;
1346 contacts_to_send
= min(num_contacts_left
, wacom
->num_contacts_left
);
1348 for (j
= 0; j
< contacts_to_send
; j
++) {
1349 unsigned char *touch
= &frame
[j
*finger_touch_len
+ 1];
1350 int slot
= input_mt_get_slot_by_key(touch_input
, touch
[0]);
1351 int x
= get_unaligned_le16(&touch
[2]);
1352 int y
= get_unaligned_le16(&touch
[4]);
1353 int w
= touch
[6] * input_abs_get_res(touch_input
, ABS_MT_POSITION_X
);
1354 int h
= touch
[7] * input_abs_get_res(touch_input
, ABS_MT_POSITION_Y
);
1359 input_mt_slot(touch_input
, slot
);
1360 input_mt_report_slot_state(touch_input
, MT_TOOL_FINGER
, touch
[1] & 0x01);
1361 input_report_abs(touch_input
, ABS_MT_POSITION_X
, x
);
1362 input_report_abs(touch_input
, ABS_MT_POSITION_Y
, y
);
1363 input_report_abs(touch_input
, ABS_MT_TOUCH_MAJOR
, max(w
, h
));
1364 input_report_abs(touch_input
, ABS_MT_TOUCH_MINOR
, min(w
, h
));
1365 input_report_abs(touch_input
, ABS_MT_ORIENTATION
, w
> h
);
1368 input_mt_sync_frame(touch_input
);
1370 wacom
->num_contacts_left
-= contacts_to_send
;
1371 if (wacom
->num_contacts_left
<= 0) {
1372 wacom
->num_contacts_left
= 0;
1373 wacom
->shared
->touch_down
= wacom_wac_finger_count_touches(wacom
);
1374 input_sync(touch_input
);
1378 if (wacom
->num_contacts_left
== 0) {
1379 // Be careful that we don't accidentally call input_sync with
1380 // only a partial set of fingers of processed
1381 input_report_switch(touch_input
, SW_MUTE_DEVICE
, !(data
[281] >> 7));
1382 input_sync(touch_input
);
1387 static void wacom_intuos_pro2_bt_pad(struct wacom_wac
*wacom
)
1389 struct input_dev
*pad_input
= wacom
->pad_input
;
1390 unsigned char *data
= wacom
->data
;
1392 int buttons
= data
[282] | ((data
[281] & 0x40) << 2);
1393 int ring
= data
[285] & 0x7F;
1394 bool ringstatus
= data
[285] & 0x80;
1395 bool prox
= buttons
|| ringstatus
;
1397 /* Fix touchring data: userspace expects 0 at left and increasing clockwise */
1403 wacom_report_numbered_buttons(pad_input
, 9, buttons
);
1405 input_report_abs(pad_input
, ABS_WHEEL
, ringstatus
? ring
: 0);
1407 input_report_key(pad_input
, wacom
->tool
[1], prox
? 1 : 0);
1408 input_report_abs(pad_input
, ABS_MISC
, prox
? PAD_DEVICE_ID
: 0);
1409 input_event(pad_input
, EV_MSC
, MSC_SERIAL
, 0xffffffff);
1411 input_sync(pad_input
);
1414 static void wacom_intuos_pro2_bt_battery(struct wacom_wac
*wacom
)
1416 unsigned char *data
= wacom
->data
;
1418 bool chg
= data
[284] & 0x80;
1419 int battery_status
= data
[284] & 0x7F;
1421 wacom_notify_battery(wacom
, WACOM_POWER_SUPPLY_STATUS_AUTO
,
1422 battery_status
, chg
, 1, chg
);
1425 static void wacom_intuos_gen3_bt_pad(struct wacom_wac
*wacom
)
1427 struct input_dev
*pad_input
= wacom
->pad_input
;
1428 unsigned char *data
= wacom
->data
;
1430 int buttons
= data
[44];
1432 wacom_report_numbered_buttons(pad_input
, 4, buttons
);
1434 input_report_key(pad_input
, wacom
->tool
[1], buttons
? 1 : 0);
1435 input_report_abs(pad_input
, ABS_MISC
, buttons
? PAD_DEVICE_ID
: 0);
1436 input_event(pad_input
, EV_MSC
, MSC_SERIAL
, 0xffffffff);
1438 input_sync(pad_input
);
1441 static void wacom_intuos_gen3_bt_battery(struct wacom_wac
*wacom
)
1443 unsigned char *data
= wacom
->data
;
1445 bool chg
= data
[45] & 0x80;
1446 int battery_status
= data
[45] & 0x7F;
1448 wacom_notify_battery(wacom
, WACOM_POWER_SUPPLY_STATUS_AUTO
,
1449 battery_status
, chg
, 1, chg
);
1452 static int wacom_intuos_pro2_bt_irq(struct wacom_wac
*wacom
, size_t len
)
1454 unsigned char *data
= wacom
->data
;
1456 if (data
[0] != 0x80 && data
[0] != 0x81) {
1457 dev_dbg(wacom
->pen_input
->dev
.parent
,
1458 "%s: received unknown report #%d\n", __func__
, data
[0]);
1462 wacom_intuos_pro2_bt_pen(wacom
);
1463 if (wacom
->features
.type
== INTUOSP2_BT
) {
1464 wacom_intuos_pro2_bt_touch(wacom
);
1465 wacom_intuos_pro2_bt_pad(wacom
);
1466 wacom_intuos_pro2_bt_battery(wacom
);
1468 wacom_intuos_gen3_bt_pad(wacom
);
1469 wacom_intuos_gen3_bt_battery(wacom
);
1474 static int wacom_24hdt_irq(struct wacom_wac
*wacom
)
1476 struct input_dev
*input
= wacom
->touch_input
;
1477 unsigned char *data
= wacom
->data
;
1479 int current_num_contacts
= data
[61];
1480 int contacts_to_send
= 0;
1481 int num_contacts_left
= 4; /* maximum contacts per packet */
1482 int byte_per_packet
= WACOM_BYTES_PER_24HDT_PACKET
;
1485 if (wacom
->features
.type
== WACOM_27QHDT
) {
1486 current_num_contacts
= data
[63];
1487 num_contacts_left
= 10;
1488 byte_per_packet
= WACOM_BYTES_PER_QHDTHID_PACKET
;
1493 * First packet resets the counter since only the first
1494 * packet in series will have non-zero current_num_contacts.
1496 if (current_num_contacts
)
1497 wacom
->num_contacts_left
= current_num_contacts
;
1499 contacts_to_send
= min(num_contacts_left
, wacom
->num_contacts_left
);
1501 for (i
= 0; i
< contacts_to_send
; i
++) {
1502 int offset
= (byte_per_packet
* i
) + 1;
1503 bool touch
= (data
[offset
] & 0x1) && report_touch_events(wacom
);
1504 int slot
= input_mt_get_slot_by_key(input
, data
[offset
+ 1]);
1508 input_mt_slot(input
, slot
);
1509 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, touch
);
1512 int t_x
= get_unaligned_le16(&data
[offset
+ 2]);
1513 int t_y
= get_unaligned_le16(&data
[offset
+ 4 + y_offset
]);
1515 input_report_abs(input
, ABS_MT_POSITION_X
, t_x
);
1516 input_report_abs(input
, ABS_MT_POSITION_Y
, t_y
);
1518 if (wacom
->features
.type
!= WACOM_27QHDT
) {
1519 int c_x
= get_unaligned_le16(&data
[offset
+ 4]);
1520 int c_y
= get_unaligned_le16(&data
[offset
+ 8]);
1521 int w
= get_unaligned_le16(&data
[offset
+ 10]);
1522 int h
= get_unaligned_le16(&data
[offset
+ 12]);
1524 input_report_abs(input
, ABS_MT_TOUCH_MAJOR
, min(w
,h
));
1525 input_report_abs(input
, ABS_MT_WIDTH_MAJOR
,
1526 min(w
, h
) + int_dist(t_x
, t_y
, c_x
, c_y
));
1527 input_report_abs(input
, ABS_MT_WIDTH_MINOR
, min(w
, h
));
1528 input_report_abs(input
, ABS_MT_ORIENTATION
, w
> h
);
1532 input_mt_sync_frame(input
);
1534 wacom
->num_contacts_left
-= contacts_to_send
;
1535 if (wacom
->num_contacts_left
<= 0) {
1536 wacom
->num_contacts_left
= 0;
1537 wacom
->shared
->touch_down
= wacom_wac_finger_count_touches(wacom
);
1542 static int wacom_mt_touch(struct wacom_wac
*wacom
)
1544 struct input_dev
*input
= wacom
->touch_input
;
1545 unsigned char *data
= wacom
->data
;
1547 int current_num_contacts
= data
[2];
1548 int contacts_to_send
= 0;
1551 /* MTTPC does not support Height and Width */
1552 if (wacom
->features
.type
== MTTPC
|| wacom
->features
.type
== MTTPC_B
)
1556 * First packet resets the counter since only the first
1557 * packet in series will have non-zero current_num_contacts.
1559 if (current_num_contacts
)
1560 wacom
->num_contacts_left
= current_num_contacts
;
1562 /* There are at most 5 contacts per packet */
1563 contacts_to_send
= min(5, wacom
->num_contacts_left
);
1565 for (i
= 0; i
< contacts_to_send
; i
++) {
1566 int offset
= (WACOM_BYTES_PER_MT_PACKET
+ x_offset
) * i
+ 3;
1567 bool touch
= (data
[offset
] & 0x1) && report_touch_events(wacom
);
1568 int id
= get_unaligned_le16(&data
[offset
+ 1]);
1569 int slot
= input_mt_get_slot_by_key(input
, id
);
1574 input_mt_slot(input
, slot
);
1575 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, touch
);
1577 int x
= get_unaligned_le16(&data
[offset
+ x_offset
+ 7]);
1578 int y
= get_unaligned_le16(&data
[offset
+ x_offset
+ 9]);
1579 input_report_abs(input
, ABS_MT_POSITION_X
, x
);
1580 input_report_abs(input
, ABS_MT_POSITION_Y
, y
);
1583 input_mt_sync_frame(input
);
1585 wacom
->num_contacts_left
-= contacts_to_send
;
1586 if (wacom
->num_contacts_left
<= 0) {
1587 wacom
->num_contacts_left
= 0;
1588 wacom
->shared
->touch_down
= wacom_wac_finger_count_touches(wacom
);
1593 static int wacom_tpc_mt_touch(struct wacom_wac
*wacom
)
1595 struct input_dev
*input
= wacom
->touch_input
;
1596 unsigned char *data
= wacom
->data
;
1599 for (i
= 0; i
< 2; i
++) {
1600 int p
= data
[1] & (1 << i
);
1601 bool touch
= p
&& report_touch_events(wacom
);
1603 input_mt_slot(input
, i
);
1604 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, touch
);
1606 int x
= le16_to_cpup((__le16
*)&data
[i
* 2 + 2]) & 0x7fff;
1607 int y
= le16_to_cpup((__le16
*)&data
[i
* 2 + 6]) & 0x7fff;
1609 input_report_abs(input
, ABS_MT_POSITION_X
, x
);
1610 input_report_abs(input
, ABS_MT_POSITION_Y
, y
);
1613 input_mt_sync_frame(input
);
1615 /* keep touch state for pen event */
1616 wacom
->shared
->touch_down
= wacom_wac_finger_count_touches(wacom
);
1621 static int wacom_tpc_single_touch(struct wacom_wac
*wacom
, size_t len
)
1623 unsigned char *data
= wacom
->data
;
1624 struct input_dev
*input
= wacom
->touch_input
;
1625 bool prox
= report_touch_events(wacom
);
1628 if (wacom
->features
.touch_max
> 1 || len
> WACOM_PKGLEN_TPC2FG
)
1631 if (len
== WACOM_PKGLEN_TPC1FG
) {
1632 prox
= prox
&& (data
[0] & 0x01);
1633 x
= get_unaligned_le16(&data
[1]);
1634 y
= get_unaligned_le16(&data
[3]);
1635 } else if (len
== WACOM_PKGLEN_TPC1FG_B
) {
1636 prox
= prox
&& (data
[2] & 0x01);
1637 x
= get_unaligned_le16(&data
[3]);
1638 y
= get_unaligned_le16(&data
[5]);
1640 prox
= prox
&& (data
[1] & 0x01);
1641 x
= le16_to_cpup((__le16
*)&data
[2]);
1642 y
= le16_to_cpup((__le16
*)&data
[4]);
1646 input_report_abs(input
, ABS_X
, x
);
1647 input_report_abs(input
, ABS_Y
, y
);
1649 input_report_key(input
, BTN_TOUCH
, prox
);
1651 /* keep touch state for pen events */
1652 wacom
->shared
->touch_down
= prox
;
1657 static int wacom_tpc_pen(struct wacom_wac
*wacom
)
1659 unsigned char *data
= wacom
->data
;
1660 struct input_dev
*input
= wacom
->pen_input
;
1661 bool prox
= data
[1] & 0x20;
1663 if (!wacom
->shared
->stylus_in_proximity
) /* first in prox */
1664 /* Going into proximity select tool */
1665 wacom
->tool
[0] = (data
[1] & 0x0c) ? BTN_TOOL_RUBBER
: BTN_TOOL_PEN
;
1667 /* keep pen state for touch events */
1668 wacom
->shared
->stylus_in_proximity
= prox
;
1670 /* send pen events only when touch is up or forced out
1671 * or touch arbitration is off
1673 if (!delay_pen_events(wacom
)) {
1674 input_report_key(input
, BTN_STYLUS
, data
[1] & 0x02);
1675 input_report_key(input
, BTN_STYLUS2
, data
[1] & 0x10);
1676 input_report_abs(input
, ABS_X
, le16_to_cpup((__le16
*)&data
[2]));
1677 input_report_abs(input
, ABS_Y
, le16_to_cpup((__le16
*)&data
[4]));
1678 input_report_abs(input
, ABS_PRESSURE
, ((data
[7] & 0x07) << 8) | data
[6]);
1679 input_report_key(input
, BTN_TOUCH
, data
[1] & 0x05);
1680 input_report_key(input
, wacom
->tool
[0], prox
);
1687 static int wacom_tpc_irq(struct wacom_wac
*wacom
, size_t len
)
1689 unsigned char *data
= wacom
->data
;
1691 if (wacom
->pen_input
) {
1692 dev_dbg(wacom
->pen_input
->dev
.parent
,
1693 "%s: received report #%d\n", __func__
, data
[0]);
1695 if (len
== WACOM_PKGLEN_PENABLED
||
1696 data
[0] == WACOM_REPORT_PENABLED
)
1697 return wacom_tpc_pen(wacom
);
1699 else if (wacom
->touch_input
) {
1700 dev_dbg(wacom
->touch_input
->dev
.parent
,
1701 "%s: received report #%d\n", __func__
, data
[0]);
1704 case WACOM_PKGLEN_TPC1FG
:
1705 return wacom_tpc_single_touch(wacom
, len
);
1707 case WACOM_PKGLEN_TPC2FG
:
1708 return wacom_tpc_mt_touch(wacom
);
1712 case WACOM_REPORT_TPC1FG
:
1713 case WACOM_REPORT_TPCHID
:
1714 case WACOM_REPORT_TPCST
:
1715 case WACOM_REPORT_TPC1FGE
:
1716 return wacom_tpc_single_touch(wacom
, len
);
1718 case WACOM_REPORT_TPCMT
:
1719 case WACOM_REPORT_TPCMT2
:
1720 return wacom_mt_touch(wacom
);
1729 static int wacom_offset_rotation(struct input_dev
*input
, struct hid_usage
*usage
,
1730 int value
, int num
, int denom
)
1732 struct input_absinfo
*abs
= &input
->absinfo
[usage
->code
];
1733 int range
= (abs
->maximum
- abs
->minimum
+ 1);
1735 value
+= num
*range
/denom
;
1736 if (value
> abs
->maximum
)
1738 else if (value
< abs
->minimum
)
1743 int wacom_equivalent_usage(int usage
)
1745 if ((usage
& HID_USAGE_PAGE
) == WACOM_HID_UP_WACOMDIGITIZER
) {
1746 int subpage
= (usage
& 0xFF00) << 8;
1747 int subusage
= (usage
& 0xFF);
1749 if (subpage
== WACOM_HID_SP_PAD
||
1750 subpage
== WACOM_HID_SP_BUTTON
||
1751 subpage
== WACOM_HID_SP_DIGITIZER
||
1752 subpage
== WACOM_HID_SP_DIGITIZERINFO
||
1753 usage
== WACOM_HID_WD_SENSE
||
1754 usage
== WACOM_HID_WD_SERIALHI
||
1755 usage
== WACOM_HID_WD_TOOLTYPE
||
1756 usage
== WACOM_HID_WD_DISTANCE
||
1757 usage
== WACOM_HID_WD_TOUCHSTRIP
||
1758 usage
== WACOM_HID_WD_TOUCHSTRIP2
||
1759 usage
== WACOM_HID_WD_TOUCHRING
||
1760 usage
== WACOM_HID_WD_TOUCHRINGSTATUS
||
1761 usage
== WACOM_HID_WD_REPORT_VALID
) {
1765 if (subpage
== HID_UP_UNDEFINED
)
1766 subpage
= HID_UP_DIGITIZER
;
1768 return subpage
| subusage
;
1771 if ((usage
& HID_USAGE_PAGE
) == WACOM_HID_UP_WACOMTOUCH
) {
1772 int subpage
= (usage
& 0xFF00) << 8;
1773 int subusage
= (usage
& 0xFF);
1775 if (subpage
== HID_UP_UNDEFINED
)
1776 subpage
= WACOM_HID_SP_DIGITIZER
;
1778 return subpage
| subusage
;
1784 static void wacom_map_usage(struct input_dev
*input
, struct hid_usage
*usage
,
1785 struct hid_field
*field
, __u8 type
, __u16 code
, int fuzz
)
1787 struct wacom
*wacom
= input_get_drvdata(input
);
1788 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1789 struct wacom_features
*features
= &wacom_wac
->features
;
1790 int fmin
= field
->logical_minimum
;
1791 int fmax
= field
->logical_maximum
;
1792 unsigned int equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
1793 int resolution_code
= code
;
1795 if (equivalent_usage
== HID_DG_TWIST
) {
1796 resolution_code
= ABS_RZ
;
1799 if (equivalent_usage
== HID_GD_X
) {
1800 fmin
+= features
->offset_left
;
1801 fmax
-= features
->offset_right
;
1803 if (equivalent_usage
== HID_GD_Y
) {
1804 fmin
+= features
->offset_top
;
1805 fmax
-= features
->offset_bottom
;
1811 set_bit(type
, input
->evbit
);
1815 input_set_abs_params(input
, code
, fmin
, fmax
, fuzz
, 0);
1816 input_abs_set_res(input
, code
,
1817 hidinput_calc_abs_res(field
, resolution_code
));
1820 input_set_capability(input
, EV_KEY
, code
);
1823 input_set_capability(input
, EV_MSC
, code
);
1826 input_set_capability(input
, EV_SW
, code
);
1831 static void wacom_wac_battery_usage_mapping(struct hid_device
*hdev
,
1832 struct hid_field
*field
, struct hid_usage
*usage
)
1834 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1835 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1836 struct wacom_features
*features
= &wacom_wac
->features
;
1837 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
1839 switch (equivalent_usage
) {
1840 case HID_DG_BATTERYSTRENGTH
:
1841 case WACOM_HID_WD_BATTERY_LEVEL
:
1842 case WACOM_HID_WD_BATTERY_CHARGING
:
1843 features
->quirks
|= WACOM_QUIRK_BATTERY
;
1848 static void wacom_wac_battery_event(struct hid_device
*hdev
, struct hid_field
*field
,
1849 struct hid_usage
*usage
, __s32 value
)
1851 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1852 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1853 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
1855 switch (equivalent_usage
) {
1856 case HID_DG_BATTERYSTRENGTH
:
1858 wacom_wac
->hid_data
.bat_status
= POWER_SUPPLY_STATUS_UNKNOWN
;
1861 value
= value
* 100 / (field
->logical_maximum
- field
->logical_minimum
);
1862 wacom_wac
->hid_data
.battery_capacity
= value
;
1863 wacom_wac
->hid_data
.bat_connected
= 1;
1864 wacom_wac
->hid_data
.bat_status
= WACOM_POWER_SUPPLY_STATUS_AUTO
;
1867 case WACOM_HID_WD_BATTERY_LEVEL
:
1868 value
= value
* 100 / (field
->logical_maximum
- field
->logical_minimum
);
1869 wacom_wac
->hid_data
.battery_capacity
= value
;
1870 wacom_wac
->hid_data
.bat_connected
= 1;
1871 wacom_wac
->hid_data
.bat_status
= WACOM_POWER_SUPPLY_STATUS_AUTO
;
1873 case WACOM_HID_WD_BATTERY_CHARGING
:
1874 wacom_wac
->hid_data
.bat_charging
= value
;
1875 wacom_wac
->hid_data
.ps_connected
= value
;
1876 wacom_wac
->hid_data
.bat_connected
= 1;
1877 wacom_wac
->hid_data
.bat_status
= WACOM_POWER_SUPPLY_STATUS_AUTO
;
1882 static void wacom_wac_battery_pre_report(struct hid_device
*hdev
,
1883 struct hid_report
*report
)
1888 static void wacom_wac_battery_report(struct hid_device
*hdev
,
1889 struct hid_report
*report
)
1891 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1892 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1893 struct wacom_features
*features
= &wacom_wac
->features
;
1895 if (features
->quirks
& WACOM_QUIRK_BATTERY
) {
1896 int status
= wacom_wac
->hid_data
.bat_status
;
1897 int capacity
= wacom_wac
->hid_data
.battery_capacity
;
1898 bool charging
= wacom_wac
->hid_data
.bat_charging
;
1899 bool connected
= wacom_wac
->hid_data
.bat_connected
;
1900 bool powered
= wacom_wac
->hid_data
.ps_connected
;
1902 wacom_notify_battery(wacom_wac
, status
, capacity
, charging
,
1903 connected
, powered
);
1907 static void wacom_wac_pad_usage_mapping(struct hid_device
*hdev
,
1908 struct hid_field
*field
, struct hid_usage
*usage
)
1910 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1911 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1912 struct wacom_features
*features
= &wacom_wac
->features
;
1913 struct input_dev
*input
= wacom_wac
->pad_input
;
1914 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
1916 switch (equivalent_usage
) {
1917 case WACOM_HID_WD_ACCELEROMETER_X
:
1918 __set_bit(INPUT_PROP_ACCELEROMETER
, input
->propbit
);
1919 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_X
, 0);
1920 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1922 case WACOM_HID_WD_ACCELEROMETER_Y
:
1923 __set_bit(INPUT_PROP_ACCELEROMETER
, input
->propbit
);
1924 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_Y
, 0);
1925 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1927 case WACOM_HID_WD_ACCELEROMETER_Z
:
1928 __set_bit(INPUT_PROP_ACCELEROMETER
, input
->propbit
);
1929 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_Z
, 0);
1930 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1932 case WACOM_HID_WD_BUTTONCENTER
:
1933 case WACOM_HID_WD_BUTTONHOME
:
1934 case WACOM_HID_WD_BUTTONUP
:
1935 case WACOM_HID_WD_BUTTONDOWN
:
1936 case WACOM_HID_WD_BUTTONLEFT
:
1937 case WACOM_HID_WD_BUTTONRIGHT
:
1938 wacom_map_usage(input
, usage
, field
, EV_KEY
,
1939 wacom_numbered_button_to_key(features
->numbered_buttons
),
1941 features
->numbered_buttons
++;
1942 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1944 case WACOM_HID_WD_TOUCHONOFF
:
1945 case WACOM_HID_WD_MUTE_DEVICE
:
1947 * This usage, which is used to mute touch events, comes
1948 * from the pad packet, but is reported on the touch
1949 * interface. Because the touch interface may not have
1950 * been created yet, we cannot call wacom_map_usage(). In
1951 * order to process this usage when we receive it, we set
1952 * the usage type and code directly.
1954 wacom_wac
->has_mute_touch_switch
= true;
1955 usage
->type
= EV_SW
;
1956 usage
->code
= SW_MUTE_DEVICE
;
1957 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1959 case WACOM_HID_WD_TOUCHSTRIP
:
1960 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_RX
, 0);
1961 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1963 case WACOM_HID_WD_TOUCHSTRIP2
:
1964 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_RY
, 0);
1965 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1967 case WACOM_HID_WD_TOUCHRING
:
1968 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_WHEEL
, 0);
1969 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1971 case WACOM_HID_WD_TOUCHRINGSTATUS
:
1973 * Only set up type/code association. Completely mapping
1974 * this usage may overwrite the axis resolution and range.
1976 usage
->type
= EV_ABS
;
1977 usage
->code
= ABS_WHEEL
;
1978 set_bit(EV_ABS
, input
->evbit
);
1979 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1981 case WACOM_HID_WD_BUTTONCONFIG
:
1982 wacom_map_usage(input
, usage
, field
, EV_KEY
, KEY_BUTTONCONFIG
, 0);
1983 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1985 case WACOM_HID_WD_ONSCREEN_KEYBOARD
:
1986 wacom_map_usage(input
, usage
, field
, EV_KEY
, KEY_ONSCREEN_KEYBOARD
, 0);
1987 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1989 case WACOM_HID_WD_CONTROLPANEL
:
1990 wacom_map_usage(input
, usage
, field
, EV_KEY
, KEY_CONTROLPANEL
, 0);
1991 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1993 case WACOM_HID_WD_MODE_CHANGE
:
1994 /* do not overwrite previous data */
1995 if (!wacom_wac
->has_mode_change
) {
1996 wacom_wac
->has_mode_change
= true;
1997 wacom_wac
->is_direct_mode
= true;
1999 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
2003 switch (equivalent_usage
& 0xfffffff0) {
2004 case WACOM_HID_WD_EXPRESSKEY00
:
2005 wacom_map_usage(input
, usage
, field
, EV_KEY
,
2006 wacom_numbered_button_to_key(features
->numbered_buttons
),
2008 features
->numbered_buttons
++;
2009 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
2014 static void wacom_wac_pad_event(struct hid_device
*hdev
, struct hid_field
*field
,
2015 struct hid_usage
*usage
, __s32 value
)
2017 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2018 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2019 struct input_dev
*input
= wacom_wac
->pad_input
;
2020 struct wacom_features
*features
= &wacom_wac
->features
;
2021 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
2023 bool do_report
= false;
2026 * Avoid reporting this event and setting inrange_state if this usage
2027 * hasn't been mapped.
2029 if (!usage
->type
&& equivalent_usage
!= WACOM_HID_WD_MODE_CHANGE
)
2032 if (wacom_equivalent_usage(field
->physical
) == HID_DG_TABLETFUNCTIONKEY
) {
2033 if (usage
->hid
!= WACOM_HID_WD_TOUCHRING
)
2034 wacom_wac
->hid_data
.inrange_state
|= value
;
2037 switch (equivalent_usage
) {
2038 case WACOM_HID_WD_TOUCHRING
:
2040 * Userspace expects touchrings to increase in value with
2041 * clockwise gestures and have their zero point at the
2042 * tablet's left. HID events "should" be clockwise-
2043 * increasing and zero at top, though the MobileStudio
2044 * Pro and 2nd-gen Intuos Pro don't do this...
2046 if (hdev
->vendor
== 0x56a &&
2047 (hdev
->product
== 0x34d || hdev
->product
== 0x34e || /* MobileStudio Pro */
2048 hdev
->product
== 0x357 || hdev
->product
== 0x358)) { /* Intuos Pro 2 */
2049 value
= (field
->logical_maximum
- value
);
2051 if (hdev
->product
== 0x357 || hdev
->product
== 0x358)
2052 value
= wacom_offset_rotation(input
, usage
, value
, 3, 16);
2053 else if (hdev
->product
== 0x34d || hdev
->product
== 0x34e)
2054 value
= wacom_offset_rotation(input
, usage
, value
, 1, 2);
2057 value
= wacom_offset_rotation(input
, usage
, value
, 1, 4);
2061 case WACOM_HID_WD_TOUCHRINGSTATUS
:
2063 input_event(input
, usage
->type
, usage
->code
, 0);
2066 case WACOM_HID_WD_MUTE_DEVICE
:
2067 case WACOM_HID_WD_TOUCHONOFF
:
2068 if (wacom_wac
->shared
->touch_input
) {
2069 bool *is_touch_on
= &wacom_wac
->shared
->is_touch_on
;
2071 if (equivalent_usage
== WACOM_HID_WD_MUTE_DEVICE
&& value
)
2072 *is_touch_on
= !(*is_touch_on
);
2073 else if (equivalent_usage
== WACOM_HID_WD_TOUCHONOFF
)
2074 *is_touch_on
= value
;
2076 input_report_switch(wacom_wac
->shared
->touch_input
,
2077 SW_MUTE_DEVICE
, !(*is_touch_on
));
2078 input_sync(wacom_wac
->shared
->touch_input
);
2082 case WACOM_HID_WD_MODE_CHANGE
:
2083 if (wacom_wac
->is_direct_mode
!= value
) {
2084 wacom_wac
->is_direct_mode
= value
;
2085 wacom_schedule_work(&wacom
->wacom_wac
, WACOM_WORKER_MODE_CHANGE
);
2089 case WACOM_HID_WD_BUTTONCENTER
:
2090 for (i
= 0; i
< wacom
->led
.count
; i
++)
2091 wacom_update_led(wacom
, features
->numbered_buttons
,
2100 input_event(input
, usage
->type
, usage
->code
, value
);
2102 wacom_wac
->hid_data
.pad_input_event_flag
= true;
2106 static void wacom_wac_pad_pre_report(struct hid_device
*hdev
,
2107 struct hid_report
*report
)
2109 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2110 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2112 wacom_wac
->hid_data
.inrange_state
= 0;
2115 static void wacom_wac_pad_report(struct hid_device
*hdev
,
2116 struct hid_report
*report
, struct hid_field
*field
)
2118 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2119 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2120 struct input_dev
*input
= wacom_wac
->pad_input
;
2121 bool active
= wacom_wac
->hid_data
.inrange_state
!= 0;
2123 /* report prox for expresskey events */
2124 if (wacom_wac
->hid_data
.pad_input_event_flag
) {
2125 input_event(input
, EV_ABS
, ABS_MISC
, active
? PAD_DEVICE_ID
: 0);
2128 wacom_wac
->hid_data
.pad_input_event_flag
= false;
2132 static void wacom_wac_pen_usage_mapping(struct hid_device
*hdev
,
2133 struct hid_field
*field
, struct hid_usage
*usage
)
2135 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2136 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2137 struct wacom_features
*features
= &wacom_wac
->features
;
2138 struct input_dev
*input
= wacom_wac
->pen_input
;
2139 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
2141 switch (equivalent_usage
) {
2143 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_X
, 4);
2146 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_Y
, 4);
2148 case WACOM_HID_WD_DISTANCE
:
2150 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_DISTANCE
, 0);
2152 case HID_DG_TIPPRESSURE
:
2153 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_PRESSURE
, 0);
2155 case HID_DG_INRANGE
:
2156 wacom_map_usage(input
, usage
, field
, EV_KEY
, BTN_TOOL_PEN
, 0);
2159 wacom_map_usage(input
, usage
, field
, EV_KEY
,
2160 BTN_TOOL_RUBBER
, 0);
2163 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_TILT_X
, 0);
2166 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_TILT_Y
, 0);
2169 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_Z
, 0);
2172 case HID_DG_TIPSWITCH
:
2173 wacom_map_usage(input
, usage
, field
, EV_KEY
, BTN_TOUCH
, 0);
2175 case HID_DG_BARRELSWITCH
:
2176 wacom_map_usage(input
, usage
, field
, EV_KEY
, BTN_STYLUS
, 0);
2178 case HID_DG_BARRELSWITCH2
:
2179 wacom_map_usage(input
, usage
, field
, EV_KEY
, BTN_STYLUS2
, 0);
2181 case HID_DG_TOOLSERIALNUMBER
:
2182 features
->quirks
|= WACOM_QUIRK_TOOLSERIAL
;
2183 wacom_map_usage(input
, usage
, field
, EV_MSC
, MSC_SERIAL
, 0);
2185 /* Adjust AES usages to match modern convention */
2186 if (usage
->hid
== WACOM_HID_WT_SERIALNUMBER
&& field
->report_size
== 16) {
2187 if (field
->index
+ 2 < field
->report
->maxfield
) {
2188 struct hid_field
*a
= field
->report
->field
[field
->index
+ 1];
2189 struct hid_field
*b
= field
->report
->field
[field
->index
+ 2];
2191 if (a
->maxusage
> 0 && a
->usage
[0].hid
== HID_DG_TOOLSERIALNUMBER
&& a
->report_size
== 32 &&
2192 b
->maxusage
> 0 && b
->usage
[0].hid
== 0xFF000000 && b
->report_size
== 8) {
2193 features
->quirks
|= WACOM_QUIRK_AESPEN
;
2194 usage
->hid
= WACOM_HID_WD_TOOLTYPE
;
2195 field
->logical_minimum
= S16_MIN
;
2196 field
->logical_maximum
= S16_MAX
;
2197 a
->logical_minimum
= S32_MIN
;
2198 a
->logical_maximum
= S32_MAX
;
2199 b
->usage
[0].hid
= WACOM_HID_WD_SERIALHI
;
2200 b
->logical_minimum
= 0;
2201 b
->logical_maximum
= U8_MAX
;
2206 case WACOM_HID_WD_SENSE
:
2207 features
->quirks
|= WACOM_QUIRK_SENSE
;
2208 wacom_map_usage(input
, usage
, field
, EV_KEY
, BTN_TOOL_PEN
, 0);
2210 case WACOM_HID_WD_SERIALHI
:
2211 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_MISC
, 0);
2213 if (!(features
->quirks
& WACOM_QUIRK_AESPEN
)) {
2214 set_bit(EV_KEY
, input
->evbit
);
2215 input_set_capability(input
, EV_KEY
, BTN_TOOL_PEN
);
2216 input_set_capability(input
, EV_KEY
, BTN_TOOL_RUBBER
);
2217 input_set_capability(input
, EV_KEY
, BTN_TOOL_BRUSH
);
2218 input_set_capability(input
, EV_KEY
, BTN_TOOL_PENCIL
);
2219 input_set_capability(input
, EV_KEY
, BTN_TOOL_AIRBRUSH
);
2220 if (!(features
->device_type
& WACOM_DEVICETYPE_DIRECT
)) {
2221 input_set_capability(input
, EV_KEY
, BTN_TOOL_MOUSE
);
2222 input_set_capability(input
, EV_KEY
, BTN_TOOL_LENS
);
2226 case WACOM_HID_WD_FINGERWHEEL
:
2227 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_WHEEL
, 0);
2232 static void wacom_wac_pen_event(struct hid_device
*hdev
, struct hid_field
*field
,
2233 struct hid_usage
*usage
, __s32 value
)
2235 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2236 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2237 struct wacom_features
*features
= &wacom_wac
->features
;
2238 struct input_dev
*input
= wacom_wac
->pen_input
;
2239 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
2241 if (wacom_wac
->is_invalid_bt_frame
)
2244 switch (equivalent_usage
) {
2247 * HID_GD_Z "should increase as the control's position is
2248 * moved from high to low", while ABS_DISTANCE instead
2249 * increases in value as the tool moves from low to high.
2251 value
= field
->logical_maximum
- value
;
2253 case HID_DG_INRANGE
:
2254 wacom_wac
->hid_data
.inrange_state
= value
;
2255 if (!(features
->quirks
& WACOM_QUIRK_SENSE
))
2256 wacom_wac
->hid_data
.sense_state
= value
;
2259 wacom_wac
->hid_data
.invert_state
= value
;
2262 case HID_DG_TIPSWITCH
:
2263 wacom_wac
->hid_data
.tipswitch
|= value
;
2265 case HID_DG_BARRELSWITCH
:
2266 wacom_wac
->hid_data
.barrelswitch
= value
;
2268 case HID_DG_BARRELSWITCH2
:
2269 wacom_wac
->hid_data
.barrelswitch2
= value
;
2271 case HID_DG_TOOLSERIALNUMBER
:
2273 wacom_wac
->serial
[0] = (wacom_wac
->serial
[0] & ~0xFFFFFFFFULL
);
2274 wacom_wac
->serial
[0] |= wacom_s32tou(value
, field
->report_size
);
2279 * Userspace expects pen twist to have its zero point when
2280 * the buttons/finger is on the tablet's left. HID values
2281 * are zero when buttons are toward the top.
2283 value
= wacom_offset_rotation(input
, usage
, value
, 1, 4);
2285 case WACOM_HID_WD_SENSE
:
2286 wacom_wac
->hid_data
.sense_state
= value
;
2288 case WACOM_HID_WD_SERIALHI
:
2290 __u32 raw_value
= wacom_s32tou(value
, field
->report_size
);
2292 wacom_wac
->serial
[0] = (wacom_wac
->serial
[0] & 0xFFFFFFFF);
2293 wacom_wac
->serial
[0] |= ((__u64
)raw_value
) << 32;
2295 * Non-USI EMR devices may contain additional tool type
2296 * information here. See WACOM_HID_WD_TOOLTYPE case for
2299 if (value
>> 20 == 1) {
2300 wacom_wac
->id
[0] |= raw_value
& 0xFFFFF;
2304 case WACOM_HID_WD_TOOLTYPE
:
2306 * Some devices (MobileStudio Pro, and possibly later
2307 * devices as well) do not return the complete tool
2308 * type in their WACOM_HID_WD_TOOLTYPE usage. Use a
2309 * bitwise OR so the complete value can be built
2312 wacom_wac
->id
[0] |= wacom_s32tou(value
, field
->report_size
);
2314 case WACOM_HID_WD_OFFSETLEFT
:
2315 if (features
->offset_left
&& value
!= features
->offset_left
)
2316 hid_warn(hdev
, "%s: overriding existing left offset "
2317 "%d -> %d\n", __func__
, value
,
2318 features
->offset_left
);
2319 features
->offset_left
= value
;
2321 case WACOM_HID_WD_OFFSETRIGHT
:
2322 if (features
->offset_right
&& value
!= features
->offset_right
)
2323 hid_warn(hdev
, "%s: overriding existing right offset "
2324 "%d -> %d\n", __func__
, value
,
2325 features
->offset_right
);
2326 features
->offset_right
= value
;
2328 case WACOM_HID_WD_OFFSETTOP
:
2329 if (features
->offset_top
&& value
!= features
->offset_top
)
2330 hid_warn(hdev
, "%s: overriding existing top offset "
2331 "%d -> %d\n", __func__
, value
,
2332 features
->offset_top
);
2333 features
->offset_top
= value
;
2335 case WACOM_HID_WD_OFFSETBOTTOM
:
2336 if (features
->offset_bottom
&& value
!= features
->offset_bottom
)
2337 hid_warn(hdev
, "%s: overriding existing bottom offset "
2338 "%d -> %d\n", __func__
, value
,
2339 features
->offset_bottom
);
2340 features
->offset_bottom
= value
;
2342 case WACOM_HID_WD_REPORT_VALID
:
2343 wacom_wac
->is_invalid_bt_frame
= !value
;
2347 /* send pen events only when touch is up or forced out
2348 * or touch arbitration is off
2350 if (!usage
->type
|| delay_pen_events(wacom_wac
))
2353 /* send pen events only when the pen is in range */
2354 if (wacom_wac
->hid_data
.inrange_state
)
2355 input_event(input
, usage
->type
, usage
->code
, value
);
2356 else if (wacom_wac
->shared
->stylus_in_proximity
&& !wacom_wac
->hid_data
.sense_state
)
2357 input_event(input
, usage
->type
, usage
->code
, 0);
2360 static void wacom_wac_pen_pre_report(struct hid_device
*hdev
,
2361 struct hid_report
*report
)
2363 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2364 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2366 wacom_wac
->is_invalid_bt_frame
= false;
2370 static void wacom_wac_pen_report(struct hid_device
*hdev
,
2371 struct hid_report
*report
)
2373 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2374 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2375 struct input_dev
*input
= wacom_wac
->pen_input
;
2376 bool range
= wacom_wac
->hid_data
.inrange_state
;
2377 bool sense
= wacom_wac
->hid_data
.sense_state
;
2379 if (wacom_wac
->is_invalid_bt_frame
)
2382 if (!wacom_wac
->tool
[0] && range
) { /* first in range */
2383 /* Going into range select tool */
2384 if (wacom_wac
->hid_data
.invert_state
)
2385 wacom_wac
->tool
[0] = BTN_TOOL_RUBBER
;
2386 else if (wacom_wac
->id
[0])
2387 wacom_wac
->tool
[0] = wacom_intuos_get_tool_type(wacom_wac
->id
[0]);
2389 wacom_wac
->tool
[0] = BTN_TOOL_PEN
;
2392 /* keep pen state for touch events */
2393 wacom_wac
->shared
->stylus_in_proximity
= sense
;
2395 if (!delay_pen_events(wacom_wac
) && wacom_wac
->tool
[0]) {
2396 int id
= wacom_wac
->id
[0];
2397 int sw_state
= wacom_wac
->hid_data
.barrelswitch
|
2398 (wacom_wac
->hid_data
.barrelswitch2
<< 1);
2400 input_report_key(input
, BTN_STYLUS
, sw_state
== 1);
2401 input_report_key(input
, BTN_STYLUS2
, sw_state
== 2);
2402 input_report_key(input
, BTN_STYLUS3
, sw_state
== 3);
2405 * Non-USI EMR tools should have their IDs mangled to
2406 * match the legacy behavior of wacom_intuos_general
2408 if (wacom_wac
->serial
[0] >> 52 == 1)
2409 id
= wacom_intuos_id_mangle(id
);
2412 * To ensure compatibility with xf86-input-wacom, we should
2413 * report the BTN_TOOL_* event prior to the ABS_MISC or
2414 * MSC_SERIAL events.
2416 input_report_key(input
, BTN_TOUCH
,
2417 wacom_wac
->hid_data
.tipswitch
);
2418 input_report_key(input
, wacom_wac
->tool
[0], sense
);
2419 if (wacom_wac
->serial
[0]) {
2420 input_event(input
, EV_MSC
, MSC_SERIAL
, wacom_wac
->serial
[0]);
2421 input_report_abs(input
, ABS_MISC
, sense
? id
: 0);
2424 wacom_wac
->hid_data
.tipswitch
= false;
2430 wacom_wac
->tool
[0] = 0;
2431 wacom_wac
->id
[0] = 0;
2432 wacom_wac
->serial
[0] = 0;
2436 static void wacom_wac_finger_usage_mapping(struct hid_device
*hdev
,
2437 struct hid_field
*field
, struct hid_usage
*usage
)
2439 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2440 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2441 struct input_dev
*input
= wacom_wac
->touch_input
;
2442 unsigned touch_max
= wacom_wac
->features
.touch_max
;
2443 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
2445 switch (equivalent_usage
) {
2448 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_X
, 4);
2450 wacom_map_usage(input
, usage
, field
, EV_ABS
,
2451 ABS_MT_POSITION_X
, 4);
2455 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_Y
, 4);
2457 wacom_map_usage(input
, usage
, field
, EV_ABS
,
2458 ABS_MT_POSITION_Y
, 4);
2462 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_MT_TOUCH_MAJOR
, 0);
2463 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_MT_TOUCH_MINOR
, 0);
2464 input_set_abs_params(input
, ABS_MT_ORIENTATION
, 0, 1, 0, 0);
2466 case HID_DG_TIPSWITCH
:
2467 wacom_map_usage(input
, usage
, field
, EV_KEY
, BTN_TOUCH
, 0);
2469 case HID_DG_CONTACTCOUNT
:
2470 wacom_wac
->hid_data
.cc_report
= field
->report
->id
;
2471 wacom_wac
->hid_data
.cc_index
= field
->index
;
2472 wacom_wac
->hid_data
.cc_value_index
= usage
->usage_index
;
2474 case HID_DG_CONTACTID
:
2475 if ((field
->logical_maximum
- field
->logical_minimum
) < touch_max
) {
2477 * The HID descriptor for G11 sensors leaves logical
2478 * maximum set to '1' despite it being a multitouch
2479 * device. Override to a sensible number.
2481 field
->logical_maximum
= 255;
2487 static void wacom_wac_finger_slot(struct wacom_wac
*wacom_wac
,
2488 struct input_dev
*input
)
2490 struct hid_data
*hid_data
= &wacom_wac
->hid_data
;
2491 bool mt
= wacom_wac
->features
.touch_max
> 1;
2492 bool prox
= hid_data
->tipswitch
&&
2493 report_touch_events(wacom_wac
);
2495 if (wacom_wac
->shared
->has_mute_touch_switch
&&
2496 !wacom_wac
->shared
->is_touch_on
) {
2497 if (!wacom_wac
->shared
->touch_down
)
2502 wacom_wac
->hid_data
.num_received
++;
2503 if (wacom_wac
->hid_data
.num_received
> wacom_wac
->hid_data
.num_expected
)
2509 slot
= input_mt_get_slot_by_key(input
, hid_data
->id
);
2510 input_mt_slot(input
, slot
);
2511 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, prox
);
2514 input_report_key(input
, BTN_TOUCH
, prox
);
2518 input_report_abs(input
, mt
? ABS_MT_POSITION_X
: ABS_X
,
2520 input_report_abs(input
, mt
? ABS_MT_POSITION_Y
: ABS_Y
,
2523 if (test_bit(ABS_MT_TOUCH_MAJOR
, input
->absbit
)) {
2524 input_report_abs(input
, ABS_MT_TOUCH_MAJOR
, max(hid_data
->width
, hid_data
->height
));
2525 input_report_abs(input
, ABS_MT_TOUCH_MINOR
, min(hid_data
->width
, hid_data
->height
));
2526 if (hid_data
->width
!= hid_data
->height
)
2527 input_report_abs(input
, ABS_MT_ORIENTATION
, hid_data
->width
<= hid_data
->height
? 0 : 1);
2532 static void wacom_wac_finger_event(struct hid_device
*hdev
,
2533 struct hid_field
*field
, struct hid_usage
*usage
, __s32 value
)
2535 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2536 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2537 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
2538 struct wacom_features
*features
= &wacom
->wacom_wac
.features
;
2540 switch (equivalent_usage
) {
2542 wacom_wac
->hid_data
.x
= value
;
2545 wacom_wac
->hid_data
.y
= value
;
2548 wacom_wac
->hid_data
.width
= value
;
2551 wacom_wac
->hid_data
.height
= value
;
2553 case HID_DG_CONTACTID
:
2554 wacom_wac
->hid_data
.id
= value
;
2556 case HID_DG_TIPSWITCH
:
2557 wacom_wac
->hid_data
.tipswitch
= value
;
2559 case HID_DG_CONTACTMAX
:
2560 features
->touch_max
= value
;
2565 if (usage
->usage_index
+ 1 == field
->report_count
) {
2566 if (equivalent_usage
== wacom_wac
->hid_data
.last_slot_field
)
2567 wacom_wac_finger_slot(wacom_wac
, wacom_wac
->touch_input
);
2571 static void wacom_wac_finger_pre_report(struct hid_device
*hdev
,
2572 struct hid_report
*report
)
2574 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2575 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2576 struct hid_data
* hid_data
= &wacom_wac
->hid_data
;
2579 for (i
= 0; i
< report
->maxfield
; i
++) {
2580 struct hid_field
*field
= report
->field
[i
];
2583 for (j
= 0; j
< field
->maxusage
; j
++) {
2584 struct hid_usage
*usage
= &field
->usage
[j
];
2585 unsigned int equivalent_usage
=
2586 wacom_equivalent_usage(usage
->hid
);
2588 switch (equivalent_usage
) {
2593 case HID_DG_CONTACTID
:
2594 case HID_DG_INRANGE
:
2596 case HID_DG_TIPSWITCH
:
2597 hid_data
->last_slot_field
= equivalent_usage
;
2599 case HID_DG_CONTACTCOUNT
:
2600 hid_data
->cc_report
= report
->id
;
2601 hid_data
->cc_index
= i
;
2602 hid_data
->cc_value_index
= j
;
2608 if (hid_data
->cc_report
!= 0 &&
2609 hid_data
->cc_index
>= 0) {
2610 struct hid_field
*field
= report
->field
[hid_data
->cc_index
];
2611 int value
= field
->value
[hid_data
->cc_value_index
];
2613 hid_data
->num_expected
= value
;
2616 hid_data
->num_expected
= wacom_wac
->features
.touch_max
;
2620 static void wacom_wac_finger_report(struct hid_device
*hdev
,
2621 struct hid_report
*report
)
2623 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2624 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2625 struct input_dev
*input
= wacom_wac
->touch_input
;
2626 unsigned touch_max
= wacom_wac
->features
.touch_max
;
2628 /* If more packets of data are expected, give us a chance to
2629 * process them rather than immediately syncing a partial
2632 if (wacom_wac
->hid_data
.num_received
< wacom_wac
->hid_data
.num_expected
)
2636 input_mt_sync_frame(input
);
2639 wacom_wac
->hid_data
.num_received
= 0;
2641 /* keep touch state for pen event */
2642 wacom_wac
->shared
->touch_down
= wacom_wac_finger_count_touches(wacom_wac
);
2645 void wacom_wac_usage_mapping(struct hid_device
*hdev
,
2646 struct hid_field
*field
, struct hid_usage
*usage
)
2648 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2649 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2650 struct wacom_features
*features
= &wacom_wac
->features
;
2652 if (WACOM_DIRECT_DEVICE(field
))
2653 features
->device_type
|= WACOM_DEVICETYPE_DIRECT
;
2655 /* usage tests must precede field tests */
2656 if (WACOM_BATTERY_USAGE(usage
))
2657 wacom_wac_battery_usage_mapping(hdev
, field
, usage
);
2658 else if (WACOM_PAD_FIELD(field
))
2659 wacom_wac_pad_usage_mapping(hdev
, field
, usage
);
2660 else if (WACOM_PEN_FIELD(field
))
2661 wacom_wac_pen_usage_mapping(hdev
, field
, usage
);
2662 else if (WACOM_FINGER_FIELD(field
))
2663 wacom_wac_finger_usage_mapping(hdev
, field
, usage
);
2666 void wacom_wac_event(struct hid_device
*hdev
, struct hid_field
*field
,
2667 struct hid_usage
*usage
, __s32 value
)
2669 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2671 if (wacom
->wacom_wac
.features
.type
!= HID_GENERIC
)
2674 if (value
> field
->logical_maximum
|| value
< field
->logical_minimum
)
2677 /* usage tests must precede field tests */
2678 if (WACOM_BATTERY_USAGE(usage
))
2679 wacom_wac_battery_event(hdev
, field
, usage
, value
);
2680 else if (WACOM_PAD_FIELD(field
) && wacom
->wacom_wac
.pad_input
)
2681 wacom_wac_pad_event(hdev
, field
, usage
, value
);
2682 else if (WACOM_PEN_FIELD(field
) && wacom
->wacom_wac
.pen_input
)
2683 wacom_wac_pen_event(hdev
, field
, usage
, value
);
2684 else if (WACOM_FINGER_FIELD(field
) && wacom
->wacom_wac
.touch_input
)
2685 wacom_wac_finger_event(hdev
, field
, usage
, value
);
2688 static void wacom_report_events(struct hid_device
*hdev
,
2689 struct hid_report
*report
, int collection_index
,
2694 for (r
= field_index
; r
< report
->maxfield
; r
++) {
2695 struct hid_field
*field
;
2698 field
= report
->field
[r
];
2699 count
= field
->report_count
;
2701 if (!(HID_MAIN_ITEM_VARIABLE
& field
->flags
))
2704 for (n
= 0 ; n
< count
; n
++) {
2705 if (field
->usage
[n
].collection_index
== collection_index
)
2706 wacom_wac_event(hdev
, field
, &field
->usage
[n
],
2714 static int wacom_wac_collection(struct hid_device
*hdev
, struct hid_report
*report
,
2715 int collection_index
, struct hid_field
*field
,
2718 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2720 wacom_report_events(hdev
, report
, collection_index
, field_index
);
2723 * Non-input reports may be sent prior to the device being
2724 * completely initialized. Since only their events need
2725 * to be processed, exit after 'wacom_report_events' has
2726 * been called to prevent potential crashes in the report-
2727 * processing functions.
2729 if (report
->type
!= HID_INPUT_REPORT
)
2732 if (WACOM_PEN_FIELD(field
) && wacom
->wacom_wac
.pen_input
)
2733 wacom_wac_pen_report(hdev
, report
);
2734 else if (WACOM_FINGER_FIELD(field
) && wacom
->wacom_wac
.touch_input
)
2735 wacom_wac_finger_report(hdev
, report
);
2740 void wacom_wac_report(struct hid_device
*hdev
, struct hid_report
*report
)
2742 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2743 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2744 struct hid_field
*field
;
2745 bool pad_in_hid_field
= false, pen_in_hid_field
= false,
2746 finger_in_hid_field
= false, true_pad
= false;
2748 int prev_collection
= -1;
2750 if (wacom_wac
->features
.type
!= HID_GENERIC
)
2753 for (r
= 0; r
< report
->maxfield
; r
++) {
2754 field
= report
->field
[r
];
2756 if (WACOM_PAD_FIELD(field
))
2757 pad_in_hid_field
= true;
2758 if (WACOM_PEN_FIELD(field
))
2759 pen_in_hid_field
= true;
2760 if (WACOM_FINGER_FIELD(field
))
2761 finger_in_hid_field
= true;
2762 if (wacom_equivalent_usage(field
->physical
) == HID_DG_TABLETFUNCTIONKEY
)
2766 wacom_wac_battery_pre_report(hdev
, report
);
2768 if (pad_in_hid_field
&& wacom
->wacom_wac
.pad_input
)
2769 wacom_wac_pad_pre_report(hdev
, report
);
2770 if (pen_in_hid_field
&& wacom
->wacom_wac
.pen_input
)
2771 wacom_wac_pen_pre_report(hdev
, report
);
2772 if (finger_in_hid_field
&& wacom
->wacom_wac
.touch_input
)
2773 wacom_wac_finger_pre_report(hdev
, report
);
2775 for (r
= 0; r
< report
->maxfield
; r
++) {
2776 field
= report
->field
[r
];
2778 if (field
->usage
[0].collection_index
!= prev_collection
) {
2779 if (wacom_wac_collection(hdev
, report
,
2780 field
->usage
[0].collection_index
, field
, r
) < 0)
2782 prev_collection
= field
->usage
[0].collection_index
;
2786 wacom_wac_battery_report(hdev
, report
);
2788 if (true_pad
&& wacom
->wacom_wac
.pad_input
)
2789 wacom_wac_pad_report(hdev
, report
, field
);
2792 static int wacom_bpt_touch(struct wacom_wac
*wacom
)
2794 struct wacom_features
*features
= &wacom
->features
;
2795 struct input_dev
*input
= wacom
->touch_input
;
2796 struct input_dev
*pad_input
= wacom
->pad_input
;
2797 unsigned char *data
= wacom
->data
;
2800 if (data
[0] != 0x02)
2803 for (i
= 0; i
< 2; i
++) {
2804 int offset
= (data
[1] & 0x80) ? (8 * i
) : (9 * i
);
2805 bool touch
= report_touch_events(wacom
)
2806 && (data
[offset
+ 3] & 0x80);
2808 input_mt_slot(input
, i
);
2809 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, touch
);
2811 int x
= get_unaligned_be16(&data
[offset
+ 3]) & 0x7ff;
2812 int y
= get_unaligned_be16(&data
[offset
+ 5]) & 0x7ff;
2813 if (features
->quirks
& WACOM_QUIRK_BBTOUCH_LOWRES
) {
2817 input_report_abs(input
, ABS_MT_POSITION_X
, x
);
2818 input_report_abs(input
, ABS_MT_POSITION_Y
, y
);
2822 input_mt_sync_frame(input
);
2824 input_report_key(pad_input
, BTN_LEFT
, (data
[1] & 0x08) != 0);
2825 input_report_key(pad_input
, BTN_FORWARD
, (data
[1] & 0x04) != 0);
2826 input_report_key(pad_input
, BTN_BACK
, (data
[1] & 0x02) != 0);
2827 input_report_key(pad_input
, BTN_RIGHT
, (data
[1] & 0x01) != 0);
2828 wacom
->shared
->touch_down
= wacom_wac_finger_count_touches(wacom
);
2833 static void wacom_bpt3_touch_msg(struct wacom_wac
*wacom
, unsigned char *data
)
2835 struct wacom_features
*features
= &wacom
->features
;
2836 struct input_dev
*input
= wacom
->touch_input
;
2837 bool touch
= data
[1] & 0x80;
2838 int slot
= input_mt_get_slot_by_key(input
, data
[0]);
2843 touch
= touch
&& report_touch_events(wacom
);
2845 input_mt_slot(input
, slot
);
2846 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, touch
);
2849 int x
= (data
[2] << 4) | (data
[4] >> 4);
2850 int y
= (data
[3] << 4) | (data
[4] & 0x0f);
2853 if (features
->type
>= INTUOSPS
&& features
->type
<= INTUOSHT2
) {
2854 width
= data
[5] * 100;
2855 height
= data
[6] * 100;
2858 * "a" is a scaled-down area which we assume is
2859 * roughly circular and which can be described as:
2863 int x_res
= input_abs_get_res(input
, ABS_MT_POSITION_X
);
2864 int y_res
= input_abs_get_res(input
, ABS_MT_POSITION_Y
);
2865 width
= 2 * int_sqrt(a
* WACOM_CONTACT_AREA_SCALE
);
2866 height
= width
* y_res
/ x_res
;
2869 input_report_abs(input
, ABS_MT_POSITION_X
, x
);
2870 input_report_abs(input
, ABS_MT_POSITION_Y
, y
);
2871 input_report_abs(input
, ABS_MT_TOUCH_MAJOR
, width
);
2872 input_report_abs(input
, ABS_MT_TOUCH_MINOR
, height
);
2876 static void wacom_bpt3_button_msg(struct wacom_wac
*wacom
, unsigned char *data
)
2878 struct input_dev
*input
= wacom
->pad_input
;
2879 struct wacom_features
*features
= &wacom
->features
;
2881 if (features
->type
== INTUOSHT
|| features
->type
== INTUOSHT2
) {
2882 input_report_key(input
, BTN_LEFT
, (data
[1] & 0x02) != 0);
2883 input_report_key(input
, BTN_BACK
, (data
[1] & 0x08) != 0);
2885 input_report_key(input
, BTN_BACK
, (data
[1] & 0x02) != 0);
2886 input_report_key(input
, BTN_LEFT
, (data
[1] & 0x08) != 0);
2888 input_report_key(input
, BTN_FORWARD
, (data
[1] & 0x04) != 0);
2889 input_report_key(input
, BTN_RIGHT
, (data
[1] & 0x01) != 0);
2892 static int wacom_bpt3_touch(struct wacom_wac
*wacom
)
2894 unsigned char *data
= wacom
->data
;
2895 int count
= data
[1] & 0x07;
2896 int touch_changed
= 0, i
;
2898 if (data
[0] != 0x02)
2901 /* data has up to 7 fixed sized 8-byte messages starting at data[2] */
2902 for (i
= 0; i
< count
; i
++) {
2903 int offset
= (8 * i
) + 2;
2904 int msg_id
= data
[offset
];
2906 if (msg_id
>= 2 && msg_id
<= 17) {
2907 wacom_bpt3_touch_msg(wacom
, data
+ offset
);
2909 } else if (msg_id
== 128)
2910 wacom_bpt3_button_msg(wacom
, data
+ offset
);
2914 /* only update touch if we actually have a touchpad and touch data changed */
2915 if (wacom
->touch_input
&& touch_changed
) {
2916 input_mt_sync_frame(wacom
->touch_input
);
2917 wacom
->shared
->touch_down
= wacom_wac_finger_count_touches(wacom
);
2923 static int wacom_bpt_pen(struct wacom_wac
*wacom
)
2925 struct wacom_features
*features
= &wacom
->features
;
2926 struct input_dev
*input
= wacom
->pen_input
;
2927 unsigned char *data
= wacom
->data
;
2928 int x
= 0, y
= 0, p
= 0, d
= 0;
2929 bool pen
= false, btn1
= false, btn2
= false;
2930 bool range
, prox
, rdy
;
2932 if (data
[0] != WACOM_REPORT_PENABLED
)
2935 range
= (data
[1] & 0x80) == 0x80;
2936 prox
= (data
[1] & 0x40) == 0x40;
2937 rdy
= (data
[1] & 0x20) == 0x20;
2939 wacom
->shared
->stylus_in_proximity
= range
;
2940 if (delay_pen_events(wacom
))
2944 p
= le16_to_cpup((__le16
*)&data
[6]);
2945 pen
= data
[1] & 0x01;
2946 btn1
= data
[1] & 0x02;
2947 btn2
= data
[1] & 0x04;
2950 x
= le16_to_cpup((__le16
*)&data
[2]);
2951 y
= le16_to_cpup((__le16
*)&data
[4]);
2953 if (data
[1] & 0x08) {
2954 wacom
->tool
[0] = BTN_TOOL_RUBBER
;
2955 wacom
->id
[0] = ERASER_DEVICE_ID
;
2957 wacom
->tool
[0] = BTN_TOOL_PEN
;
2958 wacom
->id
[0] = STYLUS_DEVICE_ID
;
2960 wacom
->reporting_data
= true;
2964 * Convert distance from out prox to distance from tablet.
2965 * distance will be greater than distance_max once
2966 * touching and applying pressure; do not report negative
2969 if (data
[8] <= features
->distance_max
)
2970 d
= features
->distance_max
- data
[8];
2975 if (wacom
->reporting_data
) {
2976 input_report_key(input
, BTN_TOUCH
, pen
);
2977 input_report_key(input
, BTN_STYLUS
, btn1
);
2978 input_report_key(input
, BTN_STYLUS2
, btn2
);
2980 if (prox
|| !range
) {
2981 input_report_abs(input
, ABS_X
, x
);
2982 input_report_abs(input
, ABS_Y
, y
);
2984 input_report_abs(input
, ABS_PRESSURE
, p
);
2985 input_report_abs(input
, ABS_DISTANCE
, d
);
2987 input_report_key(input
, wacom
->tool
[0], range
); /* PEN or RUBBER */
2988 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]); /* TOOL ID */
2992 wacom
->reporting_data
= false;
2998 static int wacom_bpt_irq(struct wacom_wac
*wacom
, size_t len
)
3000 struct wacom_features
*features
= &wacom
->features
;
3002 if ((features
->type
== INTUOSHT2
) &&
3003 (features
->device_type
& WACOM_DEVICETYPE_PEN
))
3004 return wacom_intuos_irq(wacom
);
3005 else if (len
== WACOM_PKGLEN_BBTOUCH
)
3006 return wacom_bpt_touch(wacom
);
3007 else if (len
== WACOM_PKGLEN_BBTOUCH3
)
3008 return wacom_bpt3_touch(wacom
);
3009 else if (len
== WACOM_PKGLEN_BBFUN
|| len
== WACOM_PKGLEN_BBPEN
)
3010 return wacom_bpt_pen(wacom
);
3015 static void wacom_bamboo_pad_pen_event(struct wacom_wac
*wacom
,
3016 unsigned char *data
)
3018 unsigned char prefix
;
3021 * We need to reroute the event from the debug interface to the
3023 * We need to add the report ID to the actual pen report, so we
3024 * temporary overwrite the first byte to prevent having to kzalloc/kfree
3025 * and memcpy the report.
3028 data
[0] = WACOM_REPORT_BPAD_PEN
;
3031 * actually reroute the event.
3032 * No need to check if wacom->shared->pen is valid, hid_input_report()
3033 * will check for us.
3035 hid_input_report(wacom
->shared
->pen
, HID_INPUT_REPORT
, data
,
3036 WACOM_PKGLEN_PENABLED
, 1);
3041 static int wacom_bamboo_pad_touch_event(struct wacom_wac
*wacom
,
3042 unsigned char *data
)
3044 struct input_dev
*input
= wacom
->touch_input
;
3045 unsigned char *finger_data
, prefix
;
3052 for (id
= 0; id
< wacom
->features
.touch_max
; id
++) {
3053 valid
= !!(prefix
& BIT(id
)) &&
3054 report_touch_events(wacom
);
3056 input_mt_slot(input
, id
);
3057 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, valid
);
3062 finger_data
= data
+ 1 + id
* 3;
3063 x
= finger_data
[0] | ((finger_data
[1] & 0x0f) << 8);
3064 y
= (finger_data
[2] << 4) | (finger_data
[1] >> 4);
3066 input_report_abs(input
, ABS_MT_POSITION_X
, x
);
3067 input_report_abs(input
, ABS_MT_POSITION_Y
, y
);
3070 input_mt_sync_frame(input
);
3072 input_report_key(input
, BTN_LEFT
, prefix
& 0x40);
3073 input_report_key(input
, BTN_RIGHT
, prefix
& 0x80);
3075 /* keep touch state for pen event */
3076 wacom
->shared
->touch_down
= !!prefix
&& report_touch_events(wacom
);
3081 static int wacom_bamboo_pad_irq(struct wacom_wac
*wacom
, size_t len
)
3083 unsigned char *data
= wacom
->data
;
3085 if (!((len
== WACOM_PKGLEN_BPAD_TOUCH
) ||
3086 (len
== WACOM_PKGLEN_BPAD_TOUCH_USB
)) ||
3087 (data
[0] != WACOM_REPORT_BPAD_TOUCH
))
3091 wacom_bamboo_pad_pen_event(wacom
, &data
[1]);
3094 return wacom_bamboo_pad_touch_event(wacom
, &data
[9]);
3099 static int wacom_wireless_irq(struct wacom_wac
*wacom
, size_t len
)
3101 unsigned char *data
= wacom
->data
;
3104 if (len
!= WACOM_PKGLEN_WIRELESS
|| data
[0] != WACOM_REPORT_WL
)
3107 connected
= data
[1] & 0x01;
3109 int pid
, battery
, charging
;
3111 if ((wacom
->shared
->type
== INTUOSHT
||
3112 wacom
->shared
->type
== INTUOSHT2
) &&
3113 wacom
->shared
->touch_input
&&
3114 wacom
->shared
->touch_max
) {
3115 input_report_switch(wacom
->shared
->touch_input
,
3116 SW_MUTE_DEVICE
, data
[5] & 0x40);
3117 input_sync(wacom
->shared
->touch_input
);
3120 pid
= get_unaligned_be16(&data
[6]);
3121 battery
= (data
[5] & 0x3f) * 100 / 31;
3122 charging
= !!(data
[5] & 0x80);
3123 if (wacom
->pid
!= pid
) {
3125 wacom_schedule_work(wacom
, WACOM_WORKER_WIRELESS
);
3128 wacom_notify_battery(wacom
, WACOM_POWER_SUPPLY_STATUS_AUTO
,
3129 battery
, charging
, 1, 0);
3131 } else if (wacom
->pid
!= 0) {
3132 /* disconnected while previously connected */
3134 wacom_schedule_work(wacom
, WACOM_WORKER_WIRELESS
);
3135 wacom_notify_battery(wacom
, POWER_SUPPLY_STATUS_UNKNOWN
, 0, 0, 0, 0);
3141 static int wacom_status_irq(struct wacom_wac
*wacom_wac
, size_t len
)
3143 struct wacom
*wacom
= container_of(wacom_wac
, struct wacom
, wacom_wac
);
3144 struct wacom_features
*features
= &wacom_wac
->features
;
3145 unsigned char *data
= wacom_wac
->data
;
3147 if (data
[0] != WACOM_REPORT_USB
)
3150 if ((features
->type
== INTUOSHT
||
3151 features
->type
== INTUOSHT2
) &&
3152 wacom_wac
->shared
->touch_input
&&
3153 features
->touch_max
) {
3154 input_report_switch(wacom_wac
->shared
->touch_input
,
3155 SW_MUTE_DEVICE
, data
[8] & 0x40);
3156 input_sync(wacom_wac
->shared
->touch_input
);
3159 if (data
[9] & 0x02) { /* wireless module is attached */
3160 int battery
= (data
[8] & 0x3f) * 100 / 31;
3161 bool charging
= !!(data
[8] & 0x80);
3163 wacom_notify_battery(wacom_wac
, WACOM_POWER_SUPPLY_STATUS_AUTO
,
3164 battery
, charging
, battery
|| charging
, 1);
3166 if (!wacom
->battery
.battery
&&
3167 !(features
->quirks
& WACOM_QUIRK_BATTERY
)) {
3168 features
->quirks
|= WACOM_QUIRK_BATTERY
;
3169 wacom_schedule_work(wacom_wac
, WACOM_WORKER_BATTERY
);
3172 else if ((features
->quirks
& WACOM_QUIRK_BATTERY
) &&
3173 wacom
->battery
.battery
) {
3174 features
->quirks
&= ~WACOM_QUIRK_BATTERY
;
3175 wacom_schedule_work(wacom_wac
, WACOM_WORKER_BATTERY
);
3176 wacom_notify_battery(wacom_wac
, POWER_SUPPLY_STATUS_UNKNOWN
, 0, 0, 0, 0);
3181 void wacom_wac_irq(struct wacom_wac
*wacom_wac
, size_t len
)
3185 switch (wacom_wac
->features
.type
) {
3187 sync
= wacom_penpartner_irq(wacom_wac
);
3191 sync
= wacom_pl_irq(wacom_wac
);
3198 sync
= wacom_graphire_irq(wacom_wac
);
3202 sync
= wacom_ptu_irq(wacom_wac
);
3206 sync
= wacom_dtu_irq(wacom_wac
);
3211 sync
= wacom_dtus_irq(wacom_wac
);
3230 case CINTIQ_COMPANION_2
:
3231 sync
= wacom_intuos_irq(wacom_wac
);
3235 sync
= wacom_intuos_bt_irq(wacom_wac
, len
);
3240 sync
= wacom_24hdt_irq(wacom_wac
);
3249 if (len
== WACOM_PKGLEN_BBTOUCH3
)
3250 sync
= wacom_bpt3_touch(wacom_wac
);
3251 else if (wacom_wac
->data
[0] == WACOM_REPORT_USB
)
3252 sync
= wacom_status_irq(wacom_wac
, len
);
3254 sync
= wacom_intuos_irq(wacom_wac
);
3259 sync
= wacom_intuos_pro2_bt_irq(wacom_wac
, len
);
3268 sync
= wacom_tpc_irq(wacom_wac
, len
);
3276 if (wacom_wac
->data
[0] == WACOM_REPORT_USB
)
3277 sync
= wacom_status_irq(wacom_wac
, len
);
3279 sync
= wacom_bpt_irq(wacom_wac
, len
);
3283 sync
= wacom_bamboo_pad_irq(wacom_wac
, len
);
3287 sync
= wacom_wireless_irq(wacom_wac
, len
);
3292 if (wacom_wac
->data
[0] == WACOM_REPORT_DEVICE_LIST
)
3293 wacom_remote_status_irq(wacom_wac
, len
);
3295 sync
= wacom_remote_irq(wacom_wac
, len
);
3304 if (wacom_wac
->pen_input
)
3305 input_sync(wacom_wac
->pen_input
);
3306 if (wacom_wac
->touch_input
)
3307 input_sync(wacom_wac
->touch_input
);
3308 if (wacom_wac
->pad_input
)
3309 input_sync(wacom_wac
->pad_input
);
3313 static void wacom_setup_basic_pro_pen(struct wacom_wac
*wacom_wac
)
3315 struct input_dev
*input_dev
= wacom_wac
->pen_input
;
3317 input_set_capability(input_dev
, EV_MSC
, MSC_SERIAL
);
3319 __set_bit(BTN_TOOL_PEN
, input_dev
->keybit
);
3320 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
3321 __set_bit(BTN_STYLUS2
, input_dev
->keybit
);
3323 input_set_abs_params(input_dev
, ABS_DISTANCE
,
3324 0, wacom_wac
->features
.distance_max
, wacom_wac
->features
.distance_fuzz
, 0);
3327 static void wacom_setup_cintiq(struct wacom_wac
*wacom_wac
)
3329 struct input_dev
*input_dev
= wacom_wac
->pen_input
;
3330 struct wacom_features
*features
= &wacom_wac
->features
;
3332 wacom_setup_basic_pro_pen(wacom_wac
);
3334 __set_bit(BTN_TOOL_RUBBER
, input_dev
->keybit
);
3335 __set_bit(BTN_TOOL_BRUSH
, input_dev
->keybit
);
3336 __set_bit(BTN_TOOL_PENCIL
, input_dev
->keybit
);
3337 __set_bit(BTN_TOOL_AIRBRUSH
, input_dev
->keybit
);
3339 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 1023, 0, 0);
3340 input_set_abs_params(input_dev
, ABS_TILT_X
, -64, 63, features
->tilt_fuzz
, 0);
3341 input_abs_set_res(input_dev
, ABS_TILT_X
, 57);
3342 input_set_abs_params(input_dev
, ABS_TILT_Y
, -64, 63, features
->tilt_fuzz
, 0);
3343 input_abs_set_res(input_dev
, ABS_TILT_Y
, 57);
3346 static void wacom_setup_intuos(struct wacom_wac
*wacom_wac
)
3348 struct input_dev
*input_dev
= wacom_wac
->pen_input
;
3350 input_set_capability(input_dev
, EV_REL
, REL_WHEEL
);
3352 wacom_setup_cintiq(wacom_wac
);
3354 __set_bit(BTN_LEFT
, input_dev
->keybit
);
3355 __set_bit(BTN_RIGHT
, input_dev
->keybit
);
3356 __set_bit(BTN_MIDDLE
, input_dev
->keybit
);
3357 __set_bit(BTN_SIDE
, input_dev
->keybit
);
3358 __set_bit(BTN_EXTRA
, input_dev
->keybit
);
3359 __set_bit(BTN_TOOL_MOUSE
, input_dev
->keybit
);
3360 __set_bit(BTN_TOOL_LENS
, input_dev
->keybit
);
3362 input_set_abs_params(input_dev
, ABS_RZ
, -900, 899, 0, 0);
3363 input_abs_set_res(input_dev
, ABS_RZ
, 287);
3364 input_set_abs_params(input_dev
, ABS_THROTTLE
, -1023, 1023, 0, 0);
3367 void wacom_setup_device_quirks(struct wacom
*wacom
)
3369 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
3370 struct wacom_features
*features
= &wacom
->wacom_wac
.features
;
3372 /* The pen and pad share the same interface on most devices */
3373 if (features
->type
== GRAPHIRE_BT
|| features
->type
== WACOM_G4
||
3374 features
->type
== DTUS
||
3375 (features
->type
>= INTUOS3S
&& features
->type
<= WACOM_MO
)) {
3376 if (features
->device_type
& WACOM_DEVICETYPE_PEN
)
3377 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
3380 /* touch device found but size is not defined. use default */
3381 if (features
->device_type
& WACOM_DEVICETYPE_TOUCH
&& !features
->x_max
) {
3382 features
->x_max
= 1023;
3383 features
->y_max
= 1023;
3387 * Intuos5/Pro and Bamboo 3rd gen have no useful data about its
3388 * touch interface in its HID descriptor. If this is the touch
3389 * interface (PacketSize of WACOM_PKGLEN_BBTOUCH3), override the
3392 if ((features
->type
>= INTUOS5S
&& features
->type
<= INTUOSPL
) ||
3393 (features
->type
>= INTUOSHT
&& features
->type
<= BAMBOO_PT
)) {
3394 if (features
->pktlen
== WACOM_PKGLEN_BBTOUCH3
) {
3395 if (features
->touch_max
)
3396 features
->device_type
|= WACOM_DEVICETYPE_TOUCH
;
3397 if (features
->type
>= INTUOSHT
&& features
->type
<= BAMBOO_PT
)
3398 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
3400 if (features
->type
== INTUOSHT2
) {
3401 features
->x_max
= features
->x_max
/ 10;
3402 features
->y_max
= features
->y_max
/ 10;
3405 features
->x_max
= 4096;
3406 features
->y_max
= 4096;
3409 else if (features
->pktlen
== WACOM_PKGLEN_BBTOUCH
) {
3410 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
3415 * Hack for the Bamboo One:
3416 * the device presents a PAD/Touch interface as most Bamboos and even
3417 * sends ghosts PAD data on it. However, later, we must disable this
3418 * ghost interface, and we can not detect it unless we set it here
3419 * to WACOM_DEVICETYPE_PAD or WACOM_DEVICETYPE_TOUCH.
3421 if (features
->type
== BAMBOO_PEN
&&
3422 features
->pktlen
== WACOM_PKGLEN_BBTOUCH3
)
3423 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
3426 * Raw Wacom-mode pen and touch events both come from interface
3427 * 0, whose HID descriptor has an application usage of 0xFF0D
3428 * (i.e., WACOM_HID_WD_DIGITIZER). We route pen packets back
3429 * out through the HID_GENERIC device created for interface 1,
3430 * so rewrite this one to be of type WACOM_DEVICETYPE_TOUCH.
3432 if (features
->type
== BAMBOO_PAD
)
3433 features
->device_type
= WACOM_DEVICETYPE_TOUCH
;
3435 if (features
->type
== REMOTE
)
3436 features
->device_type
= WACOM_DEVICETYPE_PAD
;
3438 if (features
->type
== INTUOSP2_BT
) {
3439 features
->device_type
|= WACOM_DEVICETYPE_PEN
|
3440 WACOM_DEVICETYPE_PAD
|
3441 WACOM_DEVICETYPE_TOUCH
;
3442 features
->quirks
|= WACOM_QUIRK_BATTERY
;
3445 if (features
->type
== INTUOSHT3_BT
) {
3446 features
->device_type
|= WACOM_DEVICETYPE_PEN
|
3447 WACOM_DEVICETYPE_PAD
;
3448 features
->quirks
|= WACOM_QUIRK_BATTERY
;
3451 switch (features
->type
) {
3462 case CINTIQ_COMPANION_2
:
3474 features
->device_type
|= WACOM_DEVICETYPE_DIRECT
;
3478 if (wacom
->hdev
->bus
== BUS_BLUETOOTH
)
3479 features
->quirks
|= WACOM_QUIRK_BATTERY
;
3481 /* quirk for bamboo touch with 2 low res touches */
3482 if ((features
->type
== BAMBOO_PT
|| features
->type
== BAMBOO_TOUCH
) &&
3483 features
->pktlen
== WACOM_PKGLEN_BBTOUCH
) {
3484 features
->x_max
<<= 5;
3485 features
->y_max
<<= 5;
3486 features
->x_fuzz
<<= 5;
3487 features
->y_fuzz
<<= 5;
3488 features
->quirks
|= WACOM_QUIRK_BBTOUCH_LOWRES
;
3491 if (features
->type
== WIRELESS
) {
3492 if (features
->device_type
== WACOM_DEVICETYPE_WL_MONITOR
) {
3493 features
->quirks
|= WACOM_QUIRK_BATTERY
;
3497 if (features
->type
== REMOTE
)
3498 features
->device_type
|= WACOM_DEVICETYPE_WL_MONITOR
;
3500 /* HID descriptor for DTK-2451 / DTH-2452 claims to report lots
3501 * of things it shouldn't. Lets fix up the damage...
3503 if (wacom
->hdev
->product
== 0x382 || wacom
->hdev
->product
== 0x37d) {
3504 features
->quirks
&= ~WACOM_QUIRK_TOOLSERIAL
;
3505 __clear_bit(BTN_TOOL_BRUSH
, wacom_wac
->pen_input
->keybit
);
3506 __clear_bit(BTN_TOOL_PENCIL
, wacom_wac
->pen_input
->keybit
);
3507 __clear_bit(BTN_TOOL_AIRBRUSH
, wacom_wac
->pen_input
->keybit
);
3508 __clear_bit(ABS_Z
, wacom_wac
->pen_input
->absbit
);
3509 __clear_bit(ABS_DISTANCE
, wacom_wac
->pen_input
->absbit
);
3510 __clear_bit(ABS_TILT_X
, wacom_wac
->pen_input
->absbit
);
3511 __clear_bit(ABS_TILT_Y
, wacom_wac
->pen_input
->absbit
);
3512 __clear_bit(ABS_WHEEL
, wacom_wac
->pen_input
->absbit
);
3513 __clear_bit(ABS_MISC
, wacom_wac
->pen_input
->absbit
);
3514 __clear_bit(MSC_SERIAL
, wacom_wac
->pen_input
->mscbit
);
3515 __clear_bit(EV_MSC
, wacom_wac
->pen_input
->evbit
);
3519 int wacom_setup_pen_input_capabilities(struct input_dev
*input_dev
,
3520 struct wacom_wac
*wacom_wac
)
3522 struct wacom_features
*features
= &wacom_wac
->features
;
3524 input_dev
->evbit
[0] |= BIT_MASK(EV_KEY
) | BIT_MASK(EV_ABS
);
3526 if (!(features
->device_type
& WACOM_DEVICETYPE_PEN
))
3529 if (features
->device_type
& WACOM_DEVICETYPE_DIRECT
)
3530 __set_bit(INPUT_PROP_DIRECT
, input_dev
->propbit
);
3532 __set_bit(INPUT_PROP_POINTER
, input_dev
->propbit
);
3534 if (features
->type
== HID_GENERIC
) {
3535 /* setup has already been done; apply otherwise-undetectible quirks */
3536 input_set_capability(input_dev
, EV_KEY
, BTN_STYLUS3
);
3540 __set_bit(BTN_TOUCH
, input_dev
->keybit
);
3541 __set_bit(ABS_MISC
, input_dev
->absbit
);
3543 input_set_abs_params(input_dev
, ABS_X
, 0 + features
->offset_left
,
3544 features
->x_max
- features
->offset_right
,
3545 features
->x_fuzz
, 0);
3546 input_set_abs_params(input_dev
, ABS_Y
, 0 + features
->offset_top
,
3547 features
->y_max
- features
->offset_bottom
,
3548 features
->y_fuzz
, 0);
3549 input_set_abs_params(input_dev
, ABS_PRESSURE
, 0,
3550 features
->pressure_max
, features
->pressure_fuzz
, 0);
3552 /* penabled devices have fixed resolution for each model */
3553 input_abs_set_res(input_dev
, ABS_X
, features
->x_resolution
);
3554 input_abs_set_res(input_dev
, ABS_Y
, features
->y_resolution
);
3556 switch (features
->type
) {
3558 __clear_bit(ABS_MISC
, input_dev
->absbit
);
3562 input_set_abs_params(input_dev
, ABS_DISTANCE
, 0,
3563 features
->distance_max
,
3564 features
->distance_fuzz
, 0);
3568 input_set_capability(input_dev
, EV_REL
, REL_WHEEL
);
3570 __set_bit(BTN_LEFT
, input_dev
->keybit
);
3571 __set_bit(BTN_RIGHT
, input_dev
->keybit
);
3572 __set_bit(BTN_MIDDLE
, input_dev
->keybit
);
3574 __set_bit(BTN_TOOL_RUBBER
, input_dev
->keybit
);
3575 __set_bit(BTN_TOOL_PEN
, input_dev
->keybit
);
3576 __set_bit(BTN_TOOL_MOUSE
, input_dev
->keybit
);
3577 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
3578 __set_bit(BTN_STYLUS2
, input_dev
->keybit
);
3590 case CINTIQ_COMPANION_2
:
3591 input_set_abs_params(input_dev
, ABS_Z
, -900, 899, 0, 0);
3592 input_abs_set_res(input_dev
, ABS_Z
, 287);
3593 wacom_setup_cintiq(wacom_wac
);
3603 input_set_abs_params(input_dev
, ABS_Z
, -900, 899, 0, 0);
3604 input_abs_set_res(input_dev
, ABS_Z
, 287);
3608 wacom_setup_intuos(wacom_wac
);
3618 input_set_abs_params(input_dev
, ABS_DISTANCE
, 0,
3619 features
->distance_max
,
3620 features
->distance_fuzz
, 0);
3622 input_set_abs_params(input_dev
, ABS_Z
, -900, 899, 0, 0);
3623 input_abs_set_res(input_dev
, ABS_Z
, 287);
3625 wacom_setup_intuos(wacom_wac
);
3636 __clear_bit(ABS_MISC
, input_dev
->absbit
);
3643 __set_bit(BTN_TOOL_PEN
, input_dev
->keybit
);
3644 __set_bit(BTN_TOOL_RUBBER
, input_dev
->keybit
);
3645 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
3646 __set_bit(BTN_STYLUS2
, input_dev
->keybit
);
3650 __set_bit(BTN_STYLUS2
, input_dev
->keybit
);
3654 __set_bit(BTN_TOOL_PEN
, input_dev
->keybit
);
3655 __set_bit(BTN_TOOL_RUBBER
, input_dev
->keybit
);
3656 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
3664 if (features
->type
== INTUOSHT2
||
3665 features
->type
== INTUOSHT3_BT
) {
3666 wacom_setup_basic_pro_pen(wacom_wac
);
3668 __clear_bit(ABS_MISC
, input_dev
->absbit
);
3669 __set_bit(BTN_TOOL_PEN
, input_dev
->keybit
);
3670 __set_bit(BTN_TOOL_RUBBER
, input_dev
->keybit
);
3671 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
3672 __set_bit(BTN_STYLUS2
, input_dev
->keybit
);
3673 input_set_abs_params(input_dev
, ABS_DISTANCE
, 0,
3674 features
->distance_max
,
3675 features
->distance_fuzz
, 0);
3679 __clear_bit(ABS_MISC
, input_dev
->absbit
);
3685 int wacom_setup_touch_input_capabilities(struct input_dev
*input_dev
,
3686 struct wacom_wac
*wacom_wac
)
3688 struct wacom_features
*features
= &wacom_wac
->features
;
3690 input_dev
->evbit
[0] |= BIT_MASK(EV_KEY
) | BIT_MASK(EV_ABS
);
3692 if (!(features
->device_type
& WACOM_DEVICETYPE_TOUCH
))
3695 if (features
->device_type
& WACOM_DEVICETYPE_DIRECT
)
3696 __set_bit(INPUT_PROP_DIRECT
, input_dev
->propbit
);
3698 __set_bit(INPUT_PROP_POINTER
, input_dev
->propbit
);
3700 if (features
->type
== HID_GENERIC
)
3701 /* setup has already been done */
3704 __set_bit(BTN_TOUCH
, input_dev
->keybit
);
3706 if (features
->touch_max
== 1) {
3707 input_set_abs_params(input_dev
, ABS_X
, 0,
3708 features
->x_max
, features
->x_fuzz
, 0);
3709 input_set_abs_params(input_dev
, ABS_Y
, 0,
3710 features
->y_max
, features
->y_fuzz
, 0);
3711 input_abs_set_res(input_dev
, ABS_X
,
3712 features
->x_resolution
);
3713 input_abs_set_res(input_dev
, ABS_Y
,
3714 features
->y_resolution
);
3716 else if (features
->touch_max
> 1) {
3717 input_set_abs_params(input_dev
, ABS_MT_POSITION_X
, 0,
3718 features
->x_max
, features
->x_fuzz
, 0);
3719 input_set_abs_params(input_dev
, ABS_MT_POSITION_Y
, 0,
3720 features
->y_max
, features
->y_fuzz
, 0);
3721 input_abs_set_res(input_dev
, ABS_MT_POSITION_X
,
3722 features
->x_resolution
);
3723 input_abs_set_res(input_dev
, ABS_MT_POSITION_Y
,
3724 features
->y_resolution
);
3727 switch (features
->type
) {
3729 input_dev
->evbit
[0] |= BIT_MASK(EV_SW
);
3730 __set_bit(SW_MUTE_DEVICE
, input_dev
->swbit
);
3732 if (wacom_wac
->shared
->touch
->product
== 0x361) {
3733 input_set_abs_params(input_dev
, ABS_MT_POSITION_X
,
3735 input_set_abs_params(input_dev
, ABS_MT_POSITION_Y
,
3738 else if (wacom_wac
->shared
->touch
->product
== 0x360) {
3739 input_set_abs_params(input_dev
, ABS_MT_POSITION_X
,
3741 input_set_abs_params(input_dev
, ABS_MT_POSITION_Y
,
3744 input_abs_set_res(input_dev
, ABS_MT_POSITION_X
, 40);
3745 input_abs_set_res(input_dev
, ABS_MT_POSITION_Y
, 40);
3755 input_set_abs_params(input_dev
, ABS_MT_TOUCH_MAJOR
, 0, features
->x_max
, 0, 0);
3756 input_set_abs_params(input_dev
, ABS_MT_TOUCH_MINOR
, 0, features
->y_max
, 0, 0);
3757 input_mt_init_slots(input_dev
, features
->touch_max
, INPUT_MT_POINTER
);
3761 input_set_abs_params(input_dev
, ABS_MT_TOUCH_MAJOR
, 0, features
->x_max
, 0, 0);
3762 input_set_abs_params(input_dev
, ABS_MT_WIDTH_MAJOR
, 0, features
->x_max
, 0, 0);
3763 input_set_abs_params(input_dev
, ABS_MT_WIDTH_MINOR
, 0, features
->y_max
, 0, 0);
3764 input_set_abs_params(input_dev
, ABS_MT_ORIENTATION
, 0, 1, 0, 0);
3772 input_mt_init_slots(input_dev
, features
->touch_max
, INPUT_MT_DIRECT
);
3781 input_dev
->evbit
[0] |= BIT_MASK(EV_SW
);
3782 __set_bit(SW_MUTE_DEVICE
, input_dev
->swbit
);
3787 if (features
->pktlen
== WACOM_PKGLEN_BBTOUCH3
) {
3788 input_set_abs_params(input_dev
,
3790 0, features
->x_max
, 0, 0);
3791 input_set_abs_params(input_dev
,
3793 0, features
->y_max
, 0, 0);
3795 input_mt_init_slots(input_dev
, features
->touch_max
, INPUT_MT_POINTER
);
3799 input_mt_init_slots(input_dev
, features
->touch_max
,
3801 __set_bit(BTN_LEFT
, input_dev
->keybit
);
3802 __set_bit(BTN_RIGHT
, input_dev
->keybit
);
3808 static int wacom_numbered_button_to_key(int n
)
3813 return BTN_A
+ (n
-10);
3815 return BTN_BASE
+ (n
-16);
3820 static void wacom_setup_numbered_buttons(struct input_dev
*input_dev
,
3825 for (i
= 0; i
< button_count
; i
++) {
3826 int key
= wacom_numbered_button_to_key(i
);
3829 __set_bit(key
, input_dev
->keybit
);
3833 static void wacom_24hd_update_leds(struct wacom
*wacom
, int mask
, int group
)
3835 struct wacom_led
*led
;
3837 bool updated
= false;
3840 * 24HD has LED group 1 to the left and LED group 0 to the right.
3841 * So group 0 matches the second half of the buttons and thus the mask
3842 * needs to be shifted.
3847 for (i
= 0; i
< 3; i
++) {
3848 led
= wacom_led_find(wacom
, group
, i
);
3850 hid_err(wacom
->hdev
, "can't find LED %d in group %d\n",
3854 if (!updated
&& mask
& BIT(i
)) {
3856 led_trigger_event(&led
->trigger
, LED_FULL
);
3863 static bool wacom_is_led_toggled(struct wacom
*wacom
, int button_count
,
3864 int mask
, int group
)
3869 * 21UX2 has LED group 1 to the left and LED group 0
3870 * to the right. We need to reverse the group to match this
3871 * historical behavior.
3873 if (wacom
->wacom_wac
.features
.type
== WACOM_21UX2
)
3876 group_button
= group
* (button_count
/wacom
->led
.count
);
3878 if (wacom
->wacom_wac
.features
.type
== INTUOSP2_BT
)
3881 return mask
& (1 << group_button
);
3884 static void wacom_update_led(struct wacom
*wacom
, int button_count
, int mask
,
3887 struct wacom_led
*led
, *next_led
;
3891 if (wacom
->wacom_wac
.features
.type
== WACOM_24HD
)
3892 return wacom_24hd_update_leds(wacom
, mask
, group
);
3894 pressed
= wacom_is_led_toggled(wacom
, button_count
, mask
, group
);
3895 cur
= wacom
->led
.groups
[group
].select
;
3897 led
= wacom_led_find(wacom
, group
, cur
);
3899 hid_err(wacom
->hdev
, "can't find current LED %d in group %d\n",
3909 if (led
->held
&& pressed
)
3912 next_led
= wacom_led_next(wacom
, led
);
3914 hid_err(wacom
->hdev
, "can't find next LED in group %d\n",
3918 if (next_led
== led
)
3921 next_led
->held
= true;
3922 led_trigger_event(&next_led
->trigger
,
3923 wacom_leds_brightness_get(next_led
));
3926 static void wacom_report_numbered_buttons(struct input_dev
*input_dev
,
3927 int button_count
, int mask
)
3929 struct wacom
*wacom
= input_get_drvdata(input_dev
);
3932 for (i
= 0; i
< wacom
->led
.count
; i
++)
3933 wacom_update_led(wacom
, button_count
, mask
, i
);
3935 for (i
= 0; i
< button_count
; i
++) {
3936 int key
= wacom_numbered_button_to_key(i
);
3939 input_report_key(input_dev
, key
, mask
& (1 << i
));
3943 int wacom_setup_pad_input_capabilities(struct input_dev
*input_dev
,
3944 struct wacom_wac
*wacom_wac
)
3946 struct wacom_features
*features
= &wacom_wac
->features
;
3948 if ((features
->type
== HID_GENERIC
) && features
->numbered_buttons
> 0)
3949 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
3951 if (!(features
->device_type
& WACOM_DEVICETYPE_PAD
))
3954 if (features
->type
== REMOTE
&& input_dev
== wacom_wac
->pad_input
)
3957 input_dev
->evbit
[0] |= BIT_MASK(EV_KEY
) | BIT_MASK(EV_ABS
);
3959 /* kept for making legacy xf86-input-wacom working with the wheels */
3960 __set_bit(ABS_MISC
, input_dev
->absbit
);
3962 /* kept for making legacy xf86-input-wacom accepting the pad */
3963 if (!(input_dev
->absinfo
&& (input_dev
->absinfo
[ABS_X
].minimum
||
3964 input_dev
->absinfo
[ABS_X
].maximum
)))
3965 input_set_abs_params(input_dev
, ABS_X
, 0, 1, 0, 0);
3966 if (!(input_dev
->absinfo
&& (input_dev
->absinfo
[ABS_Y
].minimum
||
3967 input_dev
->absinfo
[ABS_Y
].maximum
)))
3968 input_set_abs_params(input_dev
, ABS_Y
, 0, 1, 0, 0);
3970 /* kept for making udev and libwacom accepting the pad */
3971 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
3973 wacom_setup_numbered_buttons(input_dev
, features
->numbered_buttons
);
3975 switch (features
->type
) {
3978 case CINTIQ_COMPANION_2
:
3985 __set_bit(BTN_BACK
, input_dev
->keybit
);
3986 __set_bit(BTN_LEFT
, input_dev
->keybit
);
3987 __set_bit(BTN_FORWARD
, input_dev
->keybit
);
3988 __set_bit(BTN_RIGHT
, input_dev
->keybit
);
3989 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
3993 __set_bit(BTN_BACK
, input_dev
->keybit
);
3994 __set_bit(BTN_FORWARD
, input_dev
->keybit
);
3995 input_set_capability(input_dev
, EV_REL
, REL_WHEEL
);
3999 __set_bit(KEY_PROG1
, input_dev
->keybit
);
4000 __set_bit(KEY_PROG2
, input_dev
->keybit
);
4001 __set_bit(KEY_PROG3
, input_dev
->keybit
);
4003 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
4004 input_set_abs_params(input_dev
, ABS_THROTTLE
, 0, 71, 0, 0);
4008 __set_bit(KEY_PROG1
, input_dev
->keybit
);
4009 __set_bit(KEY_PROG2
, input_dev
->keybit
);
4010 __set_bit(KEY_PROG3
, input_dev
->keybit
);
4011 input_set_abs_params(input_dev
, ABS_X
, -2048, 2048, 0, 0);
4012 input_abs_set_res(input_dev
, ABS_X
, 1024); /* points/g */
4013 input_set_abs_params(input_dev
, ABS_Y
, -2048, 2048, 0, 0);
4014 input_abs_set_res(input_dev
, ABS_Y
, 1024);
4015 input_set_abs_params(input_dev
, ABS_Z
, -2048, 2048, 0, 0);
4016 input_abs_set_res(input_dev
, ABS_Z
, 1024);
4017 __set_bit(INPUT_PROP_ACCELEROMETER
, input_dev
->propbit
);
4021 __set_bit(KEY_PROG1
, input_dev
->keybit
);
4022 __set_bit(KEY_PROG2
, input_dev
->keybit
);
4023 __set_bit(KEY_PROG3
, input_dev
->keybit
);
4029 input_set_abs_params(input_dev
, ABS_RX
, 0, 4096, 0, 0);
4030 input_set_abs_params(input_dev
, ABS_RY
, 0, 4096, 0, 0);
4034 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
4039 input_set_abs_params(input_dev
, ABS_RY
, 0, 4096, 0, 0);
4043 input_set_abs_params(input_dev
, ABS_RX
, 0, 4096, 0, 0);
4053 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
4058 * For Bluetooth devices, the udev rule does not work correctly
4059 * for pads unless we add a stylus capability, which forces
4060 * ID_INPUT_TABLET to be set.
4062 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
4068 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
4075 __clear_bit(ABS_MISC
, input_dev
->absbit
);
4077 __set_bit(BTN_LEFT
, input_dev
->keybit
);
4078 __set_bit(BTN_FORWARD
, input_dev
->keybit
);
4079 __set_bit(BTN_BACK
, input_dev
->keybit
);
4080 __set_bit(BTN_RIGHT
, input_dev
->keybit
);
4085 input_set_capability(input_dev
, EV_MSC
, MSC_SERIAL
);
4086 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
4094 /* no pad supported */
4100 static const struct wacom_features wacom_features_0x00
=
4101 { "Wacom Penpartner", 5040, 3780, 255, 0,
4102 PENPARTNER
, WACOM_PENPRTN_RES
, WACOM_PENPRTN_RES
};
4103 static const struct wacom_features wacom_features_0x10
=
4104 { "Wacom Graphire", 10206, 7422, 511, 63,
4105 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
4106 static const struct wacom_features wacom_features_0x81
=
4107 { "Wacom Graphire BT", 16704, 12064, 511, 32,
4108 GRAPHIRE_BT
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
, 2 };
4109 static const struct wacom_features wacom_features_0x11
=
4110 { "Wacom Graphire2 4x5", 10206, 7422, 511, 63,
4111 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
4112 static const struct wacom_features wacom_features_0x12
=
4113 { "Wacom Graphire2 5x7", 13918, 10206, 511, 63,
4114 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
4115 static const struct wacom_features wacom_features_0x13
=
4116 { "Wacom Graphire3", 10208, 7424, 511, 63,
4117 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
4118 static const struct wacom_features wacom_features_0x14
=
4119 { "Wacom Graphire3 6x8", 16704, 12064, 511, 63,
4120 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
4121 static const struct wacom_features wacom_features_0x15
=
4122 { "Wacom Graphire4 4x5", 10208, 7424, 511, 63,
4123 WACOM_G4
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
4124 static const struct wacom_features wacom_features_0x16
=
4125 { "Wacom Graphire4 6x8", 16704, 12064, 511, 63,
4126 WACOM_G4
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
4127 static const struct wacom_features wacom_features_0x17
=
4128 { "Wacom BambooFun 4x5", 14760, 9225, 511, 63,
4129 WACOM_MO
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4130 static const struct wacom_features wacom_features_0x18
=
4131 { "Wacom BambooFun 6x8", 21648, 13530, 511, 63,
4132 WACOM_MO
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4133 static const struct wacom_features wacom_features_0x19
=
4134 { "Wacom Bamboo1 Medium", 16704, 12064, 511, 63,
4135 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
4136 static const struct wacom_features wacom_features_0x60
=
4137 { "Wacom Volito", 5104, 3712, 511, 63,
4138 GRAPHIRE
, WACOM_VOLITO_RES
, WACOM_VOLITO_RES
};
4139 static const struct wacom_features wacom_features_0x61
=
4140 { "Wacom PenStation2", 3250, 2320, 255, 63,
4141 GRAPHIRE
, WACOM_VOLITO_RES
, WACOM_VOLITO_RES
};
4142 static const struct wacom_features wacom_features_0x62
=
4143 { "Wacom Volito2 4x5", 5104, 3712, 511, 63,
4144 GRAPHIRE
, WACOM_VOLITO_RES
, WACOM_VOLITO_RES
};
4145 static const struct wacom_features wacom_features_0x63
=
4146 { "Wacom Volito2 2x3", 3248, 2320, 511, 63,
4147 GRAPHIRE
, WACOM_VOLITO_RES
, WACOM_VOLITO_RES
};
4148 static const struct wacom_features wacom_features_0x64
=
4149 { "Wacom PenPartner2", 3250, 2320, 511, 63,
4150 GRAPHIRE
, WACOM_VOLITO_RES
, WACOM_VOLITO_RES
};
4151 static const struct wacom_features wacom_features_0x65
=
4152 { "Wacom Bamboo", 14760, 9225, 511, 63,
4153 WACOM_MO
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4154 static const struct wacom_features wacom_features_0x69
=
4155 { "Wacom Bamboo1", 5104, 3712, 511, 63,
4156 GRAPHIRE
, WACOM_PENPRTN_RES
, WACOM_PENPRTN_RES
};
4157 static const struct wacom_features wacom_features_0x6A
=
4158 { "Wacom Bamboo1 4x6", 14760, 9225, 1023, 63,
4159 GRAPHIRE
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4160 static const struct wacom_features wacom_features_0x6B
=
4161 { "Wacom Bamboo1 5x8", 21648, 13530, 1023, 63,
4162 GRAPHIRE
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4163 static const struct wacom_features wacom_features_0x20
=
4164 { "Wacom Intuos 4x5", 12700, 10600, 1023, 31,
4165 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4166 static const struct wacom_features wacom_features_0x21
=
4167 { "Wacom Intuos 6x8", 20320, 16240, 1023, 31,
4168 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4169 static const struct wacom_features wacom_features_0x22
=
4170 { "Wacom Intuos 9x12", 30480, 24060, 1023, 31,
4171 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4172 static const struct wacom_features wacom_features_0x23
=
4173 { "Wacom Intuos 12x12", 30480, 31680, 1023, 31,
4174 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4175 static const struct wacom_features wacom_features_0x24
=
4176 { "Wacom Intuos 12x18", 45720, 31680, 1023, 31,
4177 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4178 static const struct wacom_features wacom_features_0x30
=
4179 { "Wacom PL400", 5408, 4056, 255, 0,
4180 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
4181 static const struct wacom_features wacom_features_0x31
=
4182 { "Wacom PL500", 6144, 4608, 255, 0,
4183 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
4184 static const struct wacom_features wacom_features_0x32
=
4185 { "Wacom PL600", 6126, 4604, 255, 0,
4186 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
4187 static const struct wacom_features wacom_features_0x33
=
4188 { "Wacom PL600SX", 6260, 5016, 255, 0,
4189 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
4190 static const struct wacom_features wacom_features_0x34
=
4191 { "Wacom PL550", 6144, 4608, 511, 0,
4192 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
4193 static const struct wacom_features wacom_features_0x35
=
4194 { "Wacom PL800", 7220, 5780, 511, 0,
4195 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
4196 static const struct wacom_features wacom_features_0x37
=
4197 { "Wacom PL700", 6758, 5406, 511, 0,
4198 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
4199 static const struct wacom_features wacom_features_0x38
=
4200 { "Wacom PL510", 6282, 4762, 511, 0,
4201 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
4202 static const struct wacom_features wacom_features_0x39
=
4203 { "Wacom DTU710", 34080, 27660, 511, 0,
4204 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
4205 static const struct wacom_features wacom_features_0xC4
=
4206 { "Wacom DTF521", 6282, 4762, 511, 0,
4207 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
4208 static const struct wacom_features wacom_features_0xC0
=
4209 { "Wacom DTF720", 6858, 5506, 511, 0,
4210 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
4211 static const struct wacom_features wacom_features_0xC2
=
4212 { "Wacom DTF720a", 6858, 5506, 511, 0,
4213 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
4214 static const struct wacom_features wacom_features_0x03
=
4215 { "Wacom Cintiq Partner", 20480, 15360, 511, 0,
4216 PTU
, WACOM_PL_RES
, WACOM_PL_RES
};
4217 static const struct wacom_features wacom_features_0x41
=
4218 { "Wacom Intuos2 4x5", 12700, 10600, 1023, 31,
4219 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4220 static const struct wacom_features wacom_features_0x42
=
4221 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
4222 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4223 static const struct wacom_features wacom_features_0x43
=
4224 { "Wacom Intuos2 9x12", 30480, 24060, 1023, 31,
4225 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4226 static const struct wacom_features wacom_features_0x44
=
4227 { "Wacom Intuos2 12x12", 30480, 31680, 1023, 31,
4228 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4229 static const struct wacom_features wacom_features_0x45
=
4230 { "Wacom Intuos2 12x18", 45720, 31680, 1023, 31,
4231 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4232 static const struct wacom_features wacom_features_0xB0
=
4233 { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63,
4234 INTUOS3S
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 4 };
4235 static const struct wacom_features wacom_features_0xB1
=
4236 { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63,
4237 INTUOS3
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 8 };
4238 static const struct wacom_features wacom_features_0xB2
=
4239 { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63,
4240 INTUOS3
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 8 };
4241 static const struct wacom_features wacom_features_0xB3
=
4242 { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63,
4243 INTUOS3L
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 8 };
4244 static const struct wacom_features wacom_features_0xB4
=
4245 { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63,
4246 INTUOS3L
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 8 };
4247 static const struct wacom_features wacom_features_0xB5
=
4248 { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63,
4249 INTUOS3
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 8 };
4250 static const struct wacom_features wacom_features_0xB7
=
4251 { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63,
4252 INTUOS3S
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 4 };
4253 static const struct wacom_features wacom_features_0xB8
=
4254 { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63,
4255 INTUOS4S
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 7 };
4256 static const struct wacom_features wacom_features_0xB9
=
4257 { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63,
4258 INTUOS4
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9 };
4259 static const struct wacom_features wacom_features_0xBA
=
4260 { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63,
4261 INTUOS4L
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9 };
4262 static const struct wacom_features wacom_features_0xBB
=
4263 { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63,
4264 INTUOS4L
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9 };
4265 static const struct wacom_features wacom_features_0xBC
=
4266 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
4267 INTUOS4
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9 };
4268 static const struct wacom_features wacom_features_0xBD
=
4269 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
4270 INTUOS4WL
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9 };
4271 static const struct wacom_features wacom_features_0x26
=
4272 { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63,
4273 INTUOS5S
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 7, .touch_max
= 16 };
4274 static const struct wacom_features wacom_features_0x27
=
4275 { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63,
4276 INTUOS5
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9, .touch_max
= 16 };
4277 static const struct wacom_features wacom_features_0x28
=
4278 { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63,
4279 INTUOS5L
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9, .touch_max
= 16 };
4280 static const struct wacom_features wacom_features_0x29
=
4281 { "Wacom Intuos5 S", 31496, 19685, 2047, 63,
4282 INTUOS5S
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 7 };
4283 static const struct wacom_features wacom_features_0x2A
=
4284 { "Wacom Intuos5 M", 44704, 27940, 2047, 63,
4285 INTUOS5
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9 };
4286 static const struct wacom_features wacom_features_0x314
=
4287 { "Wacom Intuos Pro S", 31496, 19685, 2047, 63,
4288 INTUOSPS
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 7, .touch_max
= 16,
4289 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4290 static const struct wacom_features wacom_features_0x315
=
4291 { "Wacom Intuos Pro M", 44704, 27940, 2047, 63,
4292 INTUOSPM
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9, .touch_max
= 16,
4293 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4294 static const struct wacom_features wacom_features_0x317
=
4295 { "Wacom Intuos Pro L", 65024, 40640, 2047, 63,
4296 INTUOSPL
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9, .touch_max
= 16,
4297 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4298 static const struct wacom_features wacom_features_0xF4
=
4299 { "Wacom Cintiq 24HD", 104480, 65600, 2047, 63,
4300 WACOM_24HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 16,
4301 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4302 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
4303 static const struct wacom_features wacom_features_0xF8
=
4304 { "Wacom Cintiq 24HD touch", 104480, 65600, 2047, 63, /* Pen */
4305 WACOM_24HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 16,
4306 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4307 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4308 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0xf6 };
4309 static const struct wacom_features wacom_features_0xF6
=
4310 { "Wacom Cintiq 24HD touch", .type
= WACOM_24HDT
, /* Touch */
4311 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0xf8, .touch_max
= 10,
4312 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4313 static const struct wacom_features wacom_features_0x32A
=
4314 { "Wacom Cintiq 27QHD", 120140, 67920, 2047, 63,
4315 WACOM_27QHD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 0,
4316 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4317 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
4318 static const struct wacom_features wacom_features_0x32B
=
4319 { "Wacom Cintiq 27QHD touch", 120140, 67920, 2047, 63,
4320 WACOM_27QHD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 0,
4321 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4322 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4323 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x32C };
4324 static const struct wacom_features wacom_features_0x32C
=
4325 { "Wacom Cintiq 27QHD touch", .type
= WACOM_27QHDT
,
4326 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x32B, .touch_max
= 10 };
4327 static const struct wacom_features wacom_features_0x3F
=
4328 { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63,
4329 CINTIQ
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 8 };
4330 static const struct wacom_features wacom_features_0xC5
=
4331 { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63,
4332 WACOM_BEE
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 10 };
4333 static const struct wacom_features wacom_features_0xC6
=
4334 { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63,
4335 WACOM_BEE
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 10 };
4336 static const struct wacom_features wacom_features_0x304
=
4337 { "Wacom Cintiq 13HD", 59552, 33848, 1023, 63,
4338 WACOM_13HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9,
4339 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4340 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
4341 static const struct wacom_features wacom_features_0x333
=
4342 { "Wacom Cintiq 13HD touch", 59552, 33848, 2047, 63,
4343 WACOM_13HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9,
4344 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4345 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4346 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x335 };
4347 static const struct wacom_features wacom_features_0x335
=
4348 { "Wacom Cintiq 13HD touch", .type
= WACOM_24HDT
, /* Touch */
4349 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x333, .touch_max
= 10,
4350 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4351 static const struct wacom_features wacom_features_0xC7
=
4352 { "Wacom DTU1931", 37832, 30305, 511, 0,
4353 PL
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4354 static const struct wacom_features wacom_features_0xCE
=
4355 { "Wacom DTU2231", 47864, 27011, 511, 0,
4356 DTU
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
,
4357 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBMOUSE
};
4358 static const struct wacom_features wacom_features_0xF0
=
4359 { "Wacom DTU1631", 34623, 19553, 511, 0,
4360 DTU
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4361 static const struct wacom_features wacom_features_0xFB
=
4362 { "Wacom DTU1031", 22096, 13960, 511, 0,
4363 DTUS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, 4,
4364 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
,
4365 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
};
4366 static const struct wacom_features wacom_features_0x32F
=
4367 { "Wacom DTU1031X", 22672, 12928, 511, 0,
4368 DTUSX
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, 0,
4369 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
,
4370 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
};
4371 static const struct wacom_features wacom_features_0x336
=
4372 { "Wacom DTU1141", 23672, 13403, 1023, 0,
4373 DTUS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, 4,
4374 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
,
4375 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
};
4376 static const struct wacom_features wacom_features_0x57
=
4377 { "Wacom DTK2241", 95840, 54260, 2047, 63,
4378 DTK
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 6,
4379 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4380 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
4381 static const struct wacom_features wacom_features_0x59
= /* Pen */
4382 { "Wacom DTH2242", 95840, 54260, 2047, 63,
4383 DTK
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 6,
4384 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4385 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4386 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x5D };
4387 static const struct wacom_features wacom_features_0x5D
= /* Touch */
4388 { "Wacom DTH2242", .type
= WACOM_24HDT
,
4389 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x59, .touch_max
= 10,
4390 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4391 static const struct wacom_features wacom_features_0xCC
=
4392 { "Wacom Cintiq 21UX2", 87200, 65600, 2047, 63,
4393 WACOM_21UX2
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 18,
4394 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4395 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
4396 static const struct wacom_features wacom_features_0xFA
=
4397 { "Wacom Cintiq 22HD", 95840, 54260, 2047, 63,
4398 WACOM_22HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 18,
4399 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4400 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
4401 static const struct wacom_features wacom_features_0x5B
=
4402 { "Wacom Cintiq 22HDT", 95840, 54260, 2047, 63,
4403 WACOM_22HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 18,
4404 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4405 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4406 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x5e };
4407 static const struct wacom_features wacom_features_0x5E
=
4408 { "Wacom Cintiq 22HDT", .type
= WACOM_24HDT
,
4409 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x5b, .touch_max
= 10,
4410 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4411 static const struct wacom_features wacom_features_0x90
=
4412 { "Wacom ISDv4 90", 26202, 16325, 255, 0,
4413 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
}; /* Pen-only */
4414 static const struct wacom_features wacom_features_0x93
=
4415 { "Wacom ISDv4 93", 26202, 16325, 255, 0,
4416 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 1 };
4417 static const struct wacom_features wacom_features_0x97
=
4418 { "Wacom ISDv4 97", 26202, 16325, 511, 0,
4419 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
}; /* Pen-only */
4420 static const struct wacom_features wacom_features_0x9A
=
4421 { "Wacom ISDv4 9A", 26202, 16325, 255, 0,
4422 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 1 };
4423 static const struct wacom_features wacom_features_0x9F
=
4424 { "Wacom ISDv4 9F", 26202, 16325, 255, 0,
4425 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 1 };
4426 static const struct wacom_features wacom_features_0xE2
=
4427 { "Wacom ISDv4 E2", 26202, 16325, 255, 0,
4428 TABLETPC2FG
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
4429 static const struct wacom_features wacom_features_0xE3
=
4430 { "Wacom ISDv4 E3", 26202, 16325, 255, 0,
4431 TABLETPC2FG
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
4432 static const struct wacom_features wacom_features_0xE5
=
4433 { "Wacom ISDv4 E5", 26202, 16325, 255, 0,
4434 MTSCREEN
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4435 static const struct wacom_features wacom_features_0xE6
=
4436 { "Wacom ISDv4 E6", 27760, 15694, 255, 0,
4437 TABLETPC2FG
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
4438 static const struct wacom_features wacom_features_0xEC
=
4439 { "Wacom ISDv4 EC", 25710, 14500, 255, 0,
4440 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
}; /* Pen-only */
4441 static const struct wacom_features wacom_features_0xED
=
4442 { "Wacom ISDv4 ED", 26202, 16325, 255, 0,
4443 TABLETPCE
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 1 };
4444 static const struct wacom_features wacom_features_0xEF
=
4445 { "Wacom ISDv4 EF", 26202, 16325, 255, 0,
4446 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
}; /* Pen-only */
4447 static const struct wacom_features wacom_features_0x100
=
4448 { "Wacom ISDv4 100", 26202, 16325, 255, 0,
4449 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4450 static const struct wacom_features wacom_features_0x101
=
4451 { "Wacom ISDv4 101", 26202, 16325, 255, 0,
4452 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4453 static const struct wacom_features wacom_features_0x10D
=
4454 { "Wacom ISDv4 10D", 26202, 16325, 255, 0,
4455 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4456 static const struct wacom_features wacom_features_0x10E
=
4457 { "Wacom ISDv4 10E", 27760, 15694, 255, 0,
4458 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4459 static const struct wacom_features wacom_features_0x10F
=
4460 { "Wacom ISDv4 10F", 27760, 15694, 255, 0,
4461 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4462 static const struct wacom_features wacom_features_0x116
=
4463 { "Wacom ISDv4 116", 26202, 16325, 255, 0,
4464 TABLETPCE
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 1 };
4465 static const struct wacom_features wacom_features_0x12C
=
4466 { "Wacom ISDv4 12C", 27848, 15752, 2047, 0,
4467 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
}; /* Pen-only */
4468 static const struct wacom_features wacom_features_0x4001
=
4469 { "Wacom ISDv4 4001", 26202, 16325, 255, 0,
4470 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4471 static const struct wacom_features wacom_features_0x4004
=
4472 { "Wacom ISDv4 4004", 11060, 6220, 255, 0,
4473 MTTPC_B
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4474 static const struct wacom_features wacom_features_0x5000
=
4475 { "Wacom ISDv4 5000", 27848, 15752, 1023, 0,
4476 MTTPC_B
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4477 static const struct wacom_features wacom_features_0x5002
=
4478 { "Wacom ISDv4 5002", 29576, 16724, 1023, 0,
4479 MTTPC_B
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4480 static const struct wacom_features wacom_features_0x47
=
4481 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
4482 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4483 static const struct wacom_features wacom_features_0x84
=
4484 { "Wacom Wireless Receiver", .type
= WIRELESS
, .touch_max
= 16 };
4485 static const struct wacom_features wacom_features_0xD0
=
4486 { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31,
4487 BAMBOO_TOUCH
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
4488 static const struct wacom_features wacom_features_0xD1
=
4489 { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31,
4490 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
4491 static const struct wacom_features wacom_features_0xD2
=
4492 { "Wacom Bamboo Craft", 14720, 9200, 1023, 31,
4493 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
4494 static const struct wacom_features wacom_features_0xD3
=
4495 { "Wacom Bamboo 2FG 6x8", 21648, 13700, 1023, 31,
4496 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
4497 static const struct wacom_features wacom_features_0xD4
=
4498 { "Wacom Bamboo Pen", 14720, 9200, 1023, 31,
4499 BAMBOO_PEN
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4500 static const struct wacom_features wacom_features_0xD5
=
4501 { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31,
4502 BAMBOO_PEN
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4503 static const struct wacom_features wacom_features_0xD6
=
4504 { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31,
4505 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
4506 static const struct wacom_features wacom_features_0xD7
=
4507 { "Wacom BambooPT 2FG Small", 14720, 9200, 1023, 31,
4508 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
4509 static const struct wacom_features wacom_features_0xD8
=
4510 { "Wacom Bamboo Comic 2FG", 21648, 13700, 1023, 31,
4511 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
4512 static const struct wacom_features wacom_features_0xDA
=
4513 { "Wacom Bamboo 2FG 4x5 SE", 14720, 9200, 1023, 31,
4514 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
4515 static const struct wacom_features wacom_features_0xDB
=
4516 { "Wacom Bamboo 2FG 6x8 SE", 21648, 13700, 1023, 31,
4517 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
4518 static const struct wacom_features wacom_features_0xDD
=
4519 { "Wacom Bamboo Connect", 14720, 9200, 1023, 31,
4520 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4521 static const struct wacom_features wacom_features_0xDE
=
4522 { "Wacom Bamboo 16FG 4x5", 14720, 9200, 1023, 31,
4523 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 16 };
4524 static const struct wacom_features wacom_features_0xDF
=
4525 { "Wacom Bamboo 16FG 6x8", 21648, 13700, 1023, 31,
4526 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 16 };
4527 static const struct wacom_features wacom_features_0x300
=
4528 { "Wacom Bamboo One S", 14720, 9225, 1023, 31,
4529 BAMBOO_PEN
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4530 static const struct wacom_features wacom_features_0x301
=
4531 { "Wacom Bamboo One M", 21648, 13530, 1023, 31,
4532 BAMBOO_PEN
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4533 static const struct wacom_features wacom_features_0x302
=
4534 { "Wacom Intuos PT S", 15200, 9500, 1023, 31,
4535 INTUOSHT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 16,
4536 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4537 static const struct wacom_features wacom_features_0x303
=
4538 { "Wacom Intuos PT M", 21600, 13500, 1023, 31,
4539 INTUOSHT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 16,
4540 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4541 static const struct wacom_features wacom_features_0x30E
=
4542 { "Wacom Intuos S", 15200, 9500, 1023, 31,
4543 INTUOSHT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
,
4544 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4545 static const struct wacom_features wacom_features_0x6004
=
4546 { "ISD-V4", 12800, 8000, 255, 0,
4547 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4548 static const struct wacom_features wacom_features_0x307
=
4549 { "Wacom ISDv5 307", 59552, 33848, 2047, 63,
4550 CINTIQ_HYBRID
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9,
4551 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4552 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4553 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x309 };
4554 static const struct wacom_features wacom_features_0x309
=
4555 { "Wacom ISDv5 309", .type
= WACOM_24HDT
, /* Touch */
4556 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x0307, .touch_max
= 10,
4557 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4558 static const struct wacom_features wacom_features_0x30A
=
4559 { "Wacom ISDv5 30A", 59552, 33848, 2047, 63,
4560 CINTIQ_HYBRID
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9,
4561 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4562 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4563 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x30C };
4564 static const struct wacom_features wacom_features_0x30C
=
4565 { "Wacom ISDv5 30C", .type
= WACOM_24HDT
, /* Touch */
4566 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x30A, .touch_max
= 10,
4567 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4568 static const struct wacom_features wacom_features_0x318
=
4569 { "Wacom USB Bamboo PAD", 4095, 4095, /* Touch */
4570 .type
= BAMBOO_PAD
, 35, 48, .touch_max
= 4 };
4571 static const struct wacom_features wacom_features_0x319
=
4572 { "Wacom Wireless Bamboo PAD", 4095, 4095, /* Touch */
4573 .type
= BAMBOO_PAD
, 35, 48, .touch_max
= 4 };
4574 static const struct wacom_features wacom_features_0x325
=
4575 { "Wacom ISDv5 325", 59552, 33848, 2047, 63,
4576 CINTIQ_COMPANION_2
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 11,
4577 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4578 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4579 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x326 };
4580 static const struct wacom_features wacom_features_0x326
= /* Touch */
4581 { "Wacom ISDv5 326", .type
= HID_GENERIC
, .oVid
= USB_VENDOR_ID_WACOM
,
4583 static const struct wacom_features wacom_features_0x323
=
4584 { "Wacom Intuos P M", 21600, 13500, 1023, 31,
4585 INTUOSHT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
,
4586 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4587 static const struct wacom_features wacom_features_0x331
=
4588 { "Wacom Express Key Remote", .type
= REMOTE
,
4589 .numbered_buttons
= 18, .check_for_hid_type
= true,
4590 .hid_type
= HID_TYPE_USBNONE
};
4591 static const struct wacom_features wacom_features_0x33B
=
4592 { "Wacom Intuos S 2", 15200, 9500, 2047, 63,
4593 INTUOSHT2
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
,
4594 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4595 static const struct wacom_features wacom_features_0x33C
=
4596 { "Wacom Intuos PT S 2", 15200, 9500, 2047, 63,
4597 INTUOSHT2
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 16,
4598 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4599 static const struct wacom_features wacom_features_0x33D
=
4600 { "Wacom Intuos P M 2", 21600, 13500, 2047, 63,
4601 INTUOSHT2
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
,
4602 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4603 static const struct wacom_features wacom_features_0x33E
=
4604 { "Wacom Intuos PT M 2", 21600, 13500, 2047, 63,
4605 INTUOSHT2
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 16,
4606 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4607 static const struct wacom_features wacom_features_0x343
=
4608 { "Wacom DTK1651", 34816, 19759, 1023, 0,
4609 DTUS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, 4,
4610 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
,
4611 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
};
4612 static const struct wacom_features wacom_features_0x360
=
4613 { "Wacom Intuos Pro M", 44800, 29600, 8191, 63,
4614 INTUOSP2_BT
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9, .touch_max
= 10 };
4615 static const struct wacom_features wacom_features_0x361
=
4616 { "Wacom Intuos Pro L", 62200, 43200, 8191, 63,
4617 INTUOSP2_BT
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9, .touch_max
= 10 };
4618 static const struct wacom_features wacom_features_0x377
=
4619 { "Wacom Intuos BT S", 15200, 9500, 4095, 63,
4620 INTUOSHT3_BT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, 4 };
4621 static const struct wacom_features wacom_features_0x379
=
4622 { "Wacom Intuos BT M", 21600, 13500, 4095, 63,
4623 INTUOSHT3_BT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, 4 };
4624 static const struct wacom_features wacom_features_0x37A
=
4625 { "Wacom One by Wacom S", 15200, 9500, 2047, 63,
4626 BAMBOO_PEN
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4627 static const struct wacom_features wacom_features_0x37B
=
4628 { "Wacom One by Wacom M", 21600, 13500, 2047, 63,
4629 BAMBOO_PEN
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4631 static const struct wacom_features wacom_features_HID_ANY_ID
=
4632 { "Wacom HID", .type
= HID_GENERIC
, .oVid
= HID_ANY_ID
, .oPid
= HID_ANY_ID
};
4634 #define USB_DEVICE_WACOM(prod) \
4635 HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4636 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4638 #define BT_DEVICE_WACOM(prod) \
4639 HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4640 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4642 #define I2C_DEVICE_WACOM(prod) \
4643 HID_DEVICE(BUS_I2C, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4644 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4646 #define USB_DEVICE_LENOVO(prod) \
4647 HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
4648 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4650 const struct hid_device_id wacom_ids
[] = {
4651 { USB_DEVICE_WACOM(0x00) },
4652 { USB_DEVICE_WACOM(0x03) },
4653 { USB_DEVICE_WACOM(0x10) },
4654 { USB_DEVICE_WACOM(0x11) },
4655 { USB_DEVICE_WACOM(0x12) },
4656 { USB_DEVICE_WACOM(0x13) },
4657 { USB_DEVICE_WACOM(0x14) },
4658 { USB_DEVICE_WACOM(0x15) },
4659 { USB_DEVICE_WACOM(0x16) },
4660 { USB_DEVICE_WACOM(0x17) },
4661 { USB_DEVICE_WACOM(0x18) },
4662 { USB_DEVICE_WACOM(0x19) },
4663 { USB_DEVICE_WACOM(0x20) },
4664 { USB_DEVICE_WACOM(0x21) },
4665 { USB_DEVICE_WACOM(0x22) },
4666 { USB_DEVICE_WACOM(0x23) },
4667 { USB_DEVICE_WACOM(0x24) },
4668 { USB_DEVICE_WACOM(0x26) },
4669 { USB_DEVICE_WACOM(0x27) },
4670 { USB_DEVICE_WACOM(0x28) },
4671 { USB_DEVICE_WACOM(0x29) },
4672 { USB_DEVICE_WACOM(0x2A) },
4673 { USB_DEVICE_WACOM(0x30) },
4674 { USB_DEVICE_WACOM(0x31) },
4675 { USB_DEVICE_WACOM(0x32) },
4676 { USB_DEVICE_WACOM(0x33) },
4677 { USB_DEVICE_WACOM(0x34) },
4678 { USB_DEVICE_WACOM(0x35) },
4679 { USB_DEVICE_WACOM(0x37) },
4680 { USB_DEVICE_WACOM(0x38) },
4681 { USB_DEVICE_WACOM(0x39) },
4682 { USB_DEVICE_WACOM(0x3F) },
4683 { USB_DEVICE_WACOM(0x41) },
4684 { USB_DEVICE_WACOM(0x42) },
4685 { USB_DEVICE_WACOM(0x43) },
4686 { USB_DEVICE_WACOM(0x44) },
4687 { USB_DEVICE_WACOM(0x45) },
4688 { USB_DEVICE_WACOM(0x47) },
4689 { USB_DEVICE_WACOM(0x57) },
4690 { USB_DEVICE_WACOM(0x59) },
4691 { USB_DEVICE_WACOM(0x5B) },
4692 { USB_DEVICE_WACOM(0x5D) },
4693 { USB_DEVICE_WACOM(0x5E) },
4694 { USB_DEVICE_WACOM(0x60) },
4695 { USB_DEVICE_WACOM(0x61) },
4696 { USB_DEVICE_WACOM(0x62) },
4697 { USB_DEVICE_WACOM(0x63) },
4698 { USB_DEVICE_WACOM(0x64) },
4699 { USB_DEVICE_WACOM(0x65) },
4700 { USB_DEVICE_WACOM(0x69) },
4701 { USB_DEVICE_WACOM(0x6A) },
4702 { USB_DEVICE_WACOM(0x6B) },
4703 { BT_DEVICE_WACOM(0x81) },
4704 { USB_DEVICE_WACOM(0x84) },
4705 { USB_DEVICE_WACOM(0x90) },
4706 { USB_DEVICE_WACOM(0x93) },
4707 { USB_DEVICE_WACOM(0x97) },
4708 { USB_DEVICE_WACOM(0x9A) },
4709 { USB_DEVICE_WACOM(0x9F) },
4710 { USB_DEVICE_WACOM(0xB0) },
4711 { USB_DEVICE_WACOM(0xB1) },
4712 { USB_DEVICE_WACOM(0xB2) },
4713 { USB_DEVICE_WACOM(0xB3) },
4714 { USB_DEVICE_WACOM(0xB4) },
4715 { USB_DEVICE_WACOM(0xB5) },
4716 { USB_DEVICE_WACOM(0xB7) },
4717 { USB_DEVICE_WACOM(0xB8) },
4718 { USB_DEVICE_WACOM(0xB9) },
4719 { USB_DEVICE_WACOM(0xBA) },
4720 { USB_DEVICE_WACOM(0xBB) },
4721 { USB_DEVICE_WACOM(0xBC) },
4722 { BT_DEVICE_WACOM(0xBD) },
4723 { USB_DEVICE_WACOM(0xC0) },
4724 { USB_DEVICE_WACOM(0xC2) },
4725 { USB_DEVICE_WACOM(0xC4) },
4726 { USB_DEVICE_WACOM(0xC5) },
4727 { USB_DEVICE_WACOM(0xC6) },
4728 { USB_DEVICE_WACOM(0xC7) },
4729 { USB_DEVICE_WACOM(0xCC) },
4730 { USB_DEVICE_WACOM(0xCE) },
4731 { USB_DEVICE_WACOM(0xD0) },
4732 { USB_DEVICE_WACOM(0xD1) },
4733 { USB_DEVICE_WACOM(0xD2) },
4734 { USB_DEVICE_WACOM(0xD3) },
4735 { USB_DEVICE_WACOM(0xD4) },
4736 { USB_DEVICE_WACOM(0xD5) },
4737 { USB_DEVICE_WACOM(0xD6) },
4738 { USB_DEVICE_WACOM(0xD7) },
4739 { USB_DEVICE_WACOM(0xD8) },
4740 { USB_DEVICE_WACOM(0xDA) },
4741 { USB_DEVICE_WACOM(0xDB) },
4742 { USB_DEVICE_WACOM(0xDD) },
4743 { USB_DEVICE_WACOM(0xDE) },
4744 { USB_DEVICE_WACOM(0xDF) },
4745 { USB_DEVICE_WACOM(0xE2) },
4746 { USB_DEVICE_WACOM(0xE3) },
4747 { USB_DEVICE_WACOM(0xE5) },
4748 { USB_DEVICE_WACOM(0xE6) },
4749 { USB_DEVICE_WACOM(0xEC) },
4750 { USB_DEVICE_WACOM(0xED) },
4751 { USB_DEVICE_WACOM(0xEF) },
4752 { USB_DEVICE_WACOM(0xF0) },
4753 { USB_DEVICE_WACOM(0xF4) },
4754 { USB_DEVICE_WACOM(0xF6) },
4755 { USB_DEVICE_WACOM(0xF8) },
4756 { USB_DEVICE_WACOM(0xFA) },
4757 { USB_DEVICE_WACOM(0xFB) },
4758 { USB_DEVICE_WACOM(0x100) },
4759 { USB_DEVICE_WACOM(0x101) },
4760 { USB_DEVICE_WACOM(0x10D) },
4761 { USB_DEVICE_WACOM(0x10E) },
4762 { USB_DEVICE_WACOM(0x10F) },
4763 { USB_DEVICE_WACOM(0x116) },
4764 { USB_DEVICE_WACOM(0x12C) },
4765 { USB_DEVICE_WACOM(0x300) },
4766 { USB_DEVICE_WACOM(0x301) },
4767 { USB_DEVICE_WACOM(0x302) },
4768 { USB_DEVICE_WACOM(0x303) },
4769 { USB_DEVICE_WACOM(0x304) },
4770 { USB_DEVICE_WACOM(0x307) },
4771 { USB_DEVICE_WACOM(0x309) },
4772 { USB_DEVICE_WACOM(0x30A) },
4773 { USB_DEVICE_WACOM(0x30C) },
4774 { USB_DEVICE_WACOM(0x30E) },
4775 { USB_DEVICE_WACOM(0x314) },
4776 { USB_DEVICE_WACOM(0x315) },
4777 { USB_DEVICE_WACOM(0x317) },
4778 { USB_DEVICE_WACOM(0x318) },
4779 { USB_DEVICE_WACOM(0x319) },
4780 { USB_DEVICE_WACOM(0x323) },
4781 { USB_DEVICE_WACOM(0x325) },
4782 { USB_DEVICE_WACOM(0x326) },
4783 { USB_DEVICE_WACOM(0x32A) },
4784 { USB_DEVICE_WACOM(0x32B) },
4785 { USB_DEVICE_WACOM(0x32C) },
4786 { USB_DEVICE_WACOM(0x32F) },
4787 { USB_DEVICE_WACOM(0x331) },
4788 { USB_DEVICE_WACOM(0x333) },
4789 { USB_DEVICE_WACOM(0x335) },
4790 { USB_DEVICE_WACOM(0x336) },
4791 { USB_DEVICE_WACOM(0x33B) },
4792 { USB_DEVICE_WACOM(0x33C) },
4793 { USB_DEVICE_WACOM(0x33D) },
4794 { USB_DEVICE_WACOM(0x33E) },
4795 { USB_DEVICE_WACOM(0x343) },
4796 { BT_DEVICE_WACOM(0x360) },
4797 { BT_DEVICE_WACOM(0x361) },
4798 { BT_DEVICE_WACOM(0x377) },
4799 { BT_DEVICE_WACOM(0x379) },
4800 { USB_DEVICE_WACOM(0x37A) },
4801 { USB_DEVICE_WACOM(0x37B) },
4802 { USB_DEVICE_WACOM(0x4001) },
4803 { USB_DEVICE_WACOM(0x4004) },
4804 { USB_DEVICE_WACOM(0x5000) },
4805 { USB_DEVICE_WACOM(0x5002) },
4806 { USB_DEVICE_LENOVO(0x6004) },
4808 { USB_DEVICE_WACOM(HID_ANY_ID
) },
4809 { I2C_DEVICE_WACOM(HID_ANY_ID
) },
4810 { BT_DEVICE_WACOM(HID_ANY_ID
) },
4813 MODULE_DEVICE_TABLE(hid
, wacom_ids
);