summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2018-10-16 15:16:29 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-10-19 23:21:56 -0700
commit9a890ad22965daa7e9365a0b2cb8c734ae41a842 (patch)
tree27e3f1f0845031e685fc46ffdad44d8cb87adfeb
parent4d4d8f06e91090336c2eb29ee00ca86fea2bb796 (diff)
downloadchrome-ec-9a890ad22965daa7e9365a0b2cb8c734ae41a842.tar.gz
Keyboard: Allow keyboard size to be set at run time
Currently, the keyboard size (i.e. number of columns) is static. This patch allows it to be configured at run time. It's required to support a keyboard with/without keypad in a single image. KEYBOARD_COLS_MAX has the build time col size. It's used to allocate exact spaces for arrays. Actual keyboard scanning is done using keyboard_cols, which holds a runtime col size. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:117126568 BRANCH=none TEST=Verify keyboard functionality on Sona and Veyron. Change-Id: I4b3552be0b4b315c3fe5a6884cf25e10aba8be7c Reviewed-on: https://chromium-review.googlesource.com/1285292 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--chip/npcx/keyboard_raw.c2
-rw-r--r--chip/nrf51/keyboard_raw.c4
-rw-r--r--chip/stm32/clock-stm32l.c2
-rw-r--r--chip/stm32/keyboard_raw.c2
-rw-r--r--chip/stm32/usb_hid_keyboard.c2
-rw-r--r--common/keyboard_8042.c2
-rw-r--r--common/keyboard_8042_sharedlib.c4
-rw-r--r--common/keyboard_mkbp.c13
-rw-r--r--common/keyboard_scan.c53
-rw-r--r--common/keyboard_test.c2
-rw-r--r--include/keyboard_8042_sharedlib.h8
-rw-r--r--include/keyboard_config.h9
-rw-r--r--include/keyboard_raw.h2
-rw-r--r--include/keyboard_scan.h4
-rw-r--r--include/keyboard_test.h2
-rw-r--r--test/button.c3
-rw-r--r--test/kb_mkbp.c6
-rw-r--r--test/kb_scan.c4
-rw-r--r--util/ectool_keyscan.c4
19 files changed, 72 insertions, 56 deletions
diff --git a/chip/npcx/keyboard_raw.c b/chip/npcx/keyboard_raw.c
index 8c2915b542..1713d2c931 100644
--- a/chip/npcx/keyboard_raw.c
+++ b/chip/npcx/keyboard_raw.c
@@ -101,7 +101,7 @@ test_mockable void keyboard_raw_drive_column(int col)
}
/* Set KBSOUT to zero to detect key-press */
else if (col == KEYBOARD_COLUMN_ALL) {
- mask = ~((1 << KEYBOARD_COLS) - 1);
+ mask = ~((1 << keyboard_cols) - 1);
#ifdef CONFIG_KEYBOARD_COL2_INVERTED
gpio_set_level(GPIO_KBD_KSO2, 1);
#endif
diff --git a/chip/nrf51/keyboard_raw.c b/chip/nrf51/keyboard_raw.c
index 6db9840499..7eaf8f995c 100644
--- a/chip/nrf51/keyboard_raw.c
+++ b/chip/nrf51/keyboard_raw.c
@@ -8,7 +8,7 @@
* input and output entries in the board's gpio_list[]. Each set of inputs or
* outputs must be listed in consecutive, increasing order so that scan loops
* can iterate beginning at KB_IN00 or KB_OUT00 for however many GPIOs are
- * utilized (KEYBOARD_ROWS or KEYBOARD_COLS).
+ * utilized (KEYBOARD_ROWS or KEYBOARD_COLS_MAX).
*/
#include "gpio.h"
@@ -28,7 +28,7 @@ void keyboard_raw_init(void)
/* Initialize col_mask */
col_mask = 0;
- for (i = 0; i < KEYBOARD_COLS; i++)
+ for (i = 0; i < keyboard_cols; i++)
col_mask |= gpio_list[GPIO_KB_OUT00 + i].mask;
/* Ensure interrupts are disabled */
diff --git a/chip/stm32/clock-stm32l.c b/chip/stm32/clock-stm32l.c
index 7125821040..93706c7019 100644
--- a/chip/stm32/clock-stm32l.c
+++ b/chip/stm32/clock-stm32l.c
@@ -281,7 +281,7 @@ void __enter_hibernate(uint32_t seconds, uint32_t microseconds)
*
* A little hacky to do this here.
*/
- for (i = GPIO_KB_OUT00; i < GPIO_KB_OUT00 + KEYBOARD_COLS; i++)
+ for (i = GPIO_KB_OUT00; i < GPIO_KB_OUT00 + KEYBOARD_COLS_MAX; i++)
gpio_set_flags(i, GPIO_INPUT);
ccprints("fake hibernate. waits for power button/lid/RTC/AC");
diff --git a/chip/stm32/keyboard_raw.c b/chip/stm32/keyboard_raw.c
index 4ac7f2dcb2..875a92e484 100644
--- a/chip/stm32/keyboard_raw.c
+++ b/chip/stm32/keyboard_raw.c
@@ -8,7 +8,7 @@
* input and output entries in the board's gpio_list[]. Each set of inputs or
* outputs must be listed in consecutive, increasing order so that scan loops
* can iterate beginning at KB_IN00 or KB_OUT00 for however many GPIOs are
- * utilized (KEYBOARD_ROWS or KEYBOARD_COLS).
+ * utilized (KEYBOARD_ROWS or KEYBOARD_COLS_MAX).
*/
#include "gpio.h"
diff --git a/chip/stm32/usb_hid_keyboard.c b/chip/stm32/usb_hid_keyboard.c
index e177aa8ed7..7ce74940ed 100644
--- a/chip/stm32/usb_hid_keyboard.c
+++ b/chip/stm32/usb_hid_keyboard.c
@@ -116,7 +116,7 @@ struct usb_hid_keyboard_output_report {
*
* Assistant key is mapped as 0xf0, but this key code is never actually send.
*/
-const uint8_t keycodes[KEYBOARD_COLS][KEYBOARD_ROWS] = {
+const uint8_t keycodes[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = {
{0x00, 0x00, 0xe0, 0xe3, 0xe4, HID_KEYBOARD_ASSISTANT_KEY, 0x00, 0x00},
{0xe3, 0x29, 0x2b, 0x35, 0x04, 0x1d, 0x1e, 0x14},
{0x3a, 0x3d, 0x3c, 0x3b, 0x07, 0x06, 0x20, 0x08},
diff --git a/common/keyboard_8042.c b/common/keyboard_8042.c
index 124ac8adee..f45b84d465 100644
--- a/common/keyboard_8042.c
+++ b/common/keyboard_8042.c
@@ -306,7 +306,7 @@ static enum ec_error_list matrix_callback(int8_t row, int8_t col,
ASSERT(scan_code);
ASSERT(len);
- if (row >= KEYBOARD_ROWS || col >= KEYBOARD_COLS)
+ if (row >= KEYBOARD_ROWS || col >= keyboard_cols)
return EC_ERROR_INVAL;
make_code = scancode_set2[col][row];
diff --git a/common/keyboard_8042_sharedlib.c b/common/keyboard_8042_sharedlib.c
index 98d71cc1f9..a189d17744 100644
--- a/common/keyboard_8042_sharedlib.c
+++ b/common/keyboard_8042_sharedlib.c
@@ -16,7 +16,7 @@
#ifndef CONFIG_KEYBOARD_SCANCODE_MUTABLE
SHAREDLIB(const
#endif
-uint16_t scancode_set2[KEYBOARD_COLS][KEYBOARD_ROWS] = {
+uint16_t scancode_set2[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = {
{0x0000, 0x0000, 0x0014, 0xe01f, 0xe014, 0xe007, 0x0000, 0x0000},
{0xe01f, 0x0076, 0x000d, 0x000e, 0x001c, 0x001a, 0x0016, 0x0015},
{0x0005, 0x000c, 0x0004, 0x0006, 0x0023, 0x0021, 0x0026, 0x0024},
@@ -79,7 +79,7 @@ char * const keycap_long_label[KLLI_MAX & KEYCAP_LONG_LABEL_INDEX_BITMASK] = {
#ifndef CONFIG_KEYBOARD_SCANCODE_MUTABLE
SHAREDLIB(const
#endif
-char keycap_label[KEYBOARD_COLS][KEYBOARD_ROWS] = {
+char keycap_label[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = {
{KLLI_UNKNO, KLLI_UNKNO, KLLI_L_CTR, KLLI_UNKNO,
KLLI_R_CTR, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO},
{KLLI_SEARC, KLLI_ESC, KLLI_TAB, '~',
diff --git a/common/keyboard_mkbp.c b/common/keyboard_mkbp.c
index efd86f2e10..186475b4dd 100644
--- a/common/keyboard_mkbp.c
+++ b/common/keyboard_mkbp.c
@@ -72,7 +72,8 @@ static uint32_t mkbp_button_state;
static uint32_t mkbp_switch_state;
#ifndef HAS_TASK_KEYSCAN
/* Keys simulated-pressed */
-static uint8_t __bss_slow simulated_key[KEYBOARD_COLS];
+static uint8_t __bss_slow simulated_key[KEYBOARD_COLS_MAX];
+uint8_t keyboard_cols = KEYBOARD_COLS_MAX;
#endif /* !defined(HAS_TASK_KEYSCAN) */
/* Config for mkbp protocol; does not include fields from scan config */
@@ -99,7 +100,7 @@ static int get_data_size(enum ec_mkbp_event e)
{
switch (e) {
case EC_MKBP_EVENT_KEY_MATRIX:
- return KEYBOARD_COLS;
+ return keyboard_cols;
#ifdef CONFIG_HOST_EVENT64
case EC_MKBP_EVENT_HOST_EVENT64:
@@ -396,7 +397,7 @@ DECLARE_EVENT_SOURCE(EC_MKBP_EVENT_SYSRQ, sysrq_get_next_event);
void keyboard_send_battery_key(void)
{
- uint8_t state[KEYBOARD_COLS];
+ uint8_t state[KEYBOARD_COLS_MAX];
/* Copy debounced state and add battery pseudo-key */
memcpy(state, keyboard_scan_get_state(), sizeof(state));
@@ -456,7 +457,7 @@ static int mkbp_get_info(struct host_cmd_handler_args *args)
/* Version 0 just returns info about the keyboard. */
r->rows = KEYBOARD_ROWS;
- r->cols = KEYBOARD_COLS;
+ r->cols = keyboard_cols;
/* This used to be "switches" which was previously 0. */
r->reserved = 0;
@@ -551,7 +552,7 @@ static int command_mkbp_keyboard_press(int argc, char **argv)
int i, j;
ccputs("Simulated keys:\n");
- for (i = 0; i < KEYBOARD_COLS; ++i) {
+ for (i = 0; i < keyboard_cols; ++i) {
if (simulated_key[i] == 0)
continue;
for (j = 0; j < KEYBOARD_ROWS; ++j)
@@ -564,7 +565,7 @@ static int command_mkbp_keyboard_press(int argc, char **argv)
char *e;
c = strtoi(argv[1], &e, 0);
- if (*e || c < 0 || c >= KEYBOARD_COLS)
+ if (*e || c < 0 || c >= keyboard_cols)
return EC_ERROR_PARAM1;
r = strtoi(argv[2], &e, 0);
diff --git a/common/keyboard_scan.c b/common/keyboard_scan.c
index 034b82519c..f9a64eb806 100644
--- a/common/keyboard_scan.c
+++ b/common/keyboard_scan.c
@@ -82,14 +82,16 @@ static const struct boot_key_entry boot_key_list[] = {
static uint32_t boot_key_value = BOOT_KEY_NONE;
#endif
+uint8_t keyboard_cols = KEYBOARD_COLS_MAX;
+
/* Debounced key matrix */
-static uint8_t __bss_slow debounced_state[KEYBOARD_COLS];
+static uint8_t __bss_slow debounced_state[KEYBOARD_COLS_MAX];
/* Matrix from previous scan */
-static uint8_t __bss_slow prev_state[KEYBOARD_COLS];
+static uint8_t __bss_slow prev_state[KEYBOARD_COLS_MAX];
/* Mask of keys being debounced */
-static uint8_t __bss_slow debouncing[KEYBOARD_COLS];
+static uint8_t __bss_slow debouncing[KEYBOARD_COLS_MAX];
/* Keys simulated-pressed */
-static uint8_t __bss_slow simulated_key[KEYBOARD_COLS];
+static uint8_t __bss_slow simulated_key[KEYBOARD_COLS_MAX];
#ifdef CONFIG_KEYBOARD_LANGUAGE_ID
static uint8_t __bss_slow keyboard_id[KEYBOARD_IDS];
#endif
@@ -100,7 +102,7 @@ static uint32_t __bss_slow scan_time[SCAN_TIME_COUNT];
static int __bss_slow scan_time_index;
/* Index into scan_time[] when each key started debouncing */
-static uint8_t __bss_slow scan_edge_index[KEYBOARD_COLS][KEYBOARD_ROWS];
+static uint8_t __bss_slow scan_edge_index[KEYBOARD_COLS_MAX][KEYBOARD_ROWS];
/* Minimum delay between keyboard scans based on current clock frequency */
static uint32_t __bss_slow post_scan_clock_us;
@@ -151,7 +153,7 @@ static void print_state(const uint8_t *state, const char *msg)
int c;
CPRINTF("[%T KB %s:", msg);
- for (c = 0; c < KEYBOARD_COLS; c++) {
+ for (c = 0; c < keyboard_cols; c++) {
if (state[c])
CPRINTF(" %02x", state[c]);
else
@@ -227,7 +229,7 @@ static void simulate_key(int row, int col, int pressed)
* Used in pre-init, so must not make task-switching-dependent calls; udelay()
* is ok because it's a spin-loop.
*
- * @param state Destination for new state (must be KEYBOARD_COLS long).
+ * @param state Destination for new state (must be KEYBOARD_COLS_MAX long).
*
* @return 1 if at least one key is pressed, else zero.
*/
@@ -237,7 +239,7 @@ static int read_matrix(uint8_t *state)
uint8_t r;
int pressed = 0;
- for (c = 0; c < KEYBOARD_COLS; c++) {
+ for (c = 0; c < keyboard_cols; c++) {
/*
* Stop if scanning becomes disabled. Note, scanning is enabled
* on boot by default.
@@ -294,8 +296,11 @@ static void read_matrix_id(uint8_t *id)
int c;
for (c = 0; c < KEYBOARD_IDS; c++) {
- /* Select the ID pin, then wait a bit for it to settle */
- keyboard_raw_drive_column(KEYBOARD_COLS + c);
+ /* Select the ID pin, then wait a bit for it to settle.
+ * Caveat: If a keyboard maker puts ID pins right after scan
+ * columns, we can't support variable column size with a single
+ * image. */
+ keyboard_raw_drive_column(KEYBOARD_COLS_MAX + c);
udelay(keyscan_config.output_settle_us);
/* Read the row state */
@@ -378,7 +383,7 @@ static int check_runtime_keys(const uint8_t *state)
* pressed for volume up and alt, so if only one more key is pressed
* there will be exactly 3 non-zero columns.
*/
- for (c = 0; c < KEYBOARD_COLS; c++) {
+ for (c = 0; c < keyboard_cols; c++) {
if (state[c])
num_press++;
}
@@ -419,11 +424,11 @@ static int has_ghosting(const uint8_t *state)
{
int c, c2;
- for (c = 0; c < KEYBOARD_COLS; c++) {
+ for (c = 0; c < keyboard_cols; c++) {
if (!state[c])
continue;
- for (c2 = c + 1; c2 < KEYBOARD_COLS; c2++) {
+ for (c2 = c + 1; c2 < keyboard_cols; c2++) {
/*
* A little bit of cleverness here. Ghosting happens
* if 2 columns share at least 2 keys. So we OR the
@@ -453,7 +458,7 @@ static int check_keys_changed(uint8_t *state)
int any_pressed = 0;
int c, i;
int any_change = 0;
- static uint8_t __bss_slow new_state[KEYBOARD_COLS];
+ static uint8_t __bss_slow new_state[KEYBOARD_COLS_MAX];
uint32_t tnow = get_time().le.lo;
/* Save the current scan time */
@@ -469,7 +474,7 @@ static int check_keys_changed(uint8_t *state)
return any_pressed;
/* Check for changes between previous scan and this one */
- for (c = 0; c < KEYBOARD_COLS; c++) {
+ for (c = 0; c < keyboard_cols; c++) {
int diff = new_state[c] ^ prev_state[c];
if (!diff)
@@ -485,7 +490,7 @@ static int check_keys_changed(uint8_t *state)
}
/* Check for keys which are done debouncing */
- for (c = 0; c < KEYBOARD_COLS; c++) {
+ for (c = 0; c < keyboard_cols; c++) {
int debc = debouncing[c];
if (!debc)
@@ -567,7 +572,7 @@ static int check_keys_changed(uint8_t *state)
*/
static uint32_t check_key_list(const uint8_t *state)
{
- uint8_t curr_state[KEYBOARD_COLS];
+ uint8_t curr_state[KEYBOARD_COLS_MAX];
int c;
uint32_t boot_key_mask = BOOT_KEY_NONE;
const struct boot_key_entry *k;
@@ -580,13 +585,13 @@ static uint32_t check_key_list(const uint8_t *state)
* Check if KSI2 or KSI3 is asserted for all columns due to power
* button hold, and ignore it if so.
*/
- for (c = 0; c < KEYBOARD_COLS; c++)
+ for (c = 0; c < keyboard_cols; c++)
if ((keyscan_config.actual_key_mask[c] & KEYBOARD_MASK_PWRBTN)
&& !(curr_state[c] & KEYBOARD_MASK_PWRBTN))
break;
- if (c == KEYBOARD_COLS)
- for (c = 0; c < KEYBOARD_COLS; c++)
+ if (c == keyboard_cols)
+ for (c = 0; c < keyboard_cols; c++)
curr_state[c] &= ~KEYBOARD_MASK_PWRBTN;
#endif
@@ -602,7 +607,7 @@ static uint32_t check_key_list(const uint8_t *state)
}
/* If any other key was pressed, ignore all boot keys. */
- for (c = 0; c < KEYBOARD_COLS; c++) {
+ for (c = 0; c < keyboard_cols; c++) {
if (curr_state[c])
return BOOT_KEY_NONE;
}
@@ -844,7 +849,7 @@ static int mkbp_command_simulate_key(struct host_cmd_handler_args *args)
if (system_is_locked())
return EC_RES_ACCESS_DENIED;
- if (p->col >= KEYBOARD_COLS || p->row >= KEYBOARD_ROWS)
+ if (p->col >= keyboard_cols || p->row >= KEYBOARD_ROWS)
return EC_RES_INVALID_PARAM;
simulate_key(p->row, p->col, p->pressed);
@@ -933,7 +938,7 @@ static int command_keyboard_press(int argc, char **argv)
int i, j;
ccputs("Simulated keys:\n");
- for (i = 0; i < KEYBOARD_COLS; ++i) {
+ for (i = 0; i < keyboard_cols; ++i) {
if (simulated_key[i] == 0)
continue;
for (j = 0; j < KEYBOARD_ROWS; ++j)
@@ -946,7 +951,7 @@ static int command_keyboard_press(int argc, char **argv)
char *e;
c = strtoi(argv[1], &e, 0);
- if (*e || c < 0 || c >= KEYBOARD_COLS)
+ if (*e || c < 0 || c >= keyboard_cols)
return EC_ERROR_PARAM1;
r = strtoi(argv[2], &e, 0);
diff --git a/common/keyboard_test.c b/common/keyboard_test.c
index 580d4745cf..fee7d6db69 100644
--- a/common/keyboard_test.c
+++ b/common/keyboard_test.c
@@ -78,7 +78,7 @@ uint8_t keyscan_seq_get_scan(int column, uint8_t scan)
int c;
scan = 0;
- for (c = 0; c < KEYBOARD_COLS; c++)
+ for (c = 0; c < keyboard_cols; c++)
scan |= item->scan[c];
} else {
scan = item->scan[column];
diff --git a/include/keyboard_8042_sharedlib.h b/include/keyboard_8042_sharedlib.h
index 1cff2544dc..a70312f3d8 100644
--- a/include/keyboard_8042_sharedlib.h
+++ b/include/keyboard_8042_sharedlib.h
@@ -19,9 +19,9 @@ struct button_8042_t {
/* The standard Chrome OS keyboard matrix table. */
#ifdef CONFIG_KEYBOARD_SCANCODE_MUTABLE
-extern uint16_t scancode_set2[KEYBOARD_COLS][KEYBOARD_ROWS];
+extern uint16_t scancode_set2[KEYBOARD_COLS_MAX][KEYBOARD_ROWS];
#else
-extern const uint16_t scancode_set2[KEYBOARD_COLS][KEYBOARD_ROWS];
+extern const uint16_t scancode_set2[KEYBOARD_COLS_MAX][KEYBOARD_ROWS];
#endif
/* Translation from scan code set 2 to set 1. */
@@ -70,9 +70,9 @@ enum keycap_long_label_idx {
extern const char * const keycap_long_label[];
#ifdef CONFIG_KEYBOARD_SCANCODE_MUTABLE
-extern char keycap_label[KEYBOARD_COLS][KEYBOARD_ROWS];
+extern char keycap_label[KEYBOARD_COLS_MAX][KEYBOARD_ROWS];
#else
-extern const char keycap_label[KEYBOARD_COLS][KEYBOARD_ROWS];
+extern const char keycap_label[KEYBOARD_COLS_MAX][KEYBOARD_ROWS];
#endif
#endif
diff --git a/include/keyboard_config.h b/include/keyboard_config.h
index 932935de4c..81174eb850 100644
--- a/include/keyboard_config.h
+++ b/include/keyboard_config.h
@@ -16,9 +16,16 @@
#endif
/* Keyboard matrix is 13 output columns x 8 input rows */
-#define KEYBOARD_COLS 13
+/*
+ * KEYBOARD_COLS_MAX has the build time column size. It's used to allocate
+ * exact spaces for arrays. Actual keyboard scanning is done using
+ * keyboard_cols, which holds a runtime column size.
+ */
+#define KEYBOARD_COLS_MAX 13
#define KEYBOARD_ROWS 8
+extern uint8_t keyboard_cols;
+
#define KEYBOARD_ROW_TO_MASK(r) (1 << (r))
/* Columns and masks for keys we particularly care about */
diff --git a/include/keyboard_raw.h b/include/keyboard_raw.h
index db13852635..d2c3e6b38b 100644
--- a/include/keyboard_raw.h
+++ b/include/keyboard_raw.h
@@ -18,7 +18,7 @@
enum keyboard_column_index {
KEYBOARD_COLUMN_ALL = -2, /* Drive all columns */
KEYBOARD_COLUMN_NONE = -1, /* Drive no columns (tri-state all) */
- /* 0 ~ KEYBOARD_COLS-1 for the corresponding column */
+ /* 0 ~ KEYBOARD_COLS_MAX-1 for the corresponding column */
};
/**
diff --git a/include/keyboard_scan.h b/include/keyboard_scan.h
index 7e16fe732f..4bb44434fc 100644
--- a/include/keyboard_scan.h
+++ b/include/keyboard_scan.h
@@ -30,7 +30,7 @@ struct keyboard_scan_config {
/* Revert to interrupt mode after no keyboard activity for this long */
uint32_t poll_timeout_us;
/* Mask with 1 bits only for keys that actually exist */
- uint8_t actual_key_mask[KEYBOARD_COLS];
+ uint8_t actual_key_mask[KEYBOARD_COLS_MAX];
};
/**
@@ -78,7 +78,7 @@ static inline uint32_t keyboard_scan_get_boot_keys(void)
/**
* Return a pointer to the current debounced keyboard matrix state, which is
- * KEYBOARD_COLS bytes long.
+ * KEYBOARD_COLS_MAX bytes long.
*/
const uint8_t *keyboard_scan_get_state(void);
diff --git a/include/keyboard_test.h b/include/keyboard_test.h
index b1e4abb9c5..46166dfe69 100644
--- a/include/keyboard_test.h
+++ b/include/keyboard_test.h
@@ -19,7 +19,7 @@ struct keyscan_item {
timestamp_t abs_time; /* absolute timestamp to present this item */
uint32_t time_us; /* time for this item relative to test start */
uint8_t done; /* 1 if we managed to present this */
- uint8_t scan[KEYBOARD_COLS];
+ uint8_t scan[KEYBOARD_COLS_MAX];
};
/**
diff --git a/test/button.c b/test/button.c
index 73172abbfd..8cd82f93c2 100644
--- a/test/button.c
+++ b/test/button.c
@@ -16,10 +16,13 @@
#include "gpio.h"
#include "test_util.h"
#include "timer.h"
+#include "keyboard_config.h"
#include "keyboard_protocol.h"
#define UNCHANGED -1
+uint8_t keyboard_cols = KEYBOARD_COLS_MAX;
+
static const struct button_config *button_vol_down =
&buttons[BUTTON_VOLUME_DOWN];
static const struct button_config *button_vol_up = &buttons[BUTTON_VOLUME_UP];
diff --git a/test/kb_mkbp.c b/test/kb_mkbp.c
index f838a0c411..15952e74bb 100644
--- a/test/kb_mkbp.c
+++ b/test/kb_mkbp.c
@@ -16,7 +16,7 @@
#include "test_util.h"
#include "util.h"
-static uint8_t state[KEYBOARD_COLS];
+static uint8_t state[KEYBOARD_COLS_MAX];
static int ec_int_level;
static const char *action[2] = {"release", "press"};
@@ -48,7 +48,7 @@ int lid_is_open(void)
void clear_state(void)
{
- memset(state, 0xff, KEYBOARD_COLS);
+ memset(state, 0xff, KEYBOARD_COLS_MAX);
}
void set_state(int c, int r, int pressed)
@@ -89,7 +89,7 @@ int verify_key(int c, int r, int pressed)
if (host_command_process(&args) != EC_RES_SUCCESS)
return 0;
- for (i = 0; i < KEYBOARD_COLS; ++i)
+ for (i = 0; i < KEYBOARD_COLS_MAX; ++i)
if (event.data.key_matrix[i] != state[i])
return 0;
} else {
diff --git a/test/kb_scan.c b/test/kb_scan.c
index 75ee1932ed..b364d19368 100644
--- a/test/kb_scan.c
+++ b/test/kb_scan.c
@@ -31,7 +31,7 @@
old = fifo_add_count; \
} while (0)
-static uint8_t mock_state[KEYBOARD_COLS];
+static uint8_t mock_state[KEYBOARD_COLS_MAX];
static int column_driven;
static int fifo_add_count;
static int lid_open;
@@ -60,7 +60,7 @@ int keyboard_raw_read_rows(void)
if (column_driven == KEYBOARD_COLUMN_NONE) {
return 0;
} else if (column_driven == KEYBOARD_COLUMN_ALL) {
- for (i = 0; i < KEYBOARD_COLS; ++i)
+ for (i = 0; i < KEYBOARD_COLS_MAX; ++i)
r |= mock_state[i];
return r;
} else {
diff --git a/util/ectool_keyscan.c b/util/ectool_keyscan.c
index ce35757a19..46ba221f6e 100644
--- a/util/ectool_keyscan.c
+++ b/util/ectool_keyscan.c
@@ -32,7 +32,7 @@ struct matrix_entry {
struct keyscan_test_item {
uint32_t beat; /* Beat number */
- uint8_t scan[KEYBOARD_COLS]; /* Scan data */
+ uint8_t scan[KEYBOARD_COLS_MAX]; /* Scan data */
};
/* A single test, consisting of a list of key scans and expected ascii input */
@@ -103,7 +103,7 @@ static int keyscan_read_fdt_matrix(struct keyscan_info *keyscan,
/* Hard-code some sanity limits for now */
if (matrix->row >= KEYBOARD_ROWS ||
- matrix->col >= KEYBOARD_COLS) {
+ matrix->col >= KEYBOARD_COLS_MAX) {
fprintf(stderr, "Matrix pos out of range (%d,%d)\n",
matrix->row, matrix->col);
fclose(f);