git: 09a79e9eb4d9 - main - acpi_video: fall back to _BCL when _DOD matches no output

From: Abdelkader Boudih <seuros_at_FreeBSD.org>
Date: Tue, 10 Nov 2026 19:22:52 UTC
The branch main has been updated by seuros:

URL: https://cgit.FreeBSD.org/src/commit/?id=09a79e9eb4d902e31f699fe5bd634c00138586e0

commit 09a79e9eb4d902e31f699fe5bd634c00138586e0
Author:     Abdelkader Boudih <seuros@FreeBSD.org>
AuthorDate: 2026-11-10 19:22:27 +0000
Commit:     Abdelkader Boudih <seuros@FreeBSD.org>
CommitDate: 2026-11-10 19:22:27 +0000

    acpi_video: fall back to _BCL when _DOD matches no output
    
    vid_enum_outputs() only registers a child whose _ADR appears in the
    graphics controller's _DOD. _DOD is filled in from the graphics driver's
    ACPI opregion on some platforms, so with no such driver attached it can
    describe no device at all while the panel still implements _BCL, _BCM and
    _BQC. The match then fails for every child and the machine is left with
    no brightness control.
    
    Fall back to registering the first child that implements _BCL when _DOD
    matched nothing, so such a machine gets a working
    hw.acpi.video.lcd0.brightness and the brightness keys that ride on it.
    
    MFC after: 1 week
    
    Reviewed by:    adrian
    Differential Revision:  https://reviews.freebsd.org/D60826
---
 sys/dev/acpica/acpi_video.c | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/sys/dev/acpica/acpi_video.c b/sys/dev/acpica/acpi_video.c
index f949e14f58e6..c0fb918640ff 100644
--- a/sys/dev/acpica/acpi_video.c
+++ b/sys/dev/acpica/acpi_video.c
@@ -1007,6 +1007,7 @@ struct enum_callback_arg {
 	void *context;
 	ACPI_OBJECT *dod_pkg;
 	int count;
+	bool panel_fallback;
 };
 
 static ACPI_STATUS
@@ -1016,7 +1017,6 @@ vid_enum_outputs_subr(ACPI_HANDLE handle, UINT32 level __unused,
 	ACPI_STATUS status;
 	UINT32 adr, val;
 	struct enum_callback_arg *argset;
-	size_t i;
 
 	ACPI_SERIAL_ASSERT(video);
 	argset = context;
@@ -1024,7 +1024,20 @@ vid_enum_outputs_subr(ACPI_HANDLE handle, UINT32 level __unused,
 	if (ACPI_FAILURE(status))
 		return (AE_OK);
 
-	for (i = 0; i < argset->dod_pkg->Package.Count; i++) {
+	if (argset->panel_fallback) {
+		ACPI_HANDLE bcl_handle;
+
+		if (argset->count > 0 ||
+		    ACPI_FAILURE(AcpiGetHandle(handle, "_BCL", &bcl_handle)))
+			return (AE_OK);
+		argset->callback(handle,
+		    DOD_DEVID_INTDFP | (adr & DOD_DEVID_MASK_DISPIDX),
+		    argset->context);
+		argset->count++;
+		return (AE_OK);
+	}
+
+	for (size_t i = 0; i < argset->dod_pkg->Package.Count; i++) {
 		if (acpi_PkgInt32(argset->dod_pkg, i, &val) == 0 &&
 		    (val & DOD_DEVID_MASK_FULL) ==
 		    (adr & DOD_DEVID_MASK_FULL)) {
@@ -1071,11 +1084,20 @@ vid_enum_outputs(ACPI_HANDLE handle,
 	argset.context  = context;
 	argset.dod_pkg  = res;
 	argset.count    = 0;
+	argset.panel_fallback = false;
 	status = AcpiWalkNamespace(ACPI_TYPE_DEVICE, handle, 1,
 	    vid_enum_outputs_subr, NULL, &argset, NULL);
+	if (ACPI_SUCCESS(status) && argset.count == 0) {
+		argset.panel_fallback = true;
+		status = AcpiWalkNamespace(ACPI_TYPE_DEVICE, handle, 1,
+		    vid_enum_outputs_subr, NULL, &argset, NULL);
+		if (ACPI_SUCCESS(status) && argset.count > 0 && bootverbose)
+			printf("%s._DOD matches no output, using _BCL\n",
+			    acpi_name(handle));
+	}
 	if (ACPI_FAILURE(status))
 		printf("failed walking down %s - %s\n",
-		       acpi_name(handle), AcpiFormatException(status));
+		    acpi_name(handle), AcpiFormatException(status));
 out:
 	if (dod_buf.Pointer != NULL)
 		AcpiOsFree(dod_buf.Pointer);