[igt-dev] [PATCH i-g-t v2 09/13] igt: fb: Rework YUV i915 allocation path
Maxime Ripard
maxime.ripard at bootlin.com
Tue Jan 8 15:19:55 UTC 2019
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 at bootlin.com>
---
lib/igt_fb.c | 26 ++++++++------------------
1 file changed, 8 insertions(+), 18 deletions(-)
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);
--
2.20.1
More information about the igt-dev
mailing list