All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: imu: st_lsm6dsx: add mount matrix support
@ 2020-01-03 10:26 Martin Kepplinger
  2020-01-04 11:33 ` Lorenzo Bianconi
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Kepplinger @ 2020-01-03 10:26 UTC (permalink / raw)
  To: lorenzo.bianconi83, jic23, knaack.h, lars, pmeerw
  Cc: linux-iio, linux-kernel, Martin Kepplinger

Allow to read the mount-matrix device tree property and provide the
mount_matrix file for userspace to read.

Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
---

tested using the lsm9ds1 on the librem5-devkit (and userspace tools like
iio-sensor-proxy) where this will be needed.

thanks,

                               martin



 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h      | 18 ++++++++++++++++++
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c |  4 ++++
 2 files changed, 22 insertions(+)

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
index a763ff46f596..8483f770b233 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
@@ -76,6 +76,7 @@ enum st_lsm6dsx_hw_id {
 		.endianness = IIO_LE,					\
 	},								\
 	.event_spec = &st_lsm6dsx_event,				\
+	.ext_info = st_lsm6dsx_accel_ext_info,				\
 	.num_event_specs = 1,						\
 }
 
@@ -406,6 +407,8 @@ struct st_lsm6dsx_hw {
 	struct iio_dev *iio_devs[ST_LSM6DSX_ID_MAX];
 
 	const struct st_lsm6dsx_settings *settings;
+
+	struct iio_mount_matrix orientation;
 };
 
 static __maybe_unused const struct iio_event_spec st_lsm6dsx_event = {
@@ -479,4 +482,19 @@ st_lsm6dsx_write_locked(struct st_lsm6dsx_hw *hw, unsigned int addr,
 	return err;
 }
 
+static const struct iio_mount_matrix *
+st_lsm6dsx_get_mount_matrix(const struct iio_dev *iio_dev,
+			    const struct iio_chan_spec *chan)
+{
+	struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev);
+	struct st_lsm6dsx_hw *hw = sensor->hw;
+
+	return &hw->orientation;
+}
+
+static const struct iio_chan_spec_ext_info st_lsm6dsx_accel_ext_info[] = {
+	IIO_MOUNT_MATRIX(IIO_SHARED_BY_ALL, st_lsm6dsx_get_mount_matrix),
+	{ }
+};
+
 #endif /* ST_LSM6DSX_H */
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
index 0c64e35c7599..587e02bb9be9 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
@@ -2325,6 +2325,10 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
 	    (pdata && pdata->wakeup_source))
 		device_init_wakeup(dev, true);
 
+	err = iio_read_mount_matrix(hw->dev, "mount-matrix", &hw->orientation);
+	if (err)
+		return err;
+
 	return 0;
 }
 EXPORT_SYMBOL(st_lsm6dsx_probe);
-- 
2.20.1


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

* Re: [PATCH] iio: imu: st_lsm6dsx: add mount matrix support
  2020-01-03 10:26 [PATCH] iio: imu: st_lsm6dsx: add mount matrix support Martin Kepplinger
@ 2020-01-04 11:33 ` Lorenzo Bianconi
  2020-01-04 13:04   ` Martin Kepplinger
  0 siblings, 1 reply; 3+ messages in thread
From: Lorenzo Bianconi @ 2020-01-04 11:33 UTC (permalink / raw)
  To: Martin Kepplinger
  Cc: lorenzo.bianconi83, jic23, knaack.h, lars, pmeerw, linux-iio

[-- Attachment #1: Type: text/plain, Size: 2874 bytes --]

> Allow to read the mount-matrix device tree property and provide the
> mount_matrix file for userspace to read.
> 
> Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
> ---
> 
> tested using the lsm9ds1 on the librem5-devkit (and userspace tools like
> iio-sensor-proxy) where this will be needed.
> 
> thanks,
> 
>                                martin
> 
> 
> 
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h      | 18 ++++++++++++++++++
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c |  4 ++++
>  2 files changed, 22 insertions(+)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> index a763ff46f596..8483f770b233 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> @@ -76,6 +76,7 @@ enum st_lsm6dsx_hw_id {
>  		.endianness = IIO_LE,					\
>  	},								\
>  	.event_spec = &st_lsm6dsx_event,				\
> +	.ext_info = st_lsm6dsx_accel_ext_info,				\
>  	.num_event_specs = 1,						\
>  }
>  
> @@ -406,6 +407,8 @@ struct st_lsm6dsx_hw {
>  	struct iio_dev *iio_devs[ST_LSM6DSX_ID_MAX];
>  
>  	const struct st_lsm6dsx_settings *settings;
> +
> +	struct iio_mount_matrix orientation;

Could you please add doc for orientation struct as we did for all other member
of st_lsm6dsx_hw?

>  };
>  
>  static __maybe_unused const struct iio_event_spec st_lsm6dsx_event = {
> @@ -479,4 +482,19 @@ st_lsm6dsx_write_locked(struct st_lsm6dsx_hw *hw, unsigned int addr,
>  	return err;
>  }
>  
> +static const struct iio_mount_matrix *
> +st_lsm6dsx_get_mount_matrix(const struct iio_dev *iio_dev,
> +			    const struct iio_chan_spec *chan)

static const inline struct iio_mount_matrix *
st_lsm6dsx_get_mount_matrix(const struct iio_dev *iio_dev

> +{
> +	struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev);
> +	struct st_lsm6dsx_hw *hw = sensor->hw;
> +
> +	return &hw->orientation;
> +}
> +
> +static const struct iio_chan_spec_ext_info st_lsm6dsx_accel_ext_info[] = {
> +	IIO_MOUNT_MATRIX(IIO_SHARED_BY_ALL, st_lsm6dsx_get_mount_matrix),
> +	{ }
> +};
> +
>  #endif /* ST_LSM6DSX_H */
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index 0c64e35c7599..587e02bb9be9 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -2325,6 +2325,10 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
>  	    (pdata && pdata->wakeup_source))
>  		device_init_wakeup(dev, true);
>  
> +	err = iio_read_mount_matrix(hw->dev, "mount-matrix", &hw->orientation);
> +	if (err)
> +		return err;
> +
>  	return 0;

	return iio_read_mount_matrix(hw->dev, "mount-matrix",
				     &hw->orientation); 

>  }
>  EXPORT_SYMBOL(st_lsm6dsx_probe);
> -- 
> 2.20.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: [PATCH] iio: imu: st_lsm6dsx: add mount matrix support
  2020-01-04 11:33 ` Lorenzo Bianconi
@ 2020-01-04 13:04   ` Martin Kepplinger
  0 siblings, 0 replies; 3+ messages in thread
From: Martin Kepplinger @ 2020-01-04 13:04 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: lorenzo.bianconi83, jic23, knaack.h, lars, pmeerw, linux-iio

On 04.01.20 12:33, Lorenzo Bianconi wrote:
>> Allow to read the mount-matrix device tree property and provide the
>> mount_matrix file for userspace to read.
>>
>> Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
>> ---
>>
>> tested using the lsm9ds1 on the librem5-devkit (and userspace tools like
>> iio-sensor-proxy) where this will be needed.
>>
>> thanks,
>>
>>                                martin
>>
>>
>>
>>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h      | 18 ++++++++++++++++++
>>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c |  4 ++++
>>  2 files changed, 22 insertions(+)
>>
>> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
>> index a763ff46f596..8483f770b233 100644
>> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
>> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
>> @@ -76,6 +76,7 @@ enum st_lsm6dsx_hw_id {
>>  		.endianness = IIO_LE,					\
>>  	},								\
>>  	.event_spec = &st_lsm6dsx_event,				\
>> +	.ext_info = st_lsm6dsx_accel_ext_info,				\
>>  	.num_event_specs = 1,						\
>>  }
>>  
>> @@ -406,6 +407,8 @@ struct st_lsm6dsx_hw {
>>  	struct iio_dev *iio_devs[ST_LSM6DSX_ID_MAX];
>>  
>>  	const struct st_lsm6dsx_settings *settings;
>> +
>> +	struct iio_mount_matrix orientation;
> 
> Could you please add doc for orientation struct as we did for all other member
> of st_lsm6dsx_hw?
> 
>>  };
>>  
>>  static __maybe_unused const struct iio_event_spec st_lsm6dsx_event = {
>> @@ -479,4 +482,19 @@ st_lsm6dsx_write_locked(struct st_lsm6dsx_hw *hw, unsigned int addr,
>>  	return err;
>>  }
>>  
>> +static const struct iio_mount_matrix *
>> +st_lsm6dsx_get_mount_matrix(const struct iio_dev *iio_dev,
>> +			    const struct iio_chan_spec *chan)
> 
> static const inline struct iio_mount_matrix *
> st_lsm6dsx_get_mount_matrix(const struct iio_dev *iio_dev
> 
>> +{
>> +	struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev);
>> +	struct st_lsm6dsx_hw *hw = sensor->hw;
>> +
>> +	return &hw->orientation;
>> +}
>> +
>> +static const struct iio_chan_spec_ext_info st_lsm6dsx_accel_ext_info[] = {
>> +	IIO_MOUNT_MATRIX(IIO_SHARED_BY_ALL, st_lsm6dsx_get_mount_matrix),
>> +	{ }
>> +};
>> +
>>  #endif /* ST_LSM6DSX_H */
>> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
>> index 0c64e35c7599..587e02bb9be9 100644
>> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
>> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
>> @@ -2325,6 +2325,10 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
>>  	    (pdata && pdata->wakeup_source))
>>  		device_init_wakeup(dev, true);
>>  
>> +	err = iio_read_mount_matrix(hw->dev, "mount-matrix", &hw->orientation);
>> +	if (err)
>> +		return err;
>> +
>>  	return 0;
> 
> 	return iio_read_mount_matrix(hw->dev, "mount-matrix",
> 				     &hw->orientation); 
> 
>>  }
>>  EXPORT_SYMBOL(st_lsm6dsx_probe);
>> -- 
>> 2.20.1
>>

thanks for reviewing Lorenzo. resending soon,

                            martin

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

end of thread, other threads:[~2020-01-04 13:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-03 10:26 [PATCH] iio: imu: st_lsm6dsx: add mount matrix support Martin Kepplinger
2020-01-04 11:33 ` Lorenzo Bianconi
2020-01-04 13:04   ` Martin Kepplinger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.