module: Fix failure bind_native_display when drm fd is render node 88/279988/1
authorChangyeon Lee <cyeon.lee@samsung.com>
Mon, 22 Aug 2022 05:32:00 +0000 (14:32 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Mon, 22 Aug 2022 05:34:00 +0000 (14:34 +0900)
if drm fd is render node, tbm_drm_helper_wl_auth_server_init is not required.

Change-Id: I46921fafc3c911dc9b35be2e6fd4284440d6fc05

include/tbm_drm_helper.h
src/tbm_drm_helper_server.c
src/tbm_module.c

index 9204b43..8f1489f 100644 (file)
@@ -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
index 4be6616..14e6fa8 100644 (file)
@@ -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 */
index 16beb7f..6f98691 100644 (file)
@@ -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;