From c7485c8646de736456c07e391e84d5fee743e7d9 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Tue, 19 May 2020 13:28:35 +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: I74c1d90456e36727696c6168f8a38db1bd3c93a7 --- src/tbm_bufmgr_sprd.c | 53 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/src/tbm_bufmgr_sprd.c b/src/tbm_bufmgr_sprd.c index 2e2dd63..b256ea8 100644 --- a/src/tbm_bufmgr_sprd.c +++ b/src/tbm_bufmgr_sprd.c @@ -1794,20 +1794,44 @@ tbm_sprd_init(tbm_bufmgr bufmgr, tbm_error_e *error) return NULL; } - if (tbm_backend_bufmgr_query_display_server(bufmgr, &err)) { - bufmgr_sprd->fd = tbm_drm_helper_get_master_fd(); + /* check the master_fd which already had opened */ + bufmgr_sprd->fd = tbm_drm_helper_get_master_fd(); + if (bufmgr_sprd->fd < 0) { + bufmgr_sprd->fd = _tbm_sprd_open_drm(); if (bufmgr_sprd->fd < 0) { - bufmgr_sprd->fd = _tbm_sprd_open_drm(); - if (bufmgr_sprd->fd < 0) { - TBM_ERR("fail to open drm!\n"); + TBM_ERR("fail to open drm!\n"); + if (error) + *error = TBM_ERROR_INVALID_OPERATION; + goto fail_open_drm; + } + + if (drmIsMaster(bufmgr_sprd->fd)) { + tbm_drm_helper_set_tbm_master_fd(bufmgr_sprd->fd); + + bufmgr_sprd->device_name = drmGetDeviceNameFromFd(bufmgr_sprd->fd); + if (!bufmgr_sprd->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_ERR("This is Master FD(%d) from open_drm.", bufmgr_sprd->fd); + } else { + /* close the fd and get the authenticated fd from the master fd */ + close(bufmgr_sprd->fd); + bufmgr_sprd->fd = -1; + + /* get the authenticated drm fd from the master fd */ + if (!tbm_drm_helper_get_auth_info(&(bufmgr_sprd->fd), &(bufmgr_sprd->device_name), NULL)) { + TBM_ERR("fail to get auth drm info!\n"); if (error) *error = TBM_ERROR_INVALID_OPERATION; - goto fail_open_drm; + goto fail_get_auth_info; } + TBM_ERR("This is Authenticated FD(%d)", bufmgr_sprd->fd); } - - tbm_drm_helper_set_tbm_master_fd(bufmgr_sprd->fd); - + } else { bufmgr_sprd->device_name = drmGetDeviceNameFromFd(bufmgr_sprd->fd); if (!bufmgr_sprd->device_name) { TBM_ERR("fail to get device name!\n"); @@ -1816,14 +1840,7 @@ tbm_sprd_init(tbm_bufmgr bufmgr, tbm_error_e *error) *error = TBM_ERROR_INVALID_OPERATION; goto fail_get_device_name; } - } else { - if (!tbm_drm_helper_get_auth_info(&(bufmgr_sprd->fd), &(bufmgr_sprd->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_ERR("This is Master FD from tbm_drm_helper_get_master_fd(%d)", bufmgr_sprd->fd); } tbm_drm_helper_set_fd(bufmgr_sprd->fd); @@ -1926,7 +1943,7 @@ fail_alloc_bufmgr_func: if (bufmgr_sprd->hashBos) drmHashDestroy(bufmgr_sprd->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(); tbm_drm_helper_unset_fd(); if (bufmgr_sprd->device_name) -- 2.7.4