6 #include "tdm_nexell.h"
9 nexell_hwc_window_acquire_buffer_queue(tdm_hwc_window *hwc_window, tdm_error *error)
11 tdm_nexell_hwc_data *hwc_data = NULL;
12 tdm_nexell_hwc_window_data *hwc_window_data = NULL;
13 tbm_surface_queue_h tqueue = NULL;
16 *error = TDM_ERROR_INVALID_PARAMETER;
18 hwc_window_data = (tdm_nexell_hwc_window_data *)hwc_window;
19 RETURN_VAL_IF_FAIL(hwc_window_data != NULL, NULL);
21 hwc_data = hwc_window_data->hwc_data;
22 RETURN_VAL_IF_FAIL(hwc_data != NULL, NULL);
25 *error = TDM_ERROR_NONE;
27 if (hwc_data->ui_buffer_queue[hwc_window_data->lzpos_queue].tqueue) {
28 /* reference the ui_buffer queue */
29 tqueue = hwc_data->ui_buffer_queue[hwc_window_data->lzpos_queue].tqueue;
30 hwc_data->ui_buffer_queue[hwc_window_data->lzpos_queue].ref_cnt++;
31 TDM_ERR(" Acquire BUFFER_QUEUE[reference]: lzpos_queue:%d tqueue:%p ref_cnt:%d",
32 hwc_window_data->lzpos_queue,
33 hwc_data->ui_buffer_queue[hwc_window_data->lzpos_queue].tqueue,
34 hwc_data->ui_buffer_queue[hwc_window_data->lzpos_queue].ref_cnt);
36 /* create a ui_buffer_queue */
37 tqueue = tdm_nexell_hwc_window_create_tbm_buffer_queue(hwc_window_data, error);
38 RETURN_VAL_IF_FAIL(tqueue != NULL, NULL);
40 hwc_data->ui_buffer_queue[hwc_window_data->lzpos_queue].tqueue = tqueue;
41 hwc_data->ui_buffer_queue[hwc_window_data->lzpos_queue].ref_cnt = 1;
42 TDM_ERR(" Acquire BUFFER_QUEUE[create]: lzpos_queue:%d tqueue:%p ref_cnt:%d",
43 hwc_window_data->lzpos_queue,
44 hwc_data->ui_buffer_queue[hwc_window_data->lzpos_queue].tqueue,
45 hwc_data->ui_buffer_queue[hwc_window_data->lzpos_queue].ref_cnt);
52 nexell_hwc_window_release_buffer_queue(tdm_hwc_window *hwc_window, tbm_surface_queue_h queue)
54 tdm_nexell_hwc_data *hwc_data = NULL;
55 tdm_nexell_hwc_window_data *hwc_window_data = NULL;
57 hwc_window_data = (tdm_nexell_hwc_window_data *)hwc_window;
58 RETURN_IF_FAIL(hwc_window_data != NULL);
60 hwc_data = hwc_window_data->hwc_data;
61 RETURN_IF_FAIL(hwc_data != NULL);
63 if (hwc_data->ui_buffer_queue[hwc_window_data->lzpos_queue].ref_cnt > 0) {
64 hwc_data->ui_buffer_queue[hwc_window_data->lzpos_queue].ref_cnt--;
66 TDM_ERR(" Release BUFFER_QUEUE[dereference]: lzpos_queue:%d tqueue:%p ref_cnt:%d",
67 hwc_window_data->lzpos_queue,
68 hwc_data->ui_buffer_queue[hwc_window_data->lzpos_queue].tqueue,
69 hwc_data->ui_buffer_queue[hwc_window_data->lzpos_queue].ref_cnt);
71 /* destroy a ui_buffer_queue when ref_cnt is 0 */
72 if (hwc_data->ui_buffer_queue[hwc_window_data->lzpos_queue].ref_cnt == 0) {
73 TDM_ERR(" Release BUFFER_QUEUE", "destroy buffer_queue(%p)", hwc_data->ui_buffer_queue[hwc_window_data->lzpos_queue].tqueue);
75 tdm_nexell_hwc_window_destroy_tbm_buffer_queue(hwc_data->ui_buffer_queue[hwc_window_data->lzpos_queue].tqueue);
76 hwc_data->ui_buffer_queue[hwc_window_data->lzpos_queue].tqueue = NULL;
82 nexell_hwc_window_destroy(tdm_hwc_window *hwc_window)
84 tdm_nexell_hwc_window_data *hwc_window_data = hwc_window;
86 RETURN_IF_FAIL(hwc_window_data != NULL);
88 LIST_DEL(&hwc_window_data->link);
90 free(hwc_window_data);
94 nexell_hwc_window_set_composition_type(tdm_hwc_window *hwc_window,
95 tdm_hwc_window_composition comp_type)
97 tdm_nexell_hwc_window_data *hwc_window_data = hwc_window;
98 tdm_nexell_hwc_data *hwc_data = hwc_window_data->hwc_data;
100 RETURN_VAL_IF_FAIL(hwc_window_data != NULL, TDM_ERROR_INVALID_PARAMETER);
101 RETURN_VAL_IF_FAIL(hwc_data != NULL, TDM_ERROR_INVALID_PARAMETER);
103 /* change the client_type when it is different from one which has before */
104 if (hwc_window_data->client_type == comp_type)
105 return TDM_ERROR_NONE;
107 hwc_window_data->client_type = comp_type;
109 return TDM_ERROR_NONE;
113 nexell_hwc_window_set_buffer_damage(tdm_hwc_window *hwc_window, tdm_region damage)
115 tdm_nexell_hwc_window_data *hwc_window_data = hwc_window;
117 RETURN_VAL_IF_FAIL(hwc_window_data != NULL, TDM_ERROR_INVALID_PARAMETER);
121 return TDM_ERROR_NONE;
125 nexell_hwc_window_set_info(tdm_hwc_window *hwc_window, tdm_hwc_window_info *info)
127 tdm_nexell_hwc_window_data *hwc_window_data = hwc_window;
128 tdm_nexell_hwc_data *hwc_data;
130 RETURN_VAL_IF_FAIL(hwc_window_data != NULL, TDM_ERROR_INVALID_PARAMETER);
131 hwc_data = hwc_window_data->hwc_data;
132 RETURN_VAL_IF_FAIL(hwc_data != NULL, TDM_ERROR_INVALID_PARAMETER);
133 RETURN_VAL_IF_FAIL(info != NULL, TDM_ERROR_INVALID_PARAMETER);
135 if (!memcmp(&hwc_window_data->info, info, sizeof(tdm_hwc_window_info)))
136 return TDM_ERROR_NONE;
138 hwc_window_data->info = *info;
140 return TDM_ERROR_NONE;
144 nexell_hwc_window_set_buffer(tdm_hwc_window *hwc_window, tbm_surface_h surface)
146 tdm_nexell_hwc_window_data *hwc_window_data = hwc_window;
147 tdm_error err = TDM_ERROR_OPERATION_FAILED;
149 RETURN_VAL_IF_FAIL(hwc_window_data != NULL, err);
151 if (hwc_window_data->surface == surface)
152 return TDM_ERROR_NONE;
154 hwc_window_data->surface = surface;
156 return TDM_ERROR_NONE;
160 nexell_hwc_window_set_property(tdm_hwc_window *hwc_window, unsigned int id, tdm_value value)
162 tdm_nexell_hwc_window_data *hwc_window_data = hwc_window;
164 RETURN_VAL_IF_FAIL(hwc_window_data != NULL, TDM_ERROR_INVALID_PARAMETER);
168 return TDM_ERROR_NONE;
172 nexell_hwc_window_get_property(tdm_hwc_window *hwc_window, unsigned int id, tdm_value *value)
174 tdm_nexell_hwc_window_data *hwc_window_data = hwc_window;
176 RETURN_VAL_IF_FAIL(hwc_window_data != NULL, TDM_ERROR_INVALID_PARAMETER);
180 return TDM_ERROR_NONE;
184 nexell_hwc_window_get_constraints(tdm_hwc_window *hwc_window, int *constraints)
186 tdm_nexell_hwc_window_data *hwc_window_data = hwc_window;
188 RETURN_VAL_IF_FAIL(hwc_window_data != NULL, TDM_ERROR_INVALID_PARAMETER);
189 RETURN_VAL_IF_FAIL(constraints != NULL, TDM_ERROR_INVALID_PARAMETER);
191 *constraints = hwc_window_data->constraints;
193 return TDM_ERROR_NONE;
197 nexell_hwc_window_set_name(tdm_hwc_window *hwc_window, const char *name)
199 tdm_nexell_hwc_window_data *hwc_window_data = hwc_window;
201 RETURN_VAL_IF_FAIL(hwc_window_data != NULL, TDM_ERROR_INVALID_PARAMETER);
204 return TDM_ERROR_NONE;
206 snprintf(hwc_window_data->name, TDM_NAME_LEN, "%s", name);
208 return TDM_ERROR_NONE;
212 nexell_hwc_window_set_cursor_image(tdm_hwc_window *hwc_window, int width, int height, int stride, void *ptr)
214 tdm_nexell_hwc_window_data *hwc_window_data = hwc_window;
216 RETURN_VAL_IF_FAIL(hwc_window_data != NULL, TDM_ERROR_INVALID_PARAMETER);
217 RETURN_VAL_IF_FAIL(hwc_window_data->client_type == TDM_HWC_WIN_COMPOSITION_CURSOR, TDM_ERROR_INVALID_PARAMETER);
219 hwc_window_data->cursor_img.width = width;
220 hwc_window_data->cursor_img.height = height;
221 hwc_window_data->cursor_img.stride = stride;
222 hwc_window_data->cursor_img.ptr = ptr;
224 hwc_window_data->cursor_img_refresh = 1;
226 return TDM_ERROR_NONE;