diff options
author | Jack Rosenthal <jrosenth@chromium.org> | 2022-06-27 14:34:10 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-06-28 12:53:18 +0000 |
commit | 40cf2026fd19d2ed863064f44ebe8f006e1e0352 (patch) | |
tree | a5a2b8fd6955cae0b64ff7805eb8f4acaf70c23e /common/body_detection.c | |
parent | bd988c16ac75146ac714a761f05c493075c2a09b (diff) | |
download | chrome-ec-40cf2026fd19d2ed863064f44ebe8f006e1e0352.tar.gz |
common/body_detection.c: Format with clang-format
BUG=b:236386294
BRANCH=none
TEST=none
Change-Id: If2c14c714b5814d0fb6fceb5f910b86daa8a7d60
Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3729593
Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
Diffstat (limited to 'common/body_detection.c')
-rw-r--r-- | common/body_detection.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/common/body_detection.c b/common/body_detection.c index 4fbc88e852..ebb1db59dc 100644 --- a/common/body_detection.c +++ b/common/body_detection.c @@ -14,8 +14,8 @@ /* Console output macros */ #define CPUTS(outstr) cputs(CC_ACCEL, outstr) -#define CPRINTS(format, args...) cprints(CC_ACCEL, format, ## args) -#define CPRINTF(format, args...) cprintf(CC_ACCEL, format, ## args) +#define CPRINTS(format, args...) cprints(CC_ACCEL, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_ACCEL, format, ##args) static struct motion_sensor_t *body_sensor = &motion_sensors[CONFIG_BODY_DETECTION_SENSOR]; @@ -31,10 +31,9 @@ static bool history_initialized; static bool body_detect_enable; STATIC_IF(CONFIG_ACCEL_SPOOF_MODE) bool spoof_enable; -static struct body_detect_motion_data -{ +static struct body_detect_motion_data { int history[CONFIG_BODY_DETECTION_MAX_WINDOW_SIZE]; /* acceleration */ - int sum; /* sum(history) */ + int sum; /* sum(history) */ uint64_t n2_variance; /* n^2 * var(history) */ } data[2]; /* motion data for X-axis and Y-axis */ @@ -59,8 +58,8 @@ static void update_motion_data(struct body_detect_motion_data *x, int x_n) const int sum_diff = x_n - x_0; const int new_sum = x->sum + sum_diff; - x->n2_variance += sum_diff * - ((int64_t)n * (x_n + x_0) - new_sum - x->sum); + x->n2_variance += + sum_diff * ((int64_t)n * (x_n + x_0) - new_sum - x->sum); x->sum = new_sum; x->history[history_idx] = x_n; } @@ -76,8 +75,8 @@ static void update_motion_variance(void) /* return Var(X) + Var(Y) */ static uint64_t get_motion_variance(void) { - return (data[X].n2_variance + data[Y].n2_variance) - / window_size / window_size; + return (data[X].n2_variance + data[Y].n2_variance) / window_size / + window_size; } static int calculate_motion_confidence(uint64_t var) @@ -87,7 +86,7 @@ static int calculate_motion_confidence(uint64_t var) if (var > var_threshold_scaled + confidence_delta_scaled) return 100; return 100 * (var - var_threshold_scaled + confidence_delta_scaled) / - (2 * confidence_delta_scaled); + (2 * confidence_delta_scaled); } /* Change the motion state and commit the change to AP. */ @@ -105,7 +104,7 @@ void body_detect_change_state(enum body_detect_states state, bool spoof) .sensor_num = MOTION_SENSE_ACTIVITY_SENSOR_ID, }; motion_sense_fifo_stage_data(&vector, NULL, 0, - __hw_clock_source_read()); + __hw_clock_source_read()); motion_sense_fifo_commit_data(); } /* change the motion state */ @@ -160,15 +159,15 @@ static void determine_threshold_scale(int range, int resolution, int rms_noise) * CONFIG_BODY_DETECTION_VAR_NOISE_FACTOR / 100. */ const int var_noise = POW2((uint64_t)rms_noise) * - CONFIG_BODY_DETECTION_VAR_NOISE_FACTOR * POW2(98) - / 100 / POW2(10000); + CONFIG_BODY_DETECTION_VAR_NOISE_FACTOR * + POW2(98) / 100 / POW2(10000); - var_threshold_scaled = (uint64_t) - (CONFIG_BODY_DETECTION_VAR_THRESHOLD + var_noise) * - multiplier / divisor; - confidence_delta_scaled = (uint64_t) - CONFIG_BODY_DETECTION_CONFIDENCE_DELTA * + var_threshold_scaled = + (uint64_t)(CONFIG_BODY_DETECTION_VAR_THRESHOLD + var_noise) * multiplier / divisor; + confidence_delta_scaled = + (uint64_t)CONFIG_BODY_DETECTION_CONFIDENCE_DELTA * multiplier / + divisor; } void body_detect_reset(void) @@ -185,8 +184,8 @@ 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, resolution, + rms_noise); /* initialize motion data and state */ memset(data, 0, sizeof(data)); history_idx = 0; |