int omap_ion_fd_to_handles(int fd, struct ion_client **client, struct ion_handle **handles, int *num_handles) { #ifdef CONFIG_PVR_SGX if (*num_handles == 2) PVRSRVExportFDToIONHandles(fd, client, handles); else if (*num_handles == 1) handles[0] = PVRSRVExportFDToIONHandle(fd, client); else return -EINVAL; #else if (export_fd_to_ion_handles) { export_fd_to_ion_handles(fd, client, handles, num_handles); } else { pr_err("%s: export_fd_to_ion_handles" "not initiazied", __func__); return -EINVAL; } #endif return 0; }
int omap_ion_share_fd_to_buffers(int fd, struct ion_buffer **buffers, int *num_handles) { struct ion_handle **handles; struct ion_client *client; int i = 0, ret = 0; handles = kzalloc(*num_handles * sizeof(struct ion_handle *), GFP_KERNEL); if (!handles) return -ENOMEM; #ifdef CONFIG_PVR_SGX if (*num_handles == 2) { PVRSRVExportFDToIONHandles(fd, &client, handles); } else if (*num_handles == 1) { handles[0] = PVRSRVExportFDToIONHandle(fd, &client); } else { ret = -EINVAL; goto exit; } #else if (export_fd_to_ion_handles) { export_fd_to_ion_handles(fd, &client, handles, num_handles); } else { pr_err("%s: export_fd_to_ion_handles" "not initiazied", __func__); ret = -EINVAL; goto exit; } #endif for (i = 0; i < *num_handles; i++) { if (handles[i]) buffers[i] = ion_share(client, handles[i]); } exit: kfree(handles); return ret; }