diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2015-11-20 10:17:09 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2015-11-21 09:20:58 -0800 |
commit | 708f81e3d1d222270c697b5643760b1ca361b9f9 (patch) | |
tree | 46ca463a62d37b3fd72dcf2c83b496a7eeb036c7 /common | |
parent | d0cf3227ce425cb65015d49c0c734f3ee64fa1d5 (diff) | |
download | chrome-ec-708f81e3d1d222270c697b5643760b1ca361b9f9.tar.gz |
motion: Fix the number of sample to collect in motion task
AP could collect samples while motion task was still adding timestamp.
A data stream not ending with a timestamp can lead to timestamp error in
the kernel.
This is espcially true if the motion task interrupt the AP back to back,
when sensor ODR changes for instance.
BRANCH=smaug
BUG=b:24367625
TEST=Run android.hardware.cts.SingleSensorTests
Change-Id: I5820216a2cfc0a869db7dc5ef75d4be126a53b4f
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/313640
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/motion_sense.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c index 8a93878832..d493a5bd1d 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -77,6 +77,8 @@ static int wake_up_needed; /* Need to send flush events */ static int fifo_flush_needed; +/* Number of element the AP should collect */ +static int fifo_queue_count; struct queue motion_sense_fifo = QUEUE_NULL(CONFIG_ACCEL_FIFO, struct ec_response_motion_sensor_data); @@ -154,7 +156,7 @@ static void motion_sense_get_fifo_info( { fifo_info->size = motion_sense_fifo.buffer_units; mutex_lock(&g_sensor_mutex); - fifo_info->count = queue_count(&motion_sense_fifo); + fifo_info->count = fifo_queue_count; fifo_info->total_lost = motion_sense_fifo_lost; mutex_unlock(&g_sensor_mutex); fifo_info->timestamp = __hw_clock_source_read(); @@ -770,6 +772,13 @@ void motion_sense_task(void) motion_sense_insert_timestamp(); fifo_flush_needed = 0; ts_last_int = ts_end_task; + /* + * Count the number of event the AP is allowed to + * collect. + */ + mutex_lock(&g_sensor_mutex); + fifo_queue_count = queue_count(&motion_sense_fifo); + mutex_unlock(&g_sensor_mutex); #ifdef CONFIG_MKBP_EVENT /* * We don't currently support wake up sensor. |