[Intel-gfx] [PATCH i-g-t v2 2/2] igt/kms_plane_scaling : plane scaling enhancement for bxt

Nabendu Maiti nabendu.bikash.maiti at intel.com
Mon Jul 20 02:44:21 PDT 2015


 Added and enhanced scaler test cases for additional planes.

Signed-off-by: Nabendu Maiti <nabendu.bikash.maiti at intel.com>
---
 lib/igt_fb.c              | 40 ++++++++++++++++++++++++
 lib/igt_fb.h              |  1 +
 tests/kms_plane_scaling.c | 78 ++++++++++++++++++++++++++++++++++++++++++++---
 3 files changed, 114 insertions(+), 5 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 134dbd2..b24a6a2 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -393,6 +393,46 @@ void igt_paint_image(cairo_t *cr, const char *filename,
 }
 
 /**
+ * igt_paint_cross_ruler:
+ * @cr: cairo drawing context
+ * @dst_width: width of the horizontal ruler
+ * @dst_height: height of the vertical ruler
+ *
+ * This function can be used to draw a cross ruler on a frame buffer.
+ */
+void
+igt_paint_cross_ruler(cairo_t *cr, int w, int h)
+{
+
+	uint16_t i;
+
+	/* Paint corner markers */
+	paint_marker(cr, 0, 0);
+	paint_marker(cr, w, 0);
+	paint_marker(cr, 0, h);
+	paint_marker(cr, w, h);
+
+
+	cairo_move_to(cr, w/2, 0);
+	cairo_line_to(cr, w/2, h);
+
+	cairo_set_source_rgb(cr, 4, 1, 10);
+	cairo_move_to(cr, 0, h/2);
+	cairo_line_to(cr, w, h/2 );
+	cairo_stroke(cr);
+
+	cairo_set_source_rgb(cr, 2, 5, 1);
+	cairo_set_line_width(cr, 2);
+	cairo_stroke(cr);
+	cairo_stroke_preserve(cr);
+	for (i = 0; i < w; i +=200)
+		paint_marker(cr, i, h/2);
+
+	for (i = 0; i < h; i +=200)
+		paint_marker(cr, w/2, i);
+}
+
+/**
  * igt_create_fb_with_bo_size:
  * @fd: open i915 drm file descriptor
  * @width: width of the framebuffer in pixel
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index a07acd2..ead643a 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -98,6 +98,7 @@ void igt_write_fb_to_png(int fd, struct igt_fb *fb, const char *filename);
 int igt_cairo_printf_line(cairo_t *cr, enum igt_text_align align,
 			       double yspacing, const char *fmt, ...)
 			       __attribute__((format (printf, 4, 5)));
+void igt_paint_cross_ruler(cairo_t *cr, int w, int h);
 
 /* helpers to handle drm fourcc codes */
 uint32_t igt_bpp_depth_to_drm_format(int bpp, int depth);
diff --git a/tests/kms_plane_scaling.c b/tests/kms_plane_scaling.c
index 00db5cb..0472b2d 100644
--- a/tests/kms_plane_scaling.c
+++ b/tests/kms_plane_scaling.c
@@ -23,7 +23,6 @@
  */
 
 #include <math.h>
-
 #include "drmtest.h"
 #include "igt_debugfs.h"
 #include "igt_kms.h"
@@ -48,9 +47,11 @@ typedef struct {
 	struct igt_fb fb1;
 	struct igt_fb fb2;
 	struct igt_fb fb3;
+	struct igt_fb fb4;
 	int fb_id1;
 	int fb_id2;
 	int fb_id3;
+	int fb_id4;
 
 	igt_plane_t *plane1;
 	igt_plane_t *plane2;
@@ -61,6 +62,22 @@ typedef struct {
 #define FILE_NAME   "1080p-left.png"
 
 static void
+paint_plane_ID(data_t *d, struct igt_fb *fb, igt_plane_t *plane)
+{
+	cairo_t *cr;
+
+	cr = igt_get_cairo_ctx(d->drm_fd, fb);
+	cairo_move_to(cr, (fb->width/5),
+		      (fb->height / 5));
+	cairo_set_font_size(cr, 25);
+	igt_cairo_printf_line(cr, align_hcenter, 10, "PIPE:PLANE:");
+	cairo_set_font_size(cr, 30);
+	igt_cairo_printf_line(cr, align_hcenter, 40, " %d:%d",
+			      plane->pipe->pipe, plane->index);
+	cairo_destroy(cr);
+}
+
+static void
 paint_color(data_t *d, struct igt_fb *fb, uint16_t w, uint16_t h)
 {
 	cairo_t *cr;
@@ -71,12 +88,14 @@ paint_color(data_t *d, struct igt_fb *fb, uint16_t w, uint16_t h)
 }
 
 static void
-paint_image(data_t *d, struct igt_fb *fb, uint16_t w, uint16_t h)
+paint_image(const char *filename, data_t *d, struct igt_fb *fb,
+		uint16_t w, uint16_t h)
 {
 	cairo_t *cr;
 
 	cr = igt_get_cairo_ctx(d->drm_fd, fb);
-	igt_paint_image(cr, FILE_NAME, 0, 0, w, h);
+	igt_paint_image(cr, filename, 0, 0, w, h);
+	igt_paint_cross_ruler(cr, w, h);
 	cairo_destroy(cr);
 }
 
@@ -106,6 +125,7 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
 	igt_assert(data->fb_id1);
 
 	paint_color(data, &data->fb1, mode->hdisplay, mode->vdisplay);
+	paint_plane_ID(data, &data->fb1, plane);
 
 	/*
 	 * We always set the primary plane to actually enable the pipe as
@@ -154,7 +174,10 @@ static void cleanup_crtc(data_t *data, igt_output_t *output, igt_plane_t *plane)
 		igt_remove_fb(data->drm_fd, &data->fb3);
 		data->fb_id3 = 0;
 	}
-
+	if (data->fb_id4) {
+		igt_remove_fb(data->drm_fd, &data->fb4);
+		data->fb_id4 = 0;
+	}
 	if (!plane->is_primary) {
 		igt_plane_t *primary;
 
@@ -235,7 +258,7 @@ static void test_plane_scaling(data_t *d)
 				LOCAL_I915_FORMAT_MOD_X_TILED, /* tiled */
 				&d->fb2);
 		igt_assert(d->fb_id2);
-		paint_image(d, &d->fb2, d->fb2.width, d->fb2.height);
+		paint_image(FILE_NAME, d, &d->fb2, d->fb2.width, d->fb2.height);
 
 		d->fb_id3 = igt_create_fb(d->drm_fd,
 				mode->hdisplay, mode->vdisplay,
@@ -245,6 +268,17 @@ static void test_plane_scaling(data_t *d)
 		igt_assert(d->fb_id3);
 		paint_color(d, &d->fb3, mode->hdisplay, mode->vdisplay);
 
+		if ((display->pipes[pipe].n_planes > 4) && (pipe != PIPE_C)) {
+			d->fb_id4 = igt_create_fb(d->drm_fd,
+					d->image_w, d->image_h,
+					DRM_FORMAT_XRGB8888,
+					LOCAL_I915_FORMAT_MOD_X_TILED, /*tiled*/
+					&d->fb4);
+			igt_assert(d->fb_id4);
+			paint_image(FILE_NAME, d,&d->fb4, d->fb4.width,
+				    d->fb4.height);
+		}
+
 		/* Set up display with plane 1 */
 		d->plane1 = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
 		prepare_crtc(d, output, pipe, d->plane1, mode, COMMIT_UNIVERSAL);
@@ -268,6 +302,7 @@ static void test_plane_scaling(data_t *d)
 		/* Set up fb2->plane2 mapping. */
 		d->plane2 = igt_output_get_plane(output, IGT_PLANE_2);
 		igt_plane_set_fb(d->plane2, &d->fb2);
+		paint_plane_ID(d, &d->fb2, d->plane2);
 
 		/* 2nd plane windowed */
 		igt_fb_set_position(&d->fb2, d->plane2, 100, 100);
@@ -293,6 +328,7 @@ static void test_plane_scaling(data_t *d)
 		igt_display_commit2(display, COMMIT_UNIVERSAL);
 
 		if (primary_plane_scaling) {
+
 			/* Primary plane up scaling */
 			igt_fb_set_position(&d->fb1, d->plane1, 100, 100);
 			igt_fb_set_size(&d->fb1, d->plane1, 500, 500);
@@ -304,6 +340,7 @@ static void test_plane_scaling(data_t *d)
 		/* Set up fb3->plane3 mapping. */
 		d->plane3 = igt_output_get_plane(output, IGT_PLANE_3);
 		igt_plane_set_fb(d->plane3, &d->fb3);
+		paint_plane_ID(d, &d->fb3, d->plane3);
 
 		/* 3rd plane windowed - no scaling */
 		igt_fb_set_position(&d->fb3, d->plane3, 100, 100);
@@ -324,6 +361,35 @@ static void test_plane_scaling(data_t *d)
 		igt_plane_set_size(d->plane3, mode->hdisplay-300, mode->vdisplay-300);
 		igt_display_commit2(display, COMMIT_UNIVERSAL);
 
+		if ((display->pipes[pipe].n_planes > 4) && (pipe != PIPE_C)) {
+
+			/* Set up fb4->plane4 mapping. */
+			d->plane4 = igt_output_get_plane(output, IGT_PLANE_4);
+			igt_plane_set_fb(d->plane4, &d->fb4);
+			paint_plane_ID(d, &d->fb4, d->plane4);
+
+			/* 4th plane windowed - no scaling */
+			igt_fb_set_position(&d->fb4, d->plane4, 50, 200);
+			igt_fb_set_size(&d->fb4, d->plane4, d->fb4.width-300, d->fb4.height-300);
+			igt_plane_set_position(d->plane4, 100, 100);
+			igt_plane_set_size(d->plane4, d->fb4.width-300, d->fb4.height-300);
+			igt_display_commit2(display, COMMIT_UNIVERSAL);
+
+			/* Switch scaler from plane 3 to plane 4 */
+			igt_fb_set_position(&d->fb3, d->plane3, 100, 100);
+			igt_fb_set_size(&d->fb3, d->plane3, d->fb3.width-300, d->fb3.height-300);
+			igt_plane_set_position(d->plane3, 100, 100);
+			igt_plane_set_size(d->plane3, d->fb3.width-300, d->fb3.height-300);
+			igt_display_commit2(display, COMMIT_UNIVERSAL);
+
+			igt_fb_set_position(&d->fb4, d->plane4, 10, 10);
+			igt_fb_set_size(&d->fb4, d->plane4, d->fb4.width-50, d->fb4.height-50);
+			igt_plane_set_position(d->plane4, 10, 10);
+			igt_plane_set_size(d->plane4, mode->hdisplay-300, mode->vdisplay-300);
+			igt_display_commit2(display, COMMIT_UNIVERSAL);
+
+		}
+
 		if (primary_plane_scaling) {
 			/* Switch scaler from plane 1 to plane 2 */
 			igt_fb_set_position(&d->fb1, d->plane1, 0, 0);
@@ -341,6 +407,8 @@ static void test_plane_scaling(data_t *d)
 		/* back to single plane mode */
 		igt_plane_set_fb(d->plane2, NULL);
 		igt_plane_set_fb(d->plane3, NULL);
+		if (d->plane4)
+			igt_plane_set_fb(d->plane4, NULL);
 		igt_display_commit2(display, COMMIT_UNIVERSAL);
 
 		valid_tests++;
-- 
1.9.1



More information about the Intel-gfx mailing list