From ec7927a20d4fd1db35e482a69da1e9915552322f Mon Sep 17 00:00:00 2001 From: Douglas Anderson Date: Mon, 4 Jan 2016 09:58:12 -0800 Subject: [PATCH] keyboard: Fix kbpress after recent keyboard change After commit 98ab7484d331 ("keyboard: prevent races enabling/disabling kb scanning") kbpress was totally broken, which wasn't so good for FAFT. Fix it by making sure we go into polling mode for simulated keyboard presses. BUG=chrome-os-partner:48849 TEST=kbpress works Change-Id: Icd663c2ee7a184e6af4438368595087b35724a4f Signed-off-by: Douglas Anderson Reviewed-on: https://chromium-review.googlesource.com/319586 Reviewed-by: Randall Spangler --- common/keyboard_scan.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/common/keyboard_scan.c b/common/keyboard_scan.c index 5d93f28fc9..cad5bb559a 100644 --- a/common/keyboard_scan.c +++ b/common/keyboard_scan.c @@ -101,6 +101,9 @@ static volatile uint32_t __bss_slow disable_scanning_mask; /* Constantly incrementing counter of the number of times we polled */ static volatile int kbd_polls; +/* If true, we'll force a keyboard poll */ +static volatile int force_poll; + static int keyboard_scan_is_enabled(void) { /* NOTE: this is just an instantaneous glimpse of the variable. */ @@ -184,6 +187,9 @@ static void simulate_key(int row, int col, int pressed) print_state(simulated_key, "simulated "); + /* Force a poll even though no keys are pressed */ + force_poll = 1; + /* Wake the task to handle changes in simulated keys */ task_wake(TASK_ID_KEYSCAN); @@ -664,12 +670,16 @@ void keyboard_scan_task(void) * user pressing a key and enable_interrupt() * starting to pay attention to edges. */ - if (!local_disable_scanning && keyboard_raw_read_rows()) + if (!local_disable_scanning && + (keyboard_raw_read_rows() || force_poll)) break; else task_wait_event(-1); } + /* We're about to poll, so any existing forces are fulfilled */ + force_poll = 0; + /* Enter polling mode */ CPRINTS("KB poll"); keyboard_raw_enable_interrupt(0);