Lines Matching defs:wacom

12 #include "wacom.h"
93 struct wacom *wacom = hid_get_drvdata(hdev);
94 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
161 struct wacom *wacom = hid_get_drvdata(hdev);
163 if (wacom->wacom_wac.features.type == BOOTLOADER)
172 memcpy(wacom->wacom_wac.data, raw_data, size);
174 wacom_wac_irq(&wacom->wacom_wac, size);
181 struct wacom *wacom = input_get_drvdata(dev);
183 return hid_hw_open(wacom->hdev);
188 struct wacom *wacom = input_get_drvdata(dev);
191 * wacom->hdev should never be null, but surprisingly, I had the case
194 if (wacom->hdev)
195 hid_hw_close(wacom->hdev);
217 struct wacom *wacom = hid_get_drvdata(hdev);
218 struct wacom_features *features = &wacom->wacom_wac.features;
228 wacom->wacom_wac.mode_report = field->report->id;
229 wacom->wacom_wac.mode_value = 2;
300 struct wacom *wacom = hid_get_drvdata(hdev);
301 struct wacom_features *features = &wacom->wacom_wac.features;
302 struct hid_data *hid_data = &wacom->wacom_wac.hid_data;
312 wacom->generic_has_leds = true;
355 wacom->wacom_wac.mode_report = field->report->id;
356 wacom->wacom_wac.mode_value = 0;
361 wacom->wacom_wac.mode_report = field->report->id;
362 wacom->wacom_wac.mode_value = 2;
370 wacom->wacom_wac.mode_report = field->report->id;
371 wacom->wacom_wac.mode_value = 0;
399 * Interface Descriptor of wacom devices can be incomplete and
433 struct wacom *wacom = hid_get_drvdata(hdev);
434 struct wacom_features *features = &wacom->wacom_wac.features;
489 struct wacom *wacom = hid_get_drvdata(hdev);
490 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
554 struct wacom *wacom = hid_get_drvdata(hdev);
555 struct hid_data *hid_data = &wacom->wacom_wac.hid_data;
615 struct wacom *wacom = hid_get_drvdata(hdev);
634 wacom->wacom_wac.bt_high_speed = speed;
648 wacom->wacom_wac.bt_features &= ~0x20;
650 wacom->wacom_wac.bt_features |= 0x20;
653 rep_data[1] = wacom->wacom_wac.bt_features;
658 wacom->wacom_wac.bt_high_speed = speed;
672 static int _wacom_query_tablet_data(struct wacom *wacom)
674 struct hid_device *hdev = wacom->hdev;
675 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
716 struct wacom *wacom = hid_get_drvdata(hdev);
717 struct usb_interface *intf = wacom->intf;
756 struct wacom *wacom = hid_get_drvdata(hdev);
757 struct wacom_features *features = &wacom->wacom_wac.features;
758 struct wacom *sibling_wacom = hid_get_drvdata(sibling);
856 struct wacom *wacom = res;
858 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
864 if (wacom_wac->shared->touch == wacom->hdev)
866 else if (wacom_wac->shared->pen == wacom->hdev)
876 struct wacom *wacom = hid_get_drvdata(hdev);
877 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
898 retval = devm_add_action(&hdev->dev, wacom_remove_shared_data, wacom);
901 wacom_remove_shared_data(wacom);
915 static int wacom_led_control(struct wacom *wacom)
922 if (!wacom->led.groups)
925 if (wacom->wacom_wac.features.type == REMOTE)
928 if (wacom->wacom_wac.pid) { /* wireless connected */
932 else if (wacom->wacom_wac.features.type == INTUOSP2_BT) {
940 if (wacom->wacom_wac.features.type == HID_GENERIC) {
942 buf[1] = wacom->led.llv;
943 buf[2] = wacom->led.groups[0].select & 0x03;
945 } else if ((wacom->wacom_wac.features.type >= INTUOS5S &&
946 wacom->wacom_wac.features.type <= INTUOSPL)) {
952 int ring_led = wacom->led.groups[0].select & 0x03;
953 int ring_lum = (((wacom->led.llv & 0x60) >> 5) - 1) & 0x03;
958 if (wacom->wacom_wac.pid) {
959 wacom_get_report(wacom->hdev, HID_FEATURE_REPORT,
966 else if (wacom->wacom_wac.features.type == INTUOSP2_BT) {
973 buf[9] = wacom->led.llv;
974 buf[10] = wacom->led.groups[0].select & 0x03;
977 int led = wacom->led.groups[0].select | 0x4;
979 if (wacom->wacom_wac.features.type == WACOM_21UX2 ||
980 wacom->wacom_wac.features.type == WACOM_24HD)
981 led |= (wacom->led.groups[1].select << 4) | 0x40;
985 buf[2] = wacom->led.llv;
986 buf[3] = wacom->led.hlv;
987 buf[4] = wacom->led.img_lum;
990 retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, buf, buf_size,
997 static int wacom_led_putimage(struct wacom *wacom, int button_id, u8 xfer_id,
1011 retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, buf, 2,
1022 retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT,
1031 wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, buf, 2,
1043 struct wacom *wacom = hid_get_drvdata(hdev);
1051 mutex_lock(&wacom->lock);
1053 wacom->led.groups[set_id].select = id & 0x3;
1054 err = wacom_led_control(wacom);
1056 mutex_unlock(&wacom->lock);
1071 struct wacom *wacom = hid_get_drvdata(hdev); \
1073 wacom->led.groups[SET_ID].select); \
1082 static ssize_t wacom_luminance_store(struct wacom *wacom, u8 *dest,
1092 mutex_lock(&wacom->lock);
1095 err = wacom_led_control(wacom);
1097 mutex_unlock(&wacom->lock);
1107 struct wacom *wacom = hid_get_drvdata(hdev); \
1109 return wacom_luminance_store(wacom, &wacom->led.field, \
1115 struct wacom *wacom = dev_get_drvdata(dev); \
1116 return scnprintf(buf, PAGE_SIZE, "%d\n", wacom->led.field); \
1130 struct wacom *wacom = hid_get_drvdata(hdev);
1146 mutex_lock(&wacom->lock);
1148 err = wacom_led_putimage(wacom, button_id, xfer_id, len, buf);
1150 mutex_unlock(&wacom->lock);
1242 static int __wacom_devm_sysfs_create_group(struct wacom *wacom,
1264 devres_add(&wacom->hdev->dev, devres);
1269 static int wacom_devm_sysfs_create_group(struct wacom *wacom,
1272 return __wacom_devm_sysfs_create_group(wacom, &wacom->hdev->dev.kobj,
1283 static int wacom_devm_kfifo_alloc(struct wacom *wacom)
1285 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1302 devres_add(&wacom->hdev->dev, pen_fifo);
1310 struct wacom *wacom = led->wacom;
1312 if (wacom->led.max_hlv)
1313 return led->hlv * LED_FULL / wacom->led.max_hlv;
1315 if (wacom->led.max_llv)
1316 return led->llv * LED_FULL / wacom->led.max_llv;
1325 struct wacom *wacom = led->wacom;
1327 if (wacom->led.groups[led->group].select != led->id)
1337 struct wacom *wacom = led->wacom;
1340 mutex_lock(&wacom->lock);
1342 if (!wacom->led.groups || (brightness == LED_OFF &&
1343 wacom->led.groups[led->group].select != led->id)) {
1348 led->llv = wacom->led.llv = wacom->led.max_llv * brightness / LED_FULL;
1349 led->hlv = wacom->led.hlv = wacom->led.max_hlv * brightness / LED_FULL;
1351 wacom->led.groups[led->group].select = led->id;
1353 error = wacom_led_control(wacom);
1356 mutex_unlock(&wacom->lock);
1366 static int wacom_led_register_one(struct device *dev, struct wacom *wacom,
1374 "%s::wacom-%d.%d",
1385 hid_err(wacom->hdev,
1394 led->wacom = wacom;
1395 led->llv = wacom->led.llv;
1396 led->hlv = wacom->led.hlv;
1410 hid_err(wacom->hdev,
1428 struct wacom *wacom,
1435 if (group_id >= wacom->led.count || count <= 0)
1438 if (!devres_open_group(dev, &wacom->led.groups[group_id], GFP_KERNEL))
1447 wacom->led.groups[group_id].leds = leds;
1448 wacom->led.groups[group_id].count = count;
1451 error = wacom_led_register_one(dev, wacom, &leds[i],
1457 wacom->led.groups[group_id].dev = dev;
1459 devres_close_group(dev, &wacom->led.groups[group_id]);
1470 error = devm_add_action_or_reset(&wacom->hdev->dev,
1472 &wacom->led.groups[group_id]);
1479 devres_release_group(dev, &wacom->led.groups[group_id]);
1483 struct wacom_led *wacom_led_find(struct wacom *wacom, unsigned int group_id,
1488 if (group_id >= wacom->led.count)
1491 group = &wacom->led.groups[group_id];
1502 * wacom_led_next: gives the next available led with a wacom trigger.
1507 struct wacom_led *wacom_led_next(struct wacom *wacom, struct wacom_led *cur)
1512 if (!wacom || !cur)
1519 next_led = wacom_led_find(wacom, group, ++next);
1529 struct wacom *wacom = data;
1531 wacom->led.groups = NULL;
1532 wacom->led.count = 0;
1535 static int wacom_led_groups_allocate(struct wacom *wacom, int count)
1537 struct device *dev = &wacom->hdev->dev;
1546 error = devm_add_action_or_reset(dev, wacom_led_groups_release, wacom);
1550 wacom->led.groups = groups;
1551 wacom->led.count = count;
1556 static int wacom_leds_alloc_and_register(struct wacom *wacom, int group_count,
1562 if (!wacom->wacom_wac.pad_input)
1565 dev = &wacom->wacom_wac.pad_input->dev;
1567 error = wacom_led_groups_allocate(wacom, group_count);
1572 error = wacom_led_groups_alloc_and_register_one(dev, wacom, i,
1582 int wacom_initialize_leds(struct wacom *wacom)
1586 if (!(wacom->wacom_wac.features.device_type & WACOM_DEVICETYPE_PAD))
1590 switch (wacom->wacom_wac.features.type) {
1592 if (!wacom->generic_has_leds)
1594 wacom->led.llv = 100;
1595 wacom->led.max_llv = 100;
1597 error = wacom_leds_alloc_and_register(wacom, 1, 4, false);
1599 hid_err(wacom->hdev,
1604 error = wacom_devm_sysfs_create_group(wacom,
1612 wacom->led.llv = 10;
1613 wacom->led.hlv = 20;
1614 wacom->led.max_llv = 127;
1615 wacom->led.max_hlv = 127;
1616 wacom->led.img_lum = 10;
1618 error = wacom_leds_alloc_and_register(wacom, 1, 4, false);
1620 hid_err(wacom->hdev,
1625 error = wacom_devm_sysfs_create_group(wacom,
1631 wacom->led.llv = 0;
1632 wacom->led.hlv = 0;
1633 wacom->led.img_lum = 0;
1635 error = wacom_leds_alloc_and_register(wacom, 2, 4, false);
1637 hid_err(wacom->hdev,
1642 error = wacom_devm_sysfs_create_group(wacom,
1652 wacom->led.llv = 32;
1653 wacom->led.max_llv = 96;
1655 error = wacom_leds_alloc_and_register(wacom, 1, 4, false);
1657 hid_err(wacom->hdev,
1662 error = wacom_devm_sysfs_create_group(wacom,
1667 wacom->led.llv = 50;
1668 wacom->led.max_llv = 100;
1669 error = wacom_leds_alloc_and_register(wacom, 1, 4, false);
1671 hid_err(wacom->hdev,
1678 wacom->led.llv = 255;
1679 wacom->led.max_llv = 255;
1680 error = wacom_led_groups_allocate(wacom, 5);
1682 hid_err(wacom->hdev,
1693 hid_err(wacom->hdev,
1703 struct wacom *wacom = container_of(work, struct wacom, init_work.work);
1705 _wacom_query_tablet_data(wacom);
1706 wacom_led_control(wacom);
1709 static void wacom_query_tablet_data(struct wacom *wacom)
1711 schedule_delayed_work(&wacom->init_work, msecs_to_jiffies(1000));
1731 val->strval = battery->wacom->wacom_wac.name;
1763 static int __wacom_initialize_battery(struct wacom *wacom,
1767 struct device *dev = &wacom->hdev->dev;
1777 battery->wacom = wacom;
1795 power_supply_powers(ps_bat, &wacom->hdev->dev);
1807 static int wacom_initialize_battery(struct wacom *wacom)
1809 if (wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY)
1810 return __wacom_initialize_battery(wacom, &wacom->battery);
1815 static void wacom_destroy_battery(struct wacom *wacom)
1817 if (wacom->battery.battery) {
1818 devres_release_group(&wacom->hdev->dev,
1819 &wacom->battery.bat_desc);
1820 wacom->battery.battery = NULL;
1829 struct wacom *wacom = hid_get_drvdata(hdev);
1831 return snprintf(buf, PAGE_SIZE, "%i\n", wacom->wacom_wac.bt_high_speed);
1839 struct wacom *wacom = hid_get_drvdata(hdev);
1848 wacom_bt_query_tablet_data(hdev, new_speed, &wacom->wacom_wac.features);
1863 struct wacom *wacom = hid_get_drvdata(hdev);
1866 mode = wacom->led.groups[index].select;
1896 static int wacom_remote_create_attr_group(struct wacom *wacom, __u32 serial,
1900 struct wacom_remote *remote = wacom->remote;
1902 remote->remotes[index].group.name = devm_kasprintf(&wacom->hdev->dev,
1908 error = __wacom_devm_sysfs_create_group(wacom, remote->remote_dir,
1912 hid_err(wacom->hdev,
1920 static int wacom_cmd_unpair_remote(struct wacom *wacom, unsigned char selector)
1933 retval = wacom_set_report(wacom->hdev, HID_OUTPUT_REPORT, buf,
1947 struct wacom *wacom = hid_get_drvdata(hdev);
1953 hid_info(wacom->hdev, "remote: unrecognized unpair code: %s\n",
1958 mutex_lock(&wacom->lock);
1960 err = wacom_cmd_unpair_remote(wacom, selector);
1961 mutex_unlock(&wacom->lock);
1978 struct wacom *wacom = data;
1979 struct wacom_remote *remote = wacom->remote;
1986 wacom->remote = NULL;
1989 static int wacom_initialize_remotes(struct wacom *wacom)
1995 if (wacom->wacom_wac.features.type != REMOTE)
1998 remote = devm_kzalloc(&wacom->hdev->dev, sizeof(*wacom->remote),
2003 wacom->remote = remote;
2011 hid_err(wacom->hdev, "failed allocating remote_fifo\n");
2022 &wacom->hdev->dev.kobj);
2029 hid_err(wacom->hdev,
2035 wacom->led.groups[i].select = WACOM_STATUS_UNKNOWN;
2039 error = devm_add_action_or_reset(&wacom->hdev->dev,
2040 wacom_remotes_destroy, wacom);
2047 static struct input_dev *wacom_allocate_input(struct wacom *wacom)
2050 struct hid_device *hdev = wacom->hdev;
2051 struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
2067 input_set_drvdata(input_dev, wacom);
2072 static int wacom_allocate_inputs(struct wacom *wacom)
2074 struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
2076 wacom_wac->pen_input = wacom_allocate_input(wacom);
2077 wacom_wac->touch_input = wacom_allocate_input(wacom);
2078 wacom_wac->pad_input = wacom_allocate_input(wacom);
2091 static int wacom_setup_inputs(struct wacom *wacom)
2094 struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
2131 static int wacom_register_inputs(struct wacom *wacom)
2134 struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
2203 struct wacom *wacom = container_of(work, struct wacom, battery_work);
2205 if ((wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) &&
2206 !wacom->battery.battery) {
2207 wacom_initialize_battery(wacom);
2209 else if (!(wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) &&
2210 wacom->battery.battery) {
2211 wacom_destroy_battery(wacom);
2232 static void wacom_update_name(struct wacom *wacom, const char *suffix)
2234 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2240 char *product_name = wacom->hdev->name;
2242 if (hid_is_usb(wacom->hdev)) {
2243 struct usb_interface *intf = to_usb_interface(wacom->hdev->dev.parent);
2248 if (wacom->hdev->bus == BUS_I2C) {
2250 features->name, wacom->hdev->product);
2252 strstr(product_name, "wacom") ||
2287 static void wacom_release_resources(struct wacom *wacom)
2289 struct hid_device *hdev = wacom->hdev;
2291 if (!wacom->resources)
2294 devres_release_group(&hdev->dev, wacom);
2296 wacom->resources = false;
2298 wacom->wacom_wac.pen_input = NULL;
2299 wacom->wacom_wac.touch_input = NULL;
2300 wacom->wacom_wac.pad_input = NULL;
2323 static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
2325 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2327 struct hid_device *hdev = wacom->hdev;
2335 if (!devres_open_group(&hdev->dev, wacom, GFP_KERNEL))
2338 wacom->resources = true;
2340 error = wacom_allocate_inputs(wacom);
2364 wacom_setup_device_quirks(wacom);
2382 wacom_update_name(wacom, wireless ? " (WL)" : "");
2398 error = wacom_initialize_battery(wacom);
2403 error = wacom_setup_inputs(wacom);
2417 error = wacom_register_inputs(wacom);
2421 if (wacom->wacom_wac.features.device_type & WACOM_DEVICETYPE_PAD) {
2422 error = wacom_initialize_leds(wacom);
2426 error = wacom_initialize_remotes(wacom);
2433 wacom_query_tablet_data(wacom);
2439 cancel_delayed_work_sync(&wacom->init_work);
2440 _wacom_query_tablet_data(wacom);
2454 devres_close_group(&hdev->dev, wacom);
2461 wacom_release_resources(wacom);
2467 struct wacom *wacom = container_of(work, struct wacom, wireless_work);
2468 struct usb_device *usbdev = wacom->usbdev;
2469 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2471 struct wacom *wacom1, *wacom2;
2480 wacom_destroy_battery(wacom);
2498 hid_info(wacom->hdev, "wireless tablet disconnected\n");
2502 hid_info(wacom->hdev, "wireless tablet connected with PID %x\n",
2513 hid_info(wacom->hdev, "ignoring unknown PID.\n");
2542 error = wacom_initialize_battery(wacom);
2555 static void wacom_remote_destroy_battery(struct wacom *wacom, int index)
2557 struct wacom_remote *remote = wacom->remote;
2560 devres_release_group(&wacom->hdev->dev,
2567 static void wacom_remote_destroy_one(struct wacom *wacom, unsigned int index)
2569 struct wacom_remote *remote = wacom->remote;
2581 wacom_remote_destroy_battery(wacom, i);
2584 devres_release_group(&wacom->hdev->dev,
2589 wacom->led.groups[i].select = WACOM_STATUS_UNKNOWN;
2594 static int wacom_remote_create_one(struct wacom *wacom, u32 serial,
2597 struct wacom_remote *remote = wacom->remote;
2598 struct device *dev = &wacom->hdev->dev;
2617 error = wacom_remote_create_attr_group(wacom, serial, index);
2621 remote->remotes[index].input = wacom_allocate_input(wacom);
2627 remote->remotes[index].input->name = wacom->wacom_wac.pad_name;
2635 &wacom->wacom_wac);
2647 wacom, index, 3, true);
2662 static int wacom_remote_attach_battery(struct wacom *wacom, int index)
2664 struct wacom_remote *remote = wacom->remote;
2676 if (wacom->led.groups[index].select == WACOM_STATUS_UNKNOWN)
2679 error = __wacom_initialize_battery(wacom,
2680 &wacom->remote->remotes[index].battery);
2689 struct wacom *wacom = container_of(work, struct wacom, remote_work);
2690 struct wacom_remote *remote = wacom->remote;
2703 hid_err(wacom->hdev,
2710 wacom_schedule_work(&wacom->wacom_wac, WACOM_WORKER_REMOTE);
2720 wacom_remote_destroy_battery(wacom, i);
2723 wacom_remote_attach_battery(wacom, i);
2728 wacom_remote_destroy_one(wacom, i);
2730 wacom_remote_create_one(wacom, serial, i);
2733 wacom_remote_destroy_one(wacom, i);
2740 struct wacom *wacom = container_of(work, struct wacom, mode_change_work);
2741 struct wacom_shared *shared = wacom->wacom_wac.shared;
2742 struct wacom *wacom1 = NULL;
2743 struct wacom *wacom2 = NULL;
2744 bool is_direct = wacom->wacom_wac.is_direct_mode;
2781 struct wacom *wacom;
2794 wacom = devm_kzalloc(&hdev->dev, sizeof(struct wacom), GFP_KERNEL);
2795 if (!wacom)
2798 hid_set_drvdata(hdev, wacom);
2799 wacom->hdev = hdev;
2801 wacom_wac = &wacom->wacom_wac;
2808 error = wacom_devm_kfifo_alloc(wacom);
2819 wacom->usbdev = dev;
2820 wacom->intf = intf;
2823 mutex_init(&wacom->lock);
2824 INIT_DELAYED_WORK(&wacom->init_work, wacom_init_work);
2825 INIT_WORK(&wacom->wireless_work, wacom_wireless_work);
2826 INIT_WORK(&wacom->battery_work, wacom_battery_work);
2827 INIT_WORK(&wacom->remote_work, wacom_remote_work);
2828 INIT_WORK(&wacom->mode_change_work, wacom_mode_change_work);
2829 timer_setup(&wacom->idleprox_timer, &wacom_idleprox_timeout, TIMER_DEFERRABLE);
2843 error = wacom_parse_and_register(wacom, false);
2860 struct wacom *wacom = hid_get_drvdata(hdev);
2861 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
2869 cancel_delayed_work_sync(&wacom->init_work);
2870 cancel_work_sync(&wacom->wireless_work);
2871 cancel_work_sync(&wacom->battery_work);
2872 cancel_work_sync(&wacom->remote_work);
2873 cancel_work_sync(&wacom->mode_change_work);
2874 del_timer_sync(&wacom->idleprox_timer);
2879 wacom_led_groups_release(wacom);
2881 if (wacom->wacom_wac.features.type != REMOTE)
2882 wacom_release_resources(wacom);
2888 struct wacom *wacom = hid_get_drvdata(hdev);
2890 mutex_lock(&wacom->lock);
2892 /* switch to wacom mode first */
2893 _wacom_query_tablet_data(wacom);
2894 wacom_led_control(wacom);
2896 mutex_unlock(&wacom->lock);
2908 .name = "wacom",