]>
Commit | Line | Data |
---|---|---|
3bea733a | 1 | /* |
4104d13f | 2 | * drivers/input/tablet/wacom_wac.c |
3bea733a | 3 | * |
ee54500d | 4 | * USB Wacom tablet support - Wacom specific code |
3bea733a PC |
5 | * |
6 | */ | |
7 | ||
8 | /* | |
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. | |
13 | */ | |
51269fe8 | 14 | |
3bea733a | 15 | #include "wacom_wac.h" |
51269fe8 | 16 | #include "wacom.h" |
47c78e89 | 17 | #include <linux/input/mt.h> |
3bea733a | 18 | |
e35fb8c1 PC |
19 | /* resolution for penabled devices */ |
20 | #define WACOM_PL_RES 20 | |
21 | #define WACOM_PENPRTN_RES 40 | |
22 | #define WACOM_VOLITO_RES 50 | |
23 | #define WACOM_GRAPHIRE_RES 80 | |
24 | #define WACOM_INTUOS_RES 100 | |
25 | #define WACOM_INTUOS3_RES 200 | |
26 | ||
fa770340 PC |
27 | /* Newer Cintiq and DTU have an offset between tablet and screen areas */ |
28 | #define WACOM_DTU_OFFSET 200 | |
29 | #define WACOM_CINTIQ_OFFSET 400 | |
30 | ||
387142bb BT |
31 | /* |
32 | * Scale factor relating reported contact size to logical contact area. | |
4e904954 JG |
33 | * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo |
34 | */ | |
35 | #define WACOM_CONTACT_AREA_SCALE 2607 | |
36 | ||
1924e05e PC |
37 | static bool touch_arbitration = 1; |
38 | module_param(touch_arbitration, bool, 0644); | |
39 | MODULE_PARM_DESC(touch_arbitration, " on (Y) off (N)"); | |
40 | ||
c7f0522a JG |
41 | static void wacom_report_numbered_buttons(struct input_dev *input_dev, |
42 | int button_count, int mask); | |
43 | ||
5922e613 JG |
44 | static int wacom_numbered_button_to_key(int n); |
45 | ||
10c55cac AAS |
46 | static void wacom_update_led(struct wacom *wacom, int button_count, int mask, |
47 | int group); | |
387142bb BT |
48 | /* |
49 | * Percent of battery capacity for Graphire. | |
50 | * 8th value means AC online and show 100% capacity. | |
51 | */ | |
52 | static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 }; | |
53 | ||
81af7e61 BT |
54 | /* |
55 | * Percent of battery capacity for Intuos4 WL, AC has a separate bit. | |
56 | */ | |
57 | static unsigned short batcap_i4[8] = { 1, 15, 30, 45, 60, 70, 85, 100 }; | |
58 | ||
59d69bc8 BT |
59 | static void __wacom_notify_battery(struct wacom_battery *battery, |
60 | int bat_capacity, bool bat_charging, | |
61 | bool bat_connected, bool ps_connected) | |
62 | { | |
63 | bool changed = battery->battery_capacity != bat_capacity || | |
64 | battery->bat_charging != bat_charging || | |
65 | battery->bat_connected != bat_connected || | |
66 | battery->ps_connected != ps_connected; | |
67 | ||
68 | if (changed) { | |
69 | battery->battery_capacity = bat_capacity; | |
70 | battery->bat_charging = bat_charging; | |
71 | battery->bat_connected = bat_connected; | |
72 | battery->ps_connected = ps_connected; | |
73 | ||
74 | if (battery->battery) | |
75 | power_supply_changed(battery->battery); | |
76 | } | |
77 | } | |
78 | ||
953f2c5f | 79 | static void wacom_notify_battery(struct wacom_wac *wacom_wac, |
71fa641e JG |
80 | int bat_capacity, bool bat_charging, bool bat_connected, |
81 | bool ps_connected) | |
953f2c5f JG |
82 | { |
83 | struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac); | |
953f2c5f | 84 | |
59d69bc8 BT |
85 | __wacom_notify_battery(&wacom->battery, bat_capacity, bat_charging, |
86 | bat_connected, ps_connected); | |
953f2c5f JG |
87 | } |
88 | ||
95dd3b30 | 89 | static int wacom_penpartner_irq(struct wacom_wac *wacom) |
3bea733a PC |
90 | { |
91 | unsigned char *data = wacom->data; | |
2a6cdbdd | 92 | struct input_dev *input = wacom->pen_input; |
3bea733a PC |
93 | |
94 | switch (data[0]) { | |
73a97f4f DT |
95 | case 1: |
96 | if (data[5] & 0x80) { | |
97 | wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN; | |
98 | wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID; | |
8da23fc1 DT |
99 | input_report_key(input, wacom->tool[0], 1); |
100 | input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */ | |
252f7769 DT |
101 | input_report_abs(input, ABS_X, get_unaligned_le16(&data[1])); |
102 | input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3])); | |
8da23fc1 DT |
103 | input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127); |
104 | input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127)); | |
105 | input_report_key(input, BTN_STYLUS, (data[5] & 0x40)); | |
73a97f4f | 106 | } else { |
8da23fc1 DT |
107 | input_report_key(input, wacom->tool[0], 0); |
108 | input_report_abs(input, ABS_MISC, 0); /* report tool id */ | |
109 | input_report_abs(input, ABS_PRESSURE, -1); | |
110 | input_report_key(input, BTN_TOUCH, 0); | |
73a97f4f DT |
111 | } |
112 | break; | |
8da23fc1 | 113 | |
73a97f4f | 114 | case 2: |
8da23fc1 DT |
115 | input_report_key(input, BTN_TOOL_PEN, 1); |
116 | input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */ | |
252f7769 DT |
117 | input_report_abs(input, ABS_X, get_unaligned_le16(&data[1])); |
118 | input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3])); | |
8da23fc1 DT |
119 | input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127); |
120 | input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20)); | |
121 | input_report_key(input, BTN_STYLUS, (data[5] & 0x40)); | |
73a97f4f | 122 | break; |
8da23fc1 | 123 | |
73a97f4f | 124 | default: |
eb71d1bb DT |
125 | dev_dbg(input->dev.parent, |
126 | "%s: received unknown report #%d\n", __func__, data[0]); | |
73a97f4f | 127 | return 0; |
3bea733a | 128 | } |
8da23fc1 | 129 | |
3bea733a PC |
130 | return 1; |
131 | } | |
132 | ||
95dd3b30 | 133 | static int wacom_pl_irq(struct wacom_wac *wacom) |
3bea733a | 134 | { |
e33da8a5 | 135 | struct wacom_features *features = &wacom->features; |
3bea733a | 136 | unsigned char *data = wacom->data; |
2a6cdbdd | 137 | struct input_dev *input = wacom->pen_input; |
e34b9d2f | 138 | int prox, pressure; |
3bea733a | 139 | |
cad74700 | 140 | if (data[0] != WACOM_REPORT_PENABLED) { |
eb71d1bb DT |
141 | dev_dbg(input->dev.parent, |
142 | "%s: received unknown report #%d\n", __func__, data[0]); | |
3bea733a PC |
143 | return 0; |
144 | } | |
145 | ||
146 | prox = data[1] & 0x40; | |
147 | ||
025bcc15 JG |
148 | if (!wacom->id[0]) { |
149 | if ((data[0] & 0x10) || (data[4] & 0x20)) { | |
150 | wacom->tool[0] = BTN_TOOL_RUBBER; | |
151 | wacom->id[0] = ERASER_DEVICE_ID; | |
3bea733a | 152 | } |
025bcc15 JG |
153 | else { |
154 | wacom->tool[0] = BTN_TOOL_PEN; | |
e34b9d2f | 155 | wacom->id[0] = STYLUS_DEVICE_ID; |
3bea733a | 156 | } |
3bea733a | 157 | } |
8da23fc1 | 158 | |
025bcc15 JG |
159 | /* If the eraser is in prox, STYLUS2 is always set. If we |
160 | * mis-detected the type and notice that STYLUS2 isn't set | |
161 | * then force the eraser out of prox and let the pen in. | |
162 | */ | |
163 | if (wacom->tool[0] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) { | |
164 | input_report_key(input, BTN_TOOL_RUBBER, 0); | |
165 | input_report_abs(input, ABS_MISC, 0); | |
166 | input_sync(input); | |
167 | wacom->tool[0] = BTN_TOOL_PEN; | |
168 | wacom->id[0] = STYLUS_DEVICE_ID; | |
3bea733a PC |
169 | } |
170 | ||
282e4637 JG |
171 | if (prox) { |
172 | pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1)); | |
173 | if (features->pressure_max > 255) | |
174 | pressure = (pressure << 1) | ((data[4] >> 6) & 1); | |
175 | pressure += (features->pressure_max + 1) / 2; | |
176 | ||
177 | input_report_abs(input, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14)); | |
178 | input_report_abs(input, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14)); | |
179 | input_report_abs(input, ABS_PRESSURE, pressure); | |
180 | ||
181 | input_report_key(input, BTN_TOUCH, data[4] & 0x08); | |
182 | input_report_key(input, BTN_STYLUS, data[4] & 0x10); | |
183 | /* Only allow the stylus2 button to be reported for the pen tool. */ | |
184 | input_report_key(input, BTN_STYLUS2, (wacom->tool[0] == BTN_TOOL_PEN) && (data[4] & 0x20)); | |
185 | } | |
025bcc15 JG |
186 | |
187 | if (!prox) | |
188 | wacom->id[0] = 0; | |
189 | input_report_key(input, wacom->tool[0], prox); | |
190 | input_report_abs(input, ABS_MISC, wacom->id[0]); | |
3bea733a PC |
191 | return 1; |
192 | } | |
193 | ||
95dd3b30 | 194 | static int wacom_ptu_irq(struct wacom_wac *wacom) |
3bea733a PC |
195 | { |
196 | unsigned char *data = wacom->data; | |
2a6cdbdd | 197 | struct input_dev *input = wacom->pen_input; |
3bea733a | 198 | |
cad74700 | 199 | if (data[0] != WACOM_REPORT_PENABLED) { |
eb71d1bb DT |
200 | dev_dbg(input->dev.parent, |
201 | "%s: received unknown report #%d\n", __func__, data[0]); | |
3bea733a PC |
202 | return 0; |
203 | } | |
204 | ||
3bea733a | 205 | if (data[1] & 0x04) { |
8da23fc1 DT |
206 | input_report_key(input, BTN_TOOL_RUBBER, data[1] & 0x20); |
207 | input_report_key(input, BTN_TOUCH, data[1] & 0x08); | |
e34b9d2f | 208 | wacom->id[0] = ERASER_DEVICE_ID; |
3bea733a | 209 | } else { |
8da23fc1 DT |
210 | input_report_key(input, BTN_TOOL_PEN, data[1] & 0x20); |
211 | input_report_key(input, BTN_TOUCH, data[1] & 0x01); | |
e34b9d2f | 212 | wacom->id[0] = STYLUS_DEVICE_ID; |
3bea733a | 213 | } |
8da23fc1 | 214 | input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */ |
252f7769 DT |
215 | input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); |
216 | input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); | |
217 | input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6])); | |
8da23fc1 DT |
218 | input_report_key(input, BTN_STYLUS, data[1] & 0x02); |
219 | input_report_key(input, BTN_STYLUS2, data[1] & 0x10); | |
3bea733a PC |
220 | return 1; |
221 | } | |
222 | ||
c8f2edc5 PC |
223 | static int wacom_dtu_irq(struct wacom_wac *wacom) |
224 | { | |
74b63417 | 225 | unsigned char *data = wacom->data; |
2a6cdbdd | 226 | struct input_dev *input = wacom->pen_input; |
74b63417 | 227 | int prox = data[1] & 0x20; |
c8f2edc5 | 228 | |
eb71d1bb DT |
229 | dev_dbg(input->dev.parent, |
230 | "%s: received report #%d", __func__, data[0]); | |
c8f2edc5 PC |
231 | |
232 | if (prox) { | |
233 | /* Going into proximity select tool */ | |
234 | wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN; | |
235 | if (wacom->tool[0] == BTN_TOOL_PEN) | |
236 | wacom->id[0] = STYLUS_DEVICE_ID; | |
237 | else | |
238 | wacom->id[0] = ERASER_DEVICE_ID; | |
239 | } | |
240 | input_report_key(input, BTN_STYLUS, data[1] & 0x02); | |
241 | input_report_key(input, BTN_STYLUS2, data[1] & 0x10); | |
242 | input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); | |
243 | input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); | |
74b63417 | 244 | input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x01) << 8) | data[6]); |
c8f2edc5 PC |
245 | input_report_key(input, BTN_TOUCH, data[1] & 0x05); |
246 | if (!prox) /* out-prox */ | |
247 | wacom->id[0] = 0; | |
248 | input_report_key(input, wacom->tool[0], prox); | |
249 | input_report_abs(input, ABS_MISC, wacom->id[0]); | |
250 | return 1; | |
251 | } | |
252 | ||
497ab1f2 PC |
253 | static int wacom_dtus_irq(struct wacom_wac *wacom) |
254 | { | |
255 | char *data = wacom->data; | |
2a6cdbdd | 256 | struct input_dev *input = wacom->pen_input; |
497ab1f2 PC |
257 | unsigned short prox, pressure = 0; |
258 | ||
259 | if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) { | |
260 | dev_dbg(input->dev.parent, | |
261 | "%s: received unknown report #%d", __func__, data[0]); | |
262 | return 0; | |
263 | } else if (data[0] == WACOM_REPORT_DTUSPAD) { | |
422b0314 | 264 | input = wacom->pad_input; |
497ab1f2 PC |
265 | input_report_key(input, BTN_0, (data[1] & 0x01)); |
266 | input_report_key(input, BTN_1, (data[1] & 0x02)); | |
267 | input_report_key(input, BTN_2, (data[1] & 0x04)); | |
268 | input_report_key(input, BTN_3, (data[1] & 0x08)); | |
269 | input_report_abs(input, ABS_MISC, | |
270 | data[1] & 0x0f ? PAD_DEVICE_ID : 0); | |
497ab1f2 PC |
271 | return 1; |
272 | } else { | |
273 | prox = data[1] & 0x80; | |
274 | if (prox) { | |
275 | switch ((data[1] >> 3) & 3) { | |
276 | case 1: /* Rubber */ | |
277 | wacom->tool[0] = BTN_TOOL_RUBBER; | |
278 | wacom->id[0] = ERASER_DEVICE_ID; | |
279 | break; | |
280 | ||
281 | case 2: /* Pen */ | |
282 | wacom->tool[0] = BTN_TOOL_PEN; | |
283 | wacom->id[0] = STYLUS_DEVICE_ID; | |
284 | break; | |
285 | } | |
286 | } | |
287 | ||
288 | input_report_key(input, BTN_STYLUS, data[1] & 0x20); | |
289 | input_report_key(input, BTN_STYLUS2, data[1] & 0x40); | |
290 | input_report_abs(input, ABS_X, get_unaligned_be16(&data[3])); | |
291 | input_report_abs(input, ABS_Y, get_unaligned_be16(&data[5])); | |
292 | pressure = ((data[1] & 0x03) << 8) | (data[2] & 0xff); | |
293 | input_report_abs(input, ABS_PRESSURE, pressure); | |
294 | input_report_key(input, BTN_TOUCH, pressure > 10); | |
295 | ||
296 | if (!prox) /* out-prox */ | |
297 | wacom->id[0] = 0; | |
298 | input_report_key(input, wacom->tool[0], prox); | |
299 | input_report_abs(input, ABS_MISC, wacom->id[0]); | |
497ab1f2 PC |
300 | return 1; |
301 | } | |
302 | } | |
303 | ||
95dd3b30 | 304 | static int wacom_graphire_irq(struct wacom_wac *wacom) |
3bea733a | 305 | { |
e33da8a5 | 306 | struct wacom_features *features = &wacom->features; |
3bea733a | 307 | unsigned char *data = wacom->data; |
2a6cdbdd | 308 | struct input_dev *input = wacom->pen_input; |
3813810c | 309 | struct input_dev *pad_input = wacom->pad_input; |
387142bb | 310 | int battery_capacity, ps_connected; |
252f7769 | 311 | int prox; |
3b57ca0f PC |
312 | int rw = 0; |
313 | int retval = 0; | |
3bea733a | 314 | |
387142bb BT |
315 | if (features->type == GRAPHIRE_BT) { |
316 | if (data[0] != WACOM_REPORT_PENABLED_BT) { | |
317 | dev_dbg(input->dev.parent, | |
318 | "%s: received unknown report #%d\n", __func__, | |
319 | data[0]); | |
320 | goto exit; | |
321 | } | |
322 | } else if (data[0] != WACOM_REPORT_PENABLED) { | |
eb71d1bb DT |
323 | dev_dbg(input->dev.parent, |
324 | "%s: received unknown report #%d\n", __func__, data[0]); | |
3b57ca0f | 325 | goto exit; |
3bea733a PC |
326 | } |
327 | ||
3b57ca0f PC |
328 | prox = data[1] & 0x80; |
329 | if (prox || wacom->id[0]) { | |
330 | if (prox) { | |
331 | switch ((data[1] >> 5) & 3) { | |
3bea733a PC |
332 | |
333 | case 0: /* Pen */ | |
334 | wacom->tool[0] = BTN_TOOL_PEN; | |
e34b9d2f | 335 | wacom->id[0] = STYLUS_DEVICE_ID; |
3bea733a PC |
336 | break; |
337 | ||
338 | case 1: /* Rubber */ | |
339 | wacom->tool[0] = BTN_TOOL_RUBBER; | |
e34b9d2f | 340 | wacom->id[0] = ERASER_DEVICE_ID; |
3bea733a PC |
341 | break; |
342 | ||
343 | case 2: /* Mouse with wheel */ | |
8da23fc1 | 344 | input_report_key(input, BTN_MIDDLE, data[1] & 0x04); |
3bea733a PC |
345 | /* fall through */ |
346 | ||
347 | case 3: /* Mouse without wheel */ | |
348 | wacom->tool[0] = BTN_TOOL_MOUSE; | |
e34b9d2f | 349 | wacom->id[0] = CURSOR_DEVICE_ID; |
3bea733a | 350 | break; |
3b57ca0f | 351 | } |
3bea733a | 352 | } |
252f7769 DT |
353 | input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); |
354 | input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); | |
3bea733a | 355 | if (wacom->tool[0] != BTN_TOOL_MOUSE) { |
387142bb BT |
356 | if (features->type == GRAPHIRE_BT) |
357 | input_report_abs(input, ABS_PRESSURE, data[6] | | |
358 | (((__u16) (data[1] & 0x08)) << 5)); | |
359 | else | |
360 | input_report_abs(input, ABS_PRESSURE, data[6] | | |
361 | ((data[7] & 0x03) << 8)); | |
8da23fc1 DT |
362 | input_report_key(input, BTN_TOUCH, data[1] & 0x01); |
363 | input_report_key(input, BTN_STYLUS, data[1] & 0x02); | |
364 | input_report_key(input, BTN_STYLUS2, data[1] & 0x04); | |
afb567e3 | 365 | } else { |
8da23fc1 DT |
366 | input_report_key(input, BTN_LEFT, data[1] & 0x01); |
367 | input_report_key(input, BTN_RIGHT, data[1] & 0x02); | |
3b57ca0f PC |
368 | if (features->type == WACOM_G4 || |
369 | features->type == WACOM_MO) { | |
8da23fc1 | 370 | input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f); |
d9f66c1a | 371 | rw = (data[7] & 0x04) - (data[7] & 0x03); |
387142bb BT |
372 | } else if (features->type == GRAPHIRE_BT) { |
373 | /* Compute distance between mouse and tablet */ | |
374 | rw = 44 - (data[6] >> 2); | |
375 | rw = clamp_val(rw, 0, 31); | |
376 | input_report_abs(input, ABS_DISTANCE, rw); | |
377 | if (((data[1] >> 5) & 3) == 2) { | |
378 | /* Mouse with wheel */ | |
379 | input_report_key(input, BTN_MIDDLE, | |
380 | data[1] & 0x04); | |
381 | rw = (data[6] & 0x01) ? -1 : | |
382 | (data[6] & 0x02) ? 1 : 0; | |
383 | } else { | |
384 | rw = 0; | |
385 | } | |
3b57ca0f | 386 | } else { |
8da23fc1 | 387 | input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f); |
d9f66c1a | 388 | rw = -(signed char)data[6]; |
3b57ca0f | 389 | } |
8da23fc1 | 390 | input_report_rel(input, REL_WHEEL, rw); |
afb567e3 | 391 | } |
3b57ca0f PC |
392 | |
393 | if (!prox) | |
394 | wacom->id[0] = 0; | |
8da23fc1 DT |
395 | input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */ |
396 | input_report_key(input, wacom->tool[0], prox); | |
397 | input_sync(input); /* sync last event */ | |
80d4e8e9 | 398 | } |
3bea733a PC |
399 | |
400 | /* send pad data */ | |
e33da8a5 | 401 | switch (features->type) { |
73a97f4f | 402 | case WACOM_G4: |
3b57ca0f PC |
403 | prox = data[7] & 0xf8; |
404 | if (prox || wacom->id[1]) { | |
e34b9d2f | 405 | wacom->id[1] = PAD_DEVICE_ID; |
3813810c BT |
406 | input_report_key(pad_input, BTN_BACK, (data[7] & 0x40)); |
407 | input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x80)); | |
3bea733a | 408 | rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3); |
3813810c | 409 | input_report_rel(pad_input, REL_WHEEL, rw); |
3b57ca0f PC |
410 | if (!prox) |
411 | wacom->id[1] = 0; | |
3813810c | 412 | input_report_abs(pad_input, ABS_MISC, wacom->id[1]); |
ab687b18 | 413 | retval = 1; |
3bea733a | 414 | } |
7ecfbfd3 | 415 | break; |
73a97f4f DT |
416 | |
417 | case WACOM_MO: | |
3b57ca0f PC |
418 | prox = (data[7] & 0xf8) || data[8]; |
419 | if (prox || wacom->id[1]) { | |
e34b9d2f | 420 | wacom->id[1] = PAD_DEVICE_ID; |
3813810c BT |
421 | input_report_key(pad_input, BTN_BACK, (data[7] & 0x08)); |
422 | input_report_key(pad_input, BTN_LEFT, (data[7] & 0x20)); | |
423 | input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x10)); | |
424 | input_report_key(pad_input, BTN_RIGHT, (data[7] & 0x40)); | |
425 | input_report_abs(pad_input, ABS_WHEEL, (data[8] & 0x7f)); | |
3b57ca0f PC |
426 | if (!prox) |
427 | wacom->id[1] = 0; | |
3813810c | 428 | input_report_abs(pad_input, ABS_MISC, wacom->id[1]); |
84460014 | 429 | retval = 1; |
7ecfbfd3 PC |
430 | } |
431 | break; | |
387142bb BT |
432 | case GRAPHIRE_BT: |
433 | prox = data[7] & 0x03; | |
434 | if (prox || wacom->id[1]) { | |
435 | wacom->id[1] = PAD_DEVICE_ID; | |
436 | input_report_key(pad_input, BTN_0, (data[7] & 0x02)); | |
437 | input_report_key(pad_input, BTN_1, (data[7] & 0x01)); | |
3b57ca0f PC |
438 | if (!prox) |
439 | wacom->id[1] = 0; | |
387142bb | 440 | input_report_abs(pad_input, ABS_MISC, wacom->id[1]); |
84460014 | 441 | retval = 1; |
7ecfbfd3 PC |
442 | } |
443 | break; | |
3bea733a | 444 | } |
387142bb BT |
445 | |
446 | /* Store current battery capacity and power supply state */ | |
447 | if (features->type == GRAPHIRE_BT) { | |
448 | rw = (data[7] >> 2 & 0x07); | |
449 | battery_capacity = batcap_gr[rw]; | |
450 | ps_connected = rw == 7; | |
953f2c5f | 451 | wacom_notify_battery(wacom, battery_capacity, ps_connected, |
71fa641e | 452 | 1, ps_connected); |
3bea733a | 453 | } |
3b57ca0f PC |
454 | exit: |
455 | return retval; | |
3bea733a PC |
456 | } |
457 | ||
5fcad167 BT |
458 | static void wacom_intuos_schedule_prox_event(struct wacom_wac *wacom_wac) |
459 | { | |
460 | struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac); | |
0bbfe28a | 461 | struct wacom_features *features = &wacom_wac->features; |
5fcad167 BT |
462 | struct hid_report *r; |
463 | struct hid_report_enum *re; | |
464 | ||
465 | re = &(wacom->hdev->report_enum[HID_FEATURE_REPORT]); | |
0bbfe28a JG |
466 | if (features->type == INTUOSHT2) |
467 | r = re->report_id_hash[WACOM_REPORT_INTUOSHT2_ID]; | |
468 | else | |
469 | r = re->report_id_hash[WACOM_REPORT_INTUOS_ID1]; | |
5fcad167 BT |
470 | if (r) { |
471 | hid_hw_request(wacom->hdev, r, HID_REQ_GET_REPORT); | |
472 | } | |
473 | } | |
474 | ||
fb013a01 JG |
475 | static int wacom_intuos_pad(struct wacom_wac *wacom) |
476 | { | |
477 | struct wacom_features *features = &wacom->features; | |
478 | unsigned char *data = wacom->data; | |
479 | struct input_dev *input = wacom->pad_input; | |
c7f0522a JG |
480 | int i; |
481 | int buttons = 0, nbuttons = features->numbered_buttons; | |
482 | int keys = 0, nkeys = 0; | |
483 | int ring1 = 0, ring2 = 0; | |
484 | int strip1 = 0, strip2 = 0; | |
485 | bool prox = false; | |
fb013a01 JG |
486 | |
487 | /* pad packets. Works as a second tool and is always in prox */ | |
488 | if (!(data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD || | |
489 | data[0] == WACOM_REPORT_CINTIQPAD)) | |
490 | return 0; | |
491 | ||
492 | if (features->type >= INTUOS4S && features->type <= INTUOS4L) { | |
c7f0522a JG |
493 | buttons = (data[3] << 1) | (data[2] & 0x01); |
494 | ring1 = data[1]; | |
fb013a01 | 495 | } else if (features->type == DTK) { |
c7f0522a | 496 | buttons = data[6]; |
fb013a01 | 497 | } else if (features->type == WACOM_13HD) { |
c7f0522a | 498 | buttons = (data[4] << 1) | (data[3] & 0x01); |
fb013a01 | 499 | } else if (features->type == WACOM_24HD) { |
c7f0522a JG |
500 | buttons = (data[8] << 8) | data[6]; |
501 | ring1 = data[1]; | |
502 | ring2 = data[2]; | |
fb013a01 JG |
503 | |
504 | /* | |
505 | * Three "buttons" are available on the 24HD which are | |
506 | * physically implemented as a touchstrip. Each button | |
507 | * is approximately 3 bits wide with a 2 bit spacing. | |
508 | * The raw touchstrip bits are stored at: | |
509 | * ((data[3] & 0x1f) << 8) | data[4]) | |
510 | */ | |
c7f0522a JG |
511 | nkeys = 3; |
512 | keys = ((data[3] & 0x1C) ? 1<<2 : 0) | | |
513 | ((data[4] & 0xE0) ? 1<<1 : 0) | | |
514 | ((data[4] & 0x07) ? 1<<0 : 0); | |
fb013a01 | 515 | } else if (features->type == WACOM_27QHD) { |
c7f0522a JG |
516 | nkeys = 3; |
517 | keys = data[2] & 0x07; | |
fb013a01 JG |
518 | |
519 | input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[4])); | |
520 | input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[6])); | |
521 | input_report_abs(input, ABS_Z, be16_to_cpup((__be16 *)&data[8])); | |
fb013a01 JG |
522 | } else if (features->type == CINTIQ_HYBRID) { |
523 | /* | |
524 | * Do not send hardware buttons under Android. They | |
525 | * are already sent to the system through GPIO (and | |
526 | * have different meaning). | |
c7f0522a JG |
527 | * |
528 | * d-pad right -> data[4] & 0x10 | |
529 | * d-pad up -> data[4] & 0x20 | |
530 | * d-pad left -> data[4] & 0x40 | |
531 | * d-pad down -> data[4] & 0x80 | |
532 | * d-pad center -> data[3] & 0x01 | |
fb013a01 | 533 | */ |
c7f0522a | 534 | buttons = (data[4] << 1) | (data[3] & 0x01); |
fb013a01 | 535 | } else if (features->type == CINTIQ_COMPANION_2) { |
c7f0522a JG |
536 | /* d-pad right -> data[4] & 0x10 |
537 | * d-pad up -> data[4] & 0x20 | |
538 | * d-pad left -> data[4] & 0x40 | |
539 | * d-pad down -> data[4] & 0x80 | |
540 | * d-pad center -> data[3] & 0x01 | |
541 | */ | |
0402b6b7 | 542 | buttons = ((data[2] >> 4) << 7) | |
c7f0522a JG |
543 | ((data[1] & 0x04) << 6) | |
544 | ((data[2] & 0x0F) << 2) | | |
545 | (data[1] & 0x03); | |
fb013a01 | 546 | } else if (features->type >= INTUOS5S && features->type <= INTUOSPL) { |
fb013a01 JG |
547 | /* |
548 | * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in | |
549 | * addition to the mechanical switch. Switch data is | |
550 | * stored in data[4], capacitive data in data[5]. | |
c7f0522a JG |
551 | * |
552 | * Touch ring mode switch (data[3]) has no capacitive sensor | |
fb013a01 | 553 | */ |
c7f0522a JG |
554 | buttons = (data[4] << 1) | (data[3] & 0x01); |
555 | ring1 = data[2]; | |
fb013a01 JG |
556 | } else { |
557 | if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) { | |
c7f0522a JG |
558 | buttons = (data[8] << 10) | ((data[7] & 0x01) << 9) | |
559 | (data[6] << 1) | (data[5] & 0x01); | |
fb013a01 JG |
560 | |
561 | if (features->type == WACOM_22HD) { | |
c7f0522a JG |
562 | nkeys = 3; |
563 | keys = data[9] & 0x07; | |
fb013a01 JG |
564 | } |
565 | } else { | |
c7f0522a JG |
566 | buttons = ((data[6] & 0x10) << 10) | |
567 | ((data[5] & 0x10) << 9) | | |
568 | ((data[6] & 0x0F) << 4) | | |
569 | (data[5] & 0x0F); | |
fb013a01 | 570 | } |
f73d08d0 JG |
571 | strip1 = ((data[1] & 0x1f) << 8) | data[2]; |
572 | strip2 = ((data[3] & 0x1f) << 8) | data[4]; | |
fb013a01 | 573 | } |
c7f0522a | 574 | |
8f9cfdd3 DC |
575 | prox = (buttons & ~(~0 << nbuttons)) | (keys & ~(~0 << nkeys)) | |
576 | (ring1 & 0x80) | (ring2 & 0x80) | strip1 | strip2; | |
c7f0522a JG |
577 | |
578 | wacom_report_numbered_buttons(input, nbuttons, buttons); | |
579 | ||
580 | for (i = 0; i < nkeys; i++) | |
581 | input_report_key(input, KEY_PROG1 + i, keys & (1 << i)); | |
582 | ||
583 | input_report_abs(input, ABS_RX, strip1); | |
03a0dc54 | 584 | input_report_abs(input, ABS_RY, strip2); |
c7f0522a | 585 | |
aaae03e4 JG |
586 | input_report_abs(input, ABS_WHEEL, (ring1 & 0x80) ? (ring1 & 0x7f) : 0); |
587 | input_report_abs(input, ABS_THROTTLE, (ring2 & 0x80) ? (ring2 & 0x7f) : 0); | |
c7f0522a JG |
588 | |
589 | input_report_key(input, wacom->tool[1], prox ? 1 : 0); | |
590 | input_report_abs(input, ABS_MISC, prox ? PAD_DEVICE_ID : 0); | |
591 | ||
592 | input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff); | |
593 | ||
fb013a01 JG |
594 | return 1; |
595 | } | |
596 | ||
82527da3 JG |
597 | static int wacom_intuos_id_mangle(int tool_id) |
598 | { | |
599 | return (tool_id & ~0xFFF) << 4 | (tool_id & 0xFFF); | |
600 | } | |
601 | ||
7e129783 BT |
602 | static int wacom_intuos_get_tool_type(int tool_id) |
603 | { | |
604 | int tool_type; | |
605 | ||
606 | switch (tool_id) { | |
607 | case 0x812: /* Inking pen */ | |
608 | case 0x801: /* Intuos3 Inking pen */ | |
82527da3 | 609 | case 0x12802: /* Intuos4/5 Inking Pen */ |
7e129783 BT |
610 | case 0x012: |
611 | tool_type = BTN_TOOL_PENCIL; | |
612 | break; | |
613 | ||
614 | case 0x822: /* Pen */ | |
615 | case 0x842: | |
616 | case 0x852: | |
617 | case 0x823: /* Intuos3 Grip Pen */ | |
618 | case 0x813: /* Intuos3 Classic Pen */ | |
619 | case 0x885: /* Intuos3 Marker Pen */ | |
620 | case 0x802: /* Intuos4/5 13HD/24HD General Pen */ | |
621 | case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */ | |
622 | case 0x8e2: /* IntuosHT2 pen */ | |
623 | case 0x022: | |
82527da3 JG |
624 | case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */ |
625 | case 0x14802: /* Intuos4/5 13HD/24HD Classic Pen */ | |
626 | case 0x16802: /* Cintiq 13HD Pro Pen */ | |
627 | case 0x18802: /* DTH2242 Pen */ | |
628 | case 0x10802: /* Intuos4/5 13HD/24HD General Pen */ | |
7e129783 BT |
629 | tool_type = BTN_TOOL_PEN; |
630 | break; | |
631 | ||
632 | case 0x832: /* Stroke pen */ | |
633 | case 0x032: | |
634 | tool_type = BTN_TOOL_BRUSH; | |
635 | break; | |
636 | ||
637 | case 0x007: /* Mouse 4D and 2D */ | |
638 | case 0x09c: | |
639 | case 0x094: | |
640 | case 0x017: /* Intuos3 2D Mouse */ | |
641 | case 0x806: /* Intuos4 Mouse */ | |
642 | tool_type = BTN_TOOL_MOUSE; | |
643 | break; | |
644 | ||
645 | case 0x096: /* Lens cursor */ | |
646 | case 0x097: /* Intuos3 Lens cursor */ | |
647 | case 0x006: /* Intuos4 Lens cursor */ | |
648 | tool_type = BTN_TOOL_LENS; | |
649 | break; | |
650 | ||
651 | case 0x82a: /* Eraser */ | |
9ce9a123 | 652 | case 0x84a: |
7e129783 BT |
653 | case 0x85a: |
654 | case 0x91a: | |
655 | case 0xd1a: | |
656 | case 0x0fa: | |
657 | case 0x82b: /* Intuos3 Grip Pen Eraser */ | |
658 | case 0x81b: /* Intuos3 Classic Pen Eraser */ | |
659 | case 0x91b: /* Intuos3 Airbrush Eraser */ | |
660 | case 0x80c: /* Intuos4/5 13HD/24HD Marker Pen Eraser */ | |
661 | case 0x80a: /* Intuos4/5 13HD/24HD General Pen Eraser */ | |
662 | case 0x90a: /* Intuos4/5 13HD/24HD Airbrush Eraser */ | |
82527da3 JG |
663 | case 0x1480a: /* Intuos4/5 13HD/24HD Classic Pen Eraser */ |
664 | case 0x1090a: /* Intuos4/5 13HD/24HD Airbrush Eraser */ | |
665 | case 0x1080c: /* Intuos4/5 13HD/24HD Art Pen Eraser */ | |
666 | case 0x1680a: /* Cintiq 13HD Pro Pen Eraser */ | |
667 | case 0x1880a: /* DTH2242 Eraser */ | |
668 | case 0x1080a: /* Intuos4/5 13HD/24HD General Pen Eraser */ | |
7e129783 BT |
669 | tool_type = BTN_TOOL_RUBBER; |
670 | break; | |
671 | ||
672 | case 0xd12: | |
673 | case 0x912: | |
674 | case 0x112: | |
675 | case 0x913: /* Intuos3 Airbrush */ | |
676 | case 0x902: /* Intuos4/5 13HD/24HD Airbrush */ | |
82527da3 | 677 | case 0x10902: /* Intuos4/5 13HD/24HD Airbrush */ |
7e129783 BT |
678 | tool_type = BTN_TOOL_AIRBRUSH; |
679 | break; | |
680 | ||
681 | default: /* Unknown tool */ | |
682 | tool_type = BTN_TOOL_PEN; | |
683 | break; | |
684 | } | |
685 | return tool_type; | |
686 | } | |
687 | ||
95dd3b30 | 688 | static int wacom_intuos_inout(struct wacom_wac *wacom) |
3bea733a | 689 | { |
e33da8a5 | 690 | struct wacom_features *features = &wacom->features; |
3bea733a | 691 | unsigned char *data = wacom->data; |
2a6cdbdd | 692 | struct input_dev *input = wacom->pen_input; |
4750f5fe | 693 | int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0; |
3bea733a | 694 | |
4750f5fe PC |
695 | if (!(((data[1] & 0xfc) == 0xc0) || /* in prox */ |
696 | ((data[1] & 0xfe) == 0x20) || /* in range */ | |
697 | ((data[1] & 0xfe) == 0x80))) /* out prox */ | |
698 | return 0; | |
3bea733a PC |
699 | |
700 | /* Enter report */ | |
701 | if ((data[1] & 0xfc) == 0xc0) { | |
702 | /* serial number of the tool */ | |
703 | wacom->serial[idx] = ((data[3] & 0x0f) << 28) + | |
704 | (data[4] << 20) + (data[5] << 12) + | |
705 | (data[6] << 4) + (data[7] >> 4); | |
706 | ||
493630b2 | 707 | wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) | |
82527da3 | 708 | ((data[7] & 0x0f) << 16) | ((data[8] & 0xf0) << 8); |
73a97f4f | 709 | |
7e129783 BT |
710 | wacom->tool[idx] = wacom_intuos_get_tool_type(wacom->id[idx]); |
711 | ||
eff6ca97 | 712 | wacom->shared->stylus_in_proximity = true; |
3bea733a PC |
713 | return 1; |
714 | } | |
715 | ||
c1b03f55 PC |
716 | /* in Range */ |
717 | if ((data[1] & 0xfe) == 0x20) { | |
526d6e7b PC |
718 | if (features->type != INTUOSHT2) |
719 | wacom->shared->stylus_in_proximity = true; | |
486b908d | 720 | |
c1b03f55 PC |
721 | /* in Range while exiting */ |
722 | if (wacom->reporting_data) { | |
723 | input_report_key(input, BTN_TOUCH, 0); | |
724 | input_report_abs(input, ABS_PRESSURE, 0); | |
725 | input_report_abs(input, ABS_DISTANCE, wacom->features.distance_max); | |
726 | return 2; | |
727 | } | |
728 | return 1; | |
4eb1830b JG |
729 | } |
730 | ||
3bea733a PC |
731 | /* Exit report */ |
732 | if ((data[1] & 0xfe) == 0x80) { | |
f3586d2f | 733 | wacom->shared->stylus_in_proximity = false; |
b3bd7ef3 | 734 | wacom->reporting_data = false; |
ae584ca4 | 735 | |
373a5356 PC |
736 | /* don't report exit if we don't know the ID */ |
737 | if (!wacom->id[idx]) | |
738 | return 1; | |
739 | ||
6f660f12 PC |
740 | /* |
741 | * Reset all states otherwise we lose the initial states | |
742 | * when in-prox next time | |
743 | */ | |
8da23fc1 DT |
744 | input_report_abs(input, ABS_X, 0); |
745 | input_report_abs(input, ABS_Y, 0); | |
746 | input_report_abs(input, ABS_DISTANCE, 0); | |
747 | input_report_abs(input, ABS_TILT_X, 0); | |
748 | input_report_abs(input, ABS_TILT_Y, 0); | |
80d4e8e9 | 749 | if (wacom->tool[idx] >= BTN_TOOL_MOUSE) { |
8da23fc1 DT |
750 | input_report_key(input, BTN_LEFT, 0); |
751 | input_report_key(input, BTN_MIDDLE, 0); | |
752 | input_report_key(input, BTN_RIGHT, 0); | |
753 | input_report_key(input, BTN_SIDE, 0); | |
754 | input_report_key(input, BTN_EXTRA, 0); | |
755 | input_report_abs(input, ABS_THROTTLE, 0); | |
756 | input_report_abs(input, ABS_RZ, 0); | |
7ecfbfd3 | 757 | } else { |
8da23fc1 DT |
758 | input_report_abs(input, ABS_PRESSURE, 0); |
759 | input_report_key(input, BTN_STYLUS, 0); | |
760 | input_report_key(input, BTN_STYLUS2, 0); | |
761 | input_report_key(input, BTN_TOUCH, 0); | |
762 | input_report_abs(input, ABS_WHEEL, 0); | |
e33da8a5 | 763 | if (features->type >= INTUOS3S) |
8da23fc1 | 764 | input_report_abs(input, ABS_Z, 0); |
8d32e3ae | 765 | } |
8da23fc1 DT |
766 | input_report_key(input, wacom->tool[idx], 0); |
767 | input_report_abs(input, ABS_MISC, 0); /* reset tool id */ | |
768 | input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]); | |
6f660f12 | 769 | wacom->id[idx] = 0; |
80d4e8e9 | 770 | return 2; |
3bea733a | 771 | } |
373a5356 | 772 | |
3bea733a PC |
773 | return 0; |
774 | } | |
775 | ||
72b236d6 AS |
776 | static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len) |
777 | { | |
778 | unsigned char *data = wacom_wac->data; | |
7c35dc3c | 779 | struct input_dev *input; |
72b236d6 | 780 | struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac); |
83e6b40e | 781 | struct wacom_remote *remote = wacom->remote; |
72b236d6 AS |
782 | int bat_charging, bat_percent, touch_ring_mode; |
783 | __u32 serial; | |
7c35dc3c BT |
784 | int i, index = -1; |
785 | unsigned long flags; | |
72b236d6 AS |
786 | |
787 | if (data[0] != WACOM_REPORT_REMOTE) { | |
7c35dc3c BT |
788 | hid_dbg(wacom->hdev, "%s: received unknown report #%d", |
789 | __func__, data[0]); | |
72b236d6 AS |
790 | return 0; |
791 | } | |
792 | ||
793 | serial = data[3] + (data[4] << 8) + (data[5] << 16); | |
794 | wacom_wac->id[0] = PAD_DEVICE_ID; | |
795 | ||
7c35dc3c BT |
796 | spin_lock_irqsave(&remote->remote_lock, flags); |
797 | ||
798 | for (i = 0; i < WACOM_MAX_REMOTES; i++) { | |
799 | if (remote->remotes[i].serial == serial) { | |
800 | index = i; | |
801 | break; | |
802 | } | |
803 | } | |
804 | ||
805 | if (index < 0 || !remote->remotes[index].registered) | |
806 | goto out; | |
807 | ||
808 | input = remote->remotes[index].input; | |
809 | ||
72b236d6 AS |
810 | input_report_key(input, BTN_0, (data[9] & 0x01)); |
811 | input_report_key(input, BTN_1, (data[9] & 0x02)); | |
812 | input_report_key(input, BTN_2, (data[9] & 0x04)); | |
813 | input_report_key(input, BTN_3, (data[9] & 0x08)); | |
814 | input_report_key(input, BTN_4, (data[9] & 0x10)); | |
815 | input_report_key(input, BTN_5, (data[9] & 0x20)); | |
816 | input_report_key(input, BTN_6, (data[9] & 0x40)); | |
817 | input_report_key(input, BTN_7, (data[9] & 0x80)); | |
818 | ||
819 | input_report_key(input, BTN_8, (data[10] & 0x01)); | |
820 | input_report_key(input, BTN_9, (data[10] & 0x02)); | |
821 | input_report_key(input, BTN_A, (data[10] & 0x04)); | |
822 | input_report_key(input, BTN_B, (data[10] & 0x08)); | |
823 | input_report_key(input, BTN_C, (data[10] & 0x10)); | |
824 | input_report_key(input, BTN_X, (data[10] & 0x20)); | |
825 | input_report_key(input, BTN_Y, (data[10] & 0x40)); | |
826 | input_report_key(input, BTN_Z, (data[10] & 0x80)); | |
827 | ||
828 | input_report_key(input, BTN_BASE, (data[11] & 0x01)); | |
829 | input_report_key(input, BTN_BASE2, (data[11] & 0x02)); | |
830 | ||
831 | if (data[12] & 0x80) | |
832 | input_report_abs(input, ABS_WHEEL, (data[12] & 0x7f)); | |
833 | else | |
834 | input_report_abs(input, ABS_WHEEL, 0); | |
835 | ||
836 | bat_percent = data[7] & 0x7f; | |
837 | bat_charging = !!(data[7] & 0x80); | |
838 | ||
839 | if (data[9] | data[10] | (data[11] & 0x03) | data[12]) | |
840 | input_report_abs(input, ABS_MISC, PAD_DEVICE_ID); | |
841 | else | |
842 | input_report_abs(input, ABS_MISC, 0); | |
843 | ||
844 | input_event(input, EV_MSC, MSC_SERIAL, serial); | |
845 | ||
7c35dc3c BT |
846 | input_sync(input); |
847 | ||
72b236d6 AS |
848 | /*Which mode select (LED light) is currently on?*/ |
849 | touch_ring_mode = (data[11] & 0xC0) >> 6; | |
850 | ||
851 | for (i = 0; i < WACOM_MAX_REMOTES; i++) { | |
e7749f6e | 852 | if (remote->remotes[i].serial == serial) |
a50aac71 | 853 | wacom->led.groups[i].select = touch_ring_mode; |
72b236d6 AS |
854 | } |
855 | ||
59d69bc8 BT |
856 | __wacom_notify_battery(&remote->remotes[index].battery, bat_percent, |
857 | bat_charging, 1, bat_charging); | |
72b236d6 | 858 | |
7c35dc3c BT |
859 | out: |
860 | spin_unlock_irqrestore(&remote->remote_lock, flags); | |
861 | return 0; | |
72b236d6 AS |
862 | } |
863 | ||
e6f2813a | 864 | static void wacom_remote_status_irq(struct wacom_wac *wacom_wac, size_t len) |
72b236d6 AS |
865 | { |
866 | struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac); | |
867 | unsigned char *data = wacom_wac->data; | |
83e6b40e | 868 | struct wacom_remote *remote = wacom->remote; |
e6f2813a BT |
869 | struct wacom_remote_data remote_data; |
870 | unsigned long flags; | |
871 | int i, ret; | |
72b236d6 AS |
872 | |
873 | if (data[0] != WACOM_REPORT_DEVICE_LIST) | |
e6f2813a BT |
874 | return; |
875 | ||
876 | memset(&remote_data, 0, sizeof(struct wacom_remote_data)); | |
72b236d6 AS |
877 | |
878 | for (i = 0; i < WACOM_MAX_REMOTES; i++) { | |
879 | int j = i * 6; | |
880 | int serial = (data[j+6] << 16) + (data[j+5] << 8) + data[j+4]; | |
881 | bool connected = data[j+2]; | |
882 | ||
e6f2813a BT |
883 | remote_data.remote[i].serial = serial; |
884 | remote_data.remote[i].connected = connected; | |
885 | } | |
72b236d6 | 886 | |
83e6b40e | 887 | spin_lock_irqsave(&remote->remote_lock, flags); |
72b236d6 | 888 | |
83e6b40e | 889 | ret = kfifo_in(&remote->remote_fifo, &remote_data, sizeof(remote_data)); |
e6f2813a | 890 | if (ret != sizeof(remote_data)) { |
83e6b40e | 891 | spin_unlock_irqrestore(&remote->remote_lock, flags); |
e6f2813a BT |
892 | hid_err(wacom->hdev, "Can't queue Remote status event.\n"); |
893 | return; | |
72b236d6 | 894 | } |
72b236d6 | 895 | |
83e6b40e | 896 | spin_unlock_irqrestore(&remote->remote_lock, flags); |
72b236d6 | 897 | |
e6f2813a | 898 | wacom_schedule_work(wacom_wac, WACOM_WORKER_REMOTE); |
72b236d6 | 899 | } |
72b236d6 | 900 | |
1924e05e PC |
901 | static inline bool report_touch_events(struct wacom_wac *wacom) |
902 | { | |
903 | return (touch_arbitration ? !wacom->shared->stylus_in_proximity : 1); | |
904 | } | |
72b236d6 | 905 | |
1924e05e PC |
906 | static inline bool delay_pen_events(struct wacom_wac *wacom) |
907 | { | |
908 | return (wacom->shared->touch_down && touch_arbitration); | |
72b236d6 AS |
909 | } |
910 | ||
16e0a6a0 | 911 | static int wacom_intuos_general(struct wacom_wac *wacom) |
3bea733a | 912 | { |
e33da8a5 | 913 | struct wacom_features *features = &wacom->features; |
3bea733a | 914 | unsigned char *data = wacom->data; |
2a6cdbdd | 915 | struct input_dev *input = wacom->pen_input; |
16e0a6a0 | 916 | int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0; |
a8a09c85 | 917 | unsigned char type = (data[1] >> 1) & 0x0F; |
5f33f430 | 918 | unsigned int x, y, distance, t; |
3bea733a | 919 | |
16e0a6a0 JG |
920 | if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_CINTIQ && |
921 | data[0] != WACOM_REPORT_INTUOS_PEN) | |
922 | return 0; | |
923 | ||
1924e05e | 924 | if (delay_pen_events(wacom)) |
c1b03f55 PC |
925 | return 1; |
926 | ||
599b0820 PC |
927 | /* don't report events if we don't know the tool ID */ |
928 | if (!wacom->id[idx]) { | |
929 | /* but reschedule a read of the current tool */ | |
930 | wacom_intuos_schedule_prox_event(wacom); | |
931 | return 1; | |
932 | } | |
933 | ||
4750f5fe PC |
934 | /* |
935 | * don't report events for invalid data | |
936 | */ | |
937 | /* older I4 styli don't work with new Cintiqs */ | |
82527da3 | 938 | if ((!((wacom->id[idx] >> 16) & 0x01) && |
4750f5fe PC |
939 | (features->type == WACOM_21UX2)) || |
940 | /* Only large Intuos support Lense Cursor */ | |
941 | (wacom->tool[idx] == BTN_TOOL_LENS && | |
942 | (features->type == INTUOS3 || | |
943 | features->type == INTUOS3S || | |
944 | features->type == INTUOS4 || | |
945 | features->type == INTUOS4S || | |
946 | features->type == INTUOS5 || | |
947 | features->type == INTUOS5S || | |
948 | features->type == INTUOSPM || | |
949 | features->type == INTUOSPS)) || | |
950 | /* Cintiq doesn't send data when RDY bit isn't set */ | |
951 | (features->type == CINTIQ && !(data[1] & 0x40))) | |
952 | return 1; | |
953 | ||
5f33f430 JG |
954 | x = (be16_to_cpup((__be16 *)&data[2]) << 1) | ((data[9] >> 1) & 1); |
955 | y = (be16_to_cpup((__be16 *)&data[4]) << 1) | (data[9] & 1); | |
956 | distance = data[9] >> 2; | |
957 | if (features->type < INTUOS3S) { | |
958 | x >>= 1; | |
959 | y >>= 1; | |
960 | distance >>= 1; | |
16e0a6a0 | 961 | } |
5f33f430 JG |
962 | input_report_abs(input, ABS_X, x); |
963 | input_report_abs(input, ABS_Y, y); | |
964 | input_report_abs(input, ABS_DISTANCE, distance); | |
16e0a6a0 | 965 | |
a8a09c85 JG |
966 | switch (type) { |
967 | case 0x00: | |
968 | case 0x01: | |
969 | case 0x02: | |
970 | case 0x03: | |
971 | /* general pen packet */ | |
5f33f430 JG |
972 | t = (data[6] << 3) | ((data[7] & 0xC0) >> 5) | (data[1] & 1); |
973 | if (features->pressure_max < 2047) | |
974 | t >>= 1; | |
8da23fc1 | 975 | input_report_abs(input, ABS_PRESSURE, t); |
eda01dab PC |
976 | if (features->type != INTUOSHT2) { |
977 | input_report_abs(input, ABS_TILT_X, | |
ec5fc1c1 | 978 | (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64); |
eda01dab PC |
979 | input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64); |
980 | } | |
8da23fc1 DT |
981 | input_report_key(input, BTN_STYLUS, data[1] & 2); |
982 | input_report_key(input, BTN_STYLUS2, data[1] & 4); | |
983 | input_report_key(input, BTN_TOUCH, t > 10); | |
a8a09c85 | 984 | break; |
3bea733a | 985 | |
a8a09c85 | 986 | case 0x0a: |
a8a09c85 | 987 | /* airbrush second packet */ |
8da23fc1 | 988 | input_report_abs(input, ABS_WHEEL, |
3bea733a | 989 | (data[6] << 2) | ((data[7] >> 6) & 3)); |
8da23fc1 | 990 | input_report_abs(input, ABS_TILT_X, |
ec5fc1c1 JG |
991 | (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64); |
992 | input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64); | |
a8a09c85 | 993 | break; |
3bea733a | 994 | |
a8a09c85 | 995 | case 0x05: |
a8a09c85 JG |
996 | /* Rotation packet */ |
997 | if (features->type >= INTUOS3S) { | |
998 | /* I3 marker pen rotation */ | |
999 | t = (data[6] << 3) | ((data[7] >> 5) & 7); | |
1000 | t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) : | |
1001 | ((t-1) / 2 + 450)) : (450 - t / 2) ; | |
1002 | input_report_abs(input, ABS_Z, t); | |
1003 | } else { | |
571f572f | 1004 | /* 4D mouse 2nd packet */ |
a8a09c85 JG |
1005 | t = (data[6] << 3) | ((data[7] >> 5) & 7); |
1006 | input_report_abs(input, ABS_RZ, (data[7] & 0x20) ? | |
1007 | ((t - 1) / 2) : -t / 2); | |
1008 | } | |
1009 | break; | |
3bea733a | 1010 | |
a8a09c85 | 1011 | case 0x04: |
571f572f JG |
1012 | /* 4D mouse 1st packet */ |
1013 | input_report_key(input, BTN_LEFT, data[8] & 0x01); | |
1014 | input_report_key(input, BTN_MIDDLE, data[8] & 0x02); | |
1015 | input_report_key(input, BTN_RIGHT, data[8] & 0x04); | |
1016 | ||
1017 | input_report_key(input, BTN_SIDE, data[8] & 0x20); | |
1018 | input_report_key(input, BTN_EXTRA, data[8] & 0x10); | |
1019 | t = (data[6] << 2) | ((data[7] >> 6) & 3); | |
1020 | input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t); | |
1021 | break; | |
1022 | ||
a8a09c85 | 1023 | case 0x06: |
571f572f JG |
1024 | /* I4 mouse */ |
1025 | input_report_key(input, BTN_LEFT, data[6] & 0x01); | |
1026 | input_report_key(input, BTN_MIDDLE, data[6] & 0x02); | |
1027 | input_report_key(input, BTN_RIGHT, data[6] & 0x04); | |
1028 | input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7) | |
1029 | - ((data[7] & 0x40) >> 6)); | |
1030 | input_report_key(input, BTN_SIDE, data[6] & 0x08); | |
1031 | input_report_key(input, BTN_EXTRA, data[6] & 0x10); | |
3bea733a | 1032 | |
571f572f JG |
1033 | input_report_abs(input, ABS_TILT_X, |
1034 | (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64); | |
1035 | input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64); | |
1036 | break; | |
1037 | ||
1038 | case 0x08: | |
1039 | if (wacom->tool[idx] == BTN_TOOL_MOUSE) { | |
1040 | /* 2D mouse packet */ | |
1041 | input_report_key(input, BTN_LEFT, data[8] & 0x04); | |
1042 | input_report_key(input, BTN_MIDDLE, data[8] & 0x08); | |
1043 | input_report_key(input, BTN_RIGHT, data[8] & 0x10); | |
1044 | input_report_rel(input, REL_WHEEL, (data[8] & 0x01) | |
1045 | - ((data[8] & 0x02) >> 1)); | |
1046 | ||
1047 | /* I3 2D mouse side buttons */ | |
1048 | if (features->type >= INTUOS3S && features->type <= INTUOS3L) { | |
1049 | input_report_key(input, BTN_SIDE, data[8] & 0x40); | |
1050 | input_report_key(input, BTN_EXTRA, data[8] & 0x20); | |
3bea733a | 1051 | } |
a8a09c85 | 1052 | } |
571f572f | 1053 | else if (wacom->tool[idx] == BTN_TOOL_LENS) { |
3bea733a | 1054 | /* Lens cursor packets */ |
8da23fc1 DT |
1055 | input_report_key(input, BTN_LEFT, data[8] & 0x01); |
1056 | input_report_key(input, BTN_MIDDLE, data[8] & 0x02); | |
1057 | input_report_key(input, BTN_RIGHT, data[8] & 0x04); | |
1058 | input_report_key(input, BTN_SIDE, data[8] & 0x10); | |
1059 | input_report_key(input, BTN_EXTRA, data[8] & 0x08); | |
3bea733a | 1060 | } |
a8a09c85 JG |
1061 | break; |
1062 | ||
571f572f | 1063 | case 0x07: |
a8a09c85 | 1064 | case 0x09: |
571f572f | 1065 | case 0x0b: |
a8a09c85 JG |
1066 | case 0x0c: |
1067 | case 0x0d: | |
1068 | case 0x0e: | |
1069 | case 0x0f: | |
1070 | /* unhandled */ | |
1071 | break; | |
3bea733a | 1072 | } |
3bea733a | 1073 | |
82527da3 JG |
1074 | input_report_abs(input, ABS_MISC, |
1075 | wacom_intuos_id_mangle(wacom->id[idx])); /* report tool id */ | |
8da23fc1 DT |
1076 | input_report_key(input, wacom->tool[idx], 1); |
1077 | input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]); | |
b3bd7ef3 | 1078 | wacom->reporting_data = true; |
16e0a6a0 | 1079 | return 2; |
3bea733a PC |
1080 | } |
1081 | ||
95dd3b30 | 1082 | static int wacom_intuos_irq(struct wacom_wac *wacom) |
3bea733a PC |
1083 | { |
1084 | unsigned char *data = wacom->data; | |
2a6cdbdd | 1085 | struct input_dev *input = wacom->pen_input; |
16e0a6a0 | 1086 | int result; |
3bea733a | 1087 | |
eb71d1bb | 1088 | if (data[0] != WACOM_REPORT_PENABLED && |
06109993 JG |
1089 | data[0] != WACOM_REPORT_INTUOS_ID1 && |
1090 | data[0] != WACOM_REPORT_INTUOS_ID2 && | |
eb71d1bb | 1091 | data[0] != WACOM_REPORT_INTUOSPAD && |
eda01dab | 1092 | data[0] != WACOM_REPORT_INTUOS_PEN && |
500d4160 PC |
1093 | data[0] != WACOM_REPORT_CINTIQ && |
1094 | data[0] != WACOM_REPORT_CINTIQPAD && | |
eb71d1bb DT |
1095 | data[0] != WACOM_REPORT_INTUOS5PAD) { |
1096 | dev_dbg(input->dev.parent, | |
1097 | "%s: received unknown report #%d\n", __func__, data[0]); | |
3bea733a PC |
1098 | return 0; |
1099 | } | |
1100 | ||
16e0a6a0 JG |
1101 | /* process pad events */ |
1102 | result = wacom_intuos_pad(wacom); | |
1103 | if (result) | |
1104 | return result; | |
3bea733a PC |
1105 | |
1106 | /* process in/out prox events */ | |
95dd3b30 | 1107 | result = wacom_intuos_inout(wacom); |
3bea733a | 1108 | if (result) |
16e0a6a0 | 1109 | return result - 1; |
3bea733a PC |
1110 | |
1111 | /* process general packets */ | |
16e0a6a0 JG |
1112 | result = wacom_intuos_general(wacom); |
1113 | if (result) | |
1114 | return result - 1; | |
3bea733a | 1115 | |
16e0a6a0 | 1116 | return 0; |
3bea733a PC |
1117 | } |
1118 | ||
b1e4279e JG |
1119 | static int int_dist(int x1, int y1, int x2, int y2) |
1120 | { | |
1121 | int x = x2 - x1; | |
1122 | int y = y2 - y1; | |
1123 | ||
1124 | return int_sqrt(x*x + y*y); | |
1125 | } | |
1126 | ||
81af7e61 BT |
1127 | static void wacom_intuos_bt_process_data(struct wacom_wac *wacom, |
1128 | unsigned char *data) | |
1129 | { | |
1130 | memcpy(wacom->data, data, 10); | |
1131 | wacom_intuos_irq(wacom); | |
1132 | ||
2a6cdbdd | 1133 | input_sync(wacom->pen_input); |
81af7e61 BT |
1134 | if (wacom->pad_input) |
1135 | input_sync(wacom->pad_input); | |
1136 | } | |
1137 | ||
1138 | static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len) | |
1139 | { | |
1140 | unsigned char data[WACOM_PKGLEN_MAX]; | |
1141 | int i = 1; | |
1142 | unsigned power_raw, battery_capacity, bat_charging, ps_connected; | |
1143 | ||
1144 | memcpy(data, wacom->data, len); | |
1145 | ||
1146 | switch (data[0]) { | |
1147 | case 0x04: | |
1148 | wacom_intuos_bt_process_data(wacom, data + i); | |
1149 | i += 10; | |
1150 | /* fall through */ | |
1151 | case 0x03: | |
1152 | wacom_intuos_bt_process_data(wacom, data + i); | |
1153 | i += 10; | |
1154 | wacom_intuos_bt_process_data(wacom, data + i); | |
1155 | i += 10; | |
1156 | power_raw = data[i]; | |
1157 | bat_charging = (power_raw & 0x08) ? 1 : 0; | |
1158 | ps_connected = (power_raw & 0x10) ? 1 : 0; | |
1159 | battery_capacity = batcap_i4[power_raw & 0x07]; | |
953f2c5f | 1160 | wacom_notify_battery(wacom, battery_capacity, bat_charging, |
71fa641e | 1161 | battery_capacity || bat_charging, |
953f2c5f | 1162 | ps_connected); |
81af7e61 BT |
1163 | break; |
1164 | default: | |
2a6cdbdd | 1165 | dev_dbg(wacom->pen_input->dev.parent, |
81af7e61 BT |
1166 | "Unknown report: %d,%d size:%zu\n", |
1167 | data[0], data[1], len); | |
1168 | return 0; | |
1169 | } | |
1170 | return 0; | |
1171 | } | |
1172 | ||
7d059ed0 PC |
1173 | static int wacom_wac_finger_count_touches(struct wacom_wac *wacom) |
1174 | { | |
2a6cdbdd | 1175 | struct input_dev *input = wacom->touch_input; |
7d059ed0 PC |
1176 | unsigned touch_max = wacom->features.touch_max; |
1177 | int count = 0; | |
1178 | int i; | |
1179 | ||
26ba61f8 PC |
1180 | if (!touch_max) |
1181 | return 0; | |
1182 | ||
71b5c476 JG |
1183 | if (touch_max == 1) |
1184 | return test_bit(BTN_TOUCH, input->key) && | |
1924e05e | 1185 | report_touch_events(wacom); |
7d059ed0 PC |
1186 | |
1187 | for (i = 0; i < input->mt->num_slots; i++) { | |
1188 | struct input_mt_slot *ps = &input->mt->slots[i]; | |
1189 | int id = input_mt_get_value(ps, ABS_MT_TRACKING_ID); | |
1190 | if (id >= 0) | |
1191 | count++; | |
1192 | } | |
1193 | ||
1194 | return count; | |
1195 | } | |
1196 | ||
4922cd26 JG |
1197 | static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom) |
1198 | { | |
1199 | const int pen_frame_len = 14; | |
1200 | const int pen_frames = 7; | |
1201 | ||
1202 | struct input_dev *pen_input = wacom->pen_input; | |
1203 | unsigned char *data = wacom->data; | |
1204 | int i; | |
1205 | ||
1206 | wacom->serial[0] = get_unaligned_le64(&data[99]); | |
1207 | wacom->id[0] = get_unaligned_le16(&data[107]); | |
1208 | if (wacom->serial[0] >> 52 == 1) { | |
1209 | /* Add back in missing bits of ID for non-USI pens */ | |
1210 | wacom->id[0] |= (wacom->serial[0] >> 32) & 0xFFFFF; | |
1211 | } | |
1212 | wacom->tool[0] = wacom_intuos_get_tool_type(wacom_intuos_id_mangle(wacom->id[0])); | |
1213 | ||
1214 | for (i = 0; i < pen_frames; i++) { | |
1215 | unsigned char *frame = &data[i*pen_frame_len + 1]; | |
a48324de JG |
1216 | bool valid = frame[0] & 0x80; |
1217 | bool prox = frame[0] & 0x40; | |
1218 | bool range = frame[0] & 0x20; | |
4922cd26 | 1219 | |
a48324de | 1220 | if (!valid) |
4922cd26 JG |
1221 | continue; |
1222 | ||
a48324de JG |
1223 | if (range) { |
1224 | input_report_abs(pen_input, ABS_X, get_unaligned_le16(&frame[1])); | |
1225 | input_report_abs(pen_input, ABS_Y, get_unaligned_le16(&frame[3])); | |
1226 | input_report_abs(pen_input, ABS_TILT_X, frame[7]); | |
1227 | input_report_abs(pen_input, ABS_TILT_Y, frame[8]); | |
1228 | input_report_abs(pen_input, ABS_Z, get_unaligned_le16(&frame[9])); | |
1229 | input_report_abs(pen_input, ABS_WHEEL, get_unaligned_le16(&frame[11])); | |
1230 | } | |
4922cd26 | 1231 | input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5])); |
a48324de | 1232 | input_report_abs(pen_input, ABS_DISTANCE, range ? frame[13] : wacom->features.distance_max); |
4922cd26 JG |
1233 | |
1234 | input_report_key(pen_input, BTN_TOUCH, frame[0] & 0x01); | |
1235 | input_report_key(pen_input, BTN_STYLUS, frame[0] & 0x02); | |
1236 | input_report_key(pen_input, BTN_STYLUS2, frame[0] & 0x04); | |
1237 | ||
a48324de | 1238 | input_report_key(pen_input, wacom->tool[0], prox); |
4922cd26 JG |
1239 | input_event(pen_input, EV_MSC, MSC_SERIAL, wacom->serial[0]); |
1240 | input_report_abs(pen_input, ABS_MISC, | |
1241 | wacom_intuos_id_mangle(wacom->id[0])); /* report tool id */ | |
1242 | ||
a48324de | 1243 | wacom->shared->stylus_in_proximity = prox; |
4922cd26 JG |
1244 | |
1245 | input_sync(pen_input); | |
1246 | } | |
1247 | } | |
1248 | ||
1249 | static void wacom_intuos_pro2_bt_touch(struct wacom_wac *wacom) | |
1250 | { | |
1251 | const int finger_touch_len = 8; | |
1252 | const int finger_frames = 4; | |
1253 | const int finger_frame_len = 43; | |
1254 | ||
1255 | struct input_dev *touch_input = wacom->touch_input; | |
1256 | unsigned char *data = wacom->data; | |
1257 | int num_contacts_left = 5; | |
1258 | int i, j; | |
1259 | ||
1260 | for (i = 0; i < finger_frames; i++) { | |
1261 | unsigned char *frame = &data[i*finger_frame_len + 109]; | |
1262 | int current_num_contacts = frame[0] & 0x7F; | |
1263 | int contacts_to_send; | |
1264 | ||
1265 | if (!(frame[0] & 0x80)) | |
1266 | continue; | |
1267 | ||
1268 | /* | |
1269 | * First packet resets the counter since only the first | |
1270 | * packet in series will have non-zero current_num_contacts. | |
1271 | */ | |
1272 | if (current_num_contacts) | |
1273 | wacom->num_contacts_left = current_num_contacts; | |
1274 | ||
1275 | contacts_to_send = min(num_contacts_left, wacom->num_contacts_left); | |
1276 | ||
1277 | for (j = 0; j < contacts_to_send; j++) { | |
1278 | unsigned char *touch = &frame[j*finger_touch_len + 1]; | |
1279 | int slot = input_mt_get_slot_by_key(touch_input, touch[0]); | |
1280 | int x = get_unaligned_le16(&touch[2]); | |
1281 | int y = get_unaligned_le16(&touch[4]); | |
1282 | int w = touch[6] * input_abs_get_res(touch_input, ABS_MT_POSITION_X); | |
1283 | int h = touch[7] * input_abs_get_res(touch_input, ABS_MT_POSITION_Y); | |
1284 | ||
1285 | if (slot < 0) | |
1286 | continue; | |
1287 | ||
1288 | input_mt_slot(touch_input, slot); | |
1289 | input_mt_report_slot_state(touch_input, MT_TOOL_FINGER, touch[1] & 0x01); | |
1290 | input_report_abs(touch_input, ABS_MT_POSITION_X, x); | |
1291 | input_report_abs(touch_input, ABS_MT_POSITION_Y, y); | |
1292 | input_report_abs(touch_input, ABS_MT_TOUCH_MAJOR, max(w, h)); | |
1293 | input_report_abs(touch_input, ABS_MT_TOUCH_MINOR, min(w, h)); | |
1294 | input_report_abs(touch_input, ABS_MT_ORIENTATION, w > h); | |
1295 | } | |
1296 | ||
1297 | input_mt_sync_frame(touch_input); | |
1298 | ||
1299 | wacom->num_contacts_left -= contacts_to_send; | |
1300 | if (wacom->num_contacts_left <= 0) { | |
1301 | wacom->num_contacts_left = 0; | |
1302 | wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); | |
1303 | } | |
1304 | } | |
1305 | ||
1306 | input_report_switch(touch_input, SW_MUTE_DEVICE, !(data[281] >> 7)); | |
1307 | input_sync(touch_input); | |
1308 | } | |
1309 | ||
1310 | static void wacom_intuos_pro2_bt_pad(struct wacom_wac *wacom) | |
1311 | { | |
1312 | struct input_dev *pad_input = wacom->pad_input; | |
1313 | unsigned char *data = wacom->data; | |
1314 | ||
1315 | int buttons = (data[282] << 1) | ((data[281] >> 6) & 0x01); | |
1316 | int ring = data[285]; | |
1317 | int prox = buttons | (ring & 0x80); | |
1318 | ||
1319 | wacom_report_numbered_buttons(pad_input, 9, buttons); | |
1320 | ||
1321 | input_report_abs(pad_input, ABS_WHEEL, (ring & 0x80) ? (ring & 0x7f) : 0); | |
1322 | ||
1323 | input_report_key(pad_input, wacom->tool[1], prox ? 1 : 0); | |
1324 | input_report_abs(pad_input, ABS_MISC, prox ? PAD_DEVICE_ID : 0); | |
1325 | input_event(pad_input, EV_MSC, MSC_SERIAL, 0xffffffff); | |
1326 | ||
1327 | input_sync(pad_input); | |
1328 | } | |
1329 | ||
1330 | static void wacom_intuos_pro2_bt_battery(struct wacom_wac *wacom) | |
1331 | { | |
1332 | unsigned char *data = wacom->data; | |
1333 | ||
1334 | bool chg = data[284] & 0x80; | |
1335 | int battery_status = data[284] & 0x7F; | |
1336 | ||
1337 | wacom_notify_battery(wacom, battery_status, chg, 1, chg); | |
1338 | } | |
1339 | ||
1340 | static int wacom_intuos_pro2_bt_irq(struct wacom_wac *wacom, size_t len) | |
1341 | { | |
1342 | unsigned char *data = wacom->data; | |
1343 | ||
1344 | if (data[0] != 0x80) { | |
1345 | dev_dbg(wacom->pen_input->dev.parent, | |
1346 | "%s: received unknown report #%d\n", __func__, data[0]); | |
1347 | return 0; | |
1348 | } | |
1349 | ||
1350 | wacom_intuos_pro2_bt_pen(wacom); | |
1351 | wacom_intuos_pro2_bt_touch(wacom); | |
1352 | wacom_intuos_pro2_bt_pad(wacom); | |
1353 | wacom_intuos_pro2_bt_battery(wacom); | |
1354 | return 0; | |
1355 | } | |
1356 | ||
b1e4279e JG |
1357 | static int wacom_24hdt_irq(struct wacom_wac *wacom) |
1358 | { | |
2a6cdbdd | 1359 | struct input_dev *input = wacom->touch_input; |
74b63417 | 1360 | unsigned char *data = wacom->data; |
b1e4279e | 1361 | int i; |
e0d41fd4 | 1362 | int current_num_contacts = data[61]; |
b1e4279e | 1363 | int contacts_to_send = 0; |
500d4160 PC |
1364 | int num_contacts_left = 4; /* maximum contacts per packet */ |
1365 | int byte_per_packet = WACOM_BYTES_PER_24HDT_PACKET; | |
1366 | int y_offset = 2; | |
1367 | ||
1368 | if (wacom->features.type == WACOM_27QHDT) { | |
1369 | current_num_contacts = data[63]; | |
1370 | num_contacts_left = 10; | |
1371 | byte_per_packet = WACOM_BYTES_PER_QHDTHID_PACKET; | |
1372 | y_offset = 0; | |
500d4160 | 1373 | } |
b1e4279e JG |
1374 | |
1375 | /* | |
1376 | * First packet resets the counter since only the first | |
1377 | * packet in series will have non-zero current_num_contacts. | |
1378 | */ | |
7d059ed0 | 1379 | if (current_num_contacts) |
b1e4279e JG |
1380 | wacom->num_contacts_left = current_num_contacts; |
1381 | ||
500d4160 | 1382 | contacts_to_send = min(num_contacts_left, wacom->num_contacts_left); |
b1e4279e JG |
1383 | |
1384 | for (i = 0; i < contacts_to_send; i++) { | |
500d4160 | 1385 | int offset = (byte_per_packet * i) + 1; |
1924e05e | 1386 | bool touch = (data[offset] & 0x1) && report_touch_events(wacom); |
02295e68 | 1387 | int slot = input_mt_get_slot_by_key(input, data[offset + 1]); |
b1e4279e JG |
1388 | |
1389 | if (slot < 0) | |
1390 | continue; | |
1391 | input_mt_slot(input, slot); | |
1392 | input_mt_report_slot_state(input, MT_TOOL_FINGER, touch); | |
1393 | ||
1394 | if (touch) { | |
edc8e20a | 1395 | int t_x = get_unaligned_le16(&data[offset + 2]); |
500d4160 | 1396 | int t_y = get_unaligned_le16(&data[offset + 4 + y_offset]); |
b1e4279e JG |
1397 | |
1398 | input_report_abs(input, ABS_MT_POSITION_X, t_x); | |
1399 | input_report_abs(input, ABS_MT_POSITION_Y, t_y); | |
500d4160 PC |
1400 | |
1401 | if (wacom->features.type != WACOM_27QHDT) { | |
1402 | int c_x = get_unaligned_le16(&data[offset + 4]); | |
1403 | int c_y = get_unaligned_le16(&data[offset + 8]); | |
1404 | int w = get_unaligned_le16(&data[offset + 10]); | |
1405 | int h = get_unaligned_le16(&data[offset + 12]); | |
1406 | ||
1407 | input_report_abs(input, ABS_MT_TOUCH_MAJOR, min(w,h)); | |
1408 | input_report_abs(input, ABS_MT_WIDTH_MAJOR, | |
1409 | min(w, h) + int_dist(t_x, t_y, c_x, c_y)); | |
1410 | input_report_abs(input, ABS_MT_WIDTH_MINOR, min(w, h)); | |
1411 | input_report_abs(input, ABS_MT_ORIENTATION, w > h); | |
1412 | } | |
b1e4279e | 1413 | } |
b1e4279e | 1414 | } |
9a1c0012 | 1415 | input_mt_sync_frame(input); |
b1e4279e JG |
1416 | |
1417 | wacom->num_contacts_left -= contacts_to_send; | |
e0d41fd4 | 1418 | if (wacom->num_contacts_left <= 0) { |
b1e4279e | 1419 | wacom->num_contacts_left = 0; |
7d059ed0 | 1420 | wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); |
e0d41fd4 | 1421 | } |
b1e4279e JG |
1422 | return 1; |
1423 | } | |
1424 | ||
1963518b PC |
1425 | static int wacom_mt_touch(struct wacom_wac *wacom) |
1426 | { | |
2a6cdbdd | 1427 | struct input_dev *input = wacom->touch_input; |
74b63417 | 1428 | unsigned char *data = wacom->data; |
1963518b PC |
1429 | int i; |
1430 | int current_num_contacts = data[2]; | |
1431 | int contacts_to_send = 0; | |
6afdc289 PC |
1432 | int x_offset = 0; |
1433 | ||
1434 | /* MTTPC does not support Height and Width */ | |
d51ddb2b | 1435 | if (wacom->features.type == MTTPC || wacom->features.type == MTTPC_B) |
6afdc289 | 1436 | x_offset = -4; |
1963518b PC |
1437 | |
1438 | /* | |
1439 | * First packet resets the counter since only the first | |
1440 | * packet in series will have non-zero current_num_contacts. | |
1441 | */ | |
7d059ed0 | 1442 | if (current_num_contacts) |
1963518b PC |
1443 | wacom->num_contacts_left = current_num_contacts; |
1444 | ||
1445 | /* There are at most 5 contacts per packet */ | |
1446 | contacts_to_send = min(5, wacom->num_contacts_left); | |
1447 | ||
1448 | for (i = 0; i < contacts_to_send; i++) { | |
6afdc289 | 1449 | int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset) * i + 3; |
1924e05e | 1450 | bool touch = (data[offset] & 0x1) && report_touch_events(wacom); |
edc8e20a | 1451 | int id = get_unaligned_le16(&data[offset + 1]); |
02295e68 | 1452 | int slot = input_mt_get_slot_by_key(input, id); |
1963518b PC |
1453 | |
1454 | if (slot < 0) | |
1455 | continue; | |
1456 | ||
1457 | input_mt_slot(input, slot); | |
1458 | input_mt_report_slot_state(input, MT_TOOL_FINGER, touch); | |
1459 | if (touch) { | |
edc8e20a JG |
1460 | int x = get_unaligned_le16(&data[offset + x_offset + 7]); |
1461 | int y = get_unaligned_le16(&data[offset + x_offset + 9]); | |
1963518b PC |
1462 | input_report_abs(input, ABS_MT_POSITION_X, x); |
1463 | input_report_abs(input, ABS_MT_POSITION_Y, y); | |
1464 | } | |
1963518b | 1465 | } |
9a1c0012 | 1466 | input_mt_sync_frame(input); |
1963518b PC |
1467 | |
1468 | wacom->num_contacts_left -= contacts_to_send; | |
e0d41fd4 | 1469 | if (wacom->num_contacts_left <= 0) { |
1963518b | 1470 | wacom->num_contacts_left = 0; |
7d059ed0 | 1471 | wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); |
e0d41fd4 | 1472 | } |
1963518b PC |
1473 | return 1; |
1474 | } | |
1475 | ||
84eb5aa6 PC |
1476 | static int wacom_tpc_mt_touch(struct wacom_wac *wacom) |
1477 | { | |
2a6cdbdd | 1478 | struct input_dev *input = wacom->touch_input; |
84eb5aa6 | 1479 | unsigned char *data = wacom->data; |
84eb5aa6 PC |
1480 | int i; |
1481 | ||
1482 | for (i = 0; i < 2; i++) { | |
1483 | int p = data[1] & (1 << i); | |
1924e05e | 1484 | bool touch = p && report_touch_events(wacom); |
84eb5aa6 PC |
1485 | |
1486 | input_mt_slot(input, i); | |
1487 | input_mt_report_slot_state(input, MT_TOOL_FINGER, touch); | |
1488 | if (touch) { | |
1489 | int x = le16_to_cpup((__le16 *)&data[i * 2 + 2]) & 0x7fff; | |
1490 | int y = le16_to_cpup((__le16 *)&data[i * 2 + 6]) & 0x7fff; | |
1491 | ||
1492 | input_report_abs(input, ABS_MT_POSITION_X, x); | |
1493 | input_report_abs(input, ABS_MT_POSITION_Y, y); | |
84eb5aa6 PC |
1494 | } |
1495 | } | |
9a1c0012 | 1496 | input_mt_sync_frame(input); |
84eb5aa6 PC |
1497 | |
1498 | /* keep touch state for pen event */ | |
7d059ed0 | 1499 | wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); |
84eb5aa6 | 1500 | |
84eb5aa6 PC |
1501 | return 1; |
1502 | } | |
1503 | ||
a43c7c53 | 1504 | static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len) |
ec67bbed | 1505 | { |
74b63417 | 1506 | unsigned char *data = wacom->data; |
2a6cdbdd | 1507 | struct input_dev *input = wacom->touch_input; |
1924e05e | 1508 | bool prox = report_touch_events(wacom); |
a43c7c53 | 1509 | int x = 0, y = 0; |
ec67bbed | 1510 | |
1963518b PC |
1511 | if (wacom->features.touch_max > 1 || len > WACOM_PKGLEN_TPC2FG) |
1512 | return 0; | |
1513 | ||
e0d41fd4 PC |
1514 | if (len == WACOM_PKGLEN_TPC1FG) { |
1515 | prox = prox && (data[0] & 0x01); | |
1516 | x = get_unaligned_le16(&data[1]); | |
1517 | y = get_unaligned_le16(&data[3]); | |
1518 | } else if (len == WACOM_PKGLEN_TPC1FG_B) { | |
1519 | prox = prox && (data[2] & 0x01); | |
1520 | x = get_unaligned_le16(&data[3]); | |
1521 | y = get_unaligned_le16(&data[5]); | |
1522 | } else { | |
1523 | prox = prox && (data[1] & 0x01); | |
1524 | x = le16_to_cpup((__le16 *)&data[2]); | |
1525 | y = le16_to_cpup((__le16 *)&data[4]); | |
1526 | } | |
ec67bbed | 1527 | |
a43c7c53 PC |
1528 | if (prox) { |
1529 | input_report_abs(input, ABS_X, x); | |
1530 | input_report_abs(input, ABS_Y, y); | |
1531 | } | |
1532 | input_report_key(input, BTN_TOUCH, prox); | |
73a97f4f | 1533 | |
a43c7c53 PC |
1534 | /* keep touch state for pen events */ |
1535 | wacom->shared->touch_down = prox; | |
ec67bbed | 1536 | |
a43c7c53 | 1537 | return 1; |
ec67bbed PC |
1538 | } |
1539 | ||
8aa9a9ac | 1540 | static int wacom_tpc_pen(struct wacom_wac *wacom) |
545f4e99 | 1541 | { |
74b63417 | 1542 | unsigned char *data = wacom->data; |
2a6cdbdd | 1543 | struct input_dev *input = wacom->pen_input; |
a43c7c53 | 1544 | bool prox = data[1] & 0x20; |
8aa9a9ac | 1545 | |
a43c7c53 | 1546 | if (!wacom->shared->stylus_in_proximity) /* first in prox */ |
8aa9a9ac PC |
1547 | /* Going into proximity select tool */ |
1548 | wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN; | |
8aa9a9ac | 1549 | |
a43c7c53 PC |
1550 | /* keep pen state for touch events */ |
1551 | wacom->shared->stylus_in_proximity = prox; | |
1552 | ||
1924e05e PC |
1553 | /* send pen events only when touch is up or forced out |
1554 | * or touch arbitration is off | |
1555 | */ | |
1556 | if (!delay_pen_events(wacom)) { | |
a43c7c53 PC |
1557 | input_report_key(input, BTN_STYLUS, data[1] & 0x02); |
1558 | input_report_key(input, BTN_STYLUS2, data[1] & 0x10); | |
1559 | input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); | |
1560 | input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); | |
0b335cad | 1561 | input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x07) << 8) | data[6]); |
a43c7c53 PC |
1562 | input_report_key(input, BTN_TOUCH, data[1] & 0x05); |
1563 | input_report_key(input, wacom->tool[0], prox); | |
1564 | return 1; | |
8aa9a9ac | 1565 | } |
8aa9a9ac | 1566 | |
a43c7c53 | 1567 | return 0; |
8aa9a9ac PC |
1568 | } |
1569 | ||
1570 | static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len) | |
1571 | { | |
74b63417 | 1572 | unsigned char *data = wacom->data; |
545f4e99 | 1573 | |
2a6cdbdd JG |
1574 | if (wacom->pen_input) |
1575 | dev_dbg(wacom->pen_input->dev.parent, | |
1576 | "%s: received report #%d\n", __func__, data[0]); | |
1577 | else if (wacom->touch_input) | |
1578 | dev_dbg(wacom->touch_input->dev.parent, | |
1579 | "%s: received report #%d\n", __func__, data[0]); | |
545f4e99 | 1580 | |
31175a83 PC |
1581 | switch (len) { |
1582 | case WACOM_PKGLEN_TPC1FG: | |
1963518b | 1583 | return wacom_tpc_single_touch(wacom, len); |
31175a83 PC |
1584 | |
1585 | case WACOM_PKGLEN_TPC2FG: | |
1963518b | 1586 | return wacom_tpc_mt_touch(wacom); |
31175a83 | 1587 | |
d51ddb2b JG |
1588 | case WACOM_PKGLEN_PENABLED: |
1589 | return wacom_tpc_pen(wacom); | |
1590 | ||
31175a83 PC |
1591 | default: |
1592 | switch (data[0]) { | |
1593 | case WACOM_REPORT_TPC1FG: | |
1594 | case WACOM_REPORT_TPCHID: | |
1595 | case WACOM_REPORT_TPCST: | |
ac173837 | 1596 | case WACOM_REPORT_TPC1FGE: |
31175a83 PC |
1597 | return wacom_tpc_single_touch(wacom, len); |
1598 | ||
1963518b | 1599 | case WACOM_REPORT_TPCMT: |
d51ddb2b | 1600 | case WACOM_REPORT_TPCMT2: |
1963518b PC |
1601 | return wacom_mt_touch(wacom); |
1602 | ||
31175a83 PC |
1603 | case WACOM_REPORT_PENABLED: |
1604 | return wacom_tpc_pen(wacom); | |
1605 | } | |
1606 | } | |
4492efff | 1607 | |
8aa9a9ac | 1608 | return 0; |
545f4e99 PC |
1609 | } |
1610 | ||
ac2423c9 | 1611 | int wacom_equivalent_usage(int usage) |
c9c09587 JG |
1612 | { |
1613 | if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMDIGITIZER) { | |
1614 | int subpage = (usage & 0xFF00) << 8; | |
1615 | int subusage = (usage & 0xFF); | |
1616 | ||
5922e613 JG |
1617 | if (subpage == WACOM_HID_SP_PAD || |
1618 | subpage == WACOM_HID_SP_BUTTON || | |
1619 | subpage == WACOM_HID_SP_DIGITIZER || | |
b5c921e6 | 1620 | subpage == WACOM_HID_SP_DIGITIZERINFO || |
61ce346a | 1621 | usage == WACOM_HID_WD_SENSE || |
f85c9dc6 JG |
1622 | usage == WACOM_HID_WD_SERIALHI || |
1623 | usage == WACOM_HID_WD_TOOLTYPE || | |
5922e613 | 1624 | usage == WACOM_HID_WD_DISTANCE || |
bf78adcb JG |
1625 | usage == WACOM_HID_WD_TOUCHSTRIP || |
1626 | usage == WACOM_HID_WD_TOUCHSTRIP2 || | |
5922e613 JG |
1627 | usage == WACOM_HID_WD_TOUCHRING || |
1628 | usage == WACOM_HID_WD_TOUCHRINGSTATUS) { | |
c9c09587 JG |
1629 | return usage; |
1630 | } | |
1631 | ||
1632 | if (subpage == HID_UP_UNDEFINED) | |
1633 | subpage = HID_UP_DIGITIZER; | |
1634 | ||
1635 | return subpage | subusage; | |
1636 | } | |
1637 | ||
ac2423c9 AAS |
1638 | if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMTOUCH) { |
1639 | int subpage = (usage & 0xFF00) << 8; | |
1640 | int subusage = (usage & 0xFF); | |
1641 | ||
1642 | if (subpage == HID_UP_UNDEFINED) | |
1643 | subpage = WACOM_HID_SP_DIGITIZER; | |
1644 | ||
1645 | return subpage | subusage; | |
1646 | } | |
1647 | ||
c9c09587 JG |
1648 | return usage; |
1649 | } | |
1650 | ||
2a6cdbdd | 1651 | static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage, |
7704ac93 BT |
1652 | struct hid_field *field, __u8 type, __u16 code, int fuzz) |
1653 | { | |
345857bb JG |
1654 | struct wacom *wacom = input_get_drvdata(input); |
1655 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; | |
1656 | struct wacom_features *features = &wacom_wac->features; | |
7704ac93 BT |
1657 | int fmin = field->logical_minimum; |
1658 | int fmax = field->logical_maximum; | |
c9c09587 | 1659 | unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid); |
50066a04 JG |
1660 | int resolution_code = code; |
1661 | ||
c9c09587 | 1662 | if (equivalent_usage == HID_DG_TWIST) { |
50066a04 JG |
1663 | resolution_code = ABS_RZ; |
1664 | } | |
7704ac93 | 1665 | |
345857bb JG |
1666 | if (equivalent_usage == HID_GD_X) { |
1667 | fmin += features->offset_left; | |
1668 | fmax -= features->offset_right; | |
1669 | } | |
1670 | if (equivalent_usage == HID_GD_Y) { | |
1671 | fmin += features->offset_top; | |
1672 | fmax -= features->offset_bottom; | |
1673 | } | |
1674 | ||
7704ac93 BT |
1675 | usage->type = type; |
1676 | usage->code = code; | |
1677 | ||
1678 | set_bit(type, input->evbit); | |
1679 | ||
1680 | switch (type) { | |
1681 | case EV_ABS: | |
1682 | input_set_abs_params(input, code, fmin, fmax, fuzz, 0); | |
1683 | input_abs_set_res(input, code, | |
50066a04 | 1684 | hidinput_calc_abs_res(field, resolution_code)); |
7704ac93 BT |
1685 | break; |
1686 | case EV_KEY: | |
1687 | input_set_capability(input, EV_KEY, code); | |
1688 | break; | |
1689 | case EV_MSC: | |
1690 | input_set_capability(input, EV_MSC, code); | |
1691 | break; | |
bf78adcb JG |
1692 | case EV_SW: |
1693 | input_set_capability(input, EV_SW, code); | |
1694 | break; | |
7704ac93 BT |
1695 | } |
1696 | } | |
1697 | ||
5922e613 JG |
1698 | static void wacom_wac_pad_usage_mapping(struct hid_device *hdev, |
1699 | struct hid_field *field, struct hid_usage *usage) | |
1700 | { | |
1701 | struct wacom *wacom = hid_get_drvdata(hdev); | |
1702 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; | |
1703 | struct wacom_features *features = &wacom_wac->features; | |
1704 | struct input_dev *input = wacom_wac->pad_input; | |
1705 | unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); | |
1706 | ||
1707 | switch (equivalent_usage) { | |
93aab7fa JG |
1708 | case WACOM_HID_WD_BATTERY_LEVEL: |
1709 | case WACOM_HID_WD_BATTERY_CHARGING: | |
1710 | features->quirks |= WACOM_QUIRK_BATTERY; | |
1711 | break; | |
5922e613 JG |
1712 | case WACOM_HID_WD_ACCELEROMETER_X: |
1713 | __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit); | |
1714 | wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 0); | |
f3f24e7b | 1715 | features->device_type |= WACOM_DEVICETYPE_PAD; |
5922e613 JG |
1716 | break; |
1717 | case WACOM_HID_WD_ACCELEROMETER_Y: | |
1718 | __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit); | |
1719 | wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 0); | |
f3f24e7b | 1720 | features->device_type |= WACOM_DEVICETYPE_PAD; |
5922e613 JG |
1721 | break; |
1722 | case WACOM_HID_WD_ACCELEROMETER_Z: | |
1723 | __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit); | |
1724 | wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0); | |
f3f24e7b | 1725 | features->device_type |= WACOM_DEVICETYPE_PAD; |
5922e613 | 1726 | break; |
10c55cac AAS |
1727 | case WACOM_HID_WD_BUTTONCENTER: |
1728 | wacom->generic_has_leds = true; | |
1729 | /* fall through */ | |
5922e613 JG |
1730 | case WACOM_HID_WD_BUTTONHOME: |
1731 | case WACOM_HID_WD_BUTTONUP: | |
1732 | case WACOM_HID_WD_BUTTONDOWN: | |
1733 | case WACOM_HID_WD_BUTTONLEFT: | |
1734 | case WACOM_HID_WD_BUTTONRIGHT: | |
1735 | wacom_map_usage(input, usage, field, EV_KEY, | |
1736 | wacom_numbered_button_to_key(features->numbered_buttons), | |
1737 | 0); | |
1738 | features->numbered_buttons++; | |
f3f24e7b | 1739 | features->device_type |= WACOM_DEVICETYPE_PAD; |
5922e613 | 1740 | break; |
bf78adcb | 1741 | case WACOM_HID_WD_TOUCHONOFF: |
d2ec58ae AAS |
1742 | /* |
1743 | * This usage, which is used to mute touch events, comes | |
1744 | * from the pad packet, but is reported on the touch | |
1745 | * interface. Because the touch interface may not have | |
1746 | * been created yet, we cannot call wacom_map_usage(). In | |
1747 | * order to process this usage when we receive it, we set | |
1748 | * the usage type and code directly. | |
1749 | */ | |
1750 | wacom_wac->has_mute_touch_switch = true; | |
1751 | usage->type = EV_SW; | |
1752 | usage->code = SW_MUTE_DEVICE; | |
f3f24e7b | 1753 | features->device_type |= WACOM_DEVICETYPE_PAD; |
bf78adcb JG |
1754 | break; |
1755 | case WACOM_HID_WD_TOUCHSTRIP: | |
1756 | wacom_map_usage(input, usage, field, EV_ABS, ABS_RX, 0); | |
f3f24e7b | 1757 | features->device_type |= WACOM_DEVICETYPE_PAD; |
bf78adcb JG |
1758 | break; |
1759 | case WACOM_HID_WD_TOUCHSTRIP2: | |
1760 | wacom_map_usage(input, usage, field, EV_ABS, ABS_RY, 0); | |
f3f24e7b | 1761 | features->device_type |= WACOM_DEVICETYPE_PAD; |
bf78adcb | 1762 | break; |
5922e613 JG |
1763 | case WACOM_HID_WD_TOUCHRING: |
1764 | wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0); | |
f3f24e7b | 1765 | features->device_type |= WACOM_DEVICETYPE_PAD; |
5922e613 | 1766 | break; |
60a22186 AAS |
1767 | case WACOM_HID_WD_TOUCHRINGSTATUS: |
1768 | wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0); | |
1769 | features->device_type |= WACOM_DEVICETYPE_PAD; | |
1770 | break; | |
4eb220cb PC |
1771 | case WACOM_HID_WD_BUTTONCONFIG: |
1772 | wacom_map_usage(input, usage, field, EV_KEY, KEY_BUTTONCONFIG, 0); | |
1773 | features->device_type |= WACOM_DEVICETYPE_PAD; | |
1774 | break; | |
1775 | case WACOM_HID_WD_ONSCREEN_KEYBOARD: | |
1776 | wacom_map_usage(input, usage, field, EV_KEY, KEY_ONSCREEN_KEYBOARD, 0); | |
1777 | features->device_type |= WACOM_DEVICETYPE_PAD; | |
1778 | break; | |
1779 | case WACOM_HID_WD_CONTROLPANEL: | |
1780 | wacom_map_usage(input, usage, field, EV_KEY, KEY_CONTROLPANEL, 0); | |
1781 | features->device_type |= WACOM_DEVICETYPE_PAD; | |
1782 | break; | |
5922e613 JG |
1783 | } |
1784 | ||
1785 | switch (equivalent_usage & 0xfffffff0) { | |
1786 | case WACOM_HID_WD_EXPRESSKEY00: | |
1787 | wacom_map_usage(input, usage, field, EV_KEY, | |
1788 | wacom_numbered_button_to_key(features->numbered_buttons), | |
1789 | 0); | |
1790 | features->numbered_buttons++; | |
f3f24e7b | 1791 | features->device_type |= WACOM_DEVICETYPE_PAD; |
5922e613 JG |
1792 | break; |
1793 | } | |
1794 | } | |
1795 | ||
c9cfb2ac | 1796 | static void wacom_wac_pad_battery_event(struct hid_device *hdev, struct hid_field *field, |
5922e613 JG |
1797 | struct hid_usage *usage, __s32 value) |
1798 | { | |
1799 | struct wacom *wacom = hid_get_drvdata(hdev); | |
1800 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; | |
5922e613 JG |
1801 | unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); |
1802 | ||
93aab7fa JG |
1803 | switch (equivalent_usage) { |
1804 | case WACOM_HID_WD_BATTERY_LEVEL: | |
1805 | wacom_wac->hid_data.battery_capacity = value; | |
1806 | wacom_wac->hid_data.bat_connected = 1; | |
354a3298 | 1807 | break; |
93aab7fa JG |
1808 | |
1809 | case WACOM_HID_WD_BATTERY_CHARGING: | |
1810 | wacom_wac->hid_data.bat_charging = value; | |
1811 | wacom_wac->hid_data.ps_connected = value; | |
1812 | wacom_wac->hid_data.bat_connected = 1; | |
354a3298 | 1813 | break; |
c9cfb2ac PC |
1814 | } |
1815 | } | |
93aab7fa | 1816 | |
c9cfb2ac PC |
1817 | static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field, |
1818 | struct hid_usage *usage, __s32 value) | |
1819 | { | |
1820 | struct wacom *wacom = hid_get_drvdata(hdev); | |
1821 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; | |
1822 | struct input_dev *input = wacom_wac->pad_input; | |
1823 | struct wacom_features *features = &wacom_wac->features; | |
1824 | unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); | |
10c55cac | 1825 | int i; |
c9cfb2ac | 1826 | |
60a22186 AAS |
1827 | /* |
1828 | * Avoid reporting this event and setting inrange_state if this usage | |
1829 | * hasn't been mapped. | |
1830 | */ | |
1831 | if (!usage->type) | |
1832 | return; | |
c9cfb2ac PC |
1833 | |
1834 | if (wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY) { | |
60a22186 AAS |
1835 | if (usage->hid != WACOM_HID_WD_TOUCHRING) |
1836 | wacom_wac->hid_data.inrange_state |= value; | |
c9cfb2ac PC |
1837 | } |
1838 | ||
1839 | switch (equivalent_usage) { | |
93aab7fa | 1840 | case WACOM_HID_WD_TOUCHRINGSTATUS: |
60a22186 AAS |
1841 | if (!value) |
1842 | input_event(input, usage->type, usage->code, 0); | |
354a3298 | 1843 | break; |
93aab7fa | 1844 | |
d2ec58ae AAS |
1845 | case WACOM_HID_WD_TOUCHONOFF: |
1846 | if (wacom_wac->shared->touch_input) { | |
1847 | input_report_switch(wacom_wac->shared->touch_input, | |
1848 | SW_MUTE_DEVICE, !value); | |
1849 | input_sync(wacom_wac->shared->touch_input); | |
1850 | } | |
354a3298 | 1851 | break; |
93aab7fa | 1852 | |
10c55cac AAS |
1853 | case WACOM_HID_WD_BUTTONCENTER: |
1854 | for (i = 0; i < wacom->led.count; i++) | |
1855 | wacom_update_led(wacom, features->numbered_buttons, | |
1856 | value, i); | |
1857 | /* fall through*/ | |
93aab7fa | 1858 | default: |
5922e613 | 1859 | input_event(input, usage->type, usage->code, value); |
93aab7fa JG |
1860 | break; |
1861 | } | |
5922e613 JG |
1862 | } |
1863 | ||
1864 | static void wacom_wac_pad_pre_report(struct hid_device *hdev, | |
1865 | struct hid_report *report) | |
1866 | { | |
1867 | struct wacom *wacom = hid_get_drvdata(hdev); | |
1868 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; | |
1869 | ||
1870 | wacom_wac->hid_data.inrange_state = 0; | |
1871 | } | |
1872 | ||
c9cfb2ac | 1873 | static void wacom_wac_pad_battery_report(struct hid_device *hdev, |
5922e613 JG |
1874 | struct hid_report *report) |
1875 | { | |
1876 | struct wacom *wacom = hid_get_drvdata(hdev); | |
1877 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; | |
93aab7fa | 1878 | struct wacom_features *features = &wacom_wac->features; |
5922e613 | 1879 | |
93aab7fa JG |
1880 | if (features->quirks & WACOM_QUIRK_BATTERY) { |
1881 | int capacity = wacom_wac->hid_data.battery_capacity; | |
1882 | bool charging = wacom_wac->hid_data.bat_charging; | |
1883 | bool connected = wacom_wac->hid_data.bat_connected; | |
1884 | bool powered = wacom_wac->hid_data.ps_connected; | |
1885 | ||
1886 | wacom_notify_battery(wacom_wac, capacity, charging, | |
1887 | connected, powered); | |
1888 | } | |
c9cfb2ac | 1889 | } |
93aab7fa | 1890 | |
c9cfb2ac PC |
1891 | static void wacom_wac_pad_report(struct hid_device *hdev, |
1892 | struct hid_report *report) | |
1893 | { | |
1894 | struct wacom *wacom = hid_get_drvdata(hdev); | |
1895 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; | |
c9cfb2ac PC |
1896 | struct input_dev *input = wacom_wac->pad_input; |
1897 | bool active = wacom_wac->hid_data.inrange_state != 0; | |
1898 | ||
1899 | /* report prox for expresskey events */ | |
1900 | if (wacom_equivalent_usage(report->field[0]->physical) == HID_DG_TABLETFUNCTIONKEY) { | |
c9cfb2ac | 1901 | input_event(input, EV_ABS, ABS_MISC, active ? PAD_DEVICE_ID : 0); |
c9cfb2ac PC |
1902 | input_sync(input); |
1903 | } | |
65ef4c1e | 1904 | |
5922e613 JG |
1905 | } |
1906 | ||
7704ac93 BT |
1907 | static void wacom_wac_pen_usage_mapping(struct hid_device *hdev, |
1908 | struct hid_field *field, struct hid_usage *usage) | |
1909 | { | |
1910 | struct wacom *wacom = hid_get_drvdata(hdev); | |
2a6cdbdd | 1911 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
61ce346a | 1912 | struct wacom_features *features = &wacom_wac->features; |
2a6cdbdd | 1913 | struct input_dev *input = wacom_wac->pen_input; |
c9c09587 | 1914 | unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); |
7704ac93 | 1915 | |
c9c09587 | 1916 | switch (equivalent_usage) { |
7704ac93 | 1917 | case HID_GD_X: |
2a6cdbdd | 1918 | wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4); |
7704ac93 BT |
1919 | break; |
1920 | case HID_GD_Y: | |
2a6cdbdd | 1921 | wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4); |
7704ac93 | 1922 | break; |
b5c921e6 | 1923 | case WACOM_HID_WD_DISTANCE: |
50066a04 JG |
1924 | case HID_GD_Z: |
1925 | wacom_map_usage(input, usage, field, EV_ABS, ABS_DISTANCE, 0); | |
1926 | break; | |
7704ac93 | 1927 | case HID_DG_TIPPRESSURE: |
2a6cdbdd | 1928 | wacom_map_usage(input, usage, field, EV_ABS, ABS_PRESSURE, 0); |
7704ac93 BT |
1929 | break; |
1930 | case HID_DG_INRANGE: | |
2a6cdbdd | 1931 | wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0); |
7704ac93 | 1932 | break; |
93aab7fa JG |
1933 | case HID_DG_BATTERYSTRENGTH: |
1934 | features->quirks |= WACOM_QUIRK_BATTERY; | |
1935 | break; | |
7704ac93 | 1936 | case HID_DG_INVERT: |
2a6cdbdd | 1937 | wacom_map_usage(input, usage, field, EV_KEY, |
7704ac93 BT |
1938 | BTN_TOOL_RUBBER, 0); |
1939 | break; | |
50066a04 JG |
1940 | case HID_DG_TILT_X: |
1941 | wacom_map_usage(input, usage, field, EV_ABS, ABS_TILT_X, 0); | |
1942 | break; | |
1943 | case HID_DG_TILT_Y: | |
1944 | wacom_map_usage(input, usage, field, EV_ABS, ABS_TILT_Y, 0); | |
1945 | break; | |
1946 | case HID_DG_TWIST: | |
1947 | wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0); | |
1948 | break; | |
7704ac93 BT |
1949 | case HID_DG_ERASER: |
1950 | case HID_DG_TIPSWITCH: | |
2a6cdbdd | 1951 | wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0); |
7704ac93 BT |
1952 | break; |
1953 | case HID_DG_BARRELSWITCH: | |
2a6cdbdd | 1954 | wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS, 0); |
7704ac93 BT |
1955 | break; |
1956 | case HID_DG_BARRELSWITCH2: | |
2a6cdbdd | 1957 | wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS2, 0); |
7704ac93 BT |
1958 | break; |
1959 | case HID_DG_TOOLSERIALNUMBER: | |
2a6cdbdd | 1960 | wacom_map_usage(input, usage, field, EV_MSC, MSC_SERIAL, 0); |
7704ac93 | 1961 | break; |
61ce346a JG |
1962 | case WACOM_HID_WD_SENSE: |
1963 | features->quirks |= WACOM_QUIRK_SENSE; | |
1964 | wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0); | |
1965 | break; | |
f85c9dc6 JG |
1966 | case WACOM_HID_WD_SERIALHI: |
1967 | wacom_map_usage(input, usage, field, EV_ABS, ABS_MISC, 0); | |
1968 | set_bit(EV_KEY, input->evbit); | |
1969 | input_set_capability(input, EV_KEY, BTN_TOOL_PEN); | |
1970 | input_set_capability(input, EV_KEY, BTN_TOOL_RUBBER); | |
1971 | input_set_capability(input, EV_KEY, BTN_TOOL_BRUSH); | |
1972 | input_set_capability(input, EV_KEY, BTN_TOOL_PENCIL); | |
1973 | input_set_capability(input, EV_KEY, BTN_TOOL_AIRBRUSH); | |
1974 | input_set_capability(input, EV_KEY, BTN_TOOL_MOUSE); | |
1975 | input_set_capability(input, EV_KEY, BTN_TOOL_LENS); | |
1976 | break; | |
929d6d5d JG |
1977 | case WACOM_HID_WD_FINGERWHEEL: |
1978 | wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0); | |
1979 | break; | |
7704ac93 BT |
1980 | } |
1981 | } | |
1982 | ||
354a3298 | 1983 | static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field, |
7704ac93 BT |
1984 | struct hid_usage *usage, __s32 value) |
1985 | { | |
1986 | struct wacom *wacom = hid_get_drvdata(hdev); | |
1987 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; | |
61ce346a | 1988 | struct wacom_features *features = &wacom_wac->features; |
2a6cdbdd | 1989 | struct input_dev *input = wacom_wac->pen_input; |
c9c09587 | 1990 | unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); |
7704ac93 | 1991 | |
c9c09587 | 1992 | switch (equivalent_usage) { |
50066a04 JG |
1993 | case HID_GD_Z: |
1994 | /* | |
1995 | * HID_GD_Z "should increase as the control's position is | |
1996 | * moved from high to low", while ABS_DISTANCE instead | |
1997 | * increases in value as the tool moves from low to high. | |
1998 | */ | |
1999 | value = field->logical_maximum - value; | |
2000 | break; | |
7704ac93 BT |
2001 | case HID_DG_INRANGE: |
2002 | wacom_wac->hid_data.inrange_state = value; | |
61ce346a JG |
2003 | if (!(features->quirks & WACOM_QUIRK_SENSE)) |
2004 | wacom_wac->hid_data.sense_state = value; | |
354a3298 | 2005 | return; |
93aab7fa JG |
2006 | case HID_DG_BATTERYSTRENGTH: |
2007 | wacom_wac->hid_data.battery_capacity = value; | |
2008 | wacom_wac->hid_data.bat_connected = 1; | |
2009 | break; | |
7704ac93 BT |
2010 | case HID_DG_INVERT: |
2011 | wacom_wac->hid_data.invert_state = value; | |
354a3298 | 2012 | return; |
7704ac93 BT |
2013 | case HID_DG_ERASER: |
2014 | case HID_DG_TIPSWITCH: | |
2015 | wacom_wac->hid_data.tipswitch |= value; | |
354a3298 | 2016 | return; |
f85c9dc6 | 2017 | case HID_DG_TOOLSERIALNUMBER: |
a35f09b8 | 2018 | wacom_wac->serial[0] = (wacom_wac->serial[0] & ~0xFFFFFFFFULL); |
f85c9dc6 | 2019 | wacom_wac->serial[0] |= value; |
354a3298 | 2020 | return; |
61ce346a JG |
2021 | case WACOM_HID_WD_SENSE: |
2022 | wacom_wac->hid_data.sense_state = value; | |
354a3298 | 2023 | return; |
f85c9dc6 JG |
2024 | case WACOM_HID_WD_SERIALHI: |
2025 | wacom_wac->serial[0] = (wacom_wac->serial[0] & 0xFFFFFFFF); | |
2026 | wacom_wac->serial[0] |= ((__u64)value) << 32; | |
2027 | /* | |
2028 | * Non-USI EMR devices may contain additional tool type | |
2029 | * information here. See WACOM_HID_WD_TOOLTYPE case for | |
2030 | * more details. | |
2031 | */ | |
2032 | if (value >> 20 == 1) { | |
2033 | wacom_wac->id[0] |= value & 0xFFFFF; | |
2034 | } | |
354a3298 | 2035 | return; |
f85c9dc6 JG |
2036 | case WACOM_HID_WD_TOOLTYPE: |
2037 | /* | |
2038 | * Some devices (MobileStudio Pro, and possibly later | |
2039 | * devices as well) do not return the complete tool | |
2040 | * type in their WACOM_HID_WD_TOOLTYPE usage. Use a | |
2041 | * bitwise OR so the complete value can be built | |
2042 | * up over time :( | |
2043 | */ | |
2044 | wacom_wac->id[0] |= value; | |
354a3298 | 2045 | return; |
345857bb JG |
2046 | case WACOM_HID_WD_OFFSETLEFT: |
2047 | if (features->offset_left && value != features->offset_left) | |
2048 | hid_warn(hdev, "%s: overriding exising left offset " | |
2049 | "%d -> %d\n", __func__, value, | |
2050 | features->offset_left); | |
2051 | features->offset_left = value; | |
354a3298 | 2052 | return; |
345857bb JG |
2053 | case WACOM_HID_WD_OFFSETRIGHT: |
2054 | if (features->offset_right && value != features->offset_right) | |
2055 | hid_warn(hdev, "%s: overriding exising right offset " | |
2056 | "%d -> %d\n", __func__, value, | |
2057 | features->offset_right); | |
2058 | features->offset_right = value; | |
354a3298 | 2059 | return; |
345857bb JG |
2060 | case WACOM_HID_WD_OFFSETTOP: |
2061 | if (features->offset_top && value != features->offset_top) | |
2062 | hid_warn(hdev, "%s: overriding exising top offset " | |
2063 | "%d -> %d\n", __func__, value, | |
2064 | features->offset_top); | |
2065 | features->offset_top = value; | |
354a3298 | 2066 | return; |
345857bb JG |
2067 | case WACOM_HID_WD_OFFSETBOTTOM: |
2068 | if (features->offset_bottom && value != features->offset_bottom) | |
2069 | hid_warn(hdev, "%s: overriding exising bottom offset " | |
2070 | "%d -> %d\n", __func__, value, | |
2071 | features->offset_bottom); | |
2072 | features->offset_bottom = value; | |
354a3298 | 2073 | return; |
7704ac93 BT |
2074 | } |
2075 | ||
1924e05e PC |
2076 | /* send pen events only when touch is up or forced out |
2077 | * or touch arbitration is off | |
2078 | */ | |
2079 | if (!usage->type || delay_pen_events(wacom_wac)) | |
354a3298 | 2080 | return; |
7704ac93 | 2081 | |
61ce346a JG |
2082 | /* send pen events only when the pen is in/entering/leaving proximity */ |
2083 | if (!wacom_wac->hid_data.inrange_state && !wacom_wac->tool[0]) | |
354a3298 | 2084 | return; |
61ce346a | 2085 | |
7704ac93 | 2086 | input_event(input, usage->type, usage->code, value); |
7704ac93 BT |
2087 | } |
2088 | ||
06324e0c JG |
2089 | static void wacom_wac_pen_pre_report(struct hid_device *hdev, |
2090 | struct hid_report *report) | |
2091 | { | |
2092 | return; | |
2093 | } | |
2094 | ||
7704ac93 BT |
2095 | static void wacom_wac_pen_report(struct hid_device *hdev, |
2096 | struct hid_report *report) | |
2097 | { | |
2098 | struct wacom *wacom = hid_get_drvdata(hdev); | |
2099 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; | |
2a6cdbdd | 2100 | struct input_dev *input = wacom_wac->pen_input; |
7704ac93 | 2101 | bool prox = wacom_wac->hid_data.inrange_state; |
61ce346a | 2102 | bool range = wacom_wac->hid_data.sense_state; |
7704ac93 | 2103 | |
f85c9dc6 | 2104 | if (!wacom_wac->tool[0] && prox) { /* first in prox */ |
7704ac93 | 2105 | /* Going into proximity select tool */ |
f85c9dc6 JG |
2106 | if (wacom_wac->hid_data.invert_state) |
2107 | wacom_wac->tool[0] = BTN_TOOL_RUBBER; | |
2108 | else if (wacom_wac->id[0]) | |
2109 | wacom_wac->tool[0] = wacom_intuos_get_tool_type(wacom_wac->id[0]); | |
2110 | else | |
2111 | wacom_wac->tool[0] = BTN_TOOL_PEN; | |
2112 | } | |
7704ac93 BT |
2113 | |
2114 | /* keep pen state for touch events */ | |
61ce346a | 2115 | wacom_wac->shared->stylus_in_proximity = range; |
7704ac93 | 2116 | |
61ce346a | 2117 | if (!delay_pen_events(wacom_wac) && wacom_wac->tool[0]) { |
f85c9dc6 JG |
2118 | int id = wacom_wac->id[0]; |
2119 | ||
2120 | /* | |
2121 | * Non-USI EMR tools should have their IDs mangled to | |
2122 | * match the legacy behavior of wacom_intuos_general | |
2123 | */ | |
2124 | if (wacom_wac->serial[0] >> 52 == 1) | |
2125 | id = wacom_intuos_id_mangle(id); | |
2126 | ||
2127 | /* | |
2128 | * To ensure compatibility with xf86-input-wacom, we should | |
2129 | * report the BTN_TOOL_* event prior to the ABS_MISC or | |
2130 | * MSC_SERIAL events. | |
2131 | */ | |
7704ac93 BT |
2132 | input_report_key(input, BTN_TOUCH, |
2133 | wacom_wac->hid_data.tipswitch); | |
2134 | input_report_key(input, wacom_wac->tool[0], prox); | |
f85c9dc6 JG |
2135 | if (wacom_wac->serial[0]) { |
2136 | input_event(input, EV_MSC, MSC_SERIAL, wacom_wac->serial[0]); | |
2137 | input_report_abs(input, ABS_MISC, id); | |
2138 | } | |
7704ac93 BT |
2139 | |
2140 | wacom_wac->hid_data.tipswitch = false; | |
2141 | ||
2142 | input_sync(input); | |
2143 | } | |
61ce346a | 2144 | |
f85c9dc6 | 2145 | if (!prox) { |
61ce346a | 2146 | wacom_wac->tool[0] = 0; |
f85c9dc6 JG |
2147 | wacom_wac->id[0] = 0; |
2148 | } | |
7704ac93 BT |
2149 | } |
2150 | ||
5ae6e89f BT |
2151 | static void wacom_wac_finger_usage_mapping(struct hid_device *hdev, |
2152 | struct hid_field *field, struct hid_usage *usage) | |
2153 | { | |
2154 | struct wacom *wacom = hid_get_drvdata(hdev); | |
2155 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; | |
2a6cdbdd | 2156 | struct input_dev *input = wacom_wac->touch_input; |
5ae6e89f | 2157 | unsigned touch_max = wacom_wac->features.touch_max; |
c9c09587 | 2158 | unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); |
5ae6e89f | 2159 | |
c9c09587 | 2160 | switch (equivalent_usage) { |
5ae6e89f BT |
2161 | case HID_GD_X: |
2162 | if (touch_max == 1) | |
2a6cdbdd | 2163 | wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4); |
5ae6e89f | 2164 | else |
2a6cdbdd | 2165 | wacom_map_usage(input, usage, field, EV_ABS, |
5ae6e89f BT |
2166 | ABS_MT_POSITION_X, 4); |
2167 | break; | |
2168 | case HID_GD_Y: | |
2169 | if (touch_max == 1) | |
2a6cdbdd | 2170 | wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4); |
5ae6e89f | 2171 | else |
2a6cdbdd | 2172 | wacom_map_usage(input, usage, field, EV_ABS, |
5ae6e89f BT |
2173 | ABS_MT_POSITION_Y, 4); |
2174 | break; | |
488abb5c JG |
2175 | case HID_DG_WIDTH: |
2176 | case HID_DG_HEIGHT: | |
488abb5c JG |
2177 | wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MAJOR, 0); |
2178 | wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MINOR, 0); | |
2179 | input_set_abs_params(input, ABS_MT_ORIENTATION, 0, 1, 0, 0); | |
2180 | break; | |
5ae6e89f | 2181 | case HID_DG_TIPSWITCH: |
2a6cdbdd | 2182 | wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0); |
5ae6e89f | 2183 | break; |
1b5d514a | 2184 | case HID_DG_CONTACTCOUNT: |
499522c8 | 2185 | wacom_wac->hid_data.cc_report = field->report->id; |
1b5d514a JG |
2186 | wacom_wac->hid_data.cc_index = field->index; |
2187 | wacom_wac->hid_data.cc_value_index = usage->usage_index; | |
2188 | break; | |
5ae6e89f BT |
2189 | } |
2190 | } | |
2191 | ||
601a22f3 JG |
2192 | static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac, |
2193 | struct input_dev *input) | |
2194 | { | |
2195 | struct hid_data *hid_data = &wacom_wac->hid_data; | |
2196 | bool mt = wacom_wac->features.touch_max > 1; | |
2197 | bool prox = hid_data->tipswitch && | |
1924e05e | 2198 | report_touch_events(wacom_wac); |
601a22f3 | 2199 | |
1b5d514a JG |
2200 | wacom_wac->hid_data.num_received++; |
2201 | if (wacom_wac->hid_data.num_received > wacom_wac->hid_data.num_expected) | |
2202 | return; | |
2203 | ||
601a22f3 JG |
2204 | if (mt) { |
2205 | int slot; | |
2206 | ||
2207 | slot = input_mt_get_slot_by_key(input, hid_data->id); | |
2208 | input_mt_slot(input, slot); | |
2209 | input_mt_report_slot_state(input, MT_TOOL_FINGER, prox); | |
2210 | } | |
2211 | else { | |
2212 | input_report_key(input, BTN_TOUCH, prox); | |
2213 | } | |
2214 | ||
2215 | if (prox) { | |
2216 | input_report_abs(input, mt ? ABS_MT_POSITION_X : ABS_X, | |
2217 | hid_data->x); | |
2218 | input_report_abs(input, mt ? ABS_MT_POSITION_Y : ABS_Y, | |
2219 | hid_data->y); | |
488abb5c JG |
2220 | |
2221 | if (test_bit(ABS_MT_TOUCH_MAJOR, input->absbit)) { | |
2222 | input_report_abs(input, ABS_MT_TOUCH_MAJOR, max(hid_data->width, hid_data->height)); | |
2223 | input_report_abs(input, ABS_MT_TOUCH_MINOR, min(hid_data->width, hid_data->height)); | |
2224 | if (hid_data->width != hid_data->height) | |
2225 | input_report_abs(input, ABS_MT_ORIENTATION, hid_data->width <= hid_data->height ? 0 : 1); | |
2226 | } | |
601a22f3 JG |
2227 | } |
2228 | } | |
2229 | ||
354a3298 | 2230 | static void wacom_wac_finger_event(struct hid_device *hdev, |
5ae6e89f BT |
2231 | struct hid_field *field, struct hid_usage *usage, __s32 value) |
2232 | { | |
2233 | struct wacom *wacom = hid_get_drvdata(hdev); | |
2234 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; | |
c9c09587 | 2235 | unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); |
5ae6e89f | 2236 | |
c9c09587 | 2237 | switch (equivalent_usage) { |
5ae6e89f BT |
2238 | case HID_GD_X: |
2239 | wacom_wac->hid_data.x = value; | |
2240 | break; | |
2241 | case HID_GD_Y: | |
2242 | wacom_wac->hid_data.y = value; | |
2243 | break; | |
488abb5c JG |
2244 | case HID_DG_WIDTH: |
2245 | wacom_wac->hid_data.width = value; | |
2246 | break; | |
2247 | case HID_DG_HEIGHT: | |
2248 | wacom_wac->hid_data.height = value; | |
2249 | break; | |
5ae6e89f BT |
2250 | case HID_DG_CONTACTID: |
2251 | wacom_wac->hid_data.id = value; | |
2252 | break; | |
2253 | case HID_DG_TIPSWITCH: | |
2254 | wacom_wac->hid_data.tipswitch = value; | |
2255 | break; | |
2256 | } | |
2257 | ||
2258 | ||
601a22f3 | 2259 | if (usage->usage_index + 1 == field->report_count) { |
c9c09587 | 2260 | if (equivalent_usage == wacom_wac->hid_data.last_slot_field) |
2a6cdbdd | 2261 | wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input); |
601a22f3 | 2262 | } |
5ae6e89f BT |
2263 | } |
2264 | ||
06324e0c JG |
2265 | static void wacom_wac_finger_pre_report(struct hid_device *hdev, |
2266 | struct hid_report *report) | |
2267 | { | |
1b5d514a JG |
2268 | struct wacom *wacom = hid_get_drvdata(hdev); |
2269 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; | |
2270 | struct hid_data* hid_data = &wacom_wac->hid_data; | |
003f50ab | 2271 | int i; |
1b5d514a | 2272 | |
003f50ab JG |
2273 | for (i = 0; i < report->maxfield; i++) { |
2274 | struct hid_field *field = report->field[i]; | |
2275 | int j; | |
2276 | ||
2277 | for (j = 0; j < field->maxusage; j++) { | |
2278 | struct hid_usage *usage = &field->usage[j]; | |
ac2423c9 AAS |
2279 | unsigned int equivalent_usage = |
2280 | wacom_equivalent_usage(usage->hid); | |
003f50ab | 2281 | |
ac2423c9 | 2282 | switch (equivalent_usage) { |
003f50ab JG |
2283 | case HID_GD_X: |
2284 | case HID_GD_Y: | |
2285 | case HID_DG_WIDTH: | |
2286 | case HID_DG_HEIGHT: | |
2287 | case HID_DG_CONTACTID: | |
2288 | case HID_DG_INRANGE: | |
2289 | case HID_DG_INVERT: | |
2290 | case HID_DG_TIPSWITCH: | |
ac2423c9 | 2291 | hid_data->last_slot_field = equivalent_usage; |
003f50ab JG |
2292 | break; |
2293 | case HID_DG_CONTACTCOUNT: | |
2294 | hid_data->cc_report = report->id; | |
2295 | hid_data->cc_index = i; | |
2296 | hid_data->cc_value_index = j; | |
2297 | break; | |
499522c8 JG |
2298 | } |
2299 | } | |
2300 | } | |
003f50ab | 2301 | |
df707938 JG |
2302 | if (hid_data->cc_report != 0 && |
2303 | hid_data->cc_index >= 0) { | |
1b5d514a JG |
2304 | struct hid_field *field = report->field[hid_data->cc_index]; |
2305 | int value = field->value[hid_data->cc_value_index]; | |
2306 | if (value) | |
2307 | hid_data->num_expected = value; | |
2308 | } | |
2309 | else { | |
2310 | hid_data->num_expected = wacom_wac->features.touch_max; | |
2311 | } | |
06324e0c JG |
2312 | } |
2313 | ||
5ae6e89f BT |
2314 | static void wacom_wac_finger_report(struct hid_device *hdev, |
2315 | struct hid_report *report) | |
2316 | { | |
2317 | struct wacom *wacom = hid_get_drvdata(hdev); | |
2318 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; | |
2a6cdbdd | 2319 | struct input_dev *input = wacom_wac->touch_input; |
5ae6e89f BT |
2320 | unsigned touch_max = wacom_wac->features.touch_max; |
2321 | ||
1b5d514a JG |
2322 | /* If more packets of data are expected, give us a chance to |
2323 | * process them rather than immediately syncing a partial | |
2324 | * update. | |
2325 | */ | |
2326 | if (wacom_wac->hid_data.num_received < wacom_wac->hid_data.num_expected) | |
2327 | return; | |
2328 | ||
5ae6e89f | 2329 | if (touch_max > 1) |
601a22f3 JG |
2330 | input_mt_sync_frame(input); |
2331 | ||
5ae6e89f | 2332 | input_sync(input); |
1b5d514a | 2333 | wacom_wac->hid_data.num_received = 0; |
5ae6e89f BT |
2334 | |
2335 | /* keep touch state for pen event */ | |
7d059ed0 | 2336 | wacom_wac->shared->touch_down = wacom_wac_finger_count_touches(wacom_wac); |
5ae6e89f BT |
2337 | } |
2338 | ||
7704ac93 BT |
2339 | void wacom_wac_usage_mapping(struct hid_device *hdev, |
2340 | struct hid_field *field, struct hid_usage *usage) | |
2341 | { | |
2342 | struct wacom *wacom = hid_get_drvdata(hdev); | |
2343 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; | |
e5bc8eb1 | 2344 | struct wacom_features *features = &wacom_wac->features; |
7704ac93 | 2345 | |
ac2423c9 AAS |
2346 | if (WACOM_DIRECT_DEVICE(field)) |
2347 | features->device_type |= WACOM_DEVICETYPE_DIRECT; | |
7704ac93 | 2348 | |
5922e613 | 2349 | if (WACOM_PAD_FIELD(field)) |
354a3298 | 2350 | wacom_wac_pad_usage_mapping(hdev, field, usage); |
5922e613 | 2351 | else if (WACOM_PEN_FIELD(field)) |
354a3298 | 2352 | wacom_wac_pen_usage_mapping(hdev, field, usage); |
5922e613 | 2353 | else if (WACOM_FINGER_FIELD(field)) |
354a3298 | 2354 | wacom_wac_finger_usage_mapping(hdev, field, usage); |
7704ac93 BT |
2355 | } |
2356 | ||
354a3298 | 2357 | void wacom_wac_event(struct hid_device *hdev, struct hid_field *field, |
7704ac93 BT |
2358 | struct hid_usage *usage, __s32 value) |
2359 | { | |
2360 | struct wacom *wacom = hid_get_drvdata(hdev); | |
2361 | ||
2362 | if (wacom->wacom_wac.features.type != HID_GENERIC) | |
354a3298 | 2363 | return; |
7704ac93 | 2364 | |
60a22186 AAS |
2365 | if (value > field->logical_maximum || value < field->logical_minimum) |
2366 | return; | |
2367 | ||
c9cfb2ac PC |
2368 | if (WACOM_PAD_FIELD(field)) { |
2369 | wacom_wac_pad_battery_event(hdev, field, usage, value); | |
2370 | if (wacom->wacom_wac.pad_input) | |
2371 | wacom_wac_pad_event(hdev, field, usage, value); | |
2372 | } else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input) | |
354a3298 | 2373 | wacom_wac_pen_event(hdev, field, usage, value); |
6f46cf9b | 2374 | else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input) |
354a3298 | 2375 | wacom_wac_finger_event(hdev, field, usage, value); |
7704ac93 BT |
2376 | } |
2377 | ||
06324e0c JG |
2378 | static void wacom_report_events(struct hid_device *hdev, struct hid_report *report) |
2379 | { | |
2380 | int r; | |
2381 | ||
2382 | for (r = 0; r < report->maxfield; r++) { | |
2383 | struct hid_field *field; | |
2384 | unsigned count, n; | |
2385 | ||
2386 | field = report->field[r]; | |
2387 | count = field->report_count; | |
2388 | ||
2389 | if (!(HID_MAIN_ITEM_VARIABLE & field->flags)) | |
2390 | continue; | |
2391 | ||
2392 | for (n = 0; n < count; n++) | |
2393 | wacom_wac_event(hdev, field, &field->usage[n], field->value[n]); | |
2394 | } | |
2395 | } | |
2396 | ||
7704ac93 BT |
2397 | void wacom_wac_report(struct hid_device *hdev, struct hid_report *report) |
2398 | { | |
2399 | struct wacom *wacom = hid_get_drvdata(hdev); | |
2400 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; | |
2401 | struct hid_field *field = report->field[0]; | |
2402 | ||
2403 | if (wacom_wac->features.type != HID_GENERIC) | |
2404 | return; | |
2405 | ||
6f46cf9b | 2406 | if (WACOM_PAD_FIELD(field) && wacom->wacom_wac.pad_input) |
5922e613 | 2407 | wacom_wac_pad_pre_report(hdev, report); |
6f46cf9b | 2408 | else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input) |
06324e0c | 2409 | wacom_wac_pen_pre_report(hdev, report); |
6f46cf9b | 2410 | else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input) |
06324e0c JG |
2411 | wacom_wac_finger_pre_report(hdev, report); |
2412 | ||
2413 | wacom_report_events(hdev, report); | |
2414 | ||
a9ce7856 JG |
2415 | /* |
2416 | * Non-input reports may be sent prior to the device being | |
2417 | * completely initialized. Since only their events need | |
2418 | * to be processed, exit after 'wacom_report_events' has | |
2419 | * been called to prevent potential crashes in the report- | |
2420 | * processing functions. | |
2421 | */ | |
2422 | if (report->type != HID_INPUT_REPORT) | |
2423 | return; | |
2424 | ||
c9cfb2ac PC |
2425 | if (WACOM_PAD_FIELD(field)) { |
2426 | wacom_wac_pad_battery_report(hdev, report); | |
2427 | if (wacom->wacom_wac.pad_input) | |
2428 | wacom_wac_pad_report(hdev, report); | |
2429 | } else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input) | |
2430 | wacom_wac_pen_report(hdev, report); | |
6f46cf9b | 2431 | else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input) |
c9cfb2ac | 2432 | wacom_wac_finger_report(hdev, report); |
7704ac93 BT |
2433 | } |
2434 | ||
e1d38e49 | 2435 | static int wacom_bpt_touch(struct wacom_wac *wacom) |
cb734c03 | 2436 | { |
f4ccbef2 | 2437 | struct wacom_features *features = &wacom->features; |
2a6cdbdd | 2438 | struct input_dev *input = wacom->touch_input; |
3116871f | 2439 | struct input_dev *pad_input = wacom->pad_input; |
cb734c03 | 2440 | unsigned char *data = wacom->data; |
cb734c03 HR |
2441 | int i; |
2442 | ||
5a6c865d CB |
2443 | if (data[0] != 0x02) |
2444 | return 0; | |
2445 | ||
cb734c03 | 2446 | for (i = 0; i < 2; i++) { |
8f906860 | 2447 | int offset = (data[1] & 0x80) ? (8 * i) : (9 * i); |
1924e05e PC |
2448 | bool touch = report_touch_events(wacom) |
2449 | && (data[offset + 3] & 0x80); | |
8f906860 CB |
2450 | |
2451 | input_mt_slot(input, i); | |
2452 | input_mt_report_slot_state(input, MT_TOOL_FINGER, touch); | |
c5f4dec1 | 2453 | if (touch) { |
8f906860 CB |
2454 | int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff; |
2455 | int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff; | |
f4ccbef2 HR |
2456 | if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) { |
2457 | x <<= 5; | |
2458 | y <<= 5; | |
2459 | } | |
cb734c03 HR |
2460 | input_report_abs(input, ABS_MT_POSITION_X, x); |
2461 | input_report_abs(input, ABS_MT_POSITION_Y, y); | |
cb734c03 | 2462 | } |
cb734c03 HR |
2463 | } |
2464 | ||
9a1c0012 | 2465 | input_mt_sync_frame(input); |
cb734c03 | 2466 | |
3116871f BT |
2467 | input_report_key(pad_input, BTN_LEFT, (data[1] & 0x08) != 0); |
2468 | input_report_key(pad_input, BTN_FORWARD, (data[1] & 0x04) != 0); | |
2469 | input_report_key(pad_input, BTN_BACK, (data[1] & 0x02) != 0); | |
2470 | input_report_key(pad_input, BTN_RIGHT, (data[1] & 0x01) != 0); | |
7d059ed0 | 2471 | wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); |
cb734c03 | 2472 | |
3116871f | 2473 | return 1; |
cb734c03 HR |
2474 | } |
2475 | ||
7d059ed0 | 2476 | static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data) |
73149ab8 | 2477 | { |
9a35c411 | 2478 | struct wacom_features *features = &wacom->features; |
2a6cdbdd | 2479 | struct input_dev *input = wacom->touch_input; |
73149ab8 | 2480 | bool touch = data[1] & 0x80; |
02295e68 PC |
2481 | int slot = input_mt_get_slot_by_key(input, data[0]); |
2482 | ||
2483 | if (slot < 0) | |
7d059ed0 | 2484 | return; |
73149ab8 | 2485 | |
1924e05e | 2486 | touch = touch && report_touch_events(wacom); |
73149ab8 | 2487 | |
02295e68 | 2488 | input_mt_slot(input, slot); |
73149ab8 CB |
2489 | input_mt_report_slot_state(input, MT_TOOL_FINGER, touch); |
2490 | ||
2491 | if (touch) { | |
2492 | int x = (data[2] << 4) | (data[4] >> 4); | |
2493 | int y = (data[3] << 4) | (data[4] & 0x0f); | |
9a35c411 | 2494 | int width, height; |
4e904954 | 2495 | |
eda01dab | 2496 | if (features->type >= INTUOSPS && features->type <= INTUOSHT2) { |
0b279da7 JG |
2497 | width = data[5] * 100; |
2498 | height = data[6] * 100; | |
9a35c411 PC |
2499 | } else { |
2500 | /* | |
2501 | * "a" is a scaled-down area which we assume is | |
2502 | * roughly circular and which can be described as: | |
2503 | * a=(pi*r^2)/C. | |
2504 | */ | |
2505 | int a = data[5]; | |
d7da3a3c PC |
2506 | int x_res = input_abs_get_res(input, ABS_MT_POSITION_X); |
2507 | int y_res = input_abs_get_res(input, ABS_MT_POSITION_Y); | |
2508 | width = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE); | |
9a35c411 PC |
2509 | height = width * y_res / x_res; |
2510 | } | |
73149ab8 CB |
2511 | |
2512 | input_report_abs(input, ABS_MT_POSITION_X, x); | |
2513 | input_report_abs(input, ABS_MT_POSITION_Y, y); | |
4e904954 JG |
2514 | input_report_abs(input, ABS_MT_TOUCH_MAJOR, width); |
2515 | input_report_abs(input, ABS_MT_TOUCH_MINOR, height); | |
73149ab8 CB |
2516 | } |
2517 | } | |
2518 | ||
2519 | static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data) | |
2520 | { | |
3116871f | 2521 | struct input_dev *input = wacom->pad_input; |
b5fd2a3e | 2522 | struct wacom_features *features = &wacom->features; |
73149ab8 | 2523 | |
eda01dab | 2524 | if (features->type == INTUOSHT || features->type == INTUOSHT2) { |
b5fd2a3e PC |
2525 | input_report_key(input, BTN_LEFT, (data[1] & 0x02) != 0); |
2526 | input_report_key(input, BTN_BACK, (data[1] & 0x08) != 0); | |
2527 | } else { | |
2528 | input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0); | |
2529 | input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0); | |
2530 | } | |
73149ab8 | 2531 | input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0); |
73149ab8 CB |
2532 | input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0); |
2533 | } | |
2534 | ||
2535 | static int wacom_bpt3_touch(struct wacom_wac *wacom) | |
2536 | { | |
73149ab8 | 2537 | unsigned char *data = wacom->data; |
19d57d3a | 2538 | int count = data[1] & 0x07; |
eda01dab | 2539 | int touch_changed = 0, i; |
73149ab8 | 2540 | |
5a6c865d CB |
2541 | if (data[0] != 0x02) |
2542 | return 0; | |
2543 | ||
73149ab8 CB |
2544 | /* data has up to 7 fixed sized 8-byte messages starting at data[2] */ |
2545 | for (i = 0; i < count; i++) { | |
2546 | int offset = (8 * i) + 2; | |
2547 | int msg_id = data[offset]; | |
2548 | ||
eda01dab | 2549 | if (msg_id >= 2 && msg_id <= 17) { |
7d059ed0 | 2550 | wacom_bpt3_touch_msg(wacom, data + offset); |
eda01dab PC |
2551 | touch_changed++; |
2552 | } else if (msg_id == 128) | |
73149ab8 CB |
2553 | wacom_bpt3_button_msg(wacom, data + offset); |
2554 | ||
2555 | } | |
2a6cdbdd | 2556 | |
eda01dab | 2557 | /* only update touch if we actually have a touchpad and touch data changed */ |
84dfbd7f | 2558 | if (wacom->touch_input && touch_changed) { |
2a6cdbdd JG |
2559 | input_mt_sync_frame(wacom->touch_input); |
2560 | wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); | |
2561 | } | |
73149ab8 | 2562 | |
3116871f | 2563 | return 1; |
73149ab8 CB |
2564 | } |
2565 | ||
2aaacb15 CB |
2566 | static int wacom_bpt_pen(struct wacom_wac *wacom) |
2567 | { | |
961794a0 | 2568 | struct wacom_features *features = &wacom->features; |
2a6cdbdd | 2569 | struct input_dev *input = wacom->pen_input; |
2aaacb15 CB |
2570 | unsigned char *data = wacom->data; |
2571 | int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0; | |
2572 | ||
4ca4ec71 | 2573 | if (data[0] != WACOM_REPORT_PENABLED) |
5a6c865d CB |
2574 | return 0; |
2575 | ||
c5981411 | 2576 | prox = (data[1] & 0x20) == 0x20; |
2aaacb15 CB |
2577 | |
2578 | /* | |
2579 | * All reports shared between PEN and RUBBER tool must be | |
2580 | * forced to a known starting value (zero) when transitioning to | |
2581 | * out-of-prox. | |
2582 | * | |
2583 | * If not reset then, to userspace, it will look like lost events | |
2584 | * if new tool comes in-prox with same values as previous tool sent. | |
2585 | * | |
2586 | * Hardware does report zero in most out-of-prox cases but not all. | |
2587 | */ | |
0149931e PC |
2588 | if (!wacom->shared->stylus_in_proximity) { |
2589 | if (data[1] & 0x08) { | |
2590 | wacom->tool[0] = BTN_TOOL_RUBBER; | |
2591 | wacom->id[0] = ERASER_DEVICE_ID; | |
2592 | } else { | |
2593 | wacom->tool[0] = BTN_TOOL_PEN; | |
2594 | wacom->id[0] = STYLUS_DEVICE_ID; | |
2aaacb15 | 2595 | } |
0149931e PC |
2596 | } |
2597 | ||
2598 | wacom->shared->stylus_in_proximity = prox; | |
1924e05e | 2599 | if (delay_pen_events(wacom)) |
0149931e PC |
2600 | return 0; |
2601 | ||
2602 | if (prox) { | |
2aaacb15 CB |
2603 | x = le16_to_cpup((__le16 *)&data[2]); |
2604 | y = le16_to_cpup((__le16 *)&data[4]); | |
2605 | p = le16_to_cpup((__le16 *)&data[6]); | |
c18c2cec CB |
2606 | /* |
2607 | * Convert distance from out prox to distance from tablet. | |
2608 | * distance will be greater than distance_max once | |
2609 | * touching and applying pressure; do not report negative | |
2610 | * distance. | |
2611 | */ | |
961794a0 PC |
2612 | if (data[8] <= features->distance_max) |
2613 | d = features->distance_max - data[8]; | |
c18c2cec | 2614 | |
2aaacb15 CB |
2615 | pen = data[1] & 0x01; |
2616 | btn1 = data[1] & 0x02; | |
2617 | btn2 = data[1] & 0x04; | |
0149931e PC |
2618 | } else { |
2619 | wacom->id[0] = 0; | |
2aaacb15 CB |
2620 | } |
2621 | ||
2622 | input_report_key(input, BTN_TOUCH, pen); | |
2623 | input_report_key(input, BTN_STYLUS, btn1); | |
2624 | input_report_key(input, BTN_STYLUS2, btn2); | |
2625 | ||
2626 | input_report_abs(input, ABS_X, x); | |
2627 | input_report_abs(input, ABS_Y, y); | |
2628 | input_report_abs(input, ABS_PRESSURE, p); | |
2629 | input_report_abs(input, ABS_DISTANCE, d); | |
2630 | ||
2aaacb15 CB |
2631 | input_report_key(input, wacom->tool[0], prox); /* PEN or RUBBER */ |
2632 | input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */ | |
2633 | ||
2634 | return 1; | |
2635 | } | |
2636 | ||
e1d38e49 CB |
2637 | static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len) |
2638 | { | |
eda01dab PC |
2639 | struct wacom_features *features = &wacom->features; |
2640 | ||
2641 | if ((features->type == INTUOSHT2) && | |
eda01dab PC |
2642 | (features->device_type & WACOM_DEVICETYPE_PEN)) |
2643 | return wacom_intuos_irq(wacom); | |
2644 | else if (len == WACOM_PKGLEN_BBTOUCH) | |
e1d38e49 | 2645 | return wacom_bpt_touch(wacom); |
73149ab8 CB |
2646 | else if (len == WACOM_PKGLEN_BBTOUCH3) |
2647 | return wacom_bpt3_touch(wacom); | |
2648 | else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN) | |
2aaacb15 | 2649 | return wacom_bpt_pen(wacom); |
e1d38e49 CB |
2650 | |
2651 | return 0; | |
2652 | } | |
2653 | ||
8c97a765 BT |
2654 | static void wacom_bamboo_pad_pen_event(struct wacom_wac *wacom, |
2655 | unsigned char *data) | |
2656 | { | |
2657 | unsigned char prefix; | |
2658 | ||
2659 | /* | |
2660 | * We need to reroute the event from the debug interface to the | |
2661 | * pen interface. | |
2662 | * We need to add the report ID to the actual pen report, so we | |
2663 | * temporary overwrite the first byte to prevent having to kzalloc/kfree | |
2664 | * and memcpy the report. | |
2665 | */ | |
2666 | prefix = data[0]; | |
2667 | data[0] = WACOM_REPORT_BPAD_PEN; | |
2668 | ||
2669 | /* | |
2670 | * actually reroute the event. | |
2671 | * No need to check if wacom->shared->pen is valid, hid_input_report() | |
2672 | * will check for us. | |
2673 | */ | |
2674 | hid_input_report(wacom->shared->pen, HID_INPUT_REPORT, data, | |
2675 | WACOM_PKGLEN_PENABLED, 1); | |
2676 | ||
2677 | data[0] = prefix; | |
2678 | } | |
2679 | ||
2680 | static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom, | |
2681 | unsigned char *data) | |
2682 | { | |
2a6cdbdd | 2683 | struct input_dev *input = wacom->touch_input; |
8c97a765 BT |
2684 | unsigned char *finger_data, prefix; |
2685 | unsigned id; | |
2686 | int x, y; | |
2687 | bool valid; | |
2688 | ||
2689 | prefix = data[0]; | |
2690 | ||
2691 | for (id = 0; id < wacom->features.touch_max; id++) { | |
2692 | valid = !!(prefix & BIT(id)) && | |
1924e05e | 2693 | report_touch_events(wacom); |
8c97a765 BT |
2694 | |
2695 | input_mt_slot(input, id); | |
2696 | input_mt_report_slot_state(input, MT_TOOL_FINGER, valid); | |
2697 | ||
2698 | if (!valid) | |
2699 | continue; | |
2700 | ||
2701 | finger_data = data + 1 + id * 3; | |
2702 | x = finger_data[0] | ((finger_data[1] & 0x0f) << 8); | |
2703 | y = (finger_data[2] << 4) | (finger_data[1] >> 4); | |
2704 | ||
2705 | input_report_abs(input, ABS_MT_POSITION_X, x); | |
2706 | input_report_abs(input, ABS_MT_POSITION_Y, y); | |
2707 | } | |
2708 | ||
2709 | input_mt_sync_frame(input); | |
2710 | ||
2711 | input_report_key(input, BTN_LEFT, prefix & 0x40); | |
2712 | input_report_key(input, BTN_RIGHT, prefix & 0x80); | |
2713 | ||
2714 | /* keep touch state for pen event */ | |
1924e05e | 2715 | wacom->shared->touch_down = !!prefix && report_touch_events(wacom); |
8c97a765 BT |
2716 | |
2717 | return 1; | |
2718 | } | |
2719 | ||
2720 | static int wacom_bamboo_pad_irq(struct wacom_wac *wacom, size_t len) | |
2721 | { | |
2722 | unsigned char *data = wacom->data; | |
2723 | ||
2724 | if (!((len == WACOM_PKGLEN_BPAD_TOUCH) || | |
2725 | (len == WACOM_PKGLEN_BPAD_TOUCH_USB)) || | |
2726 | (data[0] != WACOM_REPORT_BPAD_TOUCH)) | |
2727 | return 0; | |
2728 | ||
2729 | if (data[1] & 0x01) | |
2730 | wacom_bamboo_pad_pen_event(wacom, &data[1]); | |
2731 | ||
2732 | if (data[1] & 0x02) | |
2733 | return wacom_bamboo_pad_touch_event(wacom, &data[9]); | |
2734 | ||
2735 | return 0; | |
2736 | } | |
2737 | ||
d3825d51 CB |
2738 | static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len) |
2739 | { | |
16bf288c CB |
2740 | unsigned char *data = wacom->data; |
2741 | int connected; | |
2742 | ||
b5fd2a3e | 2743 | if (len != WACOM_PKGLEN_WIRELESS || data[0] != WACOM_REPORT_WL) |
d3825d51 CB |
2744 | return 0; |
2745 | ||
16bf288c CB |
2746 | connected = data[1] & 0x01; |
2747 | if (connected) { | |
b0882cb7 | 2748 | int pid, battery, charging; |
16bf288c | 2749 | |
eda01dab PC |
2750 | if ((wacom->shared->type == INTUOSHT || |
2751 | wacom->shared->type == INTUOSHT2) && | |
44b96838 PC |
2752 | wacom->shared->touch_input && |
2753 | wacom->shared->touch_max) { | |
961794a0 PC |
2754 | input_report_switch(wacom->shared->touch_input, |
2755 | SW_MUTE_DEVICE, data[5] & 0x40); | |
2756 | input_sync(wacom->shared->touch_input); | |
2757 | } | |
2758 | ||
16bf288c | 2759 | pid = get_unaligned_be16(&data[6]); |
ac8d1010 | 2760 | battery = (data[5] & 0x3f) * 100 / 31; |
b0882cb7 | 2761 | charging = !!(data[5] & 0x80); |
16bf288c CB |
2762 | if (wacom->pid != pid) { |
2763 | wacom->pid = pid; | |
d17d1f17 | 2764 | wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS); |
16bf288c | 2765 | } |
ac8d1010 | 2766 | |
59d69bc8 | 2767 | wacom_notify_battery(wacom, battery, charging, 1, 0); |
953f2c5f | 2768 | |
16bf288c CB |
2769 | } else if (wacom->pid != 0) { |
2770 | /* disconnected while previously connected */ | |
2771 | wacom->pid = 0; | |
d17d1f17 | 2772 | wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS); |
71fa641e | 2773 | wacom_notify_battery(wacom, 0, 0, 0, 0); |
16bf288c CB |
2774 | } |
2775 | ||
d3825d51 CB |
2776 | return 0; |
2777 | } | |
2778 | ||
4ca4ec71 JG |
2779 | static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len) |
2780 | { | |
8f93b0b2 | 2781 | struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac); |
4ca4ec71 JG |
2782 | struct wacom_features *features = &wacom_wac->features; |
2783 | unsigned char *data = wacom_wac->data; | |
2784 | ||
2785 | if (data[0] != WACOM_REPORT_USB) | |
2786 | return 0; | |
2787 | ||
eda01dab PC |
2788 | if ((features->type == INTUOSHT || |
2789 | features->type == INTUOSHT2) && | |
4ca4ec71 JG |
2790 | wacom_wac->shared->touch_input && |
2791 | features->touch_max) { | |
2792 | input_report_switch(wacom_wac->shared->touch_input, | |
2793 | SW_MUTE_DEVICE, data[8] & 0x40); | |
2794 | input_sync(wacom_wac->shared->touch_input); | |
16bf288c CB |
2795 | } |
2796 | ||
8f93b0b2 JG |
2797 | if (data[9] & 0x02) { /* wireless module is attached */ |
2798 | int battery = (data[8] & 0x3f) * 100 / 31; | |
b0882cb7 | 2799 | bool charging = !!(data[8] & 0x80); |
8f93b0b2 JG |
2800 | |
2801 | wacom_notify_battery(wacom_wac, battery, charging, | |
71fa641e | 2802 | battery || charging, 1); |
8f93b0b2 | 2803 | |
59d69bc8 | 2804 | if (!wacom->battery.battery && |
8f93b0b2 JG |
2805 | !(features->quirks & WACOM_QUIRK_BATTERY)) { |
2806 | features->quirks |= WACOM_QUIRK_BATTERY; | |
d17d1f17 | 2807 | wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY); |
8f93b0b2 JG |
2808 | } |
2809 | } | |
2810 | else if ((features->quirks & WACOM_QUIRK_BATTERY) && | |
59d69bc8 | 2811 | wacom->battery.battery) { |
8f93b0b2 | 2812 | features->quirks &= ~WACOM_QUIRK_BATTERY; |
d17d1f17 | 2813 | wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY); |
71fa641e | 2814 | wacom_notify_battery(wacom_wac, 0, 0, 0, 0); |
8f93b0b2 | 2815 | } |
d3825d51 CB |
2816 | return 0; |
2817 | } | |
2818 | ||
95dd3b30 | 2819 | void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len) |
3bea733a | 2820 | { |
95dd3b30 DT |
2821 | bool sync; |
2822 | ||
e33da8a5 | 2823 | switch (wacom_wac->features.type) { |
73a97f4f | 2824 | case PENPARTNER: |
95dd3b30 DT |
2825 | sync = wacom_penpartner_irq(wacom_wac); |
2826 | break; | |
73a97f4f DT |
2827 | |
2828 | case PL: | |
95dd3b30 DT |
2829 | sync = wacom_pl_irq(wacom_wac); |
2830 | break; | |
73a97f4f DT |
2831 | |
2832 | case WACOM_G4: | |
2833 | case GRAPHIRE: | |
387142bb | 2834 | case GRAPHIRE_BT: |
73a97f4f | 2835 | case WACOM_MO: |
95dd3b30 DT |
2836 | sync = wacom_graphire_irq(wacom_wac); |
2837 | break; | |
73a97f4f DT |
2838 | |
2839 | case PTU: | |
95dd3b30 DT |
2840 | sync = wacom_ptu_irq(wacom_wac); |
2841 | break; | |
73a97f4f | 2842 | |
c8f2edc5 PC |
2843 | case DTU: |
2844 | sync = wacom_dtu_irq(wacom_wac); | |
2845 | break; | |
2846 | ||
497ab1f2 | 2847 | case DTUS: |
fff00bf8 | 2848 | case DTUSX: |
497ab1f2 PC |
2849 | sync = wacom_dtus_irq(wacom_wac); |
2850 | break; | |
2851 | ||
73a97f4f DT |
2852 | case INTUOS: |
2853 | case INTUOS3S: | |
2854 | case INTUOS3: | |
2855 | case INTUOS3L: | |
2856 | case INTUOS4S: | |
2857 | case INTUOS4: | |
2858 | case INTUOS4L: | |
2859 | case CINTIQ: | |
2860 | case WACOM_BEE: | |
56218563 | 2861 | case WACOM_13HD: |
3a4b4aaa | 2862 | case WACOM_21UX2: |
d838c644 | 2863 | case WACOM_22HD: |
803296b6 | 2864 | case WACOM_24HD: |
500d4160 | 2865 | case WACOM_27QHD: |
a112e9fd | 2866 | case DTK: |
36d3c510 | 2867 | case CINTIQ_HYBRID: |
f7acb55c | 2868 | case CINTIQ_COMPANION_2: |
95dd3b30 DT |
2869 | sync = wacom_intuos_irq(wacom_wac); |
2870 | break; | |
73a97f4f | 2871 | |
81af7e61 BT |
2872 | case INTUOS4WL: |
2873 | sync = wacom_intuos_bt_irq(wacom_wac, len); | |
2874 | break; | |
2875 | ||
b1e4279e | 2876 | case WACOM_24HDT: |
500d4160 | 2877 | case WACOM_27QHDT: |
b1e4279e JG |
2878 | sync = wacom_24hdt_irq(wacom_wac); |
2879 | break; | |
2880 | ||
ae584ca4 JG |
2881 | case INTUOS5S: |
2882 | case INTUOS5: | |
2883 | case INTUOS5L: | |
9a35c411 PC |
2884 | case INTUOSPS: |
2885 | case INTUOSPM: | |
2886 | case INTUOSPL: | |
ae584ca4 JG |
2887 | if (len == WACOM_PKGLEN_BBTOUCH3) |
2888 | sync = wacom_bpt3_touch(wacom_wac); | |
2d13a438 JG |
2889 | else if (wacom_wac->data[0] == WACOM_REPORT_USB) |
2890 | sync = wacom_status_irq(wacom_wac, len); | |
ae584ca4 JG |
2891 | else |
2892 | sync = wacom_intuos_irq(wacom_wac); | |
2893 | break; | |
2894 | ||
4922cd26 JG |
2895 | case INTUOSP2_BT: |
2896 | sync = wacom_intuos_pro2_bt_irq(wacom_wac, len); | |
2897 | break; | |
2898 | ||
73a97f4f | 2899 | case TABLETPC: |
ac173837 | 2900 | case TABLETPCE: |
73a97f4f | 2901 | case TABLETPC2FG: |
1963518b | 2902 | case MTSCREEN: |
6afdc289 | 2903 | case MTTPC: |
d51ddb2b | 2904 | case MTTPC_B: |
95dd3b30 DT |
2905 | sync = wacom_tpc_irq(wacom_wac, len); |
2906 | break; | |
73a97f4f | 2907 | |
cb734c03 | 2908 | case BAMBOO_PT: |
3b164a00 PC |
2909 | case BAMBOO_PEN: |
2910 | case BAMBOO_TOUCH: | |
b5fd2a3e | 2911 | case INTUOSHT: |
eda01dab | 2912 | case INTUOSHT2: |
4ca4ec71 JG |
2913 | if (wacom_wac->data[0] == WACOM_REPORT_USB) |
2914 | sync = wacom_status_irq(wacom_wac, len); | |
2915 | else | |
2916 | sync = wacom_bpt_irq(wacom_wac, len); | |
cb734c03 HR |
2917 | break; |
2918 | ||
8c97a765 BT |
2919 | case BAMBOO_PAD: |
2920 | sync = wacom_bamboo_pad_irq(wacom_wac, len); | |
cb734c03 HR |
2921 | break; |
2922 | ||
d3825d51 CB |
2923 | case WIRELESS: |
2924 | sync = wacom_wireless_irq(wacom_wac, len); | |
2925 | break; | |
2926 | ||
72b236d6 | 2927 | case REMOTE: |
e6f2813a | 2928 | sync = false; |
72b236d6 | 2929 | if (wacom_wac->data[0] == WACOM_REPORT_DEVICE_LIST) |
e6f2813a | 2930 | wacom_remote_status_irq(wacom_wac, len); |
72b236d6 AS |
2931 | else |
2932 | sync = wacom_remote_irq(wacom_wac, len); | |
2933 | break; | |
2934 | ||
73a97f4f | 2935 | default: |
95dd3b30 DT |
2936 | sync = false; |
2937 | break; | |
3bea733a | 2938 | } |
95dd3b30 | 2939 | |
d2d13f18 | 2940 | if (sync) { |
2a6cdbdd JG |
2941 | if (wacom_wac->pen_input) |
2942 | input_sync(wacom_wac->pen_input); | |
2943 | if (wacom_wac->touch_input) | |
2944 | input_sync(wacom_wac->touch_input); | |
d2d13f18 BT |
2945 | if (wacom_wac->pad_input) |
2946 | input_sync(wacom_wac->pad_input); | |
2947 | } | |
3bea733a PC |
2948 | } |
2949 | ||
eda01dab | 2950 | static void wacom_setup_basic_pro_pen(struct wacom_wac *wacom_wac) |
8da23fc1 | 2951 | { |
2a6cdbdd | 2952 | struct input_dev *input_dev = wacom_wac->pen_input; |
8da23fc1 DT |
2953 | |
2954 | input_set_capability(input_dev, EV_MSC, MSC_SERIAL); | |
8da23fc1 | 2955 | |
8da23fc1 | 2956 | __set_bit(BTN_TOOL_PEN, input_dev->keybit); |
8da23fc1 DT |
2957 | __set_bit(BTN_STYLUS, input_dev->keybit); |
2958 | __set_bit(BTN_STYLUS2, input_dev->keybit); | |
2959 | ||
2960 | input_set_abs_params(input_dev, ABS_DISTANCE, | |
bef7e200 | 2961 | 0, wacom_wac->features.distance_max, wacom_wac->features.distance_fuzz, 0); |
eda01dab PC |
2962 | } |
2963 | ||
2964 | static void wacom_setup_cintiq(struct wacom_wac *wacom_wac) | |
2965 | { | |
2966 | struct input_dev *input_dev = wacom_wac->pen_input; | |
bef7e200 | 2967 | struct wacom_features *features = &wacom_wac->features; |
eda01dab PC |
2968 | |
2969 | wacom_setup_basic_pro_pen(wacom_wac); | |
2970 | ||
2971 | __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); | |
2972 | __set_bit(BTN_TOOL_BRUSH, input_dev->keybit); | |
2973 | __set_bit(BTN_TOOL_PENCIL, input_dev->keybit); | |
2974 | __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit); | |
2975 | ||
8da23fc1 | 2976 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0); |
bef7e200 | 2977 | input_set_abs_params(input_dev, ABS_TILT_X, -64, 63, features->tilt_fuzz, 0); |
26fe4124 | 2978 | input_abs_set_res(input_dev, ABS_TILT_X, 57); |
bef7e200 | 2979 | input_set_abs_params(input_dev, ABS_TILT_Y, -64, 63, features->tilt_fuzz, 0); |
26fe4124 | 2980 | input_abs_set_res(input_dev, ABS_TILT_Y, 57); |
6521d0bf PC |
2981 | } |
2982 | ||
2983 | static void wacom_setup_intuos(struct wacom_wac *wacom_wac) | |
2984 | { | |
2a6cdbdd | 2985 | struct input_dev *input_dev = wacom_wac->pen_input; |
6521d0bf PC |
2986 | |
2987 | input_set_capability(input_dev, EV_REL, REL_WHEEL); | |
2988 | ||
2989 | wacom_setup_cintiq(wacom_wac); | |
2990 | ||
2991 | __set_bit(BTN_LEFT, input_dev->keybit); | |
2992 | __set_bit(BTN_RIGHT, input_dev->keybit); | |
2993 | __set_bit(BTN_MIDDLE, input_dev->keybit); | |
2994 | __set_bit(BTN_SIDE, input_dev->keybit); | |
2995 | __set_bit(BTN_EXTRA, input_dev->keybit); | |
2996 | __set_bit(BTN_TOOL_MOUSE, input_dev->keybit); | |
2997 | __set_bit(BTN_TOOL_LENS, input_dev->keybit); | |
2998 | ||
8da23fc1 | 2999 | input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0); |
26fe4124 | 3000 | input_abs_set_res(input_dev, ABS_RZ, 287); |
8da23fc1 DT |
3001 | input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0); |
3002 | } | |
3003 | ||
42f4f272 | 3004 | void wacom_setup_device_quirks(struct wacom *wacom) |
bc73dd39 | 3005 | { |
42f4f272 | 3006 | struct wacom_features *features = &wacom->wacom_wac.features; |
bc73dd39 | 3007 | |
862cf553 JG |
3008 | /* The pen and pad share the same interface on most devices */ |
3009 | if (features->type == GRAPHIRE_BT || features->type == WACOM_G4 || | |
3b164a00 PC |
3010 | features->type == DTUS || |
3011 | (features->type >= INTUOS3S && features->type <= WACOM_MO)) { | |
862cf553 JG |
3012 | if (features->device_type & WACOM_DEVICETYPE_PEN) |
3013 | features->device_type |= WACOM_DEVICETYPE_PAD; | |
3014 | } | |
bc73dd39 HR |
3015 | |
3016 | /* touch device found but size is not defined. use default */ | |
aa86b18c | 3017 | if (features->device_type & WACOM_DEVICETYPE_TOUCH && !features->x_max) { |
bc73dd39 HR |
3018 | features->x_max = 1023; |
3019 | features->y_max = 1023; | |
3020 | } | |
3021 | ||
42f4f272 PC |
3022 | /* |
3023 | * Intuos5/Pro and Bamboo 3rd gen have no useful data about its | |
3024 | * touch interface in its HID descriptor. If this is the touch | |
3025 | * interface (PacketSize of WACOM_PKGLEN_BBTOUCH3), override the | |
3026 | * tablet values. | |
3027 | */ | |
3b164a00 PC |
3028 | if ((features->type >= INTUOS5S && features->type <= INTUOSPL) || |
3029 | (features->type >= INTUOSHT && features->type <= BAMBOO_PT)) { | |
42f4f272 | 3030 | if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { |
862cf553 JG |
3031 | if (features->touch_max) |
3032 | features->device_type |= WACOM_DEVICETYPE_TOUCH; | |
a3088abc | 3033 | if (features->type >= INTUOSHT && features->type <= BAMBOO_PT) |
862cf553 | 3034 | features->device_type |= WACOM_DEVICETYPE_PAD; |
42f4f272 PC |
3035 | |
3036 | features->x_max = 4096; | |
3037 | features->y_max = 4096; | |
42f4f272 | 3038 | } |
9633920e JG |
3039 | else if (features->pktlen == WACOM_PKGLEN_BBTOUCH) { |
3040 | features->device_type |= WACOM_DEVICETYPE_PAD; | |
3041 | } | |
42f4f272 PC |
3042 | } |
3043 | ||
580549ef BT |
3044 | /* |
3045 | * Hack for the Bamboo One: | |
3046 | * the device presents a PAD/Touch interface as most Bamboos and even | |
3047 | * sends ghosts PAD data on it. However, later, we must disable this | |
3048 | * ghost interface, and we can not detect it unless we set it here | |
3049 | * to WACOM_DEVICETYPE_PAD or WACOM_DEVICETYPE_TOUCH. | |
3050 | */ | |
3051 | if (features->type == BAMBOO_PEN && | |
3052 | features->pktlen == WACOM_PKGLEN_BBTOUCH3) | |
3053 | features->device_type |= WACOM_DEVICETYPE_PAD; | |
3054 | ||
42f4f272 | 3055 | /* |
042628ab JG |
3056 | * Raw Wacom-mode pen and touch events both come from interface |
3057 | * 0, whose HID descriptor has an application usage of 0xFF0D | |
8de82280 | 3058 | * (i.e., WACOM_HID_WD_DIGITIZER). We route pen packets back |
042628ab | 3059 | * out through the HID_GENERIC device created for interface 1, |
70caee0a | 3060 | * so rewrite this one to be of type WACOM_DEVICETYPE_TOUCH. |
42f4f272 PC |
3061 | */ |
3062 | if (features->type == BAMBOO_PAD) | |
70caee0a | 3063 | features->device_type = WACOM_DEVICETYPE_TOUCH; |
42f4f272 | 3064 | |
72b236d6 AS |
3065 | if (features->type == REMOTE) |
3066 | features->device_type = WACOM_DEVICETYPE_PAD; | |
42f4f272 | 3067 | |
4922cd26 JG |
3068 | if (features->type == INTUOSP2_BT) { |
3069 | features->device_type |= WACOM_DEVICETYPE_PEN | | |
3070 | WACOM_DEVICETYPE_PAD | | |
3071 | WACOM_DEVICETYPE_TOUCH; | |
3072 | features->quirks |= WACOM_QUIRK_BATTERY; | |
3073 | } | |
3074 | ||
e5bc8eb1 JG |
3075 | switch (features->type) { |
3076 | case PL: | |
3077 | case DTU: | |
3078 | case DTUS: | |
3079 | case DTUSX: | |
3080 | case WACOM_21UX2: | |
3081 | case WACOM_22HD: | |
3082 | case DTK: | |
3083 | case WACOM_24HD: | |
3084 | case WACOM_27QHD: | |
3085 | case CINTIQ_HYBRID: | |
3086 | case CINTIQ_COMPANION_2: | |
3087 | case CINTIQ: | |
3088 | case WACOM_BEE: | |
3089 | case WACOM_13HD: | |
3090 | case WACOM_24HDT: | |
3091 | case WACOM_27QHDT: | |
3092 | case TABLETPC: | |
3093 | case TABLETPCE: | |
3094 | case TABLETPC2FG: | |
3095 | case MTSCREEN: | |
3096 | case MTTPC: | |
3097 | case MTTPC_B: | |
3098 | features->device_type |= WACOM_DEVICETYPE_DIRECT; | |
3099 | break; | |
3100 | } | |
3101 | ||
42f4f272 PC |
3102 | if (wacom->hdev->bus == BUS_BLUETOOTH) |
3103 | features->quirks |= WACOM_QUIRK_BATTERY; | |
3104 | ||
73149ab8 | 3105 | /* quirk for bamboo touch with 2 low res touches */ |
be853fd1 | 3106 | if ((features->type == BAMBOO_PT || features->type == BAMBOO_TOUCH) && |
73149ab8 | 3107 | features->pktlen == WACOM_PKGLEN_BBTOUCH) { |
f4ccbef2 HR |
3108 | features->x_max <<= 5; |
3109 | features->y_max <<= 5; | |
3110 | features->x_fuzz <<= 5; | |
3111 | features->y_fuzz <<= 5; | |
f4ccbef2 | 3112 | features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES; |
cb734c03 | 3113 | } |
d3825d51 CB |
3114 | |
3115 | if (features->type == WIRELESS) { | |
ccad85cc | 3116 | if (features->device_type == WACOM_DEVICETYPE_WL_MONITOR) { |
ac8d1010 BT |
3117 | features->quirks |= WACOM_QUIRK_BATTERY; |
3118 | } | |
d3825d51 | 3119 | } |
7c35dc3c BT |
3120 | |
3121 | if (features->type == REMOTE) | |
3122 | features->device_type |= WACOM_DEVICETYPE_WL_MONITOR; | |
bc73dd39 HR |
3123 | } |
3124 | ||
2636a3f2 | 3125 | int wacom_setup_pen_input_capabilities(struct input_dev *input_dev, |
8c0e0a4f PC |
3126 | struct wacom_wac *wacom_wac) |
3127 | { | |
3128 | struct wacom_features *features = &wacom_wac->features; | |
8c0e0a4f PC |
3129 | |
3130 | input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | |
3131 | ||
2636a3f2 JG |
3132 | if (!(features->device_type & WACOM_DEVICETYPE_PEN)) |
3133 | return -ENODEV; | |
3134 | ||
e5bc8eb1 JG |
3135 | if (features->device_type & WACOM_DEVICETYPE_DIRECT) |
3136 | __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); | |
3137 | else | |
3138 | __set_bit(INPUT_PROP_POINTER, input_dev->propbit); | |
3139 | ||
7704ac93 BT |
3140 | if (features->type == HID_GENERIC) |
3141 | /* setup has already been done */ | |
3142 | return 0; | |
3143 | ||
8c0e0a4f | 3144 | __set_bit(BTN_TOUCH, input_dev->keybit); |
8da23fc1 DT |
3145 | __set_bit(ABS_MISC, input_dev->absbit); |
3146 | ||
e779ef23 JG |
3147 | input_set_abs_params(input_dev, ABS_X, 0 + features->offset_left, |
3148 | features->x_max - features->offset_right, | |
3149 | features->x_fuzz, 0); | |
3150 | input_set_abs_params(input_dev, ABS_Y, 0 + features->offset_top, | |
3151 | features->y_max - features->offset_bottom, | |
3152 | features->y_fuzz, 0); | |
2636a3f2 JG |
3153 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, |
3154 | features->pressure_max, features->pressure_fuzz, 0); | |
3155 | ||
3156 | /* penabled devices have fixed resolution for each model */ | |
3157 | input_abs_set_res(input_dev, ABS_X, features->x_resolution); | |
3158 | input_abs_set_res(input_dev, ABS_Y, features->y_resolution); | |
3159 | ||
497ab1f2 | 3160 | switch (features->type) { |
387142bb BT |
3161 | case GRAPHIRE_BT: |
3162 | __clear_bit(ABS_MISC, input_dev->absbit); | |
a2f71c6c PC |
3163 | |
3164 | case WACOM_MO: | |
3165 | case WACOM_G4: | |
387142bb BT |
3166 | input_set_abs_params(input_dev, ABS_DISTANCE, 0, |
3167 | features->distance_max, | |
bef7e200 | 3168 | features->distance_fuzz, 0); |
a2f71c6c | 3169 | /* fall through */ |
803296b6 | 3170 | |
a2f71c6c | 3171 | case GRAPHIRE: |
387142bb | 3172 | input_set_capability(input_dev, EV_REL, REL_WHEEL); |
803296b6 | 3173 | |
387142bb BT |
3174 | __set_bit(BTN_LEFT, input_dev->keybit); |
3175 | __set_bit(BTN_RIGHT, input_dev->keybit); | |
3176 | __set_bit(BTN_MIDDLE, input_dev->keybit); | |
3177 | ||
3178 | __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); | |
3179 | __set_bit(BTN_TOOL_PEN, input_dev->keybit); | |
3180 | __set_bit(BTN_TOOL_MOUSE, input_dev->keybit); | |
3181 | __set_bit(BTN_STYLUS, input_dev->keybit); | |
3182 | __set_bit(BTN_STYLUS2, input_dev->keybit); | |
387142bb | 3183 | break; |
c73a1afb | 3184 | |
500d4160 | 3185 | case WACOM_27QHD: |
803296b6 | 3186 | case WACOM_24HD: |
a112e9fd | 3187 | case DTK: |
d838c644 | 3188 | case WACOM_22HD: |
3a4b4aaa | 3189 | case WACOM_21UX2: |
73a97f4f | 3190 | case WACOM_BEE: |
6521d0bf | 3191 | case CINTIQ: |
56218563 | 3192 | case WACOM_13HD: |
a2f71c6c | 3193 | case CINTIQ_HYBRID: |
f7acb55c | 3194 | case CINTIQ_COMPANION_2: |
56218563 | 3195 | input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); |
26fe4124 | 3196 | input_abs_set_res(input_dev, ABS_Z, 287); |
56218563 PC |
3197 | wacom_setup_cintiq(wacom_wac); |
3198 | break; | |
3199 | ||
73a97f4f DT |
3200 | case INTUOS3: |
3201 | case INTUOS3L: | |
73a97f4f | 3202 | case INTUOS3S: |
a2f71c6c PC |
3203 | case INTUOS4: |
3204 | case INTUOS4WL: | |
3205 | case INTUOS4L: | |
3206 | case INTUOS4S: | |
8da23fc1 | 3207 | input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); |
26fe4124 | 3208 | input_abs_set_res(input_dev, ABS_Z, 287); |
73a97f4f DT |
3209 | /* fall through */ |
3210 | ||
3211 | case INTUOS: | |
8da23fc1 | 3212 | wacom_setup_intuos(wacom_wac); |
73a97f4f DT |
3213 | break; |
3214 | ||
9fee6195 JG |
3215 | case INTUOS5: |
3216 | case INTUOS5L: | |
9a35c411 PC |
3217 | case INTUOSPM: |
3218 | case INTUOSPL: | |
ae584ca4 | 3219 | case INTUOS5S: |
9a35c411 | 3220 | case INTUOSPS: |
4922cd26 | 3221 | case INTUOSP2_BT: |
2636a3f2 JG |
3222 | input_set_abs_params(input_dev, ABS_DISTANCE, 0, |
3223 | features->distance_max, | |
bef7e200 | 3224 | features->distance_fuzz, 0); |
ae584ca4 | 3225 | |
2636a3f2 JG |
3226 | input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); |
3227 | input_abs_set_res(input_dev, ABS_Z, 287); | |
ae584ca4 | 3228 | |
2636a3f2 | 3229 | wacom_setup_intuos(wacom_wac); |
ae584ca4 JG |
3230 | break; |
3231 | ||
b1e4279e | 3232 | case WACOM_24HDT: |
500d4160 | 3233 | case WACOM_27QHDT: |
1963518b | 3234 | case MTSCREEN: |
6afdc289 | 3235 | case MTTPC: |
d51ddb2b | 3236 | case MTTPC_B: |
6795a524 | 3237 | case TABLETPC2FG: |
73a97f4f | 3238 | case TABLETPC: |
ac173837 | 3239 | case TABLETPCE: |
a43c7c53 | 3240 | __clear_bit(ABS_MISC, input_dev->absbit); |
73a97f4f DT |
3241 | /* fall through */ |
3242 | ||
497ab1f2 | 3243 | case DTUS: |
fff00bf8 | 3244 | case DTUSX: |
73a97f4f | 3245 | case PL: |
c8f2edc5 | 3246 | case DTU: |
8da23fc1 | 3247 | __set_bit(BTN_TOOL_PEN, input_dev->keybit); |
3512069e | 3248 | __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); |
8da23fc1 DT |
3249 | __set_bit(BTN_STYLUS, input_dev->keybit); |
3250 | __set_bit(BTN_STYLUS2, input_dev->keybit); | |
3512069e JG |
3251 | break; |
3252 | ||
3253 | case PTU: | |
8da23fc1 | 3254 | __set_bit(BTN_STYLUS2, input_dev->keybit); |
73a97f4f DT |
3255 | /* fall through */ |
3256 | ||
3257 | case PENPARTNER: | |
1fab84aa | 3258 | __set_bit(BTN_TOOL_PEN, input_dev->keybit); |
8da23fc1 | 3259 | __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); |
1fab84aa | 3260 | __set_bit(BTN_STYLUS, input_dev->keybit); |
73a97f4f | 3261 | break; |
cb734c03 | 3262 | |
b5fd2a3e | 3263 | case INTUOSHT: |
cb734c03 | 3264 | case BAMBOO_PT: |
3b164a00 | 3265 | case BAMBOO_PEN: |
eda01dab | 3266 | case INTUOSHT2: |
eda01dab PC |
3267 | if (features->type == INTUOSHT2) { |
3268 | wacom_setup_basic_pro_pen(wacom_wac); | |
3269 | } else { | |
3270 | __clear_bit(ABS_MISC, input_dev->absbit); | |
3271 | __set_bit(BTN_TOOL_PEN, input_dev->keybit); | |
3272 | __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); | |
3273 | __set_bit(BTN_STYLUS, input_dev->keybit); | |
3274 | __set_bit(BTN_STYLUS2, input_dev->keybit); | |
3275 | input_set_abs_params(input_dev, ABS_DISTANCE, 0, | |
2636a3f2 | 3276 | features->distance_max, |
bef7e200 | 3277 | features->distance_fuzz, 0); |
eda01dab | 3278 | } |
2636a3f2 JG |
3279 | break; |
3280 | case BAMBOO_PAD: | |
3281 | __clear_bit(ABS_MISC, input_dev->absbit); | |
3282 | break; | |
3283 | } | |
3284 | return 0; | |
3285 | } | |
02295e68 | 3286 | |
2636a3f2 JG |
3287 | int wacom_setup_touch_input_capabilities(struct input_dev *input_dev, |
3288 | struct wacom_wac *wacom_wac) | |
3289 | { | |
3290 | struct wacom_features *features = &wacom_wac->features; | |
30ebc1ae | 3291 | |
2636a3f2 JG |
3292 | input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
3293 | ||
3294 | if (!(features->device_type & WACOM_DEVICETYPE_TOUCH)) | |
3295 | return -ENODEV; | |
3296 | ||
e5bc8eb1 JG |
3297 | if (features->device_type & WACOM_DEVICETYPE_DIRECT) |
3298 | __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); | |
3299 | else | |
3300 | __set_bit(INPUT_PROP_POINTER, input_dev->propbit); | |
3301 | ||
2636a3f2 JG |
3302 | if (features->type == HID_GENERIC) |
3303 | /* setup has already been done */ | |
3304 | return 0; | |
3305 | ||
3306 | __set_bit(BTN_TOUCH, input_dev->keybit); | |
3307 | ||
3308 | if (features->touch_max == 1) { | |
3309 | input_set_abs_params(input_dev, ABS_X, 0, | |
3310 | features->x_max, features->x_fuzz, 0); | |
3311 | input_set_abs_params(input_dev, ABS_Y, 0, | |
3312 | features->y_max, features->y_fuzz, 0); | |
3313 | input_abs_set_res(input_dev, ABS_X, | |
3314 | features->x_resolution); | |
3315 | input_abs_set_res(input_dev, ABS_Y, | |
3316 | features->y_resolution); | |
3317 | } | |
3318 | else if (features->touch_max > 1) { | |
3319 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, | |
3320 | features->x_max, features->x_fuzz, 0); | |
3321 | input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, | |
3322 | features->y_max, features->y_fuzz, 0); | |
3323 | input_abs_set_res(input_dev, ABS_MT_POSITION_X, | |
3324 | features->x_resolution); | |
3325 | input_abs_set_res(input_dev, ABS_MT_POSITION_Y, | |
3326 | features->y_resolution); | |
3327 | } | |
3328 | ||
3329 | switch (features->type) { | |
4922cd26 JG |
3330 | case INTUOSP2_BT: |
3331 | input_dev->evbit[0] |= BIT_MASK(EV_SW); | |
3332 | __set_bit(SW_MUTE_DEVICE, input_dev->swbit); | |
3333 | ||
3334 | if (wacom_wac->shared->touch->product == 0x361) { | |
3335 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, | |
3336 | 0, 12440, 4, 0); | |
3337 | input_set_abs_params(input_dev, ABS_MT_POSITION_Y, | |
3338 | 0, 8640, 4, 0); | |
3339 | } | |
3340 | else if (wacom_wac->shared->touch->product == 0x360) { | |
3341 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, | |
3342 | 0, 8960, 4, 0); | |
3343 | input_set_abs_params(input_dev, ABS_MT_POSITION_Y, | |
3344 | 0, 5920, 4, 0); | |
3345 | } | |
3346 | input_abs_set_res(input_dev, ABS_MT_POSITION_X, 40); | |
3347 | input_abs_set_res(input_dev, ABS_MT_POSITION_X, 40); | |
3348 | ||
3349 | /* fall through */ | |
3350 | ||
2636a3f2 JG |
3351 | case INTUOS5: |
3352 | case INTUOS5L: | |
3353 | case INTUOSPM: | |
3354 | case INTUOSPL: | |
3355 | case INTUOS5S: | |
3356 | case INTUOSPS: | |
2636a3f2 JG |
3357 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0); |
3358 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, features->y_max, 0, 0); | |
3359 | input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER); | |
3360 | break; | |
3361 | ||
3362 | case WACOM_24HDT: | |
3363 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0); | |
3364 | input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0); | |
3365 | input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0); | |
3366 | input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0); | |
3367 | /* fall through */ | |
3368 | ||
3369 | case WACOM_27QHDT: | |
3370 | case MTSCREEN: | |
3371 | case MTTPC: | |
3372 | case MTTPC_B: | |
3373 | case TABLETPC2FG: | |
3374 | input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT); | |
3375 | /*fall through */ | |
3376 | ||
3377 | case TABLETPC: | |
3378 | case TABLETPCE: | |
2636a3f2 JG |
3379 | break; |
3380 | ||
3381 | case INTUOSHT: | |
eda01dab | 3382 | case INTUOSHT2: |
2636a3f2 JG |
3383 | input_dev->evbit[0] |= BIT_MASK(EV_SW); |
3384 | __set_bit(SW_MUTE_DEVICE, input_dev->swbit); | |
3385 | /* fall through */ | |
3386 | ||
3387 | case BAMBOO_PT: | |
3b164a00 | 3388 | case BAMBOO_TOUCH: |
2636a3f2 JG |
3389 | if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { |
3390 | input_set_abs_params(input_dev, | |
3391 | ABS_MT_TOUCH_MAJOR, | |
3392 | 0, features->x_max, 0, 0); | |
3393 | input_set_abs_params(input_dev, | |
3394 | ABS_MT_TOUCH_MINOR, | |
3395 | 0, features->y_max, 0, 0); | |
cb734c03 | 3396 | } |
2636a3f2 | 3397 | input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER); |
cb734c03 | 3398 | break; |
2636a3f2 | 3399 | |
8c97a765 | 3400 | case BAMBOO_PAD: |
8c97a765 BT |
3401 | input_mt_init_slots(input_dev, features->touch_max, |
3402 | INPUT_MT_POINTER); | |
3403 | __set_bit(BTN_LEFT, input_dev->keybit); | |
3404 | __set_bit(BTN_RIGHT, input_dev->keybit); | |
3405 | break; | |
3bea733a | 3406 | } |
1963518b | 3407 | return 0; |
3bea733a PC |
3408 | } |
3409 | ||
49005b9f JG |
3410 | static int wacom_numbered_button_to_key(int n) |
3411 | { | |
3412 | if (n < 10) | |
3413 | return BTN_0 + n; | |
3414 | else if (n < 16) | |
3415 | return BTN_A + (n-10); | |
3416 | else if (n < 18) | |
3417 | return BTN_BASE + (n-16); | |
3418 | else | |
3419 | return 0; | |
3420 | } | |
3421 | ||
5397df15 | 3422 | static void wacom_setup_numbered_buttons(struct input_dev *input_dev, |
70ee06c5 AS |
3423 | int button_count) |
3424 | { | |
3425 | int i; | |
3426 | ||
49005b9f JG |
3427 | for (i = 0; i < button_count; i++) { |
3428 | int key = wacom_numbered_button_to_key(i); | |
3429 | ||
3430 | if (key) | |
3431 | __set_bit(key, input_dev->keybit); | |
3432 | } | |
70ee06c5 AS |
3433 | } |
3434 | ||
6a06281e BT |
3435 | static void wacom_24hd_update_leds(struct wacom *wacom, int mask, int group) |
3436 | { | |
3437 | struct wacom_led *led; | |
3438 | int i; | |
3439 | bool updated = false; | |
3440 | ||
3441 | /* | |
3442 | * 24HD has LED group 1 to the left and LED group 0 to the right. | |
3443 | * So group 0 matches the second half of the buttons and thus the mask | |
3444 | * needs to be shifted. | |
3445 | */ | |
3446 | if (group == 0) | |
3447 | mask >>= 8; | |
3448 | ||
3449 | for (i = 0; i < 3; i++) { | |
3450 | led = wacom_led_find(wacom, group, i); | |
3451 | if (!led) { | |
3452 | hid_err(wacom->hdev, "can't find LED %d in group %d\n", | |
3453 | i, group); | |
3454 | continue; | |
3455 | } | |
3456 | if (!updated && mask & BIT(i)) { | |
3457 | led->held = true; | |
3458 | led_trigger_event(&led->trigger, LED_FULL); | |
3459 | } else { | |
3460 | led->held = false; | |
3461 | } | |
3462 | } | |
3463 | } | |
3464 | ||
34736aa9 BT |
3465 | static bool wacom_is_led_toggled(struct wacom *wacom, int button_count, |
3466 | int mask, int group) | |
3467 | { | |
3468 | int button_per_group; | |
3469 | ||
5a0fe8ab | 3470 | /* |
6a06281e | 3471 | * 21UX2 has LED group 1 to the left and LED group 0 |
5a0fe8ab BT |
3472 | * to the right. We need to reverse the group to match this |
3473 | * historical behavior. | |
3474 | */ | |
6a06281e | 3475 | if (wacom->wacom_wac.features.type == WACOM_21UX2) |
5a0fe8ab BT |
3476 | group = 1 - group; |
3477 | ||
34736aa9 BT |
3478 | button_per_group = button_count/wacom->led.count; |
3479 | ||
3480 | return mask & (1 << (group * button_per_group)); | |
3481 | } | |
3482 | ||
3483 | static void wacom_update_led(struct wacom *wacom, int button_count, int mask, | |
3484 | int group) | |
3485 | { | |
3486 | struct wacom_led *led, *next_led; | |
3487 | int cur; | |
3488 | bool pressed; | |
3489 | ||
6a06281e BT |
3490 | if (wacom->wacom_wac.features.type == WACOM_24HD) |
3491 | return wacom_24hd_update_leds(wacom, mask, group); | |
3492 | ||
34736aa9 BT |
3493 | pressed = wacom_is_led_toggled(wacom, button_count, mask, group); |
3494 | cur = wacom->led.groups[group].select; | |
3495 | ||
3496 | led = wacom_led_find(wacom, group, cur); | |
3497 | if (!led) { | |
3498 | hid_err(wacom->hdev, "can't find current LED %d in group %d\n", | |
3499 | cur, group); | |
3500 | return; | |
3501 | } | |
3502 | ||
3503 | if (!pressed) { | |
3504 | led->held = false; | |
3505 | return; | |
3506 | } | |
3507 | ||
3508 | if (led->held && pressed) | |
3509 | return; | |
3510 | ||
3511 | next_led = wacom_led_next(wacom, led); | |
3512 | if (!next_led) { | |
3513 | hid_err(wacom->hdev, "can't find next LED in group %d\n", | |
3514 | group); | |
3515 | return; | |
3516 | } | |
3517 | if (next_led == led) | |
3518 | return; | |
3519 | ||
3520 | next_led->held = true; | |
3521 | led_trigger_event(&next_led->trigger, | |
3522 | wacom_leds_brightness_get(next_led)); | |
3523 | } | |
3524 | ||
c7f0522a JG |
3525 | static void wacom_report_numbered_buttons(struct input_dev *input_dev, |
3526 | int button_count, int mask) | |
3527 | { | |
34736aa9 | 3528 | struct wacom *wacom = input_get_drvdata(input_dev); |
c7f0522a JG |
3529 | int i; |
3530 | ||
34736aa9 BT |
3531 | for (i = 0; i < wacom->led.count; i++) |
3532 | wacom_update_led(wacom, button_count, mask, i); | |
3533 | ||
49005b9f JG |
3534 | for (i = 0; i < button_count; i++) { |
3535 | int key = wacom_numbered_button_to_key(i); | |
3536 | ||
3537 | if (key) | |
3538 | input_report_key(input_dev, key, mask & (1 << i)); | |
3539 | } | |
c7f0522a JG |
3540 | } |
3541 | ||
d2d13f18 BT |
3542 | int wacom_setup_pad_input_capabilities(struct input_dev *input_dev, |
3543 | struct wacom_wac *wacom_wac) | |
3544 | { | |
3545 | struct wacom_features *features = &wacom_wac->features; | |
3546 | ||
e7deb157 PC |
3547 | if ((features->type == HID_GENERIC) && features->numbered_buttons > 0) |
3548 | features->device_type |= WACOM_DEVICETYPE_PAD; | |
3549 | ||
862cf553 JG |
3550 | if (!(features->device_type & WACOM_DEVICETYPE_PAD)) |
3551 | return -ENODEV; | |
3552 | ||
7c35dc3c BT |
3553 | if (features->type == REMOTE && input_dev == wacom_wac->pad_input) |
3554 | return -ENODEV; | |
3555 | ||
d2d13f18 BT |
3556 | input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
3557 | ||
3558 | /* kept for making legacy xf86-input-wacom working with the wheels */ | |
3559 | __set_bit(ABS_MISC, input_dev->absbit); | |
3560 | ||
3561 | /* kept for making legacy xf86-input-wacom accepting the pad */ | |
5922e613 JG |
3562 | if (!(input_dev->absinfo && (input_dev->absinfo[ABS_X].minimum || |
3563 | input_dev->absinfo[ABS_X].maximum))) | |
3564 | input_set_abs_params(input_dev, ABS_X, 0, 1, 0, 0); | |
3565 | if (!(input_dev->absinfo && (input_dev->absinfo[ABS_Y].minimum || | |
3566 | input_dev->absinfo[ABS_Y].maximum))) | |
3567 | input_set_abs_params(input_dev, ABS_Y, 0, 1, 0, 0); | |
d2d13f18 | 3568 | |
12969e3b BT |
3569 | /* kept for making udev and libwacom accepting the pad */ |
3570 | __set_bit(BTN_STYLUS, input_dev->keybit); | |
3571 | ||
70ee06c5 AS |
3572 | wacom_setup_numbered_buttons(input_dev, features->numbered_buttons); |
3573 | ||
d2d13f18 | 3574 | switch (features->type) { |
70ee06c5 AS |
3575 | |
3576 | case CINTIQ_HYBRID: | |
f7acb55c | 3577 | case CINTIQ_COMPANION_2: |
70ee06c5 AS |
3578 | case DTK: |
3579 | case DTUS: | |
387142bb | 3580 | case GRAPHIRE_BT: |
387142bb BT |
3581 | break; |
3582 | ||
3813810c BT |
3583 | case WACOM_MO: |
3584 | __set_bit(BTN_BACK, input_dev->keybit); | |
3585 | __set_bit(BTN_LEFT, input_dev->keybit); | |
3586 | __set_bit(BTN_FORWARD, input_dev->keybit); | |
3587 | __set_bit(BTN_RIGHT, input_dev->keybit); | |
3588 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); | |
3589 | break; | |
3590 | ||
3591 | case WACOM_G4: | |
3592 | __set_bit(BTN_BACK, input_dev->keybit); | |
3813810c | 3593 | __set_bit(BTN_FORWARD, input_dev->keybit); |
3813810c BT |
3594 | input_set_capability(input_dev, EV_REL, REL_WHEEL); |
3595 | break; | |
3596 | ||
10059cdc | 3597 | case WACOM_24HD: |
10059cdc BT |
3598 | __set_bit(KEY_PROG1, input_dev->keybit); |
3599 | __set_bit(KEY_PROG2, input_dev->keybit); | |
3600 | __set_bit(KEY_PROG3, input_dev->keybit); | |
3601 | ||
3602 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); | |
3603 | input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0); | |
3604 | break; | |
3605 | ||
500d4160 PC |
3606 | case WACOM_27QHD: |
3607 | __set_bit(KEY_PROG1, input_dev->keybit); | |
3608 | __set_bit(KEY_PROG2, input_dev->keybit); | |
3609 | __set_bit(KEY_PROG3, input_dev->keybit); | |
3610 | input_set_abs_params(input_dev, ABS_X, -2048, 2048, 0, 0); | |
3611 | input_abs_set_res(input_dev, ABS_X, 1024); /* points/g */ | |
3612 | input_set_abs_params(input_dev, ABS_Y, -2048, 2048, 0, 0); | |
3613 | input_abs_set_res(input_dev, ABS_Y, 1024); | |
3614 | input_set_abs_params(input_dev, ABS_Z, -2048, 2048, 0, 0); | |
3615 | input_abs_set_res(input_dev, ABS_Z, 1024); | |
3616 | __set_bit(INPUT_PROP_ACCELEROMETER, input_dev->propbit); | |
3617 | break; | |
3618 | ||
10059cdc BT |
3619 | case WACOM_22HD: |
3620 | __set_bit(KEY_PROG1, input_dev->keybit); | |
3621 | __set_bit(KEY_PROG2, input_dev->keybit); | |
3622 | __set_bit(KEY_PROG3, input_dev->keybit); | |
3623 | /* fall through */ | |
3624 | ||
3625 | case WACOM_21UX2: | |
10059cdc | 3626 | case WACOM_BEE: |
10059cdc | 3627 | case CINTIQ: |
10059cdc BT |
3628 | input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0); |
3629 | input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0); | |
3630 | break; | |
3631 | ||
3632 | case WACOM_13HD: | |
10059cdc BT |
3633 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); |
3634 | break; | |
3635 | ||
3636 | case INTUOS3: | |
3637 | case INTUOS3L: | |
10059cdc BT |
3638 | input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0); |
3639 | /* fall through */ | |
3640 | ||
3641 | case INTUOS3S: | |
10059cdc BT |
3642 | input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0); |
3643 | break; | |
36d3c510 | 3644 | |
10059cdc BT |
3645 | case INTUOS5: |
3646 | case INTUOS5L: | |
3647 | case INTUOSPM: | |
3648 | case INTUOSPL: | |
10059cdc BT |
3649 | case INTUOS5S: |
3650 | case INTUOSPS: | |
4922cd26 | 3651 | case INTUOSP2_BT: |
10059cdc | 3652 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); |
36d3c510 | 3653 | break; |
10059cdc | 3654 | |
81af7e61 BT |
3655 | case INTUOS4WL: |
3656 | /* | |
3657 | * For Bluetooth devices, the udev rule does not work correctly | |
3658 | * for pads unless we add a stylus capability, which forces | |
3659 | * ID_INPUT_TABLET to be set. | |
3660 | */ | |
3661 | __set_bit(BTN_STYLUS, input_dev->keybit); | |
3662 | /* fall through */ | |
3663 | ||
10059cdc BT |
3664 | case INTUOS4: |
3665 | case INTUOS4L: | |
10059cdc | 3666 | case INTUOS4S: |
10059cdc BT |
3667 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); |
3668 | break; | |
3669 | ||
3116871f BT |
3670 | case INTUOSHT: |
3671 | case BAMBOO_PT: | |
3b164a00 | 3672 | case BAMBOO_TOUCH: |
eda01dab | 3673 | case INTUOSHT2: |
3116871f BT |
3674 | __clear_bit(ABS_MISC, input_dev->absbit); |
3675 | ||
3676 | __set_bit(BTN_LEFT, input_dev->keybit); | |
3677 | __set_bit(BTN_FORWARD, input_dev->keybit); | |
3678 | __set_bit(BTN_BACK, input_dev->keybit); | |
3679 | __set_bit(BTN_RIGHT, input_dev->keybit); | |
3680 | ||
3681 | break; | |
3682 | ||
72b236d6 AS |
3683 | case REMOTE: |
3684 | input_set_capability(input_dev, EV_MSC, MSC_SERIAL); | |
3685 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); | |
3686 | break; | |
3687 | ||
5922e613 JG |
3688 | case HID_GENERIC: |
3689 | break; | |
3690 | ||
d2d13f18 BT |
3691 | default: |
3692 | /* no pad supported */ | |
b3c8e93f | 3693 | return -ENODEV; |
3bea733a | 3694 | } |
1963518b | 3695 | return 0; |
3bea733a PC |
3696 | } |
3697 | ||
e87a344d | 3698 | static const struct wacom_features wacom_features_0x00 = |
80befa93 BT |
3699 | { "Wacom Penpartner", 5040, 3780, 255, 0, |
3700 | PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES }; | |
e87a344d | 3701 | static const struct wacom_features wacom_features_0x10 = |
80befa93 BT |
3702 | { "Wacom Graphire", 10206, 7422, 511, 63, |
3703 | GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; | |
387142bb BT |
3704 | static const struct wacom_features wacom_features_0x81 = |
3705 | { "Wacom Graphire BT", 16704, 12064, 511, 32, | |
70ee06c5 | 3706 | GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES, 2 }; |
e87a344d | 3707 | static const struct wacom_features wacom_features_0x11 = |
80befa93 BT |
3708 | { "Wacom Graphire2 4x5", 10206, 7422, 511, 63, |
3709 | GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; | |
e87a344d | 3710 | static const struct wacom_features wacom_features_0x12 = |
80befa93 BT |
3711 | { "Wacom Graphire2 5x7", 13918, 10206, 511, 63, |
3712 | GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; | |
e87a344d | 3713 | static const struct wacom_features wacom_features_0x13 = |
80befa93 BT |
3714 | { "Wacom Graphire3", 10208, 7424, 511, 63, |
3715 | GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; | |
e87a344d | 3716 | static const struct wacom_features wacom_features_0x14 = |
80befa93 BT |
3717 | { "Wacom Graphire3 6x8", 16704, 12064, 511, 63, |
3718 | GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; | |
e87a344d | 3719 | static const struct wacom_features wacom_features_0x15 = |
80befa93 BT |
3720 | { "Wacom Graphire4 4x5", 10208, 7424, 511, 63, |
3721 | WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; | |
e87a344d | 3722 | static const struct wacom_features wacom_features_0x16 = |
80befa93 BT |
3723 | { "Wacom Graphire4 6x8", 16704, 12064, 511, 63, |
3724 | WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; | |
e87a344d | 3725 | static const struct wacom_features wacom_features_0x17 = |
80befa93 BT |
3726 | { "Wacom BambooFun 4x5", 14760, 9225, 511, 63, |
3727 | WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
e87a344d | 3728 | static const struct wacom_features wacom_features_0x18 = |
80befa93 BT |
3729 | { "Wacom BambooFun 6x8", 21648, 13530, 511, 63, |
3730 | WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
e87a344d | 3731 | static const struct wacom_features wacom_features_0x19 = |
80befa93 BT |
3732 | { "Wacom Bamboo1 Medium", 16704, 12064, 511, 63, |
3733 | GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; | |
e87a344d | 3734 | static const struct wacom_features wacom_features_0x60 = |
80befa93 BT |
3735 | { "Wacom Volito", 5104, 3712, 511, 63, |
3736 | GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; | |
e87a344d | 3737 | static const struct wacom_features wacom_features_0x61 = |
80befa93 BT |
3738 | { "Wacom PenStation2", 3250, 2320, 255, 63, |
3739 | GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; | |
e87a344d | 3740 | static const struct wacom_features wacom_features_0x62 = |
80befa93 BT |
3741 | { "Wacom Volito2 4x5", 5104, 3712, 511, 63, |
3742 | GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; | |
e87a344d | 3743 | static const struct wacom_features wacom_features_0x63 = |
80befa93 BT |
3744 | { "Wacom Volito2 2x3", 3248, 2320, 511, 63, |
3745 | GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; | |
e87a344d | 3746 | static const struct wacom_features wacom_features_0x64 = |
80befa93 BT |
3747 | { "Wacom PenPartner2", 3250, 2320, 511, 63, |
3748 | GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; | |
e87a344d | 3749 | static const struct wacom_features wacom_features_0x65 = |
80befa93 BT |
3750 | { "Wacom Bamboo", 14760, 9225, 511, 63, |
3751 | WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
e87a344d | 3752 | static const struct wacom_features wacom_features_0x69 = |
80befa93 BT |
3753 | { "Wacom Bamboo1", 5104, 3712, 511, 63, |
3754 | GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES }; | |
11d0cf88 | 3755 | static const struct wacom_features wacom_features_0x6A = |
80befa93 BT |
3756 | { "Wacom Bamboo1 4x6", 14760, 9225, 1023, 63, |
3757 | GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
11d0cf88 | 3758 | static const struct wacom_features wacom_features_0x6B = |
80befa93 BT |
3759 | { "Wacom Bamboo1 5x8", 21648, 13530, 1023, 63, |
3760 | GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
e87a344d | 3761 | static const struct wacom_features wacom_features_0x20 = |
80befa93 BT |
3762 | { "Wacom Intuos 4x5", 12700, 10600, 1023, 31, |
3763 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
e87a344d | 3764 | static const struct wacom_features wacom_features_0x21 = |
80befa93 BT |
3765 | { "Wacom Intuos 6x8", 20320, 16240, 1023, 31, |
3766 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
e87a344d | 3767 | static const struct wacom_features wacom_features_0x22 = |
80befa93 BT |
3768 | { "Wacom Intuos 9x12", 30480, 24060, 1023, 31, |
3769 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
e87a344d | 3770 | static const struct wacom_features wacom_features_0x23 = |
80befa93 BT |
3771 | { "Wacom Intuos 12x12", 30480, 31680, 1023, 31, |
3772 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
e87a344d | 3773 | static const struct wacom_features wacom_features_0x24 = |
80befa93 BT |
3774 | { "Wacom Intuos 12x18", 45720, 31680, 1023, 31, |
3775 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
e87a344d | 3776 | static const struct wacom_features wacom_features_0x30 = |
80befa93 BT |
3777 | { "Wacom PL400", 5408, 4056, 255, 0, |
3778 | PL, WACOM_PL_RES, WACOM_PL_RES }; | |
e87a344d | 3779 | static const struct wacom_features wacom_features_0x31 = |
80befa93 BT |
3780 | { "Wacom PL500", 6144, 4608, 255, 0, |
3781 | PL, WACOM_PL_RES, WACOM_PL_RES }; | |
e87a344d | 3782 | static const struct wacom_features wacom_features_0x32 = |
80befa93 BT |
3783 | { "Wacom PL600", 6126, 4604, 255, 0, |
3784 | PL, WACOM_PL_RES, WACOM_PL_RES }; | |
e87a344d | 3785 | static const struct wacom_features wacom_features_0x33 = |
80befa93 BT |
3786 | { "Wacom PL600SX", 6260, 5016, 255, 0, |
3787 | PL, WACOM_PL_RES, WACOM_PL_RES }; | |
e87a344d | 3788 | static const struct wacom_features wacom_features_0x34 = |
80befa93 BT |
3789 | { "Wacom PL550", 6144, 4608, 511, 0, |
3790 | PL, WACOM_PL_RES, WACOM_PL_RES }; | |
e87a344d | 3791 | static const struct wacom_features wacom_features_0x35 = |
80befa93 BT |
3792 | { "Wacom PL800", 7220, 5780, 511, 0, |
3793 | PL, WACOM_PL_RES, WACOM_PL_RES }; | |
e87a344d | 3794 | static const struct wacom_features wacom_features_0x37 = |
80befa93 BT |
3795 | { "Wacom PL700", 6758, 5406, 511, 0, |
3796 | PL, WACOM_PL_RES, WACOM_PL_RES }; | |
e87a344d | 3797 | static const struct wacom_features wacom_features_0x38 = |
80befa93 BT |
3798 | { "Wacom PL510", 6282, 4762, 511, 0, |
3799 | PL, WACOM_PL_RES, WACOM_PL_RES }; | |
e87a344d | 3800 | static const struct wacom_features wacom_features_0x39 = |
80befa93 BT |
3801 | { "Wacom DTU710", 34080, 27660, 511, 0, |
3802 | PL, WACOM_PL_RES, WACOM_PL_RES }; | |
e87a344d | 3803 | static const struct wacom_features wacom_features_0xC4 = |
80befa93 BT |
3804 | { "Wacom DTF521", 6282, 4762, 511, 0, |
3805 | PL, WACOM_PL_RES, WACOM_PL_RES }; | |
e87a344d | 3806 | static const struct wacom_features wacom_features_0xC0 = |
80befa93 BT |
3807 | { "Wacom DTF720", 6858, 5506, 511, 0, |
3808 | PL, WACOM_PL_RES, WACOM_PL_RES }; | |
e87a344d | 3809 | static const struct wacom_features wacom_features_0xC2 = |
80befa93 BT |
3810 | { "Wacom DTF720a", 6858, 5506, 511, 0, |
3811 | PL, WACOM_PL_RES, WACOM_PL_RES }; | |
e87a344d | 3812 | static const struct wacom_features wacom_features_0x03 = |
80befa93 BT |
3813 | { "Wacom Cintiq Partner", 20480, 15360, 511, 0, |
3814 | PTU, WACOM_PL_RES, WACOM_PL_RES }; | |
e87a344d | 3815 | static const struct wacom_features wacom_features_0x41 = |
80befa93 BT |
3816 | { "Wacom Intuos2 4x5", 12700, 10600, 1023, 31, |
3817 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
e87a344d | 3818 | static const struct wacom_features wacom_features_0x42 = |
80befa93 BT |
3819 | { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31, |
3820 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
e87a344d | 3821 | static const struct wacom_features wacom_features_0x43 = |
80befa93 BT |
3822 | { "Wacom Intuos2 9x12", 30480, 24060, 1023, 31, |
3823 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
e87a344d | 3824 | static const struct wacom_features wacom_features_0x44 = |
80befa93 BT |
3825 | { "Wacom Intuos2 12x12", 30480, 31680, 1023, 31, |
3826 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
e87a344d | 3827 | static const struct wacom_features wacom_features_0x45 = |
80befa93 BT |
3828 | { "Wacom Intuos2 12x18", 45720, 31680, 1023, 31, |
3829 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
e87a344d | 3830 | static const struct wacom_features wacom_features_0xB0 = |
80befa93 | 3831 | { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63, |
70ee06c5 | 3832 | INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 }; |
e87a344d | 3833 | static const struct wacom_features wacom_features_0xB1 = |
80befa93 | 3834 | { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63, |
70ee06c5 | 3835 | INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 }; |
e87a344d | 3836 | static const struct wacom_features wacom_features_0xB2 = |
80befa93 | 3837 | { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63, |
70ee06c5 | 3838 | INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 }; |
e87a344d | 3839 | static const struct wacom_features wacom_features_0xB3 = |
80befa93 | 3840 | { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63, |
70ee06c5 | 3841 | INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 }; |
e87a344d | 3842 | static const struct wacom_features wacom_features_0xB4 = |
80befa93 | 3843 | { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63, |
70ee06c5 | 3844 | INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 }; |
e87a344d | 3845 | static const struct wacom_features wacom_features_0xB5 = |
80befa93 | 3846 | { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63, |
70ee06c5 | 3847 | INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 }; |
e87a344d | 3848 | static const struct wacom_features wacom_features_0xB7 = |
80befa93 | 3849 | { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63, |
70ee06c5 | 3850 | INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 }; |
e87a344d | 3851 | static const struct wacom_features wacom_features_0xB8 = |
80befa93 | 3852 | { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63, |
70ee06c5 | 3853 | INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 }; |
e87a344d | 3854 | static const struct wacom_features wacom_features_0xB9 = |
80befa93 | 3855 | { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63, |
70ee06c5 | 3856 | INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 }; |
e87a344d | 3857 | static const struct wacom_features wacom_features_0xBA = |
80befa93 | 3858 | { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63, |
70ee06c5 | 3859 | INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 }; |
e87a344d | 3860 | static const struct wacom_features wacom_features_0xBB = |
80befa93 | 3861 | { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63, |
70ee06c5 | 3862 | INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 }; |
3a4b4aaa | 3863 | static const struct wacom_features wacom_features_0xBC = |
80befa93 | 3864 | { "Wacom Intuos4 WL", 40640, 25400, 2047, 63, |
70ee06c5 | 3865 | INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 }; |
81af7e61 BT |
3866 | static const struct wacom_features wacom_features_0xBD = |
3867 | { "Wacom Intuos4 WL", 40640, 25400, 2047, 63, | |
70ee06c5 | 3868 | INTUOS4WL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 }; |
9fee6195 | 3869 | static const struct wacom_features wacom_features_0x26 = |
80befa93 | 3870 | { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63, |
70ee06c5 | 3871 | INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16 }; |
9fee6195 | 3872 | static const struct wacom_features wacom_features_0x27 = |
80befa93 | 3873 | { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63, |
70ee06c5 | 3874 | INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 }; |
9fee6195 | 3875 | static const struct wacom_features wacom_features_0x28 = |
80befa93 | 3876 | { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63, |
70ee06c5 | 3877 | INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 }; |
9fee6195 | 3878 | static const struct wacom_features wacom_features_0x29 = |
80befa93 | 3879 | { "Wacom Intuos5 S", 31496, 19685, 2047, 63, |
70ee06c5 | 3880 | INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 }; |
9fee6195 | 3881 | static const struct wacom_features wacom_features_0x2A = |
80befa93 | 3882 | { "Wacom Intuos5 M", 44704, 27940, 2047, 63, |
70ee06c5 | 3883 | INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 }; |
9a35c411 | 3884 | static const struct wacom_features wacom_features_0x314 = |
80befa93 | 3885 | { "Wacom Intuos Pro S", 31496, 19685, 2047, 63, |
70ee06c5 | 3886 | INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16, |
29b47391 | 3887 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
9a35c411 | 3888 | static const struct wacom_features wacom_features_0x315 = |
80befa93 | 3889 | { "Wacom Intuos Pro M", 44704, 27940, 2047, 63, |
70ee06c5 | 3890 | INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16, |
29b47391 | 3891 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
9a35c411 | 3892 | static const struct wacom_features wacom_features_0x317 = |
80befa93 | 3893 | { "Wacom Intuos Pro L", 65024, 40640, 2047, 63, |
70ee06c5 | 3894 | INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16, |
29b47391 | 3895 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
803296b6 | 3896 | static const struct wacom_features wacom_features_0xF4 = |
e779ef23 | 3897 | { "Wacom Cintiq 24HD", 104480, 65600, 2047, 63, |
70ee06c5 | 3898 | WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16, |
e779ef23 | 3899 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
fa770340 | 3900 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; |
6f4d0382 | 3901 | static const struct wacom_features wacom_features_0xF8 = |
e779ef23 | 3902 | { "Wacom Cintiq 24HD touch", 104480, 65600, 2047, 63, /* Pen */ |
70ee06c5 | 3903 | WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16, |
fa770340 | 3904 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
e779ef23 | 3905 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
3bd1f7e2 | 3906 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 }; |
b1e4279e JG |
3907 | static const struct wacom_features wacom_features_0xF6 = |
3908 | { "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */ | |
29b47391 BT |
3909 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10, |
3910 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; | |
500d4160 | 3911 | static const struct wacom_features wacom_features_0x32A = |
e779ef23 | 3912 | { "Wacom Cintiq 27QHD", 120140, 67920, 2047, 63, |
70ee06c5 | 3913 | WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0, |
e779ef23 | 3914 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
a7e6645e | 3915 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; |
500d4160 | 3916 | static const struct wacom_features wacom_features_0x32B = |
e779ef23 | 3917 | { "Wacom Cintiq 27QHD touch", 120140, 67920, 2047, 63, |
70ee06c5 | 3918 | WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0, |
500d4160 | 3919 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
e779ef23 | 3920 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
500d4160 PC |
3921 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32C }; |
3922 | static const struct wacom_features wacom_features_0x32C = | |
3923 | { "Wacom Cintiq 27QHD touch", .type = WACOM_27QHDT, | |
3924 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32B, .touch_max = 10 }; | |
e87a344d | 3925 | static const struct wacom_features wacom_features_0x3F = |
80befa93 | 3926 | { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63, |
70ee06c5 | 3927 | CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 }; |
e87a344d | 3928 | static const struct wacom_features wacom_features_0xC5 = |
80befa93 | 3929 | { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63, |
70ee06c5 | 3930 | WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 }; |
e87a344d | 3931 | static const struct wacom_features wacom_features_0xC6 = |
80befa93 | 3932 | { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63, |
70ee06c5 | 3933 | WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 }; |
56218563 | 3934 | static const struct wacom_features wacom_features_0x304 = |
e779ef23 | 3935 | { "Wacom Cintiq 13HD", 59552, 33848, 1023, 63, |
70ee06c5 | 3936 | WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, |
e779ef23 | 3937 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
fa770340 | 3938 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; |
b4bf2120 | 3939 | static const struct wacom_features wacom_features_0x333 = |
e779ef23 | 3940 | { "Wacom Cintiq 13HD touch", 59552, 33848, 2047, 63, |
70ee06c5 | 3941 | WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, |
b4bf2120 | 3942 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
e779ef23 | 3943 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
b4bf2120 PC |
3944 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x335 }; |
3945 | static const struct wacom_features wacom_features_0x335 = | |
3946 | { "Wacom Cintiq 13HD touch", .type = WACOM_24HDT, /* Touch */ | |
3947 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x333, .touch_max = 10, | |
3948 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; | |
e87a344d | 3949 | static const struct wacom_features wacom_features_0xC7 = |
80befa93 BT |
3950 | { "Wacom DTU1931", 37832, 30305, 511, 0, |
3951 | PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
c8f2edc5 | 3952 | static const struct wacom_features wacom_features_0xCE = |
80befa93 BT |
3953 | { "Wacom DTU2231", 47864, 27011, 511, 0, |
3954 | DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES, | |
29b47391 | 3955 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBMOUSE }; |
c8f2edc5 | 3956 | static const struct wacom_features wacom_features_0xF0 = |
80befa93 BT |
3957 | { "Wacom DTU1631", 34623, 19553, 511, 0, |
3958 | DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
497ab1f2 | 3959 | static const struct wacom_features wacom_features_0xFB = |
e779ef23 | 3960 | { "Wacom DTU1031", 22096, 13960, 511, 0, |
70ee06c5 | 3961 | DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4, |
e779ef23 | 3962 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET, |
fa770340 | 3963 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET }; |
fff00bf8 | 3964 | static const struct wacom_features wacom_features_0x32F = |
e779ef23 | 3965 | { "Wacom DTU1031X", 22672, 12928, 511, 0, |
70ee06c5 | 3966 | DTUSX, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 0, |
e779ef23 | 3967 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET, |
fff00bf8 | 3968 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET }; |
007760cf | 3969 | static const struct wacom_features wacom_features_0x336 = |
e779ef23 | 3970 | { "Wacom DTU1141", 23672, 13403, 1023, 0, |
ff38e829 | 3971 | DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4, |
e779ef23 | 3972 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET, |
ff38e829 | 3973 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET }; |
56218563 | 3974 | static const struct wacom_features wacom_features_0x57 = |
e779ef23 | 3975 | { "Wacom DTK2241", 95840, 54260, 2047, 63, |
70ee06c5 | 3976 | DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6, |
e779ef23 | 3977 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
fa770340 | 3978 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; |
a112e9fd | 3979 | static const struct wacom_features wacom_features_0x59 = /* Pen */ |
e779ef23 | 3980 | { "Wacom DTH2242", 95840, 54260, 2047, 63, |
70ee06c5 | 3981 | DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6, |
fa770340 | 3982 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
e779ef23 | 3983 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
a112e9fd PC |
3984 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D }; |
3985 | static const struct wacom_features wacom_features_0x5D = /* Touch */ | |
3986 | { "Wacom DTH2242", .type = WACOM_24HDT, | |
29b47391 BT |
3987 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10, |
3988 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; | |
3a4b4aaa | 3989 | static const struct wacom_features wacom_features_0xCC = |
e779ef23 | 3990 | { "Wacom Cintiq 21UX2", 87200, 65600, 2047, 63, |
70ee06c5 | 3991 | WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18, |
e779ef23 | 3992 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
fa770340 | 3993 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; |
d838c644 | 3994 | static const struct wacom_features wacom_features_0xFA = |
e779ef23 | 3995 | { "Wacom Cintiq 22HD", 95840, 54260, 2047, 63, |
70ee06c5 | 3996 | WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18, |
e779ef23 | 3997 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
fa770340 | 3998 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; |
56218563 | 3999 | static const struct wacom_features wacom_features_0x5B = |
e779ef23 | 4000 | { "Wacom Cintiq 22HDT", 95840, 54260, 2047, 63, |
70ee06c5 | 4001 | WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18, |
fa770340 | 4002 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
e779ef23 | 4003 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
3bd1f7e2 | 4004 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e }; |
56218563 PC |
4005 | static const struct wacom_features wacom_features_0x5E = |
4006 | { "Wacom Cintiq 22HDT", .type = WACOM_24HDT, | |
29b47391 BT |
4007 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5b, .touch_max = 10, |
4008 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; | |
e87a344d | 4009 | static const struct wacom_features wacom_features_0x90 = |
80befa93 BT |
4010 | { "Wacom ISDv4 90", 26202, 16325, 255, 0, |
4011 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
e87a344d | 4012 | static const struct wacom_features wacom_features_0x93 = |
80befa93 BT |
4013 | { "Wacom ISDv4 93", 26202, 16325, 255, 0, |
4014 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
11d0cf88 | 4015 | static const struct wacom_features wacom_features_0x97 = |
80befa93 BT |
4016 | { "Wacom ISDv4 97", 26202, 16325, 511, 0, |
4017 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
e87a344d | 4018 | static const struct wacom_features wacom_features_0x9A = |
80befa93 BT |
4019 | { "Wacom ISDv4 9A", 26202, 16325, 255, 0, |
4020 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
e87a344d | 4021 | static const struct wacom_features wacom_features_0x9F = |
80befa93 BT |
4022 | { "Wacom ISDv4 9F", 26202, 16325, 255, 0, |
4023 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
e87a344d | 4024 | static const struct wacom_features wacom_features_0xE2 = |
80befa93 BT |
4025 | { "Wacom ISDv4 E2", 26202, 16325, 255, 0, |
4026 | TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; | |
e87a344d | 4027 | static const struct wacom_features wacom_features_0xE3 = |
80befa93 BT |
4028 | { "Wacom ISDv4 E3", 26202, 16325, 255, 0, |
4029 | TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; | |
1963518b | 4030 | static const struct wacom_features wacom_features_0xE5 = |
80befa93 BT |
4031 | { "Wacom ISDv4 E5", 26202, 16325, 255, 0, |
4032 | MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
26fcd2a7 | 4033 | static const struct wacom_features wacom_features_0xE6 = |
80befa93 BT |
4034 | { "Wacom ISDv4 E6", 27760, 15694, 255, 0, |
4035 | TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; | |
0d0e3064 | 4036 | static const struct wacom_features wacom_features_0xEC = |
80befa93 BT |
4037 | { "Wacom ISDv4 EC", 25710, 14500, 255, 0, |
4038 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
ac173837 | 4039 | static const struct wacom_features wacom_features_0xED = |
80befa93 BT |
4040 | { "Wacom ISDv4 ED", 26202, 16325, 255, 0, |
4041 | TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
ac173837 | 4042 | static const struct wacom_features wacom_features_0xEF = |
80befa93 BT |
4043 | { "Wacom ISDv4 EF", 26202, 16325, 255, 0, |
4044 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
6afdc289 | 4045 | static const struct wacom_features wacom_features_0x100 = |
80befa93 BT |
4046 | { "Wacom ISDv4 100", 26202, 16325, 255, 0, |
4047 | MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
6afdc289 | 4048 | static const struct wacom_features wacom_features_0x101 = |
80befa93 BT |
4049 | { "Wacom ISDv4 101", 26202, 16325, 255, 0, |
4050 | MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
58694837 | 4051 | static const struct wacom_features wacom_features_0x10D = |
80befa93 BT |
4052 | { "Wacom ISDv4 10D", 26202, 16325, 255, 0, |
4053 | MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
2d3163f1 | 4054 | static const struct wacom_features wacom_features_0x10E = |
80befa93 BT |
4055 | { "Wacom ISDv4 10E", 27760, 15694, 255, 0, |
4056 | MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
9b4f60e5 | 4057 | static const struct wacom_features wacom_features_0x10F = |
80befa93 BT |
4058 | { "Wacom ISDv4 10F", 27760, 15694, 255, 0, |
4059 | MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
61616ed0 | 4060 | static const struct wacom_features wacom_features_0x116 = |
80befa93 BT |
4061 | { "Wacom ISDv4 116", 26202, 16325, 255, 0, |
4062 | TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
aeaf50d4 JG |
4063 | static const struct wacom_features wacom_features_0x12C = |
4064 | { "Wacom ISDv4 12C", 27848, 15752, 2047, 0, | |
4065 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
edbe265d | 4066 | static const struct wacom_features wacom_features_0x4001 = |
80befa93 BT |
4067 | { "Wacom ISDv4 4001", 26202, 16325, 255, 0, |
4068 | MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
d51ddb2b | 4069 | static const struct wacom_features wacom_features_0x4004 = |
80befa93 BT |
4070 | { "Wacom ISDv4 4004", 11060, 6220, 255, 0, |
4071 | MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
d51ddb2b | 4072 | static const struct wacom_features wacom_features_0x5000 = |
80befa93 BT |
4073 | { "Wacom ISDv4 5000", 27848, 15752, 1023, 0, |
4074 | MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
d51ddb2b | 4075 | static const struct wacom_features wacom_features_0x5002 = |
80befa93 BT |
4076 | { "Wacom ISDv4 5002", 29576, 16724, 1023, 0, |
4077 | MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
e87a344d | 4078 | static const struct wacom_features wacom_features_0x47 = |
80befa93 BT |
4079 | { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31, |
4080 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
d3825d51 | 4081 | static const struct wacom_features wacom_features_0x84 = |
3b164a00 | 4082 | { "Wacom Wireless Receiver", .type = WIRELESS, .touch_max = 16 }; |
7b824bbd | 4083 | static const struct wacom_features wacom_features_0xD0 = |
80befa93 | 4084 | { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31, |
3b164a00 | 4085 | BAMBOO_TOUCH, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
7b824bbd | 4086 | static const struct wacom_features wacom_features_0xD1 = |
80befa93 BT |
4087 | { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31, |
4088 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; | |
7b824bbd | 4089 | static const struct wacom_features wacom_features_0xD2 = |
80befa93 BT |
4090 | { "Wacom Bamboo Craft", 14720, 9200, 1023, 31, |
4091 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; | |
7b824bbd | 4092 | static const struct wacom_features wacom_features_0xD3 = |
80befa93 BT |
4093 | { "Wacom Bamboo 2FG 6x8", 21648, 13700, 1023, 31, |
4094 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; | |
57a7872f | 4095 | static const struct wacom_features wacom_features_0xD4 = |
80befa93 | 4096 | { "Wacom Bamboo Pen", 14720, 9200, 1023, 31, |
3b164a00 | 4097 | BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
18adad1c | 4098 | static const struct wacom_features wacom_features_0xD5 = |
80befa93 | 4099 | { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31, |
3b164a00 | 4100 | BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
7b824bbd | 4101 | static const struct wacom_features wacom_features_0xD6 = |
80befa93 BT |
4102 | { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31, |
4103 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; | |
7b824bbd | 4104 | static const struct wacom_features wacom_features_0xD7 = |
80befa93 BT |
4105 | { "Wacom BambooPT 2FG Small", 14720, 9200, 1023, 31, |
4106 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; | |
7b824bbd | 4107 | static const struct wacom_features wacom_features_0xD8 = |
80befa93 BT |
4108 | { "Wacom Bamboo Comic 2FG", 21648, 13700, 1023, 31, |
4109 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; | |
7b824bbd | 4110 | static const struct wacom_features wacom_features_0xDA = |
80befa93 BT |
4111 | { "Wacom Bamboo 2FG 4x5 SE", 14720, 9200, 1023, 31, |
4112 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; | |
f41a64ee | 4113 | static const struct wacom_features wacom_features_0xDB = |
80befa93 BT |
4114 | { "Wacom Bamboo 2FG 6x8 SE", 21648, 13700, 1023, 31, |
4115 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; | |
73149ab8 | 4116 | static const struct wacom_features wacom_features_0xDD = |
80befa93 BT |
4117 | { "Wacom Bamboo Connect", 14720, 9200, 1023, 31, |
4118 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
73149ab8 | 4119 | static const struct wacom_features wacom_features_0xDE = |
80befa93 BT |
4120 | { "Wacom Bamboo 16FG 4x5", 14720, 9200, 1023, 31, |
4121 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 }; | |
73149ab8 | 4122 | static const struct wacom_features wacom_features_0xDF = |
80befa93 BT |
4123 | { "Wacom Bamboo 16FG 6x8", 21648, 13700, 1023, 31, |
4124 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 }; | |
f41a64ee | 4125 | static const struct wacom_features wacom_features_0x300 = |
80befa93 | 4126 | { "Wacom Bamboo One S", 14720, 9225, 1023, 31, |
3b164a00 | 4127 | BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
f41a64ee | 4128 | static const struct wacom_features wacom_features_0x301 = |
80befa93 BT |
4129 | { "Wacom Bamboo One M", 21648, 13530, 1023, 31, |
4130 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
b5fd2a3e | 4131 | static const struct wacom_features wacom_features_0x302 = |
80befa93 BT |
4132 | { "Wacom Intuos PT S", 15200, 9500, 1023, 31, |
4133 | INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16, | |
29b47391 | 4134 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
b5fd2a3e | 4135 | static const struct wacom_features wacom_features_0x303 = |
80befa93 BT |
4136 | { "Wacom Intuos PT M", 21600, 13500, 1023, 31, |
4137 | INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16, | |
29b47391 | 4138 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
b5fd2a3e | 4139 | static const struct wacom_features wacom_features_0x30E = |
80befa93 BT |
4140 | { "Wacom Intuos S", 15200, 9500, 1023, 31, |
4141 | INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, | |
29b47391 | 4142 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
7b4b3068 | 4143 | static const struct wacom_features wacom_features_0x6004 = |
80befa93 BT |
4144 | { "ISD-V4", 12800, 8000, 255, 0, |
4145 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; | |
a3e6f654 | 4146 | static const struct wacom_features wacom_features_0x307 = |
e779ef23 | 4147 | { "Wacom ISDv5 307", 59552, 33848, 2047, 63, |
70ee06c5 | 4148 | CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, |
fa770340 | 4149 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
e779ef23 | 4150 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
36d3c510 | 4151 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 }; |
a3e6f654 | 4152 | static const struct wacom_features wacom_features_0x309 = |
36d3c510 | 4153 | { "Wacom ISDv5 309", .type = WACOM_24HDT, /* Touch */ |
29b47391 BT |
4154 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x0307, .touch_max = 10, |
4155 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; | |
89f2ab55 | 4156 | static const struct wacom_features wacom_features_0x30A = |
e779ef23 | 4157 | { "Wacom ISDv5 30A", 59552, 33848, 2047, 63, |
70ee06c5 | 4158 | CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, |
fa770340 | 4159 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
e779ef23 | 4160 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
89f2ab55 BT |
4161 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30C }; |
4162 | static const struct wacom_features wacom_features_0x30C = | |
4163 | { "Wacom ISDv5 30C", .type = WACOM_24HDT, /* Touch */ | |
4164 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30A, .touch_max = 10, | |
4165 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; | |
8c97a765 BT |
4166 | static const struct wacom_features wacom_features_0x318 = |
4167 | { "Wacom USB Bamboo PAD", 4095, 4095, /* Touch */ | |
4168 | .type = BAMBOO_PAD, 35, 48, .touch_max = 4 }; | |
4169 | static const struct wacom_features wacom_features_0x319 = | |
4170 | { "Wacom Wireless Bamboo PAD", 4095, 4095, /* Touch */ | |
4171 | .type = BAMBOO_PAD, 35, 48, .touch_max = 4 }; | |
f7acb55c JG |
4172 | static const struct wacom_features wacom_features_0x325 = |
4173 | { "Wacom ISDv5 325", 59552, 33848, 2047, 63, | |
4174 | CINTIQ_COMPANION_2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 11, | |
4175 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, | |
e779ef23 | 4176 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
f7acb55c JG |
4177 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x326 }; |
4178 | static const struct wacom_features wacom_features_0x326 = /* Touch */ | |
4179 | { "Wacom ISDv5 326", .type = HID_GENERIC, .oVid = USB_VENDOR_ID_WACOM, | |
4180 | .oPid = 0x325 }; | |
fefb391f PC |
4181 | static const struct wacom_features wacom_features_0x323 = |
4182 | { "Wacom Intuos P M", 21600, 13500, 1023, 31, | |
4183 | INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, | |
4184 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; | |
72b236d6 | 4185 | static const struct wacom_features wacom_features_0x331 = |
3b164a00 PC |
4186 | { "Wacom Express Key Remote", .type = REMOTE, |
4187 | .numbered_buttons = 18, .check_for_hid_type = true, | |
72b236d6 | 4188 | .hid_type = HID_TYPE_USBNONE }; |
eda01dab PC |
4189 | static const struct wacom_features wacom_features_0x33B = |
4190 | { "Wacom Intuos S 2", 15200, 9500, 2047, 63, | |
4191 | INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, | |
4192 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; | |
4193 | static const struct wacom_features wacom_features_0x33C = | |
4194 | { "Wacom Intuos PT S 2", 15200, 9500, 2047, 63, | |
4195 | INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16, | |
4196 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; | |
4197 | static const struct wacom_features wacom_features_0x33D = | |
4198 | { "Wacom Intuos P M 2", 21600, 13500, 2047, 63, | |
4199 | INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, | |
4200 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; | |
4201 | static const struct wacom_features wacom_features_0x33E = | |
4202 | { "Wacom Intuos PT M 2", 21600, 13500, 2047, 63, | |
4203 | INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16, | |
4204 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; | |
e1123fe9 | 4205 | static const struct wacom_features wacom_features_0x343 = |
e779ef23 | 4206 | { "Wacom DTK1651", 34816, 19759, 1023, 0, |
e1123fe9 | 4207 | DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4, |
e779ef23 | 4208 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET, |
e1123fe9 | 4209 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET }; |
4922cd26 JG |
4210 | static const struct wacom_features wacom_features_0x360 = |
4211 | { "Wacom Intuos Pro M", 44800, 29600, 8191, 63, | |
4212 | INTUOSP2_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 9, .touch_max = 10 }; | |
4213 | static const struct wacom_features wacom_features_0x361 = | |
4214 | { "Wacom Intuos Pro L", 62200, 43200, 8191, 63, | |
4215 | INTUOSP2_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 9, .touch_max = 10 }; | |
b036f6fb | 4216 | |
7704ac93 | 4217 | static const struct wacom_features wacom_features_HID_ANY_ID = |
41372d5d | 4218 | { "Wacom HID", .type = HID_GENERIC, .oVid = HID_ANY_ID, .oPid = HID_ANY_ID }; |
7704ac93 | 4219 | |
29b47391 BT |
4220 | #define USB_DEVICE_WACOM(prod) \ |
4221 | HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\ | |
4222 | .driver_data = (kernel_ulong_t)&wacom_features_##prod | |
b036f6fb | 4223 | |
387142bb BT |
4224 | #define BT_DEVICE_WACOM(prod) \ |
4225 | HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\ | |
4226 | .driver_data = (kernel_ulong_t)&wacom_features_##prod | |
1483f551 | 4227 | |
eef23a84 MW |
4228 | #define I2C_DEVICE_WACOM(prod) \ |
4229 | HID_DEVICE(BUS_I2C, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\ | |
4230 | .driver_data = (kernel_ulong_t)&wacom_features_##prod | |
4231 | ||
7b4b3068 | 4232 | #define USB_DEVICE_LENOVO(prod) \ |
29b47391 BT |
4233 | HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \ |
4234 | .driver_data = (kernel_ulong_t)&wacom_features_##prod | |
7b4b3068 | 4235 | |
29b47391 | 4236 | const struct hid_device_id wacom_ids[] = { |
b036f6fb | 4237 | { USB_DEVICE_WACOM(0x00) }, |
a3e6f654 | 4238 | { USB_DEVICE_WACOM(0x03) }, |
b036f6fb BB |
4239 | { USB_DEVICE_WACOM(0x10) }, |
4240 | { USB_DEVICE_WACOM(0x11) }, | |
4241 | { USB_DEVICE_WACOM(0x12) }, | |
4242 | { USB_DEVICE_WACOM(0x13) }, | |
4243 | { USB_DEVICE_WACOM(0x14) }, | |
4244 | { USB_DEVICE_WACOM(0x15) }, | |
4245 | { USB_DEVICE_WACOM(0x16) }, | |
4246 | { USB_DEVICE_WACOM(0x17) }, | |
4247 | { USB_DEVICE_WACOM(0x18) }, | |
4248 | { USB_DEVICE_WACOM(0x19) }, | |
b036f6fb BB |
4249 | { USB_DEVICE_WACOM(0x20) }, |
4250 | { USB_DEVICE_WACOM(0x21) }, | |
4251 | { USB_DEVICE_WACOM(0x22) }, | |
4252 | { USB_DEVICE_WACOM(0x23) }, | |
4253 | { USB_DEVICE_WACOM(0x24) }, | |
a3e6f654 BT |
4254 | { USB_DEVICE_WACOM(0x26) }, |
4255 | { USB_DEVICE_WACOM(0x27) }, | |
4256 | { USB_DEVICE_WACOM(0x28) }, | |
4257 | { USB_DEVICE_WACOM(0x29) }, | |
4258 | { USB_DEVICE_WACOM(0x2A) }, | |
b036f6fb BB |
4259 | { USB_DEVICE_WACOM(0x30) }, |
4260 | { USB_DEVICE_WACOM(0x31) }, | |
4261 | { USB_DEVICE_WACOM(0x32) }, | |
4262 | { USB_DEVICE_WACOM(0x33) }, | |
4263 | { USB_DEVICE_WACOM(0x34) }, | |
4264 | { USB_DEVICE_WACOM(0x35) }, | |
4265 | { USB_DEVICE_WACOM(0x37) }, | |
4266 | { USB_DEVICE_WACOM(0x38) }, | |
4267 | { USB_DEVICE_WACOM(0x39) }, | |
a3e6f654 | 4268 | { USB_DEVICE_WACOM(0x3F) }, |
b036f6fb BB |
4269 | { USB_DEVICE_WACOM(0x41) }, |
4270 | { USB_DEVICE_WACOM(0x42) }, | |
4271 | { USB_DEVICE_WACOM(0x43) }, | |
4272 | { USB_DEVICE_WACOM(0x44) }, | |
4273 | { USB_DEVICE_WACOM(0x45) }, | |
a3e6f654 | 4274 | { USB_DEVICE_WACOM(0x47) }, |
56218563 | 4275 | { USB_DEVICE_WACOM(0x57) }, |
a112e9fd | 4276 | { USB_DEVICE_WACOM(0x59) }, |
56218563 | 4277 | { USB_DEVICE_WACOM(0x5B) }, |
a3e6f654 | 4278 | { USB_DEVICE_WACOM(0x5D) }, |
29b47391 | 4279 | { USB_DEVICE_WACOM(0x5E) }, |
a3e6f654 BT |
4280 | { USB_DEVICE_WACOM(0x60) }, |
4281 | { USB_DEVICE_WACOM(0x61) }, | |
4282 | { USB_DEVICE_WACOM(0x62) }, | |
4283 | { USB_DEVICE_WACOM(0x63) }, | |
4284 | { USB_DEVICE_WACOM(0x64) }, | |
4285 | { USB_DEVICE_WACOM(0x65) }, | |
4286 | { USB_DEVICE_WACOM(0x69) }, | |
4287 | { USB_DEVICE_WACOM(0x6A) }, | |
4288 | { USB_DEVICE_WACOM(0x6B) }, | |
387142bb | 4289 | { BT_DEVICE_WACOM(0x81) }, |
a3e6f654 BT |
4290 | { USB_DEVICE_WACOM(0x84) }, |
4291 | { USB_DEVICE_WACOM(0x90) }, | |
4292 | { USB_DEVICE_WACOM(0x93) }, | |
4293 | { USB_DEVICE_WACOM(0x97) }, | |
4294 | { USB_DEVICE_WACOM(0x9A) }, | |
4295 | { USB_DEVICE_WACOM(0x9F) }, | |
b036f6fb BB |
4296 | { USB_DEVICE_WACOM(0xB0) }, |
4297 | { USB_DEVICE_WACOM(0xB1) }, | |
4298 | { USB_DEVICE_WACOM(0xB2) }, | |
4299 | { USB_DEVICE_WACOM(0xB3) }, | |
4300 | { USB_DEVICE_WACOM(0xB4) }, | |
4301 | { USB_DEVICE_WACOM(0xB5) }, | |
4302 | { USB_DEVICE_WACOM(0xB7) }, | |
4303 | { USB_DEVICE_WACOM(0xB8) }, | |
4304 | { USB_DEVICE_WACOM(0xB9) }, | |
4305 | { USB_DEVICE_WACOM(0xBA) }, | |
4306 | { USB_DEVICE_WACOM(0xBB) }, | |
3a4b4aaa | 4307 | { USB_DEVICE_WACOM(0xBC) }, |
81af7e61 | 4308 | { BT_DEVICE_WACOM(0xBD) }, |
a3e6f654 BT |
4309 | { USB_DEVICE_WACOM(0xC0) }, |
4310 | { USB_DEVICE_WACOM(0xC2) }, | |
4311 | { USB_DEVICE_WACOM(0xC4) }, | |
b036f6fb BB |
4312 | { USB_DEVICE_WACOM(0xC5) }, |
4313 | { USB_DEVICE_WACOM(0xC6) }, | |
4314 | { USB_DEVICE_WACOM(0xC7) }, | |
a3e6f654 | 4315 | { USB_DEVICE_WACOM(0xCC) }, |
29b47391 | 4316 | { USB_DEVICE_WACOM(0xCE) }, |
cb734c03 | 4317 | { USB_DEVICE_WACOM(0xD0) }, |
2aaacb15 CB |
4318 | { USB_DEVICE_WACOM(0xD1) }, |
4319 | { USB_DEVICE_WACOM(0xD2) }, | |
4320 | { USB_DEVICE_WACOM(0xD3) }, | |
57a7872f | 4321 | { USB_DEVICE_WACOM(0xD4) }, |
18adad1c | 4322 | { USB_DEVICE_WACOM(0xD5) }, |
d38acb49 PC |
4323 | { USB_DEVICE_WACOM(0xD6) }, |
4324 | { USB_DEVICE_WACOM(0xD7) }, | |
a318e6b1 DF |
4325 | { USB_DEVICE_WACOM(0xD8) }, |
4326 | { USB_DEVICE_WACOM(0xDA) }, | |
47d09235 | 4327 | { USB_DEVICE_WACOM(0xDB) }, |
73149ab8 CB |
4328 | { USB_DEVICE_WACOM(0xDD) }, |
4329 | { USB_DEVICE_WACOM(0xDE) }, | |
4330 | { USB_DEVICE_WACOM(0xDF) }, | |
b036f6fb BB |
4331 | { USB_DEVICE_WACOM(0xE2) }, |
4332 | { USB_DEVICE_WACOM(0xE3) }, | |
1963518b | 4333 | { USB_DEVICE_WACOM(0xE5) }, |
26fcd2a7 | 4334 | { USB_DEVICE_WACOM(0xE6) }, |
0d0e3064 | 4335 | { USB_DEVICE_WACOM(0xEC) }, |
ac173837 PC |
4336 | { USB_DEVICE_WACOM(0xED) }, |
4337 | { USB_DEVICE_WACOM(0xEF) }, | |
a3e6f654 BT |
4338 | { USB_DEVICE_WACOM(0xF0) }, |
4339 | { USB_DEVICE_WACOM(0xF4) }, | |
4340 | { USB_DEVICE_WACOM(0xF6) }, | |
4341 | { USB_DEVICE_WACOM(0xF8) }, | |
4342 | { USB_DEVICE_WACOM(0xFA) }, | |
4343 | { USB_DEVICE_WACOM(0xFB) }, | |
6afdc289 PC |
4344 | { USB_DEVICE_WACOM(0x100) }, |
4345 | { USB_DEVICE_WACOM(0x101) }, | |
58694837 | 4346 | { USB_DEVICE_WACOM(0x10D) }, |
2d3163f1 | 4347 | { USB_DEVICE_WACOM(0x10E) }, |
9b4f60e5 | 4348 | { USB_DEVICE_WACOM(0x10F) }, |
61616ed0 | 4349 | { USB_DEVICE_WACOM(0x116) }, |
aeaf50d4 | 4350 | { USB_DEVICE_WACOM(0x12C) }, |
f41a64ee PC |
4351 | { USB_DEVICE_WACOM(0x300) }, |
4352 | { USB_DEVICE_WACOM(0x301) }, | |
29b47391 BT |
4353 | { USB_DEVICE_WACOM(0x302) }, |
4354 | { USB_DEVICE_WACOM(0x303) }, | |
56218563 | 4355 | { USB_DEVICE_WACOM(0x304) }, |
a3e6f654 BT |
4356 | { USB_DEVICE_WACOM(0x307) }, |
4357 | { USB_DEVICE_WACOM(0x309) }, | |
89f2ab55 BT |
4358 | { USB_DEVICE_WACOM(0x30A) }, |
4359 | { USB_DEVICE_WACOM(0x30C) }, | |
a3e6f654 | 4360 | { USB_DEVICE_WACOM(0x30E) }, |
29b47391 BT |
4361 | { USB_DEVICE_WACOM(0x314) }, |
4362 | { USB_DEVICE_WACOM(0x315) }, | |
4363 | { USB_DEVICE_WACOM(0x317) }, | |
8c97a765 BT |
4364 | { USB_DEVICE_WACOM(0x318) }, |
4365 | { USB_DEVICE_WACOM(0x319) }, | |
fefb391f | 4366 | { USB_DEVICE_WACOM(0x323) }, |
f7acb55c JG |
4367 | { USB_DEVICE_WACOM(0x325) }, |
4368 | { USB_DEVICE_WACOM(0x326) }, | |
500d4160 PC |
4369 | { USB_DEVICE_WACOM(0x32A) }, |
4370 | { USB_DEVICE_WACOM(0x32B) }, | |
4371 | { USB_DEVICE_WACOM(0x32C) }, | |
fff00bf8 | 4372 | { USB_DEVICE_WACOM(0x32F) }, |
72b236d6 | 4373 | { USB_DEVICE_WACOM(0x331) }, |
b4bf2120 PC |
4374 | { USB_DEVICE_WACOM(0x333) }, |
4375 | { USB_DEVICE_WACOM(0x335) }, | |
007760cf | 4376 | { USB_DEVICE_WACOM(0x336) }, |
eda01dab PC |
4377 | { USB_DEVICE_WACOM(0x33B) }, |
4378 | { USB_DEVICE_WACOM(0x33C) }, | |
4379 | { USB_DEVICE_WACOM(0x33D) }, | |
4380 | { USB_DEVICE_WACOM(0x33E) }, | |
e1123fe9 | 4381 | { USB_DEVICE_WACOM(0x343) }, |
4922cd26 JG |
4382 | { BT_DEVICE_WACOM(0x360) }, |
4383 | { BT_DEVICE_WACOM(0x361) }, | |
edbe265d | 4384 | { USB_DEVICE_WACOM(0x4001) }, |
d51ddb2b JG |
4385 | { USB_DEVICE_WACOM(0x4004) }, |
4386 | { USB_DEVICE_WACOM(0x5000) }, | |
4387 | { USB_DEVICE_WACOM(0x5002) }, | |
00d6f227 | 4388 | { USB_DEVICE_LENOVO(0x6004) }, |
7704ac93 BT |
4389 | |
4390 | { USB_DEVICE_WACOM(HID_ANY_ID) }, | |
eef23a84 | 4391 | { I2C_DEVICE_WACOM(HID_ANY_ID) }, |
b9e06256 | 4392 | { BT_DEVICE_WACOM(HID_ANY_ID) }, |
3bea733a PC |
4393 | { } |
4394 | }; | |
29b47391 | 4395 | MODULE_DEVICE_TABLE(hid, wacom_ids); |