diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2023-01-09 14:24:46 -0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-01-11 18:43:03 +0000 |
commit | 32c498f7240595860fdce5bd1f4ad0693a7d503e (patch) | |
tree | f3753304a3f724fa75e95a3932ab8f9f7d29a013 /common/body_detection.c | |
parent | cc3a1940419436150d363f3b74a4be9ff3037bcc (diff) | |
download | chrome-ec-32c498f7240595860fdce5bd1f4ad0693a7d503e.tar.gz |
body_detection: Remove get_resolution
EC accelerometer drivers already pad data from sensors when resolution
is less than 16 bits. No more resolution processing is needed when
measuring body activity.
BUG=b:262680246
BRANCH=none
TEST=Unit test.
Change-Id: Iff7df3915e855e25abc287a3c2caa477fd678f27
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4148783
Reviewed-by: Diana Z <dzigterman@chromium.org>
Tested-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Diffstat (limited to 'common/body_detection.c')
-rw-r--r-- | common/body_detection.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/common/body_detection.c b/common/body_detection.c index 819ced4679..50b9b93d1c 100644 --- a/common/body_detection.c +++ b/common/body_detection.c @@ -143,12 +143,11 @@ static void determine_window_size(int odr) } } -/* Determine variance threshold scale by range and resolution. */ -static void determine_threshold_scale(int range, int resolution, int rms_noise) +/* Determine variance threshold scale by range. */ +static void determine_threshold_scale(int range, int rms_noise) { /* * range: g - * resolution: bits * data_1g: LSB/g * data_1g / 9800: LSB/(mm/s^2) * (data_1g / 9800)^2: (LSB^2)/(mm^2/s^4), which number of @@ -156,7 +155,7 @@ static void determine_threshold_scale(int range, int resolution, int rms_noise) * rms_noise: ug * var_noise: mm^2/s^4 */ - const int data_1g = BIT(resolution - 1) / range; + const int data_1g = MOTION_SCALING_FACTOR / range; const int multiplier = POW2(data_1g); const int divisor = POW2(9800); /* @@ -181,7 +180,6 @@ static void determine_threshold_scale(int range, int resolution, int rms_noise) void body_detect_reset(void) { int odr = body_sensor->drv->get_data_rate(body_sensor); - int resolution = body_sensor->drv->get_resolution(body_sensor); int rms_noise = body_sensor->drv->get_rms_noise(body_sensor); body_detect_change_state(BODY_DETECTION_ON_BODY, false); @@ -192,8 +190,7 @@ void body_detect_reset(void) if (odr == 0) return; determine_window_size(odr); - determine_threshold_scale(body_sensor->current_range, resolution, - rms_noise); + determine_threshold_scale(body_sensor->current_range, rms_noise); /* initialize motion data and state */ memset(data, 0, sizeof(data)); history_idx = 0; |