git: 08330304e8c4 - main - evdev: Map the HP mic mute and programmable keys on HP only
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 24 Nov 2026 22:47:23 UTC
The branch main has been updated by olivier:
URL: https://cgit.FreeBSD.org/src/commit/?id=08330304e8c435bdec0e72bb51b64a24c858ff75
commit 08330304e8c435bdec0e72bb51b64a24c858ff75
Author: Olivier Cochard <olivier@FreeBSD.org>
AuthorDate: 2026-11-23 09:55:04 +0000
Commit: Olivier Cochard <olivier@FreeBSD.org>
CommitDate: 2026-11-24 22:40:34 +0000
evdev: Map the HP mic mute and programmable keys on HP only
AT scan codes 0xE0 0x01 and 0x68 are vendor keys: systemd's hwdb gives
them other meanings on Dell, Alienware, Lenovo, Samsung and others,
some of which send no release code. The shared AT table made Insert
toggle mic mute on an IdeaPad 5 and left KEY_PROG1 held after the Dell
G-Mode key.
Map them only where SMBIOS names an HP business laptop, as hwdb does:
0xE0 0x01 to KEY_MICMUTE on ZBook, EliteBook, ProBook, Elite Dragonfly
and EliteBoard, 0x68 to KEY_PROG1 on the Elite Dragonfly G2 and the
ZBook Ultra G1a.
Reported by: llm-postcr
Reviewed by: imp, wulf
Approved by: wulf
Fixes: d34baf1b5ca0 ("evdev: Map the HP mic mute and programmable keys")
MFC after: 1 week
Pull Request: https://ron-dev.freebsd.org/FreeBSD/src/pulls/130
---
sys/dev/evdev/evdev_utils.c | 57 +++++++++++++++++++++++++++++++++++++++++----
1 file changed, 53 insertions(+), 4 deletions(-)
diff --git a/sys/dev/evdev/evdev_utils.c b/sys/dev/evdev/evdev_utils.c
index 07ea01f31432..ecc4fec8403f 100644
--- a/sys/dev/evdev/evdev_utils.c
+++ b/sys/dev/evdev/evdev_utils.c
@@ -148,16 +148,14 @@ static uint16_t evdev_at_set1_scancodes[] = {
/* 0x60 - 0x7f */
NONE, NONE, NONE, NONE,
NONE, NONE, NONE, NONE,
- /* 0x68: HP programmable key */
- KEY_PROG1, NONE, NONE, NONE,
+ NONE, NONE, NONE, NONE,
NONE, NONE, NONE, NONE,
KEY_KATAKANAHIRAGANA, KEY_HANJA, KEY_HANGEUL, KEY_RO,
NONE, NONE, KEY_ZENKAKUHANKAKU, KEY_HIRAGANA,
KEY_KATAKANA, KEY_HENKAN, NONE, KEY_MUHENKAN,
NONE, KEY_YEN, KEY_KPCOMMA, NONE,
/* 0x00 - 0x1f. 0xE0 prefixed */
- /* 0xE0 0x01: HP mic mute (Fn+Esc on other HP models) */
- NONE, KEY_MICMUTE, NONE, NONE,
+ NONE, NONE, NONE, NONE,
NONE, NONE, NONE, NONE,
NONE, NONE, NONE, NONE,
NONE, NONE, NONE, NONE,
@@ -224,6 +222,57 @@ static uint16_t evdev_nfinger_codes[] = {
BTN_TOOL_QUINTTAP,
};
+/*
+ * Vendor keys whose scan code means another key, or a key without a
+ * release code, on other machines (systemd hwdb 60-keyboard.hwdb):
+ * mapped only when SMBIOS names the machine. The index is that of
+ * evdev_at_set1_scancodes[], 0x80 + code for 0xE0-prefixed codes.
+ */
+static const struct evdev_at_quirk {
+ const char *maker; /* prefix of smbios.system.maker */
+ const char *product; /* substring of smbios.system.product */
+ uint8_t index;
+ uint16_t keycode;
+} evdev_at_quirks[] = {
+ /* hwdb: HP EliteBook, Elite Dragonfly, ProBook, ZBook block */
+ { "HP", "ZBook", 0x81, KEY_MICMUTE },
+ { "HP", "EliteBook", 0x81, KEY_MICMUTE },
+ { "HP", "ProBook", 0x81, KEY_MICMUTE },
+ { "HP", "Elite Dragonfly", 0x81, KEY_MICMUTE },
+ { "HP", "EliteBoard", 0x81, KEY_MICMUTE },
+ { "Hewlett-Packard", "ZBook", 0x81, KEY_MICMUTE },
+ { "Hewlett-Packard", "EliteBook", 0x81, KEY_MICMUTE },
+ { "Hewlett-Packard", "ProBook", 0x81, KEY_MICMUTE },
+ /* hwdb "HP Elite Dragonfly G2" block */
+ { "HP", "Elite Dragonfly G2", 0x68, KEY_PROG1 },
+ /* Not in hwdb: measured on a ZBook Ultra G1a */
+ { "HP", "ZBook Ultra G1a", 0x68, KEY_PROG1 },
+};
+/* Any uint8_t index is in the table. */
+CTASSERT(nitems(evdev_at_set1_scancodes) > UINT8_MAX);
+
+static void
+evdev_at_quirks_init(void *arg __unused)
+{
+ char maker[64], product[128];
+ const struct evdev_at_quirk *q;
+
+ if (getenv_string("smbios.system.maker", maker, sizeof(maker)) == 0 ||
+ getenv_string("smbios.system.product", product,
+ sizeof(product)) == 0)
+ return;
+ for (q = evdev_at_quirks; q < evdev_at_quirks + nitems(evdev_at_quirks);
+ q++) {
+ /* A quirk only fills a code the generic table leaves out. */
+ if (evdev_at_set1_scancodes[q->index] == NONE &&
+ strncmp(maker, q->maker, strlen(q->maker)) == 0 &&
+ strstr(product, q->product) != NULL)
+ evdev_at_set1_scancodes[q->index] = q->keycode;
+ }
+}
+SYSINIT(evdev_at_quirks, SI_SUB_TUNABLES, SI_ORDER_ANY, evdev_at_quirks_init,
+ NULL);
+
uint16_t
evdev_hid2key(int scancode)
{