tbm_module: add tbm_module_bo_lock and use it 21/260021/1
authorSooChan Lim <sc1.lim@samsung.com>
Thu, 17 Jun 2021 09:45:19 +0000 (18:45 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Thu, 17 Jun 2021 09:48:46 +0000 (18:48 +0900)
The tbm_module_bo_lock calls it's backend function

Change-Id: Ie409832d92c73d11ce205b25dd2a296fd4cd74f4

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

index e9184367224f135d82bb601529226b977802393b..d8370678a08d9458a88b61d46f616b7032110489 100644 (file)
@@ -138,35 +138,23 @@ user_data_delete(tbm_user_data *user_data)
 static int
 _bo_lock(tbm_bo bo, int device, int opt)
 {
-       int ret = 1;
        tbm_error_e error;
+       int ret;
 
-       if (bo->bufmgr->use_hal_tbm) {
-               error = (tbm_error_e)hal_tbm_bo_lock((hal_tbm_bo *)bo->bo_data, device, opt);
-               if (error == TBM_ERROR_NOT_SUPPORTED) {
+       error = tbm_module_bo_lock(bo->bufmgr->module, bo, bo->bo_data, device, opt);
+       _tbm_set_last_result(error);
+       switch(error) {
+               case TBM_ERROR_NONE:
+                       ret = 1;
+                       break;
+               case TBM_ERROR_NOT_SUPPORTED:
+                       ret = 1;
                        _tbm_set_last_result(TBM_ERROR_NONE);
-               } else {
-                       if (error != TBM_ERROR_NONE) {
-                               TBM_WRN("fail to lock");
-                               _tbm_set_last_result(error);
-                               ret = 0;
-                       }
-               }
-       } else if (bo->bufmgr->backend_module_data) {
-               if (bo->bufmgr->bo_func->bo_lock) {
-                       error = bo->bufmgr->bo_func->bo_lock(bo->bo_data, device, opt);
-                       if (error != TBM_ERROR_NONE) {
-                               TBM_WRN("fail to lock");
-                               _tbm_set_last_result(error);
-                               ret = 0;
-                       }
-               }
-       } else {
-               if (bo->bufmgr->backend->bo_lock) {
-                       ret = bo->bufmgr->backend->bo_lock(bo, device, opt);
-                       if (!ret)
-                               _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION);
-               }
+                       break;
+               default:
+                       ret = 0;
+                       TBM_WRN("fail to lock. error:%d", error);
+                       break;
        }
 
        return ret;
index e1ab79a6db22dd42bfd9ef665141e3fe283b1260..bde820edd0436f9c21dfeb94aaa0480f4f11540c 100644 (file)
@@ -376,5 +376,6 @@ int           tbm_module_bo_get_memory_types(tbm_module *module, tbm_bo bo, tbm_
 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);
+tbm_error_e   tbm_module_bo_lock(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, int device, int opt);
 
 #endif /* _TBM_BUFMGR_INT_H_ */
index b0d1e97e798b6e81d037630341739a6f45a45fbd..84e6063ffb5296fcaf6347cb330e5ef593c8fe1c 100644 (file)
@@ -1069,3 +1069,49 @@ tbm_module_bo_unmap(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data)
 
        return error;
 }
+
+tbm_error_e
+tbm_module_bo_lock(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, int device, int opt)
+{
+       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 = (tbm_error_e)hal_tbm_bo_lock((hal_tbm_bo *)bo_data, device, opt);
+               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);
+               if (!bo_func->bo_lock)
+                       return TBM_ERROR_NOT_SUPPORTED;
+
+               error = bo_func->bo_lock(bo_data, device, opt);
+               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);
+               if (!backend->bo_unmap)
+                       return TBM_ERROR_NOT_SUPPORTED;
+
+               ret = backend->bo_lock(bo, device, opt);
+               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;
+}