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, int *max_w, int *max_h, int *preferred_align)
147 DISPLAY_FUNC_ENTRY();
149 pthread_mutex_lock(&private_display->lock);
152 *min_w = private_display->caps_pp.min_w;
154 *min_h = private_display->caps_pp.min_h;
156 *max_w = private_display->caps_pp.max_w;
158 *max_h = private_display->caps_pp.max_h;
160 *preferred_align = private_display->caps_pp.preferred_align;
162 pthread_mutex_unlock(&private_display->lock);
168 tdm_display_get_pp_available_properties(tdm_display *dpy, const tdm_prop **props, int *count)
170 DISPLAY_FUNC_ENTRY();
172 TDM_RETURN_VAL_IF_FAIL(props != NULL, TDM_ERROR_INVALID_PARAMETER);
173 TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
175 pthread_mutex_lock(&private_display->lock);
177 *props = (const tdm_prop*)private_display->caps_pp.props;
178 *count = private_display->caps_pp.prop_count;
180 pthread_mutex_unlock(&private_display->lock);
186 tdm_display_get_capture_capabilities(tdm_display *dpy, tdm_capture_capability *capabilities)
188 DISPLAY_FUNC_ENTRY();
190 TDM_RETURN_VAL_IF_FAIL(capabilities != NULL, TDM_ERROR_INVALID_PARAMETER);
192 pthread_mutex_lock(&private_display->lock);
194 *capabilities = private_display->caps_capture.capabilities;
196 pthread_mutex_unlock(&private_display->lock);
202 tdm_display_get_catpure_available_formats(tdm_display *dpy, const tbm_format **formats, int *count)
204 DISPLAY_FUNC_ENTRY();
206 TDM_RETURN_VAL_IF_FAIL(formats != NULL, TDM_ERROR_INVALID_PARAMETER);
207 TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
209 pthread_mutex_lock(&private_display->lock);
211 *formats = (const tbm_format*)private_display->caps_capture.formats;
212 *count = private_display->caps_capture.format_count;
214 pthread_mutex_unlock(&private_display->lock);
220 tdm_display_get_output_count(tdm_display *dpy, int *count)
222 tdm_private_output *private_output = NULL;
224 DISPLAY_FUNC_ENTRY();
226 TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
228 pthread_mutex_lock(&private_display->lock);
231 LIST_FOR_EACH_ENTRY(private_output, &private_display->output_list, link)
236 pthread_mutex_unlock(&private_display->lock);
237 return TDM_ERROR_NONE;
240 pthread_mutex_unlock(&private_display->lock);
246 EXTERN const tdm_output*
247 tdm_display_get_output(tdm_display *dpy, int index, tdm_error *error)
249 tdm_private_output *private_output = NULL;
252 DISPLAY_FUNC_ENTRY_ERROR();
254 pthread_mutex_lock(&private_display->lock);
257 *error = TDM_ERROR_NONE;
260 LIST_FOR_EACH_ENTRY(private_output, &private_display->output_list, link)
264 pthread_mutex_unlock(&private_display->lock);
265 return (const tdm_output*)private_output;
270 pthread_mutex_unlock(&private_display->lock);
276 tdm_display_get_fd(tdm_display *dpy, int *fd)
278 tdm_func_display *func_display;
279 DISPLAY_FUNC_ENTRY();
281 TDM_RETURN_VAL_IF_FAIL(fd != NULL, TDM_ERROR_INVALID_PARAMETER);
283 pthread_mutex_lock(&private_display->lock);
285 func_display = &private_display->func_display;
287 if (!func_display->display_get_fd)
289 pthread_mutex_unlock(&private_display->lock);
290 return TDM_ERROR_NONE;
293 ret = func_display->display_get_fd(private_display->bdata, fd);
295 pthread_mutex_unlock(&private_display->lock);
301 tdm_display_handle_events(tdm_display *dpy)
303 tdm_func_display *func_display;
304 DISPLAY_FUNC_ENTRY();
306 pthread_mutex_lock(&private_display->lock);
308 func_display = &private_display->func_display;
310 if (!func_display->display_handle_events)
312 pthread_mutex_unlock(&private_display->lock);
313 return TDM_ERROR_NONE;
316 ret = func_display->display_handle_events(private_display->bdata);
318 pthread_mutex_unlock(&private_display->lock);
324 tdm_display_create_pp(tdm_display *dpy, tdm_error *error)
328 DISPLAY_FUNC_ENTRY_ERROR();
330 pthread_mutex_lock(&private_display->lock);
332 pp = (tdm_pp*)tdm_pp_create_internal(private_display, error);
334 pthread_mutex_unlock(&private_display->lock);
340 tdm_output_get_conn_status(tdm_output *output, tdm_output_conn_status *status)
344 TDM_RETURN_VAL_IF_FAIL(status != NULL, TDM_ERROR_INVALID_PARAMETER);
346 pthread_mutex_lock(&private_display->lock);
348 *status = private_output->caps.status;
350 pthread_mutex_unlock(&private_display->lock);
356 tdm_output_get_output_type(tdm_output *output, tdm_output_type *type)
360 TDM_RETURN_VAL_IF_FAIL(type != NULL, TDM_ERROR_INVALID_PARAMETER);
362 pthread_mutex_lock(&private_display->lock);
364 *type = private_output->caps.type;
366 pthread_mutex_unlock(&private_display->lock);
372 tdm_output_get_layer_count(tdm_output *output, int *count)
374 tdm_private_layer *private_layer = NULL;
378 TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
380 pthread_mutex_lock(&private_display->lock);
383 LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link)
387 pthread_mutex_unlock(&private_display->lock);
388 return TDM_ERROR_NONE;
391 pthread_mutex_unlock(&private_display->lock);
397 EXTERN const tdm_layer*
398 tdm_output_get_layer(tdm_output *output, int index, tdm_error *error)
400 tdm_private_layer *private_layer = NULL;
403 OUTPUT_FUNC_ENTRY_ERROR();
405 pthread_mutex_lock(&private_display->lock);
408 *error = TDM_ERROR_NONE;
410 LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link)
414 pthread_mutex_unlock(&private_display->lock);
415 return private_layer;
420 pthread_mutex_unlock(&private_display->lock);
426 tdm_output_get_available_properties(tdm_output *output, const tdm_prop **props, int *count)
430 TDM_RETURN_VAL_IF_FAIL(props != NULL, TDM_ERROR_INVALID_PARAMETER);
431 TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
433 pthread_mutex_lock(&private_display->lock);
435 *props = (const tdm_prop*)private_output->caps.props;
436 *count = private_output->caps.prop_count;
438 pthread_mutex_unlock(&private_display->lock);
444 tdm_output_get_available_modes(tdm_output *output, const tdm_output_mode **modes, int *count)
448 TDM_RETURN_VAL_IF_FAIL(modes != NULL, TDM_ERROR_INVALID_PARAMETER);
449 TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
451 pthread_mutex_lock(&private_display->lock);
453 *modes = (const tdm_output_mode*)private_output->caps.modes;
454 *count = private_output->caps.mode_count;
456 pthread_mutex_unlock(&private_display->lock);
462 tdm_output_get_available_size(tdm_output *output, int *min_w, int *min_h, int *max_w, int *max_h, int *preferred_align)
466 pthread_mutex_lock(&private_display->lock);
469 *min_w = private_output->caps.min_w;
471 *min_h = private_output->caps.min_h;
473 *max_w = private_output->caps.max_w;
475 *max_h = private_output->caps.max_h;
477 *preferred_align = private_output->caps.preferred_align;
479 pthread_mutex_unlock(&private_display->lock);
485 tdm_output_get_physical_size(tdm_output *output, unsigned int *mmWidth, unsigned int *mmHeight)
489 pthread_mutex_lock(&private_display->lock);
492 *mmWidth = private_output->caps.mmWidth;
494 *mmHeight = private_output->caps.mmHeight;
496 pthread_mutex_unlock(&private_display->lock);
502 tdm_output_get_subpixel(tdm_output *output, unsigned int *subpixel)
505 TDM_RETURN_VAL_IF_FAIL(subpixel != NULL, TDM_ERROR_INVALID_PARAMETER);
507 pthread_mutex_lock(&private_display->lock);
509 *subpixel = private_output->caps.subpixel;
511 pthread_mutex_unlock(&private_display->lock);
517 tdm_output_get_pipe(tdm_output *output, unsigned int *pipe)
520 TDM_RETURN_VAL_IF_FAIL(pipe != NULL, TDM_ERROR_INVALID_PARAMETER);
522 pthread_mutex_lock(&private_display->lock);
524 *pipe = private_output->pipe;
526 pthread_mutex_unlock(&private_display->lock);
533 tdm_output_set_property(tdm_output *output, unsigned int id, tdm_value value)
535 tdm_func_display *func_display;
538 pthread_mutex_lock(&private_display->lock);
540 func_display = &private_display->func_display;
542 if (!func_display->output_set_property)
544 pthread_mutex_unlock(&private_display->lock);
545 return TDM_ERROR_NONE;
548 ret = func_display->output_set_property(private_output->output, id, value);
550 pthread_mutex_unlock(&private_display->lock);
556 tdm_output_get_property(tdm_output *output, unsigned int id, tdm_value *value)
558 tdm_func_display *func_display;
561 TDM_RETURN_VAL_IF_FAIL(value != NULL, TDM_ERROR_INVALID_PARAMETER);
563 pthread_mutex_lock(&private_display->lock);
565 func_display = &private_display->func_display;
567 if (!func_display->output_get_property)
569 pthread_mutex_unlock(&private_display->lock);
570 return TDM_ERROR_NONE;
573 ret = func_display->output_get_property(private_output->output, id, value);
575 pthread_mutex_unlock(&private_display->lock);
581 _tdm_output_cb_vblank(tdm_output *output, unsigned int sequence,
582 unsigned int tv_sec, unsigned int tv_usec, void *user_data)
584 tdm_private_output *private_output = output;
585 tdm_private_vblank_handler *vblank_handler = user_data;
587 TDM_RETURN_IF_FAIL(private_output);
588 TDM_RETURN_IF_FAIL(vblank_handler);
590 if (vblank_handler->func)
591 vblank_handler->func(private_output, sequence, tv_sec, tv_usec, vblank_handler->user_data);
593 LIST_DEL(&vblank_handler->link);
594 free(vblank_handler);
598 _tdm_output_cb_commit(tdm_output *output, unsigned int sequence,
599 unsigned int tv_sec, unsigned int tv_usec, void *user_data)
601 tdm_private_output *private_output = output;
602 tdm_private_commit_handler *commit_handler = user_data;
604 TDM_RETURN_IF_FAIL(private_output);
605 TDM_RETURN_IF_FAIL(commit_handler);
607 if (commit_handler->func)
608 commit_handler->func(private_output, sequence, tv_sec, tv_usec, commit_handler->user_data);
610 LIST_DEL(&commit_handler->link);
611 free(commit_handler);
615 tdm_output_wait_vblank(tdm_output *output, int interval, int sync, tdm_output_vblank_handler func, void *user_data)
617 tdm_func_display *func_display;
618 tdm_private_vblank_handler *vblank_handler;
621 pthread_mutex_lock(&private_display->lock);
623 func_display = &private_display->func_display;
625 if (!func_display->output_wait_vblank)
627 pthread_mutex_unlock(&private_display->lock);
628 return TDM_ERROR_NONE;
631 vblank_handler = calloc(1, sizeof(tdm_private_vblank_handler));
634 TDM_ERR("failed: alloc memory");
635 pthread_mutex_unlock(&private_display->lock);
636 return TDM_ERROR_OUT_OF_MEMORY;
639 LIST_ADD(&vblank_handler->link, &private_output->vblank_handler_list);
640 vblank_handler->func = func;
641 vblank_handler->user_data = user_data;
643 ret = func_display->output_wait_vblank(private_output->output, interval, sync, vblank_handler);
644 if (ret != TDM_ERROR_NONE)
646 pthread_mutex_unlock(&private_display->lock);
650 if (!private_output->regist_vblank_cb)
652 private_output->regist_vblank_cb = 1;
653 ret = func_display->output_set_vblank_handler(private_output->output, _tdm_output_cb_vblank);
656 pthread_mutex_unlock(&private_display->lock);
662 tdm_output_commit(tdm_output *output, int sync, tdm_output_commit_handler func, void *user_data)
664 tdm_func_display *func_display;
665 tdm_private_commit_handler *commit_handler;
668 pthread_mutex_lock(&private_display->lock);
670 func_display = &private_display->func_display;
672 if (!func_display->output_commit)
674 pthread_mutex_unlock(&private_display->lock);
675 return TDM_ERROR_NONE;
678 commit_handler = calloc(1, sizeof(tdm_private_commit_handler));
681 TDM_ERR("failed: alloc memory");
682 pthread_mutex_unlock(&private_display->lock);
683 return TDM_ERROR_OUT_OF_MEMORY;
686 LIST_ADD(&commit_handler->link, &private_output->commit_handler_list);
687 commit_handler->func = func;
688 commit_handler->user_data = user_data;
690 ret = func_display->output_commit(private_output->output, sync, commit_handler);
691 if (ret != TDM_ERROR_NONE)
693 pthread_mutex_unlock(&private_display->lock);
697 if (!private_output->regist_commit_cb)
699 private_output->regist_commit_cb = 1;
700 ret = func_display->output_set_commit_handler(private_output->output, _tdm_output_cb_commit);
703 pthread_mutex_unlock(&private_display->lock);
709 tdm_output_set_mode(tdm_output *output, tdm_output_mode *mode)
711 tdm_func_display *func_display;
714 TDM_RETURN_VAL_IF_FAIL(mode != NULL, TDM_ERROR_INVALID_PARAMETER);
716 pthread_mutex_lock(&private_display->lock);
718 func_display = &private_display->func_display;
720 if (!func_display->output_set_mode)
722 pthread_mutex_unlock(&private_display->lock);
723 return TDM_ERROR_NONE;
726 ret = func_display->output_set_mode(private_output->output, mode);
728 pthread_mutex_unlock(&private_display->lock);
734 tdm_output_get_mode(tdm_output *output, const tdm_output_mode **mode)
736 tdm_func_display *func_display;
739 TDM_RETURN_VAL_IF_FAIL(mode != NULL, TDM_ERROR_INVALID_PARAMETER);
741 pthread_mutex_lock(&private_display->lock);
743 func_display = &private_display->func_display;
745 if (!func_display->output_get_mode)
747 pthread_mutex_unlock(&private_display->lock);
748 return TDM_ERROR_NONE;
751 ret = func_display->output_get_mode(private_output->output, mode);
753 pthread_mutex_unlock(&private_display->lock);
759 tdm_output_set_dpms(tdm_output *output, tdm_output_dpms dpms_value)
761 tdm_func_display *func_display;
764 TDM_RETURN_VAL_IF_FAIL(dpms_value >= TDM_OUTPUT_DPMS_ON, TDM_ERROR_INVALID_PARAMETER);
765 TDM_RETURN_VAL_IF_FAIL(dpms_value < TDM_OUTPUT_DPMS_MAX, TDM_ERROR_INVALID_PARAMETER);
767 pthread_mutex_lock(&private_display->lock);
769 func_display = &private_display->func_display;
771 if (!func_display->output_set_dpms)
773 pthread_mutex_unlock(&private_display->lock);
774 return TDM_ERROR_NONE;
777 ret = func_display->output_set_dpms(private_output->output, dpms_value);
779 pthread_mutex_unlock(&private_display->lock);
785 tdm_output_get_dpms(tdm_output *output, tdm_output_dpms *dpms_value)
787 tdm_func_display *func_display;
790 TDM_RETURN_VAL_IF_FAIL(dpms_value != NULL, TDM_ERROR_INVALID_PARAMETER);
792 pthread_mutex_lock(&private_display->lock);
794 func_display = &private_display->func_display;
796 if (!func_display->output_get_dpms)
798 pthread_mutex_unlock(&private_display->lock);
799 return TDM_ERROR_NONE;
802 ret = func_display->output_get_dpms(private_output->output, dpms_value);
804 pthread_mutex_unlock(&private_display->lock);
810 tdm_output_create_capture(tdm_output *output, tdm_error *error)
812 tdm_capture *capture = NULL;
814 OUTPUT_FUNC_ENTRY_ERROR();
816 pthread_mutex_lock(&private_display->lock);
818 capture = (tdm_capture*)tdm_capture_create_output_internal(private_output, error);
820 pthread_mutex_unlock(&private_display->lock);
826 tdm_layer_get_capabilities(tdm_layer *layer, tdm_layer_capability *capabilities)
830 TDM_RETURN_VAL_IF_FAIL(capabilities != NULL, TDM_ERROR_INVALID_PARAMETER);
832 pthread_mutex_lock(&private_display->lock);
834 *capabilities = private_layer->caps.capabilities;
836 pthread_mutex_unlock(&private_display->lock);
842 tdm_layer_get_available_formats(tdm_layer *layer, const tbm_format **formats, int *count)
846 TDM_RETURN_VAL_IF_FAIL(formats != NULL, TDM_ERROR_INVALID_PARAMETER);
847 TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
849 pthread_mutex_lock(&private_display->lock);
851 *formats = (const tbm_format*)private_layer->caps.formats;
852 *count = private_layer->caps.format_count;
854 pthread_mutex_unlock(&private_display->lock);
860 tdm_layer_get_available_properties(tdm_layer *layer, const tdm_prop **props, int *count)
864 TDM_RETURN_VAL_IF_FAIL(props != NULL, TDM_ERROR_INVALID_PARAMETER);
865 TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
867 pthread_mutex_lock(&private_display->lock);
869 *props = (const tdm_prop*)private_output->caps.props;
870 *count = private_output->caps.prop_count;
872 pthread_mutex_unlock(&private_display->lock);
878 tdm_layer_get_zpos(tdm_layer *layer, unsigned int *zpos)
882 TDM_RETURN_VAL_IF_FAIL(zpos != NULL, TDM_ERROR_INVALID_PARAMETER);
884 pthread_mutex_lock(&private_display->lock);
886 *zpos = private_layer->caps.zpos;
888 pthread_mutex_unlock(&private_display->lock);
894 tdm_layer_set_property(tdm_layer *layer, unsigned int id, tdm_value value)
896 tdm_func_display *func_display;
899 pthread_mutex_lock(&private_display->lock);
901 func_display = &private_display->func_display;
903 if (!func_display->layer_set_property)
905 pthread_mutex_unlock(&private_display->lock);
906 return TDM_ERROR_NONE;
909 ret = func_display->layer_set_property(private_layer->layer, id, value);
911 pthread_mutex_unlock(&private_display->lock);
917 tdm_layer_get_property(tdm_layer *layer, unsigned int id, tdm_value *value)
919 tdm_func_display *func_display;
922 TDM_RETURN_VAL_IF_FAIL(value != NULL, TDM_ERROR_INVALID_PARAMETER);
924 pthread_mutex_lock(&private_display->lock);
926 func_display = &private_display->func_display;
928 if (!func_display->layer_get_property)
930 pthread_mutex_unlock(&private_display->lock);
931 return TDM_ERROR_NONE;
934 ret = func_display->layer_get_property(private_layer->layer, id, value);
936 pthread_mutex_unlock(&private_display->lock);
942 tdm_layer_set_info(tdm_layer *layer, tdm_info_layer *info)
944 tdm_func_display *func_display;
947 TDM_RETURN_VAL_IF_FAIL(info != NULL, TDM_ERROR_INVALID_PARAMETER);
949 pthread_mutex_lock(&private_display->lock);
951 func_display = &private_display->func_display;
953 private_layer->usable = 0;
955 if (!func_display->layer_set_info)
957 pthread_mutex_unlock(&private_display->lock);
958 return TDM_ERROR_NONE;
961 ret = func_display->layer_set_info(private_layer->layer, info);
963 pthread_mutex_unlock(&private_display->lock);
969 tdm_layer_get_info(tdm_layer *layer, tdm_info_layer *info)
971 tdm_func_display *func_display;
974 TDM_RETURN_VAL_IF_FAIL(info != NULL, TDM_ERROR_INVALID_PARAMETER);
976 pthread_mutex_lock(&private_display->lock);
978 func_display = &private_display->func_display;
980 if (!func_display->layer_get_info)
982 pthread_mutex_unlock(&private_display->lock);
983 return TDM_ERROR_NONE;
986 ret = func_display->layer_get_info(private_layer->layer, info);
988 pthread_mutex_unlock(&private_display->lock);
994 tdm_layer_set_buffer(tdm_layer *layer, tdm_buffer *buffer)
996 tdm_func_display *func_display;
999 TDM_RETURN_VAL_IF_FAIL(buffer != NULL, TDM_ERROR_INVALID_PARAMETER);
1001 pthread_mutex_lock(&private_display->lock);
1003 func_display = &private_display->func_display;
1005 private_layer->usable = 0;
1007 if (!func_display->layer_set_buffer)
1009 pthread_mutex_unlock(&private_display->lock);
1010 return TDM_ERROR_NONE;
1014 tdm_buffer_ref_backend(buffer);
1015 ret = func_display->layer_set_buffer(private_layer->layer,
1016 tdm_buffer_get_surface(buffer));
1017 tdm_buffer_unref_backend(buffer);
1019 pthread_mutex_unlock(&private_display->lock);
1025 tdm_layer_unset_buffer(tdm_layer *layer)
1027 tdm_func_display *func_display;
1030 pthread_mutex_lock(&private_display->lock);
1032 func_display = &private_display->func_display;
1034 private_layer->usable = 1;
1036 if (!func_display->layer_unset_buffer)
1038 pthread_mutex_unlock(&private_display->lock);
1039 return TDM_ERROR_NONE;
1042 ret = func_display->layer_unset_buffer(private_layer->layer);
1044 pthread_mutex_unlock(&private_display->lock);
1050 tdm_layer_is_usable(tdm_layer *layer, unsigned int *usable)
1054 TDM_RETURN_VAL_IF_FAIL(usable != NULL, TDM_ERROR_INVALID_PARAMETER);
1056 pthread_mutex_lock(&private_display->lock);
1058 *usable = private_layer->usable;
1060 pthread_mutex_unlock(&private_display->lock);
1067 tdm_layer_create_capture(tdm_layer *layer, tdm_error *error)
1069 tdm_capture *capture = NULL;
1071 LAYER_FUNC_ENTRY_ERROR();
1073 pthread_mutex_lock(&private_display->lock);
1075 capture = (tdm_capture*)tdm_capture_create_layer_internal(private_layer, error);
1077 pthread_mutex_unlock(&private_display->lock);