From af9e4c07f83f7a022f08767d88708f1ec6b31602 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Tue, 19 May 2020 13:51:29 +0900 Subject: [PATCH] remove the uset of tbm_backend_bufmgr_query_display_server 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: Iee8895425fe412fe5eebce98ceba6895dc3def73 --- src/tbm_bufmgr_exynos.c | 64 ++++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/src/tbm_bufmgr_exynos.c b/src/tbm_bufmgr_exynos.c index 320856c..8fdd90e 100644 --- a/src/tbm_bufmgr_exynos.c +++ b/src/tbm_bufmgr_exynos.c @@ -750,7 +750,7 @@ _exynos_bo_handle(tbm_bo_exynos bo_exynos, int device) arg.handle = bo_exynos->gem; if (drmCommandWriteRead(bo_exynos->fd, DRM_EXYNOS_GEM_MAP, &arg, sizeof(arg))) { - TBM_ERR("Cannot map_dumb gem=%d\n", bo_exynos->gem); + TBM_ERR("Cannot map_exynos gem=%d\n", bo_exynos->gem); return (tbm_bo_handle) NULL; } @@ -2010,44 +2010,58 @@ tbm_exynos_init(tbm_bufmgr bufmgr, tbm_error_e *error) return NULL; } - if (tbm_backend_bufmgr_query_display_server(bufmgr, &err)) { - bufmgr_exynos->fd = tbm_drm_helper_get_master_fd(); + /* check the master_fd which already had opened */ + bufmgr_exynos->fd = tbm_drm_helper_get_master_fd(); + if (bufmgr_exynos->fd < 0) { + bufmgr_exynos->fd = _tbm_exynos_open_drm(); if (bufmgr_exynos->fd < 0) { - bufmgr_exynos->fd = _tbm_exynos_open_drm(); - if (bufmgr_exynos->fd < 0) { - 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(bufmgr_exynos->fd); - - bufmgr_exynos->device_name = drmGetDeviceNameFromFd(bufmgr_exynos->fd); - if (!bufmgr_exynos->device_name) { - TBM_ERR("fail to get device name!\n"); - tbm_drm_helper_unset_tbm_master_fd(); + TBM_ERR("fail to open drm!\n"); if (error) *error = TBM_ERROR_INVALID_OPERATION; - goto fail_get_device_name; + goto fail_open_drm; } - } else { + + if (drmIsMaster(bufmgr_exynos->fd)) { + tbm_drm_helper_set_tbm_master_fd(bufmgr_exynos->fd); + + bufmgr_exynos->device_name = drmGetDeviceNameFromFd(bufmgr_exynos->fd); + if (!bufmgr_exynos->device_name) { + TBM_ERR("fail to get device name!\n"); + tbm_drm_helper_unset_tbm_master_fd(); + if (error) + *error = TBM_ERROR_INVALID_OPERATION; + goto fail_get_device_name; + } + TBM_INFO("This is Master FD(%d) from open_drm.", bufmgr_exynos->fd); + } else { + /* close the fd and get the authenticated fd from the master fd */ + close(bufmgr_exynos->fd); #ifdef USE_RENDER_NODE - bufmgr_exynos->fd = _get_render_node(0); + bufmgr_exynos->fd = _get_render_node(0); #else - bufmgr_exynos->fd = -1; + bufmgr_exynos->fd = -1; #endif - if (bufmgr_exynos->fd < 0) { + /* get the authenticated drm fd from the master fd */ if (!tbm_drm_helper_get_auth_info(&(bufmgr_exynos->fd), &(bufmgr_exynos->device_name), NULL)) { TBM_ERR("fail to get auth drm info!\n"); if (error) *error = TBM_ERROR_INVALID_OPERATION; goto fail_get_auth_info; } - tbm_drm_helper_set_fd(bufmgr_exynos->fd); + TBM_INFO("This is Authenticated FD(%d)", bufmgr_exynos->fd); + } + } else { + bufmgr_exynos->device_name = drmGetDeviceNameFromFd(bufmgr_exynos->fd); + if (!bufmgr_exynos->device_name) { + TBM_ERR("fail to get device name!\n"); + tbm_drm_helper_unset_tbm_master_fd(); + if (error) + *error = TBM_ERROR_INVALID_OPERATION; + goto fail_get_device_name; } + TBM_INFO("This is Master FD from tbm_drm_helper_get_master_fd(%d)", bufmgr_exynos->fd); } + tbm_drm_helper_set_fd(bufmgr_exynos->fd); //Check if the tbm manager supports dma fence or not. fp = open("/sys/module/dmabuf_sync/parameters/enabled", O_RDONLY); @@ -2168,7 +2182,7 @@ fail_alloc_bufmgr_func: if (bufmgr_exynos->hashBos) drmHashDestroy(bufmgr_exynos->hashBos); fail_init_cache_state: - if (tbm_backend_bufmgr_query_display_server(bufmgr, &err)) + if (tbm_drm_helper_get_master_fd() >= 0) tbm_drm_helper_unset_tbm_master_fd(); else tbm_drm_helper_unset_fd(); -- 2.7.4