Lines Matching refs:hidpp
214 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in __hidpp_send_report() local
225 fields_count = hidpp->very_long_report_length; in __hidpp_send_report()
237 if (hidpp->quirks & HIDPP_QUIRK_FORCE_OUTPUT_REPORTS) { in __hidpp_send_report()
256 static int hidpp_send_message_sync(struct hidpp_device *hidpp, in hidpp_send_message_sync() argument
262 mutex_lock(&hidpp->send_mutex); in hidpp_send_message_sync()
264 hidpp->send_receive_buf = response; in hidpp_send_message_sync()
265 hidpp->answer_available = false; in hidpp_send_message_sync()
273 ret = __hidpp_send_report(hidpp->hid_dev, message); in hidpp_send_message_sync()
281 if (!wait_event_timeout(hidpp->wait, hidpp->answer_available, in hidpp_send_message_sync()
304 mutex_unlock(&hidpp->send_mutex); in hidpp_send_message_sync()
309 static int hidpp_send_fap_command_sync(struct hidpp_device *hidpp, in hidpp_send_fap_command_sync() argument
331 ret = hidpp_send_message_sync(hidpp, message, response); in hidpp_send_fap_command_sync()
375 struct hidpp_device *hidpp = container_of(work, struct hidpp_device, in delayed_work_cb() local
377 hidpp_connect_event(hidpp); in delayed_work_cb()
620 static int hidpp10_query_battery_status(struct hidpp_device *hidpp) in hidpp10_query_battery_status() argument
625 ret = hidpp_send_rap_command_sync(hidpp, in hidpp10_query_battery_status()
633 hidpp->battery.level = in hidpp10_query_battery_status()
636 hidpp->battery.status = status; in hidpp10_query_battery_status()
638 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp10_query_battery_status()
672 static int hidpp10_query_battery_mileage(struct hidpp_device *hidpp) in hidpp10_query_battery_mileage() argument
677 ret = hidpp_send_rap_command_sync(hidpp, in hidpp10_query_battery_mileage()
685 hidpp->battery.capacity = response.rap.params[0]; in hidpp10_query_battery_mileage()
687 hidpp->battery.status = status; in hidpp10_query_battery_mileage()
689 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp10_query_battery_mileage()
695 static int hidpp10_battery_event(struct hidpp_device *hidpp, u8 *data, int size) in hidpp10_battery_event() argument
706 capacity = hidpp->battery.capacity; in hidpp10_battery_event()
712 level = hidpp->battery.level; in hidpp10_battery_event()
719 changed = capacity != hidpp->battery.capacity || in hidpp10_battery_event()
720 level != hidpp->battery.level || in hidpp10_battery_event()
721 status != hidpp->battery.status; in hidpp10_battery_event()
724 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp10_battery_event()
728 hidpp->battery.level = level; in hidpp10_battery_event()
729 hidpp->battery.status = status; in hidpp10_battery_event()
730 if (hidpp->battery.ps) in hidpp10_battery_event()
731 power_supply_changed(hidpp->battery.ps); in hidpp10_battery_event()
777 static int hidpp_unifying_get_serial(struct hidpp_device *hidpp, u32 *serial) in hidpp_unifying_get_serial() argument
783 ret = hidpp_send_rap_command_sync(hidpp, in hidpp_unifying_get_serial()
799 static int hidpp_unifying_init(struct hidpp_device *hidpp) in hidpp_unifying_init() argument
801 struct hid_device *hdev = hidpp->hid_dev; in hidpp_unifying_init()
806 ret = hidpp_unifying_get_serial(hidpp, &serial); in hidpp_unifying_init()
814 name = hidpp_unifying_get_name(hidpp); in hidpp_unifying_init()
835 static int hidpp_root_get_feature(struct hidpp_device *hidpp, u16 feature, in hidpp_root_get_feature() argument
842 ret = hidpp_send_fap_command_sync(hidpp, in hidpp_root_get_feature()
858 static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp) in hidpp_root_get_protocol_version() argument
865 ret = hidpp_send_rap_command_sync(hidpp, in hidpp_root_get_protocol_version()
872 hidpp->protocol_major = 1; in hidpp_root_get_protocol_version()
873 hidpp->protocol_minor = 0; in hidpp_root_get_protocol_version()
882 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_root_get_protocol_version()
890 hid_err(hidpp->hid_dev, "%s: ping mismatch 0x%02x != 0x%02x\n", in hidpp_root_get_protocol_version()
895 hidpp->protocol_major = response.rap.params[0]; in hidpp_root_get_protocol_version()
896 hidpp->protocol_minor = response.rap.params[1]; in hidpp_root_get_protocol_version()
899 hid_info(hidpp->hid_dev, "HID++ %u.%u device connected.\n", in hidpp_root_get_protocol_version()
900 hidpp->protocol_major, hidpp->protocol_minor); in hidpp_root_get_protocol_version()
914 static int hidpp_devicenametype_get_count(struct hidpp_device *hidpp, in hidpp_devicenametype_get_count() argument
920 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_devicenametype_get_count()
924 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_devicenametype_get_count()
936 static int hidpp_devicenametype_get_device_name(struct hidpp_device *hidpp, in hidpp_devicenametype_get_device_name() argument
943 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_devicenametype_get_device_name()
948 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_devicenametype_get_device_name()
957 count = hidpp->very_long_report_length - 4; in hidpp_devicenametype_get_device_name()
978 static char *hidpp_get_device_name(struct hidpp_device *hidpp) in hidpp_get_device_name() argument
987 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_GET_DEVICE_NAME_TYPE, in hidpp_get_device_name()
992 ret = hidpp_devicenametype_get_count(hidpp, feature_index, in hidpp_get_device_name()
1002 ret = hidpp_devicenametype_get_device_name(hidpp, in hidpp_get_device_name()
1091 static int hidpp20_batterylevel_get_battery_capacity(struct hidpp_device *hidpp, in hidpp20_batterylevel_get_battery_capacity() argument
1102 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp20_batterylevel_get_battery_capacity()
1106 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_batterylevel_get_battery_capacity()
1120 static int hidpp20_batterylevel_get_battery_info(struct hidpp_device *hidpp, in hidpp20_batterylevel_get_battery_info() argument
1128 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp20_batterylevel_get_battery_info()
1132 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_batterylevel_get_battery_info()
1143 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS; in hidpp20_batterylevel_get_battery_info()
1145 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_MILEAGE; in hidpp20_batterylevel_get_battery_info()
1150 static int hidpp20_query_battery_info(struct hidpp_device *hidpp) in hidpp20_query_battery_info() argument
1156 if (hidpp->battery.feature_index == 0xff) { in hidpp20_query_battery_info()
1157 ret = hidpp_root_get_feature(hidpp, in hidpp20_query_battery_info()
1159 &hidpp->battery.feature_index, in hidpp20_query_battery_info()
1165 ret = hidpp20_batterylevel_get_battery_capacity(hidpp, in hidpp20_query_battery_info()
1166 hidpp->battery.feature_index, in hidpp20_query_battery_info()
1172 ret = hidpp20_batterylevel_get_battery_info(hidpp, in hidpp20_query_battery_info()
1173 hidpp->battery.feature_index); in hidpp20_query_battery_info()
1177 hidpp->battery.status = status; in hidpp20_query_battery_info()
1178 hidpp->battery.capacity = capacity; in hidpp20_query_battery_info()
1179 hidpp->battery.level = level; in hidpp20_query_battery_info()
1181 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp20_query_battery_info()
1187 static int hidpp20_battery_event(struct hidpp_device *hidpp, in hidpp20_battery_event() argument
1194 if (report->fap.feature_index != hidpp->battery.feature_index || in hidpp20_battery_event()
1204 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp20_battery_event()
1207 changed = capacity != hidpp->battery.capacity || in hidpp20_battery_event()
1208 level != hidpp->battery.level || in hidpp20_battery_event()
1209 status != hidpp->battery.status; in hidpp20_battery_event()
1212 hidpp->battery.level = level; in hidpp20_battery_event()
1213 hidpp->battery.capacity = capacity; in hidpp20_battery_event()
1214 hidpp->battery.status = status; in hidpp20_battery_event()
1215 if (hidpp->battery.ps) in hidpp20_battery_event()
1216 power_supply_changed(hidpp->battery.ps); in hidpp20_battery_event()
1237 struct hidpp_device *hidpp = power_supply_get_drvdata(psy); in hidpp_battery_get_property() local
1242 val->intval = hidpp->battery.status; in hidpp_battery_get_property()
1245 val->intval = hidpp->battery.capacity; in hidpp_battery_get_property()
1248 val->intval = hidpp->battery.level; in hidpp_battery_get_property()
1254 val->intval = hidpp->battery.online; in hidpp_battery_get_property()
1257 if (!strncmp(hidpp->name, "Logitech ", 9)) in hidpp_battery_get_property()
1258 val->strval = hidpp->name + 9; in hidpp_battery_get_property()
1260 val->strval = hidpp->name; in hidpp_battery_get_property()
1266 val->strval = hidpp->hid_dev->uniq; in hidpp_battery_get_property()
1284 static int hidpp_hrs_set_highres_scrolling_mode(struct hidpp_device *hidpp, in hidpp_hrs_set_highres_scrolling_mode() argument
1293 ret = hidpp_root_get_feature(hidpp, in hidpp_hrs_set_highres_scrolling_mode()
1301 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_hrs_set_highres_scrolling_mode()
1319 static int hidpp_hrw_get_wheel_capability(struct hidpp_device *hidpp, in hidpp_hrw_get_wheel_capability() argument
1327 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_HIRES_WHEEL, in hidpp_hrw_get_wheel_capability()
1332 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_hrw_get_wheel_capability()
1341 hid_warn(hidpp->hid_dev, in hidpp_hrw_get_wheel_capability()
1346 static int hidpp_hrw_set_wheel_mode(struct hidpp_device *hidpp, bool invert, in hidpp_hrw_set_wheel_mode() argument
1355 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_HIRES_WHEEL, in hidpp_hrw_set_wheel_mode()
1364 return hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_hrw_set_wheel_mode()
1381 static int hidpp_solar_request_battery_event(struct hidpp_device *hidpp) in hidpp_solar_request_battery_event() argument
1388 if (hidpp->battery.feature_index == 0xff) { in hidpp_solar_request_battery_event()
1389 ret = hidpp_root_get_feature(hidpp, in hidpp_solar_request_battery_event()
1391 &hidpp->battery.solar_feature_index, in hidpp_solar_request_battery_event()
1397 ret = hidpp_send_fap_command_sync(hidpp, in hidpp_solar_request_battery_event()
1398 hidpp->battery.solar_feature_index, in hidpp_solar_request_battery_event()
1402 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_solar_request_battery_event()
1409 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_MILEAGE; in hidpp_solar_request_battery_event()
1414 static int hidpp_solar_battery_event(struct hidpp_device *hidpp, in hidpp_solar_battery_event() argument
1424 if (report->fap.feature_index != hidpp->battery.solar_feature_index || in hidpp_solar_battery_event()
1442 if (capacity < hidpp->battery.capacity) in hidpp_solar_battery_event()
1452 hidpp->battery.online = true; in hidpp_solar_battery_event()
1453 if (capacity != hidpp->battery.capacity || in hidpp_solar_battery_event()
1454 status != hidpp->battery.status) { in hidpp_solar_battery_event()
1455 hidpp->battery.capacity = capacity; in hidpp_solar_battery_event()
1456 hidpp->battery.status = status; in hidpp_solar_battery_event()
1457 if (hidpp->battery.ps) in hidpp_solar_battery_event()
1458 power_supply_changed(hidpp->battery.ps); in hidpp_solar_battery_event()
1483 static int hidpp_touchpad_fw_items_set(struct hidpp_device *hidpp, in hidpp_touchpad_fw_items_set() argument
1491 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_touchpad_fw_items_set()
1495 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_touchpad_fw_items_set()
1554 static int hidpp_touchpad_get_raw_info(struct hidpp_device *hidpp, in hidpp_touchpad_get_raw_info() argument
1561 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_touchpad_get_raw_info()
1565 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_touchpad_get_raw_info()
1678 struct hidpp_device *hidpp; member
1770 ret = hidpp_send_fap_command_sync(data->hidpp, data->feature_index, in hidpp_ff_work_handler()
1774 hid_err(data->hidpp->hid_dev, "Failed to send command to device!\n"); in hidpp_ff_work_handler()
1837 …hid_warn(data->hidpp->hid_dev, "Force feedback command queue contains %d commands, causing substan… in hidpp_ff_queue_work()
1896 …hid_err(data->hidpp->hid_dev, "Unexpected periodic waveform type %i!\n", effect->u.periodic.wavefo… in hidpp_ff_upload_effect()
1981 hid_err(data->hidpp->hid_dev, "Unexpected force type %i!\n", effect->type); in hidpp_ff_upload_effect()
2081 struct hid_device *hid = data->hidpp->hid_dev; in hidpp_ff_destroy()
2090 static int hidpp_ff_init(struct hidpp_device *hidpp, in hidpp_ff_init() argument
2093 struct hid_device *hid = hidpp->hid_dev; in hidpp_ff_init()
2149 data->hidpp = hidpp; in hidpp_ff_init()
2165 error = device_create_file(&(hidpp->hid_dev->dev), &dev_attr_range); in hidpp_ff_init()
2167 hid_warn(hidpp->hid_dev, "Unable to create sysfs interface for \"range\", errno %d!\n", error); in hidpp_ff_init()
2207 static void wtp_populate_input(struct hidpp_device *hidpp, in wtp_populate_input() argument
2210 struct wtp_data *wd = hidpp->private_data; in wtp_populate_input()
2227 if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS) in wtp_populate_input()
2236 static void wtp_touch_event(struct hidpp_device *hidpp, in wtp_touch_event() argument
2239 struct wtp_data *wd = hidpp->private_data; in wtp_touch_event()
2246 slot = input_mt_get_slot_by_key(hidpp->input, touch_report->finger_id); in wtp_touch_event()
2248 input_mt_slot(hidpp->input, slot); in wtp_touch_event()
2249 input_mt_report_slot_state(hidpp->input, MT_TOOL_FINGER, in wtp_touch_event()
2252 input_event(hidpp->input, EV_ABS, ABS_MT_POSITION_X, in wtp_touch_event()
2254 input_event(hidpp->input, EV_ABS, ABS_MT_POSITION_Y, in wtp_touch_event()
2257 input_event(hidpp->input, EV_ABS, ABS_MT_PRESSURE, in wtp_touch_event()
2262 static void wtp_send_raw_xy_event(struct hidpp_device *hidpp, in wtp_send_raw_xy_event() argument
2268 wtp_touch_event(hidpp, &(raw->fingers[i])); in wtp_send_raw_xy_event()
2271 !(hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS)) in wtp_send_raw_xy_event()
2272 input_event(hidpp->input, EV_KEY, BTN_LEFT, raw->button); in wtp_send_raw_xy_event()
2275 input_mt_sync_frame(hidpp->input); in wtp_send_raw_xy_event()
2276 input_sync(hidpp->input); in wtp_send_raw_xy_event()
2280 static int wtp_mouse_raw_xy_event(struct hidpp_device *hidpp, u8 *data) in wtp_mouse_raw_xy_event() argument
2282 struct wtp_data *wd = hidpp->private_data; in wtp_mouse_raw_xy_event()
2314 wtp_send_raw_xy_event(hidpp, &raw); in wtp_mouse_raw_xy_event()
2321 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in wtp_raw_event() local
2322 struct wtp_data *wd = hidpp->private_data; in wtp_raw_event()
2326 if (!wd || !hidpp->input) in wtp_raw_event()
2336 if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS) { in wtp_raw_event()
2337 input_event(hidpp->input, EV_KEY, BTN_LEFT, in wtp_raw_event()
2339 input_event(hidpp->input, EV_KEY, BTN_RIGHT, in wtp_raw_event()
2341 input_sync(hidpp->input); in wtp_raw_event()
2346 return wtp_mouse_raw_xy_event(hidpp, &data[7]); in wtp_raw_event()
2353 hidpp_touchpad_raw_xy_event(hidpp, data + 4, &raw); in wtp_raw_event()
2355 wtp_send_raw_xy_event(hidpp, &raw); in wtp_raw_event()
2362 static int wtp_get_config(struct hidpp_device *hidpp) in wtp_get_config() argument
2364 struct wtp_data *wd = hidpp->private_data; in wtp_get_config()
2369 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_TOUCHPAD_RAW_XY, in wtp_get_config()
2375 ret = hidpp_touchpad_get_raw_info(hidpp, wd->mt_feature_index, in wtp_get_config()
2393 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in wtp_allocate() local
2401 hidpp->private_data = wd; in wtp_allocate()
2408 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in wtp_connect() local
2409 struct wtp_data *wd = hidpp->private_data; in wtp_connect()
2413 ret = wtp_get_config(hidpp); in wtp_connect()
2420 return hidpp_touchpad_set_raw_report_state(hidpp, wd->mt_feature_index, in wtp_connect()
2488 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in m560_raw_event() local
2491 if (!hidpp->input) { in m560_raw_event()
2518 input_report_key(hidpp->input, BTN_MIDDLE, 1); in m560_raw_event()
2521 input_report_key(hidpp->input, BTN_FORWARD, 1); in m560_raw_event()
2524 input_report_key(hidpp->input, BTN_BACK, 1); in m560_raw_event()
2527 input_report_key(hidpp->input, BTN_BACK, 0); in m560_raw_event()
2528 input_report_key(hidpp->input, BTN_FORWARD, 0); in m560_raw_event()
2529 input_report_key(hidpp->input, BTN_MIDDLE, 0); in m560_raw_event()
2535 input_sync(hidpp->input); in m560_raw_event()
2549 input_report_key(hidpp->input, BTN_LEFT, in m560_raw_event()
2551 input_report_key(hidpp->input, BTN_RIGHT, in m560_raw_event()
2555 input_report_rel(hidpp->input, REL_HWHEEL, -1); in m560_raw_event()
2556 input_report_rel(hidpp->input, REL_HWHEEL_HI_RES, in m560_raw_event()
2559 input_report_rel(hidpp->input, REL_HWHEEL, 1); in m560_raw_event()
2560 input_report_rel(hidpp->input, REL_HWHEEL_HI_RES, in m560_raw_event()
2565 input_report_rel(hidpp->input, REL_X, v); in m560_raw_event()
2568 input_report_rel(hidpp->input, REL_Y, v); in m560_raw_event()
2572 hidpp_scroll_counter_handle_scroll(hidpp->input, in m560_raw_event()
2573 &hidpp->vertical_wheel_counter, v); in m560_raw_event()
2575 input_sync(hidpp->input); in m560_raw_event()
2581 static void m560_populate_input(struct hidpp_device *hidpp, in m560_populate_input() argument
2625 static int k400_disable_tap_to_click(struct hidpp_device *hidpp) in k400_disable_tap_to_click() argument
2627 struct k400_private_data *k400 = hidpp->private_data; in k400_disable_tap_to_click()
2633 ret = hidpp_root_get_feature(hidpp, in k400_disable_tap_to_click()
2641 ret = hidpp_touchpad_fw_items_set(hidpp, k400->feature_index, &items); in k400_disable_tap_to_click()
2650 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in k400_allocate() local
2658 hidpp->private_data = k400; in k400_allocate()
2665 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in k400_connect() local
2670 return k400_disable_tap_to_click(hidpp); in k400_connect()
2679 static int g920_ff_set_autocenter(struct hidpp_device *hidpp, in g920_ff_set_autocenter() argument
2691 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_ff_set_autocenter()
2696 hid_warn(hidpp->hid_dev, "Failed to autocenter device!\n"); in g920_ff_set_autocenter()
2703 static int g920_get_config(struct hidpp_device *hidpp, in g920_get_config() argument
2713 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_G920_FORCE_FEEDBACK, in g920_get_config()
2719 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_get_config()
2726 hid_err(hidpp->hid_dev, in g920_get_config()
2734 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_get_config()
2739 hid_warn(hidpp->hid_dev, "Failed to reset all forces!\n"); in g920_get_config()
2741 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_get_config()
2746 hid_warn(hidpp->hid_dev, in g920_get_config()
2753 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_get_config()
2758 hid_warn(hidpp->hid_dev, in g920_get_config()
2765 return g920_ff_set_autocenter(hidpp, data); in g920_get_config()
2771 static int hidpp10_wheel_connect(struct hidpp_device *hidpp) in hidpp10_wheel_connect() argument
2773 return hidpp10_set_register(hidpp, HIDPP_REG_ENABLE_REPORTS, 0, in hidpp10_wheel_connect()
2778 static int hidpp10_wheel_raw_event(struct hidpp_device *hidpp, in hidpp10_wheel_raw_event() argument
2783 if (!hidpp->input) in hidpp10_wheel_raw_event()
2795 input_report_rel(hidpp->input, REL_WHEEL, value); in hidpp10_wheel_raw_event()
2796 input_report_rel(hidpp->input, REL_WHEEL_HI_RES, value * 120); in hidpp10_wheel_raw_event()
2797 input_report_rel(hidpp->input, REL_HWHEEL, hvalue); in hidpp10_wheel_raw_event()
2798 input_report_rel(hidpp->input, REL_HWHEEL_HI_RES, hvalue * 120); in hidpp10_wheel_raw_event()
2799 input_sync(hidpp->input); in hidpp10_wheel_raw_event()
2804 static void hidpp10_wheel_populate_input(struct hidpp_device *hidpp, in hidpp10_wheel_populate_input() argument
2817 static int hidpp10_extra_mouse_buttons_connect(struct hidpp_device *hidpp) in hidpp10_extra_mouse_buttons_connect() argument
2819 return hidpp10_set_register(hidpp, HIDPP_REG_ENABLE_REPORTS, 0, in hidpp10_extra_mouse_buttons_connect()
2824 static int hidpp10_extra_mouse_buttons_raw_event(struct hidpp_device *hidpp, in hidpp10_extra_mouse_buttons_raw_event() argument
2829 if (!hidpp->input) in hidpp10_extra_mouse_buttons_raw_event()
2846 input_report_key(hidpp->input, BTN_MOUSE + i, in hidpp10_extra_mouse_buttons_raw_event()
2851 input_report_key(hidpp->input, BTN_MISC + i, in hidpp10_extra_mouse_buttons_raw_event()
2854 input_sync(hidpp->input); in hidpp10_extra_mouse_buttons_raw_event()
2859 struct hidpp_device *hidpp, struct input_dev *input_dev) in hidpp10_extra_mouse_buttons_populate_input() argument
2877 static u8 *hidpp10_consumer_keys_report_fixup(struct hidpp_device *hidpp, in hidpp10_consumer_keys_report_fixup() argument
2905 static int hidpp10_consumer_keys_connect(struct hidpp_device *hidpp) in hidpp10_consumer_keys_connect() argument
2907 return hidpp10_set_register(hidpp, HIDPP_REG_ENABLE_REPORTS, 0, in hidpp10_consumer_keys_connect()
2912 static int hidpp10_consumer_keys_raw_event(struct hidpp_device *hidpp, in hidpp10_consumer_keys_raw_event() argument
2931 hid_report_raw_event(hidpp->hid_dev, HID_INPUT_REPORT, in hidpp10_consumer_keys_raw_event()
2941 static int hi_res_scroll_enable(struct hidpp_device *hidpp) in hi_res_scroll_enable() argument
2946 if (hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL_X2121) { in hi_res_scroll_enable()
2947 ret = hidpp_hrw_set_wheel_mode(hidpp, false, true, false); in hi_res_scroll_enable()
2949 ret = hidpp_hrw_get_wheel_capability(hidpp, &multiplier); in hi_res_scroll_enable()
2950 } else if (hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL_X2120) { in hi_res_scroll_enable()
2951 ret = hidpp_hrs_set_highres_scrolling_mode(hidpp, true, in hi_res_scroll_enable()
2954 ret = hidpp10_enable_scrolling_acceleration(hidpp); in hi_res_scroll_enable()
2963 hidpp->vertical_wheel_counter.wheel_multiplier = multiplier; in hi_res_scroll_enable()
2964 hid_info(hidpp->hid_dev, "multiplier = %d\n", multiplier); in hi_res_scroll_enable()
2975 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_report_fixup() local
2977 if (!hidpp) in hidpp_report_fixup()
2982 (hidpp->quirks & HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS)) in hidpp_report_fixup()
2983 rdesc = hidpp10_consumer_keys_report_fixup(hidpp, rdesc, rsize); in hidpp_report_fixup()
2992 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_input_mapping() local
2994 if (!hidpp) in hidpp_input_mapping()
2997 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) in hidpp_input_mapping()
2999 else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560 && in hidpp_input_mapping()
3010 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_input_mapped() local
3012 if (!hidpp) in hidpp_input_mapped()
3016 if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) { in hidpp_input_mapped()
3028 static void hidpp_populate_input(struct hidpp_device *hidpp, in hidpp_populate_input() argument
3031 hidpp->input = input; in hidpp_populate_input()
3033 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) in hidpp_populate_input()
3034 wtp_populate_input(hidpp, input); in hidpp_populate_input()
3035 else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) in hidpp_populate_input()
3036 m560_populate_input(hidpp, input); in hidpp_populate_input()
3038 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_WHEELS) in hidpp_populate_input()
3039 hidpp10_wheel_populate_input(hidpp, input); in hidpp_populate_input()
3041 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_EXTRA_MOUSE_BTNS) in hidpp_populate_input()
3042 hidpp10_extra_mouse_buttons_populate_input(hidpp, input); in hidpp_populate_input()
3048 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_input_configured() local
3051 if (!hidpp) in hidpp_input_configured()
3054 hidpp_populate_input(hidpp, input); in hidpp_input_configured()
3059 static int hidpp_raw_hidpp_event(struct hidpp_device *hidpp, u8 *data, in hidpp_raw_hidpp_event() argument
3062 struct hidpp_report *question = hidpp->send_receive_buf; in hidpp_raw_hidpp_event()
3063 struct hidpp_report *answer = hidpp->send_receive_buf; in hidpp_raw_hidpp_event()
3071 if (unlikely(mutex_is_locked(&hidpp->send_mutex))) { in hidpp_raw_hidpp_event()
3079 hidpp->answer_available = true; in hidpp_raw_hidpp_event()
3080 wake_up(&hidpp->wait); in hidpp_raw_hidpp_event()
3092 atomic_set(&hidpp->connected, in hidpp_raw_hidpp_event()
3094 if (schedule_work(&hidpp->work) == 0) in hidpp_raw_hidpp_event()
3099 if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_BATTERY) { in hidpp_raw_hidpp_event()
3100 ret = hidpp20_battery_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3103 ret = hidpp_solar_battery_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3108 if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP10_BATTERY) { in hidpp_raw_hidpp_event()
3109 ret = hidpp10_battery_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3114 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_WHEELS) { in hidpp_raw_hidpp_event()
3115 ret = hidpp10_wheel_raw_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3120 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_EXTRA_MOUSE_BTNS) { in hidpp_raw_hidpp_event()
3121 ret = hidpp10_extra_mouse_buttons_raw_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3126 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS) { in hidpp_raw_hidpp_event()
3127 ret = hidpp10_consumer_keys_raw_event(hidpp, data, size); in hidpp_raw_hidpp_event()
3138 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_raw_event() local
3141 if (!hidpp) in hidpp_raw_event()
3147 if (size != hidpp->very_long_report_length) { in hidpp_raw_event()
3152 ret = hidpp_raw_hidpp_event(hidpp, data, size); in hidpp_raw_event()
3160 ret = hidpp_raw_hidpp_event(hidpp, data, size); in hidpp_raw_event()
3168 ret = hidpp_raw_hidpp_event(hidpp, data, size); in hidpp_raw_event()
3177 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) in hidpp_raw_event()
3179 else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) in hidpp_raw_event()
3191 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_event() local
3194 if (!hidpp) in hidpp_event()
3197 counter = &hidpp->vertical_wheel_counter; in hidpp_event()
3203 if (!(hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL) || value == 0 in hidpp_event()
3204 || hidpp->input == NULL || counter->wheel_multiplier == 0) in hidpp_event()
3207 hidpp_scroll_counter_handle_scroll(hidpp->input, counter, value); in hidpp_event()
3211 static int hidpp_initialize_battery(struct hidpp_device *hidpp) in hidpp_initialize_battery() argument
3214 struct power_supply_config cfg = { .drv_data = hidpp }; in hidpp_initialize_battery()
3215 struct power_supply_desc *desc = &hidpp->battery.desc; in hidpp_initialize_battery()
3222 if (hidpp->battery.ps) in hidpp_initialize_battery()
3225 hidpp->battery.feature_index = 0xff; in hidpp_initialize_battery()
3226 hidpp->battery.solar_feature_index = 0xff; in hidpp_initialize_battery()
3228 if (hidpp->protocol_major >= 2) { in hidpp_initialize_battery()
3229 if (hidpp->quirks & HIDPP_QUIRK_CLASS_K750) in hidpp_initialize_battery()
3230 ret = hidpp_solar_request_battery_event(hidpp); in hidpp_initialize_battery()
3232 ret = hidpp20_query_battery_info(hidpp); in hidpp_initialize_battery()
3236 hidpp->capabilities |= HIDPP_CAPABILITY_HIDPP20_BATTERY; in hidpp_initialize_battery()
3238 ret = hidpp10_query_battery_status(hidpp); in hidpp_initialize_battery()
3240 ret = hidpp10_query_battery_mileage(hidpp); in hidpp_initialize_battery()
3243 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_MILEAGE; in hidpp_initialize_battery()
3245 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS; in hidpp_initialize_battery()
3247 hidpp->capabilities |= HIDPP_CAPABILITY_HIDPP10_BATTERY; in hidpp_initialize_battery()
3250 battery_props = devm_kmemdup(&hidpp->hid_dev->dev, in hidpp_initialize_battery()
3259 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_MILEAGE) in hidpp_initialize_battery()
3263 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS) in hidpp_initialize_battery()
3267 battery = &hidpp->battery; in hidpp_initialize_battery()
3278 battery->ps = devm_power_supply_register(&hidpp->hid_dev->dev, in hidpp_initialize_battery()
3284 power_supply_powers(battery->ps, &hidpp->hid_dev->dev); in hidpp_initialize_battery()
3291 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_overwrite_name() local
3294 if (hidpp->protocol_major < 2) in hidpp_overwrite_name()
3297 name = hidpp_get_device_name(hidpp); in hidpp_overwrite_name()
3326 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_allocate_input() local
3335 input_dev->name = hidpp->name; in hidpp_allocate_input()
3347 static void hidpp_connect_event(struct hidpp_device *hidpp) in hidpp_connect_event() argument
3349 struct hid_device *hdev = hidpp->hid_dev; in hidpp_connect_event()
3351 bool connected = atomic_read(&hidpp->connected); in hidpp_connect_event()
3356 if (hidpp->battery.ps) { in hidpp_connect_event()
3357 hidpp->battery.online = false; in hidpp_connect_event()
3358 hidpp->battery.status = POWER_SUPPLY_STATUS_UNKNOWN; in hidpp_connect_event()
3359 hidpp->battery.level = POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN; in hidpp_connect_event()
3360 power_supply_changed(hidpp->battery.ps); in hidpp_connect_event()
3365 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) { in hidpp_connect_event()
3369 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) { in hidpp_connect_event()
3373 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_K400) { in hidpp_connect_event()
3379 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_WHEELS) { in hidpp_connect_event()
3380 ret = hidpp10_wheel_connect(hidpp); in hidpp_connect_event()
3385 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_EXTRA_MOUSE_BTNS) { in hidpp_connect_event()
3386 ret = hidpp10_extra_mouse_buttons_connect(hidpp); in hidpp_connect_event()
3391 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS) { in hidpp_connect_event()
3392 ret = hidpp10_consumer_keys_connect(hidpp); in hidpp_connect_event()
3399 if (!hidpp->protocol_major) { in hidpp_connect_event()
3400 ret = hidpp_root_get_protocol_version(hidpp); in hidpp_connect_event()
3407 if (hidpp->name == hdev->name && hidpp->protocol_major >= 2) { in hidpp_connect_event()
3408 name = hidpp_get_device_name(hidpp); in hidpp_connect_event()
3416 hidpp->name = devm_name; in hidpp_connect_event()
3420 hidpp_initialize_battery(hidpp); in hidpp_connect_event()
3423 if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP10_BATTERY) { in hidpp_connect_event()
3424 hidpp10_enable_battery_reporting(hidpp); in hidpp_connect_event()
3425 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_MILEAGE) in hidpp_connect_event()
3426 hidpp10_query_battery_mileage(hidpp); in hidpp_connect_event()
3428 hidpp10_query_battery_status(hidpp); in hidpp_connect_event()
3429 } else if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_BATTERY) { in hidpp_connect_event()
3430 hidpp20_query_battery_info(hidpp); in hidpp_connect_event()
3432 if (hidpp->battery.ps) in hidpp_connect_event()
3433 power_supply_changed(hidpp->battery.ps); in hidpp_connect_event()
3435 if (hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL) in hidpp_connect_event()
3436 hi_res_scroll_enable(hidpp); in hidpp_connect_event()
3438 if (!(hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT) || hidpp->delayed_input) in hidpp_connect_event()
3448 hidpp_populate_input(hidpp, input); in hidpp_connect_event()
3454 hidpp->delayed_input = input; in hidpp_connect_event()
3483 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_validate_device() local
3512 hidpp->very_long_report_length = report_length; in hidpp_validate_device()
3535 struct hidpp_device *hidpp; in hidpp_probe() local
3542 hidpp = devm_kzalloc(&hdev->dev, sizeof(*hidpp), GFP_KERNEL); in hidpp_probe()
3543 if (!hidpp) in hidpp_probe()
3546 hidpp->hid_dev = hdev; in hidpp_probe()
3547 hidpp->name = hdev->name; in hidpp_probe()
3548 hidpp->quirks = id->driver_data; in hidpp_probe()
3549 hid_set_drvdata(hdev, hidpp); in hidpp_probe()
3562 devm_kfree(&hdev->dev, hidpp); in hidpp_probe()
3567 hidpp->quirks |= HIDPP_QUIRK_UNIFYING; in hidpp_probe()
3571 hidpp->quirks |= HIDPP_QUIRK_HIDPP_WHEELS | in hidpp_probe()
3576 hidpp->quirks |= HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS; in hidpp_probe()
3579 hidpp->quirks &= ~HIDPP_QUIRK_CLASS_WTP; in hidpp_probe()
3580 hidpp->quirks &= ~HIDPP_QUIRK_NO_HIDINPUT; in hidpp_probe()
3583 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) { in hidpp_probe()
3587 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_K400) { in hidpp_probe()
3593 INIT_WORK(&hidpp->work, delayed_work_cb); in hidpp_probe()
3594 mutex_init(&hidpp->send_mutex); in hidpp_probe()
3595 init_waitqueue_head(&hidpp->wait); in hidpp_probe()
3624 if (hidpp->quirks & HIDPP_QUIRK_UNIFYING) in hidpp_probe()
3625 hidpp_unifying_init(hidpp); in hidpp_probe()
3627 connected = hidpp_root_get_protocol_version(hidpp) == 0; in hidpp_probe()
3628 atomic_set(&hidpp->connected, connected); in hidpp_probe()
3629 if (!(hidpp->quirks & HIDPP_QUIRK_UNIFYING)) { in hidpp_probe()
3639 if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)) { in hidpp_probe()
3640 ret = wtp_get_config(hidpp); in hidpp_probe()
3643 } else if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_G920)) { in hidpp_probe()
3644 ret = g920_get_config(hidpp, &data); in hidpp_probe()
3649 hidpp_connect_event(hidpp); in hidpp_probe()
3656 if (hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT) in hidpp_probe()
3666 if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) { in hidpp_probe()
3667 ret = hidpp_ff_init(hidpp, &data); in hidpp_probe()
3669 hid_warn(hidpp->hid_dev, in hidpp_probe()
3682 cancel_work_sync(&hidpp->work); in hidpp_probe()
3683 mutex_destroy(&hidpp->send_mutex); in hidpp_probe()
3689 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_remove() local
3691 if (!hidpp) in hidpp_remove()
3697 cancel_work_sync(&hidpp->work); in hidpp_remove()
3698 mutex_destroy(&hidpp->send_mutex); in hidpp_remove()