5 #include <tdm_helper.h>
18 #define ZPOS_VIDEO1 -1 //TODO:
19 #define ZPOS_NONE -999
21 tbm_format hwc_window_video_formats[] = {
27 _comp_to_str(tdm_hwc_window_composition composition_type)
29 if (composition_type == TDM_HWC_WIN_COMPOSITION_CLIENT)
31 else if (composition_type == TDM_HWC_WIN_COMPOSITION_DEVICE)
33 else if (composition_type == TDM_HWC_WIN_COMPOSITION_CURSOR)
35 else if (composition_type == TDM_HWC_WIN_COMPOSITION_VIDEO)
37 else if (composition_type == TDM_HWC_WIN_COMPOSITION_NONE)
44 _vc4_hwc_cursor_buffer_unset(tdm_vc4_hwc_window_data *hwc_window_data)
46 hwc_window_data->surface = NULL;
47 hwc_window_data->cursor_img_surface = 0;
49 hwc_window_data->info.src_config.pos.w = hwc_window_data->cursor_img.width;
50 hwc_window_data->info.src_config.pos.h = hwc_window_data->cursor_img.height;
51 hwc_window_data->info.dst_pos.w = hwc_window_data->cursor_img.width;
52 hwc_window_data->info.dst_pos.h = hwc_window_data->cursor_img.height;
58 _vc4_hwc_cursor_adjust_pos(tdm_vc4_hwc_window_data *hwc_window_data)
62 /* dst pos of cursor is possible set by negative value
63 * this is temporary code.
66 x = hwc_window_data->info.dst_pos.x;
67 y = hwc_window_data->info.dst_pos.y;
69 if (x < 0) hwc_window_data->info.dst_pos.x = 0;
70 if (y < 0) hwc_window_data->info.dst_pos.y = 0;
74 _vc4_hwc_cursor_buffer_set(tdm_vc4_hwc_data *hwc_data, tdm_vc4_hwc_window_data *hwc_window_data)
76 tbm_surface_h cursor_tsurface = NULL;
77 tbm_surface_info_s tsurface_info;
78 tbm_surface_error_e ret = TBM_SURFACE_ERROR_NONE;
79 int img_w, img_h, new_w, new_h;
80 tbm_format new_format;
81 unsigned int flags = TBM_BO_SCANOUT;
82 void *src_ptr = NULL, *dst_ptr = NULL;
86 if (!hwc_window_data->cursor_img_refresh && hwc_window_data->surface)
89 img_w = hwc_window_data->cursor_img.width;
90 img_h = hwc_window_data->cursor_img.height;
91 new_format = hwc_window_data->info.src_config.format;
93 /* cursor restriction to set the cursor layer */
94 new_w = (CURSOR_MIN_W > img_w) ? CURSOR_MIN_W : img_w;
95 new_h = (CURSOR_MIN_H > img_h) ? CURSOR_MIN_H : img_h;
97 if (hwc_data->cursor_tsurface) {
98 tbm_surface_internal_unref(hwc_data->cursor_tsurface);
99 hwc_data->cursor_tsurface = NULL;
102 cursor_tsurface = tbm_surface_internal_create_with_flags(new_w, new_h, new_format, flags);
103 RETURN_VAL_IF_FAIL(cursor_tsurface, 0);
105 hwc_data->cursor_tsurface = cursor_tsurface;
106 ret = tbm_surface_map(hwc_data->cursor_tsurface, TBM_SURF_OPTION_WRITE, &tsurface_info);
107 if (ret != TBM_SURFACE_ERROR_NONE) {
108 TDM_ERR("Failed to map tsurface\n");
109 tbm_surface_internal_unref(hwc_data->cursor_tsurface);
110 hwc_data->cursor_tsurface = NULL;
114 src_ptr = hwc_window_data->cursor_img.ptr;
115 dst_ptr = tsurface_info.planes[0].ptr;
116 src_stride = hwc_window_data->cursor_img.stride;
118 memset(dst_ptr, 0, tsurface_info.planes[0].stride * tsurface_info.height);
120 for (i = 0 ; i < img_h ; i++) {
121 memcpy(dst_ptr, src_ptr, src_stride);
122 dst_ptr += tsurface_info.planes[0].stride;
123 src_ptr += src_stride;
126 tbm_surface_unmap(hwc_data->cursor_tsurface);
128 hwc_window_data->surface = hwc_data->cursor_tsurface;
129 hwc_window_data->cursor_img_surface = 1;
131 /* fix the dst_pos info of the cursor window */
132 hwc_window_data->info.src_config.pos.w = new_w;
133 hwc_window_data->info.src_config.pos.h = new_h;
134 hwc_window_data->info.dst_pos.w = new_w;
135 hwc_window_data->info.dst_pos.h = new_h;
137 _vc4_hwc_cursor_adjust_pos(hwc_window_data);
139 hwc_window_data->cursor_img_refresh = 0;
145 _print_validate_result(tdm_vc4_hwc_data *hwc_data, tdm_hwc_window **composited_wnds, uint32_t num_wnds)
147 tdm_vc4_hwc_window_data *hwc_window_data = NULL;
150 for (i = 0; i < num_wnds; i++) {
151 hwc_window_data = composited_wnds[i];
152 switch (hwc_window_data->validated_type) {
153 case TDM_HWC_WIN_COMPOSITION_CLIENT:
154 TDM_DBG(" window(%p) %s -> %s : lzpos(%d) -- {%s} on TARGET WINDOW", hwc_window_data,
155 _comp_to_str(hwc_window_data->client_type),
156 _comp_to_str(hwc_window_data->validated_type),
157 hwc_data->target_hwc_window->lzpos,
158 hwc_window_data->name ? hwc_window_data->name : "NONE");
160 case TDM_HWC_WIN_COMPOSITION_DEVICE:
161 case TDM_HWC_WIN_COMPOSITION_VIDEO:
162 case TDM_HWC_WIN_COMPOSITION_CURSOR:
163 case TDM_HWC_WIN_COMPOSITION_NONE:
164 TDM_DBG(" window(%p) %s -> %s : lzpos(%d) -- {%s}", hwc_window_data,
165 _comp_to_str(hwc_window_data->client_type),
166 _comp_to_str(hwc_window_data->validated_type),
167 hwc_window_data->lzpos,
168 hwc_window_data->name ? hwc_window_data->name : "NONE");
177 _vc4_hwc_window_can_set_on_hw_layer(tdm_vc4_hwc_window_data *hwc_window_data)
179 if (!hwc_window_data->surface)
182 if (hwc_window_data->info.transform != TDM_TRANSFORM_NORMAL)
185 if (hwc_window_data->info.src_config.pos.w != hwc_window_data->info.dst_pos.w)
188 if (hwc_window_data->info.src_config.pos.h != hwc_window_data->info.dst_pos.h)
191 if (!IS_RGB(hwc_window_data->info.src_config.format))
194 if (hwc_window_data->info.dst_pos.x > hwc_window_data->hwc_data->output_data->current_mode->hdisplay ||
195 hwc_window_data->info.dst_pos.y > hwc_window_data->hwc_data->output_data->current_mode->vdisplay)
198 if (hwc_window_data->info.src_config.pos.w < MIN_WIDTH || hwc_window_data->info.src_config.pos.w % 2)
204 static tbm_surface_queue_h
205 _vc4_hwc_window_get_tbm_buffer_queue(tdm_hwc_window *hwc_window, tdm_error *error)
207 tdm_vc4_hwc_window_data *hwc_window_data = NULL;
208 tbm_surface_queue_h tqueue = NULL;
213 *error = TDM_ERROR_INVALID_PARAMETER;
215 RETURN_VAL_IF_FAIL(hwc_window != NULL, NULL);
217 hwc_window_data = hwc_window;
219 width = hwc_window_data->info.src_config.size.h;
220 height = hwc_window_data->info.src_config.size.v;
221 format = hwc_window_data->info.src_config.format;
223 tqueue = tbm_surface_queue_create(NUM_BUFFERS, width, height, format, TBM_BO_SCANOUT);
225 *error = TDM_ERROR_OPERATION_FAILED;
226 RETURN_VAL_IF_FAIL(tqueue != NULL, NULL);
229 *error = TDM_ERROR_NONE;
235 _vc4_hwc_layer_attach_window(tdm_vc4_layer_data *layer_data, tdm_vc4_hwc_window_data *hwc_window_data)
237 tdm_error ret = TDM_ERROR_NONE;
239 RETURN_VAL_IF_FAIL(layer_data, TDM_ERROR_OPERATION_FAILED);
241 if (hwc_window_data == NULL || hwc_window_data->surface == NULL) {
242 if (layer_data->display_buffer)
243 ret = vc4_layer_unset_buffer(layer_data);
244 RETURN_VAL_IF_FAIL(ret == TDM_ERROR_NONE, ret);
246 ret = vc4_layer_set_info((tdm_layer *)layer_data, (tdm_info_layer *)&(hwc_window_data->info));
247 RETURN_VAL_IF_FAIL(ret == TDM_ERROR_NONE, ret);
248 RETURN_VAL_IF_FAIL(hwc_window_data->surface != NULL, TDM_ERROR_INVALID_PARAMETER);
249 ret = vc4_layer_set_buffer(layer_data, hwc_window_data->surface);
250 RETURN_VAL_IF_FAIL(ret == TDM_ERROR_NONE, ret);
257 _vc4_hwc_prepare_commit(tdm_vc4_hwc_data *hwc_data)
259 tdm_vc4_hwc_window_data *hwc_window_data = NULL;
260 tdm_vc4_layer_data *layer_data = NULL;
261 int use_layers_zpos[NUM_LAYERS] = {0,};
264 /* set target hwc window to the layer */
265 if (hwc_data->need_target_window) {
266 layer_data = vc4_output_data_get_layer_data(hwc_data->output_data, hwc_data->target_hwc_window->lzpos);
267 _vc4_hwc_layer_attach_window(layer_data, hwc_data->target_hwc_window);
268 use_layers_zpos[hwc_data->target_hwc_window->lzpos] = 1;
271 /* set the hwc_windows to the layers */
272 LIST_FOR_EACH_ENTRY_REV(hwc_window_data, &hwc_data->hwc_window_list, link) {
273 if (hwc_window_data->validated_type == TDM_HWC_WIN_COMPOSITION_NONE ||
274 hwc_window_data->validated_type == TDM_HWC_WIN_COMPOSITION_CLIENT) {
276 if (hwc_window_data->cursor_img_surface)
277 _vc4_hwc_cursor_buffer_unset(hwc_window_data);
282 if (hwc_window_data == hwc_data->target_hwc_window)
285 /* set the cursor buffer HERE if it needs */
286 if (hwc_window_data->validated_type == TDM_HWC_WIN_COMPOSITION_CURSOR)
287 _vc4_hwc_cursor_buffer_set(hwc_data, hwc_window_data);
289 layer_data = vc4_output_data_get_layer_data(hwc_data->output_data, hwc_window_data->lzpos);
290 _vc4_hwc_layer_attach_window(layer_data, hwc_window_data);
291 use_layers_zpos[hwc_window_data->lzpos] = 1;
294 /* unset the unused layers */
295 for (lzpos = 0; lzpos < NUM_LAYERS; lzpos++) {
296 if (use_layers_zpos[lzpos])
299 layer_data = vc4_output_data_get_layer_data(hwc_data->output_data, lzpos);
303 _vc4_hwc_layer_attach_window(layer_data, NULL);
307 for (lzpos = NUM_LAYERS -1 ; lzpos >= 0; lzpos--) {
308 if (use_layers_zpos[lzpos])
309 TDM_DBG(" lzpos(%d) : %s", lzpos, use_layers_zpos[lzpos] ? "SET" : "UNSET");
312 return TDM_ERROR_NONE;
315 /* assign the validated_type to the composited_wnds
316 * assign the layer_zpos to the composited_wnds
319 _vc4_hwc_apply_policy(tdm_vc4_hwc_data *hwc_data , tdm_hwc_window **composited_wnds, uint32_t num_wnds)
321 tdm_vc4_hwc_window_data *hwc_window_data = NULL;
322 tdm_vc4_hwc_window_data **composited_list = NULL;
323 int client_count = 0;
324 int device_count = 0;
326 int cursor_count = 0;
328 int ui_lzpos_top = ZPOS_2;
329 int ui_lzpos_bottom = ZPOS_0;
330 int num_ui_layers = NUM_LAYERS;
333 composited_list = (tdm_vc4_hwc_window_data **)composited_wnds;
335 /* initialize the need_target_window */
336 hwc_data->need_target_window = 0;
338 /* initialize the validated_types */
339 LIST_FOR_EACH_ENTRY_REV(hwc_window_data, &hwc_data->hwc_window_list, link) {
340 if (hwc_window_data->validated_type != TDM_HWC_WIN_COMPOSITION_NONE)
341 hwc_window_data->validated_type = TDM_HWC_WIN_COMPOSITION_NONE;
344 /* use the target_window to commit when there is no window. */
346 hwc_data->need_target_window = 1;
350 /* count the composited(visible) windows */
351 for (i = 0; i < num_wnds; i++) {
352 if (composited_list[i]->client_type == TDM_HWC_WIN_COMPOSITION_CURSOR)
354 if (composited_list[i]->client_type == TDM_HWC_WIN_COMPOSITION_CLIENT)
356 if (client_count == 0 && composited_list[i]->client_type == TDM_HWC_WIN_COMPOSITION_DEVICE)
358 if (composited_list[i]->client_type == TDM_HWC_WIN_COMPOSITION_VIDEO)
362 /* apply the cursor layers */
363 if (cursor_count > 1)
364 goto set_clients_below;
366 if (cursor_count == 1) {
367 /* set cursor composition and layer zpos */
368 composited_list[next_idx]->validated_type = TDM_HWC_WIN_COMPOSITION_CURSOR;
369 composited_list[next_idx]->lzpos = ZPOS_CURSOR;
373 /* reset the lzpos_bottom when it needs target_window */
374 if ((client_count > 0) || (client_count + device_count > 2)) {
375 hwc_data->need_target_window = 1;
376 ui_lzpos_bottom = ZPOS_1;
380 /* apply the device layers from the top to the bottom */
381 if ((num_ui_layers - device_count) > 0)
382 ui_lzpos_top = ui_lzpos_bottom + device_count - 1;
384 while (device_count > 0) {
385 /* apply the video layer */
386 if (composited_list[next_idx]->client_type == TDM_HWC_WIN_COMPOSITION_VIDEO) {
387 composited_list[next_idx]->validated_type = TDM_HWC_WIN_COMPOSITION_VIDEO;
388 composited_list[next_idx]->lzpos = ZPOS_VIDEO1;
393 /* set clients below when vc4 can not set the window to the hw layer */
394 if (!_vc4_hwc_window_can_set_on_hw_layer(composited_list[next_idx]))
397 /* set device comopsition and layer zpos */
398 composited_list[next_idx]->validated_type = TDM_HWC_WIN_COMPOSITION_DEVICE;
399 composited_list[next_idx]->lzpos = ui_lzpos_top;
403 if (ui_lzpos_top < ui_lzpos_bottom)
410 /* apply the client layers */
411 while (next_idx < num_wnds) {
412 hwc_data->need_target_window = 1;
413 if (composited_list[next_idx]->client_type == TDM_HWC_WIN_COMPOSITION_VIDEO) {
414 composited_list[next_idx]->validated_type = TDM_HWC_WIN_COMPOSITION_VIDEO;
415 composited_list[next_idx]->lzpos = ZPOS_VIDEO1;
420 /* set client composition */
421 composited_list[next_idx]->validated_type = TDM_HWC_WIN_COMPOSITION_CLIENT;
422 composited_list[next_idx]->lzpos = ZPOS_NONE;
426 if (hwc_data->need_target_window)
427 hwc_data->target_hwc_window->lzpos = ZPOS_0;
431 _vc4_hwc_get_changed_number(tdm_vc4_hwc_data *hwc_data)
434 tdm_vc4_hwc_window_data *hwc_window_data = NULL;
436 LIST_FOR_EACH_ENTRY(hwc_window_data, &hwc_data->hwc_window_list, link) {
437 if (hwc_window_data->client_type == TDM_HWC_WIN_COMPOSITION_NONE)
440 if (hwc_window_data->client_type != hwc_window_data->validated_type)
448 _vc4_hwc_create_window(tdm_hwc *hwc, tdm_hwc_window_info *info, tdm_error *error)
450 tdm_vc4_hwc_data *hwc_data = hwc;
451 tdm_vc4_hwc_window_data *hwc_window_data = NULL;
454 *error = TDM_ERROR_NONE;
457 TDM_ERR("invalid params");
459 *error = TDM_ERROR_INVALID_PARAMETER;
463 hwc_window_data = calloc(1, sizeof(tdm_vc4_hwc_window_data));
464 if (!hwc_window_data) {
465 TDM_ERR("alloc failed");
467 *error = TDM_ERROR_OUT_OF_MEMORY;
471 hwc_window_data->hwc_data = hwc_data;
474 memcpy(&hwc_window_data->info, info, sizeof(tdm_hwc_window_info));
476 LIST_INITHEAD(&hwc_window_data->link);
478 return hwc_window_data;
482 vc4_hwc_create_window(tdm_hwc *hwc, tdm_error *error)
484 tdm_vc4_hwc_data *hwc_data = hwc;
485 tdm_vc4_hwc_window_data *hwc_window_data = NULL;
487 RETURN_VAL_IF_FAIL(hwc_data, NULL);
489 hwc_window_data = _vc4_hwc_create_window(hwc_data, NULL, error);
490 RETURN_VAL_IF_FAIL(hwc_window_data, NULL);
492 LIST_ADDTAIL(&hwc_window_data->link, &hwc_data->hwc_window_list);
494 TDM_DBG("hwc_window(%p) create", hwc_window_data);
496 *error = TDM_ERROR_NONE;
498 return hwc_window_data;
502 vc4_hwc_get_video_supported_formats(tdm_hwc *hwc, const tbm_format **formats, int *count)
504 RETURN_VAL_IF_FAIL(hwc != NULL, TDM_ERROR_INVALID_PARAMETER);
505 RETURN_VAL_IF_FAIL(formats != NULL, TDM_ERROR_INVALID_PARAMETER);
506 RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
508 // TODO: fix these formats.
509 *formats = hwc_window_video_formats;
510 *count = sizeof(hwc_window_video_formats) / sizeof(tbm_format);
512 return TDM_ERROR_NONE;
516 vc4_hwc_get_capabilities(tdm_hwc *hwc, tdm_hwc_capability *capabilities)
518 RETURN_VAL_IF_FAIL(hwc != NULL, TDM_ERROR_INVALID_PARAMETER);
519 RETURN_VAL_IF_FAIL(capabilities != NULL, TDM_ERROR_INVALID_PARAMETER);
521 *capabilities |= TDM_HWC_CAPABILITY_VIDEO_SCALE;
523 return TDM_ERROR_NONE;
527 vc4_hwc_get_available_properties(tdm_hwc *hwc, const tdm_prop **props, int *count)
529 tdm_vc4_hwc_data *hwc_data = hwc;
531 RETURN_VAL_IF_FAIL(hwc_data != NULL, TDM_ERROR_INVALID_PARAMETER);
532 RETURN_VAL_IF_FAIL(props != NULL, TDM_ERROR_INVALID_PARAMETER);
533 RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
538 return TDM_ERROR_NONE;
542 vc4_hwc_get_client_target_buffer_queue(tdm_hwc *hwc, tdm_error *error)
544 tdm_vc4_hwc_data *hwc_data = hwc;
545 tbm_surface_queue_h tqueue = NULL;
548 *error = TDM_ERROR_INVALID_PARAMETER;
550 RETURN_VAL_IF_FAIL(hwc_data != NULL, NULL);
552 if (hwc_data->target_hwc_window == NULL) {
554 *error = TDM_ERROR_OPERATION_FAILED;
558 tqueue = _vc4_hwc_window_get_tbm_buffer_queue(hwc_data->target_hwc_window, error);
559 RETURN_VAL_IF_FAIL(tqueue, NULL);
562 *error = TDM_ERROR_NONE;
568 vc4_hwc_set_client_target_buffer(tdm_hwc *hwc, tbm_surface_h buffer, tdm_region damage)
570 tdm_vc4_hwc_data *hwc_data = hwc;
573 RETURN_VAL_IF_FAIL(hwc_data != NULL, TDM_ERROR_INVALID_PARAMETER);
574 RETURN_VAL_IF_FAIL(hwc_data->target_hwc_window != NULL, TDM_ERROR_OPERATION_FAILED);
576 err = vc4_hwc_window_set_buffer(hwc_data->target_hwc_window, buffer);
577 RETURN_VAL_IF_FAIL(err == TDM_ERROR_NONE, err);
579 err = vc4_hwc_window_set_buffer_damage(hwc_data->target_hwc_window, damage);
580 RETURN_VAL_IF_FAIL(err == TDM_ERROR_NONE, err);
582 return TDM_ERROR_NONE;
586 vc4_hwc_validate(tdm_hwc *hwc, tdm_hwc_window **composited_wnds, uint32_t num_wnds, uint32_t *num_types)
588 tdm_vc4_hwc_data *hwc_data = hwc;
590 RETURN_VAL_IF_FAIL(hwc_data != NULL, TDM_ERROR_INVALID_PARAMETER);
591 RETURN_VAL_IF_FAIL(num_types != NULL, TDM_ERROR_INVALID_PARAMETER);
593 TDM_INFO(" ==============Validate=================================");
595 _vc4_hwc_apply_policy(hwc_data, composited_wnds, num_wnds);
597 *num_types = _vc4_hwc_get_changed_number(hwc_data);
599 _print_validate_result(hwc_data, composited_wnds, num_wnds);
601 return TDM_ERROR_NONE;
605 vc4_hwc_get_changed_composition_types(tdm_hwc *hwc, uint32_t *num_elements,
606 tdm_hwc_window **hwc_wnds, tdm_hwc_window_composition *composition_types)
608 tdm_vc4_hwc_data *hwc_data = hwc;
609 tdm_vc4_hwc_window_data *hwc_window_data = NULL;
612 RETURN_VAL_IF_FAIL(hwc_data != NULL, TDM_ERROR_INVALID_PARAMETER);
613 RETURN_VAL_IF_FAIL(num_elements != NULL, TDM_ERROR_INVALID_PARAMETER);
615 if ((hwc_wnds == NULL) || (composition_types == NULL)) {
616 *num_elements = _vc4_hwc_get_changed_number(hwc_data);
617 return TDM_ERROR_NONE;
620 LIST_FOR_EACH_ENTRY_REV(hwc_window_data, &hwc_data->hwc_window_list, link) {
621 if (hwc_window_data->client_type == TDM_HWC_WIN_COMPOSITION_NONE)
624 if (num >= *num_elements)
627 if (hwc_window_data->client_type != hwc_window_data->validated_type) {
628 composition_types[num] = hwc_window_data->validated_type;
629 hwc_wnds[num] = hwc_window_data;
634 /* set real num of changed composition types */
637 return TDM_ERROR_NONE;
641 vc4_hwc_accept_validation(tdm_hwc *hwc)
643 tdm_vc4_hwc_data *hwc_data = hwc;
644 tdm_error ret = TDM_ERROR_NONE;
646 RETURN_VAL_IF_FAIL(hwc_data != NULL, TDM_ERROR_INVALID_PARAMETER);
647 RETURN_VAL_IF_FAIL(hwc_data->output_data != NULL, TDM_ERROR_INVALID_PARAMETER);
649 TDM_DBG(" ==============Accept Changes Done=================================");
651 ret = _vc4_hwc_prepare_commit(hwc_data);
652 RETURN_VAL_IF_FAIL(ret == TDM_ERROR_NONE, ret);
654 return TDM_ERROR_NONE;
658 vc4_hwc_commit(tdm_hwc *hwc, int sync, void *user_data)
660 tdm_vc4_hwc_data *hwc_data = hwc;
661 tdm_vc4_output_data *output_data = NULL;
664 RETURN_VAL_IF_FAIL(hwc_data, TDM_ERROR_INVALID_PARAMETER);
666 output_data = hwc_data->output_data;
667 RETURN_VAL_IF_FAIL(output_data, TDM_ERROR_INVALID_PARAMETER);
669 TDM_INFO(" ==============COMMIT=================================");
671 ret = vc4_output_commit(output_data, sync, user_data);
672 RETURN_VAL_IF_FAIL(ret == TDM_ERROR_NONE, ret);
674 return TDM_ERROR_NONE;
678 vc4_hwc_set_commit_handler(tdm_hwc *hwc, tdm_hwc_commit_handler func)
680 tdm_vc4_hwc_data *hwc_data = hwc;
682 RETURN_VAL_IF_FAIL(hwc_data, TDM_ERROR_INVALID_PARAMETER);
683 RETURN_VAL_IF_FAIL(func, TDM_ERROR_INVALID_PARAMETER);
685 hwc_data->commit_func = func;
687 return TDM_ERROR_NONE;
691 vc4_hwc_initailize_target_window(tdm_vc4_hwc_data *hwc_data, int width, int height)
693 tdm_hwc_window_info info = {0};
694 tdm_error ret = TDM_ERROR_NONE;
695 tdm_vc4_hwc_window_data *target_hwc_window;
697 RETURN_VAL_IF_FAIL(hwc_data, TDM_ERROR_INVALID_PARAMETER);
701 info.dst_pos.h = height;
702 info.dst_pos.w = width;
704 info.src_config.pos.x = 0;
705 info.src_config.pos.y = 0;
706 info.src_config.pos.h = height;
707 info.src_config.pos.w = width;
709 info.src_config.size.h = width;
710 info.src_config.size.v = height;
711 info.src_config.format = TBM_FORMAT_ARGB8888;
713 target_hwc_window = _vc4_hwc_create_window(hwc_data, &info, &ret);
714 if (ret != TDM_ERROR_NONE) {
715 TDM_ERR("create target hwc window failed (%d)", ret);
716 return TDM_ERROR_OPERATION_FAILED;
719 if (hwc_data->target_hwc_window)
720 vc4_hwc_window_destroy(hwc_data->target_hwc_window);
722 hwc_data->target_hwc_window = target_hwc_window;
723 hwc_data->need_set_crtc = 1;
725 return TDM_ERROR_NONE;