summaryrefslogtreecommitdiffstats
path: root/gralloc_drm.c
diff options
context:
space:
mode:
authorChia-I Wu <olvaffe@gmail.com>2011-07-29 19:57:04 +0900
committerChia-I Wu <olvaffe@gmail.com>2011-07-29 20:45:50 +0900
commit2fc5da4da12c8fa36044acc58856b0e460e70621 (patch)
tree8d7d079e8bbc5ec234100ba4189078a9858e0141 /gralloc_drm.c
parent3b55dd80b8d0ee5eb79342a70b57b4b75cd84d5f (diff)
downloadexternal_drm_gralloc-2fc5da4da12c8fa36044acc58856b0e460e70621.zip
external_drm_gralloc-2fc5da4da12c8fa36044acc58856b0e460e70621.tar.gz
external_drm_gralloc-2fc5da4da12c8fa36044acc58856b0e460e70621.tar.bz2
close bo on unregister()
Not sure if a remote process ever destroys a bo. But let register() opens a bo and unregister() closes it.
Diffstat (limited to 'gralloc_drm.c')
-rw-r--r--gralloc_drm.c44
1 files changed, 28 insertions, 16 deletions
diff --git a/gralloc_drm.c b/gralloc_drm.c
index af33986..e220ebe 100644
--- a/gralloc_drm.c
+++ b/gralloc_drm.c
@@ -234,10 +234,28 @@ struct gralloc_drm_bo_t *gralloc_drm_bo_create(struct gralloc_drm_t *drm,
}
/*
- * Validate a buffer handle and return the associated bo.
+ * Destroy a bo.
+ */
+void gralloc_drm_bo_destroy(struct gralloc_drm_bo_t *bo)
+{
+ struct gralloc_drm_handle_t *handle = bo->handle;
+ int imported = bo->imported;
+
+ bo->drm->drv->free(bo->drm->drv, bo);
+ if (imported) {
+ handle->data_owner = 0;
+ handle->data = 0;
+ }
+ else {
+ free(handle);
+ }
+}
+
+/*
+ * Register a buffer handle and return the associated bo.
*/
-struct gralloc_drm_bo_t *gralloc_drm_bo_validate(struct gralloc_drm_t *drm,
- buffer_handle_t _handle)
+struct gralloc_drm_bo_t *gralloc_drm_bo_register(struct gralloc_drm_t *drm,
+ buffer_handle_t _handle, int create)
{
struct gralloc_drm_handle_t *handle = gralloc_drm_handle(_handle);
@@ -245,6 +263,9 @@ struct gralloc_drm_bo_t *gralloc_drm_bo_validate(struct gralloc_drm_t *drm,
if (handle && unlikely(handle->data_owner != gralloc_drm_pid)) {
struct gralloc_drm_bo_t *bo;
+ if (!create)
+ return NULL;
+
/* create the struct gralloc_drm_bo_t locally */
if (handle->name)
bo = drm->drv->alloc(drm->drv, handle);
@@ -264,21 +285,12 @@ struct gralloc_drm_bo_t *gralloc_drm_bo_validate(struct gralloc_drm_t *drm,
}
/*
- * Destroy a bo.
+ * Unregister a bo. It is no-op for bo created locally.
*/
-void gralloc_drm_bo_destroy(struct gralloc_drm_bo_t *bo)
+void gralloc_drm_bo_unregister(struct gralloc_drm_bo_t *bo)
{
- struct gralloc_drm_handle_t *handle = bo->handle;
- int imported = bo->imported;
-
- bo->drm->drv->free(bo->drm->drv, bo);
- if (imported) {
- handle->data_owner = 0;
- handle->data = 0;
- }
- else {
- free(handle);
- }
+ if (bo->imported)
+ gralloc_drm_bo_destroy(bo);
}
/*