diff options
author | Alexandru M Stan <amstan@chromium.org> | 2018-07-11 13:12:28 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2018-07-16 20:37:25 +0000 |
commit | 6f11672d847fb6440464e22bfdc478986ac1b297 (patch) | |
tree | bae1e2f01ee26ed752d7d318a6f8f236161d88c9 | |
parent | 7f5b9e97860db889186e5825a166da6ffd248075 (diff) | |
download | chrome-ec-6f11672d847fb6440464e22bfdc478986ac1b297.tar.gz |
Revert "motion: Lower jitter of Sensor->EC timestamp"
This reverts commit 05c410f34add5d4b2a50b248ab79c9436a0cf776.
A few EC CLs made some bad assumption and caused CTS to fail (without
realizing it in time). This is a series to revert those bad CLs and other
CLs that depend on it.
They might reland back soon.
BUG=b/111220617
TEST=With series, CTS passes once again
Change-Id: Id0d98eacf388d6e7778cf23c5dfcefca9e78a757
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1134056
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Commit-Queue: Furquan Shaikh <furquan@chromium.org>
Tested-by: Furquan Shaikh <furquan@chromium.org>
-rw-r--r-- | common/motion_sense.c | 43 | ||||
-rw-r--r-- | driver/accel_lis2dh.c | 8 | ||||
-rw-r--r-- | driver/accelgyro_bmi160.c | 11 | ||||
-rw-r--r-- | driver/als_si114x.c | 8 | ||||
-rw-r--r-- | include/motion_sense.h | 11 |
5 files changed, 23 insertions, 58 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c index e95dd16691..317734d878 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -104,12 +104,9 @@ struct queue motion_sense_fifo = QUEUE_NULL(CONFIG_ACCEL_FIFO, struct ec_response_motion_sensor_data); static int motion_sense_fifo_lost; -/* - * Do not use this function directly if you just want to add sensor data, use - * motion_sense_fifo_add_data instead to get a proper timestamp too. - */ -static void motion_sense_fifo_add_unit( - struct ec_response_motion_sensor_data *data, +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) { @@ -142,6 +139,11 @@ static void motion_sense_fifo_add_unit( } mutex_unlock(&g_sensor_mutex); 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; } #ifdef CONFIG_TABLET_MODE @@ -164,23 +166,15 @@ static void motion_sense_insert_flush(struct motion_sensor_t *sensor) motion_sense_fifo_add_unit(&vector, sensor, 0); } -static void motion_sense_insert_timestamp(uint32_t timestamp) +static void motion_sense_insert_timestamp(void) { struct ec_response_motion_sensor_data vector; vector.flags = MOTIONSENSE_SENSOR_FLAG_TIMESTAMP; - vector.timestamp = timestamp; + vector.timestamp = __hw_clock_source_read(); vector.sensor_num = 0; motion_sense_fifo_add_unit(&vector, NULL, 0); } -void motion_sense_fifo_add_data(struct ec_response_motion_sensor_data *data, - struct motion_sensor_t *sensor, - int valid_data, - uint32_t time) { - motion_sense_insert_timestamp(time); - motion_sense_fifo_add_unit(data, sensor, valid_data); -} - static void motion_sense_get_fifo_info( struct ec_response_motion_sense_fifo_info *fifo_info) { @@ -738,8 +732,7 @@ static int motion_sense_process(struct motion_sensor_t *sensor, vector.data[X] = v[X]; vector.data[Y] = v[Y]; vector.data[Z] = v[Z]; - motion_sense_fifo_add_data(&vector, sensor, 3, - __hw_clock_source_read()); + motion_sense_fifo_add_unit(&vector, sensor, 3); } sensor->last_collection = ts->le.lo; } else { @@ -819,8 +812,7 @@ static void check_and_queue_gestures(uint32_t *event) vector.activity = MOTIONSENSE_ACTIVITY_DOUBLE_TAP; vector.state = 1; /* triggered */ vector.sensor_num = MOTION_SENSE_ACTIVITY_SENSOR_ID; - motion_sense_fifo_add_data(&vector, NULL, 0, - __hw_clock_source_read()); + motion_sense_fifo_add_unit(&vector, NULL, 0); #endif /* Call board specific function to process tap */ sensor_board_proc_double_tap(); @@ -837,8 +829,7 @@ static void check_and_queue_gestures(uint32_t *event) vector.activity = MOTIONSENSE_ACTIVITY_SIG_MOTION; vector.state = 1; /* triggered */ vector.sensor_num = MOTION_SENSE_ACTIVITY_SENSOR_ID; - motion_sense_fifo_add_data(&vector, NULL, 0, - __hw_clock_source_read()); + motion_sense_fifo_add_unit(&vector, NULL, 0); #endif /* Disable further detection */ activity_sensor = &motion_sensors[CONFIG_GESTURE_SIGMO]; @@ -863,8 +854,7 @@ static void check_and_queue_gestures(uint32_t *event) MOTIONSENSE_ORIENTATION_UNKNOWN)) { SET_ORIENTATION_UPDATED(sensor); vector.state = GET_ORIENTATION(sensor); - motion_sense_fifo_add_data(&vector, NULL, 0, - __hw_clock_source_read()); + motion_sense_fifo_add_unit(&vector, NULL, 0); #ifdef CONFIG_DEBUG_ORIENTATION { static const char * const mode_strs[] = { @@ -983,8 +973,7 @@ void motion_sense_task(void *u) time_after(ts_end_task.le.lo, ts_last_int.le.lo + motion_int_interval))) { if (!fifo_flush_needed) - motion_sense_insert_timestamp( - __hw_clock_source_read()); + motion_sense_insert_timestamp(); fifo_flush_needed = 0; ts_last_int = ts_end_task; /* @@ -1205,7 +1194,7 @@ static int host_cmd_motion_sense(struct host_cmd_handler_args *args) * Send an event to have a timestamp inserted in the * FIFO. */ - motion_sense_insert_timestamp(__hw_clock_source_read()); + motion_sense_insert_timestamp(); #endif sensor->config[SENSOR_CONFIG_AP].odr = in->sensor_odr.data | diff --git a/driver/accel_lis2dh.c b/driver/accel_lis2dh.c index 3bba013b71..77379eb52b 100644 --- a/driver/accel_lis2dh.c +++ b/driver/accel_lis2dh.c @@ -11,7 +11,6 @@ #include "common.h" #include "console.h" #include "hooks.h" -#include "hwtimer.h" #include "i2c.h" #include "math_util.h" #include "task.h" @@ -201,12 +200,7 @@ static int load_fifo(struct motion_sensor_t *s) vect.data[2] = axis[2]; vect.flags = 0; vect.sensor_num = 0; - motion_sense_fifo_add_data(&vect, s, 3, - __hw_clock_source_read()); - /* - * TODO: get time at a more accurate spot. - * Like in lis2dh_interrupt - */ + motion_sense_fifo_add_unit(&vect, s, 3); } } while(!done); diff --git a/driver/accelgyro_bmi160.c b/driver/accelgyro_bmi160.c index 952c5de0d1..cad62df246 100644 --- a/driver/accelgyro_bmi160.c +++ b/driver/accelgyro_bmi160.c @@ -14,7 +14,6 @@ #include "driver/accelgyro_bmi160.h" #include "driver/mag_bmm150.h" #include "hooks.h" -#include "hwtimer.h" #include "i2c.h" #include "math_util.h" #include "spi.h" @@ -26,10 +25,6 @@ #define CPRINTF(format, args...) cprintf(CC_ACCEL, format, ## args) #define CPRINTS(format, args...) cprints(CC_ACCEL, format, ## args) -#ifdef CONFIG_ACCEL_FIFO -static uint32_t last_interrupt_timestamp; -#endif - /* * Struct for pairing an engineering value with the register value for a * parameter. @@ -818,8 +813,7 @@ static int bmi160_decode_header(struct motion_sensor_t *s, vector.data[Y] = v[Y]; vector.data[Z] = v[Z]; vector.sensor_num = i + (s - motion_sensors); - motion_sense_fifo_add_data(&vector, s + i, 3, - last_interrupt_timestamp); + motion_sense_fifo_add_unit(&vector, s + i, 3); *bp += (i == MOTIONSENSE_TYPE_MAG ? 8 : 6); } } @@ -954,9 +948,6 @@ static int load_fifo(struct motion_sensor_t *s) */ void bmi160_interrupt(enum gpio_signal signal) { -#ifdef CONFIG_ACCEL_FIFO - last_interrupt_timestamp = __hw_clock_source_read(); -#endif task_set_event(TASK_ID_MOTIONSENSE, CONFIG_ACCELGYRO_BMI160_INT_EVENT, 0); } diff --git a/driver/als_si114x.c b/driver/als_si114x.c index 567caa917c..5d9e595f07 100644 --- a/driver/als_si114x.c +++ b/driver/als_si114x.c @@ -11,7 +11,6 @@ #include "console.h" #include "driver/als_si114x.h" #include "hooks.h" -#include "hwtimer.h" #include "i2c.h" #include "math_util.h" #include "task.h" @@ -151,12 +150,7 @@ static int si114x_read_results(struct motion_sensor_t *s, int nb) for (i = nb; i < 3; i++) vector.data[i] = 0; vector.sensor_num = s - motion_sensors; - motion_sense_fifo_add_data(&vector, s, nb, - __hw_clock_source_read()); - /* - * TODO: get time at a more accurate spot. - * Like in si114x_interrupt - */ + motion_sense_fifo_add_unit(&vector, s, nb); #else /* We need to copy raw_xyz into xyz with mutex */ #endif diff --git a/include/motion_sense.h b/include/motion_sense.h index 07687feb5a..9d727a62de 100644 --- a/include/motion_sense.h +++ b/include/motion_sense.h @@ -180,18 +180,15 @@ extern unsigned int motion_min_interval; extern struct queue motion_sense_fifo; /** - * Add new actual data to the fifo, including a timestamp. + * Interrupt function for lid accelerometer. * * @param data data to insert in the FIFO * @param sensor sensor the data comes from - * @param valid_data data should be copied into the public sensor vector - * @param time accurate time (ideally measured in an interrupt) the sample - * was taken at + * @valid_data data should be copied into the public sensor vector */ -void motion_sense_fifo_add_data(struct ec_response_motion_sensor_data *data, +void motion_sense_fifo_add_unit(struct ec_response_motion_sensor_data *data, struct motion_sensor_t *sensor, - int valid_data, - uint32_t time); + int valid_data); #endif |