Commit b11a35a1 authored by Aaron Plattner's avatar Aaron Plattner
Browse files

Initial commit.

parents
This diff is collapsed.
/*
* This source file is documented using Doxygen markup.
* See http://www.stack.nl/~dimitri/doxygen/
*/
/*
* This copyright notice applies to this header file:
*
* 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 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.
*/
/**
* \file vdpau_x11.h
* \brief X11 Window System Integration Layer
*
* This file contains the \ref api_winsys_x11 "X11 Window System
* Integration Layer".
*/
#ifndef _VDPAU_X11_H
#define _VDPAU_X11_H
#include <X11/Xlib.h>
#include "vdpau.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \ingroup api_winsys
* @{
*/
/**
* \defgroup api_winsys_x11 X11 Window System Integration Layer
*
* The set of VDPAU functionality specific to usage with the X
* Window System.
*
* \section Driver Library Layout
*
* An X11-oriented VDPAU installation consists of the following
* components:
*
* - Header files. These files are located in the standard
* system header file path.
* - \c vdpau/vdpau.h
* - \c vdpau/vdpau_x11.h
* - The VDPAU wrapper library. These files are located in the
* 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
* For example:
* - \c libvdpau_nvidia.so
* - \c libvdpau_intel.so
* - \c libvdpau_ati.so
*
* The VDPAU wrapper library implements just one function; \ref
* vdp_device_create_x11. The wrapper will implement this function
* by dynamically loading the appropriate back-end driver file
* mentioned above. Long-term, the wrapper will use a
* VDPAU-specific X extension to determine which back-end driver
* to load. Currently, the wrapper library hard-codes the driver
* name as "nvidia", although this can be overridden using the
* environment variable VDPAU_DRIVER.
*
* The back-end driver is expected to implement a function named
* \b vdp_imp_device_create_x11. The wrapper will call this function to
* actually implement the \ref vdp_device_create_x11 application call.
*
* Note that it is theoretically possible for an application to
* create multiple \ref VdpDevice "VdpDevice" objects. In this
* case, the wrapper library may load multiple back-end drivers
* into the same application, and/or invoke a specific back-end
* driver's \b VdpImpDeviceCreateX11 multiple times. The wrapper
* libray imposes no policy regarding whether the application
* may instantiate multiple \ref VdpDevice "VdpDevice" objects for
* the same display and/or screen. However, back-end drivers are
* free to limit the number of \ref VdpDevice "VdpDevice" objects
* as required by their implementation.
*
* @{
*/
/**
* \brief Create a VdpDevice object for use with X11.
* \param[in] display The X Display that the VdpDevice VdpDevice
* will operate against.
* \param[in] screen The X screen that the VdpDevice will operate
* against.
* \param[out] device The new device's handle.
* \param[out] get_proc_address The get_proc_address entry point
* to use with this device.
* \return VdpStatus The completion status of the operation.
*/
typedef VdpStatus VdpDeviceCreateX11(
Display * display,
int screen,
/* output parameters follow */
VdpDevice * device,
VdpGetProcAddress * * get_proc_address
);
/**
* \brief Create a VdpDevice object for use with X11.
* This is an actual symbol of type \ref VdpDeviceCreateX11
*
*/
VdpDeviceCreateX11 vdp_device_create_x11;
/**
* \brief Create a VdpPresentationQueueTarget for use with X11.
* \param[in] device The device that will contain the queue
* target.
* \param[in] drawable The X11 Drawable that the presentation
* queue will present into.
* \param[out] target The new queue target's handle.
* \return VdpStatus The completion status of the operation.
*
* Note: VDPAU expects to own the entire drawable for the duration of time
* that the presentation queue target exists. In particular,
* implementations may choose to manipulate client-visible X11 window state
* as required. As such, it is recommended that applications create a
* dedicated window for the presentation queue target, as a child
* (grand-child, ...) of their top-level application window.
*
* Applications may also create child-windows of the presentation queue
* target, which will cover any presented video in the normal fashion. VDPAU
* implementations will not manipulate such child windows in any fashion.
*/
typedef VdpStatus VdpPresentationQueueTargetCreateX11(
VdpDevice device,
Drawable drawable,
/* output parameters follow */
VdpPresentationQueueTarget * target
);
/** \hideinitializer */
#define VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11 (VdpFuncId)(VDP_FUNC_ID_BASE_WINSYS + 0)
/*@}*/
/*@}*/
#ifdef __cplusplus
}
#endif
#endif
/*
* 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 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.
*/
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../include/vdpau/vdpau_x11.h"
typedef void SetDllHandle(
void * driver_dll_handle
);
#if DEBUG
static void _vdp_wrapper_error_breakpoint(char const * file, int line, char const * function)
{
fprintf(stderr, "VDPAU wrapper: Error detected at %s:%d %s()\n", file, line, function);
}
#define _VDP_ERROR_BREAKPOINT() _vdp_wrapper_error_breakpoint(__FILE__, __LINE__, __FUNCTION__)
#else
#define _VDP_ERROR_BREAKPOINT()
#endif
#define DRIVER_LIB_FORMAT "libvdpau_%s.so"
VdpStatus vdp_device_create_x11(
Display * display,
int screen,
/* output parameters follow */
VdpDevice * device,
VdpGetProcAddress * * get_proc_address
)
{
char const * vdpau_driver;
char * vdpau_driver_lib;
void * backend_dll;
char const * vdpau_trace;
char const * func_name;
VdpDeviceCreateX11 * vdp_imp_device_create_x11;
/* FIXME: Determine driver name using an X extension */
vdpau_driver = getenv("VDPAU_DRIVER");
if (!vdpau_driver) {
vdpau_driver = "nvidia";
}
vdpau_driver_lib = malloc(strlen(DRIVER_LIB_FORMAT) + strlen(vdpau_driver) + 1);
if (!vdpau_driver_lib) {
_VDP_ERROR_BREAKPOINT();
return VDP_STATUS_RESOURCES;
}
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) {
_VDP_ERROR_BREAKPOINT();
return VDP_STATUS_NO_IMPLEMENTATION;
}
vdpau_trace = getenv("VDPAU_TRACE");
if (vdpau_trace && atoi(vdpau_trace)) {
void * trace_dll;
SetDllHandle * set_dll_handle;
trace_dll = dlopen("libvdpau_trace.so", RTLD_NOW | RTLD_GLOBAL);
if (!trace_dll) {
_VDP_ERROR_BREAKPOINT();
return VDP_STATUS_NO_IMPLEMENTATION;
}
set_dll_handle = (SetDllHandle*)dlsym(
trace_dll,
"vdp_trace_set_backend_handle"
);
if (!set_dll_handle) {
_VDP_ERROR_BREAKPOINT();
return VDP_STATUS_NO_IMPLEMENTATION;
}
set_dll_handle(backend_dll);
backend_dll = trace_dll;
func_name = "vdp_trace_device_create_x11";
}
else {
func_name = "vdp_imp_device_create_x11";
}
vdp_imp_device_create_x11 = (VdpDeviceCreateX11*)dlsym(
backend_dll,
func_name
);
if (!vdp_imp_device_create_x11) {
_VDP_ERROR_BREAKPOINT();
return VDP_STATUS_NO_IMPLEMENTATION;
}
return vdp_imp_device_create_x11(
display,
screen,
device,
get_proc_address
);
}
This diff is collapsed.
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