Lines Matching +full:long +full:- +full:press +full:- +full:ms
1 // SPDX-License-Identifier: GPL-2.0-only
6 * Copyright (c) 2012-2013 Google (c)
7 * Copyright (c) 2013-2014 Red Hat Inc.
25 #include <linux/fixp-arith.h>
28 #include "hid-ids.h"
42 "Disable Tap-To-Click mode reporting for touchpads (only on the K400 currently).");
44 /* Define a non-zero software ID to identify our own requests */
85 /* Convenience constant to check for any high-res support. */
119 * is 0xFF for the receiver), and all messages (short or long) with a device
130 u8 params[HIDPP_REPORT_VERY_LONG_MAX_LENGTH - 4U];
136 u8 params[HIDPP_REPORT_VERY_LONG_MAX_LENGTH - 4U];
166 * struct hidpp_scroll_counter - Utility class for processing high-resolution
170 * @remainder: counts the number of high-resolution units moved since the last
171 * low-resolution event (REL_WHEEL or REL_HWHEEL) was sent. Should
173 * @direction: direction of last movement (1 or -1)
180 unsigned long long last_time;
202 unsigned long quirks;
203 unsigned long capabilities;
238 switch (hidpp_report->report_id) { in __hidpp_send_report()
246 fields_count = hidpp->very_long_report_length; in __hidpp_send_report()
249 return -ENODEV; in __hidpp_send_report()
256 hidpp_report->device_index = 0xff; in __hidpp_send_report()
258 if (hidpp->quirks & HIDPP_QUIRK_FORCE_OUTPUT_REPORTS) { in __hidpp_send_report()
261 ret = hid_hw_raw_request(hdev, hidpp_report->report_id, in __hidpp_send_report()
266 return ret == fields_count ? 0 : -1; in __hidpp_send_report()
272 * - If ' something else' is positive, that means that an error has been raised
274 * - If ' something else' is negative, that means that we had a classic error
275 * (-ENOMEM, -EPIPE, etc...)
283 mutex_lock(&hidpp->send_mutex); in hidpp_send_message_sync()
285 hidpp->send_receive_buf = response; in hidpp_send_message_sync()
286 hidpp->answer_available = false; in hidpp_send_message_sync()
294 ret = __hidpp_send_report(hidpp->hid_dev, message); in hidpp_send_message_sync()
302 if (!wait_event_timeout(hidpp->wait, hidpp->answer_available, in hidpp_send_message_sync()
306 ret = -ETIMEDOUT; in hidpp_send_message_sync()
309 if (response->report_id == REPORT_ID_HIDPP_SHORT && in hidpp_send_message_sync()
310 response->rap.sub_id == HIDPP_ERROR) { in hidpp_send_message_sync()
311 ret = response->rap.params[1]; in hidpp_send_message_sync()
316 if ((response->report_id == REPORT_ID_HIDPP_LONG || in hidpp_send_message_sync()
317 response->report_id == REPORT_ID_HIDPP_VERY_LONG) && in hidpp_send_message_sync()
318 response->fap.feature_index == HIDPP20_ERROR) { in hidpp_send_message_sync()
319 ret = response->fap.params[1]; in hidpp_send_message_sync()
325 mutex_unlock(&hidpp->send_mutex); in hidpp_send_message_sync()
337 if (param_count > sizeof(message->fap.params)) in hidpp_send_fap_command_sync()
338 return -EINVAL; in hidpp_send_fap_command_sync()
342 return -ENOMEM; in hidpp_send_fap_command_sync()
344 if (param_count > (HIDPP_REPORT_LONG_LENGTH - 4)) in hidpp_send_fap_command_sync()
345 message->report_id = REPORT_ID_HIDPP_VERY_LONG; in hidpp_send_fap_command_sync()
347 message->report_id = REPORT_ID_HIDPP_LONG; in hidpp_send_fap_command_sync()
348 message->fap.feature_index = feat_index; in hidpp_send_fap_command_sync()
349 message->fap.funcindex_clientid = funcindex_clientid | LINUX_KERNEL_SW_ID; in hidpp_send_fap_command_sync()
350 memcpy(&message->fap.params, params, param_count); in hidpp_send_fap_command_sync()
364 /* Send as long report if short reports are not supported. */ in hidpp_send_rap_command_sync()
366 !(hidpp_dev->supported_reports & HIDPP_REPORT_SHORT_SUPPORTED)) in hidpp_send_rap_command_sync()
371 max_count = HIDPP_REPORT_SHORT_LENGTH - 4; in hidpp_send_rap_command_sync()
374 max_count = HIDPP_REPORT_LONG_LENGTH - 4; in hidpp_send_rap_command_sync()
377 max_count = hidpp_dev->very_long_report_length - 4; in hidpp_send_rap_command_sync()
380 return -EINVAL; in hidpp_send_rap_command_sync()
384 return -EINVAL; in hidpp_send_rap_command_sync()
388 return -ENOMEM; in hidpp_send_rap_command_sync()
389 message->report_id = report_id; in hidpp_send_rap_command_sync()
390 message->rap.sub_id = sub_id; in hidpp_send_rap_command_sync()
391 message->rap.reg_address = reg_address; in hidpp_send_rap_command_sync()
392 memcpy(&message->rap.params, params, param_count); in hidpp_send_rap_command_sync()
409 return (answer->fap.feature_index == question->fap.feature_index) && in hidpp_match_answer()
410 (answer->fap.funcindex_clientid == question->fap.funcindex_clientid); in hidpp_match_answer()
416 return ((answer->rap.sub_id == HIDPP_ERROR) || in hidpp_match_error()
417 (answer->fap.feature_index == HIDPP20_ERROR)) && in hidpp_match_error()
418 (answer->fap.funcindex_clientid == question->fap.feature_index) && in hidpp_match_error()
419 (answer->fap.params[0] == question->fap.funcindex_clientid); in hidpp_match_error()
425 return (hidpp->wireless_feature_index && in hidpp_report_is_connect_event()
426 (report->fap.feature_index == hidpp->wireless_feature_index)) || in hidpp_report_is_connect_event()
427 ((report->report_id == REPORT_ID_HIDPP_SHORT) && in hidpp_report_is_connect_event()
428 (report->rap.sub_id == 0x41)); in hidpp_report_is_connect_event()
459 * hidpp_scroll_counter_handle_scroll() - Send high- and low-resolution scroll
460 * events given a high-resolution wheel
464 * @hi_res_value: the movement of the wheel, in the mouse's high-resolution
467 * Given a high-resolution movement, this function converts the movement into
468 * fractions of 120 and emits high-resolution scroll events for the input
470 * emit low-resolution scroll events when appropriate for
471 * backwards-compatibility with userspace input libraries.
478 unsigned long long now, previous; in hidpp_scroll_counter_handle_scroll()
480 hi_res_value = hi_res_value * 120/counter->wheel_multiplier; in hidpp_scroll_counter_handle_scroll()
483 remainder = counter->remainder; in hidpp_scroll_counter_handle_scroll()
484 direction = hi_res_value > 0 ? 1 : -1; in hidpp_scroll_counter_handle_scroll()
487 previous = counter->last_time; in hidpp_scroll_counter_handle_scroll()
488 counter->last_time = now; in hidpp_scroll_counter_handle_scroll()
495 if (now - previous > 1000000000 || direction != counter->direction) in hidpp_scroll_counter_handle_scroll()
498 counter->direction = direction; in hidpp_scroll_counter_handle_scroll()
502 * after slow movement, so we want the threshold for low-res events to in hidpp_scroll_counter_handle_scroll()
508 * is half-way to the next detent (i.e. scroll 1 detent after a in hidpp_scroll_counter_handle_scroll()
514 low_res_value = (hi_res_value > 0 ? 1 : -1); in hidpp_scroll_counter_handle_scroll()
516 remainder -= low_res_value * 120; in hidpp_scroll_counter_handle_scroll()
518 counter->remainder = remainder; in hidpp_scroll_counter_handle_scroll()
521 /* -------------------------------------------------------------------------- */
523 /* -------------------------------------------------------------------------- */
531 * hidpp10_set_register - Modify a HID++ 1.0 register.
583 /* On HID++ 1.0 devices, high-res scroll was called "scrolling acceleration". */
663 hidpp->battery.level = in hidpp10_query_battery_status()
666 hidpp->battery.status = status; in hidpp10_query_battery_status()
668 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp10_query_battery_status()
715 hidpp->battery.capacity = response.rap.params[0]; in hidpp10_query_battery_mileage()
717 hidpp->battery.status = status; in hidpp10_query_battery_mileage()
719 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp10_query_battery_mileage()
731 if (report->report_id != REPORT_ID_HIDPP_SHORT) in hidpp10_battery_event()
734 switch (report->rap.sub_id) { in hidpp10_battery_event()
736 capacity = hidpp->battery.capacity; in hidpp10_battery_event()
737 level = hidpp10_battery_status_map_level(report->rawbytes[1]); in hidpp10_battery_event()
738 status = hidpp10_battery_status_map_status(report->rawbytes[2]); in hidpp10_battery_event()
741 capacity = report->rap.params[0]; in hidpp10_battery_event()
742 level = hidpp->battery.level; in hidpp10_battery_event()
743 status = hidpp10_battery_mileage_map_status(report->rawbytes[3]); in hidpp10_battery_event()
749 changed = capacity != hidpp->battery.capacity || in hidpp10_battery_event()
750 level != hidpp->battery.level || in hidpp10_battery_event()
751 status != hidpp->battery.status; in hidpp10_battery_event()
754 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp10_battery_event()
758 hidpp->battery.level = level; in hidpp10_battery_event()
759 hidpp->battery.status = status; in hidpp10_battery_event()
760 if (hidpp->battery.ps) in hidpp10_battery_event()
761 power_supply_changed(hidpp->battery.ps); in hidpp10_battery_event()
831 struct hid_device *hdev = hidpp->hid_dev; in hidpp_unifying_init()
840 snprintf(hdev->uniq, sizeof(hdev->uniq), "%04x-%4phD", in hidpp_unifying_init()
841 hdev->product, &serial); in hidpp_unifying_init()
842 dbg_hid("HID++ Unifying: Got serial: %s\n", hdev->uniq); in hidpp_unifying_init()
846 return -EIO; in hidpp_unifying_init()
848 snprintf(hdev->name, sizeof(hdev->name), "%s", name); in hidpp_unifying_init()
855 /* -------------------------------------------------------------------------- */
857 /* -------------------------------------------------------------------------- */
880 return -ENOENT; in hidpp_root_get_feature()
902 hidpp->protocol_major = 1; in hidpp_root_get_protocol_version()
903 hidpp->protocol_minor = 0; in hidpp_root_get_protocol_version()
909 return -EIO; in hidpp_root_get_protocol_version()
912 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_root_get_protocol_version()
914 return -EPROTO; in hidpp_root_get_protocol_version()
920 hid_err(hidpp->hid_dev, "%s: ping mismatch 0x%02x != 0x%02x\n", in hidpp_root_get_protocol_version()
922 return -EPROTO; in hidpp_root_get_protocol_version()
925 hidpp->protocol_major = response.rap.params[0]; in hidpp_root_get_protocol_version()
926 hidpp->protocol_minor = response.rap.params[1]; in hidpp_root_get_protocol_version()
929 hid_info(hidpp->hid_dev, "HID++ %u.%u device connected.\n", in hidpp_root_get_protocol_version()
930 hidpp->protocol_major, hidpp->protocol_minor); in hidpp_root_get_protocol_version()
934 /* -------------------------------------------------------------------------- */
936 /* -------------------------------------------------------------------------- */
954 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_devicenametype_get_count()
956 return -EPROTO; in hidpp_devicenametype_get_count()
978 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_devicenametype_get_device_name()
980 return -EPROTO; in hidpp_devicenametype_get_device_name()
987 count = hidpp->very_long_report_length - 4; in hidpp_devicenametype_get_device_name()
990 count = HIDPP_REPORT_LONG_LENGTH - 4; in hidpp_devicenametype_get_device_name()
993 count = HIDPP_REPORT_SHORT_LENGTH - 4; in hidpp_devicenametype_get_device_name()
996 return -EPROTO; in hidpp_devicenametype_get_device_name()
1034 __name_length - index); in hidpp_get_device_name()
1048 /* -------------------------------------------------------------------------- */
1050 /* -------------------------------------------------------------------------- */
1137 return -EIO; in hidpp20_batterylevel_get_battery_capacity()
1139 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_batterylevel_get_battery_capacity()
1141 return -EPROTO; in hidpp20_batterylevel_get_battery_capacity()
1165 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_batterylevel_get_battery_info()
1167 return -EPROTO; in hidpp20_batterylevel_get_battery_info()
1176 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS; in hidpp20_batterylevel_get_battery_info()
1178 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_MILEAGE; in hidpp20_batterylevel_get_battery_info()
1189 if (hidpp->battery.feature_index == 0xff) { in hidpp20_query_battery_info_1000()
1192 &hidpp->battery.feature_index, in hidpp20_query_battery_info_1000()
1199 hidpp->battery.feature_index, in hidpp20_query_battery_info_1000()
1206 hidpp->battery.feature_index); in hidpp20_query_battery_info_1000()
1210 hidpp->battery.status = status; in hidpp20_query_battery_info_1000()
1211 hidpp->battery.capacity = capacity; in hidpp20_query_battery_info_1000()
1212 hidpp->battery.level = level; in hidpp20_query_battery_info_1000()
1214 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp20_query_battery_info_1000()
1227 if (report->fap.feature_index != hidpp->battery.feature_index || in hidpp20_battery_event_1000()
1228 report->fap.funcindex_clientid != EVENT_BATTERY_LEVEL_STATUS_BROADCAST) in hidpp20_battery_event_1000()
1231 status = hidpp20_batterylevel_map_status_capacity(report->fap.params, in hidpp20_battery_event_1000()
1237 hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING || in hidpp20_battery_event_1000()
1240 changed = capacity != hidpp->battery.capacity || in hidpp20_battery_event_1000()
1241 level != hidpp->battery.level || in hidpp20_battery_event_1000()
1242 status != hidpp->battery.status; in hidpp20_battery_event_1000()
1245 hidpp->battery.level = level; in hidpp20_battery_event_1000()
1246 hidpp->battery.capacity = capacity; in hidpp20_battery_event_1000()
1247 hidpp->battery.status = status; in hidpp20_battery_event_1000()
1248 if (hidpp->battery.ps) in hidpp20_battery_event_1000()
1249 power_supply_changed(hidpp->battery.ps); in hidpp20_battery_event_1000()
1255 /* -------------------------------------------------------------------------- */
1257 /* -------------------------------------------------------------------------- */
1270 long flags = (long) data[2]; in hidpp20_battery_map_status_voltage()
1322 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_battery_get_battery_voltage()
1324 return -EPROTO; in hidpp20_battery_get_battery_voltage()
1329 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_VOLTAGE; in hidpp20_battery_get_battery_voltage()
1368 return ARRAY_SIZE(voltages) - i; in hidpp20_map_battery_capacity()
1380 if (hidpp->battery.voltage_feature_index == 0xff) { in hidpp20_query_battery_voltage_info()
1382 &hidpp->battery.voltage_feature_index, in hidpp20_query_battery_voltage_info()
1389 hidpp->battery.voltage_feature_index, in hidpp20_query_battery_voltage_info()
1395 hidpp->battery.status = status; in hidpp20_query_battery_voltage_info()
1396 hidpp->battery.voltage = voltage; in hidpp20_query_battery_voltage_info()
1397 hidpp->battery.capacity = hidpp20_map_battery_capacity(hidpp->hid_dev, in hidpp20_query_battery_voltage_info()
1399 hidpp->battery.level = level; in hidpp20_query_battery_voltage_info()
1400 hidpp->battery.charge_type = charge_type; in hidpp20_query_battery_voltage_info()
1401 hidpp->battery.online = status != POWER_SUPPLY_STATUS_NOT_CHARGING; in hidpp20_query_battery_voltage_info()
1412 if (report->fap.feature_index != hidpp->battery.voltage_feature_index || in hidpp20_battery_voltage_event()
1413 report->fap.funcindex_clientid != EVENT_BATTERY_VOLTAGE_STATUS_BROADCAST) in hidpp20_battery_voltage_event()
1416 status = hidpp20_battery_map_status_voltage(report->fap.params, &voltage, in hidpp20_battery_voltage_event()
1419 hidpp->battery.online = status != POWER_SUPPLY_STATUS_NOT_CHARGING; in hidpp20_battery_voltage_event()
1421 if (voltage != hidpp->battery.voltage || status != hidpp->battery.status) { in hidpp20_battery_voltage_event()
1422 hidpp->battery.voltage = voltage; in hidpp20_battery_voltage_event()
1423 hidpp->battery.capacity = hidpp20_map_battery_capacity(hidpp->hid_dev, in hidpp20_battery_voltage_event()
1425 hidpp->battery.status = status; in hidpp20_battery_voltage_event()
1426 hidpp->battery.level = level; in hidpp20_battery_voltage_event()
1427 hidpp->battery.charge_type = charge_type; in hidpp20_battery_voltage_event()
1428 if (hidpp->battery.ps) in hidpp20_battery_voltage_event()
1429 power_supply_changed(hidpp->battery.ps); in hidpp20_battery_voltage_event()
1434 /* -------------------------------------------------------------------------- */
1436 /* -------------------------------------------------------------------------- */
1460 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS || in hidpp20_unifiedbattery_get_capabilities()
1461 hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_PERCENTAGE) { in hidpp20_unifiedbattery_get_capabilities()
1471 return -EIO; in hidpp20_unifiedbattery_get_capabilities()
1473 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_unifiedbattery_get_capabilities()
1475 return -EPROTO; in hidpp20_unifiedbattery_get_capabilities()
1488 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_PERCENTAGE; in hidpp20_unifiedbattery_get_capabilities()
1489 hidpp->battery.supported_levels_1004 = 0; in hidpp20_unifiedbattery_get_capabilities()
1491 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS; in hidpp20_unifiedbattery_get_capabilities()
1492 hidpp->battery.supported_levels_1004 = params[0]; in hidpp20_unifiedbattery_get_capabilities()
1517 hid_info(hidpp->hid_dev, "%s: charging error", in hidpp20_unifiedbattery_map_status()
1518 hidpp->name); in hidpp20_unifiedbattery_map_status()
1532 battery_level &= hidpp->battery.supported_levels_1004; in hidpp20_unifiedbattery_map_level()
1561 return -EIO; in hidpp20_unifiedbattery_get_status()
1563 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp20_unifiedbattery_get_status()
1565 return -EPROTO; in hidpp20_unifiedbattery_get_status()
1584 if (hidpp->battery.feature_index == 0xff) { in hidpp20_query_battery_info_1004()
1587 &hidpp->battery.feature_index, in hidpp20_query_battery_info_1004()
1594 hidpp->battery.feature_index); in hidpp20_query_battery_info_1004()
1599 hidpp->battery.feature_index, in hidpp20_query_battery_info_1004()
1606 hidpp->capabilities |= HIDPP_CAPABILITY_UNIFIED_BATTERY; in hidpp20_query_battery_info_1004()
1607 hidpp->battery.capacity = state_of_charge; in hidpp20_query_battery_info_1004()
1608 hidpp->battery.status = status; in hidpp20_query_battery_info_1004()
1609 hidpp->battery.level = level; in hidpp20_query_battery_info_1004()
1610 hidpp->battery.online = true; in hidpp20_query_battery_info_1004()
1619 u8 *params = (u8 *)report->fap.params; in hidpp20_battery_event_1004()
1623 if (report->fap.feature_index != hidpp->battery.feature_index || in hidpp20_battery_event_1004()
1624 report->fap.funcindex_clientid != EVENT_UNIFIED_BATTERY_STATUS_EVENT) in hidpp20_battery_event_1004()
1631 changed = status != hidpp->battery.status || in hidpp20_battery_event_1004()
1632 (state_of_charge != hidpp->battery.capacity && in hidpp20_battery_event_1004()
1633 hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_PERCENTAGE) || in hidpp20_battery_event_1004()
1634 (level != hidpp->battery.level && in hidpp20_battery_event_1004()
1635 hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS); in hidpp20_battery_event_1004()
1638 hidpp->battery.capacity = state_of_charge; in hidpp20_battery_event_1004()
1639 hidpp->battery.status = status; in hidpp20_battery_event_1004()
1640 hidpp->battery.level = level; in hidpp20_battery_event_1004()
1641 if (hidpp->battery.ps) in hidpp20_battery_event_1004()
1642 power_supply_changed(hidpp->battery.ps); in hidpp20_battery_event_1004()
1648 /* -------------------------------------------------------------------------- */
1650 /* -------------------------------------------------------------------------- */
1673 val->intval = hidpp->battery.status; in hidpp_battery_get_property()
1676 val->intval = hidpp->battery.capacity; in hidpp_battery_get_property()
1679 val->intval = hidpp->battery.level; in hidpp_battery_get_property()
1682 val->intval = POWER_SUPPLY_SCOPE_DEVICE; in hidpp_battery_get_property()
1685 val->intval = hidpp->battery.online; in hidpp_battery_get_property()
1688 if (!strncmp(hidpp->name, "Logitech ", 9)) in hidpp_battery_get_property()
1689 val->strval = hidpp->name + 9; in hidpp_battery_get_property()
1691 val->strval = hidpp->name; in hidpp_battery_get_property()
1694 val->strval = "Logitech"; in hidpp_battery_get_property()
1697 val->strval = hidpp->hid_dev->uniq; in hidpp_battery_get_property()
1701 val->intval = hidpp->battery.voltage * 1000; in hidpp_battery_get_property()
1704 val->intval = hidpp->battery.charge_type; in hidpp_battery_get_property()
1707 ret = -EINVAL; in hidpp_battery_get_property()
1714 /* -------------------------------------------------------------------------- */
1716 /* -------------------------------------------------------------------------- */
1726 &hidpp->wireless_feature_index, in hidpp_set_wireless_feature_index()
1732 /* -------------------------------------------------------------------------- */
1733 /* 0x2120: Hi-resolution scrolling */
1734 /* -------------------------------------------------------------------------- */
1766 /* -------------------------------------------------------------------------- */
1768 /* -------------------------------------------------------------------------- */
1797 hid_warn(hidpp->hid_dev, in hidpp_hrw_get_wheel_capability()
1825 /* -------------------------------------------------------------------------- */
1827 /* -------------------------------------------------------------------------- */
1844 if (hidpp->battery.feature_index == 0xff) { in hidpp_solar_request_battery_event()
1847 &hidpp->battery.solar_feature_index, in hidpp_solar_request_battery_event()
1854 hidpp->battery.solar_feature_index, in hidpp_solar_request_battery_event()
1858 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_solar_request_battery_event()
1860 return -EPROTO; in hidpp_solar_request_battery_event()
1865 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_MILEAGE; in hidpp_solar_request_battery_event()
1877 function = report->fap.funcindex_clientid; in hidpp_solar_battery_event()
1880 if (report->fap.feature_index != hidpp->battery.solar_feature_index || in hidpp_solar_battery_event()
1886 capacity = report->fap.params[0]; in hidpp_solar_battery_event()
1890 lux = (report->fap.params[1] << 8) | report->fap.params[2]; in hidpp_solar_battery_event()
1898 if (capacity < hidpp->battery.capacity) in hidpp_solar_battery_event()
1908 hidpp->battery.online = true; in hidpp_solar_battery_event()
1909 if (capacity != hidpp->battery.capacity || in hidpp_solar_battery_event()
1910 status != hidpp->battery.status) { in hidpp_solar_battery_event()
1911 hidpp->battery.capacity = capacity; in hidpp_solar_battery_event()
1912 hidpp->battery.status = status; in hidpp_solar_battery_event()
1913 if (hidpp->battery.ps) in hidpp_solar_battery_event()
1914 power_supply_changed(hidpp->battery.ps); in hidpp_solar_battery_event()
1920 /* -------------------------------------------------------------------------- */
1922 /* -------------------------------------------------------------------------- */
1936 * send a set state command to the device by reading the current items->state
1948 CMD_TOUCHPAD_FW_ITEMS_SET, &items->state, 1, &response); in hidpp_touchpad_fw_items_set()
1951 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_touchpad_fw_items_set()
1953 return -EPROTO; in hidpp_touchpad_fw_items_set()
1958 items->presence = params[0]; in hidpp_touchpad_fw_items_set()
1959 items->desired_state = params[1]; in hidpp_touchpad_fw_items_set()
1960 items->state = params[2]; in hidpp_touchpad_fw_items_set()
1961 items->persistent = params[3]; in hidpp_touchpad_fw_items_set()
1966 /* -------------------------------------------------------------------------- */
1968 /* -------------------------------------------------------------------------- */
2021 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_touchpad_get_raw_info()
2023 return -EPROTO; in hidpp_touchpad_get_raw_info()
2028 raw_info->x_size = get_unaligned_be16(¶ms[0]); in hidpp_touchpad_get_raw_info()
2029 raw_info->y_size = get_unaligned_be16(¶ms[2]); in hidpp_touchpad_get_raw_info()
2030 raw_info->z_range = params[4]; in hidpp_touchpad_get_raw_info()
2031 raw_info->area_range = params[5]; in hidpp_touchpad_get_raw_info()
2032 raw_info->maxcontacts = params[7]; in hidpp_touchpad_get_raw_info()
2033 raw_info->origin = params[8]; in hidpp_touchpad_get_raw_info()
2035 raw_info->res = get_unaligned_be16(¶ms[13]) * 2 / 51; in hidpp_touchpad_get_raw_info()
2048 * bit 0 - enable raw in hidpp_touchpad_set_raw_report_state()
2049 * bit 1 - 16bit Z, no area in hidpp_touchpad_set_raw_report_state()
2050 * bit 2 - enhanced sensitivity in hidpp_touchpad_set_raw_report_state()
2051 * bit 3 - width, height (4 bits each) instead of area in hidpp_touchpad_set_raw_report_state()
2052 * bit 4 - send raw + gestures (degrades smoothness) in hidpp_touchpad_set_raw_report_state()
2053 * remaining bits - reserved in hidpp_touchpad_set_raw_report_state()
2067 finger->x = x_m << 6 | data[1]; in hidpp_touchpad_touch_event()
2068 finger->y = y_m << 6 | data[3]; in hidpp_touchpad_touch_event()
2070 finger->contact_type = data[0] >> 6; in hidpp_touchpad_touch_event()
2071 finger->contact_status = data[2] >> 6; in hidpp_touchpad_touch_event()
2073 finger->z = data[4]; in hidpp_touchpad_touch_event()
2074 finger->area = data[5]; in hidpp_touchpad_touch_event()
2075 finger->finger_id = data[6] >> 4; in hidpp_touchpad_touch_event()
2082 raw_xy->end_of_frame = data[8] & 0x01; in hidpp_touchpad_raw_xy_event()
2083 raw_xy->spurious_flag = (data[8] >> 1) & 0x01; in hidpp_touchpad_raw_xy_event()
2084 raw_xy->finger_count = data[15] & 0x0f; in hidpp_touchpad_raw_xy_event()
2085 raw_xy->button = (data[8] >> 2) & 0x01; in hidpp_touchpad_raw_xy_event()
2087 if (raw_xy->finger_count) { in hidpp_touchpad_raw_xy_event()
2088 hidpp_touchpad_touch_event(&data[2], &raw_xy->fingers[0]); in hidpp_touchpad_raw_xy_event()
2089 hidpp_touchpad_touch_event(&data[9], &raw_xy->fingers[1]); in hidpp_touchpad_raw_xy_event()
2093 /* -------------------------------------------------------------------------- */
2095 /* -------------------------------------------------------------------------- */
2126 #define HIDPP_FF_EFFECTID_NONE -1
2127 #define HIDPP_FF_EFFECTID_AUTOCENTER -2
2167 -1
2174 -1
2196 for (i = 0; i < data->num_effects; i++) in hidpp_ff_find_effect()
2197 if (data->effect_ids[i] == effect_id) in hidpp_ff_find_effect()
2206 struct hidpp_ff_private_data *data = wd->data; in hidpp_ff_work_handler()
2212 switch (wd->effect_id) { in hidpp_ff_work_handler()
2214 wd->params[0] = data->slot_autocenter; in hidpp_ff_work_handler()
2221 wd->params[0] = hidpp_ff_find_effect(data, wd->effect_id); in hidpp_ff_work_handler()
2226 ret = hidpp_send_fap_command_sync(data->hidpp, data->feature_index, in hidpp_ff_work_handler()
2227 wd->command, wd->params, wd->size, &response); in hidpp_ff_work_handler()
2230 hid_err(data->hidpp->hid_dev, "Failed to send command to device!\n"); in hidpp_ff_work_handler()
2235 switch (wd->command) { in hidpp_ff_work_handler()
2238 if (slot > 0 && slot <= data->num_effects) { in hidpp_ff_work_handler()
2239 if (wd->effect_id >= 0) in hidpp_ff_work_handler()
2241 data->effect_ids[slot-1] = wd->effect_id; in hidpp_ff_work_handler()
2242 else if (wd->effect_id >= HIDPP_FF_EFFECTID_AUTOCENTER) in hidpp_ff_work_handler()
2244 data->slot_autocenter = slot; in hidpp_ff_work_handler()
2248 if (wd->effect_id >= 0) in hidpp_ff_work_handler()
2250 data->effect_ids[wd->params[0]-1] = -1; in hidpp_ff_work_handler()
2251 else if (wd->effect_id >= HIDPP_FF_EFFECTID_AUTOCENTER) in hidpp_ff_work_handler()
2253 data->slot_autocenter = 0; in hidpp_ff_work_handler()
2256 data->gain = (wd->params[0] << 8) + wd->params[1]; in hidpp_ff_work_handler()
2259 data->range = (wd->params[0] << 8) + wd->params[1]; in hidpp_ff_work_handler()
2267 atomic_dec(&data->workqueue_size); in hidpp_ff_work_handler()
2277 return -ENOMEM; in hidpp_ff_queue_work()
2279 INIT_WORK(&wd->work, hidpp_ff_work_handler); in hidpp_ff_queue_work()
2281 wd->data = data; in hidpp_ff_queue_work()
2282 wd->effect_id = effect_id; in hidpp_ff_queue_work()
2283 wd->command = command; in hidpp_ff_queue_work()
2284 wd->size = size; in hidpp_ff_queue_work()
2285 memcpy(wd->params, params, size); in hidpp_ff_queue_work()
2287 s = atomic_inc_return(&data->workqueue_size); in hidpp_ff_queue_work()
2288 queue_work(data->wq, &wd->work); in hidpp_ff_queue_work()
2292 …hid_warn(data->hidpp->hid_dev, "Force feedback command queue contains %d commands, causing substan… in hidpp_ff_queue_work()
2299 struct hidpp_ff_private_data *data = dev->ff->private; in hidpp_ff_upload_effect()
2305 params[2] = effect->replay.length >> 8; in hidpp_ff_upload_effect()
2306 params[3] = effect->replay.length & 255; in hidpp_ff_upload_effect()
2307 params[4] = effect->replay.delay >> 8; in hidpp_ff_upload_effect()
2308 params[5] = effect->replay.delay & 255; in hidpp_ff_upload_effect()
2310 switch (effect->type) { in hidpp_ff_upload_effect()
2312 force = (effect->u.constant.level * fixp_sin16((effect->direction * 360) >> 16)) >> 15; in hidpp_ff_upload_effect()
2316 params[8] = effect->u.constant.envelope.attack_level >> 7; in hidpp_ff_upload_effect()
2317 params[9] = effect->u.constant.envelope.attack_length >> 8; in hidpp_ff_upload_effect()
2318 params[10] = effect->u.constant.envelope.attack_length & 255; in hidpp_ff_upload_effect()
2319 params[11] = effect->u.constant.envelope.fade_level >> 7; in hidpp_ff_upload_effect()
2320 params[12] = effect->u.constant.envelope.fade_length >> 8; in hidpp_ff_upload_effect()
2321 params[13] = effect->u.constant.envelope.fade_length & 255; in hidpp_ff_upload_effect()
2324 effect->u.constant.level, in hidpp_ff_upload_effect()
2325 effect->direction, force); in hidpp_ff_upload_effect()
2326 dbg_hid(" envelope attack=(%d, %d ms) fade=(%d, %d ms)\n", in hidpp_ff_upload_effect()
2327 effect->u.constant.envelope.attack_level, in hidpp_ff_upload_effect()
2328 effect->u.constant.envelope.attack_length, in hidpp_ff_upload_effect()
2329 effect->u.constant.envelope.fade_level, in hidpp_ff_upload_effect()
2330 effect->u.constant.envelope.fade_length); in hidpp_ff_upload_effect()
2334 switch (effect->u.periodic.waveform) { in hidpp_ff_upload_effect()
2351 …hid_err(data->hidpp->hid_dev, "Unexpected periodic waveform type %i!\n", effect->u.periodic.wavefo… in hidpp_ff_upload_effect()
2352 return -EINVAL; in hidpp_ff_upload_effect()
2354 force = (effect->u.periodic.magnitude * fixp_sin16((effect->direction * 360) >> 16)) >> 15; in hidpp_ff_upload_effect()
2355 params[6] = effect->u.periodic.magnitude >> 8; in hidpp_ff_upload_effect()
2356 params[7] = effect->u.periodic.magnitude & 255; in hidpp_ff_upload_effect()
2357 params[8] = effect->u.periodic.offset >> 8; in hidpp_ff_upload_effect()
2358 params[9] = effect->u.periodic.offset & 255; in hidpp_ff_upload_effect()
2359 params[10] = effect->u.periodic.period >> 8; in hidpp_ff_upload_effect()
2360 params[11] = effect->u.periodic.period & 255; in hidpp_ff_upload_effect()
2361 params[12] = effect->u.periodic.phase >> 8; in hidpp_ff_upload_effect()
2362 params[13] = effect->u.periodic.phase & 255; in hidpp_ff_upload_effect()
2363 params[14] = effect->u.periodic.envelope.attack_level >> 7; in hidpp_ff_upload_effect()
2364 params[15] = effect->u.periodic.envelope.attack_length >> 8; in hidpp_ff_upload_effect()
2365 params[16] = effect->u.periodic.envelope.attack_length & 255; in hidpp_ff_upload_effect()
2366 params[17] = effect->u.periodic.envelope.fade_level >> 7; in hidpp_ff_upload_effect()
2367 params[18] = effect->u.periodic.envelope.fade_length >> 8; in hidpp_ff_upload_effect()
2368 params[19] = effect->u.periodic.envelope.fade_length & 255; in hidpp_ff_upload_effect()
2370 dbg_hid("Uploading periodic force mag=%d/dir=%d, offset=%d, period=%d ms, phase=%d\n", in hidpp_ff_upload_effect()
2371 effect->u.periodic.magnitude, effect->direction, in hidpp_ff_upload_effect()
2372 effect->u.periodic.offset, in hidpp_ff_upload_effect()
2373 effect->u.periodic.period, in hidpp_ff_upload_effect()
2374 effect->u.periodic.phase); in hidpp_ff_upload_effect()
2375 dbg_hid(" envelope attack=(%d, %d ms) fade=(%d, %d ms)\n", in hidpp_ff_upload_effect()
2376 effect->u.periodic.envelope.attack_level, in hidpp_ff_upload_effect()
2377 effect->u.periodic.envelope.attack_length, in hidpp_ff_upload_effect()
2378 effect->u.periodic.envelope.fade_level, in hidpp_ff_upload_effect()
2379 effect->u.periodic.envelope.fade_length); in hidpp_ff_upload_effect()
2384 force = (effect->u.ramp.start_level * fixp_sin16((effect->direction * 360) >> 16)) >> 15; in hidpp_ff_upload_effect()
2387 force = (effect->u.ramp.end_level * fixp_sin16((effect->direction * 360) >> 16)) >> 15; in hidpp_ff_upload_effect()
2390 params[10] = effect->u.ramp.envelope.attack_level >> 7; in hidpp_ff_upload_effect()
2391 params[11] = effect->u.ramp.envelope.attack_length >> 8; in hidpp_ff_upload_effect()
2392 params[12] = effect->u.ramp.envelope.attack_length & 255; in hidpp_ff_upload_effect()
2393 params[13] = effect->u.ramp.envelope.fade_level >> 7; in hidpp_ff_upload_effect()
2394 params[14] = effect->u.ramp.envelope.fade_length >> 8; in hidpp_ff_upload_effect()
2395 params[15] = effect->u.ramp.envelope.fade_length & 255; in hidpp_ff_upload_effect()
2397 dbg_hid("Uploading ramp force level=%d -> %d in dir %d = %d\n", in hidpp_ff_upload_effect()
2398 effect->u.ramp.start_level, in hidpp_ff_upload_effect()
2399 effect->u.ramp.end_level, in hidpp_ff_upload_effect()
2400 effect->direction, force); in hidpp_ff_upload_effect()
2401 dbg_hid(" envelope attack=(%d, %d ms) fade=(%d, %d ms)\n", in hidpp_ff_upload_effect()
2402 effect->u.ramp.envelope.attack_level, in hidpp_ff_upload_effect()
2403 effect->u.ramp.envelope.attack_length, in hidpp_ff_upload_effect()
2404 effect->u.ramp.envelope.fade_level, in hidpp_ff_upload_effect()
2405 effect->u.ramp.envelope.fade_length); in hidpp_ff_upload_effect()
2411 params[1] = HIDPP_FF_CONDITION_CMDS[effect->type - FF_SPRING]; in hidpp_ff_upload_effect()
2412 params[6] = effect->u.condition[0].left_saturation >> 9; in hidpp_ff_upload_effect()
2413 params[7] = (effect->u.condition[0].left_saturation >> 1) & 255; in hidpp_ff_upload_effect()
2414 params[8] = effect->u.condition[0].left_coeff >> 8; in hidpp_ff_upload_effect()
2415 params[9] = effect->u.condition[0].left_coeff & 255; in hidpp_ff_upload_effect()
2416 params[10] = effect->u.condition[0].deadband >> 9; in hidpp_ff_upload_effect()
2417 params[11] = (effect->u.condition[0].deadband >> 1) & 255; in hidpp_ff_upload_effect()
2418 params[12] = effect->u.condition[0].center >> 8; in hidpp_ff_upload_effect()
2419 params[13] = effect->u.condition[0].center & 255; in hidpp_ff_upload_effect()
2420 params[14] = effect->u.condition[0].right_coeff >> 8; in hidpp_ff_upload_effect()
2421 params[15] = effect->u.condition[0].right_coeff & 255; in hidpp_ff_upload_effect()
2422 params[16] = effect->u.condition[0].right_saturation >> 9; in hidpp_ff_upload_effect()
2423 params[17] = (effect->u.condition[0].right_saturation >> 1) & 255; in hidpp_ff_upload_effect()
2426 HIDPP_FF_CONDITION_NAMES[effect->type - FF_SPRING], in hidpp_ff_upload_effect()
2427 effect->u.condition[0].left_coeff, in hidpp_ff_upload_effect()
2428 effect->u.condition[0].left_saturation, in hidpp_ff_upload_effect()
2429 effect->u.condition[0].right_coeff, in hidpp_ff_upload_effect()
2430 effect->u.condition[0].right_saturation); in hidpp_ff_upload_effect()
2432 effect->u.condition[0].deadband, in hidpp_ff_upload_effect()
2433 effect->u.condition[0].center); in hidpp_ff_upload_effect()
2436 hid_err(data->hidpp->hid_dev, "Unexpected force type %i!\n", effect->type); in hidpp_ff_upload_effect()
2437 return -EINVAL; in hidpp_ff_upload_effect()
2440 return hidpp_ff_queue_work(data, effect->id, HIDPP_FF_DOWNLOAD_EFFECT, params, size); in hidpp_ff_upload_effect()
2445 struct hidpp_ff_private_data *data = dev->ff->private; in hidpp_ff_playback()
2457 struct hidpp_ff_private_data *data = dev->ff->private; in hidpp_ff_erase_effect()
2467 struct hidpp_ff_private_data *data = dev->ff->private; in hidpp_ff_set_autocenter()
2489 struct hidpp_ff_private_data *data = dev->ff->private; in hidpp_ff_set_gain()
2505 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); in hidpp_ff_range_show()
2506 struct input_dev *idev = hidinput->input; in hidpp_ff_range_show()
2507 struct hidpp_ff_private_data *data = idev->ff->private; in hidpp_ff_range_show()
2509 return scnprintf(buf, PAGE_SIZE, "%u\n", data->range); in hidpp_ff_range_show()
2515 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); in hidpp_ff_range_store()
2516 struct input_dev *idev = hidinput->input; in hidpp_ff_range_store()
2517 struct hidpp_ff_private_data *data = idev->ff->private; in hidpp_ff_range_store()
2526 hidpp_ff_queue_work(data, -1, HIDPP_FF_SET_APERTURE, params, ARRAY_SIZE(params)); in hidpp_ff_range_store()
2535 struct hidpp_ff_private_data *data = ff->private; in hidpp_ff_destroy()
2536 struct hid_device *hid = data->hidpp->hid_dev; in hidpp_ff_destroy()
2540 device_remove_file(&hid->dev, &dev_attr_range); in hidpp_ff_destroy()
2541 destroy_workqueue(data->wq); in hidpp_ff_destroy()
2542 kfree(data->effect_ids); in hidpp_ff_destroy()
2548 struct hid_device *hid = hidpp->hid_dev; in hidpp_ff_init()
2551 const struct usb_device_descriptor *udesc = &(hid_to_usb_dev(hid)->descriptor); in hidpp_ff_init()
2552 const u16 bcdDevice = le16_to_cpu(udesc->bcdDevice); in hidpp_ff_init()
2554 int error, j, num_slots = data->num_effects; in hidpp_ff_init()
2557 if (list_empty(&hid->inputs)) { in hidpp_ff_init()
2559 return -ENODEV; in hidpp_ff_init()
2561 hidinput = list_entry(hid->inputs.next, struct hid_input, list); in hidpp_ff_init()
2562 dev = hidinput->input; in hidpp_ff_init()
2566 return -EINVAL; in hidpp_ff_init()
2574 set_bit(hidpp_ff_effects[j], dev->ffbit); in hidpp_ff_init()
2577 set_bit(hidpp_ff_effects_v2[j], dev->ffbit); in hidpp_ff_init()
2591 return -ENOMEM; in hidpp_ff_init()
2592 data->effect_ids = kcalloc(num_slots, sizeof(int), GFP_KERNEL); in hidpp_ff_init()
2593 if (!data->effect_ids) { in hidpp_ff_init()
2595 return -ENOMEM; in hidpp_ff_init()
2597 data->wq = create_singlethread_workqueue("hidpp-ff-sendqueue"); in hidpp_ff_init()
2598 if (!data->wq) { in hidpp_ff_init()
2599 kfree(data->effect_ids); in hidpp_ff_init()
2601 return -ENOMEM; in hidpp_ff_init()
2604 data->hidpp = hidpp; in hidpp_ff_init()
2605 data->version = version; in hidpp_ff_init()
2607 data->effect_ids[j] = -1; in hidpp_ff_init()
2609 ff = dev->ff; in hidpp_ff_init()
2610 ff->private = data; in hidpp_ff_init()
2612 ff->upload = hidpp_ff_upload_effect; in hidpp_ff_init()
2613 ff->erase = hidpp_ff_erase_effect; in hidpp_ff_init()
2614 ff->playback = hidpp_ff_playback; in hidpp_ff_init()
2615 ff->set_gain = hidpp_ff_set_gain; in hidpp_ff_init()
2616 ff->set_autocenter = hidpp_ff_set_autocenter; in hidpp_ff_init()
2617 ff->destroy = hidpp_ff_destroy; in hidpp_ff_init()
2620 error = device_create_file(&(hidpp->hid_dev->dev), &dev_attr_range); in hidpp_ff_init()
2622 hid_warn(hidpp->hid_dev, "Unable to create sysfs interface for \"range\", errno %d!\n", error); in hidpp_ff_init()
2625 atomic_set(&data->workqueue_size, 0); in hidpp_ff_init()
2639 /* -------------------------------------------------------------------------- */
2641 /* -------------------------------------------------------------------------- */
2657 unsigned long **bit, int *max) in wtp_input_mapping()
2659 return -1; in wtp_input_mapping()
2665 struct wtp_data *wd = hidpp->private_data; in wtp_populate_input()
2667 __set_bit(EV_ABS, input_dev->evbit); in wtp_populate_input()
2668 __set_bit(EV_KEY, input_dev->evbit); in wtp_populate_input()
2669 __clear_bit(EV_REL, input_dev->evbit); in wtp_populate_input()
2670 __clear_bit(EV_LED, input_dev->evbit); in wtp_populate_input()
2672 input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, wd->x_size, 0, 0); in wtp_populate_input()
2673 input_abs_set_res(input_dev, ABS_MT_POSITION_X, wd->resolution); in wtp_populate_input()
2674 input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, wd->y_size, 0, 0); in wtp_populate_input()
2675 input_abs_set_res(input_dev, ABS_MT_POSITION_Y, wd->resolution); in wtp_populate_input()
2682 if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS) in wtp_populate_input()
2685 __set_bit(INPUT_PROP_BUTTONPAD, input_dev->propbit); in wtp_populate_input()
2687 input_mt_init_slots(input_dev, wd->maxcontacts, INPUT_MT_POINTER | in wtp_populate_input()
2694 struct wtp_data *wd = hidpp->private_data; in wtp_touch_event()
2697 if (!touch_report->finger_id || touch_report->contact_type) in wtp_touch_event()
2701 slot = input_mt_get_slot_by_key(hidpp->input, touch_report->finger_id); in wtp_touch_event()
2703 input_mt_slot(hidpp->input, slot); in wtp_touch_event()
2704 input_mt_report_slot_state(hidpp->input, MT_TOOL_FINGER, in wtp_touch_event()
2705 touch_report->contact_status); in wtp_touch_event()
2706 if (touch_report->contact_status) { in wtp_touch_event()
2707 input_event(hidpp->input, EV_ABS, ABS_MT_POSITION_X, in wtp_touch_event()
2708 touch_report->x); in wtp_touch_event()
2709 input_event(hidpp->input, EV_ABS, ABS_MT_POSITION_Y, in wtp_touch_event()
2710 wd->flip_y ? wd->y_size - touch_report->y : in wtp_touch_event()
2711 touch_report->y); in wtp_touch_event()
2712 input_event(hidpp->input, EV_ABS, ABS_MT_PRESSURE, in wtp_touch_event()
2713 touch_report->area); in wtp_touch_event()
2723 wtp_touch_event(hidpp, &(raw->fingers[i])); in wtp_send_raw_xy_event()
2725 if (raw->end_of_frame && in wtp_send_raw_xy_event()
2726 !(hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS)) in wtp_send_raw_xy_event()
2727 input_event(hidpp->input, EV_KEY, BTN_LEFT, raw->button); in wtp_send_raw_xy_event()
2729 if (raw->end_of_frame || raw->finger_count <= 2) { in wtp_send_raw_xy_event()
2730 input_mt_sync_frame(hidpp->input); in wtp_send_raw_xy_event()
2731 input_sync(hidpp->input); in wtp_send_raw_xy_event()
2737 struct wtp_data *wd = hidpp->private_data; in wtp_mouse_raw_xy_event()
2763 .finger_count = wd->maxcontacts, in wtp_mouse_raw_xy_event()
2777 struct wtp_data *wd = hidpp->private_data; in wtp_raw_event()
2781 if (!wd || !hidpp->input) in wtp_raw_event()
2791 if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS) { in wtp_raw_event()
2792 input_event(hidpp->input, EV_KEY, BTN_LEFT, in wtp_raw_event()
2794 input_event(hidpp->input, EV_KEY, BTN_RIGHT, in wtp_raw_event()
2796 input_sync(hidpp->input); in wtp_raw_event()
2805 if ((report->fap.feature_index != wd->mt_feature_index) || in wtp_raw_event()
2806 (report->fap.funcindex_clientid != EVENT_TOUCHPAD_RAW_XY)) in wtp_raw_event()
2819 struct wtp_data *wd = hidpp->private_data; in wtp_get_config()
2825 &wd->mt_feature_index, &feature_type); in wtp_get_config()
2830 ret = hidpp_touchpad_get_raw_info(hidpp, wd->mt_feature_index, in wtp_get_config()
2835 wd->x_size = raw_info.x_size; in wtp_get_config()
2836 wd->y_size = raw_info.y_size; in wtp_get_config()
2837 wd->maxcontacts = raw_info.maxcontacts; in wtp_get_config()
2838 wd->flip_y = raw_info.origin == TOUCHPAD_RAW_XY_ORIGIN_LOWER_LEFT; in wtp_get_config()
2839 wd->resolution = raw_info.res; in wtp_get_config()
2840 if (!wd->resolution) in wtp_get_config()
2841 wd->resolution = WTP_MANUAL_RESOLUTION; in wtp_get_config()
2851 wd = devm_kzalloc(&hdev->dev, sizeof(struct wtp_data), in wtp_allocate()
2854 return -ENOMEM; in wtp_allocate()
2856 hidpp->private_data = wd; in wtp_allocate()
2864 struct wtp_data *wd = hidpp->private_data; in wtp_connect()
2867 if (!wd->x_size) { in wtp_connect()
2875 return hidpp_touchpad_set_raw_report_state(hidpp, wd->mt_feature_index, in wtp_connect()
2879 /* ------------------------------------------------------------------------- */
2881 /* ------------------------------------------------------------------------- */
2890 * is different from the odd press and the even press.
2892 * forward button -> Super_R
2893 * backward button -> Super_L+'d' (press only)
2894 * middle button -> 1st time: Alt_L+SuperL+XF86TouchpadOff (press only)
2895 * 2nd time: left-click (press only)
2896 * NB: press-only means that when the button is pressed, the
2904 * - it never sends a keyboard key event
2905 * - for the three mouse button it sends:
2906 * middle button press 11<xx>0a 3500af00...
2907 * side 1 button (forward) press 11<xx>0a 3500b000...
2908 * side 2 button (backward) press 11<xx>0a 3500ae00...
2946 if (!hidpp->input) { in m560_raw_event()
2948 return -EINVAL; in m560_raw_event()
2962 * data[1] = device-id in m560_raw_event()
2964 * data[5] = 0xaf -> middle in m560_raw_event()
2965 * 0xb0 -> forward in m560_raw_event()
2966 * 0xae -> backward in m560_raw_event()
2967 * 0x00 -> release all in m560_raw_event()
2973 input_report_key(hidpp->input, BTN_MIDDLE, 1); in m560_raw_event()
2976 input_report_key(hidpp->input, BTN_FORWARD, 1); in m560_raw_event()
2979 input_report_key(hidpp->input, BTN_BACK, 1); in m560_raw_event()
2982 input_report_key(hidpp->input, BTN_BACK, 0); in m560_raw_event()
2983 input_report_key(hidpp->input, BTN_FORWARD, 0); in m560_raw_event()
2984 input_report_key(hidpp->input, BTN_MIDDLE, 0); in m560_raw_event()
2990 input_sync(hidpp->input); in m560_raw_event()
3004 input_report_key(hidpp->input, BTN_LEFT, in m560_raw_event()
3006 input_report_key(hidpp->input, BTN_RIGHT, in m560_raw_event()
3010 input_report_rel(hidpp->input, REL_HWHEEL, -1); in m560_raw_event()
3011 input_report_rel(hidpp->input, REL_HWHEEL_HI_RES, in m560_raw_event()
3012 -120); in m560_raw_event()
3014 input_report_rel(hidpp->input, REL_HWHEEL, 1); in m560_raw_event()
3015 input_report_rel(hidpp->input, REL_HWHEEL_HI_RES, in m560_raw_event()
3020 input_report_rel(hidpp->input, REL_X, v); in m560_raw_event()
3023 input_report_rel(hidpp->input, REL_Y, v); in m560_raw_event()
3027 hidpp_scroll_counter_handle_scroll(hidpp->input, in m560_raw_event()
3028 &hidpp->vertical_wheel_counter, v); in m560_raw_event()
3030 input_sync(hidpp->input); in m560_raw_event()
3039 __set_bit(EV_KEY, input_dev->evbit); in m560_populate_input()
3040 __set_bit(BTN_MIDDLE, input_dev->keybit); in m560_populate_input()
3041 __set_bit(BTN_RIGHT, input_dev->keybit); in m560_populate_input()
3042 __set_bit(BTN_LEFT, input_dev->keybit); in m560_populate_input()
3043 __set_bit(BTN_BACK, input_dev->keybit); in m560_populate_input()
3044 __set_bit(BTN_FORWARD, input_dev->keybit); in m560_populate_input()
3046 __set_bit(EV_REL, input_dev->evbit); in m560_populate_input()
3047 __set_bit(REL_X, input_dev->relbit); in m560_populate_input()
3048 __set_bit(REL_Y, input_dev->relbit); in m560_populate_input()
3049 __set_bit(REL_WHEEL, input_dev->relbit); in m560_populate_input()
3050 __set_bit(REL_HWHEEL, input_dev->relbit); in m560_populate_input()
3051 __set_bit(REL_WHEEL_HI_RES, input_dev->relbit); in m560_populate_input()
3052 __set_bit(REL_HWHEEL_HI_RES, input_dev->relbit); in m560_populate_input()
3057 unsigned long **bit, int *max) in m560_input_mapping()
3059 return -1; in m560_input_mapping()
3062 /* ------------------------------------------------------------------------- */
3064 /* ------------------------------------------------------------------------- */
3069 * tap-to-click but the setting is not remembered accross reset, annoying some
3082 struct k400_private_data *k400 = hidpp->private_data; in k400_disable_tap_to_click()
3087 if (!k400->feature_index) { in k400_disable_tap_to_click()
3090 &k400->feature_index, &feature_type); in k400_disable_tap_to_click()
3096 ret = hidpp_touchpad_fw_items_set(hidpp, k400->feature_index, &items); in k400_disable_tap_to_click()
3108 k400 = devm_kzalloc(&hdev->dev, sizeof(struct k400_private_data), in k400_allocate()
3111 return -ENOMEM; in k400_allocate()
3113 hidpp->private_data = k400; in k400_allocate()
3128 /* ------------------------------------------------------------------------- */
3130 /* ------------------------------------------------------------------------- */
3146 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_ff_set_autocenter()
3151 hid_warn(hidpp->hid_dev, "Failed to autocenter device!\n"); in g920_ff_set_autocenter()
3153 data->slot_autocenter = response.fap.params[0]; in g920_ff_set_autocenter()
3169 &data->feature_index, &feature_type); in g920_get_config()
3174 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_get_config()
3181 hid_err(hidpp->hid_dev, in g920_get_config()
3183 return -EPROTO; in g920_get_config()
3186 data->num_effects = response.fap.params[0] - HIDPP_FF_RESERVED_SLOTS; in g920_get_config()
3189 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_get_config()
3194 hid_warn(hidpp->hid_dev, "Failed to reset all forces!\n"); in g920_get_config()
3196 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_get_config()
3201 hid_warn(hidpp->hid_dev, in g920_get_config()
3204 data->range = ret ? in g920_get_config()
3208 ret = hidpp_send_fap_command_sync(hidpp, data->feature_index, in g920_get_config()
3213 hid_warn(hidpp->hid_dev, in g920_get_config()
3215 data->gain = ret ? in g920_get_config()
3223 /* -------------------------------------------------------------------------- */
3225 /* -------------------------------------------------------------------------- */
3230 unsigned long **bit, int *max) in lg_dinovo_input_mapping()
3232 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_LOGIVENDOR) in lg_dinovo_input_mapping()
3235 switch (usage->hid & HID_USAGE) { in lg_dinovo_input_mapping()
3243 /* -------------------------------------------------------------------------- */
3245 /* -------------------------------------------------------------------------- */
3258 if (!hidpp->input) in hidpp10_wheel_raw_event()
3259 return -EINVAL; in hidpp10_wheel_raw_event()
3270 input_report_rel(hidpp->input, REL_WHEEL, value); in hidpp10_wheel_raw_event()
3271 input_report_rel(hidpp->input, REL_WHEEL_HI_RES, value * 120); in hidpp10_wheel_raw_event()
3272 input_report_rel(hidpp->input, REL_HWHEEL, hvalue); in hidpp10_wheel_raw_event()
3273 input_report_rel(hidpp->input, REL_HWHEEL_HI_RES, hvalue * 120); in hidpp10_wheel_raw_event()
3274 input_sync(hidpp->input); in hidpp10_wheel_raw_event()
3282 __set_bit(EV_REL, input_dev->evbit); in hidpp10_wheel_populate_input()
3283 __set_bit(REL_WHEEL, input_dev->relbit); in hidpp10_wheel_populate_input()
3284 __set_bit(REL_WHEEL_HI_RES, input_dev->relbit); in hidpp10_wheel_populate_input()
3285 __set_bit(REL_HWHEEL, input_dev->relbit); in hidpp10_wheel_populate_input()
3286 __set_bit(REL_HWHEEL_HI_RES, input_dev->relbit); in hidpp10_wheel_populate_input()
3289 /* -------------------------------------------------------------------------- */
3291 /* -------------------------------------------------------------------------- */
3304 if (!hidpp->input) in hidpp10_extra_mouse_buttons_raw_event()
3305 return -EINVAL; in hidpp10_extra_mouse_buttons_raw_event()
3318 * the same usb-id show different behavior, so we handle both cases. in hidpp10_extra_mouse_buttons_raw_event()
3321 input_report_key(hidpp->input, BTN_MOUSE + i, in hidpp10_extra_mouse_buttons_raw_event()
3326 input_report_key(hidpp->input, BTN_MISC + i, in hidpp10_extra_mouse_buttons_raw_event()
3329 input_sync(hidpp->input); in hidpp10_extra_mouse_buttons_raw_event()
3336 /* BTN_MOUSE - BTN_MOUSE+7 are set already by the descriptor */ in hidpp10_extra_mouse_buttons_populate_input()
3337 __set_bit(BTN_0, input_dev->keybit); in hidpp10_extra_mouse_buttons_populate_input()
3338 __set_bit(BTN_1, input_dev->keybit); in hidpp10_extra_mouse_buttons_populate_input()
3339 __set_bit(BTN_2, input_dev->keybit); in hidpp10_extra_mouse_buttons_populate_input()
3340 __set_bit(BTN_3, input_dev->keybit); in hidpp10_extra_mouse_buttons_populate_input()
3341 __set_bit(BTN_4, input_dev->keybit); in hidpp10_extra_mouse_buttons_populate_input()
3342 __set_bit(BTN_5, input_dev->keybit); in hidpp10_extra_mouse_buttons_populate_input()
3343 __set_bit(BTN_6, input_dev->keybit); in hidpp10_extra_mouse_buttons_populate_input()
3344 __set_bit(BTN_7, input_dev->keybit); in hidpp10_extra_mouse_buttons_populate_input()
3347 /* -------------------------------------------------------------------------- */
3348 /* HID++1.0 kbds which only report 0x10xx consumer usages through sub-id 0x03 */
3349 /* -------------------------------------------------------------------------- */
3351 /* Find the consumer-page input report desc and change Maximums to 0x107f */
3370 size = *rsize - (consumer_rdesc - rdesc); in hidpp10_consumer_keys_report_fixup()
3406 hid_report_raw_event(hidpp->hid_dev, HID_INPUT_REPORT, in hidpp10_consumer_keys_raw_event()
3412 /* -------------------------------------------------------------------------- */
3413 /* High-resolution scroll wheels */
3414 /* -------------------------------------------------------------------------- */
3421 if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_HI_RES_WHEEL) { in hi_res_scroll_enable()
3425 } else if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_HI_RES_SCROLL) { in hi_res_scroll_enable()
3428 } else /* if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP10_FAST_SCROLL) */ { in hi_res_scroll_enable()
3438 hidpp->vertical_wheel_counter.wheel_multiplier = multiplier; in hi_res_scroll_enable()
3439 hid_dbg(hidpp->hid_dev, "wheel multiplier = %d\n", multiplier); in hi_res_scroll_enable()
3446 unsigned long capabilities; in hidpp_initialize_hires_scroll()
3448 capabilities = hidpp->capabilities; in hidpp_initialize_hires_scroll()
3450 if (hidpp->protocol_major >= 2) { in hidpp_initialize_hires_scroll()
3457 hidpp->capabilities |= HIDPP_CAPABILITY_HIDPP20_HI_RES_WHEEL; in hidpp_initialize_hires_scroll()
3458 hid_dbg(hidpp->hid_dev, "Detected HID++ 2.0 hi-res scroll wheel\n"); in hidpp_initialize_hires_scroll()
3464 hidpp->capabilities |= HIDPP_CAPABILITY_HIDPP20_HI_RES_SCROLL; in hidpp_initialize_hires_scroll()
3465 hid_dbg(hidpp->hid_dev, "Detected HID++ 2.0 hi-res scrolling\n"); in hidpp_initialize_hires_scroll()
3476 hidpp->capabilities |= HIDPP_CAPABILITY_HIDPP10_FAST_SCROLL; in hidpp_initialize_hires_scroll()
3477 hid_dbg(hidpp->hid_dev, "Detected HID++ 1.0 fast scroll\n"); in hidpp_initialize_hires_scroll()
3481 if (hidpp->capabilities == capabilities) in hidpp_initialize_hires_scroll()
3482 hid_dbg(hidpp->hid_dev, "Did not detect HID++ hi-res scrolling hardware support\n"); in hidpp_initialize_hires_scroll()
3486 /* -------------------------------------------------------------------------- */
3488 /* -------------------------------------------------------------------------- */
3499 if (hdev->group == HID_GROUP_LOGITECH_27MHZ_DEVICE || in hidpp_report_fixup()
3500 (hidpp->quirks & HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS)) in hidpp_report_fixup()
3508 unsigned long **bit, int *max) in hidpp_input_mapping()
3515 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) in hidpp_input_mapping()
3517 else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560 && in hidpp_input_mapping()
3518 field->application != HID_GD_MOUSE) in hidpp_input_mapping()
3521 if (hdev->product == DINOVO_MINI_PRODUCT_ID) in hidpp_input_mapping()
3529 unsigned long **bit, int *max) in hidpp_input_mapped()
3537 if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) { in hidpp_input_mapped()
3538 if (usage->type == EV_ABS && (usage->code == ABS_X || in hidpp_input_mapped()
3539 usage->code == ABS_Y || usage->code == ABS_Z || in hidpp_input_mapped()
3540 usage->code == ABS_RZ)) { in hidpp_input_mapped()
3541 field->application = HID_GD_MULTIAXIS; in hidpp_input_mapped()
3552 hidpp->input = input; in hidpp_populate_input()
3554 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) in hidpp_populate_input()
3556 else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) in hidpp_populate_input()
3559 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_WHEELS) in hidpp_populate_input()
3562 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_EXTRA_MOUSE_BTNS) in hidpp_populate_input()
3570 struct input_dev *input = hidinput->input; in hidpp_input_configured()
3583 struct hidpp_report *question = hidpp->send_receive_buf; in hidpp_raw_hidpp_event()
3584 struct hidpp_report *answer = hidpp->send_receive_buf; in hidpp_raw_hidpp_event()
3592 if (unlikely(mutex_is_locked(&hidpp->send_mutex))) { in hidpp_raw_hidpp_event()
3600 hidpp->answer_available = true; in hidpp_raw_hidpp_event()
3601 wake_up(&hidpp->wait); in hidpp_raw_hidpp_event()
3604 * We return 1 to hid-core to avoid forwarding the in hidpp_raw_hidpp_event()
3613 atomic_set(&hidpp->connected, in hidpp_raw_hidpp_event()
3614 !(report->rap.params[0] & (1 << 6))); in hidpp_raw_hidpp_event()
3615 if (schedule_work(&hidpp->work) == 0) in hidpp_raw_hidpp_event()
3620 if (hidpp->hid_dev->group == HID_GROUP_LOGITECH_27MHZ_DEVICE && in hidpp_raw_hidpp_event()
3624 dev_err_ratelimited(&hidpp->hid_dev->dev, in hidpp_raw_hidpp_event()
3625 …less encryption key has been lost, your keyboard will not work unless you re-configure encryption.… in hidpp_raw_hidpp_event()
3626 dev_err_ratelimited(&hidpp->hid_dev->dev, in hidpp_raw_hidpp_event()
3627 "See: https://gitlab.freedesktop.org/jwrdegoede/logitech-27mhz-keyboard-encryption-setup/\n"); in hidpp_raw_hidpp_event()
3630 if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_BATTERY) { in hidpp_raw_hidpp_event()
3645 if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP10_BATTERY) { in hidpp_raw_hidpp_event()
3651 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_WHEELS) { in hidpp_raw_hidpp_event()
3657 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_EXTRA_MOUSE_BTNS) { in hidpp_raw_hidpp_event()
3663 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS) { in hidpp_raw_hidpp_event()
3684 if (size != hidpp->very_long_report_length) { in hidpp_raw_event()
3714 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) in hidpp_raw_event()
3716 else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) in hidpp_raw_event()
3734 counter = &hidpp->vertical_wheel_counter; in hidpp_event()
3736 * the input device set, or high-res scroll enabling may fail. In such in hidpp_event()
3740 if (!(hidpp->capabilities & HIDPP_CAPABILITY_HI_RES_SCROLL) in hidpp_event()
3741 || value == 0 || hidpp->input == NULL in hidpp_event()
3742 || counter->wheel_multiplier == 0) in hidpp_event()
3745 hidpp_scroll_counter_handle_scroll(hidpp->input, counter, value); in hidpp_event()
3753 struct power_supply_desc *desc = &hidpp->battery.desc; in hidpp_initialize_battery()
3757 unsigned long n; in hidpp_initialize_battery()
3760 if (hidpp->battery.ps) in hidpp_initialize_battery()
3763 hidpp->battery.feature_index = 0xff; in hidpp_initialize_battery()
3764 hidpp->battery.solar_feature_index = 0xff; in hidpp_initialize_battery()
3765 hidpp->battery.voltage_feature_index = 0xff; in hidpp_initialize_battery()
3767 if (hidpp->protocol_major >= 2) { in hidpp_initialize_battery()
3768 if (hidpp->quirks & HIDPP_QUIRK_CLASS_K750) in hidpp_initialize_battery()
3783 hidpp->capabilities |= HIDPP_CAPABILITY_HIDPP20_BATTERY; in hidpp_initialize_battery()
3789 return -ENOENT; in hidpp_initialize_battery()
3790 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_MILEAGE; in hidpp_initialize_battery()
3792 hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS; in hidpp_initialize_battery()
3794 hidpp->capabilities |= HIDPP_CAPABILITY_HIDPP10_BATTERY; in hidpp_initialize_battery()
3797 battery_props = devm_kmemdup(&hidpp->hid_dev->dev, in hidpp_initialize_battery()
3802 return -ENOMEM; in hidpp_initialize_battery()
3804 num_battery_props = ARRAY_SIZE(hidpp_battery_props) - 3; in hidpp_initialize_battery()
3806 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_MILEAGE || in hidpp_initialize_battery()
3807 hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_PERCENTAGE || in hidpp_initialize_battery()
3808 hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_VOLTAGE) in hidpp_initialize_battery()
3812 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS) in hidpp_initialize_battery()
3816 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_VOLTAGE) in hidpp_initialize_battery()
3820 battery = &hidpp->battery; in hidpp_initialize_battery()
3822 n = atomic_inc_return(&battery_no) - 1; in hidpp_initialize_battery()
3823 desc->properties = battery_props; in hidpp_initialize_battery()
3824 desc->num_properties = num_battery_props; in hidpp_initialize_battery()
3825 desc->get_property = hidpp_battery_get_property; in hidpp_initialize_battery()
3826 sprintf(battery->name, "hidpp_battery_%ld", n); in hidpp_initialize_battery()
3827 desc->name = battery->name; in hidpp_initialize_battery()
3828 desc->type = POWER_SUPPLY_TYPE_BATTERY; in hidpp_initialize_battery()
3829 desc->use_for_apm = 0; in hidpp_initialize_battery()
3831 battery->ps = devm_power_supply_register(&hidpp->hid_dev->dev, in hidpp_initialize_battery()
3832 &battery->desc, in hidpp_initialize_battery()
3834 if (IS_ERR(battery->ps)) in hidpp_initialize_battery()
3835 return PTR_ERR(battery->ps); in hidpp_initialize_battery()
3837 power_supply_powers(battery->ps, &hidpp->hid_dev->dev); in hidpp_initialize_battery()
3847 if (hidpp->protocol_major < 2) in hidpp_overwrite_name()
3856 snprintf(hdev->name, sizeof(hdev->name), "%s", name); in hidpp_overwrite_name()
3878 struct input_dev *input_dev = devm_input_allocate_device(&hdev->dev); in hidpp_allocate_input()
3885 input_dev->open = hidpp_input_open; in hidpp_allocate_input()
3886 input_dev->close = hidpp_input_close; in hidpp_allocate_input()
3888 input_dev->name = hidpp->name; in hidpp_allocate_input()
3889 input_dev->phys = hdev->phys; in hidpp_allocate_input()
3890 input_dev->uniq = hdev->uniq; in hidpp_allocate_input()
3891 input_dev->id.bustype = hdev->bus; in hidpp_allocate_input()
3892 input_dev->id.vendor = hdev->vendor; in hidpp_allocate_input()
3893 input_dev->id.product = hdev->product; in hidpp_allocate_input()
3894 input_dev->id.version = hdev->version; in hidpp_allocate_input()
3895 input_dev->dev.parent = &hdev->dev; in hidpp_allocate_input()
3902 struct hid_device *hdev = hidpp->hid_dev; in hidpp_connect_event()
3904 bool connected = atomic_read(&hidpp->connected); in hidpp_connect_event()
3909 if (hidpp->battery.ps) { in hidpp_connect_event()
3910 hidpp->battery.online = false; in hidpp_connect_event()
3911 hidpp->battery.status = POWER_SUPPLY_STATUS_UNKNOWN; in hidpp_connect_event()
3912 hidpp->battery.level = POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN; in hidpp_connect_event()
3913 power_supply_changed(hidpp->battery.ps); in hidpp_connect_event()
3918 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) { in hidpp_connect_event()
3922 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) { in hidpp_connect_event()
3926 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_K400) { in hidpp_connect_event()
3932 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_WHEELS) { in hidpp_connect_event()
3938 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_EXTRA_MOUSE_BTNS) { in hidpp_connect_event()
3944 if (hidpp->quirks & HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS) { in hidpp_connect_event()
3952 if (!hidpp->protocol_major) { in hidpp_connect_event()
3960 if (hidpp->name == hdev->name && hidpp->protocol_major >= 2) { in hidpp_connect_event()
3963 devm_name = devm_kasprintf(&hdev->dev, GFP_KERNEL, in hidpp_connect_event()
3969 hidpp->name = devm_name; in hidpp_connect_event()
3977 if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP10_BATTERY) { in hidpp_connect_event()
3979 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_MILEAGE) in hidpp_connect_event()
3983 } else if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_BATTERY) { in hidpp_connect_event()
3984 if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_VOLTAGE) in hidpp_connect_event()
3986 else if (hidpp->capabilities & HIDPP_CAPABILITY_UNIFIED_BATTERY) in hidpp_connect_event()
3991 if (hidpp->battery.ps) in hidpp_connect_event()
3992 power_supply_changed(hidpp->battery.ps); in hidpp_connect_event()
3994 if (hidpp->capabilities & HIDPP_CAPABILITY_HI_RES_SCROLL) in hidpp_connect_event()
3997 if (!(hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT) || hidpp->delayed_input) in hidpp_connect_event()
4015 hidpp->delayed_input = input; in hidpp_connect_event()
4034 re = &(hdev->report_enum[HID_OUTPUT_REPORT]); in hidpp_get_report_length()
4035 report = re->report_id_hash[id]; in hidpp_get_report_length()
4039 return report->field[0]->report_count + 1; in hidpp_get_report_length()
4074 hidpp->very_long_report_length = report_length; in hidpp_validate_device()
4090 report_list = &hdev->report_enum[HID_INPUT_REPORT].report_list; in hidpp_application_equals()
4092 return report && report->application == application; in hidpp_application_equals()
4104 hidpp = devm_kzalloc(&hdev->dev, sizeof(*hidpp), GFP_KERNEL); in hidpp_probe()
4106 return -ENOMEM; in hidpp_probe()
4108 hidpp->hid_dev = hdev; in hidpp_probe()
4109 hidpp->name = hdev->name; in hidpp_probe()
4110 hidpp->quirks = id->driver_data; in hidpp_probe()
4122 hidpp->supported_reports = hidpp_validate_device(hdev); in hidpp_probe()
4124 if (!hidpp->supported_reports) { in hidpp_probe()
4126 devm_kfree(&hdev->dev, hidpp); in hidpp_probe()
4130 if (id->group == HID_GROUP_LOGITECH_DJ_DEVICE) in hidpp_probe()
4131 hidpp->quirks |= HIDPP_QUIRK_UNIFYING; in hidpp_probe()
4133 if (id->group == HID_GROUP_LOGITECH_27MHZ_DEVICE && in hidpp_probe()
4135 hidpp->quirks |= HIDPP_QUIRK_HIDPP_WHEELS | in hidpp_probe()
4138 if (id->group == HID_GROUP_LOGITECH_27MHZ_DEVICE && in hidpp_probe()
4140 hidpp->quirks |= HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS; in hidpp_probe()
4143 hidpp->quirks &= ~HIDPP_QUIRK_CLASS_WTP; in hidpp_probe()
4144 hidpp->quirks &= ~HIDPP_QUIRK_NO_HIDINPUT; in hidpp_probe()
4147 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) { in hidpp_probe()
4151 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_K400) { in hidpp_probe()
4157 INIT_WORK(&hidpp->work, delayed_work_cb); in hidpp_probe()
4158 mutex_init(&hidpp->send_mutex); in hidpp_probe()
4159 init_waitqueue_head(&hidpp->wait); in hidpp_probe()
4162 ret = sysfs_create_group(&hdev->dev.kobj, &ps_attribute_group); in hidpp_probe()
4165 hdev->name); in hidpp_probe()
4179 dev_err(&hdev->dev, "%s:hid_hw_open returned error:%d\n", in hidpp_probe()
4187 if (hidpp->quirks & HIDPP_QUIRK_UNIFYING) in hidpp_probe()
4191 atomic_set(&hidpp->connected, connected); in hidpp_probe()
4192 if (!(hidpp->quirks & HIDPP_QUIRK_UNIFYING)) { in hidpp_probe()
4194 ret = -ENODEV; in hidpp_probe()
4202 if (connected && hidpp->protocol_major >= 2) { in hidpp_probe()
4204 if (ret == -ENOENT) in hidpp_probe()
4205 hidpp->wireless_feature_index = 0; in hidpp_probe()
4210 if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)) { in hidpp_probe()
4214 } else if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_G920)) { in hidpp_probe()
4227 if (hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT) in hidpp_probe()
4237 if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) { in hidpp_probe()
4240 hid_warn(hidpp->hid_dev, in hidpp_probe()
4252 sysfs_remove_group(&hdev->dev.kobj, &ps_attribute_group); in hidpp_probe()
4253 cancel_work_sync(&hidpp->work); in hidpp_probe()
4254 mutex_destroy(&hidpp->send_mutex); in hidpp_probe()
4265 sysfs_remove_group(&hdev->dev.kobj, &ps_attribute_group); in hidpp_remove()
4268 cancel_work_sync(&hidpp->work); in hidpp_remove()
4269 mutex_destroy(&hidpp->send_mutex); in hidpp_remove()
4301 { /* Keyboard MX5000 (Bluetooth-receiver in HID proxy mode) */
4304 { /* Dinovo Edge (Bluetooth-receiver in HID proxy mode) */
4307 { /* Keyboard MX5500 (Bluetooth-receiver in HID proxy mode) */
4313 { /* Keyboard LX501 (Y-RR53) */
4316 { /* Keyboard MX3000 (Y-RAM74) */
4319 { /* Keyboard MX3200 (Y-RAV80) */
4355 { /* M-RCQ142 V470 Cordless Laser Mouse over Bluetooth */
4371 { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}
4375 .name = "logitech-hidpp-device",