diff options
author | Alec Berg <alecaberg@chromium.org> | 2014-03-11 15:17:41 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-03-20 23:51:55 +0000 |
commit | 5bd3d71259f7d6f003a5d4e53a5c23bd8035da73 (patch) | |
tree | e23f042a6644dddc61e79e13a9b7dde313a92de7 /common | |
parent | b9b5c89c301d5c7eb68b5ad5b9e05978ce93f436 (diff) | |
download | chrome-ec-5bd3d71259f7d6f003a5d4e53a5c23bd8035da73.tar.gz |
rambi: change EC accel sampling rate and default sensor output data rate.
Two accelerometer changes:
- Lower accel sampling rate when chipset is off to 10Hz. Increase
sampling rate back up to 100Hz when transitioning to S0.
- Change the default output data rate of the accelerometers to 100Hz
which matches the EC sampling rate when in S0.
BUG=none
BRANCH=rambi
TEST=manual testing. used lidangle command to verify that in S0,
EC is sampling at 100Hz, and in S3 or lower it is sampling at 10Hz.
Change-Id: Ie4e20f45f9371d674c3325a362d2729c331fac4f
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/190032
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/motion_sense.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c index eea52d394e..7c7b8a55b5 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -28,8 +28,12 @@ static vector_3_t acc_lid_raw, acc_lid, acc_base; static vector_3_t acc_lid_host, acc_base_host; static float lid_angle_deg; +/* Accelerometer polling intervals based on chipset state. */ +#define ACCEL_INTERVAL_AP_ON_MS 10 +#define ACCEL_INTERVAL_AP_SUSPEND_MS 100 + /* Sampling interval for measuring acceleration and calculating lid angle. */ -static int accel_interval_ms = 10; +static int accel_interval_ms = ACCEL_INTERVAL_AP_SUSPEND_MS; #ifdef CONFIG_CMD_LID_ANGLE static int accel_disp; @@ -117,6 +121,20 @@ void motion_get_accel_base(vector_3_t *v) } #endif +/* Lower accel polling rate on chipset suspend. */ +static void set_slow_accel_polling(void) +{ + accel_interval_ms = ACCEL_INTERVAL_AP_SUSPEND_MS; +} +DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, set_slow_accel_polling, HOOK_PRIO_DEFAULT); + +/* Raise accel polling rate on chipset resume. */ +static void set_fast_accel_polling(void) +{ + accel_interval_ms = ACCEL_INTERVAL_AP_ON_MS; +} +DECLARE_HOOK(HOOK_CHIPSET_RESUME, set_fast_accel_polling, HOOK_PRIO_DEFAULT); + void motion_sense_task(void) { @@ -244,7 +262,11 @@ static int command_ctrl_print_lid_angle_calcs(int argc, char **argv) accel_disp = val; } - /* Second arg changes the accel task time interval. */ + /* + * Second arg changes the accel task time interval. Note accel + * sampling interval will be clobbered when chipset suspends or + * resumes. + */ if (argc > 2) { val = strtoi(argv[2], &e, 0); if (*e) |