iio: imu: st_lsm6dsx: do not roundup set samplerate
Subsystems (2)
PATCH 1/1 iio: imu: st_lsm6dsx: do not roundup set samplerate
The correct way to set the sampling rate to 12.5 Hz before commit f8710f0357bc ("iio: imu: st_lsm6dsx: express odr in mHZ") was to write 13 Hz to sampling_frequency.
Before this patch writing 13 to samplerate results in sample rate set to 26 Hz.
Now we return EINVAL if the sampling rate is not in table.
--- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +1 -1
@@ -1427,7 +1427,7 @@ int st_lsm6dsx_check_odr(struct st_lsm6dsx_sensor *sensor, u32 odr, u8 *val)* ext devices can run at different odr respect to * accel sensor */ -if (odr_table->odr_avl[i].milli_hz >= odr) +if (odr_table->odr_avl[i].milli_hz == odr)break ; }
Signature · 1 line
2.31.0
Lorenzo Bianconi
maintainerQuoted 8 lines
The correct way to set the sampling rate to 12.5 Hz before commit
f8710f0357bc("iio: imu:st_lsm6dsx: express odr in mHZ") was to write 13 Hz tosampling_frequency.
Before this patch writing 13 to samplerate results in sample rate set to 26 Hz.
Now we return EINVAL if the sampling rate is not in table.Signed-off-by Sean Nyekjaer <[email protected]>
I think this patch is breaking i2c-master support available in st_lsm6dsx, have you tested it?
Quoted 20 lines
--- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +1
-1@@ -1427,7 +1427,7 @@ int st_lsm6dsx_check_odr(struct st_lsm6dsx_sensor *sensor, u32 odr, u8 *val)* ext devices can run at different odr respect to * accel sensor */ -if (odr_table->odr_avl[i].milli_hz >= odr) +if (odr_table->odr_avl[i].milli_hz == odr)break ; }Signature · 1 line
2.31.0
Quoted 11 lines · Lorenzo Bianconi
Quoted 8 lines
The correct way to set the sampling rate to 12.5 Hz before commit
f8710f0357bc("iio: imu:st_lsm6dsx: express odr in mHZ") was to write 13 Hz tosampling_frequency.
Before this patch writing 13 to samplerate results in sample rate set to 26 Hz.
Now we return EINVAL if the sampling rate is not in table.Signed-off-by Sean Nyekjaer <[email protected]>I think this patch is breaking i2c-master support available in
st_lsm6dsx, have you tested it?
I have not tested with i2c-master.
But it's not nice to round up sample rate from user space without any notice.
/Sean
Lorenzo Bianconi
maintainerQuoted 8 lines · Lorenzo Bianconi
Quoted 7 lines
Quoted 7 lines
The correct way to set the sampling rate to 12.5 Hz before commit
f8710f0357bc("iio: imu:st_lsm6dsx: express odr in mHZ") was to write 13 Hz tosampling_frequency.
Before this patch writing 13 to samplerate results in sample rate set to 26 Hz.
Now we return EINVAL if the sampling rate is not in table.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Sean Nyekjaer <[email protected]>I think this patch is breaking i2c-master support available in
st_lsm6dsx, have you tested it?I have not tested with i2c-master.
But it's not nice to round up sample rate from user space without any notice.
the point is accel odr is used as trigger for i2c-slave sampling. Connected i2c slave devices have different sample rates (e.g. LIS2MDL), so we need to select the lower accel odr greather than slave device one.
Regards,
Lorenzo
Quoted 3 lines
/Sean
Quoted 15 lines · Lorenzo Bianconi
Quoted 8 lines · Lorenzo Bianconi
Quoted 7 lines
Quoted 7 lines
The correct way to set the sampling rate to 12.5 Hz before commit
f8710f0357bc("iio: imu:st_lsm6dsx: express odr in mHZ") was to write 13 Hz tosampling_frequency.
Before this patch writing 13 to samplerate results in sample rate set to 26 Hz.
Now we return EINVAL if the sampling rate is not in table.Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Sean Nyekjaer <[email protected]>I think this patch is breaking i2c-master support available in
st_lsm6dsx, have you tested it?I have not tested with i2c-master.
But it's not nice to round up sample rate from user space without any notice.
Quoted 7 lines
the point is accel odr is used as trigger for i2c-slave sampling. Connected i2c slave devices have different sample rates (e.g. LIS2MDL), so we need to select the lower accel odr greather than slave device one.
Regards,
Lorenzo
We could open up for custom sample rates if i2c-slaves are enabled? /Sean
Lorenzo Bianconi
maintainerQuoted 20 lines · Lorenzo Bianconi
Quoted 19 lines
Quoted 8 lines · Lorenzo Bianconi
Quoted 7 lines
Quoted 7 lines
The correct way to set the sampling rate to 12.5 Hz before commit
f8710f0357bc("iio: imu:st_lsm6dsx: express odr in mHZ") was to write 13 Hz tosampling_frequency.
Before this patch writing 13 to samplerate results in sample rate set to 26 Hz.
Now we return EINVAL if the sampling rate is not in table.Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Sean Nyekjaer <[email protected]>I think this patch is breaking i2c-master support available in
st_lsm6dsx, have you tested it?I have not tested with i2c-master.
But it's not nice to round up sample rate from user space without any notice.the point is accel odr is used as trigger for i2c-slave sampling. Connected i2c slave devices have different sample rates (e.g. LIS2MDL), so we need to select the lower accel odr greather than slave device one.
Quoted 5 lines
Quoted 3 lines
Regards,
LorenzoWe could open up for custom sample rates if i2c-slaves are enabled?
can you please explain what you mean?
Quoted 1 line
/Sean
Quoted 20 lines · Lorenzo Bianconi
Quoted 20 lines · Lorenzo Bianconi
Quoted 19 lines
Quoted 8 lines · Lorenzo Bianconi
Quoted 7 lines
Quoted 7 lines
The correct way to set the sampling rate to 12.5 Hz before commit
f8710f0357bc("iio: imu:st_lsm6dsx: express odr in mHZ") was to write 13 Hz tosampling_frequency.
Before this patch writing 13 to samplerate results in sample rate set to 26 Hz.
Now we return EINVAL if the sampling rate is not in table.Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Sean Nyekjaer <[email protected]>I think this patch is breaking i2c-master support available in
st_lsm6dsx, have you tested it?I have not tested with i2c-master.
But it's not nice to round up sample rate from user space without any notice.the point is accel odr is used as trigger for i2c-slave sampling. Connected i2c slave devices have different sample rates (e.g. LIS2MDL), so we need to select the lower accel odr greather than slave device one.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Regards,
LorenzoWe could open up for custom sample rates if i2c-slaves are enabled?
can you please explain what you mean?
If i2c-slaves are enabled, it's allowed to set off table sample rates.(We roundup samplerate like now) If i2c-slaves are disabled, we return -EINVAL if we can't find the chosen samplerate in the samplerate table?
/Sean
Lorenzo Bianconi
maintainerQuoted 25 lines · Lorenzo Bianconi
Quoted 24 lines
Quoted 24 lines · Lorenzo Bianconi
Quoted 22 lines
Quoted 8 lines · Lorenzo Bianconi
Quoted 7 lines
Quoted 7 lines
The correct way to set the sampling rate to 12.5 Hz before commit
f8710f0357bc("iio: imu:st_lsm6dsx: express odr in mHZ") was to write 13 Hz tosampling_frequency.
Before this patch writing 13 to samplerate results in sample rate set to 26 Hz.
Now we return EINVAL if the sampling rate is not in table.Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Sean Nyekjaer <[email protected]>I think this patch is breaking i2c-master support available in
st_lsm6dsx, have you tested it?I have not tested with i2c-master.
But it's not nice to round up sample rate from user space without any notice.the point is accel odr is used as trigger for i2c-slave sampling. Connected i2c slave devices have different sample rates (e.g. LIS2MDL), so we need to select the lower accel odr greather than slave device one.
Regards,
Lorenzo
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
We could open up for custom sample rates if i2c-slaves are enabled?
can you please explain what you mean?
If i2c-slaves are enabled, it's allowed to set off table sample rates.(We roundup samplerate like now) If i2c-slaves are disabled, we return
-EINVALif we can't find the chosen samplerate in the samplerate table?
IMO this is not a big deal because if you set the proper ODR (e.g. 26Hz) with the i2c-master disabled, the sample rate will not be rounded-up. If you set 20Hz, the accel ODR will be set to 26Hz. I think it does not worth to make the code uglier and more complex to maintain.
Regards,
Lorenzo
Quoted 2 lines
/Sean
Quoted 32 lines · Lorenzo Bianconi
Quoted 25 lines · Lorenzo Bianconi
Quoted 24 lines
Quoted 24 lines · Lorenzo Bianconi
Quoted 22 lines
Quoted 8 lines · Lorenzo Bianconi
Quoted 7 lines
Quoted 7 lines
The correct way to set the sampling rate to 12.5 Hz before commit
f8710f0357bc("iio: imu:st_lsm6dsx: express odr in mHZ") was to write 13 Hz tosampling_frequency.
Before this patch writing 13 to samplerate results in sample rate set to 26 Hz.
Now we return EINVAL if the sampling rate is not in table.Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Sean Nyekjaer <[email protected]>I think this patch is breaking i2c-master support available in
st_lsm6dsx, have you tested it?I have not tested with i2c-master.
But it's not nice to round up sample rate from user space without any notice.the point is accel odr is used as trigger for i2c-slave sampling. Connected i2c slave devices have different sample rates (e.g. LIS2MDL), so we need to select the lower accel odr greather than slave device one.
Regards,
LorenzoQuoted 6 lines
Quoted 4 lines
Quoted 1 line
We could open up for custom sample rates if i2c-slaves are enabled?
can you please explain what you mean?
If i2c-slaves are enabled, it's allowed to set off table sample rates.(We roundup samplerate like now) If i2c-slaves are disabled, we return
-EINVALif we can't find the chosen samplerate in the samplerate table?
Quoted 8 lines
IMO this is not a big deal because if you set the proper ODR (e.g. 26Hz) with the i2c-master disabled, the sample rate will not be rounded-up. If you set 20Hz, the accel ODR will be set to 26Hz. I think it does not worth to make the code uglier and more complex to maintain.
Regards,
Lorenzo
Sure, but we had some existing code that was setting the samplerate to 13Hz as that was the way to set 12.5Hz samplerate in the past. Suddenly without any notice 13Hz(of cause the kernel was updated) resulted in a samplerate of 26Hz. :/
/Sean