summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2015-01-04 14:25:33 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-01-07 02:32:52 +0000
commit98daf2a9d19624b4a5d315f67644d44a99716e64 (patch)
tree08482262c6e1139a8a69eefd595df682b7550d68
parente39f43ed2d79195098c2373389f0495f20e3247c (diff)
downloadchrome-ec-stabilize-6662.B.tar.gz
samus: add hot keys alt+voldown+0|1|2 to set charging portstabilize-6662.B
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 <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/238226 Reviewed-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--common/keyboard_scan.c45
-rw-r--r--include/keyboard_config.h12
2 files changed, 57 insertions, 0 deletions
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 */