diff options
author | Nicolas Boichat <drinkcat@google.com> | 2017-05-23 17:47:57 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-06-02 23:59:05 -0700 |
commit | 5c9118b311ed1d4059b9e51c3defcf5bce62de04 (patch) | |
tree | 446daae3aa692462c9ddd44365f5afd60db6aaa2 | |
parent | cc8fd2386f6ea1f888466a324c8c65cbade142b1 (diff) | |
download | chrome-ec-5c9118b311ed1d4059b9e51c3defcf5bce62de04.tar.gz |
hammer: Add support for new key
There is a new keyboard matrix layout:
- We can map the search key to both KSO1, KSI0 and KSO0, KSI3
(old layout will only use the former, new layout will use the latter).
- There is a new key on KSO0, KSI5, which we can map to HID page 0xffd1
code 0x0018.
BRANCH=none
BUG=b:62004286
TEST=Flash hammer
kbpress 0 3 1; kbpress 0 3 0 reports KEY_LEFTMETA as expected
kbpress 0 5 1; kbpress 0 5 0 reports "BTN_0", which is probably
incorrect, and needs to be fixed.
Change-Id: I9fb428805ff756b6d63f50cc5b061c6a0e1defbc
Reviewed-on: https://chromium-review.googlesource.com/512502
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
-rw-r--r-- | board/hammer/board.c | 16 | ||||
-rw-r--r-- | board/hammer/board.h | 4 | ||||
-rw-r--r-- | chip/stm32/usb_hid_keyboard.c | 38 | ||||
-rw-r--r-- | include/config.h | 3 |
4 files changed, 59 insertions, 2 deletions
diff --git a/board/hammer/board.c b/board/hammer/board.c index a178dbf66a..d50634aab8 100644 --- a/board/hammer/board.c +++ b/board/hammer/board.c @@ -11,6 +11,7 @@ #include "hooks.h" #include "i2c.h" #include "keyboard_raw.h" +#include "keyboard_scan.h" #include "pwm.h" #include "pwm_chip.h" #include "registers.h" @@ -75,6 +76,21 @@ BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); int usb_i2c_board_enable(void) { return EC_SUCCESS; } void usb_i2c_board_disable(void) {} + +#ifdef CONFIG_KEYBOARD_BOARD_CONFIG +struct keyboard_scan_config keyscan_config = { + .output_settle_us = 50, + .debounce_down_us = 9 * MSEC, + .debounce_up_us = 30 * MSEC, + .scan_period_us = 3 * MSEC, + .min_post_scan_delay_us = 1000, + .poll_timeout_us = 100 * MSEC, + .actual_key_mask = { + 0x3c, 0xff, 0xff, 0xff, 0xff, 0xf5, 0xff, + 0xa4, 0xff, 0xfe, 0x55, 0xfa, 0xca /* full set */ + }, +}; +#endif #endif /****************************************************************************** diff --git a/board/hammer/board.h b/board/hammer/board.h index a676797c21..f342acf06e 100644 --- a/board/hammer/board.h +++ b/board/hammer/board.h @@ -155,6 +155,10 @@ #define CONFIG_KEYBOARD_DEBUG #undef CONFIG_KEYBOARD_BOOT_KEYS #undef CONFIG_KEYBOARD_RUNTIME_KEYS +#ifdef BOARD_HAMMER +#define CONFIG_KEYBOARD_BOARD_CONFIG +#define CONFIG_KEYBOARD_NEW_KEY +#endif /* Keyboard output port list */ #define KB_OUT_PORT_LIST GPIO_A, GPIO_B, GPIO_C, GPIO_F diff --git a/chip/stm32/usb_hid_keyboard.c b/chip/stm32/usb_hid_keyboard.c index 4147fcad1c..3b1204e47b 100644 --- a/chip/stm32/usb_hid_keyboard.c +++ b/chip/stm32/usb_hid_keyboard.c @@ -46,6 +46,10 @@ struct __attribute__((__packed__)) usb_hid_keyboard_report { uint8_t modifiers; /* bitmap of modifiers 224-231 */ uint8_t reserved; /* 0x0 */ uint8_t keys[6]; +#ifdef CONFIG_KEYBOARD_NEW_KEY + uint8_t new_key:1; + uint8_t reserved2:7; +#endif }; #define HID_KEYBOARD_REPORT_SIZE sizeof(struct usb_hid_keyboard_report) @@ -56,8 +60,12 @@ struct __attribute__((__packed__)) usb_hid_keyboard_report { #define HID_KEYBOARD_MODIFIER_LOW 0xe0 #define HID_KEYBOARD_MODIFIER_HIGH 0xe7 +#define HID_KEYBOARD_NEW_KEY 0xf0 + /* The standard Chrome OS keyboard matrix table. See HUT 1.12v2 Table 12 and * https://www.w3.org/TR/DOM-Level-3-Events-code . + * + * NEW_KEY is mapped as 0xf0, but this key code is never actually send. */ const uint8_t keycodes[KEYBOARD_ROWS][KEYBOARD_COLS] = { { 0x00, 0xe3, 0x3a, 0x05, 0x43, 0x87, 0x11, 0x00, 0x2e, @@ -66,11 +74,12 @@ const uint8_t keycodes[KEYBOARD_ROWS][KEYBOARD_COLS] = { 0x42, 0x00, 0x2a, 0x90 }, { 0xe0, 0x2b, 0x3c, 0x17, 0x3f, 0x30, 0x1c, 0x64, 0x2F, 0x41, 0x89, 0x00, 0x00 }, - { 0x00, 0x35, 0x3b, 0x22, 0x3e, 0x00, 0x23, 0x00, 0x2d, + { 0xe3, 0x35, 0x3b, 0x22, 0x3e, 0x00, 0x23, 0x00, 0x2d, 0x68, 0x00, 0x31, 0x91 }, { 0xe4, 0x04, 0x07, 0x09, 0x16, 0x0e, 0x0d, 0x00, 0x33, 0x0f, 0x31, 0x28, 0x00 }, - { 0x00, 0x1d, 0x06, 0x19, 0x1b, 0x36, 0x10, 0xe1, 0x38, + { HID_KEYBOARD_NEW_KEY, + 0x1d, 0x06, 0x19, 0x1b, 0x36, 0x10, 0xe1, 0x38, 0x37, 0x00, 0x2c, 0x00 }, { 0x00, 0x1e, 0x20, 0x21, 0x1f, 0x25, 0x24, 0x00, 0x27, 0x26, 0xe2, 0x51, 0x4f }, @@ -128,6 +137,22 @@ static const uint8_t report_desc[] = { 0x19, 0x00, /* Usage Minimum (0) */ 0x29, 0xa4, /* Usage Maximum (164) */ 0x81, 0x00, /* Input (Data, Array), ;Key arrays (6 bytes) */ + +#ifdef CONFIG_KEYBOARD_NEW_KEY + 0x06, 0xd1, 0xff, /* Usage Page (Vendor-defined 0xffd1) */ + 0x19, 0x18, /* Usage Minimum */ + 0x29, 0x18, /* Usage Maximum */ + 0x15, 0x00, /* Logical Minimum (0) */ + 0x25, 0x01, /* Logical Maximum (1) */ + 0x75, 0x01, /* Report Size (1) */ + 0x95, 0x01, /* Report Count (1) */ + 0x81, 0x02, /* Input (Data, Variable, Absolute), ;Modifier byte */ + + 0x95, 0x01, /* Report Count (1) */ + 0x75, 0x07, /* Report Size (7) */ + 0x81, 0x01, /* Input (Constant), ;7-bit padding */ +#endif + 0xC0 /* End Collection */ }; @@ -265,6 +290,15 @@ void keyboard_state_changed(int row, int col, int is_pressed) if (!keycode) { CPRINTF("Unknown key at %d/%d\n", row, col); return; + + } + + if (keycode == HID_KEYBOARD_NEW_KEY) { +#ifdef CONFIG_KEYBOARD_NEW_KEY + report.new_key = is_pressed ? 1 : 0; + write_keyboard_report(); +#endif + return; } if (keycode >= HID_KEYBOARD_MODIFIER_LOW && diff --git a/include/config.h b/include/config.h index d181ed79a8..b08f9296fa 100644 --- a/include/config.h +++ b/include/config.h @@ -1558,6 +1558,9 @@ */ #define CONFIG_KEYBOARD_BOOT_KEYS +/* Add support for the new key. */ +#undef CONFIG_KEYBOARD_NEW_KEY + /* * Minimum CPU clocks between scans. This ensures that keyboard scanning * doesn't starve the other EC tasks of CPU when running at a decreased system |