diff mbox

[6/7] exynos: prime: use drmPrime*() helpers

Message ID 1397706881-19735-8-git-send-email-djkurtz@chromium.org (mailing list archive)
State New, archived
Headers show

Commit Message

Daniel Kurtz April 17, 2014, 3:54 a.m. UTC
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>
---
 exynos/exynos_drm.c | 48 ++++++++++--------------------------------------
 1 file changed, 10 insertions(+), 38 deletions(-)
diff mbox

Patch

diff --git a/exynos/exynos_drm.c b/exynos/exynos_drm.c
index b7acdf5..5fff259 100644
--- a/exynos/exynos_drm.c
+++ b/exynos/exynos_drm.c
@@ -303,59 +303,31 @@  void *exynos_bo_map(struct exynos_bo *bo)
 /*
  * Export gem object to dmabuf as file descriptor.
  *
- * @dev: a exynos device object.
- * @handle: gem handle to be exported into dmabuf as file descriptor.
- * @fd: file descriptor to dmabuf exported from gem handle and
- *	returned by kernel side.
+ * @dev: exynos device object
+ * @handle: gem handle to export as file descriptor of dmabuf
+ * @fd: file descriptor returned from kernel
  *
- * 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 *fd)
 {
-	int ret;
-	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;
+	return drmPrimeHandleToFD(dev->fd, handle, 0, fd);
 }
 
 /*
  * Import file descriptor into gem handle.
  *
- * @dev: a exynos device object.
- * @fd: file descriptor exported into dmabuf.
- * @handle: gem handle to gem object imported from file descriptor
- *	and returned by kernel side.
+ * @dev: exynos device object
+ * @fd: file descriptor of dmabuf to import
+ * @handle: gem handle returned from kernel
  *
- * 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,
 					uint32_t *handle)
 {
-	int ret;
-	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;
+	return drmPrimeFDToHandle(dev->fd, fd, handle);
 }