summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2012-07-16 02:51:37 +0100
committerDave Airlie <airlied@redhat.com>2012-07-16 02:51:37 +0100
commitc1f99a68b24e7ebbb3a11e6b3df60ca23fcf0b8e (patch)
tree8a196121d2a1717a09ff1c17620257fc46a96a7c
parent410a7ac638b7958f3f74453effc5c91856aad574 (diff)
libdrm/nouveau: add prime handle->bo and bo->handle support.prime-stage
This adds prime support to nouveau libdrm. Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--nouveau/nouveau.c35
-rw-r--r--nouveau/nouveau.h3
2 files changed, 38 insertions, 0 deletions
diff --git a/nouveau/nouveau.c b/nouveau/nouveau.c
index 5aa41070..940d9339 100644
--- a/nouveau/nouveau.c
+++ b/nouveau/nouveau.c
@@ -34,6 +34,7 @@
#include <assert.h>
#include <errno.h>
#include <sys/mman.h>
+#include <fcntl.h>
#include <xf86drm.h>
#include <xf86atomic.h>
@@ -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 51a95981..c42eea7a 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;