- drv_bo_from_format(bo, stride, height, format);
+
+ if (bo->meta.use_flags & BO_USE_HW_VIDEO_ENCODER) {
+ uint32_t aligned_height = ALIGN(height, 32);
+ uint32_t padding[DRV_MAX_PLANES] = { 0 };
+
+ for (plane = 0; plane < bo->meta.num_planes; ++plane) {
+ uint32_t plane_stride = drv_stride_from_format(format, stride, plane);
+ padding[plane] = plane_stride *
+ (32 / drv_vertical_subsampling_from_format(format, plane));
+ }
+
+ drv_bo_from_format_and_padding(bo, stride, aligned_height, format, padding);
+ } else {
+#ifdef MTK_MT8183
+ /*
+ * JPEG Encoder Accelerator requires 16x16 alignment. We want the buffer
+ * from camera can be put in JEA directly so align the height to 16
+ * bytes.
+ */
+ if (format == DRM_FORMAT_NV12)
+ height = ALIGN(height, 16);
+#endif
+ drv_bo_from_format(bo, stride, height, format);
+ }