[igt-dev] [PATCH i-g-t 6/8] igt: fb: Separate YUV allocation from the rest

Maxime Ripard maxime.ripard at bootlin.com
Tue Dec 4 10:08:21 UTC 2018


Allocating YUV buffers is a different operation than allocating
buffers with non-trivial setups.

Let's separate the YUV buffer allocation to a case and function of its
own.

Signed-off-by: Maxime Ripard <maxime.ripard at bootlin.com>
---
 lib/igt_fb.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index d96689aa5fe6..d6242a6652f1 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -499,12 +499,30 @@ static int i915_create_gem_for_fb(struct igt_fb *fb)
 	return fb->gem_handle;
 }
 
+static int create_yuv_bo_for_fb(struct igt_fb *fb)
+{
+	uint64_t size = calc_fb_size(fb);
+	int fd = fb->fd;
+
+	/* respect the size requested by the caller */
+	if (fb->size == 0)
+		fb->size = size;
+
+	if (is_i915_device(fd))
+		return i915_create_gem_for_fb(fb);
+
+	/* We cannot allocate any other buffer type */
+	igt_assert(true);
+}
+
 /* helpers to create nice-looking framebuffers */
 static int create_bo_for_fb(struct igt_fb *fb)
 {
 	int fd = fb->fd;
 
-	if (fb->tiling || fb->size || fb->strides[0] || igt_format_is_yuv(fb->drm_format)) {
+	if (igt_format_is_yuv(fb->drm_format)) {
+		return create_yuv_bo_for_fb(fb);
+	} else if (fb->tiling || fb->size || fb->strides[0]) {
 		uint64_t size;
 
 		size = calc_fb_size(fb);
-- 
2.19.1



More information about the igt-dev mailing list