From patchwork Sun Jan 12 20:33:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11329351 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C68991398 for ; Sun, 12 Jan 2020 20:33:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A434821556 for ; Sun, 12 Jan 2020 20:33:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PR4yTzhW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387424AbgALUda (ORCPT ); Sun, 12 Jan 2020 15:33:30 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:44469 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732825AbgALUda (ORCPT ); Sun, 12 Jan 2020 15:33:30 -0500 Received: by mail-lj1-f195.google.com with SMTP id u71so7708590lje.11; Sun, 12 Jan 2020 12:33:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IrLDzyGfd9Y65dDT7UGMmoZnTT7I7zow/6QfstVQ1DA=; b=PR4yTzhWStLUhH3DAX7PztJkvplbspQP1sh3ZPkIxh99aUo16NYjsw1SkMtWfI4QQN 1Mr8p/lm6LQjAR4Hf/SWSPJ+lwa31z/0hEylxaAVjvBCV/yQLo0/CxixjrPt1/x07Mj/ 9NBM8h5sfAVUvaWcyhwiPx5+qOyq/eEhubGuJ/8Q2phD2xh1Dk/kgX7+g4RUp8iFM1V8 4LVMop1fLxL8F4T7uv/JKAUI37X+bXeaCVsS0eqsdT3DRSycvCS0xS0O3uZRx5xxIlFA UHtWrys6/cCmbWju3qjsu+jC1bKSbbJl7V5pdtt2pjUjJY0qavSoS8M7uyoWYwuhSGuG KLRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IrLDzyGfd9Y65dDT7UGMmoZnTT7I7zow/6QfstVQ1DA=; b=tXLG6ns9J8n5VpPsu7T5XrEukKbqnjOTezrcfBEt7SKZqyrETvseEnOC2TtOiGeRX3 Y/YyK84Ce1uHcksqIwTV420wDRbd/nUl4BC8Hgw2KsjF+9m1LIPw9UNUFWKX8jpPm042 HBMyw/k4mn0mJqyE/25wSevp/UKynTeC3eSML+HhAN75FH/3P/EpzSKf3yLXjzG8zSfd 770SpxIqJkEMpClM7ROvfmnMBnflxTMFopcXg3WU5I+kri0PRi6fTKpasF6wUI/7XASh uROrcPsdNZz2Nz+f25y4Og3j8PhJsl77dMxgbfzRupW5/AGIocq0KQ3jzxenGRbjbA/k MM2Q== X-Gm-Message-State: APjAAAWz+fD3VKoluFyigalzVJ6NZZPb4nkA1C+Yu18mHO95aDHII+Wl pTJFzT9KBrKrX6KRCN4i1Xc= X-Google-Smtp-Source: APXvYqwBfFAR8OQmBDBjCB3tz+Dj8/kUMmk3fxUvn9wOopBq3+C0Rda9DnZGFOZcSEMrlFNwxHgDKA== X-Received: by 2002:a05:651c:1045:: with SMTP id x5mr6601786ljm.266.1578861208532; Sun, 12 Jan 2020 12:33:28 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id u16sm5255192lfi.36.2020.01.12.12.33.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2020 12:33:27 -0800 (PST) From: Dmitry Osipenko To: Jonathan Cameron , Rob Herring , Hartmut Knaack , Peter Meerwald-Stadler , Robert Yang , Srinivas Pandruvada , =?utf-8?b?TWlj?= =?utf-8?b?aGHFgiBNaXJvc8WCYXc=?= Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 1/2] iio: accel: kxcjk1013: Support orientation matrix Date: Sun, 12 Jan 2020 23:33:00 +0300 Message-Id: <20200112203301.30235-1-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Hardware could be physically mounted in any possible direction and userpspace needs to be aware of the mounting orientation in order to process sensor's data correctly. In particular this helps iio-sensor-proxy to report display's orientation properly on a phone/tablet devices. Signed-off-by: Dmitry Osipenko Acked-by: Srinivas Pandruvada --- drivers/iio/accel/kxcjk-1013.c | 27 +++++++++++++++++++++++++-- include/linux/iio/accel/kxcjk_1013.h | 3 +++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c index fee535d6e45b..c9924a65c32a 100644 --- a/drivers/iio/accel/kxcjk-1013.c +++ b/drivers/iio/accel/kxcjk-1013.c @@ -130,6 +130,7 @@ struct kxcjk1013_data { struct i2c_client *client; struct iio_trigger *dready_trig; struct iio_trigger *motion_trig; + struct iio_mount_matrix orientation; struct mutex mutex; s16 buffer[8]; u8 odr_bits; @@ -983,6 +984,20 @@ static const struct iio_event_spec kxcjk1013_event = { BIT(IIO_EV_INFO_PERIOD) }; +static const struct iio_mount_matrix * +kxcjk1013_get_mount_matrix(const struct iio_dev *indio_dev, + const struct iio_chan_spec *chan) +{ + struct kxcjk1013_data *data = iio_priv(indio_dev); + + return &data->orientation; +} + +static const struct iio_chan_spec_ext_info kxcjk1013_ext_info[] = { + IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, kxcjk1013_get_mount_matrix), + { } +}; + #define KXCJK1013_CHANNEL(_axis) { \ .type = IIO_ACCEL, \ .modified = 1, \ @@ -999,6 +1014,7 @@ static const struct iio_event_spec kxcjk1013_event = { .endianness = IIO_LE, \ }, \ .event_spec = &kxcjk1013_event, \ + .ext_info = kxcjk1013_ext_info, \ .num_event_specs = 1 \ } @@ -1267,11 +1283,18 @@ static int kxcjk1013_probe(struct i2c_client *client, data->client = client; pdata = dev_get_platdata(&client->dev); - if (pdata) + if (pdata) { data->active_high_intr = pdata->active_high_intr; - else + data->orientation = pdata->orientation; + } else { data->active_high_intr = true; /* default polarity */ + ret = iio_read_mount_matrix(&client->dev, "mount-matrix", + &data->orientation); + if (ret) + return ret; + } + if (id) { data->chipset = (enum kx_chipset)(id->driver_data); name = id->name; diff --git a/include/linux/iio/accel/kxcjk_1013.h b/include/linux/iio/accel/kxcjk_1013.h index 8c3c78bc9f91..ea0ecb774371 100644 --- a/include/linux/iio/accel/kxcjk_1013.h +++ b/include/linux/iio/accel/kxcjk_1013.h @@ -7,8 +7,11 @@ #ifndef __IIO_KXCJK_1013_H__ #define __IIO_KXCJK_1013_H__ +#include + struct kxcjk_1013_platform_data { bool active_high_intr; + struct iio_mount_matrix orientation; }; #endif From patchwork Sun Jan 12 20:33:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11329349 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4B1E61398 for ; Sun, 12 Jan 2020 20:33:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 226AD21744 for ; Sun, 12 Jan 2020 20:33:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UpBX2EaY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732825AbgALUdb (ORCPT ); Sun, 12 Jan 2020 15:33:31 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:34713 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732960AbgALUdb (ORCPT ); Sun, 12 Jan 2020 15:33:31 -0500 Received: by mail-lj1-f194.google.com with SMTP id z22so7772904ljg.1; Sun, 12 Jan 2020 12:33:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OEXS1Fk5NwKMmzWNoapPYNtdz3Lk1NcwWzzA/BJNXDg=; b=UpBX2EaY5SAVsaubaMJ7OUg/H+3PFwPFWA3+VizPmtV1FrcMOEUvg+jy+QNcADa0EW wlNKY2usPqmqXZa2RtNx5iAIPpV1lDnV7ivg+LuzaK+mjELcnRZAtiDZyoQe1eOFVkBY Z5u9KtBWEuP5/dXv8h9b50GvFyS1sGqe5OM8+02k/rgagrofWkXwBLMai/gcMtXOJi3k 47sMBOgzgLy9n/kbh73QTfpghPMSn9xGgZ3A4zL4X8TDzmhF0HcjwjxgQ7AuBwfcmWXc RBsILhJ3F8f1o5OCgBjh1OFvhsdXIrTfDIQd++tnCXaBDx+oD7dmjl0AwdUFKK0XdJK/ FDCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OEXS1Fk5NwKMmzWNoapPYNtdz3Lk1NcwWzzA/BJNXDg=; b=gDdREcjrq7ntvFyn7HDVRlrHrkfIxpgeb8oLb6+ZKFeGWoU+25/+YjOJs3wgJfxRDy CyPgutGbmEvLXikMi3/SW0Y3UnychC1+kGIlPFCZcyXxN8OGgiSv/2Nk+qur65ltJKg3 P0pP8y4Yne7fHo9O4V7GtHDrab1w9a6vNCEj1BBKQG++MXfNZsfV72QZ9ZZhPshBlvN/ B4babSnuWDhROf2m6/puNTVPASnXa32wX0lmKp0SacgWyCcZxnTFt0jERwGb/JBHtdAs 1QOs2OZjfkYEEcgYsYdNCUaS+27D39/I767SLNrlFs8zDla+4Ap4LBhFG7LkicOY0utN +qsA== X-Gm-Message-State: APjAAAXCKQDhGUSpkbz/cyu75FOa6e87HJTfBpoWPiwPqzPI4LH4uK4j cn0d6DKD+P9zpnJ1s8FIuKI= X-Google-Smtp-Source: APXvYqwVk17pUy2k573QCR+qFhYjB4UrRtNQEr+dE2/IAp0CfNsasaxxBu5SgNftYikvEYvHIr6TuQ== X-Received: by 2002:a2e:8145:: with SMTP id t5mr9097471ljg.144.1578861209411; Sun, 12 Jan 2020 12:33:29 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id u16sm5255192lfi.36.2020.01.12.12.33.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2020 12:33:29 -0800 (PST) From: Dmitry Osipenko To: Jonathan Cameron , Rob Herring , Hartmut Knaack , Peter Meerwald-Stadler , Robert Yang , Srinivas Pandruvada , =?utf-8?b?TWlj?= =?utf-8?b?aGHFgiBNaXJvc8WCYXc=?= Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 2/2] dt-bindings: iio: accel: kxcjk1013: Document mount-matrix property Date: Sun, 12 Jan 2020 23:33:01 +0300 Message-Id: <20200112203301.30235-2-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200112203301.30235-1-digetx@gmail.com> References: <20200112203301.30235-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The generic IIO mount-matrix property conveys physical orientation of the hardware chip. Signed-off-by: Dmitry Osipenko Acked-by: Rob Herring --- .../devicetree/bindings/iio/accel/kionix,kxcjk1013.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/accel/kionix,kxcjk1013.txt b/Documentation/devicetree/bindings/iio/accel/kionix,kxcjk1013.txt index eb76a02e2a82..ce950e162d5d 100644 --- a/Documentation/devicetree/bindings/iio/accel/kionix,kxcjk1013.txt +++ b/Documentation/devicetree/bindings/iio/accel/kionix,kxcjk1013.txt @@ -9,9 +9,16 @@ Required properties: "kionix,kxtf9" - reg: i2c slave address +Optional properties: + + - mount-matrix: an optional 3x3 mounting rotation matrix + Example: kxtf9@f { compatible = "kionix,kxtf9"; reg = <0x0F>; + mount-matrix = "0", "1", "0", + "1", "0", "0", + "0", "0", "1"; };