[PATCH i-g-t] tests/kms_stridetest_crc: test different width linear framebuffers

Juha-Pekka Heikkila juhapekka.heikkila at gmail.com
Mon Aug 2 18:59:24 UTC 2021


run test with argb, pixel blend and plane alpha to see if there
are crc failures with different width linear framebuffers to test
stride alignments.

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
---
 tests/kms_stridetest_crc.c | 118 +++++++++++++++++++++++++++++++++++++
 tests/meson.build          |   1 +
 2 files changed, 119 insertions(+)
 create mode 100644 tests/kms_stridetest_crc.c

diff --git a/tests/kms_stridetest_crc.c b/tests/kms_stridetest_crc.c
new file mode 100644
index 000000000..41fa0dceb
--- /dev/null
+++ b/tests/kms_stridetest_crc.c
@@ -0,0 +1,118 @@
+#include "igt.h"
+
+typedef struct {
+	int gfx_fd;
+	igt_display_t display;
+	igt_crc_t ref_crc;
+	igt_pipe_crc_t *pipe_crc;
+	igt_output_t *output;
+} data_t;
+
+#define color 0.75, 0.75, 0.75, 0.75
+#define black 0.0, 0.0, 0.0, 1.0
+
+static void test(data_t *data)
+{
+	igt_plane_t* plane;
+	struct igt_fb softabuffa, hwbuffa = {};
+
+	igt_fixture {
+		data->output = igt_get_single_output_for_pipe(&data->display, PIPE_A);
+		igt_require(data->output);
+		igt_output_set_pipe(data->output, PIPE_A);
+		igt_display_commit_atomic(&data->display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
+
+		plane = igt_output_get_plane_type(data->output, DRM_PLANE_TYPE_PRIMARY);
+
+		if (igt_plane_has_prop(plane, IGT_PLANE_ALPHA))
+			igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0xbeef);
+
+		if (igt_plane_has_prop(plane, IGT_PLANE_PIXEL_BLEND_MODE))
+			igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "Coverage");
+	}
+
+	igt_subtest_f("stride-test-linearfb") {
+		drmModeModeInfo *drm_mode;
+		cairo_t *cr;
+		igt_crc_t softacrc, hardiscrc;
+
+		drm_mode = igt_output_get_mode(data->output);
+
+		igt_create_fb(data->gfx_fd, drm_mode->hdisplay, drm_mode->vdisplay,
+			      DRM_FORMAT_ARGB8888,
+			      DRM_FORMAT_MOD_NONE,
+			      &softabuffa);
+
+		igt_plane_set_position(plane, 0, 0);
+		data->pipe_crc = igt_pipe_crc_new(data->gfx_fd, PIPE_A, INTEL_PIPE_CRC_SOURCE_AUTO);
+		igt_pipe_crc_start(data->pipe_crc);
+
+		for (int m = 0; m < 32; m++) {
+			cr = igt_get_cairo_ctx(data->gfx_fd, &softabuffa);
+			igt_paint_color_alpha(cr, 0, 0, drm_mode->hdisplay, drm_mode->vdisplay, black);
+			igt_paint_color_alpha(cr, 0, 0, drm_mode->hdisplay - m, drm_mode->vdisplay, color);
+			igt_put_cairo_ctx(cr);
+
+			igt_plane_set_fb(plane, &softabuffa);
+			igt_display_commit_atomic(&data->display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
+			igt_remove_fb(data->gfx_fd, &hwbuffa);
+			igt_pipe_crc_get_current(data->gfx_fd, data->pipe_crc, &softacrc);
+
+			igt_create_fb(data->gfx_fd, drm_mode->hdisplay - m, drm_mode->vdisplay,
+					 DRM_FORMAT_ARGB8888,
+					 DRM_FORMAT_MOD_NONE,
+					 &hwbuffa);
+
+			cr = igt_get_cairo_ctx(data->gfx_fd, &hwbuffa);
+			igt_paint_color_alpha(cr, 0, 0, drm_mode->hdisplay - m, drm_mode->vdisplay, black);
+			igt_paint_color_alpha(cr, 0, 0, drm_mode->hdisplay - m, drm_mode->vdisplay, color);
+			igt_put_cairo_ctx(cr);
+
+			igt_plane_set_fb(plane, &hwbuffa);
+			igt_display_commit_atomic(&data->display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
+			igt_pipe_crc_get_current(data->gfx_fd, data->pipe_crc, &hardiscrc);
+
+			igt_assert_crc_equal(&softacrc, &hardiscrc);
+		}
+
+	}
+
+	igt_fixture {
+		igt_pipe_crc_stop(data->pipe_crc);
+		igt_pipe_crc_free(data->pipe_crc);
+
+		igt_plane_set_fb(plane, NULL);
+		igt_display_commit_atomic(&data->display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
+		igt_remove_fb(data->gfx_fd, &softabuffa);
+		igt_remove_fb(data->gfx_fd, &hwbuffa);
+
+		if (igt_plane_has_prop(plane, IGT_PLANE_ALPHA))
+			igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0xffff);
+
+		if (igt_plane_has_prop(plane, IGT_PLANE_PIXEL_BLEND_MODE))
+			igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "Pre-multiplied");
+
+		igt_output_set_pipe(data->output, PIPE_NONE);
+		igt_display_commit_atomic(&data->display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
+	}
+}
+
+
+
+igt_main
+{
+	data_t data = {};
+
+	igt_fixture {
+		data.gfx_fd = drm_open_driver_master(DRIVER_ANY);
+		igt_require_pipe_crc(data.gfx_fd);
+		igt_display_require(&data.display, data.gfx_fd);
+		igt_require_pipe_crc(data.gfx_fd);
+		igt_require(data.display.is_atomic);
+	}
+
+	test(&data);
+
+	igt_fixture
+		igt_display_fini(&data.display);
+}
diff --git a/tests/meson.build b/tests/meson.build
index 1bdfddbb2..54a04d870 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -71,6 +71,7 @@ test_progs = [
 	'kms_selftest',
 	'kms_sequence',
 	'kms_setmode',
+	'kms_stridetest_crc',
 	'kms_sysfs_edid_timing',
 	'kms_tv_load_detect',
 	'kms_universal_plane',
-- 
2.28.0



More information about the Intel-gfx-trybot mailing list