keyboard_8042: Allow scancode sets to be mutable

Add an option to allow the scancode sets to be mutable.  The only
reason to use this is to allow a scancode to be changed at runtime,
for instance to support different keyboards in one image.

The side effect of this is the scancode sets are moved out of the
shared RO section.

BUG=b:36735408
BRANCH=none
TEST=make -j buildall

Change-Id: Iefb97691d1f295411d7b5db603d9214d41af49fd
Signed-off-by: Duncan Laurie <dlaurie@google.com>
Reviewed-on: https://chromium-review.googlesource.com/506717
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
This commit is contained in:
Duncan Laurie
2017-05-16 07:37:33 -07:00
committed by chrome-bot
parent 11237d5e91
commit 76e064815f
3 changed files with 27 additions and 1 deletions

View File

@@ -13,7 +13,11 @@
#include "util.h"
/* The standard Chrome OS keyboard matrix table. */
#ifdef CONFIG_KEYBOARD_SCANCODE_MUTABLE
uint16_t scancode_set1[KEYBOARD_ROWS][KEYBOARD_COLS] = {
#else
SHAREDLIB(const uint16_t scancode_set1[KEYBOARD_ROWS][KEYBOARD_COLS] = {
#endif
{0x0000, 0xe05b, 0x003b, 0x0030, 0x0044, 0x0073, 0x0031, 0x0000, 0x000d,
0x0000, 0xe038, 0x0000, 0x0000},
{0x0000, 0x0001, 0x003e, 0x0022, 0x0041, 0x0000, 0x0023, 0x0000, 0x0028,
@@ -30,9 +34,17 @@ SHAREDLIB(const uint16_t scancode_set1[KEYBOARD_ROWS][KEYBOARD_COLS] = {
0x000a, 0x0038, 0xe050, 0xe04d},
{0x0000, 0x0010, 0x0012, 0x0013, 0x0011, 0x0017, 0x0016, 0x0036, 0x0019,
0x0018, 0x0000, 0xe048, 0xe04b},
#ifdef CONFIG_KEYBOARD_SCANCODE_MUTABLE
};
#else
});
#endif
SHAREDLIB(const uint16_t scancode_set2[KEYBOARD_ROWS][KEYBOARD_COLS] = {
#ifdef CONFIG_KEYBOARD_SCANCODE_MUTABLE
uint16_t scancode_set2[KEYBOARD_ROWS][KEYBOARD_COLS] = {
#else
SHAREDLIB(uint16_t const scancode_set2[KEYBOARD_ROWS][KEYBOARD_COLS] = {
#endif
{0x0000, 0xe01f, 0x0005, 0x0032, 0x0009, 0x0051, 0x0031, 0x0000, 0x0055,
0x0000, 0xe011, 0x0000, 0x0000},
{0x0000, 0x0076, 0x000c, 0x0034, 0x0083, 0x0000, 0x0033, 0x0000, 0x0052,
@@ -49,7 +61,11 @@ SHAREDLIB(const uint16_t scancode_set2[KEYBOARD_ROWS][KEYBOARD_COLS] = {
0x0046, 0x0011, 0xe072, 0xe074},
{0x0000, 0x0015, 0x0024, 0x002d, 0x001d, 0x0043, 0x003c, 0x0059, 0x004d,
0x0044, 0x0000, 0xe075, 0xe06b},
#ifdef CONFIG_KEYBOARD_SCANCODE_MUTABLE
};
#else
});
#endif
/*
* Button scancodes.

View File

@@ -1551,6 +1551,11 @@
*/
#define CONFIG_KEYBOARD_RUNTIME_KEYS
/*
* Allow the keyboard scan code set tables to be modified at runtime.
*/
#undef CONFIG_KEYBOARD_SCANCODE_MUTABLE
/*
* Call board-supplied keyboard_suppress_noise() function when the debounced
* keyboard state changes. Some boards use this to send a signal to the audio

View File

@@ -19,8 +19,13 @@ struct button_8042_t {
};
/* The standard Chrome OS keyboard matrix table. */
#ifdef CONFIG_KEYBOARD_SCANCODE_MUTABLE
extern uint16_t scancode_set1[KEYBOARD_ROWS][KEYBOARD_COLS];
extern uint16_t scancode_set2[KEYBOARD_ROWS][KEYBOARD_COLS];
#else
extern const uint16_t scancode_set1[KEYBOARD_ROWS][KEYBOARD_COLS];
extern const uint16_t scancode_set2[KEYBOARD_ROWS][KEYBOARD_COLS];
#endif
/* Button scancodes (Power, Volume Down, Volume Up, etc.) */
extern const struct button_8042_t buttons_8042[KEYBOARD_BUTTON_COUNT];