From nobody Sun Mar 29 13:17:43 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4fkFL00QQvz6X4W3 for ; Sun, 29 Mar 2026 13:17:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4fkFKz40Vcz3wVj for ; Sun, 29 Mar 2026 13:17:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1774790263; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=h2EgW/pIgWr8yCv2FqdNQWSFKoXjM0MZl9IvscfFh78=; b=vlAOfG9OIq/frY+mtbrWvs/LAMARs6eCKH3/sGWJd5rdtpo+uefpOyjnvjkZpToBTcYyTS wCS1c5Lj2QIM5LyidcKDYsFNPyc8tGO1MkZnHaD5bzDOpqrH30iWs4DH6unexaGo2Zom5X qe6jsBv0sHoS0ZPb5+jOeqZxPmk/JfBnbpIQB7oJ71RTD3EAIkosk3izaPb2WtNDCnV7Sn FB/59D2szYeHLvpGL027OaD5sDeV6qT3NwFylnanwJCi2IXoEm3ZhYqHbmMiiW7gELHMnq F+D7rPPMdIoQ9Iu4NfZkHy0AjcNjYA3sVtSLGnL1dt3ktULSqg32ccE6FrRXaA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1774790263; a=rsa-sha256; cv=none; b=Y4Kyt9AGjF+jv5hPv0UU763NQriWqZTUr8YjXkdQpMDjbbO9W5uMwUWDYKqa3VPUjDfKYW sqF5uEUDKxQ9y/sTwrfz9kqKuDSBqT0PVwdIxgu0jrGq0kMHwY6/P0f2Oeeg1GvEprcpr5 /kSrHhjFFUpxMoqg4kimv1E5GxBCHS7Q9fcAUYOYztXnJnyLZIjM49j1DM63ZjUH7DIAbJ d/MSz21zuKOXOhuixCh/emepO8IFqgaDZAMvP8lssxUtf80tldWPHjJLqTS5RZCWUAvwIK RXPkPFF72MdjmboXOJGZcn6O9+GUzzJQQ8jAAirLMaKDU4AZbwpgaX4Y9KwpEg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1774790263; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=h2EgW/pIgWr8yCv2FqdNQWSFKoXjM0MZl9IvscfFh78=; b=ShGWn0fqReG2bLjXp2F3O6OsbL776iLgFoDQNDiRgma1pEPfM3klbew6Mm0NmU1KOLYmfK x+EnRCxRZmPZ4pjwePXKaFw+4f1IuugW073KRB7//88kb+rzchviWHY2eCLf90XSH/gM18 ibGNwNwrKKnQAoXjFupWGh8QpSVSYPoHrslKMe+i/K5b4zijCtjBHVvMw6mvvtf+hbPcEj XiqMdF8aQjA3/+G6Gnkzrhi6HgLXjzp52kL4CQlOJ9USY5m9W/ZTyXe09vbaSghNz8K7Ja qrIj44/H+Xi126zRvCK9Bz4klNDAvbzRLeHTWd8kdOB5GVzR8z7whw7GrZwZ8A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fkFKz36J6z1C9w for ; Sun, 29 Mar 2026 13:17:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1e161 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 29 Mar 2026 13:17:43 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: tslight From: Vladimir Kondratyev Subject: git: 103325323c7d - main - hkbd(4): be more cautious & explicit about Apple vendor checking List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 103325323c7daf9fe6c9a6c71aa5c90974c9dff4 Auto-Submitted: auto-generated Date: Sun, 29 Mar 2026 13:17:43 +0000 Message-Id: <69c92677.1e161.65df2900@gitrepo.freebsd.org> The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=103325323c7daf9fe6c9a6c71aa5c90974c9dff4 commit 103325323c7daf9fe6c9a6c71aa5c90974c9dff4 Author: tslight AuthorDate: 2026-03-29 13:16:57 +0000 Commit: Vladimir Kondratyev CommitDate: 2026-03-29 13:16:57 +0000 hkbd(4): be more cautious & explicit about Apple vendor checking Apply the changes to ukbd(4) as well. Signed-off-by: tslight Reviewed by: wulf MFC after: 1 month Pull Request: https://github.com/freebsd/freebsd-src/pull/1998 --- sys/dev/hid/hkbd.c | 63 +++++++++++++++++++++++-------------------- sys/dev/usb/input/ukbd.c | 57 +++++++++++++++++++++------------------ sys/modules/hid/hkbd/Makefile | 2 +- 3 files changed, 66 insertions(+), 56 deletions(-) diff --git a/sys/dev/hid/hkbd.c b/sys/dev/hid/hkbd.c index a91a01a385e3..9ab02e940089 100644 --- a/sys/dev/hid/hkbd.c +++ b/sys/dev/hid/hkbd.c @@ -73,6 +73,8 @@ #include #include +#include "usbdevs.h" + #ifdef EVDEV_SUPPORT #include #include @@ -828,40 +830,43 @@ hkbd_parse_hid(struct hkbd_softc *sc, const uint8_t *ptr, uint32_t len, sc->sc_kbd_size = hid_report_size_max(ptr, len, hid_input, &sc->sc_kbd_id); + const struct hid_device_info *hw = hid_get_device_info(sc->sc_dev); + /* investigate if this is an Apple Keyboard */ - if (hidbus_locate(ptr, len, - HID_USAGE2(HUP_CONSUMER, HUG_APPLE_EJECT), - hid_input, tlc_index, 0, &sc->sc_loc_apple_eject, &flags, - &sc->sc_id_apple_eject, NULL)) { - if (flags & HIO_VARIABLE) - sc->sc_flags |= HKBD_FLAG_APPLE_EJECT | - HKBD_FLAG_APPLE_SWAP; - DPRINTFN(1, "Found Apple eject-key\n"); - } - /* - * check the same vendor pages that linux does to find the one apple - * uses for the function key. - */ - static const uint16_t apple_pages[] = { - HUP_APPLE, /* HID_UP_CUSTOM in linux */ - HUP_MICROSOFT, /* HID_UP_MSVENDOR in linux */ - HUP_HP, /* HID_UP_HPVENDOR2 in linux */ - 0xFFFF /* Original FreeBSD check (Remove?) */ - }; - for (int i = 0; i < (int)nitems(apple_pages); i++) { + if (hw->idVendor == USB_VENDOR_APPLE) { /* belt & braces! */ if (hidbus_locate(ptr, len, - HID_USAGE2(apple_pages[i], 0x0003), - hid_input, tlc_index, 0, - &sc->sc_loc_apple_fn, &flags, - &sc->sc_id_apple_fn, NULL)) { + HID_USAGE2(HUP_CONSUMER, HUG_APPLE_EJECT), + hid_input, tlc_index, 0, &sc->sc_loc_apple_eject, &flags, + &sc->sc_id_apple_eject, NULL)) { if (flags & HIO_VARIABLE) - sc->sc_flags |= HKBD_FLAG_APPLE_FN; - DPRINTFN(1, "Found Apple FN-key on page 0x%04x\n", - apple_pages[i]); - break; + sc->sc_flags |= HKBD_FLAG_APPLE_EJECT | + HKBD_FLAG_APPLE_SWAP; + DPRINTFN(1, "Found Apple eject-key\n"); + } + /* + * check the same vendor pages that linux does to find the one + * apple uses for the function key. + */ + static const uint16_t apple_pages[] = { + HUP_APPLE, /* HID_UP_CUSTOM in linux */ + HUP_MICROSOFT, /* HID_UP_MSVENDOR in linux */ + HUP_HP, /* HID_UP_HPVENDOR2 in linux */ + 0xFFFF /* Original FreeBSD check (Remove?) */ + }; + for (int i = 0; i < (int)nitems(apple_pages); i++) { + if (hidbus_locate(ptr, len, + HID_USAGE2(apple_pages[i], 0x0003), + hid_input, tlc_index, 0, &sc->sc_loc_apple_fn, &flags, + &sc->sc_id_apple_fn, NULL)) { + if (flags & HIO_VARIABLE) + sc->sc_flags |= HKBD_FLAG_APPLE_FN; + DPRINTFN(1, "Found Apple FN-key on page 0x%04x\n", + apple_pages[i]); + break; + } } } - + /* figure out event buffer */ if (hidbus_locate(ptr, len, HID_USAGE2(HUP_KEYBOARD, 0x00), diff --git a/sys/dev/usb/input/ukbd.c b/sys/dev/usb/input/ukbd.c index c15528553086..3ebdf1e9747d 100644 --- a/sys/dev/usb/input/ukbd.c +++ b/sys/dev/usb/input/ukbd.c @@ -205,6 +205,7 @@ struct ukbd_softc { uint16_t sc_inputs; uint16_t sc_inputhead; uint16_t sc_inputtail; + uint16_t sc_vendor_id; uint8_t sc_leds; /* store for async led requests */ uint8_t sc_iface_index; @@ -1093,33 +1094,36 @@ ukbd_parse_hid(struct ukbd_softc *sc, const uint8_t *ptr, uint32_t len) hid_input, &sc->sc_kbd_id); /* investigate if this is an Apple Keyboard */ - if (hid_locate(ptr, len, - HID_USAGE2(HUP_CONSUMER, HUG_APPLE_EJECT), - hid_input, 0, &sc->sc_loc_apple_eject, &flags, - &sc->sc_id_apple_eject)) { - if (flags & HIO_VARIABLE) - sc->sc_flags |= UKBD_FLAG_APPLE_EJECT; - DPRINTFN(1, "Found Apple eject-key\n"); - } - /* - * check the same vendor pages that linux does to find the one apple - * uses for the function key. - */ - static const uint16_t apple_pages[] = { - HUP_APPLE, /* HID_UP_CUSTOM in linux */ - HUP_MICROSOFT, /* HID_UP_MSVENDOR in linux */ - HUP_HP, /* HID_UP_HPVENDOR2 in linux */ - 0xFFFF /* Original FreeBSD check (Remove?) */ - }; - for (int i = 0; i < (int)nitems(apple_pages); i++) { - if (hid_locate(ptr, len, HID_USAGE2(apple_pages[i], 0x0003), - hid_input, 0, &sc->sc_loc_apple_fn, &flags, - &sc->sc_id_apple_fn)) { + if (sc->sc_vendor_id == USB_VENDOR_APPLE) { + if (hid_locate(ptr, len, + HID_USAGE2(HUP_CONSUMER, HUG_APPLE_EJECT), + hid_input, 0, &sc->sc_loc_apple_eject, &flags, + &sc->sc_id_apple_eject)) { if (flags & HIO_VARIABLE) - sc->sc_flags |= UKBD_FLAG_APPLE_FN; - DPRINTFN(1, "Found Apple FN-key on page 0x%04x\n", - apple_pages[i]); - break; + sc->sc_flags |= UKBD_FLAG_APPLE_EJECT; + DPRINTFN(1, "Found Apple eject-key\n"); + } + /* + * check the same vendor pages that linux does to find the one + * apple uses for the function key. + */ + static const uint16_t apple_pages[] = { + HUP_APPLE, /* HID_UP_CUSTOM in linux */ + HUP_MICROSOFT, /* HID_UP_MSVENDOR in linux */ + HUP_HP, /* HID_UP_HPVENDOR2 in linux */ + 0xFFFF /* Original FreeBSD check (Remove?) */ + }; + for (int i = 0; i < (int)nitems(apple_pages); i++) { + if (hid_locate(ptr, len, + HID_USAGE2(apple_pages[i], 0x0003), + hid_input, 0, &sc->sc_loc_apple_fn, &flags, + &sc->sc_id_apple_fn)) { + if (flags & HIO_VARIABLE) + sc->sc_flags |= UKBD_FLAG_APPLE_FN; + DPRINTFN(1, "Found Apple FN-key on page 0x%04x\n", + apple_pages[i]); + break; + } } } @@ -1208,6 +1212,7 @@ ukbd_attach(device_t dev) sc->sc_udev = uaa->device; sc->sc_iface = uaa->iface; + sc->sc_vendor_id = uaa->info.idVendor; sc->sc_iface_index = uaa->info.bIfaceIndex; sc->sc_iface_no = uaa->info.bIfaceNum; sc->sc_mode = K_XLATE; diff --git a/sys/modules/hid/hkbd/Makefile b/sys/modules/hid/hkbd/Makefile index 42b5d69dda9e..82f6599cca1d 100644 --- a/sys/modules/hid/hkbd/Makefile +++ b/sys/modules/hid/hkbd/Makefile @@ -3,6 +3,6 @@ KMOD= hkbd SRCS= hkbd.c SRCS+= opt_hid.h opt_evdev.h opt_kbd.h opt_hkbd.h -SRCS+= bus_if.h device_if.h +SRCS+= bus_if.h device_if.h usbdevs.h .include