From 10a11801089d87c1371e0b02b8c987b1d3417c61 Mon Sep 17 00:00:00 2001 From: Gurchetan Singh Date: Fri, 23 Sep 2016 15:27:07 -0700 Subject: [PATCH] minigbm: rockchip: enable NV12 for Android MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Tested-by: Gurchetan Singh Reviewed-by: Stéphane Marchesin --- rockchip.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/rockchip.c b/rockchip.c index e551099..c2b055e 100644 --- a/rockchip.c +++ b/rockchip.c @@ -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 " -- 2.11.0