mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul Menzel <pmenzel@molgen.mpg.de>
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>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Matthew Brost" <matthew.brost@intel.com>,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Cc: "Paul Menzel" <pmenzel@molgen.mpg.de>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"Antheas Kapenekakis" <lkml@antheas.dev>,
	"Thomas Weißschuh" <linux@weissschuh.net>,
	intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/3] drm/i915/backlight: Honor panel backlight quirk for minimum brightness
Date: Fri, 27 Nov 2026 17:37:45 +0100	[thread overview]
Message-ID: <20261127163752.54806-2-pmenzel@molgen.mpg.de> (raw)
In-Reply-To: <20261127163752.54806-1-pmenzel@molgen.mpg.de>

The DRM panel backlight quirk table (drm_panel_backlight_quirks.c)
overrides the minimum PWM brightness per system and panel, but only
amdgpu consults it. i915 always takes the minimum from the VBT, so a
firmware minimum that is too high cannot be corrected without patching
the driver.

Look up the quirk with the panel’s EDID in get_backlight_min_vbt(), and
if it sets min_brightness, use it instead of the VBT value. Like the
VBT field, the quirk value is on the [0..255] scale, stored plus one so
that 0 means unset; amdgpu reads it the same way. The lookup covers all
PWM backends, as they all get their minimum from get_backlight_min_vbt().

Select DRM_PANEL_BACKLIGHT_QUIRKS for i915 and xe, which builds the
i915 display code as well.

Tested on hardware with GNOME 51 at its lowest brightness
(sysfs 960/96000):

- Dell XPS 13 9310, BIOS 3.17.0 (Sharp LQ134N1, SHP 0x14f9): v7.4-rc1 and
  v7.4-rc4 based kernels; PWM duty 6551 -> 960 (6.8 % -> 1 %).
- Dell XPS 9315, BIOS 1.26.0 (Sharp LQ134N1, SHP 0x1548): v7.4-rc4 + this
  series, Debian 7.3.5 config; duty 6551 -> 960.

     [CONNECTOR:676:eDP-1] Applying panel backlight quirk, min brightness 0/255 (VBT 15/255)".

Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
---

Notes:
    
    Prepared with Claude Code (claude-opus-5-5).

 drivers/gpu/drm/i915/Kconfig                   |  1 +
 drivers/gpu/drm/i915/display/intel_backlight.c | 15 +++++++++++++++
 drivers/gpu/drm/xe/Kconfig                     |  1 +
 3 files changed, 17 insertions(+)

diff --git a/drivers/gpu/drm/i915/Kconfig b/drivers/gpu/drm/i915/Kconfig
index 71426b9c91f00..c2075a4a48b8b 100644
--- a/drivers/gpu/drm/i915/Kconfig
+++ b/drivers/gpu/drm/i915/Kconfig
@@ -18,6 +18,7 @@ config DRM_I915
 	select DRM_DISPLAY_HELPER
 	select DRM_KMS_HELPER
 	select DRM_PANEL
+	select DRM_PANEL_BACKLIGHT_QUIRKS
 	select DRM_MIPI_DSI
 	select FB_IOMEM_HELPERS if DRM_FBDEV_EMULATION
 	select RELAY
diff --git a/drivers/gpu/drm/i915/display/intel_backlight.c b/drivers/gpu/drm/i915/display/intel_backlight.c
index b128896cb1c2d..b0c0e7f3d6e24 100644
--- a/drivers/gpu/drm/i915/display/intel_backlight.c
+++ b/drivers/gpu/drm/i915/display/intel_backlight.c
@@ -10,6 +10,7 @@
 #include <acpi/video.h>
 
 #include <drm/drm_file.h>
+#include <drm/drm_panel_quirks.h>
 #include <drm/drm_print.h>
 #include <drm/intel/pci_config.h>
 
@@ -1207,10 +1208,24 @@ static u32 get_backlight_min_vbt(struct intel_connector *connector)
 {
 	struct intel_display *display = to_intel_display(connector);
 	struct intel_panel *panel = &connector->panel;
+	const struct drm_panel_backlight_quirk *quirk;
 	int min;
 
 	drm_WARN_ON(display->drm, panel->backlight.pwm_level_max == 0);
 
+	/* Quirk min_brightness is the minimum in [0..255] plus one, 0 = unset. */
+	quirk = drm_get_panel_backlight_quirk(IS_ERR(panel->fixed_edid) ?
+					      NULL : panel->fixed_edid);
+	if (!IS_ERR_OR_NULL(quirk) && quirk->min_brightness) {
+		min = quirk->min_brightness - 1;
+		drm_info(display->drm,
+			 "[CONNECTOR:%d:%s] Applying panel backlight quirk, min brightness %d/255 (VBT %d/255)\n",
+			 connector->base.base.id, connector->base.name,
+			 min, connector->panel.vbt.backlight.min_brightness);
+
+		return scale(min, 0, 255, 0, panel->backlight.pwm_level_max);
+	}
+
 	/*
 	 * XXX: If the vbt value is 255, it makes min equal to max, which leads
 	 * to problems. There are such machines out there. Either our
diff --git a/drivers/gpu/drm/xe/Kconfig b/drivers/gpu/drm/xe/Kconfig
index 049d2f25d0e60..dab996c7d205d 100644
--- a/drivers/gpu/drm/xe/Kconfig
+++ b/drivers/gpu/drm/xe/Kconfig
@@ -16,6 +16,7 @@ config DRM_XE
 	select DRM_KMS_HELPER
 	select DRM_KUNIT_TEST_HELPERS if DRM_XE_KUNIT_TEST != n
 	select DRM_PANEL
+	select DRM_PANEL_BACKLIGHT_QUIRKS
 	select DRM_SUBALLOC_HELPER
 	select DRM_DISPLAY_DP_HELPER
 	select DRM_DISPLAY_DSC_HELPER
-- 
2.54.0


       reply	other threads:[~2026-11-27 16:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20261127163752.54806-1-pmenzel@molgen.mpg.de>
2026-11-27 16:37 ` Paul Menzel [this message]
2026-11-27 16:37 ` [PATCH 2/3] drm: panel-backlight-quirks: Add Dell XPS 13 9310 FHD+ panel Paul Menzel

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=20261127163752.54806-2-pmenzel@molgen.mpg.de \
    --to=pmenzel@molgen.mpg.de \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --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=linux@weissschuh.net \
    --cc=lkml@antheas.dev \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=matthew.brost@intel.com \
    --cc=mripard@kernel.org \
    --cc=rodrigo.vivi@intel.com \
    --cc=simona@ffwll.ch \
    --cc=thomas.hellstrom@linux.intel.com \
    --cc=tursulin@ursulin.net \
    --cc=tzimmermann@suse.de \
    /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®