summaryrefslogtreecommitdiff
path: root/tests/kms_lease.c
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2019-02-28 15:19:14 +0100
committerDaniel Vetter <daniel.vetter@ffwll.ch>2019-03-28 10:07:52 +0100
commitf31193daf3104ac2d04ac9c1701310135ff43a7f (patch)
tree1d037b8b50d42afeb43d8ae6a77379d11556f8e2 /tests/kms_lease.c
parent2eb768b851dee3ead2563829c8f798ed89258d19 (diff)
tests/kms_lease: test implicit primary plane usage in setcrtc ioctl
Again we need to make sure that a lease can't use planes it's not allowed to through legacy ioctls. SetCrtc is a bit more tricky, since we should still allow to shut down a CRTC, e.g. when we're allowed to use other planes on that CRTC. Current kernels fail this. Cc: Keith Packard <keithp@keithp.com> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Diffstat (limited to 'tests/kms_lease.c')
-rw-r--r--tests/kms_lease.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/kms_lease.c b/tests/kms_lease.c
index 74228589..e749e10c 100644
--- a/tests/kms_lease.c
+++ b/tests/kms_lease.c
@@ -373,6 +373,65 @@ static void page_flip_implicit_plane(data_t *data)
connector_id_to_output(&data->master.display, data->connector_id));
}
+static void setcrtc_implicit_plane(data_t *data)
+{
+ uint32_t object_ids[3];
+ struct local_drm_mode_create_lease mcl;
+ drmModePlaneRes *plane_resources;
+ uint32_t wrong_plane_id = 0;
+ igt_output_t *output =
+ connector_id_to_output(&data->master.display,
+ data->connector_id);
+ drmModeModeInfo *mode = igt_output_get_mode(output);
+ int i;
+
+ /* find a plane which isn't the primary one for us */
+ plane_resources = drmModeGetPlaneResources(data->master.fd);
+ for (i = 0; i < plane_resources->count_planes; i++) {
+ if (plane_resources->planes[i] != data->plane_id) {
+ wrong_plane_id = plane_resources->planes[i];
+ break;
+ }
+ }
+ drmModeFreePlaneResources(plane_resources);
+ igt_require(wrong_plane_id);
+
+ mcl.object_ids = (uint64_t) (uintptr_t) &object_ids[0];
+ mcl.object_count = 0;
+ mcl.flags = 0;
+
+ object_ids[mcl.object_count++] = data->connector_id;
+ object_ids[mcl.object_count++] = data->crtc_id;
+
+ drmSetClientCap(data->master.fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 0);
+ do_or_die(create_lease(data->master.fd, &mcl));
+ drmSetClientCap(data->master.fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
+
+ /* Set a mode on the leased output */
+ igt_assert_eq(0, prepare_crtc(&data->master, data->connector_id, data->crtc_id));
+
+ /* sanity check */
+ do_or_die(drmModeSetCrtc(data->master.fd, data->crtc_id, -1,
+ 0, 0, object_ids, 1, mode));
+ do_or_die(drmModeSetCrtc(mcl.fd, data->crtc_id, -1,
+ 0, 0, object_ids, 1, mode));
+ close(mcl.fd);
+
+ object_ids[mcl.object_count++] = wrong_plane_id;
+ do_or_die(create_lease(data->master.fd, &mcl));
+
+ igt_assert_eq(drmModeSetCrtc(mcl.fd, data->crtc_id, -1,
+ 0, 0, object_ids, 1, mode),
+ -EACCES);
+ /* make sure we are allowed to turn the CRTC off */
+ do_or_die(drmModeSetCrtc(mcl.fd, data->crtc_id,
+ 0, 0, 0, NULL, 0, NULL));
+ close(mcl.fd);
+
+ cleanup_crtc(&data->master,
+ connector_id_to_output(&data->master.display, data->connector_id));
+}
+
/* Test listing lessees */
static void lessee_list(data_t *data)
{
@@ -1087,6 +1146,7 @@ igt_main
{ "lease_invalid_crtc", lease_invalid_crtc },
{ "lease_invalid_plane", lease_invalid_plane },
{ "page_flip_implicit_plane", page_flip_implicit_plane },
+ { "setcrtc_implicit_plane", setcrtc_implicit_plane },
{ }
}, *f;