All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anusha Srivatsa <anusha.srivatsa@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [patch i-g-t] igt/kms_rotation_crc: Add horizontal flip subtest.
Date: Wed,  4 Oct 2017 17:43:43 -0700	[thread overview]
Message-ID: <1507164223-22598-1-git-send-email-anusha.srivatsa@intel.com> (raw)

From: Joseph Garvey <joseph1.garvey@intel.com>

Test that horizontal flip works with supported rotations. Includes
a fix for the unrotated fb which was not being positioned correctly
with portrait and landscape rectangles.

v2:(from Anusha)
- Change 180 degree rotation to follow the rest, use
igt_swap(), make flip variable a bool. Format the
patch correctly (Ville, Petri Latvala)

Signed-off-by: Anusha Srivatsa <anusha.srivatsa@intel.com>
Signed-off-by: Joseph Garvey <joseph1.garvey@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Petri Latvala <petri.latvala@intel.com>
---
 lib/igt_kms.c            |   2 +-
 lib/igt_kms.h            |   5 ++
 tests/kms_rotation_crc.c | 197 +++++++++++++++++++++++++++++++++++++----------
 3 files changed, 163 insertions(+), 41 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index a572fc6..3034e44 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -3050,7 +3050,7 @@ void igt_fb_set_size(struct igt_fb *fb, igt_plane_t *plane,
 
 static const char *rotation_name(igt_rotation_t rotation)
 {
-	switch (rotation) {
+	switch (rotation & IGT_ROTATION_MASK) {
 	case IGT_ROTATION_0:
 		return "0°";
 	case IGT_ROTATION_90:
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 8dc118c..b83a828 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -281,8 +281,13 @@ typedef enum {
 	IGT_ROTATION_90  = 1 << 1,
 	IGT_ROTATION_180 = 1 << 2,
 	IGT_ROTATION_270 = 1 << 3,
+	IGT_REFLECT_X    = 1 << 4,
+	IGT_REFLECT_Y    = 1 << 5,
 } igt_rotation_t;
 
+#define IGT_ROTATION_MASK \
+	(IGT_ROTATION_0 | IGT_ROTATION_90 | IGT_ROTATION_180 | IGT_ROTATION_270)
+
 typedef struct {
 	/*< private >*/
 	igt_pipe_t *pipe;
diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
index 5aec8fa..b894df3 100644
--- a/tests/kms_rotation_crc.c
+++ b/tests/kms_rotation_crc.c
@@ -32,6 +32,7 @@ typedef struct {
 	igt_display_t display;
 	struct igt_fb fb;
 	struct igt_fb fb_reference;
+	struct igt_fb fb_unrotated;
 	struct igt_fb fb_modeset;
 	struct igt_fb fb_flip;
 	igt_crc_t ref_crc;
@@ -43,8 +44,59 @@ typedef struct {
 	uint32_t override_fmt;
 	uint64_t override_tiling;
 	bool flips;
+	int devid;
 } data_t;
 
+typedef struct {
+	float r;
+	float g;
+	float b;
+} rgb_color_t;
+
+static void set_color(rgb_color_t *color, float r, float g, float b)
+{
+	color->r = r;
+	color->g = g;
+	color->b = b;
+}
+
+static void rotate_colors(rgb_color_t *tl, rgb_color_t *tr, rgb_color_t *br,
+			  rgb_color_t *bl, igt_rotation_t rotation)
+{
+	rgb_color_t bl_tmp, br_tmp, tl_tmp, tr_tmp;
+
+	if (rotation & IGT_REFLECT_X) {
+		igt_swap(*tl, *tr);
+		igt_swap(*bl, *br);
+	}
+
+	if (rotation & IGT_ROTATION_90) {
+		bl_tmp = *bl;
+		br_tmp = *br;
+		tl_tmp = *tl;
+		tr_tmp = *tr;
+		*tl = tr_tmp;
+		*bl = tl_tmp;
+		*tr = br_tmp;
+		*br = bl_tmp;
+	} else if (rotation & IGT_ROTATION_180) {
+		igt_swap(*tl, *br);
+		igt_swap(*tr, *bl);
+	} else if (rotation & IGT_ROTATION_270) {
+		bl_tmp = *bl;
+		br_tmp = *br;
+		tl_tmp = *tl;
+		tr_tmp = *tr;
+		*tl = bl_tmp;
+		*bl = br_tmp;
+		*tr = tl_tmp;
+		*br = tr_tmp;
+	}
+}
+
+#define RGB_COLOR(color) \
+	color.r, color.g, color.b
+
 static void
 paint_squares(data_t *data, igt_rotation_t rotation,
 	      struct igt_fb *fb, float o)
@@ -52,35 +104,21 @@ paint_squares(data_t *data, igt_rotation_t rotation,
 	cairo_t *cr;
 	unsigned int w = fb->width;
 	unsigned int h = fb->height;
+	rgb_color_t tl, tr, bl, br;
 
 	cr = igt_get_cairo_ctx(data->gfx_fd, fb);
 
-	if (rotation == IGT_ROTATION_180) {
-		cairo_translate(cr, w, h);
-		cairo_rotate(cr, M_PI);
-	}
+	set_color(&tl, o, 0.0f, 0.0f);
+	set_color(&tr, 0.0f, o, 0.0f);
+	set_color(&br, o, o, o);
+	set_color(&bl, 0.0f, 0.0f, o);
 
-	if (rotation == IGT_ROTATION_90) {
-		/* Paint 4 squares with width == height in Green, White,
-		Blue, Red Clockwise order to look like 270 degree rotated*/
-		igt_paint_color(cr, 0, 0, w / 2, h / 2, 0.0, o, 0.0);
-		igt_paint_color(cr, w / 2, 0, w / 2, h / 2, o, o, o);
-		igt_paint_color(cr, 0, h / 2, w / 2, h / 2, o, 0.0, 0.0);
-		igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, 0.0, 0.0, o);
-	} else if (rotation == IGT_ROTATION_270) {
-		/* Paint 4 squares with width == height in Blue, Red,
-		Green, White Clockwise order to look like 90 degree rotated*/
-		igt_paint_color(cr, 0, 0, w / 2, h / 2, 0.0, 0.0, o);
-		igt_paint_color(cr, w / 2, 0, w / 2, h / 2, o, 0.0, 0.0);
-		igt_paint_color(cr, 0, h / 2, w / 2, h / 2, o, o, o);
-		igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, 0.0, o, 0.0);
-	} else {
-		/* Paint with 4 squares of Red, Green, White, Blue Clockwise */
-		igt_paint_color(cr, 0, 0, w / 2, h / 2, o, 0.0, 0.0);
-		igt_paint_color(cr, w / 2, 0, w / 2, h / 2, 0.0, o, 0.0);
-		igt_paint_color(cr, 0, h / 2, w / 2, h / 2, 0.0, 0.0, o);
-		igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, o, o, o);
-	}
+	rotate_colors(&tl, &tr, &br, &bl, rotation);
+
+	igt_paint_color(cr, 0, 0, w / 2, h / 2, RGB_COLOR(tl));
+	igt_paint_color(cr, w / 2, 0, w / 2, h / 2, RGB_COLOR(tr));
+	igt_paint_color(cr, 0, h / 2, w / 2, h / 2, RGB_COLOR(bl));
+	igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, RGB_COLOR(br));
 
 	cairo_destroy(cr);
 }
@@ -141,6 +179,7 @@ static void remove_fbs(data_t *data)
 
 	igt_remove_fb(data->gfx_fd, &data->fb);
 	igt_remove_fb(data->gfx_fd, &data->fb_reference);
+	igt_remove_fb(data->gfx_fd, &data->fb_unrotated);
 
 	if (data->fb_flip.fb_id)
 		igt_remove_fb(data->gfx_fd, &data->fb_flip);
@@ -212,17 +251,12 @@ static void prepare_fbs(data_t *data, igt_output_t *output,
 	 * For 90/270, we will use create smaller fb so that the rotated
 	 * frame can fit in
 	 */
-	if (data->rotation == IGT_ROTATION_90 ||
-	    data->rotation == IGT_ROTATION_270) {
+	if (data->rotation & (IGT_ROTATION_90 | IGT_ROTATION_270)) {
 		tiling = data->override_tiling ?: LOCAL_I915_FORMAT_MOD_Y_TILED;
 
 		igt_swap(w, h);
 	}
 
-	igt_create_fb(data->gfx_fd, w, h, pixel_format, tiling, &data->fb);
-
-	igt_plane_set_rotation(plane, IGT_ROTATION_0);
-
 	/*
 	 * Create a reference software rotated flip framebuffer.
 	 */
@@ -255,8 +289,20 @@ static void prepare_fbs(data_t *data, igt_output_t *output,
 	igt_pipe_crc_collect_crc(data->pipe_crc, &data->ref_crc);
 
 	/*
+	 * Prepare the non-rotated reference fb.
+	 */
+	igt_create_fb(data->gfx_fd, ref_w, ref_h, pixel_format, tiling, &data->fb_unrotated);
+	paint_squares(data, IGT_ROTATION_0, &data->fb_unrotated, 1.0);
+	igt_plane_set_fb(plane, &data->fb_unrotated);
+	igt_plane_set_rotation(plane, IGT_ROTATION_0);
+	if (plane->type != DRM_PLANE_TYPE_CURSOR)
+		igt_plane_set_position(plane, data->pos_x, data->pos_y);
+	igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_UNIVERSAL);
+
+	/*
 	 * Prepare the plane with an non-rotated fb let the hw rotate it.
 	 */
+	igt_create_fb(data->gfx_fd, w, h, pixel_format, tiling, &data->fb);
 	paint_squares(data, IGT_ROTATION_0, &data->fb, 1.0);
 	igt_plane_set_fb(plane, &data->fb);
 
@@ -322,7 +368,7 @@ static void wait_for_pageflip(int fd)
 	igt_assert(drmHandleEvent(fd, &evctx) == 0);
 }
 
-static void test_plane_rotation(data_t *data, int plane_type)
+static void __test_plane_rotation(data_t *data, int plane_type, bool test_bad_format)
 {
 	igt_display_t *display = &data->display;
 	igt_output_t *output;
@@ -348,6 +394,9 @@ static void test_plane_rotation(data_t *data, int plane_type)
 		igt_plane_t *plane;
 		int i;
 
+		if (IS_CHERRYVIEW(data->devid) && pipe != PIPE_B)
+			continue;
+
 		igt_output_set_pipe(output, pipe);
 
 		plane = igt_output_get_plane_type(output, plane_type);
@@ -369,14 +418,12 @@ static void test_plane_rotation(data_t *data, int plane_type)
 			igt_debug("Testing case %i on pipe %s\n", i, kmstest_pipe_name(pipe));
 			prepare_fbs(data, output, plane, i);
 
-			igt_display_commit2(display, commit);
-
 			igt_plane_set_rotation(plane, data->rotation);
-			if (data->rotation == IGT_ROTATION_90 || data->rotation == IGT_ROTATION_270)
+			if (data->rotation & (IGT_ROTATION_90 | IGT_ROTATION_270))
 				igt_plane_set_size(plane, data->fb.height, data->fb.width);
 
 			ret = igt_display_try_commit2(display, commit);
-			if (data->override_fmt || data->override_tiling) {
+			if (test_bad_format && (data->override_fmt || data->override_tiling)) {
 				igt_assert_eq(ret, -EINVAL);
 				continue;
 			}
@@ -421,6 +468,16 @@ static void test_plane_rotation(data_t *data, int plane_type)
 	igt_require_f(valid_tests, "no valid crtc/connector combinations found\n");
 }
 
+static inline void test_bad_plane_rotation(data_t *data, int plane_type)
+{
+	__test_plane_rotation(data, plane_type, true);
+}
+
+static inline void test_plane_rotation(data_t *data, int plane_type)
+{
+	__test_plane_rotation(data, plane_type, false);
+}
+
 static void test_plane_rotation_ytiled_obj(data_t *data,
 					   igt_output_t *output,
 					   int plane_type)
@@ -613,6 +670,8 @@ static const char *plane_test_str(unsigned plane)
 static const char *rot_test_str(igt_rotation_t rot)
 {
 	switch (rot) {
+	case IGT_ROTATION_0:
+		return "0";
 	case IGT_ROTATION_90:
 		return "90";
 	case IGT_ROTATION_180:
@@ -624,6 +683,20 @@ static const char *rot_test_str(igt_rotation_t rot)
 	}
 }
 
+static const char *tiling_test_str(uint64_t tiling)
+{
+	switch (tiling) {
+	case LOCAL_I915_FORMAT_MOD_X_TILED:
+		return "x-tiled";
+	case LOCAL_I915_FORMAT_MOD_Y_TILED:
+		return "y-tiled";
+	case LOCAL_I915_FORMAT_MOD_Yf_TILED:
+		return "yf-tiled";
+	default:
+		igt_assert(0);
+	}
+}
+
 static const char *flip_test_str(unsigned flips)
 {
 	if (flips)
@@ -637,7 +710,7 @@ igt_main
 	struct rot_subtest {
 		unsigned plane;
 		igt_rotation_t rot;
-		unsigned flips;
+		bool flips;
 	} *subtest, subtests[] = {
 		{ DRM_PLANE_TYPE_PRIMARY, IGT_ROTATION_90, 0 },
 		{ DRM_PLANE_TYPE_PRIMARY, IGT_ROTATION_180, 0 },
@@ -654,6 +727,35 @@ igt_main
 		{ DRM_PLANE_TYPE_CURSOR, IGT_ROTATION_180, 0 },
 		{ 0, 0, 0}
 	};
+
+	struct reflect_x {
+		uint64_t tiling;
+		igt_rotation_t rot;
+		bool flips;
+	} *reflect_x, reflect_x_subtests[] = {
+		{ LOCAL_I915_FORMAT_MOD_X_TILED, IGT_ROTATION_0, 0 },
+		{ LOCAL_I915_FORMAT_MOD_X_TILED, IGT_ROTATION_180, 0 },
+		{ LOCAL_I915_FORMAT_MOD_Y_TILED, IGT_ROTATION_0, 0 },
+		{ LOCAL_I915_FORMAT_MOD_Y_TILED, IGT_ROTATION_90, 0 },
+		{ LOCAL_I915_FORMAT_MOD_Y_TILED, IGT_ROTATION_180, 0 },
+		{ LOCAL_I915_FORMAT_MOD_Y_TILED, IGT_ROTATION_270, 0 },
+		{ LOCAL_I915_FORMAT_MOD_Yf_TILED, IGT_ROTATION_0, 0 },
+		{ LOCAL_I915_FORMAT_MOD_Yf_TILED, IGT_ROTATION_90, 0 },
+		{ LOCAL_I915_FORMAT_MOD_Yf_TILED, IGT_ROTATION_180, 0 },
+		{ LOCAL_I915_FORMAT_MOD_Yf_TILED, IGT_ROTATION_270, 0 },
+		{ LOCAL_I915_FORMAT_MOD_X_TILED, IGT_ROTATION_0, 1 },
+		{ LOCAL_I915_FORMAT_MOD_X_TILED, IGT_ROTATION_180, 1 },
+		{ LOCAL_I915_FORMAT_MOD_Y_TILED, IGT_ROTATION_0, 1 },
+		{ LOCAL_I915_FORMAT_MOD_Y_TILED, IGT_ROTATION_90, 1 },
+		{ LOCAL_I915_FORMAT_MOD_Y_TILED, IGT_ROTATION_180, 1 },
+		{ LOCAL_I915_FORMAT_MOD_Y_TILED, IGT_ROTATION_270, 1 },
+		{ LOCAL_I915_FORMAT_MOD_Yf_TILED, IGT_ROTATION_0, 1 },
+		{ LOCAL_I915_FORMAT_MOD_Yf_TILED, IGT_ROTATION_90, 1 },
+		{ LOCAL_I915_FORMAT_MOD_Yf_TILED, IGT_ROTATION_180, 1 },
+		{ LOCAL_I915_FORMAT_MOD_Yf_TILED, IGT_ROTATION_270, 1 },
+		{ 0, 0, 0 }
+	};
+
 	data_t data = {};
 	int gen = 0;
 
@@ -661,7 +763,8 @@ igt_main
 
 	igt_fixture {
 		data.gfx_fd = drm_open_driver_master(DRIVER_INTEL);
-		gen = intel_gen(intel_get_drm_devid(data.gfx_fd));
+		data.devid = intel_get_drm_devid(data.gfx_fd);
+		gen = intel_gen(data.devid);
 
 		kmstest_set_vt_graphics_mode();
 
@@ -698,7 +801,7 @@ igt_main
 		data.pos_y = 0;
 		data.rotation = IGT_ROTATION_90;
 		data.override_fmt = DRM_FORMAT_RGB565;
-		test_plane_rotation(&data, DRM_PLANE_TYPE_PRIMARY);
+		test_bad_plane_rotation(&data, DRM_PLANE_TYPE_PRIMARY);
 	}
 
 	igt_subtest_f("bad-tiling") {
@@ -706,7 +809,7 @@ igt_main
 		data.override_fmt = 0;
 		data.rotation = IGT_ROTATION_90;
 		data.override_tiling = LOCAL_DRM_FORMAT_MOD_NONE;
-		test_plane_rotation(&data, DRM_PLANE_TYPE_PRIMARY);
+		test_bad_plane_rotation(&data, DRM_PLANE_TYPE_PRIMARY);
 	}
 
 	igt_subtest_f("primary-rotation-90-Y-tiled") {
@@ -729,6 +832,20 @@ igt_main
 		igt_require_f(valid_tests, "no valid crtc/connector combinations found\n");
 	}
 
+	for (reflect_x = reflect_x_subtests; reflect_x->tiling; reflect_x++) {
+		igt_subtest_f("primary-%s-reflect-x-%s",
+			      tiling_test_str(reflect_x->tiling),
+			      rot_test_str(reflect_x->rot)) {
+			igt_require(gen >= 10 ||
+				    (IS_CHERRYVIEW(data.devid) && reflect_x->rot == IGT_ROTATION_0
+				     && reflect_x->tiling == LOCAL_I915_FORMAT_MOD_X_TILED));
+			data.rotation = (IGT_REFLECT_X | reflect_x->rot);
+			data.override_tiling = reflect_x->tiling;
+			data.flips = reflect_x->flips;
+			test_plane_rotation(&data, DRM_PLANE_TYPE_PRIMARY);
+		}
+	}
+
 	igt_subtest_f("exhaust-fences") {
 		enum pipe pipe;
 		igt_output_t *output;
-- 
2.7.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

             reply	other threads:[~2017-10-05  0:45 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-05  0:43 Anusha Srivatsa [this message]
2017-10-05  1:08 ` ✓ Fi.CI.BAT: success for igt/kms_rotation_crc: Add horizontal flip subtest Patchwork
2017-10-05  6:50   ` Arkadiusz Hiler
2017-10-09 17:18     ` Srivatsa, Anusha
2017-10-05  2:27 ` ✓ Fi.CI.IGT: " Patchwork
2017-10-05  6:57 ` ✓ Fi.CI.BAT: " Patchwork
2017-10-05  7:57 ` ✓ Fi.CI.IGT: " Patchwork
2017-10-20 23:29 [PATCH i-g-t] " Anusha Srivatsa
2017-11-22 23:05 Anusha Srivatsa
2017-11-29  9:55 ` Petri Latvala
2017-11-29 19:26   ` Srivatsa, Anusha
2017-12-12  9:53 ` Petri Latvala
2017-12-14 10:14 ` Daniel Vetter
2017-12-19  0:00   ` Rodrigo Vivi
2017-12-19  0:20   ` Srivatsa, Anusha
2017-12-19 21:49     ` Rodrigo Vivi
2018-02-02  7:04       ` Srivatsa, Anusha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1507164223-22598-1-git-send-email-anusha.srivatsa@intel.com \
    --to=anusha.srivatsa@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.