[Intel-gfx] [PATCH igt 6/9] igt: Add a helper function for mapping VC4 BOs.
Eric Anholt
eric at anholt.net
Wed Feb 3 21:41:40 UTC 2016
Signed-off-by: Eric Anholt <eric at anholt.net>
---
lib/igt_vc4.c | 20 ++++++++++++++++++++
lib/igt_vc4.h | 1 +
2 files changed, 21 insertions(+)
diff --git a/lib/igt_vc4.c b/lib/igt_vc4.c
index 62e1345..15804e9 100644
--- a/lib/igt_vc4.c
+++ b/lib/igt_vc4.c
@@ -25,6 +25,7 @@
#include <string.h>
#include <signal.h>
#include <errno.h>
+#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
@@ -104,3 +105,22 @@ uint32_t igt_vc4_get_cleared_bo(int fd, size_t size, uint32_t clearval)
return create.handle;
}
+
+void *
+igt_vc4_mmap_bo(int fd, uint32_t handle, uint32_t size, unsigned prot)
+{
+ struct drm_vc4_mmap_bo mmap_bo = {
+ .handle = handle,
+ };
+ int ret;
+ void *ptr;
+
+ ret = ioctl(fd, DRM_IOCTL_VC4_MMAP_BO, &mmap_bo);
+ igt_assert(ret == 0);
+
+ ptr = mmap(0, size, prot, MAP_SHARED, fd, mmap_bo.offset);
+ if (ptr == MAP_FAILED)
+ return NULL;
+ else
+ return ptr;
+}
diff --git a/lib/igt_vc4.h b/lib/igt_vc4.h
index 4622034..d428f39 100644
--- a/lib/igt_vc4.h
+++ b/lib/igt_vc4.h
@@ -25,5 +25,6 @@
#define IGT_VC4_H
uint32_t igt_vc4_get_cleared_bo(int fd, size_t size, uint32_t clearval);
+void *igt_vc4_mmap_bo(int fd, uint32_t handle, uint32_t size, unsigned prot);
#endif /* IGT_VC4_H */
--
2.7.0
More information about the Intel-gfx
mailing list