[igt-dev] [v3 7/9] tests/kms_plane_scaling: Upscaling and downscaling scenario

Swati Sharma swati2.sharma at intel.com
Tue Feb 8 05:50:37 UTC 2022


Upscaling on first overlay plane and downscaling on second
overlay plane.

v2: -add check for min 2 scalers
    -add igt_require() for overlay planes, fixes CRASH on KBL

v3: -test modified for n planes (Ville)

Signed-off-by: Swati Sharma <swati2.sharma at intel.com>
---
 tests/kms_plane_scaling.c | 80 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 80 insertions(+)

diff --git a/tests/kms_plane_scaling.c b/tests/kms_plane_scaling.c
index 5dac5fb3..882859ab 100644
--- a/tests/kms_plane_scaling.c
+++ b/tests/kms_plane_scaling.c
@@ -33,6 +33,7 @@ IGT_TEST_DESCRIPTION("Test display plane scaling");
 enum {
         TEST_UP_UP_SCALING = 1 << 0,
         TEST_DOWN_DOWN_SCALING = 1 << 1,
+        TEST_UP_DOWN_SCALING = 1 << 2,
 };
 
 typedef struct {
@@ -484,6 +485,75 @@ __test_plane_down_down_scaling(data_t *d, enum pipe pipe, igt_output_t *output)
 	}
 }
 
+static void
+__test_plane_up_down_scaling(data_t *d, enum pipe pipe, igt_output_t *output)
+{
+	igt_display_t *display = &d->display;
+	int width1, height1, width2, height2;
+	drmModeModeInfo *mode;
+	bool test_complete;
+	int scaling;
+	int ret;
+
+	cleanup_crtc(d);
+
+	igt_output_set_pipe(output, pipe);
+	mode = igt_output_get_mode(output);
+	width1 = mode->hdisplay;
+	height1 = mode->vdisplay;
+	width2 = height2 = 20;
+
+	for (int k = 0; k < display->pipes[pipe].n_planes; k++) {
+		test_complete = false;
+		scaling = 50;
+
+		while (!test_complete) {
+			igt_plane_t *plane1, *plane2;
+
+			plane1 = &display->pipes[pipe].planes[k];
+			igt_require(plane1);
+			plane2 = &display->pipes[pipe].planes[k+1];
+			igt_require(plane2);
+
+			if (plane1->type == DRM_PLANE_TYPE_PRIMARY || plane1->type == DRM_PLANE_TYPE_CURSOR ||
+			    plane2->type == DRM_PLANE_TYPE_PRIMARY || plane2->type ==DRM_PLANE_TYPE_CURSOR)
+					break;
+
+			igt_create_color_pattern_fb(display->drm_fd,
+						    width1, height1,
+						    DRM_FORMAT_XRGB8888,
+						    I915_TILING_NONE,
+						    1.0, 0.0, 0.0, &d->fb[1]);
+			igt_create_color_pattern_fb(display->drm_fd,
+						    width2, height2,
+						    DRM_FORMAT_XRGB8888,
+						    I915_TILING_NONE,
+						    0.0, 1.0, 0.0, &d->fb[2]);
+
+			igt_plane_set_fb(plane1, &d->fb[1]);
+			igt_plane_set_fb(plane2, &d->fb[2]);
+
+			/* 1st overlay plane downscaling */
+			igt_plane_set_size(plane1, (width1 * scaling) / 100, (height1 * scaling) / 100);
+			/* 2nd overlay plane upscaling */
+			igt_plane_set_size(plane2, width1, height1);
+
+			ret = igt_display_try_commit_atomic(display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
+
+			if (ret != -EINVAL)
+				test_complete = true;
+
+			scaling += 5;
+
+			/* cleanup */
+			igt_plane_set_fb(plane1, NULL);
+			igt_plane_set_fb(plane2, NULL);
+			igt_remove_fb(display->drm_fd, &d->fb[1]);
+			igt_remove_fb(display->drm_fd, &d->fb[2]);
+		}
+	}
+}
+
 static void
 test_plane_scaling_combo(data_t *d, enum pipe pipe, igt_output_t *output, uint32_t flags)
 {
@@ -493,6 +563,8 @@ test_plane_scaling_combo(data_t *d, enum pipe pipe, igt_output_t *output, uint32
 		__test_plane_up_up_scaling(d, pipe, output);
 	if (flags & TEST_DOWN_DOWN_SCALING)
 		__test_plane_down_down_scaling(d, pipe, output);
+	if (flags & TEST_UP_DOWN_SCALING)
+		__test_plane_up_down_scaling(d, pipe, output);
 }
 
 static bool test_pipe_iteration(data_t *data, enum pipe pipe, int iteration)
@@ -842,6 +914,14 @@ igt_main_args("", long_opts, help_str, opt_handler, &data)
 					test_plane_scaling_combo(&data, pipe, output, TEST_DOWN_DOWN_SCALING);
 		}
 
+		igt_describe("Tests upscaling and downscaling of overlay planes.");
+		igt_subtest_with_dynamic("plane-up-down-scaling") {
+			for_each_pipe_with_valid_output(&data.display, pipe, output)
+				igt_dynamic_f("pipe-%s-%s-plane-up-down-scaling",
+					       kmstest_pipe_name(pipe), igt_output_name(output))
+					test_plane_scaling_combo(&data, pipe, output, TEST_UP_DOWN_SCALING);
+		}
+
 		igt_describe("Tests scaling with pixel formats.");
 		igt_subtest_with_dynamic("scaler-with-pixel-format") {
 			for_each_pipe_with_single_output(&data.display, pipe, output)
-- 
2.25.1



More information about the igt-dev mailing list