[RFC PATCH v5 21/32] kms/colorop: Do proper setup and cleanup
Harry Wentland
harry.wentland at amd.com
Mon Feb 26 21:14:05 UTC 2024
We need to ensure framebuffers get removed and crcts detached
when tests fail, otherwise consecutive test runs might fail.
Signed-off-by: Harry Wentland <harry.wentland at amd.com>
---
tests/kms_colorop.c | 139 +++++++++++++++++++++++++-------------------
1 file changed, 78 insertions(+), 61 deletions(-)
diff --git a/tests/kms_colorop.c b/tests/kms_colorop.c
index 5b0b32819baf..f0f4d83d8c8c 100644
--- a/tests/kms_colorop.c
+++ b/tests/kms_colorop.c
@@ -390,52 +390,20 @@ static void apply_transforms(kms_colorop_t *colorops[], igt_fb_t *sw_transform_f
}
static void colorop_plane_test(igt_display_t *display,
+ igt_output_t *output,
+ igt_plane_t *plane,
+ igt_fb_t *input_fb,
+ igt_fb_t *output_fb,
__u32 fourcc_in,
__u32 fourcc_out,
kms_colorop_t *colorops[])
{
igt_colorop_t *color_pipeline = NULL;
- igt_output_t *output;
- igt_plane_t *plane;
- igt_fb_t input_fb;
igt_fb_t sw_transform_fb;
- igt_fb_t output_fb;
- drmModeModeInfo mode;
- unsigned int fb_id;
igt_crc_t input_crc, output_crc;
+ int res;
- output = kms_writeback_get_output(display, fourcc_in, fourcc_out);
- igt_require(output);
-
- if (output->use_override_mode)
- memcpy(&mode, &output->override_mode, sizeof(mode));
- else
- memcpy(&mode, &output->config.default_mode, sizeof(mode));
-
- /* create input fb */
- plane = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
- igt_assert(plane);
-
- fb_id = igt_create_color_pattern_fb(display->drm_fd,
- mode.hdisplay, mode.vdisplay,
- fourcc_in, DRM_FORMAT_MOD_LINEAR,
- 0.2, 0.2, 0.2, &input_fb);
- igt_assert(fb_id >= 0);
- igt_plane_set_fb(plane, &input_fb);
-#if DUMP_FBS
- igt_dump_fb(display, &input_fb, ".", "input");
-#endif
-
- /* create output fb */
- fb_id = igt_create_fb(display->drm_fd, mode.hdisplay, mode.vdisplay,
- fourcc_in,
- igt_fb_mod_to_tiling(0),
- &output_fb);
- igt_require(fb_id > 0);
-
- igt_fb_get_fnv1a_crc(&input_fb, &input_crc);
-
- igt_require(igt_plane_has_prop(plane, IGT_PLANE_COLOR_PIPELINE));
+ igt_fb_get_fnv1a_crc(input_fb, &input_crc);
/* reset color pipeline*/
@@ -443,8 +411,8 @@ static void colorop_plane_test(igt_display_t *display,
set_color_pipeline_bypass(plane);
/* Commit */
- igt_plane_set_fb(plane, &input_fb);
- igt_output_set_writeback_fb(output, &output_fb);
+ igt_plane_set_fb(plane, input_fb);
+ igt_output_set_writeback_fb(output, output_fb);
igt_display_commit_atomic(output->display,
DRM_MODE_ATOMIC_ALLOW_MODESET,
@@ -452,14 +420,15 @@ static void colorop_plane_test(igt_display_t *display,
get_and_wait_out_fence(output);
/* Compare input and output buffers. They should be equal here. */
- igt_fb_get_fnv1a_crc(&output_fb, &output_crc);
+ igt_fb_get_fnv1a_crc(output_fb, &output_crc);
igt_assert_crc_equal(&input_crc, &output_crc);
/* create sw transformed buffer */
+ res = igt_copy_fb(display->drm_fd, input_fb, &sw_transform_fb);
+ igt_assert_lte(0, res);
- igt_copy_fb(display->drm_fd, &input_fb, &sw_transform_fb);
- igt_assert(igt_cmp_fb_pixels(&input_fb, &sw_transform_fb, 0, 0));
+ igt_assert(igt_cmp_fb_pixels(input_fb, &sw_transform_fb, 0, 0));
apply_transforms(colorops, &sw_transform_fb);
#if DUMP_FBS
@@ -480,7 +449,7 @@ static void colorop_plane_test(igt_display_t *display,
set_color_pipeline(display, plane, colorops, color_pipeline);
}
- igt_output_set_writeback_fb(output, &output_fb);
+ igt_output_set_writeback_fb(output, output_fb);
/* commit COLOR_PIPELINE */
igt_display_commit_atomic(display,
@@ -488,28 +457,24 @@ static void colorop_plane_test(igt_display_t *display,
NULL);
get_and_wait_out_fence(output);
#if DUMP_FBS
- igt_dump_fb(display, &output_fb, ".", "output");
+ igt_dump_fb(display, output_fb, ".", "output");
#endif
/* compare sw transformed and KMS transformed FBs */
- igt_assert(compare_with_bracket(&sw_transform_fb, &output_fb));
+ igt_assert(compare_with_bracket(&sw_transform_fb, output_fb));
/* reset color pipeline*/
set_color_pipeline_bypass(plane);
/* Commit */
- igt_plane_set_fb(plane, &input_fb);
- igt_output_set_writeback_fb(output, &output_fb);
+ igt_plane_set_fb(plane, input_fb);
+ igt_output_set_writeback_fb(output, output_fb);
igt_display_commit_atomic(output->display,
DRM_MODE_ATOMIC_ALLOW_MODESET,
NULL);
get_and_wait_out_fence(output);
- /* cleanup */
- detach_crtc(display, output);
- igt_remove_fb(display->drm_fd, &input_fb);
- igt_remove_fb(display->drm_fd, &output_fb);
}
igt_main
@@ -553,17 +518,69 @@ igt_main
igt_display_require(&display, display.drm_fd);
igt_require(display.is_atomic);
-
}
for (j = 0; j < sizeof(formats) / sizeof (formats[0]); j++) {
- for (i = 0; i < sizeof(tests) / sizeof (tests[0]); i++) {
- igt_describe("Bla bla bla");
- igt_subtest_f("plane-%s-%s", formats[j].name, tests[i].name)
- colorop_plane_test(&display,
- formats[j].fourcc_in,
- formats[j].fourcc_out,
- tests[i].colorops);
+ igt_output_t *output;
+ igt_plane_t *plane;
+ igt_fb_t input_fb, output_fb;
+ unsigned int fb_id;
+ drmModeModeInfo mode;
+
+ igt_subtest_group {
+ igt_fixture {
+ output = kms_writeback_get_output(&display,
+ formats[j].fourcc_in,
+ formats[j].fourcc_out);
+ igt_require(output);
+
+ if (output->use_override_mode)
+ memcpy(&mode, &output->override_mode, sizeof(mode));
+ else
+ memcpy(&mode, &output->config.default_mode, sizeof(mode));
+
+ /* create input fb */
+ plane = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+ igt_assert(plane);
+ igt_require(igt_plane_has_prop(plane, IGT_PLANE_COLOR_PIPELINE));
+
+ fb_id = igt_create_color_pattern_fb(display.drm_fd,
+ mode.hdisplay, mode.vdisplay,
+ formats[j].fourcc_in, DRM_FORMAT_MOD_LINEAR,
+ 0.2, 0.2, 0.2, &input_fb);
+ igt_assert(fb_id >= 0);
+ igt_plane_set_fb(plane, &input_fb);
+#if DUMP_FBS
+ igt_dump_fb(&display, &input_fb, ".", "input");
+#endif
+
+ /* create output fb */
+ fb_id = igt_create_fb(display.drm_fd, mode.hdisplay, mode.vdisplay,
+ formats[j].fourcc_in,
+ igt_fb_mod_to_tiling(0),
+ &output_fb);
+ igt_require(fb_id > 0);
+ }
+
+ for (i = 0; i < sizeof(tests) / sizeof (tests[0]); i++) {
+ igt_describe("Bla bla bla");
+ igt_subtest_f("plane-%s-%s", formats[j].name, tests[i].name)
+ colorop_plane_test(&display,
+ output,
+ plane,
+ &input_fb,
+ &output_fb,
+ formats[j].fourcc_in,
+ formats[j].fourcc_out,
+ tests[i].colorops);
+ }
+
+ igt_fixture {
+ detach_crtc(&display, output);
+ igt_remove_fb(display.drm_fd, &input_fb);
+ igt_remove_fb(display.drm_fd, &output_fb);
+
+ }
}
}
igt_describe("Tests getting and setting COLOR_PIPELINE property on plane");
@@ -576,8 +593,8 @@ igt_main
}
#endif
igt_fixture {
-
igt_display_fini(&display);
+ drm_close_driver(display.drm_fd);
}
}
--
2.44.0
More information about the igt-dev
mailing list