From 23b00a06da929f487743bad96ec905e9f0e9285d Mon Sep 17 00:00:00 2001 From: Sean Rhodes Date: Wed, 19 Nov 2025 09:23:18 +0000 Subject: [PATCH] drivers/intel/gma: Fix brightness handling with valid-cache logic The existing brightness level fallback logic duplicated the default backlight value by hardcoding BRLV to 100% (0x64). This caused divergence whenever a platform defined a different default brightness through BRIG[0]. This change removes the duplicated default and replaces it with a cached brightness mechanism using BRVA (valid flag) and BRLV (cached level). The firmware now: - Caches the last brightness level exposed to the OS. - Uses the cached level during early boot/resume when the OpRegion (BCLM/BCLV) is not yet initialized. - Falls back to BRIG[0] only when no cached brightness exists. - Preserves the existing replay-detection logic to keep firmware and OS brightness state aligned once the graphics driver is active. This ensures consistent brightness reporting, avoids incorrect 0% fallback values, and respects board-specific BRIG defaults. No functional changes occur once the graphics driver has initialized the OpRegion; the improvement only affects early boot/resume behavior and eliminates duplicated platform policy. Change-Id: I651dfd30aa0c283b4e0659e5d19051e1b58204fe Signed-off-by: Sean Rhodes Reviewed-on: https://review.coreboot.org/c/coreboot/+/90116 Tested-by: build bot (Jenkins) Reviewed-by: Matt DeVillier --- .../gma/acpi/configure_brightness_levels.asl | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/drivers/intel/gma/acpi/configure_brightness_levels.asl b/src/drivers/intel/gma/acpi/configure_brightness_levels.asl index 9fb30f0039..11a7dd7725 100644 --- a/src/drivers/intel/gma/acpi/configure_brightness_levels.asl +++ b/src/drivers/intel/gma/acpi/configure_brightness_levels.asl @@ -1,6 +1,8 @@ /* SPDX-License-Identifier: GPL-2.0-only */ - Name (BRLV, 100) + Name (BRLV, 0) /* Brightness Last Value */ + Name (BRVA, 0) /* Brightness Valid */ + /* * Pseudo device that contains methods to modify Opregion * "Mailbox 3 BIOS to Driver Notification" @@ -149,6 +151,7 @@ Method (XBCM, 1, NotSerialized) { BRLV = Arg0 + BRVA = 1 If (^BOX3.XBCM (Arg0) == Ones) { /* @@ -167,16 +170,21 @@ /* * During early boot / resume the IGD driver has not yet populated * the OpRegion brightness fields (BCLM stays zero), so fall back to - * the cached value we last exposed to the OS. + * the cached value we last exposed to the OS. If there's no cached + * value yet, use the platform's default from BRIG[0]. */ - If (BCLM == 0) - { - Return (BRLV) + If (BCLM == 0) { + If (BRVA != 0) { + Return (BRLV) + } + + /* No cached brightness yet, fall back to platform default. */ + Local0 = DeRefOf (BRIG[0]) + Return (Local0) } Local0 = ^LEGA.XBQC () - If (Local0 != BRLV) - { + If (BRVA != 0 && Local0 != BRLV) { /* * The OS replays _BCM requests while the graphics driver is * still reinitializing, so hardware brightness can diverge @@ -193,5 +201,6 @@ } } BRLV = Local0 + BRVA = 1 Return (Local0) }