[igt-dev] [PATCH i-g-t v3 10/14] igt: fb: Rework YUV i915 allocation path
Maxime Ripard
maxime.ripard at bootlin.com
Tue Jan 22 13:42:53 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 4becbb4dbc08..4a33a00514aa 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -538,26 +538,15 @@ static int create_bo_for_fb(struct igt_fb *fb)
if (fb->size == 0)
fb->size = size;
- if (fb->tiling || fb->size || igt_format_is_yuv(fb->drm_format)) {
-
+ if (is_i915_device(fd) &&
+ (fb->tiling || fb->size || 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++)
@@ -582,6 +571,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);
--
2.20.1
More information about the igt-dev
mailing list