summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTing Shen <phoenixshen@google.com>2021-08-05 13:13:55 +0800
committerCommit Bot <commit-bot@chromium.org>2021-08-09 04:57:16 +0000
commit16c8d4e0c017b4bb5f62f51292ecd580b69722ba (patch)
tree10141e5f6f185489bb7e670069f81a16c5956226
parentf60c312dcf183fdaef40d9a32f092193f8ec89db (diff)
downloadchrome-ec-16c8d4e0c017b4bb5f62f51292ecd580b69722ba.tar.gz
stm32/usb_hid_keyboard; implement new top row keys
Use the hid usage mapping from drivers/hid/hid-input.c: Page 0xB, Usage 0x2F -> KEY_MICMUTE Page 0xC, Usage 0x7C -> KEY_KBDILLUMTOGGLE BUG=b:194460146 TEST=Map the new keys to F1/F2 on homestar, and verify 1) kernal can get the expected key code. Event: -------------- SYN_REPORT ------------ Event: type 4 (EV_MSC), code 4 (MSC_SCAN), value b002f Event: type 1 (EV_KEY), code 248 (KEY_MICMUTE), value 1 Event: -------------- SYN_REPORT ------------ Event: type 4 (EV_MSC), code 4 (MSC_SCAN), value b002f Event: type 1 (EV_KEY), code 248 (KEY_MICMUTE), value 0 Event: -------------- SYN_REPORT ------------ Event: type 4 (EV_MSC), code 4 (MSC_SCAN), value c007c Event: type 1 (EV_KEY), code 228 (KEY_KBDILLUMTOGGLE), value 1 Event: -------------- SYN_REPORT ------------ Event: type 4 (EV_MSC), code 4 (MSC_SCAN), value c007c Event: type 1 (EV_KEY), code 228 (KEY_KBDILLUMTOGGLE), value 0 2) `cat /sys/class/input/*/device/function_row_physmap` BRANCH=trogdor Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: Ibf342b881ee428598adaeb73a63bf242cd220004 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3073440 Reviewed-by: Wai-Hong Tam <waihong@google.com> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org>
-rw-r--r--chip/stm32/usb_hid_keyboard.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/chip/stm32/usb_hid_keyboard.c b/chip/stm32/usb_hid_keyboard.c
index ab529b27b3..defe39e845 100644
--- a/chip/stm32/usb_hid_keyboard.c
+++ b/chip/stm32/usb_hid_keyboard.c
@@ -226,15 +226,17 @@ const struct usb_endpoint_descriptor USB_EP_DESC(USB_IFACE_HID_KEYBOARD, 02) = {
0x09, 0xCD, /* Play / Pause (0xCD) */ \
0x09, 0xB5, /* Scan Next Track (0xB5) */ \
0x09, 0xB6, /* Scan Previous Track (0xB6) */ \
+ 0x09, 0x7C, /* Keyboard Backlight OOC (0x7C) */ \
+ 0x0B, 0x2F, 0x00, 0x0B, 0x00, /* Phone Mute (Page 0xB, Usage 0x2F) */ \
0x09, 0x32, /* Sleep (0x32) */ \
0x15, 0x00, /* Logical Minimum (0) */ \
0x25, 0x01, /* Logical Maximum (1) */ \
0x75, 0x01, /* Report Size (1) */ \
- 0x95, 0x12, /* Report Count (18) */ \
+ 0x95, 0x14, /* Report Count (20) */ \
0x81, 0x02, /* Input (Data, Variable, Absolute), ;Modifier byte */ \
\
- /* 14-bit padding */ \
- 0x95, 0x0E, /* Report Count (14) */ \
+ /* 12-bit padding */ \
+ 0x95, 0x0C, /* Report Count (12) */ \
0x75, 0x01, /* Report Size (1) */ \
0x81, 0x01, /* Input (Constant), ;1-bit padding */
@@ -509,8 +511,12 @@ static const struct action_key_config action_key[] = {
[TK_PLAY_PAUSE] = { .mask = BIT(14), .usage = 0x000C00CD },
[TK_NEXT_TRACK] = { .mask = BIT(15), .usage = 0x000C00B5 },
[TK_PREV_TRACK] = { .mask = BIT(16), .usage = 0x000C00B6 },
+ [TK_KBD_BKLIGHT_TOGGLE] = { .mask = BIT(17), .usage = 0x000C007C },
+ [TK_MICMUTE] = { .mask = BIT(18), .usage = 0x000B002F },
};
+static const int SLEEP_KEY_MASK = BIT(ARRAY_SIZE(action_key));
+
#ifdef CONFIG_USB_HID_KEYBOARD_VIVALDI
static uint32_t feature_report[CONFIG_USB_HID_KB_NUM_TOP_ROW_KEYS];
@@ -639,7 +645,7 @@ static uint32_t maybe_convert_function_key(int keycode)
/* convert F13 to Sleep */
if (index == 12 && (config->capabilities & KEYBD_CAP_SCRNLOCK_KEY))
- return BIT(17);
+ return SLEEP_KEY_MASK;
if (index >= config->num_top_row_keys ||
config->action_keys[index] == TK_ABSENT)