diff options
author | Raul E Rangel <rrangel@chromium.org> | 2020-02-25 16:57:50 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-02-27 19:42:29 +0000 |
commit | 6c0c6ec6b08a14ea0c1e612d585cdb825bb2f1cf (patch) | |
tree | d4c97dc9862c00c1d72607ff395b26b1c1f4f377 | |
parent | 782d71645f713bbce7021a0d3bd75ef1345297b0 (diff) | |
download | chrome-ec-6c0c6ec6b08a14ea0c1e612d585cdb825bb2f1cf.tar.gz |
common/keyboard_8042: Add ability to specify 8042 channel
We actually have two data channels we can send data on. This CL only
adds the functionality to specify the additional channel. We only define
the KBD channel for now. A follow up will add the AUX channel.
BUG=b:145575366
BRANCH=none
TEST=Verified keyboard data is still sent
Change-Id: Icaed0a741cee4dac5eb5e6f36bd4e45d4a1e1bcd
Signed-off-by: Raul E Rangel <rrangel@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2073285
Reviewed-by: Edward Hill <ecgh@chromium.org>
-rw-r--r-- | common/keyboard_8042.c | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/common/keyboard_8042.c b/common/keyboard_8042.c index 367b2feb3c..1e7ea37bc3 100644 --- a/common/keyboard_8042.c +++ b/common/keyboard_8042.c @@ -69,7 +69,16 @@ enum scancode_set_list { */ static struct mutex to_host_mutex; -static struct queue const to_host = QUEUE_NULL(16, uint8_t); +/* Queue command/data from the host */ +enum { + CHAN_KBD = 0, +}; +struct data_byte { + uint8_t chan; + uint8_t byte; +}; + +static struct queue const to_host = QUEUE_NULL(16, struct data_byte); /* Queue command/data from the host */ enum { @@ -235,10 +244,13 @@ static void aux_enable_irq(int enable) * * @param len Number of bytes to send to the host * @param to_host Data to send + * @param chan Channel to send data on */ -static void i8042_send_to_host(int len, const uint8_t *bytes) +static void i8042_send_to_host(int len, const uint8_t *bytes, + uint8_t chan) { int i; + struct data_byte data; for (i = 0; i < len; i++) kblog_put('s', bytes[i]); @@ -247,7 +259,11 @@ static void i8042_send_to_host(int len, const uint8_t *bytes) mutex_lock(&to_host_mutex); if (queue_space(&to_host) >= len) { kblog_put('t', to_host.state->tail); - queue_add_units(&to_host, bytes, len); + for (i = 0; i < len; i++) { + data.chan = chan; + data.byte = bytes[i]; + queue_add_unit(&to_host, &data); + } } mutex_unlock(&to_host_mutex); @@ -413,7 +429,7 @@ void keyboard_state_changed(int row, int col, int is_pressed) if (ret == EC_SUCCESS) { ASSERT(len > 0); if (keystroke_enabled) - i8042_send_to_host(len, scan_code); + i8042_send_to_host(len, scan_code, CHAN_KBD); } if (is_pressed) { @@ -804,6 +820,7 @@ static void i8042_handle_from_host(void) struct host_byte h; int ret_len; uint8_t output[MAX_SCAN_CODE_LEN]; + uint8_t chan = CHAN_KBD; while (queue_remove_unit(&from_host, &h)) { if (h.type == HOST_COMMAND) @@ -811,7 +828,7 @@ static void i8042_handle_from_host(void) else ret_len = handle_keyboard_data(h.byte, output); - i8042_send_to_host(ret_len, output); + i8042_send_to_host(ret_len, output, chan); } } @@ -828,7 +845,7 @@ void keyboard_protocol_task(void *u) while (1) { timestamp_t t = get_time(); - uint8_t chr; + struct data_byte entry; /* Handle typematic */ if (!typematic_len) { @@ -838,7 +855,8 @@ void keyboard_protocol_task(void *u) /* Ready for next typematic keystroke */ if (keystroke_enabled) i8042_send_to_host(typematic_len, - typematic_scan_code); + typematic_scan_code, + CHAN_KBD); typematic_deadline.val = t.val + typematic_inter_delay; wait = typematic_inter_delay; @@ -879,11 +897,12 @@ void keyboard_protocol_task(void *u) /* Get a char from buffer. */ kblog_put('k', to_host.state->head); - queue_remove_unit(&to_host, &chr); - kblog_put('K', chr); + queue_remove_unit(&to_host, &entry); + kblog_put('K', entry.byte); /* Write to host. */ - lpc_keyboard_put_char(chr, i8042_keyboard_irq_enabled); + lpc_keyboard_put_char(entry.byte, + i8042_keyboard_irq_enabled); retries = 0; } } @@ -927,7 +946,7 @@ test_mockable void keyboard_update_button(enum keyboard_button_type button, } if (keystroke_enabled) { - i8042_send_to_host(len, scan_code); + i8042_send_to_host(len, scan_code, CHAN_KBD); task_wake(TASK_ID_KEYPROTO); } } @@ -1102,11 +1121,11 @@ static int command_8042_internal(int argc, char **argv) ccprintf("to_host[]={"); for (i = 0; i < queue_count(&to_host); ++i) { - uint8_t entry; + struct data_byte entry; queue_peek_units(&to_host, &entry, i, 1); - ccprintf("0x%02x, ", entry); + ccprintf("0x%02x, ", entry.byte); } ccprintf("}\n"); |