Skip to contentSkip to conversation

igt/kms_rotation_crc: Add horizontal flip subtest.

PATCH In review Anusha Srivatsa 5 participants 11 messages Nov 22, 2017 – Feb 2, 2018 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 igt/kms_rotation_crc: Add horizontal flip subtest.

From: Joseph Garvey <[email protected]>

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)

v3: (From Anusha)
- Correct the name of subtests in order to avoid duplication of names (Arek)

Cc Ville Syrjälä <[email protected]>
Cc Petri Latvala <[email protected]>
Cc Arkadiusz Hiler <[email protected]>
---
 lib/igt_kms.c            |   2 +-
 lib/igt_kms.h            |   5 ++
 tests/kms_rotation_crc.c | 198 +++++++++++++++++++++++++++++++++++++----------
 3 files changed, 164 insertions(+), 41 deletions(-)
lib/igt_kms.c +1 -1
index a572fc6..3034e44 100644
@@ -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:
lib/igt_kms.h +5 -0
index 8dc118c..b83a828 100644
@@ -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;
tests/kms_rotation_crc.c +158 -40

323 lines not on this page · raw message

Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

✓ Fi.CI.BAT: success for igt/kms_rotation_crc: Add horizontal flip subtest. (rev3)

== Series Details ==

== Series Details ==

Series: igt/kms_rotation_crc: Add horizontal flip subtest. (rev3)
URL : https://patchwork.freedesktop.org/series/31407/
State : success

== Summary ==

IGT patchset tested on top of latest successful build a1e444f4c8178acb590d41c21e921c6447668be4 tests/perf_pmu: Bump measuring duration for semaphores as well

with latest DRM-Tip kernel build CI_DRM_3378
b407e5f38397 drm-tip: 2017y-11m-23d-16h-14m-59s UTC integration manifest

Testlist changes:
+igt@kms_rotation_crc@primary-x-tiled-reflect-x-0 +igt@kms_rotation_crc@primary-x-tiled-reflect-x-0-flip +igt@kms_rotation_crc@primary-x-tiled-reflect-x-180 +igt@kms_rotation_crc@primary-x-tiled-reflect-x-180-flip +igt@kms_rotation_crc@primary-yf-tiled-reflect-x-0 +igt@kms_rotation_crc@primary-yf-tiled-reflect-x-0-flip +igt@kms_rotation_crc@primary-yf-tiled-reflect-x-90 +igt@kms_rotation_crc@primary-yf-tiled-reflect-x-90-flip +igt@kms_rotation_crc@primary-yf-tiled-reflect-x-180 +igt@kms_rotation_crc@primary-yf-tiled-reflect-x-180-flip +igt@kms_rotation_crc@primary-yf-tiled-reflect-x-270 +igt@kms_rotation_crc@primary-yf-tiled-reflect-x-270-flip +igt@kms_rotation_crc@primary-y-tiled-reflect-x-0 +igt@kms_rotation_crc@primary-y-tiled-reflect-x-0-flip +igt@kms_rotation_crc@primary-y-tiled-reflect-x-90 +igt@kms_rotation_crc@primary-y-tiled-reflect-x-90-flip +igt@kms_rotation_crc@primary-y-tiled-reflect-x-180 +igt@kms_rotation_crc@primary-y-tiled-reflect-x-180-flip +igt@kms_rotation_crc@primary-y-tiled-reflect-x-270 +igt@kms_rotation_crc@primary-y-tiled-reflect-x-270-flip

Test kms_pipe_crc_basic:

        Subgroup suspend-read-crc-pipe-c:
                incomplete -> PASS       (fi-cfl-s2)
fi-bdw-5557u     total:289  pass:268  dwarn:0   dfail:0   fail:0   skip:21  time:456s
fi-bdw-gvtdvm    total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:462s
fi-blb-e6850     total:289  pass:223  dwarn:1   dfail:0   fail:0   skip:65  time:383s
fi-bsw-n3050     total:289  pass:243  dwarn:0   dfail:0   fail:0   skip:46  time:543s
fi-bwr-2160      total:289  pass:183  dwarn:0   dfail:0   fail:0   skip:106 time:281s
fi-bxt-dsi       total:289  pass:259  dwarn:0   dfail:0   fail:0   skip:30  time:507s
fi-bxt-j4205     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:511s
fi-byt-j1900     total:289  pass:254  dwarn:0   dfail:0   fail:0   skip:35  time:507s
fi-byt-n2820     total:289  pass:250  dwarn:0   dfail:0   fail:0   skip:39  time:494s
fi-cfl-s2        total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:606s
fi-elk-e7500     total:289  pass:229  dwarn:0   dfail:0   fail:0   skip:60  time:440s
fi-gdg-551       total:289  pass:178  dwarn:1   dfail:0   fail:1   skip:109 time:267s
fi-glk-1         total:289  pass:261  dwarn:0   dfail:0   fail:0   skip:28  time:543s
fi-hsw-4770      total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:434s
fi-hsw-4770r     total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:442s
fi-ilk-650       total:289  pass:228  dwarn:0   dfail:0   fail:0   skip:61  time:428s
fi-ivb-3520m     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:485s
fi-ivb-3770      total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:464s
fi-pnv-d510      total:289  pass:222  dwarn:1   dfail:0   fail:0   skip:66  time:581s
fi-skl-6260u     total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:457s
fi-skl-6600u     total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:543s
fi-skl-6700hq    total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:566s
fi-skl-6700k     total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:521s
fi-skl-6770hq    total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:500s
fi-skl-gvtdvm    total:289  pass:266  dwarn:0   dfail:0   fail:0   skip:23  time:466s
fi-snb-2520m     total:289  pass:250  dwarn:0   dfail:0   fail:0   skip:39  time:561s
fi-snb-2600      total:289  pass:249  dwarn:0   dfail:0   fail:0   skip:40  time:426s
Blacklisted hosts:
fi-cnl-y         total:232  pass:207  dwarn:0   dfail:0   fail:0   skip:24 
fi-glk-dsi       total:289  pass:164  dwarn:0   dfail:10  fail:2   skip:113 time:420s
fi-kbl-7500u     total:289  pass:264  dwarn:1   dfail:0   fail:0   skip:24  time:487s
fi-kbl-7560u     total:289  pass:270  dwarn:0   dfail:0   fail:0   skip:19  time:534s
fi-kbl-7567u     total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:478s
fi-kbl-r         total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:534s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_538/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw

✓ Fi.CI.IGT: success for igt/kms_rotation_crc: Add horizontal flip subtest. (rev3)

In reply to Anusha Srivatsa
== Series Details ==

== Series Details ==

Series: igt/kms_rotation_crc: Add horizontal flip subtest. (rev3)
URL : https://patchwork.freedesktop.org/series/31407/
State : success

== Summary ==

Test kms_frontbuffer_tracking:

        Subgroup fbc-1p-offscren-pri-shrfb-draw-render:
                pass       -> FAIL       (shard-snb) fdo#101623 +1
Test gem_busy:
        Subgroup close-race:
                pass       -> FAIL       (shard-snb) fdo#103829
Test kms_setmode:
        Subgroup basic:
                fail       -> PASS       (shard-hsw) fdo#99912
Test perf:
        Subgroup polling:
                fail       -> PASS       (shard-hsw) fdo#102252
Test drv_module_reload:
        Subgroup basic-reload-inject:
                pass       -> DMESG-WARN (shard-snb) fdo#102707 +1
        Subgroup basic-reload:
                pass       -> DMESG-WARN (shard-snb) fdo#102848

fdo#101623 https://bugs.freedesktop.org/show_bug.cgi?id=101623
fdo#103829 https://bugs.freedesktop.org/show_bug.cgi?id=103829
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
fdo#102252 https://bugs.freedesktop.org/show_bug.cgi?id=102252
fdo#102707 https://bugs.freedesktop.org/show_bug.cgi?id=102707
fdo#102848 https://bugs.freedesktop.org/show_bug.cgi?id=102848

shard-hsw        total:2687 pass:1535 dwarn:2   dfail:0   fail:9   skip:1141 time:9553s
shard-snb        total:2687 pass:1308 dwarn:3   dfail:0   fail:15  skip:1361 time:8120s

Blacklisted hosts:
shard-apl total:2665 pass:1665 dwarn:1 dfail:0 fail:24 skip:974 time:13386s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_538/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw
In reply to Anusha Srivatsa
Quoted 382 lines · Anusha Srivatsa

From: Joseph Garvey <[email protected]>

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)

v3: (From Anusha)
- Correct the name of subtests in order to avoid duplication of names (Arek)

Cc Ville Syrjälä <[email protected]>
Cc Petri Latvala <[email protected]>
Cc Arkadiusz Hiler <[email protected]>
---
 lib/igt_kms.c            |   2 +-
 lib/igt_kms.h            |   5 ++
 tests/kms_rotation_crc.c | 198 +++++++++++++++++++++++++++++++++++++----------
 3 files changed, 164 insertions(+), 41 deletions(-)
lib/igt_kms.c +1 -1
index a572fc6..3034e44 100644
@@ -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:
lib/igt_kms.h +5 -0
index 8dc118c..b83a828 100644
@@ -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;
tests/kms_rotation_crc.c +143 -40
index 5aec8fa..9e13667 100644
@@ -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,21 @@ igt_main
 		igt_require_f(valid_tests, "no valid crtc/connector combinations found\n");

tests/kms_rotation_crc.c igt_main · line 842

Quoted 10 lines
tests/kms_rotation_crc.c +8 -0
 	}
 
+	for (reflect_x = reflect_x_subtests; reflect_x->tiling; reflect_x++) {
+		igt_subtest_f("primary-%s-reflect-x-%s%s",
+			      tiling_test_str(reflect_x->tiling),
+			      rot_test_str(reflect_x->rot),
+			      flip_test_str(reflect_x->flips)) {
+			igt_require(gen >= 10 ||
+				    (IS_CHERRYVIEW(data.devid) && reflect_x->rot == IGT_ROTATION_0
+				     && reflect_x->tiling == LOCAL_I915_FORMAT_MOD_X_TILED));

Bxt and glk are unable to do this?

Signature · 5 lines
Petri Latvala
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw
Quoted 428 lines

-----Original Message-----
From: Latvala, Petri
Sent: Wednesday, November 29, 2017 1:55 AM
To: Srivatsa, Anusha <[email protected]>
Cc: [email protected]; Joseph Garvey <[email protected]>; Ville Syrjälä <[email protected]>; Hiler, Arkadiusz <[email protected]>
Subject: Re: [PATCH i-g-t] igt/kms_rotation_crc: Add horizontal flip subtest.

Quoted 178 lines · Anusha Srivatsa

From: Joseph Garvey <[email protected]>

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)

v3: (From Anusha)
- Correct the name of subtests in order to avoid duplication of names (Arek)

Cc Ville Syrjälä <[email protected]>
Cc Petri Latvala <[email protected]>
Cc Arkadiusz Hiler <[email protected]>
---
 lib/igt_kms.c            |   2 +-
 lib/igt_kms.h            |   5 ++
 tests/kms_rotation_crc.c | 198
+++++++++++++++++++++++++++++++++++++----------
 3 files changed, 164 insertions(+), 41 deletions(-)
lib/igt_kms.c index a572fc6..3034e44 renamed from lib/igt_kms.c +0 -0

100644

lib/igt_kms.c +1 -1
@@ -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:
lib/igt_kms.h index 8dc118c..b83a828 renamed from lib/igt_kms.h +0 -0

100644

lib/igt_kms.h +6 -0
@@ -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;
tests/kms_rotation_crc.c index renamed from tests/kms_rotation_crc.c +0 -0

5aec8fa..9e13667 100644

tests/kms_rotation_crc.c +62 -25
@@ -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);
 }

tests/kms_rotation_crc.c static void remove_fbs(data_t *data) · line 185

Quoted 7 lines
tests/kms_rotation_crc.c +1 -0
@@ -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 @@

tests/kms_rotation_crc.c static void prepare_fbs(data_t *data, igt_output_t *output,

Quoted 8 lines

static void prepare_fbs(data_t *data, igt_output_t *output,

tests/kms_rotation_crc.c +1 -2
 	 * 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;

tests/kms_rotation_crc.c static void prepare_fbs(data_t *data, igt_output_t

Quoted 12 lines
tests/kms_rotation_crc.c +0 -4
 		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,

tests/kms_rotation_crc.c static void test_plane_rotation(data_t *data, int

Quoted 32 lines
tests/kms_rotation_crc.c +15 -1
 	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)

tests/kms_rotation_crc.c static void test_plane_rotation(data_t *data, int plane_type)

Quoted 9 lines
tests/kms_rotation_crc.c +3 -0
 		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

Quoted 2 lines

+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));

tests/kms_rotation_crc.c

Quoted 8 lines
tests/kms_rotation_crc.c +0 -3
 			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)

tests/kms_rotation_crc.c +1 -0
+			if (data->rotation & (IGT_ROTATION_90 |

IGT_ROTATION_270))

tests/kms_rotation_crc.c static void test_plane_rotation(data_t *data, int

Quoted 11 lines

igt_plane_set_size(plane, data->fb.height, data-
fb.width);

tests/kms_rotation_crc.c +2 -1
 			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)

Quoted 42 lines
tests/kms_rotation_crc.c +23 -0
 	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)

tests/kms_rotation_crc.c igt_main · line 716

Quoted 8 lines
tests/kms_rotation_crc.c +1 -1
@@ -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

tests/kms_rotation_crc.c igt_main

Quoted 12 lines

@@ igt_main

tests/kms_rotation_crc.c +8 -0
 		{ 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

},

tests/kms_rotation_crc.c igt_main

Quoted 3 lines
tests/kms_rotation_crc.c +3 -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

},

tests/kms_rotation_crc.c

Quoted 1 line
tests/kms_rotation_crc.c +1 -0
+		{ LOCAL_I915_FORMAT_MOD_Y_TILED, IGT_ROTATION_270, 0

},

tests/kms_rotation_crc.c igt_main

Quoted 3 lines
tests/kms_rotation_crc.c +3 -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

},

tests/kms_rotation_crc.c

Quoted 1 line
tests/kms_rotation_crc.c +1 -0
+		{ LOCAL_I915_FORMAT_MOD_Yf_TILED, IGT_ROTATION_270, 0

},

tests/kms_rotation_crc.c

Quoted 2 lines
tests/kms_rotation_crc.c +2 -0
+		{ LOCAL_I915_FORMAT_MOD_X_TILED, IGT_ROTATION_0, 1 },
+		{ LOCAL_I915_FORMAT_MOD_X_TILED, IGT_ROTATION_180, 1

},

tests/kms_rotation_crc.c igt_main

Quoted 3 lines
tests/kms_rotation_crc.c +3 -0
+		{ 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

},

tests/kms_rotation_crc.c

Quoted 1 line
tests/kms_rotation_crc.c +1 -0
+		{ LOCAL_I915_FORMAT_MOD_Y_TILED, IGT_ROTATION_270, 1

},

tests/kms_rotation_crc.c igt_main

Quoted 3 lines
tests/kms_rotation_crc.c +3 -0
+		{ 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

},

tests/kms_rotation_crc.c

Quoted 1 line
tests/kms_rotation_crc.c +1 -0
+		{ LOCAL_I915_FORMAT_MOD_Yf_TILED, IGT_ROTATION_270, 1

},

Quoted 34 lines
tests/kms_rotation_crc.c +7 -3
+		{ 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,21 @@
Quoted 2 lines

igt_main
igt_require_f(valid_tests, "no valid crtc/connector combinations

found\n");

tests/kms_rotation_crc.c

Quoted 11 lines
tests/kms_rotation_crc.c +7 -0
 	}
 
+	for (reflect_x = reflect_x_subtests; reflect_x->tiling; reflect_x++) {
+		igt_subtest_f("primary-%s-reflect-x-%s%s",
+			      tiling_test_str(reflect_x->tiling),
+			      rot_test_str(reflect_x->rot),
+			      flip_test_str(reflect_x->flips)) {
+			igt_require(gen >= 10 ||
+				    (IS_CHERRYVIEW(data.devid) && reflect_x-

rot == IGT_ROTATION_0

tests/kms_rotation_crc.c +1 -0
+				     && reflect_x->tiling ==

LOCAL_I915_FORMAT_MOD_X_TILED));

Quoted 1 line

Bxt and glk are unable to do this?

Yes, that is correct.

Anusha

Quoted 3 lines

--
Petri Latvala

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reviewed-by on v1 1/1
#5 lore raw
In reply to Anusha Srivatsa
Quoted 15 lines · Anusha Srivatsa

From: Joseph Garvey <[email protected]>

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)

v3: (From Anusha)
- Correct the name of subtests in order to avoid duplication of names (Arek)

Quoted 5 lines
Cc Ville Syrjälä <[email protected]>
Cc Petri Latvala <[email protected]>
Cc Arkadiusz Hiler <[email protected]>

And merged, thanks.

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#6 lore raw
In reply to Anusha Srivatsa
Quoted 15 lines · Anusha Srivatsa

From: Joseph Garvey <[email protected]>

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)

v3: (From Anusha)
- Correct the name of subtests in order to avoid duplication of names (Arek)

Quoted 5 lines
Cc Ville Syrjälä <[email protected]>
Cc Petri Latvala <[email protected]>
Cc Arkadiusz Hiler <[email protected]>

I didn't see this patch fly by originally, but now Marta pointed out that this skips everywhere. We need to rework it.

General principle is that in kms tests we should _not_ have any platform/feature checks encoded in the test. Instead, the testcase should check properties to figure out whether something should work or not.

Quoted 214 lines
---
 lib/igt_kms.c            |   2 +-
 lib/igt_kms.h            |   5 ++
 tests/kms_rotation_crc.c | 198 +++++++++++++++++++++++++++++++++++++----------
 3 files changed, 164 insertions(+), 41 deletions(-)
lib/igt_kms.c +1 -1
index a572fc6..3034e44 100644
@@ -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:
lib/igt_kms.h +5 -0
index 8dc118c..b83a828 100644
@@ -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;
tests/kms_rotation_crc.c +78 -32
index 5aec8fa..9e13667 100644
@@ -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;

tests/kms_rotation_crc.c static void test_plane_rotation(data_t *data, int plane_type) · line 398

Quoted 5 lines
tests/kms_rotation_crc.c +2 -0
@@ -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;

This check here must be removed.

Quoted 143 lines
tests/kms_rotation_crc.c +63 -8
+
                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,21 @@ igt_main
                igt_require_f(valid_tests, "no valid crtc/connector combinations found\n");

tests/kms_rotation_crc.c igt_main · line 842

Quoted 10 lines
tests/kms_rotation_crc.c +8 -0
        }
 
+       for (reflect_x = reflect_x_subtests; reflect_x->tiling; reflect_x++) {
+               igt_subtest_f("primary-%s-reflect-x-%s%s",
+                             tiling_test_str(reflect_x->tiling),
+                             rot_test_str(reflect_x->rot),
+                             flip_test_str(reflect_x->flips)) {
+                       igt_require(gen >= 10 ||
+                                   (IS_CHERRYVIEW(data.devid) && reflect_x->rot == IGT_ROTATION_0
+                                    && reflect_x->tiling == LOCAL_I915_FORMAT_MOD_X_TILED));

This check here also must be removed and instead we need to check whether the rotation property supports the combination of rotation/flipping that we want to test.

Anusha, can you pls follow up with this?

Cc'ing Luis too to keep track of this.

Thanks, Daniel

Quoted 17 lines
tests/kms_rotation_crc.c +7 -1
+                       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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#7 lore raw
Quoted 23 lines · Daniel Vetter
Quoted 15 lines · Anusha Srivatsa

From: Joseph Garvey <[email protected]>

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)

v3: (From Anusha)
- Correct the name of subtests in order to avoid duplication of names (Arek)

Quoted 5 lines
Cc Ville Syrjälä <[email protected]>
Cc Petri Latvala <[email protected]>
Cc Arkadiusz Hiler <[email protected]>
Quoted 7 lines

I didn't see this patch fly by originally, but now Marta pointed out that this skips everywhere. We need to rework it.

General principle is that in kms tests we should _not_ have any platform/feature checks encoded in the test. Instead, the testcase should check properties to figure out whether something should work or not.

I fully agree.

But oops... I just merged the cnl patch while I had swear that I'd just merge when the test case was done. :/

Quoted 401 lines
Quoted 216 lines

---
 lib/igt_kms.c            |   2 +-
 lib/igt_kms.h            |   5 ++
 tests/kms_rotation_crc.c | 198 +++++++++++++++++++++++++++++++++++++----------
 3 files changed, 164 insertions(+), 41 deletions(-)
lib/igt_kms.c +1 -1
index a572fc6..3034e44 100644
@@ -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:
lib/igt_kms.h +5 -0
index 8dc118c..b83a828 100644
@@ -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;
tests/kms_rotation_crc.c +78 -32
index 5aec8fa..9e13667 100644
@@ -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;

tests/kms_rotation_crc.c static void test_plane_rotation(data_t *data, int plane_type) · line 398

Quoted 5 lines
tests/kms_rotation_crc.c +2 -0
@@ -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;

This check here must be removed.

Quoted 143 lines
tests/kms_rotation_crc.c +63 -8
+
                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,21 @@ igt_main
                igt_require_f(valid_tests, "no valid crtc/connector combinations found\n");

tests/kms_rotation_crc.c igt_main · line 842

Quoted 10 lines
tests/kms_rotation_crc.c +8 -0
        }
 
+       for (reflect_x = reflect_x_subtests; reflect_x->tiling; reflect_x++) {
+               igt_subtest_f("primary-%s-reflect-x-%s%s",
+                             tiling_test_str(reflect_x->tiling),
+                             rot_test_str(reflect_x->rot),
+                             flip_test_str(reflect_x->flips)) {
+                       igt_require(gen >= 10 ||
+                                   (IS_CHERRYVIEW(data.devid) && reflect_x->rot == IGT_ROTATION_0
+                                    && reflect_x->tiling == LOCAL_I915_FORMAT_MOD_X_TILED));

This check here also must be removed and instead we need to check whether the rotation property supports the combination of rotation/flipping that we want to test.

Anusha, can you pls follow up with this?

Cc'ing Luis too to keep track of this.

Thanks, Daniel

Quoted 13 lines
tests/kms_rotation_crc.c +7 -1
+                       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

Quoted 15 lines
Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#8 lore raw
In reply to Daniel Vetter
Quoted 268 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Thursday, December 14, 2017 2:14 AM
To: Srivatsa, Anusha <[email protected]>; Strano, Luis <[email protected]>; Latvala, Petri <[email protected]>; Lofstedt, Marta <[email protected]>; Saarinen, Jani <[email protected]>
Cc: intel-gfx <[email protected]>; Joseph Garvey <[email protected]>
Subject: Re: [Intel-gfx] [PATCH i-g-t] igt/kms_rotation_crc: Add horizontal flip subtest.

Quoted 15 lines · Anusha Srivatsa

From: Joseph Garvey <[email protected]>

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)

v3: (From Anusha)
- Correct the name of subtests in order to avoid duplication of names (Arek)

Quoted 5 lines
Cc Ville Syrjälä <[email protected]>
Cc Petri Latvala <[email protected]>
Cc Arkadiusz Hiler <[email protected]>

I didn't see this patch fly by originally, but now Marta pointed out that this skips everywhere. We need to rework it.

General principle is that in kms tests we should _not_ have any platform/feature checks encoded in the test. Instead, the testcase should check properties to figure out whether something should work or not.

Quoted 159 lines
---
 lib/igt_kms.c            |   2 +-
 lib/igt_kms.h            |   5 ++
 tests/kms_rotation_crc.c | 198
+++++++++++++++++++++++++++++++++++++----------
 3 files changed, 164 insertions(+), 41 deletions(-)
lib/igt_kms.c index a572fc6..3034e44 renamed from lib/igt_kms.c +0 -0

100644

lib/igt_kms.c +1 -1
@@ -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:
lib/igt_kms.h index 8dc118c..b83a828 renamed from lib/igt_kms.h +0 -0

100644

lib/igt_kms.h +6 -0
@@ -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;
tests/kms_rotation_crc.c index renamed from tests/kms_rotation_crc.c +0 -0

5aec8fa..9e13667 100644

tests/kms_rotation_crc.c +51 -0
@@ -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;
tests/kms_rotation_crc.c +12 -25
+       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);
 }

tests/kms_rotation_crc.c static void remove_fbs(data_t *data)

Quoted 8 lines
tests/kms_rotation_crc.c +1 -1
@@ -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,

tests/kms_rotation_crc.c static void prepare_fbs(data_t *data, igt_output_t

Quoted 20 lines

* For 90/270, we will use create smaller fb so that the rotated
* frame can fit in
*/

tests/kms_rotation_crc.c +1 -2
-       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);
        }
tests/kms_rotation_crc.c +0 -4
-       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,

tests/kms_rotation_crc.c static void test_plane_rotation(data_t *data, int

Quoted 33 lines
tests/kms_rotation_crc.c +16 -1
        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)

Quoted 7 lines

tests/kms_rotation_crc.c static void test_plane_rotation(data_t *data, int plane_type) · line 398

Quoted 5 lines
tests/kms_rotation_crc.c +2 -0
                igt_plane_t *plane;
                int i;
 
+               if (IS_CHERRYVIEW(data->devid) && pipe != PIPE_B)
+                       continue;

This check here must be removed.

OK.

Quoted 161 lines

tests/kms_rotation_crc.c static void test_plane_rotation(data_t *data, int

Quoted 5 lines
tests/kms_rotation_crc.c +1 -0
+
                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)

tests/kms_rotation_crc.c static void test_plane_rotation(data_t *data, int · line 418

Quoted 1 line
tests/kms_rotation_crc.c +0 -0
                        igt_debug("Testing case %i on pipe %s\n", i,

kmstest_pipe_name(pipe));

tests/kms_rotation_crc.c static void test_plane_rotation(data_t *data, int plane_type)

Quoted 6 lines
tests/kms_rotation_crc.c +0 -3
                        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)

tests/kms_rotation_crc.c static void test_plane_rotation(data_t *data, int

Quoted 13 lines
tests/kms_rotation_crc.c +4 -1
+                       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)

Quoted 108 lines
tests/kms_rotation_crc.c +9 -0
        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) {
tests/kms_rotation_crc.c +49 -4
+       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;

tests/kms_rotation_crc.c igt_main

Quoted 10 lines
tests/kms_rotation_crc.c +3 -1
                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,21 @@ igt_main
                igt_require_f(valid_tests, "no valid crtc/connector combinations

found\n");

tests/kms_rotation_crc.c igt_main

Quoted 9 lines
        }
tests/kms_rotation_crc.c +7 -0
+       for (reflect_x = reflect_x_subtests; reflect_x->tiling; reflect_x++) {
+               igt_subtest_f("primary-%s-reflect-x-%s%s",
+                             tiling_test_str(reflect_x->tiling),
+                             rot_test_str(reflect_x->rot),
+                             flip_test_str(reflect_x->flips)) {
+                       igt_require(gen >= 10 ||
+                                   (IS_CHERRYVIEW(data.devid) && reflect_x->rot ==

IGT_ROTATION_0

Quoted 2 lines

+ && reflect_x->tiling ==
+ LOCAL_I915_FORMAT_MOD_X_TILED));

Quoted 7 lines

This check here also must be removed and instead we need to check whether the rotation property supports the combination of rotation/flipping that we want to test.

Anusha, can you pls follow up with this?

Cc'ing Luis too to keep track of this.

Sure Daniel, Thanks a lot for your feedback.
Will roll up a new version of this.

Anusha

Quoted 22 lines

Thanks, Daniel

Quoted 13 lines
tests/kms_rotation_crc.c +7 -1
+                       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

Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Quoted 4 lines

--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#9 lore raw
Quoted 441 lines · Anusha
Quoted 268 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Thursday, December 14, 2017 2:14 AM
To: Srivatsa, Anusha <[email protected]>; Strano, Luis <[email protected]>; Latvala, Petri <[email protected]>; Lofstedt, Marta <[email protected]>; Saarinen, Jani <[email protected]>
Cc: intel-gfx <[email protected]>; Joseph Garvey <[email protected]>
Subject: Re: [Intel-gfx] [PATCH i-g-t] igt/kms_rotation_crc: Add horizontal flip subtest.

Quoted 15 lines · Anusha Srivatsa

From: Joseph Garvey <[email protected]>

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)

v3: (From Anusha)
- Correct the name of subtests in order to avoid duplication of names (Arek)

Quoted 5 lines
Cc Ville Syrjälä <[email protected]>
Cc Petri Latvala <[email protected]>
Cc Arkadiusz Hiler <[email protected]>

I didn't see this patch fly by originally, but now Marta pointed out that this skips everywhere. We need to rework it.

General principle is that in kms tests we should _not_ have any platform/feature checks encoded in the test. Instead, the testcase should check properties to figure out whether something should work or not.

Quoted 159 lines
---
 lib/igt_kms.c            |   2 +-
 lib/igt_kms.h            |   5 ++
 tests/kms_rotation_crc.c | 198
+++++++++++++++++++++++++++++++++++++----------
 3 files changed, 164 insertions(+), 41 deletions(-)
lib/igt_kms.c index a572fc6..3034e44 renamed from lib/igt_kms.c +0 -0

100644

lib/igt_kms.c +1 -1
@@ -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:
lib/igt_kms.h index 8dc118c..b83a828 renamed from lib/igt_kms.h +0 -0

100644

lib/igt_kms.h +6 -0
@@ -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;
tests/kms_rotation_crc.c index renamed from tests/kms_rotation_crc.c +0 -0

5aec8fa..9e13667 100644

tests/kms_rotation_crc.c +51 -0
@@ -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;
tests/kms_rotation_crc.c +12 -25
+       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);
 }

tests/kms_rotation_crc.c static void remove_fbs(data_t *data)

Quoted 8 lines
tests/kms_rotation_crc.c +1 -1
@@ -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,

tests/kms_rotation_crc.c static void prepare_fbs(data_t *data, igt_output_t

Quoted 20 lines

* For 90/270, we will use create smaller fb so that the rotated
* frame can fit in
*/

tests/kms_rotation_crc.c +1 -2
-       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);
        }
tests/kms_rotation_crc.c +0 -4
-       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,

tests/kms_rotation_crc.c static void test_plane_rotation(data_t *data, int

Quoted 33 lines
tests/kms_rotation_crc.c +16 -1
        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)

Quoted 7 lines

tests/kms_rotation_crc.c static void test_plane_rotation(data_t *data, int plane_type) · line 398

Quoted 5 lines
tests/kms_rotation_crc.c +2 -0
                igt_plane_t *plane;
                int i;
 
+               if (IS_CHERRYVIEW(data->devid) && pipe != PIPE_B)
+                       continue;

This check here must be removed.

OK.

Quoted 165 lines

tests/kms_rotation_crc.c static void test_plane_rotation(data_t *data, int

Quoted 5 lines
tests/kms_rotation_crc.c +1 -0
+
                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)

tests/kms_rotation_crc.c static void test_plane_rotation(data_t *data, int · line 418

Quoted 1 line
tests/kms_rotation_crc.c +0 -0
                        igt_debug("Testing case %i on pipe %s\n", i,

kmstest_pipe_name(pipe));

tests/kms_rotation_crc.c static void test_plane_rotation(data_t *data, int plane_type)

Quoted 6 lines
tests/kms_rotation_crc.c +0 -3
                        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)

tests/kms_rotation_crc.c static void test_plane_rotation(data_t *data, int

Quoted 13 lines
tests/kms_rotation_crc.c +4 -1
+                       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)

Quoted 108 lines
tests/kms_rotation_crc.c +9 -0
        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) {
tests/kms_rotation_crc.c +49 -4
+       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;

tests/kms_rotation_crc.c igt_main

Quoted 10 lines
tests/kms_rotation_crc.c +3 -1
                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,21 @@ igt_main
                igt_require_f(valid_tests, "no valid crtc/connector combinations

found\n");

tests/kms_rotation_crc.c igt_main

Quoted 9 lines
        }
tests/kms_rotation_crc.c +7 -0
+       for (reflect_x = reflect_x_subtests; reflect_x->tiling; reflect_x++) {
+               igt_subtest_f("primary-%s-reflect-x-%s%s",
+                             tiling_test_str(reflect_x->tiling),
+                             rot_test_str(reflect_x->rot),
+                             flip_test_str(reflect_x->flips)) {
+                       igt_require(gen >= 10 ||
+                                   (IS_CHERRYVIEW(data.devid) && reflect_x->rot ==

IGT_ROTATION_0

Quoted 2 lines

+ && reflect_x->tiling ==
+ LOCAL_I915_FORMAT_MOD_X_TILED));

This check here also must be removed and instead we need to check whether the rotation property supports the combination of rotation/flipping that we want to test.

Quoted 5 lines
Quoted 3 lines

Anusha, can you pls follow up with this?

Cc'ing Luis too to keep track of this.

Sure Daniel, Thanks a lot for your feedback.
Will roll up a new version of this.

It is already merged so a patch to fix is
needed instead of a new version.

Quoted 24 lines

Anusha

Quoted 22 lines

Thanks, Daniel

Quoted 17 lines
tests/kms_rotation_crc.c +7 -1
+                       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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Quoted 8 lines
Quoted 4 lines

--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#10 lore raw
Quoted 13 lines

-----Original Message-----
From: Vivi, Rodrigo
Sent: Tuesday, December 19, 2017 1:50 PM
To: Srivatsa, Anusha <[email protected]>
Cc: Daniel Vetter <[email protected]>; Strano, Luis <[email protected]>; Latvala, Petri <[email protected]>; Lofstedt, Marta <[email protected]>; Saarinen, Jani <[email protected]>; intel-gfx <[email protected]>; Joseph Garvey <[email protected]>
Subject: Re: [Intel-gfx] [PATCH i-g-t] igt/kms_rotation_crc: Add horizontal flip subtest.

Quoted 457 lines
Quoted 456 lines · Anusha
Quoted 278 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Thursday, December 14, 2017 2:14 AM
To: Srivatsa, Anusha <[email protected]>; Strano, Luis <[email protected]>; Latvala, Petri <[email protected]>; Lofstedt, Marta <[email protected]>; Saarinen, Jani <[email protected]>
Cc: intel-gfx <[email protected]>; Joseph Garvey <[email protected]>
Subject: Re: [Intel-gfx] [PATCH i-g-t] igt/kms_rotation_crc: Add horizontal flip subtest.

Quoted 16 lines · Anusha Srivatsa

From: Joseph Garvey <[email protected]>

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)

v3: (From Anusha)
- Correct the name of subtests in order to avoid duplication of names
(Arek)

Quoted 5 lines
Cc Ville Syrjälä <[email protected]>
Cc Petri Latvala <[email protected]>
Cc Arkadiusz Hiler <[email protected]>

I didn't see this patch fly by originally, but now Marta pointed out that this skips everywhere. We need to rework it.

General principle is that in kms tests we should _not_ have any platform/feature checks encoded in the test. Instead, the testcase should check properties to figure out whether something should work or not.

Quoted 168 lines
---
 lib/igt_kms.c            |   2 +-
 lib/igt_kms.h            |   5 ++
 tests/kms_rotation_crc.c | 198
+++++++++++++++++++++++++++++++++++++----------
 3 files changed, 164 insertions(+), 41 deletions(-)
lib/igt_kms.c index a572fc6..3034e44 renamed from lib/igt_kms.c +0 -0

100644

lib/igt_kms.c +1 -1
@@ -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:
lib/igt_kms.h index 8dc118c..b83a828 renamed from lib/igt_kms.h +0 -0

100644

lib/igt_kms.h +6 -0
@@ -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;
tests/kms_rotation_crc.c +0 -0

index
5aec8fa..9e13667 100644

tests/kms_rotation_crc.c +51 -0
@@ -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;
tests/kms_rotation_crc.c +13 -26
+       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,
Quoted 1 line

igt_output_t

*output,

Quoted 21 lines

* For 90/270, we will use create smaller fb so that the rotated
* frame can fit in
*/

tests/kms_rotation_crc.c +2 -2
-       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);
        }
tests/kms_rotation_crc.c +0 -4
-       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,
Quoted 1 line

igt_output_t

*output,

Quoted 35 lines
        igt_pipe_crc_collect_crc(data->pipe_crc, &data->ref_crc);

        /*
tests/kms_rotation_crc.c +4 -0
+        * Prepare the non-rotated reference fb.
+        */
+       igt_create_fb(data->gfx_fd, ref_w, ref_h, pixel_format,
+ tiling, &data-

fb_unrotated);

tests/kms_rotation_crc.c +14 -1
+       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,
Quoted 1 line

int

plane_type)

Quoted 7 lines

tests/kms_rotation_crc.c static void test_plane_rotation(data_t *data, int plane_type) · line 398

Quoted 5 lines
                igt_plane_t *plane;
                int i;
tests/kms_rotation_crc.c +2 -0
+               if (IS_CHERRYVIEW(data->devid) && pipe != PIPE_B)
+                       continue;

This check here must be removed.

OK.

Quoted 170 lines
Quoted 6 lines

+
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)

Quoted 2 lines

igt_debug("Testing case %i on pipe %s\n",
i,

kmstest_pipe_name(pipe));

tests/kms_rotation_crc.c static void test_plane_rotation(data_t *data, int plane_type)

Quoted 6 lines
                        prepare_fbs(data, output, plane, i);
tests/kms_rotation_crc.c +0 -3
-                       igt_display_commit2(display, commit);
-
                        igt_plane_set_rotation(plane, data->rotation);
-                       if (data->rotation == IGT_ROTATION_90 || data->rotation ==

IGT_ROTATION_270)

Quoted 14 lines

+ 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);
tests/kms_rotation_crc.c +3 -1
-                       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,
Quoted 1 line

int

plane_type)

Quoted 118 lines

igt_require_f(valid_tests, "no valid crtc/connector
combinations found\n"); }

tests/kms_rotation_crc.c +9 -1
+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) {
tests/kms_rotation_crc.c +52 -5
+       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,21 @@ igt_main
                igt_require_f(valid_tests, "no valid crtc/connector
Quoted 1 line

combinations

found\n");

tests/kms_rotation_crc.c igt_main

Quoted 10 lines
        }
tests/kms_rotation_crc.c +8 -0
+       for (reflect_x = reflect_x_subtests; reflect_x->tiling; reflect_x++) {
+               igt_subtest_f("primary-%s-reflect-x-%s%s",
+                             tiling_test_str(reflect_x->tiling),
+                             rot_test_str(reflect_x->rot),
+                             flip_test_str(reflect_x->flips)) {
+                       igt_require(gen >= 10 ||
+                                   (IS_CHERRYVIEW(data.devid) &&
+ reflect_x->rot ==

IGT_ROTATION_0

Quoted 2 lines

+ && reflect_x->tiling ==
+ LOCAL_I915_FORMAT_MOD_X_TILED));

This check here also must be removed and instead we need to check whether the rotation property supports the combination of rotation/flipping that we want to test.

Daniel, Rodrigo,

Will using igt_plane_get_prop() be a good approach?
All tests are still failing with igt_plane_get_prop() used in igt_require....

Anusha

Quoted 40 lines
Quoted 5 lines
Quoted 3 lines

Anusha, can you pls follow up with this?

Cc'ing Luis too to keep track of this.

Sure Daniel, Thanks a lot for your feedback.
Will roll up a new version of this.

It is already merged so a patch to fix is needed instead of a new version.

Quoted 32 lines

Anusha

Quoted 22 lines

Thanks, Daniel

Quoted 13 lines
tests/kms_rotation_crc.c +7 -1
+                       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

Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Quoted 4 lines

--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx