Lines Matching refs:hidpp

232 	struct hidpp_device *hidpp = hid_get_drvdata(hdev);  in __hidpp_send_report()  local
243 fields_count = hidpp->very_long_report_length; in __hidpp_send_report()
255 if (hidpp->quirks & HIDPP_QUIRK_FORCE_OUTPUT_REPORTS) { in __hidpp_send_report()
274 static int hidpp_send_message_sync(struct hidpp_device *hidpp, in hidpp_send_message_sync() argument
280 mutex_lock(&hidpp->send_mutex); in hidpp_send_message_sync()
282 hidpp->send_receive_buf = response; in hidpp_send_message_sync()
283 hidpp->answer_available = false; in hidpp_send_message_sync()
291 ret = __hidpp_send_report(hidpp->hid_dev, message); in hidpp_send_message_sync()
299 if (!wait_event_timeout(hidpp->wait, hidpp->answer_available, in hidpp_send_message_sync()
322 mutex_unlock(&hidpp->send_mutex); in hidpp_send_message_sync()
327 static int hidpp_send_fap_command_sync(struct hidpp_device *hidpp, in hidpp_send_fap_command_sync() argument
349 ret = hidpp_send_message_sync(hidpp, message, response); in hidpp_send_fap_command_sync()
398 struct hidpp_device *hidpp = container_of(work, struct hidpp_device, in delayed_work_cb() local
400 hidpp_connect_event(hidpp); in delayed_work_cb()
419 static inline bool hidpp_report_is_connect_event(struct hidpp_device *hidpp, in hidpp_report_is_connect_event() argument
422 return (hidpp->wireless_feature_index && in hidpp_report_is_connect_event()
423 (report->fap.feature_index == hidpp->wireless_feature_index)) || in hidpp_report_is_connect_event()
647 static int hidpp10_query_battery_status(struct hidpp_device *hidpp) in hidpp10_query_battery_status() argument
652 ret = hidpp_send_rap_command_sync(hidpp, in hidpp10_query_battery_status()
660 hidpp->battery.level = in hidpp10_query_battery_status()
663 hidpp->battery.status = status; in hidpp10_query_battery_status()
665 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp10_query_battery_status()
699 static int hidpp10_query_battery_mileage(struct hidpp_device *hidpp) in hidpp10_query_battery_mileage() argument
704 ret = hidpp_send_rap_command_sync(hidpp, in hidpp10_query_battery_mileage()
712 hidpp->battery.capacity = response.rap.params[0]; in hidpp10_query_battery_mileage()
714 hidpp->battery.status = status; in hidpp10_query_battery_mileage()
716 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp10_query_battery_mileage()
722 static int hidpp10_battery_event(struct hidpp_device *hidpp, u8 *data, int size) in hidpp10_battery_event() argument
733 capacity = hidpp->battery.capacity; in hidpp10_battery_event()
739 level = hidpp->battery.level; in hidpp10_battery_event()
746 changed = capacity != hidpp->battery.capacity || in hidpp10_battery_event()
747 level != hidpp->battery.level || in hidpp10_battery_event()
748 status != hidpp->battery.status; in hidpp10_battery_event()
751 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp10_battery_event()
755 hidpp->battery.level = level; in hidpp10_battery_event()
756 hidpp->battery.status = status; in hidpp10_battery_event()
757 if (hidpp->battery.ps) in hidpp10_battery_event()
758 power_supply_changed(hidpp->battery.ps); in hidpp10_battery_event()
804 static int hidpp_unifying_get_serial(struct hidpp_device *hidpp, u32 *serial) in hidpp_unifying_get_serial() argument
810 ret = hidpp_send_rap_command_sync(hidpp, in hidpp_unifying_get_serial()
826 static int hidpp_unifying_init(struct hidpp_device *hidpp) in hidpp_unifying_init() argument
828 struct hid_device *hdev = hidpp->hid_dev; in hidpp_unifying_init()
833 ret = hidpp_unifying_get_serial(hidpp, &serial); in hidpp_unifying_init()
841 name = hidpp_unifying_get_name(hidpp); in hidpp_unifying_init()
862 static int hidpp_root_get_feature(struct hidpp_device *hidpp, u16 feature, in hidpp_root_get_feature() argument
869 ret = hidpp_send_fap_command_sync(hidpp, in hidpp_root_get_feature()
885 static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp) in hidpp_root_get_protocol_version() argument
892 ret = hidpp_send_rap_command_sync(hidpp, in hidpp_root_get_protocol_version()
899 hidpp->protocol_major = 1; in hidpp_root_get_protocol_version()
900 hidpp->protocol_minor = 0; in hidpp_root_get_protocol_version()
909 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_root_get_protocol_version()
917 hid_err(hidpp->hid_dev, "%s: ping mismatch 0x%02x != 0x%02x\n", in hidpp_root_get_protocol_version()
922 hidpp->protocol_major = response.rap.params[0]; in hidpp_root_get_protocol_version()
923 hidpp->protocol_minor = response.rap.params[1]; in hidpp_root_get_protocol_version()
926 hid_info(hidpp->hid_dev, "HID++ %u.%u device connected.\n", in hidpp_root_get_protocol_version()
927 hidpp->protocol_major, hidpp->protocol_minor); in hidpp_root_get_protocol_version()
941 static int hidpp_devicenametype_get_count(struct hidpp_device *hidpp, in hidpp_devicenametype_get_count() argument
947 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_devicenametype_get_count()
951 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_devicenametype_get_count()
963 static int hidpp_devicenametype_get_device_name(struct hidpp_device *hidpp, in hidpp_devicenametype_get_device_name() argument
970 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_devicenametype_get_device_name()
975 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_devicenametype_get_device_name()
984 count = hidpp->very_long_report_length - 4; in hidpp_devicenametype_get_device_name()
1005 static char *hidpp_get_device_name(struct hidpp_device *hidpp) in hidpp_get_device_name() argument
1014 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_GET_DEVICE_NAME_TYPE, in hidpp_get_device_name()
1019 ret = hidpp_devicenametype_get_count(hidpp, feature_index, in hidpp_get_device_name()
1029 ret = hidpp_devicenametype_get_device_name(hidpp, in hidpp_get_device_name()
1118 static int hidpp20_batterylevel_get_battery_capacity(struct hidpp_device *hidpp, in hidpp20_batterylevel_get_battery_capacity() argument
1129 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp20_batterylevel_get_battery_capacity()
1136 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_batterylevel_get_battery_capacity()
1150 static int hidpp20_batterylevel_get_battery_info(struct hidpp_device *hidpp, in hidpp20_batterylevel_get_battery_info() argument
1158 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp20_batterylevel_get_battery_info()
1162 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_batterylevel_get_battery_info()
1173 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS; in hidpp20_batterylevel_get_battery_info()
1175 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_MILEAGE; in hidpp20_batterylevel_get_battery_info()
1180 static int hidpp20_query_battery_info_1000(struct hidpp_device *hidpp) in hidpp20_query_battery_info_1000() argument
1186 if (hidpp->battery.feature_index == 0xff) { in hidpp20_query_battery_info_1000()
1187 ret = hidpp_root_get_feature(hidpp, in hidpp20_query_battery_info_1000()
1189 &hidpp->battery.feature_index, in hidpp20_query_battery_info_1000()
1195 ret = hidpp20_batterylevel_get_battery_capacity(hidpp, in hidpp20_query_battery_info_1000()
1196 hidpp->battery.feature_index, in hidpp20_query_battery_info_1000()
1202 ret = hidpp20_batterylevel_get_battery_info(hidpp, in hidpp20_query_battery_info_1000()
1203 hidpp->battery.feature_index); in hidpp20_query_battery_info_1000()
1207 hidpp->battery.status = status; in hidpp20_query_battery_info_1000()
1208 hidpp->battery.capacity = capacity; in hidpp20_query_battery_info_1000()
1209 hidpp->battery.level = level; in hidpp20_query_battery_info_1000()
1211 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp20_query_battery_info_1000()
1217 static int hidpp20_battery_event_1000(struct hidpp_device *hidpp, in hidpp20_battery_event_1000() argument
1224 if (report->fap.feature_index != hidpp->battery.feature_index || in hidpp20_battery_event_1000()
1234 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp20_battery_event_1000()
1237 changed = capacity != hidpp->battery.capacity || in hidpp20_battery_event_1000()
1238 level != hidpp->battery.level || in hidpp20_battery_event_1000()
1239 status != hidpp->battery.status; in hidpp20_battery_event_1000()
1242 hidpp->battery.level = level; in hidpp20_battery_event_1000()
1243 hidpp->battery.capacity = capacity; in hidpp20_battery_event_1000()
1244 hidpp->battery.status = status; in hidpp20_battery_event_1000()
1245 if (hidpp->battery.ps) in hidpp20_battery_event_1000()
1246 power_supply_changed(hidpp->battery.ps); in hidpp20_battery_event_1000()
1305 static int hidpp20_battery_get_battery_voltage(struct hidpp_device *hidpp, in hidpp20_battery_get_battery_voltage() argument
1314 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp20_battery_get_battery_voltage()
1319 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_battery_get_battery_voltage()
1326 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_VOLTAGE; in hidpp20_battery_get_battery_voltage()
1371 static int hidpp20_query_battery_voltage_info(struct hidpp_device *hidpp) in hidpp20_query_battery_voltage_info() argument
1377 if (hidpp->battery.voltage_feature_index == 0xff) { in hidpp20_query_battery_voltage_info()
1378 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_BATTERY_VOLTAGE, in hidpp20_query_battery_voltage_info()
1379 &hidpp->battery.voltage_feature_index, in hidpp20_query_battery_voltage_info()
1385 ret = hidpp20_battery_get_battery_voltage(hidpp, in hidpp20_query_battery_voltage_info()
1386 hidpp->battery.voltage_feature_index, in hidpp20_query_battery_voltage_info()
1392 hidpp->battery.status = status; in hidpp20_query_battery_voltage_info()
1393 hidpp->battery.voltage = voltage; in hidpp20_query_battery_voltage_info()
1394 hidpp->battery.capacity = hidpp20_map_battery_capacity(hidpp->hid_dev, in hidpp20_query_battery_voltage_info()
1396 hidpp->battery.level = level; in hidpp20_query_battery_voltage_info()
1397 hidpp->battery.charge_type = charge_type; in hidpp20_query_battery_voltage_info()
1398 hidpp->battery.online = status != POWER_SUPPLY_STATUS_NOT_CHARGING; in hidpp20_query_battery_voltage_info()
1403 static int hidpp20_battery_voltage_event(struct hidpp_device *hidpp, in hidpp20_battery_voltage_event() argument
1409 if (report->fap.feature_index != hidpp->battery.voltage_feature_index || in hidpp20_battery_voltage_event()
1416 hidpp->battery.online = status != POWER_SUPPLY_STATUS_NOT_CHARGING; in hidpp20_battery_voltage_event()
1418 if (voltage != hidpp->battery.voltage || status != hidpp->battery.status) { in hidpp20_battery_voltage_event()
1419 hidpp->battery.voltage = voltage; in hidpp20_battery_voltage_event()
1420 hidpp->battery.capacity = hidpp20_map_battery_capacity(hidpp->hid_dev, in hidpp20_battery_voltage_event()
1422 hidpp->battery.status = status; in hidpp20_battery_voltage_event()
1423 hidpp->battery.level = level; in hidpp20_battery_voltage_event()
1424 hidpp->battery.charge_type = charge_type; in hidpp20_battery_voltage_event()
1425 if (hidpp->battery.ps) in hidpp20_battery_voltage_event()
1426 power_supply_changed(hidpp->battery.ps); in hidpp20_battery_voltage_event()
1450 static int hidpp20_unifiedbattery_get_capabilities(struct hidpp_device *hidpp, in hidpp20_unifiedbattery_get_capabilities() argument
1457 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS || in hidpp20_unifiedbattery_get_capabilities()
1458 hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_PERCENTAGE) { in hidpp20_unifiedbattery_get_capabilities()
1463 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp20_unifiedbattery_get_capabilities()
1470 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_unifiedbattery_get_capabilities()
1485 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_PERCENTAGE; in hidpp20_unifiedbattery_get_capabilities()
1486 hidpp->battery.supported_levels_1004 = 0; in hidpp20_unifiedbattery_get_capabilities()
1488 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS; in hidpp20_unifiedbattery_get_capabilities()
1489 hidpp->battery.supported_levels_1004 = params[0]; in hidpp20_unifiedbattery_get_capabilities()
1495 static int hidpp20_unifiedbattery_map_status(struct hidpp_device *hidpp, in hidpp20_unifiedbattery_map_status() argument
1514 hid_info(hidpp->hid_dev, "%s: charging error", in hidpp20_unifiedbattery_map_status()
1515 hidpp->name); in hidpp20_unifiedbattery_map_status()
1525 static int hidpp20_unifiedbattery_map_level(struct hidpp_device *hidpp, in hidpp20_unifiedbattery_map_level() argument
1529 battery_level &= hidpp->battery.supported_levels_1004; in hidpp20_unifiedbattery_map_level()
1543 static int hidpp20_unifiedbattery_get_status(struct hidpp_device *hidpp, in hidpp20_unifiedbattery_get_status() argument
1553 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp20_unifiedbattery_get_status()
1560 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_unifiedbattery_get_status()
1568 *status = hidpp20_unifiedbattery_map_status(hidpp, params[2], params[3]); in hidpp20_unifiedbattery_get_status()
1569 *level = hidpp20_unifiedbattery_map_level(hidpp, params[1]); in hidpp20_unifiedbattery_get_status()
1574 static int hidpp20_query_battery_info_1004(struct hidpp_device *hidpp) in hidpp20_query_battery_info_1004() argument
1581 if (hidpp->battery.feature_index == 0xff) { in hidpp20_query_battery_info_1004()
1582 ret = hidpp_root_get_feature(hidpp, in hidpp20_query_battery_info_1004()
1584 &hidpp->battery.feature_index, in hidpp20_query_battery_info_1004()
1590 ret = hidpp20_unifiedbattery_get_capabilities(hidpp, in hidpp20_query_battery_info_1004()
1591 hidpp->battery.feature_index); in hidpp20_query_battery_info_1004()
1595 ret = hidpp20_unifiedbattery_get_status(hidpp, in hidpp20_query_battery_info_1004()
1596 hidpp->battery.feature_index, in hidpp20_query_battery_info_1004()
1603 hidpp->capabilities |= HIDPP_CAPABILITY_UNIFIED_BATTERY; in hidpp20_query_battery_info_1004()
1604 hidpp->battery.capacity = state_of_charge; in hidpp20_query_battery_info_1004()
1605 hidpp->battery.status = status; in hidpp20_query_battery_info_1004()
1606 hidpp->battery.level = level; in hidpp20_query_battery_info_1004()
1607 hidpp->battery.online = true; in hidpp20_query_battery_info_1004()
1612 static int hidpp20_battery_event_1004(struct hidpp_device *hidpp, in hidpp20_battery_event_1004() argument
1620 if (report->fap.feature_index != hidpp->battery.feature_index || in hidpp20_battery_event_1004()
1625 status = hidpp20_unifiedbattery_map_status(hidpp, params[2], params[3]); in hidpp20_battery_event_1004()
1626 level = hidpp20_unifiedbattery_map_level(hidpp, params[1]); in hidpp20_battery_event_1004()
1628 changed = status != hidpp->battery.status || in hidpp20_battery_event_1004()
1629 (state_of_charge != hidpp->battery.capacity && in hidpp20_battery_event_1004()
1630 hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_PERCENTAGE) || in hidpp20_battery_event_1004()
1631 (level != hidpp->battery.level && in hidpp20_battery_event_1004()
1632 hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS); in hidpp20_battery_event_1004()
1635 hidpp->battery.capacity = state_of_charge; in hidpp20_battery_event_1004()
1636 hidpp->battery.status = status; in hidpp20_battery_event_1004()
1637 hidpp->battery.level = level; in hidpp20_battery_event_1004()
1638 if (hidpp->battery.ps) in hidpp20_battery_event_1004()
1639 power_supply_changed(hidpp->battery.ps); in hidpp20_battery_event_1004()
1665 struct hidpp_device *hidpp = power_supply_get_drvdata(psy); in hidpp_battery_get_property() local
1670 val->intval = hidpp->battery.status; in hidpp_battery_get_property()
1673 val->intval = hidpp->battery.capacity; in hidpp_battery_get_property()
1676 val->intval = hidpp->battery.level; in hidpp_battery_get_property()
1682 val->intval = hidpp->battery.online; in hidpp_battery_get_property()
1685 if (!strncmp(hidpp->name, "Logitech ", 9)) in hidpp_battery_get_property()
1686 val->strval = hidpp->name + 9; in hidpp_battery_get_property()
1688 val->strval = hidpp->name; in hidpp_battery_get_property()
1694 val->strval = hidpp->hid_dev->uniq; in hidpp_battery_get_property()
1698 val->intval = hidpp->battery.voltage * 1000; in hidpp_battery_get_property()
1701 val->intval = hidpp->battery.charge_type; in hidpp_battery_get_property()
1716 static int hidpp_set_wireless_feature_index(struct hidpp_device *hidpp) in hidpp_set_wireless_feature_index() argument
1721 ret = hidpp_root_get_feature(hidpp, in hidpp_set_wireless_feature_index()
1723 &hidpp->wireless_feature_index, in hidpp_set_wireless_feature_index()
1737 static int hidpp_hrs_set_highres_scrolling_mode(struct hidpp_device *hidpp, in hidpp_hrs_set_highres_scrolling_mode() argument
1746 ret = hidpp_root_get_feature(hidpp, in hidpp_hrs_set_highres_scrolling_mode()
1754 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_hrs_set_highres_scrolling_mode()
1772 static int hidpp_hrw_get_wheel_capability(struct hidpp_device *hidpp, in hidpp_hrw_get_wheel_capability() argument
1780 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_HIRES_WHEEL, in hidpp_hrw_get_wheel_capability()
1785 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_hrw_get_wheel_capability()
1794 hid_warn(hidpp->hid_dev, in hidpp_hrw_get_wheel_capability()
1799 static int hidpp_hrw_set_wheel_mode(struct hidpp_device *hidpp, bool invert, in hidpp_hrw_set_wheel_mode() argument
1808 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_HIRES_WHEEL, in hidpp_hrw_set_wheel_mode()
1817 return hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_hrw_set_wheel_mode()
1834 static int hidpp_solar_request_battery_event(struct hidpp_device *hidpp) in hidpp_solar_request_battery_event() argument
1841 if (hidpp->battery.feature_index == 0xff) { in hidpp_solar_request_battery_event()
1842 ret = hidpp_root_get_feature(hidpp, in hidpp_solar_request_battery_event()
1844 &hidpp->battery.solar_feature_index, in hidpp_solar_request_battery_event()
1850 ret = hidpp_send_fap_command_sync(hidpp, in hidpp_solar_request_battery_event()
1851 hidpp->battery.solar_feature_index, in hidpp_solar_request_battery_event()
1855 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_solar_request_battery_event()
1862 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_MILEAGE; in hidpp_solar_request_battery_event()
1867 static int hidpp_solar_battery_event(struct hidpp_device *hidpp, in hidpp_solar_battery_event() argument
1877 if (report->fap.feature_index != hidpp->battery.solar_feature_index || in hidpp_solar_battery_event()
1895 if (capacity < hidpp->battery.capacity) in hidpp_solar_battery_event()
1905 hidpp->battery.online = true; in hidpp_solar_battery_event()
1906 if (capacity != hidpp->battery.capacity || in hidpp_solar_battery_event()
1907 status != hidpp->battery.status) { in hidpp_solar_battery_event()
1908 hidpp->battery.capacity = capacity; in hidpp_solar_battery_event()
1909 hidpp->battery.status = status; in hidpp_solar_battery_event()
1910 if (hidpp->battery.ps) in hidpp_solar_battery_event()
1911 power_supply_changed(hidpp->battery.ps); in hidpp_solar_battery_event()
1936 static int hidpp_touchpad_fw_items_set(struct hidpp_device *hidpp, in hidpp_touchpad_fw_items_set() argument
1944 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_touchpad_fw_items_set()
1948 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_touchpad_fw_items_set()
2007 static int hidpp_touchpad_get_raw_info(struct hidpp_device *hidpp, in hidpp_touchpad_get_raw_info() argument
2014 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_touchpad_get_raw_info()
2018 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_touchpad_get_raw_info()
2131 struct hidpp_device *hidpp; member
2223 ret = hidpp_send_fap_command_sync(data->hidpp, data->feature_index, in hidpp_ff_work_handler()
2227 hid_err(data->hidpp->hid_dev, "Failed to send command to device!\n"); in hidpp_ff_work_handler()
2289 …hid_warn(data->hidpp->hid_dev, "Force feedback command queue contains %d commands, causing substan… in hidpp_ff_queue_work()
2348 …hid_err(data->hidpp->hid_dev, "Unexpected periodic waveform type %i!\n", effect->u.periodic.wavefo… in hidpp_ff_upload_effect()
2433 hid_err(data->hidpp->hid_dev, "Unexpected force type %i!\n", effect->type); in hidpp_ff_upload_effect()
2533 struct hid_device *hid = data->hidpp->hid_dev; in hidpp_ff_destroy()
2542 static int hidpp_ff_init(struct hidpp_device *hidpp, in hidpp_ff_init() argument
2545 struct hid_device *hid = hidpp->hid_dev; in hidpp_ff_init()
2601 data->hidpp = hidpp; in hidpp_ff_init()
2617 error = device_create_file(&(hidpp->hid_dev->dev), &dev_attr_range); in hidpp_ff_init()
2619 hid_warn(hidpp->hid_dev, "Unable to create sysfs interface for \"range\", errno %d!\n", error); in hidpp_ff_init()
2659 static void wtp_populate_input(struct hidpp_device *hidpp, in wtp_populate_input() argument
2662 struct wtp_data *wd = hidpp->private_data; in wtp_populate_input()
2679 if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS) in wtp_populate_input()
2688 static void wtp_touch_event(struct hidpp_device *hidpp, in wtp_touch_event() argument
2691 struct wtp_data *wd = hidpp->private_data; in wtp_touch_event()
2698 slot = input_mt_get_slot_by_key(hidpp->input, touch_report->finger_id); in wtp_touch_event()
2700 input_mt_slot(hidpp->input, slot); in wtp_touch_event()
2701 input_mt_report_slot_state(hidpp->input, MT_TOOL_FINGER, in wtp_touch_event()
2704 input_event(hidpp->input, EV_ABS, ABS_MT_POSITION_X, in wtp_touch_event()
2706 input_event(hidpp->input, EV_ABS, ABS_MT_POSITION_Y, in wtp_touch_event()
2709 input_event(hidpp->input, EV_ABS, ABS_MT_PRESSURE, in wtp_touch_event()
2714 static void wtp_send_raw_xy_event(struct hidpp_device *hidpp, in wtp_send_raw_xy_event() argument
2720 wtp_touch_event(hidpp, &(raw->fingers[i])); in wtp_send_raw_xy_event()
2723 !(hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS)) in wtp_send_raw_xy_event()
2724 input_event(hidpp->input, EV_KEY, BTN_LEFT, raw->button); in wtp_send_raw_xy_event()
2727 input_mt_sync_frame(hidpp->input); in wtp_send_raw_xy_event()
2728 input_sync(hidpp->input); in wtp_send_raw_xy_event()
2732 static int wtp_mouse_raw_xy_event(struct hidpp_device *hidpp, u8 *data) in wtp_mouse_raw_xy_event() argument
2734 struct wtp_data *wd = hidpp->private_data; in wtp_mouse_raw_xy_event()
2766 wtp_send_raw_xy_event(hidpp, &raw); in wtp_mouse_raw_xy_event()
2773 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in wtp_raw_event() local
2774 struct wtp_data *wd = hidpp->private_data; in wtp_raw_event()
2778 if (!wd || !hidpp->input) in wtp_raw_event()
2788 if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS) { in wtp_raw_event()
2789 input_event(hidpp->input, EV_KEY, BTN_LEFT, in wtp_raw_event()
2791 input_event(hidpp->input, EV_KEY, BTN_RIGHT, in wtp_raw_event()
2793 input_sync(hidpp->input); in wtp_raw_event()
2798 return wtp_mouse_raw_xy_event(hidpp, &data[7]); in wtp_raw_event()
2805 hidpp_touchpad_raw_xy_event(hidpp, data + 4, &raw); in wtp_raw_event()
2807 wtp_send_raw_xy_event(hidpp, &raw); in wtp_raw_event()
2814 static int wtp_get_config(struct hidpp_device *hidpp) in wtp_get_config() argument
2816 struct wtp_data *wd = hidpp->private_data; in wtp_get_config()
2821 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_TOUCHPAD_RAW_XY, in wtp_get_config()
2827 ret = hidpp_touchpad_get_raw_info(hidpp, wd->mt_feature_index, in wtp_get_config()
2845 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in wtp_allocate() local
2853 hidpp->private_data = wd; in wtp_allocate()
2860 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in wtp_connect() local
2861 struct wtp_data *wd = hidpp->private_data; in wtp_connect()
2865 ret = wtp_get_config(hidpp); in wtp_connect()
2872 return hidpp_touchpad_set_raw_report_state(hidpp, wd->mt_feature_index, in wtp_connect()
2940 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in m560_raw_event() local
2943 if (!hidpp->input) { in m560_raw_event()
2970 input_report_key(hidpp->input, BTN_MIDDLE, 1); in m560_raw_event()
2973 input_report_key(hidpp->input, BTN_FORWARD, 1); in m560_raw_event()
2976 input_report_key(hidpp->input, BTN_BACK, 1); in m560_raw_event()
2979 input_report_key(hidpp->input, BTN_BACK, 0); in m560_raw_event()
2980 input_report_key(hidpp->input, BTN_FORWARD, 0); in m560_raw_event()
2981 input_report_key(hidpp->input, BTN_MIDDLE, 0); in m560_raw_event()
2987 input_sync(hidpp->input); in m560_raw_event()
3001 input_report_key(hidpp->input, BTN_LEFT, in m560_raw_event()
3003 input_report_key(hidpp->input, BTN_RIGHT, in m560_raw_event()
3007 input_report_rel(hidpp->input, REL_HWHEEL, -1); in m560_raw_event()
3008 input_report_rel(hidpp->input, REL_HWHEEL_HI_RES, in m560_raw_event()
3011 input_report_rel(hidpp->input, REL_HWHEEL, 1); in m560_raw_event()
3012 input_report_rel(hidpp->input, REL_HWHEEL_HI_RES, in m560_raw_event()
3017 input_report_rel(hidpp->input, REL_X, v); in m560_raw_event()
3020 input_report_rel(hidpp->input, REL_Y, v); in m560_raw_event()
3024 hidpp_scroll_counter_handle_scroll(hidpp->input, in m560_raw_event()
3025 &hidpp->vertical_wheel_counter, v); in m560_raw_event()
3027 input_sync(hidpp->input); in m560_raw_event()
3033 static void m560_populate_input(struct hidpp_device *hidpp, in m560_populate_input() argument
3077 static int k400_disable_tap_to_click(struct hidpp_device *hidpp) in k400_disable_tap_to_click() argument
3079 struct k400_private_data *k400 = hidpp->private_data; in k400_disable_tap_to_click()
3085 ret = hidpp_root_get_feature(hidpp, in k400_disable_tap_to_click()
3093 ret = hidpp_touchpad_fw_items_set(hidpp, k400->feature_index, &items); in k400_disable_tap_to_click()
3102 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in k400_allocate() local
3110 hidpp->private_data = k400; in k400_allocate()
3117 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in k400_connect() local
3122 return k400_disable_tap_to_click(hidpp); in k400_connect()
3131 static int g920_ff_set_autocenter(struct hidpp_device *hidpp, in g920_ff_set_autocenter() argument
3143 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_ff_set_autocenter()
3148 hid_warn(hidpp->hid_dev, "Failed to autocenter device!\n"); in g920_ff_set_autocenter()
3155 static int g920_get_config(struct hidpp_device *hidpp, in g920_get_config() argument
3165 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_G920_FORCE_FEEDBACK, in g920_get_config()
3171 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_get_config()
3178 hid_err(hidpp->hid_dev, in g920_get_config()
3186 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_get_config()
3191 hid_warn(hidpp->hid_dev, "Failed to reset all forces!\n"); in g920_get_config()
3193 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_get_config()
3198 hid_warn(hidpp->hid_dev, in g920_get_config()
3205 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_get_config()
3210 hid_warn(hidpp->hid_dev, in g920_get_config()
3217 return g920_ff_set_autocenter(hidpp, data); in g920_get_config()
3243 static int hidpp10_wheel_connect(struct hidpp_device *hidpp) in hidpp10_wheel_connect() argument
3245 return hidpp10_set_register(hidpp, HIDPP_REG_ENABLE_REPORTS, 0, in hidpp10_wheel_connect()
3250 static int hidpp10_wheel_raw_event(struct hidpp_device *hidpp, in hidpp10_wheel_raw_event() argument
3255 if (!hidpp->input) in hidpp10_wheel_raw_event()
3267 input_report_rel(hidpp->input, REL_WHEEL, value); in hidpp10_wheel_raw_event()
3268 input_report_rel(hidpp->input, REL_WHEEL_HI_RES, value * 120); in hidpp10_wheel_raw_event()
3269 input_report_rel(hidpp->input, REL_HWHEEL, hvalue); in hidpp10_wheel_raw_event()
3270 input_report_rel(hidpp->input, REL_HWHEEL_HI_RES, hvalue * 120); in hidpp10_wheel_raw_event()
3271 input_sync(hidpp->input); in hidpp10_wheel_raw_event()
3276 static void hidpp10_wheel_populate_input(struct hidpp_device *hidpp, in hidpp10_wheel_populate_input() argument
3289 static int hidpp10_extra_mouse_buttons_connect(struct hidpp_device *hidpp) in hidpp10_extra_mouse_buttons_connect() argument
3291 return hidpp10_set_register(hidpp, HIDPP_REG_ENABLE_REPORTS, 0, in hidpp10_extra_mouse_buttons_connect()
3296 static int hidpp10_extra_mouse_buttons_raw_event(struct hidpp_device *hidpp, in hidpp10_extra_mouse_buttons_raw_event() argument
3301 if (!hidpp->input) in hidpp10_extra_mouse_buttons_raw_event()
3318 input_report_key(hidpp->input, BTN_MOUSE + i, in hidpp10_extra_mouse_buttons_raw_event()
3323 input_report_key(hidpp->input, BTN_MISC + i, in hidpp10_extra_mouse_buttons_raw_event()
3326 input_sync(hidpp->input); in hidpp10_extra_mouse_buttons_raw_event()
3331 struct hidpp_device *hidpp, struct input_dev *input_dev) in hidpp10_extra_mouse_buttons_populate_input() argument
3349 static u8 *hidpp10_consumer_keys_report_fixup(struct hidpp_device *hidpp, in hidpp10_consumer_keys_report_fixup() argument
3377 static int hidpp10_consumer_keys_connect(struct hidpp_device *hidpp) in hidpp10_consumer_keys_connect() argument
3379 return hidpp10_set_register(hidpp, HIDPP_REG_ENABLE_REPORTS, 0, in hidpp10_consumer_keys_connect()
3384 static int hidpp10_consumer_keys_raw_event(struct hidpp_device *hidpp, in hidpp10_consumer_keys_raw_event() argument
3403 hid_report_raw_event(hidpp->hid_dev, HID_INPUT_REPORT, in hidpp10_consumer_keys_raw_event()
3413 static int hi_res_scroll_enable(struct hidpp_device *hidpp) in hi_res_scroll_enable() argument
3418 if (hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL_X2121) { in hi_res_scroll_enable()
3419 ret = hidpp_hrw_set_wheel_mode(hidpp, false, true, false); in hi_res_scroll_enable()
3421 ret = hidpp_hrw_get_wheel_capability(hidpp, &multiplier); in hi_res_scroll_enable()
3422 } else if (hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL_X2120) { in hi_res_scroll_enable()
3423 ret = hidpp_hrs_set_highres_scrolling_mode(hidpp, true, in hi_res_scroll_enable()
3426 ret = hidpp10_enable_scrolling_acceleration(hidpp); in hi_res_scroll_enable()
3435 hidpp->vertical_wheel_counter.wheel_multiplier = multiplier; in hi_res_scroll_enable()
3436 hid_dbg(hidpp->hid_dev, "wheel multiplier = %d\n", multiplier); in hi_res_scroll_enable()
3447 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_report_fixup() local
3449 if (!hidpp) in hidpp_report_fixup()
3454 (hidpp->quirks & HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS)) in hidpp_report_fixup()
3455 rdesc = hidpp10_consumer_keys_report_fixup(hidpp, rdesc, rsize); in hidpp_report_fixup()
3464 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_input_mapping() local
3466 if (!hidpp) in hidpp_input_mapping()
3469 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) in hidpp_input_mapping()
3471 else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560 && in hidpp_input_mapping()
3485 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_input_mapped() local
3487 if (!hidpp) in hidpp_input_mapped()
3491 if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) { in hidpp_input_mapped()
3503 static void hidpp_populate_input(struct hidpp_device *hidpp, in hidpp_populate_input() argument
3506 hidpp->input = input; in hidpp_populate_input()
3508 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) in hidpp_populate_input()
3509 wtp_populate_input(hidpp, input); in hidpp_populate_input()
3510 else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) in hidpp_populate_input()
3511 m560_populate_input(hidpp, input); in hidpp_populate_input()
3513 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_WHEELS) in hidpp_populate_input()
3514 hidpp10_wheel_populate_input(hidpp, input); in hidpp_populate_input()
3516 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_EXTRA_MOUSE_BTNS) in hidpp_populate_input()
3517 hidpp10_extra_mouse_buttons_populate_input(hidpp, input); in hidpp_populate_input()
3523 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_input_configured() local
3526 if (!hidpp) in hidpp_input_configured()
3529 hidpp_populate_input(hidpp, input); in hidpp_input_configured()
3534 static int hidpp_raw_hidpp_event(struct hidpp_device *hidpp, u8 *data, in hidpp_raw_hidpp_event() argument
3537 struct hidpp_report *question = hidpp->send_receive_buf; in hidpp_raw_hidpp_event()
3538 struct hidpp_report *answer = hidpp->send_receive_buf; in hidpp_raw_hidpp_event()
3546 if (unlikely(mutex_is_locked(&hidpp->send_mutex))) { in hidpp_raw_hidpp_event()
3554 hidpp->answer_available = true; in hidpp_raw_hidpp_event()
3555 wake_up(&hidpp->wait); in hidpp_raw_hidpp_event()
3566 if (unlikely(hidpp_report_is_connect_event(hidpp, report))) { in hidpp_raw_hidpp_event()
3567 atomic_set(&hidpp->connected, in hidpp_raw_hidpp_event()
3569 if (schedule_work(&hidpp->work) == 0) in hidpp_raw_hidpp_event()
3574 if (hidpp->hid_dev->group == HID_GROUP_LOGITECH_27MHZ_DEVICE && in hidpp_raw_hidpp_event()
3578 dev_err_ratelimited(&hidpp->hid_dev->dev, in hidpp_raw_hidpp_event()
3580 dev_err_ratelimited(&hidpp->hid_dev->dev, in hidpp_raw_hidpp_event()
3584 if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_BATTERY) { in hidpp_raw_hidpp_event()
3585 ret = hidpp20_battery_event_1000(hidpp, data, size); in hidpp_raw_hidpp_event()
3588 ret = hidpp20_battery_event_1004(hidpp, data, size); in hidpp_raw_hidpp_event()
3591 ret = hidpp_solar_battery_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3594 ret = hidpp20_battery_voltage_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3599 if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP10_BATTERY) { in hidpp_raw_hidpp_event()
3600 ret = hidpp10_battery_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3605 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_WHEELS) { in hidpp_raw_hidpp_event()
3606 ret = hidpp10_wheel_raw_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3611 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_EXTRA_MOUSE_BTNS) { in hidpp_raw_hidpp_event()
3612 ret = hidpp10_extra_mouse_buttons_raw_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3617 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS) { in hidpp_raw_hidpp_event()
3618 ret = hidpp10_consumer_keys_raw_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3629 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_raw_event() local
3632 if (!hidpp) in hidpp_raw_event()
3638 if (size != hidpp->very_long_report_length) { in hidpp_raw_event()
3643 ret = hidpp_raw_hidpp_event(hidpp, data, size); in hidpp_raw_event()
3651 ret = hidpp_raw_hidpp_event(hidpp, data, size); in hidpp_raw_event()
3659 ret = hidpp_raw_hidpp_event(hidpp, data, size); in hidpp_raw_event()
3668 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) in hidpp_raw_event()
3670 else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) in hidpp_raw_event()
3682 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_event() local
3685 if (!hidpp) in hidpp_event()
3688 counter = &hidpp->vertical_wheel_counter; in hidpp_event()
3694 if (!(hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL) || value == 0 in hidpp_event()
3695 || hidpp->input == NULL || counter->wheel_multiplier == 0) in hidpp_event()
3698 hidpp_scroll_counter_handle_scroll(hidpp->input, counter, value); in hidpp_event()
3702 static int hidpp_initialize_battery(struct hidpp_device *hidpp) in hidpp_initialize_battery() argument
3705 struct power_supply_config cfg = { .drv_data = hidpp }; in hidpp_initialize_battery()
3706 struct power_supply_desc *desc = &hidpp->battery.desc; in hidpp_initialize_battery()
3713 if (hidpp->battery.ps) in hidpp_initialize_battery()
3716 hidpp->battery.feature_index = 0xff; in hidpp_initialize_battery()
3717 hidpp->battery.solar_feature_index = 0xff; in hidpp_initialize_battery()
3718 hidpp->battery.voltage_feature_index = 0xff; in hidpp_initialize_battery()
3720 if (hidpp->protocol_major >= 2) { in hidpp_initialize_battery()
3721 if (hidpp->quirks & HIDPP_QUIRK_CLASS_K750) in hidpp_initialize_battery()
3722 ret = hidpp_solar_request_battery_event(hidpp); in hidpp_initialize_battery()
3727 ret = hidpp20_query_battery_info_1000(hidpp); in hidpp_initialize_battery()
3729 ret = hidpp20_query_battery_info_1004(hidpp); in hidpp_initialize_battery()
3731 ret = hidpp20_query_battery_voltage_info(hidpp); in hidpp_initialize_battery()
3736 hidpp->capabilities |= HIDPP_CAPABILITY_HIDPP20_BATTERY; in hidpp_initialize_battery()
3738 ret = hidpp10_query_battery_status(hidpp); in hidpp_initialize_battery()
3740 ret = hidpp10_query_battery_mileage(hidpp); in hidpp_initialize_battery()
3743 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_MILEAGE; in hidpp_initialize_battery()
3745 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS; in hidpp_initialize_battery()
3747 hidpp->capabilities |= HIDPP_CAPABILITY_HIDPP10_BATTERY; in hidpp_initialize_battery()
3750 battery_props = devm_kmemdup(&hidpp->hid_dev->dev, in hidpp_initialize_battery()
3759 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_MILEAGE || in hidpp_initialize_battery()
3760 hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_PERCENTAGE || in hidpp_initialize_battery()
3761 hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_VOLTAGE) in hidpp_initialize_battery()
3765 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS) in hidpp_initialize_battery()
3769 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_VOLTAGE) in hidpp_initialize_battery()
3773 battery = &hidpp->battery; in hidpp_initialize_battery()
3784 battery->ps = devm_power_supply_register(&hidpp->hid_dev->dev, in hidpp_initialize_battery()
3790 power_supply_powers(battery->ps, &hidpp->hid_dev->dev); in hidpp_initialize_battery()
3797 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_overwrite_name() local
3800 if (hidpp->protocol_major < 2) in hidpp_overwrite_name()
3803 name = hidpp_get_device_name(hidpp); in hidpp_overwrite_name()
3832 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_allocate_input() local
3841 input_dev->name = hidpp->name; in hidpp_allocate_input()
3853 static void hidpp_connect_event(struct hidpp_device *hidpp) in hidpp_connect_event() argument
3855 struct hid_device *hdev = hidpp->hid_dev; in hidpp_connect_event()
3857 bool connected = atomic_read(&hidpp->connected); in hidpp_connect_event()
3862 if (hidpp->battery.ps) { in hidpp_connect_event()
3863 hidpp->battery.online = false; in hidpp_connect_event()
3864 hidpp->battery.status = POWER_SUPPLY_STATUS_UNKNOWN; in hidpp_connect_event()
3865 hidpp->battery.level = POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN; in hidpp_connect_event()
3866 power_supply_changed(hidpp->battery.ps); in hidpp_connect_event()
3871 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) { in hidpp_connect_event()
3875 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) { in hidpp_connect_event()
3879 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_K400) { in hidpp_connect_event()
3885 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_WHEELS) { in hidpp_connect_event()
3886 ret = hidpp10_wheel_connect(hidpp); in hidpp_connect_event()
3891 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_EXTRA_MOUSE_BTNS) { in hidpp_connect_event()
3892 ret = hidpp10_extra_mouse_buttons_connect(hidpp); in hidpp_connect_event()
3897 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS) { in hidpp_connect_event()
3898 ret = hidpp10_consumer_keys_connect(hidpp); in hidpp_connect_event()
3905 if (!hidpp->protocol_major) { in hidpp_connect_event()
3906 ret = hidpp_root_get_protocol_version(hidpp); in hidpp_connect_event()
3913 if (hidpp->name == hdev->name && hidpp->protocol_major >= 2) { in hidpp_connect_event()
3914 name = hidpp_get_device_name(hidpp); in hidpp_connect_event()
3922 hidpp->name = devm_name; in hidpp_connect_event()
3926 hidpp_initialize_battery(hidpp); in hidpp_connect_event()
3929 if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP10_BATTERY) { in hidpp_connect_event()
3930 hidpp10_enable_battery_reporting(hidpp); in hidpp_connect_event()
3931 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_MILEAGE) in hidpp_connect_event()
3932 hidpp10_query_battery_mileage(hidpp); in hidpp_connect_event()
3934 hidpp10_query_battery_status(hidpp); in hidpp_connect_event()
3935 } else if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_BATTERY) { in hidpp_connect_event()
3936 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_VOLTAGE) in hidpp_connect_event()
3937 hidpp20_query_battery_voltage_info(hidpp); in hidpp_connect_event()
3938 else if (hidpp->capabilities & HIDPP_CAPABILITY_UNIFIED_BATTERY) in hidpp_connect_event()
3939 hidpp20_query_battery_info_1004(hidpp); in hidpp_connect_event()
3941 hidpp20_query_battery_info_1000(hidpp); in hidpp_connect_event()
3943 if (hidpp->battery.ps) in hidpp_connect_event()
3944 power_supply_changed(hidpp->battery.ps); in hidpp_connect_event()
3946 if (hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL) in hidpp_connect_event()
3947 hi_res_scroll_enable(hidpp); in hidpp_connect_event()
3949 if (!(hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT) || hidpp->delayed_input) in hidpp_connect_event()
3959 hidpp_populate_input(hidpp, input); in hidpp_connect_event()
3965 hidpp->delayed_input = input; in hidpp_connect_event()
3994 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_validate_device() local
4024 hidpp->very_long_report_length = report_length; in hidpp_validate_device()
4047 struct hidpp_device *hidpp; in hidpp_probe() local
4054 hidpp = devm_kzalloc(&hdev->dev, sizeof(*hidpp), GFP_KERNEL); in hidpp_probe()
4055 if (!hidpp) in hidpp_probe()
4058 hidpp->hid_dev = hdev; in hidpp_probe()
4059 hidpp->name = hdev->name; in hidpp_probe()
4060 hidpp->quirks = id->driver_data; in hidpp_probe()
4061 hid_set_drvdata(hdev, hidpp); in hidpp_probe()
4072 hidpp->supported_reports = hidpp_validate_device(hdev); in hidpp_probe()
4074 if (!hidpp->supported_reports) { in hidpp_probe()
4076 devm_kfree(&hdev->dev, hidpp); in hidpp_probe()
4081 hidpp->quirks |= HIDPP_QUIRK_UNIFYING; in hidpp_probe()
4085 hidpp->quirks |= HIDPP_QUIRK_HIDPP_WHEELS | in hidpp_probe()
4090 hidpp->quirks |= HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS; in hidpp_probe()
4093 hidpp->quirks &= ~HIDPP_QUIRK_CLASS_WTP; in hidpp_probe()
4094 hidpp->quirks &= ~HIDPP_QUIRK_NO_HIDINPUT; in hidpp_probe()
4097 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) { in hidpp_probe()
4101 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_K400) { in hidpp_probe()
4107 INIT_WORK(&hidpp->work, delayed_work_cb); in hidpp_probe()
4108 mutex_init(&hidpp->send_mutex); in hidpp_probe()
4109 init_waitqueue_head(&hidpp->wait); in hidpp_probe()
4137 if (hidpp->quirks & HIDPP_QUIRK_UNIFYING) in hidpp_probe()
4138 hidpp_unifying_init(hidpp); in hidpp_probe()
4140 connected = hidpp_root_get_protocol_version(hidpp) == 0; in hidpp_probe()
4141 atomic_set(&hidpp->connected, connected); in hidpp_probe()
4142 if (!(hidpp->quirks & HIDPP_QUIRK_UNIFYING)) { in hidpp_probe()
4152 if (connected && hidpp->protocol_major >= 2) { in hidpp_probe()
4153 ret = hidpp_set_wireless_feature_index(hidpp); in hidpp_probe()
4155 hidpp->wireless_feature_index = 0; in hidpp_probe()
4160 if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)) { in hidpp_probe()
4161 ret = wtp_get_config(hidpp); in hidpp_probe()
4164 } else if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_G920)) { in hidpp_probe()
4165 ret = g920_get_config(hidpp, &data); in hidpp_probe()
4170 hidpp_connect_event(hidpp); in hidpp_probe()
4177 if (hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT) in hidpp_probe()
4187 if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) { in hidpp_probe()
4188 ret = hidpp_ff_init(hidpp, &data); in hidpp_probe()
4190 hid_warn(hidpp->hid_dev, in hidpp_probe()
4203 cancel_work_sync(&hidpp->work); in hidpp_probe()
4204 mutex_destroy(&hidpp->send_mutex); in hidpp_probe()
4210 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_remove() local
4212 if (!hidpp) in hidpp_remove()
4218 cancel_work_sync(&hidpp->work); in hidpp_remove()
4219 mutex_destroy(&hidpp->send_mutex); in hidpp_remove()