drm/vc4: Fix margin calculations for the right/bottom edges
authorDave Stevenson <dave.stevenson@raspberrypi.com>
Mon, 12 Jul 2021 11:27:59 +0000 (12:27 +0100)
committerPhil Elwell <8911409+pelwell@users.noreply.github.com>
Mon, 12 Jul 2021 13:27:27 +0000 (14:27 +0100)
The calculations clipped the right/bottom edge of the clipped
range based on the left/top margins.

Fixes: 666e73587f90 ("drm/vc4: Take margin setup into account when updating planes")
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
drivers/gpu/drm/vc4/vc4_plane.c

index faa1ce6..7947cf4 100644 (file)
@@ -310,16 +310,16 @@ static int vc4_plane_margins_adj(struct drm_plane_state *pstate)
                                               adjhdisplay,
                                               crtc_state->mode.hdisplay);
        vc4_pstate->crtc_x += left;
-       if (vc4_pstate->crtc_x > crtc_state->mode.hdisplay - left)
-               vc4_pstate->crtc_x = crtc_state->mode.hdisplay - left;
+       if (vc4_pstate->crtc_x > crtc_state->mode.hdisplay - right)
+               vc4_pstate->crtc_x = crtc_state->mode.hdisplay - right;
 
        adjvdisplay = crtc_state->mode.vdisplay - (top + bottom);
        vc4_pstate->crtc_y = DIV_ROUND_CLOSEST(vc4_pstate->crtc_y *
                                               adjvdisplay,
                                               crtc_state->mode.vdisplay);
        vc4_pstate->crtc_y += top;
-       if (vc4_pstate->crtc_y > crtc_state->mode.vdisplay - top)
-               vc4_pstate->crtc_y = crtc_state->mode.vdisplay - top;
+       if (vc4_pstate->crtc_y > crtc_state->mode.vdisplay - bottom)
+               vc4_pstate->crtc_y = crtc_state->mode.vdisplay - bottom;
 
        vc4_pstate->crtc_w = DIV_ROUND_CLOSEST(vc4_pstate->crtc_w *
                                               adjhdisplay,