FAILED: patch "[PATCH] iio: hid-sensor-rotation: Fix quaternion data not correct" failed to apply to 5.11-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 5.11-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 6c3b615379d7cd90d2f70b3cf9860c5a4910546a Mon Sep 17 00:00:00 2001
From: Ye Xiang <[email protected]>
Date: Sat, 30 Jan 2021 18:25:46 +0800
Subject: [PATCH] iio: hid-sensor-rotation: Fix quaternion data not correct
Because the data of HID_USAGE_SENSOR_ORIENT_QUATERNION defined by ISH FW is s16, but quaternion data type is in_rot_quaternion_type(le:s16/32X4>>0), need to transform data type from s16 to s32
May require manual backporting.
Fixes fc18dddc0625 ("iio: hid-sensors: Added device rotation support")
Signed-off-by Ye Xiang <[email protected]>
Cc <[email protected]>
Signed-off-by Jonathan Cameron <[email protected]>
drivers/iio/orientation/hid-sensor-rotation.c +10 -3
@@ -21,7 +21,7 @@ struct dev_rot_state {struct hid_sensor_common common_attributes;struct hid_sensor_hub_attribute_info quaternion;struct { -u32 sampled_vals[4 ]__aligned(16) ; +s32 sampled_vals[4 ]__aligned(16) ;u64 timestamp__aligned(8) ; } scan;int scale_pre_decml;
@@ -170,8 +170,15 @@ static int dev_rot_capture_sample(struct hid_sensor_hub_device *hsdev,struct dev_rot_state *rot_state =iio_priv (indio_dev);if (usage_id ==HID_USAGE_SENSOR_ORIENT_QUATERNION ) { -memcpy (&rot_state->scan.sampled_vals, raw_data, -sizeof (rot_state->scan.sampled_vals)); +if (raw_len /4 ==sizeof (s16)) { + rot_state->scan.sampled_vals[0 ] = ((s16 *)raw_data)[0 ]; + rot_state->scan.sampled_vals[1 ] = ((s16 *)raw_data)[1 ]; + rot_state->scan.sampled_vals[2 ] = ((s16 *)raw_data)[2 ]; + rot_state->scan.sampled_vals[3 ] = ((s16 *)raw_data)[3 ]; + }else { +memcpy (&rot_state->scan.sampled_vals, raw_data, +sizeof (rot_state->scan.sampled_vals)); + }dev_dbg (&indio_dev->dev,"Recd Quat len:%zu::%zu\n" , raw_len,sizeof (rot_state->scan.sampled_vals));