From nobody Tue Dec 24 02:13:22 2024 X-Original-To: dev-commits-src-main@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 4YHJMk3lc7z5hpWj; Tue, 24 Dec 2024 02:13:22 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YHJMk390Dz4q7n; Tue, 24 Dec 2024 02:13:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1735006402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+2wQR4ZG8uSX6iOodQWp4K+i+oq4b0iLR3fjzNM5Is4=; b=Kgq3XE5aiYb2QPBJVJsrIKAgRDS1d0io6Ry4E08ei5+J04mcpjbQE3pQgxpLBqsQKi2PUr HSTsr3dH9okCIdkpryEhCaef8Uuv4BnDvnseJkhHp2srgXk7MfYSh4+LIi15ko2t9rqZ6H KJvcZaxmQtpiHDi0neIwIc+TMIavOPZoOuZTF1Vxz6YHVRly0aHmnJUzuuwbDmSPkZhwOK f3ODdhvDSgasQF5S/3h389hGJvAEd56k3rUATl2Aa8HPLlXWmeANg0n/82jnH/p0WYViSz qkJNyBqVZXuPqa/ANIV9mM7rBvVhqQQcC2mzDTXgERCK1m8fhJaXt4aP9MeLEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1735006402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+2wQR4ZG8uSX6iOodQWp4K+i+oq4b0iLR3fjzNM5Is4=; b=DQI1IT5tqMdbX/NrcEOr38r8OomUTCIpfUJvPtTDL90WbiK1RfIPLr3hYWVxIYmNtIGrN/ LoY7CWLBRoFGwjztXBNMsndDvVBFRcTgJfO8Yq0NJtLasksPtNW/WIwrxevMEej4yQDwcQ 4kGxF9D6lvXMea6acL2vmlvbNdSaaGXDioRY5cj4Fira6q4epIwQ8BCzYTewoUD/RBkeW/ RGLFIUW1QC9pjr3u1d407KQwklSYXRPeJeziCAGnEOlb/l4jG58CAFfzBOq/jNmTyBOv41 E64X24UEu+bAOOogBkL8DUk/pScbux27Psbfz5hw/rXBV9eba8/kbaTwL1Ohjg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1735006402; a=rsa-sha256; cv=none; b=D0lsfZM7eYrHebxms94mBs/Iw6/U29gaQsC71sZRTPXrPVDdpMHMIkvpMv+rMY6KEceaG6 Car/SdTerRQ+0kWuQT7JzMeremjvpdJFLYnyjhT1jBRkf9n6R1H4b8pWCuNl0qLif1KpwT 5I2yH3XZchAsudVlT1L1OcYo+I4yQlbz9MkG3XbgDwtPORqhYM9QUe3gYXmIOFpmG41jN8 1aN0T2jptUhrjBH/nc+jM8qpEIx8WJ10kni4jkkdHq6XLU836McXgozknhHqjwa6B5F832 b9VabRkDvShb31/3uyxecAEF6mWZx7hGGn0i2jdOl7aekmaBgYD8T65a6JEdRg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4YHJMk2mJLzJhL; Tue, 24 Dec 2024 02:13:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4BO2DMhA087870; Tue, 24 Dec 2024 02:13:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BO2DMLE087867; Tue, 24 Dec 2024 02:13:22 GMT (envelope-from git) Date: Tue, 24 Dec 2024 02:13:22 GMT Message-Id: <202412240213.4BO2DMLE087867@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: c21f5751ef09 - main - acpi_ibm: pass brightness events to evdev(4) List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c21f5751ef0932796676e55953461e0679020e28 Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=c21f5751ef0932796676e55953461e0679020e28 commit c21f5751ef0932796676e55953461e0679020e28 Author: Gleb Smirnoff AuthorDate: 2024-12-24 02:10:56 +0000 Commit: Gleb Smirnoff CommitDate: 2024-12-24 02:10:56 +0000 acpi_ibm: pass brightness events to evdev(4) unless the dev.acpi_ibm.0.handlerevents sysctl is set to process them internally. The default for the latter is to ignore them, so passing to evdev(4) is enabled by default. Reviewed by: wulf, imp Tested on: Lenovo Thinpad X11 Carbon 7Th Gen Differential Revision: https://reviews.freebsd.org/D48174 --- sys/dev/acpi_support/acpi_ibm.c | 43 ++++++++++++++++++++++++++++++++++++++ sys/modules/acpi/acpi_ibm/Makefile | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/sys/dev/acpi_support/acpi_ibm.c b/sys/dev/acpi_support/acpi_ibm.c index a617088d4246..c1302508b8a2 100644 --- a/sys/dev/acpi_support/acpi_ibm.c +++ b/sys/dev/acpi_support/acpi_ibm.c @@ -37,6 +37,7 @@ */ #include "opt_acpi.h" +#include "opt_evdev.h" #include #include #include @@ -55,6 +56,11 @@ #include #include +#ifdef EVDEV_SUPPORT +#include +#include +#endif + #define _COMPONENT ACPI_OEM ACPI_MODULE_NAME("IBM") @@ -198,6 +204,9 @@ struct acpi_ibm_softc { struct sysctl_ctx_list *sysctl_ctx; struct sysctl_oid *sysctl_tree; +#ifdef EVDEV_SUPPORT + struct evdev_dev *evdev; +#endif }; static struct { @@ -363,6 +372,9 @@ static driver_t acpi_ibm_driver = { DRIVER_MODULE(acpi_ibm, acpi, acpi_ibm_driver, 0, 0); MODULE_DEPEND(acpi_ibm, acpi, 1, 1, 1); +#ifdef EVDEV_SUPPORT +MODULE_DEPEND(acpi_ibm, evdev, 1, 1, 1); +#endif static char *ibm_ids[] = {"IBM0068", "LEN0068", "LEN0268", NULL}; static int @@ -482,6 +494,20 @@ acpi_ibm_attach(device_t dev) } sc->ec_handle = acpi_get_handle(sc->ec_dev); +#ifdef EVDEV_SUPPORT + sc->evdev = evdev_alloc(); + evdev_set_name(sc->evdev, device_get_desc(dev)); + evdev_set_phys(sc->evdev, device_get_nameunit(dev)); + evdev_set_id(sc->evdev, BUS_HOST, 0, 0, 1); + evdev_support_event(sc->evdev, EV_SYN); + evdev_support_event(sc->evdev, EV_KEY); + evdev_support_key(sc->evdev, KEY_BRIGHTNESSUP); + evdev_support_key(sc->evdev, KEY_BRIGHTNESSDOWN); + + if (evdev_register(sc->evdev) != 0) + return (ENXIO); +#endif + /* Get the sysctl tree */ sc->sysctl_ctx = device_get_sysctl_ctx(dev); sc->sysctl_tree = device_get_sysctl_tree(dev); @@ -627,6 +653,10 @@ acpi_ibm_detach(device_t dev) if (sc->led_dev != NULL) led_destroy(sc->led_dev); +#ifdef EVDEV_SUPPORT + evdev_free(sc->evdev); +#endif + return (0); } @@ -1499,6 +1529,19 @@ acpi_ibm_notify(ACPI_HANDLE h, UINT32 notify, void *context) /* Execute event handler */ if (sc->handler_events & (1 << (arg - 1))) acpi_ibm_eventhandler(sc, (arg & 0xff)); +#ifdef EVDEV_SUPPORT + else if ((arg & 0xff) == IBM_EVENT_BRIGHTNESS_UP || + (arg & 0xff) == IBM_EVENT_BRIGHTNESS_DOWN) { + uint16_t key; + + key = arg == IBM_EVENT_BRIGHTNESS_UP ? + KEY_BRIGHTNESSUP : KEY_BRIGHTNESSDOWN; + evdev_push_key(sc->evdev, key, 1); + evdev_sync(sc->evdev); + evdev_push_key(sc->evdev, key, 0); + evdev_sync(sc->evdev); + } +#endif /* Notify devd(8) */ acpi_UserNotify("IBM", h, (arg & 0xff)); diff --git a/sys/modules/acpi/acpi_ibm/Makefile b/sys/modules/acpi/acpi_ibm/Makefile index ac7428ac4524..40ef83d6e78c 100644 --- a/sys/modules/acpi/acpi_ibm/Makefile +++ b/sys/modules/acpi/acpi_ibm/Makefile @@ -1,6 +1,6 @@ .PATH: ${SRCTOP}/sys/dev/acpi_support KMOD= acpi_ibm SRCS= acpi_ibm.c opt_acpi.h device_if.h bus_if.h acpi_if.h -SRCS+= opt_ddb.h +SRCS+= opt_ddb.h opt_evdev.h .include