aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlper Nebi Yasak <alpernebiyasak@gmail.com>2020-11-14 01:01:42 +0300
committerSimon Glass <sjg@chromium.org>2020-11-30 13:14:43 -0700
commit87d07ccc237a5bfd8be119af46140a4467122ca7 (patch)
treeddddf05b787a0d5eba9491f2746679bc8b2ca7af
parentf31e83d6cf44fccd25be48b67dd69aaff6c5e1f4 (diff)
downloadu-boot-87d07ccc237a5bfd8be119af46140a4467122ca7.zip
u-boot-87d07ccc237a5bfd8be119af46140a4467122ca7.tar.gz
u-boot-87d07ccc237a5bfd8be119af46140a4467122ca7.tar.bz2
sandbox: cros_ec: Basic support for EC_CMD_GET_NEXT_EVENT
Since commit 690079767803 ("cros_ec: Support keyboard scanning with EC_CMD_GET_NEXT_EVENT") the cros-ec-keyb driver has started using this command, but the sandbox EC emulator does not recognize it and continuously prints: ** Unknown EC command 0x67 This patch makes the sandbox driver send basic responses to the command, but the response only supports keyboard scans for now. The EC side of this command stores and returns events from a queue, and returns -EC_RES_UNAVAILABLE when there are no new events. This should be possible to implement by hooking into the SDL event queue (perhaps via sandbox_sdl_poll_events). Implementing that is a bit harder to do since the existing sandbox code is discarding pending keyboard events, then reading the current keyboard state. Since the EC emulator never explicitly fails to work on this command, the fallback to the older command will not trigger and will not be tested anymore. Fixes: 690079767803 ("cros_ec: Support keyboard scanning with EC_CMD_GET_NEXT_EVENT") Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Tested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r--drivers/misc/cros_ec_sandbox.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/drivers/misc/cros_ec_sandbox.c b/drivers/misc/cros_ec_sandbox.c
index ff7f782..d72db3e 100644
--- a/drivers/misc/cros_ec_sandbox.c
+++ b/drivers/misc/cros_ec_sandbox.c
@@ -460,16 +460,14 @@ static int process_cmd(struct ec_state *ec,
case EC_CMD_ENTERING_MODE:
len = 0;
break;
- case EC_CMD_GET_NEXT_EVENT:
- /*
- * TODO:
- * This driver emulates an old keyboard device supporting
- * EC_CMD_MKBP_STATE. Current Chrome OS keyboards use
- * EC_CMD_GET_NEXT_EVENT. Cf.
- * "mkbp: Add support for buttons and switches"
- * https://chromium.googlesource.com/chromiumos/platform/ec/+/87a071941b89e3f7fd3eb329b682e60b3fbd6c73
- */
- return -EC_RES_INVALID_COMMAND;
+ case EC_CMD_GET_NEXT_EVENT: {
+ struct ec_response_get_next_event *resp = resp_data;
+
+ resp->event_type = EC_MKBP_EVENT_KEY_MATRIX;
+ cros_ec_keyscan(ec, resp->data.key_matrix);
+ len = sizeof(*resp);
+ break;
+ }
default:
printf(" ** Unknown EC command %#02x\n", req_hdr->command);
return -1;