From d8263cc5120e632b75e7c9c845710e8edc274dad Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Mon, 12 Jul 2021 12:27:59 +0100 Subject: [PATCH 1/2] drm/vc4: Fix margin calculations for the right/bottom edges 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 --- drivers/gpu/drm/vc4/vc4_plane.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c index faa1ce6d658444..7947cf47b6e134 100644 --- a/drivers/gpu/drm/vc4/vc4_plane.c +++ b/drivers/gpu/drm/vc4/vc4_plane.c @@ -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, From 6700a7909c8a2ecdecee30944b61ec49585cb5a1 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Mon, 12 Jul 2021 13:06:07 +0100 Subject: [PATCH 2/2] ydrm/vc4: fkms: Fix margin calculations for the right/bottom edges The calculations clipped the right/bottom edge of the clipped range based on the left/top margins. https://github.com/raspberrypi/linux/issues/4447 Signed-off-by: Dave Stevenson --- drivers/gpu/drm/vc4/vc4_firmware_kms.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_firmware_kms.c b/drivers/gpu/drm/vc4/vc4_firmware_kms.c index e643bbe9694101..d6d50b5f64dd0c 100644 --- a/drivers/gpu/drm/vc4/vc4_firmware_kms.c +++ b/drivers/gpu/drm/vc4/vc4_firmware_kms.c @@ -458,15 +458,15 @@ static int vc4_fkms_margins_adj(struct drm_plane_state *pstate, plane->dst_x = DIV_ROUND_CLOSEST(plane->dst_x * adjhdisplay, (int)crtc_state->mode.hdisplay); plane->dst_x += left; - if (plane->dst_x > (int)(crtc_state->mode.hdisplay - left)) - plane->dst_x = crtc_state->mode.hdisplay - left; + if (plane->dst_x > (int)(crtc_state->mode.hdisplay - right)) + plane->dst_x = crtc_state->mode.hdisplay - right; adjvdisplay = crtc_state->mode.vdisplay - (top + bottom); plane->dst_y = DIV_ROUND_CLOSEST(plane->dst_y * adjvdisplay, (int)crtc_state->mode.vdisplay); plane->dst_y += top; - if (plane->dst_y > (int)(crtc_state->mode.vdisplay - top)) - plane->dst_y = crtc_state->mode.vdisplay - top; + if (plane->dst_y > (int)(crtc_state->mode.vdisplay - bottom)) + plane->dst_y = crtc_state->mode.vdisplay - bottom; plane->dst_w = DIV_ROUND_CLOSEST(plane->dst_w * adjhdisplay, crtc_state->mode.hdisplay);