summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2015-09-25 14:59:31 -0700
committerchrome-bot <chrome-bot@chromium.org>2015-09-28 17:41:59 -0700
commitfec7aea0bf11912fae03dc6c9f9292395c141294 (patch)
tree24686b73e742127f6e67aadff4e98686a171a317
parentcf25d26c2740cb86adf235ee33dd15653c7c522b (diff)
downloadchrome-ec-fec7aea0bf11912fae03dc6c9f9292395c141294.tar.gz
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=smaug BUG=chrome-os-partner:45704 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>
-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);
}