Re: [PATCH v2 3/3] iio: imu: st_lsm6dsx: Add support for rotation sensor
From: Andy Shevchenko
Date: Thu Jan 15 2026 - 08:49:17 EST
On Thu, Jan 15, 2026 at 02:32:11PM +0100, Lorenzo Bianconi wrote:
> > Some IMU chips in the LSM6DSX family have sensor fusion features that
> > combine data from the accelerometer and gyroscope. One of these features
> > generates rotation vector data and makes it available in the hardware
> > FIFO as a quaternion (more specifically, the X, Y and Z components of the
> > quaternion vector, expressed as 16-bit half-precision floating-point
> > numbers).
> >
> > Add support for a new sensor instance that allows receiving sensor fusion
> > data, by defining a new struct st_lsm6dsx_sf_settings (which contains
> > chip-specific details for the sensor fusion functionality), and adding this
> > struct as a new field in struct st_lsm6dsx_settings. In st_lsm6dsx_core.c,
> > populate this new struct for the LSM6DSV and LSM6DSV16X chips, and add the
> > logic to initialize an additional IIO device if this struct is populated
> > for the hardware type being probed.
> > Note: a new IIO device is being defined (as opposed to adding channels to
> > an existing device) because the rate at which sensor fusion data is
> > generated may not match the data rate from any of the existing devices.
> >
> > Tested on LSMDSV16X.
...
> > + settings = &sensor->hw->settings->sf_settings;
> > + switch (mask) {
> > + case IIO_CHAN_INFO_SAMP_FREQ: {
> > + u32 odr_mHz;
> > + u8 odr_val;
> > +
> > + odr_mHz = val * MILLI + val2 * MILLI / MICRO;
> > + err = st_lsm6dsx_sf_get_odr_val(settings, odr_mHz, &odr_val);
> > + if (err)
> > + return err;
> > +
> > + sensor->hwfifo_odr_mHz = odr_mHz;
> > + return 0;
>
> break;
>
> > + }
> > + default:
> > + return -EINVAL;
>
> break;
>
> > + }
>
> return err;
Why?
--
With Best Regards,
Andy Shevchenko