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