apply tizen coding rule
[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 #define TDM_NAME_LEN        64
46
47 /**
48  * @file tdm_types.h
49  * @brief The header file which defines Enumerations and Structures for frontend and backend.
50  * @details
51  * Both frontend(@ref tdm.h) and backend(@ref tdm_backend.h) header files
52  * include @ref tdm_types.h
53  * @par Example
54  * @code
55  * #include <tdm.h>    //for a frontend user
56  * @endcode
57  * @code
58  * #include <tdm_backend.h>  //for a vendor to implement a backend module
59  * @endcode
60  */
61
62 /**
63  * @brief The error enumeration
64  */
65 typedef enum {
66         TDM_ERROR_NONE                  = 0,  /**< none */
67         TDM_ERROR_BAD_REQUEST           = -1, /**< bad request */
68         TDM_ERROR_OPERATION_FAILED      = -2, /**< operaion failed */
69         TDM_ERROR_INVALID_PARAMETER     = -3, /**< wrong input parameter */
70         TDM_ERROR_PERMISSION_DENIED     = -4, /**< access denied */
71         TDM_ERROR_BUSY                  = -5, /**< hardware resource busy */
72         TDM_ERROR_OUT_OF_MEMORY         = -6, /**< no free memory */
73         TDM_ERROR_BAD_MODULE            = -7, /**< bad backend module */
74         TDM_ERROR_NOT_IMPLEMENTED       = -8, /**< not implemented */
75         TDM_ERROR_NO_CAPABILITY         = -9, /**< no capability */
76 } tdm_error;
77
78 /**
79  * @brief The transform enumeration(rotate, flip)
80  */
81 typedef enum {
82         TDM_TRANSFORM_NORMAL            = 0, /**< no transform */
83         TDM_TRANSFORM_90                = 1, /**< rotate 90 */
84         TDM_TRANSFORM_180               = 2, /**< rotate 180 */
85         TDM_TRANSFORM_270               = 3, /**< rotate 270 */
86         TDM_TRANSFORM_FLIPPED           = 4, /**< no rotate and horizontal flip */
87         TDM_TRANSFORM_FLIPPED_90        = 5, /**< rotate 90 and horizontal flip */
88         TDM_TRANSFORM_FLIPPED_180       = 6, /**< rotate 180 and horizontal flip */
89         TDM_TRANSFORM_FLIPPED_270       = 7, /**< rotate 270 and horizontal flip */
90 } tdm_transform;
91
92 /**
93  * @brief The output connection status enumeration
94  */
95 typedef enum {
96         TDM_OUTPUT_CONN_STATUS_DISCONNECTED, /**< output disconnected */
97         TDM_OUTPUT_CONN_STATUS_CONNECTED,    /**< output connected */
98         TDM_OUTPUT_CONN_STATUS_MODE_SETTED,  /**< output connected and setted a mode */
99 } tdm_output_conn_status;
100
101 /**
102  * @brief The output connection status enumeration
103  * @details bit compatible with the libdrm definitions.
104  */
105 typedef enum {
106         TDM_OUTPUT_TYPE_Unknown,        /**< unknown */
107         TDM_OUTPUT_TYPE_VGA,            /**< VGA connection */
108         TDM_OUTPUT_TYPE_DVII,           /**< DVII connection */
109         TDM_OUTPUT_TYPE_DVID,           /**< DVID connection */
110         TDM_OUTPUT_TYPE_DVIA,           /**< DVIA connection */
111         TDM_OUTPUT_TYPE_Composite,      /**< Composite connection */
112         TDM_OUTPUT_TYPE_SVIDEO,         /**< SVIDEO connection */
113         TDM_OUTPUT_TYPE_LVDS,           /**< LVDS connection */
114         TDM_OUTPUT_TYPE_Component,      /**< Component connection */
115         TDM_OUTPUT_TYPE_9PinDIN,        /**< 9PinDIN connection */
116         TDM_OUTPUT_TYPE_DisplayPort,    /**< DisplayPort connection */
117         TDM_OUTPUT_TYPE_HDMIA,          /**< HDMIA connection */
118         TDM_OUTPUT_TYPE_HDMIB,          /**< HDMIB connection */
119         TDM_OUTPUT_TYPE_TV,             /**< TV connection */
120         TDM_OUTPUT_TYPE_eDP,            /**< eDP connection */
121         TDM_OUTPUT_TYPE_VIRTUAL,        /**< Virtual connection for WiFi Display */
122         TDM_OUTPUT_TYPE_DSI,            /**< DSI connection */
123 } tdm_output_type;
124
125 /**
126  * @brief The DPMS enumeration
127  * @details bit compatible with the libdrm definitions.
128  */
129 typedef enum {
130         TDM_OUTPUT_DPMS_ON,         /**< On */
131         TDM_OUTPUT_DPMS_STANDBY,    /**< StandBy */
132         TDM_OUTPUT_DPMS_SUSPEND,    /**< Suspend */
133         TDM_OUTPUT_DPMS_OFF,        /**< Off */
134 } tdm_output_dpms;
135
136 /**
137  * @brief The layer capability enumeration
138  * @details
139  * A layer can have one of CURSOR, PRIMARY and OVERLAY capability. And a layer
140  * also can have one of GRAPHIC and VIDEO capability. And a layer also can have
141  * SCALE and TRANSFORM capability.\n
142  * @par Example
143  * @code
144  *  //For example
145  *  capabilities = TDM_LAYER_CAPABILITY_PRIMARY | TDM_LAYER_CAPABILITY_GRAPHIC;
146  *  capabilities = TDM_LAYER_CAPABILITY_OVERLAY | TDM_LAYER_CAPABILITY_GRAPHIC | TDM_LAYER_CAPABILITY_SCALE;
147  *  capabilities = TDM_LAYER_CAPABILITY_OVERLAY | TDM_LAYER_CAPABILITY_GRAPHIC | TDM_LAYER_CAPABILITY_SCALE | TDM_LAYER_CAPABILITY_TRANSFORM;
148  *  capabilities = TDM_LAYER_CAPABILITY_CURSOR | TDM_LAYER_CAPABILITY_GRAPHIC;
149  *  capabilities = TDM_LAYER_CAPABILITY_OVERLAY | TDM_LAYER_CAPABILITY_VIDEO;
150  * @endcode
151  * @remark
152  * - When a video plays, in most of cases, video buffers will be displayed to
153  * a GRAPHIC layer after converting RGB buffers via PP. In this case, a backend
154  * module doesn't need to offer VIDEO layer.
155  * - But in case that s vendor wants to handle a video by their own way,
156  * a backend module offer VIDEO layers. And a display server will pass a video
157  * buffer to a VIDEO layer without converting.
158  */
159 typedef enum {
160         TDM_LAYER_CAPABILITY_CURSOR         = (1 << 0), /**< cursor */
161         TDM_LAYER_CAPABILITY_PRIMARY        = (1 << 1), /**< primary */
162         TDM_LAYER_CAPABILITY_OVERLAY        = (1 << 2), /**< overlay */
163         TDM_LAYER_CAPABILITY_GRAPHIC        = (1 << 4), /**< graphic */
164         TDM_LAYER_CAPABILITY_VIDEO          = (1 << 5), /**< video */
165         TDM_LAYER_CAPABILITY_SCALE          = (1 << 8), /**< if a layer has scale capability  */
166         TDM_LAYER_CAPABILITY_TRANSFORM      = (1 << 9), /**< if a layer has transform capability  */
167         TDM_LAYER_CAPABILITY_SCANOUT        = (1 << 10), /**< if a layer allows a scanout buffer only */
168         TDM_LAYER_CAPABILITY_RESEVED_MEMORY = (1 << 11), /**< if a layer allows a reserved buffer only */
169         TDM_LAYER_CAPABILITY_NO_CROP        = (1 << 12), /**< if a layer has no cropping capability */
170 } tdm_layer_capability;
171
172 /**
173  * @brief The pp capability enumeration
174  */
175 typedef enum {
176         TDM_PP_CAPABILITY_SYNC           = (1 << 0), /**< The pp device supports synchronous operation */
177         TDM_PP_CAPABILITY_ASYNC          = (1 << 1), /**< The pp device supports asynchronous operation */
178         TDM_PP_CAPABILITY_SCALE          = (1 << 4), /**< The pp device supports scale operation */
179         TDM_PP_CAPABILITY_TRANSFORM      = (1 << 5), /**< The pp device supports transform operation */
180 } tdm_pp_capability;
181
182 /**
183  * @brief The capture capability enumeration
184  */
185 typedef enum {
186         TDM_CAPTURE_CAPABILITY_OUTPUT    = (1 << 0), /**< The capture device supports to dump a output */
187         TDM_CAPTURE_CAPABILITY_LAYER     = (1 << 1), /**< The capture device supports to dump a layer */
188         TDM_CAPTURE_CAPABILITY_SCALE     = (1 << 4), /**< The capture device supports scale operation */
189         TDM_CAPTURE_CAPABILITY_TRANSFORM = (1 << 5), /**< The capture device supports transform operation */
190 } tdm_capture_capability;
191
192 /**
193  * @brief The output mode type enumeration
194  * @details bit compatible with the libdrm definitions.
195  */
196 typedef enum {
197         TDM_OUTPUT_MODE_TYPE_BUILTIN    = (1 << 0),
198         TDM_OUTPUT_MODE_TYPE_CLOCK_C    = ((1 << 1) | TDM_OUTPUT_MODE_TYPE_BUILTIN),
199         TDM_OUTPUT_MODE_TYPE_CRTC_C     = ((1 << 2) | TDM_OUTPUT_MODE_TYPE_BUILTIN),
200         TDM_OUTPUT_MODE_TYPE_PREFERRED  = (1 << 3),
201         TDM_OUTPUT_MODE_TYPE_DEFAULT    = (1 << 4),
202         TDM_OUTPUT_MODE_TYPE_USERDEF    = (1 << 5),
203         TDM_OUTPUT_MODE_TYPE_DRIVER     = (1 << 6),
204 } tdm_output_mode_type;
205
206 /**
207  * @brief The output mode flag enumeration
208  * @details bit compatible with the libdrm definitions.
209  */
210 typedef enum {
211         TDM_OUTPUT_MODE_FLAG_PHSYNC     = (1 << 0),
212         TDM_OUTPUT_MODE_FLAG_NHSYNC     = (1 << 1),
213         TDM_OUTPUT_MODE_FLAG_PVSYNC     = (1 << 2),
214         TDM_OUTPUT_MODE_FLAG_NVSYNC     = (1 << 3),
215         TDM_OUTPUT_MODE_FLAG_INTERLACE  = (1 << 4),
216         TDM_OUTPUT_MODE_FLAG_DBLSCAN    = (1 << 5),
217         TDM_OUTPUT_MODE_FLAG_CSYNC      = (1 << 6),
218         TDM_OUTPUT_MODE_FLAG_PCSYNC     = (1 << 7),
219         TDM_OUTPUT_MODE_FLAG_NCSYNC     = (1 << 8),
220         TDM_OUTPUT_MODE_FLAG_HSKEW      = (1 << 9), /* hskew provided */
221         TDM_OUTPUT_MODE_FLAG_BCAST      = (1 << 10),
222         TDM_OUTPUT_MODE_FLAG_PIXMUX     = (1 << 11),
223         TDM_OUTPUT_MODE_FLAG_DBLCLK     = (1 << 12),
224         TDM_OUTPUT_MODE_FLAG_CLKDIV2    = (1 << 13),
225 } tdm_output_mode_flag;
226
227 typedef enum {
228         TDM_EVENT_LOOP_READABLE = (1 << 0),
229         TDM_EVENT_LOOP_WRITABLE = (1 << 1),
230         TDM_EVENT_LOOP_HANGUP   = (1 << 2),
231         TDM_EVENT_LOOP_ERROR    = (1 << 3),
232 } tdm_event_loop_mask;
233
234 /**
235  * @brief The output mode structure
236  */
237 typedef struct _tdm_output_mode {
238         unsigned int clock;
239         unsigned int hdisplay, hsync_start, hsync_end, htotal, hskew;
240         unsigned int vdisplay, vsync_start, vsync_end, vtotal, vscan;
241         unsigned int vrefresh;
242         unsigned int flags;
243         unsigned int type;
244         char name[TDM_NAME_LEN];
245 } tdm_output_mode;
246
247 /**
248  * @brief The property structure
249  */
250 typedef struct _tdm_prop {
251         unsigned int id;
252         char name[TDM_NAME_LEN];
253 } tdm_prop;
254
255 /**
256  * @brief The size structure
257  */
258 typedef struct _tdm_size {
259         unsigned int h;     /**< width */
260         unsigned int v;     /**< height */
261 } tdm_size;
262
263 /**
264  * @brief The pos structure
265  */
266 typedef struct _tdm_pos {
267         unsigned int x;
268         unsigned int y;
269         unsigned int w;
270         unsigned int h;
271 } tdm_pos;
272
273 /**
274  * @brief The value union
275  */
276 typedef union {
277         void     *ptr;
278         int32_t  s32;
279         uint32_t u32;
280         int64_t  s64;
281         uint64_t u64;
282 } tdm_value;
283
284 /**
285  * @brief The info config structure
286  */
287 typedef struct _tdm_info_config {
288         tdm_size size;
289         tdm_pos pos;
290         tbm_format format;
291 } tdm_info_config;
292
293 /**
294  * @brief The layer info structre
295  */
296 typedef struct _tdm_info_layer {
297         tdm_info_config src_config;
298         tdm_pos dst_pos;
299         tdm_transform transform;
300 } tdm_info_layer;
301
302 /**
303  * @brief The pp info structre
304  */
305 typedef struct _tdm_info_pp {
306         tdm_info_config src_config;
307         tdm_info_config dst_config;
308         tdm_transform transform;
309         int sync;
310         int flags;
311 } tdm_info_pp;
312
313 /**
314  * @brief The capture info structre
315  */
316 typedef struct _tdm_info_capture {
317         tdm_info_config dst_config;
318         tdm_transform transform;
319         int oneshot;
320         int frequency;
321         int flags;
322 } tdm_info_capture;
323
324 /**
325  * @brief The tdm display object
326  */
327 typedef void tdm_display;
328
329 /**
330  * @brief The tdm output object
331  */
332 typedef void tdm_output;
333
334 /**
335  * @brief The tdm layer object
336  */
337 typedef void tdm_layer;
338
339 /**
340  * @brief The tdm capture object
341  */
342 typedef void tdm_capture;
343
344 /**
345  * @brief The tdm pp object
346  */
347 typedef void tdm_pp;
348
349 /**
350  * @brief The vblank handler
351  * @see output_set_vblank_handler() function of #tdm_func_display
352  */
353 typedef void (*tdm_output_vblank_handler)(tdm_output *output, unsigned int sequence,
354                                                                                   unsigned int tv_sec, unsigned int tv_usec,
355                                                                                   void *user_data);
356
357 /**
358  * @brief The commit handler
359  * @see output_set_commit_handler() function of #tdm_func_display
360  */
361 typedef void (*tdm_output_commit_handler)(tdm_output *output, unsigned int sequence,
362                                                                                   unsigned int tv_sec, unsigned int tv_usec,
363                                                                                   void *user_data);
364
365 /**
366  * @brief The tdm event source
367  */
368 typedef void tdm_event_loop_source;
369
370 /**
371  * @brief The fd source handler
372  */
373 typedef tdm_error (*tdm_event_loop_fd_handler)(int fd, tdm_event_loop_mask mask, void *user_data);
374
375 /**
376  * @brief The timer source handler
377  */
378 typedef tdm_error (*tdm_event_loop_timer_handler)(void *user_data);
379
380 #ifdef __cplusplus
381 }
382 #endif
383
384 #endif /* _TDM_TYPES_H_ */