diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2015-09-01 15:25:01 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2016-08-25 20:58:03 +0000 |
commit | 01e404fe6de03e89bc301992de4ca11086167f2b (patch) | |
tree | 03c27da32bd6412f287b4d2dddaed210398379bc | |
parent | e91e6a642f996dfdcf172a70e1a7026eb85ab105 (diff) | |
download | chrome-ec-01e404fe6de03e89bc301992de4ca11086167f2b.tar.gz |
UPSTREAM: common: motion: move gesture actions in motion task.
Change the IRQ interface to allow adding events.
Move code to send the lightbar sequence from gesture.c to motion task.
TEST=compile, works on Ryu.
BRANCH=smaug
BUG=chrome-os-partner:44754
Change-Id: I981ea123ebef0e8e3d6aa320eade89f10e83b6fc
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/296822
Reviewed-by: Alec Berg <alecaberg@chromium.org>
(cherry picked from commit bde89ebc203d9d15ede2cefb3eea8511d1fc3b65)
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/370533
-rw-r--r-- | board/samus/board.h | 2 | ||||
-rw-r--r-- | common/gesture.c | 11 | ||||
-rw-r--r-- | common/motion_sense.c | 19 | ||||
-rw-r--r-- | include/accelgyro.h | 4 | ||||
-rw-r--r-- | include/config.h | 4 | ||||
-rw-r--r-- | include/gesture.h | 4 |
6 files changed, 26 insertions, 18 deletions
diff --git a/board/samus/board.h b/board/samus/board.h index 463a76be92..260a40bcd6 100644 --- a/board/samus/board.h +++ b/board/samus/board.h @@ -200,6 +200,8 @@ 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/common/gesture.c b/common/gesture.c index 4c155f032a..d8b3383319 100644 --- a/common/gesture.c +++ b/common/gesture.c @@ -297,19 +297,14 @@ static void gesture_chipset_suspend(void) DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, gesture_chipset_suspend, GESTURE_HOOK_PRIO); -void gesture_calc(void) +void gesture_calc(uint32_t *event) { /* Only check for gesture if lid is closed and tap detection is on */ if (!tap_detection || lid_is_open()) return; - if (gesture_tap_for_battery()) { - CPRINTS("Double Tap!"); - lightbar_sequence(LIGHTBAR_TAP); - - /* Don't need to run motion sense task for a while */ - task_wait_event(500 * MSEC); - } + if (gesture_tap_for_battery()) + *event |= CONFIG_GESTURE_TAP_EVENT; } /*****************************************************************************/ diff --git a/common/motion_sense.c b/common/motion_sense.c index 737a7b35ac..fcc28b467d 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -15,6 +15,7 @@ #include "host_command.h" #include "hwtimer.h" #include "lid_angle.h" +#include "lightbar.h" #include "math_util.h" #include "mkbp_event.h" #include "motion_sense.h" @@ -459,14 +460,14 @@ static int motion_sense_read(struct motion_sensor_t *sensor) } static int motion_sense_process(struct motion_sensor_t *sensor, - uint32_t event, + uint32_t *event, const timestamp_t *ts, int *flush_needed) { int ret = EC_SUCCESS; #ifdef CONFIG_ACCEL_INTERRUPTS - if ((event & TASK_EVENT_MOTION_INTERRUPT_MASK) && + if ((*event & TASK_EVENT_MOTION_INTERRUPT_MASK) && (sensor->drv->irq_handler != NULL)) { sensor->drv->irq_handler(sensor, event); sensor->last_collection = ts->le.lo; @@ -490,7 +491,7 @@ static int motion_sense_process(struct motion_sensor_t *sensor, } else { ret = EC_ERROR_BUSY; } - if (event & TASK_EVENT_MOTION_FLUSH_PENDING) { + if (*event & TASK_EVENT_MOTION_FLUSH_PENDING) { int flush_pending; flush_pending = atomic_read_clear(&sensor->flush_pending); for (; flush_pending > 0; flush_pending--) { @@ -564,7 +565,7 @@ void motion_sense_task(void) } ts_begin_task = get_time(); - ret = motion_sense_process(sensor, event, + ret = motion_sense_process(sensor, &event, &ts_begin_task, &fifo_flush_needed); if (ret != EC_SUCCESS) @@ -573,9 +574,17 @@ void motion_sense_task(void) } } +#ifdef CONFIG_GESTURE_DETECTION #ifdef CONFIG_GESTURE_SW_DETECTION /* Run gesture recognition engine */ - gesture_calc(); + gesture_calc(&event); +#endif +#ifdef CONFIG_GESTURE_SENSOR_BATTERY_TAP + if (event & CONFIG_GESTURE_TAP_EVENT) { + CPRINTS("double tap!"); + lightbar_sequence(LIGHTBAR_TAP); + } +#endif #endif #ifdef CONFIG_LID_ANGLE /* diff --git a/include/accelgyro.h b/include/accelgyro.h index 46ab68d855..756c2e0e9d 100644 --- a/include/accelgyro.h +++ b/include/accelgyro.h @@ -104,9 +104,9 @@ struct accelgyro_drv { * handler for interrupts triggered by the sensor: it runs in task and * process the events that triggered an interrupt. * @s Pointer to sensor data. - * @event Event to process. + * @event Event to process. May add add other events for the next processor. */ - int (*irq_handler)(struct motion_sensor_t *s, uint32_t event); + int (*irq_handler)(struct motion_sensor_t *s, uint32_t *event); #endif #ifdef CONFIG_ACCEL_FIFO /** diff --git a/include/config.h b/include/config.h index 4f3a9222d2..3a3e37512b 100644 --- a/include/config.h +++ b/include/config.h @@ -664,7 +664,7 @@ /* Sensor sampling interval for gesture recognition */ #undef CONFIG_GESTURE_SAMPLING_INTERVAL_MS -/* Which sensor to look for gesture recognition */ +/* Which sensor to look for battery tap recognition */ #undef CONFIG_GESTURE_SENSOR_BATTERY_TAP /* @@ -686,6 +686,8 @@ #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 /* Do we want to detect the lid angle? */ #undef CONFIG_LID_ANGLE diff --git a/include/gesture.h b/include/gesture.h index d98dc8cdf8..d480794758 100644 --- a/include/gesture.h +++ b/include/gesture.h @@ -9,9 +9,9 @@ #define __CROS_EC_GESTURE_H /** - * Run gesture detection engine. + * Run gesture detection engine. Modify the event flag when gestures are found. */ -void gesture_calc(void); +void gesture_calc(uint32_t *event); /* gesture hooks are triggered after the motion sense hooks. */ #define GESTURE_HOOK_PRIO (MOTION_SENSE_HOOK_PRIO + 10) |