remove the uset of tbm_backend_bufmgr_query_display_server 14/234614/2
authorSooChan Lim <sc1.lim@samsung.com>
Wed, 27 May 2020 10:29:23 +0000 (19:29 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Thu, 28 May 2020 06:12:04 +0000 (15:12 +0900)
The backend has to use the drmIsMaster() to check if the drm_fd
is the master fd instead of tbm_backend_bufmgr_query_display_server().

Change-Id: I9eee3239ad5fe2a6fc7514ae156f7eff191f402c

src/tbm_bufmgr_vigs.c

index e7ab5c9..7cc4957 100755 (executable)
@@ -822,28 +822,38 @@ tbm_vigs_init(tbm_bufmgr bufmgr, tbm_error_e *error)
                return NULL;
        }
 
-       if (tbm_backend_bufmgr_query_display_server(bufmgr, &err)) {
-               drm_fd = tbm_drm_helper_get_master_fd();
-               if (drm_fd < 0)
-                       drm_fd = _tbm_vigs_open_drm();
-
+       /* check the master_fd which already had opened */
+       drm_fd = tbm_drm_helper_get_master_fd();
+       if (drm_fd < 0) {
+               drm_fd = _tbm_vigs_open_drm();
                if (drm_fd < 0) {
-                       TBM_ERR("vigs drm device failed");
+                       TBM_ERR("fail to open drm!\n");
                        if (error)
                                *error = TBM_ERROR_INVALID_OPERATION;
                        goto fail_open_drm;
                }
 
-               tbm_drm_helper_set_tbm_master_fd(drm_fd);
-
-       } else {
-               if (!tbm_drm_helper_get_auth_info(&drm_fd, NULL, NULL)) {
-                       TBM_ERR("tbm_drm_helper_get_auth_info failed");
-                       if (error)
-                               *error = TBM_ERROR_INVALID_OPERATION;
-                       goto fail_get_auth_info;
+               if (drmIsMaster(drm_fd)) {
+                       tbm_drm_helper_set_tbm_master_fd(drm_fd);
+                       TBM_INFO("This is Master FD(%d) from open_drm.", drm_fd);
+               } else {
+                       /* close the fd and get the authenticated fd from the master fd */
+                       close(drm_fd);
+                       drm_fd = -1;
+
+                       /* get the authenticated drm fd from the master fd */
+                       if (!tbm_drm_helper_get_auth_info(&(drm_fd), NULL, NULL)) {
+                               TBM_ERR("fail to get auth drm info!\n");
+                               if (error)
+                                       *error = TBM_ERROR_INVALID_OPERATION;
+                               goto fail_get_auth_info;
+                       }
+                       TBM_INFO("This is Authenticated FD(%d)", drm_fd);
                }
+       } else {
+               TBM_INFO("This is Master FD from tbm_drm_helper_get_master_fd(%d)", drm_fd);
        }
+       tbm_drm_helper_set_fd(drm_fd);
 
        ret = vigs_drm_device_create(drm_fd, &drm_dev);
        if (ret != 0) {
@@ -923,7 +933,7 @@ fail_register_bufmgr_func:
 fail_alloc_bufmgr_func:
        vigs_drm_device_destroy(drm_dev);
 fail_create_vigs_drm_device:
-       if (tbm_backend_bufmgr_query_display_server(bufmgr, &err))
+       if (tbm_drm_helper_get_master_fd() >= 0)
                tbm_drm_helper_unset_tbm_master_fd();
        if (drm_fd >= 0)
                close(drm_fd);