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 /chip | |
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 'chip')
-rw-r--r-- | chip/npcx/keyboard_raw.c | 2 | ||||
-rw-r--r-- | chip/nrf51/keyboard_raw.c | 4 | ||||
-rw-r--r-- | chip/stm32/clock-stm32l.c | 2 | ||||
-rw-r--r-- | chip/stm32/keyboard_raw.c | 2 | ||||
-rw-r--r-- | chip/stm32/usb_hid_keyboard.c | 2 |
5 files changed, 6 insertions, 6 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}, |