From 6f7c809ebbb27c93b07a2ef5596039c68173ea71 Mon Sep 17 00:00:00 2001 From: jsg Date: Sun, 5 Feb 2017 05:46:41 +0000 Subject: [PATCH] Merge libdrm 2.4.75 --- lib/libdrm/Makefile.am | 1 + lib/libdrm/Makefile.bsd-wrapper | 4 +- lib/libdrm/Makefile.in | 3 +- lib/libdrm/Makefile.sources | 1 + lib/libdrm/README | 8 +- lib/libdrm/amdgpu/Makefile.in | 2 - lib/libdrm/config.h.in | 3 - lib/libdrm/configure | 462 ++++--------- lib/libdrm/configure.ac | 11 +- lib/libdrm/etnaviv/Makefile.in | 2 - lib/libdrm/exynos/Makefile.in | 2 - lib/libdrm/freedreno/Makefile.in | 2 - lib/libdrm/include/drm/i915_drm.h | 276 +++++++- lib/libdrm/intel/Makefile.am | 3 +- lib/libdrm/intel/Makefile.in | 6 +- lib/libdrm/intel/intel_bufmgr.h | 13 + lib/libdrm/intel/intel_bufmgr_fake.c | 4 +- lib/libdrm/intel/intel_bufmgr_gem.c | 123 +++- lib/libdrm/intel/intel_chipset.h | 13 +- lib/libdrm/libkms/Makefile.in | 6 - lib/libdrm/libkms/linux.c | 94 --- lib/libdrm/libsync.h | 2 +- lib/libdrm/man/Makefile.in | 2 - lib/libdrm/nouveau/Makefile.in | 2 - lib/libdrm/omap/Makefile.in | 2 - lib/libdrm/radeon/Makefile.in | 2 - lib/libdrm/radeon/radeon_cs_gem.c | 10 +- lib/libdrm/radeon/radeon_surface.c | 2 +- lib/libdrm/tegra/Makefile.in | 2 - lib/libdrm/tests/Makefile.in | 194 +----- lib/libdrm/tests/amdgpu/Makefile.in | 2 - lib/libdrm/tests/dristat.c | 285 -------- lib/libdrm/tests/drmstat.c | 419 ------------ lib/libdrm/tests/drmtest.c | 135 ---- lib/libdrm/tests/drmtest.h | 40 -- lib/libdrm/tests/etnaviv/Makefile.in | 2 - lib/libdrm/tests/exynos/Makefile.in | 6 +- lib/libdrm/tests/getclient.c | 61 -- lib/libdrm/tests/getstats.c | 50 -- lib/libdrm/tests/getversion.c | 49 -- lib/libdrm/tests/kms/Makefile.in | 2 - lib/libdrm/tests/kmstest/Makefile.in | 2 - lib/libdrm/tests/modeprint/Makefile.in | 2 - lib/libdrm/tests/modetest/Makefile.in | 7 +- lib/libdrm/tests/name_from_fd.c | 58 -- lib/libdrm/tests/nouveau/Makefile.in | 9 +- lib/libdrm/tests/openclose.c | 37 - lib/libdrm/tests/proptest/Makefile.in | 2 - lib/libdrm/tests/radeon/Makefile.in | 2 - lib/libdrm/tests/setversion.c | 91 --- lib/libdrm/tests/tegra/Makefile.in | 2 - lib/libdrm/tests/updatedraw.c | 154 ----- lib/libdrm/tests/util/Makefile.in | 2 - lib/libdrm/tests/vbltest/Makefile.in | 2 - lib/libdrm/vc4/Makefile.in | 2 - lib/libdrm/xf86drm.c | 905 ++++++++++++++++++++++--- lib/libdrm/xf86drm.h | 50 +- lib/libdrm/xf86drmMode.c | 2 +- lib/libdrm/xf86drmMode.h | 19 +- 59 files changed, 1461 insertions(+), 2195 deletions(-) delete mode 100644 lib/libdrm/tests/dristat.c delete mode 100644 lib/libdrm/tests/drmstat.c delete mode 100644 lib/libdrm/tests/drmtest.c delete mode 100644 lib/libdrm/tests/drmtest.h delete mode 100644 lib/libdrm/tests/getclient.c delete mode 100644 lib/libdrm/tests/getstats.c delete mode 100644 lib/libdrm/tests/getversion.c delete mode 100644 lib/libdrm/tests/name_from_fd.c delete mode 100644 lib/libdrm/tests/openclose.c delete mode 100644 lib/libdrm/tests/setversion.c delete mode 100644 lib/libdrm/tests/updatedraw.c diff --git a/lib/libdrm/Makefile.am b/lib/libdrm/Makefile.am index 2e46bde84..dfb8fcdb6 100644 --- a/lib/libdrm/Makefile.am +++ b/lib/libdrm/Makefile.am @@ -22,6 +22,7 @@ include Makefile.sources ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} +AM_MAKEFLAGS = -s AM_DISTCHECK_CONFIGURE_FLAGS = \ --enable-udev \ --enable-libkms \ diff --git a/lib/libdrm/Makefile.bsd-wrapper b/lib/libdrm/Makefile.bsd-wrapper index 4d54bb304..d09bf7bd2 100644 --- a/lib/libdrm/Makefile.bsd-wrapper +++ b/lib/libdrm/Makefile.bsd-wrapper @@ -1,6 +1,6 @@ -# $OpenBSD: Makefile.bsd-wrapper,v 1.9 2016/11/19 05:45:00 jsg Exp $ +# $OpenBSD: Makefile.bsd-wrapper,v 1.10 2017/02/05 05:46:41 jsg Exp $ -SHARED_LIBS= drm 7.3 drm_radeon 4.0 drm_intel 5.3 \ +SHARED_LIBS= drm 7.4 drm_radeon 4.0 drm_intel 5.4 \ drm_amdgpu 1.2 drm_nouveau 3.0 .include diff --git a/lib/libdrm/Makefile.in b/lib/libdrm/Makefile.in index 9913273db..a30273312 100644 --- a/lib/libdrm/Makefile.in +++ b/lib/libdrm/Makefile.in @@ -306,8 +306,6 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ -LIBUDEV_LIBS = @LIBUDEV_LIBS@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ @@ -450,6 +448,7 @@ LIBDRM_INCLUDE_VMWGFX_H_FILES := \ include/drm/vmwgfx_drm.h ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} +AM_MAKEFLAGS = -s AM_DISTCHECK_CONFIGURE_FLAGS = \ --enable-udev \ --enable-libkms \ diff --git a/lib/libdrm/Makefile.sources b/lib/libdrm/Makefile.sources index a57036a68..10aa1d0f4 100644 --- a/lib/libdrm/Makefile.sources +++ b/lib/libdrm/Makefile.sources @@ -13,6 +13,7 @@ LIBDRM_FILES := \ util_math.h LIBDRM_H_FILES := \ + libsync.h \ xf86drm.h \ xf86drmMode.h diff --git a/lib/libdrm/README b/lib/libdrm/README index 603a1c10a..26cab9d3e 100644 --- a/lib/libdrm/README +++ b/lib/libdrm/README @@ -1,7 +1,7 @@ libdrm - userspace library for drm This is libdrm, a userspace library for accessing the DRM, direct -rendering manager, on Linux, BSD and other operating systes that +rendering manager, on Linux, BSD and other operating systems that support the ioctl interface. The library provides wrapper functions for the ioctls to avoid exposing the kernel interface directly, and for chipsets with drm memory manager, support for tracking relocations @@ -15,7 +15,7 @@ with an older kernel. Compiling --------- -libdrm is a standard autotools packages and follows the normal +libdrm is a standard autotools package and follows the normal configure, build and install steps. The first step is to configure the package, which is done by running the configure shell script: @@ -37,5 +37,5 @@ and once make finishes successfully, install the package using make install -If you are install into a system location, you will need to be root to -perform the install step. +If you are installing into a system location, you will need to be root +to perform the install step. diff --git a/lib/libdrm/amdgpu/Makefile.in b/lib/libdrm/amdgpu/Makefile.in index 6b2a3b5da..ea121b986 100644 --- a/lib/libdrm/amdgpu/Makefile.in +++ b/lib/libdrm/amdgpu/Makefile.in @@ -236,8 +236,6 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ -LIBUDEV_LIBS = @LIBUDEV_LIBS@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ diff --git a/lib/libdrm/config.h.in b/lib/libdrm/config.h.in index 3072cd9ac..dd63b0b12 100644 --- a/lib/libdrm/config.h.in +++ b/lib/libdrm/config.h.in @@ -54,9 +54,6 @@ /* Enable if your compiler supports the Intel __sync_* atomic primitives */ #undef HAVE_LIBDRM_ATOMIC_PRIMITIVES -/* Have libudev support */ -#undef HAVE_LIBUDEV - /* Enable if you have libatomic-ops-dev installed */ #undef HAVE_LIB_ATOMIC_OPS diff --git a/lib/libdrm/configure b/lib/libdrm/configure index 8d38d6f6c..67be5aceb 100644 --- a/lib/libdrm/configure +++ b/lib/libdrm/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for libdrm 2.4.73. +# Generated by GNU Autoconf 2.69 for libdrm 2.4.75. # # Report bugs to . # @@ -591,8 +591,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='libdrm' PACKAGE_TARNAME='libdrm' -PACKAGE_VERSION='2.4.73' -PACKAGE_STRING='libdrm 2.4.73' +PACKAGE_VERSION='2.4.75' +PACKAGE_STRING='libdrm 2.4.75' PACKAGE_BUGREPORT='https://bugs.freedesktop.org/enter_bug.cgi?product=DRI' PACKAGE_URL='' @@ -646,10 +646,6 @@ HAVE_MANPAGES_STYLESHEET_TRUE MANPAGES_STYLESHEET BUILD_MANPAGES_FALSE BUILD_MANPAGES_TRUE -HAVE_LIBUDEV_FALSE -HAVE_LIBUDEV_TRUE -LIBUDEV_LIBS -LIBUDEV_CFLAGS HAVE_CAIRO_FALSE HAVE_CAIRO_TRUE CAIRO_LIBS @@ -688,13 +684,13 @@ HAVE_LIBKMS_FALSE HAVE_LIBKMS_TRUE PCIACCESS_LIBS PCIACCESS_CFLAGS +PKG_CONFIG_LIBDIR +PKG_CONFIG_PATH +PKG_CONFIG CLOCK_LIB pkgconfigdir PTHREADSTUBS_LIBS PTHREADSTUBS_CFLAGS -PKG_CONFIG_LIBDIR -PKG_CONFIG_PATH -PKG_CONFIG OTOOL64 OTOOL LIPO @@ -876,16 +872,12 @@ CPP PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR -PTHREADSTUBS_CFLAGS -PTHREADSTUBS_LIBS PCIACCESS_CFLAGS PCIACCESS_LIBS CUNIT_CFLAGS CUNIT_LIBS CAIRO_CFLAGS CAIRO_LIBS -LIBUDEV_CFLAGS -LIBUDEV_LIBS VALGRIND_CFLAGS VALGRIND_LIBS' @@ -1428,7 +1420,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures libdrm 2.4.73 to adapt to many kinds of systems. +\`configure' configures libdrm 2.4.75 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1498,7 +1490,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libdrm 2.4.73:";; + short | recursive ) echo "Configuration of libdrm 2.4.75:";; esac cat <<\_ACEOF @@ -1583,10 +1575,6 @@ Some influential environment variables: directories to add to pkg-config's search path PKG_CONFIG_LIBDIR path overriding pkg-config's built-in search path - PTHREADSTUBS_CFLAGS - C compiler flags for PTHREADSTUBS, overriding pkg-config - PTHREADSTUBS_LIBS - linker flags for PTHREADSTUBS, overriding pkg-config PCIACCESS_CFLAGS C compiler flags for PCIACCESS, overriding pkg-config PCIACCESS_LIBS @@ -1597,10 +1585,6 @@ Some influential environment variables: CAIRO_CFLAGS C compiler flags for CAIRO, overriding pkg-config CAIRO_LIBS linker flags for CAIRO, overriding pkg-config - LIBUDEV_CFLAGS - C compiler flags for LIBUDEV, overriding pkg-config - LIBUDEV_LIBS - linker flags for LIBUDEV, overriding pkg-config VALGRIND_CFLAGS C compiler flags for VALGRIND, overriding pkg-config VALGRIND_LIBS @@ -1672,7 +1656,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -libdrm configure 2.4.73 +libdrm configure 2.4.75 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2095,7 +2079,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by libdrm $as_me 2.4.73, which was +It was created by libdrm $as_me 2.4.75, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3318,7 +3302,7 @@ fi # Define the identity of the package. PACKAGE='libdrm' - VERSION='2.4.73' + VERSION='2.4.75' cat >>confdefs.h <<_ACEOF @@ -12610,216 +12594,6 @@ CC="$lt_save_CC" - - - -if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. -set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_PKG_CONFIG+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $PKG_CONFIG in - [\\/]* | ?:[\\/]*) - ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - ;; -esac -fi -PKG_CONFIG=$ac_cv_path_PKG_CONFIG -if test -n "$PKG_CONFIG"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 -$as_echo "$PKG_CONFIG" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_path_PKG_CONFIG"; then - ac_pt_PKG_CONFIG=$PKG_CONFIG - # Extract the first word of "pkg-config", so it can be a program name with args. -set dummy pkg-config; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $ac_pt_PKG_CONFIG in - [\\/]* | ?:[\\/]*) - ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - ;; -esac -fi -ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG -if test -n "$ac_pt_PKG_CONFIG"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 -$as_echo "$ac_pt_PKG_CONFIG" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_pt_PKG_CONFIG" = x; then - PKG_CONFIG="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - PKG_CONFIG=$ac_pt_PKG_CONFIG - fi -else - PKG_CONFIG="$ac_cv_path_PKG_CONFIG" -fi - -fi -if test -n "$PKG_CONFIG"; then - _pkg_min_version=0.9.0 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 -$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } - if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - PKG_CONFIG="" - fi -fi - -pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PTHREADSTUBS" >&5 -$as_echo_n "checking for PTHREADSTUBS... " >&6; } - -if test -n "$PTHREADSTUBS_CFLAGS"; then - pkg_cv_PTHREADSTUBS_CFLAGS="$PTHREADSTUBS_CFLAGS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pthread-stubs\""; } >&5 - ($PKG_CONFIG --exists --print-errors "pthread-stubs") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_PTHREADSTUBS_CFLAGS=`$PKG_CONFIG --cflags "pthread-stubs" 2>/dev/null` - test "x$?" != "x0" && pkg_failed=yes -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi -if test -n "$PTHREADSTUBS_LIBS"; then - pkg_cv_PTHREADSTUBS_LIBS="$PTHREADSTUBS_LIBS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pthread-stubs\""; } >&5 - ($PKG_CONFIG --exists --print-errors "pthread-stubs") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_PTHREADSTUBS_LIBS=`$PKG_CONFIG --libs "pthread-stubs" 2>/dev/null` - test "x$?" != "x0" && pkg_failed=yes -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi - - - -if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi - if test $_pkg_short_errors_supported = yes; then - PTHREADSTUBS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "pthread-stubs" 2>&1` - else - PTHREADSTUBS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "pthread-stubs" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$PTHREADSTUBS_PKG_ERRORS" >&5 - - as_fn_error $? "Package requirements (pthread-stubs) were not met: - -$PTHREADSTUBS_PKG_ERRORS - -Consider adjusting the PKG_CONFIG_PATH environment variable if you -installed software in a non-standard prefix. - -Alternatively, you may set the environment variables PTHREADSTUBS_CFLAGS -and PTHREADSTUBS_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details." "$LINENO" 5 -elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it -is in your PATH or set the PKG_CONFIG environment variable to the full -path to pkg-config. - -Alternatively, you may set the environment variables PTHREADSTUBS_CFLAGS -and PTHREADSTUBS_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details. - -To get pkg-config, see . -See \`config.log' for more details" "$LINENO" 5; } -else - PTHREADSTUBS_CFLAGS=$pkg_cv_PTHREADSTUBS_CFLAGS - PTHREADSTUBS_LIBS=$pkg_cv_PTHREADSTUBS_LIBS - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - -fi - - - pkgconfigdir=${libdir}/pkgconfig # Check whether --enable-udev was given. @@ -13266,6 +13040,126 @@ fi if test "x$INTEL" != "xno"; then + + + + + + +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. +set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +PKG_CONFIG=$ac_cv_path_PKG_CONFIG +if test -n "$PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 +$as_echo "$PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_path_PKG_CONFIG"; then + ac_pt_PKG_CONFIG=$PKG_CONFIG + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $ac_pt_PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG +if test -n "$ac_pt_PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 +$as_echo "$ac_pt_PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_pt_PKG_CONFIG" = x; then + PKG_CONFIG="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + PKG_CONFIG=$ac_pt_PKG_CONFIG + fi +else + PKG_CONFIG="$ac_cv_path_PKG_CONFIG" +fi + +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=0.9.0 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 +$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG="" + fi +fi + pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PCIACCESS" >&5 $as_echo_n "checking for PCIACCESS... " >&6; } @@ -13824,92 +13718,6 @@ else fi -# For enumerating devices in test case - -pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBUDEV" >&5 -$as_echo_n "checking for LIBUDEV... " >&6; } - -if test -n "$LIBUDEV_CFLAGS"; then - pkg_cv_LIBUDEV_CFLAGS="$LIBUDEV_CFLAGS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libudev\""; } >&5 - ($PKG_CONFIG --exists --print-errors "libudev") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_LIBUDEV_CFLAGS=`$PKG_CONFIG --cflags "libudev" 2>/dev/null` - test "x$?" != "x0" && pkg_failed=yes -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi -if test -n "$LIBUDEV_LIBS"; then - pkg_cv_LIBUDEV_LIBS="$LIBUDEV_LIBS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libudev\""; } >&5 - ($PKG_CONFIG --exists --print-errors "libudev") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_LIBUDEV_LIBS=`$PKG_CONFIG --libs "libudev" 2>/dev/null` - test "x$?" != "x0" && pkg_failed=yes -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi - - - -if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi - if test $_pkg_short_errors_supported = yes; then - LIBUDEV_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libudev" 2>&1` - else - LIBUDEV_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libudev" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$LIBUDEV_PKG_ERRORS" >&5 - - HAVE_LIBUDEV=no -elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - HAVE_LIBUDEV=no -else - LIBUDEV_CFLAGS=$pkg_cv_LIBUDEV_CFLAGS - LIBUDEV_LIBS=$pkg_cv_LIBUDEV_LIBS - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - HAVE_LIBUDEV=yes -fi -if test "x$HAVE_LIBUDEV" = xyes; then - -$as_echo "#define HAVE_LIBUDEV 1" >>confdefs.h - -fi - if test "x$HAVE_LIBUDEV" = xyes; then - HAVE_LIBUDEV_TRUE= - HAVE_LIBUDEV_FALSE='#' -else - HAVE_LIBUDEV_TRUE='#' - HAVE_LIBUDEV_FALSE= -fi - - # xsltproc for docbook manpages # Check whether --enable-manpages was given. if test "${enable_manpages+set}" = set; then : @@ -14320,10 +14128,6 @@ if test -z "${HAVE_CAIRO_TRUE}" && test -z "${HAVE_CAIRO_FALSE}"; then as_fn_error $? "conditional \"HAVE_CAIRO\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${HAVE_LIBUDEV_TRUE}" && test -z "${HAVE_LIBUDEV_FALSE}"; then - as_fn_error $? "conditional \"HAVE_LIBUDEV\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi if test -z "${BUILD_MANPAGES_TRUE}" && test -z "${BUILD_MANPAGES_FALSE}"; then as_fn_error $? "conditional \"BUILD_MANPAGES\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 @@ -14729,7 +14533,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by libdrm $as_me 2.4.73, which was +This file was extended by libdrm $as_me 2.4.75, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -14795,7 +14599,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -libdrm config.status 2.4.73 +libdrm config.status 2.4.75 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/lib/libdrm/configure.ac b/lib/libdrm/configure.ac index 9f25a4ca3..8e593324e 100644 --- a/lib/libdrm/configure.ac +++ b/lib/libdrm/configure.ac @@ -20,7 +20,7 @@ AC_PREREQ([2.63]) AC_INIT([libdrm], - [2.4.73], + [2.4.75], [https://bugs.freedesktop.org/enter_bug.cgi?product=DRI], [libdrm]) @@ -61,7 +61,7 @@ LT_PREREQ([2.2]) LT_INIT([disable-static]) -PKG_CHECK_MODULES(PTHREADSTUBS, pthread-stubs) + AC_SUBST(PTHREADSTUBS_CFLAGS) AC_SUBST(PTHREADSTUBS_LIBS) @@ -451,13 +451,6 @@ fi AC_MSG_RESULT([$CAIRO]) AM_CONDITIONAL(HAVE_CAIRO, [test "x$CAIRO" = xyes]) -# For enumerating devices in test case -PKG_CHECK_MODULES(LIBUDEV, libudev, [HAVE_LIBUDEV=yes], [HAVE_LIBUDEV=no]) -if test "x$HAVE_LIBUDEV" = xyes; then - AC_DEFINE(HAVE_LIBUDEV, 1, [Have libudev support]) -fi -AM_CONDITIONAL(HAVE_LIBUDEV, [test "x$HAVE_LIBUDEV" = xyes]) - # xsltproc for docbook manpages AC_ARG_ENABLE([manpages], AS_HELP_STRING([--enable-manpages], [enable manpages @<:@default=auto@:>@]), diff --git a/lib/libdrm/etnaviv/Makefile.in b/lib/libdrm/etnaviv/Makefile.in index e010470bd..539241546 100644 --- a/lib/libdrm/etnaviv/Makefile.in +++ b/lib/libdrm/etnaviv/Makefile.in @@ -211,8 +211,6 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ -LIBUDEV_LIBS = @LIBUDEV_LIBS@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ diff --git a/lib/libdrm/exynos/Makefile.in b/lib/libdrm/exynos/Makefile.in index dac135872..85520ac0f 100644 --- a/lib/libdrm/exynos/Makefile.in +++ b/lib/libdrm/exynos/Makefile.in @@ -212,8 +212,6 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ -LIBUDEV_LIBS = @LIBUDEV_LIBS@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ diff --git a/lib/libdrm/freedreno/Makefile.in b/lib/libdrm/freedreno/Makefile.in index 82383a63f..f4f8a353d 100644 --- a/lib/libdrm/freedreno/Makefile.in +++ b/lib/libdrm/freedreno/Makefile.in @@ -226,8 +226,6 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ -LIBUDEV_LIBS = @LIBUDEV_LIBS@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ diff --git a/lib/libdrm/include/drm/i915_drm.h b/lib/libdrm/include/drm/i915_drm.h index 13276ae23..01c02646a 100644 --- a/lib/libdrm/include/drm/i915_drm.h +++ b/lib/libdrm/include/drm/i915_drm.h @@ -29,6 +29,10 @@ #include "drm.h" +#if defined(__cplusplus) +extern "C" { +#endif + /* Please note that modifications to all structs defined here are * subject to backwards-compatibility constraints. */ @@ -58,6 +62,30 @@ #define I915_ERROR_UEVENT "ERROR" #define I915_RESET_UEVENT "RESET" +/* + * MOCS indexes used for GPU surfaces, defining the cacheability of the + * surface data and the coherency for this data wrt. CPU vs. GPU accesses. + */ +enum i915_mocs_table_index { + /* + * Not cached anywhere, coherency between CPU and GPU accesses is + * guaranteed. + */ + I915_MOCS_UNCACHED, + /* + * Cacheability and coherency controlled by the kernel automatically + * based on the DRM_I915_GEM_SET_CACHING IOCTL setting and the current + * usage of the surface (used for display scanout or not). + */ + I915_MOCS_PTE, + /* + * Cached in all GPU caches available on the platform. + * Coherency between CPU and GPU accesses to the surface is not + * guaranteed without extra synchronization. + */ + I915_MOCS_CACHED, +}; + /* Each region is a minimum of 16k, and there are at most 255 of them. */ #define I915_NR_TEX_REGIONS 255 /* table size 2k - maximum due to use @@ -225,6 +253,7 @@ typedef struct _drm_i915_sarea { #endif #define DRM_I915_OVERLAY_PUT_IMAGE 0x27 #define DRM_I915_OVERLAY_ATTRS 0x28 +#define DRM_I915_GEM_EXECBUFFER2_WR DRM_I915_GEM_EXECBUFFER2 #define DRM_I915_GET_SPRITE_COLORKEY 0x2a #define DRM_I915_SET_SPRITE_COLORKEY 0x2b #define DRM_I915_GEM_WAIT 0x2c @@ -237,6 +266,7 @@ typedef struct _drm_i915_sarea { #define DRM_I915_GEM_USERPTR 0x33 #define DRM_I915_GEM_CONTEXT_GETPARAM 0x34 #define DRM_I915_GEM_CONTEXT_SETPARAM 0x35 +#define DRM_I915_PERF_OPEN 0x36 #define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t) #define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH) @@ -258,6 +288,7 @@ typedef struct _drm_i915_sarea { #define DRM_IOCTL_I915_GEM_INIT DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_INIT, struct drm_i915_gem_init) #define DRM_IOCTL_I915_GEM_EXECBUFFER DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER, struct drm_i915_gem_execbuffer) #define DRM_IOCTL_I915_GEM_EXECBUFFER2 DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2, struct drm_i915_gem_execbuffer2) +#define DRM_IOCTL_I915_GEM_EXECBUFFER2_WR DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2_WR, struct drm_i915_gem_execbuffer2) #define DRM_IOCTL_I915_GEM_PIN DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_PIN, struct drm_i915_gem_pin) #define DRM_IOCTL_I915_GEM_UNPIN DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_UNPIN, struct drm_i915_gem_unpin) #define DRM_IOCTL_I915_GEM_BUSY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_BUSY, struct drm_i915_gem_busy) @@ -290,6 +321,7 @@ typedef struct _drm_i915_sarea { #define DRM_IOCTL_I915_GEM_USERPTR DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_USERPTR, struct drm_i915_gem_userptr) #define DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_GETPARAM, struct drm_i915_gem_context_param) #define DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_SETPARAM, struct drm_i915_gem_context_param) +#define DRM_IOCTL_I915_PERF_OPEN DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_OPEN, struct drm_i915_perf_open_param) /* Allow drivers to submit batchbuffers directly to hardware, relying * on the security mechanisms provided by hardware. @@ -364,8 +396,28 @@ typedef struct drm_i915_irq_wait { #define I915_PARAM_HAS_GPU_RESET 35 #define I915_PARAM_HAS_RESOURCE_STREAMER 36 #define I915_PARAM_HAS_EXEC_SOFTPIN 37 -#define I915_PARAM_HAS_POOLED_EU 38 -#define I915_PARAM_MIN_EU_IN_POOL 39 +#define I915_PARAM_HAS_POOLED_EU 38 +#define I915_PARAM_MIN_EU_IN_POOL 39 +#define I915_PARAM_MMAP_GTT_VERSION 40 + +/* Query whether DRM_I915_GEM_EXECBUFFER2 supports user defined execution + * priorities and the driver will attempt to execute batches in priority order. + */ +#define I915_PARAM_HAS_SCHEDULER 41 +#define I915_PARAM_HUC_STATUS 42 + +/* Query whether DRM_I915_GEM_EXECBUFFER2 supports the ability to opt-out of + * synchronisation with implicit fencing on individual objects. + * See EXEC_OBJECT_ASYNC. + */ +#define I915_PARAM_HAS_EXEC_ASYNC 43 + +/* Query whether DRM_I915_GEM_EXECBUFFER2 supports explicit fence support - + * both being able to pass in a sync_file fd to wait upon before executing, + * and being able to return a new sync_file fd that is signaled when the + * current request is complete. See I915_EXEC_FENCE_IN and I915_EXEC_FENCE_OUT. + */ +#define I915_PARAM_HAS_EXEC_FENCE 44 typedef struct drm_i915_getparam { __s32 param; @@ -703,15 +755,41 @@ struct drm_i915_gem_exec_object2 { */ __u64 offset; -#define EXEC_OBJECT_NEEDS_FENCE (1<<0) -#define EXEC_OBJECT_NEEDS_GTT (1<<1) -#define EXEC_OBJECT_WRITE (1<<2) +#define EXEC_OBJECT_NEEDS_FENCE (1<<0) +#define EXEC_OBJECT_NEEDS_GTT (1<<1) +#define EXEC_OBJECT_WRITE (1<<2) #define EXEC_OBJECT_SUPPORTS_48B_ADDRESS (1<<3) -#define EXEC_OBJECT_PINNED (1<<4) -#define __EXEC_OBJECT_UNKNOWN_FLAGS -(EXEC_OBJECT_PINNED<<1) +#define EXEC_OBJECT_PINNED (1<<4) +#define EXEC_OBJECT_PAD_TO_SIZE (1<<5) +/* The kernel implicitly tracks GPU activity on all GEM objects, and + * synchronises operations with outstanding rendering. This includes + * rendering on other devices if exported via dma-buf. However, sometimes + * this tracking is too coarse and the user knows better. For example, + * if the object is split into non-overlapping ranges shared between different + * clients or engines (i.e. suballocating objects), the implicit tracking + * by kernel assumes that each operation affects the whole object rather + * than an individual range, causing needless synchronisation between clients. + * The kernel will also forgo any CPU cache flushes prior to rendering from + * the object as the client is expected to be also handling such domain + * tracking. + * + * The kernel maintains the implicit tracking in order to manage resources + * used by the GPU - this flag only disables the synchronisation prior to + * rendering with this object in this execbuf. + * + * Opting out of implicit synhronisation requires the user to do its own + * explicit tracking to avoid rendering corruption. See, for example, + * I915_PARAM_HAS_EXEC_FENCE to order execbufs and execute them asynchronously. + */ +#define EXEC_OBJECT_ASYNC (1<<6) +/* All remaining bits are MBZ and RESERVED FOR FUTURE USE */ +#define __EXEC_OBJECT_UNKNOWN_FLAGS -(EXEC_OBJECT_ASYNC<<1) __u64 flags; - __u64 rsvd1; + union { + __u64 rsvd1; + __u64 pad_to_size; + }; __u64 rsvd2; }; @@ -797,7 +875,32 @@ struct drm_i915_gem_execbuffer2 { */ #define I915_EXEC_RESOURCE_STREAMER (1<<15) -#define __I915_EXEC_UNKNOWN_FLAGS -(I915_EXEC_RESOURCE_STREAMER<<1) +/* Setting I915_EXEC_FENCE_IN implies that lower_32_bits(rsvd2) represent + * a sync_file fd to wait upon (in a nonblocking manner) prior to executing + * the batch. + * + * Returns -EINVAL if the sync_file fd cannot be found. + */ +#define I915_EXEC_FENCE_IN (1<<16) + +/* Setting I915_EXEC_FENCE_OUT causes the ioctl to return a sync_file fd + * in the upper_32_bits(rsvd2) upon success. Ownership of the fd is given + * to the caller, and it should be close() after use. (The fd is a regular + * file descriptor and will be cleaned up on process termination. It holds + * a reference to the request, but nothing else.) + * + * The sync_file fd can be combined with other sync_file and passed either + * to execbuf using I915_EXEC_FENCE_IN, to atomic KMS ioctls (so that a flip + * will only occur after this request completes), or to other devices. + * + * Using I915_EXEC_FENCE_OUT requires use of + * DRM_IOCTL_I915_GEM_EXECBUFFER2_WR ioctl so that the result is written + * back to userspace. Failure to do so will cause the out-fence to always + * be reported as zero, and the real fence fd to be leaked. + */ +#define I915_EXEC_FENCE_OUT (1<<17) + +#define __I915_EXEC_UNKNOWN_FLAGS (-(I915_EXEC_FENCE_OUT<<1)) #define I915_EXEC_CONTEXT_ID_MASK (0xffffffff) #define i915_execbuffer2_set_context_id(eb2, context) \ @@ -833,7 +936,16 @@ struct drm_i915_gem_busy { * having flushed any pending activity), and a non-zero return that * the object is still in-flight on the GPU. (The GPU has not yet * signaled completion for all pending requests that reference the - * object.) + * object.) An object is guaranteed to become idle eventually (so + * long as no new GPU commands are executed upon it). Due to the + * asynchronous nature of the hardware, an object reported + * as busy may become idle before the ioctl is completed. + * + * Furthermore, if the object is busy, which engine is busy is only + * provided as a guide. There are race conditions which prevent the + * report of which engines are busy from being always accurate. + * However, the converse is not true. If the object is idle, the + * result of the ioctl, that all engines are idle, is accurate. * * The returned dword is split into two fields to indicate both * the engines on which the object is being read, and the @@ -856,6 +968,11 @@ struct drm_i915_gem_busy { * execution engines, e.g. multiple media engines, which are * mapped to the same identifier in the EXECBUFFER2 ioctl and * so are not separately reported for busyness. + * + * Caveat emptor: + * Only the boolean result of this query is reliable; that is whether + * the object is idle or busy. The report of which engines are busy + * should be only used as a heuristic. */ __u32 busy; }; @@ -904,6 +1021,7 @@ struct drm_i915_gem_caching { #define I915_TILING_NONE 0 #define I915_TILING_X 1 #define I915_TILING_Y 2 +#define I915_TILING_LAST I915_TILING_Y #define I915_BIT_6_SWIZZLE_NONE 0 #define I915_BIT_6_SWIZZLE_9 1 @@ -1180,7 +1298,145 @@ struct drm_i915_gem_context_param { #define I915_CONTEXT_PARAM_BAN_PERIOD 0x1 #define I915_CONTEXT_PARAM_NO_ZEROMAP 0x2 #define I915_CONTEXT_PARAM_GTT_SIZE 0x3 +#define I915_CONTEXT_PARAM_NO_ERROR_CAPTURE 0x4 +#define I915_CONTEXT_PARAM_BANNABLE 0x5 __u64 value; }; +enum drm_i915_oa_format { + I915_OA_FORMAT_A13 = 1, + I915_OA_FORMAT_A29, + I915_OA_FORMAT_A13_B8_C8, + I915_OA_FORMAT_B4_C8, + I915_OA_FORMAT_A45_B8_C8, + I915_OA_FORMAT_B4_C8_A16, + I915_OA_FORMAT_C4_B8, + + I915_OA_FORMAT_MAX /* non-ABI */ +}; + +enum drm_i915_perf_property_id { + /** + * Open the stream for a specific context handle (as used with + * execbuffer2). A stream opened for a specific context this way + * won't typically require root privileges. + */ + DRM_I915_PERF_PROP_CTX_HANDLE = 1, + + /** + * A value of 1 requests the inclusion of raw OA unit reports as + * part of stream samples. + */ + DRM_I915_PERF_PROP_SAMPLE_OA, + + /** + * The value specifies which set of OA unit metrics should be + * be configured, defining the contents of any OA unit reports. + */ + DRM_I915_PERF_PROP_OA_METRICS_SET, + + /** + * The value specifies the size and layout of OA unit reports. + */ + DRM_I915_PERF_PROP_OA_FORMAT, + + /** + * Specifying this property implicitly requests periodic OA unit + * sampling and (at least on Haswell) the sampling frequency is derived + * from this exponent as follows: + * + * 80ns * 2^(period_exponent + 1) + */ + DRM_I915_PERF_PROP_OA_EXPONENT, + + DRM_I915_PERF_PROP_MAX /* non-ABI */ +}; + +struct drm_i915_perf_open_param { + __u32 flags; +#define I915_PERF_FLAG_FD_CLOEXEC (1<<0) +#define I915_PERF_FLAG_FD_NONBLOCK (1<<1) +#define I915_PERF_FLAG_DISABLED (1<<2) + + /** The number of u64 (id, value) pairs */ + __u32 num_properties; + + /** + * Pointer to array of u64 (id, value) pairs configuring the stream + * to open. + */ + __u64 properties_ptr; +}; + +/** + * Enable data capture for a stream that was either opened in a disabled state + * via I915_PERF_FLAG_DISABLED or was later disabled via + * I915_PERF_IOCTL_DISABLE. + * + * It is intended to be cheaper to disable and enable a stream than it may be + * to close and re-open a stream with the same configuration. + * + * It's undefined whether any pending data for the stream will be lost. + */ +#define I915_PERF_IOCTL_ENABLE _IO('i', 0x0) + +/** + * Disable data capture for a stream. + * + * It is an error to try and read a stream that is disabled. + */ +#define I915_PERF_IOCTL_DISABLE _IO('i', 0x1) + +/** + * Common to all i915 perf records + */ +struct drm_i915_perf_record_header { + __u32 type; + __u16 pad; + __u16 size; +}; + +enum drm_i915_perf_record_type { + + /** + * Samples are the work horse record type whose contents are extensible + * and defined when opening an i915 perf stream based on the given + * properties. + * + * Boolean properties following the naming convention + * DRM_I915_PERF_SAMPLE_xyz_PROP request the inclusion of 'xyz' data in + * every sample. + * + * The order of these sample properties given by userspace has no + * affect on the ordering of data within a sample. The order is + * documented here. + * + * struct { + * struct drm_i915_perf_record_header header; + * + * { u32 oa_report[]; } && DRM_I915_PERF_PROP_SAMPLE_OA + * }; + */ + DRM_I915_PERF_RECORD_SAMPLE = 1, + + /* + * Indicates that one or more OA reports were not written by the + * hardware. This can happen for example if an MI_REPORT_PERF_COUNT + * command collides with periodic sampling - which would be more likely + * at higher sampling frequencies. + */ + DRM_I915_PERF_RECORD_OA_REPORT_LOST = 2, + + /** + * An error occurred that resulted in all pending OA reports being lost. + */ + DRM_I915_PERF_RECORD_OA_BUFFER_LOST = 3, + + DRM_I915_PERF_RECORD_MAX /* non-ABI */ +}; + +#if defined(__cplusplus) +} +#endif + #endif /* _I915_DRM_H_ */ diff --git a/lib/libdrm/intel/Makefile.am b/lib/libdrm/intel/Makefile.am index c52e8c086..15707ad42 100644 --- a/lib/libdrm/intel/Makefile.am +++ b/lib/libdrm/intel/Makefile.am @@ -68,6 +68,7 @@ EXTRA_DIST = \ tests/test-batch.sh \ $(TESTS) -test_decode_LDADD = libdrm_intel.la ../libdrm.la +test_decode_LDADD = libdrm_intel.la ../libdrm.la \ + -lpthread pkgconfig_DATA = libdrm_intel.pc diff --git a/lib/libdrm/intel/Makefile.in b/lib/libdrm/intel/Makefile.in index bb27f5bd4..813e99cf6 100644 --- a/lib/libdrm/intel/Makefile.in +++ b/lib/libdrm/intel/Makefile.in @@ -245,8 +245,6 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ -LIBUDEV_LIBS = @LIBUDEV_LIBS@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ @@ -397,7 +395,9 @@ EXTRA_DIST = \ tests/test-batch.sh \ $(TESTS) -test_decode_LDADD = libdrm_intel.la ../libdrm.la +test_decode_LDADD = libdrm_intel.la ../libdrm.la \ + -lpthread + pkgconfig_DATA = libdrm_intel.pc all: all-am diff --git a/lib/libdrm/intel/intel_bufmgr.h b/lib/libdrm/intel/intel_bufmgr.h index ce4e70d51..693472a52 100644 --- a/lib/libdrm/intel/intel_bufmgr.h +++ b/lib/libdrm/intel/intel_bufmgr.h @@ -184,6 +184,11 @@ int drm_intel_gem_bo_map_unsynchronized(drm_intel_bo *bo); int drm_intel_gem_bo_map_gtt(drm_intel_bo *bo); int drm_intel_gem_bo_unmap_gtt(drm_intel_bo *bo); +#define HAVE_DRM_INTEL_GEM_BO_DISABLE_IMPLICIT_SYNC 1 +int drm_intel_bufmgr_gem_can_disable_implicit_sync(drm_intel_bufmgr *bufmgr); +void drm_intel_gem_bo_disable_implicit_sync(drm_intel_bo *bo); +void drm_intel_gem_bo_enable_implicit_sync(drm_intel_bo *bo); + void *drm_intel_gem_bo_map__cpu(drm_intel_bo *bo); void *drm_intel_gem_bo_map__gtt(drm_intel_bo *bo); void *drm_intel_gem_bo_map__wc(drm_intel_bo *bo); @@ -212,9 +217,17 @@ int drm_intel_bufmgr_gem_get_devid(drm_intel_bufmgr *bufmgr); int drm_intel_gem_bo_wait(drm_intel_bo *bo, int64_t timeout_ns); drm_intel_context *drm_intel_gem_context_create(drm_intel_bufmgr *bufmgr); +int drm_intel_gem_context_get_id(drm_intel_context *ctx, + uint32_t *ctx_id); void drm_intel_gem_context_destroy(drm_intel_context *ctx); int drm_intel_gem_bo_context_exec(drm_intel_bo *bo, drm_intel_context *ctx, int used, unsigned int flags); +int drm_intel_gem_bo_fence_exec(drm_intel_bo *bo, + drm_intel_context *ctx, + int used, + int in_fence, + int *out_fence, + unsigned int flags); int drm_intel_bo_gem_export_to_prime(drm_intel_bo *bo, int *prime_fd); drm_intel_bo *drm_intel_bo_gem_create_from_prime(drm_intel_bufmgr *bufmgr, diff --git a/lib/libdrm/intel/intel_bufmgr_fake.c b/lib/libdrm/intel/intel_bufmgr_fake.c index 24b3732aa..641df6a1e 100644 --- a/lib/libdrm/intel/intel_bufmgr_fake.c +++ b/lib/libdrm/intel/intel_bufmgr_fake.c @@ -737,7 +737,7 @@ drm_intel_bufmgr_fake_wait_idle(drm_intel_bufmgr_fake *bufmgr_fake) /** * Wait for rendering to a buffer to complete. * - * It is assumed that the bathcbuffer which performed the rendering included + * It is assumed that the batchbuffer which performed the rendering included * the necessary flushing. */ static void @@ -1200,7 +1200,7 @@ static int assert(!(bo_fake->flags & (BM_NO_BACKING_STORE | BM_PINNED))); /* Actually, should be able to just wait for a fence on the - * mmory, hich we would be tracking when we free it. Waiting + * memory, which we would be tracking when we free it. Waiting * for idle is a sufficiently large hammer for now. */ drm_intel_bufmgr_fake_wait_idle(bufmgr_fake); diff --git a/lib/libdrm/intel/intel_bufmgr_gem.c b/lib/libdrm/intel/intel_bufmgr_gem.c index f5dd76303..f6f879686 100644 --- a/lib/libdrm/intel/intel_bufmgr_gem.c +++ b/lib/libdrm/intel/intel_bufmgr_gem.c @@ -151,6 +151,7 @@ typedef struct _drm_intel_bufmgr_gem { unsigned int bo_reuse : 1; unsigned int no_exec : 1; unsigned int has_vebox : 1; + unsigned int has_exec_async : 1; bool fenced_relocs; struct { @@ -197,6 +198,8 @@ struct _drm_intel_bo_gem { uint32_t swizzle_mode; unsigned long stride; + unsigned long kflags; + time_t free_time; /** Array passed to the DRM containing relocation information. */ @@ -258,7 +261,7 @@ struct _drm_intel_bo_gem { * Boolean of whether the GPU is definitely not accessing the buffer. * * This is only valid when reusable, since non-reusable - * buffers are those that have been shared wth other + * buffers are those that have been shared with other * processes, so we don't know their state. */ bool idle; @@ -296,7 +299,7 @@ struct _drm_intel_bo_gem { */ int reloc_tree_fences; - /** Flags that we may need to do the SW_FINSIH ioctl on unmap. */ + /** Flags that we may need to do the SW_FINISH ioctl on unmap. */ bool mapped_cpu_write; }; @@ -579,12 +582,11 @@ drm_intel_add_validate_buffer2(drm_intel_bo *bo, int need_fence) bufmgr_gem->exec2_objects[index].relocation_count = bo_gem->reloc_count; bufmgr_gem->exec2_objects[index].relocs_ptr = (uintptr_t)bo_gem->relocs; bufmgr_gem->exec2_objects[index].alignment = bo->align; - bufmgr_gem->exec2_objects[index].offset = bo_gem->is_softpin ? - bo->offset64 : 0; - bufmgr_gem->exec_bos[index] = bo; - bufmgr_gem->exec2_objects[index].flags = flags; + bufmgr_gem->exec2_objects[index].offset = bo->offset64; + bufmgr_gem->exec2_objects[index].flags = flags | bo_gem->kflags; bufmgr_gem->exec2_objects[index].rsvd1 = 0; bufmgr_gem->exec2_objects[index].rsvd2 = 0; + bufmgr_gem->exec_bos[index] = bo; bufmgr_gem->exec_count++; } @@ -1372,6 +1374,7 @@ drm_intel_gem_bo_unreference_final(drm_intel_bo *bo, time_t time) for (i = 0; i < bo_gem->softpin_target_count; i++) drm_intel_gem_bo_unreference_locked_timed(bo_gem->softpin_target[i], time); + bo_gem->kflags = 0; bo_gem->reloc_count = 0; bo_gem->used_as_reloc_target = false; bo_gem->softpin_target_count = 0; @@ -1412,6 +1415,8 @@ drm_intel_gem_bo_unreference_final(drm_intel_bo *bo, time_t time) bo_gem->name = NULL; bo_gem->validate_index = -1; + bo_gem->kflags = 0; + DRMLISTADDTAIL(&bo_gem->head, &bucket->head); } else { drm_intel_gem_bo_free(bo); @@ -1723,7 +1728,7 @@ static int drm_intel_gem_bo_unmap(drm_intel_bo *bo) } /* We need to unmap after every innovation as we cannot track - * an open vma for every bo as that will exhaasut the system + * an open vma for every bo as that will exhaust the system * limits and cause later failures. */ if (--bo_gem->map_count == 0) { @@ -2385,6 +2390,7 @@ drm_intel_gem_bo_exec(drm_intel_bo *bo, int used, static int do_exec2(drm_intel_bo *bo, int used, drm_intel_context *ctx, drm_clip_rect_t *cliprects, int num_cliprects, int DR4, + int in_fence, int *out_fence, unsigned int flags) { drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *)bo->bufmgr; @@ -2441,12 +2447,20 @@ do_exec2(drm_intel_bo *bo, int used, drm_intel_context *ctx, else i915_execbuffer2_set_context_id(execbuf, ctx->ctx_id); execbuf.rsvd2 = 0; + if (in_fence != -1) { + execbuf.rsvd2 = in_fence; + execbuf.flags |= I915_EXEC_FENCE_IN; + } + if (out_fence != NULL) { + *out_fence = -1; + execbuf.flags |= I915_EXEC_FENCE_OUT; + } if (bufmgr_gem->no_exec) goto skip_execution; ret = drmIoctl(bufmgr_gem->fd, - DRM_IOCTL_I915_GEM_EXECBUFFER2, + DRM_IOCTL_I915_GEM_EXECBUFFER2_WR, &execbuf); if (ret != 0) { ret = -errno; @@ -2462,6 +2476,9 @@ do_exec2(drm_intel_bo *bo, int used, drm_intel_context *ctx, } drm_intel_update_buffer_offsets2(bufmgr_gem); + if (ret == 0 && out_fence != NULL) + *out_fence = execbuf.rsvd2 >> 32; + skip_execution: if (bufmgr_gem->bufmgr.debug) drm_intel_gem_dump_validation_list(bufmgr_gem); @@ -2487,7 +2504,7 @@ drm_intel_gem_bo_exec2(drm_intel_bo *bo, int used, int DR4) { return do_exec2(bo, used, NULL, cliprects, num_cliprects, DR4, - I915_EXEC_RENDER); + -1, NULL, I915_EXEC_RENDER); } static int @@ -2496,14 +2513,25 @@ drm_intel_gem_bo_mrb_exec2(drm_intel_bo *bo, int used, unsigned int flags) { return do_exec2(bo, used, NULL, cliprects, num_cliprects, DR4, - flags); + -1, NULL, flags); } int drm_intel_gem_bo_context_exec(drm_intel_bo *bo, drm_intel_context *ctx, int used, unsigned int flags) { - return do_exec2(bo, used, ctx, NULL, 0, 0, flags); + return do_exec2(bo, used, ctx, NULL, 0, 0, -1, NULL, flags); +} + +int +drm_intel_gem_bo_fence_exec(drm_intel_bo *bo, + drm_intel_context *ctx, + int used, + int in_fence, + int *out_fence, + unsigned int flags) +{ + return do_exec2(bo, used, ctx, NULL, 0, 0, in_fence, out_fence, flags); } static int @@ -2750,11 +2778,12 @@ drm_intel_gem_bo_flink(drm_intel_bo *bo, uint32_t * name) pthread_mutex_lock(&bufmgr_gem->lock); if (!bo_gem->global_name) { + bo_gem->global_name = flink.name; + bo_gem->reusable = false; + HASH_ADD(name_hh, bufmgr_gem->name_table, global_name, sizeof(bo_gem->global_name), bo_gem); - bo_gem->global_name = flink.name; - bo_gem->reusable = false; } pthread_mutex_unlock(&bufmgr_gem->lock); } @@ -2778,6 +2807,59 @@ drm_intel_bufmgr_gem_enable_reuse(drm_intel_bufmgr *bufmgr) bufmgr_gem->bo_reuse = true; } +/** + * Disables implicit synchronisation before executing the bo + * + * This will cause rendering corruption unless you correctly manage explicit + * fences for all rendering involving this buffer - including use by others. + * Disabling the implicit serialisation is only required if that serialisation + * is too coarse (for example, you have split the buffer into many + * non-overlapping regions and are sharing the whole buffer between concurrent + * independent command streams). + * + * Note the kernel must advertise support via I915_PARAM_HAS_EXEC_ASYNC, + * which can be checked using drm_intel_bufmgr_can_disable_implicit_sync, + * or subsequent execbufs involving the bo will generate EINVAL. + */ +void +drm_intel_gem_bo_disable_implicit_sync(drm_intel_bo *bo) +{ + drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo; + + bo_gem->kflags |= EXEC_OBJECT_ASYNC; +} + +/** + * Enables implicit synchronisation before executing the bo + * + * This is the default behaviour of the kernel, to wait upon prior writes + * completing on the object before rendering with it, or to wait for prior + * reads to complete before writing into the object. + * drm_intel_gem_bo_disable_implicit_sync() can stop this behaviour, telling + * the kernel never to insert a stall before using the object. Then this + * function can be used to restore the implicit sync before subsequent + * rendering. + */ +void +drm_intel_gem_bo_enable_implicit_sync(drm_intel_bo *bo) +{ + drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo; + + bo_gem->kflags &= ~EXEC_OBJECT_ASYNC; +} + +/** + * Query whether the kernel supports disabling of its implicit synchronisation + * before execbuf. See drm_intel_gem_bo_disable_implicit_sync() + */ +int +drm_intel_bufmgr_gem_can_disable_implicit_sync(drm_intel_bufmgr *bufmgr) +{ + drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *) bufmgr; + + return bufmgr_gem->has_exec_async; +} + /** * Enable use of fenced reloc type. * @@ -3198,6 +3280,17 @@ drm_intel_gem_context_create(drm_intel_bufmgr *bufmgr) return context; } +int +drm_intel_gem_context_get_id(drm_intel_context *ctx, uint32_t *ctx_id) +{ + if (ctx == NULL) + return -EINVAL; + + *ctx_id = ctx->ctx_id; + + return 0; +} + void drm_intel_gem_context_destroy(drm_intel_context *ctx) { @@ -3641,6 +3734,10 @@ drm_intel_bufmgr_gem_init(int fd, int batch_size) ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_I915_GETPARAM, &gp); bufmgr_gem->has_relaxed_fencing = ret == 0; + gp.param = I915_PARAM_HAS_EXEC_ASYNC; + ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_I915_GETPARAM, &gp); + bufmgr_gem->has_exec_async = ret == 0; + bufmgr_gem->bufmgr.bo_alloc_userptr = check_bo_alloc_userptr; gp.param = I915_PARAM_HAS_WAIT_TIMEOUT; diff --git a/lib/libdrm/intel/intel_chipset.h b/lib/libdrm/intel/intel_chipset.h index 514f6594a..41fc0da06 100644 --- a/lib/libdrm/intel/intel_chipset.h +++ b/lib/libdrm/intel/intel_chipset.h @@ -218,6 +218,9 @@ #define PCI_CHIP_BROXTON_3 0x1A85 #define PCI_CHIP_BROXTON_4 0x5A85 +#define PCI_CHIP_GLK 0x3184 +#define PCI_CHIP_GLK_2X6 0x3185 + #define IS_MOBILE(devid) ((devid) == PCI_CHIP_I855_GM || \ (devid) == PCI_CHIP_I915_GM || \ (devid) == PCI_CHIP_I945_GM || \ @@ -446,9 +449,13 @@ (devid) == PCI_CHIP_BROXTON_3 || \ (devid) == PCI_CHIP_BROXTON_4) -#define IS_GEN9(devid) (IS_SKYLAKE(devid) || \ - IS_BROXTON(devid) || \ - IS_KABYLAKE(devid)) +#define IS_GEMINILAKE(devid) ((devid) == PCI_CHIP_GLK || \ + (devid) == PCI_CHIP_GLK_2X6) + +#define IS_GEN9(devid) (IS_SKYLAKE(devid) || \ + IS_BROXTON(devid) || \ + IS_KABYLAKE(devid) || \ + IS_GEMINILAKE(devid)) #define IS_9XX(dev) (IS_GEN3(dev) || \ IS_GEN4(dev) || \ diff --git a/lib/libdrm/libkms/Makefile.in b/lib/libdrm/libkms/Makefile.in index c750eee44..7b9c65eef 100644 --- a/lib/libdrm/libkms/Makefile.in +++ b/lib/libdrm/libkms/Makefile.in @@ -228,8 +228,6 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ -LIBUDEV_LIBS = @LIBUDEV_LIBS@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ @@ -359,10 +357,6 @@ libkms_la_LTLIBRARIES = libkms.la libkms_ladir = $(libdir) libkms_la_LDFLAGS = -version-number 1:0:0 -no-undefined libkms_la_LIBADD = ../libdrm.la - -#if HAVE_LIBUDEV -#libkms_la_LIBADD += $(LIBUDEV_LIBS) -#endif libkms_la_SOURCES = $(LIBKMS_FILES) $(am__append_1) $(am__append_2) \ $(am__append_3) $(am__append_4) $(am__append_5) libkmsincludedir = ${includedir}/libkms diff --git a/lib/libdrm/libkms/linux.c b/lib/libdrm/libkms/linux.c index 69eb1aa47..0b50777ef 100644 --- a/lib/libdrm/libkms/linux.c +++ b/lib/libdrm/libkms/linux.c @@ -141,105 +141,11 @@ linux_from_sysfs(int fd, struct kms_driver **out) return ret; } -#if 0 -#define LIBUDEV_I_KNOW_THE_API_IS_SUBJECT_TO_CHANGE -#include - -struct create_record -{ - unsigned vendor; - unsigned chip; - int (*func)(int fd, struct kms_driver **out); -}; - -static const struct create_record table[] = { - { 0x8086, 0x2a42, intel_create }, /* i965 */ -#ifdef HAVE_VMWGFX - { 0x15ad, 0x0405, vmwgfx_create }, /* VMware vGPU */ -#endif - { 0, 0, NULL }, -}; - -static int -linux_get_pciid_from_fd(int fd, unsigned *vendor_id, unsigned *chip_id) -{ - struct udev *udev; - struct udev_device *device; - struct udev_device *parent; - const char *pci_id; - struct stat buffer; - int ret; - - ret = fstat(fd, &buffer); - if (ret) - return -EINVAL; - - if (!S_ISCHR(buffer.st_mode)) - return -EINVAL; - - udev = udev_new(); - if (!udev) - return -ENOMEM; - - device = udev_device_new_from_devnum(udev, 'c', buffer.st_rdev); - if (!device) - goto err_free_udev; - - parent = udev_device_get_parent(device); - if (!parent) - goto err_free_device; - - pci_id = udev_device_get_property_value(parent, "PCI_ID"); - if (!pci_id) - goto err_free_device; - - if (sscanf(pci_id, "%x:%x", vendor_id, chip_id) != 2) - goto err_free_device; - - udev_device_unref(device); - udev_unref(udev); - - return 0; - -err_free_device: - udev_device_unref(device); -err_free_udev: - udev_unref(udev); - return -EINVAL; -} - -static int -linux_from_udev(int fd, struct kms_driver **out) -{ - unsigned vendor_id, chip_id; - int ret, i; - - ret = linux_get_pciid_from_fd(fd, &vendor_id, &chip_id); - if (ret) - return ret; - - for (i = 0; table[i].func; i++) - if (table[i].vendor == vendor_id && table[i].chip == chip_id) - return table[i].func(fd, out); - - return -ENOSYS; -} -#else -static int -linux_from_udev(int fd, struct kms_driver **out) -{ - return -ENOSYS; -} -#endif - drm_private int linux_create(int fd, struct kms_driver **out) { if (!dumb_create(fd, out)) return 0; - if (!linux_from_udev(fd, out)) - return 0; - return linux_from_sysfs(fd, out); } diff --git a/lib/libdrm/libsync.h b/lib/libdrm/libsync.h index f1a2f96d3..e1aac628a 100644 --- a/lib/libdrm/libsync.h +++ b/lib/libdrm/libsync.h @@ -75,7 +75,7 @@ static inline int sync_wait(int fd, int timeout) } return 0; } else if (ret == 0) { - errno = ETIME; + errno = ETIMEDOUT; return -1; } } while (ret == -1 && (errno == EINTR || errno == EAGAIN)); diff --git a/lib/libdrm/man/Makefile.in b/lib/libdrm/man/Makefile.in index 097c52ecc..f779f6692 100644 --- a/lib/libdrm/man/Makefile.in +++ b/lib/libdrm/man/Makefile.in @@ -169,8 +169,6 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ -LIBUDEV_LIBS = @LIBUDEV_LIBS@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ diff --git a/lib/libdrm/nouveau/Makefile.in b/lib/libdrm/nouveau/Makefile.in index e738f3462..2f93b277d 100644 --- a/lib/libdrm/nouveau/Makefile.in +++ b/lib/libdrm/nouveau/Makefile.in @@ -213,8 +213,6 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ -LIBUDEV_LIBS = @LIBUDEV_LIBS@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ diff --git a/lib/libdrm/omap/Makefile.in b/lib/libdrm/omap/Makefile.in index 92ce341d7..1fdeda126 100644 --- a/lib/libdrm/omap/Makefile.in +++ b/lib/libdrm/omap/Makefile.in @@ -212,8 +212,6 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ -LIBUDEV_LIBS = @LIBUDEV_LIBS@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ diff --git a/lib/libdrm/radeon/Makefile.in b/lib/libdrm/radeon/Makefile.in index f75d56daa..8c0bf157d 100644 --- a/lib/libdrm/radeon/Makefile.in +++ b/lib/libdrm/radeon/Makefile.in @@ -235,8 +235,6 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ -LIBUDEV_LIBS = @LIBUDEV_LIBS@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ diff --git a/lib/libdrm/radeon/radeon_cs_gem.c b/lib/libdrm/radeon/radeon_cs_gem.c index 23f33af4c..f3dccb6c2 100644 --- a/lib/libdrm/radeon/radeon_cs_gem.c +++ b/lib/libdrm/radeon/radeon_cs_gem.c @@ -189,7 +189,7 @@ static int cs_gem_write_reloc(struct radeon_cs_int *cs, /* check domains */ if ((read_domain && write_domain) || (!read_domain && !write_domain)) { /* in one CS a bo can only be in read or write domain but not - * in read & write domain at the same sime + * in read & write domain at the same time */ return -EINVAL; } @@ -242,7 +242,7 @@ static int cs_gem_write_reloc(struct radeon_cs_int *cs, } /* new relocation */ if (csg->base.crelocs >= csg->nrelocs) { - /* allocate more memory (TODO: should use a slab allocatore maybe) */ + /* allocate more memory (TODO: should use a slab allocator maybe) */ uint32_t *tmp, size; size = ((csg->nrelocs + 1) * sizeof(struct radeon_bo*)); tmp = (uint32_t*)realloc(csg->relocs_bo, size); @@ -268,7 +268,7 @@ static int cs_gem_write_reloc(struct radeon_cs_int *cs, reloc->flags = flags; csg->chunks[1].length_dw += RELOC_SIZE; radeon_bo_ref(bo); - /* bo might be referenced from another context so have to use atomic opertions */ + /* bo might be referenced from another context so have to use atomic operations */ atomic_add((atomic_t *)radeon_gem_get_reloc_in_cs(bo), cs->id); cs->relocs_total_size += boi->size; radeon_cs_write_dword((struct radeon_cs *)cs, 0xc0001000); @@ -449,7 +449,7 @@ static int cs_gem_emit(struct radeon_cs_int *cs) &csg->cs, sizeof(struct drm_radeon_cs)); for (i = 0; i < csg->base.crelocs; i++) { csg->relocs_bo[i]->space_accounted = 0; - /* bo might be referenced from another context so have to use atomic opertions */ + /* bo might be referenced from another context so have to use atomic operations */ atomic_dec((atomic_t *)radeon_gem_get_reloc_in_cs((struct radeon_bo*)csg->relocs_bo[i]), cs->id); radeon_bo_unref((struct radeon_bo *)csg->relocs_bo[i]); csg->relocs_bo[i] = NULL; @@ -481,7 +481,7 @@ static int cs_gem_erase(struct radeon_cs_int *cs) if (csg->relocs_bo) { for (i = 0; i < csg->base.crelocs; i++) { if (csg->relocs_bo[i]) { - /* bo might be referenced from another context so have to use atomic opertions */ + /* bo might be referenced from another context so have to use atomic operations */ atomic_dec((atomic_t *)radeon_gem_get_reloc_in_cs((struct radeon_bo*)csg->relocs_bo[i]), cs->id); radeon_bo_unref((struct radeon_bo *)csg->relocs_bo[i]); csg->relocs_bo[i] = NULL; diff --git a/lib/libdrm/radeon/radeon_surface.c b/lib/libdrm/radeon/radeon_surface.c index 16a8b00b7..965be24ca 100644 --- a/lib/libdrm/radeon/radeon_surface.c +++ b/lib/libdrm/radeon/radeon_surface.c @@ -981,7 +981,7 @@ static int eg_surface_best(struct radeon_surface_manager *surf_man, /* bankw or bankh greater than 1 increase alignment requirement, not * sure if it's worth using smaller bankw & bankh to stick with 2D * tiling on small surface rather than falling back to 1D tiling. - * Use recommanded value based on tile size for now. + * Use recommended value based on tile size for now. * * fmask buffer has different optimal value figure them out once we * use it. diff --git a/lib/libdrm/tegra/Makefile.in b/lib/libdrm/tegra/Makefile.in index 726f29cb2..394e90ba3 100644 --- a/lib/libdrm/tegra/Makefile.in +++ b/lib/libdrm/tegra/Makefile.in @@ -209,8 +209,6 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ -LIBUDEV_LIBS = @LIBUDEV_LIBS@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ diff --git a/lib/libdrm/tests/Makefile.in b/lib/libdrm/tests/Makefile.in index a622711cf..f84515668 100644 --- a/lib/libdrm/tests/Makefile.in +++ b/lib/libdrm/tests/Makefile.in @@ -55,23 +55,9 @@ host_triplet = @host@ @HAVE_EXYNOS_TRUE@am__append_4 = exynos @HAVE_TEGRA_TRUE@am__append_5 = tegra @HAVE_ETNAVIV_TRUE@am__append_6 = etnaviv -check_PROGRAMS = dristat$(EXEEXT) drmdevice$(EXEEXT) drmstat$(EXEEXT) \ - $(am__EXEEXT_2) @HAVE_NOUVEAU_TRUE@am__append_7 = nouveau -TESTS = drmsl$(EXEEXT) hash$(EXEEXT) random$(EXEEXT) $(am__EXEEXT_1) -@HAVE_LIBUDEV_TRUE@am__append_8 = \ -@HAVE_LIBUDEV_TRUE@ libdrmtest.la \ -@HAVE_LIBUDEV_TRUE@ $(LIBUDEV_LIBS) - -@HAVE_LIBUDEV_TRUE@am__append_9 = \ -@HAVE_LIBUDEV_TRUE@ openclose \ -@HAVE_LIBUDEV_TRUE@ getversion \ -@HAVE_LIBUDEV_TRUE@ getclient \ -@HAVE_LIBUDEV_TRUE@ getstats \ -@HAVE_LIBUDEV_TRUE@ setversion \ -@HAVE_LIBUDEV_TRUE@ updatedraw \ -@HAVE_LIBUDEV_TRUE@ name_from_fd - +TESTS = drmsl$(EXEEXT) hash$(EXEEXT) random$(EXEEXT) +check_PROGRAMS = $(am__EXEEXT_1) drmdevice$(EXEEXT) subdir = tests DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(top_srcdir)/build-aux/depcomp @@ -86,83 +72,27 @@ mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = -libdrmtest_la_LIBADD = -am__libdrmtest_la_SOURCES_DIST = drmtest.c drmtest.h -@HAVE_LIBUDEV_TRUE@am_libdrmtest_la_OBJECTS = drmtest.lo -libdrmtest_la_OBJECTS = $(am_libdrmtest_la_OBJECTS) +am__EXEEXT_1 = drmsl$(EXEEXT) hash$(EXEEXT) random$(EXEEXT) +drmdevice_SOURCES = drmdevice.c +drmdevice_OBJECTS = drmdevice.$(OBJEXT) +drmdevice_LDADD = $(LDADD) +drmdevice_DEPENDENCIES = $(top_builddir)/libdrm.la AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = -@HAVE_LIBUDEV_TRUE@am_libdrmtest_la_rpath = -@HAVE_LIBUDEV_TRUE@am__EXEEXT_1 = openclose$(EXEEXT) \ -@HAVE_LIBUDEV_TRUE@ getversion$(EXEEXT) getclient$(EXEEXT) \ -@HAVE_LIBUDEV_TRUE@ getstats$(EXEEXT) setversion$(EXEEXT) \ -@HAVE_LIBUDEV_TRUE@ updatedraw$(EXEEXT) name_from_fd$(EXEEXT) -am__EXEEXT_2 = drmsl$(EXEEXT) hash$(EXEEXT) random$(EXEEXT) \ - $(am__EXEEXT_1) -dristat_SOURCES = dristat.c -dristat_OBJECTS = dristat.$(OBJEXT) -dristat_DEPENDENCIES = -drmdevice_SOURCES = drmdevice.c -drmdevice_OBJECTS = drmdevice.$(OBJEXT) -drmdevice_LDADD = $(LDADD) -am__DEPENDENCIES_1 = -@HAVE_LIBUDEV_TRUE@am__DEPENDENCIES_2 = libdrmtest.la \ -@HAVE_LIBUDEV_TRUE@ $(am__DEPENDENCIES_1) -drmdevice_DEPENDENCIES = $(top_builddir)/libdrm.la \ - $(am__DEPENDENCIES_2) drmsl_SOURCES = drmsl.c drmsl_OBJECTS = drmsl.$(OBJEXT) drmsl_LDADD = $(LDADD) -drmsl_DEPENDENCIES = $(top_builddir)/libdrm.la $(am__DEPENDENCIES_2) -drmstat_SOURCES = drmstat.c -drmstat_OBJECTS = drmstat.$(OBJEXT) -drmstat_LDADD = $(LDADD) -drmstat_DEPENDENCIES = $(top_builddir)/libdrm.la $(am__DEPENDENCIES_2) -getclient_SOURCES = getclient.c -getclient_OBJECTS = getclient.$(OBJEXT) -getclient_LDADD = $(LDADD) -getclient_DEPENDENCIES = $(top_builddir)/libdrm.la \ - $(am__DEPENDENCIES_2) -getstats_SOURCES = getstats.c -getstats_OBJECTS = getstats.$(OBJEXT) -getstats_LDADD = $(LDADD) -getstats_DEPENDENCIES = $(top_builddir)/libdrm.la \ - $(am__DEPENDENCIES_2) -getversion_SOURCES = getversion.c -getversion_OBJECTS = getversion.$(OBJEXT) -getversion_LDADD = $(LDADD) -getversion_DEPENDENCIES = $(top_builddir)/libdrm.la \ - $(am__DEPENDENCIES_2) +drmsl_DEPENDENCIES = $(top_builddir)/libdrm.la hash_SOURCES = hash.c hash_OBJECTS = hash.$(OBJEXT) hash_LDADD = $(LDADD) -hash_DEPENDENCIES = $(top_builddir)/libdrm.la $(am__DEPENDENCIES_2) -name_from_fd_SOURCES = name_from_fd.c -name_from_fd_OBJECTS = name_from_fd.$(OBJEXT) -name_from_fd_LDADD = $(LDADD) -name_from_fd_DEPENDENCIES = $(top_builddir)/libdrm.la \ - $(am__DEPENDENCIES_2) -openclose_SOURCES = openclose.c -openclose_OBJECTS = openclose.$(OBJEXT) -openclose_LDADD = $(LDADD) -openclose_DEPENDENCIES = $(top_builddir)/libdrm.la \ - $(am__DEPENDENCIES_2) +hash_DEPENDENCIES = $(top_builddir)/libdrm.la random_SOURCES = random.c random_OBJECTS = random.$(OBJEXT) random_LDADD = $(LDADD) -random_DEPENDENCIES = $(top_builddir)/libdrm.la $(am__DEPENDENCIES_2) -setversion_SOURCES = setversion.c -setversion_OBJECTS = setversion.$(OBJEXT) -setversion_LDADD = $(LDADD) -setversion_DEPENDENCIES = $(top_builddir)/libdrm.la \ - $(am__DEPENDENCIES_2) -updatedraw_SOURCES = updatedraw.c -updatedraw_OBJECTS = updatedraw.$(OBJEXT) -updatedraw_LDADD = $(LDADD) -updatedraw_DEPENDENCIES = $(top_builddir)/libdrm.la \ - $(am__DEPENDENCIES_2) +random_DEPENDENCIES = $(top_builddir)/libdrm.la AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -197,12 +127,8 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = -SOURCES = $(libdrmtest_la_SOURCES) dristat.c drmdevice.c drmsl.c \ - drmstat.c getclient.c getstats.c getversion.c hash.c \ - name_from_fd.c openclose.c random.c setversion.c updatedraw.c -DIST_SOURCES = $(am__libdrmtest_la_SOURCES_DIST) dristat.c drmdevice.c \ - drmsl.c drmstat.c getclient.c getstats.c getversion.c hash.c \ - name_from_fd.c openclose.c random.c setversion.c updatedraw.c +SOURCES = drmdevice.c drmsl.c hash.c random.c +DIST_SOURCES = drmdevice.c drmsl.c hash.c random.c RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ @@ -304,8 +230,6 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ -LIBUDEV_LIBS = @LIBUDEV_LIBS@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ @@ -413,17 +337,7 @@ AM_CFLAGS = \ -I $(top_srcdir)/include/drm \ -I $(top_srcdir) -LDADD = $(top_builddir)/libdrm.la $(am__append_8) -dristat_LDADD = -lm -@HAVE_LIBUDEV_TRUE@check_LTLIBRARIES = libdrmtest.la -@HAVE_LIBUDEV_TRUE@libdrmtest_la_SOURCES = \ -@HAVE_LIBUDEV_TRUE@ drmtest.c \ -@HAVE_LIBUDEV_TRUE@ drmtest.h - -@HAVE_LIBUDEV_TRUE@XFAIL_TESTS = \ -@HAVE_LIBUDEV_TRUE@ auth \ -@HAVE_LIBUDEV_TRUE@ lock - +LDADD = $(top_builddir)/libdrm.la all: all-recursive .SUFFIXES: @@ -459,19 +373,6 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): -clean-checkLTLIBRARIES: - -test -z "$(check_LTLIBRARIES)" || rm -f $(check_LTLIBRARIES) - @list='$(check_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } -libdrmtest.la: $(libdrmtest_la_OBJECTS) $(libdrmtest_la_DEPENDENCIES) $(EXTRA_libdrmtest_la_DEPENDENCIES) - $(AM_V_CCLD)$(LINK) $(am_libdrmtest_la_rpath) $(libdrmtest_la_OBJECTS) $(libdrmtest_la_LIBADD) $(LIBS) - clean-checkPROGRAMS: @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ @@ -480,45 +381,18 @@ clean-checkPROGRAMS: list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list -dristat$(EXEEXT): $(dristat_OBJECTS) $(dristat_DEPENDENCIES) $(EXTRA_dristat_DEPENDENCIES) - @rm -f dristat$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(dristat_OBJECTS) $(dristat_LDADD) $(LIBS) drmdevice$(EXEEXT): $(drmdevice_OBJECTS) $(drmdevice_DEPENDENCIES) $(EXTRA_drmdevice_DEPENDENCIES) @rm -f drmdevice$(EXEEXT) $(AM_V_CCLD)$(LINK) $(drmdevice_OBJECTS) $(drmdevice_LDADD) $(LIBS) drmsl$(EXEEXT): $(drmsl_OBJECTS) $(drmsl_DEPENDENCIES) $(EXTRA_drmsl_DEPENDENCIES) @rm -f drmsl$(EXEEXT) $(AM_V_CCLD)$(LINK) $(drmsl_OBJECTS) $(drmsl_LDADD) $(LIBS) -drmstat$(EXEEXT): $(drmstat_OBJECTS) $(drmstat_DEPENDENCIES) $(EXTRA_drmstat_DEPENDENCIES) - @rm -f drmstat$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(drmstat_OBJECTS) $(drmstat_LDADD) $(LIBS) -getclient$(EXEEXT): $(getclient_OBJECTS) $(getclient_DEPENDENCIES) $(EXTRA_getclient_DEPENDENCIES) - @rm -f getclient$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(getclient_OBJECTS) $(getclient_LDADD) $(LIBS) -getstats$(EXEEXT): $(getstats_OBJECTS) $(getstats_DEPENDENCIES) $(EXTRA_getstats_DEPENDENCIES) - @rm -f getstats$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(getstats_OBJECTS) $(getstats_LDADD) $(LIBS) -getversion$(EXEEXT): $(getversion_OBJECTS) $(getversion_DEPENDENCIES) $(EXTRA_getversion_DEPENDENCIES) - @rm -f getversion$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(getversion_OBJECTS) $(getversion_LDADD) $(LIBS) hash$(EXEEXT): $(hash_OBJECTS) $(hash_DEPENDENCIES) $(EXTRA_hash_DEPENDENCIES) @rm -f hash$(EXEEXT) $(AM_V_CCLD)$(LINK) $(hash_OBJECTS) $(hash_LDADD) $(LIBS) -name_from_fd$(EXEEXT): $(name_from_fd_OBJECTS) $(name_from_fd_DEPENDENCIES) $(EXTRA_name_from_fd_DEPENDENCIES) - @rm -f name_from_fd$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(name_from_fd_OBJECTS) $(name_from_fd_LDADD) $(LIBS) -openclose$(EXEEXT): $(openclose_OBJECTS) $(openclose_DEPENDENCIES) $(EXTRA_openclose_DEPENDENCIES) - @rm -f openclose$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(openclose_OBJECTS) $(openclose_LDADD) $(LIBS) random$(EXEEXT): $(random_OBJECTS) $(random_DEPENDENCIES) $(EXTRA_random_DEPENDENCIES) @rm -f random$(EXEEXT) $(AM_V_CCLD)$(LINK) $(random_OBJECTS) $(random_LDADD) $(LIBS) -setversion$(EXEEXT): $(setversion_OBJECTS) $(setversion_DEPENDENCIES) $(EXTRA_setversion_DEPENDENCIES) - @rm -f setversion$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(setversion_OBJECTS) $(setversion_LDADD) $(LIBS) -updatedraw$(EXEEXT): $(updatedraw_OBJECTS) $(updatedraw_DEPENDENCIES) $(EXTRA_updatedraw_DEPENDENCIES) - @rm -f updatedraw$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(updatedraw_OBJECTS) $(updatedraw_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -526,20 +400,10 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dristat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/drmdevice.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/drmsl.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/drmstat.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/drmtest.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getclient.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getstats.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getversion.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hash.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/name_from_fd.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openclose.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/random.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/setversion.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/updatedraw.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -843,7 +707,7 @@ distdir: $(DISTFILES) fi; \ done check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) $(check_LTLIBRARIES) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-recursive all-am: Makefile @@ -881,8 +745,8 @@ maintainer-clean-generic: @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive -clean-am: clean-checkLTLIBRARIES clean-checkPROGRAMS clean-generic \ - clean-libtool mostlyclean-am +clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ + mostlyclean-am distclean: distclean-recursive -rm -rf ./$(DEPDIR) @@ -956,19 +820,19 @@ uninstall-am: .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am check check-TESTS check-am clean \ - clean-checkLTLIBRARIES clean-checkPROGRAMS clean-generic \ - clean-libtool cscopelist cscopelist-recursive ctags \ - ctags-recursive distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags tags-recursive uninstall uninstall-am + clean-checkPROGRAMS clean-generic clean-libtool cscopelist \ + cscopelist-recursive ctags ctags-recursive distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + installdirs-am maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \ + uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. diff --git a/lib/libdrm/tests/amdgpu/Makefile.in b/lib/libdrm/tests/amdgpu/Makefile.in index 1c97c4499..f04891d0a 100644 --- a/lib/libdrm/tests/amdgpu/Makefile.in +++ b/lib/libdrm/tests/amdgpu/Makefile.in @@ -175,8 +175,6 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ -LIBUDEV_LIBS = @LIBUDEV_LIBS@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ diff --git a/lib/libdrm/tests/dristat.c b/lib/libdrm/tests/dristat.c deleted file mode 100644 index cca4b03a5..000000000 --- a/lib/libdrm/tests/dristat.c +++ /dev/null @@ -1,285 +0,0 @@ -/* dristat.c -- - * Created: Mon Jan 15 05:05:07 2001 by faith@acm.org - * - * Copyright 2000 VA Linux Systems, Inc., Fremont, California. - * 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, 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 - * 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: Rickard E. (Rik) Faith - * - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include "xf86drm.h" -#include "xf86drmRandom.c" -#include "xf86drmHash.c" -#include "xf86drm.c" - -#define DRM_VERSION 0x00000001 -#define DRM_MEMORY 0x00000002 -#define DRM_CLIENTS 0x00000004 -#define DRM_STATS 0x00000008 -#define DRM_BUSID 0x00000010 - -static void getversion(int fd) -{ - drmVersionPtr version; - - version = drmGetVersion(fd); - if (version) { - printf(" Version information:\n"); - printf(" Name: %s\n", version->name ? version->name : "?"); - printf(" Version: %d.%d.%d\n", - version->version_major, - version->version_minor, - version->version_patchlevel); - printf(" Date: %s\n", version->date ? version->date : "?"); - printf(" Desc: %s\n", version->desc ? version->desc : "?"); - drmFreeVersion(version); - } else { - printf(" No version information available\n"); - } -} - -static void getbusid(int fd) -{ - const char *busid = drmGetBusid(fd); - - printf(" Busid: %s\n", *busid ? busid : "(not set)"); - drmFreeBusid(busid); -} - - -static void getvm(int fd) -{ - int i; - const char *typename; - char flagname[33]; - drm_handle_t offset; - drmSize size; - drmMapType type; - drmMapFlags flags; - drm_handle_t handle; - int mtrr; - - printf(" VM map information:\n"); - printf(" flags: (R)estricted (r)ead/(w)rite (l)ocked (k)ernel (W)rite-combine (L)ock:\n"); - printf(" slot offset size type flags address mtrr\n"); - - for (i = 0; - !drmGetMap(fd, i, &offset, &size, &type, &flags, &handle, &mtrr); - i++) { - - switch (type) { - case DRM_FRAME_BUFFER: typename = "FB"; break; - case DRM_REGISTERS: typename = "REG"; break; - case DRM_SHM: typename = "SHM"; break; - case DRM_AGP: typename = "AGP"; break; - case DRM_SCATTER_GATHER: typename = "SG"; break; - case DRM_CONSISTENT: typename = "CON"; break; - default: typename = "???"; break; - } - - flagname[0] = (flags & DRM_RESTRICTED) ? 'R' : ' '; - flagname[1] = (flags & DRM_READ_ONLY) ? 'r' : 'w'; - flagname[2] = (flags & DRM_LOCKED) ? 'l' : ' '; - flagname[3] = (flags & DRM_KERNEL) ? 'k' : ' '; - flagname[4] = (flags & DRM_WRITE_COMBINING) ? 'W' : ' '; - flagname[5] = (flags & DRM_CONTAINS_LOCK) ? 'L' : ' '; - flagname[6] = '\0'; - - printf(" %4d 0x%08lx 0x%08lx %3.3s %6.6s 0x%08lx ", - i, (unsigned long)offset, (unsigned long)size, - typename, flagname, (unsigned long)handle); - if (mtrr < 0) printf("none\n"); - else printf("%4d\n", mtrr); - } -} - -static void getclients(int fd) -{ - int i; - int auth; - int pid; - int uid; - unsigned long magic; - unsigned long iocs; - char buf[64]; - char cmd[40]; - int procfd; - - printf(" DRI client information:\n"); - printf(" a pid uid magic ioctls prog\n"); - - for (i = 0; !drmGetClient(fd, i, &auth, &pid, &uid, &magic, &iocs); i++) { - sprintf(buf, "/proc/%d/cmdline", pid); - memset(cmd, 0, sizeof(cmd)); - if ((procfd = open(buf, O_RDONLY, 0)) >= 0) { - read(procfd, cmd, sizeof(cmd)-1); - close(procfd); - } - if (*cmd) { - char *pt; - - for (pt = cmd; *pt; pt++) if (!isprint(*pt)) *pt = ' '; - printf(" %c %5d %5d %10lu %10lu %s\n", - auth ? 'y' : 'n', pid, uid, magic, iocs, cmd); - } else { - printf(" %c %5d %5d %10lu %10lu\n", - auth ? 'y' : 'n', pid, uid, magic, iocs); - } - } -} - -static void printhuman(unsigned long value, const char *name, int mult) -{ - const char *p; - double f; - /* Print width 5 number in width 6 space */ - if (value < 100000) { - printf(" %5lu", value); - return; - } - - p = name; - f = (double)value / (double)mult; - if (f < 10.0) { - printf(" %4.2f%c", f, *p); - return; - } - - p++; - f = (double)value / (double)mult; - if (f < 10.0) { - printf(" %4.2f%c", f, *p); - return; - } - - p++; - f = (double)value / (double)mult; - if (f < 10.0) { - printf(" %4.2f%c", f, *p); - return; - } -} - -static void getstats(int fd, int i) -{ - drmStatsT prev, curr; - unsigned j; - double rate; - - printf(" System statistics:\n"); - - if (drmGetStats(fd, &prev)) return; - if (!i) { - for (j = 0; j < prev.count; j++) { - printf(" "); - printf(prev.data[j].long_format, prev.data[j].long_name); - if (prev.data[j].isvalue) printf(" 0x%08lx\n", prev.data[j].value); - else printf(" %10lu\n", prev.data[j].value); - } - return; - } - - printf(" "); - for (j = 0; j < prev.count; j++) - if (!prev.data[j].verbose) { - printf(" "); - printf(prev.data[j].rate_format, prev.data[j].rate_name); - } - printf("\n"); - - for (;;) { - sleep(i); - if (drmGetStats(fd, &curr)) return; - printf(" "); - for (j = 0; j < curr.count; j++) { - if (curr.data[j].verbose) continue; - if (curr.data[j].isvalue) { - printf(" %08lx", curr.data[j].value); - } else { - rate = (curr.data[j].value - prev.data[j].value) / (double)i; - printhuman(rate, curr.data[j].mult_names, curr.data[j].mult); - } - } - printf("\n"); - memcpy(&prev, &curr, sizeof(prev)); - } - -} - -int main(int argc, char **argv) -{ - int c; - int mask = 0; - int minor = 0; - int interval = 0; - int fd; - char buf[64]; - int i; - - while ((c = getopt(argc, argv, "avmcsbM:i:")) != EOF) - switch (c) { - case 'a': mask = ~0; break; - case 'v': mask |= DRM_VERSION; break; - case 'm': mask |= DRM_MEMORY; break; - case 'c': mask |= DRM_CLIENTS; break; - case 's': mask |= DRM_STATS; break; - case 'b': mask |= DRM_BUSID; break; - case 'i': interval = strtol(optarg, NULL, 0); break; - case 'M': minor = strtol(optarg, NULL, 0); break; - default: - fprintf( stderr, "Usage: dristat [options]\n\n" ); - fprintf( stderr, "Displays DRM information. Use with no arguments to display available cards.\n\n" ); - fprintf( stderr, " -a Show all available information\n" ); - fprintf( stderr, " -b Show DRM bus ID's\n" ); - fprintf( stderr, " -c Display information about DRM clients\n" ); - fprintf( stderr, " -i [interval] Continuously display statistics every [interval] seconds\n" ); - fprintf( stderr, " -v Display DRM module and card version information\n" ); - fprintf( stderr, " -m Display memory use information\n" ); - fprintf( stderr, " -s Display DRM statistics\n" ); - fprintf( stderr, " -M [minor] Select card by minor number\n" ); - return 1; - } - - for (i = 0; i < 16; i++) if (!minor || i == minor) { - sprintf(buf, DRM_DEV_NAME, DRM_DIR_NAME, i); - fd = drmOpenMinor(i, 1, DRM_NODE_PRIMARY); - if (fd >= 0) { - printf("%s\n", buf); - if (mask & DRM_BUSID) getbusid(fd); - if (mask & DRM_VERSION) getversion(fd); - if (mask & DRM_MEMORY) getvm(fd); - if (mask & DRM_CLIENTS) getclients(fd); - if (mask & DRM_STATS) getstats(fd, interval); - close(fd); - } - } - - return 0; -} diff --git a/lib/libdrm/tests/drmstat.c b/lib/libdrm/tests/drmstat.c deleted file mode 100644 index 023aa069c..000000000 --- a/lib/libdrm/tests/drmstat.c +++ /dev/null @@ -1,419 +0,0 @@ -/* drmstat.c -- DRM device status and testing program - * Created: Tue Jan 5 08:19:24 1999 by faith@precisioninsight.com - * - * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. - * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. - * 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, 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 - * 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: Rickard E. (Rik) Faith - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef HAVE_ALLOCA_H -# include -#endif -#include "xf86drm.h" - -int sigio_fd; - -static double usec(struct timeval *end, struct timeval *start) -{ - double e = end->tv_sec * 1000000 + end->tv_usec; - double s = start->tv_sec * 1000000 + start->tv_usec; - - return e - s; -} - -static void getversion(int fd) -{ - drmVersionPtr version; - - version = drmGetVersion(fd); - if (version) { - printf( "Name: %s\n", version->name ? version->name : "?" ); - printf( " Version: %d.%d.%d\n", - version->version_major, - version->version_minor, - version->version_patchlevel ); - printf( " Date: %s\n", version->date ? version->date : "?" ); - printf( " Desc: %s\n", version->desc ? version->desc : "?" ); - drmFreeVersion(version); - } else { - printf( "No driver available\n" ); - } -} - -static void process_sigio(char *device) -{ - int fd; - - if ((fd = open(device, 0)) < 0) { - drmError(-errno, __func__); - exit(1); - } - - sigio_fd = fd; - for (;;) sleep(60); -} - -int main(int argc, char **argv) -{ - int c; - int r = 0; - int fd = -1; - drm_handle_t handle; - void *address; - char *pt; - unsigned long count; - unsigned long offset; - unsigned long size; - drm_context_t context; - int loops; - char buf[1024]; - int i; - drmBufInfoPtr info; - drmBufMapPtr bufs; - drmLockPtr lock; - int secs; - - while ((c = getopt(argc, argv, - "lc:vo:O:f:s:w:W:b:r:R:P:L:C:XS:B:F:")) != EOF) - switch (c) { - case 'F': - count = strtoul(optarg, NULL, 0); - if (!fork()) { - dup(fd); - sleep(count); - } - close(fd); - break; - case 'v': getversion(fd); break; - case 'X': - if ((r = drmCreateContext(fd, &context))) { - drmError(r, argv[0]); - return 1; - } - printf( "Got %d\n", context); - break; - case 'S': - process_sigio(optarg); - break; - case 'C': - if ((r = drmSwitchToContext(fd, strtoul(optarg, NULL, 0)))) { - drmError(r, argv[0]); - return 1; - } - break; - case 'c': - if ((r = drmSetBusid(fd,optarg))) { - drmError(r, argv[0]); - return 1; - } - break; - case 'o': - if ((fd = drmOpen(optarg, NULL)) < 0) { - drmError(fd, argv[0]); - return 1; - } - break; - case 'O': - if ((fd = drmOpen(NULL, optarg)) < 0) { - drmError(fd, argv[0]); - return 1; - } - break; - case 'B': /* Test buffer allocation */ - count = strtoul(optarg, &pt, 0); - size = strtoul(pt+1, &pt, 0); - secs = strtoul(pt+1, NULL, 0); - { - drmDMAReq dma; - int *indices, *sizes; - - indices = alloca(sizeof(*indices) * count); - sizes = alloca(sizeof(*sizes) * count); - dma.context = context; - dma.send_count = 0; - dma.request_count = count; - dma.request_size = size; - dma.request_list = indices; - dma.request_sizes = sizes; - dma.flags = DRM_DMA_WAIT; - if ((r = drmDMA(fd, &dma))) { - drmError(r, argv[0]); - return 1; - } - for (i = 0; i < dma.granted_count; i++) { - printf("%5d: index = %d, size = %d\n", - i, dma.request_list[i], dma.request_sizes[i]); - } - sleep(secs); - drmFreeBufs(fd, dma.granted_count, indices); - } - break; - case 'b': - count = strtoul(optarg, &pt, 0); - size = strtoul(pt+1, NULL, 0); - if ((r = drmAddBufs(fd, count, size, 0, 65536)) < 0) { - drmError(r, argv[0]); - return 1; - } - if (!(info = drmGetBufInfo(fd))) { - drmError(0, argv[0]); - return 1; - } - for (i = 0; i < info->count; i++) { - printf("%5d buffers of size %6d (low = %d, high = %d)\n", - info->list[i].count, - info->list[i].size, - info->list[i].low_mark, - info->list[i].high_mark); - } - if ((r = drmMarkBufs(fd, 0.50, 0.80))) { - drmError(r, argv[0]); - return 1; - } - if (!(info = drmGetBufInfo(fd))) { - drmError(0, argv[0]); - return 1; - } - for (i = 0; i < info->count; i++) { - printf("%5d buffers of size %6d (low = %d, high = %d)\n", - info->list[i].count, - info->list[i].size, - info->list[i].low_mark, - info->list[i].high_mark); - } - printf("===== /proc/dri/0/mem =====\n"); - sprintf(buf, "cat /proc/dri/0/mem"); - system(buf); -#if 1 - if (!(bufs = drmMapBufs(fd))) { - drmError(0, argv[0]); - return 1; - } - printf("===============================\n"); - printf( "%d bufs\n", bufs->count); - for (i = 0; i < bufs->count; i++) { - printf( " %4d: %8d bytes at %p\n", - i, - bufs->list[i].total, - bufs->list[i].address); - } - printf("===== /proc/dri/0/vma =====\n"); - sprintf(buf, "cat /proc/dri/0/vma"); - system(buf); -#endif - break; - case 'f': - offset = strtoul(optarg, &pt, 0); - size = strtoul(pt+1, NULL, 0); - handle = 0; - if ((r = drmAddMap(fd, offset, size, - DRM_FRAME_BUFFER, 0, &handle))) { - drmError(r, argv[0]); - return 1; - } - printf("0x%08lx:0x%04lx added\n", offset, size); - printf("===== /proc/dri/0/mem =====\n"); - sprintf(buf, "cat /proc/dri/0/mem"); - system(buf); - break; - case 'r': - case 'R': - offset = strtoul(optarg, &pt, 0); - size = strtoul(pt+1, NULL, 0); - handle = 0; - if ((r = drmAddMap(fd, offset, size, - DRM_REGISTERS, - c == 'R' ? DRM_READ_ONLY : 0, - &handle))) { - drmError(r, argv[0]); - return 1; - } - printf("0x%08lx:0x%04lx added\n", offset, size); - printf("===== /proc/dri/0/mem =====\n"); - sprintf(buf, "cat /proc/dri/0/mem"); - system(buf); - break; - case 's': - size = strtoul(optarg, &pt, 0); - handle = 0; - if ((r = drmAddMap(fd, 0, size, - DRM_SHM, DRM_CONTAINS_LOCK, - &handle))) { - drmError(r, argv[0]); - return 1; - } - printf("0x%04lx byte shm added at 0x%08lx\n", size, handle); - sprintf(buf, "cat /proc/dri/0/vm"); - system(buf); - break; - case 'P': - offset = strtoul(optarg, &pt, 0); - size = strtoul(pt+1, NULL, 0); - address = NULL; - if ((r = drmMap(fd, offset, size, &address))) { - drmError(r, argv[0]); - return 1; - } - printf("0x%08lx:0x%04lx mapped at %p for pid %d\n", - offset, size, address, getpid()); - printf("===== /proc/dri/0/vma =====\n"); - sprintf(buf, "cat /proc/dri/0/vma"); - system(buf); - mprotect((void *)offset, size, PROT_READ); - printf("===== /proc/dri/0/vma =====\n"); - sprintf(buf, "cat /proc/dri/0/vma"); - system(buf); - break; - case 'w': - case 'W': - offset = strtoul(optarg, &pt, 0); - size = strtoul(pt+1, NULL, 0); - address = NULL; - if ((r = drmMap(fd, offset, size, &address))) { - drmError(r, argv[0]); - return 1; - } - printf("0x%08lx:0x%04lx mapped at %p for pid %d\n", - offset, size, address, getpid()); - printf("===== /proc/%d/maps =====\n", getpid()); - sprintf(buf, "cat /proc/%d/maps", getpid()); - system(buf); - printf("===== /proc/dri/0/mem =====\n"); - sprintf(buf, "cat /proc/dri/0/mem"); - system(buf); - printf("===== /proc/dri/0/vma =====\n"); - sprintf(buf, "cat /proc/dri/0/vma"); - system(buf); - printf("===== READING =====\n"); - for (i = 0; i < 0x10; i++) - printf("%02x ", (unsigned int)((unsigned char *)address)[i]); - printf("\n"); - if (c == 'w') { - printf("===== WRITING =====\n"); - for (i = 0; i < size; i+=2) { - ((char *)address)[i] = i & 0xff; - ((char *)address)[i+1] = i & 0xff; - } - } - printf("===== READING =====\n"); - for (i = 0; i < 0x10; i++) - printf("%02x ", (unsigned int)((unsigned char *)address)[i]); - printf("\n"); - printf("===== /proc/dri/0/vma =====\n"); - sprintf(buf, "cat /proc/dri/0/vma"); - system(buf); - break; - case 'L': - context = strtoul(optarg, &pt, 0); - offset = strtoul(pt+1, &pt, 0); - size = strtoul(pt+1, &pt, 0); - loops = strtoul(pt+1, NULL, 0); - address = NULL; - if ((r = drmMap(fd, offset, size, &address))) { - drmError(r, argv[0]); - return 1; - } - lock = address; -#if 1 - { - int counter = 0; - struct timeval loop_start, loop_end; - struct timeval lock_start, lock_end; - double wt; -#define HISTOSIZE 9 - int histo[HISTOSIZE]; - int output = 0; - int fast = 0; - - if (loops < 0) { - loops = -loops; - ++output; - } - - for (i = 0; i < HISTOSIZE; i++) histo[i] = 0; - - gettimeofday(&loop_start, NULL); - for (i = 0; i < loops; i++) { - gettimeofday(&lock_start, NULL); - DRM_LIGHT_LOCK_COUNT(fd,lock,context,fast); - gettimeofday(&lock_end, NULL); - DRM_UNLOCK(fd,lock,context); - ++counter; - wt = usec(&lock_end, &lock_start); - if (wt <= 2.5) ++histo[8]; - if (wt < 5.0) ++histo[0]; - else if (wt < 50.0) ++histo[1]; - else if (wt < 500.0) ++histo[2]; - else if (wt < 5000.0) ++histo[3]; - else if (wt < 50000.0) ++histo[4]; - else if (wt < 500000.0) ++histo[5]; - else if (wt < 5000000.0) ++histo[6]; - else ++histo[7]; - if (output) printf( "%.2f uSec, %d fast\n", wt, fast); - } - gettimeofday(&loop_end, NULL); - printf( "Average wait time = %.2f usec, %d fast\n", - usec(&loop_end, &loop_start) / counter, fast); - printf( "%9d <= 2.5 uS\n", histo[8]); - printf( "%9d < 5 uS\n", histo[0]); - printf( "%9d < 50 uS\n", histo[1]); - printf( "%9d < 500 uS\n", histo[2]); - printf( "%9d < 5000 uS\n", histo[3]); - printf( "%9d < 50000 uS\n", histo[4]); - printf( "%9d < 500000 uS\n", histo[5]); - printf( "%9d < 5000000 uS\n", histo[6]); - printf( "%9d >= 5000000 uS\n", histo[7]); - } -#else - printf( "before lock: 0x%08x\n", lock->lock); - printf( "lock: 0x%08x\n", lock->lock); - sleep(5); - printf( "unlock: 0x%08x\n", lock->lock); -#endif - break; - default: - fprintf( stderr, "Usage: drmstat [options]\n" ); - return 1; - } - - return r; -} - -int xf86ConfigDRI[10]; diff --git a/lib/libdrm/tests/drmtest.c b/lib/libdrm/tests/drmtest.c deleted file mode 100644 index 022994a0d..000000000 --- a/lib/libdrm/tests/drmtest.c +++ /dev/null @@ -1,135 +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 -#include -#include -#include -#include "drmtest.h" - -#define LIBUDEV_I_KNOW_THE_API_IS_SUBJECT_TO_CHANGE -#include - -static int is_master(int fd) -{ - drm_client_t client; - int ret; - - /* Check that we're the only opener and authed. */ - client.idx = 0; - ret = ioctl(fd, DRM_IOCTL_GET_CLIENT, &client); - assert (ret == 0); - if (!client.auth) - return 0; - client.idx = 1; - ret = ioctl(fd, DRM_IOCTL_GET_CLIENT, &client); - if (ret != -1 || errno != EINVAL) - return 0; - - return 1; -} - -/** Open the first DRM device matching the criteria */ -int drm_open_matching(const char *pci_glob, int flags) -{ - struct udev *udev; - struct udev_enumerate *e; - struct udev_device *device, *parent; - struct udev_list_entry *entry; - const char *pci_id, *path; - const char *usub, *dnode; - int fd; - - udev = udev_new(); - if (udev == NULL) { - fprintf(stderr, "failed to initialize udev context\n"); - abort(); - } - - fd = -1; - e = udev_enumerate_new(udev); - udev_enumerate_add_match_subsystem(e, "drm"); - udev_enumerate_scan_devices(e); - udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e)) { - path = udev_list_entry_get_name(entry); - device = udev_device_new_from_syspath(udev, path); - parent = udev_device_get_parent(device); - usub = udev_device_get_subsystem(parent); - /* Filter out KMS output devices. */ - if (!usub || (strcmp(usub, "pci") != 0)) - continue; - pci_id = udev_device_get_property_value(parent, "PCI_ID"); - if (fnmatch(pci_glob, pci_id, 0) != 0) - continue; - dnode = udev_device_get_devnode(device); - if (strstr(dnode, "control")) - continue; - fd = open(dnode, O_RDWR); - if (fd < 0) - continue; - if ((flags & DRM_TEST_MASTER) && !is_master(fd)) { - close(fd); - fd = -1; - continue; - } - - break; - } - udev_enumerate_unref(e); - udev_unref(udev); - - return fd; -} - -int drm_open_any(void) -{ - int fd = drm_open_matching("*:*", 0); - - if (fd < 0) { - fprintf(stderr, "failed to open any drm device\n"); - exit(0); - } - - return fd; -} - -/** - * Open the first DRM device we can find where we end up being the master. - */ -int drm_open_any_master(void) -{ - int fd = drm_open_matching("*:*", DRM_TEST_MASTER); - - if (fd < 0) { - fprintf(stderr, "failed to open any drm device\n"); - exit(0); - } - - return fd; - -} diff --git a/lib/libdrm/tests/drmtest.h b/lib/libdrm/tests/drmtest.h deleted file mode 100644 index 55bb44644..000000000 --- a/lib/libdrm/tests/drmtest.h +++ /dev/null @@ -1,40 +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 -#include -#include -#include - -#include "xf86drm.h" - -#define DRM_TEST_MASTER 0x01 - -int drm_open_any(void); -int drm_open_any_master(void); -int drm_open_matching(const char *pci_glob, int flags); diff --git a/lib/libdrm/tests/etnaviv/Makefile.in b/lib/libdrm/tests/etnaviv/Makefile.in index 33bf26499..1b9e38082 100644 --- a/lib/libdrm/tests/etnaviv/Makefile.in +++ b/lib/libdrm/tests/etnaviv/Makefile.in @@ -188,8 +188,6 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ -LIBUDEV_LIBS = @LIBUDEV_LIBS@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ diff --git a/lib/libdrm/tests/exynos/Makefile.in b/lib/libdrm/tests/exynos/Makefile.in index 2a807f98a..fb2b973e2 100644 --- a/lib/libdrm/tests/exynos/Makefile.in +++ b/lib/libdrm/tests/exynos/Makefile.in @@ -201,8 +201,6 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ -LIBUDEV_LIBS = @LIBUDEV_LIBS@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ @@ -303,6 +301,7 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CFLAGS = \ + -pthread \ $(WARN_CFLAGS)\ -I $(top_srcdir)/include/drm \ -I $(top_srcdir)/libkms/ \ @@ -315,8 +314,7 @@ exynos_fimg2d_perf_LDADD = \ exynos_fimg2d_event_LDADD = \ $(top_builddir)/libdrm.la \ - $(top_builddir)/exynos/libdrm_exynos.la \ - -lpthread + $(top_builddir)/exynos/libdrm_exynos.la exynos_fimg2d_test_LDADD = \ $(top_builddir)/libdrm.la \ diff --git a/lib/libdrm/tests/getclient.c b/lib/libdrm/tests/getclient.c deleted file mode 100644 index 481ce1191..000000000 --- a/lib/libdrm/tests/getclient.c +++ /dev/null @@ -1,61 +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 -#include "drmtest.h" - -/** - * Checks DRM_IOCTL_GET_CLIENT. - */ -int main(int argc, char **argv) -{ - int fd, ret; - drm_client_t client; - - fd = drm_open_any(); - - /* Look for client index 0. This should exist whether we're operating - * on an otherwise unused drm device, or the X Server is running on - * the device. - */ - client.idx = 0; - ret = ioctl(fd, DRM_IOCTL_GET_CLIENT, &client); - assert(ret == 0); - - /* Look for some absurd client index and make sure it's invalid. - * The DRM drivers currently always return data, so the user has - * no real way to detect when the list has terminated. That's bad, - * and this test is XFAIL as a result. - */ - client.idx = 0x7fffffff; - ret = ioctl(fd, DRM_IOCTL_GET_CLIENT, &client); - assert(ret == -1 && errno == EINVAL); - - close(fd); - return 0; -} diff --git a/lib/libdrm/tests/getstats.c b/lib/libdrm/tests/getstats.c deleted file mode 100644 index 8a7d29993..000000000 --- a/lib/libdrm/tests/getstats.c +++ /dev/null @@ -1,50 +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 -#include "drmtest.h" - -/** - * Checks DRM_IOCTL_GET_STATS. - * - * I don't care too much about the actual contents, just that the kernel - * doesn't crash. - */ -int main(int argc, char **argv) -{ - int fd, ret; - drm_stats_t stats; - - fd = drm_open_any(); - - ret = ioctl(fd, DRM_IOCTL_GET_STATS, &stats); - assert(ret == 0); - - close(fd); - return 0; -} diff --git a/lib/libdrm/tests/getversion.c b/lib/libdrm/tests/getversion.c deleted file mode 100644 index bcec46999..000000000 --- a/lib/libdrm/tests/getversion.c +++ /dev/null @@ -1,49 +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" - -/** - * Checks DRM_IOCTL_GET_VERSION and libdrm's drmGetVersion() interface to it. - */ -int main(int argc, char **argv) -{ - int fd; - drmVersionPtr v; - - fd = drm_open_any(); - v = drmGetVersion(fd); - assert(strlen(v->name) != 0); - assert(strlen(v->date) != 0); - assert(strlen(v->desc) != 0); - if (strcmp(v->name, "i915") == 0) - assert(v->version_major >= 1); - drmFreeVersion(v); - close(fd); - return 0; -} diff --git a/lib/libdrm/tests/kms/Makefile.in b/lib/libdrm/tests/kms/Makefile.in index 486e386a9..d34ff7564 100644 --- a/lib/libdrm/tests/kms/Makefile.in +++ b/lib/libdrm/tests/kms/Makefile.in @@ -186,8 +186,6 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ -LIBUDEV_LIBS = @LIBUDEV_LIBS@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ diff --git a/lib/libdrm/tests/kmstest/Makefile.in b/lib/libdrm/tests/kmstest/Makefile.in index c2a994665..7fcfd97ba 100644 --- a/lib/libdrm/tests/kmstest/Makefile.in +++ b/lib/libdrm/tests/kmstest/Makefile.in @@ -170,8 +170,6 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ -LIBUDEV_LIBS = @LIBUDEV_LIBS@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ diff --git a/lib/libdrm/tests/modeprint/Makefile.in b/lib/libdrm/tests/modeprint/Makefile.in index a3c7e0e73..995438002 100644 --- a/lib/libdrm/tests/modeprint/Makefile.in +++ b/lib/libdrm/tests/modeprint/Makefile.in @@ -169,8 +169,6 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ -LIBUDEV_LIBS = @LIBUDEV_LIBS@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ diff --git a/lib/libdrm/tests/modetest/Makefile.in b/lib/libdrm/tests/modetest/Makefile.in index 4ec4da4b5..859e2ac69 100644 --- a/lib/libdrm/tests/modetest/Makefile.in +++ b/lib/libdrm/tests/modetest/Makefile.in @@ -172,8 +172,6 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ -LIBUDEV_LIBS = @LIBUDEV_LIBS@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ @@ -280,15 +278,14 @@ MODETEST_FILES := \ cursor.h \ modetest.c -AM_CFLAGS = $(filter-out -Wpointer-arith, $(WARN_CFLAGS)) \ +AM_CFLAGS = $(filter-out -Wpointer-arith, $(WARN_CFLAGS)) -pthread \ -I$(top_srcdir)/include/drm -I$(top_srcdir)/tests \ -I$(top_srcdir) modetest_SOURCES = $(MODETEST_FILES) modetest_LDADD = \ $(top_builddir)/libdrm.la \ $(top_builddir)/tests/util/libutil.la \ - $(CAIRO_LIBS) \ - -lpthread + $(CAIRO_LIBS) all: all-am diff --git a/lib/libdrm/tests/name_from_fd.c b/lib/libdrm/tests/name_from_fd.c deleted file mode 100644 index 52646812a..000000000 --- a/lib/libdrm/tests/name_from_fd.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright © 2009 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: - * Kristian Høgsberg - * - */ - -#include -#include -#include -#include -#include "drmtest.h" - -/** - * Checks drmGetDeviceNameFromFd - * - * This tests that we can get the actual version out, and that setting invalid - * major/minor numbers fails appropriately. It does not check the actual - * behavior differenses resulting from an increased DI version. - */ -int main(int argc, char **argv) -{ - int fd; - const char *name = "/dev/dri/card0"; - char *v; - - fd = open("/dev/dri/card0", O_RDWR); - if (fd < 0) - return 0; - - v = drmGetDeviceNameFromFd(fd); - close(fd); - - assert(strcmp(name, v) == 0); - drmFree(v); - - return 0; -} diff --git a/lib/libdrm/tests/nouveau/Makefile.in b/lib/libdrm/tests/nouveau/Makefile.in index b85a4c895..62965d40a 100644 --- a/lib/libdrm/tests/nouveau/Makefile.in +++ b/lib/libdrm/tests/nouveau/Makefile.in @@ -173,8 +173,6 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ -LIBUDEV_LIBS = @LIBUDEV_LIBS@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ @@ -274,16 +272,17 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -AM_CPPFLAGS = \ +AM_CFLAGS = \ + -pthread \ + $(WARN_CFLAGS) \ -I$(top_srcdir)/include/drm \ -I$(top_srcdir)/nouveau \ -I$(top_srcdir) -AM_CFLAGS = $(WARN_CFLAGS) LDADD = \ ../../nouveau/libdrm_nouveau.la \ ../../libdrm.la \ - -ldl -lpthread + -ldl all: all-am diff --git a/lib/libdrm/tests/openclose.c b/lib/libdrm/tests/openclose.c deleted file mode 100644 index 946a44599..000000000 --- a/lib/libdrm/tests/openclose.c +++ /dev/null @@ -1,37 +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 "drmtest.h" - -int main(int argc, char **argv) -{ - int fd; - - fd = drm_open_any(); - close(fd); - return 0; -} diff --git a/lib/libdrm/tests/proptest/Makefile.in b/lib/libdrm/tests/proptest/Makefile.in index 2d72b1be3..c89df9393 100644 --- a/lib/libdrm/tests/proptest/Makefile.in +++ b/lib/libdrm/tests/proptest/Makefile.in @@ -171,8 +171,6 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ -LIBUDEV_LIBS = @LIBUDEV_LIBS@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ diff --git a/lib/libdrm/tests/radeon/Makefile.in b/lib/libdrm/tests/radeon/Makefile.in index 820359778..48f6a751d 100644 --- a/lib/libdrm/tests/radeon/Makefile.in +++ b/lib/libdrm/tests/radeon/Makefile.in @@ -168,8 +168,6 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ -LIBUDEV_LIBS = @LIBUDEV_LIBS@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ diff --git a/lib/libdrm/tests/setversion.c b/lib/libdrm/tests/setversion.c deleted file mode 100644 index 2f7b529a1..000000000 --- a/lib/libdrm/tests/setversion.c +++ /dev/null @@ -1,91 +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 -#include -#include "drmtest.h" - -/** - * Checks DRM_IOCTL_SET_VERSION. - * - * This tests that we can get the actual version out, and that setting invalid - * major/minor numbers fails appropriately. It does not check the actual - * behavior differenses resulting from an increased DI version. - */ -int main(int argc, char **argv) -{ - int fd, ret; - drm_set_version_t sv, version; - - if (getuid() != 0) { - fprintf(stderr, "setversion test requires root, skipping\n"); - return 0; - } - - fd = drm_open_any_master(); - - /* First, check that we can get the DD/DI versions. */ - memset(&version, 0, sizeof(version)); - version.drm_di_major = -1; - version.drm_di_minor = -1; - version.drm_dd_major = -1; - version.drm_dd_minor = -1; - ret = ioctl(fd, DRM_IOCTL_SET_VERSION, &version); - assert(ret == 0); - assert(version.drm_di_major != -1); - assert(version.drm_di_minor != -1); - assert(version.drm_dd_major != -1); - assert(version.drm_dd_minor != -1); - - /* Check that an invalid DI major fails */ - sv = version; - sv.drm_di_major++; - ret = ioctl(fd, DRM_IOCTL_SET_VERSION, &sv); - assert(ret == -1 && errno == EINVAL); - - /* Check that an invalid DI minor fails */ - sv = version; - sv.drm_di_major++; - ret = ioctl(fd, DRM_IOCTL_SET_VERSION, &sv); - assert(ret == -1 && errno == EINVAL); - - /* Check that an invalid DD major fails */ - sv = version; - sv.drm_dd_major++; - ret = ioctl(fd, DRM_IOCTL_SET_VERSION, &sv); - assert(ret == -1 && errno == EINVAL); - - /* Check that an invalid DD minor fails */ - sv = version; - sv.drm_dd_minor++; - ret = ioctl(fd, DRM_IOCTL_SET_VERSION, &sv); - assert(ret == -1 && errno == EINVAL); - - close(fd); - return 0; -} diff --git a/lib/libdrm/tests/tegra/Makefile.in b/lib/libdrm/tests/tegra/Makefile.in index b47c2de18..fa9a965e3 100644 --- a/lib/libdrm/tests/tegra/Makefile.in +++ b/lib/libdrm/tests/tegra/Makefile.in @@ -168,8 +168,6 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ -LIBUDEV_LIBS = @LIBUDEV_LIBS@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ diff --git a/lib/libdrm/tests/updatedraw.c b/lib/libdrm/tests/updatedraw.c deleted file mode 100644 index d01fa96d4..000000000 --- a/lib/libdrm/tests/updatedraw.c +++ /dev/null @@ -1,154 +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" - -static void -set_draw_cliprects_empty(int fd, int drawable) -{ - int ret; - struct drm_update_draw update; - - update.handle = drawable; - update.type = DRM_DRAWABLE_CLIPRECTS; - update.num = 0; - update.data = 0; - - ret = ioctl(fd, DRM_IOCTL_UPDATE_DRAW, &update); - assert(ret == 0); -} - -static void -set_draw_cliprects_empty_fail(int fd, int drawable) -{ - int ret; - struct drm_update_draw update; - - update.handle = drawable; - update.type = DRM_DRAWABLE_CLIPRECTS; - update.num = 0; - update.data = 0; - - ret = ioctl(fd, DRM_IOCTL_UPDATE_DRAW, &update); - assert(ret == -1 && errno == EINVAL); -} - -static void -set_draw_cliprects_2(int fd, int drawable) -{ - int ret; - struct drm_update_draw update; - drm_clip_rect_t rects[2]; - - rects[0].x1 = 0; - rects[0].y1 = 0; - rects[0].x2 = 10; - rects[0].y2 = 10; - - rects[1].x1 = 10; - rects[1].y1 = 10; - rects[1].x2 = 20; - rects[1].y2 = 20; - - update.handle = drawable; - update.type = DRM_DRAWABLE_CLIPRECTS; - update.num = 2; - update.data = (unsigned long long)(uintptr_t)&rects; - - ret = ioctl(fd, DRM_IOCTL_UPDATE_DRAW, &update); - assert(ret == 0); -} - -static int add_drawable(int fd) -{ - drm_draw_t drawarg; - int ret; - - /* Create a drawable. - * IOCTL_ADD_DRAW is RDWR, though it should really just be RD - */ - drawarg.handle = 0; - ret = ioctl(fd, DRM_IOCTL_ADD_DRAW, &drawarg); - assert(ret == 0); - return drawarg.handle; -} - -static int rm_drawable(int fd, int drawable, int fail) -{ - drm_draw_t drawarg; - int ret; - - /* Create a drawable. - * IOCTL_ADD_DRAW is RDWR, though it should really just be RD - */ - drawarg.handle = drawable; - ret = ioctl(fd, DRM_IOCTL_RM_DRAW, &drawarg); - if (!fail) - assert(ret == 0); - else - assert(ret == -1 && errno == EINVAL); - - return drawarg.handle; -} - -/** - * Tests drawable management: adding, removing, and updating the cliprects of - * drawables. - */ -int main(int argc, char **argv) -{ - int fd, d1, d2; - - if (getuid() != 0) { - fprintf(stderr, "updatedraw test requires root, skipping\n"); - return 0; - } - - fd = drm_open_any_master(); - - d1 = add_drawable(fd); - d2 = add_drawable(fd); - /* Do a series of cliprect updates */ - set_draw_cliprects_empty(fd, d1); - set_draw_cliprects_empty(fd, d2); - set_draw_cliprects_2(fd, d1); - set_draw_cliprects_empty(fd, d1); - - /* Remove our drawables */ - rm_drawable(fd, d1, 0); - rm_drawable(fd, d2, 0); - - /* Check that removing an unknown drawable returns error */ - rm_drawable(fd, 0x7fffffff, 1); - - /* Attempt to set cliprects on a nonexistent drawable */ - set_draw_cliprects_empty_fail(fd, d1); - - close(fd); - return 0; -} diff --git a/lib/libdrm/tests/util/Makefile.in b/lib/libdrm/tests/util/Makefile.in index 3fecd54ec..c50771ba6 100644 --- a/lib/libdrm/tests/util/Makefile.in +++ b/lib/libdrm/tests/util/Makefile.in @@ -171,8 +171,6 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ -LIBUDEV_LIBS = @LIBUDEV_LIBS@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ diff --git a/lib/libdrm/tests/vbltest/Makefile.in b/lib/libdrm/tests/vbltest/Makefile.in index 407838ca1..a28748ed8 100644 --- a/lib/libdrm/tests/vbltest/Makefile.in +++ b/lib/libdrm/tests/vbltest/Makefile.in @@ -170,8 +170,6 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ -LIBUDEV_LIBS = @LIBUDEV_LIBS@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ diff --git a/lib/libdrm/vc4/Makefile.in b/lib/libdrm/vc4/Makefile.in index 7dc795fee..afb215b93 100644 --- a/lib/libdrm/vc4/Makefile.in +++ b/lib/libdrm/vc4/Makefile.in @@ -190,8 +190,6 @@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ -LIBUDEV_LIBS = @LIBUDEV_LIBS@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ diff --git a/lib/libdrm/xf86drm.c b/lib/libdrm/xf86drm.c index ed1ad7dd1..7ab64022e 100644 --- a/lib/libdrm/xf86drm.c +++ b/lib/libdrm/xf86drm.c @@ -103,7 +103,6 @@ #endif #ifdef __OpenBSD__ - #define X_PRIVSEP struct drm_pciinfo { @@ -119,7 +118,6 @@ struct drm_pciinfo { }; #define DRM_IOCTL_GET_PCIINFO DRM_IOR(0x15, struct drm_pciinfo) - #endif #define DRM_MSG_VERBOSITY 3 @@ -2862,9 +2860,10 @@ out_close_dir: closedir(sysdir); #else struct stat sbuf; - unsigned int maj, min; char buf[PATH_MAX + 1]; - int n; + const char *dev_name; + unsigned int maj, min; + int n, base; if (fstat(fd, &sbuf)) return NULL; @@ -2875,7 +2874,25 @@ out_close_dir: if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) return NULL; - n = snprintf(buf, sizeof(buf), DRM_DEV_NAME, DRM_DIR_NAME, min); + switch (type) { + case DRM_NODE_PRIMARY: + dev_name = DRM_DEV_NAME; + break; + case DRM_NODE_CONTROL: + dev_name = DRM_CONTROL_DEV_NAME; + break; + case DRM_NODE_RENDER: + dev_name = DRM_RENDER_DEV_NAME; + break; + default: + return NULL; + }; + + base = drmGetMinorBase(type); + if (base < 0) + return NULL; + + n = snprintf(buf, sizeof(buf), dev_name, DRM_DIR_NAME, min - base); if (n == -1 || n >= sizeof(buf)) return NULL; @@ -2894,6 +2911,50 @@ char *drmGetRenderDeviceNameFromFd(int fd) return drmGetMinorNameForFD(fd, DRM_NODE_RENDER); } +#ifdef __linux__ +static char * DRM_PRINTFLIKE(2, 3) +sysfs_uevent_get(const char *path, const char *fmt, ...) +{ + char filename[PATH_MAX + 1], *key, *line = NULL, *value = NULL; + size_t size = 0, len; + ssize_t num; + va_list ap; + FILE *fp; + + va_start(ap, fmt); + num = vasprintf(&key, fmt, ap); + va_end(ap); + len = num; + + snprintf(filename, sizeof(filename), "%s/uevent", path); + + fp = fopen(filename, "r"); + if (!fp) { + free(key); + return NULL; + } + + while ((num = getline(&line, &size, fp)) >= 0) { + if ((strncmp(line, key, len) == 0) && (line[len] == '=')) { + char *start = line + len + 1, *end = line + num - 1; + + if (*end != '\n') + end++; + + value = strndup(start, end - start); + break; + } + } + + free(line); + fclose(fp); + + free(key); + + return value; +} +#endif + static int drmParseSubsystemType(int maj, int min) { #ifdef __linux__ @@ -2914,9 +2975,18 @@ static int drmParseSubsystemType(int maj, int min) if (strncmp(name, "/pci", 4) == 0) return DRM_BUS_PCI; + if (strncmp(name, "/usb", 4) == 0) + return DRM_BUS_USB; + + if (strncmp(name, "/platform", 9) == 0) + return DRM_BUS_PLATFORM; + + if (strncmp(name, "/host1x", 7) == 0) + return DRM_BUS_HOST1X; + return -EINVAL; #elif defined(__OpenBSD__) - return DRM_BUS_PCI; + return DRM_BUS_PCI; #else #warning "Missing implementation of drmParseSubsystemType" return -EINVAL; @@ -2926,33 +2996,22 @@ static int drmParseSubsystemType(int maj, int min) static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info) { #ifdef __linux__ - char path[PATH_MAX + 1]; - char data[512 + 1]; - char *str; - int domain, bus, dev, func; - int fd, ret; + unsigned int domain, bus, dev, func; + char path[PATH_MAX + 1], *value; + int num; - snprintf(path, PATH_MAX, "/sys/dev/char/%d:%d/device/uevent", maj, min); - fd = open(path, O_RDONLY); - if (fd < 0) - return -errno; + snprintf(path, sizeof(path), "/sys/dev/char/%d:%d/device", maj, min); - ret = read(fd, data, sizeof(data)); - data[sizeof(data)-1] = '\0'; - close(fd); - if (ret < 0) - return -errno; + value = sysfs_uevent_get(path, "PCI_SLOT_NAME"); + if (!value) + return -ENOENT; -#define TAG "PCI_SLOT_NAME=" - str = strstr(data, TAG); - if (str == NULL) + num = sscanf(value, "%04x:%02x:%02x.%1u", &domain, &bus, &dev, &func); + free(value); + + if (num != 4) return -EINVAL; - if (sscanf(str, TAG "%04x:%02x:%02x.%1u", - &domain, &bus, &dev, &func) != 4) - return -EINVAL; -#undef TAG - info->domain = domain; info->bus = bus; info->dev = dev; @@ -2961,9 +3020,13 @@ static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info) return 0; #elif defined(__OpenBSD__) struct drm_pciinfo pinfo; - int fd; + int fd, type; - fd = drmOpenMinor(min, 0, DRM_NODE_PRIMARY); + type = drmGetMinorType(min); + if (type == -1) + return -ENODEV; + + fd = drmOpenMinor(min, 0, type); if (fd < 0) return -errno; @@ -2996,6 +3059,16 @@ static int drmCompareBusInfo(drmDevicePtr a, drmDevicePtr b) switch (a->bustype) { case DRM_BUS_PCI: return memcmp(a->businfo.pci, b->businfo.pci, sizeof(drmPciBusInfo)); + + case DRM_BUS_USB: + return memcmp(a->businfo.usb, b->businfo.usb, sizeof(drmUsbBusInfo)); + + case DRM_BUS_PLATFORM: + return memcmp(a->businfo.platform, b->businfo.platform, sizeof(drmPlatformBusInfo)); + + case DRM_BUS_HOST1X: + return memcmp(a->businfo.host1x, b->businfo.host1x, sizeof(drmHost1xBusInfo)); + default: break; } @@ -3029,15 +3102,55 @@ static int drmGetMaxNodeName(void) 3 /* length of the node number */; } -static int drmParsePciDeviceInfo(const char *d_name, - drmPciDeviceInfoPtr device) -{ #ifdef __linux__ +static int parse_separate_sysfs_files(int maj, int min, + drmPciDeviceInfoPtr device, + bool ignore_revision) +{ +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) + static const char *attrs[] = { + "revision", /* Older kernels are missing the file, so check for it first */ + "vendor", + "device", + "subsystem_vendor", + "subsystem_device", + }; + char path[PATH_MAX + 1]; + unsigned int data[ARRAY_SIZE(attrs)]; + FILE *fp; + int ret; + + for (unsigned i = ignore_revision ? 1 : 0; i < ARRAY_SIZE(attrs); i++) { + snprintf(path, PATH_MAX, "/sys/dev/char/%d:%d/device/%s", maj, min, + attrs[i]); + fp = fopen(path, "r"); + if (!fp) + return -errno; + + ret = fscanf(fp, "%x", &data[i]); + fclose(fp); + if (ret != 1) + return -errno; + + } + + device->revision_id = ignore_revision ? 0xff : data[0] & 0xff; + device->vendor_id = data[1] & 0xffff; + device->device_id = data[2] & 0xffff; + device->subvendor_id = data[3] & 0xffff; + device->subdevice_id = data[4] & 0xffff; + + return 0; +} + +static int parse_config_sysfs_file(int maj, int min, + drmPciDeviceInfoPtr device) +{ char path[PATH_MAX + 1]; unsigned char config[64]; int fd, ret; - snprintf(path, PATH_MAX, "/sys/class/drm/%s/device/config", d_name); + snprintf(path, PATH_MAX, "/sys/dev/char/%d:%d/device/config", maj, min); fd = open(path, O_RDONLY); if (fd < 0) return -errno; @@ -3054,21 +3167,30 @@ static int drmParsePciDeviceInfo(const char *d_name, device->subdevice_id = config[46] | (config[47] << 8); return 0; -#elif defined(__OpenBSD__) - struct drm_pciinfo pinfo; - char buf[PATH_MAX + 1]; - int fd, n; - - n = snprintf(buf, sizeof(buf), "%s/%s", DRM_DIR_NAME, d_name); - if (n == -1 || n >= sizeof(buf)) - return -errno; - -#ifndef X_PRIVSEP - fd = open(buf, O_RDWR, 0); -#else - fd = priv_open_device(buf); +} #endif +static int drmParsePciDeviceInfo(int maj, int min, + drmPciDeviceInfoPtr device, + uint32_t flags) +{ +#ifdef __linux__ + if (!(flags & DRM_DEVICE_GET_PCI_REVISION)) + return parse_separate_sysfs_files(maj, min, device, true); + + if (parse_separate_sysfs_files(maj, min, device, false)) + return parse_config_sysfs_file(maj, min, device); + + return 0; +#elif defined(__OpenBSD__) + struct drm_pciinfo pinfo; + int fd, type; + + type = drmGetMinorType(min); + if (type == -1) + return -ENODEV; + + fd = drmOpenMinor(min, 0, type); if (fd < 0) return -errno; @@ -3091,11 +3213,55 @@ static int drmParsePciDeviceInfo(const char *d_name, #endif } +static void drmFreePlatformDevice(drmDevicePtr device) +{ + if (device->deviceinfo.platform) { + if (device->deviceinfo.platform->compatible) { + char **compatible = device->deviceinfo.platform->compatible; + + while (*compatible) { + free(*compatible); + compatible++; + } + + free(device->deviceinfo.platform->compatible); + } + } +} + +static void drmFreeHost1xDevice(drmDevicePtr device) +{ + if (device->deviceinfo.host1x) { + if (device->deviceinfo.host1x->compatible) { + char **compatible = device->deviceinfo.host1x->compatible; + + while (*compatible) { + free(*compatible); + compatible++; + } + + free(device->deviceinfo.host1x->compatible); + } + } +} + void drmFreeDevice(drmDevicePtr *device) { if (device == NULL) return; + if (*device) { + switch ((*device)->bustype) { + case DRM_BUS_PLATFORM: + drmFreePlatformDevice(*device); + break; + + case DRM_BUS_HOST1X: + drmFreeHost1xDevice(*device); + break; + } + } + free(*device); *device = NULL; } @@ -3112,56 +3278,402 @@ void drmFreeDevices(drmDevicePtr devices[], int count) drmFreeDevice(&devices[i]); } -static int drmProcessPciDevice(drmDevicePtr *device, const char *d_name, - const char *node, int node_type, - int maj, int min, bool fetch_deviceinfo) +static drmDevicePtr drmDeviceAlloc(unsigned int type, const char *node, + size_t bus_size, size_t device_size, + char **ptrp) { - const int max_node_str = ALIGN(drmGetMaxNodeName(), sizeof(void *)); - int ret, i; - char *addr; + size_t max_node_length, extra, size; + drmDevicePtr device; + unsigned int i; + char *ptr; - *device = calloc(1, sizeof(drmDevice) + - (DRM_NODE_MAX * (sizeof(void *) + max_node_str)) + - sizeof(drmPciBusInfo) + - sizeof(drmPciDeviceInfo)); - if (!*device) + max_node_length = ALIGN(drmGetMaxNodeName(), sizeof(void *)); + extra = DRM_NODE_MAX * (sizeof(void *) + max_node_length); + + size = sizeof(*device) + extra + bus_size + device_size; + + device = calloc(1, size); + if (!device) + return NULL; + + device->available_nodes = 1 << type; + + ptr = (char *)device + sizeof(*device); + device->nodes = (char **)ptr; + + ptr += DRM_NODE_MAX * sizeof(void *); + + for (i = 0; i < DRM_NODE_MAX; i++) { + device->nodes[i] = ptr; + ptr += max_node_length; + } + + memcpy(device->nodes[type], node, max_node_length); + + *ptrp = ptr; + + return device; +} + +static int drmProcessPciDevice(drmDevicePtr *device, + const char *node, int node_type, + int maj, int min, bool fetch_deviceinfo, + uint32_t flags) +{ + drmDevicePtr dev; + char *addr; + int ret; + + dev = drmDeviceAlloc(node_type, node, sizeof(drmPciBusInfo), + sizeof(drmPciDeviceInfo), &addr); + if (!dev) return -ENOMEM; - addr = (char*)*device; + dev->bustype = DRM_BUS_PCI; - (*device)->bustype = DRM_BUS_PCI; - (*device)->available_nodes = 1 << node_type; + dev->businfo.pci = (drmPciBusInfoPtr)addr; - addr += sizeof(drmDevice); - (*device)->nodes = (char**)addr; - - addr += DRM_NODE_MAX * sizeof(void *); - for (i = 0; i < DRM_NODE_MAX; i++) { - (*device)->nodes[i] = addr; - addr += max_node_str; - } - memcpy((*device)->nodes[node_type], node, max_node_str); - - (*device)->businfo.pci = (drmPciBusInfoPtr)addr; - - ret = drmParsePciBusInfo(maj, min, (*device)->businfo.pci); + ret = drmParsePciBusInfo(maj, min, dev->businfo.pci); if (ret) goto free_device; // Fetch the device info if the user has requested it if (fetch_deviceinfo) { addr += sizeof(drmPciBusInfo); - (*device)->deviceinfo.pci = (drmPciDeviceInfoPtr)addr; + dev->deviceinfo.pci = (drmPciDeviceInfoPtr)addr; - ret = drmParsePciDeviceInfo(d_name, (*device)->deviceinfo.pci); + ret = drmParsePciDeviceInfo(maj, min, dev->deviceinfo.pci, flags); if (ret) goto free_device; } + + *device = dev; + return 0; free_device: - free(*device); - *device = NULL; + free(dev); + return ret; +} + +static int drmParseUsbBusInfo(int maj, int min, drmUsbBusInfoPtr info) +{ +#ifdef __linux__ + char path[PATH_MAX + 1], *value; + unsigned int bus, dev; + int ret; + + snprintf(path, sizeof(path), "/sys/dev/char/%d:%d/device", maj, min); + + value = sysfs_uevent_get(path, "BUSNUM"); + if (!value) + return -ENOENT; + + ret = sscanf(value, "%03u", &bus); + free(value); + + if (ret <= 0) + return -errno; + + value = sysfs_uevent_get(path, "DEVNUM"); + if (!value) + return -ENOENT; + + ret = sscanf(value, "%03u", &dev); + free(value); + + if (ret <= 0) + return -errno; + + info->bus = bus; + info->dev = dev; + + return 0; +#else +#warning "Missing implementation of drmParseUsbBusInfo" + return -EINVAL; +#endif +} + +static int drmParseUsbDeviceInfo(int maj, int min, drmUsbDeviceInfoPtr info) +{ +#ifdef __linux__ + char path[PATH_MAX + 1], *value; + unsigned int vendor, product; + int ret; + + snprintf(path, sizeof(path), "/sys/dev/char/%d:%d/device", maj, min); + + value = sysfs_uevent_get(path, "PRODUCT"); + if (!value) + return -ENOENT; + + ret = sscanf(value, "%x/%x", &vendor, &product); + free(value); + + if (ret <= 0) + return -errno; + + info->vendor = vendor; + info->product = product; + + return 0; +#else +#warning "Missing implementation of drmParseUsbDeviceInfo" + return -EINVAL; +#endif +} + +static int drmProcessUsbDevice(drmDevicePtr *device, const char *node, + int node_type, int maj, int min, + bool fetch_deviceinfo, uint32_t flags) +{ + drmDevicePtr dev; + char *ptr; + int ret; + + dev = drmDeviceAlloc(node_type, node, sizeof(drmUsbBusInfo), + sizeof(drmUsbDeviceInfo), &ptr); + if (!dev) + return -ENOMEM; + + dev->bustype = DRM_BUS_USB; + + dev->businfo.usb = (drmUsbBusInfoPtr)ptr; + + ret = drmParseUsbBusInfo(maj, min, dev->businfo.usb); + if (ret < 0) + goto free_device; + + if (fetch_deviceinfo) { + ptr += sizeof(drmUsbBusInfo); + dev->deviceinfo.usb = (drmUsbDeviceInfoPtr)ptr; + + ret = drmParseUsbDeviceInfo(maj, min, dev->deviceinfo.usb); + if (ret < 0) + goto free_device; + } + + *device = dev; + + return 0; + +free_device: + free(dev); + return ret; +} + +static int drmParsePlatformBusInfo(int maj, int min, drmPlatformBusInfoPtr info) +{ +#ifdef __linux__ + char path[PATH_MAX + 1], *name; + + snprintf(path, sizeof(path), "/sys/dev/char/%d:%d/device", maj, min); + + name = sysfs_uevent_get(path, "OF_FULLNAME"); + if (!name) + return -ENOENT; + + strncpy(info->fullname, name, DRM_PLATFORM_DEVICE_NAME_LEN); + info->fullname[DRM_PLATFORM_DEVICE_NAME_LEN - 1] = '\0'; + free(name); + + return 0; +#else +#warning "Missing implementation of drmParsePlatformBusInfo" + return -EINVAL; +#endif +} + +static int drmParsePlatformDeviceInfo(int maj, int min, + drmPlatformDeviceInfoPtr info) +{ +#ifdef __linux__ + char path[PATH_MAX + 1], *value; + unsigned int count, i; + int err; + + snprintf(path, sizeof(path), "/sys/dev/char/%d:%d/device", maj, min); + + value = sysfs_uevent_get(path, "OF_COMPATIBLE_N"); + if (!value) + return -ENOENT; + + sscanf(value, "%u", &count); + free(value); + + info->compatible = calloc(count + 1, sizeof(*info->compatible)); + if (!info->compatible) + return -ENOMEM; + + for (i = 0; i < count; i++) { + value = sysfs_uevent_get(path, "OF_COMPATIBLE_%u", i); + if (!value) { + err = -ENOENT; + goto free; + } + + info->compatible[i] = value; + } + + return 0; + +free: + while (i--) + free(info->compatible[i]); + + free(info->compatible); + return err; +#else +#warning "Missing implementation of drmParsePlatformDeviceInfo" + return -EINVAL; +#endif +} + +static int drmProcessPlatformDevice(drmDevicePtr *device, + const char *node, int node_type, + int maj, int min, bool fetch_deviceinfo, + uint32_t flags) +{ + drmDevicePtr dev; + char *ptr; + int ret; + + dev = drmDeviceAlloc(node_type, node, sizeof(drmPlatformBusInfo), + sizeof(drmPlatformDeviceInfo), &ptr); + if (!dev) + return -ENOMEM; + + dev->bustype = DRM_BUS_PLATFORM; + + dev->businfo.platform = (drmPlatformBusInfoPtr)ptr; + + ret = drmParsePlatformBusInfo(maj, min, dev->businfo.platform); + if (ret < 0) + goto free_device; + + if (fetch_deviceinfo) { + ptr += sizeof(drmPlatformBusInfo); + dev->deviceinfo.platform = (drmPlatformDeviceInfoPtr)ptr; + + ret = drmParsePlatformDeviceInfo(maj, min, dev->deviceinfo.platform); + if (ret < 0) + goto free_device; + } + + *device = dev; + + return 0; + +free_device: + free(dev); + return ret; +} + +static int drmParseHost1xBusInfo(int maj, int min, drmHost1xBusInfoPtr info) +{ +#ifdef __linux__ + char path[PATH_MAX + 1], *name; + + snprintf(path, sizeof(path), "/sys/dev/char/%d:%d/device", maj, min); + + name = sysfs_uevent_get(path, "OF_FULLNAME"); + if (!name) + return -ENOENT; + + strncpy(info->fullname, name, DRM_HOST1X_DEVICE_NAME_LEN); + info->fullname[DRM_HOST1X_DEVICE_NAME_LEN - 1] = '\0'; + free(name); + + return 0; +#else +#warning "Missing implementation of drmParseHost1xBusInfo" + return -EINVAL; +#endif +} + +static int drmParseHost1xDeviceInfo(int maj, int min, + drmHost1xDeviceInfoPtr info) +{ +#ifdef __linux__ + char path[PATH_MAX + 1], *value; + unsigned int count, i; + int err; + + snprintf(path, sizeof(path), "/sys/dev/char/%d:%d/device", maj, min); + + value = sysfs_uevent_get(path, "OF_COMPATIBLE_N"); + if (!value) + return -ENOENT; + + sscanf(value, "%u", &count); + free(value); + + info->compatible = calloc(count + 1, sizeof(*info->compatible)); + if (!info->compatible) + return -ENOMEM; + + for (i = 0; i < count; i++) { + value = sysfs_uevent_get(path, "OF_COMPATIBLE_%u", i); + if (!value) { + err = -ENOENT; + goto free; + } + + info->compatible[i] = value; + } + + return 0; + +free: + while (i--) + free(info->compatible[i]); + + free(info->compatible); + return err; +#else +#warning "Missing implementation of drmParseHost1xDeviceInfo" + return -EINVAL; +#endif +} + +static int drmProcessHost1xDevice(drmDevicePtr *device, + const char *node, int node_type, + int maj, int min, bool fetch_deviceinfo, + uint32_t flags) +{ + drmDevicePtr dev; + char *ptr; + int ret; + + dev = drmDeviceAlloc(node_type, node, sizeof(drmHost1xBusInfo), + sizeof(drmHost1xDeviceInfo), &ptr); + if (!dev) + return -ENOMEM; + + dev->bustype = DRM_BUS_HOST1X; + + dev->businfo.host1x = (drmHost1xBusInfoPtr)ptr; + + ret = drmParseHost1xBusInfo(maj, min, dev->businfo.host1x); + if (ret < 0) + goto free_device; + + if (fetch_deviceinfo) { + ptr += sizeof(drmHost1xBusInfo); + dev->deviceinfo.host1x = (drmHost1xDeviceInfoPtr)ptr; + + ret = drmParseHost1xDeviceInfo(maj, min, dev->deviceinfo.host1x); + if (ret < 0) + goto free_device; + } + + *device = dev; + + return 0; + +free_device: + free(dev); return ret; } @@ -3187,25 +3699,40 @@ static void drmFoldDuplicatedDevices(drmDevicePtr local_devices[], int count) } } +/* Check that the given flags are valid returning 0 on success */ +static int +drm_device_validate_flags(uint32_t flags) +{ + return (flags & ~DRM_DEVICE_GET_PCI_REVISION); +} + /** * Get information about the opened drm device * * \param fd file descriptor of the drm device + * \param flags feature/behaviour bitmask * \param device the address of a drmDevicePtr where the information * will be allocated in stored * * \return zero on success, negative error code otherwise. + * + * \note Unlike drmGetDevice it does not retrieve the pci device revision field + * unless the DRM_DEVICE_GET_PCI_REVISION \p flag is set. */ -int drmGetDevice(int fd, drmDevicePtr *device) +int drmGetDevice2(int fd, uint32_t flags, drmDevicePtr *device) { #ifdef __OpenBSD__ - drmDevicePtr d; - struct stat sbuf; - char node[PATH_MAX + 1]; - char d_name[PATH_MAX + 1]; - int maj, min, n; - int ret; - int max_count = 1; + /* + * DRI device nodes on OpenBSD are not in their own directory, they reside + * in /dev along with a large number of statically generated /dev nodes. + * Avoid stat'ing all of /dev needlessly by implementing this custom path. + */ + drmDevicePtr d; + struct stat sbuf; + char node[PATH_MAX + 1]; + const char *dev_name; + int node_type, subsystem_type; + int maj, min, n, ret, base; if (fd == -1 || device == NULL) return -EINVAL; @@ -3219,18 +3746,39 @@ int drmGetDevice(int fd, drmDevicePtr *device) if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) return -EINVAL; - n = snprintf(d_name, PATH_MAX, "drm%d", min); - if (n == -1 || n >= PATH_MAX) - return -errno; + node_type = drmGetMinorType(min); + if (node_type == -1) + return -ENODEV; - n = snprintf(node, PATH_MAX, DRM_DEV_NAME, DRM_DIR_NAME, min); + switch (node_type) { + case DRM_NODE_PRIMARY: + dev_name = DRM_DEV_NAME; + break; + case DRM_NODE_CONTROL: + dev_name = DRM_CONTROL_DEV_NAME; + break; + case DRM_NODE_RENDER: + dev_name = DRM_RENDER_DEV_NAME; + break; + default: + return -EINVAL; + }; + + base = drmGetMinorBase(node_type); + if (base < 0) + return -EINVAL; + + n = snprintf(node, PATH_MAX, dev_name, DRM_DIR_NAME, min - base); if (n == -1 || n >= PATH_MAX) return -errno; if (stat(node, &sbuf)) return -EINVAL; - ret = drmProcessPciDevice(&d, d_name, node, DRM_NODE_PRIMARY, - maj, min, true); + subsystem_type = drmParseSubsystemType(maj, min); + if (subsystem_type != DRM_BUS_PCI) + return -ENODEV; + + ret = drmProcessPciDevice(&d, node, node_type, maj, min, true, flags); if (ret) return ret; @@ -3250,6 +3798,9 @@ int drmGetDevice(int fd, drmDevicePtr *device) int max_count = 16; dev_t find_rdev; + if (drm_device_validate_flags(flags)) + return -EINVAL; + if (fd == -1 || device == NULL) return -EINVAL; @@ -3296,12 +3847,33 @@ int drmGetDevice(int fd, drmDevicePtr *device) switch (subsystem_type) { case DRM_BUS_PCI: - ret = drmProcessPciDevice(&d, dent->d_name, node, node_type, - maj, min, true); + ret = drmProcessPciDevice(&d, node, node_type, maj, min, true, flags); if (ret) - goto free_devices; + continue; break; + + case DRM_BUS_USB: + ret = drmProcessUsbDevice(&d, node, node_type, maj, min, true, flags); + if (ret) + continue; + + break; + + case DRM_BUS_PLATFORM: + ret = drmProcessPlatformDevice(&d, node, node_type, maj, min, true, flags); + if (ret) + continue; + + break; + + case DRM_BUS_HOST1X: + ret = drmProcessHost1xDevice(&d, node, node_type, maj, min, true, flags); + if (ret) + continue; + + break; + default: continue; } @@ -3335,7 +3907,7 @@ int drmGetDevice(int fd, drmDevicePtr *device) closedir(sysdir); free(local_devices); if (*device == NULL) - return -ENODEV; + return -ENODEV; return 0; free_devices: @@ -3348,9 +3920,24 @@ free_locals: #endif } +/** + * Get information about the opened drm device + * + * \param fd file descriptor of the drm device + * \param device the address of a drmDevicePtr where the information + * will be allocated in stored + * + * \return zero on success, negative error code otherwise. + */ +int drmGetDevice(int fd, drmDevicePtr *device) +{ + return drmGetDevice2(fd, DRM_DEVICE_GET_PCI_REVISION, device); +} + /** * Get drm devices on the system * + * \param flags feature/behaviour bitmask * \param devices the array of devices with drmDevicePtr elements * can be NULL to get the device number first * \param max_devices the maximum number of devices for the array @@ -3359,8 +3946,11 @@ free_locals: * if devices is NULL - total number of devices available on the system, * alternatively the number of devices stored in devices[], which is * capped by the max_devices. + * + * \note Unlike drmGetDevices it does not retrieve the pci device revision field + * unless the DRM_DEVICE_GET_PCI_REVISION \p flag is set. */ -int drmGetDevices(drmDevicePtr devices[], int max_devices) +int drmGetDevices2(uint32_t flags, drmDevicePtr devices[], int max_devices) { drmDevicePtr *local_devices; drmDevicePtr device; @@ -3373,6 +3963,9 @@ int drmGetDevices(drmDevicePtr devices[], int max_devices) int ret, i, node_count, device_count; int max_count = 16; + if (drm_device_validate_flags(flags)) + return -EINVAL; + local_devices = calloc(max_count, sizeof(drmDevicePtr)); if (local_devices == NULL) return -ENOMEM; @@ -3406,12 +3999,37 @@ int drmGetDevices(drmDevicePtr devices[], int max_devices) switch (subsystem_type) { case DRM_BUS_PCI: - ret = drmProcessPciDevice(&device, dent->d_name, node, node_type, - maj, min, devices != NULL); + ret = drmProcessPciDevice(&device, node, node_type, + maj, min, devices != NULL, flags); + if (ret) + continue; + + break; + + case DRM_BUS_USB: + ret = drmProcessUsbDevice(&device, node, node_type, maj, min, + devices != NULL, flags); if (ret) goto free_devices; break; + + case DRM_BUS_PLATFORM: + ret = drmProcessPlatformDevice(&device, node, node_type, maj, min, + devices != NULL, flags); + if (ret) + goto free_devices; + + break; + + case DRM_BUS_HOST1X: + ret = drmProcessHost1xDevice(&device, node, node_type, maj, min, + devices != NULL, flags); + if (ret) + goto free_devices; + + break; + default: continue; } @@ -3458,3 +4076,92 @@ free_locals: free(local_devices); return ret; } + +/** + * Get drm devices on the system + * + * \param devices the array of devices with drmDevicePtr elements + * can be NULL to get the device number first + * \param max_devices the maximum number of devices for the array + * + * \return on error - negative error code, + * if devices is NULL - total number of devices available on the system, + * alternatively the number of devices stored in devices[], which is + * capped by the max_devices. + */ +int drmGetDevices(drmDevicePtr devices[], int max_devices) +{ + return drmGetDevices2(DRM_DEVICE_GET_PCI_REVISION, devices, max_devices); +} + +char *drmGetDeviceNameFromFd2(int fd) +{ +#ifdef __linux__ + struct stat sbuf; + char path[PATH_MAX + 1], *value; + unsigned int maj, min; + + if (fstat(fd, &sbuf)) + return NULL; + + maj = major(sbuf.st_rdev); + min = minor(sbuf.st_rdev); + + if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) + return NULL; + + snprintf(path, sizeof(path), "/sys/dev/char/%d:%d", maj, min); + + value = sysfs_uevent_get(path, "DEVNAME"); + if (!value) + return NULL; + + snprintf(path, sizeof(path), "/dev/%s", value); + free(value); + + return strdup(path); +#else + struct stat sbuf; + char node[PATH_MAX + 1]; + const char *dev_name; + int node_type; + int maj, min, n, base; + + if (fstat(fd, &sbuf)) + return NULL; + + maj = major(sbuf.st_rdev); + min = minor(sbuf.st_rdev); + + if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) + return NULL; + + node_type = drmGetMinorType(min); + if (node_type == -1) + return NULL; + + switch (node_type) { + case DRM_NODE_PRIMARY: + dev_name = DRM_DEV_NAME; + break; + case DRM_NODE_CONTROL: + dev_name = DRM_CONTROL_DEV_NAME; + break; + case DRM_NODE_RENDER: + dev_name = DRM_RENDER_DEV_NAME; + break; + default: + return NULL; + }; + + base = drmGetMinorBase(node_type); + if (base < 0) + return NULL; + + n = snprintf(node, PATH_MAX, dev_name, DRM_DIR_NAME, min - base); + if (n == -1 || n >= PATH_MAX) + return NULL; + + return strdup(node); +#endif +} diff --git a/lib/libdrm/xf86drm.h b/lib/libdrm/xf86drm.h index 481d882aa..0d927018f 100644 --- a/lib/libdrm/xf86drm.h +++ b/lib/libdrm/xf86drm.h @@ -753,6 +753,11 @@ typedef struct _drmEventContext { extern int drmHandleEvent(int fd, drmEventContextPtr evctx); extern char *drmGetDeviceNameFromFd(int fd); + +/* Improved version of drmGetDeviceNameFromFd which attributes for any type of + * device/node - card, control or renderD. + */ +extern char *drmGetDeviceNameFromFd2(int fd); extern int drmGetNodeTypeFromFd(int fd); extern int drmPrimeHandleToFD(int fd, uint32_t handle, uint32_t flags, int *prime_fd); @@ -761,7 +766,10 @@ extern int drmPrimeFDToHandle(int fd, int prime_fd, uint32_t *handle); extern char *drmGetPrimaryDeviceNameFromFd(int fd); extern char *drmGetRenderDeviceNameFromFd(int fd); -#define DRM_BUS_PCI 0 +#define DRM_BUS_PCI 0 +#define DRM_BUS_USB 1 +#define DRM_BUS_PLATFORM 2 +#define DRM_BUS_HOST1X 3 typedef struct _drmPciBusInfo { uint16_t domain; @@ -778,15 +786,51 @@ typedef struct _drmPciDeviceInfo { uint8_t revision_id; } drmPciDeviceInfo, *drmPciDeviceInfoPtr; +typedef struct _drmUsbBusInfo { + uint8_t bus; + uint8_t dev; +} drmUsbBusInfo, *drmUsbBusInfoPtr; + +typedef struct _drmUsbDeviceInfo { + uint16_t vendor; + uint16_t product; +} drmUsbDeviceInfo, *drmUsbDeviceInfoPtr; + +#define DRM_PLATFORM_DEVICE_NAME_LEN 512 + +typedef struct _drmPlatformBusInfo { + char fullname[DRM_PLATFORM_DEVICE_NAME_LEN]; +} drmPlatformBusInfo, *drmPlatformBusInfoPtr; + +typedef struct _drmPlatformDeviceInfo { + char **compatible; /* NULL terminated list of compatible strings */ +} drmPlatformDeviceInfo, *drmPlatformDeviceInfoPtr; + +#define DRM_HOST1X_DEVICE_NAME_LEN 512 + +typedef struct _drmHost1xBusInfo { + char fullname[DRM_HOST1X_DEVICE_NAME_LEN]; +} drmHost1xBusInfo, *drmHost1xBusInfoPtr; + +typedef struct _drmHost1xDeviceInfo { + char **compatible; /* NULL terminated list of compatible strings */ +} drmHost1xDeviceInfo, *drmHost1xDeviceInfoPtr; + typedef struct _drmDevice { char **nodes; /* DRM_NODE_MAX sized array */ int available_nodes; /* DRM_NODE_* bitmask */ int bustype; union { drmPciBusInfoPtr pci; + drmUsbBusInfoPtr usb; + drmPlatformBusInfoPtr platform; + drmHost1xBusInfoPtr host1x; } businfo; union { drmPciDeviceInfoPtr pci; + drmUsbDeviceInfoPtr usb; + drmPlatformDeviceInfoPtr platform; + drmHost1xDeviceInfoPtr host1x; } deviceinfo; } drmDevice, *drmDevicePtr; @@ -796,6 +840,10 @@ extern void drmFreeDevice(drmDevicePtr *device); extern int drmGetDevices(drmDevicePtr devices[], int max_devices); extern void drmFreeDevices(drmDevicePtr devices[], int count); +#define DRM_DEVICE_GET_PCI_REVISION (1 << 0) +extern int drmGetDevice2(int fd, uint32_t flags, drmDevicePtr *device); +extern int drmGetDevices2(uint32_t flags, drmDevicePtr devices[], int max_devices); + #if defined(__cplusplus) } #endif diff --git a/lib/libdrm/xf86drmMode.c b/lib/libdrm/xf86drmMode.c index fb22f6837..0266bc109 100644 --- a/lib/libdrm/xf86drmMode.c +++ b/lib/libdrm/xf86drmMode.c @@ -901,7 +901,7 @@ int drmHandleEvent(int fd, drmEventContextPtr evctx) i = 0; while (i < len) { - e = (struct drm_event *) &buffer[i]; + e = (struct drm_event *)(buffer + i); switch (e->type) { case DRM_EVENT_VBLANK: if (evctx->version < 1 || diff --git a/lib/libdrm/xf86drmMode.h b/lib/libdrm/xf86drmMode.h index b68496787..5b390d9fb 100644 --- a/lib/libdrm/xf86drmMode.h +++ b/lib/libdrm/xf86drmMode.h @@ -123,13 +123,15 @@ extern "C" { #define DRM_MODE_DITHERING_OFF 0 #define DRM_MODE_DITHERING_ON 1 -#define DRM_MODE_ENCODER_NONE 0 -#define DRM_MODE_ENCODER_DAC 1 -#define DRM_MODE_ENCODER_TMDS 2 -#define DRM_MODE_ENCODER_LVDS 3 -#define DRM_MODE_ENCODER_TVDAC 4 +#define DRM_MODE_ENCODER_NONE 0 +#define DRM_MODE_ENCODER_DAC 1 +#define DRM_MODE_ENCODER_TMDS 2 +#define DRM_MODE_ENCODER_LVDS 3 +#define DRM_MODE_ENCODER_TVDAC 4 #define DRM_MODE_ENCODER_VIRTUAL 5 -#define DRM_MODE_ENCODER_DSI 6 +#define DRM_MODE_ENCODER_DSI 6 +#define DRM_MODE_ENCODER_DPMST 7 +#define DRM_MODE_ENCODER_DPI 8 #define DRM_MODE_SUBCONNECTOR_Automatic 0 #define DRM_MODE_SUBCONNECTOR_Unknown 0 @@ -153,10 +155,11 @@ extern "C" { #define DRM_MODE_CONNECTOR_DisplayPort 10 #define DRM_MODE_CONNECTOR_HDMIA 11 #define DRM_MODE_CONNECTOR_HDMIB 12 -#define DRM_MODE_CONNECTOR_TV 13 -#define DRM_MODE_CONNECTOR_eDP 14 +#define DRM_MODE_CONNECTOR_TV 13 +#define DRM_MODE_CONNECTOR_eDP 14 #define DRM_MODE_CONNECTOR_VIRTUAL 15 #define DRM_MODE_CONNECTOR_DSI 16 +#define DRM_MODE_CONNECTOR_DPI 17 #define DRM_MODE_PROP_PENDING (1<<0) #define DRM_MODE_PROP_RANGE (1<<1)