diff mbox

[i-g-t,v4,1/7] lib/igt_kms: Add forcing TEST_ONLY for atomic commits

Message ID 1490273311-9794-2-git-send-email-mika.kahola@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mika Kahola March 23, 2017, 12:48 p.m. UTC
Add an option to force atomic commits to do commits with TEST_ONLY flag
first before doing the actual commit.

v2: Clear force_test_atomic flag if atomic commit with TEST_ONLY
    flag fails (Maarten)

Signed-off-by: Mika Kahola <mika.kahola@intel.com>
---
 lib/igt_kms.c | 22 +++++++++++++++++++++-
 lib/igt_kms.h |  1 +
 2 files changed, 22 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index d9f9672..a687939 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -2436,7 +2436,27 @@  static int igt_atomic_commit(igt_display_t *display, uint32_t flags, void *user_
 		igt_atomic_prepare_connector_commit(output, req);
 	}
 
-	ret = drmModeAtomicCommit(display->drm_fd, req, flags, user_data);
+	if (display->force_test_atomic &&
+	    !(flags & DRM_MODE_ATOMIC_TEST_ONLY)) {
+		unsigned int test_flags = flags & ~DRM_MODE_PAGE_FLIP_EVENT;
+		int test_ret;
+
+		test_flags |= DRM_MODE_ATOMIC_TEST_ONLY;
+
+		test_ret = drmModeAtomicCommit(display->drm_fd, req, test_flags, user_data);
+		ret = drmModeAtomicCommit(display->drm_fd, req, flags, user_data);
+
+		if (test_ret) {
+			if (test_ret != ret)
+				display->force_test_atomic = false;
+
+			igt_assert_eq(test_ret, ret);
+		} else {
+			igt_assert(ret != -EINVAL);
+		}
+	} else
+		ret = drmModeAtomicCommit(display->drm_fd, req, flags, user_data);
+
 	if (!ret) {
 
 		for_each_pipe(display, pipe) {
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 595832d..2972e94 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -368,6 +368,7 @@  struct igt_display {
 	igt_pipe_t *pipes;
 	bool has_cursor_plane;
 	bool is_atomic;
+	bool force_test_atomic;
 };
 
 void igt_display_init(igt_display_t *display, int drm_fd);