Commit 0537b13e authored by Aaron Plattner's avatar Aaron Plattner
Browse files

Move VDPAU drivers into their own module directory.



* Add a --with-module-dir configure parameter.

* Pass the moduledir into the wrapper.  Use it to construct the path to search
  for drivers.  Require drivers to end in a ".1" version, in case we ever want
  to rev. the interface between the wrapper and the drivers.

* If no driver is found in the new module dir, look for one in the default
  search paths.  This is intended to find libvdpau_nvidia.so for drivers that
  predate the change to move it, and can be removed in the future.

* Stash the moduledir into vdpau.pc.  Drivers can find this with
  `pkg-config --variable=moduledir vdpau`.

* Add a version to libvdpau_trace.so in case the interface between it and
  libvdpau.so ever changes.

* Install libvdpau_trace.so.1 to moduledir instead of libdir.
Signed-off-by: default avatarAaron Plattner <aplattner@nvidia.com>
Acked-by: default avatarStephen Warren <swarren@nvidia.com>
parent f1f2b25e
......@@ -51,6 +51,14 @@ fi
AM_CONDITIONAL([ENABLE_DOCS], [test "x$DOXYGEN" != xno -a "x$DOT" != xno -a "x$PDFTEX" != xno])
AC_SUBST(DOXYGEN)
# Options
AC_ARG_WITH(module-dir,
AC_HELP_STRING([--with-module-dir=DIR],
[Default module directory [[default=LIBDIR/vdpau]]]),
[moduledir="$withval"],
[moduledir="$libdir/vdpau"])
AC_SUBST(moduledir)
XORG_CHANGELOG
AC_OUTPUT([Makefile
......
......@@ -6,7 +6,7 @@
/*
* This copyright notice applies to this header file:
*
* Copyright (c) 2008 NVIDIA Corporation
* Copyright (c) 2008-2009 NVIDIA Corporation
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
......@@ -72,13 +72,15 @@ extern "C" {
* standard system (possibly X11-specific) library path.
* - \c libvdpau.so.1 (runtime)
* - \c libvdpau.so (development)
* - Back-end driver files. These files are located in the
* standard system (possibly X11-specific) library path.
* - \c libvdpau_\%s.so
* - Back-end driver files. These files are located in a
* system-defined library path, which is configurable at compile
* time but is typically /usr/lib/vdpau. Use `pkg-config
* --variable=moduledir vdpau` to locate the driver install path.
* - \c $moduledir/libvdpau_\%s.so.1
* For example:
* - \c libvdpau_nvidia.so
* - \c libvdpau_intel.so
* - \c libvdpau_ati.so
* - \c /usr/lib/vdpau/libvdpau_nvidia.so.1
* - \c /usr/lib/vdpau/libvdpau_intel.so.1
* - \c /usr/lib/vdpau/libvdpau_ati.so.1
*
* The VDPAU wrapper library implements just one function; \ref
* vdp_device_create_x11. The wrapper will implement this function
......
AM_CFLAGS = \
-I$(top_srcdir)/include \
-DVDPAU_MODULEDIR="\"$(moduledir)\"" \
$(X11_CFLAGS)
lib_LTLIBRARIES = libvdpau.la
......
......@@ -22,6 +22,7 @@
*/
#include <dlfcn.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -46,7 +47,7 @@ static void _vdp_wrapper_error_breakpoint(char const * file, int line, char cons
#endif
#define DRIVER_LIB_FORMAT "libvdpau_%s.so"
#define DRIVER_LIB_FORMAT "%slibvdpau_%s.so%s"
VdpStatus vdp_device_create_x11(
Display * display,
......@@ -57,7 +58,7 @@ VdpStatus vdp_device_create_x11(
)
{
char const * vdpau_driver;
char * vdpau_driver_lib;
char vdpau_driver_lib[PATH_MAX];
void * backend_dll;
char const * vdpau_trace;
char const * func_name;
......@@ -70,15 +71,23 @@ VdpStatus vdp_device_create_x11(
vdpau_driver = "nvidia";
}
vdpau_driver_lib = malloc(strlen(DRIVER_LIB_FORMAT) + strlen(vdpau_driver) + 1);
if (!vdpau_driver_lib) {
if (snprintf(vdpau_driver_lib, sizeof(vdpau_driver_lib), DRIVER_LIB_FORMAT,
VDPAU_MODULEDIR "/", vdpau_driver, ".1") >=
sizeof(vdpau_driver_lib)) {
fprintf(stderr, "Failed to construct driver path: path too long\n");
_VDP_ERROR_BREAKPOINT();
return VDP_STATUS_RESOURCES;
return VDP_STATUS_NO_IMPLEMENTATION;
}
sprintf(vdpau_driver_lib, DRIVER_LIB_FORMAT, vdpau_driver);
backend_dll = dlopen(vdpau_driver_lib, RTLD_NOW | RTLD_GLOBAL);
free(vdpau_driver_lib);
if (!backend_dll) {
/* Try again using the old path, which is guaranteed to fit in PATH_MAX
* if the complete path fit above. */
snprintf(vdpau_driver_lib, sizeof(vdpau_driver_lib), DRIVER_LIB_FORMAT,
"", vdpau_driver, "");
backend_dll = dlopen(vdpau_driver_lib, RTLD_NOW | RTLD_GLOBAL);
}
if (!backend_dll) {
fprintf(stderr, "Failed to open VDPAU backend %s\n", dlerror());
_VDP_ERROR_BREAKPOINT();
......@@ -90,7 +99,7 @@ VdpStatus vdp_device_create_x11(
void * trace_dll;
SetDllHandle * set_dll_handle;
trace_dll = dlopen("libvdpau_trace.so", RTLD_NOW | RTLD_GLOBAL);
trace_dll = dlopen(VDPAU_MODULEDIR "/libvdpau_trace.so.1", RTLD_NOW | RTLD_GLOBAL);
if (!trace_dll) {
fprintf(stderr, "Failed to open VDPAU trace library %s\n", dlerror());
_VDP_ERROR_BREAKPOINT();
......@@ -134,4 +143,3 @@ VdpStatus vdp_device_create_x11(
get_proc_address
);
}
......@@ -2,7 +2,7 @@ AM_CXXFLAGS = \
-I$(top_srcdir)/include \
$(X11_CFLAGS)
lib_LTLIBRARIES = libvdpau_trace.la
module_LTLIBRARIES = libvdpau_trace.la
libvdpau_trace_la_SOURCES = \
vdpau_trace.cpp
......@@ -10,7 +10,7 @@ libvdpau_trace_la_SOURCES = \
libvdpau_trace_la_LIBADD = \
$(DLOPEN_LIBS)
libvdpau_trace_la_LDFLAGS = -avoid-version -module -no-undefined
libvdpau_trace_la_LDFLAGS = -version-info 1:0:0 -module -no-undefined
libvdpau_traceincludedir = $(includedir)/vdpau
libvdpau_traceinclude_HEADERS = \
......
......@@ -2,6 +2,7 @@ prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
moduledir=@moduledir@
Name: VDPAU
Description: The Video Decode and Presentation API for UNIX
......
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