Skip to content

Commit 0e51cb4

Browse files
Redecoratingjwrdegoede
authored andcommitted
apple-gmux: Hard Code max brightness for MMIO gmux
The data in the max brightness port for iMacs with MMIO gmux incorrectly reports 0x03ff, but it should be 0xffff. As all other MMIO gmux models have 0xffff, hard code this for all MMIO gmux's so they all have the proper brightness range accessible. Fixes: 0c18184 ("platform/x86: apple-gmux: support MMIO gmux on T2 Macs") Reported-by: Karsten Leipold <[email protected]> Signed-off-by: Orlando Chamberlain <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Hans de Goede <[email protected]>
1 parent fe0e04c commit 0e51cb4

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

drivers/platform/x86/apple-gmux.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ struct apple_gmux_config {
105105
#define GMUX_BRIGHTNESS_MASK 0x00ffffff
106106
#define GMUX_MAX_BRIGHTNESS GMUX_BRIGHTNESS_MASK
107107

108+
# define MMIO_GMUX_MAX_BRIGHTNESS 0xffff
109+
108110
static u8 gmux_pio_read8(struct apple_gmux_data *gmux_data, int port)
109111
{
110112
return inb(gmux_data->iostart + port);
@@ -857,7 +859,17 @@ static int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
857859

858860
memset(&props, 0, sizeof(props));
859861
props.type = BACKLIGHT_PLATFORM;
860-
props.max_brightness = gmux_read32(gmux_data, GMUX_PORT_MAX_BRIGHTNESS);
862+
863+
/*
864+
* All MMIO gmux's have 0xffff as max brightness, but some iMacs incorrectly
865+
* report 0x03ff, despite the firmware being happy to set 0xffff as the brightness
866+
* at boot. Force 0xffff for all MMIO gmux's so they all have the correct brightness
867+
* range.
868+
*/
869+
if (type == APPLE_GMUX_TYPE_MMIO)
870+
props.max_brightness = MMIO_GMUX_MAX_BRIGHTNESS;
871+
else
872+
props.max_brightness = gmux_read32(gmux_data, GMUX_PORT_MAX_BRIGHTNESS);
861873

862874
#if IS_REACHABLE(CONFIG_ACPI_VIDEO)
863875
register_bdev = acpi_video_get_backlight_type() == acpi_backlight_apple_gmux;

0 commit comments

Comments
 (0)