summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Thompson <sw@jkqxz.net>2017-07-09 22:28:53 +0100
committerXiang, Haihao <haihao.xiang@intel.com>2017-11-22 15:00:47 -0800
commitfcb9cc881596d7ff809adf5f6ff631c708d407e3 (patch)
treebad1950828f4e258dbdaf038ec7848c3c7f83478
parent6bdf6a195bb1cf7734bd8754395a8a95b56fdec1 (diff)
downloadlibva-fcb9cc881596d7ff809adf5f6ff631c708d407e3.tar.gz
Add a new interface for exporting surfaces
Signed-off-by: Mark Thompson <sw@jkqxz.net>
-rw-r--r--va/va.c17
-rw-r--r--va/va.h62
-rw-r--r--va/va_backend.h12
3 files changed, 90 insertions, 1 deletions
diff --git a/va/va.c b/va/va.c
index 86ca317..ea0cfd2 100644
--- a/va/va.c
+++ b/va/va.c
@@ -1457,6 +1457,23 @@ vaReleaseBufferHandle(VADisplay dpy, VABufferID buf_id)
return ctx->vtable->vaReleaseBufferHandle(ctx, buf_id);
}
+VAStatus
+vaExportSurfaceHandle(VADisplay dpy, VASurfaceID surface_id,
+ uint32_t mem_type, uint32_t flags,
+ void *descriptor)
+{
+ VADriverContextP ctx;
+
+ CHECK_DISPLAY(dpy);
+ ctx = CTX(dpy);
+
+ if (!ctx->vtable->vaExportSurfaceHandle)
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+ return ctx->vtable->vaExportSurfaceHandle(ctx, surface_id,
+ mem_type, flags,
+ descriptor);
+}
+
VAStatus vaBeginPicture (
VADisplay dpy,
VAContextID context,
diff --git a/va/va.h b/va/va.h
index c6d435a..073a5a7 100644
--- a/va/va.h
+++ b/va/va.h
@@ -3303,6 +3303,68 @@ vaAcquireBufferHandle(VADisplay dpy, VABufferID buf_id, VABufferInfo *buf_info);
VAStatus
vaReleaseBufferHandle(VADisplay dpy, VABufferID buf_id);
+/** @name vaExportSurfaceHandle() flags
+ *
+ * @{
+ */
+/** Export surface to be read by external API. */
+#define VA_EXPORT_SURFACE_READ_ONLY 0x0001
+/** Export surface to be written by external API. */
+#define VA_EXPORT_SURFACE_WRITE_ONLY 0x0002
+/** Export surface to be both read and written by external API. */
+#define VA_EXPORT_SURFACE_READ_WRITE 0x0003
+/** Export surface with separate layers.
+ *
+ * For example, NV12 surfaces should be exported as two separate
+ * planes for luma and chroma.
+ */
+#define VA_EXPORT_SURFACE_SEPARATE_LAYERS 0x0004
+/** Export surface with composed layers.
+ *
+ * For example, NV12 surfaces should be exported as a single NV12
+ * composed object.
+ */
+#define VA_EXPORT_SURFACE_COMPOSED_LAYERS 0x0008
+
+/** @} */
+
+/**
+ * \brief Export a handle to a surface for use with an external API
+ *
+ * The exported handles are owned by the caller, and the caller is
+ * responsible for freeing them when no longer needed (e.g. by closing
+ * DRM PRIME file descriptors).
+ *
+ * This does not perform any synchronisation. If the contents of the
+ * surface will be read, vaSyncSurface() must be called before doing so.
+ * If the contents of the surface are written, then all operations must
+ * be completed externally before using the surface again by via VA-API
+ * functions.
+ *
+ * @param[in] dpy VA display.
+ * @param[in] surface_id Surface to export.
+ * @param[in] mem_type Memory type to export to.
+ * @param[in] flags Combination of flags to apply
+ * (VA_EXPORT_SURFACE_*).
+ * @param[out] descriptor Pointer to the descriptor structure to fill
+ * with the handle details. The type of this structure depends on
+ * the value of mem_type.
+ *
+ * @return Status code:
+ * - VA_STATUS_SUCCESS: Success.
+ * - VA_STATUS_ERROR_INVALID_DISPLAY: The display is not valid.
+ * - VA_STATUS_ERROR_UNIMPLEMENTED: The driver does not implement
+ * this interface.
+ * - VA_STATUS_ERROR_INVALID_SURFACE: The surface is not valid, or
+ * the surface is not exportable in the specified way.
+ * - VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE: The driver does not
+ * support exporting surfaces to the specified memory type.
+ */
+VAStatus vaExportSurfaceHandle(VADisplay dpy,
+ VASurfaceID surface_id,
+ uint32_t mem_type, uint32_t flags,
+ void *descriptor);
+
/**
* Render (Video Decode/Encode/Processing) Pictures
*
diff --git a/va/va_backend.h b/va/va_backend.h
index f095c83..8deb979 100644
--- a/va/va_backend.h
+++ b/va/va_backend.h
@@ -476,8 +476,18 @@ struct VADriverVTable
VAProcessingRateParameter *proc_buf,/* in */
unsigned int *processing_rate /* out */
);
+
+ VAStatus
+ (*vaExportSurfaceHandle)(
+ VADriverContextP ctx,
+ VASurfaceID surface_id, /* in */
+ uint32_t mem_type, /* in */
+ uint32_t flags, /* in */
+ void *descriptor /* out */
+ );
+
/** \brief Reserved bytes for future use, must be zero */
- unsigned long reserved[58];
+ unsigned long reserved[57];
};
struct VADriverContext