drm/amd/display: Disable cursor when offscreen in negative direction
[linux-2.6-block.git] / drivers / gpu / drm / amd / display / amdgpu_dm / amdgpu_dm.c
index 995f9df66142ef92e11f465aae065541d91a3873..1e8b51d21feabe0e6933d1734f38fdd9abdd8f98 100644 (file)
@@ -4945,12 +4945,12 @@ static int get_cursor_position(struct drm_plane *plane, struct drm_crtc *crtc,
        int x, y;
        int xorigin = 0, yorigin = 0;
 
-       if (!crtc || !plane->state->fb) {
-               position->enable = false;
-               position->x = 0;
-               position->y = 0;
+       position->enable = false;
+       position->x = 0;
+       position->y = 0;
+
+       if (!crtc || !plane->state->fb)
                return 0;
-       }
 
        if ((plane->state->crtc_w > amdgpu_crtc->max_cursor_width) ||
            (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,
        x = plane->state->crtc_x;
        y = plane->state->crtc_y;
 
+       if (x <= -amdgpu_crtc->max_cursor_width ||
+           y <= -amdgpu_crtc->max_cursor_height)
+               return 0;
+
        if (crtc->primary->state) {
                /* avivo cursor are offset into the total surface */
                x += crtc->primary->state->src_x >> 16;