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
26 #define WAC_CMD_DELETE_PAIRING 0x20
27 #define WAC_CMD_UNPAIR_ALL 0xFF
29 #define DEV_ATTR_RW_PERM (S_IRUGO | S_IWUSR | S_IWGRP)
30 #define DEV_ATTR_WO_PERM (S_IWUSR | S_IWGRP)
31 #define DEV_ATTR_RO_PERM (S_IRUSR | S_IRGRP)
33 static int wacom_get_report(struct hid_device
*hdev
, u8 type
, u8
*buf
,
34 size_t size
, unsigned int retries
)
39 retval
= hid_hw_raw_request(hdev
, buf
[0], buf
, size
, type
,
41 } while ((retval
== -ETIMEDOUT
|| retval
== -EAGAIN
) && --retries
);
44 hid_err(hdev
, "wacom_get_report: ran out of retries "
45 "(last error = %d)\n", retval
);
50 static int wacom_set_report(struct hid_device
*hdev
, u8 type
, u8
*buf
,
51 size_t size
, unsigned int retries
)
56 retval
= hid_hw_raw_request(hdev
, buf
[0], buf
, size
, type
,
58 } while ((retval
== -ETIMEDOUT
|| retval
== -EAGAIN
) && --retries
);
61 hid_err(hdev
, "wacom_set_report: ran out of retries "
62 "(last error = %d)\n", retval
);
67 static int wacom_raw_event(struct hid_device
*hdev
, struct hid_report
*report
,
68 u8
*raw_data
, int size
)
70 struct wacom
*wacom
= hid_get_drvdata(hdev
);
72 if (size
> WACOM_PKGLEN_MAX
)
75 memcpy(wacom
->wacom_wac
.data
, raw_data
, size
);
77 wacom_wac_irq(&wacom
->wacom_wac
, size
);
82 static int wacom_open(struct input_dev
*dev
)
84 struct wacom
*wacom
= input_get_drvdata(dev
);
86 return hid_hw_open(wacom
->hdev
);
89 static void wacom_close(struct input_dev
*dev
)
91 struct wacom
*wacom
= input_get_drvdata(dev
);
94 * wacom->hdev should never be null, but surprisingly, I had the case
95 * once while unplugging the Wacom Wireless Receiver.
98 hid_hw_close(wacom
->hdev
);
102 * Calculate the resolution of the X or Y axis using hidinput_calc_abs_res.
104 static int wacom_calc_hid_res(int logical_extents
, int physical_extents
,
105 unsigned unit
, int exponent
)
107 struct hid_field field
= {
108 .logical_maximum
= logical_extents
,
109 .physical_maximum
= physical_extents
,
111 .unit_exponent
= exponent
,
114 return hidinput_calc_abs_res(&field
, ABS_X
);
117 static void wacom_feature_mapping(struct hid_device
*hdev
,
118 struct hid_field
*field
, struct hid_usage
*usage
)
120 struct wacom
*wacom
= hid_get_drvdata(hdev
);
121 struct wacom_features
*features
= &wacom
->wacom_wac
.features
;
122 struct hid_data
*hid_data
= &wacom
->wacom_wac
.hid_data
;
126 switch (usage
->hid
) {
127 case HID_DG_CONTACTMAX
:
128 /* leave touch_max as is if predefined */
129 if (!features
->touch_max
) {
131 data
= kzalloc(2, GFP_KERNEL
);
134 data
[0] = field
->report
->id
;
135 ret
= wacom_get_report(hdev
, HID_FEATURE_REPORT
,
136 data
, 2, WAC_CMD_RETRIES
);
138 features
->touch_max
= data
[1];
140 features
->touch_max
= 16;
141 hid_warn(hdev
, "wacom_feature_mapping: "
142 "could not get HID_DG_CONTACTMAX, "
143 "defaulting to %d\n",
144 features
->touch_max
);
149 case HID_DG_INPUTMODE
:
150 /* Ignore if value index is out of bounds. */
151 if (usage
->usage_index
>= field
->report_count
) {
152 dev_err(&hdev
->dev
, "HID_DG_INPUTMODE out of range\n");
156 hid_data
->inputmode
= field
->report
->id
;
157 hid_data
->inputmode_index
= usage
->usage_index
;
160 case HID_UP_DIGITIZER
:
161 if (field
->report
->id
== 0x0B &&
162 (field
->application
== WACOM_G9_DIGITIZER
||
163 field
->application
== WACOM_G11_DIGITIZER
)) {
164 wacom
->wacom_wac
.mode_report
= field
->report
->id
;
165 wacom
->wacom_wac
.mode_value
= 0;
171 if (field
->report
->id
== 0x03 &&
172 (field
->application
== WACOM_G9_TOUCHSCREEN
||
173 field
->application
== WACOM_G11_TOUCHSCREEN
)) {
174 wacom
->wacom_wac
.mode_report
= field
->report
->id
;
175 wacom
->wacom_wac
.mode_value
= 0;
182 * Interface Descriptor of wacom devices can be incomplete and
183 * inconsistent so wacom_features table is used to store stylus
184 * device's packet lengths, various maximum values, and tablet
185 * resolution based on product ID's.
187 * For devices that contain 2 interfaces, wacom_features table is
188 * inaccurate for the touch interface. Since the Interface Descriptor
189 * for touch interfaces has pretty complete data, this function exists
190 * to query tablet for this missing information instead of hard coding in
191 * an additional table.
193 * A typical Interface Descriptor for a stylus will contain a
194 * boot mouse application collection that is not of interest and this
195 * function will ignore it.
197 * It also contains a digitizer application collection that also is not
198 * of interest since any information it contains would be duplicate
199 * of what is in wacom_features. Usually it defines a report of an array
200 * of bytes that could be used as max length of the stylus packet returned.
201 * If it happens to define a Digitizer-Stylus Physical Collection then
202 * the X and Y logical values contain valid data but it is ignored.
204 * A typical Interface Descriptor for a touch interface will contain a
205 * Digitizer-Finger Physical Collection which will define both logical
206 * X/Y maximum as well as the physical size of tablet. Since touch
207 * interfaces haven't supported pressure or distance, this is enough
208 * information to override invalid values in the wacom_features table.
210 * Intuos5 touch interface and 3rd gen Bamboo Touch do not contain useful
211 * data. We deal with them after returning from this function.
213 static void wacom_usage_mapping(struct hid_device
*hdev
,
214 struct hid_field
*field
, struct hid_usage
*usage
)
216 struct wacom
*wacom
= hid_get_drvdata(hdev
);
217 struct wacom_features
*features
= &wacom
->wacom_wac
.features
;
218 bool finger
= WACOM_FINGER_FIELD(field
);
219 bool pen
= WACOM_PEN_FIELD(field
);
222 * Requiring Stylus Usage will ignore boot mouse
223 * X/Y values and some cases of invalid Digitizer X/Y
224 * values commonly reported.
227 features
->device_type
|= WACOM_DEVICETYPE_PEN
;
229 features
->device_type
|= WACOM_DEVICETYPE_TOUCH
;
234 * Bamboo models do not support HID_DG_CONTACTMAX.
235 * And, Bamboo Pen only descriptor contains touch.
237 if (features
->type
> BAMBOO_PT
) {
238 /* ISDv4 touch devices at least supports one touch point */
239 if (finger
&& !features
->touch_max
)
240 features
->touch_max
= 1;
243 switch (usage
->hid
) {
245 features
->x_max
= field
->logical_maximum
;
247 features
->x_phy
= field
->physical_maximum
;
248 if ((features
->type
!= BAMBOO_PT
) &&
249 (features
->type
!= BAMBOO_TOUCH
)) {
250 features
->unit
= field
->unit
;
251 features
->unitExpo
= field
->unit_exponent
;
256 features
->y_max
= field
->logical_maximum
;
258 features
->y_phy
= field
->physical_maximum
;
259 if ((features
->type
!= BAMBOO_PT
) &&
260 (features
->type
!= BAMBOO_TOUCH
)) {
261 features
->unit
= field
->unit
;
262 features
->unitExpo
= field
->unit_exponent
;
266 case HID_DG_TIPPRESSURE
:
268 features
->pressure_max
= field
->logical_maximum
;
272 if (features
->type
== HID_GENERIC
)
273 wacom_wac_usage_mapping(hdev
, field
, usage
);
276 static void wacom_post_parse_hid(struct hid_device
*hdev
,
277 struct wacom_features
*features
)
279 struct wacom
*wacom
= hid_get_drvdata(hdev
);
280 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
282 if (features
->type
== HID_GENERIC
) {
283 /* Any last-minute generic device setup */
284 if (features
->touch_max
> 1) {
285 input_mt_init_slots(wacom_wac
->touch_input
, wacom_wac
->features
.touch_max
,
291 static void wacom_parse_hid(struct hid_device
*hdev
,
292 struct wacom_features
*features
)
294 struct hid_report_enum
*rep_enum
;
295 struct hid_report
*hreport
;
298 /* check features first */
299 rep_enum
= &hdev
->report_enum
[HID_FEATURE_REPORT
];
300 list_for_each_entry(hreport
, &rep_enum
->report_list
, list
) {
301 for (i
= 0; i
< hreport
->maxfield
; i
++) {
302 /* Ignore if report count is out of bounds. */
303 if (hreport
->field
[i
]->report_count
< 1)
306 for (j
= 0; j
< hreport
->field
[i
]->maxusage
; j
++) {
307 wacom_feature_mapping(hdev
, hreport
->field
[i
],
308 hreport
->field
[i
]->usage
+ j
);
313 /* now check the input usages */
314 rep_enum
= &hdev
->report_enum
[HID_INPUT_REPORT
];
315 list_for_each_entry(hreport
, &rep_enum
->report_list
, list
) {
317 if (!hreport
->maxfield
)
320 for (i
= 0; i
< hreport
->maxfield
; i
++)
321 for (j
= 0; j
< hreport
->field
[i
]->maxusage
; j
++)
322 wacom_usage_mapping(hdev
, hreport
->field
[i
],
323 hreport
->field
[i
]->usage
+ j
);
326 wacom_post_parse_hid(hdev
, features
);
329 static int wacom_hid_set_device_mode(struct hid_device
*hdev
)
331 struct wacom
*wacom
= hid_get_drvdata(hdev
);
332 struct hid_data
*hid_data
= &wacom
->wacom_wac
.hid_data
;
333 struct hid_report
*r
;
334 struct hid_report_enum
*re
;
336 if (hid_data
->inputmode
< 0)
339 re
= &(hdev
->report_enum
[HID_FEATURE_REPORT
]);
340 r
= re
->report_id_hash
[hid_data
->inputmode
];
342 r
->field
[0]->value
[hid_data
->inputmode_index
] = 2;
343 hid_hw_request(hdev
, r
, HID_REQ_SET_REPORT
);
348 static int wacom_set_device_mode(struct hid_device
*hdev
,
349 struct wacom_wac
*wacom_wac
)
352 struct hid_report
*r
;
353 struct hid_report_enum
*re
;
355 int error
= -ENOMEM
, limit
= 0;
357 if (wacom_wac
->mode_report
< 0)
360 re
= &(hdev
->report_enum
[HID_FEATURE_REPORT
]);
361 r
= re
->report_id_hash
[wacom_wac
->mode_report
];
365 rep_data
= hid_alloc_report_buf(r
, GFP_KERNEL
);
369 length
= hid_report_len(r
);
372 rep_data
[0] = wacom_wac
->mode_report
;
373 rep_data
[1] = wacom_wac
->mode_value
;
375 error
= wacom_set_report(hdev
, HID_FEATURE_REPORT
, rep_data
,
378 error
= wacom_get_report(hdev
, HID_FEATURE_REPORT
,
379 rep_data
, length
, 1);
380 } while (error
>= 0 &&
381 rep_data
[1] != wacom_wac
->mode_report
&&
382 limit
++ < WAC_MSG_RETRIES
);
386 return error
< 0 ? error
: 0;
389 static int wacom_bt_query_tablet_data(struct hid_device
*hdev
, u8 speed
,
390 struct wacom_features
*features
)
392 struct wacom
*wacom
= hid_get_drvdata(hdev
);
396 switch (features
->type
) {
400 ret
= wacom_set_report(hdev
, HID_FEATURE_REPORT
, rep_data
, 2,
404 rep_data
[0] = speed
== 0 ? 0x05 : 0x06;
407 ret
= wacom_set_report(hdev
, HID_FEATURE_REPORT
,
411 wacom
->wacom_wac
.bt_high_speed
= speed
;
417 * Note that if the raw queries fail, it's not a hard failure
418 * and it is safe to continue
420 hid_warn(hdev
, "failed to poke device, command %d, err %d\n",
425 wacom
->wacom_wac
.bt_features
&= ~0x20;
427 wacom
->wacom_wac
.bt_features
|= 0x20;
430 rep_data
[1] = wacom
->wacom_wac
.bt_features
;
432 ret
= wacom_set_report(hdev
, HID_FEATURE_REPORT
, rep_data
, 2,
435 wacom
->wacom_wac
.bt_high_speed
= speed
;
443 * Switch the tablet into its most-capable mode. Wacom tablets are
444 * typically configured to power-up in a mode which sends mouse-like
445 * reports to the OS. To get absolute position, pressure data, etc.
446 * from the tablet, it is necessary to switch the tablet out of this
447 * mode and into one which sends the full range of tablet data.
449 static int wacom_query_tablet_data(struct hid_device
*hdev
,
450 struct wacom_features
*features
)
452 struct wacom
*wacom
= hid_get_drvdata(hdev
);
453 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
455 if (hdev
->bus
== BUS_BLUETOOTH
)
456 return wacom_bt_query_tablet_data(hdev
, 1, features
);
458 if (features
->type
!= HID_GENERIC
) {
459 if (features
->device_type
& WACOM_DEVICETYPE_TOUCH
) {
460 if (features
->type
> TABLETPC
) {
461 /* MT Tablet PC touch */
462 wacom_wac
->mode_report
= 3;
463 wacom_wac
->mode_value
= 4;
464 } else if (features
->type
== WACOM_24HDT
) {
465 wacom_wac
->mode_report
= 18;
466 wacom_wac
->mode_value
= 2;
467 } else if (features
->type
== WACOM_27QHDT
) {
468 wacom_wac
->mode_report
= 131;
469 wacom_wac
->mode_value
= 2;
470 } else if (features
->type
== BAMBOO_PAD
) {
471 wacom_wac
->mode_report
= 2;
472 wacom_wac
->mode_value
= 2;
474 } else if (features
->device_type
& WACOM_DEVICETYPE_PEN
) {
475 if (features
->type
<= BAMBOO_PT
) {
476 wacom_wac
->mode_report
= 2;
477 wacom_wac
->mode_value
= 2;
482 wacom_set_device_mode(hdev
, wacom_wac
);
484 if (features
->type
== HID_GENERIC
)
485 return wacom_hid_set_device_mode(hdev
);
490 static void wacom_retrieve_hid_descriptor(struct hid_device
*hdev
,
491 struct wacom_features
*features
)
493 struct wacom
*wacom
= hid_get_drvdata(hdev
);
494 struct usb_interface
*intf
= wacom
->intf
;
496 /* default features */
497 features
->x_fuzz
= 4;
498 features
->y_fuzz
= 4;
499 features
->pressure_fuzz
= 0;
500 features
->distance_fuzz
= 1;
501 features
->tilt_fuzz
= 1;
504 * The wireless device HID is basic and layout conflicts with
505 * other tablets (monitor and touch interface can look like pen).
506 * Skip the query for this type and modify defaults based on
509 if (features
->type
== WIRELESS
) {
510 if (intf
->cur_altsetting
->desc
.bInterfaceNumber
== 0)
511 features
->device_type
= WACOM_DEVICETYPE_WL_MONITOR
;
513 features
->device_type
= WACOM_DEVICETYPE_NONE
;
517 wacom_parse_hid(hdev
, features
);
520 struct wacom_hdev_data
{
521 struct list_head list
;
523 struct hid_device
*dev
;
524 struct wacom_shared shared
;
527 static LIST_HEAD(wacom_udev_list
);
528 static DEFINE_MUTEX(wacom_udev_list_lock
);
530 static bool wacom_are_sibling(struct hid_device
*hdev
,
531 struct hid_device
*sibling
)
533 struct wacom
*wacom
= hid_get_drvdata(hdev
);
534 struct wacom_features
*features
= &wacom
->wacom_wac
.features
;
535 int vid
= features
->oVid
;
536 int pid
= features
->oPid
;
539 if (vid
== 0 && pid
== 0) {
544 if (vid
!= sibling
->vendor
|| pid
!= sibling
->product
)
547 /* Compare the physical path. */
548 n1
= strrchr(hdev
->phys
, '.') - hdev
->phys
;
549 n2
= strrchr(sibling
->phys
, '.') - sibling
->phys
;
550 if (n1
!= n2
|| n1
<= 0 || n2
<= 0)
553 return !strncmp(hdev
->phys
, sibling
->phys
, n1
);
556 static struct wacom_hdev_data
*wacom_get_hdev_data(struct hid_device
*hdev
)
558 struct wacom_hdev_data
*data
;
560 list_for_each_entry(data
, &wacom_udev_list
, list
) {
561 if (wacom_are_sibling(hdev
, data
->dev
)) {
562 kref_get(&data
->kref
);
570 static void wacom_release_shared_data(struct kref
*kref
)
572 struct wacom_hdev_data
*data
=
573 container_of(kref
, struct wacom_hdev_data
, kref
);
575 mutex_lock(&wacom_udev_list_lock
);
576 list_del(&data
->list
);
577 mutex_unlock(&wacom_udev_list_lock
);
582 static void wacom_remove_shared_data(void *res
)
584 struct wacom
*wacom
= res
;
585 struct wacom_hdev_data
*data
;
586 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
588 if (wacom_wac
->shared
) {
589 data
= container_of(wacom_wac
->shared
, struct wacom_hdev_data
,
592 if (wacom_wac
->shared
->touch
== wacom
->hdev
)
593 wacom_wac
->shared
->touch
= NULL
;
594 else if (wacom_wac
->shared
->pen
== wacom
->hdev
)
595 wacom_wac
->shared
->pen
= NULL
;
597 kref_put(&data
->kref
, wacom_release_shared_data
);
598 wacom_wac
->shared
= NULL
;
602 static int wacom_add_shared_data(struct hid_device
*hdev
)
604 struct wacom
*wacom
= hid_get_drvdata(hdev
);
605 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
606 struct wacom_hdev_data
*data
;
609 mutex_lock(&wacom_udev_list_lock
);
611 data
= wacom_get_hdev_data(hdev
);
613 data
= kzalloc(sizeof(struct wacom_hdev_data
), GFP_KERNEL
);
619 kref_init(&data
->kref
);
621 list_add_tail(&data
->list
, &wacom_udev_list
);
624 wacom_wac
->shared
= &data
->shared
;
626 retval
= devm_add_action(&hdev
->dev
, wacom_remove_shared_data
, wacom
);
628 mutex_unlock(&wacom_udev_list_lock
);
629 wacom_remove_shared_data(wacom
);
633 if (wacom_wac
->features
.device_type
& WACOM_DEVICETYPE_TOUCH
)
634 wacom_wac
->shared
->touch
= hdev
;
635 else if (wacom_wac
->features
.device_type
& WACOM_DEVICETYPE_PEN
)
636 wacom_wac
->shared
->pen
= hdev
;
639 mutex_unlock(&wacom_udev_list_lock
);
643 static int wacom_led_control(struct wacom
*wacom
)
647 unsigned char report_id
= WAC_CMD_LED_CONTROL
;
650 if (!hid_get_drvdata(wacom
->hdev
))
653 if (!wacom
->led
.groups
)
656 if (wacom
->wacom_wac
.pid
) { /* wireless connected */
657 report_id
= WAC_CMD_WL_LED_CONTROL
;
660 buf
= kzalloc(buf_size
, GFP_KERNEL
);
664 if (wacom
->wacom_wac
.features
.type
>= INTUOS5S
&&
665 wacom
->wacom_wac
.features
.type
<= INTUOSPL
) {
667 * Touch Ring and crop mark LED luminance may take on
668 * one of four values:
669 * 0 = Low; 1 = Medium; 2 = High; 3 = Off
671 int ring_led
= wacom
->led
.groups
[0].select
& 0x03;
672 int ring_lum
= (((wacom
->led
.llv
& 0x60) >> 5) - 1) & 0x03;
674 unsigned char led_bits
= (crop_lum
<< 4) | (ring_lum
<< 2) | (ring_led
);
677 if (wacom
->wacom_wac
.pid
) {
678 wacom_get_report(wacom
->hdev
, HID_FEATURE_REPORT
,
679 buf
, buf_size
, WAC_CMD_RETRIES
);
686 int led
= wacom
->led
.groups
[0].select
| 0x4;
688 if (wacom
->wacom_wac
.features
.type
== WACOM_21UX2
||
689 wacom
->wacom_wac
.features
.type
== WACOM_24HD
)
690 led
|= (wacom
->led
.groups
[1].select
<< 4) | 0x40;
694 buf
[2] = wacom
->led
.llv
;
695 buf
[3] = wacom
->led
.hlv
;
696 buf
[4] = wacom
->led
.img_lum
;
699 retval
= wacom_set_report(wacom
->hdev
, HID_FEATURE_REPORT
, buf
, buf_size
,
706 static int wacom_led_putimage(struct wacom
*wacom
, int button_id
, u8 xfer_id
,
707 const unsigned len
, const void *img
)
711 const unsigned chunk_len
= len
/ 4; /* 4 chunks are needed to be sent */
713 buf
= kzalloc(chunk_len
+ 3 , GFP_KERNEL
);
717 /* Send 'start' command */
718 buf
[0] = WAC_CMD_ICON_START
;
720 retval
= wacom_set_report(wacom
->hdev
, HID_FEATURE_REPORT
, buf
, 2,
726 buf
[1] = button_id
& 0x07;
727 for (i
= 0; i
< 4; i
++) {
729 memcpy(buf
+ 3, img
+ i
* chunk_len
, chunk_len
);
731 retval
= wacom_set_report(wacom
->hdev
, HID_FEATURE_REPORT
,
732 buf
, chunk_len
+ 3, WAC_CMD_RETRIES
);
738 buf
[0] = WAC_CMD_ICON_START
;
740 wacom_set_report(wacom
->hdev
, HID_FEATURE_REPORT
, buf
, 2,
748 static ssize_t
wacom_led_select_store(struct device
*dev
, int set_id
,
749 const char *buf
, size_t count
)
751 struct hid_device
*hdev
= to_hid_device(dev
);
752 struct wacom
*wacom
= hid_get_drvdata(hdev
);
756 err
= kstrtouint(buf
, 10, &id
);
760 mutex_lock(&wacom
->lock
);
762 wacom
->led
.groups
[set_id
].select
= id
& 0x3;
763 err
= wacom_led_control(wacom
);
765 mutex_unlock(&wacom
->lock
);
767 return err
< 0 ? err
: count
;
770 #define DEVICE_LED_SELECT_ATTR(SET_ID) \
771 static ssize_t wacom_led##SET_ID##_select_store(struct device *dev, \
772 struct device_attribute *attr, const char *buf, size_t count) \
774 return wacom_led_select_store(dev, SET_ID, buf, count); \
776 static ssize_t wacom_led##SET_ID##_select_show(struct device *dev, \
777 struct device_attribute *attr, char *buf) \
779 struct hid_device *hdev = to_hid_device(dev);\
780 struct wacom *wacom = hid_get_drvdata(hdev); \
781 return scnprintf(buf, PAGE_SIZE, "%d\n", \
782 wacom->led.groups[SET_ID].select); \
784 static DEVICE_ATTR(status_led##SET_ID##_select, DEV_ATTR_RW_PERM, \
785 wacom_led##SET_ID##_select_show, \
786 wacom_led##SET_ID##_select_store)
788 DEVICE_LED_SELECT_ATTR(0);
789 DEVICE_LED_SELECT_ATTR(1);
791 static ssize_t
wacom_luminance_store(struct wacom
*wacom
, u8
*dest
,
792 const char *buf
, size_t count
)
797 err
= kstrtouint(buf
, 10, &value
);
801 mutex_lock(&wacom
->lock
);
803 *dest
= value
& 0x7f;
804 err
= wacom_led_control(wacom
);
806 mutex_unlock(&wacom
->lock
);
808 return err
< 0 ? err
: count
;
811 #define DEVICE_LUMINANCE_ATTR(name, field) \
812 static ssize_t wacom_##name##_luminance_store(struct device *dev, \
813 struct device_attribute *attr, const char *buf, size_t count) \
815 struct hid_device *hdev = to_hid_device(dev);\
816 struct wacom *wacom = hid_get_drvdata(hdev); \
818 return wacom_luminance_store(wacom, &wacom->led.field, \
821 static ssize_t wacom_##name##_luminance_show(struct device *dev, \
822 struct device_attribute *attr, char *buf) \
824 struct wacom *wacom = dev_get_drvdata(dev); \
825 return scnprintf(buf, PAGE_SIZE, "%d\n", wacom->led.field); \
827 static DEVICE_ATTR(name##_luminance, DEV_ATTR_RW_PERM, \
828 wacom_##name##_luminance_show, \
829 wacom_##name##_luminance_store)
831 DEVICE_LUMINANCE_ATTR(status0
, llv
);
832 DEVICE_LUMINANCE_ATTR(status1
, hlv
);
833 DEVICE_LUMINANCE_ATTR(buttons
, img_lum
);
835 static ssize_t
wacom_button_image_store(struct device
*dev
, int button_id
,
836 const char *buf
, size_t count
)
838 struct hid_device
*hdev
= to_hid_device(dev
);
839 struct wacom
*wacom
= hid_get_drvdata(hdev
);
844 if (hdev
->bus
== BUS_BLUETOOTH
) {
846 xfer_id
= WAC_CMD_ICON_BT_XFER
;
849 xfer_id
= WAC_CMD_ICON_XFER
;
855 mutex_lock(&wacom
->lock
);
857 err
= wacom_led_putimage(wacom
, button_id
, xfer_id
, len
, buf
);
859 mutex_unlock(&wacom
->lock
);
861 return err
< 0 ? err
: count
;
864 #define DEVICE_BTNIMG_ATTR(BUTTON_ID) \
865 static ssize_t wacom_btnimg##BUTTON_ID##_store(struct device *dev, \
866 struct device_attribute *attr, const char *buf, size_t count) \
868 return wacom_button_image_store(dev, BUTTON_ID, buf, count); \
870 static DEVICE_ATTR(button##BUTTON_ID##_rawimg, DEV_ATTR_WO_PERM, \
871 NULL, wacom_btnimg##BUTTON_ID##_store)
873 DEVICE_BTNIMG_ATTR(0);
874 DEVICE_BTNIMG_ATTR(1);
875 DEVICE_BTNIMG_ATTR(2);
876 DEVICE_BTNIMG_ATTR(3);
877 DEVICE_BTNIMG_ATTR(4);
878 DEVICE_BTNIMG_ATTR(5);
879 DEVICE_BTNIMG_ATTR(6);
880 DEVICE_BTNIMG_ATTR(7);
882 static struct attribute
*cintiq_led_attrs
[] = {
883 &dev_attr_status_led0_select
.attr
,
884 &dev_attr_status_led1_select
.attr
,
888 static struct attribute_group cintiq_led_attr_group
= {
890 .attrs
= cintiq_led_attrs
,
893 static struct attribute
*intuos4_led_attrs
[] = {
894 &dev_attr_status0_luminance
.attr
,
895 &dev_attr_status1_luminance
.attr
,
896 &dev_attr_status_led0_select
.attr
,
897 &dev_attr_buttons_luminance
.attr
,
898 &dev_attr_button0_rawimg
.attr
,
899 &dev_attr_button1_rawimg
.attr
,
900 &dev_attr_button2_rawimg
.attr
,
901 &dev_attr_button3_rawimg
.attr
,
902 &dev_attr_button4_rawimg
.attr
,
903 &dev_attr_button5_rawimg
.attr
,
904 &dev_attr_button6_rawimg
.attr
,
905 &dev_attr_button7_rawimg
.attr
,
909 static struct attribute_group intuos4_led_attr_group
= {
911 .attrs
= intuos4_led_attrs
,
914 static struct attribute
*intuos5_led_attrs
[] = {
915 &dev_attr_status0_luminance
.attr
,
916 &dev_attr_status_led0_select
.attr
,
920 static struct attribute_group intuos5_led_attr_group
= {
922 .attrs
= intuos5_led_attrs
,
925 struct wacom_sysfs_group_devres
{
926 struct attribute_group
*group
;
927 struct kobject
*root
;
930 static void wacom_devm_sysfs_group_release(struct device
*dev
, void *res
)
932 struct wacom_sysfs_group_devres
*devres
= res
;
933 struct kobject
*kobj
= devres
->root
;
935 dev_dbg(dev
, "%s: dropping reference to %s\n",
936 __func__
, devres
->group
->name
);
937 sysfs_remove_group(kobj
, devres
->group
);
940 static int __wacom_devm_sysfs_create_group(struct wacom
*wacom
,
941 struct kobject
*root
,
942 struct attribute_group
*group
)
944 struct wacom_sysfs_group_devres
*devres
;
947 devres
= devres_alloc(wacom_devm_sysfs_group_release
,
948 sizeof(struct wacom_sysfs_group_devres
),
953 devres
->group
= group
;
956 error
= sysfs_create_group(devres
->root
, group
);
960 devres_add(&wacom
->hdev
->dev
, devres
);
965 static int wacom_devm_sysfs_create_group(struct wacom
*wacom
,
966 struct attribute_group
*group
)
968 return __wacom_devm_sysfs_create_group(wacom
, &wacom
->hdev
->dev
.kobj
,
972 static enum led_brightness
wacom_leds_brightness_get(struct wacom_led
*led
)
974 struct wacom
*wacom
= led
->wacom
;
976 if (wacom
->led
.max_hlv
)
977 return led
->hlv
* LED_FULL
/ wacom
->led
.max_hlv
;
979 if (wacom
->led
.max_llv
)
980 return led
->llv
* LED_FULL
/ wacom
->led
.max_llv
;
982 /* device doesn't support brightness tuning */
986 static enum led_brightness
__wacom_led_brightness_get(struct led_classdev
*cdev
)
988 struct wacom_led
*led
= container_of(cdev
, struct wacom_led
, cdev
);
989 struct wacom
*wacom
= led
->wacom
;
991 if (wacom
->led
.groups
[led
->group
].select
!= led
->id
)
994 return wacom_leds_brightness_get(led
);
997 static int wacom_led_brightness_set(struct led_classdev
*cdev
,
998 enum led_brightness brightness
)
1000 struct wacom_led
*led
= container_of(cdev
, struct wacom_led
, cdev
);
1001 struct wacom
*wacom
= led
->wacom
;
1004 mutex_lock(&wacom
->lock
);
1006 if (!wacom
->led
.groups
|| (brightness
== LED_OFF
&&
1007 wacom
->led
.groups
[led
->group
].select
!= led
->id
)) {
1012 led
->llv
= wacom
->led
.llv
= wacom
->led
.max_llv
* brightness
/ LED_FULL
;
1013 led
->hlv
= wacom
->led
.hlv
= wacom
->led
.max_hlv
* brightness
/ LED_FULL
;
1015 wacom
->led
.groups
[led
->group
].select
= led
->id
;
1017 error
= wacom_led_control(wacom
);
1020 mutex_unlock(&wacom
->lock
);
1025 static void wacom_led_readonly_brightness_set(struct led_classdev
*cdev
,
1026 enum led_brightness brightness
)
1030 static int wacom_led_register_one(struct device
*dev
, struct wacom
*wacom
,
1031 struct wacom_led
*led
, unsigned int group
,
1032 unsigned int id
, bool read_only
)
1037 name
= devm_kasprintf(dev
, GFP_KERNEL
,
1048 led
->llv
= wacom
->led
.llv
;
1049 led
->hlv
= wacom
->led
.hlv
;
1050 led
->cdev
.name
= name
;
1051 led
->cdev
.max_brightness
= LED_FULL
;
1052 led
->cdev
.flags
= LED_HW_PLUGGABLE
;
1053 led
->cdev
.brightness_get
= __wacom_led_brightness_get
;
1055 led
->cdev
.brightness_set_blocking
= wacom_led_brightness_set
;
1057 led
->cdev
.brightness_set
= wacom_led_readonly_brightness_set
;
1059 error
= devm_led_classdev_register(dev
, &led
->cdev
);
1061 hid_err(wacom
->hdev
,
1062 "failed to register LED %s: %d\n",
1063 led
->cdev
.name
, error
);
1064 led
->cdev
.name
= NULL
;
1071 static int wacom_led_groups_alloc_and_register_one(struct device
*dev
,
1072 struct wacom
*wacom
,
1073 int group_id
, int count
,
1076 struct wacom_led
*leds
;
1079 if (group_id
>= wacom
->led
.count
|| count
<= 0)
1082 if (!devres_open_group(dev
, &wacom
->led
.groups
[group_id
], GFP_KERNEL
))
1085 leds
= devm_kzalloc(dev
, sizeof(struct wacom_led
) * count
, GFP_KERNEL
);
1091 wacom
->led
.groups
[group_id
].leds
= leds
;
1092 wacom
->led
.groups
[group_id
].count
= count
;
1094 for (i
= 0; i
< count
; i
++) {
1095 error
= wacom_led_register_one(dev
, wacom
, &leds
[i
],
1096 group_id
, i
, read_only
);
1101 devres_remove_group(dev
, &wacom
->led
.groups
[group_id
]);
1105 devres_release_group(dev
, &wacom
->led
.groups
[group_id
]);
1109 static void wacom_led_groups_release(void *data
)
1111 struct wacom
*wacom
= data
;
1113 wacom
->led
.groups
= NULL
;
1114 wacom
->led
.count
= 0;
1117 static int wacom_led_groups_allocate(struct wacom
*wacom
, int count
)
1119 struct device
*dev
= &wacom
->hdev
->dev
;
1120 struct wacom_group_leds
*groups
;
1123 groups
= devm_kzalloc(dev
, sizeof(struct wacom_group_leds
) * count
,
1128 error
= devm_add_action_or_reset(dev
, wacom_led_groups_release
, wacom
);
1132 wacom
->led
.groups
= groups
;
1133 wacom
->led
.count
= count
;
1138 static int wacom_leds_alloc_and_register(struct wacom
*wacom
, int group_count
,
1139 int led_per_group
, bool read_only
)
1144 if (!wacom
->wacom_wac
.pad_input
)
1147 dev
= &wacom
->wacom_wac
.pad_input
->dev
;
1149 error
= wacom_led_groups_allocate(wacom
, group_count
);
1153 for (i
= 0; i
< group_count
; i
++) {
1154 error
= wacom_led_groups_alloc_and_register_one(dev
, wacom
, i
,
1164 static int wacom_initialize_leds(struct wacom
*wacom
)
1168 if (!(wacom
->wacom_wac
.features
.device_type
& WACOM_DEVICETYPE_PAD
))
1171 /* Initialize default values */
1172 switch (wacom
->wacom_wac
.features
.type
) {
1177 wacom
->led
.llv
= 10;
1178 wacom
->led
.hlv
= 20;
1179 wacom
->led
.max_llv
= 127;
1180 wacom
->led
.max_hlv
= 127;
1181 wacom
->led
.img_lum
= 10;
1183 error
= wacom_leds_alloc_and_register(wacom
, 1, 4, false);
1185 hid_err(wacom
->hdev
,
1186 "cannot create leds err: %d\n", error
);
1190 error
= wacom_devm_sysfs_create_group(wacom
,
1191 &intuos4_led_attr_group
);
1198 wacom
->led
.img_lum
= 0;
1200 error
= wacom_leds_alloc_and_register(wacom
, 2, 4, false);
1202 hid_err(wacom
->hdev
,
1203 "cannot create leds err: %d\n", error
);
1207 error
= wacom_devm_sysfs_create_group(wacom
,
1208 &cintiq_led_attr_group
);
1217 wacom
->led
.llv
= 32;
1218 wacom
->led
.max_llv
= 96;
1220 error
= wacom_leds_alloc_and_register(wacom
, 1, 4, false);
1222 hid_err(wacom
->hdev
,
1223 "cannot create leds err: %d\n", error
);
1227 error
= wacom_devm_sysfs_create_group(wacom
,
1228 &intuos5_led_attr_group
);
1232 wacom
->led
.llv
= 255;
1233 wacom
->led
.max_llv
= 255;
1234 error
= wacom_led_groups_allocate(wacom
, 5);
1236 hid_err(wacom
->hdev
,
1237 "cannot create leds err: %d\n", error
);
1247 hid_err(wacom
->hdev
,
1248 "cannot create sysfs group err: %d\n", error
);
1251 wacom_led_control(wacom
);
1256 static enum power_supply_property wacom_battery_props
[] = {
1257 POWER_SUPPLY_PROP_PRESENT
,
1258 POWER_SUPPLY_PROP_STATUS
,
1259 POWER_SUPPLY_PROP_SCOPE
,
1260 POWER_SUPPLY_PROP_CAPACITY
1263 static enum power_supply_property wacom_ac_props
[] = {
1264 POWER_SUPPLY_PROP_PRESENT
,
1265 POWER_SUPPLY_PROP_ONLINE
,
1266 POWER_SUPPLY_PROP_SCOPE
,
1269 static int wacom_battery_get_property(struct power_supply
*psy
,
1270 enum power_supply_property psp
,
1271 union power_supply_propval
*val
)
1273 struct wacom_battery
*battery
= power_supply_get_drvdata(psy
);
1277 case POWER_SUPPLY_PROP_PRESENT
:
1278 val
->intval
= battery
->bat_connected
;
1280 case POWER_SUPPLY_PROP_SCOPE
:
1281 val
->intval
= POWER_SUPPLY_SCOPE_DEVICE
;
1283 case POWER_SUPPLY_PROP_CAPACITY
:
1284 val
->intval
= battery
->battery_capacity
;
1286 case POWER_SUPPLY_PROP_STATUS
:
1287 if (battery
->bat_charging
)
1288 val
->intval
= POWER_SUPPLY_STATUS_CHARGING
;
1289 else if (battery
->battery_capacity
== 100 &&
1290 battery
->ps_connected
)
1291 val
->intval
= POWER_SUPPLY_STATUS_FULL
;
1292 else if (battery
->ps_connected
)
1293 val
->intval
= POWER_SUPPLY_STATUS_NOT_CHARGING
;
1295 val
->intval
= POWER_SUPPLY_STATUS_DISCHARGING
;
1305 static int wacom_ac_get_property(struct power_supply
*psy
,
1306 enum power_supply_property psp
,
1307 union power_supply_propval
*val
)
1309 struct wacom_battery
*battery
= power_supply_get_drvdata(psy
);
1313 case POWER_SUPPLY_PROP_PRESENT
:
1315 case POWER_SUPPLY_PROP_ONLINE
:
1316 val
->intval
= battery
->ps_connected
;
1318 case POWER_SUPPLY_PROP_SCOPE
:
1319 val
->intval
= POWER_SUPPLY_SCOPE_DEVICE
;
1328 static int __wacom_initialize_battery(struct wacom
*wacom
,
1329 struct wacom_battery
*battery
)
1331 static atomic_t battery_no
= ATOMIC_INIT(0);
1332 struct device
*dev
= &wacom
->hdev
->dev
;
1333 struct power_supply_config psy_cfg
= { .drv_data
= battery
, };
1334 struct power_supply
*ps_bat
, *ps_ac
;
1335 struct power_supply_desc
*bat_desc
= &battery
->bat_desc
;
1336 struct power_supply_desc
*ac_desc
= &battery
->ac_desc
;
1340 if (!devres_open_group(dev
, bat_desc
, GFP_KERNEL
))
1343 n
= atomic_inc_return(&battery_no
) - 1;
1345 bat_desc
->properties
= wacom_battery_props
;
1346 bat_desc
->num_properties
= ARRAY_SIZE(wacom_battery_props
);
1347 bat_desc
->get_property
= wacom_battery_get_property
;
1348 sprintf(battery
->bat_name
, "wacom_battery_%ld", n
);
1349 bat_desc
->name
= battery
->bat_name
;
1350 bat_desc
->type
= POWER_SUPPLY_TYPE_BATTERY
;
1351 bat_desc
->use_for_apm
= 0;
1353 ac_desc
->properties
= wacom_ac_props
;
1354 ac_desc
->num_properties
= ARRAY_SIZE(wacom_ac_props
);
1355 ac_desc
->get_property
= wacom_ac_get_property
;
1356 sprintf(battery
->ac_name
, "wacom_ac_%ld", n
);
1357 ac_desc
->name
= battery
->ac_name
;
1358 ac_desc
->type
= POWER_SUPPLY_TYPE_MAINS
;
1359 ac_desc
->use_for_apm
= 0;
1361 ps_bat
= devm_power_supply_register(dev
, bat_desc
, &psy_cfg
);
1362 if (IS_ERR(ps_bat
)) {
1363 error
= PTR_ERR(ps_bat
);
1367 ps_ac
= devm_power_supply_register(dev
, ac_desc
, &psy_cfg
);
1368 if (IS_ERR(ps_ac
)) {
1369 error
= PTR_ERR(ps_ac
);
1373 power_supply_powers(ps_bat
, &wacom
->hdev
->dev
);
1374 power_supply_powers(ps_ac
, &wacom
->hdev
->dev
);
1376 battery
->battery
= ps_bat
;
1377 battery
->ac
= ps_ac
;
1379 devres_close_group(dev
, bat_desc
);
1383 devres_release_group(dev
, bat_desc
);
1387 static int wacom_initialize_battery(struct wacom
*wacom
)
1389 if (wacom
->wacom_wac
.features
.quirks
& WACOM_QUIRK_BATTERY
)
1390 return __wacom_initialize_battery(wacom
, &wacom
->battery
);
1395 static void wacom_destroy_battery(struct wacom
*wacom
)
1397 if (wacom
->battery
.battery
) {
1398 devres_release_group(&wacom
->hdev
->dev
,
1399 &wacom
->battery
.bat_desc
);
1400 wacom
->battery
.battery
= NULL
;
1401 wacom
->battery
.ac
= NULL
;
1405 static ssize_t
wacom_show_speed(struct device
*dev
,
1406 struct device_attribute
1409 struct hid_device
*hdev
= to_hid_device(dev
);
1410 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1412 return snprintf(buf
, PAGE_SIZE
, "%i\n", wacom
->wacom_wac
.bt_high_speed
);
1415 static ssize_t
wacom_store_speed(struct device
*dev
,
1416 struct device_attribute
*attr
,
1417 const char *buf
, size_t count
)
1419 struct hid_device
*hdev
= to_hid_device(dev
);
1420 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1423 if (kstrtou8(buf
, 0, &new_speed
))
1426 if (new_speed
!= 0 && new_speed
!= 1)
1429 wacom_bt_query_tablet_data(hdev
, new_speed
, &wacom
->wacom_wac
.features
);
1434 static DEVICE_ATTR(speed
, DEV_ATTR_RW_PERM
,
1435 wacom_show_speed
, wacom_store_speed
);
1438 static ssize_t
wacom_show_remote_mode(struct kobject
*kobj
,
1439 struct kobj_attribute
*kattr
,
1440 char *buf
, int index
)
1442 struct device
*dev
= kobj_to_dev(kobj
->parent
);
1443 struct hid_device
*hdev
= to_hid_device(dev
);
1444 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1447 mode
= wacom
->led
.groups
[index
].select
;
1448 if (mode
>= 0 && mode
< 3)
1449 return snprintf(buf
, PAGE_SIZE
, "%d\n", mode
);
1451 return snprintf(buf
, PAGE_SIZE
, "%d\n", -1);
1454 #define DEVICE_EKR_ATTR_GROUP(SET_ID) \
1455 static ssize_t wacom_show_remote##SET_ID##_mode(struct kobject *kobj, \
1456 struct kobj_attribute *kattr, char *buf) \
1458 return wacom_show_remote_mode(kobj, kattr, buf, SET_ID); \
1460 static struct kobj_attribute remote##SET_ID##_mode_attr = { \
1461 .attr = {.name = "remote_mode", \
1462 .mode = DEV_ATTR_RO_PERM}, \
1463 .show = wacom_show_remote##SET_ID##_mode, \
1465 static struct attribute *remote##SET_ID##_serial_attrs[] = { \
1466 &remote##SET_ID##_mode_attr.attr, \
1469 static struct attribute_group remote##SET_ID##_serial_group = { \
1471 .attrs = remote##SET_ID##_serial_attrs, \
1474 DEVICE_EKR_ATTR_GROUP(0);
1475 DEVICE_EKR_ATTR_GROUP(1);
1476 DEVICE_EKR_ATTR_GROUP(2);
1477 DEVICE_EKR_ATTR_GROUP(3);
1478 DEVICE_EKR_ATTR_GROUP(4);
1480 static int wacom_remote_create_attr_group(struct wacom
*wacom
, __u32 serial
,
1484 struct wacom_remote
*remote
= wacom
->remote
;
1486 remote
->remotes
[index
].group
.name
= devm_kasprintf(&wacom
->hdev
->dev
,
1489 if (!remote
->remotes
[index
].group
.name
)
1492 error
= __wacom_devm_sysfs_create_group(wacom
, remote
->remote_dir
,
1493 &remote
->remotes
[index
].group
);
1495 remote
->remotes
[index
].group
.name
= NULL
;
1496 hid_err(wacom
->hdev
,
1497 "cannot create sysfs group err: %d\n", error
);
1504 static int wacom_cmd_unpair_remote(struct wacom
*wacom
, unsigned char selector
)
1506 const size_t buf_size
= 2;
1510 buf
= kzalloc(buf_size
, GFP_KERNEL
);
1514 buf
[0] = WAC_CMD_DELETE_PAIRING
;
1517 retval
= wacom_set_report(wacom
->hdev
, HID_OUTPUT_REPORT
, buf
,
1518 buf_size
, WAC_CMD_RETRIES
);
1524 static ssize_t
wacom_store_unpair_remote(struct kobject
*kobj
,
1525 struct kobj_attribute
*attr
,
1526 const char *buf
, size_t count
)
1528 unsigned char selector
= 0;
1529 struct device
*dev
= kobj_to_dev(kobj
->parent
);
1530 struct hid_device
*hdev
= to_hid_device(dev
);
1531 struct wacom
*wacom
= hid_get_drvdata(hdev
);
1534 if (!strncmp(buf
, "*\n", 2)) {
1535 selector
= WAC_CMD_UNPAIR_ALL
;
1537 hid_info(wacom
->hdev
, "remote: unrecognized unpair code: %s\n",
1542 mutex_lock(&wacom
->lock
);
1544 err
= wacom_cmd_unpair_remote(wacom
, selector
);
1545 mutex_unlock(&wacom
->lock
);
1547 return err
< 0 ? err
: count
;
1550 static struct kobj_attribute unpair_remote_attr
= {
1551 .attr
= {.name
= "unpair_remote", .mode
= 0200},
1552 .store
= wacom_store_unpair_remote
,
1555 static const struct attribute
*remote_unpair_attrs
[] = {
1556 &unpair_remote_attr
.attr
,
1560 static void wacom_remotes_destroy(void *data
)
1562 struct wacom
*wacom
= data
;
1563 struct wacom_remote
*remote
= wacom
->remote
;
1568 kobject_put(remote
->remote_dir
);
1569 kfifo_free(&remote
->remote_fifo
);
1570 wacom
->remote
= NULL
;
1573 static int wacom_initialize_remotes(struct wacom
*wacom
)
1576 struct wacom_remote
*remote
;
1579 if (wacom
->wacom_wac
.features
.type
!= REMOTE
)
1582 remote
= devm_kzalloc(&wacom
->hdev
->dev
, sizeof(*wacom
->remote
),
1587 wacom
->remote
= remote
;
1589 spin_lock_init(&remote
->remote_lock
);
1591 error
= kfifo_alloc(&remote
->remote_fifo
,
1592 5 * sizeof(struct wacom_remote_data
),
1595 hid_err(wacom
->hdev
, "failed allocating remote_fifo\n");
1599 remote
->remotes
[0].group
= remote0_serial_group
;
1600 remote
->remotes
[1].group
= remote1_serial_group
;
1601 remote
->remotes
[2].group
= remote2_serial_group
;
1602 remote
->remotes
[3].group
= remote3_serial_group
;
1603 remote
->remotes
[4].group
= remote4_serial_group
;
1605 remote
->remote_dir
= kobject_create_and_add("wacom_remote",
1606 &wacom
->hdev
->dev
.kobj
);
1607 if (!remote
->remote_dir
)
1610 error
= sysfs_create_files(remote
->remote_dir
, remote_unpair_attrs
);
1613 hid_err(wacom
->hdev
,
1614 "cannot create sysfs group err: %d\n", error
);
1618 for (i
= 0; i
< WACOM_MAX_REMOTES
; i
++) {
1619 wacom
->led
.groups
[i
].select
= WACOM_STATUS_UNKNOWN
;
1620 remote
->remotes
[i
].serial
= 0;
1623 error
= devm_add_action_or_reset(&wacom
->hdev
->dev
,
1624 wacom_remotes_destroy
, wacom
);
1631 static struct input_dev
*wacom_allocate_input(struct wacom
*wacom
)
1633 struct input_dev
*input_dev
;
1634 struct hid_device
*hdev
= wacom
->hdev
;
1635 struct wacom_wac
*wacom_wac
= &(wacom
->wacom_wac
);
1637 input_dev
= devm_input_allocate_device(&hdev
->dev
);
1641 input_dev
->name
= wacom_wac
->features
.name
;
1642 input_dev
->phys
= hdev
->phys
;
1643 input_dev
->dev
.parent
= &hdev
->dev
;
1644 input_dev
->open
= wacom_open
;
1645 input_dev
->close
= wacom_close
;
1646 input_dev
->uniq
= hdev
->uniq
;
1647 input_dev
->id
.bustype
= hdev
->bus
;
1648 input_dev
->id
.vendor
= hdev
->vendor
;
1649 input_dev
->id
.product
= wacom_wac
->pid
? wacom_wac
->pid
: hdev
->product
;
1650 input_dev
->id
.version
= hdev
->version
;
1651 input_set_drvdata(input_dev
, wacom
);
1656 static int wacom_allocate_inputs(struct wacom
*wacom
)
1658 struct wacom_wac
*wacom_wac
= &(wacom
->wacom_wac
);
1660 wacom_wac
->pen_input
= wacom_allocate_input(wacom
);
1661 wacom_wac
->touch_input
= wacom_allocate_input(wacom
);
1662 wacom_wac
->pad_input
= wacom_allocate_input(wacom
);
1663 if (!wacom_wac
->pen_input
||
1664 !wacom_wac
->touch_input
||
1665 !wacom_wac
->pad_input
)
1668 wacom_wac
->pen_input
->name
= wacom_wac
->pen_name
;
1669 wacom_wac
->touch_input
->name
= wacom_wac
->touch_name
;
1670 wacom_wac
->pad_input
->name
= wacom_wac
->pad_name
;
1675 static int wacom_register_inputs(struct wacom
*wacom
)
1677 struct input_dev
*pen_input_dev
, *touch_input_dev
, *pad_input_dev
;
1678 struct wacom_wac
*wacom_wac
= &(wacom
->wacom_wac
);
1681 pen_input_dev
= wacom_wac
->pen_input
;
1682 touch_input_dev
= wacom_wac
->touch_input
;
1683 pad_input_dev
= wacom_wac
->pad_input
;
1685 if (!pen_input_dev
|| !touch_input_dev
|| !pad_input_dev
)
1688 error
= wacom_setup_pen_input_capabilities(pen_input_dev
, wacom_wac
);
1690 /* no pen in use on this interface */
1691 input_free_device(pen_input_dev
);
1692 wacom_wac
->pen_input
= NULL
;
1693 pen_input_dev
= NULL
;
1695 error
= input_register_device(pen_input_dev
);
1700 error
= wacom_setup_touch_input_capabilities(touch_input_dev
, wacom_wac
);
1702 /* no touch in use on this interface */
1703 input_free_device(touch_input_dev
);
1704 wacom_wac
->touch_input
= NULL
;
1705 touch_input_dev
= NULL
;
1707 error
= input_register_device(touch_input_dev
);
1712 error
= wacom_setup_pad_input_capabilities(pad_input_dev
, wacom_wac
);
1714 /* no pad in use on this interface */
1715 input_free_device(pad_input_dev
);
1716 wacom_wac
->pad_input
= NULL
;
1717 pad_input_dev
= NULL
;
1719 error
= input_register_device(pad_input_dev
);
1727 wacom_wac
->pad_input
= NULL
;
1728 wacom_wac
->touch_input
= NULL
;
1729 wacom_wac
->pen_input
= NULL
;
1734 * Not all devices report physical dimensions from HID.
1735 * Compute the default from hardcoded logical dimension
1736 * and resolution before driver overwrites them.
1738 static void wacom_set_default_phy(struct wacom_features
*features
)
1740 if (features
->x_resolution
) {
1741 features
->x_phy
= (features
->x_max
* 100) /
1742 features
->x_resolution
;
1743 features
->y_phy
= (features
->y_max
* 100) /
1744 features
->y_resolution
;
1748 static void wacom_calculate_res(struct wacom_features
*features
)
1750 /* set unit to "100th of a mm" for devices not reported by HID */
1751 if (!features
->unit
) {
1752 features
->unit
= 0x11;
1753 features
->unitExpo
= -3;
1756 features
->x_resolution
= wacom_calc_hid_res(features
->x_max
,
1759 features
->unitExpo
);
1760 features
->y_resolution
= wacom_calc_hid_res(features
->y_max
,
1763 features
->unitExpo
);
1766 void wacom_battery_work(struct work_struct
*work
)
1768 struct wacom
*wacom
= container_of(work
, struct wacom
, battery_work
);
1770 if ((wacom
->wacom_wac
.features
.quirks
& WACOM_QUIRK_BATTERY
) &&
1771 !wacom
->battery
.battery
) {
1772 wacom_initialize_battery(wacom
);
1774 else if (!(wacom
->wacom_wac
.features
.quirks
& WACOM_QUIRK_BATTERY
) &&
1775 wacom
->battery
.battery
) {
1776 wacom_destroy_battery(wacom
);
1780 static size_t wacom_compute_pktlen(struct hid_device
*hdev
)
1782 struct hid_report_enum
*report_enum
;
1783 struct hid_report
*report
;
1786 report_enum
= hdev
->report_enum
+ HID_INPUT_REPORT
;
1788 list_for_each_entry(report
, &report_enum
->report_list
, list
) {
1789 size_t report_size
= hid_report_len(report
);
1790 if (report_size
> size
)
1797 static void wacom_update_name(struct wacom
*wacom
, const char *suffix
)
1799 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1800 struct wacom_features
*features
= &wacom_wac
->features
;
1801 char name
[WACOM_NAME_MAX
];
1803 /* Generic devices name unspecified */
1804 if ((features
->type
== HID_GENERIC
) && !strcmp("Wacom HID", features
->name
)) {
1805 if (strstr(wacom
->hdev
->name
, "Wacom") ||
1806 strstr(wacom
->hdev
->name
, "wacom") ||
1807 strstr(wacom
->hdev
->name
, "WACOM")) {
1808 /* name is in HID descriptor, use it */
1809 strlcpy(name
, wacom
->hdev
->name
, sizeof(name
));
1811 /* strip out excess whitespaces */
1813 char *gap
= strstr(name
, " ");
1816 /* shift everything including the terminator */
1817 memmove(gap
, gap
+1, strlen(gap
));
1819 /* get rid of trailing whitespace */
1820 if (name
[strlen(name
)-1] == ' ')
1821 name
[strlen(name
)-1] = '\0';
1823 /* no meaningful name retrieved. use product ID */
1824 snprintf(name
, sizeof(name
),
1825 "%s %X", features
->name
, wacom
->hdev
->product
);
1828 strlcpy(name
, features
->name
, sizeof(name
));
1831 /* Append the device type to the name */
1832 snprintf(wacom_wac
->pen_name
, sizeof(wacom_wac
->pen_name
),
1833 "%s%s Pen", name
, suffix
);
1834 snprintf(wacom_wac
->touch_name
, sizeof(wacom_wac
->touch_name
),
1835 "%s%s Finger", name
, suffix
);
1836 snprintf(wacom_wac
->pad_name
, sizeof(wacom_wac
->pad_name
),
1837 "%s%s Pad", name
, suffix
);
1840 static void wacom_release_resources(struct wacom
*wacom
)
1842 struct hid_device
*hdev
= wacom
->hdev
;
1844 if (!wacom
->resources
)
1847 devres_release_group(&hdev
->dev
, wacom
);
1849 wacom
->resources
= false;
1851 wacom
->wacom_wac
.pen_input
= NULL
;
1852 wacom
->wacom_wac
.touch_input
= NULL
;
1853 wacom
->wacom_wac
.pad_input
= NULL
;
1856 static int wacom_parse_and_register(struct wacom
*wacom
, bool wireless
)
1858 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1859 struct wacom_features
*features
= &wacom_wac
->features
;
1860 struct hid_device
*hdev
= wacom
->hdev
;
1862 unsigned int connect_mask
= HID_CONNECT_HIDRAW
;
1864 features
->pktlen
= wacom_compute_pktlen(hdev
);
1865 if (features
->pktlen
> WACOM_PKGLEN_MAX
)
1868 if (!devres_open_group(&hdev
->dev
, wacom
, GFP_KERNEL
))
1871 wacom
->resources
= true;
1873 error
= wacom_allocate_inputs(wacom
);
1878 * Bamboo Pad has a generic hid handling for the Pen, and we switch it
1879 * into debug mode for the touch part.
1880 * We ignore the other interfaces.
1882 if (features
->type
== BAMBOO_PAD
) {
1883 if (features
->pktlen
== WACOM_PKGLEN_PENABLED
) {
1884 features
->type
= HID_GENERIC
;
1885 } else if ((features
->pktlen
!= WACOM_PKGLEN_BPAD_TOUCH
) &&
1886 (features
->pktlen
!= WACOM_PKGLEN_BPAD_TOUCH_USB
)) {
1892 /* set the default size in case we do not get them from hid */
1893 wacom_set_default_phy(features
);
1895 /* Retrieve the physical and logical size for touch devices */
1896 wacom_retrieve_hid_descriptor(hdev
, features
);
1897 wacom_setup_device_quirks(wacom
);
1899 if (features
->device_type
== WACOM_DEVICETYPE_NONE
&&
1900 features
->type
!= WIRELESS
) {
1901 error
= features
->type
== HID_GENERIC
? -ENODEV
: 0;
1903 dev_warn(&hdev
->dev
, "Unknown device_type for '%s'. %s.",
1905 error
? "Ignoring" : "Assuming pen");
1910 features
->device_type
|= WACOM_DEVICETYPE_PEN
;
1913 wacom_calculate_res(features
);
1915 wacom_update_name(wacom
, wireless
? " (WL)" : "");
1917 error
= wacom_add_shared_data(hdev
);
1921 if (!(features
->device_type
& WACOM_DEVICETYPE_WL_MONITOR
) &&
1922 (features
->quirks
& WACOM_QUIRK_BATTERY
)) {
1923 error
= wacom_initialize_battery(wacom
);
1928 error
= wacom_register_inputs(wacom
);
1932 if (wacom
->wacom_wac
.features
.device_type
& WACOM_DEVICETYPE_PAD
) {
1933 error
= wacom_initialize_leds(wacom
);
1937 error
= wacom_initialize_remotes(wacom
);
1942 if (features
->type
== HID_GENERIC
)
1943 connect_mask
|= HID_CONNECT_DRIVER
;
1945 /* Regular HID work starts now */
1946 error
= hid_hw_start(hdev
, connect_mask
);
1948 hid_err(hdev
, "hw start failed\n");
1953 /* Note that if query fails it is not a hard failure */
1954 wacom_query_tablet_data(hdev
, features
);
1957 /* touch only Bamboo doesn't support pen */
1958 if ((features
->type
== BAMBOO_TOUCH
) &&
1959 (features
->device_type
& WACOM_DEVICETYPE_PEN
)) {
1964 /* pen only Bamboo neither support touch nor pad */
1965 if ((features
->type
== BAMBOO_PEN
) &&
1966 ((features
->device_type
& WACOM_DEVICETYPE_TOUCH
) ||
1967 (features
->device_type
& WACOM_DEVICETYPE_PAD
))) {
1972 if (features
->device_type
& WACOM_DEVICETYPE_WL_MONITOR
)
1973 error
= hid_hw_open(hdev
);
1975 if ((wacom_wac
->features
.type
== INTUOSHT
||
1976 wacom_wac
->features
.type
== INTUOSHT2
) &&
1977 (wacom_wac
->features
.device_type
& WACOM_DEVICETYPE_TOUCH
)) {
1978 wacom_wac
->shared
->type
= wacom_wac
->features
.type
;
1979 wacom_wac
->shared
->touch_input
= wacom_wac
->touch_input
;
1982 devres_close_group(&hdev
->dev
, wacom
);
1989 wacom_release_resources(wacom
);
1993 static void wacom_wireless_work(struct work_struct
*work
)
1995 struct wacom
*wacom
= container_of(work
, struct wacom
, wireless_work
);
1996 struct usb_device
*usbdev
= wacom
->usbdev
;
1997 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
1998 struct hid_device
*hdev1
, *hdev2
;
1999 struct wacom
*wacom1
, *wacom2
;
2000 struct wacom_wac
*wacom_wac1
, *wacom_wac2
;
2004 * Regardless if this is a disconnect or a new tablet,
2005 * remove any existing input and battery devices.
2008 wacom_destroy_battery(wacom
);
2010 /* Stylus interface */
2011 hdev1
= usb_get_intfdata(usbdev
->config
->interface
[1]);
2012 wacom1
= hid_get_drvdata(hdev1
);
2013 wacom_wac1
= &(wacom1
->wacom_wac
);
2014 wacom_release_resources(wacom1
);
2016 /* Touch interface */
2017 hdev2
= usb_get_intfdata(usbdev
->config
->interface
[2]);
2018 wacom2
= hid_get_drvdata(hdev2
);
2019 wacom_wac2
= &(wacom2
->wacom_wac
);
2020 wacom_release_resources(wacom2
);
2022 if (wacom_wac
->pid
== 0) {
2023 hid_info(wacom
->hdev
, "wireless tablet disconnected\n");
2025 const struct hid_device_id
*id
= wacom_ids
;
2027 hid_info(wacom
->hdev
, "wireless tablet connected with PID %x\n",
2031 if (id
->vendor
== USB_VENDOR_ID_WACOM
&&
2032 id
->product
== wacom_wac
->pid
)
2038 hid_info(wacom
->hdev
, "ignoring unknown PID.\n");
2042 /* Stylus interface */
2043 wacom_wac1
->features
=
2044 *((struct wacom_features
*)id
->driver_data
);
2046 wacom_wac1
->pid
= wacom_wac
->pid
;
2048 error
= wacom_parse_and_register(wacom1
, true);
2052 /* Touch interface */
2053 if (wacom_wac1
->features
.touch_max
||
2054 (wacom_wac1
->features
.type
>= INTUOSHT
&&
2055 wacom_wac1
->features
.type
<= BAMBOO_PT
)) {
2056 wacom_wac2
->features
=
2057 *((struct wacom_features
*)id
->driver_data
);
2058 wacom_wac2
->pid
= wacom_wac
->pid
;
2060 error
= wacom_parse_and_register(wacom2
, true);
2065 error
= wacom_initialize_battery(wacom
);
2073 wacom_release_resources(wacom1
);
2074 wacom_release_resources(wacom2
);
2078 static void wacom_remote_destroy_one(struct wacom
*wacom
, unsigned int index
)
2080 struct wacom_remote
*remote
= wacom
->remote
;
2081 u32 serial
= remote
->remotes
[index
].serial
;
2083 unsigned long flags
;
2085 spin_lock_irqsave(&remote
->remote_lock
, flags
);
2086 remote
->remotes
[index
].registered
= false;
2087 spin_unlock_irqrestore(&remote
->remote_lock
, flags
);
2089 if (remote
->remotes
[index
].battery
.battery
)
2090 devres_release_group(&wacom
->hdev
->dev
,
2091 &remote
->remotes
[index
].battery
.bat_desc
);
2093 if (remote
->remotes
[index
].group
.name
)
2094 devres_release_group(&wacom
->hdev
->dev
,
2095 &remote
->remotes
[index
]);
2097 for (i
= 0; i
< WACOM_MAX_REMOTES
; i
++) {
2098 if (remote
->remotes
[i
].serial
== serial
) {
2099 remote
->remotes
[i
].serial
= 0;
2100 remote
->remotes
[i
].group
.name
= NULL
;
2101 remote
->remotes
[i
].registered
= false;
2102 remote
->remotes
[i
].battery
.battery
= NULL
;
2103 wacom
->led
.groups
[i
].select
= WACOM_STATUS_UNKNOWN
;
2108 static int wacom_remote_create_one(struct wacom
*wacom
, u32 serial
,
2111 struct wacom_remote
*remote
= wacom
->remote
;
2112 struct device
*dev
= &wacom
->hdev
->dev
;
2115 /* A remote can pair more than once with an EKR,
2116 * check to make sure this serial isn't already paired.
2118 for (k
= 0; k
< WACOM_MAX_REMOTES
; k
++) {
2119 if (remote
->remotes
[k
].serial
== serial
)
2123 if (k
< WACOM_MAX_REMOTES
) {
2124 remote
->remotes
[index
].serial
= serial
;
2128 if (!devres_open_group(dev
, &remote
->remotes
[index
], GFP_KERNEL
))
2131 error
= wacom_remote_create_attr_group(wacom
, serial
, index
);
2135 remote
->remotes
[index
].input
= wacom_allocate_input(wacom
);
2136 if (!remote
->remotes
[index
].input
) {
2140 remote
->remotes
[index
].input
->uniq
= remote
->remotes
[index
].group
.name
;
2141 remote
->remotes
[index
].input
->name
= wacom
->wacom_wac
.pad_name
;
2143 if (!remote
->remotes
[index
].input
->name
) {
2148 error
= wacom_setup_pad_input_capabilities(remote
->remotes
[index
].input
,
2153 remote
->remotes
[index
].serial
= serial
;
2155 error
= input_register_device(remote
->remotes
[index
].input
);
2159 error
= wacom_led_groups_alloc_and_register_one(
2160 &remote
->remotes
[index
].input
->dev
,
2161 wacom
, index
, 3, true);
2165 remote
->remotes
[index
].registered
= true;
2167 devres_close_group(dev
, &remote
->remotes
[index
]);
2171 devres_release_group(dev
, &remote
->remotes
[index
]);
2172 remote
->remotes
[index
].serial
= 0;
2176 static int wacom_remote_attach_battery(struct wacom
*wacom
, int index
)
2178 struct wacom_remote
*remote
= wacom
->remote
;
2181 if (!remote
->remotes
[index
].registered
)
2184 if (remote
->remotes
[index
].battery
.battery
)
2187 if (wacom
->led
.groups
[index
].select
== WACOM_STATUS_UNKNOWN
)
2190 error
= __wacom_initialize_battery(wacom
,
2191 &wacom
->remote
->remotes
[index
].battery
);
2198 static void wacom_remote_work(struct work_struct
*work
)
2200 struct wacom
*wacom
= container_of(work
, struct wacom
, remote_work
);
2201 struct wacom_remote
*remote
= wacom
->remote
;
2202 struct wacom_remote_data data
;
2203 unsigned long flags
;
2208 spin_lock_irqsave(&remote
->remote_lock
, flags
);
2210 count
= kfifo_out(&remote
->remote_fifo
, &data
, sizeof(data
));
2212 if (count
!= sizeof(data
)) {
2213 hid_err(wacom
->hdev
,
2214 "workitem triggered without status available\n");
2215 spin_unlock_irqrestore(&remote
->remote_lock
, flags
);
2219 if (!kfifo_is_empty(&remote
->remote_fifo
))
2220 wacom_schedule_work(&wacom
->wacom_wac
, WACOM_WORKER_REMOTE
);
2222 spin_unlock_irqrestore(&remote
->remote_lock
, flags
);
2224 for (i
= 0; i
< WACOM_MAX_REMOTES
; i
++) {
2225 serial
= data
.remote
[i
].serial
;
2226 if (data
.remote
[i
].connected
) {
2228 if (remote
->remotes
[i
].serial
== serial
) {
2229 wacom_remote_attach_battery(wacom
, i
);
2233 if (remote
->remotes
[i
].serial
)
2234 wacom_remote_destroy_one(wacom
, i
);
2236 wacom_remote_create_one(wacom
, serial
, i
);
2238 } else if (remote
->remotes
[i
].serial
) {
2239 wacom_remote_destroy_one(wacom
, i
);
2244 static int wacom_probe(struct hid_device
*hdev
,
2245 const struct hid_device_id
*id
)
2247 struct usb_interface
*intf
= to_usb_interface(hdev
->dev
.parent
);
2248 struct usb_device
*dev
= interface_to_usbdev(intf
);
2249 struct wacom
*wacom
;
2250 struct wacom_wac
*wacom_wac
;
2251 struct wacom_features
*features
;
2254 if (!id
->driver_data
)
2257 hdev
->quirks
|= HID_QUIRK_NO_INIT_REPORTS
;
2259 /* hid-core sets this quirk for the boot interface */
2260 hdev
->quirks
&= ~HID_QUIRK_NOGET
;
2262 wacom
= devm_kzalloc(&hdev
->dev
, sizeof(struct wacom
), GFP_KERNEL
);
2266 hid_set_drvdata(hdev
, wacom
);
2269 wacom_wac
= &wacom
->wacom_wac
;
2270 wacom_wac
->features
= *((struct wacom_features
*)id
->driver_data
);
2271 features
= &wacom_wac
->features
;
2273 if (features
->check_for_hid_type
&& features
->hid_type
!= hdev
->type
) {
2278 wacom_wac
->hid_data
.inputmode
= -1;
2279 wacom_wac
->mode_report
= -1;
2281 wacom
->usbdev
= dev
;
2283 mutex_init(&wacom
->lock
);
2284 INIT_WORK(&wacom
->wireless_work
, wacom_wireless_work
);
2285 INIT_WORK(&wacom
->battery_work
, wacom_battery_work
);
2286 INIT_WORK(&wacom
->remote_work
, wacom_remote_work
);
2288 /* ask for the report descriptor to be loaded by HID */
2289 error
= hid_parse(hdev
);
2291 hid_err(hdev
, "parse failed\n");
2295 error
= wacom_parse_and_register(wacom
, false);
2299 if (hdev
->bus
== BUS_BLUETOOTH
) {
2300 error
= device_create_file(&hdev
->dev
, &dev_attr_speed
);
2303 "can't create sysfs speed attribute err: %d\n",
2310 hid_set_drvdata(hdev
, NULL
);
2314 static void wacom_remove(struct hid_device
*hdev
)
2316 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2317 struct wacom_wac
*wacom_wac
= &wacom
->wacom_wac
;
2318 struct wacom_features
*features
= &wacom_wac
->features
;
2320 if (features
->device_type
& WACOM_DEVICETYPE_WL_MONITOR
)
2325 cancel_work_sync(&wacom
->wireless_work
);
2326 cancel_work_sync(&wacom
->battery_work
);
2327 cancel_work_sync(&wacom
->remote_work
);
2328 if (hdev
->bus
== BUS_BLUETOOTH
)
2329 device_remove_file(&hdev
->dev
, &dev_attr_speed
);
2331 hid_set_drvdata(hdev
, NULL
);
2335 static int wacom_resume(struct hid_device
*hdev
)
2337 struct wacom
*wacom
= hid_get_drvdata(hdev
);
2338 struct wacom_features
*features
= &wacom
->wacom_wac
.features
;
2340 mutex_lock(&wacom
->lock
);
2342 /* switch to wacom mode first */
2343 wacom_query_tablet_data(hdev
, features
);
2344 wacom_led_control(wacom
);
2346 mutex_unlock(&wacom
->lock
);
2351 static int wacom_reset_resume(struct hid_device
*hdev
)
2353 return wacom_resume(hdev
);
2355 #endif /* CONFIG_PM */
2357 static struct hid_driver wacom_driver
= {
2359 .id_table
= wacom_ids
,
2360 .probe
= wacom_probe
,
2361 .remove
= wacom_remove
,
2362 .report
= wacom_wac_report
,
2364 .resume
= wacom_resume
,
2365 .reset_resume
= wacom_reset_resume
,
2367 .raw_event
= wacom_raw_event
,
2369 module_hid_driver(wacom_driver
);
2371 MODULE_VERSION(DRIVER_VERSION
);
2372 MODULE_AUTHOR(DRIVER_AUTHOR
);
2373 MODULE_DESCRIPTION(DRIVER_DESC
);
2374 MODULE_LICENSE(DRIVER_LICENSE
);