diff options
author | Zick Wei <zick.wei@quanta.corp-partner.google.com> | 2021-05-19 19:28:59 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-05-22 18:45:01 +0000 |
commit | 94f1715ae2acac5bb68d31289cf46b9699a232be (patch) | |
tree | 402fc103c64e89d6ff5f43840689b7ffd6e563e0 | |
parent | e5266358469b1a57d00ba9d34618a5e1e9a435f0 (diff) | |
download | chrome-ec-94f1715ae2acac5bb68d31289cf46b9699a232be.tar.gz |
dooly: fix lux overflow
We saw under some low light environment
lux will switch between 0 to extreme high value,
wich will cause display backlight flash,
this CL fix this issue due there is overflow in calculation.
BUG=b:188205311
BRANCH=puff
TEST=make sure panel backlight not flash in low light environment.
Signed-off-by: Zick Wei <zick.wei@quanta.corp-partner.google.com>
Change-Id: I47680e0c84d84f183fd5c2b973429e9964539049
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2909095
Tested-by: Zick Wei <zick.wei@quanta.corp-partner.google.com>
Tested-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Commit-Queue: Gwendal Grignou <gwendal@chromium.org>
(cherry picked from commit d4ee99609cd07a7e5c08669036d19dd740788796)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2912404
-rw-r--r-- | board/dooly/board.c | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/board/dooly/board.c b/board/dooly/board.c index 241fa67a2a..81e2f0a861 100644 --- a/board/dooly/board.c +++ b/board/dooly/board.c @@ -188,7 +188,7 @@ __override void tcs3400_translate_to_xyz(struct motion_sensor_t *s, int32_t *crgb_data, int32_t *xyz_data) { int n, cur_gain; - fp_t n_interval; + fp_t n_interval, rgbc_sum; int integration_time_us; struct tcs_saturation_t *sat_p = &(TCS3400_RGB_DRV_DATA(s+1)->saturation); @@ -214,28 +214,34 @@ __override void tcs3400_translate_to_xyz(struct motion_sensor_t *s, switch (n) { case 1: - xyz_data[1] = FP_TO_INT(fp_mul(FLOAT_TO_FP(799.797), - (fp_mul(INT_TO_FP(crgb_data[0]), FLOAT_TO_FP(0.009)) + - fp_mul(INT_TO_FP(crgb_data[1]), FLOAT_TO_FP(0.056)) + - fp_mul(INT_TO_FP(crgb_data[2]), FLOAT_TO_FP(2.735)) + - fp_mul(INT_TO_FP(crgb_data[3]), FLOAT_TO_FP(-1.903))) / - (integration_time_us * cur_gain / 1000ULL))); + rgbc_sum = + fp_mul(INT_TO_FP(crgb_data[0]), FLOAT_TO_FP(0.009)) + + fp_mul(INT_TO_FP(crgb_data[1]), FLOAT_TO_FP(0.056)) + + fp_mul(INT_TO_FP(crgb_data[2]), FLOAT_TO_FP(2.735)) + + fp_mul(INT_TO_FP(crgb_data[3]), FLOAT_TO_FP(-1.903)); + + xyz_data[1] = FP_TO_INT(fp_mul(FLOAT_TO_FP(799.797), rgbc_sum + / (int)(integration_time_us * cur_gain / 1000ULL))); break; case 2: - xyz_data[1] = FP_TO_INT(fp_mul(FLOAT_TO_FP(801.347), - (fp_mul(INT_TO_FP(crgb_data[0]), FLOAT_TO_FP(0.202)) + - fp_mul(INT_TO_FP(crgb_data[1]), FLOAT_TO_FP(-1.1)) + - fp_mul(INT_TO_FP(crgb_data[2]), FLOAT_TO_FP(8.692)) + - fp_mul(INT_TO_FP(crgb_data[3]), FLOAT_TO_FP(-7.068))) / - (integration_time_us * cur_gain / 1000ULL))); + rgbc_sum = + fp_mul(INT_TO_FP(crgb_data[0]), FLOAT_TO_FP(0.202)) + + fp_mul(INT_TO_FP(crgb_data[1]), FLOAT_TO_FP(-1.1)) + + fp_mul(INT_TO_FP(crgb_data[2]), FLOAT_TO_FP(8.692)) + + fp_mul(INT_TO_FP(crgb_data[3]), FLOAT_TO_FP(-7.068)); + + xyz_data[1] = FP_TO_INT(fp_mul(FLOAT_TO_FP(801.347), rgbc_sum + / (int)(integration_time_us * cur_gain / 1000ULL))); break; case 3: - xyz_data[1] = FP_TO_INT(fp_mul(FLOAT_TO_FP(795.574), - (fp_mul(INT_TO_FP(crgb_data[0]), FLOAT_TO_FP(-0.661)) + - fp_mul(INT_TO_FP(crgb_data[1]), FLOAT_TO_FP(1.334)) + - fp_mul(INT_TO_FP(crgb_data[2]), FLOAT_TO_FP(1.095)) + - fp_mul(INT_TO_FP(crgb_data[3]), FLOAT_TO_FP(-1.821))) / - (integration_time_us * cur_gain / 1000ULL))); + rgbc_sum = + fp_mul(INT_TO_FP(crgb_data[0]), FLOAT_TO_FP(-0.661)) + + fp_mul(INT_TO_FP(crgb_data[1]), FLOAT_TO_FP(1.334)) + + fp_mul(INT_TO_FP(crgb_data[2]), FLOAT_TO_FP(1.095)) + + fp_mul(INT_TO_FP(crgb_data[3]), FLOAT_TO_FP(-1.821)); + + xyz_data[1] = FP_TO_INT(fp_mul(FLOAT_TO_FP(795.574), rgbc_sum + / (int)(integration_time_us * cur_gain / 1000ULL))); break; default: break; |