diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2015-11-17 13:20:12 -0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2016-11-12 19:22:27 +0000 |
commit | 81f648c25a145494cebb2f995fa50357a42725d4 (patch) | |
tree | 520061fcf5106219ed5173515962d5ccd6f90847 | |
parent | 4509fb61ca0daa61e5bbb234f2dee78b6b1a1f29 (diff) | |
download | chrome-ec-81f648c25a145494cebb2f995fa50357a42725d4.tar.gz |
UPSTREAM: motion: wake up main task for all changes in EC parameter.
We need to wake up the main task, even if we disable a sensor. It will
force sending the sensors samples in the FIFO and put a timestamp behind
them.
Also, reduce the interrupt period by 10us to be sure we fire interrupt
to the AP even if there are some variation in the timing calculation.
BUG=b:2436762, b:27849483
BRANCH=smau, cyan
TEST=Run ts.SingleSensorTests overnight.
Change-Id: I6d966d52b5cbb72ba5eb936bc2fad6c06c7d8605
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/312986
Reviewed-by: Alec Berg <alecaberg@chromium.org>
(cherry picked from commit 9d7f1674460ce8e1a9c2fab79909cfd3bc856807)
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/359399
Reviewed-on: https://chromium-review.googlesource.com/409486
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r-- | common/motion_sense.c | 23 | ||||
-rw-r--r-- | include/motion_sense.h | 4 |
2 files changed, 16 insertions, 11 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c index d4773fe5d4..d87daa1059 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -52,6 +52,13 @@ static int accel_disp; #endif /* + * Adjustment in us to ec rate when calculating interrupt interval: + * To be sure the EC will send an interrupt even if it finishes processing + * events slighly ealier than the previous period. + */ +#define MOTION_SENSOR_INT_ADJUSTMENT_US 10 + +/* * Mutex to protect sensor values between host command task and * motion sense task: * When we process CMD_DUMP, we want to be sure the motion sense @@ -321,7 +328,7 @@ static int motion_sense_ec_rate(struct motion_sensor_t *sensor) */ static int motion_sense_set_motion_intervals(void) { - int i, sensor_ec_rate, ec_rate = 0, ec_int_rate = 0, wake_up = 0; + int i, sensor_ec_rate, ec_rate = 0, ec_int_rate = 0; struct motion_sensor_t *sensor; for (i = 0; i < motion_sensor_count; ++i) { sensor = &motion_sensors[i]; @@ -344,19 +351,15 @@ static int motion_sense_set_motion_intervals(void) (sensor_ec_rate && sensor_ec_rate < ec_int_rate)) ec_int_rate = sensor_ec_rate; } + motion_interval = ec_rate; + + motion_int_interval = + MAX(0, ec_int_rate - MOTION_SENSOR_INT_ADJUSTMENT_US); /* * Wake up the motion sense task: we want to sensor task to take * in account the new period right away. */ - if ((motion_interval == 0 || - (ec_rate > 0 && motion_interval > ec_rate)) || - (motion_int_interval == 0 || - (ec_int_rate > 0 && motion_int_interval > ec_int_rate))) - wake_up = 1; - motion_interval = ec_rate; - motion_int_interval = ec_int_rate; - if (wake_up) - task_wake(TASK_ID_MOTIONSENSE); + task_wake(TASK_ID_MOTIONSENSE); return motion_interval; } diff --git a/include/motion_sense.h b/include/motion_sense.h index b05c73640b..e96740abf8 100644 --- a/include/motion_sense.h +++ b/include/motion_sense.h @@ -51,7 +51,9 @@ struct motion_data_t { * MSB is used to know if we are rounding up. */ unsigned int odr; - /* delay between collection by EC, in us. + + /* + * delay between collection by EC, in us. * For non FIFO sensor, should be need 1e6/odr to * collect events. * For sensor with FIFO, can be much longer. |