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