2 * drivers/input/tablet/wacom_wac.c
4 * USB Wacom tablet support - Wacom specific code
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
15 #include "wacom_wac.h"
17 #include <linux/input/mt.h>
18 #include <linux/hid.h>
20 /* resolution for penabled devices */
21 #define WACOM_PL_RES 20
22 #define WACOM_PENPRTN_RES 40
23 #define WACOM_VOLITO_RES 50
24 #define WACOM_GRAPHIRE_RES 80
25 #define WACOM_INTUOS_RES 100
26 #define WACOM_INTUOS3_RES 200
28 /* Newer Cintiq and DTU have an offset between tablet and screen areas */
29 #define WACOM_DTU_OFFSET 200
30 #define WACOM_CINTIQ_OFFSET 400
33 * Scale factor relating reported contact size to logical contact area.
34 * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo
36 #define WACOM_CONTACT_AREA_SCALE 2607
39 * Percent of battery capacity for Graphire.
40 * 8th value means AC online and show 100% capacity.
42 static unsigned short batcap_gr
[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
45 * Percent of battery capacity for Intuos4 WL, AC has a separate bit.
47 static unsigned short batcap_i4
[8] = { 1, 15, 30, 45, 60, 70, 85, 100 };
49 static int wacom_penpartner_irq(struct wacom_wac
*wacom
)
51 unsigned char *data
= wacom
->data
;
52 struct input_dev
*input
= wacom
->input
;
57 wacom
->tool
[0] = (data
[5] & 0x20) ? BTN_TOOL_RUBBER
: BTN_TOOL_PEN
;
58 wacom
->id
[0] = (data
[5] & 0x20) ? ERASER_DEVICE_ID
: STYLUS_DEVICE_ID
;
59 input_report_key(input
, wacom
->tool
[0], 1);
60 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]); /* report tool id */
61 input_report_abs(input
, ABS_X
, get_unaligned_le16(&data
[1]));
62 input_report_abs(input
, ABS_Y
, get_unaligned_le16(&data
[3]));
63 input_report_abs(input
, ABS_PRESSURE
, (signed char)data
[6] + 127);
64 input_report_key(input
, BTN_TOUCH
, ((signed char)data
[6] > -127));
65 input_report_key(input
, BTN_STYLUS
, (data
[5] & 0x40));
67 input_report_key(input
, wacom
->tool
[0], 0);
68 input_report_abs(input
, ABS_MISC
, 0); /* report tool id */
69 input_report_abs(input
, ABS_PRESSURE
, -1);
70 input_report_key(input
, BTN_TOUCH
, 0);
75 input_report_key(input
, BTN_TOOL_PEN
, 1);
76 input_report_abs(input
, ABS_MISC
, STYLUS_DEVICE_ID
); /* report tool id */
77 input_report_abs(input
, ABS_X
, get_unaligned_le16(&data
[1]));
78 input_report_abs(input
, ABS_Y
, get_unaligned_le16(&data
[3]));
79 input_report_abs(input
, ABS_PRESSURE
, (signed char)data
[6] + 127);
80 input_report_key(input
, BTN_TOUCH
, ((signed char)data
[6] > -80) && !(data
[5] & 0x20));
81 input_report_key(input
, BTN_STYLUS
, (data
[5] & 0x40));
85 dev_dbg(input
->dev
.parent
,
86 "%s: received unknown report #%d\n", __func__
, data
[0]);
93 static int wacom_pl_irq(struct wacom_wac
*wacom
)
95 struct wacom_features
*features
= &wacom
->features
;
96 unsigned char *data
= wacom
->data
;
97 struct input_dev
*input
= wacom
->input
;
100 if (data
[0] != WACOM_REPORT_PENABLED
) {
101 dev_dbg(input
->dev
.parent
,
102 "%s: received unknown report #%d\n", __func__
, data
[0]);
106 prox
= data
[1] & 0x40;
109 wacom
->id
[0] = ERASER_DEVICE_ID
;
110 pressure
= (signed char)((data
[7] << 1) | ((data
[4] >> 2) & 1));
111 if (features
->pressure_max
> 255)
112 pressure
= (pressure
<< 1) | ((data
[4] >> 6) & 1);
113 pressure
+= (features
->pressure_max
+ 1) / 2;
116 * if going from out of proximity into proximity select between the eraser
117 * and the pen based on the state of the stylus2 button, choose eraser if
118 * pressed else choose pen. if not a proximity change from out to in, send
119 * an out of proximity for previous tool then a in for new tool.
121 if (!wacom
->tool
[0]) {
122 /* Eraser bit set for DTF */
124 wacom
->tool
[1] = BTN_TOOL_RUBBER
;
126 /* Going into proximity select tool */
127 wacom
->tool
[1] = (data
[4] & 0x20) ? BTN_TOOL_RUBBER
: BTN_TOOL_PEN
;
129 /* was entered with stylus2 pressed */
130 if (wacom
->tool
[1] == BTN_TOOL_RUBBER
&& !(data
[4] & 0x20)) {
131 /* report out proximity for previous tool */
132 input_report_key(input
, wacom
->tool
[1], 0);
134 wacom
->tool
[1] = BTN_TOOL_PEN
;
138 if (wacom
->tool
[1] != BTN_TOOL_RUBBER
) {
139 /* Unknown tool selected default to pen tool */
140 wacom
->tool
[1] = BTN_TOOL_PEN
;
141 wacom
->id
[0] = STYLUS_DEVICE_ID
;
143 input_report_key(input
, wacom
->tool
[1], prox
); /* report in proximity for tool */
144 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]); /* report tool id */
145 input_report_abs(input
, ABS_X
, data
[3] | (data
[2] << 7) | ((data
[1] & 0x03) << 14));
146 input_report_abs(input
, ABS_Y
, data
[6] | (data
[5] << 7) | ((data
[4] & 0x03) << 14));
147 input_report_abs(input
, ABS_PRESSURE
, pressure
);
149 input_report_key(input
, BTN_TOUCH
, data
[4] & 0x08);
150 input_report_key(input
, BTN_STYLUS
, data
[4] & 0x10);
151 /* Only allow the stylus2 button to be reported for the pen tool. */
152 input_report_key(input
, BTN_STYLUS2
, (wacom
->tool
[1] == BTN_TOOL_PEN
) && (data
[4] & 0x20));
154 /* report proximity-out of a (valid) tool */
155 if (wacom
->tool
[1] != BTN_TOOL_RUBBER
) {
156 /* Unknown tool selected default to pen tool */
157 wacom
->tool
[1] = BTN_TOOL_PEN
;
159 input_report_key(input
, wacom
->tool
[1], prox
);
162 wacom
->tool
[0] = prox
; /* Save proximity state */
166 static int wacom_ptu_irq(struct wacom_wac
*wacom
)
168 unsigned char *data
= wacom
->data
;
169 struct input_dev
*input
= wacom
->input
;
171 if (data
[0] != WACOM_REPORT_PENABLED
) {
172 dev_dbg(input
->dev
.parent
,
173 "%s: received unknown report #%d\n", __func__
, data
[0]);
177 if (data
[1] & 0x04) {
178 input_report_key(input
, BTN_TOOL_RUBBER
, data
[1] & 0x20);
179 input_report_key(input
, BTN_TOUCH
, data
[1] & 0x08);
180 wacom
->id
[0] = ERASER_DEVICE_ID
;
182 input_report_key(input
, BTN_TOOL_PEN
, data
[1] & 0x20);
183 input_report_key(input
, BTN_TOUCH
, data
[1] & 0x01);
184 wacom
->id
[0] = STYLUS_DEVICE_ID
;
186 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]); /* report tool id */
187 input_report_abs(input
, ABS_X
, le16_to_cpup((__le16
*)&data
[2]));
188 input_report_abs(input
, ABS_Y
, le16_to_cpup((__le16
*)&data
[4]));
189 input_report_abs(input
, ABS_PRESSURE
, le16_to_cpup((__le16
*)&data
[6]));
190 input_report_key(input
, BTN_STYLUS
, data
[1] & 0x02);
191 input_report_key(input
, BTN_STYLUS2
, data
[1] & 0x10);
195 static int wacom_dtu_irq(struct wacom_wac
*wacom
)
197 unsigned char *data
= wacom
->data
;
198 struct input_dev
*input
= wacom
->input
;
199 int prox
= data
[1] & 0x20;
201 dev_dbg(input
->dev
.parent
,
202 "%s: received report #%d", __func__
, data
[0]);
205 /* Going into proximity select tool */
206 wacom
->tool
[0] = (data
[1] & 0x0c) ? BTN_TOOL_RUBBER
: BTN_TOOL_PEN
;
207 if (wacom
->tool
[0] == BTN_TOOL_PEN
)
208 wacom
->id
[0] = STYLUS_DEVICE_ID
;
210 wacom
->id
[0] = ERASER_DEVICE_ID
;
212 input_report_key(input
, BTN_STYLUS
, data
[1] & 0x02);
213 input_report_key(input
, BTN_STYLUS2
, data
[1] & 0x10);
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
, ((data
[7] & 0x01) << 8) | data
[6]);
217 input_report_key(input
, BTN_TOUCH
, data
[1] & 0x05);
218 if (!prox
) /* out-prox */
220 input_report_key(input
, wacom
->tool
[0], prox
);
221 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]);
225 static int wacom_dtus_irq(struct wacom_wac
*wacom
)
227 char *data
= wacom
->data
;
228 struct input_dev
*input
= wacom
->input
;
229 unsigned short prox
, pressure
= 0;
231 if (data
[0] != WACOM_REPORT_DTUS
&& data
[0] != WACOM_REPORT_DTUSPAD
) {
232 dev_dbg(input
->dev
.parent
,
233 "%s: received unknown report #%d", __func__
, data
[0]);
235 } else if (data
[0] == WACOM_REPORT_DTUSPAD
) {
236 input
= wacom
->pad_input
;
237 input_report_key(input
, BTN_0
, (data
[1] & 0x01));
238 input_report_key(input
, BTN_1
, (data
[1] & 0x02));
239 input_report_key(input
, BTN_2
, (data
[1] & 0x04));
240 input_report_key(input
, BTN_3
, (data
[1] & 0x08));
241 input_report_abs(input
, ABS_MISC
,
242 data
[1] & 0x0f ? PAD_DEVICE_ID
: 0);
245 prox
= data
[1] & 0x80;
247 switch ((data
[1] >> 3) & 3) {
249 wacom
->tool
[0] = BTN_TOOL_RUBBER
;
250 wacom
->id
[0] = ERASER_DEVICE_ID
;
254 wacom
->tool
[0] = BTN_TOOL_PEN
;
255 wacom
->id
[0] = STYLUS_DEVICE_ID
;
260 input_report_key(input
, BTN_STYLUS
, data
[1] & 0x20);
261 input_report_key(input
, BTN_STYLUS2
, data
[1] & 0x40);
262 input_report_abs(input
, ABS_X
, get_unaligned_be16(&data
[3]));
263 input_report_abs(input
, ABS_Y
, get_unaligned_be16(&data
[5]));
264 pressure
= ((data
[1] & 0x03) << 8) | (data
[2] & 0xff);
265 input_report_abs(input
, ABS_PRESSURE
, pressure
);
266 input_report_key(input
, BTN_TOUCH
, pressure
> 10);
268 if (!prox
) /* out-prox */
270 input_report_key(input
, wacom
->tool
[0], prox
);
271 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]);
276 static int wacom_graphire_irq(struct wacom_wac
*wacom
)
278 struct wacom_features
*features
= &wacom
->features
;
279 unsigned char *data
= wacom
->data
;
280 struct input_dev
*input
= wacom
->input
;
281 struct input_dev
*pad_input
= wacom
->pad_input
;
282 int battery_capacity
, ps_connected
;
287 if (features
->type
== GRAPHIRE_BT
) {
288 if (data
[0] != WACOM_REPORT_PENABLED_BT
) {
289 dev_dbg(input
->dev
.parent
,
290 "%s: received unknown report #%d\n", __func__
,
294 } else if (data
[0] != WACOM_REPORT_PENABLED
) {
295 dev_dbg(input
->dev
.parent
,
296 "%s: received unknown report #%d\n", __func__
, data
[0]);
300 prox
= data
[1] & 0x80;
301 if (prox
|| wacom
->id
[0]) {
303 switch ((data
[1] >> 5) & 3) {
306 wacom
->tool
[0] = BTN_TOOL_PEN
;
307 wacom
->id
[0] = STYLUS_DEVICE_ID
;
311 wacom
->tool
[0] = BTN_TOOL_RUBBER
;
312 wacom
->id
[0] = ERASER_DEVICE_ID
;
315 case 2: /* Mouse with wheel */
316 input_report_key(input
, BTN_MIDDLE
, data
[1] & 0x04);
319 case 3: /* Mouse without wheel */
320 wacom
->tool
[0] = BTN_TOOL_MOUSE
;
321 wacom
->id
[0] = CURSOR_DEVICE_ID
;
325 input_report_abs(input
, ABS_X
, le16_to_cpup((__le16
*)&data
[2]));
326 input_report_abs(input
, ABS_Y
, le16_to_cpup((__le16
*)&data
[4]));
327 if (wacom
->tool
[0] != BTN_TOOL_MOUSE
) {
328 if (features
->type
== GRAPHIRE_BT
)
329 input_report_abs(input
, ABS_PRESSURE
, data
[6] |
330 (((__u16
) (data
[1] & 0x08)) << 5));
332 input_report_abs(input
, ABS_PRESSURE
, data
[6] |
333 ((data
[7] & 0x03) << 8));
334 input_report_key(input
, BTN_TOUCH
, data
[1] & 0x01);
335 input_report_key(input
, BTN_STYLUS
, data
[1] & 0x02);
336 input_report_key(input
, BTN_STYLUS2
, data
[1] & 0x04);
338 input_report_key(input
, BTN_LEFT
, data
[1] & 0x01);
339 input_report_key(input
, BTN_RIGHT
, data
[1] & 0x02);
340 if (features
->type
== WACOM_G4
||
341 features
->type
== WACOM_MO
) {
342 input_report_abs(input
, ABS_DISTANCE
, data
[6] & 0x3f);
343 rw
= (data
[7] & 0x04) - (data
[7] & 0x03);
344 } else if (features
->type
== GRAPHIRE_BT
) {
345 /* Compute distance between mouse and tablet */
346 rw
= 44 - (data
[6] >> 2);
347 rw
= clamp_val(rw
, 0, 31);
348 input_report_abs(input
, ABS_DISTANCE
, rw
);
349 if (((data
[1] >> 5) & 3) == 2) {
350 /* Mouse with wheel */
351 input_report_key(input
, BTN_MIDDLE
,
353 rw
= (data
[6] & 0x01) ? -1 :
354 (data
[6] & 0x02) ? 1 : 0;
359 input_report_abs(input
, ABS_DISTANCE
, data
[7] & 0x3f);
360 rw
= -(signed char)data
[6];
362 input_report_rel(input
, REL_WHEEL
, rw
);
367 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]); /* report tool id */
368 input_report_key(input
, wacom
->tool
[0], prox
);
369 input_sync(input
); /* sync last event */
373 switch (features
->type
) {
375 prox
= data
[7] & 0xf8;
376 if (prox
|| wacom
->id
[1]) {
377 wacom
->id
[1] = PAD_DEVICE_ID
;
378 input_report_key(pad_input
, BTN_BACK
, (data
[7] & 0x40));
379 input_report_key(pad_input
, BTN_FORWARD
, (data
[7] & 0x80));
380 rw
= ((data
[7] & 0x18) >> 3) - ((data
[7] & 0x20) >> 3);
381 input_report_rel(pad_input
, REL_WHEEL
, rw
);
384 input_report_abs(pad_input
, ABS_MISC
, wacom
->id
[1]);
390 prox
= (data
[7] & 0xf8) || data
[8];
391 if (prox
|| wacom
->id
[1]) {
392 wacom
->id
[1] = PAD_DEVICE_ID
;
393 input_report_key(pad_input
, BTN_BACK
, (data
[7] & 0x08));
394 input_report_key(pad_input
, BTN_LEFT
, (data
[7] & 0x20));
395 input_report_key(pad_input
, BTN_FORWARD
, (data
[7] & 0x10));
396 input_report_key(pad_input
, BTN_RIGHT
, (data
[7] & 0x40));
397 input_report_abs(pad_input
, ABS_WHEEL
, (data
[8] & 0x7f));
400 input_report_abs(pad_input
, ABS_MISC
, wacom
->id
[1]);
405 prox
= data
[7] & 0x03;
406 if (prox
|| wacom
->id
[1]) {
407 wacom
->id
[1] = PAD_DEVICE_ID
;
408 input_report_key(pad_input
, BTN_0
, (data
[7] & 0x02));
409 input_report_key(pad_input
, BTN_1
, (data
[7] & 0x01));
412 input_report_abs(pad_input
, ABS_MISC
, wacom
->id
[1]);
418 /* Store current battery capacity and power supply state */
419 if (features
->type
== GRAPHIRE_BT
) {
420 rw
= (data
[7] >> 2 & 0x07);
421 battery_capacity
= batcap_gr
[rw
];
422 ps_connected
= rw
== 7;
423 if ((wacom
->battery_capacity
!= battery_capacity
) ||
424 (wacom
->ps_connected
!= ps_connected
)) {
425 wacom
->battery_capacity
= battery_capacity
;
426 wacom
->ps_connected
= ps_connected
;
427 wacom_notify_battery(wacom
);
434 static int wacom_intuos_inout(struct wacom_wac
*wacom
)
436 struct wacom_features
*features
= &wacom
->features
;
437 unsigned char *data
= wacom
->data
;
438 struct input_dev
*input
= wacom
->input
;
442 if (features
->type
== INTUOS
)
443 idx
= data
[1] & 0x01;
446 if ((data
[1] & 0xfc) == 0xc0) {
447 if (features
->quirks
& WACOM_QUIRK_MULTI_INPUT
)
448 wacom
->shared
->stylus_in_proximity
= true;
450 /* serial number of the tool */
451 wacom
->serial
[idx
] = ((data
[3] & 0x0f) << 28) +
452 (data
[4] << 20) + (data
[5] << 12) +
453 (data
[6] << 4) + (data
[7] >> 4);
455 wacom
->id
[idx
] = (data
[2] << 4) | (data
[3] >> 4) |
456 ((data
[7] & 0x0f) << 20) | ((data
[8] & 0xf0) << 12);
458 switch (wacom
->id
[idx
]) {
459 case 0x812: /* Inking pen */
460 case 0x801: /* Intuos3 Inking pen */
461 case 0x120802: /* Intuos4/5 Inking Pen */
463 wacom
->tool
[idx
] = BTN_TOOL_PENCIL
;
466 case 0x822: /* Pen */
469 case 0x823: /* Intuos3 Grip Pen */
470 case 0x813: /* Intuos3 Classic Pen */
471 case 0x885: /* Intuos3 Marker Pen */
472 case 0x802: /* Intuos4/5 13HD/24HD General Pen */
473 case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
475 case 0x100804: /* Intuos4/5 13HD/24HD Art Pen */
476 case 0x140802: /* Intuos4/5 13HD/24HD Classic Pen */
477 case 0x160802: /* Cintiq 13HD Pro Pen */
478 case 0x180802: /* DTH2242 Pen */
479 case 0x100802: /* Intuos4/5 13HD/24HD General Pen */
480 wacom
->tool
[idx
] = BTN_TOOL_PEN
;
483 case 0x832: /* Stroke pen */
485 wacom
->tool
[idx
] = BTN_TOOL_BRUSH
;
488 case 0x007: /* Mouse 4D and 2D */
491 case 0x017: /* Intuos3 2D Mouse */
492 case 0x806: /* Intuos4 Mouse */
493 wacom
->tool
[idx
] = BTN_TOOL_MOUSE
;
496 case 0x096: /* Lens cursor */
497 case 0x097: /* Intuos3 Lens cursor */
498 case 0x006: /* Intuos4 Lens cursor */
499 wacom
->tool
[idx
] = BTN_TOOL_LENS
;
502 case 0x82a: /* Eraser */
507 case 0x82b: /* Intuos3 Grip Pen Eraser */
508 case 0x81b: /* Intuos3 Classic Pen Eraser */
509 case 0x91b: /* Intuos3 Airbrush Eraser */
510 case 0x80c: /* Intuos4/5 13HD/24HD Marker Pen Eraser */
511 case 0x80a: /* Intuos4/5 13HD/24HD General Pen Eraser */
512 case 0x90a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
513 case 0x14080a: /* Intuos4/5 13HD/24HD Classic Pen Eraser */
514 case 0x10090a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
515 case 0x10080c: /* Intuos4/5 13HD/24HD Art Pen Eraser */
516 case 0x16080a: /* Cintiq 13HD Pro Pen Eraser */
517 case 0x18080a: /* DTH2242 Eraser */
518 case 0x10080a: /* Intuos4/5 13HD/24HD General Pen Eraser */
519 wacom
->tool
[idx
] = BTN_TOOL_RUBBER
;
525 case 0x913: /* Intuos3 Airbrush */
526 case 0x902: /* Intuos4/5 13HD/24HD Airbrush */
527 case 0x100902: /* Intuos4/5 13HD/24HD Airbrush */
528 wacom
->tool
[idx
] = BTN_TOOL_AIRBRUSH
;
531 default: /* Unknown tool */
532 wacom
->tool
[idx
] = BTN_TOOL_PEN
;
538 /* older I4 styli don't work with new Cintiqs */
539 if (!((wacom
->id
[idx
] >> 20) & 0x01) &&
540 (features
->type
== WACOM_21UX2
))
544 if ((data
[1] & 0xfe) == 0x20) {
545 input_report_key(input
, BTN_TOUCH
, 0);
546 input_report_abs(input
, ABS_PRESSURE
, 0);
547 input_report_abs(input
, ABS_DISTANCE
, wacom
->features
.distance_max
);
548 if (features
->quirks
& WACOM_QUIRK_MULTI_INPUT
)
549 wacom
->shared
->stylus_in_proximity
= true;
553 if ((data
[1] & 0xfe) == 0x80) {
554 if (features
->quirks
& WACOM_QUIRK_MULTI_INPUT
)
555 wacom
->shared
->stylus_in_proximity
= false;
558 * Reset all states otherwise we lose the initial states
559 * when in-prox next time
561 input_report_abs(input
, ABS_X
, 0);
562 input_report_abs(input
, ABS_Y
, 0);
563 input_report_abs(input
, ABS_DISTANCE
, 0);
564 input_report_abs(input
, ABS_TILT_X
, 0);
565 input_report_abs(input
, ABS_TILT_Y
, 0);
566 if (wacom
->tool
[idx
] >= BTN_TOOL_MOUSE
) {
567 input_report_key(input
, BTN_LEFT
, 0);
568 input_report_key(input
, BTN_MIDDLE
, 0);
569 input_report_key(input
, BTN_RIGHT
, 0);
570 input_report_key(input
, BTN_SIDE
, 0);
571 input_report_key(input
, BTN_EXTRA
, 0);
572 input_report_abs(input
, ABS_THROTTLE
, 0);
573 input_report_abs(input
, ABS_RZ
, 0);
575 input_report_abs(input
, ABS_PRESSURE
, 0);
576 input_report_key(input
, BTN_STYLUS
, 0);
577 input_report_key(input
, BTN_STYLUS2
, 0);
578 input_report_key(input
, BTN_TOUCH
, 0);
579 input_report_abs(input
, ABS_WHEEL
, 0);
580 if (features
->type
>= INTUOS3S
)
581 input_report_abs(input
, ABS_Z
, 0);
583 input_report_key(input
, wacom
->tool
[idx
], 0);
584 input_report_abs(input
, ABS_MISC
, 0); /* reset tool id */
585 input_event(input
, EV_MSC
, MSC_SERIAL
, wacom
->serial
[idx
]);
592 static void wacom_intuos_general(struct wacom_wac
*wacom
)
594 struct wacom_features
*features
= &wacom
->features
;
595 unsigned char *data
= wacom
->data
;
596 struct input_dev
*input
= wacom
->input
;
599 /* general pen packet */
600 if ((data
[1] & 0xb8) == 0xa0) {
601 t
= (data
[6] << 2) | ((data
[7] >> 6) & 3);
602 if (features
->type
>= INTUOS4S
&& features
->type
<= CINTIQ_HYBRID
) {
603 t
= (t
<< 1) | (data
[1] & 1);
605 input_report_abs(input
, ABS_PRESSURE
, t
);
606 input_report_abs(input
, ABS_TILT_X
,
607 (((data
[7] << 1) & 0x7e) | (data
[8] >> 7)) - 64);
608 input_report_abs(input
, ABS_TILT_Y
, (data
[8] & 0x7f) - 64);
609 input_report_key(input
, BTN_STYLUS
, data
[1] & 2);
610 input_report_key(input
, BTN_STYLUS2
, data
[1] & 4);
611 input_report_key(input
, BTN_TOUCH
, t
> 10);
614 /* airbrush second packet */
615 if ((data
[1] & 0xbc) == 0xb4) {
616 input_report_abs(input
, ABS_WHEEL
,
617 (data
[6] << 2) | ((data
[7] >> 6) & 3));
618 input_report_abs(input
, ABS_TILT_X
,
619 (((data
[7] << 1) & 0x7e) | (data
[8] >> 7)) - 64);
620 input_report_abs(input
, ABS_TILT_Y
, (data
[8] & 0x7f) - 64);
624 static int wacom_intuos_irq(struct wacom_wac
*wacom
)
626 struct wacom_features
*features
= &wacom
->features
;
627 unsigned char *data
= wacom
->data
;
628 struct input_dev
*input
= wacom
->input
;
632 if (data
[0] != WACOM_REPORT_PENABLED
&&
633 data
[0] != WACOM_REPORT_INTUOSREAD
&&
634 data
[0] != WACOM_REPORT_INTUOSWRITE
&&
635 data
[0] != WACOM_REPORT_INTUOSPAD
&&
636 data
[0] != WACOM_REPORT_INTUOS5PAD
) {
637 dev_dbg(input
->dev
.parent
,
638 "%s: received unknown report #%d\n", __func__
, data
[0]);
643 if (features
->type
== INTUOS
)
644 idx
= data
[1] & 0x01;
646 /* pad packets. Works as a second tool and is always in prox */
647 if (data
[0] == WACOM_REPORT_INTUOSPAD
|| data
[0] == WACOM_REPORT_INTUOS5PAD
) {
648 input
= wacom
->pad_input
;
649 if (features
->type
>= INTUOS4S
&& features
->type
<= INTUOS4L
) {
650 input_report_key(input
, BTN_0
, (data
[2] & 0x01));
651 input_report_key(input
, BTN_1
, (data
[3] & 0x01));
652 input_report_key(input
, BTN_2
, (data
[3] & 0x02));
653 input_report_key(input
, BTN_3
, (data
[3] & 0x04));
654 input_report_key(input
, BTN_4
, (data
[3] & 0x08));
655 input_report_key(input
, BTN_5
, (data
[3] & 0x10));
656 input_report_key(input
, BTN_6
, (data
[3] & 0x20));
657 if (data
[1] & 0x80) {
658 input_report_abs(input
, ABS_WHEEL
, (data
[1] & 0x7f));
660 /* Out of proximity, clear wheel value. */
661 input_report_abs(input
, ABS_WHEEL
, 0);
663 if (features
->type
!= INTUOS4S
) {
664 input_report_key(input
, BTN_7
, (data
[3] & 0x40));
665 input_report_key(input
, BTN_8
, (data
[3] & 0x80));
667 if (data
[1] | (data
[2] & 0x01) | data
[3]) {
668 input_report_abs(input
, ABS_MISC
, PAD_DEVICE_ID
);
670 input_report_abs(input
, ABS_MISC
, 0);
672 } else if (features
->type
== DTK
) {
673 input_report_key(input
, BTN_0
, (data
[6] & 0x01));
674 input_report_key(input
, BTN_1
, (data
[6] & 0x02));
675 input_report_key(input
, BTN_2
, (data
[6] & 0x04));
676 input_report_key(input
, BTN_3
, (data
[6] & 0x08));
677 input_report_key(input
, BTN_4
, (data
[6] & 0x10));
678 input_report_key(input
, BTN_5
, (data
[6] & 0x20));
679 if (data
[6] & 0x3f) {
680 input_report_abs(input
, ABS_MISC
, PAD_DEVICE_ID
);
682 input_report_abs(input
, ABS_MISC
, 0);
684 } else if (features
->type
== WACOM_13HD
) {
685 input_report_key(input
, BTN_0
, (data
[3] & 0x01));
686 input_report_key(input
, BTN_1
, (data
[4] & 0x01));
687 input_report_key(input
, BTN_2
, (data
[4] & 0x02));
688 input_report_key(input
, BTN_3
, (data
[4] & 0x04));
689 input_report_key(input
, BTN_4
, (data
[4] & 0x08));
690 input_report_key(input
, BTN_5
, (data
[4] & 0x10));
691 input_report_key(input
, BTN_6
, (data
[4] & 0x20));
692 input_report_key(input
, BTN_7
, (data
[4] & 0x40));
693 input_report_key(input
, BTN_8
, (data
[4] & 0x80));
694 if ((data
[3] & 0x01) | data
[4]) {
695 input_report_abs(input
, ABS_MISC
, PAD_DEVICE_ID
);
697 input_report_abs(input
, ABS_MISC
, 0);
699 } else if (features
->type
== WACOM_24HD
) {
700 input_report_key(input
, BTN_0
, (data
[6] & 0x01));
701 input_report_key(input
, BTN_1
, (data
[6] & 0x02));
702 input_report_key(input
, BTN_2
, (data
[6] & 0x04));
703 input_report_key(input
, BTN_3
, (data
[6] & 0x08));
704 input_report_key(input
, BTN_4
, (data
[6] & 0x10));
705 input_report_key(input
, BTN_5
, (data
[6] & 0x20));
706 input_report_key(input
, BTN_6
, (data
[6] & 0x40));
707 input_report_key(input
, BTN_7
, (data
[6] & 0x80));
708 input_report_key(input
, BTN_8
, (data
[8] & 0x01));
709 input_report_key(input
, BTN_9
, (data
[8] & 0x02));
710 input_report_key(input
, BTN_A
, (data
[8] & 0x04));
711 input_report_key(input
, BTN_B
, (data
[8] & 0x08));
712 input_report_key(input
, BTN_C
, (data
[8] & 0x10));
713 input_report_key(input
, BTN_X
, (data
[8] & 0x20));
714 input_report_key(input
, BTN_Y
, (data
[8] & 0x40));
715 input_report_key(input
, BTN_Z
, (data
[8] & 0x80));
718 * Three "buttons" are available on the 24HD which are
719 * physically implemented as a touchstrip. Each button
720 * is approximately 3 bits wide with a 2 bit spacing.
721 * The raw touchstrip bits are stored at:
722 * ((data[3] & 0x1f) << 8) | data[4])
724 input_report_key(input
, KEY_PROG1
, data
[4] & 0x07);
725 input_report_key(input
, KEY_PROG2
, data
[4] & 0xE0);
726 input_report_key(input
, KEY_PROG3
, data
[3] & 0x1C);
728 if (data
[1] & 0x80) {
729 input_report_abs(input
, ABS_WHEEL
, (data
[1] & 0x7f));
731 /* Out of proximity, clear wheel value. */
732 input_report_abs(input
, ABS_WHEEL
, 0);
735 if (data
[2] & 0x80) {
736 input_report_abs(input
, ABS_THROTTLE
, (data
[2] & 0x7f));
738 /* Out of proximity, clear second wheel value. */
739 input_report_abs(input
, ABS_THROTTLE
, 0);
742 if (data
[1] | data
[2] | (data
[3] & 0x1f) | data
[4] | data
[6] | data
[8]) {
743 input_report_abs(input
, ABS_MISC
, PAD_DEVICE_ID
);
745 input_report_abs(input
, ABS_MISC
, 0);
747 } else if (features
->type
== CINTIQ_HYBRID
) {
749 * Do not send hardware buttons under Android. They
750 * are already sent to the system through GPIO (and
751 * have different meaning).
753 input_report_key(input
, BTN_1
, (data
[4] & 0x01));
754 input_report_key(input
, BTN_2
, (data
[4] & 0x02));
755 input_report_key(input
, BTN_3
, (data
[4] & 0x04));
756 input_report_key(input
, BTN_4
, (data
[4] & 0x08));
758 input_report_key(input
, BTN_5
, (data
[4] & 0x10)); /* Right */
759 input_report_key(input
, BTN_6
, (data
[4] & 0x20)); /* Up */
760 input_report_key(input
, BTN_7
, (data
[4] & 0x40)); /* Left */
761 input_report_key(input
, BTN_8
, (data
[4] & 0x80)); /* Down */
762 input_report_key(input
, BTN_0
, (data
[3] & 0x01)); /* Center */
763 } else if (features
->type
>= INTUOS5S
&& features
->type
<= INTUOSPL
) {
766 /* Touch ring mode switch has no capacitive sensor */
767 input_report_key(input
, BTN_0
, (data
[3] & 0x01));
770 * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in
771 * addition to the mechanical switch. Switch data is
772 * stored in data[4], capacitive data in data[5].
774 for (i
= 0; i
< 8; i
++)
775 input_report_key(input
, BTN_1
+ i
, data
[4] & (1 << i
));
777 if (data
[2] & 0x80) {
778 input_report_abs(input
, ABS_WHEEL
, (data
[2] & 0x7f));
780 /* Out of proximity, clear wheel value. */
781 input_report_abs(input
, ABS_WHEEL
, 0);
784 if (data
[2] | (data
[3] & 0x01) | data
[4] | data
[5]) {
785 input_report_abs(input
, ABS_MISC
, PAD_DEVICE_ID
);
787 input_report_abs(input
, ABS_MISC
, 0);
790 if (features
->type
== WACOM_21UX2
|| features
->type
== WACOM_22HD
) {
791 input_report_key(input
, BTN_0
, (data
[5] & 0x01));
792 input_report_key(input
, BTN_1
, (data
[6] & 0x01));
793 input_report_key(input
, BTN_2
, (data
[6] & 0x02));
794 input_report_key(input
, BTN_3
, (data
[6] & 0x04));
795 input_report_key(input
, BTN_4
, (data
[6] & 0x08));
796 input_report_key(input
, BTN_5
, (data
[6] & 0x10));
797 input_report_key(input
, BTN_6
, (data
[6] & 0x20));
798 input_report_key(input
, BTN_7
, (data
[6] & 0x40));
799 input_report_key(input
, BTN_8
, (data
[6] & 0x80));
800 input_report_key(input
, BTN_9
, (data
[7] & 0x01));
801 input_report_key(input
, BTN_A
, (data
[8] & 0x01));
802 input_report_key(input
, BTN_B
, (data
[8] & 0x02));
803 input_report_key(input
, BTN_C
, (data
[8] & 0x04));
804 input_report_key(input
, BTN_X
, (data
[8] & 0x08));
805 input_report_key(input
, BTN_Y
, (data
[8] & 0x10));
806 input_report_key(input
, BTN_Z
, (data
[8] & 0x20));
807 input_report_key(input
, BTN_BASE
, (data
[8] & 0x40));
808 input_report_key(input
, BTN_BASE2
, (data
[8] & 0x80));
810 if (features
->type
== WACOM_22HD
) {
811 input_report_key(input
, KEY_PROG1
, data
[9] & 0x01);
812 input_report_key(input
, KEY_PROG2
, data
[9] & 0x02);
813 input_report_key(input
, KEY_PROG3
, data
[9] & 0x04);
816 input_report_key(input
, BTN_0
, (data
[5] & 0x01));
817 input_report_key(input
, BTN_1
, (data
[5] & 0x02));
818 input_report_key(input
, BTN_2
, (data
[5] & 0x04));
819 input_report_key(input
, BTN_3
, (data
[5] & 0x08));
820 input_report_key(input
, BTN_4
, (data
[6] & 0x01));
821 input_report_key(input
, BTN_5
, (data
[6] & 0x02));
822 input_report_key(input
, BTN_6
, (data
[6] & 0x04));
823 input_report_key(input
, BTN_7
, (data
[6] & 0x08));
824 input_report_key(input
, BTN_8
, (data
[5] & 0x10));
825 input_report_key(input
, BTN_9
, (data
[6] & 0x10));
827 input_report_abs(input
, ABS_RX
, ((data
[1] & 0x1f) << 8) | data
[2]);
828 input_report_abs(input
, ABS_RY
, ((data
[3] & 0x1f) << 8) | data
[4]);
830 if ((data
[5] & 0x1f) | data
[6] | (data
[1] & 0x1f) |
831 data
[2] | (data
[3] & 0x1f) | data
[4] | data
[8] |
833 input_report_abs(input
, ABS_MISC
, PAD_DEVICE_ID
);
835 input_report_abs(input
, ABS_MISC
, 0);
841 /* process in/out prox events */
842 result
= wacom_intuos_inout(wacom
);
846 /* don't proceed if we don't know the ID */
850 /* Only large Intuos support Lense Cursor */
851 if (wacom
->tool
[idx
] == BTN_TOOL_LENS
&&
852 (features
->type
== INTUOS3
||
853 features
->type
== INTUOS3S
||
854 features
->type
== INTUOS4
||
855 features
->type
== INTUOS4S
||
856 features
->type
== INTUOS5
||
857 features
->type
== INTUOS5S
||
858 features
->type
== INTUOSPM
||
859 features
->type
== INTUOSPS
)) {
864 /* Cintiq doesn't send data when RDY bit isn't set */
865 if (features
->type
== CINTIQ
&& !(data
[1] & 0x40))
868 if (features
->type
>= INTUOS3S
) {
869 input_report_abs(input
, ABS_X
, (data
[2] << 9) | (data
[3] << 1) | ((data
[9] >> 1) & 1));
870 input_report_abs(input
, ABS_Y
, (data
[4] << 9) | (data
[5] << 1) | (data
[9] & 1));
871 input_report_abs(input
, ABS_DISTANCE
, ((data
[9] >> 2) & 0x3f));
873 input_report_abs(input
, ABS_X
, be16_to_cpup((__be16
*)&data
[2]));
874 input_report_abs(input
, ABS_Y
, be16_to_cpup((__be16
*)&data
[4]));
875 input_report_abs(input
, ABS_DISTANCE
, ((data
[9] >> 3) & 0x1f));
878 /* process general packets */
879 wacom_intuos_general(wacom
);
881 /* 4D mouse, 2D mouse, marker pen rotation, tilt mouse, or Lens cursor packets */
882 if ((data
[1] & 0xbc) == 0xa8 || (data
[1] & 0xbe) == 0xb0 || (data
[1] & 0xbc) == 0xac) {
884 if (data
[1] & 0x02) {
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 rotation 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);
899 } else if (!(data
[1] & 0x10) && features
->type
< INTUOS3S
) {
900 /* 4D mouse packet */
901 input_report_key(input
, BTN_LEFT
, data
[8] & 0x01);
902 input_report_key(input
, BTN_MIDDLE
, data
[8] & 0x02);
903 input_report_key(input
, BTN_RIGHT
, data
[8] & 0x04);
905 input_report_key(input
, BTN_SIDE
, data
[8] & 0x20);
906 input_report_key(input
, BTN_EXTRA
, data
[8] & 0x10);
907 t
= (data
[6] << 2) | ((data
[7] >> 6) & 3);
908 input_report_abs(input
, ABS_THROTTLE
, (data
[8] & 0x08) ? -t
: t
);
910 } else if (wacom
->tool
[idx
] == BTN_TOOL_MOUSE
) {
912 if (features
->type
>= INTUOS4S
&& features
->type
<= INTUOSPL
) {
913 input_report_key(input
, BTN_LEFT
, data
[6] & 0x01);
914 input_report_key(input
, BTN_MIDDLE
, data
[6] & 0x02);
915 input_report_key(input
, BTN_RIGHT
, data
[6] & 0x04);
916 input_report_rel(input
, REL_WHEEL
, ((data
[7] & 0x80) >> 7)
917 - ((data
[7] & 0x40) >> 6));
918 input_report_key(input
, BTN_SIDE
, data
[6] & 0x08);
919 input_report_key(input
, BTN_EXTRA
, data
[6] & 0x10);
921 input_report_abs(input
, ABS_TILT_X
,
922 (((data
[7] << 1) & 0x7e) | (data
[8] >> 7)) - 64);
923 input_report_abs(input
, ABS_TILT_Y
, (data
[8] & 0x7f) - 64);
925 /* 2D mouse packet */
926 input_report_key(input
, BTN_LEFT
, data
[8] & 0x04);
927 input_report_key(input
, BTN_MIDDLE
, data
[8] & 0x08);
928 input_report_key(input
, BTN_RIGHT
, data
[8] & 0x10);
929 input_report_rel(input
, REL_WHEEL
, (data
[8] & 0x01)
930 - ((data
[8] & 0x02) >> 1));
932 /* I3 2D mouse side buttons */
933 if (features
->type
>= INTUOS3S
&& features
->type
<= INTUOS3L
) {
934 input_report_key(input
, BTN_SIDE
, data
[8] & 0x40);
935 input_report_key(input
, BTN_EXTRA
, data
[8] & 0x20);
938 } else if ((features
->type
< INTUOS3S
|| features
->type
== INTUOS3L
||
939 features
->type
== INTUOS4L
|| features
->type
== INTUOS5L
||
940 features
->type
== INTUOSPL
) &&
941 wacom
->tool
[idx
] == BTN_TOOL_LENS
) {
942 /* Lens cursor packets */
943 input_report_key(input
, BTN_LEFT
, data
[8] & 0x01);
944 input_report_key(input
, BTN_MIDDLE
, data
[8] & 0x02);
945 input_report_key(input
, BTN_RIGHT
, data
[8] & 0x04);
946 input_report_key(input
, BTN_SIDE
, data
[8] & 0x10);
947 input_report_key(input
, BTN_EXTRA
, data
[8] & 0x08);
951 input_report_abs(input
, ABS_MISC
, wacom
->id
[idx
]); /* report tool id */
952 input_report_key(input
, wacom
->tool
[idx
], 1);
953 input_event(input
, EV_MSC
, MSC_SERIAL
, wacom
->serial
[idx
]);
957 static int int_dist(int x1
, int y1
, int x2
, int y2
)
962 return int_sqrt(x
*x
+ y
*y
);
965 static void wacom_intuos_bt_process_data(struct wacom_wac
*wacom
,
968 memcpy(wacom
->data
, data
, 10);
969 wacom_intuos_irq(wacom
);
971 input_sync(wacom
->input
);
972 if (wacom
->pad_input
)
973 input_sync(wacom
->pad_input
);
976 static int wacom_intuos_bt_irq(struct wacom_wac
*wacom
, size_t len
)
978 unsigned char data
[WACOM_PKGLEN_MAX
];
980 unsigned power_raw
, battery_capacity
, bat_charging
, ps_connected
;
982 memcpy(data
, wacom
->data
, len
);
986 wacom_intuos_bt_process_data(wacom
, data
+ i
);
990 wacom_intuos_bt_process_data(wacom
, data
+ i
);
992 wacom_intuos_bt_process_data(wacom
, data
+ i
);
995 bat_charging
= (power_raw
& 0x08) ? 1 : 0;
996 ps_connected
= (power_raw
& 0x10) ? 1 : 0;
997 battery_capacity
= batcap_i4
[power_raw
& 0x07];
998 if ((wacom
->battery_capacity
!= battery_capacity
) ||
999 (wacom
->bat_charging
!= bat_charging
) ||
1000 (wacom
->ps_connected
!= ps_connected
)) {
1001 wacom
->battery_capacity
= battery_capacity
;
1002 wacom
->bat_charging
= bat_charging
;
1003 wacom
->ps_connected
= ps_connected
;
1004 wacom_notify_battery(wacom
);
1009 dev_dbg(wacom
->input
->dev
.parent
,
1010 "Unknown report: %d,%d size:%zu\n",
1011 data
[0], data
[1], len
);
1017 static int wacom_24hdt_irq(struct wacom_wac
*wacom
)
1019 struct input_dev
*input
= wacom
->input
;
1020 unsigned char *data
= wacom
->data
;
1022 int current_num_contacts
= data
[61];
1023 int contacts_to_send
= 0;
1026 * First packet resets the counter since only the first
1027 * packet in series will have non-zero current_num_contacts.
1029 if (current_num_contacts
)
1030 wacom
->num_contacts_left
= current_num_contacts
;
1032 /* There are at most 4 contacts per packet */
1033 contacts_to_send
= min(4, wacom
->num_contacts_left
);
1035 for (i
= 0; i
< contacts_to_send
; i
++) {
1036 int offset
= (WACOM_BYTES_PER_24HDT_PACKET
* i
) + 1;
1037 bool touch
= data
[offset
] & 0x1 && !wacom
->shared
->stylus_in_proximity
;
1038 int slot
= input_mt_get_slot_by_key(input
, data
[offset
+ 1]);
1042 input_mt_slot(input
, slot
);
1043 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, touch
);
1046 int t_x
= get_unaligned_le16(&data
[offset
+ 2]);
1047 int c_x
= get_unaligned_le16(&data
[offset
+ 4]);
1048 int t_y
= get_unaligned_le16(&data
[offset
+ 6]);
1049 int c_y
= get_unaligned_le16(&data
[offset
+ 8]);
1050 int w
= get_unaligned_le16(&data
[offset
+ 10]);
1051 int h
= get_unaligned_le16(&data
[offset
+ 12]);
1053 input_report_abs(input
, ABS_MT_POSITION_X
, t_x
);
1054 input_report_abs(input
, ABS_MT_POSITION_Y
, t_y
);
1055 input_report_abs(input
, ABS_MT_TOUCH_MAJOR
, min(w
,h
));
1056 input_report_abs(input
, ABS_MT_WIDTH_MAJOR
, min(w
, h
) + int_dist(t_x
, t_y
, c_x
, c_y
));
1057 input_report_abs(input
, ABS_MT_WIDTH_MINOR
, min(w
, h
));
1058 input_report_abs(input
, ABS_MT_ORIENTATION
, w
> h
);
1061 input_mt_report_pointer_emulation(input
, true);
1063 wacom
->num_contacts_left
-= contacts_to_send
;
1064 if (wacom
->num_contacts_left
<= 0)
1065 wacom
->num_contacts_left
= 0;
1070 static int wacom_mt_touch(struct wacom_wac
*wacom
)
1072 struct input_dev
*input
= wacom
->input
;
1073 unsigned char *data
= wacom
->data
;
1075 int current_num_contacts
= data
[2];
1076 int contacts_to_send
= 0;
1079 /* MTTPC does not support Height and Width */
1080 if (wacom
->features
.type
== MTTPC
|| wacom
->features
.type
== MTTPC_B
)
1084 * First packet resets the counter since only the first
1085 * packet in series will have non-zero current_num_contacts.
1087 if (current_num_contacts
)
1088 wacom
->num_contacts_left
= current_num_contacts
;
1090 /* There are at most 5 contacts per packet */
1091 contacts_to_send
= min(5, wacom
->num_contacts_left
);
1093 for (i
= 0; i
< contacts_to_send
; i
++) {
1094 int offset
= (WACOM_BYTES_PER_MT_PACKET
+ x_offset
) * i
+ 3;
1095 bool touch
= data
[offset
] & 0x1;
1096 int id
= get_unaligned_le16(&data
[offset
+ 1]);
1097 int slot
= input_mt_get_slot_by_key(input
, id
);
1102 input_mt_slot(input
, slot
);
1103 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, touch
);
1105 int x
= get_unaligned_le16(&data
[offset
+ x_offset
+ 7]);
1106 int y
= get_unaligned_le16(&data
[offset
+ x_offset
+ 9]);
1107 input_report_abs(input
, ABS_MT_POSITION_X
, x
);
1108 input_report_abs(input
, ABS_MT_POSITION_Y
, y
);
1111 input_mt_report_pointer_emulation(input
, true);
1113 wacom
->num_contacts_left
-= contacts_to_send
;
1114 if (wacom
->num_contacts_left
< 0)
1115 wacom
->num_contacts_left
= 0;
1120 static int wacom_tpc_mt_touch(struct wacom_wac
*wacom
)
1122 struct input_dev
*input
= wacom
->input
;
1123 unsigned char *data
= wacom
->data
;
1124 int contact_with_no_pen_down_count
= 0;
1127 for (i
= 0; i
< 2; i
++) {
1128 int p
= data
[1] & (1 << i
);
1129 bool touch
= p
&& !wacom
->shared
->stylus_in_proximity
;
1131 input_mt_slot(input
, i
);
1132 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, touch
);
1134 int x
= le16_to_cpup((__le16
*)&data
[i
* 2 + 2]) & 0x7fff;
1135 int y
= le16_to_cpup((__le16
*)&data
[i
* 2 + 6]) & 0x7fff;
1137 input_report_abs(input
, ABS_MT_POSITION_X
, x
);
1138 input_report_abs(input
, ABS_MT_POSITION_Y
, y
);
1139 contact_with_no_pen_down_count
++;
1142 input_mt_report_pointer_emulation(input
, true);
1144 /* keep touch state for pen event */
1145 wacom
->shared
->touch_down
= (contact_with_no_pen_down_count
> 0);
1150 static int wacom_tpc_single_touch(struct wacom_wac
*wacom
, size_t len
)
1152 unsigned char *data
= wacom
->data
;
1153 struct input_dev
*input
= wacom
->input
;
1157 if (wacom
->features
.touch_max
> 1 || len
> WACOM_PKGLEN_TPC2FG
)
1160 if (!wacom
->shared
->stylus_in_proximity
) {
1161 if (len
== WACOM_PKGLEN_TPC1FG
) {
1162 prox
= data
[0] & 0x01;
1163 x
= get_unaligned_le16(&data
[1]);
1164 y
= get_unaligned_le16(&data
[3]);
1165 } else if (len
== WACOM_PKGLEN_TPC1FG_B
) {
1166 prox
= data
[2] & 0x01;
1167 x
= get_unaligned_le16(&data
[3]);
1168 y
= get_unaligned_le16(&data
[5]);
1170 prox
= data
[1] & 0x01;
1171 x
= le16_to_cpup((__le16
*)&data
[2]);
1172 y
= le16_to_cpup((__le16
*)&data
[4]);
1175 /* force touch out when pen is in prox */
1179 input_report_abs(input
, ABS_X
, x
);
1180 input_report_abs(input
, ABS_Y
, y
);
1182 input_report_key(input
, BTN_TOUCH
, prox
);
1184 /* keep touch state for pen events */
1185 wacom
->shared
->touch_down
= prox
;
1190 static int wacom_tpc_pen(struct wacom_wac
*wacom
)
1192 unsigned char *data
= wacom
->data
;
1193 struct input_dev
*input
= wacom
->input
;
1194 bool prox
= data
[1] & 0x20;
1196 if (!wacom
->shared
->stylus_in_proximity
) /* first in prox */
1197 /* Going into proximity select tool */
1198 wacom
->tool
[0] = (data
[1] & 0x0c) ? BTN_TOOL_RUBBER
: BTN_TOOL_PEN
;
1200 /* keep pen state for touch events */
1201 wacom
->shared
->stylus_in_proximity
= prox
;
1203 /* send pen events only when touch is up or forced out */
1204 if (!wacom
->shared
->touch_down
) {
1205 input_report_key(input
, BTN_STYLUS
, data
[1] & 0x02);
1206 input_report_key(input
, BTN_STYLUS2
, data
[1] & 0x10);
1207 input_report_abs(input
, ABS_X
, le16_to_cpup((__le16
*)&data
[2]));
1208 input_report_abs(input
, ABS_Y
, le16_to_cpup((__le16
*)&data
[4]));
1209 input_report_abs(input
, ABS_PRESSURE
, ((data
[7] & 0x07) << 8) | data
[6]);
1210 input_report_key(input
, BTN_TOUCH
, data
[1] & 0x05);
1211 input_report_key(input
, wacom
->tool
[0], prox
);
1218 static int wacom_tpc_irq(struct wacom_wac
*wacom
, size_t len
)
1220 unsigned char *data
= wacom
->data
;
1222 dev_dbg(wacom
->input
->dev
.parent
,
1223 "%s: received report #%d\n", __func__
, data
[0]);
1226 case WACOM_PKGLEN_TPC1FG
:
1227 return wacom_tpc_single_touch(wacom
, len
);
1229 case WACOM_PKGLEN_TPC2FG
:
1230 return wacom_tpc_mt_touch(wacom
);
1232 case WACOM_PKGLEN_PENABLED
:
1233 return wacom_tpc_pen(wacom
);
1237 case WACOM_REPORT_TPC1FG
:
1238 case WACOM_REPORT_TPCHID
:
1239 case WACOM_REPORT_TPCST
:
1240 case WACOM_REPORT_TPC1FGE
:
1241 return wacom_tpc_single_touch(wacom
, len
);
1243 case WACOM_REPORT_TPCMT
:
1244 case WACOM_REPORT_TPCMT2
:
1245 return wacom_mt_touch(wacom
);
1247 case WACOM_REPORT_PENABLED
:
1248 return wacom_tpc_pen(wacom
);
1255 static void wacom_map_usage(struct wacom
*wacom
, struct hid_usage
*usage
,
1256 struct hid_field
*field
, __u8 type
, __u16 code
, int fuzz
)
1258 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1259 struct input_dev
*input
= wacom_wac
->input
;
1260 int fmin
= field
->logical_minimum
;
1261 int fmax
= field
->logical_maximum
;
1266 set_bit(type
, input
->evbit
);
1270 input_set_abs_params(input
, code
, fmin
, fmax
, fuzz
, 0);
1271 input_abs_set_res(input
, code
,
1272 hidinput_calc_abs_res(field
, code
));
1275 input_set_capability(input
, EV_KEY
, code
);
1278 input_set_capability(input
, EV_MSC
, code
);
1283 static void wacom_wac_pen_usage_mapping(struct hid_device
*hdev
,
1284 struct hid_field
*field
, struct hid_usage
*usage
)
1286 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1288 switch (usage
->hid
) {
1290 wacom_map_usage(wacom
, usage
, field
, EV_ABS
, ABS_X
, 4);
1293 wacom_map_usage(wacom
, usage
, field
, EV_ABS
, ABS_Y
, 4);
1295 case HID_DG_TIPPRESSURE
:
1296 wacom_map_usage(wacom
, usage
, field
, EV_ABS
, ABS_PRESSURE
, 0);
1298 case HID_DG_INRANGE
:
1299 wacom_map_usage(wacom
, usage
, field
, EV_KEY
, BTN_TOOL_PEN
, 0);
1302 wacom_map_usage(wacom
, usage
, field
, EV_KEY
,
1303 BTN_TOOL_RUBBER
, 0);
1306 case HID_DG_TIPSWITCH
:
1307 wacom_map_usage(wacom
, usage
, field
, EV_KEY
, BTN_TOUCH
, 0);
1309 case HID_DG_BARRELSWITCH
:
1310 wacom_map_usage(wacom
, usage
, field
, EV_KEY
, BTN_STYLUS
, 0);
1312 case HID_DG_BARRELSWITCH2
:
1313 wacom_map_usage(wacom
, usage
, field
, EV_KEY
, BTN_STYLUS2
, 0);
1315 case HID_DG_TOOLSERIALNUMBER
:
1316 wacom_map_usage(wacom
, usage
, field
, EV_MSC
, MSC_SERIAL
, 0);
1321 static int wacom_wac_pen_event(struct hid_device
*hdev
, struct hid_field
*field
,
1322 struct hid_usage
*usage
, __s32 value
)
1324 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1325 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1326 struct input_dev
*input
= wacom_wac
->input
;
1328 /* checking which Tool / tip switch to send */
1329 switch (usage
->hid
) {
1330 case HID_DG_INRANGE
:
1331 wacom_wac
->hid_data
.inrange_state
= value
;
1334 wacom_wac
->hid_data
.invert_state
= value
;
1337 case HID_DG_TIPSWITCH
:
1338 wacom_wac
->hid_data
.tipswitch
|= value
;
1342 /* send pen events only when touch is up or forced out */
1343 if (!usage
->type
|| wacom_wac
->shared
->touch_down
)
1346 input_event(input
, usage
->type
, usage
->code
, value
);
1351 static void wacom_wac_pen_report(struct hid_device
*hdev
,
1352 struct hid_report
*report
)
1354 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1355 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1356 struct input_dev
*input
= wacom_wac
->input
;
1357 bool prox
= wacom_wac
->hid_data
.inrange_state
;
1359 if (!wacom_wac
->shared
->stylus_in_proximity
) /* first in prox */
1360 /* Going into proximity select tool */
1361 wacom_wac
->tool
[0] = wacom_wac
->hid_data
.invert_state
?
1362 BTN_TOOL_RUBBER
: BTN_TOOL_PEN
;
1364 /* keep pen state for touch events */
1365 wacom_wac
->shared
->stylus_in_proximity
= prox
;
1367 /* send pen events only when touch is up or forced out */
1368 if (!wacom_wac
->shared
->touch_down
) {
1369 input_report_key(input
, BTN_TOUCH
,
1370 wacom_wac
->hid_data
.tipswitch
);
1371 input_report_key(input
, wacom_wac
->tool
[0], prox
);
1373 wacom_wac
->hid_data
.tipswitch
= false;
1379 static void wacom_wac_finger_usage_mapping(struct hid_device
*hdev
,
1380 struct hid_field
*field
, struct hid_usage
*usage
)
1382 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1383 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1384 struct wacom_features
*features
= &wacom_wac
->features
;
1385 unsigned touch_max
= wacom_wac
->features
.touch_max
;
1387 switch (usage
->hid
) {
1389 features
->last_slot_field
= usage
->hid
;
1391 wacom_map_usage(wacom
, usage
, field
, EV_ABS
, ABS_X
, 4);
1393 wacom_map_usage(wacom
, usage
, field
, EV_ABS
,
1394 ABS_MT_POSITION_X
, 4);
1397 features
->last_slot_field
= usage
->hid
;
1399 wacom_map_usage(wacom
, usage
, field
, EV_ABS
, ABS_Y
, 4);
1401 wacom_map_usage(wacom
, usage
, field
, EV_ABS
,
1402 ABS_MT_POSITION_Y
, 4);
1404 case HID_DG_CONTACTID
:
1405 features
->last_slot_field
= usage
->hid
;
1407 case HID_DG_INRANGE
:
1408 features
->last_slot_field
= usage
->hid
;
1411 features
->last_slot_field
= usage
->hid
;
1413 case HID_DG_TIPSWITCH
:
1414 features
->last_slot_field
= usage
->hid
;
1415 wacom_map_usage(wacom
, usage
, field
, EV_KEY
, BTN_TOUCH
, 0);
1420 static void wacom_wac_finger_slot(struct wacom_wac
*wacom_wac
,
1421 struct input_dev
*input
)
1423 struct hid_data
*hid_data
= &wacom_wac
->hid_data
;
1424 bool mt
= wacom_wac
->features
.touch_max
> 1;
1425 bool prox
= hid_data
->tipswitch
&&
1426 !wacom_wac
->shared
->stylus_in_proximity
;
1431 slot
= input_mt_get_slot_by_key(input
, hid_data
->id
);
1432 input_mt_slot(input
, slot
);
1433 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, prox
);
1436 input_report_key(input
, BTN_TOUCH
, prox
);
1440 input_report_abs(input
, mt
? ABS_MT_POSITION_X
: ABS_X
,
1442 input_report_abs(input
, mt
? ABS_MT_POSITION_Y
: ABS_Y
,
1447 static int wacom_wac_finger_event(struct hid_device
*hdev
,
1448 struct hid_field
*field
, struct hid_usage
*usage
, __s32 value
)
1450 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1451 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1453 switch (usage
->hid
) {
1455 wacom_wac
->hid_data
.x
= value
;
1458 wacom_wac
->hid_data
.y
= value
;
1460 case HID_DG_CONTACTID
:
1461 wacom_wac
->hid_data
.id
= value
;
1463 case HID_DG_TIPSWITCH
:
1464 wacom_wac
->hid_data
.tipswitch
= value
;
1469 if (usage
->usage_index
+ 1 == field
->report_count
) {
1470 if (usage
->hid
== wacom_wac
->features
.last_slot_field
)
1471 wacom_wac_finger_slot(wacom_wac
, wacom_wac
->input
);
1477 static int wacom_wac_finger_count_touches(struct hid_device
*hdev
)
1479 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1480 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1481 struct input_dev
*input
= wacom_wac
->input
;
1482 unsigned touch_max
= wacom_wac
->features
.touch_max
;
1487 return wacom_wac
->hid_data
.tipswitch
&&
1488 !wacom_wac
->shared
->stylus_in_proximity
;
1490 for (i
= 0; i
< input
->mt
->num_slots
; i
++) {
1491 struct input_mt_slot
*ps
= &input
->mt
->slots
[i
];
1492 int id
= input_mt_get_value(ps
, ABS_MT_TRACKING_ID
);
1500 static void wacom_wac_finger_report(struct hid_device
*hdev
,
1501 struct hid_report
*report
)
1503 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1504 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1505 struct input_dev
*input
= wacom_wac
->input
;
1506 unsigned touch_max
= wacom_wac
->features
.touch_max
;
1509 input_mt_sync_frame(input
);
1513 /* keep touch state for pen event */
1514 wacom_wac
->shared
->touch_down
= wacom_wac_finger_count_touches(hdev
);
1517 #define WACOM_PEN_FIELD(f) (((f)->logical == HID_DG_STYLUS) || \
1518 ((f)->physical == HID_DG_STYLUS) || \
1519 ((f)->application == HID_DG_PEN))
1520 #define WACOM_FINGER_FIELD(f) (((f)->logical == HID_DG_FINGER) || \
1521 ((f)->physical == HID_DG_FINGER) || \
1522 ((f)->application == HID_DG_TOUCHSCREEN))
1524 void wacom_wac_usage_mapping(struct hid_device
*hdev
,
1525 struct hid_field
*field
, struct hid_usage
*usage
)
1527 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1528 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1529 struct input_dev
*input
= wacom_wac
->input
;
1531 /* currently, only direct devices have proper hid report descriptors */
1532 __set_bit(INPUT_PROP_DIRECT
, input
->propbit
);
1534 if (WACOM_PEN_FIELD(field
))
1535 return wacom_wac_pen_usage_mapping(hdev
, field
, usage
);
1537 if (WACOM_FINGER_FIELD(field
))
1538 return wacom_wac_finger_usage_mapping(hdev
, field
, usage
);
1541 int wacom_wac_event(struct hid_device
*hdev
, struct hid_field
*field
,
1542 struct hid_usage
*usage
, __s32 value
)
1544 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1546 if (wacom
->wacom_wac
.features
.type
!= HID_GENERIC
)
1549 if (WACOM_PEN_FIELD(field
))
1550 return wacom_wac_pen_event(hdev
, field
, usage
, value
);
1552 if (WACOM_FINGER_FIELD(field
))
1553 return wacom_wac_finger_event(hdev
, field
, usage
, value
);
1558 void wacom_wac_report(struct hid_device
*hdev
, struct hid_report
*report
)
1560 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1561 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1562 struct hid_field
*field
= report
->field
[0];
1564 if (wacom_wac
->features
.type
!= HID_GENERIC
)
1567 if (WACOM_PEN_FIELD(field
))
1568 return wacom_wac_pen_report(hdev
, report
);
1570 if (WACOM_FINGER_FIELD(field
))
1571 return wacom_wac_finger_report(hdev
, report
);
1574 static int wacom_bpt_touch(struct wacom_wac
*wacom
)
1576 struct wacom_features
*features
= &wacom
->features
;
1577 struct input_dev
*input
= wacom
->input
;
1578 struct input_dev
*pad_input
= wacom
->pad_input
;
1579 unsigned char *data
= wacom
->data
;
1582 if (data
[0] != 0x02)
1585 for (i
= 0; i
< 2; i
++) {
1586 int offset
= (data
[1] & 0x80) ? (8 * i
) : (9 * i
);
1587 bool touch
= data
[offset
+ 3] & 0x80;
1590 * Touch events need to be disabled while stylus is
1591 * in proximity because user's hand is resting on touchpad
1592 * and sending unwanted events. User expects tablet buttons
1593 * to continue working though.
1595 touch
= touch
&& !wacom
->shared
->stylus_in_proximity
;
1597 input_mt_slot(input
, i
);
1598 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, touch
);
1600 int x
= get_unaligned_be16(&data
[offset
+ 3]) & 0x7ff;
1601 int y
= get_unaligned_be16(&data
[offset
+ 5]) & 0x7ff;
1602 if (features
->quirks
& WACOM_QUIRK_BBTOUCH_LOWRES
) {
1606 input_report_abs(input
, ABS_MT_POSITION_X
, x
);
1607 input_report_abs(input
, ABS_MT_POSITION_Y
, y
);
1611 input_mt_report_pointer_emulation(input
, true);
1613 input_report_key(pad_input
, BTN_LEFT
, (data
[1] & 0x08) != 0);
1614 input_report_key(pad_input
, BTN_FORWARD
, (data
[1] & 0x04) != 0);
1615 input_report_key(pad_input
, BTN_BACK
, (data
[1] & 0x02) != 0);
1616 input_report_key(pad_input
, BTN_RIGHT
, (data
[1] & 0x01) != 0);
1621 static void wacom_bpt3_touch_msg(struct wacom_wac
*wacom
, unsigned char *data
)
1623 struct wacom_features
*features
= &wacom
->features
;
1624 struct input_dev
*input
= wacom
->input
;
1625 bool touch
= data
[1] & 0x80;
1626 int slot
= input_mt_get_slot_by_key(input
, data
[0]);
1631 touch
= touch
&& !wacom
->shared
->stylus_in_proximity
;
1633 input_mt_slot(input
, slot
);
1634 input_mt_report_slot_state(input
, MT_TOOL_FINGER
, touch
);
1637 int x
= (data
[2] << 4) | (data
[4] >> 4);
1638 int y
= (data
[3] << 4) | (data
[4] & 0x0f);
1641 if (features
->type
>= INTUOSPS
&& features
->type
<= INTUOSPL
) {
1642 width
= data
[5] * 100;
1643 height
= data
[6] * 100;
1646 * "a" is a scaled-down area which we assume is
1647 * roughly circular and which can be described as:
1651 int x_res
= input_abs_get_res(input
, ABS_MT_POSITION_X
);
1652 int y_res
= input_abs_get_res(input
, ABS_MT_POSITION_Y
);
1653 width
= 2 * int_sqrt(a
* WACOM_CONTACT_AREA_SCALE
);
1654 height
= width
* y_res
/ x_res
;
1657 input_report_abs(input
, ABS_MT_POSITION_X
, x
);
1658 input_report_abs(input
, ABS_MT_POSITION_Y
, y
);
1659 input_report_abs(input
, ABS_MT_TOUCH_MAJOR
, width
);
1660 input_report_abs(input
, ABS_MT_TOUCH_MINOR
, height
);
1664 static void wacom_bpt3_button_msg(struct wacom_wac
*wacom
, unsigned char *data
)
1666 struct input_dev
*input
= wacom
->pad_input
;
1667 struct wacom_features
*features
= &wacom
->features
;
1669 if (features
->type
== INTUOSHT
) {
1670 input_report_key(input
, BTN_LEFT
, (data
[1] & 0x02) != 0);
1671 input_report_key(input
, BTN_BACK
, (data
[1] & 0x08) != 0);
1673 input_report_key(input
, BTN_BACK
, (data
[1] & 0x02) != 0);
1674 input_report_key(input
, BTN_LEFT
, (data
[1] & 0x08) != 0);
1676 input_report_key(input
, BTN_FORWARD
, (data
[1] & 0x04) != 0);
1677 input_report_key(input
, BTN_RIGHT
, (data
[1] & 0x01) != 0);
1680 static int wacom_bpt3_touch(struct wacom_wac
*wacom
)
1682 struct input_dev
*input
= wacom
->input
;
1683 unsigned char *data
= wacom
->data
;
1684 int count
= data
[1] & 0x07;
1687 if (data
[0] != 0x02)
1690 /* data has up to 7 fixed sized 8-byte messages starting at data[2] */
1691 for (i
= 0; i
< count
; i
++) {
1692 int offset
= (8 * i
) + 2;
1693 int msg_id
= data
[offset
];
1695 if (msg_id
>= 2 && msg_id
<= 17)
1696 wacom_bpt3_touch_msg(wacom
, data
+ offset
);
1697 else if (msg_id
== 128)
1698 wacom_bpt3_button_msg(wacom
, data
+ offset
);
1701 input_mt_report_pointer_emulation(input
, true);
1706 static int wacom_bpt_pen(struct wacom_wac
*wacom
)
1708 struct wacom_features
*features
= &wacom
->features
;
1709 struct input_dev
*input
= wacom
->input
;
1710 unsigned char *data
= wacom
->data
;
1711 int prox
= 0, x
= 0, y
= 0, p
= 0, d
= 0, pen
= 0, btn1
= 0, btn2
= 0;
1713 if (data
[0] != WACOM_REPORT_PENABLED
&& data
[0] != WACOM_REPORT_USB
)
1716 if (data
[0] == WACOM_REPORT_USB
) {
1717 if (features
->type
== INTUOSHT
&&
1718 wacom
->shared
->touch_input
&&
1719 features
->touch_max
) {
1720 input_report_switch(wacom
->shared
->touch_input
,
1721 SW_MUTE_DEVICE
, data
[8] & 0x40);
1722 input_sync(wacom
->shared
->touch_input
);
1727 prox
= (data
[1] & 0x20) == 0x20;
1730 * All reports shared between PEN and RUBBER tool must be
1731 * forced to a known starting value (zero) when transitioning to
1734 * If not reset then, to userspace, it will look like lost events
1735 * if new tool comes in-prox with same values as previous tool sent.
1737 * Hardware does report zero in most out-of-prox cases but not all.
1740 if (!wacom
->shared
->stylus_in_proximity
) {
1741 if (data
[1] & 0x08) {
1742 wacom
->tool
[0] = BTN_TOOL_RUBBER
;
1743 wacom
->id
[0] = ERASER_DEVICE_ID
;
1745 wacom
->tool
[0] = BTN_TOOL_PEN
;
1746 wacom
->id
[0] = STYLUS_DEVICE_ID
;
1748 wacom
->shared
->stylus_in_proximity
= true;
1750 x
= le16_to_cpup((__le16
*)&data
[2]);
1751 y
= le16_to_cpup((__le16
*)&data
[4]);
1752 p
= le16_to_cpup((__le16
*)&data
[6]);
1754 * Convert distance from out prox to distance from tablet.
1755 * distance will be greater than distance_max once
1756 * touching and applying pressure; do not report negative
1759 if (data
[8] <= features
->distance_max
)
1760 d
= features
->distance_max
- data
[8];
1762 pen
= data
[1] & 0x01;
1763 btn1
= data
[1] & 0x02;
1764 btn2
= data
[1] & 0x04;
1767 input_report_key(input
, BTN_TOUCH
, pen
);
1768 input_report_key(input
, BTN_STYLUS
, btn1
);
1769 input_report_key(input
, BTN_STYLUS2
, btn2
);
1771 input_report_abs(input
, ABS_X
, x
);
1772 input_report_abs(input
, ABS_Y
, y
);
1773 input_report_abs(input
, ABS_PRESSURE
, p
);
1774 input_report_abs(input
, ABS_DISTANCE
, d
);
1778 wacom
->shared
->stylus_in_proximity
= false;
1781 input_report_key(input
, wacom
->tool
[0], prox
); /* PEN or RUBBER */
1782 input_report_abs(input
, ABS_MISC
, wacom
->id
[0]); /* TOOL ID */
1787 static int wacom_bpt_irq(struct wacom_wac
*wacom
, size_t len
)
1789 if (len
== WACOM_PKGLEN_BBTOUCH
)
1790 return wacom_bpt_touch(wacom
);
1791 else if (len
== WACOM_PKGLEN_BBTOUCH3
)
1792 return wacom_bpt3_touch(wacom
);
1793 else if (len
== WACOM_PKGLEN_BBFUN
|| len
== WACOM_PKGLEN_BBPEN
)
1794 return wacom_bpt_pen(wacom
);
1799 static int wacom_wireless_irq(struct wacom_wac
*wacom
, size_t len
)
1801 unsigned char *data
= wacom
->data
;
1804 if (len
!= WACOM_PKGLEN_WIRELESS
|| data
[0] != WACOM_REPORT_WL
)
1807 connected
= data
[1] & 0x01;
1809 int pid
, battery
, ps_connected
;
1811 if ((wacom
->shared
->type
== INTUOSHT
) &&
1812 wacom
->shared
->touch_input
&&
1813 wacom
->shared
->touch_max
) {
1814 input_report_switch(wacom
->shared
->touch_input
,
1815 SW_MUTE_DEVICE
, data
[5] & 0x40);
1816 input_sync(wacom
->shared
->touch_input
);
1819 pid
= get_unaligned_be16(&data
[6]);
1820 battery
= (data
[5] & 0x3f) * 100 / 31;
1821 ps_connected
= !!(data
[5] & 0x80);
1822 if (wacom
->pid
!= pid
) {
1824 wacom_schedule_work(wacom
);
1827 if (wacom
->shared
->type
&&
1828 (battery
!= wacom
->battery_capacity
||
1829 ps_connected
!= wacom
->ps_connected
)) {
1830 wacom
->battery_capacity
= battery
;
1831 wacom
->ps_connected
= ps_connected
;
1832 wacom
->bat_charging
= ps_connected
&&
1833 wacom
->battery_capacity
< 100;
1834 wacom_notify_battery(wacom
);
1836 } else if (wacom
->pid
!= 0) {
1837 /* disconnected while previously connected */
1839 wacom_schedule_work(wacom
);
1840 wacom
->battery_capacity
= 0;
1841 wacom
->bat_charging
= 0;
1842 wacom
->ps_connected
= 0;
1848 void wacom_wac_irq(struct wacom_wac
*wacom_wac
, size_t len
)
1852 switch (wacom_wac
->features
.type
) {
1854 sync
= wacom_penpartner_irq(wacom_wac
);
1858 sync
= wacom_pl_irq(wacom_wac
);
1865 sync
= wacom_graphire_irq(wacom_wac
);
1869 sync
= wacom_ptu_irq(wacom_wac
);
1873 sync
= wacom_dtu_irq(wacom_wac
);
1878 sync
= wacom_dtus_irq(wacom_wac
);
1896 sync
= wacom_intuos_irq(wacom_wac
);
1900 sync
= wacom_intuos_bt_irq(wacom_wac
, len
);
1904 sync
= wacom_24hdt_irq(wacom_wac
);
1913 if (len
== WACOM_PKGLEN_BBTOUCH3
)
1914 sync
= wacom_bpt3_touch(wacom_wac
);
1916 sync
= wacom_intuos_irq(wacom_wac
);
1925 sync
= wacom_tpc_irq(wacom_wac
, len
);
1930 sync
= wacom_bpt_irq(wacom_wac
, len
);
1934 sync
= wacom_wireless_irq(wacom_wac
, len
);
1943 input_sync(wacom_wac
->input
);
1944 if (wacom_wac
->pad_input
)
1945 input_sync(wacom_wac
->pad_input
);
1949 static void wacom_setup_cintiq(struct wacom_wac
*wacom_wac
)
1951 struct input_dev
*input_dev
= wacom_wac
->input
;
1953 input_set_capability(input_dev
, EV_MSC
, MSC_SERIAL
);
1955 __set_bit(BTN_TOOL_RUBBER
, input_dev
->keybit
);
1956 __set_bit(BTN_TOOL_PEN
, input_dev
->keybit
);
1957 __set_bit(BTN_TOOL_BRUSH
, input_dev
->keybit
);
1958 __set_bit(BTN_TOOL_PENCIL
, input_dev
->keybit
);
1959 __set_bit(BTN_TOOL_AIRBRUSH
, input_dev
->keybit
);
1960 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
1961 __set_bit(BTN_STYLUS2
, input_dev
->keybit
);
1963 input_set_abs_params(input_dev
, ABS_DISTANCE
,
1964 0, wacom_wac
->features
.distance_max
, 0, 0);
1965 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 1023, 0, 0);
1966 input_set_abs_params(input_dev
, ABS_TILT_X
, -64, 63, 0, 0);
1967 input_abs_set_res(input_dev
, ABS_TILT_X
, 57);
1968 input_set_abs_params(input_dev
, ABS_TILT_Y
, -64, 63, 0, 0);
1969 input_abs_set_res(input_dev
, ABS_TILT_Y
, 57);
1972 static void wacom_setup_intuos(struct wacom_wac
*wacom_wac
)
1974 struct input_dev
*input_dev
= wacom_wac
->input
;
1976 input_set_capability(input_dev
, EV_REL
, REL_WHEEL
);
1978 wacom_setup_cintiq(wacom_wac
);
1980 __set_bit(BTN_LEFT
, input_dev
->keybit
);
1981 __set_bit(BTN_RIGHT
, input_dev
->keybit
);
1982 __set_bit(BTN_MIDDLE
, input_dev
->keybit
);
1983 __set_bit(BTN_SIDE
, input_dev
->keybit
);
1984 __set_bit(BTN_EXTRA
, input_dev
->keybit
);
1985 __set_bit(BTN_TOOL_MOUSE
, input_dev
->keybit
);
1986 __set_bit(BTN_TOOL_LENS
, input_dev
->keybit
);
1988 input_set_abs_params(input_dev
, ABS_RZ
, -900, 899, 0, 0);
1989 input_abs_set_res(input_dev
, ABS_RZ
, 287);
1990 input_set_abs_params(input_dev
, ABS_THROTTLE
, -1023, 1023, 0, 0);
1993 void wacom_setup_device_quirks(struct wacom_features
*features
)
1996 /* touch device found but size is not defined. use default */
1997 if (features
->device_type
== BTN_TOOL_FINGER
&& !features
->x_max
) {
1998 features
->x_max
= 1023;
1999 features
->y_max
= 1023;
2002 /* these device have multiple inputs */
2003 if (features
->type
>= WIRELESS
||
2004 (features
->type
>= INTUOS5S
&& features
->type
<= INTUOSHT
) ||
2005 (features
->oVid
&& features
->oPid
))
2006 features
->quirks
|= WACOM_QUIRK_MULTI_INPUT
;
2008 /* quirk for bamboo touch with 2 low res touches */
2009 if (features
->type
== BAMBOO_PT
&&
2010 features
->pktlen
== WACOM_PKGLEN_BBTOUCH
) {
2011 features
->x_max
<<= 5;
2012 features
->y_max
<<= 5;
2013 features
->x_fuzz
<<= 5;
2014 features
->y_fuzz
<<= 5;
2015 features
->quirks
|= WACOM_QUIRK_BBTOUCH_LOWRES
;
2018 if (features
->type
== WIRELESS
) {
2020 /* monitor never has input and pen/touch have delayed create */
2021 features
->quirks
|= WACOM_QUIRK_NO_INPUT
;
2023 /* must be monitor interface if no device_type set */
2024 if (!features
->device_type
) {
2025 features
->quirks
|= WACOM_QUIRK_MONITOR
;
2026 features
->quirks
|= WACOM_QUIRK_BATTERY
;
2031 static void wacom_abs_set_axis(struct input_dev
*input_dev
,
2032 struct wacom_wac
*wacom_wac
)
2034 struct wacom_features
*features
= &wacom_wac
->features
;
2036 if (features
->device_type
== BTN_TOOL_PEN
) {
2037 input_set_abs_params(input_dev
, ABS_X
, features
->x_min
,
2038 features
->x_max
, features
->x_fuzz
, 0);
2039 input_set_abs_params(input_dev
, ABS_Y
, features
->y_min
,
2040 features
->y_max
, features
->y_fuzz
, 0);
2041 input_set_abs_params(input_dev
, ABS_PRESSURE
, 0,
2042 features
->pressure_max
, features
->pressure_fuzz
, 0);
2044 /* penabled devices have fixed resolution for each model */
2045 input_abs_set_res(input_dev
, ABS_X
, features
->x_resolution
);
2046 input_abs_set_res(input_dev
, ABS_Y
, features
->y_resolution
);
2048 if (features
->touch_max
== 1) {
2049 input_set_abs_params(input_dev
, ABS_X
, 0,
2050 features
->x_max
, features
->x_fuzz
, 0);
2051 input_set_abs_params(input_dev
, ABS_Y
, 0,
2052 features
->y_max
, features
->y_fuzz
, 0);
2053 input_abs_set_res(input_dev
, ABS_X
,
2054 features
->x_resolution
);
2055 input_abs_set_res(input_dev
, ABS_Y
,
2056 features
->y_resolution
);
2059 if (features
->touch_max
> 1) {
2060 input_set_abs_params(input_dev
, ABS_MT_POSITION_X
, 0,
2061 features
->x_max
, features
->x_fuzz
, 0);
2062 input_set_abs_params(input_dev
, ABS_MT_POSITION_Y
, 0,
2063 features
->y_max
, features
->y_fuzz
, 0);
2064 input_abs_set_res(input_dev
, ABS_MT_POSITION_X
,
2065 features
->x_resolution
);
2066 input_abs_set_res(input_dev
, ABS_MT_POSITION_Y
,
2067 features
->y_resolution
);
2072 int wacom_setup_pentouch_input_capabilities(struct input_dev
*input_dev
,
2073 struct wacom_wac
*wacom_wac
)
2075 struct wacom_features
*features
= &wacom_wac
->features
;
2077 input_dev
->evbit
[0] |= BIT_MASK(EV_KEY
) | BIT_MASK(EV_ABS
);
2079 if (features
->type
== HID_GENERIC
)
2080 /* setup has already been done */
2083 __set_bit(BTN_TOUCH
, input_dev
->keybit
);
2084 __set_bit(ABS_MISC
, input_dev
->absbit
);
2086 wacom_abs_set_axis(input_dev
, wacom_wac
);
2088 switch (features
->type
) {
2094 input_set_capability(input_dev
, EV_REL
, REL_WHEEL
);
2096 __set_bit(BTN_LEFT
, input_dev
->keybit
);
2097 __set_bit(BTN_RIGHT
, input_dev
->keybit
);
2098 __set_bit(BTN_MIDDLE
, input_dev
->keybit
);
2100 __set_bit(BTN_TOOL_RUBBER
, input_dev
->keybit
);
2101 __set_bit(BTN_TOOL_PEN
, input_dev
->keybit
);
2102 __set_bit(BTN_TOOL_MOUSE
, input_dev
->keybit
);
2103 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
2104 __set_bit(BTN_STYLUS2
, input_dev
->keybit
);
2106 __set_bit(INPUT_PROP_POINTER
, input_dev
->propbit
);
2110 __clear_bit(ABS_MISC
, input_dev
->absbit
);
2111 input_set_abs_params(input_dev
, ABS_DISTANCE
, 0,
2112 features
->distance_max
,
2115 input_set_capability(input_dev
, EV_REL
, REL_WHEEL
);
2117 __set_bit(BTN_LEFT
, input_dev
->keybit
);
2118 __set_bit(BTN_RIGHT
, input_dev
->keybit
);
2119 __set_bit(BTN_MIDDLE
, input_dev
->keybit
);
2121 __set_bit(BTN_TOOL_RUBBER
, input_dev
->keybit
);
2122 __set_bit(BTN_TOOL_PEN
, input_dev
->keybit
);
2123 __set_bit(BTN_TOOL_MOUSE
, input_dev
->keybit
);
2124 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
2125 __set_bit(BTN_STYLUS2
, input_dev
->keybit
);
2127 __set_bit(INPUT_PROP_POINTER
, input_dev
->propbit
);
2131 input_set_abs_params(input_dev
, ABS_Z
, -900, 899, 0, 0);
2132 input_abs_set_res(input_dev
, ABS_Z
, 287);
2133 input_set_abs_params(input_dev
, ABS_THROTTLE
, 0, 71, 0, 0);
2137 __set_bit(INPUT_PROP_DIRECT
, input_dev
->propbit
);
2139 wacom_setup_cintiq(wacom_wac
);
2146 input_set_abs_params(input_dev
, ABS_Z
, -900, 899, 0, 0);
2147 input_abs_set_res(input_dev
, ABS_Z
, 287);
2149 __set_bit(INPUT_PROP_DIRECT
, input_dev
->propbit
);
2151 wacom_setup_cintiq(wacom_wac
);
2155 input_set_abs_params(input_dev
, ABS_Z
, -900, 899, 0, 0);
2156 input_abs_set_res(input_dev
, ABS_Z
, 287);
2157 __set_bit(INPUT_PROP_DIRECT
, input_dev
->propbit
);
2158 wacom_setup_cintiq(wacom_wac
);
2164 input_set_abs_params(input_dev
, ABS_Z
, -900, 899, 0, 0);
2165 input_abs_set_res(input_dev
, ABS_Z
, 287);
2169 __set_bit(INPUT_PROP_POINTER
, input_dev
->propbit
);
2171 wacom_setup_intuos(wacom_wac
);
2180 __set_bit(INPUT_PROP_POINTER
, input_dev
->propbit
);
2182 if (features
->device_type
== BTN_TOOL_PEN
) {
2183 input_set_abs_params(input_dev
, ABS_DISTANCE
, 0,
2184 features
->distance_max
,
2187 input_set_abs_params(input_dev
, ABS_Z
, -900, 899, 0, 0);
2188 input_abs_set_res(input_dev
, ABS_Z
, 287);
2190 wacom_setup_intuos(wacom_wac
);
2191 } else if (features
->device_type
== BTN_TOOL_FINGER
) {
2192 __clear_bit(ABS_MISC
, input_dev
->absbit
);
2194 input_set_abs_params(input_dev
, ABS_MT_TOUCH_MAJOR
,
2195 0, features
->x_max
, 0, 0);
2196 input_set_abs_params(input_dev
, ABS_MT_TOUCH_MINOR
,
2197 0, features
->y_max
, 0, 0);
2198 input_mt_init_slots(input_dev
, features
->touch_max
, INPUT_MT_POINTER
);
2206 input_set_abs_params(input_dev
, ABS_Z
, -900, 899, 0, 0);
2207 input_abs_set_res(input_dev
, ABS_Z
, 287);
2208 wacom_setup_intuos(wacom_wac
);
2210 __set_bit(INPUT_PROP_POINTER
, input_dev
->propbit
);
2214 if (features
->device_type
== BTN_TOOL_FINGER
) {
2215 input_set_abs_params(input_dev
, ABS_MT_TOUCH_MAJOR
, 0, features
->x_max
, 0, 0);
2216 input_set_abs_params(input_dev
, ABS_MT_WIDTH_MAJOR
, 0, features
->x_max
, 0, 0);
2217 input_set_abs_params(input_dev
, ABS_MT_WIDTH_MINOR
, 0, features
->y_max
, 0, 0);
2218 input_set_abs_params(input_dev
, ABS_MT_ORIENTATION
, 0, 1, 0, 0);
2226 if (features
->device_type
== BTN_TOOL_FINGER
&& features
->touch_max
> 1)
2227 input_mt_init_slots(input_dev
, features
->touch_max
, INPUT_MT_DIRECT
);
2232 __clear_bit(ABS_MISC
, input_dev
->absbit
);
2234 __set_bit(INPUT_PROP_DIRECT
, input_dev
->propbit
);
2236 if (features
->device_type
!= BTN_TOOL_PEN
)
2237 break; /* no need to process stylus stuff */
2245 __set_bit(BTN_TOOL_PEN
, input_dev
->keybit
);
2246 __set_bit(BTN_TOOL_RUBBER
, input_dev
->keybit
);
2247 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
2248 __set_bit(BTN_STYLUS2
, input_dev
->keybit
);
2250 __set_bit(INPUT_PROP_DIRECT
, input_dev
->propbit
);
2254 __set_bit(BTN_STYLUS2
, input_dev
->keybit
);
2258 __set_bit(BTN_TOOL_PEN
, input_dev
->keybit
);
2259 __set_bit(BTN_TOOL_RUBBER
, input_dev
->keybit
);
2260 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
2262 __set_bit(INPUT_PROP_POINTER
, input_dev
->propbit
);
2266 if (features
->touch_max
&&
2267 features
->device_type
== BTN_TOOL_FINGER
) {
2268 input_dev
->evbit
[0] |= BIT_MASK(EV_SW
);
2269 __set_bit(SW_MUTE_DEVICE
, input_dev
->swbit
);
2274 __clear_bit(ABS_MISC
, input_dev
->absbit
);
2276 if (features
->device_type
== BTN_TOOL_FINGER
) {
2278 if (features
->touch_max
) {
2279 if (features
->pktlen
== WACOM_PKGLEN_BBTOUCH3
) {
2280 input_set_abs_params(input_dev
,
2282 0, features
->x_max
, 0, 0);
2283 input_set_abs_params(input_dev
,
2285 0, features
->y_max
, 0, 0);
2287 input_mt_init_slots(input_dev
, features
->touch_max
, INPUT_MT_POINTER
);
2289 /* buttons/keys only interface */
2290 __clear_bit(ABS_X
, input_dev
->absbit
);
2291 __clear_bit(ABS_Y
, input_dev
->absbit
);
2292 __clear_bit(BTN_TOUCH
, input_dev
->keybit
);
2294 /* PAD is setup by wacom_setup_pad_input_capabilities later */
2297 } else if (features
->device_type
== BTN_TOOL_PEN
) {
2298 __set_bit(INPUT_PROP_POINTER
, input_dev
->propbit
);
2299 __set_bit(BTN_TOOL_RUBBER
, input_dev
->keybit
);
2300 __set_bit(BTN_TOOL_PEN
, input_dev
->keybit
);
2301 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
2302 __set_bit(BTN_STYLUS2
, input_dev
->keybit
);
2303 input_set_abs_params(input_dev
, ABS_DISTANCE
, 0,
2304 features
->distance_max
,
2310 input_set_abs_params(input_dev
, ABS_Z
, -900, 899, 0, 0);
2311 input_abs_set_res(input_dev
, ABS_Z
, 287);
2312 __set_bit(INPUT_PROP_DIRECT
, input_dev
->propbit
);
2314 wacom_setup_cintiq(wacom_wac
);
2320 int wacom_setup_pad_input_capabilities(struct input_dev
*input_dev
,
2321 struct wacom_wac
*wacom_wac
)
2323 struct wacom_features
*features
= &wacom_wac
->features
;
2326 input_dev
->evbit
[0] |= BIT_MASK(EV_KEY
) | BIT_MASK(EV_ABS
);
2328 /* kept for making legacy xf86-input-wacom working with the wheels */
2329 __set_bit(ABS_MISC
, input_dev
->absbit
);
2331 /* kept for making legacy xf86-input-wacom accepting the pad */
2332 input_set_abs_params(input_dev
, ABS_X
, 0, 1, 0, 0);
2333 input_set_abs_params(input_dev
, ABS_Y
, 0, 1, 0, 0);
2335 /* kept for making udev and libwacom accepting the pad */
2336 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
2338 switch (features
->type
) {
2340 __set_bit(BTN_0
, input_dev
->keybit
);
2341 __set_bit(BTN_1
, input_dev
->keybit
);
2345 __set_bit(BTN_BACK
, input_dev
->keybit
);
2346 __set_bit(BTN_LEFT
, input_dev
->keybit
);
2347 __set_bit(BTN_FORWARD
, input_dev
->keybit
);
2348 __set_bit(BTN_RIGHT
, input_dev
->keybit
);
2349 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
2353 __set_bit(BTN_BACK
, input_dev
->keybit
);
2354 __set_bit(BTN_FORWARD
, input_dev
->keybit
);
2355 input_set_capability(input_dev
, EV_REL
, REL_WHEEL
);
2359 __set_bit(BTN_A
, input_dev
->keybit
);
2360 __set_bit(BTN_B
, input_dev
->keybit
);
2361 __set_bit(BTN_C
, input_dev
->keybit
);
2362 __set_bit(BTN_X
, input_dev
->keybit
);
2363 __set_bit(BTN_Y
, input_dev
->keybit
);
2364 __set_bit(BTN_Z
, input_dev
->keybit
);
2366 for (i
= 0; i
< 10; i
++)
2367 __set_bit(BTN_0
+ i
, input_dev
->keybit
);
2369 __set_bit(KEY_PROG1
, input_dev
->keybit
);
2370 __set_bit(KEY_PROG2
, input_dev
->keybit
);
2371 __set_bit(KEY_PROG3
, input_dev
->keybit
);
2373 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
2374 input_set_abs_params(input_dev
, ABS_THROTTLE
, 0, 71, 0, 0);
2378 for (i
= 0; i
< 6; i
++)
2379 __set_bit(BTN_0
+ i
, input_dev
->keybit
);
2384 __set_bit(KEY_PROG1
, input_dev
->keybit
);
2385 __set_bit(KEY_PROG2
, input_dev
->keybit
);
2386 __set_bit(KEY_PROG3
, input_dev
->keybit
);
2390 __set_bit(BTN_A
, input_dev
->keybit
);
2391 __set_bit(BTN_B
, input_dev
->keybit
);
2392 __set_bit(BTN_C
, input_dev
->keybit
);
2393 __set_bit(BTN_X
, input_dev
->keybit
);
2394 __set_bit(BTN_Y
, input_dev
->keybit
);
2395 __set_bit(BTN_Z
, input_dev
->keybit
);
2396 __set_bit(BTN_BASE
, input_dev
->keybit
);
2397 __set_bit(BTN_BASE2
, input_dev
->keybit
);
2401 __set_bit(BTN_8
, input_dev
->keybit
);
2402 __set_bit(BTN_9
, input_dev
->keybit
);
2406 for (i
= 0; i
< 8; i
++)
2407 __set_bit(BTN_0
+ i
, input_dev
->keybit
);
2409 input_set_abs_params(input_dev
, ABS_RX
, 0, 4096, 0, 0);
2410 input_set_abs_params(input_dev
, ABS_RY
, 0, 4096, 0, 0);
2414 for (i
= 0; i
< 9; i
++)
2415 __set_bit(BTN_0
+ i
, input_dev
->keybit
);
2417 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
2422 __set_bit(BTN_4
, input_dev
->keybit
);
2423 __set_bit(BTN_5
, input_dev
->keybit
);
2424 __set_bit(BTN_6
, input_dev
->keybit
);
2425 __set_bit(BTN_7
, input_dev
->keybit
);
2427 input_set_abs_params(input_dev
, ABS_RY
, 0, 4096, 0, 0);
2431 __set_bit(BTN_0
, input_dev
->keybit
);
2432 __set_bit(BTN_1
, input_dev
->keybit
);
2433 __set_bit(BTN_2
, input_dev
->keybit
);
2434 __set_bit(BTN_3
, input_dev
->keybit
);
2436 input_set_abs_params(input_dev
, ABS_RX
, 0, 4096, 0, 0);
2443 __set_bit(BTN_7
, input_dev
->keybit
);
2444 __set_bit(BTN_8
, input_dev
->keybit
);
2449 /* touch interface does not have the pad device */
2450 if (features
->device_type
!= BTN_TOOL_PEN
)
2453 for (i
= 0; i
< 7; i
++)
2454 __set_bit(BTN_0
+ i
, input_dev
->keybit
);
2456 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
2461 * For Bluetooth devices, the udev rule does not work correctly
2462 * for pads unless we add a stylus capability, which forces
2463 * ID_INPUT_TABLET to be set.
2465 __set_bit(BTN_STYLUS
, input_dev
->keybit
);
2470 __set_bit(BTN_7
, input_dev
->keybit
);
2471 __set_bit(BTN_8
, input_dev
->keybit
);
2475 for (i
= 0; i
< 7; i
++)
2476 __set_bit(BTN_0
+ i
, input_dev
->keybit
);
2478 input_set_abs_params(input_dev
, ABS_WHEEL
, 0, 71, 0, 0);
2482 for (i
= 0; i
< 9; i
++)
2483 __set_bit(BTN_0
+ i
, input_dev
->keybit
);
2488 for (i
= 0; i
< 4; i
++)
2489 __set_bit(BTN_0
+ i
, input_dev
->keybit
);
2494 /* pad device is on the touch interface */
2495 if ((features
->device_type
!= BTN_TOOL_FINGER
) ||
2496 /* Bamboo Pen only tablet does not have pad */
2497 ((features
->type
== BAMBOO_PT
) && !features
->touch_max
))
2500 __clear_bit(ABS_MISC
, input_dev
->absbit
);
2502 __set_bit(BTN_LEFT
, input_dev
->keybit
);
2503 __set_bit(BTN_FORWARD
, input_dev
->keybit
);
2504 __set_bit(BTN_BACK
, input_dev
->keybit
);
2505 __set_bit(BTN_RIGHT
, input_dev
->keybit
);
2510 /* no pad supported */
2516 static const struct wacom_features wacom_features_0x00
=
2517 { "Wacom Penpartner", 5040, 3780, 255, 0,
2518 PENPARTNER
, WACOM_PENPRTN_RES
, WACOM_PENPRTN_RES
};
2519 static const struct wacom_features wacom_features_0x10
=
2520 { "Wacom Graphire", 10206, 7422, 511, 63,
2521 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
2522 static const struct wacom_features wacom_features_0x81
=
2523 { "Wacom Graphire BT", 16704, 12064, 511, 32,
2524 GRAPHIRE_BT
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
2525 static const struct wacom_features wacom_features_0x11
=
2526 { "Wacom Graphire2 4x5", 10206, 7422, 511, 63,
2527 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
2528 static const struct wacom_features wacom_features_0x12
=
2529 { "Wacom Graphire2 5x7", 13918, 10206, 511, 63,
2530 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
2531 static const struct wacom_features wacom_features_0x13
=
2532 { "Wacom Graphire3", 10208, 7424, 511, 63,
2533 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
2534 static const struct wacom_features wacom_features_0x14
=
2535 { "Wacom Graphire3 6x8", 16704, 12064, 511, 63,
2536 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
2537 static const struct wacom_features wacom_features_0x15
=
2538 { "Wacom Graphire4 4x5", 10208, 7424, 511, 63,
2539 WACOM_G4
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
2540 static const struct wacom_features wacom_features_0x16
=
2541 { "Wacom Graphire4 6x8", 16704, 12064, 511, 63,
2542 WACOM_G4
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
2543 static const struct wacom_features wacom_features_0x17
=
2544 { "Wacom BambooFun 4x5", 14760, 9225, 511, 63,
2545 WACOM_MO
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2546 static const struct wacom_features wacom_features_0x18
=
2547 { "Wacom BambooFun 6x8", 21648, 13530, 511, 63,
2548 WACOM_MO
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2549 static const struct wacom_features wacom_features_0x19
=
2550 { "Wacom Bamboo1 Medium", 16704, 12064, 511, 63,
2551 GRAPHIRE
, WACOM_GRAPHIRE_RES
, WACOM_GRAPHIRE_RES
};
2552 static const struct wacom_features wacom_features_0x60
=
2553 { "Wacom Volito", 5104, 3712, 511, 63,
2554 GRAPHIRE
, WACOM_VOLITO_RES
, WACOM_VOLITO_RES
};
2555 static const struct wacom_features wacom_features_0x61
=
2556 { "Wacom PenStation2", 3250, 2320, 255, 63,
2557 GRAPHIRE
, WACOM_VOLITO_RES
, WACOM_VOLITO_RES
};
2558 static const struct wacom_features wacom_features_0x62
=
2559 { "Wacom Volito2 4x5", 5104, 3712, 511, 63,
2560 GRAPHIRE
, WACOM_VOLITO_RES
, WACOM_VOLITO_RES
};
2561 static const struct wacom_features wacom_features_0x63
=
2562 { "Wacom Volito2 2x3", 3248, 2320, 511, 63,
2563 GRAPHIRE
, WACOM_VOLITO_RES
, WACOM_VOLITO_RES
};
2564 static const struct wacom_features wacom_features_0x64
=
2565 { "Wacom PenPartner2", 3250, 2320, 511, 63,
2566 GRAPHIRE
, WACOM_VOLITO_RES
, WACOM_VOLITO_RES
};
2567 static const struct wacom_features wacom_features_0x65
=
2568 { "Wacom Bamboo", 14760, 9225, 511, 63,
2569 WACOM_MO
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2570 static const struct wacom_features wacom_features_0x69
=
2571 { "Wacom Bamboo1", 5104, 3712, 511, 63,
2572 GRAPHIRE
, WACOM_PENPRTN_RES
, WACOM_PENPRTN_RES
};
2573 static const struct wacom_features wacom_features_0x6A
=
2574 { "Wacom Bamboo1 4x6", 14760, 9225, 1023, 63,
2575 GRAPHIRE
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2576 static const struct wacom_features wacom_features_0x6B
=
2577 { "Wacom Bamboo1 5x8", 21648, 13530, 1023, 63,
2578 GRAPHIRE
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2579 static const struct wacom_features wacom_features_0x20
=
2580 { "Wacom Intuos 4x5", 12700, 10600, 1023, 31,
2581 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2582 static const struct wacom_features wacom_features_0x21
=
2583 { "Wacom Intuos 6x8", 20320, 16240, 1023, 31,
2584 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2585 static const struct wacom_features wacom_features_0x22
=
2586 { "Wacom Intuos 9x12", 30480, 24060, 1023, 31,
2587 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2588 static const struct wacom_features wacom_features_0x23
=
2589 { "Wacom Intuos 12x12", 30480, 31680, 1023, 31,
2590 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2591 static const struct wacom_features wacom_features_0x24
=
2592 { "Wacom Intuos 12x18", 45720, 31680, 1023, 31,
2593 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2594 static const struct wacom_features wacom_features_0x30
=
2595 { "Wacom PL400", 5408, 4056, 255, 0,
2596 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
2597 static const struct wacom_features wacom_features_0x31
=
2598 { "Wacom PL500", 6144, 4608, 255, 0,
2599 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
2600 static const struct wacom_features wacom_features_0x32
=
2601 { "Wacom PL600", 6126, 4604, 255, 0,
2602 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
2603 static const struct wacom_features wacom_features_0x33
=
2604 { "Wacom PL600SX", 6260, 5016, 255, 0,
2605 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
2606 static const struct wacom_features wacom_features_0x34
=
2607 { "Wacom PL550", 6144, 4608, 511, 0,
2608 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
2609 static const struct wacom_features wacom_features_0x35
=
2610 { "Wacom PL800", 7220, 5780, 511, 0,
2611 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
2612 static const struct wacom_features wacom_features_0x37
=
2613 { "Wacom PL700", 6758, 5406, 511, 0,
2614 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
2615 static const struct wacom_features wacom_features_0x38
=
2616 { "Wacom PL510", 6282, 4762, 511, 0,
2617 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
2618 static const struct wacom_features wacom_features_0x39
=
2619 { "Wacom DTU710", 34080, 27660, 511, 0,
2620 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
2621 static const struct wacom_features wacom_features_0xC4
=
2622 { "Wacom DTF521", 6282, 4762, 511, 0,
2623 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
2624 static const struct wacom_features wacom_features_0xC0
=
2625 { "Wacom DTF720", 6858, 5506, 511, 0,
2626 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
2627 static const struct wacom_features wacom_features_0xC2
=
2628 { "Wacom DTF720a", 6858, 5506, 511, 0,
2629 PL
, WACOM_PL_RES
, WACOM_PL_RES
};
2630 static const struct wacom_features wacom_features_0x03
=
2631 { "Wacom Cintiq Partner", 20480, 15360, 511, 0,
2632 PTU
, WACOM_PL_RES
, WACOM_PL_RES
};
2633 static const struct wacom_features wacom_features_0x41
=
2634 { "Wacom Intuos2 4x5", 12700, 10600, 1023, 31,
2635 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2636 static const struct wacom_features wacom_features_0x42
=
2637 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
2638 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2639 static const struct wacom_features wacom_features_0x43
=
2640 { "Wacom Intuos2 9x12", 30480, 24060, 1023, 31,
2641 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2642 static const struct wacom_features wacom_features_0x44
=
2643 { "Wacom Intuos2 12x12", 30480, 31680, 1023, 31,
2644 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2645 static const struct wacom_features wacom_features_0x45
=
2646 { "Wacom Intuos2 12x18", 45720, 31680, 1023, 31,
2647 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2648 static const struct wacom_features wacom_features_0xB0
=
2649 { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63,
2650 INTUOS3S
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
};
2651 static const struct wacom_features wacom_features_0xB1
=
2652 { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63,
2653 INTUOS3
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
};
2654 static const struct wacom_features wacom_features_0xB2
=
2655 { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63,
2656 INTUOS3
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
};
2657 static const struct wacom_features wacom_features_0xB3
=
2658 { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63,
2659 INTUOS3L
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
};
2660 static const struct wacom_features wacom_features_0xB4
=
2661 { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63,
2662 INTUOS3L
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
};
2663 static const struct wacom_features wacom_features_0xB5
=
2664 { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63,
2665 INTUOS3
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
};
2666 static const struct wacom_features wacom_features_0xB7
=
2667 { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63,
2668 INTUOS3S
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
};
2669 static const struct wacom_features wacom_features_0xB8
=
2670 { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63,
2671 INTUOS4S
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
};
2672 static const struct wacom_features wacom_features_0xB9
=
2673 { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63,
2674 INTUOS4
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
};
2675 static const struct wacom_features wacom_features_0xBA
=
2676 { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63,
2677 INTUOS4L
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
};
2678 static const struct wacom_features wacom_features_0xBB
=
2679 { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63,
2680 INTUOS4L
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
};
2681 static const struct wacom_features wacom_features_0xBC
=
2682 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
2683 INTUOS4
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
};
2684 static const struct wacom_features wacom_features_0xBD
=
2685 { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
2686 INTUOS4WL
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
};
2687 static const struct wacom_features wacom_features_0x26
=
2688 { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63,
2689 INTUOS5S
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, .touch_max
= 16 };
2690 static const struct wacom_features wacom_features_0x27
=
2691 { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63,
2692 INTUOS5
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, .touch_max
= 16 };
2693 static const struct wacom_features wacom_features_0x28
=
2694 { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63,
2695 INTUOS5L
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, .touch_max
= 16 };
2696 static const struct wacom_features wacom_features_0x29
=
2697 { "Wacom Intuos5 S", 31496, 19685, 2047, 63,
2698 INTUOS5S
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
};
2699 static const struct wacom_features wacom_features_0x2A
=
2700 { "Wacom Intuos5 M", 44704, 27940, 2047, 63,
2701 INTUOS5
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
};
2702 static const struct wacom_features wacom_features_0x314
=
2703 { "Wacom Intuos Pro S", 31496, 19685, 2047, 63,
2704 INTUOSPS
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, .touch_max
= 16,
2705 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
2706 static const struct wacom_features wacom_features_0x315
=
2707 { "Wacom Intuos Pro M", 44704, 27940, 2047, 63,
2708 INTUOSPM
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, .touch_max
= 16,
2709 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
2710 static const struct wacom_features wacom_features_0x317
=
2711 { "Wacom Intuos Pro L", 65024, 40640, 2047, 63,
2712 INTUOSPL
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
, .touch_max
= 16,
2713 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
2714 static const struct wacom_features wacom_features_0xF4
=
2715 { "Wacom Cintiq 24HD", 104080, 65200, 2047, 63,
2716 WACOM_24HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
,
2717 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
2718 static const struct wacom_features wacom_features_0xF8
=
2719 { "Wacom Cintiq 24HD touch", 104080, 65200, 2047, 63, /* Pen */
2720 WACOM_24HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
,
2721 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
2722 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0xf6 };
2723 static const struct wacom_features wacom_features_0xF6
=
2724 { "Wacom Cintiq 24HD touch", .type
= WACOM_24HDT
, /* Touch */
2725 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0xf8, .touch_max
= 10,
2726 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
2727 static const struct wacom_features wacom_features_0x3F
=
2728 { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63,
2729 CINTIQ
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
};
2730 static const struct wacom_features wacom_features_0xC5
=
2731 { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63,
2732 WACOM_BEE
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
};
2733 static const struct wacom_features wacom_features_0xC6
=
2734 { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63,
2735 WACOM_BEE
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
};
2736 static const struct wacom_features wacom_features_0x304
=
2737 { "Wacom Cintiq 13HD", 59152, 33448, 1023, 63,
2738 WACOM_13HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
,
2739 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
2740 static const struct wacom_features wacom_features_0xC7
=
2741 { "Wacom DTU1931", 37832, 30305, 511, 0,
2742 PL
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2743 static const struct wacom_features wacom_features_0xCE
=
2744 { "Wacom DTU2231", 47864, 27011, 511, 0,
2745 DTU
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
,
2746 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBMOUSE
};
2747 static const struct wacom_features wacom_features_0xF0
=
2748 { "Wacom DTU1631", 34623, 19553, 511, 0,
2749 DTU
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2750 static const struct wacom_features wacom_features_0xFB
=
2751 { "Wacom DTU1031", 21896, 13760, 511, 0,
2752 DTUS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
,
2753 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
};
2754 static const struct wacom_features wacom_features_0x32F
=
2755 { "Wacom DTU1031X", 22472, 12728, 511, 0,
2756 DTUSX
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
,
2757 WACOM_DTU_OFFSET
, WACOM_DTU_OFFSET
};
2758 static const struct wacom_features wacom_features_0x57
=
2759 { "Wacom DTK2241", 95640, 54060, 2047, 63,
2760 DTK
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
,
2761 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
2762 static const struct wacom_features wacom_features_0x59
= /* Pen */
2763 { "Wacom DTH2242", 95640, 54060, 2047, 63,
2764 DTK
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
,
2765 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
2766 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x5D };
2767 static const struct wacom_features wacom_features_0x5D
= /* Touch */
2768 { "Wacom DTH2242", .type
= WACOM_24HDT
,
2769 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x59, .touch_max
= 10,
2770 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
2771 static const struct wacom_features wacom_features_0xCC
=
2772 { "Wacom Cintiq 21UX2", 86800, 65200, 2047, 63,
2773 WACOM_21UX2
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
,
2774 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
2775 static const struct wacom_features wacom_features_0xFA
=
2776 { "Wacom Cintiq 22HD", 95440, 53860, 2047, 63,
2777 WACOM_22HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
,
2778 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
};
2779 static const struct wacom_features wacom_features_0x5B
=
2780 { "Wacom Cintiq 22HDT", 95440, 53860, 2047, 63,
2781 WACOM_22HD
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
,
2782 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
2783 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x5e };
2784 static const struct wacom_features wacom_features_0x5E
=
2785 { "Wacom Cintiq 22HDT", .type
= WACOM_24HDT
,
2786 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x5b, .touch_max
= 10,
2787 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
2788 static const struct wacom_features wacom_features_0x90
=
2789 { "Wacom ISDv4 90", 26202, 16325, 255, 0,
2790 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2791 static const struct wacom_features wacom_features_0x93
=
2792 { "Wacom ISDv4 93", 26202, 16325, 255, 0,
2793 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2794 static const struct wacom_features wacom_features_0x97
=
2795 { "Wacom ISDv4 97", 26202, 16325, 511, 0,
2796 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2797 static const struct wacom_features wacom_features_0x9A
=
2798 { "Wacom ISDv4 9A", 26202, 16325, 255, 0,
2799 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2800 static const struct wacom_features wacom_features_0x9F
=
2801 { "Wacom ISDv4 9F", 26202, 16325, 255, 0,
2802 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2803 static const struct wacom_features wacom_features_0xE2
=
2804 { "Wacom ISDv4 E2", 26202, 16325, 255, 0,
2805 TABLETPC2FG
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
2806 static const struct wacom_features wacom_features_0xE3
=
2807 { "Wacom ISDv4 E3", 26202, 16325, 255, 0,
2808 TABLETPC2FG
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
2809 static const struct wacom_features wacom_features_0xE5
=
2810 { "Wacom ISDv4 E5", 26202, 16325, 255, 0,
2811 MTSCREEN
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2812 static const struct wacom_features wacom_features_0xE6
=
2813 { "Wacom ISDv4 E6", 27760, 15694, 255, 0,
2814 TABLETPC2FG
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
2815 static const struct wacom_features wacom_features_0xEC
=
2816 { "Wacom ISDv4 EC", 25710, 14500, 255, 0,
2817 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2818 static const struct wacom_features wacom_features_0xED
=
2819 { "Wacom ISDv4 ED", 26202, 16325, 255, 0,
2820 TABLETPCE
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2821 static const struct wacom_features wacom_features_0xEF
=
2822 { "Wacom ISDv4 EF", 26202, 16325, 255, 0,
2823 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2824 static const struct wacom_features wacom_features_0x100
=
2825 { "Wacom ISDv4 100", 26202, 16325, 255, 0,
2826 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2827 static const struct wacom_features wacom_features_0x101
=
2828 { "Wacom ISDv4 101", 26202, 16325, 255, 0,
2829 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2830 static const struct wacom_features wacom_features_0x10D
=
2831 { "Wacom ISDv4 10D", 26202, 16325, 255, 0,
2832 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2833 static const struct wacom_features wacom_features_0x10E
=
2834 { "Wacom ISDv4 10E", 27760, 15694, 255, 0,
2835 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2836 static const struct wacom_features wacom_features_0x10F
=
2837 { "Wacom ISDv4 10F", 27760, 15694, 255, 0,
2838 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2839 static const struct wacom_features wacom_features_0x116
=
2840 { "Wacom ISDv4 116", 26202, 16325, 255, 0,
2841 TABLETPCE
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2842 static const struct wacom_features wacom_features_0x12C
=
2843 { "Wacom ISDv4 12C", 27848, 15752, 2047, 0,
2844 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2845 static const struct wacom_features wacom_features_0x4001
=
2846 { "Wacom ISDv4 4001", 26202, 16325, 255, 0,
2847 MTTPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2848 static const struct wacom_features wacom_features_0x4004
=
2849 { "Wacom ISDv4 4004", 11060, 6220, 255, 0,
2850 MTTPC_B
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2851 static const struct wacom_features wacom_features_0x5000
=
2852 { "Wacom ISDv4 5000", 27848, 15752, 1023, 0,
2853 MTTPC_B
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2854 static const struct wacom_features wacom_features_0x5002
=
2855 { "Wacom ISDv4 5002", 29576, 16724, 1023, 0,
2856 MTTPC_B
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2857 static const struct wacom_features wacom_features_0x47
=
2858 { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
2859 INTUOS
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2860 static const struct wacom_features wacom_features_0x84
=
2861 { "Wacom Wireless Receiver", 0, 0, 0, 0,
2862 WIRELESS
, 0, 0, .touch_max
= 16 };
2863 static const struct wacom_features wacom_features_0xD0
=
2864 { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31,
2865 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
2866 static const struct wacom_features wacom_features_0xD1
=
2867 { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31,
2868 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
2869 static const struct wacom_features wacom_features_0xD2
=
2870 { "Wacom Bamboo Craft", 14720, 9200, 1023, 31,
2871 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
2872 static const struct wacom_features wacom_features_0xD3
=
2873 { "Wacom Bamboo 2FG 6x8", 21648, 13700, 1023, 31,
2874 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
2875 static const struct wacom_features wacom_features_0xD4
=
2876 { "Wacom Bamboo Pen", 14720, 9200, 1023, 31,
2877 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2878 static const struct wacom_features wacom_features_0xD5
=
2879 { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31,
2880 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2881 static const struct wacom_features wacom_features_0xD6
=
2882 { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31,
2883 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
2884 static const struct wacom_features wacom_features_0xD7
=
2885 { "Wacom BambooPT 2FG Small", 14720, 9200, 1023, 31,
2886 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
2887 static const struct wacom_features wacom_features_0xD8
=
2888 { "Wacom Bamboo Comic 2FG", 21648, 13700, 1023, 31,
2889 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
2890 static const struct wacom_features wacom_features_0xDA
=
2891 { "Wacom Bamboo 2FG 4x5 SE", 14720, 9200, 1023, 31,
2892 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
2893 static const struct wacom_features wacom_features_0xDB
=
2894 { "Wacom Bamboo 2FG 6x8 SE", 21648, 13700, 1023, 31,
2895 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 2 };
2896 static const struct wacom_features wacom_features_0xDD
=
2897 { "Wacom Bamboo Connect", 14720, 9200, 1023, 31,
2898 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2899 static const struct wacom_features wacom_features_0xDE
=
2900 { "Wacom Bamboo 16FG 4x5", 14720, 9200, 1023, 31,
2901 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 16 };
2902 static const struct wacom_features wacom_features_0xDF
=
2903 { "Wacom Bamboo 16FG 6x8", 21648, 13700, 1023, 31,
2904 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 16 };
2905 static const struct wacom_features wacom_features_0x300
=
2906 { "Wacom Bamboo One S", 14720, 9225, 1023, 31,
2907 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2908 static const struct wacom_features wacom_features_0x301
=
2909 { "Wacom Bamboo One M", 21648, 13530, 1023, 31,
2910 BAMBOO_PT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2911 static const struct wacom_features wacom_features_0x302
=
2912 { "Wacom Intuos PT S", 15200, 9500, 1023, 31,
2913 INTUOSHT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 16,
2914 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
2915 static const struct wacom_features wacom_features_0x303
=
2916 { "Wacom Intuos PT M", 21600, 13500, 1023, 31,
2917 INTUOSHT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
, .touch_max
= 16,
2918 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
2919 static const struct wacom_features wacom_features_0x30E
=
2920 { "Wacom Intuos S", 15200, 9500, 1023, 31,
2921 INTUOSHT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
,
2922 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
2923 static const struct wacom_features wacom_features_0x6004
=
2924 { "ISD-V4", 12800, 8000, 255, 0,
2925 TABLETPC
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
};
2926 static const struct wacom_features wacom_features_0x307
=
2927 { "Wacom ISDv5 307", 59152, 33448, 2047, 63,
2928 CINTIQ_HYBRID
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
,
2929 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
2930 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x309 };
2931 static const struct wacom_features wacom_features_0x309
=
2932 { "Wacom ISDv5 309", .type
= WACOM_24HDT
, /* Touch */
2933 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x0307, .touch_max
= 10,
2934 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
2935 static const struct wacom_features wacom_features_0x30A
=
2936 { "Wacom ISDv5 30A", 59152, 33448, 2047, 63,
2937 CINTIQ_HYBRID
, WACOM_INTUOS3_RES
, WACOM_INTUOS3_RES
,
2938 WACOM_CINTIQ_OFFSET
, WACOM_CINTIQ_OFFSET
,
2939 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x30C };
2940 static const struct wacom_features wacom_features_0x30C
=
2941 { "Wacom ISDv5 30C", .type
= WACOM_24HDT
, /* Touch */
2942 .oVid
= USB_VENDOR_ID_WACOM
, .oPid
= 0x30A, .touch_max
= 10,
2943 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
2944 static const struct wacom_features wacom_features_0x323
=
2945 { "Wacom Intuos P M", 21600, 13500, 1023, 31,
2946 INTUOSHT
, WACOM_INTUOS_RES
, WACOM_INTUOS_RES
,
2947 .check_for_hid_type
= true, .hid_type
= HID_TYPE_USBNONE
};
2949 static const struct wacom_features wacom_features_HID_ANY_ID
=
2950 { "Wacom HID", .type
= HID_GENERIC
};
2952 #define USB_DEVICE_WACOM(prod) \
2953 HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
2954 .driver_data = (kernel_ulong_t)&wacom_features_##prod
2956 #define BT_DEVICE_WACOM(prod) \
2957 HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
2958 .driver_data = (kernel_ulong_t)&wacom_features_##prod
2960 #define USB_DEVICE_LENOVO(prod) \
2961 HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
2962 .driver_data = (kernel_ulong_t)&wacom_features_##prod
2964 const struct hid_device_id wacom_ids
[] = {
2965 { USB_DEVICE_WACOM(0x00) },
2966 { USB_DEVICE_WACOM(0x03) },
2967 { USB_DEVICE_WACOM(0x10) },
2968 { USB_DEVICE_WACOM(0x11) },
2969 { USB_DEVICE_WACOM(0x12) },
2970 { USB_DEVICE_WACOM(0x13) },
2971 { USB_DEVICE_WACOM(0x14) },
2972 { USB_DEVICE_WACOM(0x15) },
2973 { USB_DEVICE_WACOM(0x16) },
2974 { USB_DEVICE_WACOM(0x17) },
2975 { USB_DEVICE_WACOM(0x18) },
2976 { USB_DEVICE_WACOM(0x19) },
2977 { USB_DEVICE_WACOM(0x20) },
2978 { USB_DEVICE_WACOM(0x21) },
2979 { USB_DEVICE_WACOM(0x22) },
2980 { USB_DEVICE_WACOM(0x23) },
2981 { USB_DEVICE_WACOM(0x24) },
2982 { USB_DEVICE_WACOM(0x26) },
2983 { USB_DEVICE_WACOM(0x27) },
2984 { USB_DEVICE_WACOM(0x28) },
2985 { USB_DEVICE_WACOM(0x29) },
2986 { USB_DEVICE_WACOM(0x2A) },
2987 { USB_DEVICE_WACOM(0x30) },
2988 { USB_DEVICE_WACOM(0x31) },
2989 { USB_DEVICE_WACOM(0x32) },
2990 { USB_DEVICE_WACOM(0x33) },
2991 { USB_DEVICE_WACOM(0x34) },
2992 { USB_DEVICE_WACOM(0x35) },
2993 { USB_DEVICE_WACOM(0x37) },
2994 { USB_DEVICE_WACOM(0x38) },
2995 { USB_DEVICE_WACOM(0x39) },
2996 { USB_DEVICE_WACOM(0x3F) },
2997 { USB_DEVICE_WACOM(0x41) },
2998 { USB_DEVICE_WACOM(0x42) },
2999 { USB_DEVICE_WACOM(0x43) },
3000 { USB_DEVICE_WACOM(0x44) },
3001 { USB_DEVICE_WACOM(0x45) },
3002 { USB_DEVICE_WACOM(0x47) },
3003 { USB_DEVICE_WACOM(0x57) },
3004 { USB_DEVICE_WACOM(0x59) },
3005 { USB_DEVICE_WACOM(0x5B) },
3006 { USB_DEVICE_WACOM(0x5D) },
3007 { USB_DEVICE_WACOM(0x5E) },
3008 { USB_DEVICE_WACOM(0x60) },
3009 { USB_DEVICE_WACOM(0x61) },
3010 { USB_DEVICE_WACOM(0x62) },
3011 { USB_DEVICE_WACOM(0x63) },
3012 { USB_DEVICE_WACOM(0x64) },
3013 { USB_DEVICE_WACOM(0x65) },
3014 { USB_DEVICE_WACOM(0x69) },
3015 { USB_DEVICE_WACOM(0x6A) },
3016 { USB_DEVICE_WACOM(0x6B) },
3017 { BT_DEVICE_WACOM(0x81) },
3018 { USB_DEVICE_WACOM(0x84) },
3019 { USB_DEVICE_WACOM(0x90) },
3020 { USB_DEVICE_WACOM(0x93) },
3021 { USB_DEVICE_WACOM(0x97) },
3022 { USB_DEVICE_WACOM(0x9A) },
3023 { USB_DEVICE_WACOM(0x9F) },
3024 { USB_DEVICE_WACOM(0xB0) },
3025 { USB_DEVICE_WACOM(0xB1) },
3026 { USB_DEVICE_WACOM(0xB2) },
3027 { USB_DEVICE_WACOM(0xB3) },
3028 { USB_DEVICE_WACOM(0xB4) },
3029 { USB_DEVICE_WACOM(0xB5) },
3030 { USB_DEVICE_WACOM(0xB7) },
3031 { USB_DEVICE_WACOM(0xB8) },
3032 { USB_DEVICE_WACOM(0xB9) },
3033 { USB_DEVICE_WACOM(0xBA) },
3034 { USB_DEVICE_WACOM(0xBB) },
3035 { USB_DEVICE_WACOM(0xBC) },
3036 { BT_DEVICE_WACOM(0xBD) },
3037 { USB_DEVICE_WACOM(0xC0) },
3038 { USB_DEVICE_WACOM(0xC2) },
3039 { USB_DEVICE_WACOM(0xC4) },
3040 { USB_DEVICE_WACOM(0xC5) },
3041 { USB_DEVICE_WACOM(0xC6) },
3042 { USB_DEVICE_WACOM(0xC7) },
3043 { USB_DEVICE_WACOM(0xCC) },
3044 { USB_DEVICE_WACOM(0xCE) },
3045 { USB_DEVICE_WACOM(0xD0) },
3046 { USB_DEVICE_WACOM(0xD1) },
3047 { USB_DEVICE_WACOM(0xD2) },
3048 { USB_DEVICE_WACOM(0xD3) },
3049 { USB_DEVICE_WACOM(0xD4) },
3050 { USB_DEVICE_WACOM(0xD5) },
3051 { USB_DEVICE_WACOM(0xD6) },
3052 { USB_DEVICE_WACOM(0xD7) },
3053 { USB_DEVICE_WACOM(0xD8) },
3054 { USB_DEVICE_WACOM(0xDA) },
3055 { USB_DEVICE_WACOM(0xDB) },
3056 { USB_DEVICE_WACOM(0xDD) },
3057 { USB_DEVICE_WACOM(0xDE) },
3058 { USB_DEVICE_WACOM(0xDF) },
3059 { USB_DEVICE_WACOM(0xE2) },
3060 { USB_DEVICE_WACOM(0xE3) },
3061 { USB_DEVICE_WACOM(0xE5) },
3062 { USB_DEVICE_WACOM(0xE6) },
3063 { USB_DEVICE_WACOM(0xEC) },
3064 { USB_DEVICE_WACOM(0xED) },
3065 { USB_DEVICE_WACOM(0xEF) },
3066 { USB_DEVICE_WACOM(0xF0) },
3067 { USB_DEVICE_WACOM(0xF4) },
3068 { USB_DEVICE_WACOM(0xF6) },
3069 { USB_DEVICE_WACOM(0xF8) },
3070 { USB_DEVICE_WACOM(0xFA) },
3071 { USB_DEVICE_WACOM(0xFB) },
3072 { USB_DEVICE_WACOM(0x100) },
3073 { USB_DEVICE_WACOM(0x101) },
3074 { USB_DEVICE_WACOM(0x10D) },
3075 { USB_DEVICE_WACOM(0x10E) },
3076 { USB_DEVICE_WACOM(0x10F) },
3077 { USB_DEVICE_WACOM(0x116) },
3078 { USB_DEVICE_WACOM(0x12C) },
3079 { USB_DEVICE_WACOM(0x300) },
3080 { USB_DEVICE_WACOM(0x301) },
3081 { USB_DEVICE_WACOM(0x302) },
3082 { USB_DEVICE_WACOM(0x303) },
3083 { USB_DEVICE_WACOM(0x304) },
3084 { USB_DEVICE_WACOM(0x307) },
3085 { USB_DEVICE_WACOM(0x309) },
3086 { USB_DEVICE_WACOM(0x30A) },
3087 { USB_DEVICE_WACOM(0x30C) },
3088 { USB_DEVICE_WACOM(0x30E) },
3089 { USB_DEVICE_WACOM(0x314) },
3090 { USB_DEVICE_WACOM(0x315) },
3091 { USB_DEVICE_WACOM(0x317) },
3092 { USB_DEVICE_WACOM(0x323) },
3093 { USB_DEVICE_WACOM(0x32F) },
3094 { USB_DEVICE_WACOM(0x4001) },
3095 { USB_DEVICE_WACOM(0x4004) },
3096 { USB_DEVICE_WACOM(0x5000) },
3097 { USB_DEVICE_WACOM(0x5002) },
3098 { USB_DEVICE_LENOVO(0x6004) },
3100 { USB_DEVICE_WACOM(HID_ANY_ID
) },
3103 MODULE_DEVICE_TABLE(hid
, wacom_ids
);