Lines Matching refs:hdev

54 	struct hid_device *hdev;  member
89 static int lenovo_led_set_tp10ubkbd(struct hid_device *hdev, u8 led_code, in lenovo_led_set_tp10ubkbd() argument
92 struct lenovo_drvdata *data = hid_get_drvdata(hdev); in lenovo_led_set_tp10ubkbd()
100 ret = hid_hw_raw_request(hdev, data->led_report[0], data->led_report, 3, in lenovo_led_set_tp10ubkbd()
104 hid_err(hdev, "Set LED output report error: %d\n", ret); in lenovo_led_set_tp10ubkbd()
121 lenovo_led_set_tp10ubkbd(data->hdev, TP10UBKBD_FN_LOCK_LED, in lenovo_tp10ubkbd_sync_fn_lock()
159 static const __u8 *lenovo_report_fixup(struct hid_device *hdev, __u8 *rdesc, in lenovo_report_fixup() argument
162 switch (hdev->product) { in lenovo_report_fixup()
199 static int lenovo_input_mapping_tpkbd(struct hid_device *hdev, in lenovo_input_mapping_tpkbd() argument
205 hid_set_drvdata(hdev, (void *)1); in lenovo_input_mapping_tpkbd()
212 static int lenovo_input_mapping_cptkbd(struct hid_device *hdev, in lenovo_input_mapping_cptkbd() argument
286 static int lenovo_input_mapping_tpIIkbd(struct hid_device *hdev, in lenovo_input_mapping_tpIIkbd() argument
381 static int lenovo_input_mapping_scrollpoint(struct hid_device *hdev, in lenovo_input_mapping_scrollpoint() argument
392 static int lenovo_input_mapping_tp10_ultrabook_kbd(struct hid_device *hdev, in lenovo_input_mapping_tp10_ultrabook_kbd() argument
430 static int lenovo_input_mapping_x1_tab_kbd(struct hid_device *hdev, in lenovo_input_mapping_x1_tab_kbd() argument
478 static int lenovo_input_mapping(struct hid_device *hdev, in lenovo_input_mapping() argument
482 switch (hdev->product) { in lenovo_input_mapping()
484 return lenovo_input_mapping_tpkbd(hdev, hi, field, in lenovo_input_mapping()
488 return lenovo_input_mapping_cptkbd(hdev, hi, field, in lenovo_input_mapping()
492 return lenovo_input_mapping_tpIIkbd(hdev, hi, field, in lenovo_input_mapping()
500 return lenovo_input_mapping_scrollpoint(hdev, hi, field, in lenovo_input_mapping()
503 return lenovo_input_mapping_tp10_ultrabook_kbd(hdev, hi, field, in lenovo_input_mapping()
510 return lenovo_input_mapping_x1_tab_kbd(hdev, hi, field, usage, bit, max); in lenovo_input_mapping()
519 static int lenovo_send_cmd_cptkbd(struct hid_device *hdev, in lenovo_send_cmd_cptkbd() argument
538 switch (hdev->product) { in lenovo_send_cmd_cptkbd()
541 ret = hid_hw_raw_request(hdev, 0x13, buf, 3, in lenovo_send_cmd_cptkbd()
546 ret = hid_hw_output_report(hdev, buf, 3); in lenovo_send_cmd_cptkbd()
558 static void lenovo_features_set_cptkbd(struct hid_device *hdev) in lenovo_features_set_cptkbd() argument
561 struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev); in lenovo_features_set_cptkbd()
567 if (hdev->product == USB_DEVICE_ID_LENOVO_CUSBKBD || in lenovo_features_set_cptkbd()
568 hdev->product == USB_DEVICE_ID_LENOVO_CBTKBD) { in lenovo_features_set_cptkbd()
569 ret = lenovo_send_cmd_cptkbd(hdev, 0x01, 0x03); in lenovo_features_set_cptkbd()
571 hid_warn(hdev, "Failed to switch F7/9/11 mode: %d\n", ret); in lenovo_features_set_cptkbd()
575 ret = lenovo_send_cmd_cptkbd(hdev, 0x09, 0x01); in lenovo_features_set_cptkbd()
577 hid_warn(hdev, "Failed to switch middle button: %d\n", ret); in lenovo_features_set_cptkbd()
579 ret = lenovo_send_cmd_cptkbd(hdev, 0x05, cptkbd_data->fn_lock); in lenovo_features_set_cptkbd()
581 hid_err(hdev, "Fn-lock setting failed: %d\n", ret); in lenovo_features_set_cptkbd()
583 ret = lenovo_send_cmd_cptkbd(hdev, 0x02, cptkbd_data->sensitivity); in lenovo_features_set_cptkbd()
585 hid_err(hdev, "Sensitivity setting failed: %d\n", ret); in lenovo_features_set_cptkbd()
592 struct hid_device *hdev = to_hid_device(dev); in attr_fn_lock_show() local
593 struct lenovo_drvdata *data = hid_get_drvdata(hdev); in attr_fn_lock_show()
603 struct hid_device *hdev = to_hid_device(dev); in attr_fn_lock_store() local
604 struct lenovo_drvdata *data = hid_get_drvdata(hdev); in attr_fn_lock_store()
614 switch (hdev->product) { in attr_fn_lock_store()
619 lenovo_features_set_cptkbd(hdev); in attr_fn_lock_store()
627 ret = lenovo_led_set_tp10ubkbd(hdev, TP10UBKBD_FN_LOCK_LED, value); in attr_fn_lock_store()
640 struct hid_device *hdev = to_hid_device(dev); in attr_sensitivity_show_cptkbd() local
641 struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev); in attr_sensitivity_show_cptkbd()
651 struct hid_device *hdev = to_hid_device(dev); in attr_sensitivity_store_cptkbd() local
652 struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev); in attr_sensitivity_store_cptkbd()
659 lenovo_features_set_cptkbd(hdev); in attr_sensitivity_store_cptkbd()
668 struct hid_device *hdev = to_hid_device(dev); in attr_middleclick_workaround_show_cptkbd() local
669 struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev); in attr_middleclick_workaround_show_cptkbd()
680 struct hid_device *hdev = to_hid_device(dev); in attr_middleclick_workaround_store_cptkbd() local
681 struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev); in attr_middleclick_workaround_store_cptkbd()
723 static int lenovo_raw_event_TP_X12_tab(struct hid_device *hdev, u32 raw_data) in lenovo_raw_event_TP_X12_tab() argument
729 list_for_each_entry(hidinput, &hdev->inputs, list) { in lenovo_raw_event_TP_X12_tab()
746 if (hdev->product == USB_DEVICE_ID_LENOVO_X12_TAB) { in lenovo_raw_event_TP_X12_tab()
754 (hdev->product == USB_DEVICE_ID_LENOVO_X12_TAB) ? in lenovo_raw_event_TP_X12_tab()
773 static int lenovo_raw_event(struct hid_device *hdev, in lenovo_raw_event() argument
781 if (unlikely(hdev->product == USB_DEVICE_ID_LENOVO_CUSBKBD in lenovo_raw_event()
794 if (unlikely((hdev->product == USB_DEVICE_ID_LENOVO_X12_TAB in lenovo_raw_event()
795 || hdev->product == USB_DEVICE_ID_LENOVO_X12_TAB2) in lenovo_raw_event()
797 return lenovo_raw_event_TP_X12_tab(hdev, le32_to_cpu(*(__le32 *)data)); in lenovo_raw_event()
802 static int lenovo_event_tp10ubkbd(struct hid_device *hdev, in lenovo_event_tp10ubkbd() argument
805 struct lenovo_drvdata *data = hid_get_drvdata(hdev); in lenovo_event_tp10ubkbd()
820 static int lenovo_event_cptkbd(struct hid_device *hdev, in lenovo_event_cptkbd() argument
823 struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev); in lenovo_event_cptkbd()
866 static int lenovo_event(struct hid_device *hdev, struct hid_field *field, in lenovo_event() argument
869 if (!hid_get_drvdata(hdev)) in lenovo_event()
872 switch (hdev->product) { in lenovo_event()
877 return lenovo_event_cptkbd(hdev, field, usage, value); in lenovo_event()
884 return lenovo_event_tp10ubkbd(hdev, field, usage, value); in lenovo_event()
890 static int lenovo_features_set_tpkbd(struct hid_device *hdev) in lenovo_features_set_tpkbd() argument
893 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in lenovo_features_set_tpkbd()
895 report = hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[4]; in lenovo_features_set_tpkbd()
905 hid_hw_request(hdev, report, HID_REQ_SET_REPORT); in lenovo_features_set_tpkbd()
913 struct hid_device *hdev = to_hid_device(dev); in attr_press_to_select_show_tpkbd() local
914 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in attr_press_to_select_show_tpkbd()
924 struct hid_device *hdev = to_hid_device(dev); in attr_press_to_select_store_tpkbd() local
925 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in attr_press_to_select_store_tpkbd()
934 lenovo_features_set_tpkbd(hdev); in attr_press_to_select_store_tpkbd()
943 struct hid_device *hdev = to_hid_device(dev); in attr_dragging_show_tpkbd() local
944 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in attr_dragging_show_tpkbd()
954 struct hid_device *hdev = to_hid_device(dev); in attr_dragging_store_tpkbd() local
955 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in attr_dragging_store_tpkbd()
964 lenovo_features_set_tpkbd(hdev); in attr_dragging_store_tpkbd()
973 struct hid_device *hdev = to_hid_device(dev); in attr_release_to_select_show_tpkbd() local
974 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in attr_release_to_select_show_tpkbd()
984 struct hid_device *hdev = to_hid_device(dev); in attr_release_to_select_store_tpkbd() local
985 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in attr_release_to_select_store_tpkbd()
994 lenovo_features_set_tpkbd(hdev); in attr_release_to_select_store_tpkbd()
1003 struct hid_device *hdev = to_hid_device(dev); in attr_select_right_show_tpkbd() local
1004 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in attr_select_right_show_tpkbd()
1014 struct hid_device *hdev = to_hid_device(dev); in attr_select_right_store_tpkbd() local
1015 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in attr_select_right_store_tpkbd()
1024 lenovo_features_set_tpkbd(hdev); in attr_select_right_store_tpkbd()
1033 struct hid_device *hdev = to_hid_device(dev); in attr_sensitivity_show_tpkbd() local
1034 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in attr_sensitivity_show_tpkbd()
1044 struct hid_device *hdev = to_hid_device(dev); in attr_sensitivity_store_tpkbd() local
1045 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in attr_sensitivity_store_tpkbd()
1052 lenovo_features_set_tpkbd(hdev); in attr_sensitivity_store_tpkbd()
1061 struct hid_device *hdev = to_hid_device(dev); in attr_press_speed_show_tpkbd() local
1062 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in attr_press_speed_show_tpkbd()
1072 struct hid_device *hdev = to_hid_device(dev); in attr_press_speed_store_tpkbd() local
1073 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in attr_press_speed_store_tpkbd()
1080 lenovo_features_set_tpkbd(hdev); in attr_press_speed_store_tpkbd()
1129 static void lenovo_led_set_tpkbd(struct hid_device *hdev) in lenovo_led_set_tpkbd() argument
1131 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in lenovo_led_set_tpkbd()
1134 report = hdev->report_enum[HID_OUTPUT_REPORT].report_id_hash[3]; in lenovo_led_set_tpkbd()
1137 hid_hw_request(hdev, report, HID_REQ_SET_REPORT); in lenovo_led_set_tpkbd()
1144 struct hid_device *hdev = to_hid_device(dev); in lenovo_led_brightness_set() local
1145 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in lenovo_led_brightness_set()
1158 switch (hdev->product) { in lenovo_led_brightness_set()
1160 lenovo_led_set_tpkbd(hdev); in lenovo_led_brightness_set()
1168 ret = lenovo_led_set_tp10ubkbd(hdev, tp10ubkbd_led[led_nr], value); in lenovo_led_brightness_set()
1175 static int lenovo_register_leds(struct hid_device *hdev) in lenovo_register_leds() argument
1177 struct lenovo_drvdata *data = hid_get_drvdata(hdev); in lenovo_register_leds()
1178 size_t name_sz = strlen(dev_name(&hdev->dev)) + 16; in lenovo_register_leds()
1182 name_mute = devm_kzalloc(&hdev->dev, name_sz, GFP_KERNEL); in lenovo_register_leds()
1183 name_micm = devm_kzalloc(&hdev->dev, name_sz, GFP_KERNEL); in lenovo_register_leds()
1185 hid_err(hdev, "Could not allocate memory for led data\n"); in lenovo_register_leds()
1188 snprintf(name_mute, name_sz, "%s:amber:mute", dev_name(&hdev->dev)); in lenovo_register_leds()
1189 snprintf(name_micm, name_sz, "%s:amber:micmute", dev_name(&hdev->dev)); in lenovo_register_leds()
1196 data->led_mute.dev = &hdev->dev; in lenovo_register_leds()
1197 ret = led_classdev_register(&hdev->dev, &data->led_mute); in lenovo_register_leds()
1206 data->led_micmute.dev = &hdev->dev; in lenovo_register_leds()
1207 ret = led_classdev_register(&hdev->dev, &data->led_micmute); in lenovo_register_leds()
1216 static int lenovo_probe_tpkbd(struct hid_device *hdev) in lenovo_probe_tpkbd() argument
1225 if (!hid_get_drvdata(hdev)) in lenovo_probe_tpkbd()
1228 hid_set_drvdata(hdev, NULL); in lenovo_probe_tpkbd()
1232 if (!hid_validate_values(hdev, HID_FEATURE_REPORT, 4, i, 1)) in lenovo_probe_tpkbd()
1235 if (!hid_validate_values(hdev, HID_OUTPUT_REPORT, 3, 0, 2)) in lenovo_probe_tpkbd()
1238 ret = sysfs_create_group(&hdev->dev.kobj, &lenovo_attr_group_tpkbd); in lenovo_probe_tpkbd()
1240 hid_warn(hdev, "Could not create sysfs group: %d\n", ret); in lenovo_probe_tpkbd()
1242 data_pointer = devm_kzalloc(&hdev->dev, in lenovo_probe_tpkbd()
1246 hid_err(hdev, "Could not allocate memory for driver data\n"); in lenovo_probe_tpkbd()
1255 hid_set_drvdata(hdev, data_pointer); in lenovo_probe_tpkbd()
1257 ret = lenovo_register_leds(hdev); in lenovo_probe_tpkbd()
1261 lenovo_features_set_tpkbd(hdev); in lenovo_probe_tpkbd()
1265 sysfs_remove_group(&hdev->dev.kobj, &lenovo_attr_group_tpkbd); in lenovo_probe_tpkbd()
1269 static int lenovo_probe_cptkbd(struct hid_device *hdev) in lenovo_probe_cptkbd() argument
1275 if (((hdev->product == USB_DEVICE_ID_LENOVO_CUSBKBD) || in lenovo_probe_cptkbd()
1276 (hdev->product == USB_DEVICE_ID_LENOVO_TPIIUSBKBD)) && in lenovo_probe_cptkbd()
1277 hdev->type != HID_TYPE_USBMOUSE) { in lenovo_probe_cptkbd()
1278 hid_dbg(hdev, "Ignoring keyboard half of device\n"); in lenovo_probe_cptkbd()
1282 cptkbd_data = devm_kzalloc(&hdev->dev, in lenovo_probe_cptkbd()
1286 hid_err(hdev, "can't alloc keyboard descriptor\n"); in lenovo_probe_cptkbd()
1289 hid_set_drvdata(hdev, cptkbd_data); in lenovo_probe_cptkbd()
1296 lenovo_features_set_cptkbd(hdev); in lenovo_probe_cptkbd()
1298 ret = sysfs_create_group(&hdev->dev.kobj, &lenovo_attr_group_cptkbd); in lenovo_probe_cptkbd()
1300 hid_warn(hdev, "Could not create sysfs group: %d\n", ret); in lenovo_probe_cptkbd()
1314 static int lenovo_probe_tp10ubkbd(struct hid_device *hdev) in lenovo_probe_tp10ubkbd() argument
1328 rep_enum = &hdev->report_enum[HID_OUTPUT_REPORT]; in lenovo_probe_tp10ubkbd()
1336 data = devm_kzalloc(&hdev->dev, sizeof(*data), GFP_KERNEL); in lenovo_probe_tp10ubkbd()
1342 data->hdev = hdev; in lenovo_probe_tp10ubkbd()
1344 hid_set_drvdata(hdev, data); in lenovo_probe_tp10ubkbd()
1357 data->fn_lock = !(hdev->product == USB_DEVICE_ID_LENOVO_X12_TAB || in lenovo_probe_tp10ubkbd()
1358 hdev->product == USB_DEVICE_ID_LENOVO_X12_TAB2); in lenovo_probe_tp10ubkbd()
1360 lenovo_led_set_tp10ubkbd(hdev, TP10UBKBD_FN_LOCK_LED, data->fn_lock); in lenovo_probe_tp10ubkbd()
1362 ret = sysfs_create_group(&hdev->dev.kobj, &lenovo_attr_group_tp10ubkbd); in lenovo_probe_tp10ubkbd()
1366 ret = lenovo_register_leds(hdev); in lenovo_probe_tp10ubkbd()
1372 sysfs_remove_group(&hdev->dev.kobj, &lenovo_attr_group_tp10ubkbd); in lenovo_probe_tp10ubkbd()
1376 static int lenovo_probe(struct hid_device *hdev, in lenovo_probe() argument
1381 ret = hid_parse(hdev); in lenovo_probe()
1383 hid_err(hdev, "hid_parse failed\n"); in lenovo_probe()
1387 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); in lenovo_probe()
1389 hid_err(hdev, "hid_hw_start failed\n"); in lenovo_probe()
1393 switch (hdev->product) { in lenovo_probe()
1395 ret = lenovo_probe_tpkbd(hdev); in lenovo_probe()
1401 ret = lenovo_probe_cptkbd(hdev); in lenovo_probe()
1409 ret = lenovo_probe_tp10ubkbd(hdev); in lenovo_probe()
1420 hid_hw_stop(hdev); in lenovo_probe()
1426 static int lenovo_reset_resume(struct hid_device *hdev) in lenovo_reset_resume() argument
1428 switch (hdev->product) { in lenovo_reset_resume()
1431 if (hdev->type == HID_TYPE_USBMOUSE) in lenovo_reset_resume()
1432 lenovo_features_set_cptkbd(hdev); in lenovo_reset_resume()
1443 static void lenovo_remove_tpkbd(struct hid_device *hdev) in lenovo_remove_tpkbd() argument
1445 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); in lenovo_remove_tpkbd()
1454 sysfs_remove_group(&hdev->dev.kobj, in lenovo_remove_tpkbd()
1461 static void lenovo_remove_cptkbd(struct hid_device *hdev) in lenovo_remove_cptkbd() argument
1463 sysfs_remove_group(&hdev->dev.kobj, in lenovo_remove_cptkbd()
1467 static void lenovo_remove_tp10ubkbd(struct hid_device *hdev) in lenovo_remove_tp10ubkbd() argument
1469 struct lenovo_drvdata *data = hid_get_drvdata(hdev); in lenovo_remove_tp10ubkbd()
1477 sysfs_remove_group(&hdev->dev.kobj, &lenovo_attr_group_tp10ubkbd); in lenovo_remove_tp10ubkbd()
1481 static void lenovo_remove(struct hid_device *hdev) in lenovo_remove() argument
1483 switch (hdev->product) { in lenovo_remove()
1485 lenovo_remove_tpkbd(hdev); in lenovo_remove()
1491 lenovo_remove_cptkbd(hdev); in lenovo_remove()
1499 lenovo_remove_tp10ubkbd(hdev); in lenovo_remove()
1503 hid_hw_stop(hdev); in lenovo_remove()
1506 static int lenovo_input_configured(struct hid_device *hdev, in lenovo_input_configured() argument
1509 switch (hdev->product) { in lenovo_input_configured()