OSDN Git Service

Make drv_mapping_destroy() be called in release builds
[android-x86/external-minigbm.git] / amdgpu.c
index fabedf3..436b892 100644 (file)
--- a/amdgpu.c
+++ b/amdgpu.c
@@ -37,8 +37,9 @@ const static uint32_t render_target_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMA
                                                  DRM_FORMAT_RGB565, DRM_FORMAT_XBGR8888,
                                                  DRM_FORMAT_XRGB8888 };
 
-const static uint32_t texture_source_formats[] = { DRM_FORMAT_GR88, DRM_FORMAT_R8, DRM_FORMAT_NV21,
-                                                  DRM_FORMAT_NV12, DRM_FORMAT_YVU420_ANDROID };
+const static uint32_t texture_source_formats[] = { DRM_FORMAT_GR88,          DRM_FORMAT_R8,
+                                                  DRM_FORMAT_NV21,           DRM_FORMAT_NV12,
+                                                  DRM_FORMAT_YVU420_ANDROID, DRM_FORMAT_YVU420 };
 
 static int amdgpu_init(struct driver *drv)
 {
@@ -78,12 +79,20 @@ static int amdgpu_init(struct driver *drv)
        drv_add_combinations(drv, texture_source_formats, ARRAY_SIZE(texture_source_formats),
                             &metadata, BO_USE_TEXTURE_MASK);
 
+       /*
+        * Chrome uses DMA-buf mmap to write to YV12 buffers, which are then accessed by the
+        * Video Encoder Accelerator (VEA). It could also support NV12 potentially in the future.
+        */
+       drv_modify_combination(drv, DRM_FORMAT_YVU420, &metadata, BO_USE_HW_VIDEO_ENCODER);
+       drv_modify_combination(drv, DRM_FORMAT_NV12, &metadata, BO_USE_HW_VIDEO_ENCODER);
+
        /* Android CTS tests require this. */
        drv_add_combination(drv, DRM_FORMAT_BGR888, &metadata, BO_USE_SW_MASK);
 
        /* Linear formats supported by display. */
        drv_modify_combination(drv, DRM_FORMAT_ARGB8888, &metadata, BO_USE_CURSOR | BO_USE_SCANOUT);
        drv_modify_combination(drv, DRM_FORMAT_XRGB8888, &metadata, BO_USE_CURSOR | BO_USE_SCANOUT);
+       drv_modify_combination(drv, DRM_FORMAT_ABGR8888, &metadata, BO_USE_SCANOUT);
        drv_modify_combination(drv, DRM_FORMAT_XBGR8888, &metadata, BO_USE_SCANOUT);
 
        /* YUV formats for camera and display. */
@@ -119,6 +128,7 @@ static int amdgpu_init(struct driver *drv)
        /* Potentially tiled formats supported by display. */
        drv_modify_combination(drv, DRM_FORMAT_ARGB8888, &metadata, BO_USE_CURSOR | BO_USE_SCANOUT);
        drv_modify_combination(drv, DRM_FORMAT_XRGB8888, &metadata, BO_USE_CURSOR | BO_USE_SCANOUT);
+       drv_modify_combination(drv, DRM_FORMAT_ABGR8888, &metadata, BO_USE_SCANOUT);
        drv_modify_combination(drv, DRM_FORMAT_XBGR8888, &metadata, BO_USE_SCANOUT);
        return 0;
 }
@@ -173,7 +183,7 @@ static int amdgpu_create_bo(struct bo *bo, uint32_t width, uint32_t height, uint
        drv_bo_from_format(bo, stride, height, format);
 
        memset(&gem_create, 0, sizeof(gem_create));
-       gem_create.in.bo_size = bo->total_size;
+       gem_create.in.bo_size = bo->meta.total_size;
        gem_create.in.alignment = 256;
        gem_create.in.domain_flags = 0;
 
@@ -190,7 +200,7 @@ static int amdgpu_create_bo(struct bo *bo, uint32_t width, uint32_t height, uint
        if (ret < 0)
                return ret;
 
-       for (plane = 0; plane < bo->num_planes; plane++)
+       for (plane = 0; plane < bo->meta.num_planes; plane++)
                bo->handles[plane].u32 = gem_create.out.handle;
 
        return 0;
@@ -234,9 +244,9 @@ static void *amdgpu_map_bo(struct bo *bo, struct vma *vma, size_t plane, uint32_
                return MAP_FAILED;
        }
 
-       vma->length = bo->total_size;
+       vma->length = bo->meta.total_size;
 
-       return mmap(0, bo->total_size, drv_get_prot(map_flags), MAP_SHARED, bo->drv->fd,
+       return mmap(0, bo->meta.total_size, drv_get_prot(map_flags), MAP_SHARED, bo->drv->fd,
                    gem_map.out.addr_ptr);
 }
 
@@ -274,7 +284,7 @@ static int amdgpu_bo_invalidate(struct bo *bo, struct mapping *mapping)
        return 0;
 }
 
-static uint32_t amdgpu_resolve_format(uint32_t format, uint64_t use_flags)
+static uint32_t amdgpu_resolve_format(struct driver *drv, uint32_t format, uint64_t use_flags)
 {
        switch (format) {
        case DRM_FORMAT_FLEX_IMPLEMENTATION_DEFINED: