From 8f543b5658b90db041ba750b67733bce22831ce2 Mon Sep 17 00:00:00 2001 From: XinfengZhang Date: Fri, 28 Sep 2018 21:14:51 +0800 Subject: [PATCH] add gpu accelarate copy interface Signed-off-by: XinfengZhang --- va/va.c | 38 ++++++++++++++++++++++++++++++++++++++ va/va.h | 30 ++++++++++++++++++++++++++++++ va/va_backend.h | 16 +++++++++++++++- 3 files changed, 83 insertions(+), 1 deletion(-) diff --git a/va/va.c b/va/va.c index a6a58aa00..a71f80ec9 100644 --- a/va/va.c +++ b/va/va.c @@ -2128,3 +2128,41 @@ vaQueryVideoProcPipelineCaps( ); return status; } + +VAStatus +vaHWAsstCopy( + VADisplay dpy, + VAHWCpObject *dst, + VAHWCpObject *src, + uint32_t option, + uintptr_t* cphandle +) +{ + VAStatus va_status; + VADriverContextP ctx; + CHECK_DISPLAY(dpy); + ctx = CTX(dpy); + + if(ctx->vtable->vaHWAsstCopy == NULL) + va_status = VA_STATUS_ERROR_UNIMPLEMENTED; + else + va_status = ctx->vtable->vaHWAsstCopy( ctx, dst, src, option, cphandle); + return va_status; +} + +VAStatus +vaHWAsstCopyWait( + VADisplay dpy, + uintptr_t cphandle +) +{ + VAStatus va_status; + VADriverContextP ctx; + CHECK_DISPLAY(dpy); + ctx = CTX(dpy); + if(ctx->vtable->vaHWAsstCopyWait == NULL) + va_status = VA_STATUS_ERROR_UNIMPLEMENTED; + else + va_status = ctx->vtable->vaHWAsstCopyWait( ctx, cphandle); + return va_status; +} diff --git a/va/va.h b/va/va.h index 217d60caf..f42dcb7c6 100644 --- a/va/va.h +++ b/va/va.h @@ -4492,6 +4492,36 @@ typedef struct _VAPictureHEVC */ #define VA_PICTURE_HEVC_RPS_LT_CURR 0x00000040 +typedef enum{ + VAHWAsstCopyObjSurface = 0, + VAHWAsstCopyObjBuffer = 1, + VAHWAsstCopyObjUserPTR = 2 +}VAHWAsstCopyObjType; + +typedef struct _VAHWCpObject{ + union + { + VASurfaceID surface_id; + VABufferID Buffer_id; + uint8_t * userptr; //pointer to system memory + }obj; + VAHWAsstCopyObjType obj_type; //type of object. + uint32_t size; // for userptr, it should be same with surface/buffer size + uint32_t width_stride; // for user ptr only, + uint32_t height_stride; // for user ptr only + uint32_t va_reserved[VA_PADDING_LOW]; +}VAHWCpObject; + +#define VA_GPU_ACCEL_COPY_BLOCK 0x00000001 +#define VA_GPU_ACCEL_COPY_NONBLOCK 0x00000002 + +/** GPU accelarate copy + * it can be block copy or non block copy + * if it is non block copy, a handle is returned for wait funtion*/ +VAStatus vaHWAsstCopy(VADisplay dpy,VAHWCpObject * dst, VAHWCpObject * src, uint32_t option, uintptr_t* cphandle); + +VAStatus vaHWAsstCopyWait(VADisplay dpy, uintptr_t cphandle); + #include #include #include diff --git a/va/va_backend.h b/va/va_backend.h index 8deb97985..9940db1f9 100644 --- a/va/va_backend.h +++ b/va/va_backend.h @@ -485,9 +485,23 @@ struct VADriverVTable uint32_t flags, /* in */ void *descriptor /* out */ ); + VAStatus + (*vaHWAsstCopy)( + VADriverContextP ctx, /* in */ + VAHWCpObject *dst, /* in */ + VAHWCpObject *src, /* in */ + uint32_t option, /* in */ + uintptr_t* cphandle /* out */ + ); + + VAStatus + (*vaHWAsstCopyWait)( + VADriverContextP ctx, /* in */ + uintptr_t cphandle /* in */ + ); /** \brief Reserved bytes for future use, must be zero */ - unsigned long reserved[57]; + unsigned long reserved[55]; }; struct VADriverContext