diff options
author | Changyeon Lee <cyeon.lee@samsung.com> | 2024-07-23 19:35:41 +0900 |
---|---|---|
committer | Changyeon Lee <cyeon.lee@samsung.com> | 2024-07-24 15:12:17 +0900 |
commit | ae0f1139a3b621c5f852a770ec143977805a0c33 (patch) | |
tree | 5946582907fd587fffda07e130c4fb29a861d539 | |
parent | 37b5988e90d775a7a821cce4fc8eb9edefb20108 (diff) | |
download | libtdm-drm-ae0f1139a3b621c5f852a770ec143977805a0c33.tar.gz libtdm-drm-ae0f1139a3b621c5f852a770ec143977805a0c33.tar.bz2 libtdm-drm-ae0f1139a3b621c5f852a770ec143977805a0c33.zip |
Do not allocate backend data
backend data is allocated in hal-api
Change-Id: I0a7802f275cab79d213a3f59cd91f2985252e0ef
-rw-r--r-- | src/tdm_backend_drm.c | 178 |
1 files changed, 58 insertions, 120 deletions
diff --git a/src/tdm_backend_drm.c b/src/tdm_backend_drm.c index 280937f..4652b5d 100644 --- a/src/tdm_backend_drm.c +++ b/src/tdm_backend_drm.c @@ -397,23 +397,6 @@ hal_backend_tdm_drm_exit(void *data) display_data = (tdm_drm_display *)backend_data->display; TDM_BACKEND_RETURN_VAL_IF_FAIL(display_data != NULL, -1); - if (backend_data->hwc_window_funcs) { - free(backend_data->hwc_window_funcs); - backend_data->hwc_window_funcs = NULL; - } - if (backend_data->hwc_funcs) { - free(backend_data->hwc_funcs); - backend_data->hwc_funcs = NULL; - } - if (backend_data->output_funcs) { - free(backend_data->output_funcs); - backend_data->output_funcs = NULL; - } - if (backend_data->display_funcs) { - free(backend_data->display_funcs); - backend_data->display_funcs = NULL; - } - _tdm_drm_display_deinitialize(display_data); #ifdef HAVE_UDEV @@ -424,10 +407,8 @@ hal_backend_tdm_drm_exit(void *data) if (display_data->drm_fd >= 0) close(display_data->drm_fd); - free(display_data); - display_data = NULL; - - free(backend_data); + free(backend_data->display); + backend_data->display = NULL; return HAL_TDM_ERROR_NONE; } @@ -436,11 +417,6 @@ static int hal_backend_tdm_drm_init(void **data) { hal_tdm_backend_data *backend_data = NULL; - hal_tdm_display_funcs *display_funcs = NULL; - hal_tdm_output_funcs *output_funcs = NULL; - hal_tdm_hwc_funcs *hwc_funcs = NULL; - hal_tdm_hwc_window_funcs *hwc_window_funcs = NULL; - hal_tdm_pp_funcs *pp_funcs = NULL; tdm_drm_display *display_data = NULL; hal_tdm_error ret; int drm_fd; @@ -449,14 +425,16 @@ hal_backend_tdm_drm_init(void **data) hal_tdm_event_source *udev_event_source; #endif - /* allocate a hal_tdm_backend_data */ - backend_data = calloc(1, sizeof(struct _hal_tdm_backend_data)); + if (!data) { + TDM_BACKEND_ERR("data is NULL"); + return -1; + } + + backend_data = *(hal_tdm_backend_data **)data; if (!backend_data) { - TDM_BACKEND_ERR("fail to alloc backend_data!\n"); - *data = NULL; + TDM_BACKEND_ERR("backend_data is NULL"); return -1; } - *data = backend_data; /* allocate a hal_tdm_display */ display_data = calloc(1, sizeof(struct _tdm_drm_display)); @@ -527,99 +505,59 @@ hal_backend_tdm_drm_init(void **data) backend_data->num_event_sources++; #endif - /* alloc and register display_funcs */ - display_funcs = calloc(1, sizeof(struct _hal_tdm_display_funcs)); - if (!display_funcs) { - TDM_BACKEND_ERR("fail to alloc display_funcs!\n"); - goto failed; - } - backend_data->display_funcs = display_funcs; - - display_funcs->display_get_capability = drm_display_get_capability; - display_funcs->display_get_pp_capability = drm_display_get_pp_capability; - display_funcs->display_get_outputs = drm_display_get_outputs; - display_funcs->display_get_fd = drm_display_get_fd; - display_funcs->display_handle_events = drm_display_handle_events; - display_funcs->display_create_pp = drm_display_create_pp; - - /* alloc and register output_funcs */ - output_funcs = calloc(1, sizeof(struct _hal_tdm_output_funcs)); - if (!output_funcs) { - TDM_BACKEND_ERR("fail to alloc output_funcs!\n"); - goto failed; - } - backend_data->output_funcs = output_funcs; - - output_funcs->output_get_capability = drm_output_get_capability; - output_funcs->output_set_property = drm_output_set_property; - output_funcs->output_get_property = drm_output_get_property; - output_funcs->output_wait_vblank = drm_output_wait_vblank; - output_funcs->output_set_vblank_handler = drm_output_set_vblank_handler; - output_funcs->output_set_dpms = drm_output_set_dpms; - output_funcs->output_get_dpms = drm_output_get_dpms; - output_funcs->output_set_mode = drm_output_set_mode; - output_funcs->output_get_mode = drm_output_get_mode; + backend_data->display_funcs->display_get_capability = drm_display_get_capability; + backend_data->display_funcs->display_get_pp_capability = drm_display_get_pp_capability; + backend_data->display_funcs->display_get_outputs = drm_display_get_outputs; + backend_data->display_funcs->display_get_fd = drm_display_get_fd; + backend_data->display_funcs->display_handle_events = drm_display_handle_events; + backend_data->display_funcs->display_create_pp = drm_display_create_pp; + + backend_data->output_funcs->output_get_capability = drm_output_get_capability; + backend_data->output_funcs->output_set_property = drm_output_set_property; + backend_data->output_funcs->output_get_property = drm_output_get_property; + backend_data->output_funcs->output_wait_vblank = drm_output_wait_vblank; + backend_data->output_funcs->output_set_vblank_handler = drm_output_set_vblank_handler; + backend_data->output_funcs->output_set_dpms = drm_output_set_dpms; + backend_data->output_funcs->output_get_dpms = drm_output_get_dpms; + backend_data->output_funcs->output_set_mode = drm_output_set_mode; + backend_data->output_funcs->output_get_mode = drm_output_get_mode; #ifdef HAVE_UDEV - output_funcs->output_set_status_handler = drm_output_set_status_handler; + backend_data->output_funcs->output_set_status_handler = drm_output_set_status_handler; #endif - output_funcs->output_get_hwc = drm_output_get_hwc; - - /* alloc and register hwc_funcs */ - hwc_funcs = calloc(1, sizeof(struct _hal_tdm_hwc_funcs)); - if (!hwc_funcs) { - TDM_BACKEND_ERR("fail to alloc hwc_funcs!\n"); - goto failed; - } - backend_data->hwc_funcs = hwc_funcs; - - hwc_funcs->hwc_create_window = drm_hwc_create_window; - hwc_funcs->hwc_get_video_supported_formats = drm_hwc_get_video_supported_formats; - hwc_funcs->hwc_get_video_available_properties = NULL; - hwc_funcs->hwc_get_capabilities = drm_hwc_get_capabilities; - hwc_funcs->hwc_get_available_properties = drm_hwc_get_available_properties; - hwc_funcs->hwc_get_client_target_buffer_queue = drm_hwc_get_client_target_buffer_queue; - hwc_funcs->hwc_set_client_target_buffer = drm_hwc_set_client_target_buffer; - hwc_funcs->hwc_validate = drm_hwc_validate; - hwc_funcs->hwc_get_changed_composition_types = drm_hwc_get_changed_composition_types; - hwc_funcs->hwc_accept_validation = drm_hwc_accept_validation; - hwc_funcs->hwc_commit = drm_hwc_commit; - hwc_funcs->hwc_set_commit_handler = drm_hwc_set_commit_handler; - - /* alloc and register hwc_window_funcs */ - hwc_window_funcs = calloc(1, sizeof(struct _hal_tdm_hwc_window_funcs)); - if (!hwc_window_funcs) { - TDM_BACKEND_ERR("fail to alloc hwc_window_funcs!\n"); - goto failed; - } - backend_data->hwc_window_funcs = hwc_window_funcs; - - hwc_window_funcs->hwc_window_destroy = drm_hwc_window_destroy; - hwc_window_funcs->hwc_window_acquire_buffer_queue = NULL; // no need - hwc_window_funcs->hwc_window_release_buffer_queue = NULL; // no need - hwc_window_funcs->hwc_window_set_composition_type = drm_hwc_window_set_composition_type; - hwc_window_funcs->hwc_window_set_buffer_damage = drm_hwc_window_set_buffer_damage; - hwc_window_funcs->hwc_window_set_info = drm_hwc_window_set_info; - hwc_window_funcs->hwc_window_set_buffer = drm_hwc_window_set_buffer; - hwc_window_funcs->hwc_window_set_property = drm_hwc_window_set_property; - hwc_window_funcs->hwc_window_get_property = drm_hwc_window_get_property; - hwc_window_funcs->hwc_window_get_constraints = drm_hwc_window_get_constraints; - hwc_window_funcs->hwc_window_set_name = drm_hwc_window_set_name; - hwc_window_funcs->hwc_window_set_cursor_image = drm_hwc_window_set_cursor_image; + backend_data->output_funcs->output_get_hwc = drm_output_get_hwc; + + backend_data->hwc_funcs->hwc_create_window = drm_hwc_create_window; + backend_data->hwc_funcs->hwc_get_video_supported_formats = drm_hwc_get_video_supported_formats; + backend_data->hwc_funcs->hwc_get_video_available_properties = NULL; + backend_data->hwc_funcs->hwc_get_capabilities = drm_hwc_get_capabilities; + backend_data->hwc_funcs->hwc_get_available_properties = drm_hwc_get_available_properties; + backend_data->hwc_funcs->hwc_get_client_target_buffer_queue = drm_hwc_get_client_target_buffer_queue; + backend_data->hwc_funcs->hwc_set_client_target_buffer = drm_hwc_set_client_target_buffer; + backend_data->hwc_funcs->hwc_validate = drm_hwc_validate; + backend_data->hwc_funcs->hwc_get_changed_composition_types = drm_hwc_get_changed_composition_types; + backend_data->hwc_funcs->hwc_accept_validation = drm_hwc_accept_validation; + backend_data->hwc_funcs->hwc_commit = drm_hwc_commit; + backend_data->hwc_funcs->hwc_set_commit_handler = drm_hwc_set_commit_handler; + + backend_data->hwc_window_funcs->hwc_window_destroy = drm_hwc_window_destroy; + backend_data->hwc_window_funcs->hwc_window_acquire_buffer_queue = NULL; // no need + backend_data->hwc_window_funcs->hwc_window_release_buffer_queue = NULL; // no need + backend_data->hwc_window_funcs->hwc_window_set_composition_type = drm_hwc_window_set_composition_type; + backend_data->hwc_window_funcs->hwc_window_set_buffer_damage = drm_hwc_window_set_buffer_damage; + backend_data->hwc_window_funcs->hwc_window_set_info = drm_hwc_window_set_info; + backend_data->hwc_window_funcs->hwc_window_set_buffer = drm_hwc_window_set_buffer; + backend_data->hwc_window_funcs->hwc_window_set_property = drm_hwc_window_set_property; + backend_data->hwc_window_funcs->hwc_window_get_property = drm_hwc_window_get_property; + backend_data->hwc_window_funcs->hwc_window_get_constraints = drm_hwc_window_get_constraints; + backend_data->hwc_window_funcs->hwc_window_set_name = drm_hwc_window_set_name; + backend_data->hwc_window_funcs->hwc_window_set_cursor_image = drm_hwc_window_set_cursor_image; #ifdef ENABLE_PP - /* alloc and register pp_funcs */ - pp_funcs = calloc(1, sizeof(struct _hal_tdm_pp_funcs)); - if (!pp_funcs) { - TDM_BACKEND_ERR("fail to alloc pp_funcs!\n"); - goto failed; - } - backend_data->pp_funcs = pp_funcs; - - pp_funcs->pp_destroy = drm_pp_destroy; - pp_funcs->pp_set_info = drm_pp_set_info; - pp_funcs->pp_attach = drm_pp_attach; - pp_funcs->pp_commit = drm_pp_commit; - pp_funcs->pp_set_done_handler = drm_pp_set_done_handler; + backend_data->pp_funcs->pp_destroy = drm_pp_destroy; + backend_data->pp_funcs->pp_set_info = drm_pp_set_info; + backend_data->pp_funcs->pp_attach = drm_pp_attach; + backend_data->pp_funcs->pp_commit = drm_pp_commit; + backend_data->pp_funcs->pp_set_done_handler = drm_pp_set_done_handler; #endif TDM_BACKEND_INFO("init success!"); |