X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Ftbm_bufmgr.h;h=e386beabc14ffef28ee19e40829d38daccc0b163;hb=e3100bbd19bd30b289e75fb05b25e472a4d19633;hp=0191d9daed8e8ad44d3a25074508e0454d91607f;hpb=b31c41a9745cbcd4656eacaae44920f8e5b7012b;p=platform%2Fcore%2Fuifw%2Flibtbm.git diff --git a/src/tbm_bufmgr.h b/src/tbm_bufmgr.h index 0191d9d..e386bea 100644 --- a/src/tbm_bufmgr.h +++ b/src/tbm_bufmgr.h @@ -49,7 +49,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * @brief Definition for the tizen buffer manager * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ -typedef struct _tbm_bufmgr * tbm_bufmgr; +typedef struct _tbm_bufmgr *tbm_bufmgr; /** * @brief Definition for the tizen buffer object @@ -67,7 +67,6 @@ typedef uint32_t tbm_key; */ typedef int32_t tbm_fd; - /* TBM_DEVICE_TYPE */ /** @@ -96,17 +95,6 @@ typedef int32_t tbm_fd; */ #define TBM_DEVICE_MM 4 -/** - * @brief Definition for the cache invalidate - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif - */ -#define TBM_CACHE_INV 0x01 -/** - * @brief Definition for the cache clean - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif - */ -#define TBM_CACHE_CLN 0x02 - /* TBM_OPTION */ /** @@ -129,54 +117,60 @@ typedef int32_t tbm_fd; * @brief tbm_bo_handle abstraction of the memory handle by TBM_DEVICE_TYPE * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ -typedef union _tbm_bo_handle -{ - void *ptr; - int32_t s32; - uint32_t u32; - int64_t s64; - uint64_t u64; +typedef union _tbm_bo_handle { + void *ptr; + int32_t s32; + uint32_t u32; + int64_t s64; + uint64_t u64; } tbm_bo_handle; /** * @brief Enumeration of bo memory type * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ -enum TBM_BO_FLAGS -{ - TBM_BO_DEFAULT = 0, /**< default memory: it depends on the backend */ - TBM_BO_SCANOUT = (1<<0), /**< scanout memory */ - TBM_BO_NONCACHABLE = (1<<1), /**< non-cachable memory */ - TBM_BO_WC = (1<<2), /**< write-combine memory */ - TBM_BO_VENDOR = (0xffff0000), /**< vendor specific memory: it depends on the backend */ +enum TBM_BO_FLAGS { + TBM_BO_DEFAULT = 0, /**< default memory: it depends on the backend */ + TBM_BO_SCANOUT = (1 << 0), /**< scanout memory */ + TBM_BO_NONCACHABLE = (1 << 1), /**< non-cachable memory */ + TBM_BO_WC = (1 << 2), /**< write-combine memory */ + TBM_BO_VENDOR = (0xffff0000), /**< vendor specific memory: it depends on the backend */ }; - /** * @brief Enumeration for tbm error type. * @since_tizen 2.4 */ -typedef enum -{ - TBM_ERROR_NONE = 0, /**< Successful */ - TBM_BO_ERROR_GET_FD_FAILED = TBM_ERROR_BASE|0x0101, /**< failed to get fd failed */ - TBM_BO_ERROR_HEAP_ALLOC_FAILED = TBM_ERROR_BASE|0x0102, /**< failed to allocate the heap memory */ - TBM_BO_ERROR_LOAD_MODULE_FAILED = TBM_ERROR_BASE|0x0103, /**< failed to load module*/ - TBM_BO_ERROR_THREAD_INIT_FAILED = TBM_ERROR_BASE|0x0104, /**< failed to initialize the pthread */ - TBM_BO_ERROR_BO_ALLOC_FAILED = TBM_ERROR_BASE|0x0105, /**< failed to allocate tbm_bo */ - TBM_BO_ERROR_INIT_STATE_FAILED = TBM_ERROR_BASE|0x0106, /**< failed to initialize the state of tbm_bo */ - TBM_BO_ERROR_IMPORT_FAILED = TBM_ERROR_BASE|0x0107, /**< failed to import the handle of tbm_bo */ - TBM_BO_ERROR_IMPORT_FD_FAILED = TBM_ERROR_BASE|0x0108, /**< failed to import fd of tbm_bo */ - TBM_BO_ERROR_EXPORT_FAILED = TBM_ERROR_BASE|0x0109, /**< failed to export the handle of the tbm_bo */ - TBM_BO_ERROR_EXPORT_FD_FAILED = TBM_ERROR_BASE|0x01010, /**< failed to export fd of tbm_bo */ - TBM_BO_ERROR_GET_HANDLE_FAILED = TBM_ERROR_BASE|0x0111, /**< failed to get the tbm_bo_handle */ - TBM_BO_ERROR_LOCK_FAILED = TBM_ERROR_BASE|0x0112, /**< failed to lock the tbm_bo */ - TBM_BO_ERROR_MAP_FAILED = TBM_ERROR_BASE|0x0113, /**< failed to map the tbm_bo to get the tbm_bo_handle */ - TBM_BO_ERROR_UNMAP_FAILED = TBM_ERROR_BASE|0x0114, /**< failed to unmap the tbm_bo */ - TBM_BO_ERROR_SWAP_FAILED = TBM_ERROR_BASE|0x0115, /**< failed to swap the tbm_bos */ - TBM_BO_ERROR_DUP_FD_FAILED = TBM_ERROR_BASE|0x0116, /**< failed to duplicate fd */ +typedef enum { + TBM_ERROR_NONE = 0, /**< Successful */ + TBM_BO_ERROR_GET_FD_FAILED = TBM_ERROR_BASE | 0x0101, /**< failed to get fd failed */ + TBM_BO_ERROR_HEAP_ALLOC_FAILED = TBM_ERROR_BASE | 0x0102, /**< failed to allocate the heap memory */ + TBM_BO_ERROR_LOAD_MODULE_FAILED = TBM_ERROR_BASE | 0x0103,/**< failed to load module*/ + TBM_BO_ERROR_THREAD_INIT_FAILED = TBM_ERROR_BASE | 0x0104,/**< failed to initialize the pthread */ + TBM_BO_ERROR_BO_ALLOC_FAILED = TBM_ERROR_BASE | 0x0105, /**< failed to allocate tbm_bo */ + TBM_BO_ERROR_INIT_STATE_FAILED = TBM_ERROR_BASE | 0x0106, /**< failed to initialize the state of tbm_bo */ + TBM_BO_ERROR_IMPORT_FAILED = TBM_ERROR_BASE | 0x0107, /**< failed to import the handle of tbm_bo */ + TBM_BO_ERROR_IMPORT_FD_FAILED = TBM_ERROR_BASE | 0x0108, /**< failed to import fd of tbm_bo */ + TBM_BO_ERROR_EXPORT_FAILED = TBM_ERROR_BASE | 0x0109, /**< failed to export the handle of the tbm_bo */ + TBM_BO_ERROR_EXPORT_FD_FAILED = TBM_ERROR_BASE | 0x01010, /**< failed to export fd of tbm_bo */ + TBM_BO_ERROR_GET_HANDLE_FAILED = TBM_ERROR_BASE | 0x0111, /**< failed to get the tbm_bo_handle */ + TBM_BO_ERROR_LOCK_FAILED = TBM_ERROR_BASE | 0x0112, /**< failed to lock the tbm_bo */ + TBM_BO_ERROR_MAP_FAILED = TBM_ERROR_BASE | 0x0113, /**< failed to map the tbm_bo to get the tbm_bo_handle */ + TBM_BO_ERROR_UNMAP_FAILED = TBM_ERROR_BASE | 0x0114, /**< failed to unmap the tbm_bo */ + TBM_BO_ERROR_SWAP_FAILED = TBM_ERROR_BASE | 0x0115, /**< failed to swap the tbm_bos */ + TBM_BO_ERROR_DUP_FD_FAILED = TBM_ERROR_BASE | 0x0116, /**< failed to duplicate fd */ } tbm_error_e; +/** + * @brief Enumeration of tbm buffer manager capability. + * @since_tizen 2.4 + */ +enum TBM_BUFMGR_CAPABILITY { + TBM_BUFMGR_CAPABILITY_NONE = 0, /**< Not Support capability*/ + TBM_BUFMGR_CAPABILITY_SHARE_KEY = (1 << 0), /**< Support sharing buffer by tbm key */ + TBM_BUFMGR_CAPABILITY_SHARE_FD = (1 << 1), /**< Support sharing buffer by tbm fd */ + TBM_BUFMGR_CAPABILITY_TBM_SYNC = (1 << 2), /**< Support tbm sync */ +}; #ifdef __cplusplus extern "C" { @@ -207,7 +201,6 @@ extern "C" { #include int bufmgr_fd; - setenv("BUFMGR_LOCK_TYPE", "once", 1); setenv("BUFMGR_MAP_CACHE", "true", 1); @@ -219,7 +212,7 @@ extern "C" { tbm_bufmgr_deinit (bufmgr); @endcode */ -tbm_bufmgr tbm_bufmgr_init (int fd); +tbm_bufmgr tbm_bufmgr_init(int fd); /** * @brief Deinitializes the buffer manager. @@ -245,7 +238,7 @@ tbm_bufmgr tbm_bufmgr_init (int fd); tbm_bufmgr_deinit (bufmgr); @endcode */ -void tbm_bufmgr_deinit (tbm_bufmgr bufmgr); +void tbm_bufmgr_deinit(tbm_bufmgr bufmgr); /* Functions for bo */ @@ -286,7 +279,7 @@ void tbm_bufmgr_deinit (tbm_bufmgr bufmgr); tbm_bufmgr_deinit (bufmgr); @endcode */ -tbm_bo tbm_bo_alloc (tbm_bufmgr bufmgr, int size, int flags); +tbm_bo tbm_bo_alloc(tbm_bufmgr bufmgr, int size, int flags); /** * @brief Increases the reference count of bo. @@ -315,7 +308,7 @@ tbm_bo tbm_bo_alloc (tbm_bufmgr bufmgr, int size, int flags); tbm_bufmgr_deinit (bufmgr); @endcode */ -tbm_bo tbm_bo_ref (tbm_bo bo); +tbm_bo tbm_bo_ref(tbm_bo bo); /** * @brief Decreases the reference count of bo @@ -340,7 +333,7 @@ tbm_bo tbm_bo_ref (tbm_bo bo); tbm_bufmgr_deinit (bufmgr); @endcode */ -void tbm_bo_unref (tbm_bo bo); +void tbm_bo_unref(tbm_bo bo); /** * @brief Maps the buffer object according to the device type and the option. @@ -396,7 +389,7 @@ void tbm_bo_unref (tbm_bo bo); tbm_bufmgr_deinit (bufmgr); @endcode */ -tbm_bo_handle tbm_bo_map (tbm_bo bo, int device, int opt); +tbm_bo_handle tbm_bo_map(tbm_bo bo, int device, int opt); /** * @brief Unmaps the buffer object. @@ -427,7 +420,7 @@ tbm_bo_handle tbm_bo_map (tbm_bo bo, int device, int opt); tbm_bufmgr_deinit (bufmgr); @endcode */ -int tbm_bo_unmap (tbm_bo bo); +int tbm_bo_unmap(tbm_bo bo); /** * @brief Gets the tbm_bo_handle according to the device type. @@ -471,7 +464,7 @@ int tbm_bo_unmap (tbm_bo bo); tbm_bufmgr_deinit (bufmgr); @endcode */ -tbm_bo_handle tbm_bo_get_handle (tbm_bo bo, int device); +tbm_bo_handle tbm_bo_get_handle(tbm_bo bo, int device); /** * @brief Exports the buffer object by key. @@ -506,7 +499,7 @@ tbm_bo_handle tbm_bo_get_handle (tbm_bo bo, int device); tbm_bufmgr_deinit (bufmgr); @endcode */ -tbm_key tbm_bo_export (tbm_bo bo); +tbm_key tbm_bo_export(tbm_bo bo); /** * @brief Exports the buffer object by fd. @@ -542,7 +535,7 @@ tbm_key tbm_bo_export (tbm_bo bo); tbm_bufmgr_deinit (bufmgr); @endcode */ -tbm_fd tbm_bo_export_fd (tbm_bo bo); +tbm_fd tbm_bo_export_fd(tbm_bo bo); /** * @brief Imports the buffer object associated with the key. @@ -566,7 +559,7 @@ tbm_fd tbm_bo_export_fd (tbm_bo bo); ... bufmgr = tbm_bufmgr_init (bufmgr_fd); - bo = tbm_bo_import (key); + bo = tbm_bo_import (bufmgr, key); if (bo == NULL) { error = tbm_get_last_error (); @@ -579,7 +572,7 @@ tbm_fd tbm_bo_export_fd (tbm_bo bo); tbm_bufmgr_deinit (bufmgr); @endcode */ -tbm_bo tbm_bo_import (tbm_bufmgr bufmgr, tbm_key key); +tbm_bo tbm_bo_import(tbm_bufmgr bufmgr, tbm_key key); /** * @brief Imports the buffer object associated with the fd. @@ -587,7 +580,7 @@ tbm_bo tbm_bo_import (tbm_bufmgr bufmgr, tbm_key key); * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks You must release the fd using close(). * @param[in] bufmgr : the buffer manager - * @parak[in] fd : the fd associated with the buffer object + * @param[in] fd : the fd associated with the buffer object * @return a buffer object * @retval #tbm_bo * @see tbm_bo_export_fd() @@ -604,8 +597,8 @@ tbm_bo tbm_bo_import (tbm_bufmgr bufmgr, tbm_key key); ... bufmgr = tbm_bufmgr_init (bufmgr_fd); - bo_fd = tbm_bo_import_fd (bo_fd); - if (bo_fd == 0) + bo = tbm_bo_import_fd (bo_fd); + if (bo == 0) { error = tbm_get_last_error (); ... @@ -617,7 +610,7 @@ tbm_bo tbm_bo_import (tbm_bufmgr bufmgr, tbm_key key); tbm_bufmgr_deinit (bufmgr); @endcode */ -tbm_bo tbm_bo_import_fd (tbm_bufmgr bufmgr, tbm_fd fd); +tbm_bo tbm_bo_import_fd(tbm_bufmgr bufmgr, tbm_fd fd); /** * @brief Gets the size of a bo. @@ -644,7 +637,7 @@ tbm_bo tbm_bo_import_fd (tbm_bufmgr bufmgr, tbm_fd fd); tbm_bufmgr_deinit (bufmgr); @endcode */ -int tbm_bo_size (tbm_bo bo); +int tbm_bo_size(tbm_bo bo); /** * @brief Gets the state where the buffer object is locked. @@ -675,7 +668,7 @@ int tbm_bo_size (tbm_bo bo); tbm_bufmgr_deinit (bufmgr); @endcode */ -int tbm_bo_locked (tbm_bo bo); +int tbm_bo_locked(tbm_bo bo); /** * @brief Swaps the buffer object. @@ -714,8 +707,7 @@ int tbm_bo_locked (tbm_bo bo); tbm_bufmgr_deinit (bufmgr); @endcode */ -int tbm_bo_swap (tbm_bo bo1, tbm_bo bo2); - +int tbm_bo_swap(tbm_bo bo1, tbm_bo bo2); /** * @brief Called when the user data is deleted in buffer object. @@ -726,7 +718,7 @@ int tbm_bo_swap (tbm_bo bo1, tbm_bo bo2); * @see tbm_bo_add_user_data() * @see tbm_bo_delete_user_data() */ -typedef void (*tbm_data_free)(void *user_data); +typedef void (*tbm_data_free) (void *user_data); /** * @brief Adds a user_data to the buffer object. @@ -781,7 +773,8 @@ typedef void (*tbm_data_free)(void *user_data); @endcode */ -int tbm_bo_add_user_data (tbm_bo bo, unsigned long key, tbm_data_free data_free_func); +int tbm_bo_add_user_data(tbm_bo bo, unsigned long key, + tbm_data_free data_free_func); /** * @brief Deletes the user_data in the buffer object. @@ -832,7 +825,7 @@ int tbm_bo_add_user_data (tbm_bo bo, unsigned long key, tbm_data_free data_fr } @endcode */ -int tbm_bo_delete_user_data (tbm_bo bo, unsigned long key); +int tbm_bo_delete_user_data(tbm_bo bo, unsigned long key); /** * @brief Sets a user_date to the buffer object. @@ -884,7 +877,7 @@ int tbm_bo_delete_user_data (tbm_bo bo, unsigned long key); } @endcode */ -int tbm_bo_set_user_data (tbm_bo bo, unsigned long key, void* data); +int tbm_bo_set_user_data(tbm_bo bo, unsigned long key, void *data); /** * @brief Gets a user_data from the buffer object with the key. @@ -936,7 +929,7 @@ int tbm_bo_set_user_data (tbm_bo bo, unsigned long key, void* data); } @endcode */ -int tbm_bo_get_user_data (tbm_bo bo, unsigned long key, void** data); +int tbm_bo_get_user_data(tbm_bo bo, unsigned long key, void **data); /** * @brief Gets the latest tbm_error. @@ -976,11 +969,121 @@ int tbm_bo_get_user_data (tbm_bo bo, unsigned long key, void** data); tbm_bufmgr_deinit (bufmgr); @endcode */ -tbm_error_e tbm_get_last_error (void); +tbm_error_e tbm_get_last_error(void); + +/** + * @brief Gets the tbm buffer capability. + * @since_tizen 2.4 + * @param[in] bufmgr : the buffer manager + * @return the tbm bufmgr capability + * @par Example + @code + #include + + int bufmgr_fd; + tbm_bufmgr bufmgr; + unsigned int capability; + + bufmgr = tbm_bufmgr_init (bufmgr_fd); + + capability = tbm_bufmgr_get_capability (bufmgr); + + tbm_bufmgr_deinit (bufmgr); + @endcode + */ +unsigned int tbm_bufmgr_get_capability(tbm_bufmgr bufmgr); + +/** + * @brief Gets the tbm bo flags. + * @since_tizen 2.4 + * @param[in] bo : the buffer object + * @return the tbm bo flags + * @see TBM_BO_FLAGS + * @par Example + @code + #include + + int bufmgr_fd; + tbm_bufmgr bufmgr; + tbm_bo; + int flags; + + bufmgr = tbm_bufmgr_init (bufmgr_fd); + bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT); + flags = tbm_bo_get_flags (bo); + + ... + + tbm_bo_unref (bo); + tbm_bufmgr_deinit (bufmgr); + + @endcode + */ +int tbm_bo_get_flags(tbm_bo bo); + +/** + * @brief Print out the information of tbm_bos. + * @since_tizen 3.0 + * @param[in] bufmgr : the buffer manager + */ +void tbm_bufmgr_debug_show(tbm_bufmgr bufmgr); + +/** + * @brief Get string with the information of tbm_bos. + * @since_tizen 3.0 + * @param[in] bufmgr : the buffer manager + * @return sting with info if this function succeeds, otherwise NULL. It has to be free by user. + */ +char * tbm_bufmgr_debug_tbm_info_get(tbm_bufmgr bufmgr); + +/** + * @brief Print out the trace of tbm_bos. + * @since_tizen 3.0 + * @param[in] bufmgr : the buffer manager + * @param[in] onoff : 1 is on, and 0 is off + */ +void tbm_bufmgr_debug_trace(tbm_bufmgr bufmgr, int onoff); + +/** + * @brief Dump all tbm surfaces + * @param[in] path : the given dump path + * @return 1 if this function succeeds, otherwise 0. + */ +int tbm_bufmgr_debug_dump_all(char *path); + +/** + * @brief Start the dump debugging for queue. + * @since_tizen 3.0 + * @param[in] path : the given dump path + * @param[in] count : the dump count number + * @param[in] onoff : 1 is on, and 0 is off, if onoff==0 path and count are ignored + * @return 1 if this function succeeds, otherwise 0. + */ +int tbm_bufmgr_debug_queue_dump(char *path, int count, int onoff); + +/** + * @brief Set scale factor for the nearest calling tbm_bufmgr_debug_dump_all() or tbm_bufmgr_debug_queue_dump() + * @since_tizen 3.0 + * @param[in] scale : the scale factor, 0 - disable scaling + * @par Example + @code + #include + + // Dump all surface with scale factor 0.5 + tbm_bufmgr_debug_dump_set_scale(0.5); + tbm_bufmgr_debug_dump_all("/tmp/"); + + // Start the dump debugging for queue with scale factor 0.5 + tbm_bufmgr_debug_dump_set_scale(0.2); + tbm_bufmgr_debug_queue_dump("/tmp/", 10, 1); + + @endcode + */ +void tbm_bufmgr_debug_dump_set_scale(double scale); + +int tbm_bufmgr_bind_native_display(tbm_bufmgr bufmgr, void *NativeDisplay); #ifdef __cplusplus } #endif - -#endif /* _TBM_BUFMGR_H_ */ - +#endif /* _TBM_BUFMGR_H_ */