Skip to content

Commit 94a4ffd

Browse files
Gloria Lialexdeucher
authored andcommitted
drm/amd/display: fix PIP bugs on Dal3
[Why] There are outstanding bugs for PIP in Dal3: -Crash when toggling PIP visibility -Global Alpha is not working, Adjusting global alpha doesn’t have an effect -Cursor is not working with pip plane and pipe splits -One flash occurs when cursor enters PIP plane from top/bottom -Crash when moving PIP plane off the screen [How] Resolve divide by 0 error Implement global alpha Program cursor on all pipes Add dst rects' x and y offests into cursor position Disable cursor when it is beyond bottom/top edge Signed-off-by: Gloria Li <[email protected]> Reviewed-by: Aric Cyr <[email protected]> Acked-by: Leo Li <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent f1220c8 commit 94a4ffd

File tree

9 files changed

+46
-14
lines changed

9 files changed

+46
-14
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,9 @@ static enum surface_update_type get_plane_info_update_type(const struct dc_surfa
11061106
if (u->plane_info->per_pixel_alpha != u->surface->per_pixel_alpha)
11071107
update_flags->bits.per_pixel_alpha_change = 1;
11081108

1109+
if (u->plane_info->global_alpha_value != u->surface->global_alpha_value)
1110+
update_flags->bits.global_alpha_change = 1;
1111+
11091112
if (u->plane_info->dcc.enable != u->surface->dcc.enable
11101113
|| u->plane_info->dcc.grph.independent_64b_blks != u->surface->dcc.grph.independent_64b_blks
11111114
|| u->plane_info->dcc.grph.meta_pitch != u->surface->dcc.grph.meta_pitch)

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -589,8 +589,10 @@ static void calculate_viewport(struct pipe_ctx *pipe_ctx)
589589
data->viewport.width = (data->viewport.width + 1) / 2;
590590
data->viewport_c.width = (data->viewport_c.width + 1) / 2;
591591
} else if (pri_split) {
592-
data->viewport.width /= 2;
593-
data->viewport_c.width /= 2;
592+
if (data->viewport.width > 1)
593+
data->viewport.width /= 2;
594+
if (data->viewport_c.width > 1)
595+
data->viewport_c.width /= 2;
594596
}
595597

596598
if (plane_state->rotation == ROTATION_ANGLE_90 ||
@@ -670,7 +672,8 @@ static void calculate_recout(struct pipe_ctx *pipe_ctx, struct rect *recout_full
670672
pipe_ctx->plane_res.scl_data.recout.width =
671673
(pipe_ctx->plane_res.scl_data.recout.width + 1) / 2;
672674
} else {
673-
pipe_ctx->plane_res.scl_data.recout.width /= 2;
675+
if (pipe_ctx->plane_res.scl_data.recout.width > 1)
676+
pipe_ctx->plane_res.scl_data.recout.width /= 2;
674677
}
675678
}
676679
/* Unclipped recout offset = stream dst offset + ((surf dst offset - stream surf_src offset)

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,6 @@ bool dc_stream_set_cursor_attributes(
205205

206206
if (pipe_ctx->stream != stream)
207207
continue;
208-
if (pipe_ctx->top_pipe && pipe_ctx->plane_state != pipe_ctx->top_pipe->plane_state)
209-
continue;
210208

211209
if (!pipe_to_program) {
212210
pipe_to_program = pipe_ctx;

drivers/gpu/drm/amd/display/dc/dc.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ union surface_update_flags {
442442
uint32_t color_space_change:1;
443443
uint32_t horizontal_mirror_change:1;
444444
uint32_t per_pixel_alpha_change:1;
445+
uint32_t global_alpha_change:1;
445446
uint32_t rotation_change:1;
446447
uint32_t swizzle_change:1;
447448
uint32_t scaling_change:1;
@@ -496,6 +497,8 @@ struct dc_plane_state {
496497

497498
bool is_tiling_rotated;
498499
bool per_pixel_alpha;
500+
bool global_alpha;
501+
int global_alpha_value;
499502
bool visible;
500503
bool flip_immediate;
501504
bool horizontal_mirror;
@@ -522,6 +525,8 @@ struct dc_plane_info {
522525
bool horizontal_mirror;
523526
bool visible;
524527
bool per_pixel_alpha;
528+
bool global_alpha;
529+
int global_alpha_value;
525530
bool input_csc_enabled;
526531
};
527532

drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,12 @@ void dpp1_set_cursor_position(
444444
struct dpp *dpp_base,
445445
const struct dc_cursor_position *pos,
446446
const struct dc_cursor_mi_param *param,
447-
uint32_t width)
447+
uint32_t width,
448+
uint32_t height)
448449
{
449450
struct dcn10_dpp *dpp = TO_DCN10_DPP(dpp_base);
450451
int src_x_offset = pos->x - pos->x_hotspot - param->viewport.x;
452+
int src_y_offset = pos->y - pos->y_hotspot - param->viewport.y;
451453
uint32_t cur_en = pos->enable ? 1 : 0;
452454

453455
if (src_x_offset >= (int)param->viewport.width)
@@ -456,6 +458,12 @@ void dpp1_set_cursor_position(
456458
if (src_x_offset + (int)width <= 0)
457459
cur_en = 0; /* not visible beyond left edge*/
458460

461+
if (src_y_offset >= (int)param->viewport.height)
462+
cur_en = 0; /* not visible beyond bottom edge*/
463+
464+
if (src_y_offset < 0)
465+
cur_en = 0; /* not visible beyond top edge*/
466+
459467
REG_UPDATE(CURSOR0_CONTROL,
460468
CUR0_ENABLE, cur_en);
461469

drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1374,7 +1374,8 @@ void dpp1_set_cursor_position(
13741374
struct dpp *dpp_base,
13751375
const struct dc_cursor_position *pos,
13761376
const struct dc_cursor_mi_param *param,
1377-
uint32_t width);
1377+
uint32_t width,
1378+
uint32_t height);
13781379

13791380
void dpp1_cnv_set_optional_cursor_attributes(
13801381
struct dpp *dpp_base,

drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,7 @@ void hubp1_cursor_set_position(
10701070
{
10711071
struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
10721072
int src_x_offset = pos->x - pos->x_hotspot - param->viewport.x;
1073+
int src_y_offset = pos->y - pos->y_hotspot - param->viewport.y;
10731074
int x_hotspot = pos->x_hotspot;
10741075
int y_hotspot = pos->y_hotspot;
10751076
uint32_t dst_x_offset;
@@ -1113,6 +1114,12 @@ void hubp1_cursor_set_position(
11131114
if (src_x_offset + (int)hubp->curs_attr.width <= 0)
11141115
cur_en = 0; /* not visible beyond left edge*/
11151116

1117+
if (src_y_offset >= (int)param->viewport.height)
1118+
cur_en = 0; /* not visible beyond bottom edge*/
1119+
1120+
if (src_y_offset < 0) //+ (int)hubp->curs_attr.height
1121+
cur_en = 0; /* not visible beyond top edge*/
1122+
11161123
if (cur_en && REG_READ(CURSOR_SURFACE_ADDRESS) == 0)
11171124
hubp->funcs->set_cursor_attributes(hubp, &hubp->curs_attr);
11181125

drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1932,9 +1932,13 @@ static void dcn10_update_mpcc(struct dc *dc, struct pipe_ctx *pipe_ctx)
19321932
blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA;
19331933

19341934
blnd_cfg.overlap_only = false;
1935-
blnd_cfg.global_alpha = 0xff;
19361935
blnd_cfg.global_gain = 0xff;
19371936

1937+
if (pipe_ctx->plane_state->global_alpha)
1938+
blnd_cfg.global_alpha = pipe_ctx->plane_state->global_alpha_value;
1939+
else
1940+
blnd_cfg.global_alpha = 0xff;
1941+
19381942
/* DCN1.0 has output CM before MPC which seems to screw with
19391943
* pre-multiplied alpha.
19401944
*/
@@ -2049,11 +2053,13 @@ static void update_dchubp_dpp(
20492053
update_dpp(dpp, plane_state);
20502054

20512055
if (plane_state->update_flags.bits.full_update ||
2052-
plane_state->update_flags.bits.per_pixel_alpha_change)
2056+
plane_state->update_flags.bits.per_pixel_alpha_change ||
2057+
plane_state->update_flags.bits.global_alpha_change)
20532058
dc->hwss.update_mpcc(dc, pipe_ctx);
20542059

20552060
if (plane_state->update_flags.bits.full_update ||
20562061
plane_state->update_flags.bits.per_pixel_alpha_change ||
2062+
plane_state->update_flags.bits.global_alpha_change ||
20572063
plane_state->update_flags.bits.scaling_change ||
20582064
plane_state->update_flags.bits.position_change) {
20592065
update_scaler(pipe_ctx);
@@ -2597,15 +2603,15 @@ static void dcn10_set_cursor_position(struct pipe_ctx *pipe_ctx)
25972603
.mirror = pipe_ctx->plane_state->horizontal_mirror
25982604
};
25992605

2606+
pos_cpy.x -= pipe_ctx->plane_state->dst_rect.x;
2607+
pos_cpy.y -= pipe_ctx->plane_state->dst_rect.y;
2608+
26002609
if (pipe_ctx->plane_state->address.type
26012610
== PLN_ADDR_TYPE_VIDEO_PROGRESSIVE)
26022611
pos_cpy.enable = false;
26032612

2604-
if (pipe_ctx->top_pipe && pipe_ctx->plane_state != pipe_ctx->top_pipe->plane_state)
2605-
pos_cpy.enable = false;
2606-
26072613
hubp->funcs->set_cursor_position(hubp, &pos_cpy, &param);
2608-
dpp->funcs->set_cursor_position(dpp, &pos_cpy, &param, hubp->curs_attr.width);
2614+
dpp->funcs->set_cursor_position(dpp, &pos_cpy, &param, hubp->curs_attr.width, hubp->curs_attr.height);
26092615
}
26102616

26112617
static void dcn10_set_cursor_attribute(struct pipe_ctx *pipe_ctx)

drivers/gpu/drm/amd/display/dc/inc/hw/dpp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ struct dpp_funcs {
147147
struct dpp *dpp_base,
148148
const struct dc_cursor_position *pos,
149149
const struct dc_cursor_mi_param *param,
150-
uint32_t width
150+
uint32_t width,
151+
uint32_t height
151152
);
152153
void (*dpp_set_hdr_multiplier)(
153154
struct dpp *dpp_base,

0 commit comments

Comments
 (0)