From: Brian Starkey <rodrigosiqueiramelo@gmail.com>
To: Simon Ser <contact@emersion.fr>,
Brian Starkey <Brian.Starkey@arm.com>,
Liviu Dudau <Liviu.Dudau@arm.com>,
Petri Latvala <petri.latvala@intel.com>,
Arkadiusz Hiler <arkadiusz.hiler@intel.com>,
Daniel Vetter <daniel@ffwll.ch>
Cc: igt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
nd <nd@arm.com>
Subject: [igt-dev] [PATCH v7 i-g-t 4/4] kms_writeback: Add writeback-check-output
Date: Mon, 21 Oct 2019 22:00:39 -0300 [thread overview]
Message-ID: <20191022010032.pgqop52v4gz5omlc@smtp.gmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 5155 bytes --]
Add a test which makes commits using the writeback connector, and
checks the output buffer hash to make sure it is/isn't written as
appropriate.
V6: Simon Ser
- Add igt documentation with igt_describe
- Replace int ret by unsigned int fd_id when calling igt_create_fb
- Add a descriptive error message if sync_fence_wait fail
- Replace color_idx variable by i
- Use in_fb instead of out_fb for getting the expected CRC
- Drop unnecessary parentheses
- Replace igt_fb_mod_to_tiling to DRM_FORMAT_MOD_LINEAR
Signed-off-by: Brian Starkey <brian.starkey@arm.com>
[rebased and updated the patch to address feedback]
Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
---
tests/kms_writeback.c | 123 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 123 insertions(+)
diff --git a/tests/kms_writeback.c b/tests/kms_writeback.c
index a373ec4d..068595b9 100644
--- a/tests/kms_writeback.c
+++ b/tests/kms_writeback.c
@@ -30,6 +30,7 @@
#include "igt.h"
#include "igt_core.h"
#include "igt_fb.h"
+#include "sw_sync.h"
IGT_TEST_DESCRIPTION("Exercise writeback feature.");
@@ -196,6 +197,115 @@ static void writeback_test_fb(igt_output_t *output, igt_fb_t *valid_fb, igt_fb_t
igt_assert(ret == -EINVAL);
}
+static void fill_fb(igt_fb_t *fb, double color[3])
+{
+ cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);
+ igt_assert(cr);
+
+ igt_paint_color(cr, 0, 0, fb->width, fb->height,
+ color[0], color[1], color[2]);
+}
+
+static void get_and_wait_out_fence(igt_output_t *output)
+{
+ int ret;
+
+ igt_assert(output->writeback_out_fence_fd >= 0);
+
+ ret = sync_fence_wait(output->writeback_out_fence_fd, 1000);
+ igt_assert_f(ret == 0, "sync_fence_wait failed: %s\n", strerror(-ret));
+ close(output->writeback_out_fence_fd);
+ output->writeback_out_fence_fd = -1;
+}
+
+static void writeback_sequence(igt_output_t *output, igt_plane_t *plane,
+ igt_fb_t *in_fb, igt_fb_t *out_fbs[], int n_commits)
+{
+ int i;
+ double in_fb_colors[2][3] = {
+ { 1.0, 0.0, 0.0 },
+ { 0.0, 1.0, 0.0 },
+ };
+ double clear_color[3] = { 1.0, 1.0, 1.0 };
+ igt_crc_t cleared_crc, out_expected;
+
+ for (i = 0; i < n_commits; i++) {
+ /* Change the input color each time */
+ fill_fb(in_fb, in_fb_colors[i % 2]);
+
+ if (out_fbs[i]) {
+ igt_crc_t out_before;
+
+ /* Get the expected CRC */
+ igt_fb_get_crc(in_fb, &out_expected);
+
+ fill_fb(out_fbs[i], clear_color);
+ if (i == 0)
+ igt_fb_get_crc(out_fbs[i], &cleared_crc);
+ igt_fb_get_crc(out_fbs[i], &out_before);
+ igt_assert_crc_equal(&cleared_crc, &out_before);
+ }
+
+ /* Commit */
+ igt_plane_set_fb(plane, in_fb);
+ igt_output_set_writeback_fb(output, out_fbs[i]);
+
+ igt_display_commit_atomic(output->display,
+ DRM_MODE_ATOMIC_ALLOW_MODESET,
+ NULL);
+ if (out_fbs[i])
+ get_and_wait_out_fence(output);
+
+ /* Make sure the old output buffer is untouched */
+ if (i > 0 && out_fbs[i - 1] && out_fbs[i] != out_fbs[i - 1]) {
+ igt_crc_t out_prev;
+ igt_fb_get_crc(out_fbs[i - 1], &out_prev);
+ igt_assert_crc_equal(&cleared_crc, &out_prev);
+ }
+
+ /* Make sure this output buffer is written */
+ if (out_fbs[i]) {
+ igt_crc_t out_after;
+ igt_fb_get_crc(out_fbs[i], &out_after);
+ igt_assert_crc_equal(&out_expected, &out_after);
+
+ /* And clear it, for the next time */
+ fill_fb(out_fbs[i], clear_color);
+ }
+ }
+}
+
+static void writeback_check_output(igt_output_t *output, igt_plane_t *plane,
+ igt_fb_t *input_fb, igt_fb_t *output_fb)
+{
+ igt_fb_t *out_fbs[2] = { 0 };
+ igt_fb_t second_out_fb;
+ unsigned int fb_id;
+
+ /* One commit, with a writeback. */
+ writeback_sequence(output, plane, input_fb, &output_fb, 1);
+
+ /* Two commits, the second with no writeback */
+ out_fbs[0] = output_fb;
+ writeback_sequence(output, plane, input_fb, out_fbs, 2);
+
+ /* Two commits, both with writeback */
+ out_fbs[1] = output_fb;
+ writeback_sequence(output, plane, input_fb, out_fbs, 2);
+
+ fb_id = igt_create_fb(output_fb->fd,
+ output_fb->width, output_fb->height,
+ DRM_FORMAT_XRGB8888,
+ DRM_FORMAT_MOD_LINEAR, &second_out_fb);
+ igt_require(fb_id > 0);
+
+ /* Two commits, with different writeback buffers */
+ out_fbs[1] = &second_out_fb;
+ writeback_sequence(output, plane, input_fb, out_fbs, 2);
+
+ igt_remove_fb(output_fb->fd, &second_out_fb);
+}
+
igt_main
{
igt_display_t display;
@@ -283,6 +393,19 @@ igt_main
igt_remove_fb(display.drm_fd, &invalid_fb);
}
+ igt_describe("Check writeback output with CRC validation");
+ igt_subtest("writeback-check-output") {
+ igt_fb_t output_fb;
+ fb_id = igt_create_fb(display.drm_fd, mode.hdisplay,
+ mode.vdisplay, DRM_FORMAT_XRGB8888,
+ DRM_FORMAT_MOD_LINEAR, &output_fb);
+ igt_require(fb_id > 0);
+
+ writeback_check_output(output, plane, &input_fb, &output_fb);
+
+ igt_remove_fb(display.drm_fd, &output_fb);
+ }
+
igt_fixture {
igt_remove_fb(display.drm_fd, &input_fb);
igt_display_fini(&display);
--
2.23.0
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
[-- Attachment #2: Type: text/plain, Size: 153 bytes --]
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next reply other threads:[~2019-10-22 1:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-22 1:00 Brian Starkey [this message]
2020-04-15 9:45 ` [Intel-gfx] [PATCH v7 i-g-t 4/4] kms_writeback: Add writeback-check-output Maxime Ripard
2020-04-21 21:07 ` [igt-dev] " Rodrigo Siqueira
2020-04-22 18:03 ` Maxime Ripard
2020-04-23 12:04 ` [igt-dev] " Rodrigo Siqueira
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=20191022010032.pgqop52v4gz5omlc@smtp.gmail.com \
--to=rodrigosiqueiramelo@gmail.com \
--cc=Brian.Starkey@arm.com \
--cc=Liviu.Dudau@arm.com \
--cc=arkadiusz.hiler@intel.com \
--cc=contact@emersion.fr \
--cc=daniel@ffwll.ch \
--cc=igt-dev@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=nd@arm.com \
--cc=petri.latvala@intel.com \
/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