drm/amd/display: set stream gamut remap matrix to MPC for DCN3+
Subsystems (3)
PATCH 1/1 drm/amd/display: set stream gamut remap matrix to MPC for DCN3+
dc->caps.color.mpc.gamut_remap says there is a post-blending color block for gamut remap matrix for DCN3 HW family and newer versions. However, those drivers still follow DCN10 programming that remap stream gamut_remap_matrix to DPP (pre-blending).
To enable pre-blending and post-blending gamut_remap matrix supports at the same time, set stream gamut_remap to MPC and plane gamut_remap to DPP for DCN families that support both.
It was tested using IGT KMS color tests for DRM CRTC CTM property and it preserves test results.
---
Hi,
Two relevant things to consider for this change. One is that mapping DRM CRTC CTM to MPC is a more consistent way since CRTC CTM is a post-blending transformation. Second, programming stream gamut_remap_matrix on MPC enables us to provide support for both plane CTM and CRTC CTM color properties. If we don't make this separation, we would need to reject an atomic commit that tries to set both properties at the same time and userspace may also get unexpected results.
Thanks in advance for any feeback,
Melissa
.../drm/amd/display/dc/dcn30/dcn30_hwseq.c | 37 +++++++++++++++++++ .../drm/amd/display/dc/dcn30/dcn30_hwseq.h | 3 ++ .../gpu/drm/amd/display/dc/dcn30/dcn30_init.c | 2 +- .../drm/amd/display/dc/dcn301/dcn301_init.c | 2 +- .../gpu/drm/amd/display/dc/dcn31/dcn31_init.c | 2 +- .../drm/amd/display/dc/dcn314/dcn314_init.c | 2 +- .../gpu/drm/amd/display/dc/dcn32/dcn32_init.c | 2 +- 7 files changed, 45 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c +37 -0
@@ -186,6 +186,43 @@ bool dcn30_set_input_transfer_func(struct dc *dc,return result; } +void dcn30_program_gamut_remap (struct pipe_ctx *pipe_ctx) +{ +int i =0 ; +struct dpp_grph_csc_adjustment dpp_adjust; +struct mpc_grph_gamut_adjustment mpc_adjust; +int mpcc_id = pipe_ctx->plane_res.hubp->inst; +struct mpc *mpc = pipe_ctx->stream_res.opp->ctx->dc->res_pool->mpc; + +memset (&dpp_adjust,0 ,sizeof (dpp_adjust)); + dpp_adjust.gamut_adjust_type =GRAPHICS_GAMUT_ADJUST_TYPE_BYPASS ; + +if (pipe_ctx->plane_state && + pipe_ctx->plane_state->gamut_remap_matrix.enable_remap == true) { + dpp_adjust.gamut_adjust_type =GRAPHICS_GAMUT_ADJUST_TYPE_SW ; +for (i =0 ; i <CSC_TEMPERATURE_MATRIX_SIZE ; i++) + dpp_adjust.temperature_matrix[i] = + pipe_ctx->plane_state->gamut_remap_matrix.matrix[i]; + } + + pipe_ctx->plane_res.dpp->funcs->dpp_set_gamut_remap (pipe_ctx->plane_res.dpp, + &dpp_adjust); + +memset (&mpc_adjust,0 ,sizeof (mpc_adjust)); + mpc_adjust.gamut_adjust_type =GRAPHICS_GAMUT_ADJUST_TYPE_BYPASS ; + +if (pipe_ctx->top_pipe ==NULL ) { +if (pipe_ctx->stream->gamut_remap_matrix.enable_remap == true) { + mpc_adjust.gamut_adjust_type =GRAPHICS_GAMUT_ADJUST_TYPE_SW ; +for (i =0 ; i <CSC_TEMPERATURE_MATRIX_SIZE ; i++) + mpc_adjust.temperature_matrix[i] = + pipe_ctx->stream->gamut_remap_matrix.matrix[i]; + } + } + + mpc->funcs->set_gamut_remap (mpc, mpcc_id, &mpc_adjust); +} +bool dcn30_set_output_transfer_func (struct dc *dc,struct pipe_ctx *pipe_ctx,const struct dc_stream_state *stream)
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.h +3 -0
@@ -58,6 +58,9 @@ bool dcn30_set_blend_lut(struct pipe_ctx *pipe_ctx,bool dcn30_set_input_transfer_func (struct dc *dc,struct pipe_ctx *pipe_ctx,const struct dc_plane_state *plane_state); + +void dcn30_program_gamut_remap (struct pipe_ctx *pipe_ctx); +bool dcn30_set_output_transfer_func (struct dc *dc,struct pipe_ctx *pipe_ctx,const struct dc_stream_state *stream);
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_init.c +1 -1
@@ -32,7 +32,7 @@#include "dcn30_init.h" static const struct hw_sequencer_funcs dcn30_funcs = { - .program_gamut_remap = dcn10_program_gamut_remap, + .program_gamut_remap = dcn30_program_gamut_remap, .init_hw = dcn30_init_hw, .apply_ctx_to_hw = dce110_apply_ctx_to_hw, .apply_ctx_for_surface =NULL ,
drivers/gpu/drm/amd/display/dc/dcn301/dcn301_init.c +1 -1
@@ -33,7 +33,7 @@#include "dcn301_init.h" static const struct hw_sequencer_funcs dcn301_funcs = { - .program_gamut_remap = dcn10_program_gamut_remap, + .program_gamut_remap = dcn30_program_gamut_remap, .init_hw = dcn10_init_hw, .power_down_on_boot = dcn10_power_down_on_boot, .apply_ctx_to_hw = dce110_apply_ctx_to_hw,
drivers/gpu/drm/amd/display/dc/dcn31/dcn31_init.c +1 -1
@@ -34,7 +34,7 @@#include "dcn31_init.h" static const struct hw_sequencer_funcs dcn31_funcs = { - .program_gamut_remap = dcn10_program_gamut_remap, + .program_gamut_remap = dcn30_program_gamut_remap, .init_hw = dcn31_init_hw, .power_down_on_boot = dcn10_power_down_on_boot, .apply_ctx_to_hw = dce110_apply_ctx_to_hw,
drivers/gpu/drm/amd/display/dc/dcn314/dcn314_init.c +1 -1
@@ -36,7 +36,7 @@#include "dcn314_init.h" static const struct hw_sequencer_funcs dcn314_funcs = { - .program_gamut_remap = dcn10_program_gamut_remap, + .program_gamut_remap = dcn30_program_gamut_remap, .init_hw = dcn31_init_hw, .power_down_on_boot = dcn10_power_down_on_boot, .apply_ctx_to_hw = dce110_apply_ctx_to_hw,
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_init.c +1 -1
@@ -33,7 +33,7 @@#include "dcn32_init.h" static const struct hw_sequencer_funcs dcn32_funcs = { - .program_gamut_remap = dcn10_program_gamut_remap, + .program_gamut_remap = dcn30_program_gamut_remap, .init_hw = dcn32_init_hw, .apply_ctx_to_hw = dce110_apply_ctx_to_hw, .apply_ctx_for_surface =NULL ,
Signature · 1 line
2.40.1
Quoted 5 lines · Melissa Wen
dc->caps.color.mpc.gamut_remapsays there is a post-blending color block for gamut remap matrix for DCN3 HW family and newer versions. However, those drivers still follow DCN10 programming that remap streamgamut_remap_matrixto DPP (pre-blending).
Quoted 9 lines
To enable pre-blending and post-blending
gamut_remapmatrix supports at the same time, set streamgamut_remapto MPC and planegamut_remapto DPP for DCN families that support both.It was tested using IGT KMS color tests for DRM CRTC CTM property and it preserves test results.
Signed-off-by Melissa Wen <[email protected]>
and merged.
I also took the liberty to expand this to the recently merged dcn35 code.
Harry
Quoted 152 lines
---
Hi,
Two relevant things to consider for this change. One is that mapping DRM CRTC CTM to MPC is a more consistent way since CRTC CTM is a post-blending transformation. Second, programming stream
gamut_remap_matrixon MPC enables us to provide support for both plane CTM and CRTC CTM color properties. If we don't make this separation, we would need to reject an atomic commit that tries to set both properties at the same time and userspace may also get unexpected results.Thanks in advance for any feeback,
Melissa
.../drm/amd/display/dc/dcn30/dcn30_hwseq.c | 37 +++++++++++++++++++ .../drm/amd/display/dc/dcn30/dcn30_hwseq.h | 3 ++ .../gpu/drm/amd/display/dc/dcn30/dcn30_init.c | 2 +- .../drm/amd/display/dc/dcn301/dcn301_init.c | 2 +- .../gpu/drm/amd/display/dc/dcn31/dcn31_init.c | 2 +- .../drm/amd/display/dc/dcn314/dcn314_init.c | 2 +- .../gpu/drm/amd/display/dc/dcn32/dcn32_init.c | 2 +- 7 files changed, 45 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c +37
-0@@ -186,6 +186,43 @@ bool dcn30_set_input_transfer_func(struct dc *dc,return result; } +void dcn30_program_gamut_remap (struct pipe_ctx *pipe_ctx) +{ +int i =0 ; +struct dpp_grph_csc_adjustment dpp_adjust; +struct mpc_grph_gamut_adjustment mpc_adjust; +int mpcc_id = pipe_ctx->plane_res.hubp->inst; +struct mpc *mpc = pipe_ctx->stream_res.opp->ctx->dc->res_pool->mpc; + +memset (&dpp_adjust,0 ,sizeof (dpp_adjust)); + dpp_adjust.gamut_adjust_type =GRAPHICS_GAMUT_ADJUST_TYPE_BYPASS ; + +if (pipe_ctx->plane_state && + pipe_ctx->plane_state->gamut_remap_matrix.enable_remap == true) { + dpp_adjust.gamut_adjust_type =GRAPHICS_GAMUT_ADJUST_TYPE_SW ; +for (i =0 ; i <CSC_TEMPERATURE_MATRIX_SIZE ; i++) + dpp_adjust.temperature_matrix[i] = + pipe_ctx->plane_state->gamut_remap_matrix.matrix[i]; + } + + pipe_ctx->plane_res.dpp->funcs->dpp_set_gamut_remap (pipe_ctx->plane_res.dpp, + &dpp_adjust); + +memset (&mpc_adjust,0 ,sizeof (mpc_adjust)); + mpc_adjust.gamut_adjust_type =GRAPHICS_GAMUT_ADJUST_TYPE_BYPASS ; + +if (pipe_ctx->top_pipe ==NULL ) { +if (pipe_ctx->stream->gamut_remap_matrix.enable_remap == true) { + mpc_adjust.gamut_adjust_type =GRAPHICS_GAMUT_ADJUST_TYPE_SW ; +for (i =0 ; i <CSC_TEMPERATURE_MATRIX_SIZE ; i++) + mpc_adjust.temperature_matrix[i] = + pipe_ctx->stream->gamut_remap_matrix.matrix[i]; + } + } + + mpc->funcs->set_gamut_remap (mpc, mpcc_id, &mpc_adjust); +} +bool dcn30_set_output_transfer_func (struct dc *dc,struct pipe_ctx *pipe_ctx,const struct dc_stream_state *stream)drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.h +3
-0@@ -58,6 +58,9 @@ bool dcn30_set_blend_lut(struct pipe_ctx *pipe_ctx,bool dcn30_set_input_transfer_func (struct dc *dc,struct pipe_ctx *pipe_ctx,const struct dc_plane_state *plane_state); + +void dcn30_program_gamut_remap (struct pipe_ctx *pipe_ctx); +bool dcn30_set_output_transfer_func (struct dc *dc,struct pipe_ctx *pipe_ctx,const struct dc_stream_state *stream);drivers/gpu/drm/amd/display/dc/dcn30/dcn30_init.c +1
-1@@ -32,7 +32,7 @@#include "dcn30_init.h" static const struct hw_sequencer_funcs dcn30_funcs = { - .program_gamut_remap = dcn10_program_gamut_remap, + .program_gamut_remap = dcn30_program_gamut_remap, .init_hw = dcn30_init_hw, .apply_ctx_to_hw = dce110_apply_ctx_to_hw, .apply_ctx_for_surface =NULL ,drivers/gpu/drm/amd/display/dc/dcn301/dcn301_init.c +1
-1@@ -33,7 +33,7 @@#include "dcn301_init.h" static const struct hw_sequencer_funcs dcn301_funcs = { - .program_gamut_remap = dcn10_program_gamut_remap, + .program_gamut_remap = dcn30_program_gamut_remap, .init_hw = dcn10_init_hw, .power_down_on_boot = dcn10_power_down_on_boot, .apply_ctx_to_hw = dce110_apply_ctx_to_hw,drivers/gpu/drm/amd/display/dc/dcn31/dcn31_init.c +1
-1@@ -34,7 +34,7 @@#include "dcn31_init.h" static const struct hw_sequencer_funcs dcn31_funcs = { - .program_gamut_remap = dcn10_program_gamut_remap, + .program_gamut_remap = dcn30_program_gamut_remap, .init_hw = dcn31_init_hw, .power_down_on_boot = dcn10_power_down_on_boot, .apply_ctx_to_hw = dce110_apply_ctx_to_hw,drivers/gpu/drm/amd/display/dc/dcn314/dcn314_init.c +1
-1@@ -36,7 +36,7 @@#include "dcn314_init.h" static const struct hw_sequencer_funcs dcn314_funcs = { - .program_gamut_remap = dcn10_program_gamut_remap, + .program_gamut_remap = dcn30_program_gamut_remap, .init_hw = dcn31_init_hw, .power_down_on_boot = dcn10_power_down_on_boot, .apply_ctx_to_hw = dce110_apply_ctx_to_hw,drivers/gpu/drm/amd/display/dc/dcn32/dcn32_init.c +1
-1@@ -33,7 +33,7 @@#include "dcn32_init.h" static const struct hw_sequencer_funcs dcn32_funcs = { - .program_gamut_remap = dcn10_program_gamut_remap, + .program_gamut_remap = dcn30_program_gamut_remap, .init_hw = dcn32_init_hw, .apply_ctx_to_hw = dce110_apply_ctx_to_hw, .apply_ctx_for_surface =NULL ,
Quoted 18 lines · Harry Wentland
Quoted 5 lines · Melissa Wen
dc->caps.color.mpc.gamut_remapsays there is a post-blending color block for gamut remap matrix for DCN3 HW family and newer versions. However, those drivers still follow DCN10 programming that remap streamgamut_remap_matrixto DPP (pre-blending).Quoted 9 lines
To enable pre-blending and post-blending
gamut_remapmatrix supports at the same time, set streamgamut_remapto MPC and planegamut_remapto DPP for DCN families that support both.It was tested using IGT KMS color tests for DRM CRTC CTM property and it preserves test results.
Signed-off-by Melissa Wen <[email protected]>
Quoted 6 lines
Reviewed-by Harry Wentland <[email protected]>and merged.
I also took the liberty to expand this to the recently merged dcn35 code.
No problem. Thank you!
With this change merged, I also removed the related patch from the series of AMD driver-specific color props.
Melissa
Quoted 156 lines
Harry
Quoted 152 lines
---
Hi,
Two relevant things to consider for this change. One is that mapping DRM CRTC CTM to MPC is a more consistent way since CRTC CTM is a post-blending transformation. Second, programming stream
gamut_remap_matrixon MPC enables us to provide support for both plane CTM and CRTC CTM color properties. If we don't make this separation, we would need to reject an atomic commit that tries to set both properties at the same time and userspace may also get unexpected results.Thanks in advance for any feeback,
Melissa
.../drm/amd/display/dc/dcn30/dcn30_hwseq.c | 37 +++++++++++++++++++ .../drm/amd/display/dc/dcn30/dcn30_hwseq.h | 3 ++ .../gpu/drm/amd/display/dc/dcn30/dcn30_init.c | 2 +- .../drm/amd/display/dc/dcn301/dcn301_init.c | 2 +- .../gpu/drm/amd/display/dc/dcn31/dcn31_init.c | 2 +- .../drm/amd/display/dc/dcn314/dcn314_init.c | 2 +- .../gpu/drm/amd/display/dc/dcn32/dcn32_init.c | 2 +- 7 files changed, 45 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c +37
-0@@ -186,6 +186,43 @@ bool dcn30_set_input_transfer_func(struct dc *dc,return result; } +void dcn30_program_gamut_remap (struct pipe_ctx *pipe_ctx) +{ +int i =0 ; +struct dpp_grph_csc_adjustment dpp_adjust; +struct mpc_grph_gamut_adjustment mpc_adjust; +int mpcc_id = pipe_ctx->plane_res.hubp->inst; +struct mpc *mpc = pipe_ctx->stream_res.opp->ctx->dc->res_pool->mpc; + +memset (&dpp_adjust,0 ,sizeof (dpp_adjust)); + dpp_adjust.gamut_adjust_type =GRAPHICS_GAMUT_ADJUST_TYPE_BYPASS ; + +if (pipe_ctx->plane_state && + pipe_ctx->plane_state->gamut_remap_matrix.enable_remap == true) { + dpp_adjust.gamut_adjust_type =GRAPHICS_GAMUT_ADJUST_TYPE_SW ; +for (i =0 ; i <CSC_TEMPERATURE_MATRIX_SIZE ; i++) + dpp_adjust.temperature_matrix[i] = + pipe_ctx->plane_state->gamut_remap_matrix.matrix[i]; + } + + pipe_ctx->plane_res.dpp->funcs->dpp_set_gamut_remap (pipe_ctx->plane_res.dpp, + &dpp_adjust); + +memset (&mpc_adjust,0 ,sizeof (mpc_adjust)); + mpc_adjust.gamut_adjust_type =GRAPHICS_GAMUT_ADJUST_TYPE_BYPASS ; + +if (pipe_ctx->top_pipe ==NULL ) { +if (pipe_ctx->stream->gamut_remap_matrix.enable_remap == true) { + mpc_adjust.gamut_adjust_type =GRAPHICS_GAMUT_ADJUST_TYPE_SW ; +for (i =0 ; i <CSC_TEMPERATURE_MATRIX_SIZE ; i++) + mpc_adjust.temperature_matrix[i] = + pipe_ctx->stream->gamut_remap_matrix.matrix[i]; + } + } + + mpc->funcs->set_gamut_remap (mpc, mpcc_id, &mpc_adjust); +} +bool dcn30_set_output_transfer_func (struct dc *dc,struct pipe_ctx *pipe_ctx,const struct dc_stream_state *stream)drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.h +3
-0@@ -58,6 +58,9 @@ bool dcn30_set_blend_lut(struct pipe_ctx *pipe_ctx,bool dcn30_set_input_transfer_func (struct dc *dc,struct pipe_ctx *pipe_ctx,const struct dc_plane_state *plane_state); + +void dcn30_program_gamut_remap (struct pipe_ctx *pipe_ctx); +bool dcn30_set_output_transfer_func (struct dc *dc,struct pipe_ctx *pipe_ctx,const struct dc_stream_state *stream);drivers/gpu/drm/amd/display/dc/dcn30/dcn30_init.c +1
-1@@ -32,7 +32,7 @@#include "dcn30_init.h" static const struct hw_sequencer_funcs dcn30_funcs = { - .program_gamut_remap = dcn10_program_gamut_remap, + .program_gamut_remap = dcn30_program_gamut_remap, .init_hw = dcn30_init_hw, .apply_ctx_to_hw = dce110_apply_ctx_to_hw, .apply_ctx_for_surface =NULL ,drivers/gpu/drm/amd/display/dc/dcn301/dcn301_init.c +1
-1@@ -33,7 +33,7 @@#include "dcn301_init.h" static const struct hw_sequencer_funcs dcn301_funcs = { - .program_gamut_remap = dcn10_program_gamut_remap, + .program_gamut_remap = dcn30_program_gamut_remap, .init_hw = dcn10_init_hw, .power_down_on_boot = dcn10_power_down_on_boot, .apply_ctx_to_hw = dce110_apply_ctx_to_hw,drivers/gpu/drm/amd/display/dc/dcn31/dcn31_init.c +1
-1@@ -34,7 +34,7 @@#include "dcn31_init.h" static const struct hw_sequencer_funcs dcn31_funcs = { - .program_gamut_remap = dcn10_program_gamut_remap, + .program_gamut_remap = dcn30_program_gamut_remap, .init_hw = dcn31_init_hw, .power_down_on_boot = dcn10_power_down_on_boot, .apply_ctx_to_hw = dce110_apply_ctx_to_hw,drivers/gpu/drm/amd/display/dc/dcn314/dcn314_init.c +1
-1@@ -36,7 +36,7 @@#include "dcn314_init.h" static const struct hw_sequencer_funcs dcn314_funcs = { - .program_gamut_remap = dcn10_program_gamut_remap, + .program_gamut_remap = dcn30_program_gamut_remap, .init_hw = dcn31_init_hw, .power_down_on_boot = dcn10_power_down_on_boot, .apply_ctx_to_hw = dce110_apply_ctx_to_hw,drivers/gpu/drm/amd/display/dc/dcn32/dcn32_init.c +1
-1@@ -33,7 +33,7 @@#include "dcn32_init.h" static const struct hw_sequencer_funcs dcn32_funcs = { - .program_gamut_remap = dcn10_program_gamut_remap, + .program_gamut_remap = dcn30_program_gamut_remap, .init_hw = dcn32_init_hw, .apply_ctx_to_hw = dce110_apply_ctx_to_hw, .apply_ctx_for_surface =NULL ,