Lines Matching refs:fd
44 int ion_is_legacy(int fd) { in ion_is_legacy() argument
51 int err = ion_free(fd, (ion_user_handle_t)NULL); in ion_is_legacy()
59 int fd = open("/dev/ion", O_RDONLY | O_CLOEXEC); in ion_open() local
60 if (fd < 0) ALOGE("open /dev/ion failed: %s", strerror(errno)); in ion_open()
62 return fd; in ion_open()
65 int ion_close(int fd) { in ion_close() argument
66 int ret = close(fd); in ion_close()
71 static int ion_ioctl(int fd, int req, void* arg) { in ion_ioctl() argument
72 int ret = ioctl(fd, req, arg); in ion_ioctl()
80 int ion_is_using_modular_heaps(int fd) { in ion_is_using_modular_heaps() argument
84 ret = ion_ioctl(fd, ION_IOC_ABI_VERSION, &ion_abi_version); in ion_is_using_modular_heaps()
88 int ion_alloc(int fd, size_t len, size_t align, unsigned int heap_mask, unsigned int flags, in ion_alloc() argument
92 if ((handle == NULL) || (!ion_is_legacy(fd))) return -EINVAL; in ion_alloc()
98 ret = ion_ioctl(fd, ION_IOC_ALLOC, &data); in ion_alloc()
106 int ion_free(int fd, ion_user_handle_t handle) { in ion_free() argument
110 return ion_ioctl(fd, ION_IOC_FREE, &data); in ion_free()
113 int ion_map(int fd, ion_user_handle_t handle, size_t length, int prot, int flags, off_t offset, in ion_map() argument
115 if (!ion_is_legacy(fd)) return -EINVAL; in ion_map()
125 ret = ion_ioctl(fd, ION_IOC_MAP, &data); in ion_map()
127 if (data.fd < 0) { in ion_map()
131 tmp_ptr = mmap(NULL, length, prot, flags, data.fd, offset); in ion_map()
136 *map_fd = data.fd; in ion_map()
141 int ion_share(int fd, ion_user_handle_t handle, int* share_fd) { in ion_share() argument
147 if (!ion_is_legacy(fd)) return -EINVAL; in ion_share()
150 ret = ion_ioctl(fd, ION_IOC_SHARE, &data); in ion_share()
152 if (data.fd < 0) { in ion_share()
156 *share_fd = data.fd; in ion_share()
160 int ion_alloc_fd(int fd, size_t len, size_t align, unsigned int heap_mask, unsigned int flags, in ion_alloc_fd() argument
167 if (!ion_is_legacy(fd)) { in ion_alloc_fd()
174 ret = ion_ioctl(fd, ION_IOC_NEW_ALLOC, &data); in ion_alloc_fd()
176 *handle_fd = data.fd; in ion_alloc_fd()
178 ret = ion_alloc(fd, len, align, heap_mask, flags, &handle); in ion_alloc_fd()
180 ret = ion_share(fd, handle, handle_fd); in ion_alloc_fd()
181 ion_free(fd, handle); in ion_alloc_fd()
186 int ion_import(int fd, int share_fd, ion_user_handle_t* handle) { in ion_import() argument
189 .fd = share_fd, in ion_import()
192 if (!ion_is_legacy(fd)) return -EINVAL; in ion_import()
196 ret = ion_ioctl(fd, ION_IOC_IMPORT, &data); in ion_import()
202 int ion_sync_fd(int fd, int handle_fd) { in ion_sync_fd() argument
204 .fd = handle_fd, in ion_sync_fd()
207 if (!ion_is_legacy(fd)) return -EINVAL; in ion_sync_fd()
209 return ion_ioctl(fd, ION_IOC_SYNC, &data); in ion_sync_fd()
212 int ion_query_heap_cnt(int fd, int* cnt) { in ion_query_heap_cnt() argument
219 ret = ion_ioctl(fd, ION_IOC_HEAP_QUERY, &query); in ion_query_heap_cnt()
226 int ion_query_get_heaps(int fd, int cnt, void* buffers) { in ion_query_get_heaps() argument
232 ret = ion_ioctl(fd, ION_IOC_HEAP_QUERY, &query); in ion_query_get_heaps()