Skip to contentSkip to conversation

drm/amd/display: log color state for DCN401

PATCH New Melissa Wen 1 participant 1 message Apr 25, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/display: log color state for DCN401

Add missing DTN logs for DCN401 to improve debugging tools. There is no DPP gamut_remap log: from ddp_set_gamut_remap = NULL, there is no DPP gamut_remap. Also, log doesn't say anything yet about the position of MPC shaper+3dlut+blndlut, that can be set before or after blending in this hw version. This moviment is also the reason that there is no log for DPP shaper+3dlut+blndlut too.

---
 .../amd/display/dc/dpp/dcn401/dcn401_dpp.c    |  16 ++-
 .../amd/display/dc/hwss/dcn401/dcn401_hwseq.c | 120 ++++++++++++++++++
 .../amd/display/dc/hwss/dcn401/dcn401_hwseq.h |   3 +
 .../amd/display/dc/hwss/dcn401/dcn401_init.c  |   1 +
 .../amd/display/dc/mpc/dcn401/dcn401_mpc.c    |  32 ++++-
 5 files changed, 169 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/dpp/dcn401/dcn401_dpp.c +14 -2
index 97bf26fa3573..b89e35d2bc0c 100644
@@ -44,12 +44,24 @@
 
 void dpp401_read_state(struct dpp *dpp_base, struct dcn_dpp_state *s)
 {
-	struct dcn3_dpp *dpp = TO_DCN30_DPP(dpp_base);
+	struct dcn401_dpp *dpp = TO_DCN401_DPP(dpp_base);
+	uint32_t gamcor_lut_mode;
 
 	REG_GET(DPP_CONTROL,
 		DPP_CLOCK_ENABLE, &s->is_enabled);
+	// Pre-degamma (ROM)
+	REG_GET_2(PRE_DEGAM,
+		  PRE_DEGAM_MODE, &s->pre_dgam_mode,
+		  PRE_DEGAM_SELECT, &s->pre_dgam_select);
 
-	// TODO: Implement for DCN4
+	// Gamma Correction (RAM)
+	REG_GET(CM_GAMCOR_CONTROL,
+		CM_GAMCOR_MODE_CURRENT, &s->gamcor_mode);
+	if (s->gamcor_mode) {
+		REG_GET(CM_GAMCOR_CONTROL, CM_GAMCOR_SELECT_CURRENT, &gamcor_lut_mode);
+		if (!gamcor_lut_mode)
+			s->gamcor_mode = LUT_RAM_A; // Otherwise, LUT_RAM_B
+	}
 }
 
 void dpp401_dpp_setup(
drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_hwseq.c +120 -0

132 lines not on this page · raw message

drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_hwseq.h +3 -0
index ce65b4f6c672..5a6c6c6ff66e 100644
@@ -35,6 +35,9 @@ void dcn401_program_gamut_remap(struct pipe_ctx *pipe_ctx);
 
 void dcn401_init_hw(struct dc *dc);
 
+void dcn401_log_color_state(struct dc *dc,
+			    struct dc_log_buffer_ctx *log_ctx);
+
 bool dcn401_set_mcm_luts(struct pipe_ctx *pipe_ctx,
 				const struct dc_plane_state *plane_state);
 bool dcn401_set_output_transfer_func(struct dc *dc,
drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_init.c +1 -0
index fe7aceb2f510..839bafa1df34 100644
@@ -50,6 +50,7 @@ static const struct hw_sequencer_funcs dcn401_funcs = {
 	.setup_stereo = dcn10_setup_stereo,
 	.set_avmute = dcn30_set_avmute,
 	.log_hw_state = dcn10_log_hw_state,
+	.log_color_state = dcn401_log_color_state,
 	.get_hw_state = dcn10_get_hw_state,
 	.clear_status_bits = dcn10_clear_status_bits,
 	.wait_for_mpcc_disconnect = dcn10_wait_for_mpcc_disconnect,
drivers/gpu/drm/amd/display/dc/mpc/dcn401/dcn401_mpc.c +31 -1
index 98cf0cbd59ba..ba36465e0b79 100644
@@ -575,8 +575,38 @@ void mpc401_get_gamut_remap(struct mpc *mpc,
 		arr_reg_val, ARRAY_SIZE(arr_reg_val));
 }
 
+static void mpc401_read_mpcc_state(struct mpc *mpc,
+				   int mpcc_inst,
+				   struct mpcc_state *s)
+{
+	struct dcn401_mpc *mpc401 = TO_DCN401_MPC(mpc);
+
+	REG_GET(MPCC_OPP_ID[mpcc_inst], MPCC_OPP_ID, &s->opp_id);
+	REG_GET(MPCC_TOP_SEL[mpcc_inst], MPCC_TOP_SEL, &s->dpp_id);
+	REG_GET(MPCC_BOT_SEL[mpcc_inst], MPCC_BOT_SEL, &s->bot_mpcc_id);
+	REG_GET_4(MPCC_CONTROL[mpcc_inst], MPCC_MODE, &s->mode,
+			MPCC_ALPHA_BLND_MODE, &s->alpha_mode,
+			MPCC_ALPHA_MULTIPLIED_MODE, &s->pre_multiplied_alpha,
+			MPCC_BLND_ACTIVE_OVERLAP_ONLY, &s->overlap_only);
+	REG_GET_2(MPCC_STATUS[mpcc_inst], MPCC_IDLE, &s->idle,
+			MPCC_BUSY, &s->busy);
+
+	/* Color blocks state */
+	REG_GET(MPCC_MCM_SHAPER_CONTROL[mpcc_inst], MPCC_MCM_SHAPER_MODE_CURRENT, &s->shaper_lut_mode);
+	REG_GET(MPCC_MCM_3DLUT_MODE[mpcc_inst],
+		MPCC_MCM_3DLUT_MODE_CURRENT,  &s->lut3d_mode);
+	REG_GET(MPCC_MCM_3DLUT_READ_WRITE_CONTROL[mpcc_inst],
+		MPCC_MCM_3DLUT_30BIT_EN, &s->lut3d_bit_depth);
+	REG_GET(MPCC_MCM_3DLUT_MODE[mpcc_inst], MPCC_MCM_3DLUT_SIZE, &s->lut3d_size);
+	REG_GET(MPCC_MCM_1DLUT_CONTROL[mpcc_inst],
+		MPCC_MCM_1DLUT_MODE_CURRENT, &s->rgam_mode);
+	REG_GET(MPCC_MCM_1DLUT_CONTROL[mpcc_inst],
+		MPCC_MCM_1DLUT_SELECT_CURRENT, &s->rgam_lut);
+
+}
+
 static const struct mpc_funcs dcn401_mpc_funcs = {
-	.read_mpcc_state = mpc1_read_mpcc_state,
+	.read_mpcc_state = mpc401_read_mpcc_state,
 	.insert_plane = mpc1_insert_plane,
 	.remove_mpcc = mpc1_remove_mpcc,
 	.mpc_init = mpc32_mpc_init,
Signature · 1 line
2.47.2