summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorThomas Wood <thomas.wood@intel.com>2015-11-02 17:04:20 +0000
committerThomas Wood <thomas.wood@intel.com>2015-11-11 14:49:46 +0000
commitd01433900906017f16034b60c710cae9581e7755 (patch)
treec4072e6c3028070a08ed7e4553d63e6d76bb55c3 /tests
parent01e1fca5828004954cdb1757409edd99d4b790c3 (diff)
tests/kms_force_connector: add an option to reset connector force states
v2: add missing igt_exit call and fix reset_connectors definition Signed-off-by: Thomas Wood <thomas.wood@intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/kms_force_connector.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/tests/kms_force_connector.c b/tests/kms_force_connector.c
index 40e56136..7aa3c80c 100644
--- a/tests/kms_force_connector.c
+++ b/tests/kms_force_connector.c
@@ -30,13 +30,55 @@ IGT_TEST_DESCRIPTION("Check the debugfs force connector/edid features work"
#define CHECK_MODE(m, h, w, r) igt_assert(m.hdisplay == h && m.vdisplay == w \
&& m.vrefresh == r)
-igt_main
+static void __attribute__((noreturn)) reset_connectors(void)
+{
+ int drm_fd = 0;
+ drmModeRes *res;
+ drmModeConnector *connector = NULL;
+
+ drm_fd = drm_open_driver_master(DRIVER_INTEL);
+ res = drmModeGetResources(drm_fd);
+
+ for (int i = 0; i < res->count_connectors; i++) {
+
+ connector = drmModeGetConnector(drm_fd, res->connectors[i]);
+
+ kmstest_force_connector(drm_fd, connector,
+ FORCE_CONNECTOR_UNSPECIFIED);
+
+ drmModeFreeConnector(connector);
+ }
+
+ exit(0);
+}
+
+static int opt_handler(int opt, int opt_index, void *data)
+{
+ switch (opt) {
+ case 'r':
+ reset_connectors();
+ break;
+ }
+
+ return 0;
+}
+
+int main(int argc, char **argv)
{
/* force the VGA output and test that it worked */
int drm_fd = 0;
drmModeRes *res;
drmModeConnector *vga_connector = NULL, *temp;
int start_n_modes;
+ struct option long_opts[] = {
+ {"reset", 0, 0, 'r'},
+ {0, 0, 0, 0}
+ };
+ const char *help_str =
+ " --reset\t\tReset all connector force states.\n";
+
+ igt_subtest_init_parse_opts(&argc, argv, "", long_opts, help_str,
+ opt_handler, NULL);
igt_fixture {
drm_fd = drm_open_driver_master(DRIVER_INTEL);
@@ -128,4 +170,6 @@ igt_main
igt_fixture {
drmModeFreeConnector(vga_connector);
}
+
+ igt_exit();
}