[igt-dev] [PATCH i-g-t v33 19/40] tests/kms_cursor_crc: remove libdrm dependency
Zbigniew Kempczyński
zbigniew.kempczynski at intel.com
Mon Aug 31 13:30:28 UTC 2020
Use intel_bb / intel_buf to remove libdrm dependency.
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
Cc: Dominik Grzegorzek <dominik.grzegorzek at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
---
tests/kms_cursor_crc.c | 63 +++++++++++++++++++++---------------------
1 file changed, 32 insertions(+), 31 deletions(-)
diff --git a/tests/kms_cursor_crc.c b/tests/kms_cursor_crc.c
index e9491847..be37a75d 100644
--- a/tests/kms_cursor_crc.c
+++ b/tests/kms_cursor_crc.c
@@ -64,11 +64,11 @@ typedef struct {
igt_plane_t *cursor;
cairo_surface_t *surface;
uint32_t devid;
- drm_intel_bufmgr *bufmgr;
+ struct buf_ops *bops;
igt_render_copyfunc_t rendercopy;
- drm_intel_bo * drmibo[2];
- struct intel_batchbuffer *batch;
- struct igt_buf igtbo[2];
+ uint32_t drm_handle[2];
+ struct intel_bb *ibb;
+ struct intel_buf igtbo[2];
} data_t;
@@ -155,7 +155,7 @@ static void restore_image(data_t *data)
if (data->rendercopy != NULL) {
/* use rendercopy if available */
- data->rendercopy(data->batch, NULL,
+ data->rendercopy(data->ibb, 0,
&data->igtbo[RESTOREBUFFER], 0, 0,
data->primary_fb[RESTOREBUFFER].width,
data->primary_fb[RESTOREBUFFER].height,
@@ -381,16 +381,25 @@ static void cleanup_crtc(data_t *data)
igt_remove_fb(data->drm_fd, &data->primary_fb[FRONTBUFFER]);
igt_remove_fb(data->drm_fd, &data->primary_fb[RESTOREBUFFER]);
+ intel_bb_destroy(data->ibb);
+
igt_display_reset(display);
}
static void scratch_buf_init(data_t *data, int buffer)
{
- data->igtbo[buffer].bo = data->drmibo[buffer];
- data->igtbo[buffer].surface[0].stride = data->primary_fb[buffer].strides[0];
- data->igtbo[buffer].tiling = data->primary_fb[buffer].modifier;
- data->igtbo[buffer].surface[0].size = data->primary_fb[buffer].size;
- data->igtbo[buffer].bpp = data->primary_fb[buffer].plane_bpp[0];
+ uint32_t handle, tiling, stride, width, height, bpp, size;
+
+ handle = data->drm_handle[buffer];
+ size = data->primary_fb[buffer].size;
+ tiling = data->primary_fb[buffer].modifier;
+ stride = data->primary_fb[buffer].strides[0];
+ bpp = data->primary_fb[buffer].plane_bpp[0];
+ width = stride / (bpp / 8);
+ height = size / stride;
+
+ intel_buf_init_using_handle(data->bops, handle, &data->igtbo[buffer],
+ width, height, bpp, 0, tiling, 0);
}
static void prepare_crtc(data_t *data, igt_output_t *output,
@@ -450,6 +459,8 @@ static void prepare_crtc(data_t *data, igt_output_t *output,
igt_paint_test_pattern(cr, data->screenw, data->screenh);
cairo_destroy(cr);
} else {
+ uint32_t name;
+
/* store test image as fb if rendercopy is available */
cr = igt_get_cairo_ctx(data->drm_fd,
&data->primary_fb[RESTOREBUFFER]);
@@ -457,22 +468,20 @@ static void prepare_crtc(data_t *data, igt_output_t *output,
igt_paint_test_pattern(cr, data->screenw, data->screenh);
igt_put_cairo_ctx(cr);
- data->drmibo[FRONTBUFFER] = gem_handle_to_libdrm_bo(data->bufmgr,
- data->drm_fd,
- "", data->primary_fb[FRONTBUFFER].gem_handle);
- igt_assert(data->drmibo[FRONTBUFFER]);
+ name = gem_flink(data->drm_fd,
+ data->primary_fb[FRONTBUFFER].gem_handle);
+ data->drm_handle[FRONTBUFFER] = gem_open(data->drm_fd, name);
+ igt_assert(data->drm_handle[FRONTBUFFER]);
- data->drmibo[RESTOREBUFFER] = gem_handle_to_libdrm_bo(data->bufmgr,
- data->drm_fd,
- "", data->primary_fb[RESTOREBUFFER].gem_handle);
- igt_assert(data->drmibo[RESTOREBUFFER]);
+ name = gem_flink(data->drm_fd,
+ data->primary_fb[RESTOREBUFFER].gem_handle);
+ data->drm_handle[RESTOREBUFFER] = gem_open(data->drm_fd, name);
+ igt_assert(data->drm_handle[RESTOREBUFFER]);
scratch_buf_init(data, RESTOREBUFFER);
scratch_buf_init(data, FRONTBUFFER);
- data->batch = intel_batchbuffer_alloc(data->bufmgr,
- data->devid);
- igt_assert(data->batch);
+ data->ibb = intel_bb_create(data->drm_fd, 4096);
}
igt_pipe_crc_start(data->pipe_crc);
@@ -832,10 +841,7 @@ igt_main
igt_display_require(&data.display, data.drm_fd);
if (is_i915_device(data.drm_fd)) {
- data.bufmgr = drm_intel_bufmgr_gem_init(data.drm_fd, 4096);
- igt_assert(data.bufmgr);
- drm_intel_bufmgr_gem_enable_reuse(data.bufmgr);
-
+ data.bops = buf_ops_create(data.drm_fd);
data.devid = intel_get_drm_devid(data.drm_fd);
data.rendercopy = igt_get_render_copyfunc(data.devid);
}
@@ -854,12 +860,7 @@ igt_main
igt_pipe_crc_stop(data.pipe_crc);
igt_pipe_crc_free(data.pipe_crc);
}
-
- if (data.bufmgr != NULL) {
- intel_batchbuffer_free(data.batch);
- drm_intel_bufmgr_destroy(data.bufmgr);
- }
-
+ buf_ops_destroy(data.bops);
igt_display_fini(&data.display);
}
}
--
2.26.0
More information about the igt-dev
mailing list