2 * Bluetooth Wacom Tablet support
4 * Copyright (c) 1999 Andreas Gal
5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
7 * Copyright (c) 2006-2007 Jiri Kosina
8 * Copyright (c) 2008 Jiri Slaby <jirislaby@gmail.com>
9 * Copyright (c) 2006 Andrew Zabolotny <zap@homelink.ru>
10 * Copyright (c) 2009 Bastien Nocera <hadess@hadess.net>
11 * Copyright (c) 2011 Przemysław Firszt <przemo@firszt.eu>
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License as published by the Free
17 * Software Foundation; either version 2 of the License, or (at your option)
21 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
23 #include <linux/device.h>
24 #include <linux/hid.h>
25 #include <linux/module.h>
26 #include <linux/leds.h>
27 #include <linux/slab.h>
28 #include <linux/power_supply.h>
32 #define PAD_DEVICE_ID 0x0F
34 #define WAC_CMD_LED_CONTROL 0x20
43 unsigned char high_speed
;
44 __u8 battery_capacity
;
47 struct power_supply battery
;
48 struct power_supply ac
;
50 struct led_classdev
*leds
[4];
53 /*percent of battery capacity for Graphire
54 8th value means AC online and show 100% capacity */
55 static unsigned short batcap_gr
[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
56 /*percent of battery capacity for Intuos4 WL, AC has a separate bit*/
57 static unsigned short batcap_i4
[8] = { 1, 15, 30, 45, 60, 70, 85, 100 };
59 static enum power_supply_property wacom_battery_props
[] = {
60 POWER_SUPPLY_PROP_PRESENT
,
61 POWER_SUPPLY_PROP_CAPACITY
,
62 POWER_SUPPLY_PROP_SCOPE
,
65 static enum power_supply_property wacom_ac_props
[] = {
66 POWER_SUPPLY_PROP_PRESENT
,
67 POWER_SUPPLY_PROP_ONLINE
,
68 POWER_SUPPLY_PROP_SCOPE
,
71 static void wacom_leds_set_brightness(struct led_classdev
*led_dev
,
72 enum led_brightness value
)
74 struct device
*dev
= led_dev
->dev
->parent
;
75 struct hid_device
*hdev
;
76 struct wacom_data
*wdata
;
81 hdev
= container_of(dev
, struct hid_device
, dev
);
82 wdata
= hid_get_drvdata(hdev
);
83 for (i
= 0; i
< 4; ++i
) {
84 if (wdata
->leds
[i
] == led_dev
)
85 wdata
->led_selector
= i
;
88 led
= wdata
->led_selector
| 0x04;
89 buf
= kzalloc(9, GFP_KERNEL
);
91 buf
[0] = WAC_CMD_LED_CONTROL
;
94 hdev
->hid_output_raw_report(hdev
, buf
, 9, HID_FEATURE_REPORT
);
101 static enum led_brightness
wacom_leds_get_brightness(struct led_classdev
*led_dev
)
103 struct wacom_data
*wdata
;
104 struct device
*dev
= led_dev
->dev
->parent
;
108 wdata
= hid_get_drvdata(container_of(dev
, struct hid_device
, dev
));
110 for (i
= 0; i
< 4; ++i
) {
111 if (wdata
->leds
[i
] == led_dev
) {
112 value
= wdata
->leds
[i
]->brightness
;
121 static int wacom_initialize_leds(struct hid_device
*hdev
)
123 struct wacom_data
*wdata
= hid_get_drvdata(hdev
);
124 struct led_classdev
*led
;
125 struct device
*dev
= &hdev
->dev
;
126 size_t namesz
= strlen(dev_name(dev
)) + 12;
130 wdata
->led_selector
= 0;
132 for (i
= 0; i
< 4; i
++) {
133 led
= kzalloc(sizeof(struct led_classdev
) + namesz
, GFP_KERNEL
);
136 "can't allocate memory for LED selector\n");
141 name
= (void *)&led
[1];
142 snprintf(name
, namesz
, "%s:selector:%d", dev_name(dev
), i
);
145 led
->max_brightness
= 127;
146 led
->brightness_get
= wacom_leds_get_brightness
;
147 led
->brightness_set
= wacom_leds_set_brightness
;
149 wdata
->leds
[i
] = led
;
151 ret
= led_classdev_register(dev
, wdata
->leds
[i
]);
154 wdata
->leds
[i
] = NULL
;
156 hid_warn(hdev
, "can't register LED\n");
165 static void wacom_destroy_leds(struct hid_device
*hdev
)
167 struct wacom_data
*wdata
= hid_get_drvdata(hdev
);
168 struct led_classdev
*led
;
171 for (i
= 0; i
< 4; ++i
) {
172 if (wdata
->leds
[i
]) {
173 led
= wdata
->leds
[i
];
174 wdata
->leds
[i
] = NULL
;
175 led_classdev_unregister(led
);
182 static int wacom_battery_get_property(struct power_supply
*psy
,
183 enum power_supply_property psp
,
184 union power_supply_propval
*val
)
186 struct wacom_data
*wdata
= container_of(psy
,
187 struct wacom_data
, battery
);
191 case POWER_SUPPLY_PROP_PRESENT
:
194 case POWER_SUPPLY_PROP_SCOPE
:
195 val
->intval
= POWER_SUPPLY_SCOPE_DEVICE
;
197 case POWER_SUPPLY_PROP_CAPACITY
:
198 val
->intval
= wdata
->battery_capacity
;
207 static int wacom_ac_get_property(struct power_supply
*psy
,
208 enum power_supply_property psp
,
209 union power_supply_propval
*val
)
211 struct wacom_data
*wdata
= container_of(psy
, struct wacom_data
, ac
);
215 case POWER_SUPPLY_PROP_PRESENT
:
217 case POWER_SUPPLY_PROP_ONLINE
:
218 val
->intval
= wdata
->ps_connected
;
220 case POWER_SUPPLY_PROP_SCOPE
:
221 val
->intval
= POWER_SUPPLY_SCOPE_DEVICE
;
230 static void wacom_set_features(struct hid_device
*hdev
, u8 speed
)
232 struct wacom_data
*wdata
= hid_get_drvdata(hdev
);
236 switch (hdev
->product
) {
237 case USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH
:
238 rep_data
[0] = 0x03 ; rep_data
[1] = 0x00;
241 ret
= hdev
->hid_output_raw_report(hdev
, rep_data
, 2,
243 } while (ret
< 0 && limit
-- > 0);
254 ret
= hdev
->hid_output_raw_report(hdev
,
255 rep_data
, 2, HID_FEATURE_REPORT
);
256 } while (ret
< 0 && limit
-- > 0);
259 wdata
->high_speed
= speed
;
265 * Note that if the raw queries fail, it's not a hard failure
266 * and it is safe to continue
268 hid_warn(hdev
, "failed to poke device, command %d, err %d\n",
271 case USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH
:
273 wdata
->features
&= ~0x20;
275 wdata
->features
|= 0x20;
278 rep_data
[1] = wdata
->features
;
280 ret
= hdev
->hid_output_raw_report(hdev
, rep_data
, 2,
283 wdata
->high_speed
= speed
;
290 static ssize_t
wacom_show_speed(struct device
*dev
,
291 struct device_attribute
294 struct wacom_data
*wdata
= dev_get_drvdata(dev
);
296 return snprintf(buf
, PAGE_SIZE
, "%i\n", wdata
->high_speed
);
299 static ssize_t
wacom_store_speed(struct device
*dev
,
300 struct device_attribute
*attr
,
301 const char *buf
, size_t count
)
303 struct hid_device
*hdev
= container_of(dev
, struct hid_device
, dev
);
306 if (sscanf(buf
, "%1d", &new_speed
) != 1)
309 if (new_speed
== 0 || new_speed
== 1) {
310 wacom_set_features(hdev
, new_speed
);
311 return strnlen(buf
, PAGE_SIZE
);
316 static DEVICE_ATTR(speed
, S_IRUGO
| S_IWUSR
| S_IWGRP
,
317 wacom_show_speed
, wacom_store_speed
);
319 static int wacom_gr_parse_report(struct hid_device
*hdev
,
320 struct wacom_data
*wdata
,
321 struct input_dev
*input
, unsigned char *data
)
326 /* Get X & Y positions */
327 x
= le16_to_cpu(*(__le16
*) &data
[2]);
328 y
= le16_to_cpu(*(__le16
*) &data
[4]);
330 /* Get current tool identifier */
331 if (data
[1] & 0x90) { /* If pen is in the in/active area */
332 switch ((data
[1] >> 5) & 3) {
338 tool
= BTN_TOOL_RUBBER
;
341 case 2: /* Mouse with wheel */
342 case 3: /* Mouse without wheel */
343 tool
= BTN_TOOL_MOUSE
;
347 /* Reset tool if out of active tablet area */
348 if (!(data
[1] & 0x10))
352 /* If tool changed, notify input subsystem */
353 if (wdata
->tool
!= tool
) {
355 /* Completely reset old tool state */
356 if (wdata
->tool
== BTN_TOOL_MOUSE
) {
357 input_report_key(input
, BTN_LEFT
, 0);
358 input_report_key(input
, BTN_RIGHT
, 0);
359 input_report_key(input
, BTN_MIDDLE
, 0);
360 input_report_abs(input
, ABS_DISTANCE
,
361 input_abs_get_max(input
, ABS_DISTANCE
));
363 input_report_key(input
, BTN_TOUCH
, 0);
364 input_report_key(input
, BTN_STYLUS
, 0);
365 input_report_key(input
, BTN_STYLUS2
, 0);
366 input_report_abs(input
, ABS_PRESSURE
, 0);
368 input_report_key(input
, wdata
->tool
, 0);
373 input_report_key(input
, tool
, 1);
377 input_report_abs(input
, ABS_X
, x
);
378 input_report_abs(input
, ABS_Y
, y
);
380 switch ((data
[1] >> 5) & 3) {
381 case 2: /* Mouse with wheel */
382 input_report_key(input
, BTN_MIDDLE
, data
[1] & 0x04);
383 rw
= (data
[6] & 0x01) ? -1 :
384 (data
[6] & 0x02) ? 1 : 0;
385 input_report_rel(input
, REL_WHEEL
, rw
);
388 case 3: /* Mouse without wheel */
389 input_report_key(input
, BTN_LEFT
, data
[1] & 0x01);
390 input_report_key(input
, BTN_RIGHT
, data
[1] & 0x02);
391 /* Compute distance between mouse and tablet */
392 rw
= 44 - (data
[6] >> 2);
397 input_report_abs(input
, ABS_DISTANCE
, rw
);
401 input_report_abs(input
, ABS_PRESSURE
,
402 data
[6] | (((__u16
) (data
[1] & 0x08)) << 5));
403 input_report_key(input
, BTN_TOUCH
, data
[1] & 0x01);
404 input_report_key(input
, BTN_STYLUS
, data
[1] & 0x02);
405 input_report_key(input
, BTN_STYLUS2
, (tool
== BTN_TOOL_PEN
) && data
[1] & 0x04);
412 /* Report the state of the two buttons at the top of the tablet
413 * as two extra fingerpad keys (buttons 4 & 5). */
415 if (rw
!= wdata
->butstate
) {
416 wdata
->butstate
= rw
;
417 input_report_key(input
, BTN_0
, rw
& 0x02);
418 input_report_key(input
, BTN_1
, rw
& 0x01);
419 input_report_key(input
, BTN_TOOL_FINGER
, 0xf0);
420 input_event(input
, EV_MSC
, MSC_SERIAL
, 0xf0);
424 /* Store current battery capacity and power supply state*/
425 rw
= (data
[7] >> 2 & 0x07);
426 if (rw
!= wdata
->power_raw
) {
427 wdata
->power_raw
= rw
;
428 wdata
->battery_capacity
= batcap_gr
[rw
];
430 wdata
->ps_connected
= 1;
432 wdata
->ps_connected
= 0;
437 static void wacom_i4_parse_button_report(struct wacom_data
*wdata
,
438 struct input_dev
*input
, unsigned char *data
)
444 new_whlstate
= data
[1];
445 if (new_whlstate
!= wdata
->whlstate
) {
446 wdata
->whlstate
= new_whlstate
;
447 if (new_whlstate
& 0x80) {
448 input_report_key(input
, BTN_TOUCH
, 1);
449 input_report_abs(input
, ABS_WHEEL
, (new_whlstate
& 0x7f));
450 input_report_key(input
, BTN_TOOL_FINGER
, 1);
452 input_report_key(input
, BTN_TOUCH
, 0);
453 input_report_abs(input
, ABS_WHEEL
, 0);
454 input_report_key(input
, BTN_TOOL_FINGER
, 0);
459 new_butstate
= (data
[3] << 1) | (data
[2] & 0x01);
460 if (new_butstate
!= wdata
->butstate
) {
461 wdata
->butstate
= new_butstate
;
462 input_report_key(input
, BTN_0
, new_butstate
& 0x001);
463 input_report_key(input
, BTN_1
, new_butstate
& 0x002);
464 input_report_key(input
, BTN_2
, new_butstate
& 0x004);
465 input_report_key(input
, BTN_3
, new_butstate
& 0x008);
466 input_report_key(input
, BTN_4
, new_butstate
& 0x010);
467 input_report_key(input
, BTN_5
, new_butstate
& 0x020);
468 input_report_key(input
, BTN_6
, new_butstate
& 0x040);
469 input_report_key(input
, BTN_7
, new_butstate
& 0x080);
470 input_report_key(input
, BTN_8
, new_butstate
& 0x100);
471 input_report_key(input
, BTN_TOOL_FINGER
, 1);
476 input_report_abs(input
, ABS_MISC
, PAD_DEVICE_ID
);
477 input_event(input
, EV_MSC
, MSC_SERIAL
, 0xffffffff);
482 static void wacom_i4_parse_pen_report(struct wacom_data
*wdata
,
483 struct input_dev
*input
, unsigned char *data
)
485 __u16 x
, y
, pressure
;
490 case 0x80: /* Out of proximity report */
491 input_report_key(input
, BTN_TOUCH
, 0);
492 input_report_abs(input
, ABS_PRESSURE
, 0);
493 input_report_key(input
, BTN_STYLUS
, 0);
494 input_report_key(input
, BTN_STYLUS2
, 0);
495 input_report_key(input
, wdata
->tool
, 0);
496 input_report_abs(input
, ABS_MISC
, 0);
497 input_event(input
, EV_MSC
, MSC_SERIAL
, wdata
->serial
);
501 case 0xC2: /* Tool report */
502 wdata
->id
= ((data
[2] << 4) | (data
[3] >> 4) |
503 ((data
[7] & 0x0f) << 20) |
504 ((data
[8] & 0xf0) << 12));
505 wdata
->serial
= ((data
[3] & 0x0f) << 28) +
506 (data
[4] << 20) + (data
[5] << 12) +
507 (data
[6] << 4) + (data
[7] >> 4);
511 wdata
->tool
= BTN_TOOL_PEN
;
514 wdata
->tool
= BTN_TOOL_RUBBER
;
518 default: /* Position/pressure report */
519 x
= data
[2] << 9 | data
[3] << 1 | ((data
[9] & 0x02) >> 1);
520 y
= data
[4] << 9 | data
[5] << 1 | (data
[9] & 0x01);
521 pressure
= (data
[6] << 3) | ((data
[7] & 0xC0) >> 5)
523 distance
= (data
[9] >> 2) & 0x3f;
524 tilt_x
= ((data
[7] << 1) & 0x7e) | (data
[8] >> 7);
525 tilt_y
= data
[8] & 0x7f;
527 input_report_key(input
, BTN_TOUCH
, pressure
> 1);
529 input_report_key(input
, BTN_STYLUS
, data
[1] & 0x02);
530 input_report_key(input
, BTN_STYLUS2
, data
[1] & 0x04);
531 input_report_key(input
, wdata
->tool
, 1);
532 input_report_abs(input
, ABS_X
, x
);
533 input_report_abs(input
, ABS_Y
, y
);
534 input_report_abs(input
, ABS_PRESSURE
, pressure
);
535 input_report_abs(input
, ABS_DISTANCE
, distance
);
536 input_report_abs(input
, ABS_TILT_X
, tilt_x
);
537 input_report_abs(input
, ABS_TILT_Y
, tilt_y
);
538 input_report_abs(input
, ABS_MISC
, wdata
->id
);
539 input_event(input
, EV_MSC
, MSC_SERIAL
, wdata
->serial
);
540 input_report_key(input
, wdata
->tool
, 1);
548 static void wacom_i4_parse_report(struct hid_device
*hdev
,
549 struct wacom_data
*wdata
,
550 struct input_dev
*input
, unsigned char *data
)
553 case 0x00: /* Empty report */
555 case 0x02: /* Pen report */
556 wacom_i4_parse_pen_report(wdata
, input
, data
);
558 case 0x03: /* Features Report */
559 wdata
->features
= data
[2];
561 case 0x0C: /* Button report */
562 wacom_i4_parse_button_report(wdata
, input
, data
);
565 hid_err(hdev
, "Unknown report: %d,%d\n", data
[0], data
[1]);
570 static int wacom_raw_event(struct hid_device
*hdev
, struct hid_report
*report
,
571 u8
*raw_data
, int size
)
573 struct wacom_data
*wdata
= hid_get_drvdata(hdev
);
574 struct hid_input
*hidinput
;
575 struct input_dev
*input
;
576 unsigned char *data
= (unsigned char *) raw_data
;
580 if (!(hdev
->claimed
& HID_CLAIMED_INPUT
))
583 hidinput
= list_entry(hdev
->inputs
.next
, struct hid_input
, list
);
584 input
= hidinput
->input
;
586 switch (hdev
->product
) {
587 case USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH
:
588 if (data
[0] == 0x03) {
589 return wacom_gr_parse_report(hdev
, wdata
, input
, data
);
591 hid_err(hdev
, "Unknown report: %d,%d size:%d\n",
592 data
[0], data
[1], size
);
596 case USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH
:
601 wacom_i4_parse_report(hdev
, wdata
, input
, data
+ i
);
605 wacom_i4_parse_report(hdev
, wdata
, input
, data
+ i
);
607 wacom_i4_parse_report(hdev
, wdata
, input
, data
+ i
);
608 power_raw
= data
[i
+10];
609 if (power_raw
!= wdata
->power_raw
) {
610 wdata
->power_raw
= power_raw
;
611 wdata
->battery_capacity
= batcap_i4
[power_raw
& 0x07];
612 wdata
->ps_connected
= power_raw
& 0x08;
617 hid_err(hdev
, "Unknown report: %d,%d size:%d\n",
618 data
[0], data
[1], size
);
625 static int wacom_input_mapped(struct hid_device
*hdev
, struct hid_input
*hi
,
626 struct hid_field
*field
, struct hid_usage
*usage
, unsigned long **bit
,
629 struct input_dev
*input
= hi
->input
;
631 __set_bit(INPUT_PROP_POINTER
, input
->propbit
);
634 input
->evbit
[0] |= BIT(EV_KEY
) | BIT(EV_ABS
) | BIT(EV_REL
);
636 __set_bit(REL_WHEEL
, input
->relbit
);
638 __set_bit(BTN_TOOL_PEN
, input
->keybit
);
639 __set_bit(BTN_TOUCH
, input
->keybit
);
640 __set_bit(BTN_STYLUS
, input
->keybit
);
641 __set_bit(BTN_STYLUS2
, input
->keybit
);
642 __set_bit(BTN_LEFT
, input
->keybit
);
643 __set_bit(BTN_RIGHT
, input
->keybit
);
644 __set_bit(BTN_MIDDLE
, input
->keybit
);
647 input_set_capability(input
, EV_MSC
, MSC_SERIAL
);
649 __set_bit(BTN_0
, input
->keybit
);
650 __set_bit(BTN_1
, input
->keybit
);
651 __set_bit(BTN_TOOL_FINGER
, input
->keybit
);
653 /* Distance, rubber and mouse */
654 __set_bit(BTN_TOOL_RUBBER
, input
->keybit
);
655 __set_bit(BTN_TOOL_MOUSE
, input
->keybit
);
657 switch (hdev
->product
) {
658 case USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH
:
659 input_set_abs_params(input
, ABS_X
, 0, 16704, 4, 0);
660 input_set_abs_params(input
, ABS_Y
, 0, 12064, 4, 0);
661 input_set_abs_params(input
, ABS_PRESSURE
, 0, 511, 0, 0);
662 input_set_abs_params(input
, ABS_DISTANCE
, 0, 32, 0, 0);
664 case USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH
:
665 __set_bit(ABS_WHEEL
, input
->absbit
);
666 __set_bit(ABS_MISC
, input
->absbit
);
667 __set_bit(BTN_2
, input
->keybit
);
668 __set_bit(BTN_3
, input
->keybit
);
669 __set_bit(BTN_4
, input
->keybit
);
670 __set_bit(BTN_5
, input
->keybit
);
671 __set_bit(BTN_6
, input
->keybit
);
672 __set_bit(BTN_7
, input
->keybit
);
673 __set_bit(BTN_8
, input
->keybit
);
674 input_set_abs_params(input
, ABS_WHEEL
, 0, 71, 0, 0);
675 input_set_abs_params(input
, ABS_X
, 0, 40640, 4, 0);
676 input_set_abs_params(input
, ABS_Y
, 0, 25400, 4, 0);
677 input_set_abs_params(input
, ABS_PRESSURE
, 0, 2047, 0, 0);
678 input_set_abs_params(input
, ABS_DISTANCE
, 0, 63, 0, 0);
679 input_set_abs_params(input
, ABS_TILT_X
, 0, 127, 0, 0);
680 input_set_abs_params(input
, ABS_TILT_Y
, 0, 127, 0, 0);
687 static int wacom_probe(struct hid_device
*hdev
,
688 const struct hid_device_id
*id
)
690 struct wacom_data
*wdata
;
693 wdata
= kzalloc(sizeof(*wdata
), GFP_KERNEL
);
695 hid_err(hdev
, "can't alloc wacom descriptor\n");
699 hid_set_drvdata(hdev
, wdata
);
701 /* Parse the HID report now */
702 ret
= hid_parse(hdev
);
704 hid_err(hdev
, "parse failed\n");
708 ret
= hid_hw_start(hdev
, HID_CONNECT_DEFAULT
);
710 hid_err(hdev
, "hw start failed\n");
714 ret
= device_create_file(&hdev
->dev
, &dev_attr_speed
);
717 "can't create sysfs speed attribute err: %d\n", ret
);
720 wacom_set_features(hdev
, 1);
722 if (hdev
->product
== USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH
) {
723 sprintf(hdev
->name
, "%s", "Wacom Intuos4 WL");
724 ret
= wacom_initialize_leds(hdev
);
727 "can't create led attribute, err: %d\n", ret
);
732 wdata
->battery
.properties
= wacom_battery_props
;
733 wdata
->battery
.num_properties
= ARRAY_SIZE(wacom_battery_props
);
734 wdata
->battery
.get_property
= wacom_battery_get_property
;
735 wdata
->battery
.name
= "wacom_battery";
736 wdata
->battery
.type
= POWER_SUPPLY_TYPE_BATTERY
;
737 wdata
->battery
.use_for_apm
= 0;
740 ret
= power_supply_register(&hdev
->dev
, &wdata
->battery
);
742 hid_warn(hdev
, "can't create sysfs battery attribute, err: %d\n",
747 power_supply_powers(&wdata
->battery
, &hdev
->dev
);
749 wdata
->ac
.properties
= wacom_ac_props
;
750 wdata
->ac
.num_properties
= ARRAY_SIZE(wacom_ac_props
);
751 wdata
->ac
.get_property
= wacom_ac_get_property
;
752 wdata
->ac
.name
= "wacom_ac";
753 wdata
->ac
.type
= POWER_SUPPLY_TYPE_MAINS
;
754 wdata
->ac
.use_for_apm
= 0;
756 ret
= power_supply_register(&hdev
->dev
, &wdata
->ac
);
759 "can't create ac battery attribute, err: %d\n", ret
);
763 power_supply_powers(&wdata
->ac
, &hdev
->dev
);
767 power_supply_unregister(&wdata
->battery
);
769 device_remove_file(&hdev
->dev
, &dev_attr_speed
);
772 wacom_destroy_leds(hdev
);
778 static void wacom_remove(struct hid_device
*hdev
)
780 struct wacom_data
*wdata
= hid_get_drvdata(hdev
);
782 wacom_destroy_leds(hdev
);
783 device_remove_file(&hdev
->dev
, &dev_attr_speed
);
786 power_supply_unregister(&wdata
->battery
);
787 power_supply_unregister(&wdata
->ac
);
788 kfree(hid_get_drvdata(hdev
));
791 static const struct hid_device_id wacom_devices
[] = {
792 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM
, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH
) },
793 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM
, USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH
) },
797 MODULE_DEVICE_TABLE(hid
, wacom_devices
);
799 static struct hid_driver wacom_driver
= {
801 .id_table
= wacom_devices
,
802 .probe
= wacom_probe
,
803 .remove
= wacom_remove
,
804 .raw_event
= wacom_raw_event
,
805 .input_mapped
= wacom_input_mapped
,
808 static int __init
wacom_init(void)
812 ret
= hid_register_driver(&wacom_driver
);
814 pr_err("can't register wacom driver\n");
818 static void __exit
wacom_exit(void)
820 hid_unregister_driver(&wacom_driver
);
823 module_init(wacom_init
);
824 module_exit(wacom_exit
);
825 MODULE_DESCRIPTION("Driver for Wacom Graphire Bluetooth and Wacom Intuos4 WL");
826 MODULE_LICENSE("GPL");