diff options
author | Nico Huber <nico.h@gmx.de> | 2018-08-23 22:14:01 +0200 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2018-09-14 20:20:22 +0000 |
commit | f26a7c76873b9a647d338370a2adf706f8b3f705 (patch) | |
tree | 9e5ca7dc82d83257267a39eac23eb186ffbb8556 /src/drivers/intel/gma | |
parent | 6b0102db76ce99796a96d2db77a3e712135e8fac (diff) |
drivers/intel/gma: Do not rely on CBLV in OpRegion Mailbox3
CBLV is not kept up to date by Linux' i915. We should fix that too,
but it will likely take some years until we can always expect it to
work.
For now read the register values directly. To accomodate that we
are not the only one writing those, revise XBQC() to search for
the closest value in BRIG (instead of a lower equal one) and round
more accurately for better matches.
Change-Id: I4e2d8fa34e75463d4cf7242af3e2c67577cfa2a5
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/28301
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
Diffstat (limited to 'src/drivers/intel/gma')
-rw-r--r-- | src/drivers/intel/gma/acpi/configure_brightness_levels.asl | 87 |
1 files changed, 36 insertions, 51 deletions
diff --git a/src/drivers/intel/gma/acpi/configure_brightness_levels.asl b/src/drivers/intel/gma/acpi/configure_brightness_levels.asl index 01642ddc6b..dfd878cb26 100644 --- a/src/drivers/intel/gma/acpi/configure_brightness_levels.asl +++ b/src/drivers/intel/gma/acpi/configure_brightness_levels.asl @@ -98,36 +98,6 @@ Return (Ones) } - - /* - * Get current back-light brightness through mailbox 3 - * - * @Return The current brightness or Ones on error - * Errors: * ASLS is zero - * * Mailbox 3 support not advertised - * * Driver not loaded or not ready - * * CBLV is not marked valid - */ - Method (XBQC, 0, NotSerialized) - { - If (LEqual(ASLS, Zero)) - { - Return (Ones) - } - If (LEqual(And(MBOX, 0x4), Zero)) - { - Return (Ones) - } - If (LEqual(ARDY, Zero)) - { - Return (Ones) - } - If (LEqual(And (CBLV, 0x80000000), Zero)) - { - Return (Ones) - } - Return (And (CBLV, 0xff)) - } } /* @@ -137,29 +107,45 @@ { Name (_ADR, 0) + /* Divide round closest */ + Method (DRCL, 2) + { + Return (Divide (Add (Arg0, Divide (Arg1, 2)), Arg1)) + } + Method (XBCM, 1, NotSerialized) { - Store (Divide (Multiply (Arg0, BCLM), 100), BCLV) + Store (DRCL (Multiply (Arg0, BCLM), 100), BCLV) } + /* Find value closest to BCLV in BRIG (which must be ordered) */ Method (XBQC, 0, NotSerialized) { - /* Find value close to BCLV in BRIG (which must be ordered) */ - Store (BCLV, Local0) // Current value - Store (BCLM, Local1) // For calculations - Store (2, Local2) // Loop index - While (LLess (Local2, Subtract (SizeOf (BRIG), 1))) { - Store (DeRefOf (Index (BRIG, Local2)), Local3) - /* Use same calculation as XBCM, to get exact matches */ - Store (Divide (Multiply (Local3, Local1), 100), Local3) - - If (LLessEqual (Local0, Local3)) { - Return (DeRefOf (Index (BRIG, Local2))) + /* Local0: current percentage */ + Store (DRCL (Multiply (BCLV, 100), BCLM), Local0) + + /* Local1: loop index (selectable values start at 2 in BRIG) */ + Store (2, Local1) + While (LLess (Local1, Subtract (SizeOf (BRIG), 1))) { + /* Local[23]: adjacent values in BRIG */ + Store (DeRefOf (Index (BRIG, Local1)), Local2) + Store (DeRefOf (Index (BRIG, Add (Local1, 1))), Local3) + + If (LLess (Local0, Local3)) { + If (LOr (LLess (Local0, Local2), + LLess (Subtract (Local0, Local2), + Subtract (Local3, Local0)))) { + Return (Local2) + } Else { + Return (Local3) + } } - Add (Local2, 1, Local2) + + Increment (Local1) } + /* Didn't find greater/equal value: use the last */ - Return (DeRefOf (Index (BRIG, Local2))) + Return (Local3) } } @@ -173,11 +159,10 @@ Method (XBQC, 0, NotSerialized) { - Store (^BOX3.XBQC (), Local0) - If (LEqual(Local0, Ones)) - { - Store (^LEGA.XBQC (), Local0) - } - - Return (Local0) + /* + * Always query the hardware directly. Not all OS drivers + * keep CBLV up to date (one is Linux' i915). Some years + * after that is fixed we can probably use CBLV? + */ + Return (^LEGA.XBQC ()) } |