diff options
author | Yuval Peress <peress@chromium.org> | 2019-05-30 13:54:52 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-06-06 23:47:08 +0000 |
commit | 4e6d315948367c53116e428828eac19dfbdfb429 (patch) | |
tree | d2feb44ea49f7059c42de41c6a6c085992ed3d6e /include | |
parent | 245450a0189391cace7ace17553193cfc10866ce (diff) | |
download | chrome-ec-4e6d315948367c53116e428828eac19dfbdfb429.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>
Diffstat (limited to 'include')
-rw-r--r-- | include/motion_sense.h | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/include/motion_sense.h b/include/motion_sense.h index ff009949e5..9f8d301bb0 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 |