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_common.h>
38 #include <tbm_error.h>
42 * \brief Tizen Buffer Manager
49 /* Functions for buffer manager */
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
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
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
68 * @see tbm_bufmgr_deinit();
71 #include <tbm_bufmgr.h>
74 setenv("BUFMGR_LOCK_TYPE", "once", 1);
75 setenv("BUFMGR_MAP_CACHE", "true", 1);
78 bufmgr = tbm_bufmgr_init (bufmgr_fd);
82 tbm_bufmgr_deinit (bufmgr);
85 tbm_bufmgr tbm_bufmgr_init(int fd);
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()
94 #include <tbm_bufmgr.h>
99 bufmgr = tbm_bufmgr_init (bufmgr_fd);
102 error = tbm_get_last_error ();
108 tbm_bufmgr_deinit (bufmgr);
111 void tbm_bufmgr_deinit(tbm_bufmgr bufmgr);
114 * @brief Gets the tbm buffer capability.
116 * @param[in] bufmgr : the buffer manager
117 * @return the tbm bufmgr capability
120 #include <tbm_bufmgr.h>
124 unsigned int capability;
126 bufmgr = tbm_bufmgr_init (bufmgr_fd);
128 capability = tbm_bufmgr_get_capability (bufmgr);
130 tbm_bufmgr_deinit (bufmgr);
133 unsigned int tbm_bufmgr_get_capability(tbm_bufmgr bufmgr);
136 * @brief bind the native_display.
138 * @param[in] bufmgr : the buffer manager
139 * @param[in] native_display : the native_display
141 int tbm_bufmgr_bind_native_display(tbm_bufmgr bufmgr, void *native_display);
144 * @brief Initializes the buffer manager at the display server.
145 * @details use this api to initialize the tbm_bufmgr at the display server.
148 tbm_bufmgr tbm_bufmgr_server_init(void);
151 * @brief Set the bo_lock_type of the bufffer manager.
152 * @details set the bo_lock_type
155 int tbm_bufmgr_set_bo_lock_type(tbm_bufmgr bufmgr, tbm_bufmgr_bo_lock_type bo_lock_type);
158 * @brief Print out the information of tbm_bos.
160 * @param[in] bufmgr : the buffer manager
162 void tbm_bufmgr_debug_show(tbm_bufmgr bufmgr);
165 * @brief Get string with the information of tbm_bos.
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.
170 char * tbm_bufmgr_debug_tbm_info_get(tbm_bufmgr bufmgr);
173 * @brief Print out the trace of tbm_bos.
175 * @param[in] bufmgr : the buffer manager
176 * @param[in] onoff : 1 is on, and 0 is off
178 void tbm_bufmgr_debug_trace(tbm_bufmgr bufmgr, int onoff);
181 * @brief Dump all tbm surfaces
182 * @param[in] path : the given dump path
183 * @return 1 if this function succeeds, otherwise 0.
185 int tbm_bufmgr_debug_dump_all(char *path);
188 * @brief Start the dump debugging for queue.
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.
195 int tbm_bufmgr_debug_queue_dump(char *path, int count, int onoff);
198 * @brief Set scale factor for the nearest calling tbm_bufmgr_debug_dump_all() or tbm_bufmgr_debug_queue_dump()
200 * @param[in] scale : the scale factor, 0 - disable scaling
203 #include <tbm_bufmgr.h>
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/");
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);
215 void tbm_bufmgr_debug_dump_set_scale(double scale);
218 * @brief Get ref_count of a global tbm_bufmgr
221 int tbm_bufmgr_debug_get_ref_count(void);
224 * @brief set or unset the trace_mask to print out the trace logs.
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
230 void tbm_bufmgr_debug_set_trace_mask(tbm_bufmgr bufmgr, tbm_bufmgr_debug_trace_mask mask, int set);
235 #endif /* _TBM_BUFMGR_H_ */