2 * drivers/input/tablet/wacom_sys.c
4 * USB Wacom tablet support - system specific code
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.
14 #include "wacom_wac.h"
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 0xa1
32 #define HID_COLLECTION_LOGICAL 0x02
33 #define HID_COLLECTION_END 0xc0
41 struct hid_descriptor {
42 struct usb_descriptor_header header;
47 __le16 wDescriptorLength;
48 } __attribute__ ((packed));
50 /* defines to get/set USB message */
51 #define USB_REQ_GET_REPORT 0x01
52 #define USB_REQ_SET_REPORT 0x09
54 #define WAC_HID_FEATURE_REPORT 0x03
55 #define WAC_MSG_RETRIES 5
57 #define WAC_CMD_LED_CONTROL 0x20
58 #define WAC_CMD_ICON_START 0x21
59 #define WAC_CMD_ICON_XFER 0x23
60 #define WAC_CMD_RETRIES 10
62 static int wacom_get_report(struct usb_interface *intf, u8 type, u8 id,
63 void *buf, size_t size, unsigned int retries)
65 struct usb_device *dev = interface_to_usbdev(intf);
69 retval = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
71 USB_DIR_IN | USB_TYPE_CLASS |
74 intf->altsetting[0].desc.bInterfaceNumber,
76 } while ((retval == -ETIMEDOUT || retval == -EPIPE) && --retries);
81 static int wacom_set_report(struct usb_interface *intf, u8 type, u8 id,
82 void *buf, size_t size, unsigned int retries)
84 struct usb_device *dev = interface_to_usbdev(intf);
88 retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
90 USB_TYPE_CLASS | USB_RECIP_INTERFACE,
92 intf->altsetting[0].desc.bInterfaceNumber,
94 } while ((retval == -ETIMEDOUT || retval == -EPIPE) && --retries);
99 static void wacom_sys_irq(struct urb *urb)
101 struct wacom *wacom = urb->context;
104 switch (urb->status) {
111 /* this urb is terminated, clean up */
112 dbg("%s - urb shutting down with status: %d", __func__, urb->status);
115 dbg("%s - nonzero urb status received: %d", __func__, urb->status);
119 wacom_wac_irq(&wacom->wacom_wac, urb->actual_length);
122 usb_mark_last_busy(wacom->usbdev);
123 retval = usb_submit_urb(urb, GFP_ATOMIC);
125 err ("%s - usb_submit_urb failed with result %d",
129 static int wacom_open(struct input_dev *dev)
131 struct wacom *wacom = input_get_drvdata(dev);
134 if (usb_autopm_get_interface(wacom->intf) < 0)
137 mutex_lock(&wacom->lock);
139 if (usb_submit_urb(wacom->irq, GFP_KERNEL)) {
145 wacom->intf->needs_remote_wakeup = 1;
148 mutex_unlock(&wacom->lock);
149 usb_autopm_put_interface(wacom->intf);
153 static void wacom_close(struct input_dev *dev)
155 struct wacom *wacom = input_get_drvdata(dev);
158 autopm_error = usb_autopm_get_interface(wacom->intf);
160 mutex_lock(&wacom->lock);
161 usb_kill_urb(wacom->irq);
163 wacom->intf->needs_remote_wakeup = 0;
164 mutex_unlock(&wacom->lock);
167 usb_autopm_put_interface(wacom->intf);
170 static int wacom_parse_logical_collection(unsigned char *report,
171 struct wacom_features *features)
175 if (features->type == BAMBOO_PT) {
177 /* Logical collection is only used by 3rd gen Bamboo Touch */
178 features->pktlen = WACOM_PKGLEN_BBTOUCH3;
179 features->device_type = BTN_TOOL_FINGER;
182 * Stylus and Touch have same active area
183 * so compute physical size based on stylus
184 * data before its overwritten.
187 (features->x_max * features->x_resolution) / 100;
189 (features->y_max * features->y_resolution) / 100;
191 features->x_max = features->y_max =
192 get_unaligned_le16(&report[10]);
200 * Interface Descriptor of wacom devices can be incomplete and
201 * inconsistent so wacom_features table is used to store stylus
202 * device's packet lengths, various maximum values, and tablet
203 * resolution based on product ID's.
205 * For devices that contain 2 interfaces, wacom_features table is
206 * inaccurate for the touch interface. Since the Interface Descriptor
207 * for touch interfaces has pretty complete data, this function exists
208 * to query tablet for this missing information instead of hard coding in
209 * an additional table.
211 * A typical Interface Descriptor for a stylus will contain a
212 * boot mouse application collection that is not of interest and this
213 * function will ignore it.
215 * It also contains a digitizer application collection that also is not
216 * of interest since any information it contains would be duplicate
217 * of what is in wacom_features. Usually it defines a report of an array
218 * of bytes that could be used as max length of the stylus packet returned.
219 * If it happens to define a Digitizer-Stylus Physical Collection then
220 * the X and Y logical values contain valid data but it is ignored.
222 * A typical Interface Descriptor for a touch interface will contain a
223 * Digitizer-Finger Physical Collection which will define both logical
224 * X/Y maximum as well as the physical size of tablet. Since touch
225 * interfaces haven't supported pressure or distance, this is enough
226 * information to override invalid values in the wacom_features table.
228 * 3rd gen Bamboo Touch no longer define a Digitizer-Finger Pysical
229 * Collection. Instead they define a Logical Collection with a single
230 * Logical Maximum for both X and Y.
232 static int wacom_parse_hid(struct usb_interface *intf,
233 struct hid_descriptor *hid_desc,
234 struct wacom_features *features)
236 struct usb_device *dev = interface_to_usbdev(intf);
238 /* result has to be defined as int for some devices */
240 int i = 0, usage = WCM_UNDEFINED, finger = 0, pen = 0;
241 unsigned char *report;
243 report = kzalloc(hid_desc->wDescriptorLength, GFP_KERNEL);
247 /* retrive report descriptors */
249 result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
250 USB_REQ_GET_DESCRIPTOR,
251 USB_RECIP_INTERFACE | USB_DIR_IN,
252 HID_DEVICET_REPORT << 8,
253 intf->altsetting[0].desc.bInterfaceNumber, /* interface */
255 hid_desc->wDescriptorLength,
257 } while (result < 0 && limit++ < WAC_MSG_RETRIES);
259 /* No need to parse the Descriptor. It isn't an error though */
263 for (i = 0; i < hid_desc->wDescriptorLength; i++) {
267 switch (report[i + 1]) {
268 case HID_USAGE_PAGE_DIGITIZER:
269 usage = WCM_DIGITIZER;
273 case HID_USAGE_PAGE_DESKTOP:
281 switch (report[i + 1]) {
283 if (usage == WCM_DESKTOP) {
285 features->device_type = BTN_TOOL_FINGER;
286 if (features->type == TABLETPC2FG) {
287 /* need to reset back */
288 features->pktlen = WACOM_PKGLEN_TPC2FG;
290 if (features->type == BAMBOO_PT) {
291 /* need to reset back */
292 features->pktlen = WACOM_PKGLEN_BBTOUCH;
294 get_unaligned_le16(&report[i + 5]);
296 get_unaligned_le16(&report[i + 8]);
300 get_unaligned_le16(&report[i + 3]);
302 get_unaligned_le16(&report[i + 6]);
303 features->unit = report[i + 9];
304 features->unitExpo = report[i + 11];
308 /* penabled only accepts exact bytes of data */
309 if (features->type == TABLETPC2FG)
310 features->pktlen = WACOM_PKGLEN_GRAPHIRE;
311 features->device_type = BTN_TOOL_PEN;
313 get_unaligned_le16(&report[i + 3]);
320 if (usage == WCM_DESKTOP) {
322 features->device_type = BTN_TOOL_FINGER;
323 if (features->type == TABLETPC2FG) {
324 /* need to reset back */
325 features->pktlen = WACOM_PKGLEN_TPC2FG;
327 get_unaligned_le16(&report[i + 3]);
329 get_unaligned_le16(&report[i + 6]);
331 } else if (features->type == BAMBOO_PT) {
332 /* need to reset back */
333 features->pktlen = WACOM_PKGLEN_BBTOUCH;
335 get_unaligned_le16(&report[i + 3]);
337 get_unaligned_le16(&report[i + 6]);
343 get_unaligned_le16(&report[i + 3]);
347 /* penabled only accepts exact bytes of data */
348 if (features->type == TABLETPC2FG)
349 features->pktlen = WACOM_PKGLEN_GRAPHIRE;
350 features->device_type = BTN_TOOL_PEN;
352 get_unaligned_le16(&report[i + 3]);
358 case HID_USAGE_FINGER:
364 * Requiring Stylus Usage will ignore boot mouse
365 * X/Y values and some cases of invalid Digitizer X/Y
366 * values commonly reported.
368 case HID_USAGE_STYLUS:
375 case HID_COLLECTION_END:
376 /* reset UsagePage and Finger */
383 case HID_COLLECTION_LOGICAL:
384 i += wacom_parse_logical_collection(&report[i],
398 static int wacom_query_tablet_data(struct usb_interface *intf, struct wacom_features *features)
400 unsigned char *rep_data;
401 int limit = 0, report_id = 2;
404 rep_data = kmalloc(4, GFP_KERNEL);
408 /* ask to report tablet data if it is MT Tablet PC or
410 if (features->type == TABLETPC2FG) {
417 error = wacom_set_report(intf, WAC_HID_FEATURE_REPORT,
418 report_id, rep_data, 4, 1);
420 error = wacom_get_report(intf,
421 WAC_HID_FEATURE_REPORT,
422 report_id, rep_data, 4, 1);
423 } while ((error < 0 || rep_data[1] != 4) && limit++ < WAC_MSG_RETRIES);
424 } else if (features->type != TABLETPC &&
425 features->device_type == BTN_TOOL_PEN) {
429 error = wacom_set_report(intf, WAC_HID_FEATURE_REPORT,
430 report_id, rep_data, 2, 1);
432 error = wacom_get_report(intf,
433 WAC_HID_FEATURE_REPORT,
434 report_id, rep_data, 2, 1);
435 } while ((error < 0 || rep_data[1] != 2) && limit++ < WAC_MSG_RETRIES);
440 return error < 0 ? error : 0;
443 static int wacom_retrieve_hid_descriptor(struct usb_interface *intf,
444 struct wacom_features *features)
447 struct usb_host_interface *interface = intf->cur_altsetting;
448 struct hid_descriptor *hid_desc;
450 /* default features */
451 features->device_type = BTN_TOOL_PEN;
452 features->x_fuzz = 4;
453 features->y_fuzz = 4;
454 features->pressure_fuzz = 0;
455 features->distance_fuzz = 0;
457 /* only Tablet PCs and Bamboo P&T need to retrieve the info */
458 if ((features->type != TABLETPC) && (features->type != TABLETPC2FG) &&
459 (features->type != BAMBOO_PT))
462 if (usb_get_extra_descriptor(interface, HID_DEVICET_HID, &hid_desc)) {
463 if (usb_get_extra_descriptor(&interface->endpoint[0],
464 HID_DEVICET_REPORT, &hid_desc)) {
465 printk("wacom: can not retrieve extra class descriptor\n");
470 error = wacom_parse_hid(intf, hid_desc, features);
478 struct wacom_usbdev_data {
479 struct list_head list;
481 struct usb_device *dev;
482 struct wacom_shared shared;
485 static LIST_HEAD(wacom_udev_list);
486 static DEFINE_MUTEX(wacom_udev_list_lock);
488 static struct wacom_usbdev_data *wacom_get_usbdev_data(struct usb_device *dev)
490 struct wacom_usbdev_data *data;
492 list_for_each_entry(data, &wacom_udev_list, list) {
493 if (data->dev == dev) {
494 kref_get(&data->kref);
502 static int wacom_add_shared_data(struct wacom_wac *wacom,
503 struct usb_device *dev)
505 struct wacom_usbdev_data *data;
508 mutex_lock(&wacom_udev_list_lock);
510 data = wacom_get_usbdev_data(dev);
512 data = kzalloc(sizeof(struct wacom_usbdev_data), GFP_KERNEL);
518 kref_init(&data->kref);
520 list_add_tail(&data->list, &wacom_udev_list);
523 wacom->shared = &data->shared;
526 mutex_unlock(&wacom_udev_list_lock);
530 static void wacom_release_shared_data(struct kref *kref)
532 struct wacom_usbdev_data *data =
533 container_of(kref, struct wacom_usbdev_data, kref);
535 mutex_lock(&wacom_udev_list_lock);
536 list_del(&data->list);
537 mutex_unlock(&wacom_udev_list_lock);
542 static void wacom_remove_shared_data(struct wacom_wac *wacom)
544 struct wacom_usbdev_data *data;
547 data = container_of(wacom->shared, struct wacom_usbdev_data, shared);
548 kref_put(&data->kref, wacom_release_shared_data);
549 wacom->shared = NULL;
553 static int wacom_led_control(struct wacom *wacom)
558 buf = kzalloc(9, GFP_KERNEL);
562 if (wacom->wacom_wac.features.type == WACOM_21UX2 ||
563 wacom->wacom_wac.features.type == WACOM_24HD)
564 led = (wacom->led.select[1] << 4) | 0x40;
566 led |= wacom->led.select[0] | 0x4;
568 buf[0] = WAC_CMD_LED_CONTROL;
570 buf[2] = wacom->led.llv;
571 buf[3] = wacom->led.hlv;
572 buf[4] = wacom->led.img_lum;
574 retval = wacom_set_report(wacom->intf, 0x03, WAC_CMD_LED_CONTROL,
575 buf, 9, WAC_CMD_RETRIES);
581 static int wacom_led_putimage(struct wacom *wacom, int button_id, const void *img)
586 buf = kzalloc(259, GFP_KERNEL);
590 /* Send 'start' command */
591 buf[0] = WAC_CMD_ICON_START;
593 retval = wacom_set_report(wacom->intf, 0x03, WAC_CMD_ICON_START,
594 buf, 2, WAC_CMD_RETRIES);
598 buf[0] = WAC_CMD_ICON_XFER;
599 buf[1] = button_id & 0x07;
600 for (i = 0; i < 4; i++) {
602 memcpy(buf + 3, img + i * 256, 256);
604 retval = wacom_set_report(wacom->intf, 0x03, WAC_CMD_ICON_XFER,
605 buf, 259, WAC_CMD_RETRIES);
611 buf[0] = WAC_CMD_ICON_START;
613 wacom_set_report(wacom->intf, 0x03, WAC_CMD_ICON_START,
614 buf, 2, WAC_CMD_RETRIES);
621 static ssize_t wacom_led_select_store(struct device *dev, int set_id,
622 const char *buf, size_t count)
624 struct wacom *wacom = dev_get_drvdata(dev);
628 err = kstrtouint(buf, 10, &id);
632 mutex_lock(&wacom->lock);
634 wacom->led.select[set_id] = id & 0x3;
635 err = wacom_led_control(wacom);
637 mutex_unlock(&wacom->lock);
639 return err < 0 ? err : count;
642 #define DEVICE_LED_SELECT_ATTR(SET_ID) \
643 static ssize_t wacom_led##SET_ID##_select_store(struct device *dev, \
644 struct device_attribute *attr, const char *buf, size_t count) \
646 return wacom_led_select_store(dev, SET_ID, buf, count); \
648 static ssize_t wacom_led##SET_ID##_select_show(struct device *dev, \
649 struct device_attribute *attr, char *buf) \
651 struct wacom *wacom = dev_get_drvdata(dev); \
652 return snprintf(buf, 2, "%d\n", wacom->led.select[SET_ID]); \
654 static DEVICE_ATTR(status_led##SET_ID##_select, S_IWUSR | S_IRUSR, \
655 wacom_led##SET_ID##_select_show, \
656 wacom_led##SET_ID##_select_store)
658 DEVICE_LED_SELECT_ATTR(0);
659 DEVICE_LED_SELECT_ATTR(1);
661 static ssize_t wacom_luminance_store(struct wacom *wacom, u8 *dest,
662 const char *buf, size_t count)
667 err = kstrtouint(buf, 10, &value);
671 mutex_lock(&wacom->lock);
673 *dest = value & 0x7f;
674 err = wacom_led_control(wacom);
676 mutex_unlock(&wacom->lock);
678 return err < 0 ? err : count;
681 #define DEVICE_LUMINANCE_ATTR(name, field) \
682 static ssize_t wacom_##name##_luminance_store(struct device *dev, \
683 struct device_attribute *attr, const char *buf, size_t count) \
685 struct wacom *wacom = dev_get_drvdata(dev); \
687 return wacom_luminance_store(wacom, &wacom->led.field, \
690 static DEVICE_ATTR(name##_luminance, S_IWUSR, \
691 NULL, wacom_##name##_luminance_store)
693 DEVICE_LUMINANCE_ATTR(status0, llv);
694 DEVICE_LUMINANCE_ATTR(status1, hlv);
695 DEVICE_LUMINANCE_ATTR(buttons, img_lum);
697 static ssize_t wacom_button_image_store(struct device *dev, int button_id,
698 const char *buf, size_t count)
700 struct wacom *wacom = dev_get_drvdata(dev);
706 mutex_lock(&wacom->lock);
708 err = wacom_led_putimage(wacom, button_id, buf);
710 mutex_unlock(&wacom->lock);
712 return err < 0 ? err : count;
715 #define DEVICE_BTNIMG_ATTR(BUTTON_ID) \
716 static ssize_t wacom_btnimg##BUTTON_ID##_store(struct device *dev, \
717 struct device_attribute *attr, const char *buf, size_t count) \
719 return wacom_button_image_store(dev, BUTTON_ID, buf, count); \
721 static DEVICE_ATTR(button##BUTTON_ID##_rawimg, S_IWUSR, \
722 NULL, wacom_btnimg##BUTTON_ID##_store)
724 DEVICE_BTNIMG_ATTR(0);
725 DEVICE_BTNIMG_ATTR(1);
726 DEVICE_BTNIMG_ATTR(2);
727 DEVICE_BTNIMG_ATTR(3);
728 DEVICE_BTNIMG_ATTR(4);
729 DEVICE_BTNIMG_ATTR(5);
730 DEVICE_BTNIMG_ATTR(6);
731 DEVICE_BTNIMG_ATTR(7);
733 static struct attribute *cintiq_led_attrs[] = {
734 &dev_attr_status_led0_select.attr,
735 &dev_attr_status_led1_select.attr,
739 static struct attribute_group cintiq_led_attr_group = {
741 .attrs = cintiq_led_attrs,
744 static struct attribute *intuos4_led_attrs[] = {
745 &dev_attr_status0_luminance.attr,
746 &dev_attr_status1_luminance.attr,
747 &dev_attr_status_led0_select.attr,
748 &dev_attr_buttons_luminance.attr,
749 &dev_attr_button0_rawimg.attr,
750 &dev_attr_button1_rawimg.attr,
751 &dev_attr_button2_rawimg.attr,
752 &dev_attr_button3_rawimg.attr,
753 &dev_attr_button4_rawimg.attr,
754 &dev_attr_button5_rawimg.attr,
755 &dev_attr_button6_rawimg.attr,
756 &dev_attr_button7_rawimg.attr,
760 static struct attribute_group intuos4_led_attr_group = {
762 .attrs = intuos4_led_attrs,
765 static int wacom_initialize_leds(struct wacom *wacom)
769 /* Initialize default values */
770 switch (wacom->wacom_wac.features.type) {
773 wacom->led.select[0] = 0;
774 wacom->led.select[1] = 0;
777 wacom->led.img_lum = 10;
778 error = sysfs_create_group(&wacom->intf->dev.kobj,
779 &intuos4_led_attr_group);
784 wacom->led.select[0] = 0;
785 wacom->led.select[1] = 0;
788 wacom->led.img_lum = 0;
790 error = sysfs_create_group(&wacom->intf->dev.kobj,
791 &cintiq_led_attr_group);
799 dev_err(&wacom->intf->dev,
800 "cannot create sysfs group err: %d\n", error);
803 wacom_led_control(wacom);
808 static void wacom_destroy_leds(struct wacom *wacom)
810 switch (wacom->wacom_wac.features.type) {
813 sysfs_remove_group(&wacom->intf->dev.kobj,
814 &intuos4_led_attr_group);
819 sysfs_remove_group(&wacom->intf->dev.kobj,
820 &cintiq_led_attr_group);
825 static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id)
827 struct usb_device *dev = interface_to_usbdev(intf);
828 struct usb_endpoint_descriptor *endpoint;
830 struct wacom_wac *wacom_wac;
831 struct wacom_features *features;
832 struct input_dev *input_dev;
835 if (!id->driver_info)
838 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL);
839 input_dev = input_allocate_device();
840 if (!wacom || !input_dev) {
845 wacom_wac = &wacom->wacom_wac;
846 wacom_wac->features = *((struct wacom_features *)id->driver_info);
847 features = &wacom_wac->features;
848 if (features->pktlen > WACOM_PKGLEN_MAX) {
853 wacom_wac->data = usb_alloc_coherent(dev, WACOM_PKGLEN_MAX,
854 GFP_KERNEL, &wacom->data_dma);
855 if (!wacom_wac->data) {
860 wacom->irq = usb_alloc_urb(0, GFP_KERNEL);
868 mutex_init(&wacom->lock);
869 usb_make_path(dev, wacom->phys, sizeof(wacom->phys));
870 strlcat(wacom->phys, "/input0", sizeof(wacom->phys));
872 wacom_wac->input = input_dev;
874 endpoint = &intf->cur_altsetting->endpoint[0].desc;
876 /* Retrieve the physical and logical size for OEM devices */
877 error = wacom_retrieve_hid_descriptor(intf, features);
881 wacom_setup_device_quirks(features);
883 strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name));
885 if (features->quirks & WACOM_QUIRK_MULTI_INPUT) {
886 /* Append the device type to the name */
887 strlcat(wacom_wac->name,
888 features->device_type == BTN_TOOL_PEN ?
890 sizeof(wacom_wac->name));
892 error = wacom_add_shared_data(wacom_wac, dev);
897 input_dev->name = wacom_wac->name;
898 input_dev->dev.parent = &intf->dev;
899 input_dev->open = wacom_open;
900 input_dev->close = wacom_close;
901 usb_to_input_id(dev, &input_dev->id);
902 input_set_drvdata(input_dev, wacom);
904 wacom_setup_input_capabilities(input_dev, wacom_wac);
906 usb_fill_int_urb(wacom->irq, dev,
907 usb_rcvintpipe(dev, endpoint->bEndpointAddress),
908 wacom_wac->data, features->pktlen,
909 wacom_sys_irq, wacom, endpoint->bInterval);
910 wacom->irq->transfer_dma = wacom->data_dma;
911 wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
913 error = wacom_initialize_leds(wacom);
917 error = input_register_device(input_dev);
921 /* Note that if query fails it is not a hard failure */
922 wacom_query_tablet_data(intf, features);
924 usb_set_intfdata(intf, wacom);
927 fail5: wacom_destroy_leds(wacom);
928 fail4: wacom_remove_shared_data(wacom_wac);
929 fail3: usb_free_urb(wacom->irq);
930 fail2: usb_free_coherent(dev, WACOM_PKGLEN_MAX, wacom_wac->data, wacom->data_dma);
931 fail1: input_free_device(input_dev);
936 static void wacom_disconnect(struct usb_interface *intf)
938 struct wacom *wacom = usb_get_intfdata(intf);
940 usb_set_intfdata(intf, NULL);
942 usb_kill_urb(wacom->irq);
943 input_unregister_device(wacom->wacom_wac.input);
944 wacom_destroy_leds(wacom);
945 usb_free_urb(wacom->irq);
946 usb_free_coherent(interface_to_usbdev(intf), WACOM_PKGLEN_MAX,
947 wacom->wacom_wac.data, wacom->data_dma);
948 wacom_remove_shared_data(&wacom->wacom_wac);
952 static int wacom_suspend(struct usb_interface *intf, pm_message_t message)
954 struct wacom *wacom = usb_get_intfdata(intf);
956 mutex_lock(&wacom->lock);
957 usb_kill_urb(wacom->irq);
958 mutex_unlock(&wacom->lock);
963 static int wacom_resume(struct usb_interface *intf)
965 struct wacom *wacom = usb_get_intfdata(intf);
966 struct wacom_features *features = &wacom->wacom_wac.features;
969 mutex_lock(&wacom->lock);
971 /* switch to wacom mode first */
972 wacom_query_tablet_data(intf, features);
973 wacom_led_control(wacom);
975 if (wacom->open && usb_submit_urb(wacom->irq, GFP_NOIO) < 0)
978 mutex_unlock(&wacom->lock);
983 static int wacom_reset_resume(struct usb_interface *intf)
985 return wacom_resume(intf);
988 static struct usb_driver wacom_driver = {
990 .id_table = wacom_ids,
991 .probe = wacom_probe,
992 .disconnect = wacom_disconnect,
993 .suspend = wacom_suspend,
994 .resume = wacom_resume,
995 .reset_resume = wacom_reset_resume,
996 .supports_autosuspend = 1,
999 module_usb_driver(wacom_driver);