diff options
author | Austin Yuan <shengquan.yuan@gmail.com> | 2010-06-04 14:29:01 +0800 |
---|---|---|
committer | Austin Yuan <shengquan.yuan@gmail.com> | 2010-06-04 14:29:01 +0800 |
commit | 943686a94957337b6a6fadcc316d6dee0e0f56d4 (patch) | |
tree | e9c2420d8631218e814da3ef5d0c5a368f488bed /va | |
parent | cb2ba3ed68b44f883ef0e8c88fbd1991c8b89548 (diff) |
Follow up the change of "LIBVA_DRIVER_NAME", remove it from va_android.cpp
Signed-off-by: Austin Yuan <shengquan.yuan@gmail.com>
Diffstat (limited to 'va')
-rw-r--r-- | va/android/va_android.cpp | 198 | ||||
-rw-r--r-- | va/glx/va_glx.c | 2 | ||||
-rw-r--r-- | va/va.h | 2 |
3 files changed, 92 insertions, 110 deletions
diff --git a/va/android/va_android.cpp b/va/android/va_android.cpp index 2e389cc..4eb90a2 100644 --- a/va/android/va_android.cpp +++ b/va/android/va_android.cpp @@ -47,45 +47,39 @@ static VADisplayContextP pDisplayContexts = NULL; -static int vaDisplayIsValid (VADisplay dpy) -{ - VADisplayContextP pDisplayContext = (VADisplayContextP)dpy; - return pDisplayContext && (pDisplayContext->vadpy_magic == VA_DISPLAY_MAGIC) && pDisplayContext->vaIsValid(pDisplayContext); -} - static int open_device (char *dev_name) { - struct stat st; - int fd; + struct stat st; + int fd; - if (-1 == stat (dev_name, &st)) + if (-1 == stat (dev_name, &st)) { - printf ("Cannot identify '%s': %d, %s\n", - dev_name, errno, strerror (errno)); - return -1; + printf ("Cannot identify '%s': %d, %s\n", + dev_name, errno, strerror (errno)); + return -1; } - if (!S_ISCHR (st.st_mode)) + if (!S_ISCHR (st.st_mode)) { - printf ("%s is no device\n", dev_name); - return -1; + printf ("%s is no device\n", dev_name); + return -1; } - fd = open (dev_name, O_RDWR); + fd = open (dev_name, O_RDWR); - if (-1 == fd) + if (-1 == fd) { - fprintf (stderr, "Cannot open '%s': %d, %s\n", - dev_name, errno, strerror (errno)); - return -1; + fprintf (stderr, "Cannot open '%s': %d, %s\n", + dev_name, errno, strerror (errno)); + return -1; } - return fd; + return fd; } static int va_DisplayContextIsValid ( VADisplayContextP pDisplayContext -) + ) { VADisplayContextP ctx = pDisplayContexts; @@ -149,17 +143,11 @@ static VAStatus va_DisplayContextGetDriverName ( return VA_STATUS_ERROR_UNKNOWN; } - if ((driver_name_env = getenv("LIBVA_DRIVER_NAME")) != NULL - && geteuid() == getuid()) { - /* don't allow setuid apps to use LIBVA_DRIVER_NAME */ - *driver_name = strdup(driver_name_env); - return VA_STATUS_SUCCESS; - } else { /* TBD: other vendor driver names */ - vendor_id = devices[0].vendor_id; - device_id = devices[0].device_id; - *driver_name = strdup(devices[0].driver_name); - } - + /* TBD: other vendor driver names */ + vendor_id = devices[0].vendor_id; + device_id = devices[0].device_id; + *driver_name = strdup(devices[0].driver_name); + dri_state->driConnectedFlag = VA_DUMMY; return VA_STATUS_SUCCESS; @@ -174,6 +162,7 @@ static VAStatus va_DisplayContextGetDriverName ( struct dri_state *dri_state = (struct dri_state *)ctx->dri_state; char *driver_name_env; int vendor_id, device_id; + int i = 0; struct { int vendor_id; @@ -193,31 +182,24 @@ static VAStatus va_DisplayContextGetDriverName ( return VA_STATUS_ERROR_UNKNOWN; } - if ((driver_name_env = getenv("LIBVA_DRIVER_NAME")) != NULL - && geteuid() == getuid()) { - /* don't allow setuid apps to use LIBVA_DRIVER_NAME */ - *driver_name = strdup(driver_name_env); - return VA_STATUS_SUCCESS; - } else { /* TBD: other vendor driver names */ - int i = 0; - - while (devices[i].device_id != 0) { - if ((devices[i].vendor_id == vendor_id) && - (devices[i].device_id == device_id)) - break; - i++; - } + /* TBD: other vendor driver names */ - if (devices[i].device_id != 0) - *driver_name = strdup(devices[i].driver_name); - else { - fprintf(stderr,"device (0x%04x:0x%04x) is not supported\n", - vendor_id, device_id); - - return VA_STATUS_ERROR_UNKNOWN; - } + while (devices[i].device_id != 0) { + if ((devices[i].vendor_id == vendor_id) && + (devices[i].device_id == device_id)) + break; + i++; } + if (devices[i].device_id != 0) + *driver_name = strdup(devices[i].driver_name); + else { + fprintf(stderr,"device (0x%04x:0x%04x) is not supported\n", + vendor_id, device_id); + + return VA_STATUS_ERROR_UNKNOWN; + } + printf("DRM device is opened, loading driver %s for device 0x%04x:0x%04x\n", driver_name, vendor_id, device_id); @@ -231,58 +213,58 @@ VADisplay vaGetDisplay ( void *native_dpy /* implementation specific */ ) { - VADisplay dpy = NULL; - VADisplayContextP pDisplayContext = pDisplayContexts; - - if (!native_dpy) - return NULL; + VADisplay dpy = NULL; + VADisplayContextP pDisplayContext = pDisplayContexts; - while (pDisplayContext) - { - if (pDisplayContext->pDriverContext && - pDisplayContext->pDriverContext->native_dpy == (void *)native_dpy) - { - dpy = (VADisplay)pDisplayContext; - break; - } - pDisplayContext = pDisplayContext->pNext; - } + if (!native_dpy) + return NULL; + while (pDisplayContext) + { + if (pDisplayContext->pDriverContext && + pDisplayContext->pDriverContext->native_dpy == (void *)native_dpy) + { + dpy = (VADisplay)pDisplayContext; + break; + } + pDisplayContext = pDisplayContext->pNext; + } - if (!dpy) - { - /* create new entry */ - VADriverContextP pDriverContext; - struct dri_state *dri_state; - pDisplayContext = (VADisplayContextP)calloc(1, sizeof(*pDisplayContext)); - pDriverContext = (VADriverContextP)calloc(1, sizeof(*pDriverContext)); - dri_state = (struct dri_state*)calloc(1, sizeof(*dri_state)); - if (pDisplayContext && pDriverContext && dri_state) - { - pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC; - pDriverContext->native_dpy = (void *)native_dpy; - pDisplayContext->pNext = pDisplayContexts; - pDisplayContext->pDriverContext = pDriverContext; - pDisplayContext->vaIsValid = va_DisplayContextIsValid; - pDisplayContext->vaDestroy = va_DisplayContextDestroy; - pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName; - pDisplayContexts = pDisplayContext; - pDriverContext->dri_state = dri_state; - dpy = (VADisplay)pDisplayContext; - } - else - { - if (pDisplayContext) - free(pDisplayContext); - if (pDriverContext) - free(pDriverContext); - if (dri_state) - free(dri_state); - } - } + if (!dpy) + { + /* create new entry */ + VADriverContextP pDriverContext; + struct dri_state *dri_state; + pDisplayContext = (VADisplayContextP)calloc(1, sizeof(*pDisplayContext)); + pDriverContext = (VADriverContextP)calloc(1, sizeof(*pDriverContext)); + dri_state = (struct dri_state*)calloc(1, sizeof(*dri_state)); + if (pDisplayContext && pDriverContext && dri_state) + { + pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC; + + pDriverContext->native_dpy = (void *)native_dpy; + pDisplayContext->pNext = pDisplayContexts; + pDisplayContext->pDriverContext = pDriverContext; + pDisplayContext->vaIsValid = va_DisplayContextIsValid; + pDisplayContext->vaDestroy = va_DisplayContextDestroy; + pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName; + pDisplayContexts = pDisplayContext; + pDriverContext->dri_state = dri_state; + dpy = (VADisplay)pDisplayContext; + } + else + { + if (pDisplayContext) + free(pDisplayContext); + if (pDriverContext) + free(pDriverContext); + if (dri_state) + free(dri_state); + } + } - return dpy; + return dpy; } #define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext) @@ -307,12 +289,12 @@ VAStatus vaPutSurface ( unsigned int flags /* de-interlacing flags */ ) { - VADriverContextP ctx; + VADriverContextP ctx; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - return ctx->vtable.vaPutSurface( ctx, surface, static_cast<void*>(&draw), srcx, srcy, srcw, srch, - destx, desty, destw, desth, - cliprects, number_cliprects, flags ); + CHECK_DISPLAY(dpy); + ctx = CTX(dpy); + return ctx->vtable.vaPutSurface( ctx, surface, static_cast<void*>(&draw), srcx, srcy, srcw, srch, + destx, desty, destw, desth, + cliprects, number_cliprects, flags ); } #endif diff --git a/va/glx/va_glx.c b/va/glx/va_glx.c index cd1275f..1812ef5 100644 --- a/va/glx/va_glx.c +++ b/va/glx/va_glx.c @@ -47,8 +47,6 @@ status = vtable->va##func##GLX args; \ } while (0) -// Check VADisplay is valid (from libva.so.*) -int vaDisplayIsValid(VADisplay dpy); // Destroy VA/GLX display context static void va_DisplayContextDestroy(VADisplayContextP pDisplayContext) @@ -159,6 +159,8 @@ const char *vaErrorStr(VAStatus error_status); */ typedef void* NativeDisplay; /* window system dependent */ +int vaDisplayIsValid(VADisplay dpy); + /* * Initialize the library */ |