diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2015-11-20 10:17:09 -0800 |
---|---|---|
committer | ChromeOS bot <3su6n15k.default@developer.gserviceaccount.com> | 2015-11-25 00:45:57 +0000 |
commit | 835de3afde0bf99a1d105667109a21e3a91c73d1 (patch) | |
tree | 1d353ae7251378660c5462238e13e2a99cfad398 | |
parent | 3e7aba4e78a2edf6f41d51b97c3ca98a142666e9 (diff) | |
download | chrome-ec-835de3afde0bf99a1d105667109a21e3a91c73d1.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>
(cherry picked from commit 708f81e3d1d222270c697b5643760b1ca361b9f9)
Reviewed-on: https://chromium-review.googlesource.com/313738
-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 0c6e461995..4854607482 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -78,6 +78,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); @@ -155,7 +157,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(); @@ -790,6 +792,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. |