All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wayne Lin <Wayne.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>,
	Zaeem Mohamed <zaeem.mohamed@amd.com>,
	Solomon Chiu <solomon.chiu@amd.com>,
	Daniel Wheeler <daniel.wheeler@amd.com>,
	Alex Hung <alex.hung@amd.com>, Leo Zeng <Leo.Zeng@amd.com>,
	Dillon Varone <dillon.varone@amd.com>
Subject: [PATCH 11/27] drm/amd/display: Added visual confirm for DCC
Date: Tue, 25 Feb 2025 14:35:54 +0800	[thread overview]
Message-ID: <20250225063610.631461-12-Wayne.Lin@amd.com> (raw)
In-Reply-To: <20250225063610.631461-1-Wayne.Lin@amd.com>

From: Leo Zeng <Leo.Zeng@amd.com>

[WHY]
We want to add a visual confirm mode for DCC and MCache for
debugging purpose.

[HOW]
color pipes based on whether DCC is enabled and what MCache id
is used.
black - DCC disabled
red - DCC enabled
grey - 2 different MCaches used
other colors - 1 MCache used

Reviewed-by: Dillon Varone <dillon.varone@amd.com>
Signed-off-by: Leo Zeng <Leo.Zeng@amd.com>
Signed-off-by: Wayne Lin <wayne.lin@amd.com>
---
 drivers/gpu/drm/amd/display/dc/core/dc.c      |  8 ++--
 .../drm/amd/display/dc/core/dc_hw_sequencer.c | 48 +++++++++++++++++++
 drivers/gpu/drm/amd/display/dc/dc.h           |  1 +
 .../drm/amd/display/dc/hwss/hw_sequencer.h    |  5 ++
 4 files changed, 59 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
index fe59649d3e15..e71ea21401f5 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -1202,6 +1202,8 @@ static void dc_update_visual_confirm_color(struct dc *dc, struct dc_state *conte
 			get_surface_tile_visual_confirm_color(pipe_ctx, &(pipe_ctx->visual_confirm_color));
 		else if (dc->debug.visual_confirm == VISUAL_CONFIRM_HW_CURSOR)
 			get_cursor_visual_confirm_color(pipe_ctx, &(pipe_ctx->visual_confirm_color));
+		else if (dc->debug.visual_confirm == VISUAL_CONFIRM_DCC)
+			get_dcc_visual_confirm_color(dc, pipe_ctx, &(pipe_ctx->visual_confirm_color));
 		else {
 			if (dc->ctx->dce_version < DCN_VERSION_2_0)
 				color_space_to_black_color(
@@ -3956,6 +3958,9 @@ static void commit_planes_for_stream(struct dc *dc,
 	if (update_type == UPDATE_TYPE_FULL && dc->optimized_required)
 		hwss_process_outstanding_hw_updates(dc, dc->current_state);
 
+	if (update_type != UPDATE_TYPE_FAST && dc->res_pool->funcs->prepare_mcache_programming)
+		dc->res_pool->funcs->prepare_mcache_programming(dc, context);
+
 	for (i = 0; i < dc->res_pool->pipe_count; i++) {
 		struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
 
@@ -4014,9 +4019,6 @@ static void commit_planes_for_stream(struct dc *dc,
 				odm_pipe->ttu_regs.min_ttu_vblank = MAX_TTU;
 	}
 
-	if (update_type != UPDATE_TYPE_FAST && dc->res_pool->funcs->prepare_mcache_programming)
-		dc->res_pool->funcs->prepare_mcache_programming(dc, context);
-
 	if ((update_type != UPDATE_TYPE_FAST) && stream->update_flags.bits.dsc_changed)
 		if (top_pipe_to_program &&
 			top_pipe_to_program->stream_res.tg->funcs->lock_doublebuffer_enable) {
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c
index 367c6b794412..e0277728268a 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c
@@ -34,6 +34,7 @@
 #include "dc_state_priv.h"
 
 #define NUM_ELEMENTS(a) (sizeof(a) / sizeof((a)[0]))
+#define MAX_NUM_MCACHE 8
 
 /* used as index in array of black_color_format */
 enum black_color_format {
@@ -553,6 +554,53 @@ void get_cursor_visual_confirm_color(
 	}
 }
 
+void get_dcc_visual_confirm_color(
+	struct dc *dc,
+	struct pipe_ctx *pipe_ctx,
+	struct tg_color *color)
+{
+	const uint32_t MCACHE_ID_UNASSIGNED = 0xF;
+
+	if (!pipe_ctx->plane_state->dcc.enable) {
+		color->color_r_cr = 0; /* black - DCC disabled */
+		color->color_g_y = 0;
+		color->color_b_cb = 0;
+		return;
+	}
+
+	if (dc->ctx->dce_version < DCN_VERSION_4_01) {
+		color->color_r_cr = MAX_TG_COLOR_VALUE; /* red - DCC enabled */
+		color->color_g_y = 0;
+		color->color_b_cb = 0;
+		return;
+	}
+
+	uint32_t first_id = pipe_ctx->mcache_regs.main.p0.mcache_id_first;
+	uint32_t second_id = pipe_ctx->mcache_regs.main.p0.mcache_id_second;
+
+	if (first_id != MCACHE_ID_UNASSIGNED && second_id != MCACHE_ID_UNASSIGNED && first_id != second_id) {
+		color->color_r_cr = MAX_TG_COLOR_VALUE/2; /* grey - 2 mcache */
+		color->color_g_y = MAX_TG_COLOR_VALUE/2;
+		color->color_b_cb = MAX_TG_COLOR_VALUE/2;
+	}
+
+	else if (first_id != MCACHE_ID_UNASSIGNED || second_id != MCACHE_ID_UNASSIGNED) {
+		const struct tg_color id_colors[MAX_NUM_MCACHE] = {
+		{0, MAX_TG_COLOR_VALUE, 0}, /* green */
+		{0, 0, MAX_TG_COLOR_VALUE}, /* blue */
+		{MAX_TG_COLOR_VALUE, MAX_TG_COLOR_VALUE, 0}, /* yellow */
+		{MAX_TG_COLOR_VALUE, 0, MAX_TG_COLOR_VALUE}, /* magenta */
+		{0, MAX_TG_COLOR_VALUE, MAX_TG_COLOR_VALUE}, /* cyan */
+		{MAX_TG_COLOR_VALUE, MAX_TG_COLOR_VALUE, MAX_TG_COLOR_VALUE}, /* white */
+		{MAX_TG_COLOR_VALUE/2, 0, 0}, /* dark red */
+		{0, MAX_TG_COLOR_VALUE/2, 0}, /* dark green */
+		};
+
+		uint32_t assigned_id = (first_id != MCACHE_ID_UNASSIGNED) ? first_id : second_id;
+		*color = id_colors[assigned_id];
+	}
+}
+
 void set_p_state_switch_method(
 		struct dc *dc,
 		struct dc_state *context,
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h
index f646f537a3dc..02bf6fe51a0d 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -495,6 +495,7 @@ enum visual_confirm {
 	VISUAL_CONFIRM_FAMS2 = 19,
 	VISUAL_CONFIRM_HW_CURSOR = 20,
 	VISUAL_CONFIRM_VABC = 21,
+	VISUAL_CONFIRM_DCC = 22,
 };
 
 enum dc_psr_power_opts {
diff --git a/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h b/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h
index 599fa41fd75f..2b1a2a00648a 100644
--- a/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h
+++ b/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h
@@ -517,6 +517,11 @@ void get_cursor_visual_confirm_color(
 		struct pipe_ctx *pipe_ctx,
 		struct tg_color *color);
 
+void get_dcc_visual_confirm_color(
+	struct dc *dc,
+	struct pipe_ctx *pipe_ctx,
+	struct tg_color *color);
+
 void set_p_state_switch_method(
 		struct dc *dc,
 		struct dc_state *context,
-- 
2.37.3


  parent reply	other threads:[~2025-02-25  6:37 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-25  6:35 [PATCH 00/27] DC Patches Feb. 25, 2025 Wayne Lin
2025-02-25  6:35 ` [PATCH 01/27] drm/amd/display: Request HW cursor on DCN3.2 with SubVP Wayne Lin
2025-02-25  6:35 ` [PATCH 02/27] drm/amd/display: Fix p-state type when p-state is unsupported Wayne Lin
2025-02-25  6:35 ` [PATCH 03/27] drm/amd/display: Fix DMUB reset sequence for DCN401 Wayne Lin
2025-02-25  6:35 ` [PATCH 04/27] drm/amd/display: read mso dpcd caps Wayne Lin
2025-02-25  6:35 ` [PATCH 05/27] drm/amd/display: misc for dio encoder refactor Wayne Lin
2025-02-25  6:35 ` [PATCH 06/27] drm/amd/display: Skip checking FRL_MODE bit for PCON BW determination Wayne Lin
2025-02-25  6:35 ` [PATCH 07/27] drm/amd/display: Remove unused struct definition Wayne Lin
2025-02-25  6:35 ` [PATCH 08/27] drm/amd/display: Check NULL connector before it is used Wayne Lin
2025-02-25  6:35 ` [PATCH 09/27] drm/amd/display: Revert "Increase halt timeout for DMCUB to 1s" Wayne Lin
2025-02-25  6:35 ` [PATCH 10/27] drm/amd/display: Ensure DMCUB idle before reset on DCN31/DCN35 Wayne Lin
2025-02-25  6:35 ` Wayne Lin [this message]
2025-02-25  6:35 ` [PATCH 12/27] drm/amd/display: wait for outstanding hw updates Wayne Lin
2025-02-25  6:35 ` [PATCH 13/27] drm/amd/display: Add tunneling IRQ handler Wayne Lin
2025-02-25  6:35 ` [PATCH 14/27] drm/amd/display: Change amdgpu_dm_irq_suspend() to void Wayne Lin
2025-02-25  6:35 ` [PATCH 15/27] drm/amd/display: Drop `ret` variable from dm_suspend() Wayne Lin
2025-02-25  6:35 ` [PATCH 16/27] drm/amd/display: Catch failures for amdgpu_dm_commit_zero_streams() Wayne Lin
2025-02-25  6:36 ` [PATCH 17/27] drm/amd/display: Use _free() macro " Wayne Lin
2025-02-25  6:36 ` [PATCH 18/27] drm/amd/display: Use drm_err() instead of DRM_ERROR in dm_resume() Wayne Lin
2025-02-25  6:36 ` [PATCH 19/27] drm/amd/display: Use scoped guard for dm_resume() Wayne Lin
2025-02-25  6:36 ` [PATCH 20/27] drm/amd/display: Change amdgpu_dm_irq_resume_*() to use drm_dbg() Wayne Lin
2025-02-25  6:36 ` [PATCH 21/27] drm/amd/display: Change amdgpu_dm_irq_resume_*() to void Wayne Lin
2025-02-25  6:36 ` [PATCH 22/27] drm/amd/display: Use _free(kfree) for dm_gpureset_commit_state() Wayne Lin
2025-02-25  6:36 ` [PATCH 23/27] drm/amd/display: Use scoped guard for amdgpu_dm_update_connector_after_detect() Wayne Lin
2025-02-25  6:36 ` [PATCH 24/27] drm/amd/display: Use _free() macro " Wayne Lin
2025-02-25  6:36 ` [PATCH 25/27] drm/amd/display: Use scoped guards for handle_hpd_irq_helper() Wayne Lin
2025-02-25  6:36 ` [PATCH 26/27] drm/amd/display: Use drm_err() " Wayne Lin
2025-02-25  6:36 ` [PATCH 27/27] drm/amd/display: Promote DAL to 3.2.323 Wayne 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=20250225063610.631461-12-Wayne.Lin@amd.com \
    --to=wayne.lin@amd.com \
    --cc=Leo.Zeng@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=dillon.varone@amd.com \
    --cc=harry.wentland@amd.com \
    --cc=jerry.zuo@amd.com \
    --cc=roman.li@amd.com \
    --cc=solomon.chiu@amd.com \
    --cc=sunpeng.li@amd.com \
    --cc=zaeem.mohamed@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.