blob: a205055a4c517d8a602e1d7d2b478d4342e783e6 [file] [log] [blame]
Ping Cheng3bea7332006-07-13 18:01:36 -07001/*
Dmitry Torokhov4104d132007-05-07 16:16:29 -04002 * drivers/input/tablet/wacom_sys.c
Ping Cheng3bea7332006-07-13 18:01:36 -07003 *
Ping Cheng232f5692009-12-15 00:35:24 -08004 * USB Wacom tablet support - system specific code
Ping Cheng3bea7332006-07-13 18:01:36 -07005 */
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 Cheng3bea7332006-07-13 18:01:36 -070014#include "wacom_wac.h"
Dmitry Torokhov51269fe2010-03-19 22:18:15 -070015#include "wacom.h"
Ping Cheng3bea7332006-07-13 18:01:36 -070016
Ping Cheng545f4e92008-11-24 11:44:27 -050017/* 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 */
Ping Cheng3bea7332006-07-13 18:01:36 -070049#define USB_REQ_GET_REPORT 0x01
50#define USB_REQ_SET_REPORT 0x09
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -070051
Ping Cheng545f4e92008-11-24 11:44:27 -050052#define WAC_HID_FEATURE_REPORT 0x03
Ping Chenga417ea42011-08-16 00:17:56 -070053#define WAC_MSG_RETRIES 5
Ping Cheng3bea7332006-07-13 18:01:36 -070054
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -070055#define WAC_CMD_LED_CONTROL 0x20
56#define WAC_CMD_ICON_START 0x21
57#define WAC_CMD_ICON_XFER 0x23
58#define WAC_CMD_RETRIES 10
59
60static int wacom_get_report(struct usb_interface *intf, u8 type, u8 id,
61 void *buf, size_t size, unsigned int retries)
Ping Cheng3bea7332006-07-13 18:01:36 -070062{
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -070063 struct usb_device *dev = interface_to_usbdev(intf);
64 int retval;
65
66 do {
67 retval = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
68 USB_REQ_GET_REPORT,
69 USB_TYPE_CLASS | USB_RECIP_INTERFACE,
70 (type << 8) + id,
71 intf->altsetting[0].desc.bInterfaceNumber,
72 buf, size, 100);
73 } while ((retval == -ETIMEDOUT || retval == -EPIPE) && --retries);
74
75 return retval;
Ping Cheng3bea7332006-07-13 18:01:36 -070076}
77
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -070078static int wacom_set_report(struct usb_interface *intf, u8 type, u8 id,
79 void *buf, size_t size, unsigned int retries)
Ping Cheng3bea7332006-07-13 18:01:36 -070080{
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -070081 struct usb_device *dev = interface_to_usbdev(intf);
82 int retval;
83
84 do {
85 retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
86 USB_REQ_SET_REPORT,
87 USB_TYPE_CLASS | USB_RECIP_INTERFACE,
88 (type << 8) + id,
89 intf->altsetting[0].desc.bInterfaceNumber,
90 buf, size, 1000);
91 } while ((retval == -ETIMEDOUT || retval == -EPIPE) && --retries);
92
93 return retval;
Ping Cheng3bea7332006-07-13 18:01:36 -070094}
95
Adrian Bunk54c9b222006-11-20 03:23:58 +010096static void wacom_sys_irq(struct urb *urb)
Ping Cheng3bea7332006-07-13 18:01:36 -070097{
98 struct wacom *wacom = urb->context;
Ping Cheng3bea7332006-07-13 18:01:36 -070099 int retval;
100
101 switch (urb->status) {
102 case 0:
103 /* success */
104 break;
105 case -ECONNRESET:
106 case -ENOENT:
107 case -ESHUTDOWN:
108 /* this urb is terminated, clean up */
Harvey Harrisonea3e6c52008-05-05 11:36:18 -0400109 dbg("%s - urb shutting down with status: %d", __func__, urb->status);
Ping Cheng3bea7332006-07-13 18:01:36 -0700110 return;
111 default:
Harvey Harrisonea3e6c52008-05-05 11:36:18 -0400112 dbg("%s - nonzero urb status received: %d", __func__, urb->status);
Ping Cheng3bea7332006-07-13 18:01:36 -0700113 goto exit;
114 }
115
Dmitry Torokhov95dd3b32010-03-19 22:18:15 -0700116 wacom_wac_irq(&wacom->wacom_wac, urb->actual_length);
Ping Cheng3bea7332006-07-13 18:01:36 -0700117
118 exit:
Oliver Neukume7224092008-04-15 01:31:57 -0400119 usb_mark_last_busy(wacom->usbdev);
Dmitry Torokhov73a97f42010-03-19 22:18:15 -0700120 retval = usb_submit_urb(urb, GFP_ATOMIC);
Ping Cheng3bea7332006-07-13 18:01:36 -0700121 if (retval)
122 err ("%s - usb_submit_urb failed with result %d",
Harvey Harrisonea3e6c52008-05-05 11:36:18 -0400123 __func__, retval);
Ping Cheng3bea7332006-07-13 18:01:36 -0700124}
125
Ping Cheng3bea7332006-07-13 18:01:36 -0700126static int wacom_open(struct input_dev *dev)
127{
Dmitry Torokhov7791bda2007-04-12 01:34:39 -0400128 struct wacom *wacom = input_get_drvdata(dev);
Dmitry Torokhovf6cd3782010-10-04 21:46:11 -0700129 int retval = 0;
130
131 if (usb_autopm_get_interface(wacom->intf) < 0)
132 return -EIO;
Ping Cheng3bea7332006-07-13 18:01:36 -0700133
Oliver Neukume7224092008-04-15 01:31:57 -0400134 mutex_lock(&wacom->lock);
Ping Cheng3bea7332006-07-13 18:01:36 -0700135
Oliver Neukume7224092008-04-15 01:31:57 -0400136 if (usb_submit_urb(wacom->irq, GFP_KERNEL)) {
Dmitry Torokhovf6cd3782010-10-04 21:46:11 -0700137 retval = -EIO;
138 goto out;
Oliver Neukume7224092008-04-15 01:31:57 -0400139 }
140
Dmitry Torokhov51269fe2010-03-19 22:18:15 -0700141 wacom->open = true;
Oliver Neukume7224092008-04-15 01:31:57 -0400142 wacom->intf->needs_remote_wakeup = 1;
143
Dmitry Torokhovf6cd3782010-10-04 21:46:11 -0700144out:
Oliver Neukume7224092008-04-15 01:31:57 -0400145 mutex_unlock(&wacom->lock);
Dmitry Torokhov62ecae02010-10-10 14:24:16 -0700146 usb_autopm_put_interface(wacom->intf);
Dmitry Torokhovf6cd3782010-10-04 21:46:11 -0700147 return retval;
Ping Cheng3bea7332006-07-13 18:01:36 -0700148}
149
150static void wacom_close(struct input_dev *dev)
151{
Dmitry Torokhov7791bda2007-04-12 01:34:39 -0400152 struct wacom *wacom = input_get_drvdata(dev);
Dmitry Torokhov62ecae02010-10-10 14:24:16 -0700153 int autopm_error;
154
155 autopm_error = usb_autopm_get_interface(wacom->intf);
Ping Cheng3bea7332006-07-13 18:01:36 -0700156
Oliver Neukume7224092008-04-15 01:31:57 -0400157 mutex_lock(&wacom->lock);
Ping Cheng3bea7332006-07-13 18:01:36 -0700158 usb_kill_urb(wacom->irq);
Dmitry Torokhov51269fe2010-03-19 22:18:15 -0700159 wacom->open = false;
Oliver Neukume7224092008-04-15 01:31:57 -0400160 wacom->intf->needs_remote_wakeup = 0;
161 mutex_unlock(&wacom->lock);
Dmitry Torokhovf6cd3782010-10-04 21:46:11 -0700162
Dmitry Torokhov62ecae02010-10-10 14:24:16 -0700163 if (!autopm_error)
164 usb_autopm_put_interface(wacom->intf);
Ping Cheng3bea7332006-07-13 18:01:36 -0700165}
166
Ping Cheng545f4e92008-11-24 11:44:27 -0500167static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hid_desc,
Ping Chengec67bbe2009-12-15 00:35:24 -0800168 struct wacom_features *features)
Ping Cheng545f4e92008-11-24 11:44:27 -0500169{
170 struct usb_device *dev = interface_to_usbdev(intf);
Ping Chengec67bbe2009-12-15 00:35:24 -0800171 char limit = 0;
172 /* result has to be defined as int for some devices */
173 int result = 0;
Ping Cheng545f4e92008-11-24 11:44:27 -0500174 int i = 0, usage = WCM_UNDEFINED, finger = 0, pen = 0;
175 unsigned char *report;
176
177 report = kzalloc(hid_desc->wDescriptorLength, GFP_KERNEL);
178 if (!report)
179 return -ENOMEM;
180
181 /* retrive report descriptors */
182 do {
183 result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
184 USB_REQ_GET_DESCRIPTOR,
185 USB_RECIP_INTERFACE | USB_DIR_IN,
186 HID_DEVICET_REPORT << 8,
187 intf->altsetting[0].desc.bInterfaceNumber, /* interface */
188 report,
189 hid_desc->wDescriptorLength,
190 5000); /* 5 secs */
Ping Chenga417ea42011-08-16 00:17:56 -0700191 } while (result < 0 && limit++ < WAC_MSG_RETRIES);
Ping Cheng545f4e92008-11-24 11:44:27 -0500192
Ping Cheng384318e2009-04-28 07:49:54 -0700193 /* No need to parse the Descriptor. It isn't an error though */
Ping Cheng545f4e92008-11-24 11:44:27 -0500194 if (result < 0)
195 goto out;
196
197 for (i = 0; i < hid_desc->wDescriptorLength; i++) {
198
199 switch (report[i]) {
200 case HID_USAGE_PAGE:
201 switch (report[i + 1]) {
202 case HID_USAGE_PAGE_DIGITIZER:
203 usage = WCM_DIGITIZER;
204 i++;
205 break;
206
207 case HID_USAGE_PAGE_DESKTOP:
208 usage = WCM_DESKTOP;
209 i++;
210 break;
211 }
212 break;
213
214 case HID_USAGE:
215 switch (report[i + 1]) {
216 case HID_USAGE_X:
217 if (usage == WCM_DESKTOP) {
218 if (finger) {
Ping Cheng84eb5aa2011-03-12 20:35:18 -0800219 features->device_type = BTN_TOOL_FINGER;
Ping Chengec67bbe2009-12-15 00:35:24 -0800220 if (features->type == TABLETPC2FG) {
221 /* need to reset back */
222 features->pktlen = WACOM_PKGLEN_TPC2FG;
Ping Cheng84eb5aa2011-03-12 20:35:18 -0800223 features->device_type = BTN_TOOL_DOUBLETAP;
Ping Chengec67bbe2009-12-15 00:35:24 -0800224 }
Ping Cheng4a880812010-09-05 12:25:40 -0700225 if (features->type == BAMBOO_PT) {
226 /* need to reset back */
227 features->pktlen = WACOM_PKGLEN_BBTOUCH;
Ping Cheng84eb5aa2011-03-12 20:35:18 -0800228 features->device_type = BTN_TOOL_DOUBLETAP;
Ping Cheng4a880812010-09-05 12:25:40 -0700229 features->x_phy =
230 get_unaligned_le16(&report[i + 5]);
231 features->x_max =
232 get_unaligned_le16(&report[i + 8]);
233 i += 15;
234 } else {
235 features->x_max =
236 get_unaligned_le16(&report[i + 3]);
237 features->x_phy =
238 get_unaligned_le16(&report[i + 6]);
239 features->unit = report[i + 9];
240 features->unitExpo = report[i + 11];
241 i += 12;
242 }
Ping Cheng545f4e92008-11-24 11:44:27 -0500243 } else if (pen) {
Ping Chengec67bbe2009-12-15 00:35:24 -0800244 /* penabled only accepts exact bytes of data */
245 if (features->type == TABLETPC2FG)
Ping Cheng57e413d2010-03-01 23:50:24 -0800246 features->pktlen = WACOM_PKGLEN_GRAPHIRE;
Ping Cheng4a880812010-09-05 12:25:40 -0700247 if (features->type == BAMBOO_PT)
248 features->pktlen = WACOM_PKGLEN_BBFUN;
Ping Chengec67bbe2009-12-15 00:35:24 -0800249 features->device_type = BTN_TOOL_PEN;
Ping Cheng545f4e92008-11-24 11:44:27 -0500250 features->x_max =
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700251 get_unaligned_le16(&report[i + 3]);
Ping Cheng545f4e92008-11-24 11:44:27 -0500252 i += 4;
253 }
254 } else if (usage == WCM_DIGITIZER) {
255 /* max pressure isn't reported
256 features->pressure_max = (unsigned short)
257 (report[i+4] << 8 | report[i + 3]);
258 */
259 features->pressure_max = 255;
260 i += 4;
261 }
262 break;
263
264 case HID_USAGE_Y:
Ping Chengec67bbe2009-12-15 00:35:24 -0800265 if (usage == WCM_DESKTOP) {
266 if (finger) {
Ping Cheng84eb5aa2011-03-12 20:35:18 -0800267 features->device_type = BTN_TOOL_FINGER;
Ping Chengec67bbe2009-12-15 00:35:24 -0800268 if (features->type == TABLETPC2FG) {
269 /* need to reset back */
270 features->pktlen = WACOM_PKGLEN_TPC2FG;
Ping Cheng84eb5aa2011-03-12 20:35:18 -0800271 features->device_type = BTN_TOOL_DOUBLETAP;
Ping Chengec67bbe2009-12-15 00:35:24 -0800272 features->y_max =
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700273 get_unaligned_le16(&report[i + 3]);
Ping Chengec67bbe2009-12-15 00:35:24 -0800274 features->y_phy =
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700275 get_unaligned_le16(&report[i + 6]);
Ping Chengec67bbe2009-12-15 00:35:24 -0800276 i += 7;
Ping Cheng4a880812010-09-05 12:25:40 -0700277 } else if (features->type == BAMBOO_PT) {
278 /* need to reset back */
279 features->pktlen = WACOM_PKGLEN_BBTOUCH;
Ping Cheng84eb5aa2011-03-12 20:35:18 -0800280 features->device_type = BTN_TOOL_DOUBLETAP;
Ping Cheng4a880812010-09-05 12:25:40 -0700281 features->y_phy =
282 get_unaligned_le16(&report[i + 3]);
283 features->y_max =
284 get_unaligned_le16(&report[i + 6]);
285 i += 12;
Ping Chengec67bbe2009-12-15 00:35:24 -0800286 } else {
287 features->y_max =
288 features->x_max;
289 features->y_phy =
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700290 get_unaligned_le16(&report[i + 3]);
Ping Chengec67bbe2009-12-15 00:35:24 -0800291 i += 4;
292 }
293 } else if (pen) {
294 /* penabled only accepts exact bytes of data */
295 if (features->type == TABLETPC2FG)
Ping Cheng57e413d2010-03-01 23:50:24 -0800296 features->pktlen = WACOM_PKGLEN_GRAPHIRE;
Ping Cheng4a880812010-09-05 12:25:40 -0700297 if (features->type == BAMBOO_PT)
298 features->pktlen = WACOM_PKGLEN_BBFUN;
Ping Chengec67bbe2009-12-15 00:35:24 -0800299 features->device_type = BTN_TOOL_PEN;
300 features->y_max =
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700301 get_unaligned_le16(&report[i + 3]);
Ping Chengec67bbe2009-12-15 00:35:24 -0800302 i += 4;
303 }
304 }
Ping Cheng545f4e92008-11-24 11:44:27 -0500305 break;
306
307 case HID_USAGE_FINGER:
308 finger = 1;
309 i++;
310 break;
311
312 case HID_USAGE_STYLUS:
313 pen = 1;
314 i++;
315 break;
316
317 case HID_USAGE_UNDEFINED:
318 if (usage == WCM_DESKTOP && finger) /* capacity */
319 features->pressure_max =
Dmitry Torokhov252f7762010-03-19 22:33:38 -0700320 get_unaligned_le16(&report[i + 3]);
Ping Cheng545f4e92008-11-24 11:44:27 -0500321 i += 4;
322 break;
323 }
324 break;
325
326 case HID_COLLECTION:
Ping Chengec67bbe2009-12-15 00:35:24 -0800327 /* reset UsagePage and Finger */
Ping Cheng545f4e92008-11-24 11:44:27 -0500328 finger = usage = 0;
329 break;
330 }
331 }
332
Ping Cheng545f4e92008-11-24 11:44:27 -0500333 out:
Ping Cheng384318e2009-04-28 07:49:54 -0700334 result = 0;
Ping Cheng545f4e92008-11-24 11:44:27 -0500335 kfree(report);
336 return result;
337}
338
Ping Chengec67bbe2009-12-15 00:35:24 -0800339static int wacom_query_tablet_data(struct usb_interface *intf, struct wacom_features *features)
Dmitry Torokhov3b7307c2009-08-20 21:41:04 -0700340{
341 unsigned char *rep_data;
Ping Chengec67bbe2009-12-15 00:35:24 -0800342 int limit = 0, report_id = 2;
343 int error = -ENOMEM;
Dmitry Torokhov3b7307c2009-08-20 21:41:04 -0700344
Ping Cheng3b48c912011-08-16 00:17:57 -0700345 rep_data = kmalloc(4, GFP_KERNEL);
Dmitry Torokhov3b7307c2009-08-20 21:41:04 -0700346 if (!rep_data)
Ping Chengec67bbe2009-12-15 00:35:24 -0800347 return error;
Dmitry Torokhov3b7307c2009-08-20 21:41:04 -0700348
Ping Cheng3b48c912011-08-16 00:17:57 -0700349 /* ask to report tablet data if it is MT Tablet PC or
Chris Bagwell3dc9f402010-09-12 00:08:40 -0700350 * not a Tablet PC */
351 if (features->type == TABLETPC2FG) {
Ping Chengec67bbe2009-12-15 00:35:24 -0800352 do {
353 rep_data[0] = 3;
354 rep_data[1] = 4;
Ping Cheng3b48c912011-08-16 00:17:57 -0700355 rep_data[2] = 0;
356 rep_data[3] = 0;
Ping Chengec67bbe2009-12-15 00:35:24 -0800357 report_id = 3;
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700358 error = wacom_set_report(intf, WAC_HID_FEATURE_REPORT,
359 report_id, rep_data, 4, 1);
Ping Chengec67bbe2009-12-15 00:35:24 -0800360 if (error >= 0)
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700361 error = wacom_get_report(intf,
362 WAC_HID_FEATURE_REPORT,
363 report_id, rep_data, 4, 1);
Ping Chenga417ea42011-08-16 00:17:56 -0700364 } while ((error < 0 || rep_data[1] != 4) && limit++ < WAC_MSG_RETRIES);
Chris Bagwell3dc9f402010-09-12 00:08:40 -0700365 } else if (features->type != TABLETPC) {
Ping Chengec67bbe2009-12-15 00:35:24 -0800366 do {
367 rep_data[0] = 2;
368 rep_data[1] = 2;
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700369 error = wacom_set_report(intf, WAC_HID_FEATURE_REPORT,
370 report_id, rep_data, 2, 1);
Ping Chengec67bbe2009-12-15 00:35:24 -0800371 if (error >= 0)
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700372 error = wacom_get_report(intf,
373 WAC_HID_FEATURE_REPORT,
374 report_id, rep_data, 2, 1);
Ping Chenga417ea42011-08-16 00:17:56 -0700375 } while ((error < 0 || rep_data[1] != 2) && limit++ < WAC_MSG_RETRIES);
Ping Chengec67bbe2009-12-15 00:35:24 -0800376 }
Dmitry Torokhov3b7307c2009-08-20 21:41:04 -0700377
378 kfree(rep_data);
379
380 return error < 0 ? error : 0;
381}
382
Ping Chengec67bbe2009-12-15 00:35:24 -0800383static int wacom_retrieve_hid_descriptor(struct usb_interface *intf,
384 struct wacom_features *features)
385{
386 int error = 0;
387 struct usb_host_interface *interface = intf->cur_altsetting;
388 struct hid_descriptor *hid_desc;
389
Henrik Rydbergfed87e62010-09-05 12:25:11 -0700390 /* default features */
Ping Chengec67bbe2009-12-15 00:35:24 -0800391 features->device_type = BTN_TOOL_PEN;
Henrik Rydbergfed87e62010-09-05 12:25:11 -0700392 features->x_fuzz = 4;
393 features->y_fuzz = 4;
394 features->pressure_fuzz = 0;
395 features->distance_fuzz = 0;
Ping Chengec67bbe2009-12-15 00:35:24 -0800396
Chris Bagwell3dc9f402010-09-12 00:08:40 -0700397 /* only Tablet PCs and Bamboo P&T need to retrieve the info */
Ping Cheng4a880812010-09-05 12:25:40 -0700398 if ((features->type != TABLETPC) && (features->type != TABLETPC2FG) &&
399 (features->type != BAMBOO_PT))
Ping Chengec67bbe2009-12-15 00:35:24 -0800400 goto out;
401
402 if (usb_get_extra_descriptor(interface, HID_DEVICET_HID, &hid_desc)) {
403 if (usb_get_extra_descriptor(&interface->endpoint[0],
404 HID_DEVICET_REPORT, &hid_desc)) {
405 printk("wacom: can not retrieve extra class descriptor\n");
406 error = 1;
407 goto out;
408 }
409 }
410 error = wacom_parse_hid(intf, hid_desc, features);
411 if (error)
412 goto out;
413
Ping Chengec67bbe2009-12-15 00:35:24 -0800414 out:
415 return error;
416}
417
Ping Cheng4492eff2010-03-19 22:18:15 -0700418struct wacom_usbdev_data {
419 struct list_head list;
420 struct kref kref;
421 struct usb_device *dev;
422 struct wacom_shared shared;
423};
424
425static LIST_HEAD(wacom_udev_list);
426static DEFINE_MUTEX(wacom_udev_list_lock);
427
428static struct wacom_usbdev_data *wacom_get_usbdev_data(struct usb_device *dev)
429{
430 struct wacom_usbdev_data *data;
431
432 list_for_each_entry(data, &wacom_udev_list, list) {
433 if (data->dev == dev) {
434 kref_get(&data->kref);
435 return data;
436 }
437 }
438
439 return NULL;
440}
441
442static int wacom_add_shared_data(struct wacom_wac *wacom,
443 struct usb_device *dev)
444{
445 struct wacom_usbdev_data *data;
446 int retval = 0;
447
448 mutex_lock(&wacom_udev_list_lock);
449
450 data = wacom_get_usbdev_data(dev);
451 if (!data) {
452 data = kzalloc(sizeof(struct wacom_usbdev_data), GFP_KERNEL);
453 if (!data) {
454 retval = -ENOMEM;
455 goto out;
456 }
457
458 kref_init(&data->kref);
459 data->dev = dev;
460 list_add_tail(&data->list, &wacom_udev_list);
461 }
462
463 wacom->shared = &data->shared;
464
465out:
466 mutex_unlock(&wacom_udev_list_lock);
467 return retval;
468}
469
470static void wacom_release_shared_data(struct kref *kref)
471{
472 struct wacom_usbdev_data *data =
473 container_of(kref, struct wacom_usbdev_data, kref);
474
475 mutex_lock(&wacom_udev_list_lock);
476 list_del(&data->list);
477 mutex_unlock(&wacom_udev_list_lock);
478
479 kfree(data);
480}
481
482static void wacom_remove_shared_data(struct wacom_wac *wacom)
483{
484 struct wacom_usbdev_data *data;
485
486 if (wacom->shared) {
487 data = container_of(wacom->shared, struct wacom_usbdev_data, shared);
488 kref_put(&data->kref, wacom_release_shared_data);
489 wacom->shared = NULL;
490 }
491}
492
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700493static int wacom_led_control(struct wacom *wacom)
494{
495 unsigned char *buf;
Ping Cheng09e7d942011-10-04 23:51:14 -0700496 int retval, led = 0;
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700497
498 buf = kzalloc(9, GFP_KERNEL);
499 if (!buf)
500 return -ENOMEM;
501
Ping Cheng09e7d942011-10-04 23:51:14 -0700502 if (wacom->wacom_wac.features.type == WACOM_21UX2)
503 led = (wacom->led.select[1] << 4) | 0x40;
504
505 led |= wacom->led.select[0] | 0x4;
506
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700507 buf[0] = WAC_CMD_LED_CONTROL;
Ping Cheng09e7d942011-10-04 23:51:14 -0700508 buf[1] = led;
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700509 buf[2] = wacom->led.llv;
510 buf[3] = wacom->led.hlv;
511 buf[4] = wacom->led.img_lum;
512
513 retval = wacom_set_report(wacom->intf, 0x03, WAC_CMD_LED_CONTROL,
514 buf, 9, WAC_CMD_RETRIES);
515 kfree(buf);
516
517 return retval;
518}
519
520static int wacom_led_putimage(struct wacom *wacom, int button_id, const void *img)
521{
522 unsigned char *buf;
523 int i, retval;
524
525 buf = kzalloc(259, GFP_KERNEL);
526 if (!buf)
527 return -ENOMEM;
528
529 /* Send 'start' command */
530 buf[0] = WAC_CMD_ICON_START;
531 buf[1] = 1;
532 retval = wacom_set_report(wacom->intf, 0x03, WAC_CMD_ICON_START,
533 buf, 2, WAC_CMD_RETRIES);
534 if (retval < 0)
535 goto out;
536
537 buf[0] = WAC_CMD_ICON_XFER;
538 buf[1] = button_id & 0x07;
539 for (i = 0; i < 4; i++) {
540 buf[2] = i;
541 memcpy(buf + 3, img + i * 256, 256);
542
543 retval = wacom_set_report(wacom->intf, 0x03, WAC_CMD_ICON_XFER,
544 buf, 259, WAC_CMD_RETRIES);
545 if (retval < 0)
546 break;
547 }
548
549 /* Send 'stop' */
550 buf[0] = WAC_CMD_ICON_START;
551 buf[1] = 0;
552 wacom_set_report(wacom->intf, 0x03, WAC_CMD_ICON_START,
553 buf, 2, WAC_CMD_RETRIES);
554
555out:
556 kfree(buf);
557 return retval;
558}
559
Ping Cheng09e7d942011-10-04 23:51:14 -0700560static ssize_t wacom_led_select_store(struct device *dev, int set_id,
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700561 const char *buf, size_t count)
562{
563 struct wacom *wacom = dev_get_drvdata(dev);
564 unsigned int id;
565 int err;
566
567 err = kstrtouint(buf, 10, &id);
568 if (err)
569 return err;
570
571 mutex_lock(&wacom->lock);
572
Ping Cheng09e7d942011-10-04 23:51:14 -0700573 wacom->led.select[set_id] = id & 0x3;
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700574 err = wacom_led_control(wacom);
575
576 mutex_unlock(&wacom->lock);
577
578 return err < 0 ? err : count;
579}
580
Ping Cheng09e7d942011-10-04 23:51:14 -0700581#define DEVICE_LED_SELECT_ATTR(SET_ID) \
582static ssize_t wacom_led##SET_ID##_select_store(struct device *dev, \
583 struct device_attribute *attr, const char *buf, size_t count) \
584{ \
585 return wacom_led_select_store(dev, SET_ID, buf, count); \
586} \
Ping Cheng04c59ab2011-10-04 23:51:49 -0700587static ssize_t wacom_led##SET_ID##_select_show(struct device *dev, \
588 struct device_attribute *attr, char *buf) \
589{ \
590 struct wacom *wacom = dev_get_drvdata(dev); \
591 return snprintf(buf, 2, "%d\n", wacom->led.select[SET_ID]); \
592} \
593static DEVICE_ATTR(status_led##SET_ID##_select, S_IWUSR | S_IRUSR, \
594 wacom_led##SET_ID##_select_show, \
Ping Cheng09e7d942011-10-04 23:51:14 -0700595 wacom_led##SET_ID##_select_store)
596
597DEVICE_LED_SELECT_ATTR(0);
598DEVICE_LED_SELECT_ATTR(1);
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700599
600static ssize_t wacom_luminance_store(struct wacom *wacom, u8 *dest,
601 const char *buf, size_t count)
602{
603 unsigned int value;
604 int err;
605
606 err = kstrtouint(buf, 10, &value);
607 if (err)
608 return err;
609
610 mutex_lock(&wacom->lock);
611
612 *dest = value & 0x7f;
613 err = wacom_led_control(wacom);
614
615 mutex_unlock(&wacom->lock);
616
617 return err < 0 ? err : count;
618}
619
620#define DEVICE_LUMINANCE_ATTR(name, field) \
621static ssize_t wacom_##name##_luminance_store(struct device *dev, \
622 struct device_attribute *attr, const char *buf, size_t count) \
623{ \
624 struct wacom *wacom = dev_get_drvdata(dev); \
625 \
626 return wacom_luminance_store(wacom, &wacom->led.field, \
627 buf, count); \
628} \
629static DEVICE_ATTR(name##_luminance, S_IWUSR, \
630 NULL, wacom_##name##_luminance_store)
631
632DEVICE_LUMINANCE_ATTR(status0, llv);
633DEVICE_LUMINANCE_ATTR(status1, hlv);
634DEVICE_LUMINANCE_ATTR(buttons, img_lum);
635
636static ssize_t wacom_button_image_store(struct device *dev, int button_id,
637 const char *buf, size_t count)
638{
639 struct wacom *wacom = dev_get_drvdata(dev);
640 int err;
641
642 if (count != 1024)
643 return -EINVAL;
644
645 mutex_lock(&wacom->lock);
646
647 err = wacom_led_putimage(wacom, button_id, buf);
648
649 mutex_unlock(&wacom->lock);
650
651 return err < 0 ? err : count;
652}
653
654#define DEVICE_BTNIMG_ATTR(BUTTON_ID) \
655static ssize_t wacom_btnimg##BUTTON_ID##_store(struct device *dev, \
656 struct device_attribute *attr, const char *buf, size_t count) \
657{ \
658 return wacom_button_image_store(dev, BUTTON_ID, buf, count); \
659} \
660static DEVICE_ATTR(button##BUTTON_ID##_rawimg, S_IWUSR, \
661 NULL, wacom_btnimg##BUTTON_ID##_store)
662
663DEVICE_BTNIMG_ATTR(0);
664DEVICE_BTNIMG_ATTR(1);
665DEVICE_BTNIMG_ATTR(2);
666DEVICE_BTNIMG_ATTR(3);
667DEVICE_BTNIMG_ATTR(4);
668DEVICE_BTNIMG_ATTR(5);
669DEVICE_BTNIMG_ATTR(6);
670DEVICE_BTNIMG_ATTR(7);
671
Ping Cheng09e7d942011-10-04 23:51:14 -0700672static struct attribute *cintiq_led_attrs[] = {
673 &dev_attr_status_led0_select.attr,
674 &dev_attr_status_led1_select.attr,
675 NULL
676};
677
678static struct attribute_group cintiq_led_attr_group = {
679 .name = "wacom_led",
680 .attrs = cintiq_led_attrs,
681};
682
683static struct attribute *intuos4_led_attrs[] = {
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700684 &dev_attr_status0_luminance.attr,
685 &dev_attr_status1_luminance.attr,
Ping Cheng09e7d942011-10-04 23:51:14 -0700686 &dev_attr_status_led0_select.attr,
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700687 &dev_attr_buttons_luminance.attr,
688 &dev_attr_button0_rawimg.attr,
689 &dev_attr_button1_rawimg.attr,
690 &dev_attr_button2_rawimg.attr,
691 &dev_attr_button3_rawimg.attr,
692 &dev_attr_button4_rawimg.attr,
693 &dev_attr_button5_rawimg.attr,
694 &dev_attr_button6_rawimg.attr,
695 &dev_attr_button7_rawimg.attr,
696 NULL
697};
698
Ping Cheng09e7d942011-10-04 23:51:14 -0700699static struct attribute_group intuos4_led_attr_group = {
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700700 .name = "wacom_led",
Ping Cheng09e7d942011-10-04 23:51:14 -0700701 .attrs = intuos4_led_attrs,
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700702};
703
704static int wacom_initialize_leds(struct wacom *wacom)
705{
706 int error;
707
Ping Cheng09e7d942011-10-04 23:51:14 -0700708 /* Initialize default values */
709 switch (wacom->wacom_wac.features.type) {
710 case INTUOS4:
711 case INTUOS4L:
712 wacom->led.select[0] = 0;
713 wacom->led.select[1] = 0;
Ping Chengf4fa9a62011-10-04 23:49:42 -0700714 wacom->led.llv = 10;
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700715 wacom->led.hlv = 20;
716 wacom->led.img_lum = 10;
Ping Cheng09e7d942011-10-04 23:51:14 -0700717 error = sysfs_create_group(&wacom->intf->dev.kobj,
718 &intuos4_led_attr_group);
719 break;
720
721 case WACOM_21UX2:
722 wacom->led.select[0] = 0;
723 wacom->led.select[1] = 0;
724 wacom->led.llv = 0;
725 wacom->led.hlv = 0;
726 wacom->led.img_lum = 0;
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700727
728 error = sysfs_create_group(&wacom->intf->dev.kobj,
Ping Cheng09e7d942011-10-04 23:51:14 -0700729 &cintiq_led_attr_group);
730 break;
731
732 default:
733 return 0;
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700734 }
735
Ping Cheng09e7d942011-10-04 23:51:14 -0700736 if (error) {
737 dev_err(&wacom->intf->dev,
738 "cannot create sysfs group err: %d\n", error);
739 return error;
740 }
741 wacom_led_control(wacom);
742
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700743 return 0;
744}
745
746static void wacom_destroy_leds(struct wacom *wacom)
747{
Ping Cheng09e7d942011-10-04 23:51:14 -0700748 switch (wacom->wacom_wac.features.type) {
749 case INTUOS4:
750 case INTUOS4L:
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700751 sysfs_remove_group(&wacom->intf->dev.kobj,
Ping Cheng09e7d942011-10-04 23:51:14 -0700752 &intuos4_led_attr_group);
753 break;
754
755 case WACOM_21UX2:
756 sysfs_remove_group(&wacom->intf->dev.kobj,
757 &cintiq_led_attr_group);
758 break;
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700759 }
760}
761
Ping Cheng3bea7332006-07-13 18:01:36 -0700762static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id)
763{
764 struct usb_device *dev = interface_to_usbdev(intf);
765 struct usb_endpoint_descriptor *endpoint;
766 struct wacom *wacom;
767 struct wacom_wac *wacom_wac;
Jason Childse33da8a2010-02-17 22:38:31 -0800768 struct wacom_features *features;
Ping Cheng3bea7332006-07-13 18:01:36 -0700769 struct input_dev *input_dev;
Jason Childse33da8a2010-02-17 22:38:31 -0800770 int error;
Ping Cheng3bea7332006-07-13 18:01:36 -0700771
Jason Childse33da8a2010-02-17 22:38:31 -0800772 if (!id->driver_info)
Bastian Blankb036f6f2010-02-10 23:06:23 -0800773 return -EINVAL;
774
Ping Cheng3bea7332006-07-13 18:01:36 -0700775 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL);
Ping Cheng3bea7332006-07-13 18:01:36 -0700776 input_dev = input_allocate_device();
Dmitry Torokhov51269fe2010-03-19 22:18:15 -0700777 if (!wacom || !input_dev) {
Jason Childse33da8a2010-02-17 22:38:31 -0800778 error = -ENOMEM;
Ping Cheng3bea7332006-07-13 18:01:36 -0700779 goto fail1;
Jason Childse33da8a2010-02-17 22:38:31 -0800780 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700781
Dmitry Torokhov51269fe2010-03-19 22:18:15 -0700782 wacom_wac = &wacom->wacom_wac;
Jason Childse33da8a2010-02-17 22:38:31 -0800783 wacom_wac->features = *((struct wacom_features *)id->driver_info);
784 features = &wacom_wac->features;
785 if (features->pktlen > WACOM_PKGLEN_MAX) {
786 error = -EINVAL;
Ping Cheng3bea7332006-07-13 18:01:36 -0700787 goto fail1;
Jason Childse33da8a2010-02-17 22:38:31 -0800788 }
789
Daniel Mack997ea582010-04-12 13:17:25 +0200790 wacom_wac->data = usb_alloc_coherent(dev, WACOM_PKGLEN_MAX,
791 GFP_KERNEL, &wacom->data_dma);
Jason Childse33da8a2010-02-17 22:38:31 -0800792 if (!wacom_wac->data) {
793 error = -ENOMEM;
794 goto fail1;
795 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700796
797 wacom->irq = usb_alloc_urb(0, GFP_KERNEL);
Jason Childse33da8a2010-02-17 22:38:31 -0800798 if (!wacom->irq) {
799 error = -ENOMEM;
Ping Cheng3bea7332006-07-13 18:01:36 -0700800 goto fail2;
Jason Childse33da8a2010-02-17 22:38:31 -0800801 }
Ping Cheng3bea7332006-07-13 18:01:36 -0700802
803 wacom->usbdev = dev;
Oliver Neukume7224092008-04-15 01:31:57 -0400804 wacom->intf = intf;
805 mutex_init(&wacom->lock);
Ping Cheng3bea7332006-07-13 18:01:36 -0700806 usb_make_path(dev, wacom->phys, sizeof(wacom->phys));
807 strlcat(wacom->phys, "/input0", sizeof(wacom->phys));
808
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700809 wacom_wac->input = input_dev;
Ping Cheng3bea7332006-07-13 18:01:36 -0700810
Ping Cheng545f4e92008-11-24 11:44:27 -0500811 endpoint = &intf->cur_altsetting->endpoint[0].desc;
812
Ping Chengec67bbe2009-12-15 00:35:24 -0800813 /* Retrieve the physical and logical size for OEM devices */
814 error = wacom_retrieve_hid_descriptor(intf, features);
815 if (error)
Alexander Strakh4b6d4432011-02-11 00:44:41 -0800816 goto fail3;
Ping Cheng545f4e92008-11-24 11:44:27 -0500817
Henrik Rydbergbc73dd32010-09-05 12:26:16 -0700818 wacom_setup_device_quirks(features);
819
Ping Cheng49b764a2010-02-20 00:53:49 -0800820 strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name));
821
Henrik Rydbergbc73dd32010-09-05 12:26:16 -0700822 if (features->quirks & WACOM_QUIRK_MULTI_INPUT) {
Ping Cheng49b764a2010-02-20 00:53:49 -0800823 /* Append the device type to the name */
824 strlcat(wacom_wac->name,
825 features->device_type == BTN_TOOL_PEN ?
826 " Pen" : " Finger",
827 sizeof(wacom_wac->name));
Ping Cheng4492eff2010-03-19 22:18:15 -0700828
829 error = wacom_add_shared_data(wacom_wac, dev);
830 if (error)
831 goto fail3;
Ping Cheng49b764a2010-02-20 00:53:49 -0800832 }
833
834 input_dev->name = wacom_wac->name;
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700835 input_dev->dev.parent = &intf->dev;
836 input_dev->open = wacom_open;
837 input_dev->close = wacom_close;
838 usb_to_input_id(dev, &input_dev->id);
839 input_set_drvdata(input_dev, wacom);
Jason Childse33da8a2010-02-17 22:38:31 -0800840
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700841 wacom_setup_input_capabilities(input_dev, wacom_wac);
Ping Cheng3bea7332006-07-13 18:01:36 -0700842
Ping Cheng3bea7332006-07-13 18:01:36 -0700843 usb_fill_int_urb(wacom->irq, dev,
844 usb_rcvintpipe(dev, endpoint->bEndpointAddress),
Ping Chengec67bbe2009-12-15 00:35:24 -0800845 wacom_wac->data, features->pktlen,
Ping Cheng8d32e3a2006-09-26 13:34:47 -0700846 wacom_sys_irq, wacom, endpoint->bInterval);
Ping Cheng3bea7332006-07-13 18:01:36 -0700847 wacom->irq->transfer_dma = wacom->data_dma;
848 wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
849
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700850 error = wacom_initialize_leds(wacom);
Dmitry Torokhov50141862007-04-12 01:33:39 -0400851 if (error)
Ping Cheng4492eff2010-03-19 22:18:15 -0700852 goto fail4;
Ping Cheng3bea7332006-07-13 18:01:36 -0700853
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700854 error = input_register_device(input_dev);
855 if (error)
856 goto fail5;
857
Ping Chengec67bbe2009-12-15 00:35:24 -0800858 /* Note that if query fails it is not a hard failure */
859 wacom_query_tablet_data(intf, features);
Ping Cheng3bea7332006-07-13 18:01:36 -0700860
861 usb_set_intfdata(intf, wacom);
862 return 0;
863
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700864 fail5: wacom_destroy_leds(wacom);
Ping Cheng4492eff2010-03-19 22:18:15 -0700865 fail4: wacom_remove_shared_data(wacom_wac);
Dmitry Torokhov50141862007-04-12 01:33:39 -0400866 fail3: usb_free_urb(wacom->irq);
Daniel Mack997ea582010-04-12 13:17:25 +0200867 fail2: usb_free_coherent(dev, WACOM_PKGLEN_MAX, wacom_wac->data, wacom->data_dma);
Dmitry Torokhov50141862007-04-12 01:33:39 -0400868 fail1: input_free_device(input_dev);
Ping Cheng3bea7332006-07-13 18:01:36 -0700869 kfree(wacom);
Dmitry Torokhov50141862007-04-12 01:33:39 -0400870 return error;
Ping Cheng3bea7332006-07-13 18:01:36 -0700871}
872
873static void wacom_disconnect(struct usb_interface *intf)
874{
Oliver Neukume7224092008-04-15 01:31:57 -0400875 struct wacom *wacom = usb_get_intfdata(intf);
Ping Cheng3bea7332006-07-13 18:01:36 -0700876
877 usb_set_intfdata(intf, NULL);
Oliver Neukume7224092008-04-15 01:31:57 -0400878
879 usb_kill_urb(wacom->irq);
Dmitry Torokhov8da23fc2010-03-19 22:18:15 -0700880 input_unregister_device(wacom->wacom_wac.input);
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700881 wacom_destroy_leds(wacom);
Oliver Neukume7224092008-04-15 01:31:57 -0400882 usb_free_urb(wacom->irq);
Daniel Mack997ea582010-04-12 13:17:25 +0200883 usb_free_coherent(interface_to_usbdev(intf), WACOM_PKGLEN_MAX,
Dmitry Torokhov51269fe2010-03-19 22:18:15 -0700884 wacom->wacom_wac.data, wacom->data_dma);
885 wacom_remove_shared_data(&wacom->wacom_wac);
Oliver Neukume7224092008-04-15 01:31:57 -0400886 kfree(wacom);
887}
888
889static int wacom_suspend(struct usb_interface *intf, pm_message_t message)
890{
891 struct wacom *wacom = usb_get_intfdata(intf);
892
893 mutex_lock(&wacom->lock);
894 usb_kill_urb(wacom->irq);
895 mutex_unlock(&wacom->lock);
896
897 return 0;
898}
899
900static int wacom_resume(struct usb_interface *intf)
901{
902 struct wacom *wacom = usb_get_intfdata(intf);
Dmitry Torokhov51269fe2010-03-19 22:18:15 -0700903 struct wacom_features *features = &wacom->wacom_wac.features;
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700904 int rv = 0;
Oliver Neukume7224092008-04-15 01:31:57 -0400905
906 mutex_lock(&wacom->lock);
Ping Cheng38101472010-04-13 23:07:52 -0700907
908 /* switch to wacom mode first */
909 wacom_query_tablet_data(intf, features);
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700910 wacom_led_control(wacom);
Ping Cheng38101472010-04-13 23:07:52 -0700911
Eduard Hasenleithner5d7e7d42011-09-07 14:08:54 -0700912 if (wacom->open && usb_submit_urb(wacom->irq, GFP_NOIO) < 0)
913 rv = -EIO;
Ping Cheng38101472010-04-13 23:07:52 -0700914
Oliver Neukume7224092008-04-15 01:31:57 -0400915 mutex_unlock(&wacom->lock);
916
917 return rv;
918}
919
920static int wacom_reset_resume(struct usb_interface *intf)
921{
922 return wacom_resume(intf);
Ping Cheng3bea7332006-07-13 18:01:36 -0700923}
924
925static struct usb_driver wacom_driver = {
926 .name = "wacom",
Bastian Blankb036f6f2010-02-10 23:06:23 -0800927 .id_table = wacom_ids,
Ping Cheng3bea7332006-07-13 18:01:36 -0700928 .probe = wacom_probe,
929 .disconnect = wacom_disconnect,
Oliver Neukume7224092008-04-15 01:31:57 -0400930 .suspend = wacom_suspend,
931 .resume = wacom_resume,
932 .reset_resume = wacom_reset_resume,
933 .supports_autosuspend = 1,
Ping Cheng3bea7332006-07-13 18:01:36 -0700934};
935
936static int __init wacom_init(void)
937{
938 int result;
Bastian Blankb036f6f2010-02-10 23:06:23 -0800939
Ping Cheng3bea7332006-07-13 18:01:36 -0700940 result = usb_register(&wacom_driver);
941 if (result == 0)
Greg Kroah-Hartman899ef6e2008-08-18 13:21:04 -0700942 printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
943 DRIVER_DESC "\n");
Ping Cheng3bea7332006-07-13 18:01:36 -0700944 return result;
945}
946
947static void __exit wacom_exit(void)
948{
949 usb_deregister(&wacom_driver);
950}
951
952module_init(wacom_init);
953module_exit(wacom_exit);