diff options
Diffstat (limited to 'va')
-rw-r--r-- | va/Makefile.am | 2 | ||||
-rw-r--r-- | va/egl/Makefile.am | 14 | ||||
-rw-r--r-- | va/egl/va_backend_egl.h | 51 | ||||
-rw-r--r-- | va/egl/va_egl.c | 240 | ||||
-rw-r--r-- | va/egl/va_egl.h | 27 | ||||
-rw-r--r-- | va/egl/va_egl_impl.c | 523 | ||||
-rw-r--r-- | va/egl/va_egl_impl.h | 39 | ||||
-rw-r--r-- | va/egl/va_egl_private.h | 98 | ||||
-rw-r--r-- | va/va_backend.h | 14 | ||||
-rw-r--r-- | va/va_egl.h | 202 | ||||
-rw-r--r-- | va/x11/va_x11.c | 43 |
11 files changed, 39 insertions, 1214 deletions
diff --git a/va/Makefile.am b/va/Makefile.am index 1c91dd7..44daac9 100644 --- a/va/Makefile.am +++ b/va/Makefile.am @@ -93,7 +93,7 @@ libva_egl_la_SOURCES = libva_egl_la_LDFLAGS = $(LDADD) libva_egl_la_DEPENDENCIES = $(libvacorelib) egl/libva_egl.la libva-x11.la libva_egl_la_LIBADD = $(libvacorelib) egl/libva_egl.la libva-x11.la \ - $(EGL_DEPS_LIBS) -ldl + $(GL_DEPS_LIBS) -ldl endif if BUILD_DUMMY_BACKEND diff --git a/va/egl/Makefile.am b/va/egl/Makefile.am index 52e7dc1..fd96a61 100644 --- a/va/egl/Makefile.am +++ b/va/egl/Makefile.am @@ -28,19 +28,13 @@ INCLUDES = \ $(NULL) source_c = \ - va_egl.c \ - va_egl_impl.c \ - $(NULL) + va_egl.c source_h = \ - ../va_egl.h \ - va_backend_egl.h \ - $(NULL) + va_egl.h \ + va_backend_egl.h -source_h_priv = \ - va_egl_impl.h \ - va_egl_private.h \ - $(NULL) +source_h_priv = noinst_LTLIBRARIES = libva_egl.la libva_eglincludedir = ${includedir}/va diff --git a/va/egl/va_backend_egl.h b/va/egl/va_backend_egl.h index bd0538c..925d933 100644 --- a/va/egl/va_backend_egl.h +++ b/va/egl/va_backend_egl.h @@ -25,7 +25,7 @@ #ifndef VA_BACKEND_EGL_H #define VA_BACKEND_EGL_H -#include <va/va_egl.h> +#include <va/va.h> #include <va/va_backend.h> struct VADriverVTableEGL { @@ -35,56 +35,7 @@ struct VADriverVTableEGL { VASurfaceID surface, void **buffer ); - /* TBD: more APIs for EGL */ - int max_egl_surface_targets; - int max_egl_surface_attributes; - - VAStatus (*vaQuerySurfaceTargetsEGL)( - VADriverContextP ctx, - EGLenum *target_list, /* out */ - int *num_targets /* out */ - ); - - VAStatus (*vaCreateSurfaceEGL)( - VADriverContextP ctx, - EGLenum target, - unsigned int width, - unsigned int height, - VASurfaceEGL *gl_surface - ); - - /* Optional: destroy a VA/EGL surface */ - VAStatus (*vaDestroySurfaceEGL)( - VADriverContextP ctx, - VASurfaceEGL egl_surface - ); - - VAStatus (*vaAssociateSurfaceEGL)( - VADriverContextP ctx, - VASurfaceEGL egl_surface, - VASurfaceID surface, - unsigned int flags - ); - - VAStatus (*vaSyncSurfaceEGL)( - VADriverContextP ctx, - VASurfaceEGL egl_surface - ); - - VAStatus (*vaGetSurfaceInfoEGL)( - VADisplay dpy, - VASurfaceEGL egl_surface, - EGLenum *target, - EGLClientBuffer *buffer, - EGLint *attrib_list, - int *num_attribs - ); - - VAStatus (*vaDeassociateSurfaceEGL)( - VADriverContextP ctx, - VASurfaceEGL egl_surface - ); }; #endif /* VA_BACKEND_EGL_H */ diff --git a/va/egl/va_egl.c b/va/egl/va_egl.c index 48ff7a1..36e5504 100644 --- a/va/egl/va_egl.c +++ b/va/egl/va_egl.c @@ -53,34 +53,14 @@ * * Bellow API vaGetEGLClientBufferFromSurface is for this purpose */ -#include "va_egl_private.h" -#include "va_egl_impl.h" + +#include "va.h" +#include "va_backend_egl.h" +#include "va_egl.h" #define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext) #define CHECK_DISPLAY(dpy) if( !vaDisplayIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; } -#define INIT_CONTEXT(ctx, dpy) do { \ - if (!vaDisplayIsValid(dpy)) \ - return VA_STATUS_ERROR_INVALID_DISPLAY; \ - \ - ctx = ((VADisplayContextP)(dpy))->pDriverContext; \ - if (!(ctx)) \ - return VA_STATUS_ERROR_INVALID_DISPLAY; \ - \ - status = va_egl_init_context(dpy); \ - if (status != VA_STATUS_SUCCESS) \ - return status; \ - } while (0) - -#define INVOKE(ctx, func, args) do { \ - VADriverVTablePrivEGLP vtable; \ - vtable = &VA_DRIVER_CONTEXT_EGL(ctx)->vtable; \ - if (!vtable->va##func##EGL) \ - return VA_STATUS_ERROR_UNIMPLEMENTED; \ - status = vtable->va##func##EGL args; \ - } while (0) - - VAStatus vaGetEGLClientBufferFromSurface ( VADisplay dpy, VASurfaceID surface, @@ -99,216 +79,4 @@ VAStatus vaGetEGLClientBufferFromSurface ( return VA_STATUS_ERROR_UNIMPLEMENTED; } -// Destroy VA/EGL display context -static void va_DisplayContextDestroy(VADisplayContextP pDisplayContext) -{ - VADisplayContextEGLP pDisplayContextEGL; - VADriverContextP pDriverContext; - VADriverContextEGLP pDriverContextEGL; - - if (!pDisplayContext) - return; - - pDriverContext = pDisplayContext->pDriverContext; - pDriverContextEGL = pDriverContext->egl; - if (pDriverContextEGL) { - free(pDriverContextEGL); - pDriverContext->egl = NULL; - } - - pDisplayContextEGL = pDisplayContext->opaque; - if (pDisplayContextEGL) { - vaDestroyFunc vaDestroy = pDisplayContextEGL->vaDestroy; - free(pDisplayContextEGL); - pDisplayContext->opaque = NULL; - if (vaDestroy) - vaDestroy(pDisplayContext); - } -} - -// Return a suitable VADisplay for VA API -VADisplay vaGetDisplayEGL(VANativeDisplay native_dpy, - EGLDisplay egl_dpy) -{ - VADisplay dpy = NULL; - VADisplayContextP pDisplayContext = NULL; - VADisplayContextEGLP pDisplayContextEGL = NULL; - VADriverContextP pDriverContext; - VADriverContextEGLP pDriverContextEGL = NULL; - - dpy = vaGetDisplay(native_dpy); - - if (!dpy) - return NULL; - - if (egl_dpy == EGL_NO_DISPLAY) - goto error; - - pDisplayContext = (VADisplayContextP)dpy; - pDriverContext = pDisplayContext->pDriverContext; - - pDisplayContextEGL = calloc(1, sizeof(*pDisplayContextEGL)); - if (!pDisplayContextEGL) - goto error; - - pDriverContextEGL = calloc(1, sizeof(*pDriverContextEGL)); - if (!pDriverContextEGL) - goto error; - - pDisplayContextEGL->vaDestroy = pDisplayContext->vaDestroy; - pDisplayContext->vaDestroy = va_DisplayContextDestroy; - pDisplayContext->opaque = pDisplayContextEGL; - pDriverContextEGL->egl_display = egl_dpy; - pDriverContext->egl = pDriverContextEGL; - return dpy; - -error: - free(pDriverContextEGL); - free(pDisplayContextEGL); - pDisplayContext->vaDestroy(pDisplayContext); - return NULL; -} - -int vaMaxNumSurfaceTargetsEGL( - VADisplay dpy -) -{ - VADriverContextP ctx; - struct VADriverVTableEGL *va_egl; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - va_egl = (struct VADriverVTableEGL *)ctx->vtable_egl; - - if (va_egl) - return va_egl->max_egl_surface_targets; - else - return IMPL_MAX_EGL_SURFACE_TARGETS; -} - -int vaMaxNumSurfaceAttributesEGL( - VADisplay dpy -) -{ - VADriverContextP ctx; - struct VADriverVTableEGL *va_egl; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - va_egl = (struct VADriverVTableEGL *)ctx->vtable_egl; - - if (va_egl) - return va_egl->max_egl_surface_attributes; - else - return IMPL_MAX_EGL_SURFACE_ATTRIBUTES; -} - -VAStatus vaQuerySurfaceTargetsEGL( - VADisplay dpy, - EGLenum *target_list, /* out */ - int *num_targets /* out */ -) -{ - VADriverContextP ctx; - VAStatus status; - - INIT_CONTEXT(ctx, dpy); - - INVOKE(ctx, QuerySurfaceTargets, (dpy, target_list, num_targets)); - return status; -} - -VAStatus vaCreateSurfaceEGL( - VADisplay dpy, - EGLenum target, - unsigned int width, - unsigned int height, - VASurfaceEGL *gl_surface -) -{ - VADriverContextP ctx; - VAStatus status; - - INIT_CONTEXT(ctx, dpy); - - INVOKE(ctx, CreateSurface, (dpy, target, width, height, gl_surface)); - return status; -} - -// Destroy a VA/EGL surface -VAStatus vaDestroySurfaceEGL( - VADisplay dpy, - VASurfaceEGL egl_surface -) -{ - VADriverContextP ctx; - VAStatus status; - - INIT_CONTEXT(ctx, dpy); - - INVOKE(ctx, DestroySurface, (dpy, egl_surface)); - return status; -} - -VAStatus vaAssociateSurfaceEGL( - VADisplay dpy, - VASurfaceEGL egl_surface, - VASurfaceID surface, - unsigned int flags -) -{ - VADriverContextP ctx; - VAStatus status; - - INIT_CONTEXT(ctx, dpy); - - INVOKE(ctx, AssociateSurface, (dpy, egl_surface, surface, flags)); - return status; -} - -VAStatus vaSyncSurfaceEGL( - VADisplay dpy, - VASurfaceEGL egl_surface -) -{ - VADriverContextP ctx; - VAStatus status; - - INIT_CONTEXT(ctx, dpy); - - INVOKE(ctx, SyncSurface, (dpy, egl_surface)); - return status; -} - -VAStatus vaGetSurfaceInfoEGL( - VADisplay dpy, - VASurfaceEGL egl_surface, - EGLenum *target, /* out, the type of <buffer> */ - EGLClientBuffer *buffer, /* out */ - EGLint *attrib_list, /* out, the last attribute must be EGL_NONE */ - int *num_attribs /* in/out */ -) -{ - VADriverContextP ctx; - VAStatus status; - - INIT_CONTEXT(ctx, dpy); - - INVOKE(ctx, GetSurfaceInfo, (dpy, egl_surface, target, buffer, attrib_list, num_attribs)); - return status; -} - -VAStatus vaDeassociateSurfaceEGL( - VADisplay dpy, - VASurfaceEGL egl_surface -) -{ - VADriverContextP ctx; - VAStatus status; - - INIT_CONTEXT(ctx, dpy); - - INVOKE(ctx, DeassociateSurface, (dpy, egl_surface)); - return status; -} diff --git a/va/egl/va_egl.h b/va/egl/va_egl.h new file mode 100644 index 0000000..4243d0b --- /dev/null +++ b/va/egl/va_egl.h @@ -0,0 +1,27 @@ +#ifndef _VA_EGL_H_ +#define _VA_EGL_H_ + +#include <va/va.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void* EGLClientBuffer; + +/*This function is used to get EGLClientBuffer + * (lower 16bits is buffer index, upper 16bits + * is BC device id.) from surface id. Application + * should maintain EGLClientBuffer itself.*/ + +VAStatus vaGetEGLClientBufferFromSurface ( + VADisplay dpy, + VASurfaceID surface, + EGLClientBuffer *buffer /* out*/ +); + +#ifdef __cplusplus +} +#endif + +#endif /* _VA_EGL_H_ */ diff --git a/va/egl/va_egl_impl.c b/va/egl/va_egl_impl.c deleted file mode 100644 index 25996b5..0000000 --- a/va/egl/va_egl_impl.c +++ /dev/null @@ -1,523 +0,0 @@ -/* - * Copyright (c) 2012 Intel Corporation. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#define _GNU_SOURCE 1 -#include <stdio.h> -#include <stdlib.h> -#include <stdarg.h> -#include <string.h> -#include <assert.h> -#include <dlfcn.h> - -#include "va_egl_private.h" -#include "va_egl_impl.h" - -static int -check_extension(const char *name, const char *exts) -{ - const char *end; - int name_len, n; - - if (!name || !exts) - return 0; - - end = exts + strlen(exts); - name_len = strlen(name); - - while (exts < end) { - n = strcspn(exts, " "); - - if (n == name_len && strncmp(name, exts, n) == 0) - return 1; - - exts += (n + 1); - } - - return 0; -} - -static int -check_pixmap_extensions(VADriverContextP ctx, EGLDisplay egl_display) -{ - const char *exts; - - exts = (const char *)eglQueryString(egl_display, EGL_EXTENSIONS); - - if (!check_extension("EGL_KHR_image_pixmap", exts)) - return 0; - - return 1; -} - -/* ========================================================================= */ -/* === VA/EGL implementation from the driver (fordward calls) === */ -/* ========================================================================= */ -#ifdef INVOKE -#undef INVOKE -#endif - -#define INVOKE(ctx, func, args) do { \ - VADriverVTableEGLP vtable = (ctx)->vtable_egl; \ - if (!vtable->va##func##EGL) \ - return VA_STATUS_ERROR_UNIMPLEMENTED; \ - \ - VAStatus status = vtable->va##func##EGL args; \ - if (status != VA_STATUS_SUCCESS) \ - return status; \ - } while (0) - - -static VAStatus -vaQuerySurfaceTargetsEGL_impl_driver(VADisplay dpy, - EGLenum *target_list, - int *num_targets) -{ - VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext; - - INVOKE(ctx, QuerySurfaceTargets, (ctx, target_list, num_targets)); - - return VA_STATUS_SUCCESS; -} - -static VAStatus -vaCreateSurfaceEGL_impl_driver(VADisplay dpy, - EGLenum target, - unsigned int width, - unsigned int height, - VASurfaceEGL *gl_surface) -{ - VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext; - - INVOKE(ctx, CreateSurface, (ctx, target, width, height, gl_surface)); - - return VA_STATUS_SUCCESS; -} - -static VAStatus -vaDestroySurfaceEGL_impl_driver(VADisplay dpy, VASurfaceEGL egl_surface) -{ - VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext; - - INVOKE(ctx, DestroySurface, (ctx, egl_surface)); - - return VA_STATUS_SUCCESS; -} - -static VAStatus -vaAssociateSurfaceEGL_impl_driver(VADisplay dpy, - VASurfaceEGL egl_surface, - VASurfaceID surface, - unsigned int flags) -{ - VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext; - - INVOKE(ctx, AssociateSurface, (ctx, egl_surface, surface, flags)); - - return VA_STATUS_SUCCESS; -} - -static VAStatus -vaSyncSurfaceEGL_impl_driver(VADisplay dpy, - VASurfaceEGL egl_surface) -{ - VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext; - - INVOKE(ctx, SyncSurface, (ctx, egl_surface)); - - return VA_STATUS_SUCCESS; -} - -static VAStatus -vaGetSurfaceInfoEGL_impl_driver(VADisplay dpy, - VASurfaceEGL egl_surface, - EGLenum *target, - EGLClientBuffer *buffer, - EGLint *attrib_list, - int *num_attribs) -{ - VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext; - - INVOKE(ctx, GetSurfaceInfo, (ctx, egl_surface, target, buffer, attrib_list, num_attribs)); - - return VA_STATUS_SUCCESS; -} - -static VAStatus -vaDeassociateSurfaceEGL_impl_driver(VADisplay dpy, - VASurfaceEGL egl_surface) -{ - VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext; - - INVOKE(ctx, DeassociateSurface, (ctx, egl_surface)); - - return VA_STATUS_SUCCESS; -} - -#undef INVOKE - -/* ========================================================================= */ -/* === VA/EGL helpers === */ -/* ========================================================================= */ -/** Unique VASurfaceImplEGL identifier */ -#define VA_SURFACE_IMPL_EGL_MAGIC VA_FOURCC('V','E','G','L') - -struct VASurfaceImplEGL { - uint32_t magic; ///< Magic number identifying a VASurfaceImplEGL - VASurfaceID surface; ///< Associated VA surface - EGLenum target; ///< EGL target - EGLClientBuffer buffer; - unsigned int width; - unsigned int height; - unsigned int flags; -}; - -static void * -create_native_pixmap(VADisplay dpy, unsigned int width, unsigned int height) -{ - VADisplayContextP pDisplayContext = (VADisplayContextP)dpy; - VAStatus status; - void *native_pixmap = NULL; - - status = pDisplayContext->vaCreateNativePixmap(pDisplayContext, width, height, &native_pixmap); - - if (status != VA_STATUS_SUCCESS) - native_pixmap = NULL; - - return native_pixmap; -} - -static void -destroy_native_pixmap(VADisplay dpy, void *native_pixmap) -{ - VADisplayContextP pDisplayContext = (VADisplayContextP)dpy; - - pDisplayContext->vaFreeNativePixmap(pDisplayContext, native_pixmap); -} - -// Check VASurfaceImplEGL is valid -static inline int check_surface(VASurfaceImplEGLP pSurfaceImplEGL) -{ - return pSurfaceImplEGL && pSurfaceImplEGL->magic == VA_SURFACE_IMPL_EGL_MAGIC; -} - -static inline VAStatus -deassociate_surface(VADriverContextP ctx, VASurfaceImplEGLP pSurfaceImplEGL) -{ - pSurfaceImplEGL->surface = VA_INVALID_SURFACE; - - return VA_STATUS_SUCCESS; -} - -static VAStatus -associate_surface(VADriverContextP ctx, - VASurfaceImplEGLP pSurfaceImplEGL, - VASurfaceID surface, - unsigned int flags) -{ - VAStatus status; - status = deassociate_surface(ctx, pSurfaceImplEGL); - - if (status != VA_STATUS_SUCCESS) - return status; - - pSurfaceImplEGL->surface = surface; - pSurfaceImplEGL->flags = flags; - - return VA_STATUS_SUCCESS; -} - -static inline VAStatus -sync_surface(VADriverContextP ctx, VASurfaceImplEGLP pSurfaceImplEGL) -{ - if (pSurfaceImplEGL->surface == VA_INVALID_SURFACE) - return VA_STATUS_ERROR_INVALID_SURFACE; - - return ctx->vtable->vaSyncSurface(ctx, pSurfaceImplEGL->surface); -} - -static VAStatus -sync_associated_surface(VADriverContextP ctx, VASurfaceImplEGLP pSurfaceImplEGL) -{ - VAStatus status; - - status = sync_surface(ctx, pSurfaceImplEGL); - - if (status != VA_STATUS_SUCCESS) - return status; - - if (pSurfaceImplEGL->target != EGL_NATIVE_PIXMAP_KHR) - return VA_STATUS_ERROR_UNIMPLEMENTED; - - status = ctx->vtable->vaPutSurface( - ctx, - pSurfaceImplEGL->surface, - (void *)pSurfaceImplEGL->buffer, - 0, 0, pSurfaceImplEGL->width, pSurfaceImplEGL->height, - 0, 0, pSurfaceImplEGL->width, pSurfaceImplEGL->height, - NULL, 0, - pSurfaceImplEGL->flags - ); - - if (status == VA_STATUS_SUCCESS) { - eglWaitNative(EGL_CORE_NATIVE_ENGINE); - } - - return status; -} - -/* ========================================================================= */ -/* === VA/EGL implementation from libVA (generic and suboptimal path) === */ -/* ========================================================================= */ -#ifdef INIT_SURFACE -#undef INIT_SURFACE -#endif - -#define INIT_SURFACE(surface, egl_surface) do { \ - surface = (VASurfaceImplEGLP)(egl_surface); \ - if (!check_surface(surface)) \ - return VA_STATUS_ERROR_INVALID_SURFACE; \ - } while (0) - -static VAStatus -vaQuerySurfaceTargetsEGL_impl_libva(VADisplay dpy, - EGLenum *target_list, - int *num_targets) -{ - int i = 0; - - /* FIXME: support other targets ??? */ - target_list[i++] = EGL_NATIVE_PIXMAP_KHR; - *num_targets = i; - assert(i <= IMPL_MAX_EGL_SURFACE_TARGETS); - - return VA_STATUS_SUCCESS; -} - -static VAStatus -vaCreateSurfaceEGL_impl_libva(VADisplay dpy, - EGLenum target, - unsigned int width, - unsigned int height, - VASurfaceEGL *egl_surface) -{ - VASurfaceImplEGLP pSurfaceImplEGL = NULL; - - /* So far only support for EGL_NATIVE_PIXMAP_KHR */ - if (target != 0 && target != EGL_NATIVE_PIXMAP_KHR) - return VA_STATUS_ERROR_INVALID_PARAMETER; - - pSurfaceImplEGL = calloc(1, sizeof(*pSurfaceImplEGL)); - - if (!pSurfaceImplEGL) { - *egl_surface = 0; - return VA_STATUS_ERROR_ALLOCATION_FAILED; - } - - pSurfaceImplEGL->magic = VA_SURFACE_IMPL_EGL_MAGIC; - pSurfaceImplEGL->surface = VA_INVALID_SURFACE; - pSurfaceImplEGL->target = target == 0 ? EGL_NATIVE_PIXMAP_KHR : target; - pSurfaceImplEGL->buffer = 0; - pSurfaceImplEGL->width = width; - pSurfaceImplEGL->height = height; - *egl_surface = (VASurfaceEGL)pSurfaceImplEGL; - - return VA_STATUS_SUCCESS; -} - -static VAStatus -vaDestroySurfaceEGL_impl_libva(VADisplay dpy, VASurfaceEGL egl_surface) -{ - VASurfaceImplEGLP pSurfaceImplEGL; - - INIT_SURFACE(pSurfaceImplEGL, egl_surface); - - if (pSurfaceImplEGL->target == EGL_NATIVE_PIXMAP_KHR) { - if (pSurfaceImplEGL->buffer) { - destroy_native_pixmap(dpy, pSurfaceImplEGL->buffer); - pSurfaceImplEGL->buffer = 0; - } - } - - free(pSurfaceImplEGL); - - return VA_STATUS_SUCCESS; -} - -static VAStatus -vaAssociateSurfaceEGL_impl_libva( - VADisplay dpy, - VASurfaceEGL egl_surface, - VASurfaceID surface, - unsigned int flags - ) -{ - VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext; - VASurfaceImplEGLP pSurfaceImplEGL; - VAStatus status; - - INIT_SURFACE(pSurfaceImplEGL, egl_surface); - - if (surface == VA_INVALID_SURFACE) - return VA_STATUS_ERROR_INVALID_SURFACE; - - if (pSurfaceImplEGL->target == EGL_NATIVE_PIXMAP_KHR) { - if (pSurfaceImplEGL->buffer) - destroy_native_pixmap(dpy, pSurfaceImplEGL->buffer); - - pSurfaceImplEGL->buffer = create_native_pixmap(dpy, pSurfaceImplEGL->width, pSurfaceImplEGL->height); - } - - pSurfaceImplEGL->surface = surface; - pSurfaceImplEGL->flags = flags; - - if (pSurfaceImplEGL->buffer) - return VA_STATUS_SUCCESS; - - return VA_STATUS_ERROR_UNKNOWN; -} - -static VAStatus -vaSyncSurfaceEGL_impl_libva(VADisplay dpy, - VASurfaceEGL egl_surface) -{ - VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext; - VASurfaceImplEGLP pSurfaceImplEGL; - VAStatus status; - - INIT_SURFACE(pSurfaceImplEGL, egl_surface); - - status = sync_associated_surface(ctx, pSurfaceImplEGL); - - return status; -} - -static VAStatus -vaGetSurfaceInfoEGL_impl_libva(VADisplay dpy, - VASurfaceEGL egl_surface, - EGLenum *target, - EGLClientBuffer *buffer, - EGLint *attrib_list, - int *num_attribs) -{ - VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext; - VASurfaceImplEGLP pSurfaceImplEGL; - VAStatus status; - int i = 0; - - INIT_SURFACE(pSurfaceImplEGL, egl_surface); - - if (pSurfaceImplEGL->surface == VA_INVALID_SURFACE) - return VA_STATUS_ERROR_INVALID_SURFACE; - - if (*num_attribs < IMPL_MAX_EGL_SURFACE_ATTRIBUTES) - return VA_STATUS_ERROR_INVALID_PARAMETER; - - *target = pSurfaceImplEGL->target; - *buffer = pSurfaceImplEGL->buffer; - - if (pSurfaceImplEGL->target == EGL_NATIVE_PIXMAP_KHR) { - attrib_list[i++] = EGL_IMAGE_PRESERVED_KHR; - attrib_list[i + 1] = EGL_TRUE; - attrib_list[i++] = EGL_NONE; - } else { - /* FIXME later */ - attrib_list[i++] = EGL_NONE; - } - - *num_attribs = i; - - return VA_STATUS_SUCCESS; -} - -static VAStatus -vaDeassociateSurfaceEGL_impl_libva( - VADisplay dpy, - VASurfaceEGL egl_surface - ) -{ - VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext; - VASurfaceImplEGLP pSurfaceImplEGL; - VAStatus status; - - INIT_SURFACE(pSurfaceImplEGL, egl_surface); - - if (pSurfaceImplEGL->target == EGL_NATIVE_PIXMAP_KHR) { - if (pSurfaceImplEGL->buffer) - destroy_native_pixmap(dpy, pSurfaceImplEGL->buffer); - - pSurfaceImplEGL->buffer = 0; - } - - pSurfaceImplEGL->surface = VA_INVALID_SURFACE; - - return VA_STATUS_SUCCESS; -} - -#undef INIT_SURFACE - -/* ========================================================================= */ -/* === Private VA/EGL vtable initialization === */ -/* ========================================================================= */ - -// Initialize EGL driver context -VAStatus va_egl_init_context(VADisplay dpy) -{ - VADisplayContextP pDisplayContext = (VADisplayContextP)dpy; - VADriverContextP ctx = pDisplayContext->pDriverContext; - VADriverContextEGLP egl_ctx = VA_DRIVER_CONTEXT_EGL(ctx); - VADriverVTablePrivEGLP vtable = &egl_ctx->vtable; - - if (egl_ctx->is_initialized) - return VA_STATUS_SUCCESS; - - if (ctx->vtable_egl && ctx->vtable_egl->vaCreateSurfaceEGL) { - vtable->vaQuerySurfaceTargetsEGL = vaQuerySurfaceTargetsEGL_impl_driver; - vtable->vaCreateSurfaceEGL = vaCreateSurfaceEGL_impl_driver; - vtable->vaDestroySurfaceEGL = vaDestroySurfaceEGL_impl_driver; - vtable->vaAssociateSurfaceEGL = vaAssociateSurfaceEGL_impl_driver; - vtable->vaSyncSurfaceEGL = vaSyncSurfaceEGL_impl_driver; - vtable->vaGetSurfaceInfoEGL = vaGetSurfaceInfoEGL_impl_driver; - vtable->vaDeassociateSurfaceEGL = vaDeassociateSurfaceEGL_impl_driver; - } - else { - if (pDisplayContext->vaCreateNativePixmap == NULL || - pDisplayContext->vaFreeNativePixmap == NULL) - return VA_STATUS_ERROR_UNIMPLEMENTED; - - if (!check_pixmap_extensions(ctx, egl_ctx->egl_display)) - return VA_STATUS_ERROR_UNIMPLEMENTED; - - vtable->vaQuerySurfaceTargetsEGL = vaQuerySurfaceTargetsEGL_impl_libva; - vtable->vaCreateSurfaceEGL = vaCreateSurfaceEGL_impl_libva; - vtable->vaDestroySurfaceEGL = vaDestroySurfaceEGL_impl_libva; - vtable->vaAssociateSurfaceEGL = vaAssociateSurfaceEGL_impl_libva; - vtable->vaSyncSurfaceEGL = vaSyncSurfaceEGL_impl_libva; - vtable->vaGetSurfaceInfoEGL = vaGetSurfaceInfoEGL_impl_libva; - vtable->vaDeassociateSurfaceEGL = vaDeassociateSurfaceEGL_impl_libva; - } - - egl_ctx->is_initialized = 1; - - return VA_STATUS_SUCCESS; -} diff --git a/va/egl/va_egl_impl.h b/va/egl/va_egl_impl.h deleted file mode 100644 index 8b6fb91..0000000 --- a/va/egl/va_egl_impl.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2012 Intel Corporation. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -#ifndef _VA_EGL_IMPL_H_ -#define _VA_EGL_IMPL_H_ - -#define IMPL_MAX_EGL_SURFACE_TARGETS 4 -#define IMPL_MAX_EGL_SURFACE_ATTRIBUTES 8 - - -/** - * Initialize EGL driver context - * - * @param[in] dpy the VA Display - * @return VA_STATUS_SUCCESS if successful - */ -VAStatus va_egl_init_context(VADisplay dpy); - -#endif /* _VA_GLX_IMPL_H_ */ diff --git a/va/egl/va_egl_private.h b/va/egl/va_egl_private.h deleted file mode 100644 index 7c2ba65..0000000 --- a/va/egl/va_egl_private.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2012 Intel Corporation. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -#ifndef _VA_EGL_PRIVATE_H_ -#define _VA_EGL_PRIVATE_H_ - -#include "va.h" -#include "va_backend.h" -#include "va_egl.h" -#include "va_backend_egl.h" - -typedef struct VADisplayContextEGL *VADisplayContextEGLP; -typedef struct VADriverContextEGL *VADriverContextEGLP; -typedef struct VASurfaceImplEGL *VASurfaceImplEGLP; -typedef struct VADriverVTableEGL *VADriverVTableEGLP; -typedef struct VADriverVTablePrivEGL *VADriverVTablePrivEGLP; -typedef void (*vaDestroyFunc)(VADisplayContextP); - -struct VADisplayContextEGL { - vaDestroyFunc vaDestroy; -}; - -#define VA_DRIVER_CONTEXT_EGL(ctx) ((VADriverContextEGLP)((ctx)->egl)) - -struct VADriverVTablePrivEGL { - VAStatus (*vaQuerySurfaceTargetsEGL)( - VADisplay dpy, - EGLenum *target_list, /* out */ - int *num_targets /* out */ - ); - - VAStatus (*vaCreateSurfaceEGL)( - VADisplay dpy, - EGLenum target, - unsigned int width, - unsigned int height, - VASurfaceEGL *gl_surface - ); - - VAStatus (*vaDestroySurfaceEGL)( - VADisplay dpy, - VASurfaceEGL egl_surface - ); - - VAStatus (*vaAssociateSurfaceEGL)( - VADisplay dpy, - VASurfaceEGL egl_surface, - VASurfaceID surface, - unsigned int flags - ); - - VAStatus (*vaSyncSurfaceEGL)( - VADisplay dpy, - VASurfaceEGL egl_surface - ); - - VAStatus (*vaGetSurfaceInfoEGL)( - VADisplay dpy, - VASurfaceEGL egl_surface, - EGLenum *target, - EGLClientBuffer *buffer, - EGLint *attrib_list, - int *num_attribs - ); - - VAStatus (*vaDeassociateSurfaceEGL)( - VADisplay dpy, - VASurfaceEGL egl_surface - ); -}; - -struct VADriverContextEGL { - struct VADriverVTablePrivEGL vtable; - unsigned int is_initialized : 1; - EGLDisplay egl_display; -}; - -#endif /* _VA_EGL_PRIVATE_H_ */ diff --git a/va/va_backend.h b/va/va_backend.h index 47ca719..9faa570 100644 --- a/va/va_backend.h +++ b/va/va_backend.h @@ -430,8 +430,8 @@ struct VADriverContext void *dri_state; void *glx; /* opaque for GLX code */ - void *egl; - unsigned long reserved[44]; /* reserve for future add-ins, decrease the subscript accordingly */ + + unsigned long reserved[45]; /* reserve for future add-ins, decrease the subscript accordingly */ }; #define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */ @@ -456,16 +456,6 @@ struct VADisplayContext ); void *opaque; /* opaque for display extensions (e.g. GLX) */ - - VAStatus (*vaCreateNativePixmap) ( - VADisplayContextP pDisplayContext, - unsigned int width, - unsigned int height, - void **native_pixmap); - - VAStatus (*vaFreeNativePixmap) ( - VADisplayContextP pDisplayContext, - void *native_pixmap); }; typedef VAStatus (*VADriverInit) ( diff --git a/va/va_egl.h b/va/va_egl.h deleted file mode 100644 index 06afe21..0000000 --- a/va/va_egl.h +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright (c) 2012 Intel Corporation. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -#ifndef _VA_EGL_H_ -#define _VA_EGL_H_ - -#include <va/va.h> -#include <EGL/egl.h> -#include <EGL/eglext.h> - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void *VASurfaceEGL; - -/*This function is used to get EGLClientBuffer - * (lower 16bits is buffer index, upper 16bits - * is BC device id.) from surface id. Application - * should maintain EGLClientBuffer itself.*/ - -VAStatus vaGetEGLClientBufferFromSurface ( - VADisplay dpy, - VASurfaceID surface, - EGLClientBuffer *buffer /* out*/ -); - -/** - * Return a suitable VADisplay for VA API - * - * @param[in] native_dpy the native display - * @param[in] egl_dpy the EGL display - * @return a VADisplay - */ -VADisplay vaGetDisplayEGL( - VANativeDisplay native_dpy, - EGLDisplay egl_dpy -); - -/** - * Return maximum number of EGL targets supported by the implementation - * - * @param[in] dpy the VADisplay - * @return the maximum number of EGL Target - */ -int vaMaxNumSurfaceTargetsEGL( - VADisplay dpy -); - -/** - * Return maximum number of EGL surface attributes supported by the implementation - * - * @param[in] dpy the VADisplay - * @return the maximum number of EGL surface attributes - */ -int vaMaxNumSurfaceAttributesEGL( - VADisplay dpy -); - -/** - * Query supported EGL targets for eglCreateImageKHR(). - * - * The caller must provide a "target_list" array that can hold at - * least vaMaxNumSurfaceTargetsEGL() entries. The actual number of - * targets returned in "target_list" is returned in "num_targets". - * - * @param[in]] dpy the VADisplay - * @param[out] target_list the array to hold target entries - * @param[out] num_targets the actual number of targets - * @return VA_STATUS_SUCCESS if successful - */ -VAStatus vaQuerySurfaceTargetsEGL( - VADisplay dpy, - EGLenum *target_list, /* out */ - int *num_targets /* out */ -); - -/** - * Creates a VA/EGL surface with the specified target - * - * If target is 0, this means the best efficient target by default. - * - * @param[in] dpy the VADisplay - * @param[in] target the specified EGL target - * @param[in] width the surface width - * @param[in] height the surface height - * @param[out] gl_surface the VA/EGL surface - * @return VA_STATUS_SUCCESS if successful - */ -VAStatus vaCreateSurfaceEGL( - VADisplay dpy, - EGLenum target, - unsigned int width, - unsigned int height, - VASurfaceEGL *gl_surface -); - -/** - * Destroy a VA/EGL surface - * - * The application shall maintain the live EGL context itself. - * - * @param[in] dpy the VA display - * @param[in] gl_surface the VA surface - * @return VA_STATUS_SUCCESS if successful - */ -VAStatus vaDestroySurfaceEGL( - VADisplay dpy, - VASurfaceEGL gl_surface -); - -/** - * Associate a EGL surface with a VA surface - * - * @param[in] dpy the VA display - * @param[in] egl_surface the VA/EGL destination surface - * @param[in] surface the VA surface - * @param[in] flags the flags to PutSurface - * @return VA_STATUS_SUCCESS if successful - */ -VAStatus vaAssociateSurfaceEGL( - VADisplay dpy, - VASurfaceEGL egl_surface, - VASurfaceID surface, - unsigned int flags -); - -/** - * Update the content of a VA/EGL surface - * - * Changes to VA surface are committed to VA/EGL surface at this point. - * - * @param[in] dpy the VA display - * @param[in] egl_surface the VA/EGL surface that has been associated with a VA surface - * @return VA_STATUS_SUCCESS if successful - */ -VAStatus vaSyncSurfaceEGL( - VADisplay dpy, - VASurfaceEGL egl_surface -); - -/** - * Get the necessary information for eglCreateImageKHR() - * - * The caller must provide a "attrib_list" array that can hold at - * least (2 * vaMaxNumSurfaceAttributesEGL()) entries. The last attribute - * specified in attrib_list must be EGL_NONE - * - * @param[in] dpy the VA display - * @param[in] egl_surface the VA/EGL surface that has been associated with a VA surface - * @param[out] target the type of <buffer> for eglCreateImageKHR() - * @param[out] buffer the EGLClientBuffer for eglCreateImageKHR() - * @param[out] attrib_list the list of attribute-value pairs for eglCreateImageKHR() - * @param[in/out] num_attribs input: the number of allocated attribute-value pairs in attrib_list; output: the actual number of attribute-value pairs - * @return VA_STATUS_SUCCESS if successful - */ -VAStatus vaGetSurfaceInfoEGL( - VADisplay dpy, - VASurfaceEGL egl_surface, - EGLenum *target, /* out, the type of <buffer> */ - EGLClientBuffer *buffer, /* out */ - EGLint *attrib_list, /* out, the last attribute must be EGL_NONE */ - int *num_attribs /* in/out, the number of attribute-value pairs */ -); - -/** - * Deassociate a EGL surface - * - * @param[in] dpy the VA display - * @param[in] egl_surface the VA/EGL destination surface - * @return VA_STATUS_SUCCESS if successful - */ -VAStatus vaDeassociateSurfaceEGL( - VADisplay dpy, - VASurfaceEGL egl_surface -); - -#ifdef __cplusplus -} -#endif - -#endif /* _VA_EGL_H_ */ diff --git a/va/x11/va_x11.c b/va/x11/va_x11.c index a593712..4f65fd0 100644 --- a/va/x11/va_x11.c +++ b/va/x11/va_x11.c @@ -145,47 +145,6 @@ static VAStatus va_DisplayContextGetDriverName ( return vaStatus; } -static VAStatus va_CreateNativePixmap( - VADisplayContextP pDisplayContext, - unsigned int width, - unsigned int height, - void **native_pixmap) -{ - VADriverContextP ctx = pDisplayContext->pDriverContext; - Window root_window; - XWindowAttributes wattr; - Pixmap pixmap = None; - - root_window = RootWindow(ctx->native_dpy, ctx->x11_screen); - XGetWindowAttributes(ctx->native_dpy, root_window, &wattr); - - if (wattr.depth != 24 && wattr.depth != 32) - return VA_STATUS_ERROR_INVALID_DISPLAY; - - pixmap = XCreatePixmap( - ctx->native_dpy, - root_window, - width, - height, - wattr.depth - ); - - *native_pixmap = (void *)pixmap; - - return !pixmap ? VA_STATUS_ERROR_UNKNOWN : VA_STATUS_SUCCESS; -} - -static VAStatus va_FreeNativePixmap( - VADisplayContextP pDisplayContext, - void *native_pixmap) -{ - VADriverContextP ctx = pDisplayContext->pDriverContext; - Pixmap pixmap = (Pixmap)native_pixmap; - - XFreePixmap(ctx->native_dpy, pixmap); - - return VA_STATUS_SUCCESS; -} VADisplay vaGetDisplay ( Display *native_dpy /* implementation specific */ @@ -215,8 +174,6 @@ VADisplay vaGetDisplay ( pDisplayContext->vaDestroy = va_DisplayContextDestroy; pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName; pDisplayContext->opaque = NULL; - pDisplayContext->vaCreateNativePixmap = va_CreateNativePixmap; - pDisplayContext->vaFreeNativePixmap = va_FreeNativePixmap; pDriverContext->dri_state = dri_state; dpy = (VADisplay)pDisplayContext; } |