adapt hal-api-tbm
[platform/core/uifw/libtbm.git] / src / tbm_surface_internal.c
index 872fb5c..0e6f1f5 100644 (file)
@@ -289,7 +289,21 @@ _tbm_surface_internal_query_plane_data(tbm_surface_h surface,
        TBM_RETURN_VAL_IF_FAIL(surf->info.height > 0, 0);
        TBM_RETURN_VAL_IF_FAIL(surf->info.format > 0, 0);
 
-       if (bufmgr->backend_module_data) {
+       if (bufmgr->use_hal_tbm) {
+               error = (tbm_error_e)hal_tbm_bufmgr_get_plane_data(bufmgr->hal_bufmgr, (hal_tbm_format)surf->info.format,
+                                                               plane_idx, surf->info.width, surf->info.height, size, offset, pitch, bo_idx);
+               /* LCOV_EXCL_START */
+               if (error == TBM_ERROR_NOT_SUPPORTED) {
+                       _tbm_set_last_result(TBM_ERROR_NOT_SUPPORTED);
+                       return 0;
+               } else if (error != TBM_ERROR_NONE) {
+                       TBM_ERR("Fail to surface_get_plane_data. surface(%p) error(%d)\n", surface, error);
+                       _tbm_set_last_result(error);
+                       return 0;
+               }
+               /* LCOV_EXCL_STOP */
+               ret = 1;
+       } else if (bufmgr->backend_module_data) {
                if (!bufmgr->bufmgr_func->bufmgr_get_plane_data) {
                        _tbm_set_last_result(TBM_ERROR_NOT_SUPPORTED);
                        return 0;
@@ -610,7 +624,18 @@ tbm_surface_internal_query_supported_formats(uint32_t **formats,
 
        bufmgr = g_surface_bufmgr;
 
-       if (bufmgr->backend_module_data) {
+       if (bufmgr->use_hal_tbm) {
+               error = (tbm_error_e)hal_tbm_bufmgr_get_supported_formats(bufmgr->hal_bufmgr, formats, num);
+               /* LCOV_EXCL_START */
+               if (error == TBM_ERROR_NOT_SUPPORTED) {
+                       _tbm_set_last_result(TBM_ERROR_NOT_SUPPORTED);
+                       goto fail;
+               } else if (error != TBM_ERROR_NONE) {
+                       _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION);
+                       goto fail;
+               }
+               /* LCOV_EXCL_STOP */
+       } else if (bufmgr->backend_module_data) {
                if (!bufmgr->bufmgr_func->bufmgr_get_supported_formats) {
                        _tbm_set_last_result(TBM_ERROR_NOT_SUPPORTED);
                        goto fail;
@@ -800,7 +825,30 @@ tbm_surface_internal_create_with_flags(int width, int height,
                                bo_size += surf->info.planes[j].size;
                }
 
-               if (bufmgr->backend_module_data) {
+               if (bufmgr->use_hal_tbm) {
+                       surf->bos[i] = tbm_bo_alloc_with_format(bufmgr, format, i, width, height, flags, &error);
+                       if (error == TBM_ERROR_NOT_SUPPORTED) {
+                               if (flags & TBM_BO_TILED) {
+                                       surf->bos[i] = tbm_bo_alloc_with_tiled_format(bufmgr, width, height, surf->info.bpp/8, format, flags, i, &error);
+                                       if (error == TBM_ERROR_NOT_SUPPORTED) {
+                                               surf->bos[i] = tbm_bo_alloc(bufmgr, bo_size, flags);
+                                       } else if (error != TBM_ERROR_NONE) {
+                                               TBM_ERR("fail to alloc bo idx:%d\n", i);
+                                               goto alloc_bo_fail;
+                                       }
+                               } 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 (error != TBM_ERROR_NONE) {
+                               TBM_ERR("fail to alloc bo idx:%d\n", i);
+                               goto alloc_bo_fail;
+                       }
+               } else if (bufmgr->backend_module_data) {
                        if (bufmgr->bufmgr_func->bufmgr_alloc_bo_with_format) {
                                /* LCOV_EXCL_START */
                                surf->bos[i] = tbm_bo_alloc_with_format(bufmgr, format, i, width, height, flags, &error);