From 327bfe2e587b0e2e127ac9659bec6f7bb7a310ed Mon Sep 17 00:00:00 2001 From: Sheng-Liang Song Date: Thu, 30 Oct 2014 15:33:43 -0700 Subject: Samus: Fixed sensor init when sysjump to between RO and RW code When sysjump between RO and RW code, the motion sensor global data structure get reset to 0. The motion sensor task does not get notification from the power state change event. Added chipset S0 state check logic to re-init sensor active flag to S0. BUG=chrome-os-partner:33370 BRANCH=ToT TEST=sysjump RW; accelread 0 Test Cases: 1 - press power cycle button; checked with powerinfo,accelread 2 - press power cycle button + F3 (refresh) key; checked with powerinfo,accelread 3 - Go to G3, S0, S3; checked with powerinfo, accelread 4 - boot up to S0; sysjump RW; accelread 0|1|2 Change-Id: Ibfe4ba581c8b771be15adb7440374d09fdf03953 Signed-off-by: Gwendal Grignou Reviewed-on: https://chromium-review.googlesource.com/226698 Reviewed-by: Alec Berg Commit-Queue: Sheng-liang Song Tested-by: Sheng-liang Song --- common/motion_sense.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/common/motion_sense.c b/common/motion_sense.c index 9ed0ab92da..21b36a1e7d 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -245,9 +245,18 @@ void motion_sense_task(void) set_present(lpc_status); - /* Initialize sampling interval. */ - accel_interval_ms = chipset_in_state(CHIPSET_STATE_ON) ? - accel_interval_ap_on_ms : SUSPEND_SAMPLING_INTERVAL; + if (chipset_in_state(CHIPSET_STATE_ON)) { + /* Update the sensor current active state to S0. */ + for (i = 0; i < motion_sensor_count; ++i) { + sensor = &motion_sensors[i]; + sensor->active = SENSOR_ACTIVE_S0; + } + + accel_interval_ms = accel_interval_ap_on_ms; + } else { + /* sensor->active already initializes to SENSOR_ACTIVE_S5 */ + accel_interval_ms = SUSPEND_SAMPLING_INTERVAL; + } while (1) { ts0 = get_time(); @@ -681,6 +690,7 @@ static int command_accel_read_xyz(int argc, char **argv) sensor = &motion_sensors[id]; while ((n == -1) || (n-- > 0)) { + x = y = z = 0; sensor->drv->read(sensor, &x, &y, &z); ccprintf("Current raw data %d: %-5d %-5d %-5d\n", id, x, y, z); ccprintf("Last calib. data %d: %-5d %-5d %-5d\n", id, -- cgit v1.2.1