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