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;
68 * @brief The output change handler
69 * @details This handler will be called when the status of a output object is
72 typedef void (*tdm_output_change_handler)(tdm_output *output,
73 tdm_output_change_type type,
78 * @brief Initialize a display object
79 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
80 * @return A display object
81 * @see tdm_display_deinit
84 tdm_display_init(tdm_error *error);
87 * @brief Deinitialize a display object
88 * @param[in] dpy A display object
89 * @see tdm_display_init
92 tdm_display_deinit(tdm_display *dpy);
95 * @brief Update a display object
97 * When new output is connected, a frontend user need to call this function.
98 * And a frontend user can the new output information with tdm_output_get_xxx functions.
99 * @param[in] dpy A display object
100 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
103 tdm_display_update(tdm_display *dpy);
106 * @brief Get the file descriptor
107 * @details TDM handles the events of fd with #tdm_display_handle_events.
108 * @param[in] dpy A display object
109 * @param[out] fd The file descriptor
110 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
111 * @see tdm_display_handle_events
114 tdm_display_get_fd(tdm_display *dpy, int *fd);
117 * @brief Handle the events
118 * @param[in] dpy A display object
119 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
120 * @see tdm_display_get_fd
123 tdm_display_handle_events(tdm_display *dpy);
126 * @brief Get the information of the TDM backend module.
127 * @param[in] dpy A display object
128 * @param[out] name The name of the TDM backend module
129 * @param[out] vendor The vendor of the TDM backend module
130 * @param[out] version The version of the TDM backend module
131 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
134 tdm_display_get_backend_info(tdm_display *dpy, const char **name,
135 const char **vendor, int *major, int *minor);
138 * @brief Get the capabilities of a display object.
139 * @details A frontend user can get whether TDM supports pp/capture functionality with this function.
140 * @param[in] dpy A display object
141 * @param[out] capabilities The capabilities of a display object
142 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
145 tdm_display_get_capabilities(tdm_display *dpy,
146 tdm_display_capability *capabilities);
149 * @brief Get the pp capabilities of a display object.
150 * @param[in] dpy A display object
151 * @param[out] capabilities The pp capabilities
152 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
155 tdm_display_get_pp_capabilities(tdm_display *dpy,
156 tdm_pp_capability *capabilities);
159 * @brief Get the pp available format array of a display object.
160 * @param[in] dpy A display object
161 * @param[out] formats The pp available format array
162 * @param[out] count The count of formats
163 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
166 tdm_display_get_pp_available_formats(tdm_display *dpy,
167 const tbm_format **formats, int *count);
170 * @brief Get the pp available size of a display object.
171 * @details -1 means that a TDM backend module doesn't define the value.
172 * @param[in] dpy A display object
173 * @param[out] min_w The minimum width which TDM can handle
174 * @param[out] min_h The minimum height which TDM can handle
175 * @param[out] max_w The maximum width which TDM can handle
176 * @param[out] max_h The maximum height which TDM can handle
177 * @param[out] preferred_align The preferred align width which TDM can handle
178 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
181 tdm_display_get_pp_available_size(tdm_display *dpy, int *min_w, int *min_h,
182 int *max_w, int *max_h, int *preferred_align);
185 * @brief Get the capture capabilities of a display object.
186 * @param[in] dpy A display object
187 * @param[out] capabilities The capture capabilities
188 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
191 tdm_display_get_capture_capabilities(tdm_display *dpy,
192 tdm_capture_capability *capabilities);
195 * @brief Get the capture available format array of a display object.
196 * @param[in] dpy A display object
197 * @param[out] formats The capture available format array
198 * @param[out] count The count of formats
199 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
202 tdm_display_get_catpure_available_formats(tdm_display *dpy,
203 const tbm_format **formats, int *count);
206 * @brief Get the capture available size of a display object.
207 * @details -1 means that a TDM backend module doesn't define the value.
208 * @param[in] dpy A display object
209 * @param[out] min_w The minimum width which TDM can handle
210 * @param[out] min_h The minimum height which TDM can handle
211 * @param[out] max_w The maximum width which TDM can handle
212 * @param[out] max_h The maximum height which TDM can handle
213 * @param[out] preferred_align The preferred align width which TDM can handle
214 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
217 tdm_display_get_capture_available_size(tdm_display *dpy, int *min_w, int *min_h,
218 int *max_w, int *max_h, int *preferred_align);
221 * @brief Get the max layer counts which a display object can show on screen.
222 * @details -1 means that a TDM backend module doesn't define the value.
223 * @param[in] dpy A display object
224 * @param[out] count The max count of layers
225 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
228 tdm_display_get_max_layer_count(tdm_display *dpy, int *max_count);
231 * @brief Get the output counts which a display object has.
232 * @param[in] dpy A display object
233 * @param[out] count The count of outputs
234 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
235 * @see tdm_display_get_output
238 tdm_display_get_output_count(tdm_display *dpy, int *count);
241 * @brief Get a output object which has the given index.
242 * @param[in] dpy A display object
243 * @param[in] index The index of a output object
244 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
245 * @return A output object if success. Otherwise, NULL.
246 * @see tdm_display_get_output_count
249 tdm_display_get_output(tdm_display *dpy, int index, tdm_error *error);
252 * @brief Create a pp object.
253 * @param[in] dpy A display object
254 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
255 * @return A pp object if success. Otherwise, NULL.
256 * @see tdm_pp_destroy
259 tdm_display_create_pp(tdm_display *dpy, tdm_error *error);
262 * @brief Get the capabilities of a output object.
263 * @param[in] output A output object
264 * @param[out] capabilities The capabilities of a output object
265 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
268 tdm_output_get_capabilities(tdm_output *output,
269 tdm_output_capability *capabilities);
272 * @brief Get the model information of a output object.
273 * @param[in] output A output object
274 * @param[out] maker The output maker.
275 * @param[out] model The output model.
276 * @param[out] name The output name.
277 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
280 tdm_output_get_model_info(tdm_output *output, const char **maker,
281 const char **model, const char **name);
284 * @brief Get the connection status of a output object.
285 * @param[in] output A output object
286 * @param[out] status The connection status.
287 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
290 tdm_output_get_conn_status(tdm_output *output, tdm_output_conn_status *status);
293 * @brief Add a output change handler
294 * @details The handler will be called when the status of a
295 * output object is changed. connection, DPMS, etc.
296 * @param[in] output A output object
297 * @param[in] func A output change handler
298 * @param[in] user_data The user data
299 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
302 tdm_output_add_change_handler(tdm_output *output,
303 tdm_output_change_handler func,
307 * @brief Remove a output change handler
308 * @param[in] output A output object
309 * @param[in] func A output change handler
310 * @param[in] user_data The user data
311 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
314 tdm_output_remove_change_handler(tdm_output *output,
315 tdm_output_change_handler func,
319 * @brief Get the connection type of a output object.
320 * @param[in] output A output object
321 * @param[out] type The connection type.
322 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
325 tdm_output_get_output_type(tdm_output *output, tdm_output_type *type);
328 * @brief Get the layer counts which a output object has.
329 * @param[in] output A output object
330 * @param[out] count The count of layers
331 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
332 * @see tdm_output_get_layer
335 tdm_output_get_layer_count(tdm_output *output, int *count);
338 * @brief Get a layer object which has the given index.
339 * @param[in] output A output object
340 * @param[in] index The index of a layer object
341 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
342 * @return A layer object if success. Otherwise, NULL.
343 * @see tdm_output_get_layer_count
346 tdm_output_get_layer(tdm_output *output, int index, tdm_error *error);
349 * @brief Get the available property array of a output object.
350 * @param[in] output A output object
351 * @param[out] props The available property array
352 * @param[out] count The count of properties
353 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
356 tdm_output_get_available_properties(tdm_output *output, const tdm_prop **props,
360 * @brief Get the available mode array of a output object.
361 * @param[in] output A output object
362 * @param[out] modes The available mode array
363 * @param[out] count The count of modes
364 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
367 tdm_output_get_available_modes(tdm_output *output,
368 const tdm_output_mode **modes, int *count);
371 * @brief Get the available size of a output object.
372 * @details -1 means that a TDM backend module doesn't define the value.
373 * @param[in] output A output object
374 * @param[out] min_w The minimum width which TDM can handle
375 * @param[out] min_h The minimum height which TDM can handle
376 * @param[out] max_w The maximum width which TDM can handle
377 * @param[out] max_h The maximum height which TDM can handle
378 * @param[out] preferred_align The preferred align width which TDM can handle
379 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
382 tdm_output_get_available_size(tdm_output *output, int *min_w, int *min_h,
383 int *max_w, int *max_h, int *preferred_align);
386 * @brief Get the available cursor size of a output object.
387 * @details -1 means that a TDM backend module doesn't define the value.
388 * @param[in] output A output object
389 * @param[out] min_w The minimum width which TDM can handle
390 * @param[out] min_h The minimum height which TDM can handle
391 * @param[out] max_w The maximum width which TDM can handle
392 * @param[out] max_h The maximum height which TDM can handle
393 * @param[out] preferred_align The preferred align width which TDM can handle
394 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
397 tdm_output_get_cursor_available_size(tdm_output *output, int *min_w, int *min_h,
398 int *max_w, int *max_h, int *preferred_align);
401 * @brief Get the physical size of a output object.
402 * @param[in] output A output object
403 * @param[out] mmWidth The milimeter width
404 * @param[out] mmHeight The milimeter height
405 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
408 tdm_output_get_physical_size(tdm_output *output, unsigned int *mmWidth,
409 unsigned int *mmHeight);
412 * @brief Get the subpixel of a output object.
413 * @param[in] output A output object
414 * @param[out] subpixel The subpixel
415 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
418 tdm_output_get_subpixel(tdm_output *output, unsigned int *subpixel);
421 * @brief Get the pipe of a output object.
422 * @param[in] output A output object
423 * @param[out] pipe The pipe
424 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
427 tdm_output_get_pipe(tdm_output *output, unsigned int *pipe);
430 * @brief Get the index of a primary layer.
431 * @param[in] output A output object
432 * @param[out] index The primary layer index
433 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
436 tdm_output_get_primary_index(tdm_output *output, int *index);
439 * @brief Set the property which has a given id.
440 * @param[in] output A output object
441 * @param[in] id The property id
442 * @param[in] value The value
443 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
446 tdm_output_set_property(tdm_output *output, unsigned int id, tdm_value value);
449 * @brief Get the property which has a given id
450 * @param[in] output A output object
451 * @param[in] id The property id
452 * @param[out] value The value
453 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
456 tdm_output_get_property(tdm_output *output, unsigned int id, tdm_value *value);
459 * @brief Wait for VBLANK
460 * @details After interval vblanks, a user vblank handler will be called.
461 * @param[in] output A output object
462 * @param[in] interval vblank interval
463 * @param[in] sync 0: asynchronous, 1:synchronous
464 * @param[in] func A user vblank handler
465 * @param[in] user_data The user data
466 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
467 * @see #tdm_output_vblank_handler
470 tdm_output_wait_vblank(tdm_output *output, int interval, int sync,
471 tdm_output_vblank_handler func, void *user_data);
474 * @brief Commit changes for a output object
475 * @details After all change of a output object are applied, a user commit handler
477 * @param[in] output A output object
478 * @param[in] sync 0: asynchronous, 1:synchronous
479 * @param[in] func A user commit handler
480 * @param[in] user_data The user data
481 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
482 * @see #tdm_layer_commit
485 tdm_output_commit(tdm_output *output, int sync, tdm_output_commit_handler func,
489 * @brief Remove the user vblank handler
490 * @param[in] output A output object
491 * @param[in] func A user vblank handler
492 * @param[in] user_data The user data
493 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
496 tdm_output_remove_vblank_handler(tdm_output *output, tdm_output_vblank_handler func, void *user_data);
499 * @brief Remove the user commit handler
500 * @param[in] output A output object
501 * @param[in] func A user commit handler
502 * @param[in] user_data The user data
503 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
506 tdm_output_remove_commit_handler(tdm_output *output, tdm_output_commit_handler func, void *user_data);
509 * @brief Set one of available modes of a output object
510 * @param[in] output A output object
511 * @param[in] mode A output mode
512 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
515 tdm_output_set_mode(tdm_output *output, const tdm_output_mode *mode);
518 * @brief Get the mode of a output object
519 * @param[in] output A output object
520 * @param[out] mode A output mode
521 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
524 tdm_output_get_mode(tdm_output *output, const tdm_output_mode **mode);
527 * @brief Set DPMS of a output object synchronously
528 * @param[in] output A output object
529 * @param[in] dpms_value DPMS value
530 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
531 * @see tdm_output_set_dpms_async
534 tdm_output_set_dpms(tdm_output *output, tdm_output_dpms dpms_value);
537 * @brief Set DPMS of a output object asynchronously
538 * @details This function can be used when a output supports the asynchronous DPMS
539 * control. The output has #TDM_OUTPUT_CAPABILITY_ASYNC_DPMS flags which
540 * #tdm_output_get_capabilities returns. If an output change handler is added with
541 * #tdm_output_add_change_handler, the output change handler will be called when
542 * the DPMS status is changed indeed.
543 * @param[in] output A output object
544 * @param[in] dpms_value DPMS value
545 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
546 * @see tdm_output_add_change_handler, tdm_output_set_dpms,
547 * tdm_output_get_capabilities, #TDM_OUTPUT_CAPABILITY_ASYNC_DPMS.
550 tdm_output_set_dpms_async(tdm_output *output, tdm_output_dpms dpms_value);
553 * @brief Get DPMS of a output object
554 * @param[in] output A output object
555 * @param[out] dpms_value DPMS value
556 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
559 tdm_output_get_dpms(tdm_output *output, tdm_output_dpms *dpms_value);
562 * @brief Create a capture object of a output object
563 * @param[in] output A output object
564 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
565 * @return A capture object
566 * @see tdm_capture_destroy
569 tdm_output_create_capture(tdm_output *output, tdm_error *error);
572 * @brief Creates a new window on the given display.
573 * @param[in] output A output object
574 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
575 * @return A created window object
579 tdm_output_hwc_create_window(tdm_output *output, tdm_error *error);
582 * @brief Destroys the given window.
583 * @param[in] output A output object
584 * @param[in] window the pointer of the window to destroy
585 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
589 tdm_output_hwc_destroy_window(tdm_output *output, tdm_hwc_window *hwc_window);
592 * @brief Set the client(relative to the TDM) target buffer
593 * @details Sets the buffer which will receive the output of client composition.
594 * Window marked as TDM_COMPOSITION_CLIENT or TDM_COMPOSITION_DEVICE_CANDIDATE
595 * will be composited into this buffer prior to the call to tdm_output_commit(),
596 * and windows not marked as TDM_COMPOSITION_CLIENT and
597 * TDM_COMPOSITION_DEVICE_CANDIDATE should be composited with this buffer by the
600 * The buffer handle provided may be null if no windows are being composited by
601 * the client. This must not result in an error (unless an invalid display
602 * handle is also provided).
604 * The damage parameter describes a buffer damage region as defined in the
605 * description of tdm_hwc_window_set_buffer_damage().
607 * Will be called before tdm_output_commit() if any of the layers are marked as
608 * TDM_COMPOSITION_CLIENT or TDM_COMPOSITION_DEVICE_CANDIDATE. If no layers are
609 * so marked, then it is not necessary to call this function. It is not necessary
610 * to call tdm_output_hwc_validate() after changing the target through this function.
611 * @param[in] output A output object
612 * @param[in] target The new target buffer
613 * @param[in] damage The buffer damage region
614 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
618 tdm_output_hwc_set_client_target_buffer(tdm_output *output, tbm_surface_h target_buffer,
619 tdm_hwc_region damage);
622 * @brief Validate the output
623 * @details Instructs the device to inspect all of the layer state and
624 * determine if there are any composition type changes necessary before
625 * presenting the output. Permitted changes are described in the definition
626 * of tdm_hwc_window_composition_t above.
627 * @param[in] output A output object
628 * @param[out] num_types The number of composition type changes required by
629 * the device; if greater than 0, the client must either set and validate new
630 * types, or call tdm_output_hwc_accept_changes() to accept the changes returned by
631 * tdm_output_hwc_get_changed_composition_types(); must be the same as the number of
632 * changes returned by tdm_output_hwc_get_changed_composition_types (see the
633 * declaration of that function for more information); pointer will be non-NULL
634 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
638 tdm_output_hwc_validate(tdm_output *output, uint32_t *num_types);
641 * @brief Set the 'need to validate' handler for the 'output'
643 * @details During backend's work it may need to ask for the revalidation
644 * (make client (E20) do tdm_output_hwc_validate() again), so a 'hndl' will
645 * be called as such need happen. Only one handler per output is supported.
647 * @param[in] output The output object a hndl is going to be registered for.
648 * @param[in] hndl The handler which will be called on the 'need to validate' event.
650 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
654 tdm_output_hwc_set_need_validate_handler(tdm_output *output,
655 tdm_output_need_validate_handler hndl);
658 * @brief Get changed composition types
659 * @details Retrieves the windows for which the device requires a different
660 * composition type than had been set prior to the last call to tdm_output_hwc_validate().
661 * The client will either update its state with these types and call
662 * tdm_output_hwc_accept_changes, or will set new types and attempt to validate the
664 * windows and types may be NULL to retrieve the number of elements which
665 * will be returned. The number of elements returned must be the same as the
666 * value returned in num_types from the last call to tdm_output_hwc_validate().
667 * @param[in] output A output object
668 * @param[out] num_elements If windows or types were NULL, the number of layers
669 * and types which would have been returned; if both were non-NULL, the
670 * number of elements returned in layers and types, which must not exceed
671 * the value stored in num_elements prior to the call; pointer will be
673 * @param[in] output A output object
674 * @param[out] windows An array of windows
675 * @param[out] composition_types An array of composition types, each corresponding
676 * to an element of windows
677 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
681 tdm_output_hwc_get_changed_composition_types(tdm_output *output,uint32_t *num_elements,
682 tdm_hwc_window **hwc_window,
683 tdm_hwc_window_composition *composition_types);
686 * @brief Accepts the changes required by the device
687 * @details Accepts the changes required by the device from the previous
688 * tdm_output_hwc_validate() call (which may be queried using
689 * tdm_output_get_chaged_composition_types()) and revalidates the display. This
690 * function is equivalent to requesting the changed types from
691 * tdm_output_get_chaged_composition_types(), setting those types on the
692 * corresponding windows, and then calling tdm_output_hwc_validate again.
693 * After this call it must be valid to present this display. Calling this after
694 * tdm_output_hwc_validate() returns 0 changes must succeed with TDM_ERROR_NONE, but
695 * should have no other effect.
696 * @param[in] output A output object
697 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
701 tdm_output_hwc_accept_changes(tdm_output *output);
704 * @brief Get a target buffer queue
705 * @details Buffers from target buffer queue will receive the output of
706 * client composition. Window marked as TDM_COMPOSITION_CLIENT or
707 * TDM_COMPOSITION_DEVICE_CANDIDATE will be composited into this buffers
708 * prior to the call to tdm_output_commit().
709 * @param[in] output A output object
710 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
711 * @return A buffer queue
715 tdm_output_hwc_get_target_buffer_queue(tdm_output *output, tdm_error *error);
718 * @brief Get the capabilities of a layer object.
719 * @param[in] layer A layer object
720 * @param[out] capabilities The capabilities of a layer object
721 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
724 tdm_layer_get_capabilities(tdm_layer *layer,
725 tdm_layer_capability *capabilities);
728 * @brief Get the available format array of a layer object.
729 * @param[in] layer A layer object
730 * @param[out] formats The available format array
731 * @param[out] count The count of formats
732 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
735 tdm_layer_get_available_formats(tdm_layer *layer, const tbm_format **formats,
739 * @brief Get the available property array of a layer object.
740 * @param[in] layer A layer object
741 * @param[out] props The available property array
742 * @param[out] count The count of properties
743 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
746 tdm_layer_get_available_properties(tdm_layer *layer, const tdm_prop **props,
750 * @brief Get the zpos of a layer object.
752 * - GRAPHIC layers have fixed zpos. It starts from 0. It's @b non-changeable.
753 * - But the zpos of VIDEO layers will be decided by a backend module side.
754 * - A frontend user only can set the relative zpos to VIDEO layers via #tdm_layer_set_video_pos
755 * - The zpos of video layers is less than GRAPHIC layers or more than GRAPHIC
756 * layers. ie, ..., -2, -1, 4, 5, ... (if 0 <= GRAPHIC layer's zpos < 4).
757 * -------------------------------- graphic layer 3 <-- top most layer
758 * -------------------------------- graphic layer 2
759 * -------------------------------- graphic layer 1
760 * -------------------------------- graphic layer 0
761 * -------------------------------- video layer -1
762 * -------------------------------- video layer -2 <-- lowest layer
763 * @param[in] layer A layer object
764 * @param[out] zpos The zpos
765 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
766 * @see tdm_layer_set_video_pos, tdm_layer_capability
769 tdm_layer_get_zpos(tdm_layer *layer, int *zpos);
772 * @brief Set the property which has a given id.
773 * @param[in] layer A layer object
774 * @param[in] id The property id
775 * @param[in] value The value
776 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
779 tdm_layer_set_property(tdm_layer *layer, unsigned int id, tdm_value value);
782 * @brief Get the property which has a given id.
783 * @param[in] layer A layer object
784 * @param[in] id The property id
785 * @param[out] value The value
786 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
789 tdm_layer_get_property(tdm_layer *layer, unsigned int id, tdm_value *value);
792 * @brief Set the geometry information to a layer object
793 * @details The geometry information will be applied when the output object
794 * of a layer object is committed. If a layer has TDM_LAYER_CAPABILITY_NO_CROP
795 * capability, a layer will ignore the pos(crop) information of #tdm_info_layer's
797 * @param[in] layer A layer object
798 * @param[in] info The geometry information
799 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
800 * @see tdm_layer_commit
803 tdm_layer_set_info(tdm_layer *layer, tdm_info_layer *info);
806 * @brief Get the geometry information to a layer object
807 * @param[in] layer A layer object
808 * @param[out] info The geometry information
809 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
812 tdm_layer_get_info(tdm_layer *layer, tdm_info_layer *info);
815 * @brief Set a TDM buffer to a layer object
816 * @details A TDM buffer will be applied when the output object
817 * of a layer object is committed.
818 * @param[in] layer A layer object
819 * @param[in] buffer A TDM buffer
820 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
821 * @see tdm_layer_commit
824 tdm_layer_set_buffer(tdm_layer *layer, tbm_surface_h buffer);
827 * @brief Unset a TDM buffer from a layer object
828 * @details When this function is called, a current showing buffer will be
829 * disappeared from screen. Then nothing is showing on a layer object.
830 * @param[in] layer A layer object
831 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
834 tdm_layer_unset_buffer(tdm_layer *layer);
837 * @brief Commit changes for a layer object
838 * @details After all change of a layer object are applied, a user commit handler
840 * @param[in] layer A layer object
841 * @param[in] func A user commit handler
842 * @param[in] user_data The user data
843 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
846 tdm_layer_commit(tdm_layer *layer, tdm_layer_commit_handler func, void *user_data);
849 tdm_layer_is_committing(tdm_layer *layer, unsigned int *committing);
852 * @brief Remove the user commit handler
853 * @param[in] layer A layer object
854 * @param[in] func A user commit handler
855 * @param[in] user_data The user data
856 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
859 tdm_layer_remove_commit_handler(tdm_layer *layer, tdm_layer_commit_handler func, void *user_data);
862 * @brief Get a displaying TDM buffer from a layer object
863 * @details A displaying TDM buffer is a current showing buffer on screen
864 * that is set to layer object and applied output object of a layer object.
865 * @param[in] layer A layer object
866 * @return A TDM buffer if success. Otherwise, NULL.
869 tdm_layer_get_displaying_buffer(tdm_layer *layer, tdm_error *error);
872 * @brief Set a TBM surface_queue to a layer object
873 * @details A TBM surface_queue will be applied when the output object
874 * of a layer object is committed. and TDM layer will be automatically updated
875 * @param[in] layer A layer object
876 * @param[in] buffer_queue A TBM surface_queue
877 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
878 * @see tdm_layer_commit
881 tdm_layer_set_buffer_queue(tdm_layer *layer, tbm_surface_queue_h buffer_queue);
884 * @brief Unset a TBM surface_queue from a layer object
885 * @details When this function is called, a current surface_queue will be
886 * disappeared from screen. Then nothing is showing on a layer object.
887 * @param[in] layer A layer object
888 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
891 tdm_layer_unset_buffer_queue(tdm_layer *layer);
894 * @brief Check wheter a layer object is available for a frontend user to use.
895 * @details A layer object is not usable if a TDM buffer is showing on screen
896 * via this layer object. By calling #tdm_layer_unset_buffer, this layer object
897 * will become usable.
898 * @param[in] layer A layer object
899 * @param[out] usable 1 if usable, 0 if not usable
900 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
903 tdm_layer_is_usable(tdm_layer *layer, unsigned int *usable);
906 * @brief Set the relative zpos to a VIDEO layer object
907 * @details The zpos value is less than the minimum zpos of GRAPHIC layers, or
908 * it is more than the maximum zpos of GRAPHIC layers.
909 * @param[in] layer A VIDEO layer object
910 * @param[in] zpos The zpos
911 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
912 * @see tdm_layer_get_zpos, tdm_layer_capability
915 tdm_layer_set_video_pos(tdm_layer *layer, int zpos);
918 * @brief Create a capture object of a layer object
919 * @param[in] layer A layer object
920 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
921 * @return A capture object
922 * @see tdm_capture_destroy
925 tdm_layer_create_capture(tdm_layer *layer, tdm_error *error);
928 * @brief Get buffer flags from a layer object
929 * @param[in] layer A layer object
930 * @param[out] flags a buffer flags value
931 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
934 tdm_layer_get_buffer_flags(tdm_layer *layer, unsigned int *flags);
937 * @brief Get a buffer queue for the window object
938 * @details These buffers are used to composite by hardware a client content in
940 * @param[in] hwc_window A window object
941 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
942 * @return A tbm buffer queue
946 tdm_hwc_window_get_tbm_buffer_queue(tdm_hwc_window *hwc_window, tdm_error *error);
949 * @brief Sets the desired Z order of the given window. A window with
950 * a greater Z value occludes a window with a lesser Z value.
951 * @param[in] hwc_window A window object
952 * @param[in] z the new Z order
953 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
957 tdm_hwc_window_set_zpos(tdm_hwc_window *hwc_window, uint32_t zpos);
960 * @brief Sets the desired composition type of the given window.
961 * @details During tdm_output_hwc_validate(), the device may request changes to
962 * the composition types of any of the layers as described in the definition
963 * of tdm_hwc_window_composition_t above.
964 * @param[in] hwc_window A window object
965 * @param[in] composition_type The new composition type
966 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
970 tdm_hwc_window_set_composition_type(tdm_hwc_window *hwc_window,
971 tdm_hwc_window_composition composition_type);
974 * @brief Set the buffer damage
975 * @details Provides the region of the source buffer which has been modified
976 * since the last frame. This region does not need to be validated before
977 * calling tdm_output_commit().
978 * Once set through this function, the damage region remains the same until a
979 * subsequent call to this function.
980 * If damage.num_rects > 0, then it may be assumed that any portion of the source
981 * buffer not covered by one of the rects has not been modified this frame. If
982 * damage.num_rects == 0, then the whole source buffer must be treated as if it
984 * If the layer's contents are not modified relative to the prior frame, damage
985 * will contain exactly one empty rect([0, 0, 0, 0]).
986 * The damage rects are relative to the pre-transformed buffer, and their origin
987 * is the top-left corner. They will not exceed the dimensions of the latched
989 * @param[in] hwc_window A window object
990 * @param[in] damage The new buffer damage region
991 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
995 tdm_hwc_window_set_buffer_damage(tdm_hwc_window *hwc_window, tdm_hwc_region damage);
998 * @brief Set the information to a window object
999 * @details The information will be applied when the output object of a window
1000 * object is committed.
1001 * @param[in] hwc_window A window object
1002 * @param[in] info The information
1003 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1007 tdm_hwc_window_set_info(tdm_hwc_window *hwc_window, tdm_hwc_window_info *info);
1010 * @brief Set a TBM buffer to a window object
1011 * @details A TBM buffer will be applied when the output object of a layer
1012 * object is committed.
1013 * @param[in] hwc_window A window object
1014 * @param[in] buffer A TDM buffer
1015 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1019 tdm_hwc_window_set_buffer(tdm_hwc_window *hwc_window, tbm_surface_h buffer);
1022 * @brief Set a flags to a window object
1023 * @param[in] hwc_window A window object
1024 * @param[in] flags A hwc_window flags
1025 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1029 tdm_hwc_window_set_flags(tdm_hwc_window *hwc_window, tdm_hwc_window_flag flags);
1032 * @brief Unset a flags from a window object
1033 * @param[in] hwc_window A window object
1034 * @param[in] flags A hwc_window flags
1035 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1039 tdm_hwc_window_unset_flags(tdm_hwc_window *hwc_window, tdm_hwc_window_flag flags);
1042 * @brief Get the window video capability
1043 * @param[in] hwc_window A window object
1044 * @param[out] video_capability A hwc window video capability
1045 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1049 tdm_hwc_window_video_get_capability(tdm_hwc_window *hwc_window,
1050 tdm_hwc_window_video_capability *video_capability);
1053 * @brief Get the window video supported format
1054 * @param[in] hwc_window A window object
1055 * @param[out] formats A hwc window supported formats
1056 * @param[out] count A number of the hwc window supported formats
1057 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1061 tdm_hwc_window_video_get_supported_format(tdm_hwc_window *hwc_window,
1062 const tbm_format **formats,
1066 * @brief Destroy a pp object
1067 * @param[in] pp A pp object
1068 * @see tdm_display_create_pp
1071 tdm_pp_destroy(tdm_pp *pp);
1074 * @brief Set the geometry information to a pp object
1075 * @param[in] pp A pp object
1076 * @param[in] info The geometry information
1077 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1078 * @see tdm_pp_commit
1081 tdm_pp_set_info(tdm_pp *pp, tdm_info_pp *info);
1084 * @brief Set the PP done handler to a pp object
1086 * The user PP done handler will be called after converting a source buffer's image
1087 * to a destination buffer.
1088 * @param[in] pp A pp object
1089 * @param[in] func A user PP done handler
1090 * @param[in] user_data The user data
1091 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1094 tdm_pp_set_done_handler(tdm_pp *pp, tdm_pp_done_handler func, void *user_data);
1097 * @brief Attach a source buffer and a destination buffer to a pp object
1098 * @param[in] pp A pp object
1099 * @param[in] src A source buffer
1100 * @param[in] dst A destination buffer
1101 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1102 * @see tdm_pp_commit, tdm_pp_set_done_handler
1105 tdm_pp_attach(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst);
1108 * @brief Commit changes for a pp object
1109 * @param[in] pp A pp object
1110 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1113 tdm_pp_commit(tdm_pp *pp);
1116 * @brief Destroy a capture object
1117 * @param[in] capture A capture object
1118 * @see tdm_output_create_capture, tdm_layer_create_capture
1121 tdm_capture_destroy(tdm_capture *capture);
1124 * @brief Set the geometry information to a capture object
1125 * @param[in] capture A capture object
1126 * @param[in] info The geometry information
1127 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1128 * @see tdm_capture_commit
1131 tdm_capture_set_info(tdm_capture *capture, tdm_info_capture *info);
1134 * @brief Set the capture done handler to a capture object
1136 * The user capture done handler will be called after capturing a screen into a
1138 * @param[in] capture A capture object
1139 * @param[in] func A user capture done handler
1140 * @param[in] user_data The user data
1141 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1144 tdm_capture_set_done_handler(tdm_capture *capture, tdm_capture_done_handler func, void *user_data);
1147 * @brief Attach a TDM buffer to a capture object
1148 * @param[in] capture A capture object
1149 * @param[in] buffer A TDM buffer
1150 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1151 * @see tdm_capture_commit, tdm_capture_set_done_handler
1154 tdm_capture_attach(tdm_capture *capture, tbm_surface_h buffer);
1157 * @brief Commit changes for a capture object
1158 * @param[in] capture A capture object
1159 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1162 tdm_capture_commit(tdm_capture *capture);
1165 * @brief The release handler of a TDM buffer
1166 * @param[in] buffer A TDM buffer
1167 * @param[in] user_data user data
1168 * @see tdm_buffer_add_release_handler, tdm_buffer_remove_release_handler
1170 typedef void (*tdm_buffer_release_handler)(tbm_surface_h buffer,
1174 * @brief Add a release handler to a TDM buffer
1176 * TDM has its own buffer release mechanism to let an frontend user know when a TDM buffer
1177 * becomes available for a next job. A TDM buffer can be used for TDM to show
1178 * it on screen or to capture an output and a layer. After all operations,
1179 * TDM will release it immediately when TDM doesn't need it any more.
1180 * @param[in] buffer A TDM buffer
1181 * @param[in] func A release handler
1182 * @param[in] user_data user data
1183 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1184 * @see tdm_buffer_remove_release_handler
1187 tdm_buffer_add_release_handler(tbm_surface_h buffer,
1188 tdm_buffer_release_handler func, void *user_data);
1191 * @brief Remove a release handler from a TDM buffer
1192 * @param[in] buffer A TDM buffer
1193 * @param[in] func A release handler
1194 * @param[in] user_data user data
1195 * @see tdm_buffer_add_release_handler
1198 tdm_buffer_remove_release_handler(tbm_surface_h buffer,
1199 tdm_buffer_release_handler func, void *user_data);
1202 * @brief The handler of a vblank object
1203 * @see #tdm_vblank_wait, #tdm_vblank_wait_seq
1205 typedef void (*tdm_vblank_handler)(tdm_vblank *vblank, tdm_error error, unsigned int sequence,
1206 unsigned int tv_sec, unsigned int tv_usec, void *user_data);
1209 * @brief Set the vblank fps for the given PID and name.
1210 * @param[in] pid The process ID
1211 * @param[in] name The client vblank name
1212 * @param[in] fps The client vblank fps
1213 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1216 tdm_vblank_set_client_vblank_fps(unsigned int pid, const char *name, unsigned int fps);
1219 * @brief Set the vblank global fps for the entire system.
1220 * @param[in] enable 1:enable, 0:disable
1221 * @param[in] fps The vblank global fps
1223 * This global fps will be applied to all client's vblanks for all outputs.
1224 * If the client's vblank fps is less than this, the global fps will be ignored
1225 * for that client. And if a client calls #tdm_vblank_ignore_global_fps to ignore
1226 * the global fps, it will be ignored also.
1227 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1230 tdm_vblank_enable_global_fps(unsigned int enable, unsigned int fps);
1233 * @brief Create a vblank object
1234 * @param[in] dpy A display object
1235 * @param[in] output A output object
1236 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
1237 * @return A vblank object
1238 * @see #tdm_vblank_destroy
1241 tdm_vblank_create(tdm_display *dpy, tdm_output *output, tdm_error *error);
1244 * @brief Destroy a vblank object
1245 * @param[in] vblank A vblank object
1246 * @see #tdm_vblank_create
1249 tdm_vblank_destroy(tdm_vblank *vblank);
1252 * @brief Set the name to a vblank object
1253 * @details The default name is "unknown"
1254 * @param[in] vblank A vblank object
1255 * @param[in] name vblank name
1256 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1259 tdm_vblank_set_name(tdm_vblank *vblank, const char *name);
1262 * @brief Get the name for a vblank object
1263 * @details The default name is "unknown"
1264 * @param[in] vblank A vblank object
1265 * @param[out] name vblank name
1266 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1269 tdm_vblank_get_name(tdm_vblank *vblank, const char **name);
1272 * @brief Set the fps to a vblank object
1273 * @details Default is the @b vertical @b refresh @b rate of the given output.
1274 * @param[in] vblank A vblank object
1275 * @param[in] fps over 0
1276 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1279 tdm_vblank_set_fps(tdm_vblank *vblank, unsigned int fps);
1282 * @brief Get the fps for a vblank object
1283 * @param[in] vblank A vblank object
1284 * @param[out] fps over 0
1285 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1288 tdm_vblank_get_fps(tdm_vblank *vblank, unsigned int *fps);
1291 * @brief Ignore the vblank global fps
1293 * The global fps will be applied to all client's vblanks for all outputs.
1294 * If the client's vblank fps is less than this, the global fps will be ignored
1295 * for that client. And if a client calls #tdm_vblank_ignore_global_fps to ignore
1296 * the global fps, it will be ignored also.
1297 * @param[in] vblank A vblank object
1298 * @param[in] ignore 1: ignore 0:not ignore(default)
1299 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1302 tdm_vblank_ignore_global_fps(tdm_vblank *vblank, unsigned int ignore);
1305 * @brief Set the offset(milli-second) to a vblank object
1306 * @details Default is @b 0.
1307 * @param[in] vblank A vblank object
1308 * @param[in] offset the offset(milli-second)
1309 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1312 tdm_vblank_set_offset(tdm_vblank *vblank, int offset);
1315 * @brief Get the offset(milli-second) for a vblank object
1316 * @param[in] vblank A vblank object
1317 * @param[out] offset the offset(milli-second)
1318 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1321 tdm_vblank_get_offset(tdm_vblank *vblank, int *offset);
1324 * @brief Enable/Disable the fake vblank to a vblank object
1326 * If enable_fake == 0, #tdm_vblank_wait will return TDM_ERROR_DPMS_OFF
1327 * when DPMS off. Otherwise, #tdm_vblank_wait will return TDM_ERROR_NONE
1329 * @param[in] vblank A vblank object
1330 * @param[in] enable_fake 1:enable, 0:disable
1331 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1334 tdm_vblank_set_enable_fake(tdm_vblank *vblank, unsigned int enable_fake);
1337 * @brief Get the fake vblank
1338 * @param[in] vblank A vblank object
1339 * @param[out] enable_fake 1:enable, 0:disable
1340 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1343 tdm_vblank_get_enable_fake(tdm_vblank *vblank, unsigned int *enable_fake);
1346 * @brief Wait for a vblank
1348 * Once #tdm_vblank_wait returns TDM_ERROR_NONE, the user vblank handler(#tdm_vblank_handler)
1349 * SHOULD be called after the given interval. \n
1350 * The sequence value of tdm_vblank_handler is the relative value of fps.
1351 * If fps = 10, this sequence value should be increased by 10 during 1 second.
1352 * @param[in] vblank A vblank object
1353 * @param[in] req_sec The vblank request time(second)
1354 * @param[in] req_usec The vblank request time(micro-second)
1355 * @param[in] interval The vblank interval
1356 * @param[in] func The user vblank handler
1357 * @param[in] user_data The user data
1358 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1361 tdm_vblank_wait(tdm_vblank *vblank, unsigned int req_sec, unsigned int req_usec,
1362 unsigned int interval, tdm_vblank_handler func, void *user_data);
1365 * @brief Wait for a vblank with the target sequence number
1366 * @param[in] vblank A vblank object
1367 * @param[in] req_sec The vblank request time(second)
1368 * @param[in] req_usec The vblank request time(micro-second)
1369 * @param[in] sequence The target sequence number
1370 * @param[in] func The user client vblank handler
1371 * @param[in] user_data The user data
1372 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1375 tdm_vblank_wait_seq(tdm_vblank *vblank, unsigned int req_sec, unsigned int req_usec,
1376 unsigned int sequence, tdm_vblank_handler func, void *user_data);
1382 #endif /* _TDM_H_ */