All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t v2 00/12] Chamelium VC4 plane testing, with T-tiled mode
@ 2018-12-13 15:55 Paul Kocialkowski
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 01/12] chamelium: Pass dimensions instead of mode to pattern generation helper Paul Kocialkowski
                   ` (12 more replies)
  0 siblings, 13 replies; 25+ messages in thread
From: Paul Kocialkowski @ 2018-12-13 15:55 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, Boris Brezillon, Thomas Petazzoni

This series introduces the required plumbing for allocating buffers in
the VC4 T-tiled mode and converting to that mode from XR24 linear
buffers.

With that in place, a new Chamelium test is introduced to perform some
testing of planes with randomized properties. It also tests the
VC4-specific VC4-specific T-tiled mode.

This series is based on Maxime Ripard's series:
  igt: chamelium: Test YUV buffers using the Chamelium

Changes since v1:
* Added collected Reviewed-by tags;
* Removed explicit size and constified tiling read order tables;
* Removed unnecessary MAP_FAILED addition in map_bo;
* Added pipe and output helpers to count and iterate planes of a given type;
* Moved CRC debug prints to the chamelium library;
* Fixed destination stride description for igt_fb_convert_with_stride;
* Split planes test into a few sub-routines;
* Removed explicit underrun detection since general error reporting is enough;
* Removed underrun detection bits due to ongoing Chamelium-specific issues;
* Deconfigured planes before removing their framebuffer, avoiding kmsg errors.

Paul Kocialkowski (12):
  chamelium: Pass dimensions instead of mode to pattern generation
    helper
  chamelium: Pass the pattern block size as argument to helpers
  chamelium: Debug-print CRCs when comparing them and dumping frames
  lib: drmtest: Add helpers to check and require the VC4 driver
  lib/igt_fb: Add checks on i915 for i915-specific tiled buffer
    allocation
  lib/igt_fb: Add support for allocating T-tiled VC4 buffers
  lib/igt_vc4: Add helpers for converting linear to T-tiled XRGB buffers
  lib/igt_fb: Add a stride-provisioned fashion of igt_fb_convert
  lib/igt_fb: Add a helper to retreive the plane bpp for a given format
  lib/igt_kms: Add helpers to count and iterate planes from pipe
  lib/igt_kms: Add helpers to count and iterate planes from output
  chamelium: Add a CRC-based display test for randomized planes

 lib/drmtest.c         |  10 ++
 lib/drmtest.h         |   2 +
 lib/igt_chamelium.c   |   7 +
 lib/igt_fb.c          |  87 ++++++++++--
 lib/igt_fb.h          |   4 +
 lib/igt_kms.c         |  84 +++++++++++
 lib/igt_kms.h         |   6 +
 lib/igt_vc4.c         |  96 +++++++++++++
 lib/igt_vc4.h         |   4 +
 tests/kms_chamelium.c | 317 ++++++++++++++++++++++++++++++++++++++++--
 10 files changed, 599 insertions(+), 18 deletions(-)

-- 
2.19.2

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

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

* [igt-dev] [PATCH i-g-t v2 01/12] chamelium: Pass dimensions instead of mode to pattern generation helper
  2018-12-13 15:55 [igt-dev] [PATCH i-g-t v2 00/12] Chamelium VC4 plane testing, with T-tiled mode Paul Kocialkowski
@ 2018-12-13 15:55 ` Paul Kocialkowski
  2018-12-14  8:58   ` Maxime Ripard
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 02/12] chamelium: Pass the pattern block size as argument to helpers Paul Kocialkowski
                   ` (11 subsequent siblings)
  12 siblings, 1 reply; 25+ messages in thread
From: Paul Kocialkowski @ 2018-12-13 15:55 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, Boris Brezillon, Thomas Petazzoni

In order to reuse the pattern generation helper for overlay planes,
let's provide the pattern generation helper with the explicit dimensions
instead of the mode (that only applies to the primary plane).

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
---
 tests/kms_chamelium.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
index 8a9f6bfe9235..b8cab9275bec 100644
--- a/tests/kms_chamelium.c
+++ b/tests/kms_chamelium.c
@@ -504,7 +504,7 @@ static void chamelium_paint_xr24_pattern(uint32_t *data,
 			*(data + i * stride / 4 + j) = colors[((j / 64) + (i / 64)) % 5];
 }
 
-static int chamelium_get_pattern_fb(data_t *data, drmModeModeInfo *mode,
+static int chamelium_get_pattern_fb(data_t *data, size_t width, size_t height,
 				    uint32_t fourcc, struct igt_fb *fb)
 {
 	int fb_id;
@@ -512,15 +512,14 @@ static int chamelium_get_pattern_fb(data_t *data, drmModeModeInfo *mode,
 
 	igt_assert(fourcc == DRM_FORMAT_XRGB8888);
 
-	fb_id = igt_create_fb(data->drm_fd, mode->hdisplay, mode->vdisplay,
-			      fourcc, LOCAL_DRM_FORMAT_MOD_NONE, fb);
+	fb_id = igt_create_fb(data->drm_fd, width, height, fourcc,
+			      LOCAL_DRM_FORMAT_MOD_NONE, fb);
 	igt_assert(fb_id > 0);
 
 	ptr = igt_fb_map_buffer(fb->fd, fb);
 	igt_assert(ptr);
 
-	chamelium_paint_xr24_pattern(ptr, mode->hdisplay, mode->vdisplay,
-				     fb->strides[0]);
+	chamelium_paint_xr24_pattern(ptr, width, height, fb->strides[0]);
 	igt_fb_unmap_buffer(fb, ptr);
 
 	return fb_id;
@@ -541,7 +540,7 @@ static void do_test_display(data_t *data, struct chamelium_port *port,
 	int i, fb_id, captured_frame_count;
 	int frame_id;
 
-	fb_id = chamelium_get_pattern_fb(data, mode,
+	fb_id = chamelium_get_pattern_fb(data, mode->hdisplay, mode->vdisplay,
 					 DRM_FORMAT_XRGB8888, &fb);
 	igt_assert(fb_id > 0);
 
-- 
2.19.2

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

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

* [igt-dev] [PATCH i-g-t v2 02/12] chamelium: Pass the pattern block size as argument to helpers
  2018-12-13 15:55 [igt-dev] [PATCH i-g-t v2 00/12] Chamelium VC4 plane testing, with T-tiled mode Paul Kocialkowski
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 01/12] chamelium: Pass dimensions instead of mode to pattern generation helper Paul Kocialkowski
@ 2018-12-13 15:55 ` Paul Kocialkowski
  2018-12-14  9:00   ` Maxime Ripard
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 03/12] chamelium: Debug-print CRCs when comparing them and dumping frames Paul Kocialkowski
                   ` (10 subsequent siblings)
  12 siblings, 1 reply; 25+ messages in thread
From: Paul Kocialkowski @ 2018-12-13 15:55 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, Boris Brezillon, Thomas Petazzoni

This adds a new block size argument to the pattern generation helpers so
that different sizes of blocks can be used.

In the future, this allows us to use different block sizes when testing
overlay planes, making it visually explicit what is part of the main
plane and what is part of the overlay plane.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
---
 tests/kms_chamelium.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
index b8cab9275bec..7d95a8bc52f3 100644
--- a/tests/kms_chamelium.c
+++ b/tests/kms_chamelium.c
@@ -490,7 +490,7 @@ enable_output(data_t *data,
 
 static void chamelium_paint_xr24_pattern(uint32_t *data,
 					 size_t width, size_t height,
-					 size_t stride)
+					 size_t stride, size_t block_size)
 {
 	uint32_t colors[] = { 0xff000000,
 			      0xffff0000,
@@ -501,11 +501,12 @@ static void chamelium_paint_xr24_pattern(uint32_t *data,
 
 	for (i = 0; i < height; i++)
 		for (j = 0; j < width; j++)
-			*(data + i * stride / 4 + j) = colors[((j / 64) + (i / 64)) % 5];
+			*(data + i * stride / 4 + j) = colors[((j / block_size) + (i / block_size)) % 5];
 }
 
 static int chamelium_get_pattern_fb(data_t *data, size_t width, size_t height,
-				    uint32_t fourcc, struct igt_fb *fb)
+				    uint32_t fourcc, size_t block_size,
+				    struct igt_fb *fb)
 {
 	int fb_id;
 	void *ptr;
@@ -519,7 +520,8 @@ static int chamelium_get_pattern_fb(data_t *data, size_t width, size_t height,
 	ptr = igt_fb_map_buffer(fb->fd, fb);
 	igt_assert(ptr);
 
-	chamelium_paint_xr24_pattern(ptr, width, height, fb->strides[0]);
+	chamelium_paint_xr24_pattern(ptr, width, height, fb->strides[0],
+				     block_size);
 	igt_fb_unmap_buffer(fb, ptr);
 
 	return fb_id;
@@ -541,7 +543,7 @@ static void do_test_display(data_t *data, struct chamelium_port *port,
 	int frame_id;
 
 	fb_id = chamelium_get_pattern_fb(data, mode->hdisplay, mode->vdisplay,
-					 DRM_FORMAT_XRGB8888, &fb);
+					 DRM_FORMAT_XRGB8888, 64, &fb);
 	igt_assert(fb_id > 0);
 
 	frame_id = igt_fb_convert(&frame_fb, &fb, fourcc);
-- 
2.19.2

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

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

* [igt-dev] [PATCH i-g-t v2 03/12] chamelium: Debug-print CRCs when comparing them and dumping frames
  2018-12-13 15:55 [igt-dev] [PATCH i-g-t v2 00/12] Chamelium VC4 plane testing, with T-tiled mode Paul Kocialkowski
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 01/12] chamelium: Pass dimensions instead of mode to pattern generation helper Paul Kocialkowski
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 02/12] chamelium: Pass the pattern block size as argument to helpers Paul Kocialkowski
@ 2018-12-13 15:55 ` Paul Kocialkowski
  2018-12-14  9:00   ` Maxime Ripard
  2018-12-14 19:42   ` Lyude Paul
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 04/12] lib: drmtest: Add helpers to check and require the VC4 driver Paul Kocialkowski
                   ` (9 subsequent siblings)
  12 siblings, 2 replies; 25+ messages in thread
From: Paul Kocialkowski @ 2018-12-13 15:55 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, Boris Brezillon, Thomas Petazzoni

Add debug prints for the reference and captured CRCs when comparing them
and dumping them, which can be useful to get an idea of what is going on
(e.g. specific noise on display cables often only changes one of the
values that compose the CRC).

It's also useful to associate a test debug output with the dumped
pictures (that have the CRC in their name).

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 lib/igt_chamelium.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index d136fb04c342..32b859eac4a7 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -1033,6 +1033,9 @@ void chamelium_assert_crc_eq_or_dump(struct chamelium *chamelium,
 	char *capture_suffix;
 	bool eq;
 
+	igt_debug("Reference CRC: %s\n", igt_crc_to_string(reference_crc));
+	igt_debug("Captured CRC: %s\n", igt_crc_to_string(capture_crc));
+
 	eq = igt_check_crc_equal(reference_crc, capture_crc);
 	if (!eq && igt_frame_dump_is_enabled()) {
 		/* Grab the reference frame from framebuffer */
@@ -1101,6 +1104,10 @@ void chamelium_assert_analog_frame_match_or_dump(struct chamelium *chamelium,
 		capture_crc = chamelium_get_crc_for_area(chamelium, port, 0, 0,
 							 0, 0);
 
+		igt_debug("Reference CRC: %s\n",
+			  igt_crc_to_string(reference_crc));
+		igt_debug("Captured CRC: %s\n", igt_crc_to_string(capture_crc));
+
 		reference_suffix = igt_crc_to_string_extended(reference_crc,
 							      '-', 2);
 		capture_suffix = igt_crc_to_string_extended(capture_crc, '-',
-- 
2.19.2

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

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

* [igt-dev] [PATCH i-g-t v2 04/12] lib: drmtest: Add helpers to check and require the VC4 driver
  2018-12-13 15:55 [igt-dev] [PATCH i-g-t v2 00/12] Chamelium VC4 plane testing, with T-tiled mode Paul Kocialkowski
                   ` (2 preceding siblings ...)
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 03/12] chamelium: Debug-print CRCs when comparing them and dumping frames Paul Kocialkowski
@ 2018-12-13 15:55 ` Paul Kocialkowski
  2018-12-14  9:00   ` Maxime Ripard
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 05/12] lib/igt_fb: Add checks on i915 for i915-specific tiled buffer allocation Paul Kocialkowski
                   ` (8 subsequent siblings)
  12 siblings, 1 reply; 25+ messages in thread
From: Paul Kocialkowski @ 2018-12-13 15:55 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, Boris Brezillon, Thomas Petazzoni

In order to add support for features specific to the VC4 driver, add
helpers for checking and requiring the driver like it's done for the
i915 driver.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
---
 lib/drmtest.c | 10 ++++++++++
 lib/drmtest.h |  2 ++
 2 files changed, 12 insertions(+)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index d2aa1c19154f..53ea75980f2a 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -105,6 +105,11 @@ bool is_i915_device(int fd)
 	return __is_device(fd, "i915");
 }
 
+bool is_vc4_device(int fd)
+{
+	return __is_device(fd, "vc4");
+}
+
 static bool has_known_intel_chipset(int fd)
 {
 	struct drm_i915_getparam gp;
@@ -444,3 +449,8 @@ void igt_require_intel(int fd)
 {
 	igt_require(is_i915_device(fd) && has_known_intel_chipset(fd));
 }
+
+void igt_require_vc4(int fd)
+{
+	igt_require(is_vc4_device(fd));
+}
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 96ee517e2ec1..1d11bff9361c 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -78,8 +78,10 @@ int __drm_open_driver(int chipset);
 void gem_quiescent_gpu(int fd);
 
 void igt_require_intel(int fd);
+void igt_require_vc4(int fd);
 
 bool is_i915_device(int fd);
+bool is_vc4_device(int fd);
 
 /**
  * do_or_die:
-- 
2.19.2

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

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

* [igt-dev] [PATCH i-g-t v2 05/12] lib/igt_fb: Add checks on i915 for i915-specific tiled buffer allocation
  2018-12-13 15:55 [igt-dev] [PATCH i-g-t v2 00/12] Chamelium VC4 plane testing, with T-tiled mode Paul Kocialkowski
                   ` (3 preceding siblings ...)
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 04/12] lib: drmtest: Add helpers to check and require the VC4 driver Paul Kocialkowski
@ 2018-12-13 15:55 ` Paul Kocialkowski
  2018-12-14  9:02   ` Maxime Ripard
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 06/12] lib/igt_fb: Add support for allocating T-tiled VC4 buffers Paul Kocialkowski
                   ` (7 subsequent siblings)
  12 siblings, 1 reply; 25+ messages in thread
From: Paul Kocialkowski @ 2018-12-13 15:55 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, Boris Brezillon, Thomas Petazzoni

The code path for allocating tiled buffers has a few i915-specific bits
without checks for the i915 driver. Add these missing checks.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 lib/igt_fb.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index e314916884d7..73e5c654b8f6 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -298,6 +298,7 @@ static uint32_t calc_plane_stride(struct igt_fb *fb, int plane)
 		(fb->plane_bpp[plane] / 8);
 
 	if (fb->tiling != LOCAL_DRM_FORMAT_MOD_NONE &&
+	    is_i915_device(fb->fd) &&
 	    intel_gen(intel_get_drm_devid(fb->fd)) <= 3) {
 		uint32_t stride;
 
@@ -326,6 +327,7 @@ static uint32_t calc_plane_stride(struct igt_fb *fb, int plane)
 static uint64_t calc_plane_size(struct igt_fb *fb, int plane)
 {
 	if (fb->tiling != LOCAL_DRM_FORMAT_MOD_NONE &&
+	    is_i915_device(fb->fd) &&
 	    intel_gen(intel_get_drm_devid(fb->fd)) <= 3) {
 		uint64_t min_size = (uint64_t) fb->strides[plane] *
 			fb->plane_height[plane];
@@ -1466,7 +1468,7 @@ static void destroy_cairo_surface__gtt(void *arg)
 
 static void *map_bo(int fd, struct igt_fb *fb)
 {
-	void *ptr;
+	void *ptr = NULL;
 
 	if (is_i915_device(fd))
 		gem_set_domain(fd, fb->gem_handle,
@@ -1475,9 +1477,11 @@ static void *map_bo(int fd, struct igt_fb *fb)
 	if (fb->is_dumb)
 		ptr = kmstest_dumb_map_buffer(fd, fb->gem_handle, fb->size,
 					      PROT_READ | PROT_WRITE);
-	else
+	else if (is_i915_device(fd))
 		ptr = gem_mmap__gtt(fd, fb->gem_handle, fb->size,
 				    PROT_READ | PROT_WRITE);
+	else
+		igt_assert(false);
 
 	return ptr;
 }
-- 
2.19.2

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

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

* [igt-dev] [PATCH i-g-t v2 06/12] lib/igt_fb: Add support for allocating T-tiled VC4 buffers
  2018-12-13 15:55 [igt-dev] [PATCH i-g-t v2 00/12] Chamelium VC4 plane testing, with T-tiled mode Paul Kocialkowski
                   ` (4 preceding siblings ...)
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 05/12] lib/igt_fb: Add checks on i915 for i915-specific tiled buffer allocation Paul Kocialkowski
@ 2018-12-13 15:55 ` Paul Kocialkowski
  2018-12-14  9:03   ` Maxime Ripard
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 07/12] lib/igt_vc4: Add helpers for converting linear to T-tiled XRGB buffers Paul Kocialkowski
                   ` (6 subsequent siblings)
  12 siblings, 1 reply; 25+ messages in thread
From: Paul Kocialkowski @ 2018-12-13 15:55 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, Boris Brezillon, Thomas Petazzoni

This introduces the required bits for allocating buffers with a T-tiled
disposition, that is specific to the VC4. It includes calculating the
top-tile width and creating a buffer object with the VC4-specific
helper. The tiling flag is set to the buffer object so that this can
be reused for GPU tests if needed later.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 lib/igt_fb.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 73e5c654b8f6..e5923b8b7745 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -37,6 +37,7 @@
 #include "igt_fb.h"
 #include "igt_kms.h"
 #include "igt_matrix.h"
+#include "igt_vc4.h"
 #include "igt_x86.h"
 #include "ioctl_wrappers.h"
 #include "intel_batchbuffer.h"
@@ -179,6 +180,9 @@ static const struct format_desc_struct *lookup_drm_format(uint32_t drm_format)
 void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp,
 			  unsigned *width_ret, unsigned *height_ret)
 {
+	if (is_vc4_device(fd))
+		tiling = fourcc_mod_broadcom_mod(tiling);
+
 	switch (tiling) {
 	case LOCAL_DRM_FORMAT_MOD_NONE:
 		*width_ret = 64;
@@ -228,6 +232,17 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp,
 			igt_assert(false);
 		}
 		break;
+	case DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED:
+		igt_require_vc4(fd);
+		switch (fb_bpp) {
+		case 32:
+			*width_ret = 32 * fb_bpp / 8;
+			*height_ret = 32;
+			break;
+		default:
+			igt_assert(false);
+		}
+		break;
 	default:
 		igt_assert(false);
 	}
@@ -568,6 +583,13 @@ static int create_bo_for_fb(struct igt_fb *fb)
 
 		if (is_i915_device(fd)) {
 			return i915_create_gem_for_fb(fb);
+		} else if (is_vc4_device(fd)) {
+			fb->gem_handle = igt_vc4_create_bo(fd, fb->size);
+
+			if (fb->tiling == DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED)
+				igt_vc4_set_tiling(fd, fb->gem_handle, fb->tiling);
+
+			return fb->gem_handle;
 		} else {
 			bool driver_has_gem_api = false;
 
@@ -1480,6 +1502,9 @@ static void *map_bo(int fd, struct igt_fb *fb)
 	else if (is_i915_device(fd))
 		ptr = gem_mmap__gtt(fd, fb->gem_handle, fb->size,
 				    PROT_READ | PROT_WRITE);
+	else if (is_vc4_device(fd))
+		ptr = igt_vc4_mmap_bo(fd, fb->gem_handle, fb->size,
+				      PROT_READ | PROT_WRITE);
 	else
 		igt_assert(false);
 
-- 
2.19.2

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

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

* [igt-dev] [PATCH i-g-t v2 07/12] lib/igt_vc4: Add helpers for converting linear to T-tiled XRGB buffers
  2018-12-13 15:55 [igt-dev] [PATCH i-g-t v2 00/12] Chamelium VC4 plane testing, with T-tiled mode Paul Kocialkowski
                   ` (5 preceding siblings ...)
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 06/12] lib/igt_fb: Add support for allocating T-tiled VC4 buffers Paul Kocialkowski
@ 2018-12-13 15:55 ` Paul Kocialkowski
  2018-12-14  9:03   ` Maxime Ripard
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 08/12] lib/igt_fb: Add a stride-provisioned fashion of igt_fb_convert Paul Kocialkowski
                   ` (5 subsequent siblings)
  12 siblings, 1 reply; 25+ messages in thread
From: Paul Kocialkowski @ 2018-12-13 15:55 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, Boris Brezillon, Thomas Petazzoni

In order to integrate testing of T-tiled buffers, the easiest path is to
generate patterns (with the already-existing functions) in linear
buffers and convert them to T-tiled subsequently.

Add helpers to do that conversion, with a first helper that returns the
memory offset for a given position in a T-tiled buffer and a second
helper that uses it for converting between framebuffers.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 lib/igt_vc4.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_vc4.h |  4 +++
 2 files changed, 100 insertions(+)

diff --git a/lib/igt_vc4.c b/lib/igt_vc4.c
index 16dfe67a44b1..ac32f9cd3220 100644
--- a/lib/igt_vc4.c
+++ b/lib/igt_vc4.c
@@ -34,6 +34,7 @@
 #include "drmtest.h"
 #include "igt_aux.h"
 #include "igt_core.h"
+#include "igt_fb.h"
 #include "igt_vc4.h"
 #include "ioctl_wrappers.h"
 #include "intel_reg.h"
@@ -176,3 +177,98 @@ bool igt_vc4_purgeable_bo(int fd, int handle, bool purgeable)
 
 	return arg.retained;
 }
+
+unsigned int igt_vc4_fb_t_tiled_convert(struct igt_fb *dst, struct igt_fb *src)
+{
+	unsigned int fb_id;
+	unsigned int i, j;
+	uint32_t *src_buf;
+	uint32_t *dst_buf;
+	size_t offset;
+
+	igt_assert(src->drm_format == DRM_FORMAT_XRGB8888);
+
+	fb_id = igt_create_fb(src->fd, src->width, src->height, src->drm_format,
+			      DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED, dst);
+	igt_assert(fb_id > 0);
+
+	src_buf = igt_fb_map_buffer(src->fd, src);
+	igt_assert(src_buf);
+
+	dst_buf = igt_fb_map_buffer(dst->fd, dst);
+	igt_assert(dst_buf);
+
+	for (i = 0; i < src->height; i++) {
+		for (j = 0; j < src->width; j++) {
+			offset = igt_vc4_t_tiled_offset(src->width, src->height,
+							src->drm_format, j, i) / 4;
+			*(dst_buf + offset) = *(src_buf +
+						src->strides[0] / 4 * i + j);
+		}
+	}
+
+	igt_fb_unmap_buffer(src, src_buf);
+	igt_fb_unmap_buffer(dst, dst_buf);
+
+	return fb_id;
+}
+
+size_t igt_vc4_t_tiled_offset(size_t width, size_t height, size_t format,
+			      size_t x, size_t y)
+{
+	const size_t t1k_map_even[] = { 0, 3, 1, 2 };
+	const size_t t1k_map_odd[] = { 2, 1, 3, 0 };
+	size_t offset = 0;
+	size_t t4k_w, t4k_x, t4k_y;
+	size_t t1k_x, t1k_y;
+	size_t t64b_x, t64b_y;
+	size_t pix_x, pix_y;
+	unsigned int index;
+
+	igt_assert(format == DRM_FORMAT_XRGB8888);
+
+	/* Width in number of 4K tiles. */
+	t4k_w = ALIGN(width, 32) / 32;
+
+	/* X and y coordinates in number of 4K tiles (32x32). */
+	t4k_x = x / 32;
+	t4k_y = y / 32;
+
+	/* Increase offset to the beginning of the corresponding 4K tile. */
+	offset += t4k_y * t4k_w * 32 * 32;
+
+	/* X and Y coordinates in number of 1K tiles (16x16) within the 4K tile. */
+	t1k_x = (x % 32) / 16;
+	t1k_y = (y % 32) / 16;
+
+	index = 2 * t1k_y + t1k_x;
+
+	if (t4k_y % 2) {
+		/* Odd rows start from the right. */
+		offset += (t4k_w - t4k_x - 1) * 32 * 32;
+		offset += t1k_map_odd[index] * 16 * 16;
+	} else {
+		/* Even rows start from the left. */
+		offset += t4k_x * 32 * 32;
+		offset += t1k_map_even[index] * 16 * 16;
+	}
+
+	/* X and Y coordinates in number of 64 byte tiles (4x4) within the 1K tile. */
+	t64b_x = (x % 16) / 4;
+	t64b_y = (y % 16) / 4;
+
+	/* Increase offset to the beginning of the corresponding 64 byte tile. */
+	offset += t64b_y * 4 * 4 * 4 + t64b_x * 4 * 4;
+
+	/* X and Y coordinates in number of pixels within the 64 byte tile. */
+	pix_x = x % 4;
+	pix_y = y % 4;
+
+	/* Increase offset to the correct pixel. */
+	offset += pix_y * 4 + pix_x;
+
+	/* Multiply by the number of bytes per pixel for the format. */
+	offset *= 4;
+
+	return offset;
+}
diff --git a/lib/igt_vc4.h b/lib/igt_vc4.h
index ebc8a3881b5e..ab44f771d023 100644
--- a/lib/igt_vc4.h
+++ b/lib/igt_vc4.h
@@ -33,4 +33,8 @@ bool igt_vc4_purgeable_bo(int fd, int handle, bool purgeable);
 void igt_vc4_set_tiling(int fd, uint32_t handle, uint64_t modifier);
 uint64_t igt_vc4_get_tiling(int fd, uint32_t handle);
 
+unsigned int igt_vc4_fb_t_tiled_convert(struct igt_fb *dst, struct igt_fb *src);
+size_t igt_vc4_t_tiled_offset(size_t width, size_t height, size_t format,
+			      size_t x, size_t y);
+
 #endif /* IGT_VC4_H */
-- 
2.19.2

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

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

* [igt-dev] [PATCH i-g-t v2 08/12] lib/igt_fb: Add a stride-provisioned fashion of igt_fb_convert
  2018-12-13 15:55 [igt-dev] [PATCH i-g-t v2 00/12] Chamelium VC4 plane testing, with T-tiled mode Paul Kocialkowski
                   ` (6 preceding siblings ...)
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 07/12] lib/igt_vc4: Add helpers for converting linear to T-tiled XRGB buffers Paul Kocialkowski
@ 2018-12-13 15:55 ` Paul Kocialkowski
  2018-12-14  9:05   ` Maxime Ripard
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 09/12] lib/igt_fb: Add a helper to retreive the plane bpp for a given format Paul Kocialkowski
                   ` (4 subsequent siblings)
  12 siblings, 1 reply; 25+ messages in thread
From: Paul Kocialkowski @ 2018-12-13 15:55 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, Boris Brezillon, Thomas Petazzoni

The current implementation of igt_fb_convert does not allow passing
the destination stride, which is something we want to change for tests.

Add a new fashion of this function that allocates the desintation buffer
with a given stride. Since the current function does the same thing with
an unspecified stride (set to zero, which will be filled later), make it
call our new fashion with the stride set to zero to avoid duplication.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
---
 lib/igt_fb.c | 38 ++++++++++++++++++++++++++++++++------
 lib/igt_fb.h |  3 +++
 2 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index e5923b8b7745..fa26753f2ec2 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -2257,14 +2257,15 @@ void igt_remove_fb(int fd, struct igt_fb *fb)
 }
 
 /**
- * igt_fb_convert:
+ * igt_fb_convert_with_stride:
  * @dst: pointer to the #igt_fb structure that will store the conversion result
  * @src: pointer to the #igt_fb structure that stores the frame we convert
  * @dst_fourcc: DRM format specifier to convert to
+ * @dst_stride: Stride for the resulting framebuffer (0 for automatic stride)
  *
  * This will convert a given @src content to the @dst_fourcc format,
  * storing the result in the @dst fb, allocating the @dst fb
- * underlying buffer.
+ * underlying buffer with a stride of @dst_stride stride.
  *
  * Once done with @dst, the caller will have to call igt_remove_fb()
  * on it to free the associated resources.
@@ -2272,15 +2273,18 @@ void igt_remove_fb(int fd, struct igt_fb *fb)
  * Returns:
  * The kms id of the created framebuffer.
  */
-unsigned int igt_fb_convert(struct igt_fb *dst, struct igt_fb *src,
-			    uint32_t dst_fourcc)
+unsigned int igt_fb_convert_with_stride(struct igt_fb *dst, struct igt_fb *src,
+					uint32_t dst_fourcc,
+					unsigned int dst_stride)
 {
 	struct fb_convert cvt = { };
 	void *dst_ptr, *src_ptr;
 	int fb_id;
 
-	fb_id = igt_create_fb(src->fd, src->width, src->height,
-			      dst_fourcc, LOCAL_DRM_FORMAT_MOD_NONE, dst);
+	fb_id = igt_create_fb_with_bo_size(src->fd, src->width, src->height,
+					   dst_fourcc,
+					   LOCAL_DRM_FORMAT_MOD_NONE,
+					   dst, 0, dst_stride);
 	igt_assert(fb_id > 0);
 
 	src_ptr = igt_fb_map_buffer(src->fd, src);
@@ -2301,6 +2305,28 @@ unsigned int igt_fb_convert(struct igt_fb *dst, struct igt_fb *src,
 	return fb_id;
 }
 
+/**
+ * igt_fb_convert:
+ * @dst: pointer to the #igt_fb structure that will store the conversion result
+ * @src: pointer to the #igt_fb structure that stores the frame we convert
+ * @dst_fourcc: DRM format specifier to convert to
+ *
+ * This will convert a given @src content to the @dst_fourcc format,
+ * storing the result in the @dst fb, allocating the @dst fb
+ * underlying buffer.
+ *
+ * Once done with @dst, the caller will have to call igt_remove_fb()
+ * on it to free the associated resources.
+ *
+ * Returns:
+ * The kms id of the created framebuffer.
+ */
+unsigned int igt_fb_convert(struct igt_fb *dst, struct igt_fb *src,
+			    uint32_t dst_fourcc)
+{
+	return igt_fb_convert_with_stride(dst, src, dst_fourcc, 0);
+}
+
 /**
  * igt_bpp_depth_to_drm_format:
  * @bpp: desired bits per pixel
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index 9f027deba842..cb21fdbc77a3 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -130,6 +130,9 @@ unsigned int igt_create_image_fb(int drm_fd,  int width, int height,
 				 struct igt_fb *fb /* out */);
 unsigned int igt_create_stereo_fb(int drm_fd, drmModeModeInfo *mode,
 				  uint32_t format, uint64_t tiling);
+unsigned int igt_fb_convert_with_stride(struct igt_fb *dst, struct igt_fb *src,
+					uint32_t dst_fourcc,
+					unsigned int stride);
 unsigned int igt_fb_convert(struct igt_fb *dst, struct igt_fb *src,
 			    uint32_t dst_fourcc);
 void igt_remove_fb(int fd, struct igt_fb *fb);
-- 
2.19.2

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

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

* [igt-dev] [PATCH i-g-t v2 09/12] lib/igt_fb: Add a helper to retreive the plane bpp for a given format
  2018-12-13 15:55 [igt-dev] [PATCH i-g-t v2 00/12] Chamelium VC4 plane testing, with T-tiled mode Paul Kocialkowski
                   ` (7 preceding siblings ...)
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 08/12] lib/igt_fb: Add a stride-provisioned fashion of igt_fb_convert Paul Kocialkowski
@ 2018-12-13 15:55 ` Paul Kocialkowski
  2018-12-14  9:05   ` Maxime Ripard
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 10/12] lib/igt_kms: Add helpers to count and iterate planes from pipe Paul Kocialkowski
                   ` (3 subsequent siblings)
  12 siblings, 1 reply; 25+ messages in thread
From: Paul Kocialkowski @ 2018-12-13 15:55 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, Boris Brezillon, Thomas Petazzoni

The format bpp for a given plane is stored in the static format_desc
structure and is not accessible to tests, which is inconvenient to
get the minimum stride for a format when testing various strides.

Add a simple helper to expose the information.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
---
 lib/igt_fb.c | 16 ++++++++++++++++
 lib/igt_fb.h |  1 +
 2 files changed, 17 insertions(+)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index fa26753f2ec2..78b958f0fbf8 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -2420,3 +2420,19 @@ bool igt_format_is_yuv(uint32_t drm_format)
 		return false;
 	}
 }
+
+/**
+ * igt_format_plane_bpp:
+ * @drm_format: drm fourcc
+ * @plane: format plane index
+ *
+ * This functions returns the number of bits per pixel for the given @plane
+ * index of the @drm_format.
+ */
+int igt_format_plane_bpp(uint32_t drm_format, int plane)
+{
+	const struct format_desc_struct *format =
+		lookup_drm_format(drm_format);
+
+	return format->plane_bpp[plane];
+}
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index cb21fdbc77a3..a39c4d2fe30e 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -175,6 +175,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);
+int igt_format_plane_bpp(uint32_t drm_format, int plane);
 
 #endif /* __IGT_FB_H__ */
 
-- 
2.19.2

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

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

* [igt-dev] [PATCH i-g-t v2 10/12] lib/igt_kms: Add helpers to count and iterate planes from pipe
  2018-12-13 15:55 [igt-dev] [PATCH i-g-t v2 00/12] Chamelium VC4 plane testing, with T-tiled mode Paul Kocialkowski
                   ` (8 preceding siblings ...)
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 09/12] lib/igt_fb: Add a helper to retreive the plane bpp for a given format Paul Kocialkowski
@ 2018-12-13 15:55 ` Paul Kocialkowski
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 11/12] lib/igt_kms: Add helpers to count and iterate planes from output Paul Kocialkowski
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Paul Kocialkowski @ 2018-12-13 15:55 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, Boris Brezillon, Thomas Petazzoni

This introduces helpers that allow counting how many planes of a given
type are present from a pipe and getting the n-th plane of a given type.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 lib/igt_kms.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_kms.h |  3 +++
 2 files changed, 51 insertions(+)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 684a599ca674..e5c4ee72884a 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -2276,6 +2276,54 @@ igt_plane_t *igt_pipe_get_plane_type(igt_pipe_t *pipe, int plane_type)
 	return &pipe->planes[plane_idx];
 }
 
+/**
+ * igt_pipe_count_plane_type:
+ * @pipe: Target pipe
+ * @plane_type: Cursor, primary or an overlay plane
+ *
+ * Counts the number of planes of type @plane_type for the provided @pipe.
+ *
+ * Returns: The number of planes that match the requested plane type
+ */
+int igt_pipe_count_plane_type(igt_pipe_t *pipe, int plane_type)
+{
+	int i, count = 0;
+
+	for(i = 0; i < pipe->n_planes; i++)
+		if (pipe->planes[i].type == plane_type)
+			count++;
+
+	return count;
+}
+
+/**
+ * igt_pipe_get_plane_type_index:
+ * @pipe: Target pipe
+ * @plane_type: Cursor, primary or an overlay plane
+ * @index: the index of the plane among planes of the same type
+ *
+ * Get the @index th plane of type @plane_type for the provided @pipe.
+ *
+ * Returns: The @index th plane that matches the requested plane type
+ */
+igt_plane_t *igt_pipe_get_plane_type_index(igt_pipe_t *pipe, int plane_type,
+					   int index)
+{
+	int i, type_index = 0;
+
+	for(i = 0; i < pipe->n_planes; i++) {
+		if (pipe->planes[i].type != plane_type)
+			continue;
+
+		if (type_index == index)
+			return &pipe->planes[i];
+
+		type_index++;
+	}
+
+	return NULL;
+}
+
 static bool output_is_internal_panel(igt_output_t *output)
 {
 	switch (output->config.connector->connector_type) {
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 09395360007f..76af8a40a349 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -405,6 +405,9 @@ igt_output_t *igt_output_from_connector(igt_display_t *display,
     drmModeConnector *connector);
 
 igt_plane_t *igt_pipe_get_plane_type(igt_pipe_t *pipe, int plane_type);
+int igt_pipe_count_plane_type(igt_pipe_t *pipe, int plane_type);
+igt_plane_t *igt_pipe_get_plane_type_index(igt_pipe_t *pipe, int plane_type,
+					   int index);
 igt_output_t *igt_get_single_output_for_pipe(igt_display_t *display, enum pipe pipe);
 
 void igt_pipe_request_out_fence(igt_pipe_t *pipe);
-- 
2.19.2

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

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

* [igt-dev] [PATCH i-g-t v2 11/12] lib/igt_kms: Add helpers to count and iterate planes from output
  2018-12-13 15:55 [igt-dev] [PATCH i-g-t v2 00/12] Chamelium VC4 plane testing, with T-tiled mode Paul Kocialkowski
                   ` (9 preceding siblings ...)
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 10/12] lib/igt_kms: Add helpers to count and iterate planes from pipe Paul Kocialkowski
@ 2018-12-13 15:55 ` Paul Kocialkowski
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 12/12] chamelium: Add a CRC-based display test for randomized planes Paul Kocialkowski
  2018-12-13 16:18 ` [igt-dev] ✗ Fi.CI.BAT: failure for Chamelium VC4 plane testing, with T-tiled mode (rev2) Patchwork
  12 siblings, 0 replies; 25+ messages in thread
From: Paul Kocialkowski @ 2018-12-13 15:55 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, Boris Brezillon, Thomas Petazzoni

With helpers to count and iterate among planes of a given type from the
pipe in place, we can use them with the current pipe for the output to
make it possible for tests to use them (the pipe struct is not currently
easily exposed to tests and exposing it adds unnecessary complexity).

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 lib/igt_kms.c | 36 ++++++++++++++++++++++++++++++++++++
 lib/igt_kms.h |  3 +++
 2 files changed, 39 insertions(+)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index e5c4ee72884a..f87c869fd3b7 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -3718,6 +3718,42 @@ igt_plane_t *igt_output_get_plane_type(igt_output_t *output, int plane_type)
 	return igt_pipe_get_plane_type(pipe, plane_type);
 }
 
+/**
+ * igt_output_count_plane_type:
+ * @output: Target output
+ * @plane_type: Cursor, primary or an overlay plane
+ *
+ * Counts the number of planes of type @plane_type for the provided @output.
+ *
+ * Returns: The number of planes that match the requested plane type
+ */
+int igt_output_count_plane_type(igt_output_t *output, int plane_type)
+{
+	igt_pipe_t *pipe = igt_output_get_driving_pipe(output);
+	igt_assert(pipe);
+
+	return igt_pipe_count_plane_type(pipe, plane_type);
+}
+
+/**
+ * igt_output_get_plane_type_index:
+ * @output: Target output
+ * @plane_type: Cursor, primary or an overlay plane
+ * @index: the index of the plane among planes of the same type
+ *
+ * Get the @index th plane of type @plane_type for the provided @output.
+ *
+ * Returns: The @index th plane that matches the requested plane type
+ */
+igt_plane_t *igt_output_get_plane_type_index(igt_output_t *output,
+					     int plane_type, int index)
+{
+	igt_pipe_t *pipe = igt_output_get_driving_pipe(output);
+	igt_assert(pipe);
+
+	return igt_pipe_get_plane_type_index(pipe, plane_type, index);
+}
+
 /**
  * igt_plane_set_fb:
  * @plane: Plane
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 76af8a40a349..8f669178cf43 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -401,6 +401,9 @@ void igt_output_override_mode(igt_output_t *output, drmModeModeInfo *mode);
 void igt_output_set_pipe(igt_output_t *output, enum pipe pipe);
 igt_plane_t *igt_output_get_plane(igt_output_t *output, int plane_idx);
 igt_plane_t *igt_output_get_plane_type(igt_output_t *output, int plane_type);
+int igt_output_count_plane_type(igt_output_t *output, int plane_type);
+igt_plane_t *igt_output_get_plane_type_index(igt_output_t *output,
+					     int plane_type, int index);
 igt_output_t *igt_output_from_connector(igt_display_t *display,
     drmModeConnector *connector);
 
-- 
2.19.2

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

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

* [igt-dev] [PATCH i-g-t v2 12/12] chamelium: Add a CRC-based display test for randomized planes
  2018-12-13 15:55 [igt-dev] [PATCH i-g-t v2 00/12] Chamelium VC4 plane testing, with T-tiled mode Paul Kocialkowski
                   ` (10 preceding siblings ...)
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 11/12] lib/igt_kms: Add helpers to count and iterate planes from output Paul Kocialkowski
@ 2018-12-13 15:55 ` Paul Kocialkowski
  2018-12-14  9:22   ` Maxime Ripard
  2018-12-13 16:18 ` [igt-dev] ✗ Fi.CI.BAT: failure for Chamelium VC4 plane testing, with T-tiled mode (rev2) Patchwork
  12 siblings, 1 reply; 25+ messages in thread
From: Paul Kocialkowski @ 2018-12-13 15:55 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, Boris Brezillon, Thomas Petazzoni

This introduces a new test for the Chamelium, that sets up planes
with randomized properties such as the format, dimensions, position,
in-framebuffer offsets and stride. The Chamelium capture is checked
against the reference generated by cairo with a CRC.

This test also includes testing of the VC4-specific T-tiled mode
(in XR24 format).

Since this test does not share much with previous CRC-based display
tests (especially regarding KMS configuration), most of the code is
not shared with other tests.

This test can be derived with reproducible properties for regression
testing in the future. For now, it serves as a fuzzing test

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 tests/kms_chamelium.c | 296 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 296 insertions(+)

diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
index 7d95a8bc52f3..efd70f0f1b59 100644
--- a/tests/kms_chamelium.c
+++ b/tests/kms_chamelium.c
@@ -26,6 +26,8 @@
 
 #include "config.h"
 #include "igt.h"
+#include "igt_sysfs.h"
+#include "igt_vc4.h"
 
 #include <fcntl.h>
 #include <string.h>
@@ -703,6 +705,295 @@ test_display_frame_dump(data_t *data, struct chamelium_port *port)
 	drmModeFreeConnector(connector);
 }
 
+static uint32_t random_plane_formats[] = {
+	DRM_FORMAT_ABGR8888,
+	DRM_FORMAT_ARGB1555,
+	DRM_FORMAT_ARGB8888,
+	DRM_FORMAT_RGB565,
+	DRM_FORMAT_BGR565,
+	DRM_FORMAT_RGB888,
+	DRM_FORMAT_BGR888,
+	DRM_FORMAT_XBGR8888,
+	DRM_FORMAT_XRGB1555,
+	DRM_FORMAT_XRGB8888,
+};
+
+static void randomize_plane_dimensions(drmModeModeInfo *mode,
+				       uint32_t *width, uint32_t *height,
+				       uint32_t *src_x, uint32_t *src_y,
+				       uint32_t *crtc_w, uint32_t *crtc_h,
+				       int32_t *crtc_x, int32_t *crtc_y)
+{
+	/* Randomize width and height in the mode dimensions range. */
+	*width = (rand() % mode->hdisplay) + 1;
+	*height = (rand() % mode->vdisplay) + 1;
+
+	/*
+	 * Randomize source offset, but keep at least half of the
+	 * original size.
+	 */
+	*src_x = rand() % (*width / 2);
+	*src_y = rand() % (*height / 2);
+
+	/*
+	 * The on-crtc size does not include the source offset, so it
+	 * needs to be subtracted to avoid scaling.
+	 */
+	*crtc_w = *width - *src_x;
+	*crtc_h = *height - *src_y;
+
+	/*
+	 * Randomize the on-crtc position and allow the plane to go
+	 * off-display by up to half of its width and height.
+	 */
+	*crtc_x = (rand() % mode->hdisplay) - *width / 2;
+	*crtc_y = (rand() % mode->vdisplay) - *height / 2;
+}
+
+static void blit_plane_cairo(data_t *data, cairo_surface_t *result,
+			     uint32_t src_x, uint32_t src_y,
+			     uint32_t crtc_w, uint32_t crtc_h,
+			     int32_t crtc_x, int32_t crtc_y,
+			     struct igt_fb *fb)
+{
+	cairo_surface_t *surface;
+	int32_t x, y;
+	cairo_t *cr;
+
+	surface = igt_get_cairo_surface(data->drm_fd, fb);
+
+	x = crtc_x - (int32_t) src_x;
+	y = crtc_y - (int32_t) src_y;
+
+	cr = cairo_create(result);
+
+	cairo_set_source_surface(cr, surface, x, y);
+	cairo_surface_destroy(surface);
+
+	/* Clip the surface to a rectangle if needed. */
+	if (src_x || src_y) {
+		cairo_rectangle(cr, crtc_x, crtc_y, crtc_w, crtc_h);
+		cairo_clip(cr);
+	}
+
+	cairo_paint(cr);
+
+	cairo_destroy(cr);
+}
+
+static void configure_plane(igt_plane_t *plane, uint32_t src_x, uint32_t src_y,
+			    uint32_t crtc_w, uint32_t crtc_h, int32_t crtc_x,
+			    int32_t crtc_y, struct igt_fb *fb)
+{
+	igt_plane_set_fb(plane, fb);
+
+	igt_plane_set_position(plane, crtc_x, crtc_y);
+	igt_plane_set_size(plane, crtc_w, crtc_h);
+
+	igt_fb_set_position(fb, plane, src_x, src_y);
+	/* Framebuffer source size set to on-CRTC size to avoid scaling. */
+	igt_fb_set_size(fb, plane, crtc_w, crtc_h);
+}
+
+static void test_display_planes_random(data_t *data,
+				       struct chamelium_port *port,
+				       enum chamelium_check check)
+{
+	igt_output_t *output;
+	drmModeModeInfo *mode;
+	igt_plane_t *primary_plane;
+	struct igt_fb primary_fb;
+	struct igt_fb result_fb;
+	struct igt_fb *overlay_fbs;
+	igt_crc_t *crc;
+	igt_crc_t *expected_crc;
+	struct chamelium_fb_crc_async_data *fb_crc;
+	unsigned int overlay_planes_max = 0;
+	unsigned int overlay_planes_count;
+	cairo_surface_t *result_surface;
+	int captured_frame_count;
+	unsigned int i;
+	int fb_id;
+
+	igt_assert(check == CHAMELIUM_CHECK_CRC);
+
+	srand(time(NULL));
+
+	reset_state(data, port);
+
+	/* Find the connector and pipe. */
+	output = prepare_output(data, port);
+
+	mode = igt_output_get_mode(output);
+
+	/* Get a framebuffer for the primary plane. */
+	primary_plane = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+	igt_assert(primary_plane);
+
+	fb_id = chamelium_get_pattern_fb(data, mode->hdisplay, mode->vdisplay,
+					 DRM_FORMAT_XRGB8888, 64, &primary_fb);
+	igt_assert(fb_id > 0);
+
+	/* Get a framebuffer for the cairo composition result. */
+	fb_id = igt_create_fb(data->drm_fd, mode->hdisplay,
+			      mode->vdisplay, DRM_FORMAT_XRGB8888,
+			      LOCAL_DRM_FORMAT_MOD_NONE, &result_fb);
+	igt_assert(fb_id > 0);
+
+	result_surface = igt_get_cairo_surface(data->drm_fd, &result_fb);
+
+	/* Paint the primary framebuffer on the result surface. */
+	blit_plane_cairo(data, result_surface, 0, 0, 0, 0, 0, 0, &primary_fb);
+
+	/* Configure the primary plane. */
+	igt_plane_set_fb(primary_plane, &primary_fb);
+
+	overlay_planes_max =
+		igt_output_count_plane_type(output, DRM_PLANE_TYPE_OVERLAY);
+
+	/* Limit the number of planes to a reasonable scene. */
+	if (overlay_planes_max > 4)
+		overlay_planes_max = 4;
+
+	overlay_planes_count = (rand() % overlay_planes_max) + 1;
+	igt_debug("Using %d overlay planes\n", overlay_planes_count);
+
+	overlay_fbs = calloc(sizeof(struct igt_fb), overlay_planes_count);
+
+	for (i = 0; i < overlay_planes_count; i++) {
+		struct igt_fb *overlay_fb = &overlay_fbs[i];
+		igt_plane_t *plane;
+		struct igt_fb pattern_fb;
+		uint32_t overlay_fb_w, overlay_fb_h;
+		int32_t overlay_crtc_x, overlay_crtc_y;
+		uint32_t overlay_crtc_w, overlay_crtc_h;
+		uint32_t overlay_src_x, overlay_src_y;
+		unsigned int index;
+		unsigned int stride_min;
+		unsigned int stride;
+		bool vc4_t_tiled;
+		uint32_t format;
+
+		plane = igt_output_get_plane_type_index(output,
+							DRM_PLANE_TYPE_OVERLAY,
+							i);
+		igt_assert(plane);
+
+		randomize_plane_dimensions(mode, &overlay_fb_w, &overlay_fb_h,
+					   &overlay_src_x, &overlay_src_y,
+					   &overlay_crtc_w, &overlay_crtc_h,
+					   &overlay_crtc_x, &overlay_crtc_y);
+
+		igt_debug("Plane %d: on-crtc size %dx%d\n", i, overlay_crtc_w,
+			  overlay_crtc_h);
+		igt_debug("Plane %d: on-crtc position %dx%d\n", i,
+			  overlay_crtc_x, overlay_crtc_y);
+		igt_debug("Plane %d: in-framebuffer position %dx%d\n", i,
+			  overlay_src_x, overlay_src_y);
+
+		/* Get a pattern framebuffer for the overlay plane. */
+		fb_id = chamelium_get_pattern_fb(data, overlay_fb_w,
+						 overlay_fb_h,
+						 DRM_FORMAT_XRGB8888,
+						 32, &pattern_fb);
+		igt_assert(fb_id > 0);
+
+		/* Randomize the use of tiled mode with a 1/4 probability. */
+		index = rand() % 4;
+
+		if (is_vc4_device(data->drm_fd) && index == 0) {
+			format = DRM_FORMAT_XRGB8888;
+			vc4_t_tiled = true;
+
+			igt_debug("Plane %d: VC4 T-tiled %s format\n", i,
+				  igt_format_str(format));
+		} else {
+			/* Randomize the format to test. */
+			index = rand() % ARRAY_SIZE(random_plane_formats);
+			format = random_plane_formats[index];
+			vc4_t_tiled = false;
+
+			igt_debug("Plane %d: %s format\n", i,
+				  igt_format_str(format));
+		}
+
+		/* Convert the pattern to the test format if needed. */
+		if (vc4_t_tiled) {
+			fb_id = igt_vc4_fb_t_tiled_convert(overlay_fb,
+							   &pattern_fb);
+			igt_assert(fb_id > 0);
+		} else {
+			stride_min = overlay_fb_w *
+				     igt_format_plane_bpp(format, 0) / 8;
+
+			/* Randomize the stride with at most twice the minimum. */
+			stride = (rand() % stride_min) + stride_min;
+
+			/* Pixman requires the stride to be aligned to 32-byte words. */
+			stride = ALIGN(stride, sizeof(uint32_t));
+
+			igt_debug("Plane %d: using stride %d\n", i, stride);
+
+			fb_id = igt_fb_convert_with_stride(overlay_fb,
+							   &pattern_fb,
+							   format, stride);
+			igt_assert(fb_id);
+		}
+
+		blit_plane_cairo(data, result_surface, overlay_src_x,
+				 overlay_src_y, overlay_crtc_w, overlay_crtc_h,
+				 overlay_crtc_x, overlay_crtc_y, &pattern_fb);
+
+		configure_plane(plane, overlay_src_x, overlay_src_y,
+				overlay_crtc_w, overlay_crtc_h, overlay_crtc_x,
+				overlay_crtc_y, overlay_fb);
+
+		/* Remove the original pattern framebuffer. */
+		igt_remove_fb(data->drm_fd, &pattern_fb);
+	}
+
+	cairo_surface_destroy(result_surface);
+
+	fb_crc = chamelium_calculate_fb_crc_async_start(data->drm_fd,
+							&result_fb);
+
+	igt_display_commit2(&data->display, COMMIT_ATOMIC);
+
+	chamelium_capture(data->chamelium, port, 0, 0, 0, 0, 1);
+	crc = chamelium_read_captured_crcs(data->chamelium,
+					   &captured_frame_count);
+
+	igt_assert(captured_frame_count == 1);
+
+	expected_crc = chamelium_calculate_fb_crc_async_finish(fb_crc);
+
+	chamelium_assert_crc_eq_or_dump(data->chamelium,
+					expected_crc, crc,
+					&result_fb, i);
+
+	free(expected_crc);
+	free(crc);
+
+	for (i = 0; i < overlay_planes_count; i++) {
+		struct igt_fb *overlay_fb = &overlay_fbs[i];
+		igt_plane_t *plane;
+
+		plane = igt_output_get_plane_type_index(output,
+							DRM_PLANE_TYPE_OVERLAY,
+							i);
+		igt_assert(plane);
+
+		igt_plane_set_fb(plane, NULL);
+		igt_remove_fb(data->drm_fd, overlay_fb);
+	}
+
+	free(overlay_fbs);
+
+	igt_plane_set_fb(primary_plane, NULL);
+	igt_remove_fb(data->drm_fd, &primary_fb);
+	igt_remove_fb(data->drm_fd, &result_fb);
+}
+
 static void
 test_hpd_without_ddc(data_t *data, struct chamelium_port *port)
 {
@@ -981,6 +1272,11 @@ igt_main
 			test_display_one_mode(&data, port, DRM_FORMAT_NV12,
 					      CHAMELIUM_CHECK_ANALOG, 1);
 
+		connector_subtest("hdmi-crc-planes-random", HDMIA)
+			test_display_planes_random(&data, port,
+						   CHAMELIUM_CHECK_CRC);
+
+
 		connector_subtest("hdmi-frame-dump", HDMIA)
 			test_display_frame_dump(&data, port);
 	}
-- 
2.19.2

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

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

* [igt-dev] ✗ Fi.CI.BAT: failure for Chamelium VC4 plane testing, with T-tiled mode (rev2)
  2018-12-13 15:55 [igt-dev] [PATCH i-g-t v2 00/12] Chamelium VC4 plane testing, with T-tiled mode Paul Kocialkowski
                   ` (11 preceding siblings ...)
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 12/12] chamelium: Add a CRC-based display test for randomized planes Paul Kocialkowski
@ 2018-12-13 16:18 ` Patchwork
  12 siblings, 0 replies; 25+ messages in thread
From: Patchwork @ 2018-12-13 16:18 UTC (permalink / raw)
  To: Paul Kocialkowski; +Cc: igt-dev

== Series Details ==

Series: Chamelium VC4 plane testing, with T-tiled mode (rev2)
URL   : https://patchwork.freedesktop.org/series/53665/
State : failure

== Summary ==

Applying: chamelium: Pass dimensions instead of mode to pattern generation helper
Using index info to reconstruct a base tree...
M	tests/kms_chamelium.c
Falling back to patching base and 3-way merge...
Auto-merging tests/kms_chamelium.c
CONFLICT (content): Merge conflict in tests/kms_chamelium.c
Patch failed at 0001 chamelium: Pass dimensions instead of mode to pattern generation helper
Use 'git am --show-current-patch' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

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

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

* Re: [igt-dev] [PATCH i-g-t v2 01/12] chamelium: Pass dimensions instead of mode to pattern generation helper
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 01/12] chamelium: Pass dimensions instead of mode to pattern generation helper Paul Kocialkowski
@ 2018-12-14  8:58   ` Maxime Ripard
  0 siblings, 0 replies; 25+ messages in thread
From: Maxime Ripard @ 2018-12-14  8:58 UTC (permalink / raw)
  To: Paul Kocialkowski
  Cc: Petri Latvala, Eben Upton, igt-dev, Boris Brezillon, Thomas Petazzoni


[-- Attachment #1.1: Type: text/plain, Size: 557 bytes --]

On Thu, Dec 13, 2018 at 04:55:22PM +0100, Paul Kocialkowski wrote:
> In order to reuse the pattern generation helper for overlay planes,
> let's provide the pattern generation helper with the explicit dimensions
> instead of the mode (that only applies to the primary plane).
> 
> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> Reviewed-by: Lyude Paul <lyude@redhat.com>

Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.com>

Maxime

-- 
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

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

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

* Re: [igt-dev] [PATCH i-g-t v2 02/12] chamelium: Pass the pattern block size as argument to helpers
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 02/12] chamelium: Pass the pattern block size as argument to helpers Paul Kocialkowski
@ 2018-12-14  9:00   ` Maxime Ripard
  0 siblings, 0 replies; 25+ messages in thread
From: Maxime Ripard @ 2018-12-14  9:00 UTC (permalink / raw)
  To: Paul Kocialkowski
  Cc: Petri Latvala, Eben Upton, igt-dev, Boris Brezillon, Thomas Petazzoni


[-- Attachment #1.1: Type: text/plain, Size: 1616 bytes --]

On Thu, Dec 13, 2018 at 04:55:23PM +0100, Paul Kocialkowski wrote:
> This adds a new block size argument to the pattern generation helpers so
> that different sizes of blocks can be used.
> 
> In the future, this allows us to use different block sizes when testing
> overlay planes, making it visually explicit what is part of the main
> plane and what is part of the overlay plane.
> 
> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> Reviewed-by: Lyude Paul <lyude@redhat.com>
> ---
>  tests/kms_chamelium.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
> index b8cab9275bec..7d95a8bc52f3 100644
> --- a/tests/kms_chamelium.c
> +++ b/tests/kms_chamelium.c
> @@ -490,7 +490,7 @@ enable_output(data_t *data,
>  
>  static void chamelium_paint_xr24_pattern(uint32_t *data,
>  					 size_t width, size_t height,
> -					 size_t stride)
> +					 size_t stride, size_t block_size)
>  {
>  	uint32_t colors[] = { 0xff000000,
>  			      0xffff0000,
> @@ -501,11 +501,12 @@ static void chamelium_paint_xr24_pattern(uint32_t *data,
>  
>  	for (i = 0; i < height; i++)
>  		for (j = 0; j < width; j++)
> -			*(data + i * stride / 4 + j) = colors[((j / 64) + (i / 64)) % 5];
> +			*(data + i * stride / 4 + j) = colors[((j / block_size) + (i / block_size)) % 5];

That line really doesn't fit on 80 characters anymore. I guess you
could split the pointer arithmetic to a new line.

Maxime

-- 
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

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

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

* Re: [igt-dev] [PATCH i-g-t v2 03/12] chamelium: Debug-print CRCs when comparing them and dumping frames
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 03/12] chamelium: Debug-print CRCs when comparing them and dumping frames Paul Kocialkowski
@ 2018-12-14  9:00   ` Maxime Ripard
  2018-12-14 19:42   ` Lyude Paul
  1 sibling, 0 replies; 25+ messages in thread
From: Maxime Ripard @ 2018-12-14  9:00 UTC (permalink / raw)
  To: Paul Kocialkowski
  Cc: Petri Latvala, Eben Upton, igt-dev, Boris Brezillon, Thomas Petazzoni


[-- Attachment #1.1: Type: text/plain, Size: 676 bytes --]

On Thu, Dec 13, 2018 at 04:55:24PM +0100, Paul Kocialkowski wrote:
> Add debug prints for the reference and captured CRCs when comparing them
> and dumping them, which can be useful to get an idea of what is going on
> (e.g. specific noise on display cables often only changes one of the
> values that compose the CRC).
> 
> It's also useful to associate a test debug output with the dumped
> pictures (that have the CRC in their name).
> 
> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>

Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.com>

Maxime

-- 
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

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

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

* Re: [igt-dev] [PATCH i-g-t v2 04/12] lib: drmtest: Add helpers to check and require the VC4 driver
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 04/12] lib: drmtest: Add helpers to check and require the VC4 driver Paul Kocialkowski
@ 2018-12-14  9:00   ` Maxime Ripard
  0 siblings, 0 replies; 25+ messages in thread
From: Maxime Ripard @ 2018-12-14  9:00 UTC (permalink / raw)
  To: Paul Kocialkowski
  Cc: Petri Latvala, Eben Upton, igt-dev, Boris Brezillon, Thomas Petazzoni


[-- Attachment #1.1: Type: text/plain, Size: 505 bytes --]

On Thu, Dec 13, 2018 at 04:55:25PM +0100, Paul Kocialkowski wrote:
> In order to add support for features specific to the VC4 driver, add
> helpers for checking and requiring the driver like it's done for the
> i915 driver.
> 
> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> Reviewed-by: Lyude Paul <lyude@redhat.com>

Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.com>

Maxime

-- 
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

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

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

* Re: [igt-dev] [PATCH i-g-t v2 05/12] lib/igt_fb: Add checks on i915 for i915-specific tiled buffer allocation
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 05/12] lib/igt_fb: Add checks on i915 for i915-specific tiled buffer allocation Paul Kocialkowski
@ 2018-12-14  9:02   ` Maxime Ripard
  0 siblings, 0 replies; 25+ messages in thread
From: Maxime Ripard @ 2018-12-14  9:02 UTC (permalink / raw)
  To: Paul Kocialkowski
  Cc: Petri Latvala, Eben Upton, igt-dev, Boris Brezillon, Thomas Petazzoni


[-- Attachment #1.1: Type: text/plain, Size: 2068 bytes --]

On Thu, Dec 13, 2018 at 04:55:26PM +0100, Paul Kocialkowski wrote:
> The code path for allocating tiled buffers has a few i915-specific bits
> without checks for the i915 driver. Add these missing checks.
> 
> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> ---
>  lib/igt_fb.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
> index e314916884d7..73e5c654b8f6 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -298,6 +298,7 @@ static uint32_t calc_plane_stride(struct igt_fb *fb, int plane)
>  		(fb->plane_bpp[plane] / 8);
>  
>  	if (fb->tiling != LOCAL_DRM_FORMAT_MOD_NONE &&
> +	    is_i915_device(fb->fd) &&
>  	    intel_gen(intel_get_drm_devid(fb->fd)) <= 3) {
>  		uint32_t stride;
>  
> @@ -326,6 +327,7 @@ static uint32_t calc_plane_stride(struct igt_fb *fb, int plane)
>  static uint64_t calc_plane_size(struct igt_fb *fb, int plane)
>  {
>  	if (fb->tiling != LOCAL_DRM_FORMAT_MOD_NONE &&
> +	    is_i915_device(fb->fd) &&
>  	    intel_gen(intel_get_drm_devid(fb->fd)) <= 3) {
>  		uint64_t min_size = (uint64_t) fb->strides[plane] *
>  			fb->plane_height[plane];
> @@ -1466,7 +1468,7 @@ static void destroy_cairo_surface__gtt(void *arg)
>  
>  static void *map_bo(int fd, struct igt_fb *fb)
>  {
> -	void *ptr;
> +	void *ptr = NULL;
>  
>  	if (is_i915_device(fd))
>  		gem_set_domain(fd, fb->gem_handle,
> @@ -1475,9 +1477,11 @@ static void *map_bo(int fd, struct igt_fb *fb)
>  	if (fb->is_dumb)
>  		ptr = kmstest_dumb_map_buffer(fd, fb->gem_handle, fb->size,
>  					      PROT_READ | PROT_WRITE);
> -	else
> +	else if (is_i915_device(fd))
>  		ptr = gem_mmap__gtt(fd, fb->gem_handle, fb->size,
>  				    PROT_READ | PROT_WRITE);
> +	else
> +		igt_assert(false);
>  
>  	return ptr;

You're not using that variable unless it has been assigned, so you
shouldn't need to set it to NULL. Did gcc put a warning?

Maxime

-- 
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

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

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

* Re: [igt-dev] [PATCH i-g-t v2 06/12] lib/igt_fb: Add support for allocating T-tiled VC4 buffers
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 06/12] lib/igt_fb: Add support for allocating T-tiled VC4 buffers Paul Kocialkowski
@ 2018-12-14  9:03   ` Maxime Ripard
  0 siblings, 0 replies; 25+ messages in thread
From: Maxime Ripard @ 2018-12-14  9:03 UTC (permalink / raw)
  To: Paul Kocialkowski
  Cc: Petri Latvala, Eben Upton, igt-dev, Boris Brezillon, Thomas Petazzoni


[-- Attachment #1.1: Type: text/plain, Size: 632 bytes --]

On Thu, Dec 13, 2018 at 04:55:27PM +0100, Paul Kocialkowski wrote:
> This introduces the required bits for allocating buffers with a T-tiled
> disposition, that is specific to the VC4. It includes calculating the
> top-tile width and creating a buffer object with the VC4-specific
> helper. The tiling flag is set to the buffer object so that this can
> be reused for GPU tests if needed later.
> 
> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>

Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.com>

Maxime

-- 
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

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

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

* Re: [igt-dev] [PATCH i-g-t v2 07/12] lib/igt_vc4: Add helpers for converting linear to T-tiled XRGB buffers
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 07/12] lib/igt_vc4: Add helpers for converting linear to T-tiled XRGB buffers Paul Kocialkowski
@ 2018-12-14  9:03   ` Maxime Ripard
  0 siblings, 0 replies; 25+ messages in thread
From: Maxime Ripard @ 2018-12-14  9:03 UTC (permalink / raw)
  To: Paul Kocialkowski
  Cc: Petri Latvala, Eben Upton, igt-dev, Boris Brezillon, Thomas Petazzoni


[-- Attachment #1.1: Type: text/plain, Size: 707 bytes --]

On Thu, Dec 13, 2018 at 04:55:28PM +0100, Paul Kocialkowski wrote:
> In order to integrate testing of T-tiled buffers, the easiest path is to
> generate patterns (with the already-existing functions) in linear
> buffers and convert them to T-tiled subsequently.
> 
> Add helpers to do that conversion, with a first helper that returns the
> memory offset for a given position in a T-tiled buffer and a second
> helper that uses it for converting between framebuffers.
> 
> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>

Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.com>

Maxime

-- 
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

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

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

* Re: [igt-dev] [PATCH i-g-t v2 08/12] lib/igt_fb: Add a stride-provisioned fashion of igt_fb_convert
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 08/12] lib/igt_fb: Add a stride-provisioned fashion of igt_fb_convert Paul Kocialkowski
@ 2018-12-14  9:05   ` Maxime Ripard
  0 siblings, 0 replies; 25+ messages in thread
From: Maxime Ripard @ 2018-12-14  9:05 UTC (permalink / raw)
  To: Paul Kocialkowski
  Cc: Petri Latvala, Eben Upton, igt-dev, Boris Brezillon, Thomas Petazzoni


[-- Attachment #1.1: Type: text/plain, Size: 797 bytes --]

On Thu, Dec 13, 2018 at 04:55:29PM +0100, Paul Kocialkowski wrote:
> The current implementation of igt_fb_convert does not allow passing
> the destination stride, which is something we want to change for tests.
> 
> Add a new fashion of this function that allocates the desintation buffer
> with a given stride. Since the current function does the same thing with
> an unspecified stride (set to zero, which will be filled later), make it
> call our new fashion with the stride set to zero to avoid duplication.
> 
> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> Reviewed-by: Lyude Paul <lyude@redhat.com>

Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.com>

Maxime

-- 
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

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

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

* Re: [igt-dev] [PATCH i-g-t v2 09/12] lib/igt_fb: Add a helper to retreive the plane bpp for a given format
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 09/12] lib/igt_fb: Add a helper to retreive the plane bpp for a given format Paul Kocialkowski
@ 2018-12-14  9:05   ` Maxime Ripard
  0 siblings, 0 replies; 25+ messages in thread
From: Maxime Ripard @ 2018-12-14  9:05 UTC (permalink / raw)
  To: Paul Kocialkowski
  Cc: Petri Latvala, Eben Upton, igt-dev, Boris Brezillon, Thomas Petazzoni


[-- Attachment #1.1: Type: text/plain, Size: 610 bytes --]

On Thu, Dec 13, 2018 at 04:55:30PM +0100, Paul Kocialkowski wrote:
> The format bpp for a given plane is stored in the static format_desc
> structure and is not accessible to tests, which is inconvenient to
> get the minimum stride for a format when testing various strides.
> 
> Add a simple helper to expose the information.
> 
> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> Reviewed-by: Lyude Paul <lyude@redhat.com>

Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.com>

Maxime

-- 
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

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

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

* Re: [igt-dev] [PATCH i-g-t v2 12/12] chamelium: Add a CRC-based display test for randomized planes
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 12/12] chamelium: Add a CRC-based display test for randomized planes Paul Kocialkowski
@ 2018-12-14  9:22   ` Maxime Ripard
  0 siblings, 0 replies; 25+ messages in thread
From: Maxime Ripard @ 2018-12-14  9:22 UTC (permalink / raw)
  To: Paul Kocialkowski
  Cc: Petri Latvala, Eben Upton, igt-dev, Boris Brezillon, Thomas Petazzoni


[-- Attachment #1.1: Type: text/plain, Size: 11338 bytes --]

Hi,

On Thu, Dec 13, 2018 at 04:55:33PM +0100, Paul Kocialkowski wrote:
> This introduces a new test for the Chamelium, that sets up planes
> with randomized properties such as the format, dimensions, position,
> in-framebuffer offsets and stride. The Chamelium capture is checked
> against the reference generated by cairo with a CRC.
> 
> This test also includes testing of the VC4-specific T-tiled mode
> (in XR24 format).
> 
> Since this test does not share much with previous CRC-based display
> tests (especially regarding KMS configuration), most of the code is
> not shared with other tests.
> 
> This test can be derived with reproducible properties for regression
> testing in the future. For now, it serves as a fuzzing test
> 
> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>

I'm really wondering if we shouldn't just move the common functions
(like enable_output) to lib, and create a new file for this test.

This test is quite unusual since it's an exploratory test, where you
want to test values that will break, while the rest of the tests in
that file are regression tests.

> ---
>  tests/kms_chamelium.c | 296 ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 296 insertions(+)
> 
> diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
> index 7d95a8bc52f3..efd70f0f1b59 100644
> --- a/tests/kms_chamelium.c
> +++ b/tests/kms_chamelium.c
> @@ -26,6 +26,8 @@
>  
>  #include "config.h"
>  #include "igt.h"
> +#include "igt_sysfs.h"
> +#include "igt_vc4.h"
>  
>  #include <fcntl.h>
>  #include <string.h>
> @@ -703,6 +705,295 @@ test_display_frame_dump(data_t *data, struct chamelium_port *port)
>  	drmModeFreeConnector(connector);
>  }
>  
> +static uint32_t random_plane_formats[] = {
> +	DRM_FORMAT_ABGR8888,
> +	DRM_FORMAT_ARGB1555,
> +	DRM_FORMAT_ARGB8888,
> +	DRM_FORMAT_RGB565,
> +	DRM_FORMAT_BGR565,
> +	DRM_FORMAT_RGB888,
> +	DRM_FORMAT_BGR888,
> +	DRM_FORMAT_XBGR8888,
> +	DRM_FORMAT_XRGB1555,
> +	DRM_FORMAT_XRGB8888,
> +};

I guess we should make this generic to whatever is supported by
igt_convert and the hardware?

> +static void randomize_plane_dimensions(drmModeModeInfo *mode,
> +				       uint32_t *width, uint32_t *height,
> +				       uint32_t *src_x, uint32_t *src_y,
> +				       uint32_t *crtc_w, uint32_t *crtc_h,
> +				       int32_t *crtc_x, int32_t *crtc_y)
> +{
> +	/* Randomize width and height in the mode dimensions range. */
> +	*width = (rand() % mode->hdisplay) + 1;
> +	*height = (rand() % mode->vdisplay) + 1;
> +
> +	/*
> +	 * Randomize source offset, but keep at least half of the
> +	 * original size.
> +	 */
> +	*src_x = rand() % (*width / 2);
> +	*src_y = rand() % (*height / 2);
> +
> +	/*
> +	 * The on-crtc size does not include the source offset, so it
> +	 * needs to be subtracted to avoid scaling.
> +	 */
> +	*crtc_w = *width - *src_x;
> +	*crtc_h = *height - *src_y;
> +
> +	/*
> +	 * Randomize the on-crtc position and allow the plane to go
> +	 * off-display by up to half of its width and height.
> +	 */
> +	*crtc_x = (rand() % mode->hdisplay) - *width / 2;
> +	*crtc_y = (rand() % mode->vdisplay) - *height / 2;
> +}
> +
> +static void blit_plane_cairo(data_t *data, cairo_surface_t *result,
> +			     uint32_t src_x, uint32_t src_y,
> +			     uint32_t crtc_w, uint32_t crtc_h,
> +			     int32_t crtc_x, int32_t crtc_y,
> +			     struct igt_fb *fb)
> +{
> +	cairo_surface_t *surface;
> +	int32_t x, y;
> +	cairo_t *cr;
> +
> +	surface = igt_get_cairo_surface(data->drm_fd, fb);
> +
> +	x = crtc_x - (int32_t) src_x;
> +	y = crtc_y - (int32_t) src_y;
> +
> +	cr = cairo_create(result);
> +
> +	cairo_set_source_surface(cr, surface, x, y);
> +	cairo_surface_destroy(surface);
> +
> +	/* Clip the surface to a rectangle if needed. */
> +	if (src_x || src_y) {
> +		cairo_rectangle(cr, crtc_x, crtc_y, crtc_w, crtc_h);
> +		cairo_clip(cr);
> +	}
> +
> +	cairo_paint(cr);
> +
> +	cairo_destroy(cr);
> +}
> +
> +static void configure_plane(igt_plane_t *plane, uint32_t src_x, uint32_t src_y,
> +			    uint32_t crtc_w, uint32_t crtc_h, int32_t crtc_x,
> +			    int32_t crtc_y, struct igt_fb *fb)
> +{
> +	igt_plane_set_fb(plane, fb);
> +
> +	igt_plane_set_position(plane, crtc_x, crtc_y);
> +	igt_plane_set_size(plane, crtc_w, crtc_h);
> +
> +	igt_fb_set_position(fb, plane, src_x, src_y);
> +	/* Framebuffer source size set to on-CRTC size to avoid scaling. */
> +	igt_fb_set_size(fb, plane, crtc_w, crtc_h);
> +}
> +
> +static void test_display_planes_random(data_t *data,
> +				       struct chamelium_port *port,
> +				       enum chamelium_check check)
> +{
> +	igt_output_t *output;
> +	drmModeModeInfo *mode;
> +	igt_plane_t *primary_plane;
> +	struct igt_fb primary_fb;
> +	struct igt_fb result_fb;
> +	struct igt_fb *overlay_fbs;
> +	igt_crc_t *crc;
> +	igt_crc_t *expected_crc;
> +	struct chamelium_fb_crc_async_data *fb_crc;
> +	unsigned int overlay_planes_max = 0;
> +	unsigned int overlay_planes_count;
> +	cairo_surface_t *result_surface;
> +	int captured_frame_count;
> +	unsigned int i;
> +	int fb_id;
> +
> +	igt_assert(check == CHAMELIUM_CHECK_CRC);
> +
> +	srand(time(NULL));
> +
> +	reset_state(data, port);
> +
> +	/* Find the connector and pipe. */
> +	output = prepare_output(data, port);
> +
> +	mode = igt_output_get_mode(output);
> +
> +	/* Get a framebuffer for the primary plane. */
> +	primary_plane = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
> +	igt_assert(primary_plane);
> +
> +	fb_id = chamelium_get_pattern_fb(data, mode->hdisplay, mode->vdisplay,
> +					 DRM_FORMAT_XRGB8888, 64, &primary_fb);
> +	igt_assert(fb_id > 0);
> +
> +	/* Get a framebuffer for the cairo composition result. */
> +	fb_id = igt_create_fb(data->drm_fd, mode->hdisplay,
> +			      mode->vdisplay, DRM_FORMAT_XRGB8888,
> +			      LOCAL_DRM_FORMAT_MOD_NONE, &result_fb);
> +	igt_assert(fb_id > 0);
> +
> +	result_surface = igt_get_cairo_surface(data->drm_fd, &result_fb);
> +
> +	/* Paint the primary framebuffer on the result surface. */
> +	blit_plane_cairo(data, result_surface, 0, 0, 0, 0, 0, 0, &primary_fb);
> +
> +	/* Configure the primary plane. */
> +	igt_plane_set_fb(primary_plane, &primary_fb);
> +
> +	overlay_planes_max =
> +		igt_output_count_plane_type(output, DRM_PLANE_TYPE_OVERLAY);
> +
> +	/* Limit the number of planes to a reasonable scene. */
> +	if (overlay_planes_max > 4)
> +		overlay_planes_max = 4;
> +
> +	overlay_planes_count = (rand() % overlay_planes_max) + 1;
> +	igt_debug("Using %d overlay planes\n", overlay_planes_count);
> +
> +	overlay_fbs = calloc(sizeof(struct igt_fb), overlay_planes_count);
> +
> +	for (i = 0; i < overlay_planes_count; i++) {
> +		struct igt_fb *overlay_fb = &overlay_fbs[i];
> +		igt_plane_t *plane;
> +		struct igt_fb pattern_fb;
> +		uint32_t overlay_fb_w, overlay_fb_h;
> +		int32_t overlay_crtc_x, overlay_crtc_y;
> +		uint32_t overlay_crtc_w, overlay_crtc_h;
> +		uint32_t overlay_src_x, overlay_src_y;
> +		unsigned int index;
> +		unsigned int stride_min;
> +		unsigned int stride;
> +		bool vc4_t_tiled;
> +		uint32_t format;
> +
> +		plane = igt_output_get_plane_type_index(output,
> +							DRM_PLANE_TYPE_OVERLAY,
> +							i);
> +		igt_assert(plane);
> +
> +		randomize_plane_dimensions(mode, &overlay_fb_w, &overlay_fb_h,
> +					   &overlay_src_x, &overlay_src_y,
> +					   &overlay_crtc_w, &overlay_crtc_h,
> +					   &overlay_crtc_x, &overlay_crtc_y);
> +
> +		igt_debug("Plane %d: on-crtc size %dx%d\n", i, overlay_crtc_w,
> +			  overlay_crtc_h);
> +		igt_debug("Plane %d: on-crtc position %dx%d\n", i,
> +			  overlay_crtc_x, overlay_crtc_y);
> +		igt_debug("Plane %d: in-framebuffer position %dx%d\n", i,
> +			  overlay_src_x, overlay_src_y);
> +
> +		/* Get a pattern framebuffer for the overlay plane. */
> +		fb_id = chamelium_get_pattern_fb(data, overlay_fb_w,
> +						 overlay_fb_h,
> +						 DRM_FORMAT_XRGB8888,
> +						 32, &pattern_fb);
> +		igt_assert(fb_id > 0);
> +
> +		/* Randomize the use of tiled mode with a 1/4 probability. */
> +		index = rand() % 4;
> +
> +		if (is_vc4_device(data->drm_fd) && index == 0) {
> +			format = DRM_FORMAT_XRGB8888;
> +			vc4_t_tiled = true;
> +
> +			igt_debug("Plane %d: VC4 T-tiled %s format\n", i,
> +				  igt_format_str(format));
> +		} else {
> +			/* Randomize the format to test. */
> +			index = rand() % ARRAY_SIZE(random_plane_formats);
> +			format = random_plane_formats[index];
> +			vc4_t_tiled = false;
> +
> +			igt_debug("Plane %d: %s format\n", i,
> +				  igt_format_str(format));
> +		}
> +
> +		/* Convert the pattern to the test format if needed. */
> +		if (vc4_t_tiled) {
> +			fb_id = igt_vc4_fb_t_tiled_convert(overlay_fb,
> +							   &pattern_fb);
> +			igt_assert(fb_id > 0);
> +		} else {
> +			stride_min = overlay_fb_w *
> +				     igt_format_plane_bpp(format, 0) / 8;
> +
> +			/* Randomize the stride with at most twice the minimum. */
> +			stride = (rand() % stride_min) + stride_min;
> +
> +			/* Pixman requires the stride to be aligned to 32-byte words. */
> +			stride = ALIGN(stride, sizeof(uint32_t));
> +
> +			igt_debug("Plane %d: using stride %d\n", i, stride);
> +
> +			fb_id = igt_fb_convert_with_stride(overlay_fb,
> +							   &pattern_fb,
> +							   format, stride);
> +			igt_assert(fb_id);
> +		}
> +
> +		blit_plane_cairo(data, result_surface, overlay_src_x,
> +				 overlay_src_y, overlay_crtc_w, overlay_crtc_h,
> +				 overlay_crtc_x, overlay_crtc_y, &pattern_fb);
> +
> +		configure_plane(plane, overlay_src_x, overlay_src_y,
> +				overlay_crtc_w, overlay_crtc_h, overlay_crtc_x,
> +				overlay_crtc_y, overlay_fb);
> +
> +		/* Remove the original pattern framebuffer. */
> +		igt_remove_fb(data->drm_fd, &pattern_fb);
> +	}
> +
> +	cairo_surface_destroy(result_surface);
> +
> +	fb_crc = chamelium_calculate_fb_crc_async_start(data->drm_fd,
> +							&result_fb);
> +
> +	igt_display_commit2(&data->display, COMMIT_ATOMIC);
> +
> +	chamelium_capture(data->chamelium, port, 0, 0, 0, 0, 1);
> +	crc = chamelium_read_captured_crcs(data->chamelium,
> +					   &captured_frame_count);
> +
> +	igt_assert(captured_frame_count == 1);
> +
> +	expected_crc = chamelium_calculate_fb_crc_async_finish(fb_crc);
> +
> +	chamelium_assert_crc_eq_or_dump(data->chamelium,
> +					expected_crc, crc,
> +					&result_fb, i);
> +
> +	free(expected_crc);
> +	free(crc);
> +
> +	for (i = 0; i < overlay_planes_count; i++) {
> +		struct igt_fb *overlay_fb = &overlay_fbs[i];
> +		igt_plane_t *plane;
> +
> +		plane = igt_output_get_plane_type_index(output,
> +							DRM_PLANE_TYPE_OVERLAY,
> +							i);
> +		igt_assert(plane);
> +
> +		igt_plane_set_fb(plane, NULL);
> +		igt_remove_fb(data->drm_fd, overlay_fb);
> +	}
> +
> +	free(overlay_fbs);
> +
> +	igt_plane_set_fb(primary_plane, NULL);
> +	igt_remove_fb(data->drm_fd, &primary_fb);
> +	igt_remove_fb(data->drm_fd, &result_fb);
> +}
> +

This function is still pretty long and could be split into smaller chunks.

Maxime

-- 
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

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

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

* Re: [igt-dev] [PATCH i-g-t v2 03/12] chamelium: Debug-print CRCs when comparing them and dumping frames
  2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 03/12] chamelium: Debug-print CRCs when comparing them and dumping frames Paul Kocialkowski
  2018-12-14  9:00   ` Maxime Ripard
@ 2018-12-14 19:42   ` Lyude Paul
  1 sibling, 0 replies; 25+ messages in thread
From: Lyude Paul @ 2018-12-14 19:42 UTC (permalink / raw)
  To: Paul Kocialkowski, igt-dev
  Cc: Petri Latvala, Eben Upton, Boris Brezillon, Thomas Petazzoni

Reviewed-by: Lyude-Paul <lyude@redhat.com>

On Thu, 2018-12-13 at 16:55 +0100, Paul Kocialkowski wrote:
> Add debug prints for the reference and captured CRCs when comparing them
> and dumping them, which can be useful to get an idea of what is going on
> (e.g. specific noise on display cables often only changes one of the
> values that compose the CRC).
> 
> It's also useful to associate a test debug output with the dumped
> pictures (that have the CRC in their name).
> 
> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> ---
>  lib/igt_chamelium.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
> index d136fb04c342..32b859eac4a7 100644
> --- a/lib/igt_chamelium.c
> +++ b/lib/igt_chamelium.c
> @@ -1033,6 +1033,9 @@ void chamelium_assert_crc_eq_or_dump(struct chamelium
> *chamelium,
>  	char *capture_suffix;
>  	bool eq;
>  
> +	igt_debug("Reference CRC: %s\n", igt_crc_to_string(reference_crc));
> +	igt_debug("Captured CRC: %s\n", igt_crc_to_string(capture_crc));
> +
>  	eq = igt_check_crc_equal(reference_crc, capture_crc);
>  	if (!eq && igt_frame_dump_is_enabled()) {
>  		/* Grab the reference frame from framebuffer */
> @@ -1101,6 +1104,10 @@ void
> chamelium_assert_analog_frame_match_or_dump(struct chamelium *chamelium,
>  		capture_crc = chamelium_get_crc_for_area(chamelium, port, 0,
> 0,
>  							 0, 0);
>  
> +		igt_debug("Reference CRC: %s\n",
> +			  igt_crc_to_string(reference_crc));
> +		igt_debug("Captured CRC: %s\n",
> igt_crc_to_string(capture_crc));
> +
>  		reference_suffix = igt_crc_to_string_extended(reference_crc,
>  							      '-', 2);
>  		capture_suffix = igt_crc_to_string_extended(capture_crc, '-',
-- 
Cheers,
	Lyude Paul

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

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

end of thread, other threads:[~2018-12-14 19:42 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-13 15:55 [igt-dev] [PATCH i-g-t v2 00/12] Chamelium VC4 plane testing, with T-tiled mode Paul Kocialkowski
2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 01/12] chamelium: Pass dimensions instead of mode to pattern generation helper Paul Kocialkowski
2018-12-14  8:58   ` Maxime Ripard
2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 02/12] chamelium: Pass the pattern block size as argument to helpers Paul Kocialkowski
2018-12-14  9:00   ` Maxime Ripard
2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 03/12] chamelium: Debug-print CRCs when comparing them and dumping frames Paul Kocialkowski
2018-12-14  9:00   ` Maxime Ripard
2018-12-14 19:42   ` Lyude Paul
2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 04/12] lib: drmtest: Add helpers to check and require the VC4 driver Paul Kocialkowski
2018-12-14  9:00   ` Maxime Ripard
2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 05/12] lib/igt_fb: Add checks on i915 for i915-specific tiled buffer allocation Paul Kocialkowski
2018-12-14  9:02   ` Maxime Ripard
2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 06/12] lib/igt_fb: Add support for allocating T-tiled VC4 buffers Paul Kocialkowski
2018-12-14  9:03   ` Maxime Ripard
2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 07/12] lib/igt_vc4: Add helpers for converting linear to T-tiled XRGB buffers Paul Kocialkowski
2018-12-14  9:03   ` Maxime Ripard
2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 08/12] lib/igt_fb: Add a stride-provisioned fashion of igt_fb_convert Paul Kocialkowski
2018-12-14  9:05   ` Maxime Ripard
2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 09/12] lib/igt_fb: Add a helper to retreive the plane bpp for a given format Paul Kocialkowski
2018-12-14  9:05   ` Maxime Ripard
2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 10/12] lib/igt_kms: Add helpers to count and iterate planes from pipe Paul Kocialkowski
2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 11/12] lib/igt_kms: Add helpers to count and iterate planes from output Paul Kocialkowski
2018-12-13 15:55 ` [igt-dev] [PATCH i-g-t v2 12/12] chamelium: Add a CRC-based display test for randomized planes Paul Kocialkowski
2018-12-14  9:22   ` Maxime Ripard
2018-12-13 16:18 ` [igt-dev] ✗ Fi.CI.BAT: failure for Chamelium VC4 plane testing, with T-tiled mode (rev2) Patchwork

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.