OSDN Git Service

minigbm: rockchip: enable NV12 for Android
authorGurchetan Singh <gurchetansingh@chromium.org>
Fri, 23 Sep 2016 22:27:07 +0000 (15:27 -0700)
committerchrome-bot <chrome-bot@chromium.org>
Tue, 18 Oct 2016 04:55:52 +0000 (21:55 -0700)
For NV12 buffers to work on Android, we need to use the same
logic that we use in gralloc_drm_rockchip.  Otherwise, video
playback doesn't work in the container.

BUG=chromium:616275
TEST=Play Youtube app.  Also ran plane_test (which defaults to NV12).
CQ-DEPEND=CL:392547

Change-Id: I8dbd989f2638c99200866f8191450c71114bdbe5
Reviewed-on: https://chromium-review.googlesource.com/392548
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
rockchip.c

index e551099..c2b055e 100644 (file)
@@ -26,17 +26,24 @@ static int rockchip_bo_create(struct bo *bo, uint32_t width, uint32_t height,
        struct drm_rockchip_gem_create gem_create;
 
        if (format == DRV_FORMAT_NV12) {
-               width = ALIGN(width, 4);
-               height = ALIGN(height, 4);
-       }
+               uint32_t w_mbs = DIV_ROUND_UP(ALIGN(width, 16), 16);
+               uint32_t h_mbs = DIV_ROUND_UP(ALIGN(width, 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, width, height, format);
+               drv_bo_from_format(bo, aligned_width, height, format);
+               bo->total_size = bo->strides[0] * aligned_height
+                                + w_mbs * h_mbs * 128;
+       } else {
+               drv_bo_from_format(bo, width, height, format);
+       }
 
        memset(&gem_create, 0, sizeof(gem_create));
        gem_create.size = bo->total_size;
 
        ret = drmIoctl(bo->drv->fd, DRM_IOCTL_ROCKCHIP_GEM_CREATE,
-                          &gem_create);
+                      &gem_create);
 
        if (ret) {
                fprintf(stderr, "drv: DRM_IOCTL_ROCKCHIP_GEM_CREATE failed "