type: add error types.
[platform/core/uifw/libtbm.git] / src / tbm_bufmgr.h
1 /**************************************************************************
2
3 libtbm
4
5 Copyright 2012 Samsung Electronics co., Ltd. All Rights Reserved.
6
7 Contact: SooChan Lim <sc1.lim@samsung.com>, Sangjin Lee <lsj119@samsung.com>
8 Boram Park <boram1288.park@samsung.com>, Changyeon Lee <cyeon.lee@samsung.com>
9
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:
17
18 The above copyright notice and this permission notice (including the
19 next paragraph) shall be included in all copies or substantial portions
20 of the Software.
21
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.
29
30 **************************************************************************/
31
32 #ifndef _TBM_BUFMGR_H_
33 #define _TBM_BUFMGR_H_
34
35 #include <tbm_type.h>
36 #include <tbm_type_int.h>
37 #include <tbm_bo.h>
38
39 /**
40  * \file tbm_bufmgr.h
41  * \brief Tizen Buffer Manager
42  */
43
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47
48 /* Functions for buffer manager */
49
50 /**
51  * @brief Initializes the buffer manager.
52  * @details If fd is lower than zero, fd is get drm fd in tbm_bufmgr_init function\n
53  * The user can decide the lock type and cache flush type with the environment variables, which are BUFMGR_LOCK_TYPE and BUFMGR_MAP_CACHE.\n
54  * \n
55  * BUFMGR_LOCK default is once\n
56  * once : The previous bo which is locked is unlock when the new bo is trying to be locked\n
57  * always : The new bo is locked until the previous bo which is locked is unlocked\n
58  * never : Every bo is never locked.\n
59  * \n
60  * BUFMGR_MAP_CACHE default is true\n
61  * true : use map cache flushing\n
62  * false : to use map cache flushing
63  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
64  * @param[in] fd : file descripter of the system buffer manager
65  * @return a buffer manager
66  * @retval #tbm_bufmgr
67  * @see tbm_bufmgr_deinit();
68  * @par Example
69    @code
70    #include <tbm_bufmgr.h>
71    int bufmgr_fd;
72
73    setenv("BUFMGR_LOCK_TYPE", "once", 1);
74    setenv("BUFMGR_MAP_CACHE", "true", 1);
75
76    tbm_bufmgr bufmgr;
77    bufmgr = tbm_bufmgr_init (bufmgr_fd);
78
79    ....
80
81    tbm_bufmgr_deinit (bufmgr);
82    @endcode
83  */
84 tbm_bufmgr tbm_bufmgr_init(int fd);
85
86 /**
87  * @brief Deinitializes the buffer manager.
88  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
89  * @param[in] bufmgr : the buffer manager
90  * @see tbm_bufmgr_init()
91  * @par Example
92    @code
93    #include <tbm_bufmgr.h>
94
95    int bufmgr_fd;
96    tbm_bufmgr bufmgr;
97    tbm_error_e error;
98    bufmgr = tbm_bufmgr_init (bufmgr_fd);
99    if (!bufmgr)
100    {
101       error = tbm_get_last_error ();
102       ...
103    }
104
105    ....
106
107    tbm_bufmgr_deinit (bufmgr);
108    @endcode
109  */
110 void tbm_bufmgr_deinit(tbm_bufmgr bufmgr);
111
112 /**
113  * @brief Gets the tbm buffer capability.
114  * @since_tizen 2.4
115  * @param[in] bufmgr : the buffer manager
116  * @return the tbm bufmgr capability
117  * @par Example
118    @code
119    #include <tbm_bufmgr.h>
120
121    int bufmgr_fd;
122    tbm_bufmgr bufmgr;
123    unsigned int capability;
124
125    bufmgr = tbm_bufmgr_init (bufmgr_fd);
126
127    capability = tbm_bufmgr_get_capability (bufmgr);
128
129    tbm_bufmgr_deinit (bufmgr);
130    @endcode
131  */
132 unsigned int tbm_bufmgr_get_capability(tbm_bufmgr bufmgr);
133
134 /**
135  * @brief bind the native_display.
136  * @since_tizen 3.0
137  * @param[in] bufmgr : the buffer manager
138  * @param[in] native_display : the native_display
139  */
140 int tbm_bufmgr_bind_native_display(tbm_bufmgr bufmgr, void *native_display);
141
142 /**
143  * @brief Initializes the buffer manager at the display server.
144  * @details use this api to initialize the tbm_bufmgr at the display server.
145  * @since_tizen 5.0
146  */
147 tbm_bufmgr tbm_bufmgr_server_init(void);
148
149 /**
150  * @brief Set the bo_lock_type of the bufffer manager.
151  * @details set the bo_lock_type
152  * @since_tizen 5.0
153  */
154 int tbm_bufmgr_set_bo_lock_type(tbm_bufmgr bufmgr, tbm_bufmgr_bo_lock_type bo_lock_type);
155
156 /**
157  * @brief Print out the information of tbm_bos.
158  * @since_tizen 3.0
159  * @param[in] bufmgr : the buffer manager
160  */
161 void tbm_bufmgr_debug_show(tbm_bufmgr bufmgr);
162
163 /**
164  * @brief Get string with the information of tbm_bos.
165  * @since_tizen 3.0
166  * @param[in] bufmgr : the buffer manager
167  * @return sting with info if this function succeeds, otherwise NULL. It has to be free by user.
168  */
169 char * tbm_bufmgr_debug_tbm_info_get(tbm_bufmgr bufmgr);
170
171 /**
172  * @brief Print out the trace of tbm_bos.
173  * @since_tizen 3.0
174  * @param[in] bufmgr : the buffer manager
175  * @param[in] onoff : 1 is on, and 0 is off
176  */
177 void tbm_bufmgr_debug_trace(tbm_bufmgr bufmgr, int onoff);
178
179 /**
180  * @brief Dump all tbm surfaces
181  * @param[in] path : the given dump path
182  * @return 1 if this function succeeds, otherwise 0.
183  */
184 int tbm_bufmgr_debug_dump_all(char *path);
185
186 /**
187  * @brief Start the dump debugging for queue.
188  * @since_tizen 3.0
189  * @param[in] path : the given dump path
190  * @param[in] count : the dump count number
191  * @param[in] onoff : 1 is on, and 0 is off, if onoff==0 path and count are ignored
192  * @return 1 if this function succeeds, otherwise 0.
193  */
194 int tbm_bufmgr_debug_queue_dump(char *path, int count, int onoff);
195
196 /**
197  * @brief Set scale factor for the nearest calling tbm_bufmgr_debug_dump_all() or tbm_bufmgr_debug_queue_dump()
198  * @since_tizen 3.0
199  * @param[in] scale : the scale factor, 0 - disable scaling
200  * @par Example
201    @code
202    #include <tbm_bufmgr.h>
203
204    // Dump all surface with scale factor 0.5
205    tbm_bufmgr_debug_dump_set_scale(0.5);
206    tbm_bufmgr_debug_dump_all("/tmp/");
207
208    // Start the dump debugging for queue with scale factor 0.5
209    tbm_bufmgr_debug_dump_set_scale(0.2);
210    tbm_bufmgr_debug_queue_dump("/tmp/", 10, 1);
211
212    @endcode
213  */
214 void tbm_bufmgr_debug_dump_set_scale(double scale);
215
216 /**
217  * @brief Get ref_count of a global tbm_bufmgr
218  * @since_tizen 5.0
219  */
220 int tbm_bufmgr_debug_get_ref_count(void);
221
222 /**
223  * @brief set or unset the trace_mask to print out the trace logs.
224  * @since_tizen 5.0
225  * @param[in] bufmgr : the buffer manager
226  * @param[in] mask : enum value for the trace log
227  * @param[in] set : set the mask when set is 1, otherwise unset the mask when set is 0
228  */
229 void tbm_bufmgr_debug_set_trace_mask(tbm_bufmgr bufmgr, tbm_bufmgr_debug_trace_mask mask, int set);
230
231 #ifdef __cplusplus
232 }
233 #endif
234 #endif                                                  /* _TBM_BUFMGR_H_ */