Commit bd592e38 authored by Austin Yuan's avatar Austin Yuan

Upload latest libVA library

    1. Upgrade VAAPI to version 0.30 which has encode support
    2. Incorporate Gwenole Beauchesne's patches 102, 103, 104. 105, 106, 107, 109 and part of 202
       (see http://www.splitted-desktop.com/~gbeauchesne/libva/patches/)
    3. DRI2 support
Signed-off-by: default avatarAustin Yuan <shengquan.yuan@intel.com>
parent 2e2e3bae
*~
Makefile.in
Makefile
......@@ -27,4 +27,3 @@ pkgconfigdir = @pkgconfigdir@
pkgconfig_DATA = libva.pc
EXTRA_DIST = libva.pc.in
......@@ -21,7 +21,7 @@
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
AC_PREREQ(2.57)
AC_INIT([libva], 0.29, [waldo.bastian@intel.com], libva)
AC_INIT([libva], 0.30, [waldo.bastian@intel.com], libva)
AC_CONFIG_SRCDIR([Makefile.am])
AM_INIT_AUTOMAKE([dist-bzip2])
......@@ -34,9 +34,24 @@ AC_PROG_CC
AC_HEADER_STDC
AC_SYS_LARGEFILE
PKG_CHECK_MODULES([libva_la], [libdrm])
PKG_CHECK_MODULES([X11], [x11])
PKG_CHECK_MODULES([XEXT],[xext])
PKG_CHECK_MODULES([DRM], [libdrm])
PKG_CHECK_MODULES(LIBDRM_DEPS, [libdrm])
# We only need the headers, we don't link against the DRM libraries
LIBVA_CFLAGS="$LIBDRM_DEPS_CFLAGS"
AC_SUBST(LIBVA_CFLAGS)
AC_SUBST(LIBVA_LIBS)
pkgconfigdir=${libdir}/pkgconfig
AC_SUBST(pkgconfigdir)
AC_OUTPUT([Makefile src/Makefile dummy_drv_video/Makefile test/Makefile libva.pc])
AC_OUTPUT([
Makefile
src/Makefile
src/X11/Makefile
dummy_drv_video/Makefile
test/Makefile
libva.pc
])
libva for Debian
----------------
This library implements the Video Acceleration (VA) API for Linux.
It will load a hardware dependendent video acceleration driver.
-- Waldo Bastian <waldo.bastian@intel.com> Mon, 18 Jun 2007 21:35:31 -0700
libva (0.24-1) unstable; urgency=low
* Updated to v0.24
* Display attributes added
* H264 parameter fixes
* Swapped vaGetConfigAttributes and vaQueryConfigAttributes
-- Waldo Bastian <waldo.bastian@intel.com> Thu, 20 Sep 2007 15:08:04 -0700
* Updated to v0.22
* VAImage and VASubpicture added
-- Waldo Bastian <waldo.bastian@intel.com> Fri, 07 Sep 2007 04:32:28 -0700
* Updated to v0.20
* Clean up & exporting DRI interface
-- Waldo Bastian <waldo.bastian@intel.com> Thu, 09 Aug 2007 11:49:43 -0700
* Add VA_INVALID_SURFACE
-- Waldo Bastian <waldo.bastian@intel.com> Wed, 11 Jul 2007 17:24:10 -0700
* Initial release of libva
-- Waldo Bastian <waldo.bastian@intel.com> Mon, 18 Jun 2007 21:35:31 -0700
Source: libva
Priority: extra
Maintainer: Waldo Bastian <waldo.bastian@intel.com>
Build-Depends: debhelper (>= 5),
autotools-dev,
libdrm-dev (>= 2.3.0),
mesa-common-dev,
x11proto-gl-dev,
x11proto-xext-dev,
libxext-dev,
pkg-config
Standards-Version: 3.7.2
Section: libs
Package: libva-dev
Section: libdevel
Architecture: any
Depends: libva1 (= ${binary:Version}),
libdrm-dev (>= 2.3.0),
pkg-config
Description: Video Acceleration (VA) API for Linux -- development files
The libva library implements the Video Acceleration (VA) API for Linux.
The library loads a hardware dependendent driver.
.
This package provides the development environment for libva.
Package: libva1
Section: libs
Architecture: any
Depends: libx11-6,
libxext6,
libdrm2 (>= 2.3.0)
Description: Video Acceleration (VA) API for Linux -- runtime
The libva library implements the Video Acceleration (VA) API for Linux.
The library loads a hardware dependendent driver.
This package was debianized by Waldo Bastian <waldo.bastian@intel.com> on
Mon, 18 Jun 2007 21:35:31 -0700.
It was downloaded from <url://example.com>
Upstream Author(s):
Waldo Bastian <waldo.bastian@intel.com>
Jonathan Bian <jonathan.bian@intel.com>
Copyright:
(C) Copyright IBM Corporation 2004
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, Inc.
Copyright 2007 Intel Corportation
License:
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.
The Debian packaging is (C) 2007, Intel Corporation and
is licensed under the GPL, see `/usr/share/common-licenses/GPL'.
# Please also look if there are files or directories which have a
# different copyright/license attached and list them here.
usr/bin
usr/sbin
libva-dev_0.24-1_i386.deb libdevel extra
libva1_0.24-1_i386.deb libs extra
debian/tmp/usr/include/va.h
debian/tmp/usr/include/va_x11.h
debian/tmp/usr/include/va_backend.h
debian/tmp/usr/include/va_dri.h
debian/tmp/usr/X11R6/lib/modules/dri/dummy_drv_video.*
debian/tmp/usr/lib/libva.la
debian/tmp/usr/lib/libva.so
debian/tmp/usr/lib/pkgconfig/libva.pc
shlibs:Depends=libc6 (>= 2.6-1)
debian/tmp/usr/lib/libva.so.*
debian/tmp/usr/bin/vainfo
shlibs:Depends=libc6 (>= 2.6-1), libx11-6, libxext6
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
CFLAGS = -Wall -g
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
CFLAGS += -O0
else
CFLAGS += -O2
endif
# shared library versions, option 1
#version=2.0.5
#major=2
# option 2, assuming the library is created as src/.libs/libfoo.so.2.0.5 or so
version=`ls src/.libs/lib*.so.* | \
awk '{if (match($$0,/[0-9]+\.[0-9]+\.[0-9]+$$/)) print substr($$0,RSTART)}'`
#major=`ls src/.libs/lib*.so.* | \
# awk '{if (match($$0,/\.so\.[0-9]+$$/)) print substr($$0,RSTART+4)}'`
config.status: configure
dh_testdir
# Add here commands to configure the package.
ifneq "$(wildcard /usr/share/misc/config.sub)" ""
cp -f /usr/share/misc/config.sub config.sub
endif
ifneq "$(wildcard /usr/share/misc/config.guess)" ""
cp -f /usr/share/misc/config.guess config.guess
endif
./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs"
build: build-stamp
build-stamp: config.status
dh_testdir
# Add here commands to compile the package.
$(MAKE)
touch $@
clean:
dh_testdir
dh_testroot
rm -f build-stamp
# Add here commands to clean up after the build process.
-$(MAKE) distclean
rm -f config.sub config.guess
dh_clean
install: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
# Add here commands to install the package into debian/tmp
$(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.
# Build architecture-dependent files here.
binary-arch: build install
dh_testdir
dh_testroot
dh_installchangelogs
dh_installdocs
dh_installexamples
dh_install
# dh_installmenu
# dh_installdebconf
# dh_installlogrotate
# dh_installemacsen
# dh_installpam
# dh_installmime
# dh_installinit
# dh_installcron
# dh_installinfo
dh_installman
dh_link
dh_strip
dh_compress
dh_fixperms
# dh_perl
# dh_python
# dh_makeshlibs
dh_installdeb
dh_shlibdeps
dh_gencontrol
dh_md5sums
dh_builddeb
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install
......@@ -21,10 +21,11 @@
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
dummy_drv_video_la_LTLIBRARIES = dummy_drv_video.la
dummy_drv_video_ladir = /usr/X11R6/lib/modules/dri
dummy_drv_video_ladir = /usr/lib/dri
dummy_drv_video_la_LDFLAGS = -module -avoid-version -no-undefined -Wl,--no-undefined
dummy_drv_video_la_LIBADD = ../src/libva.la
AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/../../include/external/ -I$(top_srcdir)/../../include/kmd
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
noinst_HEADERS = dummy_drv_video.h object_heap.h
......@@ -736,6 +736,12 @@ VAStatus dummy_CreateContext(
obj_context->picture_height = picture_height;
obj_context->num_render_targets = num_render_targets;
obj_context->render_targets = (VASurfaceID *) malloc(num_render_targets * sizeof(VASurfaceID));
if (obj_context->render_targets == NULL)
{
vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
return vaStatus;
}
for(i = 0; i < num_render_targets; i++)
{
if (NULL == SURFACE(render_targets[i]))
......@@ -1251,7 +1257,6 @@ VAStatus __vaDriverInit_0_29( VADriverContextP ctx )
ctx->vtable.vaCreateSubpicture = dummy_CreateSubpicture;
ctx->vtable.vaDestroySubpicture = dummy_DestroySubpicture;
ctx->vtable.vaSetSubpictureImage = dummy_SetSubpictureImage;
ctx->vtable.vaSetSubpicturePalette = dummy_SetSubpicturePalette;
ctx->vtable.vaSetSubpictureChromakey = dummy_SetSubpictureChromakey;
ctx->vtable.vaSetSubpictureGlobalAlpha = dummy_SetSubpictureGlobalAlpha;
ctx->vtable.vaAssociateSubpicture = dummy_AssociateSubpicture;
......
......@@ -27,6 +27,7 @@
#include "assert.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define ASSERT assert
......
......@@ -4,7 +4,7 @@ libdir=@libdir@
includedir=@includedir@
Name: libva
Description: Userspace Video Acceleration (VA) interface
Description: Userspace Video Acceleration (VA) core interface
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -lva
Cflags: -I${includedir}
......@@ -20,14 +20,29 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
INCLUDES = \
$(LIBVA_CFLAGS) \
-DIN_LIBVA
libva_la_LTLIBRARIES = libva.la
libva_ladir = $(libdir)
libva_la_LDFLAGS = -version-number 0:29:0 -no-undefined
libva_la_LIBADD = -ldl -lX11 -lXext -lXfixes -lXdamage
libva_la_LDFLAGS = -version-number 0:30:0 -no-undefined
libva_la_LIBADD = $(LIBVA_LIBS) -ldl -lX11 -lXext X11/libva_X11.la
CFLAGS = -ansi -O2
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
libva_la_SOURCES = va_dri.c va.c va_dristr.h
SUBDIRS = X11
libvaincludedir = ${includedir}
libvainclude_HEADERS = va.h va_x11.h va_dri.h va_backend.h
libva_la_SOURCES = va.c
EXTRA_DIST = ChangeLog TODO
libvaincludedir = ${includedir}/va
libvainclude_HEADERS = va.h va_backend.h
# INTEL CONFIDENTIAL
# Copyright 2007 Intel Corporation. All Rights Reserved.
#
# The source code contained or described herein and all documents related to
# the source code ("Material") are owned by Intel Corporation or its suppliers
# or licensors. Title to the Material remains with Intel Corporation or its
# suppliers and licensors. The Material may contain trade secrets and
# proprietary and confidential information of Intel Corporation and its
# suppliers and licensors, and is protected by worldwide copyright and trade
# secret laws and treaty provisions. No part of the Material may be used,
# copied, reproduced, modified, published, uploaded, posted, transmitted,
# distributed, or disclosed in any way without Intel's prior express written
# permission.
#
# No license under any patent, copyright, trade secret or other intellectual
# property right is granted to or conferred upon you by disclosure or delivery
# of the Materials, either expressly, by implication, inducement, estoppel or
# otherwise. Any license under such intellectual property rights must be
# express and approved by Intel in writing.
AM_CFLAGS = -DLINUX -DIN_LIBVA -I$(top_srcdir)/src $(DRM_CFLAGS)
noinst_LTLIBRARIES = libva_X11.la
libva_X11includedir = ${includedir}/va
libva_X11include_HEADERS = va_x11.h va_dri.h va_dri2.h
libva_X11_la_SOURCES = va_x11.c va_dri.c va_dri2.c
CFLAGS = -ansi -O2
/*
* Copyright © 2008 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Soft-
* ware"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, provided that the above copyright
* notice(s) and this permission notice appear in all copies of the Soft-
* ware and that both the above copyright notice(s) and this permission
* notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
* ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
* RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
* THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
* QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR-
* MANCE OF THIS SOFTWARE.
*
* Except as contained in this notice, the name of a copyright holder shall
* not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization of
* the copyright holder.
*
* Authors:
* Kristian Høgsberg (krh@redhat.com)
*/
#define NEED_REPLIES
#include <X11/Xlibint.h>
#include <X11/extensions/Xext.h>
#include <X11/extensions/extutil.h>
#include "xf86drm.h"
#include "va_dri2.h"
#include "va_dri2str.h"
#include "va_dri2tokens.h"
#ifndef DRI2DriverDRI
#define DRI2DriverDRI 0
#endif
static char va_dri2ExtensionName[] = DRI2_NAME;
static XExtensionInfo _va_dri2_info_data;
static XExtensionInfo *va_dri2Info = &_va_dri2_info_data;
static XEXT_GENERATE_CLOSE_DISPLAY (VA_DRI2CloseDisplay, va_dri2Info)
static /* const */ XExtensionHooks va_dri2ExtensionHooks = {
NULL, /* create_gc */
NULL, /* copy_gc */
NULL, /* flush_gc */
NULL, /* free_gc */
NULL, /* create_font */
NULL, /* free_font */
VA_DRI2CloseDisplay, /* close_display */
NULL, /* wire_to_event */
NULL, /* event_to_wire */
NULL, /* error */
NULL, /* error_string */
};
static XEXT_GENERATE_FIND_DISPLAY (DRI2FindDisplay, va_dri2Info,
va_dri2ExtensionName,
&va_dri2ExtensionHooks,
0, NULL)
Bool VA_DRI2QueryExtension(Display *dpy, int *eventBase, int *errorBase)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
if (XextHasExtension(info)) {
*eventBase = info->codes->first_event;
*errorBase = info->codes->first_error;
return True;
}
return False;
}
Bool VA_DRI2QueryVersion(Display *dpy, int *major, int *minor)
{
XExtDisplayInfo *info = DRI2FindDisplay (dpy);
xDRI2QueryVersionReply rep;
xDRI2QueryVersionReq *req;
XextCheckExtension (dpy, info, va_dri2ExtensionName, False);
LockDisplay(dpy);
GetReq(DRI2QueryVersion, req);
req->reqType = info->codes->major_opcode;
req->dri2ReqType = X_DRI2QueryVersion;
req->majorVersion = DRI2_MAJOR;
req->minorVersion = DRI2_MINOR;
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return False;
}
*major = rep.majorVersion;
*minor = rep.minorVersion;
UnlockDisplay(dpy);
SyncHandle();
return True;
}
Bool VA_DRI2Connect(Display *dpy, XID window,
char **driverName, char **deviceName)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
xDRI2ConnectReply rep;
xDRI2ConnectReq *req;
XextCheckExtension (dpy, info, va_dri2ExtensionName, False);
LockDisplay(dpy);
GetReq(DRI2Connect, req);
req->reqType = info->codes->major_opcode;
req->dri2ReqType = X_DRI2Connect;
req->window = window;
req->driverType = DRI2DriverDRI;
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return False;
}
if (rep.driverNameLength == 0 && rep.deviceNameLength == 0) {
UnlockDisplay(dpy);
SyncHandle();
return False;
}
*driverName = Xmalloc(rep.driverNameLength + 1);
if (*driverName == NULL) {
_XEatData(dpy,
((rep.driverNameLength + 3) & ~3) +
((rep.deviceNameLength + 3) & ~3));
UnlockDisplay(dpy);
SyncHandle();
return False;
}
_XReadPad(dpy, *driverName, rep.driverNameLength);
(*driverName)[rep.driverNameLength] = '\0';
*deviceName = Xmalloc(rep.deviceNameLength + 1);
if (*deviceName == NULL) {
Xfree(*driverName);
_XEatData(dpy, ((rep.deviceNameLength + 3) & ~3));
UnlockDisplay(dpy);
SyncHandle();
return False;
}
_XReadPad(dpy, *deviceName, rep.deviceNameLength);
(*deviceName)[rep.deviceNameLength] = '\0';
UnlockDisplay(dpy);
SyncHandle();
return True;
}
Bool VA_DRI2Authenticate(Display *dpy, XID window, drm_magic_t magic)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
xDRI2AuthenticateReq *req;
xDRI2AuthenticateReply rep;
XextCheckExtension (dpy, info, va_dri2ExtensionName, False);
LockDisplay(dpy);
GetReq(DRI2Authenticate, req);
req->reqType = info->codes->major_opcode;
req->dri2ReqType = X_DRI2Authenticate;
req->window = window;
req->magic = magic;
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return False;
}
UnlockDisplay(dpy);
SyncHandle();
return rep.authenticated;
}
void VA_DRI2CreateDrawable(Display *dpy, XID drawable)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
xDRI2CreateDrawableReq *req;
XextSimpleCheckExtension (dpy, info, va_dri2ExtensionName);
LockDisplay(dpy);
GetReq(DRI2CreateDrawable, req);
req->reqType = info->codes->major_opcode;
req->dri2ReqType = X_DRI2CreateDrawable;
req->drawable = drawable;
UnlockDisplay(dpy);
SyncHandle();
}
void VA_DRI2DestroyDrawable(Display *dpy, XID drawable)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
xDRI2DestroyDrawableReq *req;
XextSimpleCheckExtension (dpy, info, va_dri2ExtensionName);
XSync(dpy, False);
LockDisplay(dpy);
GetReq(DRI2DestroyDrawable, req);
req->reqType = info->codes->major_opcode;
req->dri2ReqType = X_DRI2DestroyDrawable;
req->drawable = drawable;
UnlockDisplay(dpy);
SyncHandle();
}
VA_DRI2Buffer *VA_DRI2GetBuffers(Display *dpy, XID drawable,
int *width, int *height,
unsigned int *attachments, int count,
int *outCount)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
xDRI2GetBuffersReply rep;
xDRI2GetBuffersReq *req;
VA_DRI2Buffer *buffers;
xDRI2Buffer repBuffer;
CARD32 *p;
int i;
XextCheckExtension (dpy, info, va_dri2ExtensionName, False);
LockDisplay(dpy);
GetReqExtra(DRI2GetBuffers, count * 4, req);
req->reqType = info->codes->major_opcode;
req->dri2ReqType = X_DRI2GetBuffers;
req->drawable = drawable;
req->count = count;
p = (CARD32 *) &req[1];
for (i = 0; i < count; i++)
p[i] = attachments[i];
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return NULL;
}
*width = rep.width;
*height = rep.height;
*outCount = rep.count;
buffers = Xmalloc(rep.count * sizeof buffers[0]);
if (buffers == NULL) {
_XEatData(dpy, rep.count * sizeof repBuffer);
UnlockDisplay(dpy);
SyncHandle();
return NULL;
}
for (i = 0; i < rep.count; i++) {
_XReadPad(dpy, (char *) &repBuffer, sizeof repBuffer);
buffers[i].attachment = repBuffer.attachment;
buffers[i].name = repBuffer.name;
buffers[i].pitch = repBuffer.pitch;
buffers[i].cpp = repBuffer.cpp;
buffers[i].flags = repBuffer.flags;
}
UnlockDisplay(dpy);
SyncHandle();
return buffers;
}
void VA_DRI2CopyRegion(Display *dpy, XID drawable, XserverRegion region,
CARD32 dest, CARD32 src)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
xDRI2CopyRegionReq *req;
xDRI2CopyRegionReply rep;
XextSimpleCheckExtension (dpy, info, va_dri2ExtensionName);
LockDisplay(dpy);
GetReq(DRI2CopyRegion, req);
req->reqType = info->codes->major_opcode;
req->dri2ReqType = X_DRI2CopyRegion;
req->drawable = drawable;
req->region = region;
req->dest = dest;
req->src = src;
_XReply(dpy, (xReply *)&rep, 0, xFalse);
UnlockDisplay(dpy);
SyncHandle();
}
/*
* Copyright © 2007,2008 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Soft-
* ware"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, provided that the above copyright
* notice(s) and this permission notice appear in all copies of the Soft-
* ware and that both the above copyright notice(s) and this permission
* notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
* ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
* RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
* THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
* QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR-
* MANCE OF THIS SOFTWARE.
*
* Except as contained in this notice, the name of a copyright holder shall
* not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization of
* the copyright holder.
*
* Authors:
* Kristian Høgsberg (krh@redhat.com)
*/
#ifndef _VA_DRI2_H_
#define _VA_DRI2_H_
#include <X11/extensions/Xfixes.h>
#include <X11/Xfuncproto.h>
#include <xf86drm.h>
typedef struct {
unsigned int attachment;
unsigned int name;
unsigned int pitch;
unsigned int cpp;
unsigned int flags;
} VA_DRI2Buffer;
extern Bool
VA_DRI2QueryExtension(Display *display, int *eventBase, int *errorBase);
extern Bool
VA_DRI2QueryVersion(Display *display, int *major, int *minor);
extern Bool
VA_DRI2Connect(Display *display, XID window,
char **driverName, char **deviceName);
extern Bool
VA_DRI2Authenticate(Display *display, XID window, drm_magic_t magic);
extern void
VA_DRI2CreateDrawable(Display *display, XID drawable);
extern void
VA_DRI2DestroyDrawable(Display *display, XID handle);
extern VA_DRI2Buffer *
VA_DRI2GetBuffers(Display *dpy, XID drawable,
int *width, int *height,
unsigned int *attachments, int count,
int *outCount);
#if 0
extern void
VA_DRI2CopyRegion(Display *dpy, XID drawable, XserverRegion region,
CARD32 dest, CARD32 src);
#endif
#endif
/*
* Copyright © 2008 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Soft-
* ware"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, provided that the above copyright
* notice(s) and this permission notice appear in all copies of the Soft-
* ware and that both the above copyright notice(s) and this permission
* notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
* ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
* RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
* THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
* QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR-
* MANCE OF THIS SOFTWARE.
*
* Except as contained in this notice, the name of a copyright holder shall
* not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization of
* the copyright holder.
*
* Authors:
* Kristian Høgsberg (krh@redhat.com)
*/
#ifndef _DRI2_PROTO_H_
#define _DRI2_PROTO_H_
#define DRI2_NAME "DRI2"
#define DRI2_MAJOR 1
#define DRI2_MINOR 0
#define DRI2NumberErrors 0
#define DRI2NumberEvents 0
#define DRI2NumberRequests 7
#define X_DRI2QueryVersion 0
#define X_DRI2Connect 1
#define X_DRI2Authenticate 2
#define X_DRI2CreateDrawable 3
#define X_DRI2DestroyDrawable 4
#define X_DRI2GetBuffers 5
#define X_DRI2CopyRegion 6
typedef struct {
CARD32 attachment B32;
CARD32 name B32;
CARD32 pitch B32;
CARD32 cpp B32;
CARD32 flags B32;
} xDRI2Buffer;
typedef struct {
CARD8 reqType;
CARD8 dri2ReqType;
CARD16 length B16;
CARD32 majorVersion B32;
CARD32 minorVersion B32;
} xDRI2QueryVersionReq;
#define sz_xDRI2QueryVersionReq 12
typedef struct {
BYTE type; /* X_Reply */
BYTE pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 majorVersion B32;
CARD32 minorVersion B32;
CARD32 pad2 B32;
CARD32 pad3 B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
} xDRI2QueryVersionReply;
#define sz_xDRI2QueryVersionReply 32
typedef struct {
CARD8 reqType;
CARD8 dri2ReqType;
CARD16 length B16;
CARD32 window B32;
CARD32 driverType B32;
} xDRI2ConnectReq;
#define sz_xDRI2ConnectReq 12
typedef struct {
BYTE type; /* X_Reply */
BYTE pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 driverNameLength B32;
CARD32 deviceNameLength B32;
CARD32 pad2 B32;
CARD32 pad3 B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
} xDRI2ConnectReply;
#define sz_xDRI2ConnectReply 32
typedef struct {
CARD8 reqType;
CARD8 dri2ReqType;
CARD16 length B16;
CARD32 window B32;
CARD32 magic B32;
} xDRI2AuthenticateReq;
#define sz_xDRI2AuthenticateReq 12
typedef struct {
BYTE type; /* X_Reply */
BYTE pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 authenticated B32;
CARD32 pad2 B32;
CARD32 pad3 B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
} xDRI2AuthenticateReply;
#define sz_xDRI2AuthenticateReply 32
typedef struct {
CARD8 reqType;
CARD8 dri2ReqType;
CARD16 length B16;
CARD32 drawable B32;
} xDRI2CreateDrawableReq;
#define sz_xDRI2CreateDrawableReq 8
typedef struct {
CARD8 reqType;
CARD8 dri2ReqType;
CARD16 length B16;
CARD32 drawable B32;
} xDRI2DestroyDrawableReq;
#define sz_xDRI2DestroyDrawableReq 8
typedef struct {
CARD8 reqType;
CARD8 dri2ReqType;
CARD16 length B16;
CARD32 drawable B32;
CARD32 count B32;
} xDRI2GetBuffersReq;
#define sz_xDRI2GetBuffersReq 12
typedef struct {
BYTE type; /* X_Reply */
BYTE pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 width B32;
CARD32 height B32;
CARD32 count B32;
CARD32 pad2 B32;
CARD32 pad3 B32;
CARD32 pad4 B32;
} xDRI2GetBuffersReply;
#define sz_xDRI2GetBuffersReply 32
typedef struct {
CARD8 reqType;
CARD8 dri2ReqType;
CARD16 length B16;
CARD32 drawable B32;
CARD32 region B32;
CARD32 dest B32;
CARD32 src B32;
} xDRI2CopyRegionReq;
#define sz_xDRI2CopyRegionReq 20
typedef struct {
BYTE type; /* X_Reply */
BYTE pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 pad2 B32;
CARD32 pad3 B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
CARD32 pad7 B32;
} xDRI2CopyRegionReply;
#define sz_xDRI2CopyRegionReply 32
#endif
/*
* Copyright © 2008 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Soft-
* ware"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, provided that the above copyright
* notice(s) and this permission notice appear in all copies of the Soft-
* ware and that both the above copyright notice(s) and this permission
* notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
* ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
* RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
* THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
* QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR-
* MANCE OF THIS SOFTWARE.
*
* Except as contained in this notice, the name of a copyright holder shall
* not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization of
* the copyright holder.
*
* Authors:
* Kristian Høgsberg (krh@redhat.com)
*/
#ifndef _DRI2_TOKENS_H_
#define _DRI2_TOKENS_H_
#define DRI2BufferFrontLeft 0
#define DRI2BufferBackLeft 1
#define DRI2BufferFrontRight 2
#define DRI2BufferBackRight 3
#define DRI2BufferDepth 4
#define DRI2BufferStencil 5
#define DRI2BufferAccum 6
#define DRI2BufferFakeFrontLeft 7
#define DRI2BufferFakeFrontRight 8
#define DRI2DriverDRI 0
#endif
/*
* Copyright (c) 2007 Intel Corporation. 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.
*/
#include "config.h"
#include "va.h"
#include "va_backend.h"
#include "va_x11.h"
#include "va_dri.h"
#include "va_dri2.h"
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
static VADisplayContextP pDisplayContexts = NULL;
static void va_errorMessage(const char *msg, ...)
{
va_list args;
fprintf(stderr, "libva error: ");
va_start(args, msg);
vfprintf(stderr, msg, args);
va_end(args);
}
static void va_infoMessage(const char *msg, ...)
{
va_list args;
fprintf(stderr, "libva: ");
va_start(args, msg);
vfprintf(stderr, msg, args);
va_end(args);
}
static int va_DisplayContextIsValid (
VADisplayContextP pDisplayContext
)
{
VADisplayContextP ctx = pDisplayContexts;
while (ctx)
{
if (ctx == pDisplayContext && pDisplayContext->pDriverContext)
return 1;
ctx = ctx->pNext;
}
return 0;
}
static void va_DisplayContextDestroy (
VADisplayContextP pDisplayContext
)
{
VADisplayContextP *ctx = &pDisplayContexts;
/* Throw away pDisplayContext */
while (*ctx)
{
if (*ctx == pDisplayContext)
{
*ctx = pDisplayContext->pNext;
pDisplayContext->pNext = NULL;
break;
}
ctx = &((*ctx)->pNext);
}
free(pDisplayContext->pDriverContext);
free(pDisplayContext);
}
static VAStatus va_DRI2GetDriverName (
VADisplayContextP pDisplayContext,
char **driver_name
)
{
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");
return VA_STATUS_ERROR_UNKNOWN;
}
if (!VA_DRI2QueryVersion(ctx->x11_dpy, &driver_major, &driver_minor)) {
va_errorMessage("VA_DRI2QueryVersion failed\n");
return VA_STATUS_ERROR_UNKNOWN;
}
if (!VA_DRI2Connect(ctx->x11_dpy, RootWindow(ctx->x11_dpy, ctx->x11_screen),
driver_name, &device_name)) {
va_infoMessage("DRI2 isn't enabled, fallback to DRI1\n");
return VA_STATUS_ERROR_UNKNOWN;
}
va_infoMessage("VA_DRI2Connect: %d.%d.%d %s (screen %d)\n",
driver_major, driver_minor, driver_patch, *driver_name, ctx->x11_screen);
ctx->dri2 = 1;
return VA_STATUS_SUCCESS;
}
static VAStatus va_DRIGetDriverName (
VADisplayContextP pDisplayContext,
char **driver_name
)
{
VADriverContextP ctx = pDisplayContext->pDriverContext;
VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
int eventBase, errorBase;
int direct_capable;
int driver_major;
int driver_minor;
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");
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;
}
static VAStatus va_DisplayContextGetDriverName (
VADisplayContextP pDisplayContext,
char **driver_name
)
{
VADriverContextP ctx = pDisplayContext->pDriverContext;
VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
int direct_capable;
int driver_major;
int driver_minor;
int driver_patch;
Bool result = True;
char *x_driver_name = NULL;
if (driver_name)
*driver_name = NULL;
vaStatus = va_DRI2GetDriverName(pDisplayContext, driver_name);
if (vaStatus != VA_STATUS_SUCCESS)
vaStatus = va_DRIGetDriverName(pDisplayContext, driver_name);
if ((vaStatus == VA_STATUS_SUCCESS)
&& geteuid() == getuid())
{
/* don't allow setuid apps to use LIBVA_DRIVER_NAME */
if (getenv("LIBVA_DRIVER_NAME"))
{
/* For easier debugging */
if (*driver_name)
XFree(*driver_name);
*driver_name = strdup(getenv("LIBVA_DRIVER_NAME"));
return VA_STATUS_SUCCESS;
}
}
return vaStatus;
}
int vaDisplayIsValid(VADisplay dpy)
{
VADisplayContextP tmp=NULL;
VADisplayContextP pDisplayContext = pDisplayContexts;
while (pDisplayContext)
{
if (pDisplayContext == (VADisplayContextP)dpy)
{
tmp = (VADisplay)pDisplayContext;
break;
}
pDisplayContext = pDisplayContext->pNext;
}
if (!tmp)
return 0;
return tmp->vaIsValid(pDisplayContext);
}
VADisplay vaGetDisplay (
Display *native_dpy /* implementation specific */
)
{
VADisplay dpy = NULL;
VADisplayContextP pDisplayContext = pDisplayContexts;
if (!native_dpy)
return NULL;
while (pDisplayContext)
{
if (pDisplayContext->pDriverContext &&
pDisplayContext->pDriverContext->x11_dpy == native_dpy)
{
dpy = (VADisplay)pDisplayContext;
break;
}
pDisplayContext = pDisplayContext->pNext;
}
if (!dpy)
{
/* create new entry */
VADriverContextP pDriverContext;
pDisplayContext = calloc(1, sizeof(*pDisplayContext));
pDriverContext = calloc(1, sizeof(*pDriverContext));
if (pDisplayContext && pDriverContext)
{
pDriverContext->old_pNext = (void *)(unsigned long)0xdeadbeef;
pDriverContext->x11_dpy = native_dpy;
pDisplayContext->pNext = pDisplayContexts;
pDisplayContext->pDriverContext = pDriverContext;
pDisplayContext->vaIsValid = va_DisplayContextIsValid;
pDisplayContext->vaDestroy = va_DisplayContextDestroy;
pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
pDisplayContexts = pDisplayContext;
dpy = (VADisplay)pDisplayContext;
}
else
{
if (pDisplayContext)
free(pDisplayContext);
if (pDriverContext)
free(pDriverContext);
}
}
return dpy;
}
/*
* Video Decode Acceleration API, X11 specific functions
*
* Rev. 0.15
* <jonathan.bian@intel.com>
*
* Revision History:
* rev 0.1 (12/10/06 Jonathan Bian) - Initial draft
* rev 0.11 (12/15/06 Jonathan Bian) - Fixed some errors
* rev 0.12 (02/05/07 Jonathan Bian) - Added VC-1 data structures
* rev 0.13 (02/28/07 Jonathan Bian) - Added GetDisplay()
* rev 0.14 (04/13/07 Jonathan Bian) - Fixed MPEG-2 PictureParameter struct, cleaned up a few funcs.
* rev 0.15 (04/20/07 Jonathan Bian) - Overhauled buffer management
*
*/
#ifndef _VA_X11_H_
#define _VA_X11_H_
#ifdef IN_LIBVA
#include "va.h"
#else
#include <va/va.h>
#endif
#include <X11/Xlib.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Returns a suitable VADisplay for VA API
*/
VADisplay vaGetDisplay (
Display *dpy
);
/*
* Output rendering
* Following is the rendering interface for X windows,
......@@ -31,21 +27,25 @@ extern "C" {
* color space conversion and scaling to the destination
* rectangle
*/
/* de-interlacing flags for vaPutSurface */
#define VA_FRAME_PICTURE 0x00000000
#define VA_TOP_FIELD 0x00000001
#define VA_BOTTOM_FIELD 0x00000002
/* de-interlace flags for vaPutSurface */
#define VA_FRAME_PICTURE 0x00000000
#define VA_TOP_FIELD 0x00000001
#define VA_BOTTOM_FIELD 0x00000002
/*
* clears the drawable with background color.
* for hardware overlay based implementation this flag
* can be used to turn off the overlay
*/
#define VA_CLEAR_DRAWABLE 0x00000008
#define VA_CLEAR_DRAWABLE 0x00000008
/* color space conversion flags for vaPutSurface */
#define VA_SRC_BT601 0x00000010
#define VA_SRC_BT709 0x00000020
VAStatus vaPutSurface (
VADisplay dpy,
VASurfaceID surface,
VASurfaceID surface,
Drawable draw, /* X Drawable */
short srcx,
short srcy,
......@@ -55,9 +55,9 @@ VAStatus vaPutSurface (
short desty,
unsigned short destw,
unsigned short desth,
VARectangle *cliprects, /* client supplied clip list */
VARectangle *cliprects, /* client supplied destination clip list */
unsigned int number_cliprects, /* number of clip rects in the clip list */
unsigned int flags /* de-interlacing flags */
unsigned int flags /* PutSurface flags */
);
#ifdef __cplusplus
......
This diff is collapsed.
This diff is collapsed.
......@@ -29,13 +29,19 @@
#ifndef _VA_BACKEND_H_
#define _VA_BACKEND_H_
#ifdef IN_LIBVA
#include "va.h"
#include "va_x11.h"
#include "X11/va_x11.h"
#else
#include <va/va.h>
#include <va/va_x11.h>
#endif
#include <stdlib.h>
typedef struct VADriverContext *VADriverContextP;
typedef struct VADisplayContext *VADisplayContextP;
struct VADriverVTable
{
......@@ -94,6 +100,12 @@ struct VADriverVTable
VASurfaceID *surfaces /* out */
);
VAStatus (*vaCreateSurfaceFromCIFrame) (
VADriverContextP ctx,
unsigned long frame_id,
VASurfaceID *surface /* out */
);
VAStatus (*vaDestroySurfaces) (
VADriverContextP ctx,
VASurfaceID *surface_list,
......@@ -291,17 +303,6 @@ struct VADriverVTable
VAImageID image
);
VAStatus (*vaSetSubpicturePalette) (
VADriverContextP ctx,
VASubpictureID subpicture,
/*
* pointer to an array holding the palette data. The size of the array is
* num_palette_entries * entry_bytes in size. The order of the components
* in the palette is described by the component_order in VASubpicture struct
*/
unsigned char *palette
);
VAStatus (*vaSetSubpictureChromakey) (
VADriverContextP ctx,
VASubpictureID subpicture,
......@@ -386,18 +387,32 @@ struct VADriverVTable
void **buffer, /* out */
unsigned int *stride /* out */
);
VAStatus (*vaDbgCreateSurfaceFromMrstV4L2Buf) (
VADriverContextP ctx,
unsigned int width,
unsigned int height,
unsigned int size,
unsigned int fourcc,
unsigned int luma_stride,
unsigned int chroma_u_stride,
unsigned int chroma_v_stride,
unsigned int luma_offset,
unsigned int chroma_u_offset,
unsigned int chroma_v_offset,
VASurfaceID *surface /* out */
);
};
struct VADriverContext
{
VADriverContextP pNext;
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;
......@@ -411,6 +426,25 @@ struct VADriverContext
void *handle; /* dlopen handle */
};
struct VADisplayContext
{
VADisplayContextP pNext;
VADriverContextP pDriverContext;
int (*vaIsValid) (
VADisplayContextP ctx
);
void (*vaDestroy) (
VADisplayContextP ctx
);
VAStatus (*vaGetDriverName) (
VADisplayContextP ctx,
char **driver_name
);
};
typedef VAStatus (*VADriverInit) (
VADriverContextP driver_context
);
......
......@@ -27,7 +27,7 @@ bin_PROGRAMS = vainfo
testdir = $(bindir)
AM_CFLAGS = -I$(top_srcdir)/../../include/external/ -I$(top_srcdir)/src
AM_CFLAGS = -I$(top_srcdir)/../../include/external/ -I$(top_srcdir)/src -DIN_LIBVA
TESTS = $(check_PROGRAMS)
......@@ -72,6 +72,7 @@ test_11_SOURCES = test_11.c
test_12_LDADD = $(TEST_LIBS)
test_12_SOURCES = test_12.c
EXTRA_DIST = test_common.c
valgrind: $(check_PROGRAMS)
for a in $(check_PROGRAMS); do \
......
......@@ -22,8 +22,7 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "va.h"
#include "X11/Xlib.h"
#include <va_x11.h>
#include "assert.h"
#include <stdarg.h>
......
......@@ -24,16 +24,13 @@
#define TEST_DESCRIPTION "Sample MPEG2 VLD Decoding"
#include <va_x11.h>
#include "test_common.c"
#include <X11/Xlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "va_x11.h"
void pre()
{
test_init();
......@@ -228,12 +225,10 @@ void test()
XMapWindow(dpy, win);
XSync(dpy, False);
#if 0
va_status = vaPutSurface(va_dpy, vaSurface, win,
0,0,surf_width,surf_height,
0,0,win_width,win_height,
NULL,0,0);
#endif
ASSERT( VA_STATUS_SUCCESS == va_status );
printf("press any key to exit\n");
......
......@@ -22,8 +22,7 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "va.h"
#include "X11/Xlib.h"
#include <va_x11.h>
#include "assert.h"
#include <stdarg.h>
......
......@@ -22,14 +22,51 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "va.h"
#include "X11/Xlib.h"
#include <X11/va_x11.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define CHECK_VASTATUS(va_status,func, ret) \
if (va_status != VA_STATUS_SUCCESS) { \
fprintf(stderr,"%s failed with error code %d (%s),exit\n",func, vaErrorStr(va_status)); \
exit(ret); \
}
static char * profile_string(VAProfile profile)
{
switch (profile) {
case VAProfileMPEG2Simple: return "VAProfileMPEG2Simple";
case VAProfileMPEG2Main: return "VAProfileMPEG2Main";
case VAProfileMPEG4Simple: return "VAProfileMPEG4Simple";
case VAProfileMPEG4AdvancedSimple: return "VAProfileMPEG4AdvancedSimple";
case VAProfileMPEG4Main: return "VAProfileMPEG4Main";
case VAProfileH264Baseline: return "VAProfileH264Baseline";
case VAProfileH264Main: return "VAProfileH264Main";
case VAProfileH264High: return "VAProfileH264High";
case VAProfileVC1Simple: return "VAProfileVC1Simple";
case VAProfileVC1Main: return "VAProfileVC1Main";
case VAProfileVC1Advanced: return "VAProfileVC1Advanced";
case VAProfileH263Baseline: return "VAProfileH263Baseline";
}
}
static char * entrypoint_string(VAEntrypoint entrypoint)
{
switch (entrypoint) {
case VAEntrypointVLD:return "VAEntrypointVLD";
case VAEntrypointIZZ:return "VAEntrypointIZZ";
case VAEntrypointIDCT:return "VAEntrypointIDCT";
case VAEntrypointMoComp:return "VAEntrypointMoComp";
case VAEntrypointDeblocking:return "VAEntrypointDeblocking";
case VAEntrypointEncSlice:return "VAEntrypointEncSlice";
}
}
int main(int argc, const char* argv[])
{
Display *dpy;
......@@ -38,14 +75,17 @@ int main(int argc, const char* argv[])
int major_version, minor_version;
const char *driver;
const char *display = getenv("DISPLAY");
const char *name = rindex(argv[0], '/');
const char *name = rindex(argv[0], '/');
VAProfile profile;
VAEntrypoint entrypoint, entrypoints[10];
int num_entrypoint;
if (name)
name++;
else
name = argv[0];
dpy = XOpenDisplay(NULL);
dpy = XOpenDisplay(":0.0");
if (NULL == dpy)
{
fprintf(stderr, "%s: Error, can't open display: '%s'\n", name, display ? display : "");
......@@ -60,16 +100,30 @@ int main(int argc, const char* argv[])
}
va_status = vaInitialize(va_dpy, &major_version, &minor_version);
if (VA_STATUS_SUCCESS != va_status )
{
fprintf(stderr, "%s: vaInitialize failed with error code %d (%s)\n",
name, va_status, vaErrorStr(va_status));
return 3;
}
CHECK_VASTATUS(va_status, "vaInitialize", 3);
printf("%s: VA API version: %d.%d\n", name, major_version, minor_version);
driver = vaQueryVendorString(va_dpy);
printf("%s: Driver version: %s\n", name, driver ? driver : "<unknown>");
printf("%s: Supported profile and entrypoints\n", name);
for (profile = VAProfileMPEG2Simple; profile <= VAProfileH263Baseline; profile++) {
char *profile_str;
va_status = vaQueryConfigEntrypoints(va_dpy, profile, entrypoints,
&num_entrypoint);
if (va_status == VA_STATUS_ERROR_UNSUPPORTED_PROFILE)
continue;
CHECK_VASTATUS(va_status, "vaQueryConfigEntrypoints", 4);
profile_str = profile_string(profile);
for (entrypoint = 0; entrypoint < num_entrypoint; entrypoint++)
printf(" %-32s: %s\n", profile_str, entrypoint_string(entrypoints[entrypoint]));
}
vaTerminate(va_dpy);
return 0;
}
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