From: Jonathan Cameron <jic23@kernel.org>
To: Ye Xiang <xiang.ye@intel.com>
Cc: jikos@kernel.org, srinivas.pandruvada@linux.intel.com,
linux-input@vger.kernel.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] iio: hid-sensor-rotation: Fix quaternion data not correct
Date: Sat, 30 Jan 2021 20:41:51 +0000 [thread overview]
Message-ID: <20210130204151.46457a3e@archlinux> (raw)
In-Reply-To: <20210130102546.31397-1-xiang.ye@intel.com>
On Sat, 30 Jan 2021 18:25:46 +0800
Ye Xiang <xiang.ye@intel.com> wrote:
> 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
>
> Fixes: fc18dddc0625 ("iio: hid-sensors: Added device rotation support")
> Signed-off-by: Ye Xiang <xiang.ye@intel.com>
This is going to need manual backporting. I've applied it to the
togreg branch of iio.git for the next merge window. So after that we can
work on backports.
Jonathan
> ---
> v2:
> - Add Fixes tag
>
> ---
> drivers/iio/orientation/hid-sensor-rotation.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/orientation/hid-sensor-rotation.c b/drivers/iio/orientation/hid-sensor-rotation.c
> index b0245b3b7ffc..cf7f57a47681 100644
> --- a/drivers/iio/orientation/hid-sensor-rotation.c
> +++ b/drivers/iio/orientation/hid-sensor-rotation.c
> @@ -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;
> @@ -175,8 +175,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));
prev parent reply other threads:[~2021-01-30 20:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-30 10:25 [PATCH v2] iio: hid-sensor-rotation: Fix quaternion data not correct Ye Xiang
2021-01-30 20:41 ` Jonathan Cameron [this message]
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=20210130204151.46457a3e@archlinux \
--to=jic23@kernel.org \
--cc=jikos@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=xiang.ye@intel.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).