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_INT_H_
33 #define _TBM_BUFMGR_INT_H_
39 #include <sys/ioctl.h>
40 #include <sys/types.h>
48 #include <tbm_bufmgr.h>
49 #include <tbm_surface.h>
50 #include <tbm_bufmgr_backend.h>
53 #define TBM_RETURN_IF_FAIL(cond) {\
55 TBM_LOG ("[%s] : '%s' failed.\n", __FUNCTION__, #cond);\
59 #define TBM_RETURN_VAL_IF_FAIL(cond, val) {\
61 TBM_LOG ("[%s] : '%s' failed.\n", __FUNCTION__, #cond);\
67 #define RETURN_CHECK_FLAG(cond) {\
72 #define RETURN_VAL_CHECK_FLAG(cond, val) {\
79 /* check validation */
80 #define TBM_BUFMGR_IS_VALID(mgr) (mgr)
81 #define TBM_BO_IS_VALID(bo) (bo && \
82 TBM_BUFMGR_IS_VALID(bo->bufmgr) && \
83 bo->item_link.next && \
84 bo->item_link.next->prev == &bo->item_link)
85 #define TBM_SURFACE_IS_VALID(surf) (surf && \
86 TBM_BUFMGR_IS_VALID(surf->bufmgr) && \
87 surf->item_link.next && \
88 surf->item_link.next->prev == &surf->item_link)
90 #define TBM_ALL_CTRL_BACKEND_VALID(flags) \
91 ((flags&TBM_CACHE_CTRL_BACKEND) &&\
92 (flags&TBM_LOCK_CTRL_BACKEND))
93 #define TBM_CACHE_CTRL_BACKEND_VALID(flags) \
94 (flags&TBM_CACHE_CTRL_BACKEND)
95 #define TBM_LOCK_CTRL_BACKEND_VALID(flags) \
96 (flags&TBM_LOCK_CTRL_BACKEND)
98 #define TBM_LOG(...) fprintf (stderr, __VA_ARGS__)
100 typedef union _tbm_bo_cache_state tbm_bo_cache_state;
104 struct list_head *prev;
105 struct list_head *next;
108 union _tbm_bo_cache_state
112 unsigned int cntFlush:16; /*Flush all index for sync*/
113 unsigned int isCacheable:1;
114 unsigned int isCached:1;
115 unsigned int isDirtied:2;
120 * @brief tbm_bo : buffer object of Tizen Buffer Manager
124 tbm_bufmgr bufmgr; /* tbm buffer manager */
126 int ref_cnt; /* ref count of bo */
128 int flags; /* TBM_BO_FLAGS :bo memory type */
130 unsigned int tgl_key; /*global key for tizen global lock */
132 /* for cache control */
133 unsigned int map_cnt; /* device map count */
134 tbm_bo_cache_state cache_state; /*cache state */
136 int lock_cnt; /* lock count of bo */
138 struct list_head user_data_list; /* list of the user_date in bo */
140 void *priv; /* bo private */
142 struct list_head item_link; /* link of bo */
146 * @brief tbm_bufmgr : structure for tizen buffer manager
151 pthread_mutex_t lock; /* mutex lock */
153 int ref_count; /*reference count */
155 int fd; /* bufmgr fd */
157 int fd_flag; /* flag set 1 when bufmgr fd open in tbm_bufmgr_init*/
159 int lock_fd; /* fd of tizen global lock */
161 int lock_type; /* lock_type of bufmgr */
163 int use_map_cache; /* flag to use the map_cahce */
165 struct list_head bo_list; /* list of bos belonging to bufmgr */
167 struct list_head surf_list; /* list of surfaces belonging to bufmgr */
171 tbm_bufmgr_backend backend; /* bufmgr backend */
175 * @brief tbm_surface : structure for tizen buffer surface
178 struct _tbm_surface {
179 tbm_bufmgr bufmgr; /* tbm buffer manager */
181 tbm_surface_info_s info; /* tbm surface information */
185 int num_bos; /* the number of buffer objects */
186 tbm_bo bos[4]; /* the array of buffer objects */
188 struct list_head item_link; /* link of surface */
191 int tbm_bufmgr_get_drm_fd_x11(void);
192 int tbm_bufmgr_get_drm_fd_wayland(void);
194 #endif /* _TBM_BUFMGR_INT_H_ */