From 201c108a37350ee83f214cd4c8cd046ab71b6eaa Mon Sep 17 00:00:00 2001 From: Daisuke Nojiri Date: Mon, 16 May 2022 17:18:50 +0000 Subject: keyboard: Add register_scancode_set2 API register_scancode_set2 API allows each board to install an entire scancode set. BUG=b:220800586 BRANCH=None TEST=buildall Signed-off-by: Daisuke Nojiri Change-Id: Ideafef9a4fce6197e56eee6e28acceff77803681 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3644693 Reviewed-by: Parth Malkan --- common/keyboard_8042_sharedlib.c | 8 ++++++++ include/keyboard_8042_sharedlib.h | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/common/keyboard_8042_sharedlib.c b/common/keyboard_8042_sharedlib.c index 1d024d3f47..8617d13871 100644 --- a/common/keyboard_8042_sharedlib.c +++ b/common/keyboard_8042_sharedlib.c @@ -5,6 +5,8 @@ * Objects which can be shared between RO and RW for 8042 keyboard protocol. */ +#include + #include "button.h" #include "keyboard_8042_sharedlib.h" #include "keyboard_config.h" @@ -37,6 +39,12 @@ static uint16_t scancode_set2[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = { #endif }; +void register_scancode_set2(uint16_t **scancode_set, size_t size) +{ + ASSERT(size == sizeof(scancode_set2)); + memcpy(scancode_set2, scancode_set, size); +} + uint16_t get_scancode_set2(uint8_t row, uint8_t col) { if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS) diff --git a/include/keyboard_8042_sharedlib.h b/include/keyboard_8042_sharedlib.h index 6c2e37fbf4..b03380ce4c 100644 --- a/include/keyboard_8042_sharedlib.h +++ b/include/keyboard_8042_sharedlib.h @@ -8,6 +8,8 @@ #ifndef __CROS_EC_KEYBOARD_8042_SHAREDLIB_H #define __CROS_EC_KEYBOARD_8042_SHAREDLIB_H +#include + #include "button.h" #include "keyboard_config.h" #include "keyboard_protocol.h" @@ -17,6 +19,14 @@ struct button_8042_t { int repeat; }; +/** + * Register scancode set for the standard ChromeOS keyboard matrix set 2. + * + * @param scancode_set Scancode set to register. + * @param size Size of the scancode set in bytes. + */ +void register_scancode_set2(uint16_t **scancode_set, size_t size); + /** * Get the standard Chrome OS keyboard matrix set 2 scanset * @param row Row number -- cgit v1.2.1