diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2016-10-16 06:11:12 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2016-10-16 06:11:12 +0000 |
commit | b1f001d8d4458cc7e6a324490ffef53aaca9a93c (patch) | |
tree | 8614e7a23dfe855a578134c9766b553a375c87b5 | |
parent | dbfc47a13e7838592fd16d549f2a654ebfc102bd (diff) |
Merge libdrm 2.4.71
36 files changed, 1437 insertions, 1641 deletions
diff --git a/lib/libdrm/Android.mk b/lib/libdrm/Android.mk deleted file mode 100644 index 90cdcb323..000000000 --- a/lib/libdrm/Android.mk +++ /dev/null @@ -1,47 +0,0 @@ -# -# Copyright © 2011-2012 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. -# - -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -# Import variables LIBDRM_{,H_,INCLUDE_H_,INCLUDE_VMWGFX_H_}FILES -include $(LOCAL_PATH)/Makefile.sources - -LOCAL_MODULE := libdrm -LOCAL_MODULE_TAGS := optional - -LOCAL_SRC_FILES := $(LIBDRM_FILES) -LOCAL_EXPORT_C_INCLUDE_DIRS := \ - $(LOCAL_PATH) \ - $(LOCAL_PATH)/include/drm - -LOCAL_C_INCLUDES := \ - $(LOCAL_PATH)/include/drm - -LOCAL_CFLAGS := \ - -DHAVE_VISIBILITY=1 \ - -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1 - -include $(BUILD_SHARED_LIBRARY) - -include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/lib/libdrm/Makefile.am b/lib/libdrm/Makefile.am index feecba72c..630edc4c2 100644 --- a/lib/libdrm/Makefile.am +++ b/lib/libdrm/Makefile.am @@ -36,6 +36,7 @@ AM_DISTCHECK_CONFIGURE_FLAGS = \ --enable-freedreno \ --enable-freedreno-kgsl\ --enable-tegra-experimental-api \ + --enable-etnaviv-experimental-api \ --enable-install-test-programs \ --enable-cairo-tests \ --enable-manpages \ @@ -84,6 +85,10 @@ if HAVE_VC4 VC4_SUBDIR = vc4 endif +if HAVE_ETNAVIV +ETNAVIV_SUBDIR = etnaviv +endif + if BUILD_MANPAGES if HAVE_MANPAGES_STYLESHEET MAN_SUBDIR = man @@ -102,6 +107,7 @@ SUBDIRS = \ $(FREEDRENO_SUBDIR) \ $(TEGRA_SUBDIR) \ $(VC4_SUBDIR) \ + $(ETNAVIV_SUBDIR) \ tests \ $(MAN_SUBDIR) @@ -120,8 +126,6 @@ libdrm_la_SOURCES = $(LIBDRM_FILES) libdrmincludedir = ${includedir} libdrminclude_HEADERS = $(LIBDRM_H_FILES) -EXTRA_DIST = Android.mk - klibdrmincludedir = ${includedir}/libdrm klibdrminclude_HEADERS = $(LIBDRM_INCLUDE_H_FILES) diff --git a/lib/libdrm/Makefile.bsd-wrapper b/lib/libdrm/Makefile.bsd-wrapper index 5d71a9857..0434661a4 100644 --- a/lib/libdrm/Makefile.bsd-wrapper +++ b/lib/libdrm/Makefile.bsd-wrapper @@ -1,6 +1,6 @@ -# $OpenBSD: Makefile.bsd-wrapper,v 1.7 2016/03/20 10:41:29 jsg Exp $ +# $OpenBSD: Makefile.bsd-wrapper,v 1.8 2016/10/16 06:11:11 jsg Exp $ -SHARED_LIBS= drm 7.1 drm_radeon 4.0 drm_intel 5.1 \ +SHARED_LIBS= drm 7.2 drm_radeon 4.0 drm_intel 5.2 \ drm_amdgpu 1.1 drm_nouveau 3.0 .include <bsd.xorg.mk> diff --git a/lib/libdrm/Makefile.in b/lib/libdrm/Makefile.in index 7cf08ffe1..a4315e39c 100644 --- a/lib/libdrm/Makefile.in +++ b/lib/libdrm/Makefile.in @@ -202,7 +202,7 @@ am__klibdrminclude_HEADERS_DIST = include/drm/drm.h \ include/drm/amdgpu_drm.h include/drm/savage_drm.h \ include/drm/sis_drm.h include/drm/tegra_drm.h \ include/drm/vc4_drm.h include/drm/via_drm.h \ - include/drm/vmwgfx_drm.h + include/drm/virtgpu_drm.h include/drm/vmwgfx_drm.h HEADERS = $(klibdrminclude_HEADERS) $(libdrminclude_HEADERS) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive @@ -213,7 +213,7 @@ ETAGS = etags CTAGS = ctags CSCOPE = cscope DIST_SUBDIRS = . libkms intel nouveau radeon amdgpu omap exynos \ - freedreno tegra vc4 tests man + freedreno tegra vc4 etnaviv tests man DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) @@ -442,7 +442,8 @@ LIBDRM_INCLUDE_H_FILES := \ include/drm/sis_drm.h \ include/drm/tegra_drm.h \ include/drm/vc4_drm.h \ - include/drm/via_drm.h + include/drm/via_drm.h \ + include/drm/virtgpu_drm.h LIBDRM_INCLUDE_VMWGFX_H_FILES := \ include/drm/vmwgfx_drm.h @@ -462,6 +463,7 @@ AM_DISTCHECK_CONFIGURE_FLAGS = \ --enable-freedreno \ --enable-freedreno-kgsl\ --enable-tegra-experimental-api \ + --enable-etnaviv-experimental-api \ --enable-install-test-programs \ --enable-cairo-tests \ --enable-manpages \ @@ -478,6 +480,7 @@ pkgconfig_DATA = libdrm.pc @HAVE_FREEDRENO_TRUE@FREEDRENO_SUBDIR = freedreno @HAVE_TEGRA_TRUE@TEGRA_SUBDIR = tegra @HAVE_VC4_TRUE@VC4_SUBDIR = vc4 +@HAVE_ETNAVIV_TRUE@ETNAVIV_SUBDIR = etnaviv @BUILD_MANPAGES_TRUE@@HAVE_MANPAGES_STYLESHEET_TRUE@MAN_SUBDIR = man SUBDIRS = \ . \ @@ -491,6 +494,7 @@ SUBDIRS = \ $(FREEDRENO_SUBDIR) \ $(TEGRA_SUBDIR) \ $(VC4_SUBDIR) \ + $(ETNAVIV_SUBDIR) \ tests \ $(MAN_SUBDIR) @@ -506,7 +510,6 @@ AM_CFLAGS = \ libdrm_la_SOURCES = $(LIBDRM_FILES) libdrmincludedir = ${includedir} libdrminclude_HEADERS = $(LIBDRM_H_FILES) -EXTRA_DIST = Android.mk klibdrmincludedir = ${includedir}/libdrm klibdrminclude_HEADERS = $(LIBDRM_INCLUDE_H_FILES) $(am__append_1) all: config.h diff --git a/lib/libdrm/config.h.in b/lib/libdrm/config.h.in index 0ae3589fc..3072cd9ac 100644 --- a/lib/libdrm/config.h.in +++ b/lib/libdrm/config.h.in @@ -30,6 +30,9 @@ /* Define to 1 if you have the <dlfcn.h> header file. */ #undef HAVE_DLFCN_H +/* Have etnaviv support */ +#undef HAVE_ETNAVIV + /* Have EXYNOS support */ #undef HAVE_EXYNOS @@ -84,9 +87,6 @@ /* Define to 1 if you have the <string.h> header file. */ #undef HAVE_STRING_H -/* Define to 1 if you have the <sys/mkdev.h> header file. */ -#undef HAVE_SYS_MKDEV_H - /* Define to 1 if you have the <sys/select.h> header file. */ #undef HAVE_SYS_SELECT_H @@ -121,6 +121,14 @@ */ #undef LT_OBJDIR +/* Define to 1 if `major', `minor', and `makedev' are declared in <mkdev.h>. + */ +#undef MAJOR_IN_MKDEV + +/* Define to 1 if `major', `minor', and `makedev' are declared in + <sysmacros.h>. */ +#undef MAJOR_IN_SYSMACROS + /* Name of package */ #undef PACKAGE diff --git a/lib/libdrm/configure b/lib/libdrm/configure index 31c066c9c..20189573a 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.67. +# Generated by GNU Autoconf 2.69 for libdrm 2.4.71. # # Report bugs to <https://bugs.freedesktop.org/enter_bug.cgi?product=DRI>. # @@ -591,8 +591,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='libdrm' PACKAGE_TARNAME='libdrm' -PACKAGE_VERSION='2.4.67' -PACKAGE_STRING='libdrm 2.4.67' +PACKAGE_VERSION='2.4.71' +PACKAGE_STRING='libdrm 2.4.71' PACKAGE_BUGREPORT='https://bugs.freedesktop.org/enter_bug.cgi?product=DRI' PACKAGE_URL='' @@ -656,6 +656,8 @@ CAIRO_LIBS CAIRO_CFLAGS HAVE_INSTALL_TESTS_FALSE HAVE_INSTALL_TESTS_TRUE +HAVE_ETNAVIV_FALSE +HAVE_ETNAVIV_TRUE HAVE_VC4_FALSE HAVE_VC4_TRUE HAVE_TEGRA_FALSE @@ -854,6 +856,7 @@ enable_freedreno enable_freedreno_kgsl enable_tegra_experimental_api enable_vc4 +enable_etnaviv_experimental_api enable_install_test_programs enable_cairo_tests enable_manpages @@ -1425,7 +1428,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.67 to adapt to many kinds of systems. +\`configure' configures libdrm 2.4.71 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1495,7 +1498,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libdrm 2.4.67:";; + short | recursive ) echo "Configuration of libdrm 2.4.71:";; esac cat <<\_ACEOF @@ -1543,6 +1546,9 @@ Optional Features: (default: disabled) --disable-vc4 Enable support for vc4's API (default: auto, enabled on arm) + --enable-etnaviv-experimental-api + Enable support for etnaviv's experimental API + (default: disabled) --enable-install-test-programs Install test programs (default: no) --enable-cairo-tests Enable support for Cairo rendering in tests @@ -1666,7 +1672,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -libdrm configure 2.4.67 +libdrm configure 2.4.71 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2089,7 +2095,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.67, which was +It was created by libdrm $as_me 2.4.71, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3312,7 +3318,7 @@ fi # Define the identity of the package. PACKAGE='libdrm' - VERSION='2.4.67' + VERSION='2.4.71' cat >>confdefs.h <<_ACEOF @@ -5420,7 +5426,57 @@ _ACEOF fi -for ac_header in sys/mkdev.h sys/sysctl.h sys/select.h +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether sys/types.h defines makedev" >&5 +$as_echo_n "checking whether sys/types.h defines makedev... " >&6; } +if ${ac_cv_header_sys_types_h_makedev+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <sys/types.h> +int +main () +{ +return makedev(0, 0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_header_sys_types_h_makedev=yes +else + ac_cv_header_sys_types_h_makedev=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_sys_types_h_makedev" >&5 +$as_echo "$ac_cv_header_sys_types_h_makedev" >&6; } + +if test $ac_cv_header_sys_types_h_makedev = no; then +ac_fn_c_check_header_mongrel "$LINENO" "sys/mkdev.h" "ac_cv_header_sys_mkdev_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_mkdev_h" = xyes; then : + +$as_echo "#define MAJOR_IN_MKDEV 1" >>confdefs.h + +fi + + + + if test $ac_cv_header_sys_mkdev_h = no; then + ac_fn_c_check_header_mongrel "$LINENO" "sys/sysmacros.h" "ac_cv_header_sys_sysmacros_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_sysmacros_h" = xyes; then : + +$as_echo "#define MAJOR_IN_SYSMACROS 1" >>confdefs.h + +fi + + + fi +fi + +for ac_header in sys/sysctl.h sys/select.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" @@ -12870,6 +12926,14 @@ else fi +# Check whether --enable-etnaviv-experimental-api was given. +if test "${enable_etnaviv_experimental_api+set}" = set; then : + enableval=$enable_etnaviv_experimental_api; ETNAVIV=$enableval +else + ETNAVIV=no +fi + + # Check whether --enable-install-test-programs was given. if test "${enable_install_test_programs+set}" = set; then : enableval=$enable_install_test_programs; INSTALL_TESTS=$enableval @@ -13160,6 +13224,16 @@ $as_echo "$as_me: WARNING: Disabling tegra. It depends on atomic operations, whi esac TEGRA=no + + + case "x$ETNAVIV" in + xyes) as_fn_error $? "libdrm_etnaviv depends upon atomic operations, which were not found for your compiler/cpu. Try compiling with -march=native, or install the libatomics-op-dev package, or, failing both of those, disable support for Vivante GPUs by passing --disable-etnaviv-experimental-api to ./configure" "$LINENO" 5 ;; + xauto) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Disabling etnaviv. It depends on atomic operations, which were not found for your compiler/cpu. Try compiling with -march=native, or install the libatomics-op-dev package." >&5 +$as_echo "$as_me: WARNING: Disabling etnaviv. It depends on atomic operations, which were not found for your compiler/cpu. Try compiling with -march=native, or install the libatomics-op-dev package." >&2;} ;; + *) ;; + esac + + ETNAVIV=no else if test "x$INTEL" = xauto; then case $host_cpu in @@ -13618,6 +13692,20 @@ $as_echo "#define HAVE_VC4 1" >>confdefs.h fi + if test "x$ETNAVIV" = xyes; then + HAVE_ETNAVIV_TRUE= + HAVE_ETNAVIV_FALSE='#' +else + HAVE_ETNAVIV_TRUE='#' + HAVE_ETNAVIV_FALSE= +fi + +if test "x$ETNAVIV" = xyes; then + +$as_echo "#define HAVE_ETNAVIV 1" >>confdefs.h + +fi + if test "x$INSTALL_TESTS" = xyes; then HAVE_INSTALL_TESTS_TRUE= HAVE_INSTALL_TESTS_FALSE='#' @@ -14025,7 +14113,7 @@ $as_echo "#define HAVE_VISIBILITY 1" >>confdefs.h fi -ac_config_files="$ac_config_files Makefile libkms/Makefile libkms/libkms.pc intel/Makefile intel/libdrm_intel.pc radeon/Makefile radeon/libdrm_radeon.pc amdgpu/Makefile amdgpu/libdrm_amdgpu.pc nouveau/Makefile nouveau/libdrm_nouveau.pc omap/Makefile omap/libdrm_omap.pc exynos/Makefile exynos/libdrm_exynos.pc freedreno/Makefile freedreno/libdrm_freedreno.pc tegra/Makefile tegra/libdrm_tegra.pc vc4/Makefile vc4/libdrm_vc4.pc tests/Makefile tests/modeprint/Makefile tests/modetest/Makefile tests/kms/Makefile tests/kmstest/Makefile tests/proptest/Makefile tests/radeon/Makefile tests/amdgpu/Makefile tests/vbltest/Makefile tests/exynos/Makefile tests/tegra/Makefile tests/nouveau/Makefile tests/util/Makefile man/Makefile libdrm.pc" +ac_config_files="$ac_config_files Makefile libkms/Makefile libkms/libkms.pc intel/Makefile intel/libdrm_intel.pc radeon/Makefile radeon/libdrm_radeon.pc amdgpu/Makefile amdgpu/libdrm_amdgpu.pc nouveau/Makefile nouveau/libdrm_nouveau.pc omap/Makefile omap/libdrm_omap.pc exynos/Makefile exynos/libdrm_exynos.pc freedreno/Makefile freedreno/libdrm_freedreno.pc tegra/Makefile tegra/libdrm_tegra.pc vc4/Makefile vc4/libdrm_vc4.pc etnaviv/Makefile etnaviv/libdrm_etnaviv.pc tests/Makefile tests/modeprint/Makefile tests/modetest/Makefile tests/kms/Makefile tests/kmstest/Makefile tests/proptest/Makefile tests/radeon/Makefile tests/amdgpu/Makefile tests/vbltest/Makefile tests/exynos/Makefile tests/tegra/Makefile tests/nouveau/Makefile tests/etnaviv/Makefile tests/util/Makefile man/Makefile libdrm.pc" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -14220,6 +14308,10 @@ if test -z "${HAVE_VC4_TRUE}" && test -z "${HAVE_VC4_FALSE}"; then as_fn_error $? "conditional \"HAVE_VC4\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${HAVE_ETNAVIV_TRUE}" && test -z "${HAVE_ETNAVIV_FALSE}"; then + as_fn_error $? "conditional \"HAVE_ETNAVIV\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${HAVE_INSTALL_TESTS_TRUE}" && test -z "${HAVE_INSTALL_TESTS_FALSE}"; then as_fn_error $? "conditional \"HAVE_INSTALL_TESTS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 @@ -14637,7 +14729,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.67, which was +This file was extended by libdrm $as_me 2.4.71, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -14703,7 +14795,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.67 +libdrm config.status 2.4.71 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" @@ -15133,6 +15225,8 @@ do "tegra/libdrm_tegra.pc") CONFIG_FILES="$CONFIG_FILES tegra/libdrm_tegra.pc" ;; "vc4/Makefile") CONFIG_FILES="$CONFIG_FILES vc4/Makefile" ;; "vc4/libdrm_vc4.pc") CONFIG_FILES="$CONFIG_FILES vc4/libdrm_vc4.pc" ;; + "etnaviv/Makefile") CONFIG_FILES="$CONFIG_FILES etnaviv/Makefile" ;; + "etnaviv/libdrm_etnaviv.pc") CONFIG_FILES="$CONFIG_FILES etnaviv/libdrm_etnaviv.pc" ;; "tests/Makefile") CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;; "tests/modeprint/Makefile") CONFIG_FILES="$CONFIG_FILES tests/modeprint/Makefile" ;; "tests/modetest/Makefile") CONFIG_FILES="$CONFIG_FILES tests/modetest/Makefile" ;; @@ -15145,6 +15239,7 @@ do "tests/exynos/Makefile") CONFIG_FILES="$CONFIG_FILES tests/exynos/Makefile" ;; "tests/tegra/Makefile") CONFIG_FILES="$CONFIG_FILES tests/tegra/Makefile" ;; "tests/nouveau/Makefile") CONFIG_FILES="$CONFIG_FILES tests/nouveau/Makefile" ;; + "tests/etnaviv/Makefile") CONFIG_FILES="$CONFIG_FILES tests/etnaviv/Makefile" ;; "tests/util/Makefile") CONFIG_FILES="$CONFIG_FILES tests/util/Makefile" ;; "man/Makefile") CONFIG_FILES="$CONFIG_FILES man/Makefile" ;; "libdrm.pc") CONFIG_FILES="$CONFIG_FILES libdrm.pc" ;; @@ -16519,4 +16614,5 @@ echo " EXYNOS API $EXYNOS" echo " Freedreno API $FREEDRENO (kgsl: $FREEDRENO_KGSL)" echo " Tegra API $TEGRA" echo " VC4 API $VC4" +echo " Etnaviv API $ETNAVIV" echo "" diff --git a/lib/libdrm/configure.ac b/lib/libdrm/configure.ac index ed077894a..ac6b106a8 100644 --- a/lib/libdrm/configure.ac +++ b/lib/libdrm/configure.ac @@ -20,7 +20,7 @@ AC_PREREQ([2.63]) AC_INIT([libdrm], - [2.4.67], + [2.4.71], [https://bugs.freedesktop.org/enter_bug.cgi?product=DRI], [libdrm]) @@ -53,7 +53,8 @@ AC_USE_SYSTEM_EXTENSIONS AC_SYS_LARGEFILE AC_FUNC_ALLOCA -AC_CHECK_HEADERS([sys/mkdev.h sys/sysctl.h sys/select.h]) +AC_HEADER_MAJOR +AC_CHECK_HEADERS([sys/sysctl.h sys/select.h]) # Initialize libtool LT_PREREQ([2.2]) @@ -131,6 +132,11 @@ AC_ARG_ENABLE(vc4, [Enable support for vc4's API (default: auto, enabled on arm)]), [VC4=$enableval], [VC4=auto]) +AC_ARG_ENABLE(etnaviv-experimental-api, + AS_HELP_STRING([--enable-etnaviv-experimental-api], + [Enable support for etnaviv's experimental API (default: disabled)]), + [ETNAVIV=$enableval], [ETNAVIV=no]) + AC_ARG_ENABLE(install-test-programs, AS_HELP_STRING([--enable-install-test-programs], [Install test programs (default: no)]), @@ -273,6 +279,9 @@ if test "x$drm_cv_atomic_primitives" = "xnone"; then LIBDRM_ATOMICS_NOT_FOUND_MSG($TEGRA, tegra, NVIDIA Tegra, tegra-experimental-api) TEGRA=no + + LIBDRM_ATOMICS_NOT_FOUND_MSG($ETNAVIV, etnaviv, Vivante, etnaviv-experimental-api) + ETNAVIV=no else if test "x$INTEL" = xauto; then case $host_cpu in @@ -412,6 +421,11 @@ if test "x$VC4" = xyes; then AC_DEFINE(HAVE_VC4, 1, [Have VC4 support]) fi +AM_CONDITIONAL(HAVE_ETNAVIV, [test "x$ETNAVIV" = xyes]) +if test "x$ETNAVIV" = xyes; then + AC_DEFINE(HAVE_ETNAVIV, 1, [Have etnaviv support]) +fi + AM_CONDITIONAL(HAVE_INSTALL_TESTS, [test "x$INSTALL_TESTS" = xyes]) if test "x$INSTALL_TESTS" = xyes; then AC_DEFINE(HAVE_INSTALL_TESTS, 1, [Install test programs]) @@ -523,6 +537,8 @@ AC_CONFIG_FILES([ tegra/libdrm_tegra.pc vc4/Makefile vc4/libdrm_vc4.pc + etnaviv/Makefile + etnaviv/libdrm_etnaviv.pc tests/Makefile tests/modeprint/Makefile tests/modetest/Makefile @@ -535,6 +551,7 @@ AC_CONFIG_FILES([ tests/exynos/Makefile tests/tegra/Makefile tests/nouveau/Makefile + tests/etnaviv/Makefile tests/util/Makefile man/Makefile libdrm.pc]) @@ -554,4 +571,5 @@ echo " EXYNOS API $EXYNOS" echo " Freedreno API $FREEDRENO (kgsl: $FREEDRENO_KGSL)" echo " Tegra API $TEGRA" echo " VC4 API $VC4" +echo " Etnaviv API $ETNAVIV" echo "" diff --git a/lib/libdrm/etnaviv/Makefile.in b/lib/libdrm/etnaviv/Makefile.in index 448bd010b..e010470bd 100644 --- a/lib/libdrm/etnaviv/Makefile.in +++ b/lib/libdrm/etnaviv/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2012 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -17,61 +17,23 @@ VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ +am__make_dryrun = \ + { \ + am__dry=no; \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) + test $$am__dry = yes; \ + } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -90,6 +52,9 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ +DIST_COMMON = $(libdrm_etnavivinclude_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(srcdir)/Makefile.sources \ + $(srcdir)/libdrm_etnaviv.pc.in $(top_srcdir)/build-aux/depcomp subdir = etnaviv ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ @@ -98,8 +63,6 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(libdrm_etnavivinclude_HEADERS) \ - $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = libdrm_etnaviv.pc @@ -191,205 +154,12 @@ am__can_run_installinfo = \ esac DATA = $(pkgconfig_DATA) HEADERS = $(libdrm_etnavivinclude_HEADERS) -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__tty_colors_dummy = \ mgn= red= grn= lgn= blu= brg= std=; \ am__color_tests=no -am__tty_colors = { \ - $(am__tty_colors_dummy); \ - if test "X$(AM_COLOR_TESTS)" = Xno; then \ - am__color_tests=no; \ - elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ - am__color_tests=yes; \ - elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ - am__color_tests=yes; \ - fi; \ - if test $$am__color_tests = yes; then \ - red='[0;31m'; \ - grn='[0;32m'; \ - lgn='[1;32m'; \ - blu='[1;34m'; \ - mgn='[0;35m'; \ - brg='[1m'; \ - std='[m'; \ - fi; \ -} -am__recheck_rx = ^[ ]*:recheck:[ ]* -am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* -am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* -# A command that, given a newline-separated list of test names on the -# standard input, print the name of the tests that are to be re-run -# upon "make recheck". -am__list_recheck_tests = $(AWK) '{ \ - recheck = 1; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - { \ - if ((getline line2 < ($$0 ".log")) < 0) \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ - { \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ - { \ - break; \ - } \ - }; \ - if (recheck) \ - print $$0; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# A command that, given a newline-separated list of test names on the -# standard input, create the global log from their .trs and .log files. -am__create_global_log = $(AWK) ' \ -function fatal(msg) \ -{ \ - print "fatal: making $@: " msg | "cat >&2"; \ - exit 1; \ -} \ -function rst_section(header) \ -{ \ - print header; \ - len = length(header); \ - for (i = 1; i <= len; i = i + 1) \ - printf "="; \ - printf "\n\n"; \ -} \ -{ \ - copy_in_global_log = 1; \ - global_test_result = "RUN"; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".trs"); \ - if (line ~ /$(am__global_test_result_rx)/) \ - { \ - sub("$(am__global_test_result_rx)", "", line); \ - sub("[ ]*$$", "", line); \ - global_test_result = line; \ - } \ - else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ - copy_in_global_log = 0; \ - }; \ - if (copy_in_global_log) \ - { \ - rst_section(global_test_result ": " $$0); \ - while ((rc = (getline line < ($$0 ".log"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".log"); \ - print line; \ - }; \ - printf "\n"; \ - }; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# Restructured Text title. -am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } -# Solaris 10 'make', and several other traditional 'make' implementations, -# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it -# by disabling -e (using the XSI extension "set +e") if it's set. -am__sh_e_setup = case $$- in *e*) set +e;; esac -# Default flags passed to test drivers. -am__common_driver_flags = \ - --color-tests "$$am__color_tests" \ - --enable-hard-errors "$$am__enable_hard_errors" \ - --expect-failure "$$am__expect_failure" -# To be inserted before the command running the test. Creates the -# directory for the log if needed. Stores in $dir the directory -# containing $f, in $tst the test, in $log the log. Executes the -# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and -# passes TESTS_ENVIRONMENT. Set up options for the wrapper that -# will run the test scripts (or their associated LOG_COMPILER, if -# thy have one). -am__check_pre = \ -$(am__sh_e_setup); \ -$(am__vpath_adj_setup) $(am__vpath_adj) \ -$(am__tty_colors); \ -srcdir=$(srcdir); export srcdir; \ -case "$@" in \ - */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ - *) am__odir=.;; \ -esac; \ -test "x$$am__odir" = x"." || test -d "$$am__odir" \ - || $(MKDIR_P) "$$am__odir" || exit $$?; \ -if test -f "./$$f"; then dir=./; \ -elif test -f "$$f"; then dir=; \ -else dir="$(srcdir)/"; fi; \ -tst=$$dir$$f; log='$@'; \ -if test -n '$(DISABLE_HARD_ERRORS)'; then \ - am__enable_hard_errors=no; \ -else \ - am__enable_hard_errors=yes; \ -fi; \ -case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ - am__expect_failure=yes;; \ - *) \ - am__expect_failure=no;; \ -esac; \ -$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) -# A shell command to get the names of the tests scripts with any registered -# extension removed (i.e., equivalently, the names of the test logs, with -# the '.log' extension removed). The result is saved in the shell variable -# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, -# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", -# since that might cause problem with VPATH rewrites for suffix-less tests. -# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. -am__set_TESTS_bases = \ - bases='$(TEST_LOGS)'; \ - bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ - bases=`echo $$bases` -RECHECK_LOGS = $(TEST_LOGS) -AM_RECURSIVE_TARGETS = check recheck -TEST_SUITE_LOG = test-suite.log -TEST_EXTENSIONS = @EXEEXT@ .test -LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver -LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) -am__set_b = \ - case '$@' in \ - */*) \ - case '$*' in \ - */*) b='$*';; \ - *) b=`echo '$@' | sed 's/\.log$$//'`; \ - esac;; \ - *) \ - b='$*';; \ - esac -am__test_logs1 = $(TESTS:=.log) -am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) -TEST_LOGS = $(am__test_logs2:.test.log=.log) -TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver -TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ - $(TEST_LOG_FLAGS) -am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.sources \ - $(srcdir)/libdrm_etnaviv.pc.in $(top_srcdir)/build-aux/depcomp \ - $(top_srcdir)/build-aux/test-driver +am__tty_colors = $(am__tty_colors_dummy) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ @@ -448,7 +218,7 @@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MANPAGES_STYLESHEET = @MANPAGES_STYLESHEET@ @@ -578,8 +348,8 @@ EXTRA_DIST = $(TESTS) all: all-am .SUFFIXES: -.SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/Makefile.sources $(am__configure_deps) +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/Makefile.sources $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ @@ -591,6 +361,7 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/Makefile.sources $(am__c echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign etnaviv/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign etnaviv/Makefile +.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -599,19 +370,18 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; -$(srcdir)/Makefile.sources $(am__empty): +$(srcdir)/Makefile.sources: $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(top_srcdir)/configure: $(am__configure_deps) +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): libdrm_etnaviv.pc: $(top_builddir)/config.status $(srcdir)/libdrm_etnaviv.pc.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ - install-libdrm_etnaviv_laLTLIBRARIES: $(libdrm_etnaviv_la_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(libdrm_etnaviv_la_LTLIBRARIES)'; test -n "$(libdrm_etnaviv_ladir)" || list=; \ @@ -646,7 +416,6 @@ clean-libdrm_etnaviv_laLTLIBRARIES: echo rm -f $${locs}; \ rm -f $${locs}; \ } - libdrm_etnaviv.la: $(libdrm_etnaviv_la_OBJECTS) $(libdrm_etnaviv_la_DEPENDENCIES) $(EXTRA_libdrm_etnaviv_la_DEPENDENCIES) $(AM_V_CCLD)$(libdrm_etnaviv_la_LINK) -rpath $(libdrm_etnaviv_ladir) $(libdrm_etnaviv_la_OBJECTS) $(libdrm_etnaviv_la_LIBADD) $(LIBS) @@ -668,14 +437,14 @@ distclean-compile: @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -732,15 +501,26 @@ uninstall-libdrm_etnavivincludeHEADERS: files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(libdrm_etnavivincludedir)'; $(am__uninstall_files_from_dir) -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ - $(am__define_uniq_tagged_files); \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ @@ -752,11 +532,15 @@ tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $$unique; \ fi; \ fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique @@ -765,10 +549,9 @@ GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ +cscopelist: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ @@ -784,168 +567,98 @@ cscopelist-am: $(am__tagged_files) distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -# Recover from deleted '.trs' file; this should ensure that -# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create -# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells -# to avoid problems with "make -n". -.log.trs: - rm -f $< $@ - $(MAKE) $(AM_MAKEFLAGS) $< - -# Leading 'am--fnord' is there to ensure the list of targets does not -# expand to empty, as could happen e.g. with make check TESTS=''. -am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) -am--force-recheck: - @: - -$(TEST_SUITE_LOG): $(TEST_LOGS) - @$(am__set_TESTS_bases); \ - am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ - redo_bases=`for i in $$bases; do \ - am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ - done`; \ - if test -n "$$redo_bases"; then \ - redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ - redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ - if $(am__make_dryrun); then :; else \ - rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ - fi; \ - fi; \ - if test -n "$$am__remaking_logs"; then \ - echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ - "recursion detected" >&2; \ - elif test -n "$$redo_logs"; then \ - am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ - fi; \ - if $(am__make_dryrun); then :; else \ - st=0; \ - errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ - for i in $$redo_bases; do \ - test -f $$i.trs && test -r $$i.trs \ - || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ - test -f $$i.log && test -r $$i.log \ - || { echo "$$errmsg $$i.log" >&2; st=1; }; \ +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; \ + srcdir=$(srcdir); export srcdir; \ + list=' $(TESTS) '; \ + $(am__tty_colors); \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst $(AM_TESTS_FD_REDIRECT); then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + col=$$red; res=XPASS; \ + ;; \ + *) \ + col=$$grn; res=PASS; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xfail=`expr $$xfail + 1`; \ + col=$$lgn; res=XFAIL; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + col=$$red; res=FAIL; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + col=$$blu; res=SKIP; \ + fi; \ + echo "$${col}$$res$${std}: $$tst"; \ done; \ - test $$st -eq 0 || exit 1; \ - fi - @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ - ws='[ ]'; \ - results=`for b in $$bases; do echo $$b.trs; done`; \ - test -n "$$results" || results=/dev/null; \ - all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ - pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ - fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ - skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ - xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ - xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ - error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ - if test `expr $$fail + $$xpass + $$error` -eq 0; then \ - success=true; \ - else \ - success=false; \ - fi; \ - br='==================='; br=$$br$$br$$br$$br; \ - result_count () \ - { \ - if test x"$$1" = x"--maybe-color"; then \ - maybe_colorize=yes; \ - elif test x"$$1" = x"--no-color"; then \ - maybe_colorize=no; \ + if test "$$all" -eq 1; then \ + tests="test"; \ + All=""; \ + else \ + tests="tests"; \ + All="All "; \ + fi; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="$$All$$all $$tests passed"; \ + else \ + if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ + banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all $$tests failed"; \ else \ - echo "$@: invalid 'result_count' usage" >&2; exit 4; \ + if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ + banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ fi; \ - shift; \ - desc=$$1 count=$$2; \ - if test $$maybe_colorize = yes && test $$count -gt 0; then \ - color_start=$$3 color_end=$$std; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + if test "$$skip" -eq 1; then \ + skipped="($$skip test was not run)"; \ else \ - color_start= color_end=; \ + skipped="($$skip tests were not run)"; \ fi; \ - echo "$${color_start}# $$desc $$count$${color_end}"; \ - }; \ - create_testsuite_report () \ - { \ - result_count $$1 "TOTAL:" $$all "$$brg"; \ - result_count $$1 "PASS: " $$pass "$$grn"; \ - result_count $$1 "SKIP: " $$skip "$$blu"; \ - result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ - result_count $$1 "FAIL: " $$fail "$$red"; \ - result_count $$1 "XPASS:" $$xpass "$$red"; \ - result_count $$1 "ERROR:" $$error "$$mgn"; \ - }; \ - { \ - echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ - $(am__rst_title); \ - create_testsuite_report --no-color; \ - echo; \ - echo ".. contents:: :depth: 2"; \ - echo; \ - for b in $$bases; do echo $$b; done \ - | $(am__create_global_log); \ - } >$(TEST_SUITE_LOG).tmp || exit 1; \ - mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ - if $$success; then \ - col="$$grn"; \ - else \ - col="$$red"; \ - test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ - fi; \ - echo "$${col}$$br$${std}"; \ - echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ - echo "$${col}$$br$${std}"; \ - create_testsuite_report --maybe-color; \ - echo "$$col$$br$$std"; \ - if $$success; then :; else \ - echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ - if test -n "$(PACKAGE_BUGREPORT)"; then \ - echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ - fi; \ - echo "$$col$$br$$std"; \ - fi; \ - $$success || exit 1 - -check-TESTS: - @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list - @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - trs_list=`for i in $$bases; do echo $$i.trs; done`; \ - log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ - exit $$?; -recheck: all - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - bases=`for i in $$bases; do echo $$i; done \ - | $(am__list_recheck_tests)` || exit 1; \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - log_list=`echo $$log_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ - am__force_recheck=am--force-recheck \ - TEST_LOGS="$$log_list"; \ - exit $$? -etnaviv-symbol-check.log: etnaviv-symbol-check - @p='etnaviv-symbol-check'; \ - b='etnaviv-symbol-check'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -.test.log: - @p='$<'; \ - $(am__set_b); \ - $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -@am__EXEEXT_TRUE@.test$(EXEEXT).log: -@am__EXEEXT_TRUE@ @p='$<'; \ -@am__EXEEXT_TRUE@ $(am__set_b); \ -@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ -@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ -@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ -@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + if test "$$failed" -eq 0; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + fi; \ + echo "$${col}$$dashes$${std}"; \ + echo "$${col}$$banner$${std}"; \ + test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \ + test -z "$$report" || echo "$${col}$$report$${std}"; \ + echo "$${col}$$dashes$${std}"; \ + test "$$failed" -eq 0; \ + else :; fi distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ @@ -1005,9 +718,6 @@ install-strip: "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: - -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) - -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) - -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) clean-generic: @@ -1093,26 +803,23 @@ uninstall-am: uninstall-libdrm_etnaviv_laLTLIBRARIES \ .MAKE: check-am install-am install-strip -.PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \ +.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \ clean-generic clean-libdrm_etnaviv_laLTLIBRARIES clean-libtool \ - cscopelist-am ctags ctags-am 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-libdrm_etnaviv_laLTLIBRARIES \ + cscopelist ctags 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-libdrm_etnaviv_laLTLIBRARIES \ install-libdrm_etnavivincludeHEADERS install-man install-pdf \ install-pdf-am install-pkgconfigDATA install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - pdf pdf-am ps ps-am recheck tags tags-am uninstall \ - uninstall-am uninstall-libdrm_etnaviv_laLTLIBRARIES \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-libdrm_etnaviv_laLTLIBRARIES \ uninstall-libdrm_etnavivincludeHEADERS uninstall-pkgconfigDATA -.PRECIOUS: Makefile - # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/lib/libdrm/freedreno/Android.mk b/lib/libdrm/freedreno/Android.mk deleted file mode 100644 index 2645f7375..000000000 --- a/lib/libdrm/freedreno/Android.mk +++ /dev/null @@ -1,18 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -# Import variables LIBDRM_FREEDRENO_FILES, LIBDRM_FREEDRENO_H_FILES -include $(LOCAL_PATH)/Makefile.sources - -LOCAL_MODULE := libdrm_freedreno -LOCAL_MODULE_TAGS := optional - -LOCAL_SHARED_LIBRARIES := libdrm - -LOCAL_SRC_FILES := $(LIBDRM_FREEDRENO_FILES) -LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) - -LOCAL_CFLAGS := \ - -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1 - -include $(BUILD_SHARED_LIBRARY) diff --git a/lib/libdrm/freedreno/Makefile.in b/lib/libdrm/freedreno/Makefile.in index 10be6a816..82383a63f 100644 --- a/lib/libdrm/freedreno/Makefile.in +++ b/lib/libdrm/freedreno/Makefile.in @@ -52,7 +52,7 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -DIST_COMMON = README $(libdrm_freedrenocommoninclude_HEADERS) \ +DIST_COMMON = $(libdrm_freedrenocommoninclude_HEADERS) \ $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(srcdir)/Makefile.sources $(srcdir)/libdrm_freedreno.pc.in \ $(top_srcdir)/build-aux/depcomp @@ -103,15 +103,16 @@ LTLIBRARIES = $(libdrm_freedreno_la_LTLIBRARIES) libdrm_freedreno_la_DEPENDENCIES = ../libdrm.la am__libdrm_freedreno_la_SOURCES_DIST = freedreno_device.c \ freedreno_pipe.c freedreno_priv.h freedreno_ringbuffer.c \ - freedreno_bo.c msm/msm_bo.c msm/msm_device.c msm/msm_drm.h \ - msm/msm_pipe.c msm/msm_priv.h msm/msm_ringbuffer.c \ - kgsl/kgsl_bo.c kgsl/kgsl_device.c kgsl/kgsl_drm.h \ - kgsl/kgsl_pipe.c kgsl/kgsl_priv.h kgsl/kgsl_ringbuffer.c \ - kgsl/msm_kgsl.h + freedreno_bo.c freedreno_bo_cache.c msm/msm_bo.c \ + msm/msm_device.c msm/msm_drm.h msm/msm_pipe.c msm/msm_priv.h \ + msm/msm_ringbuffer.c kgsl/kgsl_bo.c kgsl/kgsl_device.c \ + kgsl/kgsl_drm.h kgsl/kgsl_pipe.c kgsl/kgsl_priv.h \ + kgsl/kgsl_ringbuffer.c kgsl/msm_kgsl.h am__dirstamp = $(am__leading_dot)dirstamp am__objects_1 = freedreno_device.lo freedreno_pipe.lo \ - freedreno_ringbuffer.lo freedreno_bo.lo msm/msm_bo.lo \ - msm/msm_device.lo msm/msm_pipe.lo msm/msm_ringbuffer.lo + freedreno_ringbuffer.lo freedreno_bo.lo freedreno_bo_cache.lo \ + msm/msm_bo.lo msm/msm_device.lo msm/msm_pipe.lo \ + msm/msm_ringbuffer.lo am__objects_2 = kgsl/kgsl_bo.lo kgsl/kgsl_device.lo kgsl/kgsl_pipe.lo \ kgsl/kgsl_ringbuffer.lo @HAVE_FREEDRENO_KGSL_TRUE@am__objects_3 = $(am__objects_2) @@ -333,6 +334,7 @@ LIBDRM_FREEDRENO_FILES := \ freedreno_priv.h \ freedreno_ringbuffer.c \ freedreno_bo.c \ + freedreno_bo_cache.c \ msm/msm_bo.c \ msm/msm_device.c \ msm/msm_drm.h \ @@ -373,7 +375,7 @@ libdrm_freedrenocommonincludedir = ${includedir}/freedreno libdrm_freedrenocommoninclude_HEADERS = $(LIBDRM_FREEDRENO_H_FILES) pkgconfig_DATA = libdrm_freedreno.pc TESTS = freedreno-symbol-check -EXTRA_DIST = Android.mk $(TESTS) +EXTRA_DIST = $(TESTS) all: all-am .SUFFIXES: @@ -482,6 +484,7 @@ distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/freedreno_bo.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/freedreno_bo_cache.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/freedreno_device.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/freedreno_pipe.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/freedreno_ringbuffer.Plo@am__quote@ diff --git a/lib/libdrm/freedreno/README b/lib/libdrm/freedreno/README deleted file mode 100644 index ae22e0139..000000000 --- a/lib/libdrm/freedreno/README +++ /dev/null @@ -1,16 +0,0 @@ -Note that current msm kernel driver is a bit strange. It provides a -DRM interface for GEM, which is basically sufficient to have DRI2 -working. But it does not provide KMS. And interface to 2d and 3d -cores is via different other devices (/dev/kgsl-*). This is not -quite how I'd write a DRM driver, but at this stage it is useful for -xf86-video-freedreno and fdre (and eventual gallium driver) to be -able to work on existing kernel driver from QCOM, to allow to -capture cmdstream dumps from the binary blob drivers without having -to reboot. So libdrm_freedreno attempts to hide most of the crazy. -The intention is that when there is a proper kernel driver, it will -be mostly just changes in libdrm_freedreno to adapt the gallium -driver and xf86-video-freedreno (ignoring the fbdev->KMS changes). - -So don't look at freedreno as an example of how to write a libdrm -module or a DRM driver.. it is just an attempt to paper over a non- -standard kernel driver architecture. diff --git a/lib/libdrm/include/drm/drm.h b/lib/libdrm/include/drm/drm.h index 2f7063741..fd9efb492 100644 --- a/lib/libdrm/include/drm/drm.h +++ b/lib/libdrm/include/drm/drm.h @@ -36,7 +36,7 @@ #ifndef _DRM_H_ #define _DRM_H_ -#if defined(__linux__) +#if defined(__linux__) #include <linux/types.h> #include <asm/ioctl.h> @@ -54,6 +54,7 @@ typedef int32_t __s32; typedef uint32_t __u32; typedef int64_t __s64; typedef uint64_t __u64; +typedef size_t __kernel_size_t; typedef unsigned long drm_handle_t; #endif @@ -129,11 +130,11 @@ struct drm_version { int version_major; /**< Major version */ int version_minor; /**< Minor version */ int version_patchlevel; /**< Patch level */ - size_t name_len; /**< Length of name buffer */ + __kernel_size_t name_len; /**< Length of name buffer */ char *name; /**< Name of driver */ - size_t date_len; /**< Length of date buffer */ + __kernel_size_t date_len; /**< Length of date buffer */ char *date; /**< User-space buffer to hold date */ - size_t desc_len; /**< Length of desc buffer */ + __kernel_size_t desc_len; /**< Length of desc buffer */ char *desc; /**< User-space buffer to hold desc */ }; @@ -143,7 +144,7 @@ struct drm_version { * \sa drmGetBusid() and drmSetBusId(). */ struct drm_unique { - size_t unique_len; /**< Length of unique */ + __kernel_size_t unique_len; /**< Length of unique */ char *unique; /**< Unique name for driver instantiation */ }; @@ -180,8 +181,7 @@ enum drm_map_type { _DRM_SHM = 2, /**< shared, cached */ _DRM_AGP = 3, /**< AGP/GART */ _DRM_SCATTER_GATHER = 4, /**< Scatter/gather memory for PCI DMA */ - _DRM_CONSISTENT = 5, /**< Consistent memory for PCI DMA */ - _DRM_GEM = 6 /**< GEM object */ + _DRM_CONSISTENT = 5 /**< Consistent memory for PCI DMA */ }; /** @@ -467,12 +467,15 @@ struct drm_irq_busid { enum drm_vblank_seq_type { _DRM_VBLANK_ABSOLUTE = 0x0, /**< Wait for specific vblank sequence number */ _DRM_VBLANK_RELATIVE = 0x1, /**< Wait for given number of vblanks */ + /* bits 1-6 are reserved for high crtcs */ + _DRM_VBLANK_HIGH_CRTC_MASK = 0x0000003e, _DRM_VBLANK_EVENT = 0x4000000, /**< Send event instead of blocking */ _DRM_VBLANK_FLIP = 0x8000000, /**< Scheduled buffer swap should flip */ _DRM_VBLANK_NEXTONMISS = 0x10000000, /**< If missed, wait for next vblank */ _DRM_VBLANK_SECONDARY = 0x20000000, /**< Secondary display controller */ _DRM_VBLANK_SIGNAL = 0x40000000 /**< Send signal instead of blocking, unsupported */ }; +#define _DRM_VBLANK_HIGH_CRTC_SHIFT 1 #define _DRM_VBLANK_TYPES_MASK (_DRM_VBLANK_ABSOLUTE | _DRM_VBLANK_RELATIVE) #define _DRM_VBLANK_FLAGS_MASK (_DRM_VBLANK_EVENT | _DRM_VBLANK_SIGNAL | \ @@ -612,6 +615,28 @@ struct drm_gem_open { __u64 size; }; +#define DRM_CAP_DUMB_BUFFER 0x1 +#define DRM_CAP_VBLANK_HIGH_CRTC 0x2 +#define DRM_CAP_DUMB_PREFERRED_DEPTH 0x3 +#define DRM_CAP_DUMB_PREFER_SHADOW 0x4 +#define DRM_CAP_PRIME 0x5 +#define DRM_PRIME_CAP_IMPORT 0x1 +#define DRM_PRIME_CAP_EXPORT 0x2 +#define DRM_CAP_TIMESTAMP_MONOTONIC 0x6 +#define DRM_CAP_ASYNC_PAGE_FLIP 0x7 +/* + * The CURSOR_WIDTH and CURSOR_HEIGHT capabilities return a valid widthxheight + * combination for the hardware cursor. The intention is that a hardware + * agnostic userspace can query a cursor plane size to use. + * + * Note that the cross-driver contract is to merely return a valid size; + * drivers are free to attach another meaning on top, eg. i915 returns the + * maximum plane size. + */ +#define DRM_CAP_CURSOR_WIDTH 0x8 +#define DRM_CAP_CURSOR_HEIGHT 0x9 +#define DRM_CAP_ADDFB2_MODIFIERS 0x10 + /** DRM_IOCTL_GET_CAP ioctl argument type */ struct drm_get_cap { __u64 capability; @@ -630,17 +655,17 @@ struct drm_get_cap { /** * DRM_CLIENT_CAP_UNIVERSAL_PLANES * - * if set to 1, the DRM core will expose the full universal plane list - * (including primary and cursor planes). + * If set to 1, the DRM core will expose all planes (overlay, primary, and + * cursor) to userspace. */ -#define DRM_CLIENT_CAP_UNIVERSAL_PLANES 2 +#define DRM_CLIENT_CAP_UNIVERSAL_PLANES 2 /** * DRM_CLIENT_CAP_ATOMIC * - * If set to 1, the DRM core will allow atomic modesetting requests. + * If set to 1, the DRM core will expose atomic properties to userspace */ -#define DRM_CLIENT_CAP_ATOMIC 3 +#define DRM_CLIENT_CAP_ATOMIC 3 /** DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */ struct drm_set_client_cap { @@ -648,6 +673,7 @@ struct drm_set_client_cap { __u64 value; }; +#define DRM_RDWR O_RDWR #define DRM_CLOEXEC O_CLOEXEC struct drm_prime_handle { __u32 handle; @@ -745,8 +771,8 @@ struct drm_prime_handle { #define DRM_IOCTL_MODE_SETGAMMA DRM_IOWR(0xA5, struct drm_mode_crtc_lut) #define DRM_IOCTL_MODE_GETENCODER DRM_IOWR(0xA6, struct drm_mode_get_encoder) #define DRM_IOCTL_MODE_GETCONNECTOR DRM_IOWR(0xA7, struct drm_mode_get_connector) -#define DRM_IOCTL_MODE_ATTACHMODE DRM_IOWR(0xA8, struct drm_mode_mode_cmd) -#define DRM_IOCTL_MODE_DETACHMODE DRM_IOWR(0xA9, struct drm_mode_mode_cmd) +#define DRM_IOCTL_MODE_ATTACHMODE DRM_IOWR(0xA8, struct drm_mode_mode_cmd) /* deprecated (never worked) */ +#define DRM_IOCTL_MODE_DETACHMODE DRM_IOWR(0xA9, struct drm_mode_mode_cmd) /* deprecated (never worked) */ #define DRM_IOCTL_MODE_GETPROPERTY DRM_IOWR(0xAA, struct drm_mode_get_property) #define DRM_IOCTL_MODE_SETPROPERTY DRM_IOWR(0xAB, struct drm_mode_connector_set_property) @@ -773,7 +799,7 @@ struct drm_prime_handle { /** * Device specific ioctls should only be in their respective headers - * The device specific ioctl range is from 0x40 to 0x99. + * The device specific ioctl range is from 0x40 to 0x9f. * Generic IOCTLS restart at 0xA0. * * \sa drmCommandNone(), drmCommandRead(), drmCommandWrite(), and @@ -811,18 +837,6 @@ struct drm_event_vblank { __u32 reserved; }; -#define DRM_CAP_DUMB_BUFFER 0x1 -#define DRM_CAP_VBLANK_HIGH_CRTC 0x2 -#define DRM_CAP_DUMB_PREFERRED_DEPTH 0x3 -#define DRM_CAP_DUMB_PREFER_SHADOW 0x4 -#define DRM_CAP_PRIME 0x5 -#define DRM_CAP_TIMESTAMP_MONOTONIC 0x6 -#define DRM_CAP_ASYNC_PAGE_FLIP 0x7 -#define DRM_CAP_ADDFB2_MODIFIERS 0x10 - -#define DRM_PRIME_CAP_IMPORT 0x1 -#define DRM_PRIME_CAP_EXPORT 0x2 - /* typedef area */ typedef struct drm_clip_rect drm_clip_rect_t; typedef struct drm_drawable_info drm_drawable_info_t; diff --git a/lib/libdrm/include/drm/i915_drm.h b/lib/libdrm/include/drm/i915_drm.h index e30e3cc67..13276ae23 100644 --- a/lib/libdrm/include/drm/i915_drm.h +++ b/lib/libdrm/include/drm/i915_drm.h @@ -364,6 +364,8 @@ 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 typedef struct drm_i915_getparam { __s32 param; @@ -783,10 +785,12 @@ struct drm_i915_gem_execbuffer2 { #define I915_EXEC_HANDLE_LUT (1<<12) /** Used for switching BSD rings on the platforms with two BSD rings */ -#define I915_EXEC_BSD_MASK (3<<13) -#define I915_EXEC_BSD_DEFAULT (0<<13) /* default ping-pong mode */ -#define I915_EXEC_BSD_RING1 (1<<13) -#define I915_EXEC_BSD_RING2 (2<<13) +#define I915_EXEC_BSD_SHIFT (13) +#define I915_EXEC_BSD_MASK (3 << I915_EXEC_BSD_SHIFT) +/* default ping-pong mode */ +#define I915_EXEC_BSD_DEFAULT (0 << I915_EXEC_BSD_SHIFT) +#define I915_EXEC_BSD_RING1 (1 << I915_EXEC_BSD_SHIFT) +#define I915_EXEC_BSD_RING2 (2 << I915_EXEC_BSD_SHIFT) /** Tell the kernel that the batchbuffer is processed by * the resource streamer. @@ -823,10 +827,35 @@ struct drm_i915_gem_busy { /** Handle of the buffer to check for busy */ __u32 handle; - /** Return busy status (1 if busy, 0 if idle). - * The high word is used to indicate on which rings the object - * currently resides: - * 16:31 - busy (r or r/w) rings (16 render, 17 bsd, 18 blt, etc) + /** Return busy status + * + * A return of 0 implies that the object is idle (after + * 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.) + * + * The returned dword is split into two fields to indicate both + * the engines on which the object is being read, and the + * engine on which it is currently being written (if any). + * + * The low word (bits 0:15) indicate if the object is being written + * to by any engine (there can only be one, as the GEM implicit + * synchronisation rules force writes to be serialised). Only the + * engine for the last write is reported. + * + * The high word (bits 16:31) are a bitmask of which engines are + * currently reading from the object. Multiple engines may be + * reading from the object simultaneously. + * + * The value of each engine is the same as specified in the + * EXECBUFFER2 ioctl, i.e. I915_EXEC_RENDER, I915_EXEC_BSD etc. + * Note I915_EXEC_DEFAULT is a symbolic value and is mapped to + * the I915_EXEC_RENDER engine for execution, and so it is never + * reported as active itself. Some hardware may have parallel + * 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. */ __u32 busy; }; diff --git a/lib/libdrm/intel/Android.mk b/lib/libdrm/intel/Android.mk deleted file mode 100644 index 6582dfdee..000000000 --- a/lib/libdrm/intel/Android.mk +++ /dev/null @@ -1,43 +0,0 @@ -# -# Copyright © 2011 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. -# - -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -# Import variables LIBDRM_INTEL_FILES, LIBDRM_INTEL_H_FILES -include $(LOCAL_PATH)/Makefile.sources - -LOCAL_MODULE := libdrm_intel -LOCAL_MODULE_TAGS := optional - -LOCAL_SRC_FILES := $(LIBDRM_INTEL_FILES) -LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) - -LOCAL_CFLAGS := \ - -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1 - -LOCAL_SHARED_LIBRARIES := \ - libdrm \ - libpciaccess - -include $(BUILD_SHARED_LIBRARY) diff --git a/lib/libdrm/intel/Makefile.in b/lib/libdrm/intel/Makefile.in index 2eafa5793..ee5629aad 100644 --- a/lib/libdrm/intel/Makefile.in +++ b/lib/libdrm/intel/Makefile.in @@ -394,7 +394,6 @@ EXTRA_DIST = \ $(BATCHES:.batch=.batch-ref.txt) \ $(BATCHES:.batch=.batch-ref.txt) \ tests/test-batch.sh \ - Android.mk \ $(TESTS) test_decode_LDADD = libdrm_intel.la ../libdrm.la diff --git a/lib/libdrm/intel/intel_bufmgr.h b/lib/libdrm/intel/intel_bufmgr.h index a1abbcd2b..96a4d9d3e 100644 --- a/lib/libdrm/intel/intel_bufmgr.h +++ b/lib/libdrm/intel/intel_bufmgr.h @@ -273,6 +273,9 @@ int drm_intel_get_reset_stats(drm_intel_context *ctx, int drm_intel_get_subslice_total(int fd, unsigned int *subslice_total); int drm_intel_get_eu_total(int fd, unsigned int *eu_total); +int drm_intel_get_pooled_eu(int fd); +int drm_intel_get_min_eu_in_pool(int fd); + /** @{ Compatibility defines to keep old code building despite the symbol rename * from dri_* to drm_intel_* */ diff --git a/lib/libdrm/intel/intel_bufmgr_fake.c b/lib/libdrm/intel/intel_bufmgr_fake.c index 7f4c7b9fa..24b3732aa 100644 --- a/lib/libdrm/intel/intel_bufmgr_fake.c +++ b/lib/libdrm/intel/intel_bufmgr_fake.c @@ -312,7 +312,7 @@ _fence_wait_internal(drm_intel_bufmgr_fake *bufmgr_fake, int seq) * * Assume that in userland we treat sequence numbers as ints, which * makes some of the comparisons convenient, since the sequence - * numbers are all postive signed integers. + * numbers are all positive signed integers. * * From this we get several cases we need to handle. Here's a timeline. * 0x2 0x7 0x7ffffff8 0x7ffffffd diff --git a/lib/libdrm/intel/intel_bufmgr_gem.c b/lib/libdrm/intel/intel_bufmgr_gem.c index 93261ce97..ffb9ff3c6 100644 --- a/lib/libdrm/intel/intel_bufmgr_gem.c +++ b/lib/libdrm/intel/intel_bufmgr_gem.c @@ -3251,6 +3251,36 @@ drm_intel_get_eu_total(int fd, unsigned int *eu_total) return 0; } +int +drm_intel_get_pooled_eu(int fd) +{ + drm_i915_getparam_t gp; + int ret = -1; + + memclear(gp); + gp.param = I915_PARAM_HAS_POOLED_EU; + gp.value = &ret; + if (drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp)) + return -errno; + + return ret; +} + +int +drm_intel_get_min_eu_in_pool(int fd) +{ + drm_i915_getparam_t gp; + int ret = -1; + + memclear(gp); + gp.param = I915_PARAM_MIN_EU_IN_POOL; + gp.value = &ret; + if (drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp)) + return -errno; + + return ret; +} + /** * Annotate the given bo for use in aub dumping. * @@ -3395,7 +3425,7 @@ drm_intel_bufmgr_gem_init(int fd, int batch_size) bufmgr_gem->gtt_size > 256*1024*1024) { /* The unmappable part of gtt on gen 3 (i.e. above 256MB) can't * be used for tiled blits. To simplify the accounting, just - * substract the unmappable part (fixed to 256MB on all known + * subtract the unmappable part (fixed to 256MB on all known * gen3 devices) if the kernel advertises it. */ bufmgr_gem->gtt_size -= 256*1024*1024; } diff --git a/lib/libdrm/intel/intel_chipset.h b/lib/libdrm/intel/intel_chipset.h index 35148e522..514f6594a 100644 --- a/lib/libdrm/intel/intel_chipset.h +++ b/lib/libdrm/intel/intel_chipset.h @@ -168,6 +168,7 @@ #define PCI_CHIP_SKYLAKE_DT_GT1 0x1902 #define PCI_CHIP_SKYLAKE_ULT_GT1 0x1906 #define PCI_CHIP_SKYLAKE_SRV_GT1 0x190A /* Reserved */ +#define PCI_CHIP_SKYLAKE_H_GT1 0x190B #define PCI_CHIP_SKYLAKE_ULX_GT1 0x190E /* Reserved */ #define PCI_CHIP_SKYLAKE_DT_GT2 0x1912 #define PCI_CHIP_SKYLAKE_FUSED0_GT2 0x1913 /* Reserved */ @@ -179,9 +180,12 @@ #define PCI_CHIP_SKYLAKE_WKS_GT2 0x191D #define PCI_CHIP_SKYLAKE_ULX_GT2 0x191E #define PCI_CHIP_SKYLAKE_MOBILE_GT2 0x1921 /* Reserved */ -#define PCI_CHIP_SKYLAKE_GT3 0x1926 -#define PCI_CHIP_SKYLAKE_HALO_GT3 0x192B /* Reserved */ +#define PCI_CHIP_SKYLAKE_ULT_GT3_0 0x1923 +#define PCI_CHIP_SKYLAKE_ULT_GT3_1 0x1926 +#define PCI_CHIP_SKYLAKE_ULT_GT3_2 0x1927 #define PCI_CHIP_SKYLAKE_SRV_GT4 0x192A +#define PCI_CHIP_SKYLAKE_HALO_GT3 0x192B /* Reserved */ +#define PCI_CHIP_SKYLAKE_SRV_GT3 0x192D #define PCI_CHIP_SKYLAKE_DT_GT4 0x1932 #define PCI_CHIP_SKYLAKE_SRV_GT4X 0x193A #define PCI_CHIP_SKYLAKE_H_GT4 0x193B @@ -190,7 +194,9 @@ #define PCI_CHIP_KABYLAKE_ULT_GT2 0x5916 #define PCI_CHIP_KABYLAKE_ULT_GT1_5 0x5913 #define PCI_CHIP_KABYLAKE_ULT_GT1 0x5906 -#define PCI_CHIP_KABYLAKE_ULT_GT3 0x5926 +#define PCI_CHIP_KABYLAKE_ULT_GT3_0 0x5923 +#define PCI_CHIP_KABYLAKE_ULT_GT3_1 0x5926 +#define PCI_CHIP_KABYLAKE_ULT_GT3_2 0x5927 #define PCI_CHIP_KABYLAKE_ULT_GT2F 0x5921 #define PCI_CHIP_KABYLAKE_ULX_GT1_5 0x5915 #define PCI_CHIP_KABYLAKE_ULX_GT1 0x590E @@ -198,21 +204,19 @@ #define PCI_CHIP_KABYLAKE_DT_GT2 0x5912 #define PCI_CHIP_KABYLAKE_DT_GT1_5 0x5917 #define PCI_CHIP_KABYLAKE_DT_GT1 0x5902 -#define PCI_CHIP_KABYLAKE_DT_GT4 0x5932 #define PCI_CHIP_KABYLAKE_HALO_GT2 0x591B #define PCI_CHIP_KABYLAKE_HALO_GT4 0x593B -#define PCI_CHIP_KABYLAKE_HALO_GT3 0x592B -#define PCI_CHIP_KABYLAKE_HALO_GT1 0x590B +#define PCI_CHIP_KABYLAKE_HALO_GT1_0 0x5908 +#define PCI_CHIP_KABYLAKE_HALO_GT1_1 0x590B #define PCI_CHIP_KABYLAKE_SRV_GT2 0x591A -#define PCI_CHIP_KABYLAKE_SRV_GT3 0x592A #define PCI_CHIP_KABYLAKE_SRV_GT1 0x590A -#define PCI_CHIP_KABYLAKE_SRV_GT4 0x593A #define PCI_CHIP_KABYLAKE_WKS_GT2 0x591D -#define PCI_CHIP_KABYLAKE_WKS_GT4 0x593D #define PCI_CHIP_BROXTON_0 0x0A84 #define PCI_CHIP_BROXTON_1 0x1A84 #define PCI_CHIP_BROXTON_2 0x5A84 +#define PCI_CHIP_BROXTON_3 0x1A85 +#define PCI_CHIP_BROXTON_4 0x5A85 #define IS_MOBILE(devid) ((devid) == PCI_CHIP_I855_GM || \ (devid) == PCI_CHIP_I915_GM || \ @@ -373,10 +377,11 @@ #define IS_GEN8(devid) (IS_BROADWELL(devid) || \ IS_CHERRYVIEW(devid)) -#define IS_SKL_GT1(devid) ((devid) == PCI_CHIP_SKYLAKE_ULT_GT1 || \ - (devid) == PCI_CHIP_SKYLAKE_ULX_GT1 || \ - (devid) == PCI_CHIP_SKYLAKE_DT_GT1 || \ - (devid) == PCI_CHIP_SKYLAKE_SRV_GT1) +#define IS_SKL_GT1(devid) ((devid) == PCI_CHIP_SKYLAKE_DT_GT1 || \ + (devid) == PCI_CHIP_SKYLAKE_ULT_GT1 || \ + (devid) == PCI_CHIP_SKYLAKE_SRV_GT1 || \ + (devid) == PCI_CHIP_SKYLAKE_H_GT1 || \ + (devid) == PCI_CHIP_SKYLAKE_ULX_GT1) #define IS_SKL_GT2(devid) ((devid) == PCI_CHIP_SKYLAKE_DT_GT2 || \ (devid) == PCI_CHIP_SKYLAKE_FUSED0_GT2 || \ @@ -389,8 +394,11 @@ (devid) == PCI_CHIP_SKYLAKE_ULX_GT2 || \ (devid) == PCI_CHIP_SKYLAKE_MOBILE_GT2) -#define IS_SKL_GT3(devid) ((devid) == PCI_CHIP_SKYLAKE_GT3 || \ - (devid) == PCI_CHIP_SKYLAKE_HALO_GT3) +#define IS_SKL_GT3(devid) ((devid) == PCI_CHIP_SKYLAKE_ULT_GT3_0 || \ + (devid) == PCI_CHIP_SKYLAKE_ULT_GT3_1 || \ + (devid) == PCI_CHIP_SKYLAKE_ULT_GT3_2 || \ + (devid) == PCI_CHIP_SKYLAKE_HALO_GT3 || \ + (devid) == PCI_CHIP_SKYLAKE_SRV_GT3) #define IS_SKL_GT4(devid) ((devid) == PCI_CHIP_SKYLAKE_SRV_GT4 || \ (devid) == PCI_CHIP_SKYLAKE_DT_GT4 || \ @@ -404,7 +412,8 @@ (devid) == PCI_CHIP_KABYLAKE_ULT_GT1 || \ (devid) == PCI_CHIP_KABYLAKE_ULX_GT1 || \ (devid) == PCI_CHIP_KABYLAKE_DT_GT1 || \ - (devid) == PCI_CHIP_KABYLAKE_HALO_GT1 || \ + (devid) == PCI_CHIP_KABYLAKE_HALO_GT1_0 || \ + (devid) == PCI_CHIP_KABYLAKE_HALO_GT1_1 || \ (devid) == PCI_CHIP_KABYLAKE_SRV_GT1) #define IS_KBL_GT2(devid) ((devid) == PCI_CHIP_KABYLAKE_ULT_GT2 || \ @@ -415,14 +424,11 @@ (devid) == PCI_CHIP_KABYLAKE_SRV_GT2 || \ (devid) == PCI_CHIP_KABYLAKE_WKS_GT2) -#define IS_KBL_GT3(devid) ((devid) == PCI_CHIP_KABYLAKE_ULT_GT3 || \ - (devid) == PCI_CHIP_KABYLAKE_HALO_GT3 || \ - (devid) == PCI_CHIP_KABYLAKE_SRV_GT3) +#define IS_KBL_GT3(devid) ((devid) == PCI_CHIP_KABYLAKE_ULT_GT3_0 || \ + (devid) == PCI_CHIP_KABYLAKE_ULT_GT3_1 || \ + (devid) == PCI_CHIP_KABYLAKE_ULT_GT3_2) -#define IS_KBL_GT4(devid) ((devid) == PCI_CHIP_KABYLAKE_DT_GT4 || \ - (devid) == PCI_CHIP_KABYLAKE_HALO_GT4 || \ - (devid) == PCI_CHIP_KABYLAKE_SRV_GT4 || \ - (devid) == PCI_CHIP_KABYLAKE_WKS_GT4) +#define IS_KBL_GT4(devid) ((devid) == PCI_CHIP_KABYLAKE_HALO_GT4) #define IS_KABYLAKE(devid) (IS_KBL_GT1(devid) || \ IS_KBL_GT2(devid) || \ @@ -436,7 +442,9 @@ #define IS_BROXTON(devid) ((devid) == PCI_CHIP_BROXTON_0 || \ (devid) == PCI_CHIP_BROXTON_1 || \ - (devid) == PCI_CHIP_BROXTON_2) + (devid) == PCI_CHIP_BROXTON_2 || \ + (devid) == PCI_CHIP_BROXTON_3 || \ + (devid) == PCI_CHIP_BROXTON_4) #define IS_GEN9(devid) (IS_SKYLAKE(devid) || \ IS_BROXTON(devid) || \ diff --git a/lib/libdrm/intel/intel_decode.c b/lib/libdrm/intel/intel_decode.c index 287c34277..803d20293 100644 --- a/lib/libdrm/intel/intel_decode.c +++ b/lib/libdrm/intel/intel_decode.c @@ -3598,7 +3598,7 @@ decode_3d_965(struct drm_intel_decode *ctx) instr_out(ctx, 0, "3DSTATE_DEPTH_BUFFER\n"); if (IS_GEN5(devid) || IS_GEN6(devid)) instr_out(ctx, 1, - "%s, %s, pitch = %d bytes, %stiled, HiZ %d, Seperate Stencil %d\n", + "%s, %s, pitch = %d bytes, %stiled, HiZ %d, Separate Stencil %d\n", get_965_surfacetype(data[1] >> 29), get_965_depthformat((data[1] >> 18) & 0x7), (data[1] & 0x0001ffff) + 1, diff --git a/lib/libdrm/libkms/Android.mk b/lib/libdrm/libkms/Android.mk deleted file mode 100644 index 4f5e3d2f2..000000000 --- a/lib/libdrm/libkms/Android.mk +++ /dev/null @@ -1,51 +0,0 @@ -DRM_GPU_DRIVERS := $(strip $(filter-out swrast, $(BOARD_GPU_DRIVERS))) - -intel_drivers := i915 i965 i915g ilo -radeon_drivers := r300g r600g radeonsi -nouveau_drivers := nouveau -vmwgfx_drivers := vmwgfx - -valid_drivers := \ - $(intel_drivers) \ - $(radeon_drivers) \ - $(nouveau_drivers) \ - $(vmwgfx_drivers) - -# warn about invalid drivers -invalid_drivers := $(filter-out $(valid_drivers), $(DRM_GPU_DRIVERS)) -ifneq ($(invalid_drivers),) -$(warning invalid GPU drivers: $(invalid_drivers)) -# tidy up -DRM_GPU_DRIVERS := $(filter-out $(invalid_drivers), $(DRM_GPU_DRIVERS)) -endif - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -include $(LOCAL_PATH)/Makefile.sources - -LOCAL_SRC_FILES := $(LIBKMS_FILES) - -ifneq ($(filter $(vmwgfx_drivers), $(DRM_GPU_DRIVERS)),) -LOCAL_SRC_FILES += $(LIBKMS_VMWGFX_FILES) -endif - -ifneq ($(filter $(intel_drivers), $(DRM_GPU_DRIVERS)),) -LOCAL_SRC_FILES += $(LIBKMS_INTEL_FILES) -endif - -ifneq ($(filter $(nouveau_drivers), $(DRM_GPU_DRIVERS)),) -LOCAL_SRC_FILES += $(LIBKMS_NOUVEAU_FILES) -endif - -ifneq ($(filter $(radeon_drivers), $(DRM_GPU_DRIVERS)),) -LOCAL_SRC_FILES += $(LIBKMS_RADEON_FILES) -endif - -LOCAL_MODULE := libkms -LOCAL_MODULE_TAGS := optional -LOCAL_SHARED_LIBRARIES := libdrm - -LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) - -include $(BUILD_SHARED_LIBRARY) diff --git a/lib/libdrm/libkms/Makefile.in b/lib/libdrm/libkms/Makefile.in index 83fde2c03..c750eee44 100644 --- a/lib/libdrm/libkms/Makefile.in +++ b/lib/libdrm/libkms/Makefile.in @@ -369,7 +369,7 @@ libkmsincludedir = ${includedir}/libkms libkmsinclude_HEADERS = $(LIBKMS_H_FILES) pkgconfig_DATA = libkms.pc TESTS = kms-symbol-check -EXTRA_DIST = Android.mk $(TESTS) +EXTRA_DIST = $(TESTS) all: all-am .SUFFIXES: diff --git a/lib/libdrm/libkms/linux.c b/lib/libdrm/libkms/linux.c index 6e0da830f..69eb1aa47 100644 --- a/lib/libdrm/libkms/linux.c +++ b/lib/libdrm/libkms/linux.c @@ -41,9 +41,12 @@ #include <unistd.h> #include <sys/stat.h> #include <sys/types.h> -#ifdef HAVE_SYS_MKDEV_H +#ifdef MAJOR_IN_MKDEV #include <sys/mkdev.h> #endif +#ifdef MAJOR_IN_SYSMACROS +#include <sys/sysmacros.h> +#endif #include "libdrm_macros.h" #include "internal.h" diff --git a/lib/libdrm/nouveau/Android.mk b/lib/libdrm/nouveau/Android.mk deleted file mode 100644 index abc6aef74..000000000 --- a/lib/libdrm/nouveau/Android.mk +++ /dev/null @@ -1,18 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -# Import variables LIBDRM_NOUVEAU_FILES, LIBDRM_NOUVEAU_H_FILES -include $(LOCAL_PATH)/Makefile.sources - -LOCAL_MODULE := libdrm_nouveau -LOCAL_MODULE_TAGS := optional - -LOCAL_SHARED_LIBRARIES := libdrm - -LOCAL_SRC_FILES := $(LIBDRM_NOUVEAU_FILES) -LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) - -LOCAL_CFLAGS := \ - -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1 - -include $(BUILD_SHARED_LIBRARY) diff --git a/lib/libdrm/nouveau/Makefile.in b/lib/libdrm/nouveau/Makefile.in index ad3228212..e738f3462 100644 --- a/lib/libdrm/nouveau/Makefile.in +++ b/lib/libdrm/nouveau/Makefile.in @@ -349,7 +349,7 @@ libdrm_nouveaunvifinclude_HEADERS = nvif/class.h \ pkgconfig_DATA = libdrm_nouveau.pc TESTS = nouveau-symbol-check -EXTRA_DIST = Android.mk $(TESTS) +EXTRA_DIST = $(TESTS) all: all-am .SUFFIXES: diff --git a/lib/libdrm/radeon/Android.mk b/lib/libdrm/radeon/Android.mk deleted file mode 100644 index ace34080f..000000000 --- a/lib/libdrm/radeon/Android.mk +++ /dev/null @@ -1,18 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -# Import variables LIBDRM_RADEON_FILES, LIBDRM_RADEON_H_FILES -include $(LOCAL_PATH)/Makefile.sources - -LOCAL_MODULE := libdrm_radeon -LOCAL_MODULE_TAGS := optional - -LOCAL_SHARED_LIBRARIES := libdrm - -LOCAL_SRC_FILES := $(LIBDRM_RADEON_FILES) -LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) - -LOCAL_CFLAGS := \ - -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1 - -include $(BUILD_SHARED_LIBRARY) diff --git a/lib/libdrm/radeon/Makefile.in b/lib/libdrm/radeon/Makefile.in index fee7573d8..f75d56daa 100644 --- a/lib/libdrm/radeon/Makefile.in +++ b/lib/libdrm/radeon/Makefile.in @@ -180,6 +180,10 @@ DATA = $(pkgconfig_DATA) HEADERS = $(libdrm_radeoninclude_HEADERS) ETAGS = etags CTAGS = ctags +am__tty_colors_dummy = \ + mgn= red= grn= lgn= blu= brg= std=; \ + am__color_tests=no +am__tty_colors = $(am__tty_colors_dummy) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ @@ -368,7 +372,8 @@ libdrm_radeon_la_SOURCES = $(LIBDRM_RADEON_FILES) libdrm_radeonincludedir = ${includedir}/libdrm libdrm_radeoninclude_HEADERS = $(LIBDRM_RADEON_H_FILES) pkgconfig_DATA = libdrm_radeon.pc -EXTRA_DIST = Android.mk $(LIBDRM_RADEON_BOF_FILES) $(TESTS) +TESTS = radeon-symbol-check +EXTRA_DIST = $(LIBDRM_RADEON_BOF_FILES) $(TESTS) all: all-am .SUFFIXES: @@ -591,6 +596,99 @@ cscopelist: $(HEADERS) $(SOURCES) $(LISP) distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; \ + srcdir=$(srcdir); export srcdir; \ + list=' $(TESTS) '; \ + $(am__tty_colors); \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst $(AM_TESTS_FD_REDIRECT); then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + col=$$red; res=XPASS; \ + ;; \ + *) \ + col=$$grn; res=PASS; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xfail=`expr $$xfail + 1`; \ + col=$$lgn; res=XFAIL; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + col=$$red; res=FAIL; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + col=$$blu; res=SKIP; \ + fi; \ + echo "$${col}$$res$${std}: $$tst"; \ + done; \ + if test "$$all" -eq 1; then \ + tests="test"; \ + All=""; \ + else \ + tests="tests"; \ + All="All "; \ + fi; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="$$All$$all $$tests passed"; \ + else \ + if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ + banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all $$tests failed"; \ + else \ + if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ + banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ + fi; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + if test "$$skip" -eq 1; then \ + skipped="($$skip test was not run)"; \ + else \ + skipped="($$skip tests were not run)"; \ + fi; \ + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + if test "$$failed" -eq 0; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + fi; \ + echo "$${col}$$dashes$${std}"; \ + echo "$${col}$$banner$${std}"; \ + test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \ + test -z "$$report" || echo "$${col}$$report$${std}"; \ + echo "$${col}$$dashes$${std}"; \ + test "$$failed" -eq 0; \ + else :; fi + distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ @@ -622,6 +720,7 @@ distdir: $(DISTFILES) fi; \ done check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-am all-am: Makefile $(LTLIBRARIES) $(DATA) $(HEADERS) installdirs: @@ -731,11 +830,11 @@ ps-am: uninstall-am: uninstall-libdrm_radeon_laLTLIBRARIES \ uninstall-libdrm_radeonincludeHEADERS uninstall-pkgconfigDATA -.MAKE: install-am install-strip +.MAKE: check-am install-am install-strip -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ - clean-libdrm_radeon_laLTLIBRARIES clean-libtool cscopelist \ - ctags distclean distclean-compile distclean-generic \ +.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \ + clean-generic clean-libdrm_radeon_laLTLIBRARIES clean-libtool \ + cscopelist ctags 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 \ diff --git a/lib/libdrm/radeon/radeon_cs_gem.c b/lib/libdrm/radeon/radeon_cs_gem.c index cdec64e0b..23f33af4c 100644 --- a/lib/libdrm/radeon/radeon_cs_gem.c +++ b/lib/libdrm/radeon/radeon_cs_gem.c @@ -323,7 +323,7 @@ static int cs_gem_end(struct radeon_cs_int *cs, return -EPIPE; } if (cs->section_ndw != cs->section_cdw) { - fprintf(stderr, "CS section size missmatch start at (%s,%s,%d) %d vs %d\n", + fprintf(stderr, "CS section size mismatch start at (%s,%s,%d) %d vs %d\n", cs->section_file, cs->section_func, cs->section_line, cs->section_ndw, cs->section_cdw); fprintf(stderr, "CS section end at (%s,%s,%d)\n", file, func, line); diff --git a/lib/libdrm/radeon/radeon_surface.c b/lib/libdrm/radeon/radeon_surface.c index 5ec97454d..16a8b00b7 100644 --- a/lib/libdrm/radeon/radeon_surface.c +++ b/lib/libdrm/radeon/radeon_surface.c @@ -42,6 +42,14 @@ #include "radeon_drm.h" #include "radeon_surface.h" +#define CIK_TILE_MODE_COLOR_2D 14 +#define CIK_TILE_MODE_COLOR_2D_SCANOUT 10 +#define CIK_TILE_MODE_DEPTH_STENCIL_2D_TILESPLIT_64 0 +#define CIK_TILE_MODE_DEPTH_STENCIL_2D_TILESPLIT_128 1 +#define CIK_TILE_MODE_DEPTH_STENCIL_2D_TILESPLIT_256 2 +#define CIK_TILE_MODE_DEPTH_STENCIL_2D_TILESPLIT_512 3 +#define CIK_TILE_MODE_DEPTH_STENCIL_2D_TILESPLIT_ROW_SIZE 4 + #define ALIGN(value, alignment) (((value) + alignment - 1) & ~(alignment - 1)) #define MAX2(A, B) ((A) > (B) ? (A) : (B)) #define MIN2(A, B) ((A) < (B) ? (A) : (B)) @@ -957,8 +965,10 @@ static int eg_surface_best(struct radeon_surface_manager *surf_man, } surf->stencil_tile_split = 64; } else { - /* tile split must be >= 256 for colorbuffer surfaces */ - surf->tile_split = MAX2(surf->nsamples * surf->bpe * 64, 256); + /* tile split must be >= 256 for colorbuffer surfaces, + * SAMPLE_SPLIT = tile_split / (bpe * 64), the optimal value is 2 + */ + surf->tile_split = MAX2(2 * surf->bpe * 64, 256); if (surf->tile_split > 4096) surf->tile_split = 4096; } diff --git a/lib/libdrm/tests/Makefile.in b/lib/libdrm/tests/Makefile.in index b99fe98d5..a622711cf 100644 --- a/lib/libdrm/tests/Makefile.in +++ b/lib/libdrm/tests/Makefile.in @@ -54,15 +54,16 @@ host_triplet = @host@ @HAVE_AMDGPU_TRUE@@HAVE_CUNIT_TRUE@am__append_3 = amdgpu @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_6 = nouveau +@HAVE_NOUVEAU_TRUE@am__append_7 = nouveau TESTS = drmsl$(EXEEXT) hash$(EXEEXT) random$(EXEEXT) $(am__EXEEXT_1) -@HAVE_LIBUDEV_TRUE@am__append_7 = \ +@HAVE_LIBUDEV_TRUE@am__append_8 = \ @HAVE_LIBUDEV_TRUE@ libdrmtest.la \ @HAVE_LIBUDEV_TRUE@ $(LIBUDEV_LIBS) -@HAVE_LIBUDEV_TRUE@am__append_8 = \ +@HAVE_LIBUDEV_TRUE@am__append_9 = \ @HAVE_LIBUDEV_TRUE@ openclose \ @HAVE_LIBUDEV_TRUE@ getversion \ @HAVE_LIBUDEV_TRUE@ getclient \ @@ -226,7 +227,7 @@ am__tty_colors_dummy = \ am__color_tests=no am__tty_colors = $(am__tty_colors_dummy) DIST_SUBDIRS = util kms modeprint proptest modetest vbltest kmstest \ - radeon amdgpu exynos tegra nouveau + radeon amdgpu exynos tegra etnaviv nouveau DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ @@ -406,13 +407,13 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = util kms modeprint proptest modetest vbltest $(am__append_1) \ $(am__append_2) $(am__append_3) $(am__append_4) \ - $(am__append_5) $(am__append_6) + $(am__append_5) $(am__append_6) $(am__append_7) AM_CFLAGS = \ $(WARN_CFLAGS)\ -I $(top_srcdir)/include/drm \ -I $(top_srcdir) -LDADD = $(top_builddir)/libdrm.la $(am__append_7) +LDADD = $(top_builddir)/libdrm.la $(am__append_8) dristat_LDADD = -lm @HAVE_LIBUDEV_TRUE@check_LTLIBRARIES = libdrmtest.la @HAVE_LIBUDEV_TRUE@libdrmtest_la_SOURCES = \ diff --git a/lib/libdrm/tests/etnaviv/Makefile.in b/lib/libdrm/tests/etnaviv/Makefile.in index ed46840a1..33bf26499 100644 --- a/lib/libdrm/tests/etnaviv/Makefile.in +++ b/lib/libdrm/tests/etnaviv/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. +# Makefile.in generated by automake 1.12.6 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2012 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -15,61 +15,23 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ +am__make_dryrun = \ + { \ + am__dry=no; \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) + test $$am__dry = yes; \ + } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -95,6 +57,8 @@ host_triplet = @host@ @HAVE_INSTALL_TESTS_FALSE@ etnaviv_cmd_stream_test$(EXEEXT) \ @HAVE_INSTALL_TESTS_FALSE@ etnaviv_bo_cache_test$(EXEEXT) subdir = tests/etnaviv +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/build-aux/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ @@ -102,7 +66,6 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = @@ -172,27 +135,8 @@ am__can_run_installinfo = \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ @@ -251,7 +195,7 @@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MANPAGES_STYLESHEET = @MANPAGES_STYLESHEET@ @@ -379,7 +323,7 @@ all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ @@ -391,6 +335,7 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/etnaviv/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign tests/etnaviv/Makefile +.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -403,9 +348,9 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(top_srcdir)/configure: $(am__configure_deps) +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-binPROGRAMS: $(bin_PROGRAMS) @@ -417,12 +362,10 @@ install-binPROGRAMS: $(bin_PROGRAMS) fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ - while read p p1; do if test -f $$p \ - || test -f $$p1 \ - ; then echo "$$p"; echo "$$p"; else :; fi; \ + while read p p1; do if test -f $$p || test -f $$p1; \ + then echo "$$p"; echo "$$p"; else :; fi; \ done | \ - sed -e 'p;s,.*/,,;n;h' \ - -e 's|.*|.|' \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ @@ -443,8 +386,7 @@ uninstall-binPROGRAMS: @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ - -e 's/$$/$(EXEEXT)/' \ - `; \ + -e 's/$$/$(EXEEXT)/' `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files @@ -466,15 +408,12 @@ clean-noinstPROGRAMS: list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list - etnaviv_2d_test$(EXEEXT): $(etnaviv_2d_test_OBJECTS) $(etnaviv_2d_test_DEPENDENCIES) $(EXTRA_etnaviv_2d_test_DEPENDENCIES) @rm -f etnaviv_2d_test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(etnaviv_2d_test_OBJECTS) $(etnaviv_2d_test_LDADD) $(LIBS) - etnaviv_bo_cache_test$(EXEEXT): $(etnaviv_bo_cache_test_OBJECTS) $(etnaviv_bo_cache_test_DEPENDENCIES) $(EXTRA_etnaviv_bo_cache_test_DEPENDENCIES) @rm -f etnaviv_bo_cache_test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(etnaviv_bo_cache_test_OBJECTS) $(etnaviv_bo_cache_test_LDADD) $(LIBS) - etnaviv_cmd_stream_test$(EXEEXT): $(etnaviv_cmd_stream_test_OBJECTS) $(etnaviv_cmd_stream_test_DEPENDENCIES) $(EXTRA_etnaviv_cmd_stream_test_DEPENDENCIES) @rm -f etnaviv_cmd_stream_test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(etnaviv_cmd_stream_test_OBJECTS) $(etnaviv_cmd_stream_test_LDADD) $(LIBS) @@ -495,14 +434,14 @@ distclean-compile: @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -517,15 +456,26 @@ mostlyclean-libtool: clean-libtool: -rm -rf .libs _libs -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ - $(am__define_uniq_tagged_files); \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ @@ -537,11 +487,15 @@ tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $$unique; \ fi; \ fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique @@ -550,10 +504,9 @@ GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ +cscopelist: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ @@ -709,22 +662,19 @@ uninstall-am: uninstall-binPROGRAMS .MAKE: install-am install-strip -.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \ - clean-binPROGRAMS clean-generic clean-libtool \ - clean-noinstPROGRAMS cscopelist-am ctags ctags-am distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-binPROGRAMS 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 maintainer-clean \ +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libtool clean-noinstPROGRAMS cscopelist \ + ctags distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-binPROGRAMS \ + 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 maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags tags-am uninstall uninstall-am uninstall-binPROGRAMS - -.PRECIOUS: Makefile + tags uninstall uninstall-am uninstall-binPROGRAMS # Tell versions [3.59,3.63) of GNU make to not export all variables. diff --git a/lib/libdrm/tests/modetest/Android.mk b/lib/libdrm/tests/modetest/Android.mk deleted file mode 100644 index 0fdfe6856..000000000 --- a/lib/libdrm/tests/modetest/Android.mk +++ /dev/null @@ -1,12 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -include $(LOCAL_PATH)/Makefile.sources - -LOCAL_SRC_FILES := $(MODETEST_FILES) - -LOCAL_MODULE := modetest - -LOCAL_SHARED_LIBRARIES := libdrm - -include $(BUILD_EXECUTABLE) diff --git a/lib/libdrm/tests/modetest/Makefile.in b/lib/libdrm/tests/modetest/Makefile.in index 0cd3debfa..4ec4da4b5 100644 --- a/lib/libdrm/tests/modetest/Makefile.in +++ b/lib/libdrm/tests/modetest/Makefile.in @@ -290,7 +290,6 @@ modetest_LDADD = \ $(CAIRO_LIBS) \ -lpthread -EXTRA_DIST = Android.mk all: all-am .SUFFIXES: diff --git a/lib/libdrm/xf86drm.c b/lib/libdrm/xf86drm.c index ca282ad36..4c1f560ae 100644 --- a/lib/libdrm/xf86drm.c +++ b/lib/libdrm/xf86drm.c @@ -1,5 +1,5 @@ /** - * \file xf86drm.c + * \file xf86drm.c * User-level interface to DRM device * * \author Rickard E. (Rik) Faith <faith@valinux.com> @@ -54,8 +54,11 @@ #include <sys/ioctl.h> #include <sys/time.h> #include <stdarg.h> -#ifdef HAVE_SYS_MKDEV_H -# include <sys/mkdev.h> /* defines major(), minor(), and makedev() on Solaris */ +#ifdef MAJOR_IN_MKDEV +#include <sys/mkdev.h> +#endif +#ifdef MAJOR_IN_SYSMACROS +#include <sys/sysmacros.h> #endif #include <math.h> @@ -70,13 +73,13 @@ #include "util_math.h" #ifdef __OpenBSD__ -#define DRM_PRIMARY_MINOR_NAME "drm" -#define DRM_CONTROL_MINOR_NAME "drmC" -#define DRM_RENDER_MINOR_NAME "drmR" +#define DRM_PRIMARY_MINOR_NAME "drm" +#define DRM_CONTROL_MINOR_NAME "drmC" +#define DRM_RENDER_MINOR_NAME "drmR" #else -#define DRM_PRIMARY_MINOR_NAME "card" -#define DRM_CONTROL_MINOR_NAME "controlD" -#define DRM_RENDER_MINOR_NAME "renderD" +#define DRM_PRIMARY_MINOR_NAME "card" +#define DRM_CONTROL_MINOR_NAME "controlD" +#define DRM_RENDER_MINOR_NAME "renderD" #endif #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) @@ -96,7 +99,7 @@ #endif /* __OpenBSD__ */ #ifndef DRM_MAJOR -#define DRM_MAJOR 226 /* Linux */ +#define DRM_MAJOR 226 /* Linux */ #endif #ifdef __OpenBSD__ @@ -132,18 +135,18 @@ drmDebugPrint(const char *format, va_list ap) void drmMsg(const char *format, ...) { - va_list ap; + va_list ap; const char *env; if (((env = getenv("LIBGL_DEBUG")) && strstr(env, "verbose")) || (drm_server_info && drm_server_info->debug_print)) { - va_start(ap, format); - if (drm_server_info) { - drm_server_info->debug_print(format,ap); - } else { - drmDebugPrint(format, ap); - } - va_end(ap); + va_start(ap, format); + if (drm_server_info) { + drm_server_info->debug_print(format,ap); + } else { + drmDebugPrint(format, ap); + } + va_end(ap); } } @@ -170,10 +173,10 @@ void drmFree(void *pt) int drmIoctl(int fd, unsigned long request, void *arg) { - int ret; + int ret; do { - ret = ioctl(fd, request, arg); + ret = ioctl(fd, request, arg); } while (ret == -1 && (errno == EINTR || errno == EAGAIN)); return ret; } @@ -194,16 +197,16 @@ drmHashEntry *drmGetEntry(int fd) drmHashEntry *entry; if (!drmHashTable) - drmHashTable = drmHashCreate(); + drmHashTable = drmHashCreate(); if (drmHashLookup(drmHashTable, key, &value)) { - entry = drmMalloc(sizeof(*entry)); - entry->fd = fd; - entry->f = NULL; - entry->tagTable = drmHashCreate(); - drmHashInsert(drmHashTable, key, entry); + entry = drmMalloc(sizeof(*entry)); + entry->fd = fd; + entry->f = NULL; + entry->tagTable = drmHashCreate(); + drmHashInsert(drmHashTable, key, entry); } else { - entry = value; + entry = value; } return entry; } @@ -225,41 +228,41 @@ static int drmMatchBusID(const char *id1, const char *id2, int pci_domain_ok) { /* First, check if the IDs are exactly the same */ if (strcasecmp(id1, id2) == 0) - return 1; + return 1; /* Try to match old/new-style PCI bus IDs. */ if (strncasecmp(id1, "pci", 3) == 0) { - unsigned int o1, b1, d1, f1; - unsigned int o2, b2, d2, f2; - int ret; - - ret = sscanf(id1, "pci:%04x:%02x:%02x.%u", &o1, &b1, &d1, &f1); - if (ret != 4) { - o1 = 0; - ret = sscanf(id1, "PCI:%u:%u:%u", &b1, &d1, &f1); - if (ret != 3) - return 0; - } - - ret = sscanf(id2, "pci:%04x:%02x:%02x.%u", &o2, &b2, &d2, &f2); - if (ret != 4) { - o2 = 0; - ret = sscanf(id2, "PCI:%u:%u:%u", &b2, &d2, &f2); - if (ret != 3) - return 0; - } - - /* If domains aren't properly supported by the kernel interface, - * just ignore them, which sucks less than picking a totally random - * card with "open by name" - */ - if (!pci_domain_ok) - o1 = o2 = 0; - - if ((o1 != o2) || (b1 != b2) || (d1 != d2) || (f1 != f2)) - return 0; - else - return 1; + unsigned int o1, b1, d1, f1; + unsigned int o2, b2, d2, f2; + int ret; + + ret = sscanf(id1, "pci:%04x:%02x:%02x.%u", &o1, &b1, &d1, &f1); + if (ret != 4) { + o1 = 0; + ret = sscanf(id1, "PCI:%u:%u:%u", &b1, &d1, &f1); + if (ret != 3) + return 0; + } + + ret = sscanf(id2, "pci:%04x:%02x:%02x.%u", &o2, &b2, &d2, &f2); + if (ret != 4) { + o2 = 0; + ret = sscanf(id2, "PCI:%u:%u:%u", &b2, &d2, &f2); + if (ret != 3) + return 0; + } + + /* If domains aren't properly supported by the kernel interface, + * just ignore them, which sucks less than picking a totally random + * card with "open by name" + */ + if (!pci_domain_ok) + o1 = o2 = 0; + + if ((o1 != o2) || (b1 != b2) || (d1 != d2) || (f1 != f2)) + return 0; + else + return 1; } return 0; } @@ -281,18 +284,18 @@ static int drmMatchBusID(const char *id1, const char *id2, int pci_domain_ok) #if !defined(UDEV) static int chown_check_return(const char *path, uid_t owner, gid_t group) { - int rv; + int rv; - do { - rv = chown(path, owner, group); - } while (rv != 0 && errno == EINTR); + do { + rv = chown(path, owner, group); + } while (rv != 0 && errno == EINTR); - if (rv == 0) - return 0; + if (rv == 0) + return 0; - drmMsg("Failed to change owner or group for file %s! %d: %s\n", - path, errno, strerror(errno)); - return -1; + drmMsg("Failed to change owner or group for file %s! %d: %s\n", + path, errno, strerror(errno)); + return -1; } #endif @@ -313,7 +316,7 @@ int priv_open_device(const char *) * * \param dev major and minor numbers of the device. * \param minor minor number of the device. - * + * * \return a file descriptor on success, or a negative value on error. * * \internal @@ -337,72 +340,72 @@ static int drmOpenDevice(dev_t dev, int minor, int type) switch (type) { case DRM_NODE_PRIMARY: - dev_name = DRM_DEV_NAME; - break; + dev_name = DRM_DEV_NAME; + break; case DRM_NODE_CONTROL: - dev_name = DRM_CONTROL_DEV_NAME; - break; + dev_name = DRM_CONTROL_DEV_NAME; + break; case DRM_NODE_RENDER: - dev_name = DRM_RENDER_DEV_NAME; - break; + dev_name = DRM_RENDER_DEV_NAME; + break; default: - return -EINVAL; + return -EINVAL; }; sprintf(buf, dev_name, DRM_DIR_NAME, minor); drmMsg("drmOpenDevice: node name is %s\n", buf); if (drm_server_info && drm_server_info->get_perms) { - drm_server_info->get_perms(&serv_group, &serv_mode); - devmode = serv_mode ? serv_mode : DRM_DEV_MODE; - devmode &= ~(S_IXUSR|S_IXGRP|S_IXOTH); + drm_server_info->get_perms(&serv_group, &serv_mode); + devmode = serv_mode ? serv_mode : DRM_DEV_MODE; + devmode &= ~(S_IXUSR|S_IXGRP|S_IXOTH); } #ifndef __OpenBSD__ #if !defined(UDEV) if (stat(DRM_DIR_NAME, &st)) { - if (!isroot) - return DRM_ERR_NOT_ROOT; - mkdir(DRM_DIR_NAME, DRM_DEV_DIRMODE); - chown_check_return(DRM_DIR_NAME, 0, 0); /* root:root */ - chmod(DRM_DIR_NAME, DRM_DEV_DIRMODE); + if (!isroot) + return DRM_ERR_NOT_ROOT; + mkdir(DRM_DIR_NAME, DRM_DEV_DIRMODE); + chown_check_return(DRM_DIR_NAME, 0, 0); /* root:root */ + chmod(DRM_DIR_NAME, DRM_DEV_DIRMODE); } /* Check if the device node exists and create it if necessary. */ if (stat(buf, &st)) { - if (!isroot) - return DRM_ERR_NOT_ROOT; - remove(buf); - mknod(buf, S_IFCHR | devmode, dev); + if (!isroot) + return DRM_ERR_NOT_ROOT; + remove(buf); + mknod(buf, S_IFCHR | devmode, dev); } if (drm_server_info && drm_server_info->get_perms) { - group = ((int)serv_group >= 0) ? serv_group : DRM_DEV_GID; - chown_check_return(buf, user, group); - chmod(buf, devmode); + group = ((int)serv_group >= 0) ? serv_group : DRM_DEV_GID; + chown_check_return(buf, user, group); + chmod(buf, devmode); } #else /* if we modprobed then wait for udev */ { - int udev_count = 0; + int udev_count = 0; wait_for_udev: if (stat(DRM_DIR_NAME, &st)) { - usleep(20); - udev_count++; - - if (udev_count == 50) - return -1; - goto wait_for_udev; - } - - if (stat(buf, &st)) { - usleep(20); - udev_count++; - - if (udev_count == 50) - return -1; - goto wait_for_udev; - } + usleep(20); + udev_count++; + + if (udev_count == 50) + return -1; + goto wait_for_udev; + } + + if (stat(buf, &st)) { + usleep(20); + udev_count++; + + if (udev_count == 50) + return -1; + goto wait_for_udev; + } } #endif #endif /* __OpenBSD__ */ @@ -413,29 +416,29 @@ wait_for_udev: fd = priv_open_device(buf); #endif drmMsg("drmOpenDevice: open result is %d, (%s)\n", - fd, fd < 0 ? strerror(errno) : "OK"); + fd, fd < 0 ? strerror(errno) : "OK"); if (fd >= 0) - return fd; + return fd; #if !defined(UDEV) && !defined(__OpenBSD__) /* Check if the device node is not what we expect it to be, and recreate it * and try again if so. */ if (st.st_rdev != dev) { - if (!isroot) - return DRM_ERR_NOT_ROOT; - remove(buf); - mknod(buf, S_IFCHR | devmode, dev); - if (drm_server_info && drm_server_info->get_perms) { - chown_check_return(buf, user, group); - chmod(buf, devmode); - } + if (!isroot) + return DRM_ERR_NOT_ROOT; + remove(buf); + mknod(buf, S_IFCHR | devmode, dev); + if (drm_server_info && drm_server_info->get_perms) { + chown_check_return(buf, user, group); + chmod(buf, devmode); + } } fd = open(buf, O_RDWR, 0); drmMsg("drmOpenDevice: open result is %d, (%s)\n", - fd, fd < 0 ? strerror(errno) : "OK"); + fd, fd < 0 ? strerror(errno) : "OK"); if (fd >= 0) - return fd; + return fd; drmMsg("drmOpenDevice: Open failed\n"); remove(buf); @@ -451,7 +454,7 @@ wait_for_udev: * \param create allow to create the device if set. * * \return a file descriptor on success, or a negative value on error. - * + * * \internal * Calls drmOpenDevice() if \p create is set, otherwise assembles the device * name from \p minor and opens it. @@ -461,22 +464,22 @@ static int drmOpenMinor(int minor, int create, int type) int fd; char buf[64]; const char *dev_name; - + if (create) - return drmOpenDevice(makedev(DRM_MAJOR, minor), minor, type); - + return drmOpenDevice(makedev(DRM_MAJOR, minor), minor, type); + switch (type) { case DRM_NODE_PRIMARY: - dev_name = DRM_DEV_NAME; - break; + dev_name = DRM_DEV_NAME; + break; case DRM_NODE_CONTROL: - dev_name = DRM_CONTROL_DEV_NAME; - break; + dev_name = DRM_CONTROL_DEV_NAME; + break; case DRM_NODE_RENDER: - dev_name = DRM_RENDER_DEV_NAME; - break; + dev_name = DRM_RENDER_DEV_NAME; + break; default: - return -EINVAL; + return -EINVAL; }; sprintf(buf, dev_name, DRM_DIR_NAME, minor); @@ -493,10 +496,10 @@ static int drmOpenMinor(int minor, int create, int type) /** * Determine whether the DRM kernel driver has been loaded. - * + * * \return 1 if the DRM driver is loaded, 0 otherwise. * - * \internal + * \internal * Determine the presence of the kernel driver by attempting to open the 0 * minor and get version information. For backward compatibility with older * Linux implementations, /proc/dri is also checked. @@ -509,16 +512,16 @@ int drmAvailable(void) if ((fd = drmOpenMinor(0, 1, DRM_NODE_PRIMARY)) < 0) { #ifdef __linux__ - /* Try proc for backward Linux compatibility */ - if (!access("/proc/dri/0", R_OK)) - return 1; + /* Try proc for backward Linux compatibility */ + if (!access("/proc/dri/0", R_OK)) + return 1; #endif - return 0; + return 0; } - + if ((version = drmGetVersion(fd))) { - retval = 1; - drmFreeVersion(version); + retval = 1; + drmFreeVersion(version); } close(fd); @@ -597,37 +600,37 @@ static int drmOpenByBusid(const char *busid, int type) drmMsg("drmOpenByBusid: Searching for BusID %s\n", busid); for (i = base; i < base + DRM_MAX_MINOR; i++) { - fd = drmOpenMinor(i, 1, type); - drmMsg("drmOpenByBusid: drmOpenMinor returns %d\n", fd); - if (fd >= 0) { - /* We need to try for 1.4 first for proper PCI domain support - * and if that fails, we know the kernel is busted - */ - sv.drm_di_major = 1; - sv.drm_di_minor = 4; - sv.drm_dd_major = -1; /* Don't care */ - sv.drm_dd_minor = -1; /* Don't care */ - if (drmSetInterfaceVersion(fd, &sv)) { + fd = drmOpenMinor(i, 1, type); + drmMsg("drmOpenByBusid: drmOpenMinor returns %d\n", fd); + if (fd >= 0) { + /* We need to try for 1.4 first for proper PCI domain support + * and if that fails, we know the kernel is busted + */ + sv.drm_di_major = 1; + sv.drm_di_minor = 4; + sv.drm_dd_major = -1; /* Don't care */ + sv.drm_dd_minor = -1; /* Don't care */ + if (drmSetInterfaceVersion(fd, &sv)) { #ifndef __alpha__ - pci_domain_ok = 0; + pci_domain_ok = 0; #endif - sv.drm_di_major = 1; - sv.drm_di_minor = 1; - sv.drm_dd_major = -1; /* Don't care */ - sv.drm_dd_minor = -1; /* Don't care */ - drmMsg("drmOpenByBusid: Interface 1.4 failed, trying 1.1\n"); - drmSetInterfaceVersion(fd, &sv); - } - buf = drmGetBusid(fd); - drmMsg("drmOpenByBusid: drmGetBusid reports %s\n", buf); - if (buf && drmMatchBusID(buf, busid, pci_domain_ok)) { - drmFreeBusid(buf); - return fd; - } - if (buf) - drmFreeBusid(buf); - close(fd); - } + sv.drm_di_major = 1; + sv.drm_di_minor = 1; + sv.drm_dd_major = -1; /* Don't care */ + sv.drm_dd_minor = -1; /* Don't care */ + drmMsg("drmOpenByBusid: Interface 1.4 failed, trying 1.1\n"); + drmSetInterfaceVersion(fd, &sv); + } + buf = drmGetBusid(fd); + drmMsg("drmOpenByBusid: drmGetBusid reports %s\n", buf); + if (buf && drmMatchBusID(buf, busid, pci_domain_ok)) { + drmFreeBusid(buf); + return fd; + } + if (buf) + drmFreeBusid(buf); + close(fd); + } } return -1; } @@ -638,14 +641,14 @@ static int drmOpenByBusid(const char *busid, int type) * * \param name driver name. * \param type the device node type. - * + * * \return a file descriptor on success, or a negative value on error. - * + * * \internal * This function opens the first minor number that matches the driver name and * isn't already in use. If it's in use it then it will already have a bus ID * assigned. - * + * * \sa drmOpenMinor(), drmGetVersion() and drmGetBusid(). */ static int drmOpenByName(const char *name, int type) @@ -664,56 +667,56 @@ static int drmOpenByName(const char *name, int type) * already in use. If it's in use it will have a busid assigned already. */ for (i = base; i < base + DRM_MAX_MINOR; i++) { - if ((fd = drmOpenMinor(i, 1, type)) >= 0) { - if ((version = drmGetVersion(fd))) { - if (!strcmp(version->name, name)) { - drmFreeVersion(version); - id = drmGetBusid(fd); - drmMsg("drmGetBusid returned '%s'\n", id ? id : "NULL"); - if (!id || !*id) { - if (id) - drmFreeBusid(id); - return fd; - } else { - drmFreeBusid(id); - } - } else { - drmFreeVersion(version); - } - } - close(fd); - } + if ((fd = drmOpenMinor(i, 1, type)) >= 0) { + if ((version = drmGetVersion(fd))) { + if (!strcmp(version->name, name)) { + drmFreeVersion(version); + id = drmGetBusid(fd); + drmMsg("drmGetBusid returned '%s'\n", id ? id : "NULL"); + if (!id || !*id) { + if (id) + drmFreeBusid(id); + return fd; + } else { + drmFreeBusid(id); + } + } else { + drmFreeVersion(version); + } + } + close(fd); + } } #ifdef __linux__ /* Backward-compatibility /proc support */ for (i = 0; i < 8; i++) { - char proc_name[64], buf[512]; - char *driver, *pt, *devstring; - int retcode; - - sprintf(proc_name, "/proc/dri/%d/name", i); - if ((fd = open(proc_name, 0, 0)) >= 0) { - retcode = read(fd, buf, sizeof(buf)-1); - close(fd); - if (retcode) { - buf[retcode-1] = '\0'; - for (driver = pt = buf; *pt && *pt != ' '; ++pt) - ; - if (*pt) { /* Device is next */ - *pt = '\0'; - if (!strcmp(driver, name)) { /* Match */ - for (devstring = ++pt; *pt && *pt != ' '; ++pt) - ; - if (*pt) { /* Found busid */ - return drmOpenByBusid(++pt, type); - } else { /* No busid */ - return drmOpenDevice(strtol(devstring, NULL, 0),i, type); - } - } - } - } - } + char proc_name[64], buf[512]; + char *driver, *pt, *devstring; + int retcode; + + sprintf(proc_name, "/proc/dri/%d/name", i); + if ((fd = open(proc_name, 0, 0)) >= 0) { + retcode = read(fd, buf, sizeof(buf)-1); + close(fd); + if (retcode) { + buf[retcode-1] = '\0'; + for (driver = pt = buf; *pt && *pt != ' '; ++pt) + ; + if (*pt) { /* Device is next */ + *pt = '\0'; + if (!strcmp(driver, name)) { /* Match */ + for (devstring = ++pt; *pt && *pt != ' '; ++pt) + ; + if (*pt) { /* Found busid */ + return drmOpenByBusid(++pt, type); + } else { /* No busid */ + return drmOpenDevice(strtol(devstring, NULL, 0),i, type); + } + } + } + } + } } #endif @@ -729,9 +732,9 @@ static int drmOpenByName(const char *name, int type) * * \param name driver name. Not referenced if bus ID is supplied. * \param busid bus ID. Zero if not known. - * + * * \return a file descriptor on success, or a negative value on error. - * + * * \internal * It calls drmOpenByBusid() if \p busid is specified or drmOpenByName() * otherwise. @@ -761,21 +764,21 @@ int drmOpenWithType(const char *name, const char *busid, int type) { if (!drmAvailable() && name != NULL && drm_server_info && drm_server_info->load_module) { - /* try to load the kernel module */ - if (!drm_server_info->load_module(name)) { - drmMsg("[drm] failed to load kernel module \"%s\"\n", name); - return -1; - } + /* try to load the kernel module */ + if (!drm_server_info->load_module(name)) { + drmMsg("[drm] failed to load kernel module \"%s\"\n", name); + return -1; + } } if (busid) { - int fd = drmOpenByBusid(busid, type); - if (fd >= 0) - return fd; + int fd = drmOpenByBusid(busid, type); + if (fd >= 0) + return fd; } - + if (name) - return drmOpenByName(name, type); + return drmOpenByName(name, type); return -1; } @@ -802,7 +805,7 @@ int drmOpenRender(int minor) void drmFreeVersion(drmVersionPtr v) { if (!v) - return; + return; drmFree(v->name); drmFree(v->date); drmFree(v->desc); @@ -822,7 +825,7 @@ void drmFreeVersion(drmVersionPtr v) static void drmFreeKernelVersion(drm_version_t *v) { if (!v) - return; + return; drmFree(v->name); drmFree(v->date); drmFree(v->desc); @@ -832,10 +835,10 @@ static void drmFreeKernelVersion(drm_version_t *v) /** * Copy version information. - * + * * \param d destination pointer. * \param s source pointer. - * + * * \internal * Used by drmGetVersion() to translate the information returned by the ioctl * interface in a private structure into the public structure counterpart. @@ -858,12 +861,12 @@ static void drmCopyVersion(drmVersionPtr d, const drm_version_t *s) * Query the driver version information. * * \param fd file descriptor. - * + * * \return pointer to a drmVersion structure which should be freed with * drmFreeVersion(). - * + * * \note Similar information is available via /proc/dri. - * + * * \internal * It gets the version information via successive DRM_IOCTL_VERSION ioctls, * first with zeros to get the string lengths, and then the actually strings. @@ -877,21 +880,21 @@ drmVersionPtr drmGetVersion(int fd) memclear(*version); if (drmIoctl(fd, DRM_IOCTL_VERSION, version)) { - drmFreeKernelVersion(version); - return NULL; + drmFreeKernelVersion(version); + return NULL; } if (version->name_len) - version->name = drmMalloc(version->name_len + 1); + version->name = drmMalloc(version->name_len + 1); if (version->date_len) - version->date = drmMalloc(version->date_len + 1); + version->date = drmMalloc(version->date_len + 1); if (version->desc_len) - version->desc = drmMalloc(version->desc_len + 1); + version->desc = drmMalloc(version->desc_len + 1); if (drmIoctl(fd, DRM_IOCTL_VERSION, version)) { - drmMsg("DRM_IOCTL_VERSION: %s\n", strerror(errno)); - drmFreeKernelVersion(version); - return NULL; + drmMsg("DRM_IOCTL_VERSION: %s\n", strerror(errno)); + drmFreeKernelVersion(version); + return NULL; } /* The results might not be null-terminated strings, so terminate them. */ @@ -908,13 +911,13 @@ drmVersionPtr drmGetVersion(int fd) /** * Get version information for the DRM user space library. - * + * * This version number is driver independent. - * + * * \param fd file descriptor. * * \return version information. - * + * * \internal * This function allocates and fills a drm_version structure with a hard coded * version number. @@ -942,29 +945,29 @@ drmVersionPtr drmGetLibVersion(int fd) int drmGetCap(int fd, uint64_t capability, uint64_t *value) { - struct drm_get_cap cap; - int ret; + struct drm_get_cap cap; + int ret; - memclear(cap); - cap.capability = capability; + memclear(cap); + cap.capability = capability; - ret = drmIoctl(fd, DRM_IOCTL_GET_CAP, &cap); - if (ret) - return ret; + ret = drmIoctl(fd, DRM_IOCTL_GET_CAP, &cap); + if (ret) + return ret; - *value = cap.value; - return 0; + *value = cap.value; + return 0; } int drmSetClientCap(int fd, uint64_t capability, uint64_t value) { - struct drm_set_client_cap cap; + struct drm_set_client_cap cap; - memclear(cap); - cap.capability = capability; - cap.value = value; + memclear(cap); + cap.capability = capability; + cap.value = value; - return drmIoctl(fd, DRM_IOCTL_SET_CLIENT_CAP, &cap); + return drmIoctl(fd, DRM_IOCTL_SET_CLIENT_CAP, &cap); } /** @@ -1000,10 +1003,10 @@ char *drmGetBusid(int fd) memclear(u); if (drmIoctl(fd, DRM_IOCTL_GET_UNIQUE, &u)) - return NULL; + return NULL; u.unique = drmMalloc(u.unique_len + 1); if (drmIoctl(fd, DRM_IOCTL_GET_UNIQUE, &u)) - return NULL; + return NULL; u.unique[u.unique_len] = '\0'; return u.unique; @@ -1031,7 +1034,7 @@ int drmSetBusid(int fd, const char *busid) u.unique_len = strlen(busid); if (drmIoctl(fd, DRM_IOCTL_SET_UNIQUE, &u)) { - return -errno; + return -errno; } return 0; } @@ -1044,7 +1047,7 @@ int drmGetMagic(int fd, drm_magic_t * magic) *magic = 0; if (drmIoctl(fd, DRM_IOCTL_GET_MAGIC, &auth)) - return -errno; + return -errno; *magic = auth.magic; return 0; } @@ -1056,7 +1059,7 @@ int drmAuthMagic(int fd, drm_magic_t magic) memclear(auth); auth.magic = magic; if (drmIoctl(fd, DRM_IOCTL_AUTH_MAGIC, &auth)) - return -errno; + return -errno; return 0; } @@ -1072,7 +1075,7 @@ int drmAuthMagic(int fd, drm_magic_t magic) * \param flags combination of several flags to modify the function actions. * \param handle will be set to a value that may be used as the offset * parameter for mmap(). - * + * * \return zero on success or a negative value on error. * * \par Mapping the frame buffer @@ -1083,7 +1086,7 @@ int drmAuthMagic(int fd, drm_magic_t magic) * * \par * The area mapped will be uncached. If MTRR support is available in the - * kernel, the frame buffer area will be set to write combining. + * kernel, the frame buffer area will be set to write combining. * * \par Mapping the MMIO register area * For the MMIO register area, @@ -1091,19 +1094,19 @@ int drmAuthMagic(int fd, drm_magic_t magic) * - \p size will be the size of the register area bytes, and * - \p type will be DRM_REGISTERS. * \par - * The area mapped will be uncached. - * + * The area mapped will be uncached. + * * \par Mapping the SAREA * For the SAREA, * - \p offset will be ignored and should be set to zero, * - \p size will be the desired size of the SAREA in bytes, * - \p type will be DRM_SHM. - * + * * \par * A shared memory area of the requested size will be created and locked in * kernel memory. This area may be mapped into client-space by using the handle - * returned. - * + * returned. + * * \note May only be called by root. * * \internal @@ -1111,7 +1114,7 @@ int drmAuthMagic(int fd, drm_magic_t magic) * the arguments in a drm_map structure. */ int drmAddMap(int fd, drm_handle_t offset, drmSize size, drmMapType type, - drmMapFlags flags, drm_handle_t *handle) + drmMapFlags flags, drm_handle_t *handle) { drm_map_t map; @@ -1121,9 +1124,9 @@ int drmAddMap(int fd, drm_handle_t offset, drmSize size, drmMapType type, map.type = type; map.flags = flags; if (drmIoctl(fd, DRM_IOCTL_ADD_MAP, &map)) - return -errno; + return -errno; if (handle) - *handle = (drm_handle_t)(uintptr_t)map.handle; + *handle = (drm_handle_t)(uintptr_t)map.handle; return 0; } @@ -1135,18 +1138,18 @@ int drmRmMap(int fd, drm_handle_t handle) map.handle = (void *)(uintptr_t)handle; if(drmIoctl(fd, DRM_IOCTL_RM_MAP, &map)) - return -errno; + return -errno; return 0; } /** * Make buffers available for DMA transfers. - * + * * \param fd file descriptor. * \param count number of buffers. * \param size size of each buffer. * \param flags buffer allocation flags. - * \param agp_offset offset in the AGP aperture + * \param agp_offset offset in the AGP aperture * * \return number of buffers allocated, negative on error. * @@ -1156,7 +1159,7 @@ int drmRmMap(int fd, drm_handle_t handle) * \sa drm_buf_desc. */ int drmAddBufs(int fd, int count, int size, drmBufDescFlags flags, - int agp_offset) + int agp_offset) { drm_buf_desc_t request; @@ -1167,7 +1170,7 @@ int drmAddBufs(int fd, int count, int size, drmBufDescFlags flags, request.agp_start = agp_offset; if (drmIoctl(fd, DRM_IOCTL_ADD_BUFS, &request)) - return -errno; + return -errno; return request.count; } @@ -1179,28 +1182,28 @@ int drmMarkBufs(int fd, double low, double high) memclear(info); if (drmIoctl(fd, DRM_IOCTL_INFO_BUFS, &info)) - return -EINVAL; + return -EINVAL; if (!info.count) - return -EINVAL; + return -EINVAL; if (!(info.list = drmMalloc(info.count * sizeof(*info.list)))) - return -ENOMEM; + return -ENOMEM; if (drmIoctl(fd, DRM_IOCTL_INFO_BUFS, &info)) { - int retval = -errno; - drmFree(info.list); - return retval; + int retval = -errno; + drmFree(info.list); + return retval; } for (i = 0; i < info.count; i++) { - info.list[i].low_mark = low * info.list[i].count; - info.list[i].high_mark = high * info.list[i].count; - if (drmIoctl(fd, DRM_IOCTL_MARK_BUFS, &info.list[i])) { - int retval = -errno; - drmFree(info.list); - return retval; - } + info.list[i].low_mark = low * info.list[i].count; + info.list[i].high_mark = high * info.list[i].count; + if (drmIoctl(fd, DRM_IOCTL_MARK_BUFS, &info.list[i])) { + int retval = -errno; + drmFree(info.list); + return retval; + } } drmFree(info.list); @@ -1215,9 +1218,9 @@ int drmMarkBufs(int fd, double low, double high) * \param list list of buffers to be freed. * * \return zero on success, or a negative value on failure. - * + * * \note This function is primarily used for debugging. - * + * * \internal * This function is a wrapper around the DRM_IOCTL_FREE_BUFS ioctl, passing * the arguments in a drm_buf_free structure. @@ -1230,7 +1233,7 @@ int drmFreeBufs(int fd, int count, int *list) request.count = count; request.list = list; if (drmIoctl(fd, DRM_IOCTL_FREE_BUFS, &request)) - return -errno; + return -errno; return 0; } @@ -1270,7 +1273,7 @@ int drmClose(int fd) * begins. * * \return zero on success, or a negative value on failure. - * + * * \internal * This function is a wrapper for mmap(). */ @@ -1279,16 +1282,16 @@ int drmMap(int fd, drm_handle_t handle, drmSize size, drmAddressPtr address) static unsigned long pagesize_mask = 0; if (fd < 0) - return -EINVAL; + return -EINVAL; if (!pagesize_mask) - pagesize_mask = getpagesize() - 1; + pagesize_mask = getpagesize() - 1; size = (size + pagesize_mask) & ~pagesize_mask; *address = drm_mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, handle); if (*address == MAP_FAILED) - return -errno; + return -errno; return 0; } @@ -1298,7 +1301,7 @@ int drmMap(int fd, drm_handle_t handle, drmSize size, drmAddressPtr address) * * \param address address as given by drmMap(). * \param size size in bytes. Must match the size used by drmMap(). - * + * * \return zero on success, or a negative value on failure. * * \internal @@ -1318,28 +1321,28 @@ drmBufInfoPtr drmGetBufInfo(int fd) memclear(info); if (drmIoctl(fd, DRM_IOCTL_INFO_BUFS, &info)) - return NULL; + return NULL; if (info.count) { - if (!(info.list = drmMalloc(info.count * sizeof(*info.list)))) - return NULL; - - if (drmIoctl(fd, DRM_IOCTL_INFO_BUFS, &info)) { - drmFree(info.list); - return NULL; - } - - retval = drmMalloc(sizeof(*retval)); - retval->count = info.count; - retval->list = drmMalloc(info.count * sizeof(*retval->list)); - for (i = 0; i < info.count; i++) { - retval->list[i].count = info.list[i].count; - retval->list[i].size = info.list[i].size; - retval->list[i].low_mark = info.list[i].low_mark; - retval->list[i].high_mark = info.list[i].high_mark; - } - drmFree(info.list); - return retval; + if (!(info.list = drmMalloc(info.count * sizeof(*info.list)))) + return NULL; + + if (drmIoctl(fd, DRM_IOCTL_INFO_BUFS, &info)) { + drmFree(info.list); + return NULL; + } + + retval = drmMalloc(sizeof(*retval)); + retval->count = info.count; + retval->list = drmMalloc(info.count * sizeof(*retval->list)); + for (i = 0; i < info.count; i++) { + retval->list[i].count = info.list[i].count; + retval->list[i].size = info.list[i].size; + retval->list[i].low_mark = info.list[i].low_mark; + retval->list[i].high_mark = info.list[i].high_mark; + } + drmFree(info.list); + return retval; } return NULL; } @@ -1353,12 +1356,12 @@ drmBufInfoPtr drmGetBufInfo(int fd) * * \note The client may not use these buffers until obtaining buffer indices * with drmDMA(). - * + * * \internal * This function calls the DRM_IOCTL_MAP_BUFS ioctl and copies the returned * information about the buffers in a drm_buf_map structure into the * client-visible data structures. - */ + */ drmBufMapPtr drmMapBufs(int fd) { drm_buf_map_t bufs; @@ -1367,32 +1370,31 @@ drmBufMapPtr drmMapBufs(int fd) memclear(bufs); if (drmIoctl(fd, DRM_IOCTL_MAP_BUFS, &bufs)) - return NULL; + return NULL; if (!bufs.count) - return NULL; + return NULL; - if (!(bufs.list = drmMalloc(bufs.count * sizeof(*bufs.list)))) - return NULL; + if (!(bufs.list = drmMalloc(bufs.count * sizeof(*bufs.list)))) + return NULL; - if (drmIoctl(fd, DRM_IOCTL_MAP_BUFS, &bufs)) { - drmFree(bufs.list); - return NULL; - } + if (drmIoctl(fd, DRM_IOCTL_MAP_BUFS, &bufs)) { + drmFree(bufs.list); + return NULL; + } - retval = drmMalloc(sizeof(*retval)); - retval->count = bufs.count; - retval->list = drmMalloc(bufs.count * sizeof(*retval->list)); - for (i = 0; i < bufs.count; i++) { - retval->list[i].idx = bufs.list[i].idx; - retval->list[i].total = bufs.list[i].total; - retval->list[i].used = 0; - retval->list[i].address = bufs.list[i].address; - } + retval = drmMalloc(sizeof(*retval)); + retval->count = bufs.count; + retval->list = drmMalloc(bufs.count * sizeof(*retval->list)); + for (i = 0; i < bufs.count; i++) { + retval->list[i].idx = bufs.list[i].idx; + retval->list[i].total = bufs.list[i].total; + retval->list[i].used = 0; + retval->list[i].address = bufs.list[i].address; + } - drmFree(bufs.list); - - return retval; + drmFree(bufs.list); + return retval; } @@ -1410,24 +1412,23 @@ int drmUnmapBufs(drmBufMapPtr bufs) int i; for (i = 0; i < bufs->count; i++) { - drm_munmap(bufs->list[i].address, bufs->list[i].total); + drm_munmap(bufs->list[i].address, bufs->list[i].total); } drmFree(bufs->list); drmFree(bufs); - return 0; } -#define DRM_DMA_RETRY 16 +#define DRM_DMA_RETRY 16 /** * Reserve DMA buffers. * * \param fd file descriptor. - * \param request - * + * \param request + * * \return zero on success, or a negative value on failure. * * \internal @@ -1451,14 +1452,14 @@ int drmDMA(int fd, drmDMAReqPtr request) dma.granted_count = 0; do { - ret = ioctl( fd, DRM_IOCTL_DMA, &dma ); + ret = ioctl( fd, DRM_IOCTL_DMA, &dma ); } while ( ret && errno == EAGAIN && i++ < DRM_DMA_RETRY ); if ( ret == 0 ) { - request->granted_count = dma.granted_count; - return 0; + request->granted_count = dma.granted_count; + return 0; } else { - return -errno; + return -errno; } } @@ -1470,9 +1471,9 @@ int drmDMA(int fd, drmDMAReqPtr request) * \param context context. * \param flags flags that determine the sate of the hardware when the function * returns. - * + * * \return always zero. - * + * * \internal * This function translates the arguments into a drm_lock structure and issue * the DRM_IOCTL_LOCK ioctl until the lock is successfully acquired. @@ -1492,7 +1493,7 @@ int drmGetLock(int fd, drm_context_t context, drmLockFlags flags) if (flags & DRM_HALT_CUR_QUEUES) lock.flags |= _DRM_HALT_CUR_QUEUES; while (drmIoctl(fd, DRM_IOCTL_LOCK, &lock)) - ; + ; return 0; } @@ -1501,9 +1502,9 @@ int drmGetLock(int fd, drm_context_t context, drmLockFlags flags) * * \param fd file descriptor. * \param context context. - * + * * \return zero on success, or a negative value on failure. - * + * * \internal * This function is a wrapper around the DRM_IOCTL_UNLOCK ioctl, passing the * argument in a drm_lock structure. @@ -1526,24 +1527,24 @@ drm_context_t *drmGetReservedContextList(int fd, int *count) memclear(res); if (drmIoctl(fd, DRM_IOCTL_RES_CTX, &res)) - return NULL; + return NULL; if (!res.count) - return NULL; + return NULL; if (!(list = drmMalloc(res.count * sizeof(*list)))) - return NULL; + return NULL; if (!(retval = drmMalloc(res.count * sizeof(*retval)))) { - drmFree(list); - return NULL; + drmFree(list); + return NULL; } res.contexts = list; if (drmIoctl(fd, DRM_IOCTL_RES_CTX, &res)) - return NULL; + return NULL; for (i = 0; i < res.count; i++) - retval[i] = list[i].handle; + retval[i] = list[i].handle; drmFree(list); *count = res.count; @@ -1564,11 +1565,11 @@ void drmFreeReservedContextList(drm_context_t *pt) * \param fd file descriptor. * \param handle is set on success. To be used by the client when requesting DMA * dispatch with drmDMA(). - * + * * \return zero on success, or a negative value on failure. - * + * * \note May only be called by root. - * + * * \internal * This function is a wrapper around the DRM_IOCTL_ADD_CTX ioctl, passing the * argument in a drm_ctx structure. @@ -1579,7 +1580,7 @@ int drmCreateContext(int fd, drm_context_t *handle) memclear(ctx); if (drmIoctl(fd, DRM_IOCTL_ADD_CTX, &ctx)) - return -errno; + return -errno; *handle = ctx.handle; return 0; } @@ -1591,7 +1592,7 @@ int drmSwitchToContext(int fd, drm_context_t context) memclear(ctx); ctx.handle = context; if (drmIoctl(fd, DRM_IOCTL_SWITCH_CTX, &ctx)) - return -errno; + return -errno; return 0; } @@ -1608,11 +1609,11 @@ int drmSetContextFlags(int fd, drm_context_t context, drm_context_tFlags flags) memclear(ctx); ctx.handle = context; if (flags & DRM_CONTEXT_PRESERVED) - ctx.flags |= _DRM_CONTEXT_PRESERVED; + ctx.flags |= _DRM_CONTEXT_PRESERVED; if (flags & DRM_CONTEXT_2DONLY) - ctx.flags |= _DRM_CONTEXT_2DONLY; + ctx.flags |= _DRM_CONTEXT_2DONLY; if (drmIoctl(fd, DRM_IOCTL_MOD_CTX, &ctx)) - return -errno; + return -errno; return 0; } @@ -1624,12 +1625,12 @@ int drmGetContextFlags(int fd, drm_context_t context, memclear(ctx); ctx.handle = context; if (drmIoctl(fd, DRM_IOCTL_GET_CTX, &ctx)) - return -errno; + return -errno; *flags = 0; if (ctx.flags & _DRM_CONTEXT_PRESERVED) - *flags |= DRM_CONTEXT_PRESERVED; + *flags |= DRM_CONTEXT_PRESERVED; if (ctx.flags & _DRM_CONTEXT_2DONLY) - *flags |= DRM_CONTEXT_2DONLY; + *flags |= DRM_CONTEXT_2DONLY; return 0; } @@ -1638,14 +1639,14 @@ int drmGetContextFlags(int fd, drm_context_t context, * * Free any kernel-level resources allocated with drmCreateContext() associated * with the context. - * + * * \param fd file descriptor. * \param handle handle given by drmCreateContext(). - * + * * \return zero on success, or a negative value on failure. - * + * * \note May only be called by root. - * + * * \internal * This function is a wrapper around the DRM_IOCTL_RM_CTX ioctl, passing the * argument in a drm_ctx structure. @@ -1657,7 +1658,7 @@ int drmDestroyContext(int fd, drm_context_t handle) memclear(ctx); ctx.handle = handle; if (drmIoctl(fd, DRM_IOCTL_RM_CTX, &ctx)) - return -errno; + return -errno; return 0; } @@ -1667,7 +1668,7 @@ int drmCreateDrawable(int fd, drm_drawable_t *handle) memclear(draw); if (drmIoctl(fd, DRM_IOCTL_ADD_DRAW, &draw)) - return -errno; + return -errno; *handle = draw.handle; return 0; } @@ -1679,13 +1680,13 @@ int drmDestroyDrawable(int fd, drm_drawable_t handle) memclear(draw); draw.handle = handle; if (drmIoctl(fd, DRM_IOCTL_RM_DRAW, &draw)) - return -errno; + return -errno; return 0; } int drmUpdateDrawableInfo(int fd, drm_drawable_t handle, - drm_drawable_info_type_t type, unsigned int num, - void *data) + drm_drawable_info_type_t type, unsigned int num, + void *data) { drm_update_draw_t update; @@ -1696,7 +1697,7 @@ int drmUpdateDrawableInfo(int fd, drm_drawable_t handle, update.data = (unsigned long long)(unsigned long)data; if (drmIoctl(fd, DRM_IOCTL_UPDATE_DRAW, &update)) - return -errno; + return -errno; return 0; } @@ -1707,16 +1708,16 @@ int drmUpdateDrawableInfo(int fd, drm_drawable_t handle, * Must be called before any of the other AGP related calls. * * \param fd file descriptor. - * + * * \return zero on success, or a negative value on failure. - * + * * \internal * This function is a wrapper around the DRM_IOCTL_AGP_ACQUIRE ioctl. */ int drmAgpAcquire(int fd) { if (drmIoctl(fd, DRM_IOCTL_AGP_ACQUIRE, NULL)) - return -errno; + return -errno; return 0; } @@ -1725,16 +1726,16 @@ int drmAgpAcquire(int fd) * Release the AGP device. * * \param fd file descriptor. - * + * * \return zero on success, or a negative value on failure. - * + * * \internal * This function is a wrapper around the DRM_IOCTL_AGP_RELEASE ioctl. */ int drmAgpRelease(int fd) { if (drmIoctl(fd, DRM_IOCTL_AGP_RELEASE, NULL)) - return -errno; + return -errno; return 0; } @@ -1744,9 +1745,9 @@ int drmAgpRelease(int fd) * * \param fd file descriptor. * \param mode AGP mode. - * + * * \return zero on success, or a negative value on failure. - * + * * \internal * This function is a wrapper around the DRM_IOCTL_AGP_ENABLE ioctl, passing the * argument in a drm_agp_mode structure. @@ -1758,7 +1759,7 @@ int drmAgpEnable(int fd, unsigned long mode) memclear(m); m.mode = mode; if (drmIoctl(fd, DRM_IOCTL_AGP_ENABLE, &m)) - return -errno; + return -errno; return 0; } @@ -1772,15 +1773,15 @@ int drmAgpEnable(int fd, unsigned long mode) * \param address if not zero, will be set to the physical address of the * allocated memory. * \param handle on success will be set to a handle of the allocated memory. - * + * * \return zero on success, or a negative value on failure. - * + * * \internal * This function is a wrapper around the DRM_IOCTL_AGP_ALLOC ioctl, passing the * arguments in a drm_agp_buffer structure. */ int drmAgpAlloc(int fd, unsigned long size, unsigned long type, - unsigned long *address, drm_handle_t *handle) + unsigned long *address, drm_handle_t *handle) { drm_agp_buffer_t b; @@ -1789,9 +1790,9 @@ int drmAgpAlloc(int fd, unsigned long size, unsigned long type, b.size = size; b.type = type; if (drmIoctl(fd, DRM_IOCTL_AGP_ALLOC, &b)) - return -errno; + return -errno; if (address != 0UL) - *address = b.physical; + *address = b.physical; *handle = b.handle; return 0; } @@ -1802,9 +1803,9 @@ int drmAgpAlloc(int fd, unsigned long size, unsigned long type, * * \param fd file descriptor. * \param handle handle to the allocated memory, as given by drmAgpAllocate(). - * + * * \return zero on success, or a negative value on failure. - * + * * \internal * This function is a wrapper around the DRM_IOCTL_AGP_FREE ioctl, passing the * argument in a drm_agp_buffer structure. @@ -1816,7 +1817,7 @@ int drmAgpFree(int fd, drm_handle_t handle) memclear(b); b.handle = handle; if (drmIoctl(fd, DRM_IOCTL_AGP_FREE, &b)) - return -errno; + return -errno; return 0; } @@ -1827,9 +1828,9 @@ int drmAgpFree(int fd, drm_handle_t handle) * \param fd file descriptor. * \param handle handle to the allocated memory, as given by drmAgpAllocate(). * \param offset offset in bytes. It will round to page boundary. - * + * * \return zero on success, or a negative value on failure. - * + * * \internal * This function is a wrapper around the DRM_IOCTL_AGP_BIND ioctl, passing the * argument in a drm_agp_binding structure. @@ -1842,7 +1843,7 @@ int drmAgpBind(int fd, drm_handle_t handle, unsigned long offset) b.handle = handle; b.offset = offset; if (drmIoctl(fd, DRM_IOCTL_AGP_BIND, &b)) - return -errno; + return -errno; return 0; } @@ -1852,9 +1853,9 @@ int drmAgpBind(int fd, drm_handle_t handle, unsigned long offset) * * \param fd file descriptor. * \param handle handle to the allocated memory, as given by drmAgpAllocate(). - * + * * \return zero on success, or a negative value on failure. - * + * * \internal * This function is a wrapper around the DRM_IOCTL_AGP_UNBIND ioctl, passing * the argument in a drm_agp_binding structure. @@ -1866,7 +1867,7 @@ int drmAgpUnbind(int fd, drm_handle_t handle) memclear(b); b.handle = handle; if (drmIoctl(fd, DRM_IOCTL_AGP_UNBIND, &b)) - return -errno; + return -errno; return 0; } @@ -1875,9 +1876,9 @@ int drmAgpUnbind(int fd, drm_handle_t handle) * Get AGP driver major version number. * * \param fd file descriptor. - * + * * \return major version number on success, or a negative value on failure.. - * + * * \internal * This function is a wrapper around the DRM_IOCTL_AGP_INFO ioctl, getting the * necessary information in a drm_agp_info structure. @@ -1889,7 +1890,7 @@ int drmAgpVersionMajor(int fd) memclear(i); if (drmIoctl(fd, DRM_IOCTL_AGP_INFO, &i)) - return -errno; + return -errno; return i.agp_version_major; } @@ -1898,9 +1899,9 @@ int drmAgpVersionMajor(int fd) * Get AGP driver minor version number. * * \param fd file descriptor. - * + * * \return minor version number on success, or a negative value on failure. - * + * * \internal * This function is a wrapper around the DRM_IOCTL_AGP_INFO ioctl, getting the * necessary information in a drm_agp_info structure. @@ -1912,7 +1913,7 @@ int drmAgpVersionMinor(int fd) memclear(i); if (drmIoctl(fd, DRM_IOCTL_AGP_INFO, &i)) - return -errno; + return -errno; return i.agp_version_minor; } @@ -1921,9 +1922,9 @@ int drmAgpVersionMinor(int fd) * Get AGP mode. * * \param fd file descriptor. - * + * * \return mode on success, or zero on failure. - * + * * \internal * This function is a wrapper around the DRM_IOCTL_AGP_INFO ioctl, getting the * necessary information in a drm_agp_info structure. @@ -1935,7 +1936,7 @@ unsigned long drmAgpGetMode(int fd) memclear(i); if (drmIoctl(fd, DRM_IOCTL_AGP_INFO, &i)) - return 0; + return 0; return i.mode; } @@ -1944,9 +1945,9 @@ unsigned long drmAgpGetMode(int fd) * Get AGP aperture base. * * \param fd file descriptor. - * + * * \return aperture base on success, zero on failure. - * + * * \internal * This function is a wrapper around the DRM_IOCTL_AGP_INFO ioctl, getting the * necessary information in a drm_agp_info structure. @@ -1958,7 +1959,7 @@ unsigned long drmAgpBase(int fd) memclear(i); if (drmIoctl(fd, DRM_IOCTL_AGP_INFO, &i)) - return 0; + return 0; return i.aperture_base; } @@ -1967,9 +1968,9 @@ unsigned long drmAgpBase(int fd) * Get AGP aperture size. * * \param fd file descriptor. - * + * * \return aperture size on success, zero on failure. - * + * * \internal * This function is a wrapper around the DRM_IOCTL_AGP_INFO ioctl, getting the * necessary information in a drm_agp_info structure. @@ -1981,7 +1982,7 @@ unsigned long drmAgpSize(int fd) memclear(i); if (drmIoctl(fd, DRM_IOCTL_AGP_INFO, &i)) - return 0; + return 0; return i.aperture_size; } @@ -1990,9 +1991,9 @@ unsigned long drmAgpSize(int fd) * Get used AGP memory. * * \param fd file descriptor. - * + * * \return memory used on success, or zero on failure. - * + * * \internal * This function is a wrapper around the DRM_IOCTL_AGP_INFO ioctl, getting the * necessary information in a drm_agp_info structure. @@ -2004,7 +2005,7 @@ unsigned long drmAgpMemoryUsed(int fd) memclear(i); if (drmIoctl(fd, DRM_IOCTL_AGP_INFO, &i)) - return 0; + return 0; return i.memory_used; } @@ -2013,9 +2014,9 @@ unsigned long drmAgpMemoryUsed(int fd) * Get available AGP memory. * * \param fd file descriptor. - * + * * \return memory available on success, or zero on failure. - * + * * \internal * This function is a wrapper around the DRM_IOCTL_AGP_INFO ioctl, getting the * necessary information in a drm_agp_info structure. @@ -2027,7 +2028,7 @@ unsigned long drmAgpMemoryAvail(int fd) memclear(i); if (drmIoctl(fd, DRM_IOCTL_AGP_INFO, &i)) - return 0; + return 0; return i.memory_allowed; } @@ -2036,9 +2037,9 @@ unsigned long drmAgpMemoryAvail(int fd) * Get hardware vendor ID. * * \param fd file descriptor. - * + * * \return vendor ID on success, or zero on failure. - * + * * \internal * This function is a wrapper around the DRM_IOCTL_AGP_INFO ioctl, getting the * necessary information in a drm_agp_info structure. @@ -2050,7 +2051,7 @@ unsigned int drmAgpVendorId(int fd) memclear(i); if (drmIoctl(fd, DRM_IOCTL_AGP_INFO, &i)) - return 0; + return 0; return i.id_vendor; } @@ -2059,9 +2060,9 @@ unsigned int drmAgpVendorId(int fd) * Get hardware device ID. * * \param fd file descriptor. - * + * * \return zero on success, or zero on failure. - * + * * \internal * This function is a wrapper around the DRM_IOCTL_AGP_INFO ioctl, getting the * necessary information in a drm_agp_info structure. @@ -2073,7 +2074,7 @@ unsigned int drmAgpDeviceId(int fd) memclear(i); if (drmIoctl(fd, DRM_IOCTL_AGP_INFO, &i)) - return 0; + return 0; return i.id_device; } @@ -2086,7 +2087,7 @@ int drmScatterGatherAlloc(int fd, unsigned long size, drm_handle_t *handle) *handle = 0; sg.size = size; if (drmIoctl(fd, DRM_IOCTL_SG_ALLOC, &sg)) - return -errno; + return -errno; *handle = sg.handle; return 0; } @@ -2098,7 +2099,7 @@ int drmScatterGatherFree(int fd, drm_handle_t handle) memclear(sg); sg.handle = handle; if (drmIoctl(fd, DRM_IOCTL_SG_FREE, &sg)) - return -errno; + return -errno; return 0; } @@ -2107,9 +2108,9 @@ int drmScatterGatherFree(int fd, drm_handle_t handle) * * \param fd file descriptor. * \param vbl pointer to a drmVBlank structure. - * + * * \return zero on success, or a negative value on failure. - * + * * \internal * This function is a wrapper around the DRM_IOCTL_WAIT_VBLANK ioctl. */ @@ -2120,8 +2121,8 @@ int drmWaitVBlank(int fd, drmVBlankPtr vbl) ret = clock_gettime(CLOCK_MONOTONIC, &timeout); if (ret < 0) { - fprintf(stderr, "clock_gettime failed: %s\n", strerror(errno)); - goto out; + fprintf(stderr, "clock_gettime failed: %s\n", strerror(errno)); + goto out; } timeout.tv_sec++; @@ -2129,15 +2130,15 @@ int drmWaitVBlank(int fd, drmVBlankPtr vbl) ret = ioctl(fd, DRM_IOCTL_WAIT_VBLANK, vbl); vbl->request.type &= ~DRM_VBLANK_RELATIVE; if (ret && errno == EINTR) { - clock_gettime(CLOCK_MONOTONIC, &cur); - /* Timeout after 1s */ - if (cur.tv_sec > timeout.tv_sec + 1 || - (cur.tv_sec == timeout.tv_sec && cur.tv_nsec >= - timeout.tv_nsec)) { - errno = EBUSY; - ret = -1; - break; - } + clock_gettime(CLOCK_MONOTONIC, &cur); + /* Timeout after 1s */ + if (cur.tv_sec > timeout.tv_sec + 1 || + (cur.tv_sec == timeout.tv_sec && cur.tv_nsec >= + timeout.tv_nsec)) { + errno = EBUSY; + ret = -1; + break; + } } } while (ret && errno == EINTR); @@ -2149,22 +2150,22 @@ int drmError(int err, const char *label) { switch (err) { case DRM_ERR_NO_DEVICE: - fprintf(stderr, "%s: no device\n", label); - break; + fprintf(stderr, "%s: no device\n", label); + break; case DRM_ERR_NO_ACCESS: - fprintf(stderr, "%s: no access\n", label); - break; + fprintf(stderr, "%s: no access\n", label); + break; case DRM_ERR_NOT_ROOT: - fprintf(stderr, "%s: not root\n", label); - break; + fprintf(stderr, "%s: not root\n", label); + break; case DRM_ERR_INVALID: - fprintf(stderr, "%s: invalid args\n", label); - break; + fprintf(stderr, "%s: invalid args\n", label); + break; default: - if (err < 0) - err = -err; - fprintf( stderr, "%s: error %d (%s)\n", label, err, strerror(err) ); - break; + if (err < 0) + err = -err; + fprintf( stderr, "%s: error %d (%s)\n", label, err, strerror(err) ); + break; } return 1; @@ -2175,9 +2176,9 @@ int drmError(int err, const char *label) * * \param fd file descriptor. * \param irq IRQ number. - * + * * \return zero on success, or a negative value on failure. - * + * * \internal * This function is a wrapper around the DRM_IOCTL_CONTROL ioctl, passing the * argument in a drm_control structure. @@ -2190,7 +2191,7 @@ int drmCtlInstHandler(int fd, int irq) ctl.func = DRM_INST_HANDLER; ctl.irq = irq; if (drmIoctl(fd, DRM_IOCTL_CONTROL, &ctl)) - return -errno; + return -errno; return 0; } @@ -2199,9 +2200,9 @@ int drmCtlInstHandler(int fd, int irq) * Uninstall IRQ handler. * * \param fd file descriptor. - * + * * \return zero on success, or a negative value on failure. - * + * * \internal * This function is a wrapper around the DRM_IOCTL_CONTROL ioctl, passing the * argument in a drm_control structure. @@ -2214,7 +2215,7 @@ int drmCtlUninstHandler(int fd) ctl.func = DRM_UNINST_HANDLER; ctl.irq = 0; if (drmIoctl(fd, DRM_IOCTL_CONTROL, &ctl)) - return -errno; + return -errno; return 0; } @@ -2231,7 +2232,7 @@ int drmFinish(int fd, int context, drmLockFlags flags) if (flags & DRM_HALT_ALL_QUEUES) lock.flags |= _DRM_HALT_ALL_QUEUES; if (flags & DRM_HALT_CUR_QUEUES) lock.flags |= _DRM_HALT_CUR_QUEUES; if (drmIoctl(fd, DRM_IOCTL_FINISH, &lock)) - return -errno; + return -errno; return 0; } @@ -2242,9 +2243,9 @@ int drmFinish(int fd, int context, drmLockFlags flags) * \param busnum bus number. * \param devnum device number. * \param funcnum function number. - * + * * \return IRQ number on success, or a negative value on failure. - * + * * \internal * This function is a wrapper around the DRM_IOCTL_IRQ_BUSID ioctl, passing the * arguments in a drm_irq_busid structure. @@ -2258,7 +2259,7 @@ int drmGetInterruptFromBusID(int fd, int busnum, int devnum, int funcnum) p.devnum = devnum; p.funcnum = funcnum; if (drmIoctl(fd, DRM_IOCTL_IRQ_BUSID, &p)) - return -errno; + return -errno; return p.irq; } @@ -2267,8 +2268,8 @@ int drmAddContextTag(int fd, drm_context_t context, void *tag) drmHashEntry *entry = drmGetEntry(fd); if (drmHashInsert(entry->tagTable, context, tag)) { - drmHashDelete(entry->tagTable, context); - drmHashInsert(entry->tagTable, context, tag); + drmHashDelete(entry->tagTable, context); + drmHashInsert(entry->tagTable, context, tag); } return 0; } @@ -2286,7 +2287,7 @@ void *drmGetContextTag(int fd, drm_context_t context) void *value; if (drmHashLookup(entry->tagTable, context, &value)) - return NULL; + return NULL; return value; } @@ -2301,7 +2302,7 @@ int drmAddContextPrivateMapping(int fd, drm_context_t ctx_id, map.handle = (void *)(uintptr_t)handle; if (drmIoctl(fd, DRM_IOCTL_SET_SAREA_CTX, &map)) - return -errno; + return -errno; return 0; } @@ -2314,23 +2315,23 @@ int drmGetContextPrivateMapping(int fd, drm_context_t ctx_id, map.ctx_id = ctx_id; if (drmIoctl(fd, DRM_IOCTL_GET_SAREA_CTX, &map)) - return -errno; + return -errno; if (handle) - *handle = (drm_handle_t)(uintptr_t)map.handle; + *handle = (drm_handle_t)(uintptr_t)map.handle; return 0; } int drmGetMap(int fd, int idx, drm_handle_t *offset, drmSize *size, - drmMapType *type, drmMapFlags *flags, drm_handle_t *handle, - int *mtrr) + drmMapType *type, drmMapFlags *flags, drm_handle_t *handle, + int *mtrr) { drm_map_t map; memclear(map); map.offset = idx; if (drmIoctl(fd, DRM_IOCTL_GET_MAP, &map)) - return -errno; + return -errno; *offset = map.offset; *size = map.size; *type = map.type; @@ -2341,14 +2342,14 @@ int drmGetMap(int fd, int idx, drm_handle_t *offset, drmSize *size, } int drmGetClient(int fd, int idx, int *auth, int *pid, int *uid, - unsigned long *magic, unsigned long *iocs) + unsigned long *magic, unsigned long *iocs) { drm_client_t client; memclear(client); client.idx = idx; if (drmIoctl(fd, DRM_IOCTL_GET_CLIENT, &client)) - return -errno; + return -errno; *auth = client.auth; *pid = client.pid; *uid = client.uid; @@ -2364,12 +2365,12 @@ int drmGetStats(int fd, drmStatsT *stats) memclear(s); if (drmIoctl(fd, DRM_IOCTL_GET_STATS, &s)) - return -errno; + return -errno; stats->count = 0; memset(stats, 0, sizeof(*stats)); if (s.count > sizeof(stats->data)/sizeof(stats->data[0])) - return -1; + return -1; #define SET_VALUE \ stats->data[i].long_format = "%-20.20s"; \ @@ -2396,87 +2397,87 @@ int drmGetStats(int fd, drmStatsT *stats) stats->count = s.count; for (i = 0; i < s.count; i++) { - stats->data[i].value = s.data[i].value; - switch (s.data[i].type) { - case _DRM_STAT_LOCK: - stats->data[i].long_name = "Lock"; - stats->data[i].rate_name = "Lock"; - SET_VALUE; - break; - case _DRM_STAT_OPENS: - stats->data[i].long_name = "Opens"; - stats->data[i].rate_name = "O"; - SET_COUNT; - stats->data[i].verbose = 1; - break; - case _DRM_STAT_CLOSES: - stats->data[i].long_name = "Closes"; - stats->data[i].rate_name = "Lock"; - SET_COUNT; - stats->data[i].verbose = 1; - break; - case _DRM_STAT_IOCTLS: - stats->data[i].long_name = "Ioctls"; - stats->data[i].rate_name = "Ioc/s"; - SET_COUNT; - break; - case _DRM_STAT_LOCKS: - stats->data[i].long_name = "Locks"; - stats->data[i].rate_name = "Lck/s"; - SET_COUNT; - break; - case _DRM_STAT_UNLOCKS: - stats->data[i].long_name = "Unlocks"; - stats->data[i].rate_name = "Unl/s"; - SET_COUNT; - break; - case _DRM_STAT_IRQ: - stats->data[i].long_name = "IRQs"; - stats->data[i].rate_name = "IRQ/s"; - SET_COUNT; - break; - case _DRM_STAT_PRIMARY: - stats->data[i].long_name = "Primary Bytes"; - stats->data[i].rate_name = "PB/s"; - SET_BYTE; - break; - case _DRM_STAT_SECONDARY: - stats->data[i].long_name = "Secondary Bytes"; - stats->data[i].rate_name = "SB/s"; - SET_BYTE; - break; - case _DRM_STAT_DMA: - stats->data[i].long_name = "DMA"; - stats->data[i].rate_name = "DMA/s"; - SET_COUNT; - break; - case _DRM_STAT_SPECIAL: - stats->data[i].long_name = "Special DMA"; - stats->data[i].rate_name = "dma/s"; - SET_COUNT; - break; - case _DRM_STAT_MISSED: - stats->data[i].long_name = "Miss"; - stats->data[i].rate_name = "Ms/s"; - SET_COUNT; - break; - case _DRM_STAT_VALUE: - stats->data[i].long_name = "Value"; - stats->data[i].rate_name = "Value"; - SET_VALUE; - break; - case _DRM_STAT_BYTE: - stats->data[i].long_name = "Bytes"; - stats->data[i].rate_name = "B/s"; - SET_BYTE; - break; - case _DRM_STAT_COUNT: - default: - stats->data[i].long_name = "Count"; - stats->data[i].rate_name = "Cnt/s"; - SET_COUNT; - break; - } + stats->data[i].value = s.data[i].value; + switch (s.data[i].type) { + case _DRM_STAT_LOCK: + stats->data[i].long_name = "Lock"; + stats->data[i].rate_name = "Lock"; + SET_VALUE; + break; + case _DRM_STAT_OPENS: + stats->data[i].long_name = "Opens"; + stats->data[i].rate_name = "O"; + SET_COUNT; + stats->data[i].verbose = 1; + break; + case _DRM_STAT_CLOSES: + stats->data[i].long_name = "Closes"; + stats->data[i].rate_name = "Lock"; + SET_COUNT; + stats->data[i].verbose = 1; + break; + case _DRM_STAT_IOCTLS: + stats->data[i].long_name = "Ioctls"; + stats->data[i].rate_name = "Ioc/s"; + SET_COUNT; + break; + case _DRM_STAT_LOCKS: + stats->data[i].long_name = "Locks"; + stats->data[i].rate_name = "Lck/s"; + SET_COUNT; + break; + case _DRM_STAT_UNLOCKS: + stats->data[i].long_name = "Unlocks"; + stats->data[i].rate_name = "Unl/s"; + SET_COUNT; + break; + case _DRM_STAT_IRQ: + stats->data[i].long_name = "IRQs"; + stats->data[i].rate_name = "IRQ/s"; + SET_COUNT; + break; + case _DRM_STAT_PRIMARY: + stats->data[i].long_name = "Primary Bytes"; + stats->data[i].rate_name = "PB/s"; + SET_BYTE; + break; + case _DRM_STAT_SECONDARY: + stats->data[i].long_name = "Secondary Bytes"; + stats->data[i].rate_name = "SB/s"; + SET_BYTE; + break; + case _DRM_STAT_DMA: + stats->data[i].long_name = "DMA"; + stats->data[i].rate_name = "DMA/s"; + SET_COUNT; + break; + case _DRM_STAT_SPECIAL: + stats->data[i].long_name = "Special DMA"; + stats->data[i].rate_name = "dma/s"; + SET_COUNT; + break; + case _DRM_STAT_MISSED: + stats->data[i].long_name = "Miss"; + stats->data[i].rate_name = "Ms/s"; + SET_COUNT; + break; + case _DRM_STAT_VALUE: + stats->data[i].long_name = "Value"; + stats->data[i].rate_name = "Value"; + SET_VALUE; + break; + case _DRM_STAT_BYTE: + stats->data[i].long_name = "Bytes"; + stats->data[i].rate_name = "B/s"; + SET_BYTE; + break; + case _DRM_STAT_COUNT: + default: + stats->data[i].long_name = "Count"; + stats->data[i].rate_name = "Cnt/s"; + SET_COUNT; + break; + } } return 0; } @@ -2485,14 +2486,14 @@ int drmGetStats(int fd, drmStatsT *stats) * Issue a set-version ioctl. * * \param fd file descriptor. - * \param drmCommandIndex command index + * \param drmCommandIndex command index * \param data source pointer of the data to be read and written. * \param size size of the data to be read and written. - * + * * \return zero on success, or a negative value on failure. - * + * * \internal - * It issues a read-write ioctl given by + * It issues a read-write ioctl given by * \code DRM_COMMAND_BASE + drmCommandIndex \endcode. */ int drmSetInterfaceVersion(int fd, drmSetVersion *version) @@ -2507,7 +2508,7 @@ int drmSetInterfaceVersion(int fd, drmSetVersion *version) sv.drm_dd_minor = version->drm_dd_minor; if (drmIoctl(fd, DRM_IOCTL_SET_VERSION, &sv)) { - retcode = -errno; + retcode = -errno; } version->drm_di_major = sv.drm_di_major; @@ -2522,12 +2523,12 @@ int drmSetInterfaceVersion(int fd, drmSetVersion *version) * Send a device-specific command. * * \param fd file descriptor. - * \param drmCommandIndex command index - * + * \param drmCommandIndex command index + * * \return zero on success, or a negative value on failure. - * + * * \internal - * It issues a ioctl given by + * It issues a ioctl given by * \code DRM_COMMAND_BASE + drmCommandIndex \endcode. */ int drmCommandNone(int fd, unsigned long drmCommandIndex) @@ -2537,7 +2538,7 @@ int drmCommandNone(int fd, unsigned long drmCommandIndex) request = DRM_IO( DRM_COMMAND_BASE + drmCommandIndex); if (drmIoctl(fd, request, NULL)) { - return -errno; + return -errno; } return 0; } @@ -2547,14 +2548,14 @@ int drmCommandNone(int fd, unsigned long drmCommandIndex) * Send a device-specific read command. * * \param fd file descriptor. - * \param drmCommandIndex command index + * \param drmCommandIndex command index * \param data destination pointer of the data to be read. * \param size size of the data to be read. - * + * * \return zero on success, or a negative value on failure. * * \internal - * It issues a read ioctl given by + * It issues a read ioctl given by * \code DRM_COMMAND_BASE + drmCommandIndex \endcode. */ int drmCommandRead(int fd, unsigned long drmCommandIndex, void *data, @@ -2562,11 +2563,11 @@ int drmCommandRead(int fd, unsigned long drmCommandIndex, void *data, { unsigned long request; - request = DRM_IOC( DRM_IOC_READ, DRM_IOCTL_BASE, - DRM_COMMAND_BASE + drmCommandIndex, size); + request = DRM_IOC( DRM_IOC_READ, DRM_IOCTL_BASE, + DRM_COMMAND_BASE + drmCommandIndex, size); if (drmIoctl(fd, request, data)) { - return -errno; + return -errno; } return 0; } @@ -2576,14 +2577,14 @@ int drmCommandRead(int fd, unsigned long drmCommandIndex, void *data, * Send a device-specific write command. * * \param fd file descriptor. - * \param drmCommandIndex command index + * \param drmCommandIndex command index * \param data source pointer of the data to be written. * \param size size of the data to be written. - * + * * \return zero on success, or a negative value on failure. - * + * * \internal - * It issues a write ioctl given by + * It issues a write ioctl given by * \code DRM_COMMAND_BASE + drmCommandIndex \endcode. */ int drmCommandWrite(int fd, unsigned long drmCommandIndex, void *data, @@ -2591,11 +2592,11 @@ int drmCommandWrite(int fd, unsigned long drmCommandIndex, void *data, { unsigned long request; - request = DRM_IOC( DRM_IOC_WRITE, DRM_IOCTL_BASE, - DRM_COMMAND_BASE + drmCommandIndex, size); + request = DRM_IOC( DRM_IOC_WRITE, DRM_IOCTL_BASE, + DRM_COMMAND_BASE + drmCommandIndex, size); if (drmIoctl(fd, request, data)) { - return -errno; + return -errno; } return 0; } @@ -2605,14 +2606,14 @@ int drmCommandWrite(int fd, unsigned long drmCommandIndex, void *data, * Send a device-specific read-write command. * * \param fd file descriptor. - * \param drmCommandIndex command index + * \param drmCommandIndex command index * \param data source pointer of the data to be read and written. * \param size size of the data to be read and written. - * + * * \return zero on success, or a negative value on failure. - * + * * \internal - * It issues a read-write ioctl given by + * It issues a read-write ioctl given by * \code DRM_COMMAND_BASE + drmCommandIndex \endcode. */ int drmCommandWriteRead(int fd, unsigned long drmCommandIndex, void *data, @@ -2620,11 +2621,11 @@ int drmCommandWriteRead(int fd, unsigned long drmCommandIndex, void *data, { unsigned long request; - request = DRM_IOC( DRM_IOC_READ|DRM_IOC_WRITE, DRM_IOCTL_BASE, - DRM_COMMAND_BASE + drmCommandIndex, size); + request = DRM_IOC( DRM_IOC_READ|DRM_IOC_WRITE, DRM_IOCTL_BASE, + DRM_COMMAND_BASE + drmCommandIndex, size); if (drmIoctl(fd, request, data)) - return -errno; + return -errno; return 0; } @@ -2638,9 +2639,9 @@ static struct { static int nr_fds = 0; -int drmOpenOnce(void *unused, - const char *BusID, - int *newlyopened) +int drmOpenOnce(void *unused, + const char *BusID, + int *newlyopened) { return drmOpenOnceWithType(BusID, newlyopened, DRM_NODE_PRIMARY); } @@ -2649,19 +2650,19 @@ int drmOpenOnceWithType(const char *BusID, int *newlyopened, int type) { int i; int fd; - + for (i = 0; i < nr_fds; i++) - if ((strcmp(BusID, connection[i].BusID) == 0) && - (connection[i].type == type)) { - connection[i].refcount++; - *newlyopened = 0; - return connection[i].fd; - } + if ((strcmp(BusID, connection[i].BusID) == 0) && + (connection[i].type == type)) { + connection[i].refcount++; + *newlyopened = 0; + return connection[i].fd; + } fd = drmOpenWithType(NULL, BusID, type); if (fd < 0 || nr_fds == DRM_MAX_FDS) - return fd; - + return fd; + connection[nr_fds].BusID = strdup(BusID); connection[nr_fds].fd = fd; connection[nr_fds].refcount = 1; @@ -2669,9 +2670,9 @@ int drmOpenOnceWithType(const char *BusID, int *newlyopened, int type) *newlyopened = 1; if (0) - fprintf(stderr, "saved connection %d for %s %d\n", - nr_fds, connection[nr_fds].BusID, - strcmp(BusID, connection[nr_fds].BusID)); + fprintf(stderr, "saved connection %d for %s %d\n", + nr_fds, connection[nr_fds].BusID, + strcmp(BusID, connection[nr_fds].BusID)); nr_fds++; @@ -2683,24 +2684,24 @@ void drmCloseOnce(int fd) int i; for (i = 0; i < nr_fds; i++) { - if (fd == connection[i].fd) { - if (--connection[i].refcount == 0) { - drmClose(connection[i].fd); - free(connection[i].BusID); - - if (i < --nr_fds) - connection[i] = connection[nr_fds]; - - return; - } - } + if (fd == connection[i].fd) { + if (--connection[i].refcount == 0) { + drmClose(connection[i].fd); + free(connection[i].BusID); + + if (i < --nr_fds) + connection[i] = connection[nr_fds]; + + return; + } + } } } int drmSetMaster(int fd) { #ifndef __OpenBSD__ - return drmIoctl(fd, DRM_IOCTL_SET_MASTER, NULL); + return drmIoctl(fd, DRM_IOCTL_SET_MASTER, NULL); #endif return 0; } @@ -2708,161 +2709,161 @@ int drmSetMaster(int fd) int drmDropMaster(int fd) { #ifndef __OpenBSD__ - return drmIoctl(fd, DRM_IOCTL_DROP_MASTER, NULL); + return drmIoctl(fd, DRM_IOCTL_DROP_MASTER, NULL); #endif return 0; } char *drmGetDeviceNameFromFd(int fd) { - char name[128]; - struct stat sbuf; - dev_t d; - int i; + char name[128]; + struct stat sbuf; + dev_t d; + int i; - /* The whole drmOpen thing is a fiasco and we need to find a way - * back to just using open(2). For now, however, lets just make - * things worse with even more ad hoc directory walking code to - * discover the device file name. */ + /* The whole drmOpen thing is a fiasco and we need to find a way + * back to just using open(2). For now, however, lets just make + * things worse with even more ad hoc directory walking code to + * discover the device file name. */ - fstat(fd, &sbuf); - d = sbuf.st_rdev; + fstat(fd, &sbuf); + d = sbuf.st_rdev; - for (i = 0; i < DRM_MAX_MINOR; i++) { - snprintf(name, sizeof name, DRM_DEV_NAME, DRM_DIR_NAME, i); - if (stat(name, &sbuf) == 0 && sbuf.st_rdev == d) - break; - } - if (i == DRM_MAX_MINOR) - return NULL; + for (i = 0; i < DRM_MAX_MINOR; i++) { + snprintf(name, sizeof name, DRM_DEV_NAME, DRM_DIR_NAME, i); + if (stat(name, &sbuf) == 0 && sbuf.st_rdev == d) + break; + } + if (i == DRM_MAX_MINOR) + return NULL; - return strdup(name); + return strdup(name); } int drmGetNodeTypeFromFd(int fd) { - struct stat sbuf; - int maj, min, type; + struct stat sbuf; + int maj, min, type; - if (fstat(fd, &sbuf)) - return -1; + if (fstat(fd, &sbuf)) + return -1; - maj = major(sbuf.st_rdev); - min = minor(sbuf.st_rdev); + maj = major(sbuf.st_rdev); + min = minor(sbuf.st_rdev); - if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) { - errno = EINVAL; - return -1; - } + if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) { + errno = EINVAL; + return -1; + } - type = drmGetMinorType(min); - if (type == -1) - errno = ENODEV; - return type; + type = drmGetMinorType(min); + if (type == -1) + errno = ENODEV; + return type; } int drmPrimeHandleToFD(int fd, uint32_t handle, uint32_t flags, int *prime_fd) { - struct drm_prime_handle args; - int ret; + struct drm_prime_handle args; + int ret; - memclear(args); - args.fd = -1; - args.handle = handle; - args.flags = flags; - ret = drmIoctl(fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &args); - if (ret) - return ret; + memclear(args); + args.fd = -1; + args.handle = handle; + args.flags = flags; + ret = drmIoctl(fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &args); + if (ret) + return ret; - *prime_fd = args.fd; - return 0; + *prime_fd = args.fd; + return 0; } int drmPrimeFDToHandle(int fd, int prime_fd, uint32_t *handle) { - struct drm_prime_handle args; - int ret; + struct drm_prime_handle args; + int ret; - memclear(args); - args.fd = prime_fd; - ret = drmIoctl(fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &args); - if (ret) - return ret; + memclear(args); + args.fd = prime_fd; + ret = drmIoctl(fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &args); + if (ret) + return ret; - *handle = args.handle; - return 0; + *handle = args.handle; + return 0; } static char *drmGetMinorNameForFD(int fd, int type) { #ifdef __linux__ - DIR *sysdir; - struct dirent *pent, *ent; - struct stat sbuf; - const char *name = drmGetMinorName(type); - int len; - char dev_name[64], buf[64]; - long name_max; - int maj, min; + DIR *sysdir; + struct dirent *pent, *ent; + struct stat sbuf; + const char *name = drmGetMinorName(type); + int len; + char dev_name[64], buf[64]; + long name_max; + int maj, min; - if (!name) - return NULL; + if (!name) + return NULL; - len = strlen(name); + len = strlen(name); - if (fstat(fd, &sbuf)) - return NULL; + if (fstat(fd, &sbuf)) + return NULL; - maj = major(sbuf.st_rdev); - min = minor(sbuf.st_rdev); + maj = major(sbuf.st_rdev); + min = minor(sbuf.st_rdev); - if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) - return NULL; + if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) + return NULL; - snprintf(buf, sizeof(buf), "/sys/dev/char/%d:%d/device/drm", maj, min); + snprintf(buf, sizeof(buf), "/sys/dev/char/%d:%d/device/drm", maj, min); - sysdir = opendir(buf); - if (!sysdir) - return NULL; + sysdir = opendir(buf); + if (!sysdir) + return NULL; - name_max = fpathconf(dirfd(sysdir), _PC_NAME_MAX); - if (name_max == -1) - goto out_close_dir; + name_max = fpathconf(dirfd(sysdir), _PC_NAME_MAX); + if (name_max == -1) + goto out_close_dir; - pent = malloc(offsetof(struct dirent, d_name) + name_max + 1); - if (pent == NULL) - goto out_close_dir; + pent = malloc(offsetof(struct dirent, d_name) + name_max + 1); + if (pent == NULL) + goto out_close_dir; - while (readdir_r(sysdir, pent, &ent) == 0 && ent != NULL) { - if (strncmp(ent->d_name, name, len) == 0) { - snprintf(dev_name, sizeof(dev_name), DRM_DIR_NAME "/%s", - ent->d_name); + while (readdir_r(sysdir, pent, &ent) == 0 && ent != NULL) { + if (strncmp(ent->d_name, name, len) == 0) { + snprintf(dev_name, sizeof(dev_name), DRM_DIR_NAME "/%s", + ent->d_name); - free(pent); - closedir(sysdir); + free(pent); + closedir(sysdir); - return strdup(dev_name); - } - } + return strdup(dev_name); + } + } - free(pent); + free(pent); out_close_dir: - closedir(sysdir); + closedir(sysdir); #else #warning "Missing implementation of drmGetMinorNameForFD" #endif - return NULL; + return NULL; } char *drmGetPrimaryDeviceNameFromFd(int fd) { - return drmGetMinorNameForFD(fd, DRM_NODE_PRIMARY); + return drmGetMinorNameForFD(fd, DRM_NODE_PRIMARY); } char *drmGetRenderDeviceNameFromFd(int fd) { - return drmGetMinorNameForFD(fd, DRM_NODE_RENDER); + return drmGetMinorNameForFD(fd, DRM_NODE_RENDER); } static int drmParseSubsystemType(int maj, int min) @@ -2975,7 +2976,7 @@ static int drmGetMaxNodeName(void) MAX3(sizeof(DRM_PRIMARY_MINOR_NAME), sizeof(DRM_CONTROL_MINOR_NAME), sizeof(DRM_RENDER_MINOR_NAME)) + - 3 /* lenght of the node number */; + 3 /* length of the node number */; } static int drmParsePciDeviceInfo(const char *d_name, @@ -3025,27 +3026,28 @@ void drmFreeDevices(drmDevicePtr devices[], int count) if (devices == NULL) return; - for (i = 0; i < count && devices[i] != NULL; i++) - drmFreeDevice(&devices[i]); + for (i = 0; i < count; i++) + if (devices[i]) + 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) { - const int max_node_str = drmGetMaxNodeName(); + const int max_node_str = ALIGN(drmGetMaxNodeName(), sizeof(void *)); int ret, i; char *addr; *device = calloc(1, sizeof(drmDevice) + - (DRM_NODE_MAX * (sizeof(void *) + max_node_str)) + - sizeof(drmPciBusInfo) + - sizeof(drmPciDeviceInfo)); + (DRM_NODE_MAX * (sizeof(void *) + max_node_str)) + + sizeof(drmPciBusInfo) + + sizeof(drmPciDeviceInfo)); if (!*device) return -ENOMEM; addr = (char*)*device; - + (*device)->bustype = DRM_BUS_PCI; (*device)->available_nodes = 1 << node_type; @@ -3082,6 +3084,11 @@ free_device: return ret; } +/* Consider devices located on the same bus as duplicate and fold the respective + * entries into a single one. + * + * Note: this leaves "gaps" in the array, while preserving the length. + */ static void drmFoldDuplicatedDevices(drmDevicePtr local_devices[], int count) { int node_type, i, j; @@ -3120,6 +3127,7 @@ int drmGetDevice(int fd, drmDevicePtr *device) int maj, min; int ret, i, node_count; int max_count = 16; + dev_t find_rdev; if (fd == -1 || device == NULL) return -EINVAL; @@ -3127,6 +3135,7 @@ int drmGetDevice(int fd, drmDevicePtr *device) if (fstat(fd, &sbuf)) return -errno; + find_rdev = sbuf.st_rdev; maj = major(sbuf.st_rdev); min = minor(sbuf.st_rdev); @@ -3187,17 +3196,21 @@ int drmGetDevice(int fd, drmDevicePtr *device) local_devices = temp; } - local_devices[i] = d; + /* store target at local_devices[0] for ease to use below */ + if (find_rdev == sbuf.st_rdev && i) { + local_devices[i] = local_devices[0]; + local_devices[0] = d; + } + else + local_devices[i] = d; i++; } node_count = i; - /* Fold nodes into a single device if they share the same bus info */ drmFoldDuplicatedDevices(local_devices, node_count); *device = local_devices[0]; - for (i = 1; i < node_count && local_devices[i]; i++) - drmFreeDevice(&local_devices[i]); + drmFreeDevices(&local_devices[1], node_count - 1); closedir(sysdir); free(local_devices); @@ -3296,11 +3309,13 @@ int drmGetDevices(drmDevicePtr devices[], int max_devices) } node_count = i; - /* Fold nodes into a single device if they share the same bus info */ drmFoldDuplicatedDevices(local_devices, node_count); device_count = 0; - for (i = 0; i < node_count && local_devices[i]; i++) { + for (i = 0; i < node_count; i++) { + if (!local_devices[i]) + continue; + if ((devices != NULL) && (device_count < max_devices)) devices[device_count] = local_devices[i]; else diff --git a/lib/libdrm/xf86drmMode.c b/lib/libdrm/xf86drmMode.c index 771006186..228c6e4b2 100644 --- a/lib/libdrm/xf86drmMode.c +++ b/lib/libdrm/xf86drmMode.c @@ -34,7 +34,7 @@ */ /* - * TODO the types we are after are defined in diffrent headers on diffrent + * TODO the types we are after are defined in different headers on different * platforms find which headers to include to get uint32_t */ @@ -270,10 +270,10 @@ int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth, return 0; } -int drmModeAddFB2(int fd, uint32_t width, uint32_t height, - uint32_t pixel_format, uint32_t bo_handles[4], - uint32_t pitches[4], uint32_t offsets[4], - uint32_t *buf_id, uint32_t flags) +int drmModeAddFB2WithModifiers(int fd, uint32_t width, uint32_t height, + uint32_t pixel_format, uint32_t bo_handles[4], + uint32_t pitches[4], uint32_t offsets[4], + uint64_t modifier[4], uint32_t *buf_id, uint32_t flags) { struct drm_mode_fb_cmd2 f; int ret; @@ -286,6 +286,8 @@ int drmModeAddFB2(int fd, uint32_t width, uint32_t height, memcpy(f.handles, bo_handles, 4 * sizeof(bo_handles[0])); memcpy(f.pitches, pitches, 4 * sizeof(pitches[0])); memcpy(f.offsets, offsets, 4 * sizeof(offsets[0])); + if (modifier) + memcpy(f.modifier, modifier, 4 * sizeof(modifier[0])); if ((ret = DRM_IOCTL(fd, DRM_IOCTL_MODE_ADDFB2, &f))) return ret; @@ -294,6 +296,17 @@ int drmModeAddFB2(int fd, uint32_t width, uint32_t height, return 0; } +int drmModeAddFB2(int fd, uint32_t width, uint32_t height, + uint32_t pixel_format, uint32_t bo_handles[4], + uint32_t pitches[4], uint32_t offsets[4], + uint32_t *buf_id, uint32_t flags) +{ + return drmModeAddFB2WithModifiers(fd, width, height, + pixel_format, bo_handles, + pitches, offsets, NULL, + buf_id, flags); +} + int drmModeRmFB(int fd, uint32_t bufferId) { return DRM_IOCTL(fd, DRM_IOCTL_MODE_RMFB, &bufferId); diff --git a/lib/libdrm/xf86drmMode.h b/lib/libdrm/xf86drmMode.h index 4de7bbbe5..1a02fed43 100644 --- a/lib/libdrm/xf86drmMode.h +++ b/lib/libdrm/xf86drmMode.h @@ -369,6 +369,13 @@ extern int drmModeAddFB2(int fd, uint32_t width, uint32_t height, uint32_t pixel_format, uint32_t bo_handles[4], uint32_t pitches[4], uint32_t offsets[4], uint32_t *buf_id, uint32_t flags); + +/* ...with format modifiers */ +int drmModeAddFB2WithModifiers(int fd, uint32_t width, uint32_t height, + uint32_t pixel_format, uint32_t bo_handles[4], + uint32_t pitches[4], uint32_t offsets[4], + uint64_t modifier[4], uint32_t *buf_id, uint32_t flags); + /** * Destroies the given framebuffer. */ |