]> bbs.cooldavid.org Git - net-next-2.6.git/blame - drivers/input/tablet/wacom_sys.c
Input: iforce - support new revision of ACT LABS Force RS
[net-next-2.6.git] / drivers / input / tablet / wacom_sys.c
CommitLineData
3bea733a 1/*
4104d13f 2 * drivers/input/tablet/wacom_sys.c
3bea733a
PC
3 *
4 * USB Wacom Graphire and Wacom Intuos tablet support - system specific code
5 */
6
7/*
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */
13
14#include "wacom.h"
15#include "wacom_wac.h"
16
545f4e99
PC
17/* defines to get HID report descriptor */
18#define HID_DEVICET_HID (USB_TYPE_CLASS | 0x01)
19#define HID_DEVICET_REPORT (USB_TYPE_CLASS | 0x02)
20#define HID_USAGE_UNDEFINED 0x00
21#define HID_USAGE_PAGE 0x05
22#define HID_USAGE_PAGE_DIGITIZER 0x0d
23#define HID_USAGE_PAGE_DESKTOP 0x01
24#define HID_USAGE 0x09
25#define HID_USAGE_X 0x30
26#define HID_USAGE_Y 0x31
27#define HID_USAGE_X_TILT 0x3d
28#define HID_USAGE_Y_TILT 0x3e
29#define HID_USAGE_FINGER 0x22
30#define HID_USAGE_STYLUS 0x20
31#define HID_COLLECTION 0xc0
32
33enum {
34 WCM_UNDEFINED = 0,
35 WCM_DESKTOP,
36 WCM_DIGITIZER,
37};
38
39struct hid_descriptor {
40 struct usb_descriptor_header header;
41 __le16 bcdHID;
42 u8 bCountryCode;
43 u8 bNumDescriptors;
44 u8 bDescriptorType;
45 __le16 wDescriptorLength;
46} __attribute__ ((packed));
47
48/* defines to get/set USB message */
3bea733a
PC
49#define USB_REQ_GET_REPORT 0x01
50#define USB_REQ_SET_REPORT 0x09
545f4e99 51#define WAC_HID_FEATURE_REPORT 0x03
3bea733a
PC
52
53static int usb_get_report(struct usb_interface *intf, unsigned char type,
54 unsigned char id, void *buf, int size)
55{
56 return usb_control_msg(interface_to_usbdev(intf),
57 usb_rcvctrlpipe(interface_to_usbdev(intf), 0),
58 USB_REQ_GET_REPORT, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
59 (type << 8) + id, intf->altsetting[0].desc.bInterfaceNumber,
60 buf, size, 100);
61}
62
63static int usb_set_report(struct usb_interface *intf, unsigned char type,
64 unsigned char id, void *buf, int size)
65{
66 return usb_control_msg(interface_to_usbdev(intf),
67 usb_sndctrlpipe(interface_to_usbdev(intf), 0),
68 USB_REQ_SET_REPORT, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
69 (type << 8) + id, intf->altsetting[0].desc.bInterfaceNumber,
70 buf, size, 1000);
71}
72
73static struct input_dev * get_input_dev(struct wacom_combo *wcombo)
74{
75 return wcombo->wacom->dev;
76}
77
54c9b226 78static void wacom_sys_irq(struct urb *urb)
3bea733a
PC
79{
80 struct wacom *wacom = urb->context;
81 struct wacom_combo wcombo;
82 int retval;
83
84 switch (urb->status) {
85 case 0:
86 /* success */
87 break;
88 case -ECONNRESET:
89 case -ENOENT:
90 case -ESHUTDOWN:
91 /* this urb is terminated, clean up */
ea3e6c59 92 dbg("%s - urb shutting down with status: %d", __func__, urb->status);
3bea733a
PC
93 return;
94 default:
ea3e6c59 95 dbg("%s - nonzero urb status received: %d", __func__, urb->status);
3bea733a
PC
96 goto exit;
97 }
98
99 wcombo.wacom = wacom;
100 wcombo.urb = urb;
3bea733a
PC
101
102 if (wacom_wac_irq(wacom->wacom_wac, (void *)&wcombo))
103 input_sync(get_input_dev(&wcombo));
104
105 exit:
e7224094 106 usb_mark_last_busy(wacom->usbdev);
3bea733a
PC
107 retval = usb_submit_urb (urb, GFP_ATOMIC);
108 if (retval)
109 err ("%s - usb_submit_urb failed with result %d",
ea3e6c59 110 __func__, retval);
3bea733a
PC
111}
112
113void wacom_report_key(void *wcombo, unsigned int key_type, int key_data)
114{
115 input_report_key(get_input_dev((struct wacom_combo *)wcombo), key_type, key_data);
3bea733a
PC
116}
117
118void wacom_report_abs(void *wcombo, unsigned int abs_type, int abs_data)
119{
120 input_report_abs(get_input_dev((struct wacom_combo *)wcombo), abs_type, abs_data);
3bea733a
PC
121}
122
123void wacom_report_rel(void *wcombo, unsigned int rel_type, int rel_data)
124{
125 input_report_rel(get_input_dev((struct wacom_combo *)wcombo), rel_type, rel_data);
3bea733a
PC
126}
127
128void wacom_input_event(void *wcombo, unsigned int type, unsigned int code, int value)
129{
130 input_event(get_input_dev((struct wacom_combo *)wcombo), type, code, value);
3bea733a
PC
131}
132
133__u16 wacom_be16_to_cpu(unsigned char *data)
134{
135 __u16 value;
136 value = be16_to_cpu(*(__be16 *) data);
137 return value;
138}
139
140__u16 wacom_le16_to_cpu(unsigned char *data)
141{
142 __u16 value;
8d32e3ae 143 value = le16_to_cpu(*(__le16 *) data);
3bea733a
PC
144 return value;
145}
146
3bea733a
PC
147void wacom_input_sync(void *wcombo)
148{
149 input_sync(get_input_dev((struct wacom_combo *)wcombo));
3bea733a
PC
150}
151
152static int wacom_open(struct input_dev *dev)
153{
7791bdae 154 struct wacom *wacom = input_get_drvdata(dev);
3bea733a 155
e7224094
ON
156 mutex_lock(&wacom->lock);
157
3bea733a 158 wacom->irq->dev = wacom->usbdev;
e7224094
ON
159
160 if (usb_autopm_get_interface(wacom->intf) < 0) {
161 mutex_unlock(&wacom->lock);
3bea733a 162 return -EIO;
e7224094
ON
163 }
164
165 if (usb_submit_urb(wacom->irq, GFP_KERNEL)) {
166 usb_autopm_put_interface(wacom->intf);
167 mutex_unlock(&wacom->lock);
168 return -EIO;
169 }
170
171 wacom->open = 1;
172 wacom->intf->needs_remote_wakeup = 1;
3bea733a 173
e7224094 174 mutex_unlock(&wacom->lock);
3bea733a
PC
175 return 0;
176}
177
178static void wacom_close(struct input_dev *dev)
179{
7791bdae 180 struct wacom *wacom = input_get_drvdata(dev);
3bea733a 181
e7224094 182 mutex_lock(&wacom->lock);
3bea733a 183 usb_kill_urb(wacom->irq);
e7224094
ON
184 wacom->open = 0;
185 wacom->intf->needs_remote_wakeup = 0;
186 mutex_unlock(&wacom->lock);
3bea733a
PC
187}
188
7ecfbfd3
PC
189void input_dev_mo(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
190{
545f4e99 191 input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_1) |
7b19ada2 192 BIT_MASK(BTN_5);
7ecfbfd3
PC
193 input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
194}
195
3bea733a
PC
196void input_dev_g4(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
197{
7b19ada2
JS
198 input_dev->evbit[0] |= BIT_MASK(EV_MSC);
199 input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL);
200 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_FINGER);
545f4e99 201 input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_0) |
7b19ada2 202 BIT_MASK(BTN_4);
3bea733a
PC
203}
204
205void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
206{
7b19ada2
JS
207 input_dev->evbit[0] |= BIT_MASK(EV_REL);
208 input_dev->relbit[0] |= BIT_MASK(REL_WHEEL);
545f4e99 209 input_dev->keybit[BIT_WORD(BTN_MOUSE)] |= BIT_MASK(BTN_LEFT) |
7b19ada2
JS
210 BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE);
211 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER) |
212 BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_STYLUS2);
3bea733a
PC
213 input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom_wac->features->distance_max, 0, 0);
214}
215
8d32e3ae 216void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
3bea733a 217{
7b19ada2 218 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_FINGER);
545f4e99 219 input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_0) |
7b19ada2 220 BIT_MASK(BTN_1) | BIT_MASK(BTN_2) | BIT_MASK(BTN_3);
071e0a2a 221 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
0e1763f5 222 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
8d32e3ae
PC
223}
224
225void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
226{
545f4e99 227 input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_4) |
7b19ada2 228 BIT_MASK(BTN_5) | BIT_MASK(BTN_6) | BIT_MASK(BTN_7);
071e0a2a 229 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
3bea733a
PC
230}
231
6f660f12
PC
232void input_dev_i4s(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
233{
234 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_FINGER);
235 input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_0) | BIT_MASK(BTN_1) | BIT_MASK(BTN_2) | BIT_MASK(BTN_3);
236 input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_4) | BIT_MASK(BTN_5) | BIT_MASK(BTN_6);
237 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
238}
239
240void input_dev_i4(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
241{
242 input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_7) | BIT_MASK(BTN_8);
243}
244
0e1763f5
PC
245void input_dev_bee(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
246{
545f4e99 247 input_dev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_8) | BIT_MASK(BTN_9);
0e1763f5
PC
248}
249
3bea733a
PC
250void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
251{
7b19ada2
JS
252 input_dev->evbit[0] |= BIT_MASK(EV_MSC) | BIT_MASK(EV_REL);
253 input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL);
254 input_dev->relbit[0] |= BIT_MASK(REL_WHEEL);
545f4e99 255 input_dev->keybit[BIT_WORD(BTN_MOUSE)] |= BIT_MASK(BTN_LEFT) |
7b19ada2
JS
256 BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE) |
257 BIT_MASK(BTN_SIDE) | BIT_MASK(BTN_EXTRA);
258 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER) |
259 BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_TOOL_BRUSH) |
260 BIT_MASK(BTN_TOOL_PENCIL) | BIT_MASK(BTN_TOOL_AIRBRUSH) |
261 BIT_MASK(BTN_TOOL_LENS) | BIT_MASK(BTN_STYLUS2);
3bea733a
PC
262 input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom_wac->features->distance_max, 0, 0);
263 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
264 input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0);
265 input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0);
266 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
267 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
268}
269
270void input_dev_pl(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
271{
545f4e99 272 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_STYLUS2);
3bea733a
PC
273}
274
275void input_dev_pt(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
276{
7b19ada2 277 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER);
3bea733a
PC
278}
279
545f4e99
PC
280static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hid_desc,
281 struct wacom_wac *wacom_wac)
282{
283 struct usb_device *dev = interface_to_usbdev(intf);
284 struct wacom_features *features = wacom_wac->features;
285 char limit = 0, result = 0;
286 int i = 0, usage = WCM_UNDEFINED, finger = 0, pen = 0;
287 unsigned char *report;
288
289 report = kzalloc(hid_desc->wDescriptorLength, GFP_KERNEL);
290 if (!report)
291 return -ENOMEM;
292
293 /* retrive report descriptors */
294 do {
295 result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
296 USB_REQ_GET_DESCRIPTOR,
297 USB_RECIP_INTERFACE | USB_DIR_IN,
298 HID_DEVICET_REPORT << 8,
299 intf->altsetting[0].desc.bInterfaceNumber, /* interface */
300 report,
301 hid_desc->wDescriptorLength,
302 5000); /* 5 secs */
303 } while (result < 0 && limit++ < 5);
304
384318ec 305 /* No need to parse the Descriptor. It isn't an error though */
545f4e99
PC
306 if (result < 0)
307 goto out;
308
309 for (i = 0; i < hid_desc->wDescriptorLength; i++) {
310
311 switch (report[i]) {
312 case HID_USAGE_PAGE:
313 switch (report[i + 1]) {
314 case HID_USAGE_PAGE_DIGITIZER:
315 usage = WCM_DIGITIZER;
316 i++;
317 break;
318
319 case HID_USAGE_PAGE_DESKTOP:
320 usage = WCM_DESKTOP;
321 i++;
322 break;
323 }
324 break;
325
326 case HID_USAGE:
327 switch (report[i + 1]) {
328 case HID_USAGE_X:
329 if (usage == WCM_DESKTOP) {
330 if (finger) {
331 features->touch_x_max =
332 features->touch_y_max =
333 wacom_le16_to_cpu(&report[i + 3]);
334 features->x_max =
335 wacom_le16_to_cpu(&report[i + 6]);
336 i += 7;
337 } else if (pen) {
338 features->x_max =
339 wacom_le16_to_cpu(&report[i + 3]);
340 i += 4;
341 }
342 } else if (usage == WCM_DIGITIZER) {
343 /* max pressure isn't reported
344 features->pressure_max = (unsigned short)
345 (report[i+4] << 8 | report[i + 3]);
346 */
347 features->pressure_max = 255;
348 i += 4;
349 }
350 break;
351
352 case HID_USAGE_Y:
353 if (usage == WCM_DESKTOP)
354 features->y_max =
355 wacom_le16_to_cpu(&report[i + 3]);
356 i += 4;
357 break;
358
359 case HID_USAGE_FINGER:
360 finger = 1;
361 i++;
362 break;
363
364 case HID_USAGE_STYLUS:
365 pen = 1;
366 i++;
367 break;
368
369 case HID_USAGE_UNDEFINED:
370 if (usage == WCM_DESKTOP && finger) /* capacity */
371 features->pressure_max =
372 wacom_le16_to_cpu(&report[i + 3]);
373 i += 4;
374 break;
375 }
376 break;
377
378 case HID_COLLECTION:
379 /* reset UsagePage ans Finger */
380 finger = usage = 0;
381 break;
382 }
383 }
384
545f4e99 385 out:
384318ec 386 result = 0;
545f4e99
PC
387 kfree(report);
388 return result;
389}
390
3bea733a
PC
391static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id)
392{
393 struct usb_device *dev = interface_to_usbdev(intf);
545f4e99 394 struct usb_host_interface *interface = intf->cur_altsetting;
3bea733a
PC
395 struct usb_endpoint_descriptor *endpoint;
396 struct wacom *wacom;
397 struct wacom_wac *wacom_wac;
545f4e99 398 struct wacom_features *features;
3bea733a 399 struct input_dev *input_dev;
5014186d 400 int error = -ENOMEM;
3bea733a 401 char rep_data[2], limit = 0;
545f4e99 402 struct hid_descriptor *hid_desc;
3bea733a
PC
403
404 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL);
405 wacom_wac = kzalloc(sizeof(struct wacom_wac), GFP_KERNEL);
406 input_dev = input_allocate_device();
407 if (!wacom || !input_dev || !wacom_wac)
408 goto fail1;
409
410 wacom_wac->data = usb_buffer_alloc(dev, 10, GFP_KERNEL, &wacom->data_dma);
411 if (!wacom_wac->data)
412 goto fail1;
413
414 wacom->irq = usb_alloc_urb(0, GFP_KERNEL);
415 if (!wacom->irq)
416 goto fail2;
417
418 wacom->usbdev = dev;
419 wacom->dev = input_dev;
e7224094
ON
420 wacom->intf = intf;
421 mutex_init(&wacom->lock);
3bea733a
PC
422 usb_make_path(dev, wacom->phys, sizeof(wacom->phys));
423 strlcat(wacom->phys, "/input0", sizeof(wacom->phys));
424
545f4e99
PC
425 wacom_wac->features = features = get_wacom_feature(id);
426 BUG_ON(features->pktlen > 10);
3bea733a
PC
427
428 input_dev->name = wacom_wac->features->name;
429 wacom->wacom_wac = wacom_wac;
430 usb_to_input_id(dev, &input_dev->id);
431
c0f82d57 432 input_dev->dev.parent = &intf->dev;
7791bdae
DT
433
434 input_set_drvdata(input_dev, wacom);
435
3bea733a
PC
436 input_dev->open = wacom_open;
437 input_dev->close = wacom_close;
438
545f4e99
PC
439 endpoint = &intf->cur_altsetting->endpoint[0].desc;
440
384318ec
PC
441 /* Initialize touch_x_max and touch_y_max in case it is not defined */
442 if (wacom_wac->features->type == TABLETPC) {
443 features->touch_x_max = 1023;
444 features->touch_y_max = 1023;
445 } else {
446 features->touch_x_max = 0;
447 features->touch_y_max = 0;
448 }
449
545f4e99
PC
450 /* TabletPC need to retrieve the physical and logical maximum from report descriptor */
451 if (wacom_wac->features->type == TABLETPC) {
452 if (usb_get_extra_descriptor(interface, HID_DEVICET_HID, &hid_desc)) {
453 if (usb_get_extra_descriptor(&interface->endpoint[0],
454 HID_DEVICET_REPORT, &hid_desc)) {
455 printk("wacom: can not retrive extra class descriptor\n");
456 goto fail2;
457 }
458 }
459 error = wacom_parse_hid(intf, hid_desc, wacom_wac);
460 if (error)
461 goto fail2;
462 }
463
7b19ada2
JS
464 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
465 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_PEN) |
466 BIT_MASK(BTN_TOUCH) | BIT_MASK(BTN_STYLUS);
545f4e99
PC
467 input_set_abs_params(input_dev, ABS_X, 0, features->x_max, 4, 0);
468 input_set_abs_params(input_dev, ABS_Y, 0, features->y_max, 4, 0);
469 input_set_abs_params(input_dev, ABS_PRESSURE, 0, features->pressure_max, 0, 0);
470 if (features->type == TABLETPC) {
471 input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_DOUBLETAP);
472 input_set_abs_params(input_dev, ABS_RX, 0, features->touch_x_max, 4, 0);
473 input_set_abs_params(input_dev, ABS_RY, 0, features->touch_y_max, 4, 0);
474 }
7b19ada2 475 input_dev->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC);
3bea733a
PC
476
477 wacom_init_input_dev(input_dev, wacom_wac);
478
3bea733a
PC
479 usb_fill_int_urb(wacom->irq, dev,
480 usb_rcvintpipe(dev, endpoint->bEndpointAddress),
481 wacom_wac->data, wacom_wac->features->pktlen,
8d32e3ae 482 wacom_sys_irq, wacom, endpoint->bInterval);
3bea733a
PC
483 wacom->irq->transfer_dma = wacom->data_dma;
484 wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
485
5014186d
DT
486 error = input_register_device(wacom->dev);
487 if (error)
488 goto fail3;
3bea733a 489
545f4e99
PC
490 /*
491 * Ask the tablet to report tablet data if it is not a Tablet PC.
492 * Repeat until it succeeds
493 */
494 if (wacom_wac->features->type != TABLETPC) {
495 do {
496 rep_data[0] = 2;
497 rep_data[1] = 2;
498 error = usb_set_report(intf, WAC_HID_FEATURE_REPORT,
499 2, rep_data, 2);
500 if (error >= 0)
501 error = usb_get_report(intf,
502 WAC_HID_FEATURE_REPORT, 2,
503 rep_data, 2);
504 } while ((error < 0 || rep_data[1] != 2) && limit++ < 5);
505 }
3bea733a
PC
506
507 usb_set_intfdata(intf, wacom);
508 return 0;
509
5014186d
DT
510 fail3: usb_free_urb(wacom->irq);
511 fail2: usb_buffer_free(dev, 10, wacom_wac->data, wacom->data_dma);
512 fail1: input_free_device(input_dev);
3bea733a
PC
513 kfree(wacom);
514 kfree(wacom_wac);
5014186d 515 return error;
3bea733a
PC
516}
517
518static void wacom_disconnect(struct usb_interface *intf)
519{
e7224094 520 struct wacom *wacom = usb_get_intfdata(intf);
3bea733a
PC
521
522 usb_set_intfdata(intf, NULL);
e7224094
ON
523
524 usb_kill_urb(wacom->irq);
525 input_unregister_device(wacom->dev);
526 usb_free_urb(wacom->irq);
545f4e99
PC
527 usb_buffer_free(interface_to_usbdev(intf), 10,
528 wacom->wacom_wac->data, wacom->data_dma);
e7224094
ON
529 kfree(wacom->wacom_wac);
530 kfree(wacom);
531}
532
533static int wacom_suspend(struct usb_interface *intf, pm_message_t message)
534{
535 struct wacom *wacom = usb_get_intfdata(intf);
536
537 mutex_lock(&wacom->lock);
538 usb_kill_urb(wacom->irq);
539 mutex_unlock(&wacom->lock);
540
541 return 0;
542}
543
544static int wacom_resume(struct usb_interface *intf)
545{
546 struct wacom *wacom = usb_get_intfdata(intf);
547 int rv;
548
549 mutex_lock(&wacom->lock);
550 if (wacom->open)
551 rv = usb_submit_urb(wacom->irq, GFP_NOIO);
552 else
553 rv = 0;
554 mutex_unlock(&wacom->lock);
555
556 return rv;
557}
558
559static int wacom_reset_resume(struct usb_interface *intf)
560{
561 return wacom_resume(intf);
3bea733a
PC
562}
563
564static struct usb_driver wacom_driver = {
565 .name = "wacom",
566 .probe = wacom_probe,
567 .disconnect = wacom_disconnect,
e7224094
ON
568 .suspend = wacom_suspend,
569 .resume = wacom_resume,
570 .reset_resume = wacom_reset_resume,
571 .supports_autosuspend = 1,
3bea733a
PC
572};
573
574static int __init wacom_init(void)
575{
576 int result;
577 wacom_driver.id_table = get_device_table();
578 result = usb_register(&wacom_driver);
579 if (result == 0)
899ef6e7
GKH
580 printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
581 DRIVER_DESC "\n");
3bea733a
PC
582 return result;
583}
584
585static void __exit wacom_exit(void)
586{
587 usb_deregister(&wacom_driver);
588}
589
590module_init(wacom_init);
591module_exit(wacom_exit);