linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] drivers: hid: adjust gyro calibration data
@ 2022-10-02 22:03 Henry Castro
  2022-10-06  4:00 ` Roderick Colenbrander
  0 siblings, 1 reply; 5+ messages in thread
From: Henry Castro @ 2022-10-02 22:03 UTC (permalink / raw)
  To: thunderbird2k
  Cc: Henry Castro, Jiri Kosina, Benjamin Tissoires, linux-input, linux-kernel

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] drivers: hid: adjust gyro calibration data
  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
  0 siblings, 1 reply; 5+ messages in thread
From: Roderick Colenbrander @ 2022-10-06  4:00 UTC (permalink / raw)
  To: Henry Castro; +Cc: Jiri Kosina, Benjamin Tissoires, linux-input, linux-kernel

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

On Sun, Oct 2, 2022 at 3:03 PM Henry Castro <hcvcastro@gmail.com> wrote:
>
> 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>
> ---
>  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
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] drivers: hid: adjust gyro calibration data
  2022-10-06  4:00 ` Roderick Colenbrander
@ 2022-10-06 13:36   ` Henry Castro
  2022-10-06 14:03     ` Roderick Colenbrander
  0 siblings, 1 reply; 5+ messages in thread
From: Henry Castro @ 2022-10-06 13:36 UTC (permalink / raw)
  To: thunderbird2k
  Cc: Henry Castro, Jiri Kosina, Benjamin Tissoires, linux-input, linux-kernel

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] drivers: hid: adjust gyro calibration data
  2022-10-06 13:36   ` Henry Castro
@ 2022-10-06 14:03     ` Roderick Colenbrander
  2022-10-06 18:31       ` Henry Castro
  0 siblings, 1 reply; 5+ messages in thread
From: Roderick Colenbrander @ 2022-10-06 14:03 UTC (permalink / raw)
  To: Henry Castro; +Cc: Jiri Kosina, Benjamin Tissoires, linux-input, linux-kernel

On Thu, Oct 6, 2022 at 6:36 AM Henry Castro <hcvcastro@gmail.com> wrote:
>
> 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)
>

Are it only these which are equal or are there are other funky ones?
Are all constants in general the same? I'm just trying to figure out
if some of this device would even need calibration.

Thanks,
Roderick

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] drivers: hid: adjust gyro calibration data
  2022-10-06 14:03     ` Roderick Colenbrander
@ 2022-10-06 18:31       ` Henry Castro
  0 siblings, 0 replies; 5+ messages in thread
From: Henry Castro @ 2022-10-06 18:31 UTC (permalink / raw)
  To: thunderbird2k
  Cc: Henry Castro, Jiri Kosina, Benjamin Tissoires, linux-input, linux-kernel

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

> Are it only these which are equal or are there are other funky ones?
> Are all constants in general the same? I'm just trying to figure out
> if some of this device would even need calibration.

More data logs:

gyro_pitch_plus=8704 giro_pitch_minus=8704
gyro_yaw_plus=8704 giro_yaw_minus=-8704
gyro_roll_plus=-8704 giro_roll_minus=-8704

Yes, They are constants values :( I


 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-10-06 18:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2022-10-06 14:03     ` Roderick Colenbrander
2022-10-06 18:31       ` Henry Castro

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