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