Skip to content

Commit 7bec187

Browse files
Yihan Zhumehmetb0
authored andcommitted
drm/amd/display: calculate final viewport before TAP optimization
BugLink: https://bugs.launchpad.net/bugs/2096827 [ Upstream commit e982310 ] Viewport size excess surface size observed sometime with some timings or resizing the MPO video window to cause MPO unsupported. Calculate final viewport size first with a 100x100 dummy viewport to get the max TAP support and then re-run final viewport calculation if TAP value changed. Removed obsolete preliminary viewport calculation for TAP validation. Reviewed-by: Dmytro Laktyushkin <[email protected]> Signed-off-by: Yihan Zhu <[email protected]> Signed-off-by: Rodrigo Siqueira <[email protected]> Tested-by: Daniel Wheeler <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Stable-dep-of: c33a932 ("drm/amd/display: Ignore scalar validation failure if pipe is phantom") Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Koichiro Den <[email protected]>
1 parent 83f2887 commit 7bec187

File tree

1 file changed

+23
-26
lines changed

1 file changed

+23
-26
lines changed

drivers/gpu/drm/amd/display/dc/core/dc_resource.c

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -770,25 +770,6 @@ static inline void get_vp_scan_direction(
770770
*flip_horz_scan_dir = !*flip_horz_scan_dir;
771771
}
772772

773-
/*
774-
* This is a preliminary vp size calculation to allow us to check taps support.
775-
* The result is completely overridden afterwards.
776-
*/
777-
static void calculate_viewport_size(struct pipe_ctx *pipe_ctx)
778-
{
779-
struct scaler_data *data = &pipe_ctx->plane_res.scl_data;
780-
781-
data->viewport.width = dc_fixpt_ceil(dc_fixpt_mul_int(data->ratios.horz, data->recout.width));
782-
data->viewport.height = dc_fixpt_ceil(dc_fixpt_mul_int(data->ratios.vert, data->recout.height));
783-
data->viewport_c.width = dc_fixpt_ceil(dc_fixpt_mul_int(data->ratios.horz_c, data->recout.width));
784-
data->viewport_c.height = dc_fixpt_ceil(dc_fixpt_mul_int(data->ratios.vert_c, data->recout.height));
785-
if (pipe_ctx->plane_state->rotation == ROTATION_ANGLE_90 ||
786-
pipe_ctx->plane_state->rotation == ROTATION_ANGLE_270) {
787-
swap(data->viewport.width, data->viewport.height);
788-
swap(data->viewport_c.width, data->viewport_c.height);
789-
}
790-
}
791-
792773
static struct rect intersect_rec(const struct rect *r0, const struct rect *r1)
793774
{
794775
struct rect rec;
@@ -1473,6 +1454,7 @@ bool resource_build_scaling_params(struct pipe_ctx *pipe_ctx)
14731454
const struct dc_plane_state *plane_state = pipe_ctx->plane_state;
14741455
struct dc_crtc_timing *timing = &pipe_ctx->stream->timing;
14751456
const struct rect odm_slice_src = resource_get_odm_slice_src_rect(pipe_ctx);
1457+
struct scaling_taps temp = {0};
14761458
bool res = false;
14771459

14781460
DC_LOGGER_INIT(pipe_ctx->stream->ctx->logger);
@@ -1532,8 +1514,6 @@ bool resource_build_scaling_params(struct pipe_ctx *pipe_ctx)
15321514
calculate_recout(pipe_ctx);
15331515
/* depends on pixel format */
15341516
calculate_scaling_ratios(pipe_ctx);
1535-
/* depends on scaling ratios and recout, does not calculate offset yet */
1536-
calculate_viewport_size(pipe_ctx);
15371517

15381518
/*
15391519
* LB calculations depend on vp size, h/v_active and scaling ratios
@@ -1554,6 +1534,24 @@ bool resource_build_scaling_params(struct pipe_ctx *pipe_ctx)
15541534

15551535
pipe_ctx->plane_res.scl_data.lb_params.alpha_en = plane_state->per_pixel_alpha;
15561536

1537+
// get TAP value with 100x100 dummy data for max scaling qualify, override
1538+
// if a new scaling quality required
1539+
pipe_ctx->plane_res.scl_data.viewport.width = 100;
1540+
pipe_ctx->plane_res.scl_data.viewport.height = 100;
1541+
pipe_ctx->plane_res.scl_data.viewport_c.width = 100;
1542+
pipe_ctx->plane_res.scl_data.viewport_c.height = 100;
1543+
if (pipe_ctx->plane_res.xfm != NULL)
1544+
res = pipe_ctx->plane_res.xfm->funcs->transform_get_optimal_number_of_taps(
1545+
pipe_ctx->plane_res.xfm, &pipe_ctx->plane_res.scl_data, &plane_state->scaling_quality);
1546+
1547+
if (pipe_ctx->plane_res.dpp != NULL)
1548+
res = pipe_ctx->plane_res.dpp->funcs->dpp_get_optimal_number_of_taps(
1549+
pipe_ctx->plane_res.dpp, &pipe_ctx->plane_res.scl_data, &plane_state->scaling_quality);
1550+
1551+
temp = pipe_ctx->plane_res.scl_data.taps;
1552+
1553+
calculate_inits_and_viewports(pipe_ctx);
1554+
15571555
if (pipe_ctx->plane_res.xfm != NULL)
15581556
res = pipe_ctx->plane_res.xfm->funcs->transform_get_optimal_number_of_taps(
15591557
pipe_ctx->plane_res.xfm, &pipe_ctx->plane_res.scl_data, &plane_state->scaling_quality);
@@ -1580,11 +1578,10 @@ bool resource_build_scaling_params(struct pipe_ctx *pipe_ctx)
15801578
&plane_state->scaling_quality);
15811579
}
15821580

1583-
/*
1584-
* Depends on recout, scaling ratios, h_active and taps
1585-
* May need to re-check lb size after this in some obscure scenario
1586-
*/
1587-
if (res)
1581+
if (res && (pipe_ctx->plane_res.scl_data.taps.v_taps != temp.v_taps ||
1582+
pipe_ctx->plane_res.scl_data.taps.h_taps != temp.h_taps ||
1583+
pipe_ctx->plane_res.scl_data.taps.v_taps_c != temp.v_taps_c ||
1584+
pipe_ctx->plane_res.scl_data.taps.h_taps_c != temp.h_taps_c))
15881585
calculate_inits_and_viewports(pipe_ctx);
15891586

15901587
/*

0 commit comments

Comments
 (0)