Lines Matching refs:wacom

106 	struct wacom *wacom = hid_get_drvdata(hdev);  in wacom_wac_pen_serial_enforce()  local
107 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_wac_pen_serial_enforce()
174 struct wacom *wacom = hid_get_drvdata(hdev); in wacom_raw_event() local
176 if (wacom->wacom_wac.features.type == BOOTLOADER) 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()
191 struct wacom *wacom = input_get_drvdata(dev); in wacom_open() local
193 return hid_hw_open(wacom->hdev); in wacom_open()
198 struct wacom *wacom = input_get_drvdata(dev); in wacom_close() local
204 if (wacom->hdev) in wacom_close()
205 hid_hw_close(wacom->hdev); in wacom_close()
227 struct wacom *wacom = hid_get_drvdata(hdev); in wacom_hid_usage_quirk() local
228 struct wacom_features *features = &wacom->wacom_wac.features; 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()
310 struct wacom *wacom = hid_get_drvdata(hdev); in wacom_feature_mapping() local
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()
322 wacom->generic_has_leds = true; 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()
380 wacom->wacom_wac.mode_report = field->report->id; in wacom_feature_mapping()
381 wacom->wacom_wac.mode_value = 0; in wacom_feature_mapping()
443 struct wacom *wacom = hid_get_drvdata(hdev); in wacom_usage_mapping() local
444 struct wacom_features *features = &wacom->wacom_wac.features; in wacom_usage_mapping()
499 struct wacom *wacom = hid_get_drvdata(hdev); in wacom_post_parse_hid() local
500 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_post_parse_hid()
564 struct wacom *wacom = hid_get_drvdata(hdev); in wacom_hid_set_device_mode() local
565 struct hid_data *hid_data = &wacom->wacom_wac.hid_data; in wacom_hid_set_device_mode()
625 struct wacom *wacom = hid_get_drvdata(hdev); in wacom_bt_query_tablet_data() local
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()
682 static int _wacom_query_tablet_data(struct wacom *wacom) in _wacom_query_tablet_data() argument
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()
726 struct wacom *wacom = hid_get_drvdata(hdev); in wacom_retrieve_hid_descriptor() local
727 struct usb_interface *intf = wacom->intf; in wacom_retrieve_hid_descriptor()
766 struct wacom *wacom = hid_get_drvdata(hdev); in wacom_are_sibling() local
767 struct wacom_features *features = &wacom->wacom_wac.features; in wacom_are_sibling()
768 struct wacom *sibling_wacom = hid_get_drvdata(sibling); in wacom_are_sibling()
866 struct wacom *wacom = res; in wacom_remove_shared_data() local
868 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_remove_shared_data()
874 if (wacom_wac->shared->touch == wacom->hdev) in wacom_remove_shared_data()
876 else if (wacom_wac->shared->pen == wacom->hdev) in wacom_remove_shared_data()
886 struct wacom *wacom = hid_get_drvdata(hdev); in wacom_add_shared_data() local
887 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_add_shared_data()
910 retval = devm_add_action_or_reset(&hdev->dev, wacom_remove_shared_data, wacom); in wacom_add_shared_data()
922 static int wacom_led_control(struct wacom *wacom) in wacom_led_control() argument
929 if (!wacom->led.groups) in wacom_led_control()
932 if (wacom->wacom_wac.features.type == REMOTE) 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()
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()
1004 static int wacom_led_putimage(struct wacom *wacom, int button_id, u8 xfer_id, in wacom_led_putimage() argument
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()
1050 struct wacom *wacom = hid_get_drvdata(hdev); in wacom_led_select_store() local
1058 mutex_lock(&wacom->lock); in wacom_led_select_store()
1060 wacom->led.groups[set_id].select = id & 0x3; in wacom_led_select_store()
1061 err = wacom_led_control(wacom); in wacom_led_select_store()
1063 mutex_unlock(&wacom->lock); in wacom_led_select_store()
1078 struct wacom *wacom = hid_get_drvdata(hdev); \
1080 wacom->led.groups[SET_ID].select); \
1089 static ssize_t wacom_luminance_store(struct wacom *wacom, u8 *dest, in wacom_luminance_store() argument
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()
1106 if (dest == &wacom->led.llv) in wacom_luminance_store()
1108 else if (dest == &wacom->led.hlv) in wacom_luminance_store()
1113 err = wacom_led_control(wacom); in wacom_luminance_store()
1115 mutex_unlock(&wacom->lock); in wacom_luminance_store()
1125 struct wacom *wacom = hid_get_drvdata(hdev); \
1127 return wacom_luminance_store(wacom, &wacom->led.field, \
1133 struct wacom *wacom = dev_get_drvdata(dev); \
1134 return scnprintf(buf, PAGE_SIZE, "%d\n", wacom->led.field); \
1148 struct wacom *wacom = hid_get_drvdata(hdev); in wacom_button_image_store() local
1164 mutex_lock(&wacom->lock); in wacom_button_image_store()
1166 err = wacom_led_putimage(wacom, button_id, xfer_id, len, buf); in wacom_button_image_store()
1168 mutex_unlock(&wacom->lock); in wacom_button_image_store()
1260 static int __wacom_devm_sysfs_create_group(struct wacom *wacom, in __wacom_devm_sysfs_create_group() argument
1282 devres_add(&wacom->hdev->dev, devres); in __wacom_devm_sysfs_create_group()
1287 static int wacom_devm_sysfs_create_group(struct wacom *wacom, in wacom_devm_sysfs_create_group() argument
1290 return __wacom_devm_sysfs_create_group(wacom, &wacom->hdev->dev.kobj, in wacom_devm_sysfs_create_group()
1301 static int wacom_devm_kfifo_alloc(struct wacom *wacom) in wacom_devm_kfifo_alloc() argument
1303 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_devm_kfifo_alloc()
1321 devres_add(&wacom->hdev->dev, pen_fifo); in wacom_devm_kfifo_alloc()
1329 struct wacom *wacom = led->wacom; in wacom_leds_brightness_get() local
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() local
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() local
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()
1372 error = wacom_led_control(wacom); in wacom_led_brightness_set()
1375 mutex_unlock(&wacom->lock); in wacom_led_brightness_set()
1385 static int wacom_led_register_one(struct device *dev, struct wacom *wacom, in wacom_led_register_one() argument
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()
1418 if (id == wacom->led.groups[group].select) in wacom_led_register_one()
1422 hid_err(wacom->hdev, in wacom_led_register_one()
1431 hid_err(wacom->hdev, in wacom_led_register_one()
1449 struct wacom *wacom, in wacom_led_groups_alloc_and_register_one() argument
1456 if (group_id >= wacom->led.count || count <= 0) 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()
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()
1472 error = wacom_led_register_one(dev, wacom, &leds[i], 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()
1504 struct wacom_led *wacom_led_find(struct wacom *wacom, unsigned int group_id, in wacom_led_find() argument
1509 if (group_id >= wacom->led.count) in wacom_led_find()
1512 group = &wacom->led.groups[group_id]; in wacom_led_find()
1528 struct wacom_led *wacom_led_next(struct wacom *wacom, struct wacom_led *cur) in wacom_led_next() argument
1533 if (!wacom || !cur) in wacom_led_next()
1540 next_led = wacom_led_find(wacom, group, ++next); in wacom_led_next()
1550 struct wacom *wacom = data; in wacom_led_groups_release() local
1552 wacom->led.groups = NULL; in wacom_led_groups_release()
1553 wacom->led.count = 0; in wacom_led_groups_release()
1556 static int wacom_led_groups_allocate(struct wacom *wacom, int count) in wacom_led_groups_allocate() argument
1558 struct device *dev = &wacom->hdev->dev; in wacom_led_groups_allocate()
1567 error = devm_add_action_or_reset(dev, wacom_led_groups_release, wacom); 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()
1577 static int wacom_leds_alloc_and_register(struct wacom *wacom, int group_count, in wacom_leds_alloc_and_register() argument
1583 if (!wacom->wacom_wac.pad_input) in wacom_leds_alloc_and_register()
1586 dev = &wacom->wacom_wac.pad_input->dev; in wacom_leds_alloc_and_register()
1588 error = wacom_led_groups_allocate(wacom, group_count); in wacom_leds_alloc_and_register()
1593 error = wacom_led_groups_alloc_and_register_one(dev, wacom, i, in wacom_leds_alloc_and_register()
1603 int wacom_initialize_leds(struct wacom *wacom) in wacom_initialize_leds() argument
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()
1618 error = wacom_leds_alloc_and_register(wacom, 1, 4, false); in wacom_initialize_leds()
1620 hid_err(wacom->hdev, in wacom_initialize_leds()
1625 error = wacom_devm_sysfs_create_group(wacom, 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()
1639 error = wacom_leds_alloc_and_register(wacom, 1, 4, false); in wacom_initialize_leds()
1641 hid_err(wacom->hdev, in wacom_initialize_leds()
1646 error = wacom_devm_sysfs_create_group(wacom, 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()
1656 error = wacom_leds_alloc_and_register(wacom, 2, 4, false); in wacom_initialize_leds()
1658 hid_err(wacom->hdev, in wacom_initialize_leds()
1663 error = wacom_devm_sysfs_create_group(wacom, in wacom_initialize_leds()
1673 wacom->led.llv = 32; in wacom_initialize_leds()
1674 wacom->led.max_llv = 96; in wacom_initialize_leds()
1676 error = wacom_leds_alloc_and_register(wacom, 1, 4, false); in wacom_initialize_leds()
1678 hid_err(wacom->hdev, in wacom_initialize_leds()
1683 error = wacom_devm_sysfs_create_group(wacom, in wacom_initialize_leds()
1688 wacom->led.llv = 50; in wacom_initialize_leds()
1689 wacom->led.max_llv = 100; in wacom_initialize_leds()
1690 error = wacom_leds_alloc_and_register(wacom, 1, 4, false); in wacom_initialize_leds()
1692 hid_err(wacom->hdev, in wacom_initialize_leds()
1699 wacom->led.llv = 255; in wacom_initialize_leds()
1700 wacom->led.max_llv = 255; in wacom_initialize_leds()
1701 error = wacom_led_groups_allocate(wacom, 5); in wacom_initialize_leds()
1703 hid_err(wacom->hdev, in wacom_initialize_leds()
1714 hid_err(wacom->hdev, in wacom_initialize_leds()
1724 struct wacom *wacom = container_of(work, struct wacom, init_work.work); in wacom_init_work() local
1726 _wacom_query_tablet_data(wacom); in wacom_init_work()
1727 wacom_led_control(wacom); in wacom_init_work()
1730 static void wacom_query_tablet_data(struct wacom *wacom) in wacom_query_tablet_data() argument
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()
1784 static int __wacom_initialize_battery(struct wacom *wacom, in __wacom_initialize_battery() argument
1788 struct device *dev = &wacom->hdev->dev; in __wacom_initialize_battery()
1798 battery->wacom = wacom; in __wacom_initialize_battery()
1816 power_supply_powers(ps_bat, &wacom->hdev->dev); in __wacom_initialize_battery()
1828 static int wacom_initialize_battery(struct wacom *wacom) in wacom_initialize_battery() argument
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()
1836 static void wacom_destroy_battery(struct wacom *wacom) in wacom_destroy_battery() argument
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()
1847 struct wacom *wacom = container_of(work, struct wacom, aes_battery_work.work); in wacom_aes_battery_handler() local
1849 wacom_destroy_battery(wacom); in wacom_aes_battery_handler()
1857 struct wacom *wacom = hid_get_drvdata(hdev); in wacom_show_speed() local
1859 return sysfs_emit(buf, "%i\n", wacom->wacom_wac.bt_high_speed); in wacom_show_speed()
1867 struct wacom *wacom = hid_get_drvdata(hdev); in wacom_store_speed() local
1876 wacom_bt_query_tablet_data(hdev, new_speed, &wacom->wacom_wac.features); in wacom_store_speed()
1891 struct wacom *wacom = hid_get_drvdata(hdev); in wacom_show_remote_mode() local
1894 mode = wacom->led.groups[index].select; in wacom_show_remote_mode()
1924 static int wacom_remote_create_attr_group(struct wacom *wacom, __u32 serial, in wacom_remote_create_attr_group() argument
1928 struct wacom_remote *remote = wacom->remote; in wacom_remote_create_attr_group()
1930 remote->remotes[index].group.name = devm_kasprintf(&wacom->hdev->dev, in wacom_remote_create_attr_group()
1936 error = __wacom_devm_sysfs_create_group(wacom, remote->remote_dir, in wacom_remote_create_attr_group()
1940 hid_err(wacom->hdev, in wacom_remote_create_attr_group()
1948 static int wacom_cmd_unpair_remote(struct wacom *wacom, unsigned char selector) in wacom_cmd_unpair_remote() argument
1961 retval = wacom_set_report(wacom->hdev, HID_OUTPUT_REPORT, buf, in wacom_cmd_unpair_remote()
1975 struct wacom *wacom = hid_get_drvdata(hdev); in wacom_store_unpair_remote() local
1981 hid_info(wacom->hdev, "remote: unrecognized unpair code: %s\n", in wacom_store_unpair_remote()
1986 mutex_lock(&wacom->lock); in wacom_store_unpair_remote()
1988 err = wacom_cmd_unpair_remote(wacom, selector); in wacom_store_unpair_remote()
1989 mutex_unlock(&wacom->lock); in wacom_store_unpair_remote()
2006 struct wacom *wacom = data; in wacom_remotes_destroy() local
2007 struct wacom_remote *remote = wacom->remote; in wacom_remotes_destroy()
2014 wacom->remote = NULL; in wacom_remotes_destroy()
2017 static int wacom_initialize_remotes(struct wacom *wacom) in wacom_initialize_remotes() argument
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()
2031 wacom->remote = remote; in wacom_initialize_remotes()
2039 hid_err(wacom->hdev, "failed allocating remote_fifo\n"); in wacom_initialize_remotes()
2050 &wacom->hdev->dev.kobj); in wacom_initialize_remotes()
2059 hid_err(wacom->hdev, in wacom_initialize_remotes()
2067 wacom->led.groups[i].select = WACOM_STATUS_UNKNOWN; in wacom_initialize_remotes()
2071 error = devm_add_action_or_reset(&wacom->hdev->dev, in wacom_initialize_remotes()
2072 wacom_remotes_destroy, wacom); in wacom_initialize_remotes()
2079 static struct input_dev *wacom_allocate_input(struct wacom *wacom) in wacom_allocate_input() argument
2082 struct hid_device *hdev = wacom->hdev; in wacom_allocate_input()
2083 struct wacom_wac *wacom_wac = &(wacom->wacom_wac); in wacom_allocate_input()
2099 input_set_drvdata(input_dev, wacom); in wacom_allocate_input()
2104 static int wacom_allocate_inputs(struct wacom *wacom) in wacom_allocate_inputs() argument
2106 struct wacom_wac *wacom_wac = &(wacom->wacom_wac); in wacom_allocate_inputs()
2108 wacom_wac->pen_input = wacom_allocate_input(wacom); in wacom_allocate_inputs()
2109 wacom_wac->touch_input = wacom_allocate_input(wacom); in wacom_allocate_inputs()
2110 wacom_wac->pad_input = wacom_allocate_input(wacom); in wacom_allocate_inputs()
2123 static int wacom_setup_inputs(struct wacom *wacom) in wacom_setup_inputs() argument
2126 struct wacom_wac *wacom_wac = &(wacom->wacom_wac); in wacom_setup_inputs()
2163 static int wacom_register_inputs(struct wacom *wacom) in wacom_register_inputs() argument
2166 struct wacom_wac *wacom_wac = &(wacom->wacom_wac); in wacom_register_inputs()
2235 struct wacom *wacom = container_of(work, struct wacom, battery_work); in wacom_battery_work() local
2237 if ((wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) && in wacom_battery_work()
2238 !wacom->battery.battery) { in wacom_battery_work()
2239 wacom_initialize_battery(wacom); in wacom_battery_work()
2241 else if (!(wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) && in wacom_battery_work()
2242 wacom->battery.battery) { in wacom_battery_work()
2243 wacom_destroy_battery(wacom); in wacom_battery_work()
2264 static void wacom_update_name(struct wacom *wacom, const char *suffix) in wacom_update_name() argument
2266 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_update_name()
2272 char *product_name = wacom->hdev->name; in wacom_update_name()
2274 if (hid_is_usb(wacom->hdev)) { in wacom_update_name()
2275 struct usb_interface *intf = to_usb_interface(wacom->hdev->dev.parent); in wacom_update_name()
2281 if (wacom->hdev->bus == BUS_I2C) { in wacom_update_name()
2283 features->name, wacom->hdev->product); in wacom_update_name()
2288 hid_warn(wacom->hdev, "String overflow while assembling device name"); in wacom_update_name()
2308 hid_warn(wacom->hdev, "String overflow while assembling device name"); in wacom_update_name()
2324 static void wacom_release_resources(struct wacom *wacom) in wacom_release_resources() argument
2326 struct hid_device *hdev = wacom->hdev; in wacom_release_resources()
2328 if (!wacom->resources) in wacom_release_resources()
2331 devres_release_group(&hdev->dev, wacom); in wacom_release_resources()
2333 wacom->resources = false; in wacom_release_resources()
2335 wacom->wacom_wac.pen_input = NULL; in wacom_release_resources()
2336 wacom->wacom_wac.touch_input = NULL; in wacom_release_resources()
2337 wacom->wacom_wac.pad_input = NULL; in wacom_release_resources()
2366 static int wacom_parse_and_register(struct wacom *wacom, bool wireless) in wacom_parse_and_register() argument
2368 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_parse_and_register()
2370 struct hid_device *hdev = wacom->hdev; in wacom_parse_and_register()
2378 if (!devres_open_group(&hdev->dev, wacom, GFP_KERNEL)) in wacom_parse_and_register()
2381 error = wacom_devm_kfifo_alloc(wacom); in wacom_parse_and_register()
2385 wacom->resources = true; in wacom_parse_and_register()
2387 error = wacom_allocate_inputs(wacom); in wacom_parse_and_register()
2411 wacom_setup_device_quirks(wacom); in wacom_parse_and_register()
2429 wacom_update_name(wacom, wireless ? " (WL)" : ""); in wacom_parse_and_register()
2443 error = wacom_setup_inputs(wacom); in wacom_parse_and_register()
2457 error = wacom_register_inputs(wacom); in wacom_parse_and_register()
2461 if (wacom->wacom_wac.features.device_type & WACOM_DEVICETYPE_PAD) { in wacom_parse_and_register()
2462 error = wacom_initialize_leds(wacom); in wacom_parse_and_register()
2466 error = wacom_initialize_remotes(wacom); in wacom_parse_and_register()
2473 wacom_query_tablet_data(wacom); in wacom_parse_and_register()
2479 cancel_delayed_work_sync(&wacom->init_work); in wacom_parse_and_register()
2480 _wacom_query_tablet_data(wacom); in wacom_parse_and_register()
2494 devres_close_group(&hdev->dev, wacom); in wacom_parse_and_register()
2501 wacom_release_resources(wacom); in wacom_parse_and_register()
2507 struct wacom *wacom = container_of(work, struct wacom, wireless_work); in wacom_wireless_work() local
2508 struct usb_device *usbdev = wacom->usbdev; in wacom_wireless_work()
2509 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_wireless_work()
2511 struct wacom *wacom1, *wacom2; in wacom_wireless_work()
2520 wacom_destroy_battery(wacom); in wacom_wireless_work()
2538 hid_info(wacom->hdev, "wireless tablet disconnected\n"); in wacom_wireless_work()
2542 hid_info(wacom->hdev, "wireless tablet connected with PID %x\n", in wacom_wireless_work()
2553 hid_info(wacom->hdev, "ignoring unknown PID.\n"); in wacom_wireless_work()
2582 hid_warn(wacom->hdev, "String overflow while assembling device name"); in wacom_wireless_work()
2594 static void wacom_remote_destroy_battery(struct wacom *wacom, int index) in wacom_remote_destroy_battery() argument
2596 struct wacom_remote *remote = wacom->remote; in wacom_remote_destroy_battery()
2599 devres_release_group(&wacom->hdev->dev, in wacom_remote_destroy_battery()
2606 static void wacom_remote_destroy_one(struct wacom *wacom, unsigned int index) in wacom_remote_destroy_one() argument
2608 struct wacom_remote *remote = wacom->remote; in wacom_remote_destroy_one()
2620 wacom_remote_destroy_battery(wacom, i); in wacom_remote_destroy_one()
2623 devres_release_group(&wacom->hdev->dev, in wacom_remote_destroy_one()
2628 wacom->led.groups[i].select = WACOM_STATUS_UNKNOWN; in wacom_remote_destroy_one()
2633 static int wacom_remote_create_one(struct wacom *wacom, u32 serial, in wacom_remote_create_one() argument
2636 struct wacom_remote *remote = wacom->remote; in wacom_remote_create_one()
2637 struct device *dev = &wacom->hdev->dev; in wacom_remote_create_one()
2656 error = wacom_remote_create_attr_group(wacom, serial, index); in wacom_remote_create_one()
2660 remote->remotes[index].input = wacom_allocate_input(wacom); in wacom_remote_create_one()
2666 remote->remotes[index].input->name = wacom->wacom_wac.pad_name; in wacom_remote_create_one()
2674 &wacom->wacom_wac); in wacom_remote_create_one()
2686 wacom, index, 3, true); in wacom_remote_create_one()
2701 static int wacom_remote_attach_battery(struct wacom *wacom, int index) in wacom_remote_attach_battery() argument
2703 struct wacom_remote *remote = wacom->remote; in wacom_remote_attach_battery()
2715 if (wacom->led.groups[index].select == WACOM_STATUS_UNKNOWN) in wacom_remote_attach_battery()
2718 error = __wacom_initialize_battery(wacom, in wacom_remote_attach_battery()
2719 &wacom->remote->remotes[index].battery); in wacom_remote_attach_battery()
2728 struct wacom *wacom = container_of(work, struct wacom, remote_work); in wacom_remote_work() local
2729 struct wacom_remote *remote = wacom->remote; in wacom_remote_work()
2743 hid_err(wacom->hdev, in wacom_remote_work()
2750 wacom_schedule_work(&wacom->wacom_wac, WACOM_WORKER_REMOTE); in wacom_remote_work()
2760 wacom_remote_destroy_battery(wacom, i); in wacom_remote_work()
2763 wacom_remote_attach_battery(wacom, i); in wacom_remote_work()
2768 wacom_remote_destroy_one(wacom, i); in wacom_remote_work()
2770 wacom_remote_create_one(wacom, work_serial, i); in wacom_remote_work()
2773 wacom_remote_destroy_one(wacom, i); in wacom_remote_work()
2780 struct wacom *wacom = container_of(work, struct wacom, mode_change_work); in wacom_mode_change_work() local
2781 struct wacom_shared *shared = wacom->wacom_wac.shared; in wacom_mode_change_work()
2782 struct wacom *wacom1 = NULL; in wacom_mode_change_work()
2783 struct wacom *wacom2 = NULL; in wacom_mode_change_work()
2784 bool is_direct = wacom->wacom_wac.is_direct_mode; in wacom_mode_change_work()
2821 struct wacom *wacom; in wacom_probe() local
2834 wacom = devm_kzalloc(&hdev->dev, sizeof(struct wacom), GFP_KERNEL); in wacom_probe()
2835 if (!wacom) in wacom_probe()
2838 hid_set_drvdata(hdev, wacom); in wacom_probe()
2839 wacom->hdev = hdev; in wacom_probe()
2841 wacom_wac = &wacom->wacom_wac; in wacom_probe()
2855 wacom->usbdev = dev; in wacom_probe()
2856 wacom->intf = intf; in wacom_probe()
2859 mutex_init(&wacom->lock); in wacom_probe()
2860 INIT_DELAYED_WORK(&wacom->init_work, wacom_init_work); in wacom_probe()
2861 INIT_DELAYED_WORK(&wacom->aes_battery_work, wacom_aes_battery_handler); in wacom_probe()
2862 INIT_WORK(&wacom->wireless_work, wacom_wireless_work); in wacom_probe()
2863 INIT_WORK(&wacom->battery_work, wacom_battery_work); in wacom_probe()
2864 INIT_WORK(&wacom->remote_work, wacom_remote_work); in wacom_probe()
2865 INIT_WORK(&wacom->mode_change_work, wacom_mode_change_work); in wacom_probe()
2866 timer_setup(&wacom->idleprox_timer, &wacom_idleprox_timeout, TIMER_DEFERRABLE); in wacom_probe()
2880 error = wacom_parse_and_register(wacom, false); in wacom_probe()
2898 struct wacom *wacom = hid_get_drvdata(hdev); in wacom_remove() local
2899 struct wacom_wac *wacom_wac = &wacom->wacom_wac; in wacom_remove()
2907 cancel_delayed_work_sync(&wacom->init_work); in wacom_remove()
2908 cancel_delayed_work_sync(&wacom->aes_battery_work); in wacom_remove()
2909 cancel_work_sync(&wacom->wireless_work); in wacom_remove()
2910 cancel_work_sync(&wacom->battery_work); in wacom_remove()
2911 cancel_work_sync(&wacom->remote_work); in wacom_remove()
2912 cancel_work_sync(&wacom->mode_change_work); in wacom_remove()
2913 timer_delete_sync(&wacom->idleprox_timer); in wacom_remove()
2918 wacom_led_groups_release(wacom); in wacom_remove()
2920 if (wacom->wacom_wac.features.type != REMOTE) in wacom_remove()
2921 wacom_release_resources(wacom); in wacom_remove()
2927 struct wacom *wacom = hid_get_drvdata(hdev); in wacom_resume() local
2929 mutex_lock(&wacom->lock); in wacom_resume()
2932 _wacom_query_tablet_data(wacom); in wacom_resume()
2933 wacom_led_control(wacom); in wacom_resume()
2935 mutex_unlock(&wacom->lock); in wacom_resume()