summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--[-rwxr-xr-x]src/tbm_bufmgr.c50
-rwxr-xr-xsrc/tbm_bufmgr.h2
-rwxr-xr-xsrc/tbm_bufmgr_backend.h17
3 files changed, 64 insertions, 5 deletions
diff --git a/src/tbm_bufmgr.c b/src/tbm_bufmgr.c
index c4a17d2..b9ac45d 100755..100644
--- a/src/tbm_bufmgr.c
+++ b/src/tbm_bufmgr.c
@@ -1176,7 +1176,44 @@ tbm_bo_import (tbm_bufmgr bufmgr, unsigned int key)
tbm_bo
tbm_bo_import_fd (tbm_bufmgr bufmgr, tbm_fd fd)
{
+ TBM_RETURN_VAL_IF_FAIL(TBM_BUFMGR_IS_VALID(bufmgr), NULL);
+
tbm_bo bo = NULL;
+ void * bo_priv = NULL;
+
+ bo = calloc (1, sizeof(struct _tbm_bo));
+ if(!bo)
+ return NULL;
+
+ bo->bufmgr = bufmgr;
+
+ pthread_mutex_lock (&bufmgr->lock);
+
+ bo_priv = bufmgr->backend->bo_import_fd(bo, fd);
+ if (!bo_priv)
+ {
+ free (bo);
+ pthread_mutex_unlock (&bufmgr->lock);
+ return NULL;
+ }
+
+ bo->ref_cnt = 1;
+ bo->tgl_key = INITIAL_KEY;
+ bo->priv = bo_priv;
+
+ /* init bo state */
+ if (!_tbm_bo_init_state (bo, CACHE_OP_IMPORT))
+ {
+ _tbm_bo_unref (bo);
+ pthread_mutex_unlock (&bufmgr->lock);
+ return NULL;
+ }
+
+ LIST_INITHEAD (&bo->user_data_list);
+
+ LIST_ADD (&bo->item_link, &bufmgr->bo_list);
+
+ pthread_mutex_unlock (&bufmgr->lock);
return bo;
}
@@ -1201,9 +1238,18 @@ tbm_bo_export (tbm_bo bo)
tbm_fd
tbm_bo_export_fd (tbm_bo bo)
{
- tbm_fd fd = 0;
+ TBM_RETURN_VAL_IF_FAIL (_tbm_bo_is_valid(bo), 0);
+
+ tbm_bufmgr bufmgr;
+ int ret;
- return fd;
+ bufmgr = bo->bufmgr;
+
+ pthread_mutex_lock (&bufmgr->lock);
+ ret = bufmgr->backend->bo_export_fd (bo);
+ pthread_mutex_unlock (&bufmgr->lock);
+
+ return ret;
}
diff --git a/src/tbm_bufmgr.h b/src/tbm_bufmgr.h
index 83bdc54..d8e18db 100755
--- a/src/tbm_bufmgr.h
+++ b/src/tbm_bufmgr.h
@@ -524,7 +524,7 @@ tbm_bo tbm_bo_import (tbm_bufmgr bufmgr, tbm_key key);
...
bufmgr = tbm_bufmgr_init (bufmgr_fd);
- bo = tbm_bo_import (bo_fd);
+ bo = tbm_bo_import_fd (bo_fd);
...
diff --git a/src/tbm_bufmgr_backend.h b/src/tbm_bufmgr_backend.h
index fe4d3a7..3e3150f 100755
--- a/src/tbm_bufmgr_backend.h
+++ b/src/tbm_bufmgr_backend.h
@@ -235,6 +235,21 @@ struct _tbm_bufmgr_backend
*/
int (*surface_get_plane_data) (tbm_surface_h surface, int width, int height, tbm_format format, int plane_idx, uint32_t *size, uint32_t *offset, uint32_t *pitch);
+ /**
+ * @brief import the buffer object associated with the prime fd.
+ * @param[in] bo : the buffer object
+ * @param[in] fd : the prime fd associated with the buffer object
+ * @return pointer of the bo private.
+ */
+ void * (*bo_import_fd) (tbm_bo bo, tbm_fd fd);
+
+ /**
+ * @brief export the buffer object
+ * @param[in] bo : the buffer object
+ * @return tbm_fd associated with the buffer object
+ */
+ tbm_fd (*bo_export_fd) (tbm_bo bo);
+
/* Padding for future extension */
void (*reserved1) (void);
void (*reserved2) (void);
@@ -242,8 +257,6 @@ struct _tbm_bufmgr_backend
void (*reserved4) (void);
void (*reserved5) (void);
void (*reserved6) (void);
- void (*reserved7) (void);
- void (*reserved8) (void);
};
/**