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 **************************************************************************/
41 #include "tdm_backend.h"
42 #include "tdm_private.h"
46 #define DISPLAY_FUNC_ENTRY() \
47 tdm_private_display *private_display; \
48 tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\
49 TDM_RETURN_VAL_IF_FAIL(dpy != NULL, TDM_ERROR_INVALID_PARAMETER); \
50 private_display = (tdm_private_display*)dpy;
52 #define DISPLAY_FUNC_ENTRY_ERROR() \
53 tdm_private_display *private_display; \
54 tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\
55 TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(dpy != NULL, TDM_ERROR_INVALID_PARAMETER, NULL); \
56 private_display = (tdm_private_display*)dpy;
58 #define OUTPUT_FUNC_ENTRY() \
59 tdm_private_display *private_display; \
60 tdm_private_output *private_output; \
61 tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\
62 TDM_RETURN_VAL_IF_FAIL(output != NULL, TDM_ERROR_INVALID_PARAMETER); \
63 private_output = (tdm_private_output*)output; \
64 private_display = private_output->private_display
66 #define OUTPUT_FUNC_ENTRY_ERROR() \
67 tdm_private_display *private_display; \
68 tdm_private_output *private_output; \
69 tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\
70 TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(output != NULL, TDM_ERROR_INVALID_PARAMETER, NULL); \
71 private_output = (tdm_private_output*)output; \
72 private_display = private_output->private_display
74 #define LAYER_FUNC_ENTRY() \
75 tdm_private_display *private_display; \
76 tdm_private_output *private_output; \
77 tdm_private_layer *private_layer; \
78 tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\
79 TDM_RETURN_VAL_IF_FAIL(layer != NULL, TDM_ERROR_INVALID_PARAMETER); \
80 private_layer = (tdm_private_layer*)layer; \
81 private_output = private_layer->private_output; \
82 private_display = private_output->private_display
84 #define LAYER_FUNC_ENTRY_ERROR() \
85 tdm_private_display *private_display; \
86 tdm_private_output *private_output; \
87 tdm_private_layer *private_layer; \
88 tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\
89 TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(layer != NULL, TDM_ERROR_INVALID_PARAMETER, NULL); \
90 private_layer = (tdm_private_layer*)layer; \
91 private_output = private_layer->private_output; \
92 private_display = private_output->private_display
95 tdm_display_get_capabilities(tdm_display *dpy, tdm_display_capability *capabilities)
99 TDM_RETURN_VAL_IF_FAIL(capabilities != NULL, TDM_ERROR_INVALID_PARAMETER);
101 pthread_mutex_lock(&private_display->lock);
103 *capabilities = private_display->capabilities;
105 pthread_mutex_unlock(&private_display->lock);
111 tdm_display_get_pp_capabilities(tdm_display *dpy, tdm_pp_capability *capabilities)
113 DISPLAY_FUNC_ENTRY();
115 TDM_RETURN_VAL_IF_FAIL(capabilities != NULL, TDM_ERROR_INVALID_PARAMETER);
117 pthread_mutex_lock(&private_display->lock);
119 *capabilities = private_display->caps_pp.capabilities;
121 pthread_mutex_unlock(&private_display->lock);
127 tdm_display_get_pp_available_formats(tdm_display *dpy, const tbm_format **formats, int *count)
129 DISPLAY_FUNC_ENTRY();
131 TDM_RETURN_VAL_IF_FAIL(formats != NULL, TDM_ERROR_INVALID_PARAMETER);
132 TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
134 pthread_mutex_lock(&private_display->lock);
136 *formats = (const tbm_format*)private_display->caps_pp.formats;
137 *count = private_display->caps_pp.format_count;
139 pthread_mutex_unlock(&private_display->lock);
145 tdm_display_get_pp_available_size(tdm_display *dpy, int *min_w, int *min_h,
146 int *max_w, int *max_h, int *preferred_align)
148 DISPLAY_FUNC_ENTRY();
150 pthread_mutex_lock(&private_display->lock);
153 *min_w = private_display->caps_pp.min_w;
155 *min_h = private_display->caps_pp.min_h;
157 *max_w = private_display->caps_pp.max_w;
159 *max_h = private_display->caps_pp.max_h;
161 *preferred_align = private_display->caps_pp.preferred_align;
163 pthread_mutex_unlock(&private_display->lock);
169 tdm_display_get_capture_capabilities(tdm_display *dpy, tdm_capture_capability *capabilities)
171 DISPLAY_FUNC_ENTRY();
173 TDM_RETURN_VAL_IF_FAIL(capabilities != NULL, TDM_ERROR_INVALID_PARAMETER);
175 pthread_mutex_lock(&private_display->lock);
177 *capabilities = private_display->caps_capture.capabilities;
179 pthread_mutex_unlock(&private_display->lock);
185 tdm_display_get_catpure_available_formats(tdm_display *dpy, const tbm_format **formats, int *count)
187 DISPLAY_FUNC_ENTRY();
189 TDM_RETURN_VAL_IF_FAIL(formats != NULL, TDM_ERROR_INVALID_PARAMETER);
190 TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
192 pthread_mutex_lock(&private_display->lock);
194 *formats = (const tbm_format*)private_display->caps_capture.formats;
195 *count = private_display->caps_capture.format_count;
197 pthread_mutex_unlock(&private_display->lock);
203 tdm_display_get_output_count(tdm_display *dpy, int *count)
205 tdm_private_output *private_output = NULL;
207 DISPLAY_FUNC_ENTRY();
209 TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
211 pthread_mutex_lock(&private_display->lock);
214 LIST_FOR_EACH_ENTRY(private_output, &private_display->output_list, link)
219 pthread_mutex_unlock(&private_display->lock);
220 return TDM_ERROR_NONE;
223 pthread_mutex_unlock(&private_display->lock);
229 EXTERN const tdm_output*
230 tdm_display_get_output(tdm_display *dpy, int index, tdm_error *error)
232 tdm_private_output *private_output = NULL;
235 DISPLAY_FUNC_ENTRY_ERROR();
237 pthread_mutex_lock(&private_display->lock);
240 *error = TDM_ERROR_NONE;
243 LIST_FOR_EACH_ENTRY(private_output, &private_display->output_list, link)
247 pthread_mutex_unlock(&private_display->lock);
248 return (const tdm_output*)private_output;
253 pthread_mutex_unlock(&private_display->lock);
259 tdm_display_get_fd(tdm_display *dpy, int *fd)
261 tdm_func_display *func_display;
262 DISPLAY_FUNC_ENTRY();
264 TDM_RETURN_VAL_IF_FAIL(fd != NULL, TDM_ERROR_INVALID_PARAMETER);
266 pthread_mutex_lock(&private_display->lock);
268 func_display = &private_display->func_display;
270 if (!func_display->display_get_fd)
272 pthread_mutex_unlock(&private_display->lock);
273 return TDM_ERROR_NONE;
276 ret = func_display->display_get_fd(private_display->bdata, fd);
278 pthread_mutex_unlock(&private_display->lock);
284 tdm_display_handle_events(tdm_display *dpy)
286 tdm_func_display *func_display;
287 DISPLAY_FUNC_ENTRY();
289 pthread_mutex_lock(&private_display->lock);
291 func_display = &private_display->func_display;
293 if (!func_display->display_handle_events)
295 pthread_mutex_unlock(&private_display->lock);
296 return TDM_ERROR_NONE;
299 ret = func_display->display_handle_events(private_display->bdata);
301 pthread_mutex_unlock(&private_display->lock);
307 tdm_display_create_pp(tdm_display *dpy, tdm_error *error)
311 DISPLAY_FUNC_ENTRY_ERROR();
313 pthread_mutex_lock(&private_display->lock);
315 pp = (tdm_pp*)tdm_pp_create_internal(private_display, error);
317 pthread_mutex_unlock(&private_display->lock);
323 tdm_output_get_conn_status(tdm_output *output, tdm_output_conn_status *status)
327 TDM_RETURN_VAL_IF_FAIL(status != NULL, TDM_ERROR_INVALID_PARAMETER);
329 pthread_mutex_lock(&private_display->lock);
331 *status = private_output->caps.status;
333 pthread_mutex_unlock(&private_display->lock);
339 tdm_output_get_output_type(tdm_output *output, tdm_output_type *type)
343 TDM_RETURN_VAL_IF_FAIL(type != NULL, TDM_ERROR_INVALID_PARAMETER);
345 pthread_mutex_lock(&private_display->lock);
347 *type = private_output->caps.type;
349 pthread_mutex_unlock(&private_display->lock);
355 tdm_output_get_layer_count(tdm_output *output, int *count)
357 tdm_private_layer *private_layer = NULL;
361 TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
363 pthread_mutex_lock(&private_display->lock);
366 LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link)
370 pthread_mutex_unlock(&private_display->lock);
371 return TDM_ERROR_NONE;
374 pthread_mutex_unlock(&private_display->lock);
380 EXTERN const tdm_layer*
381 tdm_output_get_layer(tdm_output *output, int index, tdm_error *error)
383 tdm_private_layer *private_layer = NULL;
386 OUTPUT_FUNC_ENTRY_ERROR();
388 pthread_mutex_lock(&private_display->lock);
391 *error = TDM_ERROR_NONE;
393 LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link)
397 pthread_mutex_unlock(&private_display->lock);
398 return private_layer;
403 pthread_mutex_unlock(&private_display->lock);
409 tdm_output_get_available_properties(tdm_output *output, const tdm_prop **props, int *count)
413 TDM_RETURN_VAL_IF_FAIL(props != NULL, TDM_ERROR_INVALID_PARAMETER);
414 TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
416 pthread_mutex_lock(&private_display->lock);
418 *props = (const tdm_prop*)private_output->caps.props;
419 *count = private_output->caps.prop_count;
421 pthread_mutex_unlock(&private_display->lock);
427 tdm_output_get_available_modes(tdm_output *output, const tdm_output_mode **modes, int *count)
431 TDM_RETURN_VAL_IF_FAIL(modes != NULL, TDM_ERROR_INVALID_PARAMETER);
432 TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
434 pthread_mutex_lock(&private_display->lock);
436 *modes = (const tdm_output_mode*)private_output->caps.modes;
437 *count = private_output->caps.mode_count;
439 pthread_mutex_unlock(&private_display->lock);
445 tdm_output_get_available_size(tdm_output *output, int *min_w, int *min_h,
446 int *max_w, int *max_h, int *preferred_align)
450 pthread_mutex_lock(&private_display->lock);
453 *min_w = private_output->caps.min_w;
455 *min_h = private_output->caps.min_h;
457 *max_w = private_output->caps.max_w;
459 *max_h = private_output->caps.max_h;
461 *preferred_align = private_output->caps.preferred_align;
463 pthread_mutex_unlock(&private_display->lock);
469 tdm_output_get_physical_size(tdm_output *output, unsigned int *mmWidth, unsigned int *mmHeight)
473 pthread_mutex_lock(&private_display->lock);
476 *mmWidth = private_output->caps.mmWidth;
478 *mmHeight = private_output->caps.mmHeight;
480 pthread_mutex_unlock(&private_display->lock);
486 tdm_output_get_subpixel(tdm_output *output, unsigned int *subpixel)
489 TDM_RETURN_VAL_IF_FAIL(subpixel != NULL, TDM_ERROR_INVALID_PARAMETER);
491 pthread_mutex_lock(&private_display->lock);
493 *subpixel = private_output->caps.subpixel;
495 pthread_mutex_unlock(&private_display->lock);
501 tdm_output_get_pipe(tdm_output *output, unsigned int *pipe)
504 TDM_RETURN_VAL_IF_FAIL(pipe != NULL, TDM_ERROR_INVALID_PARAMETER);
506 pthread_mutex_lock(&private_display->lock);
508 *pipe = private_output->pipe;
510 pthread_mutex_unlock(&private_display->lock);
517 tdm_output_set_property(tdm_output *output, unsigned int id, tdm_value value)
519 tdm_func_display *func_display;
522 pthread_mutex_lock(&private_display->lock);
524 func_display = &private_display->func_display;
526 if (!func_display->output_set_property)
528 pthread_mutex_unlock(&private_display->lock);
529 return TDM_ERROR_NONE;
532 ret = func_display->output_set_property(private_output->output_backend, id, value);
534 pthread_mutex_unlock(&private_display->lock);
540 tdm_output_get_property(tdm_output *output, unsigned int id, tdm_value *value)
542 tdm_func_display *func_display;
545 TDM_RETURN_VAL_IF_FAIL(value != NULL, TDM_ERROR_INVALID_PARAMETER);
547 pthread_mutex_lock(&private_display->lock);
549 func_display = &private_display->func_display;
551 if (!func_display->output_get_property)
553 pthread_mutex_unlock(&private_display->lock);
554 return TDM_ERROR_NONE;
557 ret = func_display->output_get_property(private_output->output_backend, id, value);
559 pthread_mutex_unlock(&private_display->lock);
565 _tdm_output_cb_vblank(tdm_output *output_backend, unsigned int sequence,
566 unsigned int tv_sec, unsigned int tv_usec, void *user_data)
568 tdm_private_vblank_handler *vblank_handler = user_data;
569 tdm_private_display *private_display;
571 TDM_RETURN_IF_FAIL(vblank_handler);
573 private_display = vblank_handler->private_output->private_display;
575 if (vblank_handler->func)
577 pthread_mutex_unlock(&private_display->lock);
578 vblank_handler->func(vblank_handler->private_output, sequence,
579 tv_sec, tv_usec, vblank_handler->user_data);
580 pthread_mutex_lock(&private_display->lock);
583 LIST_DEL(&vblank_handler->link);
584 free(vblank_handler);
588 _tdm_output_cb_commit(tdm_output *output_backend, unsigned int sequence,
589 unsigned int tv_sec, unsigned int tv_usec, void *user_data)
591 tdm_private_commit_handler *commit_handler = user_data;
592 tdm_private_display *private_display;
593 tdm_private_output *private_output;
594 tdm_private_layer *private_layer;
596 TDM_RETURN_IF_FAIL(commit_handler);
598 private_output = commit_handler->private_output;
599 private_display = private_output->private_display;
601 if (commit_handler->func)
603 pthread_mutex_unlock(&private_display->lock);
604 commit_handler->func(private_output, sequence,
605 tv_sec, tv_usec, commit_handler->user_data);
606 pthread_mutex_lock(&private_display->lock);
609 LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link)
611 if (!private_layer->waiting_buffer)
614 if (private_layer->showing_buffer)
616 pthread_mutex_unlock(&private_display->lock);
617 tdm_buffer_unref_backend(private_layer->showing_buffer);
618 pthread_mutex_lock(&private_display->lock);
621 private_layer->showing_buffer = private_layer->waiting_buffer;
622 private_layer->waiting_buffer = NULL;
625 LIST_DEL(&commit_handler->link);
626 free(commit_handler);
630 tdm_output_wait_vblank(tdm_output *output, int interval, int sync,
631 tdm_output_vblank_handler func, void *user_data)
633 tdm_func_display *func_display;
634 tdm_private_vblank_handler *vblank_handler;
637 pthread_mutex_lock(&private_display->lock);
639 func_display = &private_display->func_display;
641 if (!func_display->output_wait_vblank)
643 pthread_mutex_unlock(&private_display->lock);
644 return TDM_ERROR_NONE;
647 vblank_handler = calloc(1, sizeof(tdm_private_vblank_handler));
650 TDM_ERR("failed: alloc memory");
651 pthread_mutex_unlock(&private_display->lock);
652 return TDM_ERROR_OUT_OF_MEMORY;
655 LIST_ADD(&vblank_handler->link, &private_output->vblank_handler_list);
656 vblank_handler->private_output = private_output;
657 vblank_handler->func = func;
658 vblank_handler->user_data = user_data;
660 ret = func_display->output_wait_vblank(private_output->output_backend, interval,
661 sync, vblank_handler);
662 if (ret != TDM_ERROR_NONE)
664 pthread_mutex_unlock(&private_display->lock);
668 if (!private_output->regist_vblank_cb)
670 private_output->regist_vblank_cb = 1;
671 ret = func_display->output_set_vblank_handler(private_output->output_backend,
672 _tdm_output_cb_vblank);
675 pthread_mutex_unlock(&private_display->lock);
681 tdm_output_commit(tdm_output *output, int sync, tdm_output_commit_handler func, void *user_data)
683 tdm_func_display *func_display;
684 tdm_private_commit_handler *commit_handler;
687 pthread_mutex_lock(&private_display->lock);
689 func_display = &private_display->func_display;
691 if (!func_display->output_commit)
693 pthread_mutex_unlock(&private_display->lock);
694 return TDM_ERROR_NONE;
697 commit_handler = calloc(1, sizeof(tdm_private_commit_handler));
700 TDM_ERR("failed: alloc memory");
701 pthread_mutex_unlock(&private_display->lock);
702 return TDM_ERROR_OUT_OF_MEMORY;
705 LIST_ADD(&commit_handler->link, &private_output->commit_handler_list);
706 commit_handler->private_output = private_output;
707 commit_handler->func = func;
708 commit_handler->user_data = user_data;
710 ret = func_display->output_commit(private_output->output_backend, sync, commit_handler);
711 if (ret != TDM_ERROR_NONE)
713 pthread_mutex_unlock(&private_display->lock);
717 if (!private_output->regist_commit_cb)
719 private_output->regist_commit_cb = 1;
720 ret = func_display->output_set_commit_handler(private_output->output_backend,
721 _tdm_output_cb_commit);
724 pthread_mutex_unlock(&private_display->lock);
730 tdm_output_set_mode(tdm_output *output, tdm_output_mode *mode)
732 tdm_func_display *func_display;
735 TDM_RETURN_VAL_IF_FAIL(mode != NULL, TDM_ERROR_INVALID_PARAMETER);
737 pthread_mutex_lock(&private_display->lock);
739 func_display = &private_display->func_display;
741 if (!func_display->output_set_mode)
743 pthread_mutex_unlock(&private_display->lock);
744 return TDM_ERROR_NONE;
747 ret = func_display->output_set_mode(private_output->output_backend, mode);
749 pthread_mutex_unlock(&private_display->lock);
755 tdm_output_get_mode(tdm_output *output, const tdm_output_mode **mode)
757 tdm_func_display *func_display;
760 TDM_RETURN_VAL_IF_FAIL(mode != NULL, TDM_ERROR_INVALID_PARAMETER);
762 pthread_mutex_lock(&private_display->lock);
764 func_display = &private_display->func_display;
766 if (!func_display->output_get_mode)
768 pthread_mutex_unlock(&private_display->lock);
769 return TDM_ERROR_NONE;
772 ret = func_display->output_get_mode(private_output->output_backend, mode);
774 pthread_mutex_unlock(&private_display->lock);
780 tdm_output_set_dpms(tdm_output *output, tdm_output_dpms dpms_value)
782 tdm_func_display *func_display;
785 TDM_RETURN_VAL_IF_FAIL(dpms_value >= TDM_OUTPUT_DPMS_ON, TDM_ERROR_INVALID_PARAMETER);
786 TDM_RETURN_VAL_IF_FAIL(dpms_value < TDM_OUTPUT_DPMS_MAX, TDM_ERROR_INVALID_PARAMETER);
788 pthread_mutex_lock(&private_display->lock);
790 func_display = &private_display->func_display;
792 if (!func_display->output_set_dpms)
794 pthread_mutex_unlock(&private_display->lock);
795 return TDM_ERROR_NONE;
798 ret = func_display->output_set_dpms(private_output->output_backend, dpms_value);
800 pthread_mutex_unlock(&private_display->lock);
806 tdm_output_get_dpms(tdm_output *output, tdm_output_dpms *dpms_value)
808 tdm_func_display *func_display;
811 TDM_RETURN_VAL_IF_FAIL(dpms_value != NULL, TDM_ERROR_INVALID_PARAMETER);
813 pthread_mutex_lock(&private_display->lock);
815 func_display = &private_display->func_display;
817 if (!func_display->output_get_dpms)
819 pthread_mutex_unlock(&private_display->lock);
820 return TDM_ERROR_NONE;
823 ret = func_display->output_get_dpms(private_output->output_backend, dpms_value);
825 pthread_mutex_unlock(&private_display->lock);
831 tdm_output_create_capture(tdm_output *output, tdm_error *error)
833 tdm_capture *capture = NULL;
835 OUTPUT_FUNC_ENTRY_ERROR();
837 pthread_mutex_lock(&private_display->lock);
839 capture = (tdm_capture*)tdm_capture_create_output_internal(private_output, error);
841 pthread_mutex_unlock(&private_display->lock);
847 tdm_layer_get_capabilities(tdm_layer *layer, tdm_layer_capability *capabilities)
851 TDM_RETURN_VAL_IF_FAIL(capabilities != NULL, TDM_ERROR_INVALID_PARAMETER);
853 pthread_mutex_lock(&private_display->lock);
855 *capabilities = private_layer->caps.capabilities;
857 pthread_mutex_unlock(&private_display->lock);
863 tdm_layer_get_available_formats(tdm_layer *layer, const tbm_format **formats, int *count)
867 TDM_RETURN_VAL_IF_FAIL(formats != NULL, TDM_ERROR_INVALID_PARAMETER);
868 TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
870 pthread_mutex_lock(&private_display->lock);
872 *formats = (const tbm_format*)private_layer->caps.formats;
873 *count = private_layer->caps.format_count;
875 pthread_mutex_unlock(&private_display->lock);
881 tdm_layer_get_available_properties(tdm_layer *layer, const tdm_prop **props, int *count)
885 TDM_RETURN_VAL_IF_FAIL(props != NULL, TDM_ERROR_INVALID_PARAMETER);
886 TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
888 pthread_mutex_lock(&private_display->lock);
890 *props = (const tdm_prop*)private_layer->caps.props;
891 *count = private_layer->caps.prop_count;
893 pthread_mutex_unlock(&private_display->lock);
899 tdm_layer_get_zpos(tdm_layer *layer, unsigned int *zpos)
903 TDM_RETURN_VAL_IF_FAIL(zpos != NULL, TDM_ERROR_INVALID_PARAMETER);
905 pthread_mutex_lock(&private_display->lock);
907 *zpos = private_layer->caps.zpos;
909 pthread_mutex_unlock(&private_display->lock);
915 tdm_layer_set_property(tdm_layer *layer, unsigned int id, tdm_value value)
917 tdm_func_display *func_display;
920 pthread_mutex_lock(&private_display->lock);
922 func_display = &private_display->func_display;
924 if (!func_display->layer_set_property)
926 pthread_mutex_unlock(&private_display->lock);
927 return TDM_ERROR_NONE;
930 ret = func_display->layer_set_property(private_layer->layer_backend, id, value);
932 pthread_mutex_unlock(&private_display->lock);
938 tdm_layer_get_property(tdm_layer *layer, unsigned int id, tdm_value *value)
940 tdm_func_display *func_display;
943 TDM_RETURN_VAL_IF_FAIL(value != NULL, TDM_ERROR_INVALID_PARAMETER);
945 pthread_mutex_lock(&private_display->lock);
947 func_display = &private_display->func_display;
949 if (!func_display->layer_get_property)
951 pthread_mutex_unlock(&private_display->lock);
952 return TDM_ERROR_NONE;
955 ret = func_display->layer_get_property(private_layer->layer_backend, id, value);
957 pthread_mutex_unlock(&private_display->lock);
963 tdm_layer_set_info(tdm_layer *layer, tdm_info_layer *info)
965 tdm_func_display *func_display;
968 TDM_RETURN_VAL_IF_FAIL(info != NULL, TDM_ERROR_INVALID_PARAMETER);
970 pthread_mutex_lock(&private_display->lock);
972 func_display = &private_display->func_display;
974 private_layer->usable = 0;
976 if (!func_display->layer_set_info)
978 pthread_mutex_unlock(&private_display->lock);
979 return TDM_ERROR_NONE;
982 ret = func_display->layer_set_info(private_layer->layer_backend, info);
984 pthread_mutex_unlock(&private_display->lock);
990 tdm_layer_get_info(tdm_layer *layer, tdm_info_layer *info)
992 tdm_func_display *func_display;
995 TDM_RETURN_VAL_IF_FAIL(info != NULL, TDM_ERROR_INVALID_PARAMETER);
997 pthread_mutex_lock(&private_display->lock);
999 func_display = &private_display->func_display;
1001 if (!func_display->layer_get_info)
1003 pthread_mutex_unlock(&private_display->lock);
1004 return TDM_ERROR_NONE;
1007 ret = func_display->layer_get_info(private_layer->layer_backend, info);
1009 pthread_mutex_unlock(&private_display->lock);
1015 tdm_layer_set_buffer(tdm_layer *layer, tdm_buffer *buffer)
1017 tdm_func_display *func_display;
1020 TDM_RETURN_VAL_IF_FAIL(buffer != NULL, TDM_ERROR_INVALID_PARAMETER);
1022 pthread_mutex_lock(&private_display->lock);
1024 func_display = &private_display->func_display;
1026 private_layer->usable = 0;
1028 if (!func_display->layer_set_buffer)
1030 pthread_mutex_unlock(&private_display->lock);
1031 return TDM_ERROR_NONE;
1034 if (private_layer->waiting_buffer)
1036 pthread_mutex_unlock(&private_display->lock);
1037 tdm_buffer_unref_backend(private_layer->waiting_buffer);
1038 pthread_mutex_lock(&private_display->lock);
1041 private_layer->waiting_buffer = tdm_buffer_ref_backend(buffer);
1043 ret = func_display->layer_set_buffer(private_layer->layer_backend, buffer);
1045 pthread_mutex_unlock(&private_display->lock);
1051 tdm_layer_unset_buffer(tdm_layer *layer)
1053 tdm_func_display *func_display;
1056 pthread_mutex_lock(&private_display->lock);
1058 func_display = &private_display->func_display;
1060 if (private_layer->waiting_buffer)
1062 pthread_mutex_unlock(&private_display->lock);
1063 tdm_buffer_unref_backend(private_layer->waiting_buffer);
1064 pthread_mutex_lock(&private_display->lock);
1065 private_layer->waiting_buffer = NULL;
1068 if (private_layer->showing_buffer)
1070 pthread_mutex_unlock(&private_display->lock);
1071 tdm_buffer_unref_backend(private_layer->showing_buffer);
1072 pthread_mutex_lock(&private_display->lock);
1073 private_layer->showing_buffer = NULL;
1076 private_layer->usable = 1;
1078 if (!func_display->layer_unset_buffer)
1080 pthread_mutex_unlock(&private_display->lock);
1081 return TDM_ERROR_NONE;
1084 ret = func_display->layer_unset_buffer(private_layer->layer_backend);
1086 pthread_mutex_unlock(&private_display->lock);
1092 tdm_layer_is_usable(tdm_layer *layer, unsigned int *usable)
1096 TDM_RETURN_VAL_IF_FAIL(usable != NULL, TDM_ERROR_INVALID_PARAMETER);
1098 pthread_mutex_lock(&private_display->lock);
1100 *usable = private_layer->usable;
1102 pthread_mutex_unlock(&private_display->lock);
1108 tdm_layer_set_video_pos(tdm_layer *layer, int zpos)
1110 tdm_func_display *func_display;
1113 pthread_mutex_lock(&private_display->lock);
1115 func_display = &private_display->func_display;
1117 if (!(private_layer->caps.capabilities & TDM_LAYER_CAPABILITY_VIDEO))
1119 TDM_ERR("layer is not video layer");
1120 pthread_mutex_unlock(&private_display->lock);
1121 return TDM_ERROR_INVALID_PARAMETER;
1124 if (!func_display->layer_set_video_pos)
1126 pthread_mutex_unlock(&private_display->lock);
1127 return TDM_ERROR_NONE;
1130 ret = func_display->layer_set_video_pos(private_layer->layer_backend, zpos);
1132 pthread_mutex_unlock(&private_display->lock);
1138 tdm_layer_create_capture(tdm_layer *layer, tdm_error *error)
1140 tdm_capture *capture = NULL;
1142 LAYER_FUNC_ENTRY_ERROR();
1144 pthread_mutex_lock(&private_display->lock);
1146 capture = (tdm_capture*)tdm_capture_create_layer_internal(private_layer, error);
1148 pthread_mutex_unlock(&private_display->lock);