aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ion.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/ion.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/ion.h')
-rw-r--r--lib/ion.h108
1 files changed, 108 insertions, 0 deletions
diff --git a/lib/ion.h b/lib/ion.h
new file mode 100644
index 00000000..c598b968
--- /dev/null
+++ b/lib/ion.h
@@ -0,0 +1,108 @@
+#ifndef ION_GEM_H
+#define ION_GEM_H
+
+#include "igt.h"
+#include "gem.h"
+
+/**
+ * ion_get_heap_id:
+ * @ion_fd: open ion device fd
+ * @heap_type: ION_HEAP_TYPE_* constant
+ * Returns: the index of the first heap with type matching heap_type, or -1 on
+ * failure
+ **/
+int ion_get_heap_id(int ion_fd, uint32_t heap_type);
+
+/**
+ * ion_alloc_one_fd
+ * @ion_fd: open ion device fd
+ * @size: size of the desired ion buffer
+ * @heap_id: index of the heap to allocate from
+ * @ion_buffer_fd: (out) ion buffer fd
+ * Returns: 0 on success; not 0 otherwise
+ **/
+int ion_alloc_one_fd(int ion_fd, size_t size, int heap_id, int *ion_buffer_fd);
+
+/**
+ * ion_mmap
+ * @ptr: (out) pointer to the buffer in the user process's memory
+ * @ion_buffer_fd: ion buffer fd
+ * @size: size of the desired mapping
+ * Returns: 0 on success; not 0 otherwise
+ **/
+int ion_mmap(void **ptr, int ion_buffer_fd, size_t size);
+
+/**
+ * ion_munmap
+ * @ptr: pointer to the buffer in the user process's memory
+ * @size: exact size of the mapping
+ * Returns: 0 on success; not 0 otherwise
+ **/
+int ion_munmap(void *ptr, size_t size);
+
+/**
+ * drm_check_prime_caps
+ * drm_fd: open DRM device fd
+ * Returns: 0 if the device supports Prime import/export; -1 otherwise
+ **/
+int drm_check_prime_caps(int drm_fd);
+
+/**
+ * gem_handle_for_ion_buffer
+ * drm_fd: open DRM device fd
+ * gem_handle: (out) GEM handle
+ * ion_fd: ion buffer fd
+ *
+ * Imports an ion buffer into GEM
+ *
+ * Returns: 0 if the ion buffer could be imported; -1 otherwise
+ **/
+int gem_handle_for_ion_buffer(int drm_fd, uint32_t *gem_handle, int ion_buffer_fd);
+
+/**
+ * ion_fd_for_gem_handle
+ * drm_fd: open DRM device fd
+ * ion_fd: ion buffer fd
+ *
+ * Exports a GEM buffer into ion
+ *
+ * Returns: 0 if the buffer could be exported; -1 otherwise
+ **/
+int ion_fd_for_gem_handle(int drm_fd, int *ion_bufferfd, uint32_t gem_handle);
+
+/**
+ * drm_fb_for_ion_buffer
+ * drm_fd: open DRM device fd
+ * fb_id: (out) id of the DRM KMS fb
+ * ion_fd: ion buffer fd
+ * fb_config: metadata for the fb
+ *
+ * Converts an ion buffer into a DRM KMS fb
+ *
+ * Returns: 0 if the buffer could be exported; -1 otherwise
+ **/
+int drm_fb_for_ion_buffer(int drm_fd, uint32_t *fb_id, int ion_buffer_fd,
+ const struct fb_configuration *fb_config);
+
+/**
+ * drm_release_fb
+ * drm_fd: open DRM device fd
+ * fb_id: id of the DRM KMS fb
+ *
+ * Releases the DRM KMS fb
+ **/
+void drm_release_fb(int drm_fd, uint32_t fb_id);
+
+/**
+ * ion_clone_fd_via_gem
+ * drm_fd: open DRM device fd
+ * cloned_fd: (out) cloned buffer fd
+ * ion_fd: ion buffer fd
+ *
+ * Uses GEM to clone an ion fd by importing and re-exporting it.
+ *
+ * Returns: 0 if the buffer could be cloned; -1 otherwise
+ **/
+int ion_clone_fd_via_gem(int drm_fd, int *cloned_fd, int ion_buffer_fd);
+
+#endif