Skip to content

Commit 78dfc9d

Browse files
jwrdegoederafaeljw
authored andcommitted
ACPI: video: Add auto_detect arg to __acpi_video_get_backlight_type()
Allow callers of __acpi_video_get_backlight_type() to pass a pointer to a bool which will get set to false if the backlight-type comes from the cmdline or a DMI quirk and set to true if auto-detection was used. And make __acpi_video_get_backlight_type() non static so that it can be called directly outside of video_detect.c . While at it turn the acpi_video_get_backlight_type() and acpi_video_backlight_use_native() wrappers into static inline functions in include/acpi/video.h, so that we need to export one less symbol. Fixes: 5aa9d94 ("ACPI: video: Don't enable fallback path for creating ACPI backlight by default") Cc: All applicable <[email protected]> Reviewed-by: Mario Limonciello <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 7e364e5 commit 78dfc9d

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

drivers/acpi/video_detect.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ static bool prefer_native_over_acpi_video(void)
782782
* Determine which type of backlight interface to use on this system,
783783
* First check cmdline, then dmi quirks, then do autodetect.
784784
*/
785-
static enum acpi_backlight_type __acpi_video_get_backlight_type(bool native)
785+
enum acpi_backlight_type __acpi_video_get_backlight_type(bool native, bool *auto_detect)
786786
{
787787
static DEFINE_MUTEX(init_mutex);
788788
static bool nvidia_wmi_ec_present;
@@ -807,6 +807,9 @@ static enum acpi_backlight_type __acpi_video_get_backlight_type(bool native)
807807
native_available = true;
808808
mutex_unlock(&init_mutex);
809809

810+
if (auto_detect)
811+
*auto_detect = false;
812+
810813
/*
811814
* The below heuristics / detection steps are in order of descending
812815
* presedence. The commandline takes presedence over anything else.
@@ -818,6 +821,9 @@ static enum acpi_backlight_type __acpi_video_get_backlight_type(bool native)
818821
if (acpi_backlight_dmi != acpi_backlight_undef)
819822
return acpi_backlight_dmi;
820823

824+
if (auto_detect)
825+
*auto_detect = true;
826+
821827
/* Special cases such as nvidia_wmi_ec and apple gmux. */
822828
if (nvidia_wmi_ec_present)
823829
return acpi_backlight_nvidia_wmi_ec;
@@ -837,15 +843,4 @@ static enum acpi_backlight_type __acpi_video_get_backlight_type(bool native)
837843
/* No ACPI video/native (old hw), use vendor specific fw methods. */
838844
return acpi_backlight_vendor;
839845
}
840-
841-
enum acpi_backlight_type acpi_video_get_backlight_type(void)
842-
{
843-
return __acpi_video_get_backlight_type(false);
844-
}
845-
EXPORT_SYMBOL(acpi_video_get_backlight_type);
846-
847-
bool acpi_video_backlight_use_native(void)
848-
{
849-
return __acpi_video_get_backlight_type(true) == acpi_backlight_native;
850-
}
851-
EXPORT_SYMBOL(acpi_video_backlight_use_native);
846+
EXPORT_SYMBOL(__acpi_video_get_backlight_type);

include/acpi/video.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ extern void acpi_video_unregister(void);
5959
extern void acpi_video_register_backlight(void);
6060
extern int acpi_video_get_edid(struct acpi_device *device, int type,
6161
int device_id, void **edid);
62-
extern enum acpi_backlight_type acpi_video_get_backlight_type(void);
63-
extern bool acpi_video_backlight_use_native(void);
6462
/*
6563
* Note: The value returned by acpi_video_handles_brightness_key_presses()
6664
* may change over time and should not be cached.
@@ -69,6 +67,19 @@ extern bool acpi_video_handles_brightness_key_presses(void);
6967
extern int acpi_video_get_levels(struct acpi_device *device,
7068
struct acpi_video_device_brightness **dev_br,
7169
int *pmax_level);
70+
71+
extern enum acpi_backlight_type __acpi_video_get_backlight_type(bool native,
72+
bool *auto_detect);
73+
74+
static inline enum acpi_backlight_type acpi_video_get_backlight_type(void)
75+
{
76+
return __acpi_video_get_backlight_type(false, NULL);
77+
}
78+
79+
static inline bool acpi_video_backlight_use_native(void)
80+
{
81+
return __acpi_video_get_backlight_type(true, NULL) == acpi_backlight_native;
82+
}
7283
#else
7384
static inline void acpi_video_report_nolcd(void) { return; };
7485
static inline int acpi_video_register(void) { return -ENODEV; }

0 commit comments

Comments
 (0)