1 /**************************************************************************
5 Copyright 2012 - 2016 Samsung Electronics co., Ltd. All Rights Reserved.
7 Contact: SooChan Lim <sc1.lim@samsung.com>,
8 Changyeon Lee <cyeon.lee@samsung.com>,
9 Boram Park <boram1288.park@samsung.com>,
10 Sangjin Lee <lsj119@samsung.com>
12 Permission is hereby granted, free of charge, to any person obtaining a
13 copy of this software and associated documentation files (the
14 "Software"), to deal in the Software without restriction, including
15 without limitation the rights to use, copy, modify, merge, publish,
16 distribute, sub license, and/or sell copies of the Software, and to
17 permit persons to whom the Software is furnished to do so, subject to
18 the following conditions:
20 The above copyright notice and this permission notice (including the
21 next paragraph) shall be included in all copies or substantial portions
24 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
27 IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
28 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
29 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
30 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 **************************************************************************/
34 #include "tbm_bufmgr.h"
35 #include "tbm_bufmgr_int.h"
38 static pthread_mutex_t tbm_sync_lock;
39 static int tbm_sync_support = 0;
42 _tbm_sync_mutex_init(void)
44 static bool tbm_sync_mutex_init = false;
46 if (tbm_sync_mutex_init)
49 if (pthread_mutex_init(&tbm_sync_lock, NULL)) {
50 TBM_LOG_E("fail: tbm_sync mutex init\n");
54 tbm_sync_mutex_init = true;
60 _tbm_sync_mutex_lock(void)
62 if (!_tbm_sync_mutex_init())
65 pthread_mutex_lock(&tbm_sync_lock);
69 _tbm_sync_mutex_unlock(void)
71 pthread_mutex_unlock(&tbm_sync_lock);
74 static tbm_sync_error_e
75 _tbm_sync_check_capability(void)
77 tbm_bufmgr bufmgr = NULL;
78 unsigned int capabilities = TBM_BUFMGR_CAPABILITY_NONE;
81 return TBM_SYNC_ERROR_NONE;
83 /* check the bufmgr */
84 bufmgr = _tbm_bufmgr_get_bufmgr();
86 return TBM_SYNC_ERROR_INVALID_OPERATION;
89 /* check the tbm_sync capability */
90 capabilities = tbm_bufmgr_get_capability(bufmgr);
91 if ((capabilities&TBM_BUFMGR_CAPABILITY_TBM_SYNC) != TBM_BUFMGR_CAPABILITY_TBM_SYNC) {
92 //TODO: check the sw_sync device node... to verify the timeline sync
95 return TBM_SYNC_ERROR_INVALID_OPERATION;
98 return TBM_SYNC_ERROR_NONE;
102 tbm_sync_timeline_create(tbm_sync_error_e *error)
104 tbm_sync_error_e ret = TBM_SYNC_ERROR_NONE;
105 tbm_sync_timeline_h timeline = NULL;
107 _tbm_sync_mutex_lock();
109 /* check the tbm_sync capability */
110 ret = _tbm_sync_check_capability();;
111 if (ret != TBM_SYNC_ERROR_NONE)
114 /* TODO: sync_timeline_create */
121 _tbm_sync_mutex_unlock();
127 tbm_sync_timeline_destroy(tbm_sync_timeline_h timeline)
129 tbm_sync_error_e ret = TBM_SYNC_ERROR_NONE;
131 _tbm_sync_mutex_lock();
133 /* check the tbm_sync capability */
134 ret = _tbm_sync_check_capability();;
135 if (ret != TBM_SYNC_ERROR_NONE)
138 /* TODO: sync_timeline_destroy */
142 _tbm_sync_mutex_unlock();
148 tbm_sync_timeline_import(tbm_fd fd, tbm_sync_error_e *error)
150 tbm_sync_error_e ret = TBM_SYNC_ERROR_NONE;
151 tbm_sync_timeline_h timeline = NULL;
153 _tbm_sync_mutex_lock();
155 /* check the tbm_sync capability */
156 ret = _tbm_sync_check_capability();;
157 if (ret != TBM_SYNC_ERROR_NONE)
160 /* TODO: sync_timeline_import */
166 _tbm_sync_mutex_unlock();
172 tbm_sync_timeline_increase_count(tbm_sync_timeline_h timeline, unsigned int interval)
174 tbm_sync_error_e ret = TBM_SYNC_ERROR_NONE;
176 _tbm_sync_mutex_lock();
178 /* check the tbm_sync capability */
179 ret = _tbm_sync_check_capability();;
180 if (ret != TBM_SYNC_ERROR_NONE)
183 /* TODO: sync_timeline_increase_count */
186 _tbm_sync_mutex_unlock();
192 tbm_sync_timeline_get_cur_count(tbm_sync_timeline_h timeline, tbm_sync_error_e *error)
194 tbm_sync_error_e ret = TBM_SYNC_ERROR_NONE;
195 unsigned int cur_count = 0;
197 _tbm_sync_mutex_lock();
199 /* check the tbm_sync capability */
200 ret = _tbm_sync_check_capability();;
201 if (ret != TBM_SYNC_ERROR_NONE)
204 /* TODO: sync_timeline_get_cur_count */
210 _tbm_sync_mutex_unlock();
216 tbm_sync_fence_create(tbm_sync_timeline_h timeline, const char *name, unsigned int count_val, tbm_sync_error_e *error)
218 tbm_sync_error_e ret = TBM_SYNC_ERROR_NONE;
219 tbm_sync_fence_h fence = NULL;
221 _tbm_sync_mutex_lock();
223 /* check the tbm_sync capability */
224 ret = _tbm_sync_check_capability();;
225 if (ret != TBM_SYNC_ERROR_NONE)
228 /* TODO: sync_fence_create */
234 _tbm_sync_mutex_unlock();
240 tbm_sync_fence_destroy(tbm_sync_fence_h fence)
242 tbm_sync_error_e ret = TBM_SYNC_ERROR_NONE;
244 _tbm_sync_mutex_lock();
246 /* check the tbm_sync capability */
247 ret = _tbm_sync_check_capability();;
248 if (ret != TBM_SYNC_ERROR_NONE)
251 /* TODO: sync_fence_destroy */
254 _tbm_sync_mutex_unlock();
260 tbm_sync_fence_wait(tbm_sync_fence_h fence, int timeout)
262 tbm_sync_error_e ret = TBM_SYNC_ERROR_NONE;
264 _tbm_sync_mutex_lock();
266 /* check the tbm_sync capability */
267 ret = _tbm_sync_check_capability();;
268 if (ret != TBM_SYNC_ERROR_NONE)
271 /* TODO: sync_fence_wait */
274 _tbm_sync_mutex_unlock();
280 tbm_sync_fence_merge(tbm_sync_fence_h fence1, tbm_sync_fence_h fence2, const char *name, tbm_sync_error_e *error)
282 tbm_sync_error_e ret = TBM_SYNC_ERROR_NONE;
283 tbm_sync_fence_h fence = NULL;
285 _tbm_sync_mutex_lock();
287 /* check the tbm_sync capability */
288 ret = _tbm_sync_check_capability();;
289 if (ret != TBM_SYNC_ERROR_NONE)
292 /* TODO: tbm_sync_fence_merge */
298 _tbm_sync_mutex_unlock();
304 tbm_sync_fence_get_count_val(tbm_sync_fence_h fence, tbm_sync_error_e *error)
306 tbm_sync_error_e ret = TBM_SYNC_ERROR_NONE;
307 unsigned int count_val = 0;
309 _tbm_sync_mutex_lock();
311 /* check the tbm_sync capability */
312 ret = _tbm_sync_check_capability();;
313 if (ret != TBM_SYNC_ERROR_NONE)
316 /* TODO: sync_fence_get_count_val */
322 _tbm_sync_mutex_unlock();