Skip to content

Commit 3cf3b7f

Browse files
jwrdegoederafaeljw
authored andcommitted
ACPI: video: Fix Apple GMUX backlight detection
The apple-gmux driver only binds to old GMUX devices which have an IORESOURCE_IO resource (using inb()/outb()) rather then memory-mapped IO (IORESOURCE_MEM). T2 MacBooks use the new style GMUX devices (with IORESOURCE_MEM access), so these are not supported by the apple-gmux driver. This is not a problem since they have working ACPI video backlight support. But the apple_gmux_present() helper only checks if an ACPI device with the "APP000B" HID is present, causing acpi_video_get_backlight_type() to return acpi_backlight_apple_gmux disabling the acpi_video backlight device. Add a new apple_gmux_backlight_present() helper which checks that the "APP000B" device actually is an old GMUX device with an IORESOURCE_IO resource. This fixes the acpi_video0 backlight no longer registering on T2 MacBooks. Note people are working to add support for the new style GMUX to Linux: https://github.com/kekrby/linux-t2/commits/wip/hybrid-graphics Once this lands this patch should be reverted so that acpi_video_get_backlight_type() also prefers the gmux on new style GMUX MacBooks, but for now this is necessary to avoid regressing backlight control on T2 Macs. Fixes: 21245df ("ACPI: video: Add Apple GMUX brightness control detection") Reported-and-tested-by: Aditya Garg <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 5aa9d94 commit 3cf3b7f

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

drivers/acpi/video_detect.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <linux/module.h>
3535
#include <linux/pci.h>
3636
#include <linux/platform_data/x86/nvidia-wmi-ec-backlight.h>
37+
#include <linux/pnp.h>
3738
#include <linux/types.h>
3839
#include <linux/workqueue.h>
3940
#include <acpi/video.h>
@@ -105,6 +106,26 @@ static bool nvidia_wmi_ec_supported(void)
105106
}
106107
#endif
107108

109+
static bool apple_gmux_backlight_present(void)
110+
{
111+
struct acpi_device *adev;
112+
struct device *dev;
113+
114+
adev = acpi_dev_get_first_match_dev(GMUX_ACPI_HID, NULL, -1);
115+
if (!adev)
116+
return false;
117+
118+
dev = acpi_get_first_physical_node(adev);
119+
if (!dev)
120+
return false;
121+
122+
/*
123+
* drivers/platform/x86/apple-gmux.c only supports old style
124+
* Apple GMUX with an IO-resource.
125+
*/
126+
return pnp_get_resource(to_pnp_dev(dev), IORESOURCE_IO, 0) != NULL;
127+
}
128+
108129
/* Force to use vendor driver when the ACPI device is known to be
109130
* buggy */
110131
static int video_detect_force_vendor(const struct dmi_system_id *d)
@@ -767,7 +788,7 @@ static enum acpi_backlight_type __acpi_video_get_backlight_type(bool native)
767788
if (nvidia_wmi_ec_present)
768789
return acpi_backlight_nvidia_wmi_ec;
769790

770-
if (apple_gmux_present())
791+
if (apple_gmux_backlight_present())
771792
return acpi_backlight_apple_gmux;
772793

773794
/* Use ACPI video if available, except when native should be preferred. */

0 commit comments

Comments
 (0)