diff --git a/lib/libdrm/Makefile.bsd-wrapper b/lib/libdrm/Makefile.bsd-wrapper index bd69c84a8..039f29516 100644 --- a/lib/libdrm/Makefile.bsd-wrapper +++ b/lib/libdrm/Makefile.bsd-wrapper @@ -1,8 +1,8 @@ -# $OpenBSD: Makefile.bsd-wrapper,v 1.13 2017/10/23 16:50:29 matthieu Exp $ +# $OpenBSD: Makefile.bsd-wrapper,v 1.14 2018/02/17 02:31:15 jsg Exp $ # cheat on configure - we don't need pthread-stubs anymore CONFIGURE_ARGS= PTHREADSTUBS_CFLAGS=' ' PTHREADSTUBS_LIBS=' ' -SHARED_LIBS= drm 7.5 drm_radeon 4.0 drm_intel 5.4 \ - drm_amdgpu 1.4 drm_nouveau 3.0 +SHARED_LIBS= drm 7.6 drm_radeon 4.0 drm_intel 5.4 \ + drm_amdgpu 1.5 drm_nouveau 3.0 .include diff --git a/lib/libdrm/amdgpu/Makefile.am b/lib/libdrm/amdgpu/Makefile.am index a843829b2..a1b0d05c1 100644 --- a/lib/libdrm/amdgpu/Makefile.am +++ b/lib/libdrm/amdgpu/Makefile.am @@ -31,10 +31,7 @@ AM_CFLAGS = \ -I$(top_srcdir)/include/drm libdrmdatadir = @libdrmdatadir@ -ASIC_ID_TABLE_NUM_ENTRIES != egrep -ci '^[0-9a-f]{4},.*[0-9a-f]+,' \ - $(top_srcdir)/data/amdgpu.ids -AM_CPPFLAGS = -DAMDGPU_ASIC_ID_TABLE=\"${libdrmdatadir}/amdgpu.ids\" \ - -DAMDGPU_ASIC_ID_TABLE_NUM_ENTRIES=$(ASIC_ID_TABLE_NUM_ENTRIES) +AM_CPPFLAGS = -DAMDGPU_ASIC_ID_TABLE=\"${libdrmdatadir}/amdgpu.ids\" libdrm_amdgpu_la_LTLIBRARIES = libdrm_amdgpu.la libdrm_amdgpu_ladir = $(libdir) diff --git a/lib/libdrm/amdgpu/Makefile.in b/lib/libdrm/amdgpu/Makefile.in index aafe734bb..033e1b385 100644 --- a/lib/libdrm/amdgpu/Makefile.in +++ b/lib/libdrm/amdgpu/Makefile.in @@ -125,7 +125,7 @@ LTLIBRARIES = $(libdrm_amdgpu_la_LTLIBRARIES) libdrm_amdgpu_la_DEPENDENCIES = ../libdrm.la am__objects_1 = amdgpu_asic_id.lo amdgpu_bo.lo amdgpu_cs.lo \ amdgpu_device.lo amdgpu_gpu_info.lo amdgpu_vamgr.lo \ - util_hash.lo util_hash_table.lo + amdgpu_vm.lo util_hash.lo util_hash_table.lo am_libdrm_amdgpu_la_OBJECTS = $(am__objects_1) libdrm_amdgpu_la_OBJECTS = $(am_libdrm_amdgpu_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) @@ -344,6 +344,7 @@ LIBDRM_AMDGPU_FILES := \ amdgpu_gpu_info.c \ amdgpu_internal.h \ amdgpu_vamgr.c \ + amdgpu_vm.c \ util_hash.c \ util_hash.h \ util_hash_table.c \ @@ -358,9 +359,7 @@ AM_CFLAGS = \ $(PTHREADSTUBS_CFLAGS) \ -I$(top_srcdir)/include/drm -AM_CPPFLAGS = -DAMDGPU_ASIC_ID_TABLE=\"${libdrmdatadir}/amdgpu.ids\" \ - -DAMDGPU_ASIC_ID_TABLE_NUM_ENTRIES=$(ASIC_ID_TABLE_NUM_ENTRIES) - +AM_CPPFLAGS = -DAMDGPU_ASIC_ID_TABLE=\"${libdrmdatadir}/amdgpu.ids\" libdrm_amdgpu_la_LTLIBRARIES = libdrm_amdgpu.la libdrm_amdgpu_ladir = $(libdir) libdrm_amdgpu_la_LDFLAGS = -version-number 1:0:0 -no-undefined @@ -457,6 +456,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amdgpu_device.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amdgpu_gpu_info.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amdgpu_vamgr.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amdgpu_vm.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/util_hash.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/util_hash_table.Plo@am__quote@ @@ -848,8 +848,6 @@ uninstall-am: uninstall-libdrm_amdgpu_laLTLIBRARIES \ uninstall-libdrm_amdgpu_laLTLIBRARIES \ uninstall-libdrm_amdgpuincludeHEADERS uninstall-pkgconfigDATA -ASIC_ID_TABLE_NUM_ENTRIES != egrep -ci '^[0-9a-f]{4},.*[0-9a-f]+,' \ - $(top_srcdir)/data/amdgpu.ids amdgpu_asic_id.lo: $(top_srcdir)/data/amdgpu.ids # Tell versions [3.59,3.63) of GNU make to not export all variables. diff --git a/lib/libdrm/amdgpu/amdgpu_bo.c b/lib/libdrm/amdgpu/amdgpu_bo.c index 5ac456be0..3853fd03d 100644 --- a/lib/libdrm/amdgpu/amdgpu_bo.c +++ b/lib/libdrm/amdgpu/amdgpu_bo.c @@ -53,29 +53,6 @@ static void amdgpu_close_kms_handle(amdgpu_device_handle dev, drmIoctl(dev->fd, DRM_IOCTL_GEM_CLOSE, &args); } -drm_private void amdgpu_bo_free_internal(amdgpu_bo_handle bo) -{ - /* Remove the buffer from the hash tables. */ - pthread_mutex_lock(&bo->dev->bo_table_mutex); - util_hash_table_remove(bo->dev->bo_handles, - (void*)(uintptr_t)bo->handle); - if (bo->flink_name) { - util_hash_table_remove(bo->dev->bo_flink_names, - (void*)(uintptr_t)bo->flink_name); - } - pthread_mutex_unlock(&bo->dev->bo_table_mutex); - - /* Release CPU access. */ - if (bo->cpu_map_count > 0) { - bo->cpu_map_count = 1; - amdgpu_bo_cpu_unmap(bo); - } - - amdgpu_close_kms_handle(bo->dev, bo->handle); - pthread_mutex_destroy(&bo->cpu_access_mutex); - free(bo); -} - int amdgpu_bo_alloc(amdgpu_device_handle dev, struct amdgpu_bo_alloc_request *alloc_buffer, amdgpu_bo_handle *buf_handle) @@ -302,6 +279,7 @@ int amdgpu_bo_import(amdgpu_device_handle dev, /* Get a KMS handle. */ r = drmPrimeFDToHandle(dev->fd, shared_handle, &handle); if (r) { + pthread_mutex_unlock(&dev->bo_table_mutex); return r; } @@ -341,10 +319,9 @@ int amdgpu_bo_import(amdgpu_device_handle dev, } if (bo) { - pthread_mutex_unlock(&dev->bo_table_mutex); - /* The buffer already exists, just bump the refcount. */ atomic_inc(&bo->refcount); + pthread_mutex_unlock(&dev->bo_table_mutex); output->buf_handle = bo; output->alloc_size = bo->alloc_size; @@ -419,8 +396,35 @@ int amdgpu_bo_import(amdgpu_device_handle dev, int amdgpu_bo_free(amdgpu_bo_handle buf_handle) { - /* Just drop the reference. */ - amdgpu_bo_reference(&buf_handle, NULL); + struct amdgpu_device *dev; + struct amdgpu_bo *bo = buf_handle; + + assert(bo != NULL); + dev = bo->dev; + pthread_mutex_lock(&dev->bo_table_mutex); + + if (update_references(&bo->refcount, NULL)) { + /* Remove the buffer from the hash tables. */ + util_hash_table_remove(dev->bo_handles, + (void*)(uintptr_t)bo->handle); + + if (bo->flink_name) { + util_hash_table_remove(dev->bo_flink_names, + (void*)(uintptr_t)bo->flink_name); + } + + /* Release CPU access. */ + if (bo->cpu_map_count > 0) { + bo->cpu_map_count = 1; + amdgpu_bo_cpu_unmap(bo); + } + + amdgpu_close_kms_handle(dev, bo->handle); + pthread_mutex_destroy(&bo->cpu_access_mutex); + free(bo); + } + + pthread_mutex_unlock(&dev->bo_table_mutex); return 0; } diff --git a/lib/libdrm/configure b/lib/libdrm/configure index 635c82d57..dc706d63b 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.82. +# Generated by GNU Autoconf 2.69 for libdrm 2.4.89. # # Report bugs to . # @@ -591,8 +591,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='libdrm' PACKAGE_TARNAME='libdrm' -PACKAGE_VERSION='2.4.82' -PACKAGE_STRING='libdrm 2.4.82' +PACKAGE_VERSION='2.4.89' +PACKAGE_STRING='libdrm 2.4.89' PACKAGE_BUGREPORT='https://bugs.freedesktop.org/enter_bug.cgi?product=DRI' PACKAGE_URL='' @@ -1423,7 +1423,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.82 to adapt to many kinds of systems. +\`configure' configures libdrm 2.4.89 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1493,7 +1493,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libdrm 2.4.82:";; + short | recursive ) echo "Configuration of libdrm 2.4.89:";; esac cat <<\_ACEOF @@ -1663,7 +1663,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -libdrm configure 2.4.82 +libdrm configure 2.4.89 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2086,7 +2086,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.82, which was +It was created by libdrm $as_me 2.4.89, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3429,7 +3429,7 @@ fi # Define the identity of the package. PACKAGE='libdrm' - VERSION='2.4.82' + VERSION='2.4.89' cat >>confdefs.h <<_ACEOF @@ -12721,7 +12721,7 @@ CC="$lt_save_CC" case "$host_os" in -linux* | cygwin* | darwin* | solaris* | *-gnu* | gnu*) +linux* | cygwin* | darwin* | solaris* | *-gnu* | gnu* | openbsd*) pthread_stubs_possible="no" ;; * ) @@ -12739,12 +12739,12 @@ if test -n "$PTHREADSTUBS_CFLAGS"; then pkg_cv_PTHREADSTUBS_CFLAGS="$PTHREADSTUBS_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pthread-stubs >= 0.3\""; } >&5 - ($PKG_CONFIG --exists --print-errors "pthread-stubs >= 0.3") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pthread-stubs >= 0.4\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pthread-stubs >= 0.4") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_PTHREADSTUBS_CFLAGS=`$PKG_CONFIG --cflags "pthread-stubs >= 0.3" 2>/dev/null` + pkg_cv_PTHREADSTUBS_CFLAGS=`$PKG_CONFIG --cflags "pthread-stubs >= 0.4" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -12756,12 +12756,12 @@ if test -n "$PTHREADSTUBS_LIBS"; then pkg_cv_PTHREADSTUBS_LIBS="$PTHREADSTUBS_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pthread-stubs >= 0.3\""; } >&5 - ($PKG_CONFIG --exists --print-errors "pthread-stubs >= 0.3") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pthread-stubs >= 0.4\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pthread-stubs >= 0.4") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_PTHREADSTUBS_LIBS=`$PKG_CONFIG --libs "pthread-stubs >= 0.3" 2>/dev/null` + pkg_cv_PTHREADSTUBS_LIBS=`$PKG_CONFIG --libs "pthread-stubs >= 0.4" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -12782,14 +12782,14 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - PTHREADSTUBS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "pthread-stubs >= 0.3" 2>&1` + PTHREADSTUBS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "pthread-stubs >= 0.4" 2>&1` else - PTHREADSTUBS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "pthread-stubs >= 0.3" 2>&1` + PTHREADSTUBS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "pthread-stubs >= 0.4" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$PTHREADSTUBS_PKG_ERRORS" >&5 - as_fn_error $? "Package requirements (pthread-stubs >= 0.3) were not met: + as_fn_error $? "Package requirements (pthread-stubs >= 0.4) were not met: $PTHREADSTUBS_PKG_ERRORS @@ -14647,7 +14647,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.82, which was +This file was extended by libdrm $as_me 2.4.89, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -14713,7 +14713,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.82 +libdrm config.status 2.4.89 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/lib/libdrm/configure.ac b/lib/libdrm/configure.ac index 3ba77f4af..d024fcd8c 100644 --- a/lib/libdrm/configure.ac +++ b/lib/libdrm/configure.ac @@ -20,7 +20,7 @@ AC_PREREQ([2.63]) AC_INIT([libdrm], - [2.4.82], + [2.4.89], [https://bugs.freedesktop.org/enter_bug.cgi?product=DRI], [libdrm]) @@ -65,10 +65,10 @@ AC_CHECK_HEADERS([sys/sysctl.h sys/select.h]) LT_PREREQ([2.2]) LT_INIT([disable-static]) -dnl pthread-stubs is mandatory on BSD platforms, due to the nature of the +dnl pthread-stubs is mandatory on some BSD platforms, due to the nature of the dnl project. Even then there's a notable issue as described in the project README case "$host_os" in -linux* | cygwin* | darwin* | solaris* | *-gnu* | gnu*) +linux* | cygwin* | darwin* | solaris* | *-gnu* | gnu* | openbsd*) pthread_stubs_possible="no" ;; * ) @@ -77,7 +77,7 @@ linux* | cygwin* | darwin* | solaris* | *-gnu* | gnu*) esac if test "x$pthread_stubs_possible" = xyes; then - PKG_CHECK_MODULES(PTHREADSTUBS, pthread-stubs >= 0.3) + PKG_CHECK_MODULES(PTHREADSTUBS, pthread-stubs >= 0.4) AC_SUBST(PTHREADSTUBS_CFLAGS) AC_SUBST(PTHREADSTUBS_LIBS) fi diff --git a/lib/libdrm/etnaviv/Makefile.in b/lib/libdrm/etnaviv/Makefile.in index d50a16e89..305ff46f0 100644 --- a/lib/libdrm/etnaviv/Makefile.in +++ b/lib/libdrm/etnaviv/Makefile.in @@ -100,7 +100,8 @@ am__installdirs = "$(DESTDIR)$(libdrm_etnaviv_ladir)" \ LTLIBRARIES = $(libdrm_etnaviv_la_LTLIBRARIES) libdrm_etnaviv_la_DEPENDENCIES = ../libdrm.la am__objects_1 = etnaviv_device.lo etnaviv_gpu.lo etnaviv_bo.lo \ - etnaviv_bo_cache.lo etnaviv_pipe.lo etnaviv_cmd_stream.lo + etnaviv_bo_cache.lo etnaviv_perfmon.lo etnaviv_pipe.lo \ + etnaviv_cmd_stream.lo am_libdrm_etnaviv_la_OBJECTS = $(am__objects_1) libdrm_etnaviv_la_OBJECTS = $(am_libdrm_etnaviv_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) @@ -316,6 +317,7 @@ LIBDRM_ETNAVIV_FILES := \ etnaviv_gpu.c \ etnaviv_bo.c \ etnaviv_bo_cache.c \ + etnaviv_perfmon.c \ etnaviv_pipe.c \ etnaviv_cmd_stream.c \ etnaviv_drm.h \ @@ -429,6 +431,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/etnaviv_cmd_stream.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/etnaviv_device.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/etnaviv_gpu.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/etnaviv_perfmon.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/etnaviv_pipe.Plo@am__quote@ .c.o: diff --git a/lib/libdrm/include/drm/drm.h b/lib/libdrm/include/drm/drm.h index bf3674ae8..f0bd91de0 100644 --- a/lib/libdrm/include/drm/drm.h +++ b/lib/libdrm/include/drm/drm.h @@ -694,6 +694,7 @@ struct drm_prime_handle { struct drm_syncobj_create { __u32 handle; +#define DRM_SYNCOBJ_CREATE_SIGNALED (1 << 0) __u32 flags; }; @@ -712,6 +713,46 @@ struct drm_syncobj_handle { __u32 pad; }; +#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL (1 << 0) +#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT (1 << 1) +struct drm_syncobj_wait { + __u64 handles; + /* absolute timeout */ + __s64 timeout_nsec; + __u32 count_handles; + __u32 flags; + __u32 first_signaled; /* only valid when not waiting all */ + __u32 pad; +}; + +struct drm_syncobj_array { + __u64 handles; + __u32 count_handles; + __u32 pad; +}; + +/* Query current scanout sequence number */ +struct drm_crtc_get_sequence { + __u32 crtc_id; /* requested crtc_id */ + __u32 active; /* return: crtc output is active */ + __u64 sequence; /* return: most recent vblank sequence */ + __s64 sequence_ns; /* return: most recent time of first pixel out */ +}; + +/* Queue event to be delivered at specified sequence. Time stamp marks + * when the first pixel of the refresh cycle leaves the display engine + * for the display + */ +#define DRM_CRTC_SEQUENCE_RELATIVE 0x00000001 /* sequence is relative to current */ +#define DRM_CRTC_SEQUENCE_NEXT_ON_MISS 0x00000002 /* Use next sequence if we've missed */ + +struct drm_crtc_queue_sequence { + __u32 crtc_id; + __u32 flags; + __u64 sequence; /* on input, target sequence. on output, actual sequence */ + __u64 user_data; /* user data passed to event */ +}; + #if defined(__cplusplus) } #endif @@ -794,6 +835,9 @@ extern "C" { #define DRM_IOCTL_WAIT_VBLANK DRM_IOWR(0x3a, union drm_wait_vblank) +#define DRM_IOCTL_CRTC_GET_SEQUENCE DRM_IOWR(0x3b, struct drm_crtc_get_sequence) +#define DRM_IOCTL_CRTC_QUEUE_SEQUENCE DRM_IOWR(0x3c, struct drm_crtc_queue_sequence) + #define DRM_IOCTL_UPDATE_DRAW DRM_IOW(0x3f, struct drm_update_draw) #define DRM_IOCTL_MODE_GETRESOURCES DRM_IOWR(0xA0, struct drm_mode_card_res) @@ -834,6 +878,14 @@ extern "C" { #define DRM_IOCTL_SYNCOBJ_DESTROY DRM_IOWR(0xC0, struct drm_syncobj_destroy) #define DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD DRM_IOWR(0xC1, struct drm_syncobj_handle) #define DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE DRM_IOWR(0xC2, struct drm_syncobj_handle) +#define DRM_IOCTL_SYNCOBJ_WAIT DRM_IOWR(0xC3, struct drm_syncobj_wait) +#define DRM_IOCTL_SYNCOBJ_RESET DRM_IOWR(0xC4, struct drm_syncobj_array) +#define DRM_IOCTL_SYNCOBJ_SIGNAL DRM_IOWR(0xC5, struct drm_syncobj_array) + +#define DRM_IOCTL_MODE_CREATE_LEASE DRM_IOWR(0xC6, struct drm_mode_create_lease) +#define DRM_IOCTL_MODE_LIST_LESSEES DRM_IOWR(0xC7, struct drm_mode_list_lessees) +#define DRM_IOCTL_MODE_GET_LEASE DRM_IOWR(0xC8, struct drm_mode_get_lease) +#define DRM_IOCTL_MODE_REVOKE_LEASE DRM_IOWR(0xC9, struct drm_mode_revoke_lease) /** * Device specific ioctls should only be in their respective headers @@ -865,6 +917,7 @@ struct drm_event { #define DRM_EVENT_VBLANK 0x01 #define DRM_EVENT_FLIP_COMPLETE 0x02 +#define DRM_EVENT_CRTC_SEQUENCE 0x03 struct drm_event_vblank { struct drm_event base; @@ -875,6 +928,16 @@ struct drm_event_vblank { __u32 crtc_id; /* 0 on older kernels that do not support this */ }; +/* Event delivered at sequence. Time stamp marks when the first pixel + * of the refresh cycle leaves the display engine for the display + */ +struct drm_event_crtc_sequence { + struct drm_event base; + __u64 user_data; + __s64 time_ns; + __u64 sequence; +}; + /* 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/intel/Makefile.am b/lib/libdrm/intel/Makefile.am index 15707ad42..c52e8c086 100644 --- a/lib/libdrm/intel/Makefile.am +++ b/lib/libdrm/intel/Makefile.am @@ -68,7 +68,6 @@ EXTRA_DIST = \ tests/test-batch.sh \ $(TESTS) -test_decode_LDADD = libdrm_intel.la ../libdrm.la \ - -lpthread +test_decode_LDADD = libdrm_intel.la ../libdrm.la pkgconfig_DATA = libdrm_intel.pc diff --git a/lib/libdrm/intel/Makefile.in b/lib/libdrm/intel/Makefile.in index cd4962bbb..c89c46865 100644 --- a/lib/libdrm/intel/Makefile.in +++ b/lib/libdrm/intel/Makefile.in @@ -396,9 +396,7 @@ EXTRA_DIST = \ tests/test-batch.sh \ $(TESTS) -test_decode_LDADD = libdrm_intel.la ../libdrm.la \ - -lpthread - +test_decode_LDADD = libdrm_intel.la ../libdrm.la pkgconfig_DATA = libdrm_intel.pc all: all-am diff --git a/lib/libdrm/intel/intel_chipset.h b/lib/libdrm/intel/intel_chipset.h index 3ff59adac..d81b16466 100644 --- a/lib/libdrm/intel/intel_chipset.h +++ b/lib/libdrm/intel/intel_chipset.h @@ -202,7 +202,7 @@ #define PCI_CHIP_KABYLAKE_ULX_GT1 0x590E #define PCI_CHIP_KABYLAKE_ULX_GT2 0x591E #define PCI_CHIP_KABYLAKE_DT_GT2 0x5912 -#define PCI_CHIP_KABYLAKE_DT_GT1_5 0x5917 +#define PCI_CHIP_KABYLAKE_M_GT2 0x5917 #define PCI_CHIP_KABYLAKE_DT_GT1 0x5902 #define PCI_CHIP_KABYLAKE_HALO_GT2 0x591B #define PCI_CHIP_KABYLAKE_HALO_GT4 0x593B @@ -434,7 +434,6 @@ #define IS_KBL_GT1(devid) ((devid) == PCI_CHIP_KABYLAKE_ULT_GT1_5 || \ (devid) == PCI_CHIP_KABYLAKE_ULX_GT1_5 || \ - (devid) == PCI_CHIP_KABYLAKE_DT_GT1_5 || \ (devid) == PCI_CHIP_KABYLAKE_ULT_GT1 || \ (devid) == PCI_CHIP_KABYLAKE_ULX_GT1 || \ (devid) == PCI_CHIP_KABYLAKE_DT_GT1 || \ @@ -446,6 +445,7 @@ (devid) == PCI_CHIP_KABYLAKE_ULT_GT2F || \ (devid) == PCI_CHIP_KABYLAKE_ULX_GT2 || \ (devid) == PCI_CHIP_KABYLAKE_DT_GT2 || \ + (devid) == PCI_CHIP_KABYLAKE_M_GT2 || \ (devid) == PCI_CHIP_KABYLAKE_HALO_GT2 || \ (devid) == PCI_CHIP_KABYLAKE_SRV_GT2 || \ (devid) == PCI_CHIP_KABYLAKE_WKS_GT2) diff --git a/lib/libdrm/radeon/radeon_surface.c b/lib/libdrm/radeon/radeon_surface.c index 965be24ca..04df77d63 100644 --- a/lib/libdrm/radeon/radeon_surface.c +++ b/lib/libdrm/radeon/radeon_surface.c @@ -2503,6 +2503,7 @@ static int radeon_surface_sanity(struct radeon_surface_manager *surf_man, if (surf->npix_y > 1) { return -EINVAL; } + /* fallthrough */ case RADEON_SURF_TYPE_2D: if (surf->npix_z > 1) { return -EINVAL; diff --git a/lib/libdrm/tests/amdgpu/Makefile.in b/lib/libdrm/tests/amdgpu/Makefile.in index 6f73d7bfb..a97dae301 100644 --- a/lib/libdrm/tests/amdgpu/Makefile.in +++ b/lib/libdrm/tests/amdgpu/Makefile.in @@ -72,7 +72,10 @@ am_amdgpu_test_OBJECTS = amdgpu_test-amdgpu_test.$(OBJEXT) \ amdgpu_test-basic_tests.$(OBJEXT) \ amdgpu_test-bo_tests.$(OBJEXT) amdgpu_test-cs_tests.$(OBJEXT) \ amdgpu_test-vce_tests.$(OBJEXT) \ - amdgpu_test-vcn_tests.$(OBJEXT) + amdgpu_test-uvd_enc_tests.$(OBJEXT) \ + amdgpu_test-vcn_tests.$(OBJEXT) \ + amdgpu_test-deadlock_tests.$(OBJEXT) \ + amdgpu_test-vm_tests.$(OBJEXT) amdgpu_test_OBJECTS = $(am_amdgpu_test_OBJECTS) amdgpu_test_LDADD = $(LDADD) am__DEPENDENCIES_1 = @@ -279,7 +282,8 @@ top_srcdir = @top_srcdir@ AM_CFLAGS = \ -I $(top_srcdir)/include/drm \ -I $(top_srcdir)/amdgpu \ - -I $(top_srcdir) + -I $(top_srcdir) \ + -pthread LDADD = $(top_builddir)/libdrm.la \ $(top_builddir)/amdgpu/libdrm_amdgpu.la \ @@ -296,7 +300,11 @@ amdgpu_test_SOURCES = \ vce_tests.c \ vce_ib.h \ frame.h \ - vcn_tests.c + uvd_enc_tests.c \ + vcn_tests.c \ + uve_ib.h \ + deadlock_tests.c \ + vm_tests.c all: all-am @@ -401,8 +409,11 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amdgpu_test-basic_tests.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amdgpu_test-bo_tests.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amdgpu_test-cs_tests.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amdgpu_test-deadlock_tests.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amdgpu_test-uvd_enc_tests.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amdgpu_test-vce_tests.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amdgpu_test-vcn_tests.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amdgpu_test-vm_tests.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -495,6 +506,20 @@ amdgpu_test-vce_tests.obj: vce_tests.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(amdgpu_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o amdgpu_test-vce_tests.obj `if test -f 'vce_tests.c'; then $(CYGPATH_W) 'vce_tests.c'; else $(CYGPATH_W) '$(srcdir)/vce_tests.c'; fi` +amdgpu_test-uvd_enc_tests.o: uvd_enc_tests.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(amdgpu_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT amdgpu_test-uvd_enc_tests.o -MD -MP -MF $(DEPDIR)/amdgpu_test-uvd_enc_tests.Tpo -c -o amdgpu_test-uvd_enc_tests.o `test -f 'uvd_enc_tests.c' || echo '$(srcdir)/'`uvd_enc_tests.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/amdgpu_test-uvd_enc_tests.Tpo $(DEPDIR)/amdgpu_test-uvd_enc_tests.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='uvd_enc_tests.c' object='amdgpu_test-uvd_enc_tests.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(amdgpu_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o amdgpu_test-uvd_enc_tests.o `test -f 'uvd_enc_tests.c' || echo '$(srcdir)/'`uvd_enc_tests.c + +amdgpu_test-uvd_enc_tests.obj: uvd_enc_tests.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(amdgpu_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT amdgpu_test-uvd_enc_tests.obj -MD -MP -MF $(DEPDIR)/amdgpu_test-uvd_enc_tests.Tpo -c -o amdgpu_test-uvd_enc_tests.obj `if test -f 'uvd_enc_tests.c'; then $(CYGPATH_W) 'uvd_enc_tests.c'; else $(CYGPATH_W) '$(srcdir)/uvd_enc_tests.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/amdgpu_test-uvd_enc_tests.Tpo $(DEPDIR)/amdgpu_test-uvd_enc_tests.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='uvd_enc_tests.c' object='amdgpu_test-uvd_enc_tests.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(amdgpu_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o amdgpu_test-uvd_enc_tests.obj `if test -f 'uvd_enc_tests.c'; then $(CYGPATH_W) 'uvd_enc_tests.c'; else $(CYGPATH_W) '$(srcdir)/uvd_enc_tests.c'; fi` + amdgpu_test-vcn_tests.o: vcn_tests.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(amdgpu_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT amdgpu_test-vcn_tests.o -MD -MP -MF $(DEPDIR)/amdgpu_test-vcn_tests.Tpo -c -o amdgpu_test-vcn_tests.o `test -f 'vcn_tests.c' || echo '$(srcdir)/'`vcn_tests.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/amdgpu_test-vcn_tests.Tpo $(DEPDIR)/amdgpu_test-vcn_tests.Po @@ -509,6 +534,34 @@ amdgpu_test-vcn_tests.obj: vcn_tests.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(amdgpu_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o amdgpu_test-vcn_tests.obj `if test -f 'vcn_tests.c'; then $(CYGPATH_W) 'vcn_tests.c'; else $(CYGPATH_W) '$(srcdir)/vcn_tests.c'; fi` +amdgpu_test-deadlock_tests.o: deadlock_tests.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(amdgpu_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT amdgpu_test-deadlock_tests.o -MD -MP -MF $(DEPDIR)/amdgpu_test-deadlock_tests.Tpo -c -o amdgpu_test-deadlock_tests.o `test -f 'deadlock_tests.c' || echo '$(srcdir)/'`deadlock_tests.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/amdgpu_test-deadlock_tests.Tpo $(DEPDIR)/amdgpu_test-deadlock_tests.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='deadlock_tests.c' object='amdgpu_test-deadlock_tests.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(amdgpu_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o amdgpu_test-deadlock_tests.o `test -f 'deadlock_tests.c' || echo '$(srcdir)/'`deadlock_tests.c + +amdgpu_test-deadlock_tests.obj: deadlock_tests.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(amdgpu_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT amdgpu_test-deadlock_tests.obj -MD -MP -MF $(DEPDIR)/amdgpu_test-deadlock_tests.Tpo -c -o amdgpu_test-deadlock_tests.obj `if test -f 'deadlock_tests.c'; then $(CYGPATH_W) 'deadlock_tests.c'; else $(CYGPATH_W) '$(srcdir)/deadlock_tests.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/amdgpu_test-deadlock_tests.Tpo $(DEPDIR)/amdgpu_test-deadlock_tests.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='deadlock_tests.c' object='amdgpu_test-deadlock_tests.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(amdgpu_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o amdgpu_test-deadlock_tests.obj `if test -f 'deadlock_tests.c'; then $(CYGPATH_W) 'deadlock_tests.c'; else $(CYGPATH_W) '$(srcdir)/deadlock_tests.c'; fi` + +amdgpu_test-vm_tests.o: vm_tests.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(amdgpu_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT amdgpu_test-vm_tests.o -MD -MP -MF $(DEPDIR)/amdgpu_test-vm_tests.Tpo -c -o amdgpu_test-vm_tests.o `test -f 'vm_tests.c' || echo '$(srcdir)/'`vm_tests.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/amdgpu_test-vm_tests.Tpo $(DEPDIR)/amdgpu_test-vm_tests.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='vm_tests.c' object='amdgpu_test-vm_tests.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(amdgpu_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o amdgpu_test-vm_tests.o `test -f 'vm_tests.c' || echo '$(srcdir)/'`vm_tests.c + +amdgpu_test-vm_tests.obj: vm_tests.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(amdgpu_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT amdgpu_test-vm_tests.obj -MD -MP -MF $(DEPDIR)/amdgpu_test-vm_tests.Tpo -c -o amdgpu_test-vm_tests.obj `if test -f 'vm_tests.c'; then $(CYGPATH_W) 'vm_tests.c'; else $(CYGPATH_W) '$(srcdir)/vm_tests.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/amdgpu_test-vm_tests.Tpo $(DEPDIR)/amdgpu_test-vm_tests.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='vm_tests.c' object='amdgpu_test-vm_tests.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(amdgpu_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o amdgpu_test-vm_tests.obj `if test -f 'vm_tests.c'; then $(CYGPATH_W) 'vm_tests.c'; else $(CYGPATH_W) '$(srcdir)/vm_tests.c'; fi` + mostlyclean-libtool: -rm -f *.lo diff --git a/lib/libdrm/xf86drm.c b/lib/libdrm/xf86drm.c index b1aa16cca..f9d83d2af 100644 --- a/lib/libdrm/xf86drm.c +++ b/lib/libdrm/xf86drm.c @@ -1720,6 +1720,43 @@ int drmUpdateDrawableInfo(int fd, drm_drawable_t handle, return 0; } +int drmCrtcGetSequence(int fd, uint32_t crtcId, uint64_t *sequence, uint64_t *ns) +{ + struct drm_crtc_get_sequence get_seq; + int ret; + + memclear(get_seq); + get_seq.crtc_id = crtcId; + ret = drmIoctl(fd, DRM_IOCTL_CRTC_GET_SEQUENCE, &get_seq); + if (ret) + return ret; + + if (sequence) + *sequence = get_seq.sequence; + if (ns) + *ns = get_seq.sequence_ns; + return 0; +} + +int drmCrtcQueueSequence(int fd, uint32_t crtcId, uint32_t flags, uint64_t sequence, + uint64_t *sequence_queued, uint64_t user_data) +{ + struct drm_crtc_queue_sequence queue_seq; + int ret; + + memclear(queue_seq); + queue_seq.crtc_id = crtcId; + queue_seq.flags = flags; + queue_seq.sequence = sequence; + queue_seq.user_data = user_data; + + ret = drmIoctl(fd, DRM_IOCTL_CRTC_QUEUE_SEQUENCE, &queue_seq); + if (ret == 0 && sequence_queued) + *sequence_queued = queue_seq.sequence; + + return ret; +} + /** * Acquire the AGP device. * @@ -4014,7 +4051,7 @@ int drmGetDevices2(uint32_t flags, drmDevicePtr devices[], int max_devices) ret = drmProcessUsbDevice(&device, node, node_type, maj, min, devices != NULL, flags); if (ret) - goto free_devices; + continue; break; @@ -4022,7 +4059,7 @@ int drmGetDevices2(uint32_t flags, drmDevicePtr devices[], int max_devices) ret = drmProcessPlatformDevice(&device, node, node_type, maj, min, devices != NULL, flags); if (ret) - goto free_devices; + continue; break; @@ -4030,7 +4067,7 @@ int drmGetDevices2(uint32_t flags, drmDevicePtr devices[], int max_devices) ret = drmProcessHost1xDevice(&device, node, node_type, maj, min, devices != NULL, flags); if (ret) - goto free_devices; + continue; break; @@ -4180,7 +4217,7 @@ int drmSyncobjCreate(int fd, uint32_t flags, uint32_t *handle) args.handle = 0; ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_CREATE, &args); if (ret) - return ret; + return ret; *handle = args.handle; return 0; } @@ -4204,7 +4241,7 @@ int drmSyncobjHandleToFD(int fd, uint32_t handle, int *obj_fd) args.handle = handle; ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &args); if (ret) - return ret; + return ret; *obj_fd = args.fd; return 0; } @@ -4219,7 +4256,7 @@ int drmSyncobjFDToHandle(int fd, int obj_fd, uint32_t *handle) args.handle = 0; ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &args); if (ret) - return ret; + return ret; *handle = args.handle; return 0; } @@ -4246,7 +4283,55 @@ int drmSyncobjExportSyncFile(int fd, uint32_t handle, int *sync_file_fd) args.flags = DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE; ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &args); if (ret) - return ret; + return ret; *sync_file_fd = args.fd; return 0; } + +int drmSyncobjWait(int fd, uint32_t *handles, unsigned num_handles, + int64_t timeout_nsec, unsigned flags, + uint32_t *first_signaled) +{ + struct drm_syncobj_wait args; + int ret; + + memclear(args); + args.handles = (intptr_t)handles; + args.timeout_nsec = timeout_nsec; + args.count_handles = num_handles; + args.flags = flags; + + ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_WAIT, &args); + if (ret < 0) + return ret; + + if (first_signaled) + *first_signaled = args.first_signaled; + return ret; +} + +int drmSyncobjReset(int fd, const uint32_t *handles, uint32_t handle_count) +{ + struct drm_syncobj_array args; + int ret; + + memclear(args); + args.handles = (uintptr_t)handles; + args.count_handles = handle_count; + + ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_RESET, &args); + return ret; +} + +int drmSyncobjSignal(int fd, const uint32_t *handles, uint32_t handle_count) +{ + struct drm_syncobj_array args; + int ret; + + memclear(args); + args.handles = (uintptr_t)handles; + args.count_handles = handle_count; + + ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_SIGNAL, &args); + return ret; +} diff --git a/lib/libdrm/xf86drm.h b/lib/libdrm/xf86drm.h index 2855a3ee0..7773d71a8 100644 --- a/lib/libdrm/xf86drm.h +++ b/lib/libdrm/xf86drm.h @@ -636,6 +636,12 @@ extern int drmCtlUninstHandler(int fd); extern int drmSetClientCap(int fd, uint64_t capability, uint64_t value); +extern int drmCrtcGetSequence(int fd, uint32_t crtcId, + uint64_t *sequence, uint64_t *ns); +extern int drmCrtcQueueSequence(int fd, uint32_t crtcId, + uint32_t flags, uint64_t sequence, + uint64_t *sequence_queued, + uint64_t user_data); /* General user-level programmer's API: authenticated client and/or X */ extern int drmMap(int fd, drm_handle_t handle, @@ -728,7 +734,7 @@ extern void drmMsg(const char *format, ...) DRM_PRINTFLIKE(1, 2); extern int drmSetMaster(int fd); extern int drmDropMaster(int fd); -#define DRM_EVENT_CONTEXT_VERSION 3 +#define DRM_EVENT_CONTEXT_VERSION 4 typedef struct _drmEventContext { @@ -755,6 +761,10 @@ typedef struct _drmEventContext { unsigned int crtc_id, void *user_data); + void (*sequence_handler)(int fd, + uint64_t sequence, + uint64_t ns, + uint64_t user_data); } drmEventContext, *drmEventContextPtr; extern int drmHandleEvent(int fd, drmEventContextPtr evctx); @@ -860,6 +870,11 @@ extern int drmSyncobjFDToHandle(int fd, int obj_fd, uint32_t *handle); extern int drmSyncobjImportSyncFile(int fd, uint32_t handle, int sync_file_fd); extern int drmSyncobjExportSyncFile(int fd, uint32_t handle, int *sync_file_fd); +extern int drmSyncobjWait(int fd, uint32_t *handles, unsigned num_handles, + int64_t timeout_nsec, unsigned flags, + uint32_t *first_signaled); +extern int drmSyncobjReset(int fd, const uint32_t *handles, uint32_t handle_count); +extern int drmSyncobjSignal(int fd, const uint32_t *handles, uint32_t handle_count); #if defined(__cplusplus) } diff --git a/lib/libdrm/xf86drmMode.c b/lib/libdrm/xf86drmMode.c index d3bc20ea4..15957ffcb 100644 --- a/lib/libdrm/xf86drmMode.c +++ b/lib/libdrm/xf86drmMode.c @@ -271,9 +271,9 @@ int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth, } 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) + uint32_t pixel_format, const uint32_t bo_handles[4], + const uint32_t pitches[4], const uint32_t offsets[4], + const uint64_t modifier[4], uint32_t *buf_id, uint32_t flags) { struct drm_mode_fb_cmd2 f; int ret; @@ -297,8 +297,8 @@ int drmModeAddFB2WithModifiers(int fd, uint32_t width, uint32_t height, } 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 pixel_format, const uint32_t bo_handles[4], + const uint32_t pitches[4], const uint32_t offsets[4], uint32_t *buf_id, uint32_t flags) { return drmModeAddFB2WithModifiers(fd, width, height, @@ -889,6 +889,7 @@ int drmHandleEvent(int fd, drmEventContextPtr evctx) int len, i; struct drm_event *e; struct drm_event_vblank *vblank; + struct drm_event_crtc_sequence *seq; void *user_data; /* The DRM read semantics guarantees that we always get only @@ -933,6 +934,14 @@ int drmHandleEvent(int fd, drmEventContextPtr evctx) vblank->tv_usec, user_data); break; + case DRM_EVENT_CRTC_SEQUENCE: + seq = (struct drm_event_crtc_sequence *) e; + if (evctx->version >= 4 && evctx->sequence_handler) + evctx->sequence_handler(fd, + seq->sequence, + seq->time_ns, + seq->user_data); + break; default: break; } @@ -1485,3 +1494,92 @@ drmModeDestroyPropertyBlob(int fd, uint32_t id) destroy.blob_id = id; return DRM_IOCTL(fd, DRM_IOCTL_MODE_DESTROYPROPBLOB, &destroy); } + +int +drmModeCreateLease(int fd, const uint32_t *objects, int num_objects, int flags, uint32_t *lessee_id) +{ + struct drm_mode_create_lease create; + int ret; + + memclear(create); + create.object_ids = (uintptr_t) objects; + create.object_count = num_objects; + create.flags = flags; + + ret = DRM_IOCTL(fd, DRM_IOCTL_MODE_CREATE_LEASE, &create); + if (ret == 0) { + *lessee_id = create.lessee_id; + return create.fd; + } + return -errno; +} + +drmModeLesseeListPtr +drmModeListLessees(int fd) +{ + struct drm_mode_list_lessees list; + uint32_t count; + drmModeLesseeListPtr ret; + + memclear(list); + + if (DRM_IOCTL(fd, DRM_IOCTL_MODE_LIST_LESSEES, &list)) + return NULL; + + count = list.count_lessees; + ret = drmMalloc(sizeof (drmModeLesseeListRes) + count * sizeof (ret->lessees[0])); + if (!ret) + return NULL; + + list.lessees_ptr = VOID2U64(&ret->lessees[0]); + if (DRM_IOCTL(fd, DRM_IOCTL_MODE_LIST_LESSEES, &list)) { + drmFree(ret); + return NULL; + } + + ret->count = count; + return ret; +} + +drmModeObjectListPtr +drmModeGetLease(int fd) +{ + struct drm_mode_get_lease get; + uint32_t count; + drmModeObjectListPtr ret; + + memclear(get); + + if (DRM_IOCTL(fd, DRM_IOCTL_MODE_GET_LEASE, &get)) + return NULL; + + count = get.count_objects; + ret = drmMalloc(sizeof (drmModeObjectListRes) + count * sizeof (ret->objects[0])); + if (!ret) + return NULL; + + get.objects_ptr = VOID2U64(&ret->objects[0]); + if (DRM_IOCTL(fd, DRM_IOCTL_MODE_GET_LEASE, &get)) { + drmFree(ret); + return NULL; + } + + ret->count = count; + return ret; +} + +int +drmModeRevokeLease(int fd, uint32_t lessee_id) +{ + struct drm_mode_revoke_lease revoke; + int ret; + + memclear(revoke); + + revoke.lessee_id = lessee_id; + + ret = DRM_IOCTL(fd, DRM_IOCTL_MODE_REVOKE_LEASE, &revoke); + if (ret == 0) + return 0; + return -errno; +} diff --git a/lib/libdrm/xf86drmMode.h b/lib/libdrm/xf86drmMode.h index 5b390d9fb..3cd27aee9 100644 --- a/lib/libdrm/xf86drmMode.h +++ b/lib/libdrm/xf86drmMode.h @@ -369,15 +369,16 @@ extern int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth, uint32_t *buf_id); /* ...with a specific pixel format */ 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 pixel_format, const uint32_t bo_handles[4], + const uint32_t pitches[4], const 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); + uint32_t pixel_format, const uint32_t bo_handles[4], + const uint32_t pitches[4], const uint32_t offsets[4], + const uint64_t modifier[4], uint32_t *buf_id, + uint32_t flags); /** * Destroies the given framebuffer. @@ -520,6 +521,28 @@ extern int drmModeCreatePropertyBlob(int fd, const void *data, size_t size, uint32_t *id); extern int drmModeDestroyPropertyBlob(int fd, uint32_t id); +/* + * DRM mode lease APIs. These create and manage new drm_masters with + * access to a subset of the available DRM resources + */ + +extern int drmModeCreateLease(int fd, const uint32_t *objects, int num_objects, int flags, uint32_t *lessee_id); + +typedef struct drmModeLesseeList { + uint32_t count; + uint32_t lessees[0]; +} drmModeLesseeListRes, *drmModeLesseeListPtr; + +extern drmModeLesseeListPtr drmModeListLessees(int fd); + +typedef struct drmModeObjectList { + uint32_t count; + uint32_t objects[0]; +} drmModeObjectListRes, *drmModeObjectListPtr; + +extern drmModeObjectListPtr drmModeGetLease(int fd); + +extern int drmModeRevokeLease(int fd, uint32_t lessee_id); #if defined(__cplusplus) }