summaryrefslogtreecommitdiff
path: root/common/body_detection.c
diff options
context:
space:
mode:
authorRobert Zieba <robertzieba@google.com>2023-02-06 20:46:25 +0000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-02-09 00:12:25 +0000
commitf95021944882889590b279ae27560e2a85b0d18d (patch)
treefe79310783c7b2db46da44cf4cd5099bb07cfd54 /common/body_detection.c
parent2508094b148ea1c5db358efe73a40ea7b3fefe12 (diff)
downloadchrome-ec-f95021944882889590b279ae27560e2a85b0d18d.tar.gz
common/body_detection: Update reset code to prevent extra state changes
`body_detect_reset` calls `body_detect_change_state` even if there is no actual state change. When host notifications are enabled this can cause extraneous events that result in incorrect motion sensor timestamps as the motion sense task uses the time of the last MKBP event to update timestamps in the FIFO. BRANCH=none BUG=b:263841660 TEST=Ran CtsSensorTestCases Change-Id: I4c7233019baf3496b802ca19156351babd7f3b94 Signed-off-by: Robert Zieba <robertzieba@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4214672 Commit-Queue: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Diffstat (limited to 'common/body_detection.c')
-rw-r--r--common/body_detection.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/common/body_detection.c b/common/body_detection.c
index 50b9b93d1c..8623948897 100644
--- a/common/body_detection.c
+++ b/common/body_detection.c
@@ -182,7 +182,10 @@ void body_detect_reset(void)
int odr = body_sensor->drv->get_data_rate(body_sensor);
int rms_noise = body_sensor->drv->get_rms_noise(body_sensor);
- body_detect_change_state(BODY_DETECTION_ON_BODY, false);
+ if (motion_state == BODY_DETECTION_ON_BODY)
+ stationary_timeframe = 0;
+ else
+ body_detect_change_state(BODY_DETECTION_ON_BODY, false);
/*
* The sensor is suspended since its ODR is 0,
* there is no need to reset until sensor is up again