Lines Matching refs:hidpp
181 static int hidpp_send_message_sync(struct hidpp_device *hidpp, in hidpp_send_message_sync() argument
187 mutex_lock(&hidpp->send_mutex); in hidpp_send_message_sync()
189 hidpp->send_receive_buf = response; in hidpp_send_message_sync()
190 hidpp->answer_available = false; in hidpp_send_message_sync()
198 ret = __hidpp_send_report(hidpp->hid_dev, message); in hidpp_send_message_sync()
206 if (!wait_event_timeout(hidpp->wait, hidpp->answer_available, in hidpp_send_message_sync()
228 mutex_unlock(&hidpp->send_mutex); in hidpp_send_message_sync()
233 static int hidpp_send_fap_command_sync(struct hidpp_device *hidpp, in hidpp_send_fap_command_sync() argument
251 ret = hidpp_send_message_sync(hidpp, message, response); in hidpp_send_fap_command_sync()
285 struct hidpp_device *hidpp = container_of(work, struct hidpp_device, in delayed_work_cb() local
287 hidpp_connect_event(hidpp); in delayed_work_cb()
395 static int hidpp_root_get_feature(struct hidpp_device *hidpp, u16 feature, in hidpp_root_get_feature() argument
402 ret = hidpp_send_fap_command_sync(hidpp, in hidpp_root_get_feature()
415 static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp) in hidpp_root_get_protocol_version() argument
420 ret = hidpp_send_fap_command_sync(hidpp, in hidpp_root_get_protocol_version()
426 hidpp->protocol_major = 1; in hidpp_root_get_protocol_version()
427 hidpp->protocol_minor = 0; in hidpp_root_get_protocol_version()
436 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_root_get_protocol_version()
443 hidpp->protocol_major = response.fap.params[0]; in hidpp_root_get_protocol_version()
444 hidpp->protocol_minor = response.fap.params[1]; in hidpp_root_get_protocol_version()
449 static bool hidpp_is_connected(struct hidpp_device *hidpp) in hidpp_is_connected() argument
453 ret = hidpp_root_get_protocol_version(hidpp); in hidpp_is_connected()
455 hid_dbg(hidpp->hid_dev, "HID++ %u.%u device connected.\n", in hidpp_is_connected()
456 hidpp->protocol_major, hidpp->protocol_minor); in hidpp_is_connected()
470 static int hidpp_devicenametype_get_count(struct hidpp_device *hidpp, in hidpp_devicenametype_get_count() argument
476 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_devicenametype_get_count()
480 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_devicenametype_get_count()
492 static int hidpp_devicenametype_get_device_name(struct hidpp_device *hidpp, in hidpp_devicenametype_get_device_name() argument
499 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_devicenametype_get_device_name()
504 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_devicenametype_get_device_name()
525 static char *hidpp_get_device_name(struct hidpp_device *hidpp) in hidpp_get_device_name() argument
534 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_GET_DEVICE_NAME_TYPE, in hidpp_get_device_name()
539 ret = hidpp_devicenametype_get_count(hidpp, feature_index, in hidpp_get_device_name()
549 ret = hidpp_devicenametype_get_device_name(hidpp, in hidpp_get_device_name()
584 static int hidpp_touchpad_fw_items_set(struct hidpp_device *hidpp, in hidpp_touchpad_fw_items_set() argument
592 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_touchpad_fw_items_set()
596 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_touchpad_fw_items_set()
655 static int hidpp_touchpad_get_raw_info(struct hidpp_device *hidpp, in hidpp_touchpad_get_raw_info() argument
662 ret = hidpp_send_fap_command_sync(hidpp, feature_index, in hidpp_touchpad_get_raw_info()
666 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", in hidpp_touchpad_get_raw_info()
768 static void wtp_populate_input(struct hidpp_device *hidpp, in wtp_populate_input() argument
771 struct wtp_data *wd = hidpp->private_data; in wtp_populate_input()
788 if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS) in wtp_populate_input()
824 static void wtp_send_raw_xy_event(struct hidpp_device *hidpp, in wtp_send_raw_xy_event() argument
827 struct wtp_data *wd = hidpp->private_data; in wtp_send_raw_xy_event()
834 !(hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS)) in wtp_send_raw_xy_event()
843 static int wtp_mouse_raw_xy_event(struct hidpp_device *hidpp, u8 *data) in wtp_mouse_raw_xy_event() argument
845 struct wtp_data *wd = hidpp->private_data; in wtp_mouse_raw_xy_event()
877 wtp_send_raw_xy_event(hidpp, &raw); in wtp_mouse_raw_xy_event()
884 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in wtp_raw_event() local
885 struct wtp_data *wd = hidpp->private_data; in wtp_raw_event()
899 if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS) { in wtp_raw_event()
909 return wtp_mouse_raw_xy_event(hidpp, &data[7]); in wtp_raw_event()
916 hidpp_touchpad_raw_xy_event(hidpp, data + 4, &raw); in wtp_raw_event()
918 wtp_send_raw_xy_event(hidpp, &raw); in wtp_raw_event()
925 static int wtp_get_config(struct hidpp_device *hidpp) in wtp_get_config() argument
927 struct wtp_data *wd = hidpp->private_data; in wtp_get_config()
932 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_TOUCHPAD_RAW_XY, in wtp_get_config()
938 ret = hidpp_touchpad_get_raw_info(hidpp, wd->mt_feature_index, in wtp_get_config()
956 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in wtp_allocate() local
964 hidpp->private_data = wd; in wtp_allocate()
971 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in wtp_connect() local
972 struct wtp_data *wd = hidpp->private_data; in wtp_connect()
979 ret = wtp_get_config(hidpp); in wtp_connect()
986 return hidpp_touchpad_set_raw_report_state(hidpp, wd->mt_feature_index, in wtp_connect()
1061 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in m560_allocate() local
1069 hidpp->private_data = d; in m560_allocate()
1076 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in m560_raw_event() local
1077 struct m560_private_data *mydata = hidpp->private_data; in m560_raw_event()
1163 static void m560_populate_input(struct hidpp_device *hidpp, in m560_populate_input() argument
1166 struct m560_private_data *mydata = hidpp->private_data; in m560_populate_input()
1209 static int k400_disable_tap_to_click(struct hidpp_device *hidpp) in k400_disable_tap_to_click() argument
1211 struct k400_private_data *k400 = hidpp->private_data; in k400_disable_tap_to_click()
1217 ret = hidpp_root_get_feature(hidpp, in k400_disable_tap_to_click()
1225 ret = hidpp_touchpad_fw_items_set(hidpp, k400->feature_index, &items); in k400_disable_tap_to_click()
1234 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in k400_allocate() local
1242 hidpp->private_data = k400; in k400_allocate()
1249 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in k400_connect() local
1257 return k400_disable_tap_to_click(hidpp); in k400_connect()
1268 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_input_mapping() local
1270 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) in hidpp_input_mapping()
1272 else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560 && in hidpp_input_mapping()
1279 static void hidpp_populate_input(struct hidpp_device *hidpp, in hidpp_populate_input() argument
1282 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) in hidpp_populate_input()
1283 wtp_populate_input(hidpp, input, origin_is_hid_core); in hidpp_populate_input()
1284 else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) in hidpp_populate_input()
1285 m560_populate_input(hidpp, input, origin_is_hid_core); in hidpp_populate_input()
1291 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_input_configured() local
1294 hidpp_populate_input(hidpp, input, true); in hidpp_input_configured()
1299 static int hidpp_raw_hidpp_event(struct hidpp_device *hidpp, u8 *data, in hidpp_raw_hidpp_event() argument
1302 struct hidpp_report *question = hidpp->send_receive_buf; in hidpp_raw_hidpp_event()
1303 struct hidpp_report *answer = hidpp->send_receive_buf; in hidpp_raw_hidpp_event()
1310 if (unlikely(mutex_is_locked(&hidpp->send_mutex))) { in hidpp_raw_hidpp_event()
1318 hidpp->answer_available = true; in hidpp_raw_hidpp_event()
1319 wake_up(&hidpp->wait); in hidpp_raw_hidpp_event()
1331 atomic_set(&hidpp->connected, in hidpp_raw_hidpp_event()
1333 if ((hidpp->quirks & HIDPP_QUIRK_CONNECT_EVENTS) && in hidpp_raw_hidpp_event()
1334 (schedule_work(&hidpp->work) == 0)) in hidpp_raw_hidpp_event()
1345 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_raw_event() local
1356 ret = hidpp_raw_hidpp_event(hidpp, data, size); in hidpp_raw_event()
1364 ret = hidpp_raw_hidpp_event(hidpp, data, size); in hidpp_raw_event()
1373 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) in hidpp_raw_event()
1375 else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) in hidpp_raw_event()
1383 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_overwrite_name() local
1392 name = hidpp_get_unifying_name(hidpp); in hidpp_overwrite_name()
1394 name = hidpp_get_device_name(hidpp); in hidpp_overwrite_name()
1421 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_allocate_input() local
1430 input_dev->name = hidpp->name; in hidpp_allocate_input()
1442 static void hidpp_connect_event(struct hidpp_device *hidpp) in hidpp_connect_event() argument
1444 struct hid_device *hdev = hidpp->hid_dev; in hidpp_connect_event()
1446 bool connected = atomic_read(&hidpp->connected); in hidpp_connect_event()
1450 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) { in hidpp_connect_event()
1454 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) { in hidpp_connect_event()
1458 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_K400) { in hidpp_connect_event()
1464 if (!connected || hidpp->delayed_input) in hidpp_connect_event()
1469 if (!hidpp->protocol_major) { in hidpp_connect_event()
1470 ret = !hidpp_is_connected(hidpp); in hidpp_connect_event()
1476 hidpp->protocol_major, hidpp->protocol_minor); in hidpp_connect_event()
1479 if (!(hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT)) in hidpp_connect_event()
1483 if (!hidpp->name || hidpp->name == hdev->name) { in hidpp_connect_event()
1484 name = hidpp_get_device_name(hidpp); in hidpp_connect_event()
1496 hidpp->name = devm_name; in hidpp_connect_event()
1505 hidpp_populate_input(hidpp, input, false); in hidpp_connect_event()
1511 hidpp->delayed_input = input; in hidpp_connect_event()
1516 struct hidpp_device *hidpp; in hidpp_probe() local
1521 hidpp = devm_kzalloc(&hdev->dev, sizeof(struct hidpp_device), in hidpp_probe()
1523 if (!hidpp) in hidpp_probe()
1526 hidpp->hid_dev = hdev; in hidpp_probe()
1527 hidpp->name = hdev->name; in hidpp_probe()
1528 hid_set_drvdata(hdev, hidpp); in hidpp_probe()
1530 hidpp->quirks = id->driver_data; in hidpp_probe()
1533 hidpp->quirks &= ~HIDPP_QUIRK_CLASS_WTP; in hidpp_probe()
1534 hidpp->quirks &= ~HIDPP_QUIRK_CONNECT_EVENTS; in hidpp_probe()
1535 hidpp->quirks &= ~HIDPP_QUIRK_NO_HIDINPUT; in hidpp_probe()
1538 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) { in hidpp_probe()
1542 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) { in hidpp_probe()
1546 } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_K400) { in hidpp_probe()
1552 INIT_WORK(&hidpp->work, delayed_work_cb); in hidpp_probe()
1553 mutex_init(&hidpp->send_mutex); in hidpp_probe()
1554 init_waitqueue_head(&hidpp->wait); in hidpp_probe()
1565 connected = hidpp_is_connected(hidpp); in hidpp_probe()
1575 hidpp->protocol_major, hidpp->protocol_minor); in hidpp_probe()
1579 atomic_set(&hidpp->connected, connected); in hidpp_probe()
1581 if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)) { in hidpp_probe()
1582 ret = wtp_get_config(hidpp); in hidpp_probe()
1590 if (hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT) in hidpp_probe()
1599 if (hidpp->quirks & HIDPP_QUIRK_CONNECT_EVENTS) { in hidpp_probe()
1603 hidpp_connect_event(hidpp); in hidpp_probe()
1610 cancel_work_sync(&hidpp->work); in hidpp_probe()
1611 mutex_destroy(&hidpp->send_mutex); in hidpp_probe()
1619 struct hidpp_device *hidpp = hid_get_drvdata(hdev); in hidpp_remove() local
1621 cancel_work_sync(&hidpp->work); in hidpp_remove()
1622 mutex_destroy(&hidpp->send_mutex); in hidpp_remove()