All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Lin <PingLei.Lin@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: Harry Wentland <harry.wentland@amd.com>,
	Leo Li <sunpeng.li@amd.com>,
	Aurabindo Pillai <aurabindo.pillai@amd.com>,
	Roman Li <roman.li@amd.com>, Wayne Lin <wayne.lin@amd.com>,
	Tom Chung <chiahsuan.chung@amd.com>,
	"Fangzhi Zuo" <jerry.zuo@amd.com>,
	Dan Wheeler <daniel.wheeler@amd.com>, Ray Wu <Ray.Wu@amd.com>,
	Ivan Lipski <ivan.lipski@amd.com>, Alex Hung <alex.hung@amd.com>,
	James Lin <PingLei.Lin@amd.com>,
	Chenyu Chen <Chen-Yu.Chen@amd.com>, Ray Wu <ray.wu@amd.com>,
	James Lin <pinglei.lin@amd.com>
Subject: [PATCH 07/33] drm/amd/display: Use panel luminance range for AUX backlight in power module
Date: Tue, 17 Nov 2026 05:50:44 +0800	[thread overview]
Message-ID: <20261116215641.2800595-8-PingLei.Lin@amd.com> (raw)
In-Reply-To: <20261116215641.2800595-1-PingLei.Lin@amd.com>

From: Ray Wu <ray.wu@amd.com>

[Why & How]
The power module always gets the default 1..270 nits range, so VESA
AUX panels with DMUB aux_backlight_support are capped at 270 nits. For
AUX backlight panels, pass the EDID derived aux_min/max_input_signal
to the power module, and add KUnit cases for it.

Cc: ChiaHsuan Chung <chiahsuan.chung@amd.com>
Signed-off-by: Ray Wu <ray.wu@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 20 ++++-
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  3 +
 .../display/amdgpu_dm/tests/amdgpu_dm_test.c  | 73 +++++++++++++++++++
 3 files changed, 93 insertions(+), 3 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 a7c2b0094944..2f4c6a2dd4ec 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -417,6 +417,22 @@ STATIC_IFN_KUNIT void mmhub_read_system_context(struct amdgpu_device *adev,
 }
 EXPORT_IF_KUNIT(mmhub_read_system_context);
 
+STATIC_IFN_KUNIT void
+amdgpu_dm_fill_power_nits_range(const struct amdgpu_dm_backlight_caps *caps,
+				struct mod_power_init_params *init_data)
+{
+	init_data->use_nits_based_brightness = false;
+	init_data->panel_max_millinits = 0;
+	init_data->panel_min_millinits = 0;
+	if (caps->aux_support &&
+	    caps->aux_max_input_signal > caps->aux_min_input_signal) {
+		init_data->use_nits_based_brightness = true;
+		init_data->panel_max_millinits = caps->aux_max_input_signal * 1000;
+		init_data->panel_min_millinits = caps->aux_min_input_signal * 1000;
+	}
+}
+EXPORT_IF_KUNIT(amdgpu_dm_fill_power_nits_range);
+
 STATIC_IFN_KUNIT int amdgpu_dm_init_power_module(struct amdgpu_display_manager *dm)
 {
 	struct mod_power_init_params init_data[MAX_NUM_EDP];
@@ -441,9 +457,7 @@ STATIC_IFN_KUNIT int amdgpu_dm_init_power_module(struct amdgpu_display_manager *
 		init_data[i].def_varibright_level = 0;
 		init_data[i].abm_config_setting = 0;
 		init_data[i].num_backlight_levels = 101;
-		init_data[i].use_nits_based_brightness = false;
-		init_data[i].panel_max_millinits = 0;
-		init_data[i].panel_min_millinits = 0;
+		amdgpu_dm_fill_power_nits_range(&dm->backlight_caps[i], &init_data[i]);
 		init_data[i].disable_fractional_pwm =
 			!(amdgpu_dc_feature_mask & DC_DISABLE_FRACTIONAL_PWM_MASK);
 		init_data[i].use_custom_backlight_caps = false;
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
index f8503ebf28f4..761d2b40aece 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
@@ -1346,9 +1346,12 @@ struct dc_plane_address;
 struct dc_plane_cap;
 struct dc_plane_info;
 struct dsc_mst_fairness_vars;
+struct mod_power_init_params;
 
 void mmhub_read_system_context(struct amdgpu_device *adev,
 			       struct dc_phy_addr_space_config *pa_config);
+void amdgpu_dm_fill_power_nits_range(const struct amdgpu_dm_backlight_caps *caps,
+				     struct mod_power_init_params *init_data);
 int amdgpu_dm_init_power_module(struct amdgpu_display_manager *dm);
 void dm_gpureset_toggle_interrupts(struct amdgpu_device *adev, struct dc_state *state, bool enable);
 enum dc_status amdgpu_dm_commit_zero_streams(struct dc *dc);
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c
index b9272b28f53c..a7618473e207 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c
@@ -37,6 +37,7 @@
 #include "amdgpu_dm_hdcp.h"
 #include "amdgpu_dm_mst_types.h"
 #include "amdgpu_dm_kunit_test_helpers.h"
+#include "mod_power.h"
 
 /* Tests for simple DM callbacks */
 
@@ -3802,6 +3803,74 @@ static void dm_test_init_power_module_alloc_failure(struct kunit *test)
 	KUNIT_EXPECT_NULL(test, adev->dm.power_module);
 }
 
+/* Tests for amdgpu_dm_fill_power_nits_range() */
+
+/**
+ * dm_test_fill_power_nits_range_aux - Test AUX passes the panel nits range
+ * @test: The KUnit test context
+ *
+ * The power module sends max_brightness_millinits to DMUB, which scales the
+ * VESA AUX level with it, so it must be the panel range and not 270 nits
+ */
+static void dm_test_fill_power_nits_range_aux(struct kunit *test)
+{
+	struct amdgpu_dm_backlight_caps caps = {
+		.aux_support = true,
+		.aux_min_input_signal = 1,
+		.aux_max_input_signal = 500,
+	};
+	struct mod_power_init_params init_data;
+
+	memset(&init_data, 0xff, sizeof(init_data));
+	amdgpu_dm_fill_power_nits_range(&caps, &init_data);
+
+	KUNIT_EXPECT_TRUE(test, init_data.use_nits_based_brightness);
+	KUNIT_EXPECT_EQ(test, init_data.panel_min_millinits, 1000U);
+	KUNIT_EXPECT_EQ(test, init_data.panel_max_millinits, 500000U);
+}
+
+/**
+ * dm_test_fill_power_nits_range_aux_bad_range - Test a bad AUX range keeps the default
+ * @test: The KUnit test context
+ */
+static void dm_test_fill_power_nits_range_aux_bad_range(struct kunit *test)
+{
+	struct amdgpu_dm_backlight_caps caps = {
+		.aux_support = true,
+		.aux_min_input_signal = 500,
+		.aux_max_input_signal = 500,
+	};
+	struct mod_power_init_params init_data;
+
+	memset(&init_data, 0xff, sizeof(init_data));
+	amdgpu_dm_fill_power_nits_range(&caps, &init_data);
+
+	KUNIT_EXPECT_FALSE(test, init_data.use_nits_based_brightness);
+	KUNIT_EXPECT_EQ(test, init_data.panel_min_millinits, 0U);
+	KUNIT_EXPECT_EQ(test, init_data.panel_max_millinits, 0U);
+}
+
+/**
+ * dm_test_fill_power_nits_range_pwm - Test PWM keeps the default nits range
+ * @test: The KUnit test context
+ */
+static void dm_test_fill_power_nits_range_pwm(struct kunit *test)
+{
+	struct amdgpu_dm_backlight_caps caps = {
+		.aux_support = false,
+		.aux_min_input_signal = 1,
+		.aux_max_input_signal = 500,
+	};
+	struct mod_power_init_params init_data;
+
+	memset(&init_data, 0xff, sizeof(init_data));
+	amdgpu_dm_fill_power_nits_range(&caps, &init_data);
+
+	KUNIT_EXPECT_FALSE(test, init_data.use_nits_based_brightness);
+	KUNIT_EXPECT_EQ(test, init_data.panel_min_millinits, 0U);
+	KUNIT_EXPECT_EQ(test, init_data.panel_max_millinits, 0U);
+}
+
 /* Tests for fill_dc_plane_info_and_addr() */
 
 struct dm_test_plane_info_ctx {
@@ -5390,6 +5459,10 @@ static struct kunit_case amdgpu_dm_tests[] = {
 	/* amdgpu_dm_init_power_module */
 	KUNIT_CASE(dm_test_init_power_module_no_edp),
 	KUNIT_CASE(dm_test_init_power_module_alloc_failure),
+	/* amdgpu_dm_fill_power_nits_range */
+	KUNIT_CASE(dm_test_fill_power_nits_range_aux),
+	KUNIT_CASE(dm_test_fill_power_nits_range_aux_bad_range),
+	KUNIT_CASE(dm_test_fill_power_nits_range_pwm),
 	/* fill_dc_plane_info_and_addr */
 	KUNIT_CASE(dm_test_plane_info_graphics_formats),
 	KUNIT_CASE(dm_test_plane_info_video_formats),
-- 
2.43.0


  parent reply	other threads:[~2026-11-17 17:13 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
2026-11-16 21:50 ` [PATCH 01/33] drm/amd/display: Clear OTG_AUTO_FORCE_VSYNC_MODE on OTG disable James Lin
2026-11-16 21:50 ` [PATCH 02/33] drm/amd/display: Rename DPMS to DPMS_v1 James Lin
2026-11-16 21:50 ` [PATCH 03/33] drm/amd/display: Power up eDP when detect link James Lin
2026-11-16 21:50 ` [PATCH 04/33] drm/amd/display: Add DPMS-v2 files James Lin
2026-11-16 21:50 ` [PATCH 05/33] drm/amd/display: Refactor DP retrain link HW sequence James Lin
2026-11-16 21:50 ` [PATCH 06/33] drm/amd/display: add extra 0.25 line reserved for TSetup/TCalc inefficiency James Lin
2026-11-16 21:50 ` James Lin [this message]
2026-11-16 21:50 ` [PATCH 08/33] drm/amd/display: Read PWM back linearly with the linear backlight curve James Lin
2026-11-16 21:50 ` [PATCH 09/33] drm/amd/display: Add API to set brightness percent James Lin
2026-11-16 21:50 ` [PATCH 10/33] drm/amd/display: Pass linear brightness percent to power module James Lin
2026-11-16 21:50 ` [PATCH 11/33] drm/amd/display: Add DPMS-v2 types James Lin
2026-11-16 21:50 ` [PATCH 12/33] drm/amd/display: Always apply 0ppm pixel clock adjustment James Lin
2026-11-16 21:50 ` [PATCH 13/33] drm/amd/display: Add otg versions of get_vblank_counter/scanoutpos James Lin
2026-11-16 21:50 ` [PATCH 14/33] drm/amd/display: Queue vblank control work to sleepable context James Lin
2026-11-16 21:50 ` [PATCH 15/33] drm/amd/display: Fix KUnit tests for vblank control rework James Lin
2026-11-16 21:50 ` [PATCH 16/33] drm/amd/display: Add urgent request and assertion probes James Lin
2026-11-16 21:50 ` [PATCH 17/33] drm/amd/display: Fix G7 P-state aperture addresses James Lin
2026-11-16 21:50 ` [PATCH 18/33] drm/amd/display: Set stream min/max refresh from VRR config James Lin
2026-11-16 21:50 ` [PATCH 19/33] drm/amd/display: Add DC2 wrapped initialization for DCN401 James Lin
2026-11-16 21:50 ` [PATCH 20/33] drm/amd/display: Honor the Replay stream regeneration wait event James Lin
2026-11-16 21:50 ` [PATCH 21/33] drm/amd/display: Disable Replay when link off frame count is below 2 James Lin
2026-11-16 21:50 ` [PATCH 22/33] drm/amd/display: Skip DSC padding borrow estimate for zero padding James Lin
2026-11-16 21:51 ` [PATCH 23/33] drm/amd/display: Drop unused DC interfaces James Lin
2026-11-16 21:51 ` [PATCH 24/33] drm/amd/display: Let the DC2 commit replace or keep a stream James Lin
2026-11-16 21:51 ` [PATCH 25/33] drm/amd/display: Support two streams in the dcn401 DC2 builders James Lin
2026-11-16 21:51 ` [PATCH 26/33] drm/amd/display: Add a plane beside a kept plane in DC2 update James Lin
2026-11-16 21:51 ` [PATCH 27/33] drm/amd/display: Keep an unchanged stream in the DC2 commit James Lin
2026-11-16 21:51 ` [PATCH 28/33] drm/amd/display: Change the ODM and MPC layout in DC2 update James Lin
2026-11-16 21:51 ` [PATCH 29/33] drm/amd/display: Give the DC2 builders State pipe facts James Lin
2026-11-16 21:51 ` [PATCH 30/33] drm/amd/display: Add RGBA8888 surface pixel format support James Lin
2026-11-16 21:51 ` [PATCH 31/33] drm/amd/display: Fix DCE crossbar for RGBA8888 surface format James Lin
2026-11-16 21:51 ` [PATCH 32/33] drm/amd/display: [FW Promotion] Release 0.1.85.0 James Lin
2026-11-16 21:51 ` [PATCH 33/33] drm/amd/display: Promote DC to 3.2.408 James Lin

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=20261116215641.2800595-8-PingLei.Lin@amd.com \
    --to=pinglei.lin@amd.com \
    --cc=Chen-Yu.Chen@amd.com \
    --cc=Ray.Wu@amd.com \
    --cc=alex.hung@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=aurabindo.pillai@amd.com \
    --cc=chiahsuan.chung@amd.com \
    --cc=daniel.wheeler@amd.com \
    --cc=harry.wentland@amd.com \
    --cc=ivan.lipski@amd.com \
    --cc=jerry.zuo@amd.com \
    --cc=roman.li@amd.com \
    --cc=sunpeng.li@amd.com \
    --cc=wayne.lin@amd.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.