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()
1298 static int hidpp20_battery_get_battery_voltage(struct hidpp_device *hidpp, in hidpp20_battery_get_battery_voltage() argument
1307 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp20_battery_get_battery_voltage()
1312 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_battery_get_battery_voltage()
1319 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_VOLTAGE; in hidpp20_battery_get_battery_voltage()
1327 static int hidpp20_query_battery_voltage_info(struct hidpp_device *hidpp) in hidpp20_query_battery_voltage_info() argument
1333 if (hidpp->battery.voltage_feature_index == 0xff) { in hidpp20_query_battery_voltage_info()
1334 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_BATTERY_VOLTAGE, in hidpp20_query_battery_voltage_info()
1335 &hidpp->battery.voltage_feature_index, in hidpp20_query_battery_voltage_info()
1341 ret = hidpp20_battery_get_battery_voltage(hidpp, in hidpp20_query_battery_voltage_info()
1342 hidpp->battery.voltage_feature_index, in hidpp20_query_battery_voltage_info()
1348 hidpp->battery.status = status; in hidpp20_query_battery_voltage_info()
1349 hidpp->battery.voltage = voltage; in hidpp20_query_battery_voltage_info()
1350 hidpp->battery.level = level; in hidpp20_query_battery_voltage_info()
1351 hidpp->battery.charge_type = charge_type; in hidpp20_query_battery_voltage_info()
1352 hidpp->battery.online = status != POWER_SUPPLY_STATUS_NOT_CHARGING; in hidpp20_query_battery_voltage_info()
1357 static int hidpp20_battery_voltage_event(struct hidpp_device *hidpp, in hidpp20_battery_voltage_event() argument
1363 if (report->fap.feature_index != hidpp->battery.voltage_feature_index || in hidpp20_battery_voltage_event()
1370 hidpp->battery.online = status != POWER_SUPPLY_STATUS_NOT_CHARGING; in hidpp20_battery_voltage_event()
1372 if (voltage != hidpp->battery.voltage || status != hidpp->battery.status) { in hidpp20_battery_voltage_event()
1373 hidpp->battery.voltage = voltage; in hidpp20_battery_voltage_event()
1374 hidpp->battery.status = status; in hidpp20_battery_voltage_event()
1375 hidpp->battery.level = level; in hidpp20_battery_voltage_event()
1376 hidpp->battery.charge_type = charge_type; in hidpp20_battery_voltage_event()
1377 if (hidpp->battery.ps) in hidpp20_battery_voltage_event()
1378 power_supply_changed(hidpp->battery.ps); in hidpp20_battery_voltage_event()
1399 struct hidpp_device *hidpp = power_supply_get_drvdata(psy); in hidpp_battery_get_property() local
1404 val->intval = hidpp->battery.status; in hidpp_battery_get_property()
1407 val->intval = hidpp->battery.capacity; in hidpp_battery_get_property()
1410 val->intval = hidpp->battery.level; in hidpp_battery_get_property()
1416 val->intval = hidpp->battery.online; in hidpp_battery_get_property()
1419 if (!strncmp(hidpp->name, "Logitech ", 9)) in hidpp_battery_get_property()
1420 val->strval = hidpp->name + 9; in hidpp_battery_get_property()
1422 val->strval = hidpp->name; in hidpp_battery_get_property()
1428 val->strval = hidpp->hid_dev->uniq; in hidpp_battery_get_property()
1432 val->intval = hidpp->battery.voltage * 1000; in hidpp_battery_get_property()
1435 val->intval = hidpp->battery.charge_type; in hidpp_battery_get_property()
1450 static int hidpp_set_wireless_feature_index(struct hidpp_device *hidpp) in hidpp_set_wireless_feature_index() argument
1455 ret = hidpp_root_get_feature(hidpp, in hidpp_set_wireless_feature_index()
1457 &hidpp->wireless_feature_index, in hidpp_set_wireless_feature_index()
1471 static int hidpp_hrs_set_highres_scrolling_mode(struct hidpp_device *hidpp, in hidpp_hrs_set_highres_scrolling_mode() argument
1480 ret = hidpp_root_get_feature(hidpp, in hidpp_hrs_set_highres_scrolling_mode()
1488 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_hrs_set_highres_scrolling_mode()
1506 static int hidpp_hrw_get_wheel_capability(struct hidpp_device *hidpp, in hidpp_hrw_get_wheel_capability() argument
1514 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_HIRES_WHEEL, in hidpp_hrw_get_wheel_capability()
1519 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_hrw_get_wheel_capability()
1528 hid_warn(hidpp->hid_dev, in hidpp_hrw_get_wheel_capability()
1533 static int hidpp_hrw_set_wheel_mode(struct hidpp_device *hidpp, bool invert, in hidpp_hrw_set_wheel_mode() argument
1542 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_HIRES_WHEEL, in hidpp_hrw_set_wheel_mode()
1551 return hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_hrw_set_wheel_mode()
1568 static int hidpp_solar_request_battery_event(struct hidpp_device *hidpp) in hidpp_solar_request_battery_event() argument
1575 if (hidpp->battery.feature_index == 0xff) { in hidpp_solar_request_battery_event()
1576 ret = hidpp_root_get_feature(hidpp, in hidpp_solar_request_battery_event()
1578 &hidpp->battery.solar_feature_index, in hidpp_solar_request_battery_event()
1584 ret = hidpp_send_fap_command_sync(hidpp, in hidpp_solar_request_battery_event()
1585 hidpp->battery.solar_feature_index, in hidpp_solar_request_battery_event()
1589 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_solar_request_battery_event()
1596 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_MILEAGE; in hidpp_solar_request_battery_event()
1601 static int hidpp_solar_battery_event(struct hidpp_device *hidpp, in hidpp_solar_battery_event() argument
1611 if (report->fap.feature_index != hidpp->battery.solar_feature_index || in hidpp_solar_battery_event()
1629 if (capacity < hidpp->battery.capacity) in hidpp_solar_battery_event()
1639 hidpp->battery.online = true; in hidpp_solar_battery_event()
1640 if (capacity != hidpp->battery.capacity || in hidpp_solar_battery_event()
1641 status != hidpp->battery.status) { in hidpp_solar_battery_event()
1642 hidpp->battery.capacity = capacity; in hidpp_solar_battery_event()
1643 hidpp->battery.status = status; in hidpp_solar_battery_event()
1644 if (hidpp->battery.ps) in hidpp_solar_battery_event()
1645 power_supply_changed(hidpp->battery.ps); in hidpp_solar_battery_event()
1670 static int hidpp_touchpad_fw_items_set(struct hidpp_device *hidpp, in hidpp_touchpad_fw_items_set() argument
1678 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_touchpad_fw_items_set()
1682 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_touchpad_fw_items_set()
1741 static int hidpp_touchpad_get_raw_info(struct hidpp_device *hidpp, in hidpp_touchpad_get_raw_info() argument
1748 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_touchpad_get_raw_info()
1752 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_touchpad_get_raw_info()
1865 struct hidpp_device *hidpp; member
1957 ret = hidpp_send_fap_command_sync(data->hidpp, data->feature_index, in hidpp_ff_work_handler()
1961 hid_err(data->hidpp->hid_dev, "Failed to send command to device!\n"); in hidpp_ff_work_handler()
2024 …hid_warn(data->hidpp->hid_dev, "Force feedback command queue contains %d commands, causing substan… in hidpp_ff_queue_work()
2083 …hid_err(data->hidpp->hid_dev, "Unexpected periodic waveform type %i!\n", effect->u.periodic.wavefo… in hidpp_ff_upload_effect()
2168 hid_err(data->hidpp->hid_dev, "Unexpected force type %i!\n", effect->type); in hidpp_ff_upload_effect()
2268 struct hid_device *hid = data->hidpp->hid_dev; in hidpp_ff_destroy()
2277 static int hidpp_ff_init(struct hidpp_device *hidpp, in hidpp_ff_init() argument
2280 struct hid_device *hid = hidpp->hid_dev; in hidpp_ff_init()
2336 data->hidpp = hidpp; in hidpp_ff_init()
2352 error = device_create_file(&(hidpp->hid_dev->dev), &dev_attr_range); in hidpp_ff_init()
2354 hid_warn(hidpp->hid_dev, "Unable to create sysfs interface for \"range\", errno %d!\n", error); in hidpp_ff_init()
2394 static void wtp_populate_input(struct hidpp_device *hidpp, in wtp_populate_input() argument
2397 struct wtp_data *wd = hidpp->private_data; in wtp_populate_input()
2414 if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS) in wtp_populate_input()
2423 static void wtp_touch_event(struct hidpp_device *hidpp, in wtp_touch_event() argument
2426 struct wtp_data *wd = hidpp->private_data; in wtp_touch_event()
2433 slot = input_mt_get_slot_by_key(hidpp->input, touch_report->finger_id); in wtp_touch_event()
2435 input_mt_slot(hidpp->input, slot); in wtp_touch_event()
2436 input_mt_report_slot_state(hidpp->input, MT_TOOL_FINGER, in wtp_touch_event()
2439 input_event(hidpp->input, EV_ABS, ABS_MT_POSITION_X, in wtp_touch_event()
2441 input_event(hidpp->input, EV_ABS, ABS_MT_POSITION_Y, in wtp_touch_event()
2444 input_event(hidpp->input, EV_ABS, ABS_MT_PRESSURE, in wtp_touch_event()
2449 static void wtp_send_raw_xy_event(struct hidpp_device *hidpp, in wtp_send_raw_xy_event() argument
2455 wtp_touch_event(hidpp, &(raw->fingers[i])); in wtp_send_raw_xy_event()
2458 !(hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS)) in wtp_send_raw_xy_event()
2459 input_event(hidpp->input, EV_KEY, BTN_LEFT, raw->button); in wtp_send_raw_xy_event()
2462 input_mt_sync_frame(hidpp->input); in wtp_send_raw_xy_event()
2463 input_sync(hidpp->input); in wtp_send_raw_xy_event()
2467 static int wtp_mouse_raw_xy_event(struct hidpp_device *hidpp, u8 *data) in wtp_mouse_raw_xy_event() argument
2469 struct wtp_data *wd = hidpp->private_data; in wtp_mouse_raw_xy_event()
2501 wtp_send_raw_xy_event(hidpp, &raw); in wtp_mouse_raw_xy_event()
2508 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in wtp_raw_event() local
2509 struct wtp_data *wd = hidpp->private_data; in wtp_raw_event()
2513 if (!wd || !hidpp->input) in wtp_raw_event()
2523 if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS) { in wtp_raw_event()
2524 input_event(hidpp->input, EV_KEY, BTN_LEFT, in wtp_raw_event()
2526 input_event(hidpp->input, EV_KEY, BTN_RIGHT, in wtp_raw_event()
2528 input_sync(hidpp->input); in wtp_raw_event()
2533 return wtp_mouse_raw_xy_event(hidpp, &data[7]); in wtp_raw_event()
2540 hidpp_touchpad_raw_xy_event(hidpp, data + 4, &raw); in wtp_raw_event()
2542 wtp_send_raw_xy_event(hidpp, &raw); in wtp_raw_event()
2549 static int wtp_get_config(struct hidpp_device *hidpp) in wtp_get_config() argument
2551 struct wtp_data *wd = hidpp->private_data; in wtp_get_config()
2556 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_TOUCHPAD_RAW_XY, in wtp_get_config()
2562 ret = hidpp_touchpad_get_raw_info(hidpp, wd->mt_feature_index, in wtp_get_config()
2580 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in wtp_allocate() local
2588 hidpp->private_data = wd; in wtp_allocate()
2595 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in wtp_connect() local
2596 struct wtp_data *wd = hidpp->private_data; in wtp_connect()
2600 ret = wtp_get_config(hidpp); in wtp_connect()
2607 return hidpp_touchpad_set_raw_report_state(hidpp, wd->mt_feature_index, in wtp_connect()
2675 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in m560_raw_event() local
2678 if (!hidpp->input) { in m560_raw_event()
2705 input_report_key(hidpp->input, BTN_MIDDLE, 1); in m560_raw_event()
2708 input_report_key(hidpp->input, BTN_FORWARD, 1); in m560_raw_event()
2711 input_report_key(hidpp->input, BTN_BACK, 1); in m560_raw_event()
2714 input_report_key(hidpp->input, BTN_BACK, 0); in m560_raw_event()
2715 input_report_key(hidpp->input, BTN_FORWARD, 0); in m560_raw_event()
2716 input_report_key(hidpp->input, BTN_MIDDLE, 0); in m560_raw_event()
2722 input_sync(hidpp->input); in m560_raw_event()
2736 input_report_key(hidpp->input, BTN_LEFT, in m560_raw_event()
2738 input_report_key(hidpp->input, BTN_RIGHT, in m560_raw_event()
2742 input_report_rel(hidpp->input, REL_HWHEEL, -1); in m560_raw_event()
2743 input_report_rel(hidpp->input, REL_HWHEEL_HI_RES, in m560_raw_event()
2746 input_report_rel(hidpp->input, REL_HWHEEL, 1); in m560_raw_event()
2747 input_report_rel(hidpp->input, REL_HWHEEL_HI_RES, in m560_raw_event()
2752 input_report_rel(hidpp->input, REL_X, v); in m560_raw_event()
2755 input_report_rel(hidpp->input, REL_Y, v); in m560_raw_event()
2759 hidpp_scroll_counter_handle_scroll(hidpp->input, in m560_raw_event()
2760 &hidpp->vertical_wheel_counter, v); in m560_raw_event()
2762 input_sync(hidpp->input); in m560_raw_event()
2768 static void m560_populate_input(struct hidpp_device *hidpp, in m560_populate_input() argument
2812 static int k400_disable_tap_to_click(struct hidpp_device *hidpp) in k400_disable_tap_to_click() argument
2814 struct k400_private_data *k400 = hidpp->private_data; in k400_disable_tap_to_click()
2820 ret = hidpp_root_get_feature(hidpp, in k400_disable_tap_to_click()
2828 ret = hidpp_touchpad_fw_items_set(hidpp, k400->feature_index, &items); in k400_disable_tap_to_click()
2837 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in k400_allocate() local
2845 hidpp->private_data = k400; in k400_allocate()
2852 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in k400_connect() local
2857 return k400_disable_tap_to_click(hidpp); in k400_connect()
2866 static int g920_ff_set_autocenter(struct hidpp_device *hidpp, in g920_ff_set_autocenter() argument
2878 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_ff_set_autocenter()
2883 hid_warn(hidpp->hid_dev, "Failed to autocenter device!\n"); in g920_ff_set_autocenter()
2890 static int g920_get_config(struct hidpp_device *hidpp, in g920_get_config() argument
2900 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_G920_FORCE_FEEDBACK, in g920_get_config()
2906 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_get_config()
2913 hid_err(hidpp->hid_dev, in g920_get_config()
2921 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_get_config()
2926 hid_warn(hidpp->hid_dev, "Failed to reset all forces!\n"); in g920_get_config()
2928 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_get_config()
2933 hid_warn(hidpp->hid_dev, in g920_get_config()
2940 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_get_config()
2945 hid_warn(hidpp->hid_dev, in g920_get_config()
2952 return g920_ff_set_autocenter(hidpp, data); in g920_get_config()
2978 static int hidpp10_wheel_connect(struct hidpp_device *hidpp) in hidpp10_wheel_connect() argument
2980 return hidpp10_set_register(hidpp, HIDPP_REG_ENABLE_REPORTS, 0, in hidpp10_wheel_connect()
2985 static int hidpp10_wheel_raw_event(struct hidpp_device *hidpp, in hidpp10_wheel_raw_event() argument
2990 if (!hidpp->input) in hidpp10_wheel_raw_event()
3002 input_report_rel(hidpp->input, REL_WHEEL, value); in hidpp10_wheel_raw_event()
3003 input_report_rel(hidpp->input, REL_WHEEL_HI_RES, value * 120); in hidpp10_wheel_raw_event()
3004 input_report_rel(hidpp->input, REL_HWHEEL, hvalue); in hidpp10_wheel_raw_event()
3005 input_report_rel(hidpp->input, REL_HWHEEL_HI_RES, hvalue * 120); in hidpp10_wheel_raw_event()
3006 input_sync(hidpp->input); in hidpp10_wheel_raw_event()
3011 static void hidpp10_wheel_populate_input(struct hidpp_device *hidpp, in hidpp10_wheel_populate_input() argument
3024 static int hidpp10_extra_mouse_buttons_connect(struct hidpp_device *hidpp) in hidpp10_extra_mouse_buttons_connect() argument
3026 return hidpp10_set_register(hidpp, HIDPP_REG_ENABLE_REPORTS, 0, in hidpp10_extra_mouse_buttons_connect()
3031 static int hidpp10_extra_mouse_buttons_raw_event(struct hidpp_device *hidpp, in hidpp10_extra_mouse_buttons_raw_event() argument
3036 if (!hidpp->input) in hidpp10_extra_mouse_buttons_raw_event()
3053 input_report_key(hidpp->input, BTN_MOUSE + i, in hidpp10_extra_mouse_buttons_raw_event()
3058 input_report_key(hidpp->input, BTN_MISC + i, in hidpp10_extra_mouse_buttons_raw_event()
3061 input_sync(hidpp->input); in hidpp10_extra_mouse_buttons_raw_event()
3066 struct hidpp_device *hidpp, struct input_dev *input_dev) in hidpp10_extra_mouse_buttons_populate_input() argument
3084 static u8 *hidpp10_consumer_keys_report_fixup(struct hidpp_device *hidpp, in hidpp10_consumer_keys_report_fixup() argument
3112 static int hidpp10_consumer_keys_connect(struct hidpp_device *hidpp) in hidpp10_consumer_keys_connect() argument
3114 return hidpp10_set_register(hidpp, HIDPP_REG_ENABLE_REPORTS, 0, in hidpp10_consumer_keys_connect()
3119 static int hidpp10_consumer_keys_raw_event(struct hidpp_device *hidpp, in hidpp10_consumer_keys_raw_event() argument
3138 hid_report_raw_event(hidpp->hid_dev, HID_INPUT_REPORT, in hidpp10_consumer_keys_raw_event()
3148 static int hi_res_scroll_enable(struct hidpp_device *hidpp) in hi_res_scroll_enable() argument
3153 if (hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL_X2121) { in hi_res_scroll_enable()
3154 ret = hidpp_hrw_set_wheel_mode(hidpp, false, true, false); in hi_res_scroll_enable()
3156 ret = hidpp_hrw_get_wheel_capability(hidpp, &multiplier); in hi_res_scroll_enable()
3157 } else if (hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL_X2120) { in hi_res_scroll_enable()
3158 ret = hidpp_hrs_set_highres_scrolling_mode(hidpp, true, in hi_res_scroll_enable()
3161 ret = hidpp10_enable_scrolling_acceleration(hidpp); in hi_res_scroll_enable()
3170 hidpp->vertical_wheel_counter.wheel_multiplier = multiplier; in hi_res_scroll_enable()
3171 hid_dbg(hidpp->hid_dev, "wheel multiplier = %d\n", multiplier); in hi_res_scroll_enable()
3182 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_report_fixup() local
3184 if (!hidpp) in hidpp_report_fixup()
3189 (hidpp->quirks & HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS)) in hidpp_report_fixup()
3190 rdesc = hidpp10_consumer_keys_report_fixup(hidpp, rdesc, rsize); in hidpp_report_fixup()
3199 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_input_mapping() local
3201 if (!hidpp) in hidpp_input_mapping()
3204 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) in hidpp_input_mapping()
3206 else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560 && in hidpp_input_mapping()
3220 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_input_mapped() local
3222 if (!hidpp) in hidpp_input_mapped()
3226 if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) { in hidpp_input_mapped()
3238 static void hidpp_populate_input(struct hidpp_device *hidpp, in hidpp_populate_input() argument
3241 hidpp->input = input; in hidpp_populate_input()
3243 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) in hidpp_populate_input()
3244 wtp_populate_input(hidpp, input); in hidpp_populate_input()
3245 else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) in hidpp_populate_input()
3246 m560_populate_input(hidpp, input); in hidpp_populate_input()
3248 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_WHEELS) in hidpp_populate_input()
3249 hidpp10_wheel_populate_input(hidpp, input); in hidpp_populate_input()
3251 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_EXTRA_MOUSE_BTNS) in hidpp_populate_input()
3252 hidpp10_extra_mouse_buttons_populate_input(hidpp, input); in hidpp_populate_input()
3258 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_input_configured() local
3261 if (!hidpp) in hidpp_input_configured()
3264 hidpp_populate_input(hidpp, input); in hidpp_input_configured()
3269 static int hidpp_raw_hidpp_event(struct hidpp_device *hidpp, u8 *data, in hidpp_raw_hidpp_event() argument
3272 struct hidpp_report *question = hidpp->send_receive_buf; in hidpp_raw_hidpp_event()
3273 struct hidpp_report *answer = hidpp->send_receive_buf; in hidpp_raw_hidpp_event()
3281 if (unlikely(mutex_is_locked(&hidpp->send_mutex))) { in hidpp_raw_hidpp_event()
3289 hidpp->answer_available = true; in hidpp_raw_hidpp_event()
3290 wake_up(&hidpp->wait); in hidpp_raw_hidpp_event()
3301 if (unlikely(hidpp_report_is_connect_event(hidpp, report))) { in hidpp_raw_hidpp_event()
3302 atomic_set(&hidpp->connected, in hidpp_raw_hidpp_event()
3304 if (schedule_work(&hidpp->work) == 0) in hidpp_raw_hidpp_event()
3309 if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_BATTERY) { in hidpp_raw_hidpp_event()
3310 ret = hidpp20_battery_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3313 ret = hidpp_solar_battery_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3316 ret = hidpp20_battery_voltage_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3321 if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP10_BATTERY) { in hidpp_raw_hidpp_event()
3322 ret = hidpp10_battery_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3327 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_WHEELS) { in hidpp_raw_hidpp_event()
3328 ret = hidpp10_wheel_raw_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3333 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_EXTRA_MOUSE_BTNS) { in hidpp_raw_hidpp_event()
3334 ret = hidpp10_extra_mouse_buttons_raw_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3339 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS) { in hidpp_raw_hidpp_event()
3340 ret = hidpp10_consumer_keys_raw_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3351 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_raw_event() local
3354 if (!hidpp) in hidpp_raw_event()
3360 if (size != hidpp->very_long_report_length) { in hidpp_raw_event()
3365 ret = hidpp_raw_hidpp_event(hidpp, data, size); in hidpp_raw_event()
3373 ret = hidpp_raw_hidpp_event(hidpp, data, size); in hidpp_raw_event()
3381 ret = hidpp_raw_hidpp_event(hidpp, data, size); in hidpp_raw_event()
3390 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) in hidpp_raw_event()
3392 else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) in hidpp_raw_event()
3404 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_event() local
3407 if (!hidpp) in hidpp_event()
3410 counter = &hidpp->vertical_wheel_counter; in hidpp_event()
3416 if (!(hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL) || value == 0 in hidpp_event()
3417 || hidpp->input == NULL || counter->wheel_multiplier == 0) in hidpp_event()
3420 hidpp_scroll_counter_handle_scroll(hidpp->input, counter, value); in hidpp_event()
3424 static int hidpp_initialize_battery(struct hidpp_device *hidpp) in hidpp_initialize_battery() argument
3427 struct power_supply_config cfg = { .drv_data = hidpp }; in hidpp_initialize_battery()
3428 struct power_supply_desc *desc = &hidpp->battery.desc; in hidpp_initialize_battery()
3435 if (hidpp->battery.ps) in hidpp_initialize_battery()
3438 hidpp->battery.feature_index = 0xff; in hidpp_initialize_battery()
3439 hidpp->battery.solar_feature_index = 0xff; in hidpp_initialize_battery()
3440 hidpp->battery.voltage_feature_index = 0xff; in hidpp_initialize_battery()
3442 if (hidpp->protocol_major >= 2) { in hidpp_initialize_battery()
3443 if (hidpp->quirks & HIDPP_QUIRK_CLASS_K750) in hidpp_initialize_battery()
3444 ret = hidpp_solar_request_battery_event(hidpp); in hidpp_initialize_battery()
3446 ret = hidpp20_query_battery_voltage_info(hidpp); in hidpp_initialize_battery()
3448 ret = hidpp20_query_battery_info(hidpp); in hidpp_initialize_battery()
3453 hidpp->capabilities |= HIDPP_CAPABILITY_HIDPP20_BATTERY; in hidpp_initialize_battery()
3455 ret = hidpp10_query_battery_status(hidpp); in hidpp_initialize_battery()
3457 ret = hidpp10_query_battery_mileage(hidpp); in hidpp_initialize_battery()
3460 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_MILEAGE; in hidpp_initialize_battery()
3462 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS; in hidpp_initialize_battery()
3464 hidpp->capabilities |= HIDPP_CAPABILITY_HIDPP10_BATTERY; in hidpp_initialize_battery()
3467 battery_props = devm_kmemdup(&hidpp->hid_dev->dev, in hidpp_initialize_battery()
3476 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_MILEAGE) in hidpp_initialize_battery()
3480 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS) in hidpp_initialize_battery()
3484 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_VOLTAGE) in hidpp_initialize_battery()
3488 battery = &hidpp->battery; in hidpp_initialize_battery()
3499 battery->ps = devm_power_supply_register(&hidpp->hid_dev->dev, in hidpp_initialize_battery()
3505 power_supply_powers(battery->ps, &hidpp->hid_dev->dev); in hidpp_initialize_battery()
3512 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_overwrite_name() local
3515 if (hidpp->protocol_major < 2) in hidpp_overwrite_name()
3518 name = hidpp_get_device_name(hidpp); in hidpp_overwrite_name()
3547 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_allocate_input() local
3556 input_dev->name = hidpp->name; in hidpp_allocate_input()
3568 static void hidpp_connect_event(struct hidpp_device *hidpp) in hidpp_connect_event() argument
3570 struct hid_device *hdev = hidpp->hid_dev; in hidpp_connect_event()
3572 bool connected = atomic_read(&hidpp->connected); in hidpp_connect_event()
3577 if (hidpp->battery.ps) { in hidpp_connect_event()
3578 hidpp->battery.online = false; in hidpp_connect_event()
3579 hidpp->battery.status = POWER_SUPPLY_STATUS_UNKNOWN; in hidpp_connect_event()
3580 hidpp->battery.level = POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN; in hidpp_connect_event()
3581 power_supply_changed(hidpp->battery.ps); in hidpp_connect_event()
3586 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) { in hidpp_connect_event()
3590 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) { in hidpp_connect_event()
3594 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_K400) { in hidpp_connect_event()
3600 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_WHEELS) { in hidpp_connect_event()
3601 ret = hidpp10_wheel_connect(hidpp); in hidpp_connect_event()
3606 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_EXTRA_MOUSE_BTNS) { in hidpp_connect_event()
3607 ret = hidpp10_extra_mouse_buttons_connect(hidpp); in hidpp_connect_event()
3612 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS) { in hidpp_connect_event()
3613 ret = hidpp10_consumer_keys_connect(hidpp); in hidpp_connect_event()
3620 if (!hidpp->protocol_major) { in hidpp_connect_event()
3621 ret = hidpp_root_get_protocol_version(hidpp); in hidpp_connect_event()
3628 if (hidpp->name == hdev->name && hidpp->protocol_major >= 2) { in hidpp_connect_event()
3629 name = hidpp_get_device_name(hidpp); in hidpp_connect_event()
3637 hidpp->name = devm_name; in hidpp_connect_event()
3641 hidpp_initialize_battery(hidpp); in hidpp_connect_event()
3644 if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP10_BATTERY) { in hidpp_connect_event()
3645 hidpp10_enable_battery_reporting(hidpp); in hidpp_connect_event()
3646 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_MILEAGE) in hidpp_connect_event()
3647 hidpp10_query_battery_mileage(hidpp); in hidpp_connect_event()
3649 hidpp10_query_battery_status(hidpp); in hidpp_connect_event()
3650 } else if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_BATTERY) { in hidpp_connect_event()
3651 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_VOLTAGE) in hidpp_connect_event()
3652 hidpp20_query_battery_voltage_info(hidpp); in hidpp_connect_event()
3654 hidpp20_query_battery_info(hidpp); in hidpp_connect_event()
3656 if (hidpp->battery.ps) in hidpp_connect_event()
3657 power_supply_changed(hidpp->battery.ps); in hidpp_connect_event()
3659 if (hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL) in hidpp_connect_event()
3660 hi_res_scroll_enable(hidpp); in hidpp_connect_event()
3662 if (!(hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT) || hidpp->delayed_input) in hidpp_connect_event()
3672 hidpp_populate_input(hidpp, input); in hidpp_connect_event()
3678 hidpp->delayed_input = input; in hidpp_connect_event()
3707 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_validate_device() local
3737 hidpp->very_long_report_length = report_length; in hidpp_validate_device()
3760 struct hidpp_device *hidpp; in hidpp_probe() local
3767 hidpp = devm_kzalloc(&hdev->dev, sizeof(*hidpp), GFP_KERNEL); in hidpp_probe()
3768 if (!hidpp) in hidpp_probe()
3771 hidpp->hid_dev = hdev; in hidpp_probe()
3772 hidpp->name = hdev->name; in hidpp_probe()
3773 hidpp->quirks = id->driver_data; in hidpp_probe()
3774 hid_set_drvdata(hdev, hidpp); in hidpp_probe()
3785 hidpp->supported_reports = hidpp_validate_device(hdev); in hidpp_probe()
3787 if (!hidpp->supported_reports) { in hidpp_probe()
3789 devm_kfree(&hdev->dev, hidpp); in hidpp_probe()
3794 hidpp->quirks |= HIDPP_QUIRK_UNIFYING; in hidpp_probe()
3798 hidpp->quirks |= HIDPP_QUIRK_HIDPP_WHEELS | in hidpp_probe()
3803 hidpp->quirks |= HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS; in hidpp_probe()
3806 hidpp->quirks &= ~HIDPP_QUIRK_CLASS_WTP; in hidpp_probe()
3807 hidpp->quirks &= ~HIDPP_QUIRK_NO_HIDINPUT; in hidpp_probe()
3810 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) { in hidpp_probe()
3814 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_K400) { in hidpp_probe()
3820 INIT_WORK(&hidpp->work, delayed_work_cb); in hidpp_probe()
3821 mutex_init(&hidpp->send_mutex); in hidpp_probe()
3822 init_waitqueue_head(&hidpp->wait); in hidpp_probe()
3850 if (hidpp->quirks & HIDPP_QUIRK_UNIFYING) in hidpp_probe()
3851 hidpp_unifying_init(hidpp); in hidpp_probe()
3853 connected = hidpp_root_get_protocol_version(hidpp) == 0; in hidpp_probe()
3854 atomic_set(&hidpp->connected, connected); in hidpp_probe()
3855 if (!(hidpp->quirks & HIDPP_QUIRK_UNIFYING)) { in hidpp_probe()
3865 if (connected && hidpp->protocol_major >= 2) { in hidpp_probe()
3866 ret = hidpp_set_wireless_feature_index(hidpp); in hidpp_probe()
3868 hidpp->wireless_feature_index = 0; in hidpp_probe()
3873 if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)) { in hidpp_probe()
3874 ret = wtp_get_config(hidpp); in hidpp_probe()
3877 } else if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_G920)) { in hidpp_probe()
3878 ret = g920_get_config(hidpp, &data); in hidpp_probe()
3883 hidpp_connect_event(hidpp); in hidpp_probe()
3890 if (hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT) in hidpp_probe()
3900 if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) { in hidpp_probe()
3901 ret = hidpp_ff_init(hidpp, &data); in hidpp_probe()
3903 hid_warn(hidpp->hid_dev, in hidpp_probe()
3916 cancel_work_sync(&hidpp->work); in hidpp_probe()
3917 mutex_destroy(&hidpp->send_mutex); in hidpp_probe()
3923 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_remove() local
3925 if (!hidpp) in hidpp_remove()
3931 cancel_work_sync(&hidpp->work); in hidpp_remove()
3932 mutex_destroy(&hidpp->send_mutex); in hidpp_remove()