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
= (field
->logical
== HID_DG_FINGER
) ||
177 (field
->physical
== HID_DG_FINGER
);
178 bool pen
= (field
->logical
== HID_DG_STYLUS
) ||
179 (field
->physical
== HID_DG_STYLUS
);
182 * Requiring Stylus Usage will ignore boot mouse
183 * X/Y values and some cases of invalid Digitizer X/Y
184 * values commonly reported.
190 * Bamboo models do not support HID_DG_CONTACTMAX.
191 * And, Bamboo Pen only descriptor contains touch.
193 if (features
->type
!= BAMBOO_PT
) {
194 /* ISDv4 touch devices at least supports one touch point */
195 if (finger
&& !features
->touch_max
)
196 features
->touch_max
= 1;
199 switch (usage
->hid
) {
201 features
->x_max
= field
->logical_maximum
;
203 features
->device_type
= BTN_TOOL_FINGER
;
204 features
->x_phy
= field
->physical_maximum
;
205 if (features
->type
!= BAMBOO_PT
) {
206 features
->unit
= field
->unit
;
207 features
->unitExpo
= field
->unit_exponent
;
210 features
->device_type
= BTN_TOOL_PEN
;
214 features
->y_max
= field
->logical_maximum
;
216 features
->y_phy
= field
->physical_maximum
;
217 if (features
->type
!= BAMBOO_PT
) {
218 features
->unit
= field
->unit
;
219 features
->unitExpo
= field
->unit_exponent
;
223 case HID_DG_TIPPRESSURE
:
225 features
->pressure_max
= field
->logical_maximum
;
229 if (features
->type
== HID_GENERIC
)
230 wacom_wac_usage_mapping(hdev
, field
, usage
);
233 static void wacom_post_parse_hid(struct hid_device
*hdev
,
234 struct wacom_features
*features
)
236 struct wacom
*wacom
= hid_get_drvdata(hdev
);
237 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
239 if (features
->type
== HID_GENERIC
) {
240 /* Any last-minute generic device setup */
241 if (features
->touch_max
> 1) {
242 input_mt_init_slots(wacom_wac
->input
, wacom_wac
->features
.touch_max
,
248 static void wacom_parse_hid(struct hid_device
*hdev
,
249 struct wacom_features
*features
)
251 struct hid_report_enum
*rep_enum
;
252 struct hid_report
*hreport
;
255 /* check features first */
256 rep_enum
= &hdev
->report_enum
[HID_FEATURE_REPORT
];
257 list_for_each_entry(hreport
, &rep_enum
->report_list
, list
) {
258 for (i
= 0; i
< hreport
->maxfield
; i
++) {
259 /* Ignore if report count is out of bounds. */
260 if (hreport
->field
[i
]->report_count
< 1)
263 for (j
= 0; j
< hreport
->field
[i
]->maxusage
; j
++) {
264 wacom_feature_mapping(hdev
, hreport
->field
[i
],
265 hreport
->field
[i
]->usage
+ j
);
270 /* now check the input usages */
271 rep_enum
= &hdev
->report_enum
[HID_INPUT_REPORT
];
272 list_for_each_entry(hreport
, &rep_enum
->report_list
, list
) {
274 if (!hreport
->maxfield
)
277 for (i
= 0; i
< hreport
->maxfield
; i
++)
278 for (j
= 0; j
< hreport
->field
[i
]->maxusage
; j
++)
279 wacom_usage_mapping(hdev
, hreport
->field
[i
],
280 hreport
->field
[i
]->usage
+ j
);
283 wacom_post_parse_hid(hdev
, features
);
286 static int wacom_hid_set_device_mode(struct hid_device
*hdev
)
288 struct wacom
*wacom
= hid_get_drvdata(hdev
);
289 struct hid_data
*hid_data
= &wacom
->wacom_wac
.hid_data
;
290 struct hid_report
*r
;
291 struct hid_report_enum
*re
;
293 if (hid_data
->inputmode
< 0)
296 re
= &(hdev
->report_enum
[HID_FEATURE_REPORT
]);
297 r
= re
->report_id_hash
[hid_data
->inputmode
];
299 r
->field
[0]->value
[hid_data
->inputmode_index
] = 2;
300 hid_hw_request(hdev
, r
, HID_REQ_SET_REPORT
);
305 static int wacom_set_device_mode(struct hid_device
*hdev
, int report_id
,
306 int length
, int mode
)
308 unsigned char *rep_data
;
309 int error
= -ENOMEM
, limit
= 0;
311 rep_data
= kzalloc(length
, GFP_KERNEL
);
316 rep_data
[0] = report_id
;
319 error
= wacom_set_report(hdev
, HID_FEATURE_REPORT
, rep_data
,
322 error
= wacom_get_report(hdev
, HID_FEATURE_REPORT
,
323 rep_data
, length
, 1);
324 } while ((error
< 0 || rep_data
[1] != mode
) && limit
++ < WAC_MSG_RETRIES
);
328 return error
< 0 ? error
: 0;
331 static int wacom_bt_query_tablet_data(struct hid_device
*hdev
, u8 speed
,
332 struct wacom_features
*features
)
334 struct wacom
*wacom
= hid_get_drvdata(hdev
);
338 switch (features
->type
) {
342 ret
= wacom_set_report(hdev
, HID_FEATURE_REPORT
, rep_data
, 2,
346 rep_data
[0] = speed
== 0 ? 0x05 : 0x06;
349 ret
= wacom_set_report(hdev
, HID_FEATURE_REPORT
,
353 wacom
->wacom_wac
.bt_high_speed
= speed
;
359 * Note that if the raw queries fail, it's not a hard failure
360 * and it is safe to continue
362 hid_warn(hdev
, "failed to poke device, command %d, err %d\n",
367 wacom
->wacom_wac
.bt_features
&= ~0x20;
369 wacom
->wacom_wac
.bt_features
|= 0x20;
372 rep_data
[1] = wacom
->wacom_wac
.bt_features
;
374 ret
= wacom_set_report(hdev
, HID_FEATURE_REPORT
, rep_data
, 2,
377 wacom
->wacom_wac
.bt_high_speed
= speed
;
385 * Switch the tablet into its most-capable mode. Wacom tablets are
386 * typically configured to power-up in a mode which sends mouse-like
387 * reports to the OS. To get absolute position, pressure data, etc.
388 * from the tablet, it is necessary to switch the tablet out of this
389 * mode and into one which sends the full range of tablet data.
391 static int wacom_query_tablet_data(struct hid_device
*hdev
,
392 struct wacom_features
*features
)
394 if (hdev
->bus
== BUS_BLUETOOTH
)
395 return wacom_bt_query_tablet_data(hdev
, 1, features
);
397 if (features
->type
== HID_GENERIC
)
398 return wacom_hid_set_device_mode(hdev
);
400 if (features
->device_type
== BTN_TOOL_FINGER
) {
401 if (features
->type
> TABLETPC
) {
402 /* MT Tablet PC touch */
403 return wacom_set_device_mode(hdev
, 3, 4, 4);
405 else if (features
->type
== WACOM_24HDT
|| features
->type
== CINTIQ_HYBRID
) {
406 return wacom_set_device_mode(hdev
, 18, 3, 2);
408 } else if (features
->device_type
== BTN_TOOL_PEN
) {
409 if (features
->type
<= BAMBOO_PT
&& features
->type
!= WIRELESS
) {
410 return wacom_set_device_mode(hdev
, 2, 2, 2);
417 static void wacom_retrieve_hid_descriptor(struct hid_device
*hdev
,
418 struct wacom_features
*features
)
420 struct wacom
*wacom
= hid_get_drvdata(hdev
);
421 struct usb_interface
*intf
= wacom
->intf
;
423 /* default features */
424 features
->device_type
= BTN_TOOL_PEN
;
425 features
->x_fuzz
= 4;
426 features
->y_fuzz
= 4;
427 features
->pressure_fuzz
= 0;
428 features
->distance_fuzz
= 0;
431 * The wireless device HID is basic and layout conflicts with
432 * other tablets (monitor and touch interface can look like pen).
433 * Skip the query for this type and modify defaults based on
436 if (features
->type
== WIRELESS
) {
437 if (intf
->cur_altsetting
->desc
.bInterfaceNumber
== 0) {
438 features
->device_type
= 0;
439 } else if (intf
->cur_altsetting
->desc
.bInterfaceNumber
== 2) {
440 features
->device_type
= BTN_TOOL_FINGER
;
441 features
->pktlen
= WACOM_PKGLEN_BBTOUCH3
;
445 /* only devices that support touch need to retrieve the info */
446 if (features
->type
< BAMBOO_PT
)
449 wacom_parse_hid(hdev
, features
);
452 struct wacom_hdev_data
{
453 struct list_head list
;
455 struct hid_device
*dev
;
456 struct wacom_shared shared
;
459 static LIST_HEAD(wacom_udev_list
);
460 static DEFINE_MUTEX(wacom_udev_list_lock
);
462 static bool wacom_are_sibling(struct hid_device
*hdev
,
463 struct hid_device
*sibling
)
465 struct wacom
*wacom
= hid_get_drvdata(hdev
);
466 struct wacom_features
*features
= &wacom
->wacom_wac
.features
;
467 int vid
= features
->oVid
;
468 int pid
= features
->oPid
;
471 if (vid
== 0 && pid
== 0) {
476 if (vid
!= sibling
->vendor
|| pid
!= sibling
->product
)
479 /* Compare the physical path. */
480 n1
= strrchr(hdev
->phys
, '.') - hdev
->phys
;
481 n2
= strrchr(sibling
->phys
, '.') - sibling
->phys
;
482 if (n1
!= n2
|| n1
<= 0 || n2
<= 0)
485 return !strncmp(hdev
->phys
, sibling
->phys
, n1
);
488 static struct wacom_hdev_data
*wacom_get_hdev_data(struct hid_device
*hdev
)
490 struct wacom_hdev_data
*data
;
492 list_for_each_entry(data
, &wacom_udev_list
, list
) {
493 if (wacom_are_sibling(hdev
, data
->dev
)) {
494 kref_get(&data
->kref
);
502 static int wacom_add_shared_data(struct hid_device
*hdev
)
504 struct wacom
*wacom
= hid_get_drvdata(hdev
);
505 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
506 struct wacom_hdev_data
*data
;
509 mutex_lock(&wacom_udev_list_lock
);
511 data
= wacom_get_hdev_data(hdev
);
513 data
= kzalloc(sizeof(struct wacom_hdev_data
), GFP_KERNEL
);
519 kref_init(&data
->kref
);
521 list_add_tail(&data
->list
, &wacom_udev_list
);
524 wacom_wac
->shared
= &data
->shared
;
527 mutex_unlock(&wacom_udev_list_lock
);
531 static void wacom_release_shared_data(struct kref
*kref
)
533 struct wacom_hdev_data
*data
=
534 container_of(kref
, struct wacom_hdev_data
, kref
);
536 mutex_lock(&wacom_udev_list_lock
);
537 list_del(&data
->list
);
538 mutex_unlock(&wacom_udev_list_lock
);
543 static void wacom_remove_shared_data(struct wacom_wac
*wacom
)
545 struct wacom_hdev_data
*data
;
548 data
= container_of(wacom
->shared
, struct wacom_hdev_data
, shared
);
549 kref_put(&data
->kref
, wacom_release_shared_data
);
550 wacom
->shared
= NULL
;
554 static int wacom_led_control(struct wacom
*wacom
)
558 unsigned char report_id
= WAC_CMD_LED_CONTROL
;
561 if (wacom
->wacom_wac
.pid
) { /* wireless connected */
562 report_id
= WAC_CMD_WL_LED_CONTROL
;
565 buf
= kzalloc(buf_size
, GFP_KERNEL
);
569 if (wacom
->wacom_wac
.features
.type
>= INTUOS5S
&&
570 wacom
->wacom_wac
.features
.type
<= INTUOSPL
) {
572 * Touch Ring and crop mark LED luminance may take on
573 * one of four values:
574 * 0 = Low; 1 = Medium; 2 = High; 3 = Off
576 int ring_led
= wacom
->led
.select
[0] & 0x03;
577 int ring_lum
= (((wacom
->led
.llv
& 0x60) >> 5) - 1) & 0x03;
579 unsigned char led_bits
= (crop_lum
<< 4) | (ring_lum
<< 2) | (ring_led
);
582 if (wacom
->wacom_wac
.pid
) {
583 wacom_get_report(wacom
->hdev
, HID_FEATURE_REPORT
,
584 buf
, buf_size
, WAC_CMD_RETRIES
);
591 int led
= wacom
->led
.select
[0] | 0x4;
593 if (wacom
->wacom_wac
.features
.type
== WACOM_21UX2
||
594 wacom
->wacom_wac
.features
.type
== WACOM_24HD
)
595 led
|= (wacom
->led
.select
[1] << 4) | 0x40;
599 buf
[2] = wacom
->led
.llv
;
600 buf
[3] = wacom
->led
.hlv
;
601 buf
[4] = wacom
->led
.img_lum
;
604 retval
= wacom_set_report(wacom
->hdev
, HID_FEATURE_REPORT
, buf
, buf_size
,
611 static int wacom_led_putimage(struct wacom
*wacom
, int button_id
, u8 xfer_id
,
612 const unsigned len
, const void *img
)
616 const unsigned chunk_len
= len
/ 4; /* 4 chunks are needed to be sent */
618 buf
= kzalloc(chunk_len
+ 3 , GFP_KERNEL
);
622 /* Send 'start' command */
623 buf
[0] = WAC_CMD_ICON_START
;
625 retval
= wacom_set_report(wacom
->hdev
, HID_FEATURE_REPORT
, buf
, 2,
631 buf
[1] = button_id
& 0x07;
632 for (i
= 0; i
< 4; i
++) {
634 memcpy(buf
+ 3, img
+ i
* chunk_len
, chunk_len
);
636 retval
= wacom_set_report(wacom
->hdev
, HID_FEATURE_REPORT
,
637 buf
, chunk_len
+ 3, WAC_CMD_RETRIES
);
643 buf
[0] = WAC_CMD_ICON_START
;
645 wacom_set_report(wacom
->hdev
, HID_FEATURE_REPORT
, buf
, 2,
653 static ssize_t
wacom_led_select_store(struct device
*dev
, int set_id
,
654 const char *buf
, size_t count
)
656 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
657 struct wacom
*wacom
= hid_get_drvdata(hdev
);
661 err
= kstrtouint(buf
, 10, &id
);
665 mutex_lock(&wacom
->lock
);
667 wacom
->led
.select
[set_id
] = id
& 0x3;
668 err
= wacom_led_control(wacom
);
670 mutex_unlock(&wacom
->lock
);
672 return err
< 0 ? err
: count
;
675 #define DEVICE_LED_SELECT_ATTR(SET_ID) \
676 static ssize_t wacom_led##SET_ID##_select_store(struct device *dev, \
677 struct device_attribute *attr, const char *buf, size_t count) \
679 return wacom_led_select_store(dev, SET_ID, buf, count); \
681 static ssize_t wacom_led##SET_ID##_select_show(struct device *dev, \
682 struct device_attribute *attr, char *buf) \
684 struct hid_device *hdev = container_of(dev, struct hid_device, dev);\
685 struct wacom *wacom = hid_get_drvdata(hdev); \
686 return scnprintf(buf, PAGE_SIZE, "%d\n", \
687 wacom->led.select[SET_ID]); \
689 static DEVICE_ATTR(status_led##SET_ID##_select, DEV_ATTR_RW_PERM, \
690 wacom_led##SET_ID##_select_show, \
691 wacom_led##SET_ID##_select_store)
693 DEVICE_LED_SELECT_ATTR(0);
694 DEVICE_LED_SELECT_ATTR(1);
696 static ssize_t
wacom_luminance_store(struct wacom
*wacom
, u8
*dest
,
697 const char *buf
, size_t count
)
702 err
= kstrtouint(buf
, 10, &value
);
706 mutex_lock(&wacom
->lock
);
708 *dest
= value
& 0x7f;
709 err
= wacom_led_control(wacom
);
711 mutex_unlock(&wacom
->lock
);
713 return err
< 0 ? err
: count
;
716 #define DEVICE_LUMINANCE_ATTR(name, field) \
717 static ssize_t wacom_##name##_luminance_store(struct device *dev, \
718 struct device_attribute *attr, const char *buf, size_t count) \
720 struct hid_device *hdev = container_of(dev, struct hid_device, dev);\
721 struct wacom *wacom = hid_get_drvdata(hdev); \
723 return wacom_luminance_store(wacom, &wacom->led.field, \
726 static ssize_t wacom_##name##_luminance_show(struct device *dev, \
727 struct device_attribute *attr, char *buf) \
729 struct wacom *wacom = dev_get_drvdata(dev); \
730 return scnprintf(buf, PAGE_SIZE, "%d\n", wacom->led.field); \
732 static DEVICE_ATTR(name##_luminance, DEV_ATTR_RW_PERM, \
733 wacom_##name##_luminance_show, \
734 wacom_##name##_luminance_store)
736 DEVICE_LUMINANCE_ATTR(status0
, llv
);
737 DEVICE_LUMINANCE_ATTR(status1
, hlv
);
738 DEVICE_LUMINANCE_ATTR(buttons
, img_lum
);
740 static ssize_t
wacom_button_image_store(struct device
*dev
, int button_id
,
741 const char *buf
, size_t count
)
743 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
744 struct wacom
*wacom
= hid_get_drvdata(hdev
);
749 if (hdev
->bus
== BUS_BLUETOOTH
) {
751 xfer_id
= WAC_CMD_ICON_BT_XFER
;
754 xfer_id
= WAC_CMD_ICON_XFER
;
760 mutex_lock(&wacom
->lock
);
762 err
= wacom_led_putimage(wacom
, button_id
, xfer_id
, len
, buf
);
764 mutex_unlock(&wacom
->lock
);
766 return err
< 0 ? err
: count
;
769 #define DEVICE_BTNIMG_ATTR(BUTTON_ID) \
770 static ssize_t wacom_btnimg##BUTTON_ID##_store(struct device *dev, \
771 struct device_attribute *attr, const char *buf, size_t count) \
773 return wacom_button_image_store(dev, BUTTON_ID, buf, count); \
775 static DEVICE_ATTR(button##BUTTON_ID##_rawimg, DEV_ATTR_WO_PERM, \
776 NULL, wacom_btnimg##BUTTON_ID##_store)
778 DEVICE_BTNIMG_ATTR(0);
779 DEVICE_BTNIMG_ATTR(1);
780 DEVICE_BTNIMG_ATTR(2);
781 DEVICE_BTNIMG_ATTR(3);
782 DEVICE_BTNIMG_ATTR(4);
783 DEVICE_BTNIMG_ATTR(5);
784 DEVICE_BTNIMG_ATTR(6);
785 DEVICE_BTNIMG_ATTR(7);
787 static struct attribute
*cintiq_led_attrs
[] = {
788 &dev_attr_status_led0_select
.attr
,
789 &dev_attr_status_led1_select
.attr
,
793 static struct attribute_group cintiq_led_attr_group
= {
795 .attrs
= cintiq_led_attrs
,
798 static struct attribute
*intuos4_led_attrs
[] = {
799 &dev_attr_status0_luminance
.attr
,
800 &dev_attr_status1_luminance
.attr
,
801 &dev_attr_status_led0_select
.attr
,
802 &dev_attr_buttons_luminance
.attr
,
803 &dev_attr_button0_rawimg
.attr
,
804 &dev_attr_button1_rawimg
.attr
,
805 &dev_attr_button2_rawimg
.attr
,
806 &dev_attr_button3_rawimg
.attr
,
807 &dev_attr_button4_rawimg
.attr
,
808 &dev_attr_button5_rawimg
.attr
,
809 &dev_attr_button6_rawimg
.attr
,
810 &dev_attr_button7_rawimg
.attr
,
814 static struct attribute_group intuos4_led_attr_group
= {
816 .attrs
= intuos4_led_attrs
,
819 static struct attribute
*intuos5_led_attrs
[] = {
820 &dev_attr_status0_luminance
.attr
,
821 &dev_attr_status_led0_select
.attr
,
825 static struct attribute_group intuos5_led_attr_group
= {
827 .attrs
= intuos5_led_attrs
,
830 static int wacom_initialize_leds(struct wacom
*wacom
)
834 /* Initialize default values */
835 switch (wacom
->wacom_wac
.features
.type
) {
840 wacom
->led
.select
[0] = 0;
841 wacom
->led
.select
[1] = 0;
844 wacom
->led
.img_lum
= 10;
845 error
= sysfs_create_group(&wacom
->hdev
->dev
.kobj
,
846 &intuos4_led_attr_group
);
851 wacom
->led
.select
[0] = 0;
852 wacom
->led
.select
[1] = 0;
855 wacom
->led
.img_lum
= 0;
857 error
= sysfs_create_group(&wacom
->hdev
->dev
.kobj
,
858 &cintiq_led_attr_group
);
867 if (wacom
->wacom_wac
.features
.device_type
== BTN_TOOL_PEN
) {
868 wacom
->led
.select
[0] = 0;
869 wacom
->led
.select
[1] = 0;
872 wacom
->led
.img_lum
= 0;
874 error
= sysfs_create_group(&wacom
->hdev
->dev
.kobj
,
875 &intuos5_led_attr_group
);
886 "cannot create sysfs group err: %d\n", error
);
889 wacom_led_control(wacom
);
890 wacom
->led_initialized
= true;
895 static void wacom_destroy_leds(struct wacom
*wacom
)
897 if (!wacom
->led_initialized
)
900 wacom
->led_initialized
= false;
902 switch (wacom
->wacom_wac
.features
.type
) {
907 sysfs_remove_group(&wacom
->hdev
->dev
.kobj
,
908 &intuos4_led_attr_group
);
913 sysfs_remove_group(&wacom
->hdev
->dev
.kobj
,
914 &cintiq_led_attr_group
);
923 if (wacom
->wacom_wac
.features
.device_type
== BTN_TOOL_PEN
)
924 sysfs_remove_group(&wacom
->hdev
->dev
.kobj
,
925 &intuos5_led_attr_group
);
930 static enum power_supply_property wacom_battery_props
[] = {
931 POWER_SUPPLY_PROP_STATUS
,
932 POWER_SUPPLY_PROP_SCOPE
,
933 POWER_SUPPLY_PROP_CAPACITY
936 static enum power_supply_property wacom_ac_props
[] = {
937 POWER_SUPPLY_PROP_PRESENT
,
938 POWER_SUPPLY_PROP_ONLINE
,
939 POWER_SUPPLY_PROP_SCOPE
,
942 static int wacom_battery_get_property(struct power_supply
*psy
,
943 enum power_supply_property psp
,
944 union power_supply_propval
*val
)
946 struct wacom
*wacom
= container_of(psy
, struct wacom
, battery
);
950 case POWER_SUPPLY_PROP_SCOPE
:
951 val
->intval
= POWER_SUPPLY_SCOPE_DEVICE
;
953 case POWER_SUPPLY_PROP_CAPACITY
:
955 wacom
->wacom_wac
.battery_capacity
;
957 case POWER_SUPPLY_PROP_STATUS
:
958 if (wacom
->wacom_wac
.bat_charging
)
959 val
->intval
= POWER_SUPPLY_STATUS_CHARGING
;
960 else if (wacom
->wacom_wac
.battery_capacity
== 100 &&
961 wacom
->wacom_wac
.ps_connected
)
962 val
->intval
= POWER_SUPPLY_STATUS_FULL
;
964 val
->intval
= POWER_SUPPLY_STATUS_DISCHARGING
;
974 static int wacom_ac_get_property(struct power_supply
*psy
,
975 enum power_supply_property psp
,
976 union power_supply_propval
*val
)
978 struct wacom
*wacom
= container_of(psy
, struct wacom
, ac
);
982 case POWER_SUPPLY_PROP_PRESENT
:
984 case POWER_SUPPLY_PROP_ONLINE
:
985 val
->intval
= wacom
->wacom_wac
.ps_connected
;
987 case POWER_SUPPLY_PROP_SCOPE
:
988 val
->intval
= POWER_SUPPLY_SCOPE_DEVICE
;
997 static int wacom_initialize_battery(struct wacom
*wacom
)
999 static atomic_t battery_no
= ATOMIC_INIT(0);
1003 if (wacom
->wacom_wac
.features
.quirks
& WACOM_QUIRK_BATTERY
) {
1004 n
= atomic_inc_return(&battery_no
) - 1;
1006 wacom
->battery
.properties
= wacom_battery_props
;
1007 wacom
->battery
.num_properties
= ARRAY_SIZE(wacom_battery_props
);
1008 wacom
->battery
.get_property
= wacom_battery_get_property
;
1009 sprintf(wacom
->wacom_wac
.bat_name
, "wacom_battery_%ld", n
);
1010 wacom
->battery
.name
= wacom
->wacom_wac
.bat_name
;
1011 wacom
->battery
.type
= POWER_SUPPLY_TYPE_BATTERY
;
1012 wacom
->battery
.use_for_apm
= 0;
1014 wacom
->ac
.properties
= wacom_ac_props
;
1015 wacom
->ac
.num_properties
= ARRAY_SIZE(wacom_ac_props
);
1016 wacom
->ac
.get_property
= wacom_ac_get_property
;
1017 sprintf(wacom
->wacom_wac
.ac_name
, "wacom_ac_%ld", n
);
1018 wacom
->ac
.name
= wacom
->wacom_wac
.ac_name
;
1019 wacom
->ac
.type
= POWER_SUPPLY_TYPE_MAINS
;
1020 wacom
->ac
.use_for_apm
= 0;
1022 error
= power_supply_register(&wacom
->hdev
->dev
,
1027 power_supply_powers(&wacom
->battery
, &wacom
->hdev
->dev
);
1029 error
= power_supply_register(&wacom
->hdev
->dev
, &wacom
->ac
);
1031 power_supply_unregister(&wacom
->battery
);
1035 power_supply_powers(&wacom
->ac
, &wacom
->hdev
->dev
);
1041 static void wacom_destroy_battery(struct wacom
*wacom
)
1043 if ((wacom
->wacom_wac
.features
.quirks
& WACOM_QUIRK_BATTERY
) &&
1044 wacom
->battery
.dev
) {
1045 power_supply_unregister(&wacom
->battery
);
1046 wacom
->battery
.dev
= NULL
;
1047 power_supply_unregister(&wacom
->ac
);
1048 wacom
->ac
.dev
= NULL
;
1052 static ssize_t
wacom_show_speed(struct device
*dev
,
1053 struct device_attribute
1056 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
1057 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1059 return snprintf(buf
, PAGE_SIZE
, "%i\n", wacom
->wacom_wac
.bt_high_speed
);
1062 static ssize_t
wacom_store_speed(struct device
*dev
,
1063 struct device_attribute
*attr
,
1064 const char *buf
, size_t count
)
1066 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
1067 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1070 if (kstrtou8(buf
, 0, &new_speed
))
1073 if (new_speed
!= 0 && new_speed
!= 1)
1076 wacom_bt_query_tablet_data(hdev
, new_speed
, &wacom
->wacom_wac
.features
);
1081 static DEVICE_ATTR(speed
, DEV_ATTR_RW_PERM
,
1082 wacom_show_speed
, wacom_store_speed
);
1084 static struct input_dev
*wacom_allocate_input(struct wacom
*wacom
)
1086 struct input_dev
*input_dev
;
1087 struct hid_device
*hdev
= wacom
->hdev
;
1088 struct wacom_wac
*wacom_wac
= &(wacom
->wacom_wac
);
1090 input_dev
= input_allocate_device();
1094 input_dev
->name
= wacom_wac
->name
;
1095 input_dev
->phys
= hdev
->phys
;
1096 input_dev
->dev
.parent
= &hdev
->dev
;
1097 input_dev
->open
= wacom_open
;
1098 input_dev
->close
= wacom_close
;
1099 input_dev
->uniq
= hdev
->uniq
;
1100 input_dev
->id
.bustype
= hdev
->bus
;
1101 input_dev
->id
.vendor
= hdev
->vendor
;
1102 input_dev
->id
.product
= wacom_wac
->pid
? wacom_wac
->pid
: hdev
->product
;
1103 input_dev
->id
.version
= hdev
->version
;
1104 input_set_drvdata(input_dev
, wacom
);
1109 static void wacom_free_inputs(struct wacom
*wacom
)
1111 struct wacom_wac
*wacom_wac
= &(wacom
->wacom_wac
);
1113 if (wacom_wac
->input
)
1114 input_free_device(wacom_wac
->input
);
1115 if (wacom_wac
->pad_input
)
1116 input_free_device(wacom_wac
->pad_input
);
1117 wacom_wac
->input
= NULL
;
1118 wacom_wac
->pad_input
= NULL
;
1121 static int wacom_allocate_inputs(struct wacom
*wacom
)
1123 struct input_dev
*input_dev
, *pad_input_dev
;
1124 struct wacom_wac
*wacom_wac
= &(wacom
->wacom_wac
);
1126 input_dev
= wacom_allocate_input(wacom
);
1127 pad_input_dev
= wacom_allocate_input(wacom
);
1128 if (!input_dev
|| !pad_input_dev
) {
1129 wacom_free_inputs(wacom
);
1133 wacom_wac
->input
= input_dev
;
1134 wacom_wac
->pad_input
= pad_input_dev
;
1135 wacom_wac
->pad_input
->name
= wacom_wac
->pad_name
;
1140 static void wacom_clean_inputs(struct wacom
*wacom
)
1142 if (wacom
->wacom_wac
.input
) {
1143 if (wacom
->wacom_wac
.input_registered
)
1144 input_unregister_device(wacom
->wacom_wac
.input
);
1146 input_free_device(wacom
->wacom_wac
.input
);
1148 if (wacom
->wacom_wac
.pad_input
) {
1149 if (wacom
->wacom_wac
.pad_registered
)
1150 input_unregister_device(wacom
->wacom_wac
.pad_input
);
1152 input_free_device(wacom
->wacom_wac
.pad_input
);
1154 wacom
->wacom_wac
.input
= NULL
;
1155 wacom
->wacom_wac
.pad_input
= NULL
;
1156 wacom_destroy_leds(wacom
);
1159 static int wacom_register_inputs(struct wacom
*wacom
)
1161 struct input_dev
*input_dev
, *pad_input_dev
;
1162 struct wacom_wac
*wacom_wac
= &(wacom
->wacom_wac
);
1165 input_dev
= wacom_wac
->input
;
1166 pad_input_dev
= wacom_wac
->pad_input
;
1168 if (!input_dev
|| !pad_input_dev
)
1171 error
= wacom_setup_pentouch_input_capabilities(input_dev
, wacom_wac
);
1173 error
= input_register_device(input_dev
);
1176 wacom_wac
->input_registered
= true;
1179 error
= wacom_setup_pad_input_capabilities(pad_input_dev
, wacom_wac
);
1181 /* no pad in use on this interface */
1182 input_free_device(pad_input_dev
);
1183 wacom_wac
->pad_input
= NULL
;
1184 pad_input_dev
= NULL
;
1186 error
= input_register_device(pad_input_dev
);
1188 goto fail_register_pad_input
;
1189 wacom_wac
->pad_registered
= true;
1191 error
= wacom_initialize_leds(wacom
);
1199 input_unregister_device(pad_input_dev
);
1200 pad_input_dev
= NULL
;
1201 wacom_wac
->pad_registered
= false;
1202 fail_register_pad_input
:
1203 input_unregister_device(input_dev
);
1204 wacom_wac
->input
= NULL
;
1205 wacom_wac
->input_registered
= false;
1209 static void wacom_wireless_work(struct work_struct
*work
)
1211 struct wacom
*wacom
= container_of(work
, struct wacom
, work
);
1212 struct usb_device
*usbdev
= wacom
->usbdev
;
1213 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1214 struct hid_device
*hdev1
, *hdev2
;
1215 struct wacom
*wacom1
, *wacom2
;
1216 struct wacom_wac
*wacom_wac1
, *wacom_wac2
;
1220 * Regardless if this is a disconnect or a new tablet,
1221 * remove any existing input and battery devices.
1224 wacom_destroy_battery(wacom
);
1226 /* Stylus interface */
1227 hdev1
= usb_get_intfdata(usbdev
->config
->interface
[1]);
1228 wacom1
= hid_get_drvdata(hdev1
);
1229 wacom_wac1
= &(wacom1
->wacom_wac
);
1230 wacom_clean_inputs(wacom1
);
1232 /* Touch interface */
1233 hdev2
= usb_get_intfdata(usbdev
->config
->interface
[2]);
1234 wacom2
= hid_get_drvdata(hdev2
);
1235 wacom_wac2
= &(wacom2
->wacom_wac
);
1236 wacom_clean_inputs(wacom2
);
1238 if (wacom_wac
->pid
== 0) {
1239 hid_info(wacom
->hdev
, "wireless tablet disconnected\n");
1240 wacom_wac1
->shared
->type
= 0;
1242 const struct hid_device_id
*id
= wacom_ids
;
1244 hid_info(wacom
->hdev
, "wireless tablet connected with PID %x\n",
1248 if (id
->vendor
== USB_VENDOR_ID_WACOM
&&
1249 id
->product
== wacom_wac
->pid
)
1255 hid_info(wacom
->hdev
, "ignoring unknown PID.\n");
1259 /* Stylus interface */
1260 wacom_wac1
->features
=
1261 *((struct wacom_features
*)id
->driver_data
);
1262 wacom_wac1
->features
.device_type
= BTN_TOOL_PEN
;
1263 snprintf(wacom_wac1
->name
, WACOM_NAME_MAX
, "%s (WL) Pen",
1264 wacom_wac1
->features
.name
);
1265 snprintf(wacom_wac1
->pad_name
, WACOM_NAME_MAX
, "%s (WL) Pad",
1266 wacom_wac1
->features
.name
);
1267 wacom_wac1
->shared
->touch_max
= wacom_wac1
->features
.touch_max
;
1268 wacom_wac1
->shared
->type
= wacom_wac1
->features
.type
;
1269 wacom_wac1
->pid
= wacom_wac
->pid
;
1270 error
= wacom_allocate_inputs(wacom1
) ||
1271 wacom_register_inputs(wacom1
);
1275 /* Touch interface */
1276 if (wacom_wac1
->features
.touch_max
||
1277 wacom_wac1
->features
.type
== INTUOSHT
) {
1278 wacom_wac2
->features
=
1279 *((struct wacom_features
*)id
->driver_data
);
1280 wacom_wac2
->features
.pktlen
= WACOM_PKGLEN_BBTOUCH3
;
1281 wacom_wac2
->features
.device_type
= BTN_TOOL_FINGER
;
1282 wacom_wac2
->features
.x_max
= wacom_wac2
->features
.y_max
= 4096;
1283 if (wacom_wac2
->features
.touch_max
)
1284 snprintf(wacom_wac2
->name
, WACOM_NAME_MAX
,
1285 "%s (WL) Finger",wacom_wac2
->features
.name
);
1287 snprintf(wacom_wac2
->name
, WACOM_NAME_MAX
,
1288 "%s (WL) Pad",wacom_wac2
->features
.name
);
1289 snprintf(wacom_wac2
->pad_name
, WACOM_NAME_MAX
,
1290 "%s (WL) Pad", wacom_wac2
->features
.name
);
1291 wacom_wac2
->pid
= wacom_wac
->pid
;
1292 error
= wacom_allocate_inputs(wacom2
) ||
1293 wacom_register_inputs(wacom2
);
1297 if (wacom_wac1
->features
.type
== INTUOSHT
&&
1298 wacom_wac1
->features
.touch_max
)
1299 wacom_wac
->shared
->touch_input
= wacom_wac2
->input
;
1302 error
= wacom_initialize_battery(wacom
);
1310 wacom_clean_inputs(wacom1
);
1311 wacom_clean_inputs(wacom2
);
1316 * Not all devices report physical dimensions from HID.
1317 * Compute the default from hardcoded logical dimension
1318 * and resolution before driver overwrites them.
1320 static void wacom_set_default_phy(struct wacom_features
*features
)
1322 if (features
->x_resolution
) {
1323 features
->x_phy
= (features
->x_max
* 100) /
1324 features
->x_resolution
;
1325 features
->y_phy
= (features
->y_max
* 100) /
1326 features
->y_resolution
;
1330 static void wacom_calculate_res(struct wacom_features
*features
)
1332 features
->x_resolution
= wacom_calc_hid_res(features
->x_max
,
1335 features
->unitExpo
);
1336 features
->y_resolution
= wacom_calc_hid_res(features
->y_max
,
1339 features
->unitExpo
);
1342 static size_t wacom_compute_pktlen(struct hid_device
*hdev
)
1344 struct hid_report_enum
*report_enum
;
1345 struct hid_report
*report
;
1348 report_enum
= hdev
->report_enum
+ HID_INPUT_REPORT
;
1350 list_for_each_entry(report
, &report_enum
->report_list
, list
) {
1351 size_t report_size
= hid_report_len(report
);
1352 if (report_size
> size
)
1359 static int wacom_probe(struct hid_device
*hdev
,
1360 const struct hid_device_id
*id
)
1362 struct usb_interface
*intf
= to_usb_interface(hdev
->dev
.parent
);
1363 struct usb_device
*dev
= interface_to_usbdev(intf
);
1364 struct wacom
*wacom
;
1365 struct wacom_wac
*wacom_wac
;
1366 struct wacom_features
*features
;
1368 unsigned int connect_mask
= HID_CONNECT_HIDRAW
;
1370 if (!id
->driver_data
)
1373 hdev
->quirks
|= HID_QUIRK_NO_INIT_REPORTS
;
1375 wacom
= kzalloc(sizeof(struct wacom
), GFP_KERNEL
);
1379 hid_set_drvdata(hdev
, wacom
);
1382 /* ask for the report descriptor to be loaded by HID */
1383 error
= hid_parse(hdev
);
1385 hid_err(hdev
, "parse failed\n");
1389 wacom_wac
= &wacom
->wacom_wac
;
1390 wacom_wac
->features
= *((struct wacom_features
*)id
->driver_data
);
1391 features
= &wacom_wac
->features
;
1392 features
->pktlen
= wacom_compute_pktlen(hdev
);
1393 if (features
->pktlen
> WACOM_PKGLEN_MAX
) {
1398 if (features
->check_for_hid_type
&& features
->hid_type
!= hdev
->type
) {
1403 wacom
->usbdev
= dev
;
1405 mutex_init(&wacom
->lock
);
1406 INIT_WORK(&wacom
->work
, wacom_wireless_work
);
1408 if (!(features
->quirks
& WACOM_QUIRK_NO_INPUT
)) {
1409 error
= wacom_allocate_inputs(wacom
);
1411 goto fail_allocate_inputs
;
1414 /* set the default size in case we do not get them from hid */
1415 wacom_set_default_phy(features
);
1417 /* Retrieve the physical and logical size for touch devices */
1418 wacom_retrieve_hid_descriptor(hdev
, features
);
1421 * Intuos5 has no useful data about its touch interface in its
1422 * HID descriptor. If this is the touch interface (PacketSize
1423 * of WACOM_PKGLEN_BBTOUCH3), override the table values.
1425 if (features
->type
>= INTUOS5S
&& features
->type
<= INTUOSHT
) {
1426 if (features
->pktlen
== WACOM_PKGLEN_BBTOUCH3
) {
1427 features
->device_type
= BTN_TOOL_FINGER
;
1429 features
->x_max
= 4096;
1430 features
->y_max
= 4096;
1432 features
->device_type
= BTN_TOOL_PEN
;
1437 * Same thing for Bamboo 3rd gen.
1439 if ((features
->type
== BAMBOO_PT
) &&
1440 (features
->pktlen
== WACOM_PKGLEN_BBTOUCH3
) &&
1441 (features
->device_type
== BTN_TOOL_PEN
)) {
1442 features
->device_type
= BTN_TOOL_FINGER
;
1444 features
->x_max
= 4096;
1445 features
->y_max
= 4096;
1448 if (hdev
->bus
== BUS_BLUETOOTH
)
1449 features
->quirks
|= WACOM_QUIRK_BATTERY
;
1451 wacom_setup_device_quirks(features
);
1453 /* set unit to "100th of a mm" for devices not reported by HID */
1454 if (!features
->unit
) {
1455 features
->unit
= 0x11;
1456 features
->unitExpo
= -3;
1458 wacom_calculate_res(features
);
1460 strlcpy(wacom_wac
->name
, features
->name
, sizeof(wacom_wac
->name
));
1461 snprintf(wacom_wac
->pad_name
, sizeof(wacom_wac
->pad_name
),
1462 "%s Pad", features
->name
);
1464 if (features
->quirks
& WACOM_QUIRK_MULTI_INPUT
) {
1465 /* Append the device type to the name */
1466 if (features
->device_type
!= BTN_TOOL_FINGER
)
1467 strlcat(wacom_wac
->name
, " Pen", WACOM_NAME_MAX
);
1468 else if (features
->touch_max
)
1469 strlcat(wacom_wac
->name
, " Finger", WACOM_NAME_MAX
);
1471 strlcat(wacom_wac
->name
, " Pad", WACOM_NAME_MAX
);
1473 error
= wacom_add_shared_data(hdev
);
1475 goto fail_shared_data
;
1478 if (!(features
->quirks
& WACOM_QUIRK_MONITOR
) &&
1479 (features
->quirks
& WACOM_QUIRK_BATTERY
)) {
1480 error
= wacom_initialize_battery(wacom
);
1485 if (!(features
->quirks
& WACOM_QUIRK_NO_INPUT
)) {
1486 error
= wacom_register_inputs(wacom
);
1488 goto fail_register_inputs
;
1491 if (hdev
->bus
== BUS_BLUETOOTH
) {
1492 error
= device_create_file(&hdev
->dev
, &dev_attr_speed
);
1495 "can't create sysfs speed attribute err: %d\n",
1499 if (features
->type
== HID_GENERIC
)
1500 connect_mask
|= HID_CONNECT_DRIVER
;
1502 /* Regular HID work starts now */
1503 error
= hid_hw_start(hdev
, connect_mask
);
1505 hid_err(hdev
, "hw start failed\n");
1509 /* Note that if query fails it is not a hard failure */
1510 wacom_query_tablet_data(hdev
, features
);
1512 if (features
->quirks
& WACOM_QUIRK_MONITOR
)
1513 error
= hid_hw_open(hdev
);
1515 if (wacom_wac
->features
.type
== INTUOSHT
&& wacom_wac
->features
.touch_max
) {
1516 if (wacom_wac
->features
.device_type
== BTN_TOOL_FINGER
)
1517 wacom_wac
->shared
->touch_input
= wacom_wac
->input
;
1523 if (hdev
->bus
== BUS_BLUETOOTH
)
1524 device_remove_file(&hdev
->dev
, &dev_attr_speed
);
1525 fail_register_inputs
:
1526 wacom_clean_inputs(wacom
);
1527 wacom_destroy_battery(wacom
);
1529 wacom_remove_shared_data(wacom_wac
);
1531 wacom_clean_inputs(wacom
);
1532 fail_allocate_inputs
:
1537 hid_set_drvdata(hdev
, NULL
);
1541 static void wacom_remove(struct hid_device
*hdev
)
1543 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1547 cancel_work_sync(&wacom
->work
);
1548 wacom_clean_inputs(wacom
);
1549 if (hdev
->bus
== BUS_BLUETOOTH
)
1550 device_remove_file(&hdev
->dev
, &dev_attr_speed
);
1551 wacom_destroy_battery(wacom
);
1552 wacom_remove_shared_data(&wacom
->wacom_wac
);
1554 hid_set_drvdata(hdev
, NULL
);
1559 static int wacom_resume(struct hid_device
*hdev
)
1561 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1562 struct wacom_features
*features
= &wacom
->wacom_wac
.features
;
1564 mutex_lock(&wacom
->lock
);
1566 /* switch to wacom mode first */
1567 wacom_query_tablet_data(hdev
, features
);
1568 wacom_led_control(wacom
);
1570 mutex_unlock(&wacom
->lock
);
1575 static int wacom_reset_resume(struct hid_device
*hdev
)
1577 return wacom_resume(hdev
);
1579 #endif /* CONFIG_PM */
1581 static struct hid_driver wacom_driver
= {
1583 .id_table
= wacom_ids
,
1584 .probe
= wacom_probe
,
1585 .remove
= wacom_remove
,
1586 .event
= wacom_wac_event
,
1587 .report
= wacom_wac_report
,
1589 .resume
= wacom_resume
,
1590 .reset_resume
= wacom_reset_resume
,
1592 .raw_event
= wacom_raw_event
,
1594 module_hid_driver(wacom_driver
);
1596 MODULE_VERSION(DRIVER_VERSION
);
1597 MODULE_AUTHOR(DRIVER_AUTHOR
);
1598 MODULE_DESCRIPTION(DRIVER_DESC
);
1599 MODULE_LICENSE(DRIVER_LICENSE
);