mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-29 01:50:53 +00:00
mkbp: Add keyboard_update_button().
MKBP can now support buttons, so this commit adds the keyboard_update_button() function which will be used to handle the non-matrixed buttons. BUG=chrome-os-partner:54976 BUG=chromium:626863 BRANCH=None TEST=Flash kevin, press volume and power buttons and verify that keyboard is still functional. TEST=make -j buildall CQ-DEPEND=CL:358633 Change-Id: I1c2d36d2113715cf6bd8c6fa7b26fe9253f6ac9f Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/358634 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
87a071941b
commit
0325284e17
@@ -81,7 +81,7 @@ static void button_change_deferred(void)
|
||||
CPRINTS("Button '%s' was %s",
|
||||
buttons[i].name, new_pressed ?
|
||||
"pressed" : "released");
|
||||
#ifdef HAS_TASK_KEYPROTO
|
||||
#if defined(HAS_TASK_KEYPROTO) || defined(CONFIG_KEYBOARD_PROTOCOL_MKBP)
|
||||
keyboard_update_button(buttons[i].type,
|
||||
new_pressed);
|
||||
#endif
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "atomic.h"
|
||||
#include "button.h"
|
||||
#include "chipset.h"
|
||||
#include "common.h"
|
||||
#include "console.h"
|
||||
@@ -213,6 +214,49 @@ static void lid_change(void)
|
||||
DECLARE_HOOK(HOOK_LID_CHANGE, lid_change, HOOK_PRIO_LAST);
|
||||
DECLARE_HOOK(HOOK_INIT, lid_change, HOOK_PRIO_INIT_LID+1);
|
||||
|
||||
void keyboard_update_button(enum keyboard_button_type button, int is_pressed)
|
||||
{
|
||||
switch (button) {
|
||||
case KEYBOARD_BUTTON_POWER:
|
||||
mkbp_button_state &= ~(1 << EC_MKBP_POWER_BUTTON);
|
||||
mkbp_button_state |= (is_pressed << EC_MKBP_POWER_BUTTON);
|
||||
break;
|
||||
|
||||
case KEYBOARD_BUTTON_VOLUME_UP:
|
||||
mkbp_button_state &= ~(1 << EC_MKBP_VOL_UP);
|
||||
mkbp_button_state |= (is_pressed << EC_MKBP_VOL_UP);
|
||||
break;
|
||||
|
||||
case KEYBOARD_BUTTON_VOLUME_DOWN:
|
||||
mkbp_button_state &= ~(1 << EC_MKBP_VOL_DOWN);
|
||||
mkbp_button_state |= (is_pressed << EC_MKBP_VOL_DOWN);
|
||||
break;
|
||||
|
||||
default:
|
||||
/* ignored. */
|
||||
return;
|
||||
}
|
||||
|
||||
CPRINTS("buttons: %x", mkbp_button_state);
|
||||
|
||||
/* Add the new state to the FIFO. */
|
||||
mkbp_fifo_add(EC_MKBP_EVENT_BUTTON,
|
||||
(const uint8_t *)&mkbp_button_state);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_POWER_BUTTON
|
||||
/**
|
||||
* Handle power button changing state.
|
||||
*/
|
||||
static void keyboard_power_button(void)
|
||||
{
|
||||
keyboard_update_button(KEYBOARD_BUTTON_POWER,
|
||||
power_button_is_pressed());
|
||||
}
|
||||
DECLARE_HOOK(HOOK_POWER_BUTTON_CHANGE, keyboard_power_button,
|
||||
HOOK_PRIO_DEFAULT);
|
||||
#endif /* defined(CONFIG_POWER_BUTTON) */
|
||||
|
||||
static int get_next_event(uint8_t *out, enum ec_mkbp_event evt)
|
||||
{
|
||||
uint8_t t = fifo[fifo_start].event_type;
|
||||
|
||||
Reference in New Issue
Block a user