This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / drivers / usb / input / wacom_wac.c
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                         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);
38                         }
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;
52         }
53         return 1;
54 }
55
56 static int wacom_pl_irq(struct wacom_wac *wacom, void *wcombo)
57 {
58         unsigned char *data = wacom->data;
59         int prox, id, pressure;
60
61         if (data[0] != 2) {
62                 dbg("wacom_pl_irq: received unknown report #%d", data[0]);
63                 return 0;
64         }
65
66         prox = data[1] & 0x40;
67
68         id = ERASER_DEVICE_ID;
69         if (prox) {
70
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;
75
76                 /*
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.
81                  */
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;
97                         }
98                 }
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;
103                 }
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);
109
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;
119                 }
120                 wacom_report_key(wcombo, wacom->tool[1], prox);
121         }
122
123         wacom->tool[0] = prox; /* Save proximity state */
124         return 1;
125 }
126
127 static int wacom_ptu_irq(struct wacom_wac *wacom, void *wcombo)
128 {
129         unsigned char *data = wacom->data;
130         int id;
131
132         if (data[0] != 2) {
133                 printk(KERN_INFO "wacom_ptu_irq: received unknown report #%d\n", data[0]);
134                 return 0;
135         }
136
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;
145         }
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;
153 }
154
155 static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
156 {
157         unsigned char *data = wacom->data;
158         int x, y, id, rw;
159
160         if (data[0] != 2) {
161                 dbg("wacom_graphire_irq: received unknown report #%d", data[0]);
162                 return 0;
163         }
164
165         id = STYLUS_DEVICE_ID;
166         if (data[1] & 0x10) { /* in prox */
167
168                 switch ((data[1] >> 5) & 3) {
169
170                         case 0: /* Pen */
171                                 wacom->tool[0] = BTN_TOOL_PEN;
172                                 break;
173
174                         case 1: /* Rubber */
175                                 wacom->tool[0] = BTN_TOOL_RUBBER;
176                                 id = ERASER_DEVICE_ID;
177                                 break;
178
179                         case 2: /* Mouse with wheel */
180                                 wacom_report_key(wcombo, BTN_MIDDLE, data[1] & 0x04);
181                                 if (wacom->features->type == WACOM_G4) {
182                                         rw = data[7] & 0x04 ? (data[7] & 0x03)-4 : (data[7] & 0x03);
183                                         wacom_report_rel(wcombo, REL_WHEEL, -rw);
184                                 } else
185                                         wacom_report_rel(wcombo, REL_WHEEL, -(signed char) data[6]);
186                                 /* fall through */
187
188                         case 3: /* Mouse without wheel */
189                                 wacom->tool[0] = BTN_TOOL_MOUSE;
190                                 id = CURSOR_DEVICE_ID;
191                                 wacom_report_key(wcombo, BTN_LEFT, data[1] & 0x01);
192                                 wacom_report_key(wcombo, BTN_RIGHT, data[1] & 0x02);
193                                 if (wacom->features->type == WACOM_G4)
194                                         wacom_report_abs(wcombo, ABS_DISTANCE, data[6] & 0x3f);
195                                 else
196                                         wacom_report_abs(wcombo, ABS_DISTANCE, data[7] & 0x3f);
197                                 break;
198                 }
199         }
200
201         if (data[1] & 0x90) {
202                 x = wacom_le16_to_cpu(&data[2]);
203                 y = wacom_le16_to_cpu(&data[4]);
204                 wacom_report_abs(wcombo, ABS_X, x);
205                 wacom_report_abs(wcombo, ABS_Y, y);
206                 if (wacom->tool[0] != BTN_TOOL_MOUSE) {
207                         wacom_report_abs(wcombo, ABS_PRESSURE, data[6] | ((data[7] & 0x01) << 8));
208                         wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x01);
209                         wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02);
210                         wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x04);
211                 }
212                 wacom_report_abs(wcombo, ABS_MISC, id); /* report tool id */
213         }
214         else
215                 wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */
216
217         if (data[1] & 0x10)  /* only report prox-in when in area */
218                 wacom_report_key(wcombo, wacom->tool[0], 1);
219         if (!(data[1] & 0x90))  /* report prox-out when physically out */
220                 wacom_report_key(wcombo, wacom->tool[0], 0);
221         wacom_input_sync(wcombo);
222
223         /* send pad data */
224         if (wacom->features->type == WACOM_G4) {
225                 if ( (wacom->serial[1] & 0xc0) != (data[7] & 0xf8) ) {
226                         wacom->id[1] = 1;
227                         wacom->serial[1] = (data[7] & 0xf8);
228                         wacom_report_key(wcombo, BTN_0, (data[7] & 0x40));
229                         wacom_report_key(wcombo, BTN_4, (data[7] & 0x80));
230                         rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
231                         wacom_report_rel(wcombo, REL_WHEEL, rw);
232                         wacom_report_key(wcombo, BTN_TOOL_FINGER, 0xf0);
233                         wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
234                 } else if (wacom->id[1]) {
235                         wacom->id[1] = 0;
236                         wacom_report_key(wcombo, BTN_TOOL_FINGER, 0);
237                         wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
238                 }
239         }
240         return 1;
241 }
242
243 static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
244 {
245         unsigned char *data = wacom->data;
246         int idx;
247
248         /* tool number */
249         idx = data[1] & 0x01;
250
251         /* Enter report */
252         if ((data[1] & 0xfc) == 0xc0) {
253                 /* serial number of the tool */
254                 wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
255                         (data[4] << 20) + (data[5] << 12) +
256                         (data[6] << 4) + (data[7] >> 4);
257
258                 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4);
259                 switch (wacom->id[idx]) {
260                         case 0x812: /* Inking pen */
261                         case 0x801: /* Intuos3 Inking pen */
262                         case 0x012:
263                                 wacom->tool[idx] = BTN_TOOL_PENCIL;
264                                 break;
265                         case 0x822: /* Pen */
266                         case 0x842:
267                         case 0x852:
268                         case 0x823: /* Intuos3 Grip Pen */
269                         case 0x813: /* Intuos3 Classic Pen */
270                         case 0x885: /* Intuos3 Marker Pen */
271                         case 0x022:
272                                 wacom->tool[idx] = BTN_TOOL_PEN;
273                                 break;
274                         case 0x832: /* Stroke pen */
275                         case 0x032:
276                                 wacom->tool[idx] = BTN_TOOL_BRUSH;
277                                 break;
278                         case 0x007: /* Mouse 4D and 2D */
279                         case 0x09c:
280                         case 0x094:
281                         case 0x017: /* Intuos3 2D Mouse */
282                                 wacom->tool[idx] = BTN_TOOL_MOUSE;
283                                 break;
284                         case 0x096: /* Lens cursor */
285                         case 0x097: /* Intuos3 Lens cursor */
286                                 wacom->tool[idx] = BTN_TOOL_LENS;
287                                 break;
288                         case 0x82a: /* Eraser */
289                         case 0x85a:
290                         case 0x91a:
291                         case 0xd1a:
292                         case 0x0fa:
293                         case 0x82b: /* Intuos3 Grip Pen Eraser */
294                         case 0x81b: /* Intuos3 Classic Pen Eraser */
295                         case 0x91b: /* Intuos3 Airbrush Eraser */
296                                 wacom->tool[idx] = BTN_TOOL_RUBBER;
297                                 break;
298                         case 0xd12:
299                         case 0x912:
300                         case 0x112:
301                         case 0x913: /* Intuos3 Airbrush */
302                                 wacom->tool[idx] = BTN_TOOL_AIRBRUSH;
303                                 break;
304                         default: /* Unknown tool */
305                                 wacom->tool[idx] = BTN_TOOL_PEN;
306                 }
307                 /* only large I3 support Lens Cursor */
308                 if(!((wacom->tool[idx] == BTN_TOOL_LENS)
309                                  && ((wacom->features->type == INTUOS3)
310                                  || (wacom->features->type == INTUOS3S)))) {
311                         wacom_report_abs(wcombo, ABS_MISC, wacom->id[idx]); /* report tool id */
312                         wacom_report_key(wcombo, wacom->tool[idx], 1);
313                         wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
314                         return 2;
315                 }
316                 return 1;
317         }
318
319         /* Exit report */
320         if ((data[1] & 0xfe) == 0x80) {
321                 if(!((wacom->tool[idx] == BTN_TOOL_LENS)
322                                  && ((wacom->features->type == INTUOS3)
323                                  || (wacom->features->type == INTUOS3S)))) {
324                         wacom_report_key(wcombo, wacom->tool[idx], 0);
325                         wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */
326                         wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
327                         return 2;
328                 }
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         /* tool number */
373         idx = data[1] & 0x01;
374
375         /* pad packets. Works as a second tool and is always in prox */
376         if (data[0] == 12) {
377                 /* initiate the pad as a device */
378                 if (wacom->tool[1] != BTN_TOOL_FINGER)
379                         wacom->tool[1] = BTN_TOOL_FINGER;
380
381                 wacom_report_key(wcombo, BTN_0, (data[5] & 0x01));
382                 wacom_report_key(wcombo, BTN_1, (data[5] & 0x02));
383                 wacom_report_key(wcombo, BTN_2, (data[5] & 0x04));
384                 wacom_report_key(wcombo, BTN_3, (data[5] & 0x08));
385                 wacom_report_key(wcombo, BTN_4, (data[6] & 0x01));
386                 wacom_report_key(wcombo, BTN_5, (data[6] & 0x02));
387                 wacom_report_key(wcombo, BTN_6, (data[6] & 0x04));
388                 wacom_report_key(wcombo, BTN_7, (data[6] & 0x08));
389                 wacom_report_abs(wcombo, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
390                 wacom_report_abs(wcombo, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
391
392                 if((data[5] & 0x0f) | (data[6] & 0x0f) | (data[1] & 0x1f) |
393                         data[2] | (data[3] & 0x1f) | data[4])
394                         wacom_report_key(wcombo, wacom->tool[1], 1);
395                 else
396                         wacom_report_key(wcombo, wacom->tool[1], 0);
397                 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xffffffff);
398                 return 1;
399         }
400
401         /* process in/out prox events */
402         result = wacom_intuos_inout(wacom, wcombo);
403         if (result)
404                 return result-1;
405
406         /* Cintiq doesn't send data when RDY bit isn't set */
407         if ((wacom->features->type == CINTIQ) && !(data[1] & 0x40))
408                  return 0;
409
410         if (wacom->features->type >= INTUOS3S) {
411                 wacom_report_abs(wcombo, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
412                 wacom_report_abs(wcombo, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
413                 wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
414         } else {
415                 wacom_report_abs(wcombo, ABS_X, wacom_be16_to_cpu(&data[2]));
416                 wacom_report_abs(wcombo, ABS_Y, wacom_be16_to_cpu(&data[4]));
417                 wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 3) & 0x1f));
418         }
419
420         /* process general packets */
421         wacom_intuos_general(wacom, wcombo);
422
423         /* 4D mouse, 2D mouse, marker pen rotation, or Lens cursor packets */
424         if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0) {
425
426                 if (data[1] & 0x02) {
427                         /* Rotation packet */
428                         if (wacom->features->type >= INTUOS3S) {
429                                 /* I3 marker pen rotation reported as wheel
430                                  * due to valuator limitation
431                                  */
432                                 t = (data[6] << 3) | ((data[7] >> 5) & 7);
433                                 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
434                                         ((t-1) / 2 + 450)) : (450 - t / 2) ;
435                                 wacom_report_abs(wcombo, ABS_WHEEL, t);
436                         } else {
437                                 /* 4D mouse rotation packet */
438                                 t = (data[6] << 3) | ((data[7] >> 5) & 7);
439                                 wacom_report_abs(wcombo, ABS_RZ, (data[7] & 0x20) ?
440                                         ((t - 1) / 2) : -t / 2);
441                         }
442
443                 } else if (!(data[1] & 0x10) && wacom->features->type < INTUOS3S) {
444                         /* 4D mouse packet */
445                         wacom_report_key(wcombo, BTN_LEFT,   data[8] & 0x01);
446                         wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02);
447                         wacom_report_key(wcombo, BTN_RIGHT,  data[8] & 0x04);
448
449                         wacom_report_key(wcombo, BTN_SIDE,   data[8] & 0x20);
450                         wacom_report_key(wcombo, BTN_EXTRA,  data[8] & 0x10);
451                         t = (data[6] << 2) | ((data[7] >> 6) & 3);
452                         wacom_report_abs(wcombo, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
453
454                 } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
455                         /* 2D mouse packet */
456                         wacom_report_key(wcombo, BTN_LEFT,   data[8] & 0x04);
457                         wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x08);
458                         wacom_report_key(wcombo, BTN_RIGHT,  data[8] & 0x10);
459                         wacom_report_rel(wcombo, REL_WHEEL, (data[8] & 0x01)
460                                                  - ((data[8] & 0x02) >> 1));
461
462                         /* I3 2D mouse side buttons */
463                         if (wacom->features->type >= INTUOS3S && wacom->features->type <= INTUOS3L) {
464                                 wacom_report_key(wcombo, BTN_SIDE,   data[8] & 0x40);
465                                 wacom_report_key(wcombo, BTN_EXTRA,  data[8] & 0x20);
466                         }
467
468                 } else if (wacom->features->type < INTUOS3S || wacom->features->type == INTUOS3L) {
469                         /* Lens cursor packets */
470                         wacom_report_key(wcombo, BTN_LEFT,   data[8] & 0x01);
471                         wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02);
472                         wacom_report_key(wcombo, BTN_RIGHT,  data[8] & 0x04);
473                         wacom_report_key(wcombo, BTN_SIDE,   data[8] & 0x10);
474                         wacom_report_key(wcombo, BTN_EXTRA,  data[8] & 0x08);
475                 }
476         }
477
478         wacom_report_abs(wcombo, ABS_MISC, wacom->id[idx]); /* report tool id */
479         wacom_report_key(wcombo, wacom->tool[idx], 1);
480         wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
481         return 1;
482 }
483
484 int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo)
485 {
486         switch (wacom_wac->features->type) {
487                 case PENPARTNER:
488                         return (wacom_penpartner_irq(wacom_wac, wcombo));
489                         break;
490                 case PL:
491                         return (wacom_pl_irq(wacom_wac, wcombo));
492                         break;
493                 case WACOM_G4:
494                 case GRAPHIRE:
495                         return (wacom_graphire_irq(wacom_wac, wcombo));
496                         break;
497                 case PTU:
498                         return (wacom_ptu_irq(wacom_wac, wcombo));
499                         break;
500                 case INTUOS:
501                 case INTUOS3S:
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 INTUOS3S:
528                         input_dev_i3s(input_dev, wacom_wac);
529                 case INTUOS:
530                         input_dev_i(input_dev, wacom_wac);
531                         break;
532                 case PL:
533                 case PTU:
534                         input_dev_pl(input_dev, wacom_wac);
535                         break;
536                 case PENPARTNER:
537                         input_dev_pt(input_dev, wacom_wac);
538                         break;
539         }
540         return;
541 }
542
543 static struct wacom_features wacom_features[] = {
544         { "Wacom Penpartner",    7,   5040,  3780,  255,  0, PENPARTNER },
545         { "Wacom Graphire",      8,  10206,  7422,  511, 63, GRAPHIRE },
546         { "Wacom Graphire2 4x5", 8,  10206,  7422,  511, 63, GRAPHIRE },
547         { "Wacom Graphire2 5x7", 8,  13918, 10206,  511, 63, GRAPHIRE },
548         { "Wacom Graphire3",     8,  10208,  7424,  511, 63, GRAPHIRE },
549         { "Wacom Graphire3 6x8", 8,  16704, 12064,  511, 63, GRAPHIRE },
550         { "Wacom Graphire4 4x5", 8,  10208,  7424,  511, 63, WACOM_G4 },
551         { "Wacom Graphire4 6x8", 8,  16704, 12064,  511, 63, WACOM_G4 },
552         { "Wacom Volito",        8,   5104,  3712,  511, 63, GRAPHIRE },
553         { "Wacom PenStation2",   8,   3250,  2320,  255, 63, GRAPHIRE },
554         { "Wacom Volito2 4x5",   8,   5104,  3712,  511, 63, GRAPHIRE },
555         { "Wacom Volito2 2x3",   8,   3248,  2320,  511, 63, GRAPHIRE },
556         { "Wacom PenPartner2",   8,   3250,  2320,  255, 63, GRAPHIRE },
557         { "Wacom Intuos 4x5",   10,  12700, 10600, 1023, 63, INTUOS },
558         { "Wacom Intuos 6x8",   10,  20320, 16240, 1023, 63, INTUOS },
559         { "Wacom Intuos 9x12",  10,  30480, 24060, 1023, 63, INTUOS },
560         { "Wacom Intuos 12x12", 10,  30480, 31680, 1023, 63, INTUOS },
561         { "Wacom Intuos 12x18", 10,  45720, 31680, 1023, 63, INTUOS },
562         { "Wacom PL400",         8,   5408,  4056,  255,  0, PL },
563         { "Wacom PL500",         8,   6144,  4608,  255,  0, PL },
564         { "Wacom PL600",         8,   6126,  4604,  255,  0, PL },
565         { "Wacom PL600SX",       8,   6260,  5016,  255,  0, PL },
566         { "Wacom PL550",         8,   6144,  4608,  511,  0, PL },
567         { "Wacom PL800",         8,   7220,  5780,  511,  0, PL },
568         { "Wacom PL700",         8,   6758,  5406,  511,  0, PL },
569         { "Wacom PL510",         8,   6282,  4762,  511,  0, PL },
570         { "Wacom DTU710",        8,  34080, 27660,  511,  0, PL },
571         { "Wacom DTF521",        8,   6282,  4762,  511,  0, PL },
572         { "Wacom DTF720",        8,   6858,  5506,  511,  0, PL },
573         { "Wacom Cintiq Partner",8,  20480, 15360,  511,  0, PTU },
574         { "Wacom Intuos2 4x5",   10, 12700, 10600, 1023, 63, INTUOS },
575         { "Wacom Intuos2 6x8",   10, 20320, 16240, 1023, 63, INTUOS },
576         { "Wacom Intuos2 9x12",  10, 30480, 24060, 1023, 63, INTUOS },
577         { "Wacom Intuos2 12x12", 10, 30480, 31680, 1023, 63, INTUOS },
578         { "Wacom Intuos2 12x18", 10, 45720, 31680, 1023, 63, INTUOS },
579         { "Wacom Intuos3 4x5",   10, 25400, 20320, 1023, 63, INTUOS3S },
580         { "Wacom Intuos3 6x8",   10, 40640, 30480, 1023, 63, INTUOS3 },
581         { "Wacom Intuos3 9x12",  10, 60960, 45720, 1023, 63, INTUOS3 },
582         { "Wacom Intuos3 12x12", 10, 60960, 60960, 1023, 63, INTUOS3L },
583         { "Wacom Intuos3 12x19", 10, 97536, 60960, 1023, 63, INTUOS3L },
584         { "Wacom Intuos3 6x11",  10, 54204, 31750, 1023, 63, INTUOS3 },
585         { "Wacom Intuos3 4x6",   10, 31496, 19685, 1023, 63, INTUOS3S },
586         { "Wacom Cintiq 21UX",   10, 87200, 65600, 1023, 63, CINTIQ },
587         { "Wacom Intuos2 6x8",   10, 20320, 16240, 1023, 63, INTUOS },
588         { }
589 };
590
591 static struct usb_device_id wacom_ids[] = {
592         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x00) },
593         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x10) },
594         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x11) },
595         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x12) },
596         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x13) },
597         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x14) },
598         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x15) },
599         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x16) },
600         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60) },
601         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x61) },
602         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x62) },
603         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x63) },
604         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x64) },
605         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x20) },
606         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x21) },
607         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x22) },
608         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x23) },
609         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x24) },
610         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x30) },
611         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x31) },
612         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x32) },
613         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x33) },
614         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x34) },
615         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x35) },
616         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x37) },
617         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x38) },
618         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x39) },
619         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC0) },
620         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC4) },
621         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x03) },
622         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x41) },
623         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x42) },
624         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x43) },
625         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x44) },
626         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x45) },
627         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB0) },
628         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB1) },
629         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB2) },
630         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB3) },
631         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB4) },
632         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB5) },
633         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB7) },
634         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) },
635         { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) },
636         { }
637 };
638
639 const struct usb_device_id * get_device_table(void) {
640         const struct usb_device_id * id_table = wacom_ids;
641         return id_table;
642 }
643
644 struct wacom_features * get_wacom_feature(const struct usb_device_id * id) {
645         int index = id - wacom_ids;
646         struct wacom_features *wf = &wacom_features[index];
647         return wf;
648 }
649
650 MODULE_DEVICE_TABLE(usb, wacom_ids);