[hwc] add the ability to ask a client(E20) about the revalidation
[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 /**
46  * @file tdm_types.h
47  * @brief The header file which defines Enumerations and Structures for frontend and backend.
48  * @details
49  * Both frontend(@ref tdm.h) and backend(@ref tdm_backend.h) header files
50  * include @ref tdm_types.h
51  * @par Example
52  * @code
53  * #include <tdm.h>    //for a frontend user
54  * @endcode
55  * @code
56  * #include <tdm_backend.h>  //for a vendor to implement a backend module
57  * @endcode
58  */
59
60 #include <tdm_common.h>
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 output mode structure
71  */
72 typedef struct _tdm_output_mode {
73         unsigned int clock;
74         unsigned int hdisplay, hsync_start, hsync_end, htotal, hskew;
75         unsigned int vdisplay, vsync_start, vsync_end, vtotal, vscan;
76         unsigned int vrefresh;
77         unsigned int flags;
78         unsigned int type;
79         char name[TDM_NAME_LEN];
80 } tdm_output_mode;
81
82 /**
83  * @brief The property structure
84  */
85 typedef struct _tdm_prop {
86         unsigned int id;
87         char name[TDM_NAME_LEN];
88         tdm_value_type type;
89 } tdm_prop;
90
91 /**
92  * @brief The info config structure
93  */
94 typedef struct _tdm_info_config {
95         tdm_size size;
96         tdm_pos pos;
97         tbm_format format;
98 } tdm_info_config;
99
100 /**
101  * @brief The layer info structre
102  */
103 typedef struct _tdm_info_layer {
104         tdm_info_config src_config;
105         tdm_pos dst_pos;
106         tdm_transform transform;
107 } tdm_info_layer;
108
109 /**
110  * @brief The hwc window info structure
111  */
112 typedef struct _tdm_hwc_window_info {
113         tdm_info_config src_config;
114         tdm_pos dst_pos;
115         tdm_transform transform;
116 } tdm_hwc_window_info;
117
118 /**
119  * @brief The pp info structre
120  */
121 typedef struct _tdm_info_pp {
122         tdm_info_config src_config;
123         tdm_info_config dst_config;
124         tdm_transform transform;
125         int sync;
126         int flags;
127 } tdm_info_pp;
128
129 /**
130  * @brief The capture info structre
131  */
132 typedef struct _tdm_info_capture {
133         tdm_info_config dst_config;
134         tdm_transform transform;
135         tdm_capture_type type;
136         int frequency;
137         int flags;
138 } tdm_info_capture;
139
140 /**
141  * @brief Possible composition types for a given window
142  */
143 typedef enum {
144         /** The client will composite this window into the client target window
145          *
146          * User can choose this type for window to avoid a hardware composition for
147          * this window.
148          *
149          * User has to set this type for the window which has the TDM_COMPOSITION_CLIENT_CANDIDATE
150          * type. (see the TDM_COMPOSITION_CLIENT_CANDIDATE type)
151          *
152          * The device must not request any composition type changes for windows of
153          * this type.
154          */
155         TDM_COMPOSITION_CLIENT = 0,
156
157         /* Set by the HWC after tdm_output_validate().
158          *
159          * If the HWC decided that it doesn't want/can't to continue the composition for
160          * the window through a hardware overlay or other similar way it'll change
161          * a type to the TDM_COMPOSITION_CLIENT_CANDIDATE type.
162          *
163          * This transition can happen only if the window has the TDM_COMPOSITION_DEVICE
164          * or the TDM_COMPOSITION_VIDEO type already.
165          *
166          * If an user changed type of a window from the TDM_COMPOSITION_DEVICE or the
167          * TDM_COMPOSITION_VIDEO type to the the TDM_COMPOSITION_CLIENT type, the type
168          * will be rejected to the TDM_COMPOSITION_CLIENT_CANDIDATE type.
169          *
170          * The user has to composite this window itself.
171          *
172          * The underlying hardware overlay is owned by this window till a type being
173          * changed to the TDM_COMPOSITION_CLIENT type, but it's not possible to set a
174          * buffer for this window after a type's been changed to the
175          * TDM_COMPOSITION_CLIENT_CANDIDATE type.
176          *
177          * This transitional state is used to get rid of blinking at a transition from
178          * the TDM_COMPOSITION_DEVICE/TDM_COMPOSITION_VIDEO type to the
179          * TDM_COMPOSITION_CLIENT type where the hw     has to wait till a buffer, which was
180          * on a hw overlay, get composited to the fb_target and only after this happens
181          * unset(or set another window on) this hw overlay.
182          *
183          * User has to inform the HWC (the HWC got no way to know when it happens) after a buffer,
184          * which was on a hw overlay, get composited to the fb_target by setting a type of this
185          * window to the TDM_COMPOSITION_CLIENT type, it causes a type of this window being changed
186          * to TDM_COMPOSITION_CLIENT.
187          */
188         TDM_COMPOSITION_CLIENT_CANDIDATE = 5,
189
190         /** Set by the client before tdm_output_validate().
191          *
192          * Upon tdm_output_validate(), the device may request a change from this type to
193          * TDM_COMPOSITION_DEVICE or TDM_COMPOSITION_CLIENT. */
194         TDM_COMPOSITION_DEVICE_CANDIDATE = 2,
195
196         /** Set by the HWC after tdm_output_validate().
197          *
198          * The device will handle the composition of this window through a hardware
199          * overlay or other similar means.
200          *
201          * Upon tdm_output_validate(), the device may request a change from this type to
202          * TDM_COMPOSITION_CLIENT or TDM_COMPOSITION_DEVICE_CANDIDATE. */
203         TDM_COMPOSITION_DEVICE = 1,
204
205         /** Similar to DEVICE, but the position of this layer may also be set
206          * asynchronously through layer_set_cursor_position. If this functionality is not
207          * supported on a layer that the client sets to TDM_COMPOSITION_CURSOR, the
208          * device must request that the composition type of that layer is changed to
209          * TDM_COMPOSITION_CLIENT upon the next call to tdm_output_validate().
210          *
211          * Upon tdm_output_validate(), the device may request a change from this type to
212          * either TDM_COMPOSITION_DEVICE or TDM_COMPOSITION_CLIENT. Changing to
213          * TDM_COMPOSITION_DEVICE will prevent the use of layer_set_cursor_position but
214          * still permit the device to composite the layer. */
215         TDM_COMPOSITION_CURSOR = 3,
216
217         /** The device will handle the composition of this layer through a hardware
218          * overlay or other similar means.
219          *
220          * Upon tdm_output_validate(), the device may request a change from this type to
221          * either TDM_COMPOSITION_DEVICE or TDM_COMPOSITION_CLIENT, but it is
222          * unlikely that content will display correctly in these cases. */
223         TDM_COMPOSITION_VIDEO = 4,
224 } tdm_hwc_window_composition_t;
225
226 /**
227  * @brief The tdm display object
228  */
229 typedef void tdm_display;
230
231 /**
232  * @brief The tdm output object
233  */
234 typedef void tdm_output;
235
236 /**
237  * @brief The tdm layer object
238  */
239 typedef void tdm_layer;
240
241 /**
242  * @brief The tdm window object
243  */
244 typedef void tdm_hwc_window;
245
246 /**
247  * @brief The tdm capture object
248  */
249 typedef void tdm_capture;
250
251 /**
252  * @brief The tdm pp object
253  */
254 typedef void tdm_pp;
255
256 /**
257  * @brief The tdm vblank object
258  */
259 typedef void tdm_vblank;
260
261 /**
262  * @brief The vblank handler
263  * @see output_set_vblank_handler() function of #tdm_func_display
264  */
265 typedef void (*tdm_output_vblank_handler)(tdm_output *output, unsigned int sequence,
266                                                                                   unsigned int tv_sec, unsigned int tv_usec,
267                                                                                   void *user_data);
268
269 /**
270  * @brief The output commit handler
271  * @see output_set_commit_handler() function of #tdm_func_display
272  */
273 typedef void (*tdm_output_commit_handler)(tdm_output *output, unsigned int sequence,
274                                                                                   unsigned int tv_sec, unsigned int tv_usec,
275                                                                                   void *user_data);
276
277 /**
278  * @brief The layer commit handler
279  */
280 typedef void (*tdm_layer_commit_handler)(tdm_layer *layer, unsigned int sequence,
281                                                                                  unsigned int tv_sec, unsigned int tv_usec,
282                                                                                  void *user_data);
283
284 /**
285  * @brief The done handler of a pp object
286  */
287 typedef void (*tdm_pp_done_handler)(tdm_pp *pp, tbm_surface_h src,
288                                                                         tbm_surface_h dst, void *user_data);
289
290 /**
291  * @brief The done handler of a capture object
292  */
293 typedef void (*tdm_capture_done_handler)(tdm_capture *capture,
294                                                                                  tbm_surface_h buffer, void *user_data);
295
296 /**
297  * @brief The 'need to validate' handler of an output object
298  */
299 typedef void (*tdm_output_need_validate_handler)(tdm_output *output);
300
301 #ifdef __cplusplus
302 }
303 #endif
304
305 #endif /* _TDM_TYPES_H_ */