tbm_bufmgr: lock/unlock tbm_bufmgr_mutex at tbm_bufmgr function
[platform/core/uifw/libtbm.git] / src / tbm_drm_helper_server.c
index 9182fa5..4be6616 100644 (file)
@@ -248,7 +248,7 @@ _tbm_drm_auth_socket_init(struct wayland_tbm_drm_auth_server *tbm_drm_auth_srv)
 }
 
 int
-tbm_drm_helper_wl_auth_server_init(void *wl_display,   int fd, const char *device_name, uint32_t flags)
+tbm_drm_helper_wl_auth_server_init(void *wl_display, int fd, const char *device_name, uint32_t flags)
 {
        if (!tbm_drm_auth_srv) {
                TBM_RETURN_VAL_IF_FAIL(wl_display != NULL, 0);
@@ -257,7 +257,15 @@ tbm_drm_helper_wl_auth_server_init(void *wl_display,   int fd, const char *devic
                TBM_RETURN_VAL_IF_FAIL(tbm_drm_auth_srv != NULL, 0);
 
                tbm_drm_auth_srv->display = (struct wl_display *)wl_display;
-               tbm_drm_auth_srv->device_name = strdup(device_name);
+               if (!device_name) {
+                       tbm_drm_auth_srv->device_name = drmGetDeviceNameFromFd(fd);
+                       if (!tbm_drm_auth_srv->device_name) {
+                                       TBM_ERR("fail to get device name!\n");
+                                       return 0;
+                       }
+               } else {
+                       tbm_drm_auth_srv->device_name = strdup(device_name);
+               }
                tbm_drm_auth_srv->fd = fd;
                tbm_drm_auth_srv->flags = flags;
 
@@ -302,39 +310,7 @@ tbm_drm_helper_get_master_fd(void)
 {
        int new_fd, flags, fd = -1;
 
-#if 1  /* TODO: can't remove below at this time. This code SHOULD be removed later  */
-       const char *value = (const char*)getenv("TDM_DRM_MASTER_FD");
-       if (value) {
-               char *end;
-               const long int sl = strtol(value, &end, 10);
-
-               if (end == value) {
-                       TBM_ERR("%s: not a decimal number\n", value);
-                       return -1;
-               } else if (*end != '\0') {
-                       TBM_ERR("%s: extra characters at end of input: %s\n", value, end);
-                       return -1;
-               } else if ((sl == LONG_MIN || sl == LONG_MAX) && errno == ERANGE) {
-                       TBM_ERR("%s out of range of type long\n", value);
-                       return -1;
-               } else if (sl >= INT_MAX) {
-                       TBM_ERR("%ld greater than INT_MAX\n", sl);
-                       return -1;
-               } else if (sl <= INT_MIN) {
-                       TBM_ERR("%ld less than INT_MIN\n", sl);
-                       return -1;
-               } else {
-                       int fd_max = tbm_bufmgr_get_fd_limit();
-                       fd = (int)sl;
-                       if (fd < 0 || fd > fd_max) {
-                               TBM_ERR("%d out of fd range\n", fd);
-                               return -1;
-                       }
-               }
-       } else
-#endif
        fd = tbm_drm_master_fd;
-
        if (fd == -1) {
                TBM_INFO("no presetted TBM DRM MASTER FD");
                return -1;