From 0685d37af53e41e7ad4daa7aea7c799c5642a198 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Tue, 15 Jun 2021 14:19:37 +0900 Subject: [PATCH] tbm_module: make tbm_module_bufmgr_bind_native_display encapsulate the bufmgr_bind_native_display with this function. Change-Id: I777a9ff365b9211eaacb7a350623c8974cd77324 --- src/tbm_bufmgr.c | 68 +++++++--------------------------------------------- src/tbm_bufmgr_int.h | 4 +++- src/tbm_module.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 73 insertions(+), 62 deletions(-) diff --git a/src/tbm_bufmgr.c b/src/tbm_bufmgr.c index 107d0fd..ec7a7cf 100644 --- a/src/tbm_bufmgr.c +++ b/src/tbm_bufmgr.c @@ -791,76 +791,24 @@ _tbm_bufmgr_get_bufmgr(void) int tbm_bufmgr_bind_native_display(tbm_bufmgr bufmgr, void *native_display) { - int ret; tbm_error_e error; _tbm_bufmgr_mutex_lock(); _tbm_set_last_result(TBM_ERROR_NONE); - TBM_BUFMGR_RETURN_VAL_IF_FAIL(TBM_BUFMGR_IS_VALID(gBufMgr), 0); - - if (bufmgr->use_hal_tbm) { - if (hal_tbm_backend_has_drm_device(bufmgr->hal_backend, &ret)) { - int fd = tbm_drm_helper_get_fd(); // this must be the auth drm_fd.(master drm_fd); - if (fd < -1) { - TBM_ERR("error: tbm_bufmgr(%p) native_display(%p)\n", bufmgr, native_display); - _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION); - _tbm_bufmgr_mutex_unlock(); - return 0; - } - - // make the wayland server socket for sending the authenticated drm_fd to wayland clients. - if (!tbm_drm_helper_wl_auth_server_init(native_display, fd, NULL, 0)) { - TBM_ERR("error: tbm_drm_helper_wl_auth_server_init failed\n", bufmgr, native_display); - close(fd); - _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION); - _tbm_bufmgr_mutex_unlock(); - return 0; - } - TBM_INFO("tbm creates a wayland socket for authentication of drm_fd."); + TBM_BUFMGR_RETURN_VAL_IF_FAIL(TBM_BUFMGR_IS_VALID(bufmgr), 0); - bufmgr->auth_wl_socket_created = 1; - bufmgr->auth_fd = fd; - - // TODO: this duplication will be removed after refactoring tbm_module - bufmgr->module->auth_wl_socket_created = 1; - bufmgr->module->auth_fd = fd; - } - } else if (bufmgr->backend_module_data) { - if (!bufmgr->bufmgr_func->bufmgr_bind_native_display) { - TBM_WRN("skip: tbm_bufmgr(%p) native_display(%p)\n", - bufmgr, native_display); - _tbm_set_last_result(TBM_ERROR_NOT_SUPPORTED); - _tbm_bufmgr_mutex_unlock(); - return 1; - } + error = tbm_module_bufmgr_bind_native_display(bufmgr->module, native_display); + if (error != TBM_ERROR_NONE) { + _tbm_set_last_result(error); + _tbm_bufmgr_mutex_unlock(); - error = bufmgr->bufmgr_func->bufmgr_bind_native_display(bufmgr->bufmgr_data, (tbm_native_display *)native_display); - if (error != TBM_ERROR_NONE) { - TBM_ERR("error: tbm_bufmgr(%p) native_display(%p) error(%d)\n", - bufmgr, native_display, error); - _tbm_set_last_result(error); - _tbm_bufmgr_mutex_unlock(); - return 0; - } - ret = 1; - } else { - if (!bufmgr->backend->bufmgr_bind_native_display) { - TBM_WRN("skip: tbm_bufmgr(%p) native_display(%p)\n", - bufmgr, native_display); - _tbm_set_last_result(TBM_ERROR_NOT_SUPPORTED); - _tbm_bufmgr_mutex_unlock(); + if (error == TBM_ERROR_NOT_SUPPORTED) { + TBM_WRN("Not supported, so skip: tbm_bufmgr(%p) native_display(%p)", bufmgr, native_display); return 1; } - ret = bufmgr->backend->bufmgr_bind_native_display(bufmgr, native_display); - if (!ret) { - TBM_ERR("error: tbm_bufmgr(%p) native_display(%p)\n", - bufmgr, native_display); - _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION); - _tbm_bufmgr_mutex_unlock(); - return 0; - } + return 0; } TBM_INFO("tbm_bufmgr(%p) native_display(%p)\n", bufmgr, native_display); diff --git a/src/tbm_bufmgr_int.h b/src/tbm_bufmgr_int.h index fe2f186..915cd1b 100644 --- a/src/tbm_bufmgr_int.h +++ b/src/tbm_bufmgr_int.h @@ -354,6 +354,8 @@ tbm_module *tbm_module_load(int fd); void tbm_module_unload(tbm_module *module); int tbm_module_bufmgr_get_capabilities(tbm_module *module, tbm_error_e *error); +tbm_error_e tbm_module_bufmgr_bind_native_display(tbm_module *module, void *native_display); tbm_backend_bo_data *tbm_module_bufmgr_bo_alloc(tbm_module *module, tbm_bo bo, int size, int flags, tbm_error_e *error); tbm_backend_bo_data *tbm_module_bufmgr_bo_alloc_with_format(tbm_module *module, int format, int bo_idx, int width, int height, int bpp, tbm_bo_memory_type flags, tbm_error_e *error); -#endif /* _TBM_BUFMGR_INT_H_ */ + +#endif /* _TBM_BUFMGR_INT_H_ */ diff --git a/src/tbm_module.c b/src/tbm_module.c index d561406..2da8152 100644 --- a/src/tbm_module.c +++ b/src/tbm_module.c @@ -477,7 +477,7 @@ tbm_module_bufmgr_get_capabilities(tbm_module *module, tbm_error_e *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_WRN("!!WARNING: This backend interface will be DEPRECATED after Tizen 6.5."); TBM_ERR("Do not support at tbm_bufmgr_backend."); *error = TBM_ERROR_NOT_SUPPORTED; @@ -491,6 +491,67 @@ tbm_module_bufmgr_get_capabilities(tbm_module *module, tbm_error_e *error) return capabilities; } +tbm_error_e +tbm_module_bufmgr_bind_native_display(tbm_module *module, void *native_display) +{ + tbm_error_e error = TBM_ERROR_NONE; + tbm_backend_bufmgr_func *bufmgr_func = NULL; + tbm_bufmgr_backend backend = NULL; + int ret = 0; + + TBM_RETURN_VAL_IF_FAIL(module, TBM_ERROR_INVALID_PARAMETER); + + switch (module->type) { + case TBM_MODULE_TYPE_HAL_TBM: + if (hal_tbm_backend_has_drm_device(module->hal_backend, &ret)) { + int fd = tbm_drm_helper_get_fd(); // this must be the auth drm_fd.(master drm_fd); + if (fd < -1) { + TBM_ERR("error: module(%p) native_display(%p)\n", module, native_display); + return TBM_ERROR_INVALID_OPERATION; + } + + // make the wayland server socket for sending the authenticated drm_fd to wayland clients. + if (!tbm_drm_helper_wl_auth_server_init(native_display, fd, NULL, 0)) { + TBM_ERR("error: tbm_drm_helper_wl_auth_server_init failed\n", module, native_display); + close(fd); + return TBM_ERROR_INVALID_OPERATION; + } + TBM_INFO("tbm creates a wayland socket for authentication of drm_fd."); + + module->auth_wl_socket_created = 1; + module->auth_fd = fd; + } else { + TBM_INFO("tbm_module has no drm device."); + error = TBM_ERROR_NONE; + } + break; + case TBM_MODULE_TYPE_TBM_BACKEND: + bufmgr_func = module->bufmgr_func; + TBM_RETURN_VAL_IF_FAIL(bufmgr_func, TBM_ERROR_INVALID_OPERATION); + TBM_RETURN_VAL_IF_FAIL(bufmgr_func->bufmgr_bind_native_display, TBM_ERROR_NOT_SUPPORTED); + + error = bufmgr_func->bufmgr_bind_native_display(module->bufmgr_data, (tbm_native_display *)native_display); + break; + case TBM_MODULE_TYPE_BUFMGR_BACKEND: + TBM_WRN("!!WARNING: This backend interface will be DEPRECATED after Tizen 7.0."); + backend = module->backend; + TBM_RETURN_VAL_IF_FAIL(backend, TBM_ERROR_INVALID_OPERATION); + TBM_RETURN_VAL_IF_FAIL(backend->bufmgr_bind_native_display, TBM_ERROR_NOT_SUPPORTED); + + ret = backend->bufmgr_bind_native_display((tbm_bufmgr)module, native_display); + if (!ret) + error = TBM_ERROR_INVALID_OPERATION; + + break; + default: + TBM_ERR("Wrong module type:%d", module->type); + error = TBM_ERROR_INVALID_OPERATION; + break; + } + + return error; +} + tbm_backend_bo_data * tbm_module_bufmgr_bo_alloc(tbm_module *module, tbm_bo bo, int size, int flags, tbm_error_e *error) { -- 2.7.4