Lines Matching defs:hdev
33 struct hid_device *hdev;
551 hid_err(dev->hdev, "Duplicate device found for MAC address %pMR.\n",
589 static struct input_dev *ps_allocate_input_dev(struct hid_device *hdev, const char *name_suffix)
593 input_dev = devm_input_allocate_device(&hdev->dev);
597 input_dev->id.bustype = hdev->bus;
598 input_dev->id.vendor = hdev->vendor;
599 input_dev->id.product = hdev->product;
600 input_dev->id.version = hdev->version;
601 input_dev->uniq = hdev->uniq;
604 input_dev->name = devm_kasprintf(&hdev->dev, GFP_KERNEL, "%s %s", hdev->name,
609 input_dev->name = hdev->name;
612 input_set_drvdata(input_dev, hdev);
670 dev->battery_desc.name = devm_kasprintf(&dev->hdev->dev, GFP_KERNEL,
675 battery = devm_power_supply_register(&dev->hdev->dev, &dev->battery_desc, &battery_cfg);
678 hid_err(dev->hdev, "Unable to register battery device: %d\n", ret);
683 ret = power_supply_powers(dev->battery, &dev->hdev->dev);
685 hid_err(dev->hdev, "Unable to activate battery device: %d\n", ret);
703 static struct input_dev *ps_gamepad_create(struct hid_device *hdev,
710 gamepad = ps_allocate_input_dev(hdev, NULL);
741 static int ps_get_report(struct hid_device *hdev, uint8_t report_id, uint8_t *buf, size_t size,
746 ret = hid_hw_raw_request(hdev, report_id, buf, size, HID_FEATURE_REPORT,
749 hid_err(hdev, "Failed to retrieve feature with reportID %d: %d\n", report_id, ret);
754 hid_err(hdev, "Invalid byte count transferred, expected %zu got %d\n", size, ret);
759 hid_err(hdev, "Invalid reportID received, expected %d got %d\n", report_id, buf[0]);
763 if (hdev->bus == BUS_BLUETOOTH && check_crc) {
769 hid_err(hdev, "CRC check failed for reportID=%d\n", report_id);
783 led->name = devm_kasprintf(&ps_dev->hdev->dev, GFP_KERNEL,
787 led->name = devm_kasprintf(&ps_dev->hdev->dev, GFP_KERNEL,
801 ret = devm_led_classdev_register(&ps_dev->hdev->dev, led);
803 hid_err(ps_dev->hdev, "Failed to register LED %s: %d\n", led_info->name, ret);
814 struct hid_device *hdev = ps_dev->hdev;
819 mc_led_info = devm_kmalloc_array(&hdev->dev, 3, sizeof(*mc_led_info),
832 led_cdev->name = devm_kasprintf(&hdev->dev, GFP_KERNEL, "%s:rgb:indicator",
840 ret = devm_led_classdev_multicolor_register(&hdev->dev, lightbar_mc_dev);
842 hid_err(hdev, "Cannot register multicolor LED device\n");
849 static struct input_dev *ps_sensors_create(struct hid_device *hdev, int accel_range, int accel_res,
855 sensors = ps_allocate_input_dev(hdev, "Motion Sensors");
886 static struct input_dev *ps_touchpad_create(struct hid_device *hdev, int width, int height,
892 touchpad = ps_allocate_input_dev(hdev, "Touchpad");
918 struct hid_device *hdev = to_hid_device(dev);
919 struct ps_device *ps_dev = hid_get_drvdata(hdev);
930 struct hid_device *hdev = to_hid_device(dev);
931 struct ps_device *ps_dev = hid_get_drvdata(hdev);
947 struct hid_device *hdev = ds->base.hdev;
965 ret = ps_get_report(ds->base.hdev, DS_FEATURE_REPORT_CALIBRATION, buf,
968 hid_err(ds->base.hdev, "Failed to retrieve DualSense calibration info: %d\n", ret);
1020 hid_warn(hdev, "Invalid gyro calibration data for axis (%d), disabling calibration.",
1057 hid_warn(hdev, "Invalid accelerometer calibration data for axis (%d), disabling calibration.",
1080 ret = ps_get_report(ds->base.hdev, DS_FEATURE_REPORT_FIRMWARE_INFO, buf,
1083 hid_err(ds->base.hdev, "Failed to retrieve DualSense firmware info: %d\n", ret);
1113 ret = ps_get_report(ds->base.hdev, DS_FEATURE_REPORT_PAIRING_INFO, buf,
1116 hid_err(ds->base.hdev, "Failed to retrieve DualSense pairing info: %d\n", ret);
1145 struct hid_device *hdev = to_hid_device(led->dev->parent);
1146 struct dualsense *ds = hid_get_drvdata(hdev);
1153 struct hid_device *hdev = to_hid_device(led->dev->parent);
1154 struct dualsense *ds = hid_get_drvdata(hdev);
1177 struct hid_device *hdev = ds->base.hdev;
1179 if (hdev->bus == BUS_BLUETOOTH) {
1230 struct hid_device *hdev = ds->base.hdev;
1243 hid_hw_output_report(hdev, report->data, report->len);
1311 struct hid_device *hdev = ps_dev->hdev;
1326 if (hdev->bus == BUS_USB && report->id == DS_INPUT_REPORT_USB &&
1329 } else if (hdev->bus == BUS_BLUETOOTH && report->id == DS_INPUT_REPORT_BT &&
1335 hid_err(hdev, "DualSense input CRC's check failed\n");
1341 hid_err(hdev, "Unhandled reportID=%d\n", report->id);
1487 struct hid_device *hdev = input_get_drvdata(dev);
1488 struct dualsense *ds = hid_get_drvdata(hdev);
1578 static struct ps_device *dualsense_create(struct hid_device *hdev)
1598 ds = devm_kzalloc(&hdev->dev, sizeof(*ds), GFP_KERNEL);
1606 hdev->version |= HID_PLAYSTATION_VERSION_PATCH;
1609 ps_dev->hdev = hdev;
1617 hid_set_drvdata(hdev, ds);
1620 ds->output_report_dmabuf = devm_kzalloc(&hdev->dev, max_output_report_size, GFP_KERNEL);
1626 hid_err(hdev, "Failed to get MAC address from DualSense\n");
1629 snprintf(hdev->uniq, sizeof(hdev->uniq), "%pMR", ds->base.mac_address);
1633 hid_err(hdev, "Failed to get firmware info from DualSense\n");
1645 if (hdev->product == USB_DEVICE_ID_SONY_PS5_CONTROLLER) {
1648 } else if (hdev->product == USB_DEVICE_ID_SONY_PS5_CONTROLLER_2) {
1658 hid_err(hdev, "Failed to get calibration data from DualSense\n");
1662 ds->gamepad = ps_gamepad_create(hdev, dualsense_play_effect);
1670 ds->sensors = ps_sensors_create(hdev, DS_ACC_RANGE, DS_ACC_RES_PER_G,
1677 ds->touchpad = ps_touchpad_create(hdev, DS_TOUCHPAD_WIDTH, DS_TOUCHPAD_HEIGHT, 2);
1713 hid_err(hdev, "Failed to assign player id for DualSense: %d\n", ret);
1724 hid_info(hdev, "Registered DualSense controller hw_version=0x%08x fw_version=0x%08x\n",
1749 hid_err(ds4->base.hdev, "DualShock 4 USB dongle: calibration failed, disabling device\n");
1752 hid_info(ds4->base.hdev, "DualShock 4 USB dongle: calibration completed\n");
1763 struct hid_device *hdev = ds4->base.hdev;
1777 if (ds4->base.hdev->bus == BUS_USB) {
1791 ret = ps_get_report(hdev, DS4_FEATURE_REPORT_CALIBRATION, buf,
1795 hid_warn(hdev, "Retrying DualShock 4 get calibration report (0x02) request\n");
1799 hid_err(hdev, "Failed to retrieve DualShock4 calibration info: %d\n", ret);
1811 ret = ps_get_report(hdev, DS4_FEATURE_REPORT_CALIBRATION_BT, buf,
1814 hid_err(hdev, "Failed to retrieve DualShock4 calibration info: %d\n", ret);
1822 if (ds4->base.hdev->bus == BUS_USB) {
1877 hid_warn(hdev, "Invalid gyro calibration data for axis (%d), disabling calibration.",
1914 hid_warn(hdev, "Invalid accelerometer calibration data for axis (%d), disabling calibration.",
1939 ret = ps_get_report(ds4->base.hdev, DS4_FEATURE_REPORT_FIRMWARE_INFO, buf,
1942 hid_err(ds4->base.hdev, "Failed to retrieve DualShock4 firmware info: %d\n", ret);
1956 struct hid_device *hdev = ds4->base.hdev;
1960 if (hdev->bus == BUS_USB) {
1965 ret = ps_get_report(hdev, DS4_FEATURE_REPORT_PAIRING_INFO, buf,
1968 hid_err(hdev, "Failed to retrieve DualShock4 pairing info: %d\n", ret);
1975 if (strlen(hdev->uniq) != 17)
1978 ret = sscanf(hdev->uniq, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
1996 struct hid_device *hdev = to_hid_device(led->dev->parent);
1997 struct dualshock4 *ds4 = hid_get_drvdata(hdev);
2018 struct hid_device *hdev = to_hid_device(led->dev->parent);
2019 struct dualshock4 *ds4 = hid_get_drvdata(hdev);
2048 struct hid_device *hdev = to_hid_device(led->dev->parent);
2049 struct dualshock4 *ds4 = hid_get_drvdata(hdev);
2082 struct hid_device *hdev = ds4->base.hdev;
2084 if (hdev->bus == BUS_BLUETOOTH) {
2171 hid_hw_output_report(ds4->base.hdev, report.data, report.len);
2177 struct hid_device *hdev = ps_dev->hdev;
2191 if (hdev->bus == BUS_USB && report->id == DS4_INPUT_REPORT_USB &&
2198 } else if (hdev->bus == BUS_BLUETOOTH && report->id == DS4_INPUT_REPORT_BT &&
2205 hid_err(hdev, "DualShock4 input CRC's check failed\n");
2213 hid_err(hdev, "Unhandled reportID=%d\n", report->id);
2373 hid_info(ps_dev->hdev, "DualShock 4 USB dongle: controller connected\n");
2389 hid_info(ps_dev->hdev, "DualShock 4 USB dongle: controller disconnected\n");
2413 struct hid_device *hdev = input_get_drvdata(dev);
2414 struct dualshock4 *ds4 = hid_get_drvdata(hdev);
2441 if (ps_dev->hdev->product == USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE)
2486 static struct ps_device *dualshock4_create(struct hid_device *hdev)
2510 ds4 = devm_kzalloc(&hdev->dev, sizeof(*ds4), GFP_KERNEL);
2518 hdev->version |= HID_PLAYSTATION_VERSION_PATCH;
2521 ps_dev->hdev = hdev;
2529 hid_set_drvdata(hdev, ds4);
2532 ds4->output_report_dmabuf = devm_kzalloc(&hdev->dev, max_output_report_size, GFP_KERNEL);
2536 if (hdev->product == USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE) {
2546 hid_err(hdev, "Failed to get MAC address from DualShock4\n");
2549 snprintf(hdev->uniq, sizeof(hdev->uniq), "%pMR", ds4->base.mac_address);
2553 hid_err(hdev, "Failed to get firmware info from DualShock4\n");
2563 hid_err(hdev, "Failed to get calibration data from DualShock4\n");
2567 ds4->gamepad = ps_gamepad_create(hdev, dualshock4_play_effect);
2576 ds4->sensors = ps_sensors_create(hdev, DS4_ACC_RANGE, DS4_ACC_RES_PER_G,
2583 ds4->touchpad = ps_touchpad_create(hdev, DS4_TOUCHPAD_WIDTH, DS4_TOUCHPAD_HEIGHT, 2);
2605 hid_err(hdev, "Failed to assign player id for DualShock4: %d\n", ret);
2615 hid_info(hdev, "Registered DualShock4 controller hw_version=0x%08x fw_version=0x%08x\n",
2624 static int ps_raw_event(struct hid_device *hdev, struct hid_report *report,
2627 struct ps_device *dev = hid_get_drvdata(hdev);
2635 static int ps_probe(struct hid_device *hdev, const struct hid_device_id *id)
2640 ret = hid_parse(hdev);
2642 hid_err(hdev, "Parse failed\n");
2646 ret = hid_hw_start(hdev, HID_CONNECT_HIDRAW);
2648 hid_err(hdev, "Failed to start HID device\n");
2652 ret = hid_hw_open(hdev);
2654 hid_err(hdev, "Failed to open HID device\n");
2658 if (hdev->product == USB_DEVICE_ID_SONY_PS4_CONTROLLER ||
2659 hdev->product == USB_DEVICE_ID_SONY_PS4_CONTROLLER_2 ||
2660 hdev->product == USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE) {
2661 dev = dualshock4_create(hdev);
2663 hid_err(hdev, "Failed to create dualshock4.\n");
2667 } else if (hdev->product == USB_DEVICE_ID_SONY_PS5_CONTROLLER ||
2668 hdev->product == USB_DEVICE_ID_SONY_PS5_CONTROLLER_2) {
2669 dev = dualsense_create(hdev);
2671 hid_err(hdev, "Failed to create dualsense.\n");
2680 hid_hw_close(hdev);
2682 hid_hw_stop(hdev);
2686 static void ps_remove(struct hid_device *hdev)
2688 struct ps_device *dev = hid_get_drvdata(hdev);
2696 hid_hw_close(hdev);
2697 hid_hw_stop(hdev);