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

Submitted by Maxime Ripard on Dec. 4, 2018, 10:08 a.m.

Details

Message ID 20181204100826.15522-6-maxime.ripard@bootlin.com
State New
Series "igt: chamelium: Test YUV buffers using the Chamelium"
Headers show

Commit Message

Maxime Ripard Dec. 4, 2018, 10:08 a.m.
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@bootlin.com>
---
 lib/igt_fb.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

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);