tbm_module: add tbm_module_bo_unmap and use it 20/260020/1
authorSooChan Lim <sc1.lim@samsung.com>
Thu, 17 Jun 2021 08:27:33 +0000 (17:27 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Thu, 17 Jun 2021 09:48:42 +0000 (18:48 +0900)
The tbm_module_bo_unmap calls it's backend function

Change-Id: I4dbd8164bf1cbd7d67af0e22ce40d46be24dabd1

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

index 4066567..e918436 100644 (file)
@@ -432,7 +432,6 @@ tbm_bo_map(tbm_bo bo, int device, int opt)
 int
 tbm_bo_unmap(tbm_bo bo)
 {
-       int ret = 1;
        tbm_error_e error;
 
        _tbm_bufmgr_mutex_lock();
@@ -441,35 +440,14 @@ tbm_bo_unmap(tbm_bo bo)
        TBM_BO_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), 0);
        TBM_BO_RETURN_VAL_IF_FAIL(bo->map_cnt > 0, 0);
 
-       if (bo->bufmgr->use_hal_tbm) {
-               error = (hal_tbm_error)hal_tbm_bo_unmap((hal_tbm_bo *)bo->bo_data);
-               if (error != TBM_ERROR_NONE) {
-                       /* LCOV_EXCL_START */
-                       TBM_ERR("error: bo(%p) map_cnt(%d) error(%d)\n", bo, bo->map_cnt, error);
-                       _tbm_set_last_result(error);
-                       ret = 0;
-                       goto done;
-                       /* LCOV_EXCL_STOP */
-               }
-       } else if (bo->bufmgr->backend_module_data) {
-               error = bo->bufmgr->bo_func->bo_unmap(bo->bo_data);
-               if (error != TBM_ERROR_NONE) {
-                       /* LCOV_EXCL_START */
-                       TBM_ERR("error: bo(%p) map_cnt(%d) error(%d)\n", bo, bo->map_cnt, error);
-                       _tbm_set_last_result(error);
-                       ret = 0;
-                       goto done;
-                       /* LCOV_EXCL_STOP */
-               }
-       } else {
-               ret = bo->bufmgr->backend->bo_unmap(bo);
-               if (!ret) {
-                       /* LCOV_EXCL_START */
-                       TBM_ERR("error: bo(%p) map_cnt(%d)\n", bo, bo->map_cnt);
-                       _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION);
-                       goto done;
-                       /* LCOV_EXCL_STOP */
-               }
+       error = tbm_module_bo_unmap(bo->bufmgr->module, bo, bo->bo_data);
+       if (error != TBM_ERROR_NONE) {
+               /* LCOV_EXCL_START */
+               TBM_ERR("error: bo(%p) map_cnt(%d) error(%d)\n", bo, bo->map_cnt, error);
+               _tbm_set_last_result(error);
+               _tbm_bufmgr_mutex_unlock();
+               return 0;
+               /* LCOV_EXCL_STOP */
        }
 
        /* decrease the map_count */
@@ -479,10 +457,9 @@ tbm_bo_unmap(tbm_bo bo)
 
        _tbm_bo_unlock(bo);
 
-done:
        _tbm_bufmgr_mutex_unlock();
 
-       return ret;
+       return 1;
 }
 
 tbm_bo_handle
index 28aa622..e1ab79a 100644 (file)
@@ -375,5 +375,6 @@ int           tbm_module_bo_get_size(tbm_module *module, tbm_bo bo, tbm_backend_
 int           tbm_module_bo_get_memory_types(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, tbm_error_e *error);
 tbm_bo_handle tbm_module_bo_get_handle(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, int device, tbm_error_e *error);
 tbm_bo_handle tbm_module_bo_map(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, int device, int opt, tbm_error_e *error);
+tbm_error_e   tbm_module_bo_unmap(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data);
 
 #endif /* _TBM_BUFMGR_INT_H_ */
index d6663a9..b0d1e97 100644 (file)
@@ -1025,3 +1025,47 @@ tbm_module_bo_map(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, i
 
        return bo_handle;
 }
+
+tbm_error_e
+tbm_module_bo_unmap(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data)
+{
+       tbm_backend_bo_func *bo_func = NULL;
+       tbm_bufmgr_backend backend = NULL;
+       tbm_error_e error;
+       int ret = 0;
+
+       TBM_RETURN_VAL_IF_FAIL(module, TBM_ERROR_INVALID_PARAMETER);
+
+       switch (module->type) {
+       case TBM_MODULE_TYPE_HAL_TBM:
+               error = (hal_tbm_error)hal_tbm_bo_unmap((hal_tbm_bo *)bo_data);
+               break;
+/* LCOV_EXCL_START */
+       case TBM_MODULE_TYPE_TBM_BACKEND:
+               bo_func = module->bo_func;
+               TBM_RETURN_VAL_IF_FAIL(bo_func, TBM_ERROR_INVALID_OPERATION);
+               TBM_RETURN_VAL_IF_FAIL(bo_func->bo_unmap, TBM_ERROR_NOT_SUPPORTED);
+
+               error = bo_func->bo_unmap(bo->bo_data);
+               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_IF_FAIL(backend, TBM_ERROR_INVALID_OPERATION);
+               TBM_RETURN_VAL_IF_FAIL(backend->bo_unmap, TBM_ERROR_NOT_SUPPORTED);
+
+               ret = bo->bufmgr->backend->bo_unmap(bo);
+               if (!ret)
+                       error = TBM_ERROR_INVALID_OPERATION;
+               else
+                       error = TBM_ERROR_NONE;
+               break;
+       default:
+               TBM_ERR("Wrong module type:%d", module->type);
+               error = TBM_ERROR_INVALID_OPERATION;
+               break;
+/* LCOV_EXCL_STOP */
+       }
+
+       return error;
+}