1 /*
2 * $Id: wacom.c,v 1.23 2001/05/29 12:57:18 vojtech Exp $
3 *
4 * Copyright (c) 2000-2001 Vojtech Pavlik <vojtech@suse.cz>
5 * Copyright (c) 2000 Andreas Bach Aaen <abach@stofanet.dk>
6 * Copyright (c) 2000 Clifford Wolf <clifford@clifford.at>
7 * Copyright (c) 2000 Sam Mosel <sam.mosel@computer.org>
8 * Copyright (c) 2000 James E. Blair <corvus@gnu.org>
9 * Copyright (c) 2000 Daniel Egger <egger@suse.de>
10 * Copyright (c) 2001 Frederic Lepied <flepied@mandrakesoft.com>
11 *
12 * USB Wacom Graphire and Wacom Intuos tablet support
13 *
14 * Sponsored by SuSE
15 *
16 * ChangeLog:
17 * v0.1 (vp) - Initial release
18 * v0.2 (aba) - Support for all buttons / combinations
19 * v0.3 (vp) - Support for Intuos added
20 * v0.4 (sm) - Support for more Intuos models, menustrip
21 * relative mode, proximity.
22 * v0.5 (vp) - Big cleanup, nifty features removed,
23 * they belong in userspace
24 * v1.8 (vp) - Submit URB only when operating, moved to CVS,
25 * use input_report_key instead of report_btn and
26 * other cleanups
27 * v1.11 (vp) - Add URB ->dev setting for new kernels
28 * v1.11 (jb) - Add support for the 4D Mouse & Lens
29 * v1.12 (de) - Add support for two more inking pen IDs
30 * v1.14 (vp) - Use new USB device id probing scheme.
31 * Fix Wacom Graphire mouse wheel
32 * v1.18 (vp) - Fix mouse wheel direction
33 * Make mouse relative
34 * v1.20 (fl) - Report tool id for Intuos devices
35 * - Multi tools support
36 * - Corrected Intuos protocol decoding (airbrush, 4D mouse, lens cursor...)
37 * - Add PL models support
38 * - Fix Wacom Graphire mouse wheel again
39 * v1.21 (vp) - Removed protocol descriptions
40 * - Added MISC_SERIAL for tool serial numbers
41 * (gb) - Identify version on module load.
42 * v1.21.1 (fl) - added Graphire2 support
43 * v1.21.2 (fl) - added Intuos2 support
44 * - added all the PL ids
45 * v1.21.3 (fl) - added another eraser id from Neil Okamoto
46 * - added smooth filter for Graphire from Peri Hankey
47 * - added PenPartner support from Olaf van Es
48 * - new tool ids from Ole Martin Bjoerndalen
49 */
50
51 /*
52 * This program is free software; you can redistribute it and/or modify
53 * it under the terms of the GNU General Public License as published by
54 * the Free Software Foundation; either version 2 of the License, or
55 * (at your option) any later version.
56 *
57 * This program is distributed in the hope that it will be useful,
58 * but WITHOUT ANY WARRANTY; without even the implied warranty of
59 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
60 * GNU General Public License for more details.
61 *
62 * You should have received a copy of the GNU General Public License
63 * along with this program; if not, write to the Free Software
64 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
65 *
66 * Should you need to contact me, the author, you can do so either by
67 * e-mail - mail your message to <vojtech@suse.cz>, or by paper mail:
68 * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic
69 */
70
71 #include <linux/kernel.h>
72 #include <linux/slab.h>
73 #include <linux/input.h>
74 #include <linux/module.h>
75 #include <linux/init.h>
76 #include <linux/usb.h>
77
78 /*
79 * Version Information
80 */
81 #define DRIVER_VERSION "v1.21.3"
82 #define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@suse.cz>"
83 #define DRIVER_DESC "USB Wacom Graphire and Wacom Intuos tablet driver"
84
85 MODULE_AUTHOR( DRIVER_AUTHOR );
86 MODULE_DESCRIPTION( DRIVER_DESC );
87 MODULE_LICENSE("GPL");
88
89 #define USB_VENDOR_ID_WACOM 0x056a
90
91 struct wacom_features {
92 char *name;
93 int pktlen;
94 int x_max;
95 int y_max;
96 int pressure_max;
97 int distance_max;
98 void (*irq)(struct urb *urb);
99 unsigned long evbit;
100 unsigned long absbit;
101 unsigned long relbit;
102 unsigned long btnbit;
103 unsigned long digibit;
104 };
105
106 struct wacom {
107 signed char data[10];
108 struct input_dev dev;
109 struct usb_device *usbdev;
110 struct urb irq;
111 struct wacom_features *features;
112 int tool[2];
113 int open;
114 __u32 serial[2];
115 };
116
wacom_pl_irq(struct urb * urb)117 static void wacom_pl_irq(struct urb *urb)
118 {
119 struct wacom *wacom = urb->context;
120 unsigned char *data = wacom->data;
121 struct input_dev *dev = &wacom->dev;
122 int prox;
123
124 if (urb->status) return;
125
126 if (data[0] != 2) {
127 printk(KERN_ERR "wacom_pl_irq: received unknown report #%d\n", data[0]);
128 return;
129 }
130
131 prox = data[1] & 0x20;
132
133 input_report_key(dev, BTN_TOOL_PEN, prox);
134
135 if (prox) {
136 int pressure = (data[4] & 0x04) >> 2 | ((__u32)(data[7] & 0x7f) << 1);
137
138 input_report_abs(dev, ABS_X, data[3] | ((__u32)data[2] << 8) | ((__u32)(data[1] & 0x03) << 16));
139 input_report_abs(dev, ABS_Y, data[6] | ((__u32)data[5] << 8) | ((__u32)(data[4] & 0x03) << 8));
140 input_report_abs(dev, ABS_PRESSURE, (data[7] & 0x80) ? (255 - pressure) : (pressure + 255));
141 input_report_key(dev, BTN_TOUCH, data[4] & 0x08);
142 input_report_key(dev, BTN_STYLUS, data[4] & 0x10);
143 input_report_key(dev, BTN_STYLUS2, data[4] & 0x20);
144 }
145
146 input_event(dev, EV_MSC, MSC_SERIAL, 0);
147 }
148
wacom_penpartner_irq(struct urb * urb)149 static void wacom_penpartner_irq(struct urb *urb)
150 {
151 struct wacom *wacom = urb->context;
152 unsigned char *data = wacom->data;
153 struct input_dev *dev = &wacom->dev;
154 int x, y;
155 char pressure;
156 int leftmb;
157
158 if (urb->status) return;
159
160 x = data[2] << 8 | data[1];
161 y = data[4] << 8 | data[3];
162 pressure = data[6];
163 leftmb = ((pressure > -80) && !(data[5] &20));
164
165 input_report_key(dev, BTN_TOOL_PEN, 1);
166
167 input_report_abs(dev, ABS_X, x);
168 input_report_abs(dev, ABS_Y, y);
169 input_report_abs(dev, ABS_PRESSURE, pressure+127);
170 input_report_key(dev, BTN_LEFT, leftmb);
171 input_report_key(dev, BTN_RIGHT, (data[5] & 0x40));
172
173 input_event(dev, EV_MSC, MSC_SERIAL, leftmb);
174 }
175
wacom_graphire_irq(struct urb * urb)176 static void wacom_graphire_irq(struct urb *urb)
177 {
178 struct wacom *wacom = urb->context;
179 unsigned char *data = wacom->data;
180 struct input_dev *dev = &wacom->dev;
181 int x, y;
182
183 if (urb->status) return;
184
185 if (data[0] != 2) {
186 printk(KERN_ERR "wacom_graphire_irq: received unknown report #%d\n", data[0]);
187 return;
188 }
189
190 x = data[2] | ((__u32)data[3] << 8);
191 y = data[4] | ((__u32)data[5] << 8);
192
193 switch ((data[1] >> 5) & 3) {
194
195 case 0: /* Pen */
196 input_report_key(dev, BTN_TOOL_PEN, data[1] & 0x80);
197 break;
198
199 case 1: /* Rubber */
200 input_report_key(dev, BTN_TOOL_RUBBER, data[1] & 0x80);
201 break;
202
203 case 2: /* Mouse */
204 input_report_key(dev, BTN_TOOL_MOUSE, data[7] > 24);
205 input_report_key(dev, BTN_LEFT, data[1] & 0x01);
206 input_report_key(dev, BTN_RIGHT, data[1] & 0x02);
207 input_report_key(dev, BTN_MIDDLE, data[1] & 0x04);
208 input_report_abs(dev, ABS_DISTANCE, data[7]);
209 input_report_rel(dev, REL_WHEEL, (signed char) data[6]);
210
211 input_report_abs(dev, ABS_X, x);
212 input_report_abs(dev, ABS_Y, y);
213
214 input_event(dev, EV_MSC, MSC_SERIAL, data[1] & 0x01);
215 return;
216 }
217
218 if (data[1] & 0x80) {
219 input_report_abs(dev, ABS_X, x);
220 input_report_abs(dev, ABS_Y, y);
221 }
222
223 input_report_abs(dev, ABS_PRESSURE, data[6] | ((__u32)data[7] << 8));
224 input_report_key(dev, BTN_TOUCH, data[1] & 0x01);
225 input_report_key(dev, BTN_STYLUS, data[1] & 0x02);
226 input_report_key(dev, BTN_STYLUS2, data[1] & 0x04);
227
228 input_event(dev, EV_MSC, MSC_SERIAL, data[1] & 0x01);
229 }
230
wacom_intuos_irq(struct urb * urb)231 static void wacom_intuos_irq(struct urb *urb)
232 {
233 struct wacom *wacom = urb->context;
234 unsigned char *data = wacom->data;
235 struct input_dev *dev = &wacom->dev;
236 unsigned int t;
237 int idx;
238
239 if (urb->status) return;
240
241 if (data[0] != 2) {
242 printk(KERN_ERR "wacom_intuos_irq: received unknown report #%d\n", data[0]);
243 return;
244 }
245
246 /* tool number */
247 idx = data[1] & 0x01;
248
249 if ((data[1] & 0xfc) == 0xc0) { /* Enter report */
250
251 wacom->serial[idx] = ((__u32)(data[3] & 0x0f) << 4) + /* serial number of the tool */
252 ((__u32)data[4] << 16) + ((__u32)data[5] << 12) +
253 ((__u32)data[6] << 4) + (data[7] >> 4);
254
255 switch (((__u32)data[2] << 4) | (data[3] >> 4)) {
256 case 0x832:
257 case 0x012: wacom->tool[idx] = BTN_TOOL_PENCIL; break; /* Inking pen */
258 case 0x822:
259 case 0x852:
260 case 0x022: wacom->tool[idx] = BTN_TOOL_PEN; break; /* Pen */
261 case 0x812:
262 case 0x032: wacom->tool[idx] = BTN_TOOL_BRUSH; break; /* Stroke pen */
263 case 0x09c:
264 case 0x007:
265 case 0x094: wacom->tool[idx] = BTN_TOOL_MOUSE; break; /* Mouse 4D */
266 case 0x096: wacom->tool[idx] = BTN_TOOL_LENS; break; /* Lens cursor */
267 case 0x82a:
268 case 0x85a:
269 case 0x91a:
270 case 0x0fa: wacom->tool[idx] = BTN_TOOL_RUBBER; break; /* Eraser */
271 case 0x112: wacom->tool[idx] = BTN_TOOL_AIRBRUSH; break; /* Airbrush */
272 default: wacom->tool[idx] = BTN_TOOL_PEN; break; /* Unknown tool */
273 }
274
275 input_report_key(dev, wacom->tool[idx], 1);
276 input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
277 return;
278 }
279
280 if ((data[1] & 0xfe) == 0x80) { /* Exit report */
281 input_report_key(dev, wacom->tool[idx], 0);
282 input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
283 return;
284 }
285
286 input_report_abs(dev, ABS_X, ((__u32)data[2] << 8) | data[3]);
287 input_report_abs(dev, ABS_Y, ((__u32)data[4] << 8) | data[5]);
288 input_report_abs(dev, ABS_DISTANCE, data[9] >> 4);
289
290 if ((data[1] & 0xb8) == 0xa0) { /* general pen packet */
291 input_report_abs(dev, ABS_PRESSURE, t = ((__u32)data[6] << 2) | ((data[7] >> 6) & 3));
292 input_report_abs(dev, ABS_TILT_X, ((data[7] << 1) & 0x7e) | (data[8] >> 7));
293 input_report_abs(dev, ABS_TILT_Y, data[8] & 0x7f);
294 input_report_key(dev, BTN_STYLUS, data[1] & 2);
295 input_report_key(dev, BTN_STYLUS2, data[1] & 4);
296 input_report_key(dev, BTN_TOUCH, t > 10);
297 }
298
299 if ((data[1] & 0xbc) == 0xb4) { /* airbrush second packet */
300 input_report_abs(dev, ABS_WHEEL, ((__u32)data[6] << 2) | ((data[7] >> 6) & 3));
301 input_report_abs(dev, ABS_TILT_X, ((data[7] << 1) & 0x7e) | (data[8] >> 7));
302 input_report_abs(dev, ABS_TILT_Y, data[8] & 0x7f);
303 }
304
305 if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0) { /* 4D mouse or Lens cursor packets */
306
307 if (data[1] & 0x02) { /* Rotation packet */
308
309 input_report_abs(dev, ABS_RZ, (data[7] & 0x20) ?
310 ((__u32)data[6] << 2) | ((data[7] >> 6) & 3):
311 (-(((__u32)data[6] << 2) | ((data[7] >> 6) & 3))) - 1);
312
313 } else {
314
315 input_report_key(dev, BTN_LEFT, data[8] & 0x01);
316 input_report_key(dev, BTN_MIDDLE, data[8] & 0x02);
317 input_report_key(dev, BTN_RIGHT, data[8] & 0x04);
318
319 if ((data[1] & 0x10) == 0) { /* 4D mouse packets */
320
321 input_report_key(dev, BTN_SIDE, data[8] & 0x20);
322 input_report_key(dev, BTN_EXTRA, data[8] & 0x10);
323 input_report_abs(dev, ABS_THROTTLE, (data[8] & 0x08) ?
324 ((__u32)data[6] << 2) | ((data[7] >> 6) & 3) :
325 -((__u32)data[6] << 2) | ((data[7] >> 6) & 3));
326
327 } else { /* Lens cursor packets */
328
329 input_report_key(dev, BTN_SIDE, data[8] & 0x10);
330 input_report_key(dev, BTN_EXTRA, data[8] & 0x08);
331 }
332 }
333 }
334
335 input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
336 }
337
338 #define WACOM_INTUOS_TOOLS (BIT(BTN_TOOL_BRUSH) | BIT(BTN_TOOL_PENCIL) | BIT(BTN_TOOL_AIRBRUSH) | BIT(BTN_TOOL_LENS))
339 #define WACOM_INTUOS_BUTTONS (BIT(BTN_SIDE) | BIT(BTN_EXTRA))
340 #define WACOM_INTUOS_ABS (BIT(ABS_TILT_X) | BIT(ABS_TILT_Y) | BIT(ABS_RZ) | BIT(ABS_THROTTLE))
341
342 struct wacom_features wacom_features[] = {
343 { "Wacom Penpartner", 7, 5040, 3780, 255, 32, wacom_penpartner_irq,
344 0, 0, 0, 0 },
345 { "Wacom Graphire", 8, 10206, 7422, 511, 32, wacom_graphire_irq,
346 BIT(EV_REL), 0, BIT(REL_WHEEL), 0 },
347 { "Wacom Graphire2 4x5", 8, 10206, 7422, 511, 32, wacom_graphire_irq,
348 BIT(EV_REL), 0, BIT(REL_WHEEL), 0 },
349 { "Wacom Graphire2 5x7", 8, 10206, 7422, 511, 32, wacom_graphire_irq,
350 BIT(EV_REL), 0, BIT(REL_WHEEL), 0 },
351 { "Wacom Intuos 4x5", 10, 12700, 10360, 1023, 15, wacom_intuos_irq,
352 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
353 { "Wacom Intuos 6x8", 10, 20320, 15040, 1023, 15, wacom_intuos_irq,
354 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
355 { "Wacom Intuos 9x12", 10, 30480, 23060, 1023, 15, wacom_intuos_irq,
356 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
357 { "Wacom Intuos 12x12", 10, 30480, 30480, 1023, 15, wacom_intuos_irq,
358 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
359 { "Wacom Intuos 12x18", 10, 47720, 30480, 1023, 15, wacom_intuos_irq,
360 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
361 { "Wacom PL400", 8, 12328, 9256, 511, 32, wacom_pl_irq,
362 0, 0, 0, 0 },
363 { "Wacom PL500", 8, 12328, 9256, 511, 32, wacom_pl_irq,
364 0, 0, 0, 0 },
365 { "Wacom PL600", 8, 12328, 9256, 511, 32, wacom_pl_irq,
366 0, 0, 0, 0 },
367 { "Wacom PL600SX", 8, 12328, 9256, 511, 32, wacom_pl_irq,
368 0, 0, 0, 0 },
369 { "Wacom PL550", 8, 12328, 9256, 511, 32, wacom_pl_irq,
370 0, 0, 0, 0 },
371 { "Wacom PL800", 8, 12328, 9256, 511, 32, wacom_pl_irq,
372 0, 0, 0, 0 },
373 { "Wacom Intuos2 4x5", 10, 12700, 10360, 1023, 15, wacom_intuos_irq,
374 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
375 { "Wacom Intuos2 6x8", 10, 20320, 15040, 1023, 15, wacom_intuos_irq,
376 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
377 { "Wacom Intuos2 9x12", 10, 30480, 23060, 1023, 15, wacom_intuos_irq,
378 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
379 { "Wacom Intuos2 12x12", 10, 30480, 30480, 1023, 15, wacom_intuos_irq,
380 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
381 { "Wacom Intuos2 12x18", 10, 47720, 30480, 1023, 15, wacom_intuos_irq,
382 0, WACOM_INTUOS_ABS, 0, WACOM_INTUOS_BUTTONS, WACOM_INTUOS_TOOLS },
383 { NULL , 0 }
384 };
385
386 struct usb_device_id wacom_ids[] = {
387 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x00), driver_info: 0 },
388 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x10), driver_info: 1 },
389 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x11), driver_info: 2 },
390 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x12), driver_info: 3 },
391 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x20), driver_info: 4 },
392 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x21), driver_info: 5 },
393 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x22), driver_info: 6 },
394 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x23), driver_info: 7 },
395 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x24), driver_info: 8 },
396 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x30), driver_info: 9 },
397 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x31), driver_info: 10 },
398 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x32), driver_info: 11 },
399 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x33), driver_info: 12 },
400 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x34), driver_info: 13 },
401 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x35), driver_info: 14 },
402 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x41), driver_info: 15 },
403 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x42), driver_info: 16 },
404 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x43), driver_info: 17 },
405 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x44), driver_info: 18 },
406 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x45), driver_info: 19 },
407 { }
408 };
409
410 MODULE_DEVICE_TABLE(usb, wacom_ids);
411
wacom_open(struct input_dev * dev)412 static int wacom_open(struct input_dev *dev)
413 {
414 struct wacom *wacom = dev->private;
415
416 if (wacom->open++)
417 return 0;
418
419 wacom->irq.dev = wacom->usbdev;
420 if (usb_submit_urb(&wacom->irq))
421 return -EIO;
422
423 return 0;
424 }
425
wacom_close(struct input_dev * dev)426 static void wacom_close(struct input_dev *dev)
427 {
428 struct wacom *wacom = dev->private;
429
430 if (!--wacom->open)
431 usb_unlink_urb(&wacom->irq);
432 }
433
wacom_probe(struct usb_device * dev,unsigned int ifnum,const struct usb_device_id * id)434 static void *wacom_probe(struct usb_device *dev, unsigned int ifnum, const struct usb_device_id *id)
435 {
436 struct usb_endpoint_descriptor *endpoint;
437 struct wacom *wacom;
438 char rep_data[2] = {0x02, 0x02};
439
440 if (!(wacom = kmalloc(sizeof(struct wacom), GFP_KERNEL))) return NULL;
441 memset(wacom, 0, sizeof(struct wacom));
442
443 wacom->features = wacom_features + id->driver_info;
444
445 wacom->dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC) | wacom->features->evbit;
446 wacom->dev.absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE) | BIT(ABS_DISTANCE) | BIT(ABS_WHEEL) | wacom->features->absbit;
447 wacom->dev.relbit[0] |= wacom->features->relbit;
448 wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE) | wacom->features->btnbit;
449 wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) |
450 BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2) | wacom->features->digibit;
451 wacom->dev.mscbit[0] |= BIT(MSC_SERIAL);
452
453 wacom->dev.absmax[ABS_X] = wacom->features->x_max;
454 wacom->dev.absmax[ABS_Y] = wacom->features->y_max;
455 wacom->dev.absmax[ABS_PRESSURE] = wacom->features->pressure_max;
456 wacom->dev.absmax[ABS_DISTANCE] = wacom->features->distance_max;
457 wacom->dev.absmax[ABS_TILT_X] = 127;
458 wacom->dev.absmax[ABS_TILT_Y] = 127;
459 wacom->dev.absmax[ABS_WHEEL] = 1023;
460
461 wacom->dev.absmin[ABS_RZ] = -900;
462 wacom->dev.absmax[ABS_RZ] = 899;
463 wacom->dev.absmin[ABS_THROTTLE] = -1023;
464 wacom->dev.absmax[ABS_THROTTLE] = 1023;
465
466 wacom->dev.absfuzz[ABS_X] = 4;
467 wacom->dev.absfuzz[ABS_Y] = 4;
468
469 wacom->dev.private = wacom;
470 wacom->dev.open = wacom_open;
471 wacom->dev.close = wacom_close;
472
473 wacom->dev.name = wacom->features->name;
474 wacom->dev.idbus = BUS_USB;
475 wacom->dev.idvendor = dev->descriptor.idVendor;
476 wacom->dev.idproduct = dev->descriptor.idProduct;
477 wacom->dev.idversion = dev->descriptor.bcdDevice;
478 wacom->usbdev = dev;
479
480 endpoint = dev->config[0].interface[ifnum].altsetting[0].endpoint + 0;
481
482 usb_set_idle(dev, dev->config[0].interface[ifnum].altsetting[0].bInterfaceNumber, 0, 0);
483
484 FILL_INT_URB(&wacom->irq, dev, usb_rcvintpipe(dev, endpoint->bEndpointAddress),
485 wacom->data, wacom->features->pktlen, wacom->features->irq, wacom, endpoint->bInterval);
486
487 input_register_device(&wacom->dev);
488
489 /* ask the tablet to report tablet data */
490 usb_set_report(dev, ifnum, 3, 2, rep_data, 2);
491 usb_set_report(dev, ifnum, 3, 5, rep_data, 0);
492 usb_set_report(dev, ifnum, 3, 6, rep_data, 0);
493
494 printk(KERN_INFO "input%d: %s on usb%d:%d.%d\n",
495 wacom->dev.number, wacom->features->name, dev->bus->busnum, dev->devnum, ifnum);
496
497 return wacom;
498 }
499
wacom_disconnect(struct usb_device * dev,void * ptr)500 static void wacom_disconnect(struct usb_device *dev, void *ptr)
501 {
502 struct wacom *wacom = ptr;
503 usb_unlink_urb(&wacom->irq);
504 input_unregister_device(&wacom->dev);
505 kfree(wacom);
506 }
507
508 static struct usb_driver wacom_driver = {
509 name: "wacom",
510 probe: wacom_probe,
511 disconnect: wacom_disconnect,
512 id_table: wacom_ids,
513 };
514
wacom_init(void)515 static int __init wacom_init(void)
516 {
517 usb_register(&wacom_driver);
518 info(DRIVER_VERSION " " DRIVER_AUTHOR);
519 info(DRIVER_DESC);
520 return 0;
521 }
522
wacom_exit(void)523 static void __exit wacom_exit(void)
524 {
525 usb_deregister(&wacom_driver);
526 }
527
528 module_init(wacom_init);
529 module_exit(wacom_exit);
530