summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2018-09-04 10:10:04 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-03-20 19:51:25 -0700
commit4b9a3c0cc9cee9ed85ba18dd2f9c23e90ca051fc (patch)
tree3f8db048371f529ac0ffff71553c8c8bd378cfe0
parent8fb1c6c52510438f77378f08d2b6d881da48dd3f (diff)
downloadchrome-ec-4b9a3c0cc9cee9ed85ba18dd2f9c23e90ca051fc.tar.gz
motion: Define macros for custom events
Define macros to define custom events used by sensor interrupt handlers. Remove CONFIG_ for activity events. BUG=none BRANCH=none TEST=compile, sensors work on eve. Change-Id: I08ef6ed2a004466ebc5f7650d6952a150b9de713 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1272189 Reviewed-by: Jett Rink <jettrink@chromium.org>
-rw-r--r--board/aleena/board.h3
-rw-r--r--board/ampton/board.h6
-rw-r--r--board/arcada_ish/board.h3
-rw-r--r--board/atlas/board.h3
-rw-r--r--board/bloog/board.h4
-rw-r--r--board/bobba/board.h7
-rw-r--r--board/cheza/board.h3
-rw-r--r--board/coral/board.h3
-rw-r--r--board/eve/board.h7
-rw-r--r--board/flapjack/board.h6
-rw-r--r--board/fleex/board.h3
-rw-r--r--board/grunt/board.h3
-rw-r--r--board/hatch/board.h3
-rw-r--r--board/kukui/board.h6
-rw-r--r--board/meep/board.h4
-rw-r--r--board/nami/board.h3
-rw-r--r--board/nautilus/board.h3
-rw-r--r--board/nocturne/board.h6
-rw-r--r--board/phaser/board.h3
-rw-r--r--board/poppy/board.h3
-rw-r--r--board/rainier/board.h3
-rw-r--r--board/rammus/board.h3
-rw-r--r--board/reef/board.h3
-rw-r--r--board/reef_mchp/board.h3
-rw-r--r--board/samus/board.h2
-rw-r--r--board/scarlet/board.h6
-rw-r--r--board/yorp/board.h4
-rw-r--r--common/gesture.c3
-rw-r--r--common/motion_sense.c6
-rw-r--r--driver/accelgyro_bmi160.c6
-rw-r--r--include/config.h6
-rw-r--r--include/motion_sense.h39
32 files changed, 114 insertions, 52 deletions
diff --git a/board/aleena/board.h b/board/aleena/board.h
index 3c5cf048b7..62f2f475c8 100644
--- a/board/aleena/board.h
+++ b/board/aleena/board.h
@@ -33,7 +33,8 @@
/* Motion sensing drivers */
#define CONFIG_ACCELGYRO_BMI160
-#define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(4)
+#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
#define CONFIG_ACCEL_INTERRUPTS
#define CONFIG_ACCEL_KX022
#define CONFIG_CMD_ACCELS
diff --git a/board/ampton/board.h b/board/ampton/board.h
index 35e8d8a8de..58b4844402 100644
--- a/board/ampton/board.h
+++ b/board/ampton/board.h
@@ -46,8 +46,10 @@
#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL
#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL
-#define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(1 << 2)
-#define CONFIG_SYNC_INT_EVENT TASK_EVENT_CUSTOM(1 << 3)
+#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
+#define CONFIG_SYNC_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(VSYNC)
/* Keyboard backlight is unimplemented in hardware */
#undef CONFIG_PWM
diff --git a/board/arcada_ish/board.h b/board/arcada_ish/board.h
index 83ddaec08d..54676661e4 100644
--- a/board/arcada_ish/board.h
+++ b/board/arcada_ish/board.h
@@ -40,7 +40,8 @@
/* Sensors without hardware FIFO are in forced mode */
#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << BASE_ACCEL)
-#define CONFIG_ACCEL_LSM6DSM_INT_EVENT TASK_EVENT_CUSTOM(1 << 2)
+#define CONFIG_ACCEL_LSM6DSM_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(LID_ACCEL)
#define CONFIG_MKBP_EVENT
#define CONFIG_MKBP_USE_HECI
diff --git a/board/atlas/board.h b/board/atlas/board.h
index 756883e669..418ed5e923 100644
--- a/board/atlas/board.h
+++ b/board/atlas/board.h
@@ -123,7 +123,8 @@
#define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO / 3)
#define CONFIG_ACCEL_INTERRUPTS
#define CONFIG_ACCELGYRO_BMI160
-#define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(4)
+#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
/* USB */
#define CONFIG_USB_PD_ALT_MODE
diff --git a/board/bloog/board.h b/board/bloog/board.h
index f106c29dea..56b6144898 100644
--- a/board/bloog/board.h
+++ b/board/bloog/board.h
@@ -47,7 +47,9 @@
#define OCTOPUS_BATT_FUEL_LOW_LED 10
-#define CONFIG_ACCEL_LSM6DSM_INT_EVENT TASK_EVENT_CUSTOM(4)
+#define CONFIG_ACCEL_LSM6DSM_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(LID_ACCEL)
+
#ifndef __ASSEMBLER__
#include "gpio_signal.h"
diff --git a/board/bobba/board.h b/board/bobba/board.h
index 0beed83d29..1c508a2039 100644
--- a/board/bobba/board.h
+++ b/board/bobba/board.h
@@ -32,8 +32,11 @@
#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_ACCEL)
/* Motion Sense Task Events */
-#define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(1 << 2)
-#define CONFIG_SYNC_INT_EVENT TASK_EVENT_CUSTOM(1 << 3)
+#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
+
+#define CONFIG_SYNC_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(VSYNC)
#define CONFIG_LID_ANGLE
#define CONFIG_LID_ANGLE_UPDATE
diff --git a/board/cheza/board.h b/board/cheza/board.h
index 174cce0c15..63aa937f0f 100644
--- a/board/cheza/board.h
+++ b/board/cheza/board.h
@@ -129,7 +129,8 @@
/* Sensors */
#define CONFIG_ACCELGYRO_BMI160
#define CONFIG_ACCEL_INTERRUPTS
-#define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(4)
+#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(LID_ACCEL)
#define CONFIG_ACCEL_FIFO 512
#define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO / 3)
#define CONFIG_CMD_ACCELS
diff --git a/board/coral/board.h b/board/coral/board.h
index 5a60c51aea..db16a7d538 100644
--- a/board/coral/board.h
+++ b/board/coral/board.h
@@ -197,7 +197,8 @@
#define CONFIG_MKBP_USE_HOST_EVENT
#define CONFIG_ACCELGYRO_BMI160
#define CONFIG_ACCEL_INTERRUPTS
-#define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(4)
+#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
#define CONFIG_MAG_CALIBRATE
#define CONFIG_ACCEL_KX022
#define CONFIG_LID_ANGLE
diff --git a/board/eve/board.h b/board/eve/board.h
index 466376fe60..5eed5b7613 100644
--- a/board/eve/board.h
+++ b/board/eve/board.h
@@ -117,7 +117,8 @@
#define CONFIG_MKBP_USE_HOST_EVENT
#define CONFIG_ACCEL_KXCJ9
#define CONFIG_ALS_SI114X 0x40
-#define CONFIG_ALS_SI114X_INT_EVENT TASK_EVENT_CUSTOM(8)
+#define CONFIG_ALS_SI114X_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(LID_LIGHT)
#define CONFIG_ALS_SI114X_POLLING
#define CONFIG_TEMP_SENSOR
#define CONFIG_TEMP_SENSOR_BD99992GW
@@ -125,7 +126,8 @@
#define CONFIG_ACCELGYRO_BMI160
#define CONFIG_MAG_BMI160_BMM150
#define CONFIG_ACCEL_INTERRUPTS
-#define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(4)
+#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
#define CONFIG_ACCELGYRO_SEC_ADDR BMM150_ADDR0 /* 8-bit address */
#define CONFIG_ACCELGYRO_BMI160_INT2_OUTPUT /* Unused */
#define CONFIG_MAG_CALIBRATE
@@ -149,7 +151,6 @@
#define CONFIG_GESTURE_TAP_MAX_INTERSTICE_T 500
#define CONFIG_GESTURE_DETECTION_MASK \
(1 << CONFIG_GESTURE_SENSOR_BATTERY_TAP)
-#define CONFIG_GESTURE_TAP_EVENT TASK_EVENT_CUSTOM(1024)
/* USB */
#define CONFIG_USB_CHARGER
diff --git a/board/flapjack/board.h b/board/flapjack/board.h
index fc40c4b399..8ca624a1f2 100644
--- a/board/flapjack/board.h
+++ b/board/flapjack/board.h
@@ -88,7 +88,8 @@
#ifdef SECTION_IS_RW
#define CONFIG_ACCELGYRO_BMI160
#define CONFIG_ACCEL_INTERRUPTS
-#define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(4)
+#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(LID_ACCEL)
#define CONFIG_ALS
#define ALS_COUNT 1
#define CONFIG_ALS_OPT3001
@@ -98,7 +99,8 @@
/* Camera VSYNC */
#define CONFIG_SYNC
#define CONFIG_SYNC_COMMAND
-#define CONFIG_SYNC_INT_EVENT TASK_EVENT_CUSTOM(5)
+#define CONFIG_SYNC_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(VSYNC)
#endif /* SECTION_IS_RW */
/* To be able to indicate the device is in tablet mode. */
diff --git a/board/fleex/board.h b/board/fleex/board.h
index 2d57b48fd9..9184f85bd6 100644
--- a/board/fleex/board.h
+++ b/board/fleex/board.h
@@ -42,7 +42,8 @@
#define CONFIG_STEINHART_HART_3V3_13K7_47K_4050B
#define CONFIG_STEINHART_HART_3V3_51K1_47K_4050B
-#define CONFIG_ACCEL_LSM6DSM_INT_EVENT TASK_EVENT_CUSTOM(4)
+#define CONFIG_ACCEL_LSM6DSM_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
#ifndef __ASSEMBLER__
#include "gpio_signal.h"
diff --git a/board/grunt/board.h b/board/grunt/board.h
index d66f212340..4e482c8a87 100644
--- a/board/grunt/board.h
+++ b/board/grunt/board.h
@@ -47,7 +47,8 @@
/* Motion sensing drivers */
#define CONFIG_ACCELGYRO_BMI160
-#define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(4)
+#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
#define CONFIG_ACCEL_INTERRUPTS
#define CONFIG_ACCEL_KX022
#define CONFIG_CMD_ACCELS
diff --git a/board/hatch/board.h b/board/hatch/board.h
index 65af61ae74..ee4ea2fd1f 100644
--- a/board/hatch/board.h
+++ b/board/hatch/board.h
@@ -33,7 +33,8 @@
/* BMI160 Base accel/gyro */
#define CONFIG_ACCEL_INTERRUPTS
#define CONFIG_ACCELGYRO_BMI160
-#define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(4)
+#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
#define CONFIG_ACCELGYRO_BMI160_INT2_OUTPUT
/* BMA253 Lid accel */
#define CONFIG_ACCEL_BMA255
diff --git a/board/kukui/board.h b/board/kukui/board.h
index 01677e04da..40d1fc3930 100644
--- a/board/kukui/board.h
+++ b/board/kukui/board.h
@@ -89,12 +89,14 @@
#define CONFIG_MAG_CALIBRATE
#define CONFIG_ACCELGYRO_BMI160
#define CONFIG_ACCEL_INTERRUPTS
-#define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(4)
+#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(LID_ACCEL)
/* Camera VSYNC */
#define CONFIG_SYNC
#define CONFIG_SYNC_COMMAND
-#define CONFIG_SYNC_INT_EVENT TASK_EVENT_CUSTOM(5)
+#define CONFIG_SYNC_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(VSYNC)
#endif /* SECTION_IS_RW */
/* To be able to indicate the device is in tablet mode. */
diff --git a/board/meep/board.h b/board/meep/board.h
index 3932468e7b..7515a2ea40 100644
--- a/board/meep/board.h
+++ b/board/meep/board.h
@@ -47,7 +47,9 @@
#define OCTOPUS_BATT_FUEL_LOW_LED 10
-#define CONFIG_ACCEL_LSM6DSM_INT_EVENT TASK_EVENT_CUSTOM(4)
+#define CONFIG_ACCEL_LSM6DSM_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
+
#ifndef __ASSEMBLER__
#include "gpio_signal.h"
diff --git a/board/nami/board.h b/board/nami/board.h
index 81447f2c69..157ea5554b 100644
--- a/board/nami/board.h
+++ b/board/nami/board.h
@@ -133,7 +133,8 @@
#define CONFIG_MKBP_EVENT
#define CONFIG_MKBP_USE_HOST_EVENT
#define CONFIG_ACCELGYRO_BMI160
-#define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(4)
+#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
#define CONFIG_ACCELGYRO_BMI160_INT2_OUTPUT
#define CONFIG_ACCEL_BMA255
#define CONFIG_ACCEL_KX022
diff --git a/board/nautilus/board.h b/board/nautilus/board.h
index c64a33a724..acbed5897e 100644
--- a/board/nautilus/board.h
+++ b/board/nautilus/board.h
@@ -113,7 +113,8 @@
#define CONFIG_MKBP_EVENT
#define CONFIG_MKBP_USE_HOST_EVENT
#define CONFIG_ACCELGYRO_BMI160
-#define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(4)
+#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
#define CONFIG_ACCELGYRO_BMI160_INT2_OUTPUT
#define CONFIG_ACCEL_BMA255
#define CONFIG_ACCEL_INTERRUPTS
diff --git a/board/nocturne/board.h b/board/nocturne/board.h
index 15464dfba7..99984ae3ea 100644
--- a/board/nocturne/board.h
+++ b/board/nocturne/board.h
@@ -98,9 +98,11 @@
#define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO / 3)
#define CONFIG_ACCEL_INTERRUPTS
#define CONFIG_ACCELGYRO_BMI160
-#define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(4)
+#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(LID_ACCEL)
#define CONFIG_SYNC
-#define CONFIG_SYNC_INT_EVENT TASK_EVENT_CUSTOM(8)
+#define CONFIG_SYNC_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(VSYNC)
#define CONFIG_TEMP_SENSOR
#define CONFIG_TEMP_SENSOR_BD99992GW
#define CONFIG_THERMISTOR_NCP15WB
diff --git a/board/phaser/board.h b/board/phaser/board.h
index 91d3d793ad..56e07ee863 100644
--- a/board/phaser/board.h
+++ b/board/phaser/board.h
@@ -40,7 +40,8 @@
#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL
#define CONFIG_DYNAMIC_MOTION_SENSOR_COUNT
-#define CONFIG_ACCEL_LSM6DSM_INT_EVENT TASK_EVENT_CUSTOM(4)
+#define CONFIG_ACCEL_LSM6DSM_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
#ifndef __ASSEMBLER__
diff --git a/board/poppy/board.h b/board/poppy/board.h
index cf030f0c91..92d15ce0f7 100644
--- a/board/poppy/board.h
+++ b/board/poppy/board.h
@@ -126,7 +126,8 @@
#define CONFIG_ACCELGYRO_BMI160
#define CONFIG_MAG_BMI160_BMM150
#define CONFIG_ACCEL_INTERRUPTS
-#define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(4)
+#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(LID_ACCEL)
#define CONFIG_ACCELGYRO_SEC_ADDR BMM150_ADDR0 /* 8-bit address */
#define CONFIG_MAG_CALIBRATE
/* Lower maximal ODR to 100Hz */
diff --git a/board/rainier/board.h b/board/rainier/board.h
index 2fc5ac63a1..3b31b2079d 100644
--- a/board/rainier/board.h
+++ b/board/rainier/board.h
@@ -69,7 +69,8 @@
/* Motion Sensors */
#define CONFIG_ACCELGYRO_BMI160
#define CONFIG_ACCEL_INTERRUPTS
-#define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(4)
+#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(LID_ACCEL)
#define CONFIG_BARO_BMP280
/* To be able to indicate the device is in tablet mode. */
diff --git a/board/rammus/board.h b/board/rammus/board.h
index 29209ec811..da8f311fca 100644
--- a/board/rammus/board.h
+++ b/board/rammus/board.h
@@ -110,7 +110,8 @@
#define CONFIG_MKBP_EVENT
#define CONFIG_MKBP_USE_HOST_EVENT
#define CONFIG_ACCELGYRO_BMI160
-#define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(4)
+#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
#define CONFIG_ACCELGYRO_BMI160_INT2_OUTPUT
#define CONFIG_ACCEL_BMA255
#define CONFIG_ACCEL_INTERRUPTS
diff --git a/board/reef/board.h b/board/reef/board.h
index 83facd8c04..b166d24c8b 100644
--- a/board/reef/board.h
+++ b/board/reef/board.h
@@ -193,7 +193,8 @@
#define CONFIG_MKBP_USE_HOST_EVENT
#define CONFIG_ACCELGYRO_BMI160
#define CONFIG_ACCEL_INTERRUPTS
-#define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(4)
+#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
#define CONFIG_MAG_BMI160_BMM150
#define CONFIG_ACCELGYRO_SEC_ADDR BMM150_ADDR0 /* 8-bit address */
#define CONFIG_MAG_CALIBRATE
diff --git a/board/reef_mchp/board.h b/board/reef_mchp/board.h
index 7b6cdfbbe8..1250689d0d 100644
--- a/board/reef_mchp/board.h
+++ b/board/reef_mchp/board.h
@@ -200,7 +200,8 @@
#define CONFIG_MKBP_USE_HOST_EVENT
#define CONFIG_ACCELGYRO_BMI160
#define CONFIG_ACCEL_INTERRUPTS
-#define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(4)
+#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
#define CONFIG_MAG_BMI160_BMM150
#define CONFIG_ACCELGYRO_SEC_ADDR BMM150_ADDR0 /* 8-bit address */
#define CONFIG_MAG_CALIBRATE
diff --git a/board/samus/board.h b/board/samus/board.h
index 1a5e11667f..59c3e8ca4d 100644
--- a/board/samus/board.h
+++ b/board/samus/board.h
@@ -214,8 +214,6 @@ void set_pp5000_in_g3(int mask, int enable);
#define CONFIG_GESTURE_TAP_INNER_WINDOW_T 30
#define CONFIG_GESTURE_TAP_MIN_INTERSTICE_T 120
#define CONFIG_GESTURE_TAP_MAX_INTERSTICE_T 500
-/* event 2 to 9 are reserved for hardware interrupt */
-#define CONFIG_GESTURE_TAP_EVENT TASK_EVENT_CUSTOM(1024)
#define CONFIG_LID_ANGLE_SENSOR_BASE 0
#define CONFIG_LID_ANGLE_SENSOR_LID 1
diff --git a/board/scarlet/board.h b/board/scarlet/board.h
index e440ef4948..1a682b93ba 100644
--- a/board/scarlet/board.h
+++ b/board/scarlet/board.h
@@ -86,12 +86,14 @@
/* Motion Sensors */
#define CONFIG_ACCELGYRO_BMI160
#define CONFIG_ACCEL_INTERRUPTS
-#define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(4)
+#define CONFIG_ACCELGYRO_BMI160_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(LID_ACCEL)
/* Camera VSYNC */
#define CONFIG_SYNC
#define CONFIG_SYNC_COMMAND
-#define CONFIG_SYNC_INT_EVENT TASK_EVENT_CUSTOM(5)
+#define CONFIG_SYNC_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(VSYNC)
/* To be able to indicate the device is in tablet mode. */
#define CONFIG_TABLET_MODE
diff --git a/board/yorp/board.h b/board/yorp/board.h
index b84785c7bd..5a1e152b2a 100644
--- a/board/yorp/board.h
+++ b/board/yorp/board.h
@@ -39,7 +39,9 @@
#define CONFIG_STEINHART_HART_3V3_13K7_47K_4050B
#define CONFIG_STEINHART_HART_3V3_51K1_47K_4050B
-#define CONFIG_ACCEL_LSM6DSM_INT_EVENT TASK_EVENT_CUSTOM(4)
+#define CONFIG_ACCEL_LSM6DSM_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
+
#ifndef __ASSEMBLER__
#include "gpio_signal.h"
diff --git a/common/gesture.c b/common/gesture.c
index 8d9c744cf7..e4fb79c5bd 100644
--- a/common/gesture.c
+++ b/common/gesture.c
@@ -304,7 +304,8 @@ void gesture_calc(uint32_t *event)
return;
if (gesture_tap_for_battery())
- *event |= CONFIG_GESTURE_TAP_EVENT;
+ *event |= TASK_EVENT_MOTION_ACTIVITY_INTERRUPT(
+ MOTIONSENSE_ACTIVITY_DOUBLE_TAP);
}
/*****************************************************************************/
diff --git a/common/motion_sense.c b/common/motion_sense.c
index 7b9d66204c..e0332ae073 100644
--- a/common/motion_sense.c
+++ b/common/motion_sense.c
@@ -832,7 +832,8 @@ static void check_and_queue_gestures(uint32_t *event)
gesture_calc(event);
#endif
#ifdef CONFIG_GESTURE_SENSOR_BATTERY_TAP
- if (*event & CONFIG_GESTURE_TAP_EVENT) {
+ if (*event & TASK_EVENT_MOTION_ACTIVITY_INTERRUPT(
+ MOTIONSENSE_ACTIVITY_DOUBLE_TAP)) {
#ifdef CONFIG_GESTURE_HOST_DETECTION
struct ec_response_motion_sensor_data vector;
@@ -853,7 +854,8 @@ static void check_and_queue_gestures(uint32_t *event)
}
#endif
#ifdef CONFIG_GESTURE_SIGMO
- if (*event & CONFIG_GESTURE_SIGMO_EVENT) {
+ if (*event & TASK_EVENT_MOTION_ACTIVITY_INTERRUPT(
+ MOTIONSENSE_ACTIVITY_SIG_MOTION)) {
struct motion_sensor_t *activity_sensor;
#ifdef CONFIG_GESTURE_HOST_DETECTION
struct ec_response_motion_sensor_data vector;
diff --git a/driver/accelgyro_bmi160.c b/driver/accelgyro_bmi160.c
index f15a9a3dd0..b2a59cb17c 100644
--- a/driver/accelgyro_bmi160.c
+++ b/driver/accelgyro_bmi160.c
@@ -1157,11 +1157,13 @@ static int irq_handler(struct motion_sensor_t *s, uint32_t *event)
#ifdef CONFIG_GESTURE_SENSOR_BATTERY_TAP
if (interrupt & BMI160_D_TAP_INT)
- *event |= CONFIG_GESTURE_TAP_EVENT;
+ *event |= TASK_EVENT_MOTION_ACTIVITY_INTERRUPT(
+ MOTIONSENSE_ACTIVITY_DOUBLE_TAP);
#endif
#ifdef CONFIG_GESTURE_SIGMO
if (interrupt & BMI160_SIGMOT_INT)
- *event |= CONFIG_GESTURE_SIGMO_EVENT;
+ *event |= TASK_EVENT_MOTION_ACTIVITY_INTERRUPT(
+ MOTIONSENSE_ACTIVITY_SIG_MOTION);
#endif
#ifdef CONFIG_ACCEL_FIFO
if (interrupt & (BMI160_FWM_INT | BMI160_FFULL_INT))
diff --git a/include/config.h b/include/config.h
index c4428c8ea9..b53c48cfc1 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1745,9 +1745,6 @@
#undef CONFIG_GESTURE_TAP_MAX_INTERSTICE_T
#undef CONFIG_GESTURE_TAP_THRES_MG
-/* Event generated when battery tap is detected */
-#undef CONFIG_GESTURE_TAP_EVENT
-
/* Which sensor to look for significant motion activity */
#undef CONFIG_GESTURE_SIGMO
@@ -1759,9 +1756,6 @@
#undef CONFIG_GESTURE_SIGMO_PROOF_MS
#undef CONFIG_GESTURE_SIGMO_SKIP_MS
#undef CONFIG_GESTURE_SIGMO_THRES_MG
-/* Event generated when significant motion is detected. */
-
-#undef CONFIG_GESTURE_SIGMO_EVENT
/*
* Delay between power on and configuring GPIOs.
diff --git a/include/motion_sense.h b/include/motion_sense.h
index 2291784c1c..0e6f7aa342 100644
--- a/include/motion_sense.h
+++ b/include/motion_sense.h
@@ -36,11 +36,39 @@ enum sensor_config {
#define SENSOR_ACTIVE_S0_S3 (SENSOR_ACTIVE_S3 | SENSOR_ACTIVE_S0)
#define SENSOR_ACTIVE_S0_S3_S5 (SENSOR_ACTIVE_S0_S3 | SENSOR_ACTIVE_S5)
-/* Events the motion sense task may have to process.*/
-#define TASK_EVENT_MOTION_FLUSH_PENDING TASK_EVENT_CUSTOM(1)
-#define TASK_EVENT_MOTION_ODR_CHANGE TASK_EVENT_CUSTOM(2)
-/* Next 8 events for sensor interrupt lines */
-#define TASK_EVENT_MOTION_INTERRUPT_MASK (0xff << 2)
+
+/*
+ * Events layout:
+ * 0 8 10
+ * +-----------------------+---------------+----------------------------
+ * | hardware interrupts | internal ints | activity interrupts
+ * +-----------------------+---------------+----------------------------
+ */
+
+/* First 8 events for sensor interrupt lines */
+#define TASK_EVENT_MOTION_INTERRUPT_NUM 8
+#define TASK_EVENT_MOTION_INTERRUPT_MASK \
+ ((1 << TASK_EVENT_MOTION_INTERRUPT_NUM) - 1)
+#define TASK_EVENT_MOTION_SENSOR_INTERRUPT(_sensor_id) \
+ BUILD_CHECK_INLINE( \
+ TASK_EVENT_CUSTOM(1 << (_sensor_id)), \
+ _sensor_id < TASK_EVENT_MOTION_INTERRUPT_NUM)
+
+/* Internal events to motion sense task.*/
+#define TASK_EVENT_MOTION_FIRST_INTERNAL_EVENT TASK_EVENT_MOTION_INTERRUPT_NUM
+#define TASK_EVENT_MOTION_INTERNAL_EVENT_NUM 2
+#define TASK_EVENT_MOTION_FLUSH_PENDING \
+ TASK_EVENT_CUSTOM(1 << TASK_EVENT_MOTION_FIRST_INTERNAL_EVENT)
+#define TASK_EVENT_MOTION_ODR_CHANGE \
+ TASK_EVENT_CUSTOM(1 << (TASK_EVENT_MOTION_FIRST_INTERNAL_EVENT + 1))
+
+/* Activity events */
+#define TASK_EVENT_MOTION_FIRST_SW_EVENT \
+ (TASK_EVENT_MOTION_INTERRUPT_NUM + TASK_EVENT_MOTION_INTERNAL_EVENT_NUM)
+#define TASK_EVENT_MOTION_ACTIVITY_INTERRUPT(_activity_id) \
+ (TASK_EVENT_CUSTOM( \
+ 1 << (TASK_EVENT_MOTION_FIRST_SW_EVENT + (_activity_id))))
+
#define ROUND_UP_FLAG (1 << 31)
#define BASE_ODR(_odr) ((_odr) & ~ROUND_UP_FLAG)
@@ -168,6 +196,7 @@ struct motion_sensor_t {
/* Defined at board level. */
extern struct motion_sensor_t motion_sensors[];
+
#ifdef CONFIG_DYNAMIC_MOTION_SENSOR_COUNT
extern unsigned motion_sensor_count;
#else