[PATCH] drm/amd/display: Fix cursor pos and hotspot calcs
Alex Deucher
alexdeucher at gmail.com
Wed Dec 12 15:18:41 UTC 2018
On Wed, Dec 12, 2018 at 9:04 AM Nicholas Kazlauskas
<nicholas.kazlauskas at amd.com> wrote:
>
> [Why]
> The cursor calculations in amdgpu_dm incorrectly assume that the
> cursor hotspot is always (0, 0) and don't respect the hot_x and hot_y
> attributes that can be passed in via the drm_mode_cursor2_ioctl.
>
> The DC hotspot parameters are also incorrectly used to offset the
> cursor when it goes beyond the bounds of the screen instead of
> being clamped.
>
> [How]
> Use the hot_x and hot_y attributes from the fb to directly fill in the
> DC hotspot attributes.
>
> Clamp the cursor position on the edges of the screen instead of using
> the hotspot to offset it back in.
Does this patch fix this bug?
https://bugzilla.kernel.org/show_bug.cgi?id=201815
Alex
>
> Cc: Leo Li <sunpeng.li at amd.com>
> Cc: Harry Wentland <harry.wentland at amd.com>
> Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas at amd.com>
> ---
> .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 23 +++++++------------
> 1 file changed, 8 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 01badda14079..61f2eae0b67f 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -4266,7 +4266,6 @@ static int get_cursor_position(struct drm_plane *plane, struct drm_crtc *crtc,
> {
> struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
> int x, y;
> - int xorigin = 0, yorigin = 0;
>
> if (!crtc || !plane->state->fb) {
> position->enable = false;
> @@ -4284,24 +4283,18 @@ static int get_cursor_position(struct drm_plane *plane, struct drm_crtc *crtc,
> return -EINVAL;
> }
>
> - x = plane->state->crtc_x;
> - y = plane->state->crtc_y;
> + x = plane->state->crtc_x + plane->state->fb->hot_x;
> + y = plane->state->crtc_y + plane->state->fb->hot_y;
> +
> /* avivo cursor are offset into the total surface */
> x += crtc->primary->state->src_x >> 16;
> y += crtc->primary->state->src_y >> 16;
> - if (x < 0) {
> - xorigin = min(-x, amdgpu_crtc->max_cursor_width - 1);
> - x = 0;
> - }
> - if (y < 0) {
> - yorigin = min(-y, amdgpu_crtc->max_cursor_height - 1);
> - y = 0;
> - }
> +
> position->enable = true;
> - position->x = x;
> - position->y = y;
> - position->x_hotspot = xorigin;
> - position->y_hotspot = yorigin;
> + position->x = x >= 0 ? x : 0;
> + position->y = y >= 0 ? y : 0;
> + position->x_hotspot = plane->state->fb->hot_x;
> + position->y_hotspot = plane->state->fb->hot_y;
>
> return 0;
> }
> --
> 2.17.1
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
More information about the amd-gfx
mailing list