tbm_bufmgr: use tbm_module_bufmgr_get_capabilities 03/259703/1
authorSooChan Lim <sc1.lim@samsung.com>
Thu, 10 Jun 2021 06:47:23 +0000 (15:47 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Fri, 11 Jun 2021 00:50:04 +0000 (09:50 +0900)
Use tbm_module_bufmgr_get_capabilities and
remove the code for getting capabilities at tbm_module.c

Change-Id: Iff76fa966f202a1a28e2a518733ba7901e43b490

src/tbm_bufmgr.c
src/tbm_module.c

index 703cf40..38ec943 100644 (file)
@@ -244,6 +244,31 @@ _tbm_bufmgr_init(int fd, int server)
                return NULL;
 
        }
+
+       /* check the essential capabilities of tbm_module */
+       gBufMgr->capabilities = tbm_module_bufmgr_get_capabilities(gBufMgr->module);
+       if (gBufMgr->capabilities == HAL_TBM_BUFMGR_CAPABILITY_NONE) {
+               TBM_ERR("The capabilities of the backend module is TBM_BUFMGR_CAPABILITY_NONE.");
+               TBM_ERR("TBM_BUFMGR_CAPABILITY_SHARE_FD is the essential capability.");
+               tbm_module_unload(gBufMgr->module);
+               _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION);
+               free(gBufMgr);
+               gBufMgr = NULL;
+               pthread_mutex_unlock(&gLock);
+               return NULL;
+       }
+
+       if (!(gBufMgr->capabilities & HAL_TBM_BUFMGR_CAPABILITY_SHARE_FD)) {
+               TBM_ERR("The capabilities of the backend module had no TBM_BUFMGR_CAPABILITY_SHARE_FD.");
+               TBM_ERR("The tbm backend has to get TBM_BUFMGR_CAPABILITY_SHARE_FD. ");
+               tbm_module_unload(gBufMgr->module);
+               _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION);
+               free(gBufMgr);
+               gBufMgr = NULL;
+               pthread_mutex_unlock(&gLock);
+               return NULL;
+       }
+
        /* LCOV_EXCL_STOP */
 
        gBufMgr->ref_count = 1;
index fe90662..10e7eff 100644 (file)
@@ -91,7 +91,6 @@ static int
 _tbm_backend_load_hal_tbm(tbm_module *module)
 {
        hal_tbm_backend *hal_backend = NULL;
-       hal_tbm_bufmgr_capability capability;
        hal_tbm_bufmgr *hal_bufmgr;
        hal_tbm_error ret = HAL_TBM_ERROR_NONE;
        hal_tbm_fd auth_drm_fd = -1;
@@ -138,25 +137,6 @@ _tbm_backend_load_hal_tbm(tbm_module *module)
                tbm_drm_helper_set_fd(auth_drm_fd);
        }
 
-       capability = hal_tbm_bufmgr_get_capabilities(hal_bufmgr, &ret);
-       if (ret != HAL_TBM_ERROR_NONE) {
-               TBM_ERR("hal_tbm_bufmgr_get_capabilities fail.");
-               goto get_backend_fail;
-       }
-
-       if (capability == HAL_TBM_BUFMGR_CAPABILITY_NONE) {
-               TBM_ERR("The capabilities of the backend module is TBM_BUFMGR_CAPABILITY_NONE.");
-               TBM_ERR("TBM_BUFMGR_CAPABILITY_SHARE_FD is the essential capability.");
-               goto get_backend_fail;
-       }
-       if (!(capability & HAL_TBM_BUFMGR_CAPABILITY_SHARE_FD)) {
-               TBM_ERR("The capabilities of the backend module had no TBM_BUFMGR_CAPABILITY_SHARE_FD.");
-               TBM_ERR("The tbm backend has to get TBM_BUFMGR_CAPABILITY_SHARE_FD. ");
-               goto get_backend_fail;
-       }
-
-       module->bufmgr->capabilities = capability;
-
        module->hal_backend = hal_backend;
        module->hal_bufmgr = hal_bufmgr;
 
@@ -318,20 +298,6 @@ _tbm_backend_load_module(tbm_module *module, const char *file)
                goto err;
        }
 
-       /* get the capability */
-       module->bufmgr->capabilities = module->bufmgr->bufmgr_func->bufmgr_get_capabilities(bufmgr_data, &error);
-       if (module->bufmgr->capabilities == TBM_BUFMGR_CAPABILITY_NONE) {
-               TBM_ERR("The capabilities of the backend module is TBM_BUFMGR_CAPABILITY_NONE.");
-               TBM_ERR("TBM_BUFMGR_CAPABILITY_SHARE_FD is the essential capability.");
-               goto err;
-       }
-
-       if (!(module->bufmgr->capabilities & TBM_BUFMGR_CAPABILITY_SHARE_FD)) {
-               TBM_ERR("The capabilities of the backend module had no TBM_BUFMGR_CAPABILITY_SHARE_FD.");
-               TBM_ERR("The tbm backend has to get TBM_BUFMGR_CAPABILITY_SHARE_FD. ");
-               goto err;
-       }
-
        module->module_data = module_data;
        module->backend_module_data = backend_module_data;
        module->bufmgr_data = bufmgr_data;