mkbp: Re-factor button processing in MKBP driver

This change is motivated by following requirements on devices like
Soraka for the firmware menu:
1. Single button should be reported on release and not press.
2. If button is held down for 3 seconds, then a special action needs
to be taken.
3. Special action needs to be taken on two button press i.e. Vup+Vdn.

Above requirements need to be satisifed because:
1. In conditions where user is trying to enter manual recovery by
holding power, vup and vdn buttons at the firmware menu screen, button
press can be incorrectly accepted as user input thus taking action
based on the current menu.
2. At developer screen, if volume up is held for 3 seconds, it should
act as Ctrl-U and if volume down is held for 3 seconds, it should act
as Ctrl-D.
3. For one of the future works, Vup+Vdn needs to be identified as a
valid input from user on one of the firmware screens.

This change introduces a prev_bitmap for button state that is checked
whenever there is a new button event. It is used to decide if a button
that was pressed earlier is released now. If so, then it is reported
back to the caller. Additionally, if more than one button is pressed
at a time, then the combo is checked to identify if it is valid and
reported back to the caller.

Each button combo has longpress and shortpress info associated with
it. If a button release event is received for a button that was
pressed before, then it is accepted as a short press and corresponding
scancode is reported. If a button is held down for >3seconds, then it
is considered as a long press and corresponding scancode is reported.

CQ-DEPEND=CL:757123
BUG=b:64992445,b:65013794
BRANCH=None
TEST=Verified following on Soraka:
1. Short press of button behaves correctly in navigating and selecting
menu option.
2. Long press of Vup in developer mode screen results in Ctrl-U action.
3. Long press of Vdn in developer mode screen results in Ctrl-D
action.
4. Pressing Pwr+Vup+Vdn at any firmware screen does not trigger menu
selection or navigation.

Change-Id: I3a5a9748538c4d15fb8dc2192a7d268467afe158
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/756254
Reviewed-by: Julius Werner <jwerner@chromium.org>
6 files changed