HWC: first draft
[platform/core/uifw/libtdm.git] / include / tdm.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_H_
37 #define _TDM_H_
38
39 #include <stdint.h>
40 #include <tbm_surface.h>
41 #include <tbm_surface_queue.h>
42 #include <tbm_surface_internal.h>
43
44 #include "tdm_types.h"
45
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49
50 /**
51  * @file tdm.h
52  * @brief The header file for a frontend user.
53  * @par Example
54  * @code
55  * #include <tdm.h>    //for a frontend user
56  * @endcode
57  */
58
59 /**
60  * @brief The display capability enumeration
61  */
62 typedef enum {
63         TDM_DISPLAY_CAPABILITY_PP       = (1 << 0), /**< if hardware supports pp operation */
64         TDM_DISPLAY_CAPABILITY_CAPTURE  = (1 << 1), /**< if hardware supports capture operation */
65         TDM_DISPLAY_CAPABILITY_HWC              = (1 << 2), /**< if hardware supports hwc operation */
66 } tdm_display_capability;
67
68 /**
69  * @brief The output change handler
70  * @details This handler will be called when the status of a output object is
71  * changed in runtime.
72  */
73 typedef void (*tdm_output_change_handler)(tdm_output *output,
74                                                                                   tdm_output_change_type type,
75                                                                                   tdm_value value,
76                                                                                   void *user_data);
77
78 /**
79  * @brief Initialize a display object
80  * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
81  * @return A display object
82  * @see tdm_display_deinit
83  */
84 tdm_display *
85 tdm_display_init(tdm_error *error);
86
87 /**
88  * @brief Deinitialize a display object
89  * @param[in] dpy A display object
90  * @see tdm_display_init
91  */
92 void
93 tdm_display_deinit(tdm_display *dpy);
94
95 /**
96  * @brief Update a display object
97  * @details
98  * When new output is connected, a frontend user need to call this function.
99  * And a frontend user can the new output information with tdm_output_get_xxx functions.
100  * @param[in] dpy A display object
101  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
102  */
103 tdm_error
104 tdm_display_update(tdm_display *dpy);
105
106 /**
107  * @brief Get the file descriptor
108  * @details TDM handles the events of fd with #tdm_display_handle_events.
109  * @param[in] dpy A display object
110  * @param[out] fd The file descriptor
111  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
112  * @see tdm_display_handle_events
113  */
114 tdm_error
115 tdm_display_get_fd(tdm_display *dpy, int *fd);
116
117 /**
118  * @brief Handle the events
119  * @param[in] dpy A display object
120  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
121  * @see tdm_display_get_fd
122  */
123 tdm_error
124 tdm_display_handle_events(tdm_display *dpy);
125
126 /**
127  * @brief Get the information of the TDM backend module.
128  * @param[in] dpy A display object
129  * @param[out] name The name of the TDM backend module
130  * @param[out] vendor The vendor of the TDM backend module
131  * @param[out] version The version of the TDM backend module
132  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
133  */
134 tdm_error
135 tdm_display_get_backend_info(tdm_display *dpy, const char **name,
136                                                          const char **vendor, int *major, int *minor);
137
138 /**
139  * @brief Get the capabilities of a display object.
140  * @details A frontend user can get whether TDM supports pp/capture functionality with this function.
141  * @param[in] dpy A display object
142  * @param[out] capabilities The capabilities of a display object
143  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
144  */
145 tdm_error
146 tdm_display_get_capabilities(tdm_display *dpy,
147                                                          tdm_display_capability *capabilities);
148
149 /**
150  * @brief Get the pp capabilities of a display object.
151  * @param[in] dpy A display object
152  * @param[out] capabilities The pp capabilities
153  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
154  */
155 tdm_error
156 tdm_display_get_pp_capabilities(tdm_display *dpy,
157                                                                 tdm_pp_capability *capabilities);
158
159 /**
160  * @brief Get the pp available format array of a display object.
161  * @param[in] dpy A display object
162  * @param[out] formats The pp available format array
163  * @param[out] count The count of formats
164  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
165  */
166 tdm_error
167 tdm_display_get_pp_available_formats(tdm_display *dpy,
168                                                                          const tbm_format **formats, int *count);
169
170 /**
171  * @brief Get the pp available size of a display object.
172  * @details -1 means that a TDM backend module doesn't define the value.
173  * @param[in] dpy A display object
174  * @param[out] min_w The minimum width which TDM can handle
175  * @param[out] min_h The minimum height which TDM can handle
176  * @param[out] max_w The maximum width which TDM can handle
177  * @param[out] max_h The maximum height which TDM can handle
178  * @param[out] preferred_align The preferred align width which TDM can handle
179  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
180  */
181 tdm_error
182 tdm_display_get_pp_available_size(tdm_display *dpy, int *min_w, int *min_h,
183                                                                   int *max_w, int *max_h, int *preferred_align);
184
185 /**
186  * @brief Get the capture capabilities of a display object.
187  * @param[in] dpy A display object
188  * @param[out] capabilities The capture capabilities
189  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
190  */
191 tdm_error
192 tdm_display_get_capture_capabilities(tdm_display *dpy,
193                                                                          tdm_capture_capability *capabilities);
194
195 /**
196  * @brief Get the capture available format array of a display object.
197  * @param[in] dpy A display object
198  * @param[out] formats The capture available format array
199  * @param[out] count The count of formats
200  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
201  */
202 tdm_error
203 tdm_display_get_catpure_available_formats(tdm_display *dpy,
204                                                                                   const tbm_format **formats, int *count);
205
206 /**
207  * @brief Get the capture available size of a display object.
208  * @details -1 means that a TDM backend module doesn't define the value.
209  * @param[in] dpy A display object
210  * @param[out] min_w The minimum width which TDM can handle
211  * @param[out] min_h The minimum height which TDM can handle
212  * @param[out] max_w The maximum width which TDM can handle
213  * @param[out] max_h The maximum height which TDM can handle
214  * @param[out] preferred_align The preferred align width which TDM can handle
215  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
216  */
217 tdm_error
218 tdm_display_get_capture_available_size(tdm_display *dpy, int *min_w, int *min_h,
219                                                                            int *max_w, int *max_h, int *preferred_align);
220
221 /**
222  * @brief Get the max layer counts which a display object can show on screen.
223  * @details -1 means that a TDM backend module doesn't define the value.
224  * @param[in] dpy A display object
225  * @param[out] count The max count of layers
226  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
227  */
228 tdm_error
229 tdm_display_get_max_layer_count(tdm_display *dpy, int *max_count);
230
231 /**
232  * @brief Get the output counts which a display object has.
233  * @param[in] dpy A display object
234  * @param[out] count The count of outputs
235  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
236  * @see tdm_display_get_output
237  */
238 tdm_error
239 tdm_display_get_output_count(tdm_display *dpy, int *count);
240
241 /**
242  * @brief Get a output object which has the given index.
243  * @param[in] dpy A display object
244  * @param[in] index The index of a output object
245  * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
246  * @return A output object if success. Otherwise, NULL.
247  * @see tdm_display_get_output_count
248  */
249 tdm_output *
250 tdm_display_get_output(tdm_display *dpy, int index, tdm_error *error);
251
252 /**
253  * @brief Create a pp object.
254  * @param[in] dpy A display object
255  * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
256  * @return A pp object if success. Otherwise, NULL.
257  * @see tdm_pp_destroy
258  */
259 tdm_pp *
260 tdm_display_create_pp(tdm_display *dpy, tdm_error *error);
261
262 /**
263  * @brief Get the capabilities of a output object.
264  * @param[in] output A output object
265  * @param[out] capabilities The capabilities of a output object
266  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
267  */
268 tdm_error
269 tdm_output_get_capabilities(tdm_output *output,
270                                                         tdm_output_capability *capabilities);
271
272 /**
273  * @brief Get the model information of a output object.
274  * @param[in] output A output object
275  * @param[out] maker The output maker.
276  * @param[out] model The output model.
277  * @param[out] name The output name.
278  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
279  */
280 tdm_error
281 tdm_output_get_model_info(tdm_output *output, const char **maker,
282                                                   const char **model, const char **name);
283
284 /**
285  * @brief Get the connection status of a output object.
286  * @param[in] output A output object
287  * @param[out] status The connection status.
288  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
289  */
290 tdm_error
291 tdm_output_get_conn_status(tdm_output *output, tdm_output_conn_status *status);
292
293 /**
294  * @brief Add a output change handler
295  * @details The handler will be called when the status of a
296  * output object is changed. connection, DPMS, etc.
297  * @param[in] output A output object
298  * @param[in] func A output change handler
299  * @param[in] user_data The user data
300  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
301  */
302 tdm_error
303 tdm_output_add_change_handler(tdm_output *output,
304                                                           tdm_output_change_handler func,
305                                                           void *user_data);
306
307 /**
308  * @brief Remove a output change handler
309  * @param[in] output A output object
310  * @param[in] func A output change handler
311  * @param[in] user_data The user data
312  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
313  */
314 void
315 tdm_output_remove_change_handler(tdm_output *output,
316                                                                  tdm_output_change_handler func,
317                                                                  void *user_data);
318
319 /**
320  * @brief Get the connection type of a output object.
321  * @param[in] output A output object
322  * @param[out] type The connection type.
323  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
324  */
325 tdm_error
326 tdm_output_get_output_type(tdm_output *output, tdm_output_type *type);
327
328 /**
329  * @brief Get the layer counts which a output object has.
330  * @param[in] output A output object
331  * @param[out] count The count of layers
332  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
333  * @see tdm_output_get_layer
334  */
335 tdm_error
336 tdm_output_get_layer_count(tdm_output *output, int *count);
337
338 /**
339  * @brief Get a layer object which has the given index.
340  * @param[in] output A output object
341  * @param[in] index The index of a layer object
342  * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
343  * @return A layer object if success. Otherwise, NULL.
344  * @see tdm_output_get_layer_count
345  */
346 tdm_layer *
347 tdm_output_get_layer(tdm_output *output, int index, tdm_error *error);
348
349 /**
350  * @brief Get the available property array of a output object.
351  * @param[in] output A output object
352  * @param[out] props The available property array
353  * @param[out] count The count of properties
354  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
355  */
356 tdm_error
357 tdm_output_get_available_properties(tdm_output *output, const tdm_prop **props,
358                                                                         int *count);
359
360 /**
361  * @brief Get the available mode array of a output object.
362  * @param[in] output A output object
363  * @param[out] modes The available mode array
364  * @param[out] count The count of modes
365  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
366  */
367 tdm_error
368 tdm_output_get_available_modes(tdm_output *output,
369                                                            const tdm_output_mode **modes, int *count);
370
371 /**
372  * @brief Get the available size of a output object.
373  * @details -1 means that a TDM backend module doesn't define the value.
374  * @param[in] output A output object
375  * @param[out] min_w The minimum width which TDM can handle
376  * @param[out] min_h The minimum height which TDM can handle
377  * @param[out] max_w The maximum width which TDM can handle
378  * @param[out] max_h The maximum height which TDM can handle
379  * @param[out] preferred_align The preferred align width which TDM can handle
380  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
381  */
382 tdm_error
383 tdm_output_get_available_size(tdm_output *output, int *min_w, int *min_h,
384                                                           int *max_w, int *max_h, int *preferred_align);
385
386 /**
387  * @brief Get the available cursor size of a output object.
388  * @details -1 means that a TDM backend module doesn't define the value.
389  * @param[in] output A output object
390  * @param[out] min_w The minimum width which TDM can handle
391  * @param[out] min_h The minimum height which TDM can handle
392  * @param[out] max_w The maximum width which TDM can handle
393  * @param[out] max_h The maximum height which TDM can handle
394  * @param[out] preferred_align The preferred align width which TDM can handle
395  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
396  */
397 tdm_error
398 tdm_output_get_cursor_available_size(tdm_output *output, int *min_w, int *min_h,
399                                                                          int *max_w, int *max_h, int *preferred_align);
400
401 /**
402  * @brief Get the physical size of a output object.
403  * @param[in] output A output object
404  * @param[out] mmWidth The milimeter width
405  * @param[out] mmHeight The milimeter height
406  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
407  */
408 tdm_error
409 tdm_output_get_physical_size(tdm_output *output, unsigned int *mmWidth,
410                                                          unsigned int *mmHeight);
411
412 /**
413  * @brief Get the subpixel of a output object.
414  * @param[in] output A output object
415  * @param[out] subpixel The subpixel
416  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
417  */
418 tdm_error
419 tdm_output_get_subpixel(tdm_output *output, unsigned int *subpixel);
420
421 /**
422  * @brief Get the pipe of a output object.
423  * @param[in] output A output object
424  * @param[out] pipe The pipe
425  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
426  */
427 tdm_error
428 tdm_output_get_pipe(tdm_output *output, unsigned int *pipe);
429
430 /**
431  * @brief Get the index of a primary layer.
432  * @param[in] output A output object
433  * @param[out] index The primary layer index
434  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
435  */
436 tdm_error
437 tdm_output_get_primary_index(tdm_output *output, int *index);
438
439 /**
440  * @brief Set the property which has a given id.
441  * @param[in] output A output object
442  * @param[in] id The property id
443  * @param[in] value The value
444  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
445  */
446 tdm_error
447 tdm_output_set_property(tdm_output *output, unsigned int id, tdm_value value);
448
449 /**
450  * @brief Get the property which has a given id
451  * @param[in] output A output object
452  * @param[in] id The property id
453  * @param[out] value The value
454  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
455  */
456 tdm_error
457 tdm_output_get_property(tdm_output *output, unsigned int id, tdm_value *value);
458
459 /**
460  * @brief Wait for VBLANK
461  * @details After interval vblanks, a user vblank handler will be called.
462  * @param[in] output A output object
463  * @param[in] interval vblank interval
464  * @param[in] sync 0: asynchronous, 1:synchronous
465  * @param[in] func A user vblank handler
466  * @param[in] user_data The user data
467  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
468  * @see #tdm_output_vblank_handler
469  */
470 tdm_error
471 tdm_output_wait_vblank(tdm_output *output, int interval, int sync,
472                                            tdm_output_vblank_handler func, void *user_data);
473
474 /**
475  * @brief Commit changes for a output object
476  * @details After all change of a output object are applied, a user commit handler
477  * will be called.
478  * @param[in] output A output object
479  * @param[in] sync 0: asynchronous, 1:synchronous
480  * @param[in] func A user commit handler
481  * @param[in] user_data The user data
482  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
483  * @see #tdm_layer_commit
484  */
485 tdm_error
486 tdm_output_commit(tdm_output *output, int sync, tdm_output_commit_handler func,
487                                   void *user_data);
488
489 /**
490  * @brief Remove the user vblank handler
491  * @param[in] output A output object
492  * @param[in] func A user vblank handler
493  * @param[in] user_data The user data
494  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
495  */
496 tdm_error
497 tdm_output_remove_vblank_handler(tdm_output *output, tdm_output_vblank_handler func, void *user_data);
498
499 /**
500  * @brief Remove the user commit handler
501  * @param[in] output A output object
502  * @param[in] func A user commit handler
503  * @param[in] user_data The user data
504  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
505  */
506 tdm_error
507 tdm_output_remove_commit_handler(tdm_output *output, tdm_output_commit_handler func, void *user_data);
508
509 /**
510  * @brief Set one of available modes of a output object
511  * @param[in] output A output object
512  * @param[in] mode A output mode
513  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
514  */
515 tdm_error
516 tdm_output_set_mode(tdm_output *output, const tdm_output_mode *mode);
517
518 /**
519  * @brief Get the mode of a output object
520  * @param[in] output A output object
521  * @param[out] mode A output mode
522  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
523  */
524 tdm_error
525 tdm_output_get_mode(tdm_output *output, const tdm_output_mode **mode);
526
527 /**
528  * @brief Set DPMS of a output object
529  * @param[in] output A output object
530  * @param[in] dpms_value DPMS value
531  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
532  */
533 tdm_error
534 tdm_output_set_dpms(tdm_output *output, tdm_output_dpms dpms_value);
535
536 /**
537  * @brief Get DPMS of a output object
538  * @param[in] output A output object
539  * @param[out] dpms_value DPMS value
540  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
541  */
542 tdm_error
543 tdm_output_get_dpms(tdm_output *output, tdm_output_dpms *dpms_value);
544
545 /**
546  * @brief Create a capture object of a output object
547  * @param[in] output A output object
548  * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
549  * @return A capture object
550  * @see tdm_capture_destroy
551  */
552 tdm_capture *
553 tdm_output_create_capture(tdm_output *output, tdm_error *error);
554
555 /**
556  * @brief Creates a new window on the given display.
557  * @param[in] output A output object
558  * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
559  * @return A created window object
560  */
561 tdm_hwc_window *
562 tdm_output_create_hwc_window(tdm_output *output, tdm_error *error);
563
564 /**
565  * @brief Destroys the given window.
566  * @param[in] output A output object
567  * @param[in] window the pointer of the window to destroy
568  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
569  */
570 tdm_error
571 tdm_output_destroy_hwc_window(tdm_output *output, tdm_hwc_window *hwc_window);
572
573 /**
574  * @brief Set the client(relative to the TDM) target buffer
575  * @details Sets the buffer which will receive the output of client composition.
576  * Window marked as TDM_COMPOSITION_CLIENT or TDM_COMPOSITION_DEVICE_CANDIDATE
577  * will be composited into this buffer prior to the call to tdm_output_commit(),
578  * and windows not marked as TDM_COMPOSITION_CLIENT and
579  * TDM_COMPOSITION_DEVICE_CANDIDATE should be composited with this buffer by the
580  * device.
581  *
582  * The buffer handle provided may be null if no windows are being composited by
583  * the client. This must not result in an error (unless an invalid display
584  * handle is also provided).
585  *
586  * The damage parameter describes a surface damage region as defined in the
587  * description of tdm_hwc_window_set_surface_damage().
588  *
589  * Will be called before tdm_output_commit() if any of the layers are marked as
590  * TDM_COMPOSITION_CLIENT or TDM_COMPOSITION_DEVICE_CANDIDATE. If no layers are
591  * so marked, then it is not necessary to call this function. It is not necessary
592  * to call tdm_output_validate() after changing the target through this function.
593  * @param[in] output A output object
594  * @param[in] target The new target buffer
595  * @param[in] damage The surface damage region
596  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
597  */
598 tdm_error
599 tdm_output_set_client_target_buffer(tdm_output *output, tbm_surface_h target,
600                                                                         tdm_hwc_region damage);
601
602 /**
603  * @brief Validate the output
604  * @details Instructs the device to inspect all of the layer state and
605  * determine if there are any composition type changes necessary before
606  * presenting the output. Permitted changes are described in the definition
607  * of tdm_hwc_window_composition_t above.
608  * @param[in] output A output object
609  * @param[out] num_types The number of composition type changes required by
610  * the device; if greater than 0, the client must either set and validate new
611  * types, or call tdm_output_accept_changes() to accept the changes returned by
612  * tdm_output_get_changed_composition_types(); must be the same as the number of
613  * changes returned by tdm_output_get_changed_composition_types (see the
614  * declaration of that function for more information); pointer will be non-NULL
615  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
616  */
617 tdm_error
618 tdm_output_validate(tdm_output *output, uint32_t *num_types);
619
620 /**
621  * @brief Get changed composition types
622  * @details Retrieves the windows for which the device requires a different
623  * composition type than had been set prior to the last call to tdm_output_validate().
624  * The client will either update its state with these types and call
625  * tdm_output_accept_changes, or will set new types and attempt to validate the
626  * display again.
627  * windows and types may be NULL to retrieve the number of elements which
628  * will be returned. The number of elements returned must be the same as the
629  * value returned in num_types from the last call to tdm_output_validate().
630  * @param[in] output A output object
631  * @param[out] num_elements If windows or types were NULL, the number of layers
632  * and types which would have been returned; if both were non-NULL, the
633  * number of elements returned in layers and types, which must not exceed
634  * the value stored in num_elements prior to the call; pointer will be
635  * non-NULL
636  * @param[in] output A output object
637  * @param[out] windows An array of windows
638  * @param[out] composition_types An array of composition types, each corresponding
639  * to an element of windows
640  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
641  */
642 tdm_error
643 tdm_output_get_changed_composition_types(tdm_output *output,uint32_t *num_elements,
644                                                                                  tdm_hwc_window **hwc_window,
645                                                                                  tdm_hwc_window_composition_t *composition_types);
646
647 /**
648  * @brief Accepts the changes required by the device
649  * @details Accepts the changes required by the device from the previous
650  * tdm_output_validate() call (which may be queried using
651  * tdm_output_get_chaged_composition_types()) and revalidates the display. This
652  * function is equivalent to requesting the changed types from
653  * tdm_output_get_chaged_composition_types(), setting those types on the
654  * corresponding windows, and then calling tdm_output_validate again.
655  * After this call it must be valid to present this display. Calling this after
656  * tdm_output_validate() returns 0 changes must succeed with TDM_ERROR_NONE, but
657  * should have no other effect.
658  * @param[in] output A output object
659  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
660  */
661 tdm_error
662 tdm_output_accept_changes(tdm_output *output);
663
664 /**
665  * @brief Get a target surface queue
666  * @details Surfaces from target surface queue will receive the output of
667  * client composition. Window marked as TDM_COMPOSITION_CLIENT or
668  * TDM_COMPOSITION_DEVICE_CANDIDATE will be composited into this surfaces
669  * prior to the call to tdm_output_commit().
670  * @param[in] output A output object
671  * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
672  * @return A surface queue
673  */
674 tbm_surface_queue_h
675 tdm_output_get_target_surface_queue(tdm_output *output, tdm_error *error);
676
677 /**
678  * @brief Get the capabilities of a layer object.
679  * @param[in] layer A layer object
680  * @param[out] capabilities The capabilities of a layer object
681  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
682  */
683 tdm_error
684 tdm_layer_get_capabilities(tdm_layer *layer,
685                                                    tdm_layer_capability *capabilities);
686
687 /**
688  * @brief Get the available format array of a layer object.
689  * @param[in] layer A layer object
690  * @param[out] formats The available format array
691  * @param[out] count The count of formats
692  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
693  */
694 tdm_error
695 tdm_layer_get_available_formats(tdm_layer *layer, const tbm_format **formats,
696                                                                 int *count);
697
698 /**
699  * @brief Get the available property array of a layer object.
700  * @param[in] layer A layer object
701  * @param[out] props The available property array
702  * @param[out] count The count of properties
703  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
704  */
705 tdm_error
706 tdm_layer_get_available_properties(tdm_layer *layer, const tdm_prop **props,
707                                                                    int *count);
708
709 /**
710  * @brief Get the zpos of a layer object.
711  * @details
712  * - GRAPHIC layers have fixed zpos. It starts from 0. It's @b non-changeable.
713  * - But the zpos of VIDEO layers will be decided by a backend module side.
714  * - A frontend user only can set the relative zpos to VIDEO layers via #tdm_layer_set_video_pos
715  * - The zpos of video layers is less than GRAPHIC layers or more than GRAPHIC
716  * layers. ie, ..., -2, -1, 4, 5, ... (if 0 <= GRAPHIC layer's zpos < 4).
717  *   -------------------------------- graphic layer  3 <-- top most layer
718  *   -------------------------------- graphic layer  2
719  *   -------------------------------- graphic layer  1
720  *   -------------------------------- graphic layer  0
721  *   -------------------------------- video   layer -1
722  *   -------------------------------- video   layer -2 <-- lowest layer
723  * @param[in] layer A layer object
724  * @param[out] zpos The zpos
725  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
726  * @see tdm_layer_set_video_pos, tdm_layer_capability
727  */
728 tdm_error
729 tdm_layer_get_zpos(tdm_layer *layer, int *zpos);
730
731 /**
732  * @brief Set the property which has a given id.
733  * @param[in] layer A layer object
734  * @param[in] id The property id
735  * @param[in] value The value
736  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
737  */
738 tdm_error
739 tdm_layer_set_property(tdm_layer *layer, unsigned int id, tdm_value value);
740
741 /**
742  * @brief Get the property which has a given id.
743  * @param[in] layer A layer object
744  * @param[in] id The property id
745  * @param[out] value The value
746  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
747  */
748 tdm_error
749 tdm_layer_get_property(tdm_layer *layer, unsigned int id, tdm_value *value);
750
751 /**
752  * @brief Set the geometry information to a layer object
753  * @details The geometry information will be applied when the output object
754  * of a layer object is committed. If a layer has TDM_LAYER_CAPABILITY_NO_CROP
755  * capability, a layer will ignore the pos(crop) information of #tdm_info_layer's
756  * src_config.
757  * @param[in] layer A layer object
758  * @param[in] info The geometry information
759  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
760  * @see tdm_layer_commit
761  */
762 tdm_error
763 tdm_layer_set_info(tdm_layer *layer, tdm_info_layer *info);
764
765 /**
766  * @brief Get the geometry information to a layer object
767  * @param[in] layer A layer object
768  * @param[out] info The geometry information
769  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
770  */
771 tdm_error
772 tdm_layer_get_info(tdm_layer *layer, tdm_info_layer *info);
773
774 /**
775  * @brief Set a TDM buffer to a layer object
776  * @details A TDM buffer will be applied when the output object
777  * of a layer object is committed.
778  * @param[in] layer A layer object
779  * @param[in] buffer A TDM buffer
780  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
781  * @see tdm_layer_commit
782  */
783 tdm_error
784 tdm_layer_set_buffer(tdm_layer *layer, tbm_surface_h buffer);
785
786 /**
787  * @brief Unset a TDM buffer from a layer object
788  * @details When this function is called, a current showing buffer will be
789  * disappeared from screen. Then nothing is showing on a layer object.
790  * @param[in] layer A layer object
791  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
792  */
793 tdm_error
794 tdm_layer_unset_buffer(tdm_layer *layer);
795
796 /**
797  * @brief Commit changes for a layer object
798  * @details After all change of a layer object are applied, a user commit handler
799  * will be called.
800  * @param[in] layer A layer object
801  * @param[in] func A user commit handler
802  * @param[in] user_data The user data
803  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
804  */
805 tdm_error
806 tdm_layer_commit(tdm_layer *layer, tdm_layer_commit_handler func, void *user_data);
807
808 tdm_error
809 tdm_layer_is_committing(tdm_layer *layer, unsigned int *committing);
810
811 /**
812  * @brief Remove the user commit handler
813  * @param[in] layer A layer object
814  * @param[in] func A user commit handler
815  * @param[in] user_data The user data
816  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
817  */
818 tdm_error
819 tdm_layer_remove_commit_handler(tdm_layer *layer, tdm_layer_commit_handler func, void *user_data);
820
821 /**
822  * @brief Get a displaying TDM buffer from a layer object
823  * @details A displaying TDM buffer is a current showing buffer on screen
824  * that is set to layer object and applied output object of a layer object.
825  * @param[in] layer A layer object
826  * @return A TDM buffer if success. Otherwise, NULL.
827  */
828 tbm_surface_h
829 tdm_layer_get_displaying_buffer(tdm_layer *layer, tdm_error *error);
830
831 /**
832  * @brief Set a TBM surface_queue to a layer object
833  * @details A TBM surface_queue will be applied when the output object
834  * of a layer object is committed. and TDM layer will be automatically updated
835  * @param[in] layer A layer object
836  * @param[in] buffer_queue A TBM surface_queue
837  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
838  * @see tdm_layer_commit
839  */
840 tdm_error
841 tdm_layer_set_buffer_queue(tdm_layer *layer, tbm_surface_queue_h buffer_queue);
842
843 /**
844  * @brief Unset a TBM surface_queue from a layer object
845  * @details When this function is called, a current surface_queue will be
846  * disappeared from screen. Then nothing is showing on a layer object.
847  * @param[in] layer A layer object
848  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
849  */
850 tdm_error
851 tdm_layer_unset_buffer_queue(tdm_layer *layer);
852
853 /**
854  * @brief Check wheter a layer object is available for a frontend user to use.
855  * @details A layer object is not usable if a TDM buffer is showing on screen
856  * via this layer object. By calling #tdm_layer_unset_buffer, this layer object
857  * will become usable.
858  * @param[in] layer A layer object
859  * @param[out] usable 1 if usable, 0 if not usable
860  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
861  */
862 tdm_error
863 tdm_layer_is_usable(tdm_layer *layer, unsigned int *usable);
864
865 /**
866  * @brief Set the relative zpos to a VIDEO layer object
867  * @details The zpos value is less than the minimum zpos of GRAPHIC layers, or
868  * it is more than the maximum zpos of GRAPHIC layers.
869  * @param[in] layer A VIDEO layer object
870  * @param[in] zpos The zpos
871  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
872  * @see tdm_layer_get_zpos, tdm_layer_capability
873  */
874 tdm_error
875 tdm_layer_set_video_pos(tdm_layer *layer, int zpos);
876
877 /**
878  * @brief Create a capture object of a layer object
879  * @param[in] layer A layer object
880  * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
881  * @return A capture object
882  * @see tdm_capture_destroy
883  */
884 tdm_capture *
885 tdm_layer_create_capture(tdm_layer *layer, tdm_error *error);
886
887 /**
888  * @brief Get buffer flags from a layer object
889  * @param[in] layer A layer object
890  * @param[out] flags a buffer flags value
891  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
892  */
893 tdm_error
894 tdm_layer_get_buffer_flags(tdm_layer *layer, unsigned int *flags);
895
896 /**
897  * @brief Get a tbm surface queue for the window object
898  * @details These surfaces are used to composite by hardware a client content in
899  * the nocomp mode.
900  * @param[in] hwc_window A window object
901  * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
902  * @return A tbm surface queue
903  */
904 tbm_surface_queue_h
905 tdm_hwc_window_get_tbm_surface_queue(tdm_hwc_window *hwc_window, tdm_error *error);
906
907 /**
908  * @brief Sets the desired Z order of the given window. A window with
909  * a greater Z value occludes a window with a lesser Z value.
910  * @param[in] hwc_window A window object
911  * @param[in] z the new Z order
912  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
913  */
914 tdm_error
915 tdm_hwc_window_set_zpos(tdm_hwc_window *hwc_window, uint32_t zpos);
916
917 /**
918  * @brief Sets the desired composition type of the given window.
919  * @details During tdm_output_validate(), the device may request changes to
920  * the composition types of any of the layers as described in the definition
921  * of tdm_hwc_window_composition_t above.
922  * @param[in] hwc_window A window object
923  * @param[in] composition_type The new composition type
924  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
925  */
926 tdm_error
927 tdm_hwc_window_set_composition_type(tdm_hwc_window *hwc_window,
928                                                                         tdm_hwc_window_composition_t composition_type);
929
930 /**
931  * @brief Set the surface damage
932  * @details Provides the region of the source buffer which has been modified
933  * since the last frame. This region does not need to be validated before
934  * calling tdm_output_commit().
935  * Once set through this function, the damage region remains the same until a
936  * subsequent call to this function.
937  * If damage.num_rects > 0, then it may be assumed that any portion of the source
938  * buffer not covered by one of the rects has not been modified this frame. If
939  * damage.num_rects == 0, then the whole source buffer must be treated as if it
940  * has been modified.
941  * If the layer's contents are not modified relative to the prior frame, damage
942  * will contain exactly one empty rect([0, 0, 0, 0]).
943  * The damage rects are relative to the pre-transformed buffer, and their origin
944  * is the top-left corner. They will not exceed the dimensions of the latched
945  * buffer.
946  * @param[in] hwc_window A window object
947  * @param[in] damage The new surface damage region
948  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
949  */
950 tdm_error
951 tdm_hwc_window_set_surface_damage(tdm_hwc_window *hwc_window, tdm_hwc_region damage);
952
953 /**
954  * @brief Set the information to a window object
955  * @details The information will be applied when the output object of a window
956  * object is committed.
957  * @param[in] hwc_window A window object
958  * @param[in] info The information
959  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
960  */
961 tdm_error
962 tdm_hwc_window_set_info(tdm_hwc_window *hwc_window, tdm_hwc_window_info *info);
963
964 /**
965  * @brief Set a TBM buffer to a window object
966  * @details A TBM buffer will be applied when the output object of a layer
967  * object is committed.
968  * @param[in] hwc_window A layer object
969  * @param[in] buffer A TDM buffer
970  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
971  */
972 tdm_error
973 tdm_hwc_window_set_buffer(tdm_hwc_window *hwc_window, tbm_surface_h buffer);
974
975 /**
976  * @brief Destroy a pp object
977  * @param[in] pp A pp object
978  * @see tdm_display_create_pp
979  */
980 void
981 tdm_pp_destroy(tdm_pp *pp);
982
983 /**
984  * @brief Set the geometry information to a pp object
985  * @param[in] pp A pp object
986  * @param[in] info The geometry information
987  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
988  * @see tdm_pp_commit
989  */
990 tdm_error
991 tdm_pp_set_info(tdm_pp *pp, tdm_info_pp *info);
992
993 /**
994  * @brief Set the PP done handler to a pp object
995  * @details
996  * The user PP done handler will be called after converting a source buffer's image
997  * to a destination buffer.
998  * @param[in] pp A pp object
999  * @param[in] func A user PP done handler
1000  * @param[in] user_data The user data
1001  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1002  */
1003 tdm_error
1004 tdm_pp_set_done_handler(tdm_pp *pp, tdm_pp_done_handler func, void *user_data);
1005
1006 /**
1007  * @brief Attach a source buffer and a destination buffer to a pp object
1008  * @param[in] pp A pp object
1009  * @param[in] src A source buffer
1010  * @param[in] dst A destination buffer
1011  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1012  * @see tdm_pp_commit, tdm_pp_set_done_handler
1013  */
1014 tdm_error
1015 tdm_pp_attach(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst);
1016
1017 /**
1018  * @brief Commit changes for a pp object
1019  * @param[in] pp A pp object
1020  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1021  */
1022 tdm_error
1023 tdm_pp_commit(tdm_pp *pp);
1024
1025 /**
1026  * @brief Destroy a capture object
1027  * @param[in] capture A capture object
1028  * @see tdm_output_create_capture, tdm_layer_create_capture
1029  */
1030 void
1031 tdm_capture_destroy(tdm_capture *capture);
1032
1033 /**
1034  * @brief Set the geometry information to a capture object
1035  * @param[in] capture A capture object
1036  * @param[in] info The geometry information
1037  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1038  * @see tdm_capture_commit
1039  */
1040 tdm_error
1041 tdm_capture_set_info(tdm_capture *capture, tdm_info_capture *info);
1042
1043 /**
1044  * @brief Set the capture done handler to a capture object
1045  * @details
1046  * The user capture done handler will be called after capturing a screen into a
1047  * buffer.
1048  * @param[in] capture A capture object
1049  * @param[in] func A user capture done handler
1050  * @param[in] user_data The user data
1051  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1052  */
1053 tdm_error
1054 tdm_capture_set_done_handler(tdm_capture *capture, tdm_capture_done_handler func, void *user_data);
1055
1056 /**
1057  * @brief Attach a TDM buffer to a capture object
1058  * @param[in] capture A capture object
1059  * @param[in] buffer A TDM buffer
1060  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1061  * @see tdm_capture_commit, tdm_capture_set_done_handler
1062  */
1063 tdm_error
1064 tdm_capture_attach(tdm_capture *capture, tbm_surface_h buffer);
1065
1066 /**
1067  * @brief Commit changes for a capture object
1068  * @param[in] capture A capture object
1069  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1070  */
1071 tdm_error
1072 tdm_capture_commit(tdm_capture *capture);
1073
1074 /**
1075  * @brief The release handler of a TDM buffer
1076  * @param[in] buffer A TDM buffer
1077  * @param[in] user_data user data
1078  * @see tdm_buffer_add_release_handler, tdm_buffer_remove_release_handler
1079  */
1080 typedef void (*tdm_buffer_release_handler)(tbm_surface_h buffer,
1081                                                                                    void *user_data);
1082
1083 /**
1084  * @brief Add a release handler to a TDM buffer
1085  * @details
1086  * TDM has its own buffer release mechanism to let an frontend user know when a TDM buffer
1087  * becomes available for a next job. A TDM buffer can be used for TDM to show
1088  * it on screen or to capture an output and a layer. After all operations,
1089  * TDM will release it immediately when TDM doesn't need it any more.
1090  * @param[in] buffer A TDM buffer
1091  * @param[in] func A release handler
1092  * @param[in] user_data user data
1093  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1094  * @see tdm_buffer_remove_release_handler
1095  */
1096 tdm_error
1097 tdm_buffer_add_release_handler(tbm_surface_h buffer,
1098                                                            tdm_buffer_release_handler func, void *user_data);
1099
1100 /**
1101  * @brief Remove a release handler from a TDM buffer
1102  * @param[in] buffer A TDM buffer
1103  * @param[in] func A release handler
1104  * @param[in] user_data user data
1105  * @see tdm_buffer_add_release_handler
1106  */
1107 void
1108 tdm_buffer_remove_release_handler(tbm_surface_h buffer,
1109                                                                   tdm_buffer_release_handler func, void *user_data);
1110
1111 /**
1112  * @brief The handler of a vblank object
1113  * @see #tdm_vblank_wait, #tdm_vblank_wait_seq
1114  */
1115 typedef void (*tdm_vblank_handler)(tdm_vblank *vblank, tdm_error error, unsigned int sequence,
1116                                                                    unsigned int tv_sec, unsigned int tv_usec, void *user_data);
1117
1118 /**
1119  * @brief Set the vblank fps for the given PID and name.
1120  * @param[in] pid The process ID
1121  * @param[in] name The client vblank name
1122  * @param[in] fps The client vblank fps
1123  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1124  */
1125 tdm_error
1126 tdm_vblank_set_client_vblank_fps(unsigned int pid, const char *name, unsigned int fps);
1127
1128 /**
1129  * @brief Set the vblank global fps for the entire system.
1130  * @param[in] enable 1:enable, 0:disable
1131  * @param[in] fps The vblank global fps
1132  * @details
1133  * This global fps will be applied to all client's vblanks for all outputs.
1134  * If the client's vblank fps is less than this, the global fps will be ignored
1135  * for that client. And if a client calls #tdm_vblank_ignore_global_fps to ignore
1136  * the global fps, it will be ignored also.
1137  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1138  */
1139 tdm_error
1140 tdm_vblank_enable_global_fps(unsigned int enable, unsigned int fps);
1141
1142 /**
1143  * @brief Create a vblank object
1144  * @param[in] dpy A display object
1145  * @param[in] output A output object
1146  * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
1147  * @return A vblank object
1148  * @see #tdm_vblank_destroy
1149  */
1150 tdm_vblank*
1151 tdm_vblank_create(tdm_display *dpy, tdm_output *output, tdm_error *error);
1152
1153 /**
1154  * @brief Destroy a vblank object
1155  * @param[in] vblank A vblank object
1156  * @see #tdm_vblank_create
1157  */
1158 void
1159 tdm_vblank_destroy(tdm_vblank *vblank);
1160
1161 /**
1162  * @brief Set the name to a vblank object
1163  * @details The default name is "unknown"
1164  * @param[in] vblank A vblank object
1165  * @param[in] name vblank name
1166  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1167  */
1168 tdm_error
1169 tdm_vblank_set_name(tdm_vblank *vblank, const char *name);
1170
1171 /**
1172  * @brief Get the name for a vblank object
1173  * @details The default name is "unknown"
1174  * @param[in] vblank A vblank object
1175  * @param[out] name vblank name
1176  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1177  */
1178 tdm_error
1179 tdm_vblank_get_name(tdm_vblank *vblank, const char **name);
1180
1181 /**
1182  * @brief Set the fps to a vblank object
1183  * @details Default is the @b vertical @b refresh @b rate of the given output.
1184  * @param[in] vblank A vblank object
1185  * @param[in] fps over 0
1186  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1187  */
1188 tdm_error
1189 tdm_vblank_set_fps(tdm_vblank *vblank, unsigned int fps);
1190
1191 /**
1192  * @brief Get the fps for a vblank object
1193  * @param[in] vblank A vblank object
1194  * @param[out] fps over 0
1195  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1196  */
1197 tdm_error
1198 tdm_vblank_get_fps(tdm_vblank *vblank, unsigned int *fps);
1199
1200 /**
1201  * @brief Ignore the vblank global fps
1202  * @details
1203  * The global fps will be applied to all client's vblanks for all outputs.
1204  * If the client's vblank fps is less than this, the global fps will be ignored
1205  * for that client. And if a client calls #tdm_vblank_ignore_global_fps to ignore
1206  * the global fps, it will be ignored also.
1207  * @param[in] vblank A vblank object
1208  * @param[in] ignore 1: ignore 0:not ignore(default)
1209  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1210  */
1211 tdm_error
1212 tdm_vblank_ignore_global_fps(tdm_vblank *vblank, unsigned int ignore);
1213
1214 /**
1215  * @brief Set the offset(milli-second) to a vblank object
1216  * @details Default is @b 0.
1217  * @param[in] vblank A vblank object
1218  * @param[in] offset the offset(milli-second)
1219  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1220  */
1221 tdm_error
1222 tdm_vblank_set_offset(tdm_vblank *vblank, int offset);
1223
1224 /**
1225  * @brief Get the offset(milli-second) for a vblank object
1226  * @param[in] vblank A vblank object
1227  * @param[out] offset the offset(milli-second)
1228  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1229  */
1230 tdm_error
1231 tdm_vblank_get_offset(tdm_vblank *vblank, int *offset);
1232
1233 /**
1234  * @brief Enable/Disable the fake vblank to a vblank object
1235  * @details
1236  * If enable_fake == 0, #tdm_vblank_wait will return TDM_ERROR_DPMS_OFF
1237  * when DPMS off. Otherwise, #tdm_vblank_wait will return TDM_ERROR_NONE
1238  * as success.
1239  * @param[in] vblank A vblank object
1240  * @param[in] enable_fake 1:enable, 0:disable
1241  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1242  */
1243 tdm_error
1244 tdm_vblank_set_enable_fake(tdm_vblank *vblank, unsigned int enable_fake);
1245
1246 /**
1247  * @brief Get the fake vblank
1248  * @param[in] vblank A vblank object
1249  * @param[out] enable_fake 1:enable, 0:disable
1250  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1251  */
1252 tdm_error
1253 tdm_vblank_get_enable_fake(tdm_vblank *vblank, unsigned int *enable_fake);
1254
1255 /**
1256  * @brief Wait for a vblank
1257  * @details
1258  * Once #tdm_vblank_wait returns TDM_ERROR_NONE, the user vblank handler(#tdm_vblank_handler)
1259  * SHOULD be called after the given interval. \n
1260  * The sequence value of tdm_vblank_handler is the relative value of fps.
1261  * If fps = 10, this sequence value should be increased by 10 during 1 second.
1262  * @param[in] vblank A vblank object
1263  * @param[in] req_sec The vblank request time(second)
1264  * @param[in] req_usec The vblank request time(micro-second)
1265  * @param[in] interval The vblank interval
1266  * @param[in] func The user vblank handler
1267  * @param[in] user_data The user data
1268  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1269  */
1270 tdm_error
1271 tdm_vblank_wait(tdm_vblank *vblank, unsigned int req_sec, unsigned int req_usec,
1272                                 unsigned int interval, tdm_vblank_handler func, void *user_data);
1273
1274 /**
1275  * @brief Wait for a vblank with the target sequence number
1276  * @param[in] vblank A vblank object
1277  * @param[in] req_sec The vblank request time(second)
1278  * @param[in] req_usec The vblank request time(micro-second)
1279  * @param[in] sequence The target sequence number
1280  * @param[in] func The user client vblank handler
1281  * @param[in] user_data The user data
1282  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1283  */
1284 tdm_error
1285 tdm_vblank_wait_seq(tdm_vblank *vblank, unsigned int req_sec, unsigned int req_usec,
1286                                         unsigned int sequence, tdm_vblank_handler func, void *user_data);
1287
1288 #ifdef __cplusplus
1289 }
1290 #endif
1291
1292 #endif /* _TDM_H_ */