summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChangyeon Lee <cyeon.lee@samsung.com>2016-05-16 17:13:32 +0900
committerSooChan Lim <sc1.lim@samsung.com>2016-05-16 02:56:20 -0700
commita8dcbdcbc9c879f2196177ff2a096016aea3b386 (patch)
treee7aeee9335e5af0341523b290ad39478b3a7acc1
parent9badccfefed3346631c9017cd44e041e63e98de9 (diff)
downloadlibtbm-a8dcbdcbc9c879f2196177ff2a096016aea3b386.tar.gz
libtbm-a8dcbdcbc9c879f2196177ff2a096016aea3b386.tar.bz2
libtbm-a8dcbdcbc9c879f2196177ff2a096016aea3b386.zip
Support logging dlog
if TBM_DLOG=1(environment variable) is set, tbm log message with dlog system Change-Id: Ib130e2dee69b2d3d89ec03e1e33a566883bf48af
-rw-r--r--configure.ac17
-rw-r--r--packaging/libtbm.spec1
-rw-r--r--src/tbm_bufmgr.c174
-rw-r--r--src/tbm_bufmgr_backend.c8
-rw-r--r--src/tbm_bufmgr_int.h75
-rw-r--r--src/tbm_drm_helper_client.c8
-rw-r--r--src/tbm_drm_helper_server.c22
-rw-r--r--src/tbm_surface_internal.c39
-rw-r--r--src/tbm_surface_queue.c18
9 files changed, 201 insertions, 161 deletions
diff --git a/configure.ac b/configure.ac
index f726daa..f919408 100644
--- a/configure.ac
+++ b/configure.ac
@@ -75,8 +75,21 @@ PKG_CHECK_MODULES(WL_SERVER, wayland-server)
PKG_CHECK_MODULES(WL_SCANNER, wayland-scanner)
PKG_CHECK_MODULES(LIBPNG, libpng)
-LIBTBM_CFLAGS+="$LIBTBM_CFALGS $LIBDRM_CFLAGS $PTHREADSTUBS_CFLAGS $CAPI_CFLAGS $WL_CLIENT_CFLAGS $WL_SERVER_CFLAGS $LIBPNG_CFLAGS"
-LIBTBM_LIBS+="$LIBTBM_LIBS $LIBDRM_LIBS $PTHREADSTUBS_LIBS $CAPI_LIBS $WL_CLIENT_LIBS $WL_SERVER_LIBS $LIBPNG_LIBS"
+LIBTBM_CFLAGS+="$LIBTBM_CFALGS $LIBDRM_CFLAGS $PTHREADSTUBS_CFLAGS $CAPI_CFLAGS $WL_CLIENT_CFLAGS $WL_SERVER_CFLAGS $LIBPNG_CFLAGS "
+LIBTBM_LIBS+="$LIBTBM_LIBS $LIBDRM_LIBS $PTHREADSTUBS_LIBS $CAPI_LIBS $WL_CLIENT_LIBS $WL_SERVER_LIBS $LIBPNG_LIBS "
+
+PKG_CHECK_EXISTS([dlog], [have_dlog="yes"], [have_dlog="no"])
+AC_MSG_CHECKING([Have dlog logger])
+AC_MSG_RESULT([${have_dlog}])
+if test "x${have_dlog}" = "xyes"; then
+ AC_DEFINE([HAVE_DLOG], [1], [Define to 1 if you have dlog])
+
+ PKG_CHECK_MODULES(DLOG, dlog)
+
+ LIBTBM_CFLAGS+="$DLOG_CFLAGS "
+ LIBTBM_LIBS+="$DLOG_LIBS "
+fi
+
AC_SUBST(LIBTBM_CFLAGS)
AC_SUBST(LIBTBM_LIBS)
diff --git a/packaging/libtbm.spec b/packaging/libtbm.spec
index 03f0f62..ade712b 100644
--- a/packaging/libtbm.spec
+++ b/packaging/libtbm.spec
@@ -16,6 +16,7 @@ BuildRequires: pkgconfig(wayland-client)
BuildRequires: pkgconfig(pthread-stubs)
BuildRequires: pkgconfig(capi-base-common)
BuildRequires: pkgconfig(libpng)
+BuildRequires: pkgconfig(dlog)
%description
Description: %{summary}
diff --git a/src/tbm_bufmgr.c b/src/tbm_bufmgr.c
index 981d50e..702b709 100644
--- a/src/tbm_bufmgr.c
+++ b/src/tbm_bufmgr.c
@@ -36,14 +36,12 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "tbm_bufmgr_backend.h"
#include "list.h"
-#define DEBUG
#ifdef DEBUG
int bDebug;
-#define DBG(...) {if (bDebug&0x1) TBM_LOG(__VA_ARGS__);}
-#define DBG_LOCK(...) {if (bDebug&0x2) TBM_LOG(__VA_ARGS__);}
-#else
-#define DBG(...)
-#define DBG_LOCK(...)
+#endif
+
+#ifdef HAVE_DLOG
+int bDlog;
#endif
#define PREFIX_LIB "libtbm_"
@@ -218,9 +216,8 @@ _tbm_bo_lock(tbm_bo bo, int device, int opt)
return 1;
if (bo->lock_cnt < 0) {
- TBM_LOG("[libtbm:%d] "
- "error %s:%d bo:%p LOCK_CNT=%d\n",
- getpid(), __func__, __LINE__, bo, bo->lock_cnt);
+ TBM_LOG_E("error bo:%p LOCK_CNT=%d\n",
+ bo, bo->lock_cnt);
}
old = bo->lock_cnt;
@@ -240,12 +237,11 @@ _tbm_bo_lock(tbm_bo bo, int device, int opt)
if (ret)
bo->lock_cnt++;
} else {
- TBM_LOG("[libtbm:%d] "
- "error %s:%d bo:%p lock_type is wrong.\n",
- getpid(), __func__, __LINE__, bo);
+ TBM_LOG_E("error bo:%p lock_type is wrong.\n",
+ bo);
}
- DBG_LOCK("[libtbm:%d] >> LOCK bo:%p(%d->%d)\n", getpid(),
+ DBG_LOCK(">> LOCK bo:%p(%d->%d)\n",
bo, old, bo->lock_cnt);
return ret;
@@ -280,15 +276,14 @@ _tbm_bo_unlock(tbm_bo bo)
_bo_unlock(bo);
}
} else {
- TBM_LOG("[libtbm:%d] "
- "error %s:%d bo:%p lock_type is wrong.\n",
- getpid(), __func__, __LINE__, bo);
+ TBM_LOG_E("error bo:%p lock_type is wrong.\n",
+ bo);
}
if (bo->lock_cnt < 0)
bo->lock_cnt = 0;
- DBG_LOCK("[libtbm:%d] << unlock bo:%p(%d->%d)\n", getpid(),
+ DBG_LOCK(">> UNLOCK bo:%p(%d->%d)\n",
bo, old, bo->lock_cnt);
}
@@ -330,16 +325,14 @@ _tbm_bo_unref(tbm_bo bo)
/* destory the user_data_list */
if (!LIST_IS_EMPTY(&bo->user_data_list)) {
LIST_FOR_EACH_ENTRY_SAFE(old_data, tmp, &bo->user_data_list, item_link) {
- DBG("[libtbm:%d] free user_data\n",
- getpid());
+ DBG("free user_data\n");
user_data_delete(old_data);
}
}
if (bo->lock_cnt > 0) {
- TBM_LOG("[libtbm:%d] "
- "error %s:%d lock_cnt:%d\n",
- getpid(), __func__, __LINE__, bo->lock_cnt);
+ TBM_LOG_E("error lock_cnt:%d\n",
+ bo->lock_cnt);
_bo_unlock(bo);
}
@@ -363,27 +356,23 @@ _check_version(TBMModuleVersionInfo *data)
abimaj = GET_ABI_MAJOR(data->abiversion);
abimin = GET_ABI_MINOR(data->abiversion);
- DBG("[libtbm:%d] "
- "TBM module %s: vendor=\"%s\" ABI=%d,%d\n",
- getpid(), data->modname ? data->modname : "UNKNOWN!",
+ DBG("TBM module %s: vendor=\"%s\" ABI=%d,%d\n",
+ data->modname ? data->modname : "UNKNOWN!",
data->vendor ? data->vendor : "UNKNOWN!", abimaj, abimin);
vermaj = GET_ABI_MAJOR(TBM_ABI_VERSION);
vermin = GET_ABI_MINOR(TBM_ABI_VERSION);
- DBG("[libtbm:%d] "
- "TBM ABI version %d.%d\n",
- getpid(), vermaj, vermin);
+ DBG("TBM ABI version %d.%d\n",
+ vermaj, vermin);
if (abimaj != vermaj) {
- TBM_LOG("[libtbm:%d] "
- "TBM module ABI major ver(%d) doesn't match the TBM's ver(%d)\n",
- getpid(), abimaj, vermaj);
+ TBM_LOG_E("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("[libtbm:%d] "
- "TBM module ABI minor ver(%d) is newer than the TBM's ver(%d)\n",
- getpid(), abimin, vermin);
+ TBM_LOG_E("TBM module ABI minor ver(%d) is newer than the TBM's ver(%d)\n",
+ abimin, vermin);
return 0;
}
return 1;
@@ -400,9 +389,8 @@ _tbm_bufmgr_load_module(tbm_bufmgr bufmgr, int fd, const char *file)
module_data = dlopen(path, RTLD_LAZY);
if (!module_data) {
- TBM_LOG("[libtbm:%d] "
- "failed to load module: %s(%s)\n",
- getpid(), dlerror(), file);
+ TBM_LOG_E("failed to load module: %s(%s)\n",
+ dlerror(), file);
return 0;
}
@@ -420,9 +408,7 @@ _tbm_bufmgr_load_module(tbm_bufmgr bufmgr, int fd, const char *file)
return 0;
}
} else {
- TBM_LOG("[libtbm:%d] "
- "Error: module does not supply version information.\n",
- getpid());
+ TBM_LOG_E("Error: module does not supply version information.\n");
dlclose(module_data);
return 0;
@@ -430,40 +416,33 @@ _tbm_bufmgr_load_module(tbm_bufmgr bufmgr, int fd, const char *file)
if (init) {
if (!init(bufmgr, fd)) {
- TBM_LOG("[libtbm:%d] "
- "Fail to init module(%s)\n",
- getpid(), file);
+ TBM_LOG_E("Fail to init module(%s)\n",
+ file);
dlclose(module_data);
return 0;
}
if (!bufmgr->backend || !bufmgr->backend->priv) {
- TBM_LOG("[libtbm:%d] "
- "Error: module(%s) wrong operation. Check backend or backend's priv.\n",
- getpid(), file);
+ TBM_LOG_E("Error: module(%s) wrong operation. Check backend or backend's priv.\n",
+ file);
dlclose(module_data);
return 0;
}
} else {
- TBM_LOG("[libtbm:%d] "
- "Error: module does not supply init symbol.\n",
- getpid());
+ TBM_LOG_E("Error: module does not supply init symbol.\n");
dlclose(module_data);
return 0;
}
} else {
- TBM_LOG("[libtbm:%d] "
- "Error: module does not have data object.\n",
- getpid());
+ TBM_LOG_E("Error: module does not have data object.\n");
dlclose(module_data);
return 0;
}
bufmgr->module_data = module_data;
- DBG("[libtbm:%d] "
- "Success to load module(%s)\n",
- getpid(), file);
+ DBG("Success to load module(%s)\n",
+ file);
return 1;
}
@@ -483,9 +462,8 @@ _tbm_load_module(tbm_bufmgr bufmgr, int fd)
if (!ret) {
n = scandir(BUFMGR_MODULE_DIR, &namelist, 0, alphasort);
if (n < 0) {
- TBM_LOG("[libtbm:%d] "
- "no files : %s\n",
- getpid(), BUFMGR_MODULE_DIR);
+ TBM_LOG_E("no files : %s\n",
+ BUFMGR_MODULE_DIR);
} else {
while (n--) {
if (!ret && strstr(namelist[n]->d_name, PREFIX_LIB)) {
@@ -509,11 +487,21 @@ tbm_bufmgr_init(int fd)
pthread_mutex_lock(&gLock);
+#ifdef HAVE_DLOG
+ env = getenv("TBM_DLOG");
+ if (env) {
+ bDlog = atoi(env);
+ TBM_LOG_D("TBM_DLOG=%s\n", env);
+ } else {
+ bDlog = 0;
+ }
+#endif
+
#ifdef DEBUG
- env = getenv("GEM_DEBUG");
+ env = getenv("TBM_DEBUG");
if (env) {
bDebug = atoi(env);
- TBM_LOG("GEM_DEBUG=%s\n", env);
+ TBM_LOG_D("TBM_DEBUG=%s\n", env);
} else {
bDebug = 0;
}
@@ -523,13 +511,13 @@ tbm_bufmgr_init(int fd)
if (gBufMgr) {
gBufMgr->ref_count++;
- DBG("[libtbm:%d] bufmgr ref: fd=%d, ref_count:%d\n",
- getpid(), gBufMgr->fd, gBufMgr->ref_count);
+ DBG("bufmgr:%p ref: fd=%d, ref_count:%d\n",
+ gBufMgr, gBufMgr->fd, gBufMgr->ref_count);
pthread_mutex_unlock(&gLock);
return gBufMgr;
}
- DBG("[libtbm:%d] bufmgr init\n", getpid());
+ DBG("bufmgr init\n");
/* allocate bufmgr */
gBufMgr = calloc(1, sizeof(struct _tbm_bufmgr));
@@ -544,7 +532,7 @@ tbm_bufmgr_init(int fd)
/* load bufmgr priv from env */
if (!_tbm_load_module(gBufMgr, gBufMgr->fd)) {
_tbm_set_last_result(TBM_BO_ERROR_LOAD_MODULE_FAILED);
- TBM_LOG("[libtbm:%d] error : Fail to load bufmgr backend\n", getpid());
+ TBM_LOG_E("error : Fail to load bufmgr backend\n");
free(gBufMgr);
gBufMgr = NULL;
@@ -553,14 +541,13 @@ tbm_bufmgr_init(int fd)
}
/* log for tbm backend_flag */
- DBG("[libtbm:%d] ", getpid());
DBG("backend flag:%x:", gBufMgr->backend->flags);
DBG("\n");
gBufMgr->ref_count = 1;
- DBG("[libtbm:%d] create tizen bufmgr: ref_count:%d\n",
- getpid(), gBufMgr->ref_count);
+ DBG("create tizen bufmgr:%p ref_count:%d\n",
+ gBufMgr, gBufMgr->ref_count);
if (pthread_mutex_init(&gBufMgr->lock, NULL) != 0) {
_tbm_set_last_result(TBM_BO_ERROR_THREAD_INIT_FAILED);
@@ -584,8 +571,8 @@ tbm_bufmgr_init(int fd)
else
gBufMgr->lock_type = LOCK_TRY_ALWAYS;
- DBG("[libtbm:%d] BUFMGR_LOCK_TYPE=%s\n",
- getpid(), env ? env : "default:once");
+ DBG("BUFMGR_LOCK_TYPE=%s\n",
+ env ? env : "default:once");
/* intialize bo_list */
LIST_INITHEAD(&gBufMgr->bo_list);
@@ -612,9 +599,8 @@ tbm_bufmgr_deinit(tbm_bufmgr bufmgr)
bufmgr->ref_count--;
if (bufmgr->ref_count > 0) {
- TBM_LOG("[libtbm:%d] "
- "tizen bufmgr destroy: bufmgr:%p, ref_count:%d\n",
- getpid(), bufmgr, bufmgr->ref_count);
+ DBG("tizen bufmgr destroy: bufmgr:%p, ref_count:%d\n",
+ bufmgr, bufmgr->ref_count);
pthread_mutex_unlock(&gLock);
return;
}
@@ -622,9 +608,8 @@ tbm_bufmgr_deinit(tbm_bufmgr bufmgr)
/* destroy bo_list */
if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
LIST_FOR_EACH_ENTRY_SAFE(bo, tmp, &bufmgr->bo_list, item_link) {
- TBM_LOG("[libtbm:%d] "
- "Un-freed bo(%p, ref:%d)\n",
- getpid(), bo, bo->ref_cnt);
+ TBM_LOG_E("Un-freed bo(%p, ref:%d)\n",
+ bo, bo->ref_cnt);
bo->ref_cnt = 1;
tbm_bo_unref(bo);
}
@@ -633,9 +618,8 @@ tbm_bufmgr_deinit(tbm_bufmgr bufmgr)
/* destroy surf_list */
if (!LIST_IS_EMPTY(&bufmgr->surf_list)) {
LIST_FOR_EACH_ENTRY_SAFE(surf, tmp_surf, &bufmgr->surf_list, item_link) {
- TBM_LOG("[libtbm:%d] "
- "Destroy surf(%p)\n",
- getpid(), surf);
+ TBM_LOG_E("Un-freed surf(%p, ref:%d)\n",
+ surf, surf->refcnt);
tbm_surface_destroy(surf);
}
}
@@ -648,9 +632,8 @@ tbm_bufmgr_deinit(tbm_bufmgr bufmgr)
pthread_mutex_destroy(&bufmgr->lock);
- DBG("[libtbm:%d] "
- "tizen bufmgr destroy: bufmgr:%p\n",
- getpid(), bufmgr);
+ DBG("tizen bufmgr destroy: bufmgr:%p\n",
+ bufmgr);
dlclose(bufmgr->module_data);
@@ -781,9 +764,8 @@ tbm_bo_import(tbm_bufmgr bufmgr, unsigned int key)
if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
LIST_FOR_EACH_ENTRY_SAFE(bo2, tmp, &bufmgr->bo_list, item_link) {
if (bo2->priv == bo_priv) {
- DBG("[libtbm:%d] "
- "find bo(%p, ref:%d key:%d) in list\n",
- getpid(), bo2, bo2->ref_cnt, key);
+ DBG("find bo(%p, ref:%d key:%d) in list\n",
+ bo2, bo2->ref_cnt, key);
bo2->ref_cnt++;
free(bo);
@@ -841,9 +823,8 @@ tbm_bo_import_fd(tbm_bufmgr bufmgr, tbm_fd fd)
if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
LIST_FOR_EACH_ENTRY_SAFE(bo2, tmp, &bufmgr->bo_list, item_link) {
if (bo2->priv == bo_priv) {
- DBG("[libtbm:%d] "
- "find bo(%p, ref:%d, fd:%d) in list\n",
- getpid(), bo2, bo2->ref_cnt, fd);
+ DBG("find bo(%p, ref:%d, fd:%d) in list\n",
+ bo2, bo2->ref_cnt, fd);
bo2->ref_cnt++;
free(bo);
@@ -950,9 +931,8 @@ 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("[libtbm:%d] "
- "error %s:%d fail to lock bo:%p)\n",
- getpid(), __func__, __LINE__, bo);
+ TBM_LOG_E("error fail to lock bo:%p)\n",
+ bo);
pthread_mutex_unlock(&bufmgr->lock);
return (tbm_bo_handle) NULL;
}
@@ -960,9 +940,8 @@ tbm_bo_map(tbm_bo bo, int device, int opt)
bo_handle = bufmgr->backend->bo_map(bo, device, opt);
if (bo_handle.ptr == NULL) {
_tbm_set_last_result(TBM_BO_ERROR_MAP_FAILED);
- TBM_LOG("[libtbm:%d] "
- "error %s:%d fail to map bo:%p\n",
- getpid(), __func__, __LINE__, bo);
+ TBM_LOG_E("error fail to map bo:%p\n",
+ bo);
_tbm_bo_unlock(bo);
pthread_mutex_unlock(&bufmgr->lock);
@@ -1067,9 +1046,8 @@ 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_LOG("[libtbm:%d] "
- "waring: %s:%d user data already exist. key:%ld\n",
- getpid(), __func__, __LINE__, key);
+ TBM_LOG_W("waring user data already exist. key:%ld\n",
+ key);
return 0;
}
@@ -1268,8 +1246,8 @@ tbm_bufmgr_debug_show(tbm_bufmgr bufmgr)
void
tbm_bufmgr_debug_trace(tbm_bufmgr bufmgr, int onoff)
{
- TBM_LOG("bufmgr=%p onoff=%d\n", bufmgr, onoff);
- TBM_LOG("Not implemented yet.\n");
+ TBM_LOG_D("bufmgr=%p onoff=%d\n", bufmgr, onoff);
+ TBM_LOG_D("Not implemented yet.\n");
}
/* internal function */
diff --git a/src/tbm_bufmgr_backend.c b/src/tbm_bufmgr_backend.c
index 65ef8c6..a467d2a 100644
--- a/src/tbm_bufmgr_backend.c
+++ b/src/tbm_bufmgr_backend.c
@@ -60,16 +60,12 @@ void tbm_backend_free(tbm_bufmgr_backend backend)
int tbm_backend_init(tbm_bufmgr bufmgr, tbm_bufmgr_backend backend)
{
if (!bufmgr) {
- TBM_LOG("[libtbm:%d] "
- "error (%s): fail to init tbm backend... bufmgr is null\n", getpid(),
- __func__);
+ TBM_LOG_E("error: fail to init tbm backend... bufmgr is null\n");
return 0;
}
if (!backend) {
- TBM_LOG("[libtbm:%d] "
- "error (%s): fail to init tbm backend... backend is null\n", getpid(),
- __func__);
+ TBM_LOG_E("error: fail to init tbm backend... backend is null\n");
return 0;
}
diff --git a/src/tbm_bufmgr_int.h b/src/tbm_bufmgr_int.h
index f0e116a..3cb5bb1 100644
--- a/src/tbm_bufmgr_int.h
+++ b/src/tbm_bufmgr_int.h
@@ -51,22 +51,88 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <tbm_bufmgr_backend.h>
#include <tbm_surface_queue.h>
+#define DEBUG
+#ifdef DEBUG
+extern int bDebug;
+
+#define DBG(...) {if (bDebug&0x1) TBM_LOG_D(__VA_ARGS__);}
+#define DBG_LOCK(...) {if (bDebug&0x2) TBM_LOG_D(__VA_ARGS__);}
+#else
+#define DBG(...)
+#define DBG_LOCK(...)
+#endif /* DEBUG */
+
+#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) {\
+ LOGD("[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__);\
+ } \
+}
+#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__)
+#endif /* HAVE_DLOG */
+
+#define TBM_DEBUG(fmt, ...) fprintf(stderr, "[TBM:DEBUG(%d)] " fmt, getpid(), ##__VA_ARGS__)
+
/* check condition */
#define TBM_RETURN_IF_FAIL(cond) {\
if (!(cond)) {\
- TBM_LOG("[%s] : '%s' failed.\n", __func__, #cond);\
+ TBM_LOG_E("'%s' failed.\n", #cond);\
return;\
} \
}
#define TBM_RETURN_VAL_IF_FAIL(cond, val) {\
if (!(cond)) {\
- TBM_LOG("[%s] : '%s' failed.\n", __func__, #cond);\
+ TBM_LOG_E("'%s' failed.\n", #cond);\
return val;\
} \
}
#define TBM_GOTO_VAL_IF_FAIL(cond, val) {\
if (!(cond)) {\
- TBM_LOG("[%s] : '%s' failed.\n", __func__, #cond);\
+ TBM_LOG_E("'%s' failed.\n", #cond);\
goto val;\
} \
}
@@ -94,9 +160,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
surf->item_link.next && \
surf->item_link.next->prev == &surf->item_link)
-#define TBM_DEBUG(fmt, ...) fprintf(stderr, "[TBM:DEBUG(%d)] " fmt, getpid(), ##__VA_ARGS__)
-#define TBM_LOG(fmt, ...) fprintf(stderr, "[TBM(%d):%s] " fmt, getpid(), __func__, ##__VA_ARGS__)
-
struct list_head {
struct list_head *prev;
struct list_head *next;
diff --git a/src/tbm_drm_helper_client.c b/src/tbm_drm_helper_client.c
index 7bc0eea..9f85694 100644
--- a/src/tbm_drm_helper_client.c
+++ b/src/tbm_drm_helper_client.c
@@ -98,7 +98,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("Failed to connect display\n");
+ TBM_LOG_E("Failed to connect display\n");
free(tbm_drm_client);
return 0;
@@ -108,7 +108,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("Failed to get registry\n");
+ TBM_LOG_E("Failed to get registry\n");
wl_display_disconnect(display);
free(tbm_drm_client);
@@ -119,7 +119,7 @@ tbm_drm_helper_get_auth_info(int *auth_fd, char **device, uint32_t *capabilities
wl_display_roundtrip(display); //For Gloabl registry
if (!tbm_drm_client->wl_tbm_drm_auth) {
- TBM_LOG("Failed to get wl_tbm_drm_auth interface\n");
+ TBM_LOG_E("Failed to get wl_tbm_drm_auth interface\n");
wl_registry_destroy(wl_registry);
wl_display_disconnect(display);
free(tbm_drm_client);
@@ -131,7 +131,7 @@ tbm_drm_helper_get_auth_info(int *auth_fd, char **device, uint32_t *capabilities
wl_display_roundtrip(display);
if (tbm_drm_client->auth_fd < 0) {
- TBM_LOG("Failed to get auth info\n");
+ TBM_LOG_E("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);
diff --git a/src/tbm_drm_helper_server.c b/src/tbm_drm_helper_server.c
index 5ddf991..3a30fd3 100644
--- a/src/tbm_drm_helper_server.c
+++ b/src/tbm_drm_helper_server.c
@@ -75,7 +75,7 @@ _send_server_auth_info(struct wayland_tbm_drm_auth_server *tbm_drm_auth_srv,
}
if (fd < 0) {
- TBM_LOG("failed to open drm : device_name, %s\n", tbm_drm_auth_srv->device_name);
+ TBM_LOG_E("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");
@@ -84,7 +84,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("failed to get magic\n");
+ TBM_LOG_E("failed to get magic\n");
wl_resource_post_error(resource, WL_TBM_DRM_AUTH_ERROR_AUTHENTICATE_FAIL,
"authenicate failed::get_magic");
@@ -93,7 +93,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("failed to authenticate magic\n");
+ TBM_LOG_E("failed to authenticate magic\n");
wl_resource_post_error(resource, WL_TBM_DRM_AUTH_ERROR_AUTHENTICATE_FAIL,
"authenicate failed::auth_magic");
@@ -164,7 +164,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("[TBM_DRM] fail to add socket\n");
+ TBM_LOG_E("[TBM_DRM] fail to add socket\n");
if (tbm_drm_auth_srv->device_name)
free(tbm_drm_auth_srv->device_name);
@@ -212,23 +212,23 @@ tbm_drm_helper_get_master_fd(void)
if (ret <= 0)
return -1;
- TBM_LOG("TDM_DRM_MASTER_FD: %d\n", fd);
+ TBM_LOG_I("TDM_DRM_MASTER_FD: %d\n", fd);
flags = fcntl(fd, F_GETFD);
if (flags == -1) {
- TBM_LOG("fcntl failed: %m");
+ TBM_LOG_E("fcntl failed: %m");
return -1;
}
new_fd = dup(fd);
if (new_fd < 0) {
- TBM_LOG("dup failed: %m");
+ TBM_LOG_E("dup failed: %m");
return -1;
}
fcntl(new_fd, F_SETFD, flags|FD_CLOEXEC);
- TBM_LOG("Return MASTER_FD: %d\n", new_fd);
+ TBM_LOG_I("Return MASTER_FD: %d\n", new_fd);
return new_fd;
}
@@ -244,11 +244,11 @@ tbm_drm_helper_set_tbm_master_fd(int fd)
ret = setenv("TBM_DRM_MASTER_FD", (const char*)buf, 1);
if (ret)
{
- TBM_LOG("failed to set TIZEN_DRM_MASTER_FD to %d", fd);
+ TBM_LOG_E("failed to set TIZEN_DRM_MASTER_FD to %d", fd);
return;
}
- TBM_LOG("TBM_DRM_MASTER_FD: %d\n", fd);
+ TBM_LOG_I("TBM_DRM_MASTER_FD: %d\n", fd);
}
void
@@ -259,7 +259,7 @@ tbm_drm_helper_unset_tbm_master_fd(void)
ret = unsetenv("TBM_DRM_MASTER_FD");
if (ret)
{
- TBM_LOG("failed to unset TBM_DRM_MASTER_FD");
+ TBM_LOG_E("failed to unset TBM_DRM_MASTER_FD");
return;
}
}
diff --git a/src/tbm_surface_internal.c b/src/tbm_surface_internal.c
index 4f79c10..2148274 100644
--- a/src/tbm_surface_internal.c
+++ b/src/tbm_surface_internal.c
@@ -181,7 +181,7 @@ _tbm_surface_mutex_init(void)
return true;
if (pthread_mutex_init(&tbm_surface_lock, NULL)) {
- TBM_LOG("[libtbm] fail: tbm_surface mutex init\n");
+ TBM_LOG_E("fail: tbm_surface mutex init\n");
return false;
}
@@ -265,8 +265,7 @@ _tbm_surface_internal_destroy(tbm_surface_h surface)
/* destory the user_data_list */
if (!LIST_IS_EMPTY(&surface->user_data_list)) {
LIST_FOR_EACH_ENTRY_SAFE(old_data, tmp, &surface->user_data_list, item_link) {
- TBM_LOG("[tbm_surface:%d] free user_data\n",
- getpid());
+ DBG("free user_data\n");
user_data_delete(old_data);
}
}
@@ -575,9 +574,7 @@ tbm_surface_internal_create_with_flags(int width, int height,
bo = calloc(1, sizeof(struct _tbm_bo));
if (!bo) {
- TBM_LOG("[libtbm:%d] "
- "error %s:%d fail to alloc bo struct\n",
- getpid(), __func__, __LINE__);
+ TBM_LOG_E("fail to alloc bo struct\n");
goto alloc_fail;
}
@@ -587,9 +584,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("[libtbm:%d] "
- "error %s:%d fail to alloc bo priv\n",
- getpid(), __func__, __LINE__);
+ TBM_LOG_E("fail to alloc bo priv\n");
free(bo);
pthread_mutex_unlock(&surf->bufmgr->lock);
goto alloc_fail;
@@ -612,9 +607,7 @@ tbm_surface_internal_create_with_flags(int width, int height,
}
if (!surf->bos[i]) {
- TBM_LOG("[libtbm:%d] "
- "error %s:%d fail to alloc bo\n",
- getpid(), __func__, __LINE__);
+ TBM_LOG_E("fail to alloc bo idx:%d\n", i);
goto alloc_fail;
}
@@ -1064,9 +1057,7 @@ 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_LOG("[libtbm:%d] "
- "waring: %s:%d user data already exist. key:%ld\n",
- getpid(), __func__, __LINE__, key);
+ TBM_LOG_W("waring user data already exist. key:%ld\n", key);
return 0;
}
@@ -1286,9 +1277,7 @@ tbm_surface_internal_dump_start(char *path, int w, int h, int count)
/* check running */
if (g_dump_info) {
- TBM_LOG("[libtbm:%d] "
- "waring: %s:%d already running the tbm_surface_internal_dump.\n",
- getpid(), __func__, __LINE__);
+ TBM_LOG_W("waring already running the tbm_surface_internal_dump.\n");
return;
}
@@ -1339,7 +1328,7 @@ tbm_surface_internal_dump_start(char *path, int w, int h, int count)
g_dump_info->path = path;
g_dump_info->link = &g_dump_info->surface_list;
- TBM_LOG("Dump Start.. path:%s, count:%d\n", g_dump_info->path, count);
+ TBM_LOG_I("Dump Start.. path:%s, count:%d\n", g_dump_info->path, count);
return;
fail:
@@ -1351,7 +1340,7 @@ fail:
}
}
- TBM_LOG("Dump Start fail.. path:%s\n", g_dump_info->path);
+ TBM_LOG_E("Dump Start fail.. path:%s\n", g_dump_info->path);
free(g_dump_info);
g_dump_info = NULL;
@@ -1382,7 +1371,7 @@ tbm_surface_internal_dump_end(void)
continue;
snprintf(file, sizeof(file), "%s/%s", g_dump_info->path, buf_info->name);
- TBM_LOG("Dump File.. %s generated.\n", file);
+ TBM_LOG_I("Dump File.. %s generated.\n", file);
switch (buf_info->info.format) {
case TBM_FORMAT_ARGB8888:
@@ -1417,7 +1406,7 @@ tbm_surface_internal_dump_end(void)
NULL, 0, NULL, 0);
break;
default:
- TBM_LOG("can't dump %c%c%c%c buffer", FOURCC_STR(buf_info->info.format));
+ TBM_LOG_E("can't dump %c%c%c%c buffer", FOURCC_STR(buf_info->info.format));
tbm_bo_unmap(buf_info->bo);
return;
}
@@ -1451,7 +1440,7 @@ tbm_surface_internal_dump_end(void)
free(g_dump_info);
g_dump_info = NULL;
- TBM_LOG("Dump End..\n");
+ TBM_LOG_I("Dump End..\n");
}
void
@@ -1534,7 +1523,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("can't copy %c%c%c%c buffer", FOURCC_STR(info.format));
+ TBM_LOG_E("can't copy %c%c%c%c buffer", FOURCC_STR(info.format));
tbm_bo_unmap(buf_info->bo);
return;
}
@@ -1607,6 +1596,6 @@ void tbm_surface_internal_dump_shm_buffer(void *ptr, int w, int h, int stride,
g_dump_info->link = next_link;
- TBM_LOG("Dump %s \n", buf_info->name);
+ TBM_LOG_I("Dump %s \n", buf_info->name);
}
diff --git a/src/tbm_surface_queue.c b/src/tbm_surface_queue.c
index 0cebb0c..62adc52 100644
--- a/src/tbm_surface_queue.c
+++ b/src/tbm_surface_queue.c
@@ -36,12 +36,12 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define DIRTY_QUEUE 2
#define NODE_LIST 4
-#define DEBUG 0
+#define TBM_QUEUE_DEBUG 0
-#if DEBUG
+#if TBM_QUEUE_DEBUG
#define TBM_QUEUE_TRACE(fmt, ...) fprintf(stderr, "[TBM(%d):%s] " fmt, getpid(), __func__, ##__VA_ARGS__)
-#define TBM_LOCK() TBM_LOG("[LOCK] %s:%d surface:%p\n", __func__, __LINE__, surface_queue)
-#define TBM_UNLOCK() TBM_LOG("[UNLOCK] %s:%d surface:%p\n", __func__, __LINE__, surface_queue)
+#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_QUEUE_TRACE(fmt, ...)
#define TBM_LOCK()
@@ -277,7 +277,7 @@ _notify_remove(struct list_head *list,
}
}
- TBM_LOG("Cannot find notifiy\n");
+ TBM_LOG_E("Cannot find notifiy\n");
}
static void
@@ -651,7 +651,7 @@ tbm_surface_queue_enqueue(tbm_surface_queue_h
node = _queue_get_node(surface_queue, 0, surface, &queue_type);
if (node == NULL || queue_type != NODE_LIST) {
- TBM_LOG("tbm_surface_queue_enqueue::Surface exist in free_queue or dirty_queue node:%p, queue:%d\n",
+ TBM_LOG_E("tbm_surface_queue_enqueue::Surface exist in free_queue or dirty_queue node:%p, queue:%d\n",
node, queue_type);
pthread_mutex_unlock(&surface_queue->lock);
return TBM_SURFACE_QUEUE_ERROR_INVALID_SURFACE;
@@ -701,7 +701,7 @@ tbm_surface_queue_dequeue(tbm_surface_queue_h
if (node->surface == NULL) {
*surface = NULL;
- TBM_LOG("_queue_node_pop_front failed\n");
+ TBM_LOG_E("_queue_node_pop_front failed\n");
pthread_mutex_unlock(&surface_queue->lock);
return TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE;
}
@@ -763,7 +763,7 @@ tbm_surface_queue_release(tbm_surface_queue_h
node = _queue_get_node(surface_queue, 0, surface, &queue_type);
if (node == NULL || queue_type != NODE_LIST) {
- TBM_LOG("tbm_surface_queue_release::Surface exist in free_queue or dirty_queue node:%p, queue:%d\n",
+ TBM_LOG_E("tbm_surface_queue_release::Surface exist in free_queue or dirty_queue node:%p, queue:%d\n",
node, queue_type);
pthread_mutex_unlock(&surface_queue->lock);
return TBM_SURFACE_QUEUE_ERROR_INVALID_SURFACE;
@@ -813,7 +813,7 @@ tbm_surface_queue_acquire(tbm_surface_queue_h
if (node->surface == NULL) {
*surface = NULL;
- TBM_LOG("_queue_node_pop_front failed\n");
+ TBM_LOG_E("_queue_node_pop_front failed\n");
pthread_mutex_unlock(&surface_queue->lock);
return TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE;
}