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

Paul Kocialkowski paul.kocialkowski at bootlin.com
Thu Dec 6 14:11:28 UTC 2018


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 | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index ccdf07d0..61250b0e 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(ptr != MAP_FAILED);
 
-- 
2.19.2



More information about the igt-dev mailing list