summaryrefslogtreecommitdiff
path: root/gralloc_drm.cpp
diff options
context:
space:
mode:
authorSean Paul <seanpaul@chromium.org>2015-02-09 02:39:09 -0500
committerTomasz Figa <tfiga@google.com>2015-05-30 15:51:14 +0900
commit879cc4e7c6da5ecf631d65ddd98d12bccd5817f5 (patch)
treec8e2b058c99eace17d557a61dacf7ea24c4294db /gralloc_drm.cpp
parentd225ab0eaecac84e5fd7199968a433a462af0196 (diff)
downloaddrm_gralloc-879cc4e7c6da5ecf631d65ddd98d12bccd5817f5.tar.gz
drm_gralloc: Use render node
Change-Id: I9bbee113e884d0c512a855e85fa88db4e3789a1e Signed-off-by: Sean Paul <seanpaul@chromium.org> Signed-off-by: Tomasz Figa <tfiga@google.com>
Diffstat (limited to 'gralloc_drm.cpp')
-rw-r--r--gralloc_drm.cpp57
1 files changed, 10 insertions, 47 deletions
diff --git a/gralloc_drm.cpp b/gralloc_drm.cpp
index 8826f73..ebff717 100644
--- a/gralloc_drm.cpp
+++ b/gralloc_drm.cpp
@@ -25,6 +25,7 @@
#include <cutils/log.h>
#include <cutils/atomic.h>
+#include <cutils/properties.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
@@ -36,8 +37,6 @@
#define unlikely(x) __builtin_expect(!!(x), 0)
-#define GRALLOC_DRM_DEVICE "/dev/dri/card0"
-
static int32_t gralloc_drm_pid = 0;
/*
@@ -101,6 +100,7 @@ init_drv_from_fd(int fd)
*/
struct gralloc_drm_t *gralloc_drm_create(void)
{
+ char path[PROPERTY_VALUE_MAX];
struct gralloc_drm_t *drm;
int err;
@@ -108,9 +108,10 @@ struct gralloc_drm_t *gralloc_drm_create(void)
if (!drm)
return NULL;
- drm->fd = open(GRALLOC_DRM_DEVICE, O_RDWR);
+ property_get("gralloc.drm.device", path, "/dev/dri/renderD128");
+ drm->fd = open(path, O_RDWR);
if (drm->fd < 0) {
- ALOGE("failed to open %s", GRALLOC_DRM_DEVICE);
+ ALOGE("failed to open %s", path);
return NULL;
}
@@ -144,42 +145,6 @@ int gralloc_drm_get_fd(struct gralloc_drm_t *drm)
}
/*
- * Get the magic for authentication.
- */
-int gralloc_drm_get_magic(struct gralloc_drm_t *drm, int32_t *magic)
-{
- return drmGetMagic(drm->fd, (drm_magic_t *) magic);
-}
-
-/*
- * Authenticate a magic.
- */
-int gralloc_drm_auth_magic(struct gralloc_drm_t *drm, int32_t magic)
-{
- return drmAuthMagic(drm->fd, (drm_magic_t) magic);
-}
-
-/*
- * Set as the master of a DRM device.
- */
-int gralloc_drm_set_master(struct gralloc_drm_t *drm)
-{
- ALOGD("set master");
- drmSetMaster(drm->fd);
- drm->first_post = 1;
-
- return 0;
-}
-
-/*
- * Drop from the master of a DRM device.
- */
-void gralloc_drm_drop_master(struct gralloc_drm_t *drm)
-{
- drmDropMaster(drm->fd);
-}
-
-/*
* Validate a buffer handle and return the associated bo.
*/
static struct gralloc_drm_bo_t *validate_handle(buffer_handle_t _handle,
@@ -191,6 +156,7 @@ static struct gralloc_drm_bo_t *validate_handle(buffer_handle_t _handle,
return NULL;
/* the buffer handle is passed to a new process */
+ ALOGE("data_owner=%d gralloc_pid=%d data=%p\n", handle->data_owner, gralloc_drm_get_pid(), handle->data);
if (unlikely(handle->data_owner != gralloc_drm_pid)) {
struct gralloc_drm_bo_t *bo;
@@ -198,8 +164,10 @@ static struct gralloc_drm_bo_t *validate_handle(buffer_handle_t _handle,
if (!drm)
return NULL;
+ ALOGE("handle: name=%d pfd=%d\n", handle->name,
+ handle->prime_fd);
/* create the struct gralloc_drm_bo_t locally */
- if (handle->name)
+ if (handle->name || handle->prime_fd >= 0)
bo = drm->drv->alloc(drm->drv, handle);
else /* an invalid handle */
bo = NULL;
@@ -263,6 +231,7 @@ static struct gralloc_drm_handle_t *create_bo_handle(int width,
handle->height = height;
handle->format = format;
handle->usage = usage;
+ handle->prime_fd = -1;
return handle;
}
@@ -347,12 +316,6 @@ buffer_handle_t gralloc_drm_bo_get_handle(struct gralloc_drm_bo_t *bo, int *stri
return &bo->handle->base;
}
-int gralloc_drm_get_gem_handle(buffer_handle_t _handle)
-{
- struct gralloc_drm_handle_t *handle = gralloc_drm_handle(_handle);
- return (handle) ? handle->name : 0;
-}
-
/*
* Query YUV component offsets for a buffer handle
*/