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 "tdm_backend.h"
64 #if defined(__GNUC__) && __GNUC__ >= 4
65 #define EXTERN __attribute__ ((visibility("default")))
70 #if defined(__GNUC__) && __GNUC__ >= 4
71 #define INTERN __attribute__ ((visibility("hidden")))
76 #if defined(__GNUC__) && __GNUC__ >= 4
77 #define DEPRECATED __attribute__ ((deprecated))
83 #define TDM_RETURN_IF_FAIL(cond) {\
85 TDM_ERR ("'%s' failed", #cond);\
89 #define TDM_RETURN_VAL_IF_FAIL(cond, val) {\
91 TDM_ERR ("'%s' failed", #cond);\
95 #define TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(cond, error_v, val) {\
97 TDM_ERR ("'%s' failed", #cond);\
99 if (error) *error = ret;\
104 #define TDM_WARNING_IF_FAIL(cond) {\
106 TDM_ERR ("'%s' failed", #cond);\
108 #define TDM_GOTO_IF_FAIL(cond, dst) {\
110 TDM_ERR ("'%s' failed", #cond);\
115 #define TDM_NEVER_GET_HERE() TDM_ERR("** NEVER GET HERE **")
117 #define TDM_SNPRINTF(p, len, fmt, ARG...) \
119 if (p && len && *len > 0) \
121 int s = snprintf(p, *len, fmt, ##ARG); \
127 #define C(b,m) (((b) >> (m)) & 0xFF)
128 #define B(c,s) ((((unsigned int)(c)) & 0xff) << (s))
129 #define FOURCC(a,b,c,d) (B(d,24) | B(c,16) | B(b,8) | B(a,0))
130 #define FOURCC_STR(id) C(id,0), C(id,8), C(id,16), C(id,24)
131 #define FOURCC_ID(str) FOURCC(((char*)str)[0],((char*)str)[1],((char*)str)[2],((char*)str)[3])
135 TDM_CAPTURE_TARGET_OUTPUT,
136 TDM_CAPTURE_TARGET_LAYER,
137 } tdm_capture_target;
139 typedef struct _tdm_private_display tdm_private_display;
140 typedef struct _tdm_private_output tdm_private_output;
141 typedef struct _tdm_private_layer tdm_private_layer;
142 typedef struct _tdm_private_pp tdm_private_pp;
143 typedef struct _tdm_private_capture tdm_private_capture;
144 typedef struct _tdm_private_vblank_handler tdm_private_vblank_handler;
145 typedef struct _tdm_private_commit_handler tdm_private_commit_handler;
147 struct _tdm_private_display
149 pthread_mutex_t lock;
150 unsigned int init_count;
152 /* backend module info */
154 tdm_backend_module *module_data;
155 tdm_backend_data *bdata;
157 /* backend function */
158 tdm_display_capability capabilities;
159 tdm_func_display func_display;
161 tdm_func_capture func_capture;
163 /* backend capability */
164 tdm_caps_display caps_display;
166 tdm_caps_capture caps_capture;
168 /* output, pp list */
169 struct list_head output_list;
170 struct list_head pp_list;
175 struct _tdm_private_output
177 struct list_head link;
179 tdm_func_display *func_display;
180 tdm_private_display *private_display;
182 tdm_caps_output caps;
183 tdm_output *output_backend;
187 int regist_vblank_cb;
188 int regist_commit_cb;
190 struct list_head layer_list;
191 struct list_head capture_list;
192 struct list_head vblank_handler_list;
193 struct list_head commit_handler_list;
198 struct _tdm_private_layer
200 struct list_head link;
202 tdm_func_display *func_display;
203 tdm_private_display *private_display;
204 tdm_private_output *private_output;
207 tdm_layer *layer_backend;
209 tdm_buffer *waiting_buffer;
210 tdm_buffer *showing_buffer;
212 struct list_head capture_list;
217 struct _tdm_private_pp
219 struct list_head link;
221 tdm_func_pp *func_pp;
222 tdm_private_display *private_display;
227 struct _tdm_private_capture
229 struct list_head link;
231 tdm_capture_target target;
233 tdm_func_capture *func_capture;
234 tdm_private_display *private_display;
235 tdm_private_output *private_output;
236 tdm_private_layer *private_layer;
238 tdm_capture *capture_backend;
241 struct _tdm_private_vblank_handler
243 struct list_head link;
245 tdm_private_output *private_output;
246 tdm_output_vblank_handler func;
250 struct _tdm_private_commit_handler
252 struct list_head link;
254 tdm_private_output *private_output;
255 tdm_output_commit_handler func;
259 tdm_buffer* tdm_buffer_ref_backend(tdm_buffer *buffer);
260 void tdm_buffer_unref_backend(tdm_buffer *buffer);
261 tbm_surface_h tdm_buffer_get_surface(tdm_buffer *buffer);
262 tdm_buffer* tdm_buffer_get(tbm_surface_h buffer);
264 tdm_private_pp* tdm_pp_create_internal(tdm_private_display *private_display, tdm_error *error);
265 void tdm_pp_destroy_internal(tdm_private_pp *private_pp);
267 tdm_private_capture* tdm_capture_create_output_internal(tdm_private_output *private_output, tdm_error *error);
268 tdm_private_capture* tdm_capture_create_layer_internal(tdm_private_layer *private_layer, tdm_error *error);
269 void tdm_capture_destroy_internal(tdm_private_capture *private_capture);
275 #endif /* _TDM_PRIVATE_H_ */