diff options
author | Nick Vaccaro <nvaccaro@chromium.org> | 2017-05-26 12:29:14 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-08-08 17:34:11 -0700 |
commit | e656b970e204309c1a665f154a5972ed85305911 (patch) | |
tree | 58ed84ec4144caf71a4953bae780ec60dd62037e /include | |
parent | 8bfde69fdd9b5feb4c47c8c714416c17afe00f78 (diff) | |
download | chrome-ec-e656b970e204309c1a665f154a5972ed85305911.tar.gz |
sensors: add bmi160 & kionix orientation driver
BRANCH=none
BUG=chromium:718919
TEST=make buildall -j works, orientation works when enabled on gru
and scarlet.
Change-Id: I16dcfa5d9dea39c082d98190fa1bb6e496168b17
Signed-off-by: Nick Vaccaro <nvaccaro@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/540124
Tested-by: Nick Vaccaro <nvaccaro@google.com>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/config.h | 31 | ||||
-rw-r--r-- | include/ec_commands.h | 10 | ||||
-rw-r--r-- | include/motion_sense.h | 8 |
3 files changed, 48 insertions, 1 deletions
diff --git a/include/config.h b/include/config.h index b557b7b8be..ee4ebf0967 100644 --- a/include/config.h +++ b/include/config.h @@ -69,6 +69,21 @@ #undef CONFIG_ACCELGYRO_BMI160 #undef CONFIG_ACCELGYRO_LSM6DSM +/* Support for BMI160 hardware orientation sensor */ +#undef CONFIG_BMI160_ORIENTATION_SENSOR + +/* Support for KIONIX KX022 hardware orientation sensor */ +#undef CONFIG_KX022_ORIENTATION_SENSOR + +/* + * Define if either CONFIG_BMI160_ORIENTATION_SUPPORT or + * CONFIG_KX022_ORIENTATION_SUPPORT is set. + */ +#undef CONFIG_ORIENTATION_SENSOR + +/* Support the orientation gesture */ +#undef CONFIG_GESTURE_ORIENTATION + /* Specify barometer attached */ #undef CONFIG_BARO_BMP280 @@ -943,6 +958,12 @@ */ #define CONFIG_DEBUG_EXCEPTIONS +/* + * Print orientation when device orientation changes + * (requires CONFIG_SENSOR_ORIENTATION) + */ +#undef CONFIG_DEBUG_ORIENTATION + /* Support Synchronous UART debug printf. */ #undef CONFIG_DEBUG_PRINTF @@ -2916,6 +2937,16 @@ #define CONFIG_MKBP_EVENT #endif +/******************************************************************************/ +/* Set generic orientation config if a specific orientation config is set. */ +#if defined(CONFIG_KX022_ORIENTATION_SENSOR) || \ + defined(CONFIG_BMI160_ORIENTATION_SENSOR) +#ifndef CONFIG_ACCEL_FIFO +#error CONFIG_ACCEL_FIFO must be defined to use hw orientation sensor support +#endif +#define CONFIG_ORIENTATION_SENSOR +#endif + /*****************************************************************************/ /* * Handle task-dependent configs. diff --git a/include/ec_commands.h b/include/ec_commands.h index d15c213e98..5be3892d66 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -2080,6 +2080,15 @@ enum motionsensor_chip { MOTIONSENSE_CHIP_OPT3001 = 10, }; +/* List of orientation positions */ +enum motionsensor_orientation { + MOTIONSENSE_ORIENTATION_LANDSCAPE = 0, + MOTIONSENSE_ORIENTATION_PORTRAIT = 1, + MOTIONSENSE_ORIENTATION_UPSIDE_DOWN_PORTRAIT = 2, + MOTIONSENSE_ORIENTATION_UPSIDE_DOWN_LANDSCAPE = 3, + MOTIONSENSE_ORIENTATION_UNKNOWN = 4, +}; + struct __ec_todo_packed ec_response_motion_sensor_data { /* Flags for each sensor. */ uint8_t flags; @@ -2124,6 +2133,7 @@ enum motionsensor_activity { MOTIONSENSE_ACTIVITY_RESERVED = 0, MOTIONSENSE_ACTIVITY_SIG_MOTION = 1, MOTIONSENSE_ACTIVITY_DOUBLE_TAP = 2, + MOTIONSENSE_ACTIVITY_ORIENTATION = 3, }; struct __ec_todo_unpacked ec_motion_sense_activity { diff --git a/include/motion_sense.h b/include/motion_sense.h index ef5340122f..553cf0ca7e 100644 --- a/include/motion_sense.h +++ b/include/motion_sense.h @@ -203,7 +203,13 @@ void sensor_init_done(const struct motion_sensor_t *sensor, int range); */ void sensor_board_proc_double_tap(void); -#ifdef CONFIG_GESTURE_HOST_DETECTION +#ifdef CONFIG_ORIENTATION_SENSOR +enum motionsensor_orientation motion_sense_remap_orientation( + const struct motion_sensor_t *s, + enum motionsensor_orientation orientation); +#endif + +#if defined(CONFIG_GESTURE_HOST_DETECTION) || defined(CONFIG_ORIENTATION_SENSOR) /* Add an extra sensor. We may need to add more */ #define MOTION_SENSE_ACTIVITY_SENSOR_ID (motion_sensor_count) #define ALL_MOTION_SENSORS (MOTION_SENSE_ACTIVITY_SENSOR_ID + 1) |