From 43899e1d9e3f523701d8d8b5c93890322894e6e4 Mon Sep 17 00:00:00 2001 From: Hung-Te Lin Date: Wed, 8 Aug 2018 08:55:38 +0800 Subject: keyboard: Keep only scan code set 2 table and do translation for set 1. The 8042 scan code set 1 can be directly translated from set 2, with a 256 byte table. With this change, we can always process key stroke in scan code (set 2), and only translate in the single function `scancode_bytes`. This is very helpful when we need to do key processing, for example the buttons_8042 can now be simplified with only one scan code. And is extremely helpful if we want to do dynamic translation (i.e., to prevent something like CL:1164725). For `make BOARD=samus', the free space is also increased from 18472 to 18656 (+184) bytes. BUG=None TEST=make buildall; manually installed on Eve and tested by running 'keyboard' factory test to make sure all key scancodes are not changed. BRANCH=None Change-Id: Ieb303d84edcd4375bbeb1ea5f032d0462bbfd250 Signed-off-by: Hung-Te Lin Reviewed-on: https://chromium-review.googlesource.com/1166742 Commit-Ready: ChromeOS CL Exonerator Bot Reviewed-by: Randall Spangler --- include/keyboard_8042_sharedlib.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'include/keyboard_8042_sharedlib.h') diff --git a/include/keyboard_8042_sharedlib.h b/include/keyboard_8042_sharedlib.h index 5c9b559279..e475288ad5 100644 --- a/include/keyboard_8042_sharedlib.h +++ b/include/keyboard_8042_sharedlib.h @@ -13,20 +13,21 @@ #include "keyboard_protocol.h" struct button_8042_t { - uint16_t scancode_set1; - uint16_t scancode_set2; + uint16_t scancode; int repeat; }; /* 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 +/* Translation from scan code set 2 to set 1. */ +extern const uint8_t scancode_translate_table[]; +extern uint8_t scancode_translate_set2_to_1(uint8_t code); + /* Button scancodes (Power, Volume Down, Volume Up, etc.) */ extern const struct button_8042_t buttons_8042[KEYBOARD_BUTTON_COUNT]; -- cgit v1.2.1