Lines Matching refs:hidpp
243 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in __hidpp_send_report() local
254 fields_count = hidpp->very_long_report_length; in __hidpp_send_report()
266 if (hidpp->quirks & HIDPP_QUIRK_FORCE_OUTPUT_REPORTS) { in __hidpp_send_report()
287 static int __do_hidpp_send_message_sync(struct hidpp_device *hidpp, in __do_hidpp_send_message_sync() argument
293 __must_hold(&hidpp->send_mutex); in __do_hidpp_send_message_sync()
295 hidpp->send_receive_buf = response; in __do_hidpp_send_message_sync()
296 hidpp->answer_available = false; in __do_hidpp_send_message_sync()
304 ret = __hidpp_send_report(hidpp->hid_dev, message); in __do_hidpp_send_message_sync()
311 if (!wait_event_timeout(hidpp->wait, hidpp->answer_available, in __do_hidpp_send_message_sync()
343 static int hidpp_send_message_sync(struct hidpp_device *hidpp, in hidpp_send_message_sync() argument
350 mutex_lock(&hidpp->send_mutex); in hidpp_send_message_sync()
353 ret = __do_hidpp_send_message_sync(hidpp, message, response); in hidpp_send_message_sync()
360 mutex_unlock(&hidpp->send_mutex); in hidpp_send_message_sync()
372 static int hidpp_send_fap_command_sync(struct hidpp_device *hidpp, in hidpp_send_fap_command_sync() argument
380 hid_dbg(hidpp->hid_dev, in hidpp_send_fap_command_sync()
399 ret = hidpp_send_message_sync(hidpp, message, response); in hidpp_send_fap_command_sync()
455 struct hidpp_device *hidpp = container_of(work, struct hidpp_device, in delayed_work_cb() local
457 hidpp_connect_event(hidpp); in delayed_work_cb()
476 static inline bool hidpp_report_is_connect_event(struct hidpp_device *hidpp, in hidpp_report_is_connect_event() argument
479 return (hidpp->wireless_feature_index && in hidpp_report_is_connect_event()
480 (report->fap.feature_index == hidpp->wireless_feature_index)) || in hidpp_report_is_connect_event()
516 static void hidpp_update_usb_wireless_status(struct hidpp_device *hidpp) in hidpp_update_usb_wireless_status() argument
518 struct hid_device *hdev = hidpp->hid_dev; in hidpp_update_usb_wireless_status()
521 if (!(hidpp->quirks & HIDPP_QUIRK_WIRELESS_STATUS)) in hidpp_update_usb_wireless_status()
527 usb_set_wireless_status(intf, hidpp->battery.online ? in hidpp_update_usb_wireless_status()
724 static int hidpp10_query_battery_status(struct hidpp_device *hidpp) in hidpp10_query_battery_status() argument
729 ret = hidpp_send_rap_command_sync(hidpp, in hidpp10_query_battery_status()
737 hidpp->battery.level = in hidpp10_query_battery_status()
740 hidpp->battery.status = status; in hidpp10_query_battery_status()
742 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp10_query_battery_status()
776 static int hidpp10_query_battery_mileage(struct hidpp_device *hidpp) in hidpp10_query_battery_mileage() argument
781 ret = hidpp_send_rap_command_sync(hidpp, in hidpp10_query_battery_mileage()
789 hidpp->battery.capacity = response.rap.params[0]; in hidpp10_query_battery_mileage()
791 hidpp->battery.status = status; in hidpp10_query_battery_mileage()
793 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp10_query_battery_mileage()
799 static int hidpp10_battery_event(struct hidpp_device *hidpp, u8 *data, int size) in hidpp10_battery_event() argument
810 capacity = hidpp->battery.capacity; in hidpp10_battery_event()
816 level = hidpp->battery.level; in hidpp10_battery_event()
823 changed = capacity != hidpp->battery.capacity || in hidpp10_battery_event()
824 level != hidpp->battery.level || in hidpp10_battery_event()
825 status != hidpp->battery.status; in hidpp10_battery_event()
828 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp10_battery_event()
832 hidpp->battery.level = level; in hidpp10_battery_event()
833 hidpp->battery.status = status; in hidpp10_battery_event()
834 if (hidpp->battery.ps) in hidpp10_battery_event()
835 power_supply_changed(hidpp->battery.ps); in hidpp10_battery_event()
881 static int hidpp_unifying_get_serial(struct hidpp_device *hidpp, u32 *serial) in hidpp_unifying_get_serial() argument
887 ret = hidpp_send_rap_command_sync(hidpp, in hidpp_unifying_get_serial()
903 static int hidpp_unifying_init(struct hidpp_device *hidpp) in hidpp_unifying_init() argument
905 struct hid_device *hdev = hidpp->hid_dev; in hidpp_unifying_init()
910 ret = hidpp_unifying_get_serial(hidpp, &serial); in hidpp_unifying_init()
917 name = hidpp_unifying_get_name(hidpp); in hidpp_unifying_init()
938 static int hidpp_root_get_feature(struct hidpp_device *hidpp, u16 feature, in hidpp_root_get_feature() argument
945 ret = hidpp_send_fap_command_sync(hidpp, in hidpp_root_get_feature()
961 static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp) in hidpp_root_get_protocol_version() argument
968 ret = hidpp_send_rap_command_sync(hidpp, in hidpp_root_get_protocol_version()
975 hidpp->protocol_major = 1; in hidpp_root_get_protocol_version()
976 hidpp->protocol_minor = 0; in hidpp_root_get_protocol_version()
985 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_root_get_protocol_version()
993 hid_err(hidpp->hid_dev, "%s: ping mismatch 0x%02x != 0x%02x\n", in hidpp_root_get_protocol_version()
998 hidpp->protocol_major = response.rap.params[0]; in hidpp_root_get_protocol_version()
999 hidpp->protocol_minor = response.rap.params[1]; in hidpp_root_get_protocol_version()
1002 hid_info(hidpp->hid_dev, "HID++ %u.%u device connected.\n", in hidpp_root_get_protocol_version()
1003 hidpp->protocol_major, hidpp->protocol_minor); in hidpp_root_get_protocol_version()
1015 static int hidpp_get_serial(struct hidpp_device *hidpp, u32 *serial) in hidpp_get_serial() argument
1022 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_DEVICE_INFORMATION, in hidpp_get_serial()
1028 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_get_serial()
1039 static int hidpp_serial_init(struct hidpp_device *hidpp) in hidpp_serial_init() argument
1041 struct hid_device *hdev = hidpp->hid_dev; in hidpp_serial_init()
1045 ret = hidpp_get_serial(hidpp, &serial); in hidpp_serial_init()
1065 static int hidpp_devicenametype_get_count(struct hidpp_device *hidpp, in hidpp_devicenametype_get_count() argument
1071 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_devicenametype_get_count()
1075 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_devicenametype_get_count()
1087 static int hidpp_devicenametype_get_device_name(struct hidpp_device *hidpp, in hidpp_devicenametype_get_device_name() argument
1094 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_devicenametype_get_device_name()
1099 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_devicenametype_get_device_name()
1108 count = hidpp->very_long_report_length - 4; in hidpp_devicenametype_get_device_name()
1129 static char *hidpp_get_device_name(struct hidpp_device *hidpp) in hidpp_get_device_name() argument
1138 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_GET_DEVICE_NAME_TYPE, in hidpp_get_device_name()
1143 ret = hidpp_devicenametype_get_count(hidpp, feature_index, in hidpp_get_device_name()
1153 ret = hidpp_devicenametype_get_device_name(hidpp, in hidpp_get_device_name()
1242 static int hidpp20_batterylevel_get_battery_capacity(struct hidpp_device *hidpp, in hidpp20_batterylevel_get_battery_capacity() argument
1253 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp20_batterylevel_get_battery_capacity()
1260 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_batterylevel_get_battery_capacity()
1274 static int hidpp20_batterylevel_get_battery_info(struct hidpp_device *hidpp, in hidpp20_batterylevel_get_battery_info() argument
1282 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp20_batterylevel_get_battery_info()
1286 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_batterylevel_get_battery_info()
1297 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS; in hidpp20_batterylevel_get_battery_info()
1299 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_MILEAGE; in hidpp20_batterylevel_get_battery_info()
1304 static int hidpp20_query_battery_info_1000(struct hidpp_device *hidpp) in hidpp20_query_battery_info_1000() argument
1310 if (hidpp->battery.feature_index == 0xff) { in hidpp20_query_battery_info_1000()
1311 ret = hidpp_root_get_feature(hidpp, in hidpp20_query_battery_info_1000()
1313 &hidpp->battery.feature_index, in hidpp20_query_battery_info_1000()
1319 ret = hidpp20_batterylevel_get_battery_capacity(hidpp, in hidpp20_query_battery_info_1000()
1320 hidpp->battery.feature_index, in hidpp20_query_battery_info_1000()
1326 ret = hidpp20_batterylevel_get_battery_info(hidpp, in hidpp20_query_battery_info_1000()
1327 hidpp->battery.feature_index); in hidpp20_query_battery_info_1000()
1331 hidpp->battery.status = status; in hidpp20_query_battery_info_1000()
1332 hidpp->battery.capacity = capacity; in hidpp20_query_battery_info_1000()
1333 hidpp->battery.level = level; in hidpp20_query_battery_info_1000()
1335 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp20_query_battery_info_1000()
1341 static int hidpp20_battery_event_1000(struct hidpp_device *hidpp, in hidpp20_battery_event_1000() argument
1348 if (report->fap.feature_index != hidpp->battery.feature_index || in hidpp20_battery_event_1000()
1358 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp20_battery_event_1000()
1361 changed = capacity != hidpp->battery.capacity || in hidpp20_battery_event_1000()
1362 level != hidpp->battery.level || in hidpp20_battery_event_1000()
1363 status != hidpp->battery.status; in hidpp20_battery_event_1000()
1366 hidpp->battery.level = level; in hidpp20_battery_event_1000()
1367 hidpp->battery.capacity = capacity; in hidpp20_battery_event_1000()
1368 hidpp->battery.status = status; in hidpp20_battery_event_1000()
1369 if (hidpp->battery.ps) in hidpp20_battery_event_1000()
1370 power_supply_changed(hidpp->battery.ps); in hidpp20_battery_event_1000()
1429 static int hidpp20_battery_get_battery_voltage(struct hidpp_device *hidpp, in hidpp20_battery_get_battery_voltage() argument
1438 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp20_battery_get_battery_voltage()
1443 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_battery_get_battery_voltage()
1450 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_VOLTAGE; in hidpp20_battery_get_battery_voltage()
1493 static int hidpp20_query_battery_voltage_info(struct hidpp_device *hidpp) in hidpp20_query_battery_voltage_info() argument
1499 if (hidpp->battery.voltage_feature_index == 0xff) { in hidpp20_query_battery_voltage_info()
1500 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_BATTERY_VOLTAGE, in hidpp20_query_battery_voltage_info()
1501 &hidpp->battery.voltage_feature_index, in hidpp20_query_battery_voltage_info()
1507 ret = hidpp20_battery_get_battery_voltage(hidpp, in hidpp20_query_battery_voltage_info()
1508 hidpp->battery.voltage_feature_index, in hidpp20_query_battery_voltage_info()
1514 hidpp->battery.status = status; in hidpp20_query_battery_voltage_info()
1515 hidpp->battery.voltage = voltage; in hidpp20_query_battery_voltage_info()
1516 hidpp->battery.capacity = hidpp20_map_battery_capacity(hidpp->hid_dev, in hidpp20_query_battery_voltage_info()
1518 hidpp->battery.level = level; in hidpp20_query_battery_voltage_info()
1519 hidpp->battery.charge_type = charge_type; in hidpp20_query_battery_voltage_info()
1520 hidpp->battery.online = status != POWER_SUPPLY_STATUS_NOT_CHARGING; in hidpp20_query_battery_voltage_info()
1525 static int hidpp20_battery_voltage_event(struct hidpp_device *hidpp, in hidpp20_battery_voltage_event() argument
1531 if (report->fap.feature_index != hidpp->battery.voltage_feature_index || in hidpp20_battery_voltage_event()
1538 hidpp->battery.online = status != POWER_SUPPLY_STATUS_NOT_CHARGING; in hidpp20_battery_voltage_event()
1540 if (voltage != hidpp->battery.voltage || status != hidpp->battery.status) { in hidpp20_battery_voltage_event()
1541 hidpp->battery.voltage = voltage; in hidpp20_battery_voltage_event()
1542 hidpp->battery.capacity = hidpp20_map_battery_capacity(hidpp->hid_dev, in hidpp20_battery_voltage_event()
1544 hidpp->battery.status = status; in hidpp20_battery_voltage_event()
1545 hidpp->battery.level = level; in hidpp20_battery_voltage_event()
1546 hidpp->battery.charge_type = charge_type; in hidpp20_battery_voltage_event()
1547 if (hidpp->battery.ps) in hidpp20_battery_voltage_event()
1548 power_supply_changed(hidpp->battery.ps); in hidpp20_battery_voltage_event()
1572 static int hidpp20_unifiedbattery_get_capabilities(struct hidpp_device *hidpp, in hidpp20_unifiedbattery_get_capabilities() argument
1579 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS || in hidpp20_unifiedbattery_get_capabilities()
1580 hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_PERCENTAGE) { in hidpp20_unifiedbattery_get_capabilities()
1585 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp20_unifiedbattery_get_capabilities()
1592 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_unifiedbattery_get_capabilities()
1607 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_PERCENTAGE; in hidpp20_unifiedbattery_get_capabilities()
1608 hidpp->battery.supported_levels_1004 = 0; in hidpp20_unifiedbattery_get_capabilities()
1610 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS; in hidpp20_unifiedbattery_get_capabilities()
1611 hidpp->battery.supported_levels_1004 = params[0]; in hidpp20_unifiedbattery_get_capabilities()
1617 static int hidpp20_unifiedbattery_map_status(struct hidpp_device *hidpp, in hidpp20_unifiedbattery_map_status() argument
1636 hid_info(hidpp->hid_dev, "%s: charging error", in hidpp20_unifiedbattery_map_status()
1637 hidpp->name); in hidpp20_unifiedbattery_map_status()
1647 static int hidpp20_unifiedbattery_map_level(struct hidpp_device *hidpp, in hidpp20_unifiedbattery_map_level() argument
1651 battery_level &= hidpp->battery.supported_levels_1004; in hidpp20_unifiedbattery_map_level()
1665 static int hidpp20_unifiedbattery_get_status(struct hidpp_device *hidpp, in hidpp20_unifiedbattery_get_status() argument
1675 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp20_unifiedbattery_get_status()
1682 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_unifiedbattery_get_status()
1690 *status = hidpp20_unifiedbattery_map_status(hidpp, params[2], params[3]); in hidpp20_unifiedbattery_get_status()
1691 *level = hidpp20_unifiedbattery_map_level(hidpp, params[1]); in hidpp20_unifiedbattery_get_status()
1696 static int hidpp20_query_battery_info_1004(struct hidpp_device *hidpp) in hidpp20_query_battery_info_1004() argument
1703 if (hidpp->battery.feature_index == 0xff) { in hidpp20_query_battery_info_1004()
1704 ret = hidpp_root_get_feature(hidpp, in hidpp20_query_battery_info_1004()
1706 &hidpp->battery.feature_index, in hidpp20_query_battery_info_1004()
1712 ret = hidpp20_unifiedbattery_get_capabilities(hidpp, in hidpp20_query_battery_info_1004()
1713 hidpp->battery.feature_index); in hidpp20_query_battery_info_1004()
1717 ret = hidpp20_unifiedbattery_get_status(hidpp, in hidpp20_query_battery_info_1004()
1718 hidpp->battery.feature_index, in hidpp20_query_battery_info_1004()
1725 hidpp->capabilities |= HIDPP_CAPABILITY_UNIFIED_BATTERY; in hidpp20_query_battery_info_1004()
1726 hidpp->battery.capacity = state_of_charge; in hidpp20_query_battery_info_1004()
1727 hidpp->battery.status = status; in hidpp20_query_battery_info_1004()
1728 hidpp->battery.level = level; in hidpp20_query_battery_info_1004()
1729 hidpp->battery.online = true; in hidpp20_query_battery_info_1004()
1734 static int hidpp20_battery_event_1004(struct hidpp_device *hidpp, in hidpp20_battery_event_1004() argument
1742 if (report->fap.feature_index != hidpp->battery.feature_index || in hidpp20_battery_event_1004()
1747 status = hidpp20_unifiedbattery_map_status(hidpp, params[2], params[3]); in hidpp20_battery_event_1004()
1748 level = hidpp20_unifiedbattery_map_level(hidpp, params[1]); in hidpp20_battery_event_1004()
1750 changed = status != hidpp->battery.status || in hidpp20_battery_event_1004()
1751 (state_of_charge != hidpp->battery.capacity && in hidpp20_battery_event_1004()
1752 hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_PERCENTAGE) || in hidpp20_battery_event_1004()
1753 (level != hidpp->battery.level && in hidpp20_battery_event_1004()
1754 hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS); in hidpp20_battery_event_1004()
1757 hidpp->battery.capacity = state_of_charge; in hidpp20_battery_event_1004()
1758 hidpp->battery.status = status; in hidpp20_battery_event_1004()
1759 hidpp->battery.level = level; in hidpp20_battery_event_1004()
1760 if (hidpp->battery.ps) in hidpp20_battery_event_1004()
1761 power_supply_changed(hidpp->battery.ps); in hidpp20_battery_event_1004()
1787 struct hidpp_device *hidpp = power_supply_get_drvdata(psy); in hidpp_battery_get_property() local
1792 val->intval = hidpp->battery.status; in hidpp_battery_get_property()
1795 val->intval = hidpp->battery.capacity; in hidpp_battery_get_property()
1798 val->intval = hidpp->battery.level; in hidpp_battery_get_property()
1804 val->intval = hidpp->battery.online; in hidpp_battery_get_property()
1807 if (!strncmp(hidpp->name, "Logitech ", 9)) in hidpp_battery_get_property()
1808 val->strval = hidpp->name + 9; in hidpp_battery_get_property()
1810 val->strval = hidpp->name; in hidpp_battery_get_property()
1816 val->strval = hidpp->hid_dev->uniq; in hidpp_battery_get_property()
1820 val->intval = hidpp->battery.voltage * 1000; in hidpp_battery_get_property()
1823 val->intval = hidpp->battery.charge_type; in hidpp_battery_get_property()
1838 static int hidpp_set_wireless_feature_index(struct hidpp_device *hidpp) in hidpp_set_wireless_feature_index() argument
1843 ret = hidpp_root_get_feature(hidpp, in hidpp_set_wireless_feature_index()
1845 &hidpp->wireless_feature_index, in hidpp_set_wireless_feature_index()
1933 static bool hidpp20_get_adc_measurement_1f20(struct hidpp_device *hidpp, in hidpp20_get_adc_measurement_1f20() argument
1943 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp20_get_adc_measurement_1f20()
1948 hid_dbg(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_get_adc_measurement_1f20()
1957 static int hidpp20_query_adc_measurement_info_1f20(struct hidpp_device *hidpp) in hidpp20_query_adc_measurement_info_1f20() argument
1961 if (hidpp->battery.adc_measurement_feature_index == 0xff) { in hidpp20_query_adc_measurement_info_1f20()
1964 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_ADC_MEASUREMENT, in hidpp20_query_adc_measurement_info_1f20()
1965 &hidpp->battery.adc_measurement_feature_index, in hidpp20_query_adc_measurement_info_1f20()
1970 hidpp->capabilities |= HIDPP_CAPABILITY_ADC_MEASUREMENT; in hidpp20_query_adc_measurement_info_1f20()
1973 hidpp->battery.online = hidpp20_get_adc_measurement_1f20(hidpp, in hidpp20_query_adc_measurement_info_1f20()
1974 hidpp->battery.adc_measurement_feature_index, in hidpp20_query_adc_measurement_info_1f20()
1975 &hidpp->battery.status, in hidpp20_query_adc_measurement_info_1f20()
1976 &hidpp->battery.voltage); in hidpp20_query_adc_measurement_info_1f20()
1977 hidpp->battery.capacity = hidpp20_map_adc_measurement_1f20_capacity(hidpp->hid_dev, in hidpp20_query_adc_measurement_info_1f20()
1978 hidpp->battery.voltage); in hidpp20_query_adc_measurement_info_1f20()
1979 hidpp_update_usb_wireless_status(hidpp); in hidpp20_query_adc_measurement_info_1f20()
1984 static int hidpp20_adc_measurement_event_1f20(struct hidpp_device *hidpp, in hidpp20_adc_measurement_event_1f20() argument
1990 if (report->fap.feature_index != hidpp->battery.adc_measurement_feature_index || in hidpp20_adc_measurement_event_1f20()
1996 hidpp->battery.online = status != POWER_SUPPLY_STATUS_UNKNOWN; in hidpp20_adc_measurement_event_1f20()
1998 if (voltage != hidpp->battery.voltage || status != hidpp->battery.status) { in hidpp20_adc_measurement_event_1f20()
1999 hidpp->battery.status = status; in hidpp20_adc_measurement_event_1f20()
2000 hidpp->battery.voltage = voltage; in hidpp20_adc_measurement_event_1f20()
2001 hidpp->battery.capacity = hidpp20_map_adc_measurement_1f20_capacity(hidpp->hid_dev, voltage); in hidpp20_adc_measurement_event_1f20()
2002 if (hidpp->battery.ps) in hidpp20_adc_measurement_event_1f20()
2003 power_supply_changed(hidpp->battery.ps); in hidpp20_adc_measurement_event_1f20()
2004 hidpp_update_usb_wireless_status(hidpp); in hidpp20_adc_measurement_event_1f20()
2017 static int hidpp_hrs_set_highres_scrolling_mode(struct hidpp_device *hidpp, in hidpp_hrs_set_highres_scrolling_mode() argument
2026 ret = hidpp_root_get_feature(hidpp, in hidpp_hrs_set_highres_scrolling_mode()
2034 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_hrs_set_highres_scrolling_mode()
2052 static int hidpp_hrw_get_wheel_capability(struct hidpp_device *hidpp, in hidpp_hrw_get_wheel_capability() argument
2060 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_HIRES_WHEEL, in hidpp_hrw_get_wheel_capability()
2065 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_hrw_get_wheel_capability()
2074 hid_warn(hidpp->hid_dev, in hidpp_hrw_get_wheel_capability()
2079 static int hidpp_hrw_set_wheel_mode(struct hidpp_device *hidpp, bool invert, in hidpp_hrw_set_wheel_mode() argument
2088 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_HIRES_WHEEL, in hidpp_hrw_set_wheel_mode()
2097 return hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_hrw_set_wheel_mode()
2114 static int hidpp_solar_request_battery_event(struct hidpp_device *hidpp) in hidpp_solar_request_battery_event() argument
2121 if (hidpp->battery.feature_index == 0xff) { in hidpp_solar_request_battery_event()
2122 ret = hidpp_root_get_feature(hidpp, in hidpp_solar_request_battery_event()
2124 &hidpp->battery.solar_feature_index, in hidpp_solar_request_battery_event()
2130 ret = hidpp_send_fap_command_sync(hidpp, in hidpp_solar_request_battery_event()
2131 hidpp->battery.solar_feature_index, in hidpp_solar_request_battery_event()
2135 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_solar_request_battery_event()
2142 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_MILEAGE; in hidpp_solar_request_battery_event()
2147 static int hidpp_solar_battery_event(struct hidpp_device *hidpp, in hidpp_solar_battery_event() argument
2157 if (report->fap.feature_index != hidpp->battery.solar_feature_index || in hidpp_solar_battery_event()
2175 if (capacity < hidpp->battery.capacity) in hidpp_solar_battery_event()
2185 hidpp->battery.online = true; in hidpp_solar_battery_event()
2186 if (capacity != hidpp->battery.capacity || in hidpp_solar_battery_event()
2187 status != hidpp->battery.status) { in hidpp_solar_battery_event()
2188 hidpp->battery.capacity = capacity; in hidpp_solar_battery_event()
2189 hidpp->battery.status = status; in hidpp_solar_battery_event()
2190 if (hidpp->battery.ps) in hidpp_solar_battery_event()
2191 power_supply_changed(hidpp->battery.ps); in hidpp_solar_battery_event()
2216 static int hidpp_touchpad_fw_items_set(struct hidpp_device *hidpp, in hidpp_touchpad_fw_items_set() argument
2224 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_touchpad_fw_items_set()
2228 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_touchpad_fw_items_set()
2287 static int hidpp_touchpad_get_raw_info(struct hidpp_device *hidpp, in hidpp_touchpad_get_raw_info() argument
2294 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_touchpad_get_raw_info()
2298 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_touchpad_get_raw_info()
2411 struct hidpp_device *hidpp; member
2503 ret = hidpp_send_fap_command_sync(data->hidpp, data->feature_index, in hidpp_ff_work_handler()
2507 hid_err(data->hidpp->hid_dev, "Failed to send command to device!\n"); in hidpp_ff_work_handler()
2569 …hid_warn(data->hidpp->hid_dev, "Force feedback command queue contains %d commands, causing substan… in hidpp_ff_queue_work()
2628 …hid_err(data->hidpp->hid_dev, "Unexpected periodic waveform type %i!\n", effect->u.periodic.wavefo… in hidpp_ff_upload_effect()
2713 hid_err(data->hidpp->hid_dev, "Unexpected force type %i!\n", effect->type); in hidpp_ff_upload_effect()
2813 struct hid_device *hid = data->hidpp->hid_dev; in hidpp_ff_destroy()
2822 static int hidpp_ff_init(struct hidpp_device *hidpp, in hidpp_ff_init() argument
2825 struct hid_device *hid = hidpp->hid_dev; in hidpp_ff_init()
2888 data->hidpp = hidpp; in hidpp_ff_init()
2904 error = device_create_file(&(hidpp->hid_dev->dev), &dev_attr_range); in hidpp_ff_init()
2906 hid_warn(hidpp->hid_dev, "Unable to create sysfs interface for \"range\", errno %d!\n", error); in hidpp_ff_init()
2946 static void wtp_populate_input(struct hidpp_device *hidpp, in wtp_populate_input() argument
2949 struct wtp_data *wd = hidpp->private_data; in wtp_populate_input()
2966 if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS) in wtp_populate_input()
2975 static void wtp_touch_event(struct hidpp_device *hidpp, in wtp_touch_event() argument
2978 struct wtp_data *wd = hidpp->private_data; in wtp_touch_event()
2985 slot = input_mt_get_slot_by_key(hidpp->input, touch_report->finger_id); in wtp_touch_event()
2987 input_mt_slot(hidpp->input, slot); in wtp_touch_event()
2988 input_mt_report_slot_state(hidpp->input, MT_TOOL_FINGER, in wtp_touch_event()
2991 input_event(hidpp->input, EV_ABS, ABS_MT_POSITION_X, in wtp_touch_event()
2993 input_event(hidpp->input, EV_ABS, ABS_MT_POSITION_Y, in wtp_touch_event()
2996 input_event(hidpp->input, EV_ABS, ABS_MT_PRESSURE, in wtp_touch_event()
3001 static void wtp_send_raw_xy_event(struct hidpp_device *hidpp, in wtp_send_raw_xy_event() argument
3007 wtp_touch_event(hidpp, &(raw->fingers[i])); in wtp_send_raw_xy_event()
3010 !(hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS)) in wtp_send_raw_xy_event()
3011 input_event(hidpp->input, EV_KEY, BTN_LEFT, raw->button); in wtp_send_raw_xy_event()
3014 input_mt_sync_frame(hidpp->input); in wtp_send_raw_xy_event()
3015 input_sync(hidpp->input); in wtp_send_raw_xy_event()
3019 static int wtp_mouse_raw_xy_event(struct hidpp_device *hidpp, u8 *data) in wtp_mouse_raw_xy_event() argument
3021 struct wtp_data *wd = hidpp->private_data; in wtp_mouse_raw_xy_event()
3053 wtp_send_raw_xy_event(hidpp, &raw); in wtp_mouse_raw_xy_event()
3060 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in wtp_raw_event() local
3061 struct wtp_data *wd = hidpp->private_data; in wtp_raw_event()
3065 if (!wd || !hidpp->input) in wtp_raw_event()
3075 if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS) { in wtp_raw_event()
3076 input_event(hidpp->input, EV_KEY, BTN_LEFT, in wtp_raw_event()
3078 input_event(hidpp->input, EV_KEY, BTN_RIGHT, in wtp_raw_event()
3080 input_sync(hidpp->input); in wtp_raw_event()
3085 return wtp_mouse_raw_xy_event(hidpp, &data[7]); in wtp_raw_event()
3092 hidpp_touchpad_raw_xy_event(hidpp, data + 4, &raw); in wtp_raw_event()
3094 wtp_send_raw_xy_event(hidpp, &raw); in wtp_raw_event()
3101 static int wtp_get_config(struct hidpp_device *hidpp) in wtp_get_config() argument
3103 struct wtp_data *wd = hidpp->private_data; in wtp_get_config()
3108 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_TOUCHPAD_RAW_XY, in wtp_get_config()
3114 ret = hidpp_touchpad_get_raw_info(hidpp, wd->mt_feature_index, in wtp_get_config()
3132 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in wtp_allocate() local
3140 hidpp->private_data = wd; in wtp_allocate()
3147 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in wtp_connect() local
3148 struct wtp_data *wd = hidpp->private_data; in wtp_connect()
3152 ret = wtp_get_config(hidpp); in wtp_connect()
3159 return hidpp_touchpad_set_raw_report_state(hidpp, wd->mt_feature_index, in wtp_connect()
3227 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in m560_raw_event() local
3230 if (!hidpp->input) { in m560_raw_event()
3257 input_report_key(hidpp->input, BTN_MIDDLE, 1); in m560_raw_event()
3260 input_report_key(hidpp->input, BTN_FORWARD, 1); in m560_raw_event()
3263 input_report_key(hidpp->input, BTN_BACK, 1); in m560_raw_event()
3266 input_report_key(hidpp->input, BTN_BACK, 0); in m560_raw_event()
3267 input_report_key(hidpp->input, BTN_FORWARD, 0); in m560_raw_event()
3268 input_report_key(hidpp->input, BTN_MIDDLE, 0); in m560_raw_event()
3274 input_sync(hidpp->input); in m560_raw_event()
3288 input_report_key(hidpp->input, BTN_LEFT, in m560_raw_event()
3290 input_report_key(hidpp->input, BTN_RIGHT, in m560_raw_event()
3294 input_report_rel(hidpp->input, REL_HWHEEL, -1); in m560_raw_event()
3295 input_report_rel(hidpp->input, REL_HWHEEL_HI_RES, in m560_raw_event()
3298 input_report_rel(hidpp->input, REL_HWHEEL, 1); in m560_raw_event()
3299 input_report_rel(hidpp->input, REL_HWHEEL_HI_RES, in m560_raw_event()
3304 input_report_rel(hidpp->input, REL_X, v); in m560_raw_event()
3307 input_report_rel(hidpp->input, REL_Y, v); in m560_raw_event()
3311 hidpp_scroll_counter_handle_scroll(hidpp->input, in m560_raw_event()
3312 &hidpp->vertical_wheel_counter, v); in m560_raw_event()
3314 input_sync(hidpp->input); in m560_raw_event()
3320 static void m560_populate_input(struct hidpp_device *hidpp, in m560_populate_input() argument
3364 static int k400_disable_tap_to_click(struct hidpp_device *hidpp) in k400_disable_tap_to_click() argument
3366 struct k400_private_data *k400 = hidpp->private_data; in k400_disable_tap_to_click()
3372 ret = hidpp_root_get_feature(hidpp, in k400_disable_tap_to_click()
3380 ret = hidpp_touchpad_fw_items_set(hidpp, k400->feature_index, &items); in k400_disable_tap_to_click()
3389 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in k400_allocate() local
3397 hidpp->private_data = k400; in k400_allocate()
3404 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in k400_connect() local
3409 return k400_disable_tap_to_click(hidpp); in k400_connect()
3418 static int g920_ff_set_autocenter(struct hidpp_device *hidpp, in g920_ff_set_autocenter() argument
3430 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_ff_set_autocenter()
3435 hid_warn(hidpp->hid_dev, "Failed to autocenter device!\n"); in g920_ff_set_autocenter()
3442 static int g920_get_config(struct hidpp_device *hidpp, in g920_get_config() argument
3452 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_G920_FORCE_FEEDBACK, in g920_get_config()
3458 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_get_config()
3465 hid_err(hidpp->hid_dev, in g920_get_config()
3473 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_get_config()
3478 hid_warn(hidpp->hid_dev, "Failed to reset all forces!\n"); in g920_get_config()
3480 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_get_config()
3485 hid_warn(hidpp->hid_dev, in g920_get_config()
3492 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_get_config()
3497 hid_warn(hidpp->hid_dev, in g920_get_config()
3504 return g920_ff_set_autocenter(hidpp, data); in g920_get_config()
3530 static int hidpp10_wheel_connect(struct hidpp_device *hidpp) in hidpp10_wheel_connect() argument
3532 return hidpp10_set_register(hidpp, HIDPP_REG_ENABLE_REPORTS, 0, in hidpp10_wheel_connect()
3537 static int hidpp10_wheel_raw_event(struct hidpp_device *hidpp, in hidpp10_wheel_raw_event() argument
3542 if (!hidpp->input) in hidpp10_wheel_raw_event()
3554 input_report_rel(hidpp->input, REL_WHEEL, value); in hidpp10_wheel_raw_event()
3555 input_report_rel(hidpp->input, REL_WHEEL_HI_RES, value * 120); in hidpp10_wheel_raw_event()
3556 input_report_rel(hidpp->input, REL_HWHEEL, hvalue); in hidpp10_wheel_raw_event()
3557 input_report_rel(hidpp->input, REL_HWHEEL_HI_RES, hvalue * 120); in hidpp10_wheel_raw_event()
3558 input_sync(hidpp->input); in hidpp10_wheel_raw_event()
3563 static void hidpp10_wheel_populate_input(struct hidpp_device *hidpp, in hidpp10_wheel_populate_input() argument
3576 static int hidpp10_extra_mouse_buttons_connect(struct hidpp_device *hidpp) in hidpp10_extra_mouse_buttons_connect() argument
3578 return hidpp10_set_register(hidpp, HIDPP_REG_ENABLE_REPORTS, 0, in hidpp10_extra_mouse_buttons_connect()
3583 static int hidpp10_extra_mouse_buttons_raw_event(struct hidpp_device *hidpp, in hidpp10_extra_mouse_buttons_raw_event() argument
3588 if (!hidpp->input) in hidpp10_extra_mouse_buttons_raw_event()
3605 input_report_key(hidpp->input, BTN_MOUSE + i, in hidpp10_extra_mouse_buttons_raw_event()
3610 input_report_key(hidpp->input, BTN_MISC + i, in hidpp10_extra_mouse_buttons_raw_event()
3613 input_sync(hidpp->input); in hidpp10_extra_mouse_buttons_raw_event()
3618 struct hidpp_device *hidpp, struct input_dev *input_dev) in hidpp10_extra_mouse_buttons_populate_input() argument
3636 static u8 *hidpp10_consumer_keys_report_fixup(struct hidpp_device *hidpp, in hidpp10_consumer_keys_report_fixup() argument
3664 static int hidpp10_consumer_keys_connect(struct hidpp_device *hidpp) in hidpp10_consumer_keys_connect() argument
3666 return hidpp10_set_register(hidpp, HIDPP_REG_ENABLE_REPORTS, 0, in hidpp10_consumer_keys_connect()
3671 static int hidpp10_consumer_keys_raw_event(struct hidpp_device *hidpp, in hidpp10_consumer_keys_raw_event() argument
3690 hid_report_raw_event(hidpp->hid_dev, HID_INPUT_REPORT, in hidpp10_consumer_keys_raw_event()
3700 static int hi_res_scroll_enable(struct hidpp_device *hidpp) in hi_res_scroll_enable() argument
3705 if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_HI_RES_WHEEL) { in hi_res_scroll_enable()
3706 ret = hidpp_hrw_set_wheel_mode(hidpp, false, true, false); in hi_res_scroll_enable()
3708 ret = hidpp_hrw_get_wheel_capability(hidpp, &multiplier); in hi_res_scroll_enable()
3709 } else if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_HI_RES_SCROLL) { in hi_res_scroll_enable()
3710 ret = hidpp_hrs_set_highres_scrolling_mode(hidpp, true, in hi_res_scroll_enable()
3713 ret = hidpp10_enable_scrolling_acceleration(hidpp); in hi_res_scroll_enable()
3717 hid_dbg(hidpp->hid_dev, in hi_res_scroll_enable()
3723 hid_dbg(hidpp->hid_dev, in hi_res_scroll_enable()
3728 hidpp->vertical_wheel_counter.wheel_multiplier = multiplier; in hi_res_scroll_enable()
3729 hid_dbg(hidpp->hid_dev, "wheel multiplier = %d\n", multiplier); in hi_res_scroll_enable()
3733 static int hidpp_initialize_hires_scroll(struct hidpp_device *hidpp) in hidpp_initialize_hires_scroll() argument
3738 capabilities = hidpp->capabilities; in hidpp_initialize_hires_scroll()
3740 if (hidpp->protocol_major >= 2) { in hidpp_initialize_hires_scroll()
3744 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_HIRES_WHEEL, in hidpp_initialize_hires_scroll()
3747 hidpp->capabilities |= HIDPP_CAPABILITY_HIDPP20_HI_RES_WHEEL; in hidpp_initialize_hires_scroll()
3748 hid_dbg(hidpp->hid_dev, "Detected HID++ 2.0 hi-res scroll wheel\n"); in hidpp_initialize_hires_scroll()
3751 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_HI_RESOLUTION_SCROLLING, in hidpp_initialize_hires_scroll()
3754 hidpp->capabilities |= HIDPP_CAPABILITY_HIDPP20_HI_RES_SCROLL; in hidpp_initialize_hires_scroll()
3755 hid_dbg(hidpp->hid_dev, "Detected HID++ 2.0 hi-res scrolling\n"); in hidpp_initialize_hires_scroll()
3759 if (hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL_1P0) { in hidpp_initialize_hires_scroll()
3760 hidpp->capabilities |= HIDPP_CAPABILITY_HIDPP10_FAST_SCROLL; in hidpp_initialize_hires_scroll()
3761 hid_dbg(hidpp->hid_dev, "Detected HID++ 1.0 fast scroll\n"); in hidpp_initialize_hires_scroll()
3765 if (hidpp->capabilities == capabilities) in hidpp_initialize_hires_scroll()
3766 hid_dbg(hidpp->hid_dev, "Did not detect HID++ hi-res scrolling hardware support\n"); in hidpp_initialize_hires_scroll()
3777 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_report_fixup() local
3779 if (!hidpp) in hidpp_report_fixup()
3784 (hidpp->quirks & HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS)) in hidpp_report_fixup()
3785 rdesc = hidpp10_consumer_keys_report_fixup(hidpp, rdesc, rsize); in hidpp_report_fixup()
3794 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_input_mapping() local
3796 if (!hidpp) in hidpp_input_mapping()
3799 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) in hidpp_input_mapping()
3801 else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560 && in hidpp_input_mapping()
3815 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_input_mapped() local
3817 if (!hidpp) in hidpp_input_mapped()
3821 if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) { in hidpp_input_mapped()
3833 static void hidpp_populate_input(struct hidpp_device *hidpp, in hidpp_populate_input() argument
3836 hidpp->input = input; in hidpp_populate_input()
3838 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) in hidpp_populate_input()
3839 wtp_populate_input(hidpp, input); in hidpp_populate_input()
3840 else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) in hidpp_populate_input()
3841 m560_populate_input(hidpp, input); in hidpp_populate_input()
3843 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_WHEELS) in hidpp_populate_input()
3844 hidpp10_wheel_populate_input(hidpp, input); in hidpp_populate_input()
3846 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_EXTRA_MOUSE_BTNS) in hidpp_populate_input()
3847 hidpp10_extra_mouse_buttons_populate_input(hidpp, input); in hidpp_populate_input()
3853 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_input_configured() local
3856 if (!hidpp) in hidpp_input_configured()
3859 hidpp_populate_input(hidpp, input); in hidpp_input_configured()
3864 static int hidpp_raw_hidpp_event(struct hidpp_device *hidpp, u8 *data, in hidpp_raw_hidpp_event() argument
3867 struct hidpp_report *question = hidpp->send_receive_buf; in hidpp_raw_hidpp_event()
3868 struct hidpp_report *answer = hidpp->send_receive_buf; in hidpp_raw_hidpp_event()
3876 if (unlikely(mutex_is_locked(&hidpp->send_mutex))) { in hidpp_raw_hidpp_event()
3884 hidpp->answer_available = true; in hidpp_raw_hidpp_event()
3885 wake_up(&hidpp->wait); in hidpp_raw_hidpp_event()
3896 if (unlikely(hidpp_report_is_connect_event(hidpp, report))) { in hidpp_raw_hidpp_event()
3897 atomic_set(&hidpp->connected, in hidpp_raw_hidpp_event()
3899 if (schedule_work(&hidpp->work) == 0) in hidpp_raw_hidpp_event()
3904 if (hidpp->hid_dev->group == HID_GROUP_LOGITECH_27MHZ_DEVICE && in hidpp_raw_hidpp_event()
3908 dev_err_ratelimited(&hidpp->hid_dev->dev, in hidpp_raw_hidpp_event()
3910 dev_err_ratelimited(&hidpp->hid_dev->dev, in hidpp_raw_hidpp_event()
3914 if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_BATTERY) { in hidpp_raw_hidpp_event()
3915 ret = hidpp20_battery_event_1000(hidpp, data, size); in hidpp_raw_hidpp_event()
3918 ret = hidpp20_battery_event_1004(hidpp, data, size); in hidpp_raw_hidpp_event()
3921 ret = hidpp_solar_battery_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3924 ret = hidpp20_battery_voltage_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3927 ret = hidpp20_adc_measurement_event_1f20(hidpp, data, size); in hidpp_raw_hidpp_event()
3932 if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP10_BATTERY) { in hidpp_raw_hidpp_event()
3933 ret = hidpp10_battery_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3938 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_WHEELS) { in hidpp_raw_hidpp_event()
3939 ret = hidpp10_wheel_raw_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3944 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_EXTRA_MOUSE_BTNS) { in hidpp_raw_hidpp_event()
3945 ret = hidpp10_extra_mouse_buttons_raw_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3950 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS) { in hidpp_raw_hidpp_event()
3951 ret = hidpp10_consumer_keys_raw_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3962 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_raw_event() local
3965 if (!hidpp) in hidpp_raw_event()
3971 if (size != hidpp->very_long_report_length) { in hidpp_raw_event()
3976 ret = hidpp_raw_hidpp_event(hidpp, data, size); in hidpp_raw_event()
3984 ret = hidpp_raw_hidpp_event(hidpp, data, size); in hidpp_raw_event()
3992 ret = hidpp_raw_hidpp_event(hidpp, data, size); in hidpp_raw_event()
4001 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) in hidpp_raw_event()
4003 else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) in hidpp_raw_event()
4015 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_event() local
4018 if (!hidpp) in hidpp_event()
4021 counter = &hidpp->vertical_wheel_counter; in hidpp_event()
4027 if (!(hidpp->capabilities & HIDPP_CAPABILITY_HI_RES_SCROLL) in hidpp_event()
4028 || value == 0 || hidpp->input == NULL in hidpp_event()
4032 hidpp_scroll_counter_handle_scroll(hidpp->input, counter, value); in hidpp_event()
4036 static int hidpp_initialize_battery(struct hidpp_device *hidpp) in hidpp_initialize_battery() argument
4039 struct power_supply_config cfg = { .drv_data = hidpp }; in hidpp_initialize_battery()
4040 struct power_supply_desc *desc = &hidpp->battery.desc; in hidpp_initialize_battery()
4047 if (hidpp->battery.ps) in hidpp_initialize_battery()
4050 hidpp->battery.feature_index = 0xff; in hidpp_initialize_battery()
4051 hidpp->battery.solar_feature_index = 0xff; in hidpp_initialize_battery()
4052 hidpp->battery.voltage_feature_index = 0xff; in hidpp_initialize_battery()
4053 hidpp->battery.adc_measurement_feature_index = 0xff; in hidpp_initialize_battery()
4055 if (hidpp->protocol_major >= 2) { in hidpp_initialize_battery()
4056 if (hidpp->quirks & HIDPP_QUIRK_CLASS_K750) in hidpp_initialize_battery()
4057 ret = hidpp_solar_request_battery_event(hidpp); in hidpp_initialize_battery()
4062 ret = hidpp20_query_battery_info_1000(hidpp); in hidpp_initialize_battery()
4064 ret = hidpp20_query_battery_info_1004(hidpp); in hidpp_initialize_battery()
4066 ret = hidpp20_query_battery_voltage_info(hidpp); in hidpp_initialize_battery()
4068 ret = hidpp20_query_adc_measurement_info_1f20(hidpp); in hidpp_initialize_battery()
4073 hidpp->capabilities |= HIDPP_CAPABILITY_HIDPP20_BATTERY; in hidpp_initialize_battery()
4075 ret = hidpp10_query_battery_status(hidpp); in hidpp_initialize_battery()
4077 ret = hidpp10_query_battery_mileage(hidpp); in hidpp_initialize_battery()
4080 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_MILEAGE; in hidpp_initialize_battery()
4082 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS; in hidpp_initialize_battery()
4084 hidpp->capabilities |= HIDPP_CAPABILITY_HIDPP10_BATTERY; in hidpp_initialize_battery()
4087 battery_props = devm_kmemdup(&hidpp->hid_dev->dev, in hidpp_initialize_battery()
4096 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_MILEAGE || in hidpp_initialize_battery()
4097 hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_PERCENTAGE || in hidpp_initialize_battery()
4098 hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_VOLTAGE || in hidpp_initialize_battery()
4099 hidpp->capabilities & HIDPP_CAPABILITY_ADC_MEASUREMENT) in hidpp_initialize_battery()
4103 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS) in hidpp_initialize_battery()
4107 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_VOLTAGE || in hidpp_initialize_battery()
4108 hidpp->capabilities & HIDPP_CAPABILITY_ADC_MEASUREMENT) in hidpp_initialize_battery()
4112 battery = &hidpp->battery; in hidpp_initialize_battery()
4123 battery->ps = devm_power_supply_register(&hidpp->hid_dev->dev, in hidpp_initialize_battery()
4129 power_supply_powers(battery->ps, &hidpp->hid_dev->dev); in hidpp_initialize_battery()
4136 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_overwrite_name() local
4139 if (hidpp->protocol_major < 2) in hidpp_overwrite_name()
4142 name = hidpp_get_device_name(hidpp); in hidpp_overwrite_name()
4171 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_allocate_input() local
4180 input_dev->name = hidpp->name; in hidpp_allocate_input()
4192 static void hidpp_connect_event(struct hidpp_device *hidpp) in hidpp_connect_event() argument
4194 struct hid_device *hdev = hidpp->hid_dev; in hidpp_connect_event()
4196 bool connected = atomic_read(&hidpp->connected); in hidpp_connect_event()
4201 if (hidpp->battery.ps) { in hidpp_connect_event()
4202 hidpp->battery.online = false; in hidpp_connect_event()
4203 hidpp->battery.status = POWER_SUPPLY_STATUS_UNKNOWN; in hidpp_connect_event()
4204 hidpp->battery.level = POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN; in hidpp_connect_event()
4205 power_supply_changed(hidpp->battery.ps); in hidpp_connect_event()
4210 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) { in hidpp_connect_event()
4214 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) { in hidpp_connect_event()
4218 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_K400) { in hidpp_connect_event()
4224 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_WHEELS) { in hidpp_connect_event()
4225 ret = hidpp10_wheel_connect(hidpp); in hidpp_connect_event()
4230 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_EXTRA_MOUSE_BTNS) { in hidpp_connect_event()
4231 ret = hidpp10_extra_mouse_buttons_connect(hidpp); in hidpp_connect_event()
4236 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS) { in hidpp_connect_event()
4237 ret = hidpp10_consumer_keys_connect(hidpp); in hidpp_connect_event()
4244 if (!hidpp->protocol_major) { in hidpp_connect_event()
4245 ret = hidpp_root_get_protocol_version(hidpp); in hidpp_connect_event()
4252 if (hidpp->name == hdev->name && hidpp->protocol_major >= 2) { in hidpp_connect_event()
4253 name = hidpp_get_device_name(hidpp); in hidpp_connect_event()
4261 hidpp->name = devm_name; in hidpp_connect_event()
4265 hidpp_initialize_battery(hidpp); in hidpp_connect_event()
4266 if (!hid_is_usb(hidpp->hid_dev)) in hidpp_connect_event()
4267 hidpp_initialize_hires_scroll(hidpp); in hidpp_connect_event()
4270 if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP10_BATTERY) { in hidpp_connect_event()
4271 hidpp10_enable_battery_reporting(hidpp); in hidpp_connect_event()
4272 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_MILEAGE) in hidpp_connect_event()
4273 hidpp10_query_battery_mileage(hidpp); in hidpp_connect_event()
4275 hidpp10_query_battery_status(hidpp); in hidpp_connect_event()
4276 } else if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_BATTERY) { in hidpp_connect_event()
4277 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_VOLTAGE) in hidpp_connect_event()
4278 hidpp20_query_battery_voltage_info(hidpp); in hidpp_connect_event()
4279 else if (hidpp->capabilities & HIDPP_CAPABILITY_UNIFIED_BATTERY) in hidpp_connect_event()
4280 hidpp20_query_battery_info_1004(hidpp); in hidpp_connect_event()
4281 else if (hidpp->capabilities & HIDPP_CAPABILITY_ADC_MEASUREMENT) in hidpp_connect_event()
4282 hidpp20_query_adc_measurement_info_1f20(hidpp); in hidpp_connect_event()
4284 hidpp20_query_battery_info_1000(hidpp); in hidpp_connect_event()
4286 if (hidpp->battery.ps) in hidpp_connect_event()
4287 power_supply_changed(hidpp->battery.ps); in hidpp_connect_event()
4289 if (hidpp->capabilities & HIDPP_CAPABILITY_HI_RES_SCROLL) in hidpp_connect_event()
4290 hi_res_scroll_enable(hidpp); in hidpp_connect_event()
4292 if (!(hidpp->quirks & HIDPP_QUIRK_DELAYED_INIT) || hidpp->delayed_input) in hidpp_connect_event()
4302 hidpp_populate_input(hidpp, input); in hidpp_connect_event()
4310 hidpp->delayed_input = input; in hidpp_connect_event()
4339 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_validate_device() local
4369 hidpp->very_long_report_length = report_length; in hidpp_validate_device()
4392 struct hidpp_device *hidpp; in hidpp_probe() local
4400 hidpp = devm_kzalloc(&hdev->dev, sizeof(*hidpp), GFP_KERNEL); in hidpp_probe()
4401 if (!hidpp) in hidpp_probe()
4404 hidpp->hid_dev = hdev; in hidpp_probe()
4405 hidpp->name = hdev->name; in hidpp_probe()
4406 hidpp->quirks = id->driver_data; in hidpp_probe()
4407 hid_set_drvdata(hdev, hidpp); in hidpp_probe()
4418 hidpp->supported_reports = hidpp_validate_device(hdev); in hidpp_probe()
4420 if (!hidpp->supported_reports) { in hidpp_probe()
4422 devm_kfree(&hdev->dev, hidpp); in hidpp_probe()
4427 hidpp->quirks |= HIDPP_QUIRK_UNIFYING; in hidpp_probe()
4431 hidpp->quirks |= HIDPP_QUIRK_HIDPP_WHEELS | in hidpp_probe()
4436 hidpp->quirks |= HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS; in hidpp_probe()
4438 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) { in hidpp_probe()
4442 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_K400) { in hidpp_probe()
4448 if (hidpp->quirks & HIDPP_QUIRK_DELAYED_INIT || in hidpp_probe()
4449 hidpp->quirks & HIDPP_QUIRK_UNIFYING) in hidpp_probe()
4452 INIT_WORK(&hidpp->work, delayed_work_cb); in hidpp_probe()
4453 mutex_init(&hidpp->send_mutex); in hidpp_probe()
4454 init_waitqueue_head(&hidpp->wait); in hidpp_probe()
4482 if (hidpp->quirks & HIDPP_QUIRK_UNIFYING) in hidpp_probe()
4483 hidpp_unifying_init(hidpp); in hidpp_probe()
4484 else if (hid_is_usb(hidpp->hid_dev)) in hidpp_probe()
4485 hidpp_serial_init(hidpp); in hidpp_probe()
4487 connected = hidpp_root_get_protocol_version(hidpp) == 0; in hidpp_probe()
4488 atomic_set(&hidpp->connected, connected); in hidpp_probe()
4489 if (!(hidpp->quirks & HIDPP_QUIRK_UNIFYING)) { in hidpp_probe()
4499 if (connected && hidpp->protocol_major >= 2) { in hidpp_probe()
4500 ret = hidpp_set_wireless_feature_index(hidpp); in hidpp_probe()
4502 hidpp->wireless_feature_index = 0; in hidpp_probe()
4508 if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)) { in hidpp_probe()
4509 ret = wtp_get_config(hidpp); in hidpp_probe()
4512 } else if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_G920)) { in hidpp_probe()
4513 ret = g920_get_config(hidpp, &data); in hidpp_probe()
4518 schedule_work(&hidpp->work); in hidpp_probe()
4519 flush_work(&hidpp->work); in hidpp_probe()
4527 if (hidpp->quirks & HIDPP_QUIRK_DELAYED_INIT) in hidpp_probe()
4538 if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) { in hidpp_probe()
4539 ret = hidpp_ff_init(hidpp, &data); in hidpp_probe()
4541 hid_warn(hidpp->hid_dev, in hidpp_probe()
4554 cancel_work_sync(&hidpp->work); in hidpp_probe()
4555 mutex_destroy(&hidpp->send_mutex); in hidpp_probe()
4561 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_remove() local
4563 if (!hidpp) in hidpp_remove()
4569 cancel_work_sync(&hidpp->work); in hidpp_remove()
4570 mutex_destroy(&hidpp->send_mutex); in hidpp_remove()