tbm_module: get the error type at tbm_module_bufmgr_get_capabilities 85/259885/1
authorSooChan Lim <sc1.lim@samsung.com>
Fri, 11 Jun 2021 08:10:36 +0000 (17:10 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Tue, 15 Jun 2021 12:02:57 +0000 (21:02 +0900)
return the error type which is returned by
tbm_module_bufmgr_get_capabilities

Change-Id: I7199e8e44ad802c1e743439321f1c2b5ac965739

src/tbm_bufmgr.c
src/tbm_bufmgr_int.h
src/tbm_module.c

index 226ea25..107d0fd 100644 (file)
@@ -208,6 +208,8 @@ _tbm_bufmgr_copy_module_data(tbm_bufmgr bufmgr, tbm_module *module, int reset)
 static tbm_bufmgr
 _tbm_bufmgr_init(int fd, int server)
 {
+       tbm_error_e error = TBM_ERROR_NONE;
+
 #ifdef TBM_BUFMGR_INIT_TIME
        struct timeval start_tv, end_tv;
 #endif
@@ -283,19 +285,19 @@ _tbm_bufmgr_init(int fd, int server)
        _tbm_bufmgr_copy_module_data(gBufMgr, gBufMgr->module, 0);
 
        /* check the essential capabilities of tbm_module */
-       gBufMgr->capabilities = tbm_module_bufmgr_get_capabilities(gBufMgr->module);
-       if (gBufMgr->capabilities == HAL_TBM_BUFMGR_CAPABILITY_NONE) {
+       gBufMgr->capabilities = tbm_module_bufmgr_get_capabilities(gBufMgr->module, &error);
+       if (gBufMgr->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.");
                tbm_module_unload(gBufMgr->module);
-               _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION);
+               _tbm_set_last_result(error);
                free(gBufMgr);
                gBufMgr = NULL;
                pthread_mutex_unlock(&gLock);
                return NULL;
        }
 
-       if (!(gBufMgr->capabilities & HAL_TBM_BUFMGR_CAPABILITY_SHARE_FD)) {
+       if (!(gBufMgr->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. ");
                tbm_module_unload(gBufMgr->module);
index c7e7d69..99e8e74 100644 (file)
@@ -357,7 +357,7 @@ tbm_bo tbm_bo_alloc_with_bo_data(tbm_bufmgr bufmgr, tbm_backend_bo_data *bo_data
 tbm_module *tbm_module_load(int fd);
 void        tbm_module_unload(tbm_module *module);
 
-int                  tbm_module_bufmgr_get_capabilities(tbm_module *module);
+int                  tbm_module_bufmgr_get_capabilities(tbm_module *module, tbm_error_e *error);
 tbm_backend_bo_data *tbm_module_bufmgr_bo_alloc(tbm_module *module, tbm_bo bo, int size, int flags, tbm_error_e *error);
 
 #endif                                                 /* _TBM_BUFMGR_INT_H_ */
index e0d8daf..a2f3ac6 100644 (file)
@@ -458,31 +458,30 @@ tbm_module_unload(tbm_module *module)
 }
 
 int
-tbm_module_bufmgr_get_capabilities(tbm_module *module)
+tbm_module_bufmgr_get_capabilities(tbm_module *module, tbm_error_e *error)
 {
-       tbm_error_e error = TBM_ERROR_NOT_SUPPORTED;
        int capabilities = 0;
 
+       TBM_RETURN_VAL_SET_ERR_IF_FAIL(module, TBM_BUFMGR_CAPABILITY_NONE, *error, TBM_ERROR_INVALID_PARAMETER);
+
        switch (module->type) {
        case TBM_MODULE_TYPE_HAL_TBM:
-               capabilities = hal_tbm_bufmgr_get_capabilities(module->hal_bufmgr, (hal_tbm_error *)&error);
+               capabilities = hal_tbm_bufmgr_get_capabilities(module->hal_bufmgr, (hal_tbm_error *)error);
                break;
        case TBM_MODULE_TYPE_TBM_BACKEND:
-               capabilities = module->bufmgr_func->bufmgr_get_capabilities(module->bufmgr_data, &error);
+               capabilities = module->bufmgr_func->bufmgr_get_capabilities(module->bufmgr_data, error);
                break;
        case TBM_MODULE_TYPE_BUFMGR_BACKEND:
+               TBM_WRN("!!WARNING: This backend interface will be DEPRECATED after Tizen 7.0.");
                TBM_ERR("Do not support at tbm_bufmgr_backend.");
+               *error = TBM_ERROR_NOT_SUPPORTED;
                break;
        default:
                TBM_ERR("Wrong module type:%d", module->type);
+               *error = TBM_ERROR_INVALID_OPERATION;
                break;
        }
 
-       if (error != TBM_ERROR_NONE) {
-               TBM_ERR("fail to get capabilities of tbm_module_bufmgr");
-               return 0;
-       }
-
        return capabilities;
 }