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