TBM_RETURN_VAL_IF_FAIL(plane_idx > -1, 0);
struct _tbm_surface *surf = (struct _tbm_surface *)surface;
- struct _tbm_bufmgr *mgr = surf->bufmgr;
+ struct _tbm_bufmgr *bufmgr = surf->bufmgr;
int ret = 0;
+ tbm_error_e error;
- TBM_RETURN_VAL_IF_FAIL(mgr != NULL, 0);
+ TBM_RETURN_VAL_IF_FAIL(bufmgr != NULL, 0);
TBM_RETURN_VAL_IF_FAIL(surf->info.width > 0, 0);
TBM_RETURN_VAL_IF_FAIL(surf->info.height > 0, 0);
TBM_RETURN_VAL_IF_FAIL(surf->info.format > 0, 0);
- if (!mgr->backend->surface_get_plane_data)
- return 0;
+ if (bufmgr->backend_module_data) {
+ if (!bufmgr->bufmgr_func->bufmgr_get_plane_data)
+ return 0;
- ret = mgr->backend->surface_get_plane_data(surf->info.width,
- surf->info.height, surf->info.format, plane_idx, size, offset, pitch, bo_idx);
- if (!ret) {
- /* LCOV_EXCL_START */
- TBM_ERR("Fail to surface_get_plane_data. surface(%p)\n", surface);
- return 0;
- /* LCOV_EXCL_STOP */
+ error = bufmgr->bufmgr_func->bufmgr_get_plane_data(bufmgr->bufmgr_data, surf->info.format, plane_idx,
+ surf->info.width, surf->info.height, size, offset, pitch, bo_idx);
+ if (error != TBM_ERROR_NONE) {
+ /* LCOV_EXCL_START */
+ TBM_ERR("Fail to surface_get_plane_data. surface(%p) error(%d)\n", surface, error);
+ return 0;
+ /* LCOV_EXCL_STOP */
+ }
+ ret = 1;
+ } else {
+ if (!bufmgr->backend->surface_get_plane_data)
+ return 0;
+
+ ret = bufmgr->backend->surface_get_plane_data(surf->info.width,
+ surf->info.height, surf->info.format, plane_idx, size, offset, pitch, bo_idx);
+ if (!ret) {
+ /* LCOV_EXCL_START */
+ TBM_ERR("Fail to surface_get_plane_data. surface(%p)\n", surface);
+ return 0;
+ /* LCOV_EXCL_STOP */
+ }
}
- return 1;
+ return ret;
}
static void
struct _tbm_bufmgr *bufmgr;
int ret = 0;
bool bufmgr_initialized = false;
+ tbm_error_e error;
_tbm_surface_mutex_lock();
bufmgr = g_surface_bufmgr;
- if (!bufmgr->backend->surface_supported_format)
- goto fail;
+ if (bufmgr->backend_module_data) {
+ if (!bufmgr->bufmgr_func->bufmgr_get_supported_formats)
+ goto fail;
- ret = bufmgr->backend->surface_supported_format(formats, num);
- if (!ret) {
- /* LCOV_EXCL_START */
- TBM_ERR("Fail to surface_supported_format.\n");
- goto fail;
- /* LCOV_EXCL_START */
+ error = bufmgr->bufmgr_func->bufmgr_get_supported_formats(bufmgr->bufmgr_data, formats, num);
+ if (error != TBM_ERROR_NONE) {
+ /* LCOV_EXCL_START */
+ TBM_ERR("Fail to surface_supported_format. error(%d)\n", error);
+ goto fail;
+ /* LCOV_EXCL_START */
+ }
+ ret = 1;
+ } else {
+ if (!bufmgr->backend->surface_supported_format)
+ goto fail;
+
+ ret = bufmgr->backend->surface_supported_format(formats, num);
+ if (!ret) {
+ /* LCOV_EXCL_START */
+ TBM_ERR("Fail to surface_supported_format.\n");
+ goto fail;
+ /* LCOV_EXCL_START */
+ }
}
TBM_TRACE_SURFACE_INTERNAL("tbm_bufmgr(%p) format num(%u)\n", g_surface_bufmgr, *num);
TBM_RETURN_VAL_IF_FAIL(width > 0, NULL);
TBM_RETURN_VAL_IF_FAIL(height > 0, NULL);
- struct _tbm_bufmgr *mgr;
+ struct _tbm_bufmgr *bufmgr;
struct _tbm_surface *surf = NULL;
uint32_t size = 0;
uint32_t offset = 0;
int bo_idx;
int i, j;
bool bufmgr_initialized = false;
+ tbm_bo bo = NULL;
+ void *bo_priv = NULL;
+ tbm_backend_bo_data *bo_data = NULL;
+ tbm_error_e error;
_tbm_surface_mutex_lock();
bufmgr_initialized = true;
}
- mgr = g_surface_bufmgr;
- if (!TBM_BUFMGR_IS_VALID(mgr)) {
+ bufmgr = g_surface_bufmgr;
+ if (!TBM_BUFMGR_IS_VALID(bufmgr)) {
TBM_ERR("The bufmgr is invalid\n");
goto check_valid_fail;
}
/* LCOV_EXCL_STOP */
}
- surf->bufmgr = mgr;
+ surf->bufmgr = bufmgr;
surf->info.width = width;
surf->info.height = height;
surf->info.format = format;
bo_size += surf->info.planes[j].size;
}
- if (mgr->backend->surface_bo_alloc) {
- /* LCOV_EXCL_START */
- tbm_bo bo = NULL;
- void *bo_priv = NULL;
+ if (bufmgr->backend_module_data) {
+ if (bufmgr->bufmgr_func->bufmgr_alloc_bo_with_format) {
+ /* LCOV_EXCL_START */
+ bo = calloc(1, sizeof(struct _tbm_bo));
+ if (!bo) {
+ TBM_ERR("fail to alloc bo struct\n");
+ goto alloc_bo_fail;
+ }
- bo = calloc(1, sizeof(struct _tbm_bo));
- if (!bo) {
- TBM_ERR("fail to alloc bo struct\n");
- goto alloc_bo_fail;
- }
+ bo->bufmgr = surf->bufmgr;
- bo->bufmgr = surf->bufmgr;
+ pthread_mutex_lock(&surf->bufmgr->lock);
- pthread_mutex_lock(&surf->bufmgr->lock);
+ bo_data = bufmgr->bufmgr_func->bufmgr_alloc_bo_with_format(bufmgr->bufmgr_data, format, i,
+ width, height, flags, &error);
+ if (!bo_data) {
+ TBM_ERR("fail to alloc bo priv. error(%d)\n", error);
+ free(bo);
+ pthread_mutex_unlock(&surf->bufmgr->lock);
+ goto alloc_bo_fail;
+ }
+ bo->bo_data = bo_data;
+
+ bo->ref_cnt = 1;
+ bo->flags = flags;
+ LIST_INITHEAD(&bo->user_data_list);
+
+ LIST_ADD(&bo->item_link, &surf->bufmgr->bo_list);
- bo_priv = mgr->backend->surface_bo_alloc(bo, width, height, format, flags, i);
- if (!bo_priv) {
- TBM_ERR("fail to alloc bo priv\n");
- free(bo);
pthread_mutex_unlock(&surf->bufmgr->lock);
- goto alloc_bo_fail;
+
+ surf->bos[i] = bo;
+ /* LCOV_EXCL_STOP */
+ } else {
+ surf->bos[i] = tbm_bo_alloc(bufmgr, bo_size, flags);
+ if (!surf->bos[i]) {
+ TBM_ERR("fail to alloc bo idx:%d\n", i);
+ goto alloc_bo_fail;
+ }
}
+ } else {
+ if (bufmgr->backend->surface_bo_alloc) {
+ /* LCOV_EXCL_START */
+ bo = calloc(1, sizeof(struct _tbm_bo));
+ if (!bo) {
+ TBM_ERR("fail to alloc bo struct\n");
+ goto alloc_bo_fail;
+ }
- bo->ref_cnt = 1;
- bo->flags = flags;
- bo->priv = bo_priv;
+ bo->bufmgr = surf->bufmgr;
- LIST_INITHEAD(&bo->user_data_list);
+ pthread_mutex_lock(&surf->bufmgr->lock);
- LIST_ADD(&bo->item_link, &surf->bufmgr->bo_list);
+ bo_priv = bufmgr->backend->surface_bo_alloc(bo, width, height, format, flags, i);
+ if (!bo_priv) {
+ TBM_ERR("fail to alloc bo priv\n");
+ free(bo);
+ pthread_mutex_unlock(&surf->bufmgr->lock);
+ goto alloc_bo_fail;
+ }
+ bo->priv = bo_priv;
- pthread_mutex_unlock(&surf->bufmgr->lock);
+ bo->ref_cnt = 1;
+ bo->flags = flags;
+ LIST_INITHEAD(&bo->user_data_list);
- surf->bos[i] = bo;
- /* LCOV_EXCL_STOP */
- } else {
- surf->bos[i] = tbm_bo_alloc(mgr, bo_size, flags);
- if (!surf->bos[i]) {
- TBM_ERR("fail to alloc bo idx:%d\n", i);
- goto alloc_bo_fail;
+ LIST_ADD(&bo->item_link, &surf->bufmgr->bo_list);
+
+ pthread_mutex_unlock(&surf->bufmgr->lock);
+
+ surf->bos[i] = bo;
+ /* LCOV_EXCL_STOP */
+ } else {
+ surf->bos[i] = tbm_bo_alloc(bufmgr, bo_size, flags);
+ if (!surf->bos[i]) {
+ TBM_ERR("fail to alloc bo idx:%d\n", i);
+ goto alloc_bo_fail;
+ }
}
}
LIST_INITHEAD(&surf->user_data_list);
LIST_INITHEAD(&surf->debug_data_list);
- LIST_ADD(&surf->item_link, &mgr->surf_list);
+ LIST_ADD(&surf->item_link, &bufmgr->surf_list);
_tbm_surface_mutex_unlock();
free(surf);
alloc_surf_fail:
check_valid_fail:
- if (bufmgr_initialized && mgr) {
- LIST_DELINIT(&mgr->surf_list);
+ if (bufmgr_initialized && bufmgr) {
+ LIST_DELINIT(&bufmgr->surf_list);
_deinit_surface_bufmgr();
}
_tbm_surface_mutex_unlock();
TBM_RETURN_VAL_IF_FAIL(num > 0, NULL);
TBM_RETURN_VAL_IF_FAIL(num == 1 || info->num_planes == num, NULL);
- struct _tbm_bufmgr *mgr;
+ struct _tbm_bufmgr *bufmgr;
struct _tbm_surface *surf = NULL;
int i;
bool bufmgr_initialized = false;
bufmgr_initialized = true;
}
- mgr = g_surface_bufmgr;
- if (!TBM_BUFMGR_IS_VALID(mgr)) {
+ bufmgr = g_surface_bufmgr;
+ if (!TBM_BUFMGR_IS_VALID(bufmgr)) {
TBM_ERR("fail to validate the Bufmgr.\n");
goto check_valid_fail;
}
/* LCOV_EXCL_STOP */
}
- surf->bufmgr = mgr;
+ surf->bufmgr = bufmgr;
surf->info.width = info->width;
surf->info.height = info->height;
surf->info.format = info->format;
LIST_INITHEAD(&surf->user_data_list);
LIST_INITHEAD(&surf->debug_data_list);
- LIST_ADD(&surf->item_link, &mgr->surf_list);
+ LIST_ADD(&surf->item_link, &bufmgr->surf_list);
_tbm_surface_mutex_unlock();
free(surf);
alloc_surf_fail:
check_valid_fail:
- if (bufmgr_initialized && mgr) {
- LIST_DELINIT(&mgr->surf_list);
+ if (bufmgr_initialized && bufmgr) {
+ LIST_DELINIT(&bufmgr->surf_list);
_deinit_surface_bufmgr();
}
_tbm_surface_mutex_unlock();