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 **************************************************************************/
36 #ifndef _TDM_BACKEND_H_
37 #define _TDM_BACKEND_H_
39 #include <tbm_surface.h>
41 #include "tdm_types.h"
49 * @brief The backend header file of TDM to implement a TDM backend module.
52 * #include <tdm_backend.h>
57 * @brief The backend module data
59 * The init() function of #tdm_backend_module returns the backend module data.
60 * And it will be passed to display functions of #tdm_func_display.
61 * @see tdm_backend_module, tdm_backend_module
63 typedef void tdm_backend_data;
66 * @brief The output status handler
67 * @details This handler will be called when the status of a output object is
70 typedef void (*tdm_output_status_handler)(tdm_output *output,
71 tdm_output_conn_status status,
75 * @brief The display capabilities structure of a backend module
76 * @see The display_get_capability() function of #tdm_func_display
78 typedef struct _tdm_caps_display {
79 int max_layer_count; /**< The maximum layer count. -1 means "not defined" */
83 * @brief The capabilities structure of a output object
84 * @see The output_get_capability() function of #tdm_func_output
86 typedef struct _tdm_caps_output {
87 char maker[TDM_NAME_LEN]; /**< The output maker */
88 char model[TDM_NAME_LEN]; /**< The output model */
89 char name[TDM_NAME_LEN]; /**< The output name */
91 tdm_output_conn_status status; /**< The connection status */
92 tdm_output_type type; /**< The connection type */
93 unsigned int type_id; /**< The connection type id */
95 unsigned int mode_count; /**< The count of available modes */
97 *modes; /**< The @b newly-allocated array of modes. will be freed in frontend. */
99 unsigned int prop_count; /**< The count of available properties */
100 tdm_prop *props; /**< The @b newly-allocated array of properties. will be freed in frontend. */
102 unsigned int mmWidth; /**< The physical width (milimeter) */
103 unsigned int mmHeight; /**< The physical height (milimeter) */
104 unsigned int subpixel; /**< The subpixel */
106 int min_w; /**< The minimun width. -1 means "not defined" */
107 int min_h; /**< The minimun height. -1 means "not defined" */
108 int max_w; /**< The maximum width. -1 means "not defined" */
109 int max_h; /**< The maximum height. -1 means "not defined" */
110 int preferred_align; /**< The prefered align. -1 means "not defined" */
112 tdm_output_capability capabilities; /**< The capabilities of output. @since 1.4.1 */
116 * @brief The capabilities structure of a layer object
117 * @see The layer_get_capability() function of #tdm_func_layer
119 typedef struct _tdm_caps_layer {
120 tdm_layer_capability capabilities; /**< The capabilities of layer */
124 * GRAPHIC layers are non-changeable. The zpos of GRAPHIC layers starts
125 * from 0. If there are 4 GRAPHIC layers, The zpos SHOULD be 0, 1, 2, 3.\n
126 * But the zpos of VIDEO layer is changeable by layer_set_video_pos() function
127 * of #tdm_func_layer. And The zpos of VIDEO layers is less than GRAPHIC
128 * layers or more than GRAPHIC layers.
129 * ie, ..., -2, -1, 4, 5, ... (if 0 <= GRAPHIC layer's zpos < 4).
130 * The zpos of VIDEO layers is @b relative. It doesn't need to start
131 * from -1 or 4. Let's suppose that there are two VIDEO layers.
132 * One has -2 zpos. Another has -4 zpos. Then -2 Video layer is higher
133 * than -4 VIDEO layer.
137 unsigned int format_count; /**< The count of available formats */
139 *formats; /**< The @b newly-allocated array of formats. will be freed in frontend. */
141 unsigned int prop_count; /**< The count of available properties */
142 tdm_prop *props; /**< The @b newly-allocated array of properties. will be freed in frontend. */
146 * @brief The capabilities structure of a pp object
147 * @see The display_get_pp_capability() function of #tdm_func_display
149 typedef struct _tdm_caps_pp {
150 tdm_pp_capability capabilities; /**< The capabilities of pp */
152 unsigned int format_count; /**< The count of available formats */
154 *formats; /**< The @b newly-allocated array. will be freed in frontend. */
156 int min_w; /**< The minimun width. -1 means "not defined" */
157 int min_h; /**< The minimun height. -1 means "not defined" */
158 int max_w; /**< The maximum width. -1 means "not defined" */
159 int max_h; /**< The maximum height. -1 means "not defined" */
160 int preferred_align; /**< The prefered align. -1 means "not defined" */
162 /**< The attach count which a PP object can handle.
163 * -1 means "not defined".
166 int max_attach_count;
170 * @brief The capabilities structure of a capture object
171 * @see The display_get_capture_capability() function of #tdm_func_display
173 typedef struct _tdm_caps_capture {
174 tdm_capture_capability capabilities; /**< The capabilities of capture */
176 unsigned int format_count; /**< The count of available formats */
178 *formats; /**< The @b newly-allocated array of formats. will be freed in frontend. */
180 int min_w; /**< The minimun width. -1 means "not defined" */
181 int min_h; /**< The minimun height. -1 means "not defined" */
182 int max_w; /**< The maximum width. -1 means "not defined" */
183 int max_h; /**< The maximum height. -1 means "not defined" */
184 int preferred_align; /**< The prefered align. -1 means "not defined" */
186 /**< The attach count which a capture object can handle.
187 * -1 means "not defined".
190 int max_attach_count;
194 * @brief The display functions for a backend module.
196 typedef struct _tdm_func_display {
198 * @brief Get the display capabilities of a backend module
199 * @param[in] bdata The backend module data
200 * @param[out] caps The display capabilities of a backend module
201 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
203 * A backend module @b SHOULD implement this function. TDM calls this function
204 * not only at the initial time, but also at the update time when new output
206 * If a hardware has the restriction of the number of max usable layer count,
207 * a backend module can set the max count to max_layer_count of #tdm_caps_display
208 * structure. Otherwise, set -1.
210 tdm_error (*display_get_capability)(tdm_backend_data *bdata, tdm_caps_display *caps);
213 * @brief Get the pp capabilities of a backend module
214 * @param[in] bdata The backend module data
215 * @param[out] caps The pp capabilities of a backend module
216 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
217 * @see tdm_backend_register_func_pp
219 * TDM calls this function not only at the initial time, but also at the update
220 * time when new output is connected.\n
221 * A backend module doesn't need to implement this function if a hardware
222 * doesn't have the memory-to-memory converting device. Otherwise, a backend module
223 * @b SHOULD fill the #tdm_caps_pp data. #tdm_caps_pp contains the hardware
224 * restriction information which a converting device can handle. ie, format, size, etc.
226 tdm_error (*display_get_pp_capability)(tdm_backend_data *bdata, tdm_caps_pp *caps);
229 * @brief Get the capture capabilities of a backend module
230 * @param[in] bdata The backend module data
231 * @param[out] caps The capture capabilities of a backend module
232 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
233 * @see tdm_backend_register_func_capture
235 * TDM calls this function not only at the initial time, but also at the update
236 * time when new output is connected.\n
237 * A backend module doesn't need to implement this function if a hardware
238 * doesn't have the capture device. Otherwise, a backend module @b SHOULD fill the
239 * #tdm_caps_capture data. #tdm_caps_capture contains the hardware restriction
240 * information which a capture device can handle. ie, format, size, etc.
242 tdm_error (*display_get_capture_capability)(tdm_backend_data *bdata, tdm_caps_capture *caps);
245 * @brief Get a output array of a backend module
246 * @param[in] bdata The backend module data
247 * @param[out] count The count of outputs
248 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
249 * @return A output array which is @b newly-allocated
250 * @see tdm_backend_register_func_capture
252 * A backend module @b SHOULD implement this function. TDM calls this function
253 * not only at the initial time, but also at the update time when new output
255 * A backend module @b SHOULD return the @b newly-allocated array which contains
256 * "tdm_output*" data. It will be freed in frontend.
260 * drm_display_get_outputs(tdm_backend_data *bdata, int *count, tdm_error *error)
262 * tdm_drm_data *drm_data = bdata;
263 * tdm_drm_output_data *output_data = NULL;
264 * tdm_output **outputs;
268 * LIST_FOR_EACH_ENTRY(output_data, &drm_data->output_list, link)
273 * if (error) *error = TDM_ERROR_NONE;
277 * // will be freed in frontend
278 * outputs = calloc(*count, sizeof(tdm_drm_output_data*));
282 * if (error) *error = TDM_ERROR_OUT_OF_MEMORY;
287 * LIST_FOR_EACH_ENTRY(output_data, &drm_data->output_list, link)
288 * outputs[i++] = output_data;
290 * if (error) *error = TDM_ERROR_NONE;
296 tdm_output **(*display_get_outputs)(tdm_backend_data *bdata, int *count,
300 * @brief Get the file descriptor of a backend module
301 * @param[in] bdata The backend module data
302 * @param[out] fd The fd of a backend module
303 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
304 * @see display_handle_events() function of #tdm_func_display
306 * A backend module can return epoll's fd which is watching the backend device one more fds.
308 tdm_error (*display_get_fd)(tdm_backend_data *bdata, int *fd);
311 * @brief Handle the events which happens on the fd of a backend module
312 * @param[in] bdata The backend module data
313 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
315 tdm_error (*display_handle_events)(tdm_backend_data *bdata);
318 * @brief Create a pp object of a backend module
319 * @param[in] bdata The backend module data
320 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
321 * @return A pp object
322 * @see pp_destroy() function of #tdm_func_pp
324 * A backend module doesn't need to implement this function if a hardware
325 * doesn't have the memory-to-memory converting device.
327 tdm_pp *(*display_create_pp)(tdm_backend_data *bdata, tdm_error *error);
329 tdm_error (*display_get_capabilitiy)(tdm_backend_data *bdata, tdm_caps_display *caps);
331 void (*reserved2)(void);
332 void (*reserved3)(void);
333 void (*reserved4)(void);
334 void (*reserved5)(void);
335 void (*reserved6)(void);
336 void (*reserved7)(void);
337 void (*reserved8)(void);
341 * @brief The output functions for a backend module.
343 typedef struct _tdm_func_output {
345 * @brief Get the capabilities of a output object
346 * @param[in] output A output object
347 * @param[out] caps The capabilities of a output object
348 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
350 * A backend module @b SHOULD implement this function. TDM calls this function
351 * not only at the initial time, but also at the update time when new output
353 * #tdm_caps_output contains connection status, modes, avaiable properties,
354 * size restriction information, etc.
356 tdm_error (*output_get_capability)(tdm_output *output, tdm_caps_output *caps);
359 * @brief Get a layer array of a output object
360 * @param[in] output A output object
361 * @param[out] count The count of layers
362 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
363 * @return A layer array which is @b newly-allocated
365 * A backend module @b SHOULD implement this function. TDM calls this function
366 * not only at the initial time, but also at the update time when new output
368 * A backend module @b SHOULD return the @b newly-allocated array which contains
369 * "tdm_layer*" data. It will be freed in frontend.
371 tdm_layer **(*output_get_layers)(tdm_output *output, int *count,
375 * @brief Set the property which has a given id
376 * @param[in] output A output object
377 * @param[in] id The property id
378 * @param[in] value The value
379 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
381 tdm_error (*output_set_property)(tdm_output *output, unsigned int id,
385 * @brief Get the property which has a given id
386 * @param[in] output A output object
387 * @param[in] id The property id
388 * @param[out] value The value
389 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
391 tdm_error (*output_get_property)(tdm_output *output, unsigned int id,
395 * @brief Wait for VBLANK
396 * @param[in] output A output object
397 * @param[in] interval vblank interval
398 * @param[in] sync 0: asynchronous, 1:synchronous
399 * @param[in] user_data The user data
400 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
401 * @see output_set_vblank_handler, tdm_output_vblank_handler
403 * If this function returns TDM_ERROR_NONE, a backend module @b SHOULD call
404 * a user vblank handler with the user data of this function after interval
407 tdm_error (*output_wait_vblank)(tdm_output *output, int interval, int sync,
411 * @brief Set a user vblank handler
412 * @param[in] output A output object
413 * @param[in] func A user vblank handler
414 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
416 tdm_error (*output_set_vblank_handler)(tdm_output *output,
417 tdm_output_vblank_handler func);
420 * @brief Commit changes for a output object
421 * @param[in] output A output object
422 * @param[in] sync 0: asynchronous, 1:synchronous
423 * @param[in] user_data The user data
424 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
425 * @see output_set_commit_handler, tdm_output_commit_handler
427 * When this function is called, a backend module @b SHOULD apply the all
428 * changes of the given output object to screen as well as the layer changes
430 * If this function returns TDM_ERROR_NONE, a backend module @b SHOULD call
431 * a user commit handler with the user data of this function after all
432 * changes of the given output object are applied.
434 tdm_error (*output_commit)(tdm_output *output, int sync, void *user_data);
437 * @brief Set a user commit handler
438 * @param[in] output A output object
439 * @param[in] func A user commit handler
440 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
442 tdm_error (*output_set_commit_handler)(tdm_output *output,
443 tdm_output_commit_handler func);
446 * @brief Set DPMS of a output object
447 * @param[in] output A output object
448 * @param[in] dpms_value DPMS value
449 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
451 tdm_error (*output_set_dpms)(tdm_output *output, tdm_output_dpms dpms_value);
454 * @brief Get DPMS of a output object
455 * @param[in] output A output object
456 * @param[out] dpms_value DPMS value
457 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
459 tdm_error (*output_get_dpms)(tdm_output *output, tdm_output_dpms *dpms_value);
462 * @brief Set one of available modes of a output object
463 * @param[in] output A output object
464 * @param[in] mode A output mode
465 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
467 tdm_error (*output_set_mode)(tdm_output *output, const tdm_output_mode *mode);
470 * @brief Get the mode of a output object
471 * @param[in] output A output object
472 * @param[out] mode A output mode
473 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
475 tdm_error (*output_get_mode)(tdm_output *output, const tdm_output_mode **mode);
478 * @brief Create a capture object of a output object
479 * @param[in] output A output object
480 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
481 * @return A capture object
482 * @see capture_destroy() function of #tdm_func_capture
484 * A backend module doesn't need to implement this function if a hardware
485 * doesn't have the capture device.
487 tdm_capture *(*output_create_capture)(tdm_output *output, tdm_error *error);
490 * @brief Set a output connection status handler
491 * @details A backend module need to call the output status handler when the
492 * output connection status has been changed to let the TDM frontend know
494 * @param[in] output A output object
495 * @param[in] func A output status handler
496 * @param[in] user_data The user data
497 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
500 tdm_error (*output_set_status_handler)(tdm_output *output,
501 tdm_output_status_handler func,
504 void (*reserved1)(void);
505 void (*reserved2)(void);
506 void (*reserved3)(void);
507 void (*reserved4)(void);
508 void (*reserved5)(void);
509 void (*reserved6)(void);
510 void (*reserved7)(void);
511 void (*reserved8)(void);
515 * @brief The layer functions for a backend module.
517 typedef struct _tdm_func_layer {
519 * @brief Get the capabilities of a layer object
520 * @param[in] layer A layer object
521 * @param[out] caps The capabilities of a layer object
522 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
524 * A backend module @b SHOULD implement this function. TDM calls this function
525 * not only at the initial time, but also at the update time when new output
527 * #tdm_caps_layer contains avaiable formats/properties, zpos information, etc.
529 tdm_error (*layer_get_capability)(tdm_layer *layer, tdm_caps_layer *caps);
532 * @brief Set the property which has a given id.
533 * @param[in] layer A layer object
534 * @param[in] id The property id
535 * @param[in] value The value
536 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
538 tdm_error (*layer_set_property)(tdm_layer *layer, unsigned int id,
542 * @brief Get the property which has a given id.
543 * @param[in] layer A layer object
544 * @param[in] id The property id
545 * @param[out] value The value
546 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
548 tdm_error (*layer_get_property)(tdm_layer *layer, unsigned int id,
552 * @brief Set the geometry information to a layer object
553 * @param[in] layer A layer object
554 * @param[in] info The geometry information
555 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
556 * @see output_commit() function of #tdm_func_output
558 * A backend module would apply the geometry information when the output object
559 * of a layer object is committed.
561 tdm_error (*layer_set_info)(tdm_layer *layer, tdm_info_layer *info);
564 * @brief Get the geometry information to a layer object
565 * @param[in] layer A layer object
566 * @param[out] info The geometry information
567 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
569 tdm_error (*layer_get_info)(tdm_layer *layer, tdm_info_layer *info);
572 * @brief Set a TDM buffer to a layer object
573 * @param[in] layer A layer object
574 * @param[in] buffer A TDM buffer
575 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
576 * @see output_commit() function of #tdm_func_output
578 * A backend module would apply a TDM buffer when the output object
579 * of a layer object is committed.
581 tdm_error (*layer_set_buffer)(tdm_layer *layer, tbm_surface_h buffer);
584 * @brief Unset a TDM buffer from a layer object
585 * @param[in] layer A layer object
586 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
588 * A backend module @b SHOULD hide the current showing buffer from screen.
589 * If needed, cleanup a layer object resource.
591 tdm_error (*layer_unset_buffer)(tdm_layer *layer);
594 * @brief Set the zpos for a VIDEO layer object
595 * @param[in] layer A layer object
596 * @param[in] zpos z-order
597 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
598 * @see tdm_caps_layer, tdm_layer_capability
600 * A backend module doesn't need to implement this function if a backend
601 * module doesn't have VIDEO layers.\n
602 * This function is for VIDEO layers.
603 * GRAPHIC layers are non-changeable. The zpos of GRAPHIC layers starts
604 * from 0. If there are 4 GRAPHIC layers, The zpos SHOULD be 0, 1, 2, 3.\n
605 * But the zpos of VIDEO layer is changeable. And The zpos of VIDEO layers
606 * is less than GRAPHIC layers or more than GRAPHIC layers.
607 * ie, ..., -2, -1, 4, 5, ... (if 0 <= GRAPHIC layer's zpos < 4).
608 * The zpos of VIDEO layers is @b relative. It doesn't need to start
609 * from -1 or 4. Let's suppose that there are two VIDEO layers.
610 * One has -2 zpos. Another has -4 zpos. Then -2 Video layer is higher
611 * than -4 VIDEO layer.
613 tdm_error (*layer_set_video_pos)(tdm_layer *layer, int zpos);
616 * @brief Create a capture object of a layer object
617 * @param[in] output A output object
618 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
619 * @return A capture object
620 * @see capture_destroy() function of #tdm_func_capture
622 * A backend module doesn't need to implement this function if a hardware
623 * doesn't have the capture device.
625 tdm_capture *(*layer_create_capture)(tdm_layer *layer, tdm_error *error);
628 * @brief Get buffer flags which the layer can support.
629 * @param[in] layer A layer object
630 * @param[out] flags The buffer flags which should be the tbm_bo flags
631 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
633 tdm_error (*layer_get_buffer_flags)(tdm_layer *layer, unsigned int *flags);
635 void (*reserved1)(void);
636 void (*reserved2)(void);
637 void (*reserved3)(void);
638 void (*reserved4)(void);
639 void (*reserved5)(void);
640 void (*reserved6)(void);
641 void (*reserved7)(void);
645 * @brief The pp functions for a backend module.
647 typedef struct _tdm_func_pp {
649 * @brief Destroy a pp object
650 * @param[in] pp A pp object
651 * @see display_create_pp() function of #tdm_func_display
653 void (*pp_destroy)(tdm_pp *pp);
656 * @brief Set the geometry information to a pp object
657 * @param[in] pp A pp object
658 * @param[in] info The geometry information
659 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
660 * @see pp_commit() function of #tdm_func_pp
662 * A backend module would apply the geometry information when committed.
664 tdm_error (*pp_set_info)(tdm_pp *pp, tdm_info_pp *info);
667 * @brief Attach a source buffer and a destination buffer to a pp object
668 * @param[in] pp A pp object
669 * @param[in] src A source buffer
670 * @param[in] dst A destination buffer
671 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
672 * @see pp_set_info() function of #tdm_func_pp
673 * @see pp_commit() function of #tdm_func_pp
674 * @see pp_set_done_handler, tdm_pp_done_handler
676 * A backend module converts the image of a source buffer to a destination
677 * buffer when committed. The size/crop/transform information is set via
678 * #pp_set_info() of #tdm_func_pp. When done, a backend module @b SHOULD
679 * return the source/destination buffer via tdm_pp_done_handler.
681 tdm_error (*pp_attach)(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst);
684 * @brief Commit changes for a pp object
685 * @param[in] pp A pp object
686 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
688 tdm_error (*pp_commit)(tdm_pp *pp);
691 * @brief Set a user done handler to a pp object
692 * @param[in] pp A pp object
693 * @param[in] func A user done handler
694 * @param[in] user_data user data
695 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
697 * A backend module @b SHOULD call #tdm_pp_done_handler when converintg a image is done.
699 tdm_error (*pp_set_done_handler)(tdm_pp *pp, tdm_pp_done_handler func,
702 void (*reserved1)(void);
703 void (*reserved2)(void);
704 void (*reserved3)(void);
705 void (*reserved4)(void);
706 void (*reserved5)(void);
707 void (*reserved6)(void);
708 void (*reserved7)(void);
709 void (*reserved8)(void);
713 * @brief The capture functions for a backend module.
715 typedef struct _tdm_func_capture {
717 * @brief Destroy a capture object
718 * @param[in] capture A capture object
719 * @see output_create_capture() function of #tdm_func_output
720 * @see layer_create_capture() function of #tdm_func_layer
722 void (*capture_destroy)(tdm_capture *capture);
725 * @brief Set the geometry information to a capture object
726 * @param[in] capture A capture object
727 * @param[in] info The geometry information
728 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
729 * @see capture_commit() function of #tdm_func_capture
731 * A backend module would apply the geometry information when committed.
733 tdm_error (*capture_set_info)(tdm_capture *capture, tdm_info_capture *info);
736 * @brief Attach a TDM buffer to a capture object
737 * @details When capture_commit() function is called, a backend module starts
738 * to dump a output or a layer to a TDM buffer.
739 * @param[in] capture A capture object
740 * @param[in] buffer A TDM buffer
741 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
742 * @see capture_set_info() function of #tdm_func_capture
743 * @see capture_commit() function of #tdm_func_capture
744 * @see capture_set_done_handler, tdm_capture_done_handler
746 * A backend module starts to dump a output or a layer to to a TDM buffer when
747 * committed. The size/crop/transform information is set via #capture_set_info()
748 * of #tdm_func_capture. When done, a backend module @b SHOULD return the TDM
749 * buffer via tdm_capture_done_handler.
751 tdm_error (*capture_attach)(tdm_capture *capture, tbm_surface_h buffer);
754 * @brief Commit changes for a capture object
755 * @param[in] capture A capture object
756 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
758 tdm_error (*capture_commit)(tdm_capture *capture);
761 * @brief Set a user done handler to a capture object
762 * @param[in] capture A capture object
763 * @param[in] func A user done handler
764 * @param[in] user_data user data
765 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
767 * A backend module @b SHOULD call #tdm_capture_done_handler when capture operation is done.
769 tdm_error (*capture_set_done_handler)(tdm_capture *capture,
770 tdm_capture_done_handler func, void *user_data);
772 void (*reserved1)(void);
773 void (*reserved2)(void);
774 void (*reserved3)(void);
775 void (*reserved4)(void);
776 void (*reserved5)(void);
777 void (*reserved6)(void);
778 void (*reserved7)(void);
779 void (*reserved8)(void);
783 * @brief The tdm event source
785 typedef void tdm_event_loop_source;
788 * @brief The fd source handler
790 typedef tdm_error (*tdm_event_loop_fd_handler)(int fd, tdm_event_loop_mask mask, void *user_data);
793 * @brief The timer source handler
795 typedef tdm_error (*tdm_event_loop_timer_handler)(void *user_data);
797 #define TDM_BACKEND_MINOR_VERSION_MASK 0x0000FFFF
798 #define TDM_BACKEND_MAJOR_VERSION_MASK 0xFFFF0000
799 #define TDM_BACKEND_GET_ABI_MINOR(v) ((v) & TDM_BACKEND_MINOR_VERSION_MASK)
800 #define TDM_BACKEND_GET_ABI_MAJOR(v) (((v) & TDM_BACKEND_MAJOR_VERSION_MASK) >> 16)
804 * The ABI version of TDM backend module. It has a major and minor revision.
805 * Modules using lower minor revisions will work with TDM frontend of a higher
806 * minor revision. There is no compatibility between different major revisions.
807 * The minor revision mask is 0x0000FFFF and the major revision mask is 0xFFFF0000.
810 * tdm_backend_module tdm_backend_module_data = {
813 * TDM_BACKEND_SET_ABI_VERSION(1,1),
819 #define TDM_BACKEND_SET_ABI_VERSION(major, minor) \
820 (((major) << 16) & TDM_BACKEND_MAJOR_VERSION_MASK) | \
821 ((major) & TDM_BACKEND_MINOR_VERSION_MASK)
825 * This MACRO is deprecated since 1.2.0. Use TDM_BACKEND_SET_ABI_VERSION instead of this.
827 * Use #TDM_BACKEND_SET_ABI_VERSION macro instead of this macro.
829 #define TDM_BACKEND_ABI_VERSION TDM_BACKEND_SET_ABI_VERSION(1, 1)
832 * @brief The backend module information of the entry point to initialize a TDM
835 * A backend module @b SHOULD define the global data symbol of which name is
836 * @b "tdm_backend_module_data". TDM will read this symbol, @b "tdm_backend_module_data",
837 * at the initial time and call init() function of #tdm_backend_module.
839 typedef struct _tdm_backend_module {
840 const char *name; /**< The module name of a backend module */
841 const char *vendor; /**< The vendor name of a backend module */
842 unsigned long abi_version; /**< The ABI version of a backend module */
845 * @brief The init function of a backend module
846 * @param[in] dpy A display object
847 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
848 * @return The backend module data
849 * @see tdm_backend_data
851 tdm_backend_data *(*init)(tdm_display *dpy, tdm_error *error);
854 * @brief The deinit function of a backend module
855 * @param[in] bdata The backend module data
857 void (*deinit)(tdm_backend_data *bdata);
858 } tdm_backend_module;
861 * @brief Register the backend display functions to a display
862 * @param[in] dpy A display object
863 * @param[in] func_display display functions
864 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
865 * @see tdm_backend_register_func_output, tdm_backend_register_func_layer
867 * A backend module @b SHOULD set the backend display functions at least.
870 tdm_backend_register_func_display(tdm_display *dpy,
871 tdm_func_display *func_display);
874 * @brief Register the backend output functions to a display
875 * @param[in] dpy A display object
876 * @param[in] func_output output functions
877 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
878 * @see tdm_backend_register_func_display, tdm_backend_register_func_layer
880 * A backend module @b SHOULD set the backend output functions at least.
883 tdm_backend_register_func_output(tdm_display *dpy,
884 tdm_func_output *func_output);
887 * @brief Register the backend layer functions to a display
888 * @param[in] dpy A display object
889 * @param[in] func_layer layer functions
890 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
891 * @see tdm_backend_register_func_display, tdm_backend_register_func_output
893 * A backend module @b SHOULD set the backend layer functions at least.
896 tdm_backend_register_func_layer(tdm_display *dpy, tdm_func_layer *func_layer);
899 * @brief Register the backend pp functions to a display
900 * @param[in] dpy A display object
901 * @param[in] func_pp pp functions
902 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
903 * @see tdm_backend_register_func_display, tdm_backend_register_func_capture
905 * A backend module doesn'tcan skip to register the backend pp functions
906 * if a hardware doesn't have the memory-to-memory converting device.
909 tdm_backend_register_func_pp(tdm_display *dpy, tdm_func_pp *func_pp);
912 * @brief Register the backend capture functions to a display
913 * @param[in] dpy A display object
914 * @param[in] func_capture capture functions
915 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
916 * @see tdm_backend_register_func_display, tdm_backend_register_func_pp
918 * A backend module can skip to register the backend capture functions
919 * if a hardware doesn't have the capture device.
922 tdm_backend_register_func_capture(tdm_display *dpy,
923 tdm_func_capture *func_capture);
926 * @brief Increase the ref_count of a TDM buffer
928 * TDM has its own buffer release mechanism to let an frontend user know when a TDM buffer
929 * becomes available for a next job. A TDM buffer can be used for TDM to show
930 * it on screen or to capture an output and a layer. After all operations,
931 * TDM will release it immediately when TDM doesn't need it any more.
932 * @param[in] buffer A TDM buffer
933 * @return A buffer itself. Otherwise, NULL.
934 * @see tdm_buffer_unref_backend
936 * - This function @b SHOULD be paired with #tdm_buffer_unref_backend. \n
937 * - For example, this function @b SHOULD be called in case that a backend module uses the TDM
938 * buffer of a layer for capturing a output or a layer to avoid tearing issue.
941 tdm_buffer_ref_backend(tbm_surface_h buffer);
944 * @brief Decrease the ref_count of a TDM buffer
945 * @param[in] buffer A TDM buffer
946 * @see tdm_buffer_ref_backend
949 tdm_buffer_unref_backend(tbm_surface_h buffer);
952 * @brief The destroy handler of a TDM buffer
953 * @param[in] buffer A TDM buffer
954 * @param[in] user_data user data
955 * @see tdm_buffer_add_destroy_handler, tdm_buffer_remove_destroy_handler
957 typedef void (*tdm_buffer_destroy_handler)(tbm_surface_h buffer,
961 * @brief Add a destroy handler to a TDM buffer
962 * @param[in] buffer A TDM buffer
963 * @param[in] func A destroy handler
964 * @param[in] user_data user data
965 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
966 * @see tdm_buffer_remove_destroy_handler
968 * A backend module can add a TDM buffer destroy handler to a TDM buffer which
969 * is a #tbm_surface_h object. When the TDM buffer is destroyed, this handler will
973 tdm_buffer_add_destroy_handler(tbm_surface_h buffer,
974 tdm_buffer_destroy_handler func, void *user_data);
977 * @brief Remove a destroy handler from a TDM buffer
978 * @param[in] buffer A TDM buffer
979 * @param[in] func A destroy handler
980 * @param[in] user_data user data
981 * @see tdm_buffer_add_destroy_handler
984 tdm_buffer_remove_destroy_handler(tbm_surface_h buffer,
985 tdm_buffer_destroy_handler func, void *user_data);
988 * @brief Add a FD handler for activity on the given file descriptor
989 * @param[in] dpy A display object
990 * @param[in] fd A file descriptor
991 * @param[in] mask to monitor FD
992 * @param[in] func A FD handler function
993 * @param[in] user_data user data
994 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
995 * @return A FD event source
996 * @see #tdm_event_loop_source_fd_update, #tdm_event_loop_source_remove
998 tdm_event_loop_source*
999 tdm_event_loop_add_fd_handler(tdm_display *dpy, int fd, tdm_event_loop_mask mask,
1000 tdm_event_loop_fd_handler func, void *user_data,
1004 * @brief Update the mask of the given FD event source
1005 * @param[in] source The given FD event source
1006 * @param[in] mask to monitor FD
1007 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1010 tdm_event_loop_source_fd_update(tdm_event_loop_source *source, tdm_event_loop_mask mask);
1013 * @brief Add a timer handler
1014 * @param[in] dpy A display object
1015 * @param[in] func A timer handler function
1016 * @param[in] user_data user data
1017 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
1018 * @return A timer event source
1019 * @see #tdm_event_loop_source_timer_update, #tdm_event_loop_source_remove
1021 tdm_event_loop_source*
1022 tdm_event_loop_add_timer_handler(tdm_display *dpy, tdm_event_loop_timer_handler func,
1023 void *user_data, tdm_error *error);
1026 * @brief Update the millisecond delay time of the given timer event source.
1027 * @param[in] source The given timer event source
1028 * @param[in] ms_delay The millisecond delay time. zero "0" disarms the timer.
1029 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
1032 tdm_event_loop_source_timer_update(tdm_event_loop_source *source, unsigned int ms_delay);
1035 * @brief Remove the given event source
1036 * @param[in] source The given event source
1037 * @see #tdm_event_loop_add_fd_handler, #tdm_event_loop_add_timer_handler
1040 tdm_event_loop_source_remove(tdm_event_loop_source *source);
1046 #endif /* _TDM_BACKEND_H_ */