summaryrefslogtreecommitdiff
path: root/common/motion_sense_fifo.c
diff options
context:
space:
mode:
authorYuval Peress <peress@chromium.org>2021-05-04 12:18:13 -0600
committerCommit Bot <commit-bot@chromium.org>2021-05-04 20:04:08 +0000
commitbc9660a4b3e8bab1d729cb42e0f27ac968a4f457 (patch)
treedf3aaf6b1c5d6f530a3212e5bac4341c0db7a34f /common/motion_sense_fifo.c
parentdda5488d3c5749f368d748404cfa5353e3f88fef (diff)
downloadchrome-ec-bc9660a4b3e8bab1d729cb42e0f27ac968a4f457.tar.gz
common: motionsense fifo: Reset the initialized bits after commit
Previously once we had one sample from a sensor, we considered the fifo initialized. Meaning we would use our computed next timestamp to spread the timestamps. This was causing issues with some devices that ended up causing the timestamps to run ahead. Reset next_timestamp_initialized back to 0 after each commit. This will allow repeated timestamps but only if a driver stages/commits the same timestamp twice. Staging the same timestamp with only a single commit will still work as before (which is the expected path). BRANCH=none BUG=b:168335284 TEST=make run-motion_sense_fifo Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: Ib7c566f69d7c1e4e898050b67105555dd05376e5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2871055 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Diffstat (limited to 'common/motion_sense_fifo.c')
-rw-r--r--common/motion_sense_fifo.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/common/motion_sense_fifo.c b/common/motion_sense_fifo.c
index 2b697e1f4c..244032d10a 100644
--- a/common/motion_sense_fifo.c
+++ b/common/motion_sense_fifo.c
@@ -549,6 +549,12 @@ commit_data_end:
/* Reset metadata for next staging cycle. */
memset(&fifo_staged, 0, sizeof(fifo_staged));
+ /*
+ * Reset the initialized bits. This will allow new timestamps to be
+ * considered as the new "source of truth".
+ */
+ next_timestamp_initialized = 0;
+
mutex_unlock(&g_sensor_mutex);
}