add tdm_layer_get_buffer_flags
[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 <sc1.lim@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 <tbm_surface.h>
41 #include <tbm_surface_queue.h>
42 #include <tbm_surface_internal.h>
43
44 #include "tdm_types.h"
45
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49
50 /**
51  * @file tdm.h
52  * @brief The header file for a frontend user.
53  * @par Example
54  * @code
55  * #include <tdm.h>    //for a frontend user
56  * @endcode
57  */
58
59 /**
60  * @brief The display capability enumeration
61  */
62 typedef enum {
63         TDM_DISPLAY_CAPABILITY_PP       = (1 << 0), /**< if hardware supports pp operation */
64         TDM_DISPLAY_CAPABILITY_CAPTURE  = (1 << 1), /**< if hardware supports capture operation */
65 } tdm_display_capability;
66
67 /**
68  * @brief The output change enumeration of #tdm_output_change_handler
69  */
70 typedef enum {
71         TDM_OUTPUT_CHANGE_CONNECTION    = (1 << 0), /**< connection chagne */
72         TDM_OUTPUT_CHANGE_DPMS          = (1 << 1), /**< dpms change */
73 } tdm_output_change_type;
74
75 /**
76  * @brief The output change handler
77  * @details This handler will be called when the status of a output object is
78  * changed in runtime.
79  */
80 typedef void (*tdm_output_change_handler)(tdm_output *output,
81                                                                                   tdm_output_change_type type,
82                                                                                   tdm_value value,
83                                                                                   void *user_data);
84
85 /**
86  * @brief Initialize a display object
87  * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
88  * @return A display object
89  * @see tdm_display_deinit
90  */
91 tdm_display *
92 tdm_display_init(tdm_error *error);
93
94 /**
95  * @brief Deinitialize a display object
96  * @param[in] dpy A display object
97  * @see tdm_display_init
98  */
99 void
100 tdm_display_deinit(tdm_display *dpy);
101
102 /**
103  * @brief Update a display object
104  * @details
105  * When new output is connected, a frontend user need to call this function.
106  * And a frontend user can the new output information with tdm_output_get_xxx functions.
107  * @param[in] dpy A display object
108  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
109  */
110 tdm_error
111 tdm_display_update(tdm_display *dpy);
112
113 /**
114  * @brief Get the file descriptor
115  * @details TDM handles the events of fd with #tdm_display_handle_events.
116  * @param[in] dpy A display object
117  * @param[out] fd The file descriptor
118  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
119  * @see tdm_display_handle_events
120  */
121 tdm_error
122 tdm_display_get_fd(tdm_display *dpy, int *fd);
123
124 /**
125  * @brief Handle the events
126  * @param[in] dpy A display object
127  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
128  * @see tdm_display_get_fd
129  */
130 tdm_error
131 tdm_display_handle_events(tdm_display *dpy);
132
133 /**
134  * @brief Get the capabilities of a display object.
135  * @details A frontend user can get whether TDM supports pp/capture functionality with this function.
136  * @param[in] dpy A display object
137  * @param[out] capabilities The capabilities of a display object
138  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
139  */
140 tdm_error
141 tdm_display_get_capabilities(tdm_display *dpy,
142                                                          tdm_display_capability *capabilities);
143
144 /**
145  * @brief Get the pp capabilities of a display object.
146  * @param[in] dpy A display object
147  * @param[out] capabilities The pp capabilities
148  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
149  */
150 tdm_error
151 tdm_display_get_pp_capabilities(tdm_display *dpy,
152                                                                 tdm_pp_capability *capabilities);
153
154 /**
155  * @brief Get the pp available format array of a display object.
156  * @param[in] dpy A display object
157  * @param[out] formats The pp available format array
158  * @param[out] count The count of formats
159  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
160  */
161 tdm_error
162 tdm_display_get_pp_available_formats(tdm_display *dpy,
163                                                                          const tbm_format **formats, int *count);
164
165 /**
166  * @brief Get the pp available size of a display object.
167  * @details -1 means that a TDM backend module doesn't define the value.
168  * @param[in] dpy A display object
169  * @param[out] min_w The minimum width which TDM can handle
170  * @param[out] min_h The minimum height which TDM can handle
171  * @param[out] max_w The maximum width which TDM can handle
172  * @param[out] max_h The maximum height which TDM can handle
173  * @param[out] preferred_align The preferred align width which TDM can handle
174  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
175  */
176 tdm_error
177 tdm_display_get_pp_available_size(tdm_display *dpy, int *min_w, int *min_h,
178                                                                   int *max_w, int *max_h, int *preferred_align);
179
180 /**
181  * @brief Get the capture capabilities of a display object.
182  * @param[in] dpy A display object
183  * @param[out] capabilities The capture capabilities
184  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
185  */
186 tdm_error
187 tdm_display_get_capture_capabilities(tdm_display *dpy,
188                                                                          tdm_capture_capability *capabilities);
189
190 /**
191  * @brief Get the capture available format array of a display object.
192  * @param[in] dpy A display object
193  * @param[out] formats The capture available format array
194  * @param[out] count The count of formats
195  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
196  */
197 tdm_error
198 tdm_display_get_catpure_available_formats(tdm_display *dpy,
199                                                                                   const tbm_format **formats, int *count);
200
201 /**
202  * @brief Get the output counts which a display object has.
203  * @param[in] dpy A display object
204  * @param[out] count The count of outputs
205  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
206  * @see tdm_display_get_output
207  */
208 tdm_error
209 tdm_display_get_output_count(tdm_display *dpy, int *count);
210
211 /**
212  * @brief Get a output object which has the given index.
213  * @param[in] dpy A display object
214  * @param[in] index The index of a output object
215  * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
216  * @return A output object if success. Otherwise, NULL.
217  * @see tdm_display_get_output_count
218  */
219 tdm_output *
220 tdm_display_get_output(tdm_display *dpy, int index, tdm_error *error);
221
222 /**
223  * @brief Create a pp object.
224  * @param[in] dpy A display object
225  * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
226  * @return A pp object if success. Otherwise, NULL.
227  * @see tdm_pp_destroy
228  */
229 tdm_pp *
230 tdm_display_create_pp(tdm_display *dpy, tdm_error *error);
231
232 /**
233  * @brief Get the model information of a output object.
234  * @param[in] output A output object
235  * @param[out] maker The output maker.
236  * @param[out] model The output model.
237  * @param[out] name The output name.
238  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
239  */
240 tdm_error
241 tdm_output_get_model_info(tdm_output *output, const char **maker,
242                                                   const char **model, const char **name);
243
244 /**
245  * @brief Get the connection status of a output object.
246  * @param[in] output A output object
247  * @param[out] status The connection status.
248  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
249  */
250 tdm_error
251 tdm_output_get_conn_status(tdm_output *output, tdm_output_conn_status *status);
252
253 /**
254  * @brief Add a output change handler
255  * @details The handler will be called when the status of a
256  * output object is changed. connection, DPMS, etc.
257  * @param[in] output A output object
258  * @param[in] func A output change handler
259  * @param[in] user_data The user data
260  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
261  */
262 tdm_error
263 tdm_output_add_change_handler(tdm_output *output,
264                                                           tdm_output_change_handler func,
265                                                           void *user_data);
266
267 /**
268  * @brief Remove a output change handler
269  * @param[in] output A output object
270  * @param[in] func A output change handler
271  * @param[in] user_data The user data
272  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
273  */
274 void
275 tdm_output_remove_change_handler(tdm_output *output,
276                                                                  tdm_output_change_handler func,
277                                                                  void *user_data);
278
279 /**
280  * @brief Get the connection type of a output object.
281  * @param[in] output A output object
282  * @param[out] type The connection type.
283  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
284  */
285 tdm_error
286 tdm_output_get_output_type(tdm_output *output, tdm_output_type *type);
287
288 /**
289  * @brief Get the layer counts which a output object has.
290  * @param[in] output A output object
291  * @param[out] count The count of layers
292  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
293  * @see tdm_output_get_layer
294  */
295 tdm_error
296 tdm_output_get_layer_count(tdm_output *output, int *count);
297
298 /**
299  * @brief Get a layer object which has the given index.
300  * @param[in] output A output object
301  * @param[in] index The index of a layer object
302  * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
303  * @return A layer object if success. Otherwise, NULL.
304  * @see tdm_output_get_layer_count
305  */
306 tdm_layer *
307 tdm_output_get_layer(tdm_output *output, int index, tdm_error *error);
308
309 /**
310  * @brief Get the available property array of a output object.
311  * @param[in] output A output object
312  * @param[out] props The available property array
313  * @param[out] count The count of properties
314  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
315  */
316 tdm_error
317 tdm_output_get_available_properties(tdm_output *output, const tdm_prop **props,
318                                                                         int *count);
319
320 /**
321  * @brief Get the available mode array of a output object.
322  * @param[in] output A output object
323  * @param[out] modes The available mode array
324  * @param[out] count The count of modes
325  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
326  */
327 tdm_error
328 tdm_output_get_available_modes(tdm_output *output,
329                                                            const tdm_output_mode **modes, int *count);
330
331 /**
332  * @brief Get the available size of a output object.
333  * @details -1 means that a TDM backend module doesn't define the value.
334  * @param[in] output A output object
335  * @param[out] min_w The minimum width which TDM can handle
336  * @param[out] min_h The minimum height which TDM can handle
337  * @param[out] max_w The maximum width which TDM can handle
338  * @param[out] max_h The maximum height which TDM can handle
339  * @param[out] preferred_align The preferred align width which TDM can handle
340  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
341  */
342 tdm_error
343 tdm_output_get_available_size(tdm_output *output, int *min_w, int *min_h,
344                                                           int *max_w, int *max_h, int *preferred_align);
345
346 /**
347  * @brief Get the physical size of a output object.
348  * @param[in] output A output object
349  * @param[out] mmWidth The milimeter width
350  * @param[out] mmHeight The milimeter height
351  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
352  */
353 tdm_error
354 tdm_output_get_physical_size(tdm_output *output, unsigned int *mmWidth,
355                                                          unsigned int *mmHeight);
356
357 /**
358  * @brief Get the subpixel of a output object.
359  * @param[in] output A output object
360  * @param[out] subpixel The subpixel
361  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
362  */
363 tdm_error
364 tdm_output_get_subpixel(tdm_output *output, unsigned int *subpixel);
365
366 /**
367  * @brief Get the pipe of a output object.
368  * @param[in] output A output object
369  * @param[out] pipe The pipe
370  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
371  */
372 tdm_error
373 tdm_output_get_pipe(tdm_output *output, unsigned int *pipe);
374
375 /**
376  * @brief Set the property which has a given id.
377  * @param[in] output A output object
378  * @param[in] id The property id
379  * @param[in] value The value
380  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
381  */
382 tdm_error
383 tdm_output_set_property(tdm_output *output, unsigned int id, tdm_value value);
384
385 /**
386  * @brief Get the property which has a given id
387  * @param[in] output A output object
388  * @param[in] id The property id
389  * @param[out] value The value
390  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
391  */
392 tdm_error
393 tdm_output_get_property(tdm_output *output, unsigned int id, tdm_value *value);
394
395 /**
396  * @brief Wait for VBLANK
397  * @details After interval vblanks, a user vblank handler will be called.
398  * @param[in] output A output object
399  * @param[in] interval vblank interval
400  * @param[in] sync 0: asynchronous, 1:synchronous
401  * @param[in] func A user vblank handler
402  * @param[in] user_data The user data
403  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
404  * @see #tdm_output_vblank_handler
405  */
406 tdm_error
407 tdm_output_wait_vblank(tdm_output *output, int interval, int sync,
408                                            tdm_output_vblank_handler func, void *user_data);
409
410 /**
411  * @brief Commit changes for a output object
412  * @details After all change of a output object are applied, a user commit handler
413  * will be called.
414  * @param[in] output A output object
415  * @param[in] sync 0: asynchronous, 1:synchronous
416  * @param[in] func A user commit handler
417  * @param[in] user_data The user data
418  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
419  */
420 tdm_error
421 tdm_output_commit(tdm_output *output, int sync, tdm_output_commit_handler func,
422                                   void *user_data);
423
424 /**
425  * @brief Set one of available modes of a output object
426  * @param[in] output A output object
427  * @param[in] mode A output mode
428  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
429  */
430 tdm_error
431 tdm_output_set_mode(tdm_output *output, const tdm_output_mode *mode);
432
433 /**
434  * @brief Get the mode of a output object
435  * @param[in] output A output object
436  * @param[out] mode A output mode
437  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
438  */
439 tdm_error
440 tdm_output_get_mode(tdm_output *output, const tdm_output_mode **mode);
441
442 /**
443  * @brief Set DPMS of a output object
444  * @param[in] output A output object
445  * @param[in] dpms_value DPMS value
446  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
447  */
448 tdm_error
449 tdm_output_set_dpms(tdm_output *output, tdm_output_dpms dpms_value);
450
451 /**
452  * @brief Get DPMS of a output object
453  * @param[in] output A output object
454  * @param[out] dpms_value DPMS value
455  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
456  */
457 tdm_error
458 tdm_output_get_dpms(tdm_output *output, tdm_output_dpms *dpms_value);
459
460 /**
461  * @brief Create a capture object of a output object
462  * @param[in] output A output object
463  * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
464  * @return A capture object
465  * @see tdm_capture_destroy
466  */
467 tdm_capture *
468 tdm_output_create_capture(tdm_output *output, tdm_error *error);
469
470 /**
471  * @brief Get the capabilities of a layer object.
472  * @param[in] layer A layer object
473  * @param[out] capabilities The capabilities of a layer object
474  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
475  */
476 tdm_error
477 tdm_layer_get_capabilities(tdm_layer *layer,
478                                                    tdm_layer_capability *capabilities);
479
480 /**
481  * @brief Get the available format array of a layer object.
482  * @param[in] layer A layer object
483  * @param[out] formats The available format array
484  * @param[out] count The count of formats
485  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
486  */
487 tdm_error
488 tdm_layer_get_available_formats(tdm_layer *layer, const tbm_format **formats,
489                                                                 int *count);
490
491 /**
492  * @brief Get the available property array of a layer object.
493  * @param[in] layer A layer object
494  * @param[out] props The available property array
495  * @param[out] count The count of properties
496  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
497  */
498 tdm_error
499 tdm_layer_get_available_properties(tdm_layer *layer, const tdm_prop **props,
500                                                                    int *count);
501
502 /**
503  * @brief Get the zpos of a layer object.
504  * @details
505  * - GRAPHIC layers have fixed zpos. It starts from 0. It's @b non-changeable.
506  * - But the zpos of VIDEO layers will be decided by a backend module side.
507  * - A frontend user only can set the relative zpos to VIDEO layers via #tdm_layer_set_video_pos
508  * - The zpos of video layers is less than GRAPHIC layers or more than GRAPHIC
509  * layers. ie, ..., -2, -1, 4, 5, ... (if 0 <= GRAPHIC layer's zpos < 4).
510  *   -------------------------------- graphic layer  3 <-- top most layer
511  *   -------------------------------- graphic layer  2
512  *   -------------------------------- graphic layer  1
513  *   -------------------------------- graphic layer  0
514  *   -------------------------------- video   layer -1
515  *   -------------------------------- video   layer -2 <-- lowest layer
516  * @param[in] layer A layer object
517  * @param[out] zpos The zpos
518  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
519  * @see tdm_layer_set_video_pos, tdm_layer_capability
520  */
521 tdm_error
522 tdm_layer_get_zpos(tdm_layer *layer, int *zpos);
523
524 /**
525  * @brief Set the property which has a given id.
526  * @param[in] layer A layer object
527  * @param[in] id The property id
528  * @param[in] value The value
529  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
530  */
531 tdm_error
532 tdm_layer_set_property(tdm_layer *layer, unsigned int id, tdm_value value);
533
534 /**
535  * @brief Get the property which has a given id.
536  * @param[in] layer A layer object
537  * @param[in] id The property id
538  * @param[out] value The value
539  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
540  */
541 tdm_error
542 tdm_layer_get_property(tdm_layer *layer, unsigned int id, tdm_value *value);
543
544 /**
545  * @brief Set the geometry information to a layer object
546  * @details The geometry information will be applied when the output object
547  * of a layer object is committed. If a layer has TDM_LAYER_CAPABILITY_NO_CROP
548  * capability, a layer will ignore the pos(crop) information of #tdm_info_layer's
549  * src_config.
550  * @param[in] layer A layer object
551  * @param[in] info The geometry information
552  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
553  * @see tdm_output_commit
554  */
555 tdm_error
556 tdm_layer_set_info(tdm_layer *layer, tdm_info_layer *info);
557
558 /**
559  * @brief Get the geometry information to a layer object
560  * @param[in] layer A layer object
561  * @param[out] info The geometry information
562  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
563  */
564 tdm_error
565 tdm_layer_get_info(tdm_layer *layer, tdm_info_layer *info);
566
567 /**
568  * @brief Set a TDM buffer to a layer object
569  * @details A TDM buffer will be applied when the output object
570  * of a layer object is committed.
571  * @param[in] layer A layer object
572  * @param[in] buffer A TDM buffer
573  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
574  * @see tdm_output_commit
575  */
576 tdm_error
577 tdm_layer_set_buffer(tdm_layer *layer, tbm_surface_h buffer);
578
579 /**
580  * @brief Unset a TDM buffer from a layer object
581  * @details When this function is called, a current showing buffer will be
582  * disappeared from screen. Then nothing is showing on a layer object.
583  * @param[in] layer A layer object
584  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
585  */
586 tdm_error
587 tdm_layer_unset_buffer(tdm_layer *layer);
588
589 /**
590  * @brief Get a displaying TDM buffer from a layer object
591  * @details A displaying TDM buffer is a current showing buffer on screen
592  * that is set to layer object and applied output object of a layer object.
593  * @param[in] layer A layer object
594  * @return A TDM buffer if success. Otherwise, NULL.
595  */
596 tbm_surface_h
597 tdm_layer_get_displaying_buffer(tdm_layer *layer, tdm_error *error);
598
599 /**
600  * @brief Set a TBM surface_queue to a layer object
601  * @details A TBM surface_queue will be applied when the output object
602  * of a layer object is committed. and TDM layer will be automatically updated
603  * @param[in] layer A layer object
604  * @param[in] buffer_queue A TBM surface_queue
605  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
606  * @see tdm_output_commit
607  */
608 tdm_error
609 tdm_layer_set_buffer_queue(tdm_layer *layer, tbm_surface_queue_h buffer_queue);
610
611 /**
612  * @brief Unset a TBM surface_queue from a layer object
613  * @details When this function is called, a current surface_queue will be
614  * disappeared from screen. Then nothing is showing on a layer object.
615  * @param[in] layer A layer object
616  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
617  */
618 tdm_error
619 tdm_layer_unset_buffer_queue(tdm_layer *layer);
620
621 /**
622  * @brief Check wheter a layer object is available for a frontend user to use.
623  * @details A layer object is not usable if a TDM buffer is showing on screen
624  * via this layer object. By calling #tdm_layer_unset_buffer, this layer object
625  * will become usable.
626  * @param[in] layer A layer object
627  * @param[out] usable 1 if usable, 0 if not usable
628  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
629  */
630 tdm_error
631 tdm_layer_is_usable(tdm_layer *layer, unsigned int *usable);
632
633 /**
634  * @brief Set the relative zpos to a VIDEO layer object
635  * @details The zpos value is less than the minimum zpos of GRAPHIC layers, or
636  * it is more than the maximum zpos of GRAPHIC layers.
637  * @param[in] layer A VIDEO layer object
638  * @param[in] zpos The zpos
639  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
640  * @see tdm_layer_get_zpos, tdm_layer_capability
641  */
642 tdm_error
643 tdm_layer_set_video_pos(tdm_layer *layer, int zpos);
644
645 /**
646  * @brief Create a capture object of a layer object
647  * @param[in] layer A layer object
648  * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
649  * @return A capture object
650  * @see tdm_capture_destroy
651  */
652 tdm_capture *
653 tdm_layer_create_capture(tdm_layer *layer, tdm_error *error);
654
655 /**
656  * @brief Get buffer flags from a layer object
657  * @param[in] layer A layer object
658  * @param[out] flags a buffer flags value
659  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
660  */
661 tdm_error
662 tdm_layer_get_buffer_flags(tdm_layer *layer, unsigned int *flags);
663
664 /**
665  * @brief Destroy a pp object
666  * @param[in] pp A pp object
667  * @see tdm_display_create_pp
668  */
669 void
670 tdm_pp_destroy(tdm_pp *pp);
671
672 /**
673  * @brief Set the geometry information to a pp object
674  * @param[in] pp A pp object
675  * @param[in] info The geometry information
676  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
677  * @see tdm_pp_commit
678  */
679 tdm_error
680 tdm_pp_set_info(tdm_pp *pp, tdm_info_pp *info);
681
682 /**
683  * @brief Attach a source buffer and a destination buffer to a pp object
684  * @param[in] pp A pp object
685  * @param[in] src A source buffer
686  * @param[in] dst A destination buffer
687  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
688  * @see tdm_pp_commit, tdm_buffer_add_release_handler, tdm_buffer_release_handler
689  */
690 tdm_error
691 tdm_pp_attach(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst);
692
693 /**
694  * @brief Commit changes for a pp object
695  * @param[in] pp A pp object
696  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
697  */
698 tdm_error
699 tdm_pp_commit(tdm_pp *pp);
700
701 /**
702  * @brief Destroy a capture object
703  * @param[in] capture A capture object
704  * @see tdm_output_create_capture, tdm_layer_create_capture
705  */
706 void
707 tdm_capture_destroy(tdm_capture *capture);
708
709 /**
710  * @brief Set the geometry information to a capture object
711  * @param[in] capture A capture object
712  * @param[in] info The geometry information
713  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
714  * @see tdm_capture_commit
715  */
716 tdm_error
717 tdm_capture_set_info(tdm_capture *capture, tdm_info_capture *info);
718
719 /**
720  * @brief Attach a TDM buffer to a capture object
721  * @param[in] capture A capture object
722  * @param[in] buffer A TDM buffer
723  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
724  * @see tdm_capture_commit, tdm_buffer_add_release_handler, tdm_buffer_release_handler
725  */
726 tdm_error
727 tdm_capture_attach(tdm_capture *capture, tbm_surface_h buffer);
728
729 /**
730  * @brief Commit changes for a capture object
731  * @param[in] capture A capture object
732  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
733  */
734 tdm_error
735 tdm_capture_commit(tdm_capture *capture);
736
737 /**
738  * @brief The release handler of a TDM buffer
739  * @param[in] buffer A TDM buffer
740  * @param[in] user_data user data
741  * @see tdm_buffer_add_release_handler, tdm_buffer_remove_release_handler
742  */
743 typedef void (*tdm_buffer_release_handler)(tbm_surface_h buffer,
744                                                                                    void *user_data);
745
746 /**
747  * @brief Add a release handler to a TDM buffer
748  * @details
749  * TDM has its own buffer release mechanism to let an frontend user know when a TDM buffer
750  * becomes available for a next job. A TDM buffer can be used for TDM to show
751  * it on screen or to capture an output and a layer. After all operations,
752  * TDM will release it immediately when TDM doesn't need it any more.
753  * @param[in] buffer A TDM buffer
754  * @param[in] func A release handler
755  * @param[in] user_data user data
756  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
757  * @see tdm_buffer_remove_release_handler
758  */
759 tdm_error
760 tdm_buffer_add_release_handler(tbm_surface_h buffer,
761                                                            tdm_buffer_release_handler func, void *user_data);
762
763 /**
764  * @brief Remove a release handler from a TDM buffer
765  * @param[in] buffer A TDM buffer
766  * @param[in] func A release handler
767  * @param[in] user_data user data
768  * @see tdm_buffer_add_release_handler
769  */
770 void
771 tdm_buffer_remove_release_handler(tbm_surface_h buffer,
772                                                                   tdm_buffer_release_handler func, void *user_data);
773
774 #ifdef __cplusplus
775 }
776 #endif
777
778 #endif /* _TDM_H_ */