mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/1] apple-gmux: Hard Code max brightness for MMIO gmux
@ 2023-10-17 11:14 Orlando Chamberlain
  2023-10-18 13:36 ` Hans de Goede
  0 siblings, 1 reply; 2+ messages in thread
From: Orlando Chamberlain @ 2023-10-17 11:14 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Mark Gross, platform-driver-x86, linux-kernel, Aditya Garg,
	Aun-Ali Zaidi, Kerem Karabay, Orlando Chamberlain,
	Karsten Leipold

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.

Reported-by: Karsten Leipold <poldi@dfn.de>
Signed-off-by: Orlando Chamberlain <orlandoch.dev@gmail.com>
---
 drivers/platform/x86/apple-gmux.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/apple-gmux.c b/drivers/platform/x86/apple-gmux.c
index cadbb557a108..1417e230edbd 100644
--- a/drivers/platform/x86/apple-gmux.c
+++ b/drivers/platform/x86/apple-gmux.c
@@ -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,7 +859,17 @@ static int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
 
 	memset(&props, 0, sizeof(props));
 	props.type = BACKLIGHT_PLATFORM;
-	props.max_brightness = gmux_read32(gmux_data, GMUX_PORT_MAX_BRIGHTNESS);
+
+	/*
+	 * 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)
 	register_bdev = acpi_video_get_backlight_type() == acpi_backlight_apple_gmux;
-- 
2.42.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/1] apple-gmux: Hard Code max brightness for MMIO gmux
  2023-10-17 11:14 [PATCH 1/1] apple-gmux: Hard Code max brightness for MMIO gmux Orlando Chamberlain
@ 2023-10-18 13:36 ` Hans de Goede
  0 siblings, 0 replies; 2+ messages in thread
From: Hans de Goede @ 2023-10-18 13:36 UTC (permalink / raw)
  To: Orlando Chamberlain
  Cc: Mark Gross, platform-driver-x86, linux-kernel, Aditya Garg,
	Aun-Ali Zaidi, Kerem Karabay, Karsten Leipold

Hi,

On 10/17/23 13:14, Orlando Chamberlain wrote:
> 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.
> 
> Reported-by: Karsten Leipold <poldi@dfn.de>
> Signed-off-by: Orlando Chamberlain <orlandoch.dev@gmail.com>

Thank you for your patch/series, I've applied this patch
(series) to the pdx86 fixes branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=fixes

I have added the following Fixes: tag while merging this:

Fixes: 0c18184de990 ("platform/x86: apple-gmux: support MMIO gmux on T2 Macs")

I will include this patch in my next fixes pull-req to Linus
for the current kernel development cycle.

Regards,

Hans



> ---
>  drivers/platform/x86/apple-gmux.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/x86/apple-gmux.c b/drivers/platform/x86/apple-gmux.c
> index cadbb557a108..1417e230edbd 100644
> --- a/drivers/platform/x86/apple-gmux.c
> +++ b/drivers/platform/x86/apple-gmux.c
> @@ -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,7 +859,17 @@ static int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
>  
>  	memset(&props, 0, sizeof(props));
>  	props.type = BACKLIGHT_PLATFORM;
> -	props.max_brightness = gmux_read32(gmux_data, GMUX_PORT_MAX_BRIGHTNESS);
> +
> +	/*
> +	 * 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)
>  	register_bdev = acpi_video_get_backlight_type() == acpi_backlight_apple_gmux;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-10-18 13:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-17 11:14 [PATCH 1/1] apple-gmux: Hard Code max brightness for MMIO gmux Orlando Chamberlain
2023-10-18 13:36 ` Hans de Goede

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®