From 98daf2a9d19624b4a5d315f67644d44a99716e64 Mon Sep 17 00:00:00 2001 From: Alec Berg Date: Sun, 4 Jan 2015 14:25:33 -0800 Subject: samus: add hot keys alt+voldown+0|1|2 to set charging port Add hot key detection for alt + volume down + 0|1|2 to set the charging port by sending the charge override command to PD MCU. This should be removed once hot-keys (or some other UI) is added to higher layers. BUG=chrome-os-partner:34850 BRANCH=samus TEST=load onto samus and connect to another samus. use hot keys and see that charge override command gets set appropriately on PD MCU. Change-Id: I7e72d597a02b7aca3326911796d20003f6697077 Signed-off-by: Alec Berg Reviewed-on: https://chromium-review.googlesource.com/238226 Reviewed-by: Duncan Laurie Reviewed-by: Vincent Palatin --- common/keyboard_scan.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ include/keyboard_config.h | 12 ++++++++++++ 2 files changed, 57 insertions(+) diff --git a/common/keyboard_scan.c b/common/keyboard_scan.c index 4bc2391722..df9e9064ff 100644 --- a/common/keyboard_scan.c +++ b/common/keyboard_scan.c @@ -270,11 +270,26 @@ static int check_runtime_keys(const uint8_t *state) int num_press = 0; int c; +#ifdef BOARD_SAMUS + int16_t chg_override; + + /* + * TODO(crosbug.com/p/34850): remove these hot-keys for samus, should + * be done at higher level than this. + */ + /* + * All runtime key combos are (right or left ) alt + volume up|down + + * (some key NOT on the same col as alt or volume up|down ) + */ + if (state[KEYBOARD_COL_VOL_UP] != KEYBOARD_MASK_VOL_UP && + state[KEYBOARD_COL_VOL_DOWN] != KEYBOARD_MASK_VOL_DOWN) +#else /* * All runtime key combos are (right or left ) alt + volume up + (some * key NOT on the same col as alt or volume up ) */ if (state[KEYBOARD_COL_VOL_UP] != KEYBOARD_MASK_VOL_UP) +#endif return 0; if (state[KEYBOARD_COL_RIGHT_ALT] != KEYBOARD_MASK_RIGHT_ALT && @@ -307,6 +322,36 @@ static int check_runtime_keys(const uint8_t *state) system_hibernate(0, 0); return 1; } +#ifdef BOARD_SAMUS + /* + * TODO(crosbug.com/p/34850): remove these hot-keys for samus, should + * be done at higher level than this. + */ + /* + * On samus, alt + volume down + 0|1|2 sets the active charge port + * by sending the charge override host command. Should only be sent + * when chipset is in S0. + */ + else if (state[KEYBOARD_COL_VOL_DOWN] == KEYBOARD_MASK_VOL_DOWN && + chipset_in_state(CHIPSET_STATE_ON)) { + if (state[KEYBOARD_COL_KEY_0] == KEYBOARD_MASK_KEY_0) { + /* Charge from neither port */ + chg_override = -2; + pd_host_command(EC_CMD_PD_CHARGE_PORT_OVERRIDE, 0, + &chg_override, 2, NULL, 0); + } else if (state[KEYBOARD_COL_KEY_1] == KEYBOARD_MASK_KEY_1) { + /* Charge from port 0 (left side) */ + chg_override = 0; + pd_host_command(EC_CMD_PD_CHARGE_PORT_OVERRIDE, 0, + &chg_override, 2, NULL, 0); + } else if (state[KEYBOARD_COL_KEY_2] == KEYBOARD_MASK_KEY_2) { + /* Charge from port 1 (right side) */ + chg_override = 1; + pd_host_command(EC_CMD_PD_CHARGE_PORT_OVERRIDE, 0, + &chg_override, 2, NULL, 0); + } + } +#endif return 0; } diff --git a/include/keyboard_config.h b/include/keyboard_config.h index ae70bf7352..2c44259929 100644 --- a/include/keyboard_config.h +++ b/include/keyboard_config.h @@ -41,5 +41,17 @@ #define KEYBOARD_COL_VOL_UP 4 #define KEYBOARD_ROW_VOL_UP 0 #define KEYBOARD_MASK_VOL_UP KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_VOL_UP) +#define KEYBOARD_COL_VOL_DOWN 9 +#define KEYBOARD_ROW_VOL_DOWN 1 +#define KEYBOARD_MASK_VOL_DOWN KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_VOL_DOWN) +#define KEYBOARD_COL_KEY_0 8 +#define KEYBOARD_ROW_KEY_0 6 +#define KEYBOARD_MASK_KEY_0 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_0) +#define KEYBOARD_COL_KEY_1 1 +#define KEYBOARD_ROW_KEY_1 6 +#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) #endif /* __CROS_EC_KEYBOARD_CONFIG_H */ -- cgit v1.2.1