Friday, June 14, 2013

ACPI Brightness Control (1) - Control Methods

All laptops today come with hotkeys to adjust panel's brightness. This blog aims to discuss how to control brightness from BIOS's perspectives.

ACPI Control Methods


ACPI Appendix B.5 (Output Device-specific Methods) defines three control methods for brightness.
  • _BCL – Query List of Brightness Control Levels Supported
  • _BCM – Set the Brightness Level
  • _BQC – Brightness Query Current level
Figure 1 - Interaction between OS, BIOS and Hardware
As in Figure 1, OS queries the list of supported brightness levels from _BCL when it starts (1). This list can be used in UI or by OS kernel when it intends to adjust the brightness. OS also read current brightness from _BQC (2). Together with (1), OS can display how brightness the LCD is in a slider or in a OSD to users.

When a user want to adjust the brightness via a slider or hotkeys (more in next blog), OS will call _BCM which calls to EC or to VGA that eventually changes the panel brightness. However, it is worthwhile to note whether to call _BCM is OS- and driver-dependent. At the time of writing, Windows 8 does not call _BCM and Windows 7 may or may not call _BCM depending on VGA, while normal Linux distribution always uses _BCM. A separate blog will discuss how Ubuntu Linux controls brightness.

Sample Code and Common Errors


_BCL


Method (_BCL, 0) {
     // List of supported brightness levels
     Return (Package(7){
          80, // level when machine has full power
          50, // level when machine is on batteries
          20, 40, 60, 80, 100 // other supported levels:
          }
}


The above is an example of _BCL in ACPI. One of the most common errors is the first two elements are left-out. Meaning OS no longer knows what brightness levels should be used when the AC adapter is plugged and unplugged.

_BCM


Method (_BCM, 1) {
     Store (Arg0, \_SB.PCI0.LPC.EC.BRLV)
}

The above is a very simple _BCM implementation. It simply passes the brightness level, from OS, to an EC registers (assuming brightness is controlled by EC). Please note Arg0 will be one of the values in _BCL such as 20, 40, 60 and so on in the _BCL example.

Common errors of _BCM are:
  • _BCM is present but it does not control brightness
    • Some Windows VGA drivers do not use _BCM; however, Linux requires _BCM to work correctly.
  • Lowest brightness level blacks out the screen
    • This may or may not be a bug depending on OEMs.

_BQC


Method (_BQC, 0) {
     Return (\_SB.PCI0.LPC.EC.BRLV)
}

The above example simply returns brightness set from _BCM in the above example.

Common errors of _BQC are:
  • _BQC is not implemented in BIOS AML
  • _BQC returns value not in _BCL
    • _BQC needs to report the value of the brightness, the order of the brightness.
  • _BQC returns zero at boot time

No comments:

Post a Comment