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