summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorYuval Peress <peress@chromium.org>2019-05-30 13:54:52 -0600
committerCommit Bot <commit-bot@chromium.org>2019-08-02 17:47:55 +0000
commite60fe475ef464e341803e2630472adf9c8bee468 (patch)
tree68236feacc04366ab36e543affdfc96c259ddc06 /include
parent2f9fea63521978521b579ee87f0220271ecf0f46 (diff)
downloadchrome-ec-e60fe475ef464e341803e2630472adf9c8bee468.tar.gz
common: motion_sense: Spread timestamps in motion sense fifo
This changes moves the specialized logic for timestamp spreading away from the accelgyro_lsm6dsm and into the main motion_sense loop. The motion_sense_fifo_add_data function was replaced by a stage equivalent, and a commit function was added. Similarly, internal static functions for motion_sense.c were renamed to use the stage terminology. The idea is: When a sensor is read, it might provide more than one measurement though the only known timestamp is the one that caused the interrupt. Staging this data allows us to use the same fifo queue space that the entries would consume eventually anyway without making the entries readable. Upon commit, the timestamp entries are spread if needed. Note that if tight timestamps are disabled, the commit becomes a simple tail move. BUG=chromium:966506 BRANCH=None TEST=Ran CTS on arcada. Change-Id: Ib7d0a75c9c56fc4e275aed794058a5eca58ff47f Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1637416 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1719566 Reviewed-by: Edward Hill <ecgh@chromium.org> Tested-by: Edward Hill <ecgh@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/motion_sense.h17
1 files changed, 12 insertions, 5 deletions
diff --git a/include/motion_sense.h b/include/motion_sense.h
index 28612f0454..352301a892 100644
--- a/include/motion_sense.h
+++ b/include/motion_sense.h
@@ -233,7 +233,8 @@ extern unsigned int motion_min_interval;
extern struct queue motion_sense_fifo;
/**
- * Add new actual data to the fifo, including a timestamp.
+ * Stage data to the fifo, including a timestamp. This data will not be
+ * available to the AP until motion_sense_fifo_commit_data is called.
*
* @param data data to insert in the FIFO
* @param sensor sensor the data comes from
@@ -241,10 +242,16 @@ extern struct queue motion_sense_fifo;
* @param time accurate time (ideally measured in an interrupt) the sample
* was taken at
*/
-void motion_sense_fifo_add_data(struct ec_response_motion_sensor_data *data,
- struct motion_sensor_t *sensor,
- int valid_data,
- uint32_t time);
+void motion_sense_fifo_stage_data(struct ec_response_motion_sensor_data *data,
+ struct motion_sensor_t *sensor,
+ int valid_data,
+ uint32_t time);
+
+/**
+ * Commits all staged data to the fifo. If multiple readings were placed using
+ * the same timestamps, they will be spread out.
+ */
+void motion_sense_fifo_commit_data(void);
#endif