78be73b
From patchwork Wed Jul 25 12:29:07 2018
78be73b
Content-Type: text/plain; charset="utf-8"
78be73b
MIME-Version: 1.0
78be73b
Content-Transfer-Encoding: 7bit
78be73b
Subject: drm/vc4: Fix the "no scaling" case on multi-planar YUV formats
78be73b
From: Boris Brezillon <boris.brezillon@bootlin.com>
78be73b
X-Patchwork-Id: 240917
78be73b
Message-Id: <20180725122907.13702-1-boris.brezillon@bootlin.com>
78be73b
To: Eric Anholt <eric@anholt.net>
78be73b
Cc: David Airlie <airlied@linux.ie>,
78be73b
 Boris Brezillon <boris.brezillon@bootlin.com>, stable@vger.kernel.org,
78be73b
 dri-devel@lists.freedesktop.org
78be73b
Date: Wed, 25 Jul 2018 14:29:07 +0200
78be73b
78be73b
When there's no scaling requested ->is_unity should be true no matter
78be73b
the format.
78be73b
78be73b
Also, when no scaling is requested and we have a multi-planar YUV
78be73b
format, we should leave ->y_scaling[0] to VC4_SCALING_NONE and only
78be73b
set ->x_scaling[0] to VC4_SCALING_PPF.
78be73b
78be73b
Doing this fixes an hardly visible artifact (seen when using modetest
78be73b
and a rather big overlay plane in YUV420).
78be73b
78be73b
Fixes: fc04023fafec ("drm/vc4: Add support for YUV planes.")
78be73b
Cc: <stable@vger.kernel.org>
78be73b
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
78be73b
Reviewed-by: Eric Anholt <eric@anholt.net>
78be73b
---
78be73b
 drivers/gpu/drm/vc4/vc4_plane.c | 25 ++++++++++++-------------
78be73b
 1 file changed, 12 insertions(+), 13 deletions(-)
78be73b
78be73b
diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c
78be73b
index cfb50fedfa2b..a3275fa66b7b 100644
78be73b
--- a/drivers/gpu/drm/vc4/vc4_plane.c
78be73b
+++ b/drivers/gpu/drm/vc4/vc4_plane.c
78be73b
@@ -297,6 +297,9 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state)
78be73b
 	vc4_state->y_scaling[0] = vc4_get_scaling_mode(vc4_state->src_h[0],
78be73b
 						       vc4_state->crtc_h);
78be73b
 
78be73b
+	vc4_state->is_unity = (vc4_state->x_scaling[0] == VC4_SCALING_NONE &&
78be73b
+			       vc4_state->y_scaling[0] == VC4_SCALING_NONE);
78be73b
+
78be73b
 	if (num_planes > 1) {
78be73b
 		vc4_state->is_yuv = true;
78be73b
 
78be73b
@@ -312,24 +315,17 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state)
78be73b
 			vc4_get_scaling_mode(vc4_state->src_h[1],
78be73b
 					     vc4_state->crtc_h);
78be73b
 
78be73b
-		/* YUV conversion requires that scaling be enabled,
78be73b
-		 * even on a plane that's otherwise 1:1.  Choose TPZ
78be73b
-		 * for simplicity.
78be73b
+		/* YUV conversion requires that horizontal scaling be enabled,
78be73b
+		 * even on a plane that's otherwise 1:1. Looks like only PPF
78be73b
+		 * works in that case, so let's pick that one.
78be73b
 		 */
78be73b
-		if (vc4_state->x_scaling[0] == VC4_SCALING_NONE)
78be73b
-			vc4_state->x_scaling[0] = VC4_SCALING_TPZ;
78be73b
-		if (vc4_state->y_scaling[0] == VC4_SCALING_NONE)
78be73b
-			vc4_state->y_scaling[0] = VC4_SCALING_TPZ;
78be73b
+		if (vc4_state->is_unity)
78be73b
+			vc4_state->x_scaling[0] = VC4_SCALING_PPF;
78be73b
 	} else {
78be73b
 		vc4_state->x_scaling[1] = VC4_SCALING_NONE;
78be73b
 		vc4_state->y_scaling[1] = VC4_SCALING_NONE;
78be73b
 	}
78be73b
 
78be73b
-	vc4_state->is_unity = (vc4_state->x_scaling[0] == VC4_SCALING_NONE &&
78be73b
-			       vc4_state->y_scaling[0] == VC4_SCALING_NONE &&
78be73b
-			       vc4_state->x_scaling[1] == VC4_SCALING_NONE &&
78be73b
-			       vc4_state->y_scaling[1] == VC4_SCALING_NONE);
78be73b
-
78be73b
 	/* No configuring scaling on the cursor plane, since it gets
78be73b
 	   non-vblank-synced updates, and scaling requires requires
78be73b
 	   LBM changes which have to be vblank-synced.
78be73b
@@ -672,7 +668,10 @@ static int vc4_plane_mode_set(struct drm_plane *plane,
78be73b
 		vc4_dlist_write(vc4_state, SCALER_CSC2_ITR_R_601_5);
78be73b
 	}
78be73b
 
78be73b
-	if (!vc4_state->is_unity) {
78be73b
+	if (vc4_state->x_scaling[0] != VC4_SCALING_NONE ||
78be73b
+	    vc4_state->x_scaling[1] != VC4_SCALING_NONE ||
78be73b
+	    vc4_state->y_scaling[0] != VC4_SCALING_NONE ||
78be73b
+	    vc4_state->y_scaling[1] != VC4_SCALING_NONE) {
78be73b
 		/* LBM Base Address. */
78be73b
 		if (vc4_state->y_scaling[0] != VC4_SCALING_NONE ||
78be73b
 		    vc4_state->y_scaling[1] != VC4_SCALING_NONE) {