summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2015-11-20 10:17:09 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2016-11-21 23:59:38 +0000
commit4996560fde069e71d726036a2ffa7a6bf1bc8b4d (patch)
treecc83bde79dbec98c3c89f35db6f1d62f763a8ff7
parent033266fa9ed479f6249e49a82c894bfb71261b77 (diff)
downloadchrome-ec-4996560fde069e71d726036a2ffa7a6bf1bc8b4d.tar.gz
UPSTREAM: 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, samus BUG=b:24367625, b:27849483 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) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/378315
-rw-r--r--common/motion_sense.c11
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.