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