diff options
author | Jongpil Jung <jongpil19.jung@samsung.com> | 2016-07-01 20:32:04 +0900 |
---|---|---|
committer | Douglas Anderson <dianders@chromium.org> | 2016-07-08 13:28:31 +0000 |
commit | 3851b19f7126b03e0830ee60cdc6e00f793ac8ee (patch) | |
tree | c5bb582b5660d2f999d11731539004f827752552 | |
parent | 8c52bb8d3bedbd8c0535a3fcbd1016c726c9ba85 (diff) | |
download | chrome-ec-3851b19f7126b03e0830ee60cdc6e00f793ac8ee.tar.gz |
kevin: Generate key scan event with hardware volume up/down button.
Gru/Kevin has gio based hardware volume up/down key.
Those will not report host as keyboard scan task.
So, we need generate key event when we press hardware
volume up and down button.
BRANCH=none
BUG=chrome-os-partner:54976
TEST=evtest and check volume up/down.
Change-Id: I6abce5b24ec5f21227d9019764bbc3170859098a
Reviewed-on: https://chromium-review.googlesource.com/359090
Tested-by: Jongpil Jung <jongpil19.jung@samsung.com>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
-rw-r--r-- | board/kevin/board.h | 3 | ||||
-rw-r--r-- | common/button.c | 4 | ||||
-rw-r--r-- | common/keyboard_scan.c | 18 | ||||
-rw-r--r-- | include/keyboard_config.h | 5 | ||||
-rw-r--r-- | include/keyboard_scan.h | 4 |
5 files changed, 34 insertions, 0 deletions
diff --git a/board/kevin/board.h b/board/kevin/board.h index d6fa88b97c..6e7cb11484 100644 --- a/board/kevin/board.h +++ b/board/kevin/board.h @@ -143,6 +143,9 @@ EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEY_PRESSED) |\ EC_HOST_EVENT_MASK(EC_HOST_EVENT_RTC)) +/* Define to report hardware button event as keyboard event */ +#define HAS_HW_BUTTON_KEY + #ifndef __ASSEMBLER__ enum adc_channel { diff --git a/common/button.c b/common/button.c index 38f5a61403..fdbeb23cd9 100644 --- a/common/button.c +++ b/common/button.c @@ -11,6 +11,7 @@ #include "gpio.h" #include "hooks.h" #include "keyboard_protocol.h" +#include "keyboard_scan.h" #include "timer.h" #include "util.h" @@ -81,6 +82,9 @@ static void button_change_deferred(void) CPRINTS("Button '%s' was %s", buttons[i].name, new_pressed ? "pressed" : "released"); +#ifdef HAS_HW_BUTTON_KEY + report_hw_button_key(buttons[i].type, new_pressed); +#endif #ifdef HAS_TASK_KEYPROTO keyboard_update_button(buttons[i].type, new_pressed); diff --git a/common/keyboard_scan.c b/common/keyboard_scan.c index 73a6e6fdaf..6a23c3d429 100644 --- a/common/keyboard_scan.c +++ b/common/keyboard_scan.c @@ -203,6 +203,24 @@ static void simulate_key(int row, int col, int pressed) ensure_keyboard_scanned(kbd_polls); } +#ifdef HAS_HW_BUTTON_KEY +/** + * Report hardware button key as key scan code + * @param type button type + * @param pressed key pressed[0] or released[1] + */ +test_mockable void report_hw_button_key(int type, int pressed) +{ + if( type == KEYBOARD_BUTTON_VOLUME_UP ) { + simulate_key(KEYBOARD_VOLUME_UP_ROW, KEYBOARD_VOLUME_UP_COL, pressed); + } else if ( type == KEYBOARD_BUTTON_VOLUME_DOWN ) { + simulate_key(KEYBOARD_VOLUME_DOWN_ROW, KEYBOARD_VOLUME_DOWN_COL, pressed); + } else { + CPRINTF("Not handled"); + } +} +#endif + /** * Read the raw keyboard matrix state. * diff --git a/include/keyboard_config.h b/include/keyboard_config.h index 6cb1b53a52..bdce52d9f4 100644 --- a/include/keyboard_config.h +++ b/include/keyboard_config.h @@ -61,4 +61,9 @@ #define KEYBOARD_MASK_KEY_2 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_2) #define KEYBOARD_MASK_KSI2 KEYBOARD_ROW_TO_MASK(2) +#define KEYBOARD_VOLUME_UP_ROW 0 +#define KEYBOARD_VOLUME_UP_COL 4 +#define KEYBOARD_VOLUME_DOWN_ROW 1 +#define KEYBOARD_VOLUME_DOWN_COL 9 + #endif /* __CROS_EC_KEYBOARD_CONFIG_H */ diff --git a/include/keyboard_scan.h b/include/keyboard_scan.h index 41cdbdf611..0d20788ef8 100644 --- a/include/keyboard_scan.h +++ b/include/keyboard_scan.h @@ -105,4 +105,8 @@ static inline void keyboard_scan_enable(int enable, void keyboard_suppress_noise(void); #endif +#ifdef HAS_HW_BUTTON_KEY +test_mockable void report_hw_button_key(int type, int pressed); +#endif + #endif /* __CROS_EC_KEYBOARD_SCAN_H */ |