From: Mario Limonciello <mario.limonciello@amd.com>
To: <dri-devel@lists.freedesktop.org>, <harry.wentland@amd.com>,
Simona Vetter <simona@ffwll.ch>,
Alex Deucher <alexander.deucher@amd.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>
Cc: Xaver Hugl <xaver.hugl@gmail.com>,
<amd-gfx@lists.freedesktop.org>,
"open list:INTEL DRM DISPLAY FOR XE AND I915 DRIVERS"
<intel-gfx@lists.freedesktop.org>,
"open list:INTEL DRM DISPLAY FOR XE AND I915 DRIVERS"
<intel-xe@lists.freedesktop.org>,
Hans de Goede <hansg@kernel.org>,
Mario Limonciello <mario.limonciello@amd.com>,
"Mario Limonciello" <superm1@kernel.org>
Subject: [PATCH v8 08/14] drm/amd/display: use drm backlight
Date: Mon, 7 Sep 2026 23:40:29 -0500 [thread overview]
Message-ID: <20260908044035.62093-9-mario.limonciello@amd.com> (raw)
In-Reply-To: <20260908044035.62093-1-mario.limonciello@amd.com>
Convert the AMD display driver to the DRM backlight infrastructure so
brightness can be controlled through the connector LUMINANCE property.
Link the registered backlight_device to the eDP connector and unlink it
on teardown; the DRM core owns the embedded backlight state and its
property, so no explicit allocation or failure handling is needed.
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
---
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 15 +++++++++---
.../display/amdgpu_dm/amdgpu_dm_backlight.c | 23 ++++++++++++++++---
.../display/amdgpu_dm/amdgpu_dm_connector.c | 2 ++
3 files changed, 34 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 2fe934036e363..f7b1eaf34b59d 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -5050,10 +5050,21 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_commit *state)
old_crtc_state = drm_atomic_get_old_crtc_state(state, &acrtc->base);
}
+ /*
+ * Apply the LUMINANCE property first: a brightness-only commit
+ * does not pull the CRTC into the atomic state (so new_crtc_state
+ * is NULL), and a modeset is skipped below - in both cases the
+ * backlight must still follow the requested luminance.
+ */
+ drm_atomic_helper_connector_apply_luminance(new_con_state);
+
/* Skip any modesets/resets */
- if (!acrtc || drm_atomic_crtc_needs_modeset(new_crtc_state))
+ if (!acrtc || !new_crtc_state ||
+ drm_atomic_crtc_needs_modeset(new_crtc_state))
continue;
+ drm_connector_update_privacy_screen(new_con_state);
+
dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
dm_old_crtc_state = to_dm_crtc_state(old_crtc_state);
@@ -5133,8 +5144,6 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_commit *state)
&stream_update);
mutex_unlock(&dm->dc_lock);
kfree(dummy_updates);
-
- drm_connector_update_privacy_screen(new_con_state);
}
/**
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.c
index 406a821d03cd6..1fefe3837e4cf 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.c
@@ -40,6 +40,7 @@
#include <linux/backlight.h>
#include <linux/power_supply.h>
+#include <drm/drm_backlight.h>
#include <drm/drm_edid.h>
#include <drm/drm_utils.h>
@@ -224,13 +225,17 @@ struct dc_stream_state *dm_find_stream_with_link(
struct amdgpu_display_manager *dm,
struct dc_link *link)
{
- struct dc_state *cur_dc_state = dm->dc->current_state;
+ struct dc_state *cur_dc_state;
struct dc_stream_state *stream = NULL;
int i;
+ if (!dm || !dm->dc || !dm->dc->current_state || !link)
+ return NULL;
+
+ cur_dc_state = dm->dc->current_state;
for (i = 0; i < cur_dc_state->stream_count; i++) {
stream = cur_dc_state->streams[i];
- if (stream->link == link)
+ if (stream && stream->link == link)
return stream;
}
@@ -284,7 +289,7 @@ void amdgpu_dm_backlight_set_level(struct amdgpu_display_manager *dm,
dm->brightness[bl_idx] = user_brightness;
/* update scratch register */
- if (bl_idx == 0)
+ if (bl_idx == 0 && dm->adev && dm->adev->rmmio && dm->adev->bios_scratch_reg_offset)
amdgpu_atombios_scratch_regs_set_backlight_level(dm->adev, dm->brightness[bl_idx]);
brightness = convert_brightness_from_user(caps, dm->brightness[bl_idx]);
link = (struct dc_link *)dm->backlight_link[bl_idx];
@@ -496,6 +501,9 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
dm->actual_brightness[aconnector->bl_idx] = real_brightness;
dm->brightness[aconnector->bl_idx] = real_brightness;
}
+ /* Link the registered backlight device to the DRM connector. */
+ drm_backlight_link(&aconnector->base, dm->backlight_dev[aconnector->bl_idx]);
+
drm_dbg_driver(drm, "DM: Registered Backlight device: %s\n", bl_name);
}
}
@@ -582,6 +590,8 @@ void amdgpu_dm_setup_backlight_device(struct amdgpu_display_manager *dm,
{
struct dc_link *link = aconnector->dc_link;
int bl_idx = dm->num_of_edps;
+ struct backlight_properties props = { 0 };
+ struct amdgpu_dm_backlight_caps *caps;
if (!(link->connector_signal & (SIGNAL_TYPE_EDP | SIGNAL_TYPE_LVDS)) ||
link->type == dc_connection_none)
@@ -600,6 +610,13 @@ void amdgpu_dm_setup_backlight_device(struct amdgpu_display_manager *dm,
amdgpu_dm_update_connector_ext_caps(aconnector);
+ caps = &dm->backlight_caps[bl_idx];
+ amdgpu_dm_backlight_fill_props(caps, power_supply_is_system_supplied() > 0,
+ !(amdgpu_dc_debug_mask &
+ DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE),
+ &props);
+ drm_backlight_create_property(&aconnector->base, props.max_brightness, false);
+
/* Offer ABM property when user didn't turn off by module parameter.
* OLED panels are included to support CACP (Content Adaptive
* Contrast and Power) feature via set_abm_level.
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
index c8a1ab8c3b169..fe4ab55f5130f 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
@@ -58,6 +58,7 @@
#include <drm/drm_atomic.h>
#include <drm/drm_atomic_uapi.h>
#include <drm/drm_atomic_helper.h>
+#include <drm/drm_backlight.h>
#include <drm/drm_edid.h>
#include <drm/drm_eld.h>
#include <drm/drm_fixed.h>
@@ -1911,6 +1912,7 @@ STATIC_IFN_KUNIT void amdgpu_dm_connector_destroy(struct drm_connector *connecto
}
if (aconnector->bl_idx != -1) {
+ drm_backlight_link(&aconnector->base, NULL);
backlight_device_unregister(dm->backlight_dev[aconnector->bl_idx]);
dm->backlight_dev[aconnector->bl_idx] = NULL;
}
--
2.43.0
next prev parent reply other threads:[~2026-09-08 4:41 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 4:40 [PATCH v8 00/14] Add support for a DRM backlight capability Mario Limonciello
2026-09-08 4:40 ` [PATCH v8 01/14] Revert "backlight: Remove notifier" Mario Limonciello
2026-09-08 4:51 ` sashiko-bot
2026-09-08 4:40 ` [PATCH v8 02/14] backlight: add kernel-internal backlight API Mario Limonciello
2026-09-08 4:52 ` sashiko-bot
2026-09-08 15:45 ` Jani Nikula
2026-09-08 16:00 ` Mario Limonciello
2026-09-08 16:33 ` Jani Nikula
2026-09-08 4:40 ` [PATCH v8 03/14] drm/property: add a per-connector luminance flag Mario Limonciello
2026-09-08 4:54 ` sashiko-bot
2026-09-08 4:40 ` [PATCH v8 04/14] drm: add connector backlight (LUMINANCE) infrastructure Mario Limonciello
2026-09-08 4:54 ` sashiko-bot
2026-09-08 15:48 ` Jani Nikula
2026-09-08 4:40 ` [PATCH v8 05/14] drm: add DRM_CLIENT_CAP_LUMINANCE Mario Limonciello
2026-09-08 4:55 ` sashiko-bot
2026-09-08 4:40 ` [PATCH v8 06/14] drm/amd/display: Pass up errors reading actual brightness Mario Limonciello
2026-09-08 4:40 ` [PATCH v8 07/14] drm/amd: Indicate driver supports luminance Mario Limonciello
2026-09-08 4:40 ` Mario Limonciello [this message]
2026-09-08 4:57 ` [PATCH v8 08/14] drm/amd/display: use drm backlight sashiko-bot
2026-09-08 4:40 ` [PATCH v8 09/14] drm/amdgpu: Check bios_scratch_reg_offset in backlight level helper Mario Limonciello
2026-09-08 4:51 ` sashiko-bot
2026-09-08 4:40 ` [PATCH v8 10/14] drm/amd/display: Update KUnit backlight tests for luminance property and fixtures Mario Limonciello
2026-09-08 4:54 ` sashiko-bot
2026-09-08 4:40 ` [PATCH v8 11/14] drm/bridge: auto-link panel backlight in bridge connector Mario Limonciello
2026-09-08 4:40 ` [PATCH v8 12/14] drm/xe: Indicate support for luminance on the connector Mario Limonciello
2026-09-08 4:57 ` sashiko-bot
2026-09-08 4:40 ` [PATCH v8 13/14] drm/i915: " Mario Limonciello
2026-09-08 4:40 ` [PATCH v8 14/14] drm/i915/display: use drm backlight Mario Limonciello
2026-09-08 5:03 ` sashiko-bot
2026-09-08 9:32 ` ✓ i915.CI.BAT: success for Add support for a DRM backlight capability (rev3) Patchwork
2026-09-08 18:45 ` ✗ i915.CI.Full: failure " Patchwork
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=20260908044035.62093-9-mario.limonciello@amd.com \
--to=mario.limonciello@amd.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=hansg@kernel.org \
--cc=harry.wentland@amd.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=superm1@kernel.org \
--cc=tzimmermann@suse.de \
--cc=xaver.hugl@gmail.com \
/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