change the log macro at all files 91/171891/3
authorSooChan Lim <sc1.lim@samsung.com>
Thu, 8 Mar 2018 03:49:11 +0000 (12:49 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Thu, 8 Mar 2018 05:44:25 +0000 (14:44 +0900)
add tbm_log.c and libtbm_log.h files
change the log macros and use them.

Change-Id: Ib432447a1daa5f2d5b0c2c242e4eaec6a4082031

17 files changed:
packaging/libtbm.spec
src/Makefile.am
src/tbm_bo.c
src/tbm_bufmgr.c
src/tbm_bufmgr_backend.c
src/tbm_bufmgr_int.h
src/tbm_drm_helper_client.c
src/tbm_drm_helper_server.c
src/tbm_log.c [new file with mode: 0644]
src/tbm_log.h [new file with mode: 0644]
src/tbm_surface.c
src/tbm_surface_internal.c
src/tbm_surface_queue.c
src/tbm_sync.c
src/tbm_type_int.h
utests/Makefile.am
utests/ut_tbm.h

index 467b51c976a8e9a23cadb3b10e79702e023627d3..2db19783e532ab517f2bbb56396b14c605a6fa9a 100644 (file)
@@ -114,6 +114,7 @@ rm -f %{_unitdir_user}/basic.target.wants/tbm-drm-auth-user.path
 %{_includedir}/tbm_drm_helper.h
 %{_includedir}/tbm_sync.h
 %{_includedir}/tbm_bo.h
+%{_includedir}/tbm_log.h
 %{_libdir}/libtbm.so
 %{_libdir}/pkgconfig/libtbm.pc
 
index 26bce0d042eb468f9e3c0fbb63bb86e9f198e7e1..2d6089700dc028e80ef9d4001de468903629057d 100644 (file)
@@ -22,7 +22,8 @@ libtbm_la_SOURCES = \
        tbm_bo.c \
        tbm_drm_helper_server.c \
        tbm_drm_helper_client.c \
-       tbm_sync.c
+       tbm_sync.c \
+       tbm_log.c
 
 nodist_libtbm_la_SOURCES =             \
        wayland-tbm-drm-auth-server-protocol.h  \
@@ -50,6 +51,7 @@ libtbminclude_HEADERS = tbm_bufmgr.h \
                                                tbm_surface_internal.h \
                                                tbm_surface_queue.h \
                                                tbm_drm_helper.h \
-                                               tbm_sync.h
+                                               tbm_sync.h \
+                                               tbm_log.h
 
 CLEANFILES = $(BUILT_SOURCES)
index cb18292b20918bbe3cab68c253477f7df9c9fce4..95d74781252347b0a7bc30c1b65d0d9bae89e551 100644 (file)
@@ -41,7 +41,7 @@ static void _tbm_bo_mutex_unlock(void);
 /* check condition */
 #define TBM_BO_RETURN_IF_FAIL(cond) {\
        if (!(cond)) {\
-               TBM_LOG_E("'%s' failed.\n", #cond);\
+               TBM_ERR("'%s' failed.\n", #cond);\
                _tbm_bo_mutex_unlock();\
                return;\
        } \
@@ -49,7 +49,7 @@ static void _tbm_bo_mutex_unlock(void);
 
 #define TBM_BO_RETURN_VAL_IF_FAIL(cond, val) {\
        if (!(cond)) {\
-               TBM_LOG_E("'%s' failed.\n", #cond);\
+               TBM_ERR("'%s' failed.\n", #cond);\
                _tbm_bo_mutex_unlock();\
                return val;\
        } \
@@ -71,7 +71,7 @@ _tbm_bo_mutex_init(void)
                return true;
 
        if (pthread_mutex_init(&tbm_bo_lock, NULL)) {
-               TBM_LOG_E("fail: Cannot pthread_mutex_init for tbm_bo_lock.\n");
+               TBM_ERR("fail: Cannot pthread_mutex_init for tbm_bo_lock.\n");
                return false;
        }
 
@@ -84,7 +84,7 @@ static void
 _tbm_bo_mutex_lock(void)
 {
        if (!_tbm_bo_mutex_init()) {
-               TBM_LOG_E("fail: _tbm_bo_mutex_init()\n");
+               TBM_ERR("fail: _tbm_bo_mutex_init()\n");
                return;
        }
 
@@ -137,7 +137,7 @@ _tbm_util_check_bo_cnt(tbm_bufmgr bufmgr)
 
        if ((bufmgr->bo_cnt >= 500) && ((bufmgr->bo_cnt % 20) == 0) &&
                (bufmgr->bo_cnt > last_chk_bo_cnt)) {
-               TBM_DEBUG("============TBM BO CNT DEBUG: bo_cnt=%d\n", bufmgr->bo_cnt);
+               TBM_DBG("============TBM BO CNT DEBUG: bo_cnt=%d\n", bufmgr->bo_cnt);
                tbm_bufmgr_debug_show(bufmgr);
                last_chk_bo_cnt = bufmgr->bo_cnt;
        }
@@ -168,7 +168,7 @@ tbm_user_data
        user_data = calloc(1, sizeof(tbm_user_data));
        if (!user_data) {
                /* LCOV_EXCL_START */
-               TBM_LOG_E("fail to allocate an user_date\n");
+               TBM_ERR("fail to allocate an user_date\n");
                return NULL;
                /* LCOV_EXCL_STOP */
        }
@@ -221,7 +221,7 @@ _tbm_bo_lock(tbm_bo bo, int device, int opt)
                return 1;
 
        if (bo->lock_cnt < 0) {
-               TBM_LOG_E("error bo:%p LOCK_CNT=%d\n",
+               TBM_ERR("error bo:%p LOCK_CNT=%d\n",
                        bo, bo->lock_cnt);
                return 0;
        }
@@ -247,13 +247,13 @@ _tbm_bo_lock(tbm_bo bo, int device, int opt)
                        bo->lock_cnt++;
                break;
        default:
-               TBM_LOG_E("error bo:%p bo_lock_type[%d] is wrong.\n",
+               TBM_ERR("error bo:%p bo_lock_type[%d] is wrong.\n",
                                bo, bo->bufmgr->bo_lock_type);
                ret = 0;
                break;
        }
 
-       TBM_DBG_LOCK(">> LOCK bo:%p(%d->%d)\n", bo, old, bo->lock_cnt);
+       TBM_DBG(">> LOCK bo:%p(%d->%d)\n", bo, old, bo->lock_cnt);
 
        return ret;
 }
@@ -284,7 +284,7 @@ _tbm_bo_unlock(tbm_bo bo)
                }
                break;
        default:
-               TBM_LOG_E("error bo:%p bo_lock_type[%d] is wrong.\n",
+               TBM_ERR("error bo:%p bo_lock_type[%d] is wrong.\n",
                                bo, bo->bufmgr->bo_lock_type);
                break;
        }
@@ -292,7 +292,7 @@ _tbm_bo_unlock(tbm_bo bo)
        if (bo->lock_cnt < 0)
                bo->lock_cnt = 0;
 
-       TBM_DBG_LOCK(">> UNLOCK bo:%p(%d->%d)\n", bo, old, bo->lock_cnt);
+       TBM_DBG(">> UNLOCK bo:%p(%d->%d)\n", bo, old, bo->lock_cnt);
 }
 
 static int
@@ -302,18 +302,18 @@ _tbm_bo_is_valid(tbm_bo bo)
        tbm_bo old_data = NULL;
 
        if (bo == NULL) {
-               TBM_LOG_E("error: bo is NULL.\n");
+               TBM_ERR("error: bo is NULL.\n");
                return 0;
        }
 
        bufmgr = tbm_bufmgr_get();
        if (bufmgr == NULL) {
-               TBM_LOG_E("error: bufmgr is NULL.\n");
+               TBM_ERR("error: bufmgr is NULL.\n");
                return 0;
        }
 
        if (LIST_IS_EMPTY(&bufmgr->bo_list)) {
-               TBM_LOG_E("error: bo->bo->bufmgr->bo_list is EMPTY.\n");
+               TBM_ERR("error: bo->bo->bufmgr->bo_list is EMPTY.\n");
                return 0;
        }
 
@@ -322,7 +322,7 @@ _tbm_bo_is_valid(tbm_bo bo)
                        return 1;
        }
 
-       TBM_LOG_E("error: No valid bo(%p).\n", bo);
+       TBM_ERR("error: No valid bo(%p).\n", bo);
 
        return 0;
 }
@@ -341,7 +341,7 @@ tbm_bo_alloc(tbm_bufmgr bufmgr, int size, int flags)
        bo = calloc(1, sizeof(struct _tbm_bo));
        if (!bo) {
                /* LCOV_EXCL_START */
-               TBM_LOG_E("error: fail to create of tbm_bo size(%d) flag(%s)\n",
+               TBM_ERR("error: fail to create of tbm_bo size(%d) flag(%s)\n",
                                size, _tbm_flag_to_str(flags));
                _tbm_set_last_result(TBM_BO_ERROR_HEAP_ALLOC_FAILED);
                _tbm_bo_mutex_unlock();
@@ -356,7 +356,7 @@ tbm_bo_alloc(tbm_bufmgr bufmgr, int size, int flags)
        bo_priv = bo->bufmgr->backend->bo_alloc(bo, size, flags);
        if (!bo_priv) {
                /* LCOV_EXCL_START */
-               TBM_LOG_E("error: fail to create of tbm_bo size(%d) flag(%s)\n",
+               TBM_ERR("error: fail to create of tbm_bo size(%d) flag(%s)\n",
                                size, _tbm_flag_to_str(flags));
                _tbm_set_last_result(TBM_BO_ERROR_BO_ALLOC_FAILED);
                free(bo);
@@ -371,7 +371,7 @@ tbm_bo_alloc(tbm_bufmgr bufmgr, int size, int flags)
        bo->flags = flags;
        bo->priv = bo_priv;
 
-       TBM_TRACE("bo(%p) size(%d) refcnt(%d), flag(%s)\n", bo, size, bo->ref_cnt,
+       TBM_TRACE_BO("bo(%p) size(%d) refcnt(%d), flag(%s)\n", bo, size, bo->ref_cnt,
                        _tbm_flag_to_str(bo->flags));
 
        LIST_INITHEAD(&bo->user_data_list);
@@ -392,7 +392,7 @@ tbm_bo_ref(tbm_bo bo)
 
        bo->ref_cnt++;
 
-       TBM_TRACE("bo(%p) ref_cnt(%d)\n", bo, bo->ref_cnt);
+       TBM_TRACE_BO("bo(%p) ref_cnt(%d)\n", bo, bo->ref_cnt);
 
        _tbm_bo_mutex_unlock();
 
@@ -406,7 +406,7 @@ tbm_bo_unref(tbm_bo bo)
 
        TBM_BO_RETURN_IF_FAIL(_tbm_bo_is_valid(bo));
 
-       TBM_TRACE("bo(%p) ref_cnt(%d)\n", bo, bo->ref_cnt - 1);
+       TBM_TRACE_BO("bo(%p) ref_cnt(%d)\n", bo, bo->ref_cnt - 1);
 
        if (bo->ref_cnt <= 0) {
                _tbm_bo_mutex_unlock();
@@ -431,7 +431,7 @@ tbm_bo_map(tbm_bo bo, int device, int opt)
 
        if (!_tbm_bo_lock(bo, device, opt)) {
                _tbm_set_last_result(TBM_BO_ERROR_LOCK_FAILED);
-               TBM_LOG_E("error: fail to lock bo:%p)\n", bo);
+               TBM_ERR("error: fail to lock bo:%p)\n", bo);
                _tbm_bo_mutex_unlock();
                return (tbm_bo_handle) NULL;
        }
@@ -440,7 +440,7 @@ tbm_bo_map(tbm_bo bo, int device, int opt)
        if (bo_handle.ptr == NULL) {
                /* LCOV_EXCL_START */
                _tbm_set_last_result(TBM_BO_ERROR_MAP_FAILED);
-               TBM_LOG_E("error: fail to map bo:%p\n", bo);
+               TBM_ERR("error: fail to map bo:%p\n", bo);
                _tbm_bo_unlock(bo);
                _tbm_bo_mutex_unlock();
                return (tbm_bo_handle) NULL;
@@ -450,7 +450,7 @@ tbm_bo_map(tbm_bo bo, int device, int opt)
        /* increase the map_count */
        bo->map_cnt++;
 
-       TBM_TRACE("bo(%p) map_cnt(%d)\n", bo, bo->map_cnt);
+       TBM_TRACE_BO("bo(%p) map_cnt(%d)\n", bo, bo->map_cnt);
 
        _tbm_bo_mutex_unlock();
 
@@ -470,7 +470,7 @@ tbm_bo_unmap(tbm_bo bo)
        ret = bo->bufmgr->backend->bo_unmap(bo);
        if (!ret) {
                /* LCOV_EXCL_START */
-               TBM_LOG_E("error: bo(%p) map_cnt(%d)\n", bo, bo->map_cnt);
+               TBM_ERR("error: bo(%p) map_cnt(%d)\n", bo, bo->map_cnt);
                _tbm_set_last_result(TBM_BO_ERROR_UNMAP_FAILED);
                _tbm_bo_mutex_unlock();
                return ret;
@@ -480,7 +480,7 @@ tbm_bo_unmap(tbm_bo bo)
        /* decrease the map_count */
        bo->map_cnt--;
 
-       TBM_TRACE("bo(%p) map_cnt(%d)\n", bo, bo->map_cnt);
+       TBM_TRACE_BO("bo(%p) map_cnt(%d)\n", bo, bo->map_cnt);
 
        _tbm_bo_unlock(bo);
 
@@ -502,13 +502,13 @@ tbm_bo_get_handle(tbm_bo bo, int device)
        if (bo_handle.ptr == NULL) {
                /* LCOV_EXCL_START */
                _tbm_set_last_result(TBM_BO_ERROR_GET_HANDLE_FAILED);
-               TBM_LOG_E("error: bo(%p) bo_handle(%p)\n", bo, bo_handle.ptr);
+               TBM_ERR("error: bo(%p) bo_handle(%p)\n", bo, bo_handle.ptr);
                _tbm_bo_mutex_unlock();
                return (tbm_bo_handle) NULL;
                /* LCOV_EXCL_STOP */
        }
 
-       TBM_TRACE("bo(%p) bo_handle(%p)\n", bo, bo_handle.ptr);
+       TBM_TRACE_BO("bo(%p) bo_handle(%p)\n", bo, bo_handle.ptr);
 
        _tbm_bo_mutex_unlock();
 
@@ -535,13 +535,13 @@ tbm_bo_export(tbm_bo bo)
        if (!ret) {
                /* LCOV_EXCL_START */
                _tbm_set_last_result(TBM_BO_ERROR_EXPORT_FAILED);
-               TBM_LOG_E("error: bo(%p) tbm_key(%d)\n", bo, ret);
+               TBM_ERR("error: bo(%p) tbm_key(%d)\n", bo, ret);
                _tbm_bo_mutex_unlock();
                return ret;
                /* LCOV_EXCL_STOP */
        }
 
-       TBM_TRACE("bo(%p) tbm_key(%u)\n", bo, ret);
+       TBM_TRACE_BO("bo(%p) tbm_key(%u)\n", bo, ret);
 
        _tbm_bo_mutex_unlock();
 
@@ -568,13 +568,13 @@ tbm_bo_export_fd(tbm_bo bo)
        if (ret < 0) {
                /* LCOV_EXCL_START */
                _tbm_set_last_result(TBM_BO_ERROR_EXPORT_FD_FAILED);
-               TBM_LOG_E("error: bo(%p) tbm_fd(%d)\n", bo, ret);
+               TBM_ERR("error: bo(%p) tbm_fd(%d)\n", bo, ret);
                _tbm_bo_mutex_unlock();
                return ret;
                /* LCOV_EXCL_STOP */
        }
 
-       TBM_TRACE("bo(%p) tbm_fd(%d)\n", bo, ret);
+       TBM_TRACE_BO("bo(%p) tbm_fd(%d)\n", bo, ret);
 
        _tbm_bo_mutex_unlock();
 
@@ -604,7 +604,7 @@ tbm_bo_import(tbm_bufmgr bufmgr, unsigned int key)
        bo = calloc(1, sizeof(struct _tbm_bo));
        if (!bo) {
                /* LCOV_EXCL_START */
-               TBM_LOG_E("error: fail to import of tbm_bo by key(%d)\n", key);
+               TBM_ERR("error: fail to import of tbm_bo by key(%d)\n", key);
                _tbm_bo_mutex_unlock();
                return NULL;
                /* LCOV_EXCL_STOP */
@@ -615,7 +615,7 @@ tbm_bo_import(tbm_bufmgr bufmgr, unsigned int key)
        bo_priv = bo->bufmgr->backend->bo_import(bo, key);
        if (!bo_priv) {
                /* LCOV_EXCL_START */
-               TBM_LOG_E("error: fail to import of tbm_bo by key(%d)\n", key);
+               TBM_ERR("error: fail to import of tbm_bo by key(%d)\n", key);
                _tbm_set_last_result(TBM_BO_ERROR_IMPORT_FAILED);
                free(bo);
                _tbm_bo_mutex_unlock();
@@ -626,7 +626,7 @@ tbm_bo_import(tbm_bufmgr bufmgr, unsigned int key)
        if (!LIST_IS_EMPTY(&bo->bufmgr->bo_list)) {
                LIST_FOR_EACH_ENTRY(bo2, &bo->bufmgr->bo_list, item_link) {
                        if (bo2->priv == bo_priv) {
-                               TBM_TRACE("find bo(%p) ref(%d) key(%d) flag(%s) in list\n",
+                               TBM_TRACE_BO("find bo(%p) ref(%d) key(%d) flag(%s) in list\n",
                                                bo2, bo2->ref_cnt, key,
                                                _tbm_flag_to_str(bo2->flags));
                                bo2->ref_cnt++;
@@ -647,7 +647,7 @@ tbm_bo_import(tbm_bufmgr bufmgr, unsigned int key)
        else
                bo->flags = TBM_BO_DEFAULT;
 
-       TBM_TRACE("import new bo(%p) ref(%d) key(%d) flag(%s) in list\n",
+       TBM_TRACE_BO("import new bo(%p) ref(%d) key(%d) flag(%s) in list\n",
                          bo, bo->ref_cnt, key, _tbm_flag_to_str(bo->flags));
 
        LIST_INITHEAD(&bo->user_data_list);
@@ -682,7 +682,7 @@ tbm_bo_import_fd(tbm_bufmgr bufmgr, tbm_fd fd)
        bo = calloc(1, sizeof(struct _tbm_bo));
        if (!bo) {
                /* LCOV_EXCL_START */
-               TBM_LOG_E("error: fail to import tbm_bo by tbm_fd(%d)\n", fd);
+               TBM_ERR("error: fail to import tbm_bo by tbm_fd(%d)\n", fd);
                _tbm_bo_mutex_unlock();
                return NULL;
                /* LCOV_EXCL_STOP */
@@ -693,7 +693,7 @@ tbm_bo_import_fd(tbm_bufmgr bufmgr, tbm_fd fd)
        bo_priv = bo->bufmgr->backend->bo_import_fd(bo, fd);
        if (!bo_priv) {
                /* LCOV_EXCL_START */
-               TBM_LOG_E("error: fail to import tbm_bo by tbm_fd(%d)\n", fd);
+               TBM_ERR("error: fail to import tbm_bo by tbm_fd(%d)\n", fd);
                _tbm_set_last_result(TBM_BO_ERROR_IMPORT_FD_FAILED);
                free(bo);
                _tbm_bo_mutex_unlock();
@@ -705,7 +705,7 @@ tbm_bo_import_fd(tbm_bufmgr bufmgr, tbm_fd fd)
 
                LIST_FOR_EACH_ENTRY(bo2, &bo->bufmgr->bo_list, item_link) {
                        if (bo2->priv == bo_priv) {
-                               TBM_TRACE("find bo(%p) ref(%d) fd(%d) flag(%s) in list\n",
+                               TBM_TRACE_BO("find bo(%p) ref(%d) fd(%d) flag(%s) in list\n",
                                                bo2, bo2->ref_cnt, fd,
                                                _tbm_flag_to_str(bo2->flags));
                                bo2->ref_cnt++;
@@ -726,7 +726,7 @@ tbm_bo_import_fd(tbm_bufmgr bufmgr, tbm_fd fd)
        else
                bo->flags = TBM_BO_DEFAULT;
 
-       TBM_TRACE("import bo(%p) ref(%d) fd(%d) flag(%s)\n",
+       TBM_TRACE_BO("import bo(%p) ref(%d) fd(%d) flag(%s)\n",
                        bo, bo->ref_cnt, fd, _tbm_flag_to_str(bo->flags));
 
        LIST_INITHEAD(&bo->user_data_list);
@@ -749,7 +749,7 @@ tbm_bo_size(tbm_bo bo)
 
        size = bo->bufmgr->backend->bo_size(bo);
 
-       TBM_TRACE("bo(%p) size(%d)\n", bo, size);
+       TBM_TRACE_BO("bo(%p) size(%d)\n", bo, size);
 
        _tbm_bo_mutex_unlock();
 
@@ -764,18 +764,18 @@ tbm_bo_locked(tbm_bo bo)
        TBM_BO_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), 0);
 
        if (bo->bufmgr->bo_lock_type == TBM_BUFMGR_BO_LOCK_TYPE_NEVER) {
-               TBM_LOG_E("bo(%p) lock_cnt(%d)\n", bo, bo->lock_cnt);
+               TBM_ERR("bo(%p) lock_cnt(%d)\n", bo, bo->lock_cnt);
                _tbm_bo_mutex_unlock();
                return 0;
        }
 
        if (bo->lock_cnt > 0) {
-               TBM_TRACE("error: bo(%p) lock_cnt(%d)\n", bo, bo->lock_cnt);
+               TBM_TRACE_BO("error: bo(%p) lock_cnt(%d)\n", bo, bo->lock_cnt);
                _tbm_bo_mutex_unlock();
                return 1;
        }
 
-       TBM_TRACE("bo(%p) lock_cnt(%d)\n", bo, bo->lock_cnt);
+       TBM_TRACE_BO("bo(%p) lock_cnt(%d)\n", bo, bo->lock_cnt);
        _tbm_bo_mutex_unlock();
 
        return 0;
@@ -791,16 +791,16 @@ tbm_bo_swap(tbm_bo bo1, tbm_bo bo2)
        TBM_BO_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo1), 0);
        TBM_BO_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo2), 0);
 
-       TBM_TRACE("before: bo1(%p) bo2(%p)\n", bo1, bo2);
+       TBM_TRACE_BO("before: bo1(%p) bo2(%p)\n", bo1, bo2);
 
        if (bo1->bufmgr->backend->bo_size(bo1) != bo2->bufmgr->backend->bo_size(bo2)) {
                _tbm_set_last_result(TBM_BO_ERROR_SWAP_FAILED);
-               TBM_LOG_E("error: bo1(%p) bo2(%p)\n", bo1, bo2);
+               TBM_ERR("error: bo1(%p) bo2(%p)\n", bo1, bo2);
                _tbm_bo_mutex_unlock();
                return 0;
        }
 
-       TBM_TRACE("after: bo1(%p) bo2(%p)\n", bo1, bo2);
+       TBM_TRACE_BO("after: bo1(%p) bo2(%p)\n", bo1, bo2);
 
        temp = bo1->priv;
        bo1->priv = bo2->priv;
@@ -824,19 +824,19 @@ tbm_bo_add_user_data(tbm_bo bo, unsigned long key,
        /* check if the data according to the key exist if so, return false. */
        data = user_data_lookup(&bo->user_data_list, key);
        if (data) {
-               TBM_TRACE("warning: user data already exist key(%ld)\n", key);
+               TBM_TRACE_BO("warning: user data already exist key(%ld)\n", key);
                _tbm_bo_mutex_unlock();
                return 0;
        }
 
        data = user_data_create(key, data_free_func);
        if (!data) {
-               TBM_LOG_E("error: bo(%p) key(%lu)\n", bo, key);
+               TBM_ERR("error: bo(%p) key(%lu)\n", bo, key);
                _tbm_bo_mutex_unlock();
                return 0;
        }
 
-       TBM_TRACE("bo(%p) key(%lu) data(%p)\n", bo, key, data->data);
+       TBM_TRACE_BO("bo(%p) key(%lu) data(%p)\n", bo, key, data->data);
 
        LIST_ADD(&data->item_link, &bo->user_data_list);
 
@@ -855,19 +855,19 @@ tbm_bo_delete_user_data(tbm_bo bo, unsigned long key)
        TBM_BO_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), 0);
 
        if (LIST_IS_EMPTY(&bo->user_data_list)) {
-               TBM_TRACE("error: bo(%p) key(%lu)\n", bo, key);
+               TBM_TRACE_BO("error: bo(%p) key(%lu)\n", bo, key);
                _tbm_bo_mutex_unlock();
                return 0;
        }
 
        old_data = user_data_lookup(&bo->user_data_list, key);
        if (!old_data) {
-               TBM_TRACE("error: bo(%p) key(%lu)\n", bo, key);
+               TBM_TRACE_BO("error: bo(%p) key(%lu)\n", bo, key);
                _tbm_bo_mutex_unlock();
                return 0;
        }
 
-       TBM_TRACE("bo(%p) key(%lu) data(%p)\n", bo, key, old_data->data);
+       TBM_TRACE_BO("bo(%p) key(%lu) data(%p)\n", bo, key, old_data->data);
 
        user_data_delete(old_data);
 
@@ -886,14 +886,14 @@ tbm_bo_set_user_data(tbm_bo bo, unsigned long key, void *data)
        TBM_BO_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), 0);
 
        if (LIST_IS_EMPTY(&bo->user_data_list)) {
-               TBM_TRACE("error: bo(%p) key(%lu)\n", bo, key);
+               TBM_TRACE_BO("error: bo(%p) key(%lu)\n", bo, key);
                _tbm_bo_mutex_unlock();
                return 0;
        }
 
        old_data = user_data_lookup(&bo->user_data_list, key);
        if (!old_data) {
-               TBM_TRACE("error: bo(%p) key(%lu)\n", bo, key);
+               TBM_TRACE_BO("error: bo(%p) key(%lu)\n", bo, key);
                _tbm_bo_mutex_unlock();
                return 0;
        }
@@ -902,7 +902,7 @@ tbm_bo_set_user_data(tbm_bo bo, unsigned long key, void *data)
                old_data->free_func(old_data->data);
        old_data->data = data;
 
-       TBM_TRACE("bo(%p) key(%lu) data(%p)\n", bo, key, old_data->data);
+       TBM_TRACE_BO("bo(%p) key(%lu) data(%p)\n", bo, key, old_data->data);
 
        _tbm_bo_mutex_unlock();
 
@@ -919,14 +919,14 @@ tbm_bo_get_user_data(tbm_bo bo, unsigned long key, void **data)
        TBM_BO_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), 0);
 
        if (!data || LIST_IS_EMPTY(&bo->user_data_list)) {
-               TBM_TRACE("error: bo(%p) key(%lu)\n", bo, key);
+               TBM_TRACE_BO("error: bo(%p) key(%lu)\n", bo, key);
                _tbm_bo_mutex_unlock();
                return 0;
        }
 
        old_data = user_data_lookup(&bo->user_data_list, key);
        if (!old_data) {
-               TBM_TRACE("error: bo(%p) key(%lu)\n", bo, key);
+               TBM_TRACE_BO("error: bo(%p) key(%lu)\n", bo, key);
                *data = NULL;
                _tbm_bo_mutex_unlock();
                return 0;
@@ -934,7 +934,7 @@ tbm_bo_get_user_data(tbm_bo bo, unsigned long key, void **data)
 
        *data = old_data->data;
 
-       TBM_TRACE("bo(%p) key(%lu) data(%p)\n", bo, key, old_data->data);
+       TBM_TRACE_BO("bo(%p) key(%lu) data(%p)\n", bo, key, old_data->data);
 
        _tbm_bo_mutex_unlock();
 
@@ -960,7 +960,7 @@ tbm_bo_get_flags(tbm_bo bo)
 
        flags = bo->flags;
 
-       TBM_TRACE("bo(%p)\n", bo);
+       TBM_TRACE_BO("bo(%p)\n", bo);
 
        _tbm_bo_mutex_unlock();
 
@@ -998,7 +998,7 @@ _tbm_bo_free(tbm_bo bo)
        }
 
        while (bo->lock_cnt > 0) {
-               TBM_LOG_E("error lock_cnt:%d\n", bo->lock_cnt);
+               TBM_ERR("error lock_cnt:%d\n", bo->lock_cnt);
                _bo_unlock(bo);
                bo->lock_cnt--;
        }
index deccc1b857a98148aed0cdf278ea5fd0606787ab..8046e9b8109cba6ea69ce5c77c21781757fbf13e 100644 (file)
@@ -38,13 +38,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include <sys/resource.h>
 
-#ifdef DEBUG
-int bDebug;
-#endif
-
-#ifdef TRACE
-int bTrace;
-#endif
+int trace_mask = 0;
 
 #ifdef HAVE_DLOG
 int bDlog;
@@ -81,7 +75,7 @@ static void _tbm_bufmgr_mutex_unlock(void);
 /* check condition */
 #define TBM_BUFMGR_RETURN_IF_FAIL(cond) {\
        if (!(cond)) {\
-               TBM_LOG_E("'%s' failed.\n", #cond);\
+               TBM_ERR("'%s' failed.\n", #cond);\
                _tbm_bufmgr_mutex_unlock();\
                return;\
        } \
@@ -89,7 +83,7 @@ static void _tbm_bufmgr_mutex_unlock(void);
 
 #define TBM_BUFMGR_RETURN_VAL_IF_FAIL(cond, val) {\
        if (!(cond)) {\
-               TBM_LOG_E("'%s' failed.\n", #cond);\
+               TBM_ERR("'%s' failed.\n", #cond);\
                _tbm_bufmgr_mutex_unlock();\
                return val;\
        } \
@@ -105,7 +99,7 @@ _tbm_bufmgr_mutex_init(void)
                return true;
 
        if (pthread_mutex_init(&tbm_bufmgr_lock, NULL)) {
-               TBM_LOG_E("fail: Cannot pthread_mutex_init for tbm_bufmgr_lock.\n");
+               TBM_ERR("fail: Cannot pthread_mutex_init for tbm_bufmgr_lock.\n");
                return false;
        }
 
@@ -118,7 +112,7 @@ static void
 _tbm_bufmgr_mutex_lock(void)
 {
        if (!_tbm_bufmgr_mutex_init()) {
-               TBM_LOG_E("fail: _tbm_bufmgr_mutex_init()\n");
+               TBM_ERR("fail: _tbm_bufmgr_mutex_init()\n");
                return;
        }
 
@@ -187,12 +181,12 @@ _tbm_util_get_appname_from_pid(long pid, char *str)
 
        fp = fopen(fn_cmdline, "r");
        if (fp == 0) {
-               TBM_LOG_E("cannot file open %s\n", fn_cmdline);
+               TBM_ERR("cannot file open %s\n", fn_cmdline);
                return;
        }
 
        if (!fgets(cmdline, 255, fp)) {
-               TBM_LOG_E("fail to get appname for pid(%ld)\n", pid);
+               TBM_ERR("fail to get appname for pid(%ld)\n", pid);
                fclose(fp);
                return;
        }
@@ -228,11 +222,11 @@ _check_version(TBMModuleVersionInfo *data)
            vermaj, vermin);
 
        if (abimaj != vermaj) {
-               TBM_LOG_E("TBM module ABI major ver(%d) doesn't match the TBM's ver(%d)\n",
+               TBM_ERR("TBM module ABI major ver(%d) doesn't match the TBM's ver(%d)\n",
                        abimaj, vermaj);
                return 0;
        } else if (abimin > vermin) {
-               TBM_LOG_E("TBM module ABI minor ver(%d) is newer than the TBM's ver(%d)\n",
+               TBM_ERR("TBM module ABI minor ver(%d) is newer than the TBM's ver(%d)\n",
                        abimin, vermin);
                return 0;
        }
@@ -253,40 +247,40 @@ _tbm_bufmgr_load_module(tbm_bufmgr bufmgr, int fd, const char *file)
 
        module_data = dlopen(path, RTLD_LAZY);
        if (!module_data) {
-               TBM_LOG_E("failed to load module: %s(%s)\n", dlerror(), file);
+               TBM_ERR("failed to load module: %s(%s)\n", dlerror(), file);
                return 0;
        }
 
        initdata = dlsym(module_data, "tbmModuleData");
        if (!initdata) {
-               TBM_LOG_E("Error: module does not have data object.\n");
+               TBM_ERR("Error: module does not have data object.\n");
                goto err;
        }
 
        vers = initdata->vers;
        if (!vers) {
-               TBM_LOG_E("Error: module does not supply version information.\n");
+               TBM_ERR("Error: module does not supply version information.\n");
                goto err;
        }
 
        init = initdata->init;
        if (!init) {
-               TBM_LOG_E("Error: module does not supply init symbol.\n");
+               TBM_ERR("Error: module does not supply init symbol.\n");
                goto err;
        }
 
        if (!_check_version(vers)) {
-               TBM_LOG_E("Fail to check version.\n");
+               TBM_ERR("Fail to check version.\n");
                goto err;
        }
 
        if (!init(bufmgr, fd)) {
-               TBM_LOG_E("Fail to init module(%s)\n", file);
+               TBM_ERR("Fail to init module(%s)\n", file);
                goto err;
        }
 
        if (!bufmgr->backend || !bufmgr->backend->priv) {
-               TBM_LOG_E("Error: module(%s) wrong operation. Check backend or backend's priv.\n", file);
+               TBM_ERR("Error: module(%s) wrong operation. Check backend or backend's priv.\n", file);
                goto err;
        }
 
@@ -314,7 +308,7 @@ _tbm_load_module(tbm_bufmgr bufmgr, int fd)
        /* load bufmgr priv from configured path */
        n = scandir(BUFMGR_MODULE_DIR, &namelist, 0, alphasort);
        if (n < 0) {
-               TBM_LOG_E("no files : %s\n", BUFMGR_MODULE_DIR);
+               TBM_ERR("no files : %s\n", BUFMGR_MODULE_DIR);
                return 0;
        }
 
@@ -354,41 +348,32 @@ _tbm_bufmgr_init(int fd, int server)
        env = getenv("TBM_DLOG");
        if (env) {
                bDlog = atoi(env);
-               TBM_LOG_D("TBM_DLOG=%s\n", env);
+               TBM_DBG("TBM_DLOG=%s\n", env);
        } else
                bDlog = 1;
 #endif
 
-#ifdef DEBUG
-       env = getenv("TBM_DEBUG");
-       if (env) {
-               bDebug = atoi(env);
-               TBM_LOG_D("TBM_DEBUG=%s\n", env);
-       } else
-               bDebug = 0;
-#endif
-
 #ifdef TRACE
        env = getenv("TBM_TRACE");
        if (env) {
-               bTrace = atoi(env);
-               TBM_LOG_D("TBM_TRACE=%s\n", env);
+               trace_mask = atoi(env);
+               TBM_DBG("TBM_TRACE=%s\n", env);
        } else
-               bTrace = 0;
+               trace_mask = 0;
 #endif
 
        pthread_mutex_lock(&gLock);
 
        if (fd >= 0) {
-               TBM_LOG_W("!!!!!WARNING:: The tbm_bufmgr_init DOSE NOT use argument fd ANYMORE.\n");
-               TBM_LOG_W("!!!!!WARNING:: IT WILL BE CHANGED like tbm_bufmgr_init(int fd) --> tbm_bufmgr_init(void).\n");
+               TBM_WRN("!!!!!WARNING:: The tbm_bufmgr_init DOSE NOT use argument fd ANYMORE.\n");
+               TBM_WRN("!!!!!WARNING:: IT WILL BE CHANGED like tbm_bufmgr_init(int fd) --> tbm_bufmgr_init(void).\n");
        }
 
 
        /* initialize buffer manager */
        if (gBufMgr) {
                gBufMgr->ref_count++;
-               TBM_TRACE("reuse  tbm_bufmgr(%p) ref_count(%d) fd(%d)\n", gBufMgr, gBufMgr->ref_count, gBufMgr->fd);
+               TBM_INFO("reuse  tbm_bufmgr(%p) ref_count(%d) fd(%d)\n", gBufMgr, gBufMgr->ref_count, gBufMgr->fd);
                pthread_mutex_unlock(&gLock);
                return gBufMgr;
        }
@@ -398,7 +383,7 @@ _tbm_bufmgr_init(int fd, int server)
        /* allocate bufmgr */
        gBufMgr = calloc(1, sizeof(struct _tbm_bufmgr));
        if (!gBufMgr) {
-               TBM_TRACE("error: fail to alloc bufmgr fd(%d)\n", fd);
+               TBM_ERR("error: fail to alloc bufmgr fd(%d)\n", fd);
                pthread_mutex_unlock(&gLock);
                return NULL;
        }
@@ -407,13 +392,13 @@ _tbm_bufmgr_init(int fd, int server)
 
        /* set the display_server flag before loading the backend module */
        if (server) {
-               TBM_LOG_I("The tbm_bufmgr(%p) is used by display server. Need to bind the native_display.\n", gBufMgr);
+               TBM_INFO("The tbm_bufmgr(%p) is used by display server. Need to bind the native_display.\n", gBufMgr);
                gBufMgr->display_server = 1;
        }
 
        /* load bufmgr priv from env */
        if (!_tbm_load_module(gBufMgr, gBufMgr->fd)) {
-               TBM_LOG_E("error : Fail to load bufmgr backend\n");
+               TBM_ERR("error : Fail to load bufmgr backend\n");
                free(gBufMgr);
                gBufMgr = NULL;
                pthread_mutex_unlock(&gLock);
@@ -422,13 +407,9 @@ _tbm_bufmgr_init(int fd, int server)
        }
        /* LCOV_EXCL_STOP */
 
-       /* log for tbm backend_flag */
-       TBM_DBG("backend flag:%x:", gBufMgr->backend->flags);
-       TBM_DBG("\n");
-
        gBufMgr->ref_count = 1;
 
-       TBM_DBG("create tizen bufmgr:%p ref_count:%d\n",
+       TBM_INFO("create tizen bufmgr:%p ref_count:%d\n",
            gBufMgr, gBufMgr->ref_count);
 
        /* setup the bo_lock_type */
@@ -444,8 +425,6 @@ _tbm_bufmgr_init(int fd, int server)
 
        TBM_DBG("BUFMGR_LOCK_TYPE=%s\n", env ? env : "default:once");
 
-       TBM_TRACE("create tbm_bufmgr(%p) ref_count(%d) fd(%d)\n", gBufMgr, gBufMgr->ref_count, fd);
-
        /* intialize bo_list */
        LIST_INITHEAD(&gBufMgr->bo_list);
 
@@ -461,7 +440,7 @@ _tbm_bufmgr_init(int fd, int server)
 #ifdef TBM_BUFMGR_INIT_TIME
        /* get the end tv */
        gettimeofday(&end_tv, NULL);
-       TBM_LOG_I("tbm_bufmgr_init time: %ld ms", ((end_tv.tv_sec * 1000 + end_tv.tv_usec / 1000) - (start_tv.tv_sec * 1000 + start_tv.tv_usec / 1000)));
+       TBM_INFO("tbm_bufmgr_init time: %ld ms", ((end_tv.tv_sec * 1000 + end_tv.tv_usec / 1000) - (start_tv.tv_sec * 1000 + start_tv.tv_usec / 1000)));
 #endif
 
        pthread_mutex_unlock(&gLock);
@@ -488,7 +467,7 @@ tbm_bufmgr_deinit(tbm_bufmgr bufmgr)
        pthread_mutex_lock(&gLock);
 
        if (!gBufMgr) {
-               TBM_LOG_E("gBufmgr already destroy: bufmgr:%p\n", bufmgr);
+               TBM_ERR("gBufmgr already destroy: bufmgr:%p\n", bufmgr);
                pthread_mutex_unlock(&gLock);
                _tbm_bufmgr_mutex_unlock();
                return;
@@ -496,7 +475,7 @@ tbm_bufmgr_deinit(tbm_bufmgr bufmgr)
 
        bufmgr->ref_count--;
        if (bufmgr->ref_count > 0) {
-               TBM_TRACE("reduce a ref_count(%d) of tbm_bufmgr(%p)\n", bufmgr->ref_count, bufmgr);
+               TBM_INFO("reduce a ref_count(%d) of tbm_bufmgr(%p)\n", bufmgr->ref_count, bufmgr);
                pthread_mutex_unlock(&gLock);
                _tbm_bufmgr_mutex_unlock();
                return;
@@ -507,7 +486,7 @@ tbm_bufmgr_deinit(tbm_bufmgr bufmgr)
                tbm_bo bo = NULL, tmp;
 
                LIST_FOR_EACH_ENTRY_SAFE(bo, tmp, &bufmgr->bo_list, item_link) {
-                       TBM_LOG_E("Un-freed bo(%p, ref:%d)\n", bo, bo->ref_cnt);
+                       TBM_ERR("Un-freed bo(%p, ref:%d)\n", bo, bo->ref_cnt);
                        _tbm_bo_free(bo);
                }
                LIST_DELINIT(&bufmgr->bo_list);
@@ -518,7 +497,7 @@ tbm_bufmgr_deinit(tbm_bufmgr bufmgr)
                tbm_surface_h surf = NULL, tmp;
 
                LIST_FOR_EACH_ENTRY_SAFE(surf, tmp, &bufmgr->surf_list, item_link) {
-                       TBM_LOG_E("Un-freed surf(%p, ref:%d)\n", surf, surf->refcnt);
+                       TBM_ERR("Un-freed surf(%p, ref:%d)\n", surf, surf->refcnt);
                        tbm_surface_destroy(surf);
                }
                LIST_DELINIT(&bufmgr->surf_list);
@@ -530,7 +509,7 @@ tbm_bufmgr_deinit(tbm_bufmgr bufmgr)
        tbm_backend_free(bufmgr->backend);
        bufmgr->backend = NULL;
 
-       TBM_TRACE("destroy tbm_bufmgr(%p)\n", bufmgr);
+       TBM_INFO("destroy tbm_bufmgr(%p)\n", bufmgr);
 
        dlclose(bufmgr->module_data);
 
@@ -554,8 +533,6 @@ tbm_bufmgr_get_capability(tbm_bufmgr bufmgr)
        TBM_BUFMGR_RETURN_VAL_IF_FAIL(TBM_BUFMGR_IS_VALID(bufmgr), TBM_BUFMGR_CAPABILITY_NONE);
        TBM_BUFMGR_RETURN_VAL_IF_FAIL(bufmgr == gBufMgr, TBM_BUFMGR_CAPABILITY_NONE);
 
-       TBM_TRACE("tbm_bufmgr(%p) capability(%u)\n", bufmgr, bufmgr->capabilities);
-
        capabilities = bufmgr->capabilities;
 
        _tbm_bufmgr_mutex_unlock();
@@ -576,14 +553,14 @@ tbm_bufmgr_debug_tbm_info_get(tbm_bufmgr bufmgr)
        pthread_mutex_lock(&gLock);
 
        if (!TBM_BUFMGR_IS_VALID(bufmgr) || (bufmgr != gBufMgr)) {
-               TBM_LOG_E("invalid bufmgr\n");
+               TBM_ERR("invalid bufmgr\n");
                pthread_mutex_unlock(&gLock);
                return NULL;
        }
 
        str = malloc(len);
        if (!str) {
-               TBM_LOG_E("Fail to allocate the string.\n");
+               TBM_ERR("Fail to allocate the string.\n");
                pthread_mutex_unlock(&gLock);
                return NULL;
        }
@@ -703,7 +680,7 @@ tbm_bufmgr_debug_show(tbm_bufmgr bufmgr)
        char * str;
        str = tbm_bufmgr_debug_tbm_info_get(bufmgr);
        if (str) {
-               TBM_DEBUG("     %s", str);
+               TBM_DBG("       %s", str);
                free(str);
        }
 }
@@ -744,21 +721,21 @@ tbm_bufmgr_debug_queue_dump(char *path, int count, int onoff)
        pthread_mutex_lock(&gLock);
 
        if (onoff == 0) {
-               TBM_LOG_D("count=%d onoff=%d\n", count, onoff);
+               TBM_DBG("count=%d onoff=%d\n", count, onoff);
                b_dump_queue = 0;
                tbm_surface_internal_dump_end();
        } else {
                int w, h;
 
                if (path == NULL) {
-                       TBM_LOG_E("path is null");
+                       TBM_ERR("path is null");
                        pthread_mutex_unlock(&gLock);
                        return 0;
                }
-               TBM_LOG_D("path=%s count=%d onoff=%d\n", path, count, onoff);
+               TBM_DBG("path=%s count=%d onoff=%d\n", path, count, onoff);
 
                if (_tbm_util_get_max_surface_size(&w, &h) == 0) {
-                       TBM_LOG_E("Fail to get tbm_surface size.\n");
+                       TBM_ERR("Fail to get tbm_surface size.\n");
                        pthread_mutex_unlock(&gLock);
                        return 0;
                }
@@ -780,13 +757,13 @@ tbm_bufmgr_debug_dump_all(char *path)
        tbm_surface_h surface = NULL;
 
        TBM_RETURN_VAL_IF_FAIL(path != NULL, 0);
-       TBM_LOG_D("path=%s\n", path);
+       TBM_DBG("path=%s\n", path);
 
        pthread_mutex_lock(&gLock);
 
        count = _tbm_util_get_max_surface_size(&w, &h);
        if (count == 0) {
-               TBM_LOG_E("No tbm_surface.\n");
+               TBM_ERR("No tbm_surface.\n");
                pthread_mutex_unlock(&gLock);
                return 1;
        }
@@ -821,7 +798,7 @@ tbm_bufmgr_bind_native_display(tbm_bufmgr bufmgr, void *native_display)
        TBM_BUFMGR_RETURN_VAL_IF_FAIL(TBM_BUFMGR_IS_VALID(gBufMgr), 0);
 
        if (!bufmgr->backend->bufmgr_bind_native_display) {
-               TBM_TRACE("skip: tbm_bufmgr(%p) native_display(%p)\n",
+               TBM_WRN("skip: tbm_bufmgr(%p) native_display(%p)\n",
                                bufmgr, native_display);
                _tbm_bufmgr_mutex_unlock();
                return 1;
@@ -829,13 +806,13 @@ tbm_bufmgr_bind_native_display(tbm_bufmgr bufmgr, void *native_display)
 
        ret = bufmgr->backend->bufmgr_bind_native_display(bufmgr, native_display);
        if (!ret) {
-               TBM_LOG_E("error: tbm_bufmgr(%p) native_display(%p)\n",
+               TBM_ERR("error: tbm_bufmgr(%p) native_display(%p)\n",
                                bufmgr, native_display);
                _tbm_bufmgr_mutex_unlock();
                return 0;
        }
 
-       TBM_TRACE("tbm_bufmgr(%p) native_display(%p)\n", bufmgr, native_display);
+       TBM_INFO("tbm_bufmgr(%p) native_display(%p)\n", bufmgr, native_display);
 
        _tbm_bufmgr_mutex_unlock();
 
@@ -860,7 +837,7 @@ tbm_bufmgr_set_bo_lock_type(tbm_bufmgr bufmgr, tbm_bufmgr_bo_lock_type bo_lock_t
 
        gBufMgr->bo_lock_type = bo_lock_type;
 
-       TBM_LOG_I("The bo_lock_type of the bo is %d\n", bo_lock_type);
+       TBM_INFO("The bo_lock_type of the bo is %d\n", bo_lock_type);
 
        return 1;
 }
index ad809ff1ef63720b88ced090cc9b5fd106adc00b..87d3c78bbfc7209d861543723763be5e0576f7eb 100644 (file)
@@ -44,7 +44,7 @@ tbm_bufmgr_backend tbm_backend_alloc(void)
 
        bufmgr_backend = calloc(1, sizeof(struct _tbm_bufmgr_backend));
        if (!bufmgr_backend) {
-               TBM_LOG_E("error: fail to allocate the bufmgr_backend\n");
+               TBM_ERR("error: fail to allocate the bufmgr_backend\n");
                return NULL;
        }
 
@@ -63,12 +63,12 @@ void tbm_backend_free(tbm_bufmgr_backend backend)
 int tbm_backend_init(tbm_bufmgr bufmgr, tbm_bufmgr_backend backend)
 {
        if (!bufmgr) {
-               TBM_LOG_E("error: fail to init tbm backend... bufmgr is null\n");
+               TBM_ERR("error: fail to init tbm backend... bufmgr is null\n");
                return 0;
        }
 
        if (!backend) {
-               TBM_LOG_E("error: fail to init tbm backend... backend is null\n");
+               TBM_ERR("error: fail to init tbm backend... backend is null\n");
                return 0;
        }
 
@@ -113,7 +113,7 @@ int tbm_backend_is_display_server(void)
        const char *value;
 
        if (gBufMgr == NULL) {
-               TBM_LOG_E("error: no gBufMgr.\n");
+               TBM_ERR("error: no gBufMgr.\n");
                return 0;
        }
 
index 6a36a638d543bbc929d859e06571e70b85877630..ea58185b33a5b83b6e1a9cb6c95bb39ba45dc2a5 100644 (file)
@@ -46,6 +46,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include <dirent.h>
 #include <string.h>
 #include <errno.h>
+#include <assert.h>
 #include <pthread.h>
 #include <tbm_bufmgr.h>
 #include <tbm_bo.h>
@@ -53,124 +54,29 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include <tbm_surface_internal.h>
 #include <tbm_bufmgr_backend.h>
 #include <tbm_surface_queue.h>
+#include <tbm_log.h>
+#include <dlog.h>
 
-#define DEBUG
-#ifdef DEBUG
-extern int bDebug;
 extern tbm_bufmgr gBufMgr;
-
-#define TBM_DBG(...) { if (bDebug&0x1) TBM_LOG_D(__VA_ARGS__); }
-#define TBM_DBG_LOCK(...) { if (bDebug&0x2) TBM_LOG_D(__VA_ARGS__); }
-#else
-#define TBM_DBG(...)
-#define TBM_DBG_LOCK(...)
-#endif /* DEBUG */
-
-#define TRACE
-#ifdef TRACE
-extern int bTrace;
-#endif /* TRACE */
-
 extern int b_dump_queue;
-
-#ifdef HAVE_DLOG
-#include <dlog.h>
-
-extern int bDlog;
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "TBM"
-
-#define TBM_LOG_D(fmt, ...) {\
-       if (bDlog) {\
-               LOGD("[TBM:D] " fmt, ##__VA_ARGS__);\
-       } \
-       else {\
-               fprintf(stderr, "[TBM:D(%d)(%s:%d)] " fmt, getpid(), __func__, __LINE__, ##__VA_ARGS__);\
-       } \
-}
-
-#define TBM_LOG_I(fmt, ...) {\
-       if (bDlog) {\
-               LOGI("[TBM:I] " fmt, ##__VA_ARGS__);\
-       } \
-       else {\
-               fprintf(stderr, "[TBM:I(%d)(%s:%d)] " fmt, getpid(), __func__, __LINE__, ##__VA_ARGS__);\
-       } \
-}
-
-#define TBM_LOG_W(fmt, ...) {\
-       if (bDlog) {\
-               LOGW("[TBM:W] " fmt, ##__VA_ARGS__);\
-       } \
-       else {\
-               fprintf(stderr, "[TBM:W(%d)(%s:%d)] " fmt, getpid(), __func__, __LINE__, ##__VA_ARGS__);\
-       } \
-}
-
-#define TBM_LOG_E(fmt, ...) {\
-       if (bDlog) {\
-               LOGE("[TBM:E] " fmt, ##__VA_ARGS__);\
-       } \
-       else {\
-               fprintf(stderr, "[TBM:E(%d)(%s:%d)] " fmt, getpid(), __func__, __LINE__, ##__VA_ARGS__);\
-       } \
-}
-
-#define TBM_DEBUG(fmt, ...) {\
-       if (bDlog) {\
-               LOGE("[TBM_DEBUG] " fmt, ##__VA_ARGS__);\
-       } \
-       else {\
-               fprintf(stderr, "[TBM:DEBUG(%d)] " fmt, getpid(), ##__VA_ARGS__);\
-       } \
-}
-
-#ifdef TRACE
-#define TBM_TRACE(fmt, ...) {\
-       if (bDlog) {\
-               if (bTrace&0x1) LOGE("[TBM:TRACE] " fmt, ##__VA_ARGS__);\
-       } \
-       else {\
-               if (bTrace&0x1) fprintf(stderr, "[TBM:TRACE(%d)(%s:%d)] " fmt, getpid(), __func__, __LINE__, ##__VA_ARGS__);\
-       } \
-}
-#else
-#define TBM_TRACE(fmt, ...)
-#endif /* TRACE */
-
-#else
-#define TBM_LOG_D(fmt, ...)   fprintf(stderr, "[TBM:D(%d)(%s:%d)] " fmt, getpid(), __func__, __LINE__, ##__VA_ARGS__)
-#define TBM_LOG_I(fmt, ...)   fprintf(stderr, "[TBM:I(%d)(%s:%d)] " fmt, getpid(), __func__, __LINE__, ##__VA_ARGS__)
-#define TBM_LOG_W(fmt, ...)   fprintf(stderr, "[TBM:W(%d)(%s:%d)] " fmt, getpid(), __func__, __LINE__, ##__VA_ARGS__)
-#define TBM_LOG_E(fmt, ...)   fprintf(stderr, "[TBM:E(%d)(%s:%d)] " fmt, getpid(), __func__, __LINE__, ##__VA_ARGS__)
-#define TBM_DEBUG(fmt, ...)   fprintf(stderr, "[TBM:DEBUG(%d)] " fmt, getpid(), ##__VA_ARGS__)
-#ifdef TRACE
-#define TBM_TRACE(fmt, ...)   { if (bTrace&0x1) fprintf(stderr, "[TBM:TRACE(%d)(%s:%d)] " fmt, getpid(), __func__, __LINE__, ##__VA_ARGS__); }
-#else
-#define TBM_TRACE(fmt, ...)
-#endif /* TRACE */
-#endif /* HAVE_DLOG */
+extern int trace_mask;
 
 /* check condition */
 #define TBM_RETURN_IF_FAIL(cond) {\
        if (!(cond)) {\
-               TBM_LOG_E("'%s' failed.\n", #cond);\
+               TBM_ERR("'%s' failed.\n", #cond);\
                return;\
        } \
 }
 #define TBM_RETURN_VAL_IF_FAIL(cond, val) {\
        if (!(cond)) {\
-               TBM_LOG_E("'%s' failed.\n", #cond);\
+               TBM_ERR("'%s' failed.\n", #cond);\
                return val;\
        } \
 }
 #define TBM_GOTO_VAL_IF_FAIL(cond, val) {\
        if (!(cond)) {\
-               TBM_LOG_E("'%s' failed.\n", #cond);\
+               TBM_ERR("'%s' failed.\n", #cond);\
                goto val;\
        } \
 }
@@ -187,6 +93,62 @@ extern int bDlog;
        } \
 }
 
+#define TBM_TRACE_BO(fmt, args...) \
+       do { \
+               if (trace_mask&TBM_BUFGMR_DEBUG_TRACE_BO) { \
+                       struct timespec ts; \
+                       clock_gettime(CLOCK_MONOTONIC, &ts); \
+                       tbm_log_print(TBM_LOG_LEVEL_INFO, "[%5d.%06d][%d][%s %d](TRACE)"fmt, \
+                                                 (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \
+                                                 (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args);  \
+               } \
+       } while (0)
+
+#define TBM_TRACE_SURFACE_INTERNAL(fmt, args...) \
+       do { \
+               if (trace_mask&TBM_BUFGMR_DEBUG_TRACE_SURFACE_INTERNAL) { \
+                       struct timespec ts; \
+                       clock_gettime(CLOCK_MONOTONIC, &ts); \
+                       tbm_log_print(TBM_LOG_LEVEL_INFO, "[%5d.%06d][%d][%s %d](TRACE)"fmt, \
+                                                 (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \
+                                                 (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args);  \
+               } \
+       } while (0)
+
+#define TBM_TRACE_SURFACE(fmt, args...) \
+       do { \
+               if (trace_mask&TBM_BUFGMR_DEBUG_TRACE_SURFACE) { \
+                       struct timespec ts; \
+                       clock_gettime(CLOCK_MONOTONIC, &ts); \
+                       tbm_log_print(TBM_LOG_LEVEL_INFO, "[%5d.%06d][%d][%s %d](TRACE)"fmt, \
+                                                 (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \
+                                                 (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args);  \
+               } \
+       } while (0)
+
+#define TBM_TRACE_SURFACE_QUEUE(fmt, args...) \
+       do { \
+               if (trace_mask&TBM_BUFGMR_DEBUG_TRACE_SURFACE_QUEUE) { \
+                       struct timespec ts; \
+                       clock_gettime(CLOCK_MONOTONIC, &ts); \
+                       tbm_log_print(TBM_LOG_LEVEL_INFO, "[%5d.%06d][%d][%s %d](TRACE)"fmt, \
+                                                 (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \
+                                                 (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args);  \
+               } \
+       } while (0)
+
+#define TBM_TRACE(fmt, args...) \
+       do { \
+               if (trace_mask&0x1) { \
+                       struct timespec ts; \
+                       clock_gettime(CLOCK_MONOTONIC, &ts); \
+                       tbm_log_print(TBM_LOG_LEVEL_INFO, "[%5d.%06d][%d][%s %d](TRACE)"fmt, \
+                                                 (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \
+                                                 (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args);  \
+               } \
+       } while (0)
+
+
 /* check validation */
 #define TBM_BUFMGR_IS_VALID(mgr) (mgr && mgr == gBufMgr)
 #define TBM_BO_IS_VALID(bo) (bo && \
index ecd5653b7fc6668cbc23c98545441b29de9919c9..4139e1d7464ddc82450332abaedd52278afe7051 100644 (file)
@@ -103,7 +103,7 @@ tbm_drm_helper_get_auth_info(int *auth_fd, char **device, uint32_t *capabilities
 
        display = wl_display_connect("tbm-drm-auth");
        if (!display) {
-               TBM_LOG_E("Failed to connect display\n");
+               TBM_ERR("Failed to connect display\n");
                free(tbm_drm_client);
 
                return 0;
@@ -113,7 +113,7 @@ tbm_drm_helper_get_auth_info(int *auth_fd, char **device, uint32_t *capabilities
 
        wl_registry = wl_display_get_registry(display);
        if (!wl_registry) {
-               TBM_LOG_E("Failed to get registry\n");
+               TBM_ERR("Failed to get registry\n");
                wl_display_disconnect(display);
                free(tbm_drm_client);
 
@@ -122,7 +122,7 @@ tbm_drm_helper_get_auth_info(int *auth_fd, char **device, uint32_t *capabilities
 
        wl_registry_add_listener(wl_registry, &registry_listener, tbm_drm_client);
        if (wl_display_roundtrip(display) < 0) { //For Gloabl registry
-               TBM_LOG_E("Failed to wl_display_roundtrip for global registry\n");
+               TBM_ERR("Failed to wl_display_roundtrip for global registry\n");
                wl_registry_destroy(wl_registry);
                wl_display_disconnect(display);
                free(tbm_drm_client);
@@ -130,7 +130,7 @@ tbm_drm_helper_get_auth_info(int *auth_fd, char **device, uint32_t *capabilities
        }
 
        if (!tbm_drm_client->wl_tbm_drm_auth) {
-               TBM_LOG_E("Failed to get wl_tbm_drm_auth interface\n");
+               TBM_ERR("Failed to get wl_tbm_drm_auth interface\n");
                wl_registry_destroy(wl_registry);
                wl_display_disconnect(display);
                free(tbm_drm_client);
@@ -140,7 +140,7 @@ tbm_drm_helper_get_auth_info(int *auth_fd, char **device, uint32_t *capabilities
 
        wl_tbm_drm_auth_get_authentication_info(tbm_drm_client->wl_tbm_drm_auth);
        if (wl_display_roundtrip(display) < 0) {
-               TBM_LOG_E("Failed to wl_display_roundtrip get auth info\n");
+               TBM_ERR("Failed to wl_display_roundtrip get auth info\n");
                wl_tbm_drm_auth_set_user_data(tbm_drm_client->wl_tbm_drm_auth, NULL);
                wl_tbm_drm_auth_destroy(tbm_drm_client->wl_tbm_drm_auth);
                wl_registry_destroy(wl_registry);
@@ -150,7 +150,7 @@ tbm_drm_helper_get_auth_info(int *auth_fd, char **device, uint32_t *capabilities
        }
 
        if (tbm_drm_client->auth_fd < 0) {
-               TBM_LOG_E("Failed to get auth info\n");
+               TBM_ERR("Failed to get auth info\n");
                wl_tbm_drm_auth_set_user_data(tbm_drm_client->wl_tbm_drm_auth, NULL);
                wl_tbm_drm_auth_destroy(tbm_drm_client->wl_tbm_drm_auth);
                wl_registry_destroy(wl_registry);
@@ -199,23 +199,23 @@ tbm_drm_helper_set_fd(int fd)
                return;
 
        if (fd < 0 || fd > fd_max) {
-               TBM_LOG_E("%d out of fd range\n", fd);
+               TBM_ERR("%d out of fd range\n", fd);
                return;
        }
 
        if (tbm_drm_fd != -1)
-               TBM_LOG_W("already has TBM_DRM_FD: %d\n", tbm_drm_fd);
+               TBM_WRN("already has TBM_DRM_FD: %d\n", tbm_drm_fd);
 
        tbm_drm_fd = fd;
 
-       TBM_LOG_I("TBM_DRM_FD: %d\n", tbm_drm_fd);
+       TBM_INFO("TBM_DRM_FD: %d\n", tbm_drm_fd);
 }
 
 void
 tbm_drm_helper_unset_fd(void)
 {
        tbm_drm_fd = -1;
-       TBM_LOG_I("TBM_DRM_FD: %d\n", tbm_drm_fd);
+       TBM_INFO("TBM_DRM_FD: %d\n", tbm_drm_fd);
 }
 
 int
@@ -224,31 +224,31 @@ tbm_drm_helper_get_fd(void)
        int new_fd, flags;
 
        if (tbm_drm_fd == -1) {
-               TBM_LOG_E("no drm fd");
+               TBM_ERR("no drm fd");
                return -1;
        }
 
-       TBM_LOG_I("TBM_DRM_FD: %d\n", tbm_drm_fd);
+       TBM_INFO("TBM_DRM_FD: %d\n", tbm_drm_fd);
 
        flags = fcntl(tbm_drm_fd, F_GETFD);
        if (flags == -1) {
-               TBM_LOG_E("fcntl failed: %m");
+               TBM_ERR("fcntl failed: %m");
                return -1;
        }
 
        new_fd = dup(tbm_drm_fd);
        if (new_fd < 0) {
-               TBM_LOG_E("dup failed: %m");
+               TBM_ERR("dup failed: %m");
                return -1;
        }
 
        if (fcntl(new_fd, F_SETFD, flags|FD_CLOEXEC) == -1) {
-               TBM_LOG_E("failed to set fd\n");
+               TBM_ERR("failed to set fd\n");
                close(new_fd);
                return -1;
        }
 
-       TBM_LOG_I("Return TBM_FD: %d\n", new_fd);
+       TBM_INFO("Return TBM_FD: %d\n", new_fd);
 
        return new_fd;
 }
index cb6254e5ced6841b56ef8fdd48a702a42a98f401..9182fa5279d11ccc3af99375c1b292ab391f2d0e 100644 (file)
@@ -70,14 +70,14 @@ _send_server_auth_info(struct wayland_tbm_drm_auth_server *tbm_drm_auth_srv,
                fd = open(tbm_drm_auth_srv->device_name, O_RDWR);
                if (fd != -1) {
                        if (fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC) == -1) {
-                               TBM_LOG_E("failed to set fd\n");
+                               TBM_ERR("failed to set fd\n");
                                goto fini;
                        }
                }
        }
 
        if (fd < 0) {
-               TBM_LOG_E("failed to open drm : device_name, %s\n", tbm_drm_auth_srv->device_name);
+               TBM_ERR("failed to open drm : device_name, %s\n", tbm_drm_auth_srv->device_name);
 
                wl_resource_post_error(resource, WL_TBM_DRM_AUTH_ERROR_AUTHENTICATE_FAIL,
                                       "authenicate failed::open_drm");
@@ -86,7 +86,7 @@ _send_server_auth_info(struct wayland_tbm_drm_auth_server *tbm_drm_auth_srv,
 
        if (drmGetMagic(fd, &magic) < 0) {
                if (errno != EACCES) {
-                       TBM_LOG_E("failed to get magic\n");
+                       TBM_ERR("failed to get magic\n");
 
                        wl_resource_post_error(resource, WL_TBM_DRM_AUTH_ERROR_AUTHENTICATE_FAIL,
                                               "authenicate failed::get_magic");
@@ -95,7 +95,7 @@ _send_server_auth_info(struct wayland_tbm_drm_auth_server *tbm_drm_auth_srv,
        }
 
        if (drmAuthMagic(tbm_drm_auth_srv->fd, magic) < 0) {
-               TBM_LOG_E("failed to authenticate magic\n");
+               TBM_ERR("failed to authenticate magic\n");
 
                wl_resource_post_error(resource, WL_TBM_DRM_AUTH_ERROR_AUTHENTICATE_FAIL,
                                       "authenicate failed::auth_magic");
@@ -167,24 +167,24 @@ _tbm_getgrnam_r(const char *name)
 
        buf = calloc(1, buf_len * sizeof(char));
        if (!buf) {
-               TBM_LOG_E("creating buffer failed\n");
+               TBM_ERR("creating buffer failed\n");
                goto failed;
        }
 
        grp = calloc(1, sizeof(struct group));
        if (!grp) {
-               TBM_LOG_E("creating group failed\n");
+               TBM_ERR("creating group failed\n");
                goto failed;
        }
 
        ret = getgrnam_r(name, grp, buf, buf_len, &grp_res);
        if (ret < 0) {
-               TBM_LOG_E("getgrnam_r failed errno:%d(%m)\n", ret);
+               TBM_ERR("getgrnam_r failed errno:%d(%m)\n", ret);
                goto failed;
        }
 
        if (grp_res == NULL) {
-               TBM_LOG_E("finding name:%s group failed\n", name);
+               TBM_ERR("finding name:%s group failed\n", name);
                goto failed;
        }
 
@@ -214,7 +214,7 @@ _tbm_drm_auth_socket_init(struct wayland_tbm_drm_auth_server *tbm_drm_auth_srv)
 
        dir = getenv("XDG_RUNTIME_DIR");
        if (!dir) {
-               TBM_LOG_W("getting XDG_RUNTIME_DIR failed\n");
+               TBM_WRN("getting XDG_RUNTIME_DIR failed\n");
                return;
        }
 
@@ -222,27 +222,27 @@ _tbm_drm_auth_socket_init(struct wayland_tbm_drm_auth_server *tbm_drm_auth_srv)
 
        ret = chmod(socket_path, 509);
        if (ret < 0) {
-               TBM_LOG_W("changing modes of socket file failed:%s (%m)\n", socket_path);
+               TBM_WRN("changing modes of socket file failed:%s (%m)\n", socket_path);
                return;
        }
 
        ret = _tbm_getgrnam_r("root");
        if (ret < 0) {
-               TBM_LOG_W("getting uid failed\n");
+               TBM_WRN("getting uid failed\n");
                return;
        }
        uid = ret;
 
        ret = _tbm_getgrnam_r("display");
        if (ret < 0) {
-               TBM_LOG_W("getting gid failed\n");
+               TBM_WRN("getting gid failed\n");
                return;
        }
        gid = ret;
 
        ret = chown(socket_path, uid, gid);
        if (ret < 0) {
-               TBM_LOG_W("changing owner of socket file failed:%s (%m)\n", socket_path);
+               TBM_WRN("changing owner of socket file failed:%s (%m)\n", socket_path);
                return;
        }
 }
@@ -262,7 +262,7 @@ tbm_drm_helper_wl_auth_server_init(void *wl_display,   int fd, const char *devic
                tbm_drm_auth_srv->flags = flags;
 
                if (wl_display_add_socket(tbm_drm_auth_srv->display, "tbm-drm-auth")) {
-                       TBM_LOG_E("[TBM_DRM] fail to add socket\n");
+                       TBM_ERR("[TBM_DRM] fail to add socket\n");
 
                        if (tbm_drm_auth_srv->device_name)
                                free(tbm_drm_auth_srv->device_name);
@@ -309,25 +309,25 @@ tbm_drm_helper_get_master_fd(void)
                const long int sl = strtol(value, &end, 10);
 
                if (end == value) {
-                       TBM_LOG_E("%s: not a decimal number\n", value);
+                       TBM_ERR("%s: not a decimal number\n", value);
                        return -1;
                } else if (*end != '\0') {
-                       TBM_LOG_E("%s: extra characters at end of input: %s\n", value, end);
+                       TBM_ERR("%s: extra characters at end of input: %s\n", value, end);
                        return -1;
                } else if ((sl == LONG_MIN || sl == LONG_MAX) && errno == ERANGE) {
-                       TBM_LOG_E("%s out of range of type long\n", value);
+                       TBM_ERR("%s out of range of type long\n", value);
                        return -1;
                } else if (sl >= INT_MAX) {
-                       TBM_LOG_E("%ld greater than INT_MAX\n", sl);
+                       TBM_ERR("%ld greater than INT_MAX\n", sl);
                        return -1;
                } else if (sl <= INT_MIN) {
-                       TBM_LOG_E("%ld less than INT_MIN\n", sl);
+                       TBM_ERR("%ld less than INT_MIN\n", sl);
                        return -1;
                } else {
                        int fd_max = tbm_bufmgr_get_fd_limit();
                        fd = (int)sl;
                        if (fd < 0 || fd > fd_max) {
-                               TBM_LOG_E("%d out of fd range\n", fd);
+                               TBM_ERR("%d out of fd range\n", fd);
                                return -1;
                        }
                }
@@ -336,31 +336,31 @@ tbm_drm_helper_get_master_fd(void)
        fd = tbm_drm_master_fd;
 
        if (fd == -1) {
-               TBM_LOG_I("no presetted TBM DRM MASTER FD");
+               TBM_INFO("no presetted TBM DRM MASTER FD");
                return -1;
        }
 
-       TBM_LOG_I("TBM DRM MASTER FD: %d\n", fd);
+       TBM_INFO("TBM DRM MASTER FD: %d\n", fd);
 
        flags = fcntl(fd, F_GETFD);
        if (flags == -1) {
-               TBM_LOG_E("fcntl failed: %m");
+               TBM_ERR("fcntl failed: %m");
                return -1;
        }
 
        new_fd = dup(fd);
        if (new_fd < 0) {
-               TBM_LOG_E("dup failed: %m");
+               TBM_ERR("dup failed: %m");
                return -1;
        }
 
        if (fcntl(new_fd, F_SETFD, flags|FD_CLOEXEC) == -1) {
-               TBM_LOG_E("failed to set fd\n");
+               TBM_ERR("failed to set fd\n");
                close(new_fd);
                return -1;
        }
 
-       TBM_LOG_I("Return MASTER_FD: %d\n", new_fd);
+       TBM_INFO("Return MASTER_FD: %d\n", new_fd);
 
        return new_fd;
 }
@@ -374,23 +374,23 @@ tbm_drm_helper_set_tbm_master_fd(int fd)
                return;
 
        if (fd < 0 || fd > fd_max) {
-               TBM_LOG_E("%d out of fd range\n", fd);
+               TBM_ERR("%d out of fd range\n", fd);
                return;
        }
 
        if (tbm_drm_master_fd != -1)
-               TBM_LOG_W("already has TBM DRM MASTER FD: %d\n", tbm_drm_master_fd);
+               TBM_WRN("already has TBM DRM MASTER FD: %d\n", tbm_drm_master_fd);
 
        tbm_drm_master_fd = fd;
 
-       TBM_LOG_I("TBM DRM MASTER FD: %d\n", tbm_drm_master_fd);
+       TBM_INFO("TBM DRM MASTER FD: %d\n", tbm_drm_master_fd);
 }
 
 void
 tbm_drm_helper_unset_tbm_master_fd(void)
 {
        tbm_drm_master_fd = -1;
-       TBM_LOG_I("TBM DRM MASTER FD: %d\n", tbm_drm_master_fd);
+       TBM_INFO("TBM DRM MASTER FD: %d\n", tbm_drm_master_fd);
 }
 /* LCOV_EXCL_STOP */
 
diff --git a/src/tbm_log.c b/src/tbm_log.c
new file mode 100644 (file)
index 0000000..e4fcd22
--- /dev/null
@@ -0,0 +1,230 @@
+/**************************************************************************
+
+libtbm
+
+Copyright 2018 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: SooChan Lim <sc1.lim@samsung.com>, Sangjin Lee <lsj119@samsung.com>
+Boram Park <boram1288.park@samsung.com>, Changyeon Lee <cyeon.lee@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "tbm_bufmgr_int.h"
+#include "tbm_log.h"
+
+#define TBM_PATH_LEN        1024
+
+#define COLOR_RED "\x1b[31m"      /* for error */
+#define COLOR_YELLOW "\x1b[33m"   /* for warning */
+#define COLOR_GREEN "\x1b[32m"    /* for info */
+#define COLOR_RESET "\x1b[0m"
+
+#undef LOG_TAG
+#define LOG_TAG "TBM"
+
+static unsigned int dlog_enable = 1;
+static unsigned int color_enable = 1;
+
+static unsigned int assert_level = TBM_LOG_LEVEL_NONE;
+
+static unsigned int log_lock_init;
+static pthread_mutex_t log_lock;
+
+unsigned int tbm_log_debug_level = TBM_LOG_LEVEL_INFO;
+
+static int stdout_fd = -1;
+
+void
+tbm_log_enable_color(unsigned int enable)
+{
+       color_enable = enable;
+}
+
+void
+tbm_log_enable_dlog(unsigned int enable)
+{
+       const char *str = getenv("TBM_DLOG");
+       if (str)
+               enable = (str[0] == '1') ? 1 : 0;
+       dlog_enable = enable;
+}
+
+void
+tbm_log_enable_debug(unsigned int enable)
+{
+       if (enable)
+               tbm_log_debug_level = TBM_LOG_LEVEL_DBG;
+       else
+               tbm_log_debug_level = TBM_LOG_LEVEL_INFO;
+}
+
+void
+tbm_log_set_debug_level(int level)
+{
+       tbm_log_debug_level = level;
+}
+
+void
+tbm_log_set_assert_level(int level)
+{
+       assert_level = level;
+}
+
+void
+tbm_log_set_path(const char *path)
+{
+       if (!path) {
+               if (stdout_fd != -1) {
+                       fflush(stdout);
+                       close(STDOUT_FILENO);
+                       dup2(stdout_fd, STDOUT_FILENO);
+                       close(stdout_fd);
+                       stdout_fd = -1;
+               }
+       } else {
+               char fd_name[TBM_PATH_LEN];
+               int  log_fd = -1;
+               FILE *log_fl;
+
+               snprintf(fd_name, TBM_PATH_LEN, "%s", path);
+
+               log_fl = fopen(fd_name, "a");
+               if (!log_fl) {
+                       TBM_ERR("failed: open file(%s)\n", fd_name);
+                       return;
+               }
+
+               if (stdout_fd == -1) {
+                       fflush(stdout);
+                       stdout_fd = dup(STDOUT_FILENO);
+                       if (stdout_fd < 0) {
+                               TBM_ERR("dup failed: %m\n");
+                               fclose(log_fl);
+                               return;
+                       }
+               }
+
+               setvbuf(log_fl, NULL, _IOLBF, 512);
+               log_fd = fileno(log_fl);
+
+               close(STDOUT_FILENO);
+               dup2(log_fd, STDOUT_FILENO);
+               fclose(log_fl);
+       }
+}
+
+static void
+_tbm_log_vprint_stdout(int level, const char *fmt, va_list arg)
+{
+       char *lvl_str[] = {"TBM_NON", "TBM_ERR", "TBM_WRN", "TBM_INF", "TBM_DBG"};
+       char *color[] = {COLOR_RESET, COLOR_RED, COLOR_YELLOW, COLOR_GREEN, COLOR_RESET};
+
+       if (!log_lock_init) {
+               log_lock_init = 1;
+               pthread_mutex_init(&log_lock, NULL);
+       }
+
+       if (level > tbm_log_debug_level)
+               return;
+
+       pthread_mutex_lock(&log_lock);
+
+       if (color_enable)
+               printf("%s", color[level]);
+       printf("[%s]", lvl_str[level]);
+       if (color_enable)
+               printf(COLOR_RESET);
+       vprintf(fmt, arg);
+       printf("\n");
+       pthread_mutex_unlock(&log_lock);
+}
+
+void
+tbm_log_print_stdout(int level, const char *fmt, ...)
+{
+       va_list arg;
+       va_start(arg, fmt);
+       _tbm_log_vprint_stdout(level, fmt, arg);
+       va_end(arg);
+}
+
+static void
+_tbm_log_dlog_print(int level, const char *fmt, va_list arg)
+{
+       log_priority dlog_prio;
+
+       switch (level) {
+       case TBM_LOG_LEVEL_ERR:
+               dlog_prio = DLOG_ERROR;
+               break;
+       case TBM_LOG_LEVEL_WRN:
+               dlog_prio = DLOG_WARN;
+               break;
+       case TBM_LOG_LEVEL_INFO:
+               dlog_prio = DLOG_INFO;
+               break;
+       case TBM_LOG_LEVEL_DBG:
+               dlog_prio = DLOG_DEBUG;
+               break;
+       default:
+               return;
+       }
+       __dlog_vprint(LOG_ID_SYSTEM, dlog_prio, LOG_TAG, fmt, arg);
+}
+
+void
+tbm_log_print(int level, const char *fmt, ...)
+{
+       va_list arg;
+
+       if (!log_lock_init) {
+               log_lock_init = 1;
+               pthread_mutex_init(&log_lock, NULL);
+       }
+
+       if (level > tbm_log_debug_level)
+               return;
+
+       if (dlog_enable) {
+               va_start(arg, fmt);
+               _tbm_log_dlog_print(level, fmt, arg);
+               va_end(arg);
+       } else {
+               va_start(arg, fmt);
+               _tbm_log_vprint_stdout(level, fmt, arg);
+               va_end(arg);
+       }
+
+       assert(level > assert_level);
+}
+
+void
+tbm_log_reset(void)
+{
+       pthread_mutex_trylock(&log_lock);
+       pthread_mutex_unlock(&log_lock);
+}
diff --git a/src/tbm_log.h b/src/tbm_log.h
new file mode 100644 (file)
index 0000000..97a819c
--- /dev/null
@@ -0,0 +1,113 @@
+/**************************************************************************
+
+libtbm
+
+Copyright 2018 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact: SooChan Lim <sc1.lim@samsung.com>, Sangjin Lee <lsj119@samsung.com>
+Boram Park <boram1288.park@samsung.com>, Changyeon Lee <cyeon.lee@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef _TBM_LOG_H_
+#define _TBM_LOG_H_
+
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <time.h>
+#include <dlog.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file tbm_log.h
+ * @brief The header file to print logs in frontend and backend modules
+ * @details
+ */
+
+enum {
+       TBM_LOG_LEVEL_NONE,
+       TBM_LOG_LEVEL_ERR,
+       TBM_LOG_LEVEL_WRN,
+       TBM_LOG_LEVEL_INFO,
+       TBM_LOG_LEVEL_DBG,
+};
+
+void tbm_log_enable_color(unsigned int enable);
+void tbm_log_enable_dlog(unsigned int enable);
+void tbm_log_enable_debug(unsigned int enable);
+void tbm_log_set_debug_level(int level);
+void tbm_log_set_assert_level(int level);
+void tbm_log_set_path(const char *path);
+void tbm_log_print(int level, const char *fmt, ...);
+void tbm_log_reset(void);
+
+#define TBM_DBG(fmt, args...) \
+       do { \
+               struct timespec ts; \
+               clock_gettime(CLOCK_MONOTONIC, &ts); \
+               tbm_log_print(TBM_LOG_LEVEL_DBG, "[%5d.%06d][%d][%s %d]"fmt, \
+                                         (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \
+                                         (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args);  \
+       } while (0)
+#define TBM_INFO(fmt, args...) \
+       do { \
+               struct timespec ts; \
+               clock_gettime(CLOCK_MONOTONIC, &ts); \
+               tbm_log_print(TBM_LOG_LEVEL_INFO, "[%5d.%06d][%d][%s %d]"fmt, \
+                                         (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \
+                                         (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args);  \
+       } while (0)
+#define TBM_WRN(fmt, args...) \
+       do { \
+               struct timespec ts; \
+               clock_gettime(CLOCK_MONOTONIC, &ts); \
+               tbm_log_print(TBM_LOG_LEVEL_WRN, "[%5d.%06d][%d][%s %d]"fmt, \
+                                         (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \
+                                         (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args);  \
+       } while (0)
+#define TBM_ERR(fmt, args...) \
+       do { \
+               struct timespec ts; \
+               clock_gettime(CLOCK_MONOTONIC, &ts); \
+               tbm_log_print(TBM_LOG_LEVEL_ERR, "[%5d.%06d][%d][%s %d]"fmt, \
+                                         (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \
+                                         (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args);  \
+       } while (0)
+
+#define TBM_NEVER_GET_HERE() TBM_WRN("** NEVER GET HERE **")
+#define TBM_DEPRECATED(str) \
+       do { \
+               if (str) \
+                       TBM_WRN("** DEPRECATED: %s **", str); \
+               else \
+                       TBM_WRN("** DEPRECATED **"); \
+       } while(0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _TBM_LOG_H_ */
index a05ae06ccdff10491cbca5075357cdb54a9f2322..1ca367e6010c3a873327ca151f093912e5a6b811 100644 (file)
@@ -38,7 +38,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 int
 tbm_surface_query_formats(uint32_t **formats, uint32_t *num)
 {
-       TBM_TRACE("\n");
+       TBM_TRACE_SURFACE("\n");
 
        if (!tbm_surface_internal_query_supported_formats(formats, num))
                return TBM_SURFACE_ERROR_INVALID_OPERATION;
@@ -49,7 +49,7 @@ tbm_surface_query_formats(uint32_t **formats, uint32_t *num)
 tbm_surface_h
 tbm_surface_create(int width, int height, tbm_format format)
 {
-       TBM_TRACE("width(%d) height(%d)\n", width, height);
+       TBM_TRACE_SURFACE("width(%d) height(%d)\n", width, height);
 
        if (!(width > 0) || !(height > 0)) {
 #ifdef HAVE_CAPI_0_1_1
@@ -77,7 +77,7 @@ tbm_surface_create(int width, int height, tbm_format format)
 int
 tbm_surface_destroy(tbm_surface_h surface)
 {
-       TBM_TRACE("tbm_surface(%p)\n", surface);
+       TBM_TRACE_SURFACE("tbm_surface(%p)\n", surface);
 
        TBM_RETURN_VAL_IF_FAIL(surface, TBM_SURFACE_ERROR_INVALID_PARAMETER);
 
@@ -89,7 +89,7 @@ tbm_surface_destroy(tbm_surface_h surface)
 int
 tbm_surface_map(tbm_surface_h surface, int opt, tbm_surface_info_s *info)
 {
-       TBM_TRACE("tbm_surface(%p)\n", surface);
+       TBM_TRACE_SURFACE("tbm_surface(%p)\n", surface);
 
        TBM_RETURN_VAL_IF_FAIL(surface, TBM_SURFACE_ERROR_INVALID_PARAMETER);
        TBM_RETURN_VAL_IF_FAIL(info != NULL, TBM_SURFACE_ERROR_INVALID_PARAMETER);
@@ -106,7 +106,7 @@ tbm_surface_map(tbm_surface_h surface, int opt, tbm_surface_info_s *info)
 int
 tbm_surface_unmap(tbm_surface_h surface)
 {
-       TBM_TRACE("tbm_surface(%p)\n", surface);
+       TBM_TRACE_SURFACE("tbm_surface(%p)\n", surface);
 
        TBM_RETURN_VAL_IF_FAIL(surface, TBM_SURFACE_ERROR_INVALID_PARAMETER);
 
@@ -118,7 +118,7 @@ tbm_surface_unmap(tbm_surface_h surface)
 int
 tbm_surface_get_info(tbm_surface_h surface, tbm_surface_info_s *info)
 {
-       TBM_TRACE("tbm_surface(%p)\n", surface);
+       TBM_TRACE_SURFACE("tbm_surface(%p)\n", surface);
 
        TBM_RETURN_VAL_IF_FAIL(surface, TBM_SURFACE_ERROR_INVALID_PARAMETER);
        TBM_RETURN_VAL_IF_FAIL(info != NULL, TBM_SURFACE_ERROR_INVALID_PARAMETER);
@@ -135,7 +135,7 @@ tbm_surface_get_info(tbm_surface_h surface, tbm_surface_info_s *info)
 int
 tbm_surface_get_width(tbm_surface_h surface)
 {
-       TBM_TRACE("tbm_surface(%p)\n", surface);
+       TBM_TRACE_SURFACE("tbm_surface(%p)\n", surface);
 
        TBM_RETURN_VAL_IF_FAIL(surface, TBM_SURFACE_ERROR_INVALID_PARAMETER);
 
@@ -145,7 +145,7 @@ tbm_surface_get_width(tbm_surface_h surface)
 int
 tbm_surface_get_height(tbm_surface_h surface)
 {
-       TBM_TRACE("tbm_surface(%p)\n", surface);
+       TBM_TRACE_SURFACE("tbm_surface(%p)\n", surface);
 
        TBM_RETURN_VAL_IF_FAIL(surface, TBM_SURFACE_ERROR_INVALID_PARAMETER);
 
@@ -155,7 +155,7 @@ tbm_surface_get_height(tbm_surface_h surface)
 tbm_format
 tbm_surface_get_format(tbm_surface_h surface)
 {
-       TBM_TRACE("tbm_surface(%p)\n", surface);
+       TBM_TRACE_SURFACE("tbm_surface(%p)\n", surface);
 
        if (!surface) {
 #ifdef HAVE_CAPI_0_1_1
index 5d9d91bec69cd36b12647298e6dea1583811728b..d4cdaf1604e4aa4b16028e6916b1883a8d442152 100644 (file)
@@ -54,7 +54,7 @@ void _tbm_surface_mutex_unlock(void);
 /* check condition */
 #define TBM_SURFACE_RETURN_IF_FAIL(cond) {\
        if (!(cond)) {\
-               TBM_LOG_E("'%s' failed.\n", #cond);\
+               TBM_ERR("'%s' failed.\n", #cond);\
                _tbm_surface_mutex_unlock();\
                return;\
        } \
@@ -62,7 +62,7 @@ void _tbm_surface_mutex_unlock(void);
 
 #define TBM_SURFACE_RETURN_VAL_IF_FAIL(cond, val) {\
        if (!(cond)) {\
-               TBM_LOG_E("'%s' failed.\n", #cond);\
+               TBM_ERR("'%s' failed.\n", #cond);\
                _tbm_surface_mutex_unlock();\
                return val;\
        } \
@@ -227,7 +227,7 @@ _tbm_surface_mutex_init(void)
                return true;
 
        if (pthread_mutex_init(&tbm_surface_lock, NULL)) {
-               TBM_LOG_E("fail: pthread_mutex_init for tbm_surface_lock.\n");
+               TBM_ERR("fail: pthread_mutex_init for tbm_surface_lock.\n");
                return false;
        }
 
@@ -240,7 +240,7 @@ void
 _tbm_surface_mutex_lock(void)
 {
        if (!_tbm_surface_mutex_init()) {
-               TBM_LOG_E("fail: _tbm_surface_mutex_init.\n");
+               TBM_ERR("fail: _tbm_surface_mutex_init.\n");
                return;
        }
 
@@ -281,13 +281,13 @@ _tbm_surface_internal_is_valid(tbm_surface_h surface)
        if (!LIST_IS_EMPTY(&g_surface_bufmgr->surf_list)) {
                LIST_FOR_EACH_ENTRY(old_data, &g_surface_bufmgr->surf_list, item_link) {
                        if (old_data == surface) {
-                               TBM_TRACE("tbm_surface(%p)\n", surface);
+                               TBM_TRACE_SURFACE_INTERNAL("tbm_surface(%p)\n", surface);
                                return 1;
                        }
                }
        }
 
-       TBM_LOG_E("error: No valid tbm_surface(%p)\n", surface);
+       TBM_ERR("error: No valid tbm_surface(%p)\n", surface);
 
        return 0;
 }
@@ -315,7 +315,7 @@ _tbm_surface_internal_query_plane_data(tbm_surface_h surface,
                        surf->info.height, surf->info.format, plane_idx, size, offset, pitch, bo_idx);
        if (!ret) {
                /* LCOV_EXCL_START */
-               TBM_LOG_E("Fail to surface_get_plane_data. surface(%p)\n", surface);
+               TBM_ERR("Fail to surface_get_plane_data. surface(%p)\n", surface);
                return 0;
                /* LCOV_EXCL_STOP */
        }
@@ -435,12 +435,12 @@ tbm_surface_internal_query_supported_formats(uint32_t **formats,
        ret = bufmgr->backend->surface_supported_format(formats, num);
        if (!ret)  {
                /* LCOV_EXCL_START */
-               TBM_LOG_E("Fail to surface_supported_format.\n");
+               TBM_ERR("Fail to surface_supported_format.\n");
                goto fail;
                /* LCOV_EXCL_START */
        }
 
-       TBM_TRACE("tbm_bufmgr(%p) format num(%u)\n", g_surface_bufmgr, *num);
+       TBM_TRACE_SURFACE_INTERNAL("tbm_bufmgr(%p) format num(%u)\n", g_surface_bufmgr, *num);
 
        if (bufmgr_initialized) {
                LIST_DELINIT(&g_surface_bufmgr->surf_list);
@@ -459,7 +459,7 @@ fail:
        }
        _tbm_surface_mutex_unlock();
 
-       TBM_LOG_E("error: tbm_bufmgr(%p)\n", g_surface_bufmgr);
+       TBM_ERR("error: tbm_bufmgr(%p)\n", g_surface_bufmgr);
 
        return 0;
 /* LCOV_EXCL_STOP */
@@ -541,7 +541,7 @@ tbm_surface_internal_get_num_planes(tbm_format format)
                break;
        }
 
-       TBM_TRACE("tbm_format(%s) num_planes(%d)\n", _tbm_surface_internal_format_to_str(format), num_planes);
+       TBM_TRACE_SURFACE_INTERNAL("tbm_format(%s) num_planes(%d)\n", _tbm_surface_internal_format_to_str(format), num_planes);
 
        return num_planes;
 }
@@ -636,7 +636,7 @@ tbm_surface_internal_get_bpp(tbm_format format)
                break;
        }
 
-       TBM_TRACE("tbm_format(%s) bpp(%d)\n", _tbm_surface_internal_format_to_str(format), bpp);
+       TBM_TRACE_SURFACE_INTERNAL("tbm_format(%s) bpp(%d)\n", _tbm_surface_internal_format_to_str(format), bpp);
 
        return bpp;
 }
@@ -668,14 +668,14 @@ tbm_surface_internal_create_with_flags(int width, int height,
 
        mgr = g_surface_bufmgr;
        if (!TBM_BUFMGR_IS_VALID(mgr)) {
-               TBM_LOG_E("The bufmgr is invalid\n");
+               TBM_ERR("The bufmgr is invalid\n");
                goto check_valid_fail;
        }
 
        surf = calloc(1, sizeof(struct _tbm_surface));
        if (!surf) {
                /* LCOV_EXCL_START */
-               TBM_LOG_E("fail to alloc surf\n");
+               TBM_ERR("fail to alloc surf\n");
                goto alloc_surf_fail;
                /* LCOV_EXCL_STOP */
        }
@@ -692,7 +692,7 @@ tbm_surface_internal_create_with_flags(int width, int height,
        for (i = 0; i < surf->info.num_planes; i++) {
                if (!_tbm_surface_internal_query_plane_data(surf, i, &size,
                                                &offset, &stride, &bo_idx)) {
-                       TBM_LOG_E("fail to query plane data\n");
+                       TBM_ERR("fail to query plane data\n");
                        goto query_plane_data_fail;
                }
 
@@ -727,7 +727,7 @@ tbm_surface_internal_create_with_flags(int width, int height,
 
                        bo = calloc(1, sizeof(struct _tbm_bo));
                        if (!bo) {
-                               TBM_LOG_E("fail to alloc bo struct\n");
+                               TBM_ERR("fail to alloc bo struct\n");
                                goto alloc_bo_fail;
                        }
 
@@ -737,7 +737,7 @@ tbm_surface_internal_create_with_flags(int width, int height,
 
                        bo_priv = mgr->backend->surface_bo_alloc(bo, width, height, format, flags, i);
                        if (!bo_priv) {
-                               TBM_LOG_E("fail to alloc bo priv\n");
+                               TBM_ERR("fail to alloc bo priv\n");
                                free(bo);
                                pthread_mutex_unlock(&surf->bufmgr->lock);
                                goto alloc_bo_fail;
@@ -758,7 +758,7 @@ tbm_surface_internal_create_with_flags(int width, int height,
                } else {
                        surf->bos[i] = tbm_bo_alloc(mgr, bo_size, flags);
                        if (!surf->bos[i]) {
-                               TBM_LOG_E("fail to alloc bo idx:%d\n", i);
+                               TBM_ERR("fail to alloc bo idx:%d\n", i);
                                goto alloc_bo_fail;
                        }
                }
@@ -766,7 +766,7 @@ tbm_surface_internal_create_with_flags(int width, int height,
                _tbm_bo_set_surface(surf->bos[i], surf);
        }
 
-       TBM_TRACE("width(%d) height(%d) format(%s) flags(%d) tbm_surface(%p)\n", width, height,
+       TBM_TRACE_SURFACE_INTERNAL("width(%d) height(%d) format(%s) flags(%d) tbm_surface(%p)\n", width, height,
                        _tbm_surface_internal_format_to_str(format), flags, surf);
 
        LIST_INITHEAD(&surf->user_data_list);
@@ -794,7 +794,7 @@ check_valid_fail:
        }
        _tbm_surface_mutex_unlock();
 
-       TBM_LOG_E("error: width(%d) height(%d) format(%s) flags(%d)\n",
+       TBM_ERR("error: width(%d) height(%d) format(%s) flags(%d)\n",
                        width, height,
                        _tbm_surface_internal_format_to_str(format), flags);
 /* LCOV_EXCL_STOP */
@@ -827,14 +827,14 @@ tbm_surface_internal_create_with_bos(tbm_surface_info_s *info,
 
        mgr = g_surface_bufmgr;
        if (!TBM_BUFMGR_IS_VALID(mgr)) {
-               TBM_LOG_E("fail to validate the Bufmgr.\n");
+               TBM_ERR("fail to validate the Bufmgr.\n");
                goto check_valid_fail;
        }
 
        surf = calloc(1, sizeof(struct _tbm_surface));
        if (!surf) {
                /* LCOV_EXCL_START */
-               TBM_LOG_E("fail to allocate struct _tbm_surface.\n");
+               TBM_ERR("fail to allocate struct _tbm_surface.\n");
                goto alloc_surf_fail;
                /* LCOV_EXCL_STOP */
        }
@@ -885,7 +885,7 @@ tbm_surface_internal_create_with_bos(tbm_surface_info_s *info,
        surf->num_bos = num;
        for (i = 0; i < num; i++) {
                if (bos[i] == NULL) {
-                       TBM_LOG_E("bos[%d] is null.\n", i);
+                       TBM_ERR("bos[%d] is null.\n", i);
                        goto check_bo_fail;
                }
 
@@ -893,7 +893,7 @@ tbm_surface_internal_create_with_bos(tbm_surface_info_s *info,
                _tbm_bo_set_surface(bos[i], surf);
        }
 
-       TBM_TRACE("tbm_surface(%p) width(%u) height(%u) format(%s) bo_num(%d)\n", surf,
+       TBM_TRACE_SURFACE_INTERNAL("tbm_surface(%p) width(%u) height(%u) format(%s) bo_num(%d)\n", surf,
                        info->width, info->height, _tbm_surface_internal_format_to_str(info->format), num);
 
        LIST_INITHEAD(&surf->user_data_list);
@@ -920,7 +920,7 @@ check_valid_fail:
        }
        _tbm_surface_mutex_unlock();
 
-       TBM_LOG_E("error: width(%u) height(%u) format(%s) bo_num(%d)\n",
+       TBM_ERR("error: width(%u) height(%u) format(%s) bo_num(%d)\n",
                        info->width, info->height,
                        _tbm_surface_internal_format_to_str(info->format), num);
 /* LCOV_EXCL_STOP */
@@ -938,12 +938,12 @@ tbm_surface_internal_destroy(tbm_surface_h surface)
        surface->refcnt--;
 
        if (surface->refcnt > 0) {
-               TBM_TRACE("reduce a refcnt(%d) of tbm_surface(%p)\n", surface->refcnt, surface);
+               TBM_TRACE_SURFACE_INTERNAL("reduce a refcnt(%d) of tbm_surface(%p)\n", surface->refcnt, surface);
                _tbm_surface_mutex_unlock();
                return;
        }
 
-       TBM_TRACE("destroy tbm_surface(%p) refcnt(%d)\n", surface, surface->refcnt);
+       TBM_TRACE_SURFACE_INTERNAL("destroy tbm_surface(%p) refcnt(%d)\n", surface, surface->refcnt);
 
        if (surface->refcnt == 0)
                _tbm_surface_internal_destroy(surface);
@@ -960,7 +960,7 @@ tbm_surface_internal_ref(tbm_surface_h surface)
 
        surface->refcnt++;
 
-       TBM_TRACE("tbm_surface(%p) refcnt(%d)\n", surface, surface->refcnt);
+       TBM_TRACE_SURFACE_INTERNAL("tbm_surface(%p) refcnt(%d)\n", surface, surface->refcnt);
 
        _tbm_surface_mutex_unlock();
 }
@@ -975,12 +975,12 @@ tbm_surface_internal_unref(tbm_surface_h surface)
        surface->refcnt--;
 
        if (surface->refcnt > 0) {
-               TBM_TRACE("reduce a refcnt(%d) of tbm_surface(%p)\n", surface->refcnt, surface);
+               TBM_TRACE_SURFACE_INTERNAL("reduce a refcnt(%d) of tbm_surface(%p)\n", surface->refcnt, surface);
                _tbm_surface_mutex_unlock();
                return;
        }
 
-       TBM_TRACE("destroy tbm_surface(%p) refcnt(%d)\n", surface, surface->refcnt);
+       TBM_TRACE_SURFACE_INTERNAL("destroy tbm_surface(%p) refcnt(%d)\n", surface, surface->refcnt);
 
        if (surface->refcnt == 0)
                _tbm_surface_internal_destroy(surface);
@@ -1001,7 +1001,7 @@ tbm_surface_internal_get_num_bos(tbm_surface_h surface)
        surf = (struct _tbm_surface *)surface;
        num = surf->num_bos;
 
-       TBM_TRACE("tbm_surface(%p) num_bos(%d)\n", surface, num);
+       TBM_TRACE_SURFACE_INTERNAL("tbm_surface(%p) num_bos(%d)\n", surface, num);
 
        _tbm_surface_mutex_unlock();
 
@@ -1022,7 +1022,7 @@ tbm_surface_internal_get_bo(tbm_surface_h surface, int bo_idx)
        surf = (struct _tbm_surface *)surface;
        bo = surf->bos[bo_idx];
 
-       TBM_TRACE("tbm_surface(%p) bo_idx(%d) tbm_bo(%p)\n", surface, bo_idx, bo);
+       TBM_TRACE_SURFACE_INTERNAL("tbm_surface(%p) bo_idx(%d) tbm_bo(%p)\n", surface, bo_idx, bo);
 
        _tbm_surface_mutex_unlock();
 
@@ -1042,7 +1042,7 @@ tbm_surface_internal_get_size(tbm_surface_h surface)
        surf = (struct _tbm_surface *)surface;
        size = surf->info.size;
 
-       TBM_TRACE("tbm_surface(%p) size(%u)\n", surface, size);
+       TBM_TRACE_SURFACE_INTERNAL("tbm_surface(%p) size(%u)\n", surface, size);
 
        _tbm_surface_mutex_unlock();
 
@@ -1063,7 +1063,7 @@ tbm_surface_internal_get_plane_data(tbm_surface_h surface, int plane_idx,
        surf = (struct _tbm_surface *)surface;
 
        if (plane_idx >= surf->info.num_planes) {
-               TBM_TRACE("error: tbm_surface(%p) plane_idx(%d)\n", surface, plane_idx);
+               TBM_TRACE_SURFACE_INTERNAL("error: tbm_surface(%p) plane_idx(%d)\n", surface, plane_idx);
                _tbm_surface_mutex_unlock();
                return 0;
        }
@@ -1077,7 +1077,7 @@ tbm_surface_internal_get_plane_data(tbm_surface_h surface, int plane_idx,
        if (pitch)
                *pitch = surf->info.planes[plane_idx].stride;
 
-       TBM_TRACE("tbm_surface(%p) plane_idx(%d) size(%u) offset(%u) pitch(%u)\n", surface, plane_idx,
+       TBM_TRACE_SURFACE_INTERNAL("tbm_surface(%p) plane_idx(%d) size(%u) offset(%u) pitch(%u)\n", surface, plane_idx,
                                surf->info.planes[plane_idx].size, surf->info.planes[plane_idx].offset,
                                surf->info.planes[plane_idx].stride);
 
@@ -1133,7 +1133,7 @@ tbm_surface_internal_get_info(tbm_surface_h surface, int opt,
                                for (j = 0; j < i; j++)
                                        tbm_bo_unmap(bos[j]);
 
-                               TBM_LOG_E("error: tbm_surface(%p) opt(%d) map(%d)\n", surface, opt, map);
+                               TBM_ERR("error: tbm_surface(%p) opt(%d) map(%d)\n", surface, opt, map);
                                return 0;
                        }
                }
@@ -1142,7 +1142,7 @@ tbm_surface_internal_get_info(tbm_surface_h surface, int opt,
                for (i = 0; i < num_bos; i++) {
                        bo_handles[i] = tbm_bo_get_handle(bos[i], TBM_DEVICE_CPU);
                        if (bo_handles[i].ptr == NULL) {
-                               TBM_LOG_E("error: tbm_surface(%p) opt(%d) map(%d)\n", surface, opt, map);
+                               TBM_ERR("error: tbm_surface(%p) opt(%d) map(%d)\n", surface, opt, map);
                                _tbm_surface_mutex_unlock();
                                return 0;
                        }
@@ -1154,7 +1154,7 @@ tbm_surface_internal_get_info(tbm_surface_h surface, int opt,
                        info->planes[i].ptr = bo_handles[planes_bo_idx[i]].ptr + info->planes[i].offset;
        }
 
-       TBM_TRACE("tbm_surface(%p) opt(%d) map(%d)\n", surface, opt, map);
+       TBM_TRACE_SURFACE_INTERNAL("tbm_surface(%p) opt(%d) map(%d)\n", surface, opt, map);
 
        _tbm_surface_mutex_unlock();
 
@@ -1176,7 +1176,7 @@ tbm_surface_internal_unmap(tbm_surface_h surface)
        for (i = 0; i < surf->num_bos; i++)
                tbm_bo_unmap(surf->bos[i]);
 
-       TBM_TRACE("tbm_surface(%p)\n", surface);
+       TBM_TRACE_SURFACE_INTERNAL("tbm_surface(%p)\n", surface);
 
        _tbm_surface_mutex_unlock();
 }
@@ -1194,7 +1194,7 @@ tbm_surface_internal_get_width(tbm_surface_h surface)
        surf = (struct _tbm_surface *)surface;
        width = surf->info.width;
 
-       TBM_TRACE("tbm_surface(%p) width(%u)\n", surface, width);
+       TBM_TRACE_SURFACE_INTERNAL("tbm_surface(%p) width(%u)\n", surface, width);
 
        _tbm_surface_mutex_unlock();
 
@@ -1214,7 +1214,7 @@ tbm_surface_internal_get_height(tbm_surface_h surface)
        surf = (struct _tbm_surface *)surface;
        height = surf->info.height;
 
-       TBM_TRACE("tbm_surface(%p) height(%u)\n", surface, height);
+       TBM_TRACE_SURFACE_INTERNAL("tbm_surface(%p) height(%u)\n", surface, height);
 
        _tbm_surface_mutex_unlock();
 
@@ -1235,7 +1235,7 @@ tbm_surface_internal_get_format(tbm_surface_h surface)
        surf = (struct _tbm_surface *)surface;
        format = surf->info.format;
 
-       TBM_TRACE("tbm_surface(%p) format(%s)\n", surface, _tbm_surface_internal_format_to_str(format));
+       TBM_TRACE_SURFACE_INTERNAL("tbm_surface(%p) format(%s)\n", surface, _tbm_surface_internal_format_to_str(format));
 
        _tbm_surface_mutex_unlock();
 
@@ -1256,7 +1256,7 @@ tbm_surface_internal_get_plane_bo_idx(tbm_surface_h surface, int plane_idx)
        surf = (struct _tbm_surface *)surface;
        bo_idx = surf->planes_bo_idx[plane_idx];
 
-       TBM_TRACE("tbm_surface(%p) plane_idx(%d) bo_idx(%d)\n", surface, plane_idx, bo_idx);
+       TBM_TRACE_SURFACE_INTERNAL("tbm_surface(%p) plane_idx(%d) bo_idx(%d)\n", surface, plane_idx, bo_idx);
 
        _tbm_surface_mutex_unlock();
 
@@ -1276,19 +1276,19 @@ tbm_surface_internal_add_user_data(tbm_surface_h surface, unsigned long key,
        /* check if the data according to the key exist if so, return false. */
        data = user_data_lookup(&surface->user_data_list, key);
        if (data) {
-               TBM_TRACE("warning: user data already exist tbm_surface(%p) key(%lu)\n", surface, key);
+               TBM_TRACE_SURFACE_INTERNAL("warning: user data already exist tbm_surface(%p) key(%lu)\n", surface, key);
                _tbm_surface_mutex_unlock();
                return 0;
        }
 
        data = user_data_create(key, data_free_func);
        if (!data) {
-               TBM_TRACE("error: tbm_surface(%p) key(%lu)\n", surface, key);
+               TBM_TRACE_SURFACE_INTERNAL("error: tbm_surface(%p) key(%lu)\n", surface, key);
                _tbm_surface_mutex_unlock();
                return 0;
        }
 
-       TBM_TRACE("tbm_surface(%p) key(%lu) data(%p)\n", surface, key, data);
+       TBM_TRACE_SURFACE_INTERNAL("tbm_surface(%p) key(%lu) data(%p)\n", surface, key, data);
 
        LIST_ADD(&data->item_link, &surface->user_data_list);
 
@@ -1309,7 +1309,7 @@ tbm_surface_internal_set_user_data(tbm_surface_h surface, unsigned long key,
 
        old_data = user_data_lookup(&surface->user_data_list, key);
        if (!old_data) {
-               TBM_TRACE("error: tbm_surface(%p) key(%lu)\n", surface, key);
+               TBM_TRACE_SURFACE_INTERNAL("error: tbm_surface(%p) key(%lu)\n", surface, key);
                _tbm_surface_mutex_unlock();
                return 0;
        }
@@ -1319,7 +1319,7 @@ tbm_surface_internal_set_user_data(tbm_surface_h surface, unsigned long key,
 
        old_data->data = data;
 
-       TBM_TRACE("tbm_surface(%p) key(%lu) data(%p)\n", surface, key, old_data->data);
+       TBM_TRACE_SURFACE_INTERNAL("tbm_surface(%p) key(%lu) data(%p)\n", surface, key, old_data->data);
 
        _tbm_surface_mutex_unlock();
 
@@ -1337,7 +1337,7 @@ tbm_surface_internal_get_user_data(tbm_surface_h surface, unsigned long key,
        TBM_SURFACE_RETURN_VAL_IF_FAIL(_tbm_surface_internal_is_valid(surface), 0);
 
        if (!data) {
-               TBM_LOG_E("error: tbm_surface(%p) key(%lu)\n", surface, key);
+               TBM_ERR("error: tbm_surface(%p) key(%lu)\n", surface, key);
                _tbm_surface_mutex_unlock();
                return 0;
        }
@@ -1345,14 +1345,14 @@ tbm_surface_internal_get_user_data(tbm_surface_h surface, unsigned long key,
 
        old_data = user_data_lookup(&surface->user_data_list, key);
        if (!old_data) {
-               TBM_TRACE("error: tbm_surface(%p) key(%lu)\n", surface, key);
+               TBM_TRACE_SURFACE_INTERNAL("error: tbm_surface(%p) key(%lu)\n", surface, key);
                _tbm_surface_mutex_unlock();
                return 0;
        }
 
        *data = old_data->data;
 
-       TBM_TRACE("tbm_surface(%p) key(%lu) data(%p)\n", surface, key, old_data->data);
+       TBM_TRACE_SURFACE_INTERNAL("tbm_surface(%p) key(%lu) data(%p)\n", surface, key, old_data->data);
 
        _tbm_surface_mutex_unlock();
 
@@ -1371,12 +1371,12 @@ tbm_surface_internal_delete_user_data(tbm_surface_h surface,
 
        old_data = user_data_lookup(&surface->user_data_list, key);
        if (!old_data) {
-               TBM_TRACE("error: tbm_surface(%p) key(%lu)\n", surface, key);
+               TBM_TRACE_SURFACE_INTERNAL("error: tbm_surface(%p) key(%lu)\n", surface, key);
                _tbm_surface_mutex_unlock();
                return 0;
        }
 
-       TBM_TRACE("tbm_surface(%p) key(%lu) data(%p)\n", surface, key, old_data->data);
+       TBM_TRACE_SURFACE_INTERNAL("tbm_surface(%p) key(%lu) data(%p)\n", surface, key, old_data->data);
 
        user_data_delete(old_data);
 
@@ -1442,7 +1442,7 @@ tbm_surface_internal_set_debug_data(tbm_surface_h surface, char *key, char *valu
                        if (old_data) {
                                if (!strcmp(old_data->key, key)) {
                                        if (old_data->value && value && !strncmp(old_data->value, value, strlen(old_data->value))) {
-                                               TBM_TRACE("tbm_surface(%p) Already exist key(%s) and value(%s)!\n", surface, key, value);
+                                               TBM_TRACE_SURFACE_INTERNAL("tbm_surface(%p) Already exist key(%s) and value(%s)!\n", surface, key, value);
                                                goto add_debug_key_list;
                                        }
 
@@ -1462,12 +1462,12 @@ tbm_surface_internal_set_debug_data(tbm_surface_h surface, char *key, char *valu
 
        debug_data = _tbm_surface_internal_debug_data_create(key, value);
        if (!debug_data) {
-               TBM_LOG_E("error: tbm_surface(%p) key(%s) value(%s)\n", surface, key, value);
+               TBM_ERR("error: tbm_surface(%p) key(%s) value(%s)\n", surface, key, value);
                _tbm_surface_mutex_unlock();
                return 0;
        }
 
-       TBM_TRACE("tbm_surface(%p) key(%s) value(%s)\n", surface, key, value);
+       TBM_TRACE_SURFACE_INTERNAL("tbm_surface(%p) key(%s) value(%s)\n", surface, key, value);
 
        LIST_ADD(&debug_data->item_link, &surface->debug_data_list);
 
@@ -1544,7 +1544,7 @@ _tbm_surface_internal_dump_file_raw(const char *file, void *data1, int size1,
        unsigned int *blocks;
 
        if (_tbm_surface_check_file_is_symbolic_link(file))
-               TBM_LOG_E("%s is symbolic link\n", file);
+               TBM_ERR("%s is symbolic link\n", file);
 
        fp = fopen(file, "w+");
        TBM_RETURN_IF_FAIL(fp != NULL);
@@ -1575,7 +1575,7 @@ _tbm_surface_internal_dump_file_png(const char *file, const void *data, int widt
        int depth = 8, y;
 
        if (_tbm_surface_check_file_is_symbolic_link(file))
-               TBM_LOG_E("%s is symbolic link\n", file);
+               TBM_ERR("%s is symbolic link\n", file);
 
        fp = fopen(file, "wb");
        TBM_RETURN_IF_FAIL(fp != NULL);
@@ -1583,14 +1583,14 @@ _tbm_surface_internal_dump_file_png(const char *file, const void *data, int widt
        png_structp pPngStruct = png_create_write_struct(PNG_LIBPNG_VER_STRING,
                                                        NULL, NULL, NULL);
        if (!pPngStruct) {
-               TBM_LOG_E("fail to create a png write structure.\n");
+               TBM_ERR("fail to create a png write structure.\n");
                fclose(fp);
                return;
        }
 
        png_infop pPngInfo = png_create_info_struct(pPngStruct);
        if (!pPngInfo) {
-               TBM_LOG_E("fail to create a png info structure.\n");
+               TBM_ERR("fail to create a png info structure.\n");
                png_destroy_write_struct(&pPngStruct, NULL);
                fclose(fp);
                return;
@@ -1624,7 +1624,7 @@ _tbm_surface_internal_dump_file_png(const char *file, const void *data, int widt
 
        row_pointers = png_malloc(pPngStruct, height * sizeof(png_byte *));
        if (!row_pointers) {
-               TBM_LOG_E("fail to allocate the png row_pointers.\n");
+               TBM_ERR("fail to allocate the png row_pointers.\n");
                png_destroy_write_struct(&pPngStruct, &pPngInfo);
                fclose(fp);
                return;
@@ -1636,7 +1636,7 @@ _tbm_surface_internal_dump_file_png(const char *file, const void *data, int widt
 
                row = png_malloc(pPngStruct, sizeof(png_byte) * width * pixel_size);
                if (!row) {
-                       TBM_LOG_E("fail to allocate the png row.\n");
+                       TBM_ERR("fail to allocate the png row.\n");
                        for (x = 0; x < y; x++)
                                png_free(pPngStruct, row_pointers[x]);
                        png_free(pPngStruct, row_pointers);
@@ -1689,7 +1689,7 @@ tbm_surface_internal_dump_start(char *path, int w, int h, int count)
 
        /* check running */
        if (g_dump_info) {
-               TBM_LOG_W("waring already running the tbm_surface_internal_dump.\n");
+               TBM_WRN("waring already running the tbm_surface_internal_dump.\n");
                return;
        }
 
@@ -1703,14 +1703,14 @@ tbm_surface_internal_dump_start(char *path, int w, int h, int count)
        /* get buffer size */
        tbm_surface = tbm_surface_create(w, h, TBM_FORMAT_ARGB8888);
        if (tbm_surface == NULL) {
-               TBM_LOG_E("tbm_surface_create fail\n");
+               TBM_ERR("tbm_surface_create fail\n");
                free(g_dump_info);
                g_dump_info = NULL;
                return;
        }
 
        if (TBM_SURFACE_ERROR_NONE != tbm_surface_get_info(tbm_surface, &info)) {
-               TBM_LOG_E("tbm_surface_get_info fail\n");
+               TBM_ERR("tbm_surface_get_info fail\n");
                tbm_surface_destroy(tbm_surface);
                free(g_dump_info);
                g_dump_info = NULL;
@@ -1728,7 +1728,7 @@ tbm_surface_internal_dump_start(char *path, int w, int h, int count)
 
                bo = tbm_bo_alloc(g_surface_bufmgr, buffer_size, TBM_BO_DEFAULT);
                if (bo == NULL) {
-                       TBM_LOG_E("fail to allocate the tbm_bo[%d]\n", i);
+                       TBM_ERR("fail to allocate the tbm_bo[%d]\n", i);
                        free(buf_info);
                        goto fail;
                }
@@ -1745,7 +1745,7 @@ tbm_surface_internal_dump_start(char *path, int w, int h, int count)
 
        scale_factor = 0.0;
 
-       TBM_LOG_I("Dump Start.. path:%s, count:%d\n", g_dump_info->path, count);
+       TBM_INFO("Dump Start.. path:%s, count:%d\n", g_dump_info->path, count);
 
        return;
 
@@ -1761,7 +1761,7 @@ fail:
                }
        }
 
-       TBM_LOG_E("Dump Start fail.. path:%s\n", g_dump_info->path);
+       TBM_ERR("Dump Start fail.. path:%s\n", g_dump_info->path);
 
        free(g_dump_info);
        g_dump_info = NULL;
@@ -1809,7 +1809,7 @@ tbm_surface_internal_dump_end(void)
                }
 
                snprintf(file, sizeof(file), "%s/%s", g_dump_info->path, buf_info->name);
-               TBM_LOG_I("Dump File.. %s generated.\n", file);
+               TBM_INFO("Dump File.. %s generated.\n", file);
 
                if (buf_info->dirty) {
                        void *ptr1 = NULL, *ptr2 = NULL;
@@ -1852,7 +1852,7 @@ tbm_surface_internal_dump_end(void)
                                                        NULL, 0, NULL, 0);
                                break;
                        default:
-                               TBM_LOG_E("can't dump %c%c%c%c buffer", FOURCC_STR(buf_info->info.format));
+                               TBM_ERR("can't dump %c%c%c%c buffer", FOURCC_STR(buf_info->info.format));
                                break;
                        }
                } else if (buf_info->dirty_shm)
@@ -1869,7 +1869,7 @@ tbm_surface_internal_dump_end(void)
        free(g_dump_info);
        g_dump_info = NULL;
 
-       TBM_LOG_I("Dump End..\n");
+       TBM_INFO("Dump End..\n");
 }
 
 static pixman_format_code_t
@@ -1967,7 +1967,7 @@ static char *_tbm_surface_internal_get_keys(tbm_surface_h surface)
 
        keys = calloc(KEYS_LEN + 1, sizeof(char));
        if (!keys) {
-               TBM_LOG_E("Failed to alloc memory");
+               TBM_ERR("Failed to alloc memory");
                _tbm_surface_mutex_unlock();
                return NULL;
        }
@@ -2026,7 +2026,7 @@ tbm_surface_internal_dump_buffer(tbm_surface_h surface, const char *type)
                const int bpp = 4;
 
                if (info.format != TBM_FORMAT_ARGB8888 && info.format != TBM_FORMAT_XRGB8888) {
-                       TBM_LOG_W("Dump with scale skip. unsupported format(%s)\n",
+                       TBM_WRN("Dump with scale skip. unsupported format(%s)\n",
                                          _tbm_surface_internal_format_to_str(info.format));
                        tbm_surface_unmap(surface);
                        return;
@@ -2043,14 +2043,14 @@ tbm_surface_internal_dump_buffer(tbm_surface_h surface, const char *type)
                buf_info->info.size = buf_info->info.width * buf_info->info.height * bpp;
 
                if (buf_info->info.size > buf_info->size) {
-                       TBM_LOG_W("Dump with scale skip. surface over created buffer size(%u, %d)\n",
+                       TBM_WRN("Dump with scale skip. surface over created buffer size(%u, %d)\n",
                                        buf_info->info.size, buf_info->size);
                        tbm_surface_unmap(surface);
                        return;
                }
        } else {
                if (info.size > buf_info->size) {
-                       TBM_LOG_W("Dump skip. surface over created buffer size(%u, %d)\n",
+                       TBM_WRN("Dump skip. surface over created buffer size(%u, %d)\n",
                                        info.size, buf_info->size);
                        tbm_surface_unmap(surface);
                        return;
@@ -2068,7 +2068,7 @@ tbm_surface_internal_dump_buffer(tbm_surface_h surface, const char *type)
 
        keys = _tbm_surface_internal_get_keys(surface);
        if (!keys) {
-               TBM_LOG_E("fail to get keys");
+               TBM_ERR("fail to get keys");
                tbm_surface_unmap(surface);
                return;
        }
@@ -2076,7 +2076,7 @@ tbm_surface_internal_dump_buffer(tbm_surface_h surface, const char *type)
        /* dump */
        bo_handle = tbm_bo_map(buf_info->bo, TBM_DEVICE_CPU, TBM_OPTION_WRITE);
        if (!bo_handle.ptr) {
-               TBM_LOG_E("fail to map bo");
+               TBM_ERR("fail to map bo");
                _tbm_surface_internal_put_keys(keys);
                tbm_surface_unmap(surface);
                return;
@@ -2101,7 +2101,7 @@ tbm_surface_internal_dump_buffer(tbm_surface_h surface, const char *type)
                                                                                                         buf_info->info.width,
                                                                                                         buf_info->info.height);
                        if (ret != TBM_SURFACE_ERROR_NONE) {
-                               TBM_LOG_E("fail to scale buffer");
+                               TBM_ERR("fail to scale buffer");
                                tbm_bo_unmap(buf_info->bo);
                                _tbm_surface_internal_put_keys(keys);
                                tbm_surface_unmap(surface);
@@ -2144,7 +2144,7 @@ tbm_surface_internal_dump_buffer(tbm_surface_h surface, const char *type)
                memcpy(bo_handle.ptr, info.planes[0].ptr, info.planes[0].stride * info.height);
                break;
        default:
-               TBM_LOG_E("can't copy %c%c%c%c buffer", FOURCC_STR(info.format));
+               TBM_ERR("can't copy %c%c%c%c buffer", FOURCC_STR(info.format));
                tbm_bo_unmap(buf_info->bo);
                _tbm_surface_internal_put_keys(keys);
                tbm_surface_unmap(surface);
@@ -2165,7 +2165,7 @@ tbm_surface_internal_dump_buffer(tbm_surface_h surface, const char *type)
 
        g_dump_info->link = next_link;
 
-       TBM_LOG_I("Dump %s \n", buf_info->name);
+       TBM_INFO("Dump %s \n", buf_info->name);
 }
 
 void tbm_surface_internal_dump_shm_buffer(void *ptr, int w, int h, int stride,
@@ -2207,7 +2207,7 @@ void tbm_surface_internal_dump_shm_buffer(void *ptr, int w, int h, int stride,
                size = stride * h;
 
        if (size > buf_info->size) {
-               TBM_LOG_W("Dump skip. shm buffer over created buffer size(%d, %d)\n",
+               TBM_WRN("Dump skip. shm buffer over created buffer size(%d, %d)\n",
                                size, buf_info->size);
                return;
        }
@@ -2227,7 +2227,7 @@ void tbm_surface_internal_dump_shm_buffer(void *ptr, int w, int h, int stride,
                                                                                                 TBM_FORMAT_ARGB8888, stride,
                                                                                                 w, h, dstride, dw, dh);
                if (ret != TBM_SURFACE_ERROR_NONE) {
-                       TBM_LOG_E("fail to scale buffer");
+                       TBM_ERR("fail to scale buffer");
                        tbm_bo_unmap(buf_info->bo);
                        return;
                }
@@ -2249,7 +2249,7 @@ void tbm_surface_internal_dump_shm_buffer(void *ptr, int w, int h, int stride,
 
        g_dump_info->link = next_link;
 
-       TBM_LOG_I("Dump %s \n", buf_info->name);
+       TBM_INFO("Dump %s \n", buf_info->name);
 }
 
 int
@@ -2273,7 +2273,7 @@ tbm_surface_internal_capture_buffer(tbm_surface_h surface, const char *path, con
                postfix = dump_postfix[1];
 
        if (strcmp(postfix, type)) {
-               TBM_LOG_E("not support type(%s) %c%c%c%c buffer", type, FOURCC_STR(info.format));
+               TBM_ERR("not support type(%s) %c%c%c%c buffer", type, FOURCC_STR(info.format));
                tbm_surface_unmap(surface);
                return 0;
        }
@@ -2281,7 +2281,7 @@ tbm_surface_internal_capture_buffer(tbm_surface_h surface, const char *path, con
        snprintf(file, sizeof(file), "%s/%s.%s", path , name, postfix);
 
        if (!access(file, 0)) {
-               TBM_LOG_E("can't capture  buffer, exist file %s", file);
+               TBM_ERR("can't capture  buffer, exist file %s", file);
                tbm_surface_unmap(surface);
                return 0;
        }
@@ -2321,14 +2321,14 @@ tbm_surface_internal_capture_buffer(tbm_surface_h surface, const char *path, con
                                        NULL, 0, NULL, 0);
                break;
        default:
-               TBM_LOG_E("can't dump %c%c%c%c buffer", FOURCC_STR(info.format));
+               TBM_ERR("can't dump %c%c%c%c buffer", FOURCC_STR(info.format));
                tbm_surface_unmap(surface);
                return 0;
        }
 
        tbm_surface_unmap(surface);
 
-       TBM_TRACE("Capture %s \n", file);
+       TBM_TRACE_SURFACE_INTERNAL("Capture %s \n", file);
 
        return 1;
 }
@@ -2347,20 +2347,20 @@ tbm_surface_internal_capture_shm_buffer(void *ptr, int w, int h, int stride,
        char file[1024];
 
        if (strcmp(dump_postfix[0], type)) {
-               TBM_LOG_E("Not supported type:%s'", type);
+               TBM_ERR("Not supported type:%s'", type);
                return 0;
        }
 
        snprintf(file, sizeof(file), "%s/%s.%s", path , name, dump_postfix[0]);
 
        if (!access(file, 0)) {
-               TBM_LOG_E("can't capture buffer, exist file %sTBM_FORMAT_XRGB8888", file);
+               TBM_ERR("can't capture buffer, exist file %sTBM_FORMAT_XRGB8888", file);
                return 0;
        }
 
        _tbm_surface_internal_dump_file_png(file, ptr, w, h, 0);
 
-       TBM_TRACE("Capture %s \n", file);
+       TBM_TRACE_SURFACE_INTERNAL("Capture %s \n", file);
 
        return 1;
 }
index ab2fd2bed0d747c218c51bc8e0094d2c3e6656c7..cf2e0a21d28ccdf2f98a32c1acb27d58816afa12 100644 (file)
@@ -38,22 +38,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define DIRTY_QUEUE    2
 #define NODE_LIST      4
 
-#define TBM_QUEUE_DEBUG 0
-
-#ifdef TRACE
-#define TBM_QUEUE_TRACE(fmt, ...)  { if (bTrace&0x1) fprintf(stderr, "[TBM:TRACE(%d)(%s:%d)] " fmt, getpid(), __func__, __LINE__, ##__VA_ARGS__); }
-#else
-#define TBM_QUEUE_TRACE(fmt, ...)
-#endif /* TRACE */
-
-#if TBM_QUEUE_DEBUG
-#define TBM_LOCK() TBM_LOG_D("[LOCK] %s:%d surface:%p\n", __func__, __LINE__, surface_queue)
-#define TBM_UNLOCK() TBM_LOG_D("[UNLOCK] %s:%d surface:%p\n", __func__, __LINE__, surface_queue)
-#else
-#define TBM_LOCK()
-#define TBM_UNLOCK()
-#endif
-
 static tbm_bufmgr g_surf_queue_bufmgr;
 static pthread_mutex_t tbm_surf_queue_lock;
 void _tbm_surface_queue_mutex_unlock(void);
@@ -61,7 +45,7 @@ void _tbm_surface_queue_mutex_unlock(void);
 /* check condition */
 #define TBM_SURF_QUEUE_RETURN_IF_FAIL(cond) {\
        if (!(cond)) {\
-               TBM_LOG_E("'%s' failed.\n", #cond);\
+               TBM_ERR("'%s' failed.\n", #cond);\
                _tbm_surf_queue_mutex_unlock();\
                return;\
        } \
@@ -69,7 +53,7 @@ void _tbm_surface_queue_mutex_unlock(void);
 
 #define TBM_SURF_QUEUE_RETURN_VAL_IF_FAIL(cond, val) {\
        if (!(cond)) {\
-               TBM_LOG_E("'%s' failed.\n", #cond);\
+               TBM_ERR("'%s' failed.\n", #cond);\
                _tbm_surf_queue_mutex_unlock();\
                return val;\
        } \
@@ -175,7 +159,7 @@ _tbm_surf_queue_mutex_init(void)
                return true;
 
        if (pthread_mutex_init(&tbm_surf_queue_lock, NULL)) {
-               TBM_LOG_E("fail: pthread_mutex_init\n");
+               TBM_ERR("fail: pthread_mutex_init\n");
                return false;
        }
 
@@ -188,7 +172,7 @@ static void
 _tbm_surf_queue_mutex_lock(void)
 {
        if (!_tbm_surf_queue_mutex_init()) {
-               TBM_LOG_E("fail: _tbm_surf_queue_mutex_init\n");
+               TBM_ERR("fail: _tbm_surf_queue_mutex_init\n");
                return;
        }
 
@@ -223,29 +207,29 @@ _tbm_surface_queue_is_valid(tbm_surface_queue_h surface_queue)
        tbm_surface_queue_h old_data = NULL;
 
        if (surface_queue == NULL) {
-               TBM_LOG_E("error: surface_queue is NULL.\n");
+               TBM_ERR("error: surface_queue is NULL.\n");
                return 0;
        }
 
        if (g_surf_queue_bufmgr == NULL) {
-               TBM_LOG_E("error: g_surf_queue_bufmgr is NULL.\n");
+               TBM_ERR("error: g_surf_queue_bufmgr is NULL.\n");
                return 0;
        }
 
        if (LIST_IS_EMPTY(&g_surf_queue_bufmgr->surf_queue_list)) {
-               TBM_LOG_E("error: surf_queue_list is empty\n");
+               TBM_ERR("error: surf_queue_list is empty\n");
                return 0;
        }
 
        LIST_FOR_EACH_ENTRY(old_data, &g_surf_queue_bufmgr->surf_queue_list,
                                item_link) {
                if (old_data == surface_queue) {
-                       TBM_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+                       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
                        return 1;
                }
        }
 
-       TBM_LOG_E("error: Invalid tbm_surface_queue(%p)\n", surface_queue);
+       TBM_ERR("error: Invalid tbm_surface_queue(%p)\n", surface_queue);
 
        return 0;
 }
@@ -362,7 +346,7 @@ _queue_get_node(tbm_surface_queue_h surface_queue, int type,
                }
        }
 
-       TBM_LOG_E("fail to get the queue_node.\n");
+       TBM_ERR("fail to get the queue_node.\n");
 
        return NULL;
 }
@@ -422,7 +406,7 @@ _notify_remove(struct list_head *list,
                }
        }
 
-       TBM_LOG_E("Cannot find notifiy\n");
+       TBM_ERR("Cannot find notifiy\n");
 }
 
 static void
@@ -482,7 +466,7 @@ _trace_remove(struct list_head *list,
                }
        }
 
-       TBM_LOG_E("Cannot find notifiy\n");
+       TBM_ERR("Cannot find notifiy\n");
 }
 
 static void
@@ -655,7 +639,7 @@ tbm_surface_queue_add_destroy_cb(
 
        pthread_mutex_lock(&surface_queue->lock);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
 
        _notify_add(&surface_queue->destory_noti, destroy_cb, data);
 
@@ -678,7 +662,7 @@ tbm_surface_queue_remove_destroy_cb(
 
        pthread_mutex_lock(&surface_queue->lock);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
 
        _notify_remove(&surface_queue->destory_noti, destroy_cb, data);
 
@@ -703,7 +687,7 @@ tbm_surface_queue_add_dequeuable_cb(
 
        pthread_mutex_lock(&surface_queue->lock);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
 
        _notify_add(&surface_queue->dequeuable_noti, dequeuable_cb, data);
 
@@ -726,7 +710,7 @@ tbm_surface_queue_remove_dequeuable_cb(
 
        pthread_mutex_lock(&surface_queue->lock);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
 
        _notify_remove(&surface_queue->dequeuable_noti, dequeuable_cb, data);
 
@@ -751,7 +735,7 @@ tbm_surface_queue_add_dequeue_cb(
 
        pthread_mutex_lock(&surface_queue->lock);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
 
        _notify_add(&surface_queue->dequeue_noti, dequeue_cb, data);
 
@@ -774,7 +758,7 @@ tbm_surface_queue_remove_dequeue_cb(
 
        pthread_mutex_lock(&surface_queue->lock);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
 
        _notify_remove(&surface_queue->dequeue_noti, dequeue_cb, data);
 
@@ -799,7 +783,7 @@ tbm_surface_queue_add_can_dequeue_cb(
 
        pthread_mutex_lock(&surface_queue->lock);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
 
        _notify_add(&surface_queue->can_dequeue_noti, can_dequeue_cb, data);
 
@@ -822,7 +806,7 @@ tbm_surface_queue_remove_can_dequeue_cb(
 
        pthread_mutex_lock(&surface_queue->lock);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
 
        _notify_remove(&surface_queue->can_dequeue_noti, can_dequeue_cb, data);
 
@@ -847,7 +831,7 @@ tbm_surface_queue_add_acquirable_cb(
 
        pthread_mutex_lock(&surface_queue->lock);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
 
        _notify_add(&surface_queue->acquirable_noti, acquirable_cb, data);
 
@@ -870,7 +854,7 @@ tbm_surface_queue_remove_acquirable_cb(
 
        pthread_mutex_lock(&surface_queue->lock);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
 
        _notify_remove(&surface_queue->acquirable_noti, acquirable_cb, data);
 
@@ -895,7 +879,7 @@ tbm_surface_queue_add_trace_cb(
 
        pthread_mutex_lock(&surface_queue->lock);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
 
        _trace_add(&surface_queue->trace_noti, trace_cb, data);
 
@@ -918,7 +902,7 @@ tbm_surface_queue_remove_trace_cb(
 
        pthread_mutex_lock(&surface_queue->lock);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
 
        _trace_remove(&surface_queue->trace_noti, trace_cb, data);
 
@@ -943,7 +927,7 @@ tbm_surface_queue_set_alloc_cb(
 
        pthread_mutex_lock(&surface_queue->lock);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
 
        surface_queue->alloc_cb = alloc_cb;
        surface_queue->free_cb = free_cb;
@@ -965,7 +949,7 @@ tbm_surface_queue_get_width(tbm_surface_queue_h surface_queue)
 
        TBM_SURF_QUEUE_RETURN_VAL_IF_FAIL(_tbm_surface_queue_is_valid(surface_queue), 0);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
 
        width = surface_queue->width;
 
@@ -983,7 +967,7 @@ tbm_surface_queue_get_height(tbm_surface_queue_h surface_queue)
 
        TBM_SURF_QUEUE_RETURN_VAL_IF_FAIL(_tbm_surface_queue_is_valid(surface_queue), 0);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
 
        height = surface_queue->height;
 
@@ -1001,7 +985,7 @@ tbm_surface_queue_get_format(tbm_surface_queue_h surface_queue)
 
        TBM_SURF_QUEUE_RETURN_VAL_IF_FAIL(_tbm_surface_queue_is_valid(surface_queue), 0);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
 
        format = surface_queue->format;
 
@@ -1019,7 +1003,7 @@ tbm_surface_queue_get_size(tbm_surface_queue_h surface_queue)
 
        TBM_SURF_QUEUE_RETURN_VAL_IF_FAIL(_tbm_surface_queue_is_valid(surface_queue), 0);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
 
        queue_size = surface_queue->queue_size;
 
@@ -1042,7 +1026,7 @@ tbm_surface_queue_add_reset_cb(
 
        pthread_mutex_lock(&surface_queue->lock);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
 
        _notify_add(&surface_queue->reset_noti, reset_cb, data);
 
@@ -1065,7 +1049,7 @@ tbm_surface_queue_remove_reset_cb(
 
        pthread_mutex_lock(&surface_queue->lock);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
 
        _notify_remove(&surface_queue->reset_noti, reset_cb, data);
 
@@ -1095,11 +1079,11 @@ tbm_surface_queue_enqueue(tbm_surface_queue_h
 
        pthread_mutex_lock(&surface_queue->lock);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p) tbm_surface(%p)\n", surface_queue, surface);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p) tbm_surface(%p)\n", surface_queue, surface);
 
        node = _queue_get_node(surface_queue, 0, surface, &queue_type);
        if (node == NULL || queue_type != NODE_LIST) {
-               TBM_LOG_E("tbm_surface_queue_enqueue::Surface is existed in free_queue or dirty_queue node:%p, type:%d\n",
+               TBM_ERR("tbm_surface_queue_enqueue::Surface is existed in free_queue or dirty_queue node:%p, type:%d\n",
                        node, queue_type);
                pthread_mutex_unlock(&surface_queue->lock);
 
@@ -1117,7 +1101,7 @@ tbm_surface_queue_enqueue(tbm_surface_queue_h
                _tbm_surface_queue_enqueue(surface_queue, node, 1);
 
        if (!_queue_get_node(surface_queue, DIRTY_QUEUE, surface, NULL)) {
-               TBM_LOG_E("enqueue surface(%p) but surface isn't present in the dirty_queue\n", surface);
+               TBM_ERR("enqueue surface(%p) but surface isn't present in the dirty_queue\n", surface);
                pthread_mutex_unlock(&surface_queue->lock);
 
                _tbm_surf_queue_mutex_unlock();
@@ -1165,11 +1149,11 @@ tbm_surface_queue_cancel_dequeue(tbm_surface_queue_h
 
        pthread_mutex_lock(&surface_queue->lock);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p) tbm_surface(%p)\n", surface_queue, surface);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p) tbm_surface(%p)\n", surface_queue, surface);
 
        node = _queue_get_node(surface_queue, 0, surface, &queue_type);
        if (node == NULL || queue_type != NODE_LIST) {
-               TBM_LOG_E("tbm_surface_queue_cancel_dequeue::Surface is existed in free_queue or dirty_queue node:%p, type:%d\n",
+               TBM_ERR("tbm_surface_queue_cancel_dequeue::Surface is existed in free_queue or dirty_queue node:%p, type:%d\n",
                        node, queue_type);
                pthread_mutex_unlock(&surface_queue->lock);
 
@@ -1178,7 +1162,7 @@ tbm_surface_queue_cancel_dequeue(tbm_surface_queue_h
        }
 
        if (node->delete_pending) {
-               TBM_QUEUE_TRACE("delete pending tbm_surface_queue(%p) surface(%p)\n", surface_queue, node->surface);
+               TBM_TRACE_SURFACE_QUEUE("delete pending tbm_surface_queue(%p) surface(%p)\n", surface_queue, node->surface);
 
                _queue_delete_node(surface_queue, node);
 
@@ -1192,7 +1176,7 @@ tbm_surface_queue_cancel_dequeue(tbm_surface_queue_h
        }
 
        if (surface_queue->queue_size < surface_queue->num_attached) {
-               TBM_QUEUE_TRACE("deatch tbm_surface_queue(%p) surface(%p)\n", surface_queue, node->surface);
+               TBM_TRACE_SURFACE_QUEUE("deatch tbm_surface_queue(%p) surface(%p)\n", surface_queue, node->surface);
 
                if (surface_queue->impl && surface_queue->impl->need_detach)
                        surface_queue->impl->need_detach(surface_queue, node);
@@ -1216,7 +1200,7 @@ tbm_surface_queue_cancel_dequeue(tbm_surface_queue_h
        if (_queue_is_empty(&surface_queue->free_queue)) {
                pthread_mutex_unlock(&surface_queue->lock);
 
-               TBM_LOG_E("surface_queue->free_queue is empty.\n");
+               TBM_ERR("surface_queue->free_queue is empty.\n");
                _tbm_surf_queue_mutex_unlock();
                return TBM_SURFACE_QUEUE_ERROR_INVALID_SURFACE;
        }
@@ -1255,7 +1239,7 @@ tbm_surface_queue_dequeue(tbm_surface_queue_h
                        surface_queue->impl->need_attach(surface_queue);
 
                if (!_tbm_surface_queue_is_valid(surface_queue)) {
-                       TBM_LOG_E("surface_queue:%p is invalid", surface_queue);
+                       TBM_ERR("surface_queue:%p is invalid", surface_queue);
                        pthread_mutex_unlock(&surface_queue->lock);
                        _tbm_surf_queue_mutex_unlock();
                        return TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE;
@@ -1268,7 +1252,7 @@ tbm_surface_queue_dequeue(tbm_surface_queue_h
                node = _tbm_surface_queue_dequeue(surface_queue);
 
        if (node == NULL || node->surface == NULL) {
-               TBM_LOG_E("_queue_node_pop_front failed\n");
+               TBM_ERR("_queue_node_pop_front failed\n");
                pthread_mutex_unlock(&surface_queue->lock);
 
                _tbm_surf_queue_mutex_unlock();
@@ -1278,7 +1262,7 @@ tbm_surface_queue_dequeue(tbm_surface_queue_h
        node->type = QUEUE_NODE_TYPE_DEQUEUE;
        *surface = node->surface;
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p) tbm_surface(%p)\n", surface_queue, *surface);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p) tbm_surface(%p)\n", surface_queue, *surface);
 
        pthread_mutex_unlock(&surface_queue->lock);
 
@@ -1308,14 +1292,14 @@ tbm_surface_queue_can_dequeue(tbm_surface_queue_h surface_queue, int wait)
 
        pthread_mutex_lock(&surface_queue->lock);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
 
        if (_queue_is_empty(&surface_queue->free_queue)) {
                if (surface_queue->impl && surface_queue->impl->need_attach)
                        surface_queue->impl->need_attach(surface_queue);
 
                if (!_tbm_surface_queue_is_valid(surface_queue)) {
-                       TBM_LOG_E("surface_queue:%p is invalid", surface_queue);
+                       TBM_ERR("surface_queue:%p is invalid", surface_queue);
                        pthread_mutex_unlock(&surface_queue->lock);
                        _tbm_surf_queue_mutex_unlock();
                        return 0;
@@ -1357,11 +1341,11 @@ tbm_surface_queue_release(tbm_surface_queue_h
 
        pthread_mutex_lock(&surface_queue->lock);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p) tbm_surface(%p)\n", surface_queue, surface);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p) tbm_surface(%p)\n", surface_queue, surface);
 
        node = _queue_get_node(surface_queue, 0, surface, &queue_type);
        if (node == NULL || queue_type != NODE_LIST) {
-               TBM_LOG_E("tbm_surface_queue_release::Surface is existed in free_queue or dirty_queue node:%p, type:%d\n",
+               TBM_ERR("tbm_surface_queue_release::Surface is existed in free_queue or dirty_queue node:%p, type:%d\n",
                        node, queue_type);
                pthread_mutex_unlock(&surface_queue->lock);
 
@@ -1374,7 +1358,7 @@ tbm_surface_queue_release(tbm_surface_queue_h
        }
 
        if (node->delete_pending) {
-               TBM_QUEUE_TRACE("delete pending tbm_surface_queue(%p) surface(%p)\n", surface_queue, node->surface);
+               TBM_TRACE_SURFACE_QUEUE("delete pending tbm_surface_queue(%p) surface(%p)\n", surface_queue, node->surface);
 
                _queue_delete_node(surface_queue, node);
 
@@ -1388,7 +1372,7 @@ tbm_surface_queue_release(tbm_surface_queue_h
        }
 
        if (surface_queue->queue_size < surface_queue->num_attached) {
-               TBM_QUEUE_TRACE("deatch tbm_surface_queue(%p) surface(%p)\n", surface_queue, node->surface);
+               TBM_TRACE_SURFACE_QUEUE("deatch tbm_surface_queue(%p) surface(%p)\n", surface_queue, node->surface);
 
                if (surface_queue->impl && surface_queue->impl->need_detach)
                        surface_queue->impl->need_detach(surface_queue, node);
@@ -1410,7 +1394,7 @@ tbm_surface_queue_release(tbm_surface_queue_h
                _tbm_surface_queue_release(surface_queue, node, 1);
 
        if (!_queue_get_node(surface_queue, FREE_QUEUE, surface, NULL)) {
-               TBM_LOG_E("release surface(%p) but surface isn't present in the free_queue\n", surface);
+               TBM_ERR("release surface(%p) but surface isn't present in the free_queue\n", surface);
                pthread_mutex_unlock(&surface_queue->lock);
 
                _tbm_surf_queue_mutex_unlock();
@@ -1447,11 +1431,11 @@ tbm_surface_queue_cancel_acquire(tbm_surface_queue_h
 
        pthread_mutex_lock(&surface_queue->lock);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p) tbm_surface(%p)\n", surface_queue, surface);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p) tbm_surface(%p)\n", surface_queue, surface);
 
        node = _queue_get_node(surface_queue, 0, surface, &queue_type);
        if (node == NULL || queue_type != NODE_LIST) {
-               TBM_LOG_E("tbm_surface_queue_cancel_acquire::Surface is existed in free_queue or dirty_queue node:%p, type:%d\n",
+               TBM_ERR("tbm_surface_queue_cancel_acquire::Surface is existed in free_queue or dirty_queue node:%p, type:%d\n",
                        node, queue_type);
                pthread_mutex_unlock(&surface_queue->lock);
 
@@ -1465,7 +1449,7 @@ tbm_surface_queue_cancel_acquire(tbm_surface_queue_h
                _tbm_surface_queue_enqueue(surface_queue, node, 1);
 
        if (_queue_is_empty(&surface_queue->dirty_queue)) {
-               TBM_LOG_E("enqueue surface but queue is empty node:%p\n", node);
+               TBM_ERR("enqueue surface but queue is empty node:%p\n", node);
                pthread_mutex_unlock(&surface_queue->lock);
 
                _tbm_surf_queue_mutex_unlock();
@@ -1509,7 +1493,7 @@ tbm_surface_queue_acquire(tbm_surface_queue_h
                node = _tbm_surface_queue_acquire(surface_queue);
 
        if (node == NULL || node->surface == NULL) {
-               TBM_LOG_E("_queue_node_pop_front failed\n");
+               TBM_ERR("_queue_node_pop_front failed\n");
                pthread_mutex_unlock(&surface_queue->lock);
 
                _tbm_surf_queue_mutex_unlock();
@@ -1524,16 +1508,16 @@ tbm_surface_queue_acquire(tbm_surface_queue_h
                tbm_surface_info_s info;
                int ret;
 
-               TBM_LOG_E("start map surface:%p", *surface);
+               TBM_ERR("start map surface:%p", *surface);
                ret = tbm_surface_map(*surface, TBM_SURF_OPTION_READ, &info);
-               TBM_LOG_E("end map surface:%p", *surface);
+               TBM_ERR("end map surface:%p", *surface);
                if (ret == TBM_SURFACE_ERROR_NONE)
                        tbm_surface_unmap(*surface);
        }
 
        if (surface_queue->acquire_sync_count > 0) surface_queue->acquire_sync_count--;
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p) tbm_surface(%p)\n", surface_queue, *surface);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p) tbm_surface(%p)\n", surface_queue, *surface);
 
        pthread_mutex_unlock(&surface_queue->lock);
 
@@ -1556,7 +1540,7 @@ tbm_surface_queue_can_acquire(tbm_surface_queue_h surface_queue, int wait)
 
        pthread_mutex_lock(&surface_queue->lock);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
 
        if (!_queue_is_empty(&surface_queue->dirty_queue)) {
                pthread_mutex_unlock(&surface_queue->lock);
@@ -1586,7 +1570,7 @@ tbm_surface_queue_destroy(tbm_surface_queue_h surface_queue)
 
        TBM_SURF_QUEUE_RETURN_IF_FAIL(_tbm_surface_queue_is_valid(surface_queue));
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
 
        LIST_DEL(&surface_queue->item_link);
 
@@ -1627,7 +1611,7 @@ tbm_surface_queue_reset(tbm_surface_queue_h
        TBM_SURF_QUEUE_RETURN_VAL_IF_FAIL(_tbm_surface_queue_is_valid(surface_queue),
                               TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
 
        if (width == surface_queue->width && height == surface_queue->height &&
                format == surface_queue->format) {
@@ -1717,7 +1701,7 @@ tbm_surface_queue_set_size(tbm_surface_queue_h
        TBM_SURF_QUEUE_RETURN_VAL_IF_FAIL(queue_size > 0,
                                        TBM_SURFACE_QUEUE_ERROR_INVALID_PARAMETER);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
 
        if ((surface_queue->queue_size == queue_size) && !flush) {
                _tbm_surf_queue_mutex_unlock();
@@ -1764,7 +1748,7 @@ tbm_surface_queue_set_size(tbm_surface_queue_h
                        int need_del = surface_queue->queue_size - queue_size;
 
                        LIST_FOR_EACH_ENTRY_SAFE(node, tmp, &surface_queue->free_queue.head, item_link) {
-                               TBM_QUEUE_TRACE("deatch tbm_surface_queue(%p) surface(%p)\n", surface_queue, node->surface);
+                               TBM_TRACE_SURFACE_QUEUE("deatch tbm_surface_queue(%p) surface(%p)\n", surface_queue, node->surface);
 
                                if (surface_queue->impl && surface_queue->impl->need_detach)
                                        surface_queue->impl->need_detach(surface_queue, node);
@@ -1797,7 +1781,7 @@ tbm_surface_queue_free_flush(tbm_surface_queue_h surface_queue)
        TBM_SURF_QUEUE_RETURN_VAL_IF_FAIL(_tbm_surface_queue_is_valid(surface_queue),
                               TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
 
        if (surface_queue->num_attached == 0) {
                _tbm_surf_queue_mutex_unlock();
@@ -1833,7 +1817,7 @@ tbm_surface_queue_flush(tbm_surface_queue_h surface_queue)
        TBM_SURF_QUEUE_RETURN_VAL_IF_FAIL(_tbm_surface_queue_is_valid(surface_queue),
                               TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
 
        if (surface_queue->num_attached == 0) {
                _tbm_surf_queue_mutex_unlock();
@@ -2018,12 +2002,12 @@ tbm_surface_queue_create(int queue_size, int width,
                                            sizeof(struct _tbm_surface_queue));
        TBM_SURF_QUEUE_RETURN_VAL_IF_FAIL(surface_queue != NULL, NULL);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
 
        tbm_queue_default *data = (tbm_queue_default *) calloc(1,
                                  sizeof(tbm_queue_default));
        if (data == NULL) {
-               TBM_LOG_E("cannot allocate the tbm_queue_default.\n");
+               TBM_ERR("cannot allocate the tbm_queue_default.\n");
                free(surface_queue);
                _tbm_surf_queue_mutex_unlock();
                return NULL;
@@ -2178,12 +2162,12 @@ tbm_surface_queue_sequence_create(int queue_size, int width,
                                            sizeof(struct _tbm_surface_queue));
        TBM_SURF_QUEUE_RETURN_VAL_IF_FAIL(surface_queue != NULL, NULL);
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p)\n", surface_queue);
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p)\n", surface_queue);
 
        tbm_queue_sequence *data = (tbm_queue_sequence *) calloc(1,
                                   sizeof(tbm_queue_sequence));
        if (data == NULL) {
-               TBM_LOG_E("cannot allocate the tbm_queue_sequence.\n");
+               TBM_ERR("cannot allocate the tbm_queue_sequence.\n");
                free(surface_queue);
                _tbm_surf_queue_mutex_unlock();
                return NULL;
@@ -2244,7 +2228,7 @@ tbm_surface_queue_set_sync_count(tbm_surface_queue_h surface_queue,
        else
                surface_queue->enqueue_sync_count = dequeue_num + sync_count;
 
-       TBM_QUEUE_TRACE("tbm_surface_queue(%p) enqueue_sync_count:(%d) acquire_sync_count:(%d)\n",
+       TBM_TRACE_SURFACE_QUEUE("tbm_surface_queue(%p) enqueue_sync_count:(%d) acquire_sync_count:(%d)\n",
                                surface_queue, surface_queue->enqueue_sync_count, surface_queue->acquire_sync_count);
 
        pthread_mutex_unlock(&surface_queue->lock);
index 9ee38a01d6acf64b1bfe857072afe77599d5fcba..e126a36bc15955da8217e7e04d9945d683bef98d 100644 (file)
@@ -79,10 +79,10 @@ _log_errno()
        char    buf[ERRNO_BUF_SIZE];
 
        if (strerror_r(errnum, buf, ERRNO_BUF_SIZE) == 0) {
-               TBM_LOG_E("errno : %d(%s)\n", errnum, buf);
+               TBM_ERR("errno : %d(%s)\n", errnum, buf);
                return;
        } else {
-               TBM_LOG_E("errno : %d()\n", errnum);
+               TBM_ERR("errno : %d()\n", errnum);
                return;
        }
 }
index c2134267dd7a7d08175610ebf3fe7e7363ecf072..f711aaf05b441188872a054825c625ba45605d9b 100644 (file)
@@ -193,4 +193,16 @@ enum TBM_BO_FLAGS {
  */
 typedef void (*tbm_data_free) (void *user_data);
 
+/**
+ * @brief Enumeration of the trace log for debug
+ * @since_tizen 5.0
+ */
+typedef enum {
+       TBM_BUFGMR_DEBUG_TRACE_NONE             = 0,
+       TBM_BUFGMR_DEBUG_TRACE_BO               = (1 << 0),
+       TBM_BUFGMR_DEBUG_TRACE_SURFACE_INTERNAL = (1 << 1),
+       TBM_BUFGMR_DEBUG_TRACE_SURFACE          = (1 << 2),
+       TBM_BUFGMR_DEBUG_TRACE_SURFACE_QUEUE    = (1 << 3),
+} tbm_bufmgr_debug_trace_mask;
+
 #endif                                                 /* _TBM_TYPE_INT_H_ */
index 6da03984e4038116ab29ca006fbcaccf9e3e56a6..8e9f410938a8fa97c7dbf5c321e27c63687f0ee1 100644 (file)
@@ -11,11 +11,13 @@ tbm_utests_SOURCES = \
        ut_tbm_backend.cpp
 
 tbm_utests_CXXFLAGS = \
+       @DLOG_CFLAGS@ \
        ${CXXFLAGS} \
        -I$(top_builddir)/src \
        -I$(includedir)/gtest
 
 tbm_utests_LDFLAGS = \
+       @DLOG_LIBS@ \
        ${LDFLAGS} \
        $(top_builddir)/src/libtbm.la \
        -lgtest \
index 719e73979d422e8ccd17939257fdf79c708ff7b1..7393f8dc181f3c4a669f41d4a4a6ae21be93ef6c 100644 (file)
 #include <pthread.h>
 #include <gtest/gtest.h>
 #include <stdlib.h>
-#include <tbm_bufmgr.h>
-#include <tbm_bo.h>
 #include <tbm_bufmgr_int.h>
-#include <tbm_surface.h>
-#include <tbm_surface_internal.h>
-#include <tbm_surface_queue.h>
 #include <wayland-server-protocol.h>
 
-#undef TBM_DBG
-#define TBM_DBG(fmt, args...) \
-    TBM_LOG_D(fmt, ##args);
-#undef TBM_INFO
-#define TBM_INFO(fmt, args...) \
-    TBM_LOG_I(fmt, ##args);
-#undef TBM_WRN
-#define TBM_WRN(fmt, args...) \
-    TBM_LOG_W(fmt, ##args);
-#undef TBM_ERR
-#define TBM_ERR(fmt, args...) \
-    TBM_LOG_E(fmt, ##args);
-
 #define TBM_UT_ENTRY() \
     TBM_INFO("--------------------------------------------- %s", typeid(*this).name())