git: c21f5751ef09 - main - acpi_ibm: pass brightness events to evdev(4)
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 24 Dec 2024 02:13:22 UTC
The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=c21f5751ef0932796676e55953461e0679020e28 commit c21f5751ef0932796676e55953461e0679020e28 Author: Gleb Smirnoff <glebius@FreeBSD.org> AuthorDate: 2024-12-24 02:10:56 +0000 Commit: Gleb Smirnoff <glebius@FreeBSD.org> 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 <sys/param.h> #include <sys/systm.h> #include <sys/kernel.h> @@ -55,6 +56,11 @@ #include <sys/sysctl.h> #include <isa/rtc.h> +#ifdef EVDEV_SUPPORT +#include <dev/evdev/input.h> +#include <dev/evdev/evdev.h> +#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 <bsd.kmod.mk>