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