ACPI: video: Add acpi_video_backlight_use_native() helper
authorHans de Goede <hdegoede@redhat.com>
Fri, 15 Apr 2022 11:59:48 +0000 (13:59 +0200)
committerHans de Goede <hdegoede@redhat.com>
Wed, 17 Aug 2022 10:30:05 +0000 (12:30 +0200)
commit2600bfa3df9944562d43d1f17016832a6ffa3b38
tree5206d8cc6ea54884b7b434d1c395349c0b34d6d3
parent568035b01cfb107af8d2e4bd2fb9aea22cf5b868
ACPI: video: Add acpi_video_backlight_use_native() helper

ATM on x86 laptops where we want userspace to use the acpi_video backlight
device we often register both the GPU's native backlight device and
acpi_video's firmware acpi_video# backlight device. This relies on
userspace preferring firmware type backlight devices over native ones, but
registering 2 backlight devices for a single display really is undesirable.

On x86 laptops where the native GPU backlight device should be used,
the registering of other backlight devices is avoided by their drivers
using acpi_video_get_backlight_type() and only registering their backlight
if the return value matches their type.

acpi_video_get_backlight_type() uses
backlight_device_get_by_type(BACKLIGHT_RAW) to determine if a native
driver is available and will never return native if this returns
false. This means that the GPU's native backlight registering code
cannot just call acpi_video_get_backlight_type() to determine if it
should register its backlight, since acpi_video_get_backlight_type() will
never return native until the native backlight has already registered.

To fix this add a new internal native function parameter to
acpi_video_get_backlight_type(), which when set to true will make
acpi_video_get_backlight_type() behave as if a native backlight has
already been registered.

And add a new acpi_video_backlight_use_native() helper, which sets this
to true, for use in native GPU backlight code.

Changes in v2:
- Replace adding a native parameter to acpi_video_get_backlight_type() with
  adding a new acpi_video_backlight_use_native() helper.

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/acpi/video_detect.c
include/acpi/video.h