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 <sean@starlabs.systems>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/90116
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
This commit is contained in:
Sean Rhodes 2025-11-19 09:23:18 +00:00
commit 23b00a06da

View file

@ -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)
}