diff options
Diffstat (limited to 'drivers/usb/input/wacom_wac.c')
-rw-r--r-- | drivers/usb/input/wacom_wac.c | 646 |
1 files changed, 646 insertions, 0 deletions
diff --git a/drivers/usb/input/wacom_wac.c b/drivers/usb/input/wacom_wac.c new file mode 100644 index 000000000000..85d458c98b6e --- /dev/null +++ b/drivers/usb/input/wacom_wac.c | |||
@@ -0,0 +1,646 @@ | |||
1 | /* | ||
2 | * drivers/usb/input/wacom_wac.c | ||
3 | * | ||
4 | * USB Wacom Graphire and Wacom Intuos tablet support - Wacom specific code | ||
5 | * | ||
6 | */ | ||
7 | |||
8 | /* | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | */ | ||
14 | #include "wacom.h" | ||
15 | #include "wacom_wac.h" | ||
16 | |||
17 | static int wacom_penpartner_irq(struct wacom_wac *wacom, void *wcombo) | ||
18 | { | ||
19 | unsigned char *data = wacom->data; | ||
20 | |||
21 | switch (data[0]) { | ||
22 | case 1: | ||
23 | wacom_input_regs(wcombo); | ||
24 | if (data[5] & 0x80) { | ||
25 | wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN; | ||
26 | wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID; | ||
27 | wacom_report_key(wcombo, wacom->tool[0], 1); | ||
28 | wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); /* report tool id */ | ||
29 | wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[1])); | ||
30 | wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[3])); | ||
31 | wacom_report_abs(wcombo, ABS_PRESSURE, (signed char)data[6] + 127); | ||
32 | wacom_report_key(wcombo, BTN_TOUCH, ((signed char)data[6] > -127)); | ||
33 | wacom_report_key(wcombo, BTN_STYLUS, (data[5] & 0x40)); | ||
34 | } else { | ||
35 | wacom_report_key(wcombo, wacom->tool[0], 0); | ||
36 | wacom_report_abs(wcombo, ABS_MISC, 0); /* report tool id */ | ||
37 | wacom_report_abs(wcombo, ABS_PRESSURE, -1); | ||
38 | wacom_report_key(wcombo, BTN_TOUCH, 0); | ||
39 | } | ||
40 | break; | ||
41 | case 2: | ||
42 | wacom_input_regs(wcombo); | ||
43 | wacom_report_key(wcombo, BTN_TOOL_PEN, 1); | ||
44 | wacom_report_abs(wcombo, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */ | ||
45 | wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[1])); | ||
46 | wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[3])); | ||
47 | wacom_report_abs(wcombo, ABS_PRESSURE, (signed char)data[6] + 127); | ||
48 | wacom_report_key(wcombo, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20)); | ||
49 | wacom_report_key(wcombo, BTN_STYLUS, (data[5] & 0x40)); | ||
50 | break; | ||
51 | default: | ||
52 | printk(KERN_INFO "wacom_penpartner_irq: received unknown report #%d\n", data[0]); | ||
53 | return 0; | ||
54 | } | ||
55 | return 1; | ||
56 | } | ||
57 | |||
58 | static int wacom_pl_irq(struct wacom_wac *wacom, void *wcombo) | ||
59 | { | ||
60 | unsigned char *data = wacom->data; | ||
61 | int prox, id, pressure; | ||
62 | |||
63 | if (data[0] != 2) { | ||
64 | dbg("wacom_pl_irq: received unknown report #%d", data[0]); | ||
65 | return 0; | ||
66 | } | ||
67 | |||
68 | prox = data[1] & 0x40; | ||
69 | |||
70 | wacom_input_regs(wcombo); | ||
71 | |||
72 | id = ERASER_DEVICE_ID; | ||
73 | if (prox) { | ||
74 | |||
75 | pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1)); | ||
76 | if (wacom->features->pressure_max > 255) | ||
77 | pressure = (pressure << 1) | ((data[4] >> 6) & 1); | ||
78 | pressure += (wacom->features->pressure_max + 1) / 2; | ||
79 | |||
80 | /* | ||
81 | * if going from out of proximity into proximity select between the eraser | ||
82 | * and the pen based on the state of the stylus2 button, choose eraser if | ||
83 | * pressed else choose pen. if not a proximity change from out to in, send | ||
84 | * an out of proximity for previous tool then a in for new tool. | ||
85 | */ | ||
86 | if (!wacom->tool[0]) { | ||
87 | /* Eraser bit set for DTF */ | ||
88 | if (data[1] & 0x10) | ||
89 | wacom->tool[1] = BTN_TOOL_RUBBER; | ||
90 | else | ||
91 | /* Going into proximity select tool */ | ||
92 | wacom->tool[1] = (data[4] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN; | ||
93 | } else { | ||
94 | /* was entered with stylus2 pressed */ | ||
95 | if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) { | ||
96 | /* report out proximity for previous tool */ | ||
97 | wacom_report_key(wcombo, wacom->tool[1], 0); | ||
98 | wacom_input_sync(wcombo); | ||
99 | wacom->tool[1] = BTN_TOOL_PEN; | ||
100 | return 0; | ||
101 | } | ||
102 | } | ||
103 | if (wacom->tool[1] != BTN_TOOL_RUBBER) { | ||
104 | /* Unknown tool selected default to pen tool */ | ||
105 | wacom->tool[1] = BTN_TOOL_PEN; | ||
106 | id = STYLUS_DEVICE_ID; | ||
107 | } | ||
108 | wacom_report_key(wcombo, wacom->tool[1], prox); /* report in proximity for tool */ | ||
109 | wacom_report_abs(wcombo, ABS_MISC, id); /* report tool id */ | ||
110 | wacom_report_abs(wcombo, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14)); | ||
111 | wacom_report_abs(wcombo, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14)); | ||
112 | wacom_report_abs(wcombo, ABS_PRESSURE, pressure); | ||
113 | |||
114 | wacom_report_key(wcombo, BTN_TOUCH, data[4] & 0x08); | ||
115 | wacom_report_key(wcombo, BTN_STYLUS, data[4] & 0x10); | ||
116 | /* Only allow the stylus2 button to be reported for the pen tool. */ | ||
117 | wacom_report_key(wcombo, BTN_STYLUS2, (wacom->tool[1] == BTN_TOOL_PEN) && (data[4] & 0x20)); | ||
118 | } else { | ||
119 | /* report proximity-out of a (valid) tool */ | ||
120 | if (wacom->tool[1] != BTN_TOOL_RUBBER) { | ||
121 | /* Unknown tool selected default to pen tool */ | ||
122 | wacom->tool[1] = BTN_TOOL_PEN; | ||
123 | } | ||
124 | wacom_report_key(wcombo, wacom->tool[1], prox); | ||
125 | } | ||
126 | |||
127 | wacom->tool[0] = prox; /* Save proximity state */ | ||
128 | return 1; | ||
129 | } | ||
130 | |||
131 | static int wacom_ptu_irq(struct wacom_wac *wacom, void *wcombo) | ||
132 | { | ||
133 | unsigned char *data = wacom->data; | ||
134 | int id; | ||
135 | |||
136 | if (data[0] != 2) { | ||
137 | printk(KERN_INFO "wacom_ptu_irq: received unknown report #%d\n", data[0]); | ||
138 | return 0; | ||
139 | } | ||
140 | |||
141 | wacom_input_regs(wcombo); | ||
142 | if (data[1] & 0x04) { | ||
143 | wacom_report_key(wcombo, BTN_TOOL_RUBBER, data[1] & 0x20); | ||
144 | wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x08); | ||
145 | id = ERASER_DEVICE_ID; | ||
146 | } else { | ||
147 | wacom_report_key(wcombo, BTN_TOOL_PEN, data[1] & 0x20); | ||
148 | wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x01); | ||
149 | id = STYLUS_DEVICE_ID; | ||
150 | } | ||
151 | wacom_report_abs(wcombo, ABS_MISC, id); /* report tool id */ | ||
152 | wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[2])); | ||
153 | wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4])); | ||
154 | wacom_report_abs(wcombo, ABS_PRESSURE, wacom_le16_to_cpu(&data[6])); | ||
155 | wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02); | ||
156 | wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x10); | ||
157 | return 1; | ||
158 | } | ||
159 | |||
160 | static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo) | ||
161 | { | ||
162 | unsigned char *data = wacom->data; | ||
163 | int x, y, id, rw; | ||
164 | |||
165 | if (data[0] != 2) { | ||
166 | dbg("wacom_graphire_irq: received unknown report #%d", data[0]); | ||
167 | return 0; | ||
168 | } | ||
169 | |||
170 | wacom_input_regs(wcombo); | ||
171 | |||
172 | id = STYLUS_DEVICE_ID; | ||
173 | if (data[1] & 0x10) { /* in prox */ | ||
174 | |||
175 | switch ((data[1] >> 5) & 3) { | ||
176 | |||
177 | case 0: /* Pen */ | ||
178 | wacom->tool[0] = BTN_TOOL_PEN; | ||
179 | break; | ||
180 | |||
181 | case 1: /* Rubber */ | ||
182 | wacom->tool[0] = BTN_TOOL_RUBBER; | ||
183 | id = ERASER_DEVICE_ID; | ||
184 | break; | ||
185 | |||
186 | case 2: /* Mouse with wheel */ | ||
187 | wacom_report_key(wcombo, BTN_MIDDLE, data[1] & 0x04); | ||
188 | if (wacom->features->type == WACOM_G4) { | ||
189 | rw = data[7] & 0x04 ? (data[7] & 0x03)-4 : (data[7] & 0x03); | ||
190 | wacom_report_rel(wcombo, REL_WHEEL, -rw); | ||
191 | } else | ||
192 | wacom_report_rel(wcombo, REL_WHEEL, -(signed char) data[6]); | ||
193 | /* fall through */ | ||
194 | |||
195 | case 3: /* Mouse without wheel */ | ||
196 | wacom->tool[0] = BTN_TOOL_MOUSE; | ||
197 | id = CURSOR_DEVICE_ID; | ||
198 | wacom_report_key(wcombo, BTN_LEFT, data[1] & 0x01); | ||
199 | wacom_report_key(wcombo, BTN_RIGHT, data[1] & 0x02); | ||
200 | if (wacom->features->type == WACOM_G4) | ||
201 | wacom_report_abs(wcombo, ABS_DISTANCE, data[6]); | ||
202 | else | ||
203 | wacom_report_abs(wcombo, ABS_DISTANCE, data[7]); | ||
204 | break; | ||
205 | } | ||
206 | } | ||
207 | |||
208 | if (data[1] & 0x90) { | ||
209 | x = wacom_le16_to_cpu(&data[2]); | ||
210 | y = wacom_le16_to_cpu(&data[4]); | ||
211 | wacom_report_abs(wcombo, ABS_X, x); | ||
212 | wacom_report_abs(wcombo, ABS_Y, y); | ||
213 | if (wacom->tool[0] != BTN_TOOL_MOUSE) { | ||
214 | wacom_report_abs(wcombo, ABS_PRESSURE, data[6] | ((data[7] & 0x01) << 8)); | ||
215 | wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x01); | ||
216 | wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02); | ||
217 | wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x04); | ||
218 | } | ||
219 | } | ||
220 | |||
221 | if (data[1] & 0x10) | ||
222 | wacom_report_abs(wcombo, ABS_MISC, id); /* report tool id */ | ||
223 | else | ||
224 | wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */ | ||
225 | wacom_report_key(wcombo, wacom->tool[0], data[1] & 0x10); | ||
226 | wacom_input_sync(wcombo); | ||
227 | |||
228 | /* send pad data */ | ||
229 | if (wacom->features->type == WACOM_G4) { | ||
230 | if ( (wacom->serial[1] & 0xc0) != (data[7] & 0xf8) ) { | ||
231 | wacom->id[1] = 1; | ||
232 | wacom->serial[1] = (data[7] & 0xf8); | ||
233 | wacom_report_key(wcombo, BTN_0, (data[7] & 0x40)); | ||
234 | wacom_report_key(wcombo, BTN_4, (data[7] & 0x80)); | ||
235 | rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3); | ||
236 | wacom_report_rel(wcombo, REL_WHEEL, rw); | ||
237 | wacom_report_key(wcombo, BTN_TOOL_FINGER, 0xf0); | ||
238 | wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0); | ||
239 | } else if (wacom->id[1]) { | ||
240 | wacom->id[1] = 0; | ||
241 | wacom_report_key(wcombo, BTN_TOOL_FINGER, 0); | ||
242 | wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0); | ||
243 | } | ||
244 | } | ||
245 | return 1; | ||
246 | } | ||
247 | |||
248 | static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo) | ||
249 | { | ||
250 | unsigned char *data = wacom->data; | ||
251 | int idx; | ||
252 | |||
253 | /* tool number */ | ||
254 | idx = data[1] & 0x01; | ||
255 | |||
256 | /* Enter report */ | ||
257 | if ((data[1] & 0xfc) == 0xc0) { | ||
258 | /* serial number of the tool */ | ||
259 | wacom->serial[idx] = ((data[3] & 0x0f) << 28) + | ||
260 | (data[4] << 20) + (data[5] << 12) + | ||
261 | (data[6] << 4) + (data[7] >> 4); | ||
262 | |||
263 | wacom->id[idx] = (data[2] << 4) | (data[3] >> 4); | ||
264 | switch (wacom->id[idx]) { | ||
265 | case 0x812: /* Inking pen */ | ||
266 | case 0x801: /* Intuos3 Inking pen */ | ||
267 | case 0x012: | ||
268 | wacom->tool[idx] = BTN_TOOL_PENCIL; | ||
269 | break; | ||
270 | case 0x822: /* Pen */ | ||
271 | case 0x842: | ||
272 | case 0x852: | ||
273 | case 0x823: /* Intuos3 Grip Pen */ | ||
274 | case 0x813: /* Intuos3 Classic Pen */ | ||
275 | case 0x885: /* Intuos3 Marker Pen */ | ||
276 | case 0x022: | ||
277 | wacom->tool[idx] = BTN_TOOL_PEN; | ||
278 | break; | ||
279 | case 0x832: /* Stroke pen */ | ||
280 | case 0x032: | ||
281 | wacom->tool[idx] = BTN_TOOL_BRUSH; | ||
282 | break; | ||
283 | case 0x007: /* Mouse 4D and 2D */ | ||
284 | case 0x09c: | ||
285 | case 0x094: | ||
286 | case 0x017: /* Intuos3 2D Mouse */ | ||
287 | wacom->tool[idx] = BTN_TOOL_MOUSE; | ||
288 | break; | ||
289 | case 0x096: /* Lens cursor */ | ||
290 | case 0x097: /* Intuos3 Lens cursor */ | ||
291 | wacom->tool[idx] = BTN_TOOL_LENS; | ||
292 | break; | ||
293 | case 0x82a: /* Eraser */ | ||
294 | case 0x85a: | ||
295 | case 0x91a: | ||
296 | case 0xd1a: | ||
297 | case 0x0fa: | ||
298 | case 0x82b: /* Intuos3 Grip Pen Eraser */ | ||
299 | case 0x81b: /* Intuos3 Classic Pen Eraser */ | ||
300 | case 0x91b: /* Intuos3 Airbrush Eraser */ | ||
301 | wacom->tool[idx] = BTN_TOOL_RUBBER; | ||
302 | break; | ||
303 | case 0xd12: | ||
304 | case 0x912: | ||
305 | case 0x112: | ||
306 | case 0x913: /* Intuos3 Airbrush */ | ||
307 | wacom->tool[idx] = BTN_TOOL_AIRBRUSH; | ||
308 | break; | ||
309 | default: /* Unknown tool */ | ||
310 | wacom->tool[idx] = BTN_TOOL_PEN; | ||
311 | } | ||
312 | /* only large I3 support Lens Cursor */ | ||
313 | if(!((wacom->tool[idx] == BTN_TOOL_LENS) && | ||
314 | (wacom->features->type == INTUOS3))) { | ||
315 | wacom_report_abs(wcombo, ABS_MISC, wacom->id[idx]); /* report tool id */ | ||
316 | wacom_report_key(wcombo, wacom->tool[idx], 1); | ||
317 | wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]); | ||
318 | return 2; | ||
319 | } | ||
320 | return 1; | ||
321 | } | ||
322 | |||
323 | /* Exit report */ | ||
324 | if ((data[1] & 0xfe) == 0x80) { | ||
325 | wacom_report_key(wcombo, wacom->tool[idx], 0); | ||
326 | wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */ | ||
327 | wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]); | ||
328 | return 2; | ||
329 | } | ||
330 | return 0; | ||
331 | } | ||
332 | |||
333 | static void wacom_intuos_general(struct wacom_wac *wacom, void *wcombo) | ||
334 | { | ||
335 | unsigned char *data = wacom->data; | ||
336 | unsigned int t; | ||
337 | |||
338 | /* general pen packet */ | ||
339 | if ((data[1] & 0xb8) == 0xa0) { | ||
340 | t = (data[6] << 2) | ((data[7] >> 6) & 3); | ||
341 | wacom_report_abs(wcombo, ABS_PRESSURE, t); | ||
342 | wacom_report_abs(wcombo, ABS_TILT_X, | ||
343 | ((data[7] << 1) & 0x7e) | (data[8] >> 7)); | ||
344 | wacom_report_abs(wcombo, ABS_TILT_Y, data[8] & 0x7f); | ||
345 | wacom_report_key(wcombo, BTN_STYLUS, data[1] & 2); | ||
346 | wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 4); | ||
347 | wacom_report_key(wcombo, BTN_TOUCH, t > 10); | ||
348 | } | ||
349 | |||
350 | /* airbrush second packet */ | ||
351 | if ((data[1] & 0xbc) == 0xb4) { | ||
352 | wacom_report_abs(wcombo, ABS_WHEEL, | ||
353 | (data[6] << 2) | ((data[7] >> 6) & 3)); | ||
354 | wacom_report_abs(wcombo, ABS_TILT_X, | ||
355 | ((data[7] << 1) & 0x7e) | (data[8] >> 7)); | ||
356 | wacom_report_abs(wcombo, ABS_TILT_Y, data[8] & 0x7f); | ||
357 | } | ||
358 | return; | ||
359 | } | ||
360 | |||
361 | static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo) | ||
362 | { | ||
363 | unsigned char *data = wacom->data; | ||
364 | unsigned int t; | ||
365 | int idx, result; | ||
366 | |||
367 | if (data[0] != 2 && data[0] != 5 && data[0] != 6 && data[0] != 12) { | ||
368 | dbg("wacom_intuos_irq: received unknown report #%d", data[0]); | ||
369 | return 0; | ||
370 | } | ||
371 | |||
372 | wacom_input_regs(wcombo); | ||
373 | |||
374 | /* tool number */ | ||
375 | idx = data[1] & 0x01; | ||
376 | |||
377 | /* pad packets. Works as a second tool and is always in prox */ | ||
378 | if (data[0] == 12) { | ||
379 | /* initiate the pad as a device */ | ||
380 | if (wacom->tool[1] != BTN_TOOL_FINGER) | ||
381 | wacom->tool[1] = BTN_TOOL_FINGER; | ||
382 | |||
383 | wacom_report_key(wcombo, BTN_0, (data[5] & 0x01)); | ||
384 | wacom_report_key(wcombo, BTN_1, (data[5] & 0x02)); | ||
385 | wacom_report_key(wcombo, BTN_2, (data[5] & 0x04)); | ||
386 | wacom_report_key(wcombo, BTN_3, (data[5] & 0x08)); | ||
387 | wacom_report_key(wcombo, BTN_4, (data[6] & 0x01)); | ||
388 | wacom_report_key(wcombo, BTN_5, (data[6] & 0x02)); | ||
389 | wacom_report_key(wcombo, BTN_6, (data[6] & 0x04)); | ||
390 | wacom_report_key(wcombo, BTN_7, (data[6] & 0x08)); | ||
391 | wacom_report_abs(wcombo, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]); | ||
392 | wacom_report_abs(wcombo, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]); | ||
393 | |||
394 | if((data[5] & 0x0f) | (data[6] & 0x0f) | (data[1] & 0x1f) | data[2]) | ||
395 | wacom_report_key(wcombo, wacom->tool[1], 1); | ||
396 | else | ||
397 | wacom_report_key(wcombo, wacom->tool[1], 0); | ||
398 | wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xffffffff); | ||
399 | return 1; | ||
400 | } | ||
401 | |||
402 | /* process in/out prox events */ | ||
403 | result = wacom_intuos_inout(wacom, wcombo); | ||
404 | if (result) | ||
405 | return result-1; | ||
406 | |||
407 | /* Cintiq doesn't send data when RDY bit isn't set */ | ||
408 | if ((wacom->features->type == CINTIQ) && !(data[1] & 0x40)) | ||
409 | return 0; | ||
410 | |||
411 | if (wacom->features->type >= INTUOS3) { | ||
412 | wacom_report_abs(wcombo, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1)); | ||
413 | wacom_report_abs(wcombo, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1)); | ||
414 | wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 2) & 0x3f)); | ||
415 | } else { | ||
416 | wacom_report_abs(wcombo, ABS_X, wacom_be16_to_cpu(&data[2])); | ||
417 | wacom_report_abs(wcombo, ABS_Y, wacom_be16_to_cpu(&data[4])); | ||
418 | wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 3) & 0x1f)); | ||
419 | } | ||
420 | |||
421 | /* process general packets */ | ||
422 | wacom_intuos_general(wacom, wcombo); | ||
423 | |||
424 | /* 4D mouse, 2D mouse, marker pen rotation, or Lens cursor packets */ | ||
425 | if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0) { | ||
426 | |||
427 | if (data[1] & 0x02) { | ||
428 | /* Rotation packet */ | ||
429 | if (wacom->features->type >= INTUOS3) { | ||
430 | /* I3 marker pen rotation reported as wheel | ||
431 | * due to valuator limitation | ||
432 | */ | ||
433 | t = (data[6] << 3) | ((data[7] >> 5) & 7); | ||
434 | t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) : | ||
435 | ((t-1) / 2 + 450)) : (450 - t / 2) ; | ||
436 | wacom_report_abs(wcombo, ABS_WHEEL, t); | ||
437 | } else { | ||
438 | /* 4D mouse rotation packet */ | ||
439 | t = (data[6] << 3) | ((data[7] >> 5) & 7); | ||
440 | wacom_report_abs(wcombo, ABS_RZ, (data[7] & 0x20) ? | ||
441 | ((t - 1) / 2) : -t / 2); | ||
442 | } | ||
443 | |||
444 | } else if (!(data[1] & 0x10) && wacom->features->type < INTUOS3) { | ||
445 | /* 4D mouse packet */ | ||
446 | wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01); | ||
447 | wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02); | ||
448 | wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x04); | ||
449 | |||
450 | wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x20); | ||
451 | wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x10); | ||
452 | t = (data[6] << 2) | ((data[7] >> 6) & 3); | ||
453 | wacom_report_abs(wcombo, ABS_THROTTLE, (data[8] & 0x08) ? -t : t); | ||
454 | |||
455 | } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) { | ||
456 | /* 2D mouse packet */ | ||
457 | wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x04); | ||
458 | wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x08); | ||
459 | wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x10); | ||
460 | wacom_report_rel(wcombo, REL_WHEEL, (data[8] & 0x01) | ||
461 | - ((data[8] & 0x02) >> 1)); | ||
462 | |||
463 | /* I3 2D mouse side buttons */ | ||
464 | if (wacom->features->type == INTUOS3) { | ||
465 | wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x40); | ||
466 | wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x20); | ||
467 | } | ||
468 | |||
469 | } else if (wacom->features->type < INTUOS3) { | ||
470 | /* Lens cursor packets */ | ||
471 | wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01); | ||
472 | wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02); | ||
473 | wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x04); | ||
474 | wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x10); | ||
475 | wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x08); | ||
476 | } | ||
477 | } | ||
478 | |||
479 | wacom_report_abs(wcombo, ABS_MISC, wacom->id[idx]); /* report tool id */ | ||
480 | wacom_report_key(wcombo, wacom->tool[idx], 1); | ||
481 | wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]); | ||
482 | return 1; | ||
483 | } | ||
484 | |||
485 | int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo) | ||
486 | { | ||
487 | switch (wacom_wac->features->type) { | ||
488 | case PENPARTNER: | ||
489 | return (wacom_penpartner_irq(wacom_wac, wcombo)); | ||
490 | break; | ||
491 | case PL: | ||
492 | return (wacom_pl_irq(wacom_wac, wcombo)); | ||
493 | break; | ||
494 | case WACOM_G4: | ||
495 | case GRAPHIRE: | ||
496 | return (wacom_graphire_irq(wacom_wac, wcombo)); | ||
497 | break; | ||
498 | case PTU: | ||
499 | return (wacom_ptu_irq(wacom_wac, wcombo)); | ||
500 | break; | ||
501 | case INTUOS: | ||
502 | case INTUOS3: | ||
503 | case INTUOS3L: | ||
504 | case CINTIQ: | ||
505 | return (wacom_intuos_irq(wacom_wac, wcombo)); | ||
506 | break; | ||
507 | default: | ||
508 | return 0; | ||
509 | } | ||
510 | return 0; | ||
511 | } | ||
512 | |||
513 | void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | ||
514 | { | ||
515 | switch (wacom_wac->features->type) { | ||
516 | case WACOM_G4: | ||
517 | input_dev_g4(input_dev, wacom_wac); | ||
518 | /* fall through */ | ||
519 | case GRAPHIRE: | ||
520 | input_dev_g(input_dev, wacom_wac); | ||
521 | break; | ||
522 | case INTUOS3: | ||
523 | case INTUOS3L: | ||
524 | case CINTIQ: | ||
525 | input_dev_i3(input_dev, wacom_wac); | ||
526 | /* fall through */ | ||
527 | case INTUOS: | ||
528 | input_dev_i(input_dev, wacom_wac); | ||
529 | break; | ||
530 | case PL: | ||
531 | case PTU: | ||
532 | input_dev_pl(input_dev, wacom_wac); | ||
533 | break; | ||
534 | case PENPARTNER: | ||
535 | input_dev_pt(input_dev, wacom_wac); | ||
536 | break; | ||
537 | } | ||
538 | return; | ||
539 | } | ||
540 | |||
541 | static struct wacom_features wacom_features[] = { | ||
542 | { "Wacom Penpartner", 7, 5040, 3780, 255, 32, PENPARTNER, wacom_sys_irq }, | ||
543 | { "Wacom Graphire", 8, 10206, 7422, 511, 32, GRAPHIRE, wacom_sys_irq }, | ||
544 | { "Wacom Graphire2 4x5", 8, 10206, 7422, 511, 32, GRAPHIRE, wacom_sys_irq }, | ||
545 | { "Wacom Graphire2 5x7", 8, 13918, 10206, 511, 32, GRAPHIRE, wacom_sys_irq }, | ||
546 | { "Wacom Graphire3", 8, 10208, 7424, 511, 32, GRAPHIRE, wacom_sys_irq }, | ||
547 | { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 32, GRAPHIRE, wacom_sys_irq }, | ||
548 | { "Wacom Graphire4 4x5", 8, 10208, 7424, 511, 32, WACOM_G4, wacom_sys_irq }, | ||
549 | { "Wacom Graphire4 6x8", 8, 16704, 12064, 511, 32, WACOM_G4, wacom_sys_irq }, | ||
550 | { "Wacom Volito", 8, 5104, 3712, 511, 32, GRAPHIRE, wacom_sys_irq }, | ||
551 | { "Wacom PenStation2", 8, 3250, 2320, 255, 32, GRAPHIRE, wacom_sys_irq }, | ||
552 | { "Wacom Volito2 4x5", 8, 5104, 3712, 511, 32, GRAPHIRE, wacom_sys_irq }, | ||
553 | { "Wacom Volito2 2x3", 8, 3248, 2320, 511, 32, GRAPHIRE, wacom_sys_irq }, | ||
554 | { "Wacom PenPartner2", 8, 3250, 2320, 255, 32, GRAPHIRE, wacom_sys_irq }, | ||
555 | { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 15, INTUOS, wacom_sys_irq}, | ||
556 | { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_sys_irq }, | ||
557 | { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 15, INTUOS, wacom_sys_irq }, | ||
558 | { "Wacom Intuos 12x12", 10, 30480, 31680, 1023, 15, INTUOS, wacom_sys_irq }, | ||
559 | { "Wacom Intuos 12x18", 10, 45720, 31680, 1023, 15, INTUOS, wacom_sys_irq}, | ||
560 | { "Wacom PL400", 8, 5408, 4056, 255, 32, PL, wacom_sys_irq }, | ||
561 | { "Wacom PL500", 8, 6144, 4608, 255, 32, PL, wacom_sys_irq }, | ||
562 | { "Wacom PL600", 8, 6126, 4604, 255, 32, PL, wacom_sys_irq }, | ||
563 | { "Wacom PL600SX", 8, 6260, 5016, 255, 32, PL, wacom_sys_irq }, | ||
564 | { "Wacom PL550", 8, 6144, 4608, 511, 32, PL, wacom_sys_irq }, | ||
565 | { "Wacom PL800", 8, 7220, 5780, 511, 32, PL, wacom_sys_irq }, | ||
566 | { "Wacom PL700", 8, 6758, 5406, 511, 32, PL, wacom_sys_irq }, | ||
567 | { "Wacom PL510", 8, 6282, 4762, 511, 32, PL, wacom_sys_irq }, | ||
568 | { "Wacom DTU710", 8, 34080, 27660, 511, 32, PL, wacom_sys_irq }, | ||
569 | { "Wacom DTF521", 8, 6282, 4762, 511, 32, PL, wacom_sys_irq }, | ||
570 | { "Wacom DTF720", 8, 6858, 5506, 511, 32, PL, wacom_sys_irq }, | ||
571 | { "Wacom Cintiq Partner",8, 20480, 15360, 511, 32, PTU, wacom_sys_irq }, | ||
572 | { "Wacom Intuos2 4x5", 10, 12700, 10600, 1023, 15, INTUOS, wacom_sys_irq }, | ||
573 | { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_sys_irq }, | ||
574 | { "Wacom Intuos2 9x12", 10, 30480, 24060, 1023, 15, INTUOS, wacom_sys_irq }, | ||
575 | { "Wacom Intuos2 12x12", 10, 30480, 31680, 1023, 15, INTUOS, wacom_sys_irq }, | ||
576 | { "Wacom Intuos2 12x18", 10, 45720, 31680, 1023, 15, INTUOS, wacom_sys_irq }, | ||
577 | { "Wacom Intuos3 4x5", 10, 25400, 20320, 1023, 15, INTUOS3, wacom_sys_irq }, | ||
578 | { "Wacom Intuos3 6x8", 10, 40640, 30480, 1023, 15, INTUOS3, wacom_sys_irq }, | ||
579 | { "Wacom Intuos3 9x12", 10, 60960, 45720, 1023, 15, INTUOS3, wacom_sys_irq }, | ||
580 | { "Wacom Intuos3 12x12", 10, 60960, 60960, 1023, 15, INTUOS3L, wacom_sys_irq }, | ||
581 | { "Wacom Intuos3 12x19", 10, 97536, 60960, 1023, 15, INTUOS3L, wacom_sys_irq }, | ||
582 | { "Wacom Intuos3 6x11", 10, 54204, 31750, 1023, 15, INTUOS3, wacom_sys_irq }, | ||
583 | { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 15, CINTIQ, wacom_sys_irq }, | ||
584 | { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_sys_irq }, | ||
585 | { } | ||
586 | }; | ||
587 | |||
588 | static struct usb_device_id wacom_ids[] = { | ||
589 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x00) }, | ||
590 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x10) }, | ||
591 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x11) }, | ||
592 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x12) }, | ||
593 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x13) }, | ||
594 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x14) }, | ||
595 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x15) }, | ||
596 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x16) }, | ||
597 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60) }, | ||
598 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x61) }, | ||
599 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x62) }, | ||
600 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x63) }, | ||
601 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x64) }, | ||
602 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x20) }, | ||
603 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x21) }, | ||
604 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x22) }, | ||
605 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x23) }, | ||
606 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x24) }, | ||
607 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x30) }, | ||
608 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x31) }, | ||
609 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x32) }, | ||
610 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x33) }, | ||
611 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x34) }, | ||
612 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x35) }, | ||
613 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x37) }, | ||
614 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x38) }, | ||
615 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x39) }, | ||
616 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC0) }, | ||
617 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC4) }, | ||
618 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x03) }, | ||
619 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x41) }, | ||
620 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x42) }, | ||
621 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x43) }, | ||
622 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x44) }, | ||
623 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x45) }, | ||
624 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB0) }, | ||
625 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB1) }, | ||
626 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB2) }, | ||
627 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB3) }, | ||
628 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB4) }, | ||
629 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB5) }, | ||
630 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) }, | ||
631 | { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) }, | ||
632 | { } | ||
633 | }; | ||
634 | |||
635 | const struct usb_device_id * get_device_table(void) { | ||
636 | const struct usb_device_id * id_table = wacom_ids; | ||
637 | return id_table; | ||
638 | } | ||
639 | |||
640 | struct wacom_features * get_wacom_feature(const struct usb_device_id * id) { | ||
641 | int index = id - wacom_ids; | ||
642 | struct wacom_features *wf = &wacom_features[index]; | ||
643 | return wf; | ||
644 | } | ||
645 | |||
646 | MODULE_DEVICE_TABLE(usb, wacom_ids); | ||