diff options
author | Rajat Jain <rajatja@google.com> | 2020-02-20 18:17:21 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-03-17 01:00:55 +0000 |
commit | ff9678a2d7b3fb50e022fff34e66a660de0862fe (patch) | |
tree | c3177c1d8fe2b45c394c8787954c4a993a9f4516 /common/keyboard_vivaldi.c | |
parent | f270fc5d420c54fd26579fe7d5c7ce2bf0ddd936 (diff) | |
download | chrome-ec-ff9678a2d7b3fb50e022fff34e66a660de0862fe.tar.gz |
common/keyboard_vivaldi: Support for new Vivaldi keyboard
Vivaldi is a new keyboard that allows individual boards to have
additional or different top row keys and/or to reorder those keys.
go/vivaldi-prd
go/vivaldi-design
Add code to provide an API that individual boards that use the vivaldi
keyboard, that lets them define their board keyboard top row layout.
Some scan codes have been taken from
https://wiki.osdev.org/PS/2_Keyboard#Key_Codes.2C_Key_States_and_Key_Mappings
and ones that did not exist, have been allotted from (seemingly) free
holes in there.
BUG=b:146501925
TEST=Check on Jinlon the (new) expected scancodes are output from EC.
BRANCH=firmware-hatch-12672.B
Signed-off-by: Rajat Jain <rajatja@google.com>
Change-Id: Id6b854337958d99898175e7be7a9972938e32399
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2080603
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Diffstat (limited to 'common/keyboard_vivaldi.c')
-rw-r--r-- | common/keyboard_vivaldi.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/common/keyboard_vivaldi.c b/common/keyboard_vivaldi.c new file mode 100644 index 0000000000..4f59f5495b --- /dev/null +++ b/common/keyboard_vivaldi.c @@ -0,0 +1,68 @@ +/* Copyright 2020 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Vivali Keyboard code for Chrome EC */ + +#include "keyboard_8042_sharedlib.h" +#include "keyboard_scan.h" +#include "keyboard_vivaldi.h" + +/* + * Row Column info for Top row keys T1 - T15 + * Ref: https://drive.google.com/corp/drive/folders/17UtVQ-AixnlQuicRPTp8t46HE-sT522E + */ +static const struct key { + uint8_t row; + uint8_t col; +} vivaldi[MAX_VIVALDI_KEYS] = { + [T1] = {.row = 0, .col = 2}, + [T2] = {.row = 3, .col = 2}, + [T3] = {.row = 2, .col = 2}, + [T4] = {.row = 1, .col = 2}, + [T5] = {.row = 3, .col = 4}, + [T6] = {.row = 2, .col = 4}, + [T7] = {.row = 1, .col = 4}, + [T8] = {.row = 2, .col = 9}, + [T9] = {.row = 1, .col = 9}, + [T10] = {.row = 0, .col = 4}, + [T11] = {.row = 0, .col = 1}, + [T12] = {.row = 1, .col = 5}, + [T13] = {.row = 3, .col = 5}, + [T14] = {.row = 0, .col = 9}, + [T15] = {.row = 0, .col = 11}, +}; + +void vivaldi_init(const struct vivaldi_config *keybd) +{ + uint8_t row, col, *mask; + int key; + + cprints(CC_KEYBOARD, "VIVALDI: Num top row keys = %u\n", + keybd->num_top_row_keys); + + if (keybd->num_top_row_keys > MAX_VIVALDI_KEYS || + keybd->num_top_row_keys < 10) + cprints(CC_KEYBOARD, + "BAD VIVALDI CONFIG! Some keys may not work\n"); + + for (key = T1; key < MAX_VIVALDI_KEYS; key++) { + + row = vivaldi[key].row; + col = vivaldi[key].col; + mask = keyscan_config.actual_key_mask + col; + + if (key < keybd->num_top_row_keys && keybd->scancodes[key]) { + + /* Enable the mask */ + *mask |= (1 << row); + + /* Populate the scancode */ + scancode_set2[col][row] = keybd->scancodes[key]; + } else { + /* Disable the mask */ + *mask &= ~(1 << row); + } + } +} |