[Libva] [PATCH 2/3] extbuf: validate surface memory type.

Gwenole Beauchesne gb.devel at gmail.com
Thu Apr 2 06:28:19 PDT 2015


Shuffle the internal memory type ids by one, and turn them into clean
enum values. Also make sure to validate the VA surface memory type
early enough.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne at intel.com>
---
 src/i965_drv_video.c | 5 +++++
 src/i965_drv_video.h | 8 +++++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c
index 0b04bd5..799ebad 100644
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -1240,6 +1240,8 @@ i965_CreateSurfaces2(
                 memory_type = I965_SURFACE_MEM_DRM_PRIME; /* drm prime fd */
             else if (attrib_list[i].value.value.i == VA_SURFACE_ATTRIB_MEM_TYPE_VA)
                 memory_type = I965_SURFACE_MEM_NATIVE; /* va native memory, to be allocated */
+            else
+                memory_type = 0;
         }
 
         if ((attrib_list[i].type == VASurfaceAttribExternalBufferDescriptor) &&
@@ -1249,6 +1251,9 @@ i965_CreateSurfaces2(
         }
     }
 
+    if (!memory_type)
+        return VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE;
+
     /* support 420 & 422 & RGB32 format, 422 and RGB32 are only used
      * for post-processing (including color conversion) */
     if (VA_RT_FORMAT_YUV420 != format &&
diff --git a/src/i965_drv_video.h b/src/i965_drv_video.h
index 188cecf..c39d53b 100644
--- a/src/i965_drv_video.h
+++ b/src/i965_drv_video.h
@@ -505,9 +505,11 @@ extern VAStatus i965_CreateSurfaces(VADriverContextP ctx,
                     int num_surfaces,
                     VASurfaceID *surfaces);
 
-#define I965_SURFACE_MEM_NATIVE             0
-#define I965_SURFACE_MEM_GEM_FLINK          1
-#define I965_SURFACE_MEM_DRM_PRIME          2
+enum {
+    I965_SURFACE_MEM_NATIVE = 1,
+    I965_SURFACE_MEM_GEM_FLINK,
+    I965_SURFACE_MEM_DRM_PRIME,
+};
 
 void
 i965_destroy_surface_storage(struct object_surface *obj_surface);
-- 
1.9.1



More information about the Libva mailing list