pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
libdrm-dfbsd: Update wip/libdrm-dfbsd to 2.4.97
Module Name: pkgsrc-wip
Committed By: David Shao <davshao%gmail.com@localhost>
Pushed By: dshao
Date: Sat Feb 23 20:37:49 2019 -0800
Changeset: 859aad7056a9c23db0645c4f21ec765bb6681730
Modified Files:
libdrm-dfbsd/Makefile
libdrm-dfbsd/PLIST
libdrm-dfbsd/builtin.mk
libdrm-dfbsd/distinfo
libdrm-dfbsd/patches/patch-ac
libdrm-dfbsd/patches/patch-libkms_vmwgfx.c
libdrm-dfbsd/patches/patch-libsync.h
libdrm-dfbsd/patches/patch-xf86drmMode.c
Added Files:
libdrm-dfbsd/patches/patch-xf86drm.c
libdrm-dfbsd/patches/patch-xf86drmMode.h
Removed Files:
libdrm-dfbsd/patches/patch-ab
libdrm-dfbsd/patches/patch-radeon_radeon__bo__gem.c
libdrm-dfbsd/patches/patch-radeon_radeon__cs__gem.c
Log Message:
libdrm-dfbsd: Update wip/libdrm-dfbsd to 2.4.97
Have not switched over to DragonFly copying OpenBSD's ioctl yet.
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=859aad7056a9c23db0645c4f21ec765bb6681730
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
libdrm-dfbsd/Makefile | 36 +-
libdrm-dfbsd/PLIST | 3 +-
libdrm-dfbsd/builtin.mk | 10 +-
libdrm-dfbsd/distinfo | 23 +-
libdrm-dfbsd/patches/patch-ab | 1104 --------------------
libdrm-dfbsd/patches/patch-ac | 41 +-
libdrm-dfbsd/patches/patch-libkms_vmwgfx.c | 25 +-
libdrm-dfbsd/patches/patch-libsync.h | 20 +-
.../patches/patch-radeon_radeon__bo__gem.c | 37 -
.../patches/patch-radeon_radeon__cs__gem.c | 23 -
libdrm-dfbsd/patches/patch-xf86drm.c | 639 +++++++++++
libdrm-dfbsd/patches/patch-xf86drmMode.c | 95 +-
libdrm-dfbsd/patches/patch-xf86drmMode.h | 20 +
13 files changed, 761 insertions(+), 1315 deletions(-)
diffs:
diff --git a/libdrm-dfbsd/Makefile b/libdrm-dfbsd/Makefile
index a80e4fbd8c..f7a2348fcc 100644
--- a/libdrm-dfbsd/Makefile
+++ b/libdrm-dfbsd/Makefile
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.80 2018/03/07 12:12:35 wiz Exp $
+# $NetBSD: Makefile,v 1.91 2019/01/22 21:50:47 wiz Exp $
-DISTNAME= libdrm-2.4.91
+DISTNAME= libdrm-2.4.97
CATEGORIES= x11 graphics
MASTER_SITES= http://dri.freedesktop.org/libdrm/
EXTRACT_SUFX= .tar.bz2
@@ -16,14 +16,13 @@ USE_PKGLOCALEDIR= yes
USE_TOOLS+= gmake pkg-config
USE_LIBTOOL= yes
PKGCONFIG_OVERRIDE+= libdrm.pc.in
-PKGCONFIG_OVERRIDE+= libkms.pc.in
GNU_CONFIGURE= yes
.include "../../mk/bsd.prefs.mk"
SUBST_CLASSES+= atomic
SUBST_FILES.atomic= xf86drm.h
-SUBST_MESSAGE.atomic= Configuring xf86drm.h atomic operations.
+SUBST_MESSAGE.atomic= Configuring xf86drm.h s atomic operations.
SUBST_STAGE.atomic= pre-configure
SUBST_VARS.atomic= ATOMIC_OPS_CHECK
@@ -38,9 +37,13 @@ CONFIGURE_ENV+= drm_cv_atomic_primitives=libatomic-ops
.endif
.endif
+CONFIGURE_ARGS+= PTHREADSTUBS_CFLAGS=-I${PREFIX}/include \
+ PTHREADSTUBS_LIBS=-L${PREFIX}/lib
CONFIGURE_ARGS+= --disable-manpages
CONFIGURE_ARGS+= --disable-valgrind
+LDFLAGS.NetBSD+= -lpci
+
PLIST_VARS+= intel arm
.if !empty(MACHINE_ARCH:Mi386) || !empty(MACHINE_ARCH:Mx86_64)
# libpciaccess is needed to build support for the intel KMS API,
@@ -56,29 +59,22 @@ PLIST.arm= yes
.endif
PKG_OPTIONS_VAR= PKG_OPTIONS.libdrm
-PKG_SUPPORTED_OPTIONS= pthreadstubs libkms
-PKG_SUGGESTED_OPTIONS+= pthreadstubs
-
-.if !empty(MACHINE_ARCH:Mi386) || !empty(MACHINE_ARCH:Mx86_64)
-PKG_SUGGESTED_OPTIONS+= libkms
-.endif
+PKG_SUPPORTED_OPTIONS= libkms
+PKG_SUGGESTED_OPTIONS=
-# avoid circular dependency in case cairo supports OpenGL (cairo->mesa-libs->libdrm->cairo)
-CONFIGURE_ARGS+= --disable-cairo-tests
+# .if !empty(MACHINE_ARCH:Mi386) || !empty(MACHINE_ARCH:Mx86_64)
+# PKG_SUGGESTED_OPTIONS+= libkms
+# .endif
.include "../../mk/bsd.options.mk"
-.if !empty(PKG_OPTIONS:Mpthreadstubs)
-CONFIGURE_ARGS+= PTHREADSTUBS_CFLAGS=-I${PREFIX}/include \
- PTHREADSTUBS_LIBS=-L${PREFIX}/lib
-.endif
-
-PLIST_VARS+= libkms
+PLIST_VARS+= libkms
.if !empty(PKG_OPTIONS:Mlibkms)
-PLIST.libkms= yes
+PKGCONFIG_OVERRIDE+= libkms.pc.in
+PLIST.libkms= yes
CONFIGURE_ARGS+= --enable-libkms
.else
-CONFIGURE_ARGS+= --disable-libkms
+#CONFIGURE_ARGS+= --disable-libkms
.endif
.include "../../mk/bsd.pkg.mk"
diff --git a/libdrm-dfbsd/PLIST b/libdrm-dfbsd/PLIST
index 0182516978..c1ec709d1e 100644
--- a/libdrm-dfbsd/PLIST
+++ b/libdrm-dfbsd/PLIST
@@ -1,4 +1,4 @@
-@comment $NetBSD: PLIST,v 1.20 2017/08/26 05:47:56 wiz Exp $
+@comment $NetBSD: PLIST,v 1.21 2018/09/02 08:34:34 wiz Exp $
${PLIST.arm}include/freedreno/freedreno_drmif.h
${PLIST.arm}include/freedreno/freedreno_ringbuffer.h
include/libdrm/amdgpu.h
@@ -13,6 +13,7 @@ ${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
diff --git a/libdrm-dfbsd/builtin.mk b/libdrm-dfbsd/builtin.mk
index 1b52d9b25e..ffe2489949 100644
--- a/libdrm-dfbsd/builtin.mk
+++ b/libdrm-dfbsd/builtin.mk
@@ -1,8 +1,10 @@
-# $NetBSD: builtin.mk,v 1.3 2014/03/10 11:05:53 jperkin Exp $
+# $NetBSD: builtin.mk,v 1.4 2018/06/01 15:05:43 maya Exp $
-BUILTIN_PKG:= libdrm
-PKGCONFIG_FILE.libdrm= ${X11BASE}/lib/pkgconfig/libdrm.pc
-PKGCONFIG_FILE.libdrm+= ${X11BASE}/lib${LIBABISUFFIX}/pkgconfig/libdrm.pc
+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-dfbsd/distinfo b/libdrm-dfbsd/distinfo
index 4b1b7e266d..e7248739db 100644
--- a/libdrm-dfbsd/distinfo
+++ b/libdrm-dfbsd/distinfo
@@ -1,15 +1,14 @@
-$NetBSD: distinfo,v 1.80 2018/03/07 12:12:35 wiz Exp $
+$NetBSD: distinfo,v 1.92 2019/01/22 21:50:47 wiz Exp $
-SHA1 (libdrm-2.4.91.tar.bz2) = 44e42ce3cd41666e343ba393c73f6f1ad9fe1e74
-RMD160 (libdrm-2.4.91.tar.bz2) = d1c35b94703fdfb944c54451fe65977d24d7a568
-SHA512 (libdrm-2.4.91.tar.bz2) = 07578c00c121ba37033db7172590e26d1545f81c242bbce2cfb7fb904bde504822c275d6468e5c5d20360d0046ae73d9b058aa0459ba35eb11927141cc998772
-Size (libdrm-2.4.91.tar.bz2) = 815419 bytes
-SHA1 (patch-ab) = c2d32279cbf91e57ee1fd1d237186e029ebaffaf
-SHA1 (patch-ac) = 87d34e929f6ebeaa7991d343b3025a0a3b276329
+SHA1 (libdrm-2.4.97.tar.bz2) = 7635bec769a17edd140282fa2c46838c4a44bc91
+RMD160 (libdrm-2.4.97.tar.bz2) = eb9b715aef37af8b879f45fb2ee5fbb9adbba31b
+SHA512 (libdrm-2.4.97.tar.bz2) = 3e08ee9d6c9ce265d783a59b51e22449905ea73aa27f25a082a1e9e1532f7c99e1c9f7cb966eb0970be2a08e2e5993dc9aa55093b1bff548689fdb465e7145ed
+Size (libdrm-2.4.97.tar.bz2) = 837329 bytes
+SHA1 (patch-ac) = 67c998df7dfc0dabc86320ea6d015cede3e464ea
SHA1 (patch-include_drm_drm.h) = 48a912f40bf2b2a1c23edbe4446fa7869212f17b
-SHA1 (patch-libkms_vmwgfx.c) = 159228d66cfa12bbbad268a8881ffdf5127799b5
-SHA1 (patch-libsync.h) = 937d1150bf816e5f7809fa96ad7f981895bf99f5
-SHA1 (patch-radeon_radeon__bo__gem.c) = 93a9238277f40813b3d1c1e6984106657d654dc7
-SHA1 (patch-radeon_radeon__cs__gem.c) = 5cc9bd1a5f62fb380f9f92b7ce1c44769b35c751
+SHA1 (patch-libkms_vmwgfx.c) = de56a4f1724bef5f237f183eca889b8cef3b81af
+SHA1 (patch-libsync.h) = 1e0603e72a54a069fc9d2ab2c9559d22381a69d3
SHA1 (patch-xf86atomic.h) = 887db95db00125bdfa1ab298b2ccc555dec70366
-SHA1 (patch-xf86drmMode.c) = ad3c2c9188e6582c4f311851bd366ad873455750
+SHA1 (patch-xf86drm.c) = 3cd8c6a6e26728d92ec3fc03cfffa778a65c286b
+SHA1 (patch-xf86drmMode.c) = d7c6617ef54f76dc3dac00098adbb2f6fb02d685
+SHA1 (patch-xf86drmMode.h) = 265989e670cc7ead9bb5002e116e5ab56439ede6
diff --git a/libdrm-dfbsd/patches/patch-ab b/libdrm-dfbsd/patches/patch-ab
deleted file mode 100644
index a399ac786c..0000000000
--- a/libdrm-dfbsd/patches/patch-ab
+++ /dev/null
@@ -1,1104 +0,0 @@
-$NetBSD: patch-ab,v 1.8 2015/08/14 17:12:35 wiz Exp $
-
-Code for OpenBSD adapted for NetBSD. Assumes NetBSD kernel has been
-patched to use drm ioctl number 0x0f.
-
-Patches from FreeBSD ports / DragonFly dports for graphics/libdrm 2.4.84.
-
---- xf86drm.c.orig 2017-12-18 01:33:10.000000000 +0000
-+++ xf86drm.c
-@@ -49,6 +49,9 @@
- #include <signal.h>
- #include <time.h>
- #include <sys/types.h>
-+#ifdef HAVE_SYS_SYSCTL_H
-+#include <sys/sysctl.h>
-+#endif
- #include <sys/stat.h>
- #define stat_t struct stat
- #include <sys/ioctl.h>
-@@ -62,6 +65,10 @@
- #endif
- #include <math.h>
-
-+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
-+#include <sys/pciio.h>
-+#endif
-+
- /* Not all systems have MAP_FAILED defined */
- #ifndef MAP_FAILED
- #define MAP_FAILED ((void *)-1)
-@@ -72,22 +79,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"
--#else
--#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__)
--#define DRM_MAJOR 145
-+#define DRM_MAJOR 0 /* Major ID unused on systems with devfs */
- #endif
-
- #ifdef __NetBSD__
--#define DRM_MAJOR 34
-+#undef DRM_MAJOR
-+#define DRM_MAJOR 180
- #endif
-
- #ifdef __OpenBSD__
-@@ -102,7 +100,7 @@
- #define DRM_MAJOR 226 /* Linux */
- #endif
-
--#ifdef __OpenBSD__
-+#if defined(__OpenBSD__) || defined(__NetBSD__)
- struct drm_pciinfo {
- uint16_t domain;
- uint8_t bus;
-@@ -114,8 +112,12 @@ struct drm_pciinfo {
- uint16_t subdevice_id;
- uint8_t revision_id;
- };
-+#endif
-
-+#if defined(__OpenBSD__)
- #define DRM_IOCTL_GET_PCIINFO DRM_IOR(0x15, struct drm_pciinfo)
-+#elif defined(__NetBSD__)
-+#define DRM_IOCTL_GET_PCIINFO DRM_IOR(0x0f, struct drm_pciinfo)
- #endif
-
- #define DRM_MSG_VERBOSITY 3
-@@ -180,7 +182,7 @@ void drmFree(void *pt)
- }
-
- /**
-- * Call ioctl, restarting if it is interupted
-+ * Call ioctl, restarting if it is interrupted
- */
- int
- drmIoctl(int fd, unsigned long request, void *arg)
-@@ -189,10 +191,111 @@ drmIoctl(int fd, unsigned long request,
-
- do {
- ret = ioctl(fd, request, arg);
-+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-+/*
-+ * FreeBSD Bug 204174: error code 512 (ERESTARTSYS) leaked from kernel space
-+ * for some older kernels.
-+ */
-+ } while (ret == -1 && (errno == EINTR || errno == EAGAIN || errno == 512));
-+#else
- } while (ret == -1 && (errno == EINTR || errno == EAGAIN));
-+#endif
-+ if (ret) {
-+ struct stat sbuf;
-+ char name[64];
-+
-+ fstat(fd, &sbuf);
-+ snprintf(name, sizeof(name), "%s", devname(sbuf.st_rdev, S_IFCHR));
-+
-+ drmMsg("[drm] drmIoctl FAILED : fd (%d), device (%s): request (0x%08lx): ret (%d), errno (%d), (%s)\n",
-+ fd, name, request, ret, errno, strerror(errno));
-+ }
- return ret;
- }
-
-+static int drmGetMinorBase(int type)
-+{
-+ switch (type) {
-+ case DRM_NODE_PRIMARY:
-+ case DRM_NODE_CONTROL:
-+ case DRM_NODE_RENDER:
-+ return type << 6;
-+ default:
-+ return -1;
-+ };
-+}
-+
-+static int drmGetMinorType(int minor)
-+{
-+ if (minor < 0)
-+ return -1;
-+
-+ int type = minor >> 6;
-+ switch (type) {
-+ case DRM_NODE_PRIMARY:
-+ case DRM_NODE_CONTROL:
-+ case DRM_NODE_RENDER:
-+ return type;
-+ default:
-+ return -1;
-+ }
-+}
-+
-+#if defined(__linux__)
-+static const char *drmGetMinorName(int type)
-+{
-+ switch (type) {
-+ case DRM_NODE_PRIMARY:
-+ return DRM_PRIMARY_MINOR_NAME;
-+ case DRM_NODE_CONTROL:
-+ return DRM_CONTROL_MINOR_NAME;
-+ case DRM_NODE_RENDER:
-+ return DRM_RENDER_MINOR_NAME;
-+ default:
-+ return NULL;
-+ }
-+}
-+#endif
-+
-+static const char *drmGetDeviceName(int type)
-+{
-+ switch (type) {
-+ case DRM_NODE_PRIMARY:
-+ return DRM_DEV_NAME;
-+ case DRM_NODE_CONTROL:
-+ return DRM_CONTROL_DEV_NAME;
-+ case DRM_NODE_RENDER:
-+ return DRM_RENDER_DEV_NAME;
-+ default:
-+ return NULL;
-+ }
-+}
-+
-+static int drmGetNodeNumber(const char *name)
-+{
-+ size_t name_len = strnlen(name, DRM_NODE_NAME_MAX);
-+ while (name_len && isdigit(name[name_len - 1]))
-+ --name_len;
-+ return strtol(name + name_len, NULL, 10);
-+}
-+
-+static int drmGetNodeType(const char *name)
-+{
-+ if (strncmp(name, DRM_PRIMARY_MINOR_NAME,
-+ sizeof(DRM_PRIMARY_MINOR_NAME) - 1) == 0)
-+ return DRM_NODE_PRIMARY;
-+
-+ if (strncmp(name, DRM_CONTROL_MINOR_NAME,
-+ sizeof(DRM_CONTROL_MINOR_NAME ) - 1) == 0)
-+ return DRM_NODE_CONTROL;
-+
-+ if (strncmp(name, DRM_RENDER_MINOR_NAME,
-+ sizeof(DRM_RENDER_MINOR_NAME) - 1) == 0)
-+ return DRM_NODE_RENDER;
-+
-+ return -1;
-+}
-+
- static unsigned long drmGetKeyFromFd(int fd)
- {
- stat_t st;
-@@ -290,7 +393,7 @@ static int drmMatchBusID(const char *id1
- *
- * \internal
- * Checks for failure. If failure was caused by signal call chown again.
-- * If any other failure happened then it will output error mesage using
-+ * If any other failure happened then it will output error message using
- * drmMsg() call.
- */
- #if !defined(UDEV)
-@@ -327,8 +430,8 @@ static int chown_check_return(const char
- static int drmOpenDevice(dev_t dev, int minor, int type)
- {
- stat_t st;
-- const char *dev_name;
-- char buf[64];
-+ const char *dev_name = drmGetDeviceName(type);
-+ char buf[DRM_NODE_NAME_MAX];
- int fd;
- mode_t devmode = DRM_DEV_MODE, serv_mode;
- gid_t serv_group;
-@@ -338,21 +441,14 @@ static int drmOpenDevice(dev_t dev, int
- gid_t group = DRM_DEV_GID;
- #endif
-
-- switch (type) {
-- case DRM_NODE_PRIMARY:
-- dev_name = DRM_DEV_NAME;
-- break;
-- case DRM_NODE_CONTROL:
-- dev_name = DRM_CONTROL_DEV_NAME;
-- break;
-- case DRM_NODE_RENDER:
-- dev_name = DRM_RENDER_DEV_NAME;
-- break;
-- default:
-+ if (!dev_name)
- return -EINVAL;
-- };
-
-+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
-+ sprintf(buf, dev_name, DRM_DIR_NAME, minor + drmGetMinorBase(type));
-+#else
- sprintf(buf, dev_name, DRM_DIR_NAME, minor);
-+#endif
- drmMsg("drmOpenDevice: node name is %s\n", buf);
-
- if (drm_server_info && drm_server_info->get_perms) {
-@@ -456,27 +552,20 @@ wait_for_udev:
- static int drmOpenMinor(int minor, int create, int type)
- {
- int fd;
-- char buf[64];
-- const char *dev_name;
-+ char buf[DRM_NODE_NAME_MAX];
-+ const char *dev_name = drmGetDeviceName(type);
-
- if (create)
- return drmOpenDevice(makedev(DRM_MAJOR, minor), minor, type);
-
-- switch (type) {
-- case DRM_NODE_PRIMARY:
-- dev_name = DRM_DEV_NAME;
-- break;
-- case DRM_NODE_CONTROL:
-- dev_name = DRM_CONTROL_DEV_NAME;
-- break;
-- case DRM_NODE_RENDER:
-- dev_name = DRM_RENDER_DEV_NAME;
-- break;
-- default:
-+ if (!dev_name)
- return -EINVAL;
-- };
-
-+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
-+ sprintf(buf, dev_name, DRM_DIR_NAME, minor + drmGetMinorBase(type));
-+#else
- sprintf(buf, dev_name, DRM_DIR_NAME, minor);
-+#endif
- if ((fd = open(buf, O_RDWR, 0)) >= 0)
- return fd;
- return -errno;
-@@ -505,11 +594,17 @@ int drmAvailable(void)
- if (!access("/proc/dri/0", R_OK))
- return 1;
- #endif
-+
-+ drmMsg("[drm] drmAvailable: FAILED to open drm minor 0: fd (%d)\n", fd);
-+
- return 0;
- }
-
-+ drmMsg("[drm] drmAvailable: OPENED drm minor 0 with fd (%d)\n", fd);
-+
- if ((version = drmGetVersion(fd))) {
- retval = 1;
-+ drmMsg("[drm] drmAvailable: SUCCESS to open drm minor 0: fd (%d)\n", fd);
- drmFreeVersion(version);
- }
- close(fd);
-@@ -517,51 +612,6 @@ int drmAvailable(void)
- return retval;
- }
-
--static int drmGetMinorBase(int type)
--{
-- switch (type) {
-- case DRM_NODE_PRIMARY:
-- return 0;
-- case DRM_NODE_CONTROL:
-- return 64;
-- case DRM_NODE_RENDER:
-- return 128;
-- default:
-- return -1;
-- };
--}
--
--static int drmGetMinorType(int minor)
--{
-- int type = minor >> 6;
--
-- if (minor < 0)
-- return -1;
--
-- switch (type) {
-- case DRM_NODE_PRIMARY:
-- case DRM_NODE_CONTROL:
-- case DRM_NODE_RENDER:
-- return type;
-- default:
-- return -1;
-- }
--}
--
--static const char *drmGetMinorName(int type)
--{
-- switch (type) {
-- case DRM_NODE_PRIMARY:
-- return DRM_PRIMARY_MINOR_NAME;
-- case DRM_NODE_CONTROL:
-- return DRM_CONTROL_MINOR_NAME;
-- case DRM_NODE_RENDER:
-- return DRM_RENDER_MINOR_NAME;
-- default:
-- return NULL;
-- }
--}
--
- /**
- * Open the device by bus ID.
- *
-@@ -2740,50 +2790,80 @@ int drmDropMaster(int fd)
-
- char *drmGetDeviceNameFromFd(int fd)
- {
-- 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. */
-
-+ stat_t sbuf;
- fstat(fd, &sbuf);
-- d = sbuf.st_rdev;
-+ dev_t d = sbuf.st_rdev;
-
-- for (i = 0; i < DRM_MAX_MINOR; i++) {
-+ drmMsg("[drm] drmGetDeviceNameFromFd: fd (%d)\n", fd);
-+
-+ for (int i = 0; i < DRM_MAX_MINOR; i++) {
-+ char name[DRM_NODE_NAME_MAX];
- 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;
-+ if (stat(name, &sbuf) == 0 && sbuf.st_rdev == d) {
-
-- return strdup(name);
-+ drmMsg("[drm] drmGetDeviceNameFromFd: device name (%s)\n", name);
-+
-+ return strdup(name);
-+ }
-+ }
-+ return NULL;
- }
-
-+
- int drmGetNodeTypeFromFd(int fd)
- {
-- struct stat sbuf;
-+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
-+ char *name = drmGetDeviceNameFromFd2(fd);
-+
-+ drmMsg("[drm] drmGetNodeTypeFromFd: fd (%d)\n", fd);
-+
-+ if (!name) {
-+ errno = ENODEV;
-+ return -1;
-+ }
-+
-+ drmMsg("[drm] drmGetNodeTypeFromFd: device name (%s)\n", name);
-+
-+ int type = drmGetNodeType(name);
-+
-+ drmMsg("[drm] drmGetNodeTypeFromFd: device has type (%d)\n", type);
-+
-+ free(name);
-+ if (type < 0)
-+ errno = ENODEV;
-+ return type;
-+#else
-+ stat_t sbuf;
- int maj, min, type;
-
-+ drmMsg("[drm] drmGetNodeTypeFromFd: fd (%d)\n", fd);
-+
- if (fstat(fd, &sbuf))
- return -1;
-
- maj = major(sbuf.st_rdev);
- min = minor(sbuf.st_rdev);
-
-+ drmMsg("[drm] drmGetNodeTypeFromFd: major (%d), minor (%d)\n", maj, min);
-+
- if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) {
- errno = EINVAL;
- return -1;
- }
-
- type = drmGetMinorType(min);
-+
-+ drmMsg("[drm] drmGetNodeTypeFromFd: device has type (%d)\n", type);
-+
- if (type == -1)
- errno = ENODEV;
- return type;
-+#endif
- }
-
- int drmPrimeHandleToFD(int fd, uint32_t handle, uint32_t flags, int *prime_fd)
-@@ -2823,7 +2903,7 @@ static char *drmGetMinorNameForFD(int fd
- #ifdef __linux__
- DIR *sysdir;
- struct dirent *pent, *ent;
-- struct stat sbuf;
-+ stat_t sbuf;
- const char *name = drmGetMinorName(type);
- int len;
- char dev_name[64], buf[64];
-@@ -2874,13 +2954,44 @@ static char *drmGetMinorNameForFD(int fd
-
- out_close_dir:
- closedir(sysdir);
-+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
-+ const char *dev_name = drmGetDeviceName(type);
-+ if (!dev_name)
-+ return NULL;
-+
-+ char *name = drmGetDeviceNameFromFd2(fd);
-+ if (!name)
-+ return NULL;
-+
-+ int oldnum = drmGetNodeNumber(name);
-+ int oldtype = drmGetMinorType(oldnum);
-+ if (oldtype < 0) {
-+ free(name);
-+ return NULL;
-+ }
-+
-+ int newnum = oldnum - drmGetMinorBase(oldtype) + drmGetMinorBase(type);
-+ snprintf(name, DRM_NODE_NAME_MAX, dev_name, DRM_DIR_NAME, newnum);
-+ return name;
-+#elif defined(__NetBSD__)
-+ struct stat buf;
-+ char name[64];
-+
-+ fstat(fd, &buf);
-+ snprintf(name, sizeof(name), "/dev/%s",
-+ devname(buf.st_rdev, S_IFCHR));
-+
-+ return strdup(name);
- #else
-- struct stat sbuf;
-- char buf[PATH_MAX + 1];
-- const char *dev_name;
-+ stat_t sbuf;
-+ char buf[DRM_NODE_NAME_MAX];
-+ const char *dev_name = drmGetDeviceName(type);
- unsigned int maj, min;
- int n, base;
-
-+ if (!dev_name)
-+ return NULL;
-+
- if (fstat(fd, &sbuf))
- return NULL;
-
-@@ -2890,20 +3001,6 @@ out_close_dir:
- if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode))
- return NULL;
-
-- switch (type) {
-- case DRM_NODE_PRIMARY:
-- dev_name = DRM_DEV_NAME;
-- break;
-- case DRM_NODE_CONTROL:
-- dev_name = DRM_CONTROL_DEV_NAME;
-- break;
-- case DRM_NODE_RENDER:
-- dev_name = DRM_RENDER_DEV_NAME;
-- break;
-- default:
-- return NULL;
-- };
--
- base = drmGetMinorBase(type);
- if (base < 0)
- return NULL;
-@@ -3001,7 +3098,9 @@ static int drmParseSubsystemType(int maj
- return DRM_BUS_HOST1X;
-
- return -EINVAL;
--#elif defined(__OpenBSD__)
-+#elif defined(__OpenBSD__) || defined(__NetBSD__)
-+ return DRM_BUS_PCI;
-+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
- return DRM_BUS_PCI;
- #else
- #warning "Missing implementation of drmParseSubsystemType"
-@@ -3009,7 +3108,8 @@ static int drmParseSubsystemType(int maj
- #endif
- }
-
--static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info)
-+static int drmParsePciBusInfo(const char *node, int node_type,
-+ int maj, int min, drmPciBusInfoPtr info)
- {
- #ifdef __linux__
- unsigned int domain, bus, dev, func;
-@@ -3034,23 +3134,30 @@ static int drmParsePciBusInfo(int maj, i
- info->func = func;
-
- return 0;
--#elif defined(__OpenBSD__)
-+#elif defined(__OpenBSD__) || defined(__NetBSD__)
- struct drm_pciinfo pinfo;
- int fd, type;
-
-+ drmMsg("[drm] drmParsePciBusInfo: min (%d)\n", min);
-+
- type = drmGetMinorType(min);
- if (type == -1)
- return -ENODEV;
-
-+ drmMsg("[drm] drmParsePciBusInfo: type (%d), DRM_NODE_PRIMARY (%d)\n",
-+ type, DRM_NODE_PRIMARY);
-+
- fd = drmOpenMinor(min, 0, type);
- if (fd < 0)
- return -errno;
-
- if (drmIoctl(fd, DRM_IOCTL_GET_PCIINFO, &pinfo)) {
- close(fd);
-+ drmMsg("[drm] drmParsePciBusInfo: FAILED ioctl (0x%08lx), fd (%d)\n", DRM_IOCTL_GET_PCIINFO, fd);
- return -errno;
- }
- close(fd);
-+ drmMsg("[drm] drmParsePciBusInfo: SUCCESS ioctl (0x%08lx), fd (%d)\n", DRM_IOCTL_GET_PCIINFO, fd);
-
- info->domain = pinfo.domain;
- info->bus = pinfo.bus;
-@@ -3058,6 +3165,83 @@ static int drmParsePciBusInfo(int maj, i
- info->func = pinfo.func;
-
- return 0;
-+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
-+
-+ drmMsg("[drm] drmParsePciBusInfo: node (%s), node_type (%d)\n", node, node_type);
-+ drmMsg("[drm] drmParsePciBusInfo: maj (0x%x = %d), min (0x%x = %d), rdev (0x%x)\n",
-+ maj, maj, min, min, makedev(maj, min));
-+
-+ /*
-+ * Only the primary nodes can be mapped to hw.dri.%i via major/minor
-+ * Determine the primary node by offset and use its major/minor pair
-+ */
-+ if (node_type != DRM_NODE_PRIMARY) {
-+ char name[DRM_NODE_NAME_MAX];
-+
-+ drmMsg("[drm] drmParsePciBusInfo: node_type (%d) != DRM_NODE_PRIMARY (%d)\n",
-+ node_type, DRM_NODE_PRIMARY);
-+
-+ snprintf(name, sizeof(name), DRM_DEV_NAME, DRM_DIR_NAME,
-+ drmGetNodeNumber(node) - drmGetMinorBase(node_type));
-+
-+ drmMsg("[drm] drmParsePciBusInfo: stat-ing name (%s)\n", name);
-+
-+ stat_t sbuf;
-+ if (stat(name, &sbuf))
-+ return -errno;
-+
-+ maj = major(sbuf.st_rdev);
-+ min = minor(sbuf.st_rdev);
-+
-+ drmMsg("[drm] drmParsePciBusInfo: maj (0x%x = %d), min (0x%x = %d), rdev (0x%x)\n",
-+ maj, maj, min, min, makedev(maj, min));
-+ }
-+ /*
-+ * Major/minor appear after the driver name in the hw.dri.%i.name node
-+ * Find the node with matching major/minor pair and parse the bus ID,
-+ * which may be after the name or may be alone in hw.dri.%i.busid
-+ */
-+ #define bus_fmt "pci:%04x:%02x:%02x.%d"
-+ #define name_fmt "%*s 0x%x " bus_fmt
-+ for (int i = 0; i < DRM_MAX_MINOR; ++i) {
-+ char name[16], value[256];
-+ size_t length = sizeof(value);
-+ snprintf(name, sizeof(name), "hw.dri.%d.name", i);
-+ if (sysctlbyname(name, value, &length, NULL, 0))
-+ continue;
-+
-+ value[length] = '\0';
-+
-+ drmMsg("[drm] drmParsePciBusInfo: sysctl name (%s) has value (%s)\n", name, value);
-+
-+ unsigned int rdev = 0, domain = 0, bus = 0, slot = 0, func = 0;
-+ int vals = sscanf(value, name_fmt, &rdev, &domain, &bus, &slot, &func);
-+
-+ if (vals >= 1 && rdev == makedev(maj,min)) {
-+ if (vals < 5) {
-+
-+ drmMsg("[drm] drmParsePciBusInfo: busid not in sysctl name, try busid\n");
-+
-+ /* busid not in the name, try busid */
-+ length = sizeof(value);
-+ snprintf(name, sizeof(name), "hw.dri.%d.busid", i);
-+ if (sysctlbyname(name, value, &length, NULL, 0))
-+ break;
-+ value[length] = '\0';
-+
-+ drmMsg("[drm] drmParsePciBusInfo: sysctl busid (%s) has value (%s)\n", name, value);
-+
-+ if (sscanf(value, bus_fmt, &domain, &bus, &slot, &func) != 4)
-+ break;
-+ }
-+ info->domain = domain;
-+ info->bus = bus;
-+ info->dev = slot;
-+ info->func = func;
-+ return 0;
-+ }
-+ }
-+ return -ENODEV;
- #else
- #warning "Missing implementation of drmParsePciBusInfo"
- return -EINVAL;
-@@ -3092,32 +3276,6 @@ int drmDevicesEqual(drmDevicePtr a, drmD
- return 0;
- }
-
--static int drmGetNodeType(const char *name)
--{
-- if (strncmp(name, DRM_PRIMARY_MINOR_NAME,
-- sizeof(DRM_PRIMARY_MINOR_NAME) - 1) == 0)
-- return DRM_NODE_PRIMARY;
--
-- if (strncmp(name, DRM_CONTROL_MINOR_NAME,
-- sizeof(DRM_CONTROL_MINOR_NAME ) - 1) == 0)
-- return DRM_NODE_CONTROL;
--
-- if (strncmp(name, DRM_RENDER_MINOR_NAME,
-- sizeof(DRM_RENDER_MINOR_NAME) - 1) == 0)
-- return DRM_NODE_RENDER;
--
-- return -EINVAL;
--}
--
--static int drmGetMaxNodeName(void)
--{
-- return sizeof(DRM_DIR_NAME) +
-- MAX3(sizeof(DRM_PRIMARY_MINOR_NAME),
-- sizeof(DRM_CONTROL_MINOR_NAME),
-- sizeof(DRM_RENDER_MINOR_NAME)) +
-- 3 /* length of the node number */;
--}
--
- #ifdef __linux__
- static int parse_separate_sysfs_files(int maj, int min,
- drmPciDeviceInfoPtr device,
-@@ -3187,6 +3345,7 @@ static int parse_config_sysfs_file(int m
- #endif
-
- static int drmParsePciDeviceInfo(int maj, int min,
-+ drmPciBusInfoPtr info,
- drmPciDeviceInfoPtr device,
- uint32_t flags)
- {
-@@ -3198,23 +3357,31 @@ static int drmParsePciDeviceInfo(int maj
- return parse_config_sysfs_file(maj, min, device);
-
- return 0;
--#elif defined(__OpenBSD__)
-+#elif defined(__OpenBSD__) || defined(__NetBSD__)
- struct drm_pciinfo pinfo;
- int fd, type;
-
-+ drmMsg("[drm] drmParsePciDeviceInfo: min (%d)\n", min);
-+
- type = drmGetMinorType(min);
- if (type == -1)
- return -ENODEV;
-
-+ drmMsg("[drm] drmParsePciDeviceInfo: type (%d), DRM_NODE_PRIMARY (%d)\n",
-+ type, DRM_NODE_PRIMARY);
-+
- fd = drmOpenMinor(min, 0, type);
- if (fd < 0)
- return -errno;
-
-+
- if (drmIoctl(fd, DRM_IOCTL_GET_PCIINFO, &pinfo)) {
- close(fd);
-+ drmMsg("[drm] drmParsePciDeviceInfo: FAILED ioctl (0x%08lx), fd (%d)\n", DRM_IOCTL_GET_PCIINFO, fd);
- return -errno;
- }
- close(fd);
-+ drmMsg("[drm] drmParsePciDeviceInfo: SUCCESS ioctl (0x%08lx), fd (%d)\n", DRM_IOCTL_GET_PCIINFO, fd);
-
- device->vendor_id = pinfo.vendor_id;
- device->device_id = pinfo.device_id;
-@@ -3223,6 +3390,48 @@ static int drmParsePciDeviceInfo(int maj
- device->subdevice_id = pinfo.subdevice_id;
-
- return 0;
-+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
-+ struct pci_conf_io pc;
-+ struct pci_match_conf patterns[1];
-+ struct pci_conf results[1];
-+
-+ int fd = open("/dev/pci", O_RDONLY, 0);
-+
-+ drmMsg("[drm] drmParsePciDeviceInfo: opened /dev/pci with fd (%d)\n", fd);
-+
-+ if (fd < 0)
-+ return -errno;
-+
-+ bzero(&patterns, sizeof(patterns));
-+ patterns[0].pc_sel.pc_domain = info->domain;
-+ patterns[0].pc_sel.pc_bus = info->bus;
-+ patterns[0].pc_sel.pc_dev = info->dev;
-+ patterns[0].pc_sel.pc_func = info->func;
-+ patterns[0].flags = PCI_GETCONF_MATCH_DOMAIN | PCI_GETCONF_MATCH_BUS
-+ | PCI_GETCONF_MATCH_DEV | PCI_GETCONF_MATCH_FUNC;
-+ bzero(&pc, sizeof(struct pci_conf_io));
-+ pc.num_patterns = 1;
-+ pc.pat_buf_len = sizeof(patterns);
-+ pc.patterns = patterns;
-+ pc.match_buf_len = sizeof(results);
-+ pc.matches = results;
-+
-+ if (ioctl(fd, PCIOCGETCONF, &pc) || pc.status == PCI_GETCONF_ERROR) {
-+ int error = errno;
-+ close(fd);
-+ drmMsg("[drm] drmParsePciDeviceInfo: FAILED ioctl (0x%08lx), fd (%d)\n", PCIOCGETCONF, fd);
-+ return -error;
-+ }
-+ close(fd);
-+ drmMsg("[drm] drmParsePciDeviceInfo: SUCCESS ioctl (0x%08lx), fd (%d)\n", PCIOCGETCONF, fd);
-+
-+ device->vendor_id = results[0].pc_vendor;
-+ device->device_id = results[0].pc_device;
-+ device->subvendor_id = results[0].pc_subvendor;
-+ device->subdevice_id = results[0].pc_subdevice;
-+ device->revision_id = results[0].pc_revid;
-+
-+ return 0;
- #else
- #warning "Missing implementation of drmParsePciDeviceInfo"
- return -EINVAL;
-@@ -3303,7 +3512,7 @@ static drmDevicePtr drmDeviceAlloc(unsig
- unsigned int i;
- char *ptr;
-
-- max_node_length = ALIGN(drmGetMaxNodeName(), sizeof(void *));
-+ max_node_length = ALIGN(DRM_NODE_NAME_MAX, sizeof(void *));
- extra = DRM_NODE_MAX * (sizeof(void *) + max_node_length);
-
- size = sizeof(*device) + extra + bus_size + device_size;
-@@ -3340,6 +3549,11 @@ static int drmProcessPciDevice(drmDevice
- char *addr;
- int ret;
-
-+ drmMsg("[drm] drmProcessPciDevice: node (%s), node_type (%d)\n",
-+ node, node_type);
-+ drmMsg("[drm] drmProcessPciDevice: maj (%d = 0x%x), min (%d = 0x%x), rdev (0x%x), flags (0x%x)\n",
-+ maj, maj, min, min, makedev(maj, min), flags);
-+
- dev = drmDeviceAlloc(node_type, node, sizeof(drmPciBusInfo),
- sizeof(drmPciDeviceInfo), &addr);
- if (!dev)
-@@ -3349,18 +3563,36 @@ static int drmProcessPciDevice(drmDevice
-
- dev->businfo.pci = (drmPciBusInfoPtr)addr;
-
-- ret = drmParsePciBusInfo(maj, min, dev->businfo.pci);
-+ ret = drmParsePciBusInfo(node, node_type, maj, min, dev->businfo.pci);
-+
- if (ret)
- goto free_device;
-
-+ drmMsg("[drm] drmProcessPciDevice: DOMAIN (%04x)\n", dev->businfo.pci->domain);
-+ drmMsg("[drm] drmProcessPciDevice: BUS (%02x)\n", dev->businfo.pci->bus);
-+ drmMsg("[drm] drmProcessPciDevice: DEV (%02x)\n", dev->businfo.pci->dev);
-+ drmMsg("[drm] drmProcessPciDevice: FUNC (%1u)\n", dev->businfo.pci->func);
-+
- // Fetch the device info if the user has requested it
- if (fetch_deviceinfo) {
- addr += sizeof(drmPciBusInfo);
- dev->deviceinfo.pci = (drmPciDeviceInfoPtr)addr;
-
-- ret = drmParsePciDeviceInfo(maj, min, dev->deviceinfo.pci, flags);
-+ ret = drmParsePciDeviceInfo(maj, min, dev->businfo.pci, dev->deviceinfo.pci, flags);
-+
- if (ret)
- goto free_device;
-+
-+ drmMsg("[drm] drmProcessPciDevice: VENDOR (%04x)\n",
-+ dev->deviceinfo.pci->vendor_id);
-+ drmMsg("[drm] drmProcessPciDevice: DEVICE (%04x)\n",
-+ dev->deviceinfo.pci->device_id);
-+ drmMsg("[drm] drmProcessPciDevice: SUBVENDOR (%04x)\n",
-+ dev->deviceinfo.pci->subvendor_id);
-+ drmMsg("[drm] drmProcessPciDevice: SUBDEVICE (%04x)\n",
-+ dev->deviceinfo.pci->subdevice_id);
-+ drmMsg("[drm] drmProcessPciDevice: REVISION (%02x)\n",
-+ dev->deviceinfo.pci->revision_id);
- }
-
- *device = dev;
-@@ -3708,7 +3940,7 @@ static void drmFoldDuplicatedDevices(drm
- local_devices[i]->available_nodes |= local_devices[j]->available_nodes;
- node_type = log2(local_devices[j]->available_nodes);
- memcpy(local_devices[i]->nodes[node_type],
-- local_devices[j]->nodes[node_type], drmGetMaxNodeName());
-+ local_devices[j]->nodes[node_type], DRM_NODE_NAME_MAX);
- drmFreeDevice(&local_devices[j]);
- }
- }
-@@ -3726,7 +3958,7 @@ drm_device_validate_flags(uint32_t flags
- * Get information about the opened drm device
- *
- * \param fd file descriptor of the drm device
-- * \param flags feature/behaviour bitmask
-+ * \param flags feature/behavior bitmask
- * \param device the address of a drmDevicePtr where the information
- * will be allocated in stored
- *
-@@ -3744,8 +3976,8 @@ int drmGetDevice2(int fd, uint32_t flags
- * Avoid stat'ing all of /dev needlessly by implementing this custom path.
- */
- drmDevicePtr d;
-- struct stat sbuf;
-- char node[PATH_MAX + 1];
-+ stat_t sbuf;
-+ char node[DRM_NODE_NAME_MAX];
- const char *dev_name;
- int node_type, subsystem_type;
- int maj, min, n, ret, base;
-@@ -3766,26 +3998,16 @@ int drmGetDevice2(int fd, uint32_t flags
- if (node_type == -1)
- return -ENODEV;
-
-- switch (node_type) {
-- case DRM_NODE_PRIMARY:
-- dev_name = DRM_DEV_NAME;
-- break;
-- case DRM_NODE_CONTROL:
-- dev_name = DRM_CONTROL_DEV_NAME;
-- break;
-- case DRM_NODE_RENDER:
-- dev_name = DRM_RENDER_DEV_NAME;
-- break;
-- default:
-+ dev_name = drmGetDeviceName(node_type);
-+ if (!dev_name)
- return -EINVAL;
-- };
-
- base = drmGetMinorBase(node_type);
- if (base < 0)
- return -EINVAL;
-
-- n = snprintf(node, PATH_MAX, dev_name, DRM_DIR_NAME, min - base);
-- if (n == -1 || n >= PATH_MAX)
-+ n = snprintf(node, sizeof(node), dev_name, DRM_DIR_NAME, min - base);
-+ if (n == -1 || n >= sizeof(node))
- return -errno;
- if (stat(node, &sbuf))
- return -EINVAL;
-@@ -3806,14 +4028,17 @@ int drmGetDevice2(int fd, uint32_t flags
- drmDevicePtr d;
- DIR *sysdir;
- struct dirent *dent;
-- struct stat sbuf;
-- char node[PATH_MAX + 1];
-+ stat_t sbuf;
-+ char node[DRM_NODE_NAME_MAX];
- int node_type, subsystem_type;
- int maj, min;
- int ret, i, node_count;
- int max_count = 16;
- dev_t find_rdev;
-
-+ drmMsg("[drm] drmGetDevice2: fd (%d), flags (%d) vs expected (%d)\n",
-+ fd, flags, DRM_DEVICE_GET_PCI_REVISION);
-+
- if (drm_device_validate_flags(flags))
- return -EINVAL;
-
-@@ -3827,11 +4052,16 @@ int drmGetDevice2(int fd, uint32_t flags
- maj = major(sbuf.st_rdev);
- min = minor(sbuf.st_rdev);
-
-- if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode))
-+ drmMsg("[drm] drmGetDevice2: maj (%d = 0x%x), min (%d = 0x%x), rdev (0x%x)\n",
-+ maj, maj, min, min, makedev(maj, min));
-+
-+ if ((DRM_MAJOR && maj != DRM_MAJOR) || !S_ISCHR(sbuf.st_mode))
- return -EINVAL;
-
- subsystem_type = drmParseSubsystemType(maj, min);
-
-+ drmMsg("[drm] drmGetDevice2: subsystem_type (%d)\n", subsystem_type);
-+
- local_devices = calloc(max_count, sizeof(drmDevicePtr));
- if (local_devices == NULL)
- return -ENOMEM;
-@@ -3848,14 +4078,14 @@ int drmGetDevice2(int fd, uint32_t flags
- if (node_type < 0)
- continue;
-
-- snprintf(node, PATH_MAX, "%s/%s", DRM_DIR_NAME, dent->d_name);
-+ snprintf(node, sizeof(node), "%s/%s", DRM_DIR_NAME, dent->d_name);
- if (stat(node, &sbuf))
- continue;
-
- maj = major(sbuf.st_rdev);
- min = minor(sbuf.st_rdev);
-
-- if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode))
-+ if ((DRM_MAJOR && maj != DRM_MAJOR) || !S_ISCHR(sbuf.st_mode))
- continue;
-
- if (drmParseSubsystemType(maj, min) != subsystem_type)
-@@ -3924,6 +4154,9 @@ int drmGetDevice2(int fd, uint32_t flags
- free(local_devices);
- if (*device == NULL)
- return -ENODEV;
-+
-+ drmMsg("[drm] drmGetDevice2: SUCCESS\n");
-+
- return 0;
-
- free_devices:
-@@ -3972,13 +4205,16 @@ int drmGetDevices2(uint32_t flags, drmDe
- drmDevicePtr device;
- DIR *sysdir;
- struct dirent *dent;
-- struct stat sbuf;
-- char node[PATH_MAX + 1];
-+ stat_t sbuf;
-+ char node[DRM_NODE_NAME_MAX];
- int node_type, subsystem_type;
- int maj, min;
- int ret, i, node_count, device_count;
- int max_count = 16;
-
-+ drmMsg("[drm] drmGetDevices2: flags (%d) vs expected (%d), max_devices (%d)\n",
-+ flags, DRM_DEVICE_GET_PCI_REVISION, max_devices);
-+
- if (drm_device_validate_flags(flags))
- return -EINVAL;
-
-@@ -3998,14 +4234,14 @@ int drmGetDevices2(uint32_t flags, drmDe
- if (node_type < 0)
- continue;
-
-- snprintf(node, PATH_MAX, "%s/%s", DRM_DIR_NAME, dent->d_name);
-+ snprintf(node, sizeof(node), "%s/%s", DRM_DIR_NAME, dent->d_name);
- if (stat(node, &sbuf))
- continue;
-
- maj = major(sbuf.st_rdev);
- min = minor(sbuf.st_rdev);
-
-- if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode))
-+ if ((DRM_MAJOR && maj != DRM_MAJOR) || !S_ISCHR(sbuf.st_mode))
- continue;
-
- subsystem_type = drmParseSubsystemType(maj, min);
-@@ -4082,6 +4318,7 @@ int drmGetDevices2(uint32_t flags, drmDe
-
- closedir(sysdir);
- free(local_devices);
-+ drmMsg("[drm] drmGetDevices2: SUCCESS: device_count (%d)\n", device_count);
- return device_count;
-
- free_devices:
-@@ -4113,7 +4350,7 @@ int drmGetDevices(drmDevicePtr devices[]
- char *drmGetDeviceNameFromFd2(int fd)
- {
- #ifdef __linux__
-- struct stat sbuf;
-+ stat_t sbuf;
- char path[PATH_MAX + 1], *value;
- unsigned int maj, min;
-
-@@ -4136,9 +4373,48 @@ char *drmGetDeviceNameFromFd2(int fd)
- free(value);
-
- return strdup(path);
-+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
-+ stat_t sbuf;
-+
-+ drmMsg("[drm] drmGetDeviceNameFromFd2: fd (%d)\n", fd);
-+
-+ if (fstat(fd, &sbuf))
-+ return NULL;
-+
-+ dev_t rdev = sbuf.st_rdev;
-+ /* minor numbers don't depend on node name suffix, search for a match */
-+ for (int i = 0; i < DRM_MAX_MINOR; ++i) {
-+ char node[DRM_NODE_NAME_MAX];
-+ for (int j = 0; j < DRM_NODE_MAX; ++j) {
-+ snprintf(node, sizeof(node), drmGetDeviceName(j),
-+ DRM_DIR_NAME, drmGetMinorBase(j) + i);
-+ if (stat(node, &sbuf) == 0 && sbuf.st_rdev == rdev) {
-+
-+ drmMsg("[drm] drmGetDeviceNameFromFd2: has device name (%s)\n", node);
-+
-+ return strdup(node);
-+ }
-+ }
-+ }
-+ return NULL;
-+#elif defined(__NetBSD__)
-+ struct stat sbuf;
-+ char path[64];
-+
-+ drmMsg("[drm] drmGetDeviceNameFromFd2: fd (%d)\n", fd);
-+
-+ if (fstat(fd, &sbuf))
-+ return NULL;
-+
-+ snprintf(path, sizeof(path), "/dev/%s",
-+ devname(sbuf.st_rdev, S_IFCHR));
-+
-+ drmMsg("[drm] drmGetDeviceNameFromFd2: has device name (%s)\n", path);
-+
-+ return strdup(path);
- #else
-- struct stat sbuf;
-- char node[PATH_MAX + 1];
-+ stat_t sbuf;
-+ char node[DRM_NODE_NAME_MAX];
- const char *dev_name;
- int node_type;
- int maj, min, n, base;
-@@ -4156,26 +4432,16 @@ char *drmGetDeviceNameFromFd2(int fd)
- if (node_type == -1)
- return NULL;
-
-- switch (node_type) {
-- case DRM_NODE_PRIMARY:
-- dev_name = DRM_DEV_NAME;
-- break;
-- case DRM_NODE_CONTROL:
-- dev_name = DRM_CONTROL_DEV_NAME;
-- break;
-- case DRM_NODE_RENDER:
-- dev_name = DRM_RENDER_DEV_NAME;
-- break;
-- default:
-+ dev_name = drmGetDeviceName(node_type);
-+ if (!dev_name)
- return NULL;
-- };
-
- base = drmGetMinorBase(node_type);
- if (base < 0)
- return NULL;
-
-- n = snprintf(node, PATH_MAX, dev_name, DRM_DIR_NAME, min - base);
-- if (n == -1 || n >= PATH_MAX)
-+ n = snprintf(node, sizeof(node), dev_name, DRM_DIR_NAME, min - base);
-+ if (n == -1 || n >= sizeof(node))
- return NULL;
-
- return strdup(node);
diff --git a/libdrm-dfbsd/patches/patch-ac b/libdrm-dfbsd/patches/patch-ac
index f0b2f7544d..2b11b37832 100644
--- a/libdrm-dfbsd/patches/patch-ac
+++ b/libdrm-dfbsd/patches/patch-ac
@@ -1,6 +1,6 @@
$NetBSD: patch-ac,v 1.4 2012/02/16 20:30:56 hans Exp $
---- xf86drm.h.orig 2017-12-18 01:33:10.000000000 +0000
+--- xf86drm.h.orig 2010-03-05 23:21:13.000000000 +0000
+++ xf86drm.h
@@ -35,7 +35,11 @@
#define _XF86DRM_H_
@@ -14,7 +14,7 @@ $NetBSD: patch-ac,v 1.4 2012/02/16 20:30:56 hans Exp $
#include <stdint.h>
#include <drm.h>
-@@ -59,6 +63,9 @@ extern "C" {
+@@ -55,6 +59,9 @@
#else /* One of the *BSDs */
#include <sys/ioccom.h>
@@ -24,42 +24,7 @@ $NetBSD: patch-ac,v 1.4 2012/02/16 20:30:56 hans Exp $
#define DRM_IOCTL_NR(n) ((n) & 0xff)
#define DRM_IOC_VOID IOC_VOID
#define DRM_IOC_READ IOC_OUT
-@@ -78,17 +85,28 @@ extern "C" {
-
- #ifdef __OpenBSD__
- #define DRM_DIR_NAME "/dev"
--#define DRM_DEV_NAME "%s/drm%d"
--#define DRM_CONTROL_DEV_NAME "%s/drmC%d"
--#define DRM_RENDER_DEV_NAME "%s/drmR%d"
-+#define DRM_PRIMARY_MINOR_NAME "drm"
-+#define DRM_CONTROL_MINOR_NAME "drmC"
-+#define DRM_RENDER_MINOR_NAME "drmR"
- #else
- #define DRM_DIR_NAME "/dev/dri"
--#define DRM_DEV_NAME "%s/card%d"
--#define DRM_CONTROL_DEV_NAME "%s/controlD%d"
--#define DRM_RENDER_DEV_NAME "%s/renderD%d"
-+#define DRM_PRIMARY_MINOR_NAME "card"
-+#define DRM_CONTROL_MINOR_NAME "controlD"
-+#define DRM_RENDER_MINOR_NAME "renderD"
- #define DRM_PROC_NAME "/proc/dri/" /* For backward Linux compatibility */
- #endif
-
-+#define DRM_DEV_NAME "%s/" DRM_PRIMARY_MINOR_NAME "%d"
-+#define DRM_CONTROL_DEV_NAME "%s/" DRM_CONTROL_MINOR_NAME "%d"
-+#define DRM_RENDER_DEV_NAME "%s/" DRM_RENDER_MINOR_NAME "%d"
-+
-+#define DRM_NODE_NAME_MAX \
-+ (sizeof(DRM_DIR_NAME) + \
-+ MAX3(sizeof(DRM_PRIMARY_MINOR_NAME), \
-+ sizeof(DRM_CONTROL_MINOR_NAME), \
-+ sizeof(DRM_RENDER_MINOR_NAME)) \
-+ + 3 + 3) /* length of the node number */
-+
- #define DRM_ERR_NO_DEVICE (-1001)
- #define DRM_ERR_NO_ACCESS (-1002)
- #define DRM_ERR_NOT_ROOT (-1003)
-@@ -354,7 +372,12 @@ typedef struct _drmSetVersion {
+@@ -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 */
diff --git a/libdrm-dfbsd/patches/patch-libkms_vmwgfx.c b/libdrm-dfbsd/patches/patch-libkms_vmwgfx.c
index 90c42eaa97..3ed014c2f0 100644
--- a/libdrm-dfbsd/patches/patch-libkms_vmwgfx.c
+++ b/libdrm-dfbsd/patches/patch-libkms_vmwgfx.c
@@ -8,13 +8,13 @@ From FreeBSD ports for graphics/libdrm version 2.4.84
# defining that causes errno to not be defined. fortunately, there's
# an alternative switch. unfortunately, those differ by platform and
# _WANT_KERNEL_ERRNO is too recent to be part of any release, so just
-# define ERESTART if we still don't have it after including errno.h
+# define ERESTART if we still don't have it after including errno.h
---- libkms/vmwgfx.c.orig 2017-11-03 16:44:27.000000000 +0000
+--- libkms/vmwgfx.c.orig 2015-05-06 23:04:31.000000000 +0000
+++ libkms/vmwgfx.c
-@@ -30,15 +30,31 @@
- #include "config.h"
- #endif
+@@ -26,10 +26,22 @@
+ **************************************************************************/
+
+#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
+#define _WANT_KERNEL_ERRNO
@@ -25,22 +25,13 @@ From FreeBSD ports for graphics/libdrm version 2.4.84
#include <stdlib.h>
#include <string.h>
#include "internal.h"
-
-+#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined(__DragonFly__)
+#ifndef ERESTART
++#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined(__DragonFly__)
+#define ERESTART (-1)
-+#endif
+#else
-+#ifndef ERESTART
+#define ERESTART 85
++#endif /* __FreeBSD__ || __DragonFly__ */
+#endif
-+#endif
-+
+
#include "xf86drm.h"
#include "libdrm_macros.h"
- #include "vmwgfx_drm.h"
-
-+
- struct vmwgfx_bo
- {
- struct kms_bo base;
diff --git a/libdrm-dfbsd/patches/patch-libsync.h b/libdrm-dfbsd/patches/patch-libsync.h
index 9b3a1c0327..41909f92a1 100644
--- a/libdrm-dfbsd/patches/patch-libsync.h
+++ b/libdrm-dfbsd/patches/patch-libsync.h
@@ -1,18 +1,24 @@
-$NetBSD$
+$NetBSD: patch-libsync.h,v 1.3 2019/01/22 21:50:47 wiz Exp $
-From FreeBSD ports x11/libdrm 2.4.84
+Fix public header on SunOS.
+If ETIME is not defined, use ETIMEDOUT.
-# define ETIME as ETIMEOUT same as done in Mesa
-
---- libsync.h.orig 2017-11-03 16:44:27.000000000 +0000
+--- libsync.h.orig 2019-01-22 16:32:41.000000000 +0000
+++ libsync.h
-@@ -35,6 +35,9 @@
+@@ -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-dfbsd/patches/patch-radeon_radeon__bo__gem.c b/libdrm-dfbsd/patches/patch-radeon_radeon__bo__gem.c
deleted file mode 100644
index 36f5564c8a..0000000000
--- a/libdrm-dfbsd/patches/patch-radeon_radeon__bo__gem.c
+++ /dev/null
@@ -1,37 +0,0 @@
-$NetBSD: patch-radeon_radeon__bo__gem.c,v 1.1 2014/10/26 10:20:10 wiz Exp $
-
-FreeBSD ports / DragonFly dports does not have this patch.
-
---- radeon/radeon_bo_gem.c.orig 2017-11-03 16:44:27.000000000 +0000
-+++ radeon/radeon_bo_gem.c
-@@ -178,8 +178,13 @@ static int bo_map(struct radeon_bo_int *
- boi, boi->handle, r);
- return r;
- }
-+#if defined(__FreeBSD__) || defined(__DragonFly__)
- ptr = drm_mmap(0, args.size, PROT_READ|PROT_WRITE, MAP_SHARED, boi->bom->fd, args.addr_ptr);
- if (ptr == MAP_FAILED)
-+#else
-+ r = drmMap(boi->bom->fd, args.addr_ptr, args.size, &ptr);
-+ if (r)
-+#endif
- return -errno;
- bo_gem->priv_ptr = ptr;
- wait:
-@@ -252,9 +257,16 @@ static int bo_set_tiling(struct radeon_b
- static int bo_get_tiling(struct radeon_bo_int *boi, uint32_t *tiling_flags,
- uint32_t *pitch)
- {
-+#if defined(__FreeBSD__) || defined(__DragonFly__)
- struct drm_radeon_gem_set_tiling args = {};
-+#else
-+ struct drm_radeon_gem_set_tiling args;
-+#endif
- int r;
-
-+#if !defined(__FreeBSD__) && !defined(__DragonFly__)
-+ memset(&args, 0, sizeof args);
-+#endif
- args.handle = boi->handle;
-
- r = drmCommandWriteRead(boi->bom->fd,
diff --git a/libdrm-dfbsd/patches/patch-radeon_radeon__cs__gem.c b/libdrm-dfbsd/patches/patch-radeon_radeon__cs__gem.c
deleted file mode 100644
index 9ba1699d68..0000000000
--- a/libdrm-dfbsd/patches/patch-radeon_radeon__cs__gem.c
+++ /dev/null
@@ -1,23 +0,0 @@
-$NetBSD: patch-radeon_radeon__cs__gem.c,v 1.1 2014/10/26 10:20:10 wiz Exp $
-
-FreeBSD ports / DragonFly dports does not have this patch.
-
---- radeon/radeon_cs_gem.c.orig 2017-11-03 16:44:27.000000000 +0000
-+++ radeon/radeon_cs_gem.c
-@@ -528,9 +528,16 @@ static const struct radeon_cs_funcs rade
-
- static int radeon_get_device_id(int fd, uint32_t *device_id)
- {
-+#if !defined(__FreeBSD__) && !defined(__DragonFly__)
-+ struct drm_radeon_info info;
-+#else
- struct drm_radeon_info info = {};
-+#endif
- int r;
-
-+#if !defined(__FreeBSD__) && !defined(__DragonFly__)
-+ memset(&info, 0, sizeof info);
-+#endif
- *device_id = 0;
- info.request = RADEON_INFO_DEVICE_ID;
- info.value = (uintptr_t)device_id;
diff --git a/libdrm-dfbsd/patches/patch-xf86drm.c b/libdrm-dfbsd/patches/patch-xf86drm.c
new file mode 100644
index 0000000000..5f5fc685af
--- /dev/null
+++ b/libdrm-dfbsd/patches/patch-xf86drm.c
@@ -0,0 +1,639 @@
+$NetBSD: patch-xf86drm.c,v 1.4 2019/01/22 21:50:47 wiz Exp $
+
+Implement drmParseSubsystemType, drmParsePciBusInfo for NetBSD
+
+Patches from FreeBSD ports / DragonFly dports for graphics/libdrm 2.4.84.
+
+--- xf86drm.c.orig 2019-01-22 16:32:41.000000000 +0000
++++ xf86drm.c
+@@ -46,6 +46,11 @@
+ #include <signal.h>
+ #include <time.h>
+ #include <sys/types.h>
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++#ifdef HAVE_SYS_SYSCTL_H
++#include <sys/sysctl.h>
++#endif
++#endif
+ #include <sys/stat.h>
+ #define stat_t struct stat
+ #include <sys/ioctl.h>
+@@ -59,6 +64,10 @@
+ #endif
+ #include <math.h>
+
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++#include <sys/pciio.h>
++#endif
++
+ #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+
+ /* Not all systems have MAP_FAILED defined */
+@@ -82,11 +91,23 @@
+ #endif
+
+ #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
+-#define DRM_MAJOR 145
++#define DRM_MAJOR 0 /* Major ID unused on systems with devfs */
++#endif
++
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++#define DRM_NODE_NAME_MAX \
++ (sizeof(DRM_DIR_NAME) + \
++ MAX3(sizeof(DRM_PRIMARY_MINOR_NAME), \
++ sizeof(DRM_CONTROL_MINOR_NAME), \
++ sizeof(DRM_RENDER_MINOR_NAME)) \
++ + 3) /* length of the node number */
+ #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__
+@@ -101,7 +122,7 @@
+ #define DRM_MAJOR 226 /* Linux */
+ #endif
+
+-#if defined(__OpenBSD__) || defined(__DragonFly__)
++#if defined(__OpenBSD__)
+ struct drm_pciinfo {
+ uint16_t domain;
+ uint8_t bus;
+@@ -222,6 +243,35 @@ drm_public drmHashEntry *drmGetEntry(int
+ return entry;
+ }
+
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++static int drmGetMinorBase(int type);
++static int drmGetMinorType(int minor);
++
++static const char *drmGetDeviceName(int type)
++{
++ switch (type) {
++ case DRM_NODE_PRIMARY:
++ return DRM_DEV_NAME;
++ case DRM_NODE_CONTROL:
++ return DRM_CONTROL_DEV_NAME;
++ case DRM_NODE_RENDER:
++ return DRM_RENDER_DEV_NAME;
++ default:
++ return NULL;
++ }
++}
++
++static int drmGetNodeNumber(const char *name)
++{
++ size_t name_len = strnlen(name, DRM_NODE_NAME_MAX);
++ while (name_len && isdigit(name[name_len - 1]))
++ --name_len;
++ return strtol(name + name_len, NULL, 10);
++}
++
++static int drmGetNodeType(const char *name);
++#endif /* __FreeBSD__ || __DragonFly__ */
++
+ /**
+ * Compare two busid strings
+ *
+@@ -351,7 +401,11 @@ static int drmOpenDevice(dev_t dev, int
+ return -EINVAL;
+ };
+
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++ sprintf(buf, dev_name, DRM_DIR_NAME, minor + drmGetMinorBase(type));
++#else
+ sprintf(buf, dev_name, DRM_DIR_NAME, minor);
++#endif
+ drmMsg("drmOpenDevice: node name is %s\n", buf);
+
+ if (drm_server_info && drm_server_info->get_perms) {
+@@ -475,7 +529,11 @@ static int drmOpenMinor(int minor, int c
+ return -EINVAL;
+ };
+
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++ sprintf(buf, dev_name, DRM_DIR_NAME, minor + drmGetMinorBase(type));
++#else
+ sprintf(buf, dev_name, DRM_DIR_NAME, minor);
++#endif
+ if ((fd = open(buf, O_RDWR | O_CLOEXEC, 0)) >= 0)
+ return fd;
+ return -errno;
+@@ -519,12 +577,19 @@ drm_public int drmAvailable(void)
+ static int drmGetMinorBase(int type)
+ {
+ switch (type) {
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++ case DRM_NODE_PRIMARY:
++ case DRM_NODE_CONTROL:
++ case DRM_NODE_RENDER:
++ return type << 6;
++#else /* !__FreeBSD__ && !__DragonFly__ */
+ case DRM_NODE_PRIMARY:
+ return 0;
+ case DRM_NODE_CONTROL:
+ return 64;
+ case DRM_NODE_RENDER:
+ return 128;
++#endif /* __FreeBSD__ || __DragonFly__ */
+ default:
+ return -1;
+ };
+@@ -547,6 +612,7 @@ static int drmGetMinorType(int minor)
+ }
+ }
+
++#ifdef __linux__
+ static const char *drmGetMinorName(int type)
+ {
+ switch (type) {
+@@ -560,6 +626,7 @@ static const char *drmGetMinorName(int t
+ return NULL;
+ }
+ }
++#endif /* __linux__ */
+
+ /**
+ * Open the device by bus ID.
+@@ -2779,12 +2846,29 @@ static bool drmNodeIsDRM(int maj, int mi
+ maj, min);
+ return stat(path, &sbuf) == 0;
+ #else
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++ return !DRM_MAJOR || maj == DRM_MAJOR;
++#else
+ return maj == DRM_MAJOR;
+ #endif
++#endif
+ }
+
+ drm_public int drmGetNodeTypeFromFd(int fd)
+ {
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++ char *name = drmGetDeviceNameFromFd2(fd);
++ if (!name) {
++ errno = ENODEV;
++ return -1;
++ }
++
++ int type = drmGetNodeType(name);
++ free(name);
++ if (type < 0)
++ errno = ENODEV;
++ return type;
++#else
+ struct stat sbuf;
+ int maj, min, type;
+
+@@ -2803,6 +2887,7 @@ drm_public int drmGetNodeTypeFromFd(int
+ if (type == -1)
+ errno = ENODEV;
+ return type;
++#endif
+ }
+
+ drm_public int drmPrimeHandleToFD(int fd, uint32_t handle, uint32_t flags,
+@@ -2881,6 +2966,25 @@ static char *drmGetMinorNameForFD(int fd
+
+ closedir(sysdir);
+ return NULL;
++#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++ const char *dev_name = drmGetDeviceName(type);
++ if (!dev_name)
++ return NULL;
++
++ char *name = drmGetDeviceNameFromFd2(fd);
++ if (!name)
++ return NULL;
++
++ int oldnum = drmGetNodeNumber(name);
++ int oldtype = drmGetMinorType(oldnum);
++ if (oldtype < 0) {
++ free(name);
++ return NULL;
++ }
++
++ int newnum = oldnum - drmGetMinorBase(oldtype) + drmGetMinorBase(type);
++ snprintf(name, DRM_NODE_NAME_MAX, dev_name, DRM_DIR_NAME, newnum);
++ return name;
+ #else
+ struct stat sbuf;
+ char buf[PATH_MAX + 1];
+@@ -3014,7 +3118,66 @@ static int drmParseSubsystemType(int maj
+ }
+
+ return -EINVAL;
+-#elif defined(__OpenBSD__) || defined(__DragonFly__)
++#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(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(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
+ return DRM_BUS_PCI;
+ #else
+ #warning "Missing implementation of drmParseSubsystemType"
+@@ -3022,6 +3185,7 @@ static int drmParseSubsystemType(int maj
+ #endif
+ }
+
++#ifdef __linux__
+ static void
+ get_pci_path(int maj, int min, char *pci_path)
+ {
+@@ -3037,8 +3201,14 @@ get_pci_path(int maj, int min, char *pci
+ if (term && strncmp(term, "/virtio", 7) == 0)
+ *term = 0;
+ }
++#endif
+
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++static int drmParsePciBusInfo(const char *node, int node_type,
++ int maj, int min, drmPciBusInfoPtr info)
++#else
+ static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info)
++#endif
+ {
+ #ifdef __linux__
+ unsigned int domain, bus, dev, func;
+@@ -3063,7 +3233,74 @@ static int drmParsePciBusInfo(int maj, i
+ info->func = func;
+
+ return 0;
+-#elif defined(__OpenBSD__) || defined(__DragonFly__)
++#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(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__)
+ struct drm_pciinfo pinfo;
+ int fd, type;
+
+@@ -3087,6 +3324,61 @@ static int drmParsePciBusInfo(int maj, i
+ info->func = pinfo.func;
+
+ return 0;
++#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++ /*
++ * Only the primary nodes can be mapped to hw.dri.%i via major/minor
++ * Determine the primary node by offset and use its major/minor pair
++ */
++ if (node_type != DRM_NODE_PRIMARY) {
++ char name[DRM_NODE_NAME_MAX];
++ snprintf(name, sizeof(name), DRM_DEV_NAME, DRM_DIR_NAME,
++ drmGetNodeNumber(node) - drmGetMinorBase(node_type));
++
++ stat_t sbuf;
++ if (stat(name, &sbuf))
++ return -errno;
++
++ maj = major(sbuf.st_rdev);
++ min = minor(sbuf.st_rdev);
++
++ }
++ /*
++ * Major/minor appear after the driver name in the hw.dri.%i.name node
++ * Find the node with matching major/minor pair and parse the bus ID,
++ * which may be after the name or may be alone in hw.dri.%i.busid
++ */
++ #define bus_fmt "pci:%04x:%02x:%02x.%u"
++ #define name_fmt "%*s %x " bus_fmt
++ for (int i = 0; i < DRM_MAX_MINOR; ++i) {
++ char name[16], 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 rdev = 0, domain = 0, bus = 0, slot = 0, func = 0;
++ int vals = sscanf(value, name_fmt, &rdev, &domain, &bus, &slot, &func);
++
++ if (vals >= 1 && rdev == makedev(maj,min)) {
++ if (vals < 5) {
++ /* 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))
++ break;
++ value[length] = '\0';
++ if (sscanf(value, bus_fmt, &domain, &bus, &slot, &func) != 4)
++ break;
++ }
++ info->domain = domain;
++ info->bus = bus;
++ info->dev = slot;
++ info->func = func;
++ return 0;
++ }
++ }
++ return -ENODEV;
+ #else
+ #warning "Missing implementation of drmParsePciBusInfo"
+ return -EINVAL;
+@@ -3135,7 +3427,11 @@ static int drmGetNodeType(const char *na
+ sizeof(DRM_RENDER_MINOR_NAME) - 1) == 0)
+ return DRM_NODE_RENDER;
+
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++ return -1;
++#else /* !__FreeBSD__ || __DragonFly__ */
+ return -EINVAL;
++#endif /* __FreeBSD__ || __DragonFly__ */
+ }
+
+ static int drmGetMaxNodeName(void)
+@@ -3218,6 +3514,9 @@ static int parse_config_sysfs_file(int m
+ #endif
+
+ static int drmParsePciDeviceInfo(int maj, int min,
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++ drmPciBusInfoPtr info,
++#endif
+ drmPciDeviceInfoPtr device,
+ uint32_t flags)
+ {
+@@ -3229,7 +3528,49 @@ static int drmParsePciDeviceInfo(int maj
+ return parse_config_sysfs_file(maj, min, device);
+
+ return 0;
+-#elif defined(__OpenBSD__) || defined(__DragonFly__)
++#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__)
+ struct drm_pciinfo pinfo;
+ int fd, type;
+
+@@ -3254,6 +3595,43 @@ static int drmParsePciDeviceInfo(int maj
+ device->subdevice_id = pinfo.subdevice_id;
+
+ return 0;
++#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++ struct pci_conf_io pc;
++ struct pci_match_conf patterns[1];
++ struct pci_conf results[1];
++
++ int fd = open("/dev/pci", O_RDONLY, 0);
++ if (fd < 0)
++ return -errno;
++
++ bzero(&patterns, sizeof(patterns));
++ patterns[0].pc_sel.pc_domain = info->domain;
++ patterns[0].pc_sel.pc_bus = info->bus;
++ patterns[0].pc_sel.pc_dev = info->dev;
++ patterns[0].pc_sel.pc_func = info->func;
++ patterns[0].flags = PCI_GETCONF_MATCH_DOMAIN | PCI_GETCONF_MATCH_BUS
++ | PCI_GETCONF_MATCH_DEV | PCI_GETCONF_MATCH_FUNC;
++ bzero(&pc, sizeof(struct pci_conf_io));
++ pc.num_patterns = 1;
++ pc.pat_buf_len = sizeof(patterns);
++ pc.patterns = patterns;
++ pc.match_buf_len = sizeof(results);
++ pc.matches = results;
++
++ if (ioctl(fd, PCIOCGETCONF, &pc) || pc.status == PCI_GETCONF_ERROR) {
++ int error = errno;
++ close(fd);
++ return -error;
++ }
++ close(fd);
++
++ device->vendor_id = results[0].pc_vendor;
++ device->device_id = results[0].pc_device;
++ device->subvendor_id = results[0].pc_subvendor;
++ device->subdevice_id = results[0].pc_subdevice;
++ device->revision_id = results[0].pc_revid;
++
++ return 0;
+ #else
+ #warning "Missing implementation of drmParsePciDeviceInfo"
+ return -EINVAL;
+@@ -3380,18 +3758,42 @@ static int drmProcessPciDevice(drmDevice
+
+ dev->businfo.pci = (drmPciBusInfoPtr)addr;
+
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++ ret = drmParsePciBusInfo(node, node_type, maj, min, dev->businfo.pci);
++#else
+ ret = drmParsePciBusInfo(maj, min, dev->businfo.pci);
++#endif
+ if (ret)
+ goto free_device;
+
++ drmMsg("[drm] drmProcessPciDevice: DOMAIN (%04x)\n", dev->businfo.pci->domain);
++ drmMsg("[drm] drmProcessPciDevice: BUS (%02x)\n", dev->businfo.pci->bus);
++ drmMsg("[drm] drmProcessPciDevice: DEV (%02x)\n", dev->businfo.pci->dev);
++ drmMsg("[drm] drmProcessPciDevice: FUNC (%1u)\n", dev->businfo.pci->func);
++
+ // Fetch the device info if the user has requested it
+ if (fetch_deviceinfo) {
+ addr += sizeof(drmPciBusInfo);
+ dev->deviceinfo.pci = (drmPciDeviceInfoPtr)addr;
+
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++ ret = drmParsePciDeviceInfo(maj, min, dev->businfo.pci, dev->deviceinfo.pci, flags);
++#else
+ ret = drmParsePciDeviceInfo(maj, min, dev->deviceinfo.pci, flags);
++#endif
+ if (ret)
+ goto free_device;
++
++ drmMsg("[drm] drmProcessPciDevice: VENDOR (%04x)\n",
++ dev->deviceinfo.pci->vendor_id);
++ drmMsg("[drm] drmProcessPciDevice: DEVICE (%04x)\n",
++ dev->deviceinfo.pci->device_id);
++ drmMsg("[drm] drmProcessPciDevice: SUBVENDOR (%04x)\n",
++ dev->deviceinfo.pci->subvendor_id);
++ drmMsg("[drm] drmProcessPciDevice: SUBDEVICE (%04x)\n",
++ dev->deviceinfo.pci->subdevice_id);
++ drmMsg("[drm] drmProcessPciDevice: REVISION (%02x)\n",
++ dev->deviceinfo.pci->revision_id);
+ }
+
+ *device = dev;
+@@ -4099,6 +4501,23 @@ drm_public char *drmGetDeviceNameFromFd2
+ free(value);
+
+ return strdup(path);
++#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++ stat_t sbuf;
++ if (fstat(fd, &sbuf))
++ return NULL;
++
++ dev_t rdev = sbuf.st_rdev;
++ /* minor numbers don't depend on node name suffix, search for a match */
++ for (int i = 0; i < DRM_MAX_MINOR; ++i) {
++ char node[DRM_NODE_NAME_MAX];
++ for (int j = 0; j < DRM_NODE_MAX; ++j) {
++ snprintf(node, sizeof(node), drmGetDeviceName(j),
++ DRM_DIR_NAME, drmGetMinorBase(j) + i);
++ if (stat(node, &sbuf) == 0 && sbuf.st_rdev == rdev)
++ return strdup(node);
++ }
++ }
++ return NULL;
+ #else
+ struct stat sbuf;
+ char node[PATH_MAX + 1];
diff --git a/libdrm-dfbsd/patches/patch-xf86drmMode.c b/libdrm-dfbsd/patches/patch-xf86drmMode.c
index 582487f40e..88fcd336c9 100644
--- a/libdrm-dfbsd/patches/patch-xf86drmMode.c
+++ b/libdrm-dfbsd/patches/patch-xf86drmMode.c
@@ -1,19 +1,14 @@
-$NetBSD: patch-xf86drmMode.c,v 1.2 2015/04/11 10:02:11 sevan Exp $
-
-Replace patch disabling checking for hw.dri.%d.modesetting on FreeBSD.
-This sysctl is only available if a KMS module is loaded.
-xf86-video-intel if checking for modesetting fails the first time
-tries to load the kernel module and then check again for modesetting.
-
-Use patch from FreeBSD ports / DragonFly dports graphics/libdrm 2.4.84.
+$NetBSD: patch-xf86drmMode.c,v 1.5 2019/01/19 13:21:29 tnn Exp $
+
+FreeBSD/DragonFly/NetBSD support. From FreeBSD ports and NetBSD xsrc
-Get rid of drmModeSetPlane patch (from NetBSD?)
+FreeBSD ports / DragonFly dports does not have patch for drmModeSetPlane.
Android deliberately uses signed crtc_x and crtc_y
"to allow a destination location that is partially off screen."
---- xf86drmMode.c.orig 2017-11-03 16:44:27.000000000 +0000
+--- xf86drmMode.c.orig 2018-10-16 14:49:03.000000000 +0000
+++ xf86drmMode.c
-@@ -47,6 +47,9 @@
+@@ -43,6 +43,9 @@
#include <stdlib.h>
#include <sys/ioctl.h>
#ifdef HAVE_SYS_SYSCTL_H
@@ -23,7 +18,7 @@ Android deliberately uses signed crtc_x and crtc_y
#include <sys/sysctl.h>
#endif
#include <stdio.h>
-@@ -796,43 +799,75 @@ int drmCheckModesettingSupported(const c
+@@ -799,42 +802,60 @@ drm_public int drmCheckModesettingSuppor
closedir(sysdir);
if (found)
return 0;
@@ -33,15 +28,8 @@ Android deliberately uses signed crtc_x and crtc_y
- int domain, bus, dev, func;
- int i, modesetting, ret;
- size_t len;
--
-- ret = sscanf(busid, "pci:%04x:%02x:%02x.%d", &domain, &bus, &dev,
-- &func);
-- if (ret != 4)
-- return -EINVAL;
-- snprintf(kbusid, sizeof(kbusid), "pci:%04x:%02x:%02x.%d", domain, bus,
-- dev, func);
-+#elif defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined(__DragonFly__)
-+ #define bus_fmt "pci:%04x:%02x:%02x.%d"
++#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)
@@ -53,10 +41,25 @@ Android deliberately uses signed crtc_x and crtc_y
+ 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.%d.name", i);
++ snprintf(name, sizeof(name), "hw.dri.%i.name", i);
+ if (sysctlbyname(name, value, &length, NULL, 0))
+ continue;
+- ret = sscanf(busid, "pci:%04x:%02x:%02x.%d", &domain, &bus, &dev,
+- &func);
+- if (ret != 4)
+- return -EINVAL;
+- snprintf(kbusid, sizeof(kbusid), "pci:%04x:%02x:%02x.%d", domain, bus,
+- dev, func);
++ 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;
+
- /* How many GPUs do we expect in the machine ? */
- for (i = 0; i < 16; i++) {
- snprintf(oid, sizeof(oid), "hw.dri.%d.busid", i);
@@ -64,23 +67,14 @@ Android deliberately uses signed crtc_x and crtc_y
- ret = sysctlbyname(oid, sbusid, &len, NULL, 0);
- if (ret == -1) {
- if (errno == ENOENT)
-+ 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.%d.busid", i);
-+ if (sysctlbyname(name, value, &length, NULL, 0))
- continue;
-- return -EINVAL;
-+
+ value[length] = '\0';
+ if (sscanf(value, bus_fmt, &d2, &b2, &s2, &f2) != 4)
-+ continue;
+ 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)) {
++ 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
@@ -110,24 +104,21 @@ Android deliberately uses signed crtc_x and crtc_y
- return (modesetting ? 0 : -ENOSYS);
}
-#elif defined(__DragonFly__)
-+#elif 0 && defined(__DragonFly__)
- return 0;
--#endif
--#ifdef __OpenBSD__
-+#elif defined(__NetBSD__)
-+ int fd;
-+ static const struct drm_mode_card_res zero_res;
-+ struct drm_mode_card_res res = zero_res;
-+ int ret;
-+
-+ fd = drmOpen(NULL, busid);
-+ if (fd == -1)
-+ return -EINVAL;
-+ ret = drmIoctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &res);
-+ drmClose(fd);
-+ if (ret == 0)
-+ return 0;
-+#elif defined(__OpenBSD__)
+- return 0;
+-#elif defined(__OpenBSD__)
++#elif defined(__OpenBSD__) || defined(__NetBSD__)
int fd;
struct drm_mode_card_res res;
drmModeResPtr r = 0;
+@@ -987,7 +1008,11 @@ 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,
++#if !defined(__FreeBSD__) && !defined(__DragonFly__)
++ uint32_t crtc_x, uint32_t crtc_y,
++#else
+ int32_t crtc_x, int32_t crtc_y,
++#endif
+ 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-dfbsd/patches/patch-xf86drmMode.h b/libdrm-dfbsd/patches/patch-xf86drmMode.h
new file mode 100644
index 0000000000..0a7ac6a007
--- /dev/null
+++ b/libdrm-dfbsd/patches/patch-xf86drmMode.h
@@ -0,0 +1,20 @@
+$NetBSD: patch-xf86drmMode.h,v 1.1 2014/10/26 10:20:10 wiz Exp $
+
+FreeBSD ports / DragonFly dports does not have patch for drmModeSetPlane.
+Android deliberately uses signed crtc_x and crtc_y
+"to allow a destination location that is partially off screen."
+
+--- xf86drmMode.h.orig 2014-06-14 12:33:26.000000000 +0000
++++ xf86drmMode.h
+@@ -485,7 +485,11 @@ 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,
++#if !defined(__FreeBSD__) && !defined(__DragonFly__)
++ uint32_t crtc_x, uint32_t crtc_y,
++#else
+ int32_t crtc_x, int32_t crtc_y,
++#endif
+ 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