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