git: 72478310d3b0 - main - x11-drivers/xf86-video-qxl: Resurrect xf86-video-qxl, driver for QXL GPU

From: Hiroki Sato <hrs_at_FreeBSD.org>
Date: Sat, 11 Feb 2023 06:52:32 UTC
The branch main has been updated by hrs:

URL: https://cgit.FreeBSD.org/ports/commit/?id=72478310d3b01ca54f1dfa955544ec88db731ffe

commit 72478310d3b01ca54f1dfa955544ec88db731ffe
Author:     Hiroki Sato <hrs@FreeBSD.org>
AuthorDate: 2023-02-11 03:57:57 +0000
Commit:     Hiroki Sato <hrs@FreeBSD.org>
CommitDate: 2023-02-11 03:57:57 +0000

    x11-drivers/xf86-video-qxl: Resurrect xf86-video-qxl, driver for QXL GPU
---
 MOVED                                              |  1 -
 x11-drivers/Makefile                               |  1 +
 x11-drivers/xf86-video-qxl/Makefile                | 35 ++++++++++++++++++
 x11-drivers/xf86-video-qxl/distinfo                |  3 ++
 .../xf86-video-qxl/files/patch-spiceqxl_audio.c    | 14 ++++++++
 .../xf86-video-qxl/files/patch-src-mspace.h        | 11 ++++++
 .../xf86-video-qxl/files/patch-src-qxl_driver.c    | 25 +++++++++++++
 .../files/patch-src-qxl_option_helpers.c           | 41 ++++++++++++++++++++++
 .../files/patch-src-qxl_option_helpers.h           | 19 ++++++++++
 .../xf86-video-qxl/files/patch-src-qxl_ums_mode.c  | 11 ++++++
 x11-drivers/xf86-video-qxl/pkg-descr               |  3 ++
 x11-drivers/xf86-video-qxl/pkg-plist               |  5 +++
 12 files changed, 168 insertions(+), 1 deletion(-)

diff --git a/MOVED b/MOVED
index 8fa5a3e88cfd..c9880e413bd0 100644
--- a/MOVED
+++ b/MOVED
@@ -15488,7 +15488,6 @@ www/waccess||2020-09-19|Has expired: Uses deprecated version of python
 www/wadcomblog||2020-09-19|Has expired: Uses deprecated version of python
 www/webcheck||2020-09-19|Has expired: Uses deprecated version of python
 www/woof||2020-09-19|Has expired: Uses deprecated version of python
-x11-drivers/xf86-video-qxl||2020-09-19|Has expired: uses deprecated version of python
 x11-fm/twander||2020-09-19|Has expired: Uses deprecated version of python
 x11-wm/compizconfig-python||2020-09-19|Has expired: Uses deprecated version of python
 x11-wm/fvwm-crystal||2020-09-19|Has expired: Uses deprecated version of python
diff --git a/x11-drivers/Makefile b/x11-drivers/Makefile
index 24e668fc50d8..15c37d7a8a45 100644
--- a/x11-drivers/Makefile
+++ b/x11-drivers/Makefile
@@ -28,6 +28,7 @@
     SUBDIR += xf86-video-neomagic
     SUBDIR += xf86-video-nv
     SUBDIR += xf86-video-openchrome
+    SUBDIR += xf86-video-qxl
     SUBDIR += xf86-video-r128
     SUBDIR += xf86-video-rendition
     SUBDIR += xf86-video-savage
diff --git a/x11-drivers/xf86-video-qxl/Makefile b/x11-drivers/xf86-video-qxl/Makefile
new file mode 100644
index 000000000000..6c336ab8ba7f
--- /dev/null
+++ b/x11-drivers/xf86-video-qxl/Makefile
@@ -0,0 +1,35 @@
+PORTNAME=	xf86-video-qxl
+DISTVERSION=	0.1.5
+PORTREVISION=	5
+CATEGORIES=	x11-drivers
+
+MAINTAINER=	hrs@FreeBSD.org
+COMMENT=	X.Org X server -- QXL display driver
+WWW=		https://www.x.org/
+
+LICENSE=	MIT
+
+BUILD_DEPENDS=	spice-protocol>=0.12.10:devel/spice-protocol \
+		${LOCALBASE}/include/linux/input.h:devel/evdev-proto
+LIB_DEPENDS=	libspice-server.so:devel/libspice-server \
+		libudev.so:devel/libudev-devd
+
+USES=		localbase:ldflags pkgconfig python shebangfix xorg \
+		xorg-cat:driver
+USE_XORG=	xfont2
+
+CONFIGURE_ARGS+=--enable-xspice
+
+python_OLD_CMD=	/usr/bin/python
+SHEBANG_FILES=	scripts/Xspice
+
+OPTIONS_DEFINE=	DOCS
+
+pre-install:
+	@${MKDIR} ${STAGEDIR}${PREFIX}/etc/X11/xorg.conf.d
+
+post-install:
+	${INSTALL_DATA} ${WRKSRC}/examples/spiceqxl.xorg.conf.example \
+	    ${STAGEDIR}${PREFIX}/etc/X11/xorg.conf.d/spiceqxl.xorg.conf.example
+
+.include <bsd.port.mk>
diff --git a/x11-drivers/xf86-video-qxl/distinfo b/x11-drivers/xf86-video-qxl/distinfo
new file mode 100644
index 000000000000..0a152f7d5154
--- /dev/null
+++ b/x11-drivers/xf86-video-qxl/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1514372367
+SHA256 (xorg/driver/xf86-video-qxl-0.1.5.tar.bz2) = b18682e04503c6326f7bf7190f3ee50a3d4d69758a2a3cc9af102a6b3f114c92
+SIZE (xorg/driver/xf86-video-qxl-0.1.5.tar.bz2) = 508266
diff --git a/x11-drivers/xf86-video-qxl/files/patch-spiceqxl_audio.c b/x11-drivers/xf86-video-qxl/files/patch-spiceqxl_audio.c
new file mode 100644
index 000000000000..9ba92890929e
--- /dev/null
+++ b/x11-drivers/xf86-video-qxl/files/patch-spiceqxl_audio.c
@@ -0,0 +1,14 @@
+--- src/spiceqxl_audio.c.bak	2017-09-12 12:00:11 UTC
++++ src/spiceqxl_audio.c
+@@ -410,7 +410,10 @@
+         strcat(fname, "/");
+         strcat(fname, e->name);
+ 
+-        f->fd = open(fname, O_RDONLY | O_RSYNC | O_NONBLOCK);
++//        f->fd = open(fname, O_RDONLY | O_RSYNC | O_NONBLOCK);
++        // POSIX specifies three different flavors for synchronous I/O: O_SYNC, O_DSYNC, and O_RSYNC.
++        // In BSD, these are all equivalent.
++        f->fd = open(fname, O_RDONLY | O_SYNC | O_NONBLOCK);
+         free(fname);
+         if (f->fd < 0) {
+             ErrorF("playback: open FIFO '%s' failed: %s\n", e->name, strerror(errno));
diff --git a/x11-drivers/xf86-video-qxl/files/patch-src-mspace.h b/x11-drivers/xf86-video-qxl/files/patch-src-mspace.h
new file mode 100644
index 000000000000..11a5a9dc55ea
--- /dev/null
+++ b/x11-drivers/xf86-video-qxl/files/patch-src-mspace.h
@@ -0,0 +1,11 @@
+--- src/mspace.h.orig	2023-01-07 19:53:51 UTC
++++ src/mspace.h
+@@ -9,7 +9,7 @@ extern "C" {
+ 
+ //typedef unsigned long size_t;
+ typedef void (*mspace_abort_t)(void *user_data);
+-typedef void (*mspace_print_t)(void *user_data, const char *format, ...)  __attribute__((format(gnu_printf, 2, 3)));
++typedef void (*mspace_print_t)(void *user_data, const char *format, ...)  __attribute__((__format__(__printf__, 2, 3)));
+ 
+ void mspace_set_abort_func(mspace_abort_t f);
+ void mspace_set_print_func(mspace_print_t f);
diff --git a/x11-drivers/xf86-video-qxl/files/patch-src-qxl_driver.c b/x11-drivers/xf86-video-qxl/files/patch-src-qxl_driver.c
new file mode 100644
index 000000000000..1eecfe2c9cb7
--- /dev/null
+++ b/x11-drivers/xf86-video-qxl/files/patch-src-qxl_driver.c
@@ -0,0 +1,25 @@
+--- src/qxl_driver.c.orig	2016-12-19 17:25:56 UTC
++++ src/qxl_driver.c
+@@ -807,8 +807,8 @@ qxl_screen_init (SCREEN_INIT_ARGS_DECL)
+     
+     CHECK_POINT ();
+     
+-    pScreen->width = pScrn->currentMode->HDisplay;
+-    pScreen->height = pScrn->currentMode->VDisplay;
++    pScreen->width = qxl->primary_mode.x_res;
++    pScreen->height = qxl->primary_mode.y_res;
+     
+     if (!xf86CrtcScreenInit (pScreen))
+ 	return FALSE;
+@@ -1005,6 +1005,11 @@ qxl_pre_init_common(ScrnInfoPtr pScrn)
+         get_bool_option (qxl->options, OPTION_DEBUG_RENDER_FALLBACKS, "QXL_DEBUG_RENDER_FALLBACKS");
+     qxl->num_heads =
+         get_int_option (qxl->options, OPTION_NUM_HEADS, "QXL_NUM_HEADS");
++    if (qxl->num_heads == 0) {
++        xf86DrvMsg (scrnIndex, X_INFO, "QXL_NUM_HEADS not configured, "
++            "defaulting to 1\n");
++        qxl->num_heads = 1;
++    }
+ 
+     qxl->deferred_fps = get_int_option(qxl->options, OPTION_SPICE_DEFERRED_FPS, "XSPICE_DEFERRED_FPS");
+     if (qxl->deferred_fps > 0)
diff --git a/x11-drivers/xf86-video-qxl/files/patch-src-qxl_option_helpers.c b/x11-drivers/xf86-video-qxl/files/patch-src-qxl_option_helpers.c
new file mode 100644
index 000000000000..844ab5e0072c
--- /dev/null
+++ b/x11-drivers/xf86-video-qxl/files/patch-src-qxl_option_helpers.c
@@ -0,0 +1,41 @@
+--- src/qxl_option_helpers.c.orig	2015-10-12 16:31:14 UTC
++++ src/qxl_option_helpers.c
+@@ -10,31 +10,32 @@
+ 
+ #include "qxl_option_helpers.h"
+ 
+-int get_int_option(OptionInfoPtr options, int option_index,
++int get_int_option(OptionInfoPtr options, int token,
+                    const char *env_name)
+ {
++    int value;
+     if (env_name && getenv(env_name)) {
+         return atoi(getenv(env_name));
+     }
+-    return options[option_index].value.num;
++    return xf86GetOptValInteger(options, token, &value) ? value : 0;
+ }
+ 
+-const char *get_str_option(OptionInfoPtr options, int option_index,
++const char *get_str_option(OptionInfoPtr options, int token,
+                            const char *env_name)
+ {
+     if (getenv(env_name)) {
+         return getenv(env_name);
+     }
+-    return options[option_index].value.str;
++    return xf86GetOptValString(options, token);
+ }
+ 
+-int get_bool_option(OptionInfoPtr options, int option_index,
++int get_bool_option(OptionInfoPtr options, int token,
+                      const char *env_name)
+ {
+     const char* value = getenv(env_name);
+ 
+     if (!value) {
+-        return options[option_index].value.bool;
++        return xf86ReturnOptValBool(options, token, FALSE);
+     }
+     if (strcmp(value, "0") == 0 ||
+         strcasecmp(value, "off") == 0 ||
diff --git a/x11-drivers/xf86-video-qxl/files/patch-src-qxl_option_helpers.h b/x11-drivers/xf86-video-qxl/files/patch-src-qxl_option_helpers.h
new file mode 100644
index 000000000000..7c4301816014
--- /dev/null
+++ b/x11-drivers/xf86-video-qxl/files/patch-src-qxl_option_helpers.h
@@ -0,0 +1,19 @@
+--- src/qxl_option_helpers.h.orig	2023-01-07 19:55:44 UTC
++++ src/qxl_option_helpers.h
+@@ -6,13 +6,13 @@
+ #include <xf86Crtc.h>
+ #include <xf86Opt.h>
+ 
+-int get_int_option(OptionInfoPtr options, int option_index,
++int get_int_option(OptionInfoPtr options, int token,
+                    const char *env_name);
+ 
+-const char *get_str_option(OptionInfoPtr options, int option_index,
++const char *get_str_option(OptionInfoPtr options, int token,
+                            const char *env_name);
+ 
+-int get_bool_option(OptionInfoPtr options, int option_index,
++int get_bool_option(OptionInfoPtr options, int token,
+                      const char *env_name);
+ 
+ #endif // OPTION_HELPERS_H
diff --git a/x11-drivers/xf86-video-qxl/files/patch-src-qxl_ums_mode.c b/x11-drivers/xf86-video-qxl/files/patch-src-qxl_ums_mode.c
new file mode 100644
index 000000000000..1f3b15b63032
--- /dev/null
+++ b/x11-drivers/xf86-video-qxl/files/patch-src-qxl_ums_mode.c
@@ -0,0 +1,11 @@
+--- src/qxl_ums_mode.c.orig	2023-01-07 21:22:08 UTC
++++ src/qxl_ums_mode.c
+@@ -65,7 +65,7 @@ qxl_add_mode (qxl_screen_t *qxl, ScrnInfoPtr pScrn, in
+     DisplayModePtr mode;
+ 
+     mode = screen_create_mode (pScrn, width, height, type);
+-    qxl->x_modes = xf86ModesAdd (qxl->x_modes, mode);
++    pScrn->modes = qxl->x_modes = xf86ModesAdd (qxl->x_modes, mode);
+ 
+     return mode;
+ }
diff --git a/x11-drivers/xf86-video-qxl/pkg-descr b/x11-drivers/xf86-video-qxl/pkg-descr
new file mode 100644
index 000000000000..005c4e802ea4
--- /dev/null
+++ b/x11-drivers/xf86-video-qxl/pkg-descr
@@ -0,0 +1,3 @@
+X.Org xf86-video-qxl driver, which supports the QXL virtual GPU
+found in the RedHat Enterprise Virtualisation system, and also in
+the spice project.
diff --git a/x11-drivers/xf86-video-qxl/pkg-plist b/x11-drivers/xf86-video-qxl/pkg-plist
new file mode 100644
index 000000000000..d6b0686ca6b0
--- /dev/null
+++ b/x11-drivers/xf86-video-qxl/pkg-plist
@@ -0,0 +1,5 @@
+lib/xorg/modules/drivers/spiceqxl_drv.so
+lib/xorg/modules/drivers/qxl_drv.so
+bin/Xspice
+%%PORTDOCS%%%%DOCSDIR%%/spiceqxl.xorg.conf.example
+@sample etc/X11/xorg.conf.d/spiceqxl.xorg.conf.example etc/X11/xorg.conf.d/spiceqxl.xorg.conf