From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 2/4] tests/kms_legacy_colorkey: Test a lot more things
Date: Fri, 31 Jan 2020 22:15:52 +0200 [thread overview]
Message-ID: <20200131201554.12832-2-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20200131201554.12832-1-ville.syrjala@linux.intel.com>
From: Ville Syrjälä <ville.syrjala@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
v3: Rework the expected_ret stuff to handle multiple
sprite planes
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
tests/kms_legacy_colorkey.c | 167 ++++++++++++++++++++++++++++++------
1 file changed, 143 insertions(+), 24 deletions(-)
diff --git a/tests/kms_legacy_colorkey.c b/tests/kms_legacy_colorkey.c
index de9610a75e5c..b0168a917517 100644
--- a/tests/kms_legacy_colorkey.c
+++ b/tests/kms_legacy_colorkey.c
@@ -22,49 +22,168 @@
*/
#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)
{
- drm_fd = drm_open_driver_master(DRIVER_INTEL);
+ uint32_t max_id = 0;
+ igt_plane_t *plane;
+ enum pipe pipe;
- kmstest_set_vt_graphics_mode();
+ 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);
+ }
- igt_display_require(&display, drm_fd);
+ return max_id;
+}
- 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);
+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);
+}
- max_id = max(max_id, plane->drm_plane->plane_id);
- }
+static int expected_ret(struct data *data, uint32_t flags)
+{
+ igt_plane_t *plane = data->plane;
+
+ switch (flags) {
+ case 0:
+ case I915_SET_COLORKEY_NONE:
+ case I915_SET_COLORKEY_SOURCE:
+ if (plane->type != DRM_PLANE_TYPE_OVERLAY)
+ return -ENOENT;
+
+ return 0;
+ case I915_SET_COLORKEY_DESTINATION:
+ if (plane->type != DRM_PLANE_TYPE_OVERLAY)
+ return -ENOENT;
+
+ /* VLV/CHV don't support dst colorkey (yet) */
+ if (IS_VALLEYVIEW(data->devid) ||
+ IS_CHERRYVIEW(data->devid))
+ return -EINVAL;
+
+ /*
+ * Only the first sprite plane gets to
+ * use destination colorkeying.
+ */
+ return plane->index == 1 ? 0 : -EINVAL;
+ default:
+ return -EINVAL;
+ }
+}
+
+static void test_overlays(struct data *data, uint32_t flags)
+{
+ for_each_plane_on_pipe(&data->display, data->pipe, data->plane) {
+ uint32_t plane_id = data->plane->drm_plane->plane_id;
+
+ test_plane(data, plane_id, flags, expected_ret(data, flags));
+ test_plane(data, plane_id, 0, expected_ret(data, 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);
+
+ /* test some undefined flags */
+ test_overlays(data, 1 << 3);
+ test_overlays(data, 1 << 31);
+}
+
+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);
+
+ /* the "none" flag should be ignore by the kernel */
+ test_overlays(data, I915_SET_COLORKEY_NONE);
+}
+
+static void test_src_colorkey(struct data *data)
+{
+ igt_skip_on(data->pipe >= data->display.n_pipes);
+
+ test_overlays(data, I915_SET_COLORKEY_SOURCE);
+}
+
+static void test_dst_colorkey(struct data *data)
+{
+ igt_skip_on(data->pipe >= data->display.n_pipes);
+
+ test_overlays(data, I915_SET_COLORKEY_DESTINATION);
+}
+
+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);
}
- /* try some invalid IDs too */
- test_plane(0, -ENOENT);
- test_plane(max_id + 1, -ENOENT);
+ igt_subtest("invalid-plane-id")
+ test_invalid_plane_id(&data);
+
+ for_each_pipe_static(data.pipe) {
+ 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.24.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2020-01-31 20:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-31 20:15 [igt-dev] [PATCH i-g-t 1/4] lib/igt_kms: Return the first overlay not the last one Ville Syrjala
2020-01-31 20:15 ` Ville Syrjala [this message]
2020-01-31 20:15 ` [igt-dev] [PATCH i-g-t 3/4] tests/kms_legacy_colorkey: Rename to kms_legacy_colorkey_basic Ville Syrjala
2020-01-31 20:15 ` [igt-dev] [PATCH i-g-t 4/4] tests/kms_legacy_colorkey: Add a real colorkey test Ville Syrjala
2020-01-31 20:39 ` [igt-dev] ✗ GitLab.Pipeline: failure for series starting with [i-g-t,1/4] lib/igt_kms: Return the first overlay not the last one Patchwork
2020-01-31 20:52 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2020-02-04 16:20 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200131201554.12832-2-ville.syrjala@linux.intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox