Lines Matching refs:hdev

56 	struct hid_device *hdev;  member
91 static int lenovo_led_set_tp10ubkbd(struct hid_device *hdev, u8 led_code, in lenovo_led_set_tp10ubkbd() argument
94 struct lenovo_drvdata *data = hid_get_drvdata(hdev); in lenovo_led_set_tp10ubkbd()
102 ret = hid_hw_raw_request(hdev, data->led_report[0], data->led_report, 3, in lenovo_led_set_tp10ubkbd()
106 hid_err(hdev, "Set LED output report error: %d\n", ret); in lenovo_led_set_tp10ubkbd()
123 lenovo_led_set_tp10ubkbd(data->hdev, TP10UBKBD_FN_LOCK_LED, in lenovo_tp10ubkbd_sync_fn_lock()
153 static const __u8 *lenovo_report_fixup(struct hid_device *hdev, __u8 *rdesc, in lenovo_report_fixup() argument
156 switch (hdev->product) { in lenovo_report_fixup()
186 static int lenovo_input_mapping_tpkbd(struct hid_device *hdev, in lenovo_input_mapping_tpkbd() argument
192 hid_set_drvdata(hdev, (void *)1); in lenovo_input_mapping_tpkbd()
199 static int lenovo_input_mapping_cptkbd(struct hid_device *hdev, in lenovo_input_mapping_cptkbd() argument
273 static int lenovo_input_mapping_tpIIkbd(struct hid_device *hdev, in lenovo_input_mapping_tpIIkbd() argument
368 static int lenovo_input_mapping_scrollpoint(struct hid_device *hdev, in lenovo_input_mapping_scrollpoint() argument
379 static int lenovo_input_mapping_tp10_ultrabook_kbd(struct hid_device *hdev, in lenovo_input_mapping_tp10_ultrabook_kbd() argument
417 static int lenovo_input_mapping_x1_tab_kbd(struct hid_device *hdev, in lenovo_input_mapping_x1_tab_kbd() argument
465 static int lenovo_input_mapping(struct hid_device *hdev, in lenovo_input_mapping() argument
469 switch (hdev->product) { in lenovo_input_mapping()
471 return lenovo_input_mapping_tpkbd(hdev, hi, field, in lenovo_input_mapping()
475 return lenovo_input_mapping_cptkbd(hdev, hi, field, in lenovo_input_mapping()
479 return lenovo_input_mapping_tpIIkbd(hdev, hi, field, in lenovo_input_mapping()
487 return lenovo_input_mapping_scrollpoint(hdev, hi, field, in lenovo_input_mapping()
490 return lenovo_input_mapping_tp10_ultrabook_kbd(hdev, hi, field, in lenovo_input_mapping()
497 return lenovo_input_mapping_x1_tab_kbd(hdev, hi, field, usage, bit, max); in lenovo_input_mapping()
506 static int lenovo_send_cmd_cptkbd(struct hid_device *hdev, in lenovo_send_cmd_cptkbd() argument
525 switch (hdev->product) { in lenovo_send_cmd_cptkbd()
528 ret = hid_hw_raw_request(hdev, 0x13, buf, 3, in lenovo_send_cmd_cptkbd()
533 ret = hid_hw_output_report(hdev, buf, 3); in lenovo_send_cmd_cptkbd()
545 static void lenovo_features_set_cptkbd(struct hid_device *hdev) in lenovo_features_set_cptkbd() argument
548 struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev); in lenovo_features_set_cptkbd()
554 if (hdev->product == USB_DEVICE_ID_LENOVO_CUSBKBD || in lenovo_features_set_cptkbd()
555 hdev->product == USB_DEVICE_ID_LENOVO_CBTKBD) { in lenovo_features_set_cptkbd()
556 ret = lenovo_send_cmd_cptkbd(hdev, 0x01, 0x03); in lenovo_features_set_cptkbd()
558 hid_warn(hdev, "Failed to switch F7/9/11 mode: %d\n", ret); in lenovo_features_set_cptkbd()
562 ret = lenovo_send_cmd_cptkbd(hdev, 0x09, 0x01); in lenovo_features_set_cptkbd()
564 hid_warn(hdev, "Failed to switch middle button: %d\n", ret); in lenovo_features_set_cptkbd()
566 ret = lenovo_send_cmd_cptkbd(hdev, 0x05, cptkbd_data->fn_lock); in lenovo_features_set_cptkbd()
568 hid_err(hdev, "Fn-lock setting failed: %d\n", ret); in lenovo_features_set_cptkbd()
570 ret = lenovo_send_cmd_cptkbd(hdev, 0x02, cptkbd_data->sensitivity); in lenovo_features_set_cptkbd()
572 hid_err(hdev, "Sensitivity setting failed: %d\n", ret); in lenovo_features_set_cptkbd()
579 struct hid_device *hdev = to_hid_device(dev); in attr_fn_lock_show() local
580 struct lenovo_drvdata *data = hid_get_drvdata(hdev); in attr_fn_lock_show()
590 struct hid_device *hdev = to_hid_device(dev); in attr_fn_lock_store() local
591 struct lenovo_drvdata *data = hid_get_drvdata(hdev); in attr_fn_lock_store()
601 switch (hdev->product) { in attr_fn_lock_store()
606 lenovo_features_set_cptkbd(hdev); in attr_fn_lock_store()
614 ret = lenovo_led_set_tp10ubkbd(hdev, TP10UBKBD_FN_LOCK_LED, value); in attr_fn_lock_store()
627 struct hid_device *hdev = to_hid_device(dev); in attr_sensitivity_show_cptkbd() local
628 struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev); in attr_sensitivity_show_cptkbd()
638 struct hid_device *hdev = to_hid_device(dev); in attr_sensitivity_store_cptkbd() local
639 struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev); in attr_sensitivity_store_cptkbd()
646 lenovo_features_set_cptkbd(hdev); in attr_sensitivity_store_cptkbd()
655 struct hid_device *hdev = to_hid_device(dev); in attr_middleclick_workaround_show_cptkbd() local
656 struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev); in attr_middleclick_workaround_show_cptkbd()
667 struct hid_device *hdev = to_hid_device(dev); in attr_middleclick_workaround_store_cptkbd() local
668 struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev); in attr_middleclick_workaround_store_cptkbd()
710 static int lenovo_raw_event_TP_X12_tab(struct hid_device *hdev, u32 raw_data) in lenovo_raw_event_TP_X12_tab() argument
716 list_for_each_entry(hidinput, &hdev->inputs, list) { in lenovo_raw_event_TP_X12_tab()
733 if (hdev->product == USB_DEVICE_ID_LENOVO_X12_TAB) { in lenovo_raw_event_TP_X12_tab()
741 (hdev->product == USB_DEVICE_ID_LENOVO_X12_TAB) ? in lenovo_raw_event_TP_X12_tab()
760 static int lenovo_raw_event(struct hid_device *hdev, in lenovo_raw_event() argument
768 if (unlikely(hdev->product == USB_DEVICE_ID_LENOVO_CUSBKBD in lenovo_raw_event()
781 if (unlikely((hdev->product == USB_DEVICE_ID_LENOVO_X12_TAB in lenovo_raw_event()
782 || hdev->product == USB_DEVICE_ID_LENOVO_X12_TAB2) in lenovo_raw_event()
784 return lenovo_raw_event_TP_X12_tab(hdev, le32_to_cpu(*(__le32 *)data)); in lenovo_raw_event()
789 static int lenovo_event_tp10ubkbd(struct hid_device *hdev, in lenovo_event_tp10ubkbd() argument
792 struct lenovo_drvdata *data = hid_get_drvdata(hdev); in lenovo_event_tp10ubkbd()
807 static int lenovo_event_cptkbd(struct hid_device *hdev, in lenovo_event_cptkbd() argument
810 struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev); in lenovo_event_cptkbd()
853 static int lenovo_event(struct hid_device *hdev, struct hid_field *field, in lenovo_event() argument
856 if (!hid_get_drvdata(hdev)) in lenovo_event()
859 switch (hdev->product) { in lenovo_event()
864 return lenovo_event_cptkbd(hdev, field, usage, value); in lenovo_event()
871 return lenovo_event_tp10ubkbd(hdev, field, usage, value); in lenovo_event()
877 static int lenovo_features_set_tpkbd(struct hid_device *hdev) in lenovo_features_set_tpkbd() argument
880 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in lenovo_features_set_tpkbd()
882 report = hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[4]; in lenovo_features_set_tpkbd()
892 hid_hw_request(hdev, report, HID_REQ_SET_REPORT); in lenovo_features_set_tpkbd()
900 struct hid_device *hdev = to_hid_device(dev); in attr_press_to_select_show_tpkbd() local
901 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in attr_press_to_select_show_tpkbd()
911 struct hid_device *hdev = to_hid_device(dev); in attr_press_to_select_store_tpkbd() local
912 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in attr_press_to_select_store_tpkbd()
921 lenovo_features_set_tpkbd(hdev); in attr_press_to_select_store_tpkbd()
930 struct hid_device *hdev = to_hid_device(dev); in attr_dragging_show_tpkbd() local
931 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in attr_dragging_show_tpkbd()
941 struct hid_device *hdev = to_hid_device(dev); in attr_dragging_store_tpkbd() local
942 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in attr_dragging_store_tpkbd()
951 lenovo_features_set_tpkbd(hdev); in attr_dragging_store_tpkbd()
960 struct hid_device *hdev = to_hid_device(dev); in attr_release_to_select_show_tpkbd() local
961 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in attr_release_to_select_show_tpkbd()
971 struct hid_device *hdev = to_hid_device(dev); in attr_release_to_select_store_tpkbd() local
972 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in attr_release_to_select_store_tpkbd()
981 lenovo_features_set_tpkbd(hdev); in attr_release_to_select_store_tpkbd()
990 struct hid_device *hdev = to_hid_device(dev); in attr_select_right_show_tpkbd() local
991 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in attr_select_right_show_tpkbd()
1001 struct hid_device *hdev = to_hid_device(dev); in attr_select_right_store_tpkbd() local
1002 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in attr_select_right_store_tpkbd()
1011 lenovo_features_set_tpkbd(hdev); in attr_select_right_store_tpkbd()
1020 struct hid_device *hdev = to_hid_device(dev); in attr_sensitivity_show_tpkbd() local
1021 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in attr_sensitivity_show_tpkbd()
1031 struct hid_device *hdev = to_hid_device(dev); in attr_sensitivity_store_tpkbd() local
1032 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in attr_sensitivity_store_tpkbd()
1039 lenovo_features_set_tpkbd(hdev); in attr_sensitivity_store_tpkbd()
1048 struct hid_device *hdev = to_hid_device(dev); in attr_press_speed_show_tpkbd() local
1049 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in attr_press_speed_show_tpkbd()
1059 struct hid_device *hdev = to_hid_device(dev); in attr_press_speed_store_tpkbd() local
1060 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in attr_press_speed_store_tpkbd()
1067 lenovo_features_set_tpkbd(hdev); in attr_press_speed_store_tpkbd()
1116 static void lenovo_led_set_tpkbd(struct hid_device *hdev) in lenovo_led_set_tpkbd() argument
1118 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in lenovo_led_set_tpkbd()
1121 report = hdev->report_enum[HID_OUTPUT_REPORT].report_id_hash[3]; in lenovo_led_set_tpkbd()
1124 hid_hw_request(hdev, report, HID_REQ_SET_REPORT); in lenovo_led_set_tpkbd()
1131 struct hid_device *hdev = to_hid_device(dev); in lenovo_led_brightness_set() local
1132 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in lenovo_led_brightness_set()
1145 switch (hdev->product) { in lenovo_led_brightness_set()
1147 lenovo_led_set_tpkbd(hdev); in lenovo_led_brightness_set()
1155 ret = lenovo_led_set_tp10ubkbd(hdev, tp10ubkbd_led[led_nr], value); in lenovo_led_brightness_set()
1162 static int lenovo_register_leds(struct hid_device *hdev) in lenovo_register_leds() argument
1164 struct lenovo_drvdata *data = hid_get_drvdata(hdev); in lenovo_register_leds()
1165 size_t name_sz = strlen(dev_name(&hdev->dev)) + 16; in lenovo_register_leds()
1169 name_mute = devm_kzalloc(&hdev->dev, name_sz, GFP_KERNEL); in lenovo_register_leds()
1170 name_micm = devm_kzalloc(&hdev->dev, name_sz, GFP_KERNEL); in lenovo_register_leds()
1172 hid_err(hdev, "Could not allocate memory for led data\n"); in lenovo_register_leds()
1175 snprintf(name_mute, name_sz, "%s:amber:mute", dev_name(&hdev->dev)); in lenovo_register_leds()
1176 snprintf(name_micm, name_sz, "%s:amber:micmute", dev_name(&hdev->dev)); in lenovo_register_leds()
1183 data->led_mute.dev = &hdev->dev; in lenovo_register_leds()
1184 ret = led_classdev_register(&hdev->dev, &data->led_mute); in lenovo_register_leds()
1193 data->led_micmute.dev = &hdev->dev; in lenovo_register_leds()
1194 ret = led_classdev_register(&hdev->dev, &data->led_micmute); in lenovo_register_leds()
1203 static int lenovo_probe_tpkbd(struct hid_device *hdev) in lenovo_probe_tpkbd() argument
1212 if (!hid_get_drvdata(hdev)) in lenovo_probe_tpkbd()
1215 hid_set_drvdata(hdev, NULL); in lenovo_probe_tpkbd()
1219 if (!hid_validate_values(hdev, HID_FEATURE_REPORT, 4, i, 1)) in lenovo_probe_tpkbd()
1222 if (!hid_validate_values(hdev, HID_OUTPUT_REPORT, 3, 0, 2)) in lenovo_probe_tpkbd()
1225 ret = sysfs_create_group(&hdev->dev.kobj, &lenovo_attr_group_tpkbd); in lenovo_probe_tpkbd()
1227 hid_warn(hdev, "Could not create sysfs group: %d\n", ret); in lenovo_probe_tpkbd()
1229 data_pointer = devm_kzalloc(&hdev->dev, in lenovo_probe_tpkbd()
1233 hid_err(hdev, "Could not allocate memory for driver data\n"); in lenovo_probe_tpkbd()
1242 hid_set_drvdata(hdev, data_pointer); in lenovo_probe_tpkbd()
1244 ret = lenovo_register_leds(hdev); in lenovo_probe_tpkbd()
1248 lenovo_features_set_tpkbd(hdev); in lenovo_probe_tpkbd()
1252 sysfs_remove_group(&hdev->dev.kobj, &lenovo_attr_group_tpkbd); in lenovo_probe_tpkbd()
1256 static int lenovo_probe_cptkbd(struct hid_device *hdev) in lenovo_probe_cptkbd() argument
1262 if (((hdev->product == USB_DEVICE_ID_LENOVO_CUSBKBD) || in lenovo_probe_cptkbd()
1263 (hdev->product == USB_DEVICE_ID_LENOVO_TPIIUSBKBD)) && in lenovo_probe_cptkbd()
1264 hdev->type != HID_TYPE_USBMOUSE) { in lenovo_probe_cptkbd()
1265 hid_dbg(hdev, "Ignoring keyboard half of device\n"); in lenovo_probe_cptkbd()
1269 cptkbd_data = devm_kzalloc(&hdev->dev, in lenovo_probe_cptkbd()
1273 hid_err(hdev, "can't alloc keyboard descriptor\n"); in lenovo_probe_cptkbd()
1276 hid_set_drvdata(hdev, cptkbd_data); in lenovo_probe_cptkbd()
1283 lenovo_features_set_cptkbd(hdev); in lenovo_probe_cptkbd()
1285 ret = sysfs_create_group(&hdev->dev.kobj, &lenovo_attr_group_cptkbd); in lenovo_probe_cptkbd()
1287 hid_warn(hdev, "Could not create sysfs group: %d\n", ret); in lenovo_probe_cptkbd()
1301 static int lenovo_probe_tp10ubkbd(struct hid_device *hdev) in lenovo_probe_tp10ubkbd() argument
1315 rep_enum = &hdev->report_enum[HID_OUTPUT_REPORT]; in lenovo_probe_tp10ubkbd()
1323 data = devm_kzalloc(&hdev->dev, sizeof(*data), GFP_KERNEL); in lenovo_probe_tp10ubkbd()
1329 data->hdev = hdev; in lenovo_probe_tp10ubkbd()
1331 hid_set_drvdata(hdev, data); in lenovo_probe_tp10ubkbd()
1344 data->fn_lock = !(hdev->product == USB_DEVICE_ID_LENOVO_X12_TAB || in lenovo_probe_tp10ubkbd()
1345 hdev->product == USB_DEVICE_ID_LENOVO_X12_TAB2); in lenovo_probe_tp10ubkbd()
1347 lenovo_led_set_tp10ubkbd(hdev, TP10UBKBD_FN_LOCK_LED, data->fn_lock); in lenovo_probe_tp10ubkbd()
1349 ret = sysfs_create_group(&hdev->dev.kobj, &lenovo_attr_group_tp10ubkbd); in lenovo_probe_tp10ubkbd()
1353 ret = lenovo_register_leds(hdev); in lenovo_probe_tp10ubkbd()
1359 sysfs_remove_group(&hdev->dev.kobj, &lenovo_attr_group_tp10ubkbd); in lenovo_probe_tp10ubkbd()
1363 static int lenovo_probe(struct hid_device *hdev, in lenovo_probe() argument
1368 ret = hid_parse(hdev); in lenovo_probe()
1370 hid_err(hdev, "hid_parse failed\n"); in lenovo_probe()
1374 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); in lenovo_probe()
1376 hid_err(hdev, "hid_hw_start failed\n"); in lenovo_probe()
1380 switch (hdev->product) { in lenovo_probe()
1382 ret = lenovo_probe_tpkbd(hdev); in lenovo_probe()
1388 ret = lenovo_probe_cptkbd(hdev); in lenovo_probe()
1396 ret = lenovo_probe_tp10ubkbd(hdev); in lenovo_probe()
1407 hid_hw_stop(hdev); in lenovo_probe()
1413 static int lenovo_reset_resume(struct hid_device *hdev) in lenovo_reset_resume() argument
1415 switch (hdev->product) { in lenovo_reset_resume()
1418 if (hdev->type == HID_TYPE_USBMOUSE) in lenovo_reset_resume()
1419 lenovo_features_set_cptkbd(hdev); in lenovo_reset_resume()
1430 static void lenovo_remove_tpkbd(struct hid_device *hdev) in lenovo_remove_tpkbd() argument
1432 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in lenovo_remove_tpkbd()
1441 sysfs_remove_group(&hdev->dev.kobj, in lenovo_remove_tpkbd()
1448 static void lenovo_remove_cptkbd(struct hid_device *hdev) in lenovo_remove_cptkbd() argument
1450 sysfs_remove_group(&hdev->dev.kobj, in lenovo_remove_cptkbd()
1454 static void lenovo_remove_tp10ubkbd(struct hid_device *hdev) in lenovo_remove_tp10ubkbd() argument
1456 struct lenovo_drvdata *data = hid_get_drvdata(hdev); in lenovo_remove_tp10ubkbd()
1464 sysfs_remove_group(&hdev->dev.kobj, &lenovo_attr_group_tp10ubkbd); in lenovo_remove_tp10ubkbd()
1468 static void lenovo_remove(struct hid_device *hdev) in lenovo_remove() argument
1470 switch (hdev->product) { in lenovo_remove()
1472 lenovo_remove_tpkbd(hdev); in lenovo_remove()
1478 lenovo_remove_cptkbd(hdev); in lenovo_remove()
1486 lenovo_remove_tp10ubkbd(hdev); in lenovo_remove()
1490 hid_hw_stop(hdev); in lenovo_remove()
1493 static int lenovo_input_configured(struct hid_device *hdev, in lenovo_input_configured() argument
1496 switch (hdev->product) { in lenovo_input_configured()