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