1 /**************************************************************************
5 * Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
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>
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:
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
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.
34 **************************************************************************/
40 #include <tbm_surface.h>
41 #include <tbm_surface_queue.h>
42 #include <tbm_surface_internal.h>
44 #include "tdm_types.h"
52 * @brief The header file for a frontend user.
55 * #include <tdm.h> //for a frontend user
60 * @brief The display capability enumeration
63 TDM_DISPLAY_CAPABILITY_PP = (1 << 0), /**< if hardware supports pp operation */
64 TDM_DISPLAY_CAPABILITY_CAPTURE = (1 << 1), /**< if hardware supports capture operation */
65 TDM_DISPLAY_CAPABILITY_HWC = (1 << 2), /**< if hardware supports hwc operation @since 2.0.0*/
66 } tdm_display_capability;
69 * @brief The output change handler
70 * @details This handler will be called when the status of a output object is
73 typedef void (*tdm_output_change_handler)(tdm_output *output,
74 tdm_output_change_type type,
79 * @brief Initialize a display object
80 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
81 * @return A display object
82 * @see tdm_display_deinit
85 tdm_display_init(tdm_error *error);
88 * @brief Deinitialize a display object
89 * @param[in] dpy A display object
90 * @see tdm_display_init
93 tdm_display_deinit(tdm_display *dpy);
96 * @brief Update a display object
98 * When new output is connected, a frontend user need to call this function.
99 * And a frontend user can the new output information with tdm_output_get_xxx functions.
100 * @param[in] dpy A display object
101 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
104 tdm_display_update(tdm_display *dpy);
107 * @brief Get the file descriptor
108 * @details TDM handles the events of fd with #tdm_display_handle_events.
109 * @param[in] dpy A display object
110 * @param[out] fd The file descriptor
111 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
112 * @see tdm_display_handle_events
115 tdm_display_get_fd(tdm_display *dpy, int *fd);
118 * @brief Handle the events
119 * @param[in] dpy A display object
120 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
121 * @see tdm_display_get_fd
124 tdm_display_handle_events(tdm_display *dpy);
127 * @brief Get the information of the TDM backend module.
128 * @param[in] dpy A display object
129 * @param[out] name The name of the TDM backend module
130 * @param[out] vendor The vendor of the TDM backend module
131 * @param[out] version The version of the TDM backend module
132 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
135 tdm_display_get_backend_info(tdm_display *dpy, const char **name,
136 const char **vendor, int *major, int *minor);
139 * @brief Get the capabilities of a display object.
140 * @details A frontend user can get whether TDM supports pp/capture functionality with this function.
141 * @param[in] dpy A display object
142 * @param[out] capabilities The capabilities of a display object
143 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
146 tdm_display_get_capabilities(tdm_display *dpy,
147 tdm_display_capability *capabilities);
150 * @brief Get the pp capabilities of a display object.
151 * @param[in] dpy A display object
152 * @param[out] capabilities The pp capabilities
153 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
156 tdm_display_get_pp_capabilities(tdm_display *dpy,
157 tdm_pp_capability *capabilities);
160 * @brief Get the pp available format array of a display object.
161 * @param[in] dpy A display object
162 * @param[out] formats The pp available format array
163 * @param[out] count The count of formats
164 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
167 tdm_display_get_pp_available_formats(tdm_display *dpy,
168 const tbm_format **formats, int *count);
171 * @brief Get the pp available size of a display object.
172 * @details -1 means that a TDM backend module doesn't define the value.
173 * @param[in] dpy A display object
174 * @param[out] min_w The minimum width which TDM can handle
175 * @param[out] min_h The minimum height which TDM can handle
176 * @param[out] max_w The maximum width which TDM can handle
177 * @param[out] max_h The maximum height which TDM can handle
178 * @param[out] preferred_align The preferred align width which TDM can handle
179 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
182 tdm_display_get_pp_available_size(tdm_display *dpy, int *min_w, int *min_h,
183 int *max_w, int *max_h, int *preferred_align);
186 * @brief Get the capture capabilities of a display object.
187 * @param[in] dpy A display object
188 * @param[out] capabilities The capture capabilities
189 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
192 tdm_display_get_capture_capabilities(tdm_display *dpy,
193 tdm_capture_capability *capabilities);
196 * @brief Get the capture available format array of a display object.
197 * @param[in] dpy A display object
198 * @param[out] formats The capture available format array
199 * @param[out] count The count of formats
200 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
203 tdm_display_get_catpure_available_formats(tdm_display *dpy,
204 const tbm_format **formats, int *count);
207 * @brief Get the capture available size of a display object.
208 * @details -1 means that a TDM backend module doesn't define the value.
209 * @param[in] dpy A display object
210 * @param[out] min_w The minimum width which TDM can handle
211 * @param[out] min_h The minimum height which TDM can handle
212 * @param[out] max_w The maximum width which TDM can handle
213 * @param[out] max_h The maximum height which TDM can handle
214 * @param[out] preferred_align The preferred align width which TDM can handle
215 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
218 tdm_display_get_capture_available_size(tdm_display *dpy, int *min_w, int *min_h,
219 int *max_w, int *max_h, int *preferred_align);
222 * @brief Get the max layer counts which a display object can show on screen.
223 * @details -1 means that a TDM backend module doesn't define the value.
224 * @param[in] dpy A display object
225 * @param[out] count The max count of layers
226 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
229 tdm_display_get_max_layer_count(tdm_display *dpy, int *max_count);
232 * @brief Get the output counts which a display object has.
233 * @param[in] dpy A display object
234 * @param[out] count The count of outputs
235 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
236 * @see tdm_display_get_output
239 tdm_display_get_output_count(tdm_display *dpy, int *count);
242 * @brief Get a output object which has the given index.
243 * @param[in] dpy A display object
244 * @param[in] index The index of a output object
245 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
246 * @return A output object if success. Otherwise, NULL.
247 * @see tdm_display_get_output_count
250 tdm_display_get_output(tdm_display *dpy, int index, tdm_error *error);
253 * @brief Create a pp object.
254 * @param[in] dpy A display object
255 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
256 * @return A pp object if success. Otherwise, NULL.
257 * @see tdm_pp_destroy
260 tdm_display_create_pp(tdm_display *dpy, tdm_error *error);
263 * @brief Get the capabilities of a output object.
264 * @param[in] output A output object
265 * @param[out] capabilities The capabilities of a output object
266 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
269 tdm_output_get_capabilities(tdm_output *output,
270 tdm_output_capability *capabilities);
273 * @brief Get the model information of a output object.
274 * @param[in] output A output object
275 * @param[out] maker The output maker.
276 * @param[out] model The output model.
277 * @param[out] name The output name.
278 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
281 tdm_output_get_model_info(tdm_output *output, const char **maker,
282 const char **model, const char **name);
285 * @brief Get the connection status of a output object.
286 * @param[in] output A output object
287 * @param[out] status The connection status.
288 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
291 tdm_output_get_conn_status(tdm_output *output, tdm_output_conn_status *status);
294 * @brief Add a output change handler
295 * @details The handler will be called when the status of a
296 * output object is changed. connection, DPMS, etc.
297 * @param[in] output A output object
298 * @param[in] func A output change handler
299 * @param[in] user_data The user data
300 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
303 tdm_output_add_change_handler(tdm_output *output,
304 tdm_output_change_handler func,
308 * @brief Remove a output change handler
309 * @param[in] output A output object
310 * @param[in] func A output change handler
311 * @param[in] user_data The user data
312 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
315 tdm_output_remove_change_handler(tdm_output *output,
316 tdm_output_change_handler func,
320 * @brief Get the connection type of a output object.
321 * @param[in] output A output object
322 * @param[out] type The connection type.
323 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
326 tdm_output_get_output_type(tdm_output *output, tdm_output_type *type);
329 * @brief Get the layer counts which a output object has.
330 * @param[in] output A output object
331 * @param[out] count The count of layers
332 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
333 * @see tdm_output_get_layer
336 tdm_output_get_layer_count(tdm_output *output, int *count);
339 * @brief Get a layer object which has the given index.
340 * @param[in] output A output object
341 * @param[in] index The index of a layer object
342 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
343 * @return A layer object if success. Otherwise, NULL.
344 * @see tdm_output_get_layer_count
347 tdm_output_get_layer(tdm_output *output, int index, tdm_error *error);
350 * @brief Get the available property array of a output object.
351 * @param[in] output A output object
352 * @param[out] props The available property array
353 * @param[out] count The count of properties
354 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
357 tdm_output_get_available_properties(tdm_output *output, const tdm_prop **props,
361 * @brief Get the available mode array of a output object.
362 * @param[in] output A output object
363 * @param[out] modes The available mode array
364 * @param[out] count The count of modes
365 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
368 tdm_output_get_available_modes(tdm_output *output,
369 const tdm_output_mode **modes, int *count);
372 * @brief Get the available size of a output object.
373 * @details -1 means that a TDM backend module doesn't define the value.
374 * @param[in] output A output object
375 * @param[out] min_w The minimum width which TDM can handle
376 * @param[out] min_h The minimum height which TDM can handle
377 * @param[out] max_w The maximum width which TDM can handle
378 * @param[out] max_h The maximum height which TDM can handle
379 * @param[out] preferred_align The preferred align width which TDM can handle
380 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
383 tdm_output_get_available_size(tdm_output *output, int *min_w, int *min_h,
384 int *max_w, int *max_h, int *preferred_align);
387 * @brief Get the available cursor size of a output object.
388 * @details -1 means that a TDM backend module doesn't define the value.
389 * @param[in] output A output object
390 * @param[out] min_w The minimum width which TDM can handle
391 * @param[out] min_h The minimum height which TDM can handle
392 * @param[out] max_w The maximum width which TDM can handle
393 * @param[out] max_h The maximum height which TDM can handle
394 * @param[out] preferred_align The preferred align width which TDM can handle
395 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
398 tdm_output_get_cursor_available_size(tdm_output *output, int *min_w, int *min_h,
399 int *max_w, int *max_h, int *preferred_align);
402 * @brief Get the physical size of a output object.
403 * @param[in] output A output object
404 * @param[out] mmWidth The milimeter width
405 * @param[out] mmHeight The milimeter height
406 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
409 tdm_output_get_physical_size(tdm_output *output, unsigned int *mmWidth,
410 unsigned int *mmHeight);
413 * @brief Get the subpixel of a output object.
414 * @param[in] output A output object
415 * @param[out] subpixel The subpixel
416 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
419 tdm_output_get_subpixel(tdm_output *output, unsigned int *subpixel);
422 * @brief Get the pipe of a output object.
423 * @param[in] output A output object
424 * @param[out] pipe The pipe
425 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
428 tdm_output_get_pipe(tdm_output *output, unsigned int *pipe);
431 * @brief Get the index of a primary layer.
432 * @param[in] output A output object
433 * @param[out] index The primary layer index
434 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
437 tdm_output_get_primary_index(tdm_output *output, int *index);
440 * @brief Set the property which has a given id.
441 * @param[in] output A output object
442 * @param[in] id The property id
443 * @param[in] value The value
444 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
447 tdm_output_set_property(tdm_output *output, unsigned int id, tdm_value value);
450 * @brief Get the property which has a given id
451 * @param[in] output A output object
452 * @param[in] id The property id
453 * @param[out] value The value
454 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
457 tdm_output_get_property(tdm_output *output, unsigned int id, tdm_value *value);
460 * @brief Wait for VBLANK
461 * @details After interval vblanks, a user vblank handler will be called.
462 * @param[in] output A output object
463 * @param[in] interval vblank interval
464 * @param[in] sync 0: asynchronous, 1:synchronous
465 * @param[in] func A user vblank handler
466 * @param[in] user_data The user data
467 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
468 * @see #tdm_output_vblank_handler
471 tdm_output_wait_vblank(tdm_output *output, int interval, int sync,
472 tdm_output_vblank_handler func, void *user_data);
475 * @brief Commit changes for a output object
476 * @details After all change of a output object are applied, a user commit handler
478 * @param[in] output A output object
479 * @param[in] sync 0: asynchronous, 1:synchronous
480 * @param[in] func A user commit handler
481 * @param[in] user_data The user data
482 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
483 * @see #tdm_layer_commit
486 tdm_output_commit(tdm_output *output, int sync, tdm_output_commit_handler func,
490 * @brief Remove the user vblank handler
491 * @param[in] output A output object
492 * @param[in] func A user vblank handler
493 * @param[in] user_data The user data
494 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
497 tdm_output_remove_vblank_handler(tdm_output *output, tdm_output_vblank_handler func, void *user_data);
500 * @brief Remove the user commit handler
501 * @param[in] output A output object
502 * @param[in] func A user commit handler
503 * @param[in] user_data The user data
504 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
507 tdm_output_remove_commit_handler(tdm_output *output, tdm_output_commit_handler func, void *user_data);
510 * @brief Set one of available modes of a output object
511 * @param[in] output A output object
512 * @param[in] mode A output mode
513 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
516 tdm_output_set_mode(tdm_output *output, const tdm_output_mode *mode);
519 * @brief Get the mode of a output object
520 * @param[in] output A output object
521 * @param[out] mode A output mode
522 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
525 tdm_output_get_mode(tdm_output *output, const tdm_output_mode **mode);
528 * @brief Set DPMS of a output object synchronously
529 * @param[in] output A output object
530 * @param[in] dpms_value DPMS value
531 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
532 * @see tdm_output_set_dpms_async
535 tdm_output_set_dpms(tdm_output *output, tdm_output_dpms dpms_value);
538 * @brief Set DPMS of a output object asynchronously
539 * @details This function can be used when a output supports the asynchronous DPMS
540 * control. The output has #TDM_OUTPUT_CAPABILITY_ASYNC_DPMS flags which
541 * #tdm_output_get_capabilities returns. If an output change handler is added with
542 * #tdm_output_add_change_handler, the output change handler will be called when
543 * the DPMS status is changed indeed.
544 * @param[in] output A output object
545 * @param[in] dpms_value DPMS value
546 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
547 * @see tdm_output_add_change_handler, tdm_output_set_dpms,
548 * tdm_output_get_capabilities, #TDM_OUTPUT_CAPABILITY_ASYNC_DPMS.
551 tdm_output_set_dpms_async(tdm_output *output, tdm_output_dpms dpms_value);
554 * @brief Get DPMS of a output object
555 * @param[in] output A output object
556 * @param[out] dpms_value DPMS value
557 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
560 tdm_output_get_dpms(tdm_output *output, tdm_output_dpms *dpms_value);
563 * @brief Create a capture object of a output object
564 * @param[in] output A output object
565 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
566 * @return A capture object
567 * @see tdm_capture_destroy
570 tdm_output_create_capture(tdm_output *output, tdm_error *error);
573 * @brief Creates a new window on the given display.
574 * @param[in] output A output object
575 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
576 * @return A created window object
580 tdm_output_hwc_create_window(tdm_output *output, tdm_error *error);
583 * @brief Destroys the given window.
584 * @param[in] output A output object
585 * @param[in] window the pointer of the window to destroy
586 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
590 tdm_output_hwc_destroy_window(tdm_output *output, tdm_hwc_window *hwc_window);
593 * @brief Set the client(relative to the TDM) target buffer
594 * @details Sets the buffer which will receive the output of client composition.
595 * Window marked as TDM_COMPOSITION_CLIENT or TDM_COMPOSITION_DEVICE_CANDIDATE
596 * will be composited into this buffer prior to the call to tdm_output_commit(),
597 * and windows not marked as TDM_COMPOSITION_CLIENT and
598 * TDM_COMPOSITION_DEVICE_CANDIDATE should be composited with this buffer by the
601 * The buffer handle provided may be null if no windows are being composited by
602 * the client. This must not result in an error (unless an invalid display
603 * handle is also provided).
605 * The damage parameter describes a buffer damage region as defined in the
606 * description of tdm_hwc_window_set_buffer_damage().
608 * Will be called before tdm_output_commit() if any of the layers are marked as
609 * TDM_COMPOSITION_CLIENT or TDM_COMPOSITION_DEVICE_CANDIDATE. If no layers are
610 * so marked, then it is not necessary to call this function. It is not necessary
611 * to call tdm_output_hwc_validate() after changing the target through this function.
612 * @param[in] output A output object
613 * @param[in] target The new target buffer
614 * @param[in] damage The buffer damage region
615 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
619 tdm_output_hwc_set_client_target_buffer(tdm_output *output, tbm_surface_h target_buffer,
620 tdm_hwc_region damage);
623 * @brief Validate the output
624 * @details Instructs the device to inspect all of the layer state and
625 * determine if there are any composition type changes necessary before
626 * presenting the output. Permitted changes are described in the definition
627 * of tdm_hwc_window_composition_t above.
628 * @param[in] output A output object
629 * @param[out] num_types The number of composition type changes required by
630 * the device; if greater than 0, the client must either set and validate new
631 * types, or call tdm_output_hwc_accept_changes() to accept the changes returned by
632 * tdm_output_hwc_get_changed_composition_types(); must be the same as the number of
633 * changes returned by tdm_output_hwc_get_changed_composition_types (see the
634 * declaration of that function for more information); pointer will be non-NULL
635 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
639 tdm_output_hwc_validate(tdm_output *output, uint32_t *num_types);
642 * @brief Set the 'need to validate' handler for the 'output'
644 * @details During backend's work it may need to ask for the revalidation
645 * (make client (E20) do tdm_output_hwc_validate() again), so a 'hndl' will
646 * be called as such need happen. Only one handler per output is supported.
648 * @param[in] output The output object a hndl is going to be registered for.
649 * @param[in] hndl The handler which will be called on the 'need to validate' event.
651 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
655 tdm_output_hwc_set_need_validate_handler(tdm_output *output,
656 tdm_output_need_validate_handler hndl);
659 * @brief Get changed composition types
660 * @details Retrieves the windows for which the device requires a different
661 * composition type than had been set prior to the last call to tdm_output_hwc_validate().
662 * The client will either update its state with these types and call
663 * tdm_output_hwc_accept_changes, or will set new types and attempt to validate the
665 * windows and types may be NULL to retrieve the number of elements which
666 * will be returned. The number of elements returned must be the same as the
667 * value returned in num_types from the last call to tdm_output_hwc_validate().
668 * @param[in] output A output object
669 * @param[out] num_elements If windows or types were NULL, the number of layers
670 * and types which would have been returned; if both were non-NULL, the
671 * number of elements returned in layers and types, which must not exceed
672 * the value stored in num_elements prior to the call; pointer will be
674 * @param[in] output A output object
675 * @param[out] windows An array of windows
676 * @param[out] composition_types An array of composition types, each corresponding
677 * to an element of windows
678 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
682 tdm_output_hwc_get_changed_composition_types(tdm_output *output,uint32_t *num_elements,
683 tdm_hwc_window **hwc_window,
684 tdm_hwc_window_composition *composition_types);
687 * @brief Accepts the changes required by the device
688 * @details Accepts the changes required by the device from the previous
689 * tdm_output_hwc_validate() call (which may be queried using
690 * tdm_output_get_chaged_composition_types()) and revalidates the display. This
691 * function is equivalent to requesting the changed types from
692 * tdm_output_get_chaged_composition_types(), setting those types on the
693 * corresponding windows, and then calling tdm_output_hwc_validate again.
694 * After this call it must be valid to present this display. Calling this after
695 * tdm_output_hwc_validate() returns 0 changes must succeed with TDM_ERROR_NONE, but
696 * should have no other effect.
697 * @param[in] output A output object
698 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
702 tdm_output_hwc_accept_changes(tdm_output *output);
705 * @brief Get a target buffer queue
706 * @details Buffers from target buffer queue will receive the output of
707 * client composition. Window marked as TDM_COMPOSITION_CLIENT or
708 * TDM_COMPOSITION_DEVICE_CANDIDATE will be composited into this buffers
709 * prior to the call to tdm_output_commit().
710 * @param[in] output A output object
711 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
712 * @return A buffer queue
716 tdm_output_hwc_get_target_buffer_queue(tdm_output *output, tdm_error *error);
719 * @brief Get the capabilities of a layer object.
720 * @param[in] layer A layer object
721 * @param[out] capabilities The capabilities of a layer object
722 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
725 tdm_layer_get_capabilities(tdm_layer *layer,
726 tdm_layer_capability *capabilities);
729 * @brief Get the available format array of a layer object.
730 * @param[in] layer A layer object
731 * @param[out] formats The available format array
732 * @param[out] count The count of formats
733 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
736 tdm_layer_get_available_formats(tdm_layer *layer, const tbm_format **formats,
740 * @brief Get the available property array of a layer object.
741 * @param[in] layer A layer object
742 * @param[out] props The available property array
743 * @param[out] count The count of properties
744 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
747 tdm_layer_get_available_properties(tdm_layer *layer, const tdm_prop **props,
751 * @brief Get the zpos of a layer object.
753 * - GRAPHIC layers have fixed zpos. It starts from 0. It's @b non-changeable.
754 * - But the zpos of VIDEO layers will be decided by a backend module side.
755 * - A frontend user only can set the relative zpos to VIDEO layers via #tdm_layer_set_video_pos
756 * - The zpos of video layers is less than GRAPHIC layers or more than GRAPHIC
757 * layers. ie, ..., -2, -1, 4, 5, ... (if 0 <= GRAPHIC layer's zpos < 4).
758 * -------------------------------- graphic layer 3 <-- top most layer
759 * -------------------------------- graphic layer 2
760 * -------------------------------- graphic layer 1
761 * -------------------------------- graphic layer 0
762 * -------------------------------- video layer -1
763 * -------------------------------- video layer -2 <-- lowest layer
764 * @param[in] layer A layer object
765 * @param[out] zpos The zpos
766 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
767 * @see tdm_layer_set_video_pos, tdm_layer_capability
770 tdm_layer_get_zpos(tdm_layer *layer, int *zpos);
773 * @brief Set the property which has a given id.
774 * @param[in] layer A layer object
775 * @param[in] id The property id
776 * @param[in] value The value
777 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
780 tdm_layer_set_property(tdm_layer *layer, unsigned int id, tdm_value value);
783 * @brief Get the property which has a given id.
784 * @param[in] layer A layer object
785 * @param[in] id The property id
786 * @param[out] value The value
787 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
790 tdm_layer_get_property(tdm_layer *layer, unsigned int id, tdm_value *value);
793 * @brief Set the geometry information to a layer object
794 * @details The geometry information will be applied when the output object
795 * of a layer object is committed. If a layer has TDM_LAYER_CAPABILITY_NO_CROP
796 * capability, a layer will ignore the pos(crop) information of #tdm_info_layer's
798 * @param[in] layer A layer object
799 * @param[in] info The geometry information
800 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
801 * @see tdm_layer_commit
804 tdm_layer_set_info(tdm_layer *layer, tdm_info_layer *info);
807 * @brief Get the geometry information to a layer object
808 * @param[in] layer A layer object
809 * @param[out] info The geometry information
810 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
813 tdm_layer_get_info(tdm_layer *layer, tdm_info_layer *info);
816 * @brief Set a TDM buffer to a layer object
817 * @details A TDM buffer will be applied when the output object
818 * of a layer object is committed.
819 * @param[in] layer A layer object
820 * @param[in] buffer A TDM buffer
821 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
822 * @see tdm_layer_commit
825 tdm_layer_set_buffer(tdm_layer *layer, tbm_surface_h buffer);
828 * @brief Unset a TDM buffer from a layer object
829 * @details When this function is called, a current showing buffer will be
830 * disappeared from screen. Then nothing is showing on a layer object.
831 * @param[in] layer A layer object
832 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
835 tdm_layer_unset_buffer(tdm_layer *layer);
838 * @brief Commit changes for a layer object
839 * @details After all change of a layer object are applied, a user commit handler
841 * @param[in] layer A layer object
842 * @param[in] func A user commit handler
843 * @param[in] user_data The user data
844 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
847 tdm_layer_commit(tdm_layer *layer, tdm_layer_commit_handler func, void *user_data);
850 tdm_layer_is_committing(tdm_layer *layer, unsigned int *committing);
853 * @brief Remove the user commit handler
854 * @param[in] layer A layer object
855 * @param[in] func A user commit handler
856 * @param[in] user_data The user data
857 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
860 tdm_layer_remove_commit_handler(tdm_layer *layer, tdm_layer_commit_handler func, void *user_data);
863 * @brief Get a displaying TDM buffer from a layer object
864 * @details A displaying TDM buffer is a current showing buffer on screen
865 * that is set to layer object and applied output object of a layer object.
866 * @param[in] layer A layer object
867 * @return A TDM buffer if success. Otherwise, NULL.
870 tdm_layer_get_displaying_buffer(tdm_layer *layer, tdm_error *error);
873 * @brief Set a TBM surface_queue to a layer object
874 * @details A TBM surface_queue will be applied when the output object
875 * of a layer object is committed. and TDM layer will be automatically updated
876 * @param[in] layer A layer object
877 * @param[in] buffer_queue A TBM surface_queue
878 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
879 * @see tdm_layer_commit
882 tdm_layer_set_buffer_queue(tdm_layer *layer, tbm_surface_queue_h buffer_queue);
885 * @brief Unset a TBM surface_queue from a layer object
886 * @details When this function is called, a current surface_queue will be
887 * disappeared from screen. Then nothing is showing on a layer object.
888 * @param[in] layer A layer object
889 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
892 tdm_layer_unset_buffer_queue(tdm_layer *layer);
895 * @brief Check wheter a layer object is available for a frontend user to use.
896 * @details A layer object is not usable if a TDM buffer is showing on screen
897 * via this layer object. By calling #tdm_layer_unset_buffer, this layer object
898 * will become usable.
899 * @param[in] layer A layer object
900 * @param[out] usable 1 if usable, 0 if not usable
901 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
904 tdm_layer_is_usable(tdm_layer *layer, unsigned int *usable);
907 * @brief Set the relative zpos to a VIDEO layer object
908 * @details The zpos value is less than the minimum zpos of GRAPHIC layers, or
909 * it is more than the maximum zpos of GRAPHIC layers.
910 * @param[in] layer A VIDEO layer object
911 * @param[in] zpos The zpos
912 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
913 * @see tdm_layer_get_zpos, tdm_layer_capability
916 tdm_layer_set_video_pos(tdm_layer *layer, int zpos);
919 * @brief Create a capture object of a layer object
920 * @param[in] layer A layer object
921 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
922 * @return A capture object
923 * @see tdm_capture_destroy
926 tdm_layer_create_capture(tdm_layer *layer, tdm_error *error);
929 * @brief Get buffer flags from a layer object
930 * @param[in] layer A layer object
931 * @param[out] flags a buffer flags value
932 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
935 tdm_layer_get_buffer_flags(tdm_layer *layer, unsigned int *flags);
938 * @brief Get a buffer queue for the window object
939 * @details These buffers are used to composite by hardware a client content in
941 * @param[in] hwc_window A window object
942 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
943 * @return A tbm buffer queue
947 tdm_hwc_window_get_tbm_buffer_queue(tdm_hwc_window *hwc_window, tdm_error *error);
950 * @brief Sets the desired Z order of the given window. A window with
951 * a greater Z value occludes a window with a lesser Z value.
952 * @param[in] hwc_window A window object
953 * @param[in] z the new Z order
954 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
958 tdm_hwc_window_set_zpos(tdm_hwc_window *hwc_window, uint32_t zpos);
961 * @brief Sets the desired composition type of the given window.
962 * @details During tdm_output_hwc_validate(), the device may request changes to
963 * the composition types of any of the layers as described in the definition
964 * of tdm_hwc_window_composition_t above.
965 * @param[in] hwc_window A window object
966 * @param[in] composition_type The new composition type
967 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
971 tdm_hwc_window_set_composition_type(tdm_hwc_window *hwc_window,
972 tdm_hwc_window_composition composition_type);
975 * @brief Set the buffer damage
976 * @details Provides the region of the source buffer which has been modified
977 * since the last frame. This region does not need to be validated before
978 * calling tdm_output_commit().
979 * Once set through this function, the damage region remains the same until a
980 * subsequent call to this function.
981 * If damage.num_rects > 0, then it may be assumed that any portion of the source
982 * buffer not covered by one of the rects has not been modified this frame. If
983 * damage.num_rects == 0, then the whole source buffer must be treated as if it
985 * If the layer's contents are not modified relative to the prior frame, damage
986 * will contain exactly one empty rect([0, 0, 0, 0]).
987 * The damage rects are relative to the pre-transformed buffer, and their origin
988 * is the top-left corner. They will not exceed the dimensions of the latched
990 * @param[in] hwc_window A window object
991 * @param[in] damage The new buffer damage region
992 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
996 tdm_hwc_window_set_buffer_damage(tdm_hwc_window *hwc_window, tdm_hwc_region damage);
999 * @brief Set the information to a window object
1000 * @details The information will be applied when the output object of a window
1001 * object is committed.
1002 * @param[in] hwc_window A window object
1003 * @param[in] info The information
1004 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1008 tdm_hwc_window_set_info(tdm_hwc_window *hwc_window, tdm_hwc_window_info *info);
1011 * @brief Set a TBM buffer to a window object
1012 * @details A TBM buffer will be applied when the output object of a layer
1013 * object is committed.
1014 * @param[in] hwc_window A window object
1015 * @param[in] buffer A TDM buffer
1016 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1020 tdm_hwc_window_set_buffer(tdm_hwc_window *hwc_window, tbm_surface_h buffer);
1023 * @brief Set a flags to a window object
1024 * @param[in] hwc_window A window object
1025 * @param[in] flags A hwc_window flags
1026 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1030 tdm_hwc_window_set_flags(tdm_hwc_window *hwc_window, tdm_hwc_window_flag flags);
1033 * @brief Unset a flags from a window object
1034 * @param[in] hwc_window A window object
1035 * @param[in] flags A hwc_window flags
1036 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1040 tdm_hwc_window_unset_flags(tdm_hwc_window *hwc_window, tdm_hwc_window_flag flags);
1043 * @brief Get the window video capability
1044 * @param[in] hwc_window A window object
1045 * @param[out] video_capability A hwc window video capability
1046 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1050 tdm_hwc_window_video_get_capability(tdm_hwc_window *hwc_window,
1051 tdm_hwc_window_video_capability *video_capability);
1054 * @brief Get the window video supported format
1055 * @param[in] hwc_window A window object
1056 * @param[out] formats A hwc window supported formats
1057 * @param[out] count A number of the hwc window supported formats
1058 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1062 tdm_hwc_window_video_get_supported_format(tdm_hwc_window *hwc_window,
1063 const tbm_format **formats,
1067 * @brief Destroy a pp object
1068 * @param[in] pp A pp object
1069 * @see tdm_display_create_pp
1072 tdm_pp_destroy(tdm_pp *pp);
1075 * @brief Set the geometry information to a pp object
1076 * @param[in] pp A pp object
1077 * @param[in] info The geometry information
1078 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1079 * @see tdm_pp_commit
1082 tdm_pp_set_info(tdm_pp *pp, tdm_info_pp *info);
1085 * @brief Set the PP done handler to a pp object
1087 * The user PP done handler will be called after converting a source buffer's image
1088 * to a destination buffer.
1089 * @param[in] pp A pp object
1090 * @param[in] func A user PP done handler
1091 * @param[in] user_data The user data
1092 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1095 tdm_pp_set_done_handler(tdm_pp *pp, tdm_pp_done_handler func, void *user_data);
1098 * @brief Attach a source buffer and a destination buffer to a pp object
1099 * @param[in] pp A pp object
1100 * @param[in] src A source buffer
1101 * @param[in] dst A destination buffer
1102 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1103 * @see tdm_pp_commit, tdm_pp_set_done_handler
1106 tdm_pp_attach(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst);
1109 * @brief Commit changes for a pp object
1110 * @param[in] pp A pp object
1111 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1114 tdm_pp_commit(tdm_pp *pp);
1117 * @brief Destroy a capture object
1118 * @param[in] capture A capture object
1119 * @see tdm_output_create_capture, tdm_layer_create_capture
1122 tdm_capture_destroy(tdm_capture *capture);
1125 * @brief Set the geometry information to a capture object
1126 * @param[in] capture A capture object
1127 * @param[in] info The geometry information
1128 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1129 * @see tdm_capture_commit
1132 tdm_capture_set_info(tdm_capture *capture, tdm_info_capture *info);
1135 * @brief Set the capture done handler to a capture object
1137 * The user capture done handler will be called after capturing a screen into a
1139 * @param[in] capture A capture object
1140 * @param[in] func A user capture done handler
1141 * @param[in] user_data The user data
1142 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1145 tdm_capture_set_done_handler(tdm_capture *capture, tdm_capture_done_handler func, void *user_data);
1148 * @brief Attach a TDM buffer to a capture object
1149 * @param[in] capture A capture object
1150 * @param[in] buffer A TDM buffer
1151 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1152 * @see tdm_capture_commit, tdm_capture_set_done_handler
1155 tdm_capture_attach(tdm_capture *capture, tbm_surface_h buffer);
1158 * @brief Commit changes for a capture object
1159 * @param[in] capture A capture object
1160 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1163 tdm_capture_commit(tdm_capture *capture);
1166 * @brief The release handler of a TDM buffer
1167 * @param[in] buffer A TDM buffer
1168 * @param[in] user_data user data
1169 * @see tdm_buffer_add_release_handler, tdm_buffer_remove_release_handler
1171 typedef void (*tdm_buffer_release_handler)(tbm_surface_h buffer,
1175 * @brief Add a release handler to a TDM buffer
1177 * TDM has its own buffer release mechanism to let an frontend user know when a TDM buffer
1178 * becomes available for a next job. A TDM buffer can be used for TDM to show
1179 * it on screen or to capture an output and a layer. After all operations,
1180 * TDM will release it immediately when TDM doesn't need it any more.
1181 * @param[in] buffer A TDM buffer
1182 * @param[in] func A release handler
1183 * @param[in] user_data user data
1184 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1185 * @see tdm_buffer_remove_release_handler
1188 tdm_buffer_add_release_handler(tbm_surface_h buffer,
1189 tdm_buffer_release_handler func, void *user_data);
1192 * @brief Remove a release handler from a TDM buffer
1193 * @param[in] buffer A TDM buffer
1194 * @param[in] func A release handler
1195 * @param[in] user_data user data
1196 * @see tdm_buffer_add_release_handler
1199 tdm_buffer_remove_release_handler(tbm_surface_h buffer,
1200 tdm_buffer_release_handler func, void *user_data);
1203 * @brief The handler of a vblank object
1204 * @see #tdm_vblank_wait, #tdm_vblank_wait_seq
1206 typedef void (*tdm_vblank_handler)(tdm_vblank *vblank, tdm_error error, unsigned int sequence,
1207 unsigned int tv_sec, unsigned int tv_usec, void *user_data);
1210 * @brief Set the vblank fps for the given PID and name.
1211 * @param[in] pid The process ID
1212 * @param[in] name The client vblank name
1213 * @param[in] fps The client vblank fps
1214 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1217 tdm_vblank_set_client_vblank_fps(unsigned int pid, const char *name, unsigned int fps);
1220 * @brief Set the vblank global fps for the entire system.
1221 * @param[in] enable 1:enable, 0:disable
1222 * @param[in] fps The vblank global fps
1224 * This global fps will be applied to all client's vblanks for all outputs.
1225 * If the client's vblank fps is less than this, the global fps will be ignored
1226 * for that client. And if a client calls #tdm_vblank_ignore_global_fps to ignore
1227 * the global fps, it will be ignored also.
1228 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1231 tdm_vblank_enable_global_fps(unsigned int enable, unsigned int fps);
1234 * @brief Create a vblank object
1235 * @param[in] dpy A display object
1236 * @param[in] output A output object
1237 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
1238 * @return A vblank object
1239 * @see #tdm_vblank_destroy
1242 tdm_vblank_create(tdm_display *dpy, tdm_output *output, tdm_error *error);
1245 * @brief Destroy a vblank object
1246 * @param[in] vblank A vblank object
1247 * @see #tdm_vblank_create
1250 tdm_vblank_destroy(tdm_vblank *vblank);
1253 * @brief Set the name to a vblank object
1254 * @details The default name is "unknown"
1255 * @param[in] vblank A vblank object
1256 * @param[in] name vblank name
1257 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1260 tdm_vblank_set_name(tdm_vblank *vblank, const char *name);
1263 * @brief Get the name for a vblank object
1264 * @details The default name is "unknown"
1265 * @param[in] vblank A vblank object
1266 * @param[out] name vblank name
1267 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1270 tdm_vblank_get_name(tdm_vblank *vblank, const char **name);
1273 * @brief Set the fps to a vblank object
1274 * @details Default is the @b vertical @b refresh @b rate of the given output.
1275 * @param[in] vblank A vblank object
1276 * @param[in] fps over 0
1277 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1280 tdm_vblank_set_fps(tdm_vblank *vblank, unsigned int fps);
1283 * @brief Get the fps for a vblank object
1284 * @param[in] vblank A vblank object
1285 * @param[out] fps over 0
1286 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1289 tdm_vblank_get_fps(tdm_vblank *vblank, unsigned int *fps);
1292 * @brief Ignore the vblank global fps
1294 * The global fps will be applied to all client's vblanks for all outputs.
1295 * If the client's vblank fps is less than this, the global fps will be ignored
1296 * for that client. And if a client calls #tdm_vblank_ignore_global_fps to ignore
1297 * the global fps, it will be ignored also.
1298 * @param[in] vblank A vblank object
1299 * @param[in] ignore 1: ignore 0:not ignore(default)
1300 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1303 tdm_vblank_ignore_global_fps(tdm_vblank *vblank, unsigned int ignore);
1306 * @brief Set the offset(milli-second) to a vblank object
1307 * @details Default is @b 0.
1308 * @param[in] vblank A vblank object
1309 * @param[in] offset the offset(milli-second)
1310 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1313 tdm_vblank_set_offset(tdm_vblank *vblank, int offset);
1316 * @brief Get the offset(milli-second) for a vblank object
1317 * @param[in] vblank A vblank object
1318 * @param[out] offset the offset(milli-second)
1319 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1322 tdm_vblank_get_offset(tdm_vblank *vblank, int *offset);
1325 * @brief Enable/Disable the fake vblank to a vblank object
1327 * If enable_fake == 0, #tdm_vblank_wait will return TDM_ERROR_DPMS_OFF
1328 * when DPMS off. Otherwise, #tdm_vblank_wait will return TDM_ERROR_NONE
1330 * @param[in] vblank A vblank object
1331 * @param[in] enable_fake 1:enable, 0:disable
1332 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1335 tdm_vblank_set_enable_fake(tdm_vblank *vblank, unsigned int enable_fake);
1338 * @brief Get the fake vblank
1339 * @param[in] vblank A vblank object
1340 * @param[out] enable_fake 1:enable, 0:disable
1341 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1344 tdm_vblank_get_enable_fake(tdm_vblank *vblank, unsigned int *enable_fake);
1347 * @brief Wait for a vblank
1349 * Once #tdm_vblank_wait returns TDM_ERROR_NONE, the user vblank handler(#tdm_vblank_handler)
1350 * SHOULD be called after the given interval. \n
1351 * The sequence value of tdm_vblank_handler is the relative value of fps.
1352 * If fps = 10, this sequence value should be increased by 10 during 1 second.
1353 * @param[in] vblank A vblank object
1354 * @param[in] req_sec The vblank request time(second)
1355 * @param[in] req_usec The vblank request time(micro-second)
1356 * @param[in] interval The vblank interval
1357 * @param[in] func The user vblank handler
1358 * @param[in] user_data The user data
1359 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1362 tdm_vblank_wait(tdm_vblank *vblank, unsigned int req_sec, unsigned int req_usec,
1363 unsigned int interval, tdm_vblank_handler func, void *user_data);
1366 * @brief Wait for a vblank with the target sequence number
1367 * @param[in] vblank A vblank object
1368 * @param[in] req_sec The vblank request time(second)
1369 * @param[in] req_usec The vblank request time(micro-second)
1370 * @param[in] sequence The target sequence number
1371 * @param[in] func The user client vblank handler
1372 * @param[in] user_data The user data
1373 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1376 tdm_vblank_wait_seq(tdm_vblank *vblank, unsigned int req_sec, unsigned int req_usec,
1377 unsigned int sequence, tdm_vblank_handler func, void *user_data);
1383 #endif /* _TDM_H_ */