linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/2] iio: accel: kxcjk1013: Support orientation matrix
@ 2020-01-12 20:33 Dmitry Osipenko
  2020-01-12 20:33 ` [PATCH v1 2/2] dt-bindings: iio: accel: kxcjk1013: Document mount-matrix property Dmitry Osipenko
  2020-01-15 17:20 ` [PATCH v1 1/2] iio: accel: kxcjk1013: Support orientation matrix Srinivas Pandruvada
  0 siblings, 2 replies; 8+ messages in thread
From: Dmitry Osipenko @ 2020-01-12 20:33 UTC (permalink / raw)
  To: Jonathan Cameron, Rob Herring, Hartmut Knaack,
	Peter Meerwald-Stadler, Robert Yang, Srinivas Pandruvada,
	Michał Mirosław
  Cc: linux-iio, devicetree, linux-kernel

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 <digetx@gmail.com>
---
 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 <linux/iio/iio.h>
+
 struct kxcjk_1013_platform_data {
 	bool active_high_intr;
+	struct iio_mount_matrix orientation;
 };
 
 #endif
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v1 2/2] dt-bindings: iio: accel: kxcjk1013: Document mount-matrix property
  2020-01-12 20:33 [PATCH v1 1/2] iio: accel: kxcjk1013: Support orientation matrix Dmitry Osipenko
@ 2020-01-12 20:33 ` Dmitry Osipenko
  2020-01-15 15:39   ` Rob Herring
  2020-01-15 17:20 ` [PATCH v1 1/2] iio: accel: kxcjk1013: Support orientation matrix Srinivas Pandruvada
  1 sibling, 1 reply; 8+ messages in thread
From: Dmitry Osipenko @ 2020-01-12 20:33 UTC (permalink / raw)
  To: Jonathan Cameron, Rob Herring, Hartmut Knaack,
	Peter Meerwald-Stadler, Robert Yang, Srinivas Pandruvada,
	Michał Mirosław
  Cc: linux-iio, devicetree, linux-kernel

The generic IIO mount-matrix property conveys physical orientation of the
hardware chip.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 .../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";
 };
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v1 2/2] dt-bindings: iio: accel: kxcjk1013: Document mount-matrix property
  2020-01-12 20:33 ` [PATCH v1 2/2] dt-bindings: iio: accel: kxcjk1013: Document mount-matrix property Dmitry Osipenko
@ 2020-01-15 15:39   ` Rob Herring
  2020-01-18  2:42     ` Dmitry Osipenko
  0 siblings, 1 reply; 8+ messages in thread
From: Rob Herring @ 2020-01-15 15:39 UTC (permalink / raw)
  To: Dmitry Osipenko
  Cc: Jonathan Cameron, Hartmut Knaack, Peter Meerwald-Stadler,
	Robert Yang, Srinivas Pandruvada, Michał Mirosław,
	linux-iio, devicetree, linux-kernel

On Sun, 12 Jan 2020 23:33:01 +0300, Dmitry Osipenko wrote:
> The generic IIO mount-matrix property conveys physical orientation of the
> hardware chip.
> 
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
>  .../devicetree/bindings/iio/accel/kionix,kxcjk1013.txt     | 7 +++++++
>  1 file changed, 7 insertions(+)
> 

Acked-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v1 1/2] iio: accel: kxcjk1013: Support orientation matrix
  2020-01-12 20:33 [PATCH v1 1/2] iio: accel: kxcjk1013: Support orientation matrix Dmitry Osipenko
  2020-01-12 20:33 ` [PATCH v1 2/2] dt-bindings: iio: accel: kxcjk1013: Document mount-matrix property Dmitry Osipenko
@ 2020-01-15 17:20 ` Srinivas Pandruvada
  2020-01-18  2:41   ` Dmitry Osipenko
  1 sibling, 1 reply; 8+ messages in thread
From: Srinivas Pandruvada @ 2020-01-15 17:20 UTC (permalink / raw)
  To: Dmitry Osipenko, Jonathan Cameron, Rob Herring, Hartmut Knaack,
	Peter Meerwald-Stadler, Robert Yang, Michał Mirosław
  Cc: linux-iio, devicetree, linux-kernel

On Sun, 2020-01-12 at 23:33 +0300, Dmitry Osipenko wrote:
> 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 <digetx@gmail.com>

Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

> ---
>  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 <linux/iio/iio.h>
> +
>  struct kxcjk_1013_platform_data {
>  	bool active_high_intr;
> +	struct iio_mount_matrix orientation;
>  };
>  
>  #endif


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v1 1/2] iio: accel: kxcjk1013: Support orientation matrix
  2020-01-15 17:20 ` [PATCH v1 1/2] iio: accel: kxcjk1013: Support orientation matrix Srinivas Pandruvada
@ 2020-01-18  2:41   ` Dmitry Osipenko
  2020-01-18 14:27     ` Jonathan Cameron
  0 siblings, 1 reply; 8+ messages in thread
From: Dmitry Osipenko @ 2020-01-18  2:41 UTC (permalink / raw)
  To: Srinivas Pandruvada, Jonathan Cameron, Rob Herring,
	Hartmut Knaack, Peter Meerwald-Stadler, Robert Yang,
	Michał Mirosław
  Cc: linux-iio, devicetree, linux-kernel

15.01.2020 20:20, Srinivas Pandruvada пишет:
> On Sun, 2020-01-12 at 23:33 +0300, Dmitry Osipenko wrote:
>> 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 <digetx@gmail.com>
> 
> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

Thanks!


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v1 2/2] dt-bindings: iio: accel: kxcjk1013: Document mount-matrix property
  2020-01-15 15:39   ` Rob Herring
@ 2020-01-18  2:42     ` Dmitry Osipenko
  2020-01-18 14:28       ` Jonathan Cameron
  0 siblings, 1 reply; 8+ messages in thread
From: Dmitry Osipenko @ 2020-01-18  2:42 UTC (permalink / raw)
  To: Rob Herring
  Cc: Jonathan Cameron, Hartmut Knaack, Peter Meerwald-Stadler,
	Robert Yang, Srinivas Pandruvada, Michał Mirosław,
	linux-iio, devicetree, linux-kernel

15.01.2020 18:39, Rob Herring пишет:
> On Sun, 12 Jan 2020 23:33:01 +0300, Dmitry Osipenko wrote:
>> The generic IIO mount-matrix property conveys physical orientation of the
>> hardware chip.
>>
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>> ---
>>  .../devicetree/bindings/iio/accel/kionix,kxcjk1013.txt     | 7 +++++++
>>  1 file changed, 7 insertions(+)
>>
> 
> Acked-by: Rob Herring <robh@kernel.org>
> 

Thanks!

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v1 1/2] iio: accel: kxcjk1013: Support orientation matrix
  2020-01-18  2:41   ` Dmitry Osipenko
@ 2020-01-18 14:27     ` Jonathan Cameron
  0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2020-01-18 14:27 UTC (permalink / raw)
  To: Dmitry Osipenko
  Cc: Srinivas Pandruvada, Rob Herring, Hartmut Knaack,
	Peter Meerwald-Stadler, Robert Yang, Michał Mirosław,
	linux-iio, devicetree, linux-kernel

On Sat, 18 Jan 2020 05:41:33 +0300
Dmitry Osipenko <digetx@gmail.com> wrote:

> 15.01.2020 20:20, Srinivas Pandruvada пишет:
> > On Sun, 2020-01-12 at 23:33 +0300, Dmitry Osipenko wrote:  
> >> 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 <digetx@gmail.com>  
> > 
> > Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>  
> 
> Thanks!
> 
Applied to the togreg branch of iio.git and pushed out as testing
to let the various automated test systems poke at it before I push
out as non rebasing.

Thanks,

Jonathan


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v1 2/2] dt-bindings: iio: accel: kxcjk1013: Document mount-matrix property
  2020-01-18  2:42     ` Dmitry Osipenko
@ 2020-01-18 14:28       ` Jonathan Cameron
  0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2020-01-18 14:28 UTC (permalink / raw)
  To: Dmitry Osipenko
  Cc: Rob Herring, Hartmut Knaack, Peter Meerwald-Stadler, Robert Yang,
	Srinivas Pandruvada, Michał Mirosław, linux-iio,
	devicetree, linux-kernel

On Sat, 18 Jan 2020 05:42:01 +0300
Dmitry Osipenko <digetx@gmail.com> wrote:

> 15.01.2020 18:39, Rob Herring пишет:
> > On Sun, 12 Jan 2020 23:33:01 +0300, Dmitry Osipenko wrote:  
> >> The generic IIO mount-matrix property conveys physical orientation of the
> >> hardware chip.
> >>
> >> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> >> ---
> >>  .../devicetree/bindings/iio/accel/kionix,kxcjk1013.txt     | 7 +++++++
> >>  1 file changed, 7 insertions(+)
> >>  
> > 
> > Acked-by: Rob Herring <robh@kernel.org>
> >   
> 
> Thanks!
Applied.

thanks,

Jonathan


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-01-18 14:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-12 20:33 [PATCH v1 1/2] iio: accel: kxcjk1013: Support orientation matrix Dmitry Osipenko
2020-01-12 20:33 ` [PATCH v1 2/2] dt-bindings: iio: accel: kxcjk1013: Document mount-matrix property Dmitry Osipenko
2020-01-15 15:39   ` Rob Herring
2020-01-18  2:42     ` Dmitry Osipenko
2020-01-18 14:28       ` Jonathan Cameron
2020-01-15 17:20 ` [PATCH v1 1/2] iio: accel: kxcjk1013: Support orientation matrix Srinivas Pandruvada
2020-01-18  2:41   ` Dmitry Osipenko
2020-01-18 14:27     ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).