[igt-dev] [PATCH i-g-t v3 03/21] lib/igt_fb: Add support for allocating T-tiled VC4 buffers

Paul Kocialkowski paul.kocialkowski at bootlin.com
Fri Jan 11 09:05:14 UTC 2019


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 at bootlin.com>
---
 lib/igt_fb.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 9ecd10b8cde1..73f33a26a81f 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"
@@ -237,6 +238,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))
@@ -290,6 +294,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);
 	}
@@ -581,6 +590,13 @@ static int create_bo_for_fb(struct igt_fb *fb)
 			       igt_fb_mod_to_tiling(fb->tiling),
 			       fb->strides[0]);
 
+		goto out;
+	} 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);
+
 		goto out;
 	}
 
@@ -1493,6 +1509,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



More information about the igt-dev mailing list