[PATCH igt] lib/kms: Pass fd to igt_enable_connectors()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Pass the fd along to igt_enable_connectors() so that it actually dtrt
when there are multiple drm devices in the system.

Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
---
 lib/igt_kms.c                | 13 ++++---------
 lib/igt_kms.h                |  2 +-
 tests/kms_flip.c             |  2 +-
 tests/kms_invalid_dotclock.c |  2 +-
 tests/kms_pipe_crc_basic.c   |  2 +-
 5 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 0c6dbf74..4ad16f13 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -3182,21 +3182,18 @@ 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 fd)
 {
 	drmModeRes *res;
-	int drm_fd;
 
-	drm_fd = drm_open_driver(DRIVER_ANY);
-
-	res = drmModeGetResources(drm_fd);
+	res = drmModeGetResources(fd);
 	igt_assert(res != NULL);
 
 	for (int i = 0; i < res->count_connectors; i++) {
 		drmModeConnector *c;
 
 		/* Do a probe. This may be the first action after booting */
-		c = drmModeGetConnector(drm_fd, res->connectors[i]);
+		c = drmModeGetConnector(fd, res->connectors[i]);
 		if (!c) {
 			igt_warn("Could not read connector %u: %m\n", res->connectors[i]);
 			continue;
@@ -3209,7 +3206,7 @@ void igt_enable_connectors(void)
 
 		/* just enable VGA for now */
 		if (c->connector_type == DRM_MODE_CONNECTOR_VGA) {
-			if (!kmstest_force_connector(drm_fd, c, FORCE_CONNECTOR_ON))
+			if (!kmstest_force_connector(fd, c, FORCE_CONNECTOR_ON))
 				igt_info("Unable to force state on %s-%d\n",
 					 kmstest_connector_type_str(c->connector_type),
 					 c->connector_type_id);
@@ -3217,8 +3214,6 @@ void igt_enable_connectors(void)
 
 		drmModeFreeConnector(c);
 	}
-
-	close(drm_fd);
 }
 
 /**
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 4e7cd385..c2bc0d3a 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -539,7 +539,7 @@ static inline bool igt_output_is_connected(igt_output_t *output)
 	igt_assert_lt(0, drmModeAtomicAddProperty(req, output->config.connector->connector_id,\
 						  output->config.atomic_props_connector[prop], value))
 
-void igt_enable_connectors(void);
+void igt_enable_connectors(int fd);
 void igt_reset_connectors(void);
 
 void igt_kms_disallow_hotplug(int fd);
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 4210d663..81516def 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -1650,7 +1650,7 @@ int main(int argc, char **argv)
 	igt_fixture {
 		drm_fd = drm_open_driver_master(DRIVER_ANY);
 
-		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_invalid_dotclock.c b/tests/kms_invalid_dotclock.c
index e6e72f52..b0942e59 100644
--- a/tests/kms_invalid_dotclock.c
+++ b/tests/kms_invalid_dotclock.c
@@ -131,7 +131,7 @@ igt_simple_main
 	data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
 	igt_require_intel(data.drm_fd);
 
-	igt_enable_connectors();
+	igt_enable_connectors(data.drm_fd);
 	kmstest_set_vt_graphics_mode();
 	igt_display_init(&data.display, data.drm_fd);
 	data.res = drmModeGetResources(data.drm_fd);
diff --git a/tests/kms_pipe_crc_basic.c b/tests/kms_pipe_crc_basic.c
index 35adddba..bf51b4cb 100644
--- a/tests/kms_pipe_crc_basic.c
+++ b/tests/kms_pipe_crc_basic.c
@@ -185,7 +185,7 @@ igt_main
 	igt_fixture {
 		data.drm_fd = drm_open_driver_master(DRIVER_ANY);
 
-		igt_enable_connectors();
+		igt_enable_connectors(data.drm_fd);
 
 		kmstest_set_vt_graphics_mode();
 
-- 
2.13.3

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux