From 8a971695bd3db9569c7a10fdc3f7c71dd67ac01d Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 13 Aug 2021 12:28:13 +0200 Subject: [PATCH] test: introduce liftoff_mock_require_primary_plane This allows to mimick i915's requirement of failing all commits which don't have the primary plane enabled. We could expand our test matrix to test with the param *and* without it, but since enabling the param just makes the atomic check more strict there's no real benefit of doing that. Enabling the param can only make tests fail more often, not the other way around. --- test/include/libdrm_mock.h | 6 ++++++ test/libdrm_mock.c | 19 ++++++++++++++++++- test/test_alloc.c | 2 ++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/test/include/libdrm_mock.h b/test/include/libdrm_mock.h index 5e03134..7f3b47c 100644 --- a/test/include/libdrm_mock.h +++ b/test/include/libdrm_mock.h @@ -8,6 +8,12 @@ extern uint32_t liftoff_mock_drm_crtc_id; extern size_t liftoff_mock_commit_count; +/** + * Some drivers require the primary plane to be enabled in order to light up a + * CRTC (e.g. i915). If this variable is set to true, this behavior is mimicked. + */ +extern bool liftoff_mock_require_primary_plane; + struct liftoff_layer; int liftoff_mock_drm_open(void); diff --git a/test/libdrm_mock.c b/test/libdrm_mock.c index c3846ce..34254d2 100644 --- a/test/libdrm_mock.c +++ b/test/libdrm_mock.c @@ -16,6 +16,7 @@ uint32_t liftoff_mock_drm_crtc_id = 0xCC000000; size_t liftoff_mock_commit_count = 0; +bool liftoff_mock_require_primary_plane = false; struct liftoff_mock_plane { uint32_t id; @@ -277,8 +278,9 @@ int drmModeAtomicCommit(int fd, drmModeAtomicReq *req, uint32_t flags, { size_t i, j; struct liftoff_mock_plane *plane; - uint64_t fb_id, crtc_id; + uint64_t type, fb_id, crtc_id; bool has_fb, has_crtc, found; + bool any_plane_enabled, primary_plane_enabled; struct liftoff_layer *layer; assert_drm_fd(fd); @@ -286,12 +288,15 @@ int drmModeAtomicCommit(int fd, drmModeAtomicReq *req, uint32_t flags, liftoff_mock_commit_count++; + any_plane_enabled = false; + primary_plane_enabled = false; for (i = 0; i < MAX_PLANES; i++) { plane = &mock_planes[i]; if (plane->id == 0) { break; } + type = plane->prop_values[PLANE_TYPE]; fb_id = plane->prop_values[PLANE_FB_ID]; crtc_id = plane->prop_values[PLANE_CRTC_ID]; mock_atomic_req_get_property(req, plane->id, PLANE_FB_ID, @@ -335,9 +340,21 @@ int drmModeAtomicCommit(int fd, drmModeAtomicReq *req, uint32_t flags, plane->id, (void *)layer); return -EINVAL; } + + any_plane_enabled = true; + if (type == DRM_PLANE_TYPE_PRIMARY) { + primary_plane_enabled = true; + } } } + if (liftoff_mock_require_primary_plane && any_plane_enabled && + !primary_plane_enabled) { + fprintf(stderr, "libdrm_mock: cannot light up CRTC without " + "enabling the primary plane\n"); + return -EINVAL; + } + if (!(flags & DRM_MODE_ATOMIC_TEST_ONLY)) { apply_atomic_req(req); } diff --git a/test/test_alloc.c b/test/test_alloc.c index 7120843..02d6362 100644 --- a/test/test_alloc.c +++ b/test/test_alloc.c @@ -636,6 +636,8 @@ static void run_test(struct test_layer *test_layers) int ret; uint32_t plane_id; + liftoff_mock_require_primary_plane = true; + for (i = 0; i < test_setup_len; i++) { mock_planes[i] = liftoff_mock_drm_create_plane(test_setup[i].type); }