summaryrefslogtreecommitdiff
path: root/driver/als_si114x.c
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2015-11-17 10:54:47 -0800
committerchrome-bot <chrome-bot@chromium.org>2015-11-18 13:33:26 -0800
commitcfae64d5ded2b51fd6892dbd1084abda7f503c20 (patch)
treee0d7d25a0cb04c5fd2d9583ab98ff9c156e4fb51 /driver/als_si114x.c
parentbea9bfc15db4b58e22d0b39a3590bb16b3c51d4f (diff)
downloadchrome-ec-cfae64d5ded2b51fd6892dbd1084abda7f503c20.tar.gz
driver: si114x: Do not read light when proximty is low
If the proximity sensor indicates there is an object very close (<= 5cm), ignore light sensor readings. Otherwise, when someone put their finger on the sensor, the light sensor would most likely report dark condition and the screen brightness will be lowered unexpectedly. BUG=b:25573958 BRANCH=smaug TEST=check light report does not change when proximity sensor reports < 5cm, using androsensor apps. Change-Id: I16db40766a71a7925e28372ebb54ae43f60a4989 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/312982
Diffstat (limited to 'driver/als_si114x.c')
-rw-r--r--driver/als_si114x.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/driver/als_si114x.c b/driver/als_si114x.c
index 9a4fd1ff85..f11a2100db 100644
--- a/driver/als_si114x.c
+++ b/driver/als_si114x.c
@@ -81,6 +81,7 @@ error:
static int si114x_read_results(struct motion_sensor_t *s, int nb)
{
int i, ret, val;
+ struct si114x_drv_data_t *data = SI114X_GET_DATA(s);
struct si114x_typed_data_t *type_data = SI114X_GET_TYPED_DATA(s);
#ifdef CONFIG_ACCEL_FIFO
struct ec_response_motion_sensor_data vector;
@@ -113,6 +114,16 @@ static int si114x_read_results(struct motion_sensor_t *s, int nb)
if (ret != EC_SUCCESS)
return ret;
+ if (s->type == MOTIONSENSE_TYPE_PROX)
+ data->covered = (s->raw_xyz[0] < SI114X_COVERED_THRESHOLD);
+ else if (data->covered)
+ /*
+ * The sensor (proximity & light) is covered. The light data
+ * will most likely be incorrect (darker than expected), so
+ * ignore the measurement.
+ */
+ return EC_SUCCESS;
+
/* Add in fifo if changed only */
for (i = 0; i < nb; i++) {
if (s->raw_xyz[i] != s->xyz[i])
@@ -539,6 +550,7 @@ const struct accelgyro_drv si114x_drv = {
struct si114x_drv_data_t g_si114x_data = {
.state = SI114X_NOT_READY,
+ .covered = 0,
.type_data = {
/* Proximity */
{