050dad84ab6f67e1db66f47b2c56952c820f44b8
[platform/core/uifw/libtdm.git] / include / tdm_types.h
1 /**************************************************************************
2  *
3  * libtdm
4  *
5  * Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
6  *
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>
13  *
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:
21  *
22  * The above copyright notice and this permission notice (including the
23  * next paragraph) shall be included in all copies or substantial portions
24  * of the Software.
25  *
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.
33  *
34 **************************************************************************/
35
36 #ifndef _TDM_TYPES_H_
37 #define _TDM_TYPES_H_
38
39 #include <tbm_surface.h>
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
45 /**
46  * @file tdm_types.h
47  * @brief The header file which defines Enumerations and Structures for frontend and backend.
48  * @details
49  * Both frontend(@ref tdm.h) and backend(@ref tdm_backend.h) header files
50  * include @ref tdm_types.h
51  * @par Example
52  * @code
53  * #include <tdm.h>    //for a frontend user
54  * @endcode
55  * @code
56  * #include <tdm_backend.h>  //for a vendor to implement a backend module
57  * @endcode
58  */
59
60 #include <tdm_common.h>
61
62 /**
63  * @brief The transform enumeration(rotate, flip)
64  */
65 typedef enum {
66         TDM_TRANSFORM_NORMAL            = 0, /**< no transform */
67         TDM_TRANSFORM_90                = 1, /**< rotate 90 */
68         TDM_TRANSFORM_180               = 2, /**< rotate 180 */
69         TDM_TRANSFORM_270               = 3, /**< rotate 270 */
70         TDM_TRANSFORM_FLIPPED           = 4, /**< no rotate and horizontal flip */
71         TDM_TRANSFORM_FLIPPED_90        = 5, /**< rotate 90 and horizontal flip */
72         TDM_TRANSFORM_FLIPPED_180       = 6, /**< rotate 180 and horizontal flip */
73         TDM_TRANSFORM_FLIPPED_270       = 7, /**< rotate 270 and horizontal flip */
74 } tdm_transform;
75
76 /**
77  * @brief The output connection status enumeration
78  * @details bit compatible with the libdrm definitions.
79  */
80 typedef enum {
81         TDM_OUTPUT_TYPE_Unknown,        /**< unknown */
82         TDM_OUTPUT_TYPE_VGA,            /**< VGA connection */
83         TDM_OUTPUT_TYPE_DVII,           /**< DVII connection */
84         TDM_OUTPUT_TYPE_DVID,           /**< DVID connection */
85         TDM_OUTPUT_TYPE_DVIA,           /**< DVIA connection */
86         TDM_OUTPUT_TYPE_Composite,      /**< Composite connection */
87         TDM_OUTPUT_TYPE_SVIDEO,         /**< SVIDEO connection */
88         TDM_OUTPUT_TYPE_LVDS,           /**< LVDS connection */
89         TDM_OUTPUT_TYPE_Component,      /**< Component connection */
90         TDM_OUTPUT_TYPE_9PinDIN,        /**< 9PinDIN connection */
91         TDM_OUTPUT_TYPE_DisplayPort,    /**< DisplayPort connection */
92         TDM_OUTPUT_TYPE_HDMIA,          /**< HDMIA connection */
93         TDM_OUTPUT_TYPE_HDMIB,          /**< HDMIB connection */
94         TDM_OUTPUT_TYPE_TV,             /**< TV connection */
95         TDM_OUTPUT_TYPE_eDP,            /**< eDP connection */
96         TDM_OUTPUT_TYPE_VIRTUAL,        /**< Virtual connection for WiFi Display */
97         TDM_OUTPUT_TYPE_DSI,            /**< DSI connection */
98 } tdm_output_type;
99
100 /**
101  * @brief The layer capability enumeration
102  * @details
103  * A layer can have one of CURSOR, PRIMARY and OVERLAY capability. And a layer
104  * also can have one of GRAPHIC and VIDEO capability. And a layer also can have
105  * SCALE and TRANSFORM capability.\n
106  * @par Example
107  * @code
108  *  //For example
109  *  capabilities = TDM_LAYER_CAPABILITY_PRIMARY | TDM_LAYER_CAPABILITY_GRAPHIC;
110  *  capabilities = TDM_LAYER_CAPABILITY_OVERLAY | TDM_LAYER_CAPABILITY_GRAPHIC | TDM_LAYER_CAPABILITY_SCALE;
111  *  capabilities = TDM_LAYER_CAPABILITY_OVERLAY | TDM_LAYER_CAPABILITY_GRAPHIC | TDM_LAYER_CAPABILITY_SCALE | TDM_LAYER_CAPABILITY_TRANSFORM;
112  *  capabilities = TDM_LAYER_CAPABILITY_CURSOR | TDM_LAYER_CAPABILITY_GRAPHIC;
113  *  capabilities = TDM_LAYER_CAPABILITY_OVERLAY | TDM_LAYER_CAPABILITY_VIDEO;
114  * @endcode
115  * @remark
116  * - When a video plays, in most of cases, video buffers will be displayed to
117  * a GRAPHIC layer after converting RGB buffers via PP. In this case, a backend
118  * module doesn't need to offer VIDEO layer.
119  * - But in case that s vendor wants to handle a video by their own way,
120  * a backend module offer VIDEO layers. And a display server will pass a video
121  * buffer to a VIDEO layer without converting.
122  */
123 typedef enum {
124         TDM_LAYER_CAPABILITY_CURSOR         = (1 << 0), /**< cursor */
125         TDM_LAYER_CAPABILITY_PRIMARY        = (1 << 1), /**< primary */
126         TDM_LAYER_CAPABILITY_OVERLAY        = (1 << 2), /**< overlay */
127         TDM_LAYER_CAPABILITY_GRAPHIC        = (1 << 4), /**< graphic */
128         TDM_LAYER_CAPABILITY_VIDEO          = (1 << 5), /**< video */
129         TDM_LAYER_CAPABILITY_SCALE          = (1 << 8), /**< if a layer has scale capability  */
130         TDM_LAYER_CAPABILITY_TRANSFORM      = (1 << 9), /**< if a layer has transform capability  */
131         TDM_LAYER_CAPABILITY_SCANOUT        = (1 << 10), /**< if a layer allows a scanout buffer only */
132         TDM_LAYER_CAPABILITY_RESEVED_MEMORY = (1 << 11), /**< if a layer allows a reserved buffer only */
133         TDM_LAYER_CAPABILITY_NO_CROP        = (1 << 12), /**< if a layer has no cropping capability */
134 } tdm_layer_capability;
135
136 /**
137  * @brief The pp capability enumeration
138  */
139 typedef enum {
140         TDM_PP_CAPABILITY_SYNC           = (1 << 0), /**< The pp device supports synchronous operation */
141         TDM_PP_CAPABILITY_ASYNC          = (1 << 1), /**< The pp device supports asynchronous operation */
142         TDM_PP_CAPABILITY_SCALE          = (1 << 4), /**< The pp device supports scale operation */
143         TDM_PP_CAPABILITY_TRANSFORM      = (1 << 5), /**< The pp device supports transform operation */
144 } tdm_pp_capability;
145
146 /**
147  * @brief The capture capability enumeration
148  */
149 typedef enum {
150         TDM_CAPTURE_CAPABILITY_OUTPUT    = (1 << 0), /**< The capture device supports to dump a output */
151         TDM_CAPTURE_CAPABILITY_LAYER     = (1 << 1), /**< The capture device supports to dump a layer */
152         TDM_CAPTURE_CAPABILITY_SCALE     = (1 << 4), /**< The capture device supports scale operation */
153         TDM_CAPTURE_CAPABILITY_TRANSFORM = (1 << 5), /**< The capture device supports transform operation */
154 } tdm_capture_capability;
155
156 /**
157  * @brief The output mode type enumeration
158  * @details bit compatible with the libdrm definitions.
159  */
160 typedef enum {
161         TDM_OUTPUT_MODE_TYPE_BUILTIN    = (1 << 0),
162         TDM_OUTPUT_MODE_TYPE_CLOCK_C    = ((1 << 1) | TDM_OUTPUT_MODE_TYPE_BUILTIN),
163         TDM_OUTPUT_MODE_TYPE_CRTC_C     = ((1 << 2) | TDM_OUTPUT_MODE_TYPE_BUILTIN),
164         TDM_OUTPUT_MODE_TYPE_PREFERRED  = (1 << 3),
165         TDM_OUTPUT_MODE_TYPE_DEFAULT    = (1 << 4),
166         TDM_OUTPUT_MODE_TYPE_USERDEF    = (1 << 5),
167         TDM_OUTPUT_MODE_TYPE_DRIVER     = (1 << 6),
168 } tdm_output_mode_type;
169
170 /**
171  * @brief The output mode flag enumeration
172  * @details bit compatible with the libdrm definitions.
173  */
174 typedef enum {
175         TDM_OUTPUT_MODE_FLAG_PHSYNC     = (1 << 0),
176         TDM_OUTPUT_MODE_FLAG_NHSYNC     = (1 << 1),
177         TDM_OUTPUT_MODE_FLAG_PVSYNC     = (1 << 2),
178         TDM_OUTPUT_MODE_FLAG_NVSYNC     = (1 << 3),
179         TDM_OUTPUT_MODE_FLAG_INTERLACE  = (1 << 4),
180         TDM_OUTPUT_MODE_FLAG_DBLSCAN    = (1 << 5),
181         TDM_OUTPUT_MODE_FLAG_CSYNC      = (1 << 6),
182         TDM_OUTPUT_MODE_FLAG_PCSYNC     = (1 << 7),
183         TDM_OUTPUT_MODE_FLAG_NCSYNC     = (1 << 8),
184         TDM_OUTPUT_MODE_FLAG_HSKEW      = (1 << 9), /* hskew provided */
185         TDM_OUTPUT_MODE_FLAG_BCAST      = (1 << 10),
186         TDM_OUTPUT_MODE_FLAG_PIXMUX     = (1 << 11),
187         TDM_OUTPUT_MODE_FLAG_DBLCLK     = (1 << 12),
188         TDM_OUTPUT_MODE_FLAG_CLKDIV2    = (1 << 13),
189 } tdm_output_mode_flag;
190
191 typedef enum {
192         TDM_EVENT_LOOP_READABLE = (1 << 0),
193         TDM_EVENT_LOOP_WRITABLE = (1 << 1),
194         TDM_EVENT_LOOP_HANGUP   = (1 << 2),
195         TDM_EVENT_LOOP_ERROR    = (1 << 3),
196 } tdm_event_loop_mask;
197
198 /**
199  * @brief The output mode structure
200  */
201 typedef struct _tdm_output_mode {
202         unsigned int clock;
203         unsigned int hdisplay, hsync_start, hsync_end, htotal, hskew;
204         unsigned int vdisplay, vsync_start, vsync_end, vtotal, vscan;
205         unsigned int vrefresh;
206         unsigned int flags;
207         unsigned int type;
208         char name[TDM_NAME_LEN];
209 } tdm_output_mode;
210
211 /**
212  * @brief The property structure
213  */
214 typedef struct _tdm_prop {
215         unsigned int id;
216         char name[TDM_NAME_LEN];
217 } tdm_prop;
218
219 /**
220  * @brief The info config structure
221  */
222 typedef struct _tdm_info_config {
223         tdm_size size;
224         tdm_pos pos;
225         tbm_format format;
226 } tdm_info_config;
227
228 /**
229  * @brief The layer info structre
230  */
231 typedef struct _tdm_info_layer {
232         tdm_info_config src_config;
233         tdm_pos dst_pos;
234         tdm_transform transform;
235 } tdm_info_layer;
236
237 /**
238  * @brief The pp info structre
239  */
240 typedef struct _tdm_info_pp {
241         tdm_info_config src_config;
242         tdm_info_config dst_config;
243         tdm_transform transform;
244         int sync;
245         int flags;
246 } tdm_info_pp;
247
248 /**
249  * @brief The capture info structre
250  */
251 typedef struct _tdm_info_capture {
252         tdm_info_config dst_config;
253         tdm_transform transform;
254         int oneshot;
255         int frequency;
256         int flags;
257 } tdm_info_capture;
258
259 /**
260  * @brief The tdm display object
261  */
262 typedef void tdm_display;
263
264 /**
265  * @brief The tdm output object
266  */
267 typedef void tdm_output;
268
269 /**
270  * @brief The tdm layer object
271  */
272 typedef void tdm_layer;
273
274 /**
275  * @brief The tdm capture object
276  */
277 typedef void tdm_capture;
278
279 /**
280  * @brief The tdm pp object
281  */
282 typedef void tdm_pp;
283
284 /**
285  * @brief The vblank handler
286  * @see output_set_vblank_handler() function of #tdm_func_display
287  */
288 typedef void (*tdm_output_vblank_handler)(tdm_output *output, unsigned int sequence,
289                                                                                   unsigned int tv_sec, unsigned int tv_usec,
290                                                                                   void *user_data);
291
292 /**
293  * @brief The commit handler
294  * @see output_set_commit_handler() function of #tdm_func_display
295  */
296 typedef void (*tdm_output_commit_handler)(tdm_output *output, unsigned int sequence,
297                                                                                   unsigned int tv_sec, unsigned int tv_usec,
298                                                                                   void *user_data);
299
300 #ifdef __cplusplus
301 }
302 #endif
303
304 #endif /* _TDM_TYPES_H_ */