tbm_module: add tbm_module_bo_exportd_key and use it 24/260024/2
authorSooChan Lim <sc1.lim@samsung.com>
Thu, 17 Jun 2021 10:20:52 +0000 (19:20 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Thu, 17 Jun 2021 11:02:46 +0000 (20:02 +0900)
The tbm_module_bo_export_key calls it's backend function

Change-Id: I24be15e2e60829bb4d4da0d562f032447c232c22

src/tbm_bo.c
src/tbm_bufmgr.c
src/tbm_bufmgr_int.h
src/tbm_module.c

index fcf5e86..6bb9198 100644 (file)
@@ -479,54 +479,18 @@ tbm_bo_export(tbm_bo bo)
 
        TBM_BO_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), 0);
 
-       if (bo->bufmgr->use_hal_tbm) {
-               ret = (hal_tbm_key)hal_tbm_bo_export_key((hal_tbm_bo *)bo->bo_data, (hal_tbm_error *)&error);
-               if (!ret) {
-                       /* LCOV_EXCL_START */
-                       TBM_ERR("error: bo(%p) tbm_key(%d) error(%d)\n", bo, ret, error);
-                       _tbm_set_last_result(error);
-                       goto done;
-                       /* LCOV_EXCL_STOP */
-               }
-       } else if (bo->bufmgr->backend_module_data) {
-               if (!bo->bufmgr->bo_func->bo_export_key) {
-                       /* LCOV_EXCL_START */
-                       _tbm_bufmgr_mutex_unlock();
-                       _tbm_set_last_result(TBM_ERROR_NOT_SUPPORTED);
-                       return 0;
-                       /* LCOV_EXCL_STOP */
-               }
-
-               ret = bo->bufmgr->bo_func->bo_export_key(bo->bo_data, &error);
-               if (!ret) {
-                       /* LCOV_EXCL_START */
-                       TBM_ERR("error: bo(%p) tbm_key(%d) error(%d)\n", bo, ret, error);
-                       _tbm_set_last_result(error);
-                       goto done;
-                       /* LCOV_EXCL_STOP */
-               }
-       } else {
-               if (!bo->bufmgr->backend->bo_export) {
-                       /* LCOV_EXCL_START */
-                       _tbm_bufmgr_mutex_unlock();
-                       _tbm_set_last_result(TBM_ERROR_NOT_SUPPORTED);
-                       return 0;
-                       /* LCOV_EXCL_STOP */
-               }
-
-               ret = bo->bufmgr->backend->bo_export(bo);
-               if (!ret) {
-                       /* LCOV_EXCL_START */
-                       TBM_ERR("error: bo(%p) tbm_key(%d)\n", bo, ret);
-                       _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION);
-                       goto done;
-                       /* LCOV_EXCL_STOP */
-               }
+       ret = tbm_module_bo_export_key(bo->bufmgr->module, bo, bo->bo_data, &error);
+       if (!ret) {
+               /* LCOV_EXCL_START */
+               TBM_ERR("tbm_moule_bo_export_key failed. bo:%p tbm_key:%d error:%d", bo, ret, error);
+               _tbm_set_last_result(error);
+               _tbm_bufmgr_mutex_unlock();
+               return ret;
+               /* LCOV_EXCL_STOP */
        }
 
-       TBM_TRACE_BO("bo(%p) tbm_key(%u)\n", bo, ret);
+       TBM_TRACE_BO("bo:%p tbm_key:%u", bo, ret);
 
-done:
        _tbm_bufmgr_mutex_unlock();
 
        return ret;
index 9fae74c..d0f18b0 100644 (file)
@@ -600,16 +600,9 @@ tbm_bufmgr_debug_tbm_info_get(tbm_bufmgr bufmgr)
                        size = tbm_module_bo_get_size(bufmgr->module, bo, bo->bo_data, &error);
                        if (error != TBM_ERROR_NONE)
                                TBM_WRN("fail to get the size of bo.");
-
-                       if (bo->bufmgr->use_hal_tbm) {
-                               key = (tbm_key)hal_tbm_bo_export_key((hal_tbm_bo *)bo->bo_data, (hal_tbm_error *)&error);
-                       } else if (bufmgr->backend_module_data) {
-                               key = bufmgr->bo_func->bo_export_key(bo->bo_data, &error);
-                               if (error != TBM_ERROR_NONE)
-                                       TBM_WRN("fail to get the tdm_key of bo.");
-                       } else {
-                               key = bufmgr->backend->bo_export(bo);
-                       }
+                       key = tbm_module_bo_export_key(bufmgr->module, bo, bo->bo_data, &error);
+                       if (error != TBM_ERROR_NONE)
+                               TBM_WRN("fail to get the tdm_key of bo.");
                        TBM_SNRPRINTF(str, len, c, "%-3d %-11p   %-5d %-7d    %-6d    %-5u %-7d %-11p  %-4d\n",
                                  ++bo_cnt,
                                  bo,
index 047e0ca..b5e4eb0 100644 (file)
@@ -379,5 +379,6 @@ tbm_error_e   tbm_module_bo_unmap(tbm_module *module, tbm_bo bo, tbm_backend_bo_
 tbm_error_e   tbm_module_bo_lock(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, int device, int opt);
 tbm_error_e   tbm_module_bo_unlock(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data);
 tbm_fd        tbm_module_bo_export_fd(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, tbm_error_e *error);
+tbm_key       tbm_module_bo_export_key(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, tbm_error_e *error);
 
 #endif /* _TBM_BUFMGR_INT_H_ */
index 6e99845..2a27021 100644 (file)
@@ -1201,3 +1201,47 @@ tbm_module_bo_export_fd(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_d
 
        return fd;
 }
+
+tbm_key
+tbm_module_bo_export_key(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, tbm_error_e *error)
+{
+       tbm_backend_bo_func *bo_func = NULL;
+       tbm_bufmgr_backend backend = NULL;
+       tbm_key ret;
+
+       TBM_RETURN_VAL_SET_ERR_IF_FAIL(module, 0, *error, TBM_ERROR_INVALID_PARAMETER);
+
+       switch (module->type) {
+       case TBM_MODULE_TYPE_HAL_TBM:
+               ret = (hal_tbm_fd)hal_tbm_bo_export_key((hal_tbm_bo *)bo_data, (hal_tbm_error *)error);
+               break;
+/* LCOV_EXCL_START */
+       case TBM_MODULE_TYPE_TBM_BACKEND:
+               bo_func = module->bo_func;
+               TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_func, 0, *error, TBM_ERROR_INVALID_OPERATION);
+               TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_func->bo_export_key, 0, *error, TBM_ERROR_NOT_SUPPORTED);
+
+               ret = bo_func->bo_export_key(bo_data, error);
+               break;
+       case TBM_MODULE_TYPE_BUFMGR_BACKEND:
+               TBM_WRN("!!WARNING: This backend interface will be DEPRECATED after Tizen 6.5.");
+               backend = module->backend;
+               TBM_RETURN_VAL_SET_ERR_IF_FAIL(backend, 0, *error, TBM_ERROR_INVALID_OPERATION);
+               TBM_RETURN_VAL_SET_ERR_IF_FAIL(backend->bo_export, 0, *error, TBM_ERROR_NOT_SUPPORTED);
+
+               ret = backend->bo_export(bo);
+               if (!ret)
+                       *error = TBM_ERROR_INVALID_OPERATION;
+               else
+                       *error = TBM_ERROR_NONE;
+               break;
+       default:
+               TBM_ERR("Wrong module type:%d", module->type);
+               ret = -1;
+               *error = TBM_ERROR_INVALID_OPERATION;
+               break;
+/* LCOV_EXCL_STOP */
+       }
+
+       return ret;
+}
\ No newline at end of file