[Intel-gfx] [i-g-t PATCH v2 08/17] lib: Add helper kmstest_dumb_map_buffer
Tomeu Vizoso
tomeu.vizoso at collabora.com
Tue Mar 8 14:51:30 UTC 2016
Which basically just calls DRM_IOCTL_MODE_MAP_DUMB and is similar to
gem_mmap__gtt().
Signed-off-by: Tomeu Vizoso <tomeu.vizoso at collabora.com>
---
Changes in v2:
- Add helper kmstest_dumb_map_buffer as suggested by Daniel Vetter
lib/igt_kms.c | 16 ++++++++++++++++
lib/igt_kms.h | 3 +++
2 files changed, 19 insertions(+)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index ee375bffc5e2..a98c22a7f4dc 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -345,6 +345,22 @@ uint32_t kmstest_dumb_create(int fd, int width, int height, int bpp,
return create.handle;
}
+void *kmstest_dumb_map_buffer(int fd, uint32_t handle, uint64_t size,
+ unsigned prot)
+{
+ struct drm_mode_map_dumb arg = {};
+ void *ptr;
+
+ arg.handle = handle;
+
+ do_ioctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &arg);
+
+ ptr = mmap(0, size, prot, MAP_SHARED, fd, arg.offset);
+ igt_assert(ptr != MAP_FAILED);
+
+ return ptr;
+}
+
/*
* Returns: the previous mode, or KD_GRAPHICS if no /dev/tty0 was
* found and nothing was done.
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 45df8b556daf..af794cf2c916 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -158,6 +158,9 @@ uint32_t kmstest_find_crtc_for_connector(int fd, drmModeRes *res,
uint32_t kmstest_dumb_create(int fd, int width, int height, int bpp,
unsigned *stride, unsigned *size);
+void *kmstest_dumb_map_buffer(int fd, uint32_t handle, uint64_t size,
+ unsigned prot);
+
/*
* A small modeset API
*/
--
2.5.0
More information about the Intel-gfx
mailing list