1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * drivers/input/tablet/wacom_wac.c
5 * USB Wacom tablet support - Wacom specific code
11 #include "wacom_wac.h"
13 #include <linux/input/mt.h>
15 /* resolution for penabled devices */
16 #define WACOM_PL_RES 20
17 #define WACOM_PENPRTN_RES 40
18 #define WACOM_VOLITO_RES 50
19 #define WACOM_GRAPHIRE_RES 80
20 #define WACOM_INTUOS_RES 100
21 #define WACOM_INTUOS3_RES 200
23 /* Newer Cintiq and DTU have an offset between tablet and screen areas */
24 #define WACOM_DTU_OFFSET 200
25 #define WACOM_CINTIQ_OFFSET 400
28 * Scale factor relating reported contact size to logical contact area.
29 * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo
31 #define WACOM_CONTACT_AREA_SCALE 2607
33 static bool touch_arbitration
= 1;
34 module_param(touch_arbitration
, bool, 0644);
35 MODULE_PARM_DESC(touch_arbitration
, " on (Y) off (N)");
37 static void wacom_report_numbered_buttons(struct input_dev
*input_dev
,
38 int button_count
, int mask
);
40 static int wacom_numbered_button_to_key(int n
);
42 static void wacom_update_led(struct wacom
*wacom
, int button_count
, int mask
,
45 * Percent of battery capacity for Graphire.
46 * 8th value means AC online and show 100% capacity.
48 static unsigned short batcap_gr
[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
51 * Percent of battery capacity for Intuos4 WL, AC has a separate bit.
53 static unsigned short batcap_i4
[8] = { 1, 15, 30, 45, 60, 70, 85, 100 };
55 static void __wacom_notify_battery(struct wacom_battery
*battery
,
56 int bat_status
, int bat_capacity
,
57 bool bat_charging
, bool bat_connected
,
60 bool changed
= battery
->bat_status
!= bat_status
||
61 battery
->battery_capacity
!= bat_capacity
||
62 battery
->bat_charging
!= bat_charging
||
63 battery
->bat_connected
!= bat_connected
||
64 battery
->ps_connected
!= ps_connected
;
67 battery
->bat_status
= bat_status
;
68 battery
->battery_capacity
= bat_capacity
;
69 battery
->bat_charging
= bat_charging
;
70 battery
->bat_connected
= bat_connected
;
71 battery
->ps_connected
= ps_connected
;
74 power_supply_changed(battery
->battery
);
78 static void wacom_notify_battery(struct wacom_wac
*wacom_wac
,
79 int bat_status
, int bat_capacity
, bool bat_charging
,
80 bool bat_connected
, bool ps_connected
)
82 struct wacom
*wacom
= container_of(wacom_wac
, struct wacom
, wacom_wac
);
84 __wacom_notify_battery(&wacom
->battery
, bat_status
, bat_capacity
,
85 bat_charging
, bat_connected
, ps_connected
);
88 static int wacom_penpartner_irq(struct wacom_wac
*wacom
)
90 unsigned char *data
= wacom
->data
;
91 struct input_dev
*input
= wacom
->pen_input
;
96 wacom
->tool
[0] = (data
[5] & 0x20) ? BTN_TOOL_RUBBER
: BTN_TOOL_PEN
;
97 wacom
->id
[0] = (data
[5] & 0x20) ? ERASER_DEVICE_ID
: STYLUS_DEVICE_ID
;
98 input_report_key(input
, wacom
->tool
[0], 1);
99 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]); /* report tool id */
100 input_report_abs(input
, ABS_X
, get_unaligned_le16(&data
[1]));
101 input_report_abs(input
, ABS_Y
, get_unaligned_le16(&data
[3]));
102 input_report_abs(input
, ABS_PRESSURE
, (signed char)data
[6] + 127);
103 input_report_key(input
, BTN_TOUCH
, ((signed char)data
[6] > -127));
104 input_report_key(input
, BTN_STYLUS
, (data
[5] & 0x40));
106 input_report_key(input
, wacom
->tool
[0], 0);
107 input_report_abs(input
, ABS_MISC
, 0); /* report tool id */
108 input_report_abs(input
, ABS_PRESSURE
, -1);
109 input_report_key(input
, BTN_TOUCH
, 0);
114 input_report_key(input
, BTN_TOOL_PEN
, 1);
115 input_report_abs(input
, ABS_MISC
, STYLUS_DEVICE_ID
); /* report tool id */
116 input_report_abs(input
, ABS_X
, get_unaligned_le16(&data
[1]));
117 input_report_abs(input
, ABS_Y
, get_unaligned_le16(&data
[3]));
118 input_report_abs(input
, ABS_PRESSURE
, (signed char)data
[6] + 127);
119 input_report_key(input
, BTN_TOUCH
, ((signed char)data
[6] > -80) && !(data
[5] & 0x20));
120 input_report_key(input
, BTN_STYLUS
, (data
[5] & 0x40));
124 dev_dbg(input
->dev
.parent
,
125 "%s: received unknown report #%d\n", __func__
, data
[0]);
132 static int wacom_pl_irq(struct wacom_wac
*wacom
)
134 struct wacom_features
*features
= &wacom
->features
;
135 unsigned char *data
= wacom
->data
;
136 struct input_dev
*input
= wacom
->pen_input
;
139 if (data
[0] != WACOM_REPORT_PENABLED
) {
140 dev_dbg(input
->dev
.parent
,
141 "%s: received unknown report #%d\n", __func__
, data
[0]);
145 prox
= data
[1] & 0x40;
148 if ((data
[0] & 0x10) || (data
[4] & 0x20)) {
149 wacom
->tool
[0] = BTN_TOOL_RUBBER
;
150 wacom
->id
[0] = ERASER_DEVICE_ID
;
153 wacom
->tool
[0] = BTN_TOOL_PEN
;
154 wacom
->id
[0] = STYLUS_DEVICE_ID
;
158 /* If the eraser is in prox, STYLUS2 is always set. If we
159 * mis-detected the type and notice that STYLUS2 isn't set
160 * then force the eraser out of prox and let the pen in.
162 if (wacom
->tool
[0] == BTN_TOOL_RUBBER
&& !(data
[4] & 0x20)) {
163 input_report_key(input
, BTN_TOOL_RUBBER
, 0);
164 input_report_abs(input
, ABS_MISC
, 0);
166 wacom
->tool
[0] = BTN_TOOL_PEN
;
167 wacom
->id
[0] = STYLUS_DEVICE_ID
;
171 pressure
= (signed char)((data
[7] << 1) | ((data
[4] >> 2) & 1));
172 if (features
->pressure_max
> 255)
173 pressure
= (pressure
<< 1) | ((data
[4] >> 6) & 1);
174 pressure
+= (features
->pressure_max
+ 1) / 2;
176 input_report_abs(input
, ABS_X
, data
[3] | (data
[2] << 7) | ((data
[1] & 0x03) << 14));
177 input_report_abs(input
, ABS_Y
, data
[6] | (data
[5] << 7) | ((data
[4] & 0x03) << 14));
178 input_report_abs(input
, ABS_PRESSURE
, pressure
);
180 input_report_key(input
, BTN_TOUCH
, data
[4] & 0x08);
181 input_report_key(input
, BTN_STYLUS
, data
[4] & 0x10);
182 /* Only allow the stylus2 button to be reported for the pen tool. */
183 input_report_key(input
, BTN_STYLUS2
, (wacom
->tool
[0] == BTN_TOOL_PEN
) && (data
[4] & 0x20));
188 input_report_key(input
, wacom
->tool
[0], prox
);
189 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]);
193 static int wacom_ptu_irq(struct wacom_wac
*wacom
)
195 unsigned char *data
= wacom
->data
;
196 struct input_dev
*input
= wacom
->pen_input
;
198 if (data
[0] != WACOM_REPORT_PENABLED
) {
199 dev_dbg(input
->dev
.parent
,
200 "%s: received unknown report #%d\n", __func__
, data
[0]);
204 if (data
[1] & 0x04) {
205 input_report_key(input
, BTN_TOOL_RUBBER
, data
[1] & 0x20);
206 input_report_key(input
, BTN_TOUCH
, data
[1] & 0x08);
207 wacom
->id
[0] = ERASER_DEVICE_ID
;
209 input_report_key(input
, BTN_TOOL_PEN
, data
[1] & 0x20);
210 input_report_key(input
, BTN_TOUCH
, data
[1] & 0x01);
211 wacom
->id
[0] = STYLUS_DEVICE_ID
;
213 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]); /* report tool id */
214 input_report_abs(input
, ABS_X
, le16_to_cpup((__le16
*)&data
[2]));
215 input_report_abs(input
, ABS_Y
, le16_to_cpup((__le16
*)&data
[4]));
216 input_report_abs(input
, ABS_PRESSURE
, le16_to_cpup((__le16
*)&data
[6]));
217 input_report_key(input
, BTN_STYLUS
, data
[1] & 0x02);
218 input_report_key(input
, BTN_STYLUS2
, data
[1] & 0x10);
222 static int wacom_dtu_irq(struct wacom_wac
*wacom
)
224 unsigned char *data
= wacom
->data
;
225 struct input_dev
*input
= wacom
->pen_input
;
226 int prox
= data
[1] & 0x20;
228 dev_dbg(input
->dev
.parent
,
229 "%s: received report #%d", __func__
, data
[0]);
232 /* Going into proximity select tool */
233 wacom
->tool
[0] = (data
[1] & 0x0c) ? BTN_TOOL_RUBBER
: BTN_TOOL_PEN
;
234 if (wacom
->tool
[0] == BTN_TOOL_PEN
)
235 wacom
->id
[0] = STYLUS_DEVICE_ID
;
237 wacom
->id
[0] = ERASER_DEVICE_ID
;
239 input_report_key(input
, BTN_STYLUS
, data
[1] & 0x02);
240 input_report_key(input
, BTN_STYLUS2
, data
[1] & 0x10);
241 input_report_abs(input
, ABS_X
, le16_to_cpup((__le16
*)&data
[2]));
242 input_report_abs(input
, ABS_Y
, le16_to_cpup((__le16
*)&data
[4]));
243 input_report_abs(input
, ABS_PRESSURE
, ((data
[7] & 0x01) << 8) | data
[6]);
244 input_report_key(input
, BTN_TOUCH
, data
[1] & 0x05);
245 if (!prox
) /* out-prox */
247 input_report_key(input
, wacom
->tool
[0], prox
);
248 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]);
252 static int wacom_dtus_irq(struct wacom_wac
*wacom
)
254 char *data
= wacom
->data
;
255 struct input_dev
*input
= wacom
->pen_input
;
256 unsigned short prox
, pressure
= 0;
258 if (data
[0] != WACOM_REPORT_DTUS
&& data
[0] != WACOM_REPORT_DTUSPAD
) {
259 dev_dbg(input
->dev
.parent
,
260 "%s: received unknown report #%d", __func__
, data
[0]);
262 } else if (data
[0] == WACOM_REPORT_DTUSPAD
) {
263 input
= wacom
->pad_input
;
264 input_report_key(input
, BTN_0
, (data
[1] & 0x01));
265 input_report_key(input
, BTN_1
, (data
[1] & 0x02));
266 input_report_key(input
, BTN_2
, (data
[1] & 0x04));
267 input_report_key(input
, BTN_3
, (data
[1] & 0x08));
268 input_report_abs(input
, ABS_MISC
,
269 data
[1] & 0x0f ? PAD_DEVICE_ID
: 0);
272 prox
= data
[1] & 0x80;
274 switch ((data
[1] >> 3) & 3) {
276 wacom
->tool
[0] = BTN_TOOL_RUBBER
;
277 wacom
->id
[0] = ERASER_DEVICE_ID
;
281 wacom
->tool
[0] = BTN_TOOL_PEN
;
282 wacom
->id
[0] = STYLUS_DEVICE_ID
;
287 input_report_key(input
, BTN_STYLUS
, data
[1] & 0x20);
288 input_report_key(input
, BTN_STYLUS2
, data
[1] & 0x40);
289 input_report_abs(input
, ABS_X
, get_unaligned_be16(&data
[3]));
290 input_report_abs(input
, ABS_Y
, get_unaligned_be16(&data
[5]));
291 pressure
= ((data
[1] & 0x03) << 8) | (data
[2] & 0xff);
292 input_report_abs(input
, ABS_PRESSURE
, pressure
);
293 input_report_key(input
, BTN_TOUCH
, pressure
> 10);
295 if (!prox
) /* out-prox */
297 input_report_key(input
, wacom
->tool
[0], prox
);
298 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]);
303 static int wacom_graphire_irq(struct wacom_wac
*wacom
)
305 struct wacom_features
*features
= &wacom
->features
;
306 unsigned char *data
= wacom
->data
;
307 struct input_dev
*input
= wacom
->pen_input
;
308 struct input_dev
*pad_input
= wacom
->pad_input
;
309 int battery_capacity
, ps_connected
;
314 if (features
->type
== GRAPHIRE_BT
) {
315 if (data
[0] != WACOM_REPORT_PENABLED_BT
) {
316 dev_dbg(input
->dev
.parent
,
317 "%s: received unknown report #%d\n", __func__
,
321 } else if (data
[0] != WACOM_REPORT_PENABLED
) {
322 dev_dbg(input
->dev
.parent
,
323 "%s: received unknown report #%d\n", __func__
, data
[0]);
327 prox
= data
[1] & 0x80;
328 if (prox
|| wacom
->id
[0]) {
330 switch ((data
[1] >> 5) & 3) {
333 wacom
->tool
[0] = BTN_TOOL_PEN
;
334 wacom
->id
[0] = STYLUS_DEVICE_ID
;
338 wacom
->tool
[0] = BTN_TOOL_RUBBER
;
339 wacom
->id
[0] = ERASER_DEVICE_ID
;
342 case 2: /* Mouse with wheel */
343 input_report_key(input
, BTN_MIDDLE
, data
[1] & 0x04);
346 case 3: /* Mouse without wheel */
347 wacom
->tool
[0] = BTN_TOOL_MOUSE
;
348 wacom
->id
[0] = CURSOR_DEVICE_ID
;
352 input_report_abs(input
, ABS_X
, le16_to_cpup((__le16
*)&data
[2]));
353 input_report_abs(input
, ABS_Y
, le16_to_cpup((__le16
*)&data
[4]));
354 if (wacom
->tool
[0] != BTN_TOOL_MOUSE
) {
355 if (features
->type
== GRAPHIRE_BT
)
356 input_report_abs(input
, ABS_PRESSURE
, data
[6] |
357 (((__u16
) (data
[1] & 0x08)) << 5));
359 input_report_abs(input
, ABS_PRESSURE
, data
[6] |
360 ((data
[7] & 0x03) << 8));
361 input_report_key(input
, BTN_TOUCH
, data
[1] & 0x01);
362 input_report_key(input
, BTN_STYLUS
, data
[1] & 0x02);
363 input_report_key(input
, BTN_STYLUS2
, data
[1] & 0x04);
365 input_report_key(input
, BTN_LEFT
, data
[1] & 0x01);
366 input_report_key(input
, BTN_RIGHT
, data
[1] & 0x02);
367 if (features
->type
== WACOM_G4
||
368 features
->type
== WACOM_MO
) {
369 input_report_abs(input
, ABS_DISTANCE
, data
[6] & 0x3f);
370 rw
= (data
[7] & 0x04) - (data
[7] & 0x03);
371 } else if (features
->type
== GRAPHIRE_BT
) {
372 /* Compute distance between mouse and tablet */
373 rw
= 44 - (data
[6] >> 2);
374 rw
= clamp_val(rw
, 0, 31);
375 input_report_abs(input
, ABS_DISTANCE
, rw
);
376 if (((data
[1] >> 5) & 3) == 2) {
377 /* Mouse with wheel */
378 input_report_key(input
, BTN_MIDDLE
,
380 rw
= (data
[6] & 0x01) ? -1 :
381 (data
[6] & 0x02) ? 1 : 0;
386 input_report_abs(input
, ABS_DISTANCE
, data
[7] & 0x3f);
387 rw
= -(signed char)data
[6];
389 input_report_rel(input
, REL_WHEEL
, rw
);
394 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]); /* report tool id */
395 input_report_key(input
, wacom
->tool
[0], prox
);
396 input_sync(input
); /* sync last event */
400 switch (features
->type
) {
402 prox
= data
[7] & 0xf8;
403 if (prox
|| wacom
->id
[1]) {
404 wacom
->id
[1] = PAD_DEVICE_ID
;
405 input_report_key(pad_input
, BTN_BACK
, (data
[7] & 0x40));
406 input_report_key(pad_input
, BTN_FORWARD
, (data
[7] & 0x80));
407 rw
= ((data
[7] & 0x18) >> 3) - ((data
[7] & 0x20) >> 3);
408 input_report_rel(pad_input
, REL_WHEEL
, rw
);
411 input_report_abs(pad_input
, ABS_MISC
, wacom
->id
[1]);
417 prox
= (data
[7] & 0xf8) || data
[8];
418 if (prox
|| wacom
->id
[1]) {
419 wacom
->id
[1] = PAD_DEVICE_ID
;
420 input_report_key(pad_input
, BTN_BACK
, (data
[7] & 0x08));
421 input_report_key(pad_input
, BTN_LEFT
, (data
[7] & 0x20));
422 input_report_key(pad_input
, BTN_FORWARD
, (data
[7] & 0x10));
423 input_report_key(pad_input
, BTN_RIGHT
, (data
[7] & 0x40));
424 input_report_abs(pad_input
, ABS_WHEEL
, (data
[8] & 0x7f));
427 input_report_abs(pad_input
, ABS_MISC
, wacom
->id
[1]);
432 prox
= data
[7] & 0x03;
433 if (prox
|| wacom
->id
[1]) {
434 wacom
->id
[1] = PAD_DEVICE_ID
;
435 input_report_key(pad_input
, BTN_0
, (data
[7] & 0x02));
436 input_report_key(pad_input
, BTN_1
, (data
[7] & 0x01));
439 input_report_abs(pad_input
, ABS_MISC
, wacom
->id
[1]);
445 /* Store current battery capacity and power supply state */
446 if (features
->type
== GRAPHIRE_BT
) {
447 rw
= (data
[7] >> 2 & 0x07);
448 battery_capacity
= batcap_gr
[rw
];
449 ps_connected
= rw
== 7;
450 wacom_notify_battery(wacom
, WACOM_POWER_SUPPLY_STATUS_AUTO
,
451 battery_capacity
, ps_connected
, 1,
458 static void wacom_intuos_schedule_prox_event(struct wacom_wac
*wacom_wac
)
460 struct wacom
*wacom
= container_of(wacom_wac
, struct wacom
, wacom_wac
);
461 struct wacom_features
*features
= &wacom_wac
->features
;
462 struct hid_report
*r
;
463 struct hid_report_enum
*re
;
465 re
= &(wacom
->hdev
->report_enum
[HID_FEATURE_REPORT
]);
466 if (features
->type
== INTUOSHT2
)
467 r
= re
->report_id_hash
[WACOM_REPORT_INTUOSHT2_ID
];
469 r
= re
->report_id_hash
[WACOM_REPORT_INTUOS_ID1
];
471 hid_hw_request(wacom
->hdev
, r
, HID_REQ_GET_REPORT
);
475 static int wacom_intuos_pad(struct wacom_wac
*wacom
)
477 struct wacom_features
*features
= &wacom
->features
;
478 unsigned char *data
= wacom
->data
;
479 struct input_dev
*input
= wacom
->pad_input
;
481 int buttons
= 0, nbuttons
= features
->numbered_buttons
;
482 int keys
= 0, nkeys
= 0;
483 int ring1
= 0, ring2
= 0;
484 int strip1
= 0, strip2
= 0;
487 /* pad packets. Works as a second tool and is always in prox */
488 if (!(data
[0] == WACOM_REPORT_INTUOSPAD
|| data
[0] == WACOM_REPORT_INTUOS5PAD
||
489 data
[0] == WACOM_REPORT_CINTIQPAD
))
492 if (features
->type
>= INTUOS4S
&& features
->type
<= INTUOS4L
) {
493 buttons
= (data
[3] << 1) | (data
[2] & 0x01);
495 } else if (features
->type
== DTK
) {
497 } else if (features
->type
== WACOM_13HD
) {
498 buttons
= (data
[4] << 1) | (data
[3] & 0x01);
499 } else if (features
->type
== WACOM_24HD
) {
500 buttons
= (data
[8] << 8) | data
[6];
505 * Three "buttons" are available on the 24HD which are
506 * physically implemented as a touchstrip. Each button
507 * is approximately 3 bits wide with a 2 bit spacing.
508 * The raw touchstrip bits are stored at:
509 * ((data[3] & 0x1f) << 8) | data[4])
512 keys
= ((data
[3] & 0x1C) ? 1<<2 : 0) |
513 ((data
[4] & 0xE0) ? 1<<1 : 0) |
514 ((data
[4] & 0x07) ? 1<<0 : 0);
515 } else if (features
->type
== WACOM_27QHD
) {
517 keys
= data
[2] & 0x07;
519 input_report_abs(input
, ABS_X
, be16_to_cpup((__be16
*)&data
[4]));
520 input_report_abs(input
, ABS_Y
, be16_to_cpup((__be16
*)&data
[6]));
521 input_report_abs(input
, ABS_Z
, be16_to_cpup((__be16
*)&data
[8]));
522 } else if (features
->type
== CINTIQ_HYBRID
) {
524 * Do not send hardware buttons under Android. They
525 * are already sent to the system through GPIO (and
526 * have different meaning).
528 * d-pad right -> data[4] & 0x10
529 * d-pad up -> data[4] & 0x20
530 * d-pad left -> data[4] & 0x40
531 * d-pad down -> data[4] & 0x80
532 * d-pad center -> data[3] & 0x01
534 buttons
= (data
[4] << 1) | (data
[3] & 0x01);
535 } else if (features
->type
== CINTIQ_COMPANION_2
) {
536 /* d-pad right -> data[2] & 0x10
537 * d-pad up -> data[2] & 0x20
538 * d-pad left -> data[2] & 0x40
539 * d-pad down -> data[2] & 0x80
540 * d-pad center -> data[1] & 0x01
542 buttons
= ((data
[2] >> 4) << 7) |
543 ((data
[1] & 0x04) << 4) |
544 ((data
[2] & 0x0F) << 2) |
546 } else if (features
->type
>= INTUOS5S
&& features
->type
<= INTUOSPL
) {
548 * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in
549 * addition to the mechanical switch. Switch data is
550 * stored in data[4], capacitive data in data[5].
552 * Touch ring mode switch (data[3]) has no capacitive sensor
554 buttons
= (data
[4] << 1) | (data
[3] & 0x01);
557 if (features
->type
== WACOM_21UX2
|| features
->type
== WACOM_22HD
) {
558 buttons
= (data
[8] << 10) | ((data
[7] & 0x01) << 9) |
559 (data
[6] << 1) | (data
[5] & 0x01);
561 if (features
->type
== WACOM_22HD
) {
563 keys
= data
[9] & 0x07;
566 buttons
= ((data
[6] & 0x10) << 5) |
567 ((data
[5] & 0x10) << 4) |
568 ((data
[6] & 0x0F) << 4) |
571 strip1
= ((data
[1] & 0x1f) << 8) | data
[2];
572 strip2
= ((data
[3] & 0x1f) << 8) | data
[4];
575 prox
= (buttons
& ~(~0 << nbuttons
)) | (keys
& ~(~0 << nkeys
)) |
576 (ring1
& 0x80) | (ring2
& 0x80) | strip1
| strip2
;
578 wacom_report_numbered_buttons(input
, nbuttons
, buttons
);
580 for (i
= 0; i
< nkeys
; i
++)
581 input_report_key(input
, KEY_PROG1
+ i
, keys
& (1 << i
));
583 input_report_abs(input
, ABS_RX
, strip1
);
584 input_report_abs(input
, ABS_RY
, strip2
);
586 input_report_abs(input
, ABS_WHEEL
, (ring1
& 0x80) ? (ring1
& 0x7f) : 0);
587 input_report_abs(input
, ABS_THROTTLE
, (ring2
& 0x80) ? (ring2
& 0x7f) : 0);
589 input_report_key(input
, wacom
->tool
[1], prox
? 1 : 0);
590 input_report_abs(input
, ABS_MISC
, prox
? PAD_DEVICE_ID
: 0);
592 input_event(input
, EV_MSC
, MSC_SERIAL
, 0xffffffff);
597 static int wacom_intuos_id_mangle(int tool_id
)
599 return (tool_id
& ~0xFFF) << 4 | (tool_id
& 0xFFF);
602 static int wacom_intuos_get_tool_type(int tool_id
)
607 case 0x812: /* Inking pen */
608 case 0x801: /* Intuos3 Inking pen */
609 case 0x12802: /* Intuos4/5 Inking Pen */
611 tool_type
= BTN_TOOL_PENCIL
;
614 case 0x822: /* Pen */
617 case 0x823: /* Intuos3 Grip Pen */
618 case 0x813: /* Intuos3 Classic Pen */
619 case 0x885: /* Intuos3 Marker Pen */
620 case 0x802: /* Intuos4/5 13HD/24HD General Pen */
621 case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
622 case 0x8e2: /* IntuosHT2 pen */
624 case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */
625 case 0x10842: /* MobileStudio Pro Pro Pen slim */
626 case 0x14802: /* Intuos4/5 13HD/24HD Classic Pen */
627 case 0x16802: /* Cintiq 13HD Pro Pen */
628 case 0x18802: /* DTH2242 Pen */
629 case 0x10802: /* Intuos4/5 13HD/24HD General Pen */
630 tool_type
= BTN_TOOL_PEN
;
633 case 0x832: /* Stroke pen */
635 tool_type
= BTN_TOOL_BRUSH
;
638 case 0x007: /* Mouse 4D and 2D */
641 case 0x017: /* Intuos3 2D Mouse */
642 case 0x806: /* Intuos4 Mouse */
643 tool_type
= BTN_TOOL_MOUSE
;
646 case 0x096: /* Lens cursor */
647 case 0x097: /* Intuos3 Lens cursor */
648 case 0x006: /* Intuos4 Lens cursor */
649 tool_type
= BTN_TOOL_LENS
;
652 case 0x82a: /* Eraser */
658 case 0x82b: /* Intuos3 Grip Pen Eraser */
659 case 0x81b: /* Intuos3 Classic Pen Eraser */
660 case 0x91b: /* Intuos3 Airbrush Eraser */
661 case 0x80c: /* Intuos4/5 13HD/24HD Marker Pen Eraser */
662 case 0x80a: /* Intuos4/5 13HD/24HD General Pen Eraser */
663 case 0x90a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
664 case 0x1480a: /* Intuos4/5 13HD/24HD Classic Pen Eraser */
665 case 0x1090a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
666 case 0x1080c: /* Intuos4/5 13HD/24HD Art Pen Eraser */
667 case 0x1084a: /* MobileStudio Pro Pro Pen slim Eraser */
668 case 0x1680a: /* Cintiq 13HD Pro Pen Eraser */
669 case 0x1880a: /* DTH2242 Eraser */
670 case 0x1080a: /* Intuos4/5 13HD/24HD General Pen Eraser */
671 tool_type
= BTN_TOOL_RUBBER
;
677 case 0x913: /* Intuos3 Airbrush */
678 case 0x902: /* Intuos4/5 13HD/24HD Airbrush */
679 case 0x10902: /* Intuos4/5 13HD/24HD Airbrush */
680 tool_type
= BTN_TOOL_AIRBRUSH
;
683 default: /* Unknown tool */
684 tool_type
= BTN_TOOL_PEN
;
690 static void wacom_exit_report(struct wacom_wac
*wacom
)
692 struct input_dev
*input
= wacom
->pen_input
;
693 struct wacom_features
*features
= &wacom
->features
;
694 unsigned char *data
= wacom
->data
;
695 int idx
= (features
->type
== INTUOS
) ? (data
[1] & 0x01) : 0;
698 * Reset all states otherwise we lose the initial states
699 * when in-prox next time
701 input_report_abs(input
, ABS_X
, 0);
702 input_report_abs(input
, ABS_Y
, 0);
703 input_report_abs(input
, ABS_DISTANCE
, 0);
704 input_report_abs(input
, ABS_TILT_X
, 0);
705 input_report_abs(input
, ABS_TILT_Y
, 0);
706 if (wacom
->tool
[idx
] >= BTN_TOOL_MOUSE
) {
707 input_report_key(input
, BTN_LEFT
, 0);
708 input_report_key(input
, BTN_MIDDLE
, 0);
709 input_report_key(input
, BTN_RIGHT
, 0);
710 input_report_key(input
, BTN_SIDE
, 0);
711 input_report_key(input
, BTN_EXTRA
, 0);
712 input_report_abs(input
, ABS_THROTTLE
, 0);
713 input_report_abs(input
, ABS_RZ
, 0);
715 input_report_abs(input
, ABS_PRESSURE
, 0);
716 input_report_key(input
, BTN_STYLUS
, 0);
717 input_report_key(input
, BTN_STYLUS2
, 0);
718 input_report_key(input
, BTN_TOUCH
, 0);
719 input_report_abs(input
, ABS_WHEEL
, 0);
720 if (features
->type
>= INTUOS3S
)
721 input_report_abs(input
, ABS_Z
, 0);
723 input_report_key(input
, wacom
->tool
[idx
], 0);
724 input_report_abs(input
, ABS_MISC
, 0); /* reset tool id */
725 input_event(input
, EV_MSC
, MSC_SERIAL
, wacom
->serial
[idx
]);
729 static int wacom_intuos_inout(struct wacom_wac
*wacom
)
731 struct wacom_features
*features
= &wacom
->features
;
732 unsigned char *data
= wacom
->data
;
733 struct input_dev
*input
= wacom
->pen_input
;
734 int idx
= (features
->type
== INTUOS
) ? (data
[1] & 0x01) : 0;
736 if (!(((data
[1] & 0xfc) == 0xc0) || /* in prox */
737 ((data
[1] & 0xfe) == 0x20) || /* in range */
738 ((data
[1] & 0xfe) == 0x80))) /* out prox */
742 if ((data
[1] & 0xfc) == 0xc0) {
743 /* serial number of the tool */
744 wacom
->serial
[idx
] = ((data
[3] & 0x0f) << 28) +
745 (data
[4] << 20) + (data
[5] << 12) +
746 (data
[6] << 4) + (data
[7] >> 4);
748 wacom
->id
[idx
] = (data
[2] << 4) | (data
[3] >> 4) |
749 ((data
[7] & 0x0f) << 16) | ((data
[8] & 0xf0) << 8);
751 wacom
->tool
[idx
] = wacom_intuos_get_tool_type(wacom
->id
[idx
]);
753 wacom
->shared
->stylus_in_proximity
= true;
758 if ((data
[1] & 0xfe) == 0x20) {
759 if (features
->type
!= INTUOSHT2
)
760 wacom
->shared
->stylus_in_proximity
= true;
762 /* in Range while exiting */
763 if (wacom
->reporting_data
) {
764 input_report_key(input
, BTN_TOUCH
, 0);
765 input_report_abs(input
, ABS_PRESSURE
, 0);
766 input_report_abs(input
, ABS_DISTANCE
, wacom
->features
.distance_max
);
773 if ((data
[1] & 0xfe) == 0x80) {
774 wacom
->shared
->stylus_in_proximity
= false;
775 wacom
->reporting_data
= false;
777 /* don't report exit if we don't know the ID */
781 wacom_exit_report(wacom
);
788 static inline bool report_touch_events(struct wacom_wac
*wacom
)
790 return (touch_arbitration
? !wacom
->shared
->stylus_in_proximity
: 1);
793 static inline bool delay_pen_events(struct wacom_wac
*wacom
)
795 return (wacom
->shared
->touch_down
&& touch_arbitration
);
798 static int wacom_intuos_general(struct wacom_wac
*wacom
)
800 struct wacom_features
*features
= &wacom
->features
;
801 unsigned char *data
= wacom
->data
;
802 struct input_dev
*input
= wacom
->pen_input
;
803 int idx
= (features
->type
== INTUOS
) ? (data
[1] & 0x01) : 0;
804 unsigned char type
= (data
[1] >> 1) & 0x0F;
805 unsigned int x
, y
, distance
, t
;
807 if (data
[0] != WACOM_REPORT_PENABLED
&& data
[0] != WACOM_REPORT_CINTIQ
&&
808 data
[0] != WACOM_REPORT_INTUOS_PEN
)
811 if (delay_pen_events(wacom
))
814 /* don't report events if we don't know the tool ID */
815 if (!wacom
->id
[idx
]) {
816 /* but reschedule a read of the current tool */
817 wacom_intuos_schedule_prox_event(wacom
);
822 * don't report events for invalid data
824 /* older I4 styli don't work with new Cintiqs */
825 if ((!((wacom
->id
[idx
] >> 16) & 0x01) &&
826 (features
->type
== WACOM_21UX2
)) ||
827 /* Only large Intuos support Lense Cursor */
828 (wacom
->tool
[idx
] == BTN_TOOL_LENS
&&
829 (features
->type
== INTUOS3
||
830 features
->type
== INTUOS3S
||
831 features
->type
== INTUOS4
||
832 features
->type
== INTUOS4S
||
833 features
->type
== INTUOS5
||
834 features
->type
== INTUOS5S
||
835 features
->type
== INTUOSPM
||
836 features
->type
== INTUOSPS
)) ||
837 /* Cintiq doesn't send data when RDY bit isn't set */
838 (features
->type
== CINTIQ
&& !(data
[1] & 0x40)))
841 x
= (be16_to_cpup((__be16
*)&data
[2]) << 1) | ((data
[9] >> 1) & 1);
842 y
= (be16_to_cpup((__be16
*)&data
[4]) << 1) | (data
[9] & 1);
843 distance
= data
[9] >> 2;
844 if (features
->type
< INTUOS3S
) {
849 if (features
->type
== INTUOSHT2
)
850 distance
= features
->distance_max
- distance
;
851 input_report_abs(input
, ABS_X
, x
);
852 input_report_abs(input
, ABS_Y
, y
);
853 input_report_abs(input
, ABS_DISTANCE
, distance
);
860 /* general pen packet */
861 t
= (data
[6] << 3) | ((data
[7] & 0xC0) >> 5) | (data
[1] & 1);
862 if (features
->pressure_max
< 2047)
864 input_report_abs(input
, ABS_PRESSURE
, t
);
865 if (features
->type
!= INTUOSHT2
) {
866 input_report_abs(input
, ABS_TILT_X
,
867 (((data
[7] << 1) & 0x7e) | (data
[8] >> 7)) - 64);
868 input_report_abs(input
, ABS_TILT_Y
, (data
[8] & 0x7f) - 64);
870 input_report_key(input
, BTN_STYLUS
, data
[1] & 2);
871 input_report_key(input
, BTN_STYLUS2
, data
[1] & 4);
872 input_report_key(input
, BTN_TOUCH
, t
> 10);
876 /* airbrush second packet */
877 input_report_abs(input
, ABS_WHEEL
,
878 (data
[6] << 2) | ((data
[7] >> 6) & 3));
879 input_report_abs(input
, ABS_TILT_X
,
880 (((data
[7] << 1) & 0x7e) | (data
[8] >> 7)) - 64);
881 input_report_abs(input
, ABS_TILT_Y
, (data
[8] & 0x7f) - 64);
885 /* Rotation packet */
886 if (features
->type
>= INTUOS3S
) {
887 /* I3 marker pen rotation */
888 t
= (data
[6] << 3) | ((data
[7] >> 5) & 7);
889 t
= (data
[7] & 0x20) ? ((t
> 900) ? ((t
-1) / 2 - 1350) :
890 ((t
-1) / 2 + 450)) : (450 - t
/ 2) ;
891 input_report_abs(input
, ABS_Z
, t
);
893 /* 4D mouse 2nd packet */
894 t
= (data
[6] << 3) | ((data
[7] >> 5) & 7);
895 input_report_abs(input
, ABS_RZ
, (data
[7] & 0x20) ?
896 ((t
- 1) / 2) : -t
/ 2);
901 /* 4D mouse 1st packet */
902 input_report_key(input
, BTN_LEFT
, data
[8] & 0x01);
903 input_report_key(input
, BTN_MIDDLE
, data
[8] & 0x02);
904 input_report_key(input
, BTN_RIGHT
, data
[8] & 0x04);
906 input_report_key(input
, BTN_SIDE
, data
[8] & 0x20);
907 input_report_key(input
, BTN_EXTRA
, data
[8] & 0x10);
908 t
= (data
[6] << 2) | ((data
[7] >> 6) & 3);
909 input_report_abs(input
, ABS_THROTTLE
, (data
[8] & 0x08) ? -t
: t
);
914 input_report_key(input
, BTN_LEFT
, data
[6] & 0x01);
915 input_report_key(input
, BTN_MIDDLE
, data
[6] & 0x02);
916 input_report_key(input
, BTN_RIGHT
, data
[6] & 0x04);
917 input_report_rel(input
, REL_WHEEL
, ((data
[7] & 0x80) >> 7)
918 - ((data
[7] & 0x40) >> 6));
919 input_report_key(input
, BTN_SIDE
, data
[6] & 0x08);
920 input_report_key(input
, BTN_EXTRA
, data
[6] & 0x10);
922 input_report_abs(input
, ABS_TILT_X
,
923 (((data
[7] << 1) & 0x7e) | (data
[8] >> 7)) - 64);
924 input_report_abs(input
, ABS_TILT_Y
, (data
[8] & 0x7f) - 64);
928 if (wacom
->tool
[idx
] == BTN_TOOL_MOUSE
) {
929 /* 2D mouse packet */
930 input_report_key(input
, BTN_LEFT
, data
[8] & 0x04);
931 input_report_key(input
, BTN_MIDDLE
, data
[8] & 0x08);
932 input_report_key(input
, BTN_RIGHT
, data
[8] & 0x10);
933 input_report_rel(input
, REL_WHEEL
, (data
[8] & 0x01)
934 - ((data
[8] & 0x02) >> 1));
936 /* I3 2D mouse side buttons */
937 if (features
->type
>= INTUOS3S
&& features
->type
<= INTUOS3L
) {
938 input_report_key(input
, BTN_SIDE
, data
[8] & 0x40);
939 input_report_key(input
, BTN_EXTRA
, data
[8] & 0x20);
942 else if (wacom
->tool
[idx
] == BTN_TOOL_LENS
) {
943 /* Lens cursor packets */
944 input_report_key(input
, BTN_LEFT
, data
[8] & 0x01);
945 input_report_key(input
, BTN_MIDDLE
, data
[8] & 0x02);
946 input_report_key(input
, BTN_RIGHT
, data
[8] & 0x04);
947 input_report_key(input
, BTN_SIDE
, data
[8] & 0x10);
948 input_report_key(input
, BTN_EXTRA
, data
[8] & 0x08);
963 input_report_abs(input
, ABS_MISC
,
964 wacom_intuos_id_mangle(wacom
->id
[idx
])); /* report tool id */
965 input_report_key(input
, wacom
->tool
[idx
], 1);
966 input_event(input
, EV_MSC
, MSC_SERIAL
, wacom
->serial
[idx
]);
967 wacom
->reporting_data
= true;
971 static int wacom_intuos_irq(struct wacom_wac
*wacom
)
973 unsigned char *data
= wacom
->data
;
974 struct input_dev
*input
= wacom
->pen_input
;
977 if (data
[0] != WACOM_REPORT_PENABLED
&&
978 data
[0] != WACOM_REPORT_INTUOS_ID1
&&
979 data
[0] != WACOM_REPORT_INTUOS_ID2
&&
980 data
[0] != WACOM_REPORT_INTUOSPAD
&&
981 data
[0] != WACOM_REPORT_INTUOS_PEN
&&
982 data
[0] != WACOM_REPORT_CINTIQ
&&
983 data
[0] != WACOM_REPORT_CINTIQPAD
&&
984 data
[0] != WACOM_REPORT_INTUOS5PAD
) {
985 dev_dbg(input
->dev
.parent
,
986 "%s: received unknown report #%d\n", __func__
, data
[0]);
990 /* process pad events */
991 result
= wacom_intuos_pad(wacom
);
995 /* process in/out prox events */
996 result
= wacom_intuos_inout(wacom
);
1000 /* process general packets */
1001 result
= wacom_intuos_general(wacom
);
1008 static int wacom_remote_irq(struct wacom_wac
*wacom_wac
, size_t len
)
1010 unsigned char *data
= wacom_wac
->data
;
1011 struct input_dev
*input
;
1012 struct wacom
*wacom
= container_of(wacom_wac
, struct wacom
, wacom_wac
);
1013 struct wacom_remote
*remote
= wacom
->remote
;
1014 int bat_charging
, bat_percent
, touch_ring_mode
;
1017 unsigned long flags
;
1019 if (data
[0] != WACOM_REPORT_REMOTE
) {
1020 hid_dbg(wacom
->hdev
, "%s: received unknown report #%d",
1025 serial
= data
[3] + (data
[4] << 8) + (data
[5] << 16);
1026 wacom_wac
->id
[0] = PAD_DEVICE_ID
;
1028 spin_lock_irqsave(&remote
->remote_lock
, flags
);
1030 for (i
= 0; i
< WACOM_MAX_REMOTES
; i
++) {
1031 if (remote
->remotes
[i
].serial
== serial
) {
1037 if (index
< 0 || !remote
->remotes
[index
].registered
)
1040 input
= remote
->remotes
[index
].input
;
1042 input_report_key(input
, BTN_0
, (data
[9] & 0x01));
1043 input_report_key(input
, BTN_1
, (data
[9] & 0x02));
1044 input_report_key(input
, BTN_2
, (data
[9] & 0x04));
1045 input_report_key(input
, BTN_3
, (data
[9] & 0x08));
1046 input_report_key(input
, BTN_4
, (data
[9] & 0x10));
1047 input_report_key(input
, BTN_5
, (data
[9] & 0x20));
1048 input_report_key(input
, BTN_6
, (data
[9] & 0x40));
1049 input_report_key(input
, BTN_7
, (data
[9] & 0x80));
1051 input_report_key(input
, BTN_8
, (data
[10] & 0x01));
1052 input_report_key(input
, BTN_9
, (data
[10] & 0x02));
1053 input_report_key(input
, BTN_A
, (data
[10] & 0x04));
1054 input_report_key(input
, BTN_B
, (data
[10] & 0x08));
1055 input_report_key(input
, BTN_C
, (data
[10] & 0x10));
1056 input_report_key(input
, BTN_X
, (data
[10] & 0x20));
1057 input_report_key(input
, BTN_Y
, (data
[10] & 0x40));
1058 input_report_key(input
, BTN_Z
, (data
[10] & 0x80));
1060 input_report_key(input
, BTN_BASE
, (data
[11] & 0x01));
1061 input_report_key(input
, BTN_BASE2
, (data
[11] & 0x02));
1063 if (data
[12] & 0x80)
1064 input_report_abs(input
, ABS_WHEEL
, (data
[12] & 0x7f));
1066 input_report_abs(input
, ABS_WHEEL
, 0);
1068 bat_percent
= data
[7] & 0x7f;
1069 bat_charging
= !!(data
[7] & 0x80);
1071 if (data
[9] | data
[10] | (data
[11] & 0x03) | data
[12])
1072 input_report_abs(input
, ABS_MISC
, PAD_DEVICE_ID
);
1074 input_report_abs(input
, ABS_MISC
, 0);
1076 input_event(input
, EV_MSC
, MSC_SERIAL
, serial
);
1080 /*Which mode select (LED light) is currently on?*/
1081 touch_ring_mode
= (data
[11] & 0xC0) >> 6;
1083 for (i
= 0; i
< WACOM_MAX_REMOTES
; i
++) {
1084 if (remote
->remotes
[i
].serial
== serial
)
1085 wacom
->led
.groups
[i
].select
= touch_ring_mode
;
1088 __wacom_notify_battery(&remote
->remotes
[index
].battery
,
1089 WACOM_POWER_SUPPLY_STATUS_AUTO
, bat_percent
,
1090 bat_charging
, 1, bat_charging
);
1093 spin_unlock_irqrestore(&remote
->remote_lock
, flags
);
1097 static void wacom_remote_status_irq(struct wacom_wac
*wacom_wac
, size_t len
)
1099 struct wacom
*wacom
= container_of(wacom_wac
, struct wacom
, wacom_wac
);
1100 unsigned char *data
= wacom_wac
->data
;
1101 struct wacom_remote
*remote
= wacom
->remote
;
1102 struct wacom_remote_data remote_data
;
1103 unsigned long flags
;
1106 if (data
[0] != WACOM_REPORT_DEVICE_LIST
)
1109 memset(&remote_data
, 0, sizeof(struct wacom_remote_data
));
1111 for (i
= 0; i
< WACOM_MAX_REMOTES
; i
++) {
1113 int serial
= (data
[j
+6] << 16) + (data
[j
+5] << 8) + data
[j
+4];
1114 bool connected
= data
[j
+2];
1116 remote_data
.remote
[i
].serial
= serial
;
1117 remote_data
.remote
[i
].connected
= connected
;
1120 spin_lock_irqsave(&remote
->remote_lock
, flags
);
1122 ret
= kfifo_in(&remote
->remote_fifo
, &remote_data
, sizeof(remote_data
));
1123 if (ret
!= sizeof(remote_data
)) {
1124 spin_unlock_irqrestore(&remote
->remote_lock
, flags
);
1125 hid_err(wacom
->hdev
, "Can't queue Remote status event.\n");
1129 spin_unlock_irqrestore(&remote
->remote_lock
, flags
);
1131 wacom_schedule_work(wacom_wac
, WACOM_WORKER_REMOTE
);
1134 static int int_dist(int x1
, int y1
, int x2
, int y2
)
1139 return int_sqrt(x
*x
+ y
*y
);
1142 static void wacom_intuos_bt_process_data(struct wacom_wac
*wacom
,
1143 unsigned char *data
)
1145 memcpy(wacom
->data
, data
, 10);
1146 wacom_intuos_irq(wacom
);
1148 input_sync(wacom
->pen_input
);
1149 if (wacom
->pad_input
)
1150 input_sync(wacom
->pad_input
);
1153 static int wacom_intuos_bt_irq(struct wacom_wac
*wacom
, size_t len
)
1155 unsigned char data
[WACOM_PKGLEN_MAX
];
1157 unsigned power_raw
, battery_capacity
, bat_charging
, ps_connected
;
1159 memcpy(data
, wacom
->data
, len
);
1163 wacom_intuos_bt_process_data(wacom
, data
+ i
);
1167 wacom_intuos_bt_process_data(wacom
, data
+ i
);
1169 wacom_intuos_bt_process_data(wacom
, data
+ i
);
1171 power_raw
= data
[i
];
1172 bat_charging
= (power_raw
& 0x08) ? 1 : 0;
1173 ps_connected
= (power_raw
& 0x10) ? 1 : 0;
1174 battery_capacity
= batcap_i4
[power_raw
& 0x07];
1175 wacom_notify_battery(wacom
, WACOM_POWER_SUPPLY_STATUS_AUTO
,
1176 battery_capacity
, bat_charging
,
1177 battery_capacity
|| bat_charging
,
1181 dev_dbg(wacom
->pen_input
->dev
.parent
,
1182 "Unknown report: %d,%d size:%zu\n",
1183 data
[0], data
[1], len
);
1189 static int wacom_wac_finger_count_touches(struct wacom_wac
*wacom
)
1191 struct input_dev
*input
= wacom
->touch_input
;
1192 unsigned touch_max
= wacom
->features
.touch_max
;
1200 return test_bit(BTN_TOUCH
, input
->key
) &&
1201 report_touch_events(wacom
);
1203 for (i
= 0; i
< input
->mt
->num_slots
; i
++) {
1204 struct input_mt_slot
*ps
= &input
->mt
->slots
[i
];
1205 int id
= input_mt_get_value(ps
, ABS_MT_TRACKING_ID
);
1213 static void wacom_intuos_pro2_bt_pen(struct wacom_wac
*wacom
)
1215 int pen_frame_len
, pen_frames
;
1217 struct input_dev
*pen_input
= wacom
->pen_input
;
1218 unsigned char *data
= wacom
->data
;
1221 if (wacom
->features
.type
== INTUOSP2_BT
||
1222 wacom
->features
.type
== INTUOSP2S_BT
) {
1223 wacom
->serial
[0] = get_unaligned_le64(&data
[99]);
1224 wacom
->id
[0] = get_unaligned_le16(&data
[107]);
1228 wacom
->serial
[0] = get_unaligned_le64(&data
[33]);
1229 wacom
->id
[0] = get_unaligned_le16(&data
[41]);
1234 if (wacom
->serial
[0] >> 52 == 1) {
1235 /* Add back in missing bits of ID for non-USI pens */
1236 wacom
->id
[0] |= (wacom
->serial
[0] >> 32) & 0xFFFFF;
1239 for (i
= 0; i
< pen_frames
; i
++) {
1240 unsigned char *frame
= &data
[i
*pen_frame_len
+ 1];
1241 bool valid
= frame
[0] & 0x80;
1242 bool prox
= frame
[0] & 0x40;
1243 bool range
= frame
[0] & 0x20;
1244 bool invert
= frame
[0] & 0x10;
1250 wacom
->shared
->stylus_in_proximity
= false;
1251 wacom_exit_report(wacom
);
1252 input_sync(pen_input
);
1256 wacom
->serial
[0] = 0;
1261 if (!wacom
->tool
[0]) { /* first in range */
1262 /* Going into range select tool */
1264 wacom
->tool
[0] = BTN_TOOL_RUBBER
;
1265 else if (wacom
->id
[0])
1266 wacom
->tool
[0] = wacom_intuos_get_tool_type(wacom
->id
[0]);
1268 wacom
->tool
[0] = BTN_TOOL_PEN
;
1271 input_report_abs(pen_input
, ABS_X
, get_unaligned_le16(&frame
[1]));
1272 input_report_abs(pen_input
, ABS_Y
, get_unaligned_le16(&frame
[3]));
1274 if (wacom
->features
.type
== INTUOSP2_BT
||
1275 wacom
->features
.type
== INTUOSP2S_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]));
1293 if (wacom
->tool
[0]) {
1294 input_report_abs(pen_input
, ABS_PRESSURE
, get_unaligned_le16(&frame
[5]));
1295 if (wacom
->features
.type
== INTUOSP2_BT
||
1296 wacom
->features
.type
== INTUOSP2S_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
->features
.type
== INTUOSP2S_BT
) {
1465 wacom_intuos_pro2_bt_touch(wacom
);
1466 wacom_intuos_pro2_bt_pad(wacom
);
1467 wacom_intuos_pro2_bt_battery(wacom
);
1469 wacom_intuos_gen3_bt_pad(wacom
);
1470 wacom_intuos_gen3_bt_battery(wacom
);
1475 static int wacom_24hdt_irq(struct wacom_wac
*wacom
)
1477 struct input_dev
*input
= wacom
->touch_input
;
1478 unsigned char *data
= wacom
->data
;
1480 int current_num_contacts
= data
[61];
1481 int contacts_to_send
= 0;
1482 int num_contacts_left
= 4; /* maximum contacts per packet */
1483 int byte_per_packet
= WACOM_BYTES_PER_24HDT_PACKET
;
1486 if (wacom
->features
.type
== WACOM_27QHDT
) {
1487 current_num_contacts
= data
[63];
1488 num_contacts_left
= 10;
1489 byte_per_packet
= WACOM_BYTES_PER_QHDTHID_PACKET
;
1494 * First packet resets the counter since only the first
1495 * packet in series will have non-zero current_num_contacts.
1497 if (current_num_contacts
)
1498 wacom
->num_contacts_left
= current_num_contacts
;
1500 contacts_to_send
= min(num_contacts_left
, wacom
->num_contacts_left
);
1502 for (i
= 0; i
< contacts_to_send
; i
++) {
1503 int offset
= (byte_per_packet
* i
) + 1;
1504 bool touch
= (data
[offset
] & 0x1) && report_touch_events(wacom
);
1505 int slot
= input_mt_get_slot_by_key(input
, data
[offset
+ 1]);
1509 input_mt_slot(input
, slot
);
1510 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, touch
);
1513 int t_x
= get_unaligned_le16(&data
[offset
+ 2]);
1514 int t_y
= get_unaligned_le16(&data
[offset
+ 4 + y_offset
]);
1516 input_report_abs(input
, ABS_MT_POSITION_X
, t_x
);
1517 input_report_abs(input
, ABS_MT_POSITION_Y
, t_y
);
1519 if (wacom
->features
.type
!= WACOM_27QHDT
) {
1520 int c_x
= get_unaligned_le16(&data
[offset
+ 4]);
1521 int c_y
= get_unaligned_le16(&data
[offset
+ 8]);
1522 int w
= get_unaligned_le16(&data
[offset
+ 10]);
1523 int h
= get_unaligned_le16(&data
[offset
+ 12]);
1525 input_report_abs(input
, ABS_MT_TOUCH_MAJOR
, min(w
,h
));
1526 input_report_abs(input
, ABS_MT_WIDTH_MAJOR
,
1527 min(w
, h
) + int_dist(t_x
, t_y
, c_x
, c_y
));
1528 input_report_abs(input
, ABS_MT_WIDTH_MINOR
, min(w
, h
));
1529 input_report_abs(input
, ABS_MT_ORIENTATION
, w
> h
);
1533 input_mt_sync_frame(input
);
1535 wacom
->num_contacts_left
-= contacts_to_send
;
1536 if (wacom
->num_contacts_left
<= 0) {
1537 wacom
->num_contacts_left
= 0;
1538 wacom
->shared
->touch_down
= wacom_wac_finger_count_touches(wacom
);
1543 static int wacom_mt_touch(struct wacom_wac
*wacom
)
1545 struct input_dev
*input
= wacom
->touch_input
;
1546 unsigned char *data
= wacom
->data
;
1548 int current_num_contacts
= data
[2];
1549 int contacts_to_send
= 0;
1552 /* MTTPC does not support Height and Width */
1553 if (wacom
->features
.type
== MTTPC
|| wacom
->features
.type
== MTTPC_B
)
1557 * First packet resets the counter since only the first
1558 * packet in series will have non-zero current_num_contacts.
1560 if (current_num_contacts
)
1561 wacom
->num_contacts_left
= current_num_contacts
;
1563 /* There are at most 5 contacts per packet */
1564 contacts_to_send
= min(5, wacom
->num_contacts_left
);
1566 for (i
= 0; i
< contacts_to_send
; i
++) {
1567 int offset
= (WACOM_BYTES_PER_MT_PACKET
+ x_offset
) * i
+ 3;
1568 bool touch
= (data
[offset
] & 0x1) && report_touch_events(wacom
);
1569 int id
= get_unaligned_le16(&data
[offset
+ 1]);
1570 int slot
= input_mt_get_slot_by_key(input
, id
);
1575 input_mt_slot(input
, slot
);
1576 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, touch
);
1578 int x
= get_unaligned_le16(&data
[offset
+ x_offset
+ 7]);
1579 int y
= get_unaligned_le16(&data
[offset
+ x_offset
+ 9]);
1580 input_report_abs(input
, ABS_MT_POSITION_X
, x
);
1581 input_report_abs(input
, ABS_MT_POSITION_Y
, y
);
1584 input_mt_sync_frame(input
);
1586 wacom
->num_contacts_left
-= contacts_to_send
;
1587 if (wacom
->num_contacts_left
<= 0) {
1588 wacom
->num_contacts_left
= 0;
1589 wacom
->shared
->touch_down
= wacom_wac_finger_count_touches(wacom
);
1594 static int wacom_tpc_mt_touch(struct wacom_wac
*wacom
)
1596 struct input_dev
*input
= wacom
->touch_input
;
1597 unsigned char *data
= wacom
->data
;
1600 for (i
= 0; i
< 2; i
++) {
1601 int p
= data
[1] & (1 << i
);
1602 bool touch
= p
&& report_touch_events(wacom
);
1604 input_mt_slot(input
, i
);
1605 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, touch
);
1607 int x
= le16_to_cpup((__le16
*)&data
[i
* 2 + 2]) & 0x7fff;
1608 int y
= le16_to_cpup((__le16
*)&data
[i
* 2 + 6]) & 0x7fff;
1610 input_report_abs(input
, ABS_MT_POSITION_X
, x
);
1611 input_report_abs(input
, ABS_MT_POSITION_Y
, y
);
1614 input_mt_sync_frame(input
);
1616 /* keep touch state for pen event */
1617 wacom
->shared
->touch_down
= wacom_wac_finger_count_touches(wacom
);
1622 static int wacom_tpc_single_touch(struct wacom_wac
*wacom
, size_t len
)
1624 unsigned char *data
= wacom
->data
;
1625 struct input_dev
*input
= wacom
->touch_input
;
1626 bool prox
= report_touch_events(wacom
);
1629 if (wacom
->features
.touch_max
> 1 || len
> WACOM_PKGLEN_TPC2FG
)
1632 if (len
== WACOM_PKGLEN_TPC1FG
) {
1633 prox
= prox
&& (data
[0] & 0x01);
1634 x
= get_unaligned_le16(&data
[1]);
1635 y
= get_unaligned_le16(&data
[3]);
1636 } else if (len
== WACOM_PKGLEN_TPC1FG_B
) {
1637 prox
= prox
&& (data
[2] & 0x01);
1638 x
= get_unaligned_le16(&data
[3]);
1639 y
= get_unaligned_le16(&data
[5]);
1641 prox
= prox
&& (data
[1] & 0x01);
1642 x
= le16_to_cpup((__le16
*)&data
[2]);
1643 y
= le16_to_cpup((__le16
*)&data
[4]);
1647 input_report_abs(input
, ABS_X
, x
);
1648 input_report_abs(input
, ABS_Y
, y
);
1650 input_report_key(input
, BTN_TOUCH
, prox
);
1652 /* keep touch state for pen events */
1653 wacom
->shared
->touch_down
= prox
;
1658 static int wacom_tpc_pen(struct wacom_wac
*wacom
)
1660 unsigned char *data
= wacom
->data
;
1661 struct input_dev
*input
= wacom
->pen_input
;
1662 bool prox
= data
[1] & 0x20;
1664 if (!wacom
->shared
->stylus_in_proximity
) /* first in prox */
1665 /* Going into proximity select tool */
1666 wacom
->tool
[0] = (data
[1] & 0x0c) ? BTN_TOOL_RUBBER
: BTN_TOOL_PEN
;
1668 /* keep pen state for touch events */
1669 wacom
->shared
->stylus_in_proximity
= prox
;
1671 /* send pen events only when touch is up or forced out
1672 * or touch arbitration is off
1674 if (!delay_pen_events(wacom
)) {
1675 input_report_key(input
, BTN_STYLUS
, data
[1] & 0x02);
1676 input_report_key(input
, BTN_STYLUS2
, data
[1] & 0x10);
1677 input_report_abs(input
, ABS_X
, le16_to_cpup((__le16
*)&data
[2]));
1678 input_report_abs(input
, ABS_Y
, le16_to_cpup((__le16
*)&data
[4]));
1679 input_report_abs(input
, ABS_PRESSURE
, ((data
[7] & 0x07) << 8) | data
[6]);
1680 input_report_key(input
, BTN_TOUCH
, data
[1] & 0x05);
1681 input_report_key(input
, wacom
->tool
[0], prox
);
1688 static int wacom_tpc_irq(struct wacom_wac
*wacom
, size_t len
)
1690 unsigned char *data
= wacom
->data
;
1692 if (wacom
->pen_input
) {
1693 dev_dbg(wacom
->pen_input
->dev
.parent
,
1694 "%s: received report #%d\n", __func__
, data
[0]);
1696 if (len
== WACOM_PKGLEN_PENABLED
||
1697 data
[0] == WACOM_REPORT_PENABLED
)
1698 return wacom_tpc_pen(wacom
);
1700 else if (wacom
->touch_input
) {
1701 dev_dbg(wacom
->touch_input
->dev
.parent
,
1702 "%s: received report #%d\n", __func__
, data
[0]);
1705 case WACOM_PKGLEN_TPC1FG
:
1706 return wacom_tpc_single_touch(wacom
, len
);
1708 case WACOM_PKGLEN_TPC2FG
:
1709 return wacom_tpc_mt_touch(wacom
);
1713 case WACOM_REPORT_TPC1FG
:
1714 case WACOM_REPORT_TPCHID
:
1715 case WACOM_REPORT_TPCST
:
1716 case WACOM_REPORT_TPC1FGE
:
1717 return wacom_tpc_single_touch(wacom
, len
);
1719 case WACOM_REPORT_TPCMT
:
1720 case WACOM_REPORT_TPCMT2
:
1721 return wacom_mt_touch(wacom
);
1730 static int wacom_offset_rotation(struct input_dev
*input
, struct hid_usage
*usage
,
1731 int value
, int num
, int denom
)
1733 struct input_absinfo
*abs
= &input
->absinfo
[usage
->code
];
1734 int range
= (abs
->maximum
- abs
->minimum
+ 1);
1736 value
+= num
*range
/denom
;
1737 if (value
> abs
->maximum
)
1739 else if (value
< abs
->minimum
)
1744 int wacom_equivalent_usage(int usage
)
1746 if ((usage
& HID_USAGE_PAGE
) == WACOM_HID_UP_WACOMDIGITIZER
) {
1747 int subpage
= (usage
& 0xFF00) << 8;
1748 int subusage
= (usage
& 0xFF);
1750 if (subpage
== WACOM_HID_SP_PAD
||
1751 subpage
== WACOM_HID_SP_BUTTON
||
1752 subpage
== WACOM_HID_SP_DIGITIZER
||
1753 subpage
== WACOM_HID_SP_DIGITIZERINFO
||
1754 usage
== WACOM_HID_WD_SENSE
||
1755 usage
== WACOM_HID_WD_SERIALHI
||
1756 usage
== WACOM_HID_WD_TOOLTYPE
||
1757 usage
== WACOM_HID_WD_DISTANCE
||
1758 usage
== WACOM_HID_WD_TOUCHSTRIP
||
1759 usage
== WACOM_HID_WD_TOUCHSTRIP2
||
1760 usage
== WACOM_HID_WD_TOUCHRING
||
1761 usage
== WACOM_HID_WD_TOUCHRINGSTATUS
||
1762 usage
== WACOM_HID_WD_REPORT_VALID
) {
1766 if (subpage
== HID_UP_UNDEFINED
)
1767 subpage
= HID_UP_DIGITIZER
;
1769 return subpage
| subusage
;
1772 if ((usage
& HID_USAGE_PAGE
) == WACOM_HID_UP_WACOMTOUCH
) {
1773 int subpage
= (usage
& 0xFF00) << 8;
1774 int subusage
= (usage
& 0xFF);
1776 if (usage
== WACOM_HID_WT_REPORT_VALID
)
1779 if (subpage
== HID_UP_UNDEFINED
)
1780 subpage
= WACOM_HID_SP_DIGITIZER
;
1782 return subpage
| subusage
;
1788 static void wacom_map_usage(struct input_dev
*input
, struct hid_usage
*usage
,
1789 struct hid_field
*field
, __u8 type
, __u16 code
, int fuzz
)
1791 struct wacom
*wacom
= input_get_drvdata(input
);
1792 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1793 struct wacom_features
*features
= &wacom_wac
->features
;
1794 int fmin
= field
->logical_minimum
;
1795 int fmax
= field
->logical_maximum
;
1796 unsigned int equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
1797 int resolution_code
= code
;
1799 if (equivalent_usage
== HID_DG_TWIST
) {
1800 resolution_code
= ABS_RZ
;
1803 if (equivalent_usage
== HID_GD_X
) {
1804 fmin
+= features
->offset_left
;
1805 fmax
-= features
->offset_right
;
1807 if (equivalent_usage
== HID_GD_Y
) {
1808 fmin
+= features
->offset_top
;
1809 fmax
-= features
->offset_bottom
;
1815 set_bit(type
, input
->evbit
);
1819 input_set_abs_params(input
, code
, fmin
, fmax
, fuzz
, 0);
1820 input_abs_set_res(input
, code
,
1821 hidinput_calc_abs_res(field
, resolution_code
));
1824 input_set_capability(input
, EV_KEY
, code
);
1827 input_set_capability(input
, EV_MSC
, code
);
1830 input_set_capability(input
, EV_SW
, code
);
1835 static void wacom_wac_battery_usage_mapping(struct hid_device
*hdev
,
1836 struct hid_field
*field
, struct hid_usage
*usage
)
1838 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1839 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1840 struct wacom_features
*features
= &wacom_wac
->features
;
1841 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
1843 switch (equivalent_usage
) {
1844 case HID_DG_BATTERYSTRENGTH
:
1845 case WACOM_HID_WD_BATTERY_LEVEL
:
1846 case WACOM_HID_WD_BATTERY_CHARGING
:
1847 features
->quirks
|= WACOM_QUIRK_BATTERY
;
1852 static void wacom_wac_battery_event(struct hid_device
*hdev
, struct hid_field
*field
,
1853 struct hid_usage
*usage
, __s32 value
)
1855 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1856 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1857 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
1859 switch (equivalent_usage
) {
1860 case HID_DG_BATTERYSTRENGTH
:
1862 wacom_wac
->hid_data
.bat_status
= POWER_SUPPLY_STATUS_UNKNOWN
;
1865 value
= value
* 100 / (field
->logical_maximum
- field
->logical_minimum
);
1866 wacom_wac
->hid_data
.battery_capacity
= value
;
1867 wacom_wac
->hid_data
.bat_connected
= 1;
1868 wacom_wac
->hid_data
.bat_status
= WACOM_POWER_SUPPLY_STATUS_AUTO
;
1871 case WACOM_HID_WD_BATTERY_LEVEL
:
1872 value
= value
* 100 / (field
->logical_maximum
- field
->logical_minimum
);
1873 wacom_wac
->hid_data
.battery_capacity
= value
;
1874 wacom_wac
->hid_data
.bat_connected
= 1;
1875 wacom_wac
->hid_data
.bat_status
= WACOM_POWER_SUPPLY_STATUS_AUTO
;
1877 case WACOM_HID_WD_BATTERY_CHARGING
:
1878 wacom_wac
->hid_data
.bat_charging
= value
;
1879 wacom_wac
->hid_data
.ps_connected
= value
;
1880 wacom_wac
->hid_data
.bat_connected
= 1;
1881 wacom_wac
->hid_data
.bat_status
= WACOM_POWER_SUPPLY_STATUS_AUTO
;
1886 static void wacom_wac_battery_pre_report(struct hid_device
*hdev
,
1887 struct hid_report
*report
)
1892 static void wacom_wac_battery_report(struct hid_device
*hdev
,
1893 struct hid_report
*report
)
1895 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1896 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1897 struct wacom_features
*features
= &wacom_wac
->features
;
1899 if (features
->quirks
& WACOM_QUIRK_BATTERY
) {
1900 int status
= wacom_wac
->hid_data
.bat_status
;
1901 int capacity
= wacom_wac
->hid_data
.battery_capacity
;
1902 bool charging
= wacom_wac
->hid_data
.bat_charging
;
1903 bool connected
= wacom_wac
->hid_data
.bat_connected
;
1904 bool powered
= wacom_wac
->hid_data
.ps_connected
;
1906 wacom_notify_battery(wacom_wac
, status
, capacity
, charging
,
1907 connected
, powered
);
1911 static void wacom_wac_pad_usage_mapping(struct hid_device
*hdev
,
1912 struct hid_field
*field
, struct hid_usage
*usage
)
1914 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1915 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1916 struct wacom_features
*features
= &wacom_wac
->features
;
1917 struct input_dev
*input
= wacom_wac
->pad_input
;
1918 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
1920 switch (equivalent_usage
) {
1921 case WACOM_HID_WD_ACCELEROMETER_X
:
1922 __set_bit(INPUT_PROP_ACCELEROMETER
, input
->propbit
);
1923 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_X
, 0);
1924 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1926 case WACOM_HID_WD_ACCELEROMETER_Y
:
1927 __set_bit(INPUT_PROP_ACCELEROMETER
, input
->propbit
);
1928 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_Y
, 0);
1929 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1931 case WACOM_HID_WD_ACCELEROMETER_Z
:
1932 __set_bit(INPUT_PROP_ACCELEROMETER
, input
->propbit
);
1933 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_Z
, 0);
1934 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1936 case WACOM_HID_WD_BUTTONCENTER
:
1937 case WACOM_HID_WD_BUTTONHOME
:
1938 case WACOM_HID_WD_BUTTONUP
:
1939 case WACOM_HID_WD_BUTTONDOWN
:
1940 case WACOM_HID_WD_BUTTONLEFT
:
1941 case WACOM_HID_WD_BUTTONRIGHT
:
1942 wacom_map_usage(input
, usage
, field
, EV_KEY
,
1943 wacom_numbered_button_to_key(features
->numbered_buttons
),
1945 features
->numbered_buttons
++;
1946 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1948 case WACOM_HID_WD_TOUCHONOFF
:
1949 case WACOM_HID_WD_MUTE_DEVICE
:
1951 * This usage, which is used to mute touch events, comes
1952 * from the pad packet, but is reported on the touch
1953 * interface. Because the touch interface may not have
1954 * been created yet, we cannot call wacom_map_usage(). In
1955 * order to process this usage when we receive it, we set
1956 * the usage type and code directly.
1958 wacom_wac
->has_mute_touch_switch
= true;
1959 usage
->type
= EV_SW
;
1960 usage
->code
= SW_MUTE_DEVICE
;
1961 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1963 case WACOM_HID_WD_TOUCHSTRIP
:
1964 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_RX
, 0);
1965 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1967 case WACOM_HID_WD_TOUCHSTRIP2
:
1968 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_RY
, 0);
1969 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1971 case WACOM_HID_WD_TOUCHRING
:
1972 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_WHEEL
, 0);
1973 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1975 case WACOM_HID_WD_TOUCHRINGSTATUS
:
1977 * Only set up type/code association. Completely mapping
1978 * this usage may overwrite the axis resolution and range.
1980 usage
->type
= EV_ABS
;
1981 usage
->code
= ABS_WHEEL
;
1982 set_bit(EV_ABS
, input
->evbit
);
1983 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1985 case WACOM_HID_WD_BUTTONCONFIG
:
1986 wacom_map_usage(input
, usage
, field
, EV_KEY
, KEY_BUTTONCONFIG
, 0);
1987 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1989 case WACOM_HID_WD_ONSCREEN_KEYBOARD
:
1990 wacom_map_usage(input
, usage
, field
, EV_KEY
, KEY_ONSCREEN_KEYBOARD
, 0);
1991 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1993 case WACOM_HID_WD_CONTROLPANEL
:
1994 wacom_map_usage(input
, usage
, field
, EV_KEY
, KEY_CONTROLPANEL
, 0);
1995 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
1997 case WACOM_HID_WD_MODE_CHANGE
:
1998 /* do not overwrite previous data */
1999 if (!wacom_wac
->has_mode_change
) {
2000 wacom_wac
->has_mode_change
= true;
2001 wacom_wac
->is_direct_mode
= true;
2003 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
2007 switch (equivalent_usage
& 0xfffffff0) {
2008 case WACOM_HID_WD_EXPRESSKEY00
:
2009 wacom_map_usage(input
, usage
, field
, EV_KEY
,
2010 wacom_numbered_button_to_key(features
->numbered_buttons
),
2012 features
->numbered_buttons
++;
2013 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
2018 static void wacom_wac_pad_event(struct hid_device
*hdev
, struct hid_field
*field
,
2019 struct hid_usage
*usage
, __s32 value
)
2021 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2022 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2023 struct input_dev
*input
= wacom_wac
->pad_input
;
2024 struct wacom_features
*features
= &wacom_wac
->features
;
2025 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
2027 bool do_report
= false;
2030 * Avoid reporting this event and setting inrange_state if this usage
2031 * hasn't been mapped.
2033 if (!usage
->type
&& equivalent_usage
!= WACOM_HID_WD_MODE_CHANGE
)
2036 if (wacom_equivalent_usage(field
->physical
) == HID_DG_TABLETFUNCTIONKEY
) {
2037 if (usage
->hid
!= WACOM_HID_WD_TOUCHRING
)
2038 wacom_wac
->hid_data
.inrange_state
|= value
;
2041 switch (equivalent_usage
) {
2042 case WACOM_HID_WD_TOUCHRING
:
2044 * Userspace expects touchrings to increase in value with
2045 * clockwise gestures and have their zero point at the
2046 * tablet's left. HID events "should" be clockwise-
2047 * increasing and zero at top, though the MobileStudio
2048 * Pro and 2nd-gen Intuos Pro don't do this...
2050 if (hdev
->vendor
== 0x56a &&
2051 (hdev
->product
== 0x34d || hdev
->product
== 0x34e || /* MobileStudio Pro */
2052 hdev
->product
== 0x357 || hdev
->product
== 0x358 || /* Intuos Pro 2 */
2053 hdev
->product
== 0x392 || /* Intuos Pro 2 */
2054 hdev
->product
== 0x399)) { /* MobileStudio Pro */
2055 value
= (field
->logical_maximum
- value
);
2057 if (hdev
->product
== 0x357 || hdev
->product
== 0x358 ||
2058 hdev
->product
== 0x392)
2059 value
= wacom_offset_rotation(input
, usage
, value
, 3, 16);
2060 else if (hdev
->product
== 0x34d || hdev
->product
== 0x34e ||
2061 hdev
->product
== 0x399)
2062 value
= wacom_offset_rotation(input
, usage
, value
, 1, 2);
2065 value
= wacom_offset_rotation(input
, usage
, value
, 1, 4);
2069 case WACOM_HID_WD_TOUCHRINGSTATUS
:
2071 input_event(input
, usage
->type
, usage
->code
, 0);
2074 case WACOM_HID_WD_MUTE_DEVICE
:
2075 case WACOM_HID_WD_TOUCHONOFF
:
2076 if (wacom_wac
->shared
->touch_input
) {
2077 bool *is_touch_on
= &wacom_wac
->shared
->is_touch_on
;
2079 if (equivalent_usage
== WACOM_HID_WD_MUTE_DEVICE
&& value
)
2080 *is_touch_on
= !(*is_touch_on
);
2081 else if (equivalent_usage
== WACOM_HID_WD_TOUCHONOFF
)
2082 *is_touch_on
= value
;
2084 input_report_switch(wacom_wac
->shared
->touch_input
,
2085 SW_MUTE_DEVICE
, !(*is_touch_on
));
2086 input_sync(wacom_wac
->shared
->touch_input
);
2090 case WACOM_HID_WD_MODE_CHANGE
:
2091 if (wacom_wac
->is_direct_mode
!= value
) {
2092 wacom_wac
->is_direct_mode
= value
;
2093 wacom_schedule_work(&wacom
->wacom_wac
, WACOM_WORKER_MODE_CHANGE
);
2097 case WACOM_HID_WD_BUTTONCENTER
:
2098 for (i
= 0; i
< wacom
->led
.count
; i
++)
2099 wacom_update_led(wacom
, features
->numbered_buttons
,
2108 input_event(input
, usage
->type
, usage
->code
, value
);
2110 wacom_wac
->hid_data
.pad_input_event_flag
= true;
2114 static void wacom_wac_pad_pre_report(struct hid_device
*hdev
,
2115 struct hid_report
*report
)
2117 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2118 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2120 wacom_wac
->hid_data
.inrange_state
= 0;
2123 static void wacom_wac_pad_report(struct hid_device
*hdev
,
2124 struct hid_report
*report
, struct hid_field
*field
)
2126 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2127 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2128 struct input_dev
*input
= wacom_wac
->pad_input
;
2129 bool active
= wacom_wac
->hid_data
.inrange_state
!= 0;
2131 /* report prox for expresskey events */
2132 if (wacom_wac
->hid_data
.pad_input_event_flag
) {
2133 input_event(input
, EV_ABS
, ABS_MISC
, active
? PAD_DEVICE_ID
: 0);
2136 wacom_wac
->hid_data
.pad_input_event_flag
= false;
2140 static void wacom_wac_pen_usage_mapping(struct hid_device
*hdev
,
2141 struct hid_field
*field
, struct hid_usage
*usage
)
2143 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2144 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2145 struct wacom_features
*features
= &wacom_wac
->features
;
2146 struct input_dev
*input
= wacom_wac
->pen_input
;
2147 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
2149 switch (equivalent_usage
) {
2151 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_X
, 4);
2154 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_Y
, 4);
2156 case WACOM_HID_WD_DISTANCE
:
2158 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_DISTANCE
, 0);
2160 case HID_DG_TIPPRESSURE
:
2161 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_PRESSURE
, 0);
2163 case HID_DG_INRANGE
:
2164 wacom_map_usage(input
, usage
, field
, EV_KEY
, BTN_TOOL_PEN
, 0);
2167 wacom_map_usage(input
, usage
, field
, EV_KEY
,
2168 BTN_TOOL_RUBBER
, 0);
2171 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_TILT_X
, 0);
2174 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_TILT_Y
, 0);
2177 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_Z
, 0);
2180 case HID_DG_TIPSWITCH
:
2181 wacom_map_usage(input
, usage
, field
, EV_KEY
, BTN_TOUCH
, 0);
2183 case HID_DG_BARRELSWITCH
:
2184 wacom_map_usage(input
, usage
, field
, EV_KEY
, BTN_STYLUS
, 0);
2186 case HID_DG_BARRELSWITCH2
:
2187 wacom_map_usage(input
, usage
, field
, EV_KEY
, BTN_STYLUS2
, 0);
2189 case HID_DG_TOOLSERIALNUMBER
:
2190 features
->quirks
|= WACOM_QUIRK_TOOLSERIAL
;
2191 wacom_map_usage(input
, usage
, field
, EV_MSC
, MSC_SERIAL
, 0);
2193 case WACOM_HID_WD_SENSE
:
2194 features
->quirks
|= WACOM_QUIRK_SENSE
;
2195 wacom_map_usage(input
, usage
, field
, EV_KEY
, BTN_TOOL_PEN
, 0);
2197 case WACOM_HID_WD_SERIALHI
:
2198 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_MISC
, 0);
2200 if (!(features
->quirks
& WACOM_QUIRK_AESPEN
)) {
2201 set_bit(EV_KEY
, input
->evbit
);
2202 input_set_capability(input
, EV_KEY
, BTN_TOOL_PEN
);
2203 input_set_capability(input
, EV_KEY
, BTN_TOOL_RUBBER
);
2204 input_set_capability(input
, EV_KEY
, BTN_TOOL_BRUSH
);
2205 input_set_capability(input
, EV_KEY
, BTN_TOOL_PENCIL
);
2206 input_set_capability(input
, EV_KEY
, BTN_TOOL_AIRBRUSH
);
2207 if (!(features
->device_type
& WACOM_DEVICETYPE_DIRECT
)) {
2208 input_set_capability(input
, EV_KEY
, BTN_TOOL_MOUSE
);
2209 input_set_capability(input
, EV_KEY
, BTN_TOOL_LENS
);
2213 case WACOM_HID_WD_FINGERWHEEL
:
2214 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_WHEEL
, 0);
2219 static void wacom_wac_pen_event(struct hid_device
*hdev
, struct hid_field
*field
,
2220 struct hid_usage
*usage
, __s32 value
)
2222 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2223 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2224 struct wacom_features
*features
= &wacom_wac
->features
;
2225 struct input_dev
*input
= wacom_wac
->pen_input
;
2226 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
2228 if (wacom_wac
->is_invalid_bt_frame
)
2231 switch (equivalent_usage
) {
2234 * HID_GD_Z "should increase as the control's position is
2235 * moved from high to low", while ABS_DISTANCE instead
2236 * increases in value as the tool moves from low to high.
2238 value
= field
->logical_maximum
- value
;
2240 case HID_DG_INRANGE
:
2241 wacom_wac
->hid_data
.inrange_state
= value
;
2242 if (!(features
->quirks
& WACOM_QUIRK_SENSE
))
2243 wacom_wac
->hid_data
.sense_state
= value
;
2246 wacom_wac
->hid_data
.invert_state
= value
;
2249 case HID_DG_TIPSWITCH
:
2250 wacom_wac
->hid_data
.tipswitch
|= value
;
2252 case HID_DG_BARRELSWITCH
:
2253 wacom_wac
->hid_data
.barrelswitch
= value
;
2255 case HID_DG_BARRELSWITCH2
:
2256 wacom_wac
->hid_data
.barrelswitch2
= value
;
2258 case HID_DG_TOOLSERIALNUMBER
:
2260 wacom_wac
->serial
[0] = (wacom_wac
->serial
[0] & ~0xFFFFFFFFULL
);
2261 wacom_wac
->serial
[0] |= (__u32
)value
;
2266 * Userspace expects pen twist to have its zero point when
2267 * the buttons/finger is on the tablet's left. HID values
2268 * are zero when buttons are toward the top.
2270 value
= wacom_offset_rotation(input
, usage
, value
, 1, 4);
2272 case WACOM_HID_WD_SENSE
:
2273 wacom_wac
->hid_data
.sense_state
= value
;
2275 case WACOM_HID_WD_SERIALHI
:
2277 wacom_wac
->serial
[0] = (wacom_wac
->serial
[0] & 0xFFFFFFFF);
2278 wacom_wac
->serial
[0] |= ((__u64
)value
) << 32;
2280 * Non-USI EMR devices may contain additional tool type
2281 * information here. See WACOM_HID_WD_TOOLTYPE case for
2284 if (value
>> 20 == 1) {
2285 wacom_wac
->id
[0] |= value
& 0xFFFFF;
2289 case WACOM_HID_WD_TOOLTYPE
:
2291 * Some devices (MobileStudio Pro, and possibly later
2292 * devices as well) do not return the complete tool
2293 * type in their WACOM_HID_WD_TOOLTYPE usage. Use a
2294 * bitwise OR so the complete value can be built
2297 wacom_wac
->id
[0] |= value
;
2299 case WACOM_HID_WD_OFFSETLEFT
:
2300 if (features
->offset_left
&& value
!= features
->offset_left
)
2301 hid_warn(hdev
, "%s: overriding existing left offset "
2302 "%d -> %d\n", __func__
, value
,
2303 features
->offset_left
);
2304 features
->offset_left
= value
;
2306 case WACOM_HID_WD_OFFSETRIGHT
:
2307 if (features
->offset_right
&& value
!= features
->offset_right
)
2308 hid_warn(hdev
, "%s: overriding existing right offset "
2309 "%d -> %d\n", __func__
, value
,
2310 features
->offset_right
);
2311 features
->offset_right
= value
;
2313 case WACOM_HID_WD_OFFSETTOP
:
2314 if (features
->offset_top
&& value
!= features
->offset_top
)
2315 hid_warn(hdev
, "%s: overriding existing top offset "
2316 "%d -> %d\n", __func__
, value
,
2317 features
->offset_top
);
2318 features
->offset_top
= value
;
2320 case WACOM_HID_WD_OFFSETBOTTOM
:
2321 if (features
->offset_bottom
&& value
!= features
->offset_bottom
)
2322 hid_warn(hdev
, "%s: overriding existing bottom offset "
2323 "%d -> %d\n", __func__
, value
,
2324 features
->offset_bottom
);
2325 features
->offset_bottom
= value
;
2327 case WACOM_HID_WD_REPORT_VALID
:
2328 wacom_wac
->is_invalid_bt_frame
= !value
;
2332 /* send pen events only when touch is up or forced out
2333 * or touch arbitration is off
2335 if (!usage
->type
|| delay_pen_events(wacom_wac
))
2338 /* send pen events only when the pen is in range */
2339 if (wacom_wac
->hid_data
.inrange_state
)
2340 input_event(input
, usage
->type
, usage
->code
, value
);
2341 else if (wacom_wac
->shared
->stylus_in_proximity
&& !wacom_wac
->hid_data
.sense_state
)
2342 input_event(input
, usage
->type
, usage
->code
, 0);
2345 static void wacom_wac_pen_pre_report(struct hid_device
*hdev
,
2346 struct hid_report
*report
)
2348 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2349 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2351 wacom_wac
->is_invalid_bt_frame
= false;
2355 static void wacom_wac_pen_report(struct hid_device
*hdev
,
2356 struct hid_report
*report
)
2358 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2359 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2360 struct input_dev
*input
= wacom_wac
->pen_input
;
2361 bool range
= wacom_wac
->hid_data
.inrange_state
;
2362 bool sense
= wacom_wac
->hid_data
.sense_state
;
2364 if (wacom_wac
->is_invalid_bt_frame
)
2367 if (!wacom_wac
->tool
[0] && range
) { /* first in range */
2368 /* Going into range select tool */
2369 if (wacom_wac
->hid_data
.invert_state
)
2370 wacom_wac
->tool
[0] = BTN_TOOL_RUBBER
;
2371 else if (wacom_wac
->id
[0])
2372 wacom_wac
->tool
[0] = wacom_intuos_get_tool_type(wacom_wac
->id
[0]);
2374 wacom_wac
->tool
[0] = BTN_TOOL_PEN
;
2377 /* keep pen state for touch events */
2378 wacom_wac
->shared
->stylus_in_proximity
= sense
;
2380 if (!delay_pen_events(wacom_wac
) && wacom_wac
->tool
[0]) {
2381 int id
= wacom_wac
->id
[0];
2382 int sw_state
= wacom_wac
->hid_data
.barrelswitch
|
2383 (wacom_wac
->hid_data
.barrelswitch2
<< 1);
2385 input_report_key(input
, BTN_STYLUS
, sw_state
== 1);
2386 input_report_key(input
, BTN_STYLUS2
, sw_state
== 2);
2387 input_report_key(input
, BTN_STYLUS3
, sw_state
== 3);
2390 * Non-USI EMR tools should have their IDs mangled to
2391 * match the legacy behavior of wacom_intuos_general
2393 if (wacom_wac
->serial
[0] >> 52 == 1)
2394 id
= wacom_intuos_id_mangle(id
);
2397 * To ensure compatibility with xf86-input-wacom, we should
2398 * report the BTN_TOOL_* event prior to the ABS_MISC or
2399 * MSC_SERIAL events.
2401 input_report_key(input
, BTN_TOUCH
,
2402 wacom_wac
->hid_data
.tipswitch
);
2403 input_report_key(input
, wacom_wac
->tool
[0], sense
);
2404 if (wacom_wac
->serial
[0]) {
2405 input_event(input
, EV_MSC
, MSC_SERIAL
, wacom_wac
->serial
[0]);
2406 input_report_abs(input
, ABS_MISC
, sense
? id
: 0);
2409 wacom_wac
->hid_data
.tipswitch
= false;
2415 wacom_wac
->tool
[0] = 0;
2416 wacom_wac
->id
[0] = 0;
2417 wacom_wac
->serial
[0] = 0;
2421 static void wacom_wac_finger_usage_mapping(struct hid_device
*hdev
,
2422 struct hid_field
*field
, struct hid_usage
*usage
)
2424 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2425 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2426 struct input_dev
*input
= wacom_wac
->touch_input
;
2427 unsigned touch_max
= wacom_wac
->features
.touch_max
;
2428 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
2430 switch (equivalent_usage
) {
2433 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_X
, 4);
2435 wacom_map_usage(input
, usage
, field
, EV_ABS
,
2436 ABS_MT_POSITION_X
, 4);
2440 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_Y
, 4);
2442 wacom_map_usage(input
, usage
, field
, EV_ABS
,
2443 ABS_MT_POSITION_Y
, 4);
2447 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_MT_TOUCH_MAJOR
, 0);
2448 wacom_map_usage(input
, usage
, field
, EV_ABS
, ABS_MT_TOUCH_MINOR
, 0);
2449 input_set_abs_params(input
, ABS_MT_ORIENTATION
, 0, 1, 0, 0);
2451 case HID_DG_TIPSWITCH
:
2452 wacom_map_usage(input
, usage
, field
, EV_KEY
, BTN_TOUCH
, 0);
2454 case HID_DG_CONTACTCOUNT
:
2455 wacom_wac
->hid_data
.cc_report
= field
->report
->id
;
2456 wacom_wac
->hid_data
.cc_index
= field
->index
;
2457 wacom_wac
->hid_data
.cc_value_index
= usage
->usage_index
;
2459 case HID_DG_CONTACTID
:
2460 if ((field
->logical_maximum
- field
->logical_minimum
) < touch_max
) {
2462 * The HID descriptor for G11 sensors leaves logical
2463 * maximum set to '1' despite it being a multitouch
2464 * device. Override to a sensible number.
2466 field
->logical_maximum
= 255;
2472 static void wacom_wac_finger_slot(struct wacom_wac
*wacom_wac
,
2473 struct input_dev
*input
)
2475 struct hid_data
*hid_data
= &wacom_wac
->hid_data
;
2476 bool mt
= wacom_wac
->features
.touch_max
> 1;
2477 bool prox
= hid_data
->tipswitch
&&
2478 report_touch_events(wacom_wac
);
2480 if (wacom_wac
->shared
->has_mute_touch_switch
&&
2481 !wacom_wac
->shared
->is_touch_on
) {
2482 if (!wacom_wac
->shared
->touch_down
)
2487 wacom_wac
->hid_data
.num_received
++;
2488 if (wacom_wac
->hid_data
.num_received
> wacom_wac
->hid_data
.num_expected
)
2494 slot
= input_mt_get_slot_by_key(input
, hid_data
->id
);
2495 input_mt_slot(input
, slot
);
2496 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, prox
);
2499 input_report_key(input
, BTN_TOUCH
, prox
);
2503 input_report_abs(input
, mt
? ABS_MT_POSITION_X
: ABS_X
,
2505 input_report_abs(input
, mt
? ABS_MT_POSITION_Y
: ABS_Y
,
2508 if (test_bit(ABS_MT_TOUCH_MAJOR
, input
->absbit
)) {
2509 input_report_abs(input
, ABS_MT_TOUCH_MAJOR
, max(hid_data
->width
, hid_data
->height
));
2510 input_report_abs(input
, ABS_MT_TOUCH_MINOR
, min(hid_data
->width
, hid_data
->height
));
2511 if (hid_data
->width
!= hid_data
->height
)
2512 input_report_abs(input
, ABS_MT_ORIENTATION
, hid_data
->width
<= hid_data
->height
? 0 : 1);
2517 static void wacom_wac_finger_event(struct hid_device
*hdev
,
2518 struct hid_field
*field
, struct hid_usage
*usage
, __s32 value
)
2520 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2521 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2522 unsigned equivalent_usage
= wacom_equivalent_usage(usage
->hid
);
2523 struct wacom_features
*features
= &wacom
->wacom_wac
.features
;
2525 if (wacom_wac
->is_invalid_bt_frame
)
2528 switch (equivalent_usage
) {
2530 wacom_wac
->hid_data
.x
= value
;
2533 wacom_wac
->hid_data
.y
= value
;
2536 wacom_wac
->hid_data
.width
= value
;
2539 wacom_wac
->hid_data
.height
= value
;
2541 case HID_DG_CONTACTID
:
2542 wacom_wac
->hid_data
.id
= value
;
2544 case HID_DG_TIPSWITCH
:
2545 wacom_wac
->hid_data
.tipswitch
= value
;
2547 case WACOM_HID_WT_REPORT_VALID
:
2548 wacom_wac
->is_invalid_bt_frame
= !value
;
2550 case HID_DG_CONTACTMAX
:
2551 features
->touch_max
= value
;
2555 if (usage
->usage_index
+ 1 == field
->report_count
) {
2556 if (equivalent_usage
== wacom_wac
->hid_data
.last_slot_field
)
2557 wacom_wac_finger_slot(wacom_wac
, wacom_wac
->touch_input
);
2561 static void wacom_wac_finger_pre_report(struct hid_device
*hdev
,
2562 struct hid_report
*report
)
2564 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2565 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2566 struct hid_data
* hid_data
= &wacom_wac
->hid_data
;
2569 wacom_wac
->is_invalid_bt_frame
= false;
2571 for (i
= 0; i
< report
->maxfield
; i
++) {
2572 struct hid_field
*field
= report
->field
[i
];
2575 for (j
= 0; j
< field
->maxusage
; j
++) {
2576 struct hid_usage
*usage
= &field
->usage
[j
];
2577 unsigned int equivalent_usage
=
2578 wacom_equivalent_usage(usage
->hid
);
2580 switch (equivalent_usage
) {
2585 case HID_DG_CONTACTID
:
2586 case HID_DG_INRANGE
:
2588 case HID_DG_TIPSWITCH
:
2589 hid_data
->last_slot_field
= equivalent_usage
;
2596 static void wacom_wac_finger_report(struct hid_device
*hdev
,
2597 struct hid_report
*report
)
2599 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2600 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2601 struct input_dev
*input
= wacom_wac
->touch_input
;
2602 unsigned touch_max
= wacom_wac
->features
.touch_max
;
2603 struct hid_data
*hid_data
= &wacom_wac
->hid_data
;
2605 /* If more packets of data are expected, give us a chance to
2606 * process them rather than immediately syncing a partial
2609 if (wacom_wac
->hid_data
.num_received
< wacom_wac
->hid_data
.num_expected
)
2613 input_mt_sync_frame(input
);
2616 wacom_wac
->hid_data
.num_received
= 0;
2617 hid_data
->num_expected
= 0;
2619 /* keep touch state for pen event */
2620 wacom_wac
->shared
->touch_down
= wacom_wac_finger_count_touches(wacom_wac
);
2623 void wacom_wac_usage_mapping(struct hid_device
*hdev
,
2624 struct hid_field
*field
, struct hid_usage
*usage
)
2626 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2627 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2628 struct wacom_features
*features
= &wacom_wac
->features
;
2630 if (WACOM_DIRECT_DEVICE(field
))
2631 features
->device_type
|= WACOM_DEVICETYPE_DIRECT
;
2633 /* usage tests must precede field tests */
2634 if (WACOM_BATTERY_USAGE(usage
))
2635 wacom_wac_battery_usage_mapping(hdev
, field
, usage
);
2636 else if (WACOM_PAD_FIELD(field
))
2637 wacom_wac_pad_usage_mapping(hdev
, field
, usage
);
2638 else if (WACOM_PEN_FIELD(field
))
2639 wacom_wac_pen_usage_mapping(hdev
, field
, usage
);
2640 else if (WACOM_FINGER_FIELD(field
))
2641 wacom_wac_finger_usage_mapping(hdev
, field
, usage
);
2644 void wacom_wac_event(struct hid_device
*hdev
, struct hid_field
*field
,
2645 struct hid_usage
*usage
, __s32 value
)
2647 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2649 if (wacom
->wacom_wac
.features
.type
!= HID_GENERIC
)
2652 if (value
> field
->logical_maximum
|| value
< field
->logical_minimum
)
2655 /* usage tests must precede field tests */
2656 if (WACOM_BATTERY_USAGE(usage
))
2657 wacom_wac_battery_event(hdev
, field
, usage
, value
);
2658 else if (WACOM_PAD_FIELD(field
) && wacom
->wacom_wac
.pad_input
)
2659 wacom_wac_pad_event(hdev
, field
, usage
, value
);
2660 else if (WACOM_PEN_FIELD(field
) && wacom
->wacom_wac
.pen_input
)
2661 wacom_wac_pen_event(hdev
, field
, usage
, value
);
2662 else if (WACOM_FINGER_FIELD(field
) && wacom
->wacom_wac
.touch_input
)
2663 wacom_wac_finger_event(hdev
, field
, usage
, value
);
2666 static void wacom_report_events(struct hid_device
*hdev
,
2667 struct hid_report
*report
, int collection_index
,
2672 for (r
= field_index
; r
< report
->maxfield
; r
++) {
2673 struct hid_field
*field
;
2676 field
= report
->field
[r
];
2677 count
= field
->report_count
;
2679 if (!(HID_MAIN_ITEM_VARIABLE
& field
->flags
))
2682 for (n
= 0 ; n
< count
; n
++) {
2683 if (field
->usage
[n
].collection_index
== collection_index
)
2684 wacom_wac_event(hdev
, field
, &field
->usage
[n
],
2692 static void wacom_set_num_expected(struct hid_device
*hdev
,
2693 struct hid_report
*report
,
2694 int collection_index
,
2695 struct hid_field
*field
,
2698 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2699 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2700 struct hid_data
*hid_data
= &wacom_wac
->hid_data
;
2701 unsigned int original_collection_level
=
2702 hdev
->collection
[collection_index
].level
;
2703 bool end_collection
= false;
2706 if (hid_data
->num_expected
)
2709 // find the contact count value for this segment
2710 for (i
= field_index
; i
< report
->maxfield
&& !end_collection
; i
++) {
2711 struct hid_field
*field
= report
->field
[i
];
2712 unsigned int field_level
=
2713 hdev
->collection
[field
->usage
[0].collection_index
].level
;
2716 if (field_level
!= original_collection_level
)
2719 for (j
= 0; j
< field
->maxusage
; j
++) {
2720 struct hid_usage
*usage
= &field
->usage
[j
];
2722 if (usage
->collection_index
!= collection_index
) {
2723 end_collection
= true;
2726 if (wacom_equivalent_usage(usage
->hid
) == HID_DG_CONTACTCOUNT
) {
2727 hid_data
->cc_report
= report
->id
;
2728 hid_data
->cc_index
= i
;
2729 hid_data
->cc_value_index
= j
;
2731 if (hid_data
->cc_report
!= 0 &&
2732 hid_data
->cc_index
>= 0) {
2734 struct hid_field
*field
=
2735 report
->field
[hid_data
->cc_index
];
2737 field
->value
[hid_data
->cc_value_index
];
2740 hid_data
->num_expected
= value
;
2746 if (hid_data
->cc_report
== 0 || hid_data
->cc_index
< 0)
2747 hid_data
->num_expected
= wacom_wac
->features
.touch_max
;
2750 static int wacom_wac_collection(struct hid_device
*hdev
, struct hid_report
*report
,
2751 int collection_index
, struct hid_field
*field
,
2754 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2756 if (WACOM_FINGER_FIELD(field
))
2757 wacom_set_num_expected(hdev
, report
, collection_index
, field
,
2759 wacom_report_events(hdev
, report
, collection_index
, field_index
);
2762 * Non-input reports may be sent prior to the device being
2763 * completely initialized. Since only their events need
2764 * to be processed, exit after 'wacom_report_events' has
2765 * been called to prevent potential crashes in the report-
2766 * processing functions.
2768 if (report
->type
!= HID_INPUT_REPORT
)
2771 if (WACOM_PEN_FIELD(field
) && wacom
->wacom_wac
.pen_input
)
2772 wacom_wac_pen_report(hdev
, report
);
2773 else if (WACOM_FINGER_FIELD(field
) && wacom
->wacom_wac
.touch_input
)
2774 wacom_wac_finger_report(hdev
, report
);
2779 void wacom_wac_report(struct hid_device
*hdev
, struct hid_report
*report
)
2781 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2782 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2783 struct hid_field
*field
;
2784 bool pad_in_hid_field
= false, pen_in_hid_field
= false,
2785 finger_in_hid_field
= false, true_pad
= false;
2787 int prev_collection
= -1;
2789 if (wacom_wac
->features
.type
!= HID_GENERIC
)
2792 for (r
= 0; r
< report
->maxfield
; r
++) {
2793 field
= report
->field
[r
];
2795 if (WACOM_PAD_FIELD(field
))
2796 pad_in_hid_field
= true;
2797 if (WACOM_PEN_FIELD(field
))
2798 pen_in_hid_field
= true;
2799 if (WACOM_FINGER_FIELD(field
))
2800 finger_in_hid_field
= true;
2801 if (wacom_equivalent_usage(field
->physical
) == HID_DG_TABLETFUNCTIONKEY
)
2805 wacom_wac_battery_pre_report(hdev
, report
);
2807 if (pad_in_hid_field
&& wacom
->wacom_wac
.pad_input
)
2808 wacom_wac_pad_pre_report(hdev
, report
);
2809 if (pen_in_hid_field
&& wacom
->wacom_wac
.pen_input
)
2810 wacom_wac_pen_pre_report(hdev
, report
);
2811 if (finger_in_hid_field
&& wacom
->wacom_wac
.touch_input
)
2812 wacom_wac_finger_pre_report(hdev
, report
);
2814 for (r
= 0; r
< report
->maxfield
; r
++) {
2815 field
= report
->field
[r
];
2817 if (field
->usage
[0].collection_index
!= prev_collection
) {
2818 if (wacom_wac_collection(hdev
, report
,
2819 field
->usage
[0].collection_index
, field
, r
) < 0)
2821 prev_collection
= field
->usage
[0].collection_index
;
2825 wacom_wac_battery_report(hdev
, report
);
2827 if (true_pad
&& wacom
->wacom_wac
.pad_input
)
2828 wacom_wac_pad_report(hdev
, report
, field
);
2831 static int wacom_bpt_touch(struct wacom_wac
*wacom
)
2833 struct wacom_features
*features
= &wacom
->features
;
2834 struct input_dev
*input
= wacom
->touch_input
;
2835 struct input_dev
*pad_input
= wacom
->pad_input
;
2836 unsigned char *data
= wacom
->data
;
2839 if (data
[0] != 0x02)
2842 for (i
= 0; i
< 2; i
++) {
2843 int offset
= (data
[1] & 0x80) ? (8 * i
) : (9 * i
);
2844 bool touch
= report_touch_events(wacom
)
2845 && (data
[offset
+ 3] & 0x80);
2847 input_mt_slot(input
, i
);
2848 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, touch
);
2850 int x
= get_unaligned_be16(&data
[offset
+ 3]) & 0x7ff;
2851 int y
= get_unaligned_be16(&data
[offset
+ 5]) & 0x7ff;
2852 if (features
->quirks
& WACOM_QUIRK_BBTOUCH_LOWRES
) {
2856 input_report_abs(input
, ABS_MT_POSITION_X
, x
);
2857 input_report_abs(input
, ABS_MT_POSITION_Y
, y
);
2861 input_mt_sync_frame(input
);
2863 input_report_key(pad_input
, BTN_LEFT
, (data
[1] & 0x08) != 0);
2864 input_report_key(pad_input
, BTN_FORWARD
, (data
[1] & 0x04) != 0);
2865 input_report_key(pad_input
, BTN_BACK
, (data
[1] & 0x02) != 0);
2866 input_report_key(pad_input
, BTN_RIGHT
, (data
[1] & 0x01) != 0);
2867 wacom
->shared
->touch_down
= wacom_wac_finger_count_touches(wacom
);
2872 static void wacom_bpt3_touch_msg(struct wacom_wac
*wacom
, unsigned char *data
)
2874 struct wacom_features
*features
= &wacom
->features
;
2875 struct input_dev
*input
= wacom
->touch_input
;
2876 bool touch
= data
[1] & 0x80;
2877 int slot
= input_mt_get_slot_by_key(input
, data
[0]);
2882 touch
= touch
&& report_touch_events(wacom
);
2884 input_mt_slot(input
, slot
);
2885 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, touch
);
2888 int x
= (data
[2] << 4) | (data
[4] >> 4);
2889 int y
= (data
[3] << 4) | (data
[4] & 0x0f);
2892 if (features
->type
>= INTUOSPS
&& features
->type
<= INTUOSHT2
) {
2893 width
= data
[5] * 100;
2894 height
= data
[6] * 100;
2897 * "a" is a scaled-down area which we assume is
2898 * roughly circular and which can be described as:
2902 int x_res
= input_abs_get_res(input
, ABS_MT_POSITION_X
);
2903 int y_res
= input_abs_get_res(input
, ABS_MT_POSITION_Y
);
2904 width
= 2 * int_sqrt(a
* WACOM_CONTACT_AREA_SCALE
);
2905 height
= width
* y_res
/ x_res
;
2908 input_report_abs(input
, ABS_MT_POSITION_X
, x
);
2909 input_report_abs(input
, ABS_MT_POSITION_Y
, y
);
2910 input_report_abs(input
, ABS_MT_TOUCH_MAJOR
, width
);
2911 input_report_abs(input
, ABS_MT_TOUCH_MINOR
, height
);
2915 static void wacom_bpt3_button_msg(struct wacom_wac
*wacom
, unsigned char *data
)
2917 struct input_dev
*input
= wacom
->pad_input
;
2918 struct wacom_features
*features
= &wacom
->features
;
2920 if (features
->type
== INTUOSHT
|| features
->type
== INTUOSHT2
) {
2921 input_report_key(input
, BTN_LEFT
, (data
[1] & 0x02) != 0);
2922 input_report_key(input
, BTN_BACK
, (data
[1] & 0x08) != 0);
2924 input_report_key(input
, BTN_BACK
, (data
[1] & 0x02) != 0);
2925 input_report_key(input
, BTN_LEFT
, (data
[1] & 0x08) != 0);
2927 input_report_key(input
, BTN_FORWARD
, (data
[1] & 0x04) != 0);
2928 input_report_key(input
, BTN_RIGHT
, (data
[1] & 0x01) != 0);
2931 static int wacom_bpt3_touch(struct wacom_wac
*wacom
)
2933 unsigned char *data
= wacom
->data
;
2934 int count
= data
[1] & 0x07;
2935 int touch_changed
= 0, i
;
2937 if (data
[0] != 0x02)
2940 /* data has up to 7 fixed sized 8-byte messages starting at data[2] */
2941 for (i
= 0; i
< count
; i
++) {
2942 int offset
= (8 * i
) + 2;
2943 int msg_id
= data
[offset
];
2945 if (msg_id
>= 2 && msg_id
<= 17) {
2946 wacom_bpt3_touch_msg(wacom
, data
+ offset
);
2948 } else if (msg_id
== 128)
2949 wacom_bpt3_button_msg(wacom
, data
+ offset
);
2953 /* only update touch if we actually have a touchpad and touch data changed */
2954 if (wacom
->touch_input
&& touch_changed
) {
2955 input_mt_sync_frame(wacom
->touch_input
);
2956 wacom
->shared
->touch_down
= wacom_wac_finger_count_touches(wacom
);
2962 static int wacom_bpt_pen(struct wacom_wac
*wacom
)
2964 struct wacom_features
*features
= &wacom
->features
;
2965 struct input_dev
*input
= wacom
->pen_input
;
2966 unsigned char *data
= wacom
->data
;
2967 int x
= 0, y
= 0, p
= 0, d
= 0;
2968 bool pen
= false, btn1
= false, btn2
= false;
2969 bool range
, prox
, rdy
;
2971 if (data
[0] != WACOM_REPORT_PENABLED
)
2974 range
= (data
[1] & 0x80) == 0x80;
2975 prox
= (data
[1] & 0x40) == 0x40;
2976 rdy
= (data
[1] & 0x20) == 0x20;
2978 wacom
->shared
->stylus_in_proximity
= range
;
2979 if (delay_pen_events(wacom
))
2983 p
= le16_to_cpup((__le16
*)&data
[6]);
2984 pen
= data
[1] & 0x01;
2985 btn1
= data
[1] & 0x02;
2986 btn2
= data
[1] & 0x04;
2989 x
= le16_to_cpup((__le16
*)&data
[2]);
2990 y
= le16_to_cpup((__le16
*)&data
[4]);
2992 if (data
[1] & 0x08) {
2993 wacom
->tool
[0] = BTN_TOOL_RUBBER
;
2994 wacom
->id
[0] = ERASER_DEVICE_ID
;
2996 wacom
->tool
[0] = BTN_TOOL_PEN
;
2997 wacom
->id
[0] = STYLUS_DEVICE_ID
;
2999 wacom
->reporting_data
= true;
3003 * Convert distance from out prox to distance from tablet.
3004 * distance will be greater than distance_max once
3005 * touching and applying pressure; do not report negative
3008 if (data
[8] <= features
->distance_max
)
3009 d
= features
->distance_max
- data
[8];
3014 if (wacom
->reporting_data
) {
3015 input_report_key(input
, BTN_TOUCH
, pen
);
3016 input_report_key(input
, BTN_STYLUS
, btn1
);
3017 input_report_key(input
, BTN_STYLUS2
, btn2
);
3019 if (prox
|| !range
) {
3020 input_report_abs(input
, ABS_X
, x
);
3021 input_report_abs(input
, ABS_Y
, y
);
3023 input_report_abs(input
, ABS_PRESSURE
, p
);
3024 input_report_abs(input
, ABS_DISTANCE
, d
);
3026 input_report_key(input
, wacom
->tool
[0], range
); /* PEN or RUBBER */
3027 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]); /* TOOL ID */
3031 wacom
->reporting_data
= false;
3037 static int wacom_bpt_irq(struct wacom_wac
*wacom
, size_t len
)
3039 struct wacom_features
*features
= &wacom
->features
;
3041 if ((features
->type
== INTUOSHT2
) &&
3042 (features
->device_type
& WACOM_DEVICETYPE_PEN
))
3043 return wacom_intuos_irq(wacom
);
3044 else if (len
== WACOM_PKGLEN_BBTOUCH
)
3045 return wacom_bpt_touch(wacom
);
3046 else if (len
== WACOM_PKGLEN_BBTOUCH3
)
3047 return wacom_bpt3_touch(wacom
);
3048 else if (len
== WACOM_PKGLEN_BBFUN
|| len
== WACOM_PKGLEN_BBPEN
)
3049 return wacom_bpt_pen(wacom
);
3054 static void wacom_bamboo_pad_pen_event(struct wacom_wac
*wacom
,
3055 unsigned char *data
)
3057 unsigned char prefix
;
3060 * We need to reroute the event from the debug interface to the
3062 * We need to add the report ID to the actual pen report, so we
3063 * temporary overwrite the first byte to prevent having to kzalloc/kfree
3064 * and memcpy the report.
3067 data
[0] = WACOM_REPORT_BPAD_PEN
;
3070 * actually reroute the event.
3071 * No need to check if wacom->shared->pen is valid, hid_input_report()
3072 * will check for us.
3074 hid_input_report(wacom
->shared
->pen
, HID_INPUT_REPORT
, data
,
3075 WACOM_PKGLEN_PENABLED
, 1);
3080 static int wacom_bamboo_pad_touch_event(struct wacom_wac
*wacom
,
3081 unsigned char *data
)
3083 struct input_dev
*input
= wacom
->touch_input
;
3084 unsigned char *finger_data
, prefix
;
3091 for (id
= 0; id
< wacom
->features
.touch_max
; id
++) {
3092 valid
= !!(prefix
& BIT(id
)) &&
3093 report_touch_events(wacom
);
3095 input_mt_slot(input
, id
);
3096 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, valid
);
3101 finger_data
= data
+ 1 + id
* 3;
3102 x
= finger_data
[0] | ((finger_data
[1] & 0x0f) << 8);
3103 y
= (finger_data
[2] << 4) | (finger_data
[1] >> 4);
3105 input_report_abs(input
, ABS_MT_POSITION_X
, x
);
3106 input_report_abs(input
, ABS_MT_POSITION_Y
, y
);
3109 input_mt_sync_frame(input
);
3111 input_report_key(input
, BTN_LEFT
, prefix
& 0x40);
3112 input_report_key(input
, BTN_RIGHT
, prefix
& 0x80);
3114 /* keep touch state for pen event */
3115 wacom
->shared
->touch_down
= !!prefix
&& report_touch_events(wacom
);
3120 static int wacom_bamboo_pad_irq(struct wacom_wac
*wacom
, size_t len
)
3122 unsigned char *data
= wacom
->data
;
3124 if (!((len
== WACOM_PKGLEN_BPAD_TOUCH
) ||
3125 (len
== WACOM_PKGLEN_BPAD_TOUCH_USB
)) ||
3126 (data
[0] != WACOM_REPORT_BPAD_TOUCH
))
3130 wacom_bamboo_pad_pen_event(wacom
, &data
[1]);
3133 return wacom_bamboo_pad_touch_event(wacom
, &data
[9]);
3138 static int wacom_wireless_irq(struct wacom_wac
*wacom
, size_t len
)
3140 unsigned char *data
= wacom
->data
;
3143 if (len
!= WACOM_PKGLEN_WIRELESS
|| data
[0] != WACOM_REPORT_WL
)
3146 connected
= data
[1] & 0x01;
3148 int pid
, battery
, charging
;
3150 if ((wacom
->shared
->type
== INTUOSHT
||
3151 wacom
->shared
->type
== INTUOSHT2
) &&
3152 wacom
->shared
->touch_input
&&
3153 wacom
->shared
->touch_max
) {
3154 input_report_switch(wacom
->shared
->touch_input
,
3155 SW_MUTE_DEVICE
, data
[5] & 0x40);
3156 input_sync(wacom
->shared
->touch_input
);
3159 pid
= get_unaligned_be16(&data
[6]);
3160 battery
= (data
[5] & 0x3f) * 100 / 31;
3161 charging
= !!(data
[5] & 0x80);
3162 if (wacom
->pid
!= pid
) {
3164 wacom_schedule_work(wacom
, WACOM_WORKER_WIRELESS
);
3167 wacom_notify_battery(wacom
, WACOM_POWER_SUPPLY_STATUS_AUTO
,
3168 battery
, charging
, 1, 0);
3170 } else if (wacom
->pid
!= 0) {
3171 /* disconnected while previously connected */
3173 wacom_schedule_work(wacom
, WACOM_WORKER_WIRELESS
);
3174 wacom_notify_battery(wacom
, POWER_SUPPLY_STATUS_UNKNOWN
, 0, 0, 0, 0);
3180 static int wacom_status_irq(struct wacom_wac
*wacom_wac
, size_t len
)
3182 struct wacom
*wacom
= container_of(wacom_wac
, struct wacom
, wacom_wac
);
3183 struct wacom_features
*features
= &wacom_wac
->features
;
3184 unsigned char *data
= wacom_wac
->data
;
3186 if (data
[0] != WACOM_REPORT_USB
)
3189 if ((features
->type
== INTUOSHT
||
3190 features
->type
== INTUOSHT2
) &&
3191 wacom_wac
->shared
->touch_input
&&
3192 features
->touch_max
) {
3193 input_report_switch(wacom_wac
->shared
->touch_input
,
3194 SW_MUTE_DEVICE
, data
[8] & 0x40);
3195 input_sync(wacom_wac
->shared
->touch_input
);
3198 if (data
[9] & 0x02) { /* wireless module is attached */
3199 int battery
= (data
[8] & 0x3f) * 100 / 31;
3200 bool charging
= !!(data
[8] & 0x80);
3202 wacom_notify_battery(wacom_wac
, WACOM_POWER_SUPPLY_STATUS_AUTO
,
3203 battery
, charging
, battery
|| charging
, 1);
3205 if (!wacom
->battery
.battery
&&
3206 !(features
->quirks
& WACOM_QUIRK_BATTERY
)) {
3207 features
->quirks
|= WACOM_QUIRK_BATTERY
;
3208 wacom_schedule_work(wacom_wac
, WACOM_WORKER_BATTERY
);
3211 else if ((features
->quirks
& WACOM_QUIRK_BATTERY
) &&
3212 wacom
->battery
.battery
) {
3213 features
->quirks
&= ~WACOM_QUIRK_BATTERY
;
3214 wacom_schedule_work(wacom_wac
, WACOM_WORKER_BATTERY
);
3215 wacom_notify_battery(wacom_wac
, POWER_SUPPLY_STATUS_UNKNOWN
, 0, 0, 0, 0);
3220 void wacom_wac_irq(struct wacom_wac
*wacom_wac
, size_t len
)
3224 switch (wacom_wac
->features
.type
) {
3226 sync
= wacom_penpartner_irq(wacom_wac
);
3230 sync
= wacom_pl_irq(wacom_wac
);
3237 sync
= wacom_graphire_irq(wacom_wac
);
3241 sync
= wacom_ptu_irq(wacom_wac
);
3245 sync
= wacom_dtu_irq(wacom_wac
);
3250 sync
= wacom_dtus_irq(wacom_wac
);
3269 case CINTIQ_COMPANION_2
:
3270 sync
= wacom_intuos_irq(wacom_wac
);
3274 sync
= wacom_intuos_bt_irq(wacom_wac
, len
);
3279 sync
= wacom_24hdt_irq(wacom_wac
);
3288 if (len
== WACOM_PKGLEN_BBTOUCH3
)
3289 sync
= wacom_bpt3_touch(wacom_wac
);
3290 else if (wacom_wac
->data
[0] == WACOM_REPORT_USB
)
3291 sync
= wacom_status_irq(wacom_wac
, len
);
3293 sync
= wacom_intuos_irq(wacom_wac
);
3299 sync
= wacom_intuos_pro2_bt_irq(wacom_wac
, len
);
3308 sync
= wacom_tpc_irq(wacom_wac
, len
);
3316 if (wacom_wac
->data
[0] == WACOM_REPORT_USB
)
3317 sync
= wacom_status_irq(wacom_wac
, len
);
3319 sync
= wacom_bpt_irq(wacom_wac
, len
);
3323 sync
= wacom_bamboo_pad_irq(wacom_wac
, len
);
3327 sync
= wacom_wireless_irq(wacom_wac
, len
);
3332 if (wacom_wac
->data
[0] == WACOM_REPORT_DEVICE_LIST
)
3333 wacom_remote_status_irq(wacom_wac
, len
);
3335 sync
= wacom_remote_irq(wacom_wac
, len
);
3344 if (wacom_wac
->pen_input
)
3345 input_sync(wacom_wac
->pen_input
);
3346 if (wacom_wac
->touch_input
)
3347 input_sync(wacom_wac
->touch_input
);
3348 if (wacom_wac
->pad_input
)
3349 input_sync(wacom_wac
->pad_input
);
3353 static void wacom_setup_basic_pro_pen(struct wacom_wac
*wacom_wac
)
3355 struct input_dev
*input_dev
= wacom_wac
->pen_input
;
3357 input_set_capability(input_dev
, EV_MSC
, MSC_SERIAL
);
3359 __set_bit(BTN_TOOL_PEN
, input_dev
->keybit
);
3360 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
3361 __set_bit(BTN_STYLUS2
, input_dev
->keybit
);
3363 input_set_abs_params(input_dev
, ABS_DISTANCE
,
3364 0, wacom_wac
->features
.distance_max
, wacom_wac
->features
.distance_fuzz
, 0);
3367 static void wacom_setup_cintiq(struct wacom_wac
*wacom_wac
)
3369 struct input_dev
*input_dev
= wacom_wac
->pen_input
;
3370 struct wacom_features
*features
= &wacom_wac
->features
;
3372 wacom_setup_basic_pro_pen(wacom_wac
);
3374 __set_bit(BTN_TOOL_RUBBER
, input_dev
->keybit
);
3375 __set_bit(BTN_TOOL_BRUSH
, input_dev
->keybit
);
3376 __set_bit(BTN_TOOL_PENCIL
, input_dev
->keybit
);
3377 __set_bit(BTN_TOOL_AIRBRUSH
, input_dev
->keybit
);
3379 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 1023, 0, 0);
3380 input_set_abs_params(input_dev
, ABS_TILT_X
, -64, 63, features
->tilt_fuzz
, 0);
3381 input_abs_set_res(input_dev
, ABS_TILT_X
, 57);
3382 input_set_abs_params(input_dev
, ABS_TILT_Y
, -64, 63, features
->tilt_fuzz
, 0);
3383 input_abs_set_res(input_dev
, ABS_TILT_Y
, 57);
3386 static void wacom_setup_intuos(struct wacom_wac
*wacom_wac
)
3388 struct input_dev
*input_dev
= wacom_wac
->pen_input
;
3390 input_set_capability(input_dev
, EV_REL
, REL_WHEEL
);
3392 wacom_setup_cintiq(wacom_wac
);
3394 __set_bit(BTN_LEFT
, input_dev
->keybit
);
3395 __set_bit(BTN_RIGHT
, input_dev
->keybit
);
3396 __set_bit(BTN_MIDDLE
, input_dev
->keybit
);
3397 __set_bit(BTN_SIDE
, input_dev
->keybit
);
3398 __set_bit(BTN_EXTRA
, input_dev
->keybit
);
3399 __set_bit(BTN_TOOL_MOUSE
, input_dev
->keybit
);
3400 __set_bit(BTN_TOOL_LENS
, input_dev
->keybit
);
3402 input_set_abs_params(input_dev
, ABS_RZ
, -900, 899, 0, 0);
3403 input_abs_set_res(input_dev
, ABS_RZ
, 287);
3404 input_set_abs_params(input_dev
, ABS_THROTTLE
, -1023, 1023, 0, 0);
3407 void wacom_setup_device_quirks(struct wacom
*wacom
)
3409 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
3410 struct wacom_features
*features
= &wacom
->wacom_wac
.features
;
3412 /* The pen and pad share the same interface on most devices */
3413 if (features
->type
== GRAPHIRE_BT
|| features
->type
== WACOM_G4
||
3414 features
->type
== DTUS
||
3415 (features
->type
>= INTUOS3S
&& features
->type
<= WACOM_MO
)) {
3416 if (features
->device_type
& WACOM_DEVICETYPE_PEN
)
3417 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
3420 /* touch device found but size is not defined. use default */
3421 if (features
->device_type
& WACOM_DEVICETYPE_TOUCH
&& !features
->x_max
) {
3422 features
->x_max
= 1023;
3423 features
->y_max
= 1023;
3427 * Intuos5/Pro and Bamboo 3rd gen have no useful data about its
3428 * touch interface in its HID descriptor. If this is the touch
3429 * interface (PacketSize of WACOM_PKGLEN_BBTOUCH3), override the
3432 if ((features
->type
>= INTUOS5S
&& features
->type
<= INTUOSPL
) ||
3433 (features
->type
>= INTUOSHT
&& features
->type
<= BAMBOO_PT
)) {
3434 if (features
->pktlen
== WACOM_PKGLEN_BBTOUCH3
) {
3435 if (features
->touch_max
)
3436 features
->device_type
|= WACOM_DEVICETYPE_TOUCH
;
3437 if (features
->type
>= INTUOSHT
&& features
->type
<= BAMBOO_PT
)
3438 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
3440 if (features
->type
== INTUOSHT2
) {
3441 features
->x_max
= features
->x_max
/ 10;
3442 features
->y_max
= features
->y_max
/ 10;
3445 features
->x_max
= 4096;
3446 features
->y_max
= 4096;
3449 else if (features
->pktlen
== WACOM_PKGLEN_BBTOUCH
) {
3450 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
3455 * Hack for the Bamboo One:
3456 * the device presents a PAD/Touch interface as most Bamboos and even
3457 * sends ghosts PAD data on it. However, later, we must disable this
3458 * ghost interface, and we can not detect it unless we set it here
3459 * to WACOM_DEVICETYPE_PAD or WACOM_DEVICETYPE_TOUCH.
3461 if (features
->type
== BAMBOO_PEN
&&
3462 features
->pktlen
== WACOM_PKGLEN_BBTOUCH3
)
3463 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
3466 * Raw Wacom-mode pen and touch events both come from interface
3467 * 0, whose HID descriptor has an application usage of 0xFF0D
3468 * (i.e., WACOM_HID_WD_DIGITIZER). We route pen packets back
3469 * out through the HID_GENERIC device created for interface 1,
3470 * so rewrite this one to be of type WACOM_DEVICETYPE_TOUCH.
3472 if (features
->type
== BAMBOO_PAD
)
3473 features
->device_type
= WACOM_DEVICETYPE_TOUCH
;
3475 if (features
->type
== REMOTE
)
3476 features
->device_type
= WACOM_DEVICETYPE_PAD
;
3478 if (features
->type
== INTUOSP2_BT
||
3479 features
->type
== INTUOSP2S_BT
) {
3480 features
->device_type
|= WACOM_DEVICETYPE_PEN
|
3481 WACOM_DEVICETYPE_PAD
|
3482 WACOM_DEVICETYPE_TOUCH
;
3483 features
->quirks
|= WACOM_QUIRK_BATTERY
;
3486 if (features
->type
== INTUOSHT3_BT
) {
3487 features
->device_type
|= WACOM_DEVICETYPE_PEN
|
3488 WACOM_DEVICETYPE_PAD
;
3489 features
->quirks
|= WACOM_QUIRK_BATTERY
;
3492 switch (features
->type
) {
3503 case CINTIQ_COMPANION_2
:
3515 features
->device_type
|= WACOM_DEVICETYPE_DIRECT
;
3519 if (wacom
->hdev
->bus
== BUS_BLUETOOTH
)
3520 features
->quirks
|= WACOM_QUIRK_BATTERY
;
3522 /* quirk for bamboo touch with 2 low res touches */
3523 if ((features
->type
== BAMBOO_PT
|| features
->type
== BAMBOO_TOUCH
) &&
3524 features
->pktlen
== WACOM_PKGLEN_BBTOUCH
) {
3525 features
->x_max
<<= 5;
3526 features
->y_max
<<= 5;
3527 features
->x_fuzz
<<= 5;
3528 features
->y_fuzz
<<= 5;
3529 features
->quirks
|= WACOM_QUIRK_BBTOUCH_LOWRES
;
3532 if (features
->type
== WIRELESS
) {
3533 if (features
->device_type
== WACOM_DEVICETYPE_WL_MONITOR
) {
3534 features
->quirks
|= WACOM_QUIRK_BATTERY
;
3538 if (features
->type
== REMOTE
)
3539 features
->device_type
|= WACOM_DEVICETYPE_WL_MONITOR
;
3541 /* HID descriptor for DTK-2451 / DTH-2452 claims to report lots
3542 * of things it shouldn't. Lets fix up the damage...
3544 if (wacom
->hdev
->product
== 0x382 || wacom
->hdev
->product
== 0x37d) {
3545 features
->quirks
&= ~WACOM_QUIRK_TOOLSERIAL
;
3546 __clear_bit(BTN_TOOL_BRUSH
, wacom_wac
->pen_input
->keybit
);
3547 __clear_bit(BTN_TOOL_PENCIL
, wacom_wac
->pen_input
->keybit
);
3548 __clear_bit(BTN_TOOL_AIRBRUSH
, wacom_wac
->pen_input
->keybit
);
3549 __clear_bit(ABS_Z
, wacom_wac
->pen_input
->absbit
);
3550 __clear_bit(ABS_DISTANCE
, wacom_wac
->pen_input
->absbit
);
3551 __clear_bit(ABS_TILT_X
, wacom_wac
->pen_input
->absbit
);
3552 __clear_bit(ABS_TILT_Y
, wacom_wac
->pen_input
->absbit
);
3553 __clear_bit(ABS_WHEEL
, wacom_wac
->pen_input
->absbit
);
3554 __clear_bit(ABS_MISC
, wacom_wac
->pen_input
->absbit
);
3555 __clear_bit(MSC_SERIAL
, wacom_wac
->pen_input
->mscbit
);
3556 __clear_bit(EV_MSC
, wacom_wac
->pen_input
->evbit
);
3560 int wacom_setup_pen_input_capabilities(struct input_dev
*input_dev
,
3561 struct wacom_wac
*wacom_wac
)
3563 struct wacom_features
*features
= &wacom_wac
->features
;
3565 input_dev
->evbit
[0] |= BIT_MASK(EV_KEY
) | BIT_MASK(EV_ABS
);
3567 if (!(features
->device_type
& WACOM_DEVICETYPE_PEN
))
3570 if (features
->device_type
& WACOM_DEVICETYPE_DIRECT
)
3571 __set_bit(INPUT_PROP_DIRECT
, input_dev
->propbit
);
3573 __set_bit(INPUT_PROP_POINTER
, input_dev
->propbit
);
3575 if (features
->type
== HID_GENERIC
) {
3576 /* setup has already been done; apply otherwise-undetectible quirks */
3577 input_set_capability(input_dev
, EV_KEY
, BTN_STYLUS3
);
3581 __set_bit(BTN_TOUCH
, input_dev
->keybit
);
3582 __set_bit(ABS_MISC
, input_dev
->absbit
);
3584 input_set_abs_params(input_dev
, ABS_X
, 0 + features
->offset_left
,
3585 features
->x_max
- features
->offset_right
,
3586 features
->x_fuzz
, 0);
3587 input_set_abs_params(input_dev
, ABS_Y
, 0 + features
->offset_top
,
3588 features
->y_max
- features
->offset_bottom
,
3589 features
->y_fuzz
, 0);
3590 input_set_abs_params(input_dev
, ABS_PRESSURE
, 0,
3591 features
->pressure_max
, features
->pressure_fuzz
, 0);
3593 /* penabled devices have fixed resolution for each model */
3594 input_abs_set_res(input_dev
, ABS_X
, features
->x_resolution
);
3595 input_abs_set_res(input_dev
, ABS_Y
, features
->y_resolution
);
3597 switch (features
->type
) {
3599 __clear_bit(ABS_MISC
, input_dev
->absbit
);
3604 input_set_abs_params(input_dev
, ABS_DISTANCE
, 0,
3605 features
->distance_max
,
3606 features
->distance_fuzz
, 0);
3610 input_set_capability(input_dev
, EV_REL
, REL_WHEEL
);
3612 __set_bit(BTN_LEFT
, input_dev
->keybit
);
3613 __set_bit(BTN_RIGHT
, input_dev
->keybit
);
3614 __set_bit(BTN_MIDDLE
, input_dev
->keybit
);
3616 __set_bit(BTN_TOOL_RUBBER
, input_dev
->keybit
);
3617 __set_bit(BTN_TOOL_PEN
, input_dev
->keybit
);
3618 __set_bit(BTN_TOOL_MOUSE
, input_dev
->keybit
);
3619 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
3620 __set_bit(BTN_STYLUS2
, input_dev
->keybit
);
3632 case CINTIQ_COMPANION_2
:
3633 input_set_abs_params(input_dev
, ABS_Z
, -900, 899, 0, 0);
3634 input_abs_set_res(input_dev
, ABS_Z
, 287);
3635 wacom_setup_cintiq(wacom_wac
);
3645 input_set_abs_params(input_dev
, ABS_Z
, -900, 899, 0, 0);
3646 input_abs_set_res(input_dev
, ABS_Z
, 287);
3650 wacom_setup_intuos(wacom_wac
);
3661 input_set_abs_params(input_dev
, ABS_DISTANCE
, 0,
3662 features
->distance_max
,
3663 features
->distance_fuzz
, 0);
3665 input_set_abs_params(input_dev
, ABS_Z
, -900, 899, 0, 0);
3666 input_abs_set_res(input_dev
, ABS_Z
, 287);
3668 wacom_setup_intuos(wacom_wac
);
3679 __clear_bit(ABS_MISC
, input_dev
->absbit
);
3686 __set_bit(BTN_TOOL_PEN
, input_dev
->keybit
);
3687 __set_bit(BTN_TOOL_RUBBER
, input_dev
->keybit
);
3688 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
3689 __set_bit(BTN_STYLUS2
, input_dev
->keybit
);
3693 __set_bit(BTN_STYLUS2
, input_dev
->keybit
);
3697 __set_bit(BTN_TOOL_PEN
, input_dev
->keybit
);
3698 __set_bit(BTN_TOOL_RUBBER
, input_dev
->keybit
);
3699 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
3707 if (features
->type
== INTUOSHT2
||
3708 features
->type
== INTUOSHT3_BT
) {
3709 wacom_setup_basic_pro_pen(wacom_wac
);
3711 __clear_bit(ABS_MISC
, input_dev
->absbit
);
3712 __set_bit(BTN_TOOL_PEN
, input_dev
->keybit
);
3713 __set_bit(BTN_TOOL_RUBBER
, input_dev
->keybit
);
3714 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
3715 __set_bit(BTN_STYLUS2
, input_dev
->keybit
);
3716 input_set_abs_params(input_dev
, ABS_DISTANCE
, 0,
3717 features
->distance_max
,
3718 features
->distance_fuzz
, 0);
3722 __clear_bit(ABS_MISC
, input_dev
->absbit
);
3728 int wacom_setup_touch_input_capabilities(struct input_dev
*input_dev
,
3729 struct wacom_wac
*wacom_wac
)
3731 struct wacom_features
*features
= &wacom_wac
->features
;
3733 input_dev
->evbit
[0] |= BIT_MASK(EV_KEY
) | BIT_MASK(EV_ABS
);
3735 if (!(features
->device_type
& WACOM_DEVICETYPE_TOUCH
))
3738 if (features
->device_type
& WACOM_DEVICETYPE_DIRECT
)
3739 __set_bit(INPUT_PROP_DIRECT
, input_dev
->propbit
);
3741 __set_bit(INPUT_PROP_POINTER
, input_dev
->propbit
);
3743 if (features
->type
== HID_GENERIC
)
3744 /* setup has already been done */
3747 __set_bit(BTN_TOUCH
, input_dev
->keybit
);
3749 if (features
->touch_max
== 1) {
3750 input_set_abs_params(input_dev
, ABS_X
, 0,
3751 features
->x_max
, features
->x_fuzz
, 0);
3752 input_set_abs_params(input_dev
, ABS_Y
, 0,
3753 features
->y_max
, features
->y_fuzz
, 0);
3754 input_abs_set_res(input_dev
, ABS_X
,
3755 features
->x_resolution
);
3756 input_abs_set_res(input_dev
, ABS_Y
,
3757 features
->y_resolution
);
3759 else if (features
->touch_max
> 1) {
3760 input_set_abs_params(input_dev
, ABS_MT_POSITION_X
, 0,
3761 features
->x_max
, features
->x_fuzz
, 0);
3762 input_set_abs_params(input_dev
, ABS_MT_POSITION_Y
, 0,
3763 features
->y_max
, features
->y_fuzz
, 0);
3764 input_abs_set_res(input_dev
, ABS_MT_POSITION_X
,
3765 features
->x_resolution
);
3766 input_abs_set_res(input_dev
, ABS_MT_POSITION_Y
,
3767 features
->y_resolution
);
3770 switch (features
->type
) {
3773 input_dev
->evbit
[0] |= BIT_MASK(EV_SW
);
3774 __set_bit(SW_MUTE_DEVICE
, input_dev
->swbit
);
3776 if (wacom_wac
->shared
->touch
->product
== 0x361) {
3777 input_set_abs_params(input_dev
, ABS_MT_POSITION_X
,
3779 input_set_abs_params(input_dev
, ABS_MT_POSITION_Y
,
3782 else if (wacom_wac
->shared
->touch
->product
== 0x360) {
3783 input_set_abs_params(input_dev
, ABS_MT_POSITION_X
,
3785 input_set_abs_params(input_dev
, ABS_MT_POSITION_Y
,
3788 else if (wacom_wac
->shared
->touch
->product
== 0x393) {
3789 input_set_abs_params(input_dev
, ABS_MT_POSITION_X
,
3791 input_set_abs_params(input_dev
, ABS_MT_POSITION_Y
,
3794 input_abs_set_res(input_dev
, ABS_MT_POSITION_X
, 40);
3795 input_abs_set_res(input_dev
, ABS_MT_POSITION_Y
, 40);
3805 input_set_abs_params(input_dev
, ABS_MT_TOUCH_MAJOR
, 0, features
->x_max
, 0, 0);
3806 input_set_abs_params(input_dev
, ABS_MT_TOUCH_MINOR
, 0, features
->y_max
, 0, 0);
3807 input_mt_init_slots(input_dev
, features
->touch_max
, INPUT_MT_POINTER
);
3811 input_set_abs_params(input_dev
, ABS_MT_TOUCH_MAJOR
, 0, features
->x_max
, 0, 0);
3812 input_set_abs_params(input_dev
, ABS_MT_WIDTH_MAJOR
, 0, features
->x_max
, 0, 0);
3813 input_set_abs_params(input_dev
, ABS_MT_WIDTH_MINOR
, 0, features
->y_max
, 0, 0);
3814 input_set_abs_params(input_dev
, ABS_MT_ORIENTATION
, 0, 1, 0, 0);
3822 input_mt_init_slots(input_dev
, features
->touch_max
, INPUT_MT_DIRECT
);
3831 input_dev
->evbit
[0] |= BIT_MASK(EV_SW
);
3832 __set_bit(SW_MUTE_DEVICE
, input_dev
->swbit
);
3837 if (features
->pktlen
== WACOM_PKGLEN_BBTOUCH3
) {
3838 input_set_abs_params(input_dev
,
3840 0, features
->x_max
, 0, 0);
3841 input_set_abs_params(input_dev
,
3843 0, features
->y_max
, 0, 0);
3845 input_mt_init_slots(input_dev
, features
->touch_max
, INPUT_MT_POINTER
);
3849 input_mt_init_slots(input_dev
, features
->touch_max
,
3851 __set_bit(BTN_LEFT
, input_dev
->keybit
);
3852 __set_bit(BTN_RIGHT
, input_dev
->keybit
);
3858 static int wacom_numbered_button_to_key(int n
)
3863 return BTN_A
+ (n
-10);
3865 return BTN_BASE
+ (n
-16);
3870 static void wacom_setup_numbered_buttons(struct input_dev
*input_dev
,
3875 for (i
= 0; i
< button_count
; i
++) {
3876 int key
= wacom_numbered_button_to_key(i
);
3879 __set_bit(key
, input_dev
->keybit
);
3883 static void wacom_24hd_update_leds(struct wacom
*wacom
, int mask
, int group
)
3885 struct wacom_led
*led
;
3887 bool updated
= false;
3890 * 24HD has LED group 1 to the left and LED group 0 to the right.
3891 * So group 0 matches the second half of the buttons and thus the mask
3892 * needs to be shifted.
3897 for (i
= 0; i
< 3; i
++) {
3898 led
= wacom_led_find(wacom
, group
, i
);
3900 hid_err(wacom
->hdev
, "can't find LED %d in group %d\n",
3904 if (!updated
&& mask
& BIT(i
)) {
3906 led_trigger_event(&led
->trigger
, LED_FULL
);
3913 static bool wacom_is_led_toggled(struct wacom
*wacom
, int button_count
,
3914 int mask
, int group
)
3919 * 21UX2 has LED group 1 to the left and LED group 0
3920 * to the right. We need to reverse the group to match this
3921 * historical behavior.
3923 if (wacom
->wacom_wac
.features
.type
== WACOM_21UX2
)
3926 group_button
= group
* (button_count
/wacom
->led
.count
);
3928 if (wacom
->wacom_wac
.features
.type
== INTUOSP2_BT
)
3931 return mask
& (1 << group_button
);
3934 static void wacom_update_led(struct wacom
*wacom
, int button_count
, int mask
,
3937 struct wacom_led
*led
, *next_led
;
3941 if (wacom
->wacom_wac
.features
.type
== WACOM_24HD
)
3942 return wacom_24hd_update_leds(wacom
, mask
, group
);
3944 pressed
= wacom_is_led_toggled(wacom
, button_count
, mask
, group
);
3945 cur
= wacom
->led
.groups
[group
].select
;
3947 led
= wacom_led_find(wacom
, group
, cur
);
3949 hid_err(wacom
->hdev
, "can't find current LED %d in group %d\n",
3959 if (led
->held
&& pressed
)
3962 next_led
= wacom_led_next(wacom
, led
);
3964 hid_err(wacom
->hdev
, "can't find next LED in group %d\n",
3968 if (next_led
== led
)
3971 next_led
->held
= true;
3972 led_trigger_event(&next_led
->trigger
,
3973 wacom_leds_brightness_get(next_led
));
3976 static void wacom_report_numbered_buttons(struct input_dev
*input_dev
,
3977 int button_count
, int mask
)
3979 struct wacom
*wacom
= input_get_drvdata(input_dev
);
3982 for (i
= 0; i
< wacom
->led
.count
; i
++)
3983 wacom_update_led(wacom
, button_count
, mask
, i
);
3985 for (i
= 0; i
< button_count
; i
++) {
3986 int key
= wacom_numbered_button_to_key(i
);
3989 input_report_key(input_dev
, key
, mask
& (1 << i
));
3993 int wacom_setup_pad_input_capabilities(struct input_dev
*input_dev
,
3994 struct wacom_wac
*wacom_wac
)
3996 struct wacom_features
*features
= &wacom_wac
->features
;
3998 if ((features
->type
== HID_GENERIC
) && features
->numbered_buttons
> 0)
3999 features
->device_type
|= WACOM_DEVICETYPE_PAD
;
4001 if (!(features
->device_type
& WACOM_DEVICETYPE_PAD
))
4004 if (features
->type
== REMOTE
&& input_dev
== wacom_wac
->pad_input
)
4007 input_dev
->evbit
[0] |= BIT_MASK(EV_KEY
) | BIT_MASK(EV_ABS
);
4009 /* kept for making legacy xf86-input-wacom working with the wheels */
4010 __set_bit(ABS_MISC
, input_dev
->absbit
);
4012 /* kept for making legacy xf86-input-wacom accepting the pad */
4013 if (!(input_dev
->absinfo
&& (input_dev
->absinfo
[ABS_X
].minimum
||
4014 input_dev
->absinfo
[ABS_X
].maximum
)))
4015 input_set_abs_params(input_dev
, ABS_X
, 0, 1, 0, 0);
4016 if (!(input_dev
->absinfo
&& (input_dev
->absinfo
[ABS_Y
].minimum
||
4017 input_dev
->absinfo
[ABS_Y
].maximum
)))
4018 input_set_abs_params(input_dev
, ABS_Y
, 0, 1, 0, 0);
4020 /* kept for making udev and libwacom accepting the pad */
4021 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
4023 wacom_setup_numbered_buttons(input_dev
, features
->numbered_buttons
);
4025 switch (features
->type
) {
4028 case CINTIQ_COMPANION_2
:
4035 __set_bit(BTN_BACK
, input_dev
->keybit
);
4036 __set_bit(BTN_LEFT
, input_dev
->keybit
);
4037 __set_bit(BTN_FORWARD
, input_dev
->keybit
);
4038 __set_bit(BTN_RIGHT
, input_dev
->keybit
);
4039 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
4043 __set_bit(BTN_BACK
, input_dev
->keybit
);
4044 __set_bit(BTN_FORWARD
, input_dev
->keybit
);
4045 input_set_capability(input_dev
, EV_REL
, REL_WHEEL
);
4049 __set_bit(KEY_PROG1
, input_dev
->keybit
);
4050 __set_bit(KEY_PROG2
, input_dev
->keybit
);
4051 __set_bit(KEY_PROG3
, input_dev
->keybit
);
4053 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
4054 input_set_abs_params(input_dev
, ABS_THROTTLE
, 0, 71, 0, 0);
4058 __set_bit(KEY_PROG1
, input_dev
->keybit
);
4059 __set_bit(KEY_PROG2
, input_dev
->keybit
);
4060 __set_bit(KEY_PROG3
, input_dev
->keybit
);
4061 input_set_abs_params(input_dev
, ABS_X
, -2048, 2048, 0, 0);
4062 input_abs_set_res(input_dev
, ABS_X
, 1024); /* points/g */
4063 input_set_abs_params(input_dev
, ABS_Y
, -2048, 2048, 0, 0);
4064 input_abs_set_res(input_dev
, ABS_Y
, 1024);
4065 input_set_abs_params(input_dev
, ABS_Z
, -2048, 2048, 0, 0);
4066 input_abs_set_res(input_dev
, ABS_Z
, 1024);
4067 __set_bit(INPUT_PROP_ACCELEROMETER
, input_dev
->propbit
);
4071 __set_bit(KEY_PROG1
, input_dev
->keybit
);
4072 __set_bit(KEY_PROG2
, input_dev
->keybit
);
4073 __set_bit(KEY_PROG3
, input_dev
->keybit
);
4079 input_set_abs_params(input_dev
, ABS_RX
, 0, 4096, 0, 0);
4080 input_set_abs_params(input_dev
, ABS_RY
, 0, 4096, 0, 0);
4084 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
4089 input_set_abs_params(input_dev
, ABS_RY
, 0, 4096, 0, 0);
4093 input_set_abs_params(input_dev
, ABS_RX
, 0, 4096, 0, 0);
4104 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
4109 * For Bluetooth devices, the udev rule does not work correctly
4110 * for pads unless we add a stylus capability, which forces
4111 * ID_INPUT_TABLET to be set.
4113 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
4119 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
4126 __clear_bit(ABS_MISC
, input_dev
->absbit
);
4128 __set_bit(BTN_LEFT
, input_dev
->keybit
);
4129 __set_bit(BTN_FORWARD
, input_dev
->keybit
);
4130 __set_bit(BTN_BACK
, input_dev
->keybit
);
4131 __set_bit(BTN_RIGHT
, input_dev
->keybit
);
4136 input_set_capability(input_dev
, EV_MSC
, MSC_SERIAL
);
4137 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
4145 /* no pad supported */
4151 static const struct wacom_features wacom_features_0x00
=
4152 { "Wacom Penpartner", 5040, 3780, 255, 0,
4153 PENPARTNER
, WACOM_PENPRTN_RES
, WACOM_PENPRTN_RES
};
4154 static const struct wacom_features wacom_features_0x10
=
4155 { "Wacom Graphire", 10206, 7422, 511, 63,
4156 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
4157 static const struct wacom_features wacom_features_0x81
=
4158 { "Wacom Graphire BT", 16704, 12064, 511, 32,
4159 GRAPHIRE_BT
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
, 2 };
4160 static const struct wacom_features wacom_features_0x11
=
4161 { "Wacom Graphire2 4x5", 10206, 7422, 511, 63,
4162 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
4163 static const struct wacom_features wacom_features_0x12
=
4164 { "Wacom Graphire2 5x7", 13918, 10206, 511, 63,
4165 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
4166 static const struct wacom_features wacom_features_0x13
=
4167 { "Wacom Graphire3", 10208, 7424, 511, 63,
4168 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
4169 static const struct wacom_features wacom_features_0x14
=
4170 { "Wacom Graphire3 6x8", 16704, 12064, 511, 63,
4171 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
4172 static const struct wacom_features wacom_features_0x15
=
4173 { "Wacom Graphire4 4x5", 10208, 7424, 511, 63,
4174 WACOM_G4
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
4175 static const struct wacom_features wacom_features_0x16
=
4176 { "Wacom Graphire4 6x8", 16704, 12064, 511, 63,
4177 WACOM_G4
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
4178 static const struct wacom_features wacom_features_0x17
=
4179 { "Wacom BambooFun 4x5", 14760, 9225, 511, 63,
4180 WACOM_MO
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4181 static const struct wacom_features wacom_features_0x18
=
4182 { "Wacom BambooFun 6x8", 21648, 13530, 511, 63,
4183 WACOM_MO
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4184 static const struct wacom_features wacom_features_0x19
=
4185 { "Wacom Bamboo1 Medium", 16704, 12064, 511, 63,
4186 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
4187 static const struct wacom_features wacom_features_0x60
=
4188 { "Wacom Volito", 5104, 3712, 511, 63,
4189 GRAPHIRE
, WACOM_VOLITO_RES
, WACOM_VOLITO_RES
};
4190 static const struct wacom_features wacom_features_0x61
=
4191 { "Wacom PenStation2", 3250, 2320, 255, 63,
4192 GRAPHIRE
, WACOM_VOLITO_RES
, WACOM_VOLITO_RES
};
4193 static const struct wacom_features wacom_features_0x62
=
4194 { "Wacom Volito2 4x5", 5104, 3712, 511, 63,
4195 GRAPHIRE
, WACOM_VOLITO_RES
, WACOM_VOLITO_RES
};
4196 static const struct wacom_features wacom_features_0x63
=
4197 { "Wacom Volito2 2x3", 3248, 2320, 511, 63,
4198 GRAPHIRE
, WACOM_VOLITO_RES
, WACOM_VOLITO_RES
};
4199 static const struct wacom_features wacom_features_0x64
=
4200 { "Wacom PenPartner2", 3250, 2320, 511, 63,
4201 GRAPHIRE
, WACOM_VOLITO_RES
, WACOM_VOLITO_RES
};
4202 static const struct wacom_features wacom_features_0x65
=
4203 { "Wacom Bamboo", 14760, 9225, 511, 63,
4204 WACOM_MO
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4205 static const struct wacom_features wacom_features_0x69
=
4206 { "Wacom Bamboo1", 5104, 3712, 511, 63,
4207 GRAPHIRE
, WACOM_PENPRTN_RES
, WACOM_PENPRTN_RES
};
4208 static const struct wacom_features wacom_features_0x6A
=
4209 { "Wacom Bamboo1 4x6", 14760, 9225, 1023, 63,
4210 GRAPHIRE
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4211 static const struct wacom_features wacom_features_0x6B
=
4212 { "Wacom Bamboo1 5x8", 21648, 13530, 1023, 63,
4213 GRAPHIRE
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4214 static const struct wacom_features wacom_features_0x20
=
4215 { "Wacom Intuos 4x5", 12700, 10600, 1023, 31,
4216 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4217 static const struct wacom_features wacom_features_0x21
=
4218 { "Wacom Intuos 6x8", 20320, 16240, 1023, 31,
4219 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4220 static const struct wacom_features wacom_features_0x22
=
4221 { "Wacom Intuos 9x12", 30480, 24060, 1023, 31,
4222 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4223 static const struct wacom_features wacom_features_0x23
=
4224 { "Wacom Intuos 12x12", 30480, 31680, 1023, 31,
4225 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4226 static const struct wacom_features wacom_features_0x24
=
4227 { "Wacom Intuos 12x18", 45720, 31680, 1023, 31,
4228 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4229 static const struct wacom_features wacom_features_0x30
=
4230 { "Wacom PL400", 5408, 4056, 255, 0,
4231 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
4232 static const struct wacom_features wacom_features_0x31
=
4233 { "Wacom PL500", 6144, 4608, 255, 0,
4234 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
4235 static const struct wacom_features wacom_features_0x32
=
4236 { "Wacom PL600", 6126, 4604, 255, 0,
4237 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
4238 static const struct wacom_features wacom_features_0x33
=
4239 { "Wacom PL600SX", 6260, 5016, 255, 0,
4240 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
4241 static const struct wacom_features wacom_features_0x34
=
4242 { "Wacom PL550", 6144, 4608, 511, 0,
4243 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
4244 static const struct wacom_features wacom_features_0x35
=
4245 { "Wacom PL800", 7220, 5780, 511, 0,
4246 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
4247 static const struct wacom_features wacom_features_0x37
=
4248 { "Wacom PL700", 6758, 5406, 511, 0,
4249 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
4250 static const struct wacom_features wacom_features_0x38
=
4251 { "Wacom PL510", 6282, 4762, 511, 0,
4252 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
4253 static const struct wacom_features wacom_features_0x39
=
4254 { "Wacom DTU710", 34080, 27660, 511, 0,
4255 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
4256 static const struct wacom_features wacom_features_0xC4
=
4257 { "Wacom DTF521", 6282, 4762, 511, 0,
4258 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
4259 static const struct wacom_features wacom_features_0xC0
=
4260 { "Wacom DTF720", 6858, 5506, 511, 0,
4261 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
4262 static const struct wacom_features wacom_features_0xC2
=
4263 { "Wacom DTF720a", 6858, 5506, 511, 0,
4264 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
4265 static const struct wacom_features wacom_features_0x03
=
4266 { "Wacom Cintiq Partner", 20480, 15360, 511, 0,
4267 PTU
, WACOM_PL_RES
, WACOM_PL_RES
};
4268 static const struct wacom_features wacom_features_0x41
=
4269 { "Wacom Intuos2 4x5", 12700, 10600, 1023, 31,
4270 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4271 static const struct wacom_features wacom_features_0x42
=
4272 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
4273 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4274 static const struct wacom_features wacom_features_0x43
=
4275 { "Wacom Intuos2 9x12", 30480, 24060, 1023, 31,
4276 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4277 static const struct wacom_features wacom_features_0x44
=
4278 { "Wacom Intuos2 12x12", 30480, 31680, 1023, 31,
4279 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4280 static const struct wacom_features wacom_features_0x45
=
4281 { "Wacom Intuos2 12x18", 45720, 31680, 1023, 31,
4282 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4283 static const struct wacom_features wacom_features_0xB0
=
4284 { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63,
4285 INTUOS3S
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 4 };
4286 static const struct wacom_features wacom_features_0xB1
=
4287 { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63,
4288 INTUOS3
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 8 };
4289 static const struct wacom_features wacom_features_0xB2
=
4290 { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63,
4291 INTUOS3
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 8 };
4292 static const struct wacom_features wacom_features_0xB3
=
4293 { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63,
4294 INTUOS3L
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 8 };
4295 static const struct wacom_features wacom_features_0xB4
=
4296 { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63,
4297 INTUOS3L
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 8 };
4298 static const struct wacom_features wacom_features_0xB5
=
4299 { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63,
4300 INTUOS3
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 8 };
4301 static const struct wacom_features wacom_features_0xB7
=
4302 { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63,
4303 INTUOS3S
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 4 };
4304 static const struct wacom_features wacom_features_0xB8
=
4305 { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63,
4306 INTUOS4S
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 7 };
4307 static const struct wacom_features wacom_features_0xB9
=
4308 { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63,
4309 INTUOS4
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9 };
4310 static const struct wacom_features wacom_features_0xBA
=
4311 { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63,
4312 INTUOS4L
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9 };
4313 static const struct wacom_features wacom_features_0xBB
=
4314 { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63,
4315 INTUOS4L
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9 };
4316 static const struct wacom_features wacom_features_0xBC
=
4317 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
4318 INTUOS4
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9 };
4319 static const struct wacom_features wacom_features_0xBD
=
4320 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
4321 INTUOS4WL
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9 };
4322 static const struct wacom_features wacom_features_0x26
=
4323 { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63,
4324 INTUOS5S
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 7, .touch_max
= 16 };
4325 static const struct wacom_features wacom_features_0x27
=
4326 { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63,
4327 INTUOS5
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9, .touch_max
= 16 };
4328 static const struct wacom_features wacom_features_0x28
=
4329 { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63,
4330 INTUOS5L
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9, .touch_max
= 16 };
4331 static const struct wacom_features wacom_features_0x29
=
4332 { "Wacom Intuos5 S", 31496, 19685, 2047, 63,
4333 INTUOS5S
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 7 };
4334 static const struct wacom_features wacom_features_0x2A
=
4335 { "Wacom Intuos5 M", 44704, 27940, 2047, 63,
4336 INTUOS5
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9 };
4337 static const struct wacom_features wacom_features_0x314
=
4338 { "Wacom Intuos Pro S", 31496, 19685, 2047, 63,
4339 INTUOSPS
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 7, .touch_max
= 16,
4340 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4341 static const struct wacom_features wacom_features_0x315
=
4342 { "Wacom Intuos Pro M", 44704, 27940, 2047, 63,
4343 INTUOSPM
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9, .touch_max
= 16,
4344 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4345 static const struct wacom_features wacom_features_0x317
=
4346 { "Wacom Intuos Pro L", 65024, 40640, 2047, 63,
4347 INTUOSPL
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9, .touch_max
= 16,
4348 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4349 static const struct wacom_features wacom_features_0xF4
=
4350 { "Wacom Cintiq 24HD", 104480, 65600, 2047, 63,
4351 WACOM_24HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 16,
4352 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4353 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
4354 static const struct wacom_features wacom_features_0xF8
=
4355 { "Wacom Cintiq 24HD touch", 104480, 65600, 2047, 63, /* Pen */
4356 WACOM_24HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 16,
4357 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4358 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4359 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0xf6 };
4360 static const struct wacom_features wacom_features_0xF6
=
4361 { "Wacom Cintiq 24HD touch", .type
= WACOM_24HDT
, /* Touch */
4362 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0xf8, .touch_max
= 10,
4363 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4364 static const struct wacom_features wacom_features_0x32A
=
4365 { "Wacom Cintiq 27QHD", 120140, 67920, 2047, 63,
4366 WACOM_27QHD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 0,
4367 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4368 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
4369 static const struct wacom_features wacom_features_0x32B
=
4370 { "Wacom Cintiq 27QHD touch", 120140, 67920, 2047, 63,
4371 WACOM_27QHD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 0,
4372 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4373 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4374 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x32C };
4375 static const struct wacom_features wacom_features_0x32C
=
4376 { "Wacom Cintiq 27QHD touch", .type
= WACOM_27QHDT
,
4377 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x32B, .touch_max
= 10 };
4378 static const struct wacom_features wacom_features_0x3F
=
4379 { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63,
4380 CINTIQ
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 8 };
4381 static const struct wacom_features wacom_features_0xC5
=
4382 { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63,
4383 WACOM_BEE
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 10 };
4384 static const struct wacom_features wacom_features_0xC6
=
4385 { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63,
4386 WACOM_BEE
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 10 };
4387 static const struct wacom_features wacom_features_0x304
=
4388 { "Wacom Cintiq 13HD", 59552, 33848, 1023, 63,
4389 WACOM_13HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9,
4390 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4391 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
4392 static const struct wacom_features wacom_features_0x333
=
4393 { "Wacom Cintiq 13HD touch", 59552, 33848, 2047, 63,
4394 WACOM_13HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9,
4395 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4396 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4397 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x335 };
4398 static const struct wacom_features wacom_features_0x335
=
4399 { "Wacom Cintiq 13HD touch", .type
= WACOM_24HDT
, /* Touch */
4400 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x333, .touch_max
= 10,
4401 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4402 static const struct wacom_features wacom_features_0xC7
=
4403 { "Wacom DTU1931", 37832, 30305, 511, 0,
4404 PL
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4405 static const struct wacom_features wacom_features_0xCE
=
4406 { "Wacom DTU2231", 47864, 27011, 511, 0,
4407 DTU
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
,
4408 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBMOUSE
};
4409 static const struct wacom_features wacom_features_0xF0
=
4410 { "Wacom DTU1631", 34623, 19553, 511, 0,
4411 DTU
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4412 static const struct wacom_features wacom_features_0xFB
=
4413 { "Wacom DTU1031", 22096, 13960, 511, 0,
4414 DTUS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, 4,
4415 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
,
4416 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
};
4417 static const struct wacom_features wacom_features_0x32F
=
4418 { "Wacom DTU1031X", 22672, 12928, 511, 0,
4419 DTUSX
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, 0,
4420 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
,
4421 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
};
4422 static const struct wacom_features wacom_features_0x336
=
4423 { "Wacom DTU1141", 23672, 13403, 1023, 0,
4424 DTUS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, 4,
4425 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
,
4426 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
};
4427 static const struct wacom_features wacom_features_0x57
=
4428 { "Wacom DTK2241", 95840, 54260, 2047, 63,
4429 DTK
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 6,
4430 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4431 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
4432 static const struct wacom_features wacom_features_0x59
= /* Pen */
4433 { "Wacom DTH2242", 95840, 54260, 2047, 63,
4434 DTK
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 6,
4435 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4436 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4437 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x5D };
4438 static const struct wacom_features wacom_features_0x5D
= /* Touch */
4439 { "Wacom DTH2242", .type
= WACOM_24HDT
,
4440 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x59, .touch_max
= 10,
4441 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4442 static const struct wacom_features wacom_features_0xCC
=
4443 { "Wacom Cintiq 21UX2", 87200, 65600, 2047, 63,
4444 WACOM_21UX2
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 18,
4445 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4446 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
4447 static const struct wacom_features wacom_features_0xFA
=
4448 { "Wacom Cintiq 22HD", 95840, 54260, 2047, 63,
4449 WACOM_22HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 18,
4450 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4451 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
4452 static const struct wacom_features wacom_features_0x5B
=
4453 { "Wacom Cintiq 22HDT", 95840, 54260, 2047, 63,
4454 WACOM_22HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 18,
4455 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4456 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4457 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x5e };
4458 static const struct wacom_features wacom_features_0x5E
=
4459 { "Wacom Cintiq 22HDT", .type
= WACOM_24HDT
,
4460 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x5b, .touch_max
= 10,
4461 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4462 static const struct wacom_features wacom_features_0x90
=
4463 { "Wacom ISDv4 90", 26202, 16325, 255, 0,
4464 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
}; /* Pen-only */
4465 static const struct wacom_features wacom_features_0x93
=
4466 { "Wacom ISDv4 93", 26202, 16325, 255, 0,
4467 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 1 };
4468 static const struct wacom_features wacom_features_0x97
=
4469 { "Wacom ISDv4 97", 26202, 16325, 511, 0,
4470 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
}; /* Pen-only */
4471 static const struct wacom_features wacom_features_0x9A
=
4472 { "Wacom ISDv4 9A", 26202, 16325, 255, 0,
4473 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 1 };
4474 static const struct wacom_features wacom_features_0x9F
=
4475 { "Wacom ISDv4 9F", 26202, 16325, 255, 0,
4476 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 1 };
4477 static const struct wacom_features wacom_features_0xE2
=
4478 { "Wacom ISDv4 E2", 26202, 16325, 255, 0,
4479 TABLETPC2FG
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
4480 static const struct wacom_features wacom_features_0xE3
=
4481 { "Wacom ISDv4 E3", 26202, 16325, 255, 0,
4482 TABLETPC2FG
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
4483 static const struct wacom_features wacom_features_0xE5
=
4484 { "Wacom ISDv4 E5", 26202, 16325, 255, 0,
4485 MTSCREEN
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4486 static const struct wacom_features wacom_features_0xE6
=
4487 { "Wacom ISDv4 E6", 27760, 15694, 255, 0,
4488 TABLETPC2FG
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
4489 static const struct wacom_features wacom_features_0xEC
=
4490 { "Wacom ISDv4 EC", 25710, 14500, 255, 0,
4491 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
}; /* Pen-only */
4492 static const struct wacom_features wacom_features_0xED
=
4493 { "Wacom ISDv4 ED", 26202, 16325, 255, 0,
4494 TABLETPCE
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 1 };
4495 static const struct wacom_features wacom_features_0xEF
=
4496 { "Wacom ISDv4 EF", 26202, 16325, 255, 0,
4497 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
}; /* Pen-only */
4498 static const struct wacom_features wacom_features_0x100
=
4499 { "Wacom ISDv4 100", 26202, 16325, 255, 0,
4500 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4501 static const struct wacom_features wacom_features_0x101
=
4502 { "Wacom ISDv4 101", 26202, 16325, 255, 0,
4503 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4504 static const struct wacom_features wacom_features_0x10D
=
4505 { "Wacom ISDv4 10D", 26202, 16325, 255, 0,
4506 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4507 static const struct wacom_features wacom_features_0x10E
=
4508 { "Wacom ISDv4 10E", 27760, 15694, 255, 0,
4509 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4510 static const struct wacom_features wacom_features_0x10F
=
4511 { "Wacom ISDv4 10F", 27760, 15694, 255, 0,
4512 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4513 static const struct wacom_features wacom_features_0x116
=
4514 { "Wacom ISDv4 116", 26202, 16325, 255, 0,
4515 TABLETPCE
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 1 };
4516 static const struct wacom_features wacom_features_0x12C
=
4517 { "Wacom ISDv4 12C", 27848, 15752, 2047, 0,
4518 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
}; /* Pen-only */
4519 static const struct wacom_features wacom_features_0x4001
=
4520 { "Wacom ISDv4 4001", 26202, 16325, 255, 0,
4521 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4522 static const struct wacom_features wacom_features_0x4004
=
4523 { "Wacom ISDv4 4004", 11060, 6220, 255, 0,
4524 MTTPC_B
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4525 static const struct wacom_features wacom_features_0x5000
=
4526 { "Wacom ISDv4 5000", 27848, 15752, 1023, 0,
4527 MTTPC_B
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4528 static const struct wacom_features wacom_features_0x5002
=
4529 { "Wacom ISDv4 5002", 29576, 16724, 1023, 0,
4530 MTTPC_B
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4531 static const struct wacom_features wacom_features_0x47
=
4532 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
4533 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4534 static const struct wacom_features wacom_features_0x84
=
4535 { "Wacom Wireless Receiver", .type
= WIRELESS
, .touch_max
= 16 };
4536 static const struct wacom_features wacom_features_0xD0
=
4537 { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31,
4538 BAMBOO_TOUCH
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
4539 static const struct wacom_features wacom_features_0xD1
=
4540 { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31,
4541 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
4542 static const struct wacom_features wacom_features_0xD2
=
4543 { "Wacom Bamboo Craft", 14720, 9200, 1023, 31,
4544 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
4545 static const struct wacom_features wacom_features_0xD3
=
4546 { "Wacom Bamboo 2FG 6x8", 21648, 13700, 1023, 31,
4547 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
4548 static const struct wacom_features wacom_features_0xD4
=
4549 { "Wacom Bamboo Pen", 14720, 9200, 1023, 31,
4550 BAMBOO_PEN
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4551 static const struct wacom_features wacom_features_0xD5
=
4552 { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31,
4553 BAMBOO_PEN
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4554 static const struct wacom_features wacom_features_0xD6
=
4555 { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31,
4556 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
4557 static const struct wacom_features wacom_features_0xD7
=
4558 { "Wacom BambooPT 2FG Small", 14720, 9200, 1023, 31,
4559 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
4560 static const struct wacom_features wacom_features_0xD8
=
4561 { "Wacom Bamboo Comic 2FG", 21648, 13700, 1023, 31,
4562 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
4563 static const struct wacom_features wacom_features_0xDA
=
4564 { "Wacom Bamboo 2FG 4x5 SE", 14720, 9200, 1023, 31,
4565 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
4566 static const struct wacom_features wacom_features_0xDB
=
4567 { "Wacom Bamboo 2FG 6x8 SE", 21648, 13700, 1023, 31,
4568 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
4569 static const struct wacom_features wacom_features_0xDD
=
4570 { "Wacom Bamboo Connect", 14720, 9200, 1023, 31,
4571 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4572 static const struct wacom_features wacom_features_0xDE
=
4573 { "Wacom Bamboo 16FG 4x5", 14720, 9200, 1023, 31,
4574 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 16 };
4575 static const struct wacom_features wacom_features_0xDF
=
4576 { "Wacom Bamboo 16FG 6x8", 21648, 13700, 1023, 31,
4577 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 16 };
4578 static const struct wacom_features wacom_features_0x300
=
4579 { "Wacom Bamboo One S", 14720, 9225, 1023, 31,
4580 BAMBOO_PEN
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4581 static const struct wacom_features wacom_features_0x301
=
4582 { "Wacom Bamboo One M", 21648, 13530, 1023, 31,
4583 BAMBOO_PEN
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4584 static const struct wacom_features wacom_features_0x302
=
4585 { "Wacom Intuos PT S", 15200, 9500, 1023, 31,
4586 INTUOSHT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 16,
4587 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4588 static const struct wacom_features wacom_features_0x303
=
4589 { "Wacom Intuos PT M", 21600, 13500, 1023, 31,
4590 INTUOSHT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 16,
4591 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4592 static const struct wacom_features wacom_features_0x30E
=
4593 { "Wacom Intuos S", 15200, 9500, 1023, 31,
4594 INTUOSHT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
,
4595 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4596 static const struct wacom_features wacom_features_0x6004
=
4597 { "ISD-V4", 12800, 8000, 255, 0,
4598 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4599 static const struct wacom_features wacom_features_0x307
=
4600 { "Wacom ISDv5 307", 59552, 33848, 2047, 63,
4601 CINTIQ_HYBRID
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9,
4602 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4603 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4604 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x309 };
4605 static const struct wacom_features wacom_features_0x309
=
4606 { "Wacom ISDv5 309", .type
= WACOM_24HDT
, /* Touch */
4607 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x0307, .touch_max
= 10,
4608 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4609 static const struct wacom_features wacom_features_0x30A
=
4610 { "Wacom ISDv5 30A", 59552, 33848, 2047, 63,
4611 CINTIQ_HYBRID
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9,
4612 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4613 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4614 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x30C };
4615 static const struct wacom_features wacom_features_0x30C
=
4616 { "Wacom ISDv5 30C", .type
= WACOM_24HDT
, /* Touch */
4617 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x30A, .touch_max
= 10,
4618 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4619 static const struct wacom_features wacom_features_0x318
=
4620 { "Wacom USB Bamboo PAD", 4095, 4095, /* Touch */
4621 .type
= BAMBOO_PAD
, 35, 48, .touch_max
= 4 };
4622 static const struct wacom_features wacom_features_0x319
=
4623 { "Wacom Wireless Bamboo PAD", 4095, 4095, /* Touch */
4624 .type
= BAMBOO_PAD
, 35, 48, .touch_max
= 4 };
4625 static const struct wacom_features wacom_features_0x325
=
4626 { "Wacom ISDv5 325", 59552, 33848, 2047, 63,
4627 CINTIQ_COMPANION_2
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 11,
4628 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4629 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
4630 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x326 };
4631 static const struct wacom_features wacom_features_0x326
= /* Touch */
4632 { "Wacom ISDv5 326", .type
= HID_GENERIC
, .oVid
= USB_VENDOR_ID_WACOM
,
4634 static const struct wacom_features wacom_features_0x323
=
4635 { "Wacom Intuos P M", 21600, 13500, 1023, 31,
4636 INTUOSHT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
,
4637 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4638 static const struct wacom_features wacom_features_0x331
=
4639 { "Wacom Express Key Remote", .type
= REMOTE
,
4640 .numbered_buttons
= 18, .check_for_hid_type
= true,
4641 .hid_type
= HID_TYPE_USBNONE
};
4642 static const struct wacom_features wacom_features_0x33B
=
4643 { "Wacom Intuos S 2", 15200, 9500, 2047, 63,
4644 INTUOSHT2
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
,
4645 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4646 static const struct wacom_features wacom_features_0x33C
=
4647 { "Wacom Intuos PT S 2", 15200, 9500, 2047, 63,
4648 INTUOSHT2
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 16,
4649 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4650 static const struct wacom_features wacom_features_0x33D
=
4651 { "Wacom Intuos P M 2", 21600, 13500, 2047, 63,
4652 INTUOSHT2
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
,
4653 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4654 static const struct wacom_features wacom_features_0x33E
=
4655 { "Wacom Intuos PT M 2", 21600, 13500, 2047, 63,
4656 INTUOSHT2
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 16,
4657 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
4658 static const struct wacom_features wacom_features_0x343
=
4659 { "Wacom DTK1651", 34816, 19759, 1023, 0,
4660 DTUS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, 4,
4661 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
,
4662 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
};
4663 static const struct wacom_features wacom_features_0x360
=
4664 { "Wacom Intuos Pro M", 44800, 29600, 8191, 63,
4665 INTUOSP2_BT
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9, .touch_max
= 10 };
4666 static const struct wacom_features wacom_features_0x361
=
4667 { "Wacom Intuos Pro L", 62200, 43200, 8191, 63,
4668 INTUOSP2_BT
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 9, .touch_max
= 10 };
4669 static const struct wacom_features wacom_features_0x377
=
4670 { "Wacom Intuos BT S", 15200, 9500, 4095, 63,
4671 INTUOSHT3_BT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, 4 };
4672 static const struct wacom_features wacom_features_0x379
=
4673 { "Wacom Intuos BT M", 21600, 13500, 4095, 63,
4674 INTUOSHT3_BT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, 4 };
4675 static const struct wacom_features wacom_features_0x37A
=
4676 { "Wacom One by Wacom S", 15200, 9500, 2047, 63,
4677 BAMBOO_PEN
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4678 static const struct wacom_features wacom_features_0x37B
=
4679 { "Wacom One by Wacom M", 21600, 13500, 2047, 63,
4680 BAMBOO_PEN
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
4681 static const struct wacom_features wacom_features_0x393
=
4682 { "Wacom Intuos Pro S", 31920, 19950, 8191, 63,
4683 INTUOSP2S_BT
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, 7,
4686 static const struct wacom_features wacom_features_HID_ANY_ID
=
4687 { "Wacom HID", .type
= HID_GENERIC
, .oVid
= HID_ANY_ID
, .oPid
= HID_ANY_ID
};
4689 #define USB_DEVICE_WACOM(prod) \
4690 HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4691 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4693 #define BT_DEVICE_WACOM(prod) \
4694 HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4695 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4697 #define I2C_DEVICE_WACOM(prod) \
4698 HID_DEVICE(BUS_I2C, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4699 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4701 #define USB_DEVICE_LENOVO(prod) \
4702 HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
4703 .driver_data = (kernel_ulong_t)&wacom_features_##prod
4705 const struct hid_device_id wacom_ids
[] = {
4706 { USB_DEVICE_WACOM(0x00) },
4707 { USB_DEVICE_WACOM(0x03) },
4708 { USB_DEVICE_WACOM(0x10) },
4709 { USB_DEVICE_WACOM(0x11) },
4710 { USB_DEVICE_WACOM(0x12) },
4711 { USB_DEVICE_WACOM(0x13) },
4712 { USB_DEVICE_WACOM(0x14) },
4713 { USB_DEVICE_WACOM(0x15) },
4714 { USB_DEVICE_WACOM(0x16) },
4715 { USB_DEVICE_WACOM(0x17) },
4716 { USB_DEVICE_WACOM(0x18) },
4717 { USB_DEVICE_WACOM(0x19) },
4718 { USB_DEVICE_WACOM(0x20) },
4719 { USB_DEVICE_WACOM(0x21) },
4720 { USB_DEVICE_WACOM(0x22) },
4721 { USB_DEVICE_WACOM(0x23) },
4722 { USB_DEVICE_WACOM(0x24) },
4723 { USB_DEVICE_WACOM(0x26) },
4724 { USB_DEVICE_WACOM(0x27) },
4725 { USB_DEVICE_WACOM(0x28) },
4726 { USB_DEVICE_WACOM(0x29) },
4727 { USB_DEVICE_WACOM(0x2A) },
4728 { USB_DEVICE_WACOM(0x30) },
4729 { USB_DEVICE_WACOM(0x31) },
4730 { USB_DEVICE_WACOM(0x32) },
4731 { USB_DEVICE_WACOM(0x33) },
4732 { USB_DEVICE_WACOM(0x34) },
4733 { USB_DEVICE_WACOM(0x35) },
4734 { USB_DEVICE_WACOM(0x37) },
4735 { USB_DEVICE_WACOM(0x38) },
4736 { USB_DEVICE_WACOM(0x39) },
4737 { USB_DEVICE_WACOM(0x3F) },
4738 { USB_DEVICE_WACOM(0x41) },
4739 { USB_DEVICE_WACOM(0x42) },
4740 { USB_DEVICE_WACOM(0x43) },
4741 { USB_DEVICE_WACOM(0x44) },
4742 { USB_DEVICE_WACOM(0x45) },
4743 { USB_DEVICE_WACOM(0x47) },
4744 { USB_DEVICE_WACOM(0x57) },
4745 { USB_DEVICE_WACOM(0x59) },
4746 { USB_DEVICE_WACOM(0x5B) },
4747 { USB_DEVICE_WACOM(0x5D) },
4748 { USB_DEVICE_WACOM(0x5E) },
4749 { USB_DEVICE_WACOM(0x60) },
4750 { USB_DEVICE_WACOM(0x61) },
4751 { USB_DEVICE_WACOM(0x62) },
4752 { USB_DEVICE_WACOM(0x63) },
4753 { USB_DEVICE_WACOM(0x64) },
4754 { USB_DEVICE_WACOM(0x65) },
4755 { USB_DEVICE_WACOM(0x69) },
4756 { USB_DEVICE_WACOM(0x6A) },
4757 { USB_DEVICE_WACOM(0x6B) },
4758 { BT_DEVICE_WACOM(0x81) },
4759 { USB_DEVICE_WACOM(0x84) },
4760 { USB_DEVICE_WACOM(0x90) },
4761 { USB_DEVICE_WACOM(0x93) },
4762 { USB_DEVICE_WACOM(0x97) },
4763 { USB_DEVICE_WACOM(0x9A) },
4764 { USB_DEVICE_WACOM(0x9F) },
4765 { USB_DEVICE_WACOM(0xB0) },
4766 { USB_DEVICE_WACOM(0xB1) },
4767 { USB_DEVICE_WACOM(0xB2) },
4768 { USB_DEVICE_WACOM(0xB3) },
4769 { USB_DEVICE_WACOM(0xB4) },
4770 { USB_DEVICE_WACOM(0xB5) },
4771 { USB_DEVICE_WACOM(0xB7) },
4772 { USB_DEVICE_WACOM(0xB8) },
4773 { USB_DEVICE_WACOM(0xB9) },
4774 { USB_DEVICE_WACOM(0xBA) },
4775 { USB_DEVICE_WACOM(0xBB) },
4776 { USB_DEVICE_WACOM(0xBC) },
4777 { BT_DEVICE_WACOM(0xBD) },
4778 { USB_DEVICE_WACOM(0xC0) },
4779 { USB_DEVICE_WACOM(0xC2) },
4780 { USB_DEVICE_WACOM(0xC4) },
4781 { USB_DEVICE_WACOM(0xC5) },
4782 { USB_DEVICE_WACOM(0xC6) },
4783 { USB_DEVICE_WACOM(0xC7) },
4784 { USB_DEVICE_WACOM(0xCC) },
4785 { USB_DEVICE_WACOM(0xCE) },
4786 { USB_DEVICE_WACOM(0xD0) },
4787 { USB_DEVICE_WACOM(0xD1) },
4788 { USB_DEVICE_WACOM(0xD2) },
4789 { USB_DEVICE_WACOM(0xD3) },
4790 { USB_DEVICE_WACOM(0xD4) },
4791 { USB_DEVICE_WACOM(0xD5) },
4792 { USB_DEVICE_WACOM(0xD6) },
4793 { USB_DEVICE_WACOM(0xD7) },
4794 { USB_DEVICE_WACOM(0xD8) },
4795 { USB_DEVICE_WACOM(0xDA) },
4796 { USB_DEVICE_WACOM(0xDB) },
4797 { USB_DEVICE_WACOM(0xDD) },
4798 { USB_DEVICE_WACOM(0xDE) },
4799 { USB_DEVICE_WACOM(0xDF) },
4800 { USB_DEVICE_WACOM(0xE2) },
4801 { USB_DEVICE_WACOM(0xE3) },
4802 { USB_DEVICE_WACOM(0xE5) },
4803 { USB_DEVICE_WACOM(0xE6) },
4804 { USB_DEVICE_WACOM(0xEC) },
4805 { USB_DEVICE_WACOM(0xED) },
4806 { USB_DEVICE_WACOM(0xEF) },
4807 { USB_DEVICE_WACOM(0xF0) },
4808 { USB_DEVICE_WACOM(0xF4) },
4809 { USB_DEVICE_WACOM(0xF6) },
4810 { USB_DEVICE_WACOM(0xF8) },
4811 { USB_DEVICE_WACOM(0xFA) },
4812 { USB_DEVICE_WACOM(0xFB) },
4813 { USB_DEVICE_WACOM(0x100) },
4814 { USB_DEVICE_WACOM(0x101) },
4815 { USB_DEVICE_WACOM(0x10D) },
4816 { USB_DEVICE_WACOM(0x10E) },
4817 { USB_DEVICE_WACOM(0x10F) },
4818 { USB_DEVICE_WACOM(0x116) },
4819 { USB_DEVICE_WACOM(0x12C) },
4820 { USB_DEVICE_WACOM(0x300) },
4821 { USB_DEVICE_WACOM(0x301) },
4822 { USB_DEVICE_WACOM(0x302) },
4823 { USB_DEVICE_WACOM(0x303) },
4824 { USB_DEVICE_WACOM(0x304) },
4825 { USB_DEVICE_WACOM(0x307) },
4826 { USB_DEVICE_WACOM(0x309) },
4827 { USB_DEVICE_WACOM(0x30A) },
4828 { USB_DEVICE_WACOM(0x30C) },
4829 { USB_DEVICE_WACOM(0x30E) },
4830 { USB_DEVICE_WACOM(0x314) },
4831 { USB_DEVICE_WACOM(0x315) },
4832 { USB_DEVICE_WACOM(0x317) },
4833 { USB_DEVICE_WACOM(0x318) },
4834 { USB_DEVICE_WACOM(0x319) },
4835 { USB_DEVICE_WACOM(0x323) },
4836 { USB_DEVICE_WACOM(0x325) },
4837 { USB_DEVICE_WACOM(0x326) },
4838 { USB_DEVICE_WACOM(0x32A) },
4839 { USB_DEVICE_WACOM(0x32B) },
4840 { USB_DEVICE_WACOM(0x32C) },
4841 { USB_DEVICE_WACOM(0x32F) },
4842 { USB_DEVICE_WACOM(0x331) },
4843 { USB_DEVICE_WACOM(0x333) },
4844 { USB_DEVICE_WACOM(0x335) },
4845 { USB_DEVICE_WACOM(0x336) },
4846 { USB_DEVICE_WACOM(0x33B) },
4847 { USB_DEVICE_WACOM(0x33C) },
4848 { USB_DEVICE_WACOM(0x33D) },
4849 { USB_DEVICE_WACOM(0x33E) },
4850 { USB_DEVICE_WACOM(0x343) },
4851 { BT_DEVICE_WACOM(0x360) },
4852 { BT_DEVICE_WACOM(0x361) },
4853 { BT_DEVICE_WACOM(0x377) },
4854 { BT_DEVICE_WACOM(0x379) },
4855 { USB_DEVICE_WACOM(0x37A) },
4856 { USB_DEVICE_WACOM(0x37B) },
4857 { BT_DEVICE_WACOM(0x393) },
4858 { USB_DEVICE_WACOM(0x4001) },
4859 { USB_DEVICE_WACOM(0x4004) },
4860 { USB_DEVICE_WACOM(0x5000) },
4861 { USB_DEVICE_WACOM(0x5002) },
4862 { USB_DEVICE_LENOVO(0x6004) },
4864 { USB_DEVICE_WACOM(HID_ANY_ID
) },
4865 { I2C_DEVICE_WACOM(HID_ANY_ID
) },
4866 { BT_DEVICE_WACOM(HID_ANY_ID
) },
4869 MODULE_DEVICE_TABLE(hid
, wacom_ids
);