diff options
author | Randall Spangler <rspangler@chromium.org> | 2013-10-24 10:19:55 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2013-10-30 23:10:13 +0000 |
commit | d16a246ea9c7d5982d4eb932c09310146ab3463e (patch) | |
tree | 780645ec6acc8496e367d5a34f9cc23020a650c9 | |
parent | e48a9d9c2143695cdd7a35ab06d6a6d5820efd9b (diff) | |
download | chrome-ec-d16a246ea9c7d5982d4eb932c09310146ab3463e.tar.gz |
cleanup: mkbp keyboard module
Rather than compile it by default for host-based tests, only compile
it for the few tests that actually use it. Since those (and all
boards) now only use if if they also have a keyscan task, we can get
rid of the #ifdefs in keyboard_mkbp.c as well.
And remove a TODO we'll never do...
BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all boards; pass unit tests. These pass:
util/make_all.sh
make BOARD=pit tests
Change-Id: I44d1806cfb375027a7ed0b33a5e9bdbbed8ccddc
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/174513
-rw-r--r-- | board/host/board.h | 1 | ||||
-rw-r--r-- | common/extpower_spring.c | 2 | ||||
-rw-r--r-- | common/keyboard_mkbp.c | 10 | ||||
-rw-r--r-- | include/config.h | 5 | ||||
-rw-r--r-- | include/keyboard_mkbp.h | 4 | ||||
-rw-r--r-- | test/test_config.h | 9 |
6 files changed, 18 insertions, 13 deletions
diff --git a/board/host/board.h b/board/host/board.h index ab67e8d67b..543f25b6b6 100644 --- a/board/host/board.h +++ b/board/host/board.h @@ -11,7 +11,6 @@ /* Optional features */ #define CONFIG_EXTPOWER_GPIO #undef CONFIG_FMAP -#define CONFIG_KEYBOARD_PROTOCOL_MKBP #define CONFIG_POWER_BUTTON #undef CONFIG_WATCHDOG #define CONFIG_SWITCH diff --git a/common/extpower_spring.c b/common/extpower_spring.c index 14bc864cf1..022788704b 100644 --- a/common/extpower_spring.c +++ b/common/extpower_spring.c @@ -16,7 +16,7 @@ #include "gpio.h" #include "hooks.h" #include "host_command.h" -#include "keyboard_protocol.h" +#include "keyboard_mkbp.h" #include "pmu_tpschrome.h" #include "pwm.h" /* TODO(rspangler): files in common should not use chip registers directly */ diff --git a/common/keyboard_mkbp.c b/common/keyboard_mkbp.c index 33ba1e782a..d5343cdf36 100644 --- a/common/keyboard_mkbp.c +++ b/common/keyboard_mkbp.c @@ -156,12 +156,8 @@ void keyboard_send_battery_key(void) { uint8_t state[KEYBOARD_COLS]; -#ifdef HAS_TASK_KEYSCAN /* Copy debounced state and add battery pseudo-key */ memcpy(state, keyboard_scan_get_state(), sizeof(state)); -#else - memset(state, 0, sizeof(state)); -#endif state[BATTERY_KEY_COL] ^= BATTERY_KEY_ROW_MASK; /* Add to FIFO only if AP is on or else it will wake from suspend */ @@ -206,7 +202,6 @@ static void set_keyscan_config(const struct ec_mkbp_config *src, struct ec_mkbp_protocol_config *dst, uint32_t valid_mask, uint8_t new_flags) { -#ifdef HAS_TASK_KEYSCAN struct keyboard_scan_config *ksc = keyboard_scan_get_config(); if (valid_mask & EC_MKBP_VALID_SCAN_PERIOD) @@ -241,12 +236,10 @@ static void set_keyscan_config(const struct ec_mkbp_config *src, if ((new_flags & EC_MKBP_FLAGS_ENABLE) && !(dst->flags & EC_MKBP_FLAGS_ENABLE)) task_wake(TASK_ID_KEYSCAN); -#endif } static void get_keyscan_config(struct ec_mkbp_config *dst) { -#ifdef HAS_TASK_KEYSCAN const struct keyboard_scan_config *ksc = keyboard_scan_get_config(); /* Copy fields from keyscan config to mkbp config */ @@ -256,7 +249,6 @@ static void get_keyscan_config(struct ec_mkbp_config *dst) dst->scan_period_us = ksc->scan_period_us; dst->min_post_scan_delay_us = ksc->min_post_scan_delay_us; dst->poll_timeout_us = ksc->poll_timeout_us; -#endif } /** @@ -265,8 +257,6 @@ static void get_keyscan_config(struct ec_mkbp_config *dst) * This is like a structure copy, except that only selected fields are * copied. * - * TODO(sjg@chromium.org): Consider making this table driven as ectool. - * * @param src Source config * @param dst Destination config * @param valid_mask Bits representing which fields to copy - each bit is diff --git a/include/config.h b/include/config.h index 05f085f180..345a606c5e 100644 --- a/include/config.h +++ b/include/config.h @@ -774,6 +774,11 @@ */ #endif +#ifndef HAS_TASK_KEYSCAN +#undef CONFIG_KEYBOARD_PROTOCOL_8042 +#undef CONFIG_KEYBOARD_PROTOCOL_MKBP +#endif + /*****************************************************************************/ /* * Apply test config overrides last, since tests need to override some of the diff --git a/include/keyboard_mkbp.h b/include/keyboard_mkbp.h index 2fb9fc1273..5ea3c54593 100644 --- a/include/keyboard_mkbp.h +++ b/include/keyboard_mkbp.h @@ -20,6 +20,10 @@ int keyboard_fifo_add(const uint8_t *buffp); /** * Send KEY_BATTERY keystroke. */ +#ifdef CONFIG_KEYBOARD_PROTOCOL_MKBP void keyboard_send_battery_key(void); +#else +static inline void keyboard_send_battery_key(void) { } +#endif #endif /* __CROS_EC_KEYBOARD_MKBP_H */ diff --git a/test/test_config.h b/test/test_config.h index 1273a4c4aa..055a0b60df 100644 --- a/test/test_config.h +++ b/test/test_config.h @@ -23,10 +23,17 @@ #endif #ifdef TEST_kb_8042 -#undef CONFIG_KEYBOARD_PROTOCOL_MKBP #define CONFIG_KEYBOARD_PROTOCOL_8042 #endif +#ifdef TEST_kb_mkbp +#define CONFIG_KEYBOARD_PROTOCOL_MKBP +#endif + +#ifdef TEST_kb_scan +#define CONFIG_KEYBOARD_PROTOCOL_MKBP +#endif + #ifdef TEST_led_spring #define CONFIG_BATTERY_MOCK #define CONFIG_BATTERY_SMART |