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