]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/vc4: plane: Fix margin calculations for the right/bottom edges
authorDave Stevenson <dave.stevenson@raspberrypi.com>
Mon, 13 Jun 2022 14:47:32 +0000 (16:47 +0200)
committerMaxime Ripard <maxime@cerno.tech>
Tue, 28 Jun 2022 12:55:06 +0000 (14:55 +0200)
The current plane margin calculation code clips the right and bottom
edges of the range based using the left and top margins.

This is obviously wrong, so let's fix it.

Fixes: 188f608deb8f ("drm/vc4: Take margin setup into account when updating planes")
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Link: https://lore.kernel.org/r/20220613144800.326124-6-maxime@cerno.tech
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
drivers/gpu/drm/vc4/vc4_plane.c

index c6d42041f4b3013ff444d8914d38c425f336a483..da850d09ef8d92c84a7d94958a031f266769cb55 100644 (file)
@@ -312,16 +312,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,