summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2021-03-22 17:30:39 -0700
committerCommit Bot <commit-bot@chromium.org>2021-03-29 19:07:38 +0000
commit4c84afb1cdb1d1da8155f1bc30ea93ecd7b8dd4b (patch)
tree21a4edcf7386e94e950acb588540f7f779b9d79e /common
parentf4b27032e1c508b693bba1f2d6572ad14d42f319 (diff)
downloadchrome-ec-4c84afb1cdb1d1da8155f1bc30ea93ecd7b8dd4b.tar.gz
common: motion_sense: Prevent on/off body from waking up device
Introduce a new flag: BYPASS_FIFO to raise an interrupt to the AP when an event is sent. It is not as strong as WAKEUP, as it does not wake up the AP. BYPASS_FIFO must be set when WAKEUP is set. It is applied to sync sensor as well as gesture/activity sensor. BUG=b:123434029 BRANCH=trogdor TEST=Compile Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Change-Id: Id5aba71e6d11ef31f7fa2c67ba2e07178d088b1b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2780834 Reviewed-by: Ching-Kang Yen <chingkang@chromium.org> Tested-by: Ching-Kang Yen <chingkang@chromium.org> Commit-Queue: Ching-Kang Yen <chingkang@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/motion_sense.c14
-rw-r--r--common/motion_sense_fifo.c18
2 files changed, 25 insertions, 7 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c
index efb6552078..4dd8b6cc13 100644
--- a/common/motion_sense.c
+++ b/common/motion_sense.c
@@ -777,15 +777,14 @@ static void check_and_queue_gestures(uint32_t *event)
if (IS_ENABLED(CONFIG_GESTURE_HOST_DETECTION)) {
struct ec_response_motion_sensor_data vector;
+ vector.flags = MOTIONSENSE_SENSOR_FLAG_BYPASS_FIFO;
/*
* Send events to the FIFO
* AP is ignoring double tap event, do no wake up and no
* automatic disable.
*/
if (IS_ENABLED(CONFIG_GESTURE_SENSOR_DOUBLE_TAP_FOR_HOST))
- vector.flags = MOTIONSENSE_SENSOR_FLAG_WAKEUP;
- else
- vector.flags = 0;
+ vector.flags |= MOTIONSENSE_SENSOR_FLAG_WAKEUP;
vector.activity_data.activity =
MOTIONSENSE_ACTIVITY_DOUBLE_TAP;
vector.activity_data.state = 1 /* triggered */;
@@ -805,7 +804,8 @@ static void check_and_queue_gestures(uint32_t *event)
struct ec_response_motion_sensor_data vector;
/* Send events to the FIFO */
- vector.flags = MOTIONSENSE_SENSOR_FLAG_WAKEUP;
+ vector.flags = MOTIONSENSE_SENSOR_FLAG_WAKEUP |
+ MOTIONSENSE_SENSOR_FLAG_BYPASS_FIFO;
vector.activity_data.activity =
MOTIONSENSE_ACTIVITY_SIG_MOTION;
vector.activity_data.state = 1 /* triggered */;
@@ -951,7 +951,7 @@ void motion_sense_task(void *u)
* - we haven't done it for a while.
*/
if (IS_ENABLED(CONFIG_ACCEL_FIFO) &&
- (motion_sense_fifo_wake_up_needed() ||
+ (motion_sense_fifo_bypass_needed() ||
event & (TASK_EVENT_MOTION_ODR_CHANGE |
TASK_EVENT_MOTION_FLUSH_PENDING) ||
motion_sense_fifo_over_thres() ||
@@ -974,8 +974,10 @@ void motion_sense_task(void *u)
sensor_active == SENSOR_ACTIVE_S0) ||
motion_sense_fifo_wake_up_needed()))) {
mkbp_send_event(EC_MKBP_EVENT_SENSOR_FIFO);
- motion_sense_fifo_reset_wake_up_needed();
}
+ if (motion_sense_fifo_bypass_needed())
+ /* wakeup flag is a subset of bypass flag. */
+ motion_sense_fifo_reset_needed_flags();
}
ts_end_task = get_time();
diff --git a/common/motion_sense_fifo.c b/common/motion_sense_fifo.c
index 67fb196bc6..2b697e1f4c 100644
--- a/common/motion_sense_fifo.c
+++ b/common/motion_sense_fifo.c
@@ -64,6 +64,9 @@ static struct timestamp_state next_timestamp[MAX_MOTION_SENSORS];
*/
static uint32_t next_timestamp_initialized;
+/** Need to bypass the FIFO for an important message. */
+static int bypass_needed;
+
/** Need to wake up the AP. */
static int wake_up_needed;
@@ -358,6 +361,16 @@ void motion_sense_fifo_init(void)
online_calibration_init();
}
+int motion_sense_fifo_bypass_needed(void)
+{
+ int res;
+
+ mutex_lock(&g_sensor_mutex);
+ res = bypass_needed;
+ mutex_unlock(&g_sensor_mutex);
+ return res;
+}
+
int motion_sense_fifo_wake_up_needed(void)
{
int res;
@@ -368,10 +381,11 @@ int motion_sense_fifo_wake_up_needed(void)
return res;
}
-void motion_sense_fifo_reset_wake_up_needed(void)
+void motion_sense_fifo_reset_needed_flags(void)
{
mutex_lock(&g_sensor_mutex);
wake_up_needed = 0;
+ bypass_needed = 0;
mutex_unlock(&g_sensor_mutex);
}
@@ -478,6 +492,8 @@ commit_data_end:
*/
for (i = 0; i < fifo_staged.count; i++) {
data = peek_fifo_staged(i);
+ if (data->flags & MOTIONSENSE_SENSOR_FLAG_BYPASS_FIFO)
+ bypass_needed = 1;
if (data->flags & MOTIONSENSE_SENSOR_FLAG_WAKEUP)
wake_up_needed = 1;