Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / drivers / input / tablet / wacom_wac.c
blobcaf37d21456df0896449881156b28fe439952d96
1 /*
2 * drivers/input/tablet/wacom_wac.c
4 * USB Wacom Graphire and Wacom Intuos tablet support - Wacom specific code
6 */
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.
14 #include "wacom.h"
15 #include "wacom_wac.h"
17 static int wacom_penpartner_irq(struct wacom_wac *wacom, void *wcombo)
19 unsigned char *data = wacom->data;
21 switch (data[0]) {
22 case 1:
23 if (data[5] & 0x80) {
24 wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
25 wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID;
26 wacom_report_key(wcombo, wacom->tool[0], 1);
27 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); /* report tool id */
28 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[1]));
29 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[3]));
30 wacom_report_abs(wcombo, ABS_PRESSURE, (signed char)data[6] + 127);
31 wacom_report_key(wcombo, BTN_TOUCH, ((signed char)data[6] > -127));
32 wacom_report_key(wcombo, BTN_STYLUS, (data[5] & 0x40));
33 } else {
34 wacom_report_key(wcombo, wacom->tool[0], 0);
35 wacom_report_abs(wcombo, ABS_MISC, 0); /* report tool id */
36 wacom_report_abs(wcombo, ABS_PRESSURE, -1);
37 wacom_report_key(wcombo, BTN_TOUCH, 0);
39 break;
40 case 2:
41 wacom_report_key(wcombo, BTN_TOOL_PEN, 1);
42 wacom_report_abs(wcombo, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
43 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[1]));
44 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[3]));
45 wacom_report_abs(wcombo, ABS_PRESSURE, (signed char)data[6] + 127);
46 wacom_report_key(wcombo, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
47 wacom_report_key(wcombo, BTN_STYLUS, (data[5] & 0x40));
48 break;
49 default:
50 printk(KERN_INFO "wacom_penpartner_irq: received unknown report #%d\n", data[0]);
51 return 0;
53 return 1;
56 static int wacom_pl_irq(struct wacom_wac *wacom, void *wcombo)
58 unsigned char *data = wacom->data;
59 int prox, id, pressure;
61 if (data[0] != 2) {
62 dbg("wacom_pl_irq: received unknown report #%d", data[0]);
63 return 0;
66 prox = data[1] & 0x40;
68 id = ERASER_DEVICE_ID;
69 if (prox) {
71 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
72 if (wacom->features->pressure_max > 255)
73 pressure = (pressure << 1) | ((data[4] >> 6) & 1);
74 pressure += (wacom->features->pressure_max + 1) / 2;
77 * if going from out of proximity into proximity select between the eraser
78 * and the pen based on the state of the stylus2 button, choose eraser if
79 * pressed else choose pen. if not a proximity change from out to in, send
80 * an out of proximity for previous tool then a in for new tool.
82 if (!wacom->tool[0]) {
83 /* Eraser bit set for DTF */
84 if (data[1] & 0x10)
85 wacom->tool[1] = BTN_TOOL_RUBBER;
86 else
87 /* Going into proximity select tool */
88 wacom->tool[1] = (data[4] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
89 } else {
90 /* was entered with stylus2 pressed */
91 if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
92 /* report out proximity for previous tool */
93 wacom_report_key(wcombo, wacom->tool[1], 0);
94 wacom_input_sync(wcombo);
95 wacom->tool[1] = BTN_TOOL_PEN;
96 return 0;
99 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
100 /* Unknown tool selected default to pen tool */
101 wacom->tool[1] = BTN_TOOL_PEN;
102 id = STYLUS_DEVICE_ID;
104 wacom_report_key(wcombo, wacom->tool[1], prox); /* report in proximity for tool */
105 wacom_report_abs(wcombo, ABS_MISC, id); /* report tool id */
106 wacom_report_abs(wcombo, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
107 wacom_report_abs(wcombo, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
108 wacom_report_abs(wcombo, ABS_PRESSURE, pressure);
110 wacom_report_key(wcombo, BTN_TOUCH, data[4] & 0x08);
111 wacom_report_key(wcombo, BTN_STYLUS, data[4] & 0x10);
112 /* Only allow the stylus2 button to be reported for the pen tool. */
113 wacom_report_key(wcombo, BTN_STYLUS2, (wacom->tool[1] == BTN_TOOL_PEN) && (data[4] & 0x20));
114 } else {
115 /* report proximity-out of a (valid) tool */
116 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
117 /* Unknown tool selected default to pen tool */
118 wacom->tool[1] = BTN_TOOL_PEN;
120 wacom_report_key(wcombo, wacom->tool[1], prox);
123 wacom->tool[0] = prox; /* Save proximity state */
124 return 1;
127 static int wacom_ptu_irq(struct wacom_wac *wacom, void *wcombo)
129 unsigned char *data = wacom->data;
130 int id;
132 if (data[0] != 2) {
133 printk(KERN_INFO "wacom_ptu_irq: received unknown report #%d\n", data[0]);
134 return 0;
137 if (data[1] & 0x04) {
138 wacom_report_key(wcombo, BTN_TOOL_RUBBER, data[1] & 0x20);
139 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x08);
140 id = ERASER_DEVICE_ID;
141 } else {
142 wacom_report_key(wcombo, BTN_TOOL_PEN, data[1] & 0x20);
143 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x01);
144 id = STYLUS_DEVICE_ID;
146 wacom_report_abs(wcombo, ABS_MISC, id); /* report tool id */
147 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[2]));
148 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4]));
149 wacom_report_abs(wcombo, ABS_PRESSURE, wacom_le16_to_cpu(&data[6]));
150 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02);
151 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x10);
152 return 1;
155 static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
157 unsigned char *data = wacom->data;
158 int x, y, id, rw;
160 if (data[0] != 2) {
161 dbg("wacom_graphire_irq: received unknown report #%d", data[0]);
162 return 0;
165 id = STYLUS_DEVICE_ID;
166 <<<<<<< HEAD:drivers/input/tablet/wacom_wac.c
167 if (data[1] & 0x80) { /* in prox */
168 =======
169 if ((data[1] & 0x80) && ((data[1] & 0x07) || data[2] || data[3] || data[4]
170 || data[5] || data[6] || (data[7] & 0x07))) {
171 /* in prox and not a pad data */
172 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/input/tablet/wacom_wac.c
174 switch ((data[1] >> 5) & 3) {
176 case 0: /* Pen */
177 wacom->tool[0] = BTN_TOOL_PEN;
178 break;
180 case 1: /* Rubber */
181 wacom->tool[0] = BTN_TOOL_RUBBER;
182 id = ERASER_DEVICE_ID;
183 break;
185 case 2: /* Mouse with wheel */
186 wacom_report_key(wcombo, BTN_MIDDLE, data[1] & 0x04);
187 if (wacom->features->type == WACOM_G4 ||
188 wacom->features->type == WACOM_MO) {
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 */
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->features->type == WACOM_MO)
202 wacom_report_abs(wcombo, ABS_DISTANCE, data[6] & 0x3f);
203 else
204 wacom_report_abs(wcombo, ABS_DISTANCE, data[7] & 0x3f);
205 break;
207 x = wacom_le16_to_cpu(&data[2]);
208 y = wacom_le16_to_cpu(&data[4]);
209 wacom_report_abs(wcombo, ABS_X, x);
210 wacom_report_abs(wcombo, ABS_Y, y);
211 if (wacom->tool[0] != BTN_TOOL_MOUSE) {
212 wacom_report_abs(wcombo, ABS_PRESSURE, data[6] | ((data[7] & 0x01) << 8));
213 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x01);
214 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02);
215 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x04);
217 wacom_report_abs(wcombo, ABS_MISC, id); /* report tool id */
218 wacom_report_key(wcombo, wacom->tool[0], 1);
219 } else if (!(data[1] & 0x90)) {
220 wacom_report_abs(wcombo, ABS_X, 0);
221 wacom_report_abs(wcombo, ABS_Y, 0);
222 if (wacom->tool[0] == BTN_TOOL_MOUSE) {
223 wacom_report_key(wcombo, BTN_LEFT, 0);
224 wacom_report_key(wcombo, BTN_RIGHT, 0);
225 wacom_report_abs(wcombo, ABS_DISTANCE, 0);
226 } else {
227 wacom_report_abs(wcombo, ABS_PRESSURE, 0);
228 wacom_report_key(wcombo, BTN_TOUCH, 0);
229 wacom_report_key(wcombo, BTN_STYLUS, 0);
230 wacom_report_key(wcombo, BTN_STYLUS2, 0);
232 wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */
233 wacom_report_key(wcombo, wacom->tool[0], 0);
236 /* send pad data */
237 switch (wacom->features->type) {
238 case WACOM_G4:
239 if (data[7] & 0xf8) {
240 wacom_input_sync(wcombo); /* sync last event */
241 wacom->id[1] = 1;
242 <<<<<<< HEAD:drivers/input/tablet/wacom_wac.c
243 wacom->serial[1] = (data[7] & 0xf8);
244 =======
245 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/input/tablet/wacom_wac.c
246 wacom_report_key(wcombo, BTN_0, (data[7] & 0x40));
247 wacom_report_key(wcombo, BTN_4, (data[7] & 0x80));
248 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
249 wacom_report_rel(wcombo, REL_WHEEL, rw);
250 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0xf0);
251 wacom_report_abs(wcombo, ABS_MISC, PAD_DEVICE_ID);
252 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
253 } else if (wacom->id[1]) {
254 wacom_input_sync(wcombo); /* sync last event */
255 wacom->id[1] = 0;
256 wacom_report_key(wcombo, BTN_0, (data[7] & 0x40));
257 wacom_report_key(wcombo, BTN_4, (data[7] & 0x80));
258 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0);
259 wacom_report_abs(wcombo, ABS_MISC, 0);
260 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
262 break;
263 case WACOM_MO:
264 <<<<<<< HEAD:drivers/input/tablet/wacom_wac.c
265 if ((data[7] & 0xf8) || (data[8] & 0x80)) {
266 =======
267 if ((data[7] & 0xf8) || (data[8] & 0xff)) {
268 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/input/tablet/wacom_wac.c
269 wacom_input_sync(wcombo); /* sync last event */
270 wacom->id[1] = 1;
271 <<<<<<< HEAD:drivers/input/tablet/wacom_wac.c
272 wacom->serial[1] = (data[7] & 0xf8);
273 =======
274 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/input/tablet/wacom_wac.c
275 wacom_report_key(wcombo, BTN_0, (data[7] & 0x08));
276 wacom_report_key(wcombo, BTN_1, (data[7] & 0x20));
277 wacom_report_key(wcombo, BTN_4, (data[7] & 0x10));
278 wacom_report_key(wcombo, BTN_5, (data[7] & 0x40));
279 wacom_report_abs(wcombo, ABS_WHEEL, (data[8] & 0x7f));
280 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0xf0);
281 wacom_report_abs(wcombo, ABS_MISC, PAD_DEVICE_ID);
282 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
283 } else if (wacom->id[1]) {
284 wacom_input_sync(wcombo); /* sync last event */
285 wacom->id[1] = 0;
286 wacom_report_key(wcombo, BTN_0, (data[7] & 0x08));
287 wacom_report_key(wcombo, BTN_1, (data[7] & 0x20));
288 wacom_report_key(wcombo, BTN_4, (data[7] & 0x10));
289 wacom_report_key(wcombo, BTN_5, (data[7] & 0x40));
290 wacom_report_abs(wcombo, ABS_WHEEL, (data[8] & 0x7f));
291 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0);
292 wacom_report_abs(wcombo, ABS_MISC, 0);
293 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
295 break;
297 return 1;
300 static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
302 unsigned char *data = wacom->data;
303 int idx;
305 /* tool number */
306 idx = data[1] & 0x01;
308 /* Enter report */
309 if ((data[1] & 0xfc) == 0xc0) {
310 /* serial number of the tool */
311 wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
312 (data[4] << 20) + (data[5] << 12) +
313 (data[6] << 4) + (data[7] >> 4);
315 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4);
316 switch (wacom->id[idx]) {
317 case 0x812: /* Inking pen */
318 case 0x801: /* Intuos3 Inking pen */
319 case 0x012:
320 wacom->tool[idx] = BTN_TOOL_PENCIL;
321 break;
322 case 0x822: /* Pen */
323 case 0x842:
324 case 0x852:
325 case 0x823: /* Intuos3 Grip Pen */
326 case 0x813: /* Intuos3 Classic Pen */
327 case 0x885: /* Intuos3 Marker Pen */
328 case 0x022:
329 wacom->tool[idx] = BTN_TOOL_PEN;
330 break;
331 case 0x832: /* Stroke pen */
332 case 0x032:
333 wacom->tool[idx] = BTN_TOOL_BRUSH;
334 break;
335 case 0x007: /* Mouse 4D and 2D */
336 case 0x09c:
337 case 0x094:
338 case 0x017: /* Intuos3 2D Mouse */
339 wacom->tool[idx] = BTN_TOOL_MOUSE;
340 break;
341 case 0x096: /* Lens cursor */
342 case 0x097: /* Intuos3 Lens cursor */
343 wacom->tool[idx] = BTN_TOOL_LENS;
344 break;
345 case 0x82a: /* Eraser */
346 case 0x85a:
347 case 0x91a:
348 case 0xd1a:
349 case 0x0fa:
350 case 0x82b: /* Intuos3 Grip Pen Eraser */
351 case 0x81b: /* Intuos3 Classic Pen Eraser */
352 case 0x91b: /* Intuos3 Airbrush Eraser */
353 wacom->tool[idx] = BTN_TOOL_RUBBER;
354 break;
355 case 0xd12:
356 case 0x912:
357 case 0x112:
358 case 0x913: /* Intuos3 Airbrush */
359 wacom->tool[idx] = BTN_TOOL_AIRBRUSH;
360 break;
361 default: /* Unknown tool */
362 wacom->tool[idx] = BTN_TOOL_PEN;
364 return 1;
367 /* Exit report */
368 if ((data[1] & 0xfe) == 0x80) {
369 wacom_report_abs(wcombo, ABS_X, 0);
370 wacom_report_abs(wcombo, ABS_Y, 0);
371 wacom_report_abs(wcombo, ABS_DISTANCE, 0);
372 if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
373 wacom_report_key(wcombo, BTN_LEFT, 0);
374 wacom_report_key(wcombo, BTN_MIDDLE, 0);
375 wacom_report_key(wcombo, BTN_RIGHT, 0);
376 wacom_report_key(wcombo, BTN_SIDE, 0);
377 wacom_report_key(wcombo, BTN_EXTRA, 0);
378 wacom_report_abs(wcombo, ABS_THROTTLE, 0);
379 wacom_report_abs(wcombo, ABS_RZ, 0);
380 } else {
381 wacom_report_abs(wcombo, ABS_PRESSURE, 0);
382 wacom_report_abs(wcombo, ABS_TILT_X, 0);
383 wacom_report_abs(wcombo, ABS_TILT_Y, 0);
384 wacom_report_key(wcombo, BTN_STYLUS, 0);
385 wacom_report_key(wcombo, BTN_STYLUS2, 0);
386 wacom_report_key(wcombo, BTN_TOUCH, 0);
387 wacom_report_abs(wcombo, ABS_WHEEL, 0);
389 wacom_report_key(wcombo, wacom->tool[idx], 0);
390 wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */
391 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
392 return 2;
394 return 0;
397 static void wacom_intuos_general(struct wacom_wac *wacom, void *wcombo)
399 unsigned char *data = wacom->data;
400 unsigned int t;
402 /* general pen packet */
403 if ((data[1] & 0xb8) == 0xa0) {
404 t = (data[6] << 2) | ((data[7] >> 6) & 3);
405 wacom_report_abs(wcombo, ABS_PRESSURE, t);
406 wacom_report_abs(wcombo, ABS_TILT_X,
407 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
408 wacom_report_abs(wcombo, ABS_TILT_Y, data[8] & 0x7f);
409 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 2);
410 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 4);
411 wacom_report_key(wcombo, BTN_TOUCH, t > 10);
414 /* airbrush second packet */
415 if ((data[1] & 0xbc) == 0xb4) {
416 wacom_report_abs(wcombo, ABS_WHEEL,
417 (data[6] << 2) | ((data[7] >> 6) & 3));
418 wacom_report_abs(wcombo, ABS_TILT_X,
419 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
420 wacom_report_abs(wcombo, ABS_TILT_Y, data[8] & 0x7f);
422 return;
425 static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
427 unsigned char *data = wacom->data;
428 unsigned int t;
429 int idx, result;
431 if (data[0] != 2 && data[0] != 5 && data[0] != 6 && data[0] != 12) {
432 dbg("wacom_intuos_irq: received unknown report #%d", data[0]);
433 return 0;
436 /* tool number */
437 idx = data[1] & 0x01;
439 /* pad packets. Works as a second tool and is always in prox */
440 if (data[0] == 12) {
441 /* initiate the pad as a device */
442 if (wacom->tool[1] != BTN_TOOL_FINGER)
443 wacom->tool[1] = BTN_TOOL_FINGER;
445 wacom_report_key(wcombo, BTN_0, (data[5] & 0x01));
446 wacom_report_key(wcombo, BTN_1, (data[5] & 0x02));
447 wacom_report_key(wcombo, BTN_2, (data[5] & 0x04));
448 wacom_report_key(wcombo, BTN_3, (data[5] & 0x08));
449 wacom_report_key(wcombo, BTN_4, (data[6] & 0x01));
450 wacom_report_key(wcombo, BTN_5, (data[6] & 0x02));
451 wacom_report_key(wcombo, BTN_6, (data[6] & 0x04));
452 wacom_report_key(wcombo, BTN_7, (data[6] & 0x08));
453 <<<<<<< HEAD:drivers/input/tablet/wacom_wac.c
454 =======
455 wacom_report_key(wcombo, BTN_8, (data[5] & 0x10));
456 wacom_report_key(wcombo, BTN_9, (data[6] & 0x10));
457 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/input/tablet/wacom_wac.c
458 wacom_report_abs(wcombo, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
459 wacom_report_abs(wcombo, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
461 <<<<<<< HEAD:drivers/input/tablet/wacom_wac.c
462 if((data[5] & 0x0f) | (data[6] & 0x0f) | (data[1] & 0x1f) |
463 =======
464 if ((data[5] & 0x1f) | (data[6] & 0x1f) | (data[1] & 0x1f) |
465 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/input/tablet/wacom_wac.c
466 data[2] | (data[3] & 0x1f) | data[4])
467 wacom_report_key(wcombo, wacom->tool[1], 1);
468 else
469 wacom_report_key(wcombo, wacom->tool[1], 0);
470 wacom_report_abs(wcombo, ABS_MISC, PAD_DEVICE_ID);
471 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xffffffff);
472 return 1;
475 /* process in/out prox events */
476 result = wacom_intuos_inout(wacom, wcombo);
477 if (result)
478 return result-1;
480 /* Only large I3 and I1 & I2 support Lense Cursor */
481 if ((wacom->tool[idx] == BTN_TOOL_LENS)
482 && ((wacom->features->type == INTUOS3)
483 || (wacom->features->type == INTUOS3S)))
484 return 0;
486 /* Cintiq doesn't send data when RDY bit isn't set */
487 if ((wacom->features->type == CINTIQ) && !(data[1] & 0x40))
488 return 0;
490 if (wacom->features->type >= INTUOS3S) {
491 wacom_report_abs(wcombo, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
492 wacom_report_abs(wcombo, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
493 wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
494 } else {
495 wacom_report_abs(wcombo, ABS_X, wacom_be16_to_cpu(&data[2]));
496 wacom_report_abs(wcombo, ABS_Y, wacom_be16_to_cpu(&data[4]));
497 wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 3) & 0x1f));
500 /* process general packets */
501 wacom_intuos_general(wacom, wcombo);
503 /* 4D mouse, 2D mouse, marker pen rotation, or Lens cursor packets */
504 if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0) {
506 if (data[1] & 0x02) {
507 /* Rotation packet */
508 if (wacom->features->type >= INTUOS3S) {
509 <<<<<<< HEAD:drivers/input/tablet/wacom_wac.c
510 /* I3 marker pen rotation reported as wheel
511 * due to valuator limitation
513 =======
514 /* I3 marker pen rotation */
515 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/input/tablet/wacom_wac.c
516 t = (data[6] << 3) | ((data[7] >> 5) & 7);
517 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
518 ((t-1) / 2 + 450)) : (450 - t / 2) ;
519 <<<<<<< HEAD:drivers/input/tablet/wacom_wac.c
520 wacom_report_abs(wcombo, ABS_WHEEL, t);
521 =======
522 wacom_report_abs(wcombo, ABS_Z, t);
523 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/input/tablet/wacom_wac.c
524 } else {
525 /* 4D mouse rotation packet */
526 t = (data[6] << 3) | ((data[7] >> 5) & 7);
527 wacom_report_abs(wcombo, ABS_RZ, (data[7] & 0x20) ?
528 ((t - 1) / 2) : -t / 2);
531 } else if (!(data[1] & 0x10) && wacom->features->type < INTUOS3S) {
532 /* 4D mouse packet */
533 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
534 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02);
535 wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x04);
537 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x20);
538 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x10);
539 t = (data[6] << 2) | ((data[7] >> 6) & 3);
540 wacom_report_abs(wcombo, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
542 } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
543 /* 2D mouse packet */
544 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x04);
545 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x08);
546 wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x10);
547 wacom_report_rel(wcombo, REL_WHEEL, (data[8] & 0x01)
548 - ((data[8] & 0x02) >> 1));
550 /* I3 2D mouse side buttons */
551 if (wacom->features->type >= INTUOS3S && wacom->features->type <= INTUOS3L) {
552 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x40);
553 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x20);
556 } else if (wacom->features->type < INTUOS3S || wacom->features->type == INTUOS3L) {
557 /* Lens cursor packets */
558 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
559 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02);
560 wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x04);
561 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x10);
562 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x08);
566 wacom_report_abs(wcombo, ABS_MISC, wacom->id[idx]); /* report tool id */
567 wacom_report_key(wcombo, wacom->tool[idx], 1);
568 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
569 return 1;
572 int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo)
574 switch (wacom_wac->features->type) {
575 case PENPARTNER:
576 return (wacom_penpartner_irq(wacom_wac, wcombo));
577 break;
578 case PL:
579 return (wacom_pl_irq(wacom_wac, wcombo));
580 break;
581 case WACOM_G4:
582 case GRAPHIRE:
583 case WACOM_MO:
584 return (wacom_graphire_irq(wacom_wac, wcombo));
585 break;
586 case PTU:
587 return (wacom_ptu_irq(wacom_wac, wcombo));
588 break;
589 case INTUOS:
590 case INTUOS3S:
591 case INTUOS3:
592 case INTUOS3L:
593 case CINTIQ:
594 <<<<<<< HEAD:drivers/input/tablet/wacom_wac.c
595 =======
596 case WACOM_BEE:
597 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/input/tablet/wacom_wac.c
598 return (wacom_intuos_irq(wacom_wac, wcombo));
599 break;
600 default:
601 return 0;
603 return 0;
606 void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
608 switch (wacom_wac->features->type) {
609 case WACOM_MO:
610 input_dev_mo(input_dev, wacom_wac);
611 case WACOM_G4:
612 input_dev_g4(input_dev, wacom_wac);
613 /* fall through */
614 case GRAPHIRE:
615 input_dev_g(input_dev, wacom_wac);
616 break;
617 <<<<<<< HEAD:drivers/input/tablet/wacom_wac.c
618 =======
619 case WACOM_BEE:
620 input_dev_bee(input_dev, wacom_wac);
621 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/input/tablet/wacom_wac.c
622 case INTUOS3:
623 case INTUOS3L:
624 case CINTIQ:
625 input_dev_i3(input_dev, wacom_wac);
626 /* fall through */
627 case INTUOS3S:
628 input_dev_i3s(input_dev, wacom_wac);
629 case INTUOS:
630 input_dev_i(input_dev, wacom_wac);
631 break;
632 case PL:
633 case PTU:
634 input_dev_pl(input_dev, wacom_wac);
635 break;
636 case PENPARTNER:
637 input_dev_pt(input_dev, wacom_wac);
638 break;
640 return;
643 static struct wacom_features wacom_features[] = {
644 { "Wacom Penpartner", 7, 5040, 3780, 255, 0, PENPARTNER },
645 { "Wacom Graphire", 8, 10206, 7422, 511, 63, GRAPHIRE },
646 { "Wacom Graphire2 4x5", 8, 10206, 7422, 511, 63, GRAPHIRE },
647 { "Wacom Graphire2 5x7", 8, 13918, 10206, 511, 63, GRAPHIRE },
648 { "Wacom Graphire3", 8, 10208, 7424, 511, 63, GRAPHIRE },
649 { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 63, GRAPHIRE },
650 { "Wacom Graphire4 4x5", 8, 10208, 7424, 511, 63, WACOM_G4 },
651 { "Wacom Graphire4 6x8", 8, 16704, 12064, 511, 63, WACOM_G4 },
652 <<<<<<< HEAD:drivers/input/tablet/wacom_wac.c
653 =======
654 { "Wacom BambooFun 4x5", 9, 14760, 9225, 511, 63, WACOM_MO },
655 { "Wacom BambooFun 6x8", 9, 21648, 13530, 511, 63, WACOM_MO },
656 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/input/tablet/wacom_wac.c
657 { "Wacom Volito", 8, 5104, 3712, 511, 63, GRAPHIRE },
658 { "Wacom PenStation2", 8, 3250, 2320, 255, 63, GRAPHIRE },
659 { "Wacom Volito2 4x5", 8, 5104, 3712, 511, 63, GRAPHIRE },
660 { "Wacom Volito2 2x3", 8, 3248, 2320, 511, 63, GRAPHIRE },
661 <<<<<<< HEAD:drivers/input/tablet/wacom_wac.c
662 { "Wacom PenPartner2", 8, 3250, 2320, 255, 63, GRAPHIRE },
663 =======
664 { "Wacom PenPartner2", 8, 3250, 2320, 511, 63, GRAPHIRE },
665 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/input/tablet/wacom_wac.c
666 { "Wacom Bamboo", 9, 14760, 9225, 511, 63, WACOM_MO },
667 <<<<<<< HEAD:drivers/input/tablet/wacom_wac.c
668 =======
669 { "Wacom Bamboo1", 8, 5104, 3712, 511, 63, GRAPHIRE },
670 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/input/tablet/wacom_wac.c
671 { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 31, INTUOS },
672 { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 31, INTUOS },
673 { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 31, INTUOS },
674 { "Wacom Intuos 12x12", 10, 30480, 31680, 1023, 31, INTUOS },
675 { "Wacom Intuos 12x18", 10, 45720, 31680, 1023, 31, INTUOS },
676 { "Wacom PL400", 8, 5408, 4056, 255, 0, PL },
677 { "Wacom PL500", 8, 6144, 4608, 255, 0, PL },
678 { "Wacom PL600", 8, 6126, 4604, 255, 0, PL },
679 { "Wacom PL600SX", 8, 6260, 5016, 255, 0, PL },
680 { "Wacom PL550", 8, 6144, 4608, 511, 0, PL },
681 { "Wacom PL800", 8, 7220, 5780, 511, 0, PL },
682 { "Wacom PL700", 8, 6758, 5406, 511, 0, PL },
683 { "Wacom PL510", 8, 6282, 4762, 511, 0, PL },
684 { "Wacom DTU710", 8, 34080, 27660, 511, 0, PL },
685 { "Wacom DTF521", 8, 6282, 4762, 511, 0, PL },
686 { "Wacom DTF720", 8, 6858, 5506, 511, 0, PL },
687 { "Wacom Cintiq Partner",8, 20480, 15360, 511, 0, PTU },
688 { "Wacom Intuos2 4x5", 10, 12700, 10600, 1023, 31, INTUOS },
689 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 31, INTUOS },
690 { "Wacom Intuos2 9x12", 10, 30480, 24060, 1023, 31, INTUOS },
691 { "Wacom Intuos2 12x12", 10, 30480, 31680, 1023, 31, INTUOS },
692 { "Wacom Intuos2 12x18", 10, 45720, 31680, 1023, 31, INTUOS },
693 { "Wacom Intuos3 4x5", 10, 25400, 20320, 1023, 63, INTUOS3S },
694 { "Wacom Intuos3 6x8", 10, 40640, 30480, 1023, 63, INTUOS3 },
695 { "Wacom Intuos3 9x12", 10, 60960, 45720, 1023, 63, INTUOS3 },
696 { "Wacom Intuos3 12x12", 10, 60960, 60960, 1023, 63, INTUOS3L },
697 { "Wacom Intuos3 12x19", 10, 97536, 60960, 1023, 63, INTUOS3L },
698 { "Wacom Intuos3 6x11", 10, 54204, 31750, 1023, 63, INTUOS3 },
699 { "Wacom Intuos3 4x6", 10, 31496, 19685, 1023, 63, INTUOS3S },
700 { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 63, CINTIQ },
701 <<<<<<< HEAD:drivers/input/tablet/wacom_wac.c
702 =======
703 { "Wacom Cintiq 12WX", 10, 53020, 33440, 1023, 63, WACOM_BEE },
704 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/input/tablet/wacom_wac.c
705 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 31, INTUOS },
709 static struct usb_device_id wacom_ids[] = {
710 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x00) },
711 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x10) },
712 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x11) },
713 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x12) },
714 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x13) },
715 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x14) },
716 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x15) },
717 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x16) },
718 <<<<<<< HEAD:drivers/input/tablet/wacom_wac.c
719 =======
720 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x17) },
721 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x18) },
722 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/input/tablet/wacom_wac.c
723 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60) },
724 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x61) },
725 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x62) },
726 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x63) },
727 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x64) },
728 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x65) },
729 <<<<<<< HEAD:drivers/input/tablet/wacom_wac.c
730 =======
731 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x69) },
732 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/input/tablet/wacom_wac.c
733 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x20) },
734 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x21) },
735 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x22) },
736 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x23) },
737 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x24) },
738 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x30) },
739 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x31) },
740 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x32) },
741 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x33) },
742 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x34) },
743 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x35) },
744 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x37) },
745 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x38) },
746 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x39) },
747 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC0) },
748 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC4) },
749 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x03) },
750 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x41) },
751 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x42) },
752 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x43) },
753 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x44) },
754 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x45) },
755 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB0) },
756 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB1) },
757 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB2) },
758 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB3) },
759 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB4) },
760 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB5) },
761 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB7) },
762 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) },
763 <<<<<<< HEAD:drivers/input/tablet/wacom_wac.c
764 =======
765 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC6) },
766 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/input/tablet/wacom_wac.c
767 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) },
771 const struct usb_device_id * get_device_table(void) {
772 const struct usb_device_id * id_table = wacom_ids;
773 return id_table;
776 struct wacom_features * get_wacom_feature(const struct usb_device_id * id) {
777 int index = id - wacom_ids;
778 struct wacom_features *wf = &wacom_features[index];
779 return wf;
782 MODULE_DEVICE_TABLE(usb, wacom_ids);