[Intel-gfx] [PATCH i-g-t v2 6/9] tests/kms_plane_scaling: test scaling with tiling rotation and pixel formats, v2.

Maarten Lankhorst maarten.lankhorst at linux.intel.com
Fri Jan 12 10:21:13 UTC 2018


From: Jyoti Yadav <jyoti.r.yadav at intel.com>

This patch adds subtest for testing scaling in combination with rotation
and pixel formats.

Changes since v1:
- Rework test to work with the other changes to kms_plane_scaling. (Maarten)
- Remove hardcodes for MIN/MAX_SRC_WIDTH, and use the value directly. (Maarten)

Signed-off-by: Jyoti Yadav <jyoti.r.yadav at intel.com>
Signed-off-by: Mahesh Kumar <mahesh1.kumar at intel.com>
Signed-off-by: Vidya Srinivas <vidya.srinivas at intel.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
---
 tests/kms_plane_scaling.c | 161 +++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 160 insertions(+), 1 deletion(-)

diff --git a/tests/kms_plane_scaling.c b/tests/kms_plane_scaling.c
index 44ff91d7738f..821d0a9c883b 100644
--- a/tests/kms_plane_scaling.c
+++ b/tests/kms_plane_scaling.c
@@ -48,10 +48,55 @@ typedef struct {
 
 #define FILE_NAME   "1080p-left.png"
 
+#define MAX_ROTATION	4
+static igt_rotation_t get_rotation_angle(int rot)
+{
+	switch (rot) {
+	case 0:
+		return IGT_ROTATION_0;
+		break;
+	case 1:
+		return IGT_ROTATION_90;
+		break;
+	case 2:
+		return IGT_ROTATION_180;
+		break;
+	case 3:
+		return IGT_ROTATION_270;
+		break;
+	default:
+		igt_info("Unknown/Unsupported Rotation %d\n", rot);
+		return IGT_ROTATION_0;
+	}
+}
+
+#define MAX_TILING	4
+static uint64_t get_tiling(int tiling)
+{
+	switch (tiling) {
+	case 0:
+		return LOCAL_DRM_FORMAT_MOD_NONE;
+		break;
+	case 1:
+		return LOCAL_I915_FORMAT_MOD_X_TILED;
+		break;
+	case 2:
+		return LOCAL_I915_FORMAT_MOD_Y_TILED;
+		break;
+	case 3:
+		return LOCAL_I915_FORMAT_MOD_Yf_TILED;
+		break;
+	default:
+		igt_info("Unknown/Unsupported Tiling %d\n", tiling);
+		return LOCAL_DRM_FORMAT_MOD_NONE;
+	}
+}
+
 static void cleanup_crtc(data_t *data)
 {
 	int i;
 
+	igt_display_reset(&data->display);
 	igt_pipe_crc_free(data->pipe_crc);
 	data->pipe_crc = NULL;
 
@@ -71,7 +116,6 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
 
 	cleanup_crtc(data);
 
-	igt_display_reset(display);
 	igt_output_set_pipe(output, pipe);
 
 	/* create the pipe_crc object for this pipe */
@@ -104,6 +148,112 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
 	igt_display_commit2(display, COMMIT_ATOMIC);
 }
 
+static void paint_fb(data_t *d, struct igt_fb *fb)
+{
+	cairo_t *cr;
+
+	cr = igt_get_cairo_ctx(d->drm_fd, fb);
+	igt_paint_color(cr, 0, 0, fb->width, fb->height, 0.0, 1.0, 0.0);
+	igt_assert(cairo_status(cr) == 0);
+	cairo_destroy(cr);
+}
+
+static void check_scaling_pipe_plane_rot(data_t *d, igt_plane_t *plane,
+					 uint32_t pixel_format,
+					 uint64_t tiling, enum pipe pipe,
+					 igt_output_t *output,
+					 igt_rotation_t rot)
+{
+	igt_display_t *display = &d->display;
+	int width, height;
+	drmModeModeInfo *mode;
+
+	cleanup_crtc(d);
+
+	igt_output_set_pipe(output, pipe);
+	mode = igt_output_get_mode(output);
+
+	/* create buffer in the range of  min and max source side limit.*/
+	width = height = 9;
+	igt_create_fb(display->drm_fd, width, height,
+		      pixel_format, tiling, &d->fb[0]);
+	paint_fb(d, &d->fb[0]);
+	igt_plane_set_fb(plane, &d->fb[0]);
+
+	/* Check min to full resolution upscaling */
+	igt_fb_set_position(&d->fb[0], plane, 0, 0);
+	igt_fb_set_size(&d->fb[0], plane, width, height);
+	igt_plane_set_position(plane, 0, 0);
+	igt_plane_set_size(plane, mode->hdisplay, mode->vdisplay);
+	igt_plane_set_rotation(plane, rot);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+
+	igt_plane_set_fb(plane, NULL);
+	igt_plane_set_position(plane, 0, 0);
+}
+
+static void test_scaler_with_rotation_pipe(data_t *d, enum pipe pipe,
+					   igt_output_t *output)
+{
+	igt_display_t *display = &d->display;
+	igt_plane_t *plane;
+
+	igt_output_set_pipe(output, pipe);
+	for_each_plane_on_pipe(display, pipe, plane) {
+
+		if (plane->type == DRM_PLANE_TYPE_CURSOR)
+			continue;
+
+		for (int i = 0; i < MAX_ROTATION; i++) {
+			igt_rotation_t rot = get_rotation_angle(i);
+			check_scaling_pipe_plane_rot(d, plane, DRM_FORMAT_XRGB8888,
+						     LOCAL_I915_FORMAT_MOD_Y_TILED,
+						     pipe, output, rot);
+		}
+	}
+}
+
+static bool can_draw(uint32_t drm_format)
+{
+	const uint32_t *drm_formats;
+	int format_count, i;
+
+	igt_get_all_cairo_formats(&drm_formats, &format_count);
+
+	for (i = 0; i < format_count; i++)
+		if (drm_formats[i] == drm_format)
+			return true;
+
+	return false;
+}
+
+static void test_scaler_with_pixel_format_pipe(data_t *d, enum pipe pipe, igt_output_t *output)
+{
+	igt_display_t *display = &d->display;
+	igt_plane_t *plane;
+
+	igt_output_set_pipe(output, pipe);
+
+	for_each_plane_on_pipe(display, pipe, plane) {
+		if (plane->type == DRM_PLANE_TYPE_CURSOR)
+			continue;
+
+		for (int i = 0; i < MAX_TILING; i++) {
+			uint64_t tiling = get_tiling(i);
+			int j;
+
+			for (j = 0; j < plane->drm_plane->count_formats; j++) {
+				uint32_t format = plane->drm_plane->formats[j];
+
+				if (can_draw(format))
+					check_scaling_pipe_plane_rot(d, plane,
+								     format, tiling,
+								     pipe, output, IGT_ROTATION_0);
+			}
+		}
+	}
+}
+
 /* does iterative scaling on plane2 */
 static void iterate_plane_scaling(data_t *d, drmModeModeInfo *mode)
 {
@@ -287,6 +437,15 @@ igt_main
 		igt_subtest_f("pipe-%s-plane-scaling", kmstest_pipe_name(pipe))
 			for_each_valid_output_on_pipe(&data.display, pipe, output)
 				test_plane_scaling_on_pipe(&data, pipe, output);
+
+		igt_subtest_f("pipe-%s-scaler-with-pixel-format", kmstest_pipe_name(pipe))
+			for_each_valid_output_on_pipe(&data.display, pipe, output)
+				test_scaler_with_pixel_format_pipe(&data, pipe, output);
+
+		igt_subtest_f("pipe-%s-scaler-with-rotation", kmstest_pipe_name(pipe))
+			for_each_valid_output_on_pipe(&data.display, pipe, output)
+				test_scaler_with_rotation_pipe(&data, pipe, output);
+
 	}
 
 	igt_fixture
-- 
2.15.1



More information about the Intel-gfx mailing list