diff options
-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"); |