diff options
author | Aseda Aboagye <aaboagye@google.com> | 2016-07-06 19:37:00 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-07-19 18:33:36 -0700 |
commit | 87a071941b89e3f7fd3eb329b682e60b3fbd6c73 (patch) | |
tree | d82c7b76924dea16c7c9d4de69b591be3a9ddfe6 /test | |
parent | c0f6ac5e02cdb7a25f593af6dce7b0eea71d996d (diff) | |
download | chrome-ec-87a071941b89e3f7fd3eb329b682e60b3fbd6c73.tar.gz |
mkbp: Add support for buttons and switches.
Currently, the matrix keyboard protocol does not have support for
handling non-matrixed keys. This commit adds support for buttons which
do not appear in the keyboard matrix as well as switches.
Additionally, the keyboard FIFO is now just a general MKBP events FIFO
which MKBP events are free to use. Now, buttons and switches wil join
the key matrix event.
BUG=chrome-os-partner:54988
BUG=chrome-os-partner:54976
BUG=chromium:626863
BRANCH=None
TEST=Flash kevin, and verify that keyboard is still functional.
TEST=make -j buildall
CQ-DEPEND=CL:358926
Change-Id: If4ada904cbd5d77823a0710d4671484b198c9d91
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/358633
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/kb_mkbp.c | 54 | ||||
-rw-r--r-- | test/test_config.h | 2 |
2 files changed, 41 insertions, 15 deletions
diff --git a/test/kb_mkbp.c b/test/kb_mkbp.c index e1abcc3adb..f838a0c411 100644 --- a/test/kb_mkbp.c +++ b/test/kb_mkbp.c @@ -71,31 +71,33 @@ int press_key(int c, int r, int pressed) int verify_key(int c, int r, int pressed) { struct host_cmd_handler_args args; - uint8_t mkbp_out[KEYBOARD_COLS]; + struct ec_response_get_next_event event; int i; - if (c >= 0 && r >= 0) { - ccprintf("Verify %s (%d, %d)\n", action[pressed], c, r); - set_state(c, r, pressed); - } else { - ccprintf("Verify last state\n"); - } - args.version = 0; - args.command = EC_CMD_MKBP_STATE; + args.command = EC_CMD_GET_NEXT_EVENT; args.params = NULL; args.params_size = 0; - args.response = mkbp_out; - args.response_max = sizeof(mkbp_out); + args.response = &event; + args.response_max = sizeof(event); args.response_size = 0; - if (host_command_process(&args) != EC_RES_SUCCESS) - return 0; + if (c >= 0 && r >= 0) { + ccprintf("Verify %s (%d, %d)\n", action[pressed], c, r); + set_state(c, r, pressed); - for (i = 0; i < KEYBOARD_COLS; ++i) - if (mkbp_out[i] != state[i]) + if (host_command_process(&args) != EC_RES_SUCCESS) return 0; + for (i = 0; i < KEYBOARD_COLS; ++i) + if (event.data.key_matrix[i] != state[i]) + return 0; + } else { + ccprintf("Verify no events available\n"); + if (host_command_process(&args) != EC_RES_UNAVAILABLE) + return 0; + } + return 1; } @@ -136,6 +138,26 @@ int set_kb_scan_enabled(int enabled) return mkbp_config(params); } +void clear_mkbp_events(void) +{ + struct host_cmd_handler_args args; + struct ec_response_get_next_event event; + + args.version = 0; + args.command = EC_CMD_GET_NEXT_EVENT; + args.params = NULL; + args.params_size = 0; + args.response = &event; + args.response_max = sizeof(event); + args.response_size = 0; + + /* + * We should return EC_RES_UNAVAILABLE if there are no MKBP events left. + */ + while (host_command_process(&args) != EC_RES_UNAVAILABLE) + ; +} + /*****************************************************************************/ /* Tests */ @@ -211,6 +233,8 @@ void run_test(void) ec_int_level = 1; test_reset(); + /* Clear any pending events such as lid open. */ + clear_mkbp_events(); RUN_TEST(single_key_press); RUN_TEST(test_fifo_size); RUN_TEST(test_enable); diff --git a/test/test_config.h b/test/test_config.h index 7e0a9d073d..3750015bc3 100644 --- a/test/test_config.h +++ b/test/test_config.h @@ -31,10 +31,12 @@ #ifdef TEST_KB_MKBP #define CONFIG_KEYBOARD_PROTOCOL_MKBP +#define CONFIG_MKBP_EVENT #endif #ifdef TEST_KB_SCAN #define CONFIG_KEYBOARD_PROTOCOL_MKBP +#define CONFIG_MKBP_EVENT #endif #ifdef TEST_MATH_UTIL |