#define DEBUG
#ifdef DEBUG
-int bDebug = 0;
-#define DBG(...) if (bDebug&0x1) TBM_LOG(__VA_ARGS__)
-#define DBG_LOCK(...) if (bDebug&0x2) TBM_LOG(__VA_ARGS__)
+int bDebug;
+#define DBG(...) {if (bDebug&0x1) TBM_LOG(__VA_ARGS__)}
+#define DBG_LOCK(...) {if (bDebug&0x2) TBM_LOG(__VA_ARGS__)}
#else
#define DBG(...)
#define DBG_LOCK(...)
/* unneeded version 2.0 */
enum {
DEVICE_NONE = 0,
- DEVICE_CA, /* cache aware device */
- DEVICE_CO /* cache oblivious device */
+ 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;
+tbm_bufmgr gBufMgr;
static __thread tbm_error_e tbm_last_error = TBM_ERROR_NONE;
-static void _tbm_set_last_result(tbm_error_e err)
+static void
+_tbm_set_last_result(tbm_error_e err)
{
tbm_last_error = err;
}
-static void _tbm_util_get_appname_brief(char *brief)
+static void
+_tbm_util_get_appname_brief(char *brief)
{
char delim[] = "/";
char *token = NULL;
token = strtok_r(brief, delim, &saveptr);
while (token != NULL) {
- memset(temp, 0x00, 255*sizeof(char));
- strncpy(temp, token, 254*sizeof(char));
+ memset(temp, 0x00, 255 * sizeof(char));
+ strncpy(temp, token, 254 * sizeof(char));
token = strtok_r(NULL, delim, &saveptr);
}
snprintf(brief, sizeof(temp), "%s", temp);
}
-static void _tbm_util_get_appname_from_pid(long pid, char *str)
+static void
+_tbm_util_get_appname_from_pid(long pid, char *str)
{
- FILE* fp;
+ FILE *fp;
int len;
long app_pid = pid;
char fn_cmdline[255] = {0,};
/* unneeded version 2.0 */
-static inline int _tgl_init(int fd, unsigned int key)
+static inline int
+_tgl_init(int fd, unsigned int key)
{
struct tgl_attribute attr;
int err;
err = ioctl(fd, TGL_IOC_INIT_LOCK, &attr);
if (err) {
- TBM_LOG("[libtbm:%d] "
- "error(%s) %s:%d key:%d\n",
- getpid(), strerror(errno), __FUNCTION__, __LINE__, key);
+ TBM_LOG("[libtbm:%d] error(%s) %s:%d key:%d\n",
+ getpid(), strerror(errno), __func__, __LINE__, key);
return 0;
}
return 1;
}
-static inline int _tgl_destroy(int fd, unsigned int key)
+static inline int
+_tgl_destroy(int fd, unsigned int key)
{
int err;
+
err = ioctl(fd, TGL_IOC_DESTROY_LOCK, key);
if (err) {
TBM_LOG("[libtbm:%d] "
"error(%s) %s:%d key:%d\n",
- getpid(), strerror(errno), __FUNCTION__, __LINE__, key);
+ getpid(), strerror(errno), __func__, __LINE__, key);
return 0;
}
return 1;
}
-static inline int _tgl_lock(int fd, unsigned int key)
+static inline int
+_tgl_lock(int fd, unsigned int key)
{
int err;
+
err = ioctl(fd, TGL_IOC_LOCK_LOCK, key);
if (err) {
TBM_LOG("[libtbm:%d] "
"error(%s) %s:%d key:%d\n",
- getpid(), strerror(errno), __FUNCTION__, __LINE__, key);
+ getpid(), strerror(errno), __func__, __LINE__, key);
return 0;
}
return 1;
}
-static inline int _tgl_unlock(int fd, unsigned int key)
+static inline int
+_tgl_unlock(int fd, unsigned int key)
{
int err;
+
err = ioctl(fd, TGL_IOC_UNLOCK_LOCK, key);
if (err) {
TBM_LOG("[libtbm:%d] "
"error(%s) %s:%d key:%d\n",
- getpid(), strerror(errno), __FUNCTION__, __LINE__, key);
+ getpid(), strerror(errno), __func__, __LINE__, key);
return 0;
}
return 1;
}
-static inline int _tgl_set_data(int fd, unsigned int key, unsigned int val)
+static inline int
+_tgl_set_data(int fd, unsigned int key, unsigned int val)
{
int err;
struct tgl_user_data arg;
if (err) {
TBM_LOG("[libtbm:%d] "
"error(%s) %s:%d key:%d\n",
- getpid(), strerror(errno), __FUNCTION__, __LINE__, key);
+ getpid(), strerror(errno), __func__, __LINE__, key);
return 0;
}
return 1;
}
-static inline unsigned int _tgl_get_data(int fd, unsigned int key, unsigned int *locked)
+static inline unsigned int
+_tgl_get_data(int fd, unsigned int key, unsigned int *locked)
{
int err;
struct tgl_user_data arg = { 0, };
if (err) {
TBM_LOG("[libtbm:%d] "
"error(%s) %s:%d key:%d\n",
- getpid(), strerror(errno), __FUNCTION__, __LINE__, key);
+ getpid(), strerror(errno), __func__, __LINE__, key);
return 0;
}
}
/* unneeded version 2.0 */
-tbm_user_data *user_data_lookup(struct list_head *user_data_list, unsigned long key)
+tbm_user_data
+*user_data_lookup(struct list_head *user_data_list, unsigned long key)
{
tbm_user_data *user_data = NULL;
tbm_user_data *old_data = NULL, *tmp = NULL;
return user_data;
}
-tbm_user_data *user_data_create(unsigned long key, tbm_data_free data_free_func)
+tbm_user_data
+*user_data_create(unsigned long key, tbm_data_free data_free_func)
{
tbm_user_data *user_data = NULL;
return user_data;
}
-void user_data_delete(tbm_user_data * user_data)
+void
+user_data_delete(tbm_user_data *user_data)
{
if (user_data->data && user_data->free_func)
user_data->free_func(user_data->data);
free(user_data);
}
-static int _bo_lock(tbm_bo bo, int device, int opt)
+static int
+_bo_lock(tbm_bo bo, int device, int opt)
{
tbm_bufmgr bufmgr = bo->bufmgr;
int ret = 0;
} else {
TBM_LOG("[libtbm:%d] "
"error %s:%d no backend lock functions\n",
- getpid(), __FUNCTION__, __LINE__);
+ getpid(), __func__, __LINE__);
}
} else {
if (TBM_LOCK_CTRL_BACKEND_VALID(bufmgr->backend->flags)) {
} else {
TBM_LOG("[libtbm:%d] "
"error %s:%d no backend lock functions\n",
- getpid(), __FUNCTION__, __LINE__);
+ getpid(), __func__, __LINE__);
}
} else {
/* use tizen global lock */
return ret;
}
-static void _bo_unlock(tbm_bo bo)
+static void
+_bo_unlock(tbm_bo bo)
{
tbm_bufmgr bufmgr = bo->bufmgr;
} else {
TBM_LOG("[libtbm:%d] "
"error %s:%d no backend unlock functions\n",
- getpid(), __FUNCTION__, __LINE__);
+ getpid(), __func__, __LINE__);
}
- }
- else {
+ } else {
if (TBM_LOCK_CTRL_BACKEND_VALID(bufmgr->backend->flags)) {
if (bufmgr->backend->bo_unlock) {
/* use backend unlock */
} else {
TBM_LOG("[libtbm:%d] "
"error %s:%d no backend unlock functions\n",
- getpid(), __FUNCTION__, __LINE__);
+ getpid(), __func__, __LINE__);
}
} else {
/* use tizen global unlock */
}
}
-static int _tbm_bo_init_state(tbm_bo bo, int opt)
+static int
+_tbm_bo_init_state(tbm_bo bo, int opt)
{
tbm_bufmgr bufmgr = bo->bufmgr;
tbm_bo_cache_state cache_state;
return 1;
}
-static void _tbm_bo_destroy_state(tbm_bo bo)
+static void
+_tbm_bo_destroy_state(tbm_bo bo)
{
tbm_bufmgr bufmgr = bo->bufmgr;
_tgl_destroy(bufmgr->lock_fd, bo->tgl_key);
}
-static int _tbm_bo_set_state(tbm_bo bo, int device, int opt)
+static int
+_tbm_bo_set_state(tbm_bo bo, int device, int opt)
{
tbm_bufmgr bufmgr = bo->bufmgr;
char need_flush = 0;
if (DEVICE_IS_CACHE_AWARE(device)) {
if (bo->cache_state.data.isDirtied == DEVICE_CO &&
- bo->cache_state.data.isCached)
+ bo->cache_state.data.isCached)
need_flush = TBM_CACHE_INV;
bo->cache_state.data.isCached = 1;
}
} else {
if (bo->cache_state.data.isDirtied == DEVICE_CA &&
- bo->cache_state.data.isCached &&
- bo->cache_state.data.cntFlush == cntFlush)
+ bo->cache_state.data.isCached &&
+ bo->cache_state.data.cntFlush == cntFlush)
need_flush = TBM_CACHE_CLN | TBM_CACHE_ALL;
if (opt & TBM_OPTION_WRITE)
bufmgr->backend->bo_cache_flush(bo, need_flush);
DBG("[libtbm:%d] \tcache(%d,%d,%d)....flush:0x%x, cntFlush(%d)\n",
- getpid(),
- bo->cache_state.data.isCacheable,
- bo->cache_state.data.isCached,
- bo->cache_state.data.isDirtied,
- need_flush,
- cntFlush);
+ getpid(),
+ bo->cache_state.data.isCacheable,
+ bo->cache_state.data.isCached,
+ bo->cache_state.data.isDirtied,
+ need_flush,
+ cntFlush);
}
return 1;
}
-static void _tbm_bo_save_state(tbm_bo bo)
+static void
+_tbm_bo_save_state(tbm_bo bo)
{
tbm_bufmgr bufmgr = bo->bufmgr;
unsigned short cntFlush = 0;
_tgl_set_data(bufmgr->lock_fd, bo->tgl_key, bo->cache_state.val);
}
-static int _tbm_bo_lock(tbm_bo bo, int device, int opt)
+static int
+_tbm_bo_lock(tbm_bo bo, int device, int opt)
{
tbm_bufmgr bufmgr = NULL;
int old;
if (bo->lock_cnt < 0) {
TBM_LOG("[libtbm:%d] "
"error %s:%d bo:%p(%d) LOCK_CNT=%d\n",
- getpid(), __FUNCTION__, __LINE__, bo, bo->tgl_key, bo->lock_cnt);
+ getpid(), __func__, __LINE__, bo, bo->tgl_key, bo->lock_cnt);
}
old = bo->lock_cnt;
} else {
TBM_LOG("[libtbm:%d] "
"error %s:%d bo:%p lock_type is wrong.\n",
- getpid(), __FUNCTION__, __LINE__, bo);
+ getpid(), __func__, __LINE__, bo);
}
DBG_LOCK("[libtbm:%d] >> LOCK bo:%p(%d, %d->%d)\n", getpid(),
- bo, bo->tgl_key, old, bo->lock_cnt);
+ bo, bo->tgl_key, old, bo->lock_cnt);
return ret;
}
-static void _tbm_bo_unlock(tbm_bo bo)
+static void
+_tbm_bo_unlock(tbm_bo bo)
{
tbm_bufmgr bufmgr = NULL;
} else {
TBM_LOG("[libtbm:%d] "
"error %s:%d bo:%p lock_type is wrong.\n",
- getpid(), __FUNCTION__, __LINE__, bo);
+ getpid(), __func__, __LINE__, bo);
}
if (bo->lock_cnt < 0)
bo->lock_cnt = 0;
DBG_LOCK("[libtbm:%d] << unlock bo:%p(%d, %d->%d)\n", getpid(),
- bo, bo->tgl_key, old, bo->lock_cnt);
+ bo, bo->tgl_key, old, bo->lock_cnt);
}
-static int _tbm_bo_is_valid(tbm_bo bo)
+static int
+_tbm_bo_is_valid(tbm_bo bo)
{
- tbm_bo old_data = NULL, tmp = NULL;;
+ tbm_bo old_data = NULL, tmp = NULL;
if (bo == NULL)
return 0;
return 0;
}
-static void _tbm_bo_ref(tbm_bo bo)
+static void
+_tbm_bo_ref(tbm_bo bo)
{
bo->ref_cnt++;
}
-static void _tbm_bo_unref(tbm_bo bo)
+static void
+_tbm_bo_unref(tbm_bo bo)
{
tbm_bufmgr bufmgr = bo->bufmgr;
tbm_user_data *old_data = NULL, *tmp = NULL;
/* destory the user_data_list */
if (!LIST_IS_EMPTY(&bo->user_data_list)) {
LIST_FOR_EACH_ENTRY_SAFE(old_data, tmp, &bo->user_data_list, item_link) {
- DBG("[libtbm:%d] free user_data \n",
- getpid());
+ DBG("[libtbm:%d] free user_data\n",
+ getpid());
user_data_delete(old_data);
}
}
if (bo->lock_cnt > 0) {
TBM_LOG("[libtbm:%d] "
"error %s:%d lock_cnt:%d\n",
- getpid(), __FUNCTION__, __LINE__, bo->lock_cnt);
+ getpid(), __func__, __LINE__, bo->lock_cnt);
_bo_unlock(bo);
}
}
-static int _tbm_bufmgr_init_state(tbm_bufmgr bufmgr)
+static int
+_tbm_bufmgr_init_state(tbm_bufmgr bufmgr)
{
RETURN_VAL_CHECK_FLAG(TBM_ALL_CTRL_BACKEND_VALID(bufmgr->backend->flags), 1);
return 1;
}
-static void _tbm_bufmgr_destroy_state(tbm_bufmgr bufmgr)
+static void
+_tbm_bufmgr_destroy_state(tbm_bufmgr bufmgr)
{
RETURN_CHECK_FLAG(TBM_ALL_CTRL_BACKEND_VALID(bufmgr->backend->flags));
close(bufmgr->lock_fd);
}
-static int _check_version(TBMModuleVersionInfo * data)
+static int
+_check_version(TBMModuleVersionInfo *data)
{
int abimaj, abimin;
int vermaj, vermin;
abimin = GET_ABI_MINOR(data->abiversion);
DBG("[libtbm:%d] "
- "TBM module %s: vendor=\"%s\" ABI=%d,%d\n",
- getpid(), data->modname ? data->modname : "UNKNOWN!",
- data->vendor ? data->vendor : "UNKNOWN!", abimaj, abimin);
+ "TBM module %s: vendor=\"%s\" ABI=%d,%d\n",
+ getpid(), data->modname ? data->modname : "UNKNOWN!",
+ data->vendor ? data->vendor : "UNKNOWN!", abimaj, abimin);
vermaj = GET_ABI_MAJOR(TBM_ABI_VERSION);
vermin = GET_ABI_MINOR(TBM_ABI_VERSION);
DBG("[libtbm:%d] "
- "TBM ABI version %d.%d\n",
- getpid(), vermaj, vermin);
+ "TBM ABI version %d.%d\n",
+ getpid(), vermaj, vermin);
if (abimaj != vermaj) {
TBM_LOG("[libtbm:%d] "
return 1;
}
-static int _tbm_bufmgr_load_module(tbm_bufmgr bufmgr, int fd, const char *file)
+static int
+_tbm_bufmgr_load_module(tbm_bufmgr bufmgr, int fd, const char *file)
{
char path[PATH_MAX] = { 0, };
TBMModuleData *initdata = NULL;
bufmgr->module_data = module_data;
DBG("[libtbm:%d] "
- "Success to load module(%s)\n",
- getpid(), file);
+ "Success to load module(%s)\n",
+ getpid(), file);
return 1;
}
-static int _tbm_load_module(tbm_bufmgr bufmgr, int fd)
+static int
+_tbm_load_module(tbm_bufmgr bufmgr, int fd)
{
struct dirent **namelist;
const char *p = NULL;
while (n--) {
if (!ret && strstr(namelist[n]->d_name, PREFIX_LIB)) {
p = strstr(namelist[n]->d_name, SUFFIX_LIB);
- if (p != NULL) {
- if (!strcmp(p, SUFFIX_LIB))
- ret = _tbm_bufmgr_load_module(bufmgr, fd, namelist[n]->d_name);
- }
+ if (p && !strcmp(p, SUFFIX_LIB))
+ ret = _tbm_bufmgr_load_module(bufmgr, fd, namelist[n]->d_name);
}
free(namelist[n]);
}
return ret;
}
-tbm_bufmgr tbm_bufmgr_init(int fd)
+tbm_bufmgr
+tbm_bufmgr_init(int fd)
{
char *env;
int fd_flag = 0;
if (env) {
bDebug = atoi(env);
TBM_LOG("GEM_DEBUG=%s\n", env);
- } else
+ } else {
bDebug = 0;
+ }
#endif
/* initialize buffer manager */
return NULL;
}
DBG("[libtbm:%d] duplicate the drm_fd(%d), new drm_fd(%d).\n",
- getpid(), gBufMgr->fd, fd);
+ getpid(), gBufMgr->fd, fd);
}
}
gBufMgr->ref_count++;
DBG("[libtbm:%d] bufmgr ref: fd=%d, ref_count:%d\n",
- getpid(), gBufMgr->fd, gBufMgr->ref_count);
+ getpid(), gBufMgr->fd, gBufMgr->ref_count);
pthread_mutex_unlock(&gLock);
return gBufMgr;
}
- if (fd < 0) {
+ if (fd < 0)
fd_flag = 1;
- }
DBG("[libtbm:%d] bufmgr init: fd=%d\n", getpid(), fd);
return NULL;
}
DBG("[libtbm:%d] duplicate the drm_fd(%d), bufmgr use fd(%d).\n",
- getpid(), fd, gBufMgr->fd);
+ getpid(), fd, gBufMgr->fd);
}
/* load bufmgr priv from env */
if (!_tbm_load_module(gBufMgr, gBufMgr->fd)) {
_tbm_set_last_result(TBM_BO_ERROR_LOAD_MODULE_FAILED);
- TBM_LOG("[libtbm:%d] " "error : Fail to load bufmgr backend\n", getpid());
+ TBM_LOG("[libtbm:%d] error : Fail to load bufmgr backend\n", getpid());
if (gBufMgr->fd > 0)
close(gBufMgr->fd);
gBufMgr = NULL;
pthread_mutex_unlock(&gLock);
return NULL;
- } else {
- backend_flag = gBufMgr->backend->flags;
- /* log for tbm backend_flag */
- DBG("[libtbm:%d] ", getpid());
- DBG("cache_crtl:");
- if (backend_flag & TBM_CACHE_CTRL_BACKEND) {
- DBG("BACKEND ");
- } else {
- DBG("TBM ");
- }
+ }
- DBG("lock_crtl:");
- if (backend_flag & TBM_LOCK_CTRL_BACKEND) {
- DBG("BACKEND ");
- } else {
- DBG("TBM ");
- }
+ backend_flag = gBufMgr->backend->flags;
+ /* log for tbm backend_flag */
+ DBG("[libtbm:%d] ", getpid());
+ DBG("cache_crtl:");
+ if (backend_flag & TBM_CACHE_CTRL_BACKEND) {
+ DBG("BACKEND ");
+ } else {
+ DBG("TBM ");
+ }
- if (backend_flag & TBM_USE_2_0_BACKEND) {
- gBufMgr->use_2_0 = 1;
- DBG("USE 2.0 backend");
- }
+ DBG("lock_crtl:");
+ if (backend_flag & TBM_LOCK_CTRL_BACKEND) {
+ DBG("BACKEND ");
+ } else {
+ DBG("TBM ");
+ }
- DBG("\n");
+ if (backend_flag & TBM_USE_2_0_BACKEND) {
+ gBufMgr->use_2_0 = 1;
+ DBG("USE 2.0 backend");
}
+ DBG("\n");
+
gBufMgr->ref_count = 1;
DBG("[libtbm:%d] create tizen bufmgr: ref_count:%d\n",
- getpid(), gBufMgr->ref_count);
+ getpid(), gBufMgr->ref_count);
if (pthread_mutex_init(&gBufMgr->lock, NULL) != 0) {
_tbm_set_last_result(TBM_BO_ERROR_THREAD_INIT_FAILED);
/* 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());
+ 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);
else
gBufMgr->use_map_cache = 1;
DBG("[libtbm:%d] BUFMGR_MAP_CACHE=%s\n",
- getpid(), env ? env : "default:true");
+ getpid(), env ? env : "default:true");
}
/* setup the lock_type */
gBufMgr->lock_type = LOCK_TRY_ALWAYS;
DBG("[libtbm:%d] BUFMGR_LOCK_TYPE=%s\n",
- getpid(), env ? env : "default:once");
+ getpid(), env ? env : "default:once");
/* intialize bo_list */
LIST_INITHEAD(&gBufMgr->bo_list);
return gBufMgr;
}
-void tbm_bufmgr_deinit(tbm_bufmgr bufmgr)
+void
+tbm_bufmgr_deinit(tbm_bufmgr bufmgr)
{
TBM_RETURN_IF_FAIL(TBM_BUFMGR_IS_VALID(bufmgr));
if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
LIST_FOR_EACH_ENTRY_SAFE(bo, tmp, &bufmgr->bo_list, item_link) {
TBM_LOG("[libtbm:%d] "
- "Un-freed bo(%p, ref:%d) \n",
+ "Un-freed bo(%p, ref:%d)\n",
getpid(), bo, bo->ref_cnt);
bo->ref_cnt = 1;
tbm_bo_unref(bo);
if (!LIST_IS_EMPTY(&bufmgr->surf_list)) {
LIST_FOR_EACH_ENTRY_SAFE(surf, tmp_surf, &bufmgr->surf_list, item_link) {
TBM_LOG("[libtbm:%d] "
- "Destroy surf(%p) \n",
+ "Destroy surf(%p)\n",
getpid(), surf);
tbm_surface_destroy(surf);
}
pthread_mutex_destroy(&bufmgr->lock);
DBG("[libtbm:%d] "
- "tizen bufmgr destroy: bufmgr:%p\n",
- getpid(), bufmgr);
+ "tizen bufmgr destroy: bufmgr:%p\n",
+ getpid(), bufmgr);
dlclose(bufmgr->module_data);
pthread_mutex_unlock(&gLock);
}
-int tbm_bo_size(tbm_bo bo)
+int
+tbm_bo_size(tbm_bo bo)
{
TBM_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), 0);
return size;
}
-tbm_bo tbm_bo_ref(tbm_bo bo)
+tbm_bo
+tbm_bo_ref(tbm_bo bo)
{
TBM_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), NULL);
return bo;
}
-void tbm_bo_unref(tbm_bo bo)
+void
+tbm_bo_unref(tbm_bo bo)
{
TBM_RETURN_IF_FAIL(_tbm_bo_is_valid(bo));
pthread_mutex_unlock(&bufmgr->lock);
}
-tbm_bo tbm_bo_alloc(tbm_bufmgr bufmgr, int size, int flags)
+tbm_bo
+tbm_bo_alloc(tbm_bufmgr bufmgr, int size, int flags)
{
TBM_RETURN_VAL_IF_FAIL(TBM_BUFMGR_IS_VALID(bufmgr) && (size > 0), NULL);
return bo;
}
-tbm_bo tbm_bo_import(tbm_bufmgr bufmgr, unsigned int key)
+tbm_bo
+tbm_bo_import(tbm_bufmgr bufmgr, unsigned int key)
{
TBM_RETURN_VAL_IF_FAIL(TBM_BUFMGR_IS_VALID(bufmgr), NULL);
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);
+ "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);
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);
+ "find bo(%p, ref:%d key:%d) in list\n",
+ getpid(), bo2, bo2->ref_cnt, bo2->tgl_key);
bo2->ref_cnt++;
free(bo);
return bo;
}
-tbm_bo tbm_bo_import_fd(tbm_bufmgr bufmgr, tbm_fd fd)
+tbm_bo
+tbm_bo_import_fd(tbm_bufmgr bufmgr, tbm_fd fd)
{
TBM_RETURN_VAL_IF_FAIL(TBM_BUFMGR_IS_VALID(bufmgr), NULL);
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);
+ "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);
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);
+ "find bo(%p, ref:%d key:%d) in list\n",
+ getpid(), bo2, bo2->ref_cnt, bo2->tgl_key);
bo2->ref_cnt++;
free(bo);
return bo;
}
-tbm_key tbm_bo_export(tbm_bo bo)
+tbm_key
+tbm_bo_export(tbm_bo bo)
{
TBM_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), 0);
return ret;
}
-tbm_fd tbm_bo_export_fd(tbm_bo bo)
+tbm_fd
+tbm_bo_export_fd(tbm_bo bo)
{
TBM_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), -1);
return ret;
}
-tbm_bo_handle tbm_bo_get_handle(tbm_bo bo, int device)
+tbm_bo_handle
+tbm_bo_get_handle(tbm_bo bo, int device)
{
TBM_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), (tbm_bo_handle) 0);
return bo_handle;
}
-tbm_bo_handle tbm_bo_map(tbm_bo bo, int device, int opt)
+tbm_bo_handle
+tbm_bo_map(tbm_bo bo, int device, int opt)
{
TBM_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), (tbm_bo_handle) 0);
_tbm_set_last_result(TBM_BO_ERROR_LOCK_FAILED);
TBM_LOG("[libtbm:%d] "
"error %s:%d fail to lock bo:%p)\n",
- getpid(), __FUNCTION__, __LINE__, bo);
+ getpid(), __func__, __LINE__, bo);
pthread_mutex_unlock(&bufmgr->lock);
return (tbm_bo_handle) NULL;
}
_tbm_set_last_result(TBM_BO_ERROR_MAP_FAILED);
TBM_LOG("[libtbm:%d] "
"error %s:%d fail to map bo:%p\n",
- getpid(), __FUNCTION__, __LINE__, bo);
+ getpid(), __func__, __LINE__, bo);
_tbm_bo_unlock(bo);
pthread_mutex_unlock(&bufmgr->lock);
return bo_handle;
}
-int tbm_bo_unmap(tbm_bo bo)
+int
+tbm_bo_unmap(tbm_bo bo)
{
TBM_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), 0);
return ret;
}
-int tbm_bo_swap(tbm_bo bo1, tbm_bo bo2)
+int
+tbm_bo_swap(tbm_bo bo1, tbm_bo bo2)
{
TBM_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo1), 0);
TBM_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo2), 0);
return 1;
}
-int tbm_bo_locked(tbm_bo bo)
+int
+tbm_bo_locked(tbm_bo bo)
{
TBM_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), 0);
return 0;
}
-int tbm_bo_add_user_data(tbm_bo bo, unsigned long key, tbm_data_free data_free_func)
+int
+tbm_bo_add_user_data(tbm_bo bo, unsigned long key,
+ tbm_data_free data_free_func)
{
TBM_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), 0);
if (data) {
TBM_LOG("[libtbm:%d] "
"waring: %s:%d user data already exist. key:%ld\n",
- getpid(), __FUNCTION__, __LINE__, key);
+ getpid(), __func__, __LINE__, key);
return 0;
}
return 1;
}
-int tbm_bo_set_user_data(tbm_bo bo, unsigned long key, void *data)
+int
+tbm_bo_set_user_data(tbm_bo bo, unsigned long key, void *data)
{
TBM_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), 0);
return 1;
}
-int tbm_bo_get_user_data(tbm_bo bo, unsigned long key, void **data)
+int
+tbm_bo_get_user_data(tbm_bo bo, unsigned long key, void **data)
{
TBM_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), 0);
return 1;
}
-int tbm_bo_delete_user_data(tbm_bo bo, unsigned long key)
+int
+tbm_bo_delete_user_data(tbm_bo bo, unsigned long key)
{
TBM_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), 0);
return 1;
}
-tbm_error_e tbm_get_last_error(void)
+tbm_error_e
+tbm_get_last_error(void)
{
return tbm_last_error;
}
-unsigned int tbm_bufmgr_get_capability(tbm_bufmgr bufmgr)
+unsigned int
+tbm_bufmgr_get_capability(tbm_bufmgr bufmgr)
{
TBM_RETURN_VAL_IF_FAIL(TBM_BUFMGR_IS_VALID(bufmgr), 0);
return capability;
}
-int tbm_bo_get_flags(tbm_bo bo)
+int
+tbm_bo_get_flags(tbm_bo bo)
{
TBM_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), 0);
return bo->flags;
}
-void tbm_bufmgr_debug_show(tbm_bufmgr bufmgr)
+void
+tbm_bufmgr_debug_show(tbm_bufmgr bufmgr)
{
TBM_RETURN_IF_FAIL(bufmgr != NULL);
tbm_bo bo = NULL, tmp_bo = NULL;
TBM_DEBUG("\n");
_tbm_util_get_appname_from_pid(getpid(), app_name);
_tbm_util_get_appname_brief(app_name);
- TBM_DEBUG("============TBM DEBUG: %s(%d)===========================\n", app_name, getpid());
- memset(app_name, 0x0, 255*sizeof(char));
+ TBM_DEBUG("============TBM DEBUG: %s(%d)===========================\n",
+ app_name, getpid());
+ memset(app_name, 0x0, 255 * sizeof(char));
TBM_DEBUG("[tbm_surface information]\n");
TBM_DEBUG("no surface refcnt width height bpp size num_bos num_planes flags format app_name\n");
LIST_FOR_EACH_ENTRY_SAFE(surf, tmp_surf, &bufmgr->surf_list, item_link) {
pid = _tbm_surface_internal_get_debug_pid(surf);
if (!pid) {
- /* if pid is null, set the self_pid */
- pid = getpid();
+ /* if pid is null, set the self_pid */
+ pid = getpid();
}
_tbm_util_get_appname_from_pid(pid, app_name);
_tbm_util_get_appname_brief(app_name);
TBM_DEBUG("%-4d%-23p%-6d%-7d%-8d%-5d%-12d%-10d%-9d%-4d%-20s%s\n",
- ++surf_cnt,
- surf,
- surf->refcnt,
- surf->info.width,
- surf->info.height,
- surf->info.bpp,
- surf->info.size/1024,
- surf->num_bos,
- surf->num_planes,
- surf->flags,
- _tbm_surface_internal_format_to_str(surf->info.format),
- app_name);
+ ++surf_cnt,
+ surf,
+ surf->refcnt,
+ surf->info.width,
+ surf->info.height,
+ surf->info.bpp,
+ surf->info.size / 1024,
+ surf->num_bos,
+ surf->num_planes,
+ surf->flags,
+ _tbm_surface_internal_format_to_str(surf->info.format),
+ app_name);
for (i = 0; i < surf->num_bos; i++) {
TBM_DEBUG(" bo:%-12p(key:%2d) %-26d%-10d\n",
- surf->bos[i],
- surf->bos[i]->tgl_key,
- surf->bos[i]->ref_cnt,
- tbm_bo_size(surf->bos[i])/1024);
+ surf->bos[i],
+ surf->bos[i]->tgl_key,
+ surf->bos[i]->ref_cnt,
+ tbm_bo_size(surf->bos[i]) / 1024);
}
- memset(app_name, 0x0, 255*sizeof(char));
+ memset(app_name, 0x0, 255 * sizeof(char));
}
} else {
TBM_DEBUG("no tbm_surfaces.\n");
if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
LIST_FOR_EACH_ENTRY_SAFE(bo, tmp_bo, &bufmgr->bo_list, item_link) {
TBM_DEBUG("%-4d%-11p(key:%2d) %-6d%-12d%-9d%-9d%-10d%-4d%-11p\n",
- ++bo_cnt,
- bo,
- bo->tgl_key,
- bo->ref_cnt,
- tbm_bo_size(bo)/1024,
- bo->lock_cnt,
- bo->map_cnt,
- bo->cache_state.val,
- bo->flags,
- bo->surface);
+ ++bo_cnt,
+ bo,
+ bo->tgl_key,
+ bo->ref_cnt,
+ tbm_bo_size(bo) / 1024,
+ bo->lock_cnt,
+ bo->map_cnt,
+ bo->cache_state.val,
+ bo->flags,
+ bo->surface);
}
} else {
TBM_DEBUG("no tbm_bos.\n");
}
-void tbm_bufmgr_debug_trace(tbm_bufmgr bufmgr, int onoff)
+void
+tbm_bufmgr_debug_trace(tbm_bufmgr bufmgr, int onoff)
{
TBM_LOG("bufmgr=%p onoff=%d\n", bufmgr, onoff);
TBM_LOG("Not implemented yet.\n");
}
/* internal function */
-int _tbm_bo_set_surface(tbm_bo bo, tbm_surface_h surface)
+int
+_tbm_bo_set_surface(tbm_bo bo, tbm_surface_h surface)
{
TBM_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), 0);
@endcode
*/
-int tbm_bo_add_user_data(tbm_bo bo, unsigned long key, tbm_data_free data_free_func);
+int tbm_bo_add_user_data(tbm_bo bo, unsigned long key,
+ tbm_data_free data_free_func);
/**
* @brief Deletes the user_data in the buffer object.
* @since_tizen 3.0
* @param[in] bufmgr : the buffer manager
*/
-void tbm_bufmgr_debug_show (tbm_bufmgr bufmgr);
+void tbm_bufmgr_debug_show(tbm_bufmgr bufmgr);
/**
* @brief Print out the trace of tbm_bos.
* @param[in] bufmgr : the buffer manager
* @param[in] onoff : 1 is on, and 0 is off
*/
-void tbm_bufmgr_debug_trace (tbm_bufmgr bufmgr, int onoff);
+void tbm_bufmgr_debug_trace(tbm_bufmgr bufmgr, int onoff);
int flags = 0;
if (!bufmgr) {
- TBM_LOG("[libtbm:%d] " "error (%s): fail to init tbm backend... bufmgr is null\n", getpid(), __FUNCTION__);
+ TBM_LOG("[libtbm:%d] "
+ "error (%s): fail to init tbm backend... bufmgr is null\n", getpid(),
+ __func__);
return 0;
}
if (!backend) {
- TBM_LOG("[libtbm:%d] " "error (%s): fail to init tbm backend... backend is null\n", getpid(), __FUNCTION__);
+ TBM_LOG("[libtbm:%d] "
+ "error (%s): fail to init tbm backend... backend is null\n", getpid(),
+ __func__);
return 0;
}
if (!(flags & TBM_USE_2_0_BACKEND)) {
if (flags & TBM_CACHE_CTRL_BACKEND) {
if (!backend->bo_cache_flush) {
- TBM_LOG("[libtbm:%d] " "error (%s): TBM_FLAG_CACHE_CTRL_TBM needs backend->bo_cache_flush\n", getpid(), __FUNCTION__);
+ TBM_LOG("[libtbm:%d] "
+ "error (%s): TBM_FLAG_CACHE_CTRL_TBM needs backend->bo_cache_flush\n", getpid(),
+ __func__);
return 0;
}
}
void *priv; /**< bufmgr private */
/**
- * @brief deinitialize the bufmgr private.
- * @param[in] bufmgr : the private of the bufmgr
- * @return 1 if this function succeeds, otherwise 0.
- */
- void (*bufmgr_deinit) (void *priv);
+ * @brief deinitialize the bufmgr private.
+ * @param[in] bufmgr : the private of the bufmgr
+ * @return 1 if this function succeeds, otherwise 0.
+ */
+ void (*bufmgr_deinit)(void *priv);
/**
- * @brief get the size of a bo.
- * @param[in] bo : the buffer object
- * @return 1 if this function succeeds, otherwise 0.
- */
- int (*bo_size) (tbm_bo bo);
+ * @brief get the size of a bo.
+ * @param[in] bo : the buffer object
+ * @return 1 if this function succeeds, otherwise 0.
+ */
+ int (*bo_size)(tbm_bo bo);
/**
- * @brief allocate the buffer object
- * @param[in] bo : the buffer object
- * @param[in] size : the size of buffer object
- * @param[in] flags : the flags of memory type
- * @return pointer of the bo private.
- */
- void *(*bo_alloc) (tbm_bo bo, int size, int flags);
+ * @brief allocate the buffer object
+ * @param[in] bo : the buffer object
+ * @param[in] size : the size of buffer object
+ * @param[in] flags : the flags of memory type
+ * @return pointer of the bo private.
+ */
+ void *(*bo_alloc)(tbm_bo bo, int size, int flags);
/**
- * @brief free the buffer object.
- * @param[in] bo : the buffer object
- */
- void (*bo_free) (tbm_bo bo);
+ * @brief free the buffer object.
+ * @param[in] bo : the buffer object
+ */
+ void (*bo_free)(tbm_bo bo);
/**
- * @brief import the buffer object associated with the key.
- * @remarks If the backend doesn't support a buffer sharing by tbm key,
+ * @brief import the buffer object associated with the key.
+ * @remarks If the backend doesn't support a buffer sharing by tbm key,
fucntion pointer must be set to NULL.
- * @param[in] bo : the buffer object
- * @param[in] key : the key associated with the buffer object
- * @return pointer of the bo private.
- */
- void *(*bo_import) (tbm_bo bo, unsigned int key);
+ * @param[in] bo : the buffer object
+ * @param[in] key : the key associated with the buffer object
+ * @return pointer of the bo private.
+ */
+ void *(*bo_import)(tbm_bo bo, unsigned int key);
/**
- * @brief export the buffer object
- * @remarks If the backend doesn't support a buffer sharing by tbm key,
+ * @brief export the buffer object
+ * @remarks If the backend doesn't support a buffer sharing by tbm key,
fucntion pointer must be set to NULL.
- * @param[in] bo : the buffer object
- * @return key associated with the buffer object
- */
- unsigned int (*bo_export) (tbm_bo bo);
+ * @param[in] bo : the buffer object
+ * @return key associated with the buffer object
+ */
+ unsigned int (*bo_export)(tbm_bo bo);
/**
- * @brief get the tbm_bo_handle according to the device type.
- * @param[in] bo : the buffer object
- * @param[in] device : the device type to get a handle
- * @return the handle of the buffer object
- */
- tbm_bo_handle(*bo_get_handle) (tbm_bo bo, int device);
+ * @brief get the tbm_bo_handle according to the device type.
+ * @param[in] bo : the buffer object
+ * @param[in] device : the device type to get a handle
+ * @return the handle of the buffer object
+ */
+ tbm_bo_handle(*bo_get_handle)(tbm_bo bo, int device);
/**
- * @brief map the buffer object according to the device type and the option.
- * @param[in] bo : the buffer object
- * @param[in] device : the device type to get a handle
- * @param[in] option : the option to access the buffer object
- * @return the handle of the buffer object
- */
- tbm_bo_handle(*bo_map) (tbm_bo bo, int device, int opt);
+ * @brief map the buffer object according to the device type and the option.
+ * @param[in] bo : the buffer object
+ * @param[in] device : the device type to get a handle
+ * @param[in] option : the option to access the buffer object
+ * @return the handle of the buffer object
+ */
+ tbm_bo_handle(*bo_map)(tbm_bo bo, int device, int opt);
/**
- * @brief unmap the buffer object.
- * @param[in] bo : the buffer object
- * @return 1 if this function succeeds, otherwise 0.
- */
- int (*bo_unmap) (tbm_bo bo);
+ * @brief unmap the buffer object.
+ * @param[in] bo : the buffer object
+ * @return 1 if this function succeeds, otherwise 0.
+ */
+ int (*bo_unmap)(tbm_bo bo);
/* version 2.0 dosen't need to backend function bo_cache_flush */
/**
- * @brief flush the cache of the buffer object.
- * @param[in] bo : the buffer object
- * @param[in] flags : the flags of cache flush type
- * @return 1 if this function succeeds, otherwise 0.
- */
- int (*bo_cache_flush) (tbm_bo bo, int flags);
+ * @brief flush the cache of the buffer object.
+ * @param[in] bo : the buffer object
+ * @param[in] flags : the flags of cache flush type
+ * @return 1 if this function succeeds, otherwise 0.
+ */
+ int (*bo_cache_flush)(tbm_bo bo, int flags);
/* version 2.0 dosen't need to backend function bo_get_global_key */
/**
- * @brief get the global key associated with the buffer object.
- * @param[in] bo : the buffer object
- * @return global key associated with the buffer object.
- */
- int (*bo_get_global_key) (tbm_bo bo);
+ * @brief get the global key associated with the buffer object.
+ * @param[in] bo : the buffer object
+ * @return global key associated with the buffer object.
+ */
+ int (*bo_get_global_key)(tbm_bo bo);
/**
- * @brief lock the buffer object.
- * @param[in] bo : the buffer object
- * @return 1 if this function succeeds, otherwise 0.
- * @remark This function pointer could be null. (default: use the tizen global lock)
- */
- int (*bo_lock) (tbm_bo bo);
+ * @brief lock the buffer object.
+ * @param[in] bo : the buffer object
+ * @return 1 if this function succeeds, otherwise 0.
+ * @remark This function pointer could be null. (default: use the tizen global lock)
+ */
+ int (*bo_lock)(tbm_bo bo);
/**
- * @brief unlock the buffer object.
- * @param[in] bo : the buffer object
- * @return 1 if this function succeeds, otherwise 0.
- * @remark This function pointer could be null. (default: use the tizen global lock)
- */
- int (*bo_unlock) (tbm_bo bo);
+ * @brief unlock the buffer object.
+ * @param[in] bo : the buffer object
+ * @return 1 if this function succeeds, otherwise 0.
+ * @remark This function pointer could be null. (default: use the tizen global lock)
+ */
+ int (*bo_unlock)(tbm_bo bo);
/**
- * @brief lock the buffer object with a device and an opt.
- * @param[in] bo : the buffer object
- * @param[in] device : the device type to get a handle
- * @param[in] option : the option to access the buffer object
- * @return 1 if this function succeeds, otherwise 0.
- * @remark This function pointer could be null. (default: use the tizen global lock)
- */
- int (*bo_lock2) (tbm_bo bo, int device, int opt);
+ * @brief lock the buffer object with a device and an opt.
+ * @param[in] bo : the buffer object
+ * @param[in] device : the device type to get a handle
+ * @param[in] option : the option to access the buffer object
+ * @return 1 if this function succeeds, otherwise 0.
+ * @remark This function pointer could be null. (default: use the tizen global lock)
+ */
+ int (*bo_lock2)(tbm_bo bo, int device, int opt);
/**
- * @brief query the formats list and the num to be supported by backend.
- * @param[out] *formats : format array list. this array has to be allocated by backend funtion
- * @param[out] *num : the number of the formats to be supported by backend
- * @return 1 if this function succeeds, otherwise 0.
- */
- int (*surface_supported_format) (uint32_t ** formats, uint32_t * num);
+ * @brief query the formats list and the num to be supported by backend.
+ * @param[out] *formats : format array list. this array has to be allocated by backend funtion
+ * @param[out] *num : the number of the formats to be supported by backend
+ * @return 1 if this function succeeds, otherwise 0.
+ */
+ int (*surface_supported_format)(uint32_t **formats, uint32_t *num);
/* version 2.0 dosen't need to backend function surface get size*/
/**
- * @brief get the size of the surface with a format.
- * @param[in] surface : the surface
- * @param[in] width : the width of the surface
- * @param[in] height : the height of the surface
- * @param[in] format : the format of the surface
- * @return size of the surface if this function succeeds, otherwise 0.
- */
- int (*surface_get_size) (tbm_surface_h surface, int width, int height, tbm_format format);
+ * @brief get the size of the surface with a format.
+ * @param[in] surface : the surface
+ * @param[in] width : the width of the surface
+ * @param[in] height : the height of the surface
+ * @param[in] format : the format of the surface
+ * @return size of the surface if this function succeeds, otherwise 0.
+ */
+ int (*surface_get_size)(tbm_surface_h surface, int width, int height,
+ tbm_format format);
/**
- * @brief get the plane data of the surface.
- * @param[in] surface : the surface
- * @param[in] width : the width of the surface
- * @param[in] height : the height of the surface
- * @param[in] format : the format of the surface
- * @param[in] plane_idx : the format of the surface
- * @param[out] size : the size of the plane
- * @param[out] offset : the offset of the plane
- * @param[out] pitch : the pitch of the plane
- * @param[out] bo_idx : the bo index of the plane
- * @return 1 if this function succeeds, otherwise 0.
- */
- 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, int *bo_idx);
+ * @brief get the plane data of the surface.
+ * @param[in] surface : the surface
+ * @param[in] width : the width of the surface
+ * @param[in] height : the height of the surface
+ * @param[in] format : the format of the surface
+ * @param[in] plane_idx : the format of the surface
+ * @param[out] size : the size of the plane
+ * @param[out] offset : the offset of the plane
+ * @param[out] pitch : the pitch of the plane
+ * @param[out] bo_idx : the bo index of the plane
+ * @return 1 if this function succeeds, otherwise 0.
+ */
+ 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, int *bo_idx);
/**
- * @brief import the buffer object associated with the prime fd.
- * @remarks tbm_fd must be free by user.
- * @remarks If the backend doesn't support a buffer sharing by tbm fd,
+ * @brief import the buffer object associated with the prime fd.
+ * @remarks tbm_fd must be free by user.
+ * @remarks If the backend doesn't support a buffer sharing by tbm fd,
fucntion pointer must be set to NULL.
- * @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);
+ * @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
- * @remarks tbm_fd must be free by user.
- * @remarks If the backend doesn't support a buffer sharing by tbm fd,
+ * @brief export the buffer object
+ * @remarks tbm_fd must be free by user.
+ * @remarks If the backend doesn't support a buffer sharing by tbm fd,
fucntion pointer must be set to NULL.
- * @param[in] bo : the buffer object
- * @return tbm_fd associated with the buffer object
- */
- tbm_fd(*bo_export_fd) (tbm_bo bo);
-
+ * @param[in] bo : the buffer object
+ * @return tbm_fd associated with the buffer object
+ */
+ tbm_fd (*bo_export_fd)(tbm_bo bo);
/* version 2.0 dosen't need to backend function fd_to_handle */
/**
- * @brief get the tbm_bo_handle according to the device type and the prime fd.
- * @param[in] bufmgr : the tizen buffer manager
- * @param[in] fd : the prime fd associated with the buffer object
- * @param[in] device : the option to access the buffer object
- * @return the handle of the buffer object
- */
- tbm_bo_handle(*fd_to_handle) (tbm_bufmgr bufmgr, tbm_fd fd, int device);
+ * @brief get the tbm_bo_handle according to the device type and the prime fd.
+ * @param[in] bufmgr : the tizen buffer manager
+ * @param[in] fd : the prime fd associated with the buffer object
+ * @param[in] device : the option to access the buffer object
+ * @return the handle of the buffer object
+ */
+ tbm_bo_handle(*fd_to_handle)(tbm_bufmgr bufmgr, tbm_fd fd, int device);
/**
- * @brief get the num of bos with a format.
- * @param[in] format : the format of the surface
- * @return num of the bos if this function succeeds, otherwise 0.
- */
- int (*surface_get_num_bos) (tbm_format format);
+ * @brief get the num of bos with a format.
+ * @param[in] format : the format of the surface
+ * @return num of the bos if this function succeeds, otherwise 0.
+ */
+ int (*surface_get_num_bos)(tbm_format format);
/**
- * @brief get the tbm flags of memory type
- * @param[in] bo : the buffer object
- * @see #TBM_BO_FLAGS
- * @return tbm flags of memory type is this function succeeds, otherwise 0.
- */
- int (*bo_get_flags) (tbm_bo bo);
+ * @brief get the tbm flags of memory type
+ * @param[in] bo : the buffer object
+ * @see #TBM_BO_FLAGS
+ * @return tbm flags of memory type is this function succeeds, otherwise 0.
+ */
+ int (*bo_get_flags)(tbm_bo bo);
/* Padding for future extension */
- void (*reserved1) (void);
- void (*reserved2) (void);
- void (*reserved3) (void);
- void (*reserved4) (void);
- void (*reserved5) (void);
- void (*reserved6) (void);
+ void (*reserved1)(void);
+ void (*reserved2)(void);
+ void (*reserved3)(void);
+ void (*reserved4)(void);
+ void (*reserved5)(void);
+ void (*reserved6)(void);
};
/**
/* check condition */
#define TBM_RETURN_IF_FAIL(cond) {\
if (!(cond)) {\
- TBM_LOG("[%s] : '%s' failed.\n", __FUNCTION__, #cond);\
+ TBM_LOG("[%s] : '%s' failed.\n", __func__, #cond);\
return;\
} \
}
#define TBM_RETURN_VAL_IF_FAIL(cond, val) {\
if (!(cond)) {\
- TBM_LOG("[%s] : '%s' failed.\n", __FUNCTION__, #cond);\
+ TBM_LOG("[%s] : '%s' failed.\n", __func__, #cond);\
return val;\
} \
}
/* check validation */
#define TBM_BUFMGR_IS_VALID(mgr) (mgr)
#define TBM_BO_IS_VALID(bo) (bo && \
- TBM_BUFMGR_IS_VALID(bo->bufmgr) && \
- bo->item_link.next && \
- bo->item_link.next->prev == &bo->item_link)
+ TBM_BUFMGR_IS_VALID(bo->bufmgr) && \
+ bo->item_link.next && \
+ bo->item_link.next->prev == &bo->item_link)
#define TBM_SURFACE_IS_VALID(surf) (surf && \
- TBM_BUFMGR_IS_VALID(surf->bufmgr) && \
- surf->item_link.next && \
- surf->item_link.next->prev == &surf->item_link)
+ TBM_BUFMGR_IS_VALID(surf->bufmgr) && \
+ 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__)
union _tbm_bo_cache_state {
unsigned int val;
struct {
- unsigned int cntFlush:16; /*Flush all index for sync */
- unsigned int isCacheable:1;
- unsigned int isCached:1;
- unsigned int isDirtied:2;
+ unsigned int cntFlush: 16; /*Flush all index for sync */
+ unsigned int isCacheable: 1;
+ unsigned int isCached: 1;
+ unsigned int isDirtied: 2;
} data;
};
/* unneeded version 2.0 */
int _tbm_bo_set_surface(tbm_bo bo, tbm_surface_h surface);
/* functions for mutex */
-int tbm_surface_internal_get_info(tbm_surface_h surface, int opt, tbm_surface_info_s * info, int map);
+int tbm_surface_internal_get_info(tbm_surface_h surface, int opt,
+ tbm_surface_info_s *info, int map);
void tbm_surface_internal_unmap(tbm_surface_h surface);
unsigned int tbm_surface_internal_get_width(tbm_surface_h surface);
unsigned int tbm_surface_internal_get_height(tbm_surface_h surface);
tbm_format tbm_surface_internal_get_format(tbm_surface_h surface);
unsigned int _tbm_surface_internal_get_debug_pid(tbm_surface_h surface);
-char * _tbm_surface_internal_format_to_str(tbm_format format);
+char *_tbm_surface_internal_format_to_str(tbm_format format);
-tbm_user_data *user_data_lookup(struct list_head *user_data_list, unsigned long key);
-tbm_user_data *user_data_create(unsigned long key, tbm_data_free data_free_func);
-void user_data_delete(tbm_user_data * user_data);
+tbm_user_data *user_data_lookup(struct list_head *user_data_list,
+ unsigned long key);
+tbm_user_data *user_data_create(unsigned long key,
+ tbm_data_free data_free_func);
+void user_data_delete(tbm_user_data *user_data);
#endif /* _TBM_BUFMGR_INT_H_ */
#include "tbm_bufmgr_int.h"
#include "tbm_surface_internal.h"
-int tbm_surface_query_formats(uint32_t ** formats, uint32_t * num)
+int
+tbm_surface_query_formats(uint32_t **formats, uint32_t *num)
{
if (!tbm_surface_internal_query_supported_formats(formats, num))
return TBM_SURFACE_ERROR_INVALID_OPERATION;
return TBM_SURFACE_ERROR_NONE;
}
-tbm_surface_h tbm_surface_create(int width, int height, tbm_format format)
+tbm_surface_h
+tbm_surface_create(int width, int height, tbm_format format)
{
if (!(width > 0) || !(height > 0)) {
#ifdef HAVE_CAPI_0_1_1
struct _tbm_surface *surf = NULL;
- surf = tbm_surface_internal_create_with_flags(width, height, format, TBM_BO_DEFAULT);
+ surf = tbm_surface_internal_create_with_flags(width, height, format,
+ TBM_BO_DEFAULT);
if (!surf) {
#ifdef HAVE_CAPI_0_1_1
set_last_result(TBM_SURFACE_ERROR_INVALID_OPERATION);
return surf;
}
-int tbm_surface_destroy(tbm_surface_h surface)
+int
+tbm_surface_destroy(tbm_surface_h surface)
{
if (!surface)
return TBM_SURFACE_ERROR_INVALID_PARAMETER;
return TBM_SURFACE_ERROR_NONE;
}
-int tbm_surface_map(tbm_surface_h surface, int opt, tbm_surface_info_s * info)
+int
+tbm_surface_map(tbm_surface_h surface, int opt, tbm_surface_info_s *info)
{
TBM_RETURN_VAL_IF_FAIL(surface != NULL, TBM_SURFACE_ERROR_INVALID_PARAMETER);
TBM_RETURN_VAL_IF_FAIL(info != NULL, TBM_SURFACE_ERROR_INVALID_PARAMETER);
return TBM_SURFACE_ERROR_NONE;
}
-int tbm_surface_unmap(tbm_surface_h surface)
+int
+tbm_surface_unmap(tbm_surface_h surface)
{
TBM_RETURN_VAL_IF_FAIL(surface != NULL, TBM_SURFACE_ERROR_INVALID_PARAMETER);
return TBM_SURFACE_ERROR_NONE;
}
-int tbm_surface_get_info(tbm_surface_h surface, tbm_surface_info_s * info)
+int
+tbm_surface_get_info(tbm_surface_h surface, tbm_surface_info_s *info)
{
TBM_RETURN_VAL_IF_FAIL(surface != NULL, TBM_SURFACE_ERROR_INVALID_PARAMETER);
TBM_RETURN_VAL_IF_FAIL(info != NULL, TBM_SURFACE_ERROR_INVALID_PARAMETER);
return TBM_SURFACE_ERROR_NONE;
}
-int tbm_surface_get_width(tbm_surface_h surface)
+int
+tbm_surface_get_width(tbm_surface_h surface)
{
TBM_RETURN_VAL_IF_FAIL(surface != NULL, TBM_SURFACE_ERROR_INVALID_PARAMETER);
return tbm_surface_internal_get_width(surface);
}
-int tbm_surface_get_height(tbm_surface_h surface)
+int
+tbm_surface_get_height(tbm_surface_h surface)
{
TBM_RETURN_VAL_IF_FAIL(surface != NULL, TBM_SURFACE_ERROR_INVALID_PARAMETER);
return tbm_surface_internal_get_height(surface);
}
-tbm_format tbm_surface_get_format(tbm_surface_h surface)
+tbm_format
+tbm_surface_get_format(tbm_surface_h surface)
{
if (!surface) {
#ifdef HAVE_CAPI_0_1_1
free (formats);
@endcode
*/
-int tbm_surface_query_formats(uint32_t ** formats, uint32_t * num);
+int tbm_surface_query_formats(uint32_t **formats, uint32_t *num);
/**
* @brief Creates the tbm_surface.
tbm_surface_destroy (surface);
@endcode
*/
-int tbm_surface_map(tbm_surface_h surface, int opt, tbm_surface_info_s * info);
+int tbm_surface_map(tbm_surface_h surface, int opt, tbm_surface_info_s *info);
/**
* @brief Unmaps the tbm_surface.
tbm_surface_destroy (surface);
@endcode
*/
-int tbm_surface_get_info(tbm_surface_h surface, tbm_surface_info_s * info);
+int tbm_surface_get_info(tbm_surface_h surface, tbm_surface_info_s *info);
/**
* @brief Gets the width of the tbm_surface.
#include "tbm_surface_internal.h"
#include "list.h"
-static tbm_bufmgr g_surface_bufmgr = NULL;
+static tbm_bufmgr g_surface_bufmgr;
static pthread_mutex_t tbm_surface_lock;
-char *_tbm_surface_internal_format_to_str(tbm_format format)
+char *
+_tbm_surface_internal_format_to_str(tbm_format format)
{
switch (format) {
case TBM_FORMAT_C8:
}
}
-static bool _tbm_surface_mutex_init(void)
+static bool
+_tbm_surface_mutex_init(void)
{
static bool tbm_surface_mutex_init = false;
return true;
}
-void _tbm_surface_mutex_lock(void)
+void
+_tbm_surface_mutex_lock(void)
{
if (!_tbm_surface_mutex_init())
return;
pthread_mutex_lock(&tbm_surface_lock);
}
-void _tbm_surface_mutex_unlock(void)
+void
+_tbm_surface_mutex_unlock(void)
{
pthread_mutex_unlock(&tbm_surface_lock);
}
-static void _init_surface_bufmgr()
+static void
+_init_surface_bufmgr(void)
{
g_surface_bufmgr = tbm_bufmgr_init(-1);
}
-static void _deinit_surface_bufmgr()
+static void
+_deinit_surface_bufmgr(void)
{
if (!g_surface_bufmgr)
return;
g_surface_bufmgr = NULL;
}
-static int _tbm_surface_internal_query_plane_data(tbm_surface_h surface, int plane_idx, uint32_t * size, uint32_t * offset, uint32_t * pitch, int *bo_idx)
+static int
+_tbm_surface_internal_query_plane_data(tbm_surface_h surface,
+ int plane_idx, uint32_t *size, uint32_t *offset, uint32_t *pitch, int *bo_idx)
{
TBM_RETURN_VAL_IF_FAIL(surface, 0);
TBM_RETURN_VAL_IF_FAIL(plane_idx > -1, 0);
if (!mgr->backend->surface_get_plane_data)
return 0;
- ret = mgr->backend->surface_get_plane_data(surf, surf->info.width, surf->info.height, surf->info.format, plane_idx, size, offset, pitch, bo_idx);
+ ret = mgr->backend->surface_get_plane_data(surf, surf->info.width,
+ surf->info.height, surf->info.format, plane_idx, size, offset, pitch, bo_idx);
if (!ret)
return 0;
return 1;
}
-static int _tbm_surface_internal_query_num_bos(tbm_format format)
+static int
+_tbm_surface_internal_query_num_bos(tbm_format format)
{
TBM_RETURN_VAL_IF_FAIL(format > 0, 0);
struct _tbm_bufmgr *mgr;
return ret;
}
-static void _tbm_surface_internal_destroy(tbm_surface_h surface)
+static void
+_tbm_surface_internal_destroy(tbm_surface_h surface)
{
int i;
tbm_bufmgr bufmgr = surface->bufmgr;
/* destory the user_data_list */
if (!LIST_IS_EMPTY(&surface->user_data_list)) {
LIST_FOR_EACH_ENTRY_SAFE(old_data, tmp, &surface->user_data_list, item_link) {
- TBM_LOG("[tbm_surface:%d] free user_data \n",
+ TBM_LOG("[tbm_surface:%d] free user_data\n",
getpid());
user_data_delete(old_data);
}
}
}
-int tbm_surface_internal_query_supported_formats(uint32_t ** formats, uint32_t * num)
+int
+tbm_surface_internal_query_supported_formats(uint32_t **formats,
+ uint32_t *num)
{
struct _tbm_bufmgr *mgr;
int ret = 0;
return ret;
}
-int tbm_surface_internal_get_num_planes(tbm_format format)
+int
+tbm_surface_internal_get_num_planes(tbm_format format)
{
int num_planes = 0;
return num_planes;
}
-int tbm_surface_internal_get_bpp(tbm_format format)
+int
+tbm_surface_internal_get_bpp(tbm_format format)
{
int bpp = 0;
return bpp;
}
-tbm_surface_h tbm_surface_internal_create_with_flags(int width, int height, int format, int flags)
+tbm_surface_h
+tbm_surface_internal_create_with_flags(int width, int height,
+ int format, int flags)
{
TBM_RETURN_VAL_IF_FAIL(width > 0, NULL);
TBM_RETURN_VAL_IF_FAIL(height > 0, NULL);
/* get size, stride and offset bo_idx */
for (i = 0; i < surf->info.num_planes; i++) {
- _tbm_surface_internal_query_plane_data(surf, i, &size, &offset, &stride, &bo_idx);
+ _tbm_surface_internal_query_plane_data(surf, i, &size, &offset, &stride,
+ &bo_idx);
surf->info.planes[i].size = size;
surf->info.planes[i].offset = offset;
surf->info.planes[i].stride = stride;
return surf;
}
-tbm_surface_h tbm_surface_internal_create_with_bos(tbm_surface_info_s * info, tbm_bo * bos, int num)
+tbm_surface_h
+tbm_surface_internal_create_with_bos(tbm_surface_info_s *info,
+ tbm_bo *bos, int num)
{
TBM_RETURN_VAL_IF_FAIL(bos, NULL);
TBM_RETURN_VAL_IF_FAIL(info, NULL);
_tbm_surface_mutex_unlock();
return surf;
- bail1:
+bail1:
for (i = 0; i < num; i++) {
if (surf->bos[i]) {
tbm_bo_unref(surf->bos[i]);
return NULL;
}
-void tbm_surface_internal_destroy(tbm_surface_h surface)
+void
+tbm_surface_internal_destroy(tbm_surface_h surface)
{
if (!surface)
return;
_tbm_surface_mutex_unlock();
}
-void tbm_surface_internal_ref(tbm_surface_h surface)
+void
+tbm_surface_internal_ref(tbm_surface_h surface)
{
TBM_RETURN_IF_FAIL(surface);
_tbm_surface_mutex_unlock();
}
-void tbm_surface_internal_unref(tbm_surface_h surface)
+void
+tbm_surface_internal_unref(tbm_surface_h surface)
{
TBM_RETURN_IF_FAIL(surface);
_tbm_surface_mutex_unlock();
}
-int tbm_surface_internal_get_num_bos(tbm_surface_h surface)
+int
+tbm_surface_internal_get_num_bos(tbm_surface_h surface)
{
TBM_RETURN_VAL_IF_FAIL(surface, 0);
return num;
}
-tbm_bo tbm_surface_internal_get_bo(tbm_surface_h surface, int bo_idx)
+tbm_bo
+tbm_surface_internal_get_bo(tbm_surface_h surface, int bo_idx)
{
TBM_RETURN_VAL_IF_FAIL(surface, NULL);
TBM_RETURN_VAL_IF_FAIL(bo_idx > -1, NULL);
return bo;
}
-int tbm_surface_internal_get_size(tbm_surface_h surface)
+int
+tbm_surface_internal_get_size(tbm_surface_h surface)
{
TBM_RETURN_VAL_IF_FAIL(surface, 0);
return size;
}
-int tbm_surface_internal_get_plane_data(tbm_surface_h surface, int plane_idx, uint32_t * size, uint32_t * offset, uint32_t * pitch)
+int
+tbm_surface_internal_get_plane_data(tbm_surface_h surface, int plane_idx,
+ uint32_t *size, uint32_t *offset, uint32_t *pitch)
{
TBM_RETURN_VAL_IF_FAIL(surface, 0);
TBM_RETURN_VAL_IF_FAIL(plane_idx > -1, 0);
return 1;
}
-int tbm_surface_internal_get_info(tbm_surface_h surface, int opt, tbm_surface_info_s * info, int map)
+int
+tbm_surface_internal_get_info(tbm_surface_h surface, int opt,
+ tbm_surface_info_s *info, int map)
{
struct _tbm_surface *surf;
tbm_bo_handle bo_handles[4];
surf = (struct _tbm_surface *)surface;
- memset(info, 0x00, sizeof (tbm_surface_info_s));
+ memset(info, 0x00, sizeof(tbm_surface_info_s));
info->width = surf->info.width;
info->height = surf->info.height;
info->format = surf->info.format;
}
}
} else {
- for (i = 0; i < surf->num_bos; i++) {
+ for (i = 0; i < surf->num_bos; i++)
bo_handles[i] = tbm_bo_get_handle(surf->bos[i], TBM_DEVICE_CPU);
- }
}
for (i = 0; i < surf->info.num_planes; i++) {
info->planes[i].stride = surf->info.planes[i].stride;
if (bo_handles[surf->planes_bo_idx[i]].ptr)
- info->planes[i].ptr = bo_handles[surf->planes_bo_idx[i]].ptr + surf->info.planes[i].offset;
+ info->planes[i].ptr = bo_handles[surf->planes_bo_idx[i]].ptr +
+ surf->info.planes[i].offset;
}
_tbm_surface_mutex_unlock();
return 1;
}
-void tbm_surface_internal_unmap(tbm_surface_h surface)
+void
+tbm_surface_internal_unmap(tbm_surface_h surface)
{
struct _tbm_surface *surf;
int i;
_tbm_surface_mutex_unlock();
}
-unsigned int tbm_surface_internal_get_width(tbm_surface_h surface)
+unsigned int
+tbm_surface_internal_get_width(tbm_surface_h surface)
{
struct _tbm_surface *surf;
unsigned int width;
return width;
}
-unsigned int tbm_surface_internal_get_height(tbm_surface_h surface)
+unsigned int
+tbm_surface_internal_get_height(tbm_surface_h surface)
{
struct _tbm_surface *surf;
unsigned int height;
}
-tbm_format tbm_surface_internal_get_format(tbm_surface_h surface)
+tbm_format
+tbm_surface_internal_get_format(tbm_surface_h surface)
{
struct _tbm_surface *surf;
tbm_format format;
return format;
}
-int tbm_surface_internal_get_plane_bo_idx(tbm_surface_h surface, int plane_idx)
+int
+tbm_surface_internal_get_plane_bo_idx(tbm_surface_h surface, int plane_idx)
{
TBM_RETURN_VAL_IF_FAIL(surface, 0);
TBM_RETURN_VAL_IF_FAIL(plane_idx > -1, 0);
return bo_idx;
}
-unsigned int _tbm_surface_internal_get_debug_pid(tbm_surface_h surface)
+unsigned int
+_tbm_surface_internal_get_debug_pid(tbm_surface_h surface)
{
TBM_RETURN_VAL_IF_FAIL(surface, 0);
return surface->debug_pid;
}
-void tbm_surface_internal_set_debug_pid(tbm_surface_h surface, unsigned int pid)
+void
+tbm_surface_internal_set_debug_pid(tbm_surface_h surface, unsigned int pid)
{
TBM_RETURN_IF_FAIL(surface);
surface->debug_pid = pid;
}
-int tbm_surface_internal_add_user_data(tbm_surface_h surface, unsigned long key, tbm_data_free data_free_func)
+int
+tbm_surface_internal_add_user_data(tbm_surface_h surface, unsigned long key,
+ tbm_data_free data_free_func)
{
TBM_RETURN_VAL_IF_FAIL(surface, 0);
if (data) {
TBM_LOG("[libtbm:%d] "
"waring: %s:%d user data already exist. key:%ld\n",
- getpid(), __FUNCTION__, __LINE__, key);
+ getpid(), __func__, __LINE__, key);
return 0;
}
return 1;
}
-int tbm_surface_internal_set_user_data(tbm_surface_h surface, unsigned long key, void *data)
+int
+tbm_surface_internal_set_user_data(tbm_surface_h surface, unsigned long key,
+ void *data)
{
TBM_RETURN_VAL_IF_FAIL(surface, 0);
return 1;
}
-int tbm_surface_internal_get_user_data(tbm_surface_h surface, unsigned long key, void **data)
+int
+tbm_surface_internal_get_user_data(tbm_surface_h surface, unsigned long key,
+ void **data)
{
TBM_RETURN_VAL_IF_FAIL(surface, 0);
return 1;
}
-int tbm_surface_internal_delete_user_data(tbm_surface_h surface, unsigned long key)
+int
+tbm_surface_internal_delete_user_data(tbm_surface_h surface,
+ unsigned long key)
{
TBM_RETURN_VAL_IF_FAIL(surface, 0);
tbm_surface_bufmgr_deinit (bufmgr);
@endcode
*/
-int tbm_surface_internal_query_supported_formats(uint32_t ** formats, uint32_t * num);
+int tbm_surface_internal_query_supported_formats(uint32_t **formats,
+ uint32_t *num);
/**
* @brief Creates the tbm_surface with memory type.
tbm_surface_bufmgr_deinit (bufmgr);
@endcode
*/
-tbm_surface_h tbm_surface_internal_create_with_flags(int width, int height, int format, int flags);
+tbm_surface_h tbm_surface_internal_create_with_flags(int width, int height,
+ int format, int flags);
/**
* @brief Creates the tbm_surface with buffer objects.
tbm_surface_bufmgr_deinit (bufmgr);
@endcode
*/
-tbm_surface_h tbm_surface_internal_create_with_bos(tbm_surface_info_s * info, tbm_bo * bos, int num);
+tbm_surface_h tbm_surface_internal_create_with_bos(tbm_surface_info_s *info,
+ tbm_bo *bos, int num);
/**
* @brief Destroy the tbm surface
tbm_surface_destroy (surface);
@endcode
*/
-int tbm_surface_internal_get_plane_data(tbm_surface_h surface, int plane_idx, uint32_t * size, uint32_t * offset, uint32_t * pitch);
+int tbm_surface_internal_get_plane_data(tbm_surface_h surface, int plane_idx,
+ uint32_t *size, uint32_t *offset, uint32_t *pitch);
/**
* @brief Gets number of planes by the format.
* @param[in] surface : the tbm_surface_h
* @param[in] pid : the pid
*/
-void tbm_surface_internal_set_debug_pid(tbm_surface_h surface, unsigned int pid);
+void tbm_surface_internal_set_debug_pid(tbm_surface_h surface,
+ unsigned int pid);
/**
* @brief Adds a user_data to the tbm surface.
* @see tbm_surface_get_user_data()
* @see tbm_surface_delete_user_data()
*/
-int tbm_surface_internal_add_user_data(tbm_surface_h surface, unsigned long key, tbm_data_free data_free_func);
+int tbm_surface_internal_add_user_data(tbm_surface_h surface, unsigned long key,
+ tbm_data_free data_free_func);
/**
* @brief Sets a user_date to the tbm surface.
* @param[in] data : a pointer of the user_data
* @return 1 if this function succeeds, otherwise 0.
*/
-int tbm_surface_internal_set_user_data(tbm_surface_h surface, unsigned long key, void *data);
+int tbm_surface_internal_set_user_data(tbm_surface_h surface, unsigned long key,
+ void *data);
/**
* @brief Gets a user_data from the tbm surface with the key.
* @param[out] data : to get the user data
* @return 1 if this function succeeds, otherwise 0.
*/
-int tbm_surface_internal_get_user_data(tbm_surface_h surface, unsigned long key, void **data);
+int tbm_surface_internal_get_user_data(tbm_surface_h surface, unsigned long key,
+ void **data);
/**
* @brief Deletes the user_data in the tbm surface.
* @param[in] key : the key associated with the user_date
* @return 1 if this function succeeds, otherwise 0.
*/
-int tbm_surface_internal_delete_user_data(tbm_surface_h surface, unsigned long key);
+int tbm_surface_internal_delete_user_data(tbm_surface_h surface,
+ unsigned long key);
#ifdef __cplusplus
}
#define DEBUG 0
#if DEBUG
-#define TBM_TRACE() TBM_LOG("[TRACE] %s:%d surface:%p\n", __FUNCTION__, __LINE__, surface_queue)
-#define TBM_LOCK() TBM_LOG("[LOCK] %s:%d surface:%p\n", __FUNCTION__, __LINE__, surface_queue)
-#define TBM_UNLOCK() TBM_LOG("[UNLOCK] %s:%d surface:%p\n", __FUNCTION__, __LINE__, surface_queue)
+#define TBM_TRACE() TBM_LOG("[TRACE] %s:%d surface:%p\n", __func__, __LINE__, surface_queue)
+#define TBM_LOCK() TBM_LOG("[LOCK] %s:%d surface:%p\n", __func__, __LINE__, surface_queue)
+#define TBM_UNLOCK() TBM_LOG("[UNLOCK] %s:%d surface:%p\n", __func__, __LINE__, surface_queue)
#else
#define TBM_TRACE()
#define TBM_LOCK()
void (*destroy)(tbm_surface_queue_h queue);
void (*need_attach)(tbm_surface_queue_h queue);
- void (*enqueue)(tbm_surface_queue_h queue, queue_node* node);
- void (*release)(tbm_surface_queue_h queue, queue_node* node);
- queue_node* (*dequeue)(tbm_surface_queue_h queue);
- queue_node* (*acquire)(tbm_surface_queue_h queue);
-}tbm_surface_queue_interface;
+ void (*enqueue)(tbm_surface_queue_h queue, queue_node *node);
+ void (*release)(tbm_surface_queue_h queue, queue_node *node);
+ queue_node *(*dequeue)(tbm_surface_queue_h queue);
+ queue_node *(*acquire)(tbm_surface_queue_h queue);
+} tbm_surface_queue_interface;
struct _tbm_surface_queue {
int width;
void *impl_data;
};
-static queue_node *_queue_node_create(void)
+static queue_node *
+_queue_node_create(void)
{
queue_node *node = (queue_node *) calloc(1, sizeof(queue_node));
+
TBM_RETURN_VAL_IF_FAIL(node != NULL, NULL);
return node;
}
-static void _queue_node_delete(queue_node * node)
+static void
+_queue_node_delete(queue_node *node)
{
if (node->surface)
tbm_surface_destroy(node->surface);
free(node);
}
-static int _queue_is_empty(queue * queue)
+static int
+_queue_is_empty(queue *queue)
{
if (queue->head.next == &queue->tail)
return 1;
return 0;
}
-static void _queue_node_push_back(queue * queue, queue_node * node)
+static void
+_queue_node_push_back(queue *queue, queue_node *node)
{
LIST_ADDTAIL(&node->item_link, &queue->tail);
queue->count++;
- return;
}
-static void _queue_node_push_front(queue * queue, queue_node * node)
+static void
+_queue_node_push_front(queue *queue, queue_node *node)
{
LIST_ADD(&node->item_link, &queue->head);
queue->count++;
- return;
}
-static queue_node *_queue_node_pop_front(queue * queue)
+static queue_node *
+_queue_node_pop_front(queue *queue)
{
queue_node *node = NULL;
return node;
}
-static queue_node *_queue_node_pop(queue * queue, queue_node* node)
+static queue_node *
+_queue_node_pop(queue *queue, queue_node *node)
{
LIST_DEL(&node->item_link);
queue->count--;
return node;
}
-static queue_node* _queue_get_node(tbm_surface_queue_h surface_queue, int type, tbm_surface_h surface, int *out_type)
+static queue_node *
+_queue_get_node(tbm_surface_queue_h surface_queue, int type,
+ tbm_surface_h surface, int *out_type)
{
queue_node *node = NULL;
queue_node *tmp = NULL;
if (out_type)
*out_type = 0;
- if (type & FREE_QUEUE)
- {
- LIST_FOR_EACH_ENTRY_SAFE(node, tmp, &surface_queue->free_queue.head, item_link) {
- if (node->surface == surface)
- {
- if (out_type) *out_type = FREE_QUEUE;
+ if (type & FREE_QUEUE) {
+ LIST_FOR_EACH_ENTRY_SAFE(node, tmp, &surface_queue->free_queue.head,
+ item_link) {
+ if (node->surface == surface) {
+ if (out_type)
+ *out_type = FREE_QUEUE;
+
return node;
}
}
}
- if (type & DIRTY_QUEUE)
- {
- LIST_FOR_EACH_ENTRY_SAFE(node, tmp, &surface_queue->dirty_queue.head, item_link) {
- if (node->surface == surface)
- {
- if (out_type) *out_type = DIRTY_QUEUE;
+ if (type & DIRTY_QUEUE) {
+ LIST_FOR_EACH_ENTRY_SAFE(node, tmp, &surface_queue->dirty_queue.head,
+ item_link) {
+ if (node->surface == surface) {
+ if (out_type)
+ *out_type = DIRTY_QUEUE;
+
return node;
}
}
}
- if (type & NODE_LIST)
- {
+ if (type & NODE_LIST) {
LIST_FOR_EACH_ENTRY_SAFE(node, tmp, &surface_queue->list, link) {
- if (node->surface == surface)
- {
- if (out_type) *out_type = NODE_LIST;
+ if (node->surface == surface) {
+ if (out_type)
+ *out_type = NODE_LIST;
+
return node;
}
}
return NULL;
}
-static void _queue_init(queue * queue)
+static void
+_queue_init(queue *queue)
{
LIST_INITHEAD(&queue->head);
LIST_INITHEAD(&queue->tail);
queue->count = 0;
}
-static void _notify_add(struct list_head *list, tbm_surface_queue_notify_cb cb, void* data)
+static void
+_notify_add(struct list_head *list, tbm_surface_queue_notify_cb cb,
+ void *data)
{
TBM_RETURN_IF_FAIL(cb != NULL);
- queue_notify *item = (queue_notify*)calloc(1, sizeof(queue_notify));
+ queue_notify *item = (queue_notify *)calloc(1, sizeof(queue_notify));
+
TBM_RETURN_IF_FAIL(item != NULL);
LIST_INITHEAD(&item->link);
LIST_ADDTAIL(&item->link, list);
}
-static void _notify_remove(struct list_head *list, tbm_surface_queue_notify_cb cb, void* data)
+static void
+_notify_remove(struct list_head *list,
+ tbm_surface_queue_notify_cb cb, void *data)
{
queue_notify *item = NULL, *tmp = NULL;
TBM_LOG("Cannot find notifiy\n");
}
-static void _notify_remove_all(struct list_head *list)
+static void
+_notify_remove_all(struct list_head *list)
{
queue_notify *item = NULL, *tmp = NULL;
}
}
-static void _notify_emit(tbm_surface_queue_h surface_queue, struct list_head *list)
+static void
+_notify_emit(tbm_surface_queue_h surface_queue,
+ struct list_head *list)
{
queue_notify *item = NULL, *tmp = NULL;
}
}
-void _tbm_surface_queue_attach(tbm_surface_queue_h surface_queue, tbm_surface_h surface)
+void
+_tbm_surface_queue_attach(tbm_surface_queue_h surface_queue,
+ tbm_surface_h surface)
{
queue_node *node = NULL;
_queue_node_push_back(&surface_queue->free_queue, node);
}
-void _tbm_surface_queue_detach(tbm_surface_queue_h surface_queue, tbm_surface_h surface)
+void
+_tbm_surface_queue_detach(tbm_surface_queue_h surface_queue,
+ tbm_surface_h surface)
{
queue_node *node = NULL;
int queue_type;
_queue_node_delete(node);
}
-void _tbm_surface_queue_enqueue(tbm_surface_queue_h surface_queue, queue_node* node, int push_back)
+void
+_tbm_surface_queue_enqueue(tbm_surface_queue_h surface_queue,
+ queue_node *node, int push_back)
{
if (push_back)
_queue_node_push_back(&surface_queue->dirty_queue, node);
_queue_node_push_front(&surface_queue->dirty_queue, node);
}
-queue_node* _tbm_surface_queue_dequeue(tbm_surface_queue_h surface_queue)
+queue_node *
+_tbm_surface_queue_dequeue(tbm_surface_queue_h surface_queue)
{
queue_node *node = NULL;
if (surface_queue->impl && surface_queue->impl->need_attach)
surface_queue->impl->need_attach(surface_queue);
- if (_queue_is_empty(&surface_queue->free_queue)) {
+ if (_queue_is_empty(&surface_queue->free_queue))
return NULL;
- }
}
node = _queue_node_pop_front(&surface_queue->free_queue);
return node;
}
-queue_node* _tbm_surface_queue_acquire(tbm_surface_queue_h surface_queue)
+queue_node *
+_tbm_surface_queue_acquire(tbm_surface_queue_h surface_queue)
{
queue_node *node = NULL;
- if (_queue_is_empty(&surface_queue->dirty_queue)) {
+ if (_queue_is_empty(&surface_queue->dirty_queue))
return NULL;
- }
node = _queue_node_pop_front(&surface_queue->dirty_queue);
return node;
}
-void _tbm_surface_queue_release(tbm_surface_queue_h surface_queue, queue_node* node, int push_back)
+void
+_tbm_surface_queue_release(tbm_surface_queue_h surface_queue,
+ queue_node *node, int push_back)
{
if (push_back)
_queue_node_push_back(&surface_queue->free_queue, node);
_queue_node_push_front(&surface_queue->free_queue, node);
}
-void _tbm_surface_queue_init(tbm_surface_queue_h surface_queue,
- int width, int height, int format,
- const tbm_surface_queue_interface* impl, void *data)
+void
+_tbm_surface_queue_init(tbm_surface_queue_h surface_queue,
+ int width, int height, int format,
+ const tbm_surface_queue_interface *impl, void *data)
{
TBM_RETURN_IF_FAIL(surface_queue != NULL);
TBM_RETURN_IF_FAIL(impl != NULL);
surface_queue->impl->init(surface_queue);
}
-tbm_surface_queue_error_e tbm_surface_queue_set_destroy_cb(tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb destroy_cb, void *data)
+tbm_surface_queue_error_e
+tbm_surface_queue_set_destroy_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb destroy_cb,
+ void *data)
{
- TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL, TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
+ TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL,
+ TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
pthread_mutex_lock(&surface_queue->lock);
return TBM_SURFACE_QUEUE_ERROR_NONE;
}
-tbm_surface_queue_error_e tbm_surface_queue_add_destroy_cb(tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb destroy_cb, void *data)
+tbm_surface_queue_error_e
+tbm_surface_queue_add_destroy_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb destroy_cb,
+ void *data)
{
- TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL, TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
+ TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL,
+ TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
pthread_mutex_lock(&surface_queue->lock);
return TBM_SURFACE_QUEUE_ERROR_NONE;
}
-tbm_surface_queue_error_e tbm_surface_queue_remove_destroy_cb(tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb destroy_cb, void *data)
+tbm_surface_queue_error_e
+tbm_surface_queue_remove_destroy_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb destroy_cb,
+ void *data)
{
- TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL, TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
+ TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL,
+ TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
pthread_mutex_lock(&surface_queue->lock);
return TBM_SURFACE_QUEUE_ERROR_NONE;
}
-tbm_surface_queue_error_e tbm_surface_queue_set_dequeuable_cb(tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb dequeuable_cb, void *data)
+tbm_surface_queue_error_e
+tbm_surface_queue_set_dequeuable_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb dequeuable_cb,
+ void *data)
{
- TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL, TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
+ TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL,
+ TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
pthread_mutex_lock(&surface_queue->lock);
return TBM_SURFACE_QUEUE_ERROR_NONE;
}
-tbm_surface_queue_error_e tbm_surface_queue_add_dequeuable_cb(tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb dequeuable_cb, void *data)
+tbm_surface_queue_error_e
+tbm_surface_queue_add_dequeuable_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb dequeuable_cb,
+ void *data)
{
- TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL, TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
+ TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL,
+ TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
pthread_mutex_lock(&surface_queue->lock);
return TBM_SURFACE_QUEUE_ERROR_NONE;
}
-tbm_surface_queue_error_e tbm_surface_queue_remove_dequeuable_cb(tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb dequeuable_cb, void *data)
+tbm_surface_queue_error_e
+tbm_surface_queue_remove_dequeuable_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb dequeuable_cb,
+ void *data)
{
- TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL, TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
+ TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL,
+ TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
pthread_mutex_lock(&surface_queue->lock);
return TBM_SURFACE_QUEUE_ERROR_NONE;
}
-tbm_surface_queue_error_e tbm_surface_queue_set_acquirable_cb(tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb acquirable_cb, void *data)
+tbm_surface_queue_error_e
+tbm_surface_queue_set_acquirable_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb acquirable_cb,
+ void *data)
{
- TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL, TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
+ TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL,
+ TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
pthread_mutex_lock(&surface_queue->lock);
return TBM_SURFACE_QUEUE_ERROR_NONE;
}
-tbm_surface_queue_error_e tbm_surface_queue_add_acquirable_cb(tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb acquirable_cb, void *data)
+tbm_surface_queue_error_e
+tbm_surface_queue_add_acquirable_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb acquirable_cb,
+ void *data)
{
- TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL, TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
+ TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL,
+ TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
pthread_mutex_lock(&surface_queue->lock);
return TBM_SURFACE_QUEUE_ERROR_NONE;
}
-tbm_surface_queue_error_e tbm_surface_queue_remove_acquirable_cb(tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb acquirable_cb, void *data)
+tbm_surface_queue_error_e
+tbm_surface_queue_remove_acquirable_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb acquirable_cb,
+ void *data)
{
- TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL, TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
+ TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL,
+ TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
pthread_mutex_lock(&surface_queue->lock);
return TBM_SURFACE_QUEUE_ERROR_NONE;
}
-int tbm_surface_queue_get_width(tbm_surface_queue_h surface_queue)
+int
+tbm_surface_queue_get_width(tbm_surface_queue_h surface_queue)
{
TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL, 0);
return surface_queue->width;
}
-int tbm_surface_queue_get_height(tbm_surface_queue_h surface_queue)
+int
+tbm_surface_queue_get_height(tbm_surface_queue_h surface_queue)
{
return surface_queue->height;
}
-int tbm_surface_queue_get_format(tbm_surface_queue_h surface_queue)
+int
+tbm_surface_queue_get_format(tbm_surface_queue_h surface_queue)
{
return surface_queue->format;
}
-tbm_surface_queue_error_e tbm_surface_queue_set_reset_cb(tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb reset_cb, void *data)
+tbm_surface_queue_error_e
+tbm_surface_queue_set_reset_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb reset_cb,
+ void *data)
{
- TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL, TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
+ TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL,
+ TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
pthread_mutex_lock(&surface_queue->lock);
return TBM_SURFACE_QUEUE_ERROR_NONE;
}
-tbm_surface_queue_error_e tbm_surface_queue_add_reset_cb(tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb reset_cb, void *data)
+tbm_surface_queue_error_e
+tbm_surface_queue_add_reset_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb reset_cb,
+ void *data)
{
- TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL, TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
+ TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL,
+ TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
pthread_mutex_lock(&surface_queue->lock);
return TBM_SURFACE_QUEUE_ERROR_NONE;
}
-tbm_surface_queue_error_e tbm_surface_queue_remove_reset_cb(tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb reset_cb, void *data)
+tbm_surface_queue_error_e
+tbm_surface_queue_remove_reset_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb reset_cb,
+ void *data)
{
- TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL, TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
+ TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL,
+ TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
pthread_mutex_lock(&surface_queue->lock);
return TBM_SURFACE_QUEUE_ERROR_NONE;
}
-tbm_surface_queue_error_e tbm_surface_queue_enqueue(tbm_surface_queue_h surface_queue, tbm_surface_h surface)
+tbm_surface_queue_error_e
+tbm_surface_queue_enqueue(tbm_surface_queue_h
+ surface_queue, tbm_surface_h surface)
{
queue_node *node = NULL;
int queue_type;
- TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL, TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
- TBM_RETURN_VAL_IF_FAIL(surface != NULL, TBM_SURFACE_QUEUE_ERROR_INVALID_SURFACE);
+ TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL,
+ TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
+ TBM_RETURN_VAL_IF_FAIL(surface != NULL,
+ TBM_SURFACE_QUEUE_ERROR_INVALID_SURFACE);
pthread_mutex_lock(&surface_queue->lock);
node = _queue_get_node(surface_queue, 0, surface, &queue_type);
- if (node == NULL || queue_type != NODE_LIST)
- {
- TBM_LOG("tbm_surface_queue_enqueue::Surface exist in free_queue or dirty_queue node:%p, queue:%d\n", node, queue_type);
+ if (node == NULL || queue_type != NODE_LIST) {
+ TBM_LOG("tbm_surface_queue_enqueue::Surface exist in free_queue or dirty_queue node:%p, queue:%d\n",
+ node, queue_type);
pthread_mutex_unlock(&surface_queue->lock);
return TBM_SURFACE_QUEUE_ERROR_INVALID_SURFACE;
}
return TBM_SURFACE_QUEUE_ERROR_NONE;
}
-tbm_surface_queue_error_e tbm_surface_queue_dequeue(tbm_surface_queue_h surface_queue, tbm_surface_h * surface)
+tbm_surface_queue_error_e
+tbm_surface_queue_dequeue(tbm_surface_queue_h
+ surface_queue, tbm_surface_h *surface)
{
queue_node *node = NULL;
- TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL, TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
- TBM_RETURN_VAL_IF_FAIL(surface != NULL, TBM_SURFACE_QUEUE_ERROR_INVALID_SURFACE);
+ TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL,
+ TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
+ TBM_RETURN_VAL_IF_FAIL(surface != NULL,
+ TBM_SURFACE_QUEUE_ERROR_INVALID_SURFACE);
pthread_mutex_lock(&surface_queue->lock);
return TBM_SURFACE_QUEUE_ERROR_NONE;
}
-int tbm_surface_queue_can_dequeue(tbm_surface_queue_h surface_queue, int wait)
+int
+tbm_surface_queue_can_dequeue(tbm_surface_queue_h surface_queue, int wait)
{
TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL, 0);
return 1;
}
-tbm_surface_queue_error_e tbm_surface_queue_release(tbm_surface_queue_h surface_queue, tbm_surface_h surface)
+tbm_surface_queue_error_e
+tbm_surface_queue_release(tbm_surface_queue_h
+ surface_queue, tbm_surface_h surface)
{
queue_node *node = NULL;
int queue_type;
- TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL, TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
- TBM_RETURN_VAL_IF_FAIL(surface != NULL, TBM_SURFACE_QUEUE_ERROR_INVALID_SURFACE);
+ TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL,
+ TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
+ TBM_RETURN_VAL_IF_FAIL(surface != NULL,
+ TBM_SURFACE_QUEUE_ERROR_INVALID_SURFACE);
pthread_mutex_lock(&surface_queue->lock);
node = _queue_get_node(surface_queue, 0, surface, &queue_type);
- if (node == NULL || queue_type != NODE_LIST)
- {
- TBM_LOG("tbm_surface_queue_release::Surface exist in free_queue or dirty_queue node:%p, queue:%d\n", node, queue_type);
+ if (node == NULL || queue_type != NODE_LIST) {
+ TBM_LOG("tbm_surface_queue_release::Surface exist in free_queue or dirty_queue node:%p, queue:%d\n",
+ node, queue_type);
pthread_mutex_unlock(&surface_queue->lock);
return TBM_SURFACE_QUEUE_ERROR_INVALID_SURFACE;
}
return TBM_SURFACE_QUEUE_ERROR_NONE;
}
-tbm_surface_queue_error_e tbm_surface_queue_acquire(tbm_surface_queue_h surface_queue, tbm_surface_h * surface)
+tbm_surface_queue_error_e
+tbm_surface_queue_acquire(tbm_surface_queue_h
+ surface_queue, tbm_surface_h *surface)
{
queue_node *node = NULL;
- TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL, TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
- TBM_RETURN_VAL_IF_FAIL(surface != NULL, TBM_SURFACE_QUEUE_ERROR_INVALID_SURFACE);
+ TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL,
+ TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
+ TBM_RETURN_VAL_IF_FAIL(surface != NULL,
+ TBM_SURFACE_QUEUE_ERROR_INVALID_SURFACE);
pthread_mutex_lock(&surface_queue->lock);
return TBM_SURFACE_QUEUE_ERROR_NONE;
}
-int tbm_surface_queue_can_acquire(tbm_surface_queue_h surface_queue, int wait)
+int
+tbm_surface_queue_can_acquire(tbm_surface_queue_h surface_queue, int wait)
{
TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL, 0);
return 1;
}
-void tbm_surface_queue_destroy(tbm_surface_queue_h surface_queue)
+void
+tbm_surface_queue_destroy(tbm_surface_queue_h surface_queue)
{
queue_node *node = NULL, *tmp = NULL;
free(surface_queue);
}
-tbm_surface_queue_error_e tbm_surface_queue_reset(tbm_surface_queue_h surface_queue, int width, int height, int format)
+tbm_surface_queue_error_e
+tbm_surface_queue_reset(tbm_surface_queue_h
+ surface_queue, int width, int height, int format)
{
- TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL, TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
+ TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL,
+ TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
queue_node *node = NULL, *tmp = NULL;
- if (width == surface_queue->width && height == surface_queue->height && format == surface_queue->format)
+ if (width == surface_queue->width && height == surface_queue->height &&
+ format == surface_queue->format)
return TBM_SURFACE_QUEUE_ERROR_NONE;
pthread_mutex_lock(&surface_queue->lock);
surface_queue->format = format;
/* Destory surface and Push to free_queue */
- LIST_FOR_EACH_ENTRY_SAFE(node, tmp, &surface_queue->list, link)
- {
+ LIST_FOR_EACH_ENTRY_SAFE(node, tmp, &surface_queue->list, link) {
_queue_node_delete(node);
}
return TBM_SURFACE_QUEUE_ERROR_NONE;
}
-typedef struct
-{
+typedef struct {
int queue_size;
int num_attached;
int flags;
-}tbm_queue_default;
+} tbm_queue_default;
-static void __tbm_queue_default_init(tbm_surface_queue_h surface_queue)
+static void
+__tbm_queue_default_init(tbm_surface_queue_h surface_queue)
{
- tbm_queue_default* data = surface_queue->impl_data;
+ tbm_queue_default *data = surface_queue->impl_data;
+
data->num_attached = 0;
}
-static void __tbm_queue_default_reset(tbm_surface_queue_h surface_queue)
+static void
+__tbm_queue_default_reset(tbm_surface_queue_h surface_queue)
{
- tbm_queue_default* data = surface_queue->impl_data;
+ tbm_queue_default *data = surface_queue->impl_data;
+
data->num_attached = 0;
}
-static void __tbm_queue_default_destroy(tbm_surface_queue_h surface_queue)
+static void
+__tbm_queue_default_destroy(tbm_surface_queue_h surface_queue)
{
free(surface_queue->impl_data);
}
-static void __tbm_queue_default_need_attach(tbm_surface_queue_h surface_queue)
+static void
+__tbm_queue_default_need_attach(tbm_surface_queue_h surface_queue)
{
- tbm_queue_default* data = surface_queue->impl_data;
+ tbm_queue_default *data = surface_queue->impl_data;
tbm_surface_h surface;
if (data->queue_size == data->num_attached)
return;
surface = tbm_surface_internal_create_with_flags(surface_queue->width,
- surface_queue->height,
- surface_queue->format,
- data->flags);
+ surface_queue->height,
+ surface_queue->format,
+ data->flags);
TBM_RETURN_IF_FAIL(surface != NULL);
_tbm_surface_queue_attach(surface_queue, surface);
tbm_surface_internal_unref(surface);
data->num_attached++;
}
-static const tbm_surface_queue_interface tbm_queue_default_impl =
-{
+static const tbm_surface_queue_interface tbm_queue_default_impl = {
__tbm_queue_default_init,
__tbm_queue_default_reset,
__tbm_queue_default_destroy,
__tbm_queue_default_need_attach,
- NULL, /*__tbm_queue_default_enqueue*/
- NULL, /*__tbm_queue_default_release*/
- NULL, /*__tbm_queue_default_dequeue*/
+ NULL, /*__tbm_queue_default_enqueue*/
+ NULL, /*__tbm_queue_default_release*/
+ NULL, /*__tbm_queue_default_dequeue*/
NULL, /*__tbm_queue_default_acquire*/
};
-tbm_surface_queue_h tbm_surface_queue_create(int queue_size, int width, int height, int format, int flags)
+tbm_surface_queue_h
+tbm_surface_queue_create(int queue_size, int width,
+ int height, int format, int flags)
{
TBM_RETURN_VAL_IF_FAIL(queue_size > 0, NULL);
TBM_RETURN_VAL_IF_FAIL(width > 0, NULL);
TBM_RETURN_VAL_IF_FAIL(height > 0, NULL);
TBM_RETURN_VAL_IF_FAIL(format > 0, NULL);
- tbm_surface_queue_h surface_queue = (tbm_surface_queue_h) calloc(1, sizeof(struct _tbm_surface_queue));
+ tbm_surface_queue_h surface_queue = (tbm_surface_queue_h) calloc(1,
+ sizeof(struct _tbm_surface_queue));
TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL, NULL);
- tbm_queue_default *data = (tbm_queue_default *) calloc(1, sizeof(tbm_queue_default));
- if (data == NULL)
- {
+ tbm_queue_default *data = (tbm_queue_default *) calloc(1,
+ sizeof(tbm_queue_default));
+ if (data == NULL) {
free(surface_queue);
return NULL;
}
data->queue_size = queue_size;
data->flags = flags;
_tbm_surface_queue_init(surface_queue,
- width, height, format,
- &tbm_queue_default_impl, data);
+ width, height, format,
+ &tbm_queue_default_impl, data);
return surface_queue;
}
-typedef struct
-{
+typedef struct {
int queue_size;
int num_attached;
int flags;
queue dequeue_list;
-}tbm_queue_sequence;
+} tbm_queue_sequence;
-static void __tbm_queue_sequence_init(tbm_surface_queue_h surface_queue)
+static void
+__tbm_queue_sequence_init(tbm_surface_queue_h surface_queue)
{
- tbm_queue_sequence* data = surface_queue->impl_data;
+ tbm_queue_sequence *data = surface_queue->impl_data;
data->num_attached = 0;
_queue_init(&data->dequeue_list);
}
-static void __tbm_queue_sequence_reset(tbm_surface_queue_h surface_queue)
+static void
+__tbm_queue_sequence_reset(tbm_surface_queue_h surface_queue)
{
- tbm_queue_sequence* data = surface_queue->impl_data;
+ tbm_queue_sequence *data = surface_queue->impl_data;
data->num_attached = 0;
_queue_init(&data->dequeue_list);
}
-static void __tbm_queue_sequence_destroy(tbm_surface_queue_h surface_queue)
+static void
+__tbm_queue_sequence_destroy(tbm_surface_queue_h surface_queue)
{
free(surface_queue->impl_data);
}
-static void __tbm_queue_sequence_need_attach(tbm_surface_queue_h surface_queue)
+static void
+__tbm_queue_sequence_need_attach(tbm_surface_queue_h surface_queue)
{
- tbm_queue_sequence* data = surface_queue->impl_data;
+ tbm_queue_sequence *data = surface_queue->impl_data;
tbm_surface_h surface;
if (data->queue_size == data->num_attached)
return;
surface = tbm_surface_internal_create_with_flags(surface_queue->width,
- surface_queue->height,
- surface_queue->format,
- data->flags);
+ surface_queue->height,
+ surface_queue->format,
+ data->flags);
TBM_RETURN_IF_FAIL(surface != NULL);
_tbm_surface_queue_attach(surface_queue, surface);
tbm_surface_internal_unref(surface);
data->num_attached++;
}
-static void __tbm_queue_sequence_enqueue(tbm_surface_queue_h surface_queue, queue_node* node)
+static void
+__tbm_queue_sequence_enqueue(tbm_surface_queue_h surface_queue,
+ queue_node *node)
{
- tbm_queue_sequence* data = surface_queue->impl_data;
+ tbm_queue_sequence *data = surface_queue->impl_data;
queue_node *next = NULL;
queue_node *tmp = NULL;
node->priv_flags = 0;
LIST_FOR_EACH_ENTRY_SAFE(next, tmp, &data->dequeue_list.head, item_link) {
- if (next->priv_flags) break;
- _queue_node_pop(&data->dequeue_list, next);
+ if (next->priv_flags)
+ break;
+ _queue_node_pop(&data->dequeue_list, next);
_tbm_surface_queue_enqueue(surface_queue, next, 1);
}
}
-static queue_node* __tbm_queue_sequence_dequeue(tbm_surface_queue_h surface_queue)
+static queue_node *
+__tbm_queue_sequence_dequeue(tbm_surface_queue_h
+ surface_queue)
{
- tbm_queue_sequence* data = surface_queue->impl_data;
- queue_node* node = NULL;
+ tbm_queue_sequence *data = surface_queue->impl_data;
+ queue_node *node = NULL;
node = _tbm_surface_queue_dequeue(surface_queue);
- if (node)
- {
+ if (node) {
_queue_node_push_back(&data->dequeue_list, node);
node->priv_flags = 1;
}
return node;
}
-static const tbm_surface_queue_interface tbm_queue_sequence_impl =
-{
+static const tbm_surface_queue_interface tbm_queue_sequence_impl = {
__tbm_queue_sequence_init,
__tbm_queue_sequence_reset,
__tbm_queue_sequence_destroy,
__tbm_queue_sequence_need_attach,
__tbm_queue_sequence_enqueue,
- NULL, /*__tbm_queue_sequence_release*/
+ NULL, /*__tbm_queue_sequence_release*/
__tbm_queue_sequence_dequeue,
- NULL, /*__tbm_queue_sequence_acquire*/
+ NULL, /*__tbm_queue_sequence_acquire*/
};
-tbm_surface_queue_h tbm_surface_queue_sequence_create(int queue_size, int width, int height, int format, int flags)
+tbm_surface_queue_h
+tbm_surface_queue_sequence_create(int queue_size, int width,
+ int height, int format, int flags)
{
TBM_RETURN_VAL_IF_FAIL(queue_size > 0, NULL);
TBM_RETURN_VAL_IF_FAIL(width > 0, NULL);
TBM_RETURN_VAL_IF_FAIL(height > 0, NULL);
TBM_RETURN_VAL_IF_FAIL(format > 0, NULL);
- tbm_surface_queue_h surface_queue = (tbm_surface_queue_h) calloc(1, sizeof(struct _tbm_surface_queue));
+ tbm_surface_queue_h surface_queue = (tbm_surface_queue_h) calloc(1,
+ sizeof(struct _tbm_surface_queue));
TBM_RETURN_VAL_IF_FAIL(surface_queue != NULL, NULL);
- tbm_queue_sequence *data = (tbm_queue_sequence *) calloc(1, sizeof(tbm_queue_sequence));
- if (data == NULL)
- {
+ tbm_queue_sequence *data = (tbm_queue_sequence *) calloc(1,
+ sizeof(tbm_queue_sequence));
+ if (data == NULL) {
free(surface_queue);
return NULL;
}
data->queue_size = queue_size;
data->flags = flags;
_tbm_surface_queue_init(surface_queue,
- width, height, format,
- &tbm_queue_sequence_impl, data);
+ width, height, format,
+ &tbm_queue_sequence_impl, data);
return surface_queue;
}
typedef struct _tbm_surface_queue *tbm_surface_queue_h;
-typedef void (*tbm_surface_queue_notify_cb) (tbm_surface_queue_h surface_queue, void *data);
+typedef void (*tbm_surface_queue_notify_cb) (tbm_surface_queue_h surface_queue,
+ void *data);
#ifdef __cplusplus
extern "C" {
#endif
-tbm_surface_queue_error_e tbm_surface_queue_enqueue(tbm_surface_queue_h surface_queue, tbm_surface_h surface);
+tbm_surface_queue_error_e tbm_surface_queue_enqueue(
+ tbm_surface_queue_h surface_queue, tbm_surface_h surface);
-tbm_surface_queue_error_e tbm_surface_queue_dequeue(tbm_surface_queue_h surface_queue, tbm_surface_h * surface);
+tbm_surface_queue_error_e tbm_surface_queue_dequeue(
+ tbm_surface_queue_h surface_queue, tbm_surface_h *surface);
-tbm_surface_queue_error_e tbm_surface_queue_release(tbm_surface_queue_h surface_queue, tbm_surface_h surface);
+tbm_surface_queue_error_e tbm_surface_queue_release(
+ tbm_surface_queue_h surface_queue, tbm_surface_h surface);
-tbm_surface_queue_error_e tbm_surface_queue_acquire(tbm_surface_queue_h surface_queue, tbm_surface_h * surface);
+tbm_surface_queue_error_e tbm_surface_queue_acquire(
+ tbm_surface_queue_h surface_queue, tbm_surface_h *surface);
int tbm_surface_queue_can_dequeue(tbm_surface_queue_h surface_queue, int wait);
int tbm_surface_queue_get_format(tbm_surface_queue_h surface_queue);
-tbm_surface_queue_error_e tbm_surface_queue_reset(tbm_surface_queue_h surface_queue, int width, int height, int format);
+tbm_surface_queue_error_e tbm_surface_queue_reset(
+ tbm_surface_queue_h surface_queue, int width, int height, int format);
-tbm_surface_queue_error_e tbm_surface_queue_add_reset_cb(tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb reset_cb, void *data);
+tbm_surface_queue_error_e tbm_surface_queue_add_reset_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb reset_cb,
+ void *data);
-tbm_surface_queue_error_e tbm_surface_queue_remove_reset_cb(tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb reset_cb, void *data);
+tbm_surface_queue_error_e tbm_surface_queue_remove_reset_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb reset_cb,
+ void *data);
-tbm_surface_queue_error_e tbm_surface_queue_add_destroy_cb(tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb destroy_cb, void *data);
+tbm_surface_queue_error_e tbm_surface_queue_add_destroy_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb destroy_cb,
+ void *data);
-tbm_surface_queue_error_e tbm_surface_queue_remove_destroy_cb(tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb destroy_cb, void *data);
+tbm_surface_queue_error_e tbm_surface_queue_remove_destroy_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb destroy_cb,
+ void *data);
-tbm_surface_queue_error_e tbm_surface_queue_add_dequeuable_cb(tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb dequeuable_cb, void *data);
+tbm_surface_queue_error_e tbm_surface_queue_add_dequeuable_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb dequeuable_cb,
+ void *data);
-tbm_surface_queue_error_e tbm_surface_queue_remove_dequeuable_cb(tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb dequeuable_cb, void *data);
+tbm_surface_queue_error_e tbm_surface_queue_remove_dequeuable_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb dequeuable_cb,
+ void *data);
-tbm_surface_queue_error_e tbm_surface_queue_add_acquirable_cb(tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb acquirable_cb, void *data);
+tbm_surface_queue_error_e tbm_surface_queue_add_acquirable_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb acquirable_cb,
+ void *data);
-tbm_surface_queue_error_e tbm_surface_queue_remove_acquirable_cb(tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb acquirable_cb, void *data);
+tbm_surface_queue_error_e tbm_surface_queue_remove_acquirable_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb acquirable_cb,
+ void *data);
/*The functions of queue factory*/
-tbm_surface_queue_h tbm_surface_queue_create(int queue_size, int width, int height, int format, int flags);
-tbm_surface_queue_h tbm_surface_queue_sequence_create(int queue_size, int width, int height, int format, int flags);
+tbm_surface_queue_h tbm_surface_queue_create(int queue_size, int width,
+ int height, int format, int flags);
+tbm_surface_queue_h tbm_surface_queue_sequence_create(int queue_size, int width,
+ int height, int format, int flags);
/*DEPRECATED apis*/
-tbm_surface_queue_error_e tbm_surface_queue_set_destroy_cb(tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb destroy_cb, void *data);
+tbm_surface_queue_error_e tbm_surface_queue_set_destroy_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb destroy_cb,
+ void *data);
-tbm_surface_queue_error_e tbm_surface_queue_set_dequeuable_cb(tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb dequeuable_cb, void *data);
+tbm_surface_queue_error_e tbm_surface_queue_set_dequeuable_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb dequeuable_cb,
+ void *data);
-tbm_surface_queue_error_e tbm_surface_queue_set_acquirable_cb(tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb acquirable_cb, void *data);
+tbm_surface_queue_error_e tbm_surface_queue_set_acquirable_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb acquirable_cb,
+ void *data);
-tbm_surface_queue_error_e tbm_surface_queue_set_reset_cb(tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb reset_cb, void *data);
+tbm_surface_queue_error_e tbm_surface_queue_set_reset_cb(
+ tbm_surface_queue_h surface_queue, tbm_surface_queue_notify_cb reset_cb,
+ void *data);
#ifdef __cplusplus
}
#endif