summaryrefslogtreecommitdiff
path: root/common/motion_sense.c
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2022-07-11 03:39:57 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-08-03 22:02:17 +0000
commit1404036c889324442a9559812f5c4ed6143506f3 (patch)
tree3fb75cd665c2f862e975995aeffa0d2c0b3db022 /common/motion_sense.c
parenta2efacf4a0a5857176bc6f39c9bd1e4cd2e1d6ec (diff)
downloadchrome-ec-1404036c889324442a9559812f5c4ed6143506f3.tar.gz
motion_sense_fifo: Reset timestamp only when ODR changes
Timestamp spreading is reset after each fifo commit. It prevents the fifo logic to operate when the EC takes more than a period to collect the samples. Reset timestamp spreading only when ODR changes. Move needed fields inside motion_sense_fifo to handle virtual sensors. Fixes commit bc9660a4b3e8 ("common: motionsense fifo: Reset the initialized bits after commit") BUG=b:168335284,b:237305991,b:217580259 BRANCH=all TEST=make run-motion_sense_fifo Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Change-Id: If7265079f7fc7f4e7e22dd80865305f4553df020 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3754212 Reviewed-by: Yuval Peress <peress@google.com>
Diffstat (limited to 'common/motion_sense.c')
-rw-r--r--common/motion_sense.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c
index 5a1f3a805c..2cd1f2fe5f 100644
--- a/common/motion_sense.c
+++ b/common/motion_sense.c
@@ -196,6 +196,10 @@ int motion_sense_set_data_rate(struct motion_sensor_t *sensor)
sensor->collection_rate = odr > 0 ? SECOND * 1000 / odr : 0;
sensor->next_collection = ts.le.lo + sensor->collection_rate;
sensor->oversampling = 0;
+ if (IS_ENABLED(CONFIG_ACCEL_FIFO)) {
+ motion_sense_set_data_period(sensor - motion_sensors,
+ sensor->collection_rate);
+ }
mutex_unlock(&g_sensor_mutex);
if (IS_ENABLED(CONFIG_BODY_DETECTION) &&
(sensor - motion_sensors == CONFIG_BODY_DETECTION_SENSOR))