public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: "Mario Limonciello (AMD)" <superm1@kernel.org>
To: dri-devel@lists.freedesktop.org
Cc: amd-gfx@lists.freedesktop.org,
	"Mario Limonciello (AMD)" <superm1@kernel.org>
Subject: [PATCH v5 08/11] drm/amd/display: use drm backlight
Date: Sun, 31 May 2026 06:49:05 -0500	[thread overview]
Message-ID: <20260531114908.1693426-9-superm1@kernel.org> (raw)
In-Reply-To: <20260531114908.1693426-1-superm1@kernel.org>

Convert AMD display driver to use the new DRM backlight infrastructure.
This allows brightness control via DRM connector properties.

Includes fixes for backlight resource lifecycle management.

Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)

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 f6610902eee4..55c3838f7ec8 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -86,6 +86,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_blend.h>
 #include <drm/drm_fixed.h>
 #include <drm/drm_fourcc.h>
@@ -5549,6 +5550,15 @@ 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. If
+	 * drm_backlight_alloc() failed earlier in init_helper,
+	 * aconnector->base.backlight is NULL and drm_backlight_link() is a
+	 * no-op.
+	 */
+	drm_backlight_link(aconnector->base.backlight,
+			   dm->backlight_dev[aconnector->bl_idx]);
+
 	drm_dbg_driver(drm, "DM: Registered Backlight device: %s\n", bl_name);
 
 	return 0;
@@ -7993,6 +8003,7 @@ static void amdgpu_dm_connector_destroy(struct drm_connector *connector)
 	}
 
 	if (aconnector->bl_idx != -1) {
+		drm_backlight_link(aconnector->base.backlight, NULL);
 		backlight_device_unregister(dm->backlight_dev[aconnector->bl_idx]);
 		dm->backlight_dev[aconnector->bl_idx] = NULL;
 	}
@@ -8005,6 +8016,10 @@ static void amdgpu_dm_connector_destroy(struct drm_connector *connector)
 	aconnector->dc_sink = NULL;
 
 	drm_dp_cec_unregister_connector(&aconnector->dm_dp_aux.aux);
+	/* DRM core will handle drm_backlight cleanup via:
+	 * drm_connector_unregister() -> drm_backlight_unregister()
+	 * drm_connector_cleanup() -> drm_backlight_free()
+	 */
 	drm_connector_unregister(connector);
 	drm_connector_cleanup(connector);
 	kfree(aconnector->dm_dp_aux.aux.name);
@@ -9254,6 +9269,12 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm,
 	aconnector->base.state->max_bpc = 16;
 	aconnector->base.state->max_requested_bpc = aconnector->base.state->max_bpc;
 
+	if (connector_type == DRM_MODE_CONNECTOR_eDP) {
+		int r = drm_backlight_alloc(&aconnector->base);
+
+		if (r)
+			drm_err(dm->ddev, "Failed to allocate backlight: %d\n", r);
+	}
 	if (connector_type == DRM_MODE_CONNECTOR_HDMIA) {
 		/* Content Type is currently only implemented for HDMI. */
 		drm_connector_attach_content_type_property(&aconnector->base);
-- 
2.54.0


  parent reply	other threads:[~2026-05-31 11:49 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-31 11:48 [PATCH v5 00/11] Add support for a DRM backlight capability Mario Limonciello (AMD)
2026-05-31 11:48 ` [PATCH v5 01/11] Revert "backlight: Remove notifier" Mario Limonciello (AMD)
2026-06-04  4:54   ` Claude review: " Claude Code Review Bot
2026-05-31 11:48 ` [PATCH v5 02/11] backlight: add kernel-internal backlight API Mario Limonciello (AMD)
2026-06-04  4:54   ` Claude review: " Claude Code Review Bot
2026-05-31 11:49 ` [PATCH v5 03/11] drm: link connectors to backlight devices Mario Limonciello (AMD)
2026-06-04  4:54   ` Claude review: " Claude Code Review Bot
2026-05-31 11:49 ` [PATCH v5 04/11] DRM: Add support for client indicating support for luminance Mario Limonciello (AMD)
2026-06-04  4:54   ` Claude review: " Claude Code Review Bot
2026-05-31 11:49 ` [PATCH v5 05/11] drm/amd/display: Pass up errors reading actual brightness Mario Limonciello (AMD)
2026-06-04  4:54   ` Claude review: " Claude Code Review Bot
2026-05-31 11:49 ` [PATCH v5 06/11] drm/amd/display: Allow backlight registration to fail Mario Limonciello (AMD)
2026-06-04  4:54   ` Claude review: " Claude Code Review Bot
2026-05-31 11:49 ` [PATCH v5 07/11] drm/amd/display: Move backlight tracing out of the dc lock Mario Limonciello (AMD)
2026-06-04  4:54   ` Claude review: " Claude Code Review Bot
2026-05-31 11:49 ` Mario Limonciello (AMD) [this message]
2026-06-04  4:54   ` Claude review: drm/amd/display: use drm backlight Claude Code Review Bot
2026-05-31 11:49 ` [PATCH v5 09/11] drm/amd/display: Drop brightness caching in amdgpu_dm Mario Limonciello (AMD)
2026-06-04  4:54   ` Claude review: " Claude Code Review Bot
2026-05-31 11:49 ` [PATCH v5 10/11] drm/bridge: auto-link panel backlight in bridge connector Mario Limonciello (AMD)
2026-06-04  4:54   ` Claude review: " Claude Code Review Bot
2026-05-31 11:49 ` [PATCH v5 11/11] drm/i915/display: use drm backlight Mario Limonciello (AMD)
2026-06-04  4:54   ` Claude review: " Claude Code Review Bot
2026-06-04  4:54 ` Claude review: Add support for a DRM backlight capability Claude Code Review Bot

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=20260531114908.1693426-9-superm1@kernel.org \
    --to=superm1@kernel.org \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    /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