diff mbox

[i-g-t,2/2] lib/debugfs: Report failures when starting CRC capture

Message ID 1473338324-6986-2-git-send-email-tomeu.vizoso@collabora.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tomeu Vizoso Sept. 8, 2016, 12:38 p.m. UTC
For drivers other than i915, the "auto" source for a given CRTC may be
only able to generate CRCs in specific modeset configurations.

So allow the tests to find out if CRC generation is possible by
returning an error when CRC capture would start so tests can be skipped.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---
 lib/igt_debugfs.c | 28 ++++++++++++++++++++--------
 lib/igt_debugfs.h |  4 ++--
 2 files changed, 22 insertions(+), 10 deletions(-)
diff mbox

Patch

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 1bbbabc9f1c9..4b64ad8d4834 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -325,7 +325,7 @@  static const char *pipe_crc_source_name(enum intel_pipe_crc_source source)
 	return pipe_crc_sources[source];
 }
 
-static bool igt_pipe_crc_do_start(igt_pipe_crc_t *pipe_crc)
+static int igt_pipe_crc_do_start(igt_pipe_crc_t *pipe_crc)
 {
 	char buf[64];
 	int mode = O_RDONLY;
@@ -342,7 +342,7 @@  static bool igt_pipe_crc_do_start(igt_pipe_crc_t *pipe_crc)
 	errno = 0;
 	igt_assert_eq(write(pipe_crc->ctl_fd, buf, strlen(buf)), strlen(buf));
 	if (errno != 0)
-		return false;
+		return errno;
 
 	if (!pipe_crc->is_legacy) {
 		sprintf(buf, "crtc-%d/crc/data", pipe_crc->pipe);
@@ -351,11 +351,11 @@  static bool igt_pipe_crc_do_start(igt_pipe_crc_t *pipe_crc)
 			mode |= O_NONBLOCK;
 		pipe_crc->crc_fd = igt_debugfs_open(buf, mode);
 		if (pipe_crc->crc_fd == -1 && errno == EINVAL)
-			return false;
+			return errno;
 		igt_assert_eq(errno, 0);
 	}
 
-	return true;
+	return 0;
 }
 
 static void igt_pipe_crc_pipe_off(int fd, enum pipe pipe)
@@ -633,11 +633,14 @@  static void read_one_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out)
  *
  * Starts the CRC capture process on @pipe_crc.
  */
-void igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc)
+int igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc)
 {
 	igt_crc_t crc;
+	int ret;
 
-	igt_assert(igt_pipe_crc_do_start(pipe_crc));
+	ret = igt_pipe_crc_do_start(pipe_crc);
+	if (ret)
+		return ret;
 
 	if (pipe_crc->is_legacy) {
 		/*
@@ -651,6 +654,8 @@  void igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc)
 		read_one_crc(pipe_crc, &crc);
 		read_one_crc(pipe_crc, &crc);
 	}
+
+	return 0;
 }
 
 /**
@@ -756,15 +761,22 @@  static void crc_sanity_checks(igt_crc_t *crc)
  * For continuous CRC collection look at igt_pipe_crc_start(),
  * igt_pipe_crc_get_crcs() and igt_pipe_crc_stop().
  */
-void igt_pipe_crc_collect_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out_crc)
+int igt_pipe_crc_collect_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out_crc)
 {
+	int ret;
+
 	igt_debug_wait_for_keypress("crc");
 
-	igt_pipe_crc_start(pipe_crc);
+	ret = igt_pipe_crc_start(pipe_crc);
+	if (ret)
+		return ret;
+
 	read_one_crc(pipe_crc, out_crc);
 	igt_pipe_crc_stop(pipe_crc);
 
 	crc_sanity_checks(out_crc);
+
+	return 0;
 }
 
 /*
diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
index 84d5c0a0a84b..e51a89bbac30 100644
--- a/lib/igt_debugfs.h
+++ b/lib/igt_debugfs.h
@@ -124,12 +124,12 @@  igt_pipe_crc_new_legacy(enum pipe pipe, enum intel_pipe_crc_source source);
 igt_pipe_crc_t *
 igt_pipe_crc_new_nonblock_legacy(enum pipe pipe, enum intel_pipe_crc_source source);
 void igt_pipe_crc_free(igt_pipe_crc_t *pipe_crc);
-void igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc);
+int igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc);
 void igt_pipe_crc_stop(igt_pipe_crc_t *pipe_crc);
 __attribute__((warn_unused_result))
 int igt_pipe_crc_get_crcs(igt_pipe_crc_t *pipe_crc, int n_crcs,
 			  igt_crc_t **out_crcs);
-void igt_pipe_crc_collect_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out_crc);
+int igt_pipe_crc_collect_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out_crc);
 
 /*
  * Drop caches