Skip to content

Commit a5df425

Browse files
jwrdegoederafaeljw
authored andcommitted
ACPI: video: Simplify __acpi_video_get_backlight_type()
Simplify __acpi_video_get_backlight_type() removing a nested if which makes the flow harder to follow. This also results in having only 1 exit point with return acpi_backlight_native instead of 2. Note this drops the (video_caps & ACPI_VIDEO_BACKLIGHT) check from the if (acpi_osi_is_win8() && native_available) return native path. Windows 8's hardware certification requirements include that there must be ACPI video bus backlight control, so the ACPI_VIDEO_BACKLIGHT check is redundant. Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent f5a6ff9 commit a5df425

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

drivers/acpi/video_detect.c

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,16 @@ static bool google_cros_ec_present(void)
715715
return acpi_dev_found("GOOG0004") || acpi_dev_found("GOOG000C");
716716
}
717717

718+
/*
719+
* Windows 8 and newer no longer use the ACPI video interface, so it often
720+
* does not work. So on win8+ systems prefer native brightness control.
721+
* Chromebooks should always prefer native backlight control.
722+
*/
723+
static bool prefer_native_over_acpi_video(void)
724+
{
725+
return acpi_osi_is_win8() || google_cros_ec_present();
726+
}
727+
718728
/*
719729
* Determine which type of backlight interface to use on this system,
720730
* First check cmdline, then dmi quirks, then do autodetect.
@@ -760,26 +770,14 @@ static enum acpi_backlight_type __acpi_video_get_backlight_type(bool native)
760770
if (apple_gmux_present())
761771
return acpi_backlight_apple_gmux;
762772

763-
/* Chromebooks should always prefer native backlight control. */
764-
if (google_cros_ec_present() && native_available)
765-
return acpi_backlight_native;
773+
/* Use ACPI video if available, except when native should be preferred. */
774+
if ((video_caps & ACPI_VIDEO_BACKLIGHT) &&
775+
!(native_available && prefer_native_over_acpi_video()))
776+
return acpi_backlight_video;
766777

767-
/* On systems with ACPI video use either native or ACPI video. */
768-
if (video_caps & ACPI_VIDEO_BACKLIGHT) {
769-
/*
770-
* Windows 8 and newer no longer use the ACPI video interface,
771-
* so it often does not work. If the ACPI tables are written
772-
* for win8 and native brightness ctl is available, use that.
773-
*
774-
* The native check deliberately is inside the if acpi-video
775-
* block on older devices without acpi-video support native
776-
* is usually not the best choice.
777-
*/
778-
if (acpi_osi_is_win8() && native_available)
779-
return acpi_backlight_native;
780-
else
781-
return acpi_backlight_video;
782-
}
778+
/* Use native if available */
779+
if (native_available && prefer_native_over_acpi_video())
780+
return acpi_backlight_native;
783781

784782
/* No ACPI video (old hw), use vendor specific fw methods. */
785783
return acpi_backlight_vendor;

0 commit comments

Comments
 (0)