summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAustin Yuan <shengquan.yuan@gmail.com>2010-06-04 16:56:01 +0800
committerAustin Yuan <shengquan.yuan@gmail.com>2010-06-04 16:56:01 +0800
commitc6e1d7a30d5960bd26f45a44f9f77d5c172efec1 (patch)
treee9c2420d8631218e814da3ef5d0c5a368f488bed
parent18570d34f337748afb34cd8cd49fbe69970e9796 (diff)
parent943686a94957337b6a6fadcc316d6dee0e0f56d4 (diff)
downloadlibva-c6e1d7a30d5960bd26f45a44f9f77d5c172efec1.tar.gz
Merge branch 'fdva-master'
-rw-r--r--test/Makefile.am5
-rw-r--r--va/android/va_android.cpp198
-rw-r--r--va/va.c50
-rw-r--r--va/va.h2
-rw-r--r--va/va_backend.h2
-rw-r--r--va/x11/va_x11.c9
6 files changed, 126 insertions, 140 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index 321c822..7153b10 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -25,9 +25,8 @@ bin_PROGRAMS = vainfo
AM_CFLAGS = -I$(top_srcdir)/va -I$(top_srcdir)/test/basic -I$(top_srcdir)/src/x11
-
-vainfo_LDADD = $(top_builddir)/va/libva.la $(top_srcdir)/va/$(libvabackendlib)
-vainfo_DEPENDENCIES = $(top_builddir)/va/libva.la $(top_srcdir)/va/$(libvabackendlib)
+vainfo_LDADD = $(top_builddir)/va/$(libvacorelib) $(top_builddir)/va/$(libvabackendlib)
+vainfo_DEPENDENCIES = $(top_builddir)/va/$(libvacorelib) $(top_builddir)/va/$(libvabackendlib)
vainfo_SOURCES = vainfo.c
SUBDIRS = basic decode encode putsurface
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/va.c b/va/va.c
index 2d277e7..00a96cf 100644
--- a/va/va.c
+++ b/va/va.c
@@ -331,30 +331,42 @@ VAStatus vaInitialize (
int *minor_version /* out */
)
{
- char *driver_name = NULL;
- VAStatus vaStatus;
-
- CHECK_DISPLAY(dpy);
+ const char *driver_name_env = NULL;
+ char *driver_name = NULL;
+ VAStatus vaStatus;
- va_TraceInit();
+ CHECK_DISPLAY(dpy);
- va_infoMessage("libva version %s\n", VA_VERSION_S);
+ va_TraceInit();
- vaStatus = va_getDriverName(dpy, &driver_name);
- va_infoMessage("va_getDriverName() returns %d\n", vaStatus);
-
- if (VA_STATUS_SUCCESS == vaStatus)
- {
- vaStatus = va_openDriver(dpy, driver_name);
- va_infoMessage("va_openDriver() returns %d\n", vaStatus);
+ va_infoMessage("libva version %s\n", VA_VERSION_S);
- *major_version = VA_MAJOR_VERSION;
- *minor_version = VA_MINOR_VERSION;
- }
+ driver_name_env = getenv("LIBVA_DRIVER_NAME");
+ if (driver_name_env && geteuid() == getuid())
+ {
+ /* Don't allow setuid apps to use LIBVA_DRIVER_NAME */
+ driver_name = strdup(driver_name_env);
+ vaStatus = VA_STATUS_SUCCESS;
+ va_infoMessage("User requested driver '%s'\n", driver_name);
+ }
+ else
+ {
+ vaStatus = va_getDriverName(dpy, &driver_name);
+ va_infoMessage("va_getDriverName() returns %d\n", vaStatus);
+ }
- if (driver_name)
- free(driver_name);
- return vaStatus;
+ if (VA_STATUS_SUCCESS == vaStatus)
+ {
+ vaStatus = va_openDriver(dpy, driver_name);
+ va_infoMessage("va_openDriver() returns %d\n", vaStatus);
+
+ *major_version = VA_MAJOR_VERSION;
+ *minor_version = VA_MINOR_VERSION;
+ }
+
+ if (driver_name)
+ free(driver_name);
+ return vaStatus;
}
diff --git a/va/va.h b/va/va.h
index 0142cc2..a4a9cf6 100644
--- a/va/va.h
+++ b/va/va.h
@@ -159,6 +159,8 @@ const char *vaErrorStr(VAStatus error_status);
*/
typedef void* NativeDisplay; /* window system dependent */
+int vaDisplayIsValid(VADisplay dpy);
+
/*
* Initialize the library
*/
diff --git a/va/va_backend.h b/va/va_backend.h
index 9029fa6..62ac970 100644
--- a/va/va_backend.h
+++ b/va/va_backend.h
@@ -397,7 +397,7 @@ struct VADriverContext
void *handle; /* dlopen handle */
void *dri_state;
- void *glx; /* opaque for GLX code */
+ void *glx; /* opaque for GLX code */
};
#define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */
diff --git a/va/x11/va_x11.c b/va/x11/va_x11.c
index 9f233da..7f8fbd6 100644
--- a/va/x11/va_x11.c
+++ b/va/x11/va_x11.c
@@ -136,19 +136,10 @@ static VAStatus va_DisplayContextGetDriverName (
)
{
VAStatus vaStatus;
- char *driver_name_env;
if (driver_name)
*driver_name = NULL;
- 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;
- }
-
vaStatus = va_DRI2GetDriverName(pDisplayContext, driver_name);
if (vaStatus != VA_STATUS_SUCCESS)
vaStatus = va_DRIGetDriverName(pDisplayContext, driver_name);