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