3f0b89dd67e412467799cd7db366ca030004e795
[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 The client composites the tdm_hwd_windows which have
860  * TDM_COMPOSITE_CLIENT types on the buffer from this target buffer queue.
861  * Then, the client set the buffer by calling tdm_hwc_set_client_target_buffer.
862  * @param[in] output A output object
863  * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
864  * @return A buffer queue
865  * @since 2.0.0
866  */
867 tbm_surface_queue_h
868 tdm_hwc_get_client_target_buffer_queue(tdm_hwc *hwc, tdm_error *error);
869
870 /**
871  * @brief Set the client(relative to the TDM) target buffer
872  * @details This function lets the backend know the target buffer.
873  * The target buffer contains the result of the gl composition with the
874  * tdm_hwc_windows which marked as TDM_COMPOSITION_CLIENT.
875  * @param[in] hwc A output hwc
876  * @param[in] target_buffer The new target buffer
877  * @param[in] damage The buffer damage region
878  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
879  * @since 2.0.0
880  */
881 tdm_error
882 tdm_hwc_set_client_target_buffer(tdm_hwc *hwc, tbm_surface_h target_buffer, tdm_region damage);
883
884 /**
885  * @brief Validate the output
886  * @details Instructs the backend to inspect all of the hw layer state and
887  * determine if there are any composition type changes necessary before
888  * presenting the hwc.
889  * @param[in] hwc A hwc object
890  * @param[in] composited_wnds the hwc window list which is visible.
891  * @param[in] num_wnds the number of the visible windows in the composited_wnds
892  * @param[out] num_types The number of composition type changes
893  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
894  * @remark
895  * The backend has to return the num_types when the assgined comopsite types of
896  * the tdm_hwc_windows in the composited_wnds. If the num_types is greater than
897  * 0, the cleint must get the changed composite types of the tdm_hwc_windows
898  * and change the comopsite types
899  * @since 2.0.0
900  */
901 tdm_error
902 tdm_hwc_validate(tdm_hwc *hwc, tdm_hwc_window **composited_wnds, uint32_t num_wnds,
903                         uint32_t *num_types);
904
905 /**
906  * @brief Get changed composition types
907  * @details Retrieves the windows for which the backend requires a different
908  * composition types that had been set prior to the last call to tdm_hwc_validate().
909  * The client will either update its state with these types and call
910  * tdm_hwc_accept_changes, or will set new types and attempt to validate the
911  * display again. The number of elements returned must be the same as the
912  * value returned in num_types from the last call to tdm_hwc_validate().
913  * @param[in] hwc A hwc object
914  * @param[out] num_elements the number of hwc_windows
915  * @param[out] windows An array of windows
916  * @param[out] composition_types An array of composition types, each corresponding
917  * to an element of windows
918  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
919  * @remark
920  * @since 2.0.0
921  */
922 tdm_error
923 tdm_hwc_get_changed_composition_types(tdm_hwc *hwc, uint32_t *num_elements,
924                                                                         tdm_hwc_window **hwc_window,
925                                                                         tdm_hwc_window_composition *composition_types);
926
927 /**
928  * @brief Accepts the changes required by the backend
929  * @details Accepts the changes required by the backend from the previous
930  * tdm_hwc_validate() and tdm_hwc_get_chaged_composition_types().
931  * @param[in] hwc A hwc object
932  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
933  * @since 2.0.0
934  */
935 tdm_error
936 tdm_hwc_accept_changes(tdm_hwc *hwc);
937
938 /**
939  * @brief Commit changes for a hwc
940  * @details After all change of a window object are applied, a user commit handler
941  * will be called.
942  * @param[in] hwc A hwc object
943  * @param[in] sync 0: asynchronous, 1:synchronous
944  * @param[in] func A user commit handler
945  * @param[in] user_data The user data
946  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
947  */
948 tdm_error
949 tdm_hwc_commit(tdm_hwc *hwc, int sync, tdm_hwc_commit_handler func, void *user_data);
950
951 /**
952  * @brief Destroys the given window.
953  * @param[in] window the pointer of the window to destroy
954  * @since 2.0.0
955  */
956 void
957 tdm_hwc_window_destroy(tdm_hwc_window *hwc_window);
958
959 /**
960  * @brief Acquire a buffer queue for the window object
961  * @details These buffers are used to composite by hardware a client content in
962  * the nocomp mode.
963  * @param[in] hwc_window A window object
964  * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
965  * @return A tbm buffer queue
966  * @since 2.0.0
967  */
968 tbm_surface_queue_h
969 tdm_hwc_window_acquire_buffer_queue(tdm_hwc_window *hwc_window, tdm_error *error);
970
971 /**
972  * @brief Release a buffer queue for the window object
973  * @details Release buffer queue when the client no longer uses buferrs of queue.
974  * @param[in] hwc_window A window object
975  * @param[in] A tbm buffer queue
976  * @since 2.0.0
977  */
978 void
979 tdm_hwc_window_release_buffer_queue(tdm_hwc_window *hwc_window, tbm_surface_queue_h queue);
980
981 /**
982  * @brief Sets the desired composition type of the given window.
983  * @details During tdm_hwc_validate(), the backend may request changes to
984  * the composition types of any of the layers as described in the definition
985  * of tdm_hwc_window_composition_t above.
986  * @param[in] hwc_window A window object
987  * @param[in] composition_type The new composition type
988  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
989  * @since 2.0.0
990  */
991 tdm_error
992 tdm_hwc_window_set_composition_type(tdm_hwc_window *hwc_window,
993                                                                         tdm_hwc_window_composition composition_type);
994
995 /**
996  * @brief Set the buffer damage
997  * @details Provides the region of the source buffer which has been modified
998  * since the last frame. This region does not need to be validated before
999  * calling tdm_output_commit().
1000  * Once set through this function, the damage region remains the same until a
1001  * subsequent call to this function.
1002  * If damage.num_rects > 0, then it may be assumed that any portion of the source
1003  * buffer not covered by one of the rects has not been modified this frame. If
1004  * damage.num_rects == 0, then the whole source buffer must be treated as if it
1005  * has been modified.
1006  * If the layer's contents are not modified relative to the prior frame, damage
1007  * will contain exactly one empty rect([0, 0, 0, 0]).
1008  * The damage rects are relative to the pre-transformed buffer, and their origin
1009  * is the top-left corner. They will not exceed the dimensions of the latched
1010  * buffer.
1011  * @param[in] hwc_window A window object
1012  * @param[in] damage The new buffer damage region
1013  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1014  * @since 2.0.0
1015  */
1016 tdm_error
1017 tdm_hwc_window_set_buffer_damage(tdm_hwc_window *hwc_window, tdm_region damage);
1018
1019 /**
1020  * @brief Set the information to a window object
1021  * @details The information will be applied when the hwc object is committed.
1022  * @param[in] hwc_window A window object
1023  * @param[in] info The information
1024  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1025  * @since 2.0.0
1026  */
1027 tdm_error
1028 tdm_hwc_window_set_info(tdm_hwc_window *hwc_window, tdm_hwc_window_info *info);
1029
1030 /**
1031  * @brief Set a TBM buffer to a window object
1032  * @details A TBM buffer will be applied when the output object of a layer
1033  * object is committed.
1034  * @param[in] hwc_window A window object
1035  * @param[in] buffer A TBM buffer
1036  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1037  * @since 2.0.0
1038  */
1039 tdm_error
1040 tdm_hwc_window_set_buffer(tdm_hwc_window *hwc_window, tbm_surface_h buffer);
1041
1042 /**
1043  * @brief Get the property which has a given id.
1044  * @param[in] hwc_window A hwc window object
1045  * @param[in] id The property id
1046  * @param[out] value The value of the propery id
1047  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1048  */
1049 tdm_error
1050 tdm_hwc_window_get_property(tdm_hwc_window *hwc_window, uint32_t id, tdm_value *value);
1051
1052 /**
1053  * @brief Set the property which has a given id.
1054  * @param[in] hwc_window  A hwc window object
1055  * @param[in] id The property id
1056  * @param[in] value The value of the propery id
1057  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1058  */
1059 tdm_error
1060 tdm_hwc_window_set_property(tdm_hwc_window *hwc_window, uint32_t id, tdm_value value);
1061
1062 /**
1063  * @brief Get the constraints of hwc_window
1064  * @param[in] hwc_window A hwc window object
1065  * @param[out] constraints The tdm_hwc_window_constraint types
1066  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1067  */
1068 tdm_error
1069 tdm_hwc_window_get_constraints(tdm_hwc_window *hwc_window, int *constraints);
1070
1071 // TODO : this will be removed...
1072 #define TDM_PREPARATION_BUFFER_QUEUE 1000
1073 #define TDM_PREPARATION_NONE 1001
1074
1075 tdm_error
1076 tdm_hwc_window_get_preparation_types(tdm_hwc_window *hwc_window, int *preparation_types);
1077 // TODO
1078
1079 /**
1080  * @brief Destroy a pp object
1081  * @param[in] pp A pp object
1082  * @see tdm_display_create_pp
1083  */
1084 void
1085 tdm_pp_destroy(tdm_pp *pp);
1086
1087 /**
1088  * @brief Set the geometry information to a pp object
1089  * @param[in] pp A pp object
1090  * @param[in] info The geometry information
1091  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1092  * @see tdm_pp_commit
1093  */
1094 tdm_error
1095 tdm_pp_set_info(tdm_pp *pp, tdm_info_pp *info);
1096
1097 /**
1098  * @brief Set the PP done handler to a pp object
1099  * @details
1100  * The user PP done handler will be called after converting a source buffer's image
1101  * to a destination buffer.
1102  * @param[in] pp A pp object
1103  * @param[in] func A user PP done handler
1104  * @param[in] user_data The user data
1105  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1106  */
1107 tdm_error
1108 tdm_pp_set_done_handler(tdm_pp *pp, tdm_pp_done_handler func, void *user_data);
1109
1110 /**
1111  * @brief Attach a source buffer and a destination buffer to a pp object
1112  * @param[in] pp A pp object
1113  * @param[in] src A source buffer
1114  * @param[in] dst A destination buffer
1115  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1116  * @see tdm_pp_commit, tdm_pp_set_done_handler
1117  */
1118 tdm_error
1119 tdm_pp_attach(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst);
1120
1121 /**
1122  * @brief Commit changes for a pp object
1123  * @param[in] pp A pp object
1124  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1125  */
1126 tdm_error
1127 tdm_pp_commit(tdm_pp *pp);
1128
1129 /**
1130  * @brief Destroy a capture object
1131  * @param[in] capture A capture object
1132  * @see tdm_output_create_capture, tdm_layer_create_capture
1133  */
1134 void
1135 tdm_capture_destroy(tdm_capture *capture);
1136
1137 /**
1138  * @brief Set the geometry information to a capture object
1139  * @param[in] capture A capture object
1140  * @param[in] info The geometry information
1141  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1142  * @see tdm_capture_commit
1143  */
1144 tdm_error
1145 tdm_capture_set_info(tdm_capture *capture, tdm_info_capture *info);
1146
1147 /**
1148  * @brief Set the capture done handler to a capture object
1149  * @details
1150  * The user capture done handler will be called after capturing a screen into a
1151  * buffer.
1152  * @param[in] capture A capture object
1153  * @param[in] func A user capture done handler
1154  * @param[in] user_data The user data
1155  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1156  */
1157 tdm_error
1158 tdm_capture_set_done_handler(tdm_capture *capture, tdm_capture_done_handler func, void *user_data);
1159
1160 /**
1161  * @brief Attach a TDM buffer to a capture object
1162  * @param[in] capture A capture object
1163  * @param[in] buffer A TDM buffer
1164  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1165  * @see tdm_capture_commit, tdm_capture_set_done_handler
1166  */
1167 tdm_error
1168 tdm_capture_attach(tdm_capture *capture, tbm_surface_h buffer);
1169
1170 /**
1171  * @brief Commit changes for a capture object
1172  * @param[in] capture A capture object
1173  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1174  */
1175 tdm_error
1176 tdm_capture_commit(tdm_capture *capture);
1177
1178 /**
1179  * @brief The release handler of a TDM buffer
1180  * @param[in] buffer A TDM buffer
1181  * @param[in] user_data user data
1182  * @see tdm_buffer_add_release_handler, tdm_buffer_remove_release_handler
1183  */
1184 typedef void (*tdm_buffer_release_handler)(tbm_surface_h buffer,
1185                                                                                    void *user_data);
1186
1187 /**
1188  * @brief Add a release handler to a TDM buffer
1189  * @details
1190  * TDM has its own buffer release mechanism to let an frontend user know when a TDM buffer
1191  * becomes available for a next job. A TDM buffer can be used for TDM to show
1192  * it on screen or to capture an output and a layer. After all operations,
1193  * TDM will release it immediately when TDM doesn't need it any more.
1194  * @param[in] buffer A TDM buffer
1195  * @param[in] func A release handler
1196  * @param[in] user_data user data
1197  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1198  * @see tdm_buffer_remove_release_handler
1199  */
1200 tdm_error
1201 tdm_buffer_add_release_handler(tbm_surface_h buffer,
1202                                                            tdm_buffer_release_handler func, void *user_data);
1203
1204 /**
1205  * @brief Remove a release handler from a TDM buffer
1206  * @param[in] buffer A TDM buffer
1207  * @param[in] func A release handler
1208  * @param[in] user_data user data
1209  * @see tdm_buffer_add_release_handler
1210  */
1211 void
1212 tdm_buffer_remove_release_handler(tbm_surface_h buffer,
1213                                                                   tdm_buffer_release_handler func, void *user_data);
1214
1215 /**
1216  * @brief The handler of a vblank object
1217  * @see #tdm_vblank_wait, #tdm_vblank_wait_seq
1218  */
1219 typedef void (*tdm_vblank_handler)(tdm_vblank *vblank, tdm_error error, unsigned int sequence,
1220                                                                    unsigned int tv_sec, unsigned int tv_usec, void *user_data);
1221
1222 /**
1223  * @brief Set the vblank fps for the given PID and name.
1224  * @param[in] pid The process ID
1225  * @param[in] name The client vblank name
1226  * @param[in] fps The client vblank fps
1227  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1228  */
1229 tdm_error
1230 tdm_vblank_set_client_vblank_fps(unsigned int pid, const char *name, unsigned int fps);
1231
1232 /**
1233  * @brief Set the ignore global fps for the given PID and name.
1234  * @param[in] pid The process ID
1235  * @param[in] name The client vblank name
1236  * @param[in] ignore 1: ignore 0:not ignore(default)
1237  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1238  */
1239 tdm_error
1240 tdm_vblank_set_client_ignore_global_fps(unsigned int pid, const char *name, unsigned int ignore);
1241
1242 /**
1243  * @brief Set the vblank global fps for the entire system.
1244  * @param[in] enable 1:enable, 0:disable
1245  * @param[in] fps The vblank global fps
1246  * @details
1247  * This global fps will be applied to all client's vblanks for all outputs.
1248  * If the client's vblank fps is less than this, the global fps will be ignored
1249  * for that client. And if a client calls #tdm_vblank_ignore_global_fps to ignore
1250  * the global fps, it will be ignored also.
1251  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1252  */
1253 tdm_error
1254 tdm_vblank_enable_global_fps(unsigned int enable, unsigned int fps);
1255
1256 /**
1257  * @brief Add the vblank create handler.
1258  * @param[in] dpy A display object
1259  * @param[in] func The user vblank create handler
1260  * @param[in] user_data The user data
1261  * @details
1262  * The user vblank create handler will be called when new vblank object created.
1263  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1264  */
1265 tdm_error
1266 tdm_vblank_add_create_handler(tdm_display *dpy, tdm_vblank_create_handler func, void *user_data);
1267
1268 /**
1269  * @brief Remove the vblank create handler.
1270  * @param[in] dpy A display object
1271  * @param[in] func The user vblank create handler
1272  * @param[in] user_data The user data
1273  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1274  */
1275 void
1276 tdm_vblank_remove_create_handler(tdm_display *dpy, tdm_vblank_create_handler func, void *user_data);
1277
1278 /**
1279  * @brief Create a vblank object
1280  * @param[in] dpy A display object
1281  * @param[in] output A output object
1282  * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
1283  * @return A vblank object
1284  * @see #tdm_vblank_destroy
1285  */
1286 tdm_vblank*
1287 tdm_vblank_create(tdm_display *dpy, tdm_output *output, tdm_error *error);
1288
1289 /**
1290  * @brief Destroy a vblank object
1291  * @param[in] vblank A vblank object
1292  * @see #tdm_vblank_create
1293  */
1294 void
1295 tdm_vblank_destroy(tdm_vblank *vblank);
1296
1297 /**
1298  * @brief Get a output object of a vblank object
1299  * @param[in] vblank A vblank object
1300  * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
1301  * @return A TDM output object if success. Otherwise, NULL.
1302  * @see #tdm_vblank_create
1303  */
1304 tdm_output *
1305 tdm_vblank_get_output(tdm_vblank *vblank, tdm_error *error);
1306
1307 /**
1308  * @brief Get the client PID for a vblank object
1309  * @param[in] vblank A vblank object
1310  * @param[out] pid PID of vblank's client
1311  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1312  */
1313 tdm_error
1314 tdm_vblank_get_client_pid(tdm_vblank *vblank, pid_t *pid);
1315
1316 /**
1317  * @brief Set the name to a vblank object
1318  * @details The default name is "unknown"
1319  * @param[in] vblank A vblank object
1320  * @param[in] name vblank name
1321  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1322  */
1323 tdm_error
1324 tdm_vblank_set_name(tdm_vblank *vblank, const char *name);
1325
1326 /**
1327  * @brief Get the name for a vblank object
1328  * @details The default name is "unknown"
1329  * @param[in] vblank A vblank object
1330  * @param[out] name vblank name
1331  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1332  */
1333 tdm_error
1334 tdm_vblank_get_name(tdm_vblank *vblank, const char **name);
1335
1336 /**
1337  * @brief Set the fps to a vblank object
1338  * @details Default is the @b vertical @b refresh @b rate of the given output.
1339  * It could be ignored when the fixed fps is set by #tdm_vblank_set_fixed_fps
1340  * @param[in] vblank A vblank object
1341  * @param[in] fps over 0
1342  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1343  */
1344 tdm_error
1345 tdm_vblank_set_fps(tdm_vblank *vblank, unsigned int fps);
1346
1347 /**
1348  * @brief Get the fps for a vblank object
1349  * @param[in] vblank A vblank object
1350  * @param[out] fps over 0
1351  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1352  */
1353 tdm_error
1354 tdm_vblank_get_fps(tdm_vblank *vblank, unsigned int *fps);
1355
1356 /**
1357  * @brief Set the fixed fps to a vblank object
1358  * @details
1359  * It could be ignored when the global fps is set by #tdm_vblank_enable_global_fps
1360  * @param[in] vblank A vblank object
1361  * @param[in] fps over 0
1362  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1363  */
1364 tdm_error
1365 tdm_vblank_set_fixed_fps(tdm_vblank *vblank, unsigned int fps);
1366
1367 /**
1368  * @brief Ignore the vblank global fps
1369  * @details
1370  * The global fps will be applied to all client's vblanks for all outputs.
1371  * If the client's vblank fps is less than this, the global fps will be ignored
1372  * for that client. And if a client calls #tdm_vblank_ignore_global_fps to ignore
1373  * the global fps, it will be ignored also.
1374  * @param[in] vblank A vblank object
1375  * @param[in] ignore 1: ignore 0:not ignore(default)
1376  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1377  */
1378 tdm_error
1379 tdm_vblank_ignore_global_fps(tdm_vblank *vblank, unsigned int ignore);
1380
1381 /**
1382  * @brief Set the offset(milli-second) to a vblank object
1383  * @details Default is @b 0.
1384  * @param[in] vblank A vblank object
1385  * @param[in] offset the offset(milli-second)
1386  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1387  */
1388 tdm_error
1389 tdm_vblank_set_offset(tdm_vblank *vblank, int offset);
1390
1391 /**
1392  * @brief Get the offset(milli-second) for a vblank object
1393  * @param[in] vblank A vblank object
1394  * @param[out] offset the offset(milli-second)
1395  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1396  */
1397 tdm_error
1398 tdm_vblank_get_offset(tdm_vblank *vblank, int *offset);
1399
1400 /**
1401  * @brief Enable/Disable the fake vblank to a vblank object
1402  * @details
1403  * If enable_fake == 0, #tdm_vblank_wait will return TDM_ERROR_DPMS_OFF
1404  * when DPMS off. Otherwise, #tdm_vblank_wait will return TDM_ERROR_NONE
1405  * as success.
1406  * @param[in] vblank A vblank object
1407  * @param[in] enable_fake 1:enable, 0:disable
1408  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1409  */
1410 tdm_error
1411 tdm_vblank_set_enable_fake(tdm_vblank *vblank, unsigned int enable_fake);
1412
1413 /**
1414  * @brief Get the fake vblank
1415  * @param[in] vblank A vblank object
1416  * @param[out] enable_fake 1:enable, 0:disable
1417  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1418  */
1419 tdm_error
1420 tdm_vblank_get_enable_fake(tdm_vblank *vblank, unsigned int *enable_fake);
1421
1422 /**
1423  * @brief Wait for a vblank
1424  * @details
1425  * Once #tdm_vblank_wait returns TDM_ERROR_NONE, the user vblank handler(#tdm_vblank_handler)
1426  * SHOULD be called after the given interval. \n
1427  * The sequence value of tdm_vblank_handler is the relative value of fps.
1428  * If fps = 10, this sequence value should be increased by 10 during 1 second.
1429  * @param[in] vblank A vblank object
1430  * @param[in] req_sec The vblank request time(second)
1431  * @param[in] req_usec The vblank request time(micro-second)
1432  * @param[in] interval The vblank interval
1433  * @param[in] func The user vblank handler
1434  * @param[in] user_data The user data
1435  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1436  */
1437 tdm_error
1438 tdm_vblank_wait(tdm_vblank *vblank, unsigned int req_sec, unsigned int req_usec,
1439                                 unsigned int interval, tdm_vblank_handler func, void *user_data);
1440
1441 /**
1442  * @brief Wait for a vblank with the target sequence number
1443  * @param[in] vblank A vblank object
1444  * @param[in] req_sec The vblank request time(second)
1445  * @param[in] req_usec The vblank request time(micro-second)
1446  * @param[in] sequence The target sequence number
1447  * @param[in] func The user client vblank handler
1448  * @param[in] user_data The user data
1449  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1450  */
1451 tdm_error
1452 tdm_vblank_wait_seq(tdm_vblank *vblank, unsigned int req_sec, unsigned int req_usec,
1453                                         unsigned int sequence, tdm_vblank_handler func, void *user_data);
1454
1455 #ifdef __cplusplus
1456 }
1457 #endif
1458
1459 #endif /* _TDM_H_ */