summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Ripard <maxime.ripard@bootlin.com>2019-02-08 14:18:57 +0100
committerPaul Kocialkowski <paul.kocialkowski@bootlin.com>2019-02-11 10:53:07 +0100
commit270e8229ed10de119a4c85e88505751fbd15d0fe (patch)
treecbee53c49529dec46158a8f86dcc098caad50e2d
parent062508c725125f2cdf49ddf23bec9f383b4326eb (diff)
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 <lyude@redhat.com> Reviewed-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com> Reviewed-by: Deepak Rawat <drawat@vmware.com>
-rw-r--r--lib/igt_fb.c27
1 files changed, 8 insertions, 19 deletions
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 6fe0d0847..e9728c0c0 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);