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