Added cursor available size in caps output
[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 capabilities of a output object.
238  * @param[in] output A output object
239  * @param[out] capabilities The capabilities of a output object
240  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
241  */
242 tdm_error
243 tdm_output_get_capabilities(tdm_output *output,
244                                                         tdm_output_capability *capabilities);
245
246 /**
247  * @brief Get the model information of a output object.
248  * @param[in] output A output object
249  * @param[out] maker The output maker.
250  * @param[out] model The output model.
251  * @param[out] name The output name.
252  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
253  */
254 tdm_error
255 tdm_output_get_model_info(tdm_output *output, const char **maker,
256                                                   const char **model, const char **name);
257
258 /**
259  * @brief Get the connection status of a output object.
260  * @param[in] output A output object
261  * @param[out] status The connection status.
262  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
263  */
264 tdm_error
265 tdm_output_get_conn_status(tdm_output *output, tdm_output_conn_status *status);
266
267 /**
268  * @brief Add a output change handler
269  * @details The handler will be called when the status of a
270  * output object is changed. connection, DPMS, etc.
271  * @param[in] output A output object
272  * @param[in] func A output change handler
273  * @param[in] user_data The user data
274  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
275  */
276 tdm_error
277 tdm_output_add_change_handler(tdm_output *output,
278                                                           tdm_output_change_handler func,
279                                                           void *user_data);
280
281 /**
282  * @brief Remove a output change handler
283  * @param[in] output A output object
284  * @param[in] func A output change handler
285  * @param[in] user_data The user data
286  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
287  */
288 void
289 tdm_output_remove_change_handler(tdm_output *output,
290                                                                  tdm_output_change_handler func,
291                                                                  void *user_data);
292
293 /**
294  * @brief Get the connection type of a output object.
295  * @param[in] output A output object
296  * @param[out] type The connection type.
297  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
298  */
299 tdm_error
300 tdm_output_get_output_type(tdm_output *output, tdm_output_type *type);
301
302 /**
303  * @brief Get the layer counts which a output object has.
304  * @param[in] output A output object
305  * @param[out] count The count of layers
306  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
307  * @see tdm_output_get_layer
308  */
309 tdm_error
310 tdm_output_get_layer_count(tdm_output *output, int *count);
311
312 /**
313  * @brief Get a layer object which has the given index.
314  * @param[in] output A output object
315  * @param[in] index The index of a layer object
316  * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
317  * @return A layer object if success. Otherwise, NULL.
318  * @see tdm_output_get_layer_count
319  */
320 tdm_layer *
321 tdm_output_get_layer(tdm_output *output, int index, tdm_error *error);
322
323 /**
324  * @brief Get the available property array of a output object.
325  * @param[in] output A output object
326  * @param[out] props The available property array
327  * @param[out] count The count of properties
328  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
329  */
330 tdm_error
331 tdm_output_get_available_properties(tdm_output *output, const tdm_prop **props,
332                                                                         int *count);
333
334 /**
335  * @brief Get the available mode array of a output object.
336  * @param[in] output A output object
337  * @param[out] modes The available mode array
338  * @param[out] count The count of modes
339  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
340  */
341 tdm_error
342 tdm_output_get_available_modes(tdm_output *output,
343                                                            const tdm_output_mode **modes, int *count);
344
345 /**
346  * @brief Get the available size of a output object.
347  * @details -1 means that a TDM backend module doesn't define the value.
348  * @param[in] output A output object
349  * @param[out] min_w The minimum width which TDM can handle
350  * @param[out] min_h The minimum height which TDM can handle
351  * @param[out] max_w The maximum width which TDM can handle
352  * @param[out] max_h The maximum height which TDM can handle
353  * @param[out] preferred_align The preferred align width which TDM can handle
354  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
355  */
356 tdm_error
357 tdm_output_get_available_size(tdm_output *output, int *min_w, int *min_h,
358                                                           int *max_w, int *max_h, int *preferred_align);
359
360 /**
361  * @brief Get the available cursor size of a output object.
362  * @details -1 means that a TDM backend module doesn't define the value.
363  * @param[in] output A output object
364  * @param[out] min_w The minimum width which TDM can handle
365  * @param[out] min_h The minimum height which TDM can handle
366  * @param[out] max_w The maximum width which TDM can handle
367  * @param[out] max_h The maximum height which TDM can handle
368  * @param[out] preferred_align The preferred align width which TDM can handle
369  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
370  */
371 tdm_error
372 tdm_output_get_cursor_available_size(tdm_output *output, int *min_w, int *min_h,
373                                                                          int *max_w, int *max_h, int *preferred_align);
374
375 /**
376  * @brief Get the physical size of a output object.
377  * @param[in] output A output object
378  * @param[out] mmWidth The milimeter width
379  * @param[out] mmHeight The milimeter height
380  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
381  */
382 tdm_error
383 tdm_output_get_physical_size(tdm_output *output, unsigned int *mmWidth,
384                                                          unsigned int *mmHeight);
385
386 /**
387  * @brief Get the subpixel of a output object.
388  * @param[in] output A output object
389  * @param[out] subpixel The subpixel
390  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
391  */
392 tdm_error
393 tdm_output_get_subpixel(tdm_output *output, unsigned int *subpixel);
394
395 /**
396  * @brief Get the pipe of a output object.
397  * @param[in] output A output object
398  * @param[out] pipe The pipe
399  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
400  */
401 tdm_error
402 tdm_output_get_pipe(tdm_output *output, unsigned int *pipe);
403
404 /**
405  * @brief Get the index of a primary layer.
406  * @param[in] output A output object
407  * @param[out] index The primary layer index
408  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
409  */
410 tdm_error
411 tdm_output_get_primary_index(tdm_output *output, int *index);
412
413 /**
414  * @brief Set the property which has a given id.
415  * @param[in] output A output object
416  * @param[in] id The property id
417  * @param[in] value The value
418  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
419  */
420 tdm_error
421 tdm_output_set_property(tdm_output *output, unsigned int id, tdm_value value);
422
423 /**
424  * @brief Get the property which has a given id
425  * @param[in] output A output object
426  * @param[in] id The property id
427  * @param[out] value The value
428  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
429  */
430 tdm_error
431 tdm_output_get_property(tdm_output *output, unsigned int id, tdm_value *value);
432
433 /**
434  * @brief Wait for VBLANK
435  * @details After interval vblanks, a user vblank handler will be called.
436  * @param[in] output A output object
437  * @param[in] interval vblank interval
438  * @param[in] sync 0: asynchronous, 1:synchronous
439  * @param[in] func A user vblank handler
440  * @param[in] user_data The user data
441  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
442  * @see #tdm_output_vblank_handler
443  */
444 tdm_error
445 tdm_output_wait_vblank(tdm_output *output, int interval, int sync,
446                                            tdm_output_vblank_handler func, void *user_data);
447
448 /**
449  * @brief Commit changes for a output object
450  * @details After all change of a output object are applied, a user commit handler
451  * will be called.
452  * @param[in] output A output object
453  * @param[in] sync 0: asynchronous, 1:synchronous
454  * @param[in] func A user commit handler
455  * @param[in] user_data The user data
456  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
457  */
458 tdm_error
459 tdm_output_commit(tdm_output *output, int sync, tdm_output_commit_handler func,
460                                   void *user_data);
461
462 /**
463  * @brief Set one of available modes of a output object
464  * @param[in] output A output object
465  * @param[in] mode A output mode
466  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
467  */
468 tdm_error
469 tdm_output_set_mode(tdm_output *output, const tdm_output_mode *mode);
470
471 /**
472  * @brief Get the mode of a output object
473  * @param[in] output A output object
474  * @param[out] mode A output mode
475  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
476  */
477 tdm_error
478 tdm_output_get_mode(tdm_output *output, const tdm_output_mode **mode);
479
480 /**
481  * @brief Set DPMS of a output object
482  * @param[in] output A output object
483  * @param[in] dpms_value DPMS value
484  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
485  */
486 tdm_error
487 tdm_output_set_dpms(tdm_output *output, tdm_output_dpms dpms_value);
488
489 /**
490  * @brief Get DPMS of a output object
491  * @param[in] output A output object
492  * @param[out] dpms_value DPMS value
493  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
494  */
495 tdm_error
496 tdm_output_get_dpms(tdm_output *output, tdm_output_dpms *dpms_value);
497
498 /**
499  * @brief Create a capture object of a output object
500  * @param[in] output A output object
501  * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
502  * @return A capture object
503  * @see tdm_capture_destroy
504  */
505 tdm_capture *
506 tdm_output_create_capture(tdm_output *output, tdm_error *error);
507
508 /**
509  * @brief Get the capabilities of a layer object.
510  * @param[in] layer A layer object
511  * @param[out] capabilities The capabilities of a layer object
512  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
513  */
514 tdm_error
515 tdm_layer_get_capabilities(tdm_layer *layer,
516                                                    tdm_layer_capability *capabilities);
517
518 /**
519  * @brief Get the available format array of a layer object.
520  * @param[in] layer A layer object
521  * @param[out] formats The available format array
522  * @param[out] count The count of formats
523  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
524  */
525 tdm_error
526 tdm_layer_get_available_formats(tdm_layer *layer, const tbm_format **formats,
527                                                                 int *count);
528
529 /**
530  * @brief Get the available property array of a layer object.
531  * @param[in] layer A layer object
532  * @param[out] props The available property array
533  * @param[out] count The count of properties
534  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
535  */
536 tdm_error
537 tdm_layer_get_available_properties(tdm_layer *layer, const tdm_prop **props,
538                                                                    int *count);
539
540 /**
541  * @brief Get the zpos of a layer object.
542  * @details
543  * - GRAPHIC layers have fixed zpos. It starts from 0. It's @b non-changeable.
544  * - But the zpos of VIDEO layers will be decided by a backend module side.
545  * - A frontend user only can set the relative zpos to VIDEO layers via #tdm_layer_set_video_pos
546  * - The zpos of video layers is less than GRAPHIC layers or more than GRAPHIC
547  * layers. ie, ..., -2, -1, 4, 5, ... (if 0 <= GRAPHIC layer's zpos < 4).
548  *   -------------------------------- graphic layer  3 <-- top most layer
549  *   -------------------------------- graphic layer  2
550  *   -------------------------------- graphic layer  1
551  *   -------------------------------- graphic layer  0
552  *   -------------------------------- video   layer -1
553  *   -------------------------------- video   layer -2 <-- lowest layer
554  * @param[in] layer A layer object
555  * @param[out] zpos The zpos
556  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
557  * @see tdm_layer_set_video_pos, tdm_layer_capability
558  */
559 tdm_error
560 tdm_layer_get_zpos(tdm_layer *layer, int *zpos);
561
562 /**
563  * @brief Set the property which has a given id.
564  * @param[in] layer A layer object
565  * @param[in] id The property id
566  * @param[in] value The value
567  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
568  */
569 tdm_error
570 tdm_layer_set_property(tdm_layer *layer, unsigned int id, tdm_value value);
571
572 /**
573  * @brief Get the property which has a given id.
574  * @param[in] layer A layer object
575  * @param[in] id The property id
576  * @param[out] value The value
577  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
578  */
579 tdm_error
580 tdm_layer_get_property(tdm_layer *layer, unsigned int id, tdm_value *value);
581
582 /**
583  * @brief Set the geometry information to a layer object
584  * @details The geometry information will be applied when the output object
585  * of a layer object is committed. If a layer has TDM_LAYER_CAPABILITY_NO_CROP
586  * capability, a layer will ignore the pos(crop) information of #tdm_info_layer's
587  * src_config.
588  * @param[in] layer A layer object
589  * @param[in] info The geometry information
590  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
591  * @see tdm_output_commit
592  */
593 tdm_error
594 tdm_layer_set_info(tdm_layer *layer, tdm_info_layer *info);
595
596 /**
597  * @brief Get the geometry information to a layer object
598  * @param[in] layer A layer object
599  * @param[out] info The geometry information
600  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
601  */
602 tdm_error
603 tdm_layer_get_info(tdm_layer *layer, tdm_info_layer *info);
604
605 /**
606  * @brief Set a TDM buffer to a layer object
607  * @details A TDM buffer will be applied when the output object
608  * of a layer object is committed.
609  * @param[in] layer A layer object
610  * @param[in] buffer A TDM buffer
611  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
612  * @see tdm_output_commit
613  */
614 tdm_error
615 tdm_layer_set_buffer(tdm_layer *layer, tbm_surface_h buffer);
616
617 /**
618  * @brief Unset a TDM buffer from a layer object
619  * @details When this function is called, a current showing buffer will be
620  * disappeared from screen. Then nothing is showing on a layer object.
621  * @param[in] layer A layer object
622  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
623  */
624 tdm_error
625 tdm_layer_unset_buffer(tdm_layer *layer);
626
627 /**
628  * @brief Get a displaying TDM buffer from a layer object
629  * @details A displaying TDM buffer is a current showing buffer on screen
630  * that is set to layer object and applied output object of a layer object.
631  * @param[in] layer A layer object
632  * @return A TDM buffer if success. Otherwise, NULL.
633  */
634 tbm_surface_h
635 tdm_layer_get_displaying_buffer(tdm_layer *layer, tdm_error *error);
636
637 /**
638  * @brief Set a TBM surface_queue to a layer object
639  * @details A TBM surface_queue will be applied when the output object
640  * of a layer object is committed. and TDM layer will be automatically updated
641  * @param[in] layer A layer object
642  * @param[in] buffer_queue A TBM surface_queue
643  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
644  * @see tdm_output_commit
645  */
646 tdm_error
647 tdm_layer_set_buffer_queue(tdm_layer *layer, tbm_surface_queue_h buffer_queue);
648
649 /**
650  * @brief Unset a TBM surface_queue from a layer object
651  * @details When this function is called, a current surface_queue will be
652  * disappeared from screen. Then nothing is showing on a layer object.
653  * @param[in] layer A layer object
654  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
655  */
656 tdm_error
657 tdm_layer_unset_buffer_queue(tdm_layer *layer);
658
659 /**
660  * @brief Check wheter a layer object is available for a frontend user to use.
661  * @details A layer object is not usable if a TDM buffer is showing on screen
662  * via this layer object. By calling #tdm_layer_unset_buffer, this layer object
663  * will become usable.
664  * @param[in] layer A layer object
665  * @param[out] usable 1 if usable, 0 if not usable
666  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
667  */
668 tdm_error
669 tdm_layer_is_usable(tdm_layer *layer, unsigned int *usable);
670
671 /**
672  * @brief Set the relative zpos to a VIDEO layer object
673  * @details The zpos value is less than the minimum zpos of GRAPHIC layers, or
674  * it is more than the maximum zpos of GRAPHIC layers.
675  * @param[in] layer A VIDEO layer object
676  * @param[in] zpos The zpos
677  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
678  * @see tdm_layer_get_zpos, tdm_layer_capability
679  */
680 tdm_error
681 tdm_layer_set_video_pos(tdm_layer *layer, int zpos);
682
683 /**
684  * @brief Create a capture object of a layer object
685  * @param[in] layer A layer object
686  * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
687  * @return A capture object
688  * @see tdm_capture_destroy
689  */
690 tdm_capture *
691 tdm_layer_create_capture(tdm_layer *layer, tdm_error *error);
692
693 /**
694  * @brief Get buffer flags from a layer object
695  * @param[in] layer A layer object
696  * @param[out] flags a buffer flags value
697  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
698  */
699 tdm_error
700 tdm_layer_get_buffer_flags(tdm_layer *layer, unsigned int *flags);
701
702 /**
703  * @brief Destroy a pp object
704  * @param[in] pp A pp object
705  * @see tdm_display_create_pp
706  */
707 void
708 tdm_pp_destroy(tdm_pp *pp);
709
710 /**
711  * @brief Set the geometry information to a pp object
712  * @param[in] pp A pp object
713  * @param[in] info The geometry information
714  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
715  * @see tdm_pp_commit
716  */
717 tdm_error
718 tdm_pp_set_info(tdm_pp *pp, tdm_info_pp *info);
719
720 /**
721  * @brief Set the PP done handler to a pp object
722  * @details
723  * The user PP done handler will be called after converting a source buffer's image
724  * to a destination buffer.
725  * @param[in] pp A pp object
726  * @param[in] func A user PP done handler
727  * @param[in] user_data The user data
728  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
729  */
730 tdm_error
731 tdm_pp_set_done_handler(tdm_pp *pp, tdm_pp_done_handler func, void *user_data);
732
733 /**
734  * @brief Attach a source buffer and a destination buffer to a pp object
735  * @param[in] pp A pp object
736  * @param[in] src A source buffer
737  * @param[in] dst A destination buffer
738  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
739  * @see tdm_pp_commit, tdm_pp_set_done_handler
740  */
741 tdm_error
742 tdm_pp_attach(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst);
743
744 /**
745  * @brief Commit changes for a pp object
746  * @param[in] pp A pp object
747  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
748  */
749 tdm_error
750 tdm_pp_commit(tdm_pp *pp);
751
752 /**
753  * @brief Destroy a capture object
754  * @param[in] capture A capture object
755  * @see tdm_output_create_capture, tdm_layer_create_capture
756  */
757 void
758 tdm_capture_destroy(tdm_capture *capture);
759
760 /**
761  * @brief Set the geometry information to a capture object
762  * @param[in] capture A capture object
763  * @param[in] info The geometry information
764  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
765  * @see tdm_capture_commit
766  */
767 tdm_error
768 tdm_capture_set_info(tdm_capture *capture, tdm_info_capture *info);
769
770 /**
771  * @brief Set the capture done handler to a capture object
772  * @details
773  * The user capture done handler will be called after capturing a screen into a
774  * buffer.
775  * @param[in] capture A capture object
776  * @param[in] func A user capture done handler
777  * @param[in] user_data The user data
778  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
779  */
780 tdm_error
781 tdm_capture_set_done_handler(tdm_capture *capture, tdm_capture_done_handler func, void *user_data);
782
783 /**
784  * @brief Attach a TDM buffer to a capture object
785  * @param[in] capture A capture object
786  * @param[in] buffer A TDM buffer
787  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
788  * @see tdm_capture_commit, tdm_capture_set_done_handler
789  */
790 tdm_error
791 tdm_capture_attach(tdm_capture *capture, tbm_surface_h buffer);
792
793 /**
794  * @brief Commit changes for a capture object
795  * @param[in] capture A capture object
796  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
797  */
798 tdm_error
799 tdm_capture_commit(tdm_capture *capture);
800
801 /**
802  * @brief The release handler of a TDM buffer
803  * @param[in] buffer A TDM buffer
804  * @param[in] user_data user data
805  * @see tdm_buffer_add_release_handler, tdm_buffer_remove_release_handler
806  */
807 typedef void (*tdm_buffer_release_handler)(tbm_surface_h buffer,
808                                                                                    void *user_data);
809
810 /**
811  * @brief Add a release handler to a TDM buffer
812  * @details
813  * TDM has its own buffer release mechanism to let an frontend user know when a TDM buffer
814  * becomes available for a next job. A TDM buffer can be used for TDM to show
815  * it on screen or to capture an output and a layer. After all operations,
816  * TDM will release it immediately when TDM doesn't need it any more.
817  * @param[in] buffer A TDM buffer
818  * @param[in] func A release handler
819  * @param[in] user_data user data
820  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
821  * @see tdm_buffer_remove_release_handler
822  */
823 tdm_error
824 tdm_buffer_add_release_handler(tbm_surface_h buffer,
825                                                            tdm_buffer_release_handler func, void *user_data);
826
827 /**
828  * @brief Remove a release handler from a TDM buffer
829  * @param[in] buffer A TDM buffer
830  * @param[in] func A release handler
831  * @param[in] user_data user data
832  * @see tdm_buffer_add_release_handler
833  */
834 void
835 tdm_buffer_remove_release_handler(tbm_surface_h buffer,
836                                                                   tdm_buffer_release_handler func, void *user_data);
837
838 /**
839  * @brief The handler of a vblank object
840  * @see #tdm_vblank_wait, #tdm_vblank_wait_seq
841  */
842 typedef void (*tdm_vblank_handler)(tdm_vblank *vblank, tdm_error error, unsigned int sequence,
843                                                                    unsigned int tv_sec, unsigned int tv_usec, void *user_data);
844
845 /**
846  * @brief Create a vblank object
847  * @param[in] dpy A display object
848  * @param[in] output A output object
849  * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
850  * @return A vblank object
851  * @see #tdm_vblank_destroy
852  */
853 tdm_vblank*
854 tdm_vblank_create(tdm_display *dpy, tdm_output *output, tdm_error *error);
855
856 /**
857  * @brief Destroy a vblank object
858  * @param[in] vblank A vblank object
859  * @see #tdm_vblank_create
860  */
861 void
862 tdm_vblank_destroy(tdm_vblank *vblank);
863
864 /**
865  * @brief Set the fps to a vblank object
866  * @details Default is the @b vertical @b refresh @b rate of the given output.
867  * @param[in] vblank A vblank object
868  * @param[in] fps over 0
869  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
870  */
871 tdm_error
872 tdm_vblank_set_fps(tdm_vblank *vblank, unsigned int fps);
873
874 /**
875  * @brief Set the offset(milli-second) to a vblank object
876  * @details Default is @b 0.
877  * @param[in] vblank A vblank object
878  * @param[in] offset the offset(milli-second)
879  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
880  */
881 tdm_error
882 tdm_vblank_set_offset(tdm_vblank *vblank, int offset);
883
884 /**
885  * @brief Enable/Disable the fake vblank to a vblank object
886  * @details
887  * If enable_fake == 0, #tdm_vblank_wait will return TDM_ERROR_DPMS_OFF
888  * when DPMS off. Otherwise, #tdm_vblank_wait will return TDM_ERROR_NONE
889  * as success.
890  * @param[in] vblank A vblank object
891  * @param[in] enable_fake 1:enable, 0:disable
892  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
893  */
894 tdm_error
895 tdm_vblank_set_enable_fake(tdm_vblank *vblank, unsigned int enable_fake);
896
897 /**
898  * @brief Get the fake vblank
899  * @param[in] vblank A vblank object
900  * @return 1 if enable. Otherwise, 0.
901  */
902 unsigned int
903 tdm_vblank_get_enable_fake(tdm_vblank *vblank);
904
905 /**
906  * @brief Wait for a vblank
907  * @details
908  * Once #tdm_vblank_wait returns TDM_ERROR_NONE, the user vblank handler(#tdm_vblank_handler)
909  * SHOULD be called after the given interval. \n
910  * The sequence value of tdm_vblank_handler is the relative value of fps.
911  * If fps = 10, this sequence value should be increased by 10 during 1 second.
912  * @param[in] vblank A vblank object
913  * @param[in] req_sec The vblank request time(second)
914  * @param[in] req_usec The vblank request time(micro-second)
915  * @param[in] interval The vblank interval
916  * @param[in] func The user vblank handler
917  * @param[in] user_data The user data
918  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
919  */
920 tdm_error
921 tdm_vblank_wait(tdm_vblank *vblank, unsigned int req_sec, unsigned int req_usec,
922                                 unsigned int interval, tdm_vblank_handler func, void *user_data);
923
924 /**
925  * @brief Wait for a vblank with the target sequence number
926  * @param[in] vblank A vblank object
927  * @param[in] req_sec The vblank request time(second)
928  * @param[in] req_usec The vblank request time(micro-second)
929  * @param[in] sequence The target sequence number
930  * @param[in] func The user client vblank handler
931  * @param[in] user_data The user data
932  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
933  */
934 tdm_error
935 tdm_vblank_wait_seq(tdm_vblank *vblank, unsigned int req_sec, unsigned int req_usec,
936                                         unsigned int sequence, tdm_vblank_handler func, void *user_data);
937
938 #ifdef __cplusplus
939 }
940 #endif
941
942 #endif /* _TDM_H_ */