OSDN Git Service

msm: allow allocation of NV12 dumb buffers
[android-x86/external-minigbm.git] / msm.c
diff --git a/msm.c b/msm.c
index 420abfd..2b9bb48 100644 (file)
--- a/msm.c
+++ b/msm.c
 static const uint32_t render_target_formats[] = { DRM_FORMAT_ARGB8888, DRM_FORMAT_BGR888,
                                                  DRM_FORMAT_XRGB8888 };
 
+static const uint32_t supported_formats[] = { DRM_FORMAT_NV12 };
+
 static int msm_init(struct driver *drv)
 {
        drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
                             &LINEAR_METADATA, BO_USE_RENDER_MASK);
 
+       drv_add_combinations(drv, supported_formats, ARRAY_SIZE(supported_formats),
+                            &LINEAR_METADATA, BO_USE_TEXTURE_MASK | BO_USE_HW_VIDEO_DECODER);
+
        return drv_modify_linear_combinations(drv);
 }
 
@@ -34,6 +39,11 @@ static int msm_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32_
        if (bo->format == DRM_FORMAT_YVU420_ANDROID)
                height = bo->height;
 
+       /* Adjust the height of NV12 buffers to include room for the UV plane */
+       /* The extra 12KB at the end are a requirement of the Venus codec driver */
+       if (bo->format == DRM_FORMAT_NV12)
+               height += DIV_ROUND_UP(height, 2) + DIV_ROUND_UP(0x3000, width);
+
        return drv_dumb_bo_create(bo, width, height, format, flags);
 }