All of lore.kernel.org
 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 1/2] drivers: hid: adjust gyro calibration data
Date: Thu,  6 Oct 2022 09:36:08 -0400	[thread overview]
Message-ID: <20221006133609.3839-1-hcvcastro@gmail.com> (raw)
In-Reply-To: <CAEc3jaDLE1_+cCdL0nwUq-TPzBhoPmukGs527TokNN=iwqO5Hw@mail.gmail.com>

For some reason my DualShock 4 get the calibration
data values equal:

	gyro_pitch_plus == gyro_pitch_minus

Probably due to some defect in the DS4 hardware, and cause
a CPU division exception to crash the linux kernel.

At least with the patch, I can continue play Retroarch
without using the Gyroscope :)

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

>> Hm, I'm not the biggest fan. Is this an official DS4 or a clone
>> device? It sounds like it is some type of clone (some look real).

Sorry it happens in my DS4 clone:

I have the log values:

gyro_pitch_plus = 8704
giro_pitch_minus = 8704

Then the division exception:

mult_frac(x, y, 0)



 drivers/hid/hid-sony.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 87b538656f64..656caa07b25f 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -1823,6 +1823,15 @@ static int dualshock4_get_calibration_data(struct sony_sc *sc)
 	acc_z_plus       = get_unaligned_le16(&buf[31]);
 	acc_z_minus      = get_unaligned_le16(&buf[33]);

+	if (gyro_pitch_plus == gyro_pitch_minus)
+		gyro_pitch_minus *= -1;
+
+	if (gyro_yaw_plus == gyro_yaw_minus)
+		gyro_yaw_minus *= -1;
+
+	if (gyro_roll_plus == gyro_roll_minus)
+		gyro_roll_minus *= -1;
+
 	/* Set gyroscope calibration and normalization parameters.
 	 * Data values will be normalized to 1/DS4_GYRO_RES_PER_DEG_S degree/s.
 	 */
--
2.20.1


  reply	other threads:[~2022-10-06 13:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-02 22:03 [PATCH 1/2] drivers: hid: adjust gyro calibration data Henry Castro
2022-10-06  4:00 ` Roderick Colenbrander
2022-10-06 13:36   ` Henry Castro [this message]
2022-10-06 14:03     ` Roderick Colenbrander
2022-10-06 18:31       ` 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=20221006133609.3839-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.