diff options
author | Rajat Jain <rajatja@google.com> | 2020-02-20 18:17:21 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-03-18 15:08:20 +0000 |
commit | 193ac121158cffb17fb9ad10324b3ef1eb218604 (patch) | |
tree | d565780ef0b96b560bcedbfc2364016070af0e65 | |
parent | eb035de8a80ee23b6c156043ebf618e90193c731 (diff) | |
download | chrome-ec-193ac121158cffb17fb9ad10324b3ef1eb218604.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>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2080603
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Change-Id: Id6b854337958d99898175e7be7a9972938e32399
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2106616
Tested-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Commit-Queue: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
-rw-r--r-- | common/build.mk | 1 | ||||
-rw-r--r-- | common/keyboard_vivaldi.c | 68 | ||||
-rw-r--r-- | include/config.h | 12 | ||||
-rw-r--r-- | include/keyboard_8042_sharedlib.h | 42 | ||||
-rw-r--r-- | include/keyboard_vivaldi.h | 37 |
5 files changed, 150 insertions, 10 deletions
diff --git a/common/build.mk b/common/build.mk index f9af6a2c27..cb6982626d 100644 --- a/common/build.mk +++ b/common/build.mk @@ -92,6 +92,7 @@ common-$(CONFIG_KEYBOARD_PROTOCOL_8042)+=keyboard_8042.o \ keyboard_8042_sharedlib.o common-$(CONFIG_KEYBOARD_PROTOCOL_MKBP)+=keyboard_mkbp.o common-$(CONFIG_KEYBOARD_TEST)+=keyboard_test.o +common-$(CONFIG_KEYBOARD_VIVALDI)+=keyboard_vivaldi.o common-$(CONFIG_LED_COMMON)+=led_common.o common-$(CONFIG_LED_POLICY_STD)+=led_policy_std.o common-$(CONFIG_LED_PWM)+=led_pwm.o 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); + } + } +} diff --git a/include/config.h b/include/config.h index b2d998f883..2f1d94e00f 100644 --- a/include/config.h +++ b/include/config.h @@ -2475,6 +2475,13 @@ #undef CONFIG_KEYBOARD_SCANCODE_MUTABLE /* + * Include the Vivaldi keyboard code. The vivaldi is a newer keyboard that can + * have up to 15 top row keys (other than Esc and Power/Lock) and also allows + * OEMs flexibility to use these keys for different purposes (or reordering). + */ +#undef CONFIG_KEYBOARD_VIVALDI + +/* * Allow board-specific 8042 keyboard callback when a key state is changed. */ #undef CONFIG_KEYBOARD_SCANCODE_CALLBACK @@ -4604,6 +4611,11 @@ #define CONFIG_MKBP_EVENT #endif +/* Vivaldi keyboard code needs to be able to change the keyboard scancodes */ +#ifdef CONFIG_KEYBOARD_VIVALDI +#define CONFIG_KEYBOARD_SCANCODE_MUTABLE +#endif + /******************************************************************************/ /* MKBP events delivery methods. */ #ifdef CONFIG_MKBP_EVENT diff --git a/include/keyboard_8042_sharedlib.h b/include/keyboard_8042_sharedlib.h index a82e1f85eb..e2cc22e633 100644 --- a/include/keyboard_8042_sharedlib.h +++ b/include/keyboard_8042_sharedlib.h @@ -94,14 +94,38 @@ enum scancode_values { SCANCODE_B = 0x0032, SCANCODE_T = 0x002c, - SCANCODE_F1 = 0x0005, - SCANCODE_F2 = 0x0006, - SCANCODE_F3 = 0x0004, - SCANCODE_F4 = 0x000c, - SCANCODE_F5 = 0x0003, - SCANCODE_F6 = 0x000b, - SCANCODE_F7 = 0x0083, - SCANCODE_F8 = 0x000a, + SCANCODE_F1 = 0x0005, /* Translates to 3b in codeset 1 */ + SCANCODE_F2 = 0x0006, /* Translates to 3c in codeset 1 */ + SCANCODE_F3 = 0x0004, /* Translates to 3d in codeset 1 */ + SCANCODE_F4 = 0x000c, /* Translates to 3e in codeset 1 */ + SCANCODE_F5 = 0x0003, /* Translates to 3f in codeset 1 */ + SCANCODE_F6 = 0x000b, /* Translates to 40 in codeset 1 */ + SCANCODE_F7 = 0x0083, /* Translates to 41 in codeset 1 */ + SCANCODE_F8 = 0x000a, /* Translates to 42 in codeset 1 */ + SCANCODE_F9 = 0x0001, /* Translates to 43 in codeset 1 */ + SCANCODE_F10 = 0x0009, /* Translates to 44 in codeset 1 */ + SCANCODE_F11 = 0x0078, /* Translates to 57 in codeset 1 */ + SCANCODE_F12 = 0x0007, /* Translates to 58 in codeset 1 */ + SCANCODE_F13 = 0x000f, /* Translates to 59 in codeset 1 */ + SCANCODE_F14 = 0x0017, /* Translates to 5a in codeset 1 */ + SCANCODE_F15 = 0x001f, /* Translates to 5b in codeset 1 */ + + SCANCODE_BACK = 0xe038, /* e06a in codeset 1 */ + SCANCODE_REFRESH = 0xe020, /* e067 in codeset 1 */ + SCANCODE_ZOOM = 0xe01d, /* e011 in codeset 1 */ + SCANCODE_SCALE = 0xe024, /* e012 in codeset 1 */ + SCANCODE_SNIP = 0xe02d, /* e013 in codeset 1 */ + SCANCODE_BRIGHTNESS_DOWN = 0xe02c, /* e014 in codeset 1 */ + SCANCODE_BRIGHTNESS_UP = 0xe035, /* e015 in codeset 1 */ + SCANCODE_PRIVACY_SCRN_TOGGLE = 0xe03c, /* e016 in codeset 1 */ + SCANCODE_VOLUME_MUTE = 0xe023, /* e020 in codeset 1 */ + SCANCODE_VOLUME_DOWN = 0xe021, /* e02e in codeset 1 */ + SCANCODE_VOLUME_UP = 0xe032, /* e030 in codeset 1 */ + SCANCODE_KBD_BKLIGHT_DOWN = 0xe043, /* e017 in codeset 1 */ + SCANCODE_KBD_BKLIGHT_UP = 0xe044, /* e018 in codeset 1 */ + SCANCODE_NEXT_TRACK = 0xe04d, /* e019 in codeset 1 */ + SCANCODE_PREV_TRACK = 0xe015, /* e010 in codeset 1 */ + SCANCODE_PLAY_PAUSE = 0xe054, /* e01a in codeset 1 */ SCANCODE_UP = 0xe075, SCANCODE_DOWN = 0xe072, @@ -118,8 +142,6 @@ enum scancode_values { SCANCODE_MENU = 0xe02f, SCANCODE_POWER = 0xe037, - SCANCODE_VOLUME_DOWN = 0xe021, - SCANCODE_VOLUME_UP = 0xe032, SCANCODE_NUMLOCK = 0x0077, SCANCODE_CAPSLOCK = 0x0058, diff --git a/include/keyboard_vivaldi.h b/include/keyboard_vivaldi.h new file mode 100644 index 0000000000..c17fe7abb9 --- /dev/null +++ b/include/keyboard_vivaldi.h @@ -0,0 +1,37 @@ +/* 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. + */ + +#ifndef __KEYBOARD_VIVALDI_H__ +#define __KEYBOARD_VIVALDI_H__ + +#include <keyboard_8042_sharedlib.h> + +enum vivaldi_top_keys { + T1 = 0, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + MAX_VIVALDI_KEYS +}; + +struct vivaldi_config { + uint8_t num_top_row_keys; + uint16_t scancodes[MAX_VIVALDI_KEYS]; +}; + +void vivaldi_init(const struct vivaldi_config *vivaldi_config); + +#endif /* __KEYBOARD_VIVALDI_H__ */ |