Re: [PATCH 2/2] iio: imu: st_lsm6dsx: Decouple sensor ODR from FIFO batch data rate
From: Andy Shevchenko
Date: Fri Oct 10 2025 - 10:55:56 EST
On Thu, Oct 9, 2025 at 8:36 PM Francesco Lavra <flavra@xxxxxxxxxxxx> wrote:
>
> The rate at which accelerometer or gyroscope sensor samples are fed
> to the hardware FIFO (batch data rate, or BDR) does not have to
> coincide with the sensor sampling frequency (output data rate, or
> ODR); the only requirement is for the BDR to not be greater than
> the ODR. Having a BDR lower than the ODR is useful in cases where
> an application requires a high sampling rate for accurate detection
> of motion events (e.g. wakeup events), but wants to read sensor
> sample values from the device buffer at a lower data rate.
> To support the above use case, add a sampling_frequency sysfs
> attribute to the buffer directory of st_lsm6dsx IIO devices, which
> controls the BDR for a given sensor independently from the "main"
> sampling_frequency attribute (which controls the ODR); introduce a
> new `bdr` field in struct st_lsm6dsx_sensor to keep track of the
> current BDR value, and use this field instead of the `odr` field in
> the code that deals with the FIFO data rate. In the sensor hub
> driver, make the bdr value always mirror the odr value, since there
> is no separate configuration setting to control the BDR for data
> produced by the sensor hub functionality.
...
> - *max_odr = max_t(u32, *max_odr, sensor->odr);
> - *min_odr = min_t(u32, *min_odr, sensor->odr);
> + *max_odr = max_t(u32, *max_odr, sensor->bdr);
> + *min_odr = min_t(u32, *min_odr, sensor->bdr);
Can we get rid of '_t' parts at some point? Or IOW what is the good
justification for typed macros here?
...
> + ret = iio_str_to_fixpoint(buf, 100, &integer, &fract);
> + if (ret)
> + return ret;
> + bdr = integer * 1000 + fract;
MILLI?
--
With Best Regards,
Andy Shevchenko