public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t v6 00/22] Chamelium VC4 plane fuzzy testing, with SAND and T-tiled mode
@ 2019-02-22  9:28 Paul Kocialkowski
  2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 01/22] lib: drmtest: Add helpers to check and require the VC4 driver Paul Kocialkowski
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: Paul Kocialkowski @ 2019-02-22  9:28 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, Thomas Petazzoni

This series introduces the required plumbing for allocating buffers in
the VC4 T-tiled and SAND_tiled modes, along with helpers to convert to
these tiling modes.

A new "checkerboard" comparison method is introduced to check whether
captured frames match their references in cases where pixel-perfect
results are not possible (e.g. with scaling) and the analog test does
not provide reliable results.

With that in place, new tests for the Chamelium are introduced to
perform testing of planes with randomized properties, both with a
CRC and frame comparison fashion.

Changes sinve v5:
* Always call calc_fb_size in create_bo_for_fb to set stride when needed,
  fixing a regression picked-up by CI;
* Added collected Reviewed-By tags.

Changes since v4:
* Rebased atop latest master;
* Added collected Reviewed-By tags;
* Added a commit to refactor create_bo_for_fb before VC4 support.

Changes since v3:
* Documented the chamelium_check enum;
* Documented the checkerboard algorithm;
* Added igt_assert after memory allocations;
* Added modifier support to igt_fb_convert;
* Dropped inline helpers for checking vc4 tiling support;
* Various requested minor changes;
* Rebased on v4 of Maxime Ripard's YUV series;
* Added collected Reviewed-By tags;

Changes since v2:
* Added support for SAND tiling;
* Generalized T-tiling to support both 16 and 32 bpp;
* Split the main test into more sub-functions;
* Removed explicit lists of DRM formats;
* Added helper to list known DRM formats;
* Various functional fixes in the main test;
* Removed unnecessary pointer init in map_bo;
* Rebased on v3 of Maxime Ripard's YUV series;
* Added collected Reviewed-By tags;

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 (22):
  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: Refactor create_bo_for_fb to prepare for VC4 support
  lib/igt_fb: Add support for allocating T-tiled VC4 buffers
  lib/igt_fb: Add support for VC4 SAND tiling modes
  lib/igt_fb: Allow interpreting the tile height as a stride equivalent
  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_fb: Add a helper to fill-in the available DRM formats
  lib/igt_vc4: Add helpers for converting linear to T-tiled RGB buffers
  lib/igt_vc4: Add helpers for converting linear to SAND-tiled buffers
  lib/igt_fb: Pass the modifier to igt_fb_convert helpers
  lib/igt_fb: Support converting to VC4 modifiers in igt_fb_convert
  lib/igt_kms: Add helpers to count and iterate planes from pipe
  lib/igt_kms: Add helpers to count and iterate planes from output
  lib/igt_chamelium: Fixup resources liberation in comparison helpers
  lib/igt_chamelium: Split frames dump logic and rework surroundings
  lib/igt_chamelium: Generalize the frame match helper with check type
  lib/igt_frame: Add a checkerboard frame comparison method
  lib/igt_chamelium: Hook-in checkerboard comparison method in helpers
  chamelium: Move the YUV tests over to the checkerboard checking method
  chamelium: Add a display test for randomized planes

 lib/drmtest.c         |  10 +
 lib/drmtest.h         |   2 +
 lib/igt_chamelium.c   | 125 +++++++----
 lib/igt_chamelium.h   |  22 +-
 lib/igt_fb.c          | 225 +++++++++++++++++---
 lib/igt_fb.h          |   9 +-
 lib/igt_frame.c       | 135 ++++++++++++
 lib/igt_frame.h       |   2 +
 lib/igt_kms.c         |  84 ++++++++
 lib/igt_kms.h         |   6 +
 lib/igt_vc4.c         | 239 +++++++++++++++++++++
 lib/igt_vc4.h         |   8 +
 tests/kms_chamelium.c | 476 ++++++++++++++++++++++++++++++++++++++++--
 13 files changed, 1244 insertions(+), 99 deletions(-)

-- 
2.20.1

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

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

* [igt-dev] [PATCH i-g-t v6 01/22] lib: drmtest: Add helpers to check and require the VC4 driver
  2019-02-22  9:28 [igt-dev] [PATCH i-g-t v6 00/22] Chamelium VC4 plane fuzzy testing, with SAND and T-tiled mode Paul Kocialkowski
@ 2019-02-22  9:28 ` Paul Kocialkowski
  2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 02/22] lib/igt_fb: Add checks on i915 for i915-specific tiled buffer allocation Paul Kocialkowski
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Paul Kocialkowski @ 2019-02-22  9:28 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, 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>
Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.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 6c0a0e381aef..6506791b521e 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -106,6 +106,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;
@@ -484,3 +489,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 8743b1bb1ed3..ca347a7120db 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -80,8 +80,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.20.1

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

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

* [igt-dev] [PATCH i-g-t v6 02/22] lib/igt_fb: Add checks on i915 for i915-specific tiled buffer allocation
  2019-02-22  9:28 [igt-dev] [PATCH i-g-t v6 00/22] Chamelium VC4 plane fuzzy testing, with SAND and T-tiled mode Paul Kocialkowski
  2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 01/22] lib: drmtest: Add helpers to check and require the VC4 driver Paul Kocialkowski
@ 2019-02-22  9:28 ` Paul Kocialkowski
  2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 03/22] lib/igt_fb: Refactor create_bo_for_fb to prepare for VC4 support Paul Kocialkowski
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Paul Kocialkowski @ 2019-02-22  9:28 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, 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>
Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
---
 lib/igt_fb.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 462afec22085..058cfab604b8 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -397,6 +397,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;
 
@@ -425,6 +426,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];
@@ -1559,9 +1561,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.20.1

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

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

* [igt-dev] [PATCH i-g-t v6 03/22] lib/igt_fb: Refactor create_bo_for_fb to prepare for VC4 support
  2019-02-22  9:28 [igt-dev] [PATCH i-g-t v6 00/22] Chamelium VC4 plane fuzzy testing, with SAND and T-tiled mode Paul Kocialkowski
  2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 01/22] lib: drmtest: Add helpers to check and require the VC4 driver Paul Kocialkowski
  2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 02/22] lib/igt_fb: Add checks on i915 for i915-specific tiled buffer allocation Paul Kocialkowski
@ 2019-02-22  9:28 ` Paul Kocialkowski
  2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 04/22] lib/igt_fb: Add support for allocating T-tiled VC4 buffers Paul Kocialkowski
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Paul Kocialkowski @ 2019-02-22  9:28 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, Thomas Petazzoni

The current create_bo_for_fb uses a device-specific BO instead of dumb
allocation when dumb allocation is not appropriate and the driver is
Intel. Then, it will assert that the parameters are appropriate for
dumb allocation.

The conditions related to tiling, size and stride are sufficient for
needing a device-specific BO and they are not specific to Intel.
However, a device-specific BO for YUV is only needed for Intel.

Change the conditions accordingly and set a device_bo variable. This
variable allows making fb->size calculation common between the
device-specific and dumb paths. Use the variable after that and
distinguish between the device types for allocating and error out if
it's not supported.

This makes the extra checks that dumb allocation is valid redundant,
since these cases will always fall under device-specific allocation
and potentially error out then.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
---
 lib/igt_fb.c | 45 +++++++++++++++++++++++++--------------------
 1 file changed, 25 insertions(+), 20 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 058cfab604b8..1178dddf2337 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -610,36 +610,41 @@ static int create_bo_for_fb(struct igt_fb *fb)
 	unsigned int bpp = 0;
 	unsigned int plane;
 	unsigned *strides = &fb->strides[0];
+	bool device_bo = false;
 	int fd = fb->fd;
+	uint64_t size;
 
-	if (is_i915_device(fd) &&
-	   (fb->tiling || fb->size || fb->strides[0] || igt_format_is_yuv(fb->drm_format))) {
-		uint64_t size;
+	/*
+	 * The current dumb buffer allocation API doesn't really allow to
+	 * specify a custom size or stride. Yet the caller is free to specify
+	 * them, so we need to make sure to use a device BO then.
+	 */
+	if (fb->tiling || fb->size || fb->strides[0] ||
+	    (is_i915_device(fd) && igt_format_is_yuv(fb->drm_format)))
+		device_bo = true;
 
-		size = calc_fb_size(fb);
+	/* Sets offets and stride if necessary. */
+	size = calc_fb_size(fb);
 
-		/* respect the size requested by the caller */
-		if (fb->size == 0)
-			fb->size = size;
+	/* Respect the size requested by the caller. */
+	if (fb->size == 0)
+		fb->size = size;
 
+	if (device_bo) {
 		fb->is_dumb = false;
-		fb->gem_handle = gem_create(fd, fb->size);
-		gem_set_tiling(fd, fb->gem_handle,
-			       igt_fb_mod_to_tiling(fb->tiling),
-			       fb->strides[0]);
+
+		if (is_i915_device(fd)) {
+			fb->gem_handle = gem_create(fd, fb->size);
+			gem_set_tiling(fd, fb->gem_handle,
+				       igt_fb_mod_to_tiling(fb->tiling),
+				       fb->strides[0]);
+		} else {
+			igt_assert(false);
+		}
 
 		goto out;
 	}
 
-	/*
-	 * The current dumb buffer allocation API doesn't really allow to
-	 * specify a custom size or stride. Yet the caller is free to specify
-	 * them, so we need to make sure to error out in this case.
-	 */
-	igt_assert(fb->size == 0);
-	igt_assert(fb->strides[0] == 0);
-
-	fb->size = calc_fb_size(fb);
 	for (plane = 0; plane < fb->num_planes; plane++)
 		bpp += DIV_ROUND_UP(fb->plane_bpp[plane],
 				    plane ? fmt->hsub * fmt->vsub : 1);
-- 
2.20.1

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

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

* [igt-dev] [PATCH i-g-t v6 04/22] lib/igt_fb: Add support for allocating T-tiled VC4 buffers
  2019-02-22  9:28 [igt-dev] [PATCH i-g-t v6 00/22] Chamelium VC4 plane fuzzy testing, with SAND and T-tiled mode Paul Kocialkowski
                   ` (2 preceding siblings ...)
  2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 03/22] lib/igt_fb: Refactor create_bo_for_fb to prepare for VC4 support Paul Kocialkowski
@ 2019-02-22  9:28 ` Paul Kocialkowski
  2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 05/22] lib/igt_fb: Add support for VC4 SAND tiling modes Paul Kocialkowski
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Paul Kocialkowski @ 2019-02-22  9:28 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, 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>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.com>
---
 lib/igt_fb.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 1178dddf2337..bfb47622a474 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"
@@ -270,6 +271,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:
 		if (is_i915_device(fd))
@@ -323,6 +327,11 @@ 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);
+		*width_ret = 128;
+		*height_ret = 32;
+		break;
 	default:
 		igt_assert(false);
 	}
@@ -638,6 +647,12 @@ static int create_bo_for_fb(struct igt_fb *fb)
 			gem_set_tiling(fd, fb->gem_handle,
 				       igt_fb_mod_to_tiling(fb->tiling),
 				       fb->strides[0]);
+		} 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);
 		} else {
 			igt_assert(false);
 		}
@@ -1569,6 +1584,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.20.1

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

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

* [igt-dev] [PATCH i-g-t v6 05/22] lib/igt_fb: Add support for VC4 SAND tiling modes
  2019-02-22  9:28 [igt-dev] [PATCH i-g-t v6 00/22] Chamelium VC4 plane fuzzy testing, with SAND and T-tiled mode Paul Kocialkowski
                   ` (3 preceding siblings ...)
  2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 04/22] lib/igt_fb: Add support for allocating T-tiled VC4 buffers Paul Kocialkowski
@ 2019-02-22  9:28 ` Paul Kocialkowski
  2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 06/22] lib/igt_fb: Allow interpreting the tile height as a stride equivalent Paul Kocialkowski
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Paul Kocialkowski @ 2019-02-22  9:28 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, Thomas Petazzoni

This introduces support for the VC4 SAND tiling modes, that take a
specific parameter indicating their column height. This parameter acts
as a height-based stride equivalent, that shall be equal or greater
than the displayed height.

The parameter is extracted and returned as tile height so that enough
memory can be reserved for column heights containing extra padding.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
---
 lib/igt_fb.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index bfb47622a474..a02b3621102f 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -271,8 +271,12 @@ 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))
+	uint32_t vc4_tiling_param = 0;
+
+	if (is_vc4_device(fd)) {
+		vc4_tiling_param = fourcc_mod_broadcom_param(tiling);
 		tiling = fourcc_mod_broadcom_mod(tiling);
+	}
 
 	switch (tiling) {
 	case LOCAL_DRM_FORMAT_MOD_NONE:
@@ -332,6 +336,26 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp,
 		*width_ret = 128;
 		*height_ret = 32;
 		break;
+	case DRM_FORMAT_MOD_BROADCOM_SAND32:
+		igt_require_vc4(fd);
+		*width_ret = 32;
+		*height_ret = vc4_tiling_param;
+		break;
+	case DRM_FORMAT_MOD_BROADCOM_SAND64:
+		igt_require_vc4(fd);
+		*width_ret = 64;
+		*height_ret = vc4_tiling_param;
+		break;
+	case DRM_FORMAT_MOD_BROADCOM_SAND128:
+		igt_require_vc4(fd);
+		*width_ret = 128;
+		*height_ret = vc4_tiling_param;
+		break;
+	case DRM_FORMAT_MOD_BROADCOM_SAND256:
+		igt_require_vc4(fd);
+		*width_ret = 256;
+		*height_ret = vc4_tiling_param;
+		break;
 	default:
 		igt_assert(false);
 	}
-- 
2.20.1

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

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

* [igt-dev] [PATCH i-g-t v6 06/22] lib/igt_fb: Allow interpreting the tile height as a stride equivalent
  2019-02-22  9:28 [igt-dev] [PATCH i-g-t v6 00/22] Chamelium VC4 plane fuzzy testing, with SAND and T-tiled mode Paul Kocialkowski
                   ` (4 preceding siblings ...)
  2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 05/22] lib/igt_fb: Add support for VC4 SAND tiling modes Paul Kocialkowski
@ 2019-02-22  9:28 ` Paul Kocialkowski
  2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 07/22] lib/igt_fb: Add a stride-provisioned fashion of igt_fb_convert Paul Kocialkowski
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Paul Kocialkowski @ 2019-02-22  9:28 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, Thomas Petazzoni

The VC4 SAND tiling modes are disposed in columns that follow each
other in memory. The column height defines the number of fixed-width
lines from the beginning of one column to the other, which may be
greater than the display height. In this case, the extra lines are
used as padding and the column height becomes a height-based stride
equivalent.

Support this when calculating the plane size by using the tile height
directly if it is greater than the plane height. This works better than
alignment for non-power-of-two cases (no space is wasted) and it is
equivalent to alignment for power-of-two tile heights.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.com>
---
 lib/igt_fb.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index a02b3621102f..92899aa8b601 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -483,6 +483,13 @@ static uint64_t calc_plane_size(struct igt_fb *fb, int plane)
 		igt_get_fb_tile_size(fb->fd, fb->tiling, fb->plane_bpp[plane],
 				     &tile_width, &tile_height);
 
+		/* Special case where the "tile height" represents a
+		 * height-based stride, such as with VC4 SAND tiling modes.
+		 */
+
+		if (tile_height > fb->plane_height[plane])
+			return fb->strides[plane] * tile_height;
+
 		return (uint64_t) fb->strides[plane] *
 			ALIGN(fb->plane_height[plane], tile_height);
 	}
-- 
2.20.1

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

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

* [igt-dev] [PATCH i-g-t v6 07/22] lib/igt_fb: Add a stride-provisioned fashion of igt_fb_convert
  2019-02-22  9:28 [igt-dev] [PATCH i-g-t v6 00/22] Chamelium VC4 plane fuzzy testing, with SAND and T-tiled mode Paul Kocialkowski
                   ` (5 preceding siblings ...)
  2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 06/22] lib/igt_fb: Allow interpreting the tile height as a stride equivalent Paul Kocialkowski
@ 2019-02-22  9:28 ` Paul Kocialkowski
  2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 08/22] lib/igt_fb: Add a helper to retreive the plane bpp for a given format Paul Kocialkowski
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Paul Kocialkowski @ 2019-02-22  9:28 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, 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>
Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.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 92899aa8b601..f19892490884 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -2553,14 +2553,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.
@@ -2568,15 +2569,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);
@@ -2597,6 +2601,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 8c683db5e9ec..232370bd47a0 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -136,6 +136,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.20.1

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

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

* [igt-dev] [PATCH i-g-t v6 08/22] lib/igt_fb: Add a helper to retreive the plane bpp for a given format
  2019-02-22  9:28 [igt-dev] [PATCH i-g-t v6 00/22] Chamelium VC4 plane fuzzy testing, with SAND and T-tiled mode Paul Kocialkowski
                   ` (6 preceding siblings ...)
  2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 07/22] lib/igt_fb: Add a stride-provisioned fashion of igt_fb_convert Paul Kocialkowski
@ 2019-02-22  9:28 ` Paul Kocialkowski
  2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 09/22] lib/igt_fb: Add a helper to fill-in the available DRM formats Paul Kocialkowski
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Paul Kocialkowski @ 2019-02-22  9:28 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, 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>
Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.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 f19892490884..48f7921e9e09 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -2727,3 +2727,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 232370bd47a0..0bac83c3b150 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -181,6 +181,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.20.1

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

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

* [igt-dev] [PATCH i-g-t v6 09/22] lib/igt_fb: Add a helper to fill-in the available DRM formats
  2019-02-22  9:28 [igt-dev] [PATCH i-g-t v6 00/22] Chamelium VC4 plane fuzzy testing, with SAND and T-tiled mode Paul Kocialkowski
                   ` (7 preceding siblings ...)
  2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 08/22] lib/igt_fb: Add a helper to retreive the plane bpp for a given format Paul Kocialkowski
@ 2019-02-22  9:28 ` Paul Kocialkowski
  2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 10/22] lib/igt_vc4: Add helpers for converting linear to T-tiled RGB buffers Paul Kocialkowski
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Paul Kocialkowski @ 2019-02-22  9:28 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, Thomas Petazzoni

Introduce a helper to allocate and fill-in a list of available DRM
formats, which is useful for picking one at random in tests.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.com>
---
 lib/igt_fb.c | 35 +++++++++++++++++++++++++++++++++++
 lib/igt_fb.h |  2 ++
 2 files changed, 37 insertions(+)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 48f7921e9e09..0b59ff4771aa 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -2743,3 +2743,38 @@ int igt_format_plane_bpp(uint32_t drm_format, int plane)
 
 	return format->plane_bpp[plane];
 }
+
+/**
+ * igt_format_array_fill:
+ * @formats_array: a pointer to the formats array pointer to be allocated
+ * @count: a pointer to the number of elements contained in the allocated array
+ * @allow_yuv: a boolean indicating whether YUV formats should be included
+ *
+ * This functions allocates and fills a @formats_array that lists the DRM
+ * formats current available.
+ */
+void igt_format_array_fill(uint32_t **formats_array, unsigned int *count,
+			   bool allow_yuv)
+{
+	const struct format_desc_struct *format;
+	unsigned int index = 0;
+
+	*count = 0;
+
+	for_each_format(format) {
+		if (!allow_yuv && igt_format_is_yuv(format->drm_id))
+			continue;
+
+		(*count)++;
+	}
+
+	*formats_array = calloc(*count, sizeof(uint32_t));
+	igt_assert(*formats_array);
+
+	for_each_format(format) {
+		if (!allow_yuv && igt_format_is_yuv(format->drm_id))
+			continue;
+
+		(*formats_array)[index++] = format->drm_id;
+	}
+}
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index 0bac83c3b150..2c0a24d2129f 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -182,6 +182,8 @@ 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);
+void igt_format_array_fill(uint32_t **formats_array, unsigned int *count,
+			   bool allow_yuv);
 
 #endif /* __IGT_FB_H__ */
 
-- 
2.20.1

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

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

* [igt-dev] [PATCH i-g-t v6 10/22] lib/igt_vc4: Add helpers for converting linear to T-tiled RGB buffers
  2019-02-22  9:28 [igt-dev] [PATCH i-g-t v6 00/22] Chamelium VC4 plane fuzzy testing, with SAND and T-tiled mode Paul Kocialkowski
                   ` (8 preceding siblings ...)
  2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 09/22] lib/igt_fb: Add a helper to fill-in the available DRM formats Paul Kocialkowski
@ 2019-02-22  9:28 ` Paul Kocialkowski
  2019-02-22  9:29 ` [igt-dev] [PATCH i-g-t v6 11/22] lib/igt_vc4: Add helpers for converting linear to SAND-tiled buffers Paul Kocialkowski
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Paul Kocialkowski @ 2019-02-22  9:28 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, 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>
Acked-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.com>
---
 lib/igt_vc4.c | 131 ++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_vc4.h |   4 ++
 2 files changed, 135 insertions(+)

diff --git a/lib/igt_vc4.c b/lib/igt_vc4.c
index 16dfe67a44b1..b697b5fdf082 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,133 @@ 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;
+	void *src_buf;
+	void *dst_buf;
+	size_t bpp = src->plane_bpp[0];
+	size_t dst_stride = ALIGN(src->strides[0], 128);
+
+	fb_id = igt_create_fb_with_bo_size(src->fd, src->width, src->height,
+					   src->drm_format,
+					   DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED,
+					   dst, 0, dst_stride);
+	igt_assert(fb_id > 0);
+
+	igt_assert(bpp == 16 || bpp == 32);
+
+	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++) {
+			size_t src_offset = src->offsets[0];
+			size_t dst_offset = dst->offsets[0];
+
+			src_offset += src->strides[0] * i + j * bpp / 8;
+			dst_offset += igt_vc4_t_tiled_offset(dst_stride,
+							     src->height,
+							     bpp, j, i);
+
+			switch (bpp) {
+			case 16:
+				*(uint16_t *)(dst_buf + dst_offset) =
+					*(uint16_t *)(src_buf + src_offset);
+				break;
+			case 32:
+				*(uint32_t *)(dst_buf + dst_offset) =
+					*(uint32_t *)(src_buf + src_offset);
+				break;
+			}
+		}
+	}
+
+	igt_fb_unmap_buffer(src, src_buf);
+	igt_fb_unmap_buffer(dst, dst_buf);
+
+	return fb_id;
+}
+
+/* Calculate the t-tile width so that size = width * height * bpp / 8. */
+#define VC4_T_TILE_W(size, height, bpp) ((size) / (height) / ((bpp) / 8))
+
+size_t igt_vc4_t_tiled_offset(size_t stride, size_t height, size_t bpp,
+			      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 };
+	const size_t t4k_t_h = 32;
+	const size_t t1k_t_h = 16;
+	const size_t t64_t_h = 4;
+	size_t offset = 0;
+	size_t t4k_t_w, t4k_w, t4k_x, t4k_y;
+	size_t t1k_t_w, t1k_x, t1k_y;
+	size_t t64_t_w, t64_x, t64_y;
+	size_t pix_x, pix_y;
+	unsigned int index;
+
+	/* T-tiling is only supported for 16 and 32 bpp. */
+	igt_assert(bpp == 16 || bpp == 32);
+
+	/* T-tiling stride must be aligned to the 4K tiles strides. */
+	igt_assert((stride % (4096 / t4k_t_h)) == 0);
+
+	/* Calculate the tile width for the bpp. */
+	t4k_t_w = VC4_T_TILE_W(4096, t4k_t_h, bpp);
+	t1k_t_w = VC4_T_TILE_W(1024, t1k_t_h, bpp);
+	t64_t_w = VC4_T_TILE_W(64, t64_t_h, bpp);
+
+	/* Aligned total width in number of 4K tiles. */
+	t4k_w = (stride / (bpp / 8)) / t4k_t_w;
+
+	/* X and y coordinates in number of 4K tiles. */
+	t4k_x = x / t4k_t_w;
+	t4k_y = y / t4k_t_h;
+
+	/* Increase offset to the beginning of the 4K tile row. */
+	offset += t4k_y * t4k_w * 4096;
+
+	/* X and Y coordinates in number of 1K tiles within the 4K tile. */
+	t1k_x = (x % t4k_t_w) / t1k_t_w;
+	t1k_y = (y % t4k_t_h) / t1k_t_h;
+
+	/* Index for 1K tile map lookup. */
+	index = 2 * t1k_y + t1k_x;
+
+	/* Odd rows start from the right, even rows from the left. */
+	if (t4k_y % 2) {
+		/* Increase offset to the 4K tile (starting from the right). */
+		offset += (t4k_w - t4k_x - 1) * 4096;
+
+		/* Incrase offset to the beginning of the (odd) 1K tile. */
+		offset += t1k_map_odd[index] * 1024;
+	} else {
+		/* Increase offset to the 4K tile (starting from the left). */
+		offset += t4k_x * 4096;
+
+		/* Incrase offset to the beginning of the (even) 1K tile. */
+		offset += t1k_map_even[index] * 1024;
+	}
+
+	/* X and Y coordinates in number of 64 byte tiles within the 1K tile. */
+	t64_x = (x % t1k_t_w) / t64_t_w;
+	t64_y = (y % t1k_t_h) / t64_t_h;
+
+	/* Increase offset to the beginning of the 64-byte tile. */
+	offset += (t64_y * (t1k_t_w / t64_t_w) + t64_x) * 64;
+
+	/* X and Y coordinates in number of pixels within the 64-byte tile. */
+	pix_x = x % t64_t_w;
+	pix_y = y % t64_t_h;
+
+	/* Increase offset to the correct pixel. */
+	offset += (pix_y * t64_t_w + pix_x) * bpp / 8;
+
+	return offset;
+}
diff --git a/lib/igt_vc4.h b/lib/igt_vc4.h
index ebc8a3881b5e..d5c529bbccda 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 stride, size_t height, size_t bpp,
+			      size_t x, size_t y);
+
 #endif /* IGT_VC4_H */
-- 
2.20.1

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

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

* [igt-dev] [PATCH i-g-t v6 11/22] lib/igt_vc4: Add helpers for converting linear to SAND-tiled buffers
  2019-02-22  9:28 [igt-dev] [PATCH i-g-t v6 00/22] Chamelium VC4 plane fuzzy testing, with SAND and T-tiled mode Paul Kocialkowski
                   ` (9 preceding siblings ...)
  2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 10/22] lib/igt_vc4: Add helpers for converting linear to T-tiled RGB buffers Paul Kocialkowski
@ 2019-02-22  9:29 ` Paul Kocialkowski
  2019-02-22  9:29 ` [igt-dev] [PATCH i-g-t v6 12/22] lib/igt_fb: Pass the modifier to igt_fb_convert helpers Paul Kocialkowski
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Paul Kocialkowski @ 2019-02-22  9:29 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, Thomas Petazzoni

In order to test buffers with SAND tiling, it is useful to convert
linear buffers to SAND tiling mode.

Introduce helpers to assist in that direction, one that calculates the
memory offset in the SAND-tiled buffer for a given pixel position and
one that makes use of the latter for framebuffer conversion.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Acked-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.com>
---
 lib/igt_vc4.c | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_vc4.h |   4 ++
 2 files changed, 112 insertions(+)

diff --git a/lib/igt_vc4.c b/lib/igt_vc4.c
index b697b5fdf082..9a0ba30b4420 100644
--- a/lib/igt_vc4.c
+++ b/lib/igt_vc4.c
@@ -307,3 +307,111 @@ size_t igt_vc4_t_tiled_offset(size_t stride, size_t height, size_t bpp,
 
 	return offset;
 }
+
+static void vc4_fb_sand_tiled_convert_plane(struct igt_fb *dst, void *dst_buf,
+					    struct igt_fb *src, void *src_buf,
+					    size_t column_width_bytes,
+					    size_t column_height,
+					    unsigned int plane)
+{
+	size_t bpp = dst->plane_bpp[plane];
+	size_t column_width = column_width_bytes * dst->plane_width[plane] /
+			      dst->width;
+	size_t column_size = column_width_bytes * column_height;
+	unsigned int i, j;
+
+	for (i = 0; i < dst->plane_height[plane]; i++) {
+		for (j = 0; j < src->plane_width[plane]; j++) {
+			size_t src_offset = src->offsets[plane];
+			size_t dst_offset = dst->offsets[plane];
+
+			src_offset += src->strides[plane] * i + j * bpp / 8;
+			dst_offset += vc4_sand_tiled_offset(column_width,
+							    column_size, j, i,
+							    bpp);
+
+			switch (bpp) {
+			case 8:
+				*(uint8_t *)(dst_buf + dst_offset) =
+					*(uint8_t *)(src_buf + src_offset);
+				break;
+			case 16:
+				*(uint16_t *)(dst_buf + dst_offset) =
+					*(uint16_t *)(src_buf + src_offset);
+				break;
+			default:
+				igt_assert(false);
+			}
+		}
+	}
+}
+
+unsigned int vc4_fb_sand_tiled_convert(struct igt_fb *dst, struct igt_fb *src,
+				       uint64_t modifier)
+{
+	uint64_t modifier_base;
+	size_t column_width_bytes;
+	size_t column_height;
+	unsigned int fb_id;
+	unsigned int i;
+	void *src_buf;
+	void *dst_buf;
+
+	modifier_base = fourcc_mod_broadcom_mod(modifier);
+	column_height = fourcc_mod_broadcom_param(modifier);
+
+	switch (modifier_base) {
+	case DRM_FORMAT_MOD_BROADCOM_SAND32:
+		column_width_bytes = 32;
+		break;
+	case DRM_FORMAT_MOD_BROADCOM_SAND64:
+		column_width_bytes = 64;
+		break;
+	case DRM_FORMAT_MOD_BROADCOM_SAND128:
+		column_width_bytes = 128;
+		break;
+	case DRM_FORMAT_MOD_BROADCOM_SAND256:
+		column_width_bytes = 256;
+		break;
+	default:
+		igt_assert(false);
+	}
+
+	fb_id = igt_create_fb(src->fd, src->width, src->height, src->drm_format,
+			      modifier, 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 < dst->num_planes; i++)
+		vc4_fb_sand_tiled_convert_plane(dst, dst_buf, src, src_buf,
+						column_width_bytes,
+						column_height, i);
+
+	igt_fb_unmap_buffer(src, src_buf);
+	igt_fb_unmap_buffer(dst, dst_buf);
+
+	return fb_id;
+}
+
+size_t vc4_sand_tiled_offset(size_t column_width, size_t column_size, size_t x,
+			     size_t y, size_t bpp)
+{
+	size_t offset = 0;
+	size_t cols_x;
+	size_t pix_x;
+
+	/* Offset to the beginning of the relevant column. */
+	cols_x = x / column_width;
+	offset += cols_x * column_size;
+
+	/* Offset to the relevant pixel. */
+	pix_x = x % column_width;
+	offset += (column_width * y + pix_x) * bpp / 8;
+
+	return offset;
+}
diff --git a/lib/igt_vc4.h b/lib/igt_vc4.h
index d5c529bbccda..a17812698fe5 100644
--- a/lib/igt_vc4.h
+++ b/lib/igt_vc4.h
@@ -36,5 +36,9 @@ 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 stride, size_t height, size_t bpp,
 			      size_t x, size_t y);
+unsigned int vc4_fb_sand_tiled_convert(struct igt_fb *dst, struct igt_fb *src,
+				       uint64_t modifier);
+size_t vc4_sand_tiled_offset(size_t column_width, size_t column_size, size_t x,
+			     size_t y, size_t bpp);
 
 #endif /* IGT_VC4_H */
-- 
2.20.1

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

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

* [igt-dev] [PATCH i-g-t v6 12/22] lib/igt_fb: Pass the modifier to igt_fb_convert helpers
  2019-02-22  9:28 [igt-dev] [PATCH i-g-t v6 00/22] Chamelium VC4 plane fuzzy testing, with SAND and T-tiled mode Paul Kocialkowski
                   ` (10 preceding siblings ...)
  2019-02-22  9:29 ` [igt-dev] [PATCH i-g-t v6 11/22] lib/igt_vc4: Add helpers for converting linear to SAND-tiled buffers Paul Kocialkowski
@ 2019-02-22  9:29 ` Paul Kocialkowski
  2019-02-22  9:29 ` [igt-dev] [PATCH i-g-t v6 13/22] lib/igt_fb: Support converting to VC4 modifiers in igt_fb_convert Paul Kocialkowski
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Paul Kocialkowski @ 2019-02-22  9:29 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, Thomas Petazzoni

The modifier is part of how a frame is represented, so add it as an
extra argument so that it can be specified when converting framebuffers.

For now, only a linear modifier is supported.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
---
 lib/igt_fb.c          | 14 ++++++++++----
 lib/igt_fb.h          |  3 ++-
 tests/kms_chamelium.c |  3 ++-
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 0b59ff4771aa..25a07b0dfa39 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -2557,6 +2557,7 @@ void igt_remove_fb(int fd, struct igt_fb *fb)
  * @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_modifier: DRM format modifier 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,
@@ -2571,6 +2572,7 @@ void igt_remove_fb(int fd, struct igt_fb *fb)
  */
 unsigned int igt_fb_convert_with_stride(struct igt_fb *dst, struct igt_fb *src,
 					uint32_t dst_fourcc,
+					uint64_t dst_modifier,
 					unsigned int dst_stride)
 {
 	struct fb_convert cvt = { };
@@ -2579,8 +2581,8 @@ unsigned int igt_fb_convert_with_stride(struct igt_fb *dst, struct igt_fb *src,
 
 	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);
+					   LOCAL_DRM_FORMAT_MOD_NONE, dst, 0,
+					   dst_stride);
 	igt_assert(fb_id > 0);
 
 	src_ptr = igt_fb_map_buffer(src->fd, src);
@@ -2598,6 +2600,8 @@ unsigned int igt_fb_convert_with_stride(struct igt_fb *dst, struct igt_fb *src,
 	igt_fb_unmap_buffer(dst, dst_ptr);
 	igt_fb_unmap_buffer(src, src_ptr);
 
+	igt_assert(dst_modifier == LOCAL_DRM_FORMAT_MOD_NONE);
+
 	return fb_id;
 }
 
@@ -2606,6 +2610,7 @@ unsigned int igt_fb_convert_with_stride(struct igt_fb *dst, struct igt_fb *src,
  * @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_modifier: DRM format modifier 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
@@ -2618,9 +2623,10 @@ unsigned int igt_fb_convert_with_stride(struct igt_fb *dst, struct igt_fb *src,
  * The kms id of the created framebuffer.
  */
 unsigned int igt_fb_convert(struct igt_fb *dst, struct igt_fb *src,
-			    uint32_t dst_fourcc)
+			    uint32_t dst_fourcc, uint64_t dst_modifier)
 {
-	return igt_fb_convert_with_stride(dst, src, dst_fourcc, 0);
+	return igt_fb_convert_with_stride(dst, src, dst_fourcc, dst_modifier,
+					  0);
 }
 
 /**
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index 2c0a24d2129f..e1d885e2c5bc 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -138,9 +138,10 @@ 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,
+					uint64_t dst_modifier,
 					unsigned int stride);
 unsigned int igt_fb_convert(struct igt_fb *dst, struct igt_fb *src,
-			    uint32_t dst_fourcc);
+			    uint32_t dst_fourcc, uint64_t dst_modifier);
 void igt_remove_fb(int fd, struct igt_fb *fb);
 int igt_dirty_fb(int fd, struct igt_fb *fb);
 void *igt_fb_map_buffer(int fd, struct igt_fb *fb);
diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
index 64f87d3ae474..fe58aea98e86 100644
--- a/tests/kms_chamelium.c
+++ b/tests/kms_chamelium.c
@@ -546,7 +546,8 @@ static void do_test_display(data_t *data, struct chamelium_port *port,
 					 DRM_FORMAT_XRGB8888, 64, &fb);
 	igt_assert(fb_id > 0);
 
-	frame_id = igt_fb_convert(&frame_fb, &fb, fourcc);
+	frame_id = igt_fb_convert(&frame_fb, &fb, fourcc,
+				  LOCAL_DRM_FORMAT_MOD_NONE);
 	igt_assert(frame_id > 0);
 
 	if (check == CHAMELIUM_CHECK_CRC)
-- 
2.20.1

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

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

* [igt-dev] [PATCH i-g-t v6 13/22] lib/igt_fb: Support converting to VC4 modifiers in igt_fb_convert
  2019-02-22  9:28 [igt-dev] [PATCH i-g-t v6 00/22] Chamelium VC4 plane fuzzy testing, with SAND and T-tiled mode Paul Kocialkowski
                   ` (11 preceding siblings ...)
  2019-02-22  9:29 ` [igt-dev] [PATCH i-g-t v6 12/22] lib/igt_fb: Pass the modifier to igt_fb_convert helpers Paul Kocialkowski
@ 2019-02-22  9:29 ` Paul Kocialkowski
  2019-02-22  9:29 ` [igt-dev] [PATCH i-g-t v6 14/22] lib/igt_kms: Add helpers to count and iterate planes from pipe Paul Kocialkowski
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Paul Kocialkowski @ 2019-02-22  9:29 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, Thomas Petazzoni

This pipes-in support for the VC4 modifiers that we have conversion
helpers for. A new temporary linear framebuffer is introduced, that
is either freed later or copied to the destination framebuffer
pointer.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
---
 lib/igt_fb.c | 36 +++++++++++++++++++++++++++++++-----
 1 file changed, 31 insertions(+), 5 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 25a07b0dfa39..e44b803f24d1 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -2576,23 +2576,30 @@ unsigned int igt_fb_convert_with_stride(struct igt_fb *dst, struct igt_fb *src,
 					unsigned int dst_stride)
 {
 	struct fb_convert cvt = { };
+	struct igt_fb linear;
 	void *dst_ptr, *src_ptr;
+	uint64_t base_modifier;
 	int fb_id;
 
+	if (is_vc4_device(src->fd))
+		base_modifier = fourcc_mod_broadcom_mod(dst_modifier);
+	else
+		base_modifier = dst_modifier;
+
 	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);
+					   LOCAL_DRM_FORMAT_MOD_NONE, &linear,
+					   0, dst_stride);
 	igt_assert(fb_id > 0);
 
 	src_ptr = igt_fb_map_buffer(src->fd, src);
 	igt_assert(src_ptr);
 
-	dst_ptr = igt_fb_map_buffer(dst->fd, dst);
+	dst_ptr = igt_fb_map_buffer(linear.fd, &linear);
 	igt_assert(dst_ptr);
 
 	cvt.dst.ptr = dst_ptr;
-	cvt.dst.fb = dst;
+	cvt.dst.fb = &linear;
 	cvt.src.ptr = src_ptr;
 	cvt.src.fb = src;
 	fb_convert(&cvt);
@@ -2600,7 +2607,26 @@ unsigned int igt_fb_convert_with_stride(struct igt_fb *dst, struct igt_fb *src,
 	igt_fb_unmap_buffer(dst, dst_ptr);
 	igt_fb_unmap_buffer(src, src_ptr);
 
-	igt_assert(dst_modifier == LOCAL_DRM_FORMAT_MOD_NONE);
+	switch (base_modifier) {
+	case DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED:
+		fb_id = igt_vc4_fb_t_tiled_convert(dst, &linear);
+		break;
+	case DRM_FORMAT_MOD_BROADCOM_SAND32:
+	case DRM_FORMAT_MOD_BROADCOM_SAND64:
+	case DRM_FORMAT_MOD_BROADCOM_SAND128:
+	case DRM_FORMAT_MOD_BROADCOM_SAND256:
+		fb_id = vc4_fb_sand_tiled_convert(dst, &linear, dst_modifier);
+		break;
+	default:
+		igt_assert(dst_modifier == LOCAL_DRM_FORMAT_MOD_NONE);
+	}
+
+	igt_assert(fb_id > 0);
+
+	if (dst_modifier == LOCAL_DRM_FORMAT_MOD_NONE)
+		*dst = linear;
+	else
+		igt_remove_fb(linear.fd, &linear);
 
 	return fb_id;
 }
-- 
2.20.1

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

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

* [igt-dev] [PATCH i-g-t v6 14/22] lib/igt_kms: Add helpers to count and iterate planes from pipe
  2019-02-22  9:28 [igt-dev] [PATCH i-g-t v6 00/22] Chamelium VC4 plane fuzzy testing, with SAND and T-tiled mode Paul Kocialkowski
                   ` (12 preceding siblings ...)
  2019-02-22  9:29 ` [igt-dev] [PATCH i-g-t v6 13/22] lib/igt_fb: Support converting to VC4 modifiers in igt_fb_convert Paul Kocialkowski
@ 2019-02-22  9:29 ` Paul Kocialkowski
  2019-02-22  9:29 ` [igt-dev] [PATCH i-g-t v6 15/22] lib/igt_kms: Add helpers to count and iterate planes from output Paul Kocialkowski
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Paul Kocialkowski @ 2019-02-22  9:29 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, 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>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Maxime Ripard <maxime.ripard@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 080f90ae6e8c..1388bb4dae89 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -2279,6 +2279,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 679d4e84fab8..3b3cf659035b 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -407,6 +407,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.20.1

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

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

* [igt-dev] [PATCH i-g-t v6 15/22] lib/igt_kms: Add helpers to count and iterate planes from output
  2019-02-22  9:28 [igt-dev] [PATCH i-g-t v6 00/22] Chamelium VC4 plane fuzzy testing, with SAND and T-tiled mode Paul Kocialkowski
                   ` (13 preceding siblings ...)
  2019-02-22  9:29 ` [igt-dev] [PATCH i-g-t v6 14/22] lib/igt_kms: Add helpers to count and iterate planes from pipe Paul Kocialkowski
@ 2019-02-22  9:29 ` Paul Kocialkowski
  2019-02-22  9:29 ` [igt-dev] [PATCH i-g-t v6 16/22] lib/igt_chamelium: Fixup resources liberation in comparison helpers Paul Kocialkowski
  2019-02-22  9:29 ` [igt-dev] [PATCH i-g-t v6 17/22] lib/igt_chamelium: Split frames dump logic and rework surroundings Paul Kocialkowski
  16 siblings, 0 replies; 18+ messages in thread
From: Paul Kocialkowski @ 2019-02-22  9:29 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, 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>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Maxime Ripard <maxime.ripard@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 1388bb4dae89..87e6dbb89e5a 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -3716,6 +3716,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 3b3cf659035b..727ac2d186ed 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -403,6 +403,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.20.1

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

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

* [igt-dev] [PATCH i-g-t v6 16/22] lib/igt_chamelium: Fixup resources liberation in comparison helpers
  2019-02-22  9:28 [igt-dev] [PATCH i-g-t v6 00/22] Chamelium VC4 plane fuzzy testing, with SAND and T-tiled mode Paul Kocialkowski
                   ` (14 preceding siblings ...)
  2019-02-22  9:29 ` [igt-dev] [PATCH i-g-t v6 15/22] lib/igt_kms: Add helpers to count and iterate planes from output Paul Kocialkowski
@ 2019-02-22  9:29 ` Paul Kocialkowski
  2019-02-22  9:29 ` [igt-dev] [PATCH i-g-t v6 17/22] lib/igt_chamelium: Split frames dump logic and rework surroundings Paul Kocialkowski
  16 siblings, 0 replies; 18+ messages in thread
From: Paul Kocialkowski @ 2019-02-22  9:29 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, Thomas Petazzoni

This fixes a bunch of occurrences of memory not being properly
liberated after its use in helpers revolving around frame/CRC
comparison.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.com>
---
 lib/igt_chamelium.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index 32b859eac4a7..0b6ac37a3d89 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -1060,9 +1060,9 @@ void chamelium_assert_crc_eq_or_dump(struct chamelium *chamelium,
 		free(reference_suffix);
 		free(capture_suffix);
 
-		chamelium_destroy_frame_dump(frame);
-
+		cairo_surface_destroy(reference);
 		cairo_surface_destroy(capture);
+		chamelium_destroy_frame_dump(frame);
 	}
 
 	igt_assert(eq);
@@ -1120,11 +1120,14 @@ void chamelium_assert_analog_frame_match_or_dump(struct chamelium *chamelium,
 
 		free(reference_suffix);
 		free(capture_suffix);
+		free(reference_crc);
+		free(capture_crc);
 	}
 
-	cairo_surface_destroy(capture);
-
 	igt_assert(match);
+
+	cairo_surface_destroy(reference);
+	cairo_surface_destroy(capture);
 }
 
 
@@ -1323,6 +1326,8 @@ igt_crc_t *chamelium_calculate_fb_crc(int fd, struct igt_fb *fb)
 
 	chamelium_do_calculate_fb_crc(fb_surface, ret);
 
+	cairo_surface_destroy(fb_surface);
+
 	return ret;
 }
 
-- 
2.20.1

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

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

* [igt-dev] [PATCH i-g-t v6 17/22] lib/igt_chamelium: Split frames dump logic and rework surroundings
  2019-02-22  9:28 [igt-dev] [PATCH i-g-t v6 00/22] Chamelium VC4 plane fuzzy testing, with SAND and T-tiled mode Paul Kocialkowski
                   ` (15 preceding siblings ...)
  2019-02-22  9:29 ` [igt-dev] [PATCH i-g-t v6 16/22] lib/igt_chamelium: Fixup resources liberation in comparison helpers Paul Kocialkowski
@ 2019-02-22  9:29 ` Paul Kocialkowski
  16 siblings, 0 replies; 18+ messages in thread
From: Paul Kocialkowski @ 2019-02-22  9:29 UTC (permalink / raw)
  To: igt-dev; +Cc: Petri Latvala, Eben Upton, Thomas Petazzoni

The frame dump logic is the same for all comparison helpers, so split
it to a dedicated function and adapt helpers using it to avoid
duplicating operations.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.com>
---
 lib/igt_chamelium.c | 87 +++++++++++++++++++++++++++------------------
 1 file changed, 52 insertions(+), 35 deletions(-)

diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index 0b6ac37a3d89..dcf8e2f151ab 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -124,6 +124,9 @@ struct chamelium {
 
 static struct chamelium *cleanup_instance;
 
+static void chamelium_do_calculate_fb_crc(cairo_surface_t *fb_surface,
+					  igt_crc_t *out);
+
 /**
  * chamelium_get_ports:
  * @chamelium: The Chamelium instance to use
@@ -967,6 +970,39 @@ static cairo_surface_t *convert_frame_dump_argb32(const struct chamelium_frame_d
 	return dump_surface;
 }
 
+static void compared_frames_dump(cairo_surface_t *reference,
+				 cairo_surface_t *capture,
+				 igt_crc_t *reference_crc,
+				 igt_crc_t *capture_crc)
+{
+	char *reference_suffix;
+	char *capture_suffix;
+	igt_crc_t local_reference_crc;
+	igt_crc_t local_capture_crc;
+
+	igt_assert(reference && capture);
+
+	if (!reference_crc) {
+		chamelium_do_calculate_fb_crc(reference, &local_reference_crc);
+		reference_crc = &local_reference_crc;
+	}
+
+	if (!capture_crc) {
+		chamelium_do_calculate_fb_crc(reference, &local_capture_crc);
+		capture_crc = &local_capture_crc;
+	}
+
+	reference_suffix = igt_crc_to_string_extended(reference_crc, '-', 2);
+	capture_suffix = igt_crc_to_string_extended(capture_crc, '-', 2);
+
+	/* Write reference and capture frames to png. */
+	igt_write_compared_frames_to_png(reference, capture, reference_suffix,
+					 capture_suffix);
+
+	free(reference_suffix);
+	free(capture_suffix);
+}
+
 /**
  * chamelium_assert_frame_eq:
  * @chamelium: The chamelium instance the frame dump belongs to
@@ -1029,8 +1065,6 @@ void chamelium_assert_crc_eq_or_dump(struct chamelium *chamelium,
 	struct chamelium_frame_dump *frame;
 	cairo_surface_t *reference;
 	cairo_surface_t *capture;
-	char *reference_suffix;
-	char *capture_suffix;
 	bool eq;
 
 	igt_debug("Reference CRC: %s\n", igt_crc_to_string(reference_crc));
@@ -1038,27 +1072,19 @@ void chamelium_assert_crc_eq_or_dump(struct chamelium *chamelium,
 
 	eq = igt_check_crc_equal(reference_crc, capture_crc);
 	if (!eq && igt_frame_dump_is_enabled()) {
-		/* Grab the reference frame from framebuffer */
+		/* Convert the reference framebuffer to cairo. */
 		reference = igt_get_cairo_surface(chamelium->drm_fd, fb);
 
-		/* Grab the captured frame from chamelium */
+		/* Grab the captured frame from the Chamelium. */
 		frame = chamelium_read_captured_frame(chamelium, index);
 		igt_assert(frame);
 
+		/* Convert the captured frame to cairo. */
 		capture = convert_frame_dump_argb32(frame);
+		igt_assert(capture);
 
-		reference_suffix = igt_crc_to_string_extended(reference_crc,
-							      '-', 2);
-		capture_suffix = igt_crc_to_string_extended(capture_crc, '-',
-							    2);
-
-		/* Write reference and capture frames to png */
-		igt_write_compared_frames_to_png(reference, capture,
-						 reference_suffix,
-						 capture_suffix);
-
-		free(reference_suffix);
-		free(capture_suffix);
+		compared_frames_dump(reference, capture, reference_crc,
+				     capture_crc);
 
 		cairo_surface_destroy(reference);
 		cairo_surface_destroy(capture);
@@ -1087,8 +1113,6 @@ void chamelium_assert_analog_frame_match_or_dump(struct chamelium *chamelium,
 	cairo_surface_t *capture;
 	igt_crc_t *reference_crc;
 	igt_crc_t *capture_crc;
-	char *reference_suffix;
-	char *capture_suffix;
 	bool match;
 
 	/* Grab the reference frame from framebuffer */
@@ -1099,27 +1123,20 @@ void chamelium_assert_analog_frame_match_or_dump(struct chamelium *chamelium,
 
 	match = igt_check_analog_frame_match(reference, capture);
 	if (!match && igt_frame_dump_is_enabled()) {
-		reference_crc = chamelium_calculate_fb_crc(chamelium->drm_fd,
-							   fb);
-		capture_crc = chamelium_get_crc_for_area(chamelium, port, 0, 0,
-							 0, 0);
+		reference_crc = malloc(sizeof(igt_crc_t));
+		igt_assert(reference_crc);
 
-		igt_debug("Reference CRC: %s\n",
-			  igt_crc_to_string(reference_crc));
-		igt_debug("Captured CRC: %s\n", igt_crc_to_string(capture_crc));
+		/* Calculate the reference frame CRC. */
+		chamelium_do_calculate_fb_crc(reference, reference_crc);
 
-		reference_suffix = igt_crc_to_string_extended(reference_crc,
-							      '-', 2);
-		capture_suffix = igt_crc_to_string_extended(capture_crc, '-',
-							    2);
+		/* Get the captured frame CRC from the Chamelium. */
+		capture_crc = chamelium_get_crc_for_area(chamelium, port, 0, 0,
+							 0, 0);
+		igt_assert(capture_crc);
 
-		/* Write reference and capture frames to png */
-		igt_write_compared_frames_to_png(reference, capture,
-						 reference_suffix,
-						 capture_suffix);
+		compared_frames_dump(reference, capture, reference_crc,
+				     capture_crc);
 
-		free(reference_suffix);
-		free(capture_suffix);
 		free(reference_crc);
 		free(capture_crc);
 	}
-- 
2.20.1

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

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

end of thread, other threads:[~2019-02-22  9:30 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-22  9:28 [igt-dev] [PATCH i-g-t v6 00/22] Chamelium VC4 plane fuzzy testing, with SAND and T-tiled mode Paul Kocialkowski
2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 01/22] lib: drmtest: Add helpers to check and require the VC4 driver Paul Kocialkowski
2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 02/22] lib/igt_fb: Add checks on i915 for i915-specific tiled buffer allocation Paul Kocialkowski
2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 03/22] lib/igt_fb: Refactor create_bo_for_fb to prepare for VC4 support Paul Kocialkowski
2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 04/22] lib/igt_fb: Add support for allocating T-tiled VC4 buffers Paul Kocialkowski
2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 05/22] lib/igt_fb: Add support for VC4 SAND tiling modes Paul Kocialkowski
2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 06/22] lib/igt_fb: Allow interpreting the tile height as a stride equivalent Paul Kocialkowski
2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 07/22] lib/igt_fb: Add a stride-provisioned fashion of igt_fb_convert Paul Kocialkowski
2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 08/22] lib/igt_fb: Add a helper to retreive the plane bpp for a given format Paul Kocialkowski
2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 09/22] lib/igt_fb: Add a helper to fill-in the available DRM formats Paul Kocialkowski
2019-02-22  9:28 ` [igt-dev] [PATCH i-g-t v6 10/22] lib/igt_vc4: Add helpers for converting linear to T-tiled RGB buffers Paul Kocialkowski
2019-02-22  9:29 ` [igt-dev] [PATCH i-g-t v6 11/22] lib/igt_vc4: Add helpers for converting linear to SAND-tiled buffers Paul Kocialkowski
2019-02-22  9:29 ` [igt-dev] [PATCH i-g-t v6 12/22] lib/igt_fb: Pass the modifier to igt_fb_convert helpers Paul Kocialkowski
2019-02-22  9:29 ` [igt-dev] [PATCH i-g-t v6 13/22] lib/igt_fb: Support converting to VC4 modifiers in igt_fb_convert Paul Kocialkowski
2019-02-22  9:29 ` [igt-dev] [PATCH i-g-t v6 14/22] lib/igt_kms: Add helpers to count and iterate planes from pipe Paul Kocialkowski
2019-02-22  9:29 ` [igt-dev] [PATCH i-g-t v6 15/22] lib/igt_kms: Add helpers to count and iterate planes from output Paul Kocialkowski
2019-02-22  9:29 ` [igt-dev] [PATCH i-g-t v6 16/22] lib/igt_chamelium: Fixup resources liberation in comparison helpers Paul Kocialkowski
2019-02-22  9:29 ` [igt-dev] [PATCH i-g-t v6 17/22] lib/igt_chamelium: Split frames dump logic and rework surroundings Paul Kocialkowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox