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