H A D | hid-logitech-hidpp.c | 49 * There are two hidpp protocols in use, the first version hidpp10 is known 170 static int hidpp_send_message_sync(struct hidpp_device *hidpp, hidpp_send_message_sync() argument 176 mutex_lock(&hidpp->send_mutex); hidpp_send_message_sync() 178 hidpp->send_receive_buf = response; hidpp_send_message_sync() 179 hidpp->answer_available = false; hidpp_send_message_sync() 187 ret = __hidpp_send_report(hidpp->hid_dev, message); hidpp_send_message_sync() 195 if (!wait_event_timeout(hidpp->wait, hidpp->answer_available, hidpp_send_message_sync() 205 dbg_hid("%s:got hidpp error %02X\n", __func__, ret); hidpp_send_message_sync() 212 dbg_hid("%s:got hidpp 2.0 error %02X\n", __func__, ret); hidpp_send_message_sync() 217 mutex_unlock(&hidpp->send_mutex); hidpp_send_message_sync() 222 static int hidpp_send_fap_command_sync(struct hidpp_device *hidpp, hidpp_send_fap_command_sync() argument 240 ret = hidpp_send_message_sync(hidpp, message, response); hidpp_send_fap_command_sync() 274 struct hidpp_device *hidpp = container_of(work, struct hidpp_device, delayed_work_cb() local 276 hidpp_connect_event(hidpp); delayed_work_cb() 384 static int hidpp_root_get_feature(struct hidpp_device *hidpp, u16 feature, hidpp_root_get_feature() argument 391 ret = hidpp_send_fap_command_sync(hidpp, hidpp_root_get_feature() 404 static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp) hidpp_root_get_protocol_version() argument 409 ret = hidpp_send_fap_command_sync(hidpp, hidpp_root_get_protocol_version() 415 hidpp->protocol_major = 1; hidpp_root_get_protocol_version() 416 hidpp->protocol_minor = 0; hidpp_root_get_protocol_version() 425 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", hidpp_root_get_protocol_version() 432 hidpp->protocol_major = response.fap.params[0]; hidpp_root_get_protocol_version() 433 hidpp->protocol_minor = response.fap.params[1]; hidpp_root_get_protocol_version() 438 static bool hidpp_is_connected(struct hidpp_device *hidpp) hidpp_is_connected() argument 442 ret = hidpp_root_get_protocol_version(hidpp); hidpp_is_connected() 444 hid_dbg(hidpp->hid_dev, "HID++ %u.%u device connected.\n", hidpp_is_connected() 445 hidpp->protocol_major, hidpp->protocol_minor); hidpp_is_connected() 459 static int hidpp_devicenametype_get_count(struct hidpp_device *hidpp, hidpp_devicenametype_get_count() argument 465 ret = hidpp_send_fap_command_sync(hidpp, feature_index, hidpp_devicenametype_get_count() 469 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", hidpp_devicenametype_get_count() 481 static int hidpp_devicenametype_get_device_name(struct hidpp_device *hidpp, hidpp_devicenametype_get_device_name() argument 488 ret = hidpp_send_fap_command_sync(hidpp, feature_index, hidpp_devicenametype_get_device_name() 493 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", hidpp_devicenametype_get_device_name() 514 static char *hidpp_get_device_name(struct hidpp_device *hidpp) hidpp_get_device_name() argument 523 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_GET_DEVICE_NAME_TYPE, hidpp_get_device_name() 528 ret = hidpp_devicenametype_get_count(hidpp, feature_index, hidpp_get_device_name() 538 ret = hidpp_devicenametype_get_device_name(hidpp, hidpp_get_device_name() 598 static int hidpp_touchpad_get_raw_info(struct hidpp_device *hidpp, hidpp_touchpad_get_raw_info() argument 605 ret = hidpp_send_fap_command_sync(hidpp, feature_index, hidpp_touchpad_get_raw_info() 609 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", hidpp_touchpad_get_raw_info() 711 static void wtp_populate_input(struct hidpp_device *hidpp, wtp_populate_input() argument 714 struct wtp_data *wd = hidpp->private_data; wtp_populate_input() 731 if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS) wtp_populate_input() 767 static void wtp_send_raw_xy_event(struct hidpp_device *hidpp, wtp_send_raw_xy_event() argument 770 struct wtp_data *wd = hidpp->private_data; wtp_send_raw_xy_event() 777 !(hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS)) wtp_send_raw_xy_event() 786 static int wtp_mouse_raw_xy_event(struct hidpp_device *hidpp, u8 *data) wtp_mouse_raw_xy_event() argument 788 struct wtp_data *wd = hidpp->private_data; wtp_mouse_raw_xy_event() 820 wtp_send_raw_xy_event(hidpp, &raw); wtp_mouse_raw_xy_event() 827 struct hidpp_device *hidpp = hid_get_drvdata(hdev); wtp_raw_event() local 828 struct wtp_data *wd = hidpp->private_data; wtp_raw_event() 842 if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS) { wtp_raw_event() 852 return wtp_mouse_raw_xy_event(hidpp, &data[7]); wtp_raw_event() 859 hidpp_touchpad_raw_xy_event(hidpp, data + 4, &raw); wtp_raw_event() 861 wtp_send_raw_xy_event(hidpp, &raw); wtp_raw_event() 868 static int wtp_get_config(struct hidpp_device *hidpp) wtp_get_config() argument 870 struct wtp_data *wd = hidpp->private_data; wtp_get_config() 875 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_TOUCHPAD_RAW_XY, wtp_get_config() 881 ret = hidpp_touchpad_get_raw_info(hidpp, wd->mt_feature_index, wtp_get_config() 899 struct hidpp_device *hidpp = hid_get_drvdata(hdev); wtp_allocate() local 907 hidpp->private_data = wd; wtp_allocate() 914 struct hidpp_device *hidpp = hid_get_drvdata(hdev); wtp_connect() local 915 struct wtp_data *wd = hidpp->private_data; wtp_connect() 922 ret = wtp_get_config(hidpp); wtp_connect() 929 return hidpp_touchpad_set_raw_report_state(hidpp, wd->mt_feature_index, wtp_connect() 941 struct hidpp_device *hidpp = hid_get_drvdata(hdev); hidpp_input_mapping() local 943 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) hidpp_input_mapping() 949 static void hidpp_populate_input(struct hidpp_device *hidpp, hidpp_populate_input() argument 952 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) hidpp_populate_input() 953 wtp_populate_input(hidpp, input, origin_is_hid_core); hidpp_populate_input() 959 struct hidpp_device *hidpp = hid_get_drvdata(hdev); hidpp_input_configured() local 962 hidpp_populate_input(hidpp, input, true); hidpp_input_configured() 965 static int hidpp_raw_hidpp_event(struct hidpp_device *hidpp, u8 *data, hidpp_raw_hidpp_event() argument 968 struct hidpp_report *question = hidpp->send_receive_buf; hidpp_raw_hidpp_event() 969 struct hidpp_report *answer = hidpp->send_receive_buf; hidpp_raw_hidpp_event() 976 if (unlikely(mutex_is_locked(&hidpp->send_mutex))) { hidpp_raw_hidpp_event() 984 hidpp->answer_available = true; hidpp_raw_hidpp_event() 985 wake_up(&hidpp->wait); hidpp_raw_hidpp_event() 997 atomic_set(&hidpp->connected, hidpp_raw_hidpp_event() 999 if ((hidpp->quirks & HIDPP_QUIRK_DELAYED_INIT) && hidpp_raw_hidpp_event() 1000 (schedule_work(&hidpp->work) == 0)) hidpp_raw_hidpp_event() 1011 struct hidpp_device *hidpp = hid_get_drvdata(hdev); hidpp_raw_event() local 1022 ret = hidpp_raw_hidpp_event(hidpp, data, size); hidpp_raw_event() 1030 ret = hidpp_raw_hidpp_event(hidpp, data, size); hidpp_raw_event() 1039 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) hidpp_raw_event() 1047 struct hidpp_device *hidpp = hid_get_drvdata(hdev); hidpp_overwrite_name() local 1056 name = hidpp_get_unifying_name(hidpp); hidpp_overwrite_name() 1058 name = hidpp_get_device_name(hidpp); hidpp_overwrite_name() 1085 struct hidpp_device *hidpp = hid_get_drvdata(hdev); hidpp_allocate_input() local 1094 input_dev->name = hidpp->name; hidpp_allocate_input() 1106 static void hidpp_connect_event(struct hidpp_device *hidpp) hidpp_connect_event() argument 1108 struct hid_device *hdev = hidpp->hid_dev; hidpp_connect_event() 1110 bool connected = atomic_read(&hidpp->connected); hidpp_connect_event() 1114 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) { hidpp_connect_event() 1120 if (!connected || hidpp->delayed_input) hidpp_connect_event() 1123 if (!hidpp->protocol_major) { hidpp_connect_event() 1124 ret = !hidpp_is_connected(hidpp); hidpp_connect_event() 1134 hidpp->protocol_major, hidpp->protocol_minor); hidpp_connect_event() 1136 if (!hidpp->name || hidpp->name == hdev->name) { hidpp_connect_event() 1137 name = hidpp_get_device_name(hidpp); hidpp_connect_event() 1149 hidpp->name = devm_name; hidpp_connect_event() 1158 hidpp_populate_input(hidpp, input, false); hidpp_connect_event() 1164 hidpp->delayed_input = input; hidpp_connect_event() 1169 struct hidpp_device *hidpp; hidpp_probe() local 1174 hidpp = devm_kzalloc(&hdev->dev, sizeof(struct hidpp_device), hidpp_probe() 1176 if (!hidpp) hidpp_probe() 1179 hidpp->hid_dev = hdev; hidpp_probe() 1180 hidpp->name = hdev->name; hidpp_probe() 1181 hid_set_drvdata(hdev, hidpp); hidpp_probe() 1183 hidpp->quirks = id->driver_data; hidpp_probe() 1186 hidpp->quirks &= ~HIDPP_QUIRK_CLASS_WTP; hidpp_probe() 1187 hidpp->quirks &= ~HIDPP_QUIRK_DELAYED_INIT; hidpp_probe() 1190 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) { hidpp_probe() 1196 INIT_WORK(&hidpp->work, delayed_work_cb); hidpp_probe() 1197 mutex_init(&hidpp->send_mutex); hidpp_probe() 1198 init_waitqueue_head(&hidpp->wait); hidpp_probe() 1209 connected = hidpp_is_connected(hidpp); hidpp_probe() 1219 hidpp->protocol_major, hidpp->protocol_minor); hidpp_probe() 1223 atomic_set(&hidpp->connected, connected); hidpp_probe() 1225 if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)) { hidpp_probe() 1226 ret = wtp_get_config(hidpp); hidpp_probe() 1234 if (hidpp->quirks & HIDPP_QUIRK_DELAYED_INIT) hidpp_probe() 1243 if (hidpp->quirks & HIDPP_QUIRK_DELAYED_INIT) { hidpp_probe() 1247 hidpp_connect_event(hidpp); hidpp_probe() 1254 cancel_work_sync(&hidpp->work); hidpp_probe() 1255 mutex_destroy(&hidpp->send_mutex); hidpp_probe() 1263 struct hidpp_device *hidpp = hid_get_drvdata(hdev); hidpp_remove() local 1265 cancel_work_sync(&hidpp->work); hidpp_remove() 1266 mutex_destroy(&hidpp->send_mutex); hidpp_remove() 1293 .name = "logitech-hidpp-device",
|