From 72787589097c15d1a9e1529b4ff627c0e2f67b4a Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Tue, 1 Dec 2020 12:13:13 -0800 Subject: [PATCH] minigbm/msm: Double pitch alignment for YUV Something somewhere is assuming the UV pitch can be half of the Y pitch, leading to failures with CtsMediaTestCases#android.media.cts.DecodeAccuracyTest To componsate, double the pitch alignment requirement for YUV formats. BUG=b:159504968, b:165333514 TEST=run CtsMediaTestCases#android.media.cts.DecodeAccuracyTest Change-Id: I0118d813576654c72ed55500d741cf07a1977b20 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2568395 Commit-Queue: Rob Clark Commit-Queue: Kristian H. Kristensen Tested-by: Rob Clark Auto-Submit: Rob Clark Reviewed-by: Kristian H. Kristensen Reviewed-by: Alexandre Courbot --- msm.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/msm.c b/msm.c index add04a8..033dda5 100644 --- a/msm.c +++ b/msm.c @@ -66,6 +66,24 @@ static uint32_t get_ubwc_meta_size(uint32_t width, uint32_t height, uint32_t til return ALIGN(macrotile_width * macrotile_height, PLANE_SIZE_ALIGN); } +static unsigned get_pitch_alignment(struct bo *bo) +{ + switch (bo->meta.format) { + case DRM_FORMAT_NV12: + return VENUS_STRIDE_ALIGN; + case DRM_FORMAT_YVU420: + case DRM_FORMAT_YVU420_ANDROID: + /* TODO other YUV formats? */ + /* Something (in the video stack?) assumes the U/V planes can use + * half the pitch as the Y plane.. to componsate, double the + * alignment: + */ + return 2 * DEFAULT_ALIGNMENT; + default: + return DEFAULT_ALIGNMENT; + } +} + static void msm_calculate_layout(struct bo *bo) { uint32_t width, height; @@ -108,7 +126,7 @@ static void msm_calculate_layout(struct bo *bo) } else { uint32_t stride, alignw, alignh; - alignw = ALIGN(width, DEFAULT_ALIGNMENT); + alignw = ALIGN(width, get_pitch_alignment(bo)); /* HAL_PIXEL_FORMAT_YV12 requires that the buffer's height not be aligned. DRM_FORMAT_R8 of height one is used for JPEG camera output, so don't height align that. */ -- 2.11.0