Skip to content

Commit c9797db

Browse files
committed
Merge tag 'acpi-6.3-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull ACPI fixes from Rafael Wysocki: "Fix the ACPI backlight override mechanism for the cases when acpi_backlight=video is set through the kernel command line or a DMI quirk and add backlight quirks for Apple iMac14,1 and iMac14,2 and Lenovo ThinkPad W530 (Hans de Goede)" * tag 'acpi-6.3-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: ACPI: video: Add acpi_backlight=video quirk for Lenovo ThinkPad W530 ACPI: video: Add acpi_backlight=video quirk for Apple iMac14,1 and iMac14,2 ACPI: video: Make acpi_backlight=video work independent from GPU driver ACPI: video: Add auto_detect arg to __acpi_video_get_backlight_type()
2 parents d523dc7 + a5b2781 commit c9797db

File tree

3 files changed

+71
-17
lines changed

3 files changed

+71
-17
lines changed

drivers/acpi/acpi_video.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,6 +1984,7 @@ static int instance;
19841984
static int acpi_video_bus_add(struct acpi_device *device)
19851985
{
19861986
struct acpi_video_bus *video;
1987+
bool auto_detect;
19871988
int error;
19881989
acpi_status status;
19891990

@@ -2045,10 +2046,20 @@ static int acpi_video_bus_add(struct acpi_device *device)
20452046
mutex_unlock(&video_list_lock);
20462047

20472048
/*
2048-
* The userspace visible backlight_device gets registered separately
2049-
* from acpi_video_register_backlight().
2049+
* If backlight-type auto-detection is used then a native backlight may
2050+
* show up later and this may change the result from video to native.
2051+
* Therefor normally the userspace visible /sys/class/backlight device
2052+
* gets registered separately by the GPU driver calling
2053+
* acpi_video_register_backlight() when an internal panel is detected.
2054+
* Register the backlight now when not using auto-detection, so that
2055+
* when the kernel cmdline or DMI-quirks are used the backlight will
2056+
* get registered even if acpi_video_register_backlight() is not called.
20502057
*/
20512058
acpi_video_run_bcl_for_osi(video);
2059+
if (__acpi_video_get_backlight_type(false, &auto_detect) == acpi_backlight_video &&
2060+
!auto_detect)
2061+
acpi_video_bus_register_backlight(video);
2062+
20522063
acpi_video_bus_add_notify_handler(video);
20532064

20542065
return 0;

drivers/acpi/video_detect.c

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,43 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
276276
},
277277
},
278278

279+
/*
280+
* Models which need acpi_video backlight control where the GPU drivers
281+
* do not call acpi_video_register_backlight() because no internal panel
282+
* is detected. Typically these are all-in-ones (monitors with builtin
283+
* PC) where the panel connection shows up as regular DP instead of eDP.
284+
*/
285+
{
286+
.callback = video_detect_force_video,
287+
/* Apple iMac14,1 */
288+
.matches = {
289+
DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
290+
DMI_MATCH(DMI_PRODUCT_NAME, "iMac14,1"),
291+
},
292+
},
293+
{
294+
.callback = video_detect_force_video,
295+
/* Apple iMac14,2 */
296+
.matches = {
297+
DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
298+
DMI_MATCH(DMI_PRODUCT_NAME, "iMac14,2"),
299+
},
300+
},
301+
302+
/*
303+
* Older models with nvidia GPU which need acpi_video backlight
304+
* control and where the old nvidia binary driver series does not
305+
* call acpi_video_register_backlight().
306+
*/
307+
{
308+
.callback = video_detect_force_video,
309+
/* ThinkPad W530 */
310+
.matches = {
311+
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
312+
DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad W530"),
313+
},
314+
},
315+
279316
/*
280317
* These models have a working acpi_video backlight control, and using
281318
* native backlight causes a regression where backlight does not work
@@ -782,7 +819,7 @@ static bool prefer_native_over_acpi_video(void)
782819
* Determine which type of backlight interface to use on this system,
783820
* First check cmdline, then dmi quirks, then do autodetect.
784821
*/
785-
static enum acpi_backlight_type __acpi_video_get_backlight_type(bool native)
822+
enum acpi_backlight_type __acpi_video_get_backlight_type(bool native, bool *auto_detect)
786823
{
787824
static DEFINE_MUTEX(init_mutex);
788825
static bool nvidia_wmi_ec_present;
@@ -807,6 +844,9 @@ static enum acpi_backlight_type __acpi_video_get_backlight_type(bool native)
807844
native_available = true;
808845
mutex_unlock(&init_mutex);
809846

847+
if (auto_detect)
848+
*auto_detect = false;
849+
810850
/*
811851
* The below heuristics / detection steps are in order of descending
812852
* presedence. The commandline takes presedence over anything else.
@@ -818,6 +858,9 @@ static enum acpi_backlight_type __acpi_video_get_backlight_type(bool native)
818858
if (acpi_backlight_dmi != acpi_backlight_undef)
819859
return acpi_backlight_dmi;
820860

861+
if (auto_detect)
862+
*auto_detect = true;
863+
821864
/* Special cases such as nvidia_wmi_ec and apple gmux. */
822865
if (nvidia_wmi_ec_present)
823866
return acpi_backlight_nvidia_wmi_ec;
@@ -837,15 +880,4 @@ static enum acpi_backlight_type __acpi_video_get_backlight_type(bool native)
837880
/* No ACPI video/native (old hw), use vendor specific fw methods. */
838881
return acpi_backlight_vendor;
839882
}
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);
883+
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)