[igt-dev] [PATCH i-g-t v8 08/16] lib/igt_fb: Removal of libdrm dependency
Zbigniew Kempczyński
zbigniew.kempczynski at intel.com
Mon Jul 27 11:44:04 UTC 2020
From: Dominik Grzegorzek <dominik.grzegorzek at intel.com>
Adopt to intel_bb/intel_buf for libdrm removal.
Signed-off-by: Dominik Grzegorzek <dominik.grzegorzek at intel.com>
Cc: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
---
lib/igt_fb.c | 96 +++++++++++++++++++++++++++++-----------------------
1 file changed, 54 insertions(+), 42 deletions(-)
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 3864b7a1..748c9c5a 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -45,6 +45,7 @@
#include "intel_batchbuffer.h"
#include "intel_chipset.h"
#include "i915/gem_mman.h"
+#include "intel_bufops.h"
/**
* SECTION:igt_fb
@@ -1973,8 +1974,8 @@ struct fb_blit_upload {
int fd;
struct igt_fb *fb;
struct fb_blit_linear linear;
- drm_intel_bufmgr *bufmgr;
- struct intel_batchbuffer *batch;
+ struct buf_ops *bops;
+ struct intel_bb *ibb;
};
static bool fast_blit_ok(const struct igt_fb *fb)
@@ -2044,14 +2045,14 @@ static bool use_blitter(const struct igt_fb *fb)
!gem_has_mappable_ggtt(fb->fd);
}
-static void init_buf_ccs(struct igt_buf *buf, int ccs_idx,
+static void init_buf_ccs(struct intel_buf *buf, int ccs_idx,
uint32_t offset, uint32_t stride)
{
buf->ccs[ccs_idx].offset = offset;
buf->ccs[ccs_idx].stride = stride;
}
-static void init_buf_surface(struct igt_buf *buf, int surface_idx,
+static void init_buf_surface(struct intel_buf *buf, int surface_idx,
uint32_t offset, uint32_t stride, uint32_t size)
{
buf->surface[surface_idx].offset = offset;
@@ -2075,26 +2076,17 @@ static int yuv_semiplanar_bpp(uint32_t drm_format)
}
}
-static void init_buf(struct fb_blit_upload *blit,
- struct igt_buf *buf,
- const struct igt_fb *fb,
- const char *name)
+static struct intel_buf *create_buf(struct fb_blit_upload *blit,
+ const struct igt_fb *fb,
+ const char *name)
{
+ struct intel_buf *buf;
+ uint32_t bo_name, handle, compression;
int num_surfaces;
int i;
igt_assert_eq(fb->offsets[0], 0);
- buf->bo = gem_handle_to_libdrm_bo(blit->bufmgr, blit->fd,
- name, fb->gem_handle);
- buf->tiling = igt_fb_mod_to_tiling(fb->modifier);
- buf->bpp = fb->plane_bpp[0];
- buf->format_is_yuv = igt_format_is_yuv(fb->drm_format);
- buf->format_is_yuv_semiplanar =
- igt_format_is_yuv_semiplanar(fb->drm_format);
- if (buf->format_is_yuv_semiplanar)
- buf->yuv_semiplanar_bpp = yuv_semiplanar_bpp(fb->drm_format);
-
if (is_ccs_modifier(fb->modifier)) {
igt_assert_eq(fb->strides[0] & 127, 0);
@@ -2104,17 +2096,36 @@ static void init_buf(struct fb_blit_upload *blit,
igt_assert_eq(fb->strides[1] & 127, 0);
if (is_gen12_mc_ccs_modifier(fb->modifier))
- buf->compression = I915_COMPRESSION_MEDIA;
+ compression = I915_COMPRESSION_MEDIA;
else
- buf->compression = I915_COMPRESSION_RENDER;
+ compression = I915_COMPRESSION_RENDER;
+ } else {
+ num_surfaces = fb->num_planes;
+ compression = I915_COMPRESSION_NONE;
+ }
+ bo_name = gem_flink(blit->fd, fb->gem_handle);
+ handle = gem_open(blit->fd, bo_name);
+ buf = calloc(1, sizeof(*buf));
+ igt_assert(buf);
+ intel_buf_init_using_handle(blit->bops, handle, buf, fb->width,
+ fb->height, fb->plane_bpp[0], 0,
+ igt_fb_mod_to_tiling(fb->modifier),
+ compression);
+ intel_buf_set_name(buf, name);
+
+ buf->format_is_yuv = igt_format_is_yuv(fb->drm_format);
+ buf->format_is_yuv_semiplanar =
+ igt_format_is_yuv_semiplanar(fb->drm_format);
+ if (buf->format_is_yuv_semiplanar)
+ buf->yuv_semiplanar_bpp = yuv_semiplanar_bpp(fb->drm_format);
+
+ if (is_ccs_modifier(fb->modifier)) {
num_surfaces = fb->num_planes / 2;
for (i = 0; i < num_surfaces; i++)
init_buf_ccs(buf, i,
fb->offsets[num_surfaces + i],
fb->strides[num_surfaces + i]);
- } else {
- num_surfaces = fb->num_planes;
}
igt_assert(fb->offsets[0] == 0);
@@ -2130,11 +2141,13 @@ static void init_buf(struct fb_blit_upload *blit,
if (fb->modifier == I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC)
buf->cc.offset = fb->offsets[2];
+
+ return buf;
}
-static void fini_buf(struct igt_buf *buf)
+static void fini_buf(struct intel_buf *buf)
{
- drm_intel_bo_unreference(buf->bo);
+ intel_buf_destroy(buf);
}
static bool use_vebox_copy(const struct igt_fb *src_fb,
@@ -2164,7 +2177,7 @@ static void copy_with_engine(struct fb_blit_upload *blit,
const struct igt_fb *dst_fb,
const struct igt_fb *src_fb)
{
- struct igt_buf src = {}, dst = {};
+ struct intel_buf *src, *dst;
igt_render_copyfunc_t render_copy = NULL;
igt_vebox_copyfunc_t vebox_copy = NULL;
@@ -2178,23 +2191,23 @@ static void copy_with_engine(struct fb_blit_upload *blit,
igt_assert_eq(dst_fb->offsets[0], 0);
igt_assert_eq(src_fb->offsets[0], 0);
- init_buf(blit, &src, src_fb, "cairo enginecopy src");
- init_buf(blit, &dst, dst_fb, "cairo enginecopy dst");
+ src = create_buf(blit, src_fb, "cairo enginecopy src");
+ dst = create_buf(blit, dst_fb, "cairo enginecopy dst");
if (vebox_copy)
- vebox_copy(blit->batch, &src,
+ vebox_copy(blit->ibb, src,
dst_fb->plane_width[0], dst_fb->plane_height[0],
- &dst);
+ dst);
else
- render_copy(blit->batch, NULL,
- &src,
+ render_copy(blit->ibb, 0,
+ src,
0, 0,
dst_fb->plane_width[0], dst_fb->plane_height[0],
- &dst,
+ dst,
0, 0);
- fini_buf(&dst);
- fini_buf(&src);
+ fini_buf(dst);
+ fini_buf(src);
}
static void blitcopy(const struct igt_fb *dst_fb,
@@ -2268,7 +2281,7 @@ static void free_linear_mapping(struct fb_blit_upload *blit)
gem_set_domain(fd, linear->fb.gem_handle,
I915_GEM_DOMAIN_GTT, 0);
- if (blit->batch)
+ if (blit->ibb)
copy_with_engine(blit, fb, &linear->fb);
else
blitcopy(fb, &linear->fb);
@@ -2277,9 +2290,9 @@ static void free_linear_mapping(struct fb_blit_upload *blit)
gem_close(fd, linear->fb.gem_handle);
}
- if (blit->batch) {
- intel_batchbuffer_free(blit->batch);
- drm_intel_bufmgr_destroy(blit->bufmgr);
+ if (blit->ibb) {
+ intel_bb_destroy(blit->ibb);
+ buf_ops_destroy(blit->bops);
}
}
@@ -2301,9 +2314,8 @@ static void setup_linear_mapping(struct fb_blit_upload *blit)
struct fb_blit_linear *linear = &blit->linear;
if (!igt_vc4_is_tiled(fb->modifier) && use_enginecopy(fb)) {
- blit->bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
- blit->batch = intel_batchbuffer_alloc(blit->bufmgr,
- intel_get_drm_devid(fd));
+ blit->bops = buf_ops_create(fd);
+ blit->ibb = intel_bb_create(fd, 4096);
}
/*
@@ -2335,7 +2347,7 @@ static void setup_linear_mapping(struct fb_blit_upload *blit)
gem_set_domain(fd, linear->fb.gem_handle,
I915_GEM_DOMAIN_GTT, 0);
- if (blit->batch)
+ if (blit->ibb)
copy_with_engine(blit, &linear->fb, fb);
else
blitcopy(&linear->fb, fb);
--
2.26.0
More information about the igt-dev
mailing list