summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHung-Te Lin <hungte@chromium.org>2018-08-09 11:53:38 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-08-20 03:27:39 -0700
commit28433e8bae44a39550e69f6b891444db246126e9 (patch)
tree3b33c832957a7cd6912bf34db9b8e18b56186188
parente627fce49ece0908d1d2bf32d83cdc3718c3016b (diff)
downloadchrome-ec-28433e8bae44a39550e69f6b891444db246126e9.tar.gz
keyboard: Move keyboard_special (lightbar demo) to samus/board.c
Currently the keyboard_special has only one function - to enter demo or easter egg mode if lightbar task is running. However, only Samus has lightbar so we should not waste time doing keyboard_special on all boards. The better approach is to use the new CONFIG_KEYBOARD_SCANCODE_CALLBACK and provide the lightbar demo check inside samus board.c. BUG=None TEST=make buildall -j BRANCH=None Change-Id: Ie8ab994b5439309663328a75680d45230a6eaeea Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1168702 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--board/samus/board.c54
-rw-r--r--board/samus/board.h1
-rw-r--r--common/keyboard_8042.c54
3 files changed, 55 insertions, 54 deletions
diff --git a/board/samus/board.c b/board/samus/board.c
index d95975bb18..646d8ded9a 100644
--- a/board/samus/board.c
+++ b/board/samus/board.c
@@ -27,6 +27,8 @@
#include "host_command.h"
#include "i2c.h"
#include "keyboard_scan.h"
+#include "keyboard_8042.h"
+#include "keyboard_8042_sharedlib.h"
#include "lid_switch.h"
#include "lightbar.h"
#include "motion_sense.h"
@@ -407,3 +409,55 @@ void jtag_interrupt(enum gpio_signal signal)
}
#endif /* CONFIG_LOW_POWER_IDLE */
+
+enum ec_error_list keyboard_scancode_callback(uint16_t *make_code,
+ int8_t pressed)
+{
+ const uint16_t k = *make_code;
+ static uint8_t s;
+ static const uint16_t a[] = {
+ SCANCODE_UP, SCANCODE_UP, SCANCODE_DOWN, SCANCODE_DOWN,
+ SCANCODE_LEFT, SCANCODE_RIGHT, SCANCODE_LEFT, SCANCODE_RIGHT,
+ SCANCODE_B, SCANCODE_A};
+
+ if (!pressed)
+ return EC_SUCCESS;
+
+ /* Lightbar demo mode: keyboard can fake the battery state */
+ switch (k) {
+ case SCANCODE_UP:
+ demo_battery_level(1);
+ break;
+ case SCANCODE_DOWN:
+ demo_battery_level(-1);
+ break;
+ case SCANCODE_LEFT:
+ demo_is_charging(0);
+ break;
+ case SCANCODE_RIGHT:
+ demo_is_charging(1);
+ break;
+ case SCANCODE_F6: /* dim */
+ demo_brightness(-1);
+ break;
+ case SCANCODE_F7: /* bright */
+ demo_brightness(1);
+ break;
+ case SCANCODE_T:
+ demo_tap();
+ break;
+ }
+
+ if (k == a[s])
+ s++;
+ else if (k != a[0])
+ s = 0;
+ else if (s != 2)
+ s = 1;
+
+ if (s == ARRAY_SIZE(a)) {
+ s = 0;
+ lightbar_sequence(LIGHTBAR_KONAMI);
+ }
+ return EC_SUCCESS;
+}
diff --git a/board/samus/board.h b/board/samus/board.h
index 1e0b73179e..1a5e11667f 100644
--- a/board/samus/board.h
+++ b/board/samus/board.h
@@ -33,6 +33,7 @@
#define CONFIG_KEYBOARD_BOARD_CONFIG
#define CONFIG_KEYBOARD_PROTOCOL_8042
#define CONFIG_KEYBOARD_COL2_INVERTED
+#define CONFIG_KEYBOARD_SCANCODE_CALLBACK
#define CONFIG_LID_ANGLE
#define CONFIG_LIGHTBAR_POWER_RAILS
#define CONFIG_LOW_POWER_IDLE
diff --git a/common/keyboard_8042.c b/common/keyboard_8042.c
index b178c50066..7e906a1c04 100644
--- a/common/keyboard_8042.c
+++ b/common/keyboard_8042.c
@@ -108,7 +108,6 @@ static uint8_t controller_ram[0x20] = {
/* 0x01 - 0x1f are controller RAM */
};
static uint8_t A20_status;
-static void keyboard_special(uint16_t k);
/*
* Scancode settings
@@ -311,8 +310,6 @@ static enum ec_error_list matrix_callback(int8_t row, int8_t col,
return EC_ERROR_INVAL;
make_code = scancode_set2[row][col];
- if (pressed)
- keyboard_special(make_code);
#ifdef CONFIG_KEYBOARD_SCANCODE_CALLBACK
{
@@ -781,57 +778,6 @@ static void i8042_handle_from_host(void)
}
}
-/* U U D D L R L R b a */
-static void keyboard_special(uint16_t k)
-{
- static uint8_t s;
- static const uint16_t a[] = {
- SCANCODE_UP, SCANCODE_UP, SCANCODE_DOWN, SCANCODE_DOWN,
- SCANCODE_LEFT, SCANCODE_RIGHT, SCANCODE_LEFT, SCANCODE_RIGHT,
- SCANCODE_B, SCANCODE_A};
-
-#ifdef HAS_TASK_LIGHTBAR
- /* Lightbar demo mode: keyboard can fake the battery state */
- switch (k) {
- case SCANCODE_UP:
- demo_battery_level(1);
- break;
- case SCANCODE_DOWN:
- demo_battery_level(-1);
- break;
- case SCANCODE_LEFT:
- demo_is_charging(0);
- break;
- case SCANCODE_RIGHT:
- demo_is_charging(1);
- break;
- case SCANCODE_F6: /* dim */
- demo_brightness(-1);
- break;
- case SCANCODE_F7: /* bright */
- demo_brightness(1);
- break;
- case SCANCODE_T:
- demo_tap();
- break;
- }
-#endif
-
- if (k == a[s])
- s++;
- else if (k != SCANCODE_UP)
- s = 0;
- else if (s != 2)
- s = 1;
-
- if (s == ARRAY_SIZE(a)) {
- s = 0;
-#ifdef HAS_TASK_LIGHTBAR
- lightbar_sequence(LIGHTBAR_KONAMI);
-#endif
- }
-}
-
void keyboard_protocol_task(void *u)
{
int wait = -1;