From e656b970e204309c1a665f154a5972ed85305911 Mon Sep 17 00:00:00 2001 From: Nick Vaccaro Date: Fri, 26 May 2017 12:29:14 -0700 Subject: [PATCH] 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 Reviewed-on: https://chromium-review.googlesource.com/540124 Tested-by: Nick Vaccaro Reviewed-by: Gwendal Grignou --- common/motion_sense.c | 172 +++++++++++++++++++++++++++----------- driver/accel_kionix.c | 60 +++++++++++++ driver/accel_kionix.h | 21 +++++ driver/accel_kx022.h | 11 +++ driver/accelgyro_bmi160.c | 49 +++++++++++ driver/accelgyro_bmi160.h | 39 ++++++++- include/config.h | 31 +++++++ include/ec_commands.h | 10 +++ include/motion_sense.h | 8 +- 9 files changed, 350 insertions(+), 51 deletions(-) diff --git a/common/motion_sense.c b/common/motion_sense.c index 230523acee..e3cf38b88a 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -26,12 +26,26 @@ #include "timer.h" #include "task.h" #include "util.h" +#include "accel_kionix.h" /* Console output macros */ #define CPUTS(outstr) cputs(CC_MOTION_SENSE, outstr) #define CPRINTS(format, args...) cprints(CC_MOTION_SENSE, format, ## args) #define CPRINTF(format, args...) cprintf(CC_MOTION_SENSE, format, ## args) +#ifdef CONFIG_ORIENTATION_SENSOR +/* + * Orientation mode vectors, must match sequential ordering of + * known orientations from enum motionsensor_orientation + */ +const vector_3_t orientation_modes[] = { + [MOTIONSENSE_ORIENTATION_LANDSCAPE] = { 0, -1, 0 }, + [MOTIONSENSE_ORIENTATION_PORTRAIT] = { 1, 0, 0 }, + [MOTIONSENSE_ORIENTATION_UPSIDE_DOWN_PORTRAIT] = { -1, 0, 0 }, + [MOTIONSENSE_ORIENTATION_UPSIDE_DOWN_LANDSCAPE] = { 0, 1, 0 }, +}; +#endif + /* * Sampling interval for measuring acceleration and calculating lid angle. */ @@ -711,6 +725,115 @@ static int motion_sense_process(struct motion_sensor_t *sensor, return ret; } +#ifdef CONFIG_ORIENTATION_SENSOR +enum motionsensor_orientation motion_sense_remap_orientation( + const struct motion_sensor_t *s, + enum motionsensor_orientation orientation) +{ + enum motionsensor_orientation rotated_orientation; + const vector_3_t *orientation_v; + vector_3_t rotated_orientation_v; + + if (orientation == MOTIONSENSE_ORIENTATION_UNKNOWN) + return MOTIONSENSE_ORIENTATION_UNKNOWN; + + orientation_v = &orientation_modes[orientation]; + rotate(*orientation_v, *s->rot_standard_ref, rotated_orientation_v); + rotated_orientation = ((2 * rotated_orientation_v[1] + + rotated_orientation_v[0] + 4) % 5); + return rotated_orientation; +} +#endif + +#ifdef CONFIG_GESTURE_DETECTION +static void check_and_queue_gestures(uint32_t *event) +{ +#ifdef CONFIG_ORIENTATION_SENSOR + const struct motion_sensor_t *sensor; +#endif + +#ifdef CONFIG_GESTURE_SW_DETECTION + /* Run gesture recognition engine */ + gesture_calc(event); +#endif +#ifdef CONFIG_GESTURE_SENSOR_BATTERY_TAP + if (*event & CONFIG_GESTURE_TAP_EVENT) { +#ifdef CONFIG_GESTURE_HOST_DETECTION + struct ec_response_motion_sensor_data vector; + + /* + * Send events to the FIFO + * AP is ignoring double tap event, do no wake up and no + * automatic disable. + */ + vector.flags = 0; + vector.activity = MOTIONSENSE_ACTIVITY_DOUBLE_TAP; + vector.state = 1; /* triggered */ + vector.sensor_num = MOTION_SENSE_ACTIVITY_SENSOR_ID; + motion_sense_fifo_add_unit(&vector, NULL, 0); +#endif + CPRINTS("double tap!"); + /* Call board specific function to process tap */ + sensor_board_proc_double_tap(); + } +#endif +#ifdef CONFIG_GESTURE_SIGMO + if (*event & CONFIG_GESTURE_SIGMO_EVENT) { + struct motion_sensor_t *activity_sensor; +#ifdef CONFIG_GESTURE_HOST_DETECTION + struct ec_response_motion_sensor_data vector; + + /* Send events to the FIFO */ + vector.flags = MOTIONSENSE_SENSOR_FLAG_WAKEUP; + vector.activity = MOTIONSENSE_ACTIVITY_SIG_MOTION; + vector.state = 1; /* triggered */ + vector.sensor_num = MOTION_SENSE_ACTIVITY_SENSOR_ID; + motion_sense_fifo_add_unit(&vector, NULL, 0); +#endif + CPRINTS("significant motion"); + /* Disable further detection */ + activity_sensor = &motion_sensors[CONFIG_GESTURE_SIGMO]; + activity_sensor->drv->manage_activity( + activity_sensor, + MOTIONSENSE_ACTIVITY_SIG_MOTION, + 0, NULL); + } +#endif + +#ifdef CONFIG_ORIENTATION_SENSOR + sensor = &motion_sensors[LID_ACCEL]; + if (SENSOR_ACTIVE(sensor) && (sensor->state == SENSOR_INITIALIZED)) { + struct ec_response_motion_sensor_data vector = { + .flags = 0, + .activity = MOTIONSENSE_ACTIVITY_ORIENTATION, + .sensor_num = MOTION_SENSE_ACTIVITY_SENSOR_ID, + }; + + mutex_lock(sensor->mutex); + if (ORIENTATION_CHANGED(sensor) && (GET_ORIENTATION(sensor) != + MOTIONSENSE_ORIENTATION_UNKNOWN)) { + SET_ORIENTATION_UPDATED(sensor); + vector.state = GET_ORIENTATION(sensor); + motion_sense_fifo_add_unit(&vector, NULL, 0); +#ifdef CONFIG_DEBUG_ORIENTATION + { + static const char * const mode_strs[] = { + "Landscape", + "Portrait", + "Inv_Portrait", + "Inv_Landscape", + "Unknown" + }; + CPRINTS(mode_strs[GET_ORIENTATION(sensor)]); + } +#endif + } + mutex_unlock(sensor->mutex); + } +#endif +} +#endif + /* * Motion Sense Task * Requirement: motion_sensors[] are defined in board.c file. @@ -763,55 +886,8 @@ void motion_sense_task(void *u) ready_status |= (1 << i); } } - #ifdef CONFIG_GESTURE_DETECTION -#ifdef CONFIG_GESTURE_SW_DETECTION - /* Run gesture recognition engine */ - gesture_calc(&event); -#endif -#ifdef CONFIG_GESTURE_SENSOR_BATTERY_TAP - if (event & CONFIG_GESTURE_TAP_EVENT) { -#ifdef CONFIG_GESTURE_HOST_DETECTION - struct ec_response_motion_sensor_data vector; - - /* - * Send events to the FIFO - * AP is ignoring double tap event, do no wake up and no - * automatic disable. - */ - vector.flags = 0; - vector.activity = MOTIONSENSE_ACTIVITY_DOUBLE_TAP; - vector.state = 1; /* triggered */ - vector.sensor_num = MOTION_SENSE_ACTIVITY_SENSOR_ID; - motion_sense_fifo_add_unit(&vector, NULL, 0); -#endif - CPRINTS("double tap!"); - /* Call board specific function to process tap */ - sensor_board_proc_double_tap(); - } -#endif -#ifdef CONFIG_GESTURE_SIGMO - if (event & CONFIG_GESTURE_SIGMO_EVENT) { - struct motion_sensor_t *activity_sensor; -#ifdef CONFIG_GESTURE_HOST_DETECTION - struct ec_response_motion_sensor_data vector; - - /* Send events to the FIFO */ - vector.flags = MOTIONSENSE_SENSOR_FLAG_WAKEUP; - vector.activity = MOTIONSENSE_ACTIVITY_SIG_MOTION; - vector.state = 1; /* triggered */ - vector.sensor_num = MOTION_SENSE_ACTIVITY_SENSOR_ID; - motion_sense_fifo_add_unit(&vector, NULL, 0); -#endif - CPRINTS("significant motion"); - /* Disable further detection */ - activity_sensor = &motion_sensors[CONFIG_GESTURE_SIGMO]; - activity_sensor->drv->manage_activity( - activity_sensor, - MOTIONSENSE_ACTIVITY_SIG_MOTION, - 0, NULL); - } -#endif + check_and_queue_gestures(&event); #endif #ifdef CONFIG_LID_ANGLE /* diff --git a/driver/accel_kionix.c b/driver/accel_kionix.c index 7323abf6f0..8697a17d66 100644 --- a/driver/accel_kionix.c +++ b/driver/accel_kionix.c @@ -253,6 +253,12 @@ static int enable_sensor(const struct motion_sensor_t *s, int reg_val) if (ret != EC_SUCCESS) continue; +#ifdef CONFIG_KX022_ORIENTATION_SENSOR + /* Enable tilt orientation mode if lid sensor */ + if ((s->location == MOTIONSENSE_LOC_LID) && (V(s) == 0)) + reg_val |= KX022_CNTL1_TPE; +#endif + /* Enable accelerometer based on reg_val value. */ ret = raw_write8(s->port, s->addr, reg, reg_val | pc1_field); @@ -394,6 +400,55 @@ static int get_offset(const struct motion_sensor_t *s, int16_t *offset, return EC_SUCCESS; } +#ifdef CONFIG_KX022_ORIENTATION_SENSOR +static enum motionsensor_orientation kx022_convert_orientation( + const struct motion_sensor_t *s, + int orientation) +{ + enum motionsensor_orientation res = MOTIONSENSE_ORIENTATION_UNKNOWN; + + switch (orientation) { + case KX022_ORIENT_PORTRAIT: + res = MOTIONSENSE_ORIENTATION_PORTRAIT; + break; + case KX022_ORIENT_INVERT_PORTRAIT: + res = MOTIONSENSE_ORIENTATION_UPSIDE_DOWN_PORTRAIT; + break; + case KX022_ORIENT_LANDSCAPE: + res = MOTIONSENSE_ORIENTATION_LANDSCAPE; + break; + case KX022_ORIENT_INVERT_LANDSCAPE: + res = MOTIONSENSE_ORIENTATION_UPSIDE_DOWN_LANDSCAPE; + break; + default: + break; + } + res = motion_sense_remap_orientation(s, res); + return res; +} + +static int check_orientation_locked(const struct motion_sensor_t *s) +{ + struct kionix_accel_data *data = s->drv_data; + int orientation, raw_orientation; + int ret; + + ret = raw_read8(s->port, s->addr, + KX022_TSCP, &raw_orientation); + if (ret != EC_SUCCESS) + return ret; + + /* mask off up and down events, we don't care about those */ + raw_orientation &= KX022_ORIENT_MASK; + if (raw_orientation && (raw_orientation != data->raw_orientation)) { + data->raw_orientation = raw_orientation; + orientation = kx022_convert_orientation(s, raw_orientation); + SET_ORIENTATION(s, orientation); + } + return ret; +} +#endif + static int read(const struct motion_sensor_t *s, vector_3_t v) { uint8_t acc[6]; @@ -405,6 +460,11 @@ static int read(const struct motion_sensor_t *s, vector_3_t v) reg = KIONIX_XOUT_L(V(s)); mutex_lock(s->mutex); ret = raw_read_multi(s->port, s->addr, reg, acc, 6); +#ifdef CONFIG_KX022_ORIENTATION_SENSOR + if ((s->location == MOTIONSENSE_LOC_LID) && (V(s) == 0) && + (ret == EC_SUCCESS)) + ret = check_orientation_locked(s); +#endif mutex_unlock(s->mutex); if (ret != EC_SUCCESS) diff --git a/driver/accel_kionix.h b/driver/accel_kionix.h index aeac666039..79d6374917 100644 --- a/driver/accel_kionix.h +++ b/driver/accel_kionix.h @@ -30,6 +30,11 @@ struct kionix_accel_data { /* Current resolution of accelerometer. */ int sensor_resolution; int16_t offset[3]; +#ifdef CONFIG_KX022_ORIENTATION_SENSOR + int8_t raw_orientation; + enum motionsensor_orientation orientation; + enum motionsensor_orientation last_orientation; +#endif }; extern const struct accelgyro_drv kionix_accel_drv; @@ -77,4 +82,20 @@ extern const struct accelgyro_drv kionix_accel_drv; extern struct i2c_stress_test_dev kionix_i2c_stress_test_dev; #endif +#ifdef CONFIG_KX022_ORIENTATION_SENSOR +#define ORIENTATION_CHANGED(_sensor) \ + (((struct kionix_accel_data *)(_sensor->drv_data))->orientation != \ + ((struct kionix_accel_data *)(_sensor->drv_data))->last_orientation) + +#define GET_ORIENTATION(_sensor) \ + (((struct kionix_accel_data *)(_sensor->drv_data))->orientation) + +#define SET_ORIENTATION(_sensor, _val) \ + (((struct kionix_accel_data *)(_sensor->drv_data))->orientation = _val) + +#define SET_ORIENTATION_UPDATED(_sensor) \ + (((struct kionix_accel_data *)(_sensor->drv_data))->last_orientation = \ + ((struct kionix_accel_data *)(_sensor->drv_data))->orientation) +#endif + #endif /* __CROS_EC_ACCEL_KIONIX_H */ diff --git a/driver/accel_kx022.h b/driver/accel_kx022.h index 7b1ea89c43..7fd7508395 100644 --- a/driver/accel_kx022.h +++ b/driver/accel_kx022.h @@ -74,6 +74,17 @@ #define KX022_CNTL1_PC1 (1 << 7) #define KX022_CNTL1_WUFE (1 << 1) +#define KX022_CNTL1_TPE (1 << 0) + +/* TSCP orientations */ +#define KX022_ORIENT_PORTRAIT (1 << 2) +#define KX022_ORIENT_INVERT_PORTRAIT (1 << 3) +#define KX022_ORIENT_LANDSCAPE (1 << 4) +#define KX022_ORIENT_INVERT_LANDSCAPE (1 << 5) +#define KX022_ORIENT_MASK (KX022_ORIENT_PORTRAIT | \ + KX022_ORIENT_INVERT_PORTRAIT | \ + KX022_ORIENT_LANDSCAPE | \ + KX022_ORIENT_INVERT_LANDSCAPE) #define KX022_CNTL2_SRST (1 << 7) diff --git a/driver/accelgyro_bmi160.c b/driver/accelgyro_bmi160.c index e63aefcb34..dcba2ae17f 100644 --- a/driver/accelgyro_bmi160.c +++ b/driver/accelgyro_bmi160.c @@ -796,6 +796,16 @@ static int config_interrupt(const struct motion_sensor_t *s) ret = raw_write8(s->port, s->addr, BMI160_INT_TAP_1, BMI160_TAP_TH(s, CONFIG_GESTURE_TAP_THRES_MG)); #endif +#ifdef CONFIG_BMI160_ORIENTATION_SENSOR + /* only use orientation sensor on the lid sensor */ + if (s->location == MOTIONSENSE_LOC_LID) { + ret = raw_write8(s->port, s->addr, BMI160_INT_ORIENT_0, + BMI160_INT_ORIENT_0_INIT_VAL); + ret = raw_write8(s->port, s->addr, BMI160_INT_ORIENT_1, + BMI160_INT_ORIENT_1_INIT_VAL); + } +#endif + /* * Set a 5ms latch to be sure the EC can read the interrupt register * properly, even when it is running more slowly. @@ -819,6 +829,11 @@ static int config_interrupt(const struct motion_sensor_t *s) #endif #ifdef CONFIG_GESTURE_SENSOR_BATTERY_TAP tmp |= BMI160_INT_D_TAP; +#endif +#ifdef CONFIG_BMI160_ORIENTATION_SENSOR + /* enable orientation interrupt for lid sensor only */ + if (s->location == MOTIONSENSE_LOC_LID) + tmp |= BMI160_INT_ORIENT; #endif ret = raw_write8(s->port, s->addr, BMI160_INT_MAP_REG(1), tmp); @@ -859,6 +874,9 @@ static int config_interrupt(const struct motion_sensor_t *s) static int irq_handler(struct motion_sensor_t *s, uint32_t *event) { int interrupt; +#ifdef CONFIG_BMI160_ORIENTATION_SENSOR + int shifted_masked_orientation; +#endif if ((s->type != MOTIONSENSE_TYPE_ACCEL) || (!(*event & CONFIG_ACCELGYRO_BMI160_INT_EVENT))) @@ -873,6 +891,37 @@ static int irq_handler(struct motion_sensor_t *s, uint32_t *event) #ifdef CONFIG_GESTURE_SIGMO if (interrupt & BMI160_SIGMOT_INT) *event |= CONFIG_GESTURE_SIGMO_EVENT; +#endif +#ifdef CONFIG_BMI160_ORIENTATION_SENSOR + shifted_masked_orientation = (interrupt >> 24) & BMI160_ORIENT_XY_MASK; + if (BMI160_GET_DATA(s)->raw_orientation != shifted_masked_orientation) { + enum motionsensor_orientation orientation = + MOTIONSENSE_ORIENTATION_UNKNOWN; + + BMI160_GET_DATA(s)->raw_orientation = + shifted_masked_orientation; + + switch (shifted_masked_orientation) { + case BMI160_ORIENT_PORTRAIT: + orientation = MOTIONSENSE_ORIENTATION_PORTRAIT; + break; + case BMI160_ORIENT_PORTRAIT_INVERT: + orientation = + MOTIONSENSE_ORIENTATION_UPSIDE_DOWN_PORTRAIT; + break; + case BMI160_ORIENT_LANDSCAPE: + orientation = MOTIONSENSE_ORIENTATION_LANDSCAPE; + break; + case BMI160_ORIENT_LANDSCAPE_INVERT: + orientation = + MOTIONSENSE_ORIENTATION_UPSIDE_DOWN_LANDSCAPE; + break; + default: + break; + } + orientation = motion_sense_remap_orientation(s, orientation); + SET_ORIENTATION(s, orientation); + } #endif /* * No need to read the FIFO here, motion sense task is diff --git a/driver/accelgyro_bmi160.h b/driver/accelgyro_bmi160.h index bc31186344..0682d03171 100644 --- a/driver/accelgyro_bmi160.h +++ b/driver/accelgyro_bmi160.h @@ -99,6 +99,12 @@ #define BMI160_S_TAP_INT (1 << 5) #define BMI160_ORIENT_INT (1 << 6) #define BMI160_FLAT_INT (1 << 7) +#define BMI160_ORIENT_XY_MASK 0x30 +#define BMI160_ORIENT_PORTRAIT (0 << 4) +#define BMI160_ORIENT_PORTRAIT_INVERT (1 << 4) +#define BMI160_ORIENT_LANDSCAPE (2 << 4) +#define BMI160_ORIENT_LANDSCAPE_INVERT (3 << 4) + #define BMI160_INT_STATUS_1 0x1d #define BMI160_HIGHG_INT (1 << (2 + 8)) @@ -333,8 +339,15 @@ enum fifo_header { #define BMI160_TAP_TH(_s, _mg) \ (MIN(((_mg) * 1000) / ((_s)->drv->get_range(_s) * 31250), 0x1f)) -#define BMI160_INT_ORIENT_0 0x65 -#define BMI160_INT_ORIENT_1 0x66 +#define BMI160_INT_ORIENT_0 0x65 + +/* No hysterisis, theta block, int on slope > 0.2 or axis > 1.5, symmetrical */ +#define BMI160_INT_ORIENT_0_INIT_VAL 0x48 + +#define BMI160_INT_ORIENT_1 0x66 + +/* no axes remap, no int on up/down, no blocking angle */ +#define BMI160_INT_ORIENT_1_INIT_VAL 0x00 #define BMI160_INT_FLAT_0 0x67 #define BMI160_INT_FLAT_1 0x68 @@ -449,6 +462,12 @@ struct bmi160_drv_data_t { #ifdef CONFIG_MAG_BMI160_BMM150 struct bmm150_private_data compass; #endif +#ifdef CONFIG_BMI160_ORIENTATION_SENSOR + uint8_t raw_orientation; + enum motionsensor_orientation orientation; + enum motionsensor_orientation last_orientation; +#endif + }; #define BMI160_GET_DATA(_s) \ @@ -456,6 +475,22 @@ struct bmi160_drv_data_t { #define BMI160_GET_SAVED_DATA(_s) \ (&BMI160_GET_DATA(_s)->saved_data[(_s)->type]) +#ifdef CONFIG_BMI160_ORIENTATION_SENSOR +#define ORIENTATION_CHANGED(_sensor) \ + (BMI160_GET_DATA(_sensor)->orientation != \ + BMI160_GET_DATA(_sensor)->last_orientation) + +#define GET_ORIENTATION(_sensor) \ + (BMI160_GET_DATA(_sensor)->orientation) + +#define SET_ORIENTATION(_sensor, _val) \ + (BMI160_GET_DATA(_sensor)->orientation = _val) + +#define SET_ORIENTATION_UPDATED(_sensor) \ + (BMI160_GET_DATA(_sensor)->last_orientation = \ + BMI160_GET_DATA(_sensor)->orientation) +#endif + void bmi160_interrupt(enum gpio_signal signal); #ifdef CONFIG_MAG_BMI160_BMM150 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)