diff options
author | Jack Rosenthal <jrosenth@chromium.org> | 2022-06-27 14:36:58 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-07-01 04:31:56 +0000 |
commit | 464210e264e9d8b27aba2b4ea173f85dc80130b5 (patch) | |
tree | 55e573f6bad22649ea8a6ebb54d6dc9fcbc76992 /common/keyboard_scan.c | |
parent | 4b7e8b728dac87d3f174f38abfc8fe930214bfb3 (diff) | |
download | chrome-ec-464210e264e9d8b27aba2b4ea173f85dc80130b5.tar.gz |
common/keyboard_scan.c: Format with clang-format
BUG=b:236386294
BRANCH=none
TEST=none
Change-Id: Ie0ce1a97977659490e8d56fc0a2b5838e6bcb135
Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3729659
Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
Diffstat (limited to 'common/keyboard_scan.c')
-rw-r--r-- | common/keyboard_scan.c | 89 |
1 files changed, 40 insertions, 49 deletions
diff --git a/common/keyboard_scan.c b/common/keyboard_scan.c index 0edeca5867..f445efc33f 100644 --- a/common/keyboard_scan.c +++ b/common/keyboard_scan.c @@ -33,21 +33,21 @@ /* Console output macros */ #define CPUTS(outstr) cputs(CC_KEYSCAN, outstr) -#define CPRINTF(format, args...) cprintf(CC_KEYSCAN, format, ## args) -#define CPRINTS(format, args...) cprints(CC_KEYSCAN, format, ## args) +#define CPRINTF(format, args...) cprintf(CC_KEYSCAN, format, ##args) +#define CPRINTS(format, args...) cprints(CC_KEYSCAN, format, ##args) #ifdef CONFIG_KEYBOARD_DEBUG #define CPUTS5(outstr) cputs(CC_KEYSCAN, 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...) #endif -#define SCAN_TIME_COUNT 32 /* Number of last scan times to track */ +#define SCAN_TIME_COUNT 32 /* Number of last scan times to track */ /* If we're waiting for a scan to happen, we'll give it this long */ -#define SCAN_TASK_TIMEOUT_US (100 * MSEC) +#define SCAN_TASK_TIMEOUT_US (100 * MSEC) #ifndef CONFIG_KEYBOARD_POST_SCAN_CLOCKS /* @@ -85,9 +85,9 @@ __overridable struct keyboard_scan_config keyscan_config = { #ifdef CONFIG_KEYBOARD_BOOT_KEYS #ifndef CONFIG_KEYBOARD_MULTIPLE static const struct boot_key_entry boot_key_list[] = { - {KEYBOARD_COL_ESC, KEYBOARD_ROW_ESC}, /* Esc */ - {KEYBOARD_COL_DOWN, KEYBOARD_ROW_DOWN}, /* Down-arrow */ - {KEYBOARD_COL_LEFT_SHIFT, KEYBOARD_ROW_LEFT_SHIFT}, /* Left-Shift */ + { KEYBOARD_COL_ESC, KEYBOARD_ROW_ESC }, /* Esc */ + { KEYBOARD_COL_DOWN, KEYBOARD_ROW_DOWN }, /* Down-arrow */ + { KEYBOARD_COL_LEFT_SHIFT, KEYBOARD_ROW_LEFT_SHIFT }, /* Left-Shift */ }; #else struct boot_key_entry boot_key_list[] = { @@ -214,7 +214,7 @@ static int keyboard_read_adc_rows(void) /* Read each adc channel to build row byte */ for (int i = 0; i < KEYBOARD_ROWS; i++) { if (adc_read_channel(ADC_KSI_00 + i) > - keyscan_config.ksi_threshold_mv) + keyscan_config.ksi_threshold_mv) kb_row |= (1 << i); } @@ -246,7 +246,6 @@ static void keyboard_read_refresh_key(uint8_t *state) } #endif - /** * Simulate a keypress. * @@ -259,7 +258,7 @@ static void simulate_key(int row, int col, int pressed) int old_polls; if ((simulated_key[col] & BIT(row)) == ((pressed ? 1 : 0) << row)) - return; /* No change */ + return; /* No change */ simulated_key[col] ^= BIT(row); @@ -279,8 +278,8 @@ static void simulate_key(int row, int col, int pressed) * That means it needs to have run and for enough time. */ ensure_keyboard_scanned(old_polls); - usleep(pressed ? - keyscan_config.debounce_down_us : keyscan_config.debounce_up_us); + usleep(pressed ? keyscan_config.debounce_down_us : + keyscan_config.debounce_up_us); ensure_keyboard_scanned(kbd_polls); } @@ -378,7 +377,6 @@ static int read_matrix(uint8_t *state) /* Mask off keys that don't exist on the actual keyboard */ state[c] &= keyscan_config.actual_key_mask[c]; - } keyboard_raw_drive_column(KEYBOARD_COLUMN_NONE); @@ -594,7 +592,7 @@ static int check_keys_changed(uint8_t *state) if (tnow - scan_time[scan_edge_index[c][i]] < (state[c] ? keyscan_config.debounce_down_us : keyscan_config.debounce_up_us)) - continue; /* Not done debouncing */ + continue; /* Not done debouncing */ debouncing[c] &= ~BIT(i); if (!IS_ENABLED(CONFIG_KEYBOARD_STRICT_DEBOUNCE)) @@ -639,7 +637,6 @@ static int check_keys_changed(uint8_t *state) } if (any_change) { - #ifdef CONFIG_KEYBOARD_SUPPRESS_NOISE /* Suppress keyboard noise */ keyboard_suppress_noise(); @@ -652,9 +649,9 @@ static int check_keys_changed(uint8_t *state) /* Print delta times from now back to each previous scan */ CPRINTF("[%pT kb deltaT", PRINTF_TIMESTAMP_NOW); for (i = 0; i < SCAN_TIME_COUNT; i++) { - int tnew = scan_time[ - (SCAN_TIME_COUNT + scan_time_index - i) % - SCAN_TIME_COUNT]; + int tnew = scan_time[(SCAN_TIME_COUNT + + scan_time_index - i) % + SCAN_TIME_COUNT]; CPRINTF(" %d", tnow - tnew); } CPRINTF("]\n"); @@ -706,8 +703,9 @@ static uint32_t check_key_list(const uint8_t *state) * button hold, and ignore it if so. */ for (c = 0; c < keyboard_cols; c++) - if ((keyscan_config.actual_key_mask[c] & KEYBOARD_MASK_PWRBTN) - && !(curr_state[c] & KEYBOARD_MASK_PWRBTN)) + if ((keyscan_config.actual_key_mask[c] & + KEYBOARD_MASK_PWRBTN) && + !(curr_state[c] & KEYBOARD_MASK_PWRBTN)) break; if (c == keyboard_cols) @@ -754,7 +752,7 @@ static void read_adc_boot_keys(uint8_t *state) udelay(keyscan_config.output_settle_us); if (adc_read_channel(ADC_KSI_00 + r) > - keyscan_config.ksi_threshold_mv) + keyscan_config.ksi_threshold_mv) state[c] |= BIT(r); } @@ -802,7 +800,7 @@ static uint32_t check_boot_key(const uint8_t *state) static void keyboard_freq_change(void) { post_scan_clock_us = (CONFIG_KEYBOARD_POST_SCAN_CLOCKS * 1000) / - (clock_get_freq() / 1000); + (clock_get_freq() / 1000); } DECLARE_HOOK(HOOK_FREQ_CHANGE, keyboard_freq_change, HOOK_PRIO_DEFAULT); @@ -838,8 +836,8 @@ void keyboard_scan_init(void) } /* Configure refresh key matrix */ - keyboard_mask_refresh = KEYBOARD_ROW_TO_MASK( - board_keyboard_row_refresh()); + keyboard_mask_refresh = + KEYBOARD_ROW_TO_MASK(board_keyboard_row_refresh()); if (!IS_ENABLED(CONFIG_KEYBOARD_SCAN_ADC)) /* Configure GPIO */ @@ -920,7 +918,8 @@ void keyboard_scan_task(void *u) if (local_disable_scanning != new_disable_scanning) CPRINTS("KB disable_scanning_mask changed: " - "0x%08x", new_disable_scanning); + "0x%08x", + new_disable_scanning); if (!new_disable_scanning) { /* Enabled now */ @@ -955,7 +954,7 @@ void keyboard_scan_task(void *u) #else if (!local_disable_scanning && (keyboard_read_adc_rows() || force_poll || - !gpio_get_level(GPIO_RFR_KEY_L))) + !gpio_get_level(GPIO_RFR_KEY_L))) break; #endif else @@ -976,15 +975,16 @@ void keyboard_scan_task(void *u) /* Check for keys down */ if (check_keys_changed(debounced_state)) { - poll_deadline.val = start.val - + keyscan_config.poll_timeout_us; + poll_deadline.val = + start.val + + keyscan_config.poll_timeout_us; } else if (timestamp_expired(poll_deadline, &start)) { break; } /* Delay between scans */ wait_time = keyscan_config.scan_period_us - - (get_time().val - start.val); + (get_time().val - start.val); if (wait_time < keyscan_config.min_post_scan_delay_us) wait_time = @@ -1046,8 +1046,7 @@ mkbp_command_simulate_key(struct host_cmd_handler_args *args) return EC_RES_SUCCESS; } -DECLARE_HOST_COMMAND(EC_CMD_MKBP_SIMULATE_KEY, - mkbp_command_simulate_key, +DECLARE_HOST_COMMAND(EC_CMD_MKBP_SIMULATE_KEY, mkbp_command_simulate_key, EC_VER_MASK(0)); #ifdef CONFIG_KEYBOARD_FACTORY_TEST @@ -1065,17 +1064,15 @@ int keyboard_factory_test_scan(void) /* Set all of KSO/KSI pins to internal pull-up and input */ for (i = 0; i < keyboard_factory_scan_pins_used; i++) { - if (keyboard_factory_scan_pins[i][0] < 0) continue; port = keyboard_factory_scan_pins[i][0]; id = keyboard_factory_scan_pins[i][1]; - gpio_set_alternate_function(port, 1 << id, - GPIO_ALT_FUNC_NONE); + gpio_set_alternate_function(port, 1 << id, GPIO_ALT_FUNC_NONE); gpio_set_flags_by_mask(port, 1 << id, - GPIO_INPUT | GPIO_PULL_UP); + GPIO_INPUT | GPIO_PULL_UP); } /* @@ -1083,7 +1080,6 @@ int keyboard_factory_test_scan(void) * going to low level, it indicate the two pins are shorted. */ for (i = 0; i < keyboard_factory_scan_pins_used; i++) { - if (keyboard_factory_scan_pins[i][0] < 0) continue; @@ -1093,19 +1089,18 @@ int keyboard_factory_test_scan(void) gpio_set_flags_by_mask(port, 1 << id, GPIO_OUT_LOW); for (j = 0; j < keyboard_factory_scan_pins_used; j++) { - if (keyboard_factory_scan_pins[j][0] < 0 || i == j) continue; if (keyboard_raw_is_input_low( - keyboard_factory_scan_pins[j][0], - keyboard_factory_scan_pins[j][1])) { + keyboard_factory_scan_pins[j][0], + keyboard_factory_scan_pins[j][1])) { shorted = i << 8 | j; goto done; } } gpio_set_flags_by_mask(port, 1 << id, - GPIO_INPUT | GPIO_PULL_UP); + GPIO_INPUT | GPIO_PULL_UP); } done: gpio_config_module(MODULE_KEYBOARD_SCAN, 1); @@ -1133,8 +1128,7 @@ static enum ec_status keyboard_factory_test(struct host_cmd_handler_args *args) return EC_RES_SUCCESS; } -DECLARE_HOST_COMMAND(EC_CMD_KEYBOARD_FACTORY_TEST, - keyboard_factory_test, +DECLARE_HOST_COMMAND(EC_CMD_KEYBOARD_FACTORY_TEST, keyboard_factory_test, EC_VER_MASK(0)); #endif @@ -1175,14 +1169,12 @@ static int command_ksstate(int argc, char **argv) print_state(debounced_state, "debounced "); print_state(debouncing, "debouncing"); - ccprintf("Keyboard scan disable mask: 0x%08x\n", - disable_scanning_mask); + ccprintf("Keyboard scan disable mask: 0x%08x\n", disable_scanning_mask); ccprintf("Keyboard scan state printing %s\n", print_state_changes ? "on" : "off"); return EC_SUCCESS; } -DECLARE_CONSOLE_COMMAND(ksstate, command_ksstate, - "ksstate [on | off | force]", +DECLARE_CONSOLE_COMMAND(ksstate, command_ksstate, "ksstate [on | off | force]", "Show or toggle printing keyboard scan state"); static int command_keyboard_press(int argc, char **argv) @@ -1226,7 +1218,6 @@ static int command_keyboard_press(int argc, char **argv) return EC_SUCCESS; } -DECLARE_CONSOLE_COMMAND(kbpress, command_keyboard_press, - "[col row [0 | 1]]", +DECLARE_CONSOLE_COMMAND(kbpress, command_keyboard_press, "[col row [0 | 1]]", "Simulate keypress"); #endif |