diff options
author | Paulo Zanoni <paulo.r.zanoni@intel.com> | 2016-02-26 11:27:20 -0300 |
---|---|---|
committer | Paulo Zanoni <paulo.r.zanoni@intel.com> | 2016-03-03 16:57:48 -0300 |
commit | d8bf28f0cbe990d5b1906c686cdaa76c74b1cffd (patch) | |
tree | 44609a602e07119633c51a6e2b01c4f9568b4c50 /lib | |
parent | 9751e602b7e10310b011586fe16d7eea2cfb9026 (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 'lib')
-rw-r--r-- | lib/igt_kms.c | 32 | ||||
-rw-r--r-- | lib/igt_kms.h | 3 |
2 files changed, 35 insertions, 0 deletions
diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 75761e5c..5a61def9 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -277,6 +277,38 @@ int kmstest_get_pipe_from_crtc_id(int fd, int crtc_id) return pfci.pipe; } +/** + * kmstest_find_crtc_for_connector: + * @fd: DRM fd + * @res: libdrm resources pointer + * @connector: libdrm connector pointer + * @crtc_blacklist_idx_mask: a mask of CRTC indexes that we can't return + * + * Returns: the CRTC ID for a CRTC that fits the connector, otherwise it asserts + * false and never returns. The blacklist mask can be used in case you have + * CRTCs that are already in use by other connectors. + */ +uint32_t kmstest_find_crtc_for_connector(int fd, drmModeRes *res, + drmModeConnector *connector, + uint32_t crtc_blacklist_idx_mask) +{ + drmModeEncoder *e; + uint32_t possible_crtcs; + int i, j; + + for (i = 0; i < connector->count_encoders; i++) { + e = drmModeGetEncoder(fd, connector->encoders[i]); + possible_crtcs = e->possible_crtcs & ~crtc_blacklist_idx_mask; + drmModeFreeEncoder(e); + + for (j = 0; possible_crtcs >> j; j++) + if (possible_crtcs & (1 << j)) + return res->crtcs[j]; + } + + igt_assert(false); +} + /* * Returns: the previous mode, or KD_GRAPHICS if no /dev/tty0 was * found and nothing was done. diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 2cb7c1f2..5744ed00 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -151,6 +151,9 @@ bool kmstest_get_property(int drm_fd, uint32_t object_id, uint32_t object_type, drmModePropertyPtr *prop); void kmstest_unset_all_crtcs(int drm_fd, drmModeResPtr resources); int kmstest_get_crtc_idx(drmModeRes *res, uint32_t crtc_id); +uint32_t kmstest_find_crtc_for_connector(int fd, drmModeRes *res, + drmModeConnector *connector, + uint32_t crtc_blacklist_idx_mask); /* * A small modeset API |