[i-g-t,v2,09/13] igt: fb: Rework YUV i915 allocation path

Submitted by Maxime Ripard on Jan. 8, 2019, 3:19 p.m.

Details

Message ID 20190108152001.5367-9-maxime.ripard@bootlin.com
State New
Headers show
Series "igt: chamelium: Test YUV buffers using the Chamelium" ( rev: 4 3 ) in IGT

Not browsing as part of any series.

Commit Message

Maxime Ripard Jan. 8, 2019, 3:19 p.m.
We only need to allocate a buffer using the GEM API when we're in the
condition that we currently test, and that we're running on i915.

All the other cases can be handled by a fallback to a dumb buffer
allocation. Let's simplify the code a bit to reflect that.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
---
 lib/igt_fb.c | 26 ++++++++------------------
 1 file changed, 8 insertions(+), 18 deletions(-)

Patch hide | download patch | download mbox

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 263a889dbaa3..386908b72782 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -536,26 +536,15 @@  static int create_bo_for_fb(struct igt_fb *fb)
 	if (fb->size == 0)
 		fb->size = size;
 
-	if (fb->tiling || fb->size || fb->strides[0] || igt_format_is_yuv(fb->drm_format)) {
-
+	if (is_i915_device(fd) &&
+	    (fb->tiling || fb->size || fb->strides[0] || igt_format_is_yuv(fb->drm_format))) {
 		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]);
-			clear_yuv_buffer(fd);
-
-			return fb->gem_handle;
-		} else {
-			bool driver_has_gem_api = false;
-
-			igt_require(driver_has_gem_api);
-			return -EINVAL;
-		}
+		goto out;
 	}
 
 	for (plane = 0; plane < fb->num_planes; plane++)
@@ -565,6 +554,7 @@  static int create_bo_for_fb(struct igt_fb *fb)
 	fb->gem_handle = kmstest_dumb_create(fd, fb->width, fb->height,
 					     bpp, &fb->strides[0], &fb->size);
 
+out:
 	if (igt_format_is_yuv(fb->drm_format))
 		clear_yuv_buffer(fb);