drm/amd/display: 3DLUT non-DMA refactor
authorRelja Vojvodic <Relja.Vojvodic@amd.com>
Mon, 29 Jul 2024 18:35:45 +0000 (14:35 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 13 Aug 2024 14:31:53 +0000 (10:31 -0400)
[Why]
Currently the handling for 3DLUT is found in multiple different
places, which causes issues when the different functions are not
in sync with each other.
Frequently bugs occur because the LUT handling is broken up, and
what has already been handled isn't kept track of well, which can
cause earlier changes to the LUT params to be overridden.

[How]
Remove DMA LUT handling from DCN401 and refactor legacy LUT
handling in one place to make it easier to keep track of what has
and needs to be done.

Reviewed-by: Ilya Bakoulin <ilya.bakoulin@amd.com>
Signed-off-by: Relja Vojvodic <Relja.Vojvodic@amd.com>
Signed-off-by: Tom Chung <chiahsuan.chung@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/hwss/dcn32/dcn32_init.c
drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_hwseq.c
drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_init.c

index 968b010..58bed01 100644 (file)
@@ -162,7 +162,6 @@ static const struct hwseq_private_funcs dcn32_private_funcs = {
        .is_dp_dig_pixel_rate_div_policy = dcn32_is_dp_dig_pixel_rate_div_policy,
        .apply_single_controller_ctx_to_hw = dce110_apply_single_controller_ctx_to_hw,
        .reset_back_end_for_pipe = dcn20_reset_back_end_for_pipe,
-       .populate_mcm_luts = dcn401_populate_mcm_luts,
 };
 
 void dcn32_hw_sequencer_init_functions(struct dc *dc)
index 77489bb..44c1184 100644 (file)
@@ -670,46 +670,40 @@ bool dcn401_set_mcm_luts(struct pipe_ctx *pipe_ctx,
        struct dpp *dpp_base = pipe_ctx->plane_res.dpp;
        int mpcc_id = pipe_ctx->plane_res.hubp->inst;
        struct mpc *mpc = pipe_ctx->stream_res.opp->ctx->dc->res_pool->mpc;
-       bool result = true;
+       bool result;
        const struct pwl_params *lut_params = NULL;
        bool rval;
 
        mpc->funcs->set_movable_cm_location(mpc, MPCC_MOVABLE_CM_LOCATION_BEFORE, mpcc_id);
        pipe_ctx->plane_state->mcm_location = MPCC_MOVABLE_CM_LOCATION_BEFORE;
        // 1D LUT
-       if (plane_state->mcm_shaper_3dlut_setting == DC_CM2_SHAPER_3DLUT_SETTING_BYPASS_ALL) {
-               if (plane_state->blend_tf.type == TF_TYPE_HWPWL)
-                       lut_params = &plane_state->blend_tf.pwl;
-               else if (plane_state->blend_tf.type == TF_TYPE_DISTRIBUTED_POINTS) {
-                       rval = cm3_helper_translate_curve_to_hw_format(&plane_state->blend_tf,
-                                       &dpp_base->regamma_params, false);
-                       lut_params = rval ? &dpp_base->regamma_params : NULL;
-               }
-               result = mpc->funcs->program_1dlut(mpc, lut_params, mpcc_id);
-               lut_params = NULL;
+       if (plane_state->blend_tf.type == TF_TYPE_HWPWL)
+               lut_params = &plane_state->blend_tf.pwl;
+       else if (plane_state->blend_tf.type == TF_TYPE_DISTRIBUTED_POINTS) {
+               rval = cm3_helper_translate_curve_to_hw_format(&plane_state->blend_tf,
+                               &dpp_base->regamma_params, false);
+               lut_params = rval ? &dpp_base->regamma_params : NULL;
        }
+       result = mpc->funcs->program_1dlut(mpc, lut_params, mpcc_id);
+       lut_params = NULL;
 
        // Shaper
-       if (plane_state->mcm_shaper_3dlut_setting == DC_CM2_SHAPER_3DLUT_SETTING_BYPASS_ALL) {
-               if (plane_state->in_shaper_func.type == TF_TYPE_HWPWL)
-                       lut_params = &plane_state->in_shaper_func.pwl;
-               else if (plane_state->in_shaper_func.type == TF_TYPE_DISTRIBUTED_POINTS) {
-                       // TODO: dpp_base replace
-                       ASSERT(false);
-                       rval = cm3_helper_translate_curve_to_hw_format(&plane_state->in_shaper_func,
-                                       &dpp_base->shaper_params, true);
-                       lut_params = rval ? &dpp_base->shaper_params : NULL;
-               }
-
-               result = mpc->funcs->program_shaper(mpc, lut_params, mpcc_id);
+       if (plane_state->in_shaper_func.type == TF_TYPE_HWPWL)
+               lut_params = &plane_state->in_shaper_func.pwl;
+       else if (plane_state->in_shaper_func.type == TF_TYPE_DISTRIBUTED_POINTS) {
+               // TODO: dpp_base replace
+               rval = cm3_helper_translate_curve_to_hw_format(&plane_state->in_shaper_func,
+                               &dpp_base->shaper_params, true);
+               lut_params = rval ? &dpp_base->shaper_params : NULL;
        }
+       result &= mpc->funcs->program_shaper(mpc, lut_params, mpcc_id);
 
        // 3D
-       if (plane_state->mcm_shaper_3dlut_setting == DC_CM2_SHAPER_3DLUT_SETTING_BYPASS_ALL) {
+       if (mpc->funcs->program_3dlut) {
                if (plane_state->lut3d_func.state.bits.initialized == 1)
-                       result = mpc->funcs->program_3dlut(mpc, &plane_state->lut3d_func.lut_3d, mpcc_id);
+                       result &= mpc->funcs->program_3dlut(mpc, &plane_state->lut3d_func.lut_3d, mpcc_id);
                else
-                       result = mpc->funcs->program_3dlut(mpc, NULL, mpcc_id);
+                       result &= mpc->funcs->program_3dlut(mpc, NULL, mpcc_id);
        }
 
        return result;
index 457f416..f4eda4a 100644 (file)
@@ -136,7 +136,7 @@ static const struct hwseq_private_funcs dcn401_private_funcs = {
        .calculate_dccg_k1_k2_values = NULL,
        .apply_single_controller_ctx_to_hw = dce110_apply_single_controller_ctx_to_hw,
        .reset_back_end_for_pipe = dcn20_reset_back_end_for_pipe,
-       .populate_mcm_luts = dcn401_populate_mcm_luts,
+       .populate_mcm_luts = NULL,
 };
 
 void dcn401_hw_sequencer_init_functions(struct dc *dc)