change tdm capture capbility
[platform/core/uifw/libtdm.git] / include / tdm_common.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_COMMON_H_
37 #define _TDM_COMMON_H_
38
39 #include <stdint.h>
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
45 #define TDM_NAME_LEN        64
46 #define TDM_PATH_LEN        1024
47
48 /**
49  * @file tdm_common.h
50  * @brief The header file which defines Enumerations and Structures for TDM
51  * frontend, backend and client.
52  */
53
54 /**
55  * @brief The error enumeration
56  */
57 typedef enum {
58         TDM_ERROR_NONE                  = 0,  /**< none */
59         TDM_ERROR_BAD_REQUEST           = -1, /**< bad request */
60         TDM_ERROR_OPERATION_FAILED      = -2, /**< operaion failed */
61         TDM_ERROR_INVALID_PARAMETER     = -3, /**< wrong input parameter */
62         TDM_ERROR_PERMISSION_DENIED     = -4, /**< access denied */
63         TDM_ERROR_BUSY                  = -5, /**< hardware resource busy */
64         TDM_ERROR_OUT_OF_MEMORY         = -6, /**< no free memory */
65         TDM_ERROR_BAD_MODULE            = -7, /**< bad backend module */
66         TDM_ERROR_NOT_IMPLEMENTED       = -8, /**< not implemented */
67         TDM_ERROR_NO_CAPABILITY         = -9, /**< no capability */
68         TDM_ERROR_DPMS_OFF              = -10, /**< dpms off */
69 } tdm_error;
70
71 /**
72  * @brief The transform enumeration(rotate, flip)
73  */
74 typedef enum {
75         TDM_TRANSFORM_NORMAL            = 0, /**< no transform */
76         TDM_TRANSFORM_90                = 1, /**< rotate 90 */
77         TDM_TRANSFORM_180               = 2, /**< rotate 180 */
78         TDM_TRANSFORM_270               = 3, /**< rotate 270 */
79         TDM_TRANSFORM_FLIPPED           = 4, /**< no rotate and horizontal flip */
80         TDM_TRANSFORM_FLIPPED_90        = 5, /**< rotate 90 and horizontal flip */
81         TDM_TRANSFORM_FLIPPED_180       = 6, /**< rotate 180 and horizontal flip */
82         TDM_TRANSFORM_FLIPPED_270       = 7, /**< rotate 270 and horizontal flip */
83 } tdm_transform;
84
85 /**
86  * @brief The output capability enumeration
87  * @details
88  * @remark
89  */
90 typedef enum {
91         TDM_OUTPUT_CAPABILITY_ASYNC_DPMS         = (1 << 0), /**< if a outupt supports asynchronous DPMS operation */
92 } tdm_output_capability;
93
94 /**
95  * @brief The layer capability enumeration
96  * @details
97  * A layer can have one of CURSOR, PRIMARY and OVERLAY capability. And a layer
98  * also can have one of GRAPHIC and VIDEO capability. And a layer also can have
99  * SCALE and TRANSFORM capability.\n
100  * @par Example
101  * @code
102  *  //For example
103  *  capabilities = TDM_LAYER_CAPABILITY_PRIMARY | TDM_LAYER_CAPABILITY_GRAPHIC;
104  *  capabilities = TDM_LAYER_CAPABILITY_OVERLAY | TDM_LAYER_CAPABILITY_GRAPHIC | TDM_LAYER_CAPABILITY_SCALE;
105  *  capabilities = TDM_LAYER_CAPABILITY_OVERLAY | TDM_LAYER_CAPABILITY_GRAPHIC | TDM_LAYER_CAPABILITY_SCALE | TDM_LAYER_CAPABILITY_TRANSFORM;
106  *  capabilities = TDM_LAYER_CAPABILITY_CURSOR | TDM_LAYER_CAPABILITY_GRAPHIC;
107  *  capabilities = TDM_LAYER_CAPABILITY_OVERLAY | TDM_LAYER_CAPABILITY_VIDEO;
108  * @endcode
109  * @remark
110  * - When a video plays, in most of cases, video buffers will be displayed to
111  * a GRAPHIC layer after converting RGB buffers via PP. In this case, a backend
112  * module doesn't need to offer VIDEO layer.
113  * - But in case that s vendor wants to handle a video by their own way,
114  * a backend module offer VIDEO layers. And a display server will pass a video
115  * buffer to a VIDEO layer without converting.
116  */
117 typedef enum {
118         TDM_LAYER_CAPABILITY_CURSOR         = (1 << 0), /**< cursor */
119         TDM_LAYER_CAPABILITY_PRIMARY        = (1 << 1), /**< primary */
120         TDM_LAYER_CAPABILITY_OVERLAY        = (1 << 2), /**< overlay */
121         TDM_LAYER_CAPABILITY_GRAPHIC        = (1 << 4), /**< graphic */
122         TDM_LAYER_CAPABILITY_VIDEO          = (1 << 5), /**< video */
123         TDM_LAYER_CAPABILITY_SCALE          = (1 << 8), /**< if a layer has scale capability  */
124         TDM_LAYER_CAPABILITY_TRANSFORM      = (1 << 9), /**< if a layer has transform capability  */
125         TDM_LAYER_CAPABILITY_SCANOUT        = (1 << 10), /**< if a layer allows a scanout buffer only */
126         TDM_LAYER_CAPABILITY_RESEVED_MEMORY = (1 << 11), /**< if a layer allows a reserved buffer only */
127         TDM_LAYER_CAPABILITY_NO_CROP        = (1 << 12), /**< if a layer has no cropping capability */
128 } tdm_layer_capability;
129
130 /**
131  * @brief The pp capability enumeration
132  */
133 typedef enum {
134         TDM_PP_CAPABILITY_SYNC           = (1 << 0), /**< The pp device supports synchronous operation */
135         TDM_PP_CAPABILITY_ASYNC          = (1 << 1), /**< The pp device supports asynchronous operation */
136         TDM_PP_CAPABILITY_SCALE          = (1 << 4), /**< The pp device supports scale operation */
137         TDM_PP_CAPABILITY_TRANSFORM      = (1 << 5), /**< The pp device supports transform operation */
138 } tdm_pp_capability;
139
140 /**
141  * @brief The capture capability enumeration
142  */
143 typedef enum {
144         TDM_CAPTURE_CAPABILITY_OUTPUT    = (1 << 0), /**< The capture device supports to dump a output */
145         TDM_CAPTURE_CAPABILITY_LAYER     = (1 << 1), /**< The capture device supports to dump a layer */
146         TDM_CAPTURE_CAPABILITY_ONESHOT   = (1 << 4), /**< The capture device supports oneshot dump */
147         TDM_CAPTURE_CAPABILITY_STREAM    = (1 << 5), /**< The capture device supports streamp sump */
148 } tdm_capture_capability;
149
150 /**
151  * @brief The capture type enumeration
152  */
153 typedef enum {
154         TDM_CAPTURE_TYPE_ONESHOT    = (1 << 0), /**< The oneshot capture */
155         TDM_CAPTURE_TYPE_STREAM     = (1 << 1), /**< The stream capture */
156 } tdm_capture_type;
157
158 /**
159  * @brief The output change enumeration of #tdm_output_change_handler
160  */
161 typedef enum {
162         TDM_OUTPUT_CHANGE_CONNECTION    = (1 << 0), /**< connection chagne */
163         TDM_OUTPUT_CHANGE_DPMS          = (1 << 1), /**< dpms change */
164 } tdm_output_change_type;
165
166 /**
167  * @brief The output connection status enumeration
168  */
169 typedef enum {
170         TDM_OUTPUT_CONN_STATUS_DISCONNECTED, /**< output disconnected */
171         TDM_OUTPUT_CONN_STATUS_CONNECTED,    /**< output connected */
172         TDM_OUTPUT_CONN_STATUS_MODE_SETTED,  /**< output connected and setted a mode */
173 } tdm_output_conn_status;
174
175 /**
176  * @brief The output connection status enumeration
177  * @details bit compatible with the libdrm definitions.
178  */
179 typedef enum {
180         TDM_OUTPUT_TYPE_Unknown,        /**< unknown */
181         TDM_OUTPUT_TYPE_VGA,            /**< VGA connection */
182         TDM_OUTPUT_TYPE_DVII,           /**< DVII connection */
183         TDM_OUTPUT_TYPE_DVID,           /**< DVID connection */
184         TDM_OUTPUT_TYPE_DVIA,           /**< DVIA connection */
185         TDM_OUTPUT_TYPE_Composite,      /**< Composite connection */
186         TDM_OUTPUT_TYPE_SVIDEO,         /**< SVIDEO connection */
187         TDM_OUTPUT_TYPE_LVDS,           /**< LVDS connection */
188         TDM_OUTPUT_TYPE_Component,      /**< Component connection */
189         TDM_OUTPUT_TYPE_9PinDIN,        /**< 9PinDIN connection */
190         TDM_OUTPUT_TYPE_DisplayPort,    /**< DisplayPort connection */
191         TDM_OUTPUT_TYPE_HDMIA,          /**< HDMIA connection */
192         TDM_OUTPUT_TYPE_HDMIB,          /**< HDMIB connection */
193         TDM_OUTPUT_TYPE_TV,             /**< TV connection */
194         TDM_OUTPUT_TYPE_eDP,            /**< eDP connection */
195         TDM_OUTPUT_TYPE_VIRTUAL,        /**< Virtual connection for WiFi Display */
196         TDM_OUTPUT_TYPE_DSI,            /**< DSI connection */
197 } tdm_output_type;
198
199 /**
200  * @brief The DPMS enumeration
201  * @details bit compatible with the libdrm definitions.
202  */
203 typedef enum {
204         TDM_OUTPUT_DPMS_ON,         /**< On */
205         TDM_OUTPUT_DPMS_STANDBY,    /**< StandBy */
206         TDM_OUTPUT_DPMS_SUSPEND,    /**< Suspend */
207         TDM_OUTPUT_DPMS_OFF,        /**< Off */
208 } tdm_output_dpms;
209
210 /**
211  * @brief The output mode type enumeration
212  * @details bit compatible with the libdrm definitions.
213  */
214 typedef enum {
215         TDM_OUTPUT_MODE_TYPE_BUILTIN    = (1 << 0),
216         TDM_OUTPUT_MODE_TYPE_CLOCK_C    = ((1 << 1) | TDM_OUTPUT_MODE_TYPE_BUILTIN),
217         TDM_OUTPUT_MODE_TYPE_CRTC_C     = ((1 << 2) | TDM_OUTPUT_MODE_TYPE_BUILTIN),
218         TDM_OUTPUT_MODE_TYPE_PREFERRED  = (1 << 3),
219         TDM_OUTPUT_MODE_TYPE_DEFAULT    = (1 << 4),
220         TDM_OUTPUT_MODE_TYPE_USERDEF    = (1 << 5),
221         TDM_OUTPUT_MODE_TYPE_DRIVER     = (1 << 6),
222 } tdm_output_mode_type;
223
224 /**
225  * @brief The output mode flag enumeration
226  * @details bit compatible with the libdrm definitions.
227  */
228 typedef enum {
229         TDM_OUTPUT_MODE_FLAG_PHSYNC     = (1 << 0),
230         TDM_OUTPUT_MODE_FLAG_NHSYNC     = (1 << 1),
231         TDM_OUTPUT_MODE_FLAG_PVSYNC     = (1 << 2),
232         TDM_OUTPUT_MODE_FLAG_NVSYNC     = (1 << 3),
233         TDM_OUTPUT_MODE_FLAG_INTERLACE  = (1 << 4),
234         TDM_OUTPUT_MODE_FLAG_DBLSCAN    = (1 << 5),
235         TDM_OUTPUT_MODE_FLAG_CSYNC      = (1 << 6),
236         TDM_OUTPUT_MODE_FLAG_PCSYNC     = (1 << 7),
237         TDM_OUTPUT_MODE_FLAG_NCSYNC     = (1 << 8),
238         TDM_OUTPUT_MODE_FLAG_HSKEW      = (1 << 9), /* hskew provided */
239         TDM_OUTPUT_MODE_FLAG_BCAST      = (1 << 10),
240         TDM_OUTPUT_MODE_FLAG_PIXMUX     = (1 << 11),
241         TDM_OUTPUT_MODE_FLAG_DBLCLK     = (1 << 12),
242         TDM_OUTPUT_MODE_FLAG_CLKDIV2    = (1 << 13),
243 } tdm_output_mode_flag;
244
245 /**
246  * @brief The size structure
247  */
248 typedef struct _tdm_size {
249         unsigned int h;     /**< width */
250         unsigned int v;     /**< height */
251 } tdm_size;
252
253 /**
254  * @brief The pos structure
255  */
256 typedef struct _tdm_pos {
257         unsigned int x;
258         unsigned int y;
259         unsigned int w;
260         unsigned int h;
261 } tdm_pos;
262
263 /**
264  * @brief The value union
265  */
266 typedef union {
267         void     *ptr;
268         int32_t  s32;
269         uint32_t u32;
270         int64_t  s64;
271         uint64_t u64;
272 } tdm_value;
273
274 #ifdef __cplusplus
275 }
276 #endif
277
278 #endif /* _TDM_COMMON_H_ */