From ecfec9583a0f1076dd28e8102de9b5c5834a9d62 Mon Sep 17 00:00:00 2001 From: Paulo Zanoni Date: Wed, 6 Jan 2016 18:53:17 -0200 Subject: [PATCH igt] tests/pm_rpm: find an appropriate CRTC instead of hardcoding CRTC 0 BSW does not allow CRTC 0 to be used on every connector, so we need to write code to actually find a suitable CRTC. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93124 Signed-off-by: Paulo Zanoni --- tests/pm_rpm.c | 51 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/tests/pm_rpm.c b/tests/pm_rpm.c index d8e8b2c..578d626 100644 --- a/tests/pm_rpm.c +++ b/tests/pm_rpm.c @@ -224,12 +224,32 @@ static void disable_or_dpms_all_screens(struct mode_set_data *data, bool dpms) igt_assert(wait_for_suspended()); \ } while (0) +static uint32_t find_crtc_for_connector(struct mode_set_data *data, + drmModeConnectorPtr connector) +{ + drmModeEncoderPtr e; + uint32_t crtc_id = 0; + int i, j; + + for (i = 0; i < connector->count_encoders && !crtc_id; i++) { + e = drmModeGetEncoder(drm_fd, connector->encoders[i]); + + for (j = 0; (e->possible_crtcs >> j) && !crtc_id; j++) + if (e->possible_crtcs & (1 << j)) + crtc_id = data->res->crtcs[j]; + + drmModeFreeEncoder(e); + } + + return crtc_id; +} + static bool init_modeset_params_for_type(struct mode_set_data *data, struct modeset_params *params, enum screen_type type) { int i; - uint32_t connector_id = 0; + drmModeConnectorPtr connector = NULL; drmModeModeInfoPtr mode = NULL; cairo_t *cr; @@ -245,13 +265,13 @@ static bool init_modeset_params_for_type(struct mode_set_data *data, continue; if (c->connection == DRM_MODE_CONNECTED && c->count_modes) { - connector_id = c->connector_id; + connector = c; mode = &c->modes[0]; break; } } - if (!connector_id) + if (!connector) return false; igt_create_fb(drm_fd, mode->hdisplay, mode->vdisplay, @@ -261,8 +281,8 @@ static bool init_modeset_params_for_type(struct mode_set_data *data, igt_paint_test_pattern(cr, mode->hdisplay, mode->vdisplay); cairo_destroy(cr); - params->crtc_id = data->res->crtcs[0]; - params->connector_id = connector_id; + params->crtc_id = find_crtc_for_connector(data, connector); + params->connector_id = connector->connector_id; params->mode = mode; return true; @@ -1603,7 +1623,6 @@ static void test_one_plane(bool dpms, uint32_t plane_id, disable_all_screens_and_wait(&ms_data); - igt_require(default_mode_params); crtc_id = default_mode_params->crtc_id; switch (plane_type) { @@ -1685,12 +1704,26 @@ static void test_one_plane(bool dpms, uint32_t plane_id, igt_assert(wait_for_suspended()); } +static int get_crtc_idx(struct mode_set_data *data, uint32_t crtc_id) +{ + int i; + + for (i = 0; i < data->res->count_crtcs; i++) + if (data->res->crtcs[i] == crtc_id) + return i; + + igt_assert(false); +} + /* This one also triggered WARNs on our driver at some point in time. */ static void planes_subtest(bool universal, bool dpms) { - int i, rc, planes_tested = 0; + int i, rc, planes_tested = 0, crtc_idx; drmModePlaneResPtr planes; + igt_require(default_mode_params); + crtc_idx = get_crtc_idx(&ms_data, default_mode_params->crtc_id); + if (universal) { rc = drmSetClientCap(drm_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1); @@ -1704,9 +1737,7 @@ static void planes_subtest(bool universal, bool dpms) plane = drmModeGetPlane(drm_fd, planes->planes[i]); igt_assert(plane); - /* We just pick the first CRTC on the list, so we can test for - * 0x1 as the index. */ - if (plane->possible_crtcs & 0x1) { + if (plane->possible_crtcs & (1 << crtc_idx)) { enum plane_type type; type = universal ? get_plane_type(plane->plane_id) : -- 2.6.4