summaryrefslogtreecommitdiff
path: root/lib/igt_kms.c
diff options
context:
space:
mode:
authorMaarten Lankhorst <maarten.lankhorst@linux.intel.com>2016-06-13 15:27:22 +0200
committerMaarten Lankhorst <maarten.lankhorst@linux.intel.com>2016-06-29 14:57:11 +0200
commitbe13126cc861b886720bfbffe8edeb60f10fdb94 (patch)
tree0e2e415d8f706801e1b2a9936d64ad71d30eef9b /lib/igt_kms.c
parent3916465bb935fc80c4fe9a7e20d848fcb0aba5b0 (diff)
lib/igt_kms: Add for_each_pipe_with_valid_output and for_each_valid_output_on_pipe.
There are a lot of places where we do either for_each_pipe { igt_subtest_f(... "-pipe-C", pipe_name()) for_each_connected_output() /* Run subtest */ } or: igt_subtest_f(...) { for_each_pipe() for_each_connected_output() /* Run subtest */ } The former should be replaced with for_each_valid_output_on_pipe, the latter with for_each_pipe_with_valid_output. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Diffstat (limited to 'lib/igt_kms.c')
-rw-r--r--lib/igt_kms.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index af72b908..f9e32a5a 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -773,8 +773,8 @@ static bool _kmstest_connector_config(int drm_fd, uint32_t connector_id,
{
drmModeRes *resources;
drmModeConnector *connector;
- drmModeEncoder *encoder;
- int i, j;
+ drmModeEncoder *encoder, *found = NULL;
+ int i, j, pipe;
resources = drmModeGetResources(drm_fd);
if (!resources) {
@@ -810,9 +810,9 @@ static bool _kmstest_connector_config(int drm_fd, uint32_t connector_id,
* In both cases find the first compatible encoder and skip the CRTC
* if there is non such.
*/
- encoder = NULL; /* suppress GCC warning */
+ config->valid_crtc_idx_mask = 0;
for (i = 0; i < resources->count_crtcs; i++) {
- if (!resources->crtcs[i] || !(crtc_idx_mask & (1 << i)))
+ if (!resources->crtcs[i])
continue;
/* Now get a compatible encoder */
@@ -828,24 +828,27 @@ static bool _kmstest_connector_config(int drm_fd, uint32_t connector_id,
continue;
}
- if (encoder->possible_crtcs & (1 << i))
- goto found;
+ config->valid_crtc_idx_mask |= encoder->possible_crtcs;
- drmModeFreeEncoder(encoder);
+ if (!found && (crtc_idx_mask & encoder->possible_crtcs & (1 << i))) {
+ found = encoder;
+ pipe = i;
+ } else
+ drmModeFreeEncoder(encoder);
}
}
- goto err3;
+ if (!found)
+ goto err3;
-found:
if (!kmstest_get_connector_default_mode(drm_fd, connector,
&config->default_mode))
goto err4;
config->connector = connector;
- config->encoder = encoder;
- config->crtc = drmModeGetCrtc(drm_fd, resources->crtcs[i]);
- config->crtc_idx = i;
+ config->encoder = found;
+ config->crtc = drmModeGetCrtc(drm_fd, resources->crtcs[pipe]);
+ config->crtc_idx = pipe;
config->pipe = kmstest_get_pipe_from_crtc_id(drm_fd,
config->crtc->crtc_id);
@@ -853,7 +856,7 @@ found:
return true;
err4:
- drmModeFreeEncoder(encoder);
+ drmModeFreeEncoder(found);
err3:
drmModeFreeConnector(connector);
err2: