summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/keyboard_8042.c9
-rw-r--r--include/config.h5
-rw-r--r--include/keyboard_8042.h17
3 files changed, 31 insertions, 0 deletions
diff --git a/common/keyboard_8042.c b/common/keyboard_8042.c
index 50320807cb..b178c50066 100644
--- a/common/keyboard_8042.c
+++ b/common/keyboard_8042.c
@@ -314,6 +314,15 @@ static enum ec_error_list matrix_callback(int8_t row, int8_t col,
if (pressed)
keyboard_special(make_code);
+#ifdef CONFIG_KEYBOARD_SCANCODE_CALLBACK
+ {
+ enum ec_error_list r = keyboard_scancode_callback(
+ &make_code, pressed);
+ if (r != EC_SUCCESS)
+ return r;
+ }
+#endif
+
code_set = acting_code_set(code_set);
if (!is_supported_code_set(code_set)) {
CPRINTS("KB scancode set %d unsupported", code_set);
diff --git a/include/config.h b/include/config.h
index ba1ffd954a..a5c17ad9b5 100644
--- a/include/config.h
+++ b/include/config.h
@@ -2043,6 +2043,11 @@
#undef CONFIG_KEYBOARD_SCANCODE_MUTABLE
/*
+ * Allow board-specific 8042 keyboard callback when a key state is changed.
+ */
+#undef CONFIG_KEYBOARD_SCANCODE_CALLBACK
+
+/*
* Call board-supplied keyboard_suppress_noise() function when the debounced
* keyboard state changes. Some boards use this to send a signal to the audio
* codec to suppress typing noise picked up by the microphone.
diff --git a/include/keyboard_8042.h b/include/keyboard_8042.h
index 00fdc9901b..7bde59ac35 100644
--- a/include/keyboard_8042.h
+++ b/include/keyboard_8042.h
@@ -28,4 +28,21 @@ void button_state_changed(enum keyboard_button_type button, int is_pressed);
*/
void keyboard_host_write(int data, int is_cmd);
+/*
+ * Board specific callback function when a key state is changed.
+ *
+ * A board may watch key events and create some easter eggs, or apply dynamic
+ * translation to the make code (i.e., remap keys).
+ *
+ * Returning EC_SUCCESS implies *make_code is still a valid make code to be
+ * processed. Any other return value will abort processing of this make code.
+ * If callback alters *make_code or aborts key processing when pressed=1, it is
+ * responsible for also altering/aborting the matching pressed=0 call.
+ *
+ * @param make_code Pointer to scan code (set 2) of key in action.
+ * @param pressed Is the key being pressed (1) or released (0).
+ */
+enum ec_error_list keyboard_scancode_callback(uint16_t *make_code,
+ int8_t pressed);
+
#endif /* __CROS_EC_KEYBOARD_8042_H */