Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2739453pxb; Sat, 30 Jan 2021 12:44:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJx0AvjUUOCbF3HeovzHsMVOhOF+WQ+8O8auwpoouGPUaXL2o5/saO/JqPDqhJKds6xCaDDN X-Received: by 2002:a17:906:14d5:: with SMTP id y21mr10541464ejc.410.1612039479238; Sat, 30 Jan 2021 12:44:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612039479; cv=none; d=google.com; s=arc-20160816; b=GOOrXpSv5PCBDMOtjxZ6Ljiwr6+mlWwzgAPb9WeMs4hDxNCnqVQWE0bgm1pw8eh5ee 2jvROBKdsWRLk/y8MD16DpqPJZG84CvkN9BjlfvxG4vLg6LwOeAeSRAIgTaxnLTdPeoE Wq7Kq/1kgvjVbwk1utB21e4rE+ijrJ7rRdVppMGtyHe/1raSVO5NAurNG678rTLgOPY5 d6wMSrG5tuIM5ycTw6DdP4z5WKSTjXDmvOsoagfpbIwr7cCwJqyi4t6b6gv7TFmYq631 tgsWqDjfk5Gbm8/D1AEEvR8MmJVMpU5qAaIh3CP7vQSFzTf1WcAwvIu3XX+8wg8NTOSw zVyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=b+Z6z9i5CzupiwX94B3J1cKxOBMsfoC6OajFItYxxlQ=; b=DpyxwOFLJTpOStdY+X9t1n5+iAY0fMyiVbfvjl0xXxgcbNUJinZDrP/dVymU/Yj0sX NxdIqNLivkSMF+ceFzrWXwb4MM/jPDEVn38YrXEaPTLCV7dJ3hNMLYJOtoGA/jiAgFKA FgU9gAG8ENmW2ErGt6ca+M3lgB03fOlXU/FM300SgT3vxK51bi6gVdFU5RmLHyZ40AIa J0M+bhBFx5wUaVl3Hdd+cM1yo7wRMxTX6wk1bVNRqlEUrh2UwQwwi2VyRezmcjhHJh62 G9ZT/IllAC843h4+n8E4sKqGOcOz2HfUSeuQfQyT28MJmslRGzEL7/LVhaK9ocsDWGGm bP7A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s8si7534099edd.534.2021.01.30.12.44.15; Sat, 30 Jan 2021 12:44:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232120AbhA3Umk (ORCPT + 99 others); Sat, 30 Jan 2021 15:42:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:52242 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231923AbhA3Umh (ORCPT ); Sat, 30 Jan 2021 15:42:37 -0500 Received: from archlinux (cpc108967-cmbg20-2-0-cust86.5-4.cable.virginm.net [81.101.6.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AD29464E0C; Sat, 30 Jan 2021 20:41:55 +0000 (UTC) Date: Sat, 30 Jan 2021 20:41:51 +0000 From: Jonathan Cameron To: Ye Xiang 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 Message-ID: <20210130204151.46457a3e@archlinux> In-Reply-To: <20210130102546.31397-1-xiang.ye@intel.com> References: <20210130102546.31397-1-xiang.ye@intel.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 30 Jan 2021 18:25:46 +0800 Ye Xiang 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 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));