[igt-dev] [PATCH i-g-t 1/4] lib/intel_bufops: Add intel_buf create/destroy functions
Dominik Grzegorzek
dominik.grzegorzek at intel.com
Mon Jun 29 11:10:01 UTC 2020
From: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
Add create/destroy of intel_buf objects to fill the API gap.
Change function name to be more consistent with other functions names:
buf_ops_getfd() -> buf_ops_get_fd()
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
---
lib/intel_bufops.c | 32 ++++++++++++++++++++++++++++----
lib/intel_bufops.h | 8 +++++++-
2 files changed, 35 insertions(+), 5 deletions(-)
diff --git a/lib/intel_bufops.c b/lib/intel_bufops.c
index 0337b638..8bbb8b12 100644
--- a/lib/intel_bufops.c
+++ b/lib/intel_bufops.c
@@ -697,7 +697,6 @@ static void __intel_buf_init(struct buf_ops *bops,
igt_require(bops->intel_gen >= 9);
igt_assert(req_tiling == I915_TILING_Y ||
req_tiling == I915_TILING_Yf);
-
/*
* On GEN12+ we align the main surface to 4 * 4 main surface
* tiles, which is 64kB. These 16 tiles are mapped by 4 AUX
@@ -724,7 +723,6 @@ static void __intel_buf_init(struct buf_ops *bops,
buf->aux.stride = aux_width;
size = buf->aux.offset + aux_width * aux_height;
-
} else {
if (buf->tiling) {
devid = intel_get_drm_devid(bops->fd);
@@ -826,6 +824,32 @@ void intel_buf_init_using_handle(struct buf_ops *bops,
req_tiling, compression);
}
+struct intel_buf *intel_buf_create(struct buf_ops *bops,
+ int width, int height,
+ int bpp, int alignment,
+ uint32_t req_tiling, uint32_t compression)
+{
+ struct intel_buf *buf;
+
+ igt_assert(bops);
+
+ buf = calloc(1, sizeof(*buf));
+ igt_assert(buf);
+
+ intel_buf_init(bops, buf, width, height, bpp, alignment,
+ req_tiling, compression);
+
+ return buf;
+}
+
+void intel_buf_destroy(struct intel_buf *buf)
+{
+ igt_assert(buf);
+
+ intel_buf_close(buf->bops, buf);
+ free(buf);
+}
+
#define DEFAULT_BUFOPS(__gen_start, __gen_end) \
.gen_start = __gen_start, \
.gen_end = __gen_end, \
@@ -1061,12 +1085,12 @@ void buf_ops_destroy(struct buf_ops *bops)
}
/**
- * buf_ops_getfd
+ * buf_ops_get_fd
* @bops: pointer to buf_ops
*
* Returns: drm fd
*/
-int buf_ops_getfd(struct buf_ops *bops)
+int buf_ops_get_fd(struct buf_ops *bops)
{
igt_assert(bops);
diff --git a/lib/intel_bufops.h b/lib/intel_bufops.h
index 95217cfe..327ac92e 100644
--- a/lib/intel_bufops.h
+++ b/lib/intel_bufops.h
@@ -64,7 +64,7 @@ intel_buf_aux_height(int gen, const struct intel_buf *buf)
struct buf_ops *buf_ops_create(int fd);
void buf_ops_destroy(struct buf_ops *bops);
-int buf_ops_getfd(struct buf_ops *bops);
+int buf_ops_get_fd(struct buf_ops *bops);
bool buf_ops_set_software_tiling(struct buf_ops *bops,
uint32_t tiling,
@@ -90,4 +90,10 @@ void intel_buf_init_using_handle(struct buf_ops *bops,
int width, int height, int bpp, int alignment,
uint32_t req_tiling, uint32_t compression);
+struct intel_buf *intel_buf_create(struct buf_ops *bops,
+ int width, int height,
+ int bpp, int alignment,
+ uint32_t req_tiling, uint32_t compression);
+void intel_buf_destroy(struct intel_buf *buf);
+
#endif
--
2.20.1
More information about the igt-dev
mailing list