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