Commit d2e68321 authored by Hans de Goede's avatar Hans de Goede

platform/x86: apple-gmux: Add acpi_video_get_backlight_type() check

Make apple-gmux backlight registration honor the acpi_backlight=...
kernel commandline option which is used to select the backlight
control method on x86/ACPI devices.
Reported-and-tested-by: default avatarAditya Garg <gargaditya08@live.com>
Link: https://lore.kernel.org/platform-driver-x86/BM1PR01MB0931B467250831916F7C55B3B8A59@BM1PR01MB0931.INDPRD01.PROD.OUTLOOK.COM/Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20230307113813.359743-1-hdegoede@redhat.com
parent f863fac1
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/vga_switcheroo.h> #include <linux/vga_switcheroo.h>
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include <acpi/video.h>
#include <asm/io.h> #include <asm/io.h>
/** /**
...@@ -781,8 +782,9 @@ static int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id) ...@@ -781,8 +782,9 @@ static int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
struct apple_gmux_data *gmux_data; struct apple_gmux_data *gmux_data;
struct resource *res; struct resource *res;
struct backlight_properties props; struct backlight_properties props;
struct backlight_device *bdev; struct backlight_device *bdev = NULL;
u8 ver_major, ver_minor, ver_release; u8 ver_major, ver_minor, ver_release;
bool register_bdev = true;
int ret = -ENXIO; int ret = -ENXIO;
acpi_status status; acpi_status status;
unsigned long long gpe; unsigned long long gpe;
...@@ -859,33 +861,38 @@ static int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id) ...@@ -859,33 +861,38 @@ static int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
props.type = BACKLIGHT_PLATFORM; props.type = BACKLIGHT_PLATFORM;
props.max_brightness = gmux_read32(gmux_data, GMUX_PORT_MAX_BRIGHTNESS); props.max_brightness = gmux_read32(gmux_data, GMUX_PORT_MAX_BRIGHTNESS);
/* #if IS_REACHABLE(CONFIG_ACPI_VIDEO)
* Currently it's assumed that the maximum brightness is less than register_bdev = acpi_video_get_backlight_type() == acpi_backlight_apple_gmux;
* 2^24 for compatibility with old gmux versions. Cap the max #endif
* brightness at this value, but print a warning if the hardware if (register_bdev) {
* reports something higher so that it can be fixed. /*
*/ * Currently it's assumed that the maximum brightness is less than
if (WARN_ON(props.max_brightness > GMUX_MAX_BRIGHTNESS)) * 2^24 for compatibility with old gmux versions. Cap the max
props.max_brightness = GMUX_MAX_BRIGHTNESS; * brightness at this value, but print a warning if the hardware
* reports something higher so that it can be fixed.
bdev = backlight_device_register("gmux_backlight", &pnp->dev, */
gmux_data, &gmux_bl_ops, &props); if (WARN_ON(props.max_brightness > GMUX_MAX_BRIGHTNESS))
if (IS_ERR(bdev)) { props.max_brightness = GMUX_MAX_BRIGHTNESS;
ret = PTR_ERR(bdev);
goto err_unmap; bdev = backlight_device_register("gmux_backlight", &pnp->dev,
} gmux_data, &gmux_bl_ops, &props);
if (IS_ERR(bdev)) {
gmux_data->bdev = bdev; ret = PTR_ERR(bdev);
bdev->props.brightness = gmux_get_brightness(bdev); goto err_unmap;
backlight_update_status(bdev); }
/* gmux_data->bdev = bdev;
* The backlight situation on Macs is complicated. If the gmux is bdev->props.brightness = gmux_get_brightness(bdev);
* present it's the best choice, because it always works for backlight_update_status(bdev);
* backlight control and supports more levels than other options.
* Disable the other backlight choices. /*
*/ * The backlight situation on Macs is complicated. If the gmux is
apple_bl_unregister(); * present it's the best choice, because it always works for
* backlight control and supports more levels than other options.
* Disable the other backlight choices.
*/
apple_bl_unregister();
}
gmux_data->power_state = VGA_SWITCHEROO_ON; gmux_data->power_state = VGA_SWITCHEROO_ON;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment