From 82bd09ce4fd3b15680735eaeafe2e688901e3b00 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Maneyrol Date: Mon, 20 Jul 2026 12:38:34 +0200 Subject: iio: inv_sensors: improve period measurement by using a longer delay Period measurement can be difficult when using high sampling frequency where the jitter criteria is hard to meet because of the system jitter. This new version is using the delta time between 2 distant interrupts to measure an interval of at least 20ms. 20ms is a good compromise between the mitigation of system jitter and the delay to update period. This way we decorrelate the period measurement from the interrupt timestamps syncing using only the 2 last interrupts. Signed-off-by: Jean-Baptiste Maneyrol Signed-off-by: Jonathan Cameron --- include/linux/iio/common/inv_sensors_timestamp.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include/linux') diff --git a/include/linux/iio/common/inv_sensors_timestamp.h b/include/linux/iio/common/inv_sensors_timestamp.h index e4e720e6f4b7..4f08204ede3b 100644 --- a/include/linux/iio/common/inv_sensors_timestamp.h +++ b/include/linux/iio/common/inv_sensors_timestamp.h @@ -46,6 +46,8 @@ struct inv_sensors_timestamp_acc { * @min_period: minimal acceptable clock period * @max_period: maximal acceptable clock period * @it: interrupts interval timestamps + * @delta: interval timestamps between several interrupts + * @delta_counter: number of data samples in the delta interval * @timestamp: store last timestamp for computing next data timestamp * @mult: current internal period multiplier * @new_mult: new set internal period multiplier (not yet effective) @@ -57,6 +59,8 @@ struct inv_sensors_timestamp { u32 min_period; u32 max_period; struct inv_sensors_timestamp_interval it; + struct inv_sensors_timestamp_interval delta; + u32 delta_counter; s64 timestamp; u32 mult; u32 new_mult; @@ -88,6 +92,8 @@ static inline void inv_sensors_timestamp_reset(struct inv_sensors_timestamp *ts) const struct inv_sensors_timestamp_interval interval_init = {0LL, 0LL}; ts->it = interval_init; + ts->delta = interval_init; + ts->delta_counter = 0; ts->timestamp = 0; } -- cgit v1.2.3