Skip to contentSkip to conversation

sandbox: cros_ec: Basic support for EC_CMD_GET_NEXT_EVENT

PATCH New Alper Nebi Yasak 3 participants 4 messages Nov 10, 2020 – Nov 11, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

Fixes 690079767803 ("cros_ec: Support keyboard scanning with EC_CMD_GET_NEXT_EVENT")

---
This doesn't test the -EC_RES_UNAVAILABLE part, which looks like an event queue on the EC side. As far as I understand sandbox is getting a single keyboard state from SDL after discarding pending events. I think things would need to be hooked into sandbox_sdl_poll_events, looks possible but harder.

Also, now that this command would work, the fallback to the old one would never trigger and wouldn't be tested.

 drivers/misc/cros_ec_sandbox.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/misc/cros_ec_sandbox.c +8 -0
index a191f061b898..d72db3eace98 100644
@@ -460,6 +460,14 @@ static int process_cmd(struct ec_state *ec,
 	case EC_CMD_ENTERING_MODE:
 		len = 0;
 		break;
+	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;
Signature · 1 line
2.29.2
#1 lore raw

PATCH 1/1 sandbox: cros_ec: Basic support for EC_CMD_GET_NEXT_EVENT

Quoted 20 lines · Alper Nebi Yasak

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.

Fixes 690079767803 ("cros_ec: Support keyboard scanning with EC_CMD_GET_NEXT_EVENT")

---
This doesn't test the -EC_RES_UNAVAILABLE part, which looks like an event queue on the EC side. As far as I understand sandbox is getting a single keyboard state from SDL after discarding pending events. I think things would need to be hooked into sandbox_sdl_poll_events, looks possible but harder.

Quoted 2 lines

Also, now that this command would work, the fallback to the old one would never trigger and wouldn't be tested.

Should some of the comment above be merged into the commit message?

Quoted 24 lines
 drivers/misc/cros_ec_sandbox.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/misc/cros_ec_sandbox.c +8 -0
index a191f061b898..d72db3eace98 100644
@@ -460,6 +460,14 @@ static int process_cmd(struct ec_state *ec,
 	case EC_CMD_ENTERING_MODE:
 		len = 0;
 		break;
+	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;
#2 lore raw

PATCH 1/1 sandbox: cros_ec: Basic support for EC_CMD_GET_NEXT_EVENT

Quoted 21 lines · Heinrich Schuchardt
Quoted 20 lines · Alper Nebi Yasak

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.

Fixes 690079767803 ("cros_ec: Support keyboard scanning with EC_CMD_GET_NEXT_EVENT")

---
This doesn't test the -EC_RES_UNAVAILABLE part, which looks like an event queue on the EC side. As far as I understand sandbox is getting a single keyboard state from SDL after discarding pending events. I think things would need to be hooked into sandbox_sdl_poll_events, looks possible but harder.

Quoted 4 lines
Quoted 2 lines

Also, now that this command would work, the fallback to the old one would never trigger and wouldn't be tested.

Should some of the comment above be merged into the commit message?

Yeah, probably. I just defaulted to the notes since I'd be writing in an informal tone and was not sure if leaving those as future work is OK.

Quoted 1 line

Thanks.

Quoted 25 lines
Quoted 24 lines
 drivers/misc/cros_ec_sandbox.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/misc/cros_ec_sandbox.c +8 -0
index a191f061b898..d72db3eace98 100644
@@ -460,6 +460,14 @@ static int process_cmd(struct ec_state *ec,
 	case EC_CMD_ENTERING_MODE:
 		len = 0;
 		break;
+	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;
#3 lore raw

PATCH 1/1 sandbox: cros_ec: Basic support for EC_CMD_GET_NEXT_EVENT

In reply to Alper Nebi Yasak
Quoted 21 lines · Alper Nebi Yasak

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.

Fixes 690079767803 ("cros_ec: Support keyboard scanning with EC_CMD_GET_NEXT_EVENT")

---
This doesn't test the -EC_RES_UNAVAILABLE part, which looks like an event queue on the EC side. As far as I understand sandbox is getting a single keyboard state from SDL after discarding pending events. I think things would need to be hooked into sandbox_sdl_poll_events, looks possible but harder.

Quoted 6 lines

Also, now that this command would work, the fallback to the old one would never trigger and wouldn't be tested.

 drivers/misc/cros_ec_sandbox.c | 8 ++++++++
 1 file changed, 8 insertions(+)
Quoted 22 lines
drivers/misc/cros_ec_sandbox.c +8 -1
index a191f061b898..d72db3eace98 100644
@@ -460,6 +460,14 @@ static int process_cmd(struct ec_state *ec,
        case EC_CMD_ENTERING_MODE:
                len = 0;
                break;
+       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;
--

2.29.2