diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 10:05:51 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 10:05:51 +0000 |
commit | 5d1646d90e1f2cceb9f0828f4b28318cd0ec7744 (patch) | |
tree | a94efe259b9009378be6d90eb30d2b019d95c194 /tools/testing/selftests/android/ion/ionutils.h | |
parent | Initial commit. (diff) | |
download | linux-upstream.tar.xz linux-upstream.zip |
Adding upstream version 5.10.209.upstream/5.10.209upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | tools/testing/selftests/android/ion/ionutils.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tools/testing/selftests/android/ion/ionutils.h b/tools/testing/selftests/android/ion/ionutils.h new file mode 100644 index 000000000..9941eb858 --- /dev/null +++ b/tools/testing/selftests/android/ion/ionutils.h @@ -0,0 +1,55 @@ +#ifndef __ION_UTILS_H +#define __ION_UTILS_H + +#include "ion.h" + +#define SOCKET_NAME "ion_socket" +#define ION_DEVICE "/dev/ion" + +#define ION_BUFFER_LEN 4096 +#define MAX_HEAP_COUNT ION_HEAP_TYPE_CUSTOM + +struct socket_info { + int sockfd; + int datafd; + unsigned long buflen; +}; + +struct ion_buffer_info { + int ionfd; + int buffd; + unsigned int heap_type; + unsigned int flag_type; + unsigned long heap_size; + unsigned long buflen; + unsigned char *buffer; +}; + + +/* This is used to fill the data into the mapped buffer */ +void write_buffer(void *buffer, unsigned long len); + +/* This is used to read the data from the exported buffer */ +void read_buffer(void *buffer, unsigned long len); + +/* This is used to create an ION buffer FD for the kernel buffer + * So you can export this same buffer to others in the form of FD + */ +int ion_export_buffer_fd(struct ion_buffer_info *ion_info); + +/* This is used to import or map an exported FD. + * So we point to same buffer without making a copy. Hence zero-copy. + */ +int ion_import_buffer_fd(struct ion_buffer_info *ion_info); + +/* This is used to close all references for the ION client */ +void ion_close_buffer_fd(struct ion_buffer_info *ion_info); + +/* This is used to send FD to another process using socket IPC */ +int socket_send_fd(struct socket_info *skinfo); + +/* This is used to receive FD from another process using socket IPC */ +int socket_receive_fd(struct socket_info *skinfo); + + +#endif |