virtual: support tdm_client output_set_mode
[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 <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_TYPES_H_
37 #define _TDM_TYPES_H_
38
39 #include <tbm_surface.h>
40
41 #include "tdm_common.h"
42
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
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 typedef enum {
63         TDM_EVENT_LOOP_READABLE = (1 << 0),
64         TDM_EVENT_LOOP_WRITABLE = (1 << 1),
65         TDM_EVENT_LOOP_HANGUP   = (1 << 2),
66         TDM_EVENT_LOOP_ERROR    = (1 << 3),
67 } tdm_event_loop_mask;
68
69 /**
70  * @brief The display capability enumeration
71  */
72 typedef enum {
73         TDM_DISPLAY_CAPABILITY_PP       = (1 << 0), /**< if hardware supports pp operation */
74         TDM_DISPLAY_CAPABILITY_CAPTURE  = (1 << 1), /**< if hardware supports capture operation */
75 } tdm_display_capability;
76
77 /**
78  * @brief The output mode structure
79  */
80 typedef struct _tdm_output_mode {
81         unsigned int clock;
82         unsigned int hdisplay, hsync_start, hsync_end, htotal, hskew;
83         unsigned int vdisplay, vsync_start, vsync_end, vtotal, vscan;
84         unsigned int vrefresh;
85         unsigned int flags;
86         unsigned int type;
87         char name[TDM_NAME_LEN];
88 } tdm_output_mode;
89
90 /**
91  * @brief The property structure
92  */
93 typedef struct _tdm_prop {
94         unsigned int id;
95         char name[TDM_NAME_LEN];
96         tdm_value_type type;
97 } tdm_prop;
98
99 /**
100  * @brief The info config structure
101  */
102 typedef struct _tdm_info_config {
103         tdm_size size;
104         tdm_pos pos;
105         tbm_format format;
106 } tdm_info_config;
107
108 /**
109  * @brief The layer info structre
110  */
111 typedef struct _tdm_info_layer {
112         tdm_info_config src_config;
113         tdm_pos dst_pos;
114         tdm_transform transform;
115 } tdm_info_layer;
116
117 /**
118  * @brief The region structure
119  * @since 2.0.0
120  */
121 typedef struct _tdm_region {
122         unsigned int num_rects;
123         tdm_pos const *rects;
124 } tdm_region;
125
126 /**
127  * @brief The hwc window info structure
128  * @since 2.0.0
129  */
130 typedef struct _tdm_hwc_window_info {
131         tdm_info_config src_config;
132         tdm_pos dst_pos;
133         tdm_transform transform;
134 } tdm_hwc_window_info;
135
136 /**
137  * @brief The pp info structre
138  */
139 typedef struct _tdm_info_pp {
140         tdm_info_config src_config;
141         tdm_info_config dst_config;
142         tdm_transform transform;
143         int sync;
144         int flags;
145 } tdm_info_pp;
146
147 /**
148  * @brief The capture info structre
149  */
150 typedef struct _tdm_info_capture {
151         tdm_info_config dst_config;
152         tdm_transform transform;
153         tdm_capture_type type;
154         int frequency;
155         int flags;
156 } tdm_info_capture;
157
158 /**
159  * @brief Possible composition types for a given window
160  * @since 2.0.0
161  */
162 typedef enum {
163
164         /** Set by the client for an invisible window. The value by default.
165          *
166          * The device ignores windows of this type.
167          */
168         TDM_COMPOSITION_NONE = 0,
169
170         /** The client will composite this window into the client target window
171          *
172          * User can choose this type for window to avoid a hardware composition for
173          * this window.
174          *
175          * The device must not request any composition type changes for windows of
176          * this type.
177          */
178         TDM_COMPOSITION_CLIENT = 1,
179
180         /** Set by the client before tdm_hwc_validate().
181          *
182          * Upon tdm_hwc_validate(), the device may request a change from this type to
183          * TDM_COMPOSITION_DEVICE or TDM_COMPOSITION_CLIENT. */
184         TDM_COMPOSITION_DEVICE_CANDIDATE = 2,
185
186         /** Set by the HWC after tdm_hwc_validate().
187          *
188          * The device will handle the composition of this window through a hardware
189          * overlay or other similar means.
190          *
191          * Upon tdm_hwc_validate(), the device may request a change from this type to
192          * TDM_COMPOSITION_CLIENT or TDM_COMPOSITION_DEVICE_CANDIDATE. */
193         TDM_COMPOSITION_DEVICE = 3,
194
195         /** Similar to DEVICE, but the position of this layer may also be set
196          * asynchronously through layer_set_cursor_position. If this functionality is not
197          * supported on a layer that the client sets to TDM_COMPOSITION_CURSOR, the
198          * device must request that the composition type of that layer is changed to
199          * TDM_COMPOSITION_CLIENT upon the next call to tdm_hwc_validate().
200          *
201          * Upon tdm_hwc_validate(), the device may request a change from this type to
202          * either TDM_COMPOSITION_DEVICE or TDM_COMPOSITION_CLIENT. Changing to
203          * TDM_COMPOSITION_DEVICE will prevent the use of layer_set_cursor_position but
204          * still permit the device to composite the layer. */
205         TDM_COMPOSITION_CURSOR = 4,
206
207         /** This type is for the VIDEO window which can be set to the reserved hw overlay
208          *  which is assigned by the device.
209          *
210          * Normally, this VIDEO window displays under the primary hw overlayer of the output. */
211         TDM_COMPOSITION_VIDEO = 5,
212 } tdm_hwc_window_composition;
213
214 /**
215  * @brief The hwc window flag enumeration
216  * @since 2.0.0
217  */
218 typedef enum {
219         TDM_HWC_WINDOW_FLAG_NONE     = 0,
220 } tdm_hwc_window_flag;
221
222 /**
223  * @brief The tdm display object
224  */
225 typedef void tdm_display;
226
227 /**
228  * @brief The tdm backend object
229  */
230 typedef void tdm_module;
231
232 /**
233  * @brief The tdm output object
234  */
235 typedef void tdm_output;
236
237 /**
238  * @brief The tdm layer object
239  */
240 typedef void tdm_layer;
241
242 /**
243  * @brief The tdm hwc object
244  * @since 2.0.0
245  */
246 typedef void tdm_hwc;
247
248 /**
249  * @brief The tdm hwc window object
250  * @since 2.0.0
251  */
252 typedef void tdm_hwc_window;
253
254 /**
255  * @brief The tdm capture object
256  */
257 typedef void tdm_capture;
258
259 /**
260  * @brief The tdm pp object
261  */
262 typedef void tdm_pp;
263
264 /**
265  * @brief The tdm vblank object
266  */
267 typedef void tdm_vblank;
268
269 /* virtual */
270 typedef void (*tdm_output_create_handler)(tdm_display *dpy, tdm_output *output, void *user_data);
271 typedef void (*tdm_output_destroy_handler)(tdm_output *output, void *user_data);
272
273 /**
274  * @brief The output change handler
275  * @details This handler will be called when the status of a output object is
276  * changed in runtime.
277  */
278 typedef void (*tdm_output_change_handler)(tdm_output *output,
279                                                                                   tdm_output_change_type type,
280                                                                                   tdm_value value,
281                                                                                   void *user_data);
282
283 /**
284  * @brief The vblank handler
285  * @see output_set_vblank_handler() function of #tdm_func_display
286  */
287 typedef void (*tdm_output_vblank_handler)(tdm_output *output, unsigned int sequence,
288                                                                                   unsigned int tv_sec, unsigned int tv_usec,
289                                                                                   void *user_data);
290
291 /**
292  * @brief The output commit handler
293  * @see output_set_commit_handler() function of #tdm_func_display
294  */
295 typedef void (*tdm_output_commit_handler)(tdm_output *output, unsigned int sequence,
296                                                                                   unsigned int tv_sec, unsigned int tv_usec,
297                                                                                   void *user_data);
298
299 /**
300  * @brief The output mode change request handler
301  */
302 typedef void (*tdm_output_mode_change_request_handler)(tdm_output *output,
303                                                                                                            unsigned int index, void *user_data);
304
305 /**
306  * @brief The layer commit handler
307  */
308 typedef void (*tdm_layer_commit_handler)(tdm_layer *layer, unsigned int sequence,
309                                                                                  unsigned int tv_sec, unsigned int tv_usec,
310                                                                                  void *user_data);
311
312 /**
313  * @brief The done handler of a pp object
314  */
315 typedef void (*tdm_pp_done_handler)(tdm_pp *pp, tbm_surface_h src,
316                                                                         tbm_surface_h dst, void *user_data);
317
318 /**
319  * @brief The done handler of a capture object
320  */
321 typedef void (*tdm_capture_done_handler)(tdm_capture *capture,
322                                                                                  tbm_surface_h buffer, void *user_data);
323
324 /**
325  * @brief The create handler of a vblank object
326  */
327 typedef void (*tdm_vblank_create_handler)(tdm_vblank *vblank, void *user_data);
328
329 /**
330  * @brief The hwc commit handler
331  * @see hwc_set_commit_handler() function of #tdm_func_hwc
332  */
333 typedef void (*tdm_hwc_commit_handler)(tdm_hwc *hwc, unsigned int sequence,
334                                                                           unsigned int tv_sec, unsigned int tv_usec,
335                                                                           void *user_data);
336
337 #ifdef __cplusplus
338 }
339 #endif
340
341 #endif /* _TDM_TYPES_H_ */