From patchwork Sun May 7 10:24:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Song, Hongyan" X-Patchwork-Id: 9715573 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 39499602BD for ; Sun, 7 May 2017 22:23:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D7AB22B39 for ; Sun, 7 May 2017 22:23:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 224B024151; Sun, 7 May 2017 22:23:28 +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 97AFD22B39 for ; Sun, 7 May 2017 22:23:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756760AbdEGWX0 (ORCPT ); Sun, 7 May 2017 18:23:26 -0400 Received: from mga04.intel.com ([192.55.52.120]:62260 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756726AbdEGWXY (ORCPT ); Sun, 7 May 2017 18:23:24 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 May 2017 19:01:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,301,1491289200"; d="scan'208";a="1144612690" Received: from shsensorbuild.sh.intel.com ([10.239.133.27]) by fmsmga001.fm.intel.com with ESMTP; 06 May 2017 19:01:36 -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 v2 2/3] iio: hid-sensor-rotation: Add geomagnetic orientation sensor hid support. Date: Sun, 7 May 2017 18:24:25 +0800 Message-Id: <1494152666-25632-2-git-send-email-hongyan.song@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1494152666-25632-1-git-send-email-hongyan.song@intel.com> References: <1494152666-25632-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 --- drivers/iio/orientation/hid-sensor-rotation.c | 7 +++++++ include/linux/hid-sensor-ids.h | 1 + 2 files changed, 8 insertions(+) diff --git a/drivers/iio/orientation/hid-sensor-rotation.c b/drivers/iio/orientation/hid-sensor-rotation.c index 4d953c2..60d3517 100644 --- a/drivers/iio/orientation/hid-sensor-rotation.c +++ b/drivers/iio/orientation/hid-sensor-rotation.c @@ -241,6 +241,9 @@ static int hid_dev_rot_probe(struct platform_device *pdev) case HID_USAGE_SENSOR_RELATIVE_ORIENTATION: name = "relative_orientation"; break; + case HID_USAGE_SENSOR_GEOMAGNETIC_ORIENTATION: + name = "geomagnetic_orientation"; + break; default: return -EINVAL; } @@ -339,6 +342,10 @@ static int hid_dev_rot_remove(struct platform_device *pdev) /* Relative 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