diff options
author | Jack Rosenthal <jrosenth@chromium.org> | 2022-06-27 14:36:48 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-07-01 17:43:32 +0000 |
commit | 43f6eddfa38598921622465e4c34d93f0461ef8d (patch) | |
tree | ea268374d17b6b9daf7908b15441cd2f3102c661 /common/keyboard_8042.c | |
parent | 268a378fa2802844034ae6c1d0289e73d55157d9 (diff) | |
download | chrome-ec-43f6eddfa38598921622465e4c34d93f0461ef8d.tar.gz |
common/keyboard_8042.c: Format with clang-format
BUG=b:236386294
BRANCH=none
TEST=none
Change-Id: I328779d2e401f23cdc4cd88bfdf5aeb71d854343
Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3729658
Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
Diffstat (limited to 'common/keyboard_8042.c')
-rw-r--r-- | common/keyboard_8042.c | 127 |
1 files changed, 59 insertions, 68 deletions
diff --git a/common/keyboard_8042.c b/common/keyboard_8042.c index 755b26f360..aebbf38e87 100644 --- a/common/keyboard_8042.c +++ b/common/keyboard_8042.c @@ -28,11 +28,11 @@ /* Console output macros */ #define CPUTS(outstr) cputs(CC_KEYBOARD, outstr) -#define CPRINTS(format, args...) cprints(CC_KEYBOARD, format, ## args) +#define CPRINTS(format, args...) cprints(CC_KEYBOARD, format, ##args) #ifdef CONFIG_KEYBOARD_DEBUG #define CPUTS5(outstr) cputs(CC_KEYBOARD, outstr) -#define CPRINTS5(format, args...) cprints(CC_KEYBOARD, format, ## args) +#define CPRINTS5(format, args...) cprints(CC_KEYBOARD, format, ##args) #else #define CPUTS5(outstr) #define CPRINTS5(format, args...) @@ -44,16 +44,16 @@ * #define CMD_KEYBOARD_LOG IS_ENABLED(CONFIG_MALLOC) */ #ifdef CONFIG_MALLOC -#define CMD_KEYBOARD_LOG 1 +#define CMD_KEYBOARD_LOG 1 #else -#define CMD_KEYBOARD_LOG 0 +#define CMD_KEYBOARD_LOG 0 #endif static enum { STATE_NORMAL = 0, STATE_SCANCODE, STATE_SETLEDS, - STATE_EX_SETLEDS_1, /* Expect 2-byte parameter */ + STATE_EX_SETLEDS_1, /* Expect 2-byte parameter */ STATE_EX_SETLEDS_2, STATE_WRITE_CMD_BYTE, STATE_WRITE_OUTPUT_PORT, @@ -123,9 +123,9 @@ static int i8042_keyboard_irq_enabled; static int i8042_aux_irq_enabled; /* i8042 global settings */ -static int keyboard_enabled; /* default the keyboard is disabled. */ -static int aux_chan_enabled; /* default the mouse is disabled. */ -static int keystroke_enabled; /* output keystrokes */ +static int keyboard_enabled; /* default the keyboard is disabled. */ +static int aux_chan_enabled; /* default the mouse is disabled. */ +static int keystroke_enabled; /* output keystrokes */ static uint8_t resend_command[MAX_SCAN_CODE_LEN]; static uint8_t resend_command_len; static uint8_t controller_ram_address; @@ -157,11 +157,11 @@ static enum scancode_set_list scancode_set = SCANCODE_SET_2; static uint8_t typematic_value_from_host; static int typematic_first_delay; static int typematic_inter_delay; -static int typematic_len; /* length of typematic_scan_code */ +static int typematic_len; /* length of typematic_scan_code */ static uint8_t typematic_scan_code[MAX_SCAN_CODE_LEN]; static timestamp_t typematic_deadline; -#define KB_SYSJUMP_TAG 0x4b42 /* "KB" */ +#define KB_SYSJUMP_TAG 0x4b42 /* "KB" */ #define KB_HOOK_VERSION 2 /* the previous keyboard state before reboot_ec. */ struct kb_state { @@ -174,7 +174,7 @@ struct kb_state { /* Keyboard event log */ /* Log the traffic between EC and host -- for debug only */ -#define MAX_KBLOG 512 /* Max events in keyboard log */ +#define MAX_KBLOG 512 /* Max events in keyboard log */ struct kblog_t { /* @@ -202,8 +202,8 @@ struct kblog_t { uint8_t byte; }; -static struct kblog_t *kblog_buf; /* Log buffer; NULL if not logging */ -static int kblog_len; /* Current log length */ +static struct kblog_t *kblog_buf; /* Log buffer; NULL if not logging */ +static int kblog_len; /* Current log length */ /** * Add event to keyboard log. @@ -266,8 +266,7 @@ static void aux_enable_irq(int enable) * @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, - uint8_t chan) +static void i8042_send_to_host(int len, const uint8_t *bytes, uint8_t chan) { int i; struct data_byte data; @@ -364,8 +363,8 @@ static enum ec_error_list matrix_callback(int8_t row, int8_t col, #ifdef CONFIG_KEYBOARD_SCANCODE_CALLBACK { - enum ec_error_list r = keyboard_scancode_callback( - &make_code, pressed); + enum ec_error_list r = + keyboard_scancode_callback(&make_code, pressed); if (r != EC_SUCCESS) return r; } @@ -392,10 +391,10 @@ static enum ec_error_list matrix_callback(int8_t row, int8_t col, static void set_typematic_delays(uint8_t data) { typematic_value_from_host = data; - typematic_first_delay = MSEC * - (((typematic_value_from_host & 0x60) >> 5) + 1) * 250; - typematic_inter_delay = SECOND * - (1 << ((typematic_value_from_host & 0x18) >> 3)) * + typematic_first_delay = + MSEC * (((typematic_value_from_host & 0x60) >> 5) + 1) * 250; + typematic_inter_delay = + SECOND * (1 << ((typematic_value_from_host & 0x18) >> 3)) * ((typematic_value_from_host & 0x7) + 8) / 240; } @@ -442,7 +441,8 @@ void keyboard_state_changed(int row, int col, int is_pressed) if (mylabel & KEYCAP_LONG_LABEL_BIT) CPRINTS("KB (%d,%d)=%d %s", row, col, is_pressed, - get_keycap_long_label(mylabel & KEYCAP_LONG_LABEL_INDEX_BITMASK)); + get_keycap_long_label(mylabel & + KEYCAP_LONG_LABEL_INDEX_BITMASK)); else CPRINTS("KB (%d,%d)=%d %c", row, col, is_pressed, mylabel); #endif @@ -516,8 +516,8 @@ static void update_ctl_ram(uint8_t addr, uint8_t data) orig = controller_ram[addr]; controller_ram[addr] = data; - CPRINTS5("KB set CTR_RAM(0x%02x)=0x%02x (old:0x%02x)", - addr, data, orig); + CPRINTS5("KB set CTR_RAM(0x%02x)=0x%02x (old:0x%02x)", addr, data, + orig); if (addr == 0x00) { /* Keyboard enable/disable */ @@ -567,7 +567,7 @@ static int handle_mouse_data(uint8_t data, uint8_t *output, int *count) data_port_state = STATE_NORMAL; break; - default: /* STATE_NORMAL */ + default: /* STATE_NORMAL */ return 0; } @@ -622,15 +622,13 @@ static int handle_keyboard_data(uint8_t data, uint8_t *output) break; case STATE_WRITE_CMD_BYTE: - CPRINTS5("KB eaten by STATE_WRITE_CMD_BYTE: 0x%02x", - data); + CPRINTS5("KB eaten by STATE_WRITE_CMD_BYTE: 0x%02x", data); update_ctl_ram(controller_ram_address, data); data_port_state = STATE_NORMAL; break; case STATE_WRITE_OUTPUT_PORT: - CPRINTS5("KB eaten by STATE_WRITE_OUTPUT_PORT: 0x%02x", - data); + CPRINTS5("KB eaten by STATE_WRITE_OUTPUT_PORT: 0x%02x", data); A20_status = (data & BIT(1)) ? 1 : 0; data_port_state = STATE_NORMAL; break; @@ -643,9 +641,9 @@ static int handle_keyboard_data(uint8_t data, uint8_t *output) data_port_state = STATE_NORMAL; break; - default: /* STATE_NORMAL */ + default: /* STATE_NORMAL */ switch (data) { - case I8042_CMD_GSCANSET: /* also I8042_CMD_SSCANSET */ + case I8042_CMD_GSCANSET: /* also I8042_CMD_SSCANSET */ output[out_len++] = I8042_RET_ACK; data_port_state = STATE_SCANCODE; break; @@ -666,10 +664,10 @@ static int handle_keyboard_data(uint8_t data, uint8_t *output) output[out_len++] = I8042_CMD_DIAG_ECHO; break; - case I8042_CMD_GETID: /* fall-thru */ + case I8042_CMD_GETID: /* fall-thru */ case I8042_CMD_OK_GETID: output[out_len++] = I8042_RET_ACK; - output[out_len++] = 0xab; /* Regular keyboards */ + output[out_len++] = 0xab; /* Regular keyboards */ output[out_len++] = 0x83; break; @@ -714,13 +712,12 @@ static int handle_keyboard_data(uint8_t data, uint8_t *output) /* U-boot hack. Just ignore; don't reply. */ break; - case I8042_CMD_SETALL_MB: /* fall-thru */ + case I8042_CMD_SETALL_MB: /* fall-thru */ case I8042_CMD_SETALL_MBR: case I8042_CMD_EX_ENABLE: default: output[out_len++] = I8042_RET_NAK; - CPRINTS("KB Unsupported i8042 data 0x%02x", - data); + CPRINTS("KB Unsupported i8042 data 0x%02x", data); break; } } @@ -770,7 +767,7 @@ static int handle_keyboard_command(uint8_t command, uint8_t *output) case I8042_DIS_KB: update_ctl_ram(0, read_ctl_ram(0) | I8042_KBD_DIS); reset_rate_and_delay(); - typematic_len = 0; /* stop typematic */ + typematic_len = 0; /* stop typematic */ keyboard_clear_buffer(); break; @@ -784,8 +781,8 @@ static int handle_keyboard_command(uint8_t command, uint8_t *output) output[out_len++] = (lpc_keyboard_input_pending() ? BIT(5) : 0) | (lpc_keyboard_has_char() ? BIT(4) : 0) | - (A20_status ? BIT(1) : 0) | - 1; /* Main processor in normal mode */ + (A20_status ? BIT(1) : 0) | 1; /* Main processor in + normal mode */ break; case I8042_WRITE_OUTPUT_PORT: @@ -793,7 +790,7 @@ static int handle_keyboard_command(uint8_t command, uint8_t *output) break; case I8042_RESET_SELF_TEST: - output[out_len++] = 0x55; /* Self test success */ + output[out_len++] = 0x55; /* Self test success */ break; case I8042_TEST_KB_PORT: @@ -809,7 +806,7 @@ static int handle_keyboard_command(uint8_t command, uint8_t *output) break; case I8042_TEST_MOUSE: - output[out_len++] = 0; /* No error detected */ + output[out_len++] = 0; /* No error detected */ break; case I8042_ECHO_MOUSE: @@ -906,8 +903,8 @@ void keyboard_protocol_task(void *u) i8042_send_to_host(typematic_len, typematic_scan_code, CHAN_KBD); - typematic_deadline.val = t.val + - typematic_inter_delay; + typematic_deadline.val = + t.val + typematic_inter_delay; wait = typematic_inter_delay; } else { /* Wait for remaining interval */ @@ -970,7 +967,7 @@ static void send_aux_data_to_host_deferred(void) uint8_t data; if (IS_ENABLED(CONFIG_DEVICE_EVENT) && - chipset_in_state(CHIPSET_STATE_ANY_SUSPEND)) + chipset_in_state(CHIPSET_STATE_ANY_SUSPEND)) device_set_single_event(EC_DEVICE_EVENT_TRACKPAD); while (!queue_is_empty(&aux_to_host_queue)) { @@ -1069,8 +1066,8 @@ static int command_codeset(int argc, char **argv) if (argc == 2) { int set = strtoi(argv[1], NULL, 0); switch (set) { - case SCANCODE_SET_1: /* fall-thru */ - case SCANCODE_SET_2: /* fall-thru */ + case SCANCODE_SET_1: /* fall-thru */ + case SCANCODE_SET_2: /* fall-thru */ scancode_set = set; break; default: @@ -1109,8 +1106,8 @@ static int command_keyboard_log(int argc, char **argv) if (argc == 1) { ccprintf("KBC log (len=%d):\n", kblog_len); for (i = 0; kblog_buf && i < kblog_len; ++i) { - ccprintf("%c.%02x ", - kblog_buf[i].type, kblog_buf[i].byte); + ccprintf("%c.%02x ", kblog_buf[i].type, + kblog_buf[i].byte); if ((i & 15) == 15) { ccputs("\n"); cflush(); @@ -1126,9 +1123,9 @@ static int command_keyboard_log(int argc, char **argv) if (i) { if (!kblog_buf) { - int rv = SHARED_MEM_ACQUIRE_CHECK( - sizeof(*kblog_buf) * MAX_KBLOG, - (char **)&kblog_buf); + int rv = SHARED_MEM_ACQUIRE_CHECK(sizeof(*kblog_buf) * + MAX_KBLOG, + (char **)&kblog_buf); if (rv != EC_SUCCESS) kblog_buf = NULL; kblog_len = 0; @@ -1204,20 +1201,15 @@ static int command_8042_internal(int argc, char **argv) /* Zephyr only provides these as subcommands*/ #ifndef CONFIG_ZEPHYR -DECLARE_CONSOLE_COMMAND(typematic, command_typematic, - "[first] [inter]", +DECLARE_CONSOLE_COMMAND(typematic, command_typematic, "[first] [inter]", "Get/set typematic delays"); -DECLARE_CONSOLE_COMMAND(codeset, command_codeset, - "[set]", +DECLARE_CONSOLE_COMMAND(codeset, command_codeset, "[set]", "Get/set keyboard codeset"); -DECLARE_CONSOLE_COMMAND(ctrlram, command_controller_ram, - "index [value]", +DECLARE_CONSOLE_COMMAND(ctrlram, command_controller_ram, "index [value]", "Get/set keyboard controller RAM"); -DECLARE_CONSOLE_COMMAND(kblog, command_keyboard_log, - "[on | off]", +DECLARE_CONSOLE_COMMAND(kblog, command_keyboard_log, "[on | off]", "Print or toggle keyboard event log"); -DECLARE_CONSOLE_COMMAND(kbd, command_keyboard, - "[on | off]", +DECLARE_CONSOLE_COMMAND(kbd, command_keyboard, "[on | off]", "Print or toggle keyboard info"); #endif @@ -1239,16 +1231,16 @@ static int command_8042(int argc, char **argv) else return EC_ERROR_PARAM1; } else { - char *ctlram_argv[] = {"ctrlram", "0"}; + char *ctlram_argv[] = { "ctrlram", "0" }; ccprintf("\n- Typematic:\n"); command_typematic(argc, argv); ccprintf("\n- Codeset:\n"); command_codeset(argc, argv); ccprintf("\n- Control RAM:\n"); - command_controller_ram( - sizeof(ctlram_argv) / sizeof(ctlram_argv[0]), - ctlram_argv); + command_controller_ram(sizeof(ctlram_argv) / + sizeof(ctlram_argv[0]), + ctlram_argv); if (CMD_KEYBOARD_LOG) { ccprintf("\n- Keyboard log:\n"); command_keyboard_log(argc, argv); @@ -1268,7 +1260,6 @@ DECLARE_CONSOLE_COMMAND(8042, command_8042, "Print 8042 state in one place"); #endif - /*****************************************************************************/ /* Hooks */ @@ -1290,8 +1281,8 @@ static void keyboard_preserve_state(void) state.ctlram = controller_ram[0]; state.keystroke_enabled = keystroke_enabled; - system_add_jump_tag(KB_SYSJUMP_TAG, KB_HOOK_VERSION, - sizeof(state), &state); + system_add_jump_tag(KB_SYSJUMP_TAG, KB_HOOK_VERSION, sizeof(state), + &state); } DECLARE_HOOK(HOOK_SYSJUMP, keyboard_preserve_state, HOOK_PRIO_DEFAULT); |