support multi backend
[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  * @return A TDM output object if success. Otherwise, NULL.
742  */
743 tdm_output*
744 tdm_layer_get_output(tdm_layer *layer, tdm_error *error);
745
746 /**
747  * @brief Get the capabilities of a layer object.
748  * @param[in] layer A layer object
749  * @param[out] capabilities The capabilities of a layer object
750  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
751  */
752 tdm_error
753 tdm_layer_get_capabilities(tdm_layer *layer,
754                                                    tdm_layer_capability *capabilities);
755
756 /**
757  * @brief Get the available format array of a layer object.
758  * @param[in] layer A layer object
759  * @param[out] formats The available format array
760  * @param[out] count The count of formats
761  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
762  */
763 tdm_error
764 tdm_layer_get_available_formats(tdm_layer *layer, const tbm_format **formats,
765                                                                 int *count);
766
767 /**
768  * @brief Get the available property array of a layer object.
769  * @param[in] layer A layer object
770  * @param[out] props The available property array
771  * @param[out] count The count of properties
772  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
773  */
774 tdm_error
775 tdm_layer_get_available_properties(tdm_layer *layer, const tdm_prop **props,
776                                                                    int *count);
777
778 /**
779  * @brief Get the zpos of a layer object.
780  * @details
781  * - GRAPHIC layers have fixed zpos. It starts from 0. It's @b non-changeable.
782  * - But the zpos of VIDEO layers will be decided by a backend module side.
783  * - A frontend user only can set the relative zpos to VIDEO layers via #tdm_layer_set_video_pos
784  * - The zpos of video layers is less than GRAPHIC layers or more than GRAPHIC
785  * layers. ie, ..., -2, -1, 4, 5, ... (if 0 <= GRAPHIC layer's zpos < 4).
786  *   -------------------------------- graphic layer  3 <-- top most layer
787  *   -------------------------------- graphic layer  2
788  *   -------------------------------- graphic layer  1
789  *   -------------------------------- graphic layer  0
790  *   -------------------------------- video   layer -1
791  *   -------------------------------- video   layer -2 <-- lowest layer
792  * @param[in] layer A layer object
793  * @param[out] zpos The zpos
794  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
795  * @see tdm_layer_set_video_pos, tdm_layer_capability
796  */
797 tdm_error
798 tdm_layer_get_zpos(tdm_layer *layer, int *zpos);
799
800 /**
801  * @brief Set the property which has a given id.
802  * @param[in] layer A layer object
803  * @param[in] id The property id
804  * @param[in] value The value
805  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
806  */
807 tdm_error
808 tdm_layer_set_property(tdm_layer *layer, unsigned int id, tdm_value value);
809
810 /**
811  * @brief Get the property which has a given id.
812  * @param[in] layer A layer object
813  * @param[in] id The property id
814  * @param[out] value The value
815  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
816  */
817 tdm_error
818 tdm_layer_get_property(tdm_layer *layer, unsigned int id, tdm_value *value);
819
820 /**
821  * @brief Set the geometry information to a layer object
822  * @details The geometry information will be applied when the output object
823  * of a layer object is committed. If a layer has TDM_LAYER_CAPABILITY_NO_CROP
824  * capability, a layer will ignore the pos(crop) information of #tdm_info_layer's
825  * src_config.
826  * @param[in] layer A layer object
827  * @param[in] info The geometry information
828  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
829  * @see tdm_layer_commit
830  */
831 tdm_error
832 tdm_layer_set_info(tdm_layer *layer, tdm_info_layer *info);
833
834 /**
835  * @brief Get the geometry information to a layer object
836  * @param[in] layer A layer object
837  * @param[out] info The geometry information
838  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
839  */
840 tdm_error
841 tdm_layer_get_info(tdm_layer *layer, tdm_info_layer *info);
842
843 /**
844  * @brief Set a TDM buffer to a layer object
845  * @details A TDM buffer will be applied when the output object
846  * of a layer object is committed.
847  * @param[in] layer A layer object
848  * @param[in] buffer A TDM buffer
849  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
850  * @see tdm_layer_commit
851  */
852 tdm_error
853 tdm_layer_set_buffer(tdm_layer *layer, tbm_surface_h buffer);
854
855 /**
856  * @brief Unset a TDM buffer from a layer object
857  * @details When this function is called, a current showing buffer will be
858  * disappeared from screen. Then nothing is showing on a layer object.
859  * @param[in] layer A layer object
860  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
861  */
862 tdm_error
863 tdm_layer_unset_buffer(tdm_layer *layer);
864
865 /**
866  * @brief Commit changes for a layer object
867  * @details After all change of a layer object are applied, a user commit handler
868  * will be called.
869  * @param[in] layer A layer object
870  * @param[in] func A user commit handler
871  * @param[in] user_data The user data
872  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
873  */
874 tdm_error
875 tdm_layer_commit(tdm_layer *layer, tdm_layer_commit_handler func, void *user_data);
876
877 tdm_error
878 tdm_layer_is_committing(tdm_layer *layer, unsigned int *committing);
879
880 /**
881  * @brief Remove the user commit handler
882  * @param[in] layer A layer object
883  * @param[in] func A user commit handler
884  * @param[in] user_data The user data
885  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
886  */
887 tdm_error
888 tdm_layer_remove_commit_handler(tdm_layer *layer, tdm_layer_commit_handler func, void *user_data);
889
890 /**
891  * @brief Get a displaying TDM buffer from a layer object
892  * @details A displaying TDM buffer is a current showing buffer on screen
893  * that is set to layer object and applied output object of a layer object.
894  * @param[in] layer A layer object
895  * @return A TDM buffer if success. Otherwise, NULL.
896  */
897 tbm_surface_h
898 tdm_layer_get_displaying_buffer(tdm_layer *layer, tdm_error *error);
899
900 /**
901  * @brief Set a TBM surface_queue to a layer object
902  * @details A TBM surface_queue will be applied when the output object
903  * of a layer object is committed. and TDM layer will be automatically updated
904  * @param[in] layer A layer object
905  * @param[in] buffer_queue A TBM surface_queue
906  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
907  * @see tdm_layer_commit
908  */
909 tdm_error
910 tdm_layer_set_buffer_queue(tdm_layer *layer, tbm_surface_queue_h buffer_queue);
911
912 /**
913  * @brief Unset a TBM surface_queue from a layer object
914  * @details When this function is called, a current surface_queue will be
915  * disappeared from screen. Then nothing is showing on a layer object.
916  * @param[in] layer A layer object
917  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
918  */
919 tdm_error
920 tdm_layer_unset_buffer_queue(tdm_layer *layer);
921
922 /**
923  * @brief Check wheter a layer object is available for a frontend user to use.
924  * @details A layer object is not usable if a TDM buffer is showing on screen
925  * via this layer object. By calling #tdm_layer_unset_buffer, this layer object
926  * will become usable.
927  * @param[in] layer A layer object
928  * @param[out] usable 1 if usable, 0 if not usable
929  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
930  */
931 tdm_error
932 tdm_layer_is_usable(tdm_layer *layer, unsigned int *usable);
933
934 /**
935  * @brief Set the relative zpos to a VIDEO layer object
936  * @details The zpos value is less than the minimum zpos of GRAPHIC layers, or
937  * it is more than the maximum zpos of GRAPHIC layers.
938  * @param[in] layer A VIDEO layer object
939  * @param[in] zpos The zpos
940  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
941  * @see tdm_layer_get_zpos, tdm_layer_capability
942  */
943 tdm_error
944 tdm_layer_set_video_pos(tdm_layer *layer, int zpos);
945
946 /**
947  * @brief Create a capture object of a layer object
948  * @param[in] layer A layer object
949  * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
950  * @return A capture object
951  * @see tdm_capture_destroy
952  */
953 tdm_capture *
954 tdm_layer_create_capture(tdm_layer *layer, tdm_error *error);
955
956 /**
957  * @brief Get buffer flags from a layer object
958  * @param[in] layer A layer object
959  * @param[out] flags a buffer flags value
960  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
961  */
962 tdm_error
963 tdm_layer_get_buffer_flags(tdm_layer *layer, unsigned int *flags);
964
965 /**
966  * @brief Get a buffer queue for the window object
967  * @details These buffers are used to composite by hardware a client content in
968  * the nocomp mode.
969  * @param[in] hwc_window A window object
970  * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
971  * @return A tbm buffer queue
972  * @since 2.0.0
973  */
974 tbm_surface_queue_h
975 tdm_hwc_window_get_tbm_buffer_queue(tdm_hwc_window *hwc_window, tdm_error *error);
976
977 /**
978  * @brief Sets the desired composition type of the given window.
979  * @details During tdm_output_hwc_validate(), the device may request changes to
980  * the composition types of any of the layers as described in the definition
981  * of tdm_hwc_window_composition_t above.
982  * @param[in] hwc_window A window object
983  * @param[in] composition_type The new composition type
984  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
985  * @since 2.0.0
986  */
987 tdm_error
988 tdm_hwc_window_set_composition_type(tdm_hwc_window *hwc_window,
989                                                                         tdm_hwc_window_composition composition_type);
990
991 /**
992  * @brief Set the buffer damage
993  * @details Provides the region of the source buffer which has been modified
994  * since the last frame. This region does not need to be validated before
995  * calling tdm_output_commit().
996  * Once set through this function, the damage region remains the same until a
997  * subsequent call to this function.
998  * If damage.num_rects > 0, then it may be assumed that any portion of the source
999  * buffer not covered by one of the rects has not been modified this frame. If
1000  * damage.num_rects == 0, then the whole source buffer must be treated as if it
1001  * has been modified.
1002  * If the layer's contents are not modified relative to the prior frame, damage
1003  * will contain exactly one empty rect([0, 0, 0, 0]).
1004  * The damage rects are relative to the pre-transformed buffer, and their origin
1005  * is the top-left corner. They will not exceed the dimensions of the latched
1006  * buffer.
1007  * @param[in] hwc_window A window object
1008  * @param[in] damage The new buffer damage region
1009  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1010  * @since 2.0.0
1011  */
1012 tdm_error
1013 tdm_hwc_window_set_buffer_damage(tdm_hwc_window *hwc_window, tdm_hwc_region damage);
1014
1015 /**
1016  * @brief Set the information to a window object
1017  * @details The information will be applied when the output object of a window
1018  * object is committed.
1019  * @param[in] hwc_window A window object
1020  * @param[in] info The information
1021  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1022  * @since 2.0.0
1023  */
1024 tdm_error
1025 tdm_hwc_window_set_info(tdm_hwc_window *hwc_window, tdm_hwc_window_info *info);
1026
1027 /**
1028  * @brief Set a TBM buffer to a window object
1029  * @details A TBM buffer will be applied when the output object of a layer
1030  * object is committed.
1031  * @param[in] hwc_window A window object
1032  * @param[in] buffer A TDM buffer
1033  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1034  * @return #TDM_ERROR_BUSY if #hwc_window can't be updated right now, this
1035  * can happen if #hwc_window is involved in the smooth transition from
1036  * DEVICE to CLIENT, this shouldn't be interpreted like some critical error.
1037  * @since 2.0.0
1038  */
1039 tdm_error
1040 tdm_hwc_window_set_buffer(tdm_hwc_window *hwc_window, tbm_surface_h buffer);
1041
1042 /**
1043  * @brief Unset a TBM buffer to a window object
1044  * @details A TBM buffer will be applied when the output object of a layer
1045  * object is committed.
1046  * @param[in] hwc_window A window object
1047  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1048  * @return #TDM_ERROR_BUSY if #hwc_window can't be updated right now, this
1049  * can happen if #hwc_window is involved in the smooth transition from
1050  * DEVICE to CLIENT, this shouldn't be interpreted like some critical error.
1051  * @since 2.0.0
1052  */
1053 tdm_error
1054 tdm_hwc_window_unset_buffer(tdm_hwc_window *hwc_window);
1055
1056 /**
1057  * @brief Set a flags to a window object
1058  * @param[in] hwc_window A window object
1059  * @param[in] flags A hwc_window flags
1060  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1061  * @since 2.0.0
1062  */
1063 tdm_error
1064 tdm_hwc_window_set_flags(tdm_hwc_window *hwc_window, tdm_hwc_window_flag flags);
1065
1066 /**
1067  * @brief Unset a flags from a window object
1068  * @param[in] hwc_window A window object
1069  * @param[in] flags A hwc_window flags
1070  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1071  * @since 2.0.0
1072  */
1073 tdm_error
1074 tdm_hwc_window_unset_flags(tdm_hwc_window *hwc_window, tdm_hwc_window_flag flags);
1075
1076 /**
1077  * @brief Commit changes for a window object
1078  * @details After all change of a window object are applied, a user commit handler
1079  * will be called.
1080  * @param[in] hwc_window A window object
1081  * @param[in] func A user commit handler
1082  * @param[in] user_data The user data
1083  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1084  */
1085 tdm_error
1086 tdm_hwc_window_commit(tdm_hwc_window *hwc_window, tdm_hwc_window_commit_handler func, void *user_data);
1087
1088 /**
1089  * @brief Get the available property array  of a video hwc window object.
1090  * @param[in] hwc window A video hwc window object
1091  * @param[out] props The available property array
1092  * @param[out] count The count of properties
1093  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1094  */
1095 tdm_error
1096 tdm_hwc_window_video_get_available_properties(tdm_hwc_window *hwc_window,
1097                                                                   const tdm_prop **props, int *count);
1098
1099 /**
1100  * @brief Get the property which has a given id.
1101  * @param[in] hwc window A video hwc window object
1102  * @param[in] id The property id
1103  * @param[out] value The value
1104  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1105  */
1106 tdm_error
1107 tdm_hwc_window_video_get_property(tdm_hwc_window *hwc_window, uint32_t id,
1108                                                                   tdm_value *value);
1109
1110 /**
1111  * @brief Set the property which has a given id.
1112  * @param[in] hwc window  A video hwc window object
1113  * @param[in] id The property id
1114  * @param[in] value The value
1115  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1116  */
1117 tdm_error
1118 tdm_hwc_window_video_set_property(tdm_hwc_window *hwc_window, uint32_t id,
1119                                                                   tdm_value value);
1120
1121 /**
1122  * @brief Get the window video capability
1123  * @param[in] hwc_window A window object
1124  * @param[out] video_capability A hwc window video capability
1125  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1126  * @since 2.0.0
1127  */
1128 tdm_error
1129 tdm_hwc_window_video_get_capability(tdm_hwc_window *hwc_window,
1130                                                                         tdm_hwc_window_video_capability *video_capability);
1131
1132 /**
1133  * @brief Destroy a pp object
1134  * @param[in] pp A pp object
1135  * @see tdm_display_create_pp
1136  */
1137 void
1138 tdm_pp_destroy(tdm_pp *pp);
1139
1140 /**
1141  * @brief Set the geometry information to a pp object
1142  * @param[in] pp A pp object
1143  * @param[in] info The geometry information
1144  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1145  * @see tdm_pp_commit
1146  */
1147 tdm_error
1148 tdm_pp_set_info(tdm_pp *pp, tdm_info_pp *info);
1149
1150 /**
1151  * @brief Set the PP done handler to a pp object
1152  * @details
1153  * The user PP done handler will be called after converting a source buffer's image
1154  * to a destination buffer.
1155  * @param[in] pp A pp object
1156  * @param[in] func A user PP done handler
1157  * @param[in] user_data The user data
1158  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1159  */
1160 tdm_error
1161 tdm_pp_set_done_handler(tdm_pp *pp, tdm_pp_done_handler func, void *user_data);
1162
1163 /**
1164  * @brief Attach a source buffer and a destination buffer to a pp object
1165  * @param[in] pp A pp object
1166  * @param[in] src A source buffer
1167  * @param[in] dst A destination buffer
1168  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1169  * @see tdm_pp_commit, tdm_pp_set_done_handler
1170  */
1171 tdm_error
1172 tdm_pp_attach(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst);
1173
1174 /**
1175  * @brief Commit changes for a pp object
1176  * @param[in] pp A pp object
1177  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1178  */
1179 tdm_error
1180 tdm_pp_commit(tdm_pp *pp);
1181
1182 /**
1183  * @brief Destroy a capture object
1184  * @param[in] capture A capture object
1185  * @see tdm_output_create_capture, tdm_layer_create_capture
1186  */
1187 void
1188 tdm_capture_destroy(tdm_capture *capture);
1189
1190 /**
1191  * @brief Set the geometry information to a capture object
1192  * @param[in] capture A capture object
1193  * @param[in] info The geometry information
1194  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1195  * @see tdm_capture_commit
1196  */
1197 tdm_error
1198 tdm_capture_set_info(tdm_capture *capture, tdm_info_capture *info);
1199
1200 /**
1201  * @brief Set the capture done handler to a capture object
1202  * @details
1203  * The user capture done handler will be called after capturing a screen into a
1204  * buffer.
1205  * @param[in] capture A capture object
1206  * @param[in] func A user capture done handler
1207  * @param[in] user_data The user data
1208  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1209  */
1210 tdm_error
1211 tdm_capture_set_done_handler(tdm_capture *capture, tdm_capture_done_handler func, void *user_data);
1212
1213 /**
1214  * @brief Attach a TDM buffer to a capture object
1215  * @param[in] capture A capture object
1216  * @param[in] buffer A TDM buffer
1217  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1218  * @see tdm_capture_commit, tdm_capture_set_done_handler
1219  */
1220 tdm_error
1221 tdm_capture_attach(tdm_capture *capture, tbm_surface_h buffer);
1222
1223 /**
1224  * @brief Commit changes for a capture object
1225  * @param[in] capture A capture object
1226  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1227  */
1228 tdm_error
1229 tdm_capture_commit(tdm_capture *capture);
1230
1231 /**
1232  * @brief The release handler of a TDM buffer
1233  * @param[in] buffer A TDM buffer
1234  * @param[in] user_data user data
1235  * @see tdm_buffer_add_release_handler, tdm_buffer_remove_release_handler
1236  */
1237 typedef void (*tdm_buffer_release_handler)(tbm_surface_h buffer,
1238                                                                                    void *user_data);
1239
1240 /**
1241  * @brief Add a release handler to a TDM buffer
1242  * @details
1243  * TDM has its own buffer release mechanism to let an frontend user know when a TDM buffer
1244  * becomes available for a next job. A TDM buffer can be used for TDM to show
1245  * it on screen or to capture an output and a layer. After all operations,
1246  * TDM will release it immediately when TDM doesn't need it any more.
1247  * @param[in] buffer A TDM buffer
1248  * @param[in] func A release handler
1249  * @param[in] user_data user data
1250  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1251  * @see tdm_buffer_remove_release_handler
1252  */
1253 tdm_error
1254 tdm_buffer_add_release_handler(tbm_surface_h buffer,
1255                                                            tdm_buffer_release_handler func, void *user_data);
1256
1257 /**
1258  * @brief Remove a release handler from a TDM buffer
1259  * @param[in] buffer A TDM buffer
1260  * @param[in] func A release handler
1261  * @param[in] user_data user data
1262  * @see tdm_buffer_add_release_handler
1263  */
1264 void
1265 tdm_buffer_remove_release_handler(tbm_surface_h buffer,
1266                                                                   tdm_buffer_release_handler func, void *user_data);
1267
1268 /**
1269  * @brief The handler of a vblank object
1270  * @see #tdm_vblank_wait, #tdm_vblank_wait_seq
1271  */
1272 typedef void (*tdm_vblank_handler)(tdm_vblank *vblank, tdm_error error, unsigned int sequence,
1273                                                                    unsigned int tv_sec, unsigned int tv_usec, void *user_data);
1274
1275 /**
1276  * @brief Set the vblank fps for the given PID and name.
1277  * @param[in] pid The process ID
1278  * @param[in] name The client vblank name
1279  * @param[in] fps The client vblank fps
1280  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1281  */
1282 tdm_error
1283 tdm_vblank_set_client_vblank_fps(unsigned int pid, const char *name, unsigned int fps);
1284
1285 /**
1286  * @brief Set the ignore global fps for the given PID and name.
1287  * @param[in] pid The process ID
1288  * @param[in] name The client vblank name
1289  * @param[in] ignore 1: ignore 0:not ignore(default)
1290  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1291  */
1292 tdm_error
1293 tdm_vblank_set_client_ignore_global_fps(unsigned int pid, const char *name, unsigned int ignore);
1294
1295 /**
1296  * @brief Set the vblank global fps for the entire system.
1297  * @param[in] enable 1:enable, 0:disable
1298  * @param[in] fps The vblank global fps
1299  * @details
1300  * This global fps will be applied to all client's vblanks for all outputs.
1301  * If the client's vblank fps is less than this, the global fps will be ignored
1302  * for that client. And if a client calls #tdm_vblank_ignore_global_fps to ignore
1303  * the global fps, it will be ignored also.
1304  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1305  */
1306 tdm_error
1307 tdm_vblank_enable_global_fps(unsigned int enable, unsigned int fps);
1308
1309 /**
1310  * @brief Add the vblank create handler.
1311  * @param[in] dpy A display object
1312  * @param[in] func The user vblank create handler
1313  * @param[in] user_data The user data
1314  * @details
1315  * The user vblank create handler will be called when new vblank object created.
1316  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1317  */
1318 tdm_error
1319 tdm_vblank_add_create_handler(tdm_display *dpy, tdm_vblank_create_handler func, void *user_data);
1320
1321 /**
1322  * @brief Remove the vblank create handler.
1323  * @param[in] dpy A display object
1324  * @param[in] func The user vblank create handler
1325  * @param[in] user_data The user data
1326  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1327  */
1328 void
1329 tdm_vblank_remove_create_handler(tdm_display *dpy, tdm_vblank_create_handler func, void *user_data);
1330
1331 /**
1332  * @brief Create a vblank object
1333  * @param[in] dpy A display object
1334  * @param[in] output A output object
1335  * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
1336  * @return A vblank object
1337  * @see #tdm_vblank_destroy
1338  */
1339 tdm_vblank*
1340 tdm_vblank_create(tdm_display *dpy, tdm_output *output, tdm_error *error);
1341
1342 /**
1343  * @brief Destroy a vblank object
1344  * @param[in] vblank A vblank object
1345  * @see #tdm_vblank_create
1346  */
1347 void
1348 tdm_vblank_destroy(tdm_vblank *vblank);
1349
1350 /**
1351  * @brief Get the client PID for a vblank object
1352  * @param[in] vblank A vblank object
1353  * @param[out] pid PID of vblank's client
1354  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1355  */
1356 tdm_error
1357 tdm_vblank_get_client_pid(tdm_vblank *vblank, pid_t *pid);
1358
1359 /**
1360  * @brief Set the name to a vblank object
1361  * @details The default name is "unknown"
1362  * @param[in] vblank A vblank object
1363  * @param[in] name vblank name
1364  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1365  */
1366 tdm_error
1367 tdm_vblank_set_name(tdm_vblank *vblank, const char *name);
1368
1369 /**
1370  * @brief Get the name for a vblank object
1371  * @details The default name is "unknown"
1372  * @param[in] vblank A vblank object
1373  * @param[out] name vblank name
1374  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1375  */
1376 tdm_error
1377 tdm_vblank_get_name(tdm_vblank *vblank, const char **name);
1378
1379 /**
1380  * @brief Set the fps to a vblank object
1381  * @details Default is the @b vertical @b refresh @b rate of the given output.
1382  * It could be ignored when the fixed fps is set by #tdm_vblank_set_fixed_fps
1383  * @param[in] vblank A vblank object
1384  * @param[in] fps over 0
1385  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1386  */
1387 tdm_error
1388 tdm_vblank_set_fps(tdm_vblank *vblank, unsigned int fps);
1389
1390 /**
1391  * @brief Get the fps for a vblank object
1392  * @param[in] vblank A vblank object
1393  * @param[out] fps over 0
1394  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1395  */
1396 tdm_error
1397 tdm_vblank_get_fps(tdm_vblank *vblank, unsigned int *fps);
1398
1399 /**
1400  * @brief Set the fixed fps to a vblank object
1401  * @details
1402  * It could be ignored when the global fps is set by #tdm_vblank_enable_global_fps
1403  * @param[in] vblank A vblank object
1404  * @param[in] fps over 0
1405  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1406  */
1407 tdm_error
1408 tdm_vblank_set_fixed_fps(tdm_vblank *vblank, unsigned int fps);
1409
1410 /**
1411  * @brief Ignore the vblank global fps
1412  * @details
1413  * The global fps will be applied to all client's vblanks for all outputs.
1414  * If the client's vblank fps is less than this, the global fps will be ignored
1415  * for that client. And if a client calls #tdm_vblank_ignore_global_fps to ignore
1416  * the global fps, it will be ignored also.
1417  * @param[in] vblank A vblank object
1418  * @param[in] ignore 1: ignore 0:not ignore(default)
1419  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1420  */
1421 tdm_error
1422 tdm_vblank_ignore_global_fps(tdm_vblank *vblank, unsigned int ignore);
1423
1424 /**
1425  * @brief Set the offset(milli-second) to a vblank object
1426  * @details Default is @b 0.
1427  * @param[in] vblank A vblank object
1428  * @param[in] offset the offset(milli-second)
1429  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1430  */
1431 tdm_error
1432 tdm_vblank_set_offset(tdm_vblank *vblank, int offset);
1433
1434 /**
1435  * @brief Get the offset(milli-second) for a vblank object
1436  * @param[in] vblank A vblank object
1437  * @param[out] offset the offset(milli-second)
1438  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1439  */
1440 tdm_error
1441 tdm_vblank_get_offset(tdm_vblank *vblank, int *offset);
1442
1443 /**
1444  * @brief Enable/Disable the fake vblank to a vblank object
1445  * @details
1446  * If enable_fake == 0, #tdm_vblank_wait will return TDM_ERROR_DPMS_OFF
1447  * when DPMS off. Otherwise, #tdm_vblank_wait will return TDM_ERROR_NONE
1448  * as success.
1449  * @param[in] vblank A vblank object
1450  * @param[in] enable_fake 1:enable, 0:disable
1451  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1452  */
1453 tdm_error
1454 tdm_vblank_set_enable_fake(tdm_vblank *vblank, unsigned int enable_fake);
1455
1456 /**
1457  * @brief Get the fake vblank
1458  * @param[in] vblank A vblank object
1459  * @param[out] enable_fake 1:enable, 0:disable
1460  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1461  */
1462 tdm_error
1463 tdm_vblank_get_enable_fake(tdm_vblank *vblank, unsigned int *enable_fake);
1464
1465 /**
1466  * @brief Wait for a vblank
1467  * @details
1468  * Once #tdm_vblank_wait returns TDM_ERROR_NONE, the user vblank handler(#tdm_vblank_handler)
1469  * SHOULD be called after the given interval. \n
1470  * The sequence value of tdm_vblank_handler is the relative value of fps.
1471  * If fps = 10, this sequence value should be increased by 10 during 1 second.
1472  * @param[in] vblank A vblank object
1473  * @param[in] req_sec The vblank request time(second)
1474  * @param[in] req_usec The vblank request time(micro-second)
1475  * @param[in] interval The vblank interval
1476  * @param[in] func The user vblank handler
1477  * @param[in] user_data The user data
1478  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1479  */
1480 tdm_error
1481 tdm_vblank_wait(tdm_vblank *vblank, unsigned int req_sec, unsigned int req_usec,
1482                                 unsigned int interval, tdm_vblank_handler func, void *user_data);
1483
1484 /**
1485  * @brief Wait for a vblank with the target sequence number
1486  * @param[in] vblank A vblank object
1487  * @param[in] req_sec The vblank request time(second)
1488  * @param[in] req_usec The vblank request time(micro-second)
1489  * @param[in] sequence The target sequence number
1490  * @param[in] func The user client vblank handler
1491  * @param[in] user_data The user data
1492  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1493  */
1494 tdm_error
1495 tdm_vblank_wait_seq(tdm_vblank *vblank, unsigned int req_sec, unsigned int req_usec,
1496                                         unsigned int sequence, tdm_vblank_handler func, void *user_data);
1497
1498 #ifdef __cplusplus
1499 }
1500 #endif
1501
1502 #endif /* _TDM_H_ */