OSDN Git Service

minigbm/msm: Double pitch alignment for YUV
authorRob Clark <robdclark@chromium.org>
Tue, 1 Dec 2020 20:13:13 +0000 (12:13 -0800)
committerCommit Bot <commit-bot@chromium.org>
Wed, 2 Dec 2020 16:20:56 +0000 (16:20 +0000)
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 <robdclark@chromium.org>
Commit-Queue: Kristian H. Kristensen <hoegsberg@chromium.org>
Tested-by: Rob Clark <robdclark@chromium.org>
Auto-Submit: Rob Clark <robdclark@chromium.org>
Reviewed-by: Kristian H. Kristensen <hoegsberg@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
msm.c

diff --git a/msm.c b/msm.c
index add04a8..033dda5 100644 (file)
--- 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);
 }
 
        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;
 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;
 
        } 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. */
                /* 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. */