mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andre Eikmeyer <dev@deq.rocks>
To: Jani Nikula <jani.nikula@linux.intel.com>,
	Rodrigo Vivi <rodrigo.vivi@intel.com>,
	Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
	Tvrtko Ursulin <tursulin@ursulin.net>
Cc: "David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Hans de Goede" <hansg@kernel.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org, "Andre Eikmeyer" <dev@deq.rocks>
Subject: [PATCH] drm/i915/backlight: restore the gmux brightness on dual GPU T2 MacBook Pros
Date: Sun,  8 Nov 2026 11:09:26 +0100	[thread overview]
Message-ID: <20261108100926.28950-1-dev@deq.rocks> (raw)

When i915 drives the panel of a dual GPU T2 MacBook Pro, the panel comes
back at 80% brightness after every screen lock, login and resume, while
the gmux backlight device still reports the level userspace set.

gmux resets its brightness register to 0xcccc of 0xffff when i915 powers
the panel off and applies that value when the panel comes back on.

This cannot be handled in apple-gmux. gmux raises no interrupt when the
panel is powered off or on. Only the GPU driver knows when the panel is
back.

amdgpu needs no such restore. When it drives the panel, the gmux
brightness register and the panel's DPCD brightness stay unchanged across
a screen lock.

Add a DMI quirk for these models and write the cached level back through
the gmux backlight device after enabling the backlight. The device is
looked up by name so i915 does not depend on apple-gmux.

Tested on the MacBookPro15,1 and MacBookPro16,1.

Signed-off-by: Andre Eikmeyer <dev@deq.rocks>
---
 .../gpu/drm/i915/display/intel_backlight.c    | 31 ++++++++++++++++
 drivers/gpu/drm/i915/display/intel_quirks.c   | 37 +++++++++++++++++++
 drivers/gpu/drm/i915/display/intel_quirks.h   |  1 +
 3 files changed, 69 insertions(+)

diff --git a/drivers/gpu/drm/i915/display/intel_backlight.c b/drivers/gpu/drm/i915/display/intel_backlight.c
index b128896cb..fddd2292e 100644
--- a/drivers/gpu/drm/i915/display/intel_backlight.c
+++ b/drivers/gpu/drm/i915/display/intel_backlight.c
@@ -793,6 +793,35 @@ static void __intel_backlight_enable(const struct intel_crtc_state *crtc_state,
 		panel->backlight.device->props.power = BACKLIGHT_POWER_ON;
 }
 
+#if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
+/*
+ * The gmux of dual GPU T2 MacBook Pros falls back to its default brightness
+ * whenever the panel is powered off and raises no interrupt for it. Its
+ * backlight device still holds the level userspace set, so apply that level
+ * again once the panel is back on.
+ */
+static void intel_backlight_restore_gmux(struct intel_display *display)
+{
+	struct backlight_device *bd;
+
+	if (!intel_has_quirk(display, QUIRK_GMUX_RESETS_BRIGHTNESS))
+		return;
+
+	bd = backlight_device_get_by_name("gmux_backlight");
+	if (!bd)
+		return;
+
+	drm_dbg_kms(display->drm, "restoring gmux brightness %d\n",
+		    bd->props.brightness);
+	backlight_update_status(bd);
+	put_device(&bd->dev);
+}
+#else
+static void intel_backlight_restore_gmux(struct intel_display *display)
+{
+}
+#endif
+
 void intel_backlight_enable(const struct intel_crtc_state *crtc_state,
 			    const struct drm_connector_state *conn_state)
 {
@@ -811,6 +840,8 @@ void intel_backlight_enable(const struct intel_crtc_state *crtc_state,
 	__intel_backlight_enable(crtc_state, conn_state);
 
 	mutex_unlock(&display->backlight.lock);
+
+	intel_backlight_restore_gmux(display);
 }
 
 #if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
diff --git a/drivers/gpu/drm/i915/display/intel_quirks.c b/drivers/gpu/drm/i915/display/intel_quirks.c
index 96eb9a40d..739e030cf 100644
--- a/drivers/gpu/drm/i915/display/intel_quirks.c
+++ b/drivers/gpu/drm/i915/display/intel_quirks.c
@@ -100,6 +100,13 @@ static void quirk_disable_psr2(struct intel_display *display)
 	drm_info(display->drm, "PSR2 support not currently available for this setup, applying disable PSR2 quirk\n");
 }
 
+/* The gmux of dual GPU T2 MacBook Pros resets the brightness on panel power off */
+static void quirk_gmux_resets_brightness(struct intel_display *display)
+{
+	intel_set_quirk(display, QUIRK_GMUX_RESETS_BRIGHTNESS);
+	drm_info(display->drm, "Applying gmux brightness restore quirk\n");
+}
+
 static void quirk_enable_dpcd_backlight(struct intel_dp *intel_dp)
 {
 	struct intel_display *display = to_intel_display(intel_dp);
@@ -196,6 +203,36 @@ static const struct intel_dmi_quirk intel_dmi_quirks[] = {
 		},
 		.hook = quirk_no_pps_backlight_power_hook,
 	},
+	{
+		.dmi_id_list = &(const struct dmi_system_id[]) {
+			{
+				.ident = "MacBookPro15,1",
+				.matches = {DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
+					    DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "MacBookPro15,1"),
+				},
+			},
+			{
+				.ident = "MacBookPro15,3",
+				.matches = {DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
+					    DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "MacBookPro15,3"),
+				},
+			},
+			{
+				.ident = "MacBookPro16,1",
+				.matches = {DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
+					    DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,1"),
+				},
+			},
+			{
+				.ident = "MacBookPro16,4",
+				.matches = {DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
+					    DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,4"),
+				},
+			},
+			{ }
+		},
+		.hook = quirk_gmux_resets_brightness,
+	},
 };
 
 static struct intel_quirk intel_quirks[] = {
diff --git a/drivers/gpu/drm/i915/display/intel_quirks.h b/drivers/gpu/drm/i915/display/intel_quirks.h
index 4996419ae..7498583c1 100644
--- a/drivers/gpu/drm/i915/display/intel_quirks.h
+++ b/drivers/gpu/drm/i915/display/intel_quirks.h
@@ -24,6 +24,7 @@ enum intel_quirk_id {
 	QUIRK_DISABLE_EDP_PANEL_REPLAY,
 	QUIRK_DISABLE_PSR2,
 	QUIRK_ENABLE_DPCD_BACKLIGHT,
+	QUIRK_GMUX_RESETS_BRIGHTNESS,
 };
 
 void intel_init_quirks(struct intel_display *display);

base-commit: 7b42cc130bec053d6989b849785c553f27b752ce

                 reply	other threads:[~2026-11-08 10:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261108100926.28950-1-dev@deq.rocks \
    --to=dev@deq.rocks \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hansg@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rodrigo.vivi@intel.com \
    --cc=simona@ffwll.ch \
    --cc=tursulin@ursulin.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®