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