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>2017-05-01 21:19:55 +0000
commitb4f98e5736b88a0fa3e675c29e6b271ca0d3ecfb (patch)
treeb73cebd977d81fa53df2d8904ce5a46f076befb5
parentc4bb4d02ba67f84c5a4cb4c40df741844ddd0158 (diff)
downloadchrome-ec-b4f98e5736b88a0fa3e675c29e6b271ca0d3ecfb.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=smau, cyan, ultima BUG=b:2436762, b:27849483, b:36973851 TEST=Run android.hardware.cts.SingleSensorTests 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/359401 Reviewed-on: https://chromium-review.googlesource.com/409488 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> (cherry picked from commit dcb288509c3ea77188d41674ea9ab92fd3c7146e) Change-Id: I5820216a2cfc0a869db7dc5ef75d4be126a53b4f Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/489761
-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.