diff options
Diffstat (limited to 'va')
-rw-r--r-- | va/Makefile.am | 1 | ||||
-rw-r--r-- | va/android/va_android.cpp | 14 | ||||
-rw-r--r-- | va/va_drmcommon.h | 71 | ||||
-rw-r--r-- | va/x11/dri2_util.c | 24 | ||||
-rw-r--r-- | va/x11/va_dricommon.h | 16 |
5 files changed, 99 insertions, 27 deletions
diff --git a/va/Makefile.am b/va/Makefile.am index 44daac9..3fcf697 100644 --- a/va/Makefile.am +++ b/va/Makefile.am @@ -42,6 +42,7 @@ libva_source_h = \ va_backend.h \ va_backend_tpi.h \ va_dec_jpeg.h \ + va_drmcommon.h \ va_dummy.h \ va_tpi.h \ va_version.h \ diff --git a/va/android/va_android.cpp b/va/android/va_android.cpp index 4d4885a..7d7998e 100644 --- a/va/android/va_android.cpp +++ b/va/android/va_android.cpp @@ -96,7 +96,7 @@ static void va_DisplayContextDestroy ( /* close the open-ed DRM fd */ dri_state = (struct dri_state *)pDisplayContext->pDriverContext->dri_state; - close(dri_state->fd); + close(dri_state->base.fd); free(pDisplayContext->pDriverContext->dri_state); free(pDisplayContext->pDriverContext); @@ -125,9 +125,9 @@ static VAStatus va_DisplayContextGetDriverName ( }; memset(dri_state, 0, sizeof(*dri_state)); - dri_state->fd = open_device((char *)DEVICE_NAME); + dri_state->base.fd = open_device((char *)DEVICE_NAME); - if (dri_state->fd < 0) { + if (dri_state->base.fd < 0) { fprintf(stderr,"can't open DRM devices\n"); return VA_STATUS_ERROR_UNKNOWN; } @@ -137,7 +137,7 @@ static VAStatus va_DisplayContextGetDriverName ( device_id = devices[0].device_id; *driver_name = strdup(devices[0].driver_name); - dri_state->driConnectedFlag = VA_DUMMY; + dri_state->base.auth_type = VA_DUMMY; return VA_STATUS_SUCCESS; } @@ -164,9 +164,9 @@ static VAStatus va_DisplayContextGetDriverName ( }; memset(dri_state, 0, sizeof(*dri_state)); - dri_state->fd = drm_open_any(&vendor_id, &device_id); + dri_state->base.fd = drm_open_any(&vendor_id, &device_id); - if (dri_state->fd < 0) { + if (dri_state->base.fd < 0) { fprintf(stderr,"can't open DRM devices\n"); return VA_STATUS_ERROR_UNKNOWN; } @@ -192,7 +192,7 @@ static VAStatus va_DisplayContextGetDriverName ( printf("DRM device is opened, loading driver %s for device 0x%04x:0x%04x\n", driver_name, vendor_id, device_id); - dri_state->driConnectedFlag = VA_DUMMY; + dri_state->base.auth_type = VA_DUMMY; return VA_STATUS_SUCCESS; } diff --git a/va/va_drmcommon.h b/va/va_drmcommon.h new file mode 100644 index 0000000..bb00fd4 --- /dev/null +++ b/va/va_drmcommon.h @@ -0,0 +1,71 @@ +/* + * va_drmcommon.h - Common utilities for DRM-based drivers + * + * 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 INTEL 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_DRM_COMMON_H +#define VA_DRM_COMMON_H + +/** \brief DRM authentication type. */ +enum { + /** \brief Disconnected. */ + VA_DRM_AUTH_NONE = 0, + /** + * \brief Connected. Authenticated with DRI1 protocol. + * + * @deprecated + * This is a deprecated authentication type. All DRI-based drivers have + * been migrated to use the DRI2 protocol. Newly written drivers shall + * use DRI2 protocol only, or a custom authentication means. e.g. opt + * for authenticating on the VA driver side, instead of libva side. + */ + VA_DRM_AUTH_DRI1 = 1, + /** + * \brief Connected. Authenticated with DRI2 protocol. + * + * This is only useful to VA/X11 drivers. The libva-x11 library provides + * a helper function VA_DRI2Authenticate() for authenticating the + * connection. However, DRI2 conformant drivers don't need to call that + * function since authentication happens on the libva side, implicitly. + */ + VA_DRM_AUTH_DRI2 = 2, + /** + * \brief Connected. Authenticated with some alternate raw protocol. + * + * This authentication mode is mainly used in non-VA/X11 drivers. + * Authentication happens through some alternative method, at the + * discretion of the VA driver implementation. + */ + VA_DRM_AUTH_CUSTOM = 3 +}; + +/** \brief Base DRM state. */ +struct drm_state { + /** \brief DRM connection descriptor. */ + int fd; + /** \brief DRM authentication type. */ + int auth_type; +}; + +#endif /* VA_DRM_COMMON_H */ diff --git a/va/x11/dri2_util.c b/va/x11/dri2_util.c index ab3f58a..47f663a 100644 --- a/va/x11/dri2_util.c +++ b/va/x11/dri2_util.c @@ -168,8 +168,8 @@ dri2Close(VADriverContextP ctx) free_drawable_hashtable(ctx); - if (dri_state->fd >= 0); - close(dri_state->fd); + if (dri_state->base.fd >= 0); + close(dri_state->base.fd); } Bool @@ -182,8 +182,8 @@ isDRI2Connected(VADriverContextP ctx, char **driver_name) char *device_name = NULL; drm_magic_t magic; *driver_name = NULL; - dri_state->fd = -1; - dri_state->driConnectedFlag = VA_NONE; + dri_state->base.fd = -1; + dri_state->base.auth_type = VA_NONE; if (!VA_DRI2QueryExtension(ctx->native_dpy, &event_base, &error_base)) goto err_out; @@ -195,20 +195,20 @@ isDRI2Connected(VADriverContextP ctx, char **driver_name) driver_name, &device_name)) goto err_out; - dri_state->fd = open(device_name, O_RDWR); - assert(dri_state->fd >= 0); + dri_state->base.fd = open(device_name, O_RDWR); + assert(dri_state->base.fd >= 0); - if (dri_state->fd < 0) + if (dri_state->base.fd < 0) goto err_out; - if (drmGetMagic(dri_state->fd, &magic)) + if (drmGetMagic(dri_state->base.fd, &magic)) goto err_out; if (!VA_DRI2Authenticate(ctx->native_dpy, RootWindow(ctx->native_dpy, ctx->x11_screen), magic)) goto err_out; - dri_state->driConnectedFlag = VA_DRI2; + dri_state->base.auth_type = VA_DRI2; dri_state->createDrawable = dri2CreateDrawable; dri_state->destroyDrawable = dri2DestroyDrawable; dri_state->swapBuffer = dri2SwapBuffer; @@ -228,11 +228,11 @@ err_out: if (*driver_name) Xfree(*driver_name); - if (dri_state->fd >= 0) - close(dri_state->fd); + if (dri_state->base.fd >= 0) + close(dri_state->base.fd); *driver_name = NULL; - dri_state->fd = -1; + dri_state->base.fd = -1; return False; } diff --git a/va/x11/va_dricommon.h b/va/x11/va_dricommon.h index 4d6e3aa..eb6ddad 100644 --- a/va/x11/va_dricommon.h +++ b/va/x11/va_dricommon.h @@ -32,18 +32,19 @@ #endif #include <va/va_backend.h> +#include <va/va_drmcommon.h> #ifdef ANDROID #define XID unsigned int #define Bool int #endif -enum -{ - VA_NONE = 0, - VA_DRI1 = 1, - VA_DRI2 = 2, - VA_DUMMY = 3 +enum { + /* Compatibility. Do not use for newly-written code. */ + VA_NONE = VA_DRM_AUTH_NONE, + VA_DRI1 = VA_DRM_AUTH_DRI1, + VA_DRI2 = VA_DRM_AUTH_DRI2, + VA_DUMMY = VA_DRM_AUTH_CUSTOM }; union dri_buffer @@ -71,8 +72,7 @@ struct dri_drawable #define DRAWABLE_HASH_SZ 32 struct dri_state { - int fd; - int driConnectedFlag; /* 0: disconnected, 1: DRI, 2: DRI2 */ + struct drm_state base; #ifndef ANDROID struct dri_drawable *drawable_hash[DRAWABLE_HASH_SZ]; |