All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Subject: [igt-dev] [PATCH i-g-t v23 12/18] lib/igt_fb: Removal of libdrm dependency
Date: Sun,  2 Aug 2020 18:29:56 +0200	[thread overview]
Message-ID: <20200802163002.5815-13-zbigniew.kempczynski@intel.com> (raw)
In-Reply-To: <20200802163002.5815-1-zbigniew.kempczynski@intel.com>

From: Dominik Grzegorzek <dominik.grzegorzek@intel.com>

Adopt to intel_bb/intel_buf for libdrm removal.

Signed-off-by: Dominik Grzegorzek <dominik.grzegorzek@intel.com>
Cc: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Chris Wilson <chris@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

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2020-08-02 16:30 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-02 16:29 [igt-dev] [PATCH i-g-t v23 00/18] Remove libdrm in rendercopy Zbigniew Kempczyński
2020-08-02 16:29 ` [igt-dev] [PATCH i-g-t v23 01/18] lib/intel_bufops: add mapping on cpu / device Zbigniew Kempczyński
2020-08-02 16:29 ` [igt-dev] [PATCH i-g-t v23 02/18] lib/intel_bufops: change in hw/sw tiling detection Zbigniew Kempczyński
2020-08-02 16:29 ` [igt-dev] [PATCH i-g-t v23 03/18] lib/intel_bufops: change stride requirements for Grantsdale Zbigniew Kempczyński
2020-08-02 16:29 ` [igt-dev] [PATCH i-g-t v23 04/18] lib/intel_batchbuffer: add new functions to support rendercopy Zbigniew Kempczyński
2020-08-02 16:29 ` [igt-dev] [PATCH i-g-t v23 05/18] lib/intel_batchbuffer: dump bb to base64 Zbigniew Kempczyński
2020-08-02 16:29 ` [igt-dev] [PATCH i-g-t v23 06/18] lib/intel_batchbuffer: use canonical addresses for 48bit ppgtt Zbigniew Kempczyński
2020-08-02 16:29 ` [igt-dev] [PATCH i-g-t v23 07/18] tests/api_intel_bb: test flags are cleared on bb reset Zbigniew Kempczyński
2020-08-02 16:29 ` [igt-dev] [PATCH i-g-t v23 08/18] tests/gem_caching|partial: adopt to batch flush function cleanup Zbigniew Kempczyński
2020-08-02 16:29 ` [igt-dev] [PATCH i-g-t v23 09/18] lib/rendercopy: remove libdrm dependency Zbigniew Kempczyński
2020-08-02 16:29 ` [igt-dev] [PATCH i-g-t v23 10/18] tests/api_intel_bb: add render tests Zbigniew Kempczyński
2020-08-02 16:29 ` [igt-dev] [PATCH i-g-t v23 11/18] lib/igt_draw: remove libdrm dependency Zbigniew Kempczyński
2020-08-02 16:29 ` Zbigniew Kempczyński [this message]
2020-08-02 16:29 ` [igt-dev] [PATCH i-g-t v23 13/18] tests/gem|kms: remove libdrm dependency (batch 1) Zbigniew Kempczyński
2020-08-02 16:29 ` [igt-dev] [PATCH i-g-t v23 14/18] tests/gem|kms: remove libdrm dependency (batch 2) Zbigniew Kempczyński
2020-08-02 16:29 ` [igt-dev] [PATCH i-g-t v23 15/18] tools/intel_residency: adopt intel_residency to use bufops Zbigniew Kempczyński
2020-08-02 16:30 ` [igt-dev] [PATCH i-g-t v23 16/18] tests/perf: remove libdrm dependency for rendercopy Zbigniew Kempczyński
2020-08-02 16:30 ` [igt-dev] [PATCH i-g-t v23 17/18] fix: lib/intel_bufops: add 64bit bpp Zbigniew Kempczyński
2020-08-02 16:30 ` [igt-dev] [PATCH i-g-t v23 18/18] tests/kms_psr: trying to fix blt Zbigniew Kempczyński
2020-08-02 17:09 ` [igt-dev] ✓ Fi.CI.BAT: success for Remove libdrm in rendercopy (rev22) Patchwork
2020-08-02 20:36 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200802163002.5815-13-zbigniew.kempczynski@intel.com \
    --to=zbigniew.kempczynski@intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.