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 display capabilities structure of a backend module
67 * @see The display_get_capabilitiy() function of #tdm_func_display
69 typedef struct _tdm_caps_display
71 int max_layer_count; /**< The maximum layer count. -1 means "not defined" */
75 * @brief The capabilities structure of a output object
76 * @see The output_get_capability() function of #tdm_func_display
78 typedef struct _tdm_caps_output
80 char maker[TDM_NAME_LEN]; /**< The output maker */
81 char model[TDM_NAME_LEN]; /**< The output model */
82 char name[TDM_NAME_LEN]; /**< The output name */
84 tdm_output_conn_status status; /**< The connection status */
85 tdm_output_type type; /**< The connection type */
86 unsigned int type_id; /**< The connection type id */
88 unsigned int mode_count; /**< The count of available modes */
89 tdm_output_mode *modes; /**< The @b newly-allocated array of modes. will be freed in frontend. */
91 unsigned int prop_count; /**< The count of available properties */
92 tdm_prop *props; /**< The @b newly-allocated array of properties. will be freed in frontend. */
94 unsigned int mmWidth; /**< The physical width (milimeter) */
95 unsigned int mmHeight; /**< The physical height (milimeter) */
96 unsigned int subpixel; /**< The subpixel */
98 int min_w; /**< The minimun width. -1 means "not defined" */
99 int min_h; /**< The minimun height. -1 means "not defined" */
100 int max_w; /**< The maximum width. -1 means "not defined" */
101 int max_h; /**< The maximum height. -1 means "not defined" */
102 int preferred_align; /**< The prefered align. -1 means "not defined" */
106 * @brief The capabilities structure of a layer object
107 * @see The layer_get_capability() function of #tdm_func_display
109 typedef struct _tdm_caps_layer
111 tdm_layer_capability capabilities; /**< The capabilities of layer */
115 * GRAPHIC layers are non-changeable. The zpos of GRAPHIC layers starts
116 * from 0. If there are 4 GRAPHIC layers, The zpos SHOULD be 0, 1, 2, 3.\n
117 * But the zpos of VIDEO layer is changeable by layer_set_video_pos() function
118 * of #tdm_func_display. And The zpos of VIDEO layers is less than GRAPHIC
119 * layers or more than GRAPHIC layers.
120 * ie, ..., -2, -1, 4, 5, ... (if 0 <= GRAPHIC layer's zpos < 4).
121 * The zpos of VIDEO layers is @b relative. It doesn't need to start
122 * from -1 or 4. Let's suppose that there are two VIDEO layers.
123 * One has -2 zpos. Another has -4 zpos. Then -2 Video layer is higher
124 * than -4 VIDEO layer.
128 unsigned int format_count; /**< The count of available formats */
129 tbm_format *formats; /**< The @b newly-allocated array of formats. will be freed in frontend. */
131 unsigned int prop_count; /**< The count of available properties */
132 tdm_prop *props; /**< The @b newly-allocated array of properties. will be freed in frontend. */
136 * @brief The capabilities structure of a pp object
137 * @see The display_get_pp_capability() function of #tdm_func_display
139 typedef struct _tdm_caps_pp
141 tdm_pp_capability capabilities; /**< The capabilities of pp */
143 unsigned int format_count; /**< The count of available formats */
144 tbm_format *formats; /**< The @b newly-allocated array. will be freed in frontend. */
146 int min_w; /**< The minimun width. -1 means "not defined" */
147 int min_h; /**< The minimun height. -1 means "not defined" */
148 int max_w; /**< The maximum width. -1 means "not defined" */
149 int max_h; /**< The maximum height. -1 means "not defined" */
150 int preferred_align; /**< The prefered align. -1 means "not defined" */
154 * @brief The capabilities structure of a capture object
155 * @see The display_get_capture_capability() function of #tdm_func_display
157 typedef struct _tdm_caps_capture
159 tdm_capture_capability capabilities; /**< The capabilities of capture */
161 unsigned int format_count; /**< The count of available formats */
162 tbm_format *formats; /**< The @b newly-allocated array of formats. will be freed in frontend. */
164 int min_w; /**< The minimun width. -1 means "not defined" */
165 int min_h; /**< The minimun height. -1 means "not defined" */
166 int max_w; /**< The maximum width. -1 means "not defined" */
167 int max_h; /**< The maximum height. -1 means "not defined" */
168 int preferred_align; /**< The prefered align. -1 means "not defined" */
172 * @brief The display functions for a backend module.
174 typedef struct _tdm_func_display
177 * @brief Get the display capabilities of a backend module
178 * @param[in] bdata The backend module data
179 * @param[out] caps The display capabilities of a backend module
180 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
182 * A backend module @b SHOULD implement this function. TDM calls this function
183 * not only at the initial time, but also at the update time when new output
185 * If a hardware has the restriction of the number of max usable layer count,
186 * a backend module can set the max count to max_layer_count of #tdm_caps_display
187 * structure. Otherwise, set -1.
189 tdm_error (*display_get_capabilitiy)(tdm_backend_data *bdata, tdm_caps_display *caps);
192 * @brief Get the pp capabilities of a backend module
193 * @param[in] bdata The backend module data
194 * @param[out] caps The pp capabilities of a backend module
195 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
196 * @see tdm_backend_register_func_pp
198 * TDM calls this function not only at the initial time, but also at the update
199 * time when new output is connected.\n
200 * A backend module doesn't need to implement this function if a hardware
201 * doesn't have the memory-to-memory converting device. Otherwise, a backend module
202 * @b SHOULD fill the #tdm_caps_pp data. #tdm_caps_pp contains the hardware
203 * restriction information which a converting device can handle. ie, format, size, etc.
205 tdm_error (*display_get_pp_capability)(tdm_backend_data *bdata, tdm_caps_pp *caps);
208 * @brief Get the capture capabilities of a backend module
209 * @param[in] bdata The backend module data
210 * @param[out] caps The capture capabilities of a backend module
211 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
212 * @see tdm_backend_register_func_capture
214 * TDM calls this function not only at the initial time, but also at the update
215 * time when new output is connected.\n
216 * A backend module doesn't need to implement this function if a hardware
217 * doesn't have the capture device. Otherwise, a backend module @b SHOULD fill the
218 * #tdm_caps_capture data. #tdm_caps_capture contains the hardware restriction
219 * information which a capture device can handle. ie, format, size, etc.
221 tdm_error (*display_get_capture_capability)(tdm_backend_data *bdata, tdm_caps_capture *caps);
224 * @brief Get a output array of a backend module
225 * @param[in] bdata The backend module data
226 * @param[out] count The count of outputs
227 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
228 * @return A output array which is @b newly-allocated
229 * @see tdm_backend_register_func_capture
231 * A backend module @b SHOULD implement this function. TDM calls this function
232 * not only at the initial time, but also at the update time when new output
234 * A backend module @b SHOULD return the @b newly-allocated array which contains
235 * "tdm_output*" data. It will be freed in frontend.
239 drm_display_get_outputs(tdm_backend_data *bdata, int *count, tdm_error *error)
241 tdm_drm_data *drm_data = bdata;
242 tdm_drm_output_data *output_data = NULL;
243 tdm_output **outputs;
247 LIST_FOR_EACH_ENTRY(output_data, &drm_data->output_list, link)
252 if (error) *error = TDM_ERROR_NONE;
256 // will be freed in frontend
257 outputs = calloc(*count, sizeof(tdm_drm_output_data*));
261 if (error) *error = TDM_ERROR_OUT_OF_MEMORY;
266 LIST_FOR_EACH_ENTRY(output_data, &drm_data->output_list, link)
267 outputs[i++] = output_data;
269 if (error) *error = TDM_ERROR_NONE;
275 tdm_output **(*display_get_outputs)(tdm_backend_data *bdata, int *count, tdm_error *error);
278 * @brief Get the file descriptor of a backend module
279 * @param[in] bdata The backend module data
280 * @param[out] fd The fd of a backend module
281 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
282 * @see display_handle_events() function of #tdm_func_display
284 * A backend module can return epoll's fd which is watching the backend device one more fds.
286 tdm_error (*display_get_fd)(tdm_backend_data *bdata, int *fd);
289 * @brief Get the file descriptor for the memory-management framework of a backend module
290 * @param[in] bdata The backend module data
291 * @param[out] fd The fd of a backend module
292 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
293 * @see display_handle_events() function of #tdm_func_display
294 * This buffer fd will be passed to tbm_bufmgr_init.
296 tdm_error (*display_get_buffer_fd)(tdm_backend_data *bdata, int *fd);
299 * @brief Handle the events which happens on the fd of a backend module
300 * @param[in] bdata The backend module data
301 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
303 tdm_error (*display_handle_events)(tdm_backend_data *bdata);
306 * @brief Create a pp object of a backend module
307 * @param[in] bdata The backend module data
308 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
309 * @return A pp object
310 * @see pp_destroy() function of #tdm_func_pp
312 * A backend module doesn't need to implement this function if a hardware
313 * doesn't have the memory-to-memory converting device.
315 tdm_pp* (*display_create_pp)(tdm_backend_data *bdata, tdm_error *error);
317 void (*reserved1)(void);
318 void (*reserved2)(void);
319 void (*reserved3)(void);
320 void (*reserved4)(void);
321 void (*reserved5)(void);
322 void (*reserved6)(void);
323 void (*reserved7)(void);
324 void (*reserved8)(void);
328 * @brief The output functions for a backend module.
330 typedef struct _tdm_func_output
333 * @brief Get the capabilities of a output object
334 * @param[in] output A output object
335 * @param[out] caps The capabilities of a output object
336 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
338 * A backend module @b SHOULD implement this function. TDM calls this function
339 * not only at the initial time, but also at the update time when new output
341 * #tdm_caps_output contains connection status, modes, avaiable properties,
342 * size restriction information, etc.
344 tdm_error (*output_get_capability)(tdm_output *output, tdm_caps_output *caps);
347 * @brief Get a layer array of a output object
348 * @param[in] output A output object
349 * @param[out] count The count of layers
350 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
351 * @return A layer array which is @b newly-allocated
353 * A backend module @b SHOULD implement this function. TDM calls this function
354 * not only at the initial time, but also at the update time when new output
356 * A backend module @b SHOULD return the @b newly-allocated array which contains
357 * "tdm_layer*" data. It will be freed in frontend.
359 tdm_layer **(*output_get_layers)(tdm_output *output, int *count, tdm_error *error);
362 * @brief Set the property which has a given id
363 * @param[in] output A output object
364 * @param[in] id The property id
365 * @param[in] value The value
366 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
368 tdm_error (*output_set_property)(tdm_output *output, unsigned int id, tdm_value value);
371 * @brief Get the property which has a given id
372 * @param[in] output A output object
373 * @param[in] id The property id
374 * @param[out] value The value
375 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
377 tdm_error (*output_get_property)(tdm_output *output, unsigned int id, tdm_value *value);
380 * @brief Wait for VBLANK
381 * @param[in] output A output object
382 * @param[in] interval vblank interval
383 * @param[in] sync 0: asynchronous, 1:synchronous
384 * @param[in] user_data The user data
385 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
386 * @see output_set_vblank_handler, tdm_output_vblank_handler
388 * A backend module @b SHOULD call a user vblank handler after interval vblanks.
390 tdm_error (*output_wait_vblank)(tdm_output *output, int interval, int sync, void *user_data);
393 * @brief Set a user vblank handler
394 * @param[in] output A output object
395 * @param[in] func A user vblank handler
396 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
398 tdm_error (*output_set_vblank_handler)(tdm_output *output, tdm_output_vblank_handler func);
401 * @brief Commit changes for a output object
402 * @param[in] output A output object
403 * @param[in] sync 0: asynchronous, 1:synchronous
404 * @param[in] user_data The user data
405 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
406 * @see output_set_commit_handler, tdm_output_commit_handler
408 * A backend module @b SHOULD call a user commit handler after all change of
409 * a output object are applied.
411 tdm_error (*output_commit)(tdm_output *output, int sync, void *user_data);
414 * @brief Set a user commit handler
415 * @param[in] output A output object
416 * @param[in] func A user commit handler
417 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
419 tdm_error (*output_set_commit_handler)(tdm_output *output, tdm_output_commit_handler func);
422 * @brief Set DPMS of a output object
423 * @param[in] output A output object
424 * @param[in] dpms_value DPMS value
425 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
427 tdm_error (*output_set_dpms)(tdm_output *output, tdm_output_dpms dpms_value);
430 * @brief Get DPMS of a output object
431 * @param[in] output A output object
432 * @param[out] dpms_value DPMS value
433 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
435 tdm_error (*output_get_dpms)(tdm_output *output, tdm_output_dpms *dpms_value);
438 * @brief Set one of available modes of a output object
439 * @param[in] output A output object
440 * @param[in] mode A output mode
441 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
443 tdm_error (*output_set_mode)(tdm_output *output, const tdm_output_mode *mode);
446 * @brief Get the mode of a output object
447 * @param[in] output A output object
448 * @param[out] mode A output mode
449 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
451 tdm_error (*output_get_mode)(tdm_output *output, const tdm_output_mode **mode);
454 * @brief Create a capture object of a output object
455 * @param[in] output A output object
456 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
457 * @return A capture object
458 * @see capture_destroy() function of #tdm_func_capture
460 * A backend module doesn't need to implement this function if a hardware
461 * doesn't have the capture device.
463 tdm_capture *(*output_create_capture)(tdm_output *output, tdm_error *error);
465 void (*reserved1)(void);
466 void (*reserved2)(void);
467 void (*reserved3)(void);
468 void (*reserved4)(void);
469 void (*reserved5)(void);
470 void (*reserved6)(void);
471 void (*reserved7)(void);
472 void (*reserved8)(void);
476 * @brief The layer functions for a backend module.
478 typedef struct _tdm_func_layer
481 * @brief Get the capabilities of a layer object
482 * @param[in] layer A layer object
483 * @param[out] caps The capabilities of a layer object
484 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
486 * A backend module @b SHOULD implement this function. TDM calls this function
487 * not only at the initial time, but also at the update time when new output
489 * #tdm_caps_layer contains avaiable formats/properties, zpos information, etc.
491 tdm_error (*layer_get_capability)(tdm_layer *layer, tdm_caps_layer *caps);
494 * @brief Set the property which has a given id.
495 * @param[in] layer A layer object
496 * @param[in] id The property id
497 * @param[in] value The value
498 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
500 tdm_error (*layer_set_property)(tdm_layer *layer, unsigned int id, tdm_value value);
503 * @brief Get the property which has a given id.
504 * @param[in] layer A layer object
505 * @param[in] id The property id
506 * @param[out] value The value
507 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
509 tdm_error (*layer_get_property)(tdm_layer *layer, unsigned int id, tdm_value *value);
512 * @brief Set the geometry information to a layer object
513 * @param[in] layer A layer object
514 * @param[in] info The geometry information
515 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
516 * @see output_commit() function of #tdm_func_display
518 * A backend module would apply the geometry information when the output object
519 * of a layer object is committed.
521 tdm_error (*layer_set_info)(tdm_layer *layer, tdm_info_layer *info);
524 * @brief Get the geometry information to a layer object
525 * @param[in] layer A layer object
526 * @param[out] info The geometry information
527 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
529 tdm_error (*layer_get_info)(tdm_layer *layer, tdm_info_layer *info);
532 * @brief Set a TDM buffer to a layer object
533 * @param[in] layer A layer object
534 * @param[in] buffer A TDM buffer
535 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
536 * @see output_commit() function of #tdm_func_display
538 * A backend module would apply a TDM buffer when the output object
539 * of a layer object is committed.
541 tdm_error (*layer_set_buffer)(tdm_layer *layer, tbm_surface_h buffer);
544 * @brief Unset a TDM buffer from a layer object
545 * @param[in] layer A layer object
546 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
548 * A backend module @b SHOULD hide the current showing buffer from screen.
549 * If needed, cleanup a layer object resource.
551 tdm_error (*layer_unset_buffer)(tdm_layer *layer);
554 * @brief Set the zpos for a VIDEO layer object
555 * @param[in] layer A layer object
556 * @param[in] zpos z-order
557 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
558 * @see tdm_caps_layer, tdm_layer_capability
560 * A backend module doesn't need to implement this function if a backend
561 * module doesn't have VIDEO layers.\n
562 * This function is for VIDEO layers.
563 * GRAPHIC layers are non-changeable. The zpos of GRAPHIC layers starts
564 * from 0. If there are 4 GRAPHIC layers, The zpos SHOULD be 0, 1, 2, 3.\n
565 * But the zpos of VIDEO layer is changeable. And The zpos of VIDEO layers
566 * is less than GRAPHIC layers or more than GRAPHIC layers.
567 * ie, ..., -2, -1, 4, 5, ... (if 0 <= GRAPHIC layer's zpos < 4).
568 * The zpos of VIDEO layers is @b relative. It doesn't need to start
569 * from -1 or 4. Let's suppose that there are two VIDEO layers.
570 * One has -2 zpos. Another has -4 zpos. Then -2 Video layer is higher
571 * than -4 VIDEO layer.
573 tdm_error (*layer_set_video_pos)(tdm_layer *layer, int zpos);
576 * @brief Create a capture object of a layer object
577 * @param[in] output A output object
578 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
579 * @return A capture object
580 * @see capture_destroy() function of #tdm_func_capture
582 * A backend module doesn't need to implement this function if a hardware
583 * doesn't have the capture device.
585 tdm_capture *(*layer_create_capture)(tdm_layer *layer, tdm_error *error);
587 void (*reserved1)(void);
588 void (*reserved2)(void);
589 void (*reserved3)(void);
590 void (*reserved4)(void);
591 void (*reserved5)(void);
592 void (*reserved6)(void);
593 void (*reserved7)(void);
594 void (*reserved8)(void);
598 * @brief The done handler of a pp object
600 typedef void (*tdm_pp_done_handler)(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst, void *user_data);
603 * @brief The pp functions for a backend module.
605 typedef struct _tdm_func_pp
608 * @brief Destroy a pp object
609 * @param[in] pp A pp object
610 * @see display_create_pp() function of #tdm_func_display
612 void (*pp_destroy)(tdm_pp *pp);
615 * @brief Set the geometry information to a pp object
616 * @param[in] pp A pp object
617 * @param[in] info The geometry information
618 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
619 * @see pp_commit() function of #tdm_func_pp
621 * A backend module would apply the geometry information when committed.
623 tdm_error (*pp_set_info)(tdm_pp *pp, tdm_info_pp *info);
626 * @brief Attach a source buffer and a destination buffer to a pp object
627 * @param[in] pp A pp object
628 * @param[in] src A source buffer
629 * @param[in] dst A destination buffer
630 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
631 * @see pp_set_info() function of #tdm_func_pp
632 * @see pp_commit() function of #tdm_func_pp
633 * @see pp_set_done_handler, tdm_pp_done_handler
635 * A backend module converts the image of a source buffer to a destination
636 * buffer when committed. The size/crop/transform information is set via
637 * #pp_set_info() of #tdm_func_pp. When done, a backend module @b SHOULD
638 * return the source/destination buffer via tdm_pp_done_handler.
640 tdm_error (*pp_attach)(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst);
643 * @brief Commit changes for a pp object
644 * @param[in] pp A pp object
645 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
647 tdm_error (*pp_commit)(tdm_pp *pp);
650 * @brief Set a user done handler to a pp object
651 * @param[in] pp A pp object
652 * @param[in] func A user done handler
653 * @param[in] user_data user data
654 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
656 * A backend module @b SHOULD call #tdm_pp_done_handler when converintg a image is done.
658 tdm_error (*pp_set_done_handler)(tdm_pp *pp, tdm_pp_done_handler func, void *user_data);
660 void (*reserved1)(void);
661 void (*reserved2)(void);
662 void (*reserved3)(void);
663 void (*reserved4)(void);
664 void (*reserved5)(void);
665 void (*reserved6)(void);
666 void (*reserved7)(void);
667 void (*reserved8)(void);
671 * @brief The done handler of a capture object
673 typedef void (*tdm_capture_done_handler)(tdm_capture *capture, tbm_surface_h buffer, void *user_data);
676 * @brief The capture functions for a backend module.
678 typedef struct _tdm_func_capture
681 * @brief Destroy a capture object
682 * @param[in] capture A capture object
683 * @see output_create_capture() function of #tdm_func_display
684 * @see layer_create_capture() function of #tdm_func_display
686 void (*capture_destroy)(tdm_capture *capture);
689 * @brief Set the geometry information to a capture object
690 * @param[in] capture A capture object
691 * @param[in] info The geometry information
692 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
693 * @see capture_commit() function of #tdm_func_capture
695 * A backend module would apply the geometry information when committed.
697 tdm_error (*capture_set_info)(tdm_capture *capture, tdm_info_capture *info);
700 * @brief Attach a TDM buffer to a capture object
701 * @details When capture_commit() function is called, a backend module dumps
702 * a output or a layer to a TDM buffer.
703 * @param[in] capture A capture object
704 * @param[in] buffer A TDM buffer
705 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
706 * @see capture_set_info() function of #tdm_func_capture
707 * @see capture_commit() function of #tdm_func_capture
708 * @see capture_set_done_handler, tdm_capture_done_handler
710 * A backend module dumps a output or a layer to to a TDM buffer when
711 * committed. The size/crop/transform information is set via #capture_set_info()
712 * of #tdm_func_capture. When done, a backend module @b SHOULD return the TDM
713 * buffer via tdm_capture_done_handler.
715 tdm_error (*capture_attach)(tdm_capture *capture, tbm_surface_h buffer);
718 * @brief Commit changes for a capture object
719 * @param[in] capture A capture object
720 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
722 tdm_error (*capture_commit)(tdm_capture *capture);
725 * @brief Set a user done handler to a capture object
726 * @param[in] capture A capture object
727 * @param[in] func A user done handler
728 * @param[in] user_data user data
729 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
731 * A backend module @b SHOULD call #tdm_capture_done_handler when capture operation is done.
733 tdm_error (*capture_set_done_handler)(tdm_capture *capture, tdm_capture_done_handler func, void *user_data);
735 void (*reserved1)(void);
736 void (*reserved2)(void);
737 void (*reserved3)(void);
738 void (*reserved4)(void);
739 void (*reserved5)(void);
740 void (*reserved6)(void);
741 void (*reserved7)(void);
742 void (*reserved8)(void);
746 * ABI versions. Each version has a major and minor revision. Modules
747 * using lower minor revisions must work with servers of a higher minor
748 * revision. There is no compatibility between different major revisions.
749 * Whenever the ABI_ANSIC_VERSION is changed, the others must also be
750 * changed. The minor revision mask is 0x0000FFFF and the major revision
751 * mask is 0xFFFF0000.
753 #define TDM_BACKEND_MINOR_VERSION_MASK 0x0000FFFF
754 #define TDM_BACKEND_MAJOR_VERSION_MASK 0xFFFF0000
755 #define TDM_BACKEND_GET_ABI_MINOR(v) ((v) & TDM_BACKEND_MINOR_VERSION_MASK)
756 #define TDM_BACKEND_GET_ABI_MAJOR(v) (((v) & TDM_BACKEND_MAJOR_VERSION_MASK) >> 16)
758 #define SET_TDM_BACKEND_ABI_VERSION(major, minor) \
759 (((major) << 16) & TDM_BACKEND_MAJOR_VERSION_MASK) | \
760 ((major) & TDM_BACKEND_MINOR_VERSION_MASK)
761 #define TDM_BACKEND_ABI_VERSION SET_TDM_BACKEND_ABI_VERSION(1, 1)
764 * @brief The backend module information of the entry point to initialize a TDM
767 * A backend module @b SHOULD define the global data symbol of which name is
768 * @b "tdm_backend_module_data". TDM will read this symbol, @b "tdm_backend_module_data",
769 * at the initial time and call init() function of #tdm_backend_module.
771 typedef struct _tdm_backend_module
773 const char *name; /**< The module name of a backend module */
774 const char *vendor; /**< The vendor name of a backend module */
775 unsigned long abi_version; /**< The ABI version of a backend module */
778 * @brief The init function of a backend module
779 * @param[in] dpy A display object
780 * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
781 * @return The backend module data
782 * @see tdm_backend_data
784 tdm_backend_data* (*init)(tdm_display *dpy, tdm_error *error);
787 * @brief The deinit function of a backend module
788 * @param[in] bdata The backend module data
790 void (*deinit)(tdm_backend_data *bdata);
791 } tdm_backend_module;
794 * @brief Register the backend display functions to a display
795 * @param[in] dpy A display object
796 * @param[in] func_display display functions
797 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
798 * @see tdm_backend_register_func_output, tdm_backend_register_func_layer
800 * A backend module @b SHOULD set the backend display functions at least.
802 tdm_error tdm_backend_register_func_display(tdm_display *dpy, tdm_func_display *func_display);
805 * @brief Register the backend output functions to a display
806 * @param[in] dpy A display object
807 * @param[in] func_output output functions
808 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
809 * @see tdm_backend_register_func_display, tdm_backend_register_func_layer
811 * A backend module @b SHOULD set the backend output functions at least.
813 tdm_error tdm_backend_register_func_output(tdm_display *dpy, tdm_func_output *func_output);
816 * @brief Register the backend layer functions to a display
817 * @param[in] dpy A display object
818 * @param[in] func_layer layer functions
819 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
820 * @see tdm_backend_register_func_display, tdm_backend_register_func_output
822 * A backend module @b SHOULD set the backend layer functions at least.
824 tdm_error tdm_backend_register_func_layer(tdm_display *dpy, tdm_func_layer *func_layer);
827 * @brief Register the backend pp functions to a display
828 * @param[in] dpy A display object
829 * @param[in] func_pp pp functions
830 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
831 * @see tdm_backend_register_func_display, tdm_backend_register_func_capture
833 * A backend module doesn'tcan skip to register the backend pp functions
834 * if a hardware doesn't have the memory-to-memory converting device.
836 tdm_error tdm_backend_register_func_pp(tdm_display *dpy, tdm_func_pp *func_pp);
839 * @brief Register the backend capture functions to a display
840 * @param[in] dpy A display object
841 * @param[in] func_capture capture functions
842 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
843 * @see tdm_backend_register_func_display, tdm_backend_register_func_pp
845 * A backend module can skip to register the backend capture functions
846 * if a hardware doesn't have the capture device.
848 tdm_error tdm_backend_register_func_capture(tdm_display *dpy, tdm_func_capture *func_capture);
851 * @brief Increase the ref_count of a TDM buffer
853 * TDM has its own buffer release mechanism to let an frontend user know when a TDM buffer
854 * becomes available for a next job. A TDM buffer can be used for TDM to show
855 * it on screen or to capture an output and a layer. After all operations,
856 * TDM will release it immediately when TDM doesn't need it any more.
857 * @param[in] buffer A TDM buffer
858 * @return A buffer itself. Otherwise, NULL.
859 * @see tdm_buffer_unref_backend
861 * - This function @b SHOULD be paired with #tdm_buffer_unref_backend. \n
862 * - For example, this function @b SHOULD be called in case that a backend module uses the TDM
863 * buffer of a layer for capturing a output or a layer to avoid tearing issue.
865 tbm_surface_h tdm_buffer_ref_backend(tbm_surface_h buffer);
868 * @brief Decrease the ref_count of a TDM buffer
869 * @param[in] buffer A TDM buffer
870 * @see tdm_buffer_ref_backend
872 void tdm_buffer_unref_backend(tbm_surface_h buffer);
875 * @brief The destroy handler of a TDM buffer
876 * @param[in] buffer A TDM buffer
877 * @param[in] user_data user data
878 * @see tdm_buffer_add_destroy_handler, tdm_buffer_remove_destroy_handler
880 typedef void (*tdm_buffer_destroy_handler)(tbm_surface_h buffer, void *user_data);
883 * @brief Add a destroy handler to a TDM buffer
884 * @param[in] buffer A TDM buffer
885 * @param[in] func A destroy handler
886 * @param[in] user_data user data
887 * @return #TDM_ERROR_NONE if success. Otherwise, error value.
888 * @see tdm_buffer_remove_destroy_handler
890 * A backend module can add a TDM buffer destroy handler to a TDM buffer which
891 * is a #tbm_surface_h object. When the TDM buffer is destroyed, this handler will
894 tdm_error tdm_buffer_add_destroy_handler(tbm_surface_h buffer, tdm_buffer_destroy_handler func, void *user_data);
897 * @brief Remove a destroy handler from a TDM buffer
898 * @param[in] buffer A TDM buffer
899 * @param[in] func A destroy handler
900 * @param[in] user_data user data
901 * @see tdm_buffer_add_destroy_handler
903 void tdm_buffer_remove_destroy_handler(tbm_surface_h buffer, tdm_buffer_destroy_handler func, void *user_data);
910 #endif /* _TDM_BACKEND_H_ */