summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Vaccaro <nvaccaro@google.com>2019-08-21 17:35:58 -0700
committerCommit Bot <commit-bot@chromium.org>2019-09-09 18:03:53 +0000
commit6a4e9b19fbfcbecfbb95dbcbb02292bd7a4916f6 (patch)
tree5241c0ee4220d44bb3a5b9629c7ef0d990306caf
parent56496cf796e17c064e30fdcab2f1a9b1cdc92796 (diff)
downloadchrome-ec-6a4e9b19fbfcbecfbb95dbcbb02292bd7a4916f6.tar.gz
drivers/tcs3400: fix a couple values in lux table
A couple of the values in the lux atime table needed adjusting as they were too aggressive and were causing train-up / saturate / train-down / repeat... pattern cycles. Allow device to upshift in training when we're >= 2.5x from saturation (was >= 3x). Fixed a couple of nits. BUG=b:139749448 BRANCH=master TEST=Walked a flapjack through each lux light level, with a test at the low end of the level and a test at the high end of each level (i.e. for LUX level 1000, tested at 1100 and 1900 LUX), assure the tcs3400 doesn't go into saturation while trying to hit the 90% band. Change-Id: I84c5bf09e072e96d516d91520a176fa35274ce7a Signed-off-by: Nick Vaccaro <nvaccaro@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1767598
-rw-r--r--driver/als_tcs3400.c10
-rw-r--r--driver/als_tcs3400.h6
2 files changed, 9 insertions, 7 deletions
diff --git a/driver/als_tcs3400.c b/driver/als_tcs3400.c
index 7e867a606d..80bf837ad7 100644
--- a/driver/als_tcs3400.c
+++ b/driver/als_tcs3400.c
@@ -32,8 +32,8 @@ static const uint16_t
range_atime[TCS_MAX_AGAIN - TCS_MIN_AGAIN + 1][TCS_MAX_ATIME_RANGES] = {
{11200, 5600, 5600, 7200, 5500, 4500, 3800, 3800, 3300, 2900, 2575, 2275, 2075},
{11200, 5100, 2700, 1840, 1400, 1133, 981, 963, 833, 728, 650, 577, 525},
-{250, 1225, 643, 441, 337, 276, 237, 235, 203, 176, 150, 0, 0},
-{790, 311, 163, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} };
+{250, 1225, 643, 441, 337, 276, 253, 235, 203, 176, 150, 0, 0},
+{790, 261, 163, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} };
static void
decrement_atime(struct tcs_saturation_t *sat_p, uint16_t cur_lux, int percent)
@@ -217,11 +217,11 @@ tcs3400_adjust_sensor_for_saturation(struct motion_sensor_t *s,
* is to adjust atime to reduce sensitivity so
* that we may increase gain without saturation.
* This combination effectively acts as a half
- * gain increase (2x estimate) instead of a full
- * gain increase of 4x that would result in
+ * gain increase (2.5x estimate) instead of a full
+ * gain increase of > 4x that would result in
* saturation.
*/
- if (max_val < TCS_GAIN_SAT_UPSHIFT_LEVEL) {
+ if (max_val < TCS_GAIN_UPSHIFT_LEVEL) {
sat_p->atime = TCS_GAIN_UPSHIFT_ATIME;
sat_p->again++;
}
diff --git a/driver/als_tcs3400.h b/driver/als_tcs3400.h
index 9681a39a56..08467028b0 100644
--- a/driver/als_tcs3400.h
+++ b/driver/als_tcs3400.h
@@ -128,8 +128,10 @@ enum tcs3400_mode {
*/
#define TCS_GAIN_ADJUST_FACTOR 5
#define TCS_GAIN_SAT_LEVEL (TCS_SATURATION_LEVEL / TCS_GAIN_ADJUST_FACTOR)
-#define TCS_UPSHIFT_FACTOR 3
-#define TCS_GAIN_SAT_UPSHIFT_LEVEL (TCS_SATURATION_LEVEL / TCS_UPSHIFT_FACTOR)
+#define TCS_UPSHIFT_FACTOR_N 25 /* upshift factor = 2.5 */
+#define TCS_UPSHIFT_FACTOR_D 10
+#define TCS_GAIN_UPSHIFT_LEVEL (TCS_SATURATION_LEVEL * TCS_UPSHIFT_FACTOR_D \
+ / TCS_UPSHIFT_FACTOR_N)
/*
* Percentage of saturation level that the auto-adjusting anti-saturation