Re: [PATCH v8 10/11] iio: adc: ad7768-1: add filter type and oversampling ratio attributes
From: Jonathan Santos
Date: Mon May 19 2025 - 13:13:46 EST
On 05/15, Jonathan Santos wrote:
> Separate filter type and decimation rate from the sampling frequency
> attribute. The new filter type attribute enables sinc3, sinc3+rej60
> and wideband filters, which were previously unavailable.
>
> Previously, combining decimation and MCLK divider in the sampling
> frequency obscured performance trade-offs. Lower MCLK divider
> settings increase power usage, while lower decimation rates reduce
> precision by decreasing averaging. By creating an oversampling
> attribute, which controls the decimation, users gain finer control
> over performance.
>
> The addition of those attributes allows a wider range of sampling
> frequencies and more access to the device features. Sampling frequency
> table is updated after every digital filter parameter change.
>
> Changes in the sampling frequency are not allowed anymore while in
> buffered mode.
>
> Reviewed-by: David Lechner <dlechner@xxxxxxxxxxxx>
> Co-developed-by: Pop Paul <paul.pop@xxxxxxxxxx>
> Signed-off-by: Pop Paul <paul.pop@xxxxxxxxxx>
> Signed-off-by: Jonathan Santos <Jonathan.Santos@xxxxxxxxxx>
...
> +
> +/* Decimation Rate range for each filter type */
> +static const int ad7768_dec_rate_range[][3] = {
> + [AD7768_FILTER_SINC5] = { 8, 8, 1024 },
> + [AD7768_FILTER_SINC3] = { 32, 32, 163840 },
> + [AD7768_FILTER_WIDEBAND] = { 32, 32, 1024 },
> + [AD7768_FILTER_SINC3_REJ60] = { 32, 32, 163840 },
> +};
> +
Since we're still discussing some points — is the `step` in
`[min step max]` for the IIO range additive or multiplicative? It is not
clear on documentation, maybe on purpose or I have missed something.
Here, decimation/OSR doubles from 8 or 32 for SINC5/WIDEBAND, and is a
multiple of 32 for SINC3. So I'm still unsure how to represent this to be
clear to the user.
> +/*
> + * The AD7768-1 supports three primary filter types:
> + * Sinc5, Sinc3, and Wideband.
> + * However, the filter register values can also encode additional parameters
> + * such as decimation rates and 60Hz rejection. This utility array separates
> + * the filter type from these parameters.
> + */
...
> --
> 2.34.1
>