85fcefeb33de862025cfe85eedb4e7d050d81e6f
[platform/hal/api/tbm.git] / include / hal-tbm.h
1 /**************************************************************************
2  *
3  * hal-api-tbm
4  *
5  * Copyright 2021 Samsung Electronics co., Ltd. All Rights Reserved.
6  *
7  * Contact: SooChan Lim <sc1.lim@samsung.com>,
8  *          Junkyeong Kim <jk0430.kim@samsung.com>,
9  *          Changyeon Lee <cyeon.lee@samsung.com>
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining a
12  * copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sub license, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice (including the
20  * next paragraph) shall be included in all copies or substantial portions
21  * of the Software.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
26  * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
27  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
28  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
29  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30  *
31 **************************************************************************/
32
33 #ifndef __HAL_TBM__
34 #define __HAL_TBM__
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 #include <hal-tbm-types.h>
41
42 /* hal_tbm */
43 hal_tbm_backend  *hal_tbm_get_backend(hal_tbm_error *error);
44 hal_tbm_error     hal_tbm_put_backend(hal_tbm_backend *backend_data);
45
46 /* hal_tbm_backend */
47 hal_tbm_bufmgr   *hal_tbm_backend_get_bufmgr(hal_tbm_backend *backend, hal_tbm_error *error);
48 int               hal_tbm_backend_has_drm_device(hal_tbm_backend *backend, hal_tbm_error *error);
49 hal_tbm_fd        hal_tbm_backend_get_master_drm_fd(hal_tbm_backend *backend, hal_tbm_error *error);
50
51 hal_tbm_error     hal_tbm_backend_set_authenticated_drm_fd(hal_tbm_backend *backend, hal_tbm_fd auth_drm_fd);
52
53 /* hal_tbm_bufmgr_funcs */
54 hal_tbm_bufmgr_capability  hal_tbm_bufmgr_get_capabilities(hal_tbm_bufmgr *bufmgr, hal_tbm_error *error);
55 hal_tbm_error              hal_tbm_bufmgr_get_supported_formats(hal_tbm_bufmgr *bufmgr, uint32_t **formats, uint32_t *num);
56 hal_tbm_error              hal_tbm_bufmgr_get_plane_data(hal_tbm_bufmgr *bufmgr, hal_tbm_format format, int plane_idx, int width, int height,
57                                           uint32_t *size, uint32_t *offset, uint32_t *pitch, int *bo_idx);
58 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);
59 hal_tbm_bo                *hal_tbm_bufmgr_alloc_bo_with_format(hal_tbm_bufmgr *bufmgr, int format, int bo_idx, int width, int height,
60                                           hal_tbm_bo_memory_type mem_types, hal_tbm_error *error);
61 hal_tbm_bo                *hal_tbm_bufmgr_alloc_bo_with_tiled_format(hal_tbm_bufmgr *bufmgr, int width, int height, int bpp, int format,
62                                           hal_tbm_bo_memory_type flags, int bo_idx, hal_tbm_error *error);
63 hal_tbm_bo                *hal_tbm_bufmgr_import_fd(hal_tbm_bufmgr *bufmgr, hal_tbm_fd fd, hal_tbm_error *error);
64 hal_tbm_bo                *hal_tbm_bufmgr_import_key(hal_tbm_bufmgr *bufmgr, hal_tbm_key key, hal_tbm_error *error);
65
66 /* hal_tbm_bo_funcs*/
67 void                    hal_tbm_bo_free(hal_tbm_bo *bo);
68 int                     hal_tbm_bo_get_size(hal_tbm_bo *bo, hal_tbm_error *error);
69 hal_tbm_bo_memory_type  hal_tbm_bo_get_memory_types(hal_tbm_bo *bo, hal_tbm_error *error);
70 hal_tbm_bo_handle       hal_tbm_bo_get_handle(hal_tbm_bo *bo, hal_tbm_bo_device_type device, hal_tbm_error *error);
71 hal_tbm_bo_handle       hal_tbm_bo_map(hal_tbm_bo *bo, hal_tbm_bo_device_type device, hal_tbm_bo_access_option opt, hal_tbm_error *error);
72 hal_tbm_error           hal_tbm_bo_unmap(hal_tbm_bo *bo);
73 hal_tbm_error           hal_tbm_bo_lock(hal_tbm_bo *bo, hal_tbm_bo_device_type device, hal_tbm_bo_access_option opt);
74 hal_tbm_error           hal_tbm_bo_unlock(hal_tbm_bo *bo);
75 hal_tbm_fd              hal_tbm_bo_export_fd(hal_tbm_bo *bo, hal_tbm_error *error);
76 hal_tbm_key             hal_tbm_bo_export_key(hal_tbm_bo *bo, hal_tbm_error *error);
77
78 #ifdef __cplusplus
79 }
80 #endif
81 #endif /* __HAL_TBM__ */