Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1 | /* |
Dmitry Torokhov | 4104d13 | 2007-05-07 16:16:29 -0400 | [diff] [blame] | 2 | * drivers/input/tablet/wacom_sys.c |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 3 | * |
Ping Cheng | 232f569 | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 4 | * USB Wacom tablet support - system specific code |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 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 | |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 14 | #include "wacom_wac.h" |
Dmitry Torokhov | 51269fe | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 15 | #include "wacom.h" |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 16 | |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 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 | |
| 33 | enum { |
| 34 | WCM_UNDEFINED = 0, |
| 35 | WCM_DESKTOP, |
| 36 | WCM_DIGITIZER, |
| 37 | }; |
| 38 | |
| 39 | struct 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 */ |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 49 | #define USB_REQ_GET_REPORT 0x01 |
| 50 | #define USB_REQ_SET_REPORT 0x09 |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 51 | #define WAC_HID_FEATURE_REPORT 0x03 |
Ping Cheng | a417ea4 | 2011-08-16 00:17:56 -0700 | [diff] [blame] | 52 | #define WAC_MSG_RETRIES 5 |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 53 | |
| 54 | static int usb_get_report(struct usb_interface *intf, unsigned char type, |
| 55 | unsigned char id, void *buf, int size) |
| 56 | { |
| 57 | return usb_control_msg(interface_to_usbdev(intf), |
| 58 | usb_rcvctrlpipe(interface_to_usbdev(intf), 0), |
| 59 | USB_REQ_GET_REPORT, USB_TYPE_CLASS | USB_RECIP_INTERFACE, |
| 60 | (type << 8) + id, intf->altsetting[0].desc.bInterfaceNumber, |
| 61 | buf, size, 100); |
| 62 | } |
| 63 | |
| 64 | static int usb_set_report(struct usb_interface *intf, unsigned char type, |
| 65 | unsigned char id, void *buf, int size) |
| 66 | { |
| 67 | return usb_control_msg(interface_to_usbdev(intf), |
| 68 | usb_sndctrlpipe(interface_to_usbdev(intf), 0), |
| 69 | USB_REQ_SET_REPORT, USB_TYPE_CLASS | USB_RECIP_INTERFACE, |
| 70 | (type << 8) + id, intf->altsetting[0].desc.bInterfaceNumber, |
| 71 | buf, size, 1000); |
| 72 | } |
| 73 | |
Adrian Bunk | 54c9b22 | 2006-11-20 03:23:58 +0100 | [diff] [blame] | 74 | static void wacom_sys_irq(struct urb *urb) |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 75 | { |
| 76 | struct wacom *wacom = urb->context; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 77 | int retval; |
| 78 | |
| 79 | switch (urb->status) { |
| 80 | case 0: |
| 81 | /* success */ |
| 82 | break; |
| 83 | case -ECONNRESET: |
| 84 | case -ENOENT: |
| 85 | case -ESHUTDOWN: |
| 86 | /* this urb is terminated, clean up */ |
Harvey Harrison | ea3e6c5 | 2008-05-05 11:36:18 -0400 | [diff] [blame] | 87 | dbg("%s - urb shutting down with status: %d", __func__, urb->status); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 88 | return; |
| 89 | default: |
Harvey Harrison | ea3e6c5 | 2008-05-05 11:36:18 -0400 | [diff] [blame] | 90 | dbg("%s - nonzero urb status received: %d", __func__, urb->status); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 91 | goto exit; |
| 92 | } |
| 93 | |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 94 | wacom_wac_irq(&wacom->wacom_wac, urb->actual_length); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 95 | |
| 96 | exit: |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 97 | usb_mark_last_busy(wacom->usbdev); |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 98 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 99 | if (retval) |
| 100 | err ("%s - usb_submit_urb failed with result %d", |
Harvey Harrison | ea3e6c5 | 2008-05-05 11:36:18 -0400 | [diff] [blame] | 101 | __func__, retval); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 102 | } |
| 103 | |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 104 | static int wacom_open(struct input_dev *dev) |
| 105 | { |
Dmitry Torokhov | 7791bda | 2007-04-12 01:34:39 -0400 | [diff] [blame] | 106 | struct wacom *wacom = input_get_drvdata(dev); |
Dmitry Torokhov | f6cd378 | 2010-10-04 21:46:11 -0700 | [diff] [blame] | 107 | int retval = 0; |
| 108 | |
| 109 | if (usb_autopm_get_interface(wacom->intf) < 0) |
| 110 | return -EIO; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 111 | |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 112 | mutex_lock(&wacom->lock); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 113 | |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 114 | if (usb_submit_urb(wacom->irq, GFP_KERNEL)) { |
Dmitry Torokhov | f6cd378 | 2010-10-04 21:46:11 -0700 | [diff] [blame] | 115 | retval = -EIO; |
| 116 | goto out; |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 117 | } |
| 118 | |
Dmitry Torokhov | 51269fe | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 119 | wacom->open = true; |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 120 | wacom->intf->needs_remote_wakeup = 1; |
| 121 | |
Dmitry Torokhov | f6cd378 | 2010-10-04 21:46:11 -0700 | [diff] [blame] | 122 | out: |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 123 | mutex_unlock(&wacom->lock); |
Dmitry Torokhov | 62ecae0 | 2010-10-10 14:24:16 -0700 | [diff] [blame] | 124 | usb_autopm_put_interface(wacom->intf); |
Dmitry Torokhov | f6cd378 | 2010-10-04 21:46:11 -0700 | [diff] [blame] | 125 | return retval; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | static void wacom_close(struct input_dev *dev) |
| 129 | { |
Dmitry Torokhov | 7791bda | 2007-04-12 01:34:39 -0400 | [diff] [blame] | 130 | struct wacom *wacom = input_get_drvdata(dev); |
Dmitry Torokhov | 62ecae0 | 2010-10-10 14:24:16 -0700 | [diff] [blame] | 131 | int autopm_error; |
| 132 | |
| 133 | autopm_error = usb_autopm_get_interface(wacom->intf); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 134 | |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 135 | mutex_lock(&wacom->lock); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 136 | usb_kill_urb(wacom->irq); |
Dmitry Torokhov | 51269fe | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 137 | wacom->open = false; |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 138 | wacom->intf->needs_remote_wakeup = 0; |
| 139 | mutex_unlock(&wacom->lock); |
Dmitry Torokhov | f6cd378 | 2010-10-04 21:46:11 -0700 | [diff] [blame] | 140 | |
Dmitry Torokhov | 62ecae0 | 2010-10-10 14:24:16 -0700 | [diff] [blame] | 141 | if (!autopm_error) |
| 142 | usb_autopm_put_interface(wacom->intf); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 143 | } |
| 144 | |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 145 | static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hid_desc, |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 146 | struct wacom_features *features) |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 147 | { |
| 148 | struct usb_device *dev = interface_to_usbdev(intf); |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 149 | char limit = 0; |
| 150 | /* result has to be defined as int for some devices */ |
| 151 | int result = 0; |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 152 | int i = 0, usage = WCM_UNDEFINED, finger = 0, pen = 0; |
| 153 | unsigned char *report; |
| 154 | |
| 155 | report = kzalloc(hid_desc->wDescriptorLength, GFP_KERNEL); |
| 156 | if (!report) |
| 157 | return -ENOMEM; |
| 158 | |
| 159 | /* retrive report descriptors */ |
| 160 | do { |
| 161 | result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), |
| 162 | USB_REQ_GET_DESCRIPTOR, |
| 163 | USB_RECIP_INTERFACE | USB_DIR_IN, |
| 164 | HID_DEVICET_REPORT << 8, |
| 165 | intf->altsetting[0].desc.bInterfaceNumber, /* interface */ |
| 166 | report, |
| 167 | hid_desc->wDescriptorLength, |
| 168 | 5000); /* 5 secs */ |
Ping Cheng | a417ea4 | 2011-08-16 00:17:56 -0700 | [diff] [blame] | 169 | } while (result < 0 && limit++ < WAC_MSG_RETRIES); |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 170 | |
Ping Cheng | 384318e | 2009-04-28 07:49:54 -0700 | [diff] [blame] | 171 | /* No need to parse the Descriptor. It isn't an error though */ |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 172 | if (result < 0) |
| 173 | goto out; |
| 174 | |
| 175 | for (i = 0; i < hid_desc->wDescriptorLength; i++) { |
| 176 | |
| 177 | switch (report[i]) { |
| 178 | case HID_USAGE_PAGE: |
| 179 | switch (report[i + 1]) { |
| 180 | case HID_USAGE_PAGE_DIGITIZER: |
| 181 | usage = WCM_DIGITIZER; |
| 182 | i++; |
| 183 | break; |
| 184 | |
| 185 | case HID_USAGE_PAGE_DESKTOP: |
| 186 | usage = WCM_DESKTOP; |
| 187 | i++; |
| 188 | break; |
| 189 | } |
| 190 | break; |
| 191 | |
| 192 | case HID_USAGE: |
| 193 | switch (report[i + 1]) { |
| 194 | case HID_USAGE_X: |
| 195 | if (usage == WCM_DESKTOP) { |
| 196 | if (finger) { |
Ping Cheng | 84eb5aa | 2011-03-12 20:35:18 -0800 | [diff] [blame] | 197 | features->device_type = BTN_TOOL_FINGER; |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 198 | if (features->type == TABLETPC2FG) { |
| 199 | /* need to reset back */ |
| 200 | features->pktlen = WACOM_PKGLEN_TPC2FG; |
Ping Cheng | 84eb5aa | 2011-03-12 20:35:18 -0800 | [diff] [blame] | 201 | features->device_type = BTN_TOOL_DOUBLETAP; |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 202 | } |
Ping Cheng | 4a88081 | 2010-09-05 12:25:40 -0700 | [diff] [blame] | 203 | if (features->type == BAMBOO_PT) { |
| 204 | /* need to reset back */ |
| 205 | features->pktlen = WACOM_PKGLEN_BBTOUCH; |
Ping Cheng | 84eb5aa | 2011-03-12 20:35:18 -0800 | [diff] [blame] | 206 | features->device_type = BTN_TOOL_DOUBLETAP; |
Ping Cheng | 4a88081 | 2010-09-05 12:25:40 -0700 | [diff] [blame] | 207 | features->x_phy = |
| 208 | get_unaligned_le16(&report[i + 5]); |
| 209 | features->x_max = |
| 210 | get_unaligned_le16(&report[i + 8]); |
| 211 | i += 15; |
| 212 | } else { |
| 213 | features->x_max = |
| 214 | get_unaligned_le16(&report[i + 3]); |
| 215 | features->x_phy = |
| 216 | get_unaligned_le16(&report[i + 6]); |
| 217 | features->unit = report[i + 9]; |
| 218 | features->unitExpo = report[i + 11]; |
| 219 | i += 12; |
| 220 | } |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 221 | } else if (pen) { |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 222 | /* penabled only accepts exact bytes of data */ |
| 223 | if (features->type == TABLETPC2FG) |
Ping Cheng | 57e413d | 2010-03-01 23:50:24 -0800 | [diff] [blame] | 224 | features->pktlen = WACOM_PKGLEN_GRAPHIRE; |
Ping Cheng | 4a88081 | 2010-09-05 12:25:40 -0700 | [diff] [blame] | 225 | if (features->type == BAMBOO_PT) |
| 226 | features->pktlen = WACOM_PKGLEN_BBFUN; |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 227 | features->device_type = BTN_TOOL_PEN; |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 228 | features->x_max = |
Dmitry Torokhov | 252f776 | 2010-03-19 22:33:38 -0700 | [diff] [blame] | 229 | get_unaligned_le16(&report[i + 3]); |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 230 | i += 4; |
| 231 | } |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 232 | } |
| 233 | break; |
| 234 | |
| 235 | case HID_USAGE_Y: |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 236 | if (usage == WCM_DESKTOP) { |
| 237 | if (finger) { |
Ping Cheng | 84eb5aa | 2011-03-12 20:35:18 -0800 | [diff] [blame] | 238 | features->device_type = BTN_TOOL_FINGER; |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 239 | if (features->type == TABLETPC2FG) { |
| 240 | /* need to reset back */ |
| 241 | features->pktlen = WACOM_PKGLEN_TPC2FG; |
Ping Cheng | 84eb5aa | 2011-03-12 20:35:18 -0800 | [diff] [blame] | 242 | features->device_type = BTN_TOOL_DOUBLETAP; |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 243 | features->y_max = |
Dmitry Torokhov | 252f776 | 2010-03-19 22:33:38 -0700 | [diff] [blame] | 244 | get_unaligned_le16(&report[i + 3]); |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 245 | features->y_phy = |
Dmitry Torokhov | 252f776 | 2010-03-19 22:33:38 -0700 | [diff] [blame] | 246 | get_unaligned_le16(&report[i + 6]); |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 247 | i += 7; |
Ping Cheng | 4a88081 | 2010-09-05 12:25:40 -0700 | [diff] [blame] | 248 | } else if (features->type == BAMBOO_PT) { |
| 249 | /* need to reset back */ |
| 250 | features->pktlen = WACOM_PKGLEN_BBTOUCH; |
Ping Cheng | 84eb5aa | 2011-03-12 20:35:18 -0800 | [diff] [blame] | 251 | features->device_type = BTN_TOOL_DOUBLETAP; |
Ping Cheng | 4a88081 | 2010-09-05 12:25:40 -0700 | [diff] [blame] | 252 | features->y_phy = |
| 253 | get_unaligned_le16(&report[i + 3]); |
| 254 | features->y_max = |
| 255 | get_unaligned_le16(&report[i + 6]); |
| 256 | i += 12; |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 257 | } else { |
| 258 | features->y_max = |
| 259 | features->x_max; |
| 260 | features->y_phy = |
Dmitry Torokhov | 252f776 | 2010-03-19 22:33:38 -0700 | [diff] [blame] | 261 | get_unaligned_le16(&report[i + 3]); |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 262 | i += 4; |
| 263 | } |
| 264 | } else if (pen) { |
| 265 | /* penabled only accepts exact bytes of data */ |
| 266 | if (features->type == TABLETPC2FG) |
Ping Cheng | 57e413d | 2010-03-01 23:50:24 -0800 | [diff] [blame] | 267 | features->pktlen = WACOM_PKGLEN_GRAPHIRE; |
Ping Cheng | 4a88081 | 2010-09-05 12:25:40 -0700 | [diff] [blame] | 268 | if (features->type == BAMBOO_PT) |
| 269 | features->pktlen = WACOM_PKGLEN_BBFUN; |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 270 | features->device_type = BTN_TOOL_PEN; |
| 271 | features->y_max = |
Dmitry Torokhov | 252f776 | 2010-03-19 22:33:38 -0700 | [diff] [blame] | 272 | get_unaligned_le16(&report[i + 3]); |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 273 | i += 4; |
| 274 | } |
| 275 | } |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 276 | break; |
| 277 | |
| 278 | case HID_USAGE_FINGER: |
| 279 | finger = 1; |
| 280 | i++; |
| 281 | break; |
| 282 | |
| 283 | case HID_USAGE_STYLUS: |
| 284 | pen = 1; |
| 285 | i++; |
| 286 | break; |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 287 | } |
| 288 | break; |
| 289 | |
| 290 | case HID_COLLECTION: |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 291 | /* reset UsagePage and Finger */ |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 292 | finger = usage = 0; |
| 293 | break; |
| 294 | } |
| 295 | } |
| 296 | |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 297 | out: |
Ping Cheng | 384318e | 2009-04-28 07:49:54 -0700 | [diff] [blame] | 298 | result = 0; |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 299 | kfree(report); |
| 300 | return result; |
| 301 | } |
| 302 | |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 303 | static int wacom_query_tablet_data(struct usb_interface *intf, struct wacom_features *features) |
Dmitry Torokhov | 3b7307c | 2009-08-20 21:41:04 -0700 | [diff] [blame] | 304 | { |
| 305 | unsigned char *rep_data; |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 306 | int limit = 0, report_id = 2; |
| 307 | int error = -ENOMEM; |
Dmitry Torokhov | 3b7307c | 2009-08-20 21:41:04 -0700 | [diff] [blame] | 308 | |
Ping Cheng | 3b48c91 | 2011-08-16 00:17:57 -0700 | [diff] [blame] | 309 | rep_data = kmalloc(4, GFP_KERNEL); |
Dmitry Torokhov | 3b7307c | 2009-08-20 21:41:04 -0700 | [diff] [blame] | 310 | if (!rep_data) |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 311 | return error; |
Dmitry Torokhov | 3b7307c | 2009-08-20 21:41:04 -0700 | [diff] [blame] | 312 | |
Ping Cheng | 3b48c91 | 2011-08-16 00:17:57 -0700 | [diff] [blame] | 313 | /* ask to report tablet data if it is MT Tablet PC or |
Chris Bagwell | 3dc9f40 | 2010-09-12 00:08:40 -0700 | [diff] [blame] | 314 | * not a Tablet PC */ |
| 315 | if (features->type == TABLETPC2FG) { |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 316 | do { |
| 317 | rep_data[0] = 3; |
| 318 | rep_data[1] = 4; |
Ping Cheng | 3b48c91 | 2011-08-16 00:17:57 -0700 | [diff] [blame] | 319 | rep_data[2] = 0; |
| 320 | rep_data[3] = 0; |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 321 | report_id = 3; |
| 322 | error = usb_set_report(intf, WAC_HID_FEATURE_REPORT, |
Ping Cheng | 3b48c91 | 2011-08-16 00:17:57 -0700 | [diff] [blame] | 323 | report_id, rep_data, 4); |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 324 | if (error >= 0) |
| 325 | error = usb_get_report(intf, |
| 326 | WAC_HID_FEATURE_REPORT, report_id, |
Ping Cheng | 3b48c91 | 2011-08-16 00:17:57 -0700 | [diff] [blame] | 327 | rep_data, 4); |
Ping Cheng | a417ea4 | 2011-08-16 00:17:56 -0700 | [diff] [blame] | 328 | } while ((error < 0 || rep_data[1] != 4) && limit++ < WAC_MSG_RETRIES); |
Chris Bagwell | 3dc9f40 | 2010-09-12 00:08:40 -0700 | [diff] [blame] | 329 | } else if (features->type != TABLETPC) { |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 330 | do { |
| 331 | rep_data[0] = 2; |
| 332 | rep_data[1] = 2; |
| 333 | error = usb_set_report(intf, WAC_HID_FEATURE_REPORT, |
| 334 | report_id, rep_data, 2); |
| 335 | if (error >= 0) |
| 336 | error = usb_get_report(intf, |
| 337 | WAC_HID_FEATURE_REPORT, report_id, |
| 338 | rep_data, 2); |
Ping Cheng | a417ea4 | 2011-08-16 00:17:56 -0700 | [diff] [blame] | 339 | } while ((error < 0 || rep_data[1] != 2) && limit++ < WAC_MSG_RETRIES); |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 340 | } |
Dmitry Torokhov | 3b7307c | 2009-08-20 21:41:04 -0700 | [diff] [blame] | 341 | |
| 342 | kfree(rep_data); |
| 343 | |
| 344 | return error < 0 ? error : 0; |
| 345 | } |
| 346 | |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 347 | static int wacom_retrieve_hid_descriptor(struct usb_interface *intf, |
| 348 | struct wacom_features *features) |
| 349 | { |
| 350 | int error = 0; |
| 351 | struct usb_host_interface *interface = intf->cur_altsetting; |
| 352 | struct hid_descriptor *hid_desc; |
| 353 | |
Henrik Rydberg | fed87e6 | 2010-09-05 12:25:11 -0700 | [diff] [blame] | 354 | /* default features */ |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 355 | features->device_type = BTN_TOOL_PEN; |
Henrik Rydberg | fed87e6 | 2010-09-05 12:25:11 -0700 | [diff] [blame] | 356 | features->x_fuzz = 4; |
| 357 | features->y_fuzz = 4; |
| 358 | features->pressure_fuzz = 0; |
| 359 | features->distance_fuzz = 0; |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 360 | |
Chris Bagwell | 3dc9f40 | 2010-09-12 00:08:40 -0700 | [diff] [blame] | 361 | /* only Tablet PCs and Bamboo P&T need to retrieve the info */ |
Ping Cheng | 4a88081 | 2010-09-05 12:25:40 -0700 | [diff] [blame] | 362 | if ((features->type != TABLETPC) && (features->type != TABLETPC2FG) && |
| 363 | (features->type != BAMBOO_PT)) |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 364 | goto out; |
| 365 | |
| 366 | if (usb_get_extra_descriptor(interface, HID_DEVICET_HID, &hid_desc)) { |
| 367 | if (usb_get_extra_descriptor(&interface->endpoint[0], |
| 368 | HID_DEVICET_REPORT, &hid_desc)) { |
| 369 | printk("wacom: can not retrieve extra class descriptor\n"); |
| 370 | error = 1; |
| 371 | goto out; |
| 372 | } |
| 373 | } |
| 374 | error = wacom_parse_hid(intf, hid_desc, features); |
| 375 | if (error) |
| 376 | goto out; |
| 377 | |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 378 | out: |
| 379 | return error; |
| 380 | } |
| 381 | |
Ping Cheng | 4492eff | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 382 | struct wacom_usbdev_data { |
| 383 | struct list_head list; |
| 384 | struct kref kref; |
| 385 | struct usb_device *dev; |
| 386 | struct wacom_shared shared; |
| 387 | }; |
| 388 | |
| 389 | static LIST_HEAD(wacom_udev_list); |
| 390 | static DEFINE_MUTEX(wacom_udev_list_lock); |
| 391 | |
| 392 | static struct wacom_usbdev_data *wacom_get_usbdev_data(struct usb_device *dev) |
| 393 | { |
| 394 | struct wacom_usbdev_data *data; |
| 395 | |
| 396 | list_for_each_entry(data, &wacom_udev_list, list) { |
| 397 | if (data->dev == dev) { |
| 398 | kref_get(&data->kref); |
| 399 | return data; |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | return NULL; |
| 404 | } |
| 405 | |
| 406 | static int wacom_add_shared_data(struct wacom_wac *wacom, |
| 407 | struct usb_device *dev) |
| 408 | { |
| 409 | struct wacom_usbdev_data *data; |
| 410 | int retval = 0; |
| 411 | |
| 412 | mutex_lock(&wacom_udev_list_lock); |
| 413 | |
| 414 | data = wacom_get_usbdev_data(dev); |
| 415 | if (!data) { |
| 416 | data = kzalloc(sizeof(struct wacom_usbdev_data), GFP_KERNEL); |
| 417 | if (!data) { |
| 418 | retval = -ENOMEM; |
| 419 | goto out; |
| 420 | } |
| 421 | |
| 422 | kref_init(&data->kref); |
| 423 | data->dev = dev; |
| 424 | list_add_tail(&data->list, &wacom_udev_list); |
| 425 | } |
| 426 | |
| 427 | wacom->shared = &data->shared; |
| 428 | |
| 429 | out: |
| 430 | mutex_unlock(&wacom_udev_list_lock); |
| 431 | return retval; |
| 432 | } |
| 433 | |
| 434 | static void wacom_release_shared_data(struct kref *kref) |
| 435 | { |
| 436 | struct wacom_usbdev_data *data = |
| 437 | container_of(kref, struct wacom_usbdev_data, kref); |
| 438 | |
| 439 | mutex_lock(&wacom_udev_list_lock); |
| 440 | list_del(&data->list); |
| 441 | mutex_unlock(&wacom_udev_list_lock); |
| 442 | |
| 443 | kfree(data); |
| 444 | } |
| 445 | |
| 446 | static void wacom_remove_shared_data(struct wacom_wac *wacom) |
| 447 | { |
| 448 | struct wacom_usbdev_data *data; |
| 449 | |
| 450 | if (wacom->shared) { |
| 451 | data = container_of(wacom->shared, struct wacom_usbdev_data, shared); |
| 452 | kref_put(&data->kref, wacom_release_shared_data); |
| 453 | wacom->shared = NULL; |
| 454 | } |
| 455 | } |
| 456 | |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 457 | static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id) |
| 458 | { |
| 459 | struct usb_device *dev = interface_to_usbdev(intf); |
| 460 | struct usb_endpoint_descriptor *endpoint; |
| 461 | struct wacom *wacom; |
| 462 | struct wacom_wac *wacom_wac; |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 463 | struct wacom_features *features; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 464 | struct input_dev *input_dev; |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 465 | int error; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 466 | |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 467 | if (!id->driver_info) |
Bastian Blank | b036f6f | 2010-02-10 23:06:23 -0800 | [diff] [blame] | 468 | return -EINVAL; |
| 469 | |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 470 | wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 471 | input_dev = input_allocate_device(); |
Dmitry Torokhov | 51269fe | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 472 | if (!wacom || !input_dev) { |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 473 | error = -ENOMEM; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 474 | goto fail1; |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 475 | } |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 476 | |
Dmitry Torokhov | 51269fe | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 477 | wacom_wac = &wacom->wacom_wac; |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 478 | wacom_wac->features = *((struct wacom_features *)id->driver_info); |
| 479 | features = &wacom_wac->features; |
| 480 | if (features->pktlen > WACOM_PKGLEN_MAX) { |
| 481 | error = -EINVAL; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 482 | goto fail1; |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 483 | } |
| 484 | |
Daniel Mack | 997ea58 | 2010-04-12 13:17:25 +0200 | [diff] [blame] | 485 | wacom_wac->data = usb_alloc_coherent(dev, WACOM_PKGLEN_MAX, |
| 486 | GFP_KERNEL, &wacom->data_dma); |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 487 | if (!wacom_wac->data) { |
| 488 | error = -ENOMEM; |
| 489 | goto fail1; |
| 490 | } |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 491 | |
| 492 | wacom->irq = usb_alloc_urb(0, GFP_KERNEL); |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 493 | if (!wacom->irq) { |
| 494 | error = -ENOMEM; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 495 | goto fail2; |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 496 | } |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 497 | |
| 498 | wacom->usbdev = dev; |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 499 | wacom->intf = intf; |
| 500 | mutex_init(&wacom->lock); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 501 | usb_make_path(dev, wacom->phys, sizeof(wacom->phys)); |
| 502 | strlcat(wacom->phys, "/input0", sizeof(wacom->phys)); |
| 503 | |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 504 | wacom_wac->input = input_dev; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 505 | |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 506 | endpoint = &intf->cur_altsetting->endpoint[0].desc; |
| 507 | |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 508 | /* Retrieve the physical and logical size for OEM devices */ |
| 509 | error = wacom_retrieve_hid_descriptor(intf, features); |
| 510 | if (error) |
Alexander Strakh | 4b6d443 | 2011-02-11 00:44:41 -0800 | [diff] [blame] | 511 | goto fail3; |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 512 | |
Henrik Rydberg | bc73dd3 | 2010-09-05 12:26:16 -0700 | [diff] [blame] | 513 | wacom_setup_device_quirks(features); |
| 514 | |
Ping Cheng | 49b764a | 2010-02-20 00:53:49 -0800 | [diff] [blame] | 515 | strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name)); |
| 516 | |
Henrik Rydberg | bc73dd3 | 2010-09-05 12:26:16 -0700 | [diff] [blame] | 517 | if (features->quirks & WACOM_QUIRK_MULTI_INPUT) { |
Ping Cheng | 49b764a | 2010-02-20 00:53:49 -0800 | [diff] [blame] | 518 | /* Append the device type to the name */ |
| 519 | strlcat(wacom_wac->name, |
| 520 | features->device_type == BTN_TOOL_PEN ? |
| 521 | " Pen" : " Finger", |
| 522 | sizeof(wacom_wac->name)); |
Ping Cheng | 4492eff | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 523 | |
| 524 | error = wacom_add_shared_data(wacom_wac, dev); |
| 525 | if (error) |
| 526 | goto fail3; |
Ping Cheng | 49b764a | 2010-02-20 00:53:49 -0800 | [diff] [blame] | 527 | } |
| 528 | |
| 529 | input_dev->name = wacom_wac->name; |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 530 | input_dev->dev.parent = &intf->dev; |
| 531 | input_dev->open = wacom_open; |
| 532 | input_dev->close = wacom_close; |
| 533 | usb_to_input_id(dev, &input_dev->id); |
| 534 | input_set_drvdata(input_dev, wacom); |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 535 | |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 536 | wacom_setup_input_capabilities(input_dev, wacom_wac); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 537 | |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 538 | usb_fill_int_urb(wacom->irq, dev, |
| 539 | usb_rcvintpipe(dev, endpoint->bEndpointAddress), |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 540 | wacom_wac->data, features->pktlen, |
Ping Cheng | 8d32e3a | 2006-09-26 13:34:47 -0700 | [diff] [blame] | 541 | wacom_sys_irq, wacom, endpoint->bInterval); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 542 | wacom->irq->transfer_dma = wacom->data_dma; |
| 543 | wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
| 544 | |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 545 | error = input_register_device(input_dev); |
Dmitry Torokhov | 5014186 | 2007-04-12 01:33:39 -0400 | [diff] [blame] | 546 | if (error) |
Ping Cheng | 4492eff | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 547 | goto fail4; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 548 | |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 549 | /* Note that if query fails it is not a hard failure */ |
| 550 | wacom_query_tablet_data(intf, features); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 551 | |
| 552 | usb_set_intfdata(intf, wacom); |
| 553 | return 0; |
| 554 | |
Ping Cheng | 4492eff | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 555 | fail4: wacom_remove_shared_data(wacom_wac); |
Dmitry Torokhov | 5014186 | 2007-04-12 01:33:39 -0400 | [diff] [blame] | 556 | fail3: usb_free_urb(wacom->irq); |
Daniel Mack | 997ea58 | 2010-04-12 13:17:25 +0200 | [diff] [blame] | 557 | fail2: usb_free_coherent(dev, WACOM_PKGLEN_MAX, wacom_wac->data, wacom->data_dma); |
Dmitry Torokhov | 5014186 | 2007-04-12 01:33:39 -0400 | [diff] [blame] | 558 | fail1: input_free_device(input_dev); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 559 | kfree(wacom); |
Dmitry Torokhov | 5014186 | 2007-04-12 01:33:39 -0400 | [diff] [blame] | 560 | return error; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 561 | } |
| 562 | |
| 563 | static void wacom_disconnect(struct usb_interface *intf) |
| 564 | { |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 565 | struct wacom *wacom = usb_get_intfdata(intf); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 566 | |
| 567 | usb_set_intfdata(intf, NULL); |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 568 | |
| 569 | usb_kill_urb(wacom->irq); |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 570 | input_unregister_device(wacom->wacom_wac.input); |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 571 | usb_free_urb(wacom->irq); |
Daniel Mack | 997ea58 | 2010-04-12 13:17:25 +0200 | [diff] [blame] | 572 | usb_free_coherent(interface_to_usbdev(intf), WACOM_PKGLEN_MAX, |
Dmitry Torokhov | 51269fe | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 573 | wacom->wacom_wac.data, wacom->data_dma); |
| 574 | wacom_remove_shared_data(&wacom->wacom_wac); |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 575 | kfree(wacom); |
| 576 | } |
| 577 | |
| 578 | static int wacom_suspend(struct usb_interface *intf, pm_message_t message) |
| 579 | { |
| 580 | struct wacom *wacom = usb_get_intfdata(intf); |
| 581 | |
| 582 | mutex_lock(&wacom->lock); |
| 583 | usb_kill_urb(wacom->irq); |
| 584 | mutex_unlock(&wacom->lock); |
| 585 | |
| 586 | return 0; |
| 587 | } |
| 588 | |
| 589 | static int wacom_resume(struct usb_interface *intf) |
| 590 | { |
| 591 | struct wacom *wacom = usb_get_intfdata(intf); |
Dmitry Torokhov | 51269fe | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 592 | struct wacom_features *features = &wacom->wacom_wac.features; |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 593 | int rv; |
| 594 | |
| 595 | mutex_lock(&wacom->lock); |
Ping Cheng | 3810147 | 2010-04-13 23:07:52 -0700 | [diff] [blame] | 596 | |
| 597 | /* switch to wacom mode first */ |
| 598 | wacom_query_tablet_data(intf, features); |
| 599 | |
| 600 | if (wacom->open) |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 601 | rv = usb_submit_urb(wacom->irq, GFP_NOIO); |
Ping Cheng | 3810147 | 2010-04-13 23:07:52 -0700 | [diff] [blame] | 602 | else |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 603 | rv = 0; |
Ping Cheng | 3810147 | 2010-04-13 23:07:52 -0700 | [diff] [blame] | 604 | |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 605 | mutex_unlock(&wacom->lock); |
| 606 | |
| 607 | return rv; |
| 608 | } |
| 609 | |
| 610 | static int wacom_reset_resume(struct usb_interface *intf) |
| 611 | { |
| 612 | return wacom_resume(intf); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 613 | } |
| 614 | |
| 615 | static struct usb_driver wacom_driver = { |
| 616 | .name = "wacom", |
Bastian Blank | b036f6f | 2010-02-10 23:06:23 -0800 | [diff] [blame] | 617 | .id_table = wacom_ids, |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 618 | .probe = wacom_probe, |
| 619 | .disconnect = wacom_disconnect, |
Oliver Neukum | e722409 | 2008-04-15 01:31:57 -0400 | [diff] [blame] | 620 | .suspend = wacom_suspend, |
| 621 | .resume = wacom_resume, |
| 622 | .reset_resume = wacom_reset_resume, |
| 623 | .supports_autosuspend = 1, |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 624 | }; |
| 625 | |
| 626 | static int __init wacom_init(void) |
| 627 | { |
| 628 | int result; |
Bastian Blank | b036f6f | 2010-02-10 23:06:23 -0800 | [diff] [blame] | 629 | |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 630 | result = usb_register(&wacom_driver); |
| 631 | if (result == 0) |
Greg Kroah-Hartman | 899ef6e | 2008-08-18 13:21:04 -0700 | [diff] [blame] | 632 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 633 | DRIVER_DESC "\n"); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 634 | return result; |
| 635 | } |
| 636 | |
| 637 | static void __exit wacom_exit(void) |
| 638 | { |
| 639 | usb_deregister(&wacom_driver); |
| 640 | } |
| 641 | |
| 642 | module_init(wacom_init); |
| 643 | module_exit(wacom_exit); |