Skip to content

Commit e99acf7

Browse files
Nicholas Kazlauskasalexdeucher
authored andcommitted
drm/amd/display: Translate cursor position by source rect
[Why] Cursor is drawn as part of the framebuffer for a plane on AMD hardware. The cursor position on the framebuffer does not change even if the source rect viewport for the cursor does. This causes the cursor to be clipped. The following IGT tests fail as a result of this issue: - kms_plane_cursor@pipe-*-viewport-size-* [How] Offset cursor position by plane source rect viewport. If the viewport is unscaled then the cursor is now correctly positioned on any plane - primary or overlay. There is still a hardware limitation for dealing with the cursor size being incorrectly scaled but that's not something we can address. Add some documentation explaining some of this in the code while we're at it. Signed-off-by: Nicholas Kazlauskas <[email protected]> Reviewed-by: Zhan Liu <[email protected]> Acked-by: Rodrigo Siqueira <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 346d8a0 commit e99acf7

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

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

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3021,12 +3021,44 @@ void dcn10_set_cursor_position(struct pipe_ctx *pipe_ctx)
30213021
int x_pos = pos_cpy.x;
30223022
int y_pos = pos_cpy.y;
30233023

3024-
// translate cursor from stream space to plane space
3024+
/**
3025+
* DC cursor is stream space, HW cursor is plane space and drawn
3026+
* as part of the framebuffer.
3027+
*
3028+
* Cursor position can't be negative, but hotspot can be used to
3029+
* shift cursor out of the plane bounds. Hotspot must be smaller
3030+
* than the cursor size.
3031+
*/
3032+
3033+
/**
3034+
* Translate cursor from stream space to plane space.
3035+
*
3036+
* If the cursor is scaled then we need to scale the position
3037+
* to be in the approximately correct place. We can't do anything
3038+
* about the actual size being incorrect, that's a limitation of
3039+
* the hardware.
3040+
*/
30253041
x_pos = (x_pos - x_plane) * pipe_ctx->plane_state->src_rect.width /
30263042
pipe_ctx->plane_state->dst_rect.width;
30273043
y_pos = (y_pos - y_plane) * pipe_ctx->plane_state->src_rect.height /
30283044
pipe_ctx->plane_state->dst_rect.height;
30293045

3046+
/**
3047+
* If the cursor's source viewport is clipped then we need to
3048+
* translate the cursor to appear in the correct position on
3049+
* the screen.
3050+
*
3051+
* This translation isn't affected by scaling so it needs to be
3052+
* done *after* we adjust the position for the scale factor.
3053+
*/
3054+
x_pos += pipe_ctx->plane_state->src_rect.x;
3055+
y_pos += pipe_ctx->plane_state->src_rect.y;
3056+
3057+
/**
3058+
* If the position is negative then we need to add to the hotspot
3059+
* to shift the cursor outside the plane.
3060+
*/
3061+
30303062
if (x_pos < 0) {
30313063
pos_cpy.x_hotspot -= x_pos;
30323064
x_pos = 0;

0 commit comments

Comments
 (0)