summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root@localhost.localdomain>2009-04-22 12:38:56 -0400
committerroot <root@localhost.localdomain>2009-04-22 12:38:56 -0400
commit997d59cf2092a29979c19a62fbe43d7f8d4dfa29 (patch)
tree609fbb0ac280c807146860e7228eb15bd6256d30
parent69c5eb68b15ced3e822bf68c451a272477ca96cc (diff)
parent9cab1a3faa2954d10715a0df4a9fc9405a4f152f (diff)
Merge branch 'DRI2' of ssh://git@moblin-mdi.jf.intel.com/umg-moorestown-libva into DRI2
-rw-r--r--src/X11/va_x11.c94
-rwxr-xr-xsrc/va_backend.h2
2 files changed, 83 insertions, 13 deletions
diff --git a/src/X11/va_x11.c b/src/X11/va_x11.c
index bc2429e..f050648 100644
--- a/src/X11/va_x11.c
+++ b/src/X11/va_x11.c
@@ -89,13 +89,51 @@ static void va_DisplayContextDestroy (
free(pDisplayContext);
}
-static VAStatus va_DisplayContextGetDriverName (
+
+static VAStatus va_DRI2GetDriverName (
+ VADisplayContextP pDisplayContext,
+ char **driver_name
+)
+{
+ VADriverContextP ctx = pDisplayContext->pDriverContext;
+ VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
+ char *driverName, *deviceName;
+ int driver_major;
+ int driver_minor;
+ int driver_patch;
+ Bool result = True;
+
+ if (!VA_DRI2QueryExtension(ctx->x11_dpy, &eventBase, &errorBase)) {
+ va_infoMessage("DRI2 extension isn't present\n");
+ return VA_STATUS_ERROR_UNKNOWN;
+ }
+
+ if (!VA_DRI2QueryVersion(ctx->x11_dpy, &driver_major, &driver_minor)) {
+ va_errorMessage("VA_DRI2QueryVersion failed\n");
+ return VA_STATUS_ERROR_UNKNOWN;
+ }
+
+ if (!VA_DRI2Connect(ctx->x11_dpy, RootWindow(ctx->x11_dpy, ctx->x11_screen),
+ &driver_name, &device_name)) {
+ va_infoMessage("DRI2 isn't enabled, fallback to DRI1\n");
+ return VA_STATUS_ERROR_UNKNOWN;
+ }
+
+ va_infoMessage("VA_DRI2Connect: %d.%d.%d %s (screen %d)\n",
+ driver_major, driver_minor, driver_patch, *driver_name, ctx->x11_screen);
+ ctx->dri2 = 1;
+
+ return VA_STATUS_SUCCESS;
+}
+
+static VAStatus va_DRIGetDriverName (
VADisplayContextP pDisplayContext,
char **driver_name
)
{
VADriverContextP ctx = pDisplayContext->pDriverContext;
VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
+ int eventBase, errorBase;
int direct_capable;
int driver_major;
int driver_minor;
@@ -103,18 +141,11 @@ static VAStatus va_DisplayContextGetDriverName (
Bool result = True;
char *x_driver_name = NULL;
- if (driver_name)
- *driver_name = NULL;
- if (geteuid() == getuid())
- {
- /* don't allow setuid apps to use LIBVA_DRIVER_NAME */
- if (getenv("LIBVA_DRIVER_NAME"))
- {
- /* For easier debugging */
- *driver_name = strdup(getenv("LIBVA_DRIVER_NAME"));
- return VA_STATUS_SUCCESS;
- }
+ if (!VA_DRIQueryExtension(ctx->x11_dpy, &eventBase, &errorBase)) {
+ va_errorMessage("VA_DRIQueryExtension failed\n");
+ return VA_STATUS_ERROR_UNKNOWN;
}
+
if (result)
{
result = VA_DRIQueryDirectRenderingCapable(ctx->x11_dpy, ctx->x11_screen, &direct_capable);
@@ -154,6 +185,45 @@ static VAStatus va_DisplayContextGetDriverName (
return vaStatus;
}
+static VAStatus va_DisplayContextGetDriverName (
+ VADisplayContextP pDisplayContext,
+ char **driver_name
+)
+{
+ VADriverContextP ctx = pDisplayContext->pDriverContext;
+ VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
+ int direct_capable;
+ int driver_major;
+ int driver_minor;
+ int driver_patch;
+ Bool result = True;
+ char *x_driver_name = NULL;
+
+ if (driver_name)
+ *driver_name = NULL;
+
+ vaStatus = va_DRI2GetDriverName(pDisplayContext, driver_name);
+ if (vaStatus != VA_STATUS_SUCCESS)
+ vaStatus = va_DRIGetDriverName(pDisplayContext, driver_name);
+
+ if ((vaStatus == VA_STATUS_SUCCESS)
+ && geteuid() == getuid())
+ {
+ /* don't allow setuid apps to use LIBVA_DRIVER_NAME */
+ if (getenv("LIBVA_DRIVER_NAME"))
+ {
+ /* For easier debugging */
+ if (*driver_name)
+ Xfree(*driver_name);
+
+ *driver_name = strdup(getenv("LIBVA_DRIVER_NAME"));
+ return VA_STATUS_SUCCESS;
+ }
+ }
+
+ return vaStatus;
+}
+
int vaDisplayIsValid(VADisplay dpy)
{
VADisplayContextP tmp=NULL;
diff --git a/src/va_backend.h b/src/va_backend.h
index 9ab4ce1..5d0785c 100755
--- a/src/va_backend.h
+++ b/src/va_backend.h
@@ -423,7 +423,7 @@ struct VADriverContext
Display *x11_dpy;
int x11_screen;
-
+ int dri2;
int version_major;
int version_minor;
int max_profiles;