xf86-video-intel: configure.ac test/Makefile.am test/xvidmode.c

Chris Wilson ickle at kemper.freedesktop.org
Wed May 4 11:36:14 UTC 2016


 configure.ac     |    3 +++
 test/Makefile.am |    6 ++++++
 test/xvidmode.c  |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 63 insertions(+)

New commits:
commit 47cd7fdd0b0fe004c77b1c7862161d8968af2cc2
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed May 4 11:09:51 2016 +0100

    test: Exercise XVidMode switching
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/configure.ac b/configure.ac
index c18ad96..a08661e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -280,6 +280,9 @@ PKG_CHECK_MODULES(X11_DRI3, [xcb-dri3 xcb-sync xcb-xfixes xcb-present x11-xcb xs
 AM_CONDITIONAL(X11_DRI3, test "x$x11_dri3" = "xyes" -a "x$shm" = "xyes")
 AM_CONDITIONAL(X11_SHM, test "x$shm" = "xyes")
 
+PKG_CHECK_MODULES(X11_VM, [xxf86vm], [x11_vm="yes"], [x11_vm="no"])
+AM_CONDITIONAL(X11_VM, test "x$x11_vm" = "xyes")
+
 AC_ARG_ENABLE(tools,
               AS_HELP_STRING([--disable-tools],
 			     [Enable building and installing the miscellaneous tools [default=auto]]),
diff --git a/test/Makefile.am b/test/Makefile.am
index 286a03b..7bda948 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -28,6 +28,12 @@ stress_TESTS = \
 	shm-test \
 	$(NULL)
 
+if X11_VM
+stress_TESTS += \
+	xvidmode \
+	$(NULL)
+endif
+
 if DRI2
 stress_TESTS += \
 	dri2-race \
diff --git a/test/xvidmode.c b/test/xvidmode.c
new file mode 100644
index 0000000..5cde828
--- /dev/null
+++ b/test/xvidmode.c
@@ -0,0 +1,54 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/xf86vmode.h>
+
+int main(void)
+{
+	Display *dpy;
+	XF86VidModeModeLine current;
+	XF86VidModeModeInfo **modes;
+	int num_modes, i;
+	int saved_mode = -1;
+	int dotclock;
+
+	dpy = XOpenDisplay(NULL);
+	if (dpy == NULL)
+		dpy = XOpenDisplay(":0");
+
+	XF86VidModeGetModeLine(dpy, DefaultScreen(dpy), &dotclock, &current);
+	XF86VidModeGetAllModeLines(dpy, XDefaultScreen(dpy),
+				   &num_modes, &modes);
+	for (i = 0; i < num_modes; i++) {
+		int this;
+
+		this = (current.hdisplay == modes[i]->hdisplay &&
+			current.vdisplay == modes[i]->vdisplay &&
+			dotclock == modes[i]->dotclock);
+		if (this && saved_mode == -1)
+			saved_mode = i;
+
+		printf("[%d] %dx%d%s\n",
+		       i,
+		       modes[i]->hdisplay,
+		       modes[i]->vdisplay,
+		       this ? "*" : "");
+	}
+
+	for (i = 0; i < num_modes; i++) {
+		printf("Switching to mode %dx%d\n",
+		       modes[i]->hdisplay,
+		       modes[i]->vdisplay);
+		XF86VidModeSwitchToMode(dpy, XDefaultScreen(dpy), modes[i]);
+		XSync(dpy, True);
+	}
+
+	if (saved_mode != -1) {
+		XF86VidModeSwitchToMode(dpy, XDefaultScreen(dpy),
+					modes[saved_mode]);
+		XFlush(dpy);
+	}
+
+	return 0;
+}


More information about the xorg-commit mailing list