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