[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aCcGrKEIdvnPRq-w@smile.fi.intel.com>
Date: Fri, 16 May 2025 12:34:36 +0300
From: Andy Shevchenko <andy@...nel.org>
To: Jonathan Santos <Jonathan.Santos@...log.com>
Cc: linux-iio@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-gpio@...r.kernel.org,
nuno.sa@...log.com, Michael.Hennerich@...log.com,
marcelo.schmitt@...log.com, jic23@...nel.org, robh@...nel.org,
krzk+dt@...nel.org, conor+dt@...nel.org, marcelo.schmitt1@...il.com,
linus.walleij@...aro.org, brgl@...ev.pl, lgirdwood@...il.com,
broonie@...nel.org, jonath4nns@...il.com, dlechner@...libre.com,
Pop Paul <paul.pop@...log.com>
Subject: Re: [PATCH v8 10/11] iio: adc: ad7768-1: add filter type and
oversampling ratio attributes
On Thu, May 15, 2025 at 06:14:21PM -0300, 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.
...
> + /*
> + * Maximum dec_rate is limited by the MCLK_DIV value and by the ODR.
> + * The edge case is for MCLK_DIV = 2, ODR = 50 SPS.
> + * max_dec_rate <= MCLK / (2 * 50)
> + */
> + max_dec_rate = st->mclk_freq / 100;
> + dec_rate = clamp(dec_rate, 32, max_dec_rate);
> + /*
> + * Calculate the equivalent value to sinc3 decimation ratio
> + * to be written on the SINC3_DEC_RATE register:
> + * Value = (DEC_RATE / 32) -1
- 1
(mind the space)
> + */
> + dec_rate = DIV_ROUND_UP(dec_rate, 32) - 1;
...
> {
> struct ad7768_state *st = iio_priv(indio_dev);
>
> - return st->dec_rate == 8 ? AD7768_SCAN_TYPE_HIGH_SPEED :
> + return st->oversampling_ratio == 8 ? AD7768_SCAN_TYPE_HIGH_SPEED :
> AD7768_SCAN_TYPE_NORMAL;
With the proposed change in the previous patches this change will become
clearer to read, i.e. no-one needs to check if the actual value was changed.
> }
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists