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