Re: [PATCH v2 07/13] HID: playstation: add DualSense Bluetooth support.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi


2021. január 2., szombat 23:31 keltezéssel, Roderick Colenbrander írta:

> From: Roderick Colenbrander <roderick.colenbrander@xxxxxxxx>
>
> This patch adds support for the DualSense when operating in Bluetooth mode.
> The device has the same behavior as the DualShock 4 in that by default it
> sends a limited input report (0x1), but after requesting calibration data,
> it switches to an extended input report (report 49), which adds data for
> touchpad, motion sensors, battery and more.
>
> Signed-off-by: Roderick Colenbrander <roderick.colenbrander@xxxxxxxx>
> [...]
>  static struct input_dev *ps_gamepad_create(struct hid_device *hdev)
>  {
>  	struct input_dev *gamepad;
> @@ -406,6 +418,18 @@  static int dualsense_get_calibration_data(struct dualsense *ds)
>  		goto err_free;
>  	}
>
> +	if (ds->base.hdev->bus == BUS_BLUETOOTH) {
> +		/* Last 4 bytes contains crc32 */

Most other comments have a period at the end. I know this is a minor thing,
but I believe being consistent is better than not.

And shouldn't this CRC be checked in `dualsense_get_mac_address()`?
If so, maybe a helper function could be created that wraps the `hid_hw_raw_request()`
call?


> +		uint8_t crc_offset = DS_FEATURE_REPORT_CALIBRATION_SIZE - 4;
> +		uint32_t report_crc = get_unaligned_le32(&buf[crc_offset]);
> +
> +		if (!ps_check_crc32(0xa3, buf, crc_offset, report_crc)) {

Maybe that 0xa3 could be named?


> +			hid_err(ds->base.hdev, "DualSense calibration report CRC's check failed\n");
> +			ret = -EILSEQ;
> +			goto err_free;
> +		}
> +	}
> +
>  	gyro_pitch_bias  = get_unaligned_le16(&buf[1]);
>  	gyro_yaw_bias    = get_unaligned_le16(&buf[3]);
>  	gyro_roll_bias   = get_unaligned_le16(&buf[5]);
> @@ -515,6 +539,16 @@  static int dualsense_parse_report(struct ps_device *ps_dev, struct hid_report *r
>  	 */
>  	if (report->id == DS_INPUT_REPORT_USB && hdev->bus == BUS_USB) {
>  		ds_report = (struct dualsense_input_report *)&data[1];
> +	} else if (report->id == DS_INPUT_REPORT_BT && hdev->bus == BUS_BLUETOOTH) {
> +		/* Last 4 bytes of input report contain crc32 */
> +		uint32_t report_crc = get_unaligned_le32(&data[size - 4]);
> +
> +		if (!ps_check_crc32(0xa1, data, size - 4, report_crc)) {

And this 0xa1 as well?


> +			hid_err(hdev, "DualSense input CRC's check failed, size=%d\n", size);
> +			return -EILSEQ;
> +		}
> +
> +		ds_report = (struct dualsense_input_report *)&data[2];
>  	} else {
>  		hid_err(hdev, "Unhandled reportID=%d\n", report->id);
>  		return -1;
> [...]


Regards,
Barnabás Pőcze





[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux