minigbm: Added YV12 for Mali platforms
Oak-cheets is using YV12 as it's Android flexible YUV format, so
we need to support it. Additionally, we're trying to enable
YV12 on Mali with EXT_image_dma_buf_import. Instead of having
redundant switch statements in every driver, let's add a helper
function to do this.
BUG=chrome-os-partner:54632, b/29059119, chromium:616275
TEST=Ran plane_test, graphics_Gbm on veyron_minnie
Change-Id: I4798225db809941367e58dde962576535b8d767c
Reviewed-on: https://chromium-review.googlesource.com/377884
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
diff --git a/i915.c b/i915.c
index e2646ad..a3f9084 100644
--- a/i915.c
+++ b/i915.c
@@ -127,7 +127,7 @@
struct drm_i915_gem_create gem_create;
struct drm_i915_gem_set_tiling gem_set_tiling;
uint32_t tiling_mode = I915_TILING_NONE;
- size_t size, plane;
+ size_t plane;
int ret;
if (flags & (DRV_BO_USE_CURSOR | DRV_BO_USE_LINEAR |
@@ -142,34 +142,20 @@
i915_align_dimensions(drv, tiling_mode, &width, &height, bpp);
- switch (format) {
- case DRV_FORMAT_YVU420:
- bo->strides[0] = drv_stride_from_format(format, width, 0);
- bo->strides[1] = bo->strides[2] = drv_stride_from_format(format, width, 1);
- bo->sizes[0] = height * bo->strides[0];
- bo->sizes[1] = bo->sizes[2] = (height / 2) * bo->strides[1];
- bo->offsets[0] = 0;
- bo->offsets[1] = bo->sizes[0];
- bo->offsets[2] = bo->offsets[1] + bo->sizes[1];
- break;
- default:
- bo->strides[0] = drv_stride_from_format(format, width, 0);
- bo->sizes[0] = height * bo->strides[0];
- bo->offsets[0] = 0;
- }
+ drv_bo_from_format(bo, width, height, format);
if (!i915_verify_dimensions(drv, bo->strides[0], height))
return EINVAL;
- size = bo->offsets[bo->num_planes - 1] + bo->sizes[bo->num_planes - 1];
memset(&gem_create, 0, sizeof(gem_create));
- gem_create.size = size;
+ gem_create.size = bo->offsets[bo->num_planes - 1] +
+ bo->sizes[bo->num_planes - 1];
ret = drmIoctl(drv->fd, DRM_IOCTL_I915_GEM_CREATE, &gem_create);
if (ret) {
fprintf(stderr, "drv: DRM_IOCTL_I915_GEM_CREATE failed "
- "(size=%zu)\n", size);
+ "(size=%llu)\n", gem_create.size);
return ret;
}
@@ -219,7 +205,7 @@
bo->drv->fd, gem_map.offset);
}
-drv_format_t i915_resolve_format(drv_format_t format)
+static drv_format_t i915_resolve_format(drv_format_t format)
{
switch (format) {
case DRV_FORMAT_FLEX_IMPLEMENTATION_DEFINED: