From patchwork Mon Jul 16 01:52:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 1199711 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 1D9BB3FC8F for ; Mon, 16 Jul 2012 01:52:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EC8759F5E2 for ; Sun, 15 Jul 2012 18:52:32 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by gabe.freedesktop.org (Postfix) with ESMTP id 1D1F49E78D for ; Sun, 15 Jul 2012 18:52:22 -0700 (PDT) Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6G1qLBl020869 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 15 Jul 2012 21:52:21 -0400 Received: from prime.bne.redhat.com (dhcp-41-76.bne.redhat.com [10.64.41.76]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q6G1qK3k018817 for ; Sun, 15 Jul 2012 21:52:21 -0400 From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH] libdrm/nouveau: add prime handle->bo and bo->handle support. Date: Mon, 16 Jul 2012 02:52:19 +0100 Message-Id: <1342403539-11789-1-git-send-email-airlied@gmail.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 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+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org From: Dave Airlie This adds prime support to nouveau libdrm. Signed-off-by: Dave Airlie --- nouveau/nouveau.c | 35 +++++++++++++++++++++++++++++++++++ nouveau/nouveau.h | 3 +++ 2 files changed, 38 insertions(+) diff --git a/nouveau/nouveau.c b/nouveau/nouveau.c index 5aa4107..940d933 100644 --- a/nouveau/nouveau.c +++ b/nouveau/nouveau.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -442,6 +443,40 @@ nouveau_bo_ref(struct nouveau_bo *bo, struct nouveau_bo **pref) } int +nouveau_bo_prime_handle_ref(struct nouveau_device *dev, int prime_fd, + struct nouveau_bo **bo) +{ + int ret; + unsigned int handle; + + ret = drmPrimeFDToHandle(dev->fd, prime_fd, &handle); + if (ret) { + nouveau_bo_ref(NULL, bo); + return ret; + } + + ret = nouveau_bo_wrap(dev, handle, bo); + if (ret) { + nouveau_bo_ref(NULL, bo); + return ret; + } + + return 0; +} + +int +nouveau_bo_set_prime(struct nouveau_bo *bo, int *prime_fd) +{ + struct nouveau_bo_priv *nvbo = nouveau_bo(bo); + int ret; + + ret = drmPrimeHandleToFD(bo->device->fd, nvbo->base.handle, DRM_CLOEXEC, prime_fd); + if (ret) + return ret; + return 0; +} + +int nouveau_bo_wait(struct nouveau_bo *bo, uint32_t access, struct nouveau_client *client) { diff --git a/nouveau/nouveau.h b/nouveau/nouveau.h index 51a9598..c42eea7 100644 --- a/nouveau/nouveau.h +++ b/nouveau/nouveau.h @@ -135,6 +135,9 @@ int nouveau_bo_map(struct nouveau_bo *, uint32_t access, struct nouveau_client *); int nouveau_bo_wait(struct nouveau_bo *, uint32_t access, struct nouveau_client *); +int nouveau_bo_prime_handle_ref(struct nouveau_device *dev, int prime_fd, + struct nouveau_bo **); +int nouveau_bo_set_prime(struct nouveau_bo *bo, int *prime_fd); struct nouveau_bufref { struct nouveau_list thead;