From 915281cbe714b266ef29c5aea061c22b95eb2143 Mon Sep 17 00:00:00 2001 From: XinfengZhang Date: Fri, 28 Sep 2018 21:14:51 +0800 Subject: [PATCH] add vaCopy interface to copy surface and buffer Author:Dmitry Rogozhkin Author:XinfengZhang Signed-off-by: XinfengZhang --- va/va.c | 38 ++++++++++++++++++++++++++++++++++++++ va/va.h | 35 +++++++++++++++++++++++++++++++++++ va/va_backend.h | 16 +++++++++++++++- 3 files changed, 88 insertions(+), 1 deletion(-) diff --git a/va/va.c b/va/va.c index 8b0bee6f0..239406094 100644 --- a/va/va.c +++ b/va/va.c @@ -2247,3 +2247,41 @@ vaQueryVideoProcPipelineCaps( VA_TRACE_RET(dpy, status); return status; } + +VAStatus +vaCopy( + VADisplay dpy, + VACopyObject *src, + VACopyObject *dst, + uint32_t flags, + uintptr_t* sync_handle +) +{ + VAStatus va_status; + VADriverContextP ctx; + CHECK_DISPLAY(dpy); + ctx = CTX(dpy); + + if(ctx->vtable->vaCopy == NULL) + va_status = VA_STATUS_ERROR_UNIMPLEMENTED; + else + va_status = ctx->vtable->vaCopy( ctx, src, dst, flags, sync_handle); + return va_status; +} + +VAStatus +vaHWAccelCopyWait( + VADisplay dpy, + uintptr_t sync_handle +) +{ + VAStatus va_status; + VADriverContextP ctx; + CHECK_DISPLAY(dpy); + ctx = CTX(dpy); + if(ctx->vtable->vaCopyWait == NULL) + va_status = VA_STATUS_ERROR_UNIMPLEMENTED; + else + va_status = ctx->vtable->vaCopyWait( ctx, sync_handle); + return va_status; +} diff --git a/va/va.h b/va/va.h index 8e5f72107..ea84094ac 100755 --- a/va/va.h +++ b/va/va.h @@ -4620,6 +4620,41 @@ typedef struct _VAPictureHEVC */ #define VA_PICTURE_HEVC_RPS_LT_CURR 0x00000040 +typedef enum{ + VACopyObjectSurface = 0, + VACopyObjectBuffer = 1, +} VACopyObjectType; + +typedef struct _VACopyObject { + VACopyObjectType obj_type; // type of object. + union + { + VASurfaceID surface_id; + VABufferID buffer_id; + } object; + + uint32_t va_reserved[VA_PADDING_LOW]; +} VACopyObject; + +#define VA_COPY_BLOCK 0x00000001 +#define VA_COPY_NONBLOCK 0x00000002 + +/** \brief Copies an object. + * + * Copies specified object (surface or buffer). If non-blocking copy + * is requested (VA_COPY_NONBLOCK), sync_handle will contain a handle + * to pass to vaCopyWait to wait for completion. + * + * @param[in] dpy the VA display + * @param[in] src Source object to copy from + * @param[in,out] buf_info Destination object to copy to + * @param[out] sync_handle Synchronization handle to sync on + * @return VA_STATUS_SUCCESS if successful + */ +VAStatus vaCopy(VADisplay dpy, VACopyObject * src, VACopyObject * dst, uint32_t flags, uintptr_t* sync_handle); + +VAStatus vaCopyWait(VADisplay dpy, uintptr_t sync_handle); + #include #include #include diff --git a/va/va_backend.h b/va/va_backend.h index f2cd7b0f3..86ece732a 100644 --- a/va/va_backend.h +++ b/va/va_backend.h @@ -484,9 +484,23 @@ struct VADriverVTable uint32_t flags, /* in */ void *descriptor /* out */ ); + VAStatus + (*vaCopy)( + VADriverContextP ctx, /* in */ + VACopyObject *src, /* in */ + VACopyObject *dst, /* in */ + uint32_t flags, /* in */ + uintptr_t* sync_handle /* out */ + ); + + VAStatus + (*vaCopyWait)( + VADriverContextP ctx, /* in */ + uintptr_t sync_handle /* in */ + ); /** \brief Reserved bytes for future use, must be zero */ - unsigned long reserved[57]; + unsigned long reserved[55]; }; struct VADriverContext