git: 030e556ff8a9 - main - acpi_lid: add an in-kernel lid state eventhandler
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 13 Oct 2026 18:44:13 UTC
The branch main has been updated by seuros:
URL: https://cgit.FreeBSD.org/src/commit/?id=030e556ff8a9dfa6fd7b5328e410eb806f4d07ed
commit 030e556ff8a9dfa6fd7b5328e410eb806f4d07ed
Author: Abdelkader Boudih <seuros@FreeBSD.org>
AuthorDate: 2026-10-13 18:43:56 +0000
Commit: Abdelkader Boudih <seuros@FreeBSD.org>
CommitDate: 2026-10-13 18:43:56 +0000
acpi_lid: add an in-kernel lid state eventhandler
Lid state changes are only published to userland, via devd and evdev.
Drivers that need to react to the lid in the kernel have no hook, so
they end up installing a second ACPI_DEVICE_NOTIFY handler on the same
lid object and reimplementing the _LID evaluation.
Add acpi_lid_event, invoked from acpi_lid_status_update() alongside the
existing devd notification, carrying the new state (1 open, 0 closed).
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D60704
---
sys/dev/acpica/acpi_lid.c | 3 +++
sys/dev/acpica/acpivar.h | 5 +++++
2 files changed, 8 insertions(+)
diff --git a/sys/dev/acpica/acpi_lid.c b/sys/dev/acpica/acpi_lid.c
index 1d5249a19731..fb06a57d8e5e 100644
--- a/sys/dev/acpica/acpi_lid.c
+++ b/sys/dev/acpica/acpi_lid.c
@@ -117,6 +117,9 @@ acpi_lid_status_update(struct acpi_lid_softc *sc)
/* Send notification via devd */
acpi_UserNotify("Lid", sc->lid_handle, sc->lid_status);
+ /* Notify in-kernel consumers */
+ EVENTHANDLER_INVOKE(acpi_lid_event, sc->lid_status);
+
#ifdef EVDEV_SUPPORT
/* Notify evdev about lid status */
evdev_push_sw(sc->lid_evdev, SW_LID, lid_status ? 0 : 1);
diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h
index 2a2c4bcb0a7c..7ff8bd711e57 100644
--- a/sys/dev/acpica/acpivar.h
+++ b/sys/dev/acpica/acpivar.h
@@ -456,6 +456,11 @@ EVENTHANDLER_DECLARE(acpi_video_event, acpi_event_handler_t);
EVENTHANDLER_DECLARE(acpi_post_dev_suspend, acpi_event_handler_t);
EVENTHANDLER_DECLARE(acpi_pre_dev_resume, acpi_event_handler_t);
+/* Lid state changes. The int argument is 1 for open, 0 for closed. */
+typedef void (*acpi_lid_event_handler_t)(void *, int);
+
+EVENTHANDLER_DECLARE(acpi_lid_event, acpi_lid_event_handler_t);
+
void acpi_invoke_sleep_eventhandler(const enum power_stype *stype);
void acpi_invoke_wake_eventhandler(const enum power_stype *stype);