]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amd/display: Use resource_build_scaling_params for dcn20
authorPeterson <peterson.guo@amd.com>
Wed, 27 Nov 2024 21:04:13 +0000 (16:04 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 10 Dec 2024 15:32:21 +0000 (10:32 -0500)
[WHY]
When using upscaling on certain gpus, some incorrect scaling
calculations would be made causing hangs.

[HOW]
This was fixed by using the resource_build_scaling_params function on these
gpus.

Reviewed-by: Dillon Varone <dillon.varone@amd.com>
Reviewed-by: Alvin Lee <alvin.lee2@amd.com>
Signed-off-by: Peterson Guo <peterson.guo@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/resource/dcn20/dcn20_resource.c

index 7a5b9aa5292cda3f35cbc5841c10841802f10d7c..5c616b1f7bf71b98c4398b935052953d5d806b10 100644 (file)
@@ -1509,60 +1509,9 @@ bool dcn20_split_stream_for_odm(
        next_odm_pipe->prev_odm_pipe = prev_odm_pipe;
 
        if (prev_odm_pipe->plane_state) {
-               struct scaler_data *sd = &prev_odm_pipe->plane_res.scl_data;
-               struct output_pixel_processor *opp = next_odm_pipe->stream_res.opp;
-               int new_width;
-
-               /* HACTIVE halved for odm combine */
-               sd->h_active /= 2;
-               /* Calculate new vp and recout for left pipe */
-               /* Need at least 16 pixels width per side */
-               if (sd->recout.x + 16 >= sd->h_active)
-                       return false;
-               new_width = sd->h_active - sd->recout.x;
-               sd->viewport.width -= dc_fixpt_floor(dc_fixpt_mul_int(
-                               sd->ratios.horz, sd->recout.width - new_width));
-               sd->viewport_c.width -= dc_fixpt_floor(dc_fixpt_mul_int(
-                               sd->ratios.horz_c, sd->recout.width - new_width));
-               sd->recout.width = new_width;
-
-               /* Calculate new vp and recout for right pipe */
-               sd = &next_odm_pipe->plane_res.scl_data;
-               /* HACTIVE halved for odm combine */
-               sd->h_active /= 2;
-               /* Need at least 16 pixels width per side */
-               if (new_width <= 16)
-                       return false;
-               new_width = sd->recout.width + sd->recout.x - sd->h_active;
-               sd->viewport.width -= dc_fixpt_floor(dc_fixpt_mul_int(
-                               sd->ratios.horz, sd->recout.width - new_width));
-               sd->viewport_c.width -= dc_fixpt_floor(dc_fixpt_mul_int(
-                               sd->ratios.horz_c, sd->recout.width - new_width));
-               sd->recout.width = new_width;
-               sd->viewport.x += dc_fixpt_floor(dc_fixpt_mul_int(
-                               sd->ratios.horz, sd->h_active - sd->recout.x));
-               sd->viewport_c.x += dc_fixpt_floor(dc_fixpt_mul_int(
-                               sd->ratios.horz_c, sd->h_active - sd->recout.x));
-               sd->recout.x = 0;
-
-               /*
-                * When odm is used in YcbCr422 or 420 colour space, a split screen
-                * will be seen with the previous calculations since the extra left
-                *  edge pixel is accounted for in fmt but not in viewport.
-                *
-                * Below are calculations which fix the split by fixing the calculations
-                * if there is an extra left edge pixel.
-                */
-               if (opp && opp->funcs->opp_get_left_edge_extra_pixel_count
-                               && opp->funcs->opp_get_left_edge_extra_pixel_count(
-                                       opp, next_odm_pipe->stream->timing.pixel_encoding,
-                                       resource_is_pipe_type(next_odm_pipe, OTG_MASTER)) == 1) {
-                       sd->h_active += 1;
-                       sd->recout.width += 1;
-                       sd->viewport.x -= dc_fixpt_ceil(dc_fixpt_mul_int(sd->ratios.horz, 1));
-                       sd->viewport_c.x -= dc_fixpt_ceil(dc_fixpt_mul_int(sd->ratios.horz, 1));
-                       sd->viewport_c.width += dc_fixpt_ceil(dc_fixpt_mul_int(sd->ratios.horz, 1));
-                       sd->viewport.width += dc_fixpt_ceil(dc_fixpt_mul_int(sd->ratios.horz, 1));
+               if (!resource_build_scaling_params(prev_odm_pipe) ||
+                       !resource_build_scaling_params(next_odm_pipe)) {
+                               return false;
                }
        }