Lines Matching refs:hidpp
227 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in __hidpp_send_report() local
238 fields_count = hidpp->very_long_report_length; in __hidpp_send_report()
250 if (hidpp->quirks & HIDPP_QUIRK_FORCE_OUTPUT_REPORTS) { in __hidpp_send_report()
269 static int hidpp_send_message_sync(struct hidpp_device *hidpp, in hidpp_send_message_sync() argument
275 mutex_lock(&hidpp->send_mutex); in hidpp_send_message_sync()
277 hidpp->send_receive_buf = response; in hidpp_send_message_sync()
278 hidpp->answer_available = false; in hidpp_send_message_sync()
286 ret = __hidpp_send_report(hidpp->hid_dev, message); in hidpp_send_message_sync()
294 if (!wait_event_timeout(hidpp->wait, hidpp->answer_available, in hidpp_send_message_sync()
317 mutex_unlock(&hidpp->send_mutex); in hidpp_send_message_sync()
322 static int hidpp_send_fap_command_sync(struct hidpp_device *hidpp, in hidpp_send_fap_command_sync() argument
344 ret = hidpp_send_message_sync(hidpp, message, response); in hidpp_send_fap_command_sync()
393 struct hidpp_device *hidpp = container_of(work, struct hidpp_device, in delayed_work_cb() local
395 hidpp_connect_event(hidpp); in delayed_work_cb()
414 static inline bool hidpp_report_is_connect_event(struct hidpp_device *hidpp, in hidpp_report_is_connect_event() argument
417 return (hidpp->wireless_feature_index && in hidpp_report_is_connect_event()
418 (report->fap.feature_index == hidpp->wireless_feature_index)) || in hidpp_report_is_connect_event()
641 static int hidpp10_query_battery_status(struct hidpp_device *hidpp) in hidpp10_query_battery_status() argument
646 ret = hidpp_send_rap_command_sync(hidpp, in hidpp10_query_battery_status()
654 hidpp->battery.level = in hidpp10_query_battery_status()
657 hidpp->battery.status = status; in hidpp10_query_battery_status()
659 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp10_query_battery_status()
693 static int hidpp10_query_battery_mileage(struct hidpp_device *hidpp) in hidpp10_query_battery_mileage() argument
698 ret = hidpp_send_rap_command_sync(hidpp, in hidpp10_query_battery_mileage()
706 hidpp->battery.capacity = response.rap.params[0]; in hidpp10_query_battery_mileage()
708 hidpp->battery.status = status; in hidpp10_query_battery_mileage()
710 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp10_query_battery_mileage()
716 static int hidpp10_battery_event(struct hidpp_device *hidpp, u8 *data, int size) in hidpp10_battery_event() argument
727 capacity = hidpp->battery.capacity; in hidpp10_battery_event()
733 level = hidpp->battery.level; in hidpp10_battery_event()
740 changed = capacity != hidpp->battery.capacity || in hidpp10_battery_event()
741 level != hidpp->battery.level || in hidpp10_battery_event()
742 status != hidpp->battery.status; in hidpp10_battery_event()
745 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp10_battery_event()
749 hidpp->battery.level = level; in hidpp10_battery_event()
750 hidpp->battery.status = status; in hidpp10_battery_event()
751 if (hidpp->battery.ps) in hidpp10_battery_event()
752 power_supply_changed(hidpp->battery.ps); in hidpp10_battery_event()
798 static int hidpp_unifying_get_serial(struct hidpp_device *hidpp, u32 *serial) in hidpp_unifying_get_serial() argument
804 ret = hidpp_send_rap_command_sync(hidpp, in hidpp_unifying_get_serial()
820 static int hidpp_unifying_init(struct hidpp_device *hidpp) in hidpp_unifying_init() argument
822 struct hid_device *hdev = hidpp->hid_dev; in hidpp_unifying_init()
827 ret = hidpp_unifying_get_serial(hidpp, &serial); in hidpp_unifying_init()
835 name = hidpp_unifying_get_name(hidpp); in hidpp_unifying_init()
856 static int hidpp_root_get_feature(struct hidpp_device *hidpp, u16 feature, in hidpp_root_get_feature() argument
863 ret = hidpp_send_fap_command_sync(hidpp, in hidpp_root_get_feature()
879 static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp) in hidpp_root_get_protocol_version() argument
886 ret = hidpp_send_rap_command_sync(hidpp, in hidpp_root_get_protocol_version()
893 hidpp->protocol_major = 1; in hidpp_root_get_protocol_version()
894 hidpp->protocol_minor = 0; in hidpp_root_get_protocol_version()
903 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_root_get_protocol_version()
911 hid_err(hidpp->hid_dev, "%s: ping mismatch 0x%02x != 0x%02x\n", in hidpp_root_get_protocol_version()
916 hidpp->protocol_major = response.rap.params[0]; in hidpp_root_get_protocol_version()
917 hidpp->protocol_minor = response.rap.params[1]; in hidpp_root_get_protocol_version()
920 hid_info(hidpp->hid_dev, "HID++ %u.%u device connected.\n", in hidpp_root_get_protocol_version()
921 hidpp->protocol_major, hidpp->protocol_minor); in hidpp_root_get_protocol_version()
935 static int hidpp_devicenametype_get_count(struct hidpp_device *hidpp, in hidpp_devicenametype_get_count() argument
941 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_devicenametype_get_count()
945 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_devicenametype_get_count()
957 static int hidpp_devicenametype_get_device_name(struct hidpp_device *hidpp, in hidpp_devicenametype_get_device_name() argument
964 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_devicenametype_get_device_name()
969 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_devicenametype_get_device_name()
978 count = hidpp->very_long_report_length - 4; in hidpp_devicenametype_get_device_name()
999 static char *hidpp_get_device_name(struct hidpp_device *hidpp) in hidpp_get_device_name() argument
1008 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_GET_DEVICE_NAME_TYPE, in hidpp_get_device_name()
1013 ret = hidpp_devicenametype_get_count(hidpp, feature_index, in hidpp_get_device_name()
1023 ret = hidpp_devicenametype_get_device_name(hidpp, in hidpp_get_device_name()
1112 static int hidpp20_batterylevel_get_battery_capacity(struct hidpp_device *hidpp, in hidpp20_batterylevel_get_battery_capacity() argument
1123 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp20_batterylevel_get_battery_capacity()
1130 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_batterylevel_get_battery_capacity()
1144 static int hidpp20_batterylevel_get_battery_info(struct hidpp_device *hidpp, in hidpp20_batterylevel_get_battery_info() argument
1152 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp20_batterylevel_get_battery_info()
1156 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_batterylevel_get_battery_info()
1167 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS; in hidpp20_batterylevel_get_battery_info()
1169 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_MILEAGE; in hidpp20_batterylevel_get_battery_info()
1174 static int hidpp20_query_battery_info(struct hidpp_device *hidpp) in hidpp20_query_battery_info() argument
1180 if (hidpp->battery.feature_index == 0xff) { in hidpp20_query_battery_info()
1181 ret = hidpp_root_get_feature(hidpp, in hidpp20_query_battery_info()
1183 &hidpp->battery.feature_index, in hidpp20_query_battery_info()
1189 ret = hidpp20_batterylevel_get_battery_capacity(hidpp, in hidpp20_query_battery_info()
1190 hidpp->battery.feature_index, in hidpp20_query_battery_info()
1196 ret = hidpp20_batterylevel_get_battery_info(hidpp, in hidpp20_query_battery_info()
1197 hidpp->battery.feature_index); in hidpp20_query_battery_info()
1201 hidpp->battery.status = status; in hidpp20_query_battery_info()
1202 hidpp->battery.capacity = capacity; in hidpp20_query_battery_info()
1203 hidpp->battery.level = level; in hidpp20_query_battery_info()
1205 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp20_query_battery_info()
1211 static int hidpp20_battery_event(struct hidpp_device *hidpp, in hidpp20_battery_event() argument
1218 if (report->fap.feature_index != hidpp->battery.feature_index || in hidpp20_battery_event()
1228 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp20_battery_event()
1231 changed = capacity != hidpp->battery.capacity || in hidpp20_battery_event()
1232 level != hidpp->battery.level || in hidpp20_battery_event()
1233 status != hidpp->battery.status; in hidpp20_battery_event()
1236 hidpp->battery.level = level; in hidpp20_battery_event()
1237 hidpp->battery.capacity = capacity; in hidpp20_battery_event()
1238 hidpp->battery.status = status; in hidpp20_battery_event()
1239 if (hidpp->battery.ps) in hidpp20_battery_event()
1240 power_supply_changed(hidpp->battery.ps); in hidpp20_battery_event()
1299 static int hidpp20_battery_get_battery_voltage(struct hidpp_device *hidpp, in hidpp20_battery_get_battery_voltage() argument
1308 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp20_battery_get_battery_voltage()
1313 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_battery_get_battery_voltage()
1320 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_VOLTAGE; in hidpp20_battery_get_battery_voltage()
1328 static int hidpp20_query_battery_voltage_info(struct hidpp_device *hidpp) in hidpp20_query_battery_voltage_info() argument
1334 if (hidpp->battery.voltage_feature_index == 0xff) { in hidpp20_query_battery_voltage_info()
1335 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_BATTERY_VOLTAGE, in hidpp20_query_battery_voltage_info()
1336 &hidpp->battery.voltage_feature_index, in hidpp20_query_battery_voltage_info()
1342 ret = hidpp20_battery_get_battery_voltage(hidpp, in hidpp20_query_battery_voltage_info()
1343 hidpp->battery.voltage_feature_index, in hidpp20_query_battery_voltage_info()
1349 hidpp->battery.status = status; in hidpp20_query_battery_voltage_info()
1350 hidpp->battery.voltage = voltage; in hidpp20_query_battery_voltage_info()
1351 hidpp->battery.level = level; in hidpp20_query_battery_voltage_info()
1352 hidpp->battery.charge_type = charge_type; in hidpp20_query_battery_voltage_info()
1353 hidpp->battery.online = status != POWER_SUPPLY_STATUS_NOT_CHARGING; in hidpp20_query_battery_voltage_info()
1358 static int hidpp20_battery_voltage_event(struct hidpp_device *hidpp, in hidpp20_battery_voltage_event() argument
1364 if (report->fap.feature_index != hidpp->battery.voltage_feature_index || in hidpp20_battery_voltage_event()
1371 hidpp->battery.online = status != POWER_SUPPLY_STATUS_NOT_CHARGING; in hidpp20_battery_voltage_event()
1373 if (voltage != hidpp->battery.voltage || status != hidpp->battery.status) { in hidpp20_battery_voltage_event()
1374 hidpp->battery.voltage = voltage; in hidpp20_battery_voltage_event()
1375 hidpp->battery.status = status; in hidpp20_battery_voltage_event()
1376 hidpp->battery.level = level; in hidpp20_battery_voltage_event()
1377 hidpp->battery.charge_type = charge_type; in hidpp20_battery_voltage_event()
1378 if (hidpp->battery.ps) in hidpp20_battery_voltage_event()
1379 power_supply_changed(hidpp->battery.ps); in hidpp20_battery_voltage_event()
1400 struct hidpp_device *hidpp = power_supply_get_drvdata(psy); in hidpp_battery_get_property() local
1405 val->intval = hidpp->battery.status; in hidpp_battery_get_property()
1408 val->intval = hidpp->battery.capacity; in hidpp_battery_get_property()
1411 val->intval = hidpp->battery.level; in hidpp_battery_get_property()
1417 val->intval = hidpp->battery.online; in hidpp_battery_get_property()
1420 if (!strncmp(hidpp->name, "Logitech ", 9)) in hidpp_battery_get_property()
1421 val->strval = hidpp->name + 9; in hidpp_battery_get_property()
1423 val->strval = hidpp->name; in hidpp_battery_get_property()
1429 val->strval = hidpp->hid_dev->uniq; in hidpp_battery_get_property()
1433 val->intval = hidpp->battery.voltage * 1000; in hidpp_battery_get_property()
1436 val->intval = hidpp->battery.charge_type; in hidpp_battery_get_property()
1451 static int hidpp_set_wireless_feature_index(struct hidpp_device *hidpp) in hidpp_set_wireless_feature_index() argument
1456 ret = hidpp_root_get_feature(hidpp, in hidpp_set_wireless_feature_index()
1458 &hidpp->wireless_feature_index, in hidpp_set_wireless_feature_index()
1472 static int hidpp_hrs_set_highres_scrolling_mode(struct hidpp_device *hidpp, in hidpp_hrs_set_highres_scrolling_mode() argument
1481 ret = hidpp_root_get_feature(hidpp, in hidpp_hrs_set_highres_scrolling_mode()
1489 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_hrs_set_highres_scrolling_mode()
1507 static int hidpp_hrw_get_wheel_capability(struct hidpp_device *hidpp, in hidpp_hrw_get_wheel_capability() argument
1515 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_HIRES_WHEEL, in hidpp_hrw_get_wheel_capability()
1520 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_hrw_get_wheel_capability()
1529 hid_warn(hidpp->hid_dev, in hidpp_hrw_get_wheel_capability()
1534 static int hidpp_hrw_set_wheel_mode(struct hidpp_device *hidpp, bool invert, in hidpp_hrw_set_wheel_mode() argument
1543 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_HIRES_WHEEL, in hidpp_hrw_set_wheel_mode()
1552 return hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_hrw_set_wheel_mode()
1569 static int hidpp_solar_request_battery_event(struct hidpp_device *hidpp) in hidpp_solar_request_battery_event() argument
1576 if (hidpp->battery.feature_index == 0xff) { in hidpp_solar_request_battery_event()
1577 ret = hidpp_root_get_feature(hidpp, in hidpp_solar_request_battery_event()
1579 &hidpp->battery.solar_feature_index, in hidpp_solar_request_battery_event()
1585 ret = hidpp_send_fap_command_sync(hidpp, in hidpp_solar_request_battery_event()
1586 hidpp->battery.solar_feature_index, in hidpp_solar_request_battery_event()
1590 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_solar_request_battery_event()
1597 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_MILEAGE; in hidpp_solar_request_battery_event()
1602 static int hidpp_solar_battery_event(struct hidpp_device *hidpp, in hidpp_solar_battery_event() argument
1612 if (report->fap.feature_index != hidpp->battery.solar_feature_index || in hidpp_solar_battery_event()
1630 if (capacity < hidpp->battery.capacity) in hidpp_solar_battery_event()
1640 hidpp->battery.online = true; in hidpp_solar_battery_event()
1641 if (capacity != hidpp->battery.capacity || in hidpp_solar_battery_event()
1642 status != hidpp->battery.status) { in hidpp_solar_battery_event()
1643 hidpp->battery.capacity = capacity; in hidpp_solar_battery_event()
1644 hidpp->battery.status = status; in hidpp_solar_battery_event()
1645 if (hidpp->battery.ps) in hidpp_solar_battery_event()
1646 power_supply_changed(hidpp->battery.ps); in hidpp_solar_battery_event()
1671 static int hidpp_touchpad_fw_items_set(struct hidpp_device *hidpp, in hidpp_touchpad_fw_items_set() argument
1679 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_touchpad_fw_items_set()
1683 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_touchpad_fw_items_set()
1742 static int hidpp_touchpad_get_raw_info(struct hidpp_device *hidpp, in hidpp_touchpad_get_raw_info() argument
1749 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_touchpad_get_raw_info()
1753 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_touchpad_get_raw_info()
1866 struct hidpp_device *hidpp; member
1958 ret = hidpp_send_fap_command_sync(data->hidpp, data->feature_index, in hidpp_ff_work_handler()
1962 hid_err(data->hidpp->hid_dev, "Failed to send command to device!\n"); in hidpp_ff_work_handler()
2025 …hid_warn(data->hidpp->hid_dev, "Force feedback command queue contains %d commands, causing substan… in hidpp_ff_queue_work()
2084 …hid_err(data->hidpp->hid_dev, "Unexpected periodic waveform type %i!\n", effect->u.periodic.wavefo… in hidpp_ff_upload_effect()
2169 hid_err(data->hidpp->hid_dev, "Unexpected force type %i!\n", effect->type); in hidpp_ff_upload_effect()
2269 struct hid_device *hid = data->hidpp->hid_dev; in hidpp_ff_destroy()
2278 static int hidpp_ff_init(struct hidpp_device *hidpp, in hidpp_ff_init() argument
2281 struct hid_device *hid = hidpp->hid_dev; in hidpp_ff_init()
2337 data->hidpp = hidpp; in hidpp_ff_init()
2353 error = device_create_file(&(hidpp->hid_dev->dev), &dev_attr_range); in hidpp_ff_init()
2355 hid_warn(hidpp->hid_dev, "Unable to create sysfs interface for \"range\", errno %d!\n", error); in hidpp_ff_init()
2395 static void wtp_populate_input(struct hidpp_device *hidpp, in wtp_populate_input() argument
2398 struct wtp_data *wd = hidpp->private_data; in wtp_populate_input()
2415 if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS) in wtp_populate_input()
2424 static void wtp_touch_event(struct hidpp_device *hidpp, in wtp_touch_event() argument
2427 struct wtp_data *wd = hidpp->private_data; in wtp_touch_event()
2434 slot = input_mt_get_slot_by_key(hidpp->input, touch_report->finger_id); in wtp_touch_event()
2436 input_mt_slot(hidpp->input, slot); in wtp_touch_event()
2437 input_mt_report_slot_state(hidpp->input, MT_TOOL_FINGER, in wtp_touch_event()
2440 input_event(hidpp->input, EV_ABS, ABS_MT_POSITION_X, in wtp_touch_event()
2442 input_event(hidpp->input, EV_ABS, ABS_MT_POSITION_Y, in wtp_touch_event()
2445 input_event(hidpp->input, EV_ABS, ABS_MT_PRESSURE, in wtp_touch_event()
2450 static void wtp_send_raw_xy_event(struct hidpp_device *hidpp, in wtp_send_raw_xy_event() argument
2456 wtp_touch_event(hidpp, &(raw->fingers[i])); in wtp_send_raw_xy_event()
2459 !(hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS)) in wtp_send_raw_xy_event()
2460 input_event(hidpp->input, EV_KEY, BTN_LEFT, raw->button); in wtp_send_raw_xy_event()
2463 input_mt_sync_frame(hidpp->input); in wtp_send_raw_xy_event()
2464 input_sync(hidpp->input); in wtp_send_raw_xy_event()
2468 static int wtp_mouse_raw_xy_event(struct hidpp_device *hidpp, u8 *data) in wtp_mouse_raw_xy_event() argument
2470 struct wtp_data *wd = hidpp->private_data; in wtp_mouse_raw_xy_event()
2502 wtp_send_raw_xy_event(hidpp, &raw); in wtp_mouse_raw_xy_event()
2509 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in wtp_raw_event() local
2510 struct wtp_data *wd = hidpp->private_data; in wtp_raw_event()
2514 if (!wd || !hidpp->input) in wtp_raw_event()
2524 if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS) { in wtp_raw_event()
2525 input_event(hidpp->input, EV_KEY, BTN_LEFT, in wtp_raw_event()
2527 input_event(hidpp->input, EV_KEY, BTN_RIGHT, in wtp_raw_event()
2529 input_sync(hidpp->input); in wtp_raw_event()
2534 return wtp_mouse_raw_xy_event(hidpp, &data[7]); in wtp_raw_event()
2541 hidpp_touchpad_raw_xy_event(hidpp, data + 4, &raw); in wtp_raw_event()
2543 wtp_send_raw_xy_event(hidpp, &raw); in wtp_raw_event()
2550 static int wtp_get_config(struct hidpp_device *hidpp) in wtp_get_config() argument
2552 struct wtp_data *wd = hidpp->private_data; in wtp_get_config()
2557 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_TOUCHPAD_RAW_XY, in wtp_get_config()
2563 ret = hidpp_touchpad_get_raw_info(hidpp, wd->mt_feature_index, in wtp_get_config()
2581 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in wtp_allocate() local
2589 hidpp->private_data = wd; in wtp_allocate()
2596 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in wtp_connect() local
2597 struct wtp_data *wd = hidpp->private_data; in wtp_connect()
2601 ret = wtp_get_config(hidpp); in wtp_connect()
2608 return hidpp_touchpad_set_raw_report_state(hidpp, wd->mt_feature_index, in wtp_connect()
2676 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in m560_raw_event() local
2679 if (!hidpp->input) { in m560_raw_event()
2706 input_report_key(hidpp->input, BTN_MIDDLE, 1); in m560_raw_event()
2709 input_report_key(hidpp->input, BTN_FORWARD, 1); in m560_raw_event()
2712 input_report_key(hidpp->input, BTN_BACK, 1); in m560_raw_event()
2715 input_report_key(hidpp->input, BTN_BACK, 0); in m560_raw_event()
2716 input_report_key(hidpp->input, BTN_FORWARD, 0); in m560_raw_event()
2717 input_report_key(hidpp->input, BTN_MIDDLE, 0); in m560_raw_event()
2723 input_sync(hidpp->input); in m560_raw_event()
2737 input_report_key(hidpp->input, BTN_LEFT, in m560_raw_event()
2739 input_report_key(hidpp->input, BTN_RIGHT, in m560_raw_event()
2743 input_report_rel(hidpp->input, REL_HWHEEL, -1); in m560_raw_event()
2744 input_report_rel(hidpp->input, REL_HWHEEL_HI_RES, in m560_raw_event()
2747 input_report_rel(hidpp->input, REL_HWHEEL, 1); in m560_raw_event()
2748 input_report_rel(hidpp->input, REL_HWHEEL_HI_RES, in m560_raw_event()
2753 input_report_rel(hidpp->input, REL_X, v); in m560_raw_event()
2756 input_report_rel(hidpp->input, REL_Y, v); in m560_raw_event()
2760 hidpp_scroll_counter_handle_scroll(hidpp->input, in m560_raw_event()
2761 &hidpp->vertical_wheel_counter, v); in m560_raw_event()
2763 input_sync(hidpp->input); in m560_raw_event()
2769 static void m560_populate_input(struct hidpp_device *hidpp, in m560_populate_input() argument
2813 static int k400_disable_tap_to_click(struct hidpp_device *hidpp) in k400_disable_tap_to_click() argument
2815 struct k400_private_data *k400 = hidpp->private_data; in k400_disable_tap_to_click()
2821 ret = hidpp_root_get_feature(hidpp, in k400_disable_tap_to_click()
2829 ret = hidpp_touchpad_fw_items_set(hidpp, k400->feature_index, &items); in k400_disable_tap_to_click()
2838 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in k400_allocate() local
2846 hidpp->private_data = k400; in k400_allocate()
2853 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in k400_connect() local
2858 return k400_disable_tap_to_click(hidpp); in k400_connect()
2867 static int g920_ff_set_autocenter(struct hidpp_device *hidpp, in g920_ff_set_autocenter() argument
2879 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_ff_set_autocenter()
2884 hid_warn(hidpp->hid_dev, "Failed to autocenter device!\n"); in g920_ff_set_autocenter()
2891 static int g920_get_config(struct hidpp_device *hidpp, in g920_get_config() argument
2901 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_G920_FORCE_FEEDBACK, in g920_get_config()
2907 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_get_config()
2914 hid_err(hidpp->hid_dev, in g920_get_config()
2922 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_get_config()
2927 hid_warn(hidpp->hid_dev, "Failed to reset all forces!\n"); in g920_get_config()
2929 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_get_config()
2934 hid_warn(hidpp->hid_dev, in g920_get_config()
2941 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_get_config()
2946 hid_warn(hidpp->hid_dev, in g920_get_config()
2953 return g920_ff_set_autocenter(hidpp, data); in g920_get_config()
2979 static int hidpp10_wheel_connect(struct hidpp_device *hidpp) in hidpp10_wheel_connect() argument
2981 return hidpp10_set_register(hidpp, HIDPP_REG_ENABLE_REPORTS, 0, in hidpp10_wheel_connect()
2986 static int hidpp10_wheel_raw_event(struct hidpp_device *hidpp, in hidpp10_wheel_raw_event() argument
2991 if (!hidpp->input) in hidpp10_wheel_raw_event()
3003 input_report_rel(hidpp->input, REL_WHEEL, value); in hidpp10_wheel_raw_event()
3004 input_report_rel(hidpp->input, REL_WHEEL_HI_RES, value * 120); in hidpp10_wheel_raw_event()
3005 input_report_rel(hidpp->input, REL_HWHEEL, hvalue); in hidpp10_wheel_raw_event()
3006 input_report_rel(hidpp->input, REL_HWHEEL_HI_RES, hvalue * 120); in hidpp10_wheel_raw_event()
3007 input_sync(hidpp->input); in hidpp10_wheel_raw_event()
3012 static void hidpp10_wheel_populate_input(struct hidpp_device *hidpp, in hidpp10_wheel_populate_input() argument
3025 static int hidpp10_extra_mouse_buttons_connect(struct hidpp_device *hidpp) in hidpp10_extra_mouse_buttons_connect() argument
3027 return hidpp10_set_register(hidpp, HIDPP_REG_ENABLE_REPORTS, 0, in hidpp10_extra_mouse_buttons_connect()
3032 static int hidpp10_extra_mouse_buttons_raw_event(struct hidpp_device *hidpp, in hidpp10_extra_mouse_buttons_raw_event() argument
3037 if (!hidpp->input) in hidpp10_extra_mouse_buttons_raw_event()
3054 input_report_key(hidpp->input, BTN_MOUSE + i, in hidpp10_extra_mouse_buttons_raw_event()
3059 input_report_key(hidpp->input, BTN_MISC + i, in hidpp10_extra_mouse_buttons_raw_event()
3062 input_sync(hidpp->input); in hidpp10_extra_mouse_buttons_raw_event()
3067 struct hidpp_device *hidpp, struct input_dev *input_dev) in hidpp10_extra_mouse_buttons_populate_input() argument
3085 static u8 *hidpp10_consumer_keys_report_fixup(struct hidpp_device *hidpp, in hidpp10_consumer_keys_report_fixup() argument
3113 static int hidpp10_consumer_keys_connect(struct hidpp_device *hidpp) in hidpp10_consumer_keys_connect() argument
3115 return hidpp10_set_register(hidpp, HIDPP_REG_ENABLE_REPORTS, 0, in hidpp10_consumer_keys_connect()
3120 static int hidpp10_consumer_keys_raw_event(struct hidpp_device *hidpp, in hidpp10_consumer_keys_raw_event() argument
3139 hid_report_raw_event(hidpp->hid_dev, HID_INPUT_REPORT, in hidpp10_consumer_keys_raw_event()
3149 static int hi_res_scroll_enable(struct hidpp_device *hidpp) in hi_res_scroll_enable() argument
3154 if (hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL_X2121) { in hi_res_scroll_enable()
3155 ret = hidpp_hrw_set_wheel_mode(hidpp, false, true, false); in hi_res_scroll_enable()
3157 ret = hidpp_hrw_get_wheel_capability(hidpp, &multiplier); in hi_res_scroll_enable()
3158 } else if (hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL_X2120) { in hi_res_scroll_enable()
3159 ret = hidpp_hrs_set_highres_scrolling_mode(hidpp, true, in hi_res_scroll_enable()
3162 ret = hidpp10_enable_scrolling_acceleration(hidpp); in hi_res_scroll_enable()
3171 hidpp->vertical_wheel_counter.wheel_multiplier = multiplier; in hi_res_scroll_enable()
3172 hid_dbg(hidpp->hid_dev, "wheel multiplier = %d\n", multiplier); in hi_res_scroll_enable()
3183 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_report_fixup() local
3185 if (!hidpp) in hidpp_report_fixup()
3190 (hidpp->quirks & HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS)) in hidpp_report_fixup()
3191 rdesc = hidpp10_consumer_keys_report_fixup(hidpp, rdesc, rsize); in hidpp_report_fixup()
3200 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_input_mapping() local
3202 if (!hidpp) in hidpp_input_mapping()
3205 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) in hidpp_input_mapping()
3207 else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560 && in hidpp_input_mapping()
3221 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_input_mapped() local
3223 if (!hidpp) in hidpp_input_mapped()
3227 if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) { in hidpp_input_mapped()
3239 static void hidpp_populate_input(struct hidpp_device *hidpp, in hidpp_populate_input() argument
3242 hidpp->input = input; in hidpp_populate_input()
3244 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) in hidpp_populate_input()
3245 wtp_populate_input(hidpp, input); in hidpp_populate_input()
3246 else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) in hidpp_populate_input()
3247 m560_populate_input(hidpp, input); in hidpp_populate_input()
3249 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_WHEELS) in hidpp_populate_input()
3250 hidpp10_wheel_populate_input(hidpp, input); in hidpp_populate_input()
3252 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_EXTRA_MOUSE_BTNS) in hidpp_populate_input()
3253 hidpp10_extra_mouse_buttons_populate_input(hidpp, input); in hidpp_populate_input()
3259 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_input_configured() local
3262 if (!hidpp) in hidpp_input_configured()
3265 hidpp_populate_input(hidpp, input); in hidpp_input_configured()
3270 static int hidpp_raw_hidpp_event(struct hidpp_device *hidpp, u8 *data, in hidpp_raw_hidpp_event() argument
3273 struct hidpp_report *question = hidpp->send_receive_buf; in hidpp_raw_hidpp_event()
3274 struct hidpp_report *answer = hidpp->send_receive_buf; in hidpp_raw_hidpp_event()
3282 if (unlikely(mutex_is_locked(&hidpp->send_mutex))) { in hidpp_raw_hidpp_event()
3290 hidpp->answer_available = true; in hidpp_raw_hidpp_event()
3291 wake_up(&hidpp->wait); in hidpp_raw_hidpp_event()
3302 if (unlikely(hidpp_report_is_connect_event(hidpp, report))) { in hidpp_raw_hidpp_event()
3303 atomic_set(&hidpp->connected, in hidpp_raw_hidpp_event()
3305 if (schedule_work(&hidpp->work) == 0) in hidpp_raw_hidpp_event()
3310 if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_BATTERY) { in hidpp_raw_hidpp_event()
3311 ret = hidpp20_battery_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3314 ret = hidpp_solar_battery_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3317 ret = hidpp20_battery_voltage_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3322 if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP10_BATTERY) { in hidpp_raw_hidpp_event()
3323 ret = hidpp10_battery_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3328 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_WHEELS) { in hidpp_raw_hidpp_event()
3329 ret = hidpp10_wheel_raw_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3334 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_EXTRA_MOUSE_BTNS) { in hidpp_raw_hidpp_event()
3335 ret = hidpp10_extra_mouse_buttons_raw_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3340 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS) { in hidpp_raw_hidpp_event()
3341 ret = hidpp10_consumer_keys_raw_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3352 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_raw_event() local
3355 if (!hidpp) in hidpp_raw_event()
3361 if (size != hidpp->very_long_report_length) { in hidpp_raw_event()
3366 ret = hidpp_raw_hidpp_event(hidpp, data, size); in hidpp_raw_event()
3374 ret = hidpp_raw_hidpp_event(hidpp, data, size); in hidpp_raw_event()
3382 ret = hidpp_raw_hidpp_event(hidpp, data, size); in hidpp_raw_event()
3391 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) in hidpp_raw_event()
3393 else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) in hidpp_raw_event()
3405 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_event() local
3408 if (!hidpp) in hidpp_event()
3411 counter = &hidpp->vertical_wheel_counter; in hidpp_event()
3417 if (!(hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL) || value == 0 in hidpp_event()
3418 || hidpp->input == NULL || counter->wheel_multiplier == 0) in hidpp_event()
3421 hidpp_scroll_counter_handle_scroll(hidpp->input, counter, value); in hidpp_event()
3425 static int hidpp_initialize_battery(struct hidpp_device *hidpp) in hidpp_initialize_battery() argument
3428 struct power_supply_config cfg = { .drv_data = hidpp }; in hidpp_initialize_battery()
3429 struct power_supply_desc *desc = &hidpp->battery.desc; in hidpp_initialize_battery()
3436 if (hidpp->battery.ps) in hidpp_initialize_battery()
3439 hidpp->battery.feature_index = 0xff; in hidpp_initialize_battery()
3440 hidpp->battery.solar_feature_index = 0xff; in hidpp_initialize_battery()
3441 hidpp->battery.voltage_feature_index = 0xff; in hidpp_initialize_battery()
3443 if (hidpp->protocol_major >= 2) { in hidpp_initialize_battery()
3444 if (hidpp->quirks & HIDPP_QUIRK_CLASS_K750) in hidpp_initialize_battery()
3445 ret = hidpp_solar_request_battery_event(hidpp); in hidpp_initialize_battery()
3447 ret = hidpp20_query_battery_voltage_info(hidpp); in hidpp_initialize_battery()
3449 ret = hidpp20_query_battery_info(hidpp); in hidpp_initialize_battery()
3454 hidpp->capabilities |= HIDPP_CAPABILITY_HIDPP20_BATTERY; in hidpp_initialize_battery()
3456 ret = hidpp10_query_battery_status(hidpp); in hidpp_initialize_battery()
3458 ret = hidpp10_query_battery_mileage(hidpp); in hidpp_initialize_battery()
3461 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_MILEAGE; in hidpp_initialize_battery()
3463 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS; in hidpp_initialize_battery()
3465 hidpp->capabilities |= HIDPP_CAPABILITY_HIDPP10_BATTERY; in hidpp_initialize_battery()
3468 battery_props = devm_kmemdup(&hidpp->hid_dev->dev, in hidpp_initialize_battery()
3477 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_MILEAGE) in hidpp_initialize_battery()
3481 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS) in hidpp_initialize_battery()
3485 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_VOLTAGE) in hidpp_initialize_battery()
3489 battery = &hidpp->battery; in hidpp_initialize_battery()
3500 battery->ps = devm_power_supply_register(&hidpp->hid_dev->dev, in hidpp_initialize_battery()
3506 power_supply_powers(battery->ps, &hidpp->hid_dev->dev); in hidpp_initialize_battery()
3513 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_overwrite_name() local
3516 if (hidpp->protocol_major < 2) in hidpp_overwrite_name()
3519 name = hidpp_get_device_name(hidpp); in hidpp_overwrite_name()
3548 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_allocate_input() local
3557 input_dev->name = hidpp->name; in hidpp_allocate_input()
3569 static void hidpp_connect_event(struct hidpp_device *hidpp) in hidpp_connect_event() argument
3571 struct hid_device *hdev = hidpp->hid_dev; in hidpp_connect_event()
3573 bool connected = atomic_read(&hidpp->connected); in hidpp_connect_event()
3578 if (hidpp->battery.ps) { in hidpp_connect_event()
3579 hidpp->battery.online = false; in hidpp_connect_event()
3580 hidpp->battery.status = POWER_SUPPLY_STATUS_UNKNOWN; in hidpp_connect_event()
3581 hidpp->battery.level = POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN; in hidpp_connect_event()
3582 power_supply_changed(hidpp->battery.ps); in hidpp_connect_event()
3587 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) { in hidpp_connect_event()
3591 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) { in hidpp_connect_event()
3595 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_K400) { in hidpp_connect_event()
3601 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_WHEELS) { in hidpp_connect_event()
3602 ret = hidpp10_wheel_connect(hidpp); in hidpp_connect_event()
3607 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_EXTRA_MOUSE_BTNS) { in hidpp_connect_event()
3608 ret = hidpp10_extra_mouse_buttons_connect(hidpp); in hidpp_connect_event()
3613 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS) { in hidpp_connect_event()
3614 ret = hidpp10_consumer_keys_connect(hidpp); in hidpp_connect_event()
3621 if (!hidpp->protocol_major) { in hidpp_connect_event()
3622 ret = hidpp_root_get_protocol_version(hidpp); in hidpp_connect_event()
3629 if (hidpp->name == hdev->name && hidpp->protocol_major >= 2) { in hidpp_connect_event()
3630 name = hidpp_get_device_name(hidpp); in hidpp_connect_event()
3638 hidpp->name = devm_name; in hidpp_connect_event()
3642 hidpp_initialize_battery(hidpp); in hidpp_connect_event()
3645 if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP10_BATTERY) { in hidpp_connect_event()
3646 hidpp10_enable_battery_reporting(hidpp); in hidpp_connect_event()
3647 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_MILEAGE) in hidpp_connect_event()
3648 hidpp10_query_battery_mileage(hidpp); in hidpp_connect_event()
3650 hidpp10_query_battery_status(hidpp); in hidpp_connect_event()
3651 } else if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_BATTERY) { in hidpp_connect_event()
3652 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_VOLTAGE) in hidpp_connect_event()
3653 hidpp20_query_battery_voltage_info(hidpp); in hidpp_connect_event()
3655 hidpp20_query_battery_info(hidpp); in hidpp_connect_event()
3657 if (hidpp->battery.ps) in hidpp_connect_event()
3658 power_supply_changed(hidpp->battery.ps); in hidpp_connect_event()
3660 if (hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL) in hidpp_connect_event()
3661 hi_res_scroll_enable(hidpp); in hidpp_connect_event()
3663 if (!(hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT) || hidpp->delayed_input) in hidpp_connect_event()
3673 hidpp_populate_input(hidpp, input); in hidpp_connect_event()
3679 hidpp->delayed_input = input; in hidpp_connect_event()
3708 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_validate_device() local
3738 hidpp->very_long_report_length = report_length; in hidpp_validate_device()
3761 struct hidpp_device *hidpp; in hidpp_probe() local
3768 hidpp = devm_kzalloc(&hdev->dev, sizeof(*hidpp), GFP_KERNEL); in hidpp_probe()
3769 if (!hidpp) in hidpp_probe()
3772 hidpp->hid_dev = hdev; in hidpp_probe()
3773 hidpp->name = hdev->name; in hidpp_probe()
3774 hidpp->quirks = id->driver_data; in hidpp_probe()
3775 hid_set_drvdata(hdev, hidpp); in hidpp_probe()
3786 hidpp->supported_reports = hidpp_validate_device(hdev); in hidpp_probe()
3788 if (!hidpp->supported_reports) { in hidpp_probe()
3790 devm_kfree(&hdev->dev, hidpp); in hidpp_probe()
3795 hidpp->quirks |= HIDPP_QUIRK_UNIFYING; in hidpp_probe()
3799 hidpp->quirks |= HIDPP_QUIRK_HIDPP_WHEELS | in hidpp_probe()
3804 hidpp->quirks |= HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS; in hidpp_probe()
3807 hidpp->quirks &= ~HIDPP_QUIRK_CLASS_WTP; in hidpp_probe()
3808 hidpp->quirks &= ~HIDPP_QUIRK_NO_HIDINPUT; in hidpp_probe()
3811 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) { in hidpp_probe()
3815 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_K400) { in hidpp_probe()
3821 INIT_WORK(&hidpp->work, delayed_work_cb); in hidpp_probe()
3822 mutex_init(&hidpp->send_mutex); in hidpp_probe()
3823 init_waitqueue_head(&hidpp->wait); in hidpp_probe()
3851 if (hidpp->quirks & HIDPP_QUIRK_UNIFYING) in hidpp_probe()
3852 hidpp_unifying_init(hidpp); in hidpp_probe()
3854 connected = hidpp_root_get_protocol_version(hidpp) == 0; in hidpp_probe()
3855 atomic_set(&hidpp->connected, connected); in hidpp_probe()
3856 if (!(hidpp->quirks & HIDPP_QUIRK_UNIFYING)) { in hidpp_probe()
3866 if (connected && hidpp->protocol_major >= 2) { in hidpp_probe()
3867 ret = hidpp_set_wireless_feature_index(hidpp); in hidpp_probe()
3869 hidpp->wireless_feature_index = 0; in hidpp_probe()
3874 if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)) { in hidpp_probe()
3875 ret = wtp_get_config(hidpp); in hidpp_probe()
3878 } else if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_G920)) { in hidpp_probe()
3879 ret = g920_get_config(hidpp, &data); in hidpp_probe()
3884 hidpp_connect_event(hidpp); in hidpp_probe()
3891 if (hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT) in hidpp_probe()
3901 if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) { in hidpp_probe()
3902 ret = hidpp_ff_init(hidpp, &data); in hidpp_probe()
3904 hid_warn(hidpp->hid_dev, in hidpp_probe()
3917 cancel_work_sync(&hidpp->work); in hidpp_probe()
3918 mutex_destroy(&hidpp->send_mutex); in hidpp_probe()
3924 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_remove() local
3926 if (!hidpp) in hidpp_remove()
3932 cancel_work_sync(&hidpp->work); in hidpp_remove()
3933 mutex_destroy(&hidpp->send_mutex); in hidpp_remove()