diff options
author | Nick Vaccaro <nvaccaro@google.com> | 2019-10-23 20:22:28 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-12-12 11:27:45 +0000 |
commit | c7bf2e272c4a2176217198b2afd9d5f9afdfc5c2 (patch) | |
tree | 3c92991beddfbe8116070aa725bb54dcb3abc07c | |
parent | a56cdc5ff965e9f2f35cfab232022cb367820634 (diff) | |
download | chrome-ec-c7bf2e272c4a2176217198b2afd9d5f9afdfc5c2.tar.gz |
drivers/tcs3400: add IR scaling factor
This change adds a new scaling factor used in IR separation that
further improves sensor CCT accuracy. The following restructure of
calibration structure was required :
- renamed rgb_calibration_t struct to rgb_channel_calibration_t
- added new rgb_calibration_t structure definition to include
new irt scaling factor to the rgb calibration structure
BUG=b:143246741
BRANCH=master
TEST=none
Cq-Depend: chromium:1879189
Change-Id: Idb3325be828e8ed15747144670230963c369a461
Signed-off-by: Nick Vaccaro <nvaccaro@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1879188
Tested-by: Mengqi Guo <mqg@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Mengqi Guo <mqg@chromium.org>
Reviewed-by: Scott Collyer <scollyer@chromium.org>
-rw-r--r-- | driver/als_tcs3400.c | 22 | ||||
-rw-r--r-- | driver/als_tcs3400.h | 2 | ||||
-rw-r--r-- | include/accelgyro.h | 9 |
3 files changed, 23 insertions, 10 deletions
diff --git a/driver/als_tcs3400.c b/driver/als_tcs3400.c index 80bf837ad7..651f319589 100644 --- a/driver/als_tcs3400.c +++ b/driver/als_tcs3400.c @@ -273,7 +273,10 @@ static void tcs3400_translate_to_xyz(struct motion_sensor_t *s, int i; /* IR removal */ - ir = (crgb_data[1] + crgb_data[2] + crgb_data[3] - crgb_data[0]) / 2; + ir = FP_TO_INT(fp_mul(INT_TO_FP(crgb_data[1] + crgb_data[2] + + crgb_data[3] - crgb_data[0]), + rgb_drv_data->calibration.irt) / 2); + for (i = 0; i < ARRAY_SIZE(crgb_prime); i++) { if (crgb_data[i] < ir) crgb_prime[i] = 0; @@ -287,7 +290,8 @@ static void tcs3400_translate_to_xyz(struct motion_sensor_t *s, /* regression fit to XYZ space */ for (i = 0; i < 3; i++) { - const struct rgb_calibration_t *p = &rgb_drv_data->rgb_cal[i]; + const struct rgb_channel_calibration_t *p = + &rgb_drv_data->calibration.rgb_cal[i]; xyz_data[i] = p->offset + FP_TO_INT( (fp_inter_t)p->coeff[RED_CRGB_IDX] * @@ -332,7 +336,7 @@ static void tcs3400_process_raw_data(struct motion_sensor_t *s, /* rgb data at index 1, 2, and 3 owned by rgb driver, not ALS */ if (i > 0) { struct als_channel_scale_t *csp = - &rgb_drv_data->rgb_cal[i-1].scale; + &rgb_drv_data->calibration.rgb_cal[i-1].scale; k_channel_scale = csp->k_channel_scale; cover_scale = csp->cover_scale; } @@ -531,7 +535,8 @@ static int tcs3400_rgb_get_scale(const struct motion_sensor_t *s, uint16_t *scale, int16_t *temp) { - struct rgb_calibration_t *rgb_cal = TCS3400_RGB_DRV_DATA(s)->rgb_cal; + struct rgb_channel_calibration_t *rgb_cal = + TCS3400_RGB_DRV_DATA(s)->calibration.rgb_cal; scale[X] = rgb_cal[RED_RGB_IDX].scale.k_channel_scale; scale[Y] = rgb_cal[GREEN_RGB_IDX].scale.k_channel_scale; @@ -544,7 +549,8 @@ static int tcs3400_rgb_set_scale(const struct motion_sensor_t *s, const uint16_t *scale, int16_t temp) { - struct rgb_calibration_t *rgb_cal = TCS3400_RGB_DRV_DATA(s)->rgb_cal; + struct rgb_channel_calibration_t *rgb_cal = + TCS3400_RGB_DRV_DATA(s)->calibration.rgb_cal; rgb_cal[RED_RGB_IDX].scale.k_channel_scale = scale[X]; rgb_cal[GREEN_RGB_IDX].scale.k_channel_scale = scale[Y]; @@ -556,9 +562,9 @@ static int tcs3400_rgb_get_offset(const struct motion_sensor_t *s, int16_t *offset, int16_t *temp) { - offset[X] = TCS3400_RGB_DRV_DATA(s)->rgb_cal[X].offset; - offset[Y] = TCS3400_RGB_DRV_DATA(s)->rgb_cal[Y].offset; - offset[Z] = TCS3400_RGB_DRV_DATA(s)->rgb_cal[Z].offset; + offset[X] = TCS3400_RGB_DRV_DATA(s)->calibration.rgb_cal[X].offset; + offset[Y] = TCS3400_RGB_DRV_DATA(s)->calibration.rgb_cal[Y].offset; + offset[Z] = TCS3400_RGB_DRV_DATA(s)->calibration.rgb_cal[Z].offset; *temp = EC_MOTION_SENSE_INVALID_CALIB_TEMP; return EC_SUCCESS; } diff --git a/driver/als_tcs3400.h b/driver/als_tcs3400.h index 08467028b0..892b4881fd 100644 --- a/driver/als_tcs3400.h +++ b/driver/als_tcs3400.h @@ -168,7 +168,7 @@ struct tcs_saturation_t { struct tcs3400_rgb_drv_data_t { uint8_t calibration_mode;/* 0 = normal run mode, 1 = calibration mode */ - struct rgb_calibration_t rgb_cal[RGB_CHANNEL_COUNT]; + struct rgb_calibration_t calibration; struct tcs_saturation_t saturation; /* saturation adjustment */ }; diff --git a/include/accelgyro.h b/include/accelgyro.h index 2f1131c9f5..750e89e6eb 100644 --- a/include/accelgyro.h +++ b/include/accelgyro.h @@ -198,7 +198,7 @@ struct als_calibration_t { }; /* RGB ALS Calibration Data */ -struct rgb_calibration_t { +struct rgb_channel_calibration_t { /* * Each channel has scaling factor for normalization & cover */ @@ -211,6 +211,13 @@ struct rgb_calibration_t { fp_t coeff[COEFF_CHANNEL_COUNT]; }; +struct rgb_calibration_t { + struct rgb_channel_calibration_t rgb_cal[RGB_CHANNEL_COUNT]; + + /* incandecent scaling factor */ + fp_t irt; +}; + /* als driver data */ struct als_drv_data_t { int rate; /* holds current sensor rate */ |