Revert "minigbm: rockchip: align NV12 planes to 64 bytes"

This reverts commit 33cca93af658650b655b4b5dcfb18a3235a100cf.

Reason for revert:

Many CTS tests are failed by the change, and video playback is corrupted on Youtube/Netflix app.

Original change's description:
> minigbm: rockchip: align NV12 planes to 64 bytes
>
> When running the mapped_texture_test with the Mali EGL implementation
> compiled with debug symbols, Mali complains that the NV12 planes are
> not sufficiently aligned (specifically, mali_cobj_surface.c line 1806).
> Fix this.
>
> BUG=b:63910596
> TEST=run Youtube App video on Kevin, at fullscreen and at normal size
>
> Change-Id: Ia204360c3aebe2bbd545ac7be0f6d095b0412f9d
> Reviewed-on: https://chromium-review.googlesource.com/556540
> Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
> Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
> Reviewed-by: Stphane Marchesin <marcheu@chromium.org>

Bug: b:63999659
Test: 1) run CTS on minnie: CtsVideoTestCases android.video.cts.VideoEncoderDecoderTest#testAvcGoog0Qual0720x0480, which fails on ToT and passes with the revert.
2) Play a video (size:426x240) on Youtube app. Video is corrupted on ToT and good with the revert.

Change-Id: I3418d0065733b4e0f99d1ab8c3cd416f7f454bc0
Reviewed-on: https://chromium-review.googlesource.com/583696
Commit-Ready: Pin-chih Lin <johnylin@chromium.org>
Tested-by: Pin-chih Lin <johnylin@chromium.org>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
diff --git a/rockchip.c b/rockchip.c
index d8f8cd3..66f1ea0 100644
--- a/rockchip.c
+++ b/rockchip.c
@@ -162,7 +162,16 @@
 	size_t plane;
 	struct drm_rockchip_gem_create gem_create;
 
-	if (width <= 2560 &&
+	if (format == DRM_FORMAT_NV12) {
+		uint32_t w_mbs = DIV_ROUND_UP(ALIGN(width, 16), 16);
+		uint32_t h_mbs = DIV_ROUND_UP(ALIGN(height, 16), 16);
+
+		uint32_t aligned_width = w_mbs * 16;
+		uint32_t aligned_height = DIV_ROUND_UP(h_mbs * 16 * 3, 2);
+
+		drv_bo_from_format(bo, aligned_width, height, format);
+		bo->total_size = bo->strides[0] * aligned_height + w_mbs * h_mbs * 128;
+	} else if (width <= 2560 &&
 		   has_modifier(modifiers, count, DRM_FORMAT_MOD_CHROMEOS_ROCKCHIP_AFBC)) {
 		/* If the caller has decided they can use AFBC, always
 		 * pick that */
@@ -174,34 +183,20 @@
 			return -1;
 		}
 
-		uint32_t stride, extra_size;
+		uint32_t stride;
 		/*
-		 * Since the ARM L1 cache line size is 64 bytes, align to that as a performance
-		 * optimization. For YV12, the Mali cmem allocator requires that chroma planes are
-		 * aligned to 64-bytes, so align the luma plane to 128 bytes.
+		 * Since the ARM L1 cache line size is 64 bytes, align to that
+		 * as a performance optimization. For YV12, the Mali cmem allocator
+		 * requires that chroma planes are aligned to 64-bytes, so align the
+		 * luma plane to 128 bytes.
 		 */
-		extra_size = 0;
 		stride = drv_stride_from_format(format, width, 0);
 		if (format == DRM_FORMAT_YVU420 || format == DRM_FORMAT_YVU420_ANDROID)
 			stride = ALIGN(stride, 128);
 		else
 			stride = ALIGN(stride, 64);
 
-		if (format == DRM_FORMAT_NV12) {
-			/* RK VPU needs the buffers macroblock-aligned. */
-			stride = ALIGN(stride, 16);
-			height = ALIGN(height, 16);
-			/*
-			 * The RK VPU driver requires extra space for motion vectors. The amount
-			 * of extra space required is specified in 16x16 macroblocks.
-			 */
-			uint32_t w_mbs = DIV_ROUND_UP(stride, 16);
-			uint32_t h_mbs = DIV_ROUND_UP(height, 16);
-			extra_size = w_mbs * h_mbs * 128;
-		}
-
 		drv_bo_from_format(bo, stride, height, format);
-		bo->total_size += extra_size;
 	}
 
 	memset(&gem_create, 0, sizeof(gem_create));