exynos: prime: use drmPrime*() helpers

Reuse the common drmPrime() helper functions rather than reinventing them.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Acked-by: Inki Dae <inki.dae@samsung.com>
main
Daniel Kurtz 2014-04-17 11:54:40 +08:00 committed by Rob Clark
parent d1000c432c
commit a13bdd5c71
1 changed files with 10 additions and 38 deletions

View File

@ -303,59 +303,31 @@ void *exynos_bo_map(struct exynos_bo *bo)
/* /*
* Export gem object to dmabuf as file descriptor. * Export gem object to dmabuf as file descriptor.
* *
* @dev: a exynos device object. * @dev: exynos device object
* @handle: gem handle to be exported into dmabuf as file descriptor. * @handle: gem handle to export as file descriptor of dmabuf
* @fd: file descriptor to dmabuf exported from gem handle and * @fd: file descriptor returned from kernel
* returned by kernel side.
* *
* if true, return 0 else negative. * @return: 0 on success, -1 on error, and errno will be set
*/ */
int exynos_prime_handle_to_fd(struct exynos_device *dev, uint32_t handle, int exynos_prime_handle_to_fd(struct exynos_device *dev, uint32_t handle,
int *fd) int *fd)
{ {
int ret; return drmPrimeHandleToFD(dev->fd, handle, 0, fd);
struct drm_prime_handle req = {
.handle = handle,
};
ret = drmIoctl(dev->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &req);
if (ret) {
fprintf(stderr, "failed to mmap[%s].\n",
strerror(errno));
return ret;
}
*fd = req.fd;
return 0;
} }
/* /*
* Import file descriptor into gem handle. * Import file descriptor into gem handle.
* *
* @dev: a exynos device object. * @dev: exynos device object
* @fd: file descriptor exported into dmabuf. * @fd: file descriptor of dmabuf to import
* @handle: gem handle to gem object imported from file descriptor * @handle: gem handle returned from kernel
* and returned by kernel side.
* *
* if true, return 0 else negative. * @return: 0 on success, -1 on error, and errno will be set
*/ */
int exynos_prime_fd_to_handle(struct exynos_device *dev, int fd, int exynos_prime_fd_to_handle(struct exynos_device *dev, int fd,
uint32_t *handle) uint32_t *handle)
{ {
int ret; return drmPrimeFDToHandle(dev->fd, fd, handle);
struct drm_prime_handle req = {
.fd = fd,
};
ret = drmIoctl(dev->fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &req);
if (ret) {
fprintf(stderr, "failed to mmap[%s].\n",
strerror(errno));
return ret;
}
*handle = req.handle;
return 0;
} }