From patchwork Wed Mar 5 05:01:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Kurtz X-Patchwork-Id: 3770601 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 36174BF13A for ; Wed, 5 Mar 2014 05:02:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 56FB620221 for ; Wed, 5 Mar 2014 05:02:35 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7DDE220218 for ; Wed, 5 Mar 2014 05:02:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0B111FA2DF; Tue, 4 Mar 2014 21:02:29 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pb0-f47.google.com (mail-pb0-f47.google.com [209.85.160.47]) by gabe.freedesktop.org (Postfix) with ESMTP id E1A5AFA2E0 for ; Tue, 4 Mar 2014 21:02:10 -0800 (PST) Received: by mail-pb0-f47.google.com with SMTP id up15so554018pbc.34 for ; Tue, 04 Mar 2014 21:02:10 -0800 (PST) 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=g7bcJxF2ZRrm3jAwIAIMeMjW6YFg1NsJ+s8fmPS/kJI=; b=hlljiC5gXXSdDwazQ5sW58wzPXqlPHsw76NftbVNdcFw0oclVXjRCZcUTJlXbw9/w3 4xWeKERm3dhIIHbFUJdVCYyQY+yLzHgvgyzKKPZcY51AdoopUQ/OL9w2Oto0WbnqGEYF VEw1AK0Lnoo6j5LTs9Cs/0ZPjvOxY37U1289c= 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=g7bcJxF2ZRrm3jAwIAIMeMjW6YFg1NsJ+s8fmPS/kJI=; b=KaCT1GdOoTGEYt1UIQUh4Jhr7gkO9o4G7IaIvBV7I6giSvFpvFuzaU9pq3dzSA5oq1 mgw4VtahqI0cyH8Z7sRZFKV48KH/Zrhep/TgF7ZvNblc7Dx4Iay1pSQ6wJvv/omK85ak fh1asVOZNbh7YmjFceffpiJ6yH03fhdQ5bP/1UofvEy11uEm2+dDg8+UZPh11M+uFU8/ D+LOY0RY2mAuR97pLZ/ZzoCuMRPaIuZd1PdUgUd4peLtqg20CDGH/xVljnJAurYV//94 ViGj1ygevKhOq0V61LRQwR257EPVzLY/YmNwAnSS5+Y+M7IO5YHemde8y7r9MXMGQ7oQ IxFA== X-Gm-Message-State: ALoCoQkXWxSQDiJv4NjgYcJKPiSR6JovJbaas1NpXDwpC+dTcE7iv5gF6AYTYQ+zgcps9/KnxRD7 X-Received: by 10.69.2.2 with SMTP id bk2mr4180441pbd.75.1393995730679; Tue, 04 Mar 2014 21:02:10 -0800 (PST) Received: from djkurtzt530-glaptop.corp.google.com ([216.239.55.197]) by mx.google.com with ESMTPSA id ac5sm3266130pbc.37.2014.03.04.21.02.09 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 04 Mar 2014 21:02:09 -0800 (PST) From: Daniel Kurtz To: dri-devel@lists.freedesktop.org, Inki Dae Subject: [PATCH 7/8] exynos: prime: use drmPrime*() helpers Date: Tue, 4 Mar 2014 21:01:43 -0800 Message-Id: <1393995704-29184-8-git-send-email-djkurtz@chromium.org> X-Mailer: git-send-email 1.9.0.rc1.175.g0b1dcb5 In-Reply-To: <1393995704-29184-1-git-send-email-djkurtz@chromium.org> References: <1393995704-29184-1-git-send-email-djkurtz@chromium.org> Cc: Kyungmin Park X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.1 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 --- 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); }