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