drm/amd/display: Get visual confirm color for stream
authorLeo Zeng <Leo.Zeng@amd.com>
Wed, 26 Feb 2025 19:35:05 +0000 (14:35 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 7 Apr 2025 19:18:30 +0000 (15:18 -0400)
[WHY]
We want to output visual confirm color based on stream.

[HOW]
If visual confirm is for DMUB, use DMUB to get color.
Otherwise, find plane with highest layer index, output visual confirm color
of pipe that contains plane with highest index.

Reviewed-by: Aric Cyr <aric.cyr@amd.com>
Signed-off-by: Leo Zeng <Leo.Zeng@amd.com>
Signed-off-by: Aurabindo Pillai <aurabindo.pillai@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/core/dc.c
drivers/gpu/drm/amd/display/dc/dc.h
drivers/gpu/drm/amd/display/dc/hwss/dcn10/dcn10_hwseq.c

index 5a44f5da68dcc5eae887429cda16681cac0d5616..be63cc4aca1f555ea655dbf72cc081580d5c6f2e 100644 (file)
@@ -1231,6 +1231,51 @@ static void dc_update_visual_confirm_color(struct dc *dc, struct dc_state *conte
        }
 }
 
+void dc_get_visual_confirm_for_stream(
+       struct dc *dc,
+       struct dc_stream_state *stream_state,
+       struct tg_color *color)
+{
+       struct dc_stream_status *stream_status = dc_stream_get_status(stream_state);
+       struct pipe_ctx *pipe_ctx;
+       int i;
+       struct dc_plane_state *plane_state = NULL;
+
+       if (!stream_status)
+               return;
+
+       switch (dc->debug.visual_confirm) {
+       case VISUAL_CONFIRM_DISABLE:
+               return;
+       case VISUAL_CONFIRM_PSR:
+       case VISUAL_CONFIRM_FAMS:
+               pipe_ctx = dc_stream_get_pipe_ctx(stream_state);
+               if (!pipe_ctx)
+                       return;
+               dc_dmub_srv_get_visual_confirm_color_cmd(dc, pipe_ctx);
+               memcpy(color, &dc->ctx->dmub_srv->dmub->visual_confirm_color, sizeof(struct tg_color));
+               return;
+
+       default:
+               /* find plane with highest layer_index */
+               for (i = 0; i < stream_status->plane_count; i++) {
+                       if (stream_status->plane_states[i]->visible)
+                               plane_state = stream_status->plane_states[i];
+               }
+               if (!plane_state)
+                       return;
+               /* find pipe that contains plane with highest layer index */
+               for (i = 0; i < MAX_PIPES; i++) {
+                       struct pipe_ctx *pipe = &dc->current_state->res_ctx.pipe_ctx[i];
+
+                       if (pipe->plane_state == plane_state) {
+                               memcpy(color, &pipe->visual_confirm_color, sizeof(struct tg_color));
+                               return;
+                       }
+               }
+       }
+}
+
 static void disable_dangling_plane(struct dc *dc, struct dc_state *context)
 {
        int i, j;
index 78dd4d1f51dca3ae5555129d80a00a9d16b26b68..be2518e07c14b90523703487450ace5bd3188783 100644 (file)
@@ -2590,6 +2590,11 @@ unsigned int dc_get_det_buffer_size_from_state(const struct dc_state *context);
 /* DSC Interfaces */
 #include "dc_dsc.h"
 
+void dc_get_visual_confirm_for_stream(
+       struct dc *dc,
+       struct dc_stream_state *stream_state,
+       struct tg_color *color);
+
 /* Disable acc mode Interfaces */
 void dc_disable_accelerated_mode(struct dc *dc);
 
index 912f96323ed6ad3e5d3060b497e5410e608a3578..e34a93b703a7a5ab7db186a27930ec9ba7a91c49 100644 (file)
@@ -2664,7 +2664,6 @@ void dcn10_update_visual_confirm_color(struct dc *dc,
        struct mpc *mpc = dc->res_pool->mpc;
 
        if (mpc->funcs->set_bg_color) {
-               memcpy(&pipe_ctx->plane_state->visual_confirm_color, &(pipe_ctx->visual_confirm_color), sizeof(struct tg_color));
                mpc->funcs->set_bg_color(mpc, &(pipe_ctx->visual_confirm_color), mpcc_id);
        }
 }