aboutsummaryrefslogtreecommitdiffstats
path: root/lib/gem.h
diff options
context:
space:
mode:
authorSean Callanan <spyffe@google.com>2019-11-27 16:39:24 -0800
committerandroid-build-merger <android-build-merger@google.com>2019-11-27 16:39:24 -0800
commitbe62c784dbba55ebf057b7498325648e86462ff2 (patch)
tree850a6f81ff1d27569736452389a2e9a4fb1b9093 /lib/gem.h
parent0d5e3ba4977cd6b99c7a309c53cc14adce490ed8 (diff)
parent839bbf47aa8e19169e17fcbb6a79c68fffa3d820 (diff)
downloadplatform_external_igt-gpu-tools-be62c784dbba55ebf057b7498325648e86462ff2.tar.gz
platform_external_igt-gpu-tools-be62c784dbba55ebf057b7498325648e86462ff2.tar.bz2
platform_external_igt-gpu-tools-be62c784dbba55ebf057b7498325648e86462ff2.zip
igt-gpu-tools: add tests for ion/gem interaction am: 2db11e1cbb am: 7553c470d4
am: 839bbf47aa Change-Id: I1ce28d05c7a0501b95f4e7b1f167566a3835fc89
Diffstat (limited to 'lib/gem.h')
-rw-r--r--lib/gem.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/lib/gem.h b/lib/gem.h
new file mode 100644
index 00000000..790d9adb
--- /dev/null
+++ b/lib/gem.h
@@ -0,0 +1,85 @@
+#ifndef GEM_H
+#define GEM_H
+
+#include "igt.h"
+
+struct gem_driver
+{
+ /**
+ * mmap:
+ * @ptr: (out) pointer to the buffer in the user process's memory
+ * @drm_fd: open DRM device fd
+ * @gem_handle: GEM handle
+ * @size: exact size of the GEM buffer
+ *
+ * Maps the buffer backing the GEM handle for reading and writing.
+ *
+ * Returns: 0 on success, -1 otherwise
+ **/
+ int (*mmap)(void **ptr, int drm_fd, uint32_t gem_handle, size_t size);
+
+ /**
+ * munmap:
+ * @drm_fd: open DRM device fd
+ * @gem_handle: GEM handle
+ * @ptr: pointer (see ptr argument to mmap)
+ * @size: exact size of the mapped area
+ *
+ * Unmaps a region previously mapped with mmap.
+ *
+ * Returns: 0 on success: -1 otherwise
+ **/
+ int (*munmap)(int drm_fd, uint32_t gem_handle, void *ptr, size_t size);
+};
+
+/**
+ * gem_get_driver:
+ * @drm_fd: open DRM device fd
+ *
+ * Gets the driver-specific GEM APIs for a particular device.
+ *
+ * Returns: a struct with function pointers on success; NULL otherwise
+ **/
+struct gem_driver *gem_get_driver(int drm_fd);
+
+/**
+ * gem_size:
+ * @drm_fd: open DRM device fd
+ * @size: (out) size of the buffer
+ * @gem_handle: GEM handle
+ * Returns: size of the buffer backing the GEM handle.
+ **/
+int gem_size(int drm_fd, size_t *size, uint32_t gem_handle);
+
+/**
+ * gem_release_handle
+ * @drm_fd: open DRM device fd
+ * @gem_handle: GEM handle
+ *
+ * Releases a GEM handle.
+ **/
+void gem_release_handle(int drm_fd, uint32_t gem_handle);
+
+struct fb_configuration
+{
+ uint32_t width;
+ uint32_t height;
+ uint32_t pixel_format;
+ uint32_t pixel_size;
+};
+
+/**
+ * drm_fb_for_gem_handle
+ * @drm_fd: open DRM device fd
+ * @fb_id: (out) id of the DRM KMS fb
+ * @gem_handle: GEM handle
+ * @fb_config: metadata for the fb
+ *
+ * Converts a GEM buffer into a DRM KMS fb
+ *
+ * Returns: 0 if the buffer could be converted; -1 otherwise
+ **/
+int drm_fb_for_gem_handle(int drm_fd, uint32_t *fb_id, uint32_t gem_handle,
+ const struct fb_configuration *fb_config);
+
+#endif