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 1854506e3e8f91cc3f5bd4082e30b3c043d0bbc0..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;
@@ -5242,7 +5246,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
                                    struct drm_crtc *pcrtc,
                                    bool wait_for_vblank)
 {
-       uint32_t i, r;
+       uint32_t i;
        uint64_t timestamp_ns;
        struct drm_plane *plane;
        struct drm_plane_state *old_plane_state, *new_plane_state;
@@ -5253,6 +5257,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
        struct dm_crtc_state *dm_old_crtc_state =
                        to_dm_crtc_state(drm_atomic_get_old_crtc_state(state, pcrtc));
        int planes_count = 0, vpos, hpos;
+       long r;
        unsigned long flags;
        struct amdgpu_bo *abo;
        uint64_t tiling_flags;