pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
libdrm: updated to latest version for MesaLib major update
Module Name: pkgsrc-wip
Committed By: Tobias Nygren <tnn%NetBSD.org@localhost>
Pushed By: tnn
Date: Tue Jul 20 12:13:22 2021 +0200
Changeset: efa4fd5cfb839128ff4c5fefde1e20e689c4a769
Modified Files:
Makefile
Added Files:
libdrm/DESCR
libdrm/Makefile
libdrm/PLIST
libdrm/buildlink3.mk
libdrm/builtin.mk
libdrm/distinfo
libdrm/patches/patch-ac
libdrm/patches/patch-include_drm_drm.h
libdrm/patches/patch-libkms_vmwgfx.c
libdrm/patches/patch-libsync.h
libdrm/patches/patch-meson.build
libdrm/patches/patch-tests_nouveau_threaded.c
libdrm/patches/patch-xf86drm.c
libdrm/patches/patch-xf86drmMode.c
libdrm/patches/patch-xf86drmMode.h
Log Message:
libdrm: updated to latest version for MesaLib major update
XXX this swithes the build framework to meson
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=efa4fd5cfb839128ff4c5fefde1e20e689c4a769
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
Makefile | 1 +
libdrm/DESCR | 3 +
libdrm/Makefile | 102 +++++++++++++
libdrm/PLIST | 84 +++++++++++
libdrm/buildlink3.mk | 13 ++
libdrm/builtin.mk | 11 ++
libdrm/distinfo | 15 ++
libdrm/patches/patch-ac | 40 +++++
libdrm/patches/patch-include_drm_drm.h | 18 +++
libdrm/patches/patch-libkms_vmwgfx.c | 17 +++
libdrm/patches/patch-libsync.h | 24 +++
libdrm/patches/patch-meson.build | 15 ++
libdrm/patches/patch-tests_nouveau_threaded.c | 13 ++
libdrm/patches/patch-xf86drm.c | 207 ++++++++++++++++++++++++++
libdrm/patches/patch-xf86drmMode.c | 110 ++++++++++++++
libdrm/patches/patch-xf86drmMode.h | 13 ++
16 files changed, 686 insertions(+)
diffs:
diff --git a/Makefile b/Makefile
index 643b1f21a6..091c06679c 100644
--- a/Makefile
+++ b/Makefile
@@ -2013,6 +2013,7 @@ SUBDIR+= libdisasm
SUBDIR+= libdivecomputer
SUBDIR+= libdjconsole
SUBDIR+= libdoozer
+SUBDIR+= libdrm
SUBDIR+= libdrm-dfbsd
SUBDIR+= libdrm-dfbsd-meson
SUBDIR+= libdxfrw
diff --git a/libdrm/DESCR b/libdrm/DESCR
new file mode 100644
index 0000000000..c8be56c6b4
--- /dev/null
+++ b/libdrm/DESCR
@@ -0,0 +1,3 @@
+This package provides a library which offers a userspace interface
+to kernel DRM (Direct Rendering Manager) services for access to
+graphics hardware.
diff --git a/libdrm/Makefile b/libdrm/Makefile
new file mode 100644
index 0000000000..f2859a5105
--- /dev/null
+++ b/libdrm/Makefile
@@ -0,0 +1,102 @@
+# $NetBSD: Makefile,v 1.96 2021/07/20 09:43:22 tnn Exp $
+
+DISTNAME= libdrm-2.4.107
+CATEGORIES= x11 graphics
+MASTER_SITES= https://dri.freedesktop.org/libdrm/
+EXTRACT_SUFX= .tar.xz
+
+MAINTAINER= joerg%NetBSD.org@localhost
+HOMEPAGE= https://dri.freedesktop.org/wiki/DRM
+COMMENT= Userspace interface to kernel DRM services
+LICENSE= mit
+
+# Platforms with kernel support for DRM
+ONLY_FOR_PLATFORM= NetBSD-*-* DragonFly-*-* FreeBSD-*-* OpenBSD-*-* \
+ Linux-*-* SunOS-*-*
+
+USE_PKGLOCALEDIR= yes
+USE_TOOLS+= gmake pkg-config
+USE_LIBTOOL= yes
+
+PKGCONFIG_OVERRIDE+= amdgpu/libdrm_amdgpu.pc.in
+PKGCONFIG_OVERRIDE+= etnaviv/libdrm_etnaviv.pc.in
+PKGCONFIG_OVERRIDE+= exynos/libdrm_exynos.pc.in
+PKGCONFIG_OVERRIDE+= freedreno/libdrm_freedreno.pc.in
+PKGCONFIG_OVERRIDE+= intel/libdrm_intel.pc.in
+PKGCONFIG_OVERRIDE+= libkms/libkms.pc.in
+PKGCONFIG_OVERRIDE+= nouveau/libdrm_nouveau.pc.in
+PKGCONFIG_OVERRIDE+= omap/libdrm_omap.pc.in
+PKGCONFIG_OVERRIDE+= radeon/libdrm_radeon.pc.in
+PKGCONFIG_OVERRIDE+= tegra/libdrm_tegra.pc.in
+PKGCONFIG_OVERRIDE+= vc4/libdrm_vc4.pc.in
+PKGCONFIG_OVERRIDE+= libdrm.pc.in
+
+.include "../../mk/bsd.prefs.mk"
+
+SUBST_CLASSES+= atomic
+SUBST_FILES.atomic= xf86drm.h
+SUBST_MESSAGE.atomic= Configuring atomic operations in xf86drm.h
+SUBST_STAGE.atomic= pre-configure
+SUBST_VARS.atomic= ATOMIC_OPS_CHECK
+
+ATOMIC_OPS_CHECK= 0
+.if exists(${CROSS_DESTDIR}/usr/include/sys/atomic.h)
+ATOMIC_OPS_CHECK= 1
+.else
+. include "../../devel/libatomic_ops/buildlink3.mk"
+.endif
+
+PLIST_VARS+= intel arm kms
+
+.if ${OPSYS} == "Linux" || ${OPSYS} == "FreeBSD" || ${OPSYS} == "DragonFly"
+MESON_ARGS+= -Dlibkms=true
+PLIST.kms= true
+.else
+MESON_ARGS+= -Dlibkms=false
+.endif
+
+PLIST_VARS+= intel arm kms
+.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64"
+MESON_ARGS+= -Dintel=true
+MESON_ARGS+= -Dvmwgfx=true
+.include "../../sysutils/libpciaccess/buildlink3.mk"
+PLIST.intel= yes
+.else
+MESON_ARGS+= -Dintel=false
+MESON_ARGS+= -Dvmwgfx=false
+.endif
+
+MESON_ARGS+= -Dradeon=true
+MESON_ARGS+= -Damdgpu=true
+MESON_ARGS+= -Dnouveau=true
+
+.if !empty(MACHINE_ARCH:Marm*) || \
+ !empty(MACHINE_ARCH:Mearm*) || \
+ ${MACHINE_ARCH} == "aarch64"
+MESON_ARGS+= -Dfreedreno=true
+MESON_ARGS+= -Dtegra=true
+MESON_ARGS+= -Dvc4=true
+PLIST.arm= yes
+.else
+MESON_ARGS+= -Dfreedreno=false
+MESON_ARGS+= -Dtegra=false
+MESON_ARGS+= -Dvc4=false
+.endif
+MESON_ARGS+= -Domap=false
+MESON_ARGS+= -Dexynos=false
+MESON_ARGS+= -Detnaviv=false
+
+MESON_ARGS+= -Dman-pages=false
+MESON_ARGS+= -Dvalgrind=false
+
+#CONFIGURE_ARGS+= PTHREADSTUBS_CFLAGS=-I${PREFIX}/include \
+# PTHREADSTUBS_LIBS=-L${PREFIX}/lib
+
+LDFLAGS.NetBSD+= -lpci
+
+.if ${OPSYS} == "FreeBSD" || ${OPSYS} == "DragonFly" || ${OPSYS} == "Linux"
+PLIST.kms= yes
+.endif
+
+.include "../../devel/meson/build.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/libdrm/PLIST b/libdrm/PLIST
new file mode 100644
index 0000000000..7e3d7bb672
--- /dev/null
+++ b/libdrm/PLIST
@@ -0,0 +1,84 @@
+@comment $NetBSD$
+${PLIST.arm}include/freedreno/freedreno_drmif.h
+${PLIST.arm}include/freedreno/freedreno_ringbuffer.h
+include/libdrm/amdgpu.h
+include/libdrm/amdgpu_drm.h
+include/libdrm/drm.h
+include/libdrm/drm_fourcc.h
+include/libdrm/drm_mode.h
+include/libdrm/drm_sarea.h
+include/libdrm/i915_drm.h
+${PLIST.intel}include/libdrm/intel_aub.h
+${PLIST.intel}include/libdrm/intel_bufmgr.h
+${PLIST.intel}include/libdrm/intel_debug.h
+include/libdrm/mach64_drm.h
+include/libdrm/mga_drm.h
+include/libdrm/msm_drm.h
+include/libdrm/nouveau/nouveau.h
+include/libdrm/nouveau/nvif/cl0080.h
+include/libdrm/nouveau/nvif/cl9097.h
+include/libdrm/nouveau/nvif/class.h
+include/libdrm/nouveau/nvif/if0002.h
+include/libdrm/nouveau/nvif/if0003.h
+include/libdrm/nouveau/nvif/ioctl.h
+include/libdrm/nouveau/nvif/unpack.h
+include/libdrm/nouveau_drm.h
+include/libdrm/qxl_drm.h
+include/libdrm/r128_drm.h
+include/libdrm/r600_pci_ids.h
+include/libdrm/radeon_bo.h
+include/libdrm/radeon_bo_gem.h
+include/libdrm/radeon_bo_int.h
+include/libdrm/radeon_cs.h
+include/libdrm/radeon_cs_gem.h
+include/libdrm/radeon_cs_int.h
+include/libdrm/radeon_drm.h
+include/libdrm/radeon_surface.h
+include/libdrm/savage_drm.h
+include/libdrm/sis_drm.h
+${PLIST.arm}include/libdrm/tegra.h
+include/libdrm/tegra_drm.h
+include/libdrm/vc4_drm.h
+${PLIST.intel}include/libdrm/vmwgfx_drm.h
+${PLIST.arm}include/libdrm/vc4_packet.h
+${PLIST.arm}include/libdrm/vc4_qpu_defines.h
+include/libdrm/via_drm.h
+include/libdrm/virtgpu_drm.h
+${PLIST.kms}include/libkms/libkms.h
+include/libsync.h
+include/xf86drm.h
+include/xf86drmMode.h
+lib/libdrm.so
+lib/libdrm.so.2
+lib/libdrm.so.2.4.0
+lib/libdrm_amdgpu.so
+lib/libdrm_amdgpu.so.1
+lib/libdrm_amdgpu.so.1.0.0
+${PLIST.arm}lib/libdrm_freedreno.so
+${PLIST.arm}lib/libdrm_freedreno.so.1
+${PLIST.arm}lib/libdrm_freedreno.so.1.0.0
+${PLIST.intel}lib/libdrm_intel.so
+${PLIST.intel}lib/libdrm_intel.so.1
+${PLIST.intel}lib/libdrm_intel.so.1.0.0
+lib/libdrm_nouveau.so
+lib/libdrm_nouveau.so.2
+lib/libdrm_nouveau.so.2.0.0
+lib/libdrm_radeon.so
+lib/libdrm_radeon.so.1
+lib/libdrm_radeon.so.1.0.1
+${PLIST.arm}lib/libdrm_tegra.so
+${PLIST.arm}lib/libdrm_tegra.so.0
+${PLIST.arm}lib/libdrm_tegra.so.0.0.0
+lib/libkms.so
+lib/libkms.so.1
+lib/libkms.so.1.0.0
+lib/pkgconfig/libdrm.pc
+lib/pkgconfig/libdrm_amdgpu.pc
+${PLIST.arm}lib/pkgconfig/libdrm_freedreno.pc
+${PLIST.intel}lib/pkgconfig/libdrm_intel.pc
+lib/pkgconfig/libdrm_nouveau.pc
+lib/pkgconfig/libdrm_radeon.pc
+${PLIST.kms}lib/pkgconfig/libkms.pc
+${PLIST.arm}lib/pkgconfig/libdrm_tegra.pc
+${PLIST.arm}lib/pkgconfig/libdrm_vc4.pc
+share/libdrm/amdgpu.ids
diff --git a/libdrm/buildlink3.mk b/libdrm/buildlink3.mk
new file mode 100644
index 0000000000..1a1f3f203c
--- /dev/null
+++ b/libdrm/buildlink3.mk
@@ -0,0 +1,13 @@
+# $NetBSD: buildlink3.mk,v 1.7 2013/05/16 05:43:14 richard Exp $
+
+BUILDLINK_TREE+= libdrm
+
+.if !defined(LIBDRM_BUILDLINK3_MK)
+LIBDRM_BUILDLINK3_MK:=
+
+BUILDLINK_API_DEPENDS.libdrm+= libdrm>=2.4.15
+BUILDLINK_PKGSRCDIR.libdrm?= ../../x11/libdrm
+BUILDLINK_INCDIRS.libdrm?= include/libdrm
+.endif # LIBDRM_BUILDLINK3_MK
+
+BUILDLINK_TREE+= -libdrm
diff --git a/libdrm/builtin.mk b/libdrm/builtin.mk
new file mode 100644
index 0000000000..797e72a549
--- /dev/null
+++ b/libdrm/builtin.mk
@@ -0,0 +1,11 @@
+# $NetBSD: builtin.mk,v 1.5 2019/10/18 09:04:16 nia Exp $
+
+BUILTIN_PKG:= libdrm
+
+.for pcfile in libdrm libdrm_amdgpu libdrm_intel libdrm_nouveau libdrm_radeon
+PKGCONFIG_FILE.libdrm+= ${X11BASE}/lib/pkgconfig/${pcfile}.pc
+PKGCONFIG_FILE.libdrm+= ${X11BASE}/lib${LIBABISUFFIX}/pkgconfig/${pcfile}.pc
+.endfor
+
+.include "../../mk/buildlink3/pkgconfig-builtin.mk"
+.include "../../mk/x11.builtin.mk"
diff --git a/libdrm/distinfo b/libdrm/distinfo
new file mode 100644
index 0000000000..592efe642a
--- /dev/null
+++ b/libdrm/distinfo
@@ -0,0 +1,15 @@
+$NetBSD: distinfo,v 1.97 2020/04/12 19:41:21 joerg Exp $
+
+SHA1 (libdrm-2.4.107.tar.xz) = 372eb85849d1858a892dc5569edfa278640a9732
+RMD160 (libdrm-2.4.107.tar.xz) = bd639d34024bfc203123a87b4513e1b45202e237
+SHA512 (libdrm-2.4.107.tar.xz) = c7542ba15c4c934519a6a1f3cb1ec21effa820a805a030d0175313bb1cc796cd311f39596ead883f9f251679d701e262894c5a297d5cf45093c80a6cd818def0
+Size (libdrm-2.4.107.tar.xz) = 425612 bytes
+SHA1 (patch-ac) = 67c998df7dfc0dabc86320ea6d015cede3e464ea
+SHA1 (patch-include_drm_drm.h) = 48a912f40bf2b2a1c23edbe4446fa7869212f17b
+SHA1 (patch-libkms_vmwgfx.c) = d2204c0b79098c6c36b7f282b486c58c6354bd1d
+SHA1 (patch-libsync.h) = 1e0603e72a54a069fc9d2ab2c9559d22381a69d3
+SHA1 (patch-meson.build) = b9ebb763a807da931f83f4d5c02925ab5498ef69
+SHA1 (patch-tests_nouveau_threaded.c) = 82b566666e77898c209d66ce804c913b53e53a50
+SHA1 (patch-xf86drm.c) = 6e4b3ee406666b37cc0b923ad49b945055919c83
+SHA1 (patch-xf86drmMode.c) = 078b1ecaa4fedd74992d682433701245ee51785b
+SHA1 (patch-xf86drmMode.h) = a28b02887389be8670193c119f711901af61a6b2
diff --git a/libdrm/patches/patch-ac b/libdrm/patches/patch-ac
new file mode 100644
index 0000000000..2b11b37832
--- /dev/null
+++ b/libdrm/patches/patch-ac
@@ -0,0 +1,40 @@
+$NetBSD: patch-ac,v 1.4 2012/02/16 20:30:56 hans Exp $
+
+--- xf86drm.h.orig 2010-03-05 23:21:13.000000000 +0000
++++ xf86drm.h
+@@ -35,7 +35,11 @@
+ #define _XF86DRM_H_
+
+ #include <stdarg.h>
++#if @ATOMIC_OPS_CHECK@
++#include <sys/atomic.h>
++#else
+ #include <sys/types.h>
++#endif
+ #include <stdint.h>
+ #include <drm.h>
+
+@@ -55,6 +59,9 @@
+ #else /* One of the *BSDs */
+
+ #include <sys/ioccom.h>
++#ifdef __sun
++#define _IOC(d, x, y, t) ((int)((uint32_t)(d | (((sizeof (t)) & IOCPARM_MASK)<<16) | (x<<8) | y)))
++#endif
+ #define DRM_IOCTL_NR(n) ((n) & 0xff)
+ #define DRM_IOC_VOID IOC_VOID
+ #define DRM_IOC_READ IOC_OUT
+@@ -333,7 +340,12 @@ typedef struct _drmSetVersion {
+ #define DRM_LOCK_HELD 0x80000000U /**< Hardware lock is held */
+ #define DRM_LOCK_CONT 0x40000000U /**< Hardware lock is contended */
+
+-#if defined(__GNUC__) && (__GNUC__ >= 2)
++#if @ATOMIC_OPS_CHECK@ /* configured by pkgsrc */
++
++#define DRM_CAS(lock, old, new, __ret) \
++ (__ret = atomic_cas_uint(&__drm_dummy_lock(lock), (old), (new)) != (old));
++
++#elif defined(__GNUC__) && (__GNUC__ >= 2)
+ # if defined(__i386) || defined(__AMD64__) || defined(__x86_64__) || defined(__amd64__)
+ /* Reflect changes here to drmP.h */
+ #define DRM_CAS(lock,old,new,__ret) \
diff --git a/libdrm/patches/patch-include_drm_drm.h b/libdrm/patches/patch-include_drm_drm.h
new file mode 100644
index 0000000000..adff81aaef
--- /dev/null
+++ b/libdrm/patches/patch-include_drm_drm.h
@@ -0,0 +1,18 @@
+$NetBSD: patch-include_drm_drm.h,v 1.4 2016/04/29 11:17:34 wiz Exp $
+
+Fix compilation on systems that don't provide O_CLOEXEC.
+
+--- include/drm/drm.h.orig 2016-04-28 00:44:16.000000000 +0000
++++ include/drm/drm.h
+@@ -674,7 +674,11 @@ struct drm_set_client_cap {
+ };
+
+ #define DRM_RDWR O_RDWR
++#ifdef O_CLOEXEC
+ #define DRM_CLOEXEC O_CLOEXEC
++#else
++#define DRM_CLOEXEC 0
++#endif
+ struct drm_prime_handle {
+ __u32 handle;
+
diff --git a/libdrm/patches/patch-libkms_vmwgfx.c b/libdrm/patches/patch-libkms_vmwgfx.c
new file mode 100644
index 0000000000..bedfefa615
--- /dev/null
+++ b/libdrm/patches/patch-libkms_vmwgfx.c
@@ -0,0 +1,17 @@
+$NetBSD: patch-libkms_vmwgfx.c,v 1.3 2015/05/07 06:31:06 wiz Exp $
+
+Provide compatibility errno number for non-Linux.
+
+--- libkms/vmwgfx.c.orig 2015-05-06 23:04:31.000000000 +0000
++++ libkms/vmwgfx.c
+@@ -39,6 +39,10 @@
+ #include "libdrm_macros.h"
+ #include "vmwgfx_drm.h"
+
++#ifndef ERESTART
++#define ERESTART 85
++#endif
++
+ struct vmwgfx_bo
+ {
+ struct kms_bo base;
diff --git a/libdrm/patches/patch-libsync.h b/libdrm/patches/patch-libsync.h
new file mode 100644
index 0000000000..41909f92a1
--- /dev/null
+++ b/libdrm/patches/patch-libsync.h
@@ -0,0 +1,24 @@
+$NetBSD: patch-libsync.h,v 1.3 2019/01/22 21:50:47 wiz Exp $
+
+Fix public header on SunOS.
+If ETIME is not defined, use ETIMEDOUT.
+
+--- libsync.h.orig 2019-01-22 16:32:41.000000000 +0000
++++ libsync.h
+@@ -33,9 +33,16 @@
+ #include <stdint.h>
+ #include <string.h>
+ #include <sys/ioctl.h>
++#ifdef __sun
++#include <sys/filio.h>
++#endif
+ #include <sys/poll.h>
+ #include <unistd.h>
+
++#ifndef ETIME
++#define ETIME ETIMEDOUT
++#endif
++
+ #if defined(__cplusplus)
+ extern "C" {
+ #endif
diff --git a/libdrm/patches/patch-meson.build b/libdrm/patches/patch-meson.build
new file mode 100644
index 0000000000..56034eec91
--- /dev/null
+++ b/libdrm/patches/patch-meson.build
@@ -0,0 +1,15 @@
+$NetBSD$
+
+xxx how to deal with this properly?
+
+--- meson.build.orig 2021-07-02 12:49:05.442438400 +0000
++++ meson.build
+@@ -35,7 +35,7 @@ config.set10('UDEV', get_option('udev'))
+ with_freedreno_kgsl = get_option('freedreno-kgsl')
+ with_install_tests = get_option('install-test-programs')
+
+-if ['freebsd', 'dragonfly', 'netbsd'].contains(host_machine.system())
++if ['freebsd', 'dragonfly'].contains(host_machine.system())
+ dep_pthread_stubs = dependency('pthread-stubs', version : '>= 0.4')
+ else
+ dep_pthread_stubs = []
diff --git a/libdrm/patches/patch-tests_nouveau_threaded.c b/libdrm/patches/patch-tests_nouveau_threaded.c
new file mode 100644
index 0000000000..e83bddc60e
--- /dev/null
+++ b/libdrm/patches/patch-tests_nouveau_threaded.c
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- tests/nouveau/threaded.c.orig 2021-07-02 12:49:05.455772000 +0000
++++ tests/nouveau/threaded.c
+@@ -36,7 +36,7 @@ static int failed;
+
+ static int import_fd;
+
+-#if defined(__GLIBC__) || defined(__FreeBSD__)
++#if defined(__GLIBC__) || defined(__FreeBSD__) || defined(__NetBSD__)
+ int ioctl(int fd, unsigned long request, ...)
+ #else
+ int ioctl(int fd, int request, ...)
diff --git a/libdrm/patches/patch-xf86drm.c b/libdrm/patches/patch-xf86drm.c
new file mode 100644
index 0000000000..3af2a32925
--- /dev/null
+++ b/libdrm/patches/patch-xf86drm.c
@@ -0,0 +1,207 @@
+$NetBSD$
+
+Implement drmParseSubsystemType, drmParsePciBusInfo for NetBSD
+
+--- xf86drm.c.orig 2021-07-02 12:49:05.459105300 +0000
++++ xf86drm.c
+@@ -86,7 +86,10 @@
+ #endif
+
+ #ifdef __NetBSD__
+-#define DRM_MAJOR 34
++#define DRM_MAJOR 180
++#include <sys/param.h>
++#include <dev/pci/pcireg.h>
++#include <pci.h>
+ #endif
+
+ #ifdef __OpenBSD__
+@@ -3499,6 +3502,65 @@ static int drmParseSubsystemType(int maj
+ return DRM_BUS_VIRTIO;
+ }
+ return subsystem_type;
++#elif defined(__NetBSD__)
++ int type, fd;
++ drmSetVersion sv;
++ char *buf;
++ unsigned domain, bus, dev;
++ int func;
++ int ret;
++
++ /* Get the type of device we're looking for to pick the right pathname. */
++ type = drmGetMinorType(maj, min);
++ if (type == -1)
++ return -ENODEV;
++
++ /* Open the device. Don't try to create it if it's not there. */
++ fd = drmOpenMinor(min, 0, type);
++ if (fd < 0)
++ return -errno;
++
++ /*
++ * Set the interface version to 1.4 or 1.1, which has the effect of
++ * populating the bus id for us.
++ */
++ sv.drm_di_major = 1;
++ sv.drm_di_minor = 4;
++ sv.drm_dd_major = -1;
++ sv.drm_dd_minor = -1;
++ if (drmSetInterfaceVersion(fd, &sv)) {
++ sv.drm_di_major = 1;
++ sv.drm_di_minor = 1;
++ sv.drm_dd_major = -1;
++ sv.drm_dd_minor = -1;
++ if (drmSetInterfaceVersion(fd, &sv)) {
++ /*
++ * We're probably not the master. Hope the master already
++ * set the version to >=1.1 so that we can get the busid.
++ */
++ }
++ }
++
++ /* Get the bus id. */
++ buf = drmGetBusid(fd);
++
++ /* We're done with the device now. */
++ (void)close(fd);
++
++ /* If there is no bus id, fail. */
++ if (buf == NULL)
++ return -ENODEV;
++
++ /* Find a string we know about; otherwise -EINVAL. */
++ ret = -EINVAL;
++ if (strncmp(buf, "pci:", 4) == 0)
++ ret = DRM_BUS_PCI;
++
++ /* We're done with the bus id. */
++ free(buf);
++
++ /* Success or not, we're done. */
++ return ret;
+ #elif defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD__)
+ return DRM_BUS_PCI;
+ #else
+@@ -3610,6 +3672,73 @@ static int drmParsePciBusInfo(int maj, i
+ info->func = func;
+
+ return 0;
++#elif defined(__NetBSD__)
++ int type, fd;
++ drmSetVersion sv;
++ char *buf;
++ unsigned domain, bus, dev;
++ int func;
++ int ret;
++
++ /* Get the type of device we're looking for to pick the right pathname. */
++ type = drmGetMinorType(maj, min);
++ if (type == -1)
++ return -ENODEV;
++
++ /* Open the device. Don't try to create it if it's not there. */
++ fd = drmOpenMinor(min, 0, type);
++ if (fd < 0)
++ return -errno;
++
++ /*
++ * Set the interface version to 1.4 or 1.1, which has the effect of
++ * populating the bus id for us.
++ */
++ sv.drm_di_major = 1;
++ sv.drm_di_minor = 4;
++ sv.drm_dd_major = -1;
++ sv.drm_dd_minor = -1;
++ if (drmSetInterfaceVersion(fd, &sv)) {
++ sv.drm_di_major = 1;
++ sv.drm_di_minor = 1;
++ sv.drm_dd_major = -1;
++ sv.drm_dd_minor = -1;
++ if (drmSetInterfaceVersion(fd, &sv)) {
++ /*
++ * We're probably not the master. Hope the master already
++ * set the version to >=1.1 so that we can get the busid.
++ */
++ }
++ }
++
++ /* Get the bus id. */
++ buf = drmGetBusid(fd);
++
++ /* We're done with the device now. */
++ (void)close(fd);
++
++ /* If there is no bus id, fail. */
++ if (buf == NULL)
++ return -ENODEV;
++
++ /* Parse the bus id. */
++ ret = sscanf(buf, "pci:%04x:%02x:%02x.%d", &domain, &bus, &dev, &func);
++
++ /* We're done with the bus id. */
++ free(buf);
++
++ /* If scanf didn't return 4 -- domain, bus, dev, func -- then fail. */
++ if (ret != 4)
++ return -ENODEV;
++
++ /* Populate the results. */
++ info->domain = domain;
++ info->bus = bus;
++ info->dev = dev;
++ info->func = func;
++
++ /* Success! */
++ return 0;
+ #elif defined(__OpenBSD__) || defined(__DragonFly__)
+ struct drm_pciinfo pinfo;
+ int fd, type;
+@@ -3778,6 +3907,48 @@ static int drmParsePciDeviceInfo(int maj
+ return parse_config_sysfs_file(maj, min, device);
+
+ return 0;
++#elif defined(__NetBSD__)
++ drmPciBusInfo businfo;
++ char fname[PATH_MAX];
++ int pcifd;
++ pcireg_t id, class, subsys;
++ int ret;
++
++ /* Find where on the bus the device lives. */
++ ret = drmParsePciBusInfo(maj, min, &businfo);
++ if (ret)
++ return ret;
++
++ /* Open the pciN device node to get at its config registers. */
++ if (snprintf(fname, sizeof fname, "/dev/pci%u", businfo.domain)
++ >= sizeof fname)
++ return -ENODEV;
++ if ((pcifd = open(fname, O_RDONLY)) == -1)
++ return -errno;
++
++ ret = -1;
++ /* Read the id and class pci config registers. */
++ if (pcibus_conf_read(pcifd, businfo.bus, businfo.dev, businfo.func,
++ PCI_ID_REG, &id) == -1)
++ goto out;
++ if (pcibus_conf_read(pcifd, businfo.bus, businfo.dev, businfo.func,
++ PCI_CLASS_REG, &class) == -1)
++ goto out;
++ if (pcibus_conf_read(pcifd, businfo.bus, businfo.dev, businfo.func,
++ PCI_SUBSYS_ID_REG, &subsys) == -1)
++ goto out;
++
++ ret = 0;
++ device->vendor_id = PCI_VENDOR(id);
++ device->device_id = PCI_PRODUCT(id);
++ device->subvendor_id = PCI_SUBSYS_VENDOR(subsys);
++ device->subdevice_id = PCI_SUBSYS_ID(subsys);
++ device->revision_id = PCI_REVISION(class);
++out:
++ if (ret == -1)
++ ret = -errno;
++ close(pcifd);
++ return ret;
+ #elif defined(__OpenBSD__) || defined(__DragonFly__)
+ struct drm_pciinfo pinfo;
+ int fd, type;
diff --git a/libdrm/patches/patch-xf86drmMode.c b/libdrm/patches/patch-xf86drmMode.c
new file mode 100644
index 0000000000..9ebafd3601
--- /dev/null
+++ b/libdrm/patches/patch-xf86drmMode.c
@@ -0,0 +1,110 @@
+$NetBSD$
+
+FreeBSD/DragonFly/NetBSD support. From FreeBSD ports and NetBSD xsrc
+
+--- xf86drmMode.c.orig 2021-07-02 12:49:05.459105300 +0000
++++ xf86drmMode.c
+@@ -38,9 +38,7 @@
+ #include <stdlib.h>
+ #include <sys/ioctl.h>
+ #if HAVE_SYS_SYSCTL_H
+-#ifdef __FreeBSD__
+ #include <sys/types.h>
+-#endif
+ #include <sys/sysctl.h>
+ #endif
+ #include <stdio.h>
+@@ -808,34 +806,59 @@ drm_public int drmCheckModesettingSuppor
+ closedir(sysdir);
+ if (found)
+ return 0;
+-#elif defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
+- char sbusid[1024];
+- char oid[128];
+- int i, modesetting, ret;
+- size_t len;
+-
+- /* How many GPUs do we expect in the machine ? */
+- for (i = 0; i < 10; i++) {
+- snprintf(oid, sizeof(oid), "hw.dri.%d.busid", i);
+- len = sizeof(sbusid);
+- ret = sysctlbyname(oid, sbusid, &len, NULL, 0);
+- if (ret == -1) {
+- if (errno == ENOENT)
++#elif defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined(__DragonFly__)
++ #define bus_fmt "pci:%04x:%02x:%02x.%u"
++ #define name_fmt "%*s %*s " bus_fmt
++ unsigned int d1 = 0, b1 = 0, s1 = 0, f1 = 0;
++ if (sscanf(busid, bus_fmt, &d1, &b1, &s1, &f1) != 4)
++ return -EINVAL;
++ /*
++ * hw.dri.%i.bus is not always present and hw.dri.%i.name does not
++ * always contain the busid, so try both for best chance of success
++ */
++ for (int i = 0; i < DRM_MAX_MINOR; ++i) {
++ char name[22], value[256];
++ size_t length = sizeof(value);
++ snprintf(name, sizeof(name), "hw.dri.%i.name", i);
++ if (sysctlbyname(name, value, &length, NULL, 0))
++ continue;
++
++ value[length] = '\0';
++ unsigned int d2 = 0, b2 = 0, s2 = 0, f2 = 0;
++ switch (sscanf(value, name_fmt, &d2, &b2, &s2, &f2)) {
++ case 0: /* busid not in the name, try busid */
++ length = sizeof(value);
++ snprintf(name, sizeof(name), "hw.dri.%i.busid", i);
++ if (sysctlbyname(name, value, &length, NULL, 0))
++ continue;
++ value[length] = '\0';
++ if (sscanf(value, bus_fmt, &d2, &b2, &s2, &f2) != 4)
+ continue;
+- return -EINVAL;
++ /* fall through after parsing busid */
++
++ case 4: /* if we jumped here then busid was in the name */
++ if (d1 == d2 && b1 == b2 && s1 == s2 && f1 == f2) {
++ /*
++ * Confirm the drm driver for this device supports KMS,
++ * except on DragonFly where all the drm drivers do so
++ * but only hw.dri.0.modesetting is present
++ */
++ #ifndef __DragonFly__
++ int modesetting = 0;
++ length = sizeof(modesetting);
++ snprintf(name, sizeof(name), "hw.dri.%i.modesetting", i);
++ if (sysctlbyname(name, &modesetting, &length, NULL, 0)
++ || length != sizeof(modesetting) || !modesetting)
++ return -ENOSYS;
++ else
++ #endif
++ return 0;
++ }
++ default:
++ break;
+ }
+- if (strcmp(sbusid, busid) != 0)
+- continue;
+- snprintf(oid, sizeof(oid), "hw.dri.%d.modesetting", i);
+- len = sizeof(modesetting);
+- ret = sysctlbyname(oid, &modesetting, &len, NULL, 0);
+- if (ret == -1 || len != sizeof(modesetting))
+- return -EINVAL;
+- return (modesetting ? 0 : -ENOSYS);
+ }
+-#elif defined(__DragonFly__)
+- return 0;
+-#elif defined(__OpenBSD__)
++#elif defined(__OpenBSD__) || defined(__NetBSD__)
+ int fd;
+ struct drm_mode_card_res res;
+ drmModeResPtr r = 0;
+@@ -988,7 +1011,7 @@ drm_public int drmModePageFlipTarget(int
+
+ drm_public int drmModeSetPlane(int fd, uint32_t plane_id, uint32_t crtc_id,
+ uint32_t fb_id, uint32_t flags,
+- int32_t crtc_x, int32_t crtc_y,
++ uint32_t crtc_x, uint32_t crtc_y,
+ uint32_t crtc_w, uint32_t crtc_h,
+ uint32_t src_x, uint32_t src_y,
+ uint32_t src_w, uint32_t src_h)
diff --git a/libdrm/patches/patch-xf86drmMode.h b/libdrm/patches/patch-xf86drmMode.h
new file mode 100644
index 0000000000..8a20d90dc2
--- /dev/null
+++ b/libdrm/patches/patch-xf86drmMode.h
@@ -0,0 +1,13 @@
+$NetBSD: patch-xf86drmMode.h,v 1.1 2014/10/26 10:20:10 wiz Exp $
+
+--- xf86drmMode.h.orig 2014-06-14 12:33:26.000000000 +0000
++++ xf86drmMode.h
+@@ -449,7 +449,7 @@ extern drmModePlaneResPtr drmModeGetPlan
+ extern drmModePlanePtr drmModeGetPlane(int fd, uint32_t plane_id);
+ extern int drmModeSetPlane(int fd, uint32_t plane_id, uint32_t crtc_id,
+ uint32_t fb_id, uint32_t flags,
+- int32_t crtc_x, int32_t crtc_y,
++ uint32_t crtc_x, uint32_t crtc_y,
+ uint32_t crtc_w, uint32_t crtc_h,
+ uint32_t src_x, uint32_t src_y,
+ uint32_t src_w, uint32_t src_h);
Home |
Main Index |
Thread Index |
Old Index