7 /* tbm error base : this error base is same as TIZEN_ERROR_TBM in tizen_error.h */
9 #define TBM_ERROR_BASE -0x02830000
12 typedef struct _tbm_bufmgr *tbm_bufmgr;
14 typedef struct _tbm_bo *tbm_bo;
16 typedef uint32_t tbm_key;
18 typedef int32_t tbm_fd;
22 #define TBM_DEVICE_DEFAULT 0
23 #define TBM_DEVICE_CPU 1
24 #define TBM_DEVICE_2D 2
25 #define TBM_DEVICE_3D 3
26 #define TBM_DEVICE_MM 4
30 #define TBM_OPTION_READ (1 << 0)
31 #define TBM_OPTION_WRITE (1 << 1)
32 #define TBM_OPTION_VENDOR (0xffff0000)
34 /* stub for union tbm_bo_handle */
43 tbm_bo_handle(const uint64_t v)
58 TBM_BO_DEFAULT = 0, /**< default memory: it depends on the backend */
59 TBM_BO_SCANOUT = (1 << 0), /**< scanout memory */
60 TBM_BO_NONCACHABLE = (1 << 1), /**< non-cachable memory */
61 TBM_BO_WC = (1 << 2), /**< write-combine memory */
62 TBM_BO_VENDOR = (0xffff0000), /**< vendor specific memory: it depends on the backend */
66 TBM_ERROR_NONE = 0, /**< Successful */
67 TBM_BO_ERROR_GET_FD_FAILED = TBM_ERROR_BASE | 0x0101, /**< failed to get fd failed */
68 TBM_BO_ERROR_HEAP_ALLOC_FAILED = TBM_ERROR_BASE | 0x0102, /**< failed to allocate the heap memory */
69 TBM_BO_ERROR_LOAD_MODULE_FAILED = TBM_ERROR_BASE | 0x0103,/**< failed to load module*/
70 TBM_BO_ERROR_THREAD_INIT_FAILED = TBM_ERROR_BASE | 0x0104,/**< failed to initialize the pthread */
71 TBM_BO_ERROR_BO_ALLOC_FAILED = TBM_ERROR_BASE | 0x0105, /**< failed to allocate tbm_bo */
72 TBM_BO_ERROR_INIT_STATE_FAILED = TBM_ERROR_BASE | 0x0106, /**< failed to initialize the state of tbm_bo */
73 TBM_BO_ERROR_IMPORT_FAILED = TBM_ERROR_BASE | 0x0107, /**< failed to import the handle of tbm_bo */
74 TBM_BO_ERROR_IMPORT_FD_FAILED = TBM_ERROR_BASE | 0x0108, /**< failed to import fd of tbm_bo */
75 TBM_BO_ERROR_EXPORT_FAILED = TBM_ERROR_BASE | 0x0109, /**< failed to export the handle of the tbm_bo */
76 TBM_BO_ERROR_EXPORT_FD_FAILED = TBM_ERROR_BASE | 0x01010, /**< failed to export fd of tbm_bo */
77 TBM_BO_ERROR_GET_HANDLE_FAILED = TBM_ERROR_BASE | 0x0111, /**< failed to get the tbm_bo_handle */
78 TBM_BO_ERROR_LOCK_FAILED = TBM_ERROR_BASE | 0x0112, /**< failed to lock the tbm_bo */
79 TBM_BO_ERROR_MAP_FAILED = TBM_ERROR_BASE | 0x0113, /**< failed to map the tbm_bo to get the tbm_bo_handle */
80 TBM_BO_ERROR_UNMAP_FAILED = TBM_ERROR_BASE | 0x0114, /**< failed to unmap the tbm_bo */
81 TBM_BO_ERROR_SWAP_FAILED = TBM_ERROR_BASE | 0x0115, /**< failed to swap the tbm_bos */
82 TBM_BO_ERROR_DUP_FD_FAILED = TBM_ERROR_BASE | 0x0116, /**< failed to duplicate fd */
85 enum TBM_BUFMGR_CAPABILITY {
86 TBM_BUFMGR_CAPABILITY_NONE = 0, /**< Not Support capability*/
87 TBM_BUFMGR_CAPABILITY_SHARE_KEY = (1 << 0), /**< Support sharing buffer by tbm key */
88 TBM_BUFMGR_CAPABILITY_SHARE_FD = (1 << 1), /**< Support sharing buffer by tbm fd */
95 /* Functions for buffer manager */
97 tbm_bufmgr tbm_bufmgr_init(int fd);
99 void tbm_bufmgr_deinit(tbm_bufmgr bufmgr);
101 /* Functions for bo */
103 tbm_bo tbm_bo_alloc(tbm_bufmgr bufmgr, int size, int flags);
105 tbm_bo tbm_bo_ref(tbm_bo bo);
107 void tbm_bo_unref(tbm_bo bo);
109 tbm_bo_handle tbm_bo_map(tbm_bo bo, int device, int opt);
111 int tbm_bo_unmap(tbm_bo bo);
113 tbm_bo_handle tbm_bo_get_handle(tbm_bo bo, int device);
115 tbm_key tbm_bo_export(tbm_bo bo);
117 tbm_fd tbm_bo_export_fd(tbm_bo bo);
119 tbm_bo tbm_bo_import(tbm_bufmgr bufmgr, tbm_key key);
121 tbm_bo tbm_bo_import_fd(tbm_bufmgr bufmgr, tbm_fd fd);
123 int tbm_bo_size(tbm_bo bo);
125 int tbm_bo_locked(tbm_bo bo);
127 int tbm_bo_swap(tbm_bo bo1, tbm_bo bo2);
129 typedef void (*tbm_data_free) (void *user_data);
131 int tbm_bo_add_user_data(tbm_bo bo, unsigned long key,
132 tbm_data_free data_free_func);
134 int tbm_bo_delete_user_data(tbm_bo bo, unsigned long key);
136 int tbm_bo_set_user_data(tbm_bo bo, unsigned long key, void *data);
138 int tbm_bo_get_user_data(tbm_bo bo, unsigned long key, void **data);
140 tbm_error_e tbm_get_last_error(void);
142 unsigned int tbm_bufmgr_get_capability(tbm_bufmgr bufmgr);
144 int tbm_bo_get_flags(tbm_bo bo);
146 void tbm_bufmgr_debug_show(tbm_bufmgr bufmgr);
148 void tbm_bufmgr_debug_trace(tbm_bufmgr bufmgr, int onoff);
150 int tbm_bufmgr_bind_native_display(tbm_bufmgr bufmgr, void *NativeDisplay);
155 #endif /* _TBM_BUFMGR_H_ */