• Home
  • Raw
  • Download

Lines Matching +full:remote +full:- +full:pid

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * USB Wacom tablet support - system specific code
30 } while ((retval == -ETIMEDOUT || retval == -EAGAIN) && --retries); in wacom_get_report()
47 } while ((retval == -ETIMEDOUT || retval == -EAGAIN) && --retries); in wacom_set_report()
94 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_wac_pen_serial_enforce()
95 struct wacom_features *features = &wacom_wac->features; in wacom_wac_pen_serial_enforce()
100 if (wacom_wac->serial[0] || !(features->quirks & WACOM_QUIRK_TOOLSERIAL)) in wacom_wac_pen_serial_enforce()
104 for (i = 0; i < report->maxfield; i++) { in wacom_wac_pen_serial_enforce()
105 for (j = 0; j < report->field[i]->maxusage; j++) { in wacom_wac_pen_serial_enforce()
106 struct hid_field *field = report->field[i]; in wacom_wac_pen_serial_enforce()
107 struct hid_usage *usage = &field->usage[j]; in wacom_wac_pen_serial_enforce()
108 unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid); in wacom_wac_pen_serial_enforce()
119 offset = field->report_offset; in wacom_wac_pen_serial_enforce()
120 size = field->report_size; in wacom_wac_pen_serial_enforce()
131 wacom_wac->serial[0] = value; in wacom_wac_pen_serial_enforce()
135 wacom_wac->serial[0] |= ((__u64)value) << 32; in wacom_wac_pen_serial_enforce()
139 wacom_wac->id[0] = value; in wacom_wac_pen_serial_enforce()
150 wacom_wac_queue_flush(hdev, wacom_wac->pen_fifo); in wacom_wac_pen_serial_enforce()
152 wacom_wac_queue_insert(hdev, wacom_wac->pen_fifo, in wacom_wac_pen_serial_enforce()
163 if (wacom->wacom_wac.features.type == BOOTLOADER) in wacom_raw_event()
170 return -1; in wacom_raw_event()
172 memcpy(wacom->wacom_wac.data, raw_data, size); in wacom_raw_event()
174 wacom_wac_irq(&wacom->wacom_wac, size); in wacom_raw_event()
183 return hid_hw_open(wacom->hdev); in wacom_open()
191 * wacom->hdev should never be null, but surprisingly, I had the case in wacom_close()
194 if (wacom->hdev) in wacom_close()
195 hid_hw_close(wacom->hdev); in wacom_close()
218 struct wacom_features *features = &wacom->wacom_wac.features; in wacom_hid_usage_quirk()
219 unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid); in wacom_hid_usage_quirk()
222 * The Dell Canvas 27 needs to be switched to its vendor-defined in wacom_hid_usage_quirk()
225 if (hdev->vendor == USB_VENDOR_ID_WACOM && in wacom_hid_usage_quirk()
226 hdev->product == 0x4200 && in wacom_hid_usage_quirk()
227 field->application == HID_UP_MSVENDOR) { in wacom_hid_usage_quirk()
228 wacom->wacom_wac.mode_report = field->report->id; in wacom_hid_usage_quirk()
229 wacom->wacom_wac.mode_value = 2; in wacom_hid_usage_quirk()
240 if (features->type == HID_GENERIC && in wacom_hid_usage_quirk()
241 usage->hid == 0x000D0000 && in wacom_hid_usage_quirk()
242 field->application == HID_DG_PEN && in wacom_hid_usage_quirk()
243 field->physical == HID_DG_STYLUS) { in wacom_hid_usage_quirk()
244 int i = usage->usage_index; in wacom_hid_usage_quirk()
246 if (i-4 >= 0 && i+1 < field->maxusage && in wacom_hid_usage_quirk()
247 field->usage[i-4].hid == HID_DG_TIPSWITCH && in wacom_hid_usage_quirk()
248 field->usage[i-3].hid == HID_DG_BARRELSWITCH && in wacom_hid_usage_quirk()
249 field->usage[i-2].hid == HID_DG_ERASER && in wacom_hid_usage_quirk()
250 field->usage[i-1].hid == HID_DG_INVERT && in wacom_hid_usage_quirk()
251 field->usage[i+1].hid == HID_DG_INRANGE) { in wacom_hid_usage_quirk()
252 usage->hid = HID_DG_BARRELSWITCH2; in wacom_hid_usage_quirk()
257 * Wacom's AES devices use different vendor-defined usages to in wacom_hid_usage_quirk()
259 * hardware. The usages are also sometimes ill-defined and do in wacom_hid_usage_quirk()
264 if (usage->hid == WACOM_HID_WT_SERIALNUMBER && in wacom_hid_usage_quirk()
265 field->report_size == 16 && in wacom_hid_usage_quirk()
266 field->index + 2 < field->report->maxfield) { in wacom_hid_usage_quirk()
267 struct hid_field *a = field->report->field[field->index + 1]; in wacom_hid_usage_quirk()
268 struct hid_field *b = field->report->field[field->index + 2]; in wacom_hid_usage_quirk()
270 if (a->maxusage > 0 && in wacom_hid_usage_quirk()
271 a->usage[0].hid == HID_DG_TOOLSERIALNUMBER && in wacom_hid_usage_quirk()
272 a->report_size == 32 && in wacom_hid_usage_quirk()
273 b->maxusage > 0 && in wacom_hid_usage_quirk()
274 b->usage[0].hid == 0xFF000000 && in wacom_hid_usage_quirk()
275 b->report_size == 8) { in wacom_hid_usage_quirk()
276 features->quirks |= WACOM_QUIRK_AESPEN; in wacom_hid_usage_quirk()
277 usage->hid = WACOM_HID_WD_TOOLTYPE; in wacom_hid_usage_quirk()
278 field->logical_minimum = S16_MIN; in wacom_hid_usage_quirk()
279 field->logical_maximum = S16_MAX; in wacom_hid_usage_quirk()
280 a->logical_minimum = S32_MIN; in wacom_hid_usage_quirk()
281 a->logical_maximum = S32_MAX; in wacom_hid_usage_quirk()
282 b->usage[0].hid = WACOM_HID_WD_SERIALHI; in wacom_hid_usage_quirk()
283 b->logical_minimum = 0; in wacom_hid_usage_quirk()
284 b->logical_maximum = U8_MAX; in wacom_hid_usage_quirk()
288 /* 2nd-generation Intuos Pro Large has incorrect Y maximum */ in wacom_hid_usage_quirk()
289 if (hdev->vendor == USB_VENDOR_ID_WACOM && in wacom_hid_usage_quirk()
290 hdev->product == 0x0358 && in wacom_hid_usage_quirk()
293 field->logical_maximum = 43200; in wacom_hid_usage_quirk()
301 struct wacom_features *features = &wacom->wacom_wac.features; in wacom_feature_mapping()
302 struct hid_data *hid_data = &wacom->wacom_wac.hid_data; in wacom_feature_mapping()
303 unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid); in wacom_feature_mapping()
312 wacom->generic_has_leds = true; in wacom_feature_mapping()
316 if (!features->touch_max) { in wacom_feature_mapping()
318 n = hid_report_len(field->report); in wacom_feature_mapping()
319 data = hid_alloc_report_buf(field->report, GFP_KERNEL); in wacom_feature_mapping()
322 data[0] = field->report->id; in wacom_feature_mapping()
325 if (ret == n && features->type == HID_GENERIC) { in wacom_feature_mapping()
328 } else if (ret == 2 && features->type != HID_GENERIC) { in wacom_feature_mapping()
329 features->touch_max = data[1]; in wacom_feature_mapping()
331 features->touch_max = 16; in wacom_feature_mapping()
335 features->touch_max); in wacom_feature_mapping()
342 if (usage->usage_index >= field->report_count) { in wacom_feature_mapping()
343 dev_err(&hdev->dev, "HID_DG_INPUTMODE out of range\n"); in wacom_feature_mapping()
347 hid_data->inputmode = field->report->id; in wacom_feature_mapping()
348 hid_data->inputmode_index = usage->usage_index; in wacom_feature_mapping()
352 if (field->report->id == 0x0B && in wacom_feature_mapping()
353 (field->application == WACOM_HID_G9_PEN || in wacom_feature_mapping()
354 field->application == WACOM_HID_G11_PEN)) { in wacom_feature_mapping()
355 wacom->wacom_wac.mode_report = field->report->id; in wacom_feature_mapping()
356 wacom->wacom_wac.mode_value = 0; in wacom_feature_mapping()
361 wacom->wacom_wac.mode_report = field->report->id; in wacom_feature_mapping()
362 wacom->wacom_wac.mode_value = 2; in wacom_feature_mapping()
367 if (field->report->id == 0x03 && in wacom_feature_mapping()
368 (field->application == WACOM_HID_G9_TOUCHSCREEN || in wacom_feature_mapping()
369 field->application == WACOM_HID_G11_TOUCHSCREEN)) { in wacom_feature_mapping()
370 wacom->wacom_wac.mode_report = field->report->id; in wacom_feature_mapping()
371 wacom->wacom_wac.mode_value = 0; in wacom_feature_mapping()
379 n = hid_report_len(field->report); in wacom_feature_mapping()
380 data = hid_alloc_report_buf(field->report, GFP_KERNEL); in wacom_feature_mapping()
383 data[0] = field->report->id; in wacom_feature_mapping()
418 * If it happens to define a Digitizer-Stylus Physical Collection then
422 * Digitizer-Finger Physical Collection which will define both logical
434 struct wacom_features *features = &wacom->wacom_wac.features; in wacom_usage_mapping()
437 unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); in wacom_usage_mapping()
445 features->device_type |= WACOM_DEVICETYPE_PEN; in wacom_usage_mapping()
447 features->device_type |= WACOM_DEVICETYPE_TOUCH; in wacom_usage_mapping()
455 features->x_max = field->logical_maximum; in wacom_usage_mapping()
457 features->x_phy = field->physical_maximum; in wacom_usage_mapping()
458 if ((features->type != BAMBOO_PT) && in wacom_usage_mapping()
459 (features->type != BAMBOO_TOUCH)) { in wacom_usage_mapping()
460 features->unit = field->unit; in wacom_usage_mapping()
461 features->unitExpo = field->unit_exponent; in wacom_usage_mapping()
466 features->y_max = field->logical_maximum; in wacom_usage_mapping()
468 features->y_phy = field->physical_maximum; in wacom_usage_mapping()
469 if ((features->type != BAMBOO_PT) && in wacom_usage_mapping()
470 (features->type != BAMBOO_TOUCH)) { in wacom_usage_mapping()
471 features->unit = field->unit; in wacom_usage_mapping()
472 features->unitExpo = field->unit_exponent; in wacom_usage_mapping()
478 features->pressure_max = field->logical_maximum; in wacom_usage_mapping()
482 if (features->type == HID_GENERIC) in wacom_usage_mapping()
490 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_post_parse_hid()
492 if (features->type == HID_GENERIC) { in wacom_post_parse_hid()
493 /* Any last-minute generic device setup */ in wacom_post_parse_hid()
494 if (wacom_wac->has_mode_change) { in wacom_post_parse_hid()
495 if (wacom_wac->is_direct_mode) in wacom_post_parse_hid()
496 features->device_type |= WACOM_DEVICETYPE_DIRECT; in wacom_post_parse_hid()
498 features->device_type &= ~WACOM_DEVICETYPE_DIRECT; in wacom_post_parse_hid()
501 if (features->touch_max > 1) { in wacom_post_parse_hid()
502 if (features->device_type & WACOM_DEVICETYPE_DIRECT) in wacom_post_parse_hid()
503 input_mt_init_slots(wacom_wac->touch_input, in wacom_post_parse_hid()
504 wacom_wac->features.touch_max, in wacom_post_parse_hid()
507 input_mt_init_slots(wacom_wac->touch_input, in wacom_post_parse_hid()
508 wacom_wac->features.touch_max, in wacom_post_parse_hid()
522 rep_enum = &hdev->report_enum[HID_FEATURE_REPORT]; in wacom_parse_hid()
523 list_for_each_entry(hreport, &rep_enum->report_list, list) { in wacom_parse_hid()
524 for (i = 0; i < hreport->maxfield; i++) { in wacom_parse_hid()
526 if (hreport->field[i]->report_count < 1) in wacom_parse_hid()
529 for (j = 0; j < hreport->field[i]->maxusage; j++) { in wacom_parse_hid()
530 wacom_feature_mapping(hdev, hreport->field[i], in wacom_parse_hid()
531 hreport->field[i]->usage + j); in wacom_parse_hid()
537 rep_enum = &hdev->report_enum[HID_INPUT_REPORT]; in wacom_parse_hid()
538 list_for_each_entry(hreport, &rep_enum->report_list, list) { in wacom_parse_hid()
540 if (!hreport->maxfield) in wacom_parse_hid()
543 for (i = 0; i < hreport->maxfield; i++) in wacom_parse_hid()
544 for (j = 0; j < hreport->field[i]->maxusage; j++) in wacom_parse_hid()
545 wacom_usage_mapping(hdev, hreport->field[i], in wacom_parse_hid()
546 hreport->field[i]->usage + j); in wacom_parse_hid()
555 struct hid_data *hid_data = &wacom->wacom_wac.hid_data; in wacom_hid_set_device_mode()
559 if (hid_data->inputmode < 0) in wacom_hid_set_device_mode()
562 re = &(hdev->report_enum[HID_FEATURE_REPORT]); in wacom_hid_set_device_mode()
563 r = re->report_id_hash[hid_data->inputmode]; in wacom_hid_set_device_mode()
565 r->field[0]->value[hid_data->inputmode_index] = 2; in wacom_hid_set_device_mode()
578 int error = -ENOMEM, limit = 0; in wacom_set_device_mode()
580 if (wacom_wac->mode_report < 0) in wacom_set_device_mode()
583 re = &(hdev->report_enum[HID_FEATURE_REPORT]); in wacom_set_device_mode()
584 r = re->report_id_hash[wacom_wac->mode_report]; in wacom_set_device_mode()
586 return -EINVAL; in wacom_set_device_mode()
590 return -ENOMEM; in wacom_set_device_mode()
595 rep_data[0] = wacom_wac->mode_report; in wacom_set_device_mode()
596 rep_data[1] = wacom_wac->mode_value; in wacom_set_device_mode()
604 rep_data[1] != wacom_wac->mode_report && in wacom_set_device_mode()
619 switch (features->type) { in wacom_bt_query_tablet_data()
634 wacom->wacom_wac.bt_high_speed = speed; in wacom_bt_query_tablet_data()
648 wacom->wacom_wac.bt_features &= ~0x20; in wacom_bt_query_tablet_data()
650 wacom->wacom_wac.bt_features |= 0x20; in wacom_bt_query_tablet_data()
653 rep_data[1] = wacom->wacom_wac.bt_features; in wacom_bt_query_tablet_data()
658 wacom->wacom_wac.bt_high_speed = speed; in wacom_bt_query_tablet_data()
666 * Switch the tablet into its most-capable mode. Wacom tablets are
667 * typically configured to power-up in a mode which sends mouse-like
674 struct hid_device *hdev = wacom->hdev; in _wacom_query_tablet_data()
675 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in _wacom_query_tablet_data()
676 struct wacom_features *features = &wacom_wac->features; in _wacom_query_tablet_data()
678 if (hdev->bus == BUS_BLUETOOTH) in _wacom_query_tablet_data()
681 if (features->type != HID_GENERIC) { in _wacom_query_tablet_data()
682 if (features->device_type & WACOM_DEVICETYPE_TOUCH) { in _wacom_query_tablet_data()
683 if (features->type > TABLETPC) { in _wacom_query_tablet_data()
685 wacom_wac->mode_report = 3; in _wacom_query_tablet_data()
686 wacom_wac->mode_value = 4; in _wacom_query_tablet_data()
687 } else if (features->type == WACOM_24HDT) { in _wacom_query_tablet_data()
688 wacom_wac->mode_report = 18; in _wacom_query_tablet_data()
689 wacom_wac->mode_value = 2; in _wacom_query_tablet_data()
690 } else if (features->type == WACOM_27QHDT) { in _wacom_query_tablet_data()
691 wacom_wac->mode_report = 131; in _wacom_query_tablet_data()
692 wacom_wac->mode_value = 2; in _wacom_query_tablet_data()
693 } else if (features->type == BAMBOO_PAD) { in _wacom_query_tablet_data()
694 wacom_wac->mode_report = 2; in _wacom_query_tablet_data()
695 wacom_wac->mode_value = 2; in _wacom_query_tablet_data()
697 } else if (features->device_type & WACOM_DEVICETYPE_PEN) { in _wacom_query_tablet_data()
698 if (features->type <= BAMBOO_PT) { in _wacom_query_tablet_data()
699 wacom_wac->mode_report = 2; in _wacom_query_tablet_data()
700 wacom_wac->mode_value = 2; in _wacom_query_tablet_data()
707 if (features->type == HID_GENERIC) in _wacom_query_tablet_data()
717 struct usb_interface *intf = wacom->intf; in wacom_retrieve_hid_descriptor()
720 features->x_fuzz = 4; in wacom_retrieve_hid_descriptor()
721 features->y_fuzz = 4; in wacom_retrieve_hid_descriptor()
722 features->pressure_fuzz = 0; in wacom_retrieve_hid_descriptor()
723 features->distance_fuzz = 1; in wacom_retrieve_hid_descriptor()
724 features->tilt_fuzz = 1; in wacom_retrieve_hid_descriptor()
732 if (features->type == WIRELESS && intf) { in wacom_retrieve_hid_descriptor()
733 if (intf->cur_altsetting->desc.bInterfaceNumber == 0) in wacom_retrieve_hid_descriptor()
734 features->device_type = WACOM_DEVICETYPE_WL_MONITOR; in wacom_retrieve_hid_descriptor()
736 features->device_type = WACOM_DEVICETYPE_NONE; in wacom_retrieve_hid_descriptor()
757 struct wacom_features *features = &wacom->wacom_wac.features; in wacom_are_sibling()
759 struct wacom_features *sibling_features = &sibling_wacom->wacom_wac.features; in wacom_are_sibling()
760 __u32 oVid = features->oVid ? features->oVid : hdev->vendor; in wacom_are_sibling()
761 __u32 oPid = features->oPid ? features->oPid : hdev->product; in wacom_are_sibling()
764 if (features->oVid != HID_ANY_ID && sibling->vendor != oVid) in wacom_are_sibling()
766 if (features->oPid != HID_ANY_ID && sibling->product != oPid) in wacom_are_sibling()
770 * Devices with the same VID/PID must share the same physical in wacom_are_sibling()
771 * device path, while those with different VID/PID must share in wacom_are_sibling()
774 if (hdev->vendor == sibling->vendor && hdev->product == sibling->product) { in wacom_are_sibling()
783 if (features->type != HID_GENERIC) in wacom_are_sibling()
787 * Direct-input devices may not be siblings of indirect-input in wacom_are_sibling()
790 if ((features->device_type & WACOM_DEVICETYPE_DIRECT) && in wacom_are_sibling()
791 !(sibling_features->device_type & WACOM_DEVICETYPE_DIRECT)) in wacom_are_sibling()
795 * Indirect-input devices may not be siblings of direct-input in wacom_are_sibling()
798 if (!(features->device_type & WACOM_DEVICETYPE_DIRECT) && in wacom_are_sibling()
799 (sibling_features->device_type & WACOM_DEVICETYPE_DIRECT)) in wacom_are_sibling()
803 if ((features->device_type & WACOM_DEVICETYPE_PEN) && in wacom_are_sibling()
804 !(sibling_features->device_type & WACOM_DEVICETYPE_TOUCH)) in wacom_are_sibling()
808 if ((features->device_type & WACOM_DEVICETYPE_TOUCH) && in wacom_are_sibling()
809 !(sibling_features->device_type & WACOM_DEVICETYPE_PEN)) in wacom_are_sibling()
823 /* Try to find an already-probed interface from the same device */ in wacom_get_hdev_data()
825 if (hid_compare_device_paths(hdev, data->dev, '/')) { in wacom_get_hdev_data()
826 kref_get(&data->kref); in wacom_get_hdev_data()
833 if (wacom_are_sibling(hdev, data->dev)) { in wacom_get_hdev_data()
834 kref_get(&data->kref); in wacom_get_hdev_data()
848 list_del(&data->list); in wacom_release_shared_data()
858 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_remove_shared_data()
860 if (wacom_wac->shared) { in wacom_remove_shared_data()
861 data = container_of(wacom_wac->shared, struct wacom_hdev_data, in wacom_remove_shared_data()
864 if (wacom_wac->shared->touch == wacom->hdev) in wacom_remove_shared_data()
865 wacom_wac->shared->touch = NULL; in wacom_remove_shared_data()
866 else if (wacom_wac->shared->pen == wacom->hdev) in wacom_remove_shared_data()
867 wacom_wac->shared->pen = NULL; in wacom_remove_shared_data()
869 kref_put(&data->kref, wacom_release_shared_data); in wacom_remove_shared_data()
870 wacom_wac->shared = NULL; in wacom_remove_shared_data()
877 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_add_shared_data()
887 retval = -ENOMEM; in wacom_add_shared_data()
891 kref_init(&data->kref); in wacom_add_shared_data()
892 data->dev = hdev; in wacom_add_shared_data()
893 list_add_tail(&data->list, &wacom_udev_list); in wacom_add_shared_data()
896 wacom_wac->shared = &data->shared; in wacom_add_shared_data()
898 retval = devm_add_action(&hdev->dev, wacom_remove_shared_data, wacom); in wacom_add_shared_data()
905 if (wacom_wac->features.device_type & WACOM_DEVICETYPE_TOUCH) in wacom_add_shared_data()
906 wacom_wac->shared->touch = hdev; in wacom_add_shared_data()
907 else if (wacom_wac->features.device_type & WACOM_DEVICETYPE_PEN) in wacom_add_shared_data()
908 wacom_wac->shared->pen = hdev; in wacom_add_shared_data()
922 if (!wacom->led.groups) in wacom_led_control()
923 return -ENOTSUPP; in wacom_led_control()
925 if (wacom->wacom_wac.features.type == REMOTE) in wacom_led_control()
926 return -ENOTSUPP; in wacom_led_control()
928 if (wacom->wacom_wac.pid) { /* wireless connected */ in wacom_led_control()
932 else if (wacom->wacom_wac.features.type == INTUOSP2_BT) { in wacom_led_control()
938 return -ENOMEM; in wacom_led_control()
940 if (wacom->wacom_wac.features.type == HID_GENERIC) { in wacom_led_control()
942 buf[1] = wacom->led.llv; in wacom_led_control()
943 buf[2] = wacom->led.groups[0].select & 0x03; in wacom_led_control()
945 } else if ((wacom->wacom_wac.features.type >= INTUOS5S && in wacom_led_control()
946 wacom->wacom_wac.features.type <= INTUOSPL)) { in wacom_led_control()
952 int ring_led = wacom->led.groups[0].select & 0x03; in wacom_led_control()
953 int ring_lum = (((wacom->led.llv & 0x60) >> 5) - 1) & 0x03; in wacom_led_control()
958 if (wacom->wacom_wac.pid) { in wacom_led_control()
959 wacom_get_report(wacom->hdev, HID_FEATURE_REPORT, in wacom_led_control()
966 else if (wacom->wacom_wac.features.type == INTUOSP2_BT) { in wacom_led_control()
973 buf[9] = wacom->led.llv; in wacom_led_control()
974 buf[10] = wacom->led.groups[0].select & 0x03; in wacom_led_control()
977 int led = wacom->led.groups[0].select | 0x4; in wacom_led_control()
979 if (wacom->wacom_wac.features.type == WACOM_21UX2 || in wacom_led_control()
980 wacom->wacom_wac.features.type == WACOM_24HD) in wacom_led_control()
981 led |= (wacom->led.groups[1].select << 4) | 0x40; in wacom_led_control()
985 buf[2] = wacom->led.llv; in wacom_led_control()
986 buf[3] = wacom->led.hlv; in wacom_led_control()
987 buf[4] = wacom->led.img_lum; in wacom_led_control()
990 retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, buf, buf_size, in wacom_led_control()
1006 return -ENOMEM; in wacom_led_putimage()
1011 retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, buf, 2, in wacom_led_putimage()
1022 retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, in wacom_led_putimage()
1031 wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, buf, 2, in wacom_led_putimage()
1051 mutex_lock(&wacom->lock); in wacom_led_select_store()
1053 wacom->led.groups[set_id].select = id & 0x3; in wacom_led_select_store()
1056 mutex_unlock(&wacom->lock); in wacom_led_select_store()
1073 wacom->led.groups[SET_ID].select); \
1092 mutex_lock(&wacom->lock); in wacom_luminance_store()
1097 mutex_unlock(&wacom->lock); in wacom_luminance_store()
1109 return wacom_luminance_store(wacom, &wacom->led.field, \
1116 return scnprintf(buf, PAGE_SIZE, "%d\n", wacom->led.field); \
1135 if (hdev->bus == BUS_BLUETOOTH) { in wacom_button_image_store()
1144 return -EINVAL; in wacom_button_image_store()
1146 mutex_lock(&wacom->lock); in wacom_button_image_store()
1150 mutex_unlock(&wacom->lock); in wacom_button_image_store()
1235 struct kobject *kobj = devres->root; in wacom_devm_sysfs_group_release()
1238 __func__, devres->group->name); in wacom_devm_sysfs_group_release()
1239 sysfs_remove_group(kobj, devres->group); in wacom_devm_sysfs_group_release()
1253 return -ENOMEM; in __wacom_devm_sysfs_create_group()
1255 devres->group = group; in __wacom_devm_sysfs_create_group()
1256 devres->root = root; in __wacom_devm_sysfs_create_group()
1258 error = sysfs_create_group(devres->root, group); in __wacom_devm_sysfs_create_group()
1264 devres_add(&wacom->hdev->dev, devres); in __wacom_devm_sysfs_create_group()
1272 return __wacom_devm_sysfs_create_group(wacom, &wacom->hdev->dev.kobj, in wacom_devm_sysfs_create_group()
1285 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_devm_kfifo_alloc()
1294 return -ENOMEM; in wacom_devm_kfifo_alloc()
1302 devres_add(&wacom->hdev->dev, pen_fifo); in wacom_devm_kfifo_alloc()
1303 wacom_wac->pen_fifo = pen_fifo; in wacom_devm_kfifo_alloc()
1310 struct wacom *wacom = led->wacom; in wacom_leds_brightness_get()
1312 if (wacom->led.max_hlv) in wacom_leds_brightness_get()
1313 return led->hlv * LED_FULL / wacom->led.max_hlv; in wacom_leds_brightness_get()
1315 if (wacom->led.max_llv) in wacom_leds_brightness_get()
1316 return led->llv * LED_FULL / wacom->led.max_llv; in wacom_leds_brightness_get()
1325 struct wacom *wacom = led->wacom; in __wacom_led_brightness_get()
1327 if (wacom->led.groups[led->group].select != led->id) in __wacom_led_brightness_get()
1337 struct wacom *wacom = led->wacom; in wacom_led_brightness_set()
1340 mutex_lock(&wacom->lock); in wacom_led_brightness_set()
1342 if (!wacom->led.groups || (brightness == LED_OFF && in wacom_led_brightness_set()
1343 wacom->led.groups[led->group].select != led->id)) { in wacom_led_brightness_set()
1348 led->llv = wacom->led.llv = wacom->led.max_llv * brightness / LED_FULL; in wacom_led_brightness_set()
1349 led->hlv = wacom->led.hlv = wacom->led.max_hlv * brightness / LED_FULL; in wacom_led_brightness_set()
1351 wacom->led.groups[led->group].select = led->id; in wacom_led_brightness_set()
1356 mutex_unlock(&wacom->lock); in wacom_led_brightness_set()
1374 "%s::wacom-%d.%d", in wacom_led_register_one()
1379 return -ENOMEM; in wacom_led_register_one()
1382 led->trigger.name = name; in wacom_led_register_one()
1383 error = devm_led_trigger_register(dev, &led->trigger); in wacom_led_register_one()
1385 hid_err(wacom->hdev, in wacom_led_register_one()
1387 led->cdev.name, error); in wacom_led_register_one()
1392 led->group = group; in wacom_led_register_one()
1393 led->id = id; in wacom_led_register_one()
1394 led->wacom = wacom; in wacom_led_register_one()
1395 led->llv = wacom->led.llv; in wacom_led_register_one()
1396 led->hlv = wacom->led.hlv; in wacom_led_register_one()
1397 led->cdev.name = name; in wacom_led_register_one()
1398 led->cdev.max_brightness = LED_FULL; in wacom_led_register_one()
1399 led->cdev.flags = LED_HW_PLUGGABLE; in wacom_led_register_one()
1400 led->cdev.brightness_get = __wacom_led_brightness_get; in wacom_led_register_one()
1402 led->cdev.brightness_set_blocking = wacom_led_brightness_set; in wacom_led_register_one()
1403 led->cdev.default_trigger = led->cdev.name; in wacom_led_register_one()
1405 led->cdev.brightness_set = wacom_led_readonly_brightness_set; in wacom_led_register_one()
1408 error = devm_led_classdev_register(dev, &led->cdev); in wacom_led_register_one()
1410 hid_err(wacom->hdev, in wacom_led_register_one()
1412 led->cdev.name, error); in wacom_led_register_one()
1413 led->cdev.name = NULL; in wacom_led_register_one()
1424 devres_release_group(group->dev, group); in wacom_led_groups_release_one()
1435 if (group_id >= wacom->led.count || count <= 0) in wacom_led_groups_alloc_and_register_one()
1436 return -EINVAL; in wacom_led_groups_alloc_and_register_one()
1438 if (!devres_open_group(dev, &wacom->led.groups[group_id], GFP_KERNEL)) in wacom_led_groups_alloc_and_register_one()
1439 return -ENOMEM; in wacom_led_groups_alloc_and_register_one()
1443 error = -ENOMEM; in wacom_led_groups_alloc_and_register_one()
1447 wacom->led.groups[group_id].leds = leds; in wacom_led_groups_alloc_and_register_one()
1448 wacom->led.groups[group_id].count = count; in wacom_led_groups_alloc_and_register_one()
1457 wacom->led.groups[group_id].dev = dev; in wacom_led_groups_alloc_and_register_one()
1459 devres_close_group(dev, &wacom->led.groups[group_id]); in wacom_led_groups_alloc_and_register_one()
1470 error = devm_add_action_or_reset(&wacom->hdev->dev, in wacom_led_groups_alloc_and_register_one()
1472 &wacom->led.groups[group_id]); in wacom_led_groups_alloc_and_register_one()
1479 devres_release_group(dev, &wacom->led.groups[group_id]); in wacom_led_groups_alloc_and_register_one()
1488 if (group_id >= wacom->led.count) in wacom_led_find()
1491 group = &wacom->led.groups[group_id]; in wacom_led_find()
1493 if (!group->leds) in wacom_led_find()
1496 id %= group->count; in wacom_led_find()
1498 return &group->leds[id]; in wacom_led_find()
1515 group = cur->group; in wacom_led_next()
1516 next = cur->id; in wacom_led_next()
1522 } while (next_led->cdev.trigger != &next_led->trigger); in wacom_led_next()
1531 wacom->led.groups = NULL; in wacom_led_groups_release()
1532 wacom->led.count = 0; in wacom_led_groups_release()
1537 struct device *dev = &wacom->hdev->dev; in wacom_led_groups_allocate()
1544 return -ENOMEM; in wacom_led_groups_allocate()
1550 wacom->led.groups = groups; in wacom_led_groups_allocate()
1551 wacom->led.count = count; in wacom_led_groups_allocate()
1562 if (!wacom->wacom_wac.pad_input) in wacom_leds_alloc_and_register()
1563 return -EINVAL; in wacom_leds_alloc_and_register()
1565 dev = &wacom->wacom_wac.pad_input->dev; in wacom_leds_alloc_and_register()
1586 if (!(wacom->wacom_wac.features.device_type & WACOM_DEVICETYPE_PAD)) in wacom_initialize_leds()
1590 switch (wacom->wacom_wac.features.type) { in wacom_initialize_leds()
1592 if (!wacom->generic_has_leds) in wacom_initialize_leds()
1594 wacom->led.llv = 100; in wacom_initialize_leds()
1595 wacom->led.max_llv = 100; in wacom_initialize_leds()
1599 hid_err(wacom->hdev, in wacom_initialize_leds()
1612 wacom->led.llv = 10; in wacom_initialize_leds()
1613 wacom->led.hlv = 20; in wacom_initialize_leds()
1614 wacom->led.max_llv = 127; in wacom_initialize_leds()
1615 wacom->led.max_hlv = 127; in wacom_initialize_leds()
1616 wacom->led.img_lum = 10; in wacom_initialize_leds()
1620 hid_err(wacom->hdev, in wacom_initialize_leds()
1631 wacom->led.llv = 0; in wacom_initialize_leds()
1632 wacom->led.hlv = 0; in wacom_initialize_leds()
1633 wacom->led.img_lum = 0; in wacom_initialize_leds()
1637 hid_err(wacom->hdev, in wacom_initialize_leds()
1652 wacom->led.llv = 32; in wacom_initialize_leds()
1653 wacom->led.max_llv = 96; in wacom_initialize_leds()
1657 hid_err(wacom->hdev, in wacom_initialize_leds()
1667 wacom->led.llv = 50; in wacom_initialize_leds()
1668 wacom->led.max_llv = 100; in wacom_initialize_leds()
1671 hid_err(wacom->hdev, in wacom_initialize_leds()
1677 case REMOTE: in wacom_initialize_leds()
1678 wacom->led.llv = 255; in wacom_initialize_leds()
1679 wacom->led.max_llv = 255; in wacom_initialize_leds()
1682 hid_err(wacom->hdev, in wacom_initialize_leds()
1693 hid_err(wacom->hdev, in wacom_initialize_leds()
1711 schedule_delayed_work(&wacom->init_work, msecs_to_jiffies(1000)); in wacom_query_tablet_data()
1731 val->strval = battery->wacom->wacom_wac.name; in wacom_battery_get_property()
1734 val->intval = battery->bat_connected; in wacom_battery_get_property()
1737 val->intval = POWER_SUPPLY_SCOPE_DEVICE; in wacom_battery_get_property()
1740 val->intval = battery->battery_capacity; in wacom_battery_get_property()
1743 if (battery->bat_status != WACOM_POWER_SUPPLY_STATUS_AUTO) in wacom_battery_get_property()
1744 val->intval = battery->bat_status; in wacom_battery_get_property()
1745 else if (battery->bat_charging) in wacom_battery_get_property()
1746 val->intval = POWER_SUPPLY_STATUS_CHARGING; in wacom_battery_get_property()
1747 else if (battery->battery_capacity == 100 && in wacom_battery_get_property()
1748 battery->ps_connected) in wacom_battery_get_property()
1749 val->intval = POWER_SUPPLY_STATUS_FULL; in wacom_battery_get_property()
1750 else if (battery->ps_connected) in wacom_battery_get_property()
1751 val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; in wacom_battery_get_property()
1753 val->intval = POWER_SUPPLY_STATUS_DISCHARGING; in wacom_battery_get_property()
1756 ret = -EINVAL; in wacom_battery_get_property()
1767 struct device *dev = &wacom->hdev->dev; in __wacom_initialize_battery()
1770 struct power_supply_desc *bat_desc = &battery->bat_desc; in __wacom_initialize_battery()
1775 return -ENOMEM; in __wacom_initialize_battery()
1777 battery->wacom = wacom; in __wacom_initialize_battery()
1779 n = atomic_inc_return(&battery_no) - 1; in __wacom_initialize_battery()
1781 bat_desc->properties = wacom_battery_props; in __wacom_initialize_battery()
1782 bat_desc->num_properties = ARRAY_SIZE(wacom_battery_props); in __wacom_initialize_battery()
1783 bat_desc->get_property = wacom_battery_get_property; in __wacom_initialize_battery()
1784 sprintf(battery->bat_name, "wacom_battery_%ld", n); in __wacom_initialize_battery()
1785 bat_desc->name = battery->bat_name; in __wacom_initialize_battery()
1786 bat_desc->type = POWER_SUPPLY_TYPE_USB; in __wacom_initialize_battery()
1787 bat_desc->use_for_apm = 0; in __wacom_initialize_battery()
1795 power_supply_powers(ps_bat, &wacom->hdev->dev); in __wacom_initialize_battery()
1797 battery->battery = ps_bat; in __wacom_initialize_battery()
1809 if (wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) in wacom_initialize_battery()
1810 return __wacom_initialize_battery(wacom, &wacom->battery); in wacom_initialize_battery()
1817 if (wacom->battery.battery) { in wacom_destroy_battery()
1818 devres_release_group(&wacom->hdev->dev, in wacom_destroy_battery()
1819 &wacom->battery.bat_desc); in wacom_destroy_battery()
1820 wacom->battery.battery = NULL; in wacom_destroy_battery()
1831 return snprintf(buf, PAGE_SIZE, "%i\n", wacom->wacom_wac.bt_high_speed); in wacom_show_speed()
1843 return -EINVAL; in wacom_store_speed()
1846 return -EINVAL; in wacom_store_speed()
1848 wacom_bt_query_tablet_data(hdev, new_speed, &wacom->wacom_wac.features); in wacom_store_speed()
1861 struct device *dev = kobj_to_dev(kobj->parent); in wacom_show_remote_mode()
1866 mode = wacom->led.groups[index].select; in wacom_show_remote_mode()
1867 return sprintf(buf, "%d\n", mode < 3 ? mode : -1); in wacom_show_remote_mode()
1876 static struct kobj_attribute remote##SET_ID##_mode_attr = { \
1881 static struct attribute *remote##SET_ID##_serial_attrs[] = { \
1882 &remote##SET_ID##_mode_attr.attr, \
1885 static struct attribute_group remote##SET_ID##_serial_group = { \
1887 .attrs = remote##SET_ID##_serial_attrs, \
1900 struct wacom_remote *remote = wacom->remote; in wacom_remote_create_attr_group() local
1902 remote->remotes[index].group.name = devm_kasprintf(&wacom->hdev->dev, in wacom_remote_create_attr_group()
1905 if (!remote->remotes[index].group.name) in wacom_remote_create_attr_group()
1906 return -ENOMEM; in wacom_remote_create_attr_group()
1908 error = __wacom_devm_sysfs_create_group(wacom, remote->remote_dir, in wacom_remote_create_attr_group()
1909 &remote->remotes[index].group); in wacom_remote_create_attr_group()
1911 remote->remotes[index].group.name = NULL; in wacom_remote_create_attr_group()
1912 hid_err(wacom->hdev, in wacom_remote_create_attr_group()
1928 return -ENOMEM; in wacom_cmd_unpair_remote()
1933 retval = wacom_set_report(wacom->hdev, HID_OUTPUT_REPORT, buf, in wacom_cmd_unpair_remote()
1945 struct device *dev = kobj_to_dev(kobj->parent); in wacom_store_unpair_remote()
1953 hid_info(wacom->hdev, "remote: unrecognized unpair code: %s\n", in wacom_store_unpair_remote()
1955 return -1; in wacom_store_unpair_remote()
1958 mutex_lock(&wacom->lock); in wacom_store_unpair_remote()
1961 mutex_unlock(&wacom->lock); in wacom_store_unpair_remote()
1979 struct wacom_remote *remote = wacom->remote; in wacom_remotes_destroy() local
1981 if (!remote) in wacom_remotes_destroy()
1984 kobject_put(remote->remote_dir); in wacom_remotes_destroy()
1985 kfifo_free(&remote->remote_fifo); in wacom_remotes_destroy()
1986 wacom->remote = NULL; in wacom_remotes_destroy()
1992 struct wacom_remote *remote; in wacom_initialize_remotes() local
1995 if (wacom->wacom_wac.features.type != REMOTE) in wacom_initialize_remotes()
1998 remote = devm_kzalloc(&wacom->hdev->dev, sizeof(*wacom->remote), in wacom_initialize_remotes()
2000 if (!remote) in wacom_initialize_remotes()
2001 return -ENOMEM; in wacom_initialize_remotes()
2003 wacom->remote = remote; in wacom_initialize_remotes()
2005 spin_lock_init(&remote->remote_lock); in wacom_initialize_remotes()
2007 error = kfifo_alloc(&remote->remote_fifo, in wacom_initialize_remotes()
2011 hid_err(wacom->hdev, "failed allocating remote_fifo\n"); in wacom_initialize_remotes()
2012 return -ENOMEM; in wacom_initialize_remotes()
2015 remote->remotes[0].group = remote0_serial_group; in wacom_initialize_remotes()
2016 remote->remotes[1].group = remote1_serial_group; in wacom_initialize_remotes()
2017 remote->remotes[2].group = remote2_serial_group; in wacom_initialize_remotes()
2018 remote->remotes[3].group = remote3_serial_group; in wacom_initialize_remotes()
2019 remote->remotes[4].group = remote4_serial_group; in wacom_initialize_remotes()
2021 remote->remote_dir = kobject_create_and_add("wacom_remote", in wacom_initialize_remotes()
2022 &wacom->hdev->dev.kobj); in wacom_initialize_remotes()
2023 if (!remote->remote_dir) in wacom_initialize_remotes()
2024 return -ENOMEM; in wacom_initialize_remotes()
2026 error = sysfs_create_files(remote->remote_dir, remote_unpair_attrs); in wacom_initialize_remotes()
2029 hid_err(wacom->hdev, in wacom_initialize_remotes()
2035 wacom->led.groups[i].select = WACOM_STATUS_UNKNOWN; in wacom_initialize_remotes()
2036 remote->remotes[i].serial = 0; in wacom_initialize_remotes()
2039 error = devm_add_action_or_reset(&wacom->hdev->dev, in wacom_initialize_remotes()
2050 struct hid_device *hdev = wacom->hdev; in wacom_allocate_input()
2051 struct wacom_wac *wacom_wac = &(wacom->wacom_wac); in wacom_allocate_input()
2053 input_dev = devm_input_allocate_device(&hdev->dev); in wacom_allocate_input()
2057 input_dev->name = wacom_wac->features.name; in wacom_allocate_input()
2058 input_dev->phys = hdev->phys; in wacom_allocate_input()
2059 input_dev->dev.parent = &hdev->dev; in wacom_allocate_input()
2060 input_dev->open = wacom_open; in wacom_allocate_input()
2061 input_dev->close = wacom_close; in wacom_allocate_input()
2062 input_dev->uniq = hdev->uniq; in wacom_allocate_input()
2063 input_dev->id.bustype = hdev->bus; in wacom_allocate_input()
2064 input_dev->id.vendor = hdev->vendor; in wacom_allocate_input()
2065 input_dev->id.product = wacom_wac->pid ? wacom_wac->pid : hdev->product; in wacom_allocate_input()
2066 input_dev->id.version = hdev->version; in wacom_allocate_input()
2074 struct wacom_wac *wacom_wac = &(wacom->wacom_wac); in wacom_allocate_inputs()
2076 wacom_wac->pen_input = wacom_allocate_input(wacom); in wacom_allocate_inputs()
2077 wacom_wac->touch_input = wacom_allocate_input(wacom); in wacom_allocate_inputs()
2078 wacom_wac->pad_input = wacom_allocate_input(wacom); in wacom_allocate_inputs()
2079 if (!wacom_wac->pen_input || in wacom_allocate_inputs()
2080 !wacom_wac->touch_input || in wacom_allocate_inputs()
2081 !wacom_wac->pad_input) in wacom_allocate_inputs()
2082 return -ENOMEM; in wacom_allocate_inputs()
2084 wacom_wac->pen_input->name = wacom_wac->pen_name; in wacom_allocate_inputs()
2085 wacom_wac->touch_input->name = wacom_wac->touch_name; in wacom_allocate_inputs()
2086 wacom_wac->pad_input->name = wacom_wac->pad_name; in wacom_allocate_inputs()
2094 struct wacom_wac *wacom_wac = &(wacom->wacom_wac); in wacom_setup_inputs()
2097 pen_input_dev = wacom_wac->pen_input; in wacom_setup_inputs()
2098 touch_input_dev = wacom_wac->touch_input; in wacom_setup_inputs()
2099 pad_input_dev = wacom_wac->pad_input; in wacom_setup_inputs()
2102 return -EINVAL; in wacom_setup_inputs()
2108 wacom_wac->pen_input = NULL; in wacom_setup_inputs()
2116 wacom_wac->touch_input = NULL; in wacom_setup_inputs()
2124 wacom_wac->pad_input = NULL; in wacom_setup_inputs()
2134 struct wacom_wac *wacom_wac = &(wacom->wacom_wac); in wacom_register_inputs()
2137 pen_input_dev = wacom_wac->pen_input; in wacom_register_inputs()
2138 touch_input_dev = wacom_wac->touch_input; in wacom_register_inputs()
2139 pad_input_dev = wacom_wac->pad_input; in wacom_register_inputs()
2162 wacom_wac->pad_input = NULL; in wacom_register_inputs()
2163 wacom_wac->touch_input = NULL; in wacom_register_inputs()
2164 wacom_wac->pen_input = NULL; in wacom_register_inputs()
2175 if (features->x_resolution) { in wacom_set_default_phy()
2176 features->x_phy = (features->x_max * 100) / in wacom_set_default_phy()
2177 features->x_resolution; in wacom_set_default_phy()
2178 features->y_phy = (features->y_max * 100) / in wacom_set_default_phy()
2179 features->y_resolution; in wacom_set_default_phy()
2186 if (!features->unit) { in wacom_calculate_res()
2187 features->unit = 0x11; in wacom_calculate_res()
2188 features->unitExpo = -3; in wacom_calculate_res()
2191 features->x_resolution = wacom_calc_hid_res(features->x_max, in wacom_calculate_res()
2192 features->x_phy, in wacom_calculate_res()
2193 features->unit, in wacom_calculate_res()
2194 features->unitExpo); in wacom_calculate_res()
2195 features->y_resolution = wacom_calc_hid_res(features->y_max, in wacom_calculate_res()
2196 features->y_phy, in wacom_calculate_res()
2197 features->unit, in wacom_calculate_res()
2198 features->unitExpo); in wacom_calculate_res()
2205 if ((wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) && in wacom_battery_work()
2206 !wacom->battery.battery) { in wacom_battery_work()
2209 else if (!(wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) && in wacom_battery_work()
2210 wacom->battery.battery) { in wacom_battery_work()
2221 report_enum = hdev->report_enum + HID_INPUT_REPORT; in wacom_compute_pktlen()
2223 list_for_each_entry(report, &report_enum->report_list, list) { in wacom_compute_pktlen()
2234 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_update_name()
2235 struct wacom_features *features = &wacom_wac->features; in wacom_update_name()
2236 char name[WACOM_NAME_MAX - 20]; /* Leave some room for suffixes */ in wacom_update_name()
2239 if ((features->type == HID_GENERIC) && !strcmp("Wacom HID", features->name)) { in wacom_update_name()
2240 char *product_name = wacom->hdev->name; in wacom_update_name()
2242 if (hid_is_usb(wacom->hdev)) { in wacom_update_name()
2243 struct usb_interface *intf = to_usb_interface(wacom->hdev->dev.parent); in wacom_update_name()
2245 if (dev->product != NULL) in wacom_update_name()
2246 product_name = dev->product; in wacom_update_name()
2249 if (wacom->hdev->bus == BUS_I2C) { in wacom_update_name()
2251 features->name, wacom->hdev->product); in wacom_update_name()
2270 if (name[strlen(name)-1] == ' ') in wacom_update_name()
2271 name[strlen(name)-1] = '\0'; in wacom_update_name()
2273 strlcpy(name, features->name, sizeof(name)); in wacom_update_name()
2276 snprintf(wacom_wac->name, sizeof(wacom_wac->name), "%s%s", in wacom_update_name()
2280 snprintf(wacom_wac->pen_name, sizeof(wacom_wac->pen_name), in wacom_update_name()
2282 snprintf(wacom_wac->touch_name, sizeof(wacom_wac->touch_name), in wacom_update_name()
2284 snprintf(wacom_wac->pad_name, sizeof(wacom_wac->pad_name), in wacom_update_name()
2290 struct hid_device *hdev = wacom->hdev; in wacom_release_resources()
2292 if (!wacom->resources) in wacom_release_resources()
2295 devres_release_group(&hdev->dev, wacom); in wacom_release_resources()
2297 wacom->resources = false; in wacom_release_resources()
2299 wacom->wacom_wac.pen_input = NULL; in wacom_release_resources()
2300 wacom->wacom_wac.touch_input = NULL; in wacom_release_resources()
2301 wacom->wacom_wac.pad_input = NULL; in wacom_release_resources()
2306 if (wacom_wac->features.device_type & WACOM_DEVICETYPE_TOUCH) { in wacom_set_shared_values()
2307 wacom_wac->shared->type = wacom_wac->features.type; in wacom_set_shared_values()
2308 wacom_wac->shared->touch_input = wacom_wac->touch_input; in wacom_set_shared_values()
2311 if (wacom_wac->has_mute_touch_switch) { in wacom_set_shared_values()
2312 wacom_wac->shared->has_mute_touch_switch = true; in wacom_set_shared_values()
2313 wacom_wac->shared->is_touch_on = true; in wacom_set_shared_values()
2316 if (wacom_wac->shared->has_mute_touch_switch && in wacom_set_shared_values()
2317 wacom_wac->shared->touch_input) { in wacom_set_shared_values()
2318 set_bit(EV_SW, wacom_wac->shared->touch_input->evbit); in wacom_set_shared_values()
2319 input_set_capability(wacom_wac->shared->touch_input, EV_SW, in wacom_set_shared_values()
2326 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_parse_and_register()
2327 struct wacom_features *features = &wacom_wac->features; in wacom_parse_and_register()
2328 struct hid_device *hdev = wacom->hdev; in wacom_parse_and_register()
2332 features->pktlen = wacom_compute_pktlen(hdev); in wacom_parse_and_register()
2333 if (features->pktlen > WACOM_PKGLEN_MAX) in wacom_parse_and_register()
2334 return -EINVAL; in wacom_parse_and_register()
2336 if (!devres_open_group(&hdev->dev, wacom, GFP_KERNEL)) in wacom_parse_and_register()
2337 return -ENOMEM; in wacom_parse_and_register()
2339 wacom->resources = true; in wacom_parse_and_register()
2350 if (features->type == BAMBOO_PAD) { in wacom_parse_and_register()
2351 if (features->pktlen == WACOM_PKGLEN_PENABLED) { in wacom_parse_and_register()
2352 features->type = HID_GENERIC; in wacom_parse_and_register()
2353 } else if ((features->pktlen != WACOM_PKGLEN_BPAD_TOUCH) && in wacom_parse_and_register()
2354 (features->pktlen != WACOM_PKGLEN_BPAD_TOUCH_USB)) { in wacom_parse_and_register()
2355 error = -ENODEV; in wacom_parse_and_register()
2367 if (features->device_type == WACOM_DEVICETYPE_NONE && in wacom_parse_and_register()
2368 features->type != WIRELESS) { in wacom_parse_and_register()
2369 error = features->type == HID_GENERIC ? -ENODEV : 0; in wacom_parse_and_register()
2371 dev_warn(&hdev->dev, "Unknown device_type for '%s'. %s.", in wacom_parse_and_register()
2372 hdev->name, in wacom_parse_and_register()
2378 features->device_type |= WACOM_DEVICETYPE_PEN; in wacom_parse_and_register()
2386 if ((features->type == BAMBOO_PEN) && in wacom_parse_and_register()
2387 ((features->device_type & WACOM_DEVICETYPE_TOUCH) || in wacom_parse_and_register()
2388 (features->device_type & WACOM_DEVICETYPE_PAD))) { in wacom_parse_and_register()
2389 error = -ENODEV; in wacom_parse_and_register()
2397 if (!(features->device_type & WACOM_DEVICETYPE_WL_MONITOR) && in wacom_parse_and_register()
2398 (features->quirks & WACOM_QUIRK_BATTERY)) { in wacom_parse_and_register()
2408 if (features->type == HID_GENERIC) in wacom_parse_and_register()
2422 if (wacom->wacom_wac.features.device_type & WACOM_DEVICETYPE_PAD) { in wacom_parse_and_register()
2438 if ((features->type == BAMBOO_TOUCH) && in wacom_parse_and_register()
2439 (features->device_type & WACOM_DEVICETYPE_PEN)) { in wacom_parse_and_register()
2440 cancel_delayed_work_sync(&wacom->init_work); in wacom_parse_and_register()
2442 error = -ENODEV; in wacom_parse_and_register()
2446 if (features->device_type & WACOM_DEVICETYPE_WL_MONITOR) { in wacom_parse_and_register()
2455 devres_close_group(&hdev->dev, wacom); in wacom_parse_and_register()
2469 struct usb_device *usbdev = wacom->usbdev; in wacom_wireless_work()
2470 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_wireless_work()
2487 hdev1 = usb_get_intfdata(usbdev->config->interface[1]); in wacom_wireless_work()
2489 wacom_wac1 = &(wacom1->wacom_wac); in wacom_wireless_work()
2493 hdev2 = usb_get_intfdata(usbdev->config->interface[2]); in wacom_wireless_work()
2495 wacom_wac2 = &(wacom2->wacom_wac); in wacom_wireless_work()
2498 if (wacom_wac->pid == 0) { in wacom_wireless_work()
2499 hid_info(wacom->hdev, "wireless tablet disconnected\n"); in wacom_wireless_work()
2503 hid_info(wacom->hdev, "wireless tablet connected with PID %x\n", in wacom_wireless_work()
2504 wacom_wac->pid); in wacom_wireless_work()
2506 while (id->bus) { in wacom_wireless_work()
2507 if (id->vendor == USB_VENDOR_ID_WACOM && in wacom_wireless_work()
2508 id->product == wacom_wac->pid) in wacom_wireless_work()
2513 if (!id->bus) { in wacom_wireless_work()
2514 hid_info(wacom->hdev, "ignoring unknown PID.\n"); in wacom_wireless_work()
2519 wacom_wac1->features = in wacom_wireless_work()
2520 *((struct wacom_features *)id->driver_data); in wacom_wireless_work()
2522 wacom_wac1->pid = wacom_wac->pid; in wacom_wireless_work()
2529 if (wacom_wac1->features.touch_max || in wacom_wireless_work()
2530 (wacom_wac1->features.type >= INTUOSHT && in wacom_wireless_work()
2531 wacom_wac1->features.type <= BAMBOO_PT)) { in wacom_wireless_work()
2532 wacom_wac2->features = in wacom_wireless_work()
2533 *((struct wacom_features *)id->driver_data); in wacom_wireless_work()
2534 wacom_wac2->pid = wacom_wac->pid; in wacom_wireless_work()
2541 strlcpy(wacom_wac->name, wacom_wac1->name, in wacom_wireless_work()
2542 sizeof(wacom_wac->name)); in wacom_wireless_work()
2558 struct wacom_remote *remote = wacom->remote; in wacom_remote_destroy_battery() local
2560 if (remote->remotes[index].battery.battery) { in wacom_remote_destroy_battery()
2561 devres_release_group(&wacom->hdev->dev, in wacom_remote_destroy_battery()
2562 &remote->remotes[index].battery.bat_desc); in wacom_remote_destroy_battery()
2563 remote->remotes[index].battery.battery = NULL; in wacom_remote_destroy_battery()
2564 remote->remotes[index].active_time = 0; in wacom_remote_destroy_battery()
2570 struct wacom_remote *remote = wacom->remote; in wacom_remote_destroy_one() local
2571 u32 serial = remote->remotes[index].serial; in wacom_remote_destroy_one()
2576 if (remote->remotes[i].serial == serial) { in wacom_remote_destroy_one()
2578 spin_lock_irqsave(&remote->remote_lock, flags); in wacom_remote_destroy_one()
2579 remote->remotes[i].registered = false; in wacom_remote_destroy_one()
2580 spin_unlock_irqrestore(&remote->remote_lock, flags); in wacom_remote_destroy_one()
2584 if (remote->remotes[i].group.name) in wacom_remote_destroy_one()
2585 devres_release_group(&wacom->hdev->dev, in wacom_remote_destroy_one()
2586 &remote->remotes[i]); in wacom_remote_destroy_one()
2588 remote->remotes[i].serial = 0; in wacom_remote_destroy_one()
2589 remote->remotes[i].group.name = NULL; in wacom_remote_destroy_one()
2590 wacom->led.groups[i].select = WACOM_STATUS_UNKNOWN; in wacom_remote_destroy_one()
2598 struct wacom_remote *remote = wacom->remote; in wacom_remote_create_one() local
2599 struct device *dev = &wacom->hdev->dev; in wacom_remote_create_one()
2602 /* A remote can pair more than once with an EKR, in wacom_remote_create_one()
2606 if (remote->remotes[k].serial == serial) in wacom_remote_create_one()
2611 remote->remotes[index].serial = serial; in wacom_remote_create_one()
2615 if (!devres_open_group(dev, &remote->remotes[index], GFP_KERNEL)) in wacom_remote_create_one()
2616 return -ENOMEM; in wacom_remote_create_one()
2622 remote->remotes[index].input = wacom_allocate_input(wacom); in wacom_remote_create_one()
2623 if (!remote->remotes[index].input) { in wacom_remote_create_one()
2624 error = -ENOMEM; in wacom_remote_create_one()
2627 remote->remotes[index].input->uniq = remote->remotes[index].group.name; in wacom_remote_create_one()
2628 remote->remotes[index].input->name = wacom->wacom_wac.pad_name; in wacom_remote_create_one()
2630 if (!remote->remotes[index].input->name) { in wacom_remote_create_one()
2631 error = -EINVAL; in wacom_remote_create_one()
2635 error = wacom_setup_pad_input_capabilities(remote->remotes[index].input, in wacom_remote_create_one()
2636 &wacom->wacom_wac); in wacom_remote_create_one()
2640 remote->remotes[index].serial = serial; in wacom_remote_create_one()
2642 error = input_register_device(remote->remotes[index].input); in wacom_remote_create_one()
2647 &remote->remotes[index].input->dev, in wacom_remote_create_one()
2652 remote->remotes[index].registered = true; in wacom_remote_create_one()
2654 devres_close_group(dev, &remote->remotes[index]); in wacom_remote_create_one()
2658 devres_release_group(dev, &remote->remotes[index]); in wacom_remote_create_one()
2659 remote->remotes[index].serial = 0; in wacom_remote_create_one()
2665 struct wacom_remote *remote = wacom->remote; in wacom_remote_attach_battery() local
2668 if (!remote->remotes[index].registered) in wacom_remote_attach_battery()
2671 if (remote->remotes[index].battery.battery) in wacom_remote_attach_battery()
2674 if (!remote->remotes[index].active_time) in wacom_remote_attach_battery()
2677 if (wacom->led.groups[index].select == WACOM_STATUS_UNKNOWN) in wacom_remote_attach_battery()
2681 &wacom->remote->remotes[index].battery); in wacom_remote_attach_battery()
2691 struct wacom_remote *remote = wacom->remote; in wacom_remote_work() local
2699 spin_lock_irqsave(&remote->remote_lock, flags); in wacom_remote_work()
2701 count = kfifo_out(&remote->remote_fifo, &data, sizeof(data)); in wacom_remote_work()
2704 hid_err(wacom->hdev, in wacom_remote_work()
2706 spin_unlock_irqrestore(&remote->remote_lock, flags); in wacom_remote_work()
2710 if (!kfifo_is_empty(&remote->remote_fifo)) in wacom_remote_work()
2711 wacom_schedule_work(&wacom->wacom_wac, WACOM_WORKER_REMOTE); in wacom_remote_work()
2713 spin_unlock_irqrestore(&remote->remote_lock, flags); in wacom_remote_work()
2716 serial = data.remote[i].serial; in wacom_remote_work()
2717 if (data.remote[i].connected) { in wacom_remote_work()
2719 if (kt - remote->remotes[i].active_time > WACOM_REMOTE_BATTERY_TIMEOUT in wacom_remote_work()
2720 && remote->remotes[i].active_time != 0) in wacom_remote_work()
2723 if (remote->remotes[i].serial == serial) { in wacom_remote_work()
2728 if (remote->remotes[i].serial) in wacom_remote_work()
2733 } else if (remote->remotes[i].serial) { in wacom_remote_work()
2742 struct wacom_shared *shared = wacom->wacom_wac.shared; in wacom_mode_change_work()
2745 bool is_direct = wacom->wacom_wac.is_direct_mode; in wacom_mode_change_work()
2748 if (shared->pen) { in wacom_mode_change_work()
2749 wacom1 = hid_get_drvdata(shared->pen); in wacom_mode_change_work()
2751 hid_hw_stop(wacom1->hdev); in wacom_mode_change_work()
2752 wacom1->wacom_wac.has_mode_change = true; in wacom_mode_change_work()
2753 wacom1->wacom_wac.is_direct_mode = is_direct; in wacom_mode_change_work()
2756 if (shared->touch) { in wacom_mode_change_work()
2757 wacom2 = hid_get_drvdata(shared->touch); in wacom_mode_change_work()
2759 hid_hw_stop(wacom2->hdev); in wacom_mode_change_work()
2760 wacom2->wacom_wac.has_mode_change = true; in wacom_mode_change_work()
2761 wacom2->wacom_wac.is_direct_mode = is_direct; in wacom_mode_change_work()
2787 if (!id->driver_data) in wacom_probe()
2788 return -EINVAL; in wacom_probe()
2790 hdev->quirks |= HID_QUIRK_NO_INIT_REPORTS; in wacom_probe()
2792 /* hid-core sets this quirk for the boot interface */ in wacom_probe()
2793 hdev->quirks &= ~HID_QUIRK_NOGET; in wacom_probe()
2795 wacom = devm_kzalloc(&hdev->dev, sizeof(struct wacom), GFP_KERNEL); in wacom_probe()
2797 return -ENOMEM; in wacom_probe()
2800 wacom->hdev = hdev; in wacom_probe()
2802 wacom_wac = &wacom->wacom_wac; in wacom_probe()
2803 wacom_wac->features = *((struct wacom_features *)id->driver_data); in wacom_probe()
2804 features = &wacom_wac->features; in wacom_probe()
2806 if (features->check_for_hid_type && features->hid_type != hdev->type) in wacom_probe()
2807 return -ENODEV; in wacom_probe()
2813 wacom_wac->hid_data.inputmode = -1; in wacom_probe()
2814 wacom_wac->mode_report = -1; in wacom_probe()
2817 struct usb_interface *intf = to_usb_interface(hdev->dev.parent); in wacom_probe()
2820 wacom->usbdev = dev; in wacom_probe()
2821 wacom->intf = intf; in wacom_probe()
2824 mutex_init(&wacom->lock); in wacom_probe()
2825 INIT_DELAYED_WORK(&wacom->init_work, wacom_init_work); in wacom_probe()
2826 INIT_WORK(&wacom->wireless_work, wacom_wireless_work); in wacom_probe()
2827 INIT_WORK(&wacom->battery_work, wacom_battery_work); in wacom_probe()
2828 INIT_WORK(&wacom->remote_work, wacom_remote_work); in wacom_probe()
2829 INIT_WORK(&wacom->mode_change_work, wacom_mode_change_work); in wacom_probe()
2830 timer_setup(&wacom->idleprox_timer, &wacom_idleprox_timeout, TIMER_DEFERRABLE); in wacom_probe()
2839 if (features->type == BOOTLOADER) { in wacom_probe()
2840 hid_warn(hdev, "Using device in hidraw-only mode"); in wacom_probe()
2848 if (hdev->bus == BUS_BLUETOOTH) { in wacom_probe()
2849 error = device_create_file(&hdev->dev, &dev_attr_speed); in wacom_probe()
2862 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_remove()
2863 struct wacom_features *features = &wacom_wac->features; in wacom_remove()
2865 if (features->device_type & WACOM_DEVICETYPE_WL_MONITOR) in wacom_remove()
2870 cancel_delayed_work_sync(&wacom->init_work); in wacom_remove()
2871 cancel_work_sync(&wacom->wireless_work); in wacom_remove()
2872 cancel_work_sync(&wacom->battery_work); in wacom_remove()
2873 cancel_work_sync(&wacom->remote_work); in wacom_remove()
2874 cancel_work_sync(&wacom->mode_change_work); in wacom_remove()
2875 del_timer_sync(&wacom->idleprox_timer); in wacom_remove()
2876 if (hdev->bus == BUS_BLUETOOTH) in wacom_remove()
2877 device_remove_file(&hdev->dev, &dev_attr_speed); in wacom_remove()
2882 if (wacom->wacom_wac.features.type != REMOTE) in wacom_remove()
2891 mutex_lock(&wacom->lock); in wacom_resume()
2897 mutex_unlock(&wacom->lock); in wacom_resume()