[igt-dev] [PATCH i-g-t v2 17/20] tests/prime_udl: Remove libdrm dependency

Dominik Grzegorzek dominik.grzegorzek at intel.com
Thu Sep 17 13:07:08 UTC 2020


Use intel_bb / intel_buf to remove libdrm dependency.

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>
---
 tests/prime_udl.c | 44 ++++++++++++++++++++------------------------
 1 file changed, 20 insertions(+), 24 deletions(-)

diff --git a/tests/prime_udl.c b/tests/prime_udl.c
index 9b600659..b2e94160 100644
--- a/tests/prime_udl.c
+++ b/tests/prime_udl.c
@@ -27,14 +27,13 @@
 #include "xf86drm.h"
 #include <xf86drmMode.h>
 
-#include "intel_bufmgr.h"
-
 int intel_fd = -1, udl_fd = -1;
-drm_intel_bufmgr *bufmgr;
-uint32_t devid;
-struct intel_batchbuffer *intel_batch;
+struct buf_ops *bops;
+
+#define WIDTH 640
+#define HEIGHT 480
+#define BO_SIZE (WIDTH*HEIGHT*2)
 
-#define BO_SIZE (640*480*2)
 
 static int find_and_open_devices(void)
 {
@@ -94,34 +93,38 @@ static int dumb_bo_destroy(int fd, uint32_t handle)
  */
 static int test1(void)
 {
-	drm_intel_bo *test_intel_bo;
+	struct intel_buf *test_intel_buf;
 	int prime_fd;
 	int ret;
 	uint32_t udl_handle;
 
-	test_intel_bo = drm_intel_bo_alloc(bufmgr, "test bo", BO_SIZE, 4096);
+	test_intel_buf = intel_buf_create(bops, WIDTH, HEIGHT, 16, 4096,
+					  I915_TILING_NONE,
+					  I915_COMPRESSION_NONE);
 
-	drm_intel_bo_gem_export_to_prime(test_intel_bo, &prime_fd);
+	prime_fd = prime_handle_to_fd(intel_fd, test_intel_buf->handle);
 
 	ret = drmPrimeFDToHandle(udl_fd, prime_fd, &udl_handle);
 
 	dumb_bo_destroy(udl_fd, udl_handle);
-	drm_intel_bo_unreference(test_intel_bo);
+	intel_buf_destroy(test_intel_buf);
 	return ret;
 }
 
 static int test2(void)
 {
-	drm_intel_bo *test_intel_bo;
+	struct intel_buf *test_intel_buf;
 	uint32_t fb_id;
 	drmModeClip clip;
 	int prime_fd;
 	uint32_t udl_handle;
 	int ret;
 
-	test_intel_bo = drm_intel_bo_alloc(bufmgr, "test bo", BO_SIZE, 4096);
+	test_intel_buf = intel_buf_create(bops, WIDTH, HEIGHT, 16, 4096,
+					  I915_TILING_NONE,
+					  I915_COMPRESSION_NONE);
 
-	drm_intel_bo_gem_export_to_prime(test_intel_bo, &prime_fd);
+	prime_fd = prime_handle_to_fd(intel_fd, test_intel_buf->handle);
 
 	ret = drmPrimeFDToHandle(udl_fd, prime_fd, &udl_handle);
 	if (ret)
@@ -141,7 +144,7 @@ static int test2(void)
 	}
 out:
 	dumb_bo_destroy(udl_fd, udl_handle);
-	drm_intel_bo_unreference(test_intel_bo);
+	intel_buf_destroy(test_intel_buf);
 	return ret;
 }
 
@@ -152,22 +155,15 @@ igt_simple_main
 	igt_skip_on(udl_fd == -1);
 	igt_skip_on(intel_fd == -1);
 
-	/* set up intel bufmgr */
-	bufmgr = drm_intel_bufmgr_gem_init(intel_fd, 4096);
-	drm_intel_bufmgr_gem_enable_reuse(bufmgr);
-
-	/* set up an intel batch buffer */
-	devid = intel_get_drm_devid(intel_fd);
-	intel_batch = intel_batchbuffer_alloc(bufmgr, devid);
+	/* set up intel buf ops */
+	bops = buf_ops_create(intel_fd);
 
 	/* create an object on the i915 */
 	igt_assert(test1() == 0);
 
 	igt_assert(test2() == 0);
 
-	intel_batchbuffer_free(intel_batch);
-
-	drm_intel_bufmgr_destroy(bufmgr);
+	buf_ops_destroy(bops);
 
 	close(intel_fd);
 	close(udl_fd);
-- 
2.20.1



More information about the igt-dev mailing list