All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t v2 0/4] kms_plane: Add clipping subtests
@ 2018-03-06 16:52 Imre Deak
  2018-03-06 16:52 ` [igt-dev] [PATCH v2 1/4] kms_plane: Remove redundant modeset after CRC capture Imre Deak
                   ` (6 more replies)
  0 siblings, 7 replies; 17+ messages in thread
From: Imre Deak @ 2018-03-06 16:52 UTC (permalink / raw)
  To: igt-dev; +Cc: Juha-Pekka Heikkilä

This is v2 of [1], fixing the issues reported by Arek and CI. Besides
the changes described in patch 4, there is also an FBC workaround
applied now in kernel. Without the WA the test cases using the primary
plane (with FBC) could trigger FIFO underflow errors.

Note that the subtest takes ~40 seconds to run on a single pipe.

[1]
https://lists.freedesktop.org/archives/igt-dev/2018-February/000523.html

Cc: Mika Kahola <mika.kahola@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Juha-Pekka Heikkilä <juha-pekka.heikkila@intel.com>
Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>

Imre Deak (4):
  kms_plane: Remove redundant modeset after CRC capture
  lib: Export helpers to get rotation/tiling strings
  kms_plane: Split helpers creating reference FB and capturing CRC
  kms_plane: Add clipping subtests

 lib/igt_fb.c      |  23 +++
 lib/igt_fb.h      |   1 +
 lib/igt_kms.c     |  11 +-
 lib/igt_kms.h     |   1 +
 tests/kms_plane.c | 502 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 5 files changed, 517 insertions(+), 21 deletions(-)

-- 
2.13.2

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [igt-dev] [PATCH v2 1/4] kms_plane: Remove redundant modeset after CRC capture
  2018-03-06 16:52 [igt-dev] [PATCH i-g-t v2 0/4] kms_plane: Add clipping subtests Imre Deak
@ 2018-03-06 16:52 ` Imre Deak
  2018-09-05 16:27   ` [igt-dev] [PATCH i-g-t v3 0/5] kms_plane: Add clipping subtests Gwan-gyeong Mun
  2018-03-06 16:52 ` [igt-dev] [PATCH v2 2/4] lib: Export helpers to get rotation/tiling strings Imre Deak
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: Imre Deak @ 2018-03-06 16:52 UTC (permalink / raw)
  To: igt-dev

The null modeset after capturing the CRC is redundant; detaching the FB
from the plane is enough for the next modeset to work properly. This
speed things up especially on slow panels.

Signed-off-by: Imre Deak <imre.deak@intel.com>
Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
---
 tests/kms_plane.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tests/kms_plane.c b/tests/kms_plane.c
index 23173b96..1d1bc198 100644
--- a/tests/kms_plane.c
+++ b/tests/kms_plane.c
@@ -88,7 +88,6 @@ test_grab_crc(data_t *data, igt_output_t *output, enum pipe pipe,
 	igt_pipe_crc_collect_crc(data->pipe_crc, crc);
 
 	igt_plane_set_fb(primary, NULL);
-	igt_display_commit(&data->display);
 
 	igt_remove_fb(data->drm_fd, &fb);
 
-- 
2.13.2

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [igt-dev] [PATCH v2 2/4] lib: Export helpers to get rotation/tiling strings
  2018-03-06 16:52 [igt-dev] [PATCH i-g-t v2 0/4] kms_plane: Add clipping subtests Imre Deak
  2018-03-06 16:52 ` [igt-dev] [PATCH v2 1/4] kms_plane: Remove redundant modeset after CRC capture Imre Deak
@ 2018-03-06 16:52 ` Imre Deak
  2018-03-06 16:52 ` [igt-dev] [PATCH v2 3/4] kms_plane: Split helpers creating reference FB and capturing CRC Imre Deak
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 17+ messages in thread
From: Imre Deak @ 2018-03-06 16:52 UTC (permalink / raw)
  To: igt-dev

This is needed for the next patch for some debug prints.

Signed-off-by: Imre Deak <imre.deak@intel.com>
Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
---
 lib/igt_fb.c  | 23 +++++++++++++++++++++++
 lib/igt_fb.h  |  1 +
 lib/igt_kms.c | 11 +++++++++--
 lib/igt_kms.h |  1 +
 4 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 7404ba7c..f3ff1db4 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -1705,3 +1705,26 @@ bool igt_fb_supported_format(uint32_t drm_format)
 
 	return false;
 }
+
+/**
+ * igt_tiling_str:
+ * @tiling: tiling ID
+ *
+ * Returns:
+ * Human-readable tiling string for @tiling.
+ */
+const char *igt_tiling_str(uint64_t tiling)
+{
+	switch (tiling) {
+	case LOCAL_DRM_FORMAT_MOD_NONE:
+		return "linear";
+	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:
+		return "N/A";
+	}
+}
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index 023b069d..481fe107 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -163,6 +163,7 @@ uint32_t igt_bpp_depth_to_drm_format(int bpp, int depth);
 uint32_t igt_drm_format_to_bpp(uint32_t drm_format);
 const char *igt_format_str(uint32_t drm_format);
 bool igt_fb_supported_format(uint32_t drm_format);
+const char *igt_tiling_str(uint64_t tiling);
 
 #endif /* __IGT_FB_H__ */
 
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 022abfe7..1fd15453 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -3550,7 +3550,14 @@ void igt_fb_set_size(struct igt_fb *fb, igt_plane_t *plane,
 	igt_plane_set_prop_value(plane, IGT_PLANE_SRC_H, IGT_FIXED(h, 0));
 }
 
-static const char *rotation_name(igt_rotation_t rotation)
+/**
+ * igt_rotation_degrees_str:
+ * @rotation: rotation degrees/reflect mask
+ *
+ * Returns:
+ * Human-readable string for the rotation degrees part in @rotation.
+ */
+const char *igt_rotation_degrees_str(igt_rotation_t rotation)
 {
 	switch (rotation & IGT_ROTATION_MASK) {
 	case IGT_ROTATION_0:
@@ -3582,7 +3589,7 @@ void igt_plane_set_rotation(igt_plane_t *plane, igt_rotation_t rotation)
 
 	LOG(display, "%s.%d: plane_set_rotation(%s)\n",
 	    kmstest_pipe_name(pipe->pipe),
-	    plane->index, rotation_name(rotation));
+	    plane->index, igt_rotation_degrees_str(rotation));
 
 	igt_plane_set_prop_value(plane, IGT_PLANE_ROTATION, rotation);
 }
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 1c46186e..40a79338 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -389,6 +389,7 @@ void igt_plane_set_fence_fd(igt_plane_t *plane, int fence_fd);
 void igt_plane_set_position(igt_plane_t *plane, int x, int y);
 void igt_plane_set_size(igt_plane_t *plane, int w, int h);
 void igt_plane_set_rotation(igt_plane_t *plane, igt_rotation_t rotation);
+const char *igt_rotation_degrees_str(igt_rotation_t rotation);
 void igt_fb_set_position(struct igt_fb *fb, igt_plane_t *plane,
 	uint32_t x, uint32_t y);
 void igt_fb_set_size(struct igt_fb *fb, igt_plane_t *plane,
-- 
2.13.2

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [igt-dev] [PATCH v2 3/4] kms_plane: Split helpers creating reference FB and capturing CRC
  2018-03-06 16:52 [igt-dev] [PATCH i-g-t v2 0/4] kms_plane: Add clipping subtests Imre Deak
  2018-03-06 16:52 ` [igt-dev] [PATCH v2 1/4] kms_plane: Remove redundant modeset after CRC capture Imre Deak
  2018-03-06 16:52 ` [igt-dev] [PATCH v2 2/4] lib: Export helpers to get rotation/tiling strings Imre Deak
@ 2018-03-06 16:52 ` Imre Deak
  2018-03-06 16:52 ` [igt-dev] [PATCH v2 4/4] kms_plane: Add clipping subtests Imre Deak
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 17+ messages in thread
From: Imre Deak @ 2018-03-06 16:52 UTC (permalink / raw)
  To: igt-dev

Split creating a reference FB and capturing the CRC for it into separate
functions, so in a follow-up patch we can reuse the CRC capture function
for a reference FB created in a different way.

Signed-off-by: Imre Deak <imre.deak@intel.com>
Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
---
 tests/kms_plane.c | 50 ++++++++++++++++++++++++++++++++------------------
 1 file changed, 32 insertions(+), 18 deletions(-)

diff --git a/tests/kms_plane.c b/tests/kms_plane.c
index 1d1bc198..5bd3249a 100644
--- a/tests/kms_plane.c
+++ b/tests/kms_plane.c
@@ -61,11 +61,9 @@ static void test_fini(data_t *data)
 }
 
 static void
-test_grab_crc(data_t *data, igt_output_t *output, enum pipe pipe,
-	      color_t *fb_color, igt_crc_t *crc /* out */)
+test_grab_crc_for_fb(data_t *data, igt_output_t *output, enum pipe pipe,
+		     igt_fb_t *fb, igt_crc_t *crc /* out */)
 {
-	struct igt_fb fb;
-	drmModeModeInfo *mode;
 	igt_plane_t *primary;
 	char *crc_str;
 	int ret;
@@ -74,13 +72,7 @@ test_grab_crc(data_t *data, igt_output_t *output, enum pipe pipe,
 
 	primary = igt_output_get_plane(output, 0);
 
-	mode = igt_output_get_mode(output);
-	igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay,
-			    DRM_FORMAT_XRGB8888,
-			    LOCAL_DRM_FORMAT_MOD_NONE,
-			    fb_color->red, fb_color->green, fb_color->blue,
-			    &fb);
-	igt_plane_set_fb(primary, &fb);
+	igt_plane_set_fb(primary, fb);
 
 	ret = igt_display_try_commit2(&data->display, COMMIT_LEGACY);
 	igt_skip_on(ret != 0);
@@ -89,14 +81,24 @@ test_grab_crc(data_t *data, igt_output_t *output, enum pipe pipe,
 
 	igt_plane_set_fb(primary, NULL);
 
-	igt_remove_fb(data->drm_fd, &fb);
-
 	crc_str = igt_crc_to_string(crc);
-	igt_debug("CRC for a (%.02f,%.02f,%.02f) fb: %s\n", fb_color->red,
-		  fb_color->green, fb_color->blue, crc_str);
+	igt_debug("CRC for fb: %s\n", crc_str);
 	free(crc_str);
 }
 
+static void
+test_create_fb_for_output(data_t *data, igt_output_t *output, color_t *fb_color,
+			  igt_fb_t *fb)
+{
+	drmModeModeInfo *mode = igt_output_get_mode(output);
+
+	igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay,
+			    DRM_FORMAT_XRGB8888,
+			    LOCAL_DRM_FORMAT_MOD_NONE,
+			    fb_color->red, fb_color->green, fb_color->blue,
+			    fb);
+}
+
 /*
  * Plane position test.
  *   - We start by grabbing a reference CRC of a full green fb being scanned
@@ -222,11 +224,15 @@ test_plane_position(data_t *data, enum pipe pipe, unsigned int flags)
 
 	for_each_valid_output_on_pipe(&data->display, pipe, output) {
 		int n_planes = data->display.pipes[pipe].n_planes;
+		igt_fb_t reference_fb;
 		igt_crc_t reference_crc;
 
 		test_init(data, pipe);
 
-		test_grab_crc(data, output, pipe, &green, &reference_crc);
+		test_create_fb_for_output(data, output, &green, &reference_fb);
+		test_grab_crc_for_fb(data, output, pipe, &reference_fb,
+				     &reference_crc);
+		igt_remove_fb(data->drm_fd, &reference_fb);
 
 		for (int plane = 1; plane < n_planes; plane++)
 			test_plane_position_with_output(data, pipe, plane,
@@ -343,13 +349,21 @@ test_plane_panning(data_t *data, enum pipe pipe, unsigned int flags)
 
 	for_each_valid_output_on_pipe(&data->display, pipe, output) {
 		int n_planes = data->display.pipes[pipe].n_planes;
+		igt_fb_t red_fb;
+		igt_fb_t blue_fb;
 		igt_crc_t red_crc;
 		igt_crc_t blue_crc;
 
 		test_init(data, pipe);
 
-		test_grab_crc(data, output, pipe, &red, &red_crc);
-		test_grab_crc(data, output, pipe, &blue, &blue_crc);
+		test_create_fb_for_output(data, output, &red, &red_fb);
+		test_create_fb_for_output(data, output, &blue, &blue_fb);
+
+		test_grab_crc_for_fb(data, output, pipe, &red_fb, &red_crc);
+		test_grab_crc_for_fb(data, output, pipe, &blue_fb, &blue_crc);
+
+		igt_remove_fb(data->drm_fd, &blue_fb);
+		igt_remove_fb(data->drm_fd, &red_fb);
 
 		for (int plane = 1; plane < n_planes; plane++)
 			test_plane_panning_with_output(data, pipe, plane,
-- 
2.13.2

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [igt-dev] [PATCH v2 4/4] kms_plane: Add clipping subtests
  2018-03-06 16:52 [igt-dev] [PATCH i-g-t v2 0/4] kms_plane: Add clipping subtests Imre Deak
                   ` (2 preceding siblings ...)
  2018-03-06 16:52 ` [igt-dev] [PATCH v2 3/4] kms_plane: Split helpers creating reference FB and capturing CRC Imre Deak
@ 2018-03-06 16:52 ` Imre Deak
  2018-03-06 17:47 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 17+ messages in thread
From: Imre Deak @ 2018-03-06 16:52 UTC (permalink / raw)
  To: igt-dev; +Cc: Juha-Pekka Heikkilä

Add plane clipping subtests displaying a single clipped plane, with the
following test cases:
a) plane covering the whole screen, so that clipping is done at all 4
   screen edges
b) plane at either of the 4 corners of the screen clipped, so that a
   4x4 pixel part of the plane is visible
c) plane at either of the 4 corners of the screen clipped, so that a
   2x2 pixel part of the plane is visible

Each of the above cases are tested with all supported planes, tiling
modes, rotation degrees and differing pixel format sizes (only 16 bpp
and 32 bpp for now). While the a) and b) cases above are supported on
all platforms c) is not fully supported on GLK and CNL (which was the
primary motivation for this testcase).

v2:
- Add missing reset for the output pipe after finishing the test for a
  given output, fixing the
  "DP-1 and eDP-1 are both trying to use pipe A" type of errors.
- Use -ERANGE instead of -EINVAL to check the return code for
  unsupported plane X positions, based on the latest kernel code.
- Add comment explaining the dependencies when doing a universal
  commit.

Signed-off-by: Imre Deak <imre.deak@intel.com>
Cc: Mika Kahola <mika.kahola@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Juha-Pekka Heikkilä <juha-pekka.heikkila@intel.com>
Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com> (v1)
---
 tests/kms_plane.c | 451 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 451 insertions(+)

diff --git a/tests/kms_plane.c b/tests/kms_plane.c
index 5bd3249a..1226c008 100644
--- a/tests/kms_plane.c
+++ b/tests/kms_plane.c
@@ -41,11 +41,34 @@ typedef struct {
 	int drm_fd;
 	igt_display_t display;
 	igt_pipe_crc_t *pipe_crc;
+	uint32_t devid;
+	uint64_t max_curw;
+	uint64_t max_curh;
 } data_t;
 
 static color_t red   = { 1.0f, 0.0f, 0.0f };
 static color_t green = { 0.0f, 1.0f, 0.0f };
+static color_t yellow = { 1.0f, 1.0f, 0.0f };
 static color_t blue  = { 0.0f, 0.0f, 1.0f };
+static color_t white = { 1.0f, 1.0f, 1.0f };
+
+
+/*
+ * Size of a square plane used to test clipping at the 4 courners of the
+ * display.
+ */
+#define CLIPPED_PLANE_SMALL_SIZE	64
+
+/*
+ * Visible plane size after clipping that works on all platforms for all plane
+ * positions.
+ * The exceptions are GLK/CNL where there must be at least this many pixels
+ * visible from the plane after it's clipped to the left/right edge of the
+ * screen. Not meeting this condition may trigger FIFO underflows and screen
+ * corruption. The cursor plane is an exception that doesn't have this problem
+ * even on GLK/CNL.
+ */
+#define CLIPPED_PLANE_MIN_VALID		4
 
 /*
  * Common code across all tests, acting on data_t
@@ -142,6 +165,111 @@ create_fb_for_mode__position(data_t *data, drmModeModeInfo *mode,
 	igt_put_cairo_ctx(data->drm_fd, fb, cr);
 }
 
+/*
+ * Create a square FB for the plane in the clipping test, divided into 4
+ * quarters solid filled with different colors. Use the given tiling, format
+ * and size and rotate the FB clockwise with the given rotation degrees, so
+ * that the counterclockwise rotation with the same degrees done by the HW
+ * will always result in the same reference FB image.
+ */
+static void
+create_fb_for_mode__clipping_plane(data_t *data, igt_rotation_t rotation,
+				   uint64_t tiling,
+				   uint32_t format,
+				   int size,
+				   struct igt_fb *fb /* out */)
+{
+	color_t corners[] = { red, white, yellow, blue };
+	color_t color;
+	unsigned int fb_id;
+	cairo_t *cr;
+	const int qsize = size / 2;
+	int idx;
+
+	fb_id = igt_create_fb(data->drm_fd, size, size, format, tiling, fb);
+	igt_assert(fb_id);
+
+	cr = igt_get_cairo_ctx(data->drm_fd, fb);
+
+	switch (rotation) {
+	case IGT_ROTATION_0:
+		idx = 0;
+		break;
+	case IGT_ROTATION_90:
+		idx = 3;
+		break;
+	case IGT_ROTATION_180:
+		idx = 2;
+		break;
+	case IGT_ROTATION_270:
+		idx = 1;
+		break;
+	default:
+		igt_assert(0);
+	}
+
+	color = corners[idx];
+	igt_paint_color(cr, 0, 0, qsize, qsize,
+			color.red, color.green, color.blue);
+
+	color = corners[(++idx) % 4];
+	igt_paint_color(cr, qsize, 0, qsize, qsize,
+			color.red, color.green, color.blue);
+
+	color = corners[(++idx) % 4];
+	igt_paint_color(cr, qsize, qsize, qsize, qsize,
+			color.red, color.green, color.blue);
+
+	color = corners[(++idx) % 4];
+	igt_paint_color(cr, 0, qsize, qsize, qsize,
+			color.red, color.green, color.blue);
+
+	igt_assert(cairo_status(cr) == 0);
+	cairo_destroy(cr);
+}
+
+/*
+ * Create a square reference FB for the whole screen in the clipping test,
+ * with the given test plane position and size. See
+ * create_fb_for_mode__clipping_plane() for the layout of the test plane.
+ */
+static void
+create_fb_for_mode__clipping_display(data_t *data, drmModeModeInfo *mode,
+				     int plane_x, int plane_y,
+				     int plane_size,
+				     struct igt_fb *fb /* out */)
+{
+	struct igt_fb plane_fb;
+	unsigned int fb_id;
+	cairo_t *cr;
+	cairo_surface_t *src;
+
+	fb_id = igt_create_fb(data->drm_fd,
+				  mode->hdisplay, mode->vdisplay,
+				  DRM_FORMAT_XRGB8888,
+				  LOCAL_DRM_FORMAT_MOD_NONE,
+				  fb);
+	igt_assert(fb_id);
+
+	create_fb_for_mode__clipping_plane(data, IGT_ROTATION_0,
+					   LOCAL_DRM_FORMAT_MOD_NONE,
+					   DRM_FORMAT_XRGB8888,
+					   plane_size, &plane_fb);
+
+	src = igt_get_cairo_surface(data->drm_fd, &plane_fb);
+
+	cr = igt_get_cairo_ctx(data->drm_fd, fb);
+	igt_paint_color(cr, 0, 0, mode->hdisplay, mode->vdisplay,
+			0, 0, 0);
+
+	cairo_set_source_surface(cr, src, plane_x, plane_y);
+	cairo_rectangle(cr, plane_x, plane_y,
+			plane_size, plane_size);
+	cairo_fill(cr);
+	igt_assert(cairo_status(cr) == 0);
+	cairo_destroy(cr);
+}
+
 enum {
 	TEST_POSITION_FULLY_COVERED = 1 << 0,
 	TEST_DPMS = 1 << 1,
@@ -463,6 +591,313 @@ test_pixel_formats(data_t *data, enum pipe pipe)
 	}
 }
 
+static bool
+bogus_plane_conf(uint32_t devid, igt_plane_t *plane_obj,
+		 int hdisplay, int plane_x, int plane_width)
+{
+	if (!(IS_GEMINILAKE(devid) || IS_CANNONLAKE(devid)))
+		return false;
+
+	if (plane_obj->type == DRM_PLANE_TYPE_CURSOR)
+		return false;
+
+	if (plane_x + plane_width >= CLIPPED_PLANE_MIN_VALID &&
+	    plane_x <= hdisplay - CLIPPED_PLANE_MIN_VALID)
+		return false;
+
+	return true;
+}
+
+static bool
+supported_plane_conf(data_t *data, int plane_type, uint64_t tiling,
+		     uint32_t format, igt_rotation_t rotation,
+		     drmModeModeInfo *mode,
+		     int plane_x, int plane_y, int plane_size)
+{
+	if (intel_gen(data->devid) < 9 &&
+	    tiling != LOCAL_DRM_FORMAT_MOD_NONE)
+		return false;
+
+	/* On GEN<9 the primary plane must cover the full screen. */
+	if (intel_gen(data->devid) < 9 &&
+	    plane_type == DRM_PLANE_TYPE_PRIMARY &&
+	    (plane_x > 0 || plane_y > 0 ||
+	     (plane_x + plane_size < mode->hdisplay) ||
+	     (plane_y + plane_size < mode->vdisplay)))
+		return false;
+
+	if (plane_type == DRM_PLANE_TYPE_CURSOR) {
+		/* For cursor planes only linear/alpha format is supported. */
+		if (tiling != LOCAL_DRM_FORMAT_MOD_NONE ||
+		    format != DRM_FORMAT_ARGB8888)
+			return false;
+
+		if (plane_size > data->max_curw || plane_size > data->max_curh)
+			return false;
+	} else {
+		/*
+		 * For non-cursor planes formats with alpha may result in
+		 * undeterministic CRCs, we use the same sized
+		 * non-alpha XRGB8888 format instead.
+		 */
+		if (format == DRM_FORMAT_ARGB8888)
+			return false;
+
+		if (format == DRM_FORMAT_RGB565 &&
+		    intel_gen(data->devid) < 9 &&
+		    !IS_VALLEYVIEW(data->devid) && !IS_CHERRYVIEW(data->devid))
+			return false;
+	}
+
+	/* RGB565 with rotation is not supported for now. */
+	if (format == DRM_FORMAT_RGB565 && rotation != IGT_ROTATION_0)
+		return false;
+
+	return true;
+}
+
+static void
+test_plane_clipping_format(data_t *data,
+			    enum pipe pipe,
+			    int plane,
+			    igt_output_t *output,
+			    drmModeModeInfo *mode,
+			    int plane_x, int plane_y,
+			    int plane_size,
+			    uint64_t tiling,
+			    igt_rotation_t rotation,
+			    uint32_t format,
+			    igt_crc_t *reference_crc)
+{
+	igt_plane_t *plane_obj;
+	struct igt_fb reference_fb;
+	igt_crc_t crc;
+	int ret;
+
+	igt_debug("  plane %d rotation %s tiling %s format %s\n",
+		  plane,
+		  igt_rotation_degrees_str(rotation),
+		  igt_tiling_str(tiling),
+		  igt_format_str(format));
+
+	igt_output_set_pipe(output, pipe);
+	plane_obj = igt_output_get_plane(output, plane);
+
+	if (!supported_plane_conf(data, plane_obj->type,
+				  tiling, format, rotation,
+				  mode,
+				  plane_x, plane_y,
+				  plane_size))
+		goto out;
+
+	igt_output_set_pipe(output, pipe);
+
+	create_fb_for_mode__clipping_plane(data, rotation, tiling, format,
+					   plane_size, &reference_fb);
+
+	igt_plane_set_fb(plane_obj, &reference_fb);
+	igt_fb_set_position(&reference_fb, plane_obj, 0, 0);
+
+	igt_plane_set_size(plane_obj, plane_size, plane_size);
+	igt_plane_set_rotation(plane_obj, rotation);
+	igt_plane_set_position(plane_obj, plane_x, plane_y);
+
+	/*
+	 * Note that a universal commit doesn't support full modesets, so we
+	 * have to make sure that the following only needs to commit changes
+	 * that are compatible with a fastset. This should be guaranteed,
+	 * since before calling this function we took the reference CRC which
+	 * left the display enabled with the mode we require here and
+	 * afterwards we only change plane parameters (FB, position, rotation
+	 * etc.).
+	 */
+	ret = igt_display_try_commit2(&data->display, COMMIT_UNIVERSAL);
+
+	if (!bogus_plane_conf(data->devid, plane_obj, mode->hdisplay,
+			      plane_x, plane_size)) {
+		igt_assert(ret == 0);
+		igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+		igt_assert_crc_equal(reference_crc, &crc);
+	} else {
+		igt_assert(ret == -ERANGE);
+	}
+
+	igt_plane_set_fb(plane_obj, NULL);
+	igt_plane_set_rotation(plane_obj, IGT_ROTATION_0);
+	igt_plane_set_position(plane_obj, 0, 0);
+
+	igt_remove_fb(data->drm_fd, &reference_fb);
+
+out:
+	igt_output_set_pipe(output, PIPE_ANY);
+}
+
+static void
+test_plane_clipping_square(data_t *data, enum pipe pipe,
+			   igt_output_t *output, drmModeModeInfo *mode,
+			   int plane_x, int plane_y, int plane_size)
+{
+	const struct {
+		uint64_t tiling;
+		igt_rotation_t rotation;
+	} rotations[] = {
+		{ LOCAL_DRM_FORMAT_MOD_NONE,		IGT_ROTATION_0 },
+
+		{ LOCAL_I915_FORMAT_MOD_X_TILED,	IGT_ROTATION_0 },
+
+		{ LOCAL_I915_FORMAT_MOD_Y_TILED,	IGT_ROTATION_0 },
+		{ LOCAL_I915_FORMAT_MOD_Y_TILED,	IGT_ROTATION_90 },
+		{ LOCAL_I915_FORMAT_MOD_Y_TILED,	IGT_ROTATION_180 },
+		{ LOCAL_I915_FORMAT_MOD_Y_TILED,	IGT_ROTATION_270 },
+
+		{ LOCAL_I915_FORMAT_MOD_Yf_TILED,	IGT_ROTATION_0 },
+		{ LOCAL_I915_FORMAT_MOD_Yf_TILED,	IGT_ROTATION_90 },
+		{ LOCAL_I915_FORMAT_MOD_Yf_TILED,	IGT_ROTATION_180 },
+		{ LOCAL_I915_FORMAT_MOD_Yf_TILED,	IGT_ROTATION_270 },
+	};
+	const uint32_t formats[] = {
+		DRM_FORMAT_RGB565,
+		DRM_FORMAT_XRGB8888,
+		DRM_FORMAT_ARGB8888,
+	};
+	int n_planes = data->display.pipes[pipe].n_planes;
+	igt_fb_t reference_fb;
+	igt_crc_t reference_crc;
+
+	igt_info("Testing connector %s mode %dx%d using pipe %s: %d,%d@%d,%d\n",
+		 igt_output_name(output),
+		 mode->hdisplay, mode->vdisplay,
+		 kmstest_pipe_name(pipe),
+		 plane_size, plane_size,
+		 plane_x, plane_y);
+
+	test_init(data, pipe);
+
+	create_fb_for_mode__clipping_display(data, mode,
+					     plane_x, plane_y,
+					     plane_size,
+					     &reference_fb);
+
+	test_grab_crc_for_fb(data, output, pipe, &reference_fb,
+			     &reference_crc);
+
+	igt_remove_fb(data->drm_fd, &reference_fb);
+
+	for (int plane = 0; plane < n_planes; plane++)
+		for (int rotation = 0; rotation < ARRAY_SIZE(rotations);
+		     rotation++)
+			for (int format = 0; format < ARRAY_SIZE(formats);
+			     format++)
+				test_plane_clipping_format(data, pipe, plane,
+							    output,
+							    mode,
+							    plane_x, plane_y,
+							    plane_size,
+							    rotations[rotation].tiling,
+							    rotations[rotation].rotation,
+							    formats[format],
+							    &reference_crc);
+
+	test_fini(data);
+}
+
+static void
+test_plane_clipping(data_t *data, enum pipe pipe)
+{
+	igt_output_t *output;
+	int connected_outs = 0;
+
+	for_each_valid_output_on_pipe(&data->display, pipe, output) {
+		drmModeModeInfo *mode;
+		int sq_size;
+
+		igt_output_set_pipe(output, pipe);
+		mode = igt_output_get_mode(output);
+
+		/*
+		 * Test with a square plane bigger than either the width or
+		 * height of the mode. This should pass on all platforms.
+		 */
+		sq_size = mode->hdisplay > mode->vdisplay ?
+			  mode->hdisplay : mode->vdisplay;
+		test_plane_clipping_square(data, pipe, output, mode,
+					   -2,
+					   -2,
+					   sq_size + 4);
+
+		/*
+		 * Test positions in the 4 corners of the screen with a
+		 * CLIPPED_PLANE_MIN_VALID x CLIPPED_PLANE_MIN_VALID square
+		 * visible from the plane. These should pass on all platforms.
+		 */
+		test_plane_clipping_square(data, pipe, output, mode,
+					   -CLIPPED_PLANE_SMALL_SIZE +
+					    CLIPPED_PLANE_MIN_VALID,
+					   -CLIPPED_PLANE_SMALL_SIZE +
+					    CLIPPED_PLANE_MIN_VALID,
+					   CLIPPED_PLANE_SMALL_SIZE);
+
+		test_plane_clipping_square(data, pipe, output, mode,
+					   -CLIPPED_PLANE_SMALL_SIZE +
+					    CLIPPED_PLANE_MIN_VALID,
+					   mode->vdisplay -
+					    CLIPPED_PLANE_MIN_VALID,
+					   CLIPPED_PLANE_SMALL_SIZE);
+
+		test_plane_clipping_square(data, pipe, output, mode,
+					   mode->hdisplay -
+					    CLIPPED_PLANE_MIN_VALID,
+					   -CLIPPED_PLANE_SMALL_SIZE +
+					    CLIPPED_PLANE_MIN_VALID,
+					   CLIPPED_PLANE_SMALL_SIZE);
+
+		test_plane_clipping_square(data, pipe, output, mode,
+					   mode->hdisplay -
+					    CLIPPED_PLANE_MIN_VALID,
+					   mode->vdisplay -
+					    CLIPPED_PLANE_MIN_VALID,
+					   CLIPPED_PLANE_SMALL_SIZE);
+
+		/*
+		 * Test positions in the 4 corners of the screen with a
+		 * 2 x 2 square visible from the plane. These are valid on all
+		 * platforms except on GLK/CNL where less than
+		 * CLIPPED_PLANE_MIN_VALID pixels visible on the left/right
+		 * edges of the screen may cause FIFO underflow and display
+		 * corruption.
+		 *
+		 * The cursor plane is an exception without this problem.
+		 *
+		 * Use 2 x 2 size as other (odd) sizes may result in an
+		 * incorrect CRC for the cursor plane even though it displays
+		 * correctly and causes no underflow.
+		 */
+		test_plane_clipping_square(data, pipe, output, mode,
+					   -CLIPPED_PLANE_SMALL_SIZE + 2,
+					   -CLIPPED_PLANE_SMALL_SIZE + 2,
+					   CLIPPED_PLANE_SMALL_SIZE);
+
+		test_plane_clipping_square(data, pipe, output, mode,
+					   -CLIPPED_PLANE_SMALL_SIZE + 2,
+					   mode->vdisplay - 2,
+					   CLIPPED_PLANE_SMALL_SIZE);
+
+		test_plane_clipping_square(data, pipe, output, mode,
+					   mode->hdisplay - 2,
+					   -CLIPPED_PLANE_SMALL_SIZE + 2,
+					   CLIPPED_PLANE_SMALL_SIZE);
+
+		test_plane_clipping_square(data, pipe, output, mode,
+					   mode->hdisplay - 2,
+					   mode->vdisplay - 2,
+					   CLIPPED_PLANE_SMALL_SIZE);
+
+		connected_outs++;
+	}
+
+	igt_skip_on(connected_outs == 0);
+}
+
 static void
 run_tests_for_pipe_plane(data_t *data, enum pipe pipe)
 {
@@ -499,6 +934,9 @@ run_tests_for_pipe_plane(data_t *data, enum pipe pipe)
 		      kmstest_pipe_name(pipe))
 		test_plane_panning(data, pipe, TEST_PANNING_BOTTOM_RIGHT |
 					       TEST_SUSPEND_RESUME);
+	igt_subtest_f("plane-clipping-pipe-%s-planes",
+		      kmstest_pipe_name(pipe))
+		test_plane_clipping(data, pipe);
 }
 
 
@@ -511,8 +949,21 @@ igt_main
 	igt_skip_on_simulation();
 
 	igt_fixture {
+		int ret;
+
 		data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
 
+		data.devid = intel_get_drm_devid(data.drm_fd);
+
+		data.max_curw = 64;
+		data.max_curh = 64;
+		ret = drmGetCap(data.drm_fd, DRM_CAP_CURSOR_WIDTH,
+				&data.max_curw);
+		igt_assert(ret == 0 || errno == EINVAL);
+		ret = drmGetCap(data.drm_fd, DRM_CAP_CURSOR_HEIGHT,
+				&data.max_curh);
+		igt_assert(ret == 0 || errno == EINVAL);
+
 		kmstest_set_vt_graphics_mode();
 
 		igt_require_pipe_crc(data.drm_fd);
-- 
2.13.2

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [igt-dev] ✓ Fi.CI.BAT: success for kms_plane: Add clipping subtests
  2018-03-06 16:52 [igt-dev] [PATCH i-g-t v2 0/4] kms_plane: Add clipping subtests Imre Deak
                   ` (3 preceding siblings ...)
  2018-03-06 16:52 ` [igt-dev] [PATCH v2 4/4] kms_plane: Add clipping subtests Imre Deak
@ 2018-03-06 17:47 ` Patchwork
  2018-03-06 22:24 ` [igt-dev] ✗ Fi.CI.IGT: warning " Patchwork
  2018-03-07 17:03 ` [igt-dev] [PATCH i-g-t v2 0/4] " Daniel Vetter
  6 siblings, 0 replies; 17+ messages in thread
From: Patchwork @ 2018-03-06 17:47 UTC (permalink / raw)
  To: Imre Deak; +Cc: igt-dev

== Series Details ==

Series: kms_plane: Add clipping subtests
URL   : https://patchwork.freedesktop.org/series/39467/
State : success

== Summary ==

IGT patchset tested on top of latest successful build
b4689dce36d0fbd9aec70d5a4b077c43a6b9c254 igt: Remove gen7_forcewake_mt

with latest DRM-Tip kernel build CI_DRM_3881
dc9f7f3e78b9 drm-tip: 2018y-03m-06d-16h-12m-59s UTC integration manifest

Testlist changes:
+igt@kms_plane@plane-clipping-pipe-a-planes
+igt@kms_plane@plane-clipping-pipe-b-planes
+igt@kms_plane@plane-clipping-pipe-c-planes
+igt@kms_plane@plane-clipping-pipe-d-planes
+igt@kms_plane@plane-clipping-pipe-e-planes
+igt@kms_plane@plane-clipping-pipe-f-planes

---- Known issues:

Test gem_mmap_gtt:
        Subgroup basic-small-bo-tiledx:
                pass       -> FAIL       (fi-gdg-551) fdo#102575
Test kms_pipe_crc_basic:
        Subgroup suspend-read-crc-pipe-b:
                incomplete -> PASS       (fi-snb-2520m) fdo#103713
Test prime_vgem:
        Subgroup basic-fence-flip:
                fail       -> PASS       (fi-ilk-650) fdo#104008

fdo#102575 https://bugs.freedesktop.org/show_bug.cgi?id=102575
fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
fdo#104008 https://bugs.freedesktop.org/show_bug.cgi?id=104008

fi-bdw-5557u     total:288  pass:267  dwarn:0   dfail:0   fail:0   skip:21  time:423s
fi-bdw-gvtdvm    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:423s
fi-blb-e6850     total:288  pass:223  dwarn:1   dfail:0   fail:0   skip:64  time:373s
fi-bsw-n3050     total:288  pass:242  dwarn:0   dfail:0   fail:0   skip:46  time:504s
fi-bwr-2160      total:288  pass:183  dwarn:0   dfail:0   fail:0   skip:105 time:280s
fi-bxt-dsi       total:288  pass:258  dwarn:0   dfail:0   fail:0   skip:30  time:490s
fi-bxt-j4205     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:496s
fi-byt-j1900     total:288  pass:253  dwarn:0   dfail:0   fail:0   skip:35  time:484s
fi-byt-n2820     total:288  pass:249  dwarn:0   dfail:0   fail:0   skip:39  time:471s
fi-cfl-8700k     total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:407s
fi-cfl-s2        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:573s
fi-cnl-y3        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:600s
fi-elk-e7500     total:288  pass:229  dwarn:0   dfail:0   fail:0   skip:59  time:416s
fi-gdg-551       total:288  pass:179  dwarn:0   dfail:0   fail:1   skip:108 time:288s
fi-glk-1         total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:522s
fi-hsw-4770      total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:398s
fi-ilk-650       total:288  pass:228  dwarn:0   dfail:0   fail:0   skip:60  time:418s
fi-ivb-3520m     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:465s
fi-ivb-3770      total:288  pass:255  dwarn:0   dfail:0   fail:0   skip:33  time:420s
fi-kbl-7500u     total:288  pass:263  dwarn:1   dfail:0   fail:0   skip:24  time:468s
fi-kbl-7560u     total:108  pass:104  dwarn:0   dfail:0   fail:0   skip:3  
fi-kbl-7567u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:460s
fi-kbl-r         total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:511s
fi-pnv-d510      total:288  pass:222  dwarn:1   dfail:0   fail:0   skip:65  time:588s
fi-skl-6260u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:435s
fi-skl-6600u     total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:521s
fi-skl-6700hq    total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:537s
fi-skl-6700k2    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:501s
fi-skl-6770hq    total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:486s
fi-skl-guc       total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:420s
fi-snb-2520m     total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:514s
fi-snb-2600      total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:393s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1072/issues.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [igt-dev] ✗ Fi.CI.IGT: warning for kms_plane: Add clipping subtests
  2018-03-06 16:52 [igt-dev] [PATCH i-g-t v2 0/4] kms_plane: Add clipping subtests Imre Deak
                   ` (4 preceding siblings ...)
  2018-03-06 17:47 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
@ 2018-03-06 22:24 ` Patchwork
  2018-03-07 17:03 ` [igt-dev] [PATCH i-g-t v2 0/4] " Daniel Vetter
  6 siblings, 0 replies; 17+ messages in thread
From: Patchwork @ 2018-03-06 22:24 UTC (permalink / raw)
  To: Imre Deak; +Cc: igt-dev

== Series Details ==

Series: kms_plane: Add clipping subtests
URL   : https://patchwork.freedesktop.org/series/39467/
State : warning

== Summary ==

---- Possible new issues:

Test kms_busy:
        Subgroup extended-modeset-hang-oldfb-with-reset-render-b:
                pass       -> SKIP       (shard-snb)
Test kms_chv_cursor_fail:
        Subgroup pipe-a-64x64-top-edge:
                dmesg-warn -> PASS       (shard-hsw)
Test kms_vblank:
        Subgroup pipe-b-ts-continuation-suspend:
                pass       -> DMESG-WARN (shard-snb)

---- Known issues:

Test gem_eio:
        Subgroup in-flight-contexts:
                pass       -> INCOMPLETE (shard-apl) fdo#105341
Test gem_softpin:
        Subgroup noreloc-s3:
                skip       -> PASS       (shard-snb) fdo#103375
Test kms_chv_cursor_fail:
        Subgroup pipe-c-64x64-bottom-edge:
                pass       -> DMESG-WARN (shard-hsw) fdo#105185 +3
Test kms_cursor_legacy:
        Subgroup 2x-long-flip-vs-cursor-atomic:
                fail       -> PASS       (shard-hsw) fdo#104873
        Subgroup flip-vs-cursor-toggle:
                fail       -> PASS       (shard-hsw) fdo#102670
Test kms_flip:
        Subgroup plain-flip-ts-check:
                fail       -> PASS       (shard-hsw) fdo#100368 +1
Test kms_frontbuffer_tracking:
        Subgroup fbc-suspend:
                fail       -> PASS       (shard-apl) fdo#101623 +1

fdo#105341 https://bugs.freedesktop.org/show_bug.cgi?id=105341
fdo#103375 https://bugs.freedesktop.org/show_bug.cgi?id=103375
fdo#105185 https://bugs.freedesktop.org/show_bug.cgi?id=105185
fdo#104873 https://bugs.freedesktop.org/show_bug.cgi?id=104873
fdo#102670 https://bugs.freedesktop.org/show_bug.cgi?id=102670
fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#101623 https://bugs.freedesktop.org/show_bug.cgi?id=101623

shard-apl        total:3449 pass:1814 dwarn:1   dfail:0   fail:7   skip:1625 time:11964s
shard-hsw        total:3473 pass:1775 dwarn:2   dfail:0   fail:1   skip:1694 time:11827s
shard-snb        total:3473 pass:1362 dwarn:4   dfail:0   fail:2   skip:2105 time:7081s
Blacklisted hosts:
shard-kbl        total:3432 pass:1933 dwarn:1   dfail:1   fail:6   skip:1489 time:8744s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1072/shards.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [igt-dev] [PATCH i-g-t v2 0/4] kms_plane: Add clipping subtests
  2018-03-06 16:52 [igt-dev] [PATCH i-g-t v2 0/4] kms_plane: Add clipping subtests Imre Deak
                   ` (5 preceding siblings ...)
  2018-03-06 22:24 ` [igt-dev] ✗ Fi.CI.IGT: warning " Patchwork
@ 2018-03-07 17:03 ` Daniel Vetter
  2018-03-07 17:29   ` Imre Deak
  6 siblings, 1 reply; 17+ messages in thread
From: Daniel Vetter @ 2018-03-07 17:03 UTC (permalink / raw)
  To: Imre Deak; +Cc: igt-dev, Juha-Pekka Heikkil??

On Tue, Mar 06, 2018 at 06:52:11PM +0200, Imre Deak wrote:
> This is v2 of [1], fixing the issues reported by Arek and CI. Besides
> the changes described in patch 4, there is also an FBC workaround
> applied now in kernel. Without the WA the test cases using the primary
> plane (with FBC) could trigger FIFO underflow errors.
> 
> Note that the subtest takes ~40 seconds to run on a single pipe.

Do we need to spend that much time testing clipping? What's the overlap
with all the various other plane clipping tests we have already, which
focus exclusively on the cursor?

Note: Not blocking this, just want to make sure we have some overall plan
here maybe and aren't digging ourselves some comfy graves :-)

Cheers, Daniel

> 
> [1]
> https://lists.freedesktop.org/archives/igt-dev/2018-February/000523.html
> 
> Cc: Mika Kahola <mika.kahola@intel.com>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Juha-Pekka Heikkil?? <juha-pekka.heikkila@intel.com>
> Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
> 
> Imre Deak (4):
>   kms_plane: Remove redundant modeset after CRC capture
>   lib: Export helpers to get rotation/tiling strings
>   kms_plane: Split helpers creating reference FB and capturing CRC
>   kms_plane: Add clipping subtests
> 
>  lib/igt_fb.c      |  23 +++
>  lib/igt_fb.h      |   1 +
>  lib/igt_kms.c     |  11 +-
>  lib/igt_kms.h     |   1 +
>  tests/kms_plane.c | 502 +++++++++++++++++++++++++++++++++++++++++++++++++++---
>  5 files changed, 517 insertions(+), 21 deletions(-)
> 
> -- 
> 2.13.2
> 
> _______________________________________________
> igt-dev mailing list
> igt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [igt-dev] [PATCH i-g-t v2 0/4] kms_plane: Add clipping subtests
  2018-03-07 17:03 ` [igt-dev] [PATCH i-g-t v2 0/4] " Daniel Vetter
@ 2018-03-07 17:29   ` Imre Deak
  2018-03-07 20:44     ` Daniel Vetter
  0 siblings, 1 reply; 17+ messages in thread
From: Imre Deak @ 2018-03-07 17:29 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: igt-dev

On Wed, Mar 07, 2018 at 06:03:19PM +0100, Daniel Vetter wrote:
> On Tue, Mar 06, 2018 at 06:52:11PM +0200, Imre Deak wrote:
> > This is v2 of [1], fixing the issues reported by Arek and CI. Besides
> > the changes described in patch 4, there is also an FBC workaround
> > applied now in kernel. Without the WA the test cases using the primary
> > plane (with FBC) could trigger FIFO underflow errors.
> > 
> > Note that the subtest takes ~40 seconds to run on a single pipe.
> 
> Do we need to spend that much time testing clipping? What's the overlap
> with all the various other plane clipping tests we have already, which
> focus exclusively on the cursor?

There's no other clipping tests using non-cursor planes. I think we are
missing coverage here: with the plane's start/end located close to the
screen edge triggered FIFO underflows due to two new issues already.

To reduce the runtime: in this patchset I removed one redundant modeset
after capturing the CRC, so I can't see what to improve on that front.
It goes through all format-sizes/tiling/rotation and planes so we could
avoid doing some of that maybe splitting them into separate subtests and
not running them for patchwork checks.

Not sure if CRC capturing is the most optimal in this test, I could look
into improving that. Maybe Maarten has some idea?

--Imre

> 
> Note: Not blocking this, just want to make sure we have some overall plan
> here maybe and aren't digging ourselves some comfy graves :-)
> 
> Cheers, Daniel
> 
> > 
> > [1]
> > https://lists.freedesktop.org/archives/igt-dev/2018-February/000523.html
> > 
> > Cc: Mika Kahola <mika.kahola@intel.com>
> > Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > Cc: Juha-Pekka Heikkil?? <juha-pekka.heikkila@intel.com>
> > Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
> > 
> > Imre Deak (4):
> >   kms_plane: Remove redundant modeset after CRC capture
> >   lib: Export helpers to get rotation/tiling strings
> >   kms_plane: Split helpers creating reference FB and capturing CRC
> >   kms_plane: Add clipping subtests
> > 
> >  lib/igt_fb.c      |  23 +++
> >  lib/igt_fb.h      |   1 +
> >  lib/igt_kms.c     |  11 +-
> >  lib/igt_kms.h     |   1 +
> >  tests/kms_plane.c | 502 +++++++++++++++++++++++++++++++++++++++++++++++++++---
> >  5 files changed, 517 insertions(+), 21 deletions(-)
> > 
> > -- 
> > 2.13.2
> > 
> > _______________________________________________
> > igt-dev mailing list
> > igt-dev@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/igt-dev
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [igt-dev] [PATCH i-g-t v2 0/4] kms_plane: Add clipping subtests
  2018-03-07 17:29   ` Imre Deak
@ 2018-03-07 20:44     ` Daniel Vetter
  2018-03-08 12:35       ` Imre Deak
  0 siblings, 1 reply; 17+ messages in thread
From: Daniel Vetter @ 2018-03-07 20:44 UTC (permalink / raw)
  To: Imre Deak; +Cc: igt-dev, Daniel Vetter

On Wed, Mar 07, 2018 at 07:29:55PM +0200, Imre Deak wrote:
> On Wed, Mar 07, 2018 at 06:03:19PM +0100, Daniel Vetter wrote:
> > On Tue, Mar 06, 2018 at 06:52:11PM +0200, Imre Deak wrote:
> > > This is v2 of [1], fixing the issues reported by Arek and CI. Besides
> > > the changes described in patch 4, there is also an FBC workaround
> > > applied now in kernel. Without the WA the test cases using the primary
> > > plane (with FBC) could trigger FIFO underflow errors.
> > > 
> > > Note that the subtest takes ~40 seconds to run on a single pipe.
> > 
> > Do we need to spend that much time testing clipping? What's the overlap
> > with all the various other plane clipping tests we have already, which
> > focus exclusively on the cursor?
> 
> There's no other clipping tests using non-cursor planes. I think we are
> missing coverage here: with the plane's start/end located close to the
> screen edge triggered FIFO underflows due to two new issues already.
> 
> To reduce the runtime: in this patchset I removed one redundant modeset
> after capturing the CRC, so I can't see what to improve on that front.
> It goes through all format-sizes/tiling/rotation and planes so we could
> avoid doing some of that maybe splitting them into separate subtests and
> not running them for patchwork checks.
> 
> Not sure if CRC capturing is the most optimal in this test, I could look
> into improving that. Maybe Maarten has some idea?

Could we test multiple things at the same maybe? Like cursor in one
corner, plane in the other. As long as the two are really far away the wms
shouldn't influence each another really.

Wrt CRC, if you're really efficient you can sample one every frame. Since
you need two per tests (one for the reference image, one for the hw
blending) that means 40*60/2 = 1200 different cases. But this only happens
if you capture CRC continuously and make sure you're really careful with
matching CRC frame ids correctly to your flips.

If you restart crc cacpture each time you lose a few frames each (because
there's issues we don't understand with the first few crcs, so need to
drop those), which means you test througput drops by about a factor of 10.

(I didn't look whether this is actually the case, too late in the evening
now).

Cheers, Daniel

> 
> --Imre
> 
> > 
> > Note: Not blocking this, just want to make sure we have some overall plan
> > here maybe and aren't digging ourselves some comfy graves :-)
> > 
> > Cheers, Daniel
> > 
> > > 
> > > [1]
> > > https://lists.freedesktop.org/archives/igt-dev/2018-February/000523.html
> > > 
> > > Cc: Mika Kahola <mika.kahola@intel.com>
> > > Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > > Cc: Juha-Pekka Heikkil?? <juha-pekka.heikkila@intel.com>
> > > Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
> > > 
> > > Imre Deak (4):
> > >   kms_plane: Remove redundant modeset after CRC capture
> > >   lib: Export helpers to get rotation/tiling strings
> > >   kms_plane: Split helpers creating reference FB and capturing CRC
> > >   kms_plane: Add clipping subtests
> > > 
> > >  lib/igt_fb.c      |  23 +++
> > >  lib/igt_fb.h      |   1 +
> > >  lib/igt_kms.c     |  11 +-
> > >  lib/igt_kms.h     |   1 +
> > >  tests/kms_plane.c | 502 +++++++++++++++++++++++++++++++++++++++++++++++++++---
> > >  5 files changed, 517 insertions(+), 21 deletions(-)
> > > 
> > > -- 
> > > 2.13.2
> > > 
> > > _______________________________________________
> > > igt-dev mailing list
> > > igt-dev@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/igt-dev
> > 
> > -- 
> > Daniel Vetter
> > Software Engineer, Intel Corporation
> > http://blog.ffwll.ch

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [igt-dev] [PATCH i-g-t v2 0/4] kms_plane: Add clipping subtests
  2018-03-07 20:44     ` Daniel Vetter
@ 2018-03-08 12:35       ` Imre Deak
  0 siblings, 0 replies; 17+ messages in thread
From: Imre Deak @ 2018-03-08 12:35 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: igt-dev

On Wed, Mar 07, 2018 at 09:44:09PM +0100, Daniel Vetter wrote:
> On Wed, Mar 07, 2018 at 07:29:55PM +0200, Imre Deak wrote:
> > On Wed, Mar 07, 2018 at 06:03:19PM +0100, Daniel Vetter wrote:
> > > On Tue, Mar 06, 2018 at 06:52:11PM +0200, Imre Deak wrote:
> > > > This is v2 of [1], fixing the issues reported by Arek and CI. Besides
> > > > the changes described in patch 4, there is also an FBC workaround
> > > > applied now in kernel. Without the WA the test cases using the primary
> > > > plane (with FBC) could trigger FIFO underflow errors.
> > > > 
> > > > Note that the subtest takes ~40 seconds to run on a single pipe.
> > > 
> > > Do we need to spend that much time testing clipping? What's the overlap
> > > with all the various other plane clipping tests we have already, which
> > > focus exclusively on the cursor?
> > 
> > There's no other clipping tests using non-cursor planes. I think we are
> > missing coverage here: with the plane's start/end located close to the
> > screen edge triggered FIFO underflows due to two new issues already.
> > 
> > To reduce the runtime: in this patchset I removed one redundant modeset
> > after capturing the CRC, so I can't see what to improve on that front.
> > It goes through all format-sizes/tiling/rotation and planes so we could
> > avoid doing some of that maybe splitting them into separate subtests and
> > not running them for patchwork checks.
> > 
> > Not sure if CRC capturing is the most optimal in this test, I could look
> > into improving that. Maybe Maarten has some idea?
> 
> Could we test multiple things at the same maybe? Like cursor in one
> corner, plane in the other. As long as the two are really far away the wms
> shouldn't influence each another really.

Good idea, will give it a go. The underflows (with the known cause) I
wanted to trigger originally depend on the position and plane type, but
AFAICS what only matters is if it's a cursor or not.

> Wrt CRC, if you're really efficient you can sample one every frame. Since
> you need two per tests (one for the reference image, one for the hw
> blending) that means 40*60/2 = 1200 different cases. But this only happens
> if you capture CRC continuously and make sure you're really careful with
> matching CRC frame ids correctly to your flips.
> 
> If you restart crc cacpture each time you lose a few frames each (because
> there's issues we don't understand with the first few crcs, so need to
> drop those), which means you test througput drops by about a factor of 10.
> 
> (I didn't look whether this is actually the case, too late in the evening
> now).

Ok, will check if it's the bottleneck at all. I see that the CRC read is
possibly retried with a 1ms delay, not sure what's that about.

> 
> Cheers, Daniel
> 
> > 
> > --Imre
> > 
> > > 
> > > Note: Not blocking this, just want to make sure we have some overall plan
> > > here maybe and aren't digging ourselves some comfy graves :-)
> > > 
> > > Cheers, Daniel
> > > 
> > > > 
> > > > [1]
> > > > https://lists.freedesktop.org/archives/igt-dev/2018-February/000523.html
> > > > 
> > > > Cc: Mika Kahola <mika.kahola@intel.com>
> > > > Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > > > Cc: Juha-Pekka Heikkil?? <juha-pekka.heikkila@intel.com>
> > > > Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
> > > > 
> > > > Imre Deak (4):
> > > >   kms_plane: Remove redundant modeset after CRC capture
> > > >   lib: Export helpers to get rotation/tiling strings
> > > >   kms_plane: Split helpers creating reference FB and capturing CRC
> > > >   kms_plane: Add clipping subtests
> > > > 
> > > >  lib/igt_fb.c      |  23 +++
> > > >  lib/igt_fb.h      |   1 +
> > > >  lib/igt_kms.c     |  11 +-
> > > >  lib/igt_kms.h     |   1 +
> > > >  tests/kms_plane.c | 502 +++++++++++++++++++++++++++++++++++++++++++++++++++---
> > > >  5 files changed, 517 insertions(+), 21 deletions(-)
> > > > 
> > > > -- 
> > > > 2.13.2
> > > > 
> > > > _______________________________________________
> > > > igt-dev mailing list
> > > > igt-dev@lists.freedesktop.org
> > > > https://lists.freedesktop.org/mailman/listinfo/igt-dev
> > > 
> > > -- 
> > > Daniel Vetter
> > > Software Engineer, Intel Corporation
> > > http://blog.ffwll.ch
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [igt-dev] [PATCH i-g-t v3 0/5] kms_plane: Add clipping subtests
  2018-03-06 16:52 ` [igt-dev] [PATCH v2 1/4] kms_plane: Remove redundant modeset after CRC capture Imre Deak
@ 2018-09-05 16:27   ` Gwan-gyeong Mun
  2018-09-05 16:27     ` [igt-dev] [PATCH i-g-t v3 1/5] kms_plane: Remove redundant modeset after CRC capture Gwan-gyeong Mun
                       ` (4 more replies)
  0 siblings, 5 replies; 17+ messages in thread
From: Gwan-gyeong Mun @ 2018-09-05 16:27 UTC (permalink / raw)
  To: igt-dev; +Cc: juha-pekka.heikkila

This is v3 of [1] and [2], implementing an idea of Daniel to achieve
improving test speed. Besides the changes described in patch 5.

Note that the subtest takes ~10 seconds to run on a single pipe.
(a prior version took ~ 43 seconds.)

[1]
https://lists.freedesktop.org/archives/igt-dev/2018-February/000523.html

[2]
https://lists.freedesktop.org/archives/igt-dev/2018-March/001407.html

Cc: Mika Kahola <mika.kahola@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Juha-Pekka Heikkilä <juha-pekka.heikkila@intel.com>
Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Cc: Imre Deak <imre.deak@intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>

Gwan-gyeong Mun (1):
  kms_plane: Add a helper of capturing CRC with commit style

Imre Deak (4):
  kms_plane: Remove redundant modeset after CRC capture
  lib: Export helpers to get rotation/tiling strings
  kms_plane: Split helpers creating reference FB and capturing CRC
  kms_plane: Add clipping subtests

 lib/igt_fb.c      |  23 ++
 lib/igt_fb.h      |   1 +
 lib/igt_kms.c     |  11 +-
 lib/igt_kms.h     |   1 +
 tests/kms_plane.c | 591 ++++++++++++++++++++++++++++++++++++++++++++--
 5 files changed, 605 insertions(+), 22 deletions(-)

-- 
2.18.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [igt-dev] [PATCH i-g-t v3 1/5] kms_plane: Remove redundant modeset after CRC capture
  2018-09-05 16:27   ` [igt-dev] [PATCH i-g-t v3 0/5] kms_plane: Add clipping subtests Gwan-gyeong Mun
@ 2018-09-05 16:27     ` Gwan-gyeong Mun
  2018-09-05 16:27     ` [igt-dev] [PATCH i-g-t v3 2/5] lib: Export helpers to get rotation/tiling strings Gwan-gyeong Mun
                       ` (3 subsequent siblings)
  4 siblings, 0 replies; 17+ messages in thread
From: Gwan-gyeong Mun @ 2018-09-05 16:27 UTC (permalink / raw)
  To: igt-dev; +Cc: juha-pekka.heikkila

From: Imre Deak <imre.deak@intel.com>

The null modeset after capturing the CRC is redundant; detaching the FB
from the plane is enough for the next modeset to work properly. This
speed things up especially on slow panels.

Signed-off-by: Imre Deak <imre.deak@intel.com>
Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
---
 tests/kms_plane.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tests/kms_plane.c b/tests/kms_plane.c
index 3999dde8..aceae591 100644
--- a/tests/kms_plane.c
+++ b/tests/kms_plane.c
@@ -88,7 +88,6 @@ test_grab_crc(data_t *data, igt_output_t *output, enum pipe pipe,
 	igt_pipe_crc_collect_crc(data->pipe_crc, crc);
 
 	igt_plane_set_fb(primary, NULL);
-	igt_display_commit(&data->display);
 
 	igt_remove_fb(data->drm_fd, &fb);
 
-- 
2.18.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [igt-dev] [PATCH i-g-t v3 2/5] lib: Export helpers to get rotation/tiling strings
  2018-09-05 16:27   ` [igt-dev] [PATCH i-g-t v3 0/5] kms_plane: Add clipping subtests Gwan-gyeong Mun
  2018-09-05 16:27     ` [igt-dev] [PATCH i-g-t v3 1/5] kms_plane: Remove redundant modeset after CRC capture Gwan-gyeong Mun
@ 2018-09-05 16:27     ` Gwan-gyeong Mun
  2018-09-05 16:27     ` [igt-dev] [PATCH i-g-t v3 3/5] kms_plane: Split helpers creating reference FB and capturing CRC Gwan-gyeong Mun
                       ` (2 subsequent siblings)
  4 siblings, 0 replies; 17+ messages in thread
From: Gwan-gyeong Mun @ 2018-09-05 16:27 UTC (permalink / raw)
  To: igt-dev; +Cc: juha-pekka.heikkila

From: Imre Deak <imre.deak@intel.com>

This is needed for the next patch for some debug prints.

Signed-off-by: Imre Deak <imre.deak@intel.com>
Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
---
 lib/igt_fb.c  | 23 +++++++++++++++++++++++
 lib/igt_fb.h  |  1 +
 lib/igt_kms.c | 11 +++++++++--
 lib/igt_kms.h |  1 +
 4 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index ae71d967..7ac60dd3 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -2016,3 +2016,26 @@ bool igt_format_is_yuv(uint32_t drm_format)
 		return false;
 	}
 }
+
+/**
+ * igt_tiling_str:
+ * @tiling: tiling ID
+ *
+ * Returns:
+ * Human-readable tiling string for @tiling.
+ */
+const char *igt_tiling_str(uint64_t tiling)
+{
+	switch (tiling) {
+	case LOCAL_DRM_FORMAT_MOD_NONE:
+		return "linear";
+	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:
+		return "N/A";
+	}
+}
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index d28bc0c4..1091d13e 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -168,6 +168,7 @@ uint32_t igt_drm_format_to_bpp(uint32_t drm_format);
 const char *igt_format_str(uint32_t drm_format);
 bool igt_fb_supported_format(uint32_t drm_format);
 bool igt_format_is_yuv(uint32_t drm_format);
+const char *igt_tiling_str(uint64_t tiling);
 
 #endif /* __IGT_FB_H__ */
 
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 62d84684..8f5b647e 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -3794,7 +3794,14 @@ void igt_fb_set_size(struct igt_fb *fb, igt_plane_t *plane,
 	igt_plane_set_prop_value(plane, IGT_PLANE_SRC_H, IGT_FIXED(h, 0));
 }
 
-static const char *rotation_name(igt_rotation_t rotation)
+/**
+ * igt_rotation_degrees_str:
+ * @rotation: rotation degrees/reflect mask
+ *
+ * Returns:
+ * Human-readable string for the rotation degrees part in @rotation.
+ */
+const char *igt_rotation_degrees_str(igt_rotation_t rotation)
 {
 	switch (rotation & IGT_ROTATION_MASK) {
 	case IGT_ROTATION_0:
@@ -3826,7 +3833,7 @@ void igt_plane_set_rotation(igt_plane_t *plane, igt_rotation_t rotation)
 
 	LOG(display, "%s.%d: plane_set_rotation(%s)\n",
 	    kmstest_pipe_name(pipe->pipe),
-	    plane->index, rotation_name(rotation));
+	    plane->index, igt_rotation_degrees_str(rotation));
 
 	igt_plane_set_prop_value(plane, IGT_PLANE_ROTATION, rotation);
 }
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 3a12f278..fb62d8e3 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -410,6 +410,7 @@ void igt_plane_set_fence_fd(igt_plane_t *plane, int fence_fd);
 void igt_plane_set_position(igt_plane_t *plane, int x, int y);
 void igt_plane_set_size(igt_plane_t *plane, int w, int h);
 void igt_plane_set_rotation(igt_plane_t *plane, igt_rotation_t rotation);
+const char *igt_rotation_degrees_str(igt_rotation_t rotation);
 void igt_fb_set_position(struct igt_fb *fb, igt_plane_t *plane,
 	uint32_t x, uint32_t y);
 void igt_fb_set_size(struct igt_fb *fb, igt_plane_t *plane,
-- 
2.18.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [igt-dev] [PATCH i-g-t v3 3/5] kms_plane: Split helpers creating reference FB and capturing CRC
  2018-09-05 16:27   ` [igt-dev] [PATCH i-g-t v3 0/5] kms_plane: Add clipping subtests Gwan-gyeong Mun
  2018-09-05 16:27     ` [igt-dev] [PATCH i-g-t v3 1/5] kms_plane: Remove redundant modeset after CRC capture Gwan-gyeong Mun
  2018-09-05 16:27     ` [igt-dev] [PATCH i-g-t v3 2/5] lib: Export helpers to get rotation/tiling strings Gwan-gyeong Mun
@ 2018-09-05 16:27     ` Gwan-gyeong Mun
  2018-09-05 16:27     ` [igt-dev] [PATCH i-g-t v3 4/5] kms_plane: Add a helper of capturing CRC with commit style Gwan-gyeong Mun
  2018-09-05 16:27     ` [igt-dev] [PATCH i-g-t v3 5/5] kms_plane: Add clipping subtests Gwan-gyeong Mun
  4 siblings, 0 replies; 17+ messages in thread
From: Gwan-gyeong Mun @ 2018-09-05 16:27 UTC (permalink / raw)
  To: igt-dev; +Cc: juha-pekka.heikkila

From: Imre Deak <imre.deak@intel.com>

Split creating a reference FB and capturing the CRC for it into separate
functions, so in a follow-up patch we can reuse the CRC capture function
for a reference FB created in a different way.

Signed-off-by: Imre Deak <imre.deak@intel.com>
Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
---
 tests/kms_plane.c | 50 ++++++++++++++++++++++++++++++-----------------
 1 file changed, 32 insertions(+), 18 deletions(-)

diff --git a/tests/kms_plane.c b/tests/kms_plane.c
index aceae591..3f48c821 100644
--- a/tests/kms_plane.c
+++ b/tests/kms_plane.c
@@ -61,11 +61,9 @@ static void test_fini(data_t *data)
 }
 
 static void
-test_grab_crc(data_t *data, igt_output_t *output, enum pipe pipe,
-	      color_t *fb_color, igt_crc_t *crc /* out */)
+test_grab_crc_for_fb(data_t *data, igt_output_t *output, enum pipe pipe,
+		     igt_fb_t *fb, igt_crc_t *crc /* out */)
 {
-	struct igt_fb fb;
-	drmModeModeInfo *mode;
 	igt_plane_t *primary;
 	char *crc_str;
 	int ret;
@@ -74,13 +72,7 @@ test_grab_crc(data_t *data, igt_output_t *output, enum pipe pipe,
 
 	primary = igt_output_get_plane(output, 0);
 
-	mode = igt_output_get_mode(output);
-	igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay,
-			    DRM_FORMAT_XRGB8888,
-			    LOCAL_DRM_FORMAT_MOD_NONE,
-			    fb_color->red, fb_color->green, fb_color->blue,
-			    &fb);
-	igt_plane_set_fb(primary, &fb);
+	igt_plane_set_fb(primary, fb);
 
 	ret = igt_display_try_commit2(&data->display, COMMIT_LEGACY);
 	igt_skip_on(ret != 0);
@@ -89,14 +81,24 @@ test_grab_crc(data_t *data, igt_output_t *output, enum pipe pipe,
 
 	igt_plane_set_fb(primary, NULL);
 
-	igt_remove_fb(data->drm_fd, &fb);
-
 	crc_str = igt_crc_to_string(crc);
-	igt_debug("CRC for a (%.02f,%.02f,%.02f) fb: %s\n", fb_color->red,
-		  fb_color->green, fb_color->blue, crc_str);
+	igt_debug("CRC for fb: %s\n", crc_str);
 	free(crc_str);
 }
 
+static void
+test_create_fb_for_output(data_t *data, igt_output_t *output, color_t *fb_color,
+			  igt_fb_t *fb)
+{
+	drmModeModeInfo *mode = igt_output_get_mode(output);
+
+	igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay,
+			    DRM_FORMAT_XRGB8888,
+			    LOCAL_DRM_FORMAT_MOD_NONE,
+			    fb_color->red, fb_color->green, fb_color->blue,
+			    fb);
+}
+
 /*
  * Plane position test.
  *   - We start by grabbing a reference CRC of a full green fb being scanned
@@ -222,11 +224,15 @@ test_plane_position(data_t *data, enum pipe pipe, unsigned int flags)
 
 	for_each_valid_output_on_pipe(&data->display, pipe, output) {
 		int n_planes = data->display.pipes[pipe].n_planes;
+		igt_fb_t reference_fb;
 		igt_crc_t reference_crc;
 
 		test_init(data, pipe);
 
-		test_grab_crc(data, output, pipe, &green, &reference_crc);
+		test_create_fb_for_output(data, output, &green, &reference_fb);
+		test_grab_crc_for_fb(data, output, pipe, &reference_fb,
+				     &reference_crc);
+		igt_remove_fb(data->drm_fd, &reference_fb);
 
 		for (int plane = 1; plane < n_planes; plane++)
 			test_plane_position_with_output(data, pipe, plane,
@@ -343,13 +349,21 @@ test_plane_panning(data_t *data, enum pipe pipe, unsigned int flags)
 
 	for_each_valid_output_on_pipe(&data->display, pipe, output) {
 		int n_planes = data->display.pipes[pipe].n_planes;
+		igt_fb_t red_fb;
+		igt_fb_t blue_fb;
 		igt_crc_t red_crc;
 		igt_crc_t blue_crc;
 
 		test_init(data, pipe);
 
-		test_grab_crc(data, output, pipe, &red, &red_crc);
-		test_grab_crc(data, output, pipe, &blue, &blue_crc);
+		test_create_fb_for_output(data, output, &red, &red_fb);
+		test_create_fb_for_output(data, output, &blue, &blue_fb);
+
+		test_grab_crc_for_fb(data, output, pipe, &red_fb, &red_crc);
+		test_grab_crc_for_fb(data, output, pipe, &blue_fb, &blue_crc);
+
+		igt_remove_fb(data->drm_fd, &blue_fb);
+		igt_remove_fb(data->drm_fd, &red_fb);
 
 		for (int plane = 1; plane < n_planes; plane++)
 			test_plane_panning_with_output(data, pipe, plane,
-- 
2.18.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [igt-dev] [PATCH i-g-t v3 4/5] kms_plane: Add a helper of capturing CRC with commit style
  2018-09-05 16:27   ` [igt-dev] [PATCH i-g-t v3 0/5] kms_plane: Add clipping subtests Gwan-gyeong Mun
                       ` (2 preceding siblings ...)
  2018-09-05 16:27     ` [igt-dev] [PATCH i-g-t v3 3/5] kms_plane: Split helpers creating reference FB and capturing CRC Gwan-gyeong Mun
@ 2018-09-05 16:27     ` Gwan-gyeong Mun
  2018-09-05 16:27     ` [igt-dev] [PATCH i-g-t v3 5/5] kms_plane: Add clipping subtests Gwan-gyeong Mun
  4 siblings, 0 replies; 17+ messages in thread
From: Gwan-gyeong Mun @ 2018-09-05 16:27 UTC (permalink / raw)
  To: igt-dev; +Cc: juha-pekka.heikkila

As a legacy style commit does not allow changing of primary plane rotation
on non-first commit, it adds a helper of capturing CRC with commit style
argument for testing of primary plane rotation.

Signed-off-by: Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>
---
 tests/kms_plane.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/tests/kms_plane.c b/tests/kms_plane.c
index 3f48c821..3d08893f 100644
--- a/tests/kms_plane.c
+++ b/tests/kms_plane.c
@@ -61,8 +61,9 @@ static void test_fini(data_t *data)
 }
 
 static void
-test_grab_crc_for_fb(data_t *data, igt_output_t *output, enum pipe pipe,
-		     igt_fb_t *fb, igt_crc_t *crc /* out */)
+test_grab_crc_for_fb2(data_t *data, igt_output_t *output, enum pipe pipe,
+		      igt_fb_t *fb, igt_crc_t *crc /* out */,
+		      enum igt_commit_style s)
 {
 	igt_plane_t *primary;
 	char *crc_str;
@@ -74,7 +75,8 @@ test_grab_crc_for_fb(data_t *data, igt_output_t *output, enum pipe pipe,
 
 	igt_plane_set_fb(primary, fb);
 
-	ret = igt_display_try_commit2(&data->display, COMMIT_LEGACY);
+	ret = igt_display_try_commit2(&data->display, s);
+
 	igt_skip_on(ret != 0);
 
 	igt_pipe_crc_collect_crc(data->pipe_crc, crc);
@@ -86,6 +88,13 @@ test_grab_crc_for_fb(data_t *data, igt_output_t *output, enum pipe pipe,
 	free(crc_str);
 }
 
+static void
+test_grab_crc_for_fb(data_t *data, igt_output_t *output, enum pipe pipe,
+		     igt_fb_t *fb, igt_crc_t *crc /* out */)
+{
+	test_grab_crc_for_fb2(data, output, pipe, fb, crc, COMMIT_LEGACY);
+}
+
 static void
 test_create_fb_for_output(data_t *data, igt_output_t *output, color_t *fb_color,
 			  igt_fb_t *fb)
-- 
2.18.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [igt-dev] [PATCH i-g-t v3 5/5] kms_plane: Add clipping subtests
  2018-09-05 16:27   ` [igt-dev] [PATCH i-g-t v3 0/5] kms_plane: Add clipping subtests Gwan-gyeong Mun
                       ` (3 preceding siblings ...)
  2018-09-05 16:27     ` [igt-dev] [PATCH i-g-t v3 4/5] kms_plane: Add a helper of capturing CRC with commit style Gwan-gyeong Mun
@ 2018-09-05 16:27     ` Gwan-gyeong Mun
  4 siblings, 0 replies; 17+ messages in thread
From: Gwan-gyeong Mun @ 2018-09-05 16:27 UTC (permalink / raw)
  To: igt-dev; +Cc: juha-pekka.heikkila

From: Imre Deak <imre.deak@intel.com>

Add plane clipping subtests displaying a single clipped plane, with the
following test cases:
a) plane covering the whole screen, so that clipping is done at all 4
   screen edges
b) plane at either of the 4 corners of the screen clipped, so that a
   4x4 pixel part of the plane is visible
c) plane at either of the 4 corners of the screen clipped, so that a
   2x2 pixel part of the plane is visible

Each of the above cases are tested with all supported tiling modes,
rotation degrees, differing pixel format sizes (only 16 bpp and 32 bpp
for now) and certain planes. While the a) and b) cases above are
supported on all platforms c) is not fully supported on GLK and CNL
(which was the primary motivation for this testcase).

v2:
- Add missing reset for the output pipe after finishing the test for a
  given output, fixing the
  "DP-1 and eDP-1 are both trying to use pipe A" type of errors.
- Use -ERANGE instead of -EINVAL to check the return code for
  unsupported plane X positions, based on the latest kernel code.
- Add comment explaining the dependencies when doing a universal
  commit.

v3: (Gwan-gyeong)
- Add missing release of framebuffer on create_fb_for_mode__clipping_display()
  function.
- Add using multi planes per single display commit on clipping test of
  4 corners. (Daniel)
  It enables the improving of test speed. If number of planes is over
  than 4, it uses four planes from first plane to next four planes.
  (4 planes make testing of 4 corners possible as 1 display commit.)
  If number of planes is over than 2 and less than 4, it uses two planes
  from first plane to next two planes. (2 planes make testing of 4 corners
  possible as 2 display commit.) Rest of cases it uses only first plane.
  (1 plane makes testing of 4 corners possible as 4 display commit.)
  It changes to using of certain planes from using of all supported planes.
  And a cursor plane can be one of test planes.

Signed-off-by: Imre Deak <imre.deak@intel.com>
Signed-off-by: Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>
Cc: Mika Kahola <mika.kahola@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Juha-Pekka Heikkilä <juha-pekka.heikkila@intel.com>
Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com> (v1)
---
 tests/kms_plane.c | 529 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 529 insertions(+)

diff --git a/tests/kms_plane.c b/tests/kms_plane.c
index 3d08893f..ea62efed 100644
--- a/tests/kms_plane.c
+++ b/tests/kms_plane.c
@@ -41,11 +41,40 @@ typedef struct {
 	int drm_fd;
 	igt_display_t display;
 	igt_pipe_crc_t *pipe_crc;
+	uint32_t devid;
+	uint64_t max_curw;
+	uint64_t max_curh;
 } data_t;
 
+typedef struct {
+	int x;
+	int y;
+	int size;
+} square_t;
+
 static color_t red   = { 1.0f, 0.0f, 0.0f };
 static color_t green = { 0.0f, 1.0f, 0.0f };
+static color_t yellow = { 1.0f, 1.0f, 0.0f };
 static color_t blue  = { 0.0f, 0.0f, 1.0f };
+static color_t white = { 1.0f, 1.0f, 1.0f };
+static square_t clip_squares[4];
+
+/*
+ * Size of a square plane used to test clipping at the 4 courners of the
+ * display.
+ */
+#define CLIPPED_PLANE_SMALL_SIZE	64
+
+/*
+ * Visible plane size after clipping that works on all platforms for all plane
+ * positions.
+ * The exceptions are GLK/CNL where there must be at least this many pixels
+ * visible from the plane after it's clipped to the left/right edge of the
+ * screen. Not meeting this condition may trigger FIFO underflows and screen
+ * corruption. The cursor plane is an exception that doesn't have this problem
+ * even on GLK/CNL.
+ */
+#define CLIPPED_PLANE_MIN_VALID		4
 
 /*
  * Common code across all tests, acting on data_t
@@ -151,6 +180,69 @@ create_fb_for_mode__position(data_t *data, drmModeModeInfo *mode,
 	igt_put_cairo_ctx(data->drm_fd, fb, cr);
 }
 
+/*
+ * Create a square FB for the plane in the clipping test, divided into 4
+ * quarters solid filled with different colors. Use the given tiling, format
+ * and size and rotate the FB clockwise with the given rotation degrees, so
+ * that the counterclockwise rotation with the same degrees done by the HW
+ * will always result in the same reference FB image.
+ */
+static void
+create_fb_for_mode__clipping_plane(data_t *data, igt_rotation_t rotation,
+				   uint64_t tiling,
+				   uint32_t format,
+				   int size,
+				   struct igt_fb *fb /* out */)
+{
+	color_t corners[] = { red, white, yellow, blue };
+	color_t color;
+	unsigned int fb_id;
+	cairo_t *cr;
+	const int qsize = size / 2;
+	int idx;
+
+	fb_id = igt_create_fb(data->drm_fd, size, size, format, tiling, fb);
+	igt_assert(fb_id);
+
+	cr = igt_get_cairo_ctx(data->drm_fd, fb);
+
+	switch (rotation) {
+	case IGT_ROTATION_0:
+		idx = 0;
+		break;
+	case IGT_ROTATION_90:
+		idx = 3;
+		break;
+	case IGT_ROTATION_180:
+		idx = 2;
+		break;
+	case IGT_ROTATION_270:
+		idx = 1;
+		break;
+	default:
+		igt_assert(0);
+	}
+
+	color = corners[idx];
+	igt_paint_color(cr, 0, 0, qsize, qsize,
+			color.red, color.green, color.blue);
+
+	color = corners[(++idx) % 4];
+	igt_paint_color(cr, qsize, 0, qsize, qsize,
+			color.red, color.green, color.blue);
+
+	color = corners[(++idx) % 4];
+	igt_paint_color(cr, qsize, qsize, qsize, qsize,
+			color.red, color.green, color.blue);
+
+	color = corners[(++idx) % 4];
+	igt_paint_color(cr, 0, qsize, qsize, qsize,
+			color.red, color.green, color.blue);
+
+	igt_assert(cairo_status(cr) == 0);
+	cairo_destroy(cr);
+}
+
 enum {
 	TEST_POSITION_FULLY_COVERED = 1 << 0,
 	TEST_DPMS = 1 << 1,
@@ -554,6 +646,427 @@ test_pixel_formats(data_t *data, enum pipe pipe)
 	}
 }
 
+static bool
+bogus_plane_conf(uint32_t devid, igt_plane_t *plane_obj,
+		 int hdisplay, int plane_x, int plane_width)
+{
+	if (!(IS_GEMINILAKE(devid) || IS_CANNONLAKE(devid)))
+		return false;
+
+	if (plane_obj->type == DRM_PLANE_TYPE_CURSOR)
+		return false;
+
+	if (plane_x + plane_width >= CLIPPED_PLANE_MIN_VALID &&
+	    plane_x <= hdisplay - CLIPPED_PLANE_MIN_VALID)
+		return false;
+
+	return true;
+}
+
+static bool
+supported_plane_conf(data_t *data, int plane_type, uint64_t tiling,
+		     uint32_t format, igt_rotation_t rotation,
+		     drmModeModeInfo *mode,
+		     int plane_x, int plane_y, int plane_size)
+{
+	if (intel_gen(data->devid) < 9 &&
+	    tiling != LOCAL_DRM_FORMAT_MOD_NONE)
+		return false;
+
+	/* On GEN<9 the primary plane must cover the full screen. */
+	if (intel_gen(data->devid) < 9 &&
+	    plane_type == DRM_PLANE_TYPE_PRIMARY &&
+	    (plane_x > 0 || plane_y > 0 ||
+	     (plane_x + plane_size < mode->hdisplay) ||
+	     (plane_y + plane_size < mode->vdisplay)))
+		return false;
+
+	if (plane_type == DRM_PLANE_TYPE_CURSOR) {
+		/* For cursor planes only linear/alpha format is supported. */
+		if (tiling != LOCAL_DRM_FORMAT_MOD_NONE ||
+		    format != DRM_FORMAT_ARGB8888)
+			return false;
+
+		if (plane_size > data->max_curw || plane_size > data->max_curh)
+			return false;
+	} else {
+		/*
+		 * For non-cursor planes formats with alpha may result in
+		 * undeterministic CRCs, we use the same sized
+		 * non-alpha XRGB8888 format instead.
+		 */
+		if (format == DRM_FORMAT_ARGB8888)
+			return false;
+
+		if (format == DRM_FORMAT_RGB565 &&
+		    intel_gen(data->devid) < 9 &&
+		    !IS_VALLEYVIEW(data->devid) && !IS_CHERRYVIEW(data->devid))
+			return false;
+	}
+
+	/* RGB565 with rotation is not supported for now. */
+	if (format == DRM_FORMAT_RGB565 && rotation != IGT_ROTATION_0)
+		return false;
+
+	return true;
+}
+
+/*
+ * Create a square reference FB for the whole screen in the clipping test,
+ * with the given test plane position and size. See
+ * create_fb_for_mode__clipping_plane() for the layout of the test plane.
+ */
+static void
+create_fb_for_mode__clipping_display(data_t *data, drmModeModeInfo *mode,
+				     square_t *clip_squares,
+				     int clip_squares_cnt,
+				     struct igt_fb *fb /* out */)
+{
+	int plane;
+	struct igt_fb plane_fbs[4];
+	unsigned int fb_id;
+	cairo_t *cr;
+	cairo_surface_t *srcs[4];
+
+	fb_id = igt_create_fb(data->drm_fd,
+			      mode->hdisplay, mode->vdisplay,
+			      DRM_FORMAT_XRGB8888,
+			      LOCAL_DRM_FORMAT_MOD_NONE,
+			      fb);
+	igt_assert(fb_id);
+
+	cr = igt_get_cairo_ctx(data->drm_fd, fb);
+	igt_paint_color(cr, 0, 0, mode->hdisplay, mode->vdisplay,
+			0, 0, 0);
+
+	for (plane = 0; plane < clip_squares_cnt; plane++) {
+		create_fb_for_mode__clipping_plane(data, IGT_ROTATION_0,
+						   LOCAL_DRM_FORMAT_MOD_NONE,
+						   DRM_FORMAT_XRGB8888,
+						   clip_squares[plane].size,
+						   &plane_fbs[plane]);
+
+		srcs[plane] = igt_get_cairo_surface(data->drm_fd,
+						   &plane_fbs[plane]);
+		cairo_set_source_surface(cr, srcs[plane],
+					 clip_squares[plane].x,
+					 clip_squares[plane].y);
+		cairo_rectangle(cr,
+				clip_squares[plane].x,
+				clip_squares[plane].y,
+				clip_squares[plane].size,
+				clip_squares[plane].size);
+		cairo_fill(cr);
+	}
+
+	igt_assert(cairo_status(cr) == 0);
+	cairo_destroy(cr);
+
+	for (plane = 0; plane < clip_squares_cnt; plane++) {
+		cairo_surface_destroy(srcs[plane]);
+		igt_remove_fb(data->drm_fd, &plane_fbs[plane]);
+	}
+}
+
+static void
+test_plane_clipping_format(data_t *data,
+			   enum pipe pipe,
+			   igt_output_t *output,
+			   drmModeModeInfo *mode,
+			   square_t *clip_squares,
+			   int clip_squares_cnt,
+			   uint64_t tiling,
+			   igt_rotation_t rotation,
+			   uint32_t format,
+			   igt_crc_t *reference_crc)
+{
+	int plane;
+	igt_plane_t *plane_objs[4];
+	struct igt_fb plane_fbs[4];
+	igt_crc_t crc;
+	int ret;
+	bool bogus_planes = false;
+
+	memset(plane_objs, 0, sizeof(plane_objs));
+
+	igt_debug("rotation %s tiling %s format %s\n",
+		  igt_rotation_degrees_str(rotation),
+		  igt_tiling_str(tiling),
+		  igt_format_str(format));
+
+	igt_output_set_pipe(output, pipe);
+
+	for (plane = 0; plane < clip_squares_cnt ; plane++) {
+		igt_plane_t *obj = igt_output_get_plane(output, plane);
+		struct igt_fb *fb = &plane_fbs[plane];
+		int x = clip_squares[plane].x;
+		int y = clip_squares[plane].y;
+		int size = clip_squares[plane].size;
+		uint64_t _tiling = tiling;
+		uint32_t _format = format;
+
+		if (obj->type == DRM_PLANE_TYPE_CURSOR) {
+			_tiling = LOCAL_DRM_FORMAT_MOD_NONE;
+			_format = DRM_FORMAT_ARGB8888;
+		}
+
+		if (!supported_plane_conf(data, obj->type, _tiling, _format,
+					  rotation, mode, x, y, size))
+			goto out;
+
+		create_fb_for_mode__clipping_plane(data, rotation,_tiling,
+						   _format, size, fb);
+
+		igt_plane_set_fb(obj, fb);
+		igt_fb_set_position(fb, obj, 0, 0);
+
+		igt_plane_set_size(obj, size, size);
+		igt_plane_set_rotation(obj, rotation);
+		igt_plane_set_position(obj, x, y);
+
+		plane_objs[plane] = obj;
+	}
+
+	/*
+	 * Note that a universal commit doesn't support full modesets, so we
+	 * have to make sure that the following only needs to commit changes
+	 * that are compatible with a fastset. This should be guaranteed,
+	 * since before calling this function we took the reference CRC which
+	 * left the display enabled with the mode we require here and
+	 * afterwards we only change plane parameters (FB, position, rotation
+	 * etc.).
+	 */
+	ret = igt_display_try_commit2(&data->display, COMMIT_UNIVERSAL);
+
+	for (plane = 0; plane < clip_squares_cnt; plane++) {
+		if(!bogus_plane_conf(data->devid, plane_objs[plane],
+		   mode->hdisplay, clip_squares[plane].x,
+		   clip_squares[plane].size)) {
+			bogus_planes = true;
+			break;
+		}
+	}
+
+	if (bogus_planes) {
+		igt_assert(ret == 0);
+		igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+		igt_assert_crc_equal(reference_crc, &crc);
+	} else {
+		igt_assert(ret == -ERANGE);
+	}
+
+out:
+	for (plane = 0; plane < clip_squares_cnt; plane++) {
+		if (!plane_objs[plane])
+			continue;
+		igt_plane_set_fb(plane_objs[plane], NULL);
+		igt_plane_set_rotation(plane_objs[plane], IGT_ROTATION_0);
+		igt_plane_set_position(plane_objs[plane], 0, 0);
+
+		igt_remove_fb(data->drm_fd, &plane_fbs[plane]);
+	}
+
+	igt_output_set_pipe(output, PIPE_ANY);
+}
+
+static void
+test_plane_clipping_square(data_t *data, enum pipe pipe,
+			   igt_output_t *output, drmModeModeInfo *mode,
+			   square_t *clip_squares, int clip_squares_cnt)
+{
+	const struct {
+		uint64_t tiling;
+		igt_rotation_t rotation;
+	} rotations[] = {
+		{ LOCAL_DRM_FORMAT_MOD_NONE,		IGT_ROTATION_0 },
+
+		{ LOCAL_I915_FORMAT_MOD_X_TILED,	IGT_ROTATION_0 },
+
+		{ LOCAL_I915_FORMAT_MOD_Y_TILED,	IGT_ROTATION_0 },
+		{ LOCAL_I915_FORMAT_MOD_Y_TILED,	IGT_ROTATION_90 },
+		{ LOCAL_I915_FORMAT_MOD_Y_TILED,	IGT_ROTATION_180 },
+		{ LOCAL_I915_FORMAT_MOD_Y_TILED,	IGT_ROTATION_270 },
+
+		{ LOCAL_I915_FORMAT_MOD_Yf_TILED,	IGT_ROTATION_0 },
+		{ LOCAL_I915_FORMAT_MOD_Yf_TILED,	IGT_ROTATION_90 },
+		{ LOCAL_I915_FORMAT_MOD_Yf_TILED,	IGT_ROTATION_180 },
+		{ LOCAL_I915_FORMAT_MOD_Yf_TILED,	IGT_ROTATION_270 },
+	};
+	const uint32_t formats[] = {
+		DRM_FORMAT_RGB565,
+		DRM_FORMAT_XRGB8888,
+		DRM_FORMAT_ARGB8888,
+	};
+
+	igt_fb_t reference_fb;
+	igt_crc_t reference_crc;
+
+	for (int plane = 0; plane < clip_squares_cnt; plane++) {
+		igt_info("Testing connector %s mode %dx%d using pipe %s: %dx%d@%d,%d\n",
+			 igt_output_name(output),
+			 mode->hdisplay, mode->vdisplay,
+			 kmstest_pipe_name(pipe),
+			 clip_squares[plane].size, clip_squares[plane].size,
+			 clip_squares[plane].x, clip_squares[plane].y);
+	}
+
+	test_init(data, pipe);
+
+	create_fb_for_mode__clipping_display(data, mode,
+					     clip_squares,
+					     clip_squares_cnt,
+					     &reference_fb);
+
+	test_grab_crc_for_fb2(data, output, pipe, &reference_fb,
+			      &reference_crc, COMMIT_UNIVERSAL);
+
+	igt_remove_fb(data->drm_fd, &reference_fb);
+
+	for (int rotation = 0; rotation < ARRAY_SIZE(rotations); rotation++)
+		for (int format = 0; format < ARRAY_SIZE(formats); format++)
+			test_plane_clipping_format(data, pipe, output,
+						   mode,
+						   clip_squares,
+						   clip_squares_cnt,
+						   rotations[rotation].tiling,
+						   rotations[rotation].rotation,
+						   formats[format],
+						   &reference_crc);
+
+	test_fini(data);
+}
+
+static void
+test_plane_clipping_squares(data_t *data, enum pipe pipe,
+			    igt_output_t *output, drmModeModeInfo *mode,
+			    square_t *clip_squares, int clip_squares_cnt)
+{
+	switch (clip_squares_cnt) {
+	case 4:
+	    test_plane_clipping_square(data, pipe, output, mode,
+				       clip_squares, clip_squares_cnt);
+	    break;
+	case 2:
+	    test_plane_clipping_square(data, pipe, output, mode,
+				       clip_squares, clip_squares_cnt);
+	    test_plane_clipping_square(data, pipe, output, mode,
+				       clip_squares + clip_squares_cnt,
+				       clip_squares_cnt);
+	    break;
+	case 1:
+	default:
+	    for (int i = 0; i  < 4; i++) {
+		test_plane_clipping_square(data, pipe, output, mode,
+					   clip_squares + i,
+					   clip_squares_cnt);
+	    }
+	    break;
+	}
+}
+
+static void
+test_plane_clipping(data_t *data, enum pipe pipe)
+{
+	igt_output_t *output;
+	int connected_outs = 0;
+
+	for_each_valid_output_on_pipe(&data->display, pipe, output) {
+		drmModeModeInfo *mode;
+		int sq_size;
+		int max_planes = data->display.pipes[pipe].n_planes;
+		int clip_squares_cnt;
+
+		clip_squares_cnt = max_planes >= 4 ?
+				   4 : max_planes >= 2 ? 2 : 1;
+
+		igt_output_set_pipe(output, pipe);
+		mode = igt_output_get_mode(output);
+
+		/*
+		 * Test with a square plane bigger than either the width or
+		 * height of the mode. This should pass on all platforms.
+		 */
+		sq_size = mode->hdisplay > mode->vdisplay ?
+			  mode->hdisplay : mode->vdisplay;
+
+		clip_squares[0].x = -2;
+		clip_squares[0].y = -2;
+		clip_squares[0].size = sq_size + 4;
+
+		test_plane_clipping_square(data, pipe, output, mode,
+					   clip_squares, 1);
+
+		/*
+		 * Test positions in the 4 corners of the screen with a
+		 * CLIPPED_PLANE_MIN_VALID x CLIPPED_PLANE_MIN_VALID square
+		 * visible from the plane. These should pass on all platforms.
+		 */
+		clip_squares[0].x = -CLIPPED_PLANE_SMALL_SIZE +
+				     CLIPPED_PLANE_MIN_VALID;
+		clip_squares[0].y = -CLIPPED_PLANE_SMALL_SIZE +
+				     CLIPPED_PLANE_MIN_VALID;
+		clip_squares[0].size = CLIPPED_PLANE_SMALL_SIZE;
+
+		clip_squares[1].x = -CLIPPED_PLANE_SMALL_SIZE +
+				     CLIPPED_PLANE_MIN_VALID;
+		clip_squares[1].y = mode->vdisplay -
+				    CLIPPED_PLANE_MIN_VALID;
+		clip_squares[1].size = CLIPPED_PLANE_SMALL_SIZE;
+
+		clip_squares[2].x = mode->hdisplay -
+				    CLIPPED_PLANE_MIN_VALID;
+		clip_squares[2].y = -CLIPPED_PLANE_SMALL_SIZE +
+				     CLIPPED_PLANE_MIN_VALID;
+		clip_squares[2].size = CLIPPED_PLANE_SMALL_SIZE;
+
+		clip_squares[3].x = mode->hdisplay -
+				    CLIPPED_PLANE_MIN_VALID;
+		clip_squares[3].y = mode->vdisplay -
+				    CLIPPED_PLANE_MIN_VALID;
+		clip_squares[3].size = CLIPPED_PLANE_SMALL_SIZE;
+
+		test_plane_clipping_squares(data, pipe, output, mode,
+					    clip_squares, clip_squares_cnt);
+
+		/*
+		 * Test positions in the 4 corners of the screen with a
+		 * 2 x 2 square visible from the plane. These are valid on all
+		 * platforms except on GLK/CNL where less than
+		 * CLIPPED_PLANE_MIN_VALID pixels visible on the left/right
+		 * edges of the screen may cause FIFO underflow and display
+		 * corruption.
+		 *
+		 * The cursor plane is an exception without this problem.
+		 *
+		 * Use 2 x 2 size as other (odd) sizes may result in an
+		 * incorrect CRC for the cursor plane even though it displays
+		 * correctly and causes no underflow.
+		 */
+		clip_squares[0].x = -CLIPPED_PLANE_SMALL_SIZE + 2;
+		clip_squares[0].y = -CLIPPED_PLANE_SMALL_SIZE + 2;
+		clip_squares[0].size = CLIPPED_PLANE_SMALL_SIZE;
+
+		clip_squares[1].x = -CLIPPED_PLANE_SMALL_SIZE + 2;
+		clip_squares[1].y = mode->vdisplay - 2;
+		clip_squares[1].size = CLIPPED_PLANE_SMALL_SIZE;
+
+		clip_squares[2].x = mode->hdisplay - 2;
+		clip_squares[2].y = -CLIPPED_PLANE_SMALL_SIZE + 2;
+		clip_squares[2].size = CLIPPED_PLANE_SMALL_SIZE;
+
+		clip_squares[3].x = mode->hdisplay - 2;
+		clip_squares[3].y = mode->vdisplay - 2;
+		clip_squares[3].size = CLIPPED_PLANE_SMALL_SIZE;
+
+		test_plane_clipping_squares(data, pipe, output, mode,
+					    clip_squares, clip_squares_cnt);
+
+		connected_outs++;
+	}
+
+	igt_skip_on(connected_outs == 0);
+}
+
 static void
 run_tests_for_pipe_plane(data_t *data, enum pipe pipe)
 {
@@ -590,6 +1103,9 @@ run_tests_for_pipe_plane(data_t *data, enum pipe pipe)
 		      kmstest_pipe_name(pipe))
 		test_plane_panning(data, pipe, TEST_PANNING_BOTTOM_RIGHT |
 					       TEST_SUSPEND_RESUME);
+	igt_subtest_f("plane-clipping-pipe-%s-planes",
+		      kmstest_pipe_name(pipe))
+		test_plane_clipping(data, pipe);
 }
 
 
@@ -602,8 +1118,21 @@ igt_main
 	igt_skip_on_simulation();
 
 	igt_fixture {
+		int ret;
+
 		data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
 
+		data.devid = intel_get_drm_devid(data.drm_fd);
+
+		data.max_curw = 64;
+		data.max_curh = 64;
+		ret = drmGetCap(data.drm_fd, DRM_CAP_CURSOR_WIDTH,
+				&data.max_curw);
+		igt_assert(ret == 0 || errno == EINVAL);
+		ret = drmGetCap(data.drm_fd, DRM_CAP_CURSOR_HEIGHT,
+				&data.max_curh);
+		igt_assert(ret == 0 || errno == EINVAL);
+
 		kmstest_set_vt_graphics_mode();
 
 		igt_require_pipe_crc(data.drm_fd);
-- 
2.18.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2018-09-05 16:28 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-06 16:52 [igt-dev] [PATCH i-g-t v2 0/4] kms_plane: Add clipping subtests Imre Deak
2018-03-06 16:52 ` [igt-dev] [PATCH v2 1/4] kms_plane: Remove redundant modeset after CRC capture Imre Deak
2018-09-05 16:27   ` [igt-dev] [PATCH i-g-t v3 0/5] kms_plane: Add clipping subtests Gwan-gyeong Mun
2018-09-05 16:27     ` [igt-dev] [PATCH i-g-t v3 1/5] kms_plane: Remove redundant modeset after CRC capture Gwan-gyeong Mun
2018-09-05 16:27     ` [igt-dev] [PATCH i-g-t v3 2/5] lib: Export helpers to get rotation/tiling strings Gwan-gyeong Mun
2018-09-05 16:27     ` [igt-dev] [PATCH i-g-t v3 3/5] kms_plane: Split helpers creating reference FB and capturing CRC Gwan-gyeong Mun
2018-09-05 16:27     ` [igt-dev] [PATCH i-g-t v3 4/5] kms_plane: Add a helper of capturing CRC with commit style Gwan-gyeong Mun
2018-09-05 16:27     ` [igt-dev] [PATCH i-g-t v3 5/5] kms_plane: Add clipping subtests Gwan-gyeong Mun
2018-03-06 16:52 ` [igt-dev] [PATCH v2 2/4] lib: Export helpers to get rotation/tiling strings Imre Deak
2018-03-06 16:52 ` [igt-dev] [PATCH v2 3/4] kms_plane: Split helpers creating reference FB and capturing CRC Imre Deak
2018-03-06 16:52 ` [igt-dev] [PATCH v2 4/4] kms_plane: Add clipping subtests Imre Deak
2018-03-06 17:47 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2018-03-06 22:24 ` [igt-dev] ✗ Fi.CI.IGT: warning " Patchwork
2018-03-07 17:03 ` [igt-dev] [PATCH i-g-t v2 0/4] " Daniel Vetter
2018-03-07 17:29   ` Imre Deak
2018-03-07 20:44     ` Daniel Vetter
2018-03-08 12:35       ` Imre Deak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.