summaryrefslogtreecommitdiff
path: root/common/keyboard_mkbp.c
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2016-09-01 16:44:34 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-09-09 12:33:22 -0700
commit6d731f41fbf45d4d31ffa279bca61ccdc9b88c51 (patch)
tree57d83ffeef5879a7f6558d97632f585296cabc5d /common/keyboard_mkbp.c
parent97f1475fb5bc63ba6de8f5c9379c14d1ada46ad4 (diff)
downloadchrome-ec-6d731f41fbf45d4d31ffa279bca61ccdc9b88c51.tar.gz
mkbp: Send event when in tablet mode
When tablet mode is detected, send an event to the AP. BUG=chromium:606718 BRANCH=none TEST=Check with evtest that events are sent when the tablet goes in tablet mode and back to device mode. Change-Id: I49f2404b5ecf87e71fa5aef4c8ce9c9beda26a15 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/380414 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'common/keyboard_mkbp.c')
-rw-r--r--common/keyboard_mkbp.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/common/keyboard_mkbp.c b/common/keyboard_mkbp.c
index f947413720..08ec9d8c80 100644
--- a/common/keyboard_mkbp.c
+++ b/common/keyboard_mkbp.c
@@ -22,6 +22,7 @@
#include "keyboard_test.h"
#include "lid_switch.h"
#include "mkbp_event.h"
+#include "motion_lid.h"
#include "power_button.h"
#include "system.h"
#include "task.h"
@@ -204,15 +205,27 @@ void mkbp_update_switches(uint32_t sw, int state)
(const uint8_t *)&mkbp_switch_state);
}
+#ifdef CONFIG_LID_SWITCH
/**
* Handle lid changing state.
*/
-static void lid_change(void)
+static void mkbp_lid_change(void)
{
mkbp_update_switches(EC_MKBP_LID_OPEN, lid_is_open());
}
-DECLARE_HOOK(HOOK_LID_CHANGE, lid_change, HOOK_PRIO_LAST);
-DECLARE_HOOK(HOOK_INIT, lid_change, HOOK_PRIO_INIT_LID+1);
+DECLARE_HOOK(HOOK_LID_CHANGE, mkbp_lid_change, HOOK_PRIO_LAST);
+DECLARE_HOOK(HOOK_INIT, mkbp_lid_change, HOOK_PRIO_INIT_LID+1);
+#endif
+
+#ifdef CONFIG_TABLET_MODE_SWITCH
+static void mkbp_tablet_mode_change(void)
+{
+ mkbp_update_switches(EC_MKBP_TABLET_MODE,
+ motion_lid_in_tablet_mode());
+}
+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
void keyboard_update_button(enum keyboard_button_type button, int is_pressed)
{
@@ -352,6 +365,9 @@ static uint32_t get_supported_switches(void)
#ifdef CONFIG_LID_SWITCH
val |= (1 << EC_MKBP_LID_OPEN);
#endif
+#ifdef CONFIG_TABLET_MODE_SWITCH
+ val |= (1 << EC_MKBP_TABLET_MODE);
+#endif
return val;
}