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