From a81ff887616933a465c9239e0e2e67c063cd96ad Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 8 Jul 2009 07:46:31 +0000 Subject: Fix includes. Signed-off-by: Austin Yuan --- src/va.c | 1 + src/x11/dri2_util.c | 3 ++- src/x11/va_x11.c | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/va.c b/src/va.c index de2d2d8..3c07386 100644 --- a/src/va.c +++ b/src/va.c @@ -22,6 +22,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#define _GNU_SOURCE 1 #include "va.h" #include "va_backend.h" diff --git a/src/x11/dri2_util.c b/src/x11/dri2_util.c index 1d3c141..ebe7a2c 100644 --- a/src/x11/dri2_util.c +++ b/src/x11/dri2_util.c @@ -5,7 +5,8 @@ #include -#include "X11/Xlib.h" +#include +#include #include "va.h" #include "va_backend.h" diff --git a/src/x11/va_x11.c b/src/x11/va_x11.c index 4cb8fcd..1e53401 100644 --- a/src/x11/va_x11.c +++ b/src/x11/va_x11.c @@ -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" @@ -32,6 +33,7 @@ #include #include #include +#include #include #include #include -- cgit v1.2.1 From 31d02ddc2acb7276f4031c1db310f6aeafadd10f Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 8 Jul 2009 07:47:15 +0000 Subject: Fix dummy_drv_video.so init function name. Signed-off-by: Austin Yuan --- dummy_drv_video/dummy_drv_video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dummy_drv_video/dummy_drv_video.c b/dummy_drv_video/dummy_drv_video.c index 20ee3ae..6ba6ebd 100644 --- a/dummy_drv_video/dummy_drv_video.c +++ b/dummy_drv_video/dummy_drv_video.c @@ -1211,7 +1211,7 @@ 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; -- cgit v1.2.1 From 4f1b4898eb71b07397095fb22122182bc4f7191d Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 8 Jul 2009 07:48:10 +0000 Subject: Install drivers into pkglibdir/va/. Signed-off-by: Austin Yuan --- configure.ac | 7 +++++++ dummy_drv_video/Makefile.am | 2 +- i965_drv_video/Makefile.am | 2 +- libva.pc.in | 1 + src/Makefile.am | 3 ++- src/va.c | 3 +-- 6 files changed, 13 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index a3a32e7..5d53059 100644 --- a/configure.ac +++ b/configure.ac @@ -27,6 +27,13 @@ AM_INIT_AUTOMAKE([dist-bzip2]) AM_CONFIG_HEADER([config.h]) +AC_ARG_WITH(drivers-path, + [AC_HELP_STRING([--with-drivers-path=[[path]]], [drivers path])],, + [with_drivers_path="$libdir/va/drivers"]) + +LIBVA_DRIVERS_PATH="$with_drivers_path" +AC_SUBST(LIBVA_DRIVERS_PATH) + AC_DISABLE_STATIC AC_PROG_LIBTOOL AC_PROG_CC diff --git a/dummy_drv_video/Makefile.am b/dummy_drv_video/Makefile.am index f782c71..53041eb 100644 --- a/dummy_drv_video/Makefile.am +++ b/dummy_drv_video/Makefile.am @@ -21,7 +21,7 @@ # 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 diff --git a/i965_drv_video/Makefile.am b/i965_drv_video/Makefile.am index 83fb8f1..c0117c9 100644 --- a/i965_drv_video/Makefile.am +++ b/i965_drv_video/Makefile.am @@ -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 diff --git a/libva.pc.in b/libva.pc.in index 16fb6aa..60f1483 100644 --- a/libva.pc.in +++ b/libva.pc.in @@ -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 diff --git a/src/Makefile.am b/src/Makefile.am index e990979..65cca77 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -22,7 +22,8 @@ INCLUDES = \ $(LIBVA_CFLAGS) -I$(top_srcdir)/src/x11 \ - -DIN_LIBVA + -DIN_LIBVA \ + -DVA_DRIVERS_PATH="\"$(LIBVA_DRIVERS_PATH)\"" libva_la_LTLIBRARIES = libva.la libva_ladir = $(libdir) diff --git a/src/va.c b/src/va.c index 3c07386..ce6961a 100644 --- a/src/va.c +++ b/src/va.c @@ -47,7 +47,6 @@ #define VA_MINOR_VERSION 30 #define DRIVER_INIT_FUNC "__vaDriverInit_0_30" -#define DEFAULT_DRIVER_DIR "/usr/lib/dri/" #define DRIVER_EXTENSION "_drv_video.so" #define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext) @@ -153,7 +152,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); -- cgit v1.2.1 From 3b10124ce0a3ce533f65bf613cbb6ef340f90c42 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 8 Jul 2009 07:49:23 +0000 Subject: Fix tests. Signed-off-by: Austin Yuan --- test/test_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_common.c b/test/test_common.c index 8a6ca9f..91774da 100644 --- a/test/test_common.c +++ b/test/test_common.c @@ -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 -- cgit v1.2.1 From 3cc18d820a60748c1c19fa5f4a388d9c05013392 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 8 Jul 2009 07:50:01 +0000 Subject: Allow conditional build of video drivers (dummy, i965). Signed-off-by: Austin Yuan --- Makefile.am | 9 ++++++++- configure.ac | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 3515b69..d1c7cce 100644 --- a/Makefile.am +++ b/Makefile.am @@ -21,7 +21,14 @@ # 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 pkgconfigdir = @pkgconfigdir@ pkgconfig_DATA = libva.pc diff --git a/configure.ac b/configure.ac index 5d53059..5b5314c 100644 --- a/configure.ac +++ b/configure.ac @@ -27,6 +27,17 @@ AM_INIT_AUTOMAKE([dist-bzip2]) AM_CONFIG_HEADER([config.h]) +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=yes]) + AC_ARG_WITH(drivers-path, [AC_HELP_STRING([--with-drivers-path=[[path]]], [drivers path])],, [with_drivers_path="$libdir/va/drivers"]) @@ -49,6 +60,13 @@ PKG_CHECK_MODULES(LIBDRM_DEPS, [libdrm]) AC_CHECK_PROG(gen4asm, [intel-gen4asm], yes, 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" AC_SUBST(LIBVA_CFLAGS) -- cgit v1.2.1 From c00a20b3c19b90f7f9fbd4007e02ba4ce20e975b Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 8 Jul 2009 07:50:40 +0000 Subject: Fix va_DisplayContextGetDriverName() to check for LIBVA_DRIVER_NAME first. Signed-off-by: Austin Yuan --- src/x11/va_x11.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/x11/va_x11.c b/src/x11/va_x11.c index 1e53401..cfb88be 100644 --- a/src/x11/va_x11.c +++ b/src/x11/va_x11.c @@ -206,30 +206,23 @@ static VAStatus va_DisplayContextGetDriverName ( int driver_minor; int driver_patch; Bool result = True; - char *x_driver_name = NULL; + 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); + return vaStatus; } -- cgit v1.2.1 From b88e0895f0c4657e2e24fcfd4aa0078c2cb222a4 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 8 Jul 2009 07:51:21 +0000 Subject: Fix driver name retrieval for dri1 and dri2. Signed-off-by: Austin Yuan --- src/va.c | 15 +--------- src/va_backend.h | 2 +- src/x11/va_x11.c | 84 +++----------------------------------------------------- 3 files changed, 6 insertions(+), 95 deletions(-) diff --git a/src/va.c b/src/va.c index ce6961a..cbba8f8 100644 --- a/src/va.c +++ b/src/va.c @@ -116,21 +116,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) diff --git a/src/va_backend.h b/src/va_backend.h index 7dc2302..c49376a 100644 --- a/src/va_backend.h +++ b/src/va_backend.h @@ -414,7 +414,7 @@ struct VADriverContext Display *x11_dpy; int x11_screen; - int dri2; + int old_dri2; /* obsolete */ int version_major; int version_minor; int max_profiles; diff --git a/src/x11/va_x11.c b/src/x11/va_x11.c index cfb88be..5e69d6b 100644 --- a/src/x11/va_x11.c +++ b/src/x11/va_x11.c @@ -104,34 +104,10 @@ 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_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; } @@ -141,57 +117,11 @@ static VAStatus va_DRIGetDriverName ( ) { 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; - if (!VA_DRIQueryExtension(ctx->x11_dpy, &eventBase, &errorBase)) { - va_errorMessage("VA_DRIQueryExtension failed\n"); + if (!isDRI1Connected(ctx, driver_name)) return VA_STATUS_ERROR_UNKNOWN; - } - - if (result) - { - result = VA_DRIQueryDirectRenderingCapable(ctx->x11_dpy, ctx->x11_screen, &direct_capable); - if (!result) - { - va_errorMessage("VA_DRIQueryDirectRenderingCapable failed\n"); - } - } - if (result) - { - result = direct_capable; - if (!result) - { - va_errorMessage("VA_DRIQueryDirectRenderingCapable returned false\n"); - } - } - if (result) - { - result = VA_DRIGetClientDriverName(ctx->x11_dpy, ctx->x11_screen, &driver_major, &driver_minor, - &driver_patch, &x_driver_name); - if (!result) - { - va_errorMessage("VA_DRIGetClientDriverName 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); - } - if (x_driver_name) - XFree(x_driver_name); - return vaStatus; + return VA_STATUS_SUCCESS; } static VAStatus va_DisplayContextGetDriverName ( @@ -199,13 +129,7 @@ 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; + VAStatus vaStatus; char *driver_name_env; if (driver_name) -- cgit v1.2.1 From fa84f83f80bc4f201cb40b09842965ee62b87f1e Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 8 Jul 2009 07:51:42 +0000 Subject: Drop duplicate LIBDRM_DEPS pkg-config check. Signed-off-by: Austin Yuan --- configure.ac | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 5b5314c..3b57b34 100644 --- a/configure.ac +++ b/configure.ac @@ -55,7 +55,6 @@ AC_SYS_LARGEFILE PKG_CHECK_MODULES([X11], [x11]) PKG_CHECK_MODULES([XEXT],[xext]) PKG_CHECK_MODULES([DRM], [libdrm]) -PKG_CHECK_MODULES(LIBDRM_DEPS, [libdrm]) AC_CHECK_PROG(gen4asm, [intel-gen4asm], yes, no) AM_CONDITIONAL(HAVE_GEN4ASM, test x$gen4asm = xyes) @@ -68,7 +67,7 @@ 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) -- cgit v1.2.1 From 782c7439bcd0a09f64c21fd3197fa5580cdc0682 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 8 Jul 2009 07:51:58 +0000 Subject: Add check for libXfixes. Signed-off-by: Austin Yuan --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index 3b57b34..ea9e33e 100644 --- a/configure.ac +++ b/configure.ac @@ -54,6 +54,7 @@ AC_SYS_LARGEFILE PKG_CHECK_MODULES([X11], [x11]) PKG_CHECK_MODULES([XEXT],[xext]) +PKG_CHECK_MODULES([XFIXES], [xfixes]) PKG_CHECK_MODULES([DRM], [libdrm]) AC_CHECK_PROG(gen4asm, [intel-gen4asm], yes, no) -- cgit v1.2.1 From ebb5f8bab9dee76b2b2f1d6db409df06de0ba74b Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 8 Jul 2009 07:52:49 +0000 Subject: Fix make install (). Actually drop extraneous space. ;-) Signed-off-by: Austin Yuan --- src/x11/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/x11/Makefile.am b/src/x11/Makefile.am index 06129db..8d1c160 100644 --- a/src/x11/Makefile.am +++ b/src/x11/Makefile.am @@ -22,7 +22,7 @@ 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 -- cgit v1.2.1 From 0108c576ab09ac33c5edaee78bcc468527e32da8 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 8 Jul 2009 07:53:08 +0000 Subject: Add VA_INVALID_ID helper macro. Signed-off-by: Austin Yuan --- src/va.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/va.h b/src/va.h index 2c2cbe6..6856761 100644 --- a/src/va.h +++ b/src/va.h @@ -364,7 +364,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 -- cgit v1.2.1 From 2496bb03f3e70bcbee39ab84c1780ccbd57e97be Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 8 Jul 2009 07:53:37 +0000 Subject: Fix memory leak (VADriverContext.dri_state). Signed-off-by: Austin Yuan --- src/x11/va_x11.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/x11/va_x11.c b/src/x11/va_x11.c index 5e69d6b..46911fc 100644 --- a/src/x11/va_x11.c +++ b/src/x11/va_x11.c @@ -93,6 +93,7 @@ static void va_DisplayContextDestroy ( } ctx = &((*ctx)->pNext); } + free(pDisplayContext->pDriverContext->dri_state); free(pDisplayContext->pDriverContext); free(pDisplayContext); } @@ -197,9 +198,11 @@ 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; @@ -209,7 +212,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 @@ -218,6 +221,8 @@ VADisplay vaGetDisplay ( free(pDisplayContext); if (pDriverContext) free(pDriverContext); + if (dri_state) + free(dri_state); } } -- cgit v1.2.1 From fb633440881179f5df31d1c436f1db86b58b0485 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 8 Jul 2009 07:54:02 +0000 Subject: Add new DSO versioning (SONAME changed to libva-VERSION.so.CURRENT.REVISION.AGE). Signed-off-by: Austin Yuan --- Makefile.am | 7 ++++++- configure.ac | 38 +++++++++++++++++++++++++++++++++++++- dummy_drv_video/Makefile.am | 3 ++- src/Makefile.am | 5 ++++- test/Makefile.am | 5 +++-- 5 files changed, 52 insertions(+), 6 deletions(-) diff --git a/Makefile.am b/Makefile.am index d1c7cce..cd0ee58 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,7 +30,12 @@ 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) diff --git a/configure.ac b/configure.ac index ea9e33e..8490203 100644 --- a/configure.ac +++ b/configure.ac @@ -20,13 +20,46 @@ # 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]) + +# if the library source code has changed, increment revision +m4_define([libva_lt_revision], [0]) +# if any interface was added/removed/changed, then inc current, reset revision +m4_define([libva_lt_current], [1]) +# 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_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 -release $LIBVA_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])], @@ -75,6 +108,9 @@ AC_SUBST(LIBVA_LIBS) pkgconfigdir=${libdir}/pkgconfig AC_SUBST(pkgconfigdir) +libvabackendlib=libva.la +AC_SUBST([libvabackendlib]) + AC_OUTPUT([ Makefile src/Makefile diff --git a/dummy_drv_video/Makefile.am b/dummy_drv_video/Makefile.am index 53041eb..4e75a7b 100644 --- a/dummy_drv_video/Makefile.am +++ b/dummy_drv_video/Makefile.am @@ -23,7 +23,8 @@ dummy_drv_video_la_LTLIBRARIES = dummy_drv_video.la 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 diff --git a/src/Makefile.am b/src/Makefile.am index 65cca77..26671d3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -25,9 +25,12 @@ INCLUDES = \ -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 diff --git a/test/Makefile.am b/test/Makefile.am index 04a24ab..58e1677 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -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) -- cgit v1.2.1 From 6a1c58a195140e20375f0e57f512c023e22901ad Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 8 Jul 2009 07:56:26 +0000 Subject: Remove obsolete fields. Signed-off-by: Austin Yuan --- src/va_backend.h | 3 --- src/x11/va_x11.c | 1 - 2 files changed, 4 deletions(-) diff --git a/src/va_backend.h b/src/va_backend.h index c49376a..619dd99 100644 --- a/src/va_backend.h +++ b/src/va_backend.h @@ -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 old_dri2; /* obsolete */ int version_major; int version_minor; int max_profiles; diff --git a/src/x11/va_x11.c b/src/x11/va_x11.c index 46911fc..a196d3d 100644 --- a/src/x11/va_x11.c +++ b/src/x11/va_x11.c @@ -204,7 +204,6 @@ VADisplay vaGetDisplay ( 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; -- cgit v1.2.1 From ddb1a3247bab99832366429888522a314526e98c Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 8 Jul 2009 07:58:29 +0000 Subject: Add VASliceParameterBufferBase. Signed-off-by: Austin Yuan --- src/va.h | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/va.h b/src/va.h index 6856761..4218d35 100644 --- a/src/va.h +++ b/src/va.h @@ -466,6 +466,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 ****************************/ @@ -517,19 +538,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 { -- cgit v1.2.1 From 39551cbc364a700b2a8875cb154265f4a35fc523 Mon Sep 17 00:00:00 2001 From: Austin Yuan Date: Wed, 8 Jul 2009 17:48:06 +0800 Subject: don't build i965 driver by default Signed-off-by: Austin Yuan --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 8490203..33d4a36 100644 --- a/configure.ac +++ b/configure.ac @@ -69,7 +69,7 @@ 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=yes]) + [], [enable_i965_driver=no]) AC_ARG_WITH(drivers-path, [AC_HELP_STRING([--with-drivers-path=[[path]]], [drivers path])],, -- cgit v1.2.1 From 65654a4003374c1eb6b0c2611d02634d67bd5c17 Mon Sep 17 00:00:00 2001 From: Austin Yuan Date: Wed, 8 Jul 2009 17:50:16 +0800 Subject: put drivers into /usr/lib/dri by default Signed-off-by: Austin Yuan --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 33d4a36..db1c0cb 100644 --- a/configure.ac +++ b/configure.ac @@ -73,7 +73,7 @@ AC_ARG_ENABLE(i965-driver, AC_ARG_WITH(drivers-path, [AC_HELP_STRING([--with-drivers-path=[[path]]], [drivers path])],, - [with_drivers_path="$libdir/va/drivers"]) + [with_drivers_path="$libdir/dri"]) LIBVA_DRIVERS_PATH="$with_drivers_path" AC_SUBST(LIBVA_DRIVERS_PATH) -- cgit v1.2.1 From 3e118290c1055891339fd7b0591f0e9f47c839d5 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 8 Jul 2009 07:55:42 +0000 Subject: Add for versioning helpers. Signed-off-by: Austin Yuan --- configure.ac | 1 + dummy_drv_video/dummy_drv_video.c | 4 +- src/Makefile.am | 17 ++++---- src/va.c | 8 +--- src/va.h | 6 +++ src/va_version.h.in | 87 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 104 insertions(+), 19 deletions(-) create mode 100644 src/va_version.h.in diff --git a/configure.ac b/configure.ac index db1c0cb..b6f7923 100644 --- a/configure.ac +++ b/configure.ac @@ -114,6 +114,7 @@ AC_SUBST([libvabackendlib]) AC_OUTPUT([ Makefile src/Makefile + src/va_version.h src/x11/Makefile dummy_drv_video/Makefile i965_drv_video/Makefile diff --git a/dummy_drv_video/dummy_drv_video.c b/dummy_drv_video/dummy_drv_video.c index 6ba6ebd..1eb51a0 100644 --- a/dummy_drv_video/dummy_drv_video.c +++ b/dummy_drv_video/dummy_drv_video.c @@ -1218,8 +1218,8 @@ VAStatus __vaDriverInit_0_30( VADriverContextP ctx ) 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; diff --git a/src/Makefile.am b/src/Makefile.am index 26671d3..5fac8b5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -33,18 +33,15 @@ libva_ladir = $(libdir) 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 diff --git a/src/va.c b/src/va.c index cbba8f8..d7afedc 100644 --- a/src/va.c +++ b/src/va.c @@ -26,8 +26,6 @@ #include "va.h" #include "va_backend.h" -#include "va_version.h" - #include #include #include @@ -41,10 +39,6 @@ #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_EXTENSION "_drv_video.so" @@ -334,7 +328,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); diff --git a/src/va.h b/src/va.h index 4218d35..a52895c 100644 --- a/src/va.h +++ b/src/va.h @@ -63,6 +63,12 @@ #ifndef _VA_H_ #define _VA_H_ +#ifdef IN_LIBVA +#include "va_version.h" +#else +#include +#endif + #ifdef __cplusplus extern "C" { #endif diff --git a/src/va_version.h.in b/src/va_version.h.in new file mode 100644 index 0000000..c9ea97a --- /dev/null +++ b/src/va_version.h.in @@ -0,0 +1,87 @@ +/* + * 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_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@" + +/** + * 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 */ -- cgit v1.2.1 From a2523fec99e31a6a2ad0135cbad0afa5b29c34f6 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 8 Jul 2009 07:56:05 +0000 Subject: Fix NVIDIA driver detection. Signed-off-by: Austin Yuan --- src/x11/Makefile.am | 4 +- src/x11/va_nvctrl.c | 392 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/x11/va_nvctrl.h | 36 +++++ src/x11/va_x11.c | 54 ++++++++ 4 files changed, 484 insertions(+), 2 deletions(-) create mode 100644 src/x11/va_nvctrl.c create mode 100644 src/x11/va_nvctrl.h diff --git a/src/x11/Makefile.am b/src/x11/Makefile.am index 8d1c160..c70380d 100644 --- a/src/x11/Makefile.am +++ b/src/x11/Makefile.am @@ -25,6 +25,6 @@ noinst_LTLIBRARIES = libva_x11.la 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 diff --git a/src/x11/va_nvctrl.c b/src/x11/va_nvctrl.c new file mode 100644 index 0000000..46fcca5 --- /dev/null +++ b/src/x11/va_nvctrl.c @@ -0,0 +1,392 @@ +/* + * 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. + */ + +#define _GNU_SOURCE 1 +#include + +#define NEED_REPLIES +#include +#include +#include +#include +#include +#include "va_nvctrl.h" + +#define NV_CONTROL_ERRORS 0 +#define NV_CONTROL_EVENTS 5 +#define NV_CONTROL_NAME "NV-CONTROL" + +#define NV_CTRL_TARGET_TYPE_X_SCREEN 0 +#define NV_CTRL_TARGET_TYPE_GPU 1 +#define NV_CTRL_TARGET_TYPE_FRAMELOCK 2 +#define NV_CTRL_TARGET_TYPE_VCSC 3 /* Visual Computing System */ + +#define NV_CTRL_STRING_NVIDIA_DRIVER_VERSION 3 /* R--G */ + +#define X_nvCtrlQueryExtension 0 +#define X_nvCtrlIsNv 1 +#define X_nvCtrlQueryStringAttribute 4 + +typedef struct { + CARD8 reqType; + CARD8 nvReqType; + CARD16 length B16; +} xnvCtrlQueryExtensionReq; +#define sz_xnvCtrlQueryExtensionReq 4 + +typedef struct { + BYTE type; /* X_Reply */ + CARD8 padb1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD16 major B16; + CARD16 minor B16; + CARD32 padl4 B32; + CARD32 padl5 B32; + CARD32 padl6 B32; + CARD32 padl7 B32; + CARD32 padl8 B32; +} xnvCtrlQueryExtensionReply; +#define sz_xnvCtrlQueryExtensionReply 32 + +typedef struct { + CARD8 reqType; + CARD8 nvReqType; + CARD16 length B16; + CARD32 screen B32; +} xnvCtrlIsNvReq; +#define sz_xnvCtrlIsNvReq 8 + +typedef struct { + BYTE type; /* X_Reply */ + CARD8 padb1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 isnv B32; + CARD32 padl4 B32; + CARD32 padl5 B32; + CARD32 padl6 B32; + CARD32 padl7 B32; + CARD32 padl8 B32; +} xnvCtrlIsNvReply; +#define sz_xnvCtrlIsNvReply 32 + +typedef struct { + CARD8 reqType; + CARD8 nvReqType; + CARD16 length B16; + CARD16 target_id B16; /* X screen number or GPU number */ + CARD16 target_type B16; /* X screen or GPU */ + CARD32 display_mask B32; + CARD32 attribute B32; +} xnvCtrlQueryStringAttributeReq; +#define sz_xnvCtrlQueryStringAttributeReq 16 + +typedef struct { + BYTE type; + BYTE pad0; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 flags B32; + CARD32 n B32; /* Length of string */ + CARD32 pad4 B32; + CARD32 pad5 B32; + CARD32 pad6 B32; + CARD32 pad7 B32; +} xnvCtrlQueryStringAttributeReply; +#define sz_xnvCtrlQueryStringAttributeReply 32 + +#define NVCTRL_EXT_NEED_CHECK (XPointer)(~0) +#define NVCTRL_EXT_NEED_NOTHING (XPointer)(0) +#define NVCTRL_EXT_NEED_TARGET_SWAP (XPointer)(1) + +static XExtensionInfo _nvctrl_ext_info_data; +static XExtensionInfo *nvctrl_ext_info = &_nvctrl_ext_info_data; +static /* const */ char *nvctrl_extension_name = NV_CONTROL_NAME; + +#define XNVCTRLCheckExtension(dpy,i,val) \ + XextCheckExtension (dpy, i, nvctrl_extension_name, val) +#define XNVCTRLSimpleCheckExtension(dpy,i) \ + XextSimpleCheckExtension (dpy, i, nvctrl_extension_name) + +static int close_display(); +static /* const */ XExtensionHooks nvctrl_extension_hooks = { + NULL, /* create_gc */ + NULL, /* copy_gc */ + NULL, /* flush_gc */ + NULL, /* free_gc */ + NULL, /* create_font */ + NULL, /* free_font */ + close_display, /* close_display */ + NULL, /* wire_to_event */ + NULL, /* event_to_wire */ + NULL, /* error */ + NULL, /* error_string */ +}; + +static XEXT_GENERATE_FIND_DISPLAY (find_display, nvctrl_ext_info, + nvctrl_extension_name, + &nvctrl_extension_hooks, + NV_CONTROL_EVENTS, NVCTRL_EXT_NEED_CHECK) + +static XEXT_GENERATE_CLOSE_DISPLAY (close_display, nvctrl_ext_info) + +static Bool XNVCTRLQueryVersion (Display *dpy, int *major, int *minor); + +/* + * NV-CONTROL versions 1.8 and 1.9 pack the target_type and target_id + * fields in reversed order. In order to talk to one of these servers, + * we need to swap these fields. + */ +static void XNVCTRLCheckTargetData(Display *dpy, XExtDisplayInfo *info, + int *target_type, int *target_id) +{ + /* Find out what the server's NV-CONTROL version is and + * setup for swapping if we need to. + */ + if (info->data == NVCTRL_EXT_NEED_CHECK) { + int major, minor; + + if (XNVCTRLQueryVersion(dpy, &major, &minor)) { + if (major == 1 && + (minor == 8 || minor == 9)) { + info->data = NVCTRL_EXT_NEED_TARGET_SWAP; + } else { + info->data = NVCTRL_EXT_NEED_NOTHING; + } + } else { + info->data = NVCTRL_EXT_NEED_NOTHING; + } + } + + /* We need to swap the target_type and target_id */ + if (info->data == NVCTRL_EXT_NEED_TARGET_SWAP) { + int tmp; + tmp = *target_type; + *target_type = *target_id; + *target_id = tmp; + } +} + + +static Bool XNVCTRLQueryExtension ( + Display *dpy, + int *event_basep, + int *error_basep +){ + XExtDisplayInfo *info = find_display (dpy); + + if (XextHasExtension(info)) { + if (event_basep) *event_basep = info->codes->first_event; + if (error_basep) *error_basep = info->codes->first_error; + return True; + } else { + return False; + } +} + + +static Bool XNVCTRLQueryVersion ( + Display *dpy, + int *major, + int *minor +){ + XExtDisplayInfo *info = find_display (dpy); + xnvCtrlQueryExtensionReply rep; + xnvCtrlQueryExtensionReq *req; + + if(!XextHasExtension(info)) + return False; + + XNVCTRLCheckExtension (dpy, info, False); + + LockDisplay (dpy); + GetReq (nvCtrlQueryExtension, req); + req->reqType = info->codes->major_opcode; + req->nvReqType = X_nvCtrlQueryExtension; + if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { + UnlockDisplay (dpy); + SyncHandle (); + return False; + } + if (major) *major = rep.major; + if (minor) *minor = rep.minor; + UnlockDisplay (dpy); + SyncHandle (); + return True; +} + + +static Bool XNVCTRLIsNvScreen ( + Display *dpy, + int screen +){ + XExtDisplayInfo *info = find_display (dpy); + xnvCtrlIsNvReply rep; + xnvCtrlIsNvReq *req; + Bool isnv; + + if(!XextHasExtension(info)) + return False; + + XNVCTRLCheckExtension (dpy, info, False); + + LockDisplay (dpy); + GetReq (nvCtrlIsNv, req); + req->reqType = info->codes->major_opcode; + req->nvReqType = X_nvCtrlIsNv; + req->screen = screen; + if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { + UnlockDisplay (dpy); + SyncHandle (); + return False; + } + isnv = rep.isnv; + UnlockDisplay (dpy); + SyncHandle (); + return isnv; +} + + +static Bool XNVCTRLQueryTargetStringAttribute ( + Display *dpy, + int target_type, + int target_id, + unsigned int display_mask, + unsigned int attribute, + char **ptr +){ + XExtDisplayInfo *info = find_display (dpy); + xnvCtrlQueryStringAttributeReply rep; + xnvCtrlQueryStringAttributeReq *req; + Bool exists; + int length, numbytes, slop; + + if (!ptr) return False; + + if(!XextHasExtension(info)) + return False; + + XNVCTRLCheckExtension (dpy, info, False); + XNVCTRLCheckTargetData(dpy, info, &target_type, &target_id); + + LockDisplay (dpy); + GetReq (nvCtrlQueryStringAttribute, req); + req->reqType = info->codes->major_opcode; + req->nvReqType = X_nvCtrlQueryStringAttribute; + req->target_type = target_type; + req->target_id = target_id; + req->display_mask = display_mask; + req->attribute = attribute; + if (!_XReply (dpy, (xReply *) &rep, 0, False)) { + UnlockDisplay (dpy); + SyncHandle (); + return False; + } + length = rep.length; + numbytes = rep.n; + slop = numbytes & 3; + *ptr = (char *) Xmalloc(numbytes); + if (! *ptr) { + _XEatData(dpy, length); + UnlockDisplay (dpy); + SyncHandle (); + return False; + } else { + _XRead(dpy, (char *) *ptr, numbytes); + if (slop) _XEatData(dpy, 4-slop); + } + exists = rep.flags; + UnlockDisplay (dpy); + SyncHandle (); + return exists; +} + +static Bool XNVCTRLQueryStringAttribute ( + Display *dpy, + int screen, + unsigned int display_mask, + unsigned int attribute, + char **ptr +){ + return XNVCTRLQueryTargetStringAttribute(dpy, NV_CTRL_TARGET_TYPE_X_SCREEN, + screen, display_mask, + attribute, ptr); +} + + +Bool VA_NVCTRLQueryDirectRenderingCapable( Display *dpy, int screen, + Bool *isCapable ) +{ + int event_base; + int error_base; + + if (isCapable) + *isCapable = False; + + if (!XNVCTRLQueryExtension(dpy, &event_base, &error_base)) + return False; + + if (isCapable && XNVCTRLIsNvScreen(dpy, screen)) + *isCapable = True; + + return True; +} + +Bool VA_NVCTRLGetClientDriverName( Display *dpy, int screen, + int *ddxDriverMajorVersion, int *ddxDriverMinorVersion, + int *ddxDriverPatchVersion, char **clientDriverName ) +{ + if (ddxDriverMajorVersion) + *ddxDriverMajorVersion = 0; + if (ddxDriverMinorVersion) + *ddxDriverMinorVersion = 0; + if (ddxDriverPatchVersion) + *ddxDriverPatchVersion = 0; + if (clientDriverName) + *clientDriverName = NULL; + + char *nvidia_driver_version = NULL; + if (!XNVCTRLQueryStringAttribute(dpy, screen, 0, NV_CTRL_STRING_NVIDIA_DRIVER_VERSION, &nvidia_driver_version)) + return False; + + char *end, *str = nvidia_driver_version; + unsigned long v = strtoul(str, &end, 10); + if (end && end != str) { + if (ddxDriverMajorVersion) + *ddxDriverMajorVersion = v; + if (*(str = end) == '.') { + v = strtoul(str + 1, &end, 10); + if (end && end != str && *end == '\0') { + if (ddxDriverMinorVersion) + *ddxDriverMinorVersion = v; + } + } + } + Xfree(nvidia_driver_version); + + if (clientDriverName) + *clientDriverName = strdup("nvidia"); + + return True; +} diff --git a/src/x11/va_nvctrl.h b/src/x11/va_nvctrl.h new file mode 100644 index 0000000..c137b86 --- /dev/null +++ b/src/x11/va_nvctrl.h @@ -0,0 +1,36 @@ +/* + * 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 + +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 */ diff --git a/src/x11/va_x11.c b/src/x11/va_x11.c index a196d3d..ec0bbc8 100644 --- a/src/x11/va_x11.c +++ b/src/x11/va_x11.c @@ -30,6 +30,7 @@ #include "va_dri.h" #include "va_dri2.h" #include "va_dricommon.h" +#include "va_nvctrl.h" #include #include #include @@ -125,6 +126,57 @@ static VAStatus va_DRIGetDriverName ( return VA_STATUS_SUCCESS; } +static VAStatus va_NVCTRL_GetDriverName ( + 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 *nvidia_driver_name = NULL; + + if (result) + { + result = VA_NVCTRLQueryDirectRenderingCapable(ctx->x11_dpy, ctx->x11_screen, &direct_capable); + if (!result) + { + va_errorMessage("VA_NVCTRLQueryDirectRenderingCapable failed\n"); + } + } + if (result) + { + result = direct_capable; + if (!result) + { + va_errorMessage("VA_NVCTRLQueryDirectRenderingCapable returned false\n"); + } + } + if (result) + { + result = VA_NVCTRLGetClientDriverName(ctx->x11_dpy, ctx->x11_screen, &driver_major, &driver_minor, + &driver_patch, &nvidia_driver_name); + if (!result) + { + va_errorMessage("VA_NVCTRLGetClientDriverName returned false\n"); + } + } + if (result) + { + vaStatus = VA_STATUS_SUCCESS; + 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; + } + return vaStatus; +} + static VAStatus va_DisplayContextGetDriverName ( VADisplayContextP pDisplayContext, char **driver_name @@ -147,6 +199,8 @@ static VAStatus va_DisplayContextGetDriverName ( 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; } -- cgit v1.2.1 From 2162a793560a02651b3da00bb663f519742bc3fc Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 8 Jul 2009 07:56:57 +0000 Subject: Explicit API extensions versioning from SDS. Signed-off-by: Austin Yuan --- configure.ac | 8 +++++++- src/va.c | 6 ++++++ src/va_version.h.in | 9 ++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index b6f7923..3927055 100644 --- a/configure.ac +++ b/configure.ac @@ -28,6 +28,9 @@ 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], [0]) # if any interface was added/removed/changed, then inc current, reset revision @@ -52,11 +55,14 @@ 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 -release $LIBVA_VERSION" +LIBVA_LT_LDFLAGS="-version-info $LIBVA_LT_VERSION -release $LIBVA_VERSION.$LIBVA_SDS_VERSION" AC_SUBST(LIBVA_LT_VERSION) AC_SUBST(LIBVA_LT_LDFLAGS) diff --git a/src/va.c b/src/va.c index d7afedc..b409c7c 100644 --- a/src/va.c +++ b/src/va.c @@ -40,6 +40,7 @@ #define DRIVER_INIT_FUNC "__vaDriverInit_0_30" +#define DRIVER_INIT_FUNC_SDS "__vaDriverInit_0_30_sds" #define DRIVER_EXTENSION "_drv_video.so" @@ -165,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); diff --git a/src/va_version.h.in b/src/va_version.h.in index c9ea97a..197c482 100644 --- a/src/va_version.h.in +++ b/src/va_version.h.in @@ -46,6 +46,13 @@ */ #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: * @@ -59,7 +66,7 @@ * The full version of the VA library, in string form (suited for * string concatenation) */ -#define VA_VERSION_S "@LIBVA_VERSION@" +#define VA_VERSION_S "@LIBVA_VERSION@-sds@LIBVA_SDS_VERSION@" /** * VA_VERSION_HEX: -- cgit v1.2.1 From cd115fe21c3493f831dcb653c62d38e577bb6943 Mon Sep 17 00:00:00 2001 From: Austin Yuan Date: Fri, 14 Aug 2009 22:30:02 +0800 Subject: Don't include VAAPI version to SONAME VAAPI version upgrade doesn't mean it will break binary compatibility Signed-off-by: Austin Yuan --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 3927055..703bb97 100644 --- a/configure.ac +++ b/configure.ac @@ -32,9 +32,9 @@ m4_define([libva_version], m4_define([libva_sds_version], [2]) # if the library source code has changed, increment revision -m4_define([libva_lt_revision], [0]) +m4_define([libva_lt_revision], [1]) # if any interface was added/removed/changed, then inc current, reset revision -m4_define([libva_lt_current], [1]) +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]) @@ -62,7 +62,7 @@ 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 -release $LIBVA_VERSION.$LIBVA_SDS_VERSION" +LIBVA_LT_LDFLAGS="-version-info $LIBVA_LT_VERSION" AC_SUBST(LIBVA_LT_VERSION) AC_SUBST(LIBVA_LT_LDFLAGS) -- cgit v1.2.1