summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2015-09-25 14:59:31 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2016-08-01 16:40:49 +0000
commitcf10b829d30b3c6b8db32051224fe1d39bb54cc5 (patch)
tree06c961f697daeb0c3b72658e61aafcaa25a1b2f9
parent28da22ae700ce3a36401041bf2ec09575accd0fa (diff)
downloadchrome-ec-cf10b829d30b3c6b8db32051224fe1d39bb54cc5.tar.gz
UPSTREAM: common: motion: Add timestamp before wakeup event.
Sandwich wake up event between timestamp. Otherwise HAL will think the event came from a long time ago. With two timestamp, the wake event timestamp will be - more - accurantly set at the time it occurs. BRANCH=smau, cyan BUG=chrome-os-partner:4570, b:27849483 TEST=Pass com.android.cts.verifier.sensors.SignificantMotionTestActivity Change-Id: I6be76820d71d2571d069542564f569a623001190 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/302642 Reviewed-by: Alec Berg <alecaberg@chromium.org> (cherry picked from commit fec7aea0bf11912fae03dc6c9f9292395c141294) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359382
-rw-r--r--common/motion_sense.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c
index 2451ec9c75..884adf195c 100644
--- a/common/motion_sense.c
+++ b/common/motion_sense.c
@@ -70,6 +70,8 @@ struct queue motion_sense_fifo = QUEUE_NULL(CONFIG_ACCEL_FIFO,
struct ec_response_motion_sensor_data);
static int motion_sense_fifo_lost;
+static void motion_sense_insert_timestamp(void);
+
void motion_sense_fifo_add_unit(struct ec_response_motion_sensor_data *data,
struct motion_sensor_t *sensor,
int valid_data)
@@ -128,8 +130,14 @@ void motion_sense_fifo_add_unit(struct ec_response_motion_sensor_data *data,
sensor->oversampling += fp_div(INT_TO_FP(1), rate) -
fp_div(INT_TO_FP(1), INT_TO_FP(ap_odr));
}
- if (data->flags & MOTIONSENSE_SENSOR_FLAG_WAKEUP)
+ if (data->flags & MOTIONSENSE_SENSOR_FLAG_WAKEUP) {
+ /*
+ * Fist, send a timestamp to be sure the event will not
+ * be tied to an old one.
+ */
+ motion_sense_insert_timestamp();
wake_up_needed = 1;
+ }
queue_add_unit(&motion_sense_fifo, data);
}