diff options
author | Dmitry Torokhov <dtor@chromium.org> | 2018-08-15 17:16:35 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-08-22 00:10:42 -0700 |
commit | f70528e53dfbdc1f33508d157b05c608934a660f (patch) | |
tree | 214ba254482057090389c2e3170447fd51ef3f4b /common/keyboard_mkbp.c | |
parent | b8489de98f1cf3e32fbcbe4b6f6163dff4a55c78 (diff) | |
download | chrome-ec-f70528e53dfbdc1f33508d157b05c608934a660f.tar.gz |
common: add API to expose detachable "base" state
On some detachables, when base is attached, we know right away that the
device should transition from tablet to clamshell mode. However on other
detachables we need additional information (i.e. base position) before
we decide whether to transition in/out of tablet mode. For such
detachables let's allow them to signal a new "base attached" switch
event, so that the rest of the stack is not confused.
BUG=b:73133611
BRANCH=nocturne
TEST=Build and boot
Change-Id: I9be3450cba52bf9f0bad8333402f68b0c7903090
Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1176801
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'common/keyboard_mkbp.c')
-rw-r--r-- | common/keyboard_mkbp.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/common/keyboard_mkbp.c b/common/keyboard_mkbp.c index ffe5aefa92..efd86f2e10 100644 --- a/common/keyboard_mkbp.c +++ b/common/keyboard_mkbp.c @@ -6,6 +6,7 @@ */ #include "atomic.h" +#include "base_state.h" #include "button.h" #include "chipset.h" #include "common.h" @@ -264,6 +265,16 @@ DECLARE_HOOK(HOOK_TABLET_MODE_CHANGE, mkbp_tablet_mode_change, HOOK_PRIO_LAST); DECLARE_HOOK(HOOK_INIT, mkbp_tablet_mode_change, HOOK_PRIO_INIT_LID+1); #endif +#ifdef CONFIG_BASE_ATTACHED_SWITCH +static void mkbp_base_attached_change(void) +{ + mkbp_update_switches(EC_MKBP_BASE_ATTACHED, base_get_state()); +} +DECLARE_HOOK(HOOK_BASE_ATTACHED_CHANGE, mkbp_base_attached_change, + HOOK_PRIO_LAST); +DECLARE_HOOK(HOOK_INIT, mkbp_base_attached_change, HOOK_PRIO_INIT_LID+1); +#endif + void keyboard_update_button(enum keyboard_button_type button, int is_pressed) { switch (button) { @@ -430,6 +441,9 @@ static uint32_t get_supported_switches(void) #ifdef CONFIG_TABLET_MODE_SWITCH val |= (1 << EC_MKBP_TABLET_MODE); #endif +#ifdef CONFIG_BASE_ATTACHED_SWITCH + val |= (1 << EC_MKBP_BASE_ATTACHED); +#endif return val; } |