@@ -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;
+}
@@ -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 */
Signed-off-by: Eric Anholt <eric@anholt.net> --- lib/igt_vc4.c | 20 ++++++++++++++++++++ lib/igt_vc4.h | 1 + 2 files changed, 21 insertions(+)