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