From patchwork Fri May 5 13:39:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Song, Hongyan" X-Patchwork-Id: 9713053 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C59CA60387 for ; Fri, 5 May 2017 05:16:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B80BC2866D for ; Fri, 5 May 2017 05:16:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ACACF286B4; Fri, 5 May 2017 05:16:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00, DATE_IN_FUTURE_06_12, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 56FAA2866D for ; Fri, 5 May 2017 05:16:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755272AbdEEFQg (ORCPT ); Fri, 5 May 2017 01:16:36 -0400 Received: from mga11.intel.com ([192.55.52.93]:19876 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754840AbdEEFQg (ORCPT ); Fri, 5 May 2017 01:16:36 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 May 2017 22:16:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,291,1491289200"; d="scan'208";a="97534687" Received: from shsensorbuild.sh.intel.com ([10.239.133.27]) by fmsmga005.fm.intel.com with ESMTP; 04 May 2017 22:16:34 -0700 From: Song Hongyan To: linux-input@vger.kernel.org, linux-iio@vger.kernel.org Cc: jikos@kernel.org, jic23@kernel.org, srinivas.pandruvada@intel.com, Song Hongyan Subject: [PATCH 2/3] iio: hid-sensor-rotation: Add geomagnetic orientation sensor hid support. Date: Fri, 5 May 2017 21:39:24 +0800 Message-Id: <1493991565-17947-2-git-send-email-hongyan.song@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1493991565-17947-1-git-send-email-hongyan.song@intel.com> References: <1493991565-17947-1-git-send-email-hongyan.song@intel.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Geomagnetic orientation(AM) sensor is one kind of orientation 6dof sensor. It gives the device rotation in respect to the earth center and the magnetic north. The sensor is implemented through use of an accelerometer and magnetometer do not use gyroscope. It is a standard HID sensor. More information can be found in: http://www.usb.org/developers/hidpage/HUTRR59_-_Usages_for_Wearables.pdf Geomagnetic orientation(AM) sensor and dev rotation sensor have same channel and share channel usage id. So the most of the code for relative orientation sensor can be reused. Signed-off-by: Song Hongyan Reviewed-by: Andy Shevchenko Reviewed-by: Xu Even Acked-by: Srinivas Pandruvada --- drivers/iio/orientation/hid-sensor-rotation.c | 6 ++++++ include/linux/hid-sensor-ids.h | 1 + 2 files changed, 7 insertions(+) diff --git a/drivers/iio/orientation/hid-sensor-rotation.c b/drivers/iio/orientation/hid-sensor-rotation.c index 5f07a5a..93ec5e8 100644 --- a/drivers/iio/orientation/hid-sensor-rotation.c +++ b/drivers/iio/orientation/hid-sensor-rotation.c @@ -238,6 +238,8 @@ static int hid_dev_rot_probe(struct platform_device *pdev) name = "dev_rotation"; else if (hsdev->usage == HID_USAGE_SENSOR_RELATIVE_ORIENTATION) name = "relative_orientation"; + else if (hsdev->usage == HID_USAGE_SENSOR_GEOMAGNETIC_ORIENTATION) + name = "geomagnetic_orientation"; ret = hid_sensor_parse_common_attributes(hsdev, hsdev->usage, &rot_state->common_attributes); @@ -333,6 +335,10 @@ static int hid_dev_rot_remove(struct platform_device *pdev) /* Relatve orientation(AG) sensor */ .name = "HID-SENSOR-20008e", }, + { + /* Geomagnetic orientation(AM) sensor */ + .name = "HID-SENSOR-2000c1", + }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(platform, hid_dev_rot_ids); diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h index b61b985..4fc47e5 100644 --- a/include/linux/hid-sensor-ids.h +++ b/include/linux/hid-sensor-ids.h @@ -83,6 +83,7 @@ #define HID_USAGE_SENSOR_DEVICE_ORIENTATION 0x20008A #define HID_USAGE_SENSOR_RELATIVE_ORIENTATION 0x20008E +#define HID_USAGE_SENSOR_GEOMAGNETIC_ORIENTATION 0x2000C1 #define HID_USAGE_SENSOR_ORIENT_ROTATION_MATRIX 0x200482 #define HID_USAGE_SENSOR_ORIENT_QUATERNION 0x200483 #define HID_USAGE_SENSOR_ORIENT_MAGN_FLUX 0x200484