drm/amd/display: Fix Color Manager (3DLUT, Shaper, Blend)
Alex Deucher
maintainerPATCH 1/1 drm/amd/display: Fix Color Manager (3DLUT, Shaper, Blend)
From: Dillon Varone <[email protected]>
[WHY & HOW]
The original refactor and fixes are causing regressions. Revert them for now until they can be resolved
Fixes e56e3cff2a1b ("drm/amd/display: Sync dcn42 with DC 3.2.373")
Reviewed-by Tom Chung <[email protected]>
Signed-off-by Dillon Varone <[email protected]>
Signed-off-by James Lin <[email protected]>
Signed-off-by Alex Deucher <[email protected]>
(cherry picked from commit 12f58a6caad3be54d7788b338b3f57d7c17bbef7)
Cc [email protected] # 7.1.x
--- drivers/gpu/drm/amd/display/dc/core/dc.c | 81 +-- .../gpu/drm/amd/display/dc/core/dc_stream.c | 2 + drivers/gpu/drm/amd/display/dc/dc.h | 58 +- drivers/gpu/drm/amd/display/dc/dc_types.h | 24 - .../amd/display/dc/hubp/dcn401/dcn401_hubp.c | 201 +++---- .../amd/display/dc/hubp/dcn401/dcn401_hubp.h | 23 +- .../amd/display/dc/hubp/dcn42/dcn42_hubp.c | 78 +-- .../amd/display/dc/hubp/dcn42/dcn42_hubp.h | 10 +- .../amd/display/dc/hwss/dcn401/dcn401_hwseq.c | 389 +++++++++----- .../amd/display/dc/hwss/dcn42/dcn42_hwseq.c | 499 ++++++++++++++++-- .../amd/display/dc/hwss/dcn42/dcn42_hwseq.h | 9 +- drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h | 35 +- drivers/gpu/drm/amd/display/dc/inc/hw/mpc.h | 79 ++- .../amd/display/dc/mpc/dcn401/dcn401_mpc.c | 177 +++---- .../amd/display/dc/mpc/dcn401/dcn401_mpc.h | 25 +- .../drm/amd/display/dc/mpc/dcn42/dcn42_mpc.c | 388 ++++++++++++-- .../drm/amd/display/dc/mpc/dcn42/dcn42_mpc.h | 49 +- .../dc/resource/dcn42/dcn42_resource.c | 1 - 18 files changed, 1439 insertions(+), 689 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +50 -31
@@ -2956,27 +2956,16 @@ static struct surface_update_descriptor det_surface_update(elevate_update_type (&overall_type,UPDATE_TYPE_FAST ,LOCK_DESCRIPTOR_STREAM ); } -if (u->cm || (u->gamma &&dce_use_lut (u->plane_info ? u->plane_info->format : u->surface->format))) { +if (u->blend_tf || (u->gamma &&dce_use_lut (u->plane_info ? u->plane_info->format : u->surface->format))) { update_flags->bits.gamma_change =1 ;elevate_update_type (&overall_type,UPDATE_TYPE_FAST ,LOCK_DESCRIPTOR_STREAM ); } -if (u->cm && (u->cm->flags.bits.lut3d_enable || u->surface->cm.flags.bits.lut3d_enable)) { +if (u->lut3d_func || u->func_shaper) { update_flags->bits.lut_3d =1 ;elevate_update_type (&overall_type,UPDATE_TYPE_FAST ,LOCK_DESCRIPTOR_STREAM ); } -if (u->cm && u->cm->flags.bits.lut3d_dma_enable != u->surface->cm.flags.bits.lut3d_dma_enable && - u->cm->flags.bits.lut3d_enable && u->surface->cm.flags.bits.lut3d_enable) { -/* Toggling 3DLUT loading between DMA and Host is illegal */ -BREAK_TO_DEBUGGER (); - } - -if (u->cm && u->cm->flags.bits.lut3d_enable && !u->cm->flags.bits.lut3d_dma_enable) { -/* Host loading 3DLUT requires full update but only stream lock */ -elevate_update_type (&overall_type,UPDATE_TYPE_FULL ,LOCK_DESCRIPTOR_STREAM ); - } -if (u->hdr_mult.value)if (u->hdr_mult.value != u->surface->hdr_mult.value) {// TODO: Should be fast?
@@ -2995,6 +2984,20 @@ static struct surface_update_descriptor det_surface_update( update_flags->bits.cm_hist_change =1 ;elevate_update_type (&overall_type,UPDATE_TYPE_FAST ,LOCK_DESCRIPTOR_STREAM ); } +if (u->cm2_params) { +if (u->cm2_params->component_settings.shaper_3dlut_setting != u->surface->mcm_shaper_3dlut_setting + || u->cm2_params->component_settings.lut1d_enable != u->surface->mcm_lut1d_enable + || u->cm2_params->cm2_luts.lut3d_data.lut3d_src != u->surface->mcm_luts.lut3d_data.lut3d_src) { + update_flags->bits.mcm_transfer_function_enable_change =1 ; +elevate_update_type (&overall_type,UPDATE_TYPE_FULL ,LOCK_DESCRIPTOR_GLOBAL ); + } + } + +if (update_flags->bits.lut_3d && + u->surface->mcm_luts.lut3d_data.lut3d_src !=DC_CM2_TRANSFER_FUNC_SOURCE_VIDMEM ) { +elevate_update_type (&overall_type,UPDATE_TYPE_FULL ,LOCK_DESCRIPTOR_GLOBAL ); + } + if (check_config->enable_legacy_fast_update && (update_flags->bits.gamma_change || update_flags->bits.gamut_remap_change ||
@@ -3250,12 +3253,24 @@ static void copy_surface_update_to_plane( sizeof(struct dc_transfer_func_distributed_points)); } -/* Shaper, 3DLUT, 1DLUT */ -if (srf_update->cm) { -memcpy (&surface->cm, srf_update->cm, -sizeof (surface->cm)); +if (srf_update->cm2_params) { + surface->mcm_shaper_3dlut_setting = srf_update->cm2_params->component_settings.shaper_3dlut_setting; + surface->mcm_lut1d_enable = srf_update->cm2_params->component_settings.lut1d_enable; + surface->mcm_luts = srf_update->cm2_params->cm2_luts; } +if (srf_update->func_shaper) { +memcpy (&surface->in_shaper_func, srf_update->func_shaper, +sizeof (surface->in_shaper_func)); + +if (surface->mcm_shaper_3dlut_setting >=DC_CM2_SHAPER_3DLUT_SETTING_ENABLE_SHAPER ) + surface->mcm_luts.shaper = &surface->in_shaper_func; + } + +if (srf_update->lut3d_func) +memcpy (&surface->lut3d_func, srf_update->lut3d_func, +sizeof (surface->lut3d_func)); +if (srf_update->hdr_mult.value) surface->hdr_mult = srf_update->hdr_mult;
@@ -3264,6 +3279,17 @@ static void copy_surface_update_to_plane( surface->sdr_white_level_nits = srf_update->sdr_white_level_nits; +if (srf_update->blend_tf) { +memcpy (&surface->blend_tf, srf_update->blend_tf, +sizeof (surface->blend_tf)); + +if (surface->mcm_lut1d_enable) + surface->mcm_luts.lut1d_func = &surface->blend_tf; + } + +if (srf_update->cm2_params || srf_update->blend_tf) + surface->lut_bank_a = !surface->lut_bank_a; +if (srf_update->input_csc_color_matrix) surface->input_csc_color_matrix = *srf_update->input_csc_color_matrix;
@@ -4550,9 +4576,11 @@ static void commit_planes_for_stream(struct dc *dc,if (!should_update_pipe_for_plane (context, pipe_ctx, plane_state))continue ; -if (srf_updates[i].cm && - srf_updates[i].cm->flags.bits.lut3d_enable && - srf_updates[i].cm->flags.bits.lut3d_dma_enable && +if (srf_updates[i].cm2_params && + srf_updates[i].cm2_params->cm2_luts.lut3d_data.lut3d_src == +DC_CM2_TRANSFER_FUNC_SOURCE_VIDMEM && + srf_updates[i].cm2_params->component_settings.shaper_3dlut_setting == +DC_CM2_SHAPER_3DLUT_SETTING_ENABLE_SHAPER_3DLUT && dc->hwss.trigger_3dlut_dma_load) dc->hwss.trigger_3dlut_dma_load (dc, pipe_ctx);
@@ -5209,12 +5237,6 @@ static bool full_update_required( const struct dc_stream_update *stream_update, const struct dc_stream_state *stream) { - const union dc_plane_cm_flags blend_only_flags = { - .bits = { - .blend_enable =1 , - } - }; - if (full_update_required_weak(dc, srf_updates, surface_count, stream_update, stream)) return true;
@@ -5229,10 +5251,7 @@ static bool full_update_required( srf_updates[i].in_transfer_func || srf_updates[i].surface->force_full_update || (srf_updates[i].flip_addr && - srf_updates[i].flip_addr->address.tmz_surface != srf_updates[i].surface->address.tmz_surface) || - (srf_updates[i].cm && - ((srf_updates[i].cm->flags.all != blend_only_flags.all && srf_updates[i].cm->flags.all !=0 ) || - (srf_updates[i].surface->cm.flags.all != blend_only_flags.all && srf_updates[i].surface->cm.flags.all != 0))))) + srf_updates[i].flip_addr->address.tmz_surface != srf_updates[i].surface->address.tmz_surface))) return true; }
@@ -6966,7 +6985,7 @@ bool dc_capture_register_software_state(struct dc *dc, struct dc_register_softwastruct dc_plane_state *plane_state = pipe_ctx->plane_state;/* MPCC blending tree and mode control - capture actual blend configuration */ - state->mpc.mpcc_mode[i] = (plane_state->cm.blend_func.type !=TF_TYPE_BYPASS ) ?1 :0 ; + state->mpc.mpcc_mode[i] = (plane_state->blend_tf.type !=TF_TYPE_BYPASS ) ?1 :0 ; state->mpc.mpcc_alpha_blend_mode[i] = plane_state->per_pixel_alpha ?1 :0 ; state->mpc.mpcc_alpha_multiplied_mode[i] = plane_state->pre_multiplied_alpha ?1 :0 ; state->mpc.mpcc_blnd_active_overlap_only[i] =0 ;/* Default - no overlap restriction */
drivers/gpu/drm/amd/display/dc/core/dc_stream.c +2 -0
@@ -996,6 +996,7 @@ void dc_stream_release_3dlut_for_stream(if (rmcm_3dlut) { rmcm_3dlut->isInUse = false; rmcm_3dlut->stream =NULL ; + rmcm_3dlut->protection_bits =0 ; } }
@@ -1007,6 +1008,7 @@ void dc_stream_init_rmcm_3dlut(struct dc *dc)for (int i =0 ; i < num_rmcm; i++) { dc->res_pool->rmcm_3dlut[i].isInUse = false; dc->res_pool->rmcm_3dlut[i].stream =NULL ; + dc->res_pool->rmcm_3dlut[i].protection_bits =0 ; } }
drivers/gpu/drm/amd/display/dc/dc.h +10 -48
94 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/dc_types.h +0 -24
@@ -1493,28 +1493,4 @@ struct dc_validation_dpia_set { uint32_t required_bw; }; -enum dc_cm_lut_swizzle { -CM_LUT_3D_SWIZZLE_LINEAR_RGB , -CM_LUT_3D_SWIZZLE_LINEAR_BGR , -CM_LUT_1D_PACKED_LINEAR -}; - -enum dc_cm_lut_pixel_format { -CM_LUT_PIXEL_FORMAT_RGBA16161616_UNORM_12MSB , -CM_LUT_PIXEL_FORMAT_BGRA16161616_UNORM_12MSB , -CM_LUT_PIXEL_FORMAT_RGBA16161616_UNORM_12LSB , -CM_LUT_PIXEL_FORMAT_BGRA16161616_UNORM_12LSB , -CM_LUT_PIXEL_FORMAT_RGBA16161616_FLOAT_FP1_5_10 , -CM_LUT_PIXEL_FORMAT_BGRA16161616_FLOAT_FP1_5_10 -}; - -enum dc_cm_lut_size { -CM_LUT_SIZE_NONE , -CM_LUT_SIZE_999 , -CM_LUT_SIZE_171717 , -CM_LUT_SIZE_333333 , -CM_LUT_SIZE_454545 , -CM_LUT_SIZE_656565 , -}; -#endif /* DC_TYPES_H_ */
drivers/gpu/drm/amd/display/dc/hubp/dcn401/dcn401_hubp.c +67 -134
261 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/hubp/dcn401/dcn401_hubp.h +19 -4
@@ -328,17 +328,32 @@ int hubp401_get_3dlut_fl_done(struct hubp *hubp);void hubp401_set_unbounded_requesting (struct hubp *hubp,bool enable); +void hubp401_update_3dlut_fl_bias_scale (struct hubp *hubp,uint16_t bias,uint16_t scale); +void hubp401_program_3dlut_fl_crossbar (struct hubp *hubp, -const enum dc_cm_lut_pixel_format format); +enum hubp_3dlut_fl_crossbar_bit_slice bit_slice_y_g, +enum hubp_3dlut_fl_crossbar_bit_slice bit_slice_cb_b, +enum hubp_3dlut_fl_crossbar_bit_slice bit_slice_cr_r); + +void hubp401_program_3dlut_fl_tmz_protected (struct hubp *hubp,uint8_t protection_bits); + +void hubp401_program_3dlut_fl_width (struct hubp *hubp,enum hubp_3dlut_fl_width width); + +void hubp401_program_3dlut_fl_addressing_mode (struct hubp *hubp,enum hubp_3dlut_fl_addressing_mode addr_mode);void hubp401_enable_3dlut_fl (struct hubp *hubp,bool enable);void hubp401_program_3dlut_fl_dlg_param (struct hubp *hubp,int refcyc_per_3dlut_group); -void hubp401_program_3dlut_fl_addr (struct hubp *hubp,const struct dc_plane_address *address); +void hubp401_program_3dlut_fl_addr (struct hubp *hubp,const struct dc_plane_address address); -void hubp401_program_3dlut_fl_config (struct hubp *hubp, -const struct dc_3dlut_dma *config); +void hubp401_program_3dlut_fl_format (struct hubp *hubp,enum hubp_3dlut_fl_format format); + +void hubp401_program_3dlut_fl_mode (struct hubp *hubp,enum hubp_3dlut_fl_mode mode); + +void hubp401_program_3dlut_fl_config ( +struct hubp *hubp, +struct hubp_fl_3dlut_config *cfg);void hubp401_clear_tiling (struct hubp *hubp);
drivers/gpu/drm/amd/display/dc/hubp/dcn42/dcn42_hubp.c +9 -69
103 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/hubp/dcn42/dcn42_hubp.h +5 -5
@@ -58,11 +58,11 @@ bool hubp42_construct(const struct dcn_hubp2_shift *hubp_shift, const struct dcn_hubp2_mask *hubp_mask); -void hubp42_program_3dlut_fl_crossbar (struct hubp *hubp, -const enum dc_cm_lut_pixel_format format); - -void hubp42_program_3dlut_fl_config (struct hubp *hubp, -const struct dc_3dlut_dma *config); +void hubp42_program_3dlut_fl_crossbar ( +struct hubp *hubp, +enum hubp_3dlut_fl_crossbar_bit_slice bit_slice_r, +enum hubp_3dlut_fl_crossbar_bit_slice bit_slice_g, +enum hubp_3dlut_fl_crossbar_bit_slice bit_slice_b);void hubp42_read_state (struct hubp *hubp);
drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_hwseq.c +257 -132
452 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/hwss/dcn42/dcn42_hwseq.c +463 -36
574 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/hwss/dcn42/dcn42_hwseq.h +8 -1
@@ -18,11 +18,18 @@ void dcn42_program_cm_hist(bool dcn42_set_mcm_luts (struct pipe_ctx *pipe_ctx,const struct dc_plane_state *plane_state); +void dcn42_populate_mcm_luts (struct dc *dc, +struct pipe_ctx *pipe_ctx, +struct dc_cm2_func_luts mcm_luts, +bool lut_bank_a); +bool dcn42_program_rmcm_luts (struct hubp *hubp,struct pipe_ctx *pipe_ctx, -const struct dc_plane_cm *cm, +enum dc_cm2_transfer_func_source lut3d_src, +struct dc_cm2_func_luts *mcm_luts,struct mpc *mpc, +bool lut_bank_a,int mpcc_id);void dcn42_hardware_release (struct dc *dc);
drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h +30 -5
@@ -89,7 +89,7 @@ enum hubp_3dlut_fl_addressing_mode {enum hubp_3dlut_fl_width { hubp_3dlut_fl_width_17 =17 , hubp_3dlut_fl_width_33 =33 , - hubp_3dlut_fl_width_17_transformed =4916 ,//mpc default + hubp_3dlut_fl_width_transformed =4916 ,//mpc default };enum hubp_3dlut_fl_crossbar_bit_slice {
@@ -99,6 +99,22 @@ enum hubp_3dlut_fl_crossbar_bit_slice { hubp_3dlut_fl_crossbar_bit_slice_48_63 =3 }; +struct hubp_fl_3dlut_config { +bool enabled; +enum hubp_3dlut_fl_width width; +enum hubp_3dlut_fl_mode mode; +enum hubp_3dlut_fl_format format; +uint16_t bias; +uint16_t scale; +struct dc_plane_address address; +enum hubp_3dlut_fl_addressing_mode addr_mode; +enum dc_cm2_gpu_mem_layout layout; +uint8_t protection_bits; +enum hubp_3dlut_fl_crossbar_bit_slice crossbar_bit_slice_y_g; +enum hubp_3dlut_fl_crossbar_bit_slice crossbar_bit_slice_cb_b; +enum hubp_3dlut_fl_crossbar_bit_slice crossbar_bit_slice_cr_r; +}; +struct hubp {const struct hubp_funcs *funcs;struct dc_context *ctx;
@@ -273,15 +289,24 @@ struct hubp_funcs {void (*hubp_wait_pipe_read_start)(struct hubp *hubp);void (*hubp_program_mcache_id_and_split_coordinate)(struct hubp *hubp,struct dml2_hubp_pipe_mcache_regs *mcache_regs); +void (*hubp_update_3dlut_fl_bias_scale)(struct hubp *hubp,uint16_t bias,uint16_t scale); +void (*hubp_program_3dlut_fl_mode)(struct hubp *hubp, +enum hubp_3dlut_fl_mode mode); +void (*hubp_program_3dlut_fl_format)(struct hubp *hubp, +enum hubp_3dlut_fl_format format);void (*hubp_program_3dlut_fl_addr)(struct hubp *hubp, -const struct dc_plane_address *address); -void (*hubp_program_3dlut_fl_config)(struct hubp *hubp, -const struct dc_3dlut_dma *config); +const struct dc_plane_address address);void (*hubp_program_3dlut_fl_dlg_param)(struct hubp *hubp,int refcyc_per_3dlut_group);void (*hubp_enable_3dlut_fl)(struct hubp *hubp,bool enable); +void (*hubp_program_3dlut_fl_addressing_mode)(struct hubp *hubp,enum hubp_3dlut_fl_addressing_mode addr_mode); +void (*hubp_program_3dlut_fl_width)(struct hubp *hubp,enum hubp_3dlut_fl_width width); +void (*hubp_program_3dlut_fl_tmz_protected)(struct hubp *hubp,uint8_t protection_bits);void (*hubp_program_3dlut_fl_crossbar)(struct hubp *hubp, -enum dc_cm_lut_pixel_format format); +enum hubp_3dlut_fl_crossbar_bit_slice bit_slice_y_g, +enum hubp_3dlut_fl_crossbar_bit_slice bit_slice_cb_b, +enum hubp_3dlut_fl_crossbar_bit_slice bit_slice_cr_r);int (*hubp_get_3dlut_fl_done)(struct hubp *hubp); +void (*hubp_program_3dlut_fl_config)(struct hubp *hubp,struct hubp_fl_3dlut_config *cfg);void (*hubp_clear_tiling)(struct hubp *hubp);uint32_t (*hubp_get_current_read_line)(struct hubp *hubp);uint32_t (*hubp_get_det_config_error)(struct hubp *hubp);
drivers/gpu/drm/amd/display/dc/inc/hw/mpc.h +32 -47
136 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/mpc/dcn401/dcn401_mpc.c +77 -100
251 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/mpc/dcn401/dcn401_mpc.h +7 -18
@@ -206,32 +206,21 @@ void dcn401_mpc_construct(struct dcn401_mpc *mpc401, int num_rmu);void mpc401_set_movable_cm_location (struct mpc *mpc,enum mpcc_movable_cm_location location,int mpcc_id); -void mpc401_populate_lut (struct mpc *mpc, -const enum MCM_LUT_ID id, -const union mcm_lut_params *params, -bool lut_bank_a, -int mpcc_id); +void mpc401_populate_lut (struct mpc *mpc,const enum MCM_LUT_ID id,const union mcm_lut_params params, +bool lut_bank_a,int mpcc_id);void mpc401_program_lut_mode (struct mpc *mpc,const enum MCM_LUT_ID id, -const bool enable, -const bool lut_bank_a, -const enum dc_cm_lut_size size, -const int mpcc_id); - -void mpc401_get_lut_mode (struct mpc *mpc, -const enum MCM_LUT_ID id, -const int mpcc_id, -bool *enable, -bool *lut_bank_a); +const enum MCM_LUT_XABLE xable, +bool lut_bank_a, +int mpcc_id);void mpc401_program_lut_read_write_control (struct mpc *mpc,const enum MCM_LUT_ID id, -const bool lut_bank_a, -const unsigned int bit_depth, -const int mpcc_id); +bool lut_bank_a, +int mpcc_id); void mpc401_set_gamut_remap( struct mpc *mpc,
drivers/gpu/drm/amd/display/dc/mpc/dcn42/dcn42_mpc.c +356 -32
448 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/mpc/dcn42/dcn42_mpc.h +47 -2
71 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/resource/dcn42/dcn42_resource.c +0 -1
@@ -666,7 +666,6 @@ static const struct resource_caps res_cap_dcn42 = { .num_vmid = 16, .num_mpc_3dlut = 2, .num_dsc = 4, - .num_rmcm = 2, };static const struct dc_plane_cap plane_cap = {
Signature · 1 line
2.55.0