summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/eve/board.c6
-rw-r--r--board/eve/board.h1
-rw-r--r--board/nami/board.c7
-rw-r--r--board/nami/board.h1
-rw-r--r--board/palkia/keyboard_customization.c30
-rw-r--r--common/keyboard_8042.c6
-rw-r--r--common/keyboard_8042_sharedlib.c54
-rw-r--r--include/config.h5
-rw-r--r--include/keyboard_8042_sharedlib.h49
9 files changed, 111 insertions, 48 deletions
diff --git a/board/eve/board.c b/board/eve/board.c
index 8d1b21ccd6..ef5699e2df 100644
--- a/board/eve/board.c
+++ b/board/eve/board.c
@@ -494,13 +494,13 @@ static void board_init(void)
/* Update AC status to the PCH */
board_update_ac_status();
-#if defined(CONFIG_KEYBOARD_SCANCODE_MUTABLE) && !defined(TEST_BUILD)
+#ifndef TEST_BUILD
if (board_get_version() == 4) {
/* Set F13 to new defined key on EVT */
CPRINTS("Overriding F13 scan code");
- scancode_set2[9][3] = 0xe007;
+ set_scancode_set2(3, 9, 0xe007);
#ifdef CONFIG_KEYBOARD_DEBUG
- keycap_label[9][3] = KLLI_F13;
+ set_keycap_label(3, 9, KLLI_F13);
#endif
}
#endif
diff --git a/board/eve/board.h b/board/eve/board.h
index 1df410d6ef..8a46d74156 100644
--- a/board/eve/board.h
+++ b/board/eve/board.h
@@ -73,7 +73,6 @@
#define CONFIG_KEYBOARD_COL2_INVERTED
#define CONFIG_KEYBOARD_PROTOCOL_8042
#define CONFIG_KEYBOARD_REFRESH_ROW3
-#define CONFIG_KEYBOARD_SCANCODE_MUTABLE
#define CONFIG_TABLET_MODE
/* Battery */
diff --git a/board/nami/board.c b/board/nami/board.c
index 358b0bbf22..a5d38bd0d8 100644
--- a/board/nami/board.c
+++ b/board/nami/board.c
@@ -1034,13 +1034,16 @@ static void board_init(void)
/* No need to swap scancode_set2[0][3] and [1][0] because both
* are mapped to search key. */
}
- if (sku & SKU_ID_MASK_UK2)
+ if (sku & SKU_ID_MASK_UK2) {
/*
* Observed on Shyvana with UK keyboard,
* \|: 0x0061->0x61->0x56
* r-ctrl: 0xe014->0x14->0x1d
*/
- swap(scancode_set2[0][4], scancode_set2[7][2]);
+ uint16_t tmp = get_scancode_set2(4, 0);
+ set_scancode_set2(4, 0, get_scancode_set2(2, 7));
+ set_scancode_set2(2, 7, tmp);
+ }
#endif
isl923x_set_ac_prochot(CHARGER_SOLO, 3328 /* mA */);
diff --git a/board/nami/board.h b/board/nami/board.h
index 8159f13c7a..95f5a38ddc 100644
--- a/board/nami/board.h
+++ b/board/nami/board.h
@@ -32,7 +32,6 @@
#define CONFIG_KEYBOARD_COL2_INVERTED
#define CONFIG_KEYBOARD_PROTOCOL_8042
#define CONFIG_KEYBOARD_KEYPAD
-#define CONFIG_KEYBOARD_SCANCODE_MUTABLE
#define CONFIG_LED_COMMON
#define CONFIG_LID_SWITCH
#define CONFIG_LOW_POWER_IDLE
diff --git a/board/palkia/keyboard_customization.c b/board/palkia/keyboard_customization.c
index e83b5ecb99..03c29a5720 100644
--- a/board/palkia/keyboard_customization.c
+++ b/board/palkia/keyboard_customization.c
@@ -10,7 +10,7 @@
#include "keyboard_protocol.h"
#include "keyboard_raw.h"
-uint16_t scancode_set2[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = {
+static uint16_t scancode_set2[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = {
{0x0021, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000},
{0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000},
{0x0015, 0x0000, 0x0000, 0x000d, 0x000e, 0x0016, 0x0000, 0x001c},
@@ -29,6 +29,19 @@ uint16_t scancode_set2[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = {
{0x0000, 0x000a, 0xe074, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000},
};
+uint16_t get_scancode_set2(uint8_t row, uint8_t col)
+{
+ if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS)
+ return scancode_set2[col][row];
+ return 0;
+}
+
+void set_scancode_set2(uint8_t row, uint8_t col, uint16_t val)
+{
+ if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS)
+ scancode_set2[col][row] = val;
+}
+
void board_keyboard_drive_col(int col)
{
/* Drive all lines to high */
@@ -49,7 +62,7 @@ void board_keyboard_drive_col(int col)
}
#ifdef CONFIG_KEYBOARD_DEBUG
-char keycap_label[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = {
+static char keycap_label[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = {
{'c', KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO,
KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO},
{KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO,
@@ -83,4 +96,17 @@ char keycap_label[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = {
{KLLI_UNKNO, KLLI_F8, KLLI_RIGHT, KLLI_UNKNO,
KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO},
};
+
+char get_keycap_label(uint8_t row, uint8_t col)
+{
+ if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS)
+ return keycap_label[col][row];
+ return KLLI_UNKNO;
+}
+
+void set_keycap_label(uint8_t row, uint8_t col, char val)
+{
+ if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS)
+ keycap_label[col][row] = val;
+}
#endif
diff --git a/common/keyboard_8042.c b/common/keyboard_8042.c
index 7063ead88f..7c1249e748 100644
--- a/common/keyboard_8042.c
+++ b/common/keyboard_8042.c
@@ -345,7 +345,7 @@ static enum ec_error_list matrix_callback(int8_t row, int8_t col,
if (row >= KEYBOARD_ROWS || col >= keyboard_cols)
return EC_ERROR_INVAL;
- make_code = scancode_set2[col][row];
+ make_code = get_scancode_set2(row, col);
#ifdef CONFIG_KEYBOARD_SCANCODE_CALLBACK
{
@@ -423,11 +423,11 @@ void keyboard_state_changed(int row, int col, int is_pressed)
enum ec_error_list ret;
#ifdef CONFIG_KEYBOARD_DEBUG
- char mylabel = keycap_label[col][row];
+ char mylabel = get_keycap_label(row, col);
if (mylabel & KEYCAP_LONG_LABEL_BIT)
CPRINTS("KB (%d,%d)=%d %s", row, col, is_pressed,
- keycap_long_label[mylabel & KEYCAP_LONG_LABEL_INDEX_BITMASK]);
+ get_keycap_long_label(mylabel & KEYCAP_LONG_LABEL_INDEX_BITMASK));
else
CPRINTS("KB (%d,%d)=%d %c", row, col, is_pressed, mylabel);
#endif
diff --git a/common/keyboard_8042_sharedlib.c b/common/keyboard_8042_sharedlib.c
index 5740782b8e..1d024d3f47 100644
--- a/common/keyboard_8042_sharedlib.c
+++ b/common/keyboard_8042_sharedlib.c
@@ -14,10 +14,7 @@
#ifndef CONFIG_KEYBOARD_CUSTOMIZATION
/* The standard Chrome OS keyboard matrix table in scan code set 2. */
-#ifndef CONFIG_KEYBOARD_SCANCODE_MUTABLE
-SHAREDLIB(const
-#endif
-uint16_t scancode_set2[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = {
+static 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},
@@ -38,11 +35,21 @@ uint16_t scancode_set2[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = {
{0xe04a, 0x007c, 0x007b, 0x0074, 0x0071, 0x0073, 0x006b, 0x0070},
{0x006c, 0x0075, 0x007d, 0x0079, 0x007a, 0x0072, 0x0069, 0xe05a},
#endif
+};
+
+uint16_t get_scancode_set2(uint8_t row, uint8_t col)
+{
+ if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS)
+ return scancode_set2[col][row];
+ return 0;
}
-#ifndef CONFIG_KEYBOARD_SCANCODE_MUTABLE
-)
-#endif
-;
+
+void set_scancode_set2(uint8_t row, uint8_t col, uint16_t val)
+{
+ if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS)
+ scancode_set2[col][row] = val;
+}
+
#endif /* CONFIG_KEYBOARD_CUSTOMIZATION */
/*
@@ -74,7 +81,7 @@ SHAREDLIB(const uint8_t scancode_translate_table[128] = {
#ifdef CONFIG_KEYBOARD_DEBUG
SHAREDLIB(const
-char * const keycap_long_label[KLLI_MAX & KEYCAP_LONG_LABEL_INDEX_BITMASK] = {
+static char * const keycap_long_label[KLLI_MAX & KEYCAP_LONG_LABEL_INDEX_BITMASK] = {
"UNKNOWN", "F1", "F2", "F3",
"F4", "F5", "F6", "F7",
"F8", "F9", "F10", "F11",
@@ -85,11 +92,15 @@ char * const keycap_long_label[KLLI_MAX & KEYCAP_LONG_LABEL_INDEX_BITMASK] = {
"RIGHT", "DOWN", "UP", "ESC",
});
+const char *get_keycap_long_label(uint8_t idx)
+{
+ if (idx < ARRAY_SIZE(keycap_long_label))
+ return keycap_long_label[idx];
+ return "UNKNOWN";
+}
+
#ifndef CONFIG_KEYBOARD_CUSTOMIZATION
-#ifndef CONFIG_KEYBOARD_SCANCODE_MUTABLE
-SHAREDLIB(const
-#endif
-char keycap_label[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = {
+static char keycap_label[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = {
{KLLI_UNKNO, KLLI_UNKNO, KLLI_L_CTR, KLLI_SEARC,
KLLI_R_CTR, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO},
{KLLI_F11, KLLI_ESC, KLLI_TAB, '~',
@@ -123,11 +134,20 @@ char keycap_label[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = {
{KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO,
KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO},
#endif
+};
+
+char get_keycap_label(uint8_t row, uint8_t col)
+{
+ if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS)
+ return keycap_label[col][row];
+ return KLLI_UNKNO;
+}
+
+void set_keycap_label(uint8_t row, uint8_t col, char val)
+{
+ if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS)
+ keycap_label[col][row] = val;
}
-#ifndef CONFIG_KEYBOARD_SCANCODE_MUTABLE
-)
-#endif
-;
#endif /* CONFIG_KEYBOARD_CUSTOMIZATION */
#endif /* CONFIG_KEYBOARD_DEBUG */
diff --git a/include/config.h b/include/config.h
index 12667549f7..0c42772230 100644
--- a/include/config.h
+++ b/include/config.h
@@ -2408,11 +2408,6 @@
#define CONFIG_KEYBOARD_RUNTIME_KEYS
/*
- * Allow the keyboard scan code set tables to be modified at runtime.
- */
-#undef CONFIG_KEYBOARD_SCANCODE_MUTABLE
-
-/*
* Allow the board layer keyboard customization. If define, the board layer
* needs to implement:
* 1. the function board_keyboard_drive_col() which is used to control
diff --git a/include/keyboard_8042_sharedlib.h b/include/keyboard_8042_sharedlib.h
index 6ab5eb8df3..ea773cc6f4 100644
--- a/include/keyboard_8042_sharedlib.h
+++ b/include/keyboard_8042_sharedlib.h
@@ -17,13 +17,20 @@ struct button_8042_t {
int repeat;
};
-/* The standard Chrome OS keyboard matrix table. */
-#if defined(CONFIG_KEYBOARD_SCANCODE_MUTABLE) || \
- defined(CONFIG_KEYBOARD_CUSTOMIZATION)
-extern uint16_t scancode_set2[KEYBOARD_COLS_MAX][KEYBOARD_ROWS];
-#else
-extern const uint16_t scancode_set2[KEYBOARD_COLS_MAX][KEYBOARD_ROWS];
-#endif
+/**
+ * Get the standard Chrome OS keyboard matrix set 2 scanset
+ * @param row Row number
+ * @param col Column number
+ * @return 0 on error, scanset for the (row,col) if successful
+ **/
+uint16_t get_scancode_set2(uint8_t row, uint8_t col);
+/**
+ * Set the standard Chrome OS keyboard matrix set 2 scanset
+ * @param row Row number
+ * @param col Column number
+ * @param val Value to set
+ **/
+void set_scancode_set2(uint8_t row, uint8_t col, uint16_t val);
/* Translation from scan code set 2 to set 1. */
extern const uint8_t scancode_translate_table[];
@@ -69,13 +76,27 @@ enum keycap_long_label_idx {
KLLI_MAX
};
-extern const char * const keycap_long_label[];
-#if defined(CONFIG_KEYBOARD_SCANCODE_MUTABLE) || \
- defined(CONFIG_KEYBOARD_CUSTOMIZATION)
-extern char keycap_label[KEYBOARD_COLS_MAX][KEYBOARD_ROWS];
-#else
-extern const char keycap_label[KEYBOARD_COLS_MAX][KEYBOARD_ROWS];
-#endif
+/**
+ * Get the keycap "long version" label
+ * @param idx Index into keycap_long_label_idx[]
+ * @return "UNKNOWN" on error, long label for idx if successful
+ */
+const char *get_keycap_long_label(uint8_t idx);
+
+/**
+ * Get the keycap label
+ * @param row Row number
+ * @param col Column number
+ * @return KLLI_UNKNO on error, label for the (row,col) if successful
+ */
+char get_keycap_label(uint8_t row, uint8_t col);
+/**
+ * Set the keycap label
+ * @param row Row number
+ * @param col Column number
+ * @param val Value to set
+ */
+void set_keycap_label(uint8_t row, uint8_t col, char val);
#endif
/* Button scancodes (Power, Volume Down, Volume Up, etc.) */