diff mbox series

[2/2] drivers: hid: warn feature report 0x81

Message ID 20221006132240.3706-1-hcvcastro@gmail.com (mailing list archive)
State New, archived
Delegated to: Jiri Kosina
Headers show
Series [1/2] drivers: hid: adjust gyro calibration data | expand

Commit Message

Henry Castro Oct. 6, 2022, 1:22 p.m. UTC
Unfortunately, my PS DualShock 4, does not support
the feature 0x81 to get the MAC address. Instead,
use a unique hash to fake a MAC address, so I can
use DS4 to play Retroarch :)

Signed-off-by: Henry Castro <hcvcastro@gmail.com>
---

>> I see in the other email. If it doesn't support this request, it is
>> likely a clone device. We are about to submit a brand new DS4 driver
>> (for hid-playstation). It will use a different report (0x12) if I
>> recall which does the same thing. That's the more mainstream one we
>> use.

I have 2 DualShock 4, I did not notice but I have one DS4 compatible
(clone, I guess).

The DS4 Sony -> returns -ETIMEDOUT
The DS4 clone -> returns -EPIPE

Look great the new DS4 driver :)



 drivers/hid/hid-sony.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

--
2.20.1

Comments

Roderick Colenbrander Oct. 6, 2022, 2:01 p.m. UTC | #1
On Thu, Oct 6, 2022 at 6:22 AM Henry Castro <hcvcastro@gmail.com> wrote:
>
> Unfortunately, my PS DualShock 4, does not support
> the feature 0x81 to get the MAC address. Instead,
> use a unique hash to fake a MAC address, so I can
> use DS4 to play Retroarch :)
>
> Signed-off-by: Henry Castro <hcvcastro@gmail.com>
> ---
>
> >> I see in the other email. If it doesn't support this request, it is
> >> likely a clone device. We are about to submit a brand new DS4 driver
> >> (for hid-playstation). It will use a different report (0x12) if I
> >> recall which does the same thing. That's the more mainstream one we
> >> use.
>
> I have 2 DualShock 4, I did not notice but I have one DS4 compatible
> (clone, I guess).
>
> The DS4 Sony -> returns -ETIMEDOUT
> The DS4 clone -> returns -EPIPE
>
> Look great the new DS4 driver :)
>

Just for reference if you want to try out if 0x12 works, you can try
this code. This is from the new driver (ps_get_report is from
hid-playstation, but you can just use one of the existing hid calls)
if you wanted to try.

#define DS4_FEATURE_REPORT_PAIRING_INFO        0x12
#define DS4_FEATURE_REPORT_PAIRING_INFO_SIZE    16

    if (hdev->bus == BUS_USB) {
        buf = kzalloc(DS4_FEATURE_REPORT_PAIRING_INFO_SIZE, GFP_KERNEL);
        if (!buf)
            return -ENOMEM;

        ret = ps_get_report(hdev, DS4_FEATURE_REPORT_PAIRING_INFO, buf,
                DS4_FEATURE_REPORT_PAIRING_INFO_SIZE, false);
        if (ret) {
            hid_err(hdev, "Failed to retrieve DualShock4 pairing info:
%d\n", ret);
            goto err_free;
        }

        memcpy(ds4->base.mac_address, &buf[1], sizeof(ds4->base.mac_address));
    } else {
diff mbox series

Patch

diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 656caa07b25f..e3e9c58887cf 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -2641,13 +2641,14 @@  static int sony_check_add(struct sony_sc *sc)
 				HID_REQ_GET_REPORT);

 		if (ret != DS4_FEATURE_REPORT_0x81_SIZE) {
-			hid_err(sc->hdev, "failed to retrieve feature report 0x81 with the DualShock 4 MAC address\n");
-			ret = ret < 0 ? ret : -EINVAL;
-			goto out_free;
+			uint32_t hash = full_name_hash(NULL, dev_name(&sc->hdev->dev),
+						       strlen(dev_name(&sc->hdev->dev)));
+			hid_warn(sc->hdev, "failed to retrieve feature report 0x81 with the DualShock 4 MAC address\n");
+			memcpy(sc->mac_address, &hash, sizeof(hash));
+		} else {
+			memcpy(sc->mac_address, &buf[1], sizeof(sc->mac_address));
 		}

-		memcpy(sc->mac_address, &buf[1], sizeof(sc->mac_address));
-
 		snprintf(sc->hdev->uniq, sizeof(sc->hdev->uniq),
 			 "%pMR", sc->mac_address);
 	} else if ((sc->quirks & SIXAXIS_CONTROLLER_USB) ||