Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1271066 > unrolled thread

[RFC 1/2] ABI: iio: support AVERAGING_RATIO setting

Started byMarc Titinger <mtitinger@baylibre.com>
First post2015-11-17 11:50 +0100
Last post2015-11-17 15:10 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [RFC 1/2] ABI: iio: support AVERAGING_RATIO setting Marc Titinger <mtitinger@baylibre.com> - 2015-11-17 11:50 +0100
    Re: [RFC 1/2] ABI: iio: support AVERAGING_RATIO setting jic23@jic23.retrosnub.co.uk - 2015-11-17 14:50 +0100
      Re: [RFC 1/2] ABI: iio: support AVERAGING_RATIO setting Marc Titinger <mtitinger@baylibre.com> - 2015-11-17 15:10 +0100

#1271066 — [RFC 1/2] ABI: iio: support AVERAGING_RATIO setting

FromMarc Titinger <mtitinger@baylibre.com>
Date2015-11-17 11:50 +0100
Subject[RFC 1/2] ABI: iio: support AVERAGING_RATIO setting
Message-ID<qvLZM-3Ro-15@gated-at.bofh.it>
Some ADC devices allow averaging/downsampling. The minimal parameter
set for this will be the number of taps used for computing a mean value.

In some cases the ratio will hold discrete values for instance "1, 4, 16"
hence an averaging_ratio_available property is useful. The possible ratio
values are less likely to changing with the device settings, so this patch
only provides a CONST version of the definition helper.

Tested with ina226:

# ls /sys/bus/iio/devices/iio\:device0/
averaging_ratio_available     in_voltage0_raw
dev                           in_voltage1_raw
in_averaging_ratio            name
in_calibscale                 power
in_current2_raw               sampling_frequency_available
in_power3_raw                 subsystem
in_sampling_frequency         uevent

# cat averaging_ratio_available
1, 4, 16, 64, 128, 256, 512, 1024

Signed-off-by: Marc Titinger <mtitinger@baylibre.com>
---
 Documentation/ABI/testing/sysfs-bus-iio | 13 +++++++++++++
 drivers/iio/industrialio-core.c         |  1 +
 include/linux/iio/iio.h                 |  1 +
 include/linux/iio/sysfs.h               |  9 +++++++++
 4 files changed, 24 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
index 42d360f..a208dfe 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio
+++ b/Documentation/ABI/testing/sysfs-bus-iio
@@ -56,6 +56,19 @@ Description:
 		When the internal sampling clock can only take a small
 		discrete set of values, this file lists those available.
 
+What:		/sys/bus/iio/devices/iio:deviceX/averaging_ratio
+KernelVersion:	4.x.x
+Contact:	linux-iio@vger.kernel.org
+Description:
+		Hardware dependent ADC averaging. Controls the averaging ratio
+		of the digital filter if available.
+
+What:		/sys/bus/iio/devices/iio:deviceX/averaging_ratio_available
+KernelVersion:	4.x.x
+Contact:	linux-iio@vger.kernel.org
+Description:
+		Hardware dependent values supported by the averaging filter.
+
 What:		/sys/bus/iio/devices/iio:deviceX/oversampling_ratio
 KernelVersion:	2.6.38
 Contact:	linux-iio@vger.kernel.org
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index b3fcc2c..e4745f0 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -142,6 +142,7 @@ static const char * const iio_chan_info_postfix[] = {
 	[IIO_CHAN_INFO_DEBOUNCE_TIME] = "debounce_time",
 	[IIO_CHAN_INFO_CALIBEMISSIVITY] = "calibemissivity",
 	[IIO_CHAN_INFO_OVERSAMPLING_RATIO] = "oversampling_ratio",
+	[IIO_CHAN_INFO_AVERAGING_RATIO] = "averaging_ratio",
 };
 
 /**
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index 7bb7f67..4c84de5 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -46,6 +46,7 @@ enum iio_chan_info_enum {
 	IIO_CHAN_INFO_DEBOUNCE_TIME,
 	IIO_CHAN_INFO_CALIBEMISSIVITY,
 	IIO_CHAN_INFO_OVERSAMPLING_RATIO,
+	IIO_CHAN_INFO_AVERAGING_RATIO,
 };
 
 enum iio_shared_by {
diff --git a/include/linux/iio/sysfs.h b/include/linux/iio/sysfs.h
index 9cd8f74..4478ba1 100644
--- a/include/linux/iio/sysfs.h
+++ b/include/linux/iio/sysfs.h
@@ -76,6 +76,15 @@ struct iio_const_attr {
 /* Generic attributes of onetype or another */
 
 /**
+ * IIO_CONST_ATTR_AVERAGING_RATIO_AVAIL - list available averaging ratios
+ * @_string: ratio string for the attribute
+ *
+ * Constant version
+ **/
+#define IIO_CONST_ATTR_AVERAGING_RATIO_AVAIL(_string)                 \
+	IIO_CONST_ATTR(averaging_ratio_available, _string)
+
+/**
  * IIO_DEV_ATTR_SAMP_FREQ - sets any internal clock frequency
  * @_mode: sysfs file mode/permissions
  * @_show: output method for the attribute
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1271215

Fromjic23@jic23.retrosnub.co.uk
Date2015-11-17 14:50 +0100
Message-ID<qvONZ-5HC-43@gated-at.bofh.it>
In reply to#1271066
On 17.11.2015 10:44, Marc Titinger wrote:
> Some ADC devices allow averaging/downsampling. The minimal parameter
> set for this will be the number of taps used for computing a mean 
> value.
> 
> In some cases the ratio will hold discrete values for instance "1, 4, 
> 16"
> hence an averaging_ratio_available property is useful. The possible 
> ratio
> values are less likely to changing with the device settings, so this 
> patch
> only provides a CONST version of the definition helper.
> 
> Tested with ina226:
> 
> # ls /sys/bus/iio/devices/iio\:device0/
> averaging_ratio_available     in_voltage0_raw
> dev                           in_voltage1_raw
> in_averaging_ratio            name
> in_calibscale                 power
> in_current2_raw               sampling_frequency_available
> in_power3_raw                 subsystem
> in_sampling_frequency         uevent
> 
> # cat averaging_ratio_available
> 1, 4, 16, 64, 128, 256, 512, 1024
> 
> Signed-off-by: Marc Titinger <mtitinger@baylibre.com>
Having just noted the previous element we added was oversampling_ratio,
in a sense they are somewhat similar.

To play Devil's advocate...
Could we in theory just use that as it is existing ABI?

oversampling_ratio was introduced for the bmc150.
That particular part doesn't have the worlds clearest datasheet
but it seems like it's effectively specifying how many repeat 
measurements
to average.

I'm afraid I'd completely forgotten about this or
I would have mentioned it earlier!

Jonathan

> ---
>  Documentation/ABI/testing/sysfs-bus-iio | 13 +++++++++++++
>  drivers/iio/industrialio-core.c         |  1 +
>  include/linux/iio/iio.h                 |  1 +
>  include/linux/iio/sysfs.h               |  9 +++++++++
>  4 files changed, 24 insertions(+)
> 
> diff --git a/Documentation/ABI/testing/sysfs-bus-iio
> b/Documentation/ABI/testing/sysfs-bus-iio
> index 42d360f..a208dfe 100644
> --- a/Documentation/ABI/testing/sysfs-bus-iio
> +++ b/Documentation/ABI/testing/sysfs-bus-iio
> @@ -56,6 +56,19 @@ Description:
>  		When the internal sampling clock can only take a small
>  		discrete set of values, this file lists those available.
> 
> +What:		/sys/bus/iio/devices/iio:deviceX/averaging_ratio
> +KernelVersion:	4.x.x
> +Contact:	linux-iio@vger.kernel.org
> +Description:
> +		Hardware dependent ADC averaging. Controls the averaging ratio
> +		of the digital filter if available.
> +
> +What:		/sys/bus/iio/devices/iio:deviceX/averaging_ratio_available
> +KernelVersion:	4.x.x
> +Contact:	linux-iio@vger.kernel.org
> +Description:
> +		Hardware dependent values supported by the averaging filter.
> +
>  What:		/sys/bus/iio/devices/iio:deviceX/oversampling_ratio
>  KernelVersion:	2.6.38
>  Contact:	linux-iio@vger.kernel.org
> diff --git a/drivers/iio/industrialio-core.c 
> b/drivers/iio/industrialio-core.c
> index b3fcc2c..e4745f0 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -142,6 +142,7 @@ static const char * const iio_chan_info_postfix[] = 
> {
>  	[IIO_CHAN_INFO_DEBOUNCE_TIME] = "debounce_time",
>  	[IIO_CHAN_INFO_CALIBEMISSIVITY] = "calibemissivity",
>  	[IIO_CHAN_INFO_OVERSAMPLING_RATIO] = "oversampling_ratio",
> +	[IIO_CHAN_INFO_AVERAGING_RATIO] = "averaging_ratio",
>  };
> 
>  /**
> diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
> index 7bb7f67..4c84de5 100644
> --- a/include/linux/iio/iio.h
> +++ b/include/linux/iio/iio.h
> @@ -46,6 +46,7 @@ enum iio_chan_info_enum {
>  	IIO_CHAN_INFO_DEBOUNCE_TIME,
>  	IIO_CHAN_INFO_CALIBEMISSIVITY,
>  	IIO_CHAN_INFO_OVERSAMPLING_RATIO,
> +	IIO_CHAN_INFO_AVERAGING_RATIO,
>  };
> 
>  enum iio_shared_by {
> diff --git a/include/linux/iio/sysfs.h b/include/linux/iio/sysfs.h
> index 9cd8f74..4478ba1 100644
> --- a/include/linux/iio/sysfs.h
> +++ b/include/linux/iio/sysfs.h
> @@ -76,6 +76,15 @@ struct iio_const_attr {
>  /* Generic attributes of onetype or another */
> 
>  /**
> + * IIO_CONST_ATTR_AVERAGING_RATIO_AVAIL - list available averaging 
> ratios
> + * @_string: ratio string for the attribute
> + *
> + * Constant version
> + **/
> +#define IIO_CONST_ATTR_AVERAGING_RATIO_AVAIL(_string)                 
> \
> +	IIO_CONST_ATTR(averaging_ratio_available, _string)
> +
> +/**
>   * IIO_DEV_ATTR_SAMP_FREQ - sets any internal clock frequency
>   * @_mode: sysfs file mode/permissions
>   * @_show: output method for the attribute

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1271235

FromMarc Titinger <mtitinger@baylibre.com>
Date2015-11-17 15:10 +0100
Message-ID<qvP7j-64d-19@gated-at.bofh.it>
In reply to#1271215
On 17/11/2015 14:39, jic23@jic23.retrosnub.co.uk wrote:
> On 17.11.2015 10:44, Marc Titinger wrote:
>> Some ADC devices allow averaging/downsampling. The minimal parameter
>> set for this will be the number of taps used for computing a mean value.
>>
>> In some cases the ratio will hold discrete values for instance "1, 4, 16"
>> hence an averaging_ratio_available property is useful. The possible ratio
>> values are less likely to changing with the device settings, so this
>> patch
>> only provides a CONST version of the definition helper.
>>
>> Tested with ina226:
>>
>> # ls /sys/bus/iio/devices/iio\:device0/
>> averaging_ratio_available     in_voltage0_raw
>> dev                           in_voltage1_raw
>> in_averaging_ratio            name
>> in_calibscale                 power
>> in_current2_raw               sampling_frequency_available
>> in_power3_raw                 subsystem
>> in_sampling_frequency         uevent
>>
>> # cat averaging_ratio_available
>> 1, 4, 16, 64, 128, 256, 512, 1024
>>
>> Signed-off-by: Marc Titinger <mtitinger@baylibre.com>
> Having just noted the previous element we added was oversampling_ratio,
> in a sense they are somewhat similar.
>
> To play Devil's advocate...
> Could we in theory just use that as it is existing ABI?
>
> oversampling_ratio was introduced for the bmc150.
> That particular part doesn't have the worlds clearest datasheet
> but it seems like it's effectively specifying how many repeat measurements
> to average.
>
> I'm afraid I'd completely forgotten about this or
> I would have mentioned it earlier!

I saw that oversampling setting, but I my memories, oversampling was 
sometimes related to increasing the samplerate, i.e creating more 
samples possibly through interpolation, in order to allow for filtering.

If there is a consensus about this being ok to mean 'averaging' I'm 
happy to use this ABI!

M.


>
> Jonathan
>
>> ---
>>  Documentation/ABI/testing/sysfs-bus-iio | 13 +++++++++++++
>>  drivers/iio/industrialio-core.c         |  1 +
>>  include/linux/iio/iio.h                 |  1 +
>>  include/linux/iio/sysfs.h               |  9 +++++++++
>>  4 files changed, 24 insertions(+)
>>
>> diff --git a/Documentation/ABI/testing/sysfs-bus-iio
>> b/Documentation/ABI/testing/sysfs-bus-iio
>> index 42d360f..a208dfe 100644
>> --- a/Documentation/ABI/testing/sysfs-bus-iio
>> +++ b/Documentation/ABI/testing/sysfs-bus-iio
>> @@ -56,6 +56,19 @@ Description:
>>          When the internal sampling clock can only take a small
>>          discrete set of values, this file lists those available.
>>
>> +What:        /sys/bus/iio/devices/iio:deviceX/averaging_ratio
>> +KernelVersion:    4.x.x
>> +Contact:    linux-iio@vger.kernel.org
>> +Description:
>> +        Hardware dependent ADC averaging. Controls the averaging ratio
>> +        of the digital filter if available.
>> +
>> +What:        /sys/bus/iio/devices/iio:deviceX/averaging_ratio_available
>> +KernelVersion:    4.x.x
>> +Contact:    linux-iio@vger.kernel.org
>> +Description:
>> +        Hardware dependent values supported by the averaging filter.
>> +
>>  What:        /sys/bus/iio/devices/iio:deviceX/oversampling_ratio
>>  KernelVersion:    2.6.38
>>  Contact:    linux-iio@vger.kernel.org
>> diff --git a/drivers/iio/industrialio-core.c
>> b/drivers/iio/industrialio-core.c
>> index b3fcc2c..e4745f0 100644
>> --- a/drivers/iio/industrialio-core.c
>> +++ b/drivers/iio/industrialio-core.c
>> @@ -142,6 +142,7 @@ static const char * const iio_chan_info_postfix[] = {
>>      [IIO_CHAN_INFO_DEBOUNCE_TIME] = "debounce_time",
>>      [IIO_CHAN_INFO_CALIBEMISSIVITY] = "calibemissivity",
>>      [IIO_CHAN_INFO_OVERSAMPLING_RATIO] = "oversampling_ratio",
>> +    [IIO_CHAN_INFO_AVERAGING_RATIO] = "averaging_ratio",
>>  };
>>
>>  /**
>> diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
>> index 7bb7f67..4c84de5 100644
>> --- a/include/linux/iio/iio.h
>> +++ b/include/linux/iio/iio.h
>> @@ -46,6 +46,7 @@ enum iio_chan_info_enum {
>>      IIO_CHAN_INFO_DEBOUNCE_TIME,
>>      IIO_CHAN_INFO_CALIBEMISSIVITY,
>>      IIO_CHAN_INFO_OVERSAMPLING_RATIO,
>> +    IIO_CHAN_INFO_AVERAGING_RATIO,
>>  };
>>
>>  enum iio_shared_by {
>> diff --git a/include/linux/iio/sysfs.h b/include/linux/iio/sysfs.h
>> index 9cd8f74..4478ba1 100644
>> --- a/include/linux/iio/sysfs.h
>> +++ b/include/linux/iio/sysfs.h
>> @@ -76,6 +76,15 @@ struct iio_const_attr {
>>  /* Generic attributes of onetype or another */
>>
>>  /**
>> + * IIO_CONST_ATTR_AVERAGING_RATIO_AVAIL - list available averaging
>> ratios
>> + * @_string: ratio string for the attribute
>> + *
>> + * Constant version
>> + **/
>> +#define IIO_CONST_ATTR_AVERAGING_RATIO_AVAIL(_string) \
>> +    IIO_CONST_ATTR(averaging_ratio_available, _string)
>> +
>> +/**
>>   * IIO_DEV_ATTR_SAMP_FREQ - sets any internal clock frequency
>>   * @_mode: sysfs file mode/permissions
>>   * @_show: output method for the attribute
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web