[Intel-gfx] [PATCH 4/5] lib/tests: make kmstest_get_pipe_from_crtc_id and igt_enable_connectors generic to prepare for platform agnostic tests

Micah Fedke micah.fedke at collabora.co.uk
Fri Jul 31 13:11:10 PDT 2015


---
 lib/igt_kms.c              | 13 +++++++------
 lib/igt_kms.h              |  2 +-
 tests/kms_flip.c           |  2 +-
 tests/kms_pipe_crc_basic.c |  2 +-
 4 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 7e956b4..c067443 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -294,7 +294,8 @@ int kmstest_get_pipe_from_crtc_id(int fd, int crtc_id)
 	memset(&pfci, 0, sizeof(pfci));
 	pfci.crtc_id = crtc_id;
 	ret = drmIoctl(fd, DRM_IOCTL_I915_GET_PIPE_FROM_CRTC_ID, &pfci);
-	igt_assert(ret == 0);
+   if(ret)
+      return -1;
 
 	return pfci.pipe;
 }
@@ -631,6 +632,10 @@ found:
 	config->crtc_idx = i;
 	config->pipe = kmstest_get_pipe_from_crtc_id(drm_fd,
 						     config->crtc->crtc_id);
+   if(config->pipe == -1) {
+      igt_warn("could not get pipe from crtc id, using index\n");
+      config->pipe = i;
+   }
 
 	drmModeFreeResources(resources);
 
@@ -1801,13 +1806,10 @@ void igt_wait_for_vblank(int drm_fd, enum pipe pipe)
  * An exit handler is installed to ensure connectors are reset when the test
  * exits.
  */
-void igt_enable_connectors(void)
+void igt_enable_connectors(int drm_fd)
 {
 	drmModeRes *res;
 	drmModeConnector *c;
-	int drm_fd;
-
-	drm_fd = drm_open_driver(DRIVER_INTEL);
 
 	res = drmModeGetResources(drm_fd);
 
@@ -1830,7 +1832,6 @@ void igt_enable_connectors(void)
 
 		drmModeFreeConnector(c);
 	}
-	close(drm_fd);
 }
 
 /**
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 565df14..b5f007d 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -270,7 +270,7 @@ void igt_wait_for_vblank(int drm_fd, enum pipe pipe);
 
 #define IGT_FIXED(i,f)	((i) << 16 | (f))
 
-void igt_enable_connectors(void);
+void igt_enable_connectors(int drm_fd);
 void igt_reset_connectors(void);
 
 #define EDID_LENGTH 128
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 4d8d0c0..a88e707 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -1702,7 +1702,7 @@ int main(int argc, char **argv)
 	igt_fixture {
 		drm_fd = drm_open_driver_master(DRIVER_INTEL);
 
-		igt_enable_connectors();
+		igt_enable_connectors(drm_fd);
 
 		kmstest_set_vt_graphics_mode();
 		igt_install_exit_handler(kms_flip_exit_handler);
diff --git a/tests/kms_pipe_crc_basic.c b/tests/kms_pipe_crc_basic.c
index fc4ad46..10ef097 100644
--- a/tests/kms_pipe_crc_basic.c
+++ b/tests/kms_pipe_crc_basic.c
@@ -228,7 +228,7 @@ igt_main
 	igt_fixture {
 		data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
 
-		igt_enable_connectors();
+		igt_enable_connectors(data.drm_fd);
 
 		kmstest_set_vt_graphics_mode();
 
-- 
2.1.4



More information about the Intel-gfx mailing list