1 /**************************************************************************
5 Copyright 2012-2021 Samsung Electronics co., Ltd. All Rights Reserved.
7 Contact: SooChan Lim <sc1.lim@samsung.com>
8 Changyeon Lee <cyeon.lee@samsung.com>
10 Permission is hereby granted, free of charge, to any person obtaining a
11 copy of this software and associated documentation files (the
12 "Software"), to deal in the Software without restriction, including
13 without limitation the rights to use, copy, modify, merge, publish,
14 distribute, sub license, and/or sell copies of the Software, and to
15 permit persons to whom the Software is furnished to do so, subject to
16 the following conditions:
18 The above copyright notice and this permission notice (including the
19 next paragraph) shall be included in all copies or substantial portions
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
25 IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
27 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 **************************************************************************/
32 #ifndef _TBM_MODULE_H_
33 #define _TBM_MODULE_H_
35 #include <tbm_bufmgr.h>
37 #include <tbm_surface.h>
38 #include <tbm_surface_internal.h>
39 #include <tbm_surface_queue.h>
41 #include <tbm_bufmgr_backend.h>
42 #include <tbm_backend.h>
43 #include <tbm_error.h>
44 #include <hal/hal-tbm.h>
46 typedef enum _tbm_module_type {
48 TBM_MODULE_TYPE_HAL_TBM,
49 TBM_MODULE_TYPE_TBM_BACKEND,
50 TBM_MODULE_TYPE_BUFMGR_BACKEND,
53 typedef struct _tbm_module {
56 void *module_data; /* backend module */
57 tbm_bufmgr_backend backend; /* bufmgr backend (will be DEPRECATED) */
59 tbm_backend_module *backend_module_data; /* backend module data */
60 tbm_backend_bufmgr_data *bufmgr_data; /* backend data of the backend module */
61 tbm_backend_bufmgr_func *bufmgr_func; /* backend functions for bufmgr */
62 tbm_backend_bo_func *bo_func; /* backend functions for bo */
64 int use_hal_tbm; /* use hal-api-tbm */
65 int auth_wl_socket_created; /* create wayland socket for authenticated drm_fd */
67 hal_tbm_backend *hal_backend; /* hal-api-tbm backend */
68 hal_tbm_bufmgr *hal_bufmgr; /* hal-api-tbm bufmgr */
71 typedef struct _tbm_backend_surface_data {
73 hal_tbm_surface *hal_surface;
74 } tbm_backend_surface_data;
76 /* tbm_module functions */
77 tbm_module *tbm_module_load(int fd);
78 void tbm_module_unload(tbm_module *module);
80 int tbm_module_get_capabilities(tbm_module *module, tbm_error_e *error);
81 tbm_error_e tbm_module_bind_native_display(tbm_module *module, void *native_display);
82 tbm_error_e tbm_module_get_supported_formats(tbm_module *module, uint32_t **formats, uint32_t *num);
83 tbm_error_e tbm_module_get_plane_data(tbm_module *module, int format, int plane_idx, uint32_t w, uint32_t h, uint32_t *size, uint32_t *offset, uint32_t *pitch, int *bo_idx);
84 tbm_backend_bo_data *tbm_module_alloc_bo_data(tbm_module *module, tbm_bo bo, int size, int flags, tbm_error_e *error);
85 tbm_backend_bo_data *tbm_module_alloc_bo_data_with_format(tbm_module *module, int format, int bo_idx, int width, int height, int bpp, tbm_bo_memory_type flags, tbm_error_e *error);
86 tbm_backend_bo_data *tbm_module_import_bo_data_with_fd(tbm_module *module, tbm_bo bo, tbm_fd fd, tbm_error_e *error);
87 tbm_backend_bo_data *tbm_module_import_bo_data_with_key(tbm_module *module, tbm_bo bo, tbm_key key, tbm_error_e *error);
89 void tbm_module_bo_free(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, int get_from_hal_surface);
90 int tbm_module_bo_get_size(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, tbm_error_e *error);
91 int tbm_module_bo_get_memory_types(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, tbm_error_e *error);
92 tbm_bo_handle tbm_module_bo_get_handle(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, int device, tbm_error_e *error);
93 tbm_bo_handle tbm_module_bo_map(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, int device, int opt, tbm_error_e *error);
94 tbm_error_e tbm_module_bo_unmap(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data);
95 tbm_error_e tbm_module_bo_lock(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, int device, int opt);
96 tbm_error_e tbm_module_bo_unlock(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data);
97 tbm_fd tbm_module_bo_export_fd(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, tbm_error_e *error);
98 tbm_key tbm_module_bo_export_key(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, tbm_error_e *error);
100 #endif // _TBM_MODULE_H_