From 02ddede08eb66c752b868c86293eff8fed9e8160 Mon Sep 17 00:00:00 2001 From: Gwendal Grignou Date: Mon, 30 Nov 2015 13:25:14 -0800 Subject: [PATCH] device: si114x: Address overflow condition If proximity overflow (daylight), we would still assume the data was valid and consider there is an object very very close. That would prevent the light to be measured. (cl/312982) Leave the value as max range for the HAL to handle. BRANCH=smaug BUG=b:25573958 TEST=Check in daylight that light is still measured Change-Id: I684e6f4a9aecd3fd6b338a9939f7ede26752ecb8 Signed-off-by: Gwendal Grignou Reviewed-on: https://chromium-review.googlesource.com/314921 Reviewed-by: Alec Berg --- driver/als_si114x.c | 2 +- driver/als_si114x.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/driver/als_si114x.c b/driver/als_si114x.c index f11a2100db..e3cb87a2a4 100644 --- a/driver/als_si114x.c +++ b/driver/als_si114x.c @@ -96,7 +96,7 @@ static int si114x_read_results(struct motion_sensor_t *s, int nb) /* Add offset, calibration */ if (val + type_data->offset <= 0) { val = 1; - } else { + } else if (val != SI114X_OVERFLOW) { val += type_data->offset; /* * Proxmitiy sensor data is inverse of the distance. diff --git a/driver/als_si114x.h b/driver/als_si114x.h index c044a8bddf..93e9b9a9bc 100644 --- a/driver/als_si114x.h +++ b/driver/als_si114x.h @@ -206,6 +206,7 @@ /* Proximity sensor finds an object within 5 cm, disable light sensor */ #define SI114X_COVERED_THRESHOLD 5 +#define SI114X_OVERFLOW 0xffff extern const struct accelgyro_drv si114x_drv;