blob: e4e8c3636940ed16ac35f54dfd2d575a65bab65c [file] [log] [blame]
Ping Cheng3bea7332006-07-13 18:01:36 -07001/*
Dmitry Torokhov4104d132007-05-07 16:16:29 -04002 * drivers/input/tablet/wacom_wac.c
Ping Cheng3bea7332006-07-13 18:01:36 -07003 *
Ping Chengee545002009-12-15 00:35:24 -08004 * USB Wacom tablet support - Wacom specific code
Ping Cheng3bea7332006-07-13 18:01:36 -07005 *
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
17static 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:
Ping Cheng3bea7332006-07-13 18:01:36 -070023 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:
Ping Cheng3bea7332006-07-13 18:01:36 -070041 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
56static int wacom_pl_irq(struct wacom_wac *wacom, void *wcombo)
57{
58 unsigned char *data = wacom->data;
Ping Chenge34b9d22008-05-05 11:36:41 -040059 int prox, pressure;
Ping Cheng3bea7332006-07-13 18:01:36 -070060
Ping Chengcad74702009-12-15 00:35:25 -080061 if (data[0] != WACOM_REPORT_PENABLED) {
Ping Cheng3bea7332006-07-13 18:01:36 -070062 dbg("wacom_pl_irq: received unknown report #%d", data[0]);
63 return 0;
64 }
65
66 prox = data[1] & 0x40;
67
Ping Cheng3bea7332006-07-13 18:01:36 -070068 if (prox) {
Ping Chengec67bbe2009-12-15 00:35:24 -080069 wacom->id[0] = ERASER_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -070070 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
71 if (wacom->features->pressure_max > 255)
72 pressure = (pressure << 1) | ((data[4] >> 6) & 1);
73 pressure += (wacom->features->pressure_max + 1) / 2;
74
75 /*
76 * if going from out of proximity into proximity select between the eraser
77 * and the pen based on the state of the stylus2 button, choose eraser if
78 * pressed else choose pen. if not a proximity change from out to in, send
79 * an out of proximity for previous tool then a in for new tool.
80 */
81 if (!wacom->tool[0]) {
82 /* Eraser bit set for DTF */
83 if (data[1] & 0x10)
84 wacom->tool[1] = BTN_TOOL_RUBBER;
85 else
86 /* Going into proximity select tool */
87 wacom->tool[1] = (data[4] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
88 } else {
89 /* was entered with stylus2 pressed */
90 if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
91 /* report out proximity for previous tool */
92 wacom_report_key(wcombo, wacom->tool[1], 0);
93 wacom_input_sync(wcombo);
94 wacom->tool[1] = BTN_TOOL_PEN;
95 return 0;
96 }
97 }
98 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
99 /* Unknown tool selected default to pen tool */
100 wacom->tool[1] = BTN_TOOL_PEN;
Ping Chenge34b9d22008-05-05 11:36:41 -0400101 wacom->id[0] = STYLUS_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700102 }
103 wacom_report_key(wcombo, wacom->tool[1], prox); /* report in proximity for tool */
Ping Chenge34b9d22008-05-05 11:36:41 -0400104 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); /* report tool id */
Ping Cheng3bea7332006-07-13 18:01:36 -0700105 wacom_report_abs(wcombo, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
106 wacom_report_abs(wcombo, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
107 wacom_report_abs(wcombo, ABS_PRESSURE, pressure);
108
109 wacom_report_key(wcombo, BTN_TOUCH, data[4] & 0x08);
110 wacom_report_key(wcombo, BTN_STYLUS, data[4] & 0x10);
111 /* Only allow the stylus2 button to be reported for the pen tool. */
112 wacom_report_key(wcombo, BTN_STYLUS2, (wacom->tool[1] == BTN_TOOL_PEN) && (data[4] & 0x20));
113 } else {
114 /* report proximity-out of a (valid) tool */
115 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
116 /* Unknown tool selected default to pen tool */
117 wacom->tool[1] = BTN_TOOL_PEN;
118 }
119 wacom_report_key(wcombo, wacom->tool[1], prox);
120 }
121
122 wacom->tool[0] = prox; /* Save proximity state */
123 return 1;
124}
125
126static int wacom_ptu_irq(struct wacom_wac *wacom, void *wcombo)
127{
128 unsigned char *data = wacom->data;
Ping Cheng3bea7332006-07-13 18:01:36 -0700129
Ping Chengcad74702009-12-15 00:35:25 -0800130 if (data[0] != WACOM_REPORT_PENABLED) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700131 printk(KERN_INFO "wacom_ptu_irq: received unknown report #%d\n", data[0]);
132 return 0;
133 }
134
Ping Cheng3bea7332006-07-13 18:01:36 -0700135 if (data[1] & 0x04) {
136 wacom_report_key(wcombo, BTN_TOOL_RUBBER, data[1] & 0x20);
137 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x08);
Ping Chenge34b9d22008-05-05 11:36:41 -0400138 wacom->id[0] = ERASER_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700139 } else {
140 wacom_report_key(wcombo, BTN_TOOL_PEN, data[1] & 0x20);
141 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x01);
Ping Chenge34b9d22008-05-05 11:36:41 -0400142 wacom->id[0] = STYLUS_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700143 }
Ping Chenge34b9d22008-05-05 11:36:41 -0400144 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); /* report tool id */
Ping Cheng3bea7332006-07-13 18:01:36 -0700145 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[2]));
146 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4]));
147 wacom_report_abs(wcombo, ABS_PRESSURE, wacom_le16_to_cpu(&data[6]));
148 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02);
149 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x10);
150 return 1;
151}
152
153static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
154{
155 unsigned char *data = wacom->data;
Ping Chenge34b9d22008-05-05 11:36:41 -0400156 int x, y, rw;
Ping Cheng3bea7332006-07-13 18:01:36 -0700157
Ping Chengcad74702009-12-15 00:35:25 -0800158 if (data[0] != WACOM_REPORT_PENABLED) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700159 dbg("wacom_graphire_irq: received unknown report #%d", data[0]);
160 return 0;
161 }
162
Ping Chenge34b9d22008-05-05 11:36:41 -0400163 if (data[1] & 0x80) {
Ping Cheng0e1763f2008-03-13 16:46:46 -0400164 /* in prox and not a pad data */
Ping Cheng3bea7332006-07-13 18:01:36 -0700165
166 switch ((data[1] >> 5) & 3) {
167
168 case 0: /* Pen */
169 wacom->tool[0] = BTN_TOOL_PEN;
Ping Chenge34b9d22008-05-05 11:36:41 -0400170 wacom->id[0] = STYLUS_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700171 break;
172
173 case 1: /* Rubber */
174 wacom->tool[0] = BTN_TOOL_RUBBER;
Ping Chenge34b9d22008-05-05 11:36:41 -0400175 wacom->id[0] = ERASER_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700176 break;
177
178 case 2: /* Mouse with wheel */
179 wacom_report_key(wcombo, BTN_MIDDLE, data[1] & 0x04);
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400180 if (wacom->features->type == WACOM_G4 ||
181 wacom->features->type == WACOM_MO) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700182 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;
Ping Chenge34b9d22008-05-05 11:36:41 -0400190 wacom->id[0] = CURSOR_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700191 wacom_report_key(wcombo, BTN_LEFT, data[1] & 0x01);
192 wacom_report_key(wcombo, BTN_RIGHT, data[1] & 0x02);
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400193 if (wacom->features->type == WACOM_G4 ||
194 wacom->features->type == WACOM_MO)
Ping Cheng8d32e3a2006-09-26 13:34:47 -0700195 wacom_report_abs(wcombo, ABS_DISTANCE, data[6] & 0x3f);
Ping Cheng3bea7332006-07-13 18:01:36 -0700196 else
Ping Cheng8d32e3a2006-09-26 13:34:47 -0700197 wacom_report_abs(wcombo, ABS_DISTANCE, data[7] & 0x3f);
Ping Cheng3bea7332006-07-13 18:01:36 -0700198 break;
199 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700200 x = wacom_le16_to_cpu(&data[2]);
201 y = wacom_le16_to_cpu(&data[4]);
202 wacom_report_abs(wcombo, ABS_X, x);
203 wacom_report_abs(wcombo, ABS_Y, y);
204 if (wacom->tool[0] != BTN_TOOL_MOUSE) {
205 wacom_report_abs(wcombo, ABS_PRESSURE, data[6] | ((data[7] & 0x01) << 8));
206 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x01);
207 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02);
208 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x04);
209 }
Ping Chenge34b9d22008-05-05 11:36:41 -0400210 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); /* report tool id */
Ping Cheng071e0a22006-12-05 17:09:51 -0800211 wacom_report_key(wcombo, wacom->tool[0], 1);
Ping Chenge34b9d22008-05-05 11:36:41 -0400212 } else if (wacom->id[0]) {
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800213 wacom_report_abs(wcombo, ABS_X, 0);
214 wacom_report_abs(wcombo, ABS_Y, 0);
215 if (wacom->tool[0] == BTN_TOOL_MOUSE) {
216 wacom_report_key(wcombo, BTN_LEFT, 0);
217 wacom_report_key(wcombo, BTN_RIGHT, 0);
218 wacom_report_abs(wcombo, ABS_DISTANCE, 0);
219 } else {
220 wacom_report_abs(wcombo, ABS_PRESSURE, 0);
221 wacom_report_key(wcombo, BTN_TOUCH, 0);
222 wacom_report_key(wcombo, BTN_STYLUS, 0);
223 wacom_report_key(wcombo, BTN_STYLUS2, 0);
224 }
Ping Chenge34b9d22008-05-05 11:36:41 -0400225 wacom->id[0] = 0;
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800226 wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */
Ping Cheng071e0a22006-12-05 17:09:51 -0800227 wacom_report_key(wcombo, wacom->tool[0], 0);
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800228 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700229
230 /* send pad data */
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400231 switch (wacom->features->type) {
232 case WACOM_G4:
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800233 if (data[7] & 0xf8) {
234 wacom_input_sync(wcombo); /* sync last event */
Ping Chenge34b9d22008-05-05 11:36:41 -0400235 wacom->id[1] = PAD_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700236 wacom_report_key(wcombo, BTN_0, (data[7] & 0x40));
237 wacom_report_key(wcombo, BTN_4, (data[7] & 0x80));
238 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
239 wacom_report_rel(wcombo, REL_WHEEL, rw);
240 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0xf0);
Ping Chenge34b9d22008-05-05 11:36:41 -0400241 wacom_report_abs(wcombo, ABS_MISC, wacom->id[1]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700242 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
243 } else if (wacom->id[1]) {
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800244 wacom_input_sync(wcombo); /* sync last event */
Ping Cheng3bea7332006-07-13 18:01:36 -0700245 wacom->id[1] = 0;
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800246 wacom_report_key(wcombo, BTN_0, (data[7] & 0x40));
247 wacom_report_key(wcombo, BTN_4, (data[7] & 0x80));
Ping Cheng3bea7332006-07-13 18:01:36 -0700248 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0);
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800249 wacom_report_abs(wcombo, ABS_MISC, 0);
Ping Cheng3bea7332006-07-13 18:01:36 -0700250 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
251 }
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400252 break;
253 case WACOM_MO:
Ping Cheng0e1763f2008-03-13 16:46:46 -0400254 if ((data[7] & 0xf8) || (data[8] & 0xff)) {
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400255 wacom_input_sync(wcombo); /* sync last event */
Ping Chenge34b9d22008-05-05 11:36:41 -0400256 wacom->id[1] = PAD_DEVICE_ID;
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400257 wacom_report_key(wcombo, BTN_0, (data[7] & 0x08));
258 wacom_report_key(wcombo, BTN_1, (data[7] & 0x20));
259 wacom_report_key(wcombo, BTN_4, (data[7] & 0x10));
260 wacom_report_key(wcombo, BTN_5, (data[7] & 0x40));
261 wacom_report_abs(wcombo, ABS_WHEEL, (data[8] & 0x7f));
262 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0xf0);
Ping Chenge34b9d22008-05-05 11:36:41 -0400263 wacom_report_abs(wcombo, ABS_MISC, wacom->id[1]);
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400264 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
265 } else if (wacom->id[1]) {
266 wacom_input_sync(wcombo); /* sync last event */
267 wacom->id[1] = 0;
268 wacom_report_key(wcombo, BTN_0, (data[7] & 0x08));
269 wacom_report_key(wcombo, BTN_1, (data[7] & 0x20));
270 wacom_report_key(wcombo, BTN_4, (data[7] & 0x10));
271 wacom_report_key(wcombo, BTN_5, (data[7] & 0x40));
272 wacom_report_abs(wcombo, ABS_WHEEL, (data[8] & 0x7f));
273 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0);
274 wacom_report_abs(wcombo, ABS_MISC, 0);
275 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
276 }
277 break;
Ping Cheng3bea7332006-07-13 18:01:36 -0700278 }
279 return 1;
280}
281
282static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
283{
284 unsigned char *data = wacom->data;
Ping Cheng6f660f12009-05-08 18:30:33 -0700285 int idx = 0;
Ping Cheng3bea7332006-07-13 18:01:36 -0700286
287 /* tool number */
Ping Cheng6f660f12009-05-08 18:30:33 -0700288 if (wacom->features->type == INTUOS)
289 idx = data[1] & 0x01;
Ping Cheng3bea7332006-07-13 18:01:36 -0700290
291 /* Enter report */
292 if ((data[1] & 0xfc) == 0xc0) {
293 /* serial number of the tool */
294 wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
295 (data[4] << 20) + (data[5] << 12) +
296 (data[6] << 4) + (data[7] >> 4);
297
298 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4);
299 switch (wacom->id[idx]) {
300 case 0x812: /* Inking pen */
301 case 0x801: /* Intuos3 Inking pen */
Ping Cheng6f660f12009-05-08 18:30:33 -0700302 case 0x20802: /* Intuos4 Classic Pen */
Ping Cheng3bea7332006-07-13 18:01:36 -0700303 case 0x012:
304 wacom->tool[idx] = BTN_TOOL_PENCIL;
305 break;
306 case 0x822: /* Pen */
307 case 0x842:
308 case 0x852:
309 case 0x823: /* Intuos3 Grip Pen */
310 case 0x813: /* Intuos3 Classic Pen */
311 case 0x885: /* Intuos3 Marker Pen */
Ping Cheng6f660f12009-05-08 18:30:33 -0700312 case 0x802: /* Intuos4 Grip Pen Eraser */
313 case 0x804: /* Intuos4 Marker Pen */
314 case 0x40802: /* Intuos4 Classic Pen */
Ping Cheng3bea7332006-07-13 18:01:36 -0700315 case 0x022:
316 wacom->tool[idx] = BTN_TOOL_PEN;
317 break;
318 case 0x832: /* Stroke pen */
319 case 0x032:
320 wacom->tool[idx] = BTN_TOOL_BRUSH;
321 break;
322 case 0x007: /* Mouse 4D and 2D */
323 case 0x09c:
324 case 0x094:
325 case 0x017: /* Intuos3 2D Mouse */
Ping Cheng6f660f12009-05-08 18:30:33 -0700326 case 0x806: /* Intuos4 Mouse */
Ping Cheng3bea7332006-07-13 18:01:36 -0700327 wacom->tool[idx] = BTN_TOOL_MOUSE;
328 break;
329 case 0x096: /* Lens cursor */
330 case 0x097: /* Intuos3 Lens cursor */
Ping Cheng6f660f12009-05-08 18:30:33 -0700331 case 0x006: /* Intuos4 Lens cursor */
Ping Cheng3bea7332006-07-13 18:01:36 -0700332 wacom->tool[idx] = BTN_TOOL_LENS;
333 break;
334 case 0x82a: /* Eraser */
335 case 0x85a:
336 case 0x91a:
337 case 0xd1a:
338 case 0x0fa:
339 case 0x82b: /* Intuos3 Grip Pen Eraser */
340 case 0x81b: /* Intuos3 Classic Pen Eraser */
341 case 0x91b: /* Intuos3 Airbrush Eraser */
Ping Cheng6f660f12009-05-08 18:30:33 -0700342 case 0x80c: /* Intuos4 Marker Pen Eraser */
343 case 0x80a: /* Intuos4 Grip Pen Eraser */
344 case 0x4080a: /* Intuos4 Classic Pen Eraser */
345 case 0x90a: /* Intuos4 Airbrush Eraser */
Ping Cheng3bea7332006-07-13 18:01:36 -0700346 wacom->tool[idx] = BTN_TOOL_RUBBER;
347 break;
348 case 0xd12:
349 case 0x912:
350 case 0x112:
351 case 0x913: /* Intuos3 Airbrush */
Ping Cheng6f660f12009-05-08 18:30:33 -0700352 case 0x902: /* Intuos4 Airbrush */
Ping Cheng3bea7332006-07-13 18:01:36 -0700353 wacom->tool[idx] = BTN_TOOL_AIRBRUSH;
354 break;
355 default: /* Unknown tool */
356 wacom->tool[idx] = BTN_TOOL_PEN;
357 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700358 return 1;
359 }
360
361 /* Exit report */
362 if ((data[1] & 0xfe) == 0x80) {
Ping Cheng6f660f12009-05-08 18:30:33 -0700363 /*
364 * Reset all states otherwise we lose the initial states
365 * when in-prox next time
366 */
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800367 wacom_report_abs(wcombo, ABS_X, 0);
368 wacom_report_abs(wcombo, ABS_Y, 0);
369 wacom_report_abs(wcombo, ABS_DISTANCE, 0);
Ping Cheng6f660f12009-05-08 18:30:33 -0700370 wacom_report_abs(wcombo, ABS_TILT_X, 0);
371 wacom_report_abs(wcombo, ABS_TILT_Y, 0);
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800372 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);
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400380 } else {
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800381 wacom_report_abs(wcombo, ABS_PRESSURE, 0);
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800382 wacom_report_key(wcombo, BTN_STYLUS, 0);
383 wacom_report_key(wcombo, BTN_STYLUS2, 0);
384 wacom_report_key(wcombo, BTN_TOUCH, 0);
385 wacom_report_abs(wcombo, ABS_WHEEL, 0);
Ping Chengc413ec42009-06-28 22:50:58 -0700386 if (wacom->features->type >= INTUOS3S)
387 wacom_report_abs(wcombo, ABS_Z, 0);
Ping Cheng8d32e3a2006-09-26 13:34:47 -0700388 }
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800389 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]);
Ping Cheng6f660f12009-05-08 18:30:33 -0700392 wacom->id[idx] = 0;
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800393 return 2;
Ping Cheng3bea7332006-07-13 18:01:36 -0700394 }
395 return 0;
396}
397
398static void wacom_intuos_general(struct wacom_wac *wacom, void *wcombo)
399{
400 unsigned char *data = wacom->data;
401 unsigned int t;
402
403 /* general pen packet */
404 if ((data[1] & 0xb8) == 0xa0) {
405 t = (data[6] << 2) | ((data[7] >> 6) & 3);
Ping Cheng6f660f12009-05-08 18:30:33 -0700406 if (wacom->features->type >= INTUOS4S && wacom->features->type <= INTUOS4L)
407 t = (t << 1) | (data[1] & 1);
Ping Cheng3bea7332006-07-13 18:01:36 -0700408 wacom_report_abs(wcombo, ABS_PRESSURE, t);
409 wacom_report_abs(wcombo, ABS_TILT_X,
410 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
411 wacom_report_abs(wcombo, ABS_TILT_Y, data[8] & 0x7f);
412 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 2);
413 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 4);
414 wacom_report_key(wcombo, BTN_TOUCH, t > 10);
415 }
416
417 /* airbrush second packet */
418 if ((data[1] & 0xbc) == 0xb4) {
419 wacom_report_abs(wcombo, ABS_WHEEL,
420 (data[6] << 2) | ((data[7] >> 6) & 3));
421 wacom_report_abs(wcombo, ABS_TILT_X,
422 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
423 wacom_report_abs(wcombo, ABS_TILT_Y, data[8] & 0x7f);
424 }
425 return;
426}
427
428static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
429{
430 unsigned char *data = wacom->data;
431 unsigned int t;
Ping Cheng6f660f12009-05-08 18:30:33 -0700432 int idx = 0, result;
Ping Cheng3bea7332006-07-13 18:01:36 -0700433
Ping Chengcad74702009-12-15 00:35:25 -0800434 if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_INTUOSREAD
435 && data[0] != WACOM_REPORT_INTUOSWRITE && data[0] != WACOM_REPORT_INTUOSPAD) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700436 dbg("wacom_intuos_irq: received unknown report #%d", data[0]);
437 return 0;
438 }
439
Ping Cheng3bea7332006-07-13 18:01:36 -0700440 /* tool number */
Ping Cheng6f660f12009-05-08 18:30:33 -0700441 if (wacom->features->type == INTUOS)
442 idx = data[1] & 0x01;
Ping Cheng3bea7332006-07-13 18:01:36 -0700443
444 /* pad packets. Works as a second tool and is always in prox */
Ping Chengcad74702009-12-15 00:35:25 -0800445 if (data[0] == WACOM_REPORT_INTUOSPAD) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700446 /* initiate the pad as a device */
447 if (wacom->tool[1] != BTN_TOOL_FINGER)
448 wacom->tool[1] = BTN_TOOL_FINGER;
449
Ping Cheng6f660f12009-05-08 18:30:33 -0700450 if (wacom->features->type >= INTUOS4S && wacom->features->type <= INTUOS4L) {
451 wacom_report_key(wcombo, BTN_0, (data[2] & 0x01));
452 wacom_report_key(wcombo, BTN_1, (data[3] & 0x01));
453 wacom_report_key(wcombo, BTN_2, (data[3] & 0x02));
454 wacom_report_key(wcombo, BTN_3, (data[3] & 0x04));
455 wacom_report_key(wcombo, BTN_4, (data[3] & 0x08));
456 wacom_report_key(wcombo, BTN_5, (data[3] & 0x10));
457 wacom_report_key(wcombo, BTN_6, (data[3] & 0x20));
458 if (data[1] & 0x80) {
459 wacom_report_abs(wcombo, ABS_WHEEL, (data[1] & 0x7f));
Ping Chenga8629522009-06-02 16:59:58 -0700460 } else {
461 /* Out of proximity, clear wheel value. */
462 wacom_report_abs(wcombo, ABS_WHEEL, 0);
Ping Cheng6f660f12009-05-08 18:30:33 -0700463 }
464 if (wacom->features->type != INTUOS4S) {
465 wacom_report_key(wcombo, BTN_7, (data[3] & 0x40));
466 wacom_report_key(wcombo, BTN_8, (data[3] & 0x80));
467 }
468 if (data[1] | (data[2] & 0x01) | data[3]) {
469 wacom_report_key(wcombo, wacom->tool[1], 1);
470 wacom_report_abs(wcombo, ABS_MISC, PAD_DEVICE_ID);
471 } else {
472 wacom_report_key(wcombo, wacom->tool[1], 0);
473 wacom_report_abs(wcombo, ABS_MISC, 0);
474 }
475 } else {
476 wacom_report_key(wcombo, BTN_0, (data[5] & 0x01));
477 wacom_report_key(wcombo, BTN_1, (data[5] & 0x02));
478 wacom_report_key(wcombo, BTN_2, (data[5] & 0x04));
479 wacom_report_key(wcombo, BTN_3, (data[5] & 0x08));
480 wacom_report_key(wcombo, BTN_4, (data[6] & 0x01));
481 wacom_report_key(wcombo, BTN_5, (data[6] & 0x02));
482 wacom_report_key(wcombo, BTN_6, (data[6] & 0x04));
483 wacom_report_key(wcombo, BTN_7, (data[6] & 0x08));
484 wacom_report_key(wcombo, BTN_8, (data[5] & 0x10));
485 wacom_report_key(wcombo, BTN_9, (data[6] & 0x10));
486 wacom_report_abs(wcombo, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
487 wacom_report_abs(wcombo, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700488
Ping Cheng6f660f12009-05-08 18:30:33 -0700489 if ((data[5] & 0x1f) | (data[6] & 0x1f) | (data[1] & 0x1f) |
490 data[2] | (data[3] & 0x1f) | data[4]) {
491 wacom_report_key(wcombo, wacom->tool[1], 1);
492 wacom_report_abs(wcombo, ABS_MISC, PAD_DEVICE_ID);
493 } else {
494 wacom_report_key(wcombo, wacom->tool[1], 0);
495 wacom_report_abs(wcombo, ABS_MISC, 0);
496 }
497 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700498 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xffffffff);
499 return 1;
500 }
501
502 /* process in/out prox events */
503 result = wacom_intuos_inout(wacom, wcombo);
504 if (result)
505 return result-1;
506
Ping Cheng6f660f12009-05-08 18:30:33 -0700507 /* don't proceed if we don't know the ID */
508 if (!wacom->id[idx])
509 return 0;
510
511 /* Only large Intuos support Lense Cursor */
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400512 if ((wacom->tool[idx] == BTN_TOOL_LENS)
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800513 && ((wacom->features->type == INTUOS3)
Ping Cheng6f660f12009-05-08 18:30:33 -0700514 || (wacom->features->type == INTUOS3S)
515 || (wacom->features->type == INTUOS4)
516 || (wacom->features->type == INTUOS4S)))
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800517 return 0;
518
Ping Cheng3bea7332006-07-13 18:01:36 -0700519 /* Cintiq doesn't send data when RDY bit isn't set */
520 if ((wacom->features->type == CINTIQ) && !(data[1] & 0x40))
521 return 0;
522
Ping Cheng071e0a22006-12-05 17:09:51 -0800523 if (wacom->features->type >= INTUOS3S) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700524 wacom_report_abs(wcombo, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
525 wacom_report_abs(wcombo, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
526 wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
527 } else {
528 wacom_report_abs(wcombo, ABS_X, wacom_be16_to_cpu(&data[2]));
529 wacom_report_abs(wcombo, ABS_Y, wacom_be16_to_cpu(&data[4]));
530 wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 3) & 0x1f));
531 }
532
533 /* process general packets */
534 wacom_intuos_general(wacom, wcombo);
535
Ping Cheng6f660f12009-05-08 18:30:33 -0700536 /* 4D mouse, 2D mouse, marker pen rotation, tilt mouse, or Lens cursor packets */
537 if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0 || (data[1] & 0xbc) == 0xac) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700538
539 if (data[1] & 0x02) {
540 /* Rotation packet */
Ping Cheng071e0a22006-12-05 17:09:51 -0800541 if (wacom->features->type >= INTUOS3S) {
Ping Cheng0e1763f2008-03-13 16:46:46 -0400542 /* I3 marker pen rotation */
Ping Cheng3bea7332006-07-13 18:01:36 -0700543 t = (data[6] << 3) | ((data[7] >> 5) & 7);
544 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
545 ((t-1) / 2 + 450)) : (450 - t / 2) ;
Ping Cheng0e1763f2008-03-13 16:46:46 -0400546 wacom_report_abs(wcombo, ABS_Z, t);
Ping Cheng3bea7332006-07-13 18:01:36 -0700547 } else {
548 /* 4D mouse rotation packet */
549 t = (data[6] << 3) | ((data[7] >> 5) & 7);
550 wacom_report_abs(wcombo, ABS_RZ, (data[7] & 0x20) ?
551 ((t - 1) / 2) : -t / 2);
552 }
553
Ping Cheng8d32e3a2006-09-26 13:34:47 -0700554 } else if (!(data[1] & 0x10) && wacom->features->type < INTUOS3S) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700555 /* 4D mouse packet */
556 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
557 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02);
558 wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x04);
559
560 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x20);
561 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x10);
562 t = (data[6] << 2) | ((data[7] >> 6) & 3);
563 wacom_report_abs(wcombo, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
564
565 } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
Ping Cheng6f660f12009-05-08 18:30:33 -0700566 /* I4 mouse */
567 if (wacom->features->type >= INTUOS4S && wacom->features->type <= INTUOS4L) {
568 wacom_report_key(wcombo, BTN_LEFT, data[6] & 0x01);
569 wacom_report_key(wcombo, BTN_MIDDLE, data[6] & 0x02);
570 wacom_report_key(wcombo, BTN_RIGHT, data[6] & 0x04);
571 wacom_report_rel(wcombo, REL_WHEEL, ((data[7] & 0x80) >> 7)
572 - ((data[7] & 0x40) >> 6));
573 wacom_report_key(wcombo, BTN_SIDE, data[6] & 0x08);
574 wacom_report_key(wcombo, BTN_EXTRA, data[6] & 0x10);
575
576 wacom_report_abs(wcombo, ABS_TILT_X,
577 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
578 wacom_report_abs(wcombo, ABS_TILT_Y, data[8] & 0x7f);
579 } else {
580 /* 2D mouse packet */
581 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x04);
582 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x08);
583 wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x10);
584 wacom_report_rel(wcombo, REL_WHEEL, (data[8] & 0x01)
Ping Cheng3bea7332006-07-13 18:01:36 -0700585 - ((data[8] & 0x02) >> 1));
586
Ping Cheng6f660f12009-05-08 18:30:33 -0700587 /* I3 2D mouse side buttons */
588 if (wacom->features->type >= INTUOS3S && wacom->features->type <= INTUOS3L) {
589 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x40);
590 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x20);
591 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700592 }
Ping Cheng6f660f12009-05-08 18:30:33 -0700593 } else if ((wacom->features->type < INTUOS3S || wacom->features->type == INTUOS3L ||
594 wacom->features->type == INTUOS4L) &&
595 wacom->tool[idx] == BTN_TOOL_LENS) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700596 /* Lens cursor packets */
597 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
598 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02);
599 wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x04);
600 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x10);
601 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x08);
602 }
603 }
604
605 wacom_report_abs(wcombo, ABS_MISC, wacom->id[idx]); /* report tool id */
606 wacom_report_key(wcombo, wacom->tool[idx], 1);
607 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
608 return 1;
609}
610
Ping Chengec67bbe2009-12-15 00:35:24 -0800611
612static void wacom_tpc_finger_in(struct wacom_wac *wacom, void *wcombo, char *data, int idx)
613{
614 wacom_report_abs(wcombo, ABS_X,
615 (data[2 + idx * 2] & 0xff) | ((data[3 + idx * 2] & 0x7f) << 8));
616 wacom_report_abs(wcombo, ABS_Y,
617 (data[6 + idx * 2] & 0xff) | ((data[7 + idx * 2] & 0x7f) << 8));
618 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]);
619 wacom_report_key(wcombo, wacom->tool[idx], 1);
620 if (idx)
621 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
622 else
623 wacom_report_key(wcombo, BTN_TOUCH, 1);
624}
625
626static void wacom_tpc_touch_out(struct wacom_wac *wacom, void *wcombo, int idx)
627{
628 wacom_report_abs(wcombo, ABS_X, 0);
629 wacom_report_abs(wcombo, ABS_Y, 0);
630 wacom_report_abs(wcombo, ABS_MISC, 0);
631 wacom_report_key(wcombo, wacom->tool[idx], 0);
632 if (idx)
633 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
634 else
635 wacom_report_key(wcombo, BTN_TOUCH, 0);
636 return;
637}
638
639static void wacom_tpc_touch_in(struct wacom_wac *wacom, void *wcombo)
640{
641 char *data = wacom->data;
642 struct urb *urb = ((struct wacom_combo *)wcombo)->urb;
643 static int firstFinger = 0;
644 static int secondFinger = 0;
645
646 wacom->tool[0] = BTN_TOOL_DOUBLETAP;
647 wacom->id[0] = TOUCH_DEVICE_ID;
648 wacom->tool[1] = BTN_TOOL_TRIPLETAP;
649
650 if (urb->actual_length != WACOM_PKGLEN_TPC1FG) {
651 switch (data[0]) {
Ping Chengcad74702009-12-15 00:35:25 -0800652 case WACOM_REPORT_TPC1FG:
Ping Chengec67bbe2009-12-15 00:35:24 -0800653 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[2]));
654 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4]));
655 wacom_report_abs(wcombo, ABS_PRESSURE, wacom_le16_to_cpu(&data[6]));
656 wacom_report_key(wcombo, BTN_TOUCH, wacom_le16_to_cpu(&data[6]));
657 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]);
658 wacom_report_key(wcombo, wacom->tool[0], 1);
659 break;
Ping Chengcad74702009-12-15 00:35:25 -0800660 case WACOM_REPORT_TPC2FG:
Ping Chengec67bbe2009-12-15 00:35:24 -0800661 /* keep this byte to send proper out-prox event */
662 wacom->id[1] = data[1] & 0x03;
663
664 if (data[1] & 0x01) {
665 wacom_tpc_finger_in(wacom, wcombo, data, 0);
666 firstFinger = 1;
667 } else if (firstFinger) {
668 wacom_tpc_touch_out(wacom, wcombo, 0);
669 }
670
671 if (data[1] & 0x02) {
672 /* sync first finger data */
673 if (firstFinger)
674 wacom_input_sync(wcombo);
675
676 wacom_tpc_finger_in(wacom, wcombo, data, 1);
677 secondFinger = 1;
678 } else if (secondFinger) {
679 /* sync first finger data */
680 if (firstFinger)
681 wacom_input_sync(wcombo);
682
683 wacom_tpc_touch_out(wacom, wcombo, 1);
684 secondFinger = 0;
685 }
686 if (!(data[1] & 0x01))
687 firstFinger = 0;
688 break;
689 }
690 } else {
691 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[1]));
692 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[3]));
693 wacom_report_key(wcombo, BTN_TOUCH, 1);
694 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]);
695 wacom_report_key(wcombo, wacom->tool[0], 1);
696 }
697 return;
698}
699
Roel Kluin0de048a2008-12-20 05:19:43 -0500700static int wacom_tpc_irq(struct wacom_wac *wacom, void *wcombo)
Ping Cheng545f4e92008-11-24 11:44:27 -0500701{
702 char *data = wacom->data;
Ping Chengec67bbe2009-12-15 00:35:24 -0800703 int prox = 0, pressure, idx = -1;
Ping Cheng545f4e92008-11-24 11:44:27 -0500704 static int stylusInProx, touchInProx = 1, touchOut;
705 struct urb *urb = ((struct wacom_combo *)wcombo)->urb;
706
707 dbg("wacom_tpc_irq: received report #%d", data[0]);
708
Ping Chengcad74702009-12-15 00:35:25 -0800709 if (urb->actual_length == WACOM_PKGLEN_TPC1FG || /* single touch */
710 data[0] == WACOM_REPORT_TPC1FG || /* single touch */
711 data[0] == WACOM_REPORT_TPC2FG) { /* 2FG touch */
Ping Chengee545002009-12-15 00:35:24 -0800712 if (urb->actual_length == WACOM_PKGLEN_TPC1FG) { /* with touch */
Ping Chengec67bbe2009-12-15 00:35:24 -0800713 prox = data[0] & 0x01;
Ping Cheng545f4e92008-11-24 11:44:27 -0500714 } else { /* with capacity */
Ping Chengcad74702009-12-15 00:35:25 -0800715 if (data[0] == WACOM_REPORT_TPC1FG)
Ping Chengec67bbe2009-12-15 00:35:24 -0800716 /* single touch */
717 prox = data[1] & 0x01;
718 else
719 /* 2FG touch data */
720 prox = data[1] & 0x03;
Ping Cheng545f4e92008-11-24 11:44:27 -0500721 }
722
723 if (!stylusInProx) { /* stylus not in prox */
724 if (prox) {
725 if (touchInProx) {
Ping Chengec67bbe2009-12-15 00:35:24 -0800726 wacom_tpc_touch_in(wacom, wcombo);
Ping Cheng545f4e92008-11-24 11:44:27 -0500727 touchOut = 1;
728 return 1;
729 }
730 } else {
Ping Chengec67bbe2009-12-15 00:35:24 -0800731 /* 2FGT out-prox */
Ping Chengcad74702009-12-15 00:35:25 -0800732 if (data[0] == WACOM_REPORT_TPC2FG) {
Ping Chengec67bbe2009-12-15 00:35:24 -0800733 idx = (wacom->id[1] & 0x01) - 1;
734 if (idx == 0) {
735 wacom_tpc_touch_out(wacom, wcombo, idx);
736 /* sync first finger event */
737 if (wacom->id[1] & 0x02)
738 wacom_input_sync(wcombo);
739 }
740 idx = (wacom->id[1] & 0x02) - 1;
741 if (idx == 1)
742 wacom_tpc_touch_out(wacom, wcombo, idx);
743 } else /* one finger touch */
744 wacom_tpc_touch_out(wacom, wcombo, 0);
Ping Cheng545f4e92008-11-24 11:44:27 -0500745 touchOut = 0;
746 touchInProx = 1;
747 return 1;
748 }
749 } else if (touchOut || !prox) { /* force touch out-prox */
Ping Chengec67bbe2009-12-15 00:35:24 -0800750 wacom_tpc_touch_out(wacom, wcombo, 0);
Ping Cheng545f4e92008-11-24 11:44:27 -0500751 touchOut = 0;
752 touchInProx = 1;
753 return 1;
754 }
Ping Chengcad74702009-12-15 00:35:25 -0800755 } else if (data[0] == WACOM_REPORT_PENABLED) { /* Penabled */
Ping Cheng545f4e92008-11-24 11:44:27 -0500756 prox = data[1] & 0x20;
757
758 touchInProx = 0;
759
Ping Cheng545f4e92008-11-24 11:44:27 -0500760 if (prox) { /* in prox */
Ping Chengec67bbe2009-12-15 00:35:24 -0800761 if (!wacom->id[0]) {
Ping Cheng545f4e92008-11-24 11:44:27 -0500762 /* Going into proximity select tool */
Ping Chengec67bbe2009-12-15 00:35:24 -0800763 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
764 if (wacom->tool[0] == BTN_TOOL_PEN)
Ping Cheng545f4e92008-11-24 11:44:27 -0500765 wacom->id[0] = STYLUS_DEVICE_ID;
Ping Chengec67bbe2009-12-15 00:35:24 -0800766 else
767 wacom->id[0] = ERASER_DEVICE_ID;
Ping Cheng545f4e92008-11-24 11:44:27 -0500768 }
769 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02);
770 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x10);
771 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[2]));
772 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4]));
773 pressure = ((data[7] & 0x01) << 8) | data[6];
774 if (pressure < 0)
775 pressure = wacom->features->pressure_max + pressure + 1;
776 wacom_report_abs(wcombo, ABS_PRESSURE, pressure);
Ping Chengec67bbe2009-12-15 00:35:24 -0800777 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x05);
Ping Cheng545f4e92008-11-24 11:44:27 -0500778 } else {
Ping Chengec67bbe2009-12-15 00:35:24 -0800779 wacom_report_abs(wcombo, ABS_X, 0);
780 wacom_report_abs(wcombo, ABS_Y, 0);
Ping Cheng545f4e92008-11-24 11:44:27 -0500781 wacom_report_abs(wcombo, ABS_PRESSURE, 0);
782 wacom_report_key(wcombo, BTN_STYLUS, 0);
783 wacom_report_key(wcombo, BTN_STYLUS2, 0);
784 wacom_report_key(wcombo, BTN_TOUCH, 0);
Ping Chengec67bbe2009-12-15 00:35:24 -0800785 wacom->id[0] = 0;
786 /* pen is out so touch can be enabled now */
787 touchInProx = 1;
Ping Cheng545f4e92008-11-24 11:44:27 -0500788 }
Ping Chengec67bbe2009-12-15 00:35:24 -0800789 wacom_report_key(wcombo, wacom->tool[0], prox);
Ping Cheng545f4e92008-11-24 11:44:27 -0500790 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]);
791 stylusInProx = prox;
Ping Cheng545f4e92008-11-24 11:44:27 -0500792 return 1;
793 }
794 return 0;
795}
796
Ping Cheng3bea7332006-07-13 18:01:36 -0700797int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo)
798{
799 switch (wacom_wac->features->type) {
800 case PENPARTNER:
Ping Cheng545f4e92008-11-24 11:44:27 -0500801 return wacom_penpartner_irq(wacom_wac, wcombo);
802
Ping Cheng3bea7332006-07-13 18:01:36 -0700803 case PL:
Ping Cheng545f4e92008-11-24 11:44:27 -0500804 return wacom_pl_irq(wacom_wac, wcombo);
805
Ping Cheng3bea7332006-07-13 18:01:36 -0700806 case WACOM_G4:
807 case GRAPHIRE:
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400808 case WACOM_MO:
Ping Cheng545f4e92008-11-24 11:44:27 -0500809 return wacom_graphire_irq(wacom_wac, wcombo);
810
Ping Cheng3bea7332006-07-13 18:01:36 -0700811 case PTU:
Ping Cheng545f4e92008-11-24 11:44:27 -0500812 return wacom_ptu_irq(wacom_wac, wcombo);
813
Ping Cheng3bea7332006-07-13 18:01:36 -0700814 case INTUOS:
Ping Cheng8d32e3a2006-09-26 13:34:47 -0700815 case INTUOS3S:
Ping Cheng3bea7332006-07-13 18:01:36 -0700816 case INTUOS3:
817 case INTUOS3L:
Ping Cheng6f660f12009-05-08 18:30:33 -0700818 case INTUOS4S:
819 case INTUOS4:
820 case INTUOS4L:
Ping Cheng3bea7332006-07-13 18:01:36 -0700821 case CINTIQ:
Ping Cheng0e1763f2008-03-13 16:46:46 -0400822 case WACOM_BEE:
Ping Cheng545f4e92008-11-24 11:44:27 -0500823 return wacom_intuos_irq(wacom_wac, wcombo);
824
825 case TABLETPC:
Ping Chengec67bbe2009-12-15 00:35:24 -0800826 case TABLETPC2FG:
Ping Cheng545f4e92008-11-24 11:44:27 -0500827 return wacom_tpc_irq(wacom_wac, wcombo);
828
Ping Cheng3bea7332006-07-13 18:01:36 -0700829 default:
830 return 0;
831 }
832 return 0;
833}
834
835void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
836{
837 switch (wacom_wac->features->type) {
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400838 case WACOM_MO:
839 input_dev_mo(input_dev, wacom_wac);
Ping Cheng3bea7332006-07-13 18:01:36 -0700840 case WACOM_G4:
841 input_dev_g4(input_dev, wacom_wac);
842 /* fall through */
843 case GRAPHIRE:
844 input_dev_g(input_dev, wacom_wac);
845 break;
Ping Cheng0e1763f2008-03-13 16:46:46 -0400846 case WACOM_BEE:
847 input_dev_bee(input_dev, wacom_wac);
Ping Cheng3bea7332006-07-13 18:01:36 -0700848 case INTUOS3:
849 case INTUOS3L:
850 case CINTIQ:
851 input_dev_i3(input_dev, wacom_wac);
852 /* fall through */
Ping Cheng8d32e3a2006-09-26 13:34:47 -0700853 case INTUOS3S:
854 input_dev_i3s(input_dev, wacom_wac);
Ping Cheng545f4e92008-11-24 11:44:27 -0500855 /* fall through */
Ping Cheng3bea7332006-07-13 18:01:36 -0700856 case INTUOS:
857 input_dev_i(input_dev, wacom_wac);
858 break;
Ping Cheng6f660f12009-05-08 18:30:33 -0700859 case INTUOS4:
860 case INTUOS4L:
861 input_dev_i4(input_dev, wacom_wac);
862 /* fall through */
863 case INTUOS4S:
864 input_dev_i4s(input_dev, wacom_wac);
865 input_dev_i(input_dev, wacom_wac);
866 break;
Ping Chengec67bbe2009-12-15 00:35:24 -0800867 case TABLETPC2FG:
868 input_dev_tpc2fg(input_dev, wacom_wac);
869 /* fall through */
870 case TABLETPC:
871 input_dev_tpc(input_dev, wacom_wac);
872 if (wacom_wac->features->device_type != BTN_TOOL_PEN)
873 break; /* no need to process stylus stuff */
874
875 /* fall through */
Ping Cheng3bea7332006-07-13 18:01:36 -0700876 case PL:
877 case PTU:
878 input_dev_pl(input_dev, wacom_wac);
Ping Cheng545f4e92008-11-24 11:44:27 -0500879 /* fall through */
Ping Cheng3bea7332006-07-13 18:01:36 -0700880 case PENPARTNER:
881 input_dev_pt(input_dev, wacom_wac);
882 break;
883 }
884 return;
885}
886
887static struct wacom_features wacom_features[] = {
Ping Chengee545002009-12-15 00:35:24 -0800888 { "Wacom Penpartner", WACOM_PKGLEN_PENPRTN, 5040, 3780, 255, 0, PENPARTNER },
889 { "Wacom Graphire", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511, 63, GRAPHIRE },
890 { "Wacom Graphire2 4x5", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511, 63, GRAPHIRE },
891 { "Wacom Graphire2 5x7", WACOM_PKGLEN_GRAPHIRE, 13918, 10206, 511, 63, GRAPHIRE },
892 { "Wacom Graphire3", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511, 63, GRAPHIRE },
893 { "Wacom Graphire3 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, GRAPHIRE },
894 { "Wacom Graphire4 4x5", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511, 63, WACOM_G4 },
895 { "Wacom Graphire4 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, WACOM_G4 },
896 { "Wacom BambooFun 4x5", WACOM_PKGLEN_BBFUN, 14760, 9225, 511, 63, WACOM_MO },
897 { "Wacom BambooFun 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 511, 63, WACOM_MO },
898 { "Wacom Bamboo1 Medium", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, GRAPHIRE },
899 { "Wacom Volito", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE },
900 { "Wacom PenStation2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 255, 63, GRAPHIRE },
901 { "Wacom Volito2 4x5", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE },
902 { "Wacom Volito2 2x3", WACOM_PKGLEN_GRAPHIRE, 3248, 2320, 511, 63, GRAPHIRE },
903 { "Wacom PenPartner2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 511, 63, GRAPHIRE },
904 { "Wacom Bamboo", WACOM_PKGLEN_BBFUN, 14760, 9225, 511, 63, WACOM_MO },
905 { "Wacom Bamboo1", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE },
906 { "Wacom Intuos 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023, 31, INTUOS },
907 { "Wacom Intuos 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS },
908 { "Wacom Intuos 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023, 31, INTUOS },
909 { "Wacom Intuos 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023, 31, INTUOS },
910 { "Wacom Intuos 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023, 31, INTUOS },
911 { "Wacom PL400", WACOM_PKGLEN_GRAPHIRE, 5408, 4056, 255, 0, PL },
912 { "Wacom PL500", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 255, 0, PL },
913 { "Wacom PL600", WACOM_PKGLEN_GRAPHIRE, 6126, 4604, 255, 0, PL },
914 { "Wacom PL600SX", WACOM_PKGLEN_GRAPHIRE, 6260, 5016, 255, 0, PL },
915 { "Wacom PL550", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 511, 0, PL },
916 { "Wacom PL800", WACOM_PKGLEN_GRAPHIRE, 7220, 5780, 511, 0, PL },
917 { "Wacom PL700", WACOM_PKGLEN_GRAPHIRE, 6758, 5406, 511, 0, PL },
918 { "Wacom PL510", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511, 0, PL },
919 { "Wacom DTU710", WACOM_PKGLEN_GRAPHIRE, 34080, 27660, 511, 0, PL },
920 { "Wacom DTF521", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511, 0, PL },
921 { "Wacom DTF720", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511, 0, PL },
922 { "Wacom DTF720a", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511, 0, PL },
923 { "Wacom Cintiq Partner", WACOM_PKGLEN_GRAPHIRE, 20480, 15360, 511, 0, PTU },
924 { "Wacom Intuos2 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023, 31, INTUOS },
925 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS },
926 { "Wacom Intuos2 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023, 31, INTUOS },
927 { "Wacom Intuos2 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023, 31, INTUOS },
928 { "Wacom Intuos2 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023, 31, INTUOS },
929 { "Wacom Intuos3 4x5", WACOM_PKGLEN_INTUOS, 25400, 20320, 1023, 63, INTUOS3S },
930 { "Wacom Intuos3 6x8", WACOM_PKGLEN_INTUOS, 40640, 30480, 1023, 63, INTUOS3 },
931 { "Wacom Intuos3 9x12", WACOM_PKGLEN_INTUOS, 60960, 45720, 1023, 63, INTUOS3 },
932 { "Wacom Intuos3 12x12", WACOM_PKGLEN_INTUOS, 60960, 60960, 1023, 63, INTUOS3L },
933 { "Wacom Intuos3 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 1023, 63, INTUOS3L },
934 { "Wacom Intuos3 6x11", WACOM_PKGLEN_INTUOS, 54204, 31750, 1023, 63, INTUOS3 },
935 { "Wacom Intuos3 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 1023, 63, INTUOS3S },
936 { "Wacom Intuos4 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047, 63, INTUOS4S },
937 { "Wacom Intuos4 6x9", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047, 63, INTUOS4 },
938 { "Wacom Intuos4 8x13", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047, 63, INTUOS4L },
939 { "Wacom Intuos4 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 2047, 63, INTUOS4L },
940 { "Wacom Cintiq 21UX", WACOM_PKGLEN_INTUOS, 87200, 65600, 1023, 63, CINTIQ },
941 { "Wacom Cintiq 20WSX", WACOM_PKGLEN_INTUOS, 86680, 54180, 1023, 63, WACOM_BEE },
942 { "Wacom Cintiq 12WX", WACOM_PKGLEN_INTUOS, 53020, 33440, 1023, 63, WACOM_BEE },
943 { "Wacom DTU1931", WACOM_PKGLEN_GRAPHIRE, 37832, 30305, 511, 0, PL },
944 { "Wacom ISDv4 90", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC },
945 { "Wacom ISDv4 93", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC },
946 { "Wacom ISDv4 9A", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC },
Ping Chengec67bbe2009-12-15 00:35:24 -0800947 { "Wacom ISDv4 9F", WACOM_PKGLEN_PENABLED, 26202, 16325, 255, 0, TABLETPC },
948 { "Wacom ISDv4 E2", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 0, TABLETPC2FG },
949 { "Wacom ISDv4 E3", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 0, TABLETPC2FG },
Ping Chengee545002009-12-15 00:35:24 -0800950 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS },
Ping Cheng3bea7332006-07-13 18:01:36 -0700951 { }
952};
953
954static struct usb_device_id wacom_ids[] = {
955 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x00) },
956 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x10) },
957 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x11) },
958 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x12) },
959 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x13) },
960 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x14) },
961 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x15) },
962 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x16) },
Ping Cheng0e1763f2008-03-13 16:46:46 -0400963 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x17) },
964 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x18) },
Ping Cheng545f4e92008-11-24 11:44:27 -0500965 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x19) },
Ping Cheng3bea7332006-07-13 18:01:36 -0700966 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60) },
967 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x61) },
968 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x62) },
969 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x63) },
970 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x64) },
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400971 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x65) },
Ping Cheng0e1763f2008-03-13 16:46:46 -0400972 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x69) },
Ping Cheng3bea7332006-07-13 18:01:36 -0700973 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x20) },
974 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x21) },
975 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x22) },
976 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x23) },
977 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x24) },
978 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x30) },
979 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x31) },
980 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x32) },
981 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x33) },
982 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x34) },
983 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x35) },
984 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x37) },
985 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x38) },
986 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x39) },
Ping Cheng3bea7332006-07-13 18:01:36 -0700987 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC4) },
Ping Chengc413ec42009-06-28 22:50:58 -0700988 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC0) },
989 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC2) },
Ping Cheng3bea7332006-07-13 18:01:36 -0700990 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x03) },
991 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x41) },
992 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x42) },
993 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x43) },
994 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x44) },
995 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x45) },
996 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB0) },
997 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB1) },
998 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB2) },
999 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB3) },
1000 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB4) },
1001 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB5) },
Ping Cheng8d32e3a2006-09-26 13:34:47 -07001002 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB7) },
Ping Cheng6f660f12009-05-08 18:30:33 -07001003 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB8) },
1004 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB9) },
1005 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xBA) },
1006 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xBB) },
Ping Cheng3bea7332006-07-13 18:01:36 -07001007 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) },
Ping Chengb345dc72008-04-24 23:34:05 -04001008 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC5) },
Ping Cheng0e1763f2008-03-13 16:46:46 -04001009 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC6) },
Ping Cheng545f4e92008-11-24 11:44:27 -05001010 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC7) },
1011 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x90) },
1012 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x93) },
1013 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x9A) },
Ping Chengec67bbe2009-12-15 00:35:24 -08001014 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x9F) },
1015 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xE2) },
1016 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xE3) },
Ping Cheng3bea7332006-07-13 18:01:36 -07001017 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) },
1018 { }
1019};
1020
Ping Cheng545f4e92008-11-24 11:44:27 -05001021const struct usb_device_id *get_device_table(void)
1022{
1023 const struct usb_device_id *id_table = wacom_ids;
1024
Ping Cheng3bea7332006-07-13 18:01:36 -07001025 return id_table;
1026}
1027
Ping Cheng545f4e92008-11-24 11:44:27 -05001028struct wacom_features * get_wacom_feature(const struct usb_device_id *id)
1029{
Ping Cheng3bea7332006-07-13 18:01:36 -07001030 int index = id - wacom_ids;
1031 struct wacom_features *wf = &wacom_features[index];
Ping Cheng545f4e92008-11-24 11:44:27 -05001032
Ping Cheng3bea7332006-07-13 18:01:36 -07001033 return wf;
1034}
1035
1036MODULE_DEVICE_TABLE(usb, wacom_ids);