diff options
author | Changyeon Lee <cyeon.lee@samsung.com> | 2024-07-23 19:47:39 +0900 |
---|---|---|
committer | Changyeon Lee <cyeon.lee@samsung.com> | 2024-07-24 15:15:00 +0900 |
commit | 0f444875511a1bc940d23edfd5ad7172b848d83f (patch) | |
tree | 1a59be20c1d92d2f9ff92068509b77b563775077 | |
parent | 3254c29c702b11d753cce9863c7990c411be8b9b (diff) | |
download | libtbm-vigs-0f444875511a1bc940d23edfd5ad7172b848d83f.tar.gz libtbm-vigs-0f444875511a1bc940d23edfd5ad7172b848d83f.tar.bz2 libtbm-vigs-0f444875511a1bc940d23edfd5ad7172b848d83f.zip |
Do not allocate backend data
backend data is allocated in hal-api
Change-Id: Ied072accd3f201633b794151fd8e1ed2c9caef42
-rw-r--r-- | src/tbm_backend_vigs.c | 83 |
1 files changed, 27 insertions, 56 deletions
diff --git a/src/tbm_backend_vigs.c b/src/tbm_backend_vigs.c index 1437f3c..490b081 100644 --- a/src/tbm_backend_vigs.c +++ b/src/tbm_backend_vigs.c @@ -922,18 +922,13 @@ hal_backend_tbm_vigs_exit(void *data) bufmgr_data->hash_bos = NULL; } - if (backend_data->bufmgr_funcs) - free(backend_data->bufmgr_funcs); - if (backend_data->bo_funcs) - free(backend_data->bo_funcs); - _tbm_vigs_bufmgr_deinitialize(bufmgr_data); if (bufmgr_data->fd >= 0) close(bufmgr_data->fd); free(backend_data->bufmgr); - free(backend_data); + backend_data->bufmgr = NULL; return HAL_TBM_ERROR_NONE; } @@ -942,28 +937,28 @@ static int hal_backend_tbm_vigs_init(void **data) { hal_tbm_backend_data *backend_data = NULL; - hal_tbm_bufmgr_funcs *bufmgr_funcs = NULL; - hal_tbm_bo_funcs *bo_funcs = NULL; tbm_vigs_bufmgr *bufmgr_data = NULL; int drm_fd = -1; int ret = 0; TBM_BACKEND_DBG("enter"); - /* allocate a hal_tbm_backend_data */ - backend_data = calloc(1, sizeof(struct _hal_tbm_backend_data)); + if (!data) { + TBM_BACKEND_ERR("data is NULL"); + return -1; + } + + backend_data = *(hal_tbm_backend_data **)data; if (!backend_data) { - TBM_BACKEND_ERR("fail to alloc backend_data!\n"); - *data = NULL; + TBM_BACKEND_ERR("backend_data is NULL"); return -1; } - *data = backend_data; /* allocate a hal_tbm_bufmgr */ bufmgr_data = calloc(1, sizeof(struct _tbm_vigs_bufmgr)); if (!bufmgr_data) { TBM_BACKEND_ERR("fail to alloc bufmgr_data!\n"); - goto fail_alloc_bufmgr_data; + return -1; } backend_data->bufmgr = (hal_tbm_bufmgr *)bufmgr_data; @@ -1007,60 +1002,36 @@ hal_backend_tbm_vigs_init(void **data) bufmgr_data->hash_bos = drmHashCreate(); - /* alloc and register bufmgr_funcs */ - bufmgr_funcs = calloc(1, sizeof(struct _hal_tbm_bufmgr_funcs)); - if (!bufmgr_funcs) { - TBM_BACKEND_ERR("fail to alloc bufmgr_funcs!\n"); - goto fail_alloc_bufmgr_funcs; - } - backend_data->bufmgr_funcs = bufmgr_funcs; - - bufmgr_funcs->bufmgr_get_capabilities = tbm_vigs_bufmgr_get_capabilities; - bufmgr_funcs->bufmgr_get_supported_formats = tbm_vigs_bufmgr_get_supported_formats; - bufmgr_funcs->bufmgr_get_plane_data = tbm_vigs_bufmgr_get_plane_data; - bufmgr_funcs->bufmgr_alloc_bo = tbm_vigs_bufmgr_alloc_bo; - bufmgr_funcs->bufmgr_alloc_bo_with_format = tbm_vigs_bufmgr_alloc_bo_with_format; - bufmgr_funcs->bufmgr_import_fd = tbm_vigs_bufmgr_import_fd; - bufmgr_funcs->bufmgr_import_key = tbm_vigs_bufmgr_import_key; - - /* alloc and register bo_funcs */ - bo_funcs = calloc(1, sizeof(struct _hal_tbm_bo_funcs)); - if (!bo_funcs) { - TBM_BACKEND_ERR("fail to alloc bo_funcs!\n"); - goto fail_alloc_bo_funcs; - } - backend_data->bo_funcs = bo_funcs; - - bo_funcs->bo_free = tbm_vigs_bo_free; - bo_funcs->bo_get_size = tbm_vigs_bo_get_size; - bo_funcs->bo_get_memory_types = tbm_vigs_bo_get_memory_type; - bo_funcs->bo_get_handle = tbm_vigs_bo_get_handle; - bo_funcs->bo_map = tbm_vigs_bo_map; - bo_funcs->bo_unmap = tbm_vigs_bo_unmap; - bo_funcs->bo_lock = tbm_vigs_bo_lock; - bo_funcs->bo_unlock = tbm_vigs_bo_unlock; - bo_funcs->bo_export_fd = tbm_vigs_bo_export_fd; - bo_funcs->bo_export_key = tbm_vigs_bo_export_key; + backend_data->bufmgr_funcs->bufmgr_get_capabilities = tbm_vigs_bufmgr_get_capabilities; + backend_data->bufmgr_funcs->bufmgr_get_supported_formats = tbm_vigs_bufmgr_get_supported_formats; + backend_data->bufmgr_funcs->bufmgr_get_plane_data = tbm_vigs_bufmgr_get_plane_data; + backend_data->bufmgr_funcs->bufmgr_alloc_bo = tbm_vigs_bufmgr_alloc_bo; + backend_data->bufmgr_funcs->bufmgr_alloc_bo_with_format = tbm_vigs_bufmgr_alloc_bo_with_format; + backend_data->bufmgr_funcs->bufmgr_import_fd = tbm_vigs_bufmgr_import_fd; + backend_data->bufmgr_funcs->bufmgr_import_key = tbm_vigs_bufmgr_import_key; + + backend_data->bo_funcs->bo_free = tbm_vigs_bo_free; + backend_data->bo_funcs->bo_get_size = tbm_vigs_bo_get_size; + backend_data->bo_funcs->bo_get_memory_types = tbm_vigs_bo_get_memory_type; + backend_data->bo_funcs->bo_get_handle = tbm_vigs_bo_get_handle; + backend_data->bo_funcs->bo_map = tbm_vigs_bo_map; + backend_data->bo_funcs->bo_unmap = tbm_vigs_bo_unmap; + backend_data->bo_funcs->bo_lock = tbm_vigs_bo_lock; + backend_data->bo_funcs->bo_unlock = tbm_vigs_bo_unlock; + backend_data->bo_funcs->bo_export_fd = tbm_vigs_bo_export_fd; + backend_data->bo_funcs->bo_export_key = tbm_vigs_bo_export_key; TBM_BACKEND_DBG("drm_fd:%d\n", bufmgr_data->fd); return HAL_TBM_ERROR_NONE; -fail_alloc_bo_funcs: - free(bufmgr_funcs); -fail_alloc_bufmgr_funcs: - drmHashDestroy(bufmgr_data->hash_bos); - _tbm_vigs_bufmgr_deinitialize(bufmgr_data); fail_create_vigs_drm_device: if (bufmgr_data->fd >= 0) close(bufmgr_data->fd); fail_open_drm: free(bufmgr_data); -fail_alloc_bufmgr_data: - free(backend_data); g_drm_dev = NULL; - *data = NULL; return -1; } |