On Tue, 23 Apr 2024 11:42:07 +0300 Ramona Gradinariu <ramona.bolboaca13@xxxxxxxxx> wrote: > Add support for delta angle and delta velocity raw readings to > adis16480 driver. Why are these not allowed via the buffer interface? Normally my expectation of delta values is they are more or less useless without buffered capture. The intent of providing those channels is that they are gathered over time and summed up to give the angle difference (for example) between start of capture and now. Note the formula on the datasheet https://www.analog.com/media/en/technical-documentation/data-sheets/adis16545-16547.pdf looks wrong (formula 3) as it's adding the signals at time nD + d and at nD + D - 1 whereas for a delta you'd subtract those (maybe I'm reading that wrong). If we are providing these values as raw readings I'd expect them to be presented as delta_angle / time (e.g. rate of change of angle) and delta_velocity / time = acceleration (be it slightly distorted vs the acceleration measured as a result of oversampling.). So basically spot measurements of delta values are normally pretty useless. My guess is that you did this because the device either seems to allow burst reads of the main channels or of these delta values? If so consider using available_scan_masks to allow one or the other set of channels rather than not allowing capture of these via the buffered interfaces. Jonathan > > Signed-off-by: Ramona Gradinariu <ramona.gradinariu@xxxxxxxxxx> > --- > drivers/iio/imu/adis16480.c | 78 ++++++++++++++++++++++++++++++++++++- > 1 file changed, 76 insertions(+), 2 deletions(-) > > diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c > index bc6cbd00cd4b..4adc2244a4ef 100644 > --- a/drivers/iio/imu/adis16480.c > +++ b/drivers/iio/imu/adis16480.c > @@ -140,6 +140,8 @@ struct adis16480_chip_info { > unsigned int accel_max_val; > unsigned int accel_max_scale; > unsigned int temp_scale; > + unsigned int deltang_max_val; > + unsigned int deltvel_max_val; > unsigned int int_clk; > unsigned int max_dec_rate; > const unsigned int *filter_freqs; > @@ -445,6 +447,12 @@ enum { > ADIS16480_SCAN_MAGN_Z, > ADIS16480_SCAN_BARO, > ADIS16480_SCAN_TEMP, > + ADIS16480_SCAN_DELTANG_X, > + ADIS16480_SCAN_DELTANG_Y, > + ADIS16480_SCAN_DELTANG_Z, > + ADIS16480_SCAN_DELTVEL_X, > + ADIS16480_SCAN_DELTVEL_Y, > + ADIS16480_SCAN_DELTVEL_Z, > }; > > static const unsigned int adis16480_calibbias_regs[] = { > @@ -688,6 +696,14 @@ static int adis16480_read_raw(struct iio_dev *indio_dev, > *val = 131; /* 1310mbar = 131 kPa */ > *val2 = 32767 << 16; > return IIO_VAL_FRACTIONAL; > + case IIO_DELTA_ANGL: > + *val = st->chip_info->deltang_max_val; > + *val2 = 31; > + return IIO_VAL_FRACTIONAL_LOG2; > + case IIO_DELTA_VELOCITY: > + *val = st->chip_info->deltvel_max_val; > + *val2 = 31; > + return IIO_VAL_FRACTIONAL_LOG2; > default: > return -EINVAL; > } > @@ -761,6 +777,30 @@ static int adis16480_write_raw(struct iio_dev *indio_dev, > BIT(IIO_CHAN_INFO_CALIBSCALE), \ > 32) > > +#define ADIS16480_DELTANG_CHANNEL(_mod) \ > + ADIS16480_MOD_CHANNEL(IIO_DELTA_ANGL, IIO_MOD_ ## _mod, \ > + ADIS16480_REG_ ## _mod ## _DELTAANG_OUT, ADIS16480_SCAN_DELTANG_ ## _mod, \ > + 0, \ Trivial but why this line wrap? I'd push 32 onto the line above at least. > + 32) > + > +#define ADIS16480_DELTANG_CHANNEL_NO_SCAN(_mod) \ > + ADIS16480_MOD_CHANNEL(IIO_DELTA_ANGL, IIO_MOD_ ## _mod, \ > + ADIS16480_REG_ ## _mod ## _DELTAANG_OUT, -1, \ > + 0, \ > + 32) > + > +#define ADIS16480_DELTVEL_CHANNEL(_mod) \ > + ADIS16480_MOD_CHANNEL(IIO_DELTA_VELOCITY, IIO_MOD_ ## _mod, \ > + ADIS16480_REG_ ## _mod ## _DELTAVEL_OUT, ADIS16480_SCAN_DELTVEL_ ## _mod, \ > + 0, \ > + 32) > + > +#define ADIS16480_DELTVEL_CHANNEL_NO_SCAN(_mod) \ > + ADIS16480_MOD_CHANNEL(IIO_DELTA_VELOCITY, IIO_MOD_ ## _mod, \ > + ADIS16480_REG_ ## _mod ## _DELTAVEL_OUT, -1, \ > + 0, \ > + 32)