<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Arial;font-size:10pt;color:#0078D7;margin:15pt;" align="Left">
[AMD Official Use Only - Internal Distribution Only]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Reviewed-by: <font size="2"><span style="font-size:11pt">Bhawanpreet Lakha <Bhawanpreet.Lakha@amd.com></span></font>
<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Nicholas Kazlauskas <nicholas.kazlauskas@amd.com><br>
<b>Sent:</b> July 8, 2020 4:34 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Kazlauskas, Nicholas <Nicholas.Kazlauskas@amd.com>; Lakha, Bhawanpreet <Bhawanpreet.Lakha@amd.com>; Cyr, Aric <Aric.Cyr@amd.com><br>
<b>Subject:</b> [PATCH] drm/amd/display: Fix CSC remap matrix not being applied on dcn30</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">[Why]<br>
DCN3 has two gamut remap matrices. When using CSC adjustment the CM<br>
remap is set to bypass and MPCC remap is used. However to bypass CM<br>
some state in the context is modified and not restored correctly<br>
resulting in subsequent calls to disable MPCC remap as well.<br>
<br>
[How]<br>
Fix logic for save/restore of remap enable flag when programming MPCC<br>
remap matrix.<br>
<br>
Cc: Bhawanpreet Lakha <Bhawanpreet.Lakha@amd.com><br>
Signed-off-by: Aric Cyr <aric.cyr@amd.com><br>
Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com><br>
---<br>
 .../drm/amd/display/dc/dcn20/dcn20_hwseq.c    | 27 ++++++++++---------<br>
 1 file changed, 14 insertions(+), 13 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c<br>
index 5621c95177d2..7725a406c16e 100644<br>
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c<br>
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c<br>
@@ -1482,22 +1482,23 @@ static void dcn20_update_dchubp_dpp(<br>
 <br>
                         memset(&adjust, 0, sizeof(adjust));<br>
                         adjust.gamut_adjust_type = GRAPHICS_GAMUT_ADJUST_TYPE_BYPASS;<br>
-                       /* save the enablement of gamut remap for dpp*/<br>
+<br>
+                       /* save the enablement of gamut remap for dpp */<br>
                         enable_remap_dpp = pipe_ctx->stream->gamut_remap_matrix.enable_remap;<br>
-                       /*force bypass gamut remap for dpp/cm*/<br>
+<br>
+                       /* force bypass gamut remap for dpp/cm */<br>
                         pipe_ctx->stream->gamut_remap_matrix.enable_remap = false;<br>
                         dc->hwss.program_gamut_remap(pipe_ctx);<br>
-                       /*restore gamut remap flag for the top plane and use this remap into mpc*/<br>
-                       if (pipe_ctx->top_pipe == NULL)<br>
-                               pipe_ctx->stream->gamut_remap_matrix.enable_remap = enable_remap_dpp;<br>
-                       else<br>
-                               pipe_ctx->stream->gamut_remap_matrix.enable_remap = false;<br>
-<br>
-                       if (pipe_ctx->stream->gamut_remap_matrix.enable_remap == true) {<br>
-                               adjust.gamut_adjust_type = GRAPHICS_GAMUT_ADJUST_TYPE_SW;<br>
-                               for (i = 0; i < CSC_TEMPERATURE_MATRIX_SIZE; i++)<br>
-                                       adjust.temperature_matrix[i] =<br>
-                                               pipe_ctx->stream->gamut_remap_matrix.matrix[i];<br>
+<br>
+                       /* restore gamut remap flag and use this remap into mpc */<br>
+                       pipe_ctx->stream->gamut_remap_matrix.enable_remap = enable_remap_dpp;<br>
+<br>
+                       /* build remap matrix for top plane if enabled */<br>
+                       if (enable_remap_dpp && pipe_ctx->top_pipe == NULL) {<br>
+                                       adjust.gamut_adjust_type = GRAPHICS_GAMUT_ADJUST_TYPE_SW;<br>
+                                       for (i = 0; i < CSC_TEMPERATURE_MATRIX_SIZE; i++)<br>
+                                               adjust.temperature_matrix[i] =<br>
+                                                               pipe_ctx->stream->gamut_remap_matrix.matrix[i];<br>
                         }<br>
                         mpc->funcs->set_gamut_remap(mpc, mpcc_id, &adjust);<br>
                 } else<br>
-- <br>
2.25.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>