Lines Matching refs:hidpp

235 	struct hidpp_device *hidpp = hid_get_drvdata(hdev);  in __hidpp_send_report()  local
246 fields_count = hidpp->very_long_report_length; in __hidpp_send_report()
258 if (hidpp->quirks & HIDPP_QUIRK_FORCE_OUTPUT_REPORTS) { in __hidpp_send_report()
277 static int hidpp_send_message_sync(struct hidpp_device *hidpp, in hidpp_send_message_sync() argument
283 mutex_lock(&hidpp->send_mutex); in hidpp_send_message_sync()
285 hidpp->send_receive_buf = response; in hidpp_send_message_sync()
286 hidpp->answer_available = false; in hidpp_send_message_sync()
294 ret = __hidpp_send_report(hidpp->hid_dev, message); in hidpp_send_message_sync()
302 if (!wait_event_timeout(hidpp->wait, hidpp->answer_available, in hidpp_send_message_sync()
325 mutex_unlock(&hidpp->send_mutex); in hidpp_send_message_sync()
330 static int hidpp_send_fap_command_sync(struct hidpp_device *hidpp, in hidpp_send_fap_command_sync() argument
352 ret = hidpp_send_message_sync(hidpp, message, response); in hidpp_send_fap_command_sync()
401 struct hidpp_device *hidpp = container_of(work, struct hidpp_device, in delayed_work_cb() local
403 hidpp_connect_event(hidpp); in delayed_work_cb()
422 static inline bool hidpp_report_is_connect_event(struct hidpp_device *hidpp, in hidpp_report_is_connect_event() argument
425 return (hidpp->wireless_feature_index && in hidpp_report_is_connect_event()
426 (report->fap.feature_index == hidpp->wireless_feature_index)) || in hidpp_report_is_connect_event()
650 static int hidpp10_query_battery_status(struct hidpp_device *hidpp) in hidpp10_query_battery_status() argument
655 ret = hidpp_send_rap_command_sync(hidpp, in hidpp10_query_battery_status()
663 hidpp->battery.level = in hidpp10_query_battery_status()
666 hidpp->battery.status = status; in hidpp10_query_battery_status()
668 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp10_query_battery_status()
702 static int hidpp10_query_battery_mileage(struct hidpp_device *hidpp) in hidpp10_query_battery_mileage() argument
707 ret = hidpp_send_rap_command_sync(hidpp, in hidpp10_query_battery_mileage()
715 hidpp->battery.capacity = response.rap.params[0]; in hidpp10_query_battery_mileage()
717 hidpp->battery.status = status; in hidpp10_query_battery_mileage()
719 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp10_query_battery_mileage()
725 static int hidpp10_battery_event(struct hidpp_device *hidpp, u8 *data, int size) in hidpp10_battery_event() argument
736 capacity = hidpp->battery.capacity; in hidpp10_battery_event()
742 level = hidpp->battery.level; in hidpp10_battery_event()
749 changed = capacity != hidpp->battery.capacity || in hidpp10_battery_event()
750 level != hidpp->battery.level || in hidpp10_battery_event()
751 status != hidpp->battery.status; in hidpp10_battery_event()
754 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp10_battery_event()
758 hidpp->battery.level = level; in hidpp10_battery_event()
759 hidpp->battery.status = status; in hidpp10_battery_event()
760 if (hidpp->battery.ps) in hidpp10_battery_event()
761 power_supply_changed(hidpp->battery.ps); in hidpp10_battery_event()
807 static int hidpp_unifying_get_serial(struct hidpp_device *hidpp, u32 *serial) in hidpp_unifying_get_serial() argument
813 ret = hidpp_send_rap_command_sync(hidpp, in hidpp_unifying_get_serial()
829 static int hidpp_unifying_init(struct hidpp_device *hidpp) in hidpp_unifying_init() argument
831 struct hid_device *hdev = hidpp->hid_dev; in hidpp_unifying_init()
836 ret = hidpp_unifying_get_serial(hidpp, &serial); in hidpp_unifying_init()
844 name = hidpp_unifying_get_name(hidpp); in hidpp_unifying_init()
865 static int hidpp_root_get_feature(struct hidpp_device *hidpp, u16 feature, in hidpp_root_get_feature() argument
872 ret = hidpp_send_fap_command_sync(hidpp, in hidpp_root_get_feature()
888 static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp) in hidpp_root_get_protocol_version() argument
895 ret = hidpp_send_rap_command_sync(hidpp, in hidpp_root_get_protocol_version()
902 hidpp->protocol_major = 1; in hidpp_root_get_protocol_version()
903 hidpp->protocol_minor = 0; in hidpp_root_get_protocol_version()
912 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_root_get_protocol_version()
920 hid_err(hidpp->hid_dev, "%s: ping mismatch 0x%02x != 0x%02x\n", in hidpp_root_get_protocol_version()
925 hidpp->protocol_major = response.rap.params[0]; in hidpp_root_get_protocol_version()
926 hidpp->protocol_minor = response.rap.params[1]; in hidpp_root_get_protocol_version()
929 hid_info(hidpp->hid_dev, "HID++ %u.%u device connected.\n", in hidpp_root_get_protocol_version()
930 hidpp->protocol_major, hidpp->protocol_minor); in hidpp_root_get_protocol_version()
944 static int hidpp_devicenametype_get_count(struct hidpp_device *hidpp, in hidpp_devicenametype_get_count() argument
950 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_devicenametype_get_count()
954 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_devicenametype_get_count()
966 static int hidpp_devicenametype_get_device_name(struct hidpp_device *hidpp, in hidpp_devicenametype_get_device_name() argument
973 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_devicenametype_get_device_name()
978 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_devicenametype_get_device_name()
987 count = hidpp->very_long_report_length - 4; in hidpp_devicenametype_get_device_name()
1008 static char *hidpp_get_device_name(struct hidpp_device *hidpp) in hidpp_get_device_name() argument
1017 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_GET_DEVICE_NAME_TYPE, in hidpp_get_device_name()
1022 ret = hidpp_devicenametype_get_count(hidpp, feature_index, in hidpp_get_device_name()
1032 ret = hidpp_devicenametype_get_device_name(hidpp, in hidpp_get_device_name()
1121 static int hidpp20_batterylevel_get_battery_capacity(struct hidpp_device *hidpp, in hidpp20_batterylevel_get_battery_capacity() argument
1132 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp20_batterylevel_get_battery_capacity()
1139 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_batterylevel_get_battery_capacity()
1153 static int hidpp20_batterylevel_get_battery_info(struct hidpp_device *hidpp, in hidpp20_batterylevel_get_battery_info() argument
1161 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp20_batterylevel_get_battery_info()
1165 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_batterylevel_get_battery_info()
1176 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS; in hidpp20_batterylevel_get_battery_info()
1178 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_MILEAGE; in hidpp20_batterylevel_get_battery_info()
1183 static int hidpp20_query_battery_info_1000(struct hidpp_device *hidpp) in hidpp20_query_battery_info_1000() argument
1189 if (hidpp->battery.feature_index == 0xff) { in hidpp20_query_battery_info_1000()
1190 ret = hidpp_root_get_feature(hidpp, in hidpp20_query_battery_info_1000()
1192 &hidpp->battery.feature_index, in hidpp20_query_battery_info_1000()
1198 ret = hidpp20_batterylevel_get_battery_capacity(hidpp, in hidpp20_query_battery_info_1000()
1199 hidpp->battery.feature_index, in hidpp20_query_battery_info_1000()
1205 ret = hidpp20_batterylevel_get_battery_info(hidpp, in hidpp20_query_battery_info_1000()
1206 hidpp->battery.feature_index); in hidpp20_query_battery_info_1000()
1210 hidpp->battery.status = status; in hidpp20_query_battery_info_1000()
1211 hidpp->battery.capacity = capacity; in hidpp20_query_battery_info_1000()
1212 hidpp->battery.level = level; in hidpp20_query_battery_info_1000()
1214 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp20_query_battery_info_1000()
1220 static int hidpp20_battery_event_1000(struct hidpp_device *hidpp, in hidpp20_battery_event_1000() argument
1227 if (report->fap.feature_index != hidpp->battery.feature_index || in hidpp20_battery_event_1000()
1237 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp20_battery_event_1000()
1240 changed = capacity != hidpp->battery.capacity || in hidpp20_battery_event_1000()
1241 level != hidpp->battery.level || in hidpp20_battery_event_1000()
1242 status != hidpp->battery.status; in hidpp20_battery_event_1000()
1245 hidpp->battery.level = level; in hidpp20_battery_event_1000()
1246 hidpp->battery.capacity = capacity; in hidpp20_battery_event_1000()
1247 hidpp->battery.status = status; in hidpp20_battery_event_1000()
1248 if (hidpp->battery.ps) in hidpp20_battery_event_1000()
1249 power_supply_changed(hidpp->battery.ps); in hidpp20_battery_event_1000()
1308 static int hidpp20_battery_get_battery_voltage(struct hidpp_device *hidpp, in hidpp20_battery_get_battery_voltage() argument
1317 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp20_battery_get_battery_voltage()
1322 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_battery_get_battery_voltage()
1329 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_VOLTAGE; in hidpp20_battery_get_battery_voltage()
1374 static int hidpp20_query_battery_voltage_info(struct hidpp_device *hidpp) in hidpp20_query_battery_voltage_info() argument
1380 if (hidpp->battery.voltage_feature_index == 0xff) { in hidpp20_query_battery_voltage_info()
1381 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_BATTERY_VOLTAGE, in hidpp20_query_battery_voltage_info()
1382 &hidpp->battery.voltage_feature_index, in hidpp20_query_battery_voltage_info()
1388 ret = hidpp20_battery_get_battery_voltage(hidpp, in hidpp20_query_battery_voltage_info()
1389 hidpp->battery.voltage_feature_index, in hidpp20_query_battery_voltage_info()
1395 hidpp->battery.status = status; in hidpp20_query_battery_voltage_info()
1396 hidpp->battery.voltage = voltage; in hidpp20_query_battery_voltage_info()
1397 hidpp->battery.capacity = hidpp20_map_battery_capacity(hidpp->hid_dev, in hidpp20_query_battery_voltage_info()
1399 hidpp->battery.level = level; in hidpp20_query_battery_voltage_info()
1400 hidpp->battery.charge_type = charge_type; in hidpp20_query_battery_voltage_info()
1401 hidpp->battery.online = status != POWER_SUPPLY_STATUS_NOT_CHARGING; in hidpp20_query_battery_voltage_info()
1406 static int hidpp20_battery_voltage_event(struct hidpp_device *hidpp, in hidpp20_battery_voltage_event() argument
1412 if (report->fap.feature_index != hidpp->battery.voltage_feature_index || in hidpp20_battery_voltage_event()
1419 hidpp->battery.online = status != POWER_SUPPLY_STATUS_NOT_CHARGING; in hidpp20_battery_voltage_event()
1421 if (voltage != hidpp->battery.voltage || status != hidpp->battery.status) { in hidpp20_battery_voltage_event()
1422 hidpp->battery.voltage = voltage; in hidpp20_battery_voltage_event()
1423 hidpp->battery.capacity = hidpp20_map_battery_capacity(hidpp->hid_dev, in hidpp20_battery_voltage_event()
1425 hidpp->battery.status = status; in hidpp20_battery_voltage_event()
1426 hidpp->battery.level = level; in hidpp20_battery_voltage_event()
1427 hidpp->battery.charge_type = charge_type; in hidpp20_battery_voltage_event()
1428 if (hidpp->battery.ps) in hidpp20_battery_voltage_event()
1429 power_supply_changed(hidpp->battery.ps); in hidpp20_battery_voltage_event()
1453 static int hidpp20_unifiedbattery_get_capabilities(struct hidpp_device *hidpp, in hidpp20_unifiedbattery_get_capabilities() argument
1460 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS || in hidpp20_unifiedbattery_get_capabilities()
1461 hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_PERCENTAGE) { in hidpp20_unifiedbattery_get_capabilities()
1466 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp20_unifiedbattery_get_capabilities()
1473 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_unifiedbattery_get_capabilities()
1488 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_PERCENTAGE; in hidpp20_unifiedbattery_get_capabilities()
1489 hidpp->battery.supported_levels_1004 = 0; in hidpp20_unifiedbattery_get_capabilities()
1491 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS; in hidpp20_unifiedbattery_get_capabilities()
1492 hidpp->battery.supported_levels_1004 = params[0]; in hidpp20_unifiedbattery_get_capabilities()
1498 static int hidpp20_unifiedbattery_map_status(struct hidpp_device *hidpp, in hidpp20_unifiedbattery_map_status() argument
1517 hid_info(hidpp->hid_dev, "%s: charging error", in hidpp20_unifiedbattery_map_status()
1518 hidpp->name); in hidpp20_unifiedbattery_map_status()
1528 static int hidpp20_unifiedbattery_map_level(struct hidpp_device *hidpp, in hidpp20_unifiedbattery_map_level() argument
1532 battery_level &= hidpp->battery.supported_levels_1004; in hidpp20_unifiedbattery_map_level()
1546 static int hidpp20_unifiedbattery_get_status(struct hidpp_device *hidpp, in hidpp20_unifiedbattery_get_status() argument
1556 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp20_unifiedbattery_get_status()
1563 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_unifiedbattery_get_status()
1571 *status = hidpp20_unifiedbattery_map_status(hidpp, params[2], params[3]); in hidpp20_unifiedbattery_get_status()
1572 *level = hidpp20_unifiedbattery_map_level(hidpp, params[1]); in hidpp20_unifiedbattery_get_status()
1577 static int hidpp20_query_battery_info_1004(struct hidpp_device *hidpp) in hidpp20_query_battery_info_1004() argument
1584 if (hidpp->battery.feature_index == 0xff) { in hidpp20_query_battery_info_1004()
1585 ret = hidpp_root_get_feature(hidpp, in hidpp20_query_battery_info_1004()
1587 &hidpp->battery.feature_index, in hidpp20_query_battery_info_1004()
1593 ret = hidpp20_unifiedbattery_get_capabilities(hidpp, in hidpp20_query_battery_info_1004()
1594 hidpp->battery.feature_index); in hidpp20_query_battery_info_1004()
1598 ret = hidpp20_unifiedbattery_get_status(hidpp, in hidpp20_query_battery_info_1004()
1599 hidpp->battery.feature_index, in hidpp20_query_battery_info_1004()
1606 hidpp->capabilities |= HIDPP_CAPABILITY_UNIFIED_BATTERY; in hidpp20_query_battery_info_1004()
1607 hidpp->battery.capacity = state_of_charge; in hidpp20_query_battery_info_1004()
1608 hidpp->battery.status = status; in hidpp20_query_battery_info_1004()
1609 hidpp->battery.level = level; in hidpp20_query_battery_info_1004()
1610 hidpp->battery.online = true; in hidpp20_query_battery_info_1004()
1615 static int hidpp20_battery_event_1004(struct hidpp_device *hidpp, in hidpp20_battery_event_1004() argument
1623 if (report->fap.feature_index != hidpp->battery.feature_index || in hidpp20_battery_event_1004()
1628 status = hidpp20_unifiedbattery_map_status(hidpp, params[2], params[3]); in hidpp20_battery_event_1004()
1629 level = hidpp20_unifiedbattery_map_level(hidpp, params[1]); in hidpp20_battery_event_1004()
1631 changed = status != hidpp->battery.status || in hidpp20_battery_event_1004()
1632 (state_of_charge != hidpp->battery.capacity && in hidpp20_battery_event_1004()
1633 hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_PERCENTAGE) || in hidpp20_battery_event_1004()
1634 (level != hidpp->battery.level && in hidpp20_battery_event_1004()
1635 hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS); in hidpp20_battery_event_1004()
1638 hidpp->battery.capacity = state_of_charge; in hidpp20_battery_event_1004()
1639 hidpp->battery.status = status; in hidpp20_battery_event_1004()
1640 hidpp->battery.level = level; in hidpp20_battery_event_1004()
1641 if (hidpp->battery.ps) in hidpp20_battery_event_1004()
1642 power_supply_changed(hidpp->battery.ps); in hidpp20_battery_event_1004()
1668 struct hidpp_device *hidpp = power_supply_get_drvdata(psy); in hidpp_battery_get_property() local
1673 val->intval = hidpp->battery.status; in hidpp_battery_get_property()
1676 val->intval = hidpp->battery.capacity; in hidpp_battery_get_property()
1679 val->intval = hidpp->battery.level; in hidpp_battery_get_property()
1685 val->intval = hidpp->battery.online; in hidpp_battery_get_property()
1688 if (!strncmp(hidpp->name, "Logitech ", 9)) in hidpp_battery_get_property()
1689 val->strval = hidpp->name + 9; in hidpp_battery_get_property()
1691 val->strval = hidpp->name; in hidpp_battery_get_property()
1697 val->strval = hidpp->hid_dev->uniq; in hidpp_battery_get_property()
1701 val->intval = hidpp->battery.voltage * 1000; in hidpp_battery_get_property()
1704 val->intval = hidpp->battery.charge_type; in hidpp_battery_get_property()
1719 static int hidpp_set_wireless_feature_index(struct hidpp_device *hidpp) in hidpp_set_wireless_feature_index() argument
1724 ret = hidpp_root_get_feature(hidpp, in hidpp_set_wireless_feature_index()
1726 &hidpp->wireless_feature_index, in hidpp_set_wireless_feature_index()
1740 static int hidpp_hrs_set_highres_scrolling_mode(struct hidpp_device *hidpp, in hidpp_hrs_set_highres_scrolling_mode() argument
1749 ret = hidpp_root_get_feature(hidpp, in hidpp_hrs_set_highres_scrolling_mode()
1757 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_hrs_set_highres_scrolling_mode()
1775 static int hidpp_hrw_get_wheel_capability(struct hidpp_device *hidpp, in hidpp_hrw_get_wheel_capability() argument
1783 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_HIRES_WHEEL, in hidpp_hrw_get_wheel_capability()
1788 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_hrw_get_wheel_capability()
1797 hid_warn(hidpp->hid_dev, in hidpp_hrw_get_wheel_capability()
1802 static int hidpp_hrw_set_wheel_mode(struct hidpp_device *hidpp, bool invert, in hidpp_hrw_set_wheel_mode() argument
1811 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_HIRES_WHEEL, in hidpp_hrw_set_wheel_mode()
1820 return hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_hrw_set_wheel_mode()
1837 static int hidpp_solar_request_battery_event(struct hidpp_device *hidpp) in hidpp_solar_request_battery_event() argument
1844 if (hidpp->battery.feature_index == 0xff) { in hidpp_solar_request_battery_event()
1845 ret = hidpp_root_get_feature(hidpp, in hidpp_solar_request_battery_event()
1847 &hidpp->battery.solar_feature_index, in hidpp_solar_request_battery_event()
1853 ret = hidpp_send_fap_command_sync(hidpp, in hidpp_solar_request_battery_event()
1854 hidpp->battery.solar_feature_index, in hidpp_solar_request_battery_event()
1858 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_solar_request_battery_event()
1865 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_MILEAGE; in hidpp_solar_request_battery_event()
1870 static int hidpp_solar_battery_event(struct hidpp_device *hidpp, in hidpp_solar_battery_event() argument
1880 if (report->fap.feature_index != hidpp->battery.solar_feature_index || in hidpp_solar_battery_event()
1898 if (capacity < hidpp->battery.capacity) in hidpp_solar_battery_event()
1908 hidpp->battery.online = true; in hidpp_solar_battery_event()
1909 if (capacity != hidpp->battery.capacity || in hidpp_solar_battery_event()
1910 status != hidpp->battery.status) { in hidpp_solar_battery_event()
1911 hidpp->battery.capacity = capacity; in hidpp_solar_battery_event()
1912 hidpp->battery.status = status; in hidpp_solar_battery_event()
1913 if (hidpp->battery.ps) in hidpp_solar_battery_event()
1914 power_supply_changed(hidpp->battery.ps); in hidpp_solar_battery_event()
1939 static int hidpp_touchpad_fw_items_set(struct hidpp_device *hidpp, in hidpp_touchpad_fw_items_set() argument
1947 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_touchpad_fw_items_set()
1951 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_touchpad_fw_items_set()
2010 static int hidpp_touchpad_get_raw_info(struct hidpp_device *hidpp, in hidpp_touchpad_get_raw_info() argument
2017 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_touchpad_get_raw_info()
2021 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_touchpad_get_raw_info()
2134 struct hidpp_device *hidpp; member
2226 ret = hidpp_send_fap_command_sync(data->hidpp, data->feature_index, in hidpp_ff_work_handler()
2230 hid_err(data->hidpp->hid_dev, "Failed to send command to device!\n"); in hidpp_ff_work_handler()
2292 …hid_warn(data->hidpp->hid_dev, "Force feedback command queue contains %d commands, causing substan… in hidpp_ff_queue_work()
2351 …hid_err(data->hidpp->hid_dev, "Unexpected periodic waveform type %i!\n", effect->u.periodic.wavefo… in hidpp_ff_upload_effect()
2436 hid_err(data->hidpp->hid_dev, "Unexpected force type %i!\n", effect->type); in hidpp_ff_upload_effect()
2536 struct hid_device *hid = data->hidpp->hid_dev; in hidpp_ff_destroy()
2545 static int hidpp_ff_init(struct hidpp_device *hidpp, in hidpp_ff_init() argument
2548 struct hid_device *hid = hidpp->hid_dev; in hidpp_ff_init()
2604 data->hidpp = hidpp; in hidpp_ff_init()
2620 error = device_create_file(&(hidpp->hid_dev->dev), &dev_attr_range); in hidpp_ff_init()
2622 hid_warn(hidpp->hid_dev, "Unable to create sysfs interface for \"range\", errno %d!\n", error); in hidpp_ff_init()
2662 static void wtp_populate_input(struct hidpp_device *hidpp, in wtp_populate_input() argument
2665 struct wtp_data *wd = hidpp->private_data; in wtp_populate_input()
2682 if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS) in wtp_populate_input()
2691 static void wtp_touch_event(struct hidpp_device *hidpp, in wtp_touch_event() argument
2694 struct wtp_data *wd = hidpp->private_data; in wtp_touch_event()
2701 slot = input_mt_get_slot_by_key(hidpp->input, touch_report->finger_id); in wtp_touch_event()
2703 input_mt_slot(hidpp->input, slot); in wtp_touch_event()
2704 input_mt_report_slot_state(hidpp->input, MT_TOOL_FINGER, in wtp_touch_event()
2707 input_event(hidpp->input, EV_ABS, ABS_MT_POSITION_X, in wtp_touch_event()
2709 input_event(hidpp->input, EV_ABS, ABS_MT_POSITION_Y, in wtp_touch_event()
2712 input_event(hidpp->input, EV_ABS, ABS_MT_PRESSURE, in wtp_touch_event()
2717 static void wtp_send_raw_xy_event(struct hidpp_device *hidpp, in wtp_send_raw_xy_event() argument
2723 wtp_touch_event(hidpp, &(raw->fingers[i])); in wtp_send_raw_xy_event()
2726 !(hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS)) in wtp_send_raw_xy_event()
2727 input_event(hidpp->input, EV_KEY, BTN_LEFT, raw->button); in wtp_send_raw_xy_event()
2730 input_mt_sync_frame(hidpp->input); in wtp_send_raw_xy_event()
2731 input_sync(hidpp->input); in wtp_send_raw_xy_event()
2735 static int wtp_mouse_raw_xy_event(struct hidpp_device *hidpp, u8 *data) in wtp_mouse_raw_xy_event() argument
2737 struct wtp_data *wd = hidpp->private_data; in wtp_mouse_raw_xy_event()
2769 wtp_send_raw_xy_event(hidpp, &raw); in wtp_mouse_raw_xy_event()
2776 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in wtp_raw_event() local
2777 struct wtp_data *wd = hidpp->private_data; in wtp_raw_event()
2781 if (!wd || !hidpp->input) in wtp_raw_event()
2791 if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS) { in wtp_raw_event()
2792 input_event(hidpp->input, EV_KEY, BTN_LEFT, in wtp_raw_event()
2794 input_event(hidpp->input, EV_KEY, BTN_RIGHT, in wtp_raw_event()
2796 input_sync(hidpp->input); in wtp_raw_event()
2801 return wtp_mouse_raw_xy_event(hidpp, &data[7]); in wtp_raw_event()
2808 hidpp_touchpad_raw_xy_event(hidpp, data + 4, &raw); in wtp_raw_event()
2810 wtp_send_raw_xy_event(hidpp, &raw); in wtp_raw_event()
2817 static int wtp_get_config(struct hidpp_device *hidpp) in wtp_get_config() argument
2819 struct wtp_data *wd = hidpp->private_data; in wtp_get_config()
2824 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_TOUCHPAD_RAW_XY, in wtp_get_config()
2830 ret = hidpp_touchpad_get_raw_info(hidpp, wd->mt_feature_index, in wtp_get_config()
2848 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in wtp_allocate() local
2856 hidpp->private_data = wd; in wtp_allocate()
2863 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in wtp_connect() local
2864 struct wtp_data *wd = hidpp->private_data; in wtp_connect()
2868 ret = wtp_get_config(hidpp); in wtp_connect()
2875 return hidpp_touchpad_set_raw_report_state(hidpp, wd->mt_feature_index, in wtp_connect()
2943 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in m560_raw_event() local
2946 if (!hidpp->input) { in m560_raw_event()
2973 input_report_key(hidpp->input, BTN_MIDDLE, 1); in m560_raw_event()
2976 input_report_key(hidpp->input, BTN_FORWARD, 1); in m560_raw_event()
2979 input_report_key(hidpp->input, BTN_BACK, 1); in m560_raw_event()
2982 input_report_key(hidpp->input, BTN_BACK, 0); in m560_raw_event()
2983 input_report_key(hidpp->input, BTN_FORWARD, 0); in m560_raw_event()
2984 input_report_key(hidpp->input, BTN_MIDDLE, 0); in m560_raw_event()
2990 input_sync(hidpp->input); in m560_raw_event()
3004 input_report_key(hidpp->input, BTN_LEFT, in m560_raw_event()
3006 input_report_key(hidpp->input, BTN_RIGHT, in m560_raw_event()
3010 input_report_rel(hidpp->input, REL_HWHEEL, -1); in m560_raw_event()
3011 input_report_rel(hidpp->input, REL_HWHEEL_HI_RES, in m560_raw_event()
3014 input_report_rel(hidpp->input, REL_HWHEEL, 1); in m560_raw_event()
3015 input_report_rel(hidpp->input, REL_HWHEEL_HI_RES, in m560_raw_event()
3020 input_report_rel(hidpp->input, REL_X, v); in m560_raw_event()
3023 input_report_rel(hidpp->input, REL_Y, v); in m560_raw_event()
3027 hidpp_scroll_counter_handle_scroll(hidpp->input, in m560_raw_event()
3028 &hidpp->vertical_wheel_counter, v); in m560_raw_event()
3030 input_sync(hidpp->input); in m560_raw_event()
3036 static void m560_populate_input(struct hidpp_device *hidpp, in m560_populate_input() argument
3080 static int k400_disable_tap_to_click(struct hidpp_device *hidpp) in k400_disable_tap_to_click() argument
3082 struct k400_private_data *k400 = hidpp->private_data; in k400_disable_tap_to_click()
3088 ret = hidpp_root_get_feature(hidpp, in k400_disable_tap_to_click()
3096 ret = hidpp_touchpad_fw_items_set(hidpp, k400->feature_index, &items); in k400_disable_tap_to_click()
3105 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in k400_allocate() local
3113 hidpp->private_data = k400; in k400_allocate()
3120 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in k400_connect() local
3125 return k400_disable_tap_to_click(hidpp); in k400_connect()
3134 static int g920_ff_set_autocenter(struct hidpp_device *hidpp, in g920_ff_set_autocenter() argument
3146 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_ff_set_autocenter()
3151 hid_warn(hidpp->hid_dev, "Failed to autocenter device!\n"); in g920_ff_set_autocenter()
3158 static int g920_get_config(struct hidpp_device *hidpp, in g920_get_config() argument
3168 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_G920_FORCE_FEEDBACK, in g920_get_config()
3174 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_get_config()
3181 hid_err(hidpp->hid_dev, in g920_get_config()
3189 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_get_config()
3194 hid_warn(hidpp->hid_dev, "Failed to reset all forces!\n"); in g920_get_config()
3196 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_get_config()
3201 hid_warn(hidpp->hid_dev, in g920_get_config()
3208 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_get_config()
3213 hid_warn(hidpp->hid_dev, in g920_get_config()
3220 return g920_ff_set_autocenter(hidpp, data); in g920_get_config()
3246 static int hidpp10_wheel_connect(struct hidpp_device *hidpp) in hidpp10_wheel_connect() argument
3248 return hidpp10_set_register(hidpp, HIDPP_REG_ENABLE_REPORTS, 0, in hidpp10_wheel_connect()
3253 static int hidpp10_wheel_raw_event(struct hidpp_device *hidpp, in hidpp10_wheel_raw_event() argument
3258 if (!hidpp->input) in hidpp10_wheel_raw_event()
3270 input_report_rel(hidpp->input, REL_WHEEL, value); in hidpp10_wheel_raw_event()
3271 input_report_rel(hidpp->input, REL_WHEEL_HI_RES, value * 120); in hidpp10_wheel_raw_event()
3272 input_report_rel(hidpp->input, REL_HWHEEL, hvalue); in hidpp10_wheel_raw_event()
3273 input_report_rel(hidpp->input, REL_HWHEEL_HI_RES, hvalue * 120); in hidpp10_wheel_raw_event()
3274 input_sync(hidpp->input); in hidpp10_wheel_raw_event()
3279 static void hidpp10_wheel_populate_input(struct hidpp_device *hidpp, in hidpp10_wheel_populate_input() argument
3292 static int hidpp10_extra_mouse_buttons_connect(struct hidpp_device *hidpp) in hidpp10_extra_mouse_buttons_connect() argument
3294 return hidpp10_set_register(hidpp, HIDPP_REG_ENABLE_REPORTS, 0, in hidpp10_extra_mouse_buttons_connect()
3299 static int hidpp10_extra_mouse_buttons_raw_event(struct hidpp_device *hidpp, in hidpp10_extra_mouse_buttons_raw_event() argument
3304 if (!hidpp->input) in hidpp10_extra_mouse_buttons_raw_event()
3321 input_report_key(hidpp->input, BTN_MOUSE + i, in hidpp10_extra_mouse_buttons_raw_event()
3326 input_report_key(hidpp->input, BTN_MISC + i, in hidpp10_extra_mouse_buttons_raw_event()
3329 input_sync(hidpp->input); in hidpp10_extra_mouse_buttons_raw_event()
3334 struct hidpp_device *hidpp, struct input_dev *input_dev) in hidpp10_extra_mouse_buttons_populate_input() argument
3352 static u8 *hidpp10_consumer_keys_report_fixup(struct hidpp_device *hidpp, in hidpp10_consumer_keys_report_fixup() argument
3380 static int hidpp10_consumer_keys_connect(struct hidpp_device *hidpp) in hidpp10_consumer_keys_connect() argument
3382 return hidpp10_set_register(hidpp, HIDPP_REG_ENABLE_REPORTS, 0, in hidpp10_consumer_keys_connect()
3387 static int hidpp10_consumer_keys_raw_event(struct hidpp_device *hidpp, in hidpp10_consumer_keys_raw_event() argument
3406 hid_report_raw_event(hidpp->hid_dev, HID_INPUT_REPORT, in hidpp10_consumer_keys_raw_event()
3416 static int hi_res_scroll_enable(struct hidpp_device *hidpp) in hi_res_scroll_enable() argument
3421 if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_HI_RES_WHEEL) { in hi_res_scroll_enable()
3422 ret = hidpp_hrw_set_wheel_mode(hidpp, false, true, false); in hi_res_scroll_enable()
3424 ret = hidpp_hrw_get_wheel_capability(hidpp, &multiplier); in hi_res_scroll_enable()
3425 } else if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_HI_RES_SCROLL) { in hi_res_scroll_enable()
3426 ret = hidpp_hrs_set_highres_scrolling_mode(hidpp, true, in hi_res_scroll_enable()
3429 ret = hidpp10_enable_scrolling_acceleration(hidpp); in hi_res_scroll_enable()
3438 hidpp->vertical_wheel_counter.wheel_multiplier = multiplier; in hi_res_scroll_enable()
3439 hid_dbg(hidpp->hid_dev, "wheel multiplier = %d\n", multiplier); in hi_res_scroll_enable()
3443 static int hidpp_initialize_hires_scroll(struct hidpp_device *hidpp) in hidpp_initialize_hires_scroll() argument
3448 capabilities = hidpp->capabilities; in hidpp_initialize_hires_scroll()
3450 if (hidpp->protocol_major >= 2) { in hidpp_initialize_hires_scroll()
3454 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_HIRES_WHEEL, in hidpp_initialize_hires_scroll()
3457 hidpp->capabilities |= HIDPP_CAPABILITY_HIDPP20_HI_RES_WHEEL; in hidpp_initialize_hires_scroll()
3458 hid_dbg(hidpp->hid_dev, "Detected HID++ 2.0 hi-res scroll wheel\n"); in hidpp_initialize_hires_scroll()
3461 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_HI_RESOLUTION_SCROLLING, in hidpp_initialize_hires_scroll()
3464 hidpp->capabilities |= HIDPP_CAPABILITY_HIDPP20_HI_RES_SCROLL; in hidpp_initialize_hires_scroll()
3465 hid_dbg(hidpp->hid_dev, "Detected HID++ 2.0 hi-res scrolling\n"); in hidpp_initialize_hires_scroll()
3470 ret = hidpp_send_rap_command_sync(hidpp, in hidpp_initialize_hires_scroll()
3476 hidpp->capabilities |= HIDPP_CAPABILITY_HIDPP10_FAST_SCROLL; in hidpp_initialize_hires_scroll()
3477 hid_dbg(hidpp->hid_dev, "Detected HID++ 1.0 fast scroll\n"); in hidpp_initialize_hires_scroll()
3481 if (hidpp->capabilities == capabilities) in hidpp_initialize_hires_scroll()
3482 hid_dbg(hidpp->hid_dev, "Did not detect HID++ hi-res scrolling hardware support\n"); in hidpp_initialize_hires_scroll()
3493 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_report_fixup() local
3495 if (!hidpp) in hidpp_report_fixup()
3500 (hidpp->quirks & HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS)) in hidpp_report_fixup()
3501 rdesc = hidpp10_consumer_keys_report_fixup(hidpp, rdesc, rsize); in hidpp_report_fixup()
3510 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_input_mapping() local
3512 if (!hidpp) in hidpp_input_mapping()
3515 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) in hidpp_input_mapping()
3517 else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560 && in hidpp_input_mapping()
3531 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_input_mapped() local
3533 if (!hidpp) in hidpp_input_mapped()
3537 if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) { in hidpp_input_mapped()
3549 static void hidpp_populate_input(struct hidpp_device *hidpp, in hidpp_populate_input() argument
3552 hidpp->input = input; in hidpp_populate_input()
3554 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) in hidpp_populate_input()
3555 wtp_populate_input(hidpp, input); in hidpp_populate_input()
3556 else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) in hidpp_populate_input()
3557 m560_populate_input(hidpp, input); in hidpp_populate_input()
3559 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_WHEELS) in hidpp_populate_input()
3560 hidpp10_wheel_populate_input(hidpp, input); in hidpp_populate_input()
3562 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_EXTRA_MOUSE_BTNS) in hidpp_populate_input()
3563 hidpp10_extra_mouse_buttons_populate_input(hidpp, input); in hidpp_populate_input()
3569 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_input_configured() local
3572 if (!hidpp) in hidpp_input_configured()
3575 hidpp_populate_input(hidpp, input); in hidpp_input_configured()
3580 static int hidpp_raw_hidpp_event(struct hidpp_device *hidpp, u8 *data, in hidpp_raw_hidpp_event() argument
3583 struct hidpp_report *question = hidpp->send_receive_buf; in hidpp_raw_hidpp_event()
3584 struct hidpp_report *answer = hidpp->send_receive_buf; in hidpp_raw_hidpp_event()
3592 if (unlikely(mutex_is_locked(&hidpp->send_mutex))) { in hidpp_raw_hidpp_event()
3600 hidpp->answer_available = true; in hidpp_raw_hidpp_event()
3601 wake_up(&hidpp->wait); in hidpp_raw_hidpp_event()
3612 if (unlikely(hidpp_report_is_connect_event(hidpp, report))) { in hidpp_raw_hidpp_event()
3613 atomic_set(&hidpp->connected, in hidpp_raw_hidpp_event()
3615 if (schedule_work(&hidpp->work) == 0) in hidpp_raw_hidpp_event()
3620 if (hidpp->hid_dev->group == HID_GROUP_LOGITECH_27MHZ_DEVICE && in hidpp_raw_hidpp_event()
3624 dev_err_ratelimited(&hidpp->hid_dev->dev, in hidpp_raw_hidpp_event()
3626 dev_err_ratelimited(&hidpp->hid_dev->dev, in hidpp_raw_hidpp_event()
3630 if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_BATTERY) { in hidpp_raw_hidpp_event()
3631 ret = hidpp20_battery_event_1000(hidpp, data, size); in hidpp_raw_hidpp_event()
3634 ret = hidpp20_battery_event_1004(hidpp, data, size); in hidpp_raw_hidpp_event()
3637 ret = hidpp_solar_battery_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3640 ret = hidpp20_battery_voltage_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3645 if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP10_BATTERY) { in hidpp_raw_hidpp_event()
3646 ret = hidpp10_battery_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3651 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_WHEELS) { in hidpp_raw_hidpp_event()
3652 ret = hidpp10_wheel_raw_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3657 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_EXTRA_MOUSE_BTNS) { in hidpp_raw_hidpp_event()
3658 ret = hidpp10_extra_mouse_buttons_raw_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3663 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS) { in hidpp_raw_hidpp_event()
3664 ret = hidpp10_consumer_keys_raw_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3675 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_raw_event() local
3678 if (!hidpp) in hidpp_raw_event()
3684 if (size != hidpp->very_long_report_length) { in hidpp_raw_event()
3689 ret = hidpp_raw_hidpp_event(hidpp, data, size); in hidpp_raw_event()
3697 ret = hidpp_raw_hidpp_event(hidpp, data, size); in hidpp_raw_event()
3705 ret = hidpp_raw_hidpp_event(hidpp, data, size); in hidpp_raw_event()
3714 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) in hidpp_raw_event()
3716 else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) in hidpp_raw_event()
3728 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_event() local
3731 if (!hidpp) in hidpp_event()
3734 counter = &hidpp->vertical_wheel_counter; in hidpp_event()
3740 if (!(hidpp->capabilities & HIDPP_CAPABILITY_HI_RES_SCROLL) in hidpp_event()
3741 || value == 0 || hidpp->input == NULL in hidpp_event()
3745 hidpp_scroll_counter_handle_scroll(hidpp->input, counter, value); in hidpp_event()
3749 static int hidpp_initialize_battery(struct hidpp_device *hidpp) in hidpp_initialize_battery() argument
3752 struct power_supply_config cfg = { .drv_data = hidpp }; in hidpp_initialize_battery()
3753 struct power_supply_desc *desc = &hidpp->battery.desc; in hidpp_initialize_battery()
3760 if (hidpp->battery.ps) in hidpp_initialize_battery()
3763 hidpp->battery.feature_index = 0xff; in hidpp_initialize_battery()
3764 hidpp->battery.solar_feature_index = 0xff; in hidpp_initialize_battery()
3765 hidpp->battery.voltage_feature_index = 0xff; in hidpp_initialize_battery()
3767 if (hidpp->protocol_major >= 2) { in hidpp_initialize_battery()
3768 if (hidpp->quirks & HIDPP_QUIRK_CLASS_K750) in hidpp_initialize_battery()
3769 ret = hidpp_solar_request_battery_event(hidpp); in hidpp_initialize_battery()
3774 ret = hidpp20_query_battery_info_1000(hidpp); in hidpp_initialize_battery()
3776 ret = hidpp20_query_battery_info_1004(hidpp); in hidpp_initialize_battery()
3778 ret = hidpp20_query_battery_voltage_info(hidpp); in hidpp_initialize_battery()
3783 hidpp->capabilities |= HIDPP_CAPABILITY_HIDPP20_BATTERY; in hidpp_initialize_battery()
3785 ret = hidpp10_query_battery_status(hidpp); in hidpp_initialize_battery()
3787 ret = hidpp10_query_battery_mileage(hidpp); in hidpp_initialize_battery()
3790 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_MILEAGE; in hidpp_initialize_battery()
3792 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS; in hidpp_initialize_battery()
3794 hidpp->capabilities |= HIDPP_CAPABILITY_HIDPP10_BATTERY; in hidpp_initialize_battery()
3797 battery_props = devm_kmemdup(&hidpp->hid_dev->dev, in hidpp_initialize_battery()
3806 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_MILEAGE || in hidpp_initialize_battery()
3807 hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_PERCENTAGE || in hidpp_initialize_battery()
3808 hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_VOLTAGE) in hidpp_initialize_battery()
3812 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS) in hidpp_initialize_battery()
3816 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_VOLTAGE) in hidpp_initialize_battery()
3820 battery = &hidpp->battery; in hidpp_initialize_battery()
3831 battery->ps = devm_power_supply_register(&hidpp->hid_dev->dev, in hidpp_initialize_battery()
3837 power_supply_powers(battery->ps, &hidpp->hid_dev->dev); in hidpp_initialize_battery()
3844 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_overwrite_name() local
3847 if (hidpp->protocol_major < 2) in hidpp_overwrite_name()
3850 name = hidpp_get_device_name(hidpp); in hidpp_overwrite_name()
3879 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_allocate_input() local
3888 input_dev->name = hidpp->name; in hidpp_allocate_input()
3900 static void hidpp_connect_event(struct hidpp_device *hidpp) in hidpp_connect_event() argument
3902 struct hid_device *hdev = hidpp->hid_dev; in hidpp_connect_event()
3904 bool connected = atomic_read(&hidpp->connected); in hidpp_connect_event()
3909 if (hidpp->battery.ps) { in hidpp_connect_event()
3910 hidpp->battery.online = false; in hidpp_connect_event()
3911 hidpp->battery.status = POWER_SUPPLY_STATUS_UNKNOWN; in hidpp_connect_event()
3912 hidpp->battery.level = POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN; in hidpp_connect_event()
3913 power_supply_changed(hidpp->battery.ps); in hidpp_connect_event()
3918 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) { in hidpp_connect_event()
3922 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) { in hidpp_connect_event()
3926 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_K400) { in hidpp_connect_event()
3932 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_WHEELS) { in hidpp_connect_event()
3933 ret = hidpp10_wheel_connect(hidpp); in hidpp_connect_event()
3938 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_EXTRA_MOUSE_BTNS) { in hidpp_connect_event()
3939 ret = hidpp10_extra_mouse_buttons_connect(hidpp); in hidpp_connect_event()
3944 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS) { in hidpp_connect_event()
3945 ret = hidpp10_consumer_keys_connect(hidpp); in hidpp_connect_event()
3952 if (!hidpp->protocol_major) { in hidpp_connect_event()
3953 ret = hidpp_root_get_protocol_version(hidpp); in hidpp_connect_event()
3960 if (hidpp->name == hdev->name && hidpp->protocol_major >= 2) { in hidpp_connect_event()
3961 name = hidpp_get_device_name(hidpp); in hidpp_connect_event()
3969 hidpp->name = devm_name; in hidpp_connect_event()
3973 hidpp_initialize_battery(hidpp); in hidpp_connect_event()
3974 hidpp_initialize_hires_scroll(hidpp); in hidpp_connect_event()
3977 if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP10_BATTERY) { in hidpp_connect_event()
3978 hidpp10_enable_battery_reporting(hidpp); in hidpp_connect_event()
3979 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_MILEAGE) in hidpp_connect_event()
3980 hidpp10_query_battery_mileage(hidpp); in hidpp_connect_event()
3982 hidpp10_query_battery_status(hidpp); in hidpp_connect_event()
3983 } else if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_BATTERY) { in hidpp_connect_event()
3984 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_VOLTAGE) in hidpp_connect_event()
3985 hidpp20_query_battery_voltage_info(hidpp); in hidpp_connect_event()
3986 else if (hidpp->capabilities & HIDPP_CAPABILITY_UNIFIED_BATTERY) in hidpp_connect_event()
3987 hidpp20_query_battery_info_1004(hidpp); in hidpp_connect_event()
3989 hidpp20_query_battery_info_1000(hidpp); in hidpp_connect_event()
3991 if (hidpp->battery.ps) in hidpp_connect_event()
3992 power_supply_changed(hidpp->battery.ps); in hidpp_connect_event()
3994 if (hidpp->capabilities & HIDPP_CAPABILITY_HI_RES_SCROLL) in hidpp_connect_event()
3995 hi_res_scroll_enable(hidpp); in hidpp_connect_event()
3997 if (!(hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT) || hidpp->delayed_input) in hidpp_connect_event()
4007 hidpp_populate_input(hidpp, input); in hidpp_connect_event()
4015 hidpp->delayed_input = input; in hidpp_connect_event()
4044 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_validate_device() local
4074 hidpp->very_long_report_length = report_length; in hidpp_validate_device()
4097 struct hidpp_device *hidpp; in hidpp_probe() local
4104 hidpp = devm_kzalloc(&hdev->dev, sizeof(*hidpp), GFP_KERNEL); in hidpp_probe()
4105 if (!hidpp) in hidpp_probe()
4108 hidpp->hid_dev = hdev; in hidpp_probe()
4109 hidpp->name = hdev->name; in hidpp_probe()
4110 hidpp->quirks = id->driver_data; in hidpp_probe()
4111 hid_set_drvdata(hdev, hidpp); in hidpp_probe()
4122 hidpp->supported_reports = hidpp_validate_device(hdev); in hidpp_probe()
4124 if (!hidpp->supported_reports) { in hidpp_probe()
4126 devm_kfree(&hdev->dev, hidpp); in hidpp_probe()
4131 hidpp->quirks |= HIDPP_QUIRK_UNIFYING; in hidpp_probe()
4135 hidpp->quirks |= HIDPP_QUIRK_HIDPP_WHEELS | in hidpp_probe()
4140 hidpp->quirks |= HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS; in hidpp_probe()
4143 hidpp->quirks &= ~HIDPP_QUIRK_CLASS_WTP; in hidpp_probe()
4144 hidpp->quirks &= ~HIDPP_QUIRK_NO_HIDINPUT; in hidpp_probe()
4147 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) { in hidpp_probe()
4151 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_K400) { in hidpp_probe()
4157 INIT_WORK(&hidpp->work, delayed_work_cb); in hidpp_probe()
4158 mutex_init(&hidpp->send_mutex); in hidpp_probe()
4159 init_waitqueue_head(&hidpp->wait); in hidpp_probe()
4187 if (hidpp->quirks & HIDPP_QUIRK_UNIFYING) in hidpp_probe()
4188 hidpp_unifying_init(hidpp); in hidpp_probe()
4190 connected = hidpp_root_get_protocol_version(hidpp) == 0; in hidpp_probe()
4191 atomic_set(&hidpp->connected, connected); in hidpp_probe()
4192 if (!(hidpp->quirks & HIDPP_QUIRK_UNIFYING)) { in hidpp_probe()
4202 if (connected && hidpp->protocol_major >= 2) { in hidpp_probe()
4203 ret = hidpp_set_wireless_feature_index(hidpp); in hidpp_probe()
4205 hidpp->wireless_feature_index = 0; in hidpp_probe()
4210 if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)) { in hidpp_probe()
4211 ret = wtp_get_config(hidpp); in hidpp_probe()
4214 } else if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_G920)) { in hidpp_probe()
4215 ret = g920_get_config(hidpp, &data); in hidpp_probe()
4220 hidpp_connect_event(hidpp); in hidpp_probe()
4227 if (hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT) in hidpp_probe()
4237 if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) { in hidpp_probe()
4238 ret = hidpp_ff_init(hidpp, &data); in hidpp_probe()
4240 hid_warn(hidpp->hid_dev, in hidpp_probe()
4253 cancel_work_sync(&hidpp->work); in hidpp_probe()
4254 mutex_destroy(&hidpp->send_mutex); in hidpp_probe()
4260 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_remove() local
4262 if (!hidpp) in hidpp_remove()
4268 cancel_work_sync(&hidpp->work); in hidpp_remove()
4269 mutex_destroy(&hidpp->send_mutex); in hidpp_remove()