Revert "mediatek: ensure stride meets Android requirement for YVU420"
This reverts commit 23d5fb3e838e89c06452715446d58b677ad3a9ac.
Reason for revert: breaks mtk boards with img gpu
Original change's description:
> mediatek: ensure stride meets Android requirement for YVU420
>
> Android YV12 requires "c_stride = ALIGN(stride/2, 16)", and is
reflected
> in drv_bo_from_format_and_padding.
>
> BUG=b:239243515
> TEST=build
>
> Change-Id: Ifb7641f5f818f96d40af460fc9d266cd9689f48a
> Reviewed-on:
https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3919605
> Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
> Commit-Queue: Fei Shao <fshao@chromium.org>
> Reviewed-by: Ryan Neph <ryanneph@google.com>
> Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
BUG=b:251373007
BUG=b:251376604
BUG=b:251377527
BUG=b:251372443
BUG=b:251035349
BUG=b:251721989
TEST=regression fixed
Change-Id: I00b8dddd40fe313cecf99468ef97cb4064322628
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3939484
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
diff --git a/mediatek.c b/mediatek.c
index 7f780f0..7956cdc 100644
--- a/mediatek.c
+++ b/mediatek.c
@@ -7,7 +7,6 @@
#ifdef DRV_MEDIATEK
// clang-format off
-#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
@@ -87,33 +86,6 @@
return false;
}
-static uint32_t get_format_horizontal_alignment(uint32_t format)
-{
-#ifdef DONT_USE_64_ALIGNMENT_FOR_VIDEO_BUFFERS
- switch (format) {
- case DRM_FORMAT_NV21:
- case DRM_FORMAT_NV12:
- case DRM_FORMAT_YUYV:
- return 16;
- case DRM_FORMAT_YVU420:
- case DRM_FORMAT_YVU420_ANDROID:
- /* see drv_bo_from_format_and_padding */
- return 32;
- default:
- assert(!is_video_yuv_format(format));
- break;
- }
-#endif
-
- /*
- * Since the ARM L1 cache line size is 64 bytes, align to that as a
- * performance optimization, except for video buffers on certain platforms,
- * these should only be accessed from the GPU and VCODEC subsystems (maybe
- * also MDP), so it's better to align to macroblocks.
- */
- return 64;
-}
-
static int mediatek_init(struct driver *drv)
{
struct format_metadata metadata;
@@ -196,8 +168,19 @@
return -EINVAL;
}
+ /*
+ * Since the ARM L1 cache line size is 64 bytes, align to that as a
+ * performance optimization, except for video buffers on certain platforms,
+ * these should only be accessed from the GPU and VCODEC subsystems (maybe
+ * also MDP), so it's better to align to macroblocks.
+ */
stride = drv_stride_from_format(format, width, 0);
- stride = ALIGN(stride, get_format_horizontal_alignment(format));
+#ifdef DONT_USE_64_ALIGNMENT_FOR_VIDEO_BUFFERS
+ const uint32_t alignment = is_video_yuv_format(format) ? 16 : 64;
+ stride = ALIGN(stride, alignment);
+#else
+ stride = ALIGN(stride, 64);
+#endif
if ((bo->meta.use_flags & BO_USE_HW_VIDEO_ENCODER) || is_camera_preview) {
uint32_t aligned_height = ALIGN(height, 32);