From patchwork Thu Apr 17 03:54:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Kurtz X-Patchwork-Id: 4005591 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3218C9F2BA for ; Thu, 17 Apr 2014 03:55:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5D0F62034F for ; Thu, 17 Apr 2014 03:55:28 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7BFAB2034E for ; Thu, 17 Apr 2014 03:55:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C57216EAE6; Wed, 16 Apr 2014 20:55:26 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by gabe.freedesktop.org (Postfix) with ESMTP id 1D4826EAE6 for ; Wed, 16 Apr 2014 20:55:25 -0700 (PDT) Received: by mail-vc0-f171.google.com with SMTP id lg15so11794803vcb.16 for ; Wed, 16 Apr 2014 20:55:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BOrszCXCq2xSKnNoLRAoC+K7Y3CVJZLFfh/0T8bvzbU=; b=lb+VRkMVgjfzCVpO5CenWcR5ZDNbqD4T9zlDuP5hLtfNEPnUylpbC6O6BNN4MvH7yf 4XIbN3+b3k/3MrdZr/gyRb0Mb9IdDrU7tChGU2XNNBK9UOn1g5HnrwvXtgXAOrWhJKXk FoBDLTY2M2zk6V0084uC0D7Yju4RxNicsRtno= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BOrszCXCq2xSKnNoLRAoC+K7Y3CVJZLFfh/0T8bvzbU=; b=GFCAzJ9EQtFBSV6b/T9L+pK0RhCGyxW4Em2dRiXA6RI/2cTGOn+FOPuYyoH+p5IQMW /lKzg2HTX4mojqEJqIB6L6bPdUnnrDYCL964WnmC4KFoLs2RF0xC5WnCd5b3YJpSNqVE lPozOV53YLmP+JbVATdmBxwAGU9SypqyDvVz0mUuZsAoGqcyizSMCzKF42ouCe+GQs/Z ouJJcbcbqQBvBIdodnIYqx7XUr8vDiHfIbw5PAqRx/lNb2NG7MbCI2V81GZIyzdiD9lC v6uT25x0bO2takAP8qcCjxicNM3cZC/aItza+XLClawCJZ1PdFUbIL0rEOt1MxIz8VDn I1uA== X-Gm-Message-State: ALoCoQmiH09RL5xZmKau74VGiWREoHCJZF7I/909cLW2LO/cnakTp5t3qcuhcH3s0+AH7NpV8C9g X-Received: by 10.58.122.164 with SMTP id lt4mr9515324veb.2.1397706924462; Wed, 16 Apr 2014 20:55:24 -0700 (PDT) Received: from djkurtzt530-glaptop.corp.google.com ([203.208.61.193]) by mx.google.com with ESMTPSA id zb18sm21234884vdb.18.2014.04.16.20.55.21 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 16 Apr 2014 20:55:23 -0700 (PDT) From: Daniel Kurtz To: dri-devel@lists.freedesktop.org, Inki Dae Subject: [PATCH 6/7] exynos: prime: use drmPrime*() helpers Date: Thu, 17 Apr 2014 11:54:40 +0800 Message-Id: <1397706881-19735-8-git-send-email-djkurtz@chromium.org> X-Mailer: git-send-email 1.9.1.423.g4596e3a In-Reply-To: <1397706881-19735-1-git-send-email-djkurtz@chromium.org> References: <1397706881-19735-1-git-send-email-djkurtz@chromium.org> Cc: Kyungmin Park X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Reuse the common drmPrime() helper functions rather than reinventing them. Signed-off-by: Daniel Kurtz Acked-by: Inki Dae --- exynos/exynos_drm.c | 48 ++++++++++-------------------------------------- 1 file changed, 10 insertions(+), 38 deletions(-) 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); }