summaryrefslogtreecommitdiff
path: root/zephyr/projects/nissa/joxer/src/keyboard.c
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/projects/nissa/joxer/src/keyboard.c')
-rw-r--r--zephyr/projects/nissa/joxer/src/keyboard.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/zephyr/projects/nissa/joxer/src/keyboard.c b/zephyr/projects/nissa/joxer/src/keyboard.c
new file mode 100644
index 0000000000..48db40f53f
--- /dev/null
+++ b/zephyr/projects/nissa/joxer/src/keyboard.c
@@ -0,0 +1,68 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <zephyr/devicetree.h>
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/logging/log.h>
+
+#include "cros_cbi.h"
+#include "ec_commands.h"
+#include "gpio/gpio.h"
+#include "hooks.h"
+#include "keyboard_8042_sharedlib.h"
+#include "nissa_common.h"
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+static const struct ec_response_keybd_config joxer_kb_legacy = {
+ .num_top_row_keys = 13,
+ .action_keys = {
+ TK_BACK, /* T1 */
+ TK_REFRESH, /* T2 */
+ TK_FULLSCREEN, /* T3 */
+ TK_OVERVIEW, /* T4 */
+ TK_SNAPSHOT, /* T5 */
+ TK_BRIGHTNESS_DOWN, /* T6 */
+ TK_BRIGHTNESS_UP, /* T7 */
+ TK_KBD_BKLIGHT_TOGGLE, /* T8 */
+ TK_PLAY_PAUSE, /* T9 */
+ TK_MICMUTE, /* T10 */
+ TK_VOL_MUTE, /* T11 */
+ TK_VOL_DOWN, /* T12 */
+ TK_VOL_UP, /* T13 */
+ },
+ .capabilities = KEYBD_CAP_SCRNLOCK_KEY,
+};
+
+__override const struct ec_response_keybd_config *
+board_vivaldi_keybd_config(void)
+{
+ return &joxer_kb_legacy;
+}
+
+/*
+ * Keyboard layout decided by FW config.
+ */
+static void kb_layout_init(void)
+{
+ int ret;
+ uint32_t val;
+ /*
+ * Retrieve the kb layout config.
+ */
+ ret = cros_cbi_get_fw_config(FW_KB_LAYOUT, &val);
+ if (ret != 0) {
+ LOG_ERR("Error retrieving CBI FW_CONFIG field %d",
+ FW_KB_LAYOUT);
+ return;
+ }
+ /*
+ * If keyboard is US2(FW_KB_LAYOUT_US2), we need translate right ctrl
+ * to backslash(\|) key.
+ */
+ if (val == FW_KB_LAYOUT_US2)
+ set_scancode_set2(4, 0, get_scancode_set2(2, 7));
+}
+DECLARE_HOOK(HOOK_INIT, kb_layout_init, HOOK_PRIO_POST_FIRST);