Commit e371e19c authored by Nicholas Kazlauskas's avatar Nicholas Kazlauskas Committed by Alex Deucher

drm/amd/display: Disable cursor when offscreen in negative direction

[Why]
When x or y is negative we set the x and y values to 0 and compensate
with a positive cursor hotspot in DM since DC expects positive cursor
values.

When x or y is less than or equal to the maximum cursor width or height
the cursor hotspot is clamped so the hotspot doesn't exceed the
cursor size:

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;
}

This incorrectly forces the cursor to be at least 1 pixel on the screen
in either direction when x or y is sufficiently negative.

[How]
Just disable the cursor when it goes far enough off the screen in one
of these directions.

This fixes kms_cursor_crc@cursor-256x256-offscreen.
Signed-off-by: default avatarNicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Reviewed-by: default avatarSun peng Li <Sunpeng.Li@amd.com>
Acked-by: default avatarBhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 1352c779
...@@ -4945,12 +4945,12 @@ static int get_cursor_position(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -4945,12 +4945,12 @@ static int get_cursor_position(struct drm_plane *plane, struct drm_crtc *crtc,
int x, y; int x, y;
int xorigin = 0, yorigin = 0; int xorigin = 0, yorigin = 0;
if (!crtc || !plane->state->fb) { position->enable = false;
position->enable = false; position->x = 0;
position->x = 0; position->y = 0;
position->y = 0;
if (!crtc || !plane->state->fb)
return 0; return 0;
}
if ((plane->state->crtc_w > amdgpu_crtc->max_cursor_width) || if ((plane->state->crtc_w > amdgpu_crtc->max_cursor_width) ||
(plane->state->crtc_h > amdgpu_crtc->max_cursor_height)) { (plane->state->crtc_h > amdgpu_crtc->max_cursor_height)) {
...@@ -4964,6 +4964,10 @@ static int get_cursor_position(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -4964,6 +4964,10 @@ static int get_cursor_position(struct drm_plane *plane, struct drm_crtc *crtc,
x = plane->state->crtc_x; x = plane->state->crtc_x;
y = plane->state->crtc_y; y = plane->state->crtc_y;
if (x <= -amdgpu_crtc->max_cursor_width ||
y <= -amdgpu_crtc->max_cursor_height)
return 0;
if (crtc->primary->state) { if (crtc->primary->state) {
/* avivo cursor are offset into the total surface */ /* avivo cursor are offset into the total surface */
x += crtc->primary->state->src_x >> 16; x += crtc->primary->state->src_x >> 16;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment