summaryrefslogtreecommitdiff
path: root/common/keyboard_scan.c
diff options
context:
space:
mode:
authorparis_yeh <pyeh@google.com>2018-05-23 06:25:37 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-05-30 12:50:39 -0700
commite8f009b64b0b7bedc563b55efae296e3d59a15b9 (patch)
treebadb0e7da8dde8a5576f44eef930af773e563c17 /common/keyboard_scan.c
parent9102494be2821ca3bce1662d8595e8c5e0addae5 (diff)
downloadchrome-ec-e8f009b64b0b7bedc563b55efae296e3d59a15b9.tar.gz
keyboard_scan: Add option to support keyboards with language ID
ID pins are considered additional KSOs while keycode scanning works for the existing KSI0 ~ KSI7. While diriving ID pins, the state of interconnection between ID pins and KSI pins could be used for identifiers to tell keyboard itself. (e.g. US, Japan,and UK keyboard) BRANCH=master BUG=b:80168723 TEST="make -j buildall" TEST=Verified 5 distinct keyboard samples w/ different Language ID values on the same reworked Coral, which VOL_UP and VOL_DOWN were reworked for ID pins. crrev.com/c/1053617 is my experimental patch on top of this for further verification Change-Id: I1d6e647df74c50d60bc1264c045b2587d0bf23d8 Signed-off-by: paris_yeh <pyeh@google.com> Reviewed-on: https://chromium-review.googlesource.com/1068951 Commit-Ready: Paris Yeh <pyeh@chromium.org> Tested-by: Paris Yeh <pyeh@chromium.org> Reviewed-by: Paris Yeh <pyeh@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Diffstat (limited to 'common/keyboard_scan.c')
-rw-r--r--common/keyboard_scan.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/common/keyboard_scan.c b/common/keyboard_scan.c
index fee48e6a26..96dececd78 100644
--- a/common/keyboard_scan.c
+++ b/common/keyboard_scan.c
@@ -89,6 +89,9 @@ static uint8_t __bss_slow prev_state[KEYBOARD_COLS];
static uint8_t __bss_slow debouncing[KEYBOARD_COLS];
/* Keys simulated-pressed */
static uint8_t __bss_slow simulated_key[KEYBOARD_COLS];
+#ifdef CONFIG_KEYBOARD_LANGUAGE_ID
+static uint8_t __bss_slow keyboard_id[KEYBOARD_IDS];
+#endif
/* Times of last scans */
static uint32_t __bss_slow scan_time[SCAN_TIME_COUNT];
@@ -275,6 +278,35 @@ static int read_matrix(uint8_t *state)
return pressed ? 1 : 0;
}
+#ifdef CONFIG_KEYBOARD_LANGUAGE_ID
+/**
+ * Read the raw keyboard IDs state.
+ *
+ * Used in pre-init, so must not make task-switching-dependent calls; udelay()
+ * is ok because it's a spin-loop.
+ *
+ * @param id Destination for keyboard id (must be KEYBOARD_IDS long).
+ *
+ */
+static void read_matrix_id(uint8_t *id)
+{
+ int c;
+
+ for (c = 0; c < KEYBOARD_IDS; c++) {
+ /* Select the ID pin, then wait a bit for it to settle */
+ keyboard_raw_drive_column(KEYBOARD_COLS + c);
+ udelay(keyscan_config.output_settle_us);
+
+ /* Read the row state */
+ id[c] = keyboard_raw_read_rows();
+
+ CPRINTS("Keyboard ID%u: 0x%02x\n", c, id[c]);
+ }
+
+ keyboard_raw_drive_column(KEYBOARD_COLUMN_NONE);
+}
+#endif
+
#ifdef CONFIG_KEYBOARD_RUNTIME_KEYS
/**
* Check special runtime key combinations.
@@ -647,6 +679,11 @@ void keyboard_scan_init(void)
read_matrix(debounced_state);
memcpy(prev_state, debounced_state, sizeof(prev_state));
+#ifdef CONFIG_KEYBOARD_LANGUAGE_ID
+ /* Check keyboard ID state */
+ read_matrix_id(keyboard_id);
+#endif
+
#ifdef CONFIG_KEYBOARD_BOOT_KEYS
/* Check for keys held down at boot */
boot_key_value = check_boot_key(debounced_state);