summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2015-09-25 18:03:34 -0700
committerchrome-bot <chrome-bot@chromium.org>2015-09-29 11:28:40 -0700
commita490cbfe80d1cb91c04ae0966ab3b6a3fb81814c (patch)
treeddb44d043e4ac3b24926827c9b808386c85418cf
parent42062110b702b4a011a3fe0aaaef09d15e6c5006 (diff)
downloadchrome-ec-a490cbfe80d1cb91c04ae0966ab3b6a3fb81814c.tar.gz
gesture: fix double tap doesn't always work in suspend
Fix bug where sometimes on suspend tap for battery would never work, but open a resume and suspend again it would work fine. Problem is that if suspended when accel circular buffer index is 1, then we would never run the detection algorithm, because the check for if the history buffer has been initialized is incorrect. This also fixes the algorithm so that on suspend, it requires the full sensor history buffer be filled up again before starting to detect the double tap. BUG=chrome-os-partner:45930 BRANCH=samus TEST=go in to suspend when history_index is 1 and verify that tap for battery works. wrote following console command to pause the circular buffer at a specific index. static int pause_index = -1; static int check_pause; static void gesture_chipset_resume(void) { /* disable tap detection */ check_pause = 1; } DECLARE_HOOK(HOOK_CHIPSET_RESUME, gesture_chipset_resume, GESTURE_HOOK_PRIO); void gesture_calc(void) { if (check_pause) { if (pause_index < 0 || history_idx == pause_index) { ccprintf("Paused at %d\n", pause_index); tap_detection = 0; pause_index = -1; check_pause = 0; } } ... static int command_tap_pause(int argc, char **argv) { char *e; int v; if (argc == 2) { v = strtoi(argv[1], &e, 0); if (*e) return EC_ERROR_PARAM1; pause_index = v; } return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(tappause, command_tap_pause, "", "", NULL); Change-Id: I2ba4ab2c807ec6ac1885a4829efedac3c83b32f1 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/302648 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
-rw-r--r--common/gesture.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/common/gesture.c b/common/gesture.c
index 278e74e980..d8b3383319 100644
--- a/common/gesture.c
+++ b/common/gesture.c
@@ -147,10 +147,15 @@ static int gesture_tap_for_battery(void)
y_p = y;
z_p = z;
- /* Ignore data until we fill history buffer and wrap around */
- if (history_idx == 0)
+ /*
+ * Ignore data until we fill history buffer and wrap around. If
+ * detection is paused, history_init_index will store the index
+ * when paused, so that when re-started, we will wait until we
+ * wrap around again.
+ */
+ if (history_idx == history_init_index)
history_initialized = 1;
- if (history_initialized == history_init_index)
+ if (!history_initialized)
return 0;
/*