diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2018-10-16 15:16:29 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-10-19 23:21:56 -0700 |
commit | 9a890ad22965daa7e9365a0b2cb8c734ae41a842 (patch) | |
tree | 27e3f1f0845031e685fc46ffdad44d8cb87adfeb /include | |
parent | 4d4d8f06e91090336c2eb29ee00ca86fea2bb796 (diff) | |
download | chrome-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>
Diffstat (limited to 'include')
-rw-r--r-- | include/keyboard_8042_sharedlib.h | 8 | ||||
-rw-r--r-- | include/keyboard_config.h | 9 | ||||
-rw-r--r-- | include/keyboard_raw.h | 2 | ||||
-rw-r--r-- | include/keyboard_scan.h | 4 | ||||
-rw-r--r-- | include/keyboard_test.h | 2 |
5 files changed, 16 insertions, 9 deletions
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]; }; /** |