summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThomas Wood <thomas.wood@intel.com>2014-05-28 14:06:01 +0100
committerThomas Wood <thomas.wood@intel.com>2014-07-11 11:47:46 +0100
commitb6ed9fb0d9a68cd3e07154b80e78e60778a4887b (patch)
treee0cde66e5549a83a15d9d637994ca9bafb561256 /lib
parent13cd79c128b21d0de7d419d2ebfa8219d6190035 (diff)
lib: add igt_enable_connectors and igt_reset_connectors
igt_enable_connectors forces connectors to be enabled where doing so is known to work well. igt_reset_connectors resets the force state on all connectors.
Diffstat (limited to 'lib')
-rw-r--r--lib/igt_kms.c70
-rw-r--r--lib/igt_kms.h3
2 files changed, 73 insertions, 0 deletions
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 4a2551aa..aa548446 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1381,3 +1381,73 @@ void igt_wait_for_vblank(int drm_fd, enum pipe pipe)
igt_assert(drmWaitVBlank(drm_fd, &wait_vbl) == 0);
}
+
+static void reset_connectors_at_exit(int sig)
+{
+ igt_reset_connectors();
+}
+
+/**
+ * igt_enable_connectors:
+ *
+ * Force connectors to be enabled where this is known to work well. Use
+ * #igt_reset_connectors to revert the changes.
+ *
+ * An exit handler is installed to ensure connectors are reset when the test
+ * exits.
+ */
+void igt_enable_connectors(void)
+{
+ drmModeRes *res;
+ drmModeConnector *c;
+ int drm_fd;
+
+ drm_fd = drm_open_any();
+
+ res = drmModeGetResources(drm_fd);
+
+ for (int i = 0; i < res->count_connectors; i++) {
+
+ c = drmModeGetConnector(drm_fd, res->connectors[i]);
+
+ /* don't attempt to force connectors that are already connected
+ */
+ if (c->connection == DRM_MODE_CONNECTED)
+ continue;
+
+ /* just enable VGA for now */
+ if (c->connector_type == DRM_MODE_CONNECTOR_VGA)
+ kmstest_force_connector(drm_fd, c, FORCE_CONNECTOR_ON);
+
+ drmModeFreeConnector(c);
+ }
+ close(drm_fd);
+
+ igt_install_exit_handler(reset_connectors_at_exit);
+}
+
+/**
+ * igt_reset_connectors:
+ *
+ * Remove any forced state from the connectors.
+ */
+void igt_reset_connectors(void)
+{
+ drmModeRes *res;
+ drmModeConnector *c;
+ int drm_fd;
+
+ drm_fd = drm_open_any();
+ res = drmModeGetResources(drm_fd);
+
+ for (int i = 0; i < res->count_connectors; i++) {
+
+ c = drmModeGetConnector(drm_fd, res->connectors[i]);
+
+ kmstest_force_connector(drm_fd, c, FORCE_CONNECTOR_UNSPECIFIED);
+
+ drmModeFreeConnector(c);
+ }
+
+ close(drm_fd);
+}
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index e97febea..07c24183 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -228,5 +228,8 @@ 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_reset_connectors(void);
+
#endif /* __IGT_KMS_H__ */