summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjohnwc_yeh <johnwc_yeh@compal.corp-partner.google.com>2022-06-07 16:42:09 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-06-15 16:49:45 +0000
commit096b7a4dc8475093496f69f1e505a67aa7b0f9a6 (patch)
treeaabc9b03d11e0b5fc79ec485839eae10db85f3c8
parente705085f93aa0fedc6b20b81f59c0cce184404ca (diff)
downloadchrome-ec-096b7a4dc8475093496f69f1e505a67aa7b0f9a6.tar.gz
Mithrax:implement keyboard matrix
Implement customizition keyboard. Initialize vivaldi keyboard and modify combination key row and col. BUG=b:231249540 BRANCH=None TEST=make BOARD=mithrax and verify with evtest 2 Signed-off-by: johnwc_yeh <johnwc_yeh@compal.corp-partner.google.com> Change-Id: Id72c5902e0a79a503173d5135aac9380a7200639 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3690198 Reviewed-by: Ricky Chang <rickytlchang@chromium.org> Commit-Queue: Ricky Chang <rickytlchang@chromium.org> Reviewed-by: Ko Ko <ko_ko@compal.corp-partner.google.com>
-rw-r--r--board/mithrax/board.h7
-rw-r--r--board/mithrax/build.mk1
-rw-r--r--board/mithrax/keyboard.c33
-rw-r--r--board/mithrax/keyboard_customization.c113
-rw-r--r--board/mithrax/keyboard_customization.h73
5 files changed, 222 insertions, 5 deletions
diff --git a/board/mithrax/board.h b/board/mithrax/board.h
index 002b5ca17b..c9d2112b2c 100644
--- a/board/mithrax/board.h
+++ b/board/mithrax/board.h
@@ -21,6 +21,11 @@
#define CONFIG_MP2964
+/* KEYBOARD */
+#define CONFIG_KEYBOARD_CUSTOMIZATION
+#define CONFIG_KEYBOARD_VIVALDI
+#define CONFIG_KEYBOARD_REFRESH_ROW3
+
/* LED */
#define CONFIG_LED_ONOFF_STATES
#define CONFIG_LED_ONOFF_STATES_BAT_LOW 10
@@ -181,8 +186,6 @@
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
-#define CONFIG_KEYBOARD_REFRESH_ROW3
-
/* RGB Keyboard */
#ifdef SECTION_IS_RW
#define CONFIG_RGB_KEYBOARD
diff --git a/board/mithrax/build.mk b/board/mithrax/build.mk
index c4345d8de0..a7ec1987de 100644
--- a/board/mithrax/build.mk
+++ b/board/mithrax/build.mk
@@ -23,3 +23,4 @@ board-y+=led.o
board-y+=pwm.o
board-y+=sensors.o
board-y+=usbc_config.o
+board-y+=keyboard_customization.o
diff --git a/board/mithrax/keyboard.c b/board/mithrax/keyboard.c
index 348a616791..6534c7bc63 100644
--- a/board/mithrax/keyboard.c
+++ b/board/mithrax/keyboard.c
@@ -21,8 +21,8 @@ __override struct keyboard_scan_config keyscan_config = {
.min_post_scan_delay_us = 1000,
.poll_timeout_us = 100 * MSEC,
.actual_key_mask = {
- 0x1c, 0xff, 0xff, 0xff, 0xff, 0xf5, 0xff,
- 0xa4, 0xff, 0xfe, 0x55, 0xfe, 0xff, 0xff, 0xff, /* full set */
+ 0x1c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x86, 0xff, 0xff, 0x55, 0xff, 0xff, 0xff, 0xff, /* full set */
},
};
@@ -40,7 +40,7 @@ static const struct ec_response_keybd_config mithrax_kb = {
TK_VOL_DOWN, /* T9 */
TK_VOL_UP, /* T10 */
},
- .capabilities = KEYBD_CAP_SCRNLOCK_KEY | KEYBD_CAP_NUMERIC_KEYPAD,
+ .capabilities = KEYBD_CAP_SCRNLOCK_KEY,
};
static struct rgb_s grid0[RGB_GRID0_COL * RGB_GRID0_ROW];
@@ -203,3 +203,30 @@ __override const struct ec_response_keybd_config
{
return &mithrax_kb;
}
+
+/*
+ * Row Column info for Top row keys T1 - T15.
+ * on mithrax_kb keyboard Row Column is customization
+ * need define row col to mapping matrix layout.
+ */
+__override const struct key {
+ uint8_t row;
+ uint8_t col;
+} vivaldi_keys[] = {
+ {.row = 4, .col = 2}, /* T1 */
+ {.row = 3, .col = 2}, /* T2 */
+ {.row = 2, .col = 2}, /* T3 */
+ {.row = 1, .col = 2}, /* T4 */
+ {.row = 4, .col = 4}, /* T5 */
+ {.row = 3, .col = 4}, /* T6 */
+ {.row = 2, .col = 4}, /* T7 */
+ {.row = 2, .col = 9}, /* T8 */
+ {.row = 1, .col = 9}, /* T9 */
+ {.row = 1, .col = 4}, /* T10 */
+ {.row = 0, .col = 4}, /* T11 */
+ {.row = 1, .col = 5}, /* T12 */
+ {.row = 3, .col = 5}, /* T13 */
+ {.row = 2, .col = 1}, /* T14 */
+ {.row = 0, .col = 1}, /* T15 */
+};
+BUILD_ASSERT(ARRAY_SIZE(vivaldi_keys) == MAX_TOP_ROW_KEYS);
diff --git a/board/mithrax/keyboard_customization.c b/board/mithrax/keyboard_customization.c
new file mode 100644
index 0000000000..4e45de34be
--- /dev/null
+++ b/board/mithrax/keyboard_customization.c
@@ -0,0 +1,113 @@
+/* Copyright 2022 The ChromiumOS Authors.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "common.h"
+#include "gpio.h"
+#include "keyboard_customization.h"
+#include "keyboard_8042_sharedlib.h"
+#include "keyboard_config.h"
+#include "keyboard_protocol.h"
+#include "keyboard_raw.h"
+
+static uint16_t scancode_set2[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = {
+ {0x0000, 0x0000, 0x0014, 0xe01f, 0xe014, 0x0000, 0x0000, 0x0000},
+ {0x001f, 0x0076, 0x0017, 0x000e, 0x001c, 0x003a, 0x000d, 0x0016},
+ {0x006c, 0xe024, 0xe01d, 0xe020, 0xe038, 0xe071, 0x0026, 0x002a},
+ {0x0032, 0x0034, 0x002c, 0x002e, 0x002b, 0x0029, 0x0025, 0x002d},
+ {0x0078, 0xe032, 0xe035, 0xe02c, 0xe02d, 0x0041, 0x001e, 0x001d},
+ {0x0051, 0x0007, 0x005b, 0x000f, 0x0042, 0x0022, 0x003e, 0x0043},
+ {0x0031, 0x0033, 0x0035, 0x0036, 0x003b, 0x001b, 0x003d, 0x003c},
+ {0x0000, 0x0012, 0x0061, 0x0000, 0x0000, 0x0000, 0x0000, 0x0059},
+ {0x0055, 0x0052, 0x0054, 0x004e, 0x004c, 0x0024, 0x0044, 0x004d},
+ {0x0045, 0xe021, 0xe023, 0x002f, 0x004b, 0x0049, 0x0046, 0x001a},
+ {0xe011, 0x0000, 0x006a, 0x0000, 0x005d, 0x0000, 0x0011, 0x0000},
+ {0xe07a, 0x005d, 0xe075, 0x006b, 0x005a, 0xe072, 0x004a, 0x0066},
+ {0xe06b, 0xe074, 0xe069, 0x0067, 0xe06c, 0x0064, 0x0015, 0xe07d},
+ {0x0073, 0x007c, 0x007b, 0x0074, 0x0071, 0xe04a, 0x0070, 0x0021},
+ {0x0023, 0xe05a, 0x0075, 0x0079, 0x007a, 0x0072, 0x007d, 0x0069},
+};
+
+
+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 */
+ if (col == KEYBOARD_COLUMN_NONE)
+ gpio_set_level(GPIO_KBD_KSO2, 0);
+
+ /* Set KBSOUT to zero to detect key-press */
+ else if (col == KEYBOARD_COLUMN_ALL)
+ gpio_set_level(GPIO_KBD_KSO2, 1);
+
+ /* Drive one line for detection */
+ else {
+ if (col == 2)
+ gpio_set_level(GPIO_KBD_KSO2, 1);
+ else
+ gpio_set_level(GPIO_KBD_KSO2, 0);
+ }
+}
+
+#ifdef CONFIG_KEYBOARD_DEBUG
+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,
+ KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO},
+ {'q', KLLI_UNKNO, KLLI_UNKNO, KLLI_TAB, '`',
+ '1', KLLI_UNKNO, 'a'},
+ {KLLI_R_ALT, KLLI_L_ALT, KLLI_UNKNO, KLLI_UNKNO,
+ KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO},
+ {KLLI_UNKNO, KLLI_SPACE, 'e', KLLI_F4,
+ KLLI_SEARC, '3', KLLI_F3, KLLI_UNKNO},
+ {'x', 'z', KLLI_F2, KLLI_F1,
+ 's', '2', 'w', KLLI_ESC},
+ {'v', 'b', 'g', 't',
+ '5', '4', 'r', 'f'},
+ {'m', 'n', 'h', 'y',
+ '6', '7', 'u', 'j'},
+ {'.', KLLI_DOWN, '\\', 'o',
+ KLLI_F10, '9', KLLI_UNKNO, 'l'},
+ {KLLI_R_SHT, KLLI_L_SHT, KLLI_UNKNO, KLLI_UNKNO,
+ KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO},
+ {',', KLLI_UNKNO, KLLI_F7, KLLI_F6,
+ KLLI_F5, '8', 'i', 'k'},
+ {KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_F9,
+ KLLI_UNKNO, KLLI_UNKNO, KLLI_LEFT, KLLI_UNKNO},
+ {KLLI_R_CTR, KLLI_L_CTR, KLLI_UNKNO, KLLI_UNKNO,
+ KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO},
+ {'/', KLLI_UP, '-', KLLI_UNKNO,
+ '0', 'p', '[', ';'},
+ {'\'', KLLI_ENTER, KLLI_UNKNO, KLLI_UNKNO,
+ '=', KLLI_B_SPC, ']', 'd'},
+ {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/board/mithrax/keyboard_customization.h b/board/mithrax/keyboard_customization.h
new file mode 100644
index 0000000000..b177a11eb4
--- /dev/null
+++ b/board/mithrax/keyboard_customization.h
@@ -0,0 +1,73 @@
+/* Copyright 2022 The ChromiumOS Authors.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Keyboard configuration */
+
+#ifndef __KEYBOARD_CUSTOMIZATION_H
+#define __KEYBOARD_CUSTOMIZATION_H
+
+/*
+ * 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 15
+#define KEYBOARD_ROWS 8
+
+/*
+ * WARNING: Do not directly modify it. You should call keyboard_raw_set_cols,
+ * instead. It checks whether you're eligible or not.
+ */
+extern uint8_t keyboard_cols;
+
+#define KEYBOARD_ROW_TO_MASK(r) (1 << (r))
+
+/* Columns and masks for keys we particularly care about */
+#define KEYBOARD_COL_DOWN 11
+#define KEYBOARD_ROW_DOWN 5
+#define KEYBOARD_MASK_DOWN KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_DOWN)
+#define KEYBOARD_COL_ESC 1
+#define KEYBOARD_ROW_ESC 1
+#define KEYBOARD_MASK_ESC KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_ESC)
+#define KEYBOARD_COL_KEY_H 6
+#define KEYBOARD_ROW_KEY_H 1
+#define KEYBOARD_MASK_KEY_H KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_H)
+#define KEYBOARD_COL_KEY_R 3
+#define KEYBOARD_ROW_KEY_R 7
+#define KEYBOARD_MASK_KEY_R KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_R)
+#define KEYBOARD_COL_LEFT_ALT 10
+#define KEYBOARD_ROW_LEFT_ALT 6
+#define KEYBOARD_MASK_LEFT_ALT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_ALT)
+#define KEYBOARD_COL_REFRESH 2
+#define KEYBOARD_ROW_REFRESH 3
+#define KEYBOARD_MASK_REFRESH KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_REFRESH)
+#define KEYBOARD_COL_RIGHT_ALT 10
+#define KEYBOARD_ROW_RIGHT_ALT 0
+#define KEYBOARD_MASK_RIGHT_ALT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_RIGHT_ALT)
+#define KEYBOARD_DEFAULT_COL_VOL_UP 4
+#define KEYBOARD_DEFAULT_ROW_VOL_UP 1
+#define KEYBOARD_COL_LEFT_CTRL 0
+#define KEYBOARD_ROW_LEFT_CTRL 2
+#define KEYBOARD_MASK_LEFT_CTRL KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_CTRL)
+#define KEYBOARD_COL_RIGHT_CTRL 0
+#define KEYBOARD_ROW_RIGHT_CTRL 4
+#define KEYBOARD_MASK_RIGHT_CTRL KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_RIGHT_CTRL)
+#define KEYBOARD_COL_SEARCH 0
+#define KEYBOARD_ROW_SEARCH 3
+#define KEYBOARD_MASK_SEARCH KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_SEARCH)
+#define KEYBOARD_COL_KEY_0 9
+#define KEYBOARD_ROW_KEY_0 0
+#define KEYBOARD_MASK_KEY_0 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_0)
+#define KEYBOARD_COL_KEY_1 1
+#define KEYBOARD_ROW_KEY_1 7
+#define KEYBOARD_MASK_KEY_1 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_1)
+#define KEYBOARD_COL_KEY_2 4
+#define KEYBOARD_ROW_KEY_2 6
+#define KEYBOARD_MASK_KEY_2 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_2)
+#define KEYBOARD_COL_LEFT_SHIFT 7
+#define KEYBOARD_ROW_LEFT_SHIFT 1
+#define KEYBOARD_MASK_LEFT_SHIFT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_SHIFT)
+
+#endif /* __KEYBOARD_CUSTOMIZATION_H */