#define SUFFIX_LIB ".so"
#define DEFAULT_LIB PREFIX_LIB"default"SUFFIX_LIB
+/* unneeded version 2.0 */
#define BO_IS_CACHEABLE(bo) ((bo->flags & TBM_BO_NONCACHABLE) ? 0 : 1)
#define DEVICE_IS_CACHE_AWARE(device) ((device == TBM_DEVICE_CPU) ? (1) : (0))
#define CACHE_OP_CREATE (-1)
#define CACHE_OP_ATTACH (-2)
#define CACHE_OP_IMPORT (-3)
+/* unneeded version 2.0 */
/* values to indicate unspecified fields in XF86ModReqInfo. */
#define MAJOR_UNSPEC 0xFF
LOCK_TRY_NEVER
};
+/* unneeded version 2.0 */
enum {
DEVICE_NONE = 0,
DEVICE_CA, /* cache aware device */
DEVICE_CO /* cache oblivious device */
};
+/* unneeded version 2.0 */
pthread_mutex_t gLock = PTHREAD_MUTEX_INITIALIZER;
tbm_bufmgr gBufMgr = NULL;
snprintf(str, sizeof(cmdline), "%s", cmdline);
}
+
+/* unneeded version 2.0 */
static inline int _tgl_init(int fd, unsigned int key)
{
struct tgl_attribute attr;
return arg.data1;
}
+/* unneeded version 2.0 */
tbm_user_data *user_data_lookup(struct list_head *user_data_list, unsigned long key)
{
tbm_bufmgr bufmgr = bo->bufmgr;
int ret = 0;
- if (TBM_LOCK_CTRL_BACKEND_VALID(bufmgr->backend->flags)) {
+ if (bufmgr->use_2_0) {
if (bufmgr->backend->bo_lock2) {
/* use bo_lock2 backend lock */
ret = bufmgr->backend->bo_lock2(bo, device, opt);
getpid(), __FUNCTION__, __LINE__);
}
} else {
- /* use tizen global lock */
- ret = _tgl_lock(bufmgr->lock_fd, bo->tgl_key);
+ if (TBM_LOCK_CTRL_BACKEND_VALID(bufmgr->backend->flags)) {
+ if (bufmgr->backend->bo_lock2) {
+ /* use bo_lock2 backend lock */
+ ret = bufmgr->backend->bo_lock2(bo, device, opt);
+ } else if (bufmgr->backend->bo_lock) {
+ /* use bo_lock backend lock */
+ ret = bufmgr->backend->bo_lock(bo);
+ } else {
+ TBM_LOG("[libtbm:%d] "
+ "error %s:%d no backend lock functions\n",
+ getpid(), __FUNCTION__, __LINE__);
+ }
+ } else {
+ /* use tizen global lock */
+ ret = _tgl_lock(bufmgr->lock_fd, bo->tgl_key);
+ }
}
return ret;
{
tbm_bufmgr bufmgr = bo->bufmgr;
- if (TBM_LOCK_CTRL_BACKEND_VALID(bufmgr->backend->flags)) {
+ if (bufmgr->use_2_0) {
if (bufmgr->backend->bo_unlock) {
/* use backend unlock */
bufmgr->backend->bo_unlock(bo);
"error %s:%d no backend unlock functions\n",
getpid(), __FUNCTION__, __LINE__);
}
- } else {
- /* use tizen global unlock */
- _tgl_unlock(bufmgr->lock_fd, bo->tgl_key);
+ }
+ else {
+ if (TBM_LOCK_CTRL_BACKEND_VALID(bufmgr->backend->flags)) {
+ if (bufmgr->backend->bo_unlock) {
+ /* use backend unlock */
+ bufmgr->backend->bo_unlock(bo);
+ } else {
+ TBM_LOG("[libtbm:%d] "
+ "error %s:%d no backend unlock functions\n",
+ getpid(), __FUNCTION__, __LINE__);
+ }
+ } else {
+ /* use tizen global unlock */
+ _tgl_unlock(bufmgr->lock_fd, bo->tgl_key);
+ }
}
}
_bo_unlock(bo);
}
- /* Destroy Global Lock */
- _tbm_bo_destroy_state(bo);
+ if (!bufmgr->use_2_0) {
+ /* Destroy Global Lock */
+ _tbm_bo_destroy_state(bo);
+ }
/* call the bo_free */
bufmgr->backend->bo_free(bo);
DBG("TBM ");
}
+ if (backend_flag & TBM_USE_2_0_BACKEND) {
+ gBufMgr->use_2_0 = 1;
+ DBG("USE 2.0 backend");
+ }
+
DBG("\n");
}
return NULL;
}
- /* intialize the tizen global status */
- if (!_tbm_bufmgr_init_state(gBufMgr)) {
- _tbm_set_last_result(TBM_BO_ERROR_INIT_STATE_FAILED);
- TBM_LOG("[libtbm:%d] " "error: Fail to init state\n", getpid());
- gBufMgr->backend->bufmgr_deinit(gBufMgr->backend->priv);
- tbm_backend_free(gBufMgr->backend);
- pthread_mutex_destroy(&gBufMgr->lock);
- dlclose(gBufMgr->module_data);
+ if (!gBufMgr->use_2_0) {
+ /* intialize the tizen global status */
+ if (!_tbm_bufmgr_init_state(gBufMgr)) {
+ _tbm_set_last_result(TBM_BO_ERROR_INIT_STATE_FAILED);
+ TBM_LOG("[libtbm:%d] " "error: Fail to init state\n", getpid());
+ gBufMgr->backend->bufmgr_deinit(gBufMgr->backend->priv);
+ tbm_backend_free(gBufMgr->backend);
+ pthread_mutex_destroy(&gBufMgr->lock);
+ dlclose(gBufMgr->module_data);
- if (gBufMgr->fd > 0)
- close(gBufMgr->fd);
+ if (gBufMgr->fd > 0)
+ close(gBufMgr->fd);
- free(gBufMgr);
- gBufMgr = NULL;
- pthread_mutex_unlock(&gLock);
- return NULL;
+ free(gBufMgr);
+ gBufMgr = NULL;
+ pthread_mutex_unlock(&gLock);
+ return NULL;
+ }
+
+ /* setup the map_cache */
+ env = getenv("BUFMGR_MAP_CACHE");
+ if (env && !strcmp(env, "false"))
+ gBufMgr->use_map_cache = 0;
+ else
+ gBufMgr->use_map_cache = 1;
+ DBG("[libtbm:%d] BUFMGR_MAP_CACHE=%s\n",
+ getpid(), env ? env : "default:true");
}
/* setup the lock_type */
DBG("[libtbm:%d] BUFMGR_LOCK_TYPE=%s\n",
getpid(), env ? env : "default:once");
- /* setup the map_cache */
- env = getenv("BUFMGR_MAP_CACHE");
- if (env && !strcmp(env, "false"))
- gBufMgr->use_map_cache = 0;
- else
- gBufMgr->use_map_cache = 1;
- DBG("[libtbm:%d] BUFMGR_MAP_CACHE=%s\n",
- getpid(), env ? env : "default:true");
-
/* intialize bo_list */
LIST_INITHEAD(&gBufMgr->bo_list);
}
}
- /* destroy the tizen global status */
- _tbm_bufmgr_destroy_state(bufmgr);
+ if (!bufmgr->use_2_0) {
+ /* destroy the tizen global status */
+ _tbm_bufmgr_destroy_state(bufmgr);
+ }
/* destroy bufmgr priv */
bufmgr->backend->bufmgr_deinit(bufmgr->backend->priv);
bo->ref_cnt = 1;
bo->flags = flags;
- bo->tgl_key = INITIAL_KEY;
bo->priv = bo_priv;
- bo->default_handle.u32 = 0;
- /* init bo state */
- if (!_tbm_bo_init_state(bo, CACHE_OP_CREATE)) {
- _tbm_set_last_result(TBM_BO_ERROR_INIT_STATE_FAILED);
- _tbm_bo_unref(bo);
- pthread_mutex_unlock(&bufmgr->lock);
- return NULL;
+ if (!bufmgr->use_2_0) {
+ bo->tgl_key = INITIAL_KEY;
+ bo->default_handle.u32 = 0;
+
+ /* init bo state */
+ if (!_tbm_bo_init_state(bo, CACHE_OP_CREATE)) {
+ _tbm_set_last_result(TBM_BO_ERROR_INIT_STATE_FAILED);
+ _tbm_bo_unref(bo);
+ pthread_mutex_unlock(&bufmgr->lock);
+ return NULL;
+ }
}
LIST_INITHEAD(&bo->user_data_list);
pthread_mutex_lock(&bufmgr->lock);
- /* find bo in list */
- if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
- LIST_FOR_EACH_ENTRY_SAFE(bo2, tmp, &bufmgr->bo_list, item_link) {
- if (bo2->tgl_key == key) {
- DBG("[libtbm:%d] "
- "find bo(%p, ref:%d key:%d) in list \n",
- getpid(), bo2, bo2->ref_cnt, bo2->tgl_key);
-
- bo2->ref_cnt++;
- pthread_mutex_unlock(&bufmgr->lock);
- return bo2;
+ if (!bufmgr->use_2_0) {
+ /* find bo in list */
+ if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
+ LIST_FOR_EACH_ENTRY_SAFE(bo2, tmp, &bufmgr->bo_list, item_link) {
+ if (bo2->tgl_key == key) {
+ DBG("[libtbm:%d] "
+ "find bo(%p, ref:%d key:%d) in list \n",
+ getpid(), bo2, bo2->ref_cnt, bo2->tgl_key);
+
+ bo2->ref_cnt++;
+ pthread_mutex_unlock(&bufmgr->lock);
+ return bo2;
+ }
}
}
}
return NULL;
}
+ if (bufmgr->use_2_0) {
+ if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
+ LIST_FOR_EACH_ENTRY_SAFE(bo2, tmp, &bufmgr->bo_list, item_link) {
+ if (bo2->priv == bo_priv) {
+ DBG("[libtbm:%d] "
+ "find bo(%p, ref:%d key:%d) in list \n",
+ getpid(), bo2, bo2->ref_cnt, bo2->tgl_key);
+
+ bo2->ref_cnt++;
+ free(bo);
+ pthread_mutex_unlock(&bufmgr->lock);
+ return bo2;
+ }
+ }
+ }
+ }
+
bo->ref_cnt = 1;
- bo->tgl_key = INITIAL_KEY;
bo->priv = bo_priv;
- bo->default_handle.u32 = 0;
+
+ if (!bufmgr->use_2_0) {
+ bo->tgl_key = INITIAL_KEY;
+ bo->default_handle.u32 = 0;
+
+ /* init bo state */
+ if (!_tbm_bo_init_state(bo, CACHE_OP_IMPORT)) {
+ _tbm_set_last_result(TBM_BO_ERROR_INIT_STATE_FAILED);
+ _tbm_bo_unref(bo);
+ pthread_mutex_unlock(&bufmgr->lock);
+ return NULL;
+ }
+ }
if (bufmgr->backend->bo_get_flags)
bo->flags = bufmgr->backend->bo_get_flags(bo);
else
bo->flags = TBM_BO_DEFAULT;
- /* init bo state */
- if (!_tbm_bo_init_state(bo, CACHE_OP_IMPORT)) {
- _tbm_set_last_result(TBM_BO_ERROR_INIT_STATE_FAILED);
- _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_lock(&bufmgr->lock);
- default_handle = bufmgr->backend->fd_to_handle(bufmgr, fd, TBM_DEVICE_DEFAULT);
+ if (!bufmgr->use_2_0) {
+ default_handle = bufmgr->backend->fd_to_handle(bufmgr, fd, TBM_DEVICE_DEFAULT);
- /* find bo in list */
- if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
- LIST_FOR_EACH_ENTRY_SAFE(bo2, tmp, &bufmgr->bo_list, item_link) {
- if (bo2->default_handle.u32 == default_handle.u32) {
- DBG("[libtbm:%d] "
- "find bo(%p, ref:%d handle:%d) in list \n",
- getpid(), bo2, bo2->ref_cnt, bo2->default_handle.u32);
-
- bo2->ref_cnt++;
- pthread_mutex_unlock(&bufmgr->lock);
- return bo2;
+ /* find bo in list */
+ if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
+ LIST_FOR_EACH_ENTRY_SAFE(bo2, tmp, &bufmgr->bo_list, item_link) {
+ if (bo2->default_handle.u32 == default_handle.u32) {
+ DBG("[libtbm:%d] "
+ "find bo(%p, ref:%d handle:%d) in list \n",
+ getpid(), bo2, bo2->ref_cnt, bo2->default_handle.u32);
+
+ bo2->ref_cnt++;
+ pthread_mutex_unlock(&bufmgr->lock);
+ return bo2;
+ }
}
}
}
return NULL;
}
+ if (bufmgr->use_2_0) {
+ if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
+ LIST_FOR_EACH_ENTRY_SAFE(bo2, tmp, &bufmgr->bo_list, item_link) {
+ if (bo2->priv == bo_priv) {
+ DBG("[libtbm:%d] "
+ "find bo(%p, ref:%d key:%d) in list \n",
+ getpid(), bo2, bo2->ref_cnt, bo2->tgl_key);
+
+ bo2->ref_cnt++;
+ free(bo);
+ pthread_mutex_unlock(&bufmgr->lock);
+ return bo2;
+ }
+ }
+ }
+ }
+
bo->ref_cnt = 1;
- bo->tgl_key = INITIAL_KEY;
bo->priv = bo_priv;
- bo->default_handle.u32 = 0;
+
+ if (!bufmgr->use_2_0) {
+ bo->tgl_key = INITIAL_KEY;
+ bo->default_handle.u32 = 0;
+
+ /* init bo state */
+ if (!_tbm_bo_init_state(bo, CACHE_OP_IMPORT)) {
+ _tbm_set_last_result(TBM_BO_ERROR_INIT_STATE_FAILED);
+ _tbm_bo_unref(bo);
+ pthread_mutex_unlock(&bufmgr->lock);
+ return NULL;
+ }
+ }
if (bufmgr->backend->bo_get_flags)
bo->flags = bufmgr->backend->bo_get_flags(bo);
else
bo->flags = TBM_BO_DEFAULT;
- /* init bo state */
- if (!_tbm_bo_init_state(bo, CACHE_OP_IMPORT)) {
- _tbm_set_last_result(TBM_BO_ERROR_INIT_STATE_FAILED);
- _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_lock(&bufmgr->lock);
- bo_handle = bufmgr->backend->bo_get_handle(bo, device);
-
if (!_tbm_bo_lock(bo, device, opt)) {
_tbm_set_last_result(TBM_BO_ERROR_LOCK_FAILED);
TBM_LOG("[libtbm:%d] "
return (tbm_bo_handle) NULL;
}
- if (bufmgr->use_map_cache == 1 && bo->map_cnt == 0)
- _tbm_bo_set_state(bo, device, opt);
+ if (!bufmgr->use_2_0) {
+ if (bufmgr->use_map_cache == 1 && bo->map_cnt == 0)
+ _tbm_bo_set_state(bo, device, opt);
+ }
/* increase the map_count */
bo->map_cnt++;
/* decrease the map_count */
bo->map_cnt--;
- if (bo->map_cnt == 0)
- _tbm_bo_save_state(bo);
+ if (!bufmgr->use_2_0) {
+ if (bo->map_cnt == 0)
+ _tbm_bo_save_state(bo);
+ }
_tbm_bo_unlock(bo);
return 0;
}
- tmp_key = bo1->tgl_key;
- bo1->tgl_key = bo2->tgl_key;
- bo2->tgl_key = tmp_key;
+ if (!bo1->bufmgr->use_2_0) {
+ tmp_key = bo1->tgl_key;
+ bo1->tgl_key = bo2->tgl_key;
+ bo2->tgl_key = tmp_key;
- tmp_defualt_handle = bo1->default_handle;
- bo1->default_handle = bo2->default_handle;
- bo2->default_handle = tmp_defualt_handle;
+ tmp_defualt_handle = bo1->default_handle;
+ bo1->default_handle = bo2->default_handle;
+ bo2->default_handle = tmp_defualt_handle;
+ }
temp = bo1->priv;
bo1->priv = bo2->priv;
surf->item_link.next && \
surf->item_link.next->prev == &surf->item_link)
+#define TBM_DEBUG(fmt, ...) fprintf(stderr, "[TBM:DEBUG(%d)] " fmt, getpid(), ##__VA_ARGS__)
+#define TBM_LOG(fmt, ...) fprintf(stderr, "[TBM(%d):%s] " fmt, getpid(), __func__, ##__VA_ARGS__)
+
+struct list_head {
+ struct list_head *prev;
+ struct list_head *next;
+};
+
+/* unneeded version 2.0 */
#define TBM_ALL_CTRL_BACKEND_VALID(flags) \
((flags&TBM_CACHE_CTRL_BACKEND) &&\
(flags&TBM_LOCK_CTRL_BACKEND))
#define TBM_LOCK_CTRL_BACKEND_VALID(flags) \
(flags&TBM_LOCK_CTRL_BACKEND)
-#define TBM_DEBUG(fmt, ...) fprintf(stderr, "[TBM:DEBUG(%d)] " fmt, getpid(), ##__VA_ARGS__)
-#define TBM_LOG(fmt, ...) fprintf(stderr, "[TBM(%d):%s] " fmt, getpid(), __func__, ##__VA_ARGS__)
-
typedef union _tbm_bo_cache_state tbm_bo_cache_state;
-struct list_head {
- struct list_head *prev;
- struct list_head *next;
-};
-
union _tbm_bo_cache_state {
unsigned int val;
struct {
unsigned int isDirtied:2;
} data;
};
+/* unneeded version 2.0 */
/**
* @brief tbm_bo : buffer object of Tizen Buffer Manager
int flags; /* TBM_BO_FLAGS :bo memory type */
- unsigned int tgl_key; /*global key for tizen global lock */
-
- /* for cache control */
- unsigned int map_cnt; /* device map count */
- tbm_bo_cache_state cache_state; /*cache state */
-
- int lock_cnt; /* lock count of bo */
-
struct list_head user_data_list; /* list of the user_date in bo */
void *priv; /* bo private */
struct list_head item_link; /* link of bo */
+ tbm_surface_h surface; /* tbm_surface */
+
+ int lock_cnt; /* lock count of bo */
+
+ unsigned int map_cnt; /* device map count */
+
+ /* unneeded version 2.0 */
tbm_bo_handle default_handle; /*default handle */
- tbm_surface_h surface; /* tbm_surface */
+ unsigned int tgl_key; /*global key for tizen global lock */
+
+ /* for cache control */
+ tbm_bo_cache_state cache_state; /*cache state */
+ /* unneeded version 2.0 */
};
/**
int fd; /* bufmgr fd */
- int fd_flag; /* flag set 1 when bufmgr fd open in tbm_bufmgr_init */
-
- int lock_fd; /* fd of tizen global lock */
-
int lock_type; /* lock_type of bufmgr */
- int use_map_cache; /* flag to use the map_cahce */
-
struct list_head bo_list; /* list of bos belonging to bufmgr */
struct list_head surf_list; /* list of surfaces belonging to bufmgr */
void *module_data;
tbm_bufmgr_backend backend; /* bufmgr backend */
+
+ int use_2_0;
+
+ /* unneeded version 2.0 */
+ int lock_fd; /* fd of tizen global lock */
+
+ int fd_flag; /* flag set 1 when bufmgr fd open in tbm_bufmgr_init */
+
+ int use_map_cache; /* flag to use the map_cahce */
+ /* unneeded version 2.0 */
};
/**