Skip to contentSkip to conversation

Re-add filter_type/filter_mode

PATCH Superseded Marcelo Schmitt 3 participants 10 messages Feb 3, 2025 – Feb 4, 2025

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Marcelo Schmitt

author maintainer
#0 lore raw

v3 cover Re-add filter_type/filter_mode

Better document sysfs ABI for ADC digital filter configuration. Also update ad4130 driver to support the standardized IIO ABI for digital filter configuration.

Change log v2 -> v3
- Added in_voltageY-voltageZ_filter_type to main IIO ADI doc too.
- Added filter_type attributes to ad4130 driver so it also supports the standardized ABI for digital filter configuration.
- No longer dropping AD4130 specific filter_type_available options from sysfs-bus-iio.
- Re-add sysfs-bus-iio-adc-ad4130 just mentioning the ABI at sysfs-bus-iio instead of repeating the doc.

Change log v1 -> v2
- Split into 3 patches.
- Re-added sysfs-bus-iio-adc-ad4130 to keep filter_mode separate from filter_type.
- Removed in_voltage-voltage_filter_mode_available from sysfs-bus-iio.
- Added deprecation notes in sysfs-bus-iio-adc-ad4130 asking to use filter_type for new drivers and referencing sysfs-bus-iio.
- Improved commit message with explanation about use of filter type attributes.
- Dropped AD4130 specific filter_type_available options from sysfs-bus-iio.

Link to v2: https://lore.kernel.org/linux-iio/[email protected]/
Link to v1: https://lore.kernel.org/linux-iio/b2132bd3ca1d64cdd8d5afab1f1f33c574718b50.1732901318.git.marcelo.schmitt@analog.com/

Marcelo Schmitt (3):
Documentation: ABI: IIO: Add filter_type documentation
iio: adc: ad4130: Add filter_type attributes
Documentation: ABI: IIO: Re-add sysfs-bus-iio-adc-ad4130

 Documentation/ABI/testing/sysfs-bus-iio       |  9 ++++++++-
 .../ABI/testing/sysfs-bus-iio-adc-ad4130      | 20 +++++++++++++++++++
 MAINTAINERS                                   |  1 +
 drivers/iio/adc/ad4130.c                      |  3 +++
 4 files changed, 32 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-adc-ad4130

base-commit: 9b75dd1b7d6b98699a104c6b1eec0c8817e5fd4b

Signature · 1 line
2.47.2
author maintainer
#1 lore raw

PATCH v3 1/3 Documentation: ABI: IIO: Add filter_type documentation

A previous patch added documentation for filter_type_available attributes. However, the description for the value attribute (filter_type) was missing. Add documentation for filter_type sysfs ABI.

Fixes 01bb12922b60 ("Documentation: ABI: added filter mode doc in sysfs-bus-iio")
---
 Documentation/ABI/testing/sysfs-bus-iio | 8 ++++++++
 1 file changed, 8 insertions(+)
Documentation/ABI/testing/sysfs-bus-iio +8 -0
index d97c35057a03..ff9cc09360dc 100644
@@ -2300,6 +2300,14 @@ Description:
 		* "sinc3+pf3" - Sinc3 + device specific Post Filter 3.
 		* "sinc3+pf4" - Sinc3 + device specific Post Filter 4.
 
+What:		/sys/bus/iio/devices/iio:deviceX/filter_type
+What:		/sys/bus/iio/devices/iio:deviceX/in_voltageY-voltageZ_filter_type
+KernelVersion:	6.1
+Contact:	[email protected]
+Description:
+		Specifies which filter type apply to the channel. The possible
+		values are given by the filter_type_available attribute.
+
 What:		/sys/.../events/in_proximity_thresh_either_runningperiod
 KernelVersion:	6.6
 Contact:	[email protected]
Signature · 1 line
2.47.2
reviewer Reviewed-by on v3 1/3
#2 lore raw

Re: [PATCH v3 1/3] Documentation: ABI: IIO: Add filter_type documentation

Quoted 7 lines · Marcelo Schmitt

A previous patch added documentation for filter_type_available attributes. However, the description for the value attribute (filter_type) was missing. Add documentation for filter_type sysfs ABI.

Fixes 01bb12922b60 ("Documentation: ABI: added filter mode doc in sysfs-bus-iio")

---

author maintainer
#3 lore raw

PATCH v3 2/3 iio: adc: ad4130: Add filter_type attributes

In reply to Marcelo Schmitt

Make filter control also available through filter_type attributes which are now standardized in main IIO ABI documentation.

---
Hi David, I forgot to ask if you wanted it, but I've added a suggested-by tag for your advice on v2.

Thanks,
Marcelo

 drivers/iio/adc/ad4130.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/iio/adc/ad4130.c +3 -0
index de32cc9d18c5..66097ff65740 100644
@@ -942,6 +942,9 @@ static const struct iio_chan_spec_ext_info ad4130_filter_mode_ext_info[] = {
 	IIO_ENUM("filter_mode", IIO_SEPARATE, &ad4130_filter_mode_enum),
 	IIO_ENUM_AVAILABLE("filter_mode", IIO_SHARED_BY_TYPE,
 			   &ad4130_filter_mode_enum),
+	IIO_ENUM("filter_type", IIO_SEPARATE, &ad4130_filter_mode_enum),
+	IIO_ENUM_AVAILABLE("filter_type", IIO_SHARED_BY_TYPE,
+			   &ad4130_filter_mode_enum),
 	{ }
 };
 
Signature · 1 line
2.47.2
reviewer Reviewed-by on v3 2/3
#4 lore raw

Re: [PATCH v3 2/3] iio: adc: ad4130: Add filter_type attributes

Quoted 8 lines · Marcelo Schmitt

Make filter control also available through filter_type attributes which are now standardized in main IIO ABI documentation.

---
Hi David, I forgot to ask if you wanted it, but I've added a suggested-by tag for your advice on v2.

OK with me. :-)

drivers/iio/adc/ad4130.c static const struct iio_chan_spec_ext_info ad4130_filter_mode_ext_info[] = {

Quoted 12 lines

Thanks,
Marcelo

 drivers/iio/adc/ad4130.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/iio/adc/ad4130.c +0 -0
index de32cc9d18c5..66097ff65740 100644
@@ -942,6 +942,9 @@ static const struct iio_chan_spec_ext_info ad4130_filter_mode_ext_info[] = {

I suggest to add a comment here to say that the duplication is intentional and the filter_mode attributes are for backwards compatibility.

drivers/iio/adc/ad4130.c static const struct iio_chan_spec_ext_info ad4130_filter_mode_ext_info[] = { · line 950

Quoted 9 lines
drivers/iio/adc/ad4130.c +3 -0
 	IIO_ENUM("filter_mode", IIO_SEPARATE, &ad4130_filter_mode_enum),
 	IIO_ENUM_AVAILABLE("filter_mode", IIO_SHARED_BY_TYPE,
 			   &ad4130_filter_mode_enum),
+	IIO_ENUM("filter_type", IIO_SEPARATE, &ad4130_filter_mode_enum),
+	IIO_ENUM_AVAILABLE("filter_type", IIO_SHARED_BY_TYPE,
+			   &ad4130_filter_mode_enum),
 	{ }
 };
 

With that...

#5 lore raw

Re: [PATCH v3 2/3] iio: adc: ad4130: Add filter_type attributes

Quoted 19 lines · David Lechner
Quoted 8 lines · Marcelo Schmitt

Make filter control also available through filter_type attributes which are now standardized in main IIO ABI documentation.

---
Hi David, I forgot to ask if you wanted it, but I've added a suggested-by tag for your advice on v2.

OK with me. :-)

Quoted 7 lines

Thanks,
Marcelo

 drivers/iio/adc/ad4130.c | 3 +++
 1 file changed, 3 insertions(+)
Quoted 9 lines

drivers/iio/adc/ad4130.c static const struct iio_chan_spec_ext_info ad4130_filter_mode_ext_info[] = {

Quoted 5 lines
drivers/iio/adc/ad4130.c +0 -0
index de32cc9d18c5..66097ff65740 100644
@@ -942,6 +942,9 @@ static const struct iio_chan_spec_ext_info ad4130_filter_mode_ext_info[] = {

I suggest to add a comment here to say that the duplication is intentional and the filter_mode attributes are for backwards compatibility.

Okay, will do.

Quoted 13 lines

drivers/iio/adc/ad4130.c static const struct iio_chan_spec_ext_info ad4130_filter_mode_ext_info[] = { · line 950

Quoted 9 lines
drivers/iio/adc/ad4130.c +3 -0
 	IIO_ENUM("filter_mode", IIO_SEPARATE, &ad4130_filter_mode_enum),
 	IIO_ENUM_AVAILABLE("filter_mode", IIO_SHARED_BY_TYPE,
 			   &ad4130_filter_mode_enum),
+	IIO_ENUM("filter_type", IIO_SEPARATE, &ad4130_filter_mode_enum),
+	IIO_ENUM_AVAILABLE("filter_type", IIO_SHARED_BY_TYPE,
+			   &ad4130_filter_mode_enum),
 	{ }
 };
 

With that...

author maintainer
#6 lore raw

PATCH v3 3/3 Documentation: ABI: IIO: Re-add sysfs-bus-iio-adc-ad4130

In reply to Marcelo Schmitt

The ad4130 driver exports in_voltageY-voltageZ_filter_mode and in_voltage-voltage_filter_mode_available attributes to user space. A previous patch merged the documentation for those attributes with the documentation for filter_type/filter_type_available into sysfs-bus-iio. Filter mode and filter type refer to the same feature which is the digital filter applied over ADC samples. However, since datasheets use the term filter type and ad4130 driver is the only one using filter_mode, deprecate the filter_mode ABI in favor of filter_type and keep the docs separate to avoid confusion and intricate attribute descriptions.

The digital filter helps shape the noise rejection bandwidth and is supposed to be adjusted according to the signal of interest. Depending on the particular ADC design, the digital filter configuration may have an impact on the output data rate (ODR) (which is equivalent to the sampling frequency for SAR ADCs - sampling_frequency ABI), 3dB cutoff frequency of the filter (_low_pass_3db_frequency attributes), or settling time.

Digital filters are a common feature among sigma-delta ADCs and IIO drivers set digital filters according to different attributes. ad4130 and ad7779 filter options are supported through dedicated filter_mode/filter_type attributes in sysfs.
ad7768-1 and ad7173 set the sinc filters according to the sampling_frequency attribute. No filter_type attribute.
ad7124 sets the digital filter according to a filter_low_pass_3db_frequency attribute so it doesn't export filter type attributes to user space.

Fixes 01bb12922b60 ("Documentation: ABI: added filter mode doc in sysfs-bus-iio")
---
 Documentation/ABI/testing/sysfs-bus-iio       |  1 -
 .../ABI/testing/sysfs-bus-iio-adc-ad4130      | 20 +++++++++++++++++++
 MAINTAINERS                                   |  1 +
 3 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-adc-ad4130
Documentation/ABI/testing/sysfs-bus-iio +0 -1
index ff9cc09360dc..e4fd99c92d81 100644
@@ -2277,7 +2277,6 @@ Description:
 		representing the sensor unique ID number.
 
 What:		/sys/bus/iio/devices/iio:deviceX/filter_type_available
-What:		/sys/bus/iio/devices/iio:deviceX/in_voltage-voltage_filter_mode_available
 KernelVersion:	6.1
 Contact:	[email protected]
 Description:
Documentation/ABI/testing/sysfs-bus-iio-adc-ad4130 new file +20 -0
new file mode 100644
index 000000000000..9c0698ad27f9
@@ -0,0 +1,20 @@
+What:		/sys/bus/iio/devices/iio:deviceX/in_voltage-voltage_filter_mode_available
+KernelVersion:  6.2
+Contact:	[email protected]
+Description:
+		Reading returns a list with the possible filter modes.
+
+		This ABI is only kept for backwards compatibility and the values
+		returned are identical to filter_type_available attribute
+		documented in Documentation/ABI/testing/sysfs-bus-iio. Please,
+		use filter_type_available to provide filter options for new
+		drivers.
+
+What:		/sys/bus/iio/devices/iio:deviceX/in_voltageY-voltageZ_filter_mode
+KernelVersion:  6.2
+Contact:	[email protected]
+Description:
+		This ABI is only kept for backwards compatibility and the values
+		returned are identical to in_voltageY-voltageZ_filter_type
+		attribute documented in Documentation/ABI/testing/sysfs-bus-iio.
+		Please, use in_voltageY-voltageZ_filter_type for new drivers.
MAINTAINERS +1 -0
index 98a3c1e46311..28dbbf6d6efa 100644
@@ -1279,6 +1279,7 @@ M:	Cosmin Tanislav <[email protected]>
 L:	[email protected]
 S:	Supported
 W:	https://ez.analog.com/linux-software-drivers
+F:	Documentation/ABI/testing/sysfs-bus-iio-adc-ad4130
 F:	Documentation/devicetree/bindings/iio/adc/adi,ad4130.yaml
 F:	drivers/iio/adc/ad4130.c
 
Signature · 1 line
2.47.2
reviewer Reviewed-by on v3 3/3
#7 lore raw

Re: [PATCH v3 3/3] Documentation: ABI: IIO: Re-add sysfs-bus-iio-adc-ad4130

Quoted 19 lines · Marcelo Schmitt

The ad4130 driver exports in_voltageY-voltageZ_filter_mode and in_voltage-voltage_filter_mode_available attributes to user space. A previous patch merged the documentation for those attributes with the documentation for filter_type/filter_type_available into sysfs-bus-iio. Filter mode and filter type refer to the same feature which is the digital filter applied over ADC samples. However, since datasheets use the term filter type and ad4130 driver is the only one using filter_mode, deprecate the filter_mode ABI in favor of filter_type and keep the docs separate to avoid confusion and intricate attribute descriptions.

The digital filter helps shape the noise rejection bandwidth and is supposed to be adjusted according to the signal of interest. Depending on the particular ADC design, the digital filter configuration may have an impact on the output data rate (ODR) (which is equivalent to the sampling frequency for SAR ADCs - sampling_frequency ABI), 3dB cutoff frequency of the filter (_low_pass_3db_frequency attributes), or settling time.

Quoted 8 lines

Digital filters are a common feature among sigma-delta ADCs and IIO drivers set digital filters according to different attributes. ad4130 and ad7779 filter options are supported through dedicated filter_mode/filter_type attributes in sysfs.
ad7768-1 and ad7173 set the sinc filters according to the sampling_frequency attribute. No filter_type attribute.
ad7124 sets the digital filter according to a filter_low_pass_3db_frequency attribute so it doesn't export filter type attributes to user space.

These last two paragraphs seems a bit excessive and could be dropped.

Quoted 15 lines
Fixes 01bb12922b60 ("Documentation: ABI: added filter mode doc in sysfs-bus-iio")
---
 Documentation/ABI/testing/sysfs-bus-iio       |  1 -
 .../ABI/testing/sysfs-bus-iio-adc-ad4130      | 20 +++++++++++++++++++
 MAINTAINERS                                   |  1 +
 3 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-adc-ad4130
Documentation/ABI/testing/sysfs-bus-iio +0 -0
index ff9cc09360dc..e4fd99c92d81 100644

Documentation/ABI/testing/sysfs-bus-iio Description: · line 2280

Quoted 4 lines
Documentation/ABI/testing/sysfs-bus-iio +0 -1
@@ -2277,7 +2277,6 @@ Description:
 		representing the sensor unique ID number.
 
 What:		/sys/bus/iio/devices/iio:deviceX/filter_type_available
-What:		/sys/bus/iio/devices/iio:deviceX/in_voltage-voltage_filter_mode_available

Instead of removing the line, I think we need to replace it with:

/sys/bus/iio/devices/iio:deviceX/in_voltage-voltage_filter_type_available

(change mode to type)

This attribute is used in the previous patch.

Documentation/ABI/testing/sysfs-bus-iio Description: · line 2282

Quoted 3 lines
Documentation/ABI/testing/sysfs-bus-iio +0 -0
 KernelVersion:	6.1
 Contact:	[email protected]
 Description:

With those changes...

#8 lore raw

Re: [PATCH v3 3/3] Documentation: ABI: IIO: Re-add sysfs-bus-iio-adc-ad4130

Quoted 29 lines · David Lechner
Quoted 19 lines · Marcelo Schmitt

The ad4130 driver exports in_voltageY-voltageZ_filter_mode and in_voltage-voltage_filter_mode_available attributes to user space. A previous patch merged the documentation for those attributes with the documentation for filter_type/filter_type_available into sysfs-bus-iio. Filter mode and filter type refer to the same feature which is the digital filter applied over ADC samples. However, since datasheets use the term filter type and ad4130 driver is the only one using filter_mode, deprecate the filter_mode ABI in favor of filter_type and keep the docs separate to avoid confusion and intricate attribute descriptions.

The digital filter helps shape the noise rejection bandwidth and is supposed to be adjusted according to the signal of interest. Depending on the particular ADC design, the digital filter configuration may have an impact on the output data rate (ODR) (which is equivalent to the sampling frequency for SAR ADCs - sampling_frequency ABI), 3dB cutoff frequency of the filter (_low_pass_3db_frequency attributes), or settling time.

Quoted 8 lines

Digital filters are a common feature among sigma-delta ADCs and IIO drivers set digital filters according to different attributes. ad4130 and ad7779 filter options are supported through dedicated filter_mode/filter_type attributes in sysfs.
ad7768-1 and ad7173 set the sinc filters according to the sampling_frequency attribute. No filter_type attribute.
ad7124 sets the digital filter according to a filter_low_pass_3db_frequency attribute so it doesn't export filter type attributes to user space.

Quoted 1 line

These last two paragraphs seems a bit excessive and could be dropped.

Yes, the patch is justified without those paragraphs.
I wanted to understand how digital filtering works and how it was supported across IIO ADC drivers to implement something reasonable for AD4170. Those are my conclusions after looking at few ADC drivers.
I thought those could be useful but didn't have a good place to write to. Oh well, that is not covering all ADCs so also a bit far-fetched to propose it as some doc. Will drop the extra text on v4.

Quoted 36 lines
Quoted 16 lines
Fixes 01bb12922b60 ("Documentation: ABI: added filter mode doc in sysfs-bus-iio")
---
 Documentation/ABI/testing/sysfs-bus-iio       |  1 -
 .../ABI/testing/sysfs-bus-iio-adc-ad4130      | 20 +++++++++++++++++++
 MAINTAINERS                                   |  1 +
 3 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-adc-ad4130
Documentation/ABI/testing/sysfs-bus-iio +0 -0
index ff9cc09360dc..e4fd99c92d81 100644

Documentation/ABI/testing/sysfs-bus-iio Description: · line 2280

Quoted 4 lines
Documentation/ABI/testing/sysfs-bus-iio +0 -1
@@ -2277,7 +2277,6 @@ Description:
 		representing the sensor unique ID number.
 
 What:		/sys/bus/iio/devices/iio:deviceX/filter_type_available
-What:		/sys/bus/iio/devices/iio:deviceX/in_voltage-voltage_filter_mode_available

Instead of removing the line, I think we need to replace it with:

/sys/bus/iio/devices/iio:deviceX/in_voltage-voltage_filter_type_available

(change mode to type)

This attribute is used in the previous patch.

Documentation/ABI/testing/sysfs-bus-iio Description: · line 2282

Quoted 3 lines
Documentation/ABI/testing/sysfs-bus-iio +0 -0
 KernelVersion:	6.1
 Contact:	[email protected]
 Description:

With those changes...

#9 lore raw

Re: [PATCH v3 3/3] Documentation: ABI: IIO: Re-add sysfs-bus-iio-adc-ad4130

In reply to David Lechner
Quoted 53 lines · David Lechner
Quoted 19 lines · Marcelo Schmitt

The ad4130 driver exports in_voltageY-voltageZ_filter_mode and in_voltage-voltage_filter_mode_available attributes to user space. A previous patch merged the documentation for those attributes with the documentation for filter_type/filter_type_available into sysfs-bus-iio. Filter mode and filter type refer to the same feature which is the digital filter applied over ADC samples. However, since datasheets use the term filter type and ad4130 driver is the only one using filter_mode, deprecate the filter_mode ABI in favor of filter_type and keep the docs separate to avoid confusion and intricate attribute descriptions.

The digital filter helps shape the noise rejection bandwidth and is supposed to be adjusted according to the signal of interest. Depending on the particular ADC design, the digital filter configuration may have an impact on the output data rate (ODR) (which is equivalent to the sampling frequency for SAR ADCs - sampling_frequency ABI), 3dB cutoff frequency of the filter (_low_pass_3db_frequency attributes), or settling time.

Quoted 8 lines

Digital filters are a common feature among sigma-delta ADCs and IIO drivers set digital filters according to different attributes. ad4130 and ad7779 filter options are supported through dedicated filter_mode/filter_type attributes in sysfs.
ad7768-1 and ad7173 set the sinc filters according to the sampling_frequency attribute. No filter_type attribute.
ad7124 sets the digital filter according to a filter_low_pass_3db_frequency attribute so it doesn't export filter type attributes to user space.

These last two paragraphs seems a bit excessive and could be dropped.

Quoted 15 lines
Fixes 01bb12922b60 ("Documentation: ABI: added filter mode doc in sysfs-bus-iio")
---
 Documentation/ABI/testing/sysfs-bus-iio       |  1 -
 .../ABI/testing/sysfs-bus-iio-adc-ad4130      | 20 +++++++++++++++++++
 MAINTAINERS                                   |  1 +
 3 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-adc-ad4130
Documentation/ABI/testing/sysfs-bus-iio +0 -0
index ff9cc09360dc..e4fd99c92d81 100644

Documentation/ABI/testing/sysfs-bus-iio Description: · line 2280

Quoted 4 lines
Documentation/ABI/testing/sysfs-bus-iio +0 -1
@@ -2277,7 +2277,6 @@ Description:
 		representing the sensor unique ID number.
 
 What:		/sys/bus/iio/devices/iio:deviceX/filter_type_available
-What:		/sys/bus/iio/devices/iio:deviceX/in_voltage-voltage_filter_mode_available

Instead of removing the line, I think we need to replace it with:

Quoted 5 lines

/sys/bus/iio/devices/iio:deviceX/in_voltage-voltage_filter_type_available

(change mode to type)

This attribute is used in the previous patch.

Ah yes, good catch.
Will do. And will also reorder the patches so it gets documented before being used.

Thanks,
Marcelo

Quoted 8 lines

Documentation/ABI/testing/sysfs-bus-iio Description: · line 2282

Quoted 5 lines
Documentation/ABI/testing/sysfs-bus-iio +0 -0
 KernelVersion:	6.1
 Contact:	[email protected]
 Description:

With those changes...