summaryrefslogtreecommitdiff
path: root/board/dooly
diff options
context:
space:
mode:
authorZick Wei <zick.wei@quanta.corp-partner.google.com>2021-05-19 19:28:59 +0800
committerCommit Bot <commit-bot@chromium.org>2021-05-21 23:09:21 +0000
commitd4ee99609cd07a7e5c08669036d19dd740788796 (patch)
tree33c1fd860aae6f2bce1e371922a05a2a4a0dcfee /board/dooly
parent6cd536203a98ea7efd526ed98d56052db577429e (diff)
downloadchrome-ec-d4ee99609cd07a7e5c08669036d19dd740788796.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>
Diffstat (limited to 'board/dooly')
-rw-r--r--board/dooly/board.c44
1 files changed, 25 insertions, 19 deletions
diff --git a/board/dooly/board.c b/board/dooly/board.c
index cdd26a100f..bbefcdfe85 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;