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"
16 #include <linux/input/mt.h>
18 #define WAC_MSG_RETRIES 5
20 #define WAC_CMD_WL_LED_CONTROL 0x03
21 #define WAC_CMD_LED_CONTROL 0x20
22 #define WAC_CMD_ICON_START 0x21
23 #define WAC_CMD_ICON_XFER 0x23
24 #define WAC_CMD_ICON_BT_XFER 0x26
25 #define WAC_CMD_RETRIES 10
27 #define DEV_ATTR_RW_PERM (S_IRUGO | S_IWUSR | S_IWGRP)
28 #define DEV_ATTR_WO_PERM (S_IWUSR | S_IWGRP)
30 static int wacom_get_report(struct hid_device
*hdev
, u8 type
, u8
*buf
,
31 size_t size
, unsigned int retries
)
36 retval
= hid_hw_raw_request(hdev
, buf
[0], buf
, size
, type
,
38 } while ((retval
== -ETIMEDOUT
|| retval
== -EPIPE
) && --retries
);
43 static int wacom_set_report(struct hid_device
*hdev
, u8 type
, u8
*buf
,
44 size_t size
, unsigned int retries
)
49 retval
= hid_hw_raw_request(hdev
, buf
[0], buf
, size
, type
,
51 } while ((retval
== -ETIMEDOUT
|| retval
== -EPIPE
) && --retries
);
56 static int wacom_raw_event(struct hid_device
*hdev
, struct hid_report
*report
,
57 u8
*raw_data
, int size
)
59 struct wacom
*wacom
= hid_get_drvdata(hdev
);
61 if (size
> WACOM_PKGLEN_MAX
)
64 memcpy(wacom
->wacom_wac
.data
, raw_data
, size
);
66 wacom_wac_irq(&wacom
->wacom_wac
, size
);
71 static int wacom_open(struct input_dev
*dev
)
73 struct wacom
*wacom
= input_get_drvdata(dev
);
75 return hid_hw_open(wacom
->hdev
);
78 static void wacom_close(struct input_dev
*dev
)
80 struct wacom
*wacom
= input_get_drvdata(dev
);
82 hid_hw_close(wacom
->hdev
);
86 * Calculate the resolution of the X or Y axis using hidinput_calc_abs_res.
88 static int wacom_calc_hid_res(int logical_extents
, int physical_extents
,
89 unsigned unit
, int exponent
)
91 struct hid_field field
= {
92 .logical_maximum
= logical_extents
,
93 .physical_maximum
= physical_extents
,
95 .unit_exponent
= exponent
,
98 return hidinput_calc_abs_res(&field
, ABS_X
);
101 static void wacom_feature_mapping(struct hid_device
*hdev
,
102 struct hid_field
*field
, struct hid_usage
*usage
)
104 struct wacom
*wacom
= hid_get_drvdata(hdev
);
105 struct wacom_features
*features
= &wacom
->wacom_wac
.features
;
106 struct hid_data
*hid_data
= &wacom
->wacom_wac
.hid_data
;
110 switch (usage
->hid
) {
111 case HID_DG_CONTACTMAX
:
112 /* leave touch_max as is if predefined */
113 if (!features
->touch_max
) {
115 data
= kzalloc(2, GFP_KERNEL
);
118 data
[0] = field
->report
->id
;
119 ret
= wacom_get_report(hdev
, HID_FEATURE_REPORT
,
122 features
->touch_max
= data
[1];
126 case HID_DG_INPUTMODE
:
127 /* Ignore if value index is out of bounds. */
128 if (usage
->usage_index
>= field
->report_count
) {
129 dev_err(&hdev
->dev
, "HID_DG_INPUTMODE out of range\n");
133 hid_data
->inputmode
= field
->report
->id
;
134 hid_data
->inputmode_index
= usage
->usage_index
;
140 * Interface Descriptor of wacom devices can be incomplete and
141 * inconsistent so wacom_features table is used to store stylus
142 * device's packet lengths, various maximum values, and tablet
143 * resolution based on product ID's.
145 * For devices that contain 2 interfaces, wacom_features table is
146 * inaccurate for the touch interface. Since the Interface Descriptor
147 * for touch interfaces has pretty complete data, this function exists
148 * to query tablet for this missing information instead of hard coding in
149 * an additional table.
151 * A typical Interface Descriptor for a stylus will contain a
152 * boot mouse application collection that is not of interest and this
153 * function will ignore it.
155 * It also contains a digitizer application collection that also is not
156 * of interest since any information it contains would be duplicate
157 * of what is in wacom_features. Usually it defines a report of an array
158 * of bytes that could be used as max length of the stylus packet returned.
159 * If it happens to define a Digitizer-Stylus Physical Collection then
160 * the X and Y logical values contain valid data but it is ignored.
162 * A typical Interface Descriptor for a touch interface will contain a
163 * Digitizer-Finger Physical Collection which will define both logical
164 * X/Y maximum as well as the physical size of tablet. Since touch
165 * interfaces haven't supported pressure or distance, this is enough
166 * information to override invalid values in the wacom_features table.
168 * Intuos5 touch interface and 3rd gen Bamboo Touch do not contain useful
169 * data. We deal with them after returning from this function.
171 static void wacom_usage_mapping(struct hid_device
*hdev
,
172 struct hid_field
*field
, struct hid_usage
*usage
)
174 struct wacom
*wacom
= hid_get_drvdata(hdev
);
175 struct wacom_features
*features
= &wacom
->wacom_wac
.features
;
176 bool finger
= WACOM_FINGER_FIELD(field
);
177 bool pen
= WACOM_PEN_FIELD(field
);
180 * Requiring Stylus Usage will ignore boot mouse
181 * X/Y values and some cases of invalid Digitizer X/Y
182 * values commonly reported.
188 * Bamboo models do not support HID_DG_CONTACTMAX.
189 * And, Bamboo Pen only descriptor contains touch.
191 if (features
->type
!= BAMBOO_PT
) {
192 /* ISDv4 touch devices at least supports one touch point */
193 if (finger
&& !features
->touch_max
)
194 features
->touch_max
= 1;
197 switch (usage
->hid
) {
199 features
->x_max
= field
->logical_maximum
;
201 features
->device_type
= BTN_TOOL_FINGER
;
202 features
->x_phy
= field
->physical_maximum
;
203 if (features
->type
!= BAMBOO_PT
) {
204 features
->unit
= field
->unit
;
205 features
->unitExpo
= field
->unit_exponent
;
208 features
->device_type
= BTN_TOOL_PEN
;
212 features
->y_max
= field
->logical_maximum
;
214 features
->y_phy
= field
->physical_maximum
;
215 if (features
->type
!= BAMBOO_PT
) {
216 features
->unit
= field
->unit
;
217 features
->unitExpo
= field
->unit_exponent
;
221 case HID_DG_TIPPRESSURE
:
223 features
->pressure_max
= field
->logical_maximum
;
227 if (features
->type
== HID_GENERIC
)
228 wacom_wac_usage_mapping(hdev
, field
, usage
);
231 static void wacom_post_parse_hid(struct hid_device
*hdev
,
232 struct wacom_features
*features
)
234 struct wacom
*wacom
= hid_get_drvdata(hdev
);
235 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
237 if (features
->type
== HID_GENERIC
) {
238 /* Any last-minute generic device setup */
239 if (features
->touch_max
> 1) {
240 input_mt_init_slots(wacom_wac
->input
, wacom_wac
->features
.touch_max
,
246 static void wacom_parse_hid(struct hid_device
*hdev
,
247 struct wacom_features
*features
)
249 struct hid_report_enum
*rep_enum
;
250 struct hid_report
*hreport
;
253 /* check features first */
254 rep_enum
= &hdev
->report_enum
[HID_FEATURE_REPORT
];
255 list_for_each_entry(hreport
, &rep_enum
->report_list
, list
) {
256 for (i
= 0; i
< hreport
->maxfield
; i
++) {
257 /* Ignore if report count is out of bounds. */
258 if (hreport
->field
[i
]->report_count
< 1)
261 for (j
= 0; j
< hreport
->field
[i
]->maxusage
; j
++) {
262 wacom_feature_mapping(hdev
, hreport
->field
[i
],
263 hreport
->field
[i
]->usage
+ j
);
268 /* now check the input usages */
269 rep_enum
= &hdev
->report_enum
[HID_INPUT_REPORT
];
270 list_for_each_entry(hreport
, &rep_enum
->report_list
, list
) {
272 if (!hreport
->maxfield
)
275 for (i
= 0; i
< hreport
->maxfield
; i
++)
276 for (j
= 0; j
< hreport
->field
[i
]->maxusage
; j
++)
277 wacom_usage_mapping(hdev
, hreport
->field
[i
],
278 hreport
->field
[i
]->usage
+ j
);
281 wacom_post_parse_hid(hdev
, features
);
284 static int wacom_hid_set_device_mode(struct hid_device
*hdev
)
286 struct wacom
*wacom
= hid_get_drvdata(hdev
);
287 struct hid_data
*hid_data
= &wacom
->wacom_wac
.hid_data
;
288 struct hid_report
*r
;
289 struct hid_report_enum
*re
;
291 if (hid_data
->inputmode
< 0)
294 re
= &(hdev
->report_enum
[HID_FEATURE_REPORT
]);
295 r
= re
->report_id_hash
[hid_data
->inputmode
];
297 r
->field
[0]->value
[hid_data
->inputmode_index
] = 2;
298 hid_hw_request(hdev
, r
, HID_REQ_SET_REPORT
);
303 static int wacom_set_device_mode(struct hid_device
*hdev
, int report_id
,
304 int length
, int mode
)
306 unsigned char *rep_data
;
307 int error
= -ENOMEM
, limit
= 0;
309 rep_data
= kzalloc(length
, GFP_KERNEL
);
314 rep_data
[0] = report_id
;
317 error
= wacom_set_report(hdev
, HID_FEATURE_REPORT
, rep_data
,
320 error
= wacom_get_report(hdev
, HID_FEATURE_REPORT
,
321 rep_data
, length
, 1);
322 } while ((error
< 0 || rep_data
[1] != mode
) && limit
++ < WAC_MSG_RETRIES
);
326 return error
< 0 ? error
: 0;
329 static int wacom_bt_query_tablet_data(struct hid_device
*hdev
, u8 speed
,
330 struct wacom_features
*features
)
332 struct wacom
*wacom
= hid_get_drvdata(hdev
);
336 switch (features
->type
) {
340 ret
= wacom_set_report(hdev
, HID_FEATURE_REPORT
, rep_data
, 2,
344 rep_data
[0] = speed
== 0 ? 0x05 : 0x06;
347 ret
= wacom_set_report(hdev
, HID_FEATURE_REPORT
,
351 wacom
->wacom_wac
.bt_high_speed
= speed
;
357 * Note that if the raw queries fail, it's not a hard failure
358 * and it is safe to continue
360 hid_warn(hdev
, "failed to poke device, command %d, err %d\n",
365 wacom
->wacom_wac
.bt_features
&= ~0x20;
367 wacom
->wacom_wac
.bt_features
|= 0x20;
370 rep_data
[1] = wacom
->wacom_wac
.bt_features
;
372 ret
= wacom_set_report(hdev
, HID_FEATURE_REPORT
, rep_data
, 2,
375 wacom
->wacom_wac
.bt_high_speed
= speed
;
383 * Switch the tablet into its most-capable mode. Wacom tablets are
384 * typically configured to power-up in a mode which sends mouse-like
385 * reports to the OS. To get absolute position, pressure data, etc.
386 * from the tablet, it is necessary to switch the tablet out of this
387 * mode and into one which sends the full range of tablet data.
389 static int wacom_query_tablet_data(struct hid_device
*hdev
,
390 struct wacom_features
*features
)
392 if (hdev
->bus
== BUS_BLUETOOTH
)
393 return wacom_bt_query_tablet_data(hdev
, 1, features
);
395 if (features
->type
== HID_GENERIC
)
396 return wacom_hid_set_device_mode(hdev
);
398 if (features
->device_type
== BTN_TOOL_FINGER
) {
399 if (features
->type
> TABLETPC
) {
400 /* MT Tablet PC touch */
401 return wacom_set_device_mode(hdev
, 3, 4, 4);
403 else if (features
->type
== WACOM_24HDT
|| features
->type
== CINTIQ_HYBRID
) {
404 return wacom_set_device_mode(hdev
, 18, 3, 2);
406 else if (features
->type
== WACOM_27QHDT
) {
407 return wacom_set_device_mode(hdev
, 131, 3, 2);
409 } else if (features
->device_type
== BTN_TOOL_PEN
) {
410 if (features
->type
<= BAMBOO_PT
&& features
->type
!= WIRELESS
) {
411 return wacom_set_device_mode(hdev
, 2, 2, 2);
418 static void wacom_retrieve_hid_descriptor(struct hid_device
*hdev
,
419 struct wacom_features
*features
)
421 struct wacom
*wacom
= hid_get_drvdata(hdev
);
422 struct usb_interface
*intf
= wacom
->intf
;
424 /* default features */
425 features
->device_type
= BTN_TOOL_PEN
;
426 features
->x_fuzz
= 4;
427 features
->y_fuzz
= 4;
428 features
->pressure_fuzz
= 0;
429 features
->distance_fuzz
= 0;
432 * The wireless device HID is basic and layout conflicts with
433 * other tablets (monitor and touch interface can look like pen).
434 * Skip the query for this type and modify defaults based on
437 if (features
->type
== WIRELESS
) {
438 if (intf
->cur_altsetting
->desc
.bInterfaceNumber
== 0) {
439 features
->device_type
= 0;
440 } else if (intf
->cur_altsetting
->desc
.bInterfaceNumber
== 2) {
441 features
->device_type
= BTN_TOOL_FINGER
;
442 features
->pktlen
= WACOM_PKGLEN_BBTOUCH3
;
446 /* only devices that support touch need to retrieve the info */
447 if (features
->type
< BAMBOO_PT
)
450 wacom_parse_hid(hdev
, features
);
453 struct wacom_hdev_data
{
454 struct list_head list
;
456 struct hid_device
*dev
;
457 struct wacom_shared shared
;
460 static LIST_HEAD(wacom_udev_list
);
461 static DEFINE_MUTEX(wacom_udev_list_lock
);
463 static bool wacom_are_sibling(struct hid_device
*hdev
,
464 struct hid_device
*sibling
)
466 struct wacom
*wacom
= hid_get_drvdata(hdev
);
467 struct wacom_features
*features
= &wacom
->wacom_wac
.features
;
468 int vid
= features
->oVid
;
469 int pid
= features
->oPid
;
472 if (vid
== 0 && pid
== 0) {
477 if (vid
!= sibling
->vendor
|| pid
!= sibling
->product
)
480 /* Compare the physical path. */
481 n1
= strrchr(hdev
->phys
, '.') - hdev
->phys
;
482 n2
= strrchr(sibling
->phys
, '.') - sibling
->phys
;
483 if (n1
!= n2
|| n1
<= 0 || n2
<= 0)
486 return !strncmp(hdev
->phys
, sibling
->phys
, n1
);
489 static struct wacom_hdev_data
*wacom_get_hdev_data(struct hid_device
*hdev
)
491 struct wacom_hdev_data
*data
;
493 list_for_each_entry(data
, &wacom_udev_list
, list
) {
494 if (wacom_are_sibling(hdev
, data
->dev
)) {
495 kref_get(&data
->kref
);
503 static int wacom_add_shared_data(struct hid_device
*hdev
)
505 struct wacom
*wacom
= hid_get_drvdata(hdev
);
506 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
507 struct wacom_hdev_data
*data
;
510 mutex_lock(&wacom_udev_list_lock
);
512 data
= wacom_get_hdev_data(hdev
);
514 data
= kzalloc(sizeof(struct wacom_hdev_data
), GFP_KERNEL
);
520 kref_init(&data
->kref
);
522 list_add_tail(&data
->list
, &wacom_udev_list
);
525 wacom_wac
->shared
= &data
->shared
;
528 mutex_unlock(&wacom_udev_list_lock
);
532 static void wacom_release_shared_data(struct kref
*kref
)
534 struct wacom_hdev_data
*data
=
535 container_of(kref
, struct wacom_hdev_data
, kref
);
537 mutex_lock(&wacom_udev_list_lock
);
538 list_del(&data
->list
);
539 mutex_unlock(&wacom_udev_list_lock
);
544 static void wacom_remove_shared_data(struct wacom_wac
*wacom
)
546 struct wacom_hdev_data
*data
;
549 data
= container_of(wacom
->shared
, struct wacom_hdev_data
, shared
);
550 kref_put(&data
->kref
, wacom_release_shared_data
);
551 wacom
->shared
= NULL
;
555 static int wacom_led_control(struct wacom
*wacom
)
559 unsigned char report_id
= WAC_CMD_LED_CONTROL
;
562 if (wacom
->wacom_wac
.pid
) { /* wireless connected */
563 report_id
= WAC_CMD_WL_LED_CONTROL
;
566 buf
= kzalloc(buf_size
, GFP_KERNEL
);
570 if (wacom
->wacom_wac
.features
.type
>= INTUOS5S
&&
571 wacom
->wacom_wac
.features
.type
<= INTUOSPL
) {
573 * Touch Ring and crop mark LED luminance may take on
574 * one of four values:
575 * 0 = Low; 1 = Medium; 2 = High; 3 = Off
577 int ring_led
= wacom
->led
.select
[0] & 0x03;
578 int ring_lum
= (((wacom
->led
.llv
& 0x60) >> 5) - 1) & 0x03;
580 unsigned char led_bits
= (crop_lum
<< 4) | (ring_lum
<< 2) | (ring_led
);
583 if (wacom
->wacom_wac
.pid
) {
584 wacom_get_report(wacom
->hdev
, HID_FEATURE_REPORT
,
585 buf
, buf_size
, WAC_CMD_RETRIES
);
592 int led
= wacom
->led
.select
[0] | 0x4;
594 if (wacom
->wacom_wac
.features
.type
== WACOM_21UX2
||
595 wacom
->wacom_wac
.features
.type
== WACOM_24HD
)
596 led
|= (wacom
->led
.select
[1] << 4) | 0x40;
600 buf
[2] = wacom
->led
.llv
;
601 buf
[3] = wacom
->led
.hlv
;
602 buf
[4] = wacom
->led
.img_lum
;
605 retval
= wacom_set_report(wacom
->hdev
, HID_FEATURE_REPORT
, buf
, buf_size
,
612 static int wacom_led_putimage(struct wacom
*wacom
, int button_id
, u8 xfer_id
,
613 const unsigned len
, const void *img
)
617 const unsigned chunk_len
= len
/ 4; /* 4 chunks are needed to be sent */
619 buf
= kzalloc(chunk_len
+ 3 , GFP_KERNEL
);
623 /* Send 'start' command */
624 buf
[0] = WAC_CMD_ICON_START
;
626 retval
= wacom_set_report(wacom
->hdev
, HID_FEATURE_REPORT
, buf
, 2,
632 buf
[1] = button_id
& 0x07;
633 for (i
= 0; i
< 4; i
++) {
635 memcpy(buf
+ 3, img
+ i
* chunk_len
, chunk_len
);
637 retval
= wacom_set_report(wacom
->hdev
, HID_FEATURE_REPORT
,
638 buf
, chunk_len
+ 3, WAC_CMD_RETRIES
);
644 buf
[0] = WAC_CMD_ICON_START
;
646 wacom_set_report(wacom
->hdev
, HID_FEATURE_REPORT
, buf
, 2,
654 static ssize_t
wacom_led_select_store(struct device
*dev
, int set_id
,
655 const char *buf
, size_t count
)
657 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
658 struct wacom
*wacom
= hid_get_drvdata(hdev
);
662 err
= kstrtouint(buf
, 10, &id
);
666 mutex_lock(&wacom
->lock
);
668 wacom
->led
.select
[set_id
] = id
& 0x3;
669 err
= wacom_led_control(wacom
);
671 mutex_unlock(&wacom
->lock
);
673 return err
< 0 ? err
: count
;
676 #define DEVICE_LED_SELECT_ATTR(SET_ID) \
677 static ssize_t wacom_led##SET_ID##_select_store(struct device *dev, \
678 struct device_attribute *attr, const char *buf, size_t count) \
680 return wacom_led_select_store(dev, SET_ID, buf, count); \
682 static ssize_t wacom_led##SET_ID##_select_show(struct device *dev, \
683 struct device_attribute *attr, char *buf) \
685 struct hid_device *hdev = container_of(dev, struct hid_device, dev);\
686 struct wacom *wacom = hid_get_drvdata(hdev); \
687 return scnprintf(buf, PAGE_SIZE, "%d\n", \
688 wacom->led.select[SET_ID]); \
690 static DEVICE_ATTR(status_led##SET_ID##_select, DEV_ATTR_RW_PERM, \
691 wacom_led##SET_ID##_select_show, \
692 wacom_led##SET_ID##_select_store)
694 DEVICE_LED_SELECT_ATTR(0);
695 DEVICE_LED_SELECT_ATTR(1);
697 static ssize_t
wacom_luminance_store(struct wacom
*wacom
, u8
*dest
,
698 const char *buf
, size_t count
)
703 err
= kstrtouint(buf
, 10, &value
);
707 mutex_lock(&wacom
->lock
);
709 *dest
= value
& 0x7f;
710 err
= wacom_led_control(wacom
);
712 mutex_unlock(&wacom
->lock
);
714 return err
< 0 ? err
: count
;
717 #define DEVICE_LUMINANCE_ATTR(name, field) \
718 static ssize_t wacom_##name##_luminance_store(struct device *dev, \
719 struct device_attribute *attr, const char *buf, size_t count) \
721 struct hid_device *hdev = container_of(dev, struct hid_device, dev);\
722 struct wacom *wacom = hid_get_drvdata(hdev); \
724 return wacom_luminance_store(wacom, &wacom->led.field, \
727 static ssize_t wacom_##name##_luminance_show(struct device *dev, \
728 struct device_attribute *attr, char *buf) \
730 struct wacom *wacom = dev_get_drvdata(dev); \
731 return scnprintf(buf, PAGE_SIZE, "%d\n", wacom->led.field); \
733 static DEVICE_ATTR(name##_luminance, DEV_ATTR_RW_PERM, \
734 wacom_##name##_luminance_show, \
735 wacom_##name##_luminance_store)
737 DEVICE_LUMINANCE_ATTR(status0
, llv
);
738 DEVICE_LUMINANCE_ATTR(status1
, hlv
);
739 DEVICE_LUMINANCE_ATTR(buttons
, img_lum
);
741 static ssize_t
wacom_button_image_store(struct device
*dev
, int button_id
,
742 const char *buf
, size_t count
)
744 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
745 struct wacom
*wacom
= hid_get_drvdata(hdev
);
750 if (hdev
->bus
== BUS_BLUETOOTH
) {
752 xfer_id
= WAC_CMD_ICON_BT_XFER
;
755 xfer_id
= WAC_CMD_ICON_XFER
;
761 mutex_lock(&wacom
->lock
);
763 err
= wacom_led_putimage(wacom
, button_id
, xfer_id
, len
, buf
);
765 mutex_unlock(&wacom
->lock
);
767 return err
< 0 ? err
: count
;
770 #define DEVICE_BTNIMG_ATTR(BUTTON_ID) \
771 static ssize_t wacom_btnimg##BUTTON_ID##_store(struct device *dev, \
772 struct device_attribute *attr, const char *buf, size_t count) \
774 return wacom_button_image_store(dev, BUTTON_ID, buf, count); \
776 static DEVICE_ATTR(button##BUTTON_ID##_rawimg, DEV_ATTR_WO_PERM, \
777 NULL, wacom_btnimg##BUTTON_ID##_store)
779 DEVICE_BTNIMG_ATTR(0);
780 DEVICE_BTNIMG_ATTR(1);
781 DEVICE_BTNIMG_ATTR(2);
782 DEVICE_BTNIMG_ATTR(3);
783 DEVICE_BTNIMG_ATTR(4);
784 DEVICE_BTNIMG_ATTR(5);
785 DEVICE_BTNIMG_ATTR(6);
786 DEVICE_BTNIMG_ATTR(7);
788 static struct attribute
*cintiq_led_attrs
[] = {
789 &dev_attr_status_led0_select
.attr
,
790 &dev_attr_status_led1_select
.attr
,
794 static struct attribute_group cintiq_led_attr_group
= {
796 .attrs
= cintiq_led_attrs
,
799 static struct attribute
*intuos4_led_attrs
[] = {
800 &dev_attr_status0_luminance
.attr
,
801 &dev_attr_status1_luminance
.attr
,
802 &dev_attr_status_led0_select
.attr
,
803 &dev_attr_buttons_luminance
.attr
,
804 &dev_attr_button0_rawimg
.attr
,
805 &dev_attr_button1_rawimg
.attr
,
806 &dev_attr_button2_rawimg
.attr
,
807 &dev_attr_button3_rawimg
.attr
,
808 &dev_attr_button4_rawimg
.attr
,
809 &dev_attr_button5_rawimg
.attr
,
810 &dev_attr_button6_rawimg
.attr
,
811 &dev_attr_button7_rawimg
.attr
,
815 static struct attribute_group intuos4_led_attr_group
= {
817 .attrs
= intuos4_led_attrs
,
820 static struct attribute
*intuos5_led_attrs
[] = {
821 &dev_attr_status0_luminance
.attr
,
822 &dev_attr_status_led0_select
.attr
,
826 static struct attribute_group intuos5_led_attr_group
= {
828 .attrs
= intuos5_led_attrs
,
831 static int wacom_initialize_leds(struct wacom
*wacom
)
835 /* Initialize default values */
836 switch (wacom
->wacom_wac
.features
.type
) {
841 wacom
->led
.select
[0] = 0;
842 wacom
->led
.select
[1] = 0;
845 wacom
->led
.img_lum
= 10;
846 error
= sysfs_create_group(&wacom
->hdev
->dev
.kobj
,
847 &intuos4_led_attr_group
);
852 wacom
->led
.select
[0] = 0;
853 wacom
->led
.select
[1] = 0;
856 wacom
->led
.img_lum
= 0;
858 error
= sysfs_create_group(&wacom
->hdev
->dev
.kobj
,
859 &cintiq_led_attr_group
);
868 if (wacom
->wacom_wac
.features
.device_type
== BTN_TOOL_PEN
) {
869 wacom
->led
.select
[0] = 0;
870 wacom
->led
.select
[1] = 0;
873 wacom
->led
.img_lum
= 0;
875 error
= sysfs_create_group(&wacom
->hdev
->dev
.kobj
,
876 &intuos5_led_attr_group
);
887 "cannot create sysfs group err: %d\n", error
);
890 wacom_led_control(wacom
);
891 wacom
->led_initialized
= true;
896 static void wacom_destroy_leds(struct wacom
*wacom
)
898 if (!wacom
->led_initialized
)
901 wacom
->led_initialized
= false;
903 switch (wacom
->wacom_wac
.features
.type
) {
908 sysfs_remove_group(&wacom
->hdev
->dev
.kobj
,
909 &intuos4_led_attr_group
);
914 sysfs_remove_group(&wacom
->hdev
->dev
.kobj
,
915 &cintiq_led_attr_group
);
924 if (wacom
->wacom_wac
.features
.device_type
== BTN_TOOL_PEN
)
925 sysfs_remove_group(&wacom
->hdev
->dev
.kobj
,
926 &intuos5_led_attr_group
);
931 static enum power_supply_property wacom_battery_props
[] = {
932 POWER_SUPPLY_PROP_STATUS
,
933 POWER_SUPPLY_PROP_SCOPE
,
934 POWER_SUPPLY_PROP_CAPACITY
937 static enum power_supply_property wacom_ac_props
[] = {
938 POWER_SUPPLY_PROP_PRESENT
,
939 POWER_SUPPLY_PROP_ONLINE
,
940 POWER_SUPPLY_PROP_SCOPE
,
943 static int wacom_battery_get_property(struct power_supply
*psy
,
944 enum power_supply_property psp
,
945 union power_supply_propval
*val
)
947 struct wacom
*wacom
= power_supply_get_drvdata(psy
);
951 case POWER_SUPPLY_PROP_SCOPE
:
952 val
->intval
= POWER_SUPPLY_SCOPE_DEVICE
;
954 case POWER_SUPPLY_PROP_CAPACITY
:
956 wacom
->wacom_wac
.battery_capacity
;
958 case POWER_SUPPLY_PROP_STATUS
:
959 if (wacom
->wacom_wac
.bat_charging
)
960 val
->intval
= POWER_SUPPLY_STATUS_CHARGING
;
961 else if (wacom
->wacom_wac
.battery_capacity
== 100 &&
962 wacom
->wacom_wac
.ps_connected
)
963 val
->intval
= POWER_SUPPLY_STATUS_FULL
;
965 val
->intval
= POWER_SUPPLY_STATUS_DISCHARGING
;
975 static int wacom_ac_get_property(struct power_supply
*psy
,
976 enum power_supply_property psp
,
977 union power_supply_propval
*val
)
979 struct wacom
*wacom
= power_supply_get_drvdata(psy
);
983 case POWER_SUPPLY_PROP_PRESENT
:
985 case POWER_SUPPLY_PROP_ONLINE
:
986 val
->intval
= wacom
->wacom_wac
.ps_connected
;
988 case POWER_SUPPLY_PROP_SCOPE
:
989 val
->intval
= POWER_SUPPLY_SCOPE_DEVICE
;
998 static int wacom_initialize_battery(struct wacom
*wacom
)
1000 static atomic_t battery_no
= ATOMIC_INIT(0);
1001 struct power_supply_config psy_cfg
= { .drv_data
= wacom
, };
1004 if (wacom
->wacom_wac
.features
.quirks
& WACOM_QUIRK_BATTERY
) {
1005 struct power_supply_desc
*bat_desc
= &wacom
->battery_desc
;
1006 struct power_supply_desc
*ac_desc
= &wacom
->ac_desc
;
1007 n
= atomic_inc_return(&battery_no
) - 1;
1009 bat_desc
->properties
= wacom_battery_props
;
1010 bat_desc
->num_properties
= ARRAY_SIZE(wacom_battery_props
);
1011 bat_desc
->get_property
= wacom_battery_get_property
;
1012 sprintf(wacom
->wacom_wac
.bat_name
, "wacom_battery_%ld", n
);
1013 bat_desc
->name
= wacom
->wacom_wac
.bat_name
;
1014 bat_desc
->type
= POWER_SUPPLY_TYPE_BATTERY
;
1015 bat_desc
->use_for_apm
= 0;
1017 ac_desc
->properties
= wacom_ac_props
;
1018 ac_desc
->num_properties
= ARRAY_SIZE(wacom_ac_props
);
1019 ac_desc
->get_property
= wacom_ac_get_property
;
1020 sprintf(wacom
->wacom_wac
.ac_name
, "wacom_ac_%ld", n
);
1021 ac_desc
->name
= wacom
->wacom_wac
.ac_name
;
1022 ac_desc
->type
= POWER_SUPPLY_TYPE_MAINS
;
1023 ac_desc
->use_for_apm
= 0;
1025 wacom
->battery
= power_supply_register(&wacom
->hdev
->dev
,
1026 &wacom
->battery_desc
, &psy_cfg
);
1027 if (IS_ERR(wacom
->battery
))
1028 return PTR_ERR(wacom
->battery
);
1030 power_supply_powers(wacom
->battery
, &wacom
->hdev
->dev
);
1032 wacom
->ac
= power_supply_register(&wacom
->hdev
->dev
,
1035 if (IS_ERR(wacom
->ac
)) {
1036 power_supply_unregister(wacom
->battery
);
1037 return PTR_ERR(wacom
->ac
);
1040 power_supply_powers(wacom
->ac
, &wacom
->hdev
->dev
);
1046 static void wacom_destroy_battery(struct wacom
*wacom
)
1048 if ((wacom
->wacom_wac
.features
.quirks
& WACOM_QUIRK_BATTERY
) &&
1050 power_supply_unregister(wacom
->battery
);
1051 wacom
->battery
= NULL
;
1052 power_supply_unregister(wacom
->ac
);
1057 static ssize_t
wacom_show_speed(struct device
*dev
,
1058 struct device_attribute
1061 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
1062 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1064 return snprintf(buf
, PAGE_SIZE
, "%i\n", wacom
->wacom_wac
.bt_high_speed
);
1067 static ssize_t
wacom_store_speed(struct device
*dev
,
1068 struct device_attribute
*attr
,
1069 const char *buf
, size_t count
)
1071 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
1072 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1075 if (kstrtou8(buf
, 0, &new_speed
))
1078 if (new_speed
!= 0 && new_speed
!= 1)
1081 wacom_bt_query_tablet_data(hdev
, new_speed
, &wacom
->wacom_wac
.features
);
1086 static DEVICE_ATTR(speed
, DEV_ATTR_RW_PERM
,
1087 wacom_show_speed
, wacom_store_speed
);
1089 static struct input_dev
*wacom_allocate_input(struct wacom
*wacom
)
1091 struct input_dev
*input_dev
;
1092 struct hid_device
*hdev
= wacom
->hdev
;
1093 struct wacom_wac
*wacom_wac
= &(wacom
->wacom_wac
);
1095 input_dev
= input_allocate_device();
1099 input_dev
->name
= wacom_wac
->name
;
1100 input_dev
->phys
= hdev
->phys
;
1101 input_dev
->dev
.parent
= &hdev
->dev
;
1102 input_dev
->open
= wacom_open
;
1103 input_dev
->close
= wacom_close
;
1104 input_dev
->uniq
= hdev
->uniq
;
1105 input_dev
->id
.bustype
= hdev
->bus
;
1106 input_dev
->id
.vendor
= hdev
->vendor
;
1107 input_dev
->id
.product
= wacom_wac
->pid
? wacom_wac
->pid
: hdev
->product
;
1108 input_dev
->id
.version
= hdev
->version
;
1109 input_set_drvdata(input_dev
, wacom
);
1114 static void wacom_free_inputs(struct wacom
*wacom
)
1116 struct wacom_wac
*wacom_wac
= &(wacom
->wacom_wac
);
1118 if (wacom_wac
->input
)
1119 input_free_device(wacom_wac
->input
);
1120 if (wacom_wac
->pad_input
)
1121 input_free_device(wacom_wac
->pad_input
);
1122 wacom_wac
->input
= NULL
;
1123 wacom_wac
->pad_input
= NULL
;
1126 static int wacom_allocate_inputs(struct wacom
*wacom
)
1128 struct input_dev
*input_dev
, *pad_input_dev
;
1129 struct wacom_wac
*wacom_wac
= &(wacom
->wacom_wac
);
1131 input_dev
= wacom_allocate_input(wacom
);
1132 pad_input_dev
= wacom_allocate_input(wacom
);
1133 if (!input_dev
|| !pad_input_dev
) {
1134 wacom_free_inputs(wacom
);
1138 wacom_wac
->input
= input_dev
;
1139 wacom_wac
->pad_input
= pad_input_dev
;
1140 wacom_wac
->pad_input
->name
= wacom_wac
->pad_name
;
1145 static void wacom_clean_inputs(struct wacom
*wacom
)
1147 if (wacom
->wacom_wac
.input
) {
1148 if (wacom
->wacom_wac
.input_registered
)
1149 input_unregister_device(wacom
->wacom_wac
.input
);
1151 input_free_device(wacom
->wacom_wac
.input
);
1153 if (wacom
->wacom_wac
.pad_input
) {
1154 if (wacom
->wacom_wac
.pad_registered
)
1155 input_unregister_device(wacom
->wacom_wac
.pad_input
);
1157 input_free_device(wacom
->wacom_wac
.pad_input
);
1159 wacom
->wacom_wac
.input
= NULL
;
1160 wacom
->wacom_wac
.pad_input
= NULL
;
1161 wacom_destroy_leds(wacom
);
1164 static int wacom_register_inputs(struct wacom
*wacom
)
1166 struct input_dev
*input_dev
, *pad_input_dev
;
1167 struct wacom_wac
*wacom_wac
= &(wacom
->wacom_wac
);
1170 input_dev
= wacom_wac
->input
;
1171 pad_input_dev
= wacom_wac
->pad_input
;
1173 if (!input_dev
|| !pad_input_dev
)
1176 error
= wacom_setup_pentouch_input_capabilities(input_dev
, wacom_wac
);
1178 error
= input_register_device(input_dev
);
1181 wacom_wac
->input_registered
= true;
1184 error
= wacom_setup_pad_input_capabilities(pad_input_dev
, wacom_wac
);
1186 /* no pad in use on this interface */
1187 input_free_device(pad_input_dev
);
1188 wacom_wac
->pad_input
= NULL
;
1189 pad_input_dev
= NULL
;
1191 error
= input_register_device(pad_input_dev
);
1193 goto fail_register_pad_input
;
1194 wacom_wac
->pad_registered
= true;
1196 error
= wacom_initialize_leds(wacom
);
1204 input_unregister_device(pad_input_dev
);
1205 pad_input_dev
= NULL
;
1206 wacom_wac
->pad_registered
= false;
1207 fail_register_pad_input
:
1208 input_unregister_device(input_dev
);
1209 wacom_wac
->input
= NULL
;
1210 wacom_wac
->input_registered
= false;
1214 static void wacom_wireless_work(struct work_struct
*work
)
1216 struct wacom
*wacom
= container_of(work
, struct wacom
, work
);
1217 struct usb_device
*usbdev
= wacom
->usbdev
;
1218 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1219 struct hid_device
*hdev1
, *hdev2
;
1220 struct wacom
*wacom1
, *wacom2
;
1221 struct wacom_wac
*wacom_wac1
, *wacom_wac2
;
1225 * Regardless if this is a disconnect or a new tablet,
1226 * remove any existing input and battery devices.
1229 wacom_destroy_battery(wacom
);
1231 /* Stylus interface */
1232 hdev1
= usb_get_intfdata(usbdev
->config
->interface
[1]);
1233 wacom1
= hid_get_drvdata(hdev1
);
1234 wacom_wac1
= &(wacom1
->wacom_wac
);
1235 wacom_clean_inputs(wacom1
);
1237 /* Touch interface */
1238 hdev2
= usb_get_intfdata(usbdev
->config
->interface
[2]);
1239 wacom2
= hid_get_drvdata(hdev2
);
1240 wacom_wac2
= &(wacom2
->wacom_wac
);
1241 wacom_clean_inputs(wacom2
);
1243 if (wacom_wac
->pid
== 0) {
1244 hid_info(wacom
->hdev
, "wireless tablet disconnected\n");
1245 wacom_wac1
->shared
->type
= 0;
1247 const struct hid_device_id
*id
= wacom_ids
;
1249 hid_info(wacom
->hdev
, "wireless tablet connected with PID %x\n",
1253 if (id
->vendor
== USB_VENDOR_ID_WACOM
&&
1254 id
->product
== wacom_wac
->pid
)
1260 hid_info(wacom
->hdev
, "ignoring unknown PID.\n");
1264 /* Stylus interface */
1265 wacom_wac1
->features
=
1266 *((struct wacom_features
*)id
->driver_data
);
1267 wacom_wac1
->features
.device_type
= BTN_TOOL_PEN
;
1268 snprintf(wacom_wac1
->name
, WACOM_NAME_MAX
, "%s (WL) Pen",
1269 wacom_wac1
->features
.name
);
1270 snprintf(wacom_wac1
->pad_name
, WACOM_NAME_MAX
, "%s (WL) Pad",
1271 wacom_wac1
->features
.name
);
1272 wacom_wac1
->shared
->touch_max
= wacom_wac1
->features
.touch_max
;
1273 wacom_wac1
->shared
->type
= wacom_wac1
->features
.type
;
1274 wacom_wac1
->pid
= wacom_wac
->pid
;
1275 error
= wacom_allocate_inputs(wacom1
) ||
1276 wacom_register_inputs(wacom1
);
1280 /* Touch interface */
1281 if (wacom_wac1
->features
.touch_max
||
1282 wacom_wac1
->features
.type
== INTUOSHT
) {
1283 wacom_wac2
->features
=
1284 *((struct wacom_features
*)id
->driver_data
);
1285 wacom_wac2
->features
.pktlen
= WACOM_PKGLEN_BBTOUCH3
;
1286 wacom_wac2
->features
.device_type
= BTN_TOOL_FINGER
;
1287 wacom_wac2
->features
.x_max
= wacom_wac2
->features
.y_max
= 4096;
1288 if (wacom_wac2
->features
.touch_max
)
1289 snprintf(wacom_wac2
->name
, WACOM_NAME_MAX
,
1290 "%s (WL) Finger",wacom_wac2
->features
.name
);
1292 snprintf(wacom_wac2
->name
, WACOM_NAME_MAX
,
1293 "%s (WL) Pad",wacom_wac2
->features
.name
);
1294 snprintf(wacom_wac2
->pad_name
, WACOM_NAME_MAX
,
1295 "%s (WL) Pad", wacom_wac2
->features
.name
);
1296 wacom_wac2
->pid
= wacom_wac
->pid
;
1297 error
= wacom_allocate_inputs(wacom2
) ||
1298 wacom_register_inputs(wacom2
);
1302 if (wacom_wac1
->features
.type
== INTUOSHT
&&
1303 wacom_wac1
->features
.touch_max
)
1304 wacom_wac
->shared
->touch_input
= wacom_wac2
->input
;
1307 error
= wacom_initialize_battery(wacom
);
1315 wacom_clean_inputs(wacom1
);
1316 wacom_clean_inputs(wacom2
);
1321 * Not all devices report physical dimensions from HID.
1322 * Compute the default from hardcoded logical dimension
1323 * and resolution before driver overwrites them.
1325 static void wacom_set_default_phy(struct wacom_features
*features
)
1327 if (features
->x_resolution
) {
1328 features
->x_phy
= (features
->x_max
* 100) /
1329 features
->x_resolution
;
1330 features
->y_phy
= (features
->y_max
* 100) /
1331 features
->y_resolution
;
1335 static void wacom_calculate_res(struct wacom_features
*features
)
1337 features
->x_resolution
= wacom_calc_hid_res(features
->x_max
,
1340 features
->unitExpo
);
1341 features
->y_resolution
= wacom_calc_hid_res(features
->y_max
,
1344 features
->unitExpo
);
1347 static size_t wacom_compute_pktlen(struct hid_device
*hdev
)
1349 struct hid_report_enum
*report_enum
;
1350 struct hid_report
*report
;
1353 report_enum
= hdev
->report_enum
+ HID_INPUT_REPORT
;
1355 list_for_each_entry(report
, &report_enum
->report_list
, list
) {
1356 size_t report_size
= hid_report_len(report
);
1357 if (report_size
> size
)
1364 static int wacom_probe(struct hid_device
*hdev
,
1365 const struct hid_device_id
*id
)
1367 struct usb_interface
*intf
= to_usb_interface(hdev
->dev
.parent
);
1368 struct usb_device
*dev
= interface_to_usbdev(intf
);
1369 struct wacom
*wacom
;
1370 struct wacom_wac
*wacom_wac
;
1371 struct wacom_features
*features
;
1373 unsigned int connect_mask
= HID_CONNECT_HIDRAW
;
1375 if (!id
->driver_data
)
1378 hdev
->quirks
|= HID_QUIRK_NO_INIT_REPORTS
;
1380 wacom
= kzalloc(sizeof(struct wacom
), GFP_KERNEL
);
1384 hid_set_drvdata(hdev
, wacom
);
1387 /* ask for the report descriptor to be loaded by HID */
1388 error
= hid_parse(hdev
);
1390 hid_err(hdev
, "parse failed\n");
1394 wacom_wac
= &wacom
->wacom_wac
;
1395 wacom_wac
->features
= *((struct wacom_features
*)id
->driver_data
);
1396 features
= &wacom_wac
->features
;
1397 features
->pktlen
= wacom_compute_pktlen(hdev
);
1398 if (features
->pktlen
> WACOM_PKGLEN_MAX
) {
1403 if (features
->check_for_hid_type
&& features
->hid_type
!= hdev
->type
) {
1408 wacom
->usbdev
= dev
;
1410 mutex_init(&wacom
->lock
);
1411 INIT_WORK(&wacom
->work
, wacom_wireless_work
);
1413 if (!(features
->quirks
& WACOM_QUIRK_NO_INPUT
)) {
1414 error
= wacom_allocate_inputs(wacom
);
1416 goto fail_allocate_inputs
;
1419 /* set the default size in case we do not get them from hid */
1420 wacom_set_default_phy(features
);
1422 /* Retrieve the physical and logical size for touch devices */
1423 wacom_retrieve_hid_descriptor(hdev
, features
);
1426 * Intuos5 has no useful data about its touch interface in its
1427 * HID descriptor. If this is the touch interface (PacketSize
1428 * of WACOM_PKGLEN_BBTOUCH3), override the table values.
1430 if (features
->type
>= INTUOS5S
&& features
->type
<= INTUOSHT
) {
1431 if (features
->pktlen
== WACOM_PKGLEN_BBTOUCH3
) {
1432 features
->device_type
= BTN_TOOL_FINGER
;
1434 features
->x_max
= 4096;
1435 features
->y_max
= 4096;
1437 features
->device_type
= BTN_TOOL_PEN
;
1442 * Same thing for Bamboo 3rd gen.
1444 if ((features
->type
== BAMBOO_PT
) &&
1445 (features
->pktlen
== WACOM_PKGLEN_BBTOUCH3
) &&
1446 (features
->device_type
== BTN_TOOL_PEN
)) {
1447 features
->device_type
= BTN_TOOL_FINGER
;
1449 features
->x_max
= 4096;
1450 features
->y_max
= 4096;
1453 if (hdev
->bus
== BUS_BLUETOOTH
)
1454 features
->quirks
|= WACOM_QUIRK_BATTERY
;
1456 wacom_setup_device_quirks(features
);
1458 /* set unit to "100th of a mm" for devices not reported by HID */
1459 if (!features
->unit
) {
1460 features
->unit
= 0x11;
1461 features
->unitExpo
= -3;
1463 wacom_calculate_res(features
);
1465 strlcpy(wacom_wac
->name
, features
->name
, sizeof(wacom_wac
->name
));
1466 snprintf(wacom_wac
->pad_name
, sizeof(wacom_wac
->pad_name
),
1467 "%s Pad", features
->name
);
1469 if (features
->quirks
& WACOM_QUIRK_MULTI_INPUT
) {
1470 /* Append the device type to the name */
1471 if (features
->device_type
!= BTN_TOOL_FINGER
)
1472 strlcat(wacom_wac
->name
, " Pen", WACOM_NAME_MAX
);
1473 else if (features
->touch_max
)
1474 strlcat(wacom_wac
->name
, " Finger", WACOM_NAME_MAX
);
1476 strlcat(wacom_wac
->name
, " Pad", WACOM_NAME_MAX
);
1478 error
= wacom_add_shared_data(hdev
);
1480 goto fail_shared_data
;
1483 if (!(features
->quirks
& WACOM_QUIRK_MONITOR
) &&
1484 (features
->quirks
& WACOM_QUIRK_BATTERY
)) {
1485 error
= wacom_initialize_battery(wacom
);
1490 if (!(features
->quirks
& WACOM_QUIRK_NO_INPUT
)) {
1491 error
= wacom_register_inputs(wacom
);
1493 goto fail_register_inputs
;
1496 if (hdev
->bus
== BUS_BLUETOOTH
) {
1497 error
= device_create_file(&hdev
->dev
, &dev_attr_speed
);
1500 "can't create sysfs speed attribute err: %d\n",
1504 if (features
->type
== HID_GENERIC
)
1505 connect_mask
|= HID_CONNECT_DRIVER
;
1507 /* Regular HID work starts now */
1508 error
= hid_hw_start(hdev
, connect_mask
);
1510 hid_err(hdev
, "hw start failed\n");
1514 /* Note that if query fails it is not a hard failure */
1515 wacom_query_tablet_data(hdev
, features
);
1517 if (features
->quirks
& WACOM_QUIRK_MONITOR
)
1518 error
= hid_hw_open(hdev
);
1520 if (wacom_wac
->features
.type
== INTUOSHT
&& wacom_wac
->features
.touch_max
) {
1521 if (wacom_wac
->features
.device_type
== BTN_TOOL_FINGER
)
1522 wacom_wac
->shared
->touch_input
= wacom_wac
->input
;
1528 if (hdev
->bus
== BUS_BLUETOOTH
)
1529 device_remove_file(&hdev
->dev
, &dev_attr_speed
);
1530 fail_register_inputs
:
1531 wacom_clean_inputs(wacom
);
1532 wacom_destroy_battery(wacom
);
1534 wacom_remove_shared_data(wacom_wac
);
1536 wacom_clean_inputs(wacom
);
1537 fail_allocate_inputs
:
1542 hid_set_drvdata(hdev
, NULL
);
1546 static void wacom_remove(struct hid_device
*hdev
)
1548 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1552 cancel_work_sync(&wacom
->work
);
1553 wacom_clean_inputs(wacom
);
1554 if (hdev
->bus
== BUS_BLUETOOTH
)
1555 device_remove_file(&hdev
->dev
, &dev_attr_speed
);
1556 wacom_destroy_battery(wacom
);
1557 wacom_remove_shared_data(&wacom
->wacom_wac
);
1559 hid_set_drvdata(hdev
, NULL
);
1564 static int wacom_resume(struct hid_device
*hdev
)
1566 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1567 struct wacom_features
*features
= &wacom
->wacom_wac
.features
;
1569 mutex_lock(&wacom
->lock
);
1571 /* switch to wacom mode first */
1572 wacom_query_tablet_data(hdev
, features
);
1573 wacom_led_control(wacom
);
1575 mutex_unlock(&wacom
->lock
);
1580 static int wacom_reset_resume(struct hid_device
*hdev
)
1582 return wacom_resume(hdev
);
1584 #endif /* CONFIG_PM */
1586 static struct hid_driver wacom_driver
= {
1588 .id_table
= wacom_ids
,
1589 .probe
= wacom_probe
,
1590 .remove
= wacom_remove
,
1591 .event
= wacom_wac_event
,
1592 .report
= wacom_wac_report
,
1594 .resume
= wacom_resume
,
1595 .reset_resume
= wacom_reset_resume
,
1597 .raw_event
= wacom_raw_event
,
1599 module_hid_driver(wacom_driver
);
1601 MODULE_VERSION(DRIVER_VERSION
);
1602 MODULE_AUTHOR(DRIVER_AUTHOR
);
1603 MODULE_DESCRIPTION(DRIVER_DESC
);
1604 MODULE_LICENSE(DRIVER_LICENSE
);