add front-end interfaces for hal_tbm_surface 19/257719/3
authorSooChan Lim <sc1.lim@samsung.com>
Thu, 29 Apr 2021 04:56:17 +0000 (13:56 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Fri, 30 Apr 2021 07:53:11 +0000 (07:53 +0000)
Add apis for managing the hal_tbm_surface

Change-Id: I4b498c436db37b0dd87b5b475969754e706703ef

include/hal-tbm.h
src/hal-api-tbm.c

index 80e5cfce5ffca1b8345892dee3c10c16a0b862ec..a792190ec3fa92a65ef77bcb241a81d50f21a88a 100644 (file)
@@ -55,12 +55,20 @@ hal_tbm_bufmgr_capability  hal_tbm_bufmgr_get_capabilities(hal_tbm_bufmgr *bufmg
 hal_tbm_error              hal_tbm_bufmgr_get_supported_formats(hal_tbm_bufmgr *bufmgr, uint32_t **formats, uint32_t *num);
 hal_tbm_error              hal_tbm_bufmgr_get_plane_data(hal_tbm_bufmgr *bufmgr, hal_tbm_format format, int plane_idx, int width, int height,
                                           uint32_t *size, uint32_t *offset, uint32_t *pitch, int *bo_idx);
+hal_tbm_surface           *hal_tbm_bufmgr_alloc_surface(hal_tbm_bufmgr *bufmgr, int width, int height, hal_tbm_format format, hal_tbm_error *error);
+hal_tbm_surface           *hal_tbm_bufmgr_import_surface(hal_tbm_bufmgr *bufmgr, int width, int height, hal_tbm_format format, hal_tbm_surface_buffer_data *buffer_data, hal_tbm_error *error);
 hal_tbm_bo                *hal_tbm_bufmgr_alloc_bo(hal_tbm_bufmgr *bufmgr, unsigned int size, hal_tbm_bo_memory_type mem_types, hal_tbm_error *error);
 hal_tbm_bo                *hal_tbm_bufmgr_alloc_bo_with_format(hal_tbm_bufmgr *bufmgr, int format, int bo_idx, int width, int height, int bpp,
                                           hal_tbm_bo_memory_type mem_types, hal_tbm_error *error);
 hal_tbm_bo                *hal_tbm_bufmgr_import_fd(hal_tbm_bufmgr *bufmgr, hal_tbm_fd fd, hal_tbm_error *error);
 hal_tbm_bo                *hal_tbm_bufmgr_import_key(hal_tbm_bufmgr *bufmgr, hal_tbm_key key, hal_tbm_error *error);
 
+/* hal_tbm_surface_funcs*/
+void                           hal_tbm_surface_free(hal_tbm_surface *surface);
+hal_tbm_bo                   **hal_tbm_surface_get_bos(hal_tbm_surface *surface, int *num_bos, hal_tbm_error *error);
+hal_tbm_error                  hal_tbm_surface_get_plane_data(hal_tbm_surface *surface, int plane_idx, uint32_t *size, uint32_t *offset, uint32_t *pitch, int *bo_idx);
+hal_tbm_surface_buffer_data   *hal_tbm_surface_export(hal_tbm_surface *surface, hal_tbm_error *error);
+
 /* hal_tbm_bo_funcs*/
 void                    hal_tbm_bo_free(hal_tbm_bo *bo);
 int                     hal_tbm_bo_get_size(hal_tbm_bo *bo, hal_tbm_error *error);
index b2cc49c5fa4aa15b341221b73dbec69d2c1a05e1..d875d62754dfc60f7cfbea0f814ed77f208a694d 100644 (file)
        bufmgr_funcs = (hal_tbm_bufmgr_funcs *)g_hal_tbm_backend_data->bufmgr_funcs; \
        if (!bufmgr_funcs->__func__) goto __goto__;
 
+#define SURFACE_FUNC_ENTRY(__func__) \
+       hal_tbm_surface_funcs *surface_funcs; \
+       if (!surface) return HAL_TBM_ERROR_INVALID_PARAMETER; \
+       if (!g_hal_tbm_backend_data || !g_hal_tbm_backend_data->surface_funcs) return HAL_TBM_ERROR_NOT_SUPPORTED; \
+       surface_funcs = g_hal_tbm_backend_data->surface_funcs; \
+       if (!surface_funcs->__func__) return HAL_TBM_ERROR_NOT_SUPPORTED;
+
+#define SURFACE_FUNC_ENTRY_NULL(__func__) \
+       hal_tbm_surface_funcs *surface_funcs; \
+       if (!surface) { if (error) *error = HAL_TBM_ERROR_INVALID_PARAMETER; return NULL; } \
+       if (!g_hal_tbm_backend_data || !g_hal_tbm_backend_data->surface_funcs) { if (error) *error = HAL_TBM_ERROR_NOT_SUPPORTED; return NULL; } \
+       surface_funcs = g_hal_tbm_backend_data->surface_funcs; \
+       if (!surface_funcs->__func__) { if (error) *error = HAL_TBM_ERROR_NOT_SUPPORTED; return NULL; };
+
+#define SURFACE_FUNC_ENTRY_VOID(__func__) \
+       hal_tbm_surface_funcs *surface_funcs; \
+       if (!g_hal_tbm_backend_data || !g_hal_tbm_backend_data->surface_funcs) return; \
+       surface_funcs = g_hal_tbm_backend_data->surface_funcs; \
+       if (!surface_funcs->__func__) return;
+
+#define SURFACE_FUNC_ENTRY_GOTO(__func__, __goto__) \
+       hal_tbm_surface_funcs *surface_funcs; \
+       if (!surface) goto __goto__; \
+       if (!g_hal_tbm_backend_data || !g_hal_tbm_backend_data->surface_funcs) goto __goto__; \
+       surface_funcs = (hal_tbm_surface_funcs *)g_hal_tbm_backend_data->surface_funcs; \
+       if (!surface_funcs->__func__) goto __goto__;
+
 #define BO_FUNC_ENTRY(__func__) \
        hal_tbm_bo_funcs *bo_funcs; \
        if (!g_hal_tbm_backend_data || !g_hal_tbm_backend_data->bo_funcs) return HAL_TBM_ERROR_NOT_SUPPORTED; \
@@ -285,6 +312,23 @@ hal_tbm_bufmgr_get_plane_data(hal_tbm_bufmgr *bufmgr, hal_tbm_format format, int
        return bufmgr_funcs->bufmgr_get_plane_data((hal_tbm_bufmgr *)bufmgr, format, plane_idx, width, height, size, offset, pitch, bo_idx);
 }
 
+
+EXTERN hal_tbm_surface *
+hal_tbm_bufmgr_alloc_surface(hal_tbm_bufmgr *bufmgr, int width, int height, hal_tbm_format format, hal_tbm_error *error)
+{
+       BUFMGR_FUNC_ENTRY_NULL(bufmgr_alloc_surface);
+
+       return bufmgr_funcs->bufmgr_alloc_surface((hal_tbm_bufmgr *)bufmgr, width, height, format, error);
+}
+
+EXTERN hal_tbm_surface *
+hal_tbm_bufmgr_import_surface(hal_tbm_bufmgr *bufmgr, int width, int height, hal_tbm_format format, hal_tbm_surface_buffer_data *buffer_data, hal_tbm_error *error)
+{
+       BUFMGR_FUNC_ENTRY_NULL(bufmgr_import_surface);
+
+       return bufmgr_funcs->bufmgr_import_surface((hal_tbm_bufmgr *)bufmgr, width, height, format, buffer_data, error);
+}
+
 EXTERN hal_tbm_bo *
 hal_tbm_bufmgr_alloc_bo(hal_tbm_bufmgr *bufmgr, unsigned int size, hal_tbm_bo_memory_type mem_types, hal_tbm_error *error)
 {
@@ -318,6 +362,38 @@ hal_tbm_bufmgr_import_key(hal_tbm_bufmgr *bufmgr, hal_tbm_key key, hal_tbm_error
        return bufmgr_funcs->bufmgr_import_key((hal_tbm_bufmgr *)bufmgr, key, error);
 }
 
+/* tbm_surface_func */
+EXTERN void
+hal_tbm_surface_free(hal_tbm_surface *surface)
+{
+       SURFACE_FUNC_ENTRY_VOID(surface_free);
+
+       return surface_funcs->surface_free((hal_tbm_surface *)surface);
+}
+
+EXTERN hal_tbm_bo **
+hal_tbm_surface_get_bos(hal_tbm_surface *surface, int *num_bos, hal_tbm_error *error)
+{
+       SURFACE_FUNC_ENTRY_NULL(surface_get_bos);
+
+       return surface_funcs->surface_get_bos((hal_tbm_surface *)surface, num_bos, error);
+}
+
+EXTERN hal_tbm_error
+hal_tbm_surface_get_plane_data(hal_tbm_surface *surface, int plane_idx, uint32_t *size, uint32_t *offset, uint32_t *pitch, int *bo_idx)
+{
+       SURFACE_FUNC_ENTRY(surface_get_plane_data);
+
+       return surface_funcs->surface_get_plane_data((hal_tbm_surface *)surface, plane_idx, size, offset, pitch, bo_idx);
+}
+
+EXTERN hal_tbm_surface_buffer_data *
+hal_tbm_surface_export(hal_tbm_surface *surface, hal_tbm_error *error)
+{
+       SURFACE_FUNC_ENTRY_NULL(surface_export);
+
+       return surface_funcs->surface_export((hal_tbm_surface *)surface, error);
+}
 
 /* tbm_bo_func*/
 EXTERN void