diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2015-09-08 10:00:10 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2015-09-21 01:13:56 -0700 |
commit | 241c2cb42915a37ffc123fea6bc61a24620fc1dd (patch) | |
tree | c1f168d0b529c51b18620109697ea8e691b5a347 | |
parent | 8839b30b25154f96f7cc5fe893e20c478efe69f9 (diff) | |
download | chrome-ec-241c2cb42915a37ffc123fea6bc61a24620fc1dd.tar.gz |
driver: bmi160: Allow double tap to be set by the host.
In S0, allow the host to enable/disable double tap.
Set S0 accel frequency to 100Hz to track double tap event.
BRANCH=smaug
BUG=chrome-os-partner:44754
TEST=check CTS results are identical to previous runs.
Check we can enable/disable double tap from the host.
Change-Id: Ic36bdd77005a1152fd413fb3869c8a77ef680117
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/298685
-rw-r--r-- | board/ryu/board.c | 5 | ||||
-rw-r--r-- | driver/accelgyro_bmi160.c | 34 |
2 files changed, 30 insertions, 9 deletions
diff --git a/board/ryu/board.c b/board/ryu/board.c index 9370493893..6673296c31 100644 --- a/board/ryu/board.c +++ b/board/ryu/board.c @@ -298,13 +298,12 @@ struct motion_sensor_t motion_sensors[] = { .odr = 0, .ec_rate = 0, }, - /* EC needs accel for activity recognition. */ + /* Used for double tap */ [SENSOR_CONFIG_EC_S0] = { - .odr = 12500, + .odr = 100000, /* Interrupt driven, no polling */ .ec_rate = 0, }, - /* Used for double tap */ [SENSOR_CONFIG_EC_S3] = { .odr = 100000, .ec_rate = 0, diff --git a/driver/accelgyro_bmi160.c b/driver/accelgyro_bmi160.c index cbe83fd164..aaf6ff8d9b 100644 --- a/driver/accelgyro_bmi160.c +++ b/driver/accelgyro_bmi160.c @@ -645,7 +645,6 @@ int manage_activity(const struct motion_sensor_t *s, #ifdef CONFIG_GESTURE_SIGMO case MOTIONSENSE_ACTIVITY_SIG_MOTION: { int tmp; - /* Set double tap interrupt and fifo*/ ret = raw_read8(s->addr, BMI160_INT_EN_0, &tmp); if (ret) return ret; @@ -676,6 +675,23 @@ int manage_activity(const struct motion_sensor_t *s, break; } #endif +#ifdef CONFIG_GESTURE_SENSOR_BATTERY_TAP + case MOTIONSENSE_ACTIVITY_DOUBLE_TAP: { + int tmp; + /* Set double tap interrupt */ + ret = raw_read8(s->addr, BMI160_INT_EN_0, &tmp); + if (ret) + return ret; + if (enable) + tmp |= BMI160_INT_D_TAP_EN; + else + tmp &= ~BMI160_INT_D_TAP_EN; + ret = raw_write8(s->addr, BMI160_INT_EN_0, tmp); + if (ret) + ret = EC_RES_UNAVAILABLE; + break; + } +#endif default: ret = EC_RES_INVALID_PARAM; } @@ -765,10 +781,7 @@ static int config_interrupt(const struct motion_sensor_t *s) BMI160_FIFO_HEADER_EN); #endif - /* Set double tap interrupt and fifo*/ -#ifdef CONFIG_GESTURE_SENSOR_BATTERY_TAP - ret = raw_write8(s->addr, BMI160_INT_EN_0, BMI160_INT_D_TAP_EN); -#endif + /* Set fifo*/ #ifdef CONFIG_ACCEL_FIFO ret = raw_read8(s->addr, BMI160_INT_EN_1, &tmp); tmp |= BMI160_INT_FWM_EN | BMI160_INT_FFUL_EN; @@ -1052,6 +1065,10 @@ static int init(const struct motion_sensor_t *s) data->disabled_activities |= 1 << MOTIONSENSE_ACTIVITY_SIG_MOTION; #endif +#ifdef CONFIG_GESTURE_SENSOR_BATTERY_TAP + data->disabled_activities |= + 1 << MOTIONSENSE_ACTIVITY_DOUBLE_TAP; +#endif #endif /* To avoid gyro wakeup */ raw_write8(s->addr, BMI160_PMU_TRIGGER, 0); @@ -1135,10 +1152,15 @@ static int init(const struct motion_sensor_t *s) set_range(s, s->default_range, 0); + if (s->type == MOTIONSENSE_TYPE_ACCEL) { #ifdef CONFIG_ACCEL_INTERRUPTS - if (s->type == MOTIONSENSE_TYPE_ACCEL) ret = config_interrupt(s); #endif +#ifdef CONFIG_GESTURE_SENSOR_BATTERY_TAP + /* enable double tap, as soon as the chip is ready */ + manage_activity(s, MOTIONSENSE_ACTIVITY_DOUBLE_TAP, 1, NULL); +#endif + } CPRINTF("[%T %s: MS Done Init type:0x%X range:%d]\n", s->name, s->type, get_range(s)); return ret; |