1 /**************************************************************************
5 Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
7 Contact: Eunchul Kim <chulspro.kim@samsung.com>,
8 JinYoung Jeon <jy0.jeon@samsung.com>,
9 Taeheon Kim <th908.kim@samsung.com>,
10 YoungJun Cho <yj44.cho@samsung.com>,
11 SooChan Lim <sc1.lim@samsung.com>,
12 Boram Park <sc1.lim@samsung.com>
14 Permission is hereby granted, free of charge, to any person obtaining a
15 copy of this software and associated documentation files (the
16 "Software"), to deal in the Software without restriction, including
17 without limitation the rights to use, copy, modify, merge, publish,
18 distribute, sub license, and/or sell copies of the Software, and to
19 permit persons to whom the Software is furnished to do so, subject to
20 the following conditions:
22 The above copyright notice and this permission notice (including the
23 next paragraph) shall be included in all copies or substantial portions
26 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
27 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
29 IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
30 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
31 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
32 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 **************************************************************************/
36 #ifndef _TDM_PRIVATE_H_
37 #define _TDM_PRIVATE_H_
46 #include <sys/types.h>
52 #include <tbm_bufmgr.h>
53 #include <tbm_surface_queue.h>
55 #include "tdm_backend.h"
65 * @brief The private header file for a frontend library
68 extern int tdm_debug_buffer;
69 extern int tdm_debug_mutex;
75 #if defined(__GNUC__) && __GNUC__ >= 4
76 #define EXTERN __attribute__ ((visibility("default")))
81 #if defined(__GNUC__) && __GNUC__ >= 4
82 #define INTERN __attribute__ ((visibility("hidden")))
87 #if defined(__GNUC__) && __GNUC__ >= 4
88 #define DEPRECATED __attribute__ ((deprecated))
94 #define TDM_RETURN_IF_FAIL(cond) {\
96 TDM_ERR ("'%s' failed", #cond);\
100 #define TDM_RETURN_VAL_IF_FAIL(cond, val) {\
102 TDM_ERR ("'%s' failed", #cond);\
106 #define TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(cond, error_v, val) {\
108 TDM_ERR ("'%s' failed", #cond);\
110 if (error) *error = ret;\
115 #define TDM_WARNING_IF_FAIL(cond) {\
117 TDM_ERR ("'%s' failed", #cond);\
119 #define TDM_GOTO_IF_FAIL(cond, dst) {\
121 TDM_ERR ("'%s' failed", #cond);\
128 #define TDM_TRACE_BEGIN(NAME) traceBegin(TTRACE_TAG_GRAPHICS, "TDM:"#NAME)
129 #define TDM_TRACE_END() traceEnd(TTRACE_TAG_GRAPHICS)
131 #define TDM_TRACE_BEGIN(NAME)
132 #define TDM_TRACE_END()
135 #define TDM_NEVER_GET_HERE() TDM_ERR("** NEVER GET HERE **")
137 #define TDM_SNPRINTF(p, len, fmt, ARG...) \
139 if (p && len && *len > 0) \
141 int s = snprintf(p, *len, fmt, ##ARG); \
147 #define C(b,m) (((b) >> (m)) & 0xFF)
148 #define B(c,s) ((((unsigned int)(c)) & 0xff) << (s))
149 #define FOURCC(a,b,c,d) (B(d,24) | B(c,16) | B(b,8) | B(a,0))
150 #define FOURCC_STR(id) C(id,0), C(id,8), C(id,16), C(id,24)
151 #define FOURCC_ID(str) FOURCC(((char*)str)[0],((char*)str)[1],((char*)str)[2],((char*)str)[3])
154 TDM_CAPTURE_TARGET_OUTPUT,
155 TDM_CAPTURE_TARGET_LAYER,
156 } tdm_capture_target;
158 typedef struct _tdm_private_display tdm_private_display;
159 typedef struct _tdm_private_output tdm_private_output;
160 typedef struct _tdm_private_layer tdm_private_layer;
161 typedef struct _tdm_private_pp tdm_private_pp;
162 typedef struct _tdm_private_capture tdm_private_capture;
163 typedef struct _tdm_private_event tdm_private_event;
164 typedef struct _tdm_private_vblank_handler tdm_private_vblank_handler;
165 typedef struct _tdm_private_commit_handler tdm_private_commit_handler;
166 typedef struct _tdm_private_change_handler tdm_private_change_handler;
168 struct _tdm_private_display {
169 pthread_mutex_t lock;
170 unsigned int init_count;
172 /* backend module info */
174 tdm_backend_module *module_data;
175 tdm_backend_data *bdata;
177 /* backend function */
178 tdm_display_capability capabilities;
179 tdm_func_display func_display;
180 tdm_func_output func_output;
181 tdm_func_layer func_layer;
183 tdm_func_capture func_capture;
185 /* backend capability */
186 tdm_caps_display caps_display;
188 tdm_caps_capture caps_capture;
190 /* output, pp list */
191 struct list_head output_list;
192 struct list_head pp_list;
196 /* for event handling */
197 tdm_private_event *private_event;
200 struct _tdm_private_output {
201 struct list_head link;
203 tdm_private_display *private_display;
205 tdm_caps_output caps;
206 tdm_output *output_backend;
210 int regist_vblank_cb;
211 int regist_commit_cb;
212 int regist_change_cb;
214 struct list_head layer_list;
215 struct list_head capture_list;
216 struct list_head vblank_handler_list;
217 struct list_head commit_handler_list;
218 struct list_head change_handler_list;
223 struct _tdm_private_layer {
224 struct list_head link;
226 tdm_private_display *private_display;
227 tdm_private_output *private_output;
230 tdm_layer *layer_backend;
232 tbm_surface_h pending_buffer;
233 tbm_surface_h waiting_buffer;
234 tbm_surface_h showing_buffer;
235 tbm_surface_queue_h buffer_queue;
237 struct list_head capture_list;
242 struct _tdm_private_pp {
243 struct list_head link;
245 tdm_private_display *private_display;
249 struct list_head src_pending_buffer_list;
250 struct list_head dst_pending_buffer_list;
251 struct list_head src_buffer_list;
252 struct list_head dst_buffer_list;
255 struct _tdm_private_capture {
256 struct list_head link;
258 tdm_capture_target target;
260 tdm_private_display *private_display;
261 tdm_private_output *private_output;
262 tdm_private_layer *private_layer;
264 tdm_capture *capture_backend;
266 struct list_head pending_buffer_list;
267 struct list_head buffer_list;
270 struct _tdm_private_vblank_handler {
271 struct list_head link;
273 tdm_private_output *private_output;
274 tdm_output_vblank_handler func;
278 struct _tdm_private_commit_handler {
279 struct list_head link;
281 tdm_private_output *private_output;
282 tdm_output_commit_handler func;
286 struct _tdm_private_change_handler {
287 struct list_head link;
289 tdm_private_output *private_output;
290 tdm_output_change_handler func;
294 typedef struct _tdm_buffer_info {
295 tbm_surface_h buffer;
297 /* ref_count for backend */
298 int backend_ref_count;
300 struct list_head release_funcs;
301 struct list_head destroy_funcs;
303 struct list_head *list;
304 struct list_head link;
308 tdm_output_call_change_handler_internal(tdm_private_output *private_output,
309 tdm_output_change_type type,
313 tdm_pp_create_internal(tdm_private_display *private_display, tdm_error *error);
315 tdm_pp_destroy_internal(tdm_private_pp *private_pp);
317 tdm_private_capture *
318 tdm_capture_create_output_internal(tdm_private_output *private_output,
320 tdm_private_capture *
321 tdm_capture_create_layer_internal(tdm_private_layer *private_layer,
324 tdm_capture_destroy_internal(tdm_private_capture *private_capture);
326 /* utility buffer functions for private */
328 tdm_buffer_get_info(tbm_surface_h buffer);
330 tdm_buffer_list_get_first_entry(struct list_head *list);
332 tdm_buffer_list_dump(struct list_head *list);
334 /* event functions for private */
336 tdm_event_init(tdm_private_display *private_display);
338 tdm_event_deinit(tdm_private_display *private_display);
340 tdm_event_create_main_source(tdm_private_display *private_display);
342 tdm_event_get_fd(tdm_private_display *private_display);
344 tdm_event_dispatch(tdm_private_display *private_display);
346 tdm_event_add_socket(tdm_private_display *private_display, const char *name);
349 #define _pthread_mutex_lock(l) \
350 do {if (tdm_debug_mutex) TDM_INFO("mutex lock"); pthread_mutex_lock(l);} while (0)
351 #define _pthread_mutex_unlock(l) \
352 do {if (tdm_debug_mutex) TDM_INFO("mutex unlock"); pthread_mutex_unlock(l);} while (0)
358 #endif /* _TDM_PRIVATE_H_ */