ionutils.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef __ION_UTILS_H
  2. #define __ION_UTILS_H
  3. #include "ion.h"
  4. #define SOCKET_NAME "ion_socket"
  5. #define ION_DEVICE "/dev/ion"
  6. #define ION_BUFFER_LEN 4096
  7. #define MAX_HEAP_COUNT ION_HEAP_TYPE_CUSTOM
  8. struct socket_info {
  9. int sockfd;
  10. int datafd;
  11. unsigned long buflen;
  12. };
  13. struct ion_buffer_info {
  14. int ionfd;
  15. int buffd;
  16. unsigned int heap_type;
  17. unsigned int flag_type;
  18. unsigned long heap_size;
  19. unsigned long buflen;
  20. unsigned char *buffer;
  21. };
  22. /* This is used to fill the data into the mapped buffer */
  23. void write_buffer(void *buffer, unsigned long len);
  24. /* This is used to read the data from the exported buffer */
  25. void read_buffer(void *buffer, unsigned long len);
  26. /* This is used to create an ION buffer FD for the kernel buffer
  27. * So you can export this same buffer to others in the form of FD
  28. */
  29. int ion_export_buffer_fd(struct ion_buffer_info *ion_info);
  30. /* This is used to import or map an exported FD.
  31. * So we point to same buffer without making a copy. Hence zero-copy.
  32. */
  33. int ion_import_buffer_fd(struct ion_buffer_info *ion_info);
  34. /* This is used to close all references for the ION client */
  35. void ion_close_buffer_fd(struct ion_buffer_info *ion_info);
  36. /* This is used to send FD to another process using socket IPC */
  37. int socket_send_fd(struct socket_info *skinfo);
  38. /* This is used to receive FD from another process using socket IPC */
  39. int socket_receive_fd(struct socket_info *skinfo);
  40. #endif