[PATCH i-g-t v5 3/3] tests/kms_writeback: Add subtest for valid clone mode
Jessica Zhang
quic_jesszhan at quicinc.com
Thu Oct 17 01:23:01 UTC 2024
From: Esha Bharadwaj <quic_ebharadw at quicinc.com>
Move the regular writeback dump into its own subtest. Also add a subtest to
dump pairs of cloned non-writeback and writeback encoders if the dump
flag is set or check the writeback output if the dump flag isn't set
Signed-off-by: Esha Bharadwaj <quic_ebharadw at quicinc.com>
Signed-off-by: Jessica Zhang <quic_jesszhan at quicinc.com>
---
tests/kms_writeback.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 86 insertions(+), 4 deletions(-)
diff --git a/tests/kms_writeback.c b/tests/kms_writeback.c
index 1775986fe85b2b951a65355b16d5dae623d6d975..a25988016335104335ba98c3034389d7c16fe843 100644
--- a/tests/kms_writeback.c
+++ b/tests/kms_writeback.c
@@ -47,6 +47,13 @@
#include "sw_sync.h"
/**
+ * SUBTEST: dump-writeback
+ * Description: Dump a non-cloned writeback buffer
+ *
+ * SUBTEST: check-valid-clones
+ * Description: Dump all valid clone pairs of writeback and non-writeback
+ * connectors
+ *
* SUBTEST: writeback-check-output-XRGB2101010
* Description: Check XRGB2101010 writeback output with CRC validation
*
@@ -450,7 +457,7 @@ static void do_single_commit(igt_output_t *output, igt_plane_t *plane, igt_fb_t
}
static void commit_and_dump_fb(igt_display_t *display, igt_output_t *output, igt_plane_t *plane,
- igt_fb_t *input_fb, drmModeModeInfo *mode)
+ igt_fb_t *input_fb, drmModeModeInfo *mode, char *suffix)
{
cairo_surface_t *fb_surface_out;
char filepath_out[PATH_MAX];
@@ -471,7 +478,8 @@ static void commit_and_dump_fb(igt_display_t *display, igt_output_t *output, igt
do_single_commit(output, plane, input_fb, &output_fb);
fb_surface_out = igt_get_cairo_surface(display->drm_fd, &output_fb);
- snprintf(filepath_out, PATH_MAX, "%s/%s.png", path_name, file_name);
+ snprintf(filepath_out, PATH_MAX, "%s/%s-%s.png", path_name, file_name, suffix);
+
status = cairo_surface_write_to_png(fb_surface_out, filepath_out);
igt_assert_eq(status, CAIRO_STATUS_SUCCESS);
cairo_surface_destroy(fb_surface_out);
@@ -555,6 +563,7 @@ igt_main_args("b:c:f:dl", long_options, help_str, opt_handler, NULL)
drmModeModeInfo mode;
unsigned int fb_id;
int ret;
+ char dump_suffix[PATH_MAX];
memset(&display, 0, sizeof(display));
@@ -603,9 +612,82 @@ igt_main_args("b:c:f:dl", long_options, help_str, opt_handler, NULL)
if (data.list_modes)
list_writeback_modes(&display);
- if (data.dump_check)
- commit_and_dump_fb(&display, output, plane, &input_fb, &mode);
}
+
+ /*
+ * When dump_check is high, the following subtests will be run.
+ * These tests will be skipped if list_modes flag is high.
+ */
+ igt_describe("Dump a non-cloned writeback buffer");
+ igt_subtest("dump-writeback") {
+ igt_skip_on(!data.dump_check || data.list_modes);
+ snprintf(dump_suffix, PATH_MAX, "encoder%d", output->id);
+ commit_and_dump_fb(&display, output, plane, &input_fb, &mode, dump_suffix);
+ }
+
+ igt_describe("Dump valid clone pairs of writeback and non-writeback"
+ " connectors; This test will check the output of each pair"
+ " if the dump flag isn't set");
+ igt_subtest("check-valid-clones") {
+ igt_output_t *nonwb_output;
+ enum pipe curr_pipe;
+ drmModeModeInfo *nonwb_mode;
+ igt_fb_t clone_fb, output_fb;
+
+ /*
+ * Drop the dump flag check once calling writeback_sequence() is
+ * supported
+ */
+ igt_skip_on(data.list_modes);
+ igt_skip_on_f(!(data.supported_colors & XRGB8888), "DRM_FORMAT_XRGB8888 is unsupported\n");
+ igt_require(fb_id > 0);
+ for_each_output(&display, nonwb_output) {
+ if ((nonwb_output->config.connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK)
+ || igt_output_clone_invalid(display.drm_fd, output, nonwb_output))
+ continue;
+
+ /* Set up non-writeback cloned output */
+ curr_pipe = output->pending_pipe;
+ nonwb_mode = igt_output_get_mode(nonwb_output);
+
+ igt_output_set_pipe(nonwb_output, curr_pipe);
+ igt_output_override_mode(output, nonwb_mode);
+
+ fb_id = igt_create_fb(display.drm_fd, nonwb_mode->hdisplay,
+ nonwb_mode->vdisplay,
+ DRM_FORMAT_XRGB8888,
+ DRM_FORMAT_MOD_LINEAR,
+ &clone_fb);
+ igt_assert(fb_id >= 0);
+ fb_id = igt_create_fb(display.drm_fd, nonwb_mode->hdisplay,
+ nonwb_mode->vdisplay,
+ DRM_FORMAT_XRGB8888,
+ DRM_FORMAT_MOD_LINEAR,
+ &output_fb);
+ igt_assert(fb_id >= 0);
+
+ if (data.dump_check) {
+ snprintf(dump_suffix, PATH_MAX, "encoder%d-encoder%d",
+ output->id, nonwb_output->id);
+ commit_and_dump_fb(&display, output, plane, &clone_fb,
+ nonwb_mode, dump_suffix);
+ } else {
+ igt_fb_t *out_fbs[1] = { &output_fb };
+ writeback_sequence(output, plane, &clone_fb,
+ out_fbs, 1,
+ DRM_FORMAT_XRGB8888);
+ }
+
+ igt_output_set_pipe(nonwb_output, PIPE_NONE);
+ igt_output_override_mode(output, &mode);
+ igt_display_commit_atomic(output->display,
+ DRM_MODE_ATOMIC_ALLOW_MODESET,
+ NULL);
+ igt_remove_fb(display.drm_fd, &output_fb);
+ igt_remove_fb(display.drm_fd, &clone_fb);
+ }
+ }
+
/*
* When dump_check or list_modes flag is high, then the following subtests will be skipped
* as we do not want to do CRC validation.
--
2.34.1
More information about the igt-dev
mailing list