From 270e8229ed10de119a4c85e88505751fbd15d0fe Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Fri, 8 Feb 2019 14:18:57 +0100 Subject: igt: fb: Rework YUV i915 allocation path 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. Reviewed-by: Lyude Paul Reviewed-by: Paul Kocialkowski Signed-off-by: Maxime Ripard Reviewed-by: Deepak Rawat --- lib/igt_fb.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) (limited to 'lib/igt_fb.c') diff --git a/lib/igt_fb.c b/lib/igt_fb.c index 6fe0d084..e9728c0c 100644 --- a/lib/igt_fb.c +++ b/lib/igt_fb.c @@ -534,7 +534,8 @@ static int create_bo_for_fb(struct igt_fb *fb) unsigned *strides = &fb->strides[0]; int fd = fb->fd; - 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))) { uint64_t size; size = calc_fb_size(fb); @@ -544,25 +545,12 @@ static int create_bo_for_fb(struct igt_fb *fb) fb->size = size; 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]); - - if (igt_format_is_yuv(fb->drm_format)) - clear_yuv_buffer(fb); - - return fb->gem_handle; - } else { - bool driver_has_gem_api = false; - - igt_require(driver_has_gem_api); - return -EINVAL; - } + goto out; } /* @@ -596,6 +584,7 @@ static int create_bo_for_fb(struct igt_fb *fb) fb->gem_handle = kmstest_dumb_create(fd, fb->width, fb->height, bpp, strides, &fb->size); +out: if (igt_format_is_yuv(fb->drm_format)) clear_yuv_buffer(fb); -- cgit v1.2.3