tdm: make a module_data at use_tdm_hal case. 99/259399/1
authorSooChan Lim <sc1.lim@samsung.com>
Fri, 28 May 2021 00:36:54 +0000 (09:36 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Mon, 7 Jun 2021 07:59:20 +0000 (16:59 +0900)
Even though there is no module_data at use_tdm_hal case,
make a module_data for supporting the tdm api.

Change-Id: I8c488ed3b7a12335255d10d311bf69703ad6bd99

include/tdm_backend.h
src/tdm.c

index 5fe3f34..078815c 100644 (file)
@@ -1375,8 +1375,8 @@ typedef tdm_error (*tdm_event_loop_timer_handler)(void *user_data);
  * at the initial time and call init() function of #tdm_backend_module.
  */
 typedef struct _tdm_backend_module {
-       const char *name;           /**< The module name of a backend module */
-       const char *vendor;         /**< The vendor name of a backend module */
+       char *name;           /**< The module name of a backend module */
+       char *vendor;         /**< The vendor name of a backend module */
        unsigned long abi_version;  /**< The ABI version of a backend module */
 
        /**
index 3f0363d..889b3b8 100644 (file)
--- a/src/tdm.c
+++ b/src/tdm.c
@@ -910,6 +910,7 @@ _tdm_display_load_hal_backend(tdm_private_display *private_display)
        hal_tdm_backend *tdm_backend = NULL;
        hal_tdm_display *hal_tdm_dpy = NULL;
        tdm_private_module *private_module = NULL;
+       tdm_backend_module *module_data = NULL;
        hal_tdm_event_source **event_sources = NULL;
        hal_tdm_caps_display caps;
        hal_tdm_caps_pp pp_caps;
@@ -932,6 +933,15 @@ _tdm_display_load_hal_backend(tdm_private_display *private_display)
                return TDM_ERROR_OUT_OF_MEMORY;
        }
 
+       module_data = calloc(1, sizeof *module_data);
+       if (module_data == NULL) {
+               TDM_ERR("failed: alloc");
+               goto fail;
+       }
+       module_data->name = hal_tdm_backend_get_name(tdm_backend);
+       module_data->vendor = hal_tdm_backend_get_vendor(tdm_backend);
+       module_data->abi_version = hal_tdm_backend_get_abi_version(tdm_backend);
+
        hal_tdm_dpy = hal_tdm_backend_get_display(tdm_backend, &hret);
        if (hal_tdm_dpy == NULL || hret != HAL_TDM_ERROR_NONE) {
                TDM_ERR("failed hal_tdm_backend_get_display");
@@ -970,6 +980,7 @@ _tdm_display_load_hal_backend(tdm_private_display *private_display)
 
        private_module->use_hal_tdm = 1;
        private_module->htdm_backend = tdm_backend;
+       private_module->module_data = module_data;
        private_module->htdm_dpy = hal_tdm_dpy;
        private_module->private_display = private_display;
        private_display->current_module = private_module;
@@ -1029,7 +1040,9 @@ fail:
        if (master_drm_fd >= 0)
                close(master_drm_fd);
        hal_tdm_put_backend(tdm_backend);
+       free(module_data);
        free(private_module);
+
        return TDM_ERROR_NO_MODULE;
 }
 
@@ -1295,6 +1308,7 @@ static void
 _tdm_display_unload_modules(tdm_private_display *private_display)
 {
        tdm_private_module *private_module = NULL, *bb = NULL;
+       tdm_backend_module *module_data = NULL;
 
        LIST_FOR_EACH_ENTRY_SAFE(private_module, bb, &private_display->module_list, link) {
                LIST_DEL(&private_module->link);
@@ -1305,17 +1319,23 @@ _tdm_display_unload_modules(tdm_private_display *private_display)
                                        tdm_event_loop_source_remove(htdm_event_source);
                                }
                        }
+
+                       module_data = private_module->module_data;
+                       if (module_data){
+                               free(module_data->name);
+                               free(module_data->vendor);
+                               free(module_data);
+                       }
                        hal_tdm_put_backend(private_module->htdm_backend);
                        free(private_module);
-                       continue;
-               }
-
-               if (private_module->module_data)
-                       private_module->module_data->deinit(private_module->bdata);
-               if (private_module->module)
-                       dlclose(private_module->module);
+               } else {
+                       if (private_module->module_data)
+                               private_module->module_data->deinit(private_module->bdata);
+                       if (private_module->module)
+                               dlclose(private_module->module);
 
-               free(private_module);
+                       free(private_module);
+               }
        }
 }
 /* LCOV_EXCL_STOP */