From 49fd5e61313cf8afd16a6ea5b816b668e4563bec Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 17 Jun 2021 19:10:35 +0900 Subject: [PATCH] tbm_module: add tbm_module_bo_exportd_fd and use it The tbm_module_bo_export_fd calls it's backend function Change-Id: I806c6fb60545ee0777d837ab3ada36f7a511017e --- src/tbm_bo.c | 58 ++++++++++------------------------------------------ src/tbm_bufmgr_int.h | 1 + src/tbm_module.c | 44 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 47 deletions(-) diff --git a/src/tbm_bo.c b/src/tbm_bo.c index c97ac1d..fcf5e86 100644 --- a/src/tbm_bo.c +++ b/src/tbm_bo.c @@ -535,7 +535,7 @@ done: tbm_fd tbm_bo_export_fd(tbm_bo bo) { - tbm_fd ret; + tbm_fd fd; tbm_error_e error; _tbm_bufmgr_mutex_lock(); @@ -543,57 +543,21 @@ tbm_bo_export_fd(tbm_bo bo) TBM_BO_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), -1); - if (bo->bufmgr->use_hal_tbm) { - ret = (hal_tbm_fd)hal_tbm_bo_export_fd((hal_tbm_bo *)bo->bo_data, (hal_tbm_error *)&error); - if (ret < 0) { - /* LCOV_EXCL_START */ - TBM_ERR("error: bo(%p) tbm_fd(%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_fd) { - /* LCOV_EXCL_START */ - _tbm_bufmgr_mutex_unlock(); - _tbm_set_last_result(TBM_ERROR_NOT_SUPPORTED); - return -1; - /* LCOV_EXCL_STOP */ - } - - ret = bo->bufmgr->bo_func->bo_export_fd(bo->bo_data, &error); - if (ret < 0) { - /* LCOV_EXCL_START */ - TBM_ERR("error: bo(%p) tbm_fd(%d) error(%d)\n", bo, ret, error); - _tbm_set_last_result(error); - goto done; - /* LCOV_EXCL_STOP */ - } - } else { - if (!bo->bufmgr->backend->bo_export_fd) { - /* LCOV_EXCL_START */ - _tbm_bufmgr_mutex_unlock(); - _tbm_set_last_result(TBM_ERROR_NOT_SUPPORTED); - return -1; - /* LCOV_EXCL_STOP */ - } - - ret = bo->bufmgr->backend->bo_export_fd(bo); - if (ret < 0) { - /* LCOV_EXCL_START */ - TBM_ERR("error: bo(%p) tbm_fd(%d)\n", bo, ret); - _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION); - goto done; - /* LCOV_EXCL_STOP */ - } + fd = tbm_module_bo_export_fd(bo->bufmgr->module, bo, bo->bo_data, &error); + if (fd < 0) { + /* LCOV_EXCL_START */ + TBM_ERR("tbm_module_bo_export_fd filed. bo:%p tbm_fd:%d error:%d", bo, fd, error); + _tbm_set_last_result(error); + _tbm_bufmgr_mutex_unlock(); + return fd; + /* LCOV_EXCL_STOP */ } - TBM_TRACE_BO("bo(%p) tbm_fd(%d)\n", bo, ret); + TBM_TRACE_BO("bo:%p tbm_fd:%d", bo, fd); -done: _tbm_bufmgr_mutex_unlock(); - return ret; + return fd; } tbm_bo diff --git a/src/tbm_bufmgr_int.h b/src/tbm_bufmgr_int.h index c51ab88..047e0ca 100644 --- a/src/tbm_bufmgr_int.h +++ b/src/tbm_bufmgr_int.h @@ -378,5 +378,6 @@ tbm_bo_handle tbm_module_bo_map(tbm_module *module, tbm_bo bo, tbm_backend_bo_da 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); 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); #endif /* _TBM_BUFMGR_INT_H_ */ diff --git a/src/tbm_module.c b/src/tbm_module.c index 58a44e4..6e99845 100644 --- a/src/tbm_module.c +++ b/src/tbm_module.c @@ -1157,3 +1157,47 @@ tbm_module_bo_unlock(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data return error; } + +tbm_fd +tbm_module_bo_export_fd(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_fd fd; + + TBM_RETURN_VAL_SET_ERR_IF_FAIL(module, -1, *error, TBM_ERROR_INVALID_PARAMETER); + + switch (module->type) { + case TBM_MODULE_TYPE_HAL_TBM: + fd = (hal_tbm_fd)hal_tbm_bo_export_fd((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, -1, *error, TBM_ERROR_INVALID_OPERATION); + TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_func->bo_export_fd, -1, *error, TBM_ERROR_NOT_SUPPORTED); + + fd = bo_func->bo_export_fd(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, -1, *error, TBM_ERROR_INVALID_OPERATION); + TBM_RETURN_VAL_SET_ERR_IF_FAIL(backend->bo_export_fd, -1, *error, TBM_ERROR_NOT_SUPPORTED); + + fd = backend->bo_export_fd(bo); + if (fd < 0) + *error = TBM_ERROR_INVALID_OPERATION; + else + *error = TBM_ERROR_NONE; + break; + default: + TBM_ERR("Wrong module type:%d", module->type); + fd = -1; + *error = TBM_ERROR_INVALID_OPERATION; + break; +/* LCOV_EXCL_STOP */ + } + + return fd; +} -- 2.7.4