summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaulo Zanoni <paulo.r.zanoni@intel.com>2016-02-26 11:27:20 -0300
committerPaulo Zanoni <paulo.r.zanoni@intel.com>2016-03-03 16:57:48 -0300
commitd8bf28f0cbe990d5b1906c686cdaa76c74b1cffd (patch)
tree44609a602e07119633c51a6e2b01c4f9568b4c50 /tests
parent9751e602b7e10310b011586fe16d7eea2cfb9026 (diff)
tests: fix CRTC assignment for a few tests
All the tests I wrote always assumed that every connector supported CRTC 0. This is not the case for BSW and possibly others, so fix the tests before the CI reports more failures. Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/kms_draw_crc.c13
-rw-r--r--tests/kms_fbcon_fbt.c12
-rw-r--r--tests/kms_frontbuffer_tracking.c23
-rw-r--r--tests/pm_lpsp.c35
-rw-r--r--tests/pm_rpm.c24
5 files changed, 49 insertions, 58 deletions
diff --git a/tests/kms_draw_crc.c b/tests/kms_draw_crc.c
index 3f801749..9539fe45 100644
--- a/tests/kms_draw_crc.c
+++ b/tests/kms_draw_crc.c
@@ -58,25 +58,26 @@ struct modeset_params ms;
static void find_modeset_params(void)
{
int i;
- uint32_t connector_id = 0, crtc_id;
+ uint32_t crtc_id;
+ drmModeConnectorPtr connector = NULL;
drmModeModeInfoPtr mode = NULL;
for (i = 0; i < drm_res->count_connectors; i++) {
drmModeConnectorPtr c = drm_connectors[i];
if (c->count_modes) {
- connector_id = c->connector_id;
+ connector = c;
mode = &c->modes[0];
break;
}
}
- igt_require(connector_id);
+ igt_require(connector);
- crtc_id = drm_res->crtcs[0];
- igt_assert(crtc_id);
+ crtc_id = kmstest_find_crtc_for_connector(drm_fd, drm_res, connector,
+ 0);
igt_assert(mode);
- ms.connector_id = connector_id;
+ ms.connector_id = connector->connector_id;
ms.crtc_id = crtc_id;
ms.mode = mode;
diff --git a/tests/kms_fbcon_fbt.c b/tests/kms_fbcon_fbt.c
index 3c93378e..586cdf57 100644
--- a/tests/kms_fbcon_fbt.c
+++ b/tests/kms_fbcon_fbt.c
@@ -114,7 +114,7 @@ static void set_mode_for_one_screen(struct drm_info *drm, struct igt_fb *fb,
connector_possible_fn connector_possible)
{
int i, rc;
- uint32_t connector_id = 0, crtc_id;
+ uint32_t crtc_id;
drmModeModeInfoPtr mode;
uint32_t buffer_id;
drmModeConnectorPtr c = NULL;
@@ -124,14 +124,14 @@ static void set_mode_for_one_screen(struct drm_info *drm, struct igt_fb *fb,
if (c->connection == DRM_MODE_CONNECTED && c->count_modes &&
connector_possible(c)) {
- connector_id = c->connector_id;
mode = &c->modes[0];
break;
}
}
- igt_require_f(connector_id, "No connector available\n");
+ igt_require_f(i < drm->res->count_connectors,
+ "No connector available\n");
- crtc_id = drm->res->crtcs[0];
+ crtc_id = kmstest_find_crtc_for_connector(drm->fd, drm->res, c, 0);
buffer_id = igt_create_fb(drm->fd, mode->hdisplay, mode->vdisplay,
DRM_FORMAT_XRGB8888,
@@ -142,8 +142,8 @@ static void set_mode_for_one_screen(struct drm_info *drm, struct igt_fb *fb,
mode->hdisplay, mode->vdisplay,
kmstest_connector_type_str(c->connector_type));
- rc = drmModeSetCrtc(drm->fd, crtc_id, buffer_id, 0, 0, &connector_id, 1,
- mode);
+ rc = drmModeSetCrtc(drm->fd, crtc_id, buffer_id, 0, 0,
+ &c->connector_id, 1, mode);
igt_assert_eq(rc, 0);
}
diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c
index 321026a4..bb1800bf 100644
--- a/tests/kms_frontbuffer_tracking.c
+++ b/tests/kms_frontbuffer_tracking.c
@@ -374,10 +374,11 @@ static void print_mode_info(const char *screen, struct modeset_params *params)
{
drmModeConnectorPtr c = get_connector(params->connector_id);
- igt_info("%s screen: %s %s\n",
+ igt_info("%s screen: %s %s, crtc %d\n",
screen,
kmstest_connector_type_str(c->connector_type),
- params->mode->name);
+ params->mode->name,
+ params->crtc_id);
}
static void init_mode_params(struct modeset_params *params, uint32_t crtc_id,
@@ -484,6 +485,7 @@ static bool init_modeset_cached_params(void)
{
drmModeConnectorPtr prim_connector = NULL, scnd_connector = NULL;
drmModeModeInfoPtr prim_mode = NULL, scnd_mode = NULL;
+ uint32_t prim_crtc_id, scnd_crtc_id;
/*
* We have this problem where PSR is only present on eDP monitors and
@@ -507,7 +509,9 @@ static bool init_modeset_cached_params(void)
find_connector(false, false, prim_connector->connector_id,
&scnd_connector, &scnd_mode);
- init_mode_params(&prim_mode_params, drm.res->crtcs[0],
+ prim_crtc_id = kmstest_find_crtc_for_connector(drm.fd, drm.res,
+ prim_connector, 0);
+ init_mode_params(&prim_mode_params, prim_crtc_id,
prim_connector, prim_mode);
print_mode_info("Primary", &prim_mode_params);
@@ -517,7 +521,10 @@ static bool init_modeset_cached_params(void)
}
igt_assert(drm.res->count_crtcs >= 2);
- init_mode_params(&scnd_mode_params, drm.res->crtcs[1],
+ scnd_crtc_id = kmstest_find_crtc_for_connector(drm.fd, drm.res,
+ scnd_connector,
+ 1 << kmstest_get_crtc_idx(drm.res, prim_crtc_id));
+ init_mode_params(&scnd_mode_params, scnd_crtc_id,
scnd_connector, scnd_mode);
print_mode_info("Secondary", &scnd_mode_params);
@@ -2575,10 +2582,10 @@ static bool prim_plane_disabled(void)
{
int i, rc;
bool disabled, found = false;
+ int crtc_idx = kmstest_get_crtc_idx(drm.res, prim_mode_params.crtc_id);
for (i = 0; i < drm.plane_res->count_planes; i++) {
- /* We just pick the first CRTC for the primary plane. */
- if ((drm.planes[i]->possible_crtcs & 0x1) &&
+ if ((drm.planes[i]->possible_crtcs & (1 << crtc_idx)) &&
drm.plane_types[i] == DRM_PLANE_TYPE_PRIMARY) {
found = true;
disabled = (drm.planes[i]->crtc_id == 0);
@@ -2686,6 +2693,8 @@ static void scaledprimary_subtest(const struct test_mode *t)
struct modeset_params *params = pick_params(t);
int i, rc;
uint32_t plane_id;
+ int prim_crtc_idx = kmstest_get_crtc_idx(drm.res,
+ prim_mode_params.crtc_id);
igt_require_f(intel_gen(intel_get_drm_devid(drm.fd)) >= 9,
"Can't test primary plane scaling before gen 9\n");
@@ -2715,7 +2724,7 @@ static void scaledprimary_subtest(const struct test_mode *t)
pick_color(&new_fb, COLOR_MAGENTA));
for (i = 0; i < drm.plane_res->count_planes; i++)
- if ((drm.planes[i]->possible_crtcs & 1) &&
+ if ((drm.planes[i]->possible_crtcs & (1 << prim_crtc_idx)) &&
drm.plane_types[i] == DRM_PLANE_TYPE_PRIMARY)
plane_id = drm.planes[i]->plane_id;
diff --git a/tests/pm_lpsp.c b/tests/pm_lpsp.c
index 4cedefff..bfe58288 100644
--- a/tests/pm_lpsp.c
+++ b/tests/pm_lpsp.c
@@ -65,7 +65,8 @@ static void edp_subtest(int drm_fd, drmModeResPtr drm_res,
bool use_panel_fitter)
{
int i, rc;
- uint32_t connector_id = 0, crtc_id = 0, buffer_id = 0;
+ uint32_t crtc_id = 0, buffer_id = 0;
+ drmModeConnectorPtr connector = NULL;
drmModeModeInfoPtr mode = NULL;
drmModeModeInfo std_1024_mode = {
.clock = 65000,
@@ -96,12 +97,12 @@ static void edp_subtest(int drm_fd, drmModeResPtr drm_res,
continue;
if (!use_panel_fitter && c->count_modes) {
- connector_id = c->connector_id;
+ connector = c;
mode = &c->modes[0];
break;
}
if (use_panel_fitter) {
- connector_id = c->connector_id;
+ connector = c;
/* This is one of the modes Xorg creates for panels, so
* it should work just fine. Notice that Gens that
@@ -116,18 +117,18 @@ static void edp_subtest(int drm_fd, drmModeResPtr drm_res,
break;
}
}
- igt_require(connector_id);
+ igt_require(connector);
- crtc_id = drm_res->crtcs[0];
+ crtc_id = kmstest_find_crtc_for_connector(drm_fd, drm_res, connector,
+ 0);
buffer_id = create_fb(drm_fd, mode->hdisplay, mode->vdisplay);
- igt_assert(crtc_id);
igt_assert(buffer_id);
- igt_assert(connector_id);
+ igt_assert(connector);
igt_assert(mode);
- rc = drmModeSetCrtc(drm_fd, crtc_id, buffer_id, 0, 0, &connector_id, 1,
- mode);
+ rc = drmModeSetCrtc(drm_fd, crtc_id, buffer_id, 0, 0,
+ &connector->connector_id, 1, mode);
igt_assert_eq(rc, 0);
if (use_panel_fitter) {
@@ -144,7 +145,8 @@ static void non_edp_subtest(int drm_fd, drmModeResPtr drm_res,
drmModeConnectorPtr *drm_connectors)
{
int i, rc;
- uint32_t connector_id = 0, crtc_id = 0, buffer_id = 0;
+ uint32_t crtc_id = 0, buffer_id = 0;
+ drmModeConnectorPtr connector = NULL;
drmModeModeInfoPtr mode = NULL;
kmstest_unset_all_crtcs(drm_fd, drm_res);
@@ -158,23 +160,22 @@ static void non_edp_subtest(int drm_fd, drmModeResPtr drm_res,
continue;
if (c->count_modes) {
- connector_id = c->connector_id;
+ connector = c;
mode = &c->modes[0];
break;
}
}
- igt_require(connector_id);
+ igt_require(connector);
- crtc_id = drm_res->crtcs[0];
+ crtc_id = kmstest_find_crtc_for_connector(drm_fd, drm_res, connector,
+ 0);
buffer_id = create_fb(drm_fd, mode->hdisplay, mode->vdisplay);
- igt_assert(crtc_id);
igt_assert(buffer_id);
- igt_assert(connector_id);
igt_assert(mode);
- rc = drmModeSetCrtc(drm_fd, crtc_id, buffer_id, 0, 0, &connector_id, 1,
- mode);
+ rc = drmModeSetCrtc(drm_fd, crtc_id, buffer_id, 0, 0,
+ &connector->connector_id, 1, mode);
igt_assert_eq(rc, 0);
igt_assert(!lpsp_is_enabled(drm_fd));
diff --git a/tests/pm_rpm.c b/tests/pm_rpm.c
index 5f947e9e..e84a9d3b 100644
--- a/tests/pm_rpm.c
+++ b/tests/pm_rpm.c
@@ -226,27 +226,6 @@ 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(drmModeResPtr res,
- 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 = res->crtcs[j];
-
- drmModeFreeEncoder(e);
- }
-
- igt_assert(crtc_id);
- return crtc_id;
-}
-
static bool init_modeset_params_for_type(struct mode_set_data *data,
struct modeset_params *params,
enum screen_type type)
@@ -280,7 +259,8 @@ static bool init_modeset_params_for_type(struct mode_set_data *data,
DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
&params->fb);
- params->crtc_id = find_crtc_for_connector(data->res, connector);
+ params->crtc_id = kmstest_find_crtc_for_connector(drm_fd, data->res,
+ connector, 0);
params->connector_id = connector->connector_id;
params->mode = mode;