drm/amd/display: Correct cursor position on horizontal mirror

[Why]
Incorrect cursor position will induce system hang on pipe split.

[How]
1.Handle horizontal mirror on rotation,
2.Correct cursor set on piep split.

Reviewed-by: Ariel Bernstein <Eric.Bernstein@amd.com>
Acked-by: Brian Chang <Brian.Chang@amd.com>
Signed-off-by: Martin Tsai <martin.tsai@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Martin Tsai 2022-08-18 16:01:24 +08:00 коммит произвёл Alex Deucher
Родитель 67ec719574
Коммит 9d84c7ef8a
4 изменённых файлов: 62 добавлений и 31 удалений

Просмотреть файл

@ -448,11 +448,12 @@ void dpp1_set_cursor_position(
src_y_offset = pos->y - pos->x_hotspot - param->viewport.y; src_y_offset = pos->y - pos->x_hotspot - param->viewport.y;
} }
} else if (param->rotation == ROTATION_ANGLE_180) { } else if (param->rotation == ROTATION_ANGLE_180) {
src_x_offset = pos->x - param->viewport.x; if (!param->mirror)
src_x_offset = pos->x - param->viewport.x;
src_y_offset = pos->y - param->viewport.y; src_y_offset = pos->y - param->viewport.y;
} }
if (src_x_offset >= (int)param->viewport.width) if (src_x_offset >= (int)param->viewport.width)
cur_en = 0; /* not visible beyond right edge*/ cur_en = 0; /* not visible beyond right edge*/

Просмотреть файл

@ -1208,13 +1208,10 @@ void hubp1_cursor_set_position(
src_y_offset = pos->y - pos->x_hotspot - param->viewport.y; src_y_offset = pos->y - pos->x_hotspot - param->viewport.y;
} }
} else if (param->rotation == ROTATION_ANGLE_180) { } else if (param->rotation == ROTATION_ANGLE_180) {
src_x_offset = pos->x - param->viewport.x; if (!param->mirror)
src_y_offset = pos->y - param->viewport.y; src_x_offset = pos->x - param->viewport.x;
}
if (param->mirror) { src_y_offset = pos->y - param->viewport.y;
x_hotspot = param->viewport.width - x_hotspot;
src_x_offset = param->viewport.x + param->viewport.width - src_x_offset;
} }
dst_x_offset = (src_x_offset >= 0) ? src_x_offset : 0; dst_x_offset = (src_x_offset >= 0) ? src_x_offset : 0;

Просмотреть файл

@ -3470,8 +3470,7 @@ void dcn10_set_cursor_position(struct pipe_ctx *pipe_ctx)
.rotation = pipe_ctx->plane_state->rotation, .rotation = pipe_ctx->plane_state->rotation,
.mirror = pipe_ctx->plane_state->horizontal_mirror .mirror = pipe_ctx->plane_state->horizontal_mirror
}; };
bool pipe_split_on = (pipe_ctx->top_pipe != NULL) || bool pipe_split_on = false;
(pipe_ctx->bottom_pipe != NULL);
bool odm_combine_on = (pipe_ctx->next_odm_pipe != NULL) || bool odm_combine_on = (pipe_ctx->next_odm_pipe != NULL) ||
(pipe_ctx->prev_odm_pipe != NULL); (pipe_ctx->prev_odm_pipe != NULL);
@ -3480,6 +3479,13 @@ void dcn10_set_cursor_position(struct pipe_ctx *pipe_ctx)
int x_pos = pos_cpy.x; int x_pos = pos_cpy.x;
int y_pos = pos_cpy.y; int y_pos = pos_cpy.y;
if ((pipe_ctx->top_pipe != NULL) || (pipe_ctx->bottom_pipe != NULL)) {
if ((pipe_ctx->plane_state->src_rect.width != pipe_ctx->plane_res.scl_data.viewport.width) ||
(pipe_ctx->plane_state->src_rect.height != pipe_ctx->plane_res.scl_data.viewport.height)) {
pipe_split_on = true;
}
}
/** /**
* DC cursor is stream space, HW cursor is plane space and drawn * DC cursor is stream space, HW cursor is plane space and drawn
* as part of the framebuffer. * as part of the framebuffer.
@ -3551,8 +3557,36 @@ void dcn10_set_cursor_position(struct pipe_ctx *pipe_ctx)
if (pos_cpy.enable && dcn10_can_pipe_disable_cursor(pipe_ctx)) if (pos_cpy.enable && dcn10_can_pipe_disable_cursor(pipe_ctx))
pos_cpy.enable = false; pos_cpy.enable = false;
if (param.rotation == ROTATION_ANGLE_0) {
int viewport_width =
pipe_ctx->plane_res.scl_data.viewport.width;
int viewport_x =
pipe_ctx->plane_res.scl_data.viewport.x;
if (param.mirror) {
if (pipe_split_on || odm_combine_on) {
if (pos_cpy.x >= viewport_width + viewport_x) {
pos_cpy.x = 2 * viewport_width
- pos_cpy.x + 2 * viewport_x;
} else {
uint32_t temp_x = pos_cpy.x;
pos_cpy.x = 2 * viewport_x - pos_cpy.x;
if (temp_x >= viewport_x +
(int)hubp->curs_attr.width || pos_cpy.x
<= (int)hubp->curs_attr.width +
pipe_ctx->plane_state->src_rect.x) {
pos_cpy.x = temp_x + viewport_width;
}
}
} else {
pos_cpy.x = viewport_width - pos_cpy.x + 2 * viewport_x;
}
}
}
// Swap axis and mirror horizontally // Swap axis and mirror horizontally
if (param.rotation == ROTATION_ANGLE_90) { else if (param.rotation == ROTATION_ANGLE_90) {
uint32_t temp_x = pos_cpy.x; uint32_t temp_x = pos_cpy.x;
pos_cpy.x = pipe_ctx->plane_res.scl_data.viewport.width - pos_cpy.x = pipe_ctx->plane_res.scl_data.viewport.width -
@ -3623,23 +3657,25 @@ void dcn10_set_cursor_position(struct pipe_ctx *pipe_ctx)
int viewport_x = int viewport_x =
pipe_ctx->plane_res.scl_data.viewport.x; pipe_ctx->plane_res.scl_data.viewport.x;
if (pipe_split_on || odm_combine_on) { if (!param.mirror) {
if (pos_cpy.x >= viewport_width + viewport_x) { if (pipe_split_on || odm_combine_on) {
pos_cpy.x = 2 * viewport_width if (pos_cpy.x >= viewport_width + viewport_x) {
- pos_cpy.x + 2 * viewport_x; pos_cpy.x = 2 * viewport_width
} else { - pos_cpy.x + 2 * viewport_x;
uint32_t temp_x = pos_cpy.x; } else {
uint32_t temp_x = pos_cpy.x;
pos_cpy.x = 2 * viewport_x - pos_cpy.x; pos_cpy.x = 2 * viewport_x - pos_cpy.x;
if (temp_x >= viewport_x + if (temp_x >= viewport_x +
(int)hubp->curs_attr.width || pos_cpy.x (int)hubp->curs_attr.width || pos_cpy.x
<= (int)hubp->curs_attr.width + <= (int)hubp->curs_attr.width +
pipe_ctx->plane_state->src_rect.x) { pipe_ctx->plane_state->src_rect.x) {
pos_cpy.x = temp_x + viewport_width; pos_cpy.x = temp_x + viewport_width;
}
} }
} else {
pos_cpy.x = viewport_width - pos_cpy.x + 2 * viewport_x;
} }
} else {
pos_cpy.x = viewport_width - pos_cpy.x + 2 * viewport_x;
} }
/** /**

Просмотреть файл

@ -987,13 +987,10 @@ void hubp2_cursor_set_position(
src_y_offset = pos->y - pos->x_hotspot - param->viewport.y; src_y_offset = pos->y - pos->x_hotspot - param->viewport.y;
} }
} else if (param->rotation == ROTATION_ANGLE_180) { } else if (param->rotation == ROTATION_ANGLE_180) {
src_x_offset = pos->x - param->viewport.x; if (!param->mirror)
src_y_offset = pos->y - param->viewport.y; src_x_offset = pos->x - param->viewport.x;
}
if (param->mirror) { src_y_offset = pos->y - param->viewport.y;
x_hotspot = param->viewport.width - x_hotspot;
src_x_offset = param->viewport.x + param->viewport.width - src_x_offset;
} }
dst_x_offset = (src_x_offset >= 0) ? src_x_offset : 0; dst_x_offset = (src_x_offset >= 0) ? src_x_offset : 0;