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_
38 /* tbm error base : this error base is same as TIZEN_ERROR_TBM in tizen_error.h */
39 #ifndef TBM_ERROR_BASE
40 #define TBM_ERROR_BASE -0x02830000
45 * \brief Tizen Buffer Manager
49 * @brief Definition for the tizen buffer manager
50 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
52 typedef struct _tbm_bufmgr *tbm_bufmgr;
55 * @brief Definition for the tizen buffer object
56 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
58 typedef struct _tbm_bo *tbm_bo;
60 * @brief Definition for the key associated with the buffer object
61 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
63 typedef uint32_t tbm_key;
65 * @brief Definition for the file descripter of the system buffer manager
66 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
68 typedef int32_t tbm_fd;
73 * @brief Definition for the device type to get the default handle
74 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
76 #define TBM_DEVICE_DEFAULT 0
78 * @brief Definition for the device type to get the virtual memory
79 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
81 #define TBM_DEVICE_CPU 1
83 * @brief Definition for the device type to get the 2D memory handle
84 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
86 #define TBM_DEVICE_2D 2
88 * @brief Definition for the device type to get the 3D memory handle
89 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
91 #define TBM_DEVICE_3D 3
93 * @brief Definition for the device type to get the multimedia handle
94 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
96 #define TBM_DEVICE_MM 4
101 * @brief Definition for the access option to read
102 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
104 #define TBM_OPTION_READ (1 << 0)
106 * @brief Definition for the access option to write
107 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
109 #define TBM_OPTION_WRITE (1 << 1)
111 * @brief Definition for the vendor specific option that depends on the backend
112 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
114 #define TBM_OPTION_VENDOR (0xffff0000)
117 * @brief tbm_bo_handle abstraction of the memory handle by TBM_DEVICE_TYPE
118 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
120 typedef union _tbm_bo_handle {
129 * @brief Enumeration of bo memory type
130 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
133 TBM_BO_DEFAULT = 0, /**< default memory: it depends on the backend */
134 TBM_BO_SCANOUT = (1 << 0), /**< scanout memory */
135 TBM_BO_NONCACHABLE = (1 << 1), /**< non-cachable memory */
136 TBM_BO_WC = (1 << 2), /**< write-combine memory */
137 TBM_BO_VENDOR = (0xffff0000), /**< vendor specific memory: it depends on the backend */
141 * @brief Enumeration for tbm error type.
145 TBM_ERROR_NONE = 0, /**< Successful */
146 TBM_BO_ERROR_GET_FD_FAILED = TBM_ERROR_BASE | 0x0101, /**< failed to get fd failed */
147 TBM_BO_ERROR_HEAP_ALLOC_FAILED = TBM_ERROR_BASE | 0x0102, /**< failed to allocate the heap memory */
148 TBM_BO_ERROR_LOAD_MODULE_FAILED = TBM_ERROR_BASE | 0x0103,/**< failed to load module*/
149 TBM_BO_ERROR_THREAD_INIT_FAILED = TBM_ERROR_BASE | 0x0104,/**< failed to initialize the pthread */
150 TBM_BO_ERROR_BO_ALLOC_FAILED = TBM_ERROR_BASE | 0x0105, /**< failed to allocate tbm_bo */
151 TBM_BO_ERROR_INIT_STATE_FAILED = TBM_ERROR_BASE | 0x0106, /**< failed to initialize the state of tbm_bo */
152 TBM_BO_ERROR_IMPORT_FAILED = TBM_ERROR_BASE | 0x0107, /**< failed to import the handle of tbm_bo */
153 TBM_BO_ERROR_IMPORT_FD_FAILED = TBM_ERROR_BASE | 0x0108, /**< failed to import fd of tbm_bo */
154 TBM_BO_ERROR_EXPORT_FAILED = TBM_ERROR_BASE | 0x0109, /**< failed to export the handle of the tbm_bo */
155 TBM_BO_ERROR_EXPORT_FD_FAILED = TBM_ERROR_BASE | 0x01010, /**< failed to export fd of tbm_bo */
156 TBM_BO_ERROR_GET_HANDLE_FAILED = TBM_ERROR_BASE | 0x0111, /**< failed to get the tbm_bo_handle */
157 TBM_BO_ERROR_LOCK_FAILED = TBM_ERROR_BASE | 0x0112, /**< failed to lock the tbm_bo */
158 TBM_BO_ERROR_MAP_FAILED = TBM_ERROR_BASE | 0x0113, /**< failed to map the tbm_bo to get the tbm_bo_handle */
159 TBM_BO_ERROR_UNMAP_FAILED = TBM_ERROR_BASE | 0x0114, /**< failed to unmap the tbm_bo */
160 TBM_BO_ERROR_SWAP_FAILED = TBM_ERROR_BASE | 0x0115, /**< failed to swap the tbm_bos */
161 TBM_BO_ERROR_DUP_FD_FAILED = TBM_ERROR_BASE | 0x0116, /**< failed to duplicate fd */
165 * @brief Enumeration of tbm buffer manager capability.
168 enum TBM_BUFMGR_CAPABILITY {
169 TBM_BUFMGR_CAPABILITY_NONE = 0, /**< Not Support capability*/
170 TBM_BUFMGR_CAPABILITY_SHARE_KEY = (1 << 0), /**< Support sharing buffer by tbm key */
171 TBM_BUFMGR_CAPABILITY_SHARE_FD = (1 << 1), /**< Support sharing buffer by tbm fd */
172 TBM_BUFMGR_CAPABILITY_TBM_SYNC = (1 << 2), /**< Support tbm sync */
179 /* Functions for buffer manager */
182 * @brief Initializes the buffer manager.
183 * @details If fd is lower than zero, fd is get drm fd in tbm_bufmgr_init function\n
184 * 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
186 * BUFMGR_LOCK default is once\n
187 * once : The previous bo which is locked is unlock when the new bo is trying to be locked\n
188 * always : The new bo is locked until the previous bo which is locked is unlocked\n
189 * never : Every bo is never locked.\n
191 * BUFMGR_MAP_CACHE default is true\n
192 * true : use map cache flushing\n
193 * false : to use map cache flushing
194 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
195 * @param[in] fd : file descripter of the system buffer manager
196 * @return a buffer manager
197 * @retval #tbm_bufmgr
198 * @see tbm_bufmgr_deinit();
201 #include <tbm_bufmgr.h>
204 setenv("BUFMGR_LOCK_TYPE", "once", 1);
205 setenv("BUFMGR_MAP_CACHE", "true", 1);
208 bufmgr = tbm_bufmgr_init (bufmgr_fd);
212 tbm_bufmgr_deinit (bufmgr);
215 tbm_bufmgr tbm_bufmgr_init(int fd);
218 * @brief Deinitializes the buffer manager.
219 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
220 * @param[in] bufmgr : the buffer manager
221 * @see tbm_bufmgr_init()
224 #include <tbm_bufmgr.h>
229 bufmgr = tbm_bufmgr_init (bufmgr_fd);
232 error = tbm_get_last_error ();
238 tbm_bufmgr_deinit (bufmgr);
241 void tbm_bufmgr_deinit(tbm_bufmgr bufmgr);
243 /* Functions for bo */
246 * @brief Allocates the buffer object.
247 * @details This function create tbm_bo and set reference count to 1.\n
248 * The user can craete tbm_bo with memory type flag #TBM_BO_FLAGS\n\n
249 * #TBM_BO_DEFAULT indecates default memory: it depends on the backend\n
250 * #TBM_BO_SCANOUT indecates scanout memory\n
251 * #TBM_BO_NONCACHABLE indecates non-cachable memory\n
252 * #TBM_BO_WC indecates write-combine memory\n
253 * #TBM_BO_VENDOR indecates vendor specific memory: it depends on the tbm backend
254 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
255 * @param[in] bufmgr : the buffer manager
256 * @param[in] size : the size of buffer object
257 * @param[in] flags : the flags of memory type
258 * @return a buffer object
262 #include <tbm_bufmgr.h>
269 bufmgr = tbm_bufmgr_init (bufmgr_fd);
270 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
273 error = tbm_get_last_error ();
279 tbm_bufmgr_deinit (bufmgr);
282 tbm_bo tbm_bo_alloc(tbm_bufmgr bufmgr, int size, int flags);
285 * @brief Increases the reference count of bo.
286 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
287 * @param[in] bo : the buffer object
288 * @return a buffer object
290 * @see tbm_bo_unref()
293 #include <tbm_bufmgr.h>
299 bufmgr = tbm_bufmgr_init (bufmgr_fd);
300 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
304 bo = tbm_bo_ref (bo);
308 tbm_bufmgr_deinit (bufmgr);
311 tbm_bo tbm_bo_ref(tbm_bo bo);
314 * @brief Decreases the reference count of bo
315 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
316 * @param[in] bo : the buffer object
318 * @see tbm_bo_alloc()
321 #include <tbm_bufmgr.h>
327 bufmgr = tbm_bufmgr_init (bufmgr_fd);
328 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
333 tbm_bufmgr_deinit (bufmgr);
336 void tbm_bo_unref(tbm_bo bo);
339 * @brief Maps the buffer object according to the device type and the option.
340 * @details Cache flushing and Locking is executed, while tbm_bo is mapping in the proper condition according to the device type and the access option.\n
341 * If the cache flush type of bufmgr set true, the map cache flushing is executed
342 * If the lock type of bufmgr set once, the previous bo which is locked is unlock when the new bo is trying to be locked.\n
343 * If the lock type of bufmgr set always, the new bo is locked until the previous bo which is locked is unlocked.\n
344 * If the lock type of bufmgr set never, Every bo is never locked.\n\n
345 * #TBM_DEVICE_DEFAULT indecates the default handle.\n
346 * #TBM_DEVICE_2D indecates the 2D memory handle.\n
347 * #TBM_DEVICE_3D indecates the 3D memory handle.\n
348 * #TBM_DEVICE_CPU indecates the virtual memory handle.\n
349 * #TBM_DEVICE_MM indecates the multimedia handle.\n\n
350 * #TBM_OPTION_READ indecates the accss option to read.\n
351 * #TBM_OPTION_WRITE indecates the access option to write.\n
352 * #TBM_OPTION_VENDOR indecates the vendor specific option that depends on the backend.
353 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
354 * @param[in] bo : the buffer object
355 * @param[in] device : the device type to get a handle
356 * @param[in] opt : the option to access the buffer object
357 * @return the handle of the buffer object
358 * @exception #TBM_ERROR_NONE Success
359 * @exception #TBM_ERROR_BO_LOCK_FAILED tbm_bo lock failed
360 * @exception #TBM_ERROR_BO_MAP_FAILED tbm_bo map failed
362 * @see tbm_bo_unmap()
365 #include <tbm_bufmgr.h>
370 tbm_bo_handle handle;
373 bufmgr = tbm_bufmgr_init (bufmgr_fd);
374 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
378 handle = tbm_bo_map (bo, TBM_DEVICE_2D, TBM_OPTION_READ|TBM_OPTION_WRITE);
379 if (handle.ptr == NULL)
381 error = tbm_get_last_error ();
389 tbm_bufmgr_deinit (bufmgr);
392 tbm_bo_handle tbm_bo_map(tbm_bo bo, int device, int opt);
395 * @brief Unmaps the buffer object.
396 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
397 * @param[in] bo : the buffer object
398 * @return 1 if this function succeeds, otherwise 0.
402 #include <tbm_bufmgr.h>
407 tbm_bo_handle handle;
409 bufmgr = tbm_bufmgr_init (bufmgr_fd);
410 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
414 handle = tbm_bo_map (bo, TBM_DEVICE_2D, TBM_OPTION_READ|TBM_OPTION_WRITE);
420 tbm_bufmgr_deinit (bufmgr);
423 int tbm_bo_unmap(tbm_bo bo);
426 * @brief Gets the tbm_bo_handle according to the device type.
427 * @details The tbm_bo_handle can be get without the map of the tbm_bo.\n
428 * In this case, TBM does not guarantee the lock and the cache flush of the tbm_bo.\n\n
429 * #TBM_DEVICE_DEFAULT indecates the default handle.\n
430 * #TBM_DEVICE_2D indecates the 2D memory handle.\n
431 * #TBM_DEVICE_3D indecates the 3D memory handle.\n
432 * #TBM_DEVICE_CPU indecates the virtual memory handle.\n
433 * #TBM_DEVICE_MM indecates the multimedia handle.
434 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
435 * @param[in] bo : the buffer object
436 * @param[in] device : the device type to get a handle
437 * @return the handle of the buffer object
438 * @retval #tbm_bo_handle
441 #include <tbm_bufmgr.h>
446 tbm_bo_handle handle;
449 bufmgr = tbm_bufmgr_init (bufmgr_fd);
450 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
454 handle = tbm_bo_get_handle (bo, TBM_DEVICE_2D);
455 if (handle.ptr == NULL)
457 error = tbm_get_last_error ();
464 tbm_bufmgr_deinit (bufmgr);
467 tbm_bo_handle tbm_bo_get_handle(tbm_bo bo, int device);
470 * @brief Exports the buffer object by key.
471 * @details The tbm_bo can be exported to the anther process with the unique key associated with the the tbm_bo.
472 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
473 * @param[in] bo : the buffer object
474 * @return key associated with the buffer object
476 * @see tbm_bo_import()
479 #include <tbm_bufmgr.h>
487 bufmgr = tbm_bufmgr_init (bufmgr_fd);
488 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
489 key = tbm_bo_export (bo);
492 error = tbm_get_last_error ();
499 tbm_bufmgr_deinit (bufmgr);
502 tbm_key tbm_bo_export(tbm_bo bo);
505 * @brief Exports the buffer object by fd.
506 * @details The tbm_bo can be exported to the anther process with the unique fd associated with the the tbm_bo.
507 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
508 * @remarks You must release the fd using close().
509 * @param[in] bo : the buffer object
510 * @return fd associated with the buffer object
512 * @see tbm_bo_import_fd()
515 #include <tbm_bufmgr.h>
523 bufmgr = tbm_bufmgr_init (bufmgr_fd);
524 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
525 bo_fd = tbm_bo_export (bo);
528 error = tbm_get_last_error ();
535 tbm_bufmgr_deinit (bufmgr);
538 tbm_fd tbm_bo_export_fd(tbm_bo bo);
541 * @brief Imports the buffer object associated with the key.
542 * @details The reference count of the tbm_bo is 1.
543 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
544 * @param[in] bufmgr : the buffer manager
545 * @param[in] key : the key associated with the buffer object
546 * @return a buffer object
548 * @see tbm_bo_export()
551 #include <tbm_bufmgr.h>
561 bufmgr = tbm_bufmgr_init (bufmgr_fd);
562 bo = tbm_bo_import (bufmgr, key);
565 error = tbm_get_last_error ();
572 tbm_bufmgr_deinit (bufmgr);
575 tbm_bo tbm_bo_import(tbm_bufmgr bufmgr, tbm_key key);
578 * @brief Imports the buffer object associated with the fd.
579 * @details The reference count of the tbm_bo is 1.
580 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
581 * @remarks You must release the fd using close().
582 * @param[in] bufmgr : the buffer manager
583 * @param[in] fd : the fd associated with the buffer object
584 * @return a buffer object
586 * @see tbm_bo_export_fd()
589 #include <tbm_bufmgr.h>
599 bufmgr = tbm_bufmgr_init (bufmgr_fd);
600 bo = tbm_bo_import_fd (bo_fd);
603 error = tbm_get_last_error ();
610 tbm_bufmgr_deinit (bufmgr);
613 tbm_bo tbm_bo_import_fd(tbm_bufmgr bufmgr, tbm_fd fd);
616 * @brief Gets the size of a bo.
617 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
618 * @param[in] bo : the buffer object
619 * @return 1 if this function succeeds, otherwise 0.
620 * @see tbm_bo_alloc()
623 #include <tbm_bufmgr.h>
630 bufmgr = tbm_bufmgr_init (bufmgr_fd);
631 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
632 size = tbm_bo_size (bo);
637 tbm_bufmgr_deinit (bufmgr);
640 int tbm_bo_size(tbm_bo bo);
643 * @brief Gets the state where the buffer object is locked.
644 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
645 * @param[in] bo : the buffer object
646 * @return 1 if this bo is locked, otherwise 0.
648 * @see tbm_bo_unmap()
651 #include <tbm_bufmgr.h>
657 bufmgr = tbm_bufmgr_init (bufmgr_fd);
658 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
662 if (tbm_bo_locked (bo))
668 tbm_bufmgr_deinit (bufmgr);
671 int tbm_bo_locked(tbm_bo bo);
674 * @brief Swaps the buffer object.
675 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
676 * @param[in] bo1 : the buffer object
677 * @param[in] bo2 : the buffer object
678 * @return 1 if this function succeeds, otherwise 0.
681 #include <tbm_bufmgr.h>
690 bufmgr = tbm_bufmgr_init (bufmgr_fd);
691 bo1 = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
692 bo2 = tbm_bo_alloc (bufmgr, 256 * 256, TBM_BO_DEFAULT);
696 ret = tbm_bo_swap (bo1, bo2);
699 error = tbm_get_last_error ();
707 tbm_bufmgr_deinit (bufmgr);
710 int tbm_bo_swap(tbm_bo bo1, tbm_bo bo2);
713 * @brief Called when the user data is deleted in buffer object.
714 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
715 * @param[in] user_data User_data to be passed to callback function
716 * @pre The callback must be registered using tbm_bo_add_user_data().\n
717 * tbm_bo_delete_user_data() must be called to invoke this callback.
718 * @see tbm_bo_add_user_data()
719 * @see tbm_bo_delete_user_data()
721 typedef void (*tbm_data_free) (void *user_data);
724 * @brief Adds a user_data to the buffer object.
725 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
726 * @param[in] bo : the buffer object
727 * @param[in] key : the key associated with the user_data
728 * @param[in] data_free_func : the function pointer to free the user_data
729 * @return 1 if this function succeeds, otherwise 0.
730 * @post tbm_data_free() will be called under certain conditions, after calling tbm_bo_delete_user_data().
731 * @see tbm_data_free()
732 * @see tbm_bo_set_user_data()
733 * @see tbm_bo_get_user_data()
734 * @see tbm_bo_delete_user_data()
737 #include <tbm_bufmgr.h>
739 void example_data_free (void *user_data)
741 char *data = (char*) user_data;
754 bufmgr = tbm_bufmgr_init (bufmgr_fd);
755 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
756 user_data = (char*) malloc (sizeof(char) * 128);
760 tbm_bo_add_user_data (bo, 1, example_data_free);
761 tbm_bo_set_user_data (bo, 1, user_data);
765 ret = tbm_bo_get_user_data (bo, 1, &get_data);
766 tbm_bo_delete_user_data (bo, 1);
771 tbm_bufmgr_deinit (bufmgr);
776 int tbm_bo_add_user_data(tbm_bo bo, unsigned long key,
777 tbm_data_free data_free_func);
780 * @brief Deletes the user_data in the buffer object.
781 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
782 * @param[in] bo : the buffer object
783 * @param[in] key : the key associated with the user_date
784 * @return 1 if this function succeeds, otherwise 0.
785 * @see tbm_bo_add_user_data()
786 * @see tbm_bo_get_user_data()
787 * @see tbm_bo_delete_user_data()
790 #include <tbm_bufmgr.h>
792 void example_data_free (void *user_data)
794 char *data = (char*) user_data;
807 bufmgr = tbm_bufmgr_init (bufmgr_fd);
808 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
809 user_data = (char*) malloc (sizeof(char) * 128);
813 tbm_bo_add_user_data (bo, 1, example_data_free);
814 tbm_bo_set_user_data (bo, 1, user_data);
818 ret = tbm_bo_get_user_data (bo, 1, &get_data);
819 tbm_bo_delete_user_data (bo, 1);
824 tbm_bufmgr_deinit (bufmgr);
828 int tbm_bo_delete_user_data(tbm_bo bo, unsigned long key);
831 * @brief Sets a user_date to the buffer object.
832 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
833 * @param[in] bo : the buffer object
834 * @param[in] key : the key associated with the user_date
835 * @param[in] data : a pointer of the user_data
836 * @return 1 if this function succeeds, otherwise 0.
837 * @see tbm_bo_add_user_data()
838 * @see tbm_bo_set_user_data()
839 * @see tbm_bo_delete_user_data()
842 #include <tbm_bufmgr.h>
844 void example_data_free (void *user_data)
846 char *data = (char*) user_data;
859 bufmgr = tbm_bufmgr_init (bufmgr_fd);
860 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
861 user_data = (char*) malloc (sizeof(char) * 128);
865 tbm_bo_add_user_data (bo, 1, example_data_free);
866 tbm_bo_set_user_data (bo, 1, user_data);
870 ret = tbm_bo_get_user_data (bo, 1, &get_data);
871 tbm_bo_delete_user_data (bo, 1);
876 tbm_bufmgr_deinit (bufmgr);
880 int tbm_bo_set_user_data(tbm_bo bo, unsigned long key, void *data);
883 * @brief Gets a user_data from the buffer object with the key.
884 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
885 * @param[in] bo : the buffer object
886 * @param[in] key : the key associated with the user_date
887 * @param[out] data : to get the user data
888 * @return 1 if this function succeeds, otherwise 0.
889 * @see tbm_bo_add_user_data()
890 * @see tbm_bo_set_user_data()
891 * @see tbm_bo_get_user_data()
894 #include <tbm_bufmgr.h>
896 void example_data_free (void *user_data)
898 char *data = (char*) user_data;
911 bufmgr = tbm_bufmgr_init (bufmgr_fd);
912 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
913 user_data = (char*) malloc (sizeof(char) * 128);
917 tbm_bo_add_user_data (bo, 1, example_data_free);
918 tbm_bo_set_user_data (bo, 1, user_data);
922 ret = tbm_bo_get_user_data (bo, 1, &get_data);
923 tbm_bo_delete_user_data (bo, 1);
928 tbm_bufmgr_deinit (bufmgr);
932 int tbm_bo_get_user_data(tbm_bo bo, unsigned long key, void **data);
935 * @brief Gets the latest tbm_error.
937 * @return the latest tbm_error
940 #include <tbm_bufmgr.h>
945 tbm_bo_handle handle;
948 bufmgr = tbm_bufmgr_init (bufmgr_fd);
949 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
952 error = tbm_get_last_error ();
958 handle = tbm_bo_map (bo, TBM_DEVICE_2D, TBM_OPTION_READ|TBM_OPTION_WRITE);
959 if (handle.ptr == NULL)
961 error = tbm_get_last_error ();
969 tbm_bufmgr_deinit (bufmgr);
972 tbm_error_e tbm_get_last_error(void);
975 * @brief Gets the tbm buffer capability.
977 * @param[in] bufmgr : the buffer manager
978 * @return the tbm bufmgr capability
981 #include <tbm_bufmgr.h>
985 unsigned int capability;
987 bufmgr = tbm_bufmgr_init (bufmgr_fd);
989 capability = tbm_bufmgr_get_capability (bufmgr);
991 tbm_bufmgr_deinit (bufmgr);
994 unsigned int tbm_bufmgr_get_capability(tbm_bufmgr bufmgr);
997 * @brief Gets the tbm bo flags.
999 * @param[in] bo : the buffer object
1000 * @return the tbm bo flags
1004 #include <tbm_bufmgr.h>
1011 bufmgr = tbm_bufmgr_init (bufmgr_fd);
1012 bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT);
1013 flags = tbm_bo_get_flags (bo);
1018 tbm_bufmgr_deinit (bufmgr);
1022 int tbm_bo_get_flags(tbm_bo bo);
1025 * @brief Print out the information of tbm_bos.
1027 * @param[in] bufmgr : the buffer manager
1029 void tbm_bufmgr_debug_show(tbm_bufmgr bufmgr);
1032 * @brief Print out to str the information of tbm_bos.
1034 * @param[in] bufmgr : the buffer manager
1038 void tbm_bufmgr_debug_tbm_info_get(tbm_bufmgr bufmgr, char * str, int * len);
1041 * @brief Print out the trace of tbm_bos.
1043 * @param[in] bufmgr : the buffer manager
1044 * @param[in] onoff : 1 is on, and 0 is off
1046 void tbm_bufmgr_debug_trace(tbm_bufmgr bufmgr, int onoff);
1049 * @brief Dump all tbm surfaces
1050 * @param[in] path : the given dump path
1051 * @return 1 if this function succeeds, otherwise 0.
1053 int tbm_bufmgr_debug_dump_all(char *path);
1056 * @brief Start the dump debugging for queue.
1058 * @param[in] path : the given dump path
1059 * @param[in] count : the dump count number
1060 * @param[in] onoff : 1 is on, and 0 is off, if onoff==0 path and count are ignored
1061 * @return 1 if this function succeeds, otherwise 0.
1063 int tbm_bufmgr_debug_queue_dump(char *path, int count, int onoff);
1065 int tbm_bufmgr_bind_native_display(tbm_bufmgr bufmgr, void *NativeDisplay);
1070 #endif /* _TBM_BUFMGR_H_ */