From 303e3c634355ee894a5a5de37b7dbe253af6a9ca Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Tue, 19 May 2020 13:45:57 +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: Ifdb26184d08baf4abaa3af946b54edf0115ddf75 --- src/tbm_bufmgr_dumb.c | 55 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/src/tbm_bufmgr_dumb.c b/src/tbm_bufmgr_dumb.c index a962f26..bcff466 100644 --- a/src/tbm_bufmgr_dumb.c +++ b/src/tbm_bufmgr_dumb.c @@ -1446,20 +1446,44 @@ tbm_dumb_init(tbm_bufmgr bufmgr, tbm_error_e *error) return NULL; } - if (tbm_backend_bufmgr_query_display_server(bufmgr, &err)) { - bufmgr_dumb->fd = tbm_drm_helper_get_master_fd(); + /* check the master_fd which already had opened */ + bufmgr_dumb->fd = tbm_drm_helper_get_master_fd(); + if (bufmgr_dumb->fd < 0) { + bufmgr_dumb->fd = _tbm_dumb_open_drm(); if (bufmgr_dumb->fd < 0) { - bufmgr_dumb->fd = _tbm_dumb_open_drm(); - if (bufmgr_dumb->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_dumb->fd)) { + tbm_drm_helper_set_tbm_master_fd(bufmgr_dumb->fd); + + bufmgr_dumb->device_name = drmGetDeviceNameFromFd(bufmgr_dumb->fd); + if (!bufmgr_dumb->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_dumb->fd); + } else { + /* close the fd and get the authenticated fd from the master fd */ + close(bufmgr_dumb->fd); + bufmgr_dumb->fd = -1; + + /* get the authenticated drm fd from the master fd */ + if (!tbm_drm_helper_get_auth_info(&(bufmgr_dumb->fd), &(bufmgr_dumb->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_dumb->fd); } - - tbm_drm_helper_set_tbm_master_fd(bufmgr_dumb->fd); - + } else { bufmgr_dumb->device_name = drmGetDeviceNameFromFd(bufmgr_dumb->fd); if (!bufmgr_dumb->device_name) { TBM_ERR("fail to get device name!\n"); @@ -1468,16 +1492,9 @@ tbm_dumb_init(tbm_bufmgr bufmgr, tbm_error_e *error) *error = TBM_ERROR_INVALID_OPERATION; goto fail_get_device_name; } - tbm_drm_helper_set_fd(bufmgr_dumb->fd); - } else { - if (!tbm_drm_helper_get_auth_info(&(bufmgr_dumb->fd), &(bufmgr_dumb->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_dumb->fd); + TBM_ERR("This is Master FD from tbm_drm_helper_get_master_fd(%d)", bufmgr_dumb->fd); } + tbm_drm_helper_set_fd(bufmgr_dumb->fd); ret = drmGetCap(bufmgr_dumb->fd, DRM_CAP_DUMB_BUFFER, &cap); if (ret || cap == 0) { @@ -1580,7 +1597,7 @@ fail_alloc_bufmgr_func: free(bufmgr_dumb->device_name); fail_get_cap: fail_get_device_name: - 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