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"
44 #define PP_FUNC_ENTRY() \
45 tdm_func_pp *func_pp; \
46 tdm_private_display *private_display; \
47 tdm_private_pp *private_pp; \
48 tdm_error ret = TDM_ERROR_NONE; \
49 TDM_RETURN_VAL_IF_FAIL(pp != NULL, TDM_ERROR_INVALID_PARAMETER); \
50 private_pp = (tdm_private_pp*)pp; \
51 private_display = private_pp->private_display; \
52 func_pp = private_pp->func_pp
55 _tdm_pp_cb_done(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst, void *user_data)
57 tdm_buffer_unref_backend(tdm_buffer_get(src));
58 tdm_buffer_unref_backend(tdm_buffer_get(dst));
61 INTERN tdm_private_pp*
62 tdm_pp_create_internal(tdm_private_display *private_display, tdm_error *error)
64 tdm_func_display *func_display;
66 tdm_private_pp *private_pp = NULL;
68 tdm_error ret = TDM_ERROR_NONE;
70 func_display = &private_display->func_display;
71 func_pp = &private_display->func_pp;
73 if (!(private_display->capabilities & TDM_DISPLAY_CAPABILITY_PP))
75 TDM_ERR("no pp capability");
77 *error = TDM_ERROR_BAD_REQUEST;
81 pp = func_display->display_create_pp(private_display->bdata, &ret);
82 if (ret != TDM_ERROR_NONE)
89 private_pp = calloc(1, sizeof(tdm_private_pp));
92 TDM_ERR("failed: alloc memory");
93 func_pp->pp_destroy(pp);
95 *error = TDM_ERROR_OUT_OF_MEMORY;
99 ret = func_pp->pp_set_done_handler(pp, _tdm_pp_cb_done, private_pp);
100 if (ret != TDM_ERROR_NONE)
102 TDM_ERR("set pp_done_handler failed");
103 func_pp->pp_destroy(pp);
109 LIST_ADD(&private_pp->link, &private_display->pp_list);
110 private_pp->func_pp = func_pp;
111 private_pp->private_display = private_display;
115 *error = TDM_ERROR_NONE;
121 tdm_pp_destroy_internal(tdm_private_pp *private_pp)
123 tdm_func_pp *func_pp;
128 func_pp = private_pp->func_pp;
130 LIST_DEL(&private_pp->link);
132 func_pp->pp_destroy(private_pp->pp);
138 tdm_pp_destroy(tdm_pp *pp)
140 tdm_private_display *private_display;
141 tdm_private_pp *private_pp;
146 private_pp = (tdm_private_pp*)pp;
147 private_display = private_pp->private_display;
149 pthread_mutex_lock(&private_display->lock);
150 tdm_pp_destroy_internal(private_pp);
151 pthread_mutex_unlock(&private_display->lock);
155 tdm_pp_set_info(tdm_pp *pp, tdm_info_pp *info)
159 TDM_RETURN_VAL_IF_FAIL(info != NULL, TDM_ERROR_INVALID_PARAMETER);
161 pthread_mutex_lock(&private_display->lock);
163 if (!func_pp->pp_set_info)
165 pthread_mutex_unlock(&private_display->lock);
166 return TDM_ERROR_NONE;
169 ret = func_pp->pp_set_info(private_pp->pp, info);
171 pthread_mutex_unlock(&private_display->lock);
177 tdm_pp_attach(tdm_pp *pp, tdm_buffer *src, tdm_buffer *dst)
181 TDM_RETURN_VAL_IF_FAIL(src != NULL, TDM_ERROR_INVALID_PARAMETER);
182 TDM_RETURN_VAL_IF_FAIL(dst != NULL, TDM_ERROR_INVALID_PARAMETER);
184 pthread_mutex_lock(&private_display->lock);
186 if (!func_pp->pp_attach)
188 pthread_mutex_unlock(&private_display->lock);
189 return TDM_ERROR_NONE;
192 tdm_buffer_ref_backend(src);
193 tdm_buffer_ref_backend(dst);
194 ret = func_pp->pp_attach(private_pp->pp,
195 tdm_buffer_get_surface(src),
196 tdm_buffer_get_surface(dst));
198 pthread_mutex_unlock(&private_display->lock);
204 tdm_pp_commit(tdm_pp *pp)
208 pthread_mutex_lock(&private_display->lock);
210 if (!func_pp->pp_commit)
212 pthread_mutex_unlock(&private_display->lock);
213 return TDM_ERROR_NONE;
216 ret = func_pp->pp_commit(private_pp->pp);
218 pthread_mutex_unlock(&private_display->lock);