summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2015-11-17 10:54:47 -0800
committerChromeOS bot <3su6n15k.default@developer.gserviceaccount.com>2015-11-18 21:59:19 +0000
commit106942823df924d6797302c053aa7ee84a6b4786 (patch)
treee2566496c09cd1213ce0f604272ffeef3cd4f204
parent51ed96d23315f181dca058902169c2a78b2a439e (diff)
downloadchrome-ec-106942823df924d6797302c053aa7ee84a6b4786.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 (cherry picked from commit cfae64d5ded2b51fd6892dbd1084abda7f503c20) Reviewed-on: https://chromium-review.googlesource.com/312996
-rw-r--r--driver/als_si114x.c12
-rw-r--r--driver/als_si114x.h4
2 files changed, 16 insertions, 0 deletions
diff --git a/driver/als_si114x.c b/driver/als_si114x.c
index 482678ca15..b7247228aa 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])
@@ -538,6 +549,7 @@ const struct accelgyro_drv si114x_drv = {
struct si114x_drv_data_t g_si114x_data = {
.state = SI114X_NOT_READY,
+ .covered = 0,
.type_data = {
/* Proximity */
{
diff --git a/driver/als_si114x.h b/driver/als_si114x.h
index 2e068eb50c..c044a8bddf 100644
--- a/driver/als_si114x.h
+++ b/driver/als_si114x.h
@@ -204,6 +204,9 @@
#define SI114X_SEQ_REV_A10 0x08
#define SI114X_SEQ_REV_A11 0x09
+/* Proximity sensor finds an object within 5 cm, disable light sensor */
+#define SI114X_COVERED_THRESHOLD 5
+
extern const struct accelgyro_drv si114x_drv;
enum si114x_state {
@@ -232,6 +235,7 @@ struct si114x_typed_data_t {
struct si114x_drv_data_t {
enum si114x_state state;
+ uint8_t covered;
struct si114x_typed_data_t type_data[2];
};