Apply tizen coding rule
[platform/core/uifw/libtbm.git] / src / tbm_bufmgr.c
index 8df6c2d..a060584 100644 (file)
@@ -34,36 +34,20 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "tbm_bufmgr.h"
 #include "tbm_bufmgr_int.h"
 #include "tbm_bufmgr_backend.h"
-#include "tbm_bufmgr_tgl.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_"
 #define SUFFIX_LIB    ".so"
 #define DEFAULT_LIB   PREFIX_LIB"default"SUFFIX_LIB
 
-/* unneeded version 2.0 */
-#define BO_IS_CACHEABLE(bo) ((bo->flags & TBM_BO_NONCACHABLE) ? 0 : 1)
-#define DEVICE_IS_CACHE_AWARE(device) ((device == TBM_DEVICE_CPU) ? (1) : (0))
-
-/* tgl key values */
-#define GLOBAL_KEY   ((unsigned int)(-1))
-#define INITIAL_KEY  ((unsigned int)(-2))
-
-#define CACHE_OP_CREATE     (-1)
-#define CACHE_OP_ATTACH     (-2)
-#define CACHE_OP_IMPORT     (-3)
-/* unneeded version 2.0 */
-
 /* values to indicate unspecified fields in XF86ModReqInfo. */
 #define MAJOR_UNSPEC        0xFF
 #define MINOR_UNSPEC        0xFF
@@ -82,14 +66,6 @@ enum {
        LOCK_TRY_NEVER
 };
 
-/* unneeded version 2.0 */
-enum {
-       DEVICE_NONE = 0,
-       DEVICE_CA,              /* cache aware device */
-       DEVICE_CO               /* cache oblivious device */
-};
-/* unneeded version 2.0 */
-
 pthread_mutex_t gLock = PTHREAD_MUTEX_INITIALIZER;
 tbm_bufmgr gBufMgr;
 
@@ -101,6 +77,7 @@ _tbm_set_last_result(tbm_error_e err)
        tbm_last_error = err;
 }
 
+/* LCOV_EXCL_START */
 static void
 _tbm_util_get_appname_brief(char *brief)
 {
@@ -152,116 +129,7 @@ _tbm_util_get_appname_from_pid(long pid, char *str)
 
        snprintf(str, sizeof(cmdline), "%s", cmdline);
 }
-
-
-/* unneeded version 2.0 */
-static inline int
-_tgl_init(int fd, unsigned int key)
-{
-       struct tgl_attribute attr;
-       int err;
-
-       attr.key = key;
-       attr.timeout_ms = 1000;
-
-       err = ioctl(fd, TGL_IOC_INIT_LOCK, &attr);
-       if (err) {
-               TBM_LOG("[libtbm:%d] error(%s) %s:%d key:%d\n",
-                       getpid(), strerror(errno), __func__, __LINE__, key);
-               return 0;
-       }
-
-       return 1;
-}
-
-static inline int
-_tgl_destroy(int fd, unsigned int key)
-{
-       int err;
-
-       err = ioctl(fd, TGL_IOC_DESTROY_LOCK, key);
-       if (err) {
-               TBM_LOG("[libtbm:%d] "
-                       "error(%s) %s:%d key:%d\n",
-                       getpid(), strerror(errno), __func__, __LINE__, key);
-               return 0;
-       }
-
-       return 1;
-}
-
-static inline int
-_tgl_lock(int fd, unsigned int key)
-{
-       int err;
-
-       err = ioctl(fd, TGL_IOC_LOCK_LOCK, key);
-       if (err) {
-               TBM_LOG("[libtbm:%d] "
-                       "error(%s) %s:%d key:%d\n",
-                       getpid(), strerror(errno), __func__, __LINE__, key);
-               return 0;
-       }
-
-       return 1;
-}
-
-static inline int
-_tgl_unlock(int fd, unsigned int key)
-{
-       int err;
-
-       err = ioctl(fd, TGL_IOC_UNLOCK_LOCK, key);
-       if (err) {
-               TBM_LOG("[libtbm:%d] "
-                       "error(%s) %s:%d key:%d\n",
-                       getpid(), strerror(errno), __func__, __LINE__, key);
-               return 0;
-       }
-
-       return 1;
-}
-
-static inline int
-_tgl_set_data(int fd, unsigned int key, unsigned int val)
-{
-       int err;
-       struct tgl_user_data arg;
-
-       arg.key = key;
-       arg.data1 = val;
-       err = ioctl(fd, TGL_IOC_SET_DATA, &arg);
-       if (err) {
-               TBM_LOG("[libtbm:%d] "
-                       "error(%s) %s:%d key:%d\n",
-                       getpid(), strerror(errno), __func__, __LINE__, key);
-               return 0;
-       }
-
-       return 1;
-}
-
-static inline unsigned int
-_tgl_get_data(int fd, unsigned int key, unsigned int *locked)
-{
-       int err;
-       struct tgl_user_data arg = { 0, };
-
-       arg.key = key;
-       err = ioctl(fd, TGL_IOC_GET_DATA, &arg);
-       if (err) {
-               TBM_LOG("[libtbm:%d] "
-                       "error(%s) %s:%d key:%d\n",
-                       getpid(), strerror(errno), __func__, __LINE__, key);
-               return 0;
-       }
-
-       if (locked)
-               *locked = arg.locked;
-
-       return arg.data1;
-}
-/* unneeded version 2.0 */
+/* LCOV_EXCL_STOP */
 
 tbm_user_data
 *user_data_lookup(struct list_head *user_data_list, unsigned long key)
@@ -314,36 +182,10 @@ _bo_lock(tbm_bo bo, int device, int opt)
        tbm_bufmgr bufmgr = bo->bufmgr;
        int ret = 0;
 
-       if (bufmgr->use_2_0) {
-               if (bufmgr->backend->bo_lock2) {
-                       /* use bo_lock2 backend lock */
-                       ret = bufmgr->backend->bo_lock2(bo, device, opt);
-               } else if (bufmgr->backend->bo_lock) {
-                       /* use bo_lock backend lock */
-                       ret = bufmgr->backend->bo_lock(bo);
-               } else {
-                       TBM_LOG("[libtbm:%d] "
-                               "error %s:%d no backend lock functions\n",
-                               getpid(), __func__, __LINE__);
-               }
-       } else {
-               if (TBM_LOCK_CTRL_BACKEND_VALID(bufmgr->backend->flags)) {
-                       if (bufmgr->backend->bo_lock2) {
-                               /* use bo_lock2 backend lock */
-                               ret = bufmgr->backend->bo_lock2(bo, device, opt);
-                       } else if (bufmgr->backend->bo_lock) {
-                               /* use bo_lock backend lock */
-                               ret = bufmgr->backend->bo_lock(bo);
-                       } else {
-                               TBM_LOG("[libtbm:%d] "
-                                       "error %s:%d no backend lock functions\n",
-                                       getpid(), __func__, __LINE__);
-                       }
-               } else {
-                       /* use tizen global lock */
-                       ret = _tgl_lock(bufmgr->lock_fd, bo->tgl_key);
-               }
-       }
+       if (bufmgr->backend->bo_lock)
+               ret = bufmgr->backend->bo_lock(bo, device, opt);
+       else
+               ret = 1;
 
        return ret;
 }
@@ -353,159 +195,8 @@ _bo_unlock(tbm_bo bo)
 {
        tbm_bufmgr bufmgr = bo->bufmgr;
 
-       if (bufmgr->use_2_0) {
-               if (bufmgr->backend->bo_unlock) {
-                       /* use backend unlock */
-                       bufmgr->backend->bo_unlock(bo);
-               } else {
-                       TBM_LOG("[libtbm:%d] "
-                               "error %s:%d no backend unlock functions\n",
-                               getpid(), __func__, __LINE__);
-               }
-       } else {
-               if (TBM_LOCK_CTRL_BACKEND_VALID(bufmgr->backend->flags)) {
-                       if (bufmgr->backend->bo_unlock) {
-                               /* use backend unlock */
-                               bufmgr->backend->bo_unlock(bo);
-                       } else {
-                               TBM_LOG("[libtbm:%d] "
-                                       "error %s:%d no backend unlock functions\n",
-                                       getpid(), __func__, __LINE__);
-                       }
-               } else {
-                       /* use tizen global unlock */
-                       _tgl_unlock(bufmgr->lock_fd, bo->tgl_key);
-               }
-       }
-}
-
-static int
-_tbm_bo_init_state(tbm_bo bo, int opt)
-{
-       tbm_bufmgr bufmgr = bo->bufmgr;
-       tbm_bo_cache_state cache_state;
-
-       if (bo->tgl_key == INITIAL_KEY)
-               bo->tgl_key = bufmgr->backend->bo_get_global_key(bo);
-
-       if (!bo->default_handle.u32)
-               bo->default_handle = bufmgr->backend->bo_get_handle(bo, TBM_DEVICE_DEFAULT);
-
-       RETURN_VAL_CHECK_FLAG(TBM_ALL_CTRL_BACKEND_VALID(bufmgr->backend->flags), 1);
-
-       cache_state.val = 0;
-       switch (opt) {
-       case CACHE_OP_CREATE:           /*Create */
-
-               _tgl_init(bufmgr->lock_fd, bo->tgl_key);
-
-               cache_state.data.isCacheable = BO_IS_CACHEABLE(bo);
-               cache_state.data.isDirtied = DEVICE_NONE;
-               cache_state.data.isCached = 0;
-               cache_state.data.cntFlush = 0;
-
-               _tgl_set_data(bufmgr->lock_fd, bo->tgl_key, cache_state.val);
-               break;
-       case CACHE_OP_IMPORT:           /*Import */
-
-               _tgl_init(bufmgr->lock_fd, bo->tgl_key);
-               break;
-       default:
-               break;
-       }
-
-       return 1;
-}
-
-static void
-_tbm_bo_destroy_state(tbm_bo bo)
-{
-       tbm_bufmgr bufmgr = bo->bufmgr;
-
-       RETURN_CHECK_FLAG(TBM_ALL_CTRL_BACKEND_VALID(bufmgr->backend->flags));
-
-       _tgl_destroy(bufmgr->lock_fd, bo->tgl_key);
-}
-
-static int
-_tbm_bo_set_state(tbm_bo bo, int device, int opt)
-{
-       tbm_bufmgr bufmgr = bo->bufmgr;
-       char need_flush = 0;
-       unsigned short cntFlush = 0;
-       unsigned int is_locked;
-
-       RETURN_VAL_CHECK_FLAG(TBM_CACHE_CTRL_BACKEND_VALID(bufmgr->backend->flags), 1);
-
-       /* get cache state of a bo */
-       bo->cache_state.val = _tgl_get_data(bufmgr->lock_fd, bo->tgl_key, &is_locked);
-
-       if (!bo->cache_state.data.isCacheable)
-               return 1;
-
-       /* get global cache flush count */
-       cntFlush = (unsigned short)_tgl_get_data(bufmgr->lock_fd, GLOBAL_KEY, NULL);
-
-       if (DEVICE_IS_CACHE_AWARE(device)) {
-               if (bo->cache_state.data.isDirtied == DEVICE_CO &&
-                   bo->cache_state.data.isCached)
-                       need_flush = TBM_CACHE_INV;
-
-               bo->cache_state.data.isCached = 1;
-               if (opt & TBM_OPTION_WRITE)
-                       bo->cache_state.data.isDirtied = DEVICE_CA;
-               else {
-                       if (bo->cache_state.data.isDirtied != DEVICE_CA)
-                               bo->cache_state.data.isDirtied = DEVICE_NONE;
-               }
-       } else {
-               if (bo->cache_state.data.isDirtied == DEVICE_CA &&
-                   bo->cache_state.data.isCached &&
-                   bo->cache_state.data.cntFlush == cntFlush)
-                       need_flush = TBM_CACHE_CLN | TBM_CACHE_ALL;
-
-               if (opt & TBM_OPTION_WRITE)
-                       bo->cache_state.data.isDirtied = DEVICE_CO;
-               else {
-                       if (bo->cache_state.data.isDirtied != DEVICE_CO)
-                               bo->cache_state.data.isDirtied = DEVICE_NONE;
-               }
-       }
-
-       if (need_flush) {
-               /* set global cache flush count */
-               if (need_flush & TBM_CACHE_ALL)
-                       _tgl_set_data(bufmgr->lock_fd, GLOBAL_KEY, (unsigned int)(++cntFlush));
-
-               /* call backend cache flush */
-               bufmgr->backend->bo_cache_flush(bo, need_flush);
-
-               DBG("[libtbm:%d] \tcache(%d,%d,%d)....flush:0x%x, cntFlush(%d)\n",
-                   getpid(),
-                   bo->cache_state.data.isCacheable,
-                   bo->cache_state.data.isCached,
-                   bo->cache_state.data.isDirtied,
-                   need_flush,
-                   cntFlush);
-       }
-
-       return 1;
-}
-
-static void
-_tbm_bo_save_state(tbm_bo bo)
-{
-       tbm_bufmgr bufmgr = bo->bufmgr;
-       unsigned short cntFlush = 0;
-
-       RETURN_CHECK_FLAG(TBM_CACHE_CTRL_BACKEND_VALID(bufmgr->backend->flags));
-
-       /* get global cache flush count */
-       cntFlush = (unsigned short)_tgl_get_data(bufmgr->lock_fd, GLOBAL_KEY, NULL);
-
-       /* save global cache flush count */
-       bo->cache_state.data.cntFlush = cntFlush;
-       _tgl_set_data(bufmgr->lock_fd, bo->tgl_key, bo->cache_state.val);
+       if (bufmgr->backend->bo_unlock)
+               bufmgr->backend->bo_unlock(bo);
 }
 
 static int
@@ -525,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(%d) LOCK_CNT=%d\n",
-                       getpid(), __func__, __LINE__, bo, bo->tgl_key, bo->lock_cnt);
+               TBM_LOG_E("error bo:%p LOCK_CNT=%d\n",
+                       bo, bo->lock_cnt);
        }
 
        old = bo->lock_cnt;
@@ -547,13 +237,12 @@ _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->%d)\n", getpid(),
-                bo, bo->tgl_key, old, bo->lock_cnt);
+       DBG_LOCK(">> LOCK bo:%p(%d->%d)\n",
+                bo, old, bo->lock_cnt);
 
        return ret;
 }
@@ -587,16 +276,15 @@ _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->%d)\n", getpid(),
-                bo, bo->tgl_key, old, bo->lock_cnt);
+       DBG_LOCK(">> UNLOCK bo:%p(%d->%d)\n",
+                bo, old, bo->lock_cnt);
 }
 
 static int
@@ -637,24 +325,17 @@ _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);
                }
 
-               if (!bufmgr->use_2_0) {
-                       /* Destroy Global Lock */
-                       _tbm_bo_destroy_state(bo);
-               }
-
                /* call the bo_free */
                bufmgr->backend->bo_free(bo);
                bo->priv = NULL;
@@ -666,42 +347,7 @@ _tbm_bo_unref(tbm_bo bo)
 
 }
 
-static int
-_tbm_bufmgr_init_state(tbm_bufmgr bufmgr)
-{
-       RETURN_VAL_CHECK_FLAG(TBM_ALL_CTRL_BACKEND_VALID(bufmgr->backend->flags), 1);
-
-       bufmgr->lock_fd = open(tgl_devfile, O_RDWR);
-
-       if (bufmgr->lock_fd < 0) {
-               bufmgr->lock_fd = open(tgl_devfile1, O_RDWR);
-               if (bufmgr->lock_fd < 0) {
-
-                       TBM_LOG("[libtbm:%d] "
-                               "error: Fail to open global_lock:%s\n",
-                               getpid(), tgl_devfile);
-                       return 0;
-               }
-       }
-
-       if (!_tgl_init(bufmgr->lock_fd, GLOBAL_KEY)) {
-               TBM_LOG("[libtbm:%d] "
-                       "error: Fail to initialize the tgl\n",
-                       getpid());
-               return 0;
-       }
-
-       return 1;
-}
-
-static void
-_tbm_bufmgr_destroy_state(tbm_bufmgr bufmgr)
-{
-       RETURN_CHECK_FLAG(TBM_ALL_CTRL_BACKEND_VALID(bufmgr->backend->flags));
-
-       close(bufmgr->lock_fd);
-}
-
+/* LCOV_EXCL_START */
 static int
 _check_version(TBMModuleVersionInfo *data)
 {
@@ -711,27 +357,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;
@@ -748,9 +390,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;
        }
 
@@ -768,9 +409,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;
@@ -778,40 +417,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;
 }
@@ -831,9 +463,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)) {
@@ -849,54 +480,48 @@ _tbm_load_module(tbm_bufmgr bufmgr, int fd)
 
        return ret;
 }
+/* LCOV_EXCL_STOP */
 
 tbm_bufmgr
 tbm_bufmgr_init(int fd)
 {
        char *env;
-       int fd_flag = 0;
-       int backend_flag = 0;
 
        pthread_mutex_lock(&gLock);
 
+       /* LCOV_EXCL_START */
+#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;
        }
 #endif
+       /* LCOV_EXCL_STOP */
 
        /* initialize buffer manager */
        if (gBufMgr) {
-               DBG("[libtbm:%d] use previous gBufMgr\n", getpid());
-               if (!gBufMgr->fd_flag) {
-                       if (fd >= 0) {
-                               if (dup2(gBufMgr->fd, fd) < 0) {
-                                       _tbm_set_last_result(TBM_BO_ERROR_DUP_FD_FAILED);
-                                       TBM_LOG("[libtbm:%d] Fail to duplicate(dup2) the drm fd\n",
-                                               getpid());
-                                       pthread_mutex_unlock(&gLock);
-                                       return NULL;
-                               }
-                               DBG("[libtbm:%d] duplicate the drm_fd(%d), new drm_fd(%d).\n",
-                                   getpid(), gBufMgr->fd, fd);
-                       }
-               }
                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;
        }
 
-       if (fd < 0)
-               fd_flag = 1;
-
-       DBG("[libtbm:%d] bufmgr init: fd=%d\n", getpid(), fd);
+       DBG("bufmgr init\n");
 
        /* allocate bufmgr */
        gBufMgr = calloc(1, sizeof(struct _tbm_bufmgr));
@@ -906,110 +531,41 @@ tbm_bufmgr_init(int fd)
                return NULL;
        }
 
-       gBufMgr->fd_flag = fd_flag;
-
-       if (fd_flag) {
-               gBufMgr->fd = -1;
-       } else {
-               gBufMgr->fd = dup(fd);
-               if (gBufMgr->fd < 0) {
-                       _tbm_set_last_result(TBM_BO_ERROR_DUP_FD_FAILED);
-                       TBM_LOG("[libtbm:%d] Fail to duplicate(dup) the drm fd\n",
-                               getpid());
-                       free(gBufMgr);
-                       gBufMgr = NULL;
-                       pthread_mutex_unlock(&gLock);
-                       return NULL;
-               }
-               DBG("[libtbm:%d] duplicate the drm_fd(%d), bufmgr use fd(%d).\n",
-                   getpid(), fd, gBufMgr->fd);
-       }
+       gBufMgr->fd = 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("[libtbm:%d] error : Fail to load bufmgr backend\n", getpid());
-
-               if (gBufMgr->fd > 0)
-                       close(gBufMgr->fd);
+               TBM_LOG_E("error : Fail to load bufmgr backend\n");
 
                free(gBufMgr);
                gBufMgr = NULL;
                pthread_mutex_unlock(&gLock);
                return NULL;
+               /* LCOV_EXCL_STOP */
        }
 
-       backend_flag = gBufMgr->backend->flags;
        /* log for tbm backend_flag */
-       DBG("[libtbm:%d] ", getpid());
-       DBG("cache_crtl:");
-       if (backend_flag & TBM_CACHE_CTRL_BACKEND) {
-               DBG("BACKEND ");
-       } else {
-               DBG("TBM ");
-       }
-
-       DBG("lock_crtl:");
-       if (backend_flag & TBM_LOCK_CTRL_BACKEND) {
-               DBG("BACKEND ");
-       } else {
-               DBG("TBM ");
-       }
-
-       if (backend_flag & TBM_USE_2_0_BACKEND) {
-               gBufMgr->use_2_0 = 1;
-               DBG("USE 2.0 backend");
-       }
-
+       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) {
+               /* LCOV_EXCL_START */
                _tbm_set_last_result(TBM_BO_ERROR_THREAD_INIT_FAILED);
                gBufMgr->backend->bufmgr_deinit(gBufMgr->backend->priv);
                tbm_backend_free(gBufMgr->backend);
                dlclose(gBufMgr->module_data);
-
-               if (gBufMgr->fd > 0)
-                       close(gBufMgr->fd);
-
                free(gBufMgr);
                gBufMgr = NULL;
                pthread_mutex_unlock(&gLock);
                return NULL;
-       }
-
-       if (!gBufMgr->use_2_0) {
-               /* intialize the tizen global status */
-               if (!_tbm_bufmgr_init_state(gBufMgr)) {
-                       _tbm_set_last_result(TBM_BO_ERROR_INIT_STATE_FAILED);
-                       TBM_LOG("[libtbm:%d] error: Fail to init state\n", getpid());
-                       gBufMgr->backend->bufmgr_deinit(gBufMgr->backend->priv);
-                       tbm_backend_free(gBufMgr->backend);
-                       pthread_mutex_destroy(&gBufMgr->lock);
-                       dlclose(gBufMgr->module_data);
-
-                       if (gBufMgr->fd > 0)
-                               close(gBufMgr->fd);
-
-                       free(gBufMgr);
-                       gBufMgr = NULL;
-                       pthread_mutex_unlock(&gLock);
-                       return NULL;
-               }
-
-               /* setup the map_cache */
-               env = getenv("BUFMGR_MAP_CACHE");
-               if (env && !strcmp(env, "false"))
-                       gBufMgr->use_map_cache = 0;
-               else
-                       gBufMgr->use_map_cache = 1;
-               DBG("[libtbm:%d] BUFMGR_MAP_CACHE=%s\n",
-                   getpid(), env ? env : "default:true");
+               /* LCOV_EXCL_STOP */
        }
 
        /* setup the lock_type */
@@ -1023,8 +579,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);
@@ -1049,11 +605,16 @@ tbm_bufmgr_deinit(tbm_bufmgr bufmgr)
 
        pthread_mutex_lock(&gLock);
 
+       if (!gBufMgr) {
+               TBM_LOG_E("gBufmgr already destroy: bufmgr:%p\n", bufmgr);
+               pthread_mutex_unlock(&gLock);
+               return;
+       }
+
        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;
        }
@@ -1061,9 +622,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);
                }
@@ -1072,18 +632,12 @@ 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);
                }
        }
 
-       if (!bufmgr->use_2_0) {
-               /* destroy the tizen global status */
-               _tbm_bufmgr_destroy_state(bufmgr);
-       }
-
        /* destroy bufmgr priv */
        bufmgr->backend->bufmgr_deinit(bufmgr->backend->priv);
        bufmgr->backend->priv = NULL;
@@ -1092,9 +646,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);
 
@@ -1185,19 +738,6 @@ tbm_bo_alloc(tbm_bufmgr bufmgr, int size, int flags)
        bo->flags = flags;
        bo->priv = bo_priv;
 
-       if (!bufmgr->use_2_0) {
-               bo->tgl_key = INITIAL_KEY;
-               bo->default_handle.u32 = 0;
-
-               /* init bo state */
-               if (!_tbm_bo_init_state(bo, CACHE_OP_CREATE)) {
-                       _tbm_set_last_result(TBM_BO_ERROR_INIT_STATE_FAILED);
-                       _tbm_bo_unref(bo);
-                       pthread_mutex_unlock(&bufmgr->lock);
-                       return NULL;
-               }
-       }
-
        LIST_INITHEAD(&bo->user_data_list);
 
        LIST_ADD(&bo->item_link, &bufmgr->bo_list);
@@ -1219,23 +759,6 @@ tbm_bo_import(tbm_bufmgr bufmgr, unsigned int key)
 
        pthread_mutex_lock(&bufmgr->lock);
 
-       if (!bufmgr->use_2_0) {
-               /* find bo in list */
-               if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
-                       LIST_FOR_EACH_ENTRY_SAFE(bo2, tmp, &bufmgr->bo_list, item_link) {
-                               if (bo2->tgl_key == key) {
-                                       DBG("[libtbm:%d] "
-                                           "find bo(%p, ref:%d key:%d) in list\n",
-                                           getpid(), bo2, bo2->ref_cnt, bo2->tgl_key);
-
-                                       bo2->ref_cnt++;
-                                       pthread_mutex_unlock(&bufmgr->lock);
-                                       return bo2;
-                               }
-                       }
-               }
-       }
-
        bo = calloc(1, sizeof(struct _tbm_bo));
        if (!bo) {
                pthread_mutex_unlock(&bufmgr->lock);
@@ -1252,19 +775,16 @@ tbm_bo_import(tbm_bufmgr bufmgr, unsigned int key)
                return NULL;
        }
 
-       if (bufmgr->use_2_0) {
-               if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
-                       LIST_FOR_EACH_ENTRY_SAFE(bo2, tmp, &bufmgr->bo_list, item_link) {
-                               if (bo2->priv == bo_priv) {
-                                       DBG("[libtbm:%d] "
-                                           "find bo(%p, ref:%d key:%d) in list\n",
-                                           getpid(), bo2, bo2->ref_cnt, bo2->tgl_key);
-
-                                       bo2->ref_cnt++;
-                                       free(bo);
-                                       pthread_mutex_unlock(&bufmgr->lock);
-                                       return bo2;
-                               }
+       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("find bo(%p, ref:%d key:%d) in list\n",
+                                   bo2, bo2->ref_cnt, key);
+
+                               bo2->ref_cnt++;
+                               free(bo);
+                               pthread_mutex_unlock(&bufmgr->lock);
+                               return bo2;
                        }
                }
        }
@@ -1272,19 +792,6 @@ tbm_bo_import(tbm_bufmgr bufmgr, unsigned int key)
        bo->ref_cnt = 1;
        bo->priv = bo_priv;
 
-       if (!bufmgr->use_2_0) {
-               bo->tgl_key = INITIAL_KEY;
-               bo->default_handle.u32 = 0;
-
-               /* init bo state */
-               if (!_tbm_bo_init_state(bo, CACHE_OP_IMPORT)) {
-                       _tbm_set_last_result(TBM_BO_ERROR_INIT_STATE_FAILED);
-                       _tbm_bo_unref(bo);
-                       pthread_mutex_unlock(&bufmgr->lock);
-                       return NULL;
-               }
-       }
-
        if (bufmgr->backend->bo_get_flags)
                bo->flags = bufmgr->backend->bo_get_flags(bo);
        else
@@ -1308,29 +815,9 @@ tbm_bo_import_fd(tbm_bufmgr bufmgr, tbm_fd fd)
        tbm_bo bo2 = NULL;
        tbm_bo tmp = NULL;
        void *bo_priv = NULL;
-       tbm_bo_handle default_handle;
 
        pthread_mutex_lock(&bufmgr->lock);
 
-       if (!bufmgr->use_2_0) {
-               default_handle = bufmgr->backend->fd_to_handle(bufmgr, fd, TBM_DEVICE_DEFAULT);
-
-               /* find bo in list */
-               if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
-                       LIST_FOR_EACH_ENTRY_SAFE(bo2, tmp, &bufmgr->bo_list, item_link) {
-                               if (bo2->default_handle.u32 == default_handle.u32) {
-                                       DBG("[libtbm:%d] "
-                                           "find bo(%p, ref:%d handle:%d) in list\n",
-                                           getpid(), bo2, bo2->ref_cnt, bo2->default_handle.u32);
-
-                                       bo2->ref_cnt++;
-                                       pthread_mutex_unlock(&bufmgr->lock);
-                                       return bo2;
-                               }
-                       }
-               }
-       }
-
        bo = calloc(1, sizeof(struct _tbm_bo));
        if (!bo) {
                pthread_mutex_unlock(&bufmgr->lock);
@@ -1347,19 +834,16 @@ tbm_bo_import_fd(tbm_bufmgr bufmgr, tbm_fd fd)
                return NULL;
        }
 
-       if (bufmgr->use_2_0) {
-               if (!LIST_IS_EMPTY(&bufmgr->bo_list)) {
-                       LIST_FOR_EACH_ENTRY_SAFE(bo2, tmp, &bufmgr->bo_list, item_link) {
-                               if (bo2->priv == bo_priv) {
-                                       DBG("[libtbm:%d] "
-                                           "find bo(%p, ref:%d key:%d) in list\n",
-                                           getpid(), bo2, bo2->ref_cnt, bo2->tgl_key);
-
-                                       bo2->ref_cnt++;
-                                       free(bo);
-                                       pthread_mutex_unlock(&bufmgr->lock);
-                                       return bo2;
-                               }
+       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("find bo(%p, ref:%d, fd:%d) in list\n",
+                                   bo2, bo2->ref_cnt, fd);
+
+                               bo2->ref_cnt++;
+                               free(bo);
+                               pthread_mutex_unlock(&bufmgr->lock);
+                               return bo2;
                        }
                }
        }
@@ -1367,19 +851,6 @@ tbm_bo_import_fd(tbm_bufmgr bufmgr, tbm_fd fd)
        bo->ref_cnt = 1;
        bo->priv = bo_priv;
 
-       if (!bufmgr->use_2_0) {
-               bo->tgl_key = INITIAL_KEY;
-               bo->default_handle.u32 = 0;
-
-               /* init bo state */
-               if (!_tbm_bo_init_state(bo, CACHE_OP_IMPORT)) {
-                       _tbm_set_last_result(TBM_BO_ERROR_INIT_STATE_FAILED);
-                       _tbm_bo_unref(bo);
-                       pthread_mutex_unlock(&bufmgr->lock);
-                       return NULL;
-               }
-       }
-
        if (bufmgr->backend->bo_get_flags)
                bo->flags = bufmgr->backend->bo_get_flags(bo);
        else
@@ -1474,9 +945,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;
        }
@@ -1484,20 +954,14 @@ 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);
                return (tbm_bo_handle) NULL;
        }
 
-       if (!bufmgr->use_2_0) {
-               if (bufmgr->use_map_cache == 1 && bo->map_cnt == 0)
-                       _tbm_bo_set_state(bo, device, opt);
-       }
-
        /* increase the map_count */
        bo->map_cnt++;
 
@@ -1529,11 +993,6 @@ tbm_bo_unmap(tbm_bo bo)
        /* decrease the map_count */
        bo->map_cnt--;
 
-       if (!bufmgr->use_2_0) {
-               if (bo->map_cnt == 0)
-                       _tbm_bo_save_state(bo);
-       }
-
        _tbm_bo_unlock(bo);
 
        pthread_mutex_unlock(&bufmgr->lock);
@@ -1548,8 +1007,6 @@ tbm_bo_swap(tbm_bo bo1, tbm_bo bo2)
        TBM_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo2), 0);
 
        void *temp;
-       unsigned int tmp_key;
-       tbm_bo_handle tmp_defualt_handle;
 
        pthread_mutex_lock(&bo1->bufmgr->lock);
 
@@ -1559,16 +1016,6 @@ tbm_bo_swap(tbm_bo bo1, tbm_bo bo2)
                return 0;
        }
 
-       if (!bo1->bufmgr->use_2_0) {
-               tmp_key = bo1->tgl_key;
-               bo1->tgl_key = bo2->tgl_key;
-               bo2->tgl_key = tmp_key;
-
-               tmp_defualt_handle = bo1->default_handle;
-               bo1->default_handle = bo2->default_handle;
-               bo2->default_handle = tmp_defualt_handle;
-       }
-
        temp = bo1->priv;
        bo1->priv = bo2->priv;
        bo2->priv = temp;
@@ -1613,9 +1060,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;
        }
 
@@ -1690,12 +1136,6 @@ tbm_bo_delete_user_data(tbm_bo bo, unsigned long key)
        return 1;
 }
 
-tbm_error_e
-tbm_get_last_error(void)
-{
-       return tbm_last_error;
-}
-
 unsigned int
 tbm_bufmgr_get_capability(tbm_bufmgr bufmgr)
 {
@@ -1720,6 +1160,13 @@ tbm_bo_get_flags(tbm_bo bo)
        return bo->flags;
 }
 
+/* LCOV_EXCL_START */
+tbm_error_e
+tbm_get_last_error(void)
+{
+       return tbm_last_error;
+}
+
 void
 tbm_bufmgr_debug_show(tbm_bufmgr bufmgr)
 {
@@ -1771,9 +1218,8 @@ tbm_bufmgr_debug_show(tbm_bufmgr bufmgr)
                                  app_name);
 
                        for (i = 0; i < surf->num_bos; i++) {
-                               TBM_DEBUG(" bo:%-12p(key:%2d)   %-26d%-10d\n",
+                               TBM_DEBUG(" bo:%-12p  %-26d%-10d\n",
                                          surf->bos[i],
-                                         surf->bos[i]->tgl_key,
                                          surf->bos[i]->ref_cnt,
                                          tbm_bo_size(surf->bos[i]) / 1024);
                        }
@@ -1786,20 +1232,18 @@ tbm_bufmgr_debug_show(tbm_bufmgr bufmgr)
        TBM_DEBUG("\n");
 
        TBM_DEBUG("[tbm_bo information]\n");
-       TBM_DEBUG("no  bo                   refcnt  size     lock_cnt map_cnt cache_state flags surface\n");
+       TBM_DEBUG("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)) {
                LIST_FOR_EACH_ENTRY_SAFE(bo, tmp_bo, &bufmgr->bo_list, item_link) {
-                       TBM_DEBUG("%-4d%-11p(key:%2d)   %-6d%-12d%-9d%-9d%-10d%-4d%-11p\n",
+                       TBM_DEBUG("%-4d%-11p   %-6d%-12d%-9d%-9d%-4d%-11p\n",
                                  ++bo_cnt,
                                  bo,
-                                 bo->tgl_key,
                                  bo->ref_cnt,
                                  tbm_bo_size(bo) / 1024,
                                  bo->lock_cnt,
                                  bo->map_cnt,
-                                 bo->cache_state.val,
                                  bo->flags,
                                  bo->surface);
                }
@@ -1817,8 +1261,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 */
@@ -1832,3 +1276,28 @@ _tbm_bo_set_surface(tbm_bo bo, tbm_surface_h surface)
        return 1;
 }
 
+int
+tbm_bufmgr_bind_native_display(tbm_bufmgr bufmgr, void *NativeDisplay)
+{
+       TBM_RETURN_VAL_IF_FAIL(TBM_BUFMGR_IS_VALID(bufmgr), 0);
+
+       int ret;
+
+       pthread_mutex_lock(&bufmgr->lock);
+
+       if (!bufmgr->backend->bufmgr_bind_native_display) {
+               pthread_mutex_unlock(&bufmgr->lock);
+               return 1;
+       }
+
+       ret = bufmgr->backend->bufmgr_bind_native_display(bufmgr, NativeDisplay);
+       if (!ret) {
+               pthread_mutex_unlock(&bufmgr->lock);
+               return 0;
+       }
+
+       pthread_mutex_unlock(&bufmgr->lock);
+
+       return 1;
+}
+/* LCOV_EXCL_STOP */