blob: 1056f149fe31653d423f1da1d10c6e2f0d783d6b [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 Cheng0f5e1822009-12-15 00:35:25 -0800157 static int penData = 0;
Ping Cheng3bea7332006-07-13 18:01:36 -0700158
Ping Chengcad74702009-12-15 00:35:25 -0800159 if (data[0] != WACOM_REPORT_PENABLED) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700160 dbg("wacom_graphire_irq: received unknown report #%d", data[0]);
161 return 0;
162 }
163
Ping Chenge34b9d22008-05-05 11:36:41 -0400164 if (data[1] & 0x80) {
Ping Cheng0e1763f2008-03-13 16:46:46 -0400165 /* in prox and not a pad data */
Ping Cheng0f5e1822009-12-15 00:35:25 -0800166 penData = 1;
Ping Cheng3bea7332006-07-13 18:01:36 -0700167
168 switch ((data[1] >> 5) & 3) {
169
170 case 0: /* Pen */
171 wacom->tool[0] = BTN_TOOL_PEN;
Ping Chenge34b9d22008-05-05 11:36:41 -0400172 wacom->id[0] = STYLUS_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700173 break;
174
175 case 1: /* Rubber */
176 wacom->tool[0] = BTN_TOOL_RUBBER;
Ping Chenge34b9d22008-05-05 11:36:41 -0400177 wacom->id[0] = ERASER_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700178 break;
179
180 case 2: /* Mouse with wheel */
181 wacom_report_key(wcombo, BTN_MIDDLE, data[1] & 0x04);
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400182 if (wacom->features->type == WACOM_G4 ||
183 wacom->features->type == WACOM_MO) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700184 rw = data[7] & 0x04 ? (data[7] & 0x03)-4 : (data[7] & 0x03);
185 wacom_report_rel(wcombo, REL_WHEEL, -rw);
186 } else
187 wacom_report_rel(wcombo, REL_WHEEL, -(signed char) data[6]);
188 /* fall through */
189
190 case 3: /* Mouse without wheel */
191 wacom->tool[0] = BTN_TOOL_MOUSE;
Ping Chenge34b9d22008-05-05 11:36:41 -0400192 wacom->id[0] = CURSOR_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700193 wacom_report_key(wcombo, BTN_LEFT, data[1] & 0x01);
194 wacom_report_key(wcombo, BTN_RIGHT, data[1] & 0x02);
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400195 if (wacom->features->type == WACOM_G4 ||
196 wacom->features->type == WACOM_MO)
Ping Cheng8d32e3a2006-09-26 13:34:47 -0700197 wacom_report_abs(wcombo, ABS_DISTANCE, data[6] & 0x3f);
Ping Cheng3bea7332006-07-13 18:01:36 -0700198 else
Ping Cheng8d32e3a2006-09-26 13:34:47 -0700199 wacom_report_abs(wcombo, ABS_DISTANCE, data[7] & 0x3f);
Ping Cheng3bea7332006-07-13 18:01:36 -0700200 break;
201 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700202 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 }
Ping Chenge34b9d22008-05-05 11:36:41 -0400212 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); /* report tool id */
Ping Cheng071e0a22006-12-05 17:09:51 -0800213 wacom_report_key(wcombo, wacom->tool[0], 1);
Ping Chenge34b9d22008-05-05 11:36:41 -0400214 } else if (wacom->id[0]) {
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800215 wacom_report_abs(wcombo, ABS_X, 0);
216 wacom_report_abs(wcombo, ABS_Y, 0);
217 if (wacom->tool[0] == BTN_TOOL_MOUSE) {
218 wacom_report_key(wcombo, BTN_LEFT, 0);
219 wacom_report_key(wcombo, BTN_RIGHT, 0);
220 wacom_report_abs(wcombo, ABS_DISTANCE, 0);
221 } else {
222 wacom_report_abs(wcombo, ABS_PRESSURE, 0);
223 wacom_report_key(wcombo, BTN_TOUCH, 0);
224 wacom_report_key(wcombo, BTN_STYLUS, 0);
225 wacom_report_key(wcombo, BTN_STYLUS2, 0);
226 }
Ping Chenge34b9d22008-05-05 11:36:41 -0400227 wacom->id[0] = 0;
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800228 wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */
Ping Cheng071e0a22006-12-05 17:09:51 -0800229 wacom_report_key(wcombo, wacom->tool[0], 0);
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800230 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700231
232 /* send pad data */
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400233 switch (wacom->features->type) {
234 case WACOM_G4:
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800235 if (data[7] & 0xf8) {
Ping Cheng0f5e1822009-12-15 00:35:25 -0800236 if (penData) {
237 wacom_input_sync(wcombo); /* sync last event */
238 if (!wacom->id[0])
239 penData = 0;
240 }
Ping Chenge34b9d22008-05-05 11:36:41 -0400241 wacom->id[1] = PAD_DEVICE_ID;
Ping Cheng3bea7332006-07-13 18:01:36 -0700242 wacom_report_key(wcombo, BTN_0, (data[7] & 0x40));
243 wacom_report_key(wcombo, BTN_4, (data[7] & 0x80));
244 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
245 wacom_report_rel(wcombo, REL_WHEEL, rw);
246 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0xf0);
Ping Chenge34b9d22008-05-05 11:36:41 -0400247 wacom_report_abs(wcombo, ABS_MISC, wacom->id[1]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700248 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
249 } else if (wacom->id[1]) {
Ping Cheng0f5e1822009-12-15 00:35:25 -0800250 if (penData) {
251 wacom_input_sync(wcombo); /* sync last event */
252 if (!wacom->id[0])
253 penData = 0;
254 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700255 wacom->id[1] = 0;
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800256 wacom_report_key(wcombo, BTN_0, (data[7] & 0x40));
257 wacom_report_key(wcombo, BTN_4, (data[7] & 0x80));
Ping Cheng0f5e1822009-12-15 00:35:25 -0800258 wacom_report_rel(wcombo, REL_WHEEL, 0);
Ping Cheng3bea7332006-07-13 18:01:36 -0700259 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0);
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800260 wacom_report_abs(wcombo, ABS_MISC, 0);
Ping Cheng3bea7332006-07-13 18:01:36 -0700261 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
262 }
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400263 break;
264 case WACOM_MO:
Ping Cheng0e1763f2008-03-13 16:46:46 -0400265 if ((data[7] & 0xf8) || (data[8] & 0xff)) {
Ping Cheng0f5e1822009-12-15 00:35:25 -0800266 if (penData) {
267 wacom_input_sync(wcombo); /* sync last event */
268 if (!wacom->id[0])
269 penData = 0;
270 }
Ping Chenge34b9d22008-05-05 11:36:41 -0400271 wacom->id[1] = PAD_DEVICE_ID;
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400272 wacom_report_key(wcombo, BTN_0, (data[7] & 0x08));
273 wacom_report_key(wcombo, BTN_1, (data[7] & 0x20));
274 wacom_report_key(wcombo, BTN_4, (data[7] & 0x10));
275 wacom_report_key(wcombo, BTN_5, (data[7] & 0x40));
276 wacom_report_abs(wcombo, ABS_WHEEL, (data[8] & 0x7f));
277 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0xf0);
Ping Chenge34b9d22008-05-05 11:36:41 -0400278 wacom_report_abs(wcombo, ABS_MISC, wacom->id[1]);
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400279 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
280 } else if (wacom->id[1]) {
Ping Cheng0f5e1822009-12-15 00:35:25 -0800281 if (penData) {
282 wacom_input_sync(wcombo); /* sync last event */
283 if (!wacom->id[0])
284 penData = 0;
285 }
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400286 wacom->id[1] = 0;
287 wacom_report_key(wcombo, BTN_0, (data[7] & 0x08));
288 wacom_report_key(wcombo, BTN_1, (data[7] & 0x20));
289 wacom_report_key(wcombo, BTN_4, (data[7] & 0x10));
290 wacom_report_key(wcombo, BTN_5, (data[7] & 0x40));
291 wacom_report_abs(wcombo, ABS_WHEEL, (data[8] & 0x7f));
292 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0);
293 wacom_report_abs(wcombo, ABS_MISC, 0);
294 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
295 }
296 break;
Ping Cheng3bea7332006-07-13 18:01:36 -0700297 }
298 return 1;
299}
300
301static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
302{
303 unsigned char *data = wacom->data;
Ping Cheng6f660f12009-05-08 18:30:33 -0700304 int idx = 0;
Ping Cheng3bea7332006-07-13 18:01:36 -0700305
306 /* tool number */
Ping Cheng6f660f12009-05-08 18:30:33 -0700307 if (wacom->features->type == INTUOS)
308 idx = data[1] & 0x01;
Ping Cheng3bea7332006-07-13 18:01:36 -0700309
310 /* Enter report */
311 if ((data[1] & 0xfc) == 0xc0) {
312 /* serial number of the tool */
313 wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
314 (data[4] << 20) + (data[5] << 12) +
315 (data[6] << 4) + (data[7] >> 4);
316
317 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4);
318 switch (wacom->id[idx]) {
319 case 0x812: /* Inking pen */
320 case 0x801: /* Intuos3 Inking pen */
Ping Cheng6f660f12009-05-08 18:30:33 -0700321 case 0x20802: /* Intuos4 Classic Pen */
Ping Cheng3bea7332006-07-13 18:01:36 -0700322 case 0x012:
323 wacom->tool[idx] = BTN_TOOL_PENCIL;
324 break;
325 case 0x822: /* Pen */
326 case 0x842:
327 case 0x852:
328 case 0x823: /* Intuos3 Grip Pen */
329 case 0x813: /* Intuos3 Classic Pen */
330 case 0x885: /* Intuos3 Marker Pen */
Ping Cheng6f660f12009-05-08 18:30:33 -0700331 case 0x802: /* Intuos4 Grip Pen Eraser */
332 case 0x804: /* Intuos4 Marker Pen */
333 case 0x40802: /* Intuos4 Classic Pen */
Ping Cheng3bea7332006-07-13 18:01:36 -0700334 case 0x022:
335 wacom->tool[idx] = BTN_TOOL_PEN;
336 break;
337 case 0x832: /* Stroke pen */
338 case 0x032:
339 wacom->tool[idx] = BTN_TOOL_BRUSH;
340 break;
341 case 0x007: /* Mouse 4D and 2D */
342 case 0x09c:
343 case 0x094:
344 case 0x017: /* Intuos3 2D Mouse */
Ping Cheng6f660f12009-05-08 18:30:33 -0700345 case 0x806: /* Intuos4 Mouse */
Ping Cheng3bea7332006-07-13 18:01:36 -0700346 wacom->tool[idx] = BTN_TOOL_MOUSE;
347 break;
348 case 0x096: /* Lens cursor */
349 case 0x097: /* Intuos3 Lens cursor */
Ping Cheng6f660f12009-05-08 18:30:33 -0700350 case 0x006: /* Intuos4 Lens cursor */
Ping Cheng3bea7332006-07-13 18:01:36 -0700351 wacom->tool[idx] = BTN_TOOL_LENS;
352 break;
353 case 0x82a: /* Eraser */
354 case 0x85a:
355 case 0x91a:
356 case 0xd1a:
357 case 0x0fa:
358 case 0x82b: /* Intuos3 Grip Pen Eraser */
359 case 0x81b: /* Intuos3 Classic Pen Eraser */
360 case 0x91b: /* Intuos3 Airbrush Eraser */
Ping Cheng6f660f12009-05-08 18:30:33 -0700361 case 0x80c: /* Intuos4 Marker Pen Eraser */
362 case 0x80a: /* Intuos4 Grip Pen Eraser */
363 case 0x4080a: /* Intuos4 Classic Pen Eraser */
364 case 0x90a: /* Intuos4 Airbrush Eraser */
Ping Cheng3bea7332006-07-13 18:01:36 -0700365 wacom->tool[idx] = BTN_TOOL_RUBBER;
366 break;
367 case 0xd12:
368 case 0x912:
369 case 0x112:
370 case 0x913: /* Intuos3 Airbrush */
Ping Cheng6f660f12009-05-08 18:30:33 -0700371 case 0x902: /* Intuos4 Airbrush */
Ping Cheng3bea7332006-07-13 18:01:36 -0700372 wacom->tool[idx] = BTN_TOOL_AIRBRUSH;
373 break;
374 default: /* Unknown tool */
375 wacom->tool[idx] = BTN_TOOL_PEN;
376 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700377 return 1;
378 }
379
380 /* Exit report */
381 if ((data[1] & 0xfe) == 0x80) {
Ping Cheng6f660f12009-05-08 18:30:33 -0700382 /*
383 * Reset all states otherwise we lose the initial states
384 * when in-prox next time
385 */
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800386 wacom_report_abs(wcombo, ABS_X, 0);
387 wacom_report_abs(wcombo, ABS_Y, 0);
388 wacom_report_abs(wcombo, ABS_DISTANCE, 0);
Ping Cheng6f660f12009-05-08 18:30:33 -0700389 wacom_report_abs(wcombo, ABS_TILT_X, 0);
390 wacom_report_abs(wcombo, ABS_TILT_Y, 0);
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800391 if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
392 wacom_report_key(wcombo, BTN_LEFT, 0);
393 wacom_report_key(wcombo, BTN_MIDDLE, 0);
394 wacom_report_key(wcombo, BTN_RIGHT, 0);
395 wacom_report_key(wcombo, BTN_SIDE, 0);
396 wacom_report_key(wcombo, BTN_EXTRA, 0);
397 wacom_report_abs(wcombo, ABS_THROTTLE, 0);
398 wacom_report_abs(wcombo, ABS_RZ, 0);
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400399 } else {
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800400 wacom_report_abs(wcombo, ABS_PRESSURE, 0);
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800401 wacom_report_key(wcombo, BTN_STYLUS, 0);
402 wacom_report_key(wcombo, BTN_STYLUS2, 0);
403 wacom_report_key(wcombo, BTN_TOUCH, 0);
404 wacom_report_abs(wcombo, ABS_WHEEL, 0);
Ping Chengc413ec42009-06-28 22:50:58 -0700405 if (wacom->features->type >= INTUOS3S)
406 wacom_report_abs(wcombo, ABS_Z, 0);
Ping Cheng8d32e3a2006-09-26 13:34:47 -0700407 }
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800408 wacom_report_key(wcombo, wacom->tool[idx], 0);
409 wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */
410 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
Ping Cheng6f660f12009-05-08 18:30:33 -0700411 wacom->id[idx] = 0;
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800412 return 2;
Ping Cheng3bea7332006-07-13 18:01:36 -0700413 }
414 return 0;
415}
416
417static void wacom_intuos_general(struct wacom_wac *wacom, void *wcombo)
418{
419 unsigned char *data = wacom->data;
420 unsigned int t;
421
422 /* general pen packet */
423 if ((data[1] & 0xb8) == 0xa0) {
424 t = (data[6] << 2) | ((data[7] >> 6) & 3);
Ping Cheng6f660f12009-05-08 18:30:33 -0700425 if (wacom->features->type >= INTUOS4S && wacom->features->type <= INTUOS4L)
426 t = (t << 1) | (data[1] & 1);
Ping Cheng3bea7332006-07-13 18:01:36 -0700427 wacom_report_abs(wcombo, ABS_PRESSURE, t);
428 wacom_report_abs(wcombo, ABS_TILT_X,
429 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
430 wacom_report_abs(wcombo, ABS_TILT_Y, data[8] & 0x7f);
431 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 2);
432 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 4);
433 wacom_report_key(wcombo, BTN_TOUCH, t > 10);
434 }
435
436 /* airbrush second packet */
437 if ((data[1] & 0xbc) == 0xb4) {
438 wacom_report_abs(wcombo, ABS_WHEEL,
439 (data[6] << 2) | ((data[7] >> 6) & 3));
440 wacom_report_abs(wcombo, ABS_TILT_X,
441 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
442 wacom_report_abs(wcombo, ABS_TILT_Y, data[8] & 0x7f);
443 }
444 return;
445}
446
447static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
448{
449 unsigned char *data = wacom->data;
450 unsigned int t;
Ping Cheng6f660f12009-05-08 18:30:33 -0700451 int idx = 0, result;
Ping Cheng3bea7332006-07-13 18:01:36 -0700452
Ping Chengcad74702009-12-15 00:35:25 -0800453 if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_INTUOSREAD
454 && data[0] != WACOM_REPORT_INTUOSWRITE && data[0] != WACOM_REPORT_INTUOSPAD) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700455 dbg("wacom_intuos_irq: received unknown report #%d", data[0]);
456 return 0;
457 }
458
Ping Cheng3bea7332006-07-13 18:01:36 -0700459 /* tool number */
Ping Cheng6f660f12009-05-08 18:30:33 -0700460 if (wacom->features->type == INTUOS)
461 idx = data[1] & 0x01;
Ping Cheng3bea7332006-07-13 18:01:36 -0700462
463 /* pad packets. Works as a second tool and is always in prox */
Ping Chengcad74702009-12-15 00:35:25 -0800464 if (data[0] == WACOM_REPORT_INTUOSPAD) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700465 /* initiate the pad as a device */
466 if (wacom->tool[1] != BTN_TOOL_FINGER)
467 wacom->tool[1] = BTN_TOOL_FINGER;
468
Ping Cheng6f660f12009-05-08 18:30:33 -0700469 if (wacom->features->type >= INTUOS4S && wacom->features->type <= INTUOS4L) {
470 wacom_report_key(wcombo, BTN_0, (data[2] & 0x01));
471 wacom_report_key(wcombo, BTN_1, (data[3] & 0x01));
472 wacom_report_key(wcombo, BTN_2, (data[3] & 0x02));
473 wacom_report_key(wcombo, BTN_3, (data[3] & 0x04));
474 wacom_report_key(wcombo, BTN_4, (data[3] & 0x08));
475 wacom_report_key(wcombo, BTN_5, (data[3] & 0x10));
476 wacom_report_key(wcombo, BTN_6, (data[3] & 0x20));
477 if (data[1] & 0x80) {
478 wacom_report_abs(wcombo, ABS_WHEEL, (data[1] & 0x7f));
Ping Chenga8629522009-06-02 16:59:58 -0700479 } else {
480 /* Out of proximity, clear wheel value. */
481 wacom_report_abs(wcombo, ABS_WHEEL, 0);
Ping Cheng6f660f12009-05-08 18:30:33 -0700482 }
483 if (wacom->features->type != INTUOS4S) {
484 wacom_report_key(wcombo, BTN_7, (data[3] & 0x40));
485 wacom_report_key(wcombo, BTN_8, (data[3] & 0x80));
486 }
487 if (data[1] | (data[2] & 0x01) | data[3]) {
488 wacom_report_key(wcombo, wacom->tool[1], 1);
489 wacom_report_abs(wcombo, ABS_MISC, PAD_DEVICE_ID);
490 } else {
491 wacom_report_key(wcombo, wacom->tool[1], 0);
492 wacom_report_abs(wcombo, ABS_MISC, 0);
493 }
494 } else {
495 wacom_report_key(wcombo, BTN_0, (data[5] & 0x01));
496 wacom_report_key(wcombo, BTN_1, (data[5] & 0x02));
497 wacom_report_key(wcombo, BTN_2, (data[5] & 0x04));
498 wacom_report_key(wcombo, BTN_3, (data[5] & 0x08));
499 wacom_report_key(wcombo, BTN_4, (data[6] & 0x01));
500 wacom_report_key(wcombo, BTN_5, (data[6] & 0x02));
501 wacom_report_key(wcombo, BTN_6, (data[6] & 0x04));
502 wacom_report_key(wcombo, BTN_7, (data[6] & 0x08));
503 wacom_report_key(wcombo, BTN_8, (data[5] & 0x10));
504 wacom_report_key(wcombo, BTN_9, (data[6] & 0x10));
505 wacom_report_abs(wcombo, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
506 wacom_report_abs(wcombo, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
Ping Cheng3bea7332006-07-13 18:01:36 -0700507
Ping Cheng6f660f12009-05-08 18:30:33 -0700508 if ((data[5] & 0x1f) | (data[6] & 0x1f) | (data[1] & 0x1f) |
509 data[2] | (data[3] & 0x1f) | data[4]) {
510 wacom_report_key(wcombo, wacom->tool[1], 1);
511 wacom_report_abs(wcombo, ABS_MISC, PAD_DEVICE_ID);
512 } else {
513 wacom_report_key(wcombo, wacom->tool[1], 0);
514 wacom_report_abs(wcombo, ABS_MISC, 0);
515 }
516 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700517 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xffffffff);
518 return 1;
519 }
520
521 /* process in/out prox events */
522 result = wacom_intuos_inout(wacom, wcombo);
523 if (result)
524 return result-1;
525
Ping Cheng6f660f12009-05-08 18:30:33 -0700526 /* don't proceed if we don't know the ID */
527 if (!wacom->id[idx])
528 return 0;
529
530 /* Only large Intuos support Lense Cursor */
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400531 if ((wacom->tool[idx] == BTN_TOOL_LENS)
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800532 && ((wacom->features->type == INTUOS3)
Ping Cheng6f660f12009-05-08 18:30:33 -0700533 || (wacom->features->type == INTUOS3S)
534 || (wacom->features->type == INTUOS4)
535 || (wacom->features->type == INTUOS4S)))
Ping Cheng80d4e8e2007-02-23 12:22:48 -0800536 return 0;
537
Ping Cheng3bea7332006-07-13 18:01:36 -0700538 /* Cintiq doesn't send data when RDY bit isn't set */
539 if ((wacom->features->type == CINTIQ) && !(data[1] & 0x40))
540 return 0;
541
Ping Cheng071e0a22006-12-05 17:09:51 -0800542 if (wacom->features->type >= INTUOS3S) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700543 wacom_report_abs(wcombo, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
544 wacom_report_abs(wcombo, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
545 wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
546 } else {
547 wacom_report_abs(wcombo, ABS_X, wacom_be16_to_cpu(&data[2]));
548 wacom_report_abs(wcombo, ABS_Y, wacom_be16_to_cpu(&data[4]));
549 wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 3) & 0x1f));
550 }
551
552 /* process general packets */
553 wacom_intuos_general(wacom, wcombo);
554
Ping Cheng6f660f12009-05-08 18:30:33 -0700555 /* 4D mouse, 2D mouse, marker pen rotation, tilt mouse, or Lens cursor packets */
556 if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0 || (data[1] & 0xbc) == 0xac) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700557
558 if (data[1] & 0x02) {
559 /* Rotation packet */
Ping Cheng071e0a22006-12-05 17:09:51 -0800560 if (wacom->features->type >= INTUOS3S) {
Ping Cheng0e1763f2008-03-13 16:46:46 -0400561 /* I3 marker pen rotation */
Ping Cheng3bea7332006-07-13 18:01:36 -0700562 t = (data[6] << 3) | ((data[7] >> 5) & 7);
563 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
564 ((t-1) / 2 + 450)) : (450 - t / 2) ;
Ping Cheng0e1763f2008-03-13 16:46:46 -0400565 wacom_report_abs(wcombo, ABS_Z, t);
Ping Cheng3bea7332006-07-13 18:01:36 -0700566 } else {
567 /* 4D mouse rotation packet */
568 t = (data[6] << 3) | ((data[7] >> 5) & 7);
569 wacom_report_abs(wcombo, ABS_RZ, (data[7] & 0x20) ?
570 ((t - 1) / 2) : -t / 2);
571 }
572
Ping Cheng8d32e3a2006-09-26 13:34:47 -0700573 } else if (!(data[1] & 0x10) && wacom->features->type < INTUOS3S) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700574 /* 4D mouse packet */
575 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
576 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02);
577 wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x04);
578
579 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x20);
580 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x10);
581 t = (data[6] << 2) | ((data[7] >> 6) & 3);
582 wacom_report_abs(wcombo, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
583
584 } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
Ping Cheng6f660f12009-05-08 18:30:33 -0700585 /* I4 mouse */
586 if (wacom->features->type >= INTUOS4S && wacom->features->type <= INTUOS4L) {
587 wacom_report_key(wcombo, BTN_LEFT, data[6] & 0x01);
588 wacom_report_key(wcombo, BTN_MIDDLE, data[6] & 0x02);
589 wacom_report_key(wcombo, BTN_RIGHT, data[6] & 0x04);
590 wacom_report_rel(wcombo, REL_WHEEL, ((data[7] & 0x80) >> 7)
591 - ((data[7] & 0x40) >> 6));
592 wacom_report_key(wcombo, BTN_SIDE, data[6] & 0x08);
593 wacom_report_key(wcombo, BTN_EXTRA, data[6] & 0x10);
594
595 wacom_report_abs(wcombo, ABS_TILT_X,
596 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
597 wacom_report_abs(wcombo, ABS_TILT_Y, data[8] & 0x7f);
598 } else {
599 /* 2D mouse packet */
600 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x04);
601 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x08);
602 wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x10);
603 wacom_report_rel(wcombo, REL_WHEEL, (data[8] & 0x01)
Ping Cheng3bea7332006-07-13 18:01:36 -0700604 - ((data[8] & 0x02) >> 1));
605
Ping Cheng6f660f12009-05-08 18:30:33 -0700606 /* I3 2D mouse side buttons */
607 if (wacom->features->type >= INTUOS3S && wacom->features->type <= INTUOS3L) {
608 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x40);
609 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x20);
610 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700611 }
Ping Cheng6f660f12009-05-08 18:30:33 -0700612 } else if ((wacom->features->type < INTUOS3S || wacom->features->type == INTUOS3L ||
613 wacom->features->type == INTUOS4L) &&
614 wacom->tool[idx] == BTN_TOOL_LENS) {
Ping Cheng3bea7332006-07-13 18:01:36 -0700615 /* Lens cursor packets */
616 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
617 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02);
618 wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x04);
619 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x10);
620 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x08);
621 }
622 }
623
624 wacom_report_abs(wcombo, ABS_MISC, wacom->id[idx]); /* report tool id */
625 wacom_report_key(wcombo, wacom->tool[idx], 1);
626 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
627 return 1;
628}
629
Ping Chengec67bbe2009-12-15 00:35:24 -0800630
631static void wacom_tpc_finger_in(struct wacom_wac *wacom, void *wcombo, char *data, int idx)
632{
633 wacom_report_abs(wcombo, ABS_X,
634 (data[2 + idx * 2] & 0xff) | ((data[3 + idx * 2] & 0x7f) << 8));
635 wacom_report_abs(wcombo, ABS_Y,
636 (data[6 + idx * 2] & 0xff) | ((data[7 + idx * 2] & 0x7f) << 8));
637 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]);
638 wacom_report_key(wcombo, wacom->tool[idx], 1);
639 if (idx)
640 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
641 else
642 wacom_report_key(wcombo, BTN_TOUCH, 1);
643}
644
645static void wacom_tpc_touch_out(struct wacom_wac *wacom, void *wcombo, int idx)
646{
647 wacom_report_abs(wcombo, ABS_X, 0);
648 wacom_report_abs(wcombo, ABS_Y, 0);
649 wacom_report_abs(wcombo, ABS_MISC, 0);
650 wacom_report_key(wcombo, wacom->tool[idx], 0);
651 if (idx)
652 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
653 else
654 wacom_report_key(wcombo, BTN_TOUCH, 0);
655 return;
656}
657
658static void wacom_tpc_touch_in(struct wacom_wac *wacom, void *wcombo)
659{
660 char *data = wacom->data;
661 struct urb *urb = ((struct wacom_combo *)wcombo)->urb;
662 static int firstFinger = 0;
663 static int secondFinger = 0;
664
665 wacom->tool[0] = BTN_TOOL_DOUBLETAP;
666 wacom->id[0] = TOUCH_DEVICE_ID;
667 wacom->tool[1] = BTN_TOOL_TRIPLETAP;
668
669 if (urb->actual_length != WACOM_PKGLEN_TPC1FG) {
670 switch (data[0]) {
Ping Chengcad74702009-12-15 00:35:25 -0800671 case WACOM_REPORT_TPC1FG:
Ping Chengec67bbe2009-12-15 00:35:24 -0800672 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[2]));
673 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4]));
674 wacom_report_abs(wcombo, ABS_PRESSURE, wacom_le16_to_cpu(&data[6]));
675 wacom_report_key(wcombo, BTN_TOUCH, wacom_le16_to_cpu(&data[6]));
676 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]);
677 wacom_report_key(wcombo, wacom->tool[0], 1);
678 break;
Ping Chengcad74702009-12-15 00:35:25 -0800679 case WACOM_REPORT_TPC2FG:
Ping Chengec67bbe2009-12-15 00:35:24 -0800680 /* keep this byte to send proper out-prox event */
681 wacom->id[1] = data[1] & 0x03;
682
683 if (data[1] & 0x01) {
684 wacom_tpc_finger_in(wacom, wcombo, data, 0);
685 firstFinger = 1;
686 } else if (firstFinger) {
687 wacom_tpc_touch_out(wacom, wcombo, 0);
688 }
689
690 if (data[1] & 0x02) {
691 /* sync first finger data */
692 if (firstFinger)
693 wacom_input_sync(wcombo);
694
695 wacom_tpc_finger_in(wacom, wcombo, data, 1);
696 secondFinger = 1;
697 } else if (secondFinger) {
698 /* sync first finger data */
699 if (firstFinger)
700 wacom_input_sync(wcombo);
701
702 wacom_tpc_touch_out(wacom, wcombo, 1);
703 secondFinger = 0;
704 }
705 if (!(data[1] & 0x01))
706 firstFinger = 0;
707 break;
708 }
709 } else {
710 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[1]));
711 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[3]));
712 wacom_report_key(wcombo, BTN_TOUCH, 1);
713 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]);
714 wacom_report_key(wcombo, wacom->tool[0], 1);
715 }
716 return;
717}
718
Roel Kluin0de048a2008-12-20 05:19:43 -0500719static int wacom_tpc_irq(struct wacom_wac *wacom, void *wcombo)
Ping Cheng545f4e92008-11-24 11:44:27 -0500720{
721 char *data = wacom->data;
Ping Chengec67bbe2009-12-15 00:35:24 -0800722 int prox = 0, pressure, idx = -1;
Ping Cheng545f4e92008-11-24 11:44:27 -0500723 static int stylusInProx, touchInProx = 1, touchOut;
724 struct urb *urb = ((struct wacom_combo *)wcombo)->urb;
725
726 dbg("wacom_tpc_irq: received report #%d", data[0]);
727
Ping Chengcad74702009-12-15 00:35:25 -0800728 if (urb->actual_length == WACOM_PKGLEN_TPC1FG || /* single touch */
729 data[0] == WACOM_REPORT_TPC1FG || /* single touch */
730 data[0] == WACOM_REPORT_TPC2FG) { /* 2FG touch */
Ping Chengee545002009-12-15 00:35:24 -0800731 if (urb->actual_length == WACOM_PKGLEN_TPC1FG) { /* with touch */
Ping Chengec67bbe2009-12-15 00:35:24 -0800732 prox = data[0] & 0x01;
Ping Cheng545f4e92008-11-24 11:44:27 -0500733 } else { /* with capacity */
Ping Chengcad74702009-12-15 00:35:25 -0800734 if (data[0] == WACOM_REPORT_TPC1FG)
Ping Chengec67bbe2009-12-15 00:35:24 -0800735 /* single touch */
736 prox = data[1] & 0x01;
737 else
738 /* 2FG touch data */
739 prox = data[1] & 0x03;
Ping Cheng545f4e92008-11-24 11:44:27 -0500740 }
741
742 if (!stylusInProx) { /* stylus not in prox */
743 if (prox) {
744 if (touchInProx) {
Ping Chengec67bbe2009-12-15 00:35:24 -0800745 wacom_tpc_touch_in(wacom, wcombo);
Ping Cheng545f4e92008-11-24 11:44:27 -0500746 touchOut = 1;
747 return 1;
748 }
749 } else {
Ping Chengec67bbe2009-12-15 00:35:24 -0800750 /* 2FGT out-prox */
Ping Chengcad74702009-12-15 00:35:25 -0800751 if (data[0] == WACOM_REPORT_TPC2FG) {
Ping Chengec67bbe2009-12-15 00:35:24 -0800752 idx = (wacom->id[1] & 0x01) - 1;
753 if (idx == 0) {
754 wacom_tpc_touch_out(wacom, wcombo, idx);
755 /* sync first finger event */
756 if (wacom->id[1] & 0x02)
757 wacom_input_sync(wcombo);
758 }
759 idx = (wacom->id[1] & 0x02) - 1;
760 if (idx == 1)
761 wacom_tpc_touch_out(wacom, wcombo, idx);
762 } else /* one finger touch */
763 wacom_tpc_touch_out(wacom, wcombo, 0);
Ping Cheng545f4e92008-11-24 11:44:27 -0500764 touchOut = 0;
765 touchInProx = 1;
766 return 1;
767 }
768 } else if (touchOut || !prox) { /* force touch out-prox */
Ping Chengec67bbe2009-12-15 00:35:24 -0800769 wacom_tpc_touch_out(wacom, wcombo, 0);
Ping Cheng545f4e92008-11-24 11:44:27 -0500770 touchOut = 0;
771 touchInProx = 1;
772 return 1;
773 }
Ping Chengcad74702009-12-15 00:35:25 -0800774 } else if (data[0] == WACOM_REPORT_PENABLED) { /* Penabled */
Ping Cheng545f4e92008-11-24 11:44:27 -0500775 prox = data[1] & 0x20;
776
777 touchInProx = 0;
778
Ping Cheng545f4e92008-11-24 11:44:27 -0500779 if (prox) { /* in prox */
Ping Chengec67bbe2009-12-15 00:35:24 -0800780 if (!wacom->id[0]) {
Ping Cheng545f4e92008-11-24 11:44:27 -0500781 /* Going into proximity select tool */
Ping Chengec67bbe2009-12-15 00:35:24 -0800782 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
783 if (wacom->tool[0] == BTN_TOOL_PEN)
Ping Cheng545f4e92008-11-24 11:44:27 -0500784 wacom->id[0] = STYLUS_DEVICE_ID;
Ping Chengec67bbe2009-12-15 00:35:24 -0800785 else
786 wacom->id[0] = ERASER_DEVICE_ID;
Ping Cheng545f4e92008-11-24 11:44:27 -0500787 }
788 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02);
789 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x10);
790 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[2]));
791 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4]));
792 pressure = ((data[7] & 0x01) << 8) | data[6];
793 if (pressure < 0)
794 pressure = wacom->features->pressure_max + pressure + 1;
795 wacom_report_abs(wcombo, ABS_PRESSURE, pressure);
Ping Chengec67bbe2009-12-15 00:35:24 -0800796 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x05);
Ping Cheng545f4e92008-11-24 11:44:27 -0500797 } else {
Ping Chengec67bbe2009-12-15 00:35:24 -0800798 wacom_report_abs(wcombo, ABS_X, 0);
799 wacom_report_abs(wcombo, ABS_Y, 0);
Ping Cheng545f4e92008-11-24 11:44:27 -0500800 wacom_report_abs(wcombo, ABS_PRESSURE, 0);
801 wacom_report_key(wcombo, BTN_STYLUS, 0);
802 wacom_report_key(wcombo, BTN_STYLUS2, 0);
803 wacom_report_key(wcombo, BTN_TOUCH, 0);
Ping Chengec67bbe2009-12-15 00:35:24 -0800804 wacom->id[0] = 0;
805 /* pen is out so touch can be enabled now */
806 touchInProx = 1;
Ping Cheng545f4e92008-11-24 11:44:27 -0500807 }
Ping Chengec67bbe2009-12-15 00:35:24 -0800808 wacom_report_key(wcombo, wacom->tool[0], prox);
Ping Cheng545f4e92008-11-24 11:44:27 -0500809 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]);
810 stylusInProx = prox;
Ping Cheng545f4e92008-11-24 11:44:27 -0500811 return 1;
812 }
813 return 0;
814}
815
Ping Cheng3bea7332006-07-13 18:01:36 -0700816int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo)
817{
818 switch (wacom_wac->features->type) {
819 case PENPARTNER:
Ping Cheng545f4e92008-11-24 11:44:27 -0500820 return wacom_penpartner_irq(wacom_wac, wcombo);
821
Ping Cheng3bea7332006-07-13 18:01:36 -0700822 case PL:
Ping Cheng545f4e92008-11-24 11:44:27 -0500823 return wacom_pl_irq(wacom_wac, wcombo);
824
Ping Cheng3bea7332006-07-13 18:01:36 -0700825 case WACOM_G4:
826 case GRAPHIRE:
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400827 case WACOM_MO:
Ping Cheng545f4e92008-11-24 11:44:27 -0500828 return wacom_graphire_irq(wacom_wac, wcombo);
829
Ping Cheng3bea7332006-07-13 18:01:36 -0700830 case PTU:
Ping Cheng545f4e92008-11-24 11:44:27 -0500831 return wacom_ptu_irq(wacom_wac, wcombo);
832
Ping Cheng3bea7332006-07-13 18:01:36 -0700833 case INTUOS:
Ping Cheng8d32e3a2006-09-26 13:34:47 -0700834 case INTUOS3S:
Ping Cheng3bea7332006-07-13 18:01:36 -0700835 case INTUOS3:
836 case INTUOS3L:
Ping Cheng6f660f12009-05-08 18:30:33 -0700837 case INTUOS4S:
838 case INTUOS4:
839 case INTUOS4L:
Ping Cheng3bea7332006-07-13 18:01:36 -0700840 case CINTIQ:
Ping Cheng0e1763f2008-03-13 16:46:46 -0400841 case WACOM_BEE:
Ping Cheng545f4e92008-11-24 11:44:27 -0500842 return wacom_intuos_irq(wacom_wac, wcombo);
843
844 case TABLETPC:
Ping Chengec67bbe2009-12-15 00:35:24 -0800845 case TABLETPC2FG:
Ping Cheng545f4e92008-11-24 11:44:27 -0500846 return wacom_tpc_irq(wacom_wac, wcombo);
847
Ping Cheng3bea7332006-07-13 18:01:36 -0700848 default:
849 return 0;
850 }
851 return 0;
852}
853
854void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
855{
856 switch (wacom_wac->features->type) {
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400857 case WACOM_MO:
858 input_dev_mo(input_dev, wacom_wac);
Ping Cheng3bea7332006-07-13 18:01:36 -0700859 case WACOM_G4:
860 input_dev_g4(input_dev, wacom_wac);
861 /* fall through */
862 case GRAPHIRE:
863 input_dev_g(input_dev, wacom_wac);
864 break;
Ping Cheng0e1763f2008-03-13 16:46:46 -0400865 case WACOM_BEE:
866 input_dev_bee(input_dev, wacom_wac);
Ping Cheng3bea7332006-07-13 18:01:36 -0700867 case INTUOS3:
868 case INTUOS3L:
869 case CINTIQ:
870 input_dev_i3(input_dev, wacom_wac);
871 /* fall through */
Ping Cheng8d32e3a2006-09-26 13:34:47 -0700872 case INTUOS3S:
873 input_dev_i3s(input_dev, wacom_wac);
Ping Cheng545f4e92008-11-24 11:44:27 -0500874 /* fall through */
Ping Cheng3bea7332006-07-13 18:01:36 -0700875 case INTUOS:
876 input_dev_i(input_dev, wacom_wac);
877 break;
Ping Cheng6f660f12009-05-08 18:30:33 -0700878 case INTUOS4:
879 case INTUOS4L:
880 input_dev_i4(input_dev, wacom_wac);
881 /* fall through */
882 case INTUOS4S:
883 input_dev_i4s(input_dev, wacom_wac);
884 input_dev_i(input_dev, wacom_wac);
885 break;
Ping Chengec67bbe2009-12-15 00:35:24 -0800886 case TABLETPC2FG:
887 input_dev_tpc2fg(input_dev, wacom_wac);
888 /* fall through */
889 case TABLETPC:
890 input_dev_tpc(input_dev, wacom_wac);
891 if (wacom_wac->features->device_type != BTN_TOOL_PEN)
892 break; /* no need to process stylus stuff */
893
894 /* fall through */
Ping Cheng3bea7332006-07-13 18:01:36 -0700895 case PL:
896 case PTU:
897 input_dev_pl(input_dev, wacom_wac);
Ping Cheng545f4e92008-11-24 11:44:27 -0500898 /* fall through */
Ping Cheng3bea7332006-07-13 18:01:36 -0700899 case PENPARTNER:
900 input_dev_pt(input_dev, wacom_wac);
901 break;
902 }
903 return;
904}
905
906static struct wacom_features wacom_features[] = {
Ping Chengee545002009-12-15 00:35:24 -0800907 { "Wacom Penpartner", WACOM_PKGLEN_PENPRTN, 5040, 3780, 255, 0, PENPARTNER },
908 { "Wacom Graphire", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511, 63, GRAPHIRE },
909 { "Wacom Graphire2 4x5", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511, 63, GRAPHIRE },
910 { "Wacom Graphire2 5x7", WACOM_PKGLEN_GRAPHIRE, 13918, 10206, 511, 63, GRAPHIRE },
911 { "Wacom Graphire3", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511, 63, GRAPHIRE },
912 { "Wacom Graphire3 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, GRAPHIRE },
913 { "Wacom Graphire4 4x5", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511, 63, WACOM_G4 },
914 { "Wacom Graphire4 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, WACOM_G4 },
915 { "Wacom BambooFun 4x5", WACOM_PKGLEN_BBFUN, 14760, 9225, 511, 63, WACOM_MO },
916 { "Wacom BambooFun 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 511, 63, WACOM_MO },
917 { "Wacom Bamboo1 Medium", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, GRAPHIRE },
918 { "Wacom Volito", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE },
919 { "Wacom PenStation2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 255, 63, GRAPHIRE },
920 { "Wacom Volito2 4x5", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE },
921 { "Wacom Volito2 2x3", WACOM_PKGLEN_GRAPHIRE, 3248, 2320, 511, 63, GRAPHIRE },
922 { "Wacom PenPartner2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 511, 63, GRAPHIRE },
923 { "Wacom Bamboo", WACOM_PKGLEN_BBFUN, 14760, 9225, 511, 63, WACOM_MO },
924 { "Wacom Bamboo1", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE },
925 { "Wacom Intuos 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023, 31, INTUOS },
926 { "Wacom Intuos 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS },
927 { "Wacom Intuos 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023, 31, INTUOS },
928 { "Wacom Intuos 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023, 31, INTUOS },
929 { "Wacom Intuos 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023, 31, INTUOS },
930 { "Wacom PL400", WACOM_PKGLEN_GRAPHIRE, 5408, 4056, 255, 0, PL },
931 { "Wacom PL500", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 255, 0, PL },
932 { "Wacom PL600", WACOM_PKGLEN_GRAPHIRE, 6126, 4604, 255, 0, PL },
933 { "Wacom PL600SX", WACOM_PKGLEN_GRAPHIRE, 6260, 5016, 255, 0, PL },
934 { "Wacom PL550", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 511, 0, PL },
935 { "Wacom PL800", WACOM_PKGLEN_GRAPHIRE, 7220, 5780, 511, 0, PL },
936 { "Wacom PL700", WACOM_PKGLEN_GRAPHIRE, 6758, 5406, 511, 0, PL },
937 { "Wacom PL510", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511, 0, PL },
938 { "Wacom DTU710", WACOM_PKGLEN_GRAPHIRE, 34080, 27660, 511, 0, PL },
939 { "Wacom DTF521", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511, 0, PL },
940 { "Wacom DTF720", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511, 0, PL },
941 { "Wacom DTF720a", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511, 0, PL },
942 { "Wacom Cintiq Partner", WACOM_PKGLEN_GRAPHIRE, 20480, 15360, 511, 0, PTU },
943 { "Wacom Intuos2 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023, 31, INTUOS },
944 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS },
945 { "Wacom Intuos2 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023, 31, INTUOS },
946 { "Wacom Intuos2 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023, 31, INTUOS },
947 { "Wacom Intuos2 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023, 31, INTUOS },
948 { "Wacom Intuos3 4x5", WACOM_PKGLEN_INTUOS, 25400, 20320, 1023, 63, INTUOS3S },
949 { "Wacom Intuos3 6x8", WACOM_PKGLEN_INTUOS, 40640, 30480, 1023, 63, INTUOS3 },
950 { "Wacom Intuos3 9x12", WACOM_PKGLEN_INTUOS, 60960, 45720, 1023, 63, INTUOS3 },
951 { "Wacom Intuos3 12x12", WACOM_PKGLEN_INTUOS, 60960, 60960, 1023, 63, INTUOS3L },
952 { "Wacom Intuos3 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 1023, 63, INTUOS3L },
953 { "Wacom Intuos3 6x11", WACOM_PKGLEN_INTUOS, 54204, 31750, 1023, 63, INTUOS3 },
954 { "Wacom Intuos3 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 1023, 63, INTUOS3S },
955 { "Wacom Intuos4 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047, 63, INTUOS4S },
956 { "Wacom Intuos4 6x9", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047, 63, INTUOS4 },
957 { "Wacom Intuos4 8x13", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047, 63, INTUOS4L },
958 { "Wacom Intuos4 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 2047, 63, INTUOS4L },
959 { "Wacom Cintiq 21UX", WACOM_PKGLEN_INTUOS, 87200, 65600, 1023, 63, CINTIQ },
960 { "Wacom Cintiq 20WSX", WACOM_PKGLEN_INTUOS, 86680, 54180, 1023, 63, WACOM_BEE },
961 { "Wacom Cintiq 12WX", WACOM_PKGLEN_INTUOS, 53020, 33440, 1023, 63, WACOM_BEE },
962 { "Wacom DTU1931", WACOM_PKGLEN_GRAPHIRE, 37832, 30305, 511, 0, PL },
963 { "Wacom ISDv4 90", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC },
964 { "Wacom ISDv4 93", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC },
965 { "Wacom ISDv4 9A", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC },
Ping Chengec67bbe2009-12-15 00:35:24 -0800966 { "Wacom ISDv4 9F", WACOM_PKGLEN_PENABLED, 26202, 16325, 255, 0, TABLETPC },
967 { "Wacom ISDv4 E2", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 0, TABLETPC2FG },
968 { "Wacom ISDv4 E3", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 0, TABLETPC2FG },
Ping Chengee545002009-12-15 00:35:24 -0800969 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS },
Ping Cheng3bea7332006-07-13 18:01:36 -0700970 { }
971};
972
973static struct usb_device_id wacom_ids[] = {
974 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x00) },
975 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x10) },
976 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x11) },
977 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x12) },
978 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x13) },
979 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x14) },
980 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x15) },
981 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x16) },
Ping Cheng0e1763f2008-03-13 16:46:46 -0400982 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x17) },
983 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x18) },
Ping Cheng545f4e92008-11-24 11:44:27 -0500984 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x19) },
Ping Cheng3bea7332006-07-13 18:01:36 -0700985 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60) },
986 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x61) },
987 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x62) },
988 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x63) },
989 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x64) },
Ping Cheng7ecfbfd2007-06-14 23:32:48 -0400990 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x65) },
Ping Cheng0e1763f2008-03-13 16:46:46 -0400991 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x69) },
Ping Cheng3bea7332006-07-13 18:01:36 -0700992 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x20) },
993 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x21) },
994 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x22) },
995 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x23) },
996 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x24) },
997 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x30) },
998 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x31) },
999 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x32) },
1000 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x33) },
1001 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x34) },
1002 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x35) },
1003 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x37) },
1004 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x38) },
1005 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x39) },
Ping Cheng3bea7332006-07-13 18:01:36 -07001006 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC4) },
Ping Chengc413ec42009-06-28 22:50:58 -07001007 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC0) },
1008 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC2) },
Ping Cheng3bea7332006-07-13 18:01:36 -07001009 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x03) },
1010 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x41) },
1011 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x42) },
1012 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x43) },
1013 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x44) },
1014 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x45) },
1015 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB0) },
1016 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB1) },
1017 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB2) },
1018 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB3) },
1019 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB4) },
1020 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB5) },
Ping Cheng8d32e3a2006-09-26 13:34:47 -07001021 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB7) },
Ping Cheng6f660f12009-05-08 18:30:33 -07001022 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB8) },
1023 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB9) },
1024 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xBA) },
1025 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xBB) },
Ping Cheng3bea7332006-07-13 18:01:36 -07001026 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) },
Ping Chengb345dc72008-04-24 23:34:05 -04001027 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC5) },
Ping Cheng0e1763f2008-03-13 16:46:46 -04001028 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC6) },
Ping Cheng545f4e92008-11-24 11:44:27 -05001029 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC7) },
1030 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x90) },
1031 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x93) },
1032 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x9A) },
Ping Chengec67bbe2009-12-15 00:35:24 -08001033 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x9F) },
1034 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xE2) },
1035 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xE3) },
Ping Cheng3bea7332006-07-13 18:01:36 -07001036 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) },
1037 { }
1038};
1039
Ping Cheng545f4e92008-11-24 11:44:27 -05001040const struct usb_device_id *get_device_table(void)
1041{
1042 const struct usb_device_id *id_table = wacom_ids;
1043
Ping Cheng3bea7332006-07-13 18:01:36 -07001044 return id_table;
1045}
1046
Ping Cheng545f4e92008-11-24 11:44:27 -05001047struct wacom_features * get_wacom_feature(const struct usb_device_id *id)
1048{
Ping Cheng3bea7332006-07-13 18:01:36 -07001049 int index = id - wacom_ids;
1050 struct wacom_features *wf = &wacom_features[index];
Ping Cheng545f4e92008-11-24 11:44:27 -05001051
Ping Cheng3bea7332006-07-13 18:01:36 -07001052 return wf;
1053}
1054
1055MODULE_DEVICE_TABLE(usb, wacom_ids);