diff mbox

[v3] kms_flip: make sure we are unblanked during the test

Message ID 1367939102-10034-1-git-send-email-imre.deak@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Imre Deak May 7, 2013, 3:05 p.m. UTC
This is one reason for some of the sporadic kms_flip failures.
One such is https://bugs.freedesktop.org/show_bug.cgi?id=59834.

v2:
- use unsigned long for KDSETMODE/KDGETMODE
- fix passing the parameter to KDGETMODE as it should be by value
- actually testing that it works..

v3:
- don't do an explicit DPMS_ON, only switch to graphics mode.

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 tests/kms_flip.c |   26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 39f0043..4993b16 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -36,6 +36,7 @@ 
 #include <sys/time.h>
 #include <sys/mman.h>
 #include <sys/ioctl.h>
+#include <linux/kd.h>
 
 #include "i915_drm.h"
 #include "drmtest.h"
@@ -1153,6 +1154,21 @@  static void get_timestamp_format(void)
 		monotonic_timestamp ? "monotonic" : "real");
 }
 
+static unsigned long set_vt_mode(unsigned long mode)
+{
+	int fd;
+	unsigned long prev_mode;
+
+	fd = open("/dev/tty0", O_RDONLY);
+	assert(fd >= 0);
+
+	prev_mode = 0;
+	drmIoctl(fd, KDGETMODE, &prev_mode);
+	drmIoctl(fd, KDSETMODE, (void *)mode);
+
+	return prev_mode;
+}
+
 int main(int argc, char **argv)
 {
 	struct {
@@ -1200,13 +1216,18 @@  int main(int argc, char **argv)
 		{ 1, TEST_FLIP | TEST_EINVAL | TEST_FB_BAD_TILING, "flip-vs-bad-tiling" },
 	};
 	int i;
+	bool dry_run;
+	unsigned long prev_vt_mode;
 
 	drmtest_subtest_init(argc, argv);
 
 	drm_fd = drm_open_any();
 
-	if (!drmtest_only_list_subtests())
+	dry_run = drmtest_only_list_subtests();
+	if (!dry_run) {
+		prev_vt_mode = set_vt_mode(KD_GRAPHICS);
 		get_timestamp_format();
+	}
 
 	bufmgr = drm_intel_bufmgr_gem_init(drm_fd, 4096);
 	devid = intel_get_drm_devid(drm_fd);
@@ -1219,6 +1240,9 @@  int main(int argc, char **argv)
 		}
 	}
 
+	if (!dry_run)
+		set_vt_mode(prev_vt_mode);
+
 	close(drm_fd);
 
 	return 0;