summaryrefslogtreecommitdiff
path: root/common/keyboard_8042.c
diff options
context:
space:
mode:
authorTristan Honscheid <honscheid@google.com>2023-05-09 13:48:33 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-05-11 02:05:49 +0000
commitd0d67299d61a2647ea76035d85ebf4eff65b4b8a (patch)
treea09fd14d33ad82babdd54fd8bdd86519eacd3065 /common/keyboard_8042.c
parent3d6f339994bd5e9188ec22e073598f6aa811de6b (diff)
downloadchrome-ec-d0d67299d61a2647ea76035d85ebf4eff65b4b8a.tar.gz
zephyr: test: Test keyboard_8042.c console commands
Add tests for the `8042` set of console commands in `keyboard_8042.c`, covers about 100 new lines. BUG=b:281691908 TEST=./twister -s drivers/drivers.keyboard_8042 Change-Id: I1e28e0258305d0e1d17571346fcdca8f19102cb9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4520583 Commit-Queue: Peter Marheine <pmarheine@chromium.org> Tested-by: Tristan Honscheid <honscheid@google.com> Commit-Queue: Tristan Honscheid <honscheid@google.com> Auto-Submit: Tristan Honscheid <honscheid@google.com> Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Diffstat (limited to 'common/keyboard_8042.c')
-rw-r--r--common/keyboard_8042.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/common/keyboard_8042.c b/common/keyboard_8042.c
index f3c454382b..3329ce38c0 100644
--- a/common/keyboard_8042.c
+++ b/common/keyboard_8042.c
@@ -430,7 +430,7 @@ static void set_typematic_delays(uint8_t data)
((typematic_value_from_host & 0x7) + 8) / 240;
}
-static void reset_rate_and_delay(void)
+test_export_static void reset_rate_and_delay(void)
{
set_typematic_delays(DEFAULT_TYPEMATIC_VALUE);
}
@@ -451,7 +451,7 @@ static void keyboard_wakeup(void)
host_set_single_event(EC_HOST_EVENT_KEY_PRESSED);
}
-static void set_typematic_key(const uint8_t *scan_code, int32_t len)
+test_export_static void set_typematic_key(const uint8_t *scan_code, int32_t len)
{
typematic_deadline.val = get_time().val + typematic_first_delay;
memcpy(typematic_scan_code, scan_code, len);
@@ -1390,3 +1390,30 @@ DECLARE_HOOK(HOOK_POWER_BUTTON_CHANGE, keyboard_power_button,
HOOK_PRIO_DEFAULT);
#endif /* CONFIG_POWER_BUTTON && !CONFIG_MKBP_INPUT_DEVICES */
+
+#ifdef TEST_BUILD
+void test_keyboard_8042_set_resend_command(const uint8_t *data, int length)
+{
+ length = MIN(length, sizeof(resend_command));
+
+ memcpy(resend_command, data, length);
+ resend_command_len = length;
+}
+
+void test_keyboard_8042_reset(void)
+{
+ /* Initialize controller ram */
+ memset(controller_ram, 0, sizeof(controller_ram));
+ controller_ram[0] = I8042_XLATE | I8042_AUX_DIS | I8042_KBD_DIS;
+
+ /* Typematic state reset */
+ reset_rate_and_delay();
+ clear_typematic_key();
+
+ /* Use default scancode set # 2 */
+ scancode_set = SCANCODE_SET_2;
+
+ /* Keyboard not enabled (matches I8042_KBD_DIS bit being set) */
+ keyboard_enabled = false;
+}
+#endif /* TEST_BUILD */