Skip to content

Commit a23b063

Browse files
Roderick ColenbranderJiri Kosina
authored andcommitted
HID: playstation: add option to ignore CRC in ps_get_report.
This patch adds a parameter to ps_get_report to ignore CRC checks. This prepares for DualShock4, which has some HID reports, which lack CRC. Signed-off-by: Roderick Colenbrander <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 82d93f6 commit a23b063

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

drivers/hid/hid-playstation.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,8 @@ static struct input_dev *ps_gamepad_create(struct hid_device *hdev,
672672
return gamepad;
673673
}
674674

675-
static int ps_get_report(struct hid_device *hdev, uint8_t report_id, uint8_t *buf, size_t size)
675+
static int ps_get_report(struct hid_device *hdev, uint8_t report_id, uint8_t *buf, size_t size,
676+
bool check_crc)
676677
{
677678
int ret;
678679

@@ -693,7 +694,7 @@ static int ps_get_report(struct hid_device *hdev, uint8_t report_id, uint8_t *bu
693694
return -EINVAL;
694695
}
695696

696-
if (hdev->bus == BUS_BLUETOOTH) {
697+
if (hdev->bus == BUS_BLUETOOTH && check_crc) {
697698
/* Last 4 bytes contains crc32. */
698699
uint8_t crc_offset = size - 4;
699700
uint32_t report_crc = get_unaligned_le32(&buf[crc_offset]);
@@ -894,7 +895,7 @@ static int dualsense_get_calibration_data(struct dualsense *ds)
894895
return -ENOMEM;
895896

896897
ret = ps_get_report(ds->base.hdev, DS_FEATURE_REPORT_CALIBRATION, buf,
897-
DS_FEATURE_REPORT_CALIBRATION_SIZE);
898+
DS_FEATURE_REPORT_CALIBRATION_SIZE, true);
898899
if (ret) {
899900
hid_err(ds->base.hdev, "Failed to retrieve DualSense calibration info: %d\n", ret);
900901
goto err_free;
@@ -976,7 +977,7 @@ static int dualsense_get_firmware_info(struct dualsense *ds)
976977
return -ENOMEM;
977978

978979
ret = ps_get_report(ds->base.hdev, DS_FEATURE_REPORT_FIRMWARE_INFO, buf,
979-
DS_FEATURE_REPORT_FIRMWARE_INFO_SIZE);
980+
DS_FEATURE_REPORT_FIRMWARE_INFO_SIZE, true);
980981
if (ret) {
981982
hid_err(ds->base.hdev, "Failed to retrieve DualSense firmware info: %d\n", ret);
982983
goto err_free;
@@ -1009,7 +1010,7 @@ static int dualsense_get_mac_address(struct dualsense *ds)
10091010
return -ENOMEM;
10101011

10111012
ret = ps_get_report(ds->base.hdev, DS_FEATURE_REPORT_PAIRING_INFO, buf,
1012-
DS_FEATURE_REPORT_PAIRING_INFO_SIZE);
1013+
DS_FEATURE_REPORT_PAIRING_INFO_SIZE, true);
10131014
if (ret) {
10141015
hid_err(ds->base.hdev, "Failed to retrieve DualSense pairing info: %d\n", ret);
10151016
goto err_free;
@@ -1650,7 +1651,7 @@ static int dualshock4_get_calibration_data(struct dualshock4 *ds4)
16501651
return -ENOMEM;
16511652

16521653
ret = ps_get_report(hdev, DS4_FEATURE_REPORT_CALIBRATION, buf,
1653-
DS4_FEATURE_REPORT_CALIBRATION_SIZE);
1654+
DS4_FEATURE_REPORT_CALIBRATION_SIZE, true);
16541655
if (ret) {
16551656
hid_err(hdev, "Failed to retrieve DualShock4 calibration info: %d\n", ret);
16561657
goto err_free;
@@ -1731,7 +1732,7 @@ static int dualshock4_get_firmware_info(struct dualshock4 *ds4)
17311732
return -ENOMEM;
17321733

17331734
ret = ps_get_report(ds4->base.hdev, DS4_FEATURE_REPORT_FIRMWARE_INFO, buf,
1734-
DS4_FEATURE_REPORT_FIRMWARE_INFO_SIZE);
1735+
DS4_FEATURE_REPORT_FIRMWARE_INFO_SIZE, true);
17351736
if (ret) {
17361737
hid_err(ds4->base.hdev, "Failed to retrieve DualShock4 firmware info: %d\n", ret);
17371738
goto err_free;
@@ -1755,7 +1756,7 @@ static int dualshock4_get_mac_address(struct dualshock4 *ds4)
17551756
return -ENOMEM;
17561757

17571758
ret = ps_get_report(ds4->base.hdev, DS4_FEATURE_REPORT_PAIRING_INFO, buf,
1758-
DS4_FEATURE_REPORT_PAIRING_INFO_SIZE);
1759+
DS4_FEATURE_REPORT_PAIRING_INFO_SIZE, true);
17591760
if (ret) {
17601761
hid_err(ds4->base.hdev, "Failed to retrieve DualShock4 pairing info: %d\n", ret);
17611762
goto err_free;

0 commit comments

Comments
 (0)