Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp30623pxb; Tue, 19 Jan 2021 23:57:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwqXLSEx2ntQmAxEZXDrs5BefLWDV5xkDJkeyFM1a+P/DiYNPUzGDvaW3ERDBF8BLkhtoLc X-Received: by 2002:a17:906:11d6:: with SMTP id o22mr5512940eja.106.1611129440213; Tue, 19 Jan 2021 23:57:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611129440; cv=none; d=google.com; s=arc-20160816; b=WmuBjITMONcBzESnTOZDwC1zyC9YVl4i7a/9+KVPdubsW40g8agftK65hn9WxjAJCp k2+03MjA3Zm5CW3HSmcASuSf2qx2RUxF6UHfeQNhvzIm8BurE4qgWKf+wW7vmuorDKFk f8stAJIuaiGWz6pD6pfL8G//iS/v5HAnzPDTnI3jtXRrY6nHcjt1hVcYNRDZwFTxYddp Tje06khMPSWXtu7yTQWRBc+yvUdUYg/Tmayo0bZw/5iEtaEEY1qYCtEyctt7AW5nplFE BYdXRm9PAeBSWI1RaMahTk8zq3cA/89uXXPYfOyp9j2uiNC0yIfoKVUZvvzbweO6subY iV0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from:ironport-sdr :ironport-sdr; bh=lfUAMRLyEDZDCS4dmk/QGH5TkTBo8T+E6l6i4wuK7dw=; b=GzeJomp3rCnLpOfPxiLbwdhZu4BG2ma9go0HFVWEJNaYyDODwt7GPHXGQseHVtyyqV Ch3nSgXvdpJo/4T1DjocX/raJsy1SuwlahtiZSHd3g0rldGY29sIXO0L4RTSY+lcAlP2 P4Xn9+XpIJ1JNJt2sY6emsdatkgE8RTQDCSfUSxwQwFJbOIuoq7nXq5SIDUA1BMx39TJ sqnVw36B2NUUarGUCERXKXCBCSYvGAJ9ZFBuaDCUNyqug+/zDDRAlrcvPdzumNCBwneg HljecZzx7k+BREarWJu2Vu4yfFqmUJsTUZwiYgHbtWsQ5nXDMANL/O5Eg9zWoasvWWic enXw== 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e5si553306edy.556.2021.01.19.23.56.56; Tue, 19 Jan 2021 23:57:20 -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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728996AbhATHtO (ORCPT + 99 others); Wed, 20 Jan 2021 02:49:14 -0500 Received: from mga02.intel.com ([134.134.136.20]:24987 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729256AbhATHsk (ORCPT ); Wed, 20 Jan 2021 02:48:40 -0500 IronPort-SDR: grWsN4jFNcBc250QRwh1ymxRo01FiZELns6inc280Vq2ahTg5Rusjb14f4SW72gz86joF5zBEE RnxIusp/5CVA== X-IronPort-AV: E=McAfee;i="6000,8403,9869"; a="166154802" X-IronPort-AV: E=Sophos;i="5.79,360,1602572400"; d="scan'208";a="166154802" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2021 23:48:02 -0800 IronPort-SDR: 9XdYHIh0XeWfBKuyrXw3JamQgpD62COUfGMSnTf8jYLGX5isTDO2VAjDrWpp8siovPZadeZCfV ghyCE4au5zpw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,360,1602572400"; d="scan'208";a="426810560" Received: from host.sh.intel.com ([10.239.154.115]) by orsmga001.jf.intel.com with ESMTP; 19 Jan 2021 23:47:57 -0800 From: Ye Xiang To: jikos@kernel.org, jic23@kernel.org, srinivas.pandruvada@linux.intel.com Cc: linux-input@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Ye Xiang Subject: [PATCH] iio: hid-sensor-rotation: Fix quaternion data not correct Date: Wed, 20 Jan 2021 15:49:09 +0800 Message-Id: <20210120074909.25707-1-xiang.ye@intel.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Ye Xiang --- 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)); -- 2.17.1