Lines Matching refs:hidpp
177 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in __hidpp_send_report() local
180 hidpp = hid_get_drvdata(hdev); in __hidpp_send_report()
202 if (hidpp->quirks & HIDPP_QUIRK_FORCE_OUTPUT_REPORTS) { in __hidpp_send_report()
221 static int hidpp_send_message_sync(struct hidpp_device *hidpp, in hidpp_send_message_sync() argument
227 mutex_lock(&hidpp->send_mutex); in hidpp_send_message_sync()
229 hidpp->send_receive_buf = response; in hidpp_send_message_sync()
230 hidpp->answer_available = false; in hidpp_send_message_sync()
238 ret = __hidpp_send_report(hidpp->hid_dev, message); in hidpp_send_message_sync()
246 if (!wait_event_timeout(hidpp->wait, hidpp->answer_available, in hidpp_send_message_sync()
269 mutex_unlock(&hidpp->send_mutex); in hidpp_send_message_sync()
274 static int hidpp_send_fap_command_sync(struct hidpp_device *hidpp, in hidpp_send_fap_command_sync() argument
296 ret = hidpp_send_message_sync(hidpp, message, response); in hidpp_send_fap_command_sync()
340 struct hidpp_device *hidpp = container_of(work, struct hidpp_device, in delayed_work_cb() local
342 hidpp_connect_event(hidpp); in delayed_work_cb()
491 static int hidpp10_query_battery_status(struct hidpp_device *hidpp) in hidpp10_query_battery_status() argument
496 ret = hidpp_send_rap_command_sync(hidpp, in hidpp10_query_battery_status()
504 hidpp->battery.level = in hidpp10_query_battery_status()
507 hidpp->battery.status = status; in hidpp10_query_battery_status()
509 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp10_query_battery_status()
543 static int hidpp10_query_battery_mileage(struct hidpp_device *hidpp) in hidpp10_query_battery_mileage() argument
548 ret = hidpp_send_rap_command_sync(hidpp, in hidpp10_query_battery_mileage()
556 hidpp->battery.capacity = response.rap.params[0]; in hidpp10_query_battery_mileage()
558 hidpp->battery.status = status; in hidpp10_query_battery_mileage()
560 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp10_query_battery_mileage()
566 static int hidpp10_battery_event(struct hidpp_device *hidpp, u8 *data, int size) in hidpp10_battery_event() argument
577 capacity = hidpp->battery.capacity; in hidpp10_battery_event()
583 level = hidpp->battery.level; in hidpp10_battery_event()
590 changed = capacity != hidpp->battery.capacity || in hidpp10_battery_event()
591 level != hidpp->battery.level || in hidpp10_battery_event()
592 status != hidpp->battery.status; in hidpp10_battery_event()
595 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp10_battery_event()
599 hidpp->battery.level = level; in hidpp10_battery_event()
600 hidpp->battery.status = status; in hidpp10_battery_event()
601 if (hidpp->battery.ps) in hidpp10_battery_event()
602 power_supply_changed(hidpp->battery.ps); in hidpp10_battery_event()
645 static int hidpp_unifying_get_serial(struct hidpp_device *hidpp, u32 *serial) in hidpp_unifying_get_serial() argument
651 ret = hidpp_send_rap_command_sync(hidpp, in hidpp_unifying_get_serial()
667 static int hidpp_unifying_init(struct hidpp_device *hidpp) in hidpp_unifying_init() argument
669 struct hid_device *hdev = hidpp->hid_dev; in hidpp_unifying_init()
674 ret = hidpp_unifying_get_serial(hidpp, &serial); in hidpp_unifying_init()
682 name = hidpp_unifying_get_name(hidpp); in hidpp_unifying_init()
703 static int hidpp_root_get_feature(struct hidpp_device *hidpp, u16 feature, in hidpp_root_get_feature() argument
710 ret = hidpp_send_fap_command_sync(hidpp, in hidpp_root_get_feature()
726 static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp) in hidpp_root_get_protocol_version() argument
731 ret = hidpp_send_fap_command_sync(hidpp, in hidpp_root_get_protocol_version()
737 hidpp->protocol_major = 1; in hidpp_root_get_protocol_version()
738 hidpp->protocol_minor = 0; in hidpp_root_get_protocol_version()
747 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_root_get_protocol_version()
754 hidpp->protocol_major = response.fap.params[0]; in hidpp_root_get_protocol_version()
755 hidpp->protocol_minor = response.fap.params[1]; in hidpp_root_get_protocol_version()
760 static bool hidpp_is_connected(struct hidpp_device *hidpp) in hidpp_is_connected() argument
764 ret = hidpp_root_get_protocol_version(hidpp); in hidpp_is_connected()
766 hid_dbg(hidpp->hid_dev, "HID++ %u.%u device connected.\n", in hidpp_is_connected()
767 hidpp->protocol_major, hidpp->protocol_minor); in hidpp_is_connected()
781 static int hidpp_devicenametype_get_count(struct hidpp_device *hidpp, in hidpp_devicenametype_get_count() argument
787 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_devicenametype_get_count()
791 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_devicenametype_get_count()
803 static int hidpp_devicenametype_get_device_name(struct hidpp_device *hidpp, in hidpp_devicenametype_get_device_name() argument
810 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_devicenametype_get_device_name()
815 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_devicenametype_get_device_name()
845 static char *hidpp_get_device_name(struct hidpp_device *hidpp) in hidpp_get_device_name() argument
854 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_GET_DEVICE_NAME_TYPE, in hidpp_get_device_name()
859 ret = hidpp_devicenametype_get_count(hidpp, feature_index, in hidpp_get_device_name()
869 ret = hidpp_devicenametype_get_device_name(hidpp, in hidpp_get_device_name()
954 static int hidpp20_batterylevel_get_battery_capacity(struct hidpp_device *hidpp, in hidpp20_batterylevel_get_battery_capacity() argument
965 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp20_batterylevel_get_battery_capacity()
969 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_batterylevel_get_battery_capacity()
983 static int hidpp20_batterylevel_get_battery_info(struct hidpp_device *hidpp, in hidpp20_batterylevel_get_battery_info() argument
991 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp20_batterylevel_get_battery_info()
995 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_batterylevel_get_battery_info()
1006 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS; in hidpp20_batterylevel_get_battery_info()
1008 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_MILEAGE; in hidpp20_batterylevel_get_battery_info()
1013 static int hidpp20_query_battery_info(struct hidpp_device *hidpp) in hidpp20_query_battery_info() argument
1019 if (hidpp->battery.feature_index == 0xff) { in hidpp20_query_battery_info()
1020 ret = hidpp_root_get_feature(hidpp, in hidpp20_query_battery_info()
1022 &hidpp->battery.feature_index, in hidpp20_query_battery_info()
1028 ret = hidpp20_batterylevel_get_battery_capacity(hidpp, in hidpp20_query_battery_info()
1029 hidpp->battery.feature_index, in hidpp20_query_battery_info()
1035 ret = hidpp20_batterylevel_get_battery_info(hidpp, in hidpp20_query_battery_info()
1036 hidpp->battery.feature_index); in hidpp20_query_battery_info()
1040 hidpp->battery.status = status; in hidpp20_query_battery_info()
1041 hidpp->battery.capacity = capacity; in hidpp20_query_battery_info()
1042 hidpp->battery.level = level; in hidpp20_query_battery_info()
1044 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp20_query_battery_info()
1050 static int hidpp20_battery_event(struct hidpp_device *hidpp, in hidpp20_battery_event() argument
1057 if (report->fap.feature_index != hidpp->battery.feature_index || in hidpp20_battery_event()
1067 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp20_battery_event()
1070 changed = capacity != hidpp->battery.capacity || in hidpp20_battery_event()
1071 level != hidpp->battery.level || in hidpp20_battery_event()
1072 status != hidpp->battery.status; in hidpp20_battery_event()
1075 hidpp->battery.level = level; in hidpp20_battery_event()
1076 hidpp->battery.capacity = capacity; in hidpp20_battery_event()
1077 hidpp->battery.status = status; in hidpp20_battery_event()
1078 if (hidpp->battery.ps) in hidpp20_battery_event()
1079 power_supply_changed(hidpp->battery.ps); in hidpp20_battery_event()
1100 struct hidpp_device *hidpp = power_supply_get_drvdata(psy); in hidpp_battery_get_property() local
1105 val->intval = hidpp->battery.status; in hidpp_battery_get_property()
1108 val->intval = hidpp->battery.capacity; in hidpp_battery_get_property()
1111 val->intval = hidpp->battery.level; in hidpp_battery_get_property()
1117 val->intval = hidpp->battery.online; in hidpp_battery_get_property()
1120 if (!strncmp(hidpp->name, "Logitech ", 9)) in hidpp_battery_get_property()
1121 val->strval = hidpp->name + 9; in hidpp_battery_get_property()
1123 val->strval = hidpp->name; in hidpp_battery_get_property()
1129 val->strval = hidpp->hid_dev->uniq; in hidpp_battery_get_property()
1151 static int hidpp_solar_request_battery_event(struct hidpp_device *hidpp) in hidpp_solar_request_battery_event() argument
1158 if (hidpp->battery.feature_index == 0xff) { in hidpp_solar_request_battery_event()
1159 ret = hidpp_root_get_feature(hidpp, in hidpp_solar_request_battery_event()
1161 &hidpp->battery.solar_feature_index, in hidpp_solar_request_battery_event()
1167 ret = hidpp_send_fap_command_sync(hidpp, in hidpp_solar_request_battery_event()
1168 hidpp->battery.solar_feature_index, in hidpp_solar_request_battery_event()
1172 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_solar_request_battery_event()
1179 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_MILEAGE; in hidpp_solar_request_battery_event()
1184 static int hidpp_solar_battery_event(struct hidpp_device *hidpp, in hidpp_solar_battery_event() argument
1194 if (report->fap.feature_index != hidpp->battery.solar_feature_index || in hidpp_solar_battery_event()
1212 if (capacity < hidpp->battery.capacity) in hidpp_solar_battery_event()
1222 hidpp->battery.online = true; in hidpp_solar_battery_event()
1223 if (capacity != hidpp->battery.capacity || in hidpp_solar_battery_event()
1224 status != hidpp->battery.status) { in hidpp_solar_battery_event()
1225 hidpp->battery.capacity = capacity; in hidpp_solar_battery_event()
1226 hidpp->battery.status = status; in hidpp_solar_battery_event()
1227 if (hidpp->battery.ps) in hidpp_solar_battery_event()
1228 power_supply_changed(hidpp->battery.ps); in hidpp_solar_battery_event()
1253 static int hidpp_touchpad_fw_items_set(struct hidpp_device *hidpp, in hidpp_touchpad_fw_items_set() argument
1261 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_touchpad_fw_items_set()
1265 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_touchpad_fw_items_set()
1324 static int hidpp_touchpad_get_raw_info(struct hidpp_device *hidpp, in hidpp_touchpad_get_raw_info() argument
1331 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_touchpad_get_raw_info()
1335 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_touchpad_get_raw_info()
1447 struct hidpp_device *hidpp; member
1539 ret = hidpp_send_fap_command_sync(data->hidpp, data->feature_index, in hidpp_ff_work_handler()
1543 hid_err(data->hidpp->hid_dev, "Failed to send command to device!\n"); in hidpp_ff_work_handler()
1606 …hid_warn(data->hidpp->hid_dev, "Force feedback command queue contains %d commands, causing substan… in hidpp_ff_queue_work()
1665 …hid_err(data->hidpp->hid_dev, "Unexpected periodic waveform type %i!\n", effect->u.periodic.wavefo… in hidpp_ff_upload_effect()
1750 hid_err(data->hidpp->hid_dev, "Unexpected force type %i!\n", effect->type); in hidpp_ff_upload_effect()
1854 static int hidpp_ff_init(struct hidpp_device *hidpp, u8 feature_index) in hidpp_ff_init() argument
1856 struct hid_device *hid = hidpp->hid_dev; in hidpp_ff_init()
1883 error = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_ff_init()
1888 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_ff_init()
1910 data->hidpp = hidpp; in hidpp_ff_init()
1930 error = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_ff_init()
1934 error = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_ff_init()
1937 hid_warn(hidpp->hid_dev, "Failed to read range from device!\n"); in hidpp_ff_init()
1941 error = device_create_file(&(hidpp->hid_dev->dev), &dev_attr_range); in hidpp_ff_init()
1943 hid_warn(hidpp->hid_dev, "Unable to create sysfs interface for \"range\", errno %d!\n", error); in hidpp_ff_init()
1946 error = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_ff_init()
1949 hid_warn(hidpp->hid_dev, "Failed to read gain values from device!\n"); in hidpp_ff_init()
2021 static void wtp_populate_input(struct hidpp_device *hidpp, in wtp_populate_input() argument
2024 struct wtp_data *wd = hidpp->private_data; in wtp_populate_input()
2041 if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS) in wtp_populate_input()
2077 static void wtp_send_raw_xy_event(struct hidpp_device *hidpp, in wtp_send_raw_xy_event() argument
2080 struct wtp_data *wd = hidpp->private_data; in wtp_send_raw_xy_event()
2087 !(hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS)) in wtp_send_raw_xy_event()
2096 static int wtp_mouse_raw_xy_event(struct hidpp_device *hidpp, u8 *data) in wtp_mouse_raw_xy_event() argument
2098 struct wtp_data *wd = hidpp->private_data; in wtp_mouse_raw_xy_event()
2130 wtp_send_raw_xy_event(hidpp, &raw); in wtp_mouse_raw_xy_event()
2137 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in wtp_raw_event() local
2138 struct wtp_data *wd = hidpp->private_data; in wtp_raw_event()
2152 if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS) { in wtp_raw_event()
2162 return wtp_mouse_raw_xy_event(hidpp, &data[7]); in wtp_raw_event()
2169 hidpp_touchpad_raw_xy_event(hidpp, data + 4, &raw); in wtp_raw_event()
2171 wtp_send_raw_xy_event(hidpp, &raw); in wtp_raw_event()
2178 static int wtp_get_config(struct hidpp_device *hidpp) in wtp_get_config() argument
2180 struct wtp_data *wd = hidpp->private_data; in wtp_get_config()
2185 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_TOUCHPAD_RAW_XY, in wtp_get_config()
2191 ret = hidpp_touchpad_get_raw_info(hidpp, wd->mt_feature_index, in wtp_get_config()
2209 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in wtp_allocate() local
2217 hidpp->private_data = wd; in wtp_allocate()
2224 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in wtp_connect() local
2225 struct wtp_data *wd = hidpp->private_data; in wtp_connect()
2229 ret = wtp_get_config(hidpp); in wtp_connect()
2236 return hidpp_touchpad_set_raw_report_state(hidpp, wd->mt_feature_index, in wtp_connect()
2308 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in m560_allocate() local
2316 hidpp->private_data = d; in m560_allocate()
2323 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in m560_raw_event() local
2324 struct m560_private_data *mydata = hidpp->private_data; in m560_raw_event()
2410 static void m560_populate_input(struct hidpp_device *hidpp, in m560_populate_input() argument
2413 struct m560_private_data *mydata = hidpp->private_data; in m560_populate_input()
2456 static int k400_disable_tap_to_click(struct hidpp_device *hidpp) in k400_disable_tap_to_click() argument
2458 struct k400_private_data *k400 = hidpp->private_data; in k400_disable_tap_to_click()
2464 ret = hidpp_root_get_feature(hidpp, in k400_disable_tap_to_click()
2472 ret = hidpp_touchpad_fw_items_set(hidpp, k400->feature_index, &items); in k400_disable_tap_to_click()
2481 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in k400_allocate() local
2489 hidpp->private_data = k400; in k400_allocate()
2496 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in k400_connect() local
2501 return k400_disable_tap_to_click(hidpp); in k400_connect()
2510 static int g920_get_config(struct hidpp_device *hidpp) in g920_get_config() argument
2517 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_G920_FORCE_FEEDBACK, in g920_get_config()
2522 ret = hidpp_ff_init(hidpp, feature_index); in g920_get_config()
2524 hid_warn(hidpp->hid_dev, "Unable to initialize force feedback support, errno %d\n", in g920_get_config()
2538 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_input_mapping() local
2540 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) in hidpp_input_mapping()
2542 else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560 && in hidpp_input_mapping()
2553 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_input_mapped() local
2556 if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) { in hidpp_input_mapped()
2568 static void hidpp_populate_input(struct hidpp_device *hidpp, in hidpp_populate_input() argument
2571 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) in hidpp_populate_input()
2572 wtp_populate_input(hidpp, input, origin_is_hid_core); in hidpp_populate_input()
2573 else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) in hidpp_populate_input()
2574 m560_populate_input(hidpp, input, origin_is_hid_core); in hidpp_populate_input()
2580 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_input_configured() local
2583 hidpp_populate_input(hidpp, input, true); in hidpp_input_configured()
2588 static int hidpp_raw_hidpp_event(struct hidpp_device *hidpp, u8 *data, in hidpp_raw_hidpp_event() argument
2591 struct hidpp_report *question = hidpp->send_receive_buf; in hidpp_raw_hidpp_event()
2592 struct hidpp_report *answer = hidpp->send_receive_buf; in hidpp_raw_hidpp_event()
2600 if (unlikely(mutex_is_locked(&hidpp->send_mutex))) { in hidpp_raw_hidpp_event()
2608 hidpp->answer_available = true; in hidpp_raw_hidpp_event()
2609 wake_up(&hidpp->wait); in hidpp_raw_hidpp_event()
2621 atomic_set(&hidpp->connected, in hidpp_raw_hidpp_event()
2623 if (schedule_work(&hidpp->work) == 0) in hidpp_raw_hidpp_event()
2628 if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_BATTERY) { in hidpp_raw_hidpp_event()
2629 ret = hidpp20_battery_event(hidpp, data, size); in hidpp_raw_hidpp_event()
2632 ret = hidpp_solar_battery_event(hidpp, data, size); in hidpp_raw_hidpp_event()
2637 if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP10_BATTERY) { in hidpp_raw_hidpp_event()
2638 ret = hidpp10_battery_event(hidpp, data, size); in hidpp_raw_hidpp_event()
2649 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_raw_event() local
2660 ret = hidpp_raw_hidpp_event(hidpp, data, size); in hidpp_raw_event()
2668 ret = hidpp_raw_hidpp_event(hidpp, data, size); in hidpp_raw_event()
2676 ret = hidpp_raw_hidpp_event(hidpp, data, size); in hidpp_raw_event()
2685 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) in hidpp_raw_event()
2687 else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) in hidpp_raw_event()
2693 static int hidpp_initialize_battery(struct hidpp_device *hidpp) in hidpp_initialize_battery() argument
2696 struct power_supply_config cfg = { .drv_data = hidpp }; in hidpp_initialize_battery()
2697 struct power_supply_desc *desc = &hidpp->battery.desc; in hidpp_initialize_battery()
2704 if (hidpp->battery.ps) in hidpp_initialize_battery()
2707 hidpp->battery.feature_index = 0xff; in hidpp_initialize_battery()
2708 hidpp->battery.solar_feature_index = 0xff; in hidpp_initialize_battery()
2710 if (hidpp->protocol_major >= 2) { in hidpp_initialize_battery()
2711 if (hidpp->quirks & HIDPP_QUIRK_CLASS_K750) in hidpp_initialize_battery()
2712 ret = hidpp_solar_request_battery_event(hidpp); in hidpp_initialize_battery()
2714 ret = hidpp20_query_battery_info(hidpp); in hidpp_initialize_battery()
2718 hidpp->capabilities |= HIDPP_CAPABILITY_HIDPP20_BATTERY; in hidpp_initialize_battery()
2720 ret = hidpp10_query_battery_status(hidpp); in hidpp_initialize_battery()
2722 ret = hidpp10_query_battery_mileage(hidpp); in hidpp_initialize_battery()
2725 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_MILEAGE; in hidpp_initialize_battery()
2727 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS; in hidpp_initialize_battery()
2729 hidpp->capabilities |= HIDPP_CAPABILITY_HIDPP10_BATTERY; in hidpp_initialize_battery()
2732 battery_props = devm_kmemdup(&hidpp->hid_dev->dev, in hidpp_initialize_battery()
2741 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_MILEAGE) in hidpp_initialize_battery()
2745 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS) in hidpp_initialize_battery()
2749 battery = &hidpp->battery; in hidpp_initialize_battery()
2760 battery->ps = devm_power_supply_register(&hidpp->hid_dev->dev, in hidpp_initialize_battery()
2766 power_supply_powers(battery->ps, &hidpp->hid_dev->dev); in hidpp_initialize_battery()
2773 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_overwrite_name() local
2776 if (hidpp->protocol_major < 2) in hidpp_overwrite_name()
2779 name = hidpp_get_device_name(hidpp); in hidpp_overwrite_name()
2808 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_allocate_input() local
2817 input_dev->name = hidpp->name; in hidpp_allocate_input()
2829 static void hidpp_connect_event(struct hidpp_device *hidpp) in hidpp_connect_event() argument
2831 struct hid_device *hdev = hidpp->hid_dev; in hidpp_connect_event()
2833 bool connected = atomic_read(&hidpp->connected); in hidpp_connect_event()
2838 if (hidpp->battery.ps) { in hidpp_connect_event()
2839 hidpp->battery.online = false; in hidpp_connect_event()
2840 hidpp->battery.status = POWER_SUPPLY_STATUS_UNKNOWN; in hidpp_connect_event()
2841 hidpp->battery.level = POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN; in hidpp_connect_event()
2842 power_supply_changed(hidpp->battery.ps); in hidpp_connect_event()
2847 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) { in hidpp_connect_event()
2851 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) { in hidpp_connect_event()
2855 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_K400) { in hidpp_connect_event()
2863 if (!hidpp->protocol_major) { in hidpp_connect_event()
2864 ret = !hidpp_is_connected(hidpp); in hidpp_connect_event()
2870 hidpp->protocol_major, hidpp->protocol_minor); in hidpp_connect_event()
2873 if (hidpp->name == hdev->name && hidpp->protocol_major >= 2) { in hidpp_connect_event()
2874 name = hidpp_get_device_name(hidpp); in hidpp_connect_event()
2886 hidpp->name = devm_name; in hidpp_connect_event()
2889 hidpp_initialize_battery(hidpp); in hidpp_connect_event()
2892 if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP10_BATTERY) { in hidpp_connect_event()
2893 hidpp10_enable_battery_reporting(hidpp); in hidpp_connect_event()
2894 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_MILEAGE) in hidpp_connect_event()
2895 hidpp10_query_battery_mileage(hidpp); in hidpp_connect_event()
2897 hidpp10_query_battery_status(hidpp); in hidpp_connect_event()
2898 } else if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_BATTERY) { in hidpp_connect_event()
2899 hidpp20_query_battery_info(hidpp); in hidpp_connect_event()
2901 if (hidpp->battery.ps) in hidpp_connect_event()
2902 power_supply_changed(hidpp->battery.ps); in hidpp_connect_event()
2904 if (!(hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT) || hidpp->delayed_input) in hidpp_connect_event()
2914 hidpp_populate_input(hidpp, input, false); in hidpp_connect_event()
2920 hidpp->delayed_input = input; in hidpp_connect_event()
2936 struct hidpp_device *hidpp; in hidpp_probe() local
2941 hidpp = devm_kzalloc(&hdev->dev, sizeof(struct hidpp_device), in hidpp_probe()
2943 if (!hidpp) in hidpp_probe()
2946 hidpp->hid_dev = hdev; in hidpp_probe()
2947 hidpp->name = hdev->name; in hidpp_probe()
2948 hid_set_drvdata(hdev, hidpp); in hidpp_probe()
2950 hidpp->quirks = id->driver_data; in hidpp_probe()
2953 hidpp->quirks |= HIDPP_QUIRK_UNIFYING; in hidpp_probe()
2956 hidpp->quirks &= ~HIDPP_QUIRK_CLASS_WTP; in hidpp_probe()
2957 hidpp->quirks &= ~HIDPP_QUIRK_NO_HIDINPUT; in hidpp_probe()
2960 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) { in hidpp_probe()
2964 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) { in hidpp_probe()
2968 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_K400) { in hidpp_probe()
2974 INIT_WORK(&hidpp->work, delayed_work_cb); in hidpp_probe()
2975 mutex_init(&hidpp->send_mutex); in hidpp_probe()
2976 init_waitqueue_head(&hidpp->wait); in hidpp_probe()
2990 if (hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT) in hidpp_probe()
2993 if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) { in hidpp_probe()
3012 if (hidpp->quirks & HIDPP_QUIRK_UNIFYING) in hidpp_probe()
3013 hidpp_unifying_init(hidpp); in hidpp_probe()
3015 connected = hidpp_is_connected(hidpp); in hidpp_probe()
3016 atomic_set(&hidpp->connected, connected); in hidpp_probe()
3017 if (!(hidpp->quirks & HIDPP_QUIRK_UNIFYING)) { in hidpp_probe()
3025 hidpp->protocol_major, hidpp->protocol_minor); in hidpp_probe()
3030 if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)) { in hidpp_probe()
3031 ret = wtp_get_config(hidpp); in hidpp_probe()
3034 } else if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_G920)) { in hidpp_probe()
3035 ret = g920_get_config(hidpp); in hidpp_probe()
3043 if (!(hidpp->quirks & HIDPP_QUIRK_CLASS_G920)) { in hidpp_probe()
3054 hidpp_connect_event(hidpp); in hidpp_probe()
3060 if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) { in hidpp_probe()
3067 cancel_work_sync(&hidpp->work); in hidpp_probe()
3068 mutex_destroy(&hidpp->send_mutex); in hidpp_probe()
3076 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_remove() local
3080 if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) { in hidpp_remove()
3085 cancel_work_sync(&hidpp->work); in hidpp_remove()
3086 mutex_destroy(&hidpp->send_mutex); in hidpp_remove()