From 6d8cf298d7222ee3c78b24cb09a1d7f3d5688dff Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Tue, 22 Jun 2021 15:47:45 +0900 Subject: [PATCH] tbm_module: change the tbm_module_bo_xxx signature remove tbm_module and tbm_bo arguments. change the prefix of the name from tbm_module_bo_xxx to tbm_bo_data_xxx Change-Id: I03f133e90e141e4ed7f843043919871e2a97c09b --- src/tbm_bo.c | 24 +++++++------- src/tbm_bufmgr.c | 10 +++--- src/tbm_module.c | 80 ++++++++++++++++++++++++++++++++++------------ src/tbm_module.h | 20 ++++++------ src/tbm_surface_internal.c | 4 +-- 5 files changed, 88 insertions(+), 50 deletions(-) diff --git a/src/tbm_bo.c b/src/tbm_bo.c index 0220d9a..034f5cc 100644 --- a/src/tbm_bo.c +++ b/src/tbm_bo.c @@ -141,7 +141,7 @@ _bo_lock(tbm_bo bo, int device, int opt) tbm_error_e error; int ret; - error = tbm_module_bo_lock(bo->bufmgr->module, bo, bo->bo_data, device, opt); + error = tbm_bo_data_lock(bo->bo_data, device, opt); _tbm_set_last_result(error); switch(error) { case TBM_ERROR_NONE: @@ -165,7 +165,7 @@ _bo_unlock(tbm_bo bo) { tbm_error_e error; - error = tbm_module_bo_unlock(bo->bufmgr->module, bo, bo->bo_data); + error = tbm_bo_data_unlock(bo->bo_data); _tbm_set_last_result(error); switch(error) { case TBM_ERROR_NONE: @@ -386,7 +386,7 @@ tbm_bo_map(tbm_bo bo, int device, int opt) return (tbm_bo_handle) NULL; } - bo_handle = tbm_module_bo_map(bo->bufmgr->module, bo, bo->bo_data, device, opt, &error); + bo_handle = tbm_bo_data_map(bo->bo_data, device, opt, &error); if (bo_handle.ptr == NULL) { /* LCOV_EXCL_START */ TBM_ERR("error: fail to map bo:%p error:%d\n", bo, error); @@ -418,7 +418,7 @@ 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); - error = tbm_module_bo_unmap(bo->bufmgr->module, bo, bo->bo_data); + error = tbm_bo_data_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); @@ -451,7 +451,7 @@ tbm_bo_get_handle(tbm_bo bo, int device) TBM_BO_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), (tbm_bo_handle) NULL); - bo_handle = tbm_module_bo_get_handle(bo->bufmgr->module, bo, bo->bo_data, device, &error); + bo_handle = tbm_bo_data_get_handle(bo->bo_data, device, &error); if (bo_handle.ptr == NULL) { /* LCOV_EXCL_START */ TBM_ERR("error: bo(%p) bo_handle(%p) error(%d)\n", bo, bo_handle.ptr, error); @@ -479,7 +479,7 @@ tbm_bo_export(tbm_bo bo) TBM_BO_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), 0); - ret = tbm_module_bo_export_key(bo->bufmgr->module, bo, bo->bo_data, &error); + ret = tbm_bo_data_export_key(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); @@ -507,10 +507,10 @@ tbm_bo_export_fd(tbm_bo bo) TBM_BO_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), -1); - fd = tbm_module_bo_export_fd(bo->bufmgr->module, bo, bo->bo_data, &error); + fd = tbm_bo_data_export_fd(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_ERR("tbm_bo_data_export_fd filed. bo:%p tbm_fd:%d error:%d", bo, fd, error); _tbm_set_last_result(error); _tbm_bufmgr_mutex_unlock(); return fd; @@ -595,7 +595,7 @@ tbm_bo_size(tbm_bo bo) TBM_BO_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), 0); - size = tbm_module_bo_get_size(bo->bufmgr->module, bo, bo->bo_data, &error); + size = tbm_bo_data_get_size(bo->bo_data, &error); _tbm_set_last_result(error); TBM_TRACE_BO("bo(%p) size(%d)\n", bo, size); @@ -647,9 +647,9 @@ tbm_bo_swap(tbm_bo bo1, tbm_bo bo2) TBM_TRACE_BO("before: bo1(%p) bo2(%p)\n", bo1, bo2); - size1 = tbm_module_bo_get_size(bo1->bufmgr->module, bo1, bo1->bo_data, &error1); + size1 = tbm_bo_data_get_size(bo1->bo_data, &error1); _tbm_set_last_result(error1); - size2 = tbm_module_bo_get_size(bo2->bufmgr->module, bo2, bo2->bo_data, &error2); + size2 = tbm_bo_data_get_size(bo2->bo_data, &error2); _tbm_set_last_result(error2); if (size1 != size2) { @@ -871,7 +871,7 @@ _tbm_bo_free(tbm_bo bo) bo->lock_cnt--; } - tbm_module_bo_free(bo->bufmgr->module, bo, bo->bo_data, bo->get_from_surface_data); + tbm_bo_data_free(bo->bo_data, bo->get_from_surface_data); _tbm_bo_deinit(bo); diff --git a/src/tbm_bufmgr.c b/src/tbm_bufmgr.c index 932bfb8..51a075b 100644 --- a/src/tbm_bufmgr.c +++ b/src/tbm_bufmgr.c @@ -532,7 +532,7 @@ tbm_bufmgr_debug_tbm_info_get(tbm_bufmgr bufmgr) TBM_SNRPRINTF(str, len, c, "%s\n", data); for (i = 0; i < surf->num_bos; i++) { - size = tbm_module_bo_get_size(bufmgr->module, surf->bos[i], surf->bos[i]->bo_data, &error); + size = tbm_bo_data_get_size(surf->bos[i]->bo_data, &error); if (error != TBM_ERROR_NONE) TBM_WRN("fail to get the size of bo."); TBM_SNRPRINTF(str, len, c, " bo:%-12p %-26d%-10d\n", @@ -555,10 +555,10 @@ tbm_bufmgr_debug_tbm_info_get(tbm_bufmgr bufmgr) tbm_key key = 0; LIST_FOR_EACH_ENTRY(bo, &bufmgr->bo_list, item_link) { - size = tbm_module_bo_get_size(bufmgr->module, bo, bo->bo_data, &error); + size = tbm_bo_data_get_size(bo->bo_data, &error); if (error != TBM_ERROR_NONE) TBM_WRN("fail to get the size of bo."); - key = tbm_module_bo_export_key(bufmgr->module, bo, bo->bo_data, &error); + key = tbm_bo_data_export_key(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", @@ -1011,7 +1011,7 @@ tbm_bufmgr_internal_import_bo_with_key(tbm_bufmgr bufmgr, unsigned int key, tbm_ return bo2; } - flags = tbm_module_bo_get_memory_types(bufmgr->module, bo, bo->bo_data, error); + flags = tbm_bo_data_get_memory_types(bo->bo_data, error); if (*error != TBM_ERROR_NONE) { TBM_ERR("fail to get the bo flags(memory_types)"); flags = TBM_BO_DEFAULT; @@ -1058,7 +1058,7 @@ tbm_bufmgr_internal_import_bo_with_fd(tbm_bufmgr bufmgr, tbm_fd fd, tbm_error_e return bo2; } - flags = tbm_module_bo_get_memory_types(bufmgr->module, bo, bo->bo_data, error); + flags = tbm_bo_data_get_memory_types(bo->bo_data, error); if (*error != TBM_ERROR_NONE) { TBM_ERR("fail to get the bo flags(memory_types)"); flags = TBM_BO_DEFAULT; diff --git a/src/tbm_module.c b/src/tbm_module.c index c30c3fc..2ebe220 100644 --- a/src/tbm_module.c +++ b/src/tbm_module.c @@ -1094,14 +1094,16 @@ tbm_surface_data_export(tbm_surface_data *surface_data, tbm_error_e *error) } void -tbm_module_bo_free(tbm_module *module, tbm_bo bo, tbm_bo_data *bo_data, int get_from_surface_data) +tbm_bo_data_free(tbm_bo_data *bo_data, int get_from_surface_data) { + tbm_module *module = NULL; tbm_backend_bo_func *bo_func = NULL; tbm_bufmgr_backend backend = NULL; - TBM_RETURN_IF_FAIL(module); - TBM_RETURN_IF_FAIL(bo); TBM_RETURN_IF_FAIL(bo_data); + TBM_RETURN_IF_FAIL(bo_data->module); + + module = bo_data->module; switch (module->type) { case TBM_MODULE_TYPE_HAL_TBM: @@ -1140,13 +1142,17 @@ tbm_module_bo_free(tbm_module *module, tbm_bo bo, tbm_bo_data *bo_data, int get_ } int -tbm_module_bo_get_size(tbm_module *module, tbm_bo bo, tbm_bo_data *bo_data, tbm_error_e *error) +tbm_bo_data_get_size(tbm_bo_data *bo_data, tbm_error_e *error) { + tbm_module *module = NULL; tbm_backend_bo_func *bo_func = NULL; tbm_bufmgr_backend backend = NULL; int size = 0; - TBM_RETURN_VAL_SET_ERR_IF_FAIL(module, 0, *error, TBM_ERROR_INVALID_PARAMETER); + TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_data, 0, *error, TBM_ERROR_INVALID_PARAMETER); + TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_data->module, 0, *error, TBM_ERROR_INVALID_PARAMETER); + + module = bo_data->module; switch (module->type) { case TBM_MODULE_TYPE_HAL_TBM: @@ -1183,13 +1189,17 @@ tbm_module_bo_get_size(tbm_module *module, tbm_bo bo, tbm_bo_data *bo_data, tbm_ } int -tbm_module_bo_get_memory_types(tbm_module *module, tbm_bo bo, tbm_bo_data *bo_data, tbm_error_e *error) +tbm_bo_data_get_memory_types(tbm_bo_data *bo_data, tbm_error_e *error) { + tbm_module *module = NULL; tbm_backend_bo_func *bo_func = NULL; tbm_bufmgr_backend backend = NULL; int memory_types = TBM_BO_DEFAULT; - TBM_RETURN_VAL_SET_ERR_IF_FAIL(module, 0, *error, TBM_ERROR_INVALID_PARAMETER); + TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_data, 0, *error, TBM_ERROR_INVALID_PARAMETER); + TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_data->module, 0, *error, TBM_ERROR_INVALID_PARAMETER); + + module = bo_data->module; switch (module->type) { case TBM_MODULE_TYPE_HAL_TBM: @@ -1223,14 +1233,18 @@ tbm_module_bo_get_memory_types(tbm_module *module, tbm_bo bo, tbm_bo_data *bo_da } tbm_bo_handle -tbm_module_bo_get_handle(tbm_module *module, tbm_bo bo, tbm_bo_data *bo_data, int device, tbm_error_e *error) +tbm_bo_data_get_handle(tbm_bo_data *bo_data, int device, tbm_error_e *error) { + tbm_module *module = NULL; tbm_backend_bo_func *bo_func = NULL; tbm_bufmgr_backend backend = NULL; tbm_bo_handle bo_handle = (tbm_bo_handle)NULL; hal_tbm_bo_handle hbo_handle; - TBM_RETURN_VAL_SET_ERR_IF_FAIL(module, (tbm_bo_handle)NULL, *error, TBM_ERROR_INVALID_PARAMETER); + TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_data, (tbm_bo_handle)NULL, *error, TBM_ERROR_INVALID_PARAMETER); + TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_data->module, (tbm_bo_handle)NULL, *error, TBM_ERROR_INVALID_PARAMETER); + + module = bo_data->module; switch (module->type) { case TBM_MODULE_TYPE_HAL_TBM: @@ -1270,14 +1284,18 @@ tbm_module_bo_get_handle(tbm_module *module, tbm_bo bo, tbm_bo_data *bo_data, in } tbm_bo_handle -tbm_module_bo_map(tbm_module *module, tbm_bo bo, tbm_bo_data *bo_data, int device, int opt, tbm_error_e *error) +tbm_bo_data_map(tbm_bo_data *bo_data, int device, int opt, tbm_error_e *error) { + tbm_module *module = NULL; tbm_backend_bo_func *bo_func = NULL; tbm_bufmgr_backend backend = NULL; tbm_bo_handle bo_handle = (tbm_bo_handle)NULL; hal_tbm_bo_handle hbo_handle; - TBM_RETURN_VAL_SET_ERR_IF_FAIL(module, (tbm_bo_handle)NULL, *error, TBM_ERROR_INVALID_PARAMETER); + TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_data, (tbm_bo_handle)NULL, *error, TBM_ERROR_INVALID_PARAMETER); + TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_data->module, (tbm_bo_handle)NULL, *error, TBM_ERROR_INVALID_PARAMETER); + + module = bo_data->module; switch (module->type) { case TBM_MODULE_TYPE_HAL_TBM: @@ -1317,14 +1335,18 @@ tbm_module_bo_map(tbm_module *module, tbm_bo bo, tbm_bo_data *bo_data, int devic } tbm_error_e -tbm_module_bo_unmap(tbm_module *module, tbm_bo bo, tbm_bo_data *bo_data) +tbm_bo_data_unmap(tbm_bo_data *bo_data) { + tbm_module *module = NULL; 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); + TBM_RETURN_VAL_IF_FAIL(bo_data, TBM_ERROR_INVALID_PARAMETER); + TBM_RETURN_VAL_IF_FAIL(bo_data->module, TBM_ERROR_INVALID_PARAMETER); + + module = bo_data->module; switch (module->type) { case TBM_MODULE_TYPE_HAL_TBM: @@ -1361,14 +1383,18 @@ tbm_module_bo_unmap(tbm_module *module, tbm_bo bo, tbm_bo_data *bo_data) } tbm_error_e -tbm_module_bo_lock(tbm_module *module, tbm_bo bo, tbm_bo_data *bo_data, int device, int opt) +tbm_bo_data_lock(tbm_bo_data *bo_data, int device, int opt) { + tbm_module *module = NULL; 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); + TBM_RETURN_VAL_IF_FAIL(bo_data, TBM_ERROR_INVALID_PARAMETER); + TBM_RETURN_VAL_IF_FAIL(bo_data->module, TBM_ERROR_INVALID_PARAMETER); + + module = bo_data->module; switch (module->type) { case TBM_MODULE_TYPE_HAL_TBM: @@ -1407,13 +1433,17 @@ tbm_module_bo_lock(tbm_module *module, tbm_bo bo, tbm_bo_data *bo_data, int devi } tbm_error_e -tbm_module_bo_unlock(tbm_module *module, tbm_bo bo, tbm_bo_data *bo_data) +tbm_bo_data_unlock(tbm_bo_data *bo_data) { + tbm_module *module = NULL; tbm_backend_bo_func *bo_func = NULL; tbm_bufmgr_backend backend = NULL; tbm_error_e error; - TBM_RETURN_VAL_IF_FAIL(module, TBM_ERROR_INVALID_PARAMETER); + TBM_RETURN_VAL_IF_FAIL(bo_data, TBM_ERROR_INVALID_PARAMETER); + TBM_RETURN_VAL_IF_FAIL(bo_data->module, TBM_ERROR_INVALID_PARAMETER); + + module = bo_data->module; switch (module->type) { case TBM_MODULE_TYPE_HAL_TBM: @@ -1449,13 +1479,17 @@ tbm_module_bo_unlock(tbm_module *module, tbm_bo bo, tbm_bo_data *bo_data) } tbm_fd -tbm_module_bo_export_fd(tbm_module *module, tbm_bo bo, tbm_bo_data *bo_data, tbm_error_e *error) +tbm_bo_data_export_fd(tbm_bo_data *bo_data, tbm_error_e *error) { + tbm_module *module = NULL; 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); + TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_data, -1, *error, TBM_ERROR_INVALID_PARAMETER); + TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_data->module, -1, *error, TBM_ERROR_INVALID_PARAMETER); + + module = bo_data->module; switch (module->type) { case TBM_MODULE_TYPE_HAL_TBM: @@ -1493,13 +1527,17 @@ tbm_module_bo_export_fd(tbm_module *module, tbm_bo bo, tbm_bo_data *bo_data, tbm } tbm_key -tbm_module_bo_export_key(tbm_module *module, tbm_bo bo, tbm_bo_data *bo_data, tbm_error_e *error) +tbm_bo_data_export_key(tbm_bo_data *bo_data, tbm_error_e *error) { + tbm_module *module = NULL; 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); + TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_data, 0, *error, TBM_ERROR_INVALID_PARAMETER); + TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_data->module, 0, *error, TBM_ERROR_INVALID_PARAMETER); + + module = bo_data->module; switch (module->type) { case TBM_MODULE_TYPE_HAL_TBM: diff --git a/src/tbm_module.h b/src/tbm_module.h index c8f163b..a87adcb 100644 --- a/src/tbm_module.h +++ b/src/tbm_module.h @@ -105,15 +105,15 @@ tbm_error_e tbm_surface_data_get_plane_data(tbm_surface_data *surf tbm_bo_data **tbm_surface_data_get_bo_data_array(tbm_surface_data *surface_data, int *num_bos, tbm_error_e *error); tbm_surface_buffer_data *tbm_surface_data_export(tbm_surface_data *surface_data, tbm_error_e *error); -void tbm_module_bo_free(tbm_module *module, tbm_bo bo, tbm_bo_data *bo_data, int get_from_surface_data); -int tbm_module_bo_get_size(tbm_module *module, tbm_bo bo, tbm_bo_data *bo_data, tbm_error_e *error); -int tbm_module_bo_get_memory_types(tbm_module *module, tbm_bo bo, tbm_bo_data *bo_data, tbm_error_e *error); -tbm_bo_handle tbm_module_bo_get_handle(tbm_module *module, tbm_bo bo, tbm_bo_data *bo_data, int device, tbm_error_e *error); -tbm_bo_handle tbm_module_bo_map(tbm_module *module, tbm_bo bo, tbm_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_bo_data *bo_data); -tbm_error_e tbm_module_bo_lock(tbm_module *module, tbm_bo bo, tbm_bo_data *bo_data, int device, int opt); -tbm_error_e tbm_module_bo_unlock(tbm_module *module, tbm_bo bo, tbm_bo_data *bo_data); -tbm_fd tbm_module_bo_export_fd(tbm_module *module, tbm_bo bo, tbm_bo_data *bo_data, tbm_error_e *error); -tbm_key tbm_module_bo_export_key(tbm_module *module, tbm_bo bo, tbm_bo_data *bo_data, tbm_error_e *error); +void tbm_bo_data_free(tbm_bo_data *bo_data, int get_from_surface_data); +int tbm_bo_data_get_size(tbm_bo_data *bo_data, tbm_error_e *error); +int tbm_bo_data_get_memory_types(tbm_bo_data *bo_data, tbm_error_e *error); +tbm_bo_handle tbm_bo_data_get_handle(tbm_bo_data *bo_data, int device, tbm_error_e *error); +tbm_bo_handle tbm_bo_data_map(tbm_bo_data *bo_data, int device, int opt, tbm_error_e *error); +tbm_error_e tbm_bo_data_unmap(tbm_bo_data *bo_data); +tbm_error_e tbm_bo_data_lock(tbm_bo_data *bo_data, int device, int opt); +tbm_error_e tbm_bo_data_unlock(tbm_bo_data *bo_data); +tbm_fd tbm_bo_data_export_fd(tbm_bo_data *bo_data, tbm_error_e *error); +tbm_key tbm_bo_data_export_key(tbm_bo_data *bo_data, tbm_error_e *error); #endif // _TBM_MODULE_H_ diff --git a/src/tbm_surface_internal.c b/src/tbm_surface_internal.c index 6e6a492..18afbf8 100644 --- a/src/tbm_surface_internal.c +++ b/src/tbm_surface_internal.c @@ -876,9 +876,9 @@ _tbm_surface_internal_import_surface_data(tbm_bufmgr bufmgr, int width, int heig } // get memory_types(bo flags) - flags = tbm_module_bo_get_memory_types(bufmgr->module, NULL, bo_data_array[0], error); + flags = tbm_bo_data_get_memory_types(bo_data_array[0], error); if (*error != TBM_ERROR_NONE) { - TBM_ERR("tbm_module_bo_get_memory_types failed.error:%s", tbm_error_str(*error)); + TBM_ERR("tbm_bo_data_get_memory_types failed.error:%s", tbm_error_str(*error)); goto get_memory_types_fail; } surf->flags = flags; -- 2.7.4