pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

modular-xorg-server-dfbsd-meson: Import modular-xorg-server git meson as wip/modular-xorg-server-dfbsd



Module Name:	pkgsrc-wip
Committed By:	David Shao <davshao%gmail.com@localhost>
Pushed By:	dshao
Date:		Wed Feb 27 15:23:58 2019 -0800
Changeset:	d20016d6dbc1a1ce0cfe2eecdbb91eec1f1c7f91

Modified Files:
	Makefile
Added Files:
	modular-xorg-server-dfbsd-meson/DESCR
	modular-xorg-server-dfbsd-meson/MESSAGE
	modular-xorg-server-dfbsd-meson/Makefile
	modular-xorg-server-dfbsd-meson/Makefile.common
	modular-xorg-server-dfbsd-meson/PLIST
	modular-xorg-server-dfbsd-meson/TODO
	modular-xorg-server-dfbsd-meson/buildlink3.mk
	modular-xorg-server-dfbsd-meson/distinfo
	modular-xorg-server-dfbsd-meson/options.mk
	modular-xorg-server-dfbsd-meson/patches/patch-config_config-backends.h
	modular-xorg-server-dfbsd-meson/patches/patch-config_config.c
	modular-xorg-server-dfbsd-meson/patches/patch-config_devd.c
	modular-xorg-server-dfbsd-meson/patches/patch-config_meson.build
	modular-xorg-server-dfbsd-meson/patches/patch-glamor_glamor__egl.c
	modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_common_xf86AutoConfig.c
	modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_common_xf86Config.c
	modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_common_xf86Globals.c
	modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_common_xf86Xinput.c
	modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_common_xf86sbusBus.h
	modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_dri2_dri2.c
	modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_drivers_modesetting_drmmode__display.c
	modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_modes_xf86Cursors.c
	modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_bsd_arm__video.c
	modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_bsd_bsd__VTsw.c
	modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_bsd_bsd__init.c
	modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_bsd_i386__video.c
	modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_bsd_ppc__video.c
	modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_bus_Sbus.c
	modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_meson.build
	modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_solaris_solaris-amd64.S
	modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_xf86_OSproc.h
	modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os_support_bus_xf86Sbus.h
	modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_xorg-wrapper.c
	modular-xorg-server-dfbsd-meson/patches/patch-include_meson.build
	modular-xorg-server-dfbsd-meson/patches/patch-randr_randr.c
	modular-xorg-server-dfbsd-meson/patches/patch-randr_rrlease.c

Log Message:
modular-xorg-server-dfbsd-meson: Import modular-xorg-server git meson as wip/modular-xorg-server-dfbsd

meson build of modular-xorg-server git
Only most used xf86 build after, xf86-video-intel,ati,nouveau,vesa,wsfg
Need to manually link X to Xorg.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=d20016d6dbc1a1ce0cfe2eecdbb91eec1f1c7f91

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 Makefile                                           |   1 +
 modular-xorg-server-dfbsd-meson/DESCR              |   2 +
 modular-xorg-server-dfbsd-meson/MESSAGE            |  16 +
 modular-xorg-server-dfbsd-meson/Makefile           |  35 ++
 modular-xorg-server-dfbsd-meson/Makefile.common    | 228 ++++++++
 modular-xorg-server-dfbsd-meson/PLIST              | 211 +++++++
 modular-xorg-server-dfbsd-meson/TODO               |   9 +
 modular-xorg-server-dfbsd-meson/buildlink3.mk      |  34 ++
 modular-xorg-server-dfbsd-meson/distinfo           |  33 ++
 modular-xorg-server-dfbsd-meson/options.mk         | 155 +++++
 .../patches/patch-config_config-backends.h         |  15 +
 .../patches/patch-config_config.c                  |  25 +
 .../patches/patch-config_devd.c                    | 625 +++++++++++++++++++++
 .../patches/patch-config_meson.build               |  19 +
 .../patches/patch-glamor_glamor__egl.c             | 122 ++++
 .../patch-hw_xfree86_common_xf86AutoConfig.c       |  39 ++
 .../patches/patch-hw_xfree86_common_xf86Config.c   |  25 +
 .../patches/patch-hw_xfree86_common_xf86Globals.c  |  17 +
 .../patches/patch-hw_xfree86_common_xf86Xinput.c   |  24 +
 .../patches/patch-hw_xfree86_common_xf86sbusBus.h  |  24 +
 .../patches/patch-hw_xfree86_dri2_dri2.c           |  40 ++
 ..._xfree86_drivers_modesetting_drmmode__display.c |  48 ++
 .../patches/patch-hw_xfree86_modes_xf86Cursors.c   |  20 +
 .../patch-hw_xfree86_os-support_bsd_arm__video.c   |  24 +
 .../patch-hw_xfree86_os-support_bsd_bsd__VTsw.c    |  26 +
 .../patch-hw_xfree86_os-support_bsd_bsd__init.c    | 103 ++++
 .../patch-hw_xfree86_os-support_bsd_i386__video.c  |  26 +
 .../patch-hw_xfree86_os-support_bsd_ppc__video.c   |  18 +
 .../patches/patch-hw_xfree86_os-support_bus_Sbus.c | 172 ++++++
 .../patch-hw_xfree86_os-support_meson.build        |  22 +
 ...h-hw_xfree86_os-support_solaris_solaris-amd64.S |  62 ++
 .../patch-hw_xfree86_os-support_xf86_OSproc.h      |  15 +
 .../patch-hw_xfree86_os_support_bus_xf86Sbus.h     |  15 +
 .../patches/patch-hw_xfree86_xorg-wrapper.c        |  37 ++
 .../patches/patch-include_meson.build              |  33 ++
 .../patches/patch-randr_randr.c                    |  91 +++
 .../patches/patch-randr_rrlease.c                  |  55 ++
 37 files changed, 2466 insertions(+)

diffs:
diff --git a/Makefile b/Makefile
index d66f920c7f..3cbee5541c 100644
--- a/Makefile
+++ b/Makefile
@@ -2162,6 +2162,7 @@ SUBDIR+=	mnogosearch
 SUBDIR+=	modglue
 SUBDIR+=	modplugplay
 SUBDIR+=	modular-xorg-server-dfbsd
+SUBDIR+=	modular-xorg-server-dfbsd-meson
 SUBDIR+=	moe
 SUBDIR+=	monajat
 SUBDIR+=	monkey-bubble
diff --git a/modular-xorg-server-dfbsd-meson/DESCR b/modular-xorg-server-dfbsd-meson/DESCR
new file mode 100644
index 0000000000..232af8063f
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/DESCR
@@ -0,0 +1,2 @@
+The X.org X11 Server from the modularized source tree of
+X.org X11.
diff --git a/modular-xorg-server-dfbsd-meson/MESSAGE b/modular-xorg-server-dfbsd-meson/MESSAGE
new file mode 100644
index 0000000000..095b3c63b0
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/MESSAGE
@@ -0,0 +1,16 @@
+===========================================================================
+$NetBSD: MESSAGE,v 1.1 2014/12/29 07:55:23 dholland Exp $
+
+For the X server to run you need at least some fonts installed. The
+recommended approach is to install the entire modular-xorg-fonts
+meta-package, but failing that the minimum set required is:
+
+	fonts/font-alias
+	fonts/font-misc-misc
+	fonts/font-cursor-misc
+
+This package does *not* depend on these font packages directly as
+in some circumstances installing extra copies from pkgsrc would be
+redundant or possibly harmful.
+
+===========================================================================
diff --git a/modular-xorg-server-dfbsd-meson/Makefile b/modular-xorg-server-dfbsd-meson/Makefile
new file mode 100644
index 0000000000..6835986f99
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/Makefile
@@ -0,0 +1,35 @@
+# $NetBSD: Makefile,v 1.117 2018/10/26 10:20:12 maya Exp $
+
+DISTNAME=	xorg-server-${XORG_VERSION}
+PKGNAME=	modular-${DISTNAME}
+# PKGREVISION=	1
+
+MAINTAINER=	pkgsrc-users%NetBSD.org@localhost
+COMMENT=	Modular X11 server from modular X.org
+
+SPECIAL_PERMS+=		bin/Xorg ${SETUID_ROOT_PERMS}
+
+NOT_FOR_PLATFORM=	Darwin-*-*
+
+.include "Makefile.common"
+
+CONFIGURE_ARGS+=	--enable-xorg
+CONFIGURE_ARGS+=	--disable-xephyr
+CONFIGURE_ARGS+=	--disable-kdrive
+CONFIGURE_ARGS.SunOS+=	--disable-input-thread
+# MESON_ARGS+=	-Dxorg=true
+MESON_ARGS+=	-Dxephyr=false
+.if ${OPSYS} == "SunOS"
+MESON_ARGS+=	-Dinput_thread=false
+.endif
+
+.include "options.mk"
+
+# Autotools
+# pre-configure:
+#	cd ${WRKSRC} && autoreconf -vif
+
+# Meson
+.include "../../devel/py-meson/build.mk"
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/modular-xorg-server-dfbsd-meson/Makefile.common b/modular-xorg-server-dfbsd-meson/Makefile.common
new file mode 100644
index 0000000000..0f40604831
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/Makefile.common
@@ -0,0 +1,228 @@
+# $NetBSD: Makefile.common,v 1.26 2018/10/25 22:40:57 maya Exp $
+# used by x11/modular-xorg-server/Makefile
+# used by x11/modular-xorg-xephyr/Makefile
+
+# 2019-02-25	os-support/solaris: Set IOPL for input thread too
+COMMIT_ID=	12769c516d9356bd92f90e2f53a4853dbfdc4aed
+
+# 2019-01-30	ramdac: Remove core ramdac code
+# COMMIT_ID=	8f8d358bad2d33de36686e8405ade8b5b921cafd
+
+PORTNAME=	xserver
+
+DISTNAME=	${PORTNAME}-${COMMIT_ID}
+PKGNAME=	modular-xorg-server-1.20.4
+# PKGREVISION=	2
+CATEGORIES=	x11
+MASTER_SITES=	http://cgit.freedesktop.org/xorg/${PORTNAME}/snapshot/
+EXTRACT_SUFX=	.tar.xz
+
+# XORG_VERSION=	1.20.3
+# CATEGORIES=	x11
+# MASTER_SITES=	${MASTER_SITE_XORG:=xserver/}
+# EXTRACT_SUFX=	.tar.bz2
+
+HOMEPAGE=	http://xorg.freedesktop.org/
+LICENSE=	mit AND modified-bsd AND x11 # with no-advertising clause
+
+# GNU_CONFIGURE=	yes
+# USE_LIBTOOL=	yes
+# USE_TOOLS+=	gmake pkg-config autoconf automake autoreconf
+USE_TOOLS+=	gmake pkg-config
+USE_LANGUAGES+=	c99
+
+PKGCONFIG_OVERRIDE+=	xorg-server.pc.in
+SHLIBTOOL_OVERRIDE=	# empty
+
+BUILD_DEFS+=		VARBASE
+BUILD_DEFS_EFFECTS+=	XKB_OUTPUT_DIR
+
+OWN_DIRS+=		${VARBASE}/log
+OWN_DIRS+=		${XKB_OUTPUT_DIR}
+XKB_OUTPUT_DIR?=	${VARBASE}/db/xkb # XXX sync with xkeyboard-config
+
+CONFIGURE_ARGS+=	--localstatedir=${VARBASE:Q}
+CONFIGURE_ARGS+=	--with-xkb-output=${XKB_OUTPUT_DIR:Q}
+MESON_ARGS+=		-Dlog_dir=${VARBASE:Q}/log
+MESON_ARGS+=		-Dxkb_output_dir=${XKB_OUTPUT_DIR:Q}
+
+.if !empty(USE_TOOLS:Mauto*)
+TOOLS_DEPENDS+=	xorg-util-macros>=1.1.5:../../devel/xorg-util-macros
+.endif
+
+DEPENDS+=	xkbcomp-[0-9]*:../../x11/xkbcomp
+DEPENDS+=	xkeyboard-config-[0-9]*:../../x11/xkeyboard-config
+
+.include "../../mk/bsd.prefs.mk"
+
+.if ${OPSYS} == "NetBSD"
+CPPFLAGS+=		-D_OPENBSD_SOURCE	# for reallocarray(3)
+CONFIGURE_ARGS+=	--with-builder-addr="tech-x11%NetBSD.org@localhost"
+CONFIGURE_ARGS+=	--with-os-vendor="The NetBSD Foundation"
+MESON_ARGS+=		-Dbuilder_addr="tech-x11%NetBSD.org@localhost"
+MESON_ARGS+=		-Dbuilder_string="The NetBSD Foundation"
+# TLS is not supported by NetBSD<6
+.  if !empty(OS_VERSION:M[0-5].*)
+CONFIGURE_ENV+=		ac_cv_tls=no
+CONFIGURE_ARGS+=	--disable-glx-tls
+.  endif
+.endif
+CONFIGURE_ARGS+=	--with-os-name=${MACHINE_PLATFORM:Q}
+
+CONFIGURE_ARGS+=	--with-fontrootdir=${PREFIX}/share/fonts/X11
+
+LEGACY_FONT_PATHS=
+DEFAULT_FONT_PATHS=
+.for f in misc TTF OTF Type1 100dpi 75dpi cyrillic
+DEFAULT_FONT_PATHS+=	${PREFIX}/share/fonts/X11/${f}
+LEGACY_FONT_PATHS+=	${PREFIX}/lib/X11/fonts/${f}
+.endfor
+FONT_PATHS=		${DEFAULT_FONT_PATHS} ${LEGACY_FONT_PATHS}
+
+CONFIGURE_ARGS+=	--with-default-font-path=${FONT_PATHS:ts,:Q}
+MESON_ARGS+=		-Ddefault_font_path=${FONT_PATHS:ts,:Q}
+
+CONFIGURE_ARGS+=	--disable-config-hal
+CONFIGURE_ARGS+=	--disable-dmx
+MESON_ARGS+=		-Dhal=false
+MESON_ARGS+=		-Ddmx=false
+.if ${OPSYS} != "FreeBSD" &&  ${OPSYS} != "DragonFly"
+CONFIGURE_ARGS+=	--disable-xwin
+MESON_ARGS+=		-Dxwin=false
+.endif
+CONFIGURE_ARGS+=	--disable-xephyr
+MESON_ARGS+=		-Dxephyr=false
+
+.if ${OPSYS} != "FreeBSD" &&  ${OPSYS} != "DragonFly"
+CONFIGURE_ARGS+=	--disable-kdrive
+#CONFIGURE_ARGS+=	--disable-kdrive-vesa
+CONFIGURE_ARGS+=	--enable-xtrans-send-fds
+
+CONFIGURE_ARGS+=	--with-int10=x86emu
+MESON_ARGS+=		-Dint10=x86emu
+.endif
+
+.if ${OPSYS} != "Linux"
+MESON_ARGS+=		-Dudev=false
+MESON_ARGS+=		-Dxwayland=false
+.endif
+
+# From FreeBSD ports
+# .if ${OPSYS} == "FreeBSD" ||  ${OPSYS} == "DragonFly"
+.if ${OPSYS} == "FreeBSD"
+CONFIGURE_ARGS+=	--with-shared-memory-dir=/tmp
+CONFIGURE_ARGS+=	--disable-config-udev
+CONFIGURE_ARGS+=	--disable-config-udev-kms
+# CONFIGURE_ARGS+=	--disable-xnest
+# CONFIGURE_ARGS+=	--disable-xvfb
+CONFIGURE_ARGS+=	--disable-xwayland
+CONFIGURE_ARGS+=	--enable-xcsecurity
+# MESON_ARGS+=		-Dudev=false
+# MESON_ARGS+=		-Dxwayland=false
+MESON_ARGS+=		-Dxcsecurity=true
+.endif
+
+# FreeBSD ports devel/libunwind not ported to pkgsrc
+# .if ${OPSYS} == "FreeBSD" ||  ${OPSYS} == "DragonFly"
+# CONFIGURE_ARGS+=	--disable-libunwind
+# .endif
+
+CONFIGURE_ENV+=		APP_MAN_SUFFIX=1 FILE_MAN_SUFFIX=5
+CONFIGURE_ENV+=		DRIVER_MAN_SUFFIX=4
+
+PLIST_VARS+=		sunos
+PLIST_SUBST+=		SUNOS_ARCH=${SUNOS_ARCH}
+
+.if ${OPSYS} == "SunOS"
+PLIST.sunos=		yes
+.  if ${MACHINE_ARCH} == "i386"
+SUNOS_ARCH=		ia32
+.  elif ${MACHINE_ARCH} == "x86_64"
+SUNOS_ARCH=		amd64
+.  elif ${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64"
+SUNOS_ARCH=		sparcv8plus
+.  endif
+.endif
+
+PLIST_VARS+=		sparc
+.if !empty(MACHINE_ARCH:Msparc*)
+PLIST.sparc=		yes
+.endif
+
+# Workaround for PR#41556.
+# Avoid to use bsd_kqueue_apm, force to use bsd_apm instead.
+CONFIGURE_ENV.NetBSD+=	ac_cv_header_sys_event_h=no
+
+# Avoid picking up epoll on illumos
+CONFIGURE_ENV.SunOS+=	ac_cv_func_epoll_create1=no
+
+# Only available in newer releases
+CONFIGURE_ENV.SunOS+=	ac_cv_func_mkostemp=no
+
+# Avoid secure-rpc on NetBSD
+.if ${OPSYS} == "NetBSD"
+MESON_ARGS+=	-Dsecure-rpc=false
+.endif
+
+.if ${OPSYS} == "FreeBSD" || ${OPSYS} == "DragonFly"
+# Workaround glamor lockups when drm-devel-kmod (4.15-4.17) is installed
+# with partial reverting of commit
+# 86b2d8740a330deafe8a9bbf0402705a43efbb42
+SUBST_CLASSES+=		glamor
+SUBST_STAGE.glamor=	pre-configure
+SUBST_MESSAGE.glamor=	Workaround glamor lockups
+SUBST_FILES.glamor=	glamor/glamor_egl.c
+SUBST_SED.glamor=	-e '/glamor_make_pixmap_exportable/s,FALSE,TRUE,g'
+.endif
+
+INSTALLATION_DIRS+=	lib/xorg/modules/drivers lib/xorg/modules/input
+
+BUILDLINK_API_DEPENDS.MesaLib+=		MesaLib>=7.8.0
+BUILDLINK_API_DEPENDS.xtrans+=		xtrans>=1.2.2
+BUILDLINK_API_DEPENDS.dri+=		dri>=7.8
+BUILDLINK_API_DEPENDS.xfont+=		xfont>=1.4.2
+BUILDLINK_API_DEPENDS.pixman+=		pixman>=0.21.8
+
+BUILD_DEPENDS+=		tradcpp-[0-9]*:../../devel/tradcpp
+CONFIGURE_ENV+=		ac_cv_path_RAWCPP="${PREFIX}/bin/tradcpp -Uunix"
+
+# .if ${OPSYS} == "OpenBSD" || ${OPSYS} == "Bitrig" || ${OPSYS} == "MirBSD"
+# CONFIGURE_ARGS+=	--with-sha1=libc
+# .else
+.include "../../security/nettle/buildlink3.mk"
+# CONFIGURE_ARGS+=	--with-sha1=libnettle
+# .endif
+
+.if ${OPSYS} == "FreeBSD"
+CFLAGS+=	-Wno-missing-braces
+.endif
+
+.include "../../devel/ncurses/buildlink3.mk"
+.include "../../devel/zlib/buildlink3.mk"
+.include "../../fonts/libfontenc/buildlink3.mk"
+BUILDLINK_API_DEPENDS.libpciaccess+=	libpciaccess>=0.11.0
+BUILDLINK_DEPMETHOD.libpciaccess=	full
+.include "../../sysutils/libpciaccess/buildlink3.mk"
+BUILDLINK_API_DEPENDS.xorgproto+=	xorgproto>=2018.3
+.include "../../x11/xorgproto/buildlink3.mk"
+.include "../../x11/evieext/buildlink3.mk"
+.include "../../x11/libX11/buildlink3.mk"
+.include "../../x11/libXau/buildlink3.mk"
+.include "../../x11/libXaw/buildlink3.mk"
+BUILDLINK_API_DEPENDS.libXext+=	libXext>=1.1.1
+.include "../../x11/libXext/buildlink3.mk"
+.include "../../x11/libXfixes/buildlink3.mk"
+.include "../../x11/libXfont2/buildlink3.mk"
+.include "../../x11/libXt/buildlink3.mk"
+.include "../../x11/libXxf86misc/buildlink3.mk"
+.include "../../x11/libXxf86vm/buildlink3.mk"
+.include "../../x11/libXinerama/buildlink3.mk"
+.include "../../x11/libxkbfile/buildlink3.mk"
+.include "../../x11/libxkbui/buildlink3.mk"
+.include "../../x11/pixman/buildlink3.mk"
+.include "../../x11/xcb-util-keysyms/buildlink3.mk"
+.include "../../x11/xtrans/buildlink3.mk"
+.include "../../fonts/font-util/buildlink3.mk"
+.include "../../mk/pthread.buildlink3.mk"
+.include "../../sysutils/dbus/buildlink3.mk"
+.include "../../x11/xkbcomp/buildlink3.mk"
diff --git a/modular-xorg-server-dfbsd-meson/PLIST b/modular-xorg-server-dfbsd-meson/PLIST
new file mode 100644
index 0000000000..00279d1e65
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/PLIST
@@ -0,0 +1,211 @@
+@comment $NetBSD: PLIST,v 1.28 2018/05/11 13:47:35 wiz Exp $
+@comment bin/X
+bin/Xnest
+bin/Xorg
+bin/Xvfb
+bin/cvt
+bin/gtf
+@comment include/xorg/BT.h
+@comment include/xorg/IBM.h
+@comment include/xorg/TI.h
+include/xorg/XIstubs.h
+include/xorg/Xprintf.h
+include/xorg/callback.h
+include/xorg/client.h
+include/xorg/closestr.h
+include/xorg/closure.h
+include/xorg/colormap.h
+include/xorg/colormapst.h
+include/xorg/compiler.h
+include/xorg/compositeext.h
+include/xorg/cursor.h
+include/xorg/cursorstr.h
+include/xorg/damage.h
+include/xorg/damagestr.h
+include/xorg/dbestruct.h
+include/xorg/dgaproc.h
+include/xorg/displaymode.h
+include/xorg/dix.h
+include/xorg/dixaccess.h
+include/xorg/dixevents.h
+include/xorg/dixfont.h
+include/xorg/dixfontstr.h
+include/xorg/dixgrabs.h
+include/xorg/dixstruct.h
+${PLIST.dri}include/xorg/dri.h
+${PLIST.dri}include/xorg/dri2.h
+${PLIST.dri3}include/xorg/dri3.h
+${PLIST.dri}include/xorg/dristruct.h
+include/xorg/edid.h
+include/xorg/events.h
+include/xorg/exa.h
+include/xorg/exevents.h
+include/xorg/extension.h
+include/xorg/extinit.h
+include/xorg/extnsionst.h
+include/xorg/fb.h
+include/xorg/fbdevhw.h
+include/xorg/fboverlay.h
+include/xorg/fbpict.h
+include/xorg/fbrop.h
+include/xorg/fourcc.h
+include/xorg/gc.h
+include/xorg/gcstruct.h
+include/xorg/geext.h
+include/xorg/geint.h
+${PLIST.dri}include/xorg/glamor.h
+include/xorg/globals.h
+include/xorg/glx_extinit.h
+include/xorg/glxvndabi.h
+include/xorg/glyphstr.h
+include/xorg/hotplug.h
+include/xorg/i2c_def.h
+include/xorg/input.h
+include/xorg/inputstr.h
+include/xorg/list.h
+include/xorg/mi.h
+include/xorg/micmap.h
+include/xorg/micoord.h
+include/xorg/migc.h
+include/xorg/miline.h
+include/xorg/mioverlay.h
+include/xorg/mipict.h
+include/xorg/mipointer.h
+include/xorg/mipointrst.h
+include/xorg/misc.h
+include/xorg/miscstruct.h
+include/xorg/mistruct.h
+include/xorg/misync.h
+include/xorg/misyncfd.h
+include/xorg/misyncshm.h
+include/xorg/misyncstr.h
+include/xorg/mizerarc.h
+include/xorg/nonsdk_extinit.h
+include/xorg/opaque.h
+include/xorg/optionstr.h
+include/xorg/os.h
+include/xorg/panoramiX.h
+include/xorg/panoramiXsrv.h
+include/xorg/picture.h
+include/xorg/picturestr.h
+include/xorg/pixmap.h
+include/xorg/pixmapstr.h
+${PLIST.dri}include/xorg/present.h
+${PLIST.dri}include/xorg/presentext.h
+include/xorg/privates.h
+include/xorg/property.h
+include/xorg/propertyst.h
+include/xorg/ptrveloc.h
+include/xorg/randrstr.h
+include/xorg/region.h
+include/xorg/regionstr.h
+include/xorg/registry.h
+include/xorg/resource.h
+include/xorg/rgb.h
+include/xorg/rrtransform.h
+${PLIST.dri}include/xorg/sarea.h
+include/xorg/screenint.h
+include/xorg/scrnintstr.h
+include/xorg/selection.h
+include/xorg/servermd.h
+include/xorg/shadow.h
+include/xorg/shadowfb.h
+include/xorg/shmint.h
+include/xorg/site.h
+${PLIST.sunos}include/xorg/solaris-${SUNOS_ARCH}.il
+include/xorg/syncsdk.h
+include/xorg/validate.h
+include/xorg/vbe.h
+include/xorg/vbeModes.h
+include/xorg/vgaHW.h
+include/xorg/vndserver.h
+include/xorg/wfbrename.h
+include/xorg/window.h
+include/xorg/windowstr.h
+include/xorg/xaarop.h
+include/xorg/xace.h
+include/xorg/xacestr.h
+include/xorg/xf86.h
+include/xorg/xf86Crtc.h
+include/xorg/xf86Cursor.h
+include/xorg/xf86DDC.h
+include/xorg/xf86MatchDrivers.h
+include/xorg/xf86Modes.h
+include/xorg/xf86Module.h
+include/xorg/xf86Opt.h
+include/xorg/xf86Optionstr.h
+include/xorg/xf86Optrec.h
+include/xorg/xf86Parser.h
+include/xorg/xf86Pci.h
+include/xorg/xf86PciInfo.h
+include/xorg/xf86Priv.h
+include/xorg/xf86Privstr.h
+@comment include/xorg/xf86RamDac.h
+include/xorg/xf86RandR12.h
+${PLIST.sparc}include/xorg/xf86Sbus.h
+include/xorg/xf86VGAarbiter.h
+include/xorg/xf86Xinput.h
+include/xorg/xf86_OSlib.h
+include/xorg/xf86_OSproc.h
+include/xorg/xf86cmap.h
+include/xorg/xf86fbman.h
+include/xorg/xf86i2c.h
+include/xorg/xf86int10.h
+include/xorg/xf86platformBus.h
+include/xorg/xf86sbusBus.h
+include/xorg/xf86str.h
+include/xorg/xf86xv.h
+include/xorg/xf86xvmc.h
+include/xorg/xf86xvpriv.h
+include/xorg/xisb.h
+include/xorg/xkbfile.h
+include/xorg/xkbrules.h
+include/xorg/xkbsrv.h
+include/xorg/xkbstr.h
+include/xorg/xorg-server.h
+include/xorg/xorgVersion.h
+include/xorg/xserver-properties.h
+include/xorg/xserver_poll.h
+include/xorg/xvdix.h
+include/xorg/xvmcext.h
+lib/pkgconfig/xorg-server.pc
+@comment ${PLIST.dri}lib/xorg/modules/drivers/modesetting_drv.la
+@comment ${PLIST.dri}lib/xorg/modules/extensions/libglx.la
+@comment lib/xorg/modules/libexa.la
+@comment lib/xorg/modules/libfb.la
+@comment lib/xorg/modules/libfbdevhw.la
+@comment ${PLIST.dri}lib/xorg/modules/libglamoregl.la
+@comment lib/xorg/modules/libint10.la
+@comment lib/xorg/modules/libshadow.la
+@comment lib/xorg/modules/libshadowfb.la
+@comment lib/xorg/modules/libvbe.la
+@comment lib/xorg/modules/libvgahw.la
+@comment lib/xorg/modules/libwfb.la
+${PLIST.dri}lib/xorg/modules/drivers/modesetting_drv.so
+${PLIST.dri}lib/xorg/modules/extensions/libglx.so
+lib/xorg/modules/libexa.so
+lib/xorg/modules/libfb.so
+lib/xorg/modules/libfbdevhw.so
+${PLIST.dri}lib/xorg/modules/libglamoregl.so
+lib/xorg/modules/libint10.so
+lib/xorg/modules/libshadow.so
+lib/xorg/modules/libshadowfb.so
+lib/xorg/modules/libvbe.so
+lib/xorg/modules/libvgahw.so
+lib/xorg/modules/libwfb.so
+lib/xorg/protocol.txt
+man/man1/Xnest.1
+man/man1/Xorg.1
+man/man1/Xserver.1
+man/man1/Xvfb.1
+man/man1/cvt.1
+man/man1/gtf.1
+man/man4/exa.4
+man/man4/fbdevhw.4
+${PLIST.dri}man/man4/modesetting.4
+man/man5/xorg.conf.5
+man/man5/xorg.conf.d.5
+share/X11/xorg.conf.d/10-quirks.conf
+share/aclocal/xorg-server.m4
+${PLIST.dtrace}share/doc/xorg-server/Xserver-DTrace.xml
+@pkgdir lib/xorg/modules/input
diff --git a/modular-xorg-server-dfbsd-meson/TODO b/modular-xorg-server-dfbsd-meson/TODO
new file mode 100644
index 0000000000..ff35145371
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/TODO
@@ -0,0 +1,9 @@
+Copy port to x11/modular-xorg-server, do not install from wip.
+
+Waiting for devd patches required on latest FreeBSD and DragonFly
+submitted in
+pkg/50200 (x11/modular-xorg-server)
+to be accepted.
+
+Port devd patches for 1.19.6 that have not been merged
+into FreeBSD ports, supports evdev.
diff --git a/modular-xorg-server-dfbsd-meson/buildlink3.mk b/modular-xorg-server-dfbsd-meson/buildlink3.mk
new file mode 100644
index 0000000000..ca0bfae550
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/buildlink3.mk
@@ -0,0 +1,34 @@
+# $NetBSD: buildlink3.mk,v 1.22 2018/05/11 13:47:35 wiz Exp $
+
+BUILDLINK_TREE+=	modular-xorg-server
+
+.if !defined(MODULAR_XORG_SERVER_BUILDLINK3_MK)
+MODULAR_XORG_SERVER_BUILDLINK3_MK:=
+
+.include "../../mk/bsd.fast.prefs.mk"
+
+USE_OLD_MODULAR_XORG_SERVER?=	no
+
+.if !empty(USE_OLD_MODULAR_XORG_SERVER:M[yY][eE][sS])
+BUILDLINK_API_DEPENDS.modular-xorg-server+=	modular-xorg-server>=1.12.4nb12<1.17
+BUILDLINK_PKGSRCDIR.modular-xorg-server?=	../../x11/modular-xorg-server112
+.else
+BUILDLINK_API_DEPENDS.modular-xorg-server+=	modular-xorg-server>=1.18
+BUILDLINK_PKGSRCDIR.modular-xorg-server?=	../../x11/modular-xorg-server
+.endif
+
+BUILDLINK_DEPMETHOD.libpciaccess=	full
+.include "../../sysutils/libpciaccess/buildlink3.mk"
+.include "../../x11/pixman/buildlink3.mk"
+
+.include "../../x11/xorgproto/buildlink3.mk"
+.if !empty(USE_OLD_MODULAR_XORG_SERVER:M[yY][eE][sS])
+.include "../../graphics/MesaLib7/buildlink3.mk" # XXX should not be needed for non-dri build
+.include "../../x11/libXfont/buildlink3.mk"
+.else
+.include "../../x11/libXfont2/buildlink3.mk"
+.include "../../graphics/MesaLib/buildlink3.mk" # XXX should not be needed for non-dri build
+.endif
+.endif # MODULAR_XORG_SERVER_BUILDLINK3_MK
+
+BUILDLINK_TREE+=	-modular-xorg-server
diff --git a/modular-xorg-server-dfbsd-meson/distinfo b/modular-xorg-server-dfbsd-meson/distinfo
new file mode 100644
index 0000000000..c06fa2216f
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/distinfo
@@ -0,0 +1,33 @@
+$NetBSD: distinfo,v 1.92 2018/10/26 10:20:12 maya Exp $
+
+SHA1 (xserver-12769c516d9356bd92f90e2f53a4853dbfdc4aed.tar.xz) = eebbf29bf4cae996a18b7f4b08e65d374634791e
+RMD160 (xserver-12769c516d9356bd92f90e2f53a4853dbfdc4aed.tar.xz) = 1e681226b67436f618bbd6637d2814580327992c
+SHA512 (xserver-12769c516d9356bd92f90e2f53a4853dbfdc4aed.tar.xz) = 907138bde5c0aaaed61848d7d7ffab4f150d5a876e0541dbc8542558d12c693a0dcc6b05cbaca7868d1b0122f12e7d2e0468fc5811cb4be49478df1c8a5e1b1a
+Size (xserver-12769c516d9356bd92f90e2f53a4853dbfdc4aed.tar.xz) = 3097256 bytes
+SHA1 (patch-config_config-backends.h) = f44868caa51e972a76949f73ac6083640af2c351
+SHA1 (patch-config_config.c) = 5a3fe4cb6c2170335ab547f438386cff77a9c152
+SHA1 (patch-config_devd.c) = d8c534837b1c448563c363465570b9dc403f19fa
+SHA1 (patch-config_meson.build) = 865a422bc018e9778b3d8d52ee1bdbe042814550
+SHA1 (patch-glamor_glamor__egl.c) = 8057778a5f0fd03c3ecd1191cff9123310396a1f
+SHA1 (patch-hw_xfree86_common_xf86AutoConfig.c) = 61c72780a65d423965225a2dd2206bcf2264c89f
+SHA1 (patch-hw_xfree86_common_xf86Config.c) = bcb413a2211ddcde0728a368e313bea841e03828
+SHA1 (patch-hw_xfree86_common_xf86Globals.c) = da35eb1c437eaffce0b8f8a3964e3a75631d8a73
+SHA1 (patch-hw_xfree86_common_xf86Xinput.c) = 5ad0c36fe68f87c853ac084640269e3b8f9370c9
+SHA1 (patch-hw_xfree86_common_xf86sbusBus.h) = f56f87336b2f669413ebb1005a2b64568a111f92
+SHA1 (patch-hw_xfree86_dri2_dri2.c) = 475ea1956f2e71d684cf1e5a8a68b30279959a04
+SHA1 (patch-hw_xfree86_drivers_modesetting_drmmode__display.c) = 61735de44b0579d0a3d2bfb0d91c72c365d1b93f
+SHA1 (patch-hw_xfree86_modes_xf86Cursors.c) = bd9870edb1196a4d2eab49b2d13fbe6eefbe4c09
+SHA1 (patch-hw_xfree86_os-support_bsd_arm__video.c) = 9c03b24f44eafc5fabe27e9d6cc6c54b607e47c3
+SHA1 (patch-hw_xfree86_os-support_bsd_bsd__VTsw.c) = 90343f694c27a6fdd5070e1167687943bd056a99
+SHA1 (patch-hw_xfree86_os-support_bsd_bsd__init.c) = 0180a25df158ce3716071882fbb55cff9fe8e5ff
+SHA1 (patch-hw_xfree86_os-support_bsd_i386__video.c) = 68889e3ae80b9536d82909855ec7156caa928374
+SHA1 (patch-hw_xfree86_os-support_bsd_ppc__video.c) = 2f5126ee47cbd66c0241e8fbf66c8af363e01fd7
+SHA1 (patch-hw_xfree86_os-support_bus_Sbus.c) = 0035b970bdae1bab51b8ca6bfeed060ec4df3a60
+SHA1 (patch-hw_xfree86_os-support_meson.build) = 9a254dbd4480a58ee1f8515d6f810d40ca6cd74a
+SHA1 (patch-hw_xfree86_os-support_solaris_solaris-amd64.S) = 088a3118deb7567194e08dd46e34cb6edba38400
+SHA1 (patch-hw_xfree86_os-support_xf86_OSproc.h) = e1c049857893d2f050d5fb297a3e8ef86f0b1d7e
+SHA1 (patch-hw_xfree86_os_support_bus_xf86Sbus.h) = 0e0a243b737f8f762c9f8f24a2265d1b6aefb544
+SHA1 (patch-hw_xfree86_xorg-wrapper.c) = d1178c088307cd3781f8989522bab570b551ff55
+SHA1 (patch-include_meson.build) = 8e7cfb8140e325279fbd8fcebc165b9ddcf4c32d
+SHA1 (patch-randr_randr.c) = eb44a07770ca7308d706aa2324408bb8c6c6b7ba
+SHA1 (patch-randr_rrlease.c) = 82ace923fe7b65f4cf1be2ff243eabd886f3109e
diff --git a/modular-xorg-server-dfbsd-meson/options.mk b/modular-xorg-server-dfbsd-meson/options.mk
new file mode 100644
index 0000000000..7115c61a58
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/options.mk
@@ -0,0 +1,155 @@
+# $NetBSD: options.mk,v 1.19 2018/05/11 13:47:35 wiz Exp $
+
+PKG_OPTIONS_VAR=	PKG_OPTIONS.modular-xorg-server
+PKG_SUPPORTED_OPTIONS=	inet6 debug dtrace
+PKG_SUPPORTED_OPTIONS+=	revert_flink
+PKG_SUPPORTED_OPTIONS+=	revert_randr_lease
+PKG_SUPPORTED_OPTIONS+= allow_unprivileged
+PKG_SUPPORTED_OPTIONS+= suid_wrapper
+PKG_SUPPORTED_OPTIONS+= xkb_evdev
+PKG_SUGGESTED_OPTIONS=	inet6
+# PKG_SUGGESTED_OPTIONS+= suid_wrapper
+
+.if ${OPSYS} == "DragonFly"
+PKG_SUGGESTED_OPTIONS+=	revert_flink
+PKG_SUGGESTED_OPTIONS+=	revert_randr_lease
+.endif
+
+.if ${OPSYS} == "NetBSD"
+PKG_SUGGESTED_OPTIONS+=	allow_unprivileged
+.endif
+
+PKG_SUPPORTED_OPTIONS+=	devd
+.if ${OPSYS} == "FreeBSD" || ${OPSYS} == "DragonFly"
+PKG_SUGGESTED_OPTIONS+= devd
+.endif
+
+.if ${X11_TYPE} == "modular"
+PKG_SUPPORTED_OPTIONS+=	dri
+PKG_SUGGESTED_OPTIONS+=	dri
+PKG_SUPPORTED_OPTIONS+=	dri3
+# dri3 requires kernel support for dma_buf
+.if ${OPSYS} == "Linux"
+PKG_SUGGESTED_OPTIONS+=	dri3
+.endif
+.endif
+
+.include "../../mk/bsd.options.mk"
+
+PLIST_VARS+=		dri dtrace
+PLIST_VARS+=		dri3
+
+.if !empty(PKG_OPTIONS:Mdri)
+
+.if !empty(PKG_OPTIONS:Mdri3)
+CONFIGURE_ARGS+=	--enable-dri3
+MESON_ARGS+=		-Ddri3=true
+PLIST.dri3=		yes
+.else
+CONFIGURE_ARGS+=	--disable-dri3
+MESON_ARGS+=		-Ddri3=false
+.endif
+
+.include "../../graphics/libepoxy/buildlink3.mk"
+BUILDLINK_API_DEPENDS.MesaLib+=	MesaLib>=11
+.include "../../graphics/MesaLib/buildlink3.mk"
+.include "../../x11/xorgproto/buildlink3.mk"
+.include "../../x11/libdrm/buildlink3.mk"
+.include "../../x11/libxshmfence/buildlink3.mk"
+PLIST.dri=		yes
+CONFIGURE_ARGS+=	--enable-dri
+CONFIGURE_ARGS+=	--enable-dri2
+CONFIGURE_ARGS+=	--enable-glx
+CONFIGURE_ARGS+=	--enable-glamor
+CONFIGURE_ARGS+=	--enable-present
+MESON_ARGS+=		-Ddri1=true
+MESON_ARGS+=		-Ddri2=true
+MESON_ARGS+=		-Dglx=true
+MESON_ARGS+=		-Dglamor=true
+.else
+###
+### XXX Perhaps we should allow for a built-in glx without dri enabled?
+###
+CONFIGURE_ARGS+=	--disable-dri
+CONFIGURE_ARGS+=	--disable-dri2
+CONFIGURE_ARGS+=	--disable-dri3
+CONFIGURE_ARGS+=	--disable-glx
+CONFIGURE_ARGS+=	--disable-glamor
+CONFIGURE_ARGS+=	--disable-present
+MESON_ARGS+=		-Ddri1=false
+MESON_ARGS+=		-Ddri2=false
+MESON_ARGS+=		-Ddri3=false
+MESON_ARGS+=		-Dglx=false
+MESON_ARGS+=		-Dglamor=false
+pre-build: disable-modesetting
+.PHONY: disable-modesetting
+disable-modesetting:
+	(${ECHO} "all:"; ${ECHO} "install:") > ${WRKSRC}/hw/xfree86/drivers/modesetting/Makefile
+.endif
+
+.if !empty(PKG_OPTIONS:Minet6)
+CONFIGURE_ARGS+=	--enable-ipv6
+MESON_ARGS+=		-Dipv6=true
+.else
+CONFIGURE_ARGS+=	--disable-ipv6
+MESON_ARGS+=		-Dipv6=false
+.endif
+
+.if !empty(PKG_OPTIONS:Mdebug)
+CONFIGURE_ARGS+=	--enable-debug
+MESON_ARGS+=		--buildtype=debug
+# Debug flags -O0 -g3 recommended by: 
+# https://www.x.org/wiki/Development/Documentation/ServerDebugging/
+# CFLAGS+=		-ggdb
+CFLAGS+=		-O0 -g3
+.endif
+
+.if !empty(PKG_OPTIONS:Mdtrace)
+PLIST.dtrace=		yes
+CONFIGURE_ARGS+=	--with-dtrace
+.else
+CONFIGURE_ARGS+=	--without-dtrace
+.endif
+
+.if !empty(PKG_OPTIONS:Mdevd)
+# SUBST_CLASSES+=			devd_config
+# SUBST_STAGE.devd_config=	post-configure	
+# SUBST_MESSAGE.devd_config=	Patching config/Makefile for devd
+# SUBST_FILES.devd_config+=	config/Makefile
+# SUBST_SED.devd_config+=		-e 's|config\.c|config.c devd.c|g'
+# SUBST_SED.devd_config+=		-e 's|config\.lo|config.lo devd.lo|g'
+# SUBST_CLASSES+=			devd_dix
+# SUBST_STAGE.devd_dix=		post-configure
+# SUBST_MESSAGE.devd_dix=		Patching include/dix-config.h for devd 
+# SUBST_FILES.devd_dix+=		include/dix-config.h	
+# SUBST_SED.devd_dix+=		-e 's|/\* \#undef CONFIG_UDEV \*/|\#define CONFIG_DEVD 1 |'
+CPPFLAGS+=			-DCONFIG_DEVD=1
+.endif
+
+.if !empty(PKG_OPTIONS:Mrevert_flink)
+CPPFLAGS+=	-DREVERT_FLINK
+.endif
+
+.if !empty(PKG_OPTIONS:Mrevert_randr_lease)
+CPPFLAGS+=	-DREVERT_RANDR_LEASE
+
+SUBST_CLASSES+=			lease
+SUBST_STAGE.lease=		post-configure
+SUBST_MESSAGE.lease=		Removing definition of XF86_LEASE_VERSION	
+SUBST_FILES.lease+=		hw/xfree86/modes/xf86Crtc.h
+SUBST_SED.lease+=		 -e 's|XF86_LEASE_VERSION|REVERT_XF86_LEASE_VERSION|g'
+.endif
+
+.if !empty(PKG_OPTIONS:Mallow_unprivileged)
+CPPFLAGS+=	-DALLOW_UNPRIVILEGED
+.endif
+
+.if !empty(PKG_OPTIONS:Msuid_wrapper)
+MESON_ARGS+=	-Dsuid_wrapper=true
+.endif
+
+.if !empty(PKG_OPTIONS:Mxkb_evdev)
+MESON_ARGS+=	-Dxkb_default_rules=evdev
+.else
+MESON_ARGS+=	-Dxkb_default_rules=base
+.endif
diff --git a/modular-xorg-server-dfbsd-meson/patches/patch-config_config-backends.h b/modular-xorg-server-dfbsd-meson/patches/patch-config_config-backends.h
new file mode 100644
index 0000000000..e92f688496
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/patches/patch-config_config-backends.h
@@ -0,0 +1,15 @@
+$NetBSD$
+
+devd support to detect devices from FreeBSD ports / DragonFly dports
+
+--- config/config-backends.h.orig	2015-05-21 14:23:54.000000000 +0000
++++ config/config-backends.h
+@@ -44,3 +44,8 @@ void config_hal_fini(void);
+ int config_wscons_init(void);
+ void config_wscons_fini(void);
+ #endif
++
++#ifdef CONFIG_DEVD
++int config_devd_init(void);
++void config_devd_fini(void);
++#endif
diff --git a/modular-xorg-server-dfbsd-meson/patches/patch-config_config.c b/modular-xorg-server-dfbsd-meson/patches/patch-config_config.c
new file mode 100644
index 0000000000..1990a502bf
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/patches/patch-config_config.c
@@ -0,0 +1,25 @@
+$NetBSD$
+
+devd support to detect devices from FreeBSD ports / DragonFly dports
+
+--- config/config.c.orig	2015-07-18 23:39:56.348775000 +0000
++++ config/config.c
+@@ -55,6 +55,9 @@ config_init(void)
+ #elif defined(CONFIG_WSCONS)
+     if (!config_wscons_init())
+         ErrorF("[config] failed to initialise wscons\n");
++#elif defined(CONFIG_DEVD)
++    if (!config_devd_init())
++        ErrorF("[config] failed to initialise devd\n");
+ #endif
+ }
+ 
+@@ -67,6 +70,8 @@ config_fini(void)
+     config_hal_fini();
+ #elif defined(CONFIG_WSCONS)
+     config_wscons_fini();
++#elif defined(CONFIG_DEVD)
++    config_devd_fini();
+ #endif
+ }
+ 
diff --git a/modular-xorg-server-dfbsd-meson/patches/patch-config_devd.c b/modular-xorg-server-dfbsd-meson/patches/patch-config_devd.c
new file mode 100644
index 0000000000..699479ae6e
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/patches/patch-config_devd.c
@@ -0,0 +1,625 @@
+$NetBSD$
+
+devd support to detect devices from FreeBSD ports / DragonFly dports
+x11-servers/xorg-server 1.18.4.
+
+Added many debugging statements with DebugF.
+
+Adjust for update to 1.19.6 API.
+
+--- config/devd.c.orig	2018-08-04 04:32:13.580868000 +0000
++++ config/devd.c
+@@ -0,0 +1,613 @@
++/*
++ * Copyright (c) 2012 Baptiste Daroussin
++ * Copyright (c) 2013, 2014 Alex Kozlov
++ * Copyright (c) 2014 Robert Millan
++ * Copyright (c) 2014 Jean-Sebastien Pedron
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice (including the next
++ * paragraph) shall be included in all copies or substantial portions of the
++ * Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
++ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
++ * DEALINGS IN THE SOFTWARE.
++ *
++ * Author: Baptiste Daroussin <bapt%FreeBSD.org@localhost>
++ */
++
++#ifdef HAVE_DIX_CONFIG_H
++#include <dix-config.h>
++#endif
++
++#ifdef CONFIG_DEVD
++
++#include <sys/types.h>
++#include <sys/kbio.h>
++#include <sys/socket.h>
++#include <sys/stat.h>
++#include <sys/sysctl.h>
++#include <sys/un.h>
++
++#include <ctype.h>
++#include <errno.h>
++#include <fcntl.h>
++#include <stdlib.h>
++#include <stdio.h>
++#include <stdbool.h>
++#include <unistd.h>
++
++#include "input.h"
++#include "inputstr.h"
++#include "hotplug.h"
++#include "config-backends.h"
++#include "os.h"
++
++#define DEVD_SOCK_PATH "/var/run/devd.pipe"
++
++#define DEVD_EVENT_ADD		'+'
++#define DEVD_EVENT_REMOVE	'-'
++#define DEVD_EVENT_NOTIFY	'!'
++
++#define RECONNECT_DELAY		(5 * 1000)
++
++static int sock_devd;
++static bool is_console_kbd = false;
++static bool is_kbdmux = false;
++static OsTimerPtr rtimer = NULL;
++
++struct hw_type {
++	const char *driver;
++	int flag;
++	const char *xdriver;
++};
++
++static struct hw_type hw_types[] = {
++	{ "ukbd", ATTR_KEYBOARD, "kbd" },
++	{ "atkbd", ATTR_KEYBOARD, "kbd" },
++	{ "kbdmux", ATTR_KEYBOARD, "kbd" },
++	{ "sysmouse", ATTR_POINTER, "mouse" },
++	{ "ums", ATTR_POINTER, "mouse" },
++	{ "psm", ATTR_POINTER, "mouse" },
++	{ "vboxguest", ATTR_POINTER, "vboxmouse" },
++	{ "joy", ATTR_JOYSTICK, NULL },
++	{ "atp", ATTR_TOUCHPAD, NULL },
++	{ "uep", ATTR_TOUCHSCREEN, NULL },
++	{ NULL, -1, NULL },
++};
++
++static bool
++sysctl_exists(const struct hw_type *device, int unit,
++	char *devname, size_t devname_len)
++{
++	char sysctlname[PATH_MAX];
++	size_t len;
++	int ret;
++
++	if (device == NULL || device->driver == NULL)
++		return false;
++
++	/* Check if a sysctl exists. */
++	snprintf(sysctlname, sizeof(sysctlname), "dev.%s.%i.%%desc",
++	    device->driver, unit);
++	ret = sysctlbyname(sysctlname, NULL, &len, NULL, 0);
++
++	if (ret == 0 && len > 0) {
++		snprintf(devname, devname_len, "%s%i", device->driver, unit);
++		DebugF("[config/devd]: sysctl_exists: true for sysctlname (%s), devname (%s)\n", sysctlname, devname);
++		return true;
++	}
++
++	return false;
++}
++
++static bool
++devpath_exists(const struct hw_type *device,
++	char *devname, size_t devname_len)
++{
++	char *devpath;
++	struct stat st;
++	int ret;
++
++	if (device == NULL || device->driver == NULL)
++		return false;
++
++	/* Check if /dev/$driver exists. */
++	asprintf(&devpath, "/dev/%s", device->driver);
++	if (devpath == NULL)
++		return false;
++
++	ret = stat(devpath, &st);
++	free(devpath);
++
++	if (ret == 0) {
++		DebugF("[config/devd]: devpath_exists true for devpath (%s)\n", devpath);
++		strncpy(devname, device->driver, devname_len);
++		return true;
++	}
++
++	return false;
++}
++
++static char *
++sysctl_get_str(const char *sysctlname)
++{
++	char *dest = NULL;
++	size_t len;
++
++	if (sysctlname == NULL)
++		return NULL;
++
++	if (sysctlbyname(sysctlname, NULL, &len, NULL, 0) == 0) {
++		dest = malloc(len + 1);
++		if (dest) {
++			if (sysctlbyname(sysctlname, dest, &len, NULL, 0) == 0)
++				dest[len] = '\0';
++			else {
++				free(dest);
++				dest = NULL;
++			}
++		}
++	}
++
++	return dest;
++}
++
++static void
++device_added(const char *devname)
++{
++	char path[PATH_MAX];
++	char sysctlname[PATH_MAX];
++	char *vendor;
++	char *product = NULL;
++	char *config_info = NULL;
++	char *walk;
++	InputOption *options = NULL;
++	InputAttributes attrs = { };
++	DeviceIntPtr dev = NULL;
++	int i;
++	int fd;
++
++	DebugF("[config/devd]: begin device_added: devname (%s)\n", devname);
++
++	for (i = 0; hw_types[i].driver != NULL; i++) {
++		size_t len;
++
++		len = strlen(hw_types[i].driver);
++		if (strcmp(devname, hw_types[i].driver) == 0 ||
++			(strncmp(devname, hw_types[i].driver, len) == 0 &&
++				isnumber(*(devname + len)))) {
++			attrs.flags |= hw_types[i].flag;
++			break;
++		}
++	}
++
++	if (hw_types[i].driver == NULL || hw_types[i].xdriver == NULL) {
++		LogMessage(X_INFO, "config/devd: ignoring device %s\n",
++				devname);
++		DebugF("[config/devd]: ignoring device %s\n",
++				devname);
++		return;
++	}
++
++	/* Skip keyboard devices if kbdmux is enabled */
++	if (is_kbdmux && is_console_kbd && hw_types[i].flag & ATTR_KEYBOARD) {
++		LogMessage(X_INFO, "config/devd: kbdmux is enabled, ignoring device %s\n",
++				devname);
++		DebugF("[config/devd]: kbdmux is enabled, ignoring device %s\n",
++				devname);
++		return;
++	}
++
++	snprintf(path, sizeof(path), "/dev/%s", devname);
++	DebugF("[config/devd]: device_added: devname full path (%s)\n", path);
++
++	options = input_option_new(NULL, "_source", "server/devd");
++	if (!options)
++		return;
++
++	snprintf(sysctlname, sizeof(sysctlname), "dev.%s.%s.%%desc",
++	    hw_types[i].driver, devname + strlen(hw_types[i].driver));
++	DebugF("[config/devd]: device_added: try sysctl name (%s)\n", sysctlname);
++	vendor = sysctl_get_str(sysctlname);
++	if (vendor == NULL) {
++		DebugF("[config/devd]: device_added: input_option_new([name], devname (%s))\n", devname);
++		options = input_option_new(options, "name", devname);
++	}
++	else {
++		DebugF("[config/devd]: device_added: read full vendor (%s)\n", vendor);
++		if ((walk = strchr(vendor, ' ')) != NULL) {
++			walk[0] = '\0';
++			walk++;
++			product = walk;
++			if ((walk = strchr(product, ',')) != NULL)
++				walk[0] = '\0';
++		}
++
++		attrs.vendor = strdup(vendor);
++		if (product) {
++			DebugF("[config/devd]: device_added: input_option_new([name], product (%s))\n", product);
++			attrs.product = strdup(product);
++			options = input_option_new(options, "name", product);
++		}
++		else {
++			DebugF("[config/devd]: device_added: input_option_new([name], [(unnamed)])\n");
++			options = input_option_new(options, "name", "(unnamed)");
++		}
++
++		free(vendor);
++	}
++
++	/* XXX implement usb_id */
++	attrs.usb_id = NULL;
++	attrs.device = strdup(path);
++	options = input_option_new(options, "driver", hw_types[i].xdriver);
++	DebugF("[config/devd]: device_added: input_option_new ([driver], (%s))\n", hw_types[i].xdriver);
++
++	fd = open(path, O_RDONLY);
++	if (fd >= 0) {
++		DebugF("[config/devd]: device_added: input_option_new ([device], (%s)), fd (%d)\n", path, fd);
++		close(fd);
++		options = input_option_new(options, "device", path);
++	}
++	else {
++		if (attrs.flags & ~ATTR_KEYBOARD) {
++			LogMessage(X_INFO, "config/devd: device %s already opened\n",
++					 path);
++			DebugF("[config/devd]: device_added: device (%s) already opened: flags (0x%x), fd (%d)\n",
++					 path, attrs.flags, fd);
++
++			/*
++			 * Fail if cannot open device, it breaks AllowMouseOpenFail,
++			 * but it should not matter when config/devd enabled
++			 */
++			goto unwind;
++		}
++
++		if (is_console_kbd) {
++			/*
++			 * There can be only one keyboard attached to console and
++			 * it is already added.
++			 */
++			LogMessage(X_WARNING, "config/devd: console keyboard is "
++					"already added, ignoring %s (%s)\n",
++					attrs.product, path);
++			DebugF("[config/devd]: device_added: console keyboard is "
++					"already added, ignoring %s, path (%s): fd (%d)\n",
++					attrs.product, path, fd);
++			goto unwind;
++		}
++		else {
++			/*
++			 * Don't pass "device" option if the keyboard is already
++			 * attached to the console (ie. open() fails).
++			 * This would activate a special logic in xf86-input-keyboard.
++			 * Prevent any other attached to console keyboards being
++			 * processed. There can be only one such device.
++			 */
++			DebugF("[config/devd]: device_added: keyboard already attached to console "
++					"is_console_kbd = true, ignoring %s, path (%s): fd (%d)\n",
++					attrs.product, path, fd);
++			is_console_kbd = true;
++		}
++	}
++
++	if (asprintf(&config_info, "devd:%s", devname) == -1) {
++		config_info = NULL;
++		goto unwind;
++	}
++
++	if (device_is_duplicate(config_info)) {
++		LogMessage(X_WARNING, "config/devd: device %s (%s) already added. "
++				"ignoring\n", attrs.product, path);
++		DebugF("[config/devd]: device %s (%s) already added. "
++				"ignoring\n", attrs.product, path);
++		goto unwind;
++	}
++
++	DebugF("[config/devd]: device_added: input_option_new ([config_info], (%s))\n", config_info);
++	options = input_option_new(options, "config_info", config_info);
++	LogMessage(X_INFO, "config/devd: adding input device %s (%s)\n",
++			attrs.product, path);
++	DebugF("[config/devd]: device_added: before   NewInputDeviceRequest for device %s (%s)\n",
++			attrs.product, path);
++
++	NewInputDeviceRequest(options, &attrs, &dev);
++
++	DebugF("[config/devd]: device_added: finished NewInputDeviceRequest for device %s (%s)\n",
++			attrs.product, path);
++
++unwind:
++	free(config_info);
++	input_option_free_list(&options);
++	free(attrs.usb_id);
++	free(attrs.product);
++	free(attrs.device);
++	free(attrs.vendor);
++}
++
++static void
++device_removed(char *devname)
++{
++	char *config_info;
++
++	DebugF("[config/devd]: removing device (%s)\n", devname);
++
++	if (asprintf(&config_info, "devd:%s", devname) == -1)
++		return;
++
++	remove_devices("devd", config_info);
++
++	free(config_info);
++}
++
++static bool is_kbdmux_enabled(void)
++{
++	/* Xorg uses /dev/ttyv0 as a console device */
++	/* const char device[]="/dev/console"; */
++	const char device[]="/dev/ttyv0";
++	keyboard_info_t info;
++	int fd;
++
++	fd = open(device, O_RDONLY);
++	DebugF("[config/devd]: is_kbdmux_enabled: device (%s) opened, fd (%d)\n", device, fd);
++
++	if (fd < 0)
++		return false;
++
++	if (ioctl(fd, KDGKBINFO, &info) == -1) {
++		DebugF("[config/devd]: is_kbdmux_enabled: ioctl KDGKBINFO failed (%s)\n", strerror(errno));
++		close(fd);
++		return false;
++	}
++
++	close(fd);
++
++	DebugF("[config/devd]: is_kbdmux_enabled: info.kb_name (%s)\n", info.kb_name);
++	if (!strncmp(info.kb_name, "kbdmux", 6))
++		return true;
++
++	return false;
++}
++
++static void
++disconnect_devd(int sock)
++{
++	LogMessage(X_INFO, "config/devd: disconnect socket (%d)\n", sock);
++	DebugF("[config/devd]: disconnect socket (%d)\n", sock);
++
++	if (sock >= 0) {
++		RemoveNotifyFd(sock);
++		close(sock);
++	}
++}
++
++static void
++wakeup_handler(int sock, int ready, void *data);
++
++static int
++connect_devd(void)
++{
++	struct sockaddr_un devd;
++	int sock;
++
++	DebugF("[config/devd]: connecting ... \n");
++
++	sock = socket(AF_UNIX, SOCK_STREAM, 0);
++	if (sock < 0) {
++		LogMessage(X_ERROR, "[config/devd]: failed opening stream socket: %s\n", strerror(errno));
++		DebugF("[config/devd]: connect_devd: failed opening stream socket: %s\n", strerror(errno));
++		return -1;
++	}
++
++	DebugF("[config/devd]: opened stream socket (%d)\n", sock);
++
++	devd.sun_family = AF_UNIX;
++	strlcpy(devd.sun_path, DEVD_SOCK_PATH, sizeof(devd.sun_path));
++
++	if (connect(sock, (struct sockaddr *) &devd, sizeof(devd)) < 0) {
++		close(sock);
++		LogMessage(X_ERROR, "[config/devd]: failed to connect to devd: %s\n", strerror(errno));
++		DebugF("[config/devd]: connect_devd: failed to connect to devd: %s\n", strerror(errno));
++		return -1;
++	}
++
++	DebugF("[config/devd]: connected to devd, sock (%d), pid file (%s)\n", sock, DEVD_SOCK_PATH);
++
++	SetNotifyFd(sock, wakeup_handler, X_NOTIFY_READ, NULL);
++
++	return	sock;
++}
++
++static CARD32
++reconnect_handler(OsTimerPtr timer, CARD32 time, void *arg)
++{
++	int newsock;
++
++	if ((newsock = connect_devd()) >= 0) {
++		sock_devd = newsock;
++		TimerFree(rtimer);
++		rtimer = NULL;
++		LogMessage(X_INFO, "config/devd: reopening devd socket\n");
++		DebugF("[config/devd]: reconnect_handler: RECONNECTED using socket (%d)\n", sock_devd);
++		return 0;
++	}
++	DebugF("[config/devd]: reconnect_handler FAILED to reconnect returned (%d)\n", newsock);
++
++	/* Try again after RECONNECT_DELAY */
++	return RECONNECT_DELAY;
++}
++
++static ssize_t
++socket_getline(int fd, char **out)
++{
++	char *buf, *newbuf;
++	ssize_t ret, cap, sz = 0;
++	char c;
++
++	cap = 1024;
++	buf = malloc(cap * sizeof(char));
++	if (!buf)
++		return -1;
++
++	for (;;) {
++		ret = read(sock_devd, &c, 1);
++		if (ret < 0) {
++			if (errno == EINTR)
++				continue;
++			free(buf);
++			return -1;
++		/* EOF - devd socket is lost */
++		} else if (ret == 0) {
++			disconnect_devd(sock_devd);
++			rtimer = TimerSet(NULL, 0, 1, reconnect_handler, NULL);
++			LogMessage(X_WARNING, "config/devd: devd socket is lost\n");
++			DebugF("[config/devd]: WARNING socket_getline: EOF devd socket (%d) is LOST\n", sock_devd);
++			free(buf);
++			return -1;
++		}
++		if (c == '\n')
++			break;
++
++		if (sz + 1 >= cap) {
++			cap *= 2;
++			newbuf = realloc(buf, cap * sizeof(char));
++			if (!newbuf) {
++				DebugF("[config/devd]: ERROR socket_getline: realloc failed on buf\n");
++				free(buf);
++				return -1;
++			}
++			buf = newbuf;
++		}
++		buf[sz] = c;
++		sz++;
++	}
++
++	buf[sz] = '\0';
++	if (sz >= 0)
++		*out = buf;
++	else
++		free(buf);
++
++	/* Number of bytes in the line, not counting the line break */
++	return sz;
++}
++
++static void
++wakeup_handler(int sock, int ready, void *data)
++{
++	char *line = NULL;
++	char *walk;
++	ssize_t sz;
++
++	DebugF("[config/devd]: wakeup_handler: sock_devd (%d), sock (%d), ready (%d)\n", sock_devd, sock, ready);
++	
++		sz = socket_getline(sock_devd, &line);
++		if (sz < 0)
++			return;
++		if (sz == 0) {
++			DebugF("[config/devd]: WARNING wakeup_handler: socket_getline returned zero length line\n");
++			free(line);
++			return;
++		}
++		DebugF("[config/devd]: wakeup_handler: socket_getline (%s)\n", line);
++
++		walk = strchr(line + 1, ' ');
++		if (walk != NULL)
++			walk[0] = '\0';
++
++		switch (*line) {
++		case DEVD_EVENT_ADD:
++			DebugF("[config/devd]: wakeup_handler: DEVD_EVENT_ADD line (%s)\n", line);
++			device_added(line + 1);
++			break;
++		case DEVD_EVENT_REMOVE:
++			DebugF("[config/devd]: wakeup_handler: DEVD_EVENT_REMOVE line (%s)\n", line);
++			device_removed(line + 1);
++			break;
++		case DEVD_EVENT_NOTIFY:
++			DebugF("[config/devd]: wakeup_handler: DEVD_EVENT_NOTIFY line (%s)\n", line);
++			break;
++		default:
++			break;
++		}
++		free(line);
++}
++
++#if 0
++static void
++block_handler(void *data, struct timeval **tv)
++{
++}
++#endif
++
++int
++config_devd_init(void)
++{
++	char devicename[1024];
++	int i, j;
++
++	LogMessage(X_INFO, "config/devd: probing input devices...\n");
++	DebugF("[config/devd]: config_devd_init: probing input devices...\n");
++
++	/*
++	 * Add fake keyboard and give up on keyboards management
++	 * if kbdmux is enabled
++	 */
++	if ((is_kbdmux = is_kbdmux_enabled()) == true)
++		device_added("kbdmux");
++
++	for (i = 0; hw_types[i].driver != NULL; i++) {
++		/* First scan the sysctl to determine the hardware */
++		for (j = 0; j < 16; j++) {
++			if (sysctl_exists(&hw_types[i], j,
++					devicename, sizeof(devicename)) != 0)
++				device_added(devicename);
++		}
++
++		if (devpath_exists(&hw_types[i], devicename, sizeof(devicename)) != 0)
++			device_added(devicename);
++	}
++
++	if ((sock_devd = connect_devd()) < 0)
++		return 0;
++
++#if 0
++	RegisterBlockAndWakeupHandlers(block_handler, wakeup_handler, NULL);
++#endif
++	DebugF("[config/devd]: config_devd_init: devices probed, sock_devd (%d)\n", sock_devd);
++
++	return 1;
++}
++
++void
++config_devd_fini(void)
++{
++	LogMessage(X_INFO, "config/devd: terminating backend...\n");
++	DebugF("[config/devd]: terminating backend...\n");
++
++	if (rtimer) {
++		TimerFree(rtimer);
++		rtimer = NULL;
++	}
++
++	disconnect_devd(sock_devd);
++
++#if 0
++	RemoveBlockAndWakeupHandlers(block_handler, wakeup_handler, NULL);
++#endif
++
++	is_console_kbd = false;
++}
++
++#endif /* CONFIG_DEVD */
diff --git a/modular-xorg-server-dfbsd-meson/patches/patch-config_meson.build b/modular-xorg-server-dfbsd-meson/patches/patch-config_meson.build
new file mode 100644
index 0000000000..9bd7faeeb1
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/patches/patch-config_meson.build
@@ -0,0 +1,19 @@
+$NetBSD$
+
+--- config/meson.build.orig	2019-01-30 21:08:48.000000000 +0000
++++ config/meson.build
+@@ -23,6 +23,14 @@ if host_machine.system() == 'openbsd'
+     srcs_config += 'wscons.c'
+ endif
+ 
++if host_machine.system() == 'dragonfly'
++    srcs_config += 'devd.c'
++endif
++
++if host_machine.system() == 'freebsd'
++    srcs_config += 'devd.c'
++endif
++
+ if build_xorg
+     install_data('10-quirks.conf',
+                  install_dir: join_paths(get_option('datadir'), 'X11/xorg.conf.d'))
diff --git a/modular-xorg-server-dfbsd-meson/patches/patch-glamor_glamor__egl.c b/modular-xorg-server-dfbsd-meson/patches/patch-glamor_glamor__egl.c
new file mode 100644
index 0000000000..ddc3a36ddb
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/patches/patch-glamor_glamor__egl.c
@@ -0,0 +1,122 @@
+$NetBSD$
+
+Option to revert
+
+2017-05-18	glamor_egl: Avoid flink names in glamor_egl_create_textured_pixmap().
+commit	59de50d6ef3331ee03eb82d4acba45aa75c70d42
+
+glamor_egl: Avoid flink names in glamor_egl_create_textured_pixmap().
+Using flink is banned on render nodes, and they needlessly expose our
+screen pixmap contents to any authenticated client.  This also
+incidentally drops the dependency on EGL_MESA_drm_image.
+
+--- glamor/glamor_egl.c.orig	2018-10-15 15:59:33.000000000 +0000
++++ glamor/glamor_egl.c
+@@ -93,6 +93,40 @@ glamor_egl_make_current(struct glamor_co
+     }
+ }
+ 
++#if defined(REVERT_FLINK)
++static EGLImageKHR
++_glamor_egl_create_image(struct glamor_egl_screen_private *glamor_egl,
++                         int width, int height, int stride, int name, int depth)
++{
++    EGLImageKHR image;
++
++    EGLint attribs[] = {
++        EGL_WIDTH, 0,
++        EGL_HEIGHT, 0,
++        EGL_DRM_BUFFER_STRIDE_MESA, 0,
++        EGL_DRM_BUFFER_FORMAT_MESA,
++        EGL_DRM_BUFFER_FORMAT_ARGB32_MESA,
++        EGL_DRM_BUFFER_USE_MESA,
++        EGL_DRM_BUFFER_USE_SHARE_MESA | EGL_DRM_BUFFER_USE_SCANOUT_MESA,
++        EGL_NONE
++    };
++    attribs[1] = width;
++    attribs[3] = height;
++    attribs[5] = stride;
++    if (depth != 32 && depth != 24)
++        return EGL_NO_IMAGE_KHR;
++    image = eglCreateImageKHR(glamor_egl->display,
++                              glamor_egl->context,
++                              EGL_DRM_BUFFER_MESA,
++                              (void *) (uintptr_t) name,
++                              attribs);
++    if (image == EGL_NO_IMAGE_KHR)
++        return EGL_NO_IMAGE_KHR;
++
++    return image;
++}
++#endif
++
+ static int
+ glamor_get_flink_name(int fd, int handle, int *name)
+ {
+@@ -184,6 +218,48 @@ glamor_egl_create_textured_pixmap(Pixmap
+ {
+     ScreenPtr screen = pixmap->drawable.pScreen;
+     ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
++
++#if defined(REVERT_FLINK)
++    struct glamor_screen_private *glamor_priv =
++        glamor_get_screen_private(screen);
++    struct glamor_egl_screen_private *glamor_egl;
++    EGLImageKHR image;
++    GLuint texture;
++    int name;
++    Bool ret = FALSE;
++
++    glamor_egl = glamor_egl_get_screen_private(scrn);
++
++    glamor_make_current(glamor_priv);
++    if (!glamor_get_flink_name(glamor_egl->fd, handle, &name)) {
++        xf86DrvMsg(scrn->scrnIndex, X_ERROR,
++                   "Couldn't flink pixmap handle\n");
++        glamor_set_pixmap_type(pixmap, GLAMOR_DRM_ONLY);
++        assert(0);
++        return FALSE;
++    }
++
++    image = _glamor_egl_create_image(glamor_egl,
++                                     pixmap->drawable.width,
++                                     pixmap->drawable.height,
++                                     ((stride * 8 +
++                                       7) / pixmap->drawable.bitsPerPixel),
++                                     name, pixmap->drawable.depth);
++    if (image == EGL_NO_IMAGE_KHR) {
++        glamor_set_pixmap_type(pixmap, GLAMOR_DRM_ONLY);
++        goto done;
++    }
++    glamor_create_texture_from_image(screen, image, &texture);
++    glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
++    glamor_set_pixmap_texture(pixmap, texture);
++    glamor_egl_set_pixmap_image(pixmap, image, FALSE);
++    ret = TRUE;
++ 
++ done:
++    return ret;
++}
++
++#else /* !REVERT_FLINK */
+     struct glamor_egl_screen_private *glamor_egl =
+         glamor_egl_get_screen_private(scrn);
+     int ret, fd;
+@@ -213,6 +289,7 @@ glamor_egl_create_textured_pixmap(Pixmap
+     close(fd);
+     return TRUE;
+ }
++#endif /* REVERT_FLINK */
+ 
+ Bool
+ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap,
+@@ -934,6 +1011,9 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd
+ 		goto error;  \
+ 	}
+ 
++#if defined(REVERT_FLINK)
++    GLAMOR_CHECK_EGL_EXTENSION(MESA_drm_image);
++#endif
+     GLAMOR_CHECK_EGL_EXTENSION(KHR_surfaceless_context);
+ 
+     if (eglBindAPI(EGL_OPENGL_API)) {
diff --git a/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_common_xf86AutoConfig.c b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_common_xf86AutoConfig.c
new file mode 100644
index 0000000000..a019dacd4c
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_common_xf86AutoConfig.c
@@ -0,0 +1,39 @@
+$NetBSD: patch-hw_xfree86_common_xf86AutoConfig.c,v 1.3 2018/10/26 10:20:12 maya Exp $
+
+Patches from FreeBSD ports /DragonFly dports for x11-servers/xorg-server 1.18.4.
+
+Look for wsfb on netbsd (needed by genfb)
+
+--- hw/xfree86/common/xf86AutoConfig.c.orig	2018-10-25 14:13:21.000000000 +0000
++++ hw/xfree86/common/xf86AutoConfig.c
+@@ -294,7 +294,7 @@ listPossibleVideoDrivers(XF86MatchedDriv
+     xf86PciMatchDriver(md);
+ #endif
+ 
+-#if defined(__linux__)
++#if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__)
+     xf86AddMatchedDriver(md, "modesetting");
+ #endif
+ 
+@@ -302,8 +302,10 @@ listPossibleVideoDrivers(XF86MatchedDriv
+     /* Fallback to platform default frame buffer driver */
+ #if !defined(__linux__) && defined(__sparc__)
+     xf86AddMatchedDriver(md, "wsfb");
+-#else
++#elif defined(__linux__)
+     xf86AddMatchedDriver(md, "fbdev");
++#elif defined(__FreeBSD__)
++    xf86AddMatchedDriver(md, "scfb");
+ #endif
+ #endif                          /* !__sun */
+ 
+@@ -313,6 +315,9 @@ listPossibleVideoDrivers(XF86MatchedDriv
+ #elif defined(__sparc__) && !defined(__sun)
+     xf86AddMatchedDriver(md, "sunffb");
+ #endif
++#if defined(__NetBSD__)
++    xf86AddMatchedDriver(md, "wsfb");
++#endif
+ }
+ 
+ /* copy a screen section and enter the desired driver
diff --git a/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_common_xf86Config.c b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_common_xf86Config.c
new file mode 100644
index 0000000000..b888c06b04
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_common_xf86Config.c
@@ -0,0 +1,25 @@
+$NetBSD$
+
+devd support to detect devices from FreeBSD ports / DragonFly dports
+x11-servers/xorg-server 1.18.4.
+
+--- hw/xfree86/common/xf86Config.c.orig	2017-01-05 21:19:31.000000000 +0000
++++ hw/xfree86/common/xf86Config.c
+@@ -1375,13 +1375,16 @@ checkCoreInputDevices(serverLayoutPtr se
+     }
+ 
+     if (!xf86Info.forceInputDevices && !(foundPointer && foundKeyboard)) {
+-#if defined(CONFIG_HAL) || defined(CONFIG_UDEV) || defined(CONFIG_WSCONS)
++#if defined(CONFIG_HAL) || defined(CONFIG_UDEV) || defined(CONFIG_WSCONS) || \
++		defined(CONFIG_DEVD)
+         const char *config_backend;
+ 
+ #if defined(CONFIG_HAL)
+         config_backend = "HAL";
+ #elif defined(CONFIG_UDEV)
+         config_backend = "udev";
++#elif defined(CONFIG_DEVD)
++        config_backend = "devd";
+ #else
+         config_backend = "wscons";
+ #endif
diff --git a/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_common_xf86Globals.c b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_common_xf86Globals.c
new file mode 100644
index 0000000000..fcbe49c6cf
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_common_xf86Globals.c
@@ -0,0 +1,17 @@
+$NetBSD$
+
+devd support to detect devices from FreeBSD ports / DragonFly dports
+x11-servers/xorg-server 1.18.4.
+
+--- hw/xfree86/common/xf86Globals.c.orig	2018-05-10 16:32:35.000000000 +0000
++++ hw/xfree86/common/xf86Globals.c
+@@ -117,7 +117,8 @@ xf86InfoRec xf86Info = {
+     .miscModInDevEnabled = TRUE,
+     .miscModInDevAllowNonLocal = FALSE,
+     .pmFlag = TRUE,
+-#if defined(CONFIG_HAL) || defined(CONFIG_UDEV) || defined(CONFIG_WSCONS)
++#if defined(CONFIG_HAL) || defined(CONFIG_UDEV) || defined(CONFIG_WSCONS) || \
++	defined(CONFIG_DEVD)
+     .forceInputDevices = FALSE,
+     .autoAddDevices = TRUE,
+     .autoEnableDevices = TRUE,
diff --git a/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_common_xf86Xinput.c b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_common_xf86Xinput.c
new file mode 100644
index 0000000000..a8581aed25
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_common_xf86Xinput.c
@@ -0,0 +1,24 @@
+$NetBSD$
+
+devd support to detect devices from FreeBSD ports / DragonFly dports
+x11-servers/xorg-server 1.18.4.
+
+--- hw/xfree86/common/xf86Xinput.c.orig	2017-12-20 20:32:33.000000000 +0000
++++ hw/xfree86/common/xf86Xinput.c
+@@ -874,7 +874,7 @@ xf86NewInputDevice(InputInfoPtr pInfo, D
+ {
+     InputDriverPtr drv = NULL;
+     DeviceIntPtr dev = NULL;
+-    Bool paused;
++    Bool paused = 0;
+     int rval;
+     char *path = NULL;
+ 
+@@ -1037,6 +1037,7 @@ NewInputDeviceRequest(InputOption *optio
+         if (strcmp(key, "_source") == 0 &&
+             (strcmp(value, "server/hal") == 0 ||
+              strcmp(value, "server/udev") == 0 ||
++             strcmp(value, "server/devd") == 0 ||
+              strcmp(value, "server/wscons") == 0)) {
+             is_auto = 1;
+             if (!xf86Info.autoAddDevices) {
diff --git a/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_common_xf86sbusBus.h b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_common_xf86sbusBus.h
new file mode 100644
index 0000000000..1dd7b76d63
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_common_xf86sbusBus.h
@@ -0,0 +1,24 @@
+$NetBSD: patch-hw_xfree86_common_xf86sbusBus.h,v 1.1 2015/04/25 11:47:03 tnn Exp $
+
+NetBSD/sparc64 support partially from xsrc.
+
+--- hw/xfree86/common/xf86sbusBus.h.orig	2014-02-05 03:08:57.000000000 +0000
++++ hw/xfree86/common/xf86sbusBus.h
+@@ -39,6 +39,8 @@
+ #define SBUS_DEVICE_FFB		0x000b
+ #define SBUS_DEVICE_GT		0x000c
+ #define SBUS_DEVICE_MGX		0x000d
++#define SBUS_DEVICE_P9100	0x000e
++#define SBUS_DEVICE_AG10E	0x000f
+ 
+ typedef struct sbus_prom_node {
+     int node;
+@@ -50,7 +52,7 @@ typedef struct sbus_device {
+     int devId;
+     int fbNum;
+     int fd;
+-    int width, height;
++  int width, height, size;
+     sbusPromNode node;
+     const char *descr;
+     const char *device;
diff --git a/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_dri2_dri2.c b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_dri2_dri2.c
new file mode 100644
index 0000000000..69c3c18a54
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_dri2_dri2.c
@@ -0,0 +1,40 @@
+$NetBSD: patch-hw_xfree86_dri2_dri2.c,v 1.2 2015/04/25 11:47:03 tnn Exp $
+
+Fix uninitialized variables warning from clang (X crashes without this)
+
+dri2.c:242:27: note: initialize the variable 'ref' to silence this warning
+    DRI2DrawableRefPtr ref;
+dri2.c:320:27: note: initialize the variable 'ref' to silence this warning
+    DRI2DrawableRefPtr ref, next;
+dri2.c:601:27: note: initialize the variable 'ref' to silence this warning
+    DRI2DrawableRefPtr ref;
+
+--- hw/xfree86/dri2/dri2.c.orig	2015-01-26 18:42:23.000000000 +0000
++++ hw/xfree86/dri2/dri2.c
+@@ -312,7 +312,7 @@ typedef struct DRI2DrawableRefRec {
+ static DRI2DrawableRefPtr
+ DRI2LookupDrawableRef(DRI2DrawablePtr pPriv, XID id)
+ {
+-    DRI2DrawableRefPtr ref;
++    DRI2DrawableRefPtr ref = NULL;
+ 
+     xorg_list_for_each_entry(ref, &pPriv->reference_list, link) {
+         if (ref->id == id)
+@@ -392,7 +392,7 @@ static int
+ DRI2DrawableGone(void *p, XID id)
+ {
+     DRI2DrawablePtr pPriv = p;
+-    DRI2DrawableRefPtr ref, next;
++    DRI2DrawableRefPtr ref = NULL, next;
+     WindowPtr pWin;
+     PixmapPtr pPixmap;
+     DrawablePtr pDraw;
+@@ -713,7 +713,7 @@ static void
+ DRI2InvalidateDrawable(DrawablePtr pDraw)
+ {
+     DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
+-    DRI2DrawableRefPtr ref;
++    DRI2DrawableRefPtr ref = NULL;
+ 
+     if (!pPriv || !pPriv->needInvalidate)
+         return;
diff --git a/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_drivers_modesetting_drmmode__display.c b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_drivers_modesetting_drmmode__display.c
new file mode 100644
index 0000000000..0bea7afcea
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_drivers_modesetting_drmmode__display.c
@@ -0,0 +1,48 @@
+$NetBSD$
+
+Option to revert effects of upstream:
+
+2018-02-27	Add RandR leases with modesetting driver support [v6]
+
+commit	e4e3447603b5fd3a38a92c3f972396d1f81168ad
+
+--- hw/xfree86/drivers/modesetting/drmmode_display.c.orig	2018-10-15 15:59:33.000000000 +0000
++++ hw/xfree86/drivers/modesetting/drmmode_display.c
+@@ -3196,6 +3196,7 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn
+     return FALSE;
+ }
+ 
++#if !defined(REVERT_RANDR_LEASE)
+ static void
+ drmmode_validate_leases(ScrnInfoPtr scrn)
+ {
+@@ -3233,6 +3234,7 @@ drmmode_validate_leases(ScrnInfoPtr scrn
+ 
+     free(lessees);
+ }
++#endif
+ 
+ static int
+ drmmode_create_lease(RRLeasePtr lease, int *fd)
+@@ -3485,8 +3487,10 @@ drmmode_set_desired_modes(ScrnInfoPtr pS
+         }
+     }
+ 
++#if !defined(REVERT_RANDR_LEASE)
+     /* Validate leases on VT re-entry */
+     drmmode_validate_leases(pScrn);
++#endif
+ 
+     return TRUE;
+ }
+@@ -3693,8 +3697,10 @@ drmmode_handle_uevents(int fd, void *clo
+         drmmode_output_init(scrn, drmmode, mode_res, i, TRUE, 0);
+     }
+ 
++#if !defined(REVERT_RANDR_LEASE)
+     /* Check to see if a lessee has disappeared */
+     drmmode_validate_leases(scrn);
++#endif
+ 
+     if (changed) {
+         RRSetChanged(xf86ScrnToScreen(scrn));
diff --git a/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_modes_xf86Cursors.c b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_modes_xf86Cursors.c
new file mode 100644
index 0000000000..c5ac28359e
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_modes_xf86Cursors.c
@@ -0,0 +1,20 @@
+$NetBSD$
+
+Option to revert effects of upstream:
+
+2018-02-27	Add RandR leases with modesetting driver support [v6]
+
+commit	e4e3447603b5fd3a38a92c3f972396d1f81168ad
+
+--- hw/xfree86/modes/xf86Cursors.c.orig	2018-10-15 15:59:33.000000000 +0000
++++ hw/xfree86/modes/xf86Cursors.c
+@@ -348,7 +348,9 @@ Bool
+ xf86_crtc_show_cursor(xf86CrtcPtr crtc)
+ {
+     if (!crtc->cursor_in_range) {
++#if !defined(REVERT_RANDR_LEASE)
+         crtc->funcs->hide_cursor(crtc);
++#endif
+         return TRUE;
+     }
+ 
diff --git a/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_bsd_arm__video.c b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_bsd_arm__video.c
new file mode 100644
index 0000000000..26cb33d063
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_bsd_arm__video.c
@@ -0,0 +1,24 @@
+$NetBSD: patch-hw_xfree86_os-support_bsd_arm__video.c,v 1.1 2016/02/23 22:32:45 tnn Exp $
+
+XXX stubs for now, sufficient for wsfb. Need to sync this file with xsrc.
+
+--- hw/xfree86/os-support/bsd/arm_video.c.orig	2016-01-06 17:23:08.000000000 +0000
++++ hw/xfree86/os-support/bsd/arm_video.c
+@@ -66,6 +66,12 @@
+ #include "xf86_OSlib.h"
+ #include "xf86OSpriv.h"
+ 
++#if defined(__NetBSD__)
++Bool xf86EnableIO(void) { return TRUE; }
++void xf86DisableIO(void) { return; }
++void xf86OSInitVidMem(VidMemInfoPtr pVidMem) { pVidMem->initialised = TRUE; }
++#else /* DISABLED */
++
+ #if defined(__NetBSD__) && !defined(MAP_FILE)
+ #define MAP_FLAGS MAP_SHARED
+ #else
+@@ -203,3 +209,4 @@ xf86DisableIO()
+ }
+ 
+ #endif                          /* USE_ARC_MMAP */
++#endif /* DISABLED */
diff --git a/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_bsd_bsd__VTsw.c b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_bsd_bsd__VTsw.c
new file mode 100644
index 0000000000..b2053bec7e
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_bsd_bsd__VTsw.c
@@ -0,0 +1,26 @@
+$NetBSD: patch-hw_xfree86_os-support_bsd_bsd__VTsw.c,v 1.1 2015/10/11 18:28:53 tnn Exp $
+
+VT switching support. From xsrc.
+
+--- hw/xfree86/os-support/bsd/bsd_VTsw.c.orig	2015-05-21 14:21:39.000000000 +0000
++++ hw/xfree86/os-support/bsd/bsd_VTsw.c
+@@ -68,6 +68,9 @@ xf86VTSwitchAway()
+ {
+ #if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+     if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) {
++#ifdef WSCONS_SUPPORT
++	ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT);
++#endif
+         xf86Info.vtRequestsPending = FALSE;
+         if (ioctl(xf86Info.consoleFd, VT_RELDISP, 1) < 0)
+             return FALSE;
+@@ -83,6 +86,9 @@ xf86VTSwitchTo()
+ {
+ #if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+     if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) {
++#ifdef WSCONS_SUPPORT
++	ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS);
++#endif
+         xf86Info.vtRequestsPending = FALSE;
+         if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
+             return FALSE;
diff --git a/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_bsd_bsd__init.c b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_bsd_bsd__init.c
new file mode 100644
index 0000000000..588e43728c
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_bsd_bsd__init.c
@@ -0,0 +1,103 @@
+$NetBSD: patch-hw_xfree86_os-support_bsd_bsd__init.c,v 1.1 2018/10/26 10:20:12 maya Exp $
+
+Don't error when running unprivileged.
+
+From FreeBSD ports for x11-servers/xorg-server 1.18.4.
+sparc64 patch
+
+Bug 196678
+x11-servers/xorg-server: Update to 1.19.6 + make config/devd recognize
+/dev/input/eventX from multimedia/webcamd
+
+https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=196678
+
+Attachment #191592: update Xorg to 1.19.6 and integrate collective devd enhancements
+for bug #196678
+
+https://bugs.freebsd.org/bugzilla/attachment.cgi?id=191592&action=diff
+
+--- hw/xfree86/os-support/bsd/bsd_init.c.orig	2018-10-25 14:13:21.000000000 +0000
++++ hw/xfree86/os-support/bsd/bsd_init.c
+@@ -48,6 +48,10 @@ static int devConsoleFd = -1;
+ #if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ static int VTnum = -1;
+ static int initialVT = -1;
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++static struct termios tty_attr;	/* tty state to restore */
++static int tty_mode;		/* kbd mode to restore */
++#endif /* __FreeBSD__ */
+ #endif
+ 
+ #ifdef PCCONS_SUPPORT
+@@ -165,10 +169,12 @@ xf86OpenConsole()
+ #endif
+ 
+     if (serverGeneration == 1) {
++#if !defined(ALLOW_UNPRIVILEGED)
+         /* check if we are run with euid==0 */
+         if (geteuid() != 0) {
+             FatalError("xf86OpenConsole: Server must be suid root");
+         }
++#endif
+ 
+         if (!KeepTty) {
+             /*
+@@ -230,6 +236,9 @@ xf86OpenConsole()
+              * Add cases for other *BSD that behave the same.
+              */
+ #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
++#if defined(__sparc64__)
++	    pci_system_init_dev_mem(fd);
++#endif
+             uname(&uts);
+             i = atof(uts.release) * 100;
+             if (i >= 310)
+@@ -253,6 +262,9 @@ xf86OpenConsole()
+ #endif
+  acquire_vt:
+             if (!xf86Info.ShareVTs) {
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++                struct termios nTty;
++#endif /* __FreeBSD__ */
+                 /*
+                  * now get the VT
+                  */
+@@ -287,6 +299,27 @@ xf86OpenConsole()
+                 if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) {
+                     FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed");
+                 }
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++                tcgetattr(xf86Info.consoleFd, &tty_attr);
++                ioctl(xf86Info.consoleFd, KDGKBMODE, &tty_mode);
++
++                /* disable special keys */
++                if (ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW) < 0) {
++                    FatalError("xf86OpenConsole: KDSKBMODE K_RAW failed (%s)",
++                               strerror(errno));
++                }
++
++                nTty = tty_attr;
++                nTty.c_iflag = IGNPAR | IGNBRK;
++                nTty.c_oflag = 0;
++                nTty.c_cflag = CREAD | CS8;
++                nTty.c_lflag = 0;
++                nTty.c_cc[VTIME] = 0;
++                nTty.c_cc[VMIN] = 1;
++                cfsetispeed(&nTty, 9600);
++                cfsetospeed(&nTty, 9600);
++                tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
++#endif /* __FreeBSD__ */
+             }
+             else {              /* xf86Info.ShareVTs */
+                 close(xf86Info.consoleFd);
+@@ -594,6 +627,10 @@ xf86CloseConsole()
+     case SYSCONS:
+     case PCVT:
+         ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT);  /* Back to text mode */
++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++        ioctl(xf86Info.consoleFd, KDSKBMODE, tty_mode);
++        tcsetattr(xf86Info.consoleFd, TCSANOW, &tty_attr);
++#endif /* __FreeBSD__ */
+         if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1) {
+             VT.mode = VT_AUTO;
+             ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* dflt vt handling */
diff --git a/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_bsd_i386__video.c b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_bsd_i386__video.c
new file mode 100644
index 0000000000..09e0931d81
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_bsd_i386__video.c
@@ -0,0 +1,26 @@
+$NetBSD: patch-hw_xfree86_os-support_bsd_i386__video.c,v 1.1 2015/04/25 11:47:03 tnn Exp $
+
+Added patch from FreeBSD ports / DragonFly dports
+
+--- hw/xfree86/os-support/bsd/i386_video.c.orig	2015-01-17 23:42:52.000000000 +0000
++++ hw/xfree86/os-support/bsd/i386_video.c
+@@ -32,6 +32,9 @@
+ #include "xf86Priv.h"
+ 
+ #include <errno.h>
++#if defined(__FreeBSD__) || defined(__DragonFly__)
++#include <sys/types.h>
++#endif
+ #include <sys/mman.h>
+ 
+ #include "xf86_OSlib.h"
+@@ -42,6 +45,9 @@
+ #else
+ #define MAP_FLAGS (MAP_FILE | MAP_SHARED)
+ #endif
++#if defined(__NetBSD__) && defined(USE_AMD64_IOPL)
++#define amd64_iopl x86_64_iopl
++#endif
+ 
+ #ifdef __OpenBSD__
+ #define SYSCTL_MSG "\tCheck that you have set 'machdep.allowaperture=1'\n"\
diff --git a/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_bsd_ppc__video.c b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_bsd_ppc__video.c
new file mode 100644
index 0000000000..64fdc91602
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_bsd_ppc__video.c
@@ -0,0 +1,18 @@
+$NetBSD$
+
+From FreeBSD ports for x11-servers/xorg-server 1.18.4.
+
+--- hw/xfree86/os-support/bsd/ppc_video.c.orig	2016-07-15 16:18:11 UTC
++++ hw/xfree86/os-support/bsd/ppc_video.c
+@@ -79,7 +79,11 @@ xf86DisableIO()
+ {
+ 
+     if (ioBase != MAP_FAILED) {
++#if defined(__FreeBSD__)
++        munmap(__DEVOLATILE(unsigned char *, ioBase), 0x10000);
++#else
+         munmap(__UNVOLATILE(ioBase), 0x10000);
++#endif
+         ioBase = MAP_FAILED;
+     }
+ }
diff --git a/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_bus_Sbus.c b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_bus_Sbus.c
new file mode 100644
index 0000000000..311ceb7a8b
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_bus_Sbus.c
@@ -0,0 +1,172 @@
+$NetBSD: patch-hw_xfree86_os-support_bus_Sbus.c,v 1.3 2016/11/16 10:14:37 wiz Exp $
+
+Merge most of netbsdSbus.c from xsrc.
+
+--- hw/xfree86/os-support/bus/Sbus.c.orig	2016-08-11 19:08:48.000000000 +0000
++++ hw/xfree86/os-support/bus/Sbus.c
+@@ -34,6 +34,9 @@
+ #ifdef __sun
+ #include <sys/utsname.h>
+ #endif
++#if defined(__NetBSD__) && defined(__sparc__)
++#include <dev/ofw/openfirmio.h>
++#endif
+ #include "xf86.h"
+ #include "xf86Priv.h"
+ #include "xf86_OSlib.h"
+@@ -50,7 +53,6 @@ static int promP1275 = -1;
+ 
+ #define MAX_PROP	128
+ #define MAX_VAL		(4096-128-4)
+-static struct openpromio *promOpio;
+ 
+ sbusDevicePtr *xf86SbusInfo = NULL;
+ 
+@@ -68,68 +70,75 @@ struct sbus_devtable sbusDeviceTable[] =
+     {SBUS_DEVICE_GT, FBTYPE_SUNGT, "gt", NULL, "Sun Graphics Tower"},
+     {SBUS_DEVICE_MGX, -1, "mgx", NULL, "Quantum 3D MGXplus"},
+     {SBUS_DEVICE_LEO, FBTYPE_SUNLEO, "leo", "sunleo", "Sun ZX or Turbo ZX"},
+-    {SBUS_DEVICE_TCX, FBTYPE_TCXCOLOR, "tcx", "suntcx", "Sun TCX"},
++    {SBUS_DEVICE_TCX, FBTYPE_TCXCOLOR, "tcx", "suntcx", "Sun TCX or S24"},
+     {SBUS_DEVICE_FFB, FBTYPE_CREATOR, "ffb", "sunffb", "Sun FFB"},
+     {SBUS_DEVICE_FFB, FBTYPE_CREATOR, "afb", "sunffb", "Sun Elite3D"},
++    {SBUS_DEVICE_P9100, FBTYPE_P9100, "pnozz", "pnozz", "Weitek P9100"},
++    {SBUS_DEVICE_AG10E, FBTYPE_AG10E, "ag10e", "ag10e", "Fujitsu AG-10e"},
+     {0, 0, NULL}
+ };
+ 
++static struct ofiocdesc ofio;
++static char of_buf[256];
++
+ int
+ promGetSibling(int node)
+ {
+-    promOpio->oprom_size = sizeof(int);
+ 
+     if (node == -1)
+         return 0;
+-    *(int *) promOpio->oprom_array = node;
+-    if (ioctl(promFd, OPROMNEXT, promOpio) < 0)
++    if (ioctl(promFd, OFIOCGETNEXT, &node) < 0)
+         return 0;
+-    promCurrentNode = *(int *) promOpio->oprom_array;
+-    return *(int *) promOpio->oprom_array;
++    promCurrentNode = node;
++    return node;
+ }
+ 
+ int
+ promGetChild(int node)
+ {
+-    promOpio->oprom_size = sizeof(int);
+ 
+     if (!node || node == -1)
+         return 0;
+-    *(int *) promOpio->oprom_array = node;
+-    if (ioctl(promFd, OPROMCHILD, promOpio) < 0)
++    if (ioctl(promFd, OFIOCGETCHILD, &node) < 0)
+         return 0;
+-    promCurrentNode = *(int *) promOpio->oprom_array;
+-    return *(int *) promOpio->oprom_array;
++    promCurrentNode = node;
++    return node;
+ }
+ 
+ char *
+ promGetProperty(const char *prop, int *lenp)
+ {
+-    promOpio->oprom_size = MAX_VAL;
+ 
+-    strcpy(promOpio->oprom_array, prop);
+-    if (ioctl(promFd, OPROMGETPROP, promOpio) < 0)
++    ofio.of_nodeid = promCurrentNode;
++    ofio.of_name = (char *)prop;
++    ofio.of_namelen = strlen(prop);
++    ofio.of_buf = of_buf;
++    ofio.of_buflen = sizeof(of_buf);
++
++    if (ioctl(promFd, OFIOCGET, &ofio) < 0)
+         return 0;
++
++    of_buf[ofio.of_buflen] = '\0';
++
+     if (lenp)
+-        *lenp = promOpio->oprom_size;
+-    return promOpio->oprom_array;
++        *lenp = ofio.of_buflen;
++    return of_buf;
+ }
+ 
+ int
+ promGetBool(const char *prop)
+ {
+-    promOpio->oprom_size = 0;
++    ofio.of_nodeid = promCurrentNode;
++    ofio.of_name = (char *)prop;
++    ofio.of_namelen = strlen(prop);
++    ofio.of_buf = of_buf;
++    ofio.of_buflen = sizeof(of_buf);
+ 
+-    *(int *) promOpio->oprom_array = 0;
+-    for (;;) {
+-        promOpio->oprom_size = MAX_PROP;
+-        if (ioctl(promFd, OPROMNXTPROP, promOpio) < 0)
+-            return 0;
+-        if (!promOpio->oprom_size)
+-            return 0;
+-        if (!strcmp(promOpio->oprom_array, prop))
+-            return 1;
+-    }
++    if (ioctl(promFd, OFIOCGET, &ofio) < 0)
++        return 0;
++    if (ofio.of_buflen < 0)
++        return 0;
++    return 1;
+ }
+ 
+ #define PROM_NODE_SIBLING 0x01
+@@ -180,8 +189,8 @@ promIsP1275(void)
+         promP1275 = TRUE;
+     else
+         promP1275 = FALSE;
+-#elif defined(__FreeBSD__)
+-    promP1275 = TRUE;
++#elif defined(__FreeBSD__) || defined(__NetBSD__)
++     promP1275 = TRUE;
+ #else
+ #error Missing promIsP1275() function for this OS
+ #endif
+@@ -198,8 +207,6 @@ sparcPromClose(void)
+         close(promFd);
+         promFd = -1;
+     }
+-    free(promOpio);
+-    promOpio = NULL;
+     promOpenCount = 0;
+ }
+ 
+@@ -213,11 +220,6 @@ sparcPromInit(void)
+     promFd = open("/dev/openprom", O_RDONLY, 0);
+     if (promFd == -1)
+         return -1;
+-    promOpio = (struct openpromio *) malloc(4096);
+-    if (!promOpio) {
+-        sparcPromClose();
+-        return -1;
+-    }
+     promRootNode = promGetSibling(0);
+     if (!promRootNode) {
+         sparcPromClose();
+@@ -399,9 +401,9 @@ sparcPromAssignNodes(void)
+          * were the types of the cards missed. */
+         char buffer[64];
+         int fbNum, devId;
+-        static struct {
+-            int devId;
+-            char *prefix;
++        static const struct {
++            const int devId;
++            const char *prefix;
+         } procFbPrefixes[] = {
+             {SBUS_DEVICE_BW2, "BWtwo"},
+             {SBUS_DEVICE_CG14, "CGfourteen"},
diff --git a/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_meson.build b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_meson.build
new file mode 100644
index 0000000000..14bc301640
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_meson.build
@@ -0,0 +1,22 @@
+$NetBSD$
+
+--- hw/xfree86/os-support/meson.build.orig	2019-02-25 15:48:03.000000000 +0000
++++ hw/xfree86/os-support/meson.build
+@@ -91,7 +91,7 @@ elif host_machine.system() == 'solaris'
+         error('Unknown CPU family for Solaris build')
+     endif
+ 
+-elif host_machine.system().endswith('bsd')
++elif host_machine.system().endswith('bsd') or host_machine.system() == 'dragonfly'
+     srcs_xorg_os_support += [
+         'bsd/bsd_VTsw.c',
+         'bsd/bsd_bell.c',
+@@ -136,7 +136,7 @@ elif host_machine.system().endswith('bsd
+         endif
+     endif
+ 
+-    if host_machine.system() == 'freebsd'
++    if host_machine.system() == 'freebsd' or host_machine.system() == 'dragonfly'
+         srcs_xorg_os_support += 'bsd/bsd_kmod.c'
+     else
+         srcs_xorg_os_support += 'shared/kmod_noop.c'
diff --git a/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_solaris_solaris-amd64.S b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_solaris_solaris-amd64.S
new file mode 100644
index 0000000000..6ec5b859e2
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_solaris_solaris-amd64.S
@@ -0,0 +1,62 @@
+$NetBSD: patch-hw_xfree86_os-support_solaris_solaris-amd64.S,v 1.1 2018/01/25 15:06:10 jperkin Exp $
+
+Make assembly work with clang.
+
+--- hw/xfree86/os-support/solaris/solaris-amd64.S.orig	2017-12-20 20:32:33.000000000 +0000
++++ hw/xfree86/os-support/solaris/solaris-amd64.S
+@@ -1,3 +1,4 @@
++#if 0
+ / Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ / 
+ / Permission is hereby granted, free of charge, to any person obtaining a
+@@ -18,6 +19,7 @@
+ / LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ / FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ / DEALINGS IN THE SOFTWARE.
++#endif
+ 
+ #ifdef INLINE_ASM
+ #define FUNCTION_START(f,n)	.inline f,n
+@@ -32,36 +34,36 @@
+ 	FUNCTION_START(inb,4)
+ 	movq	%rdi, %rdx
+ 	xorq    %rax, %rax
+-	inb	(%dx)
++	inb	%dx
+ 	FUNCTION_END(inb)
+ 
+ 	FUNCTION_START(inw,4)
+ 	movq	%rdi, %rdx
+ 	xorq    %rax, %rax
+-	inw	(%dx)
++	inw	%dx
+ 	FUNCTION_END(inw)
+ 
+ 	FUNCTION_START(inl,4)
+ 	movq	%rdi, %rdx
+ 	xorq    %rax, %rax
+-	inl	(%dx)
++	inl	%dx
+ 	FUNCTION_END(inl)
+ 
+ 	FUNCTION_START(outb,8)
+ 	movq	%rdi, %rdx
+ 	movq    %rsi, %rax
+-	outb	(%dx)
++	outb	%dx
+ 	FUNCTION_END(outb)
+ 
+ 	FUNCTION_START(outw,8)
+ 	movq	%rdi, %rdx
+ 	movq    %rsi, %rax
+-	outw	(%dx)
++	outw	%dx
+ 	FUNCTION_END(outw)
+ 
+ 	FUNCTION_START(outl,8)
+ 	movq	%rdi, %rdx
+ 	movq    %rsi, %rax
+-	outl	(%dx)
++	outl	%dx
+ 	FUNCTION_END(outl)
+ 
diff --git a/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_xf86_OSproc.h b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_xf86_OSproc.h
new file mode 100644
index 0000000000..c781830a26
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os-support_xf86_OSproc.h
@@ -0,0 +1,15 @@
+$NetBSD: patch-hw_xfree86_os-support_xf86_OSproc.h,v 1.1 2016/02/23 22:32:45 tnn Exp $
+
+These are in i386_video.c only. XXX what are they used for?
+
+--- hw/xfree86/os-support/xf86_OSproc.h.orig	2016-01-06 17:23:08.000000000 +0000
++++ hw/xfree86/os-support/xf86_OSproc.h
+@@ -115,7 +115,7 @@ _XFUNCPROTOBEGIN
+ extern _X_EXPORT Bool xf86EnableIO(void);
+ extern _X_EXPORT void xf86DisableIO(void);
+ 
+-#ifdef __NetBSD__
++#if defined(__NetBSD__) && (defined(__i386__) || defined(__x86_64__))
+ extern _X_EXPORT void xf86SetTVOut(int);
+ extern _X_EXPORT void xf86SetRGBOut(void);
+ #endif
diff --git a/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os_support_bus_xf86Sbus.h b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os_support_bus_xf86Sbus.h
new file mode 100644
index 0000000000..816cbbd895
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_os_support_bus_xf86Sbus.h
@@ -0,0 +1,15 @@
+$NetBSD: patch-hw_xfree86_os_support_bus_xf86Sbus.h,v 1.1 2015/04/25 11:47:03 tnn Exp $
+
+NetBSD/sparc64 support.
+
+--- hw/xfree86/os-support/bus/xf86Sbus.h.orig	2014-02-05 03:08:57.000000000 +0000
++++ hw/xfree86/os-support/bus/xf86Sbus.h
+@@ -36,6 +36,8 @@
+ #elif defined(SVR4)
+ #include <sys/fbio.h>
+ #include <sys/openpromio.h>
++#elif defined(__NetBSD__) && defined(__sparc64__)
++#include <dev/sun/fbio.h>
+ #elif defined(__OpenBSD__) && defined(__sparc64__)
+ /* XXX */
+ #elif defined(CSRG_BASED)
diff --git a/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_xorg-wrapper.c b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_xorg-wrapper.c
new file mode 100644
index 0000000000..8a514f42a7
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/patches/patch-hw_xfree86_xorg-wrapper.c
@@ -0,0 +1,37 @@
+$NetBSD$
+
+Bug 196678
+x11-servers/xorg-server: Update to 1.19.6 + make config/devd recognize
+/dev/input/eventX from multimedia/webcamd
+
+https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=196678
+
+Attachment #191592: update Xorg to 1.19.6 and integrate collective devd enhancements
+for bug #196678
+
+https://bugs.freebsd.org/bugzilla/attachment.cgi?id=191592&action=diff
+
+* Skip the detection of root rights requirement, the assumption that presence
+* of KMS drivers removes the root requirement is only valid for Linux
+*
+
+--- hw/xfree86/xorg-wrapper.c.orig	2018-08-07 16:31:04.000000000 +0000
++++ hw/xfree86/xorg-wrapper.c
+@@ -191,7 +191,7 @@ static int on_console(int fd)
+ 
+ int main(int argc, char *argv[])
+ {
+-#ifdef WITH_LIBDRM
++#if defined(WITH_LIBDRM) && !defined(__FreeBSD__) && !defined(__DragonFly__)
+     struct drm_mode_card_res res;
+ #endif
+     char buf[PATH_MAX];
+@@ -230,7 +230,7 @@ int main(int argc, char *argv[])
+         }
+     }
+ 
+-#ifdef WITH_LIBDRM
++#if defined(WITH_LIBDRM) && !defined(__FreeBSD__) && !defined(__DragonFly__)
+     /* Detect if we need root rights, except when overriden by the config */
+     if (needs_root_rights == -1) {
+         for (i = 0; i < 16; i++) {
diff --git a/modular-xorg-server-dfbsd-meson/patches/patch-include_meson.build b/modular-xorg-server-dfbsd-meson/patches/patch-include_meson.build
new file mode 100644
index 0000000000..e5de8e4320
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/patches/patch-include_meson.build
@@ -0,0 +1,33 @@
+$NetBSD$
+
+--- include/meson.build.orig	2019-02-25 15:48:03.000000000 +0000
++++ include/meson.build
+@@ -254,7 +254,7 @@ supports_syscons = false
+ supports_wscons = false
+ csrg_based = false
+ 
+-if host_machine.system() == 'freebsd' or host_machine.system() == 'dragonflybsd'
++if host_machine.system() == 'freebsd' or host_machine.system() == 'dragonfly'
+   supports_pccons = true
+   supports_pcvt = true
+   supports_syscons = true
+@@ -344,14 +344,17 @@ xorg_data.set_quoted('PCI_TXT_IDS_PATH',
+ xorg_data.set('XSERVER_PLATFORM_BUS', build_udev)
+ xorg_data.set('WSCONS_SUPPORT', host_machine.system() == 'netbsd' or host_machine.system() == 'openbsd')
+ 
+-if host_machine.system() == 'freebsd' or host_machine.system() == 'dragonflybsd'
++if host_machine.system() == 'freebsd' or host_machine.system() == 'dragonfly'
+     if host_machine.cpu_family() == 'x86' or host_machine.cpu_family() == 'x86_64'
+         xorg_data.set('USE_DEV_IO', true)
+     endif
+ elif host_machine.system() == 'netbsd'
+-    if host_machine.cpu_family() == 'x86' or host_machine.cpu_family() == 'x86_64'
++    if host_machine.cpu_family() == 'x86'
+         xorg_data.set('USE_I386_IOPL', true)
+     endif
++    if host_machine.cpu_family() == 'x86_64'
++        xorg_data.set('USE_AMD64_IOPL', true)
++    endif
+ elif host_machine.system() == 'openbsd'
+     if host_machine.cpu_family() == 'x86'
+         xorg_data.set('USE_I386_IOPL', true)
diff --git a/modular-xorg-server-dfbsd-meson/patches/patch-randr_randr.c b/modular-xorg-server-dfbsd-meson/patches/patch-randr_randr.c
new file mode 100644
index 0000000000..02b7862319
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/patches/patch-randr_randr.c
@@ -0,0 +1,91 @@
+$NetBSD$
+
+Option to revert effects of upstream:
+
+2018-02-27	Add RandR leases with modesetting driver support [v6]
+
+commit	e4e3447603b5fd3a38a92c3f972396d1f81168ad
+
+--- randr/randr.c.orig	2018-10-15 15:59:33.000000000 +0000
++++ randr/randr.c
+@@ -89,12 +89,16 @@ RRCloseScreen(ScreenPtr pScreen)
+ {
+     rrScrPriv(pScreen);
+     int j;
++#if !defined(REVERT_RANDR_LEASE)
+     RRLeasePtr lease, next;
++#endif
+ 
+     unwrap(pScrPriv, pScreen, CloseScreen);
+ 
++#if !defined(REVERT_RANDR_LEASE)
+     xorg_list_for_each_entry_safe(lease, next, &pScrPriv->leases, list)
+         RRTerminateLease(lease);
++#endif
+     for (j = pScrPriv->numCrtcs - 1; j >= 0; j--)
+         RRCrtcDestroy(pScrPriv->crtcs[j]);
+     for (j = pScrPriv->numOutputs - 1; j >= 0; j--)
+@@ -227,6 +231,7 @@ SRRResourceChangeNotifyEvent(xRRResource
+     cpswapl(from->window, to->window);
+ }
+ 
++#if !defined(REVERT_RANDR_LEASE)
+ static void _X_COLD
+ SRRLeaseNotifyEvent(xRRLeaseNotifyEvent * from,
+                     xRRLeaseNotifyEvent * to)
+@@ -239,6 +244,7 @@ SRRLeaseNotifyEvent(xRRLeaseNotifyEvent
+     cpswapl(from->lease, to->lease);
+     to->created = from->created;
+ }
++#endif
+ 
+ static void _X_COLD
+ SRRNotifyEvent(xEvent *from, xEvent *to)
+@@ -268,10 +274,12 @@ SRRNotifyEvent(xEvent *from, xEvent *to)
+         SRRResourceChangeNotifyEvent((xRRResourceChangeNotifyEvent *) from,
+                                    (xRRResourceChangeNotifyEvent *) to);
+         break;
++#if !defined(REVERT_RANDR_LEASE)
+     case RRNotify_Lease:
+         SRRLeaseNotifyEvent((xRRLeaseNotifyEvent *) from,
+                             (xRRLeaseNotifyEvent *) to);
+         break;
++#endif
+     default:
+         break;
+     }
+@@ -291,8 +299,10 @@ RRInit(void)
+             return FALSE;
+         if (!RRProviderInit())
+             return FALSE;
++#if !defined(REVERT_RANDR_LEASE)
+         if (!RRLeaseInit())
+             return FALSE;
++#endif
+         RRGeneration = serverGeneration;
+     }
+     if (!dixRegisterPrivateKey(&rrPrivKeyRec, PRIVATE_SCREEN, 0))
+@@ -360,7 +370,9 @@ RRScreenInit(ScreenPtr pScreen)
+     pScrPriv->numCrtcs = 0;
+     pScrPriv->crtcs = NULL;
+ 
++#if !defined(REVERT_RANDR_LEASE)
+     xorg_list_init(&pScrPriv->leases);
++#endif
+ 
+     RRMonitorInit(pScreen);
+ 
+@@ -560,11 +572,13 @@ TellChanged(WindowPtr pWin, void *value)
+             }
+         }
+ 
++#if !defined(REVERT_RANDR_LEASE)
+         if (pRREvent->mask & RRLeaseNotifyMask) {
+             if (pScrPriv->leasesChanged) {
+                 RRDeliverLeaseEvent(client, pWin);
+             }
+         }
++#endif
+     }
+     return WT_WALKCHILDREN;
+ }
diff --git a/modular-xorg-server-dfbsd-meson/patches/patch-randr_rrlease.c b/modular-xorg-server-dfbsd-meson/patches/patch-randr_rrlease.c
new file mode 100644
index 0000000000..19cae12a7f
--- /dev/null
+++ b/modular-xorg-server-dfbsd-meson/patches/patch-randr_rrlease.c
@@ -0,0 +1,55 @@
+$NetBSD$
+
+Option to revert effects of upstream:
+
+2018-02-27	Add RandR leases with modesetting driver support [v6]
+
+commit	e4e3447603b5fd3a38a92c3f972396d1f81168ad
+
+--- randr/rrlease.c.orig	2018-10-15 15:59:33.000000000 +0000
++++ randr/rrlease.c
+@@ -101,6 +101,7 @@ RRLeaseAlloc(ScreenPtr screen, RRLease l
+ Bool
+ RRCrtcIsLeased(RRCrtcPtr crtc)
+ {
++#if !defined(REVERT_RANDR_LEASE)
+     ScreenPtr screen = crtc->pScreen;
+     rrScrPrivPtr scr_priv = rrGetScrPriv(screen);
+     RRLeasePtr lease;
+@@ -111,6 +112,7 @@ RRCrtcIsLeased(RRCrtcPtr crtc)
+             if (lease->crtcs[c] == crtc)
+                 return TRUE;
+     }
++#endif
+     return FALSE;
+ }
+ 
+@@ -120,6 +122,7 @@ RRCrtcIsLeased(RRCrtcPtr crtc)
+ Bool
+ RROutputIsLeased(RROutputPtr output)
+ {
++#if !defined(REVERT_RANDR_LEASE)
+     ScreenPtr screen = output->pScreen;
+     rrScrPrivPtr scr_priv = rrGetScrPriv(screen);
+     RRLeasePtr lease;
+@@ -130,6 +133,7 @@ RROutputIsLeased(RROutputPtr output)
+             if (lease->outputs[o] == output)
+                 return TRUE;
+     }
++#endif
+     return FALSE;
+ }
+ 
+@@ -172,10 +176,12 @@ RRLeaseFree(RRLeasePtr lease)
+ void
+ RRTerminateLease(RRLeasePtr lease)
+ {
++#if !defined(REVERT_RANDR_LEASE)
+     ScreenPtr screen = lease->screen;
+     rrScrPrivPtr scr_priv = rrGetScrPriv(screen);
+ 
+     scr_priv->rrTerminateLease(screen, lease);
++#endif
+ }
+ 
+ /*



Home | Main Index | Thread Index | Old Index