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