From 37913cc85ef9f5126b1d67f0fe0c28d9b3641c43 Mon Sep 17 00:00:00 2001 From: "Graydon, Tracy" Date: Wed, 7 Nov 2012 19:39:18 -0800 Subject: [PATCH] Branching for 2.0alpha --- RELEASING | 66 --- autogen.sh | 6 - intel/.gitignore | 1 - intel/tests/.gitignore | 1 - intel/tests/gen4-3d.batch.sh | 21 +- intel/tests/gen5-3d.batch.sh | 21 +- intel/tests/gen6-3d.batch.sh | 21 +- intel/tests/gen7-2d-copy.batch.sh | 21 +- intel/tests/gen7-3d.batch.sh | 21 +- intel/tests/gm45-3d.batch.sh | 21 +- slp/Makefile.am | 22 - slp/drm_slp_bufmgr.c | 847 -------------------------------------- slp/drm_slp_bufmgr.h | 201 --------- slp/libdrm_slp.pc.in | 11 - slp/list.h | 131 ------ tests/auth.c | 137 ------ tests/lock.c | 263 ------------ tests/ttmtest/AUTHORS | 1 - tests/ttmtest/ChangeLog | 23 -- tests/ttmtest/Makefile.am | 1 - tests/ttmtest/NEWS | 0 tests/ttmtest/README | 0 tests/ttmtest/configure.ac | 33 -- tests/ttmtest/reconf | 2 - tests/ttmtest/src/Makefile.am | 8 - tests/ttmtest/src/ttmtest.c | 430 ------------------- tests/ttmtest/src/xf86dri.c | 603 --------------------------- tests/ttmtest/src/xf86dri.h | 116 ------ tests/ttmtest/src/xf86dristr.h | 390 ------------------ xf86mm.h | 198 --------- 30 files changed, 120 insertions(+), 3497 deletions(-) delete mode 100644 RELEASING delete mode 100755 autogen.sh delete mode 100644 intel/.gitignore delete mode 100644 intel/tests/.gitignore mode change 120000 => 100755 intel/tests/gen4-3d.batch.sh mode change 120000 => 100755 intel/tests/gen5-3d.batch.sh mode change 120000 => 100755 intel/tests/gen6-3d.batch.sh mode change 120000 => 100755 intel/tests/gen7-2d-copy.batch.sh mode change 120000 => 100755 intel/tests/gen7-3d.batch.sh mode change 120000 => 100755 intel/tests/gm45-3d.batch.sh delete mode 100644 slp/Makefile.am delete mode 100644 slp/drm_slp_bufmgr.c delete mode 100644 slp/drm_slp_bufmgr.h delete mode 100644 slp/libdrm_slp.pc.in delete mode 100644 slp/list.h delete mode 100644 tests/auth.c delete mode 100644 tests/lock.c delete mode 100644 tests/ttmtest/AUTHORS delete mode 100644 tests/ttmtest/ChangeLog delete mode 100644 tests/ttmtest/Makefile.am delete mode 100644 tests/ttmtest/NEWS delete mode 100644 tests/ttmtest/README delete mode 100644 tests/ttmtest/configure.ac delete mode 100755 tests/ttmtest/reconf delete mode 100644 tests/ttmtest/src/Makefile.am delete mode 100644 tests/ttmtest/src/ttmtest.c delete mode 100644 tests/ttmtest/src/xf86dri.c delete mode 100644 tests/ttmtest/src/xf86dri.h delete mode 100644 tests/ttmtest/src/xf86dristr.h delete mode 100644 xf86mm.h diff --git a/RELEASING b/RELEASING deleted file mode 100644 index 3f07146..0000000 --- a/RELEASING +++ /dev/null @@ -1,66 +0,0 @@ -The release criteria for libdrm is essentially "if you need a release, -make one". There is no designated release engineer or maintainer. -Anybody is free to make a release if there's a certain feature or bug -fix they need in a released version of libdrm. - -When new ioctl definitions are merged into drm-next, we will add -support to libdrm, at which point we typically create a new release. -However, this is up to whoever is driving the feature in question. - -Follow these steps to release a new version of libdrm: - - 1) Ensure that there are no local, uncommitted/unpushed - modifications. You're probably in a good state if both "git diff - HEAD" and "git log master..origin/master" give no output. - - 3) Bump the version number in configure.ac. We seem to have settled - for 2.4.x as the versioning scheme for libdrm, so just bump the - micro version. - - 4) Run autoconf and then re-run ./configure so the build system - picks up the new version number. - - 5) Verify that the code passes "make distcheck". libdrm is tricky - to distcheck since the test suite will need to become drm master. - This means that you need to run it outside X, that is, in text - mode (KMS or no KMS doesn't matter). - - Running "make distcheck" should result in no warnings or errors - and end with a message of the form: - - ============================================= - libdrm-X.Y.Z archives ready for distribution: - libdrm-X.Y.Z.tar.gz - libdrm-X.Y.Z.tar.bz2 - ============================================= - - Make sure that the version number reported by distcheck and in - the tarball names matches the number you bumped to in configure.ac. - - 6) Commit the configure.ac change and make an annotated tag for that - commit with the version number of the release as the name and a - message of "libdrm X.Y.Z". For example, for the 2.4.16 release - the command is: - - git tag -a 2.4.16 -m "libdrm 2.4.16" - - 7) Push the commit and tag by saying - - git push --tags origin master - - assuming the remote for the upstream libdrm repo is called origin. - - 6) Use the release.sh script from the xorg/util/modular repo to - upload the tarballs to the freedesktop.org download area and - create an annouce email template. The script takes three - arguments: a "section", the previous tag and the new tag we just - created. For 2.4.16 again, the command is: - - ../modular/release.sh libdrm 2.4.15 2.4.16 - - This copies the two tarballs to freedesktop.org and creates - libdrm-2.4.16.announce which has a detailed summary of the - changes, links to the tarballs, MD5 and SHA1 sums and pre-filled - out email headers. Fill out the blank between the email headers - and the list of changes with a brief message of what changed or - what prompted this release. Send out the email and you're done! diff --git a/autogen.sh b/autogen.sh deleted file mode 100755 index 3f190ba..0000000 --- a/autogen.sh +++ /dev/null @@ -1,6 +0,0 @@ -#! /bin/sh - -test -n "$srcdir" || srcdir=`dirname "$0"` -test -n "$srcdir" || srcdir=. -autoreconf --force --install --verbose "$srcdir" -test -n "$NOCONFIGURE" || "$srcdir/configure" --enable-maintainer-mode "$@" diff --git a/intel/.gitignore b/intel/.gitignore deleted file mode 100644 index 528b408..0000000 --- a/intel/.gitignore +++ /dev/null @@ -1 +0,0 @@ -test_decode diff --git a/intel/tests/.gitignore b/intel/tests/.gitignore deleted file mode 100644 index e9d01ec..0000000 --- a/intel/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*-new.txt diff --git a/intel/tests/gen4-3d.batch.sh b/intel/tests/gen4-3d.batch.sh deleted file mode 120000 index 796ca5f..0000000 --- a/intel/tests/gen4-3d.batch.sh +++ /dev/null @@ -1 +0,0 @@ -test-batch.sh \ No newline at end of file diff --git a/intel/tests/gen4-3d.batch.sh b/intel/tests/gen4-3d.batch.sh new file mode 100755 index 0000000..a94057f --- /dev/null +++ b/intel/tests/gen4-3d.batch.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +TEST_FILENAME=`echo "$0" | sed 's|.sh||'` +./test_decode $TEST_FILENAME + +ret=$? + +# pretty-print a diff showing what happened, and leave the dumped +# around for possibly moving over the ref. +if test $ret = 1; then + REF_FILENAME="$TEST_FILENAME-ref.txt" + NEW_FILENAME="$TEST_FILENAME-new.txt" + ./test_decode $TEST_FILENAME -dump > $NEW_FILENAME + if test $? = 0; then + echo "Differences:" + diff -u $REF_FILENAME $NEW_FILENAME + fi +fi + +exit $ret diff --git a/intel/tests/gen5-3d.batch.sh b/intel/tests/gen5-3d.batch.sh deleted file mode 120000 index 796ca5f..0000000 --- a/intel/tests/gen5-3d.batch.sh +++ /dev/null @@ -1 +0,0 @@ -test-batch.sh \ No newline at end of file diff --git a/intel/tests/gen5-3d.batch.sh b/intel/tests/gen5-3d.batch.sh new file mode 100755 index 0000000..a94057f --- /dev/null +++ b/intel/tests/gen5-3d.batch.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +TEST_FILENAME=`echo "$0" | sed 's|.sh||'` +./test_decode $TEST_FILENAME + +ret=$? + +# pretty-print a diff showing what happened, and leave the dumped +# around for possibly moving over the ref. +if test $ret = 1; then + REF_FILENAME="$TEST_FILENAME-ref.txt" + NEW_FILENAME="$TEST_FILENAME-new.txt" + ./test_decode $TEST_FILENAME -dump > $NEW_FILENAME + if test $? = 0; then + echo "Differences:" + diff -u $REF_FILENAME $NEW_FILENAME + fi +fi + +exit $ret diff --git a/intel/tests/gen6-3d.batch.sh b/intel/tests/gen6-3d.batch.sh deleted file mode 120000 index 796ca5f..0000000 --- a/intel/tests/gen6-3d.batch.sh +++ /dev/null @@ -1 +0,0 @@ -test-batch.sh \ No newline at end of file diff --git a/intel/tests/gen6-3d.batch.sh b/intel/tests/gen6-3d.batch.sh new file mode 100755 index 0000000..a94057f --- /dev/null +++ b/intel/tests/gen6-3d.batch.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +TEST_FILENAME=`echo "$0" | sed 's|.sh||'` +./test_decode $TEST_FILENAME + +ret=$? + +# pretty-print a diff showing what happened, and leave the dumped +# around for possibly moving over the ref. +if test $ret = 1; then + REF_FILENAME="$TEST_FILENAME-ref.txt" + NEW_FILENAME="$TEST_FILENAME-new.txt" + ./test_decode $TEST_FILENAME -dump > $NEW_FILENAME + if test $? = 0; then + echo "Differences:" + diff -u $REF_FILENAME $NEW_FILENAME + fi +fi + +exit $ret diff --git a/intel/tests/gen7-2d-copy.batch.sh b/intel/tests/gen7-2d-copy.batch.sh deleted file mode 120000 index 796ca5f..0000000 --- a/intel/tests/gen7-2d-copy.batch.sh +++ /dev/null @@ -1 +0,0 @@ -test-batch.sh \ No newline at end of file diff --git a/intel/tests/gen7-2d-copy.batch.sh b/intel/tests/gen7-2d-copy.batch.sh new file mode 100755 index 0000000..a94057f --- /dev/null +++ b/intel/tests/gen7-2d-copy.batch.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +TEST_FILENAME=`echo "$0" | sed 's|.sh||'` +./test_decode $TEST_FILENAME + +ret=$? + +# pretty-print a diff showing what happened, and leave the dumped +# around for possibly moving over the ref. +if test $ret = 1; then + REF_FILENAME="$TEST_FILENAME-ref.txt" + NEW_FILENAME="$TEST_FILENAME-new.txt" + ./test_decode $TEST_FILENAME -dump > $NEW_FILENAME + if test $? = 0; then + echo "Differences:" + diff -u $REF_FILENAME $NEW_FILENAME + fi +fi + +exit $ret diff --git a/intel/tests/gen7-3d.batch.sh b/intel/tests/gen7-3d.batch.sh deleted file mode 120000 index 796ca5f..0000000 --- a/intel/tests/gen7-3d.batch.sh +++ /dev/null @@ -1 +0,0 @@ -test-batch.sh \ No newline at end of file diff --git a/intel/tests/gen7-3d.batch.sh b/intel/tests/gen7-3d.batch.sh new file mode 100755 index 0000000..a94057f --- /dev/null +++ b/intel/tests/gen7-3d.batch.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +TEST_FILENAME=`echo "$0" | sed 's|.sh||'` +./test_decode $TEST_FILENAME + +ret=$? + +# pretty-print a diff showing what happened, and leave the dumped +# around for possibly moving over the ref. +if test $ret = 1; then + REF_FILENAME="$TEST_FILENAME-ref.txt" + NEW_FILENAME="$TEST_FILENAME-new.txt" + ./test_decode $TEST_FILENAME -dump > $NEW_FILENAME + if test $? = 0; then + echo "Differences:" + diff -u $REF_FILENAME $NEW_FILENAME + fi +fi + +exit $ret diff --git a/intel/tests/gm45-3d.batch.sh b/intel/tests/gm45-3d.batch.sh deleted file mode 120000 index 796ca5f..0000000 --- a/intel/tests/gm45-3d.batch.sh +++ /dev/null @@ -1 +0,0 @@ -test-batch.sh \ No newline at end of file diff --git a/intel/tests/gm45-3d.batch.sh b/intel/tests/gm45-3d.batch.sh new file mode 100755 index 0000000..a94057f --- /dev/null +++ b/intel/tests/gm45-3d.batch.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +TEST_FILENAME=`echo "$0" | sed 's|.sh||'` +./test_decode $TEST_FILENAME + +ret=$? + +# pretty-print a diff showing what happened, and leave the dumped +# around for possibly moving over the ref. +if test $ret = 1; then + REF_FILENAME="$TEST_FILENAME-ref.txt" + NEW_FILENAME="$TEST_FILENAME-new.txt" + ./test_decode $TEST_FILENAME -dump > $NEW_FILENAME + if test $? = 0; then + echo "Differences:" + diff -u $REF_FILENAME $NEW_FILENAME + fi +fi + +exit $ret diff --git a/slp/Makefile.am b/slp/Makefile.am deleted file mode 100644 index 132662b..0000000 --- a/slp/Makefile.am +++ /dev/null @@ -1,22 +0,0 @@ -SUBDIRS = . - -AM_CFLAGS = \ - $(WARN_CFLAGS) \ - -I$(top_srcdir) \ - -I$(top_srcdir)/slp \ - $(PTHREADSTUBS_CFLAGS) \ - -I$(top_srcdir)/include/drm - -libdrm_slp_la_LTLIBRARIES = libdrm_slp.la -libdrm_slp_ladir = $(libdir) -libdrm_slp_la_LDFLAGS = -version-number 1:0:0 -no-undefined -libdrm_slp_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@ @CLOCK_LIB@ -ldl - -libdrm_slp_la_SOURCES = \ - drm_slp_bufmgr.c \ - drm_slp_bufmgr.h - -libdrm_slpincludedir = ${includedir}/libdrm -libdrm_slpinclude_HEADERS = drm_slp_bufmgr.h - -pkgconfig_DATA = libdrm_slp.pc diff --git a/slp/drm_slp_bufmgr.c b/slp/drm_slp_bufmgr.c deleted file mode 100644 index f723ded..0000000 --- a/slp/drm_slp_bufmgr.c +++ /dev/null @@ -1,847 +0,0 @@ -/************************************************************************** - -xserver-xorg-video-sec - -Copyright 2011 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: SooChan Lim , Sangjin Lee - -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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "drm_slp_bufmgr.h" -#include "list.h" - -#define PREFIX_LIB "libdrm_slp_" -#define SUFFIX_LIB ".so" -#define DEFAULT_LIB PREFIX_LIB"default"SUFFIX_LIB - -#define NUM_TRY_LOCK 10 -#define SEM_NAME "pixmap_1" -#define SEM_DEBUG 0 - -#define DRM_RETURN_IF_FAIL(cond) {if (!(cond)) { fprintf (stderr, "[%s] : '%s' failed.\n", __FUNCTION__, #cond); return; }} -#define DRM_RETURN_VAL_IF_FAIL(cond, val) {if (!(cond)) { fprintf (stderr, "[%s] : '%s' failed.\n", __FUNCTION__, #cond); return val; }} - -#define MGR_IS_VALID(mgr) (mgr && \ - mgr->link.next && \ - mgr->link.next->prev == &mgr->link) -#define BO_IS_VALID(bo) (bo && \ - MGR_IS_VALID(bo->bufmgr) && \ - bo->list.next && \ - bo->list.next->prev == &bo->list) - -typedef struct{ - void* data; - - int is_valid; - drm_data_free free_func ; -}drm_slp_user_data; - -static struct list_head *gBufMgrs = NULL; - -static int -_sem_wait_wrapper(sem_t* sem) -{ - int res = 0; - int num_try = NUM_TRY_LOCK; - - do - { - res = sem_wait(sem); - num_try--; - } while((res == -1) && (errno == EINTR) && (num_try >= 0)); - - if(res == -1) - { - fprintf(stderr, - "[libdrm] error %s:%d(sem:%p, num_try:%d) PID:%04d\n", - __FUNCTION__, - __LINE__, - sem, - num_try, - getpid()); - return 0; - } -#if SEM_DEBUG - else - { - fprintf(stderr, - "[libdrm] LOCK >> %s:%d(sem:%p, num_try:%d) PID:%04d\n", - __FUNCTION__, - __LINE__, - sem, - num_try, - getpid()); - } -#endif - - return 1; -} - -static int -_sem_post_wrapper(sem_t* sem) -{ - int res = 0; - int num_try = NUM_TRY_LOCK; - - do - { - res = sem_post(sem); - num_try--; - - } while((res == -1) && (errno == EINTR) && (num_try >= 0)); - - if(res == -1) - { - fprintf(stderr, - "[libdrm] error %s:%d(sem:%p, num_try:%d) PID:%04d\n", - __FUNCTION__, - __LINE__, - sem, - num_try, - getpid()); - return 0; - } -#if SEM_DEBUG - else - { - fprintf(stderr, - "[libdrm] UNLOCK << %s:%d(sem:%p, num_try:%d) PID:%04d\n", - __FUNCTION__, - __LINE__, - sem, - num_try, - getpid()); - } -#endif - - return 1; -} - -static int -_sem_open(drm_slp_bufmgr bufmgr) -{ - bufmgr->semObj.handle = sem_open(SEM_NAME, O_CREAT, 0777, 1); - if(bufmgr->semObj.handle == SEM_FAILED) - { - fprintf(stderr, - "[libdrm] error %s:%d(name:%s) PID:%04d\n", - __FUNCTION__, - __LINE__, - SEM_NAME, - getpid()); - bufmgr->semObj.handle = NULL; - return 0; - } -#if SEM_DEBUG - else - { - fprintf(stderr, - "[libdrm] OPEN %s:%d(sem:%p) PID:%04d\n", - __FUNCTION__, - __LINE__, - bufmgr->semObj.handle, - getpid()); - } -#endif - - bufmgr->semObj.status = STATUS_UNLOCK; - - return 1; -} - -static int -_sem_close(drm_slp_bufmgr bufmgr) -{ - _sem_wait_wrapper(bufmgr->semObj.handle); - sem_unlink(SEM_NAME); - return 1; -} - -static int -_sem_lock(drm_slp_bufmgr bufmgr) -{ - if(bufmgr->semObj.status != STATUS_UNLOCK) return 0; - - if(!_sem_wait_wrapper(bufmgr->semObj.handle)) return 0; - bufmgr->semObj.status = STATUS_LOCK; - return 1; -} - -static int -_sem_unlock(drm_slp_bufmgr bufmgr) -{ - if(bufmgr->semObj.status != STATUS_LOCK) return 0; - - _sem_post_wrapper(bufmgr->semObj.handle); - bufmgr->semObj.status = STATUS_UNLOCK; - return 1; -} - -static drm_slp_bufmgr -_load_bufmgr(int fd, const char *file, void *arg) -{ - char path[PATH_MAX] = {0,}; - drm_slp_bufmgr bufmgr = NULL; - int (*bufmgr_init)(drm_slp_bufmgr bufmgr, int fd, void *arg); - void *module; - - snprintf(path, sizeof(path), BUFMGR_DIR "/%s", file); - - module = dlopen(path, RTLD_LAZY); - if (!module) { - fprintf(stderr, - "[libdrm] failed to load module: %s(%s)\n", - dlerror(), file); - return NULL; - } - - bufmgr_init = dlsym(module, "init_slp_bufmgr"); - if (!bufmgr_init) { - fprintf(stderr, - "[libdrm] failed to lookup init function: %s(%s)\n", - dlerror(), file); - return NULL; - } - - bufmgr = calloc(sizeof(struct _drm_slp_bufmgr), 1); - if(!bufmgr) - { - return NULL; - } - - if(!bufmgr_init(bufmgr, fd, arg)) - { - fprintf(stderr,"[libdrm] Fail to init module(%s)\n", file); - free(bufmgr); - bufmgr = NULL; - return NULL; - } - - fprintf(stderr,"[libdrm] Success to load module(%s)\n", file); - - return bufmgr; -} - -drm_slp_bufmgr -drm_slp_bufmgr_init(int fd, void *arg) -{ - drm_slp_bufmgr bufmgr = NULL; - const char *p = NULL; - - if (fd < 0) - return NULL; - - if(gBufMgrs == NULL) - { - gBufMgrs = malloc(sizeof(struct list_head)); - LIST_INITHEAD(gBufMgrs); - } - else - { - LIST_FOR_EACH_ENTRY(bufmgr, gBufMgrs, link) - { - if(bufmgr->drm_fd == fd) - { - bufmgr->ref_count++; - fprintf(stderr, "[libdrm] bufmgr ref: fd=%d, ref_count:%d\n", fd, bufmgr->ref_count); - return bufmgr; - } - } - bufmgr = NULL; - } - fprintf(stderr, "[libdrm] bufmgr init: fd=%d\n", fd); - - p = getenv ("SLP_BUFMGR_MODULE"); - if (p) - { - char file[PATH_MAX] = {0,}; - snprintf(file, sizeof(file), PREFIX_LIB"%s"SUFFIX_LIB, p); - bufmgr = _load_bufmgr (fd, file, arg); - } - - if (!bufmgr) - bufmgr = _load_bufmgr (fd, DEFAULT_LIB, arg); - - if (!bufmgr) - { - struct dirent **namelist; - int found = 0; - int n; - - n = scandir(BUFMGR_DIR, &namelist, 0, alphasort); - if (n < 0) - fprintf(stderr,"[libdrm] no files : %s\n", BUFMGR_DIR); - else - { - while(n--) - { - if (!found && strstr (namelist[n]->d_name, PREFIX_LIB)) - { - char *p = strstr (namelist[n]->d_name, SUFFIX_LIB); - if (!strcmp (p, SUFFIX_LIB)) - { - bufmgr = _load_bufmgr (fd, namelist[n]->d_name, arg); - if (bufmgr) - found = 1; - } - } - free(namelist[n]); - } - free(namelist); - } - } - - if (!bufmgr) - { - fprintf(stderr,"[libdrm] backend is NULL.\n"); - return NULL; - } - - if (pthread_mutex_init(&bufmgr->lock, NULL) != 0) - { - bufmgr->bufmgr_destroy(bufmgr); - free(bufmgr); - return NULL; - } - - bufmgr->ref_count = 1; - bufmgr->drm_fd = fd; - - LIST_INITHEAD(&bufmgr->bos); - LIST_ADD(&bufmgr->link, gBufMgrs); - - return bufmgr; -} - -void -drm_slp_bufmgr_destroy(drm_slp_bufmgr bufmgr) -{ - DRM_RETURN_IF_FAIL(MGR_IS_VALID(bufmgr)); - - fprintf(stderr, "[DRM] bufmgr destroy: bufmgr:%p, drm_fd:%d\n", - bufmgr, bufmgr->drm_fd); - - /*Check and Free bos*/ - if(!LIST_IS_EMPTY(&bufmgr->bos)) - { - drm_slp_bo bo, tmp; - - LIST_FOR_EACH_ENTRY_SAFE(bo, tmp, &bufmgr->bos, list) - { - fprintf(stderr, "[libdrm] Un-freed bo(%p, ref:%d) \n", bo, bo->ref_cnt); - bo->ref_cnt = 1; - drm_slp_bo_unref(bo); - } - } - - LIST_DEL(&bufmgr->link); - bufmgr->bufmgr_destroy(bufmgr); - - if(bufmgr->semObj.isOpened) - { - _sem_close(bufmgr); - } - - pthread_mutex_destroy(&bufmgr->lock); - free(bufmgr); -} - -int -drm_slp_bufmgr_lock(drm_slp_bufmgr bufmgr) -{ - DRM_RETURN_VAL_IF_FAIL(MGR_IS_VALID(bufmgr), 0); - - pthread_mutex_lock(&bufmgr->lock); - - if(bufmgr->bufmgr_lock) - { - int ret; - ret = bufmgr->bufmgr_lock(bufmgr); - pthread_mutex_unlock(&bufmgr->lock); - return ret; - } - - if(!bufmgr->semObj.isOpened) - { - if(_sem_open(bufmgr) != 1) - { - pthread_mutex_unlock(&bufmgr->lock); - return 0; - } - bufmgr->semObj.isOpened = 1; - } - - if(_sem_lock(bufmgr) != 1) - { - pthread_mutex_unlock(&bufmgr->lock); - return 0; - } - - pthread_mutex_unlock(&bufmgr->lock); - - return 1; -} - -int -drm_slp_bufmgr_unlock(drm_slp_bufmgr bufmgr) -{ - DRM_RETURN_VAL_IF_FAIL(MGR_IS_VALID(bufmgr), 0); - - pthread_mutex_lock(&bufmgr->lock); - - if(bufmgr->bufmgr_unlock) - { - int ret; - ret = bufmgr->bufmgr_unlock(bufmgr); - pthread_mutex_unlock(&bufmgr->lock); - return ret; - } - - if(_sem_unlock(bufmgr) != 1) - { - pthread_mutex_unlock(&bufmgr->lock); - return 0; - } - - pthread_mutex_unlock(&bufmgr->lock); - - return 1; -} - -int -drm_slp_bufmgr_cache_flush(drm_slp_bufmgr bufmgr, drm_slp_bo bo, int flags) -{ - int ret; - - DRM_RETURN_VAL_IF_FAIL(MGR_IS_VALID(bufmgr) || BO_IS_VALID(bo), 0); - - if (!bo) - flags |= DRM_SLP_CACHE_ALL; - - if (bo) - { - DRM_RETURN_VAL_IF_FAIL(BO_IS_VALID(bo), 0); - - if(!bo->bufmgr) - return 0; - - pthread_mutex_lock(&bo->bufmgr->lock); - ret = bo->bufmgr->bufmgr_cache_flush(bufmgr, bo, flags); - pthread_mutex_unlock(&bo->bufmgr->lock); - } - else - { - pthread_mutex_lock(&bufmgr->lock); - ret = bufmgr->bufmgr_cache_flush(bufmgr, NULL, flags); - pthread_mutex_unlock(&bufmgr->lock); - } - - return ret; -} - -int -drm_slp_bo_size(drm_slp_bo bo) -{ - int size; - drm_slp_bufmgr bufmgr; - - DRM_RETURN_VAL_IF_FAIL(BO_IS_VALID(bo), 0); - - bufmgr = bo->bufmgr; - - pthread_mutex_lock(&bufmgr->lock); - size = bo->bufmgr->bo_size(bo); - pthread_mutex_unlock(&bufmgr->lock); - - return size; -} - -drm_slp_bo -drm_slp_bo_ref(drm_slp_bo bo) -{ - drm_slp_bufmgr bufmgr; - - DRM_RETURN_VAL_IF_FAIL(BO_IS_VALID(bo), NULL); - - bufmgr = bo->bufmgr; - - pthread_mutex_lock(&bufmgr->lock); - - bo->ref_cnt++; - - pthread_mutex_unlock(&bufmgr->lock); - - return bo; -} - -void -drm_slp_bo_unref(drm_slp_bo bo) -{ - drm_slp_bufmgr bufmgr; - - DRM_RETURN_IF_FAIL(BO_IS_VALID(bo)); - - bufmgr = bo->bufmgr; - - if(0 >= bo->ref_cnt) - return; - - pthread_mutex_lock(&bufmgr->lock); - - bo->ref_cnt--; - if(bo->ref_cnt == 0) - { - if(bo->user_data) - { - void* rd; - drm_slp_user_data* old_data; - unsigned long key; - - while(1==drmSLFirst(bo->user_data, &key, &rd)) - { - old_data = (drm_slp_user_data*)rd; - - if(old_data->is_valid && old_data->free_func) - { - if(old_data->data) - old_data->free_func(old_data->data); - old_data->data = NULL; - free(old_data); - } - drmSLDelete(bo->user_data, key); - } - - drmSLDestroy(bo->user_data); - bo->user_data = (void*)0; - } - - LIST_DEL(&bo->list); - bufmgr->bo_free(bo); - - free(bo); - } - - pthread_mutex_unlock(&bufmgr->lock); -} - -drm_slp_bo -drm_slp_bo_alloc(drm_slp_bufmgr bufmgr, const char * name, int size, int flags) -{ - drm_slp_bo bo=NULL; - - DRM_RETURN_VAL_IF_FAIL( MGR_IS_VALID(bufmgr) && (size > 0), NULL); - - bo = calloc(sizeof(struct _drm_slp_bo), 1); - if(!bo) - return NULL; - - bo->bufmgr = bufmgr; - - pthread_mutex_lock(&bufmgr->lock); - if(!bufmgr->bo_alloc(bo, name, size, flags)) - { - free(bo); - pthread_mutex_unlock(&bufmgr->lock); - return NULL; - } - bo->ref_cnt = 1; - LIST_ADD(&bo->list, &bufmgr->bos); - pthread_mutex_unlock(&bufmgr->lock); - - return bo; -} - -drm_slp_bo -drm_slp_bo_attach(drm_slp_bufmgr bufmgr, - const char* name, - int type, - int size, - unsigned int handle) -{ - drm_slp_bo bo; - - DRM_RETURN_VAL_IF_FAIL(MGR_IS_VALID(bufmgr), NULL); - - bo = calloc(sizeof(struct _drm_slp_bo), 1); - if(!bo) - return NULL; - - bo->bufmgr = bufmgr; - - pthread_mutex_lock(&bufmgr->lock); - if(!bufmgr->bo_attach(bo, name, type, size, handle)) - { - free(bo); - pthread_mutex_unlock(&bufmgr->lock); - return NULL; - } - bo->ref_cnt = 1; - LIST_ADD(&bo->list, &bufmgr->bos); - pthread_mutex_unlock(&bufmgr->lock); - - return bo; -} - -drm_slp_bo -drm_slp_bo_import(drm_slp_bufmgr bufmgr, unsigned int key) -{ - drm_slp_bo bo; - - DRM_RETURN_VAL_IF_FAIL(MGR_IS_VALID(bufmgr), NULL); - - bo = calloc(sizeof(struct _drm_slp_bo), 1); - if(!bo) - return NULL; - - bo->bufmgr = bufmgr; - - pthread_mutex_lock(&bufmgr->lock); - if(!bufmgr->bo_import(bo, key)) - { - free(bo); - pthread_mutex_unlock(&bufmgr->lock); - return NULL; - } - bo->ref_cnt = 1; - LIST_ADD(&bo->list, &bufmgr->bos); - pthread_mutex_unlock(&bufmgr->lock); - - return bo; -} - -unsigned int -drm_slp_bo_export(drm_slp_bo bo) -{ - int ret; - - DRM_RETURN_VAL_IF_FAIL(BO_IS_VALID(bo), 0); - - pthread_mutex_lock(&bo->bufmgr->lock); - ret = bo->bufmgr->bo_export(bo); - pthread_mutex_unlock(&bo->bufmgr->lock); - - return ret; -} - -unsigned int -drm_slp_bo_get_handle(drm_slp_bo bo, int device) -{ - unsigned int ret; - - DRM_RETURN_VAL_IF_FAIL(BO_IS_VALID(bo), 0); - - pthread_mutex_lock(&bo->bufmgr->lock); - ret = bo->bufmgr->bo_get_handle(bo, device); - pthread_mutex_unlock(&bo->bufmgr->lock); - - return ret; -} - -unsigned int -drm_slp_bo_map(drm_slp_bo bo, int device, int opt) -{ - unsigned int ret; - - DRM_RETURN_VAL_IF_FAIL(BO_IS_VALID(bo), 0); - - pthread_mutex_lock(&bo->bufmgr->lock); - if(bo->bufmgr->bo_lock) - { - bo->bufmgr->bo_lock(bo, 0, (void*)0); - } - - ret = bo->bufmgr->bo_map(bo, device, opt); - pthread_mutex_unlock(&bo->bufmgr->lock); - - return ret; -} - -int -drm_slp_bo_unmap(drm_slp_bo bo, int device) -{ - int ret; - - DRM_RETURN_VAL_IF_FAIL(BO_IS_VALID(bo), 0); - - pthread_mutex_lock(&bo->bufmgr->lock); - ret = bo->bufmgr->bo_unmap(bo, device); - - if(bo->bufmgr->bo_unlock) - { - bo->bufmgr->bo_unlock(bo); - } - pthread_mutex_unlock(&bo->bufmgr->lock); - - return 0; -} - -int -drm_slp_bo_swap(drm_slp_bo bo1, drm_slp_bo bo2) -{ - void* temp; - - DRM_RETURN_VAL_IF_FAIL(BO_IS_VALID(bo1), 0); - DRM_RETURN_VAL_IF_FAIL(BO_IS_VALID(bo2), 0); - - if(bo1->bufmgr->bo_size(bo1) != bo2->bufmgr->bo_size(bo2)) - return 0; - - pthread_mutex_lock(&bo1->bufmgr->lock); - temp = bo1->priv; - bo1->priv = bo2->priv; - bo2->priv = temp; - pthread_mutex_unlock(&bo1->bufmgr->lock); - - return 1; -} - -int -drm_slp_bo_add_user_data(drm_slp_bo bo, unsigned long key, drm_data_free data_free_func) -{ - int ret; - drm_slp_user_data* data; - - DRM_RETURN_VAL_IF_FAIL(BO_IS_VALID(bo), 0); - - if(!bo->user_data) - bo->user_data = drmSLCreate(); - - data = calloc(1, sizeof(drm_slp_user_data)); - if(!data) - return 0; - - data->free_func = data_free_func; - data->data = (void*)0; - data->is_valid = 0; - - ret = drmSLInsert(bo->user_data, key, data); - if(ret == 1) /* Already in list */ - { - free(data); - return 0; - } - - return 1; -} - -int -drm_slp_bo_set_user_data(drm_slp_bo bo, unsigned long key, void* data) -{ - void *rd; - drm_slp_user_data* old_data; - - DRM_RETURN_VAL_IF_FAIL(BO_IS_VALID(bo), 0); - - if(!bo->user_data) - return 0; - - if(drmSLLookup(bo->user_data, key, &rd)) - return 0; - - old_data = (drm_slp_user_data*)rd; - if (!old_data) - return 0; - - if(old_data->is_valid) - { - if(old_data->free_func) - { - if(old_data->data) - old_data->free_func(old_data->data); - old_data->data = NULL; - } - } - else - old_data->is_valid = 1; - - old_data->data = data; - - return 1; -} - -int -drm_slp_bo_get_user_data(drm_slp_bo bo, unsigned long key, void** data) -{ - void *rd; - drm_slp_user_data* old_data; - - DRM_RETURN_VAL_IF_FAIL(BO_IS_VALID(bo) && data && bo->user_data, 0); - - if(drmSLLookup(bo->user_data, key, &rd)) - { - *data = NULL; - return 0; - } - - old_data = (drm_slp_user_data*)rd; - if (!old_data) - { - *data = NULL; - return 0; - } - - *data = old_data->data; - - return 1; -} - -int -drm_slp_bo_delete_user_data(drm_slp_bo bo, unsigned long key) -{ - void *rd; - drm_slp_user_data* old_data=(void*)0; - - DRM_RETURN_VAL_IF_FAIL(BO_IS_VALID(bo) && bo->user_data, 0); - - if(drmSLLookup(bo->user_data, key, &rd)) - return 0; - - old_data = (drm_slp_user_data*)rd; - if (!old_data) - return 0; - - if(old_data->is_valid && old_data->free_func) - { - if(old_data->data) - old_data->free_func(old_data->data); - free(old_data); - } - drmSLDelete(bo->user_data, key); - - return 1; -} diff --git a/slp/drm_slp_bufmgr.h b/slp/drm_slp_bufmgr.h deleted file mode 100644 index a4adef5..0000000 --- a/slp/drm_slp_bufmgr.h +++ /dev/null @@ -1,201 +0,0 @@ -/************************************************************************** - -xserver-xorg-video-sec - -Copyright 2011 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: SooChan Lim , Sangjin Lee - -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 _DRM_SLP_BUFMGR_H_ -#define _DRM_SLP_BUFMGR_H_ - -#include -#include -#include - -typedef struct _drm_slp_bo * drm_slp_bo; -typedef struct _drm_slp_bufmgr * drm_slp_bufmgr; - -struct list_head -{ - struct list_head *prev; - struct list_head *next; -}; - -struct _drm_slp_bo -{ - struct list_head list; - drm_slp_bufmgr bufmgr; - int ref_cnt; /*atomic count*/ - void *user_data; - - /* private data */ - void *priv; -}; - -typedef enum -{ - STATUS_UNLOCK, - STATUS_READY_TO_LOCK, - STATUS_LOCK, -} lock_status; - -struct _drm_slp_bufmgr -{ - struct list_head bos; /*list head of bo*/ - - pthread_mutex_t lock; - struct { - int isOpened; - lock_status status; - sem_t* handle; - } semObj; - - void (*bufmgr_destroy)(drm_slp_bufmgr bufmgr); - int (*bufmgr_cache_flush)(drm_slp_bufmgr bufmgr, drm_slp_bo bo, int flags); - - int (*bo_size)(drm_slp_bo bo); - - void (*bo_free)(drm_slp_bo bo); - int (*bo_alloc)(drm_slp_bo bo, - const char* name, - int size, - int flags); - int (*bo_attach)(drm_slp_bo bo, - const char* name, - int type, - int size, - unsigned int handle); - int (*bo_import)(drm_slp_bo bo, unsigned int key); - unsigned int (*bo_export)(drm_slp_bo bo); - - unsigned int (*bo_get_handle)(drm_slp_bo bo, int device); - unsigned int (*bo_map)(drm_slp_bo bo, int device, int opt); - int (*bo_unmap)(drm_slp_bo bo, int device); - - - /* Padding for future extension */ - int (*bufmgr_lock) (drm_slp_bufmgr bufmgr); - int (*bufmgr_unlock) (drm_slp_bufmgr bufmgr); - int (*bo_lock) (drm_slp_bo bo, unsigned int checkOnly, unsigned int* isLocked); - int (*bo_unlock) (drm_slp_bo bo); - void (*reserved5) (void); - void (*reserved6) (void); - - /* private data */ - void *priv; - - struct list_head link; /*link of bufmgr*/ - - int drm_fd; - int ref_count; -}; - -/* DRM_SLP_MEM_TYPE */ -#define DRM_SLP_MEM_GEM 0 -#define DRM_SLP_MEM_USERPTR 1 -#define DRM_SLP_MEM_DMABUF 2 -#define DRM_SLP_MEM_GPU 3 - -/* DRM_SLP_DEVICE_TYPE */ -#define DRM_SLP_DEVICE_DEFAULT 0 //Default handle -#define DRM_SLP_DEVICE_CPU 1 -#define DRM_SLP_DEVICE_2D 2 -#define DRM_SLP_DEVICE_3D 3 -#define DRM_SLP_DEVICE_MM 4 - -/* DRM_SLP_OPTION */ -#define DRM_SLP_OPTION_READ (1 << 0) -#define DRM_SLP_OPTION_WRITE (1 << 1) - -/* DRM_SLP_CACHE */ -#define DRM_SLP_CACHE_INV 0x01 -#define DRM_SLP_CACHE_CLN 0x02 -#define DRM_SLP_CACHE_ALL 0x10 -#define DRM_SLP_CACHE_FLUSH (DRM_SLP_CACHE_INV|DRM_SLP_CACHE_CLN) -#define DRM_SLP_CACHE_FLUSH_ALL (DRM_SLP_CACHE_FLUSH|DRM_SLP_CACHE_ALL) - -enum DRM_SLP_BO_FLAGS{ - DRM_SLP_BO_DEFAULT = 0, - DRM_SLP_BO_SCANOUT = (1<<0), - DRM_SLP_BO_NONCACHABLE = (1<<1), - DRM_SLP_BO_WC = (1<<2), -}; - -/* Functions for buffer mnager */ -drm_slp_bufmgr -drm_slp_bufmgr_init(int fd, void * arg); -void -drm_slp_bufmgr_destroy(drm_slp_bufmgr bufmgr); -int -drm_slp_bufmgr_lock(drm_slp_bufmgr bufmgr); -int -drm_slp_bufmgr_unlock(drm_slp_bufmgr bufmgr); -int -drm_slp_bufmgr_cache_flush(drm_slp_bufmgr bufmgr, drm_slp_bo bo, int flags); - - -/*Functions for bo*/ -int -drm_slp_bo_size (drm_slp_bo bo); -drm_slp_bo -drm_slp_bo_ref(drm_slp_bo bo); -void -drm_slp_bo_unref(drm_slp_bo bo); -drm_slp_bo -drm_slp_bo_alloc(drm_slp_bufmgr bufmgr, - const char* name, - int size, - int flags); -drm_slp_bo -drm_slp_bo_attach(drm_slp_bufmgr bufmgr, - const char* name, - int type, - int size, - unsigned int handle); -drm_slp_bo -drm_slp_bo_import(drm_slp_bufmgr bufmgr, unsigned int key); -unsigned int -drm_slp_bo_export(drm_slp_bo bo); -unsigned int -drm_slp_bo_get_handle(drm_slp_bo, int device); -unsigned int -drm_slp_bo_map(drm_slp_bo bo, int device, int opt); -int -drm_slp_bo_unmap(drm_slp_bo bo, int device); -int -drm_slp_bo_swap(drm_slp_bo bo1, drm_slp_bo bo2); - -/*Functions for userdata of bo*/ -typedef void (*drm_data_free)(void *); -int -drm_slp_bo_add_user_data(drm_slp_bo bo, unsigned long key, drm_data_free data_free_func); -int -drm_slp_bo_delete_user_data(drm_slp_bo bo, unsigned long key); -int -drm_slp_bo_set_user_data(drm_slp_bo bo, unsigned long key, void* data); -int -drm_slp_bo_get_user_data(drm_slp_bo bo, unsigned long key, void** data); -#endif /* _DRM_SLP_BUFMGR_H_ */ diff --git a/slp/libdrm_slp.pc.in b/slp/libdrm_slp.pc.in deleted file mode 100644 index 220d38b..0000000 --- a/slp/libdrm_slp.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: libdrm -Description: Userspace interface to kernel DRM services -Version: @PACKAGE_VERSION@ -Requires: libdrm -Libs: -L${libdir} -ldrm_slp -Cflags: -I${includedir} -I${includedir}/libdrm diff --git a/slp/list.h b/slp/list.h deleted file mode 100644 index e967b93..0000000 --- a/slp/list.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * - * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND. USA. - * 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 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 - * THE COPYRIGHT HOLDERS, AUTHORS 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 above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - */ - -/** - * \file - * List macros heavily inspired by the Linux kernel - * list handling. No list looping yet. - * - * Is not threadsafe, so common operations need to - * be protected using an external mutex. - */ -#ifndef _U_DOUBLE_LIST_H_ -#define _U_DOUBLE_LIST_H_ - -#include - -static void list_inithead(struct list_head *item) -{ - item->prev = item; - item->next = item; -} - -static inline void list_add(struct list_head *item, struct list_head *list) -{ - item->prev = list; - item->next = list->next; - list->next->prev = item; - list->next = item; -} - -static inline void list_addtail(struct list_head *item, struct list_head *list) -{ - item->next = list; - item->prev = list->prev; - list->prev->next = item; - list->prev = item; -} - -static inline void list_replace(struct list_head *from, struct list_head *to) -{ - to->prev = from->prev; - to->next = from->next; - from->next->prev = to; - from->prev->next = to; -} - -static inline void list_del(struct list_head *item) -{ - item->prev->next = item->next; - item->next->prev = item->prev; -} - -static inline void list_delinit(struct list_head *item) -{ - item->prev->next = item->next; - item->next->prev = item->prev; - item->next = item; - item->prev = item; -} - -#define LIST_INITHEAD(__item) list_inithead(__item) -#define LIST_ADD(__item, __list) list_add(__item, __list) -#define LIST_ADDTAIL(__item, __list) list_addtail(__item, __list) -#define LIST_REPLACE(__from, __to) list_replace(__from, __to) -#define LIST_DEL(__item) list_del(__item) -#define LIST_DELINIT(__item) list_delinit(__item) - -#define LIST_ENTRY(__type, __item, __field) \ - ((__type *)(((char *)(__item)) - offsetof(__type, __field))) - -#define LIST_IS_EMPTY(__list) \ - ((__list)->next == (__list)) - -#ifndef container_of -#define container_of(ptr, sample, member) \ - (void *)((char *)(ptr) \ - - ((char *)&(sample)->member - (char *)(sample))) -#endif - -#define LIST_FOR_EACH_ENTRY(pos, head, member) \ - for (pos = container_of((head)->next, pos, member); \ - &pos->member != (head); \ - pos = container_of(pos->member.next, pos, member)) - -#define LIST_FOR_EACH_ENTRY_SAFE(pos, storage, head, member) \ - for (pos = container_of((head)->next, pos, member), \ - storage = container_of(pos->member.next, pos, member); \ - &pos->member != (head); \ - pos = storage, storage = container_of(storage->member.next, storage, member)) - -#define LIST_FOR_EACH_ENTRY_SAFE_REV(pos, storage, head, member) \ - for (pos = container_of((head)->prev, pos, member), \ - storage = container_of(pos->member.prev, pos, member); \ - &pos->member != (head); \ - pos = storage, storage = container_of(storage->member.prev, storage, member)) - -#define LIST_FOR_EACH_ENTRY_FROM(pos, start, head, member) \ - for (pos = container_of((start), pos, member); \ - &pos->member != (head); \ - pos = container_of(pos->member.next, pos, member)) - -#define LIST_FOR_EACH_ENTRY_FROM_REV(pos, start, head, member) \ - for (pos = container_of((start), pos, member); \ - &pos->member != (head); \ - pos = container_of(pos->member.prev, pos, member)) - -#endif /*_U_DOUBLE_LIST_H_*/ diff --git a/tests/auth.c b/tests/auth.c deleted file mode 100644 index 9b6fca9..0000000 --- a/tests/auth.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright © 2007 Intel 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. - * - * Authors: - * Eric Anholt - * - */ - -#include -#include "drmtest.h" - -enum auth_event { - SERVER_READY, - CLIENT_MAGIC, - CLIENT_DONE, -}; - -int commfd[2]; - -static void wait_event(int pipe, enum auth_event expected_event) -{ - int ret; - enum auth_event event; - unsigned char in; - - ret = read(commfd[pipe], &in, 1); - if (ret == -1) - err(1, "read error"); - event = in; - - if (event != expected_event) - errx(1, "unexpected event: %d\n", event); -} - -static void -send_event(int pipe, enum auth_event send_event) -{ - int ret; - unsigned char event; - - event = send_event; - ret = write(commfd[pipe], &event, 1); - if (ret == -1) - err(1, "failed to send event %d", event); -} - -static void client() -{ - struct drm_auth auth; - int drmfd, ret; - - /* XXX: Should make sure we open the same DRM as the master */ - wait_event(0, SERVER_READY); - - drmfd = drm_open_any(); - - /* Get a client magic number and pass it to the master for auth. */ - auth.magic = 0; /* Quiet valgrind */ - ret = ioctl(drmfd, DRM_IOCTL_GET_MAGIC, &auth); - if (ret == -1) - err(1, "Couldn't get client magic"); - send_event(0, CLIENT_MAGIC); - ret = write(commfd[0], &auth.magic, sizeof(auth.magic)); - if (ret == -1) - err(1, "Couldn't write auth data"); - - /* Signal that the client is completely done. */ - send_event(0, CLIENT_DONE); -} - -static void server() -{ - int drmfd, ret; - struct drm_auth auth; - - drmfd = drm_open_any_master(); - - auth.magic = 0xd0d0d0d0; - ret = ioctl(drmfd, DRM_IOCTL_AUTH_MAGIC, &auth); - if (ret != -1 || errno != EINVAL) - errx(1, "Authenticating bad magic succeeded\n"); - - send_event(1, SERVER_READY); - - wait_event(1, CLIENT_MAGIC); - ret = read(commfd[1], &auth.magic, sizeof(auth.magic)); - if (ret == -1) - err(1, "Failure to read client magic"); - - ret = ioctl(drmfd, DRM_IOCTL_AUTH_MAGIC, &auth); - if (ret == -1) - err(1, "Failure to authenticate client magic\n"); - - wait_event(1, CLIENT_DONE); -} - -/** - * Checks DRM authentication mechanisms. - */ -int main(int argc, char **argv) -{ - int ret; - - ret = pipe(commfd); - if (ret == -1) - err(1, "Couldn't create pipe"); - - ret = fork(); - if (ret == -1) - err(1, "failure to fork client"); - if (ret == 0) - client(); - else - server(); - - return 0; -} - diff --git a/tests/lock.c b/tests/lock.c deleted file mode 100644 index 86caa28..0000000 --- a/tests/lock.c +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Copyright © 2007 Intel 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. - * - * Authors: - * Eric Anholt - * - */ - -/** @file lock.c - * Tests various potential failures of the DRM locking mechanisms - */ - -#include -#include "drmtest.h" - -enum auth_event { - SERVER_READY, - CLIENT_MAGIC, - SERVER_LOCKED, - CLIENT_LOCKED, -}; - -int commfd[2]; -unsigned int lock1 = 0x00001111; -unsigned int lock2 = 0x00002222; - -/* return time in milliseconds */ -static unsigned int -get_millis() -{ - struct timeval tv; - - gettimeofday(&tv, NULL); - return tv.tv_sec * 1000 + tv.tv_usec / 1000; -} - -static void -wait_event(int pipe, enum auth_event expected_event) -{ - int ret; - enum auth_event event; - unsigned char in; - - ret = read(commfd[pipe], &in, 1); - if (ret == -1) - err(1, "read error"); - event = in; - - if (event != expected_event) - errx(1, "unexpected event: %d\n", event); -} - -static void -send_event(int pipe, enum auth_event send_event) -{ - int ret; - unsigned char event; - - event = send_event; - ret = write(commfd[pipe], &event, 1); - if (ret == -1) - err(1, "failed to send event %d", event); -} - -static void -client_auth(int drmfd) -{ - struct drm_auth auth; - int ret; - - /* Get a client magic number and pass it to the master for auth. */ - ret = ioctl(drmfd, DRM_IOCTL_GET_MAGIC, &auth); - if (ret == -1) - err(1, "Couldn't get client magic"); - send_event(0, CLIENT_MAGIC); - ret = write(commfd[0], &auth.magic, sizeof(auth.magic)); - if (ret == -1) - err(1, "Couldn't write auth data"); -} - -static void -server_auth(int drmfd) -{ - struct drm_auth auth; - int ret; - - send_event(1, SERVER_READY); - wait_event(1, CLIENT_MAGIC); - ret = read(commfd[1], &auth.magic, sizeof(auth.magic)); - if (ret == -1) - err(1, "Failure to read client magic"); - - ret = ioctl(drmfd, DRM_IOCTL_AUTH_MAGIC, &auth); - if (ret == -1) - err(1, "Failure to authenticate client magic\n"); -} - -/** Tests that locking is successful in normal conditions */ -static void -test_lock_unlock(int drmfd) -{ - int ret; - - ret = drmGetLock(drmfd, lock1, 0); - if (ret != 0) - err(1, "Locking failed"); - ret = drmUnlock(drmfd, lock1); - if (ret != 0) - err(1, "Unlocking failed"); -} - -/** Tests that unlocking the lock while it's not held works correctly */ -static void -test_unlock_unlocked(int drmfd) -{ - int ret; - - ret = drmUnlock(drmfd, lock1); - if (ret == 0) - err(1, "Unlocking unlocked lock succeeded"); -} - -/** Tests that unlocking a lock held by another context fails appropriately */ -static void -test_unlock_unowned(int drmfd) -{ - int ret; - - ret = drmGetLock(drmfd, lock1, 0); - assert(ret == 0); - ret = drmUnlock(drmfd, lock2); - if (ret == 0) - errx(1, "Unlocking other context's lock succeeded"); - ret = drmUnlock(drmfd, lock1); - assert(ret == 0); -} - -/** - * Tests that an open/close by the same process doesn't result in the lock - * being dropped. - */ -static void test_open_close_locked(drmfd) -{ - int ret, tempfd; - - ret = drmGetLock(drmfd, lock1, 0); - assert(ret == 0); - /* XXX: Need to make sure that this is the same device as drmfd */ - tempfd = drm_open_any(); - close(tempfd); - ret = drmUnlock(drmfd, lock1); - if (ret != 0) - errx(1, "lock lost during open/close by same pid"); -} - -static void client() -{ - int drmfd, ret; - unsigned int time; - - wait_event(0, SERVER_READY); - - /* XXX: Should make sure we open the same DRM as the master */ - drmfd = drm_open_any(); - - client_auth(drmfd); - - /* Wait for the server to grab the lock, then grab it ourselves (to - * contest it). Hopefully we hit it within the window of when the - * server locks. - */ - wait_event(0, SERVER_LOCKED); - ret = drmGetLock(drmfd, lock2, 0); - time = get_millis(); - if (ret != 0) - err(1, "Failed to get lock on client\n"); - drmUnlock(drmfd, lock2); - - /* Tell the server that our locking completed, and when it did */ - send_event(0, CLIENT_LOCKED); - ret = write(commfd[0], &time, sizeof(time)); - - close(drmfd); - exit(0); -} - -static void server() -{ - int drmfd, tempfd, ret; - unsigned int client_time, unlock_time; - - drmfd = drm_open_any_master(); - - test_lock_unlock(drmfd); - test_unlock_unlocked(drmfd); - test_unlock_unowned(drmfd); - test_open_close_locked(drmfd); - - /* Perform the authentication sequence with the client. */ - server_auth(drmfd); - - /* Now, test that the client attempting to lock while the server - * holds the lock works correctly. - */ - ret = drmGetLock(drmfd, lock1, 0); - assert(ret == 0); - send_event(1, SERVER_LOCKED); - /* Wait a while for the client to do its thing */ - sleep(1); - ret = drmUnlock(drmfd, lock1); - assert(ret == 0); - unlock_time = get_millis(); - - wait_event(1, CLIENT_LOCKED); - ret = read(commfd[1], &client_time, sizeof(client_time)); - if (ret == -1) - err(1, "Failure to read client magic"); - - if (client_time < unlock_time) - errx(1, "Client took lock before server released it"); - - close(drmfd); -} - -int main(int argc, char **argv) -{ - int ret; - - - ret = pipe(commfd); - if (ret == -1) - err(1, "Couldn't create pipe"); - - ret = fork(); - if (ret == -1) - err(1, "failure to fork client"); - if (ret == 0) - client(); - else - server(); - - return 0; -} - diff --git a/tests/ttmtest/AUTHORS b/tests/ttmtest/AUTHORS deleted file mode 100644 index fa4a089..0000000 --- a/tests/ttmtest/AUTHORS +++ /dev/null @@ -1 +0,0 @@ -Thomas Hellström and others. diff --git a/tests/ttmtest/ChangeLog b/tests/ttmtest/ChangeLog deleted file mode 100644 index 4588c8d..0000000 --- a/tests/ttmtest/ChangeLog +++ /dev/null @@ -1,23 +0,0 @@ -2006-01-24 Thomas Hellström - - * configure.ac: - * src/ttmtest.c: - - Fixed include path. - -2006-01-24 Thomas Hellström - - * AUTHORS: - * Makefile.am: - * configure.ac: - * reconf: - * src/Makefile.am: - * src/ttmtest.c: (fastrdtsc), (time_diff), (releaseContext), - (testAGP), (main): - * src/xf86dri.c: (uniDRIDestroyContext), (uniDRICreateDrawable), - (uniDRIDestroyDrawable), (uniDRIGetDrawableInfo): - * src/xf86dri.h: - * src/xf86dristr.h: - - Initial import of the ttmtest utility. - \ No newline at end of file diff --git a/tests/ttmtest/Makefile.am b/tests/ttmtest/Makefile.am deleted file mode 100644 index af437a6..0000000 --- a/tests/ttmtest/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = src diff --git a/tests/ttmtest/NEWS b/tests/ttmtest/NEWS deleted file mode 100644 index e69de29..0000000 diff --git a/tests/ttmtest/README b/tests/ttmtest/README deleted file mode 100644 index e69de29..0000000 diff --git a/tests/ttmtest/configure.ac b/tests/ttmtest/configure.ac deleted file mode 100644 index c41e91a..0000000 --- a/tests/ttmtest/configure.ac +++ /dev/null @@ -1,33 +0,0 @@ -AC_INIT -AC_PROG_CC -AC_PATH_X -if test "x$no_x" != "xyes"; then - savecpp="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS -I$x_includes" - AC_CHECK_HEADER($x_includes/X11/Xlib.h,,\ - [AC_MSG_ERROR(Could not find X installation.)]) - CPPFLAGS="$savecpp" - MDRIINC="-I$x_includes" - LIBS="-L$x_libraries $LIBS" -else - AC_MSG_ERROR(Could not find X installation. Aborting.) -fi -AC_ARG_WITH(libdrm, - AC_HELP_STRING([--with-libdrm=DIR], - [Installation prefix of libdrm [[default=/usr]]]), - [libdrmpref="$withval"], - [libdrmpref="/usr"]) -savecpp="$CPPFLAGS" -MDRIINC="-I$libdrmpref/include -I$libdrmpref/include/drm -I$x_includes" -CPPFLAGS="$CPPFLAGS $MDRIINC" -AC_CHECK_HEADER(xf86drm.h,,\ - [AC_MSG_ERROR(Could not find libdrm installation. Use --with-libdrm=)]) -AC_CHECK_HEADER(drm.h,,\ - [AC_MSG_ERROR(Could not find libdrm installation. Use --with-libdrm=)]) -CPPFLAGS="$savecpp" -LIBS="-L$libdrmpref/lib64 -L$libdrmpref/lib $LIBS" -AC_SUBST(MDRIINC) -AC_SYS_LARGEFILE -AM_INIT_AUTOMAKE(minidri,0.1.0) -AM_CONFIG_HEADER(config.h) -AC_OUTPUT([Makefile src/Makefile]) diff --git a/tests/ttmtest/reconf b/tests/ttmtest/reconf deleted file mode 100755 index e64d00a..0000000 --- a/tests/ttmtest/reconf +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -autoreconf -v --install || exit 1 \ No newline at end of file diff --git a/tests/ttmtest/src/Makefile.am b/tests/ttmtest/src/Makefile.am deleted file mode 100644 index b7ee829..0000000 --- a/tests/ttmtest/src/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -INCLUDES = @MDRIINC@ -bin_PROGRAMS = ttmtest -ttmtest_SOURCES = \ - ttmtest.c \ - xf86dri.c \ - xf86dri.h \ - xf86dristr.h -ttmtest_LDADD = -ldrm -lXext -lX11 diff --git a/tests/ttmtest/src/ttmtest.c b/tests/ttmtest/src/ttmtest.c deleted file mode 100644 index 36df242..0000000 --- a/tests/ttmtest/src/ttmtest.c +++ /dev/null @@ -1,430 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, TX., USA - * 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 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 - * THE COPYRIGHT HOLDERS, AUTHORS 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 above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * - **************************************************************************/ -/* - * Authors: Thomas Hellström - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include -#include "xf86dri.h" -#include "xf86drm.h" -#include "stdio.h" -#include "sys/types.h" -#include -#include -#include -#include -#include "sys/mman.h" - -typedef struct -{ - enum - { - haveNothing, - haveDisplay, - haveConnection, - haveDriverName, - haveDeviceInfo, - haveDRM, - haveContext - } - state; - - Display *display; - int screen; - drm_handle_t sAreaOffset; - char *curBusID; - char *driverName; - int drmFD; - XVisualInfo visualInfo; - XID id; - drm_context_t hwContext; - void *driPriv; - int driPrivSize; - int fbSize; - int fbOrigin; - int fbStride; - drm_handle_t fbHandle; - int ddxDriverMajor; - int ddxDriverMinor; - int ddxDriverPatch; -} TinyDRIContext; - -#ifndef __x86_64__ -static unsigned -fastrdtsc(void) -{ - unsigned eax; - __asm__ volatile ("\t" - "pushl %%ebx\n\t" - "cpuid\n\t" ".byte 0x0f, 0x31\n\t" "popl %%ebx\n":"=a" (eax) - :"0"(0) - :"ecx", "edx", "cc"); - - return eax; -} -#else -static unsigned -fastrdtsc(void) -{ - unsigned eax; - __asm__ volatile ("\t" "cpuid\n\t" ".byte 0x0f, 0x31\n\t":"=a" (eax) - :"0"(0) - :"ecx", "edx", "ebx", "cc"); - - return eax; -} -#endif - -void -bmError(int val, const char *file, const char *function, int line) -{ - fprintf(stderr, "Fatal video memory manager error \"%s\".\n" - "Check kernel logs or set the LIBGL_DEBUG\n" - "environment variable to \"verbose\" for more info.\n" - "Detected in file %s, line %d, function %s.\n", - strerror(-val), file, line, function); - abort(); -} - -#define BM_CKFATAL(val) \ - do{ \ - int tstVal = (val); \ - if (tstVal) \ - bmError(tstVal, __FILE__, __FUNCTION__, __LINE__); \ - } while(0); - -static unsigned -time_diff(unsigned t, unsigned t2) -{ - return ((t < t2) ? t2 - t : 0xFFFFFFFFU - (t - t2 - 1)); -} - -static int -releaseContext(TinyDRIContext * ctx) -{ - switch (ctx->state) { - case haveContext: - uniDRIDestroyContext(ctx->display, ctx->screen, ctx->id); - case haveDRM: - drmClose(ctx->drmFD); - case haveDeviceInfo: - XFree(ctx->driPriv); - case haveDriverName: - XFree(ctx->driverName); - case haveConnection: - XFree(ctx->curBusID); - uniDRICloseConnection(ctx->display, ctx->screen); - case haveDisplay: - XCloseDisplay(ctx->display); - default: - break; - } - return -1; -} - -static void -readBuf(void *buf, unsigned long size) -{ - volatile unsigned *buf32 = (unsigned *)buf; - unsigned *end = (unsigned *)buf32 + size / sizeof(*buf32); - - while (buf32 < end) { - (void)*buf32++; - } -} - -static int -benchmarkBuffer(TinyDRIContext * ctx, unsigned long size, - unsigned long *ticks) -{ - unsigned long curTime, oldTime; - int ret; - drmBO buf; - void *virtual; - - /* - * Test system memory objects. - */ - oldTime = fastrdtsc(); - BM_CKFATAL(drmBOCreate(ctx->drmFD, size, 0, NULL, - DRM_BO_FLAG_READ | - DRM_BO_FLAG_WRITE | - DRM_BO_FLAG_MEM_LOCAL, 0, &buf)); - curTime = fastrdtsc(); - *ticks++ = time_diff(oldTime, curTime); - - oldTime = fastrdtsc(); - BM_CKFATAL(drmBOMap(ctx->drmFD, &buf, - DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0, &virtual)); - curTime = fastrdtsc(); - *ticks++ = time_diff(oldTime, curTime); - - oldTime = fastrdtsc(); - memset(virtual, 0xF0, buf.size); - curTime = fastrdtsc(); - *ticks++ = time_diff(oldTime, curTime); - - oldTime = fastrdtsc(); - memset(virtual, 0x0F, buf.size); - curTime = fastrdtsc(); - *ticks++ = time_diff(oldTime, curTime); - - oldTime = fastrdtsc(); - readBuf(virtual, buf.size); - curTime = fastrdtsc(); - *ticks++ = time_diff(oldTime, curTime); - - oldTime = fastrdtsc(); - BM_CKFATAL(drmBOUnmap(ctx->drmFD, &buf)); - curTime = fastrdtsc(); - *ticks++ = time_diff(oldTime, curTime); - - /* - * Test TT bound buffer objects. - */ - - oldTime = fastrdtsc(); - BM_CKFATAL(drmBOSetStatus(ctx->drmFD, &buf, - DRM_BO_FLAG_MEM_TT, - DRM_BO_MASK_MEM, - 0,0,0)); - curTime = fastrdtsc(); - *ticks++ = time_diff(oldTime, curTime); - - oldTime = fastrdtsc(); - BM_CKFATAL(drmBOMap(ctx->drmFD, &buf, - DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0, &virtual)); - curTime = fastrdtsc(); - *ticks++ = time_diff(oldTime, curTime); - - oldTime = fastrdtsc(); - memset(virtual, 0xF0, buf.size); - curTime = fastrdtsc(); - *ticks++ = time_diff(oldTime, curTime); - - oldTime = fastrdtsc(); - memset(virtual, 0x0F, buf.size); - curTime = fastrdtsc(); - *ticks++ = time_diff(oldTime, curTime); - - oldTime = fastrdtsc(); - readBuf(virtual, buf.size); - curTime = fastrdtsc(); - *ticks++ = time_diff(oldTime, curTime); - - BM_CKFATAL(drmBOUnmap(ctx->drmFD, &buf)); - - oldTime = fastrdtsc(); - BM_CKFATAL(drmBOSetStatus(ctx->drmFD, &buf, - DRM_BO_FLAG_MEM_LOCAL, DRM_BO_MASK_MEM, 0, 0,0)); - curTime = fastrdtsc(); - *ticks++ = time_diff(oldTime, curTime); - - /* - * Test cached buffers objects. - */ - - oldTime = fastrdtsc(); - ret = drmBOSetStatus(ctx->drmFD, &buf, - DRM_BO_FLAG_MEM_TT | - DRM_BO_FLAG_CACHED | - DRM_BO_FLAG_FORCE_CACHING, - DRM_BO_MASK_MEMTYPE | - DRM_BO_FLAG_FORCE_CACHING, - 0, 0, 0); - curTime = fastrdtsc(); - - if (ret) { - printf("Couldn't bind cached. Probably no support\n"); - BM_CKFATAL(drmBOUnreference(ctx->drmFD, &buf)); - return 1; - } - *ticks++ = time_diff(oldTime, curTime); - - oldTime = fastrdtsc(); - BM_CKFATAL(drmBOMap(ctx->drmFD, &buf, - DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0, &virtual)); - - curTime = fastrdtsc(); - *ticks++ = time_diff(oldTime, curTime); - - oldTime = fastrdtsc(); - memset(virtual, 0xF0, buf.size); - curTime = fastrdtsc(); - *ticks++ = time_diff(oldTime, curTime); - - oldTime = fastrdtsc(); - memset(virtual, 0x0F, buf.size); - curTime = fastrdtsc(); - *ticks++ = time_diff(oldTime, curTime); - - oldTime = fastrdtsc(); - readBuf(virtual, buf.size); - curTime = fastrdtsc(); - *ticks++ = time_diff(oldTime, curTime); - - BM_CKFATAL(drmBOUnmap(ctx->drmFD, &buf)); - BM_CKFATAL(drmBOUnreference(ctx->drmFD, &buf)); - - return 0; -} - -static void -testAGP(TinyDRIContext * ctx) -{ - unsigned long ticks[128], *pTicks; - unsigned long size = 8 * 1024; - int ret; - - ret = benchmarkBuffer(ctx, size, ticks); - if (ret < 0) { - fprintf(stderr, "Buffer error %s\n", strerror(-ret)); - return; - } - pTicks = ticks; - - printf("Buffer size %d bytes\n", size); - printf("System memory timings ********************************\n"); - printf("Creation took %12lu ticks\n", *pTicks++); - printf("Mapping took %12lu ticks\n", *pTicks++); - printf("Writing took %12lu ticks\n", *pTicks++); - printf("Writing Again took %12lu ticks\n", *pTicks++); - printf("Reading took %12lu ticks\n", *pTicks++); - printf("Unmapping took %12lu ticks\n", *pTicks++); - - printf("\nTT Memory timings ************************************\n"); - printf("Moving to TT took %12lu ticks\n", *pTicks++); - printf("Mapping in TT took %12lu ticks\n", *pTicks++); - printf("Writing to TT took %12lu ticks\n", *pTicks++); - printf("Writing again to TT took %12lu ticks\n", *pTicks++); - printf("Reading from TT took %12lu ticks\n", *pTicks++); - printf("Moving to system took %12lu ticks\n", *pTicks++); - - if (ret == 1) - return; - - printf("\nCached TT Memory timings *****************************\n"); - printf("Moving to CTT took %12lu ticks\n", *pTicks++); - printf("Mapping in CTT took %12lu ticks\n", *pTicks++); - printf("Writing to CTT took %12lu ticks\n", *pTicks++); - printf("Re-writing to CTT took %12lu ticks\n", *pTicks++); - printf("Reading from CTT took %12lu ticks\n", *pTicks++); - printf("\n\n"); -} - -int -main() -{ - int ret, screen, isCapable; - char *displayName = ":0"; - TinyDRIContext ctx; - unsigned magic; - - ctx.screen = 0; - ctx.state = haveNothing; - ctx.display = XOpenDisplay(displayName); - if (!ctx.display) { - fprintf(stderr, "Could not open display\n"); - return releaseContext(&ctx); - } - ctx.state = haveDisplay; - - ret = - uniDRIQueryDirectRenderingCapable(ctx.display, ctx.screen, - &isCapable); - if (!ret || !isCapable) { - fprintf(stderr, "No DRI on this display:sceen\n"); - return releaseContext(&ctx); - } - - if (!uniDRIOpenConnection(ctx.display, ctx.screen, &ctx.sAreaOffset, - &ctx.curBusID)) { - fprintf(stderr, "Could not open DRI connection.\n"); - return releaseContext(&ctx); - } - ctx.state = haveConnection; - - if (!uniDRIGetClientDriverName(ctx.display, ctx.screen, - &ctx.ddxDriverMajor, &ctx.ddxDriverMinor, - &ctx.ddxDriverPatch, &ctx.driverName)) { - fprintf(stderr, "Could not get DRI driver name.\n"); - return releaseContext(&ctx); - } - ctx.state = haveDriverName; - - if (!uniDRIGetDeviceInfo(ctx.display, ctx.screen, - &ctx.fbHandle, &ctx.fbOrigin, &ctx.fbSize, - &ctx.fbStride, &ctx.driPrivSize, &ctx.driPriv)) { - fprintf(stderr, "Could not get DRI device info.\n"); - return releaseContext(&ctx); - } - ctx.state = haveDriverName; - - if ((ctx.drmFD = drmOpen(NULL, ctx.curBusID)) < 0) { - perror("DRM Device could not be opened"); - return releaseContext(&ctx); - } - ctx.state = haveDRM; - - drmGetMagic(ctx.drmFD, &magic); - if (!uniDRIAuthConnection(ctx.display, ctx.screen, magic)) { - fprintf(stderr, "Could not get X server to authenticate us.\n"); - return releaseContext(&ctx); - } - - ret = XMatchVisualInfo(ctx.display, ctx.screen, 24, TrueColor, - &ctx.visualInfo); - if (!ret) { - ret = XMatchVisualInfo(ctx.display, ctx.screen, 16, TrueColor, - &ctx.visualInfo); - if (!ret) { - fprintf(stderr, "Could not find a matching visual.\n"); - return releaseContext(&ctx); - } - } - - if (!uniDRICreateContext(ctx.display, ctx.screen, ctx.visualInfo.visual, - &ctx.id, &ctx.hwContext)) { - fprintf(stderr, "Could not create DRI context.\n"); - return releaseContext(&ctx); - } - ctx.state = haveContext; - - testAGP(&ctx); - - releaseContext(&ctx); - printf("Terminating normally\n"); - return 0; -} diff --git a/tests/ttmtest/src/xf86dri.c b/tests/ttmtest/src/xf86dri.c deleted file mode 100644 index e6e0b89..0000000 --- a/tests/ttmtest/src/xf86dri.c +++ /dev/null @@ -1,603 +0,0 @@ -/* $XFree86: xc/lib/GL/dri/XF86dri.c,v 1.13 2002/10/30 12:51:25 alanh Exp $ */ -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -Copyright 2000 VA Linux Systems, Inc. -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. - -**************************************************************************/ - -/* - * Authors: - * Kevin E. Martin - * Jens Owen - * Rickard E. (Rik) Faith - * - */ - -/* THIS IS NOT AN X CONSORTIUM STANDARD */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include -#include "xf86dristr.h" - -static XExtensionInfo _xf86dri_info_data; -static XExtensionInfo *xf86dri_info = &_xf86dri_info_data; -static char xf86dri_extension_name[] = XF86DRINAME; - -#define uniDRICheckExtension(dpy,i,val) \ - XextCheckExtension (dpy, i, xf86dri_extension_name, val) - -/***************************************************************************** - * * - * private utility routines * - * * - *****************************************************************************/ - -static int close_display(Display * dpy, XExtCodes * extCodes); -static /* const */ XExtensionHooks xf86dri_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, xf86dri_info, - xf86dri_extension_name, &xf86dri_extension_hooks, 0, NULL) - - static XEXT_GENERATE_CLOSE_DISPLAY(close_display, xf86dri_info) - -/***************************************************************************** - * * - * public XFree86-DRI Extension routines * - * * - *****************************************************************************/ -#if 0 -#include -#define TRACE(msg) fprintf(stderr,"uniDRI%s\n", msg); -#else -#define TRACE(msg) -#endif - Bool uniDRIQueryExtension(dpy, event_basep, error_basep) - Display *dpy; - int *event_basep, *error_basep; -{ - XExtDisplayInfo *info = find_display(dpy); - - TRACE("QueryExtension..."); - if (XextHasExtension(info)) { - *event_basep = info->codes->first_event; - *error_basep = info->codes->first_error; - TRACE("QueryExtension... return True"); - return True; - } else { - TRACE("QueryExtension... return False"); - return False; - } -} - -Bool -uniDRIQueryVersion(dpy, majorVersion, minorVersion, patchVersion) - Display *dpy; - int *majorVersion; - int *minorVersion; - int *patchVersion; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIQueryVersionReply rep; - xXF86DRIQueryVersionReq *req; - - TRACE("QueryVersion..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIQueryVersion, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIQueryVersion; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("QueryVersion... return False"); - return False; - } - *majorVersion = rep.majorVersion; - *minorVersion = rep.minorVersion; - *patchVersion = rep.patchVersion; - UnlockDisplay(dpy); - SyncHandle(); - TRACE("QueryVersion... return True"); - return True; -} - -Bool -uniDRIQueryDirectRenderingCapable(dpy, screen, isCapable) - Display *dpy; - int screen; - Bool *isCapable; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIQueryDirectRenderingCapableReply rep; - xXF86DRIQueryDirectRenderingCapableReq *req; - - TRACE("QueryDirectRenderingCapable..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIQueryDirectRenderingCapable, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIQueryDirectRenderingCapable; - req->screen = screen; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("QueryDirectRenderingCapable... return False"); - return False; - } - *isCapable = rep.isCapable; - UnlockDisplay(dpy); - SyncHandle(); - TRACE("QueryDirectRenderingCapable... return True"); - return True; -} - -Bool -uniDRIOpenConnection(dpy, screen, hSAREA, busIdString) - Display *dpy; - int screen; - drm_handle_t *hSAREA; - char **busIdString; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIOpenConnectionReply rep; - xXF86DRIOpenConnectionReq *req; - - TRACE("OpenConnection..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIOpenConnection, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIOpenConnection; - req->screen = screen; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("OpenConnection... return False"); - return False; - } - - *hSAREA = rep.hSAREALow; -#ifdef LONG64 - if (sizeof(drm_handle_t) == 8) { - *hSAREA |= ((unsigned long)rep.hSAREAHigh) << 32; - } -#endif - if (rep.length) { - if (!(*busIdString = (char *)Xcalloc(rep.busIdStringLength + 1, 1))) { - _XEatData(dpy, ((rep.busIdStringLength + 3) & ~3)); - UnlockDisplay(dpy); - SyncHandle(); - TRACE("OpenConnection... return False"); - return False; - } - _XReadPad(dpy, *busIdString, rep.busIdStringLength); - } else { - *busIdString = NULL; - } - UnlockDisplay(dpy); - SyncHandle(); - TRACE("OpenConnection... return True"); - return True; -} - -Bool -uniDRIAuthConnection(dpy, screen, magic) - Display *dpy; - int screen; - drm_magic_t magic; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIAuthConnectionReq *req; - xXF86DRIAuthConnectionReply rep; - - TRACE("AuthConnection..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIAuthConnection, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIAuthConnection; - req->screen = screen; - req->magic = magic; - rep.authenticated = 0; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse) || !rep.authenticated) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("AuthConnection... return False"); - return False; - } - UnlockDisplay(dpy); - SyncHandle(); - TRACE("AuthConnection... return True"); - return True; -} - -Bool -uniDRICloseConnection(dpy, screen) - Display *dpy; - int screen; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRICloseConnectionReq *req; - - TRACE("CloseConnection..."); - - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRICloseConnection, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRICloseConnection; - req->screen = screen; - UnlockDisplay(dpy); - SyncHandle(); - TRACE("CloseConnection... return True"); - return True; -} - -Bool -uniDRIGetClientDriverName(dpy, screen, ddxDriverMajorVersion, - ddxDriverMinorVersion, ddxDriverPatchVersion, clientDriverName) - Display *dpy; - int screen; - int *ddxDriverMajorVersion; - int *ddxDriverMinorVersion; - int *ddxDriverPatchVersion; - char **clientDriverName; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIGetClientDriverNameReply rep; - xXF86DRIGetClientDriverNameReq *req; - - TRACE("GetClientDriverName..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIGetClientDriverName, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIGetClientDriverName; - req->screen = screen; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetClientDriverName... return False"); - return False; - } - - *ddxDriverMajorVersion = rep.ddxDriverMajorVersion; - *ddxDriverMinorVersion = rep.ddxDriverMinorVersion; - *ddxDriverPatchVersion = rep.ddxDriverPatchVersion; - - if (rep.length) { - if (!(*clientDriverName = - (char *)Xcalloc(rep.clientDriverNameLength + 1, 1))) { - _XEatData(dpy, ((rep.clientDriverNameLength + 3) & ~3)); - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetClientDriverName... return False"); - return False; - } - _XReadPad(dpy, *clientDriverName, rep.clientDriverNameLength); - } else { - *clientDriverName = NULL; - } - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetClientDriverName... return True"); - return True; -} - -Bool -uniDRICreateContextWithConfig(dpy, screen, configID, context, hHWContext) - Display *dpy; - int screen; - int configID; - XID *context; - drm_context_t *hHWContext; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRICreateContextReply rep; - xXF86DRICreateContextReq *req; - - TRACE("CreateContext..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRICreateContext, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRICreateContext; - req->visual = configID; - req->screen = screen; - *context = XAllocID(dpy); - req->context = *context; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("CreateContext... return False"); - return False; - } - *hHWContext = rep.hHWContext; - UnlockDisplay(dpy); - SyncHandle(); - TRACE("CreateContext... return True"); - return True; -} - -Bool -uniDRICreateContext(dpy, screen, visual, context, hHWContext) - Display *dpy; - int screen; - Visual *visual; - XID *context; - drm_context_t *hHWContext; -{ - return uniDRICreateContextWithConfig(dpy, screen, visual->visualid, - context, hHWContext); -} - -Bool -uniDRIDestroyContext(Display * ndpy, int screen, XID context) -{ - Display *const dpy = (Display *) ndpy; - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIDestroyContextReq *req; - - TRACE("DestroyContext..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIDestroyContext, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIDestroyContext; - req->screen = screen; - req->context = context; - UnlockDisplay(dpy); - SyncHandle(); - TRACE("DestroyContext... return True"); - return True; -} - -Bool -uniDRICreateDrawable(Display * ndpy, int screen, - Drawable drawable, drm_drawable_t * hHWDrawable) -{ - Display *const dpy = (Display *) ndpy; - XExtDisplayInfo *info = find_display(dpy); - xXF86DRICreateDrawableReply rep; - xXF86DRICreateDrawableReq *req; - - TRACE("CreateDrawable..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRICreateDrawable, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRICreateDrawable; - req->screen = screen; - req->drawable = drawable; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("CreateDrawable... return False"); - return False; - } - *hHWDrawable = rep.hHWDrawable; - UnlockDisplay(dpy); - SyncHandle(); - TRACE("CreateDrawable... return True"); - return True; -} - -Bool -uniDRIDestroyDrawable(Display * ndpy, int screen, Drawable drawable) -{ - Display *const dpy = (Display *) ndpy; - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIDestroyDrawableReq *req; - - TRACE("DestroyDrawable..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIDestroyDrawable, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIDestroyDrawable; - req->screen = screen; - req->drawable = drawable; - UnlockDisplay(dpy); - SyncHandle(); - TRACE("DestroyDrawable... return True"); - return True; -} - -Bool -uniDRIGetDrawableInfo(Display * dpy, int screen, Drawable drawable, - unsigned int *index, unsigned int *stamp, - int *X, int *Y, int *W, int *H, - int *numClipRects, drm_clip_rect_t ** pClipRects, - int *backX, int *backY, - int *numBackClipRects, drm_clip_rect_t ** pBackClipRects) -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIGetDrawableInfoReply rep; - xXF86DRIGetDrawableInfoReq *req; - int total_rects; - - TRACE("GetDrawableInfo..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIGetDrawableInfo, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIGetDrawableInfo; - req->screen = screen; - req->drawable = drawable; - - if (!_XReply(dpy, (xReply *) & rep, 1, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetDrawableInfo... return False"); - return False; - } - *index = rep.drawableTableIndex; - *stamp = rep.drawableTableStamp; - *X = (int)rep.drawableX; - *Y = (int)rep.drawableY; - *W = (int)rep.drawableWidth; - *H = (int)rep.drawableHeight; - *numClipRects = rep.numClipRects; - total_rects = *numClipRects; - - *backX = rep.backX; - *backY = rep.backY; - *numBackClipRects = rep.numBackClipRects; - total_rects += *numBackClipRects; - -#if 0 - /* Because of the fix in Xserver/GL/dri/xf86dri.c, this check breaks - * backwards compatibility (Because of the >> 2 shift) but the fix - * enables multi-threaded apps to work. - */ - if (rep.length != ((((SIZEOF(xXF86DRIGetDrawableInfoReply) - - SIZEOF(xGenericReply) + - total_rects * sizeof(drm_clip_rect_t)) + - 3) & ~3) >> 2)) { - _XEatData(dpy, rep.length); - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetDrawableInfo... return False"); - return False; - } -#endif - - if (*numClipRects) { - int len = sizeof(drm_clip_rect_t) * (*numClipRects); - - *pClipRects = (drm_clip_rect_t *) Xcalloc(len, 1); - if (*pClipRects) - _XRead(dpy, (char *)*pClipRects, len); - } else { - *pClipRects = NULL; - } - - if (*numBackClipRects) { - int len = sizeof(drm_clip_rect_t) * (*numBackClipRects); - - *pBackClipRects = (drm_clip_rect_t *) Xcalloc(len, 1); - if (*pBackClipRects) - _XRead(dpy, (char *)*pBackClipRects, len); - } else { - *pBackClipRects = NULL; - } - - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetDrawableInfo... return True"); - return True; -} - -Bool -uniDRIGetDeviceInfo(dpy, screen, hFrameBuffer, - fbOrigin, fbSize, fbStride, devPrivateSize, pDevPrivate) - Display *dpy; - int screen; - drm_handle_t *hFrameBuffer; - int *fbOrigin; - int *fbSize; - int *fbStride; - int *devPrivateSize; - void **pDevPrivate; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIGetDeviceInfoReply rep; - xXF86DRIGetDeviceInfoReq *req; - - TRACE("GetDeviceInfo..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIGetDeviceInfo, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIGetDeviceInfo; - req->screen = screen; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetDeviceInfo... return False"); - return False; - } - - *hFrameBuffer = rep.hFrameBufferLow; -#ifdef LONG64 - if (sizeof(drm_handle_t) == 8) { - *hFrameBuffer |= ((unsigned long)rep.hFrameBufferHigh) << 32; - } -#endif - - *fbOrigin = rep.framebufferOrigin; - *fbSize = rep.framebufferSize; - *fbStride = rep.framebufferStride; - *devPrivateSize = rep.devPrivateSize; - - if (rep.length) { - if (!(*pDevPrivate = (void *)Xcalloc(rep.devPrivateSize, 1))) { - _XEatData(dpy, ((rep.devPrivateSize + 3) & ~3)); - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetDeviceInfo... return False"); - return False; - } - _XRead(dpy, (char *)*pDevPrivate, rep.devPrivateSize); - } else { - *pDevPrivate = NULL; - } - - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetDeviceInfo... return True"); - return True; -} diff --git a/tests/ttmtest/src/xf86dri.h b/tests/ttmtest/src/xf86dri.h deleted file mode 100644 index 8fb7896..0000000 --- a/tests/ttmtest/src/xf86dri.h +++ /dev/null @@ -1,116 +0,0 @@ -/* $XFree86: xc/lib/GL/dri/xf86dri.h,v 1.8 2002/10/30 12:51:25 alanh Exp $ */ -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -Copyright 2000 VA Linux Systems, Inc. -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. - -**************************************************************************/ - -/** - * \file xf86dri.h - * Protocol numbers and function prototypes for DRI X protocol. - * - * \author Kevin E. Martin - * \author Jens Owen - * \author Rickard E. (Rik) Faith - */ - -#ifndef _XF86DRI_H_ -#define _XF86DRI_H_ - -#include -#include - -#define X_XF86DRIQueryVersion 0 -#define X_XF86DRIQueryDirectRenderingCapable 1 -#define X_XF86DRIOpenConnection 2 -#define X_XF86DRICloseConnection 3 -#define X_XF86DRIGetClientDriverName 4 -#define X_XF86DRICreateContext 5 -#define X_XF86DRIDestroyContext 6 -#define X_XF86DRICreateDrawable 7 -#define X_XF86DRIDestroyDrawable 8 -#define X_XF86DRIGetDrawableInfo 9 -#define X_XF86DRIGetDeviceInfo 10 -#define X_XF86DRIAuthConnection 11 -#define X_XF86DRIOpenFullScreen 12 /* Deprecated */ -#define X_XF86DRICloseFullScreen 13 /* Deprecated */ - -#define XF86DRINumberEvents 0 - -#define XF86DRIClientNotLocal 0 -#define XF86DRIOperationNotSupported 1 -#define XF86DRINumberErrors (XF86DRIOperationNotSupported + 1) - -#ifndef _XF86DRI_SERVER_ - -_XFUNCPROTOBEGIN - Bool uniDRIQueryExtension(Display * dpy, int *event_base, - int *error_base); - -Bool uniDRIQueryVersion(Display * dpy, int *majorVersion, int *minorVersion, - int *patchVersion); - -Bool uniDRIQueryDirectRenderingCapable(Display * dpy, int screen, - Bool * isCapable); - -Bool uniDRIOpenConnection(Display * dpy, int screen, drm_handle_t * hSAREA, - char **busIDString); - -Bool uniDRIAuthConnection(Display * dpy, int screen, drm_magic_t magic); - -Bool uniDRICloseConnection(Display * dpy, int screen); - -Bool uniDRIGetClientDriverName(Display * dpy, int screen, - int *ddxDriverMajorVersion, int *ddxDriverMinorVersion, - int *ddxDriverPatchVersion, char **clientDriverName); - -Bool uniDRICreateContext(Display * dpy, int screen, Visual * visual, - XID * ptr_to_returned_context_id, drm_context_t * hHWContext); - -Bool uniDRICreateContextWithConfig(Display * dpy, int screen, int configID, - XID * ptr_to_returned_context_id, drm_context_t * hHWContext); - -extern Bool uniDRIDestroyContext(Display * dpy, int screen, XID context_id); - -extern Bool uniDRICreateDrawable(Display * dpy, int screen, - Drawable drawable, drm_drawable_t * hHWDrawable); - -extern Bool uniDRIDestroyDrawable(Display * dpy, int screen, - Drawable drawable); - -Bool uniDRIGetDrawableInfo(Display * dpy, int screen, Drawable drawable, - unsigned int *index, unsigned int *stamp, - int *X, int *Y, int *W, int *H, - int *numClipRects, drm_clip_rect_t ** pClipRects, - int *backX, int *backY, - int *numBackClipRects, drm_clip_rect_t ** pBackClipRects); - -Bool uniDRIGetDeviceInfo(Display * dpy, int screen, - drm_handle_t * hFrameBuffer, int *fbOrigin, int *fbSize, - int *fbStride, int *devPrivateSize, void **pDevPrivate); - -_XFUNCPROTOEND -#endif /* _XF86DRI_SERVER_ */ -#endif /* _XF86DRI_H_ */ diff --git a/tests/ttmtest/src/xf86dristr.h b/tests/ttmtest/src/xf86dristr.h deleted file mode 100644 index 3b43438..0000000 --- a/tests/ttmtest/src/xf86dristr.h +++ /dev/null @@ -1,390 +0,0 @@ -/* $XFree86: xc/lib/GL/dri/xf86dristr.h,v 1.10 2002/10/30 12:51:25 alanh Exp $ */ -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -Copyright 2000 VA Linux Systems, Inc. -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. - -**************************************************************************/ - -/* - * Authors: - * Kevin E. Martin - * Jens Owen - * Rickard E. (Rik) Fiath - * - */ - -#ifndef _XF86DRISTR_H_ -#define _XF86DRISTR_H_ - -#include "xf86dri.h" - -#define XF86DRINAME "XFree86-DRI" - -/* The DRI version number. This was originally set to be the same of the - * XFree86 version number. However, this version is really indepedent of - * the XFree86 version. - * - * Version History: - * 4.0.0: Original - * 4.0.1: Patch to bump clipstamp when windows are destroyed, 28 May 02 - * 4.1.0: Add transition from single to multi in DRMInfo rec, 24 Jun 02 - */ -#define XF86DRI_MAJOR_VERSION 4 -#define XF86DRI_MINOR_VERSION 1 -#define XF86DRI_PATCH_VERSION 0 - -typedef struct _XF86DRIQueryVersion -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIQueryVersion */ - CARD16 length B16; -} xXF86DRIQueryVersionReq; - -#define sz_xXF86DRIQueryVersionReq 4 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD16 majorVersion B16; /* major version of DRI protocol */ - CARD16 minorVersion B16; /* minor version of DRI protocol */ - CARD32 patchVersion B32; /* patch version of DRI protocol */ - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86DRIQueryVersionReply; - -#define sz_xXF86DRIQueryVersionReply 32 - -typedef struct _XF86DRIQueryDirectRenderingCapable -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* X_DRIQueryDirectRenderingCapable */ - CARD16 length B16; - CARD32 screen B32; -} xXF86DRIQueryDirectRenderingCapableReq; - -#define sz_xXF86DRIQueryDirectRenderingCapableReq 8 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - BOOL isCapable; - BOOL pad2; - BOOL pad3; - BOOL pad4; - CARD32 pad5 B32; - CARD32 pad6 B32; - CARD32 pad7 B32; - CARD32 pad8 B32; - CARD32 pad9 B32; -} xXF86DRIQueryDirectRenderingCapableReply; - -#define sz_xXF86DRIQueryDirectRenderingCapableReply 32 - -typedef struct _XF86DRIOpenConnection -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIOpenConnection */ - CARD16 length B16; - CARD32 screen B32; -} xXF86DRIOpenConnectionReq; - -#define sz_xXF86DRIOpenConnectionReq 8 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 hSAREALow B32; - CARD32 hSAREAHigh B32; - CARD32 busIdStringLength B32; - CARD32 pad6 B32; - CARD32 pad7 B32; - CARD32 pad8 B32; -} xXF86DRIOpenConnectionReply; - -#define sz_xXF86DRIOpenConnectionReply 32 - -typedef struct _XF86DRIAuthConnection -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRICloseConnection */ - CARD16 length B16; - CARD32 screen B32; - CARD32 magic B32; -} xXF86DRIAuthConnectionReq; - -#define sz_xXF86DRIAuthConnectionReq 12 - -typedef struct -{ - BYTE type; - BOOL 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; -} xXF86DRIAuthConnectionReply; - -#define zx_xXF86DRIAuthConnectionReply 32 - -typedef struct _XF86DRICloseConnection -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRICloseConnection */ - CARD16 length B16; - CARD32 screen B32; -} xXF86DRICloseConnectionReq; - -#define sz_xXF86DRICloseConnectionReq 8 - -typedef struct _XF86DRIGetClientDriverName -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIGetClientDriverName */ - CARD16 length B16; - CARD32 screen B32; -} xXF86DRIGetClientDriverNameReq; - -#define sz_xXF86DRIGetClientDriverNameReq 8 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 ddxDriverMajorVersion B32; - CARD32 ddxDriverMinorVersion B32; - CARD32 ddxDriverPatchVersion B32; - CARD32 clientDriverNameLength B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86DRIGetClientDriverNameReply; - -#define sz_xXF86DRIGetClientDriverNameReply 32 - -typedef struct _XF86DRICreateContext -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRICreateContext */ - CARD16 length B16; - CARD32 screen B32; - CARD32 visual B32; - CARD32 context B32; -} xXF86DRICreateContextReq; - -#define sz_xXF86DRICreateContextReq 16 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 hHWContext B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86DRICreateContextReply; - -#define sz_xXF86DRICreateContextReply 32 - -typedef struct _XF86DRIDestroyContext -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIDestroyContext */ - CARD16 length B16; - CARD32 screen B32; - CARD32 context B32; -} xXF86DRIDestroyContextReq; - -#define sz_xXF86DRIDestroyContextReq 12 - -typedef struct _XF86DRICreateDrawable -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRICreateDrawable */ - CARD16 length B16; - CARD32 screen B32; - CARD32 drawable B32; -} xXF86DRICreateDrawableReq; - -#define sz_xXF86DRICreateDrawableReq 12 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 hHWDrawable B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86DRICreateDrawableReply; - -#define sz_xXF86DRICreateDrawableReply 32 - -typedef struct _XF86DRIDestroyDrawable -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIDestroyDrawable */ - CARD16 length B16; - CARD32 screen B32; - CARD32 drawable B32; -} xXF86DRIDestroyDrawableReq; - -#define sz_xXF86DRIDestroyDrawableReq 12 - -typedef struct _XF86DRIGetDrawableInfo -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIGetDrawableInfo */ - CARD16 length B16; - CARD32 screen B32; - CARD32 drawable B32; -} xXF86DRIGetDrawableInfoReq; - -#define sz_xXF86DRIGetDrawableInfoReq 12 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 drawableTableIndex B32; - CARD32 drawableTableStamp B32; - INT16 drawableX B16; - INT16 drawableY B16; - INT16 drawableWidth B16; - INT16 drawableHeight B16; - CARD32 numClipRects B32; - INT16 backX B16; - INT16 backY B16; - CARD32 numBackClipRects B32; -} xXF86DRIGetDrawableInfoReply; - -#define sz_xXF86DRIGetDrawableInfoReply 36 - -typedef struct _XF86DRIGetDeviceInfo -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIGetDeviceInfo */ - CARD16 length B16; - CARD32 screen B32; -} xXF86DRIGetDeviceInfoReq; - -#define sz_xXF86DRIGetDeviceInfoReq 8 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 hFrameBufferLow B32; - CARD32 hFrameBufferHigh B32; - CARD32 framebufferOrigin B32; - CARD32 framebufferSize B32; - CARD32 framebufferStride B32; - CARD32 devPrivateSize B32; -} xXF86DRIGetDeviceInfoReply; - -#define sz_xXF86DRIGetDeviceInfoReply 32 - -typedef struct _XF86DRIOpenFullScreen -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIOpenFullScreen */ - CARD16 length B16; - CARD32 screen B32; - CARD32 drawable B32; -} xXF86DRIOpenFullScreenReq; - -#define sz_xXF86DRIOpenFullScreenReq 12 - -typedef struct -{ - BYTE type; - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 isFullScreen B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86DRIOpenFullScreenReply; - -#define sz_xXF86DRIOpenFullScreenReply 32 - -typedef struct _XF86DRICloseFullScreen -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRICloseFullScreen */ - CARD16 length B16; - CARD32 screen B32; - CARD32 drawable B32; -} xXF86DRICloseFullScreenReq; - -#define sz_xXF86DRICloseFullScreenReq 12 - -typedef struct -{ - BYTE type; - BOOL 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; -} xXF86DRICloseFullScreenReply; - -#define sz_xXF86DRICloseFullScreenReply 32 - -#endif /* _XF86DRISTR_H_ */ diff --git a/xf86mm.h b/xf86mm.h deleted file mode 100644 index a31de42..0000000 --- a/xf86mm.h +++ /dev/null @@ -1,198 +0,0 @@ -/************************************************************************** - * - * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND. USA. - * 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 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 - * THE COPYRIGHT HOLDERS, AUTHORS 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 above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * - **************************************************************************/ - -#ifndef _XF86MM_H_ -#define _XF86MM_H_ -#include -#include -#include "drm.h" - -/* - * Note on multithreaded applications using this interface. - * Libdrm is not threadsafe, so common buffer, TTM, and fence objects need to - * be protected using an external mutex. - * - * Note: Don't protect the following functions, as it may lead to deadlocks: - * drmBOUnmap(). - * The kernel is synchronizing and refcounting buffer maps. - * User space only needs to refcount object usage within the same application. - */ - - -/* - * List macros heavily inspired by the Linux kernel - * list handling. No list looping yet. - */ - -typedef struct _drmMMListHead -{ - struct _drmMMListHead *prev; - struct _drmMMListHead *next; -} drmMMListHead; - -#define DRMINITLISTHEAD(__item) \ - do{ \ - (__item)->prev = (__item); \ - (__item)->next = (__item); \ - } while (0) - -#define DRMLISTADD(__item, __list) \ - do { \ - (__item)->prev = (__list); \ - (__item)->next = (__list)->next; \ - (__list)->next->prev = (__item); \ - (__list)->next = (__item); \ - } while (0) - -#define DRMLISTADDTAIL(__item, __list) \ - do { \ - (__item)->next = (__list); \ - (__item)->prev = (__list)->prev; \ - (__list)->prev->next = (__item); \ - (__list)->prev = (__item); \ - } while(0) - -#define DRMLISTDEL(__item) \ - do { \ - (__item)->prev->next = (__item)->next; \ - (__item)->next->prev = (__item)->prev; \ - } while(0) - -#define DRMLISTDELINIT(__item) \ - do { \ - (__item)->prev->next = (__item)->next; \ - (__item)->next->prev = (__item)->prev; \ - (__item)->next = (__item); \ - (__item)->prev = (__item); \ - } while(0) - -#define DRMLISTENTRY(__type, __item, __field) \ - ((__type *)(((char *) (__item)) - offsetof(__type, __field))) - -#define DRMLISTEMPTY(__item) ((__item)->next == (__item)) - -#define DRMLISTFOREACHSAFE(__item, __temp, __list) \ - for ((__item) = (__list)->next, (__temp) = (__item)->next; \ - (__item) != (__list); \ - (__item) = (__temp), (__temp) = (__item)->next) - -#define DRMLISTFOREACHSAFEREVERSE(__item, __temp, __list) \ - for ((__item) = (__list)->prev, (__temp) = (__item)->prev; \ - (__item) != (__list); \ - (__item) = (__temp), (__temp) = (__item)->prev) - -typedef struct _drmFence -{ - unsigned handle; - int fence_class; - unsigned type; - unsigned flags; - unsigned signaled; - uint32_t sequence; - unsigned pad[4]; /* for future expansion */ -} drmFence; - -typedef struct _drmBO -{ - unsigned handle; - uint64_t mapHandle; - uint64_t flags; - uint64_t proposedFlags; - unsigned mapFlags; - unsigned long size; - unsigned long offset; - unsigned long start; - unsigned replyFlags; - unsigned fenceFlags; - unsigned pageAlignment; - unsigned tileInfo; - unsigned hwTileStride; - unsigned desiredTileStride; - void *virtual; - void *mapVirtual; - int mapCount; - unsigned pad[8]; /* for future expansion */ -} drmBO; - -/* - * Fence functions. - */ - -extern int drmFenceCreate(int fd, unsigned flags, int fence_class, - unsigned type, drmFence *fence); -extern int drmFenceReference(int fd, unsigned handle, drmFence *fence); -extern int drmFenceUnreference(int fd, const drmFence *fence); -extern int drmFenceFlush(int fd, drmFence *fence, unsigned flush_type); -extern int drmFenceSignaled(int fd, drmFence *fence, - unsigned fenceType, int *signaled); -extern int drmFenceWait(int fd, unsigned flags, drmFence *fence, - unsigned flush_type); -extern int drmFenceEmit(int fd, unsigned flags, drmFence *fence, - unsigned emit_type); -extern int drmFenceBuffers(int fd, unsigned flags, uint32_t fence_class, drmFence *fence); - - -/* - * Buffer object functions. - */ - -extern int drmBOCreate(int fd, unsigned long size, - unsigned pageAlignment, void *user_buffer, - uint64_t mask, unsigned hint, drmBO *buf); -extern int drmBOReference(int fd, unsigned handle, drmBO *buf); -extern int drmBOUnreference(int fd, drmBO *buf); -extern int drmBOMap(int fd, drmBO *buf, unsigned mapFlags, unsigned mapHint, - void **address); -extern int drmBOUnmap(int fd, drmBO *buf); -extern int drmBOFence(int fd, drmBO *buf, unsigned flags, unsigned fenceHandle); -extern int drmBOInfo(int fd, drmBO *buf); -extern int drmBOBusy(int fd, drmBO *buf, int *busy); - -extern int drmBOWaitIdle(int fd, drmBO *buf, unsigned hint); - -/* - * Initialization functions. - */ - -extern int drmMMInit(int fd, unsigned long pOffset, unsigned long pSize, - unsigned memType); -extern int drmMMTakedown(int fd, unsigned memType); -extern int drmMMLock(int fd, unsigned memType, int lockBM, int ignoreNoEvict); -extern int drmMMUnlock(int fd, unsigned memType, int unlockBM); -extern int drmMMInfo(int fd, unsigned memType, uint64_t *size); -extern int drmBOSetStatus(int fd, drmBO *buf, - uint64_t flags, uint64_t mask, - unsigned int hint, - unsigned int desired_tile_stride, - unsigned int tile_info); -extern int drmBOVersion(int fd, unsigned int *major, - unsigned int *minor, - unsigned int *patchlevel); - - -#endif -- 2.7.4