1 /**************************************************************************
5 Copyright 2012 Samsung Electronics co., Ltd. All Rights Reserved.
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>
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_BUFMGR_H_
33 #define _TBM_BUFMGR_H_
36 #include <tbm_type_int.h>
41 * \brief Tizen Buffer Manager
48 /* Functions for buffer manager */
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
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
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
67 * @see tbm_bufmgr_deinit();
70 #include <tbm_bufmgr.h>
73 setenv("BUFMGR_LOCK_TYPE", "once", 1);
74 setenv("BUFMGR_MAP_CACHE", "true", 1);
77 bufmgr = tbm_bufmgr_init (bufmgr_fd);
81 tbm_bufmgr_deinit (bufmgr);
84 tbm_bufmgr tbm_bufmgr_init(int fd);
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()
93 #include <tbm_bufmgr.h>
98 bufmgr = tbm_bufmgr_init (bufmgr_fd);
101 error = tbm_get_last_error ();
107 tbm_bufmgr_deinit (bufmgr);
110 void tbm_bufmgr_deinit(tbm_bufmgr bufmgr);
113 * @brief Gets the tbm buffer capability.
115 * @param[in] bufmgr : the buffer manager
116 * @return the tbm bufmgr capability
119 #include <tbm_bufmgr.h>
123 unsigned int capability;
125 bufmgr = tbm_bufmgr_init (bufmgr_fd);
127 capability = tbm_bufmgr_get_capability (bufmgr);
129 tbm_bufmgr_deinit (bufmgr);
132 unsigned int tbm_bufmgr_get_capability(tbm_bufmgr bufmgr);
135 * @brief bind the native_display.
137 * @param[in] bufmgr : the buffer manager
138 * @param[in] native_display : the native_display
140 int tbm_bufmgr_bind_native_display(tbm_bufmgr bufmgr, void *native_display);
143 * @brief Initializes the buffer manager at the display server.
144 * @details use this api to initialize the tbm_bufmgr at the display server.
147 tbm_bufmgr tbm_bufmgr_server_init(void);
150 * @brief Set the bo_lock_type of the bufffer manager.
151 * @details set the bo_lock_type
154 int tbm_bufmgr_set_bo_lock_type(tbm_bufmgr bufmgr, tbm_bufmgr_bo_lock_type bo_lock_type);
157 * @brief Print out the information of tbm_bos.
159 * @param[in] bufmgr : the buffer manager
161 void tbm_bufmgr_debug_show(tbm_bufmgr bufmgr);
164 * @brief Get string with the information of tbm_bos.
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.
169 char * tbm_bufmgr_debug_tbm_info_get(tbm_bufmgr bufmgr);
172 * @brief Print out the trace of tbm_bos.
174 * @param[in] bufmgr : the buffer manager
175 * @param[in] onoff : 1 is on, and 0 is off
177 void tbm_bufmgr_debug_trace(tbm_bufmgr bufmgr, int onoff);
180 * @brief Dump all tbm surfaces
181 * @param[in] path : the given dump path
182 * @return 1 if this function succeeds, otherwise 0.
184 int tbm_bufmgr_debug_dump_all(char *path);
187 * @brief Start the dump debugging for queue.
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.
194 int tbm_bufmgr_debug_queue_dump(char *path, int count, int onoff);
197 * @brief Set scale factor for the nearest calling tbm_bufmgr_debug_dump_all() or tbm_bufmgr_debug_queue_dump()
199 * @param[in] scale : the scale factor, 0 - disable scaling
202 #include <tbm_bufmgr.h>
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/");
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);
214 void tbm_bufmgr_debug_dump_set_scale(double scale);
217 * @brief Get ref_count of a global tbm_bufmgr
220 int tbm_bufmgr_debug_get_ref_count(void);
223 * @brief set or unset the trace_mask to print out the trace logs.
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
229 void tbm_bufmgr_debug_set_trace_mask(tbm_bufmgr bufmgr, tbm_bufmgr_debug_trace_mask mask, int set);
234 #endif /* _TBM_BUFMGR_H_ */