From 3b5a63a96137b57886367b3b9b5b4d0cfc44d633 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 17 Jun 2021 19:20:52 +0900 Subject: [PATCH] tbm_module: add tbm_module_bo_exportd_key and use it The tbm_module_bo_export_key calls it's backend function Change-Id: I24be15e2e60829bb4d4da0d562f032447c232c22 --- src/tbm_bo.c | 54 +++++++++------------------------------------------- src/tbm_bufmgr.c | 13 +++---------- src/tbm_bufmgr_int.h | 1 + src/tbm_module.c | 44 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 55 deletions(-) diff --git a/src/tbm_bo.c b/src/tbm_bo.c index fcf5e86..6bb9198 100644 --- a/src/tbm_bo.c +++ b/src/tbm_bo.c @@ -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; diff --git a/src/tbm_bufmgr.c b/src/tbm_bufmgr.c index 9fae74c..d0f18b0 100644 --- a/src/tbm_bufmgr.c +++ b/src/tbm_bufmgr.c @@ -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, diff --git a/src/tbm_bufmgr_int.h b/src/tbm_bufmgr_int.h index 047e0ca..b5e4eb0 100644 --- a/src/tbm_bufmgr_int.h +++ b/src/tbm_bufmgr_int.h @@ -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_ */ diff --git a/src/tbm_module.c b/src/tbm_module.c index 6e99845..2a27021 100644 --- a/src/tbm_module.c +++ b/src/tbm_module.c @@ -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 -- 2.7.4