add scale factor to tbm_bufmgr_debug_dump_all() and tbm_bufmgr_debug_queue_dump(...
[platform/core/uifw/libtbm.git] / src / tbm_bufmgr.c
index 43bed67..f101e73 100644 (file)
@@ -36,6 +36,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "tbm_bufmgr_backend.h"
 #include "list.h"
 
+#include <sys/resource.h>
+
 #ifdef DEBUG
 int bDebug;
 #endif
@@ -54,7 +56,7 @@ int b_dump_queue;
 static pthread_mutex_t gLock = PTHREAD_MUTEX_INITIALIZER;
 static pthread_mutex_t tbm_bufmgr_lock = PTHREAD_MUTEX_INITIALIZER;
 static __thread tbm_error_e tbm_last_error = TBM_ERROR_NONE;
-
+static double scale_factor = 0;
 static void _tbm_bufmgr_mutex_unlock(void);
 
 //#define TBM_BUFMGR_INIT_TIME
@@ -104,6 +106,7 @@ _tbm_set_last_result(tbm_error_e err)
        tbm_last_error = err;
 }
 
+/* LCOV_EXCL_START */
 static bool
 _tbm_bufmgr_mutex_init(void)
 {
@@ -113,7 +116,7 @@ _tbm_bufmgr_mutex_init(void)
                return true;
 
        if (pthread_mutex_init(&tbm_bufmgr_lock, NULL)) {
-               TBM_LOG_E("fail: tbm_bufmgr mutex init\n");
+               TBM_LOG_E("fail: Cannot pthread_mutex_init for tbm_bufmgr_lock.\n");
                return false;
        }
 
@@ -125,8 +128,10 @@ _tbm_bufmgr_mutex_init(void)
 static void
 _tbm_bufmgr_mutex_lock(void)
 {
-       if (!_tbm_bufmgr_mutex_init())
+       if (!_tbm_bufmgr_mutex_init()) {
+               TBM_LOG_E("fail: _tbm_bufmgr_mutex_init()\n");
                return;
+       }
 
        pthread_mutex_lock(&tbm_bufmgr_lock);
 }
@@ -166,7 +171,6 @@ _tbm_flag_to_str(int f)
        return str;
 }
 
-/* LCOV_EXCL_START */
 static void
 _tbm_util_check_bo_cnt(tbm_bufmgr bufmgr)
 {
@@ -193,7 +197,7 @@ _tbm_util_get_max_surface_size(int *w, int *h)
        *w = 0;
        *h = 0;
 
-       if (gBufMgr == NULL || !LIST_IS_EMPTY(&gBufMgr->surf_list))
+       if (gBufMgr == NULL || LIST_IS_EMPTY(&gBufMgr->surf_list))
                return count;
 
        LIST_FOR_EACH_ENTRY(surface, &gBufMgr->surf_list, item_link) {
@@ -239,12 +243,12 @@ _tbm_util_get_appname_from_pid(long pid, char *str)
 
        fp = fopen(fn_cmdline, "r");
        if (fp == 0) {
-               fprintf(stderr, "cannot file open %s\n", fn_cmdline);
+               TBM_LOG_E("cannot file open %s\n", fn_cmdline);
                return;
        }
 
        if (!fgets(cmdline, 255, fp)) {
-               fprintf(stderr, "fail to get appname for pid(%ld)\n", pid);
+               TBM_LOG_E("fail to get appname for pid(%ld)\n", pid);
                fclose(fp);
                return;
        }
@@ -283,8 +287,12 @@ tbm_user_data
        tbm_user_data *user_data;
 
        user_data = calloc(1, sizeof(tbm_user_data));
-       if (!user_data)
+       if (!user_data) {
+               /* LCOV_EXCL_START */
+               TBM_LOG_E("fail to allocate an user_date\n");
                return NULL;
+               /* LCOV_EXCL_STOP */
+       }
 
        user_data->key = key;
        user_data->free_func = data_free_func;
@@ -430,14 +438,18 @@ _tbm_bo_is_valid(tbm_bo bo)
                return 0;
        }
 
-       if (LIST_IS_EMPTY(&gBufMgr->bo_list))
+       if (LIST_IS_EMPTY(&gBufMgr->bo_list)) {
+               TBM_LOG_E("error: gBufMgr->bo_list is EMPTY.\n");
                return 0;
+       }
 
        LIST_FOR_EACH_ENTRY(old_data, &gBufMgr->bo_list, item_link) {
                if (old_data == bo)
                        return 1;
        }
 
+       TBM_LOG_E("error: No valid bo(%p).\n", bo);
+
        return 0;
 }
 
@@ -610,10 +622,15 @@ tbm_bufmgr_init(int fd)
        } else
                bTrace = 0;
 #endif
-       /* LCOV_EXCL_STOP */
 
        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");
+       }
+
+
        /* initialize buffer manager */
        if (gBufMgr) {
                gBufMgr->ref_count++;
@@ -637,15 +654,15 @@ tbm_bufmgr_init(int fd)
 
        /* load bufmgr priv from env */
        if (!_tbm_load_module(gBufMgr, gBufMgr->fd)) {
-               /* LCOV_EXCL_START */
                _tbm_set_last_result(TBM_BO_ERROR_LOAD_MODULE_FAILED);
                TBM_LOG_E("error : Fail to load bufmgr backend\n");
                free(gBufMgr);
                gBufMgr = NULL;
                pthread_mutex_unlock(&gLock);
                return NULL;
-               /* LCOV_EXCL_STOP */
+
        }
+       /* LCOV_EXCL_STOP */
 
        /* log for tbm backend_flag */
        TBM_DBG("backend flag:%x:", gBufMgr->backend->flags);
@@ -854,11 +871,13 @@ tbm_bo_alloc(tbm_bufmgr bufmgr, int size, int flags)
 
        bo = calloc(1, sizeof(struct _tbm_bo));
        if (!bo) {
-               TBM_TRACE("error: fail to create of tbm_bo size(%d) flag(%s)\n",
+               /* LCOV_EXCL_START */
+               TBM_LOG_E("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_bufmgr_mutex_unlock();
                return NULL;
+               /* LCOV_EXCL_STOP */
        }
 
        _tbm_util_check_bo_cnt(bufmgr);
@@ -867,12 +886,14 @@ tbm_bo_alloc(tbm_bufmgr bufmgr, int size, int flags)
 
        bo_priv = bufmgr->backend->bo_alloc(bo, size, flags);
        if (!bo_priv) {
-               TBM_TRACE("error: fail to create of tbm_bo size(%d) flag(%s)\n",
+               /* LCOV_EXCL_START */
+               TBM_LOG_E("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);
                _tbm_bufmgr_mutex_unlock();
                return NULL;
+               /* LCOV_EXCL_STOP */
        }
 
        bufmgr->bo_cnt++;
@@ -905,28 +926,34 @@ tbm_bo_import(tbm_bufmgr bufmgr, unsigned int key)
        TBM_BUFMGR_RETURN_VAL_IF_FAIL(bufmgr == gBufMgr, NULL);
 
        if (!bufmgr->backend->bo_import) {
+               /* LCOV_EXCL_START */
                _tbm_bufmgr_mutex_unlock();
                return NULL;
+               /* LCOV_EXCL_STOP */
        }
 
        _tbm_util_check_bo_cnt(bufmgr);
 
        bo = calloc(1, sizeof(struct _tbm_bo));
        if (!bo) {
-               TBM_TRACE("error: fail to import of tbm_bo by key(%d)\n", key);
+               /* LCOV_EXCL_START */
+               TBM_LOG_E("error: fail to import of tbm_bo by key(%d)\n", key);
                _tbm_bufmgr_mutex_unlock();
                return NULL;
+               /* LCOV_EXCL_STOP */
        }
 
        bo->bufmgr = bufmgr;
 
        bo_priv = bufmgr->backend->bo_import(bo, key);
        if (!bo_priv) {
-               TBM_TRACE("error: fail to import of tbm_bo by key(%d)\n", key);
+               /* LCOV_EXCL_START */
+               TBM_LOG_E("error: fail to import of tbm_bo by key(%d)\n", key);
                _tbm_set_last_result(TBM_BO_ERROR_IMPORT_FAILED);
                free(bo);
                _tbm_bufmgr_mutex_unlock();
                return NULL;
+               /* LCOV_EXCL_STOP */
        }
 
        if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
@@ -979,28 +1006,34 @@ tbm_bo_import_fd(tbm_bufmgr bufmgr, tbm_fd fd)
        TBM_BUFMGR_RETURN_VAL_IF_FAIL(bufmgr == gBufMgr, NULL);
 
        if (!bufmgr->backend->bo_import_fd) {
+               /* LCOV_EXCL_START */
                _tbm_bufmgr_mutex_unlock();
                return NULL;
+               /* LCOV_EXCL_STOP */
        }
 
        _tbm_util_check_bo_cnt(bufmgr);
 
        bo = calloc(1, sizeof(struct _tbm_bo));
        if (!bo) {
-               TBM_TRACE("error: fail to import tbm_bo by tbm_fd(%d)\n", fd);
+               /* LCOV_EXCL_START */
+               TBM_LOG_E("error: fail to import tbm_bo by tbm_fd(%d)\n", fd);
                _tbm_bufmgr_mutex_unlock();
                return NULL;
+               /* LCOV_EXCL_STOP */
        }
 
        bo->bufmgr = bufmgr;
 
        bo_priv = bufmgr->backend->bo_import_fd(bo, fd);
        if (!bo_priv) {
-               TBM_TRACE("error: fail to import tbm_bo by tbm_fd(%d)\n", fd);
+               /* LCOV_EXCL_START */
+               TBM_LOG_E("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_bufmgr_mutex_unlock();
                return NULL;
+               /* LCOV_EXCL_STOP */
        }
 
        if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
@@ -1029,7 +1062,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)in list\n",
+       TBM_TRACE("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);
@@ -1053,16 +1086,20 @@ tbm_bo_export(tbm_bo bo)
        TBM_BUFMGR_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), 0);
 
        if (!bufmgr->backend->bo_export) {
+               /* LCOV_EXCL_START */
                _tbm_bufmgr_mutex_unlock();
                return 0;
+               /* LCOV_EXCL_STOP */
        }
 
        ret = bufmgr->backend->bo_export(bo);
        if (!ret) {
+               /* LCOV_EXCL_START */
                _tbm_set_last_result(TBM_BO_ERROR_EXPORT_FAILED);
-               TBM_TRACE("error: bo(%p) tbm_key(%d)\n", bo, ret);
+               TBM_LOG_E("error: bo(%p) tbm_key(%d)\n", bo, ret);
                _tbm_bufmgr_mutex_unlock();
                return ret;
+               /* LCOV_EXCL_STOP */
        }
 
        TBM_TRACE("bo(%p) tbm_key(%u)\n", bo, ret);
@@ -1084,16 +1121,20 @@ tbm_bo_export_fd(tbm_bo bo)
        TBM_BUFMGR_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), -1);
 
        if (!bufmgr->backend->bo_export_fd) {
+               /* LCOV_EXCL_START */
                _tbm_bufmgr_mutex_unlock();
                return -1;
+               /* LCOV_EXCL_STOP */
        }
 
        ret = bufmgr->backend->bo_export_fd(bo);
        if (ret < 0) {
+               /* LCOV_EXCL_START */
                _tbm_set_last_result(TBM_BO_ERROR_EXPORT_FD_FAILED);
-               TBM_TRACE("error: bo(%p) tbm_fd(%d)\n", bo, ret);
+               TBM_LOG_E("error: bo(%p) tbm_fd(%d)\n", bo, ret);
                _tbm_bufmgr_mutex_unlock();
                return ret;
+               /* LCOV_EXCL_STOP */
        }
 
        TBM_TRACE("bo(%p) tbm_fd(%d)\n", bo, ret);
@@ -1116,10 +1157,12 @@ tbm_bo_get_handle(tbm_bo bo, int device)
 
        bo_handle = bufmgr->backend->bo_get_handle(bo, device);
        if (bo_handle.ptr == NULL) {
+               /* LCOV_EXCL_START */
                _tbm_set_last_result(TBM_BO_ERROR_GET_HANDLE_FAILED);
-               TBM_TRACE("error: bo(%p) bo_handle(%p)\n", bo, bo_handle.ptr);
+               TBM_LOG_E("error: bo(%p) bo_handle(%p)\n", bo, bo_handle.ptr);
                _tbm_bufmgr_mutex_unlock();
                return (tbm_bo_handle) NULL;
+               /* LCOV_EXCL_STOP */
        }
 
        TBM_TRACE("bo(%p) bo_handle(%p)\n", bo, bo_handle.ptr);
@@ -1142,18 +1185,20 @@ 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_TRACE("error: fail to lock bo:%p)\n", bo);
+               TBM_LOG_E("error: fail to lock bo:%p)\n", bo);
                _tbm_bufmgr_mutex_unlock();
                return (tbm_bo_handle) NULL;
        }
 
        bo_handle = bufmgr->backend->bo_map(bo, device, opt);
        if (bo_handle.ptr == NULL) {
+               /* LCOV_EXCL_START */
                _tbm_set_last_result(TBM_BO_ERROR_MAP_FAILED);
-               TBM_TRACE("error: fail to map bo:%p\n", bo);
+               TBM_LOG_E("error: fail to map bo:%p\n", bo);
                _tbm_bo_unlock(bo);
                _tbm_bufmgr_mutex_unlock();
                return (tbm_bo_handle) NULL;
+               /* LCOV_EXCL_STOP */
        }
 
        /* increase the map_count */
@@ -1179,10 +1224,12 @@ tbm_bo_unmap(tbm_bo bo)
 
        ret = bufmgr->backend->bo_unmap(bo);
        if (!ret) {
-               TBM_TRACE("error: bo(%p) map_cnt(%d)\n", bo, bo->map_cnt);
+               /* LCOV_EXCL_START */
+               TBM_LOG_E("error: bo(%p) map_cnt(%d)\n", bo, bo->map_cnt);
                _tbm_set_last_result(TBM_BO_ERROR_UNMAP_FAILED);
                _tbm_bufmgr_mutex_unlock();
                return ret;
+               /* LCOV_EXCL_STOP */
        }
 
        /* decrease the map_count */
@@ -1213,7 +1260,7 @@ tbm_bo_swap(tbm_bo bo1, tbm_bo bo2)
 
        if (bufmgr->backend->bo_size(bo1) != bufmgr->backend->bo_size(bo2)) {
                _tbm_set_last_result(TBM_BO_ERROR_SWAP_FAILED);
-               TBM_TRACE("error: bo1(%p) bo2(%p)\n", bo1, bo2);
+               TBM_LOG_E("error: bo1(%p) bo2(%p)\n", bo1, bo2);
                _tbm_bufmgr_mutex_unlock();
                return 0;
        }
@@ -1240,7 +1287,7 @@ tbm_bo_locked(tbm_bo bo)
        TBM_BUFMGR_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), 0);
 
        if (bufmgr->lock_type == LOCK_TRY_NEVER) {
-               TBM_TRACE("bo(%p) lock_cnt(%d)\n", bo, bo->lock_cnt);
+               TBM_LOG_E("bo(%p) lock_cnt(%d)\n", bo, bo->lock_cnt);
                _tbm_bufmgr_mutex_unlock();
                return 0;
        }
@@ -1278,7 +1325,7 @@ tbm_bo_add_user_data(tbm_bo bo, unsigned long key,
 
        data = user_data_create(key, data_free_func);
        if (!data) {
-               TBM_TRACE("error: bo(%p) key(%lu)\n", bo, key);
+               TBM_LOG_E("error: bo(%p) key(%lu)\n", bo, key);
                _tbm_bufmgr_mutex_unlock();
                return 0;
        }
@@ -1437,9 +1484,9 @@ tbm_get_last_error(void)
 }
 
 void
-tbm_bufmgr_debug_show(tbm_bufmgr bufmgr)
+tbm_bufmgr_debug_tbm_info_get(tbm_bufmgr bufmgr, char *str, int *len)
 {
-       char app_name[255] = {0,}, title[255] = {0,};
+       char app_name[255] = {0,}, title[512] = {0,};
        tbm_surface_debug_data *debug_old_data = NULL;
 
        pthread_mutex_lock(&gLock);
@@ -1450,10 +1497,10 @@ tbm_bufmgr_debug_show(tbm_bufmgr bufmgr)
                return;
        }
 
-       TBM_DEBUG("\n");
+       TBM_SNPRINTF(str, len, "\n");
        _tbm_util_get_appname_from_pid(getpid(), app_name);
        _tbm_util_get_appname_brief(app_name);
-       TBM_DEBUG("============TBM DEBUG: %s(%d)===========================\n",
+       TBM_SNPRINTF(str, len, "============TBM DEBUG: %s(%d)===========================\n",
                  app_name, getpid());
 
        snprintf(title, 255, "%s", "no  surface     refcnt  width  height  bpp  size    n_b  n_p  flags  format    app_name       ");
@@ -1465,8 +1512,8 @@ tbm_bufmgr_debug_show(tbm_bufmgr bufmgr)
                }
        }
 
-       TBM_DEBUG("[tbm_surface information]\n");
-       TBM_DEBUG("%s\n", title);
+       TBM_SNPRINTF(str, len, "[tbm_surface information]\n");
+       TBM_SNPRINTF(str, len, "%s\n", title);
 
        /* show the tbm_surface information in surf_list */
        if (!LIST_IS_EMPTY(&bufmgr->surf_list)) {
@@ -1474,7 +1521,7 @@ tbm_bufmgr_debug_show(tbm_bufmgr bufmgr)
                int surf_cnt = 0;
 
                LIST_FOR_EACH_ENTRY(surf, &bufmgr->surf_list, item_link) {
-                       char data[255] = {0,};
+                       char data[512] = {0,};
                        unsigned int pid;
                        int i;
 
@@ -1515,21 +1562,21 @@ tbm_bufmgr_debug_show(tbm_bufmgr bufmgr)
                                                strncat(data, "none", 5);
                                }
                        }
-                       TBM_DEBUG("%s\n", data);
+                       TBM_SNPRINTF(str, len, "%s\n", data);
 
                        for (i = 0; i < surf->num_bos; i++) {
-                               TBM_DEBUG(" bo:%-12p  %-26d%-10d\n",
+                               TBM_SNPRINTF(str, len, " bo:%-12p  %-26d%-10d\n",
                                          surf->bos[i],
                                          surf->bos[i]->ref_cnt,
                                          bufmgr->backend->bo_size(surf->bos[i]) / 1024);
                        }
                }
        } else
-               TBM_DEBUG("no tbm_surfaces.\n");
-       TBM_DEBUG("\n");
+               TBM_SNPRINTF(str, len, " no tbm_surfaces.\n");
+       TBM_SNPRINTF(str, len, "\n");
 
-       TBM_DEBUG("[tbm_bo information]\n");
-       TBM_DEBUG("no  bo          refcnt  size    lock_cnt  map_cnt  flags  surface\n");
+       TBM_SNPRINTF(str, len, "[tbm_bo information]\n");
+       TBM_SNPRINTF(str, len, "no  bo          refcnt  size    lock_cnt  map_cnt  flags  surface\n");
 
        /* show the tbm_bo information in bo_list */
        if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
@@ -1537,7 +1584,7 @@ tbm_bufmgr_debug_show(tbm_bufmgr bufmgr)
                tbm_bo bo = NULL;
 
                LIST_FOR_EACH_ENTRY(bo, &bufmgr->bo_list, item_link) {
-                       TBM_DEBUG("%-4d%-11p   %-4d  %-6d     %-5d     %-4u    %-3d  %-11p\n",
+                       TBM_SNPRINTF(str, len, "%-4d%-11p   %-4d  %-6d     %-5d     %-4u    %-3d  %-11p\n",
                                  ++bo_cnt,
                                  bo,
                                  bo->ref_cnt,
@@ -1548,15 +1595,24 @@ tbm_bufmgr_debug_show(tbm_bufmgr bufmgr)
                                  bo->surface);
                }
        } else
-               TBM_DEBUG("no tbm_bos.\n");
-       TBM_DEBUG("\n");
+               TBM_SNPRINTF(str, len, "no tbm_bos.\n");
+       TBM_SNPRINTF(str, len, "\n");
 
-       TBM_DEBUG("===============================================================\n");
+       TBM_SNPRINTF(str, len, "===============================================================\n");
 
        pthread_mutex_unlock(&gLock);
 }
 
 void
+tbm_bufmgr_debug_show(tbm_bufmgr bufmgr)
+{
+       char str[1024*4];
+       int len = sizeof(str);
+       tbm_bufmgr_debug_tbm_info_get(bufmgr, str, &len);
+       TBM_DEBUG("     %s", str);
+}
+
+void
 tbm_bufmgr_debug_trace(tbm_bufmgr bufmgr, int onoff)
 {
        _tbm_bufmgr_mutex_lock();
@@ -1572,27 +1628,42 @@ tbm_bufmgr_debug_trace(tbm_bufmgr bufmgr, int onoff)
        _tbm_bufmgr_mutex_unlock();
 }
 
+void
+tbm_bufmgr_debug_dump_set_scale(double scale)
+{
+       pthread_mutex_lock(&gLock);
+       scale_factor = scale;
+       pthread_mutex_unlock(&gLock);
+}
+
 int
 tbm_bufmgr_debug_queue_dump(char *path, int count, int onoff)
 {
-       TBM_RETURN_VAL_IF_FAIL(path != NULL, 0);
-       TBM_LOG_D("path=%s count=%d onoff=%d\n", path, count, onoff);
-
        pthread_mutex_lock(&gLock);
 
        if (onoff == 0) {
+               TBM_LOG_D("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");
+                       pthread_mutex_unlock(&gLock);
+                       return 0;
+               }
+               TBM_LOG_D("path=%s count=%d onoff=%d\n", path, count, onoff);
+
                if (_tbm_util_get_max_surface_size(&w, &h) == 0) {
-                       TBM_LOG_I("Fail to get tbm_surface size.\n");
+                       TBM_LOG_E("Fail to get tbm_surface size.\n");
                        pthread_mutex_unlock(&gLock);
                        return 0;
                }
 
-               tbm_surface_internal_dump_start(path, w, h, count);
+               tbm_surface_internal_dump_with_scale_start(path, w, h, count, scale_factor);
+               scale_factor = 0;
+
                b_dump_queue = 1;
        }
 
@@ -1613,12 +1684,13 @@ tbm_bufmgr_debug_dump_all(char *path)
 
        count = _tbm_util_get_max_surface_size(&w, &h);
        if (count == 0) {
-               TBM_LOG_I("No tbm_surface.\n");
+               TBM_LOG_E("No tbm_surface.\n");
                pthread_mutex_unlock(&gLock);
                return 1;
        }
 
-       tbm_surface_internal_dump_start(path, w, h, count);
+       tbm_surface_internal_dump_with_scale_start(path, w, h, count, scale_factor);
+       scale_factor = 0;
 
        LIST_FOR_EACH_ENTRY(surface, &gBufMgr->surf_list, item_link)
                tbm_surface_internal_dump_buffer(surface, "dump_all");
@@ -1670,7 +1742,7 @@ tbm_bufmgr_bind_native_display(tbm_bufmgr bufmgr, void *NativeDisplay)
 
        ret = bufmgr->backend->bufmgr_bind_native_display(bufmgr, NativeDisplay);
        if (!ret) {
-               TBM_TRACE("error: tbm_bufmgr(%p) NativeDisplay(%p)\n",
+               TBM_LOG_E("error: tbm_bufmgr(%p) NativeDisplay(%p)\n",
                                bufmgr, NativeDisplay);
                _tbm_bufmgr_mutex_unlock();
                return 0;
@@ -1682,4 +1754,14 @@ tbm_bufmgr_bind_native_display(tbm_bufmgr bufmgr, void *NativeDisplay)
 
        return 1;
 }
+
+int tbm_bufmgr_get_fd_limit(void)
+{
+       struct rlimit lim;
+
+       if (getrlimit(RLIMIT_NOFILE, &lim))
+               return 1024;
+
+       return (int)lim.rlim_cur;
+}
 /* LCOV_EXCL_STOP */