xref: /openbmc/linux/Documentation/firmware-guide/acpi/video_extension.rst (revision c39f2d9db0fd81ea20bb5cce9b3f082ca63753e2)
1*7fb091f8SChangbin Du.. SPDX-License-Identifier: GPL-2.0
2*7fb091f8SChangbin Du
3*7fb091f8SChangbin Du=====================
4*7fb091f8SChangbin DuACPI video extensions
5*7fb091f8SChangbin Du=====================
6*7fb091f8SChangbin Du
7*7fb091f8SChangbin DuThis driver implement the ACPI Extensions For Display Adapters for
8*7fb091f8SChangbin Duintegrated graphics devices on motherboard, as specified in ACPI 2.0
9*7fb091f8SChangbin DuSpecification, Appendix B, allowing to perform some basic control like
10*7fb091f8SChangbin Dudefining the video POST device, retrieving EDID information or to
11*7fb091f8SChangbin Dusetup a video output, etc.  Note that this is an ref. implementation
12*7fb091f8SChangbin Duonly.  It may or may not work for your integrated video device.
13*7fb091f8SChangbin Du
14*7fb091f8SChangbin DuThe ACPI video driver does 3 things regarding backlight control.
15*7fb091f8SChangbin Du
16*7fb091f8SChangbin DuExport a sysfs interface for user space to control backlight level
17*7fb091f8SChangbin Du==================================================================
18*7fb091f8SChangbin Du
19*7fb091f8SChangbin DuIf the ACPI table has a video device, and acpi_backlight=vendor kernel
20*7fb091f8SChangbin Ducommand line is not present, the driver will register a backlight device
21*7fb091f8SChangbin Duand set the required backlight operation structure for it for the sysfs
22*7fb091f8SChangbin Duinterface control. For every registered class device, there will be a
23*7fb091f8SChangbin Dudirectory named acpi_videoX under /sys/class/backlight.
24*7fb091f8SChangbin Du
25*7fb091f8SChangbin DuThe backlight sysfs interface has a standard definition here:
26*7fb091f8SChangbin DuDocumentation/ABI/stable/sysfs-class-backlight.
27*7fb091f8SChangbin Du
28*7fb091f8SChangbin DuAnd what ACPI video driver does is:
29*7fb091f8SChangbin Du
30*7fb091f8SChangbin Duactual_brightness:
31*7fb091f8SChangbin Du  on read, control method _BQC will be evaluated to
32*7fb091f8SChangbin Du  get the brightness level the firmware thinks it is at;
33*7fb091f8SChangbin Dubl_power:
34*7fb091f8SChangbin Du  not implemented, will set the current brightness instead;
35*7fb091f8SChangbin Dubrightness:
36*7fb091f8SChangbin Du  on write, control method _BCM will run to set the requested brightness level;
37*7fb091f8SChangbin Dumax_brightness:
38*7fb091f8SChangbin Du  Derived from the _BCL package(see below);
39*7fb091f8SChangbin Dutype:
40*7fb091f8SChangbin Du  firmware
41*7fb091f8SChangbin Du
42*7fb091f8SChangbin DuNote that ACPI video backlight driver will always use index for
43*7fb091f8SChangbin Dubrightness, actual_brightness and max_brightness. So if we have
44*7fb091f8SChangbin Duthe following _BCL package::
45*7fb091f8SChangbin Du
46*7fb091f8SChangbin Du	Method (_BCL, 0, NotSerialized)
47*7fb091f8SChangbin Du	{
48*7fb091f8SChangbin Du		Return (Package (0x0C)
49*7fb091f8SChangbin Du		{
50*7fb091f8SChangbin Du			0x64,
51*7fb091f8SChangbin Du			0x32,
52*7fb091f8SChangbin Du			0x0A,
53*7fb091f8SChangbin Du			0x14,
54*7fb091f8SChangbin Du			0x1E,
55*7fb091f8SChangbin Du			0x28,
56*7fb091f8SChangbin Du			0x32,
57*7fb091f8SChangbin Du			0x3C,
58*7fb091f8SChangbin Du			0x46,
59*7fb091f8SChangbin Du			0x50,
60*7fb091f8SChangbin Du			0x5A,
61*7fb091f8SChangbin Du			0x64
62*7fb091f8SChangbin Du		})
63*7fb091f8SChangbin Du	}
64*7fb091f8SChangbin Du
65*7fb091f8SChangbin DuThe first two levels are for when laptop are on AC or on battery and are
66*7fb091f8SChangbin Dunot used by Linux currently. The remaining 10 levels are supported levels
67*7fb091f8SChangbin Duthat we can choose from. The applicable index values are from 0 (that
68*7fb091f8SChangbin Ducorresponds to the 0x0A brightness value) to 9 (that corresponds to the
69*7fb091f8SChangbin Du0x64 brightness value) inclusive. Each of those index values is regarded
70*7fb091f8SChangbin Duas a "brightness level" indicator. Thus from the user space perspective
71*7fb091f8SChangbin Duthe range of available brightness levels is from 0 to 9 (max_brightness)
72*7fb091f8SChangbin Duinclusive.
73*7fb091f8SChangbin Du
74*7fb091f8SChangbin DuNotify user space about hotkey event
75*7fb091f8SChangbin Du====================================
76*7fb091f8SChangbin Du
77*7fb091f8SChangbin DuThere are generally two cases for hotkey event reporting:
78*7fb091f8SChangbin Du
79*7fb091f8SChangbin Dui) For some laptops, when user presses the hotkey, a scancode will be
80*7fb091f8SChangbin Du   generated and sent to user space through the input device created by
81*7fb091f8SChangbin Du   the keyboard driver as a key type input event, with proper remap, the
82*7fb091f8SChangbin Du   following key code will appear to user space::
83*7fb091f8SChangbin Du
84*7fb091f8SChangbin Du	EV_KEY, KEY_BRIGHTNESSUP
85*7fb091f8SChangbin Du	EV_KEY, KEY_BRIGHTNESSDOWN
86*7fb091f8SChangbin Du	etc.
87*7fb091f8SChangbin Du
88*7fb091f8SChangbin DuFor this case, ACPI video driver does not need to do anything(actually,
89*7fb091f8SChangbin Duit doesn't even know this happened).
90*7fb091f8SChangbin Du
91*7fb091f8SChangbin Duii) For some laptops, the press of the hotkey will not generate the
92*7fb091f8SChangbin Du    scancode, instead, firmware will notify the video device ACPI node
93*7fb091f8SChangbin Du    about the event. The event value is defined in the ACPI spec. ACPI
94*7fb091f8SChangbin Du    video driver will generate an key type input event according to the
95*7fb091f8SChangbin Du    notify value it received and send the event to user space through the
96*7fb091f8SChangbin Du    input device it created:
97*7fb091f8SChangbin Du
98*7fb091f8SChangbin Du	=====		==================
99*7fb091f8SChangbin Du	event		keycode
100*7fb091f8SChangbin Du	=====		==================
101*7fb091f8SChangbin Du	0x86		KEY_BRIGHTNESSUP
102*7fb091f8SChangbin Du	0x87		KEY_BRIGHTNESSDOWN
103*7fb091f8SChangbin Du	etc.
104*7fb091f8SChangbin Du	=====		==================
105*7fb091f8SChangbin Du
106*7fb091f8SChangbin Duso this would lead to the same effect as case i) now.
107*7fb091f8SChangbin Du
108*7fb091f8SChangbin DuOnce user space tool receives this event, it can modify the backlight
109*7fb091f8SChangbin Dulevel through the sysfs interface.
110*7fb091f8SChangbin Du
111*7fb091f8SChangbin DuChange backlight level in the kernel
112*7fb091f8SChangbin Du====================================
113*7fb091f8SChangbin Du
114*7fb091f8SChangbin DuThis works for machines covered by case ii) in Section 2. Once the driver
115*7fb091f8SChangbin Dureceived a notification, it will set the backlight level accordingly. This does
116*7fb091f8SChangbin Dunot affect the sending of event to user space, they are always sent to user
117*7fb091f8SChangbin Duspace regardless of whether or not the video module controls the backlight level
118*7fb091f8SChangbin Dudirectly. This behaviour can be controlled through the brightness_switch_enabled
119*7fb091f8SChangbin Dumodule parameter as documented in admin-guide/kernel-parameters.rst. It is
120*7fb091f8SChangbin Durecommended to disable this behaviour once a GUI environment starts up and
121*7fb091f8SChangbin Duwants to have full control of the backlight level.
122