From: Changyeon Lee Date: Mon, 22 Aug 2022 05:32:00 +0000 (+0900) Subject: module: Fix failure bind_native_display when drm fd is render node X-Git-Tag: submit/tizen/20220822.074506~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=65104a1417466f8a2f45d9421355364503804e45;p=platform%2Fcore%2Fuifw%2Flibtbm.git module: Fix failure bind_native_display when drm fd is render node if drm fd is render node, tbm_drm_helper_wl_auth_server_init is not required. Change-Id: I46921fafc3c911dc9b35be2e6fd4284440d6fc05 --- diff --git a/include/tbm_drm_helper.h b/include/tbm_drm_helper.h index 9204b43..8f1489f 100644 --- a/include/tbm_drm_helper.h +++ b/include/tbm_drm_helper.h @@ -138,6 +138,14 @@ void tbm_drm_helper_unset_fd(void); */ int tbm_drm_helper_get_fd(void); +/** + * @brief Check render fd. + * @details + * Check drm fd is render node + * @param[in] fd The given fd + */ +int tbm_drm_helper_is_render_node(int fd); + #ifdef __cplusplus } #endif diff --git a/src/tbm_drm_helper_server.c b/src/tbm_drm_helper_server.c index 4be6616..14e6fa8 100644 --- a/src/tbm_drm_helper_server.c +++ b/src/tbm_drm_helper_server.c @@ -368,5 +368,13 @@ tbm_drm_helper_unset_tbm_master_fd(void) tbm_drm_master_fd = -1; TBM_INFO("TBM DRM MASTER FD: %d\n", tbm_drm_master_fd); } -/* LCOV_EXCL_STOP */ +int +tbm_drm_helper_is_render_node(int fd) +{ + if (drmGetNodeTypeFromFd(fd) == DRM_NODE_RENDER) + return 1; + + return 0; +} +/* LCOV_EXCL_STOP */ diff --git a/src/tbm_module.c b/src/tbm_module.c index 16beb7f..6f98691 100644 --- a/src/tbm_module.c +++ b/src/tbm_module.c @@ -514,16 +514,21 @@ tbm_module_bind_native_display(tbm_module *module, void *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."); + if (tbm_drm_helper_is_render_node(fd)) { + TBM_INFO("tbm_module has render node."); + error = TBM_ERROR_NONE; + } else { + // 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; + module->auth_wl_socket_created = 1; + module->auth_fd = fd; + } } else { TBM_INFO("tbm_module has no drm device."); error = TBM_ERROR_NONE;