Lines Matching +full:remote +full:- +full:pid
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * USB Wacom tablet support - system specific code
25 } while ((retval == -ETIMEDOUT || retval == -EAGAIN) && --retries); in wacom_get_report()
42 } while ((retval == -ETIMEDOUT || retval == -EAGAIN) && --retries); in wacom_set_report()
107 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_wac_pen_serial_enforce()
108 struct wacom_features *features = &wacom_wac->features; in wacom_wac_pen_serial_enforce()
113 if (wacom_wac->serial[0] || !(features->quirks & WACOM_QUIRK_TOOLSERIAL)) in wacom_wac_pen_serial_enforce()
117 for (i = 0; i < report->maxfield; i++) { in wacom_wac_pen_serial_enforce()
118 for (j = 0; j < report->field[i]->maxusage; j++) { in wacom_wac_pen_serial_enforce()
119 struct hid_field *field = report->field[i]; in wacom_wac_pen_serial_enforce()
120 struct hid_usage *usage = &field->usage[j]; in wacom_wac_pen_serial_enforce()
121 unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid); in wacom_wac_pen_serial_enforce()
132 offset = field->report_offset; in wacom_wac_pen_serial_enforce()
133 size = field->report_size; in wacom_wac_pen_serial_enforce()
144 wacom_wac->serial[0] = value; in wacom_wac_pen_serial_enforce()
148 wacom_wac->serial[0] |= ((__u64)value) << 32; in wacom_wac_pen_serial_enforce()
152 wacom_wac->id[0] = value; in wacom_wac_pen_serial_enforce()
163 wacom_wac_queue_flush(hdev, wacom_wac->pen_fifo); in wacom_wac_pen_serial_enforce()
165 wacom_wac_queue_insert(hdev, wacom_wac->pen_fifo, in wacom_wac_pen_serial_enforce()
176 if (wacom->wacom_wac.features.type == BOOTLOADER) in wacom_raw_event()
180 return -1; in wacom_raw_event()
182 wacom->wacom_wac.data = raw_data; in wacom_raw_event()
184 wacom_wac_irq(&wacom->wacom_wac, size); in wacom_raw_event()
193 return hid_hw_open(wacom->hdev); in wacom_open()
201 * wacom->hdev should never be null, but surprisingly, I had the case in wacom_close()
204 if (wacom->hdev) in wacom_close()
205 hid_hw_close(wacom->hdev); in wacom_close()
228 struct wacom_features *features = &wacom->wacom_wac.features; in wacom_hid_usage_quirk()
229 unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid); in wacom_hid_usage_quirk()
232 * The Dell Canvas 27 needs to be switched to its vendor-defined in wacom_hid_usage_quirk()
235 if (hdev->vendor == USB_VENDOR_ID_WACOM && in wacom_hid_usage_quirk()
236 hdev->product == 0x4200 && in wacom_hid_usage_quirk()
237 field->application == HID_UP_MSVENDOR) { in wacom_hid_usage_quirk()
238 wacom->wacom_wac.mode_report = field->report->id; in wacom_hid_usage_quirk()
239 wacom->wacom_wac.mode_value = 2; in wacom_hid_usage_quirk()
250 if (features->type == HID_GENERIC && in wacom_hid_usage_quirk()
251 usage->hid == 0x000D0000 && in wacom_hid_usage_quirk()
252 field->application == HID_DG_PEN && in wacom_hid_usage_quirk()
253 field->physical == HID_DG_STYLUS) { in wacom_hid_usage_quirk()
254 int i = usage->usage_index; in wacom_hid_usage_quirk()
256 if (i-4 >= 0 && i+1 < field->maxusage && in wacom_hid_usage_quirk()
257 field->usage[i-4].hid == HID_DG_TIPSWITCH && in wacom_hid_usage_quirk()
258 field->usage[i-3].hid == HID_DG_BARRELSWITCH && in wacom_hid_usage_quirk()
259 field->usage[i-2].hid == HID_DG_ERASER && in wacom_hid_usage_quirk()
260 field->usage[i-1].hid == HID_DG_INVERT && in wacom_hid_usage_quirk()
261 field->usage[i+1].hid == HID_DG_INRANGE) { in wacom_hid_usage_quirk()
262 usage->hid = HID_DG_BARRELSWITCH2; in wacom_hid_usage_quirk()
267 * Wacom's AES devices use different vendor-defined usages to in wacom_hid_usage_quirk()
269 * hardware. The usages are also sometimes ill-defined and do in wacom_hid_usage_quirk()
274 if (usage->hid == WACOM_HID_WT_SERIALNUMBER && in wacom_hid_usage_quirk()
275 field->report_size == 16 && in wacom_hid_usage_quirk()
276 field->index + 2 < field->report->maxfield) { in wacom_hid_usage_quirk()
277 struct hid_field *a = field->report->field[field->index + 1]; in wacom_hid_usage_quirk()
278 struct hid_field *b = field->report->field[field->index + 2]; in wacom_hid_usage_quirk()
280 if (a->maxusage > 0 && in wacom_hid_usage_quirk()
281 a->usage[0].hid == HID_DG_TOOLSERIALNUMBER && in wacom_hid_usage_quirk()
282 a->report_size == 32 && in wacom_hid_usage_quirk()
283 b->maxusage > 0 && in wacom_hid_usage_quirk()
284 b->usage[0].hid == 0xFF000000 && in wacom_hid_usage_quirk()
285 b->report_size == 8) { in wacom_hid_usage_quirk()
286 features->quirks |= WACOM_QUIRK_AESPEN; in wacom_hid_usage_quirk()
287 usage->hid = WACOM_HID_WD_TOOLTYPE; in wacom_hid_usage_quirk()
288 field->logical_minimum = S16_MIN; in wacom_hid_usage_quirk()
289 field->logical_maximum = S16_MAX; in wacom_hid_usage_quirk()
290 a->logical_minimum = S32_MIN; in wacom_hid_usage_quirk()
291 a->logical_maximum = S32_MAX; in wacom_hid_usage_quirk()
292 b->usage[0].hid = WACOM_HID_WD_SERIALHI; in wacom_hid_usage_quirk()
293 b->logical_minimum = 0; in wacom_hid_usage_quirk()
294 b->logical_maximum = U8_MAX; in wacom_hid_usage_quirk()
298 /* 2nd-generation Intuos Pro Large has incorrect Y maximum */ in wacom_hid_usage_quirk()
299 if (hdev->vendor == USB_VENDOR_ID_WACOM && in wacom_hid_usage_quirk()
300 hdev->product == 0x0358 && in wacom_hid_usage_quirk()
303 field->logical_maximum = 43200; in wacom_hid_usage_quirk()
311 struct wacom_features *features = &wacom->wacom_wac.features; in wacom_feature_mapping()
312 struct hid_data *hid_data = &wacom->wacom_wac.hid_data; in wacom_feature_mapping()
313 unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid); in wacom_feature_mapping()
322 wacom->generic_has_leds = true; in wacom_feature_mapping()
326 if (!features->touch_max) { in wacom_feature_mapping()
328 n = hid_report_len(field->report); in wacom_feature_mapping()
329 data = hid_alloc_report_buf(field->report, GFP_KERNEL); in wacom_feature_mapping()
332 data[0] = field->report->id; in wacom_feature_mapping()
335 if (ret == n && features->type == HID_GENERIC) { in wacom_feature_mapping()
338 } else if (ret == 2 && features->type != HID_GENERIC) { in wacom_feature_mapping()
339 features->touch_max = data[1]; in wacom_feature_mapping()
341 features->touch_max = 16; in wacom_feature_mapping()
345 features->touch_max); in wacom_feature_mapping()
352 if (usage->usage_index >= field->report_count) { in wacom_feature_mapping()
353 dev_err(&hdev->dev, "HID_DG_INPUTMODE out of range\n"); in wacom_feature_mapping()
357 hid_data->inputmode = field->report->id; in wacom_feature_mapping()
358 hid_data->inputmode_index = usage->usage_index; in wacom_feature_mapping()
362 if (field->report->id == 0x0B && in wacom_feature_mapping()
363 (field->application == WACOM_HID_G9_PEN || in wacom_feature_mapping()
364 field->application == WACOM_HID_G11_PEN)) { in wacom_feature_mapping()
365 wacom->wacom_wac.mode_report = field->report->id; in wacom_feature_mapping()
366 wacom->wacom_wac.mode_value = 0; in wacom_feature_mapping()
371 wacom->wacom_wac.mode_report = field->report->id; in wacom_feature_mapping()
372 wacom->wacom_wac.mode_value = 2; in wacom_feature_mapping()
377 if (field->report->id == 0x03 && in wacom_feature_mapping()
378 (field->application == WACOM_HID_G9_TOUCHSCREEN || in wacom_feature_mapping()
379 field->application == WACOM_HID_G11_TOUCHSCREEN)) { in wacom_feature_mapping()
380 wacom->wacom_wac.mode_report = field->report->id; in wacom_feature_mapping()
381 wacom->wacom_wac.mode_value = 0; in wacom_feature_mapping()
389 n = hid_report_len(field->report); in wacom_feature_mapping()
390 data = hid_alloc_report_buf(field->report, GFP_KERNEL); in wacom_feature_mapping()
393 data[0] = field->report->id; in wacom_feature_mapping()
428 * If it happens to define a Digitizer-Stylus Physical Collection then
432 * Digitizer-Finger Physical Collection which will define both logical
444 struct wacom_features *features = &wacom->wacom_wac.features; in wacom_usage_mapping()
447 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); in wacom_usage_mapping()
455 features->device_type |= WACOM_DEVICETYPE_PEN; in wacom_usage_mapping()
457 features->device_type |= WACOM_DEVICETYPE_TOUCH; in wacom_usage_mapping()
465 features->x_max = field->logical_maximum; in wacom_usage_mapping()
467 features->x_phy = field->physical_maximum; in wacom_usage_mapping()
468 if ((features->type != BAMBOO_PT) && in wacom_usage_mapping()
469 (features->type != BAMBOO_TOUCH)) { in wacom_usage_mapping()
470 features->unit = field->unit; in wacom_usage_mapping()
471 features->unitExpo = field->unit_exponent; in wacom_usage_mapping()
476 features->y_max = field->logical_maximum; in wacom_usage_mapping()
478 features->y_phy = field->physical_maximum; in wacom_usage_mapping()
479 if ((features->type != BAMBOO_PT) && in wacom_usage_mapping()
480 (features->type != BAMBOO_TOUCH)) { in wacom_usage_mapping()
481 features->unit = field->unit; in wacom_usage_mapping()
482 features->unitExpo = field->unit_exponent; in wacom_usage_mapping()
488 features->pressure_max = field->logical_maximum; in wacom_usage_mapping()
492 if (features->type == HID_GENERIC) in wacom_usage_mapping()
500 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_post_parse_hid()
502 if (features->type == HID_GENERIC) { in wacom_post_parse_hid()
503 /* Any last-minute generic device setup */ in wacom_post_parse_hid()
504 if (wacom_wac->has_mode_change) { in wacom_post_parse_hid()
505 if (wacom_wac->is_direct_mode) in wacom_post_parse_hid()
506 features->device_type |= WACOM_DEVICETYPE_DIRECT; in wacom_post_parse_hid()
508 features->device_type &= ~WACOM_DEVICETYPE_DIRECT; in wacom_post_parse_hid()
511 if (features->touch_max > 1) { in wacom_post_parse_hid()
512 if (features->device_type & WACOM_DEVICETYPE_DIRECT) in wacom_post_parse_hid()
513 input_mt_init_slots(wacom_wac->touch_input, in wacom_post_parse_hid()
514 wacom_wac->features.touch_max, in wacom_post_parse_hid()
517 input_mt_init_slots(wacom_wac->touch_input, in wacom_post_parse_hid()
518 wacom_wac->features.touch_max, in wacom_post_parse_hid()
532 rep_enum = &hdev->report_enum[HID_FEATURE_REPORT]; in wacom_parse_hid()
533 list_for_each_entry(hreport, &rep_enum->report_list, list) { in wacom_parse_hid()
534 for (i = 0; i < hreport->maxfield; i++) { in wacom_parse_hid()
536 if (hreport->field[i]->report_count < 1) in wacom_parse_hid()
539 for (j = 0; j < hreport->field[i]->maxusage; j++) { in wacom_parse_hid()
540 wacom_feature_mapping(hdev, hreport->field[i], in wacom_parse_hid()
541 hreport->field[i]->usage + j); in wacom_parse_hid()
547 rep_enum = &hdev->report_enum[HID_INPUT_REPORT]; in wacom_parse_hid()
548 list_for_each_entry(hreport, &rep_enum->report_list, list) { in wacom_parse_hid()
550 if (!hreport->maxfield) in wacom_parse_hid()
553 for (i = 0; i < hreport->maxfield; i++) in wacom_parse_hid()
554 for (j = 0; j < hreport->field[i]->maxusage; j++) in wacom_parse_hid()
555 wacom_usage_mapping(hdev, hreport->field[i], in wacom_parse_hid()
556 hreport->field[i]->usage + j); in wacom_parse_hid()
565 struct hid_data *hid_data = &wacom->wacom_wac.hid_data; in wacom_hid_set_device_mode()
569 if (hid_data->inputmode < 0) in wacom_hid_set_device_mode()
572 re = &(hdev->report_enum[HID_FEATURE_REPORT]); in wacom_hid_set_device_mode()
573 r = re->report_id_hash[hid_data->inputmode]; in wacom_hid_set_device_mode()
575 r->field[0]->value[hid_data->inputmode_index] = 2; in wacom_hid_set_device_mode()
588 int error = -ENOMEM, limit = 0; in wacom_set_device_mode()
590 if (wacom_wac->mode_report < 0) in wacom_set_device_mode()
593 re = &(hdev->report_enum[HID_FEATURE_REPORT]); in wacom_set_device_mode()
594 r = re->report_id_hash[wacom_wac->mode_report]; in wacom_set_device_mode()
596 return -EINVAL; in wacom_set_device_mode()
600 return -ENOMEM; in wacom_set_device_mode()
605 rep_data[0] = wacom_wac->mode_report; in wacom_set_device_mode()
606 rep_data[1] = wacom_wac->mode_value; in wacom_set_device_mode()
614 rep_data[1] != wacom_wac->mode_report && in wacom_set_device_mode()
629 switch (features->type) { in wacom_bt_query_tablet_data()
644 wacom->wacom_wac.bt_high_speed = speed; in wacom_bt_query_tablet_data()
658 wacom->wacom_wac.bt_features &= ~0x20; in wacom_bt_query_tablet_data()
660 wacom->wacom_wac.bt_features |= 0x20; in wacom_bt_query_tablet_data()
663 rep_data[1] = wacom->wacom_wac.bt_features; in wacom_bt_query_tablet_data()
668 wacom->wacom_wac.bt_high_speed = speed; in wacom_bt_query_tablet_data()
676 * Switch the tablet into its most-capable mode. Wacom tablets are
677 * typically configured to power-up in a mode which sends mouse-like
684 struct hid_device *hdev = wacom->hdev; in _wacom_query_tablet_data()
685 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in _wacom_query_tablet_data()
686 struct wacom_features *features = &wacom_wac->features; in _wacom_query_tablet_data()
688 if (hdev->bus == BUS_BLUETOOTH) in _wacom_query_tablet_data()
691 if (features->type != HID_GENERIC) { in _wacom_query_tablet_data()
692 if (features->device_type & WACOM_DEVICETYPE_TOUCH) { in _wacom_query_tablet_data()
693 if (features->type > TABLETPC) { in _wacom_query_tablet_data()
695 wacom_wac->mode_report = 3; in _wacom_query_tablet_data()
696 wacom_wac->mode_value = 4; in _wacom_query_tablet_data()
697 } else if (features->type == WACOM_24HDT) { in _wacom_query_tablet_data()
698 wacom_wac->mode_report = 18; in _wacom_query_tablet_data()
699 wacom_wac->mode_value = 2; in _wacom_query_tablet_data()
700 } else if (features->type == WACOM_27QHDT) { in _wacom_query_tablet_data()
701 wacom_wac->mode_report = 131; in _wacom_query_tablet_data()
702 wacom_wac->mode_value = 2; in _wacom_query_tablet_data()
703 } else if (features->type == BAMBOO_PAD) { in _wacom_query_tablet_data()
704 wacom_wac->mode_report = 2; in _wacom_query_tablet_data()
705 wacom_wac->mode_value = 2; in _wacom_query_tablet_data()
707 } else if (features->device_type & WACOM_DEVICETYPE_PEN) { in _wacom_query_tablet_data()
708 if (features->type <= BAMBOO_PT) { in _wacom_query_tablet_data()
709 wacom_wac->mode_report = 2; in _wacom_query_tablet_data()
710 wacom_wac->mode_value = 2; in _wacom_query_tablet_data()
717 if (features->type == HID_GENERIC) in _wacom_query_tablet_data()
727 struct usb_interface *intf = wacom->intf; in wacom_retrieve_hid_descriptor()
730 features->x_fuzz = 4; in wacom_retrieve_hid_descriptor()
731 features->y_fuzz = 4; in wacom_retrieve_hid_descriptor()
732 features->pressure_fuzz = 0; in wacom_retrieve_hid_descriptor()
733 features->distance_fuzz = 1; in wacom_retrieve_hid_descriptor()
734 features->tilt_fuzz = 1; in wacom_retrieve_hid_descriptor()
742 if (features->type == WIRELESS && intf) { in wacom_retrieve_hid_descriptor()
743 if (intf->cur_altsetting->desc.bInterfaceNumber == 0) in wacom_retrieve_hid_descriptor()
744 features->device_type = WACOM_DEVICETYPE_WL_MONITOR; in wacom_retrieve_hid_descriptor()
746 features->device_type = WACOM_DEVICETYPE_NONE; in wacom_retrieve_hid_descriptor()
767 struct wacom_features *features = &wacom->wacom_wac.features; in wacom_are_sibling()
769 struct wacom_features *sibling_features = &sibling_wacom->wacom_wac.features; in wacom_are_sibling()
770 __u32 oVid = features->oVid ? features->oVid : hdev->vendor; in wacom_are_sibling()
771 __u32 oPid = features->oPid ? features->oPid : hdev->product; in wacom_are_sibling()
774 if (features->oVid != HID_ANY_ID && sibling->vendor != oVid) in wacom_are_sibling()
776 if (features->oPid != HID_ANY_ID && sibling->product != oPid) in wacom_are_sibling()
780 * Devices with the same VID/PID must share the same physical in wacom_are_sibling()
781 * device path, while those with different VID/PID must share in wacom_are_sibling()
784 if (hdev->vendor == sibling->vendor && hdev->product == sibling->product) { in wacom_are_sibling()
793 if (features->type != HID_GENERIC) in wacom_are_sibling()
797 * Direct-input devices may not be siblings of indirect-input in wacom_are_sibling()
800 if ((features->device_type & WACOM_DEVICETYPE_DIRECT) && in wacom_are_sibling()
801 !(sibling_features->device_type & WACOM_DEVICETYPE_DIRECT)) in wacom_are_sibling()
805 * Indirect-input devices may not be siblings of direct-input in wacom_are_sibling()
808 if (!(features->device_type & WACOM_DEVICETYPE_DIRECT) && in wacom_are_sibling()
809 (sibling_features->device_type & WACOM_DEVICETYPE_DIRECT)) in wacom_are_sibling()
813 if ((features->device_type & WACOM_DEVICETYPE_PEN) && in wacom_are_sibling()
814 !(sibling_features->device_type & WACOM_DEVICETYPE_TOUCH)) in wacom_are_sibling()
818 if ((features->device_type & WACOM_DEVICETYPE_TOUCH) && in wacom_are_sibling()
819 !(sibling_features->device_type & WACOM_DEVICETYPE_PEN)) in wacom_are_sibling()
833 /* Try to find an already-probed interface from the same device */ in wacom_get_hdev_data()
835 if (hid_compare_device_paths(hdev, data->dev, '/')) { in wacom_get_hdev_data()
836 kref_get(&data->kref); in wacom_get_hdev_data()
843 if (wacom_are_sibling(hdev, data->dev)) { in wacom_get_hdev_data()
844 kref_get(&data->kref); in wacom_get_hdev_data()
858 list_del(&data->list); in wacom_release_shared_data()
868 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_remove_shared_data()
870 if (wacom_wac->shared) { in wacom_remove_shared_data()
871 data = container_of(wacom_wac->shared, struct wacom_hdev_data, in wacom_remove_shared_data()
874 if (wacom_wac->shared->touch == wacom->hdev) in wacom_remove_shared_data()
875 wacom_wac->shared->touch = NULL; in wacom_remove_shared_data()
876 else if (wacom_wac->shared->pen == wacom->hdev) in wacom_remove_shared_data()
877 wacom_wac->shared->pen = NULL; in wacom_remove_shared_data()
879 kref_put(&data->kref, wacom_release_shared_data); in wacom_remove_shared_data()
880 wacom_wac->shared = NULL; in wacom_remove_shared_data()
887 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_add_shared_data()
898 return -ENOMEM; in wacom_add_shared_data()
901 kref_init(&data->kref); in wacom_add_shared_data()
902 data->dev = hdev; in wacom_add_shared_data()
903 list_add_tail(&data->list, &wacom_udev_list); in wacom_add_shared_data()
908 wacom_wac->shared = &data->shared; in wacom_add_shared_data()
910 retval = devm_add_action_or_reset(&hdev->dev, wacom_remove_shared_data, wacom); in wacom_add_shared_data()
914 if (wacom_wac->features.device_type & WACOM_DEVICETYPE_TOUCH) in wacom_add_shared_data()
915 wacom_wac->shared->touch = hdev; in wacom_add_shared_data()
916 else if (wacom_wac->features.device_type & WACOM_DEVICETYPE_PEN) in wacom_add_shared_data()
917 wacom_wac->shared->pen = hdev; in wacom_add_shared_data()
929 if (!wacom->led.groups) in wacom_led_control()
930 return -ENOTSUPP; in wacom_led_control()
932 if (wacom->wacom_wac.features.type == REMOTE) in wacom_led_control()
933 return -ENOTSUPP; in wacom_led_control()
935 if (wacom->wacom_wac.pid) { /* wireless connected */ in wacom_led_control()
939 else if (wacom->wacom_wac.features.type == INTUOSP2_BT) { in wacom_led_control()
945 return -ENOMEM; in wacom_led_control()
947 if (wacom->wacom_wac.features.type == HID_GENERIC) { in wacom_led_control()
949 buf[1] = wacom->led.llv; in wacom_led_control()
950 buf[2] = wacom->led.groups[0].select & 0x03; in wacom_led_control()
952 } else if ((wacom->wacom_wac.features.type >= INTUOS5S && in wacom_led_control()
953 wacom->wacom_wac.features.type <= INTUOSPL)) { in wacom_led_control()
959 int ring_led = wacom->led.groups[0].select & 0x03; in wacom_led_control()
960 int ring_lum = (((wacom->led.llv & 0x60) >> 5) - 1) & 0x03; in wacom_led_control()
965 if (wacom->wacom_wac.pid) { in wacom_led_control()
966 wacom_get_report(wacom->hdev, HID_FEATURE_REPORT, in wacom_led_control()
973 else if (wacom->wacom_wac.features.type == INTUOSP2_BT) { in wacom_led_control()
980 buf[9] = wacom->led.llv; in wacom_led_control()
981 buf[10] = wacom->led.groups[0].select & 0x03; in wacom_led_control()
984 int led = wacom->led.groups[0].select | 0x4; in wacom_led_control()
986 if (wacom->wacom_wac.features.type == WACOM_21UX2 || in wacom_led_control()
987 wacom->wacom_wac.features.type == WACOM_24HD) in wacom_led_control()
988 led |= (wacom->led.groups[1].select << 4) | 0x40; in wacom_led_control()
992 buf[2] = wacom->led.llv; in wacom_led_control()
993 buf[3] = wacom->led.hlv; in wacom_led_control()
994 buf[4] = wacom->led.img_lum; in wacom_led_control()
997 retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, buf, buf_size, in wacom_led_control()
1013 return -ENOMEM; in wacom_led_putimage()
1018 retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, buf, 2, in wacom_led_putimage()
1029 retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, in wacom_led_putimage()
1038 wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, buf, 2, in wacom_led_putimage()
1058 mutex_lock(&wacom->lock); in wacom_led_select_store()
1060 wacom->led.groups[set_id].select = id & 0x3; in wacom_led_select_store()
1063 mutex_unlock(&wacom->lock); in wacom_led_select_store()
1080 wacom->led.groups[SET_ID].select); \
1099 mutex_lock(&wacom->lock); in wacom_luminance_store()
1102 for (unsigned int i = 0; i < wacom->led.count; i++) { in wacom_luminance_store()
1103 struct wacom_group_leds *group = &wacom->led.groups[i]; in wacom_luminance_store()
1105 for (unsigned int j = 0; j < group->count; j++) { in wacom_luminance_store()
1106 if (dest == &wacom->led.llv) in wacom_luminance_store()
1107 group->leds[j].llv = *dest; in wacom_luminance_store()
1108 else if (dest == &wacom->led.hlv) in wacom_luminance_store()
1109 group->leds[j].hlv = *dest; in wacom_luminance_store()
1115 mutex_unlock(&wacom->lock); in wacom_luminance_store()
1127 return wacom_luminance_store(wacom, &wacom->led.field, \
1134 return scnprintf(buf, PAGE_SIZE, "%d\n", wacom->led.field); \
1153 if (hdev->bus == BUS_BLUETOOTH) { in wacom_button_image_store()
1162 return -EINVAL; in wacom_button_image_store()
1164 mutex_lock(&wacom->lock); in wacom_button_image_store()
1168 mutex_unlock(&wacom->lock); in wacom_button_image_store()
1253 struct kobject *kobj = devres->root; in wacom_devm_sysfs_group_release()
1256 __func__, devres->group->name); in wacom_devm_sysfs_group_release()
1257 sysfs_remove_group(kobj, devres->group); in wacom_devm_sysfs_group_release()
1271 return -ENOMEM; in __wacom_devm_sysfs_create_group()
1273 devres->group = group; in __wacom_devm_sysfs_create_group()
1274 devres->root = root; in __wacom_devm_sysfs_create_group()
1276 error = sysfs_create_group(devres->root, group); in __wacom_devm_sysfs_create_group()
1282 devres_add(&wacom->hdev->dev, devres); in __wacom_devm_sysfs_create_group()
1290 return __wacom_devm_sysfs_create_group(wacom, &wacom->hdev->dev.kobj, in wacom_devm_sysfs_create_group()
1303 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_devm_kfifo_alloc()
1304 int fifo_size = min(PAGE_SIZE, 10 * wacom_wac->features.pktlen); in wacom_devm_kfifo_alloc()
1313 return -ENOMEM; in wacom_devm_kfifo_alloc()
1321 devres_add(&wacom->hdev->dev, pen_fifo); in wacom_devm_kfifo_alloc()
1322 wacom_wac->pen_fifo = pen_fifo; in wacom_devm_kfifo_alloc()
1329 struct wacom *wacom = led->wacom; in wacom_leds_brightness_get()
1331 if (wacom->led.max_hlv) in wacom_leds_brightness_get()
1332 return wacom_rescale(led->hlv, wacom->led.max_hlv, LED_FULL); in wacom_leds_brightness_get()
1334 if (wacom->led.max_llv) in wacom_leds_brightness_get()
1335 return wacom_rescale(led->llv, wacom->led.max_llv, LED_FULL); in wacom_leds_brightness_get()
1344 struct wacom *wacom = led->wacom; in __wacom_led_brightness_get()
1346 if (wacom->led.groups[led->group].select != led->id) in __wacom_led_brightness_get()
1356 struct wacom *wacom = led->wacom; in wacom_led_brightness_set()
1359 mutex_lock(&wacom->lock); in wacom_led_brightness_set()
1361 if (!wacom->led.groups || (brightness == LED_OFF && in wacom_led_brightness_set()
1362 wacom->led.groups[led->group].select != led->id)) { in wacom_led_brightness_set()
1367 led->llv = wacom->led.llv = wacom_rescale(brightness, LED_FULL, wacom->led.max_llv); in wacom_led_brightness_set()
1368 led->hlv = wacom->led.hlv = wacom_rescale(brightness, LED_FULL, wacom->led.max_hlv); in wacom_led_brightness_set()
1370 wacom->led.groups[led->group].select = led->id; in wacom_led_brightness_set()
1375 mutex_unlock(&wacom->lock); in wacom_led_brightness_set()
1393 "%s::wacom-%d.%d", in wacom_led_register_one()
1398 return -ENOMEM; in wacom_led_register_one()
1400 led->group = group; in wacom_led_register_one()
1401 led->id = id; in wacom_led_register_one()
1402 led->wacom = wacom; in wacom_led_register_one()
1403 led->llv = wacom->led.llv; in wacom_led_register_one()
1404 led->hlv = wacom->led.hlv; in wacom_led_register_one()
1405 led->cdev.name = name; in wacom_led_register_one()
1406 led->cdev.max_brightness = LED_FULL; in wacom_led_register_one()
1407 led->cdev.flags = LED_HW_PLUGGABLE; in wacom_led_register_one()
1408 led->cdev.brightness_get = __wacom_led_brightness_get; in wacom_led_register_one()
1410 led->cdev.brightness_set_blocking = wacom_led_brightness_set; in wacom_led_register_one()
1411 led->cdev.default_trigger = led->cdev.name; in wacom_led_register_one()
1413 led->cdev.brightness_set = wacom_led_readonly_brightness_set; in wacom_led_register_one()
1417 led->trigger.name = name; in wacom_led_register_one()
1418 if (id == wacom->led.groups[group].select) in wacom_led_register_one()
1419 led->trigger.brightness = wacom_leds_brightness_get(led); in wacom_led_register_one()
1420 error = devm_led_trigger_register(dev, &led->trigger); in wacom_led_register_one()
1422 hid_err(wacom->hdev, in wacom_led_register_one()
1424 led->cdev.name, error); in wacom_led_register_one()
1429 error = devm_led_classdev_register(dev, &led->cdev); in wacom_led_register_one()
1431 hid_err(wacom->hdev, in wacom_led_register_one()
1433 led->cdev.name, error); in wacom_led_register_one()
1434 led->cdev.name = NULL; in wacom_led_register_one()
1445 devres_release_group(group->dev, group); in wacom_led_groups_release_one()
1456 if (group_id >= wacom->led.count || count <= 0) in wacom_led_groups_alloc_and_register_one()
1457 return -EINVAL; in wacom_led_groups_alloc_and_register_one()
1459 if (!devres_open_group(dev, &wacom->led.groups[group_id], GFP_KERNEL)) in wacom_led_groups_alloc_and_register_one()
1460 return -ENOMEM; in wacom_led_groups_alloc_and_register_one()
1464 error = -ENOMEM; in wacom_led_groups_alloc_and_register_one()
1468 wacom->led.groups[group_id].leds = leds; in wacom_led_groups_alloc_and_register_one()
1469 wacom->led.groups[group_id].count = count; in wacom_led_groups_alloc_and_register_one()
1478 wacom->led.groups[group_id].dev = dev; in wacom_led_groups_alloc_and_register_one()
1480 devres_close_group(dev, &wacom->led.groups[group_id]); in wacom_led_groups_alloc_and_register_one()
1491 error = devm_add_action_or_reset(&wacom->hdev->dev, in wacom_led_groups_alloc_and_register_one()
1493 &wacom->led.groups[group_id]); in wacom_led_groups_alloc_and_register_one()
1500 devres_release_group(dev, &wacom->led.groups[group_id]); in wacom_led_groups_alloc_and_register_one()
1509 if (group_id >= wacom->led.count) in wacom_led_find()
1512 group = &wacom->led.groups[group_id]; in wacom_led_find()
1514 if (!group->leds) in wacom_led_find()
1517 id %= group->count; in wacom_led_find()
1519 return &group->leds[id]; in wacom_led_find()
1536 group = cur->group; in wacom_led_next()
1537 next = cur->id; in wacom_led_next()
1543 } while (next_led->cdev.trigger != &next_led->trigger); in wacom_led_next()
1552 wacom->led.groups = NULL; in wacom_led_groups_release()
1553 wacom->led.count = 0; in wacom_led_groups_release()
1558 struct device *dev = &wacom->hdev->dev; in wacom_led_groups_allocate()
1565 return -ENOMEM; in wacom_led_groups_allocate()
1571 wacom->led.groups = groups; in wacom_led_groups_allocate()
1572 wacom->led.count = count; in wacom_led_groups_allocate()
1583 if (!wacom->wacom_wac.pad_input) in wacom_leds_alloc_and_register()
1584 return -EINVAL; in wacom_leds_alloc_and_register()
1586 dev = &wacom->wacom_wac.pad_input->dev; in wacom_leds_alloc_and_register()
1607 if (!(wacom->wacom_wac.features.device_type & WACOM_DEVICETYPE_PAD)) in wacom_initialize_leds()
1611 switch (wacom->wacom_wac.features.type) { in wacom_initialize_leds()
1613 if (!wacom->generic_has_leds) in wacom_initialize_leds()
1615 wacom->led.llv = 100; in wacom_initialize_leds()
1616 wacom->led.max_llv = 100; in wacom_initialize_leds()
1620 hid_err(wacom->hdev, in wacom_initialize_leds()
1633 wacom->led.llv = 10; in wacom_initialize_leds()
1634 wacom->led.hlv = 20; in wacom_initialize_leds()
1635 wacom->led.max_llv = 127; in wacom_initialize_leds()
1636 wacom->led.max_hlv = 127; in wacom_initialize_leds()
1637 wacom->led.img_lum = 10; in wacom_initialize_leds()
1641 hid_err(wacom->hdev, in wacom_initialize_leds()
1652 wacom->led.llv = 0; in wacom_initialize_leds()
1653 wacom->led.hlv = 0; in wacom_initialize_leds()
1654 wacom->led.img_lum = 0; in wacom_initialize_leds()
1658 hid_err(wacom->hdev, in wacom_initialize_leds()
1673 wacom->led.llv = 32; in wacom_initialize_leds()
1674 wacom->led.max_llv = 96; in wacom_initialize_leds()
1678 hid_err(wacom->hdev, in wacom_initialize_leds()
1688 wacom->led.llv = 50; in wacom_initialize_leds()
1689 wacom->led.max_llv = 100; in wacom_initialize_leds()
1692 hid_err(wacom->hdev, in wacom_initialize_leds()
1698 case REMOTE: in wacom_initialize_leds()
1699 wacom->led.llv = 255; in wacom_initialize_leds()
1700 wacom->led.max_llv = 255; in wacom_initialize_leds()
1703 hid_err(wacom->hdev, in wacom_initialize_leds()
1714 hid_err(wacom->hdev, in wacom_initialize_leds()
1732 schedule_delayed_work(&wacom->init_work, msecs_to_jiffies(1000)); in wacom_query_tablet_data()
1752 val->strval = battery->wacom->wacom_wac.name; in wacom_battery_get_property()
1755 val->intval = battery->bat_connected; in wacom_battery_get_property()
1758 val->intval = POWER_SUPPLY_SCOPE_DEVICE; in wacom_battery_get_property()
1761 val->intval = battery->battery_capacity; in wacom_battery_get_property()
1764 if (battery->bat_status != WACOM_POWER_SUPPLY_STATUS_AUTO) in wacom_battery_get_property()
1765 val->intval = battery->bat_status; in wacom_battery_get_property()
1766 else if (battery->bat_charging) in wacom_battery_get_property()
1767 val->intval = POWER_SUPPLY_STATUS_CHARGING; in wacom_battery_get_property()
1768 else if (battery->battery_capacity == 100 && in wacom_battery_get_property()
1769 battery->ps_connected) in wacom_battery_get_property()
1770 val->intval = POWER_SUPPLY_STATUS_FULL; in wacom_battery_get_property()
1771 else if (battery->ps_connected) in wacom_battery_get_property()
1772 val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; in wacom_battery_get_property()
1774 val->intval = POWER_SUPPLY_STATUS_DISCHARGING; in wacom_battery_get_property()
1777 ret = -EINVAL; in wacom_battery_get_property()
1788 struct device *dev = &wacom->hdev->dev; in __wacom_initialize_battery()
1791 struct power_supply_desc *bat_desc = &battery->bat_desc; in __wacom_initialize_battery()
1796 return -ENOMEM; in __wacom_initialize_battery()
1798 battery->wacom = wacom; in __wacom_initialize_battery()
1800 n = atomic_inc_return(&battery_no) - 1; in __wacom_initialize_battery()
1802 bat_desc->properties = wacom_battery_props; in __wacom_initialize_battery()
1803 bat_desc->num_properties = ARRAY_SIZE(wacom_battery_props); in __wacom_initialize_battery()
1804 bat_desc->get_property = wacom_battery_get_property; in __wacom_initialize_battery()
1805 sprintf(battery->bat_name, "wacom_battery_%ld", n); in __wacom_initialize_battery()
1806 bat_desc->name = battery->bat_name; in __wacom_initialize_battery()
1807 bat_desc->type = POWER_SUPPLY_TYPE_BATTERY; in __wacom_initialize_battery()
1808 bat_desc->use_for_apm = 0; in __wacom_initialize_battery()
1816 power_supply_powers(ps_bat, &wacom->hdev->dev); in __wacom_initialize_battery()
1818 battery->battery = ps_bat; in __wacom_initialize_battery()
1830 if (wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) in wacom_initialize_battery()
1831 return __wacom_initialize_battery(wacom, &wacom->battery); in wacom_initialize_battery()
1838 if (wacom->battery.battery) { in wacom_destroy_battery()
1839 devres_release_group(&wacom->hdev->dev, in wacom_destroy_battery()
1840 &wacom->battery.bat_desc); in wacom_destroy_battery()
1841 wacom->battery.battery = NULL; in wacom_destroy_battery()
1859 return sysfs_emit(buf, "%i\n", wacom->wacom_wac.bt_high_speed); in wacom_show_speed()
1871 return -EINVAL; in wacom_store_speed()
1874 return -EINVAL; in wacom_store_speed()
1876 wacom_bt_query_tablet_data(hdev, new_speed, &wacom->wacom_wac.features); in wacom_store_speed()
1889 struct device *dev = kobj_to_dev(kobj->parent); in wacom_show_remote_mode()
1894 mode = wacom->led.groups[index].select; in wacom_show_remote_mode()
1895 return sprintf(buf, "%d\n", mode < 3 ? mode : -1); in wacom_show_remote_mode()
1904 static struct kobj_attribute remote##SET_ID##_mode_attr = { \
1909 static struct attribute *remote##SET_ID##_serial_attrs[] = { \
1910 &remote##SET_ID##_mode_attr.attr, \
1913 static const struct attribute_group remote##SET_ID##_serial_group = { \
1915 .attrs = remote##SET_ID##_serial_attrs, \
1928 struct wacom_remote *remote = wacom->remote; in wacom_remote_create_attr_group() local
1930 remote->remotes[index].group.name = devm_kasprintf(&wacom->hdev->dev, in wacom_remote_create_attr_group()
1933 if (!remote->remotes[index].group.name) in wacom_remote_create_attr_group()
1934 return -ENOMEM; in wacom_remote_create_attr_group()
1936 error = __wacom_devm_sysfs_create_group(wacom, remote->remote_dir, in wacom_remote_create_attr_group()
1937 &remote->remotes[index].group); in wacom_remote_create_attr_group()
1939 remote->remotes[index].group.name = NULL; in wacom_remote_create_attr_group()
1940 hid_err(wacom->hdev, in wacom_remote_create_attr_group()
1956 return -ENOMEM; in wacom_cmd_unpair_remote()
1961 retval = wacom_set_report(wacom->hdev, HID_OUTPUT_REPORT, buf, in wacom_cmd_unpair_remote()
1973 struct device *dev = kobj_to_dev(kobj->parent); in wacom_store_unpair_remote()
1981 hid_info(wacom->hdev, "remote: unrecognized unpair code: %s\n", in wacom_store_unpair_remote()
1983 return -1; in wacom_store_unpair_remote()
1986 mutex_lock(&wacom->lock); in wacom_store_unpair_remote()
1989 mutex_unlock(&wacom->lock); in wacom_store_unpair_remote()
2007 struct wacom_remote *remote = wacom->remote; in wacom_remotes_destroy() local
2009 if (!remote) in wacom_remotes_destroy()
2012 kobject_put(remote->remote_dir); in wacom_remotes_destroy()
2013 kfifo_free(&remote->remote_fifo); in wacom_remotes_destroy()
2014 wacom->remote = NULL; in wacom_remotes_destroy()
2020 struct wacom_remote *remote; in wacom_initialize_remotes() local
2023 if (wacom->wacom_wac.features.type != REMOTE) in wacom_initialize_remotes()
2026 remote = devm_kzalloc(&wacom->hdev->dev, sizeof(*wacom->remote), in wacom_initialize_remotes()
2028 if (!remote) in wacom_initialize_remotes()
2029 return -ENOMEM; in wacom_initialize_remotes()
2031 wacom->remote = remote; in wacom_initialize_remotes()
2033 spin_lock_init(&remote->remote_lock); in wacom_initialize_remotes()
2035 error = kfifo_alloc(&remote->remote_fifo, in wacom_initialize_remotes()
2039 hid_err(wacom->hdev, "failed allocating remote_fifo\n"); in wacom_initialize_remotes()
2040 return -ENOMEM; in wacom_initialize_remotes()
2043 remote->remotes[0].group = remote0_serial_group; in wacom_initialize_remotes()
2044 remote->remotes[1].group = remote1_serial_group; in wacom_initialize_remotes()
2045 remote->remotes[2].group = remote2_serial_group; in wacom_initialize_remotes()
2046 remote->remotes[3].group = remote3_serial_group; in wacom_initialize_remotes()
2047 remote->remotes[4].group = remote4_serial_group; in wacom_initialize_remotes()
2049 remote->remote_dir = kobject_create_and_add("wacom_remote", in wacom_initialize_remotes()
2050 &wacom->hdev->dev.kobj); in wacom_initialize_remotes()
2051 if (!remote->remote_dir) in wacom_initialize_remotes()
2052 return -ENOMEM; in wacom_initialize_remotes()
2054 error = sysfs_create_files(remote->remote_dir, remote_unpair_attrs); in wacom_initialize_remotes()
2057 hid_err(wacom->hdev, in wacom_initialize_remotes()
2063 wacom->led.groups[i].select = WACOM_STATUS_UNKNOWN; in wacom_initialize_remotes()
2064 remote->remotes[i].serial = 0; in wacom_initialize_remotes()
2067 error = devm_add_action_or_reset(&wacom->hdev->dev, in wacom_initialize_remotes()
2078 struct hid_device *hdev = wacom->hdev; in wacom_allocate_input()
2079 struct wacom_wac *wacom_wac = &(wacom->wacom_wac); in wacom_allocate_input()
2081 input_dev = devm_input_allocate_device(&hdev->dev); in wacom_allocate_input()
2085 input_dev->name = wacom_wac->features.name; in wacom_allocate_input()
2086 input_dev->phys = hdev->phys; in wacom_allocate_input()
2087 input_dev->dev.parent = &hdev->dev; in wacom_allocate_input()
2088 input_dev->open = wacom_open; in wacom_allocate_input()
2089 input_dev->close = wacom_close; in wacom_allocate_input()
2090 input_dev->uniq = hdev->uniq; in wacom_allocate_input()
2091 input_dev->id.bustype = hdev->bus; in wacom_allocate_input()
2092 input_dev->id.vendor = hdev->vendor; in wacom_allocate_input()
2093 input_dev->id.product = wacom_wac->pid ? wacom_wac->pid : hdev->product; in wacom_allocate_input()
2094 input_dev->id.version = hdev->version; in wacom_allocate_input()
2102 struct wacom_wac *wacom_wac = &(wacom->wacom_wac); in wacom_allocate_inputs()
2104 wacom_wac->pen_input = wacom_allocate_input(wacom); in wacom_allocate_inputs()
2105 wacom_wac->touch_input = wacom_allocate_input(wacom); in wacom_allocate_inputs()
2106 wacom_wac->pad_input = wacom_allocate_input(wacom); in wacom_allocate_inputs()
2107 if (!wacom_wac->pen_input || in wacom_allocate_inputs()
2108 !wacom_wac->touch_input || in wacom_allocate_inputs()
2109 !wacom_wac->pad_input) in wacom_allocate_inputs()
2110 return -ENOMEM; in wacom_allocate_inputs()
2112 wacom_wac->pen_input->name = wacom_wac->pen_name; in wacom_allocate_inputs()
2113 wacom_wac->touch_input->name = wacom_wac->touch_name; in wacom_allocate_inputs()
2114 wacom_wac->pad_input->name = wacom_wac->pad_name; in wacom_allocate_inputs()
2122 struct wacom_wac *wacom_wac = &(wacom->wacom_wac); in wacom_setup_inputs()
2125 pen_input_dev = wacom_wac->pen_input; in wacom_setup_inputs()
2126 touch_input_dev = wacom_wac->touch_input; in wacom_setup_inputs()
2127 pad_input_dev = wacom_wac->pad_input; in wacom_setup_inputs()
2130 return -EINVAL; in wacom_setup_inputs()
2136 wacom_wac->pen_input = NULL; in wacom_setup_inputs()
2144 wacom_wac->touch_input = NULL; in wacom_setup_inputs()
2152 wacom_wac->pad_input = NULL; in wacom_setup_inputs()
2162 struct wacom_wac *wacom_wac = &(wacom->wacom_wac); in wacom_register_inputs()
2165 pen_input_dev = wacom_wac->pen_input; in wacom_register_inputs()
2166 touch_input_dev = wacom_wac->touch_input; in wacom_register_inputs()
2167 pad_input_dev = wacom_wac->pad_input; in wacom_register_inputs()
2190 wacom_wac->pad_input = NULL; in wacom_register_inputs()
2191 wacom_wac->touch_input = NULL; in wacom_register_inputs()
2192 wacom_wac->pen_input = NULL; in wacom_register_inputs()
2203 if (features->x_resolution) { in wacom_set_default_phy()
2204 features->x_phy = (features->x_max * 100) / in wacom_set_default_phy()
2205 features->x_resolution; in wacom_set_default_phy()
2206 features->y_phy = (features->y_max * 100) / in wacom_set_default_phy()
2207 features->y_resolution; in wacom_set_default_phy()
2214 if (!features->unit) { in wacom_calculate_res()
2215 features->unit = 0x11; in wacom_calculate_res()
2216 features->unitExpo = -3; in wacom_calculate_res()
2219 features->x_resolution = wacom_calc_hid_res(features->x_max, in wacom_calculate_res()
2220 features->x_phy, in wacom_calculate_res()
2221 features->unit, in wacom_calculate_res()
2222 features->unitExpo); in wacom_calculate_res()
2223 features->y_resolution = wacom_calc_hid_res(features->y_max, in wacom_calculate_res()
2224 features->y_phy, in wacom_calculate_res()
2225 features->unit, in wacom_calculate_res()
2226 features->unitExpo); in wacom_calculate_res()
2233 if ((wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) && in wacom_battery_work()
2234 !wacom->battery.battery) { in wacom_battery_work()
2237 else if (!(wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) && in wacom_battery_work()
2238 wacom->battery.battery) { in wacom_battery_work()
2249 report_enum = hdev->report_enum + HID_INPUT_REPORT; in wacom_compute_pktlen()
2251 list_for_each_entry(report, &report_enum->report_list, list) { in wacom_compute_pktlen()
2262 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_update_name()
2263 struct wacom_features *features = &wacom_wac->features; in wacom_update_name()
2264 char name[WACOM_NAME_MAX - 20]; /* Leave some room for suffixes */ in wacom_update_name()
2267 if ((features->type == HID_GENERIC) && !strcmp("Wacom HID", features->name)) { in wacom_update_name()
2268 char *product_name = wacom->hdev->name; in wacom_update_name()
2270 if (hid_is_usb(wacom->hdev)) { in wacom_update_name()
2271 struct usb_interface *intf = to_usb_interface(wacom->hdev->dev.parent); in wacom_update_name()
2273 if (dev->product != NULL) in wacom_update_name()
2274 product_name = dev->product; in wacom_update_name()
2277 if (wacom->hdev->bus == BUS_I2C) { in wacom_update_name()
2279 features->name, wacom->hdev->product); in wacom_update_name()
2284 hid_warn(wacom->hdev, "String overflow while assembling device name"); in wacom_update_name()
2300 if (name[strlen(name)-1] == ' ') in wacom_update_name()
2301 name[strlen(name)-1] = '\0'; in wacom_update_name()
2303 if (strscpy(name, features->name, sizeof(name)) < 0) { in wacom_update_name()
2304 hid_warn(wacom->hdev, "String overflow while assembling device name"); in wacom_update_name()
2308 snprintf(wacom_wac->name, sizeof(wacom_wac->name), "%s%s", in wacom_update_name()
2312 snprintf(wacom_wac->pen_name, sizeof(wacom_wac->pen_name), in wacom_update_name()
2314 snprintf(wacom_wac->touch_name, sizeof(wacom_wac->touch_name), in wacom_update_name()
2316 snprintf(wacom_wac->pad_name, sizeof(wacom_wac->pad_name), in wacom_update_name()
2322 struct hid_device *hdev = wacom->hdev; in wacom_release_resources()
2324 if (!wacom->resources) in wacom_release_resources()
2327 devres_release_group(&hdev->dev, wacom); in wacom_release_resources()
2329 wacom->resources = false; in wacom_release_resources()
2331 wacom->wacom_wac.pen_input = NULL; in wacom_release_resources()
2332 wacom->wacom_wac.touch_input = NULL; in wacom_release_resources()
2333 wacom->wacom_wac.pad_input = NULL; in wacom_release_resources()
2338 if (wacom_wac->features.device_type & WACOM_DEVICETYPE_TOUCH) { in wacom_set_shared_values()
2339 wacom_wac->shared->type = wacom_wac->features.type; in wacom_set_shared_values()
2340 wacom_wac->shared->touch_input = wacom_wac->touch_input; in wacom_set_shared_values()
2343 if (wacom_wac->has_mute_touch_switch) { in wacom_set_shared_values()
2344 wacom_wac->shared->has_mute_touch_switch = true; in wacom_set_shared_values()
2350 if (wacom_wac->is_soft_touch_switch) in wacom_set_shared_values()
2351 wacom_wac->shared->is_touch_on = true; in wacom_set_shared_values()
2354 if (wacom_wac->shared->has_mute_touch_switch && in wacom_set_shared_values()
2355 wacom_wac->shared->touch_input) { in wacom_set_shared_values()
2356 set_bit(EV_SW, wacom_wac->shared->touch_input->evbit); in wacom_set_shared_values()
2357 input_set_capability(wacom_wac->shared->touch_input, EV_SW, in wacom_set_shared_values()
2364 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_parse_and_register()
2365 struct wacom_features *features = &wacom_wac->features; in wacom_parse_and_register()
2366 struct hid_device *hdev = wacom->hdev; in wacom_parse_and_register()
2370 features->pktlen = wacom_compute_pktlen(hdev); in wacom_parse_and_register()
2371 if (!features->pktlen) in wacom_parse_and_register()
2372 return -ENODEV; in wacom_parse_and_register()
2374 if (!devres_open_group(&hdev->dev, wacom, GFP_KERNEL)) in wacom_parse_and_register()
2375 return -ENOMEM; in wacom_parse_and_register()
2381 wacom->resources = true; in wacom_parse_and_register()
2392 if (features->type == BAMBOO_PAD) { in wacom_parse_and_register()
2393 if (features->pktlen == WACOM_PKGLEN_PENABLED) { in wacom_parse_and_register()
2394 features->type = HID_GENERIC; in wacom_parse_and_register()
2395 } else if ((features->pktlen != WACOM_PKGLEN_BPAD_TOUCH) && in wacom_parse_and_register()
2396 (features->pktlen != WACOM_PKGLEN_BPAD_TOUCH_USB)) { in wacom_parse_and_register()
2397 error = -ENODEV; in wacom_parse_and_register()
2409 if (features->device_type == WACOM_DEVICETYPE_NONE && in wacom_parse_and_register()
2410 features->type != WIRELESS) { in wacom_parse_and_register()
2411 error = features->type == HID_GENERIC ? -ENODEV : 0; in wacom_parse_and_register()
2413 dev_warn(&hdev->dev, "Unknown device_type for '%s'. %s.", in wacom_parse_and_register()
2414 hdev->name, in wacom_parse_and_register()
2420 features->device_type |= WACOM_DEVICETYPE_PEN; in wacom_parse_and_register()
2428 if ((features->type == BAMBOO_PEN) && in wacom_parse_and_register()
2429 ((features->device_type & WACOM_DEVICETYPE_TOUCH) || in wacom_parse_and_register()
2430 (features->device_type & WACOM_DEVICETYPE_PAD))) { in wacom_parse_and_register()
2431 error = -ENODEV; in wacom_parse_and_register()
2443 if (features->type == HID_GENERIC) in wacom_parse_and_register()
2457 if (wacom->wacom_wac.features.device_type & WACOM_DEVICETYPE_PAD) { in wacom_parse_and_register()
2473 if ((features->type == BAMBOO_TOUCH) && in wacom_parse_and_register()
2474 (features->device_type & WACOM_DEVICETYPE_PEN)) { in wacom_parse_and_register()
2475 cancel_delayed_work_sync(&wacom->init_work); in wacom_parse_and_register()
2477 error = -ENODEV; in wacom_parse_and_register()
2481 if (features->device_type & WACOM_DEVICETYPE_WL_MONITOR) { in wacom_parse_and_register()
2490 devres_close_group(&hdev->dev, wacom); in wacom_parse_and_register()
2504 struct usb_device *usbdev = wacom->usbdev; in wacom_wireless_work()
2505 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_wireless_work()
2522 hdev1 = usb_get_intfdata(usbdev->config->interface[1]); in wacom_wireless_work()
2524 wacom_wac1 = &(wacom1->wacom_wac); in wacom_wireless_work()
2528 hdev2 = usb_get_intfdata(usbdev->config->interface[2]); in wacom_wireless_work()
2530 wacom_wac2 = &(wacom2->wacom_wac); in wacom_wireless_work()
2533 if (wacom_wac->pid == 0) { in wacom_wireless_work()
2534 hid_info(wacom->hdev, "wireless tablet disconnected\n"); in wacom_wireless_work()
2538 hid_info(wacom->hdev, "wireless tablet connected with PID %x\n", in wacom_wireless_work()
2539 wacom_wac->pid); in wacom_wireless_work()
2541 while (id->bus) { in wacom_wireless_work()
2542 if (id->vendor == USB_VENDOR_ID_WACOM && in wacom_wireless_work()
2543 id->product == wacom_wac->pid) in wacom_wireless_work()
2548 if (!id->bus) { in wacom_wireless_work()
2549 hid_info(wacom->hdev, "ignoring unknown PID.\n"); in wacom_wireless_work()
2554 wacom_wac1->features = in wacom_wireless_work()
2555 *((struct wacom_features *)id->driver_data); in wacom_wireless_work()
2557 wacom_wac1->pid = wacom_wac->pid; in wacom_wireless_work()
2564 if (wacom_wac1->features.touch_max || in wacom_wireless_work()
2565 (wacom_wac1->features.type >= INTUOSHT && in wacom_wireless_work()
2566 wacom_wac1->features.type <= BAMBOO_PT)) { in wacom_wireless_work()
2567 wacom_wac2->features = in wacom_wireless_work()
2568 *((struct wacom_features *)id->driver_data); in wacom_wireless_work()
2569 wacom_wac2->pid = wacom_wac->pid; in wacom_wireless_work()
2576 if (strscpy(wacom_wac->name, wacom_wac1->name, in wacom_wireless_work()
2577 sizeof(wacom_wac->name)) < 0) { in wacom_wireless_work()
2578 hid_warn(wacom->hdev, "String overflow while assembling device name"); in wacom_wireless_work()
2592 struct wacom_remote *remote = wacom->remote; in wacom_remote_destroy_battery() local
2594 if (remote->remotes[index].battery.battery) { in wacom_remote_destroy_battery()
2595 devres_release_group(&wacom->hdev->dev, in wacom_remote_destroy_battery()
2596 &remote->remotes[index].battery.bat_desc); in wacom_remote_destroy_battery()
2597 remote->remotes[index].battery.battery = NULL; in wacom_remote_destroy_battery()
2598 remote->remotes[index].active_time = 0; in wacom_remote_destroy_battery()
2604 struct wacom_remote *remote = wacom->remote; in wacom_remote_destroy_one() local
2605 u32 serial = remote->remotes[index].serial; in wacom_remote_destroy_one()
2610 if (remote->remotes[i].serial == serial) { in wacom_remote_destroy_one()
2612 spin_lock_irqsave(&remote->remote_lock, flags); in wacom_remote_destroy_one()
2613 remote->remotes[i].registered = false; in wacom_remote_destroy_one()
2614 spin_unlock_irqrestore(&remote->remote_lock, flags); in wacom_remote_destroy_one()
2618 if (remote->remotes[i].group.name) in wacom_remote_destroy_one()
2619 devres_release_group(&wacom->hdev->dev, in wacom_remote_destroy_one()
2620 &remote->remotes[i]); in wacom_remote_destroy_one()
2622 remote->remotes[i].serial = 0; in wacom_remote_destroy_one()
2623 remote->remotes[i].group.name = NULL; in wacom_remote_destroy_one()
2624 wacom->led.groups[i].select = WACOM_STATUS_UNKNOWN; in wacom_remote_destroy_one()
2632 struct wacom_remote *remote = wacom->remote; in wacom_remote_create_one() local
2633 struct device *dev = &wacom->hdev->dev; in wacom_remote_create_one()
2636 /* A remote can pair more than once with an EKR, in wacom_remote_create_one()
2640 if (remote->remotes[k].serial == serial) in wacom_remote_create_one()
2645 remote->remotes[index].serial = serial; in wacom_remote_create_one()
2649 if (!devres_open_group(dev, &remote->remotes[index], GFP_KERNEL)) in wacom_remote_create_one()
2650 return -ENOMEM; in wacom_remote_create_one()
2656 remote->remotes[index].input = wacom_allocate_input(wacom); in wacom_remote_create_one()
2657 if (!remote->remotes[index].input) { in wacom_remote_create_one()
2658 error = -ENOMEM; in wacom_remote_create_one()
2661 remote->remotes[index].input->uniq = remote->remotes[index].group.name; in wacom_remote_create_one()
2662 remote->remotes[index].input->name = wacom->wacom_wac.pad_name; in wacom_remote_create_one()
2664 if (!remote->remotes[index].input->name) { in wacom_remote_create_one()
2665 error = -EINVAL; in wacom_remote_create_one()
2669 error = wacom_setup_pad_input_capabilities(remote->remotes[index].input, in wacom_remote_create_one()
2670 &wacom->wacom_wac); in wacom_remote_create_one()
2674 remote->remotes[index].serial = serial; in wacom_remote_create_one()
2676 error = input_register_device(remote->remotes[index].input); in wacom_remote_create_one()
2681 &remote->remotes[index].input->dev, in wacom_remote_create_one()
2686 remote->remotes[index].registered = true; in wacom_remote_create_one()
2688 devres_close_group(dev, &remote->remotes[index]); in wacom_remote_create_one()
2692 devres_release_group(dev, &remote->remotes[index]); in wacom_remote_create_one()
2693 remote->remotes[index].serial = 0; in wacom_remote_create_one()
2699 struct wacom_remote *remote = wacom->remote; in wacom_remote_attach_battery() local
2702 if (!remote->remotes[index].registered) in wacom_remote_attach_battery()
2705 if (remote->remotes[index].battery.battery) in wacom_remote_attach_battery()
2708 if (!remote->remotes[index].active_time) in wacom_remote_attach_battery()
2711 if (wacom->led.groups[index].select == WACOM_STATUS_UNKNOWN) in wacom_remote_attach_battery()
2715 &wacom->remote->remotes[index].battery); in wacom_remote_attach_battery()
2725 struct wacom_remote *remote = wacom->remote; in wacom_remote_work() local
2733 spin_lock_irqsave(&remote->remote_lock, flags); in wacom_remote_work()
2735 count = kfifo_out(&remote->remote_fifo, &remote_work_data, in wacom_remote_work()
2739 hid_err(wacom->hdev, in wacom_remote_work()
2741 spin_unlock_irqrestore(&remote->remote_lock, flags); in wacom_remote_work()
2745 if (!kfifo_is_empty(&remote->remote_fifo)) in wacom_remote_work()
2746 wacom_schedule_work(&wacom->wacom_wac, WACOM_WORKER_REMOTE); in wacom_remote_work()
2748 spin_unlock_irqrestore(&remote->remote_lock, flags); in wacom_remote_work()
2751 work_serial = remote_work_data.remote[i].serial; in wacom_remote_work()
2754 if (kt - remote->remotes[i].active_time > WACOM_REMOTE_BATTERY_TIMEOUT in wacom_remote_work()
2755 && remote->remotes[i].active_time != 0) in wacom_remote_work()
2758 if (remote->remotes[i].serial == work_serial) { in wacom_remote_work()
2763 if (remote->remotes[i].serial) in wacom_remote_work()
2768 } else if (remote->remotes[i].serial) { in wacom_remote_work()
2777 struct wacom_shared *shared = wacom->wacom_wac.shared; in wacom_mode_change_work()
2780 bool is_direct = wacom->wacom_wac.is_direct_mode; in wacom_mode_change_work()
2783 if (shared->pen) { in wacom_mode_change_work()
2784 wacom1 = hid_get_drvdata(shared->pen); in wacom_mode_change_work()
2786 hid_hw_stop(wacom1->hdev); in wacom_mode_change_work()
2787 wacom1->wacom_wac.has_mode_change = true; in wacom_mode_change_work()
2788 wacom1->wacom_wac.is_direct_mode = is_direct; in wacom_mode_change_work()
2791 if (shared->touch) { in wacom_mode_change_work()
2792 wacom2 = hid_get_drvdata(shared->touch); in wacom_mode_change_work()
2794 hid_hw_stop(wacom2->hdev); in wacom_mode_change_work()
2795 wacom2->wacom_wac.has_mode_change = true; in wacom_mode_change_work()
2796 wacom2->wacom_wac.is_direct_mode = is_direct; in wacom_mode_change_work()
2822 if (!id->driver_data) in wacom_probe()
2823 return -EINVAL; in wacom_probe()
2825 hdev->quirks |= HID_QUIRK_NO_INIT_REPORTS; in wacom_probe()
2827 /* hid-core sets this quirk for the boot interface */ in wacom_probe()
2828 hdev->quirks &= ~HID_QUIRK_NOGET; in wacom_probe()
2830 wacom = devm_kzalloc(&hdev->dev, sizeof(struct wacom), GFP_KERNEL); in wacom_probe()
2832 return -ENOMEM; in wacom_probe()
2835 wacom->hdev = hdev; in wacom_probe()
2837 wacom_wac = &wacom->wacom_wac; in wacom_probe()
2838 wacom_wac->features = *((struct wacom_features *)id->driver_data); in wacom_probe()
2839 features = &wacom_wac->features; in wacom_probe()
2841 if (features->check_for_hid_type && features->hid_type != hdev->type) in wacom_probe()
2842 return -ENODEV; in wacom_probe()
2844 wacom_wac->hid_data.inputmode = -1; in wacom_probe()
2845 wacom_wac->mode_report = -1; in wacom_probe()
2848 struct usb_interface *intf = to_usb_interface(hdev->dev.parent); in wacom_probe()
2851 wacom->usbdev = dev; in wacom_probe()
2852 wacom->intf = intf; in wacom_probe()
2855 mutex_init(&wacom->lock); in wacom_probe()
2856 INIT_DELAYED_WORK(&wacom->init_work, wacom_init_work); in wacom_probe()
2857 INIT_DELAYED_WORK(&wacom->aes_battery_work, wacom_aes_battery_handler); in wacom_probe()
2858 INIT_WORK(&wacom->wireless_work, wacom_wireless_work); in wacom_probe()
2859 INIT_WORK(&wacom->battery_work, wacom_battery_work); in wacom_probe()
2860 INIT_WORK(&wacom->remote_work, wacom_remote_work); in wacom_probe()
2861 INIT_WORK(&wacom->mode_change_work, wacom_mode_change_work); in wacom_probe()
2862 timer_setup(&wacom->idleprox_timer, &wacom_idleprox_timeout, TIMER_DEFERRABLE); in wacom_probe()
2871 if (features->type == BOOTLOADER) { in wacom_probe()
2872 hid_warn(hdev, "Using device in hidraw-only mode"); in wacom_probe()
2880 if (hdev->bus == BUS_BLUETOOTH) { in wacom_probe()
2881 error = device_create_file(&hdev->dev, &dev_attr_speed); in wacom_probe()
2888 wacom_wac->probe_complete = true; in wacom_probe()
2895 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_remove()
2896 struct wacom_features *features = &wacom_wac->features; in wacom_remove()
2898 if (features->device_type & WACOM_DEVICETYPE_WL_MONITOR) in wacom_remove()
2903 cancel_delayed_work_sync(&wacom->init_work); in wacom_remove()
2904 cancel_work_sync(&wacom->wireless_work); in wacom_remove()
2905 cancel_work_sync(&wacom->battery_work); in wacom_remove()
2906 cancel_work_sync(&wacom->remote_work); in wacom_remove()
2907 cancel_work_sync(&wacom->mode_change_work); in wacom_remove()
2908 timer_delete_sync(&wacom->idleprox_timer); in wacom_remove()
2909 if (hdev->bus == BUS_BLUETOOTH) in wacom_remove()
2910 device_remove_file(&hdev->dev, &dev_attr_speed); in wacom_remove()
2915 if (wacom->wacom_wac.features.type != REMOTE) in wacom_remove()
2924 mutex_lock(&wacom->lock); in wacom_resume()
2930 mutex_unlock(&wacom->lock); in wacom_resume()