diff options
author | Zick Wei <zick.wei@quanta.corp-partner.google.com> | 2021-01-29 15:35:52 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-03-18 03:32:43 +0000 |
commit | 77ea2c29a7661539307934f61aecb9650deba270 (patch) | |
tree | 6dab4ddb8cd867290170f1bfdd7d64f37dd238e1 /board/dooly | |
parent | 3d8ff353dd31bfc3bc3dd60ae1bb676d28729019 (diff) | |
download | chrome-ec-77ea2c29a7661539307934f61aecb9650deba270.tar.gz |
dooly: update als lux equation and coefficient
Implement als sensor TCS3400 lux equation and coefficient:
Lux = DGFn * ((C * Ccoefn) + (R * Rcoefn) + (G * Gcoefn) +
(B * Bcoefn)) / (Atime*Again)
If (G+B)/C < 0.514, n=1
If (G+B)/C >= 0.514 and < 0.66, n=2
If (G+B)/C >= 0.66 and < 1.012, n=3
Else n=4:
Coeffs n=1 (Lo) n=2 (LM) n=3 (MH) n=4 (Hi)
Ccoef 3.8 -17.436 0.08 -0.686
Rcoef 3.956 14.535 -0.89 1.224
GCoef -20.915 32.07 7.096 4.043
BCoef 3.281 2.43 -5.603 -4.584
DGF 993 993 993 993
BUG=b:176671564
BRANCH=puff
TEST=make BOARD=dooly
Signed-off-by: Zick Wei <zick.wei@quanta.corp-partner.google.com>
Change-Id: Iaee45f670487d00179607192f2d97ca86415f077
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2657909
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.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/board/dooly/board.c b/board/dooly/board.c index cac3feefce..06a8a665db 100644 --- a/board/dooly/board.c +++ b/board/dooly/board.c @@ -184,6 +184,77 @@ BUILD_ASSERT(ARRAY_SIZE(motion_als_sensors) == ALS_COUNT); static void power_monitor(void); DECLARE_DEFERRED(power_monitor); +__override void tcs3400_translate_to_xyz(struct motion_sensor_t *s, + int32_t *crgb_data, int32_t *xyz_data) +{ + int n, cur_gain, dgf; + fp_t n_interval; + fp_t integration_time_us; + struct tcs_saturation_t *sat_p = + &(TCS3400_RGB_DRV_DATA(s+1)->saturation); + + cur_gain = (1 << (2 * sat_p->again)); + + integration_time_us = + (tcs3400_get_integration_time(sat_p->atime)); + + /* n_interval = (G+B)/C, to use different coefficient*/ + n_interval = INT_TO_FP(crgb_data[2]+crgb_data[3])/crgb_data[0]; + + dgf = 993; /* Device and Glass Factor */ + + if (n_interval < FLOAT_TO_FP(0.514)) + n = 1; + else if (n_interval >= FLOAT_TO_FP(0.514) && + n_interval < FLOAT_TO_FP(0.66)) + n = 2; + else if (n_interval >= FLOAT_TO_FP(0.66) && + n_interval < FLOAT_TO_FP(1.012)) + n = 3; + else + n = 4; + + switch (n) { + case 1: + xyz_data[1] = (fp_inter_t)(FP_TO_INT(dgf * + (crgb_data[0]*(fp_inter_t)FLOAT_TO_FP(3.8) + + crgb_data[1]*(fp_inter_t)FLOAT_TO_FP(3.956) + + crgb_data[2]*(fp_inter_t)FLOAT_TO_FP(-20.915) + + crgb_data[3]*(fp_inter_t)FLOAT_TO_FP(3.281))))*1000 / + (integration_time_us*cur_gain); + break; + case 2: + xyz_data[1] = (fp_inter_t)(FP_TO_INT(dgf * + (crgb_data[0]*(fp_inter_t)FLOAT_TO_FP(-17.436) + + crgb_data[1]*(fp_inter_t)FLOAT_TO_FP(14.535) + + crgb_data[2]*(fp_inter_t)FLOAT_TO_FP(32.07) + + crgb_data[3]*(fp_inter_t)FLOAT_TO_FP(2.43))))*1000 / + (integration_time_us*cur_gain); + break; + case 3: + xyz_data[1] = (fp_inter_t)(FP_TO_INT(dgf * + (crgb_data[0]*(fp_inter_t)FLOAT_TO_FP(0.08) + + crgb_data[1]*(fp_inter_t)FLOAT_TO_FP(-0.89) + + crgb_data[2]*(fp_inter_t)FLOAT_TO_FP(7.096) + + crgb_data[3]*(fp_inter_t)FLOAT_TO_FP(-5.603))))*1000 / + (integration_time_us*cur_gain); + break; + case 4: + xyz_data[1] = (fp_inter_t)(FP_TO_INT(dgf * + (crgb_data[0]*(fp_inter_t)FLOAT_TO_FP(-0.686) + + crgb_data[1]*(fp_inter_t)FLOAT_TO_FP(1.224) + + crgb_data[2]*(fp_inter_t)FLOAT_TO_FP(4.043) + + crgb_data[3]*(fp_inter_t)FLOAT_TO_FP(-4.584))))*1000 / + (integration_time_us*cur_gain); + break; + default: + break; + } + + if (xyz_data[1] < 0) + xyz_data[1] = 0; +} + static void ppc_interrupt(enum gpio_signal signal) { switch (signal) { |