Commit 0e51cb42 authored by Orlando Chamberlain's avatar Orlando Chamberlain Committed by Hans de Goede
Browse files

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: 0c18184d ("platform/x86: apple-gmux: support MMIO gmux on T2 Macs")
Reported-by: default avatarKarsten Leipold <poldi@dfn.de>
Signed-off-by: default avatarOrlando Chamberlain <orlandoch.dev@gmail.com>
Link: https://lore.kernel.org/r/20231017111444.19304-2-orlandoch.dev@gmail.com


Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
parent fe0e04cf
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -105,6 +105,8 @@ struct apple_gmux_config {
#define GMUX_BRIGHTNESS_MASK		0x00ffffff
#define GMUX_MAX_BRIGHTNESS		GMUX_BRIGHTNESS_MASK

# define MMIO_GMUX_MAX_BRIGHTNESS	0xffff

static u8 gmux_pio_read8(struct apple_gmux_data *gmux_data, int port)
{
	return inb(gmux_data->iostart + port);
@@ -857,6 +859,16 @@ static int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)

	memset(&props, 0, sizeof(props));
	props.type = BACKLIGHT_PLATFORM;

	/*
	 * All MMIO gmux's have 0xffff as max brightness, but some iMacs incorrectly
	 * report 0x03ff, despite the firmware being happy to set 0xffff as the brightness
	 * at boot. Force 0xffff for all MMIO gmux's so they all have the correct brightness
	 * range.
	 */
	if (type == APPLE_GMUX_TYPE_MMIO)
		props.max_brightness = MMIO_GMUX_MAX_BRIGHTNESS;
	else
		props.max_brightness = gmux_read32(gmux_data, GMUX_PORT_MAX_BRIGHTNESS);

#if IS_REACHABLE(CONFIG_ACPI_VIDEO)