[PATCH i-g-t 1/4] tests/kms_legacy_colorkey: Test a lot more things

Ville Syrjala ville.syrjala at linux.intel.com
Mon Nov 11 18:04:38 UTC 2019


From: Ville Syrjälä <ville.syrjala at linux.intel.com>

Try to test that we can actually use the colorkey ioctl to
ask for different colorkeying modes, and make sure the kernel
rejects invalid/unsupported flags, etc.

What we're still missing is looking at the crc to make sure
the color keying actually works. But let's leave that for
the future.

v2: Refactor each subtest into its own function

Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
 tests/kms_legacy_colorkey.c | 167 ++++++++++++++++++++++++++++++------
 1 file changed, 139 insertions(+), 28 deletions(-)

diff --git a/tests/kms_legacy_colorkey.c b/tests/kms_legacy_colorkey.c
index 961aa0a3192d..219ab77db5b4 100644
--- a/tests/kms_legacy_colorkey.c
+++ b/tests/kms_legacy_colorkey.c
@@ -22,51 +22,162 @@
  */
 
 #include "igt.h"
+#include "i915_drm.h"
 #include <errno.h>
 
 
-IGT_TEST_DESCRIPTION("Check that the legacy set colorkey ioctl only works on sprite planes.");
+IGT_TEST_DESCRIPTION("Check that the legacy set colorkey ioctl works.");
 
-static int drm_fd;
-static igt_display_t display;
-static int p;
-static igt_plane_t *plane;
-static uint32_t max_id;
+struct data {
+	igt_display_t display;
+	igt_plane_t *plane;
+	int drm_fd;
+	enum pipe pipe;
+	uint32_t devid;
+};
 
-static void test_plane(uint32_t plane_id, int expected_ret)
+static void test_plane(struct data *data,
+		       uint32_t plane_id,
+		       uint32_t flags,
+		       int expected_ret)
 {
 	struct drm_intel_sprite_colorkey ckey = {
 		.plane_id = plane_id,
+		.flags = flags,
 	};
 
-	igt_assert(drmCommandWrite(drm_fd, DRM_I915_SET_SPRITE_COLORKEY, &ckey,
+	igt_assert(drmCommandWrite(data->drm_fd,
+				   DRM_I915_SET_SPRITE_COLORKEY, &ckey,
 				   sizeof(ckey)) == expected_ret);
 }
 
-igt_simple_main
+static uint32_t max_plane_id(struct data *data)
 {
-	igt_skip_on_simulation();
-
-	drm_fd = drm_open_driver_master(DRIVER_INTEL);
-
-	kmstest_set_vt_graphics_mode();
-
-	igt_display_require(&display, drm_fd);
-
-	for_each_pipe(&display, p) {
-		for_each_plane_on_pipe(&display, p, plane) {
-			bool is_valid = (plane->type == DRM_PLANE_TYPE_PRIMARY ||
-			                 plane->type == DRM_PLANE_TYPE_CURSOR);
-			test_plane(plane->drm_plane->plane_id,
-				   is_valid ? -ENOENT : 0);
+	uint32_t max_id = 0;
+	igt_plane_t *plane;
+	enum pipe pipe;
 
+	for_each_pipe(&data->display, pipe) {
+		for_each_plane_on_pipe(&data->display, pipe, plane)
 			max_id = max(max_id, plane->drm_plane->plane_id);
-		}
 	}
 
-	/* try some invalid IDs too */
-	test_plane(0, -ENOENT);
-	test_plane(max_id + 1, -ENOENT);
+	return max_id;
+}
+
+static void test_invalid_plane_id(struct data *data)
+{
+	/* try some invalid plane IDs */
+	test_plane(data, 0, 0, -ENOENT);
+	test_plane(data, max_plane_id(data) + 1, 0, -ENOENT);
+}
+
+static void test_unsupported_plane(struct data *data)
+{
+	igt_skip_on(data->pipe >= data->display.n_pipes);
+
+	for_each_plane_on_pipe(&data->display, data->pipe, data->plane) {
+		uint32_t plane_id = data->plane->drm_plane->plane_id;
+
+		if (data->plane->type == DRM_PLANE_TYPE_OVERLAY)
+			continue;
+
+		/* should be rejected for primary/cursor planes */
+		test_plane(data, plane_id, 0, -ENOENT);
+	}
+}
+
+static void test_overlays(struct data *data, uint32_t flags, int expected_ret)
+{
+	for_each_plane_on_pipe(&data->display, data->pipe, data->plane) {
+		uint32_t plane_id = data->plane->drm_plane->plane_id;
+
+		if (data->plane->type != DRM_PLANE_TYPE_OVERLAY)
+			continue;
+
+		test_plane(data, plane_id, flags, expected_ret);
+		test_plane(data, plane_id, 0, 0);
+	}
+}
+
+static void test_invalid_flags(struct data *data)
+{
+	igt_skip_on(data->pipe >= data->display.n_pipes);
+
+	/* dst + src keying is not supported */
+	test_overlays(data, I915_SET_COLORKEY_DESTINATION |
+		      I915_SET_COLORKEY_SOURCE, -EINVAL);
+
+	/* test some undefined flags */
+	test_overlays(data, 1 << 3, -EINVAL);
+	test_overlays(data, 1 << 31, -EINVAL);
+}
+
+static void test_no_colorkey(struct data *data)
+{
+	igt_skip_on(data->pipe >= data->display.n_pipes);
+
+	/* no flags should work */
+	test_overlays(data, 0, 0);
+
+	/* the "none" flag should be ignore by the kernel */
+	test_overlays(data, I915_SET_COLORKEY_NONE, 0);
+}
+
+static void test_src_colorkey(struct data *data)
+{
+	igt_skip_on(data->pipe >= data->display.n_pipes);
+
+	test_overlays(data, I915_SET_COLORKEY_SOURCE, 0);
+}
+
+static void test_dst_colorkey(struct data *data)
+{
+	/* VLV/CHV don't support dst colorkey (yet) */
+	bool is_valid = !IS_VALLEYVIEW(data->devid) &&
+		!IS_CHERRYVIEW(data->devid);
+
+	igt_skip_on(data->pipe >= data->display.n_pipes);
+
+	test_overlays(data, I915_SET_COLORKEY_DESTINATION, is_valid ? 0 : -EINVAL);
+}
+
+static struct data data;
+
+igt_main
+{
+	igt_skip_on_simulation();
+
+	igt_fixture {
+		data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
+
+		data.devid = intel_get_drm_devid(data.drm_fd);
+
+		kmstest_set_vt_graphics_mode();
+
+		igt_display_require(&data.display, data.drm_fd);
+	}
+
+	igt_subtest("invalid-plane-id")
+		test_invalid_plane_id(&data);
+
+	for_each_pipe_static(data.pipe) {
+		igt_subtest_f("pipe-%s-unsupported-plane", kmstest_pipe_name(data.pipe))
+			test_unsupported_plane(&data);
+
+		igt_subtest_f("pipe-%s-invalid-flags", kmstest_pipe_name(data.pipe))
+			test_invalid_flags(&data);
+
+		igt_subtest_f("pipe-%s-no-colorkey", kmstest_pipe_name(data.pipe))
+			test_no_colorkey(&data);
+
+		igt_subtest_f("pipe-%s-src-colorkey", kmstest_pipe_name(data.pipe))
+			test_src_colorkey(&data);
+
+		igt_subtest_f("pipe-%s-dst-colorkey", kmstest_pipe_name(data.pipe))
+			test_dst_colorkey(&data);
+	}
 
-	igt_display_fini(&display);
+	igt_fixture
+		igt_display_fini(&data.display);
 }
-- 
2.23.0



More information about the Intel-gfx-trybot mailing list