From d1ed75815efe513449c653d28fe7bd3c53a3441d Mon Sep 17 00:00:00 2001 From: Vic Yang Date: Mon, 20 Oct 2014 23:31:28 -0700 Subject: MKBP event signalling implementation This implements a new API for EC modules to define MKBP event sources and send MKBP event to the AP. Also, a new host command EC_CMD_GET_NEXT_EVENT is added for the AP to query the pending MKBP events. Each event type may have custom event data sent along with the event. BRANCH=None BUG=chrome-os-partner:33194 TEST=Enable MKBP event on Ryu. Set a host event from EC console, run 'ectool nextevent', and see MKBP event 0x01 (HOST_EVENT) and the set host event. Signed-off-by: Vic Yang Change-Id: I28a1b7e826bcc102bbe39016c9bb3e37d125664c Reviewed-on: https://chromium-review.googlesource.com/224905 Reviewed-by: Randall Spangler --- common/keyboard_mkbp.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'common/keyboard_mkbp.c') diff --git a/common/keyboard_mkbp.c b/common/keyboard_mkbp.c index 7e9f6f5c45..82fc93bdf2 100644 --- a/common/keyboard_mkbp.c +++ b/common/keyboard_mkbp.c @@ -15,6 +15,7 @@ #include "keyboard_raw.h" #include "keyboard_scan.h" #include "keyboard_test.h" +#include "mkbp_event.h" #include "system.h" #include "task.h" #include "timer.h" @@ -146,12 +147,33 @@ test_mockable int keyboard_fifo_add(const uint8_t *buffp) kb_fifo_push_done: - if (ret == EC_SUCCESS) + if (ret == EC_SUCCESS) { set_host_interrupt(1); +#ifdef CONFIG_MKBP_EVENT + mkbp_send_event(EC_MKBP_EVENT_KEY_MATRIX); +#endif + } return ret; } +#ifdef CONFIG_MKBP_EVENT +static int keyboard_get_next_event(uint8_t *out) +{ + if (!kb_fifo_entries) + return -1; + + kb_fifo_remove(out); + + /* Keep sending events if FIFO is not empty */ + if (kb_fifo_entries) + mkbp_send_event(EC_MKBP_EVENT_KEY_MATRIX); + + return KEYBOARD_COLS; +} +DECLARE_EVENT_SOURCE(EC_MKBP_EVENT_KEY_MATRIX, keyboard_get_next_event); +#endif + void keyboard_send_battery_key(void) { uint8_t state[KEYBOARD_COLS]; -- cgit v1.2.1