linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Henry Castro <hcvcastro@gmail.com>
To: thunderbird2k@gmail.com
Cc: Henry Castro <hcvcastro@gmail.com>,
	Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] drivers: hid: warn feature report 0x81
Date: Thu,  6 Oct 2022 10:53:08 -0400	[thread overview]
Message-ID: <20221006145308.4393-1-hcvcastro@gmail.com> (raw)
In-Reply-To: <CAEc3jaCgEB5=3ATdaRXozMT3HrC1JeQVsY_HVF2VgY2oajzyow@mail.gmail.com>

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>
---

> 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.

It works with my 2 DS4 =)


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

			ret = hid_hw_raw_request(sc->hdev, DS4_FEATURE_REPORT_PAIRING_INFO, buf,
						 DS4_FEATURE_REPORT_PAIRING_INFO_SIZE, HID_FEATURE_REPORT,
						 HID_REQ_GET_REPORT);
			if (ret != DS4_FEATURE_REPORT_PAIRING_INFO_SIZE) {
				hid_err(sc->hdev, "Failed to retrieve DualShock4 pairing info:%pe\n", ERR_PTR(ret));
				goto out_free;
			}

			memcpy(sc->mac_address, &buf[1], sizeof(sc->mac_address));




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

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) ||
--
2.20.1


  reply	other threads:[~2022-10-06 14:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-02 22:01 [PATCH 2/2] drivers: hid: warn feature report 0x81 Henry Castro
2022-10-06  4:02 ` Roderick Colenbrander
2022-10-06 13:22   ` Henry Castro
2022-10-06 14:01     ` Roderick Colenbrander
2022-10-06 14:53       ` Henry Castro [this message]
2022-10-30 15:40         ` [PATCH v2] " Henry Castro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221006145308.4393-1-hcvcastro@gmail.com \
    --to=hcvcastro@gmail.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thunderbird2k@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).