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