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