Commit 98ed754f authored by Austin Yuan's avatar Austin Yuan

Merge branch 'test'

parents bb75774c cd115fe2
......@@ -21,9 +21,21 @@
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
AUTOMAKE_OPTIONS = foreign
SUBDIRS = src dummy_drv_video i965_drv_video test
SUBDIRS = src test
if BUILD_DUMMY_DRIVER
SUBDIRS += dummy_drv_video
endif
if BUILD_I965_DRIVER
SUBDIRS += i965_drv_video
endif
pcfiles = \
libva.pc
pkgconfigdir = @pkgconfigdir@
pkgconfig_DATA = libva.pc
pkgconfig_DATA = $(pcfiles)
EXTRA_DIST = libva.pc.in
CLEANFILES = $(pcfiles)
......@@ -20,13 +20,70 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# libva package version number, (as distinct from shared library version)
m4_define([libva_major_version], [0])
m4_define([libva_minor_version], [30])
m4_define([libva_micro_version], [4])
m4_define([libva_version],
[libva_major_version.libva_minor_version.libva_micro_version])
# increase this number for each API change
m4_define([libva_sds_version], [2])
# if the library source code has changed, increment revision
m4_define([libva_lt_revision], [1])
# if any interface was added/removed/changed, then inc current, reset revision
m4_define([libva_lt_current], [0])
# if any interface was added since last public release, then increment age
# if any interface was removed since last public release, then set age to 0
m4_define([libva_lt_age], [0])
AC_PREREQ(2.57)
AC_INIT([libva], 0.30.4, [waldo.bastian@intel.com], libva)
AC_INIT([libva], [libva_version], [waldo.bastian@intel.com], libva)
AC_CONFIG_SRCDIR([Makefile.am])
AM_INIT_AUTOMAKE([dist-bzip2])
AM_CONFIG_HEADER([config.h])
LIBVA_MAJOR_VERSION=libva_major_version
LIBVA_MINOR_VERSION=libva_minor_version
LIBVA_MICRO_VERSION=libva_micro_version
LIBVA_VERSION=libva_version
AC_SUBST(LIBVA_MAJOR_VERSION)
AC_SUBST(LIBVA_MINOR_VERSION)
AC_SUBST(LIBVA_MICRO_VERSION)
AC_SUBST(LIBVA_VERSION)
LIBVA_SDS_VERSION=libva_sds_version
AC_SUBST(LIBVA_SDS_VERSION)
LIBVA_LT_CURRENT=libva_lt_current
LIBVA_LT_REV=libva_lt_revision
LIBVA_LT_AGE=libva_lt_age
LIBVA_LT_VERSION="$LIBVA_LT_CURRENT:$LIBVA_LT_REV:$LIBVA_LT_AGE"
LIBVA_LT_LDFLAGS="-version-info $LIBVA_LT_VERSION"
AC_SUBST(LIBVA_LT_VERSION)
AC_SUBST(LIBVA_LT_LDFLAGS)
AC_ARG_ENABLE(dummy-driver,
[AC_HELP_STRING([--enable-dummy-driver],
[build dummy video driver])],
[], [enable_dummy_driver=yes])
AM_CONDITIONAL(BUILD_DUMMY_DRIVER, test x$enable_dummy_driver = xyes)
AC_ARG_ENABLE(i965-driver,
[AC_HELP_STRING([--enable-i965-driver],
[build i965 video driver])],
[], [enable_i965_driver=no])
AC_ARG_WITH(drivers-path,
[AC_HELP_STRING([--with-drivers-path=[[path]]], [drivers path])],,
[with_drivers_path="$libdir/dri"])
LIBVA_DRIVERS_PATH="$with_drivers_path"
AC_SUBST(LIBVA_DRIVERS_PATH)
AC_DISABLE_STATIC
AC_PROG_LIBTOOL
AC_PROG_CC
......@@ -36,23 +93,34 @@ AC_SYS_LARGEFILE
PKG_CHECK_MODULES([X11], [x11])
PKG_CHECK_MODULES([XEXT],[xext])
PKG_CHECK_MODULES([XFIXES], [xfixes])
PKG_CHECK_MODULES([DRM], [libdrm])
PKG_CHECK_MODULES(LIBDRM_DEPS, [libdrm])
PKG_CHECK_MODULES(GEN4ASM, [intel-gen4asm >= 1.0], [gen4asm=yes], [gen4asm=no])
AM_CONDITIONAL(HAVE_GEN4ASM, test x$gen4asm = xyes)
# Check for libdrm >= 2.4 (needed for i965_drv_video.so)
if test x$enable_i965_driver = xyes && ! $PKG_CONFIG --atleast-version=2.4 libdrm; then
AC_MSG_WARN([libdrm < 2.4 found, disabling build of i965 video driver])
enable_i965_driver=no
fi
AM_CONDITIONAL(BUILD_I965_DRIVER, test x$enable_i965_driver = xyes)
# We only need the headers, we don't link against the DRM libraries
LIBVA_CFLAGS="$LIBDRM_DEPS_CFLAGS"
LIBVA_CFLAGS="$DRM_CFLAGS"
AC_SUBST(LIBVA_CFLAGS)
AC_SUBST(LIBVA_LIBS)
pkgconfigdir=${libdir}/pkgconfig
AC_SUBST(pkgconfigdir)
libvabackendlib=libva.la
AC_SUBST([libvabackendlib])
AC_OUTPUT([
Makefile
src/Makefile
src/va_version.h
src/x11/Makefile
dummy_drv_video/Makefile
i965_drv_video/Makefile
......
......@@ -21,9 +21,10 @@
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
dummy_drv_video_la_LTLIBRARIES = dummy_drv_video.la
dummy_drv_video_ladir = /usr/lib/dri
dummy_drv_video_ladir = @LIBVA_DRIVERS_PATH@
dummy_drv_video_la_LDFLAGS = -module -avoid-version -no-undefined -Wl,--no-undefined
dummy_drv_video_la_LIBADD = ../src/libva.la
dummy_drv_video_la_LIBADD = $(top_srcdir)/src/$(libvabackendlib)
dummy_drv_video_la_DEPENDENCIES = $(top_srcdir)/src/$(libvabackendlib)
AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/../../include/external/ -I$(top_srcdir)/../../include/kmd -DIN_LIBVA
dummy_drv_video_la_SOURCES = dummy_drv_video.c object_heap.c
......
......@@ -1211,15 +1211,15 @@ VAStatus dummy_Terminate( VADriverContextP ctx )
return VA_STATUS_SUCCESS;
}
VAStatus __vaDriverInit_0_29( VADriverContextP ctx )
VAStatus __vaDriverInit_0_30( VADriverContextP ctx )
{
object_base_p obj;
int result;
struct dummy_driver_data *driver_data;
int i;
ctx->version_major = 0;
ctx->version_minor = 29;
ctx->version_major = VA_MAJOR_VERSION;
ctx->version_minor = VA_MINOR_VERSION;
ctx->max_profiles = DUMMY_MAX_PROFILES;
ctx->max_entrypoints = DUMMY_MAX_ENTRYPOINTS;
ctx->max_attributes = DUMMY_MAX_CONFIG_ATTRIBUTES;
......
......@@ -25,7 +25,7 @@ SUBDIRS = shaders
AM_CFLAGS = -Wall -I$(top_srcdir)/src -I$(top_srcdir)/src/x11 @DRM_CFLAGS@ -DIN_LIBVA
i965_drv_video_la_LTLIBRARIES = i965_drv_video.la
i965_drv_video_ladir = $(libdir)/dri
i965_drv_video_ladir = @LIBVA_DRIVERS_PATH@
i965_drv_video_la_LDFLAGS = -module -avoid-version -no-undefined -Wl,--no-undefined @DRM_LIBS@ -ldrm_intel
i965_drv_video_la_LIBADD = ../src/libva.la -lpthread
......
......@@ -2,6 +2,7 @@ prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
driverdir=@LIBVA_DRIVERS_PATH@
Name: libva
Description: Userspace Video Acceleration (VA) core interface
......
......@@ -22,25 +22,26 @@
INCLUDES = \
$(LIBVA_CFLAGS) -I$(top_srcdir)/src/x11 \
-DIN_LIBVA
-DIN_LIBVA \
-DVA_DRIVERS_PATH="\"$(LIBVA_DRIVERS_PATH)\""
LDADD = \
$(LIBVA_LT_LDFLAGS)
libva_la_LTLIBRARIES = libva.la
libva_ladir = $(libdir)
libva_la_LDFLAGS = -version-number 0:30:4 -no-undefined
libva_la_LDFLAGS = $(LDADD) -no-undefined
libva_la_LIBADD = $(LIBVA_LIBS) -ldl -lX11 -lXext x11/libva_x11.la -ldrm -lXfixes
nodist_libva_la_SOURCES = va_version.h
BUILT_SOURCES = va_version.h
CLEANFILES = va_version.h
va_version.h: Makefile
echo "#define VA_BUILD_DATE \"$(shell date +'%Y%m%d') $(shell date +'1%H%M%S') \"" > va_version.h
echo "#define VA_BUILD_GIT \"($(shell git log | head -n1 | cut -f2 -d' ')) \" " >> va_version.h
SUBDIRS = x11
libva_la_SOURCES = va.c
libvaincludedir = ${includedir}/va
libvainclude_HEADERS = va.h va_backend.h
libvainclude_HEADERS = va.h va_backend.h va_version.h
DISTCLEANFILES = \
va_version.h
EXTRA_DIST = \
va_version.h.in
......@@ -22,11 +22,10 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define _GNU_SOURCE 1
#include "va.h"
#include "va_backend.h"
#include "va_version.h"
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
......@@ -40,13 +39,9 @@
#include "va_dricommon.h"
#define VA_STR_VERSION VA_BUILD_DATE VA_BUILD_GIT
#define VA_MAJOR_VERSION 0
#define VA_MINOR_VERSION 30
#define DRIVER_INIT_FUNC "__vaDriverInit_0_30"
#define DRIVER_INIT_FUNC_SDS "__vaDriverInit_0_30_sds"
#define DEFAULT_DRIVER_DIR "/usr/lib/dri/"
#define DRIVER_EXTENSION "_drv_video.so"
#define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext)
......@@ -116,21 +111,8 @@ static Bool va_checkString(const char* value, char *variable)
static VAStatus va_getDriverName(VADisplay dpy, char **driver_name)
{
VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
VADriverContextP ctx = CTX(dpy);
VAStatus ret;
ret = pDisplayContext->vaGetDriverName(pDisplayContext, driver_name);
if (ret == VA_STATUS_SUCCESS)
{
if (isDRI2Connected(ctx, driver_name))
{
ret = VA_STATUS_SUCCESS;
} else if (isDRI1Connected(ctx, driver_name))
{
ret = VA_STATUS_SUCCESS;
}
}
return ret;
return pDisplayContext->vaGetDriverName(pDisplayContext, driver_name);
}
static VAStatus va_openDriver(VADisplay dpy, char *driver_name)
......@@ -152,7 +134,7 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name)
}
if (!search_path)
{
search_path = DEFAULT_DRIVER_DIR;
search_path = VA_DRIVERS_PATH;
}
search_path = strdup((const char *)search_path);
......@@ -184,6 +166,11 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name)
VADriverInit init_func;
init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC);
if (!init_func)
{
/* Then try SDS extensions (VDPAU and XvBA backends) */
init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC_SDS);
}
if (!init_func)
{
va_errorMessage("%s has no function %s\n", driver_path, DRIVER_INIT_FUNC);
dlclose(handle);
......@@ -347,7 +334,7 @@ VAStatus vaInitialize (
va_debug_trace = (getenv("LIBVA_DEBUG_TRACE") != NULL);
va_infoMessage("libva build on %s\n", VA_STR_VERSION);
va_infoMessage("libva version %s\n", VA_VERSION_S);
vaStatus = va_getDriverName(dpy, &driver_name);
va_infoMessage("va_getDriverName() returns %d\n", vaStatus);
......
......@@ -63,6 +63,12 @@
#ifndef _VA_H_
#define _VA_H_
#ifdef IN_LIBVA
#include "va_version.h"
#else
#include <va/va_version.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
......@@ -364,7 +370,8 @@ typedef VAGenericID VAContextID;
typedef VAGenericID VASurfaceID;
#define VA_INVALID_SURFACE -1
#define VA_INVALID_ID 0xffffffff
#define VA_INVALID_SURFACE VA_INVALID_ID
/*
* vaCreateSurfaces - Create an array of surfaces used for decode and display
......@@ -465,6 +472,27 @@ typedef enum
} VABufferType;
/*
* There will be cases where the bitstream buffer will not have enough room to hold
* the data for the entire slice, and the following flags will be used in the slice
* parameter to signal to the server for the possible cases.
* If a slice parameter buffer and slice data buffer pair is sent to the server with
* the slice data partially in the slice data buffer (BEGIN and MIDDLE cases below),
* then a slice parameter and data buffer needs to be sent again to complete this slice.
*/
#define VA_SLICE_DATA_FLAG_ALL 0x00 /* whole slice is in the buffer */
#define VA_SLICE_DATA_FLAG_BEGIN 0x01 /* The beginning of the slice is in the buffer but the end if not */
#define VA_SLICE_DATA_FLAG_MIDDLE 0x02 /* Neither beginning nor end of the slice is in the buffer */
#define VA_SLICE_DATA_FLAG_END 0x04 /* end of the slice is in the buffer */
/* Codec-independent Slice Parameter Buffer base */
typedef struct _VASliceParameterBufferBase
{
unsigned int slice_data_size; /* number of bytes in the slice data buffer for this slice */
unsigned int slice_data_offset; /* the offset to the first byte of slice data */
unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX definitions */
} VASliceParameterBufferBase;
/****************************
* MPEG-2 data structures
****************************/
......@@ -516,19 +544,6 @@ typedef struct _VAIQMatrixBufferMPEG2
unsigned char chroma_non_intra_quantiser_matrix[64];
} VAIQMatrixBufferMPEG2;
/*
* There will be cases where the bitstream buffer will not have enough room to hold
* the data for the entire slice, and the following flags will be used in the slice
* parameter to signal to the server for the possible cases.
* If a slice parameter buffer and slice data buffer pair is sent to the server with
* the slice data partially in the slice data buffer (BEGIN and MIDDLE cases below),
* then a slice parameter and data buffer needs to be sent again to complete this slice.
*/
#define VA_SLICE_DATA_FLAG_ALL 0x00 /* whole slice is in the buffer */
#define VA_SLICE_DATA_FLAG_BEGIN 0x01 /* The beginning of the slice is in the buffer but the end if not */
#define VA_SLICE_DATA_FLAG_MIDDLE 0x02 /* Neither beginning nor end of the slice is in the buffer */
#define VA_SLICE_DATA_FLAG_END 0x04 /* end of the slice is in the buffer */
/* MPEG-2 Slice Parameter Buffer */
typedef struct _VASliceParameterBufferMPEG2
{
......
......@@ -407,14 +407,11 @@ struct VADriverVTable
struct VADriverContext
{
void *old_pNext; /* preserved for binary compatibility */
void *pDriverData;
struct VADriverVTable vtable;
Display *x11_dpy;
int x11_screen;
int dri2;
int version_major;
int version_minor;
int max_profiles;
......
/*
* Copyright (C) 2009 Splitted-Desktop Systems. 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_VERSION_H
#define VA_VERSION_H
/**
* VA_MAJOR_VERSION:
*
* The major version of the VA library (1, if %VA_VERSION is 1.2.3)
*/
#define VA_MAJOR_VERSION (@LIBVA_MAJOR_VERSION@)
/**
* VA_MINOR_VERSION:
*
* The minor version of the VA library (2, if %VA_VERSION is 1.2.3)
*/
#define VA_MINOR_VERSION (@LIBVA_MINOR_VERSION@)
/**
* VA_MICRO_VERSION:
*
* The micro version of the VA library (3, if %VA_VERSION is 1.2.3)
*/
#define VA_MICRO_VERSION (@LIBVA_MICRO_VERSION@)
/**
* VA_SDS_VERSION:
*
* The version of the SDS API extensions to the VA library
*/
#define VA_SDS_VERSION (@LIBVA_SDS_VERSION@)
/**
* VA_VERSION:
*
* The full version of the VA library, like 1.2.3
*/
#define VA_VERSION @LIBVA_VERSION@
/**
* VA_VERSION_S:
*
* The full version of the VA library, in string form (suited for
* string concatenation)
*/
#define VA_VERSION_S "@LIBVA_VERSION@-sds@LIBVA_SDS_VERSION@"
/**
* VA_VERSION_HEX:
*
* Numerically encoded version of the VA library, like 0x010203
*/
#define VA_VERSION_HEX ((VA_MAJOR_VERSION << 24) | \
(VA_MINOR_VERSION << 16) | \
(VA_MICRO_VERSION << 8))
/**
* VA_CHECK_VERSION:
* @major: major version, like 1 in 1.2.3
* @minor: minor version, like 2 in 1.2.3
* @micro: micro version, like 3 in 1.2.3
*
* Evaluates to %TRUE if the version of the VA library is greater
* than @major, @minor and @micro
*/
#define VA_CHECK_VERSION(major,minor,micro) \
(VA_MAJOR_VERSION > (major) || \
(VA_MAJOR_VERSION == (major) && VA_MINOR_VERSION > (minor)) || \
(VA_MAJOR_VERSION == (major) && VA_MINOR_VERSION == (minor) && VA_MICRO_VERSION >= (micro)))
#endif /* VA_VERSION_H */
......@@ -22,9 +22,9 @@ AM_CFLAGS = -DLINUX -DIN_LIBVA -I$(top_srcdir)/src $(DRM_CFLAGS)
noinst_LTLIBRARIES = libva_x11.la
libva_x11includedir = ${includedir}/va
libva_x11includedir = ${includedir}/va
libva_x11include_HEADERS = va_x11.h va_dri.h va_dri2.h va_dricommon.h
libva_x11_la_SOURCES = va_x11.c va_dri.c va_dri2.c va_dricommon.c dri2_util.c dri1_util.c
libva_x11_la_SOURCES = va_x11.c va_dri.c va_dri2.c va_dricommon.c dri2_util.c dri1_util.c va_nvctrl.c
EXTRA_DIST = va_dristr.h va_dri2str.h va_dri2tokens.h
EXTRA_DIST = va_dristr.h va_dri2str.h va_dri2tokens.h va_nvctrl.h
......@@ -5,7 +5,8 @@
#include <xf86drm.h>
#include "X11/Xlib.h"
#include <X11/Xlibint.h>
#include <X11/Xlib.h>
#include "va.h"
#include "va_backend.h"
......
This diff is collapsed.
/*
* Copyright (c) 2008 NVIDIA, Corporation
*
* 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, sublicense, 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 NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS 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_NVCTRLLIB_H
#define VA_NVCTRLLIB_H
#include <X11/Xlib.h>
Bool VA_NVCTRLQueryDirectRenderingCapable( Display *dpy, int screen,
Bool *isCapable );
Bool VA_NVCTRLGetClientDriverName( Display *dpy, int screen,
int *ddxDriverMajorVersion, int *ddxDriverMinorVersion,
int *ddxDriverPatchVersion, char **clientDriverName );
#endif /* VA_NVCTRLLIB_H */
......@@ -22,6 +22,7 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define _GNU_SOURCE 1
#include "config.h"
#include "va.h"
#include "va_backend.h"
......@@ -29,9 +30,11 @@
#include "va_dri.h"
#include "va_dri2.h"
#include "va_dricommon.h"
#include "va_nvctrl.h"
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
......@@ -91,6 +94,7 @@ static void va_DisplayContextDestroy (
}
ctx = &((*ctx)->pNext);
}
free(pDisplayContext->pDriverContext->dri_state);
free(pDisplayContext->pDriverContext);
free(pDisplayContext);
}
......@@ -102,63 +106,46 @@ static VAStatus va_DRI2GetDriverName (
)
{
VADriverContextP ctx = pDisplayContext->pDriverContext;
VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
int eventBase, errorBase;
char *device_name;
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");
if (!isDRI2Connected(ctx, driver_name))
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_SUCCESS;
}
static VAStatus va_DRIGetDriverName (
VADisplayContextP pDisplayContext,
char **driver_name
)
{
VADriverContextP ctx = pDisplayContext->pDriverContext;
if (!isDRI1Connected(ctx, driver_name))
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 (
static VAStatus va_NVCTRL_GetDriverName (
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;
int driver_patch;
Bool result = True;
char *x_driver_name = NULL;
char *nvidia_driver_name = NULL;
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);
result = VA_NVCTRLQueryDirectRenderingCapable(ctx->x11_dpy, ctx->x11_screen, &direct_capable);
if (!result)
{
va_errorMessage("VA_DRIQueryDirectRenderingCapable failed\n");
va_errorMessage("VA_NVCTRLQueryDirectRenderingCapable failed\n");
}
}
if (result)
......@@ -166,29 +153,27 @@ static VAStatus va_DRIGetDriverName (
result = direct_capable;
if (!result)
{
va_errorMessage("VA_DRIQueryDirectRenderingCapable returned false\n");
va_errorMessage("VA_NVCTRLQueryDirectRenderingCapable returned false\n");
}
}
if (result)
{
result = VA_DRIGetClientDriverName(ctx->x11_dpy, ctx->x11_screen, &driver_major, &driver_minor,
&driver_patch, &x_driver_name);
result = VA_NVCTRLGetClientDriverName(ctx->x11_dpy, ctx->x11_screen, &driver_major, &driver_minor,
&driver_patch, &nvidia_driver_name);
if (!result)
{
va_errorMessage("VA_DRIGetClientDriverName returned false\n");
va_errorMessage("VA_NVCTRLGetClientDriverName returned false\n");
}
}
if (result)
{
vaStatus = VA_STATUS_SUCCESS;
va_infoMessage("VA_DRIGetClientDriverName: %d.%d.%d %s (screen %d)\n",
driver_major, driver_minor, driver_patch, x_driver_name, ctx->x11_screen);
if (driver_name)
*driver_name = strdup(x_driver_name);
va_infoMessage("va_NVCTRL_GetDriverName: %d.%d.%d %s (screen %d)\n",
driver_major, driver_minor, driver_patch,
nvidia_driver_name, ctx->x11_screen);
if (driver_name)
*driver_name = nvidia_driver_name;
}
if (x_driver_name)
XFree(x_driver_name);
return vaStatus;
}
......@@ -197,37 +182,26 @@ static VAStatus va_DisplayContextGetDriverName (
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;
VAStatus vaStatus;
char *driver_name_env;
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)
if ((driver_name_env = getenv("LIBVA_DRIVER_NAME")) != NULL
&& 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;
}
*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);
if (vaStatus != VA_STATUS_SUCCESS)
vaStatus = va_NVCTRL_GetDriverName(pDisplayContext, driver_name);
return vaStatus;
}
......@@ -278,11 +252,12 @@ VADisplay vaGetDisplay (
{
/* create new entry */
VADriverContextP pDriverContext;
struct dri_state *dri_state;
pDisplayContext = calloc(1, sizeof(*pDisplayContext));
pDriverContext = calloc(1, sizeof(*pDriverContext));
if (pDisplayContext && pDriverContext)
dri_state = calloc(1, sizeof(*dri_state));
if (pDisplayContext && pDriverContext && dri_state)
{
pDriverContext->old_pNext = (void *)(unsigned long)0xdeadbeef;
pDriverContext->x11_dpy = native_dpy;
pDisplayContext->pNext = pDisplayContexts;
pDisplayContext->pDriverContext = pDriverContext;
......@@ -290,7 +265,7 @@ VADisplay vaGetDisplay (
pDisplayContext->vaDestroy = va_DisplayContextDestroy;
pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
pDisplayContexts = pDisplayContext;
pDriverContext->dri_state = calloc(1, sizeof(struct dri_state));
pDriverContext->dri_state = dri_state;
dpy = (VADisplay)pDisplayContext;
}
else
......@@ -299,6 +274,8 @@ VADisplay vaGetDisplay (
free(pDisplayContext);
if (pDriverContext)
free(pDriverContext);
if (dri_state)
free(dri_state);
}
}
......
......@@ -31,9 +31,10 @@ AM_CFLAGS = -I$(top_srcdir)/../../include/external/ -I$(top_srcdir)/src -I$(top_
TESTS = $(check_PROGRAMS)
TEST_LIBS = ../src/libva.la
TEST_LIBS = $(top_srcdir)/src/$(libvabackendlib)
vainfo_LDADD = ../src/libva.la
vainfo_LDADD = $(top_srcdir)/src/$(libvabackendlib)
vainfo_DEPENDENCIES = $(top_srcdir)/src/$(libvabackendlib)
vainfo_SOURCES = vainfo.c
test_01_LDADD = $(TEST_LIBS)
......
......@@ -63,7 +63,7 @@ void status(const char *msg, ...)
int main(int argc, const char* argv[])
{
const char *name = rindex(argv[0], '/');
const char *name = strrchr(argv[0], '/');
if (name)
name++;
else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment