diff options
author | SooChan Lim <sc1.lim@samsung.com> | 2020-05-27 19:06:02 +0900 |
---|---|---|
committer | SooChan Lim <sc1.lim@samsung.com> | 2020-05-27 19:07:37 +0900 |
commit | 89408cf8acf7fc30544a1cc43207da6fd4764cf1 (patch) | |
tree | fd6a8dc47670c685e4055755a595909a958bae88 | |
parent | 5dc7b6be238469944d2b41da0d76efe842703efc (diff) | |
download | libtbm-exynos-tgm-89408cf8acf7fc30544a1cc43207da6fd4764cf1.tar.gz libtbm-exynos-tgm-89408cf8acf7fc30544a1cc43207da6fd4764cf1.tar.bz2 libtbm-exynos-tgm-89408cf8acf7fc30544a1cc43207da6fd4764cf1.zip |
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: I4cd6224fc8c66726ab43659df96f239bbc005652
-rw-r--r-- | src/tbm_bufmgr_exynos.c | 76 |
1 files changed, 47 insertions, 29 deletions
diff --git a/src/tbm_bufmgr_exynos.c b/src/tbm_bufmgr_exynos.c index ffb3dee..2936c04 100644 --- a/src/tbm_bufmgr_exynos.c +++ b/src/tbm_bufmgr_exynos.c @@ -2052,20 +2052,55 @@ 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"); + TBM_ERR("fail to open drm!\n"); + if (error) + *error = TBM_ERROR_INVALID_OPERATION; + goto fail_open_drm; + } + + 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_open_drm; + 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); + bufmgr_exynos->fd = -1; + + if (_check_render_node()) { + bufmgr_exynos->fd = _get_render_node(); + if (bufmgr_exynos->fd < 0) { + TBM_ERR("fail to get render node\n"); + if (error) + *error = TBM_ERROR_INVALID_OPERATION; + goto fail_get_render_node; + } + TBM_INFO("Use render node:%d\n", bufmgr_exynos->fd); + } else { + /* 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_INFO("This is Authenticated FD(%d)", bufmgr_exynos->fd); } } - - tbm_drm_helper_set_tbm_master_fd(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"); @@ -2074,26 +2109,9 @@ tbm_exynos_init(tbm_bufmgr bufmgr, tbm_error_e *error) *error = TBM_ERROR_INVALID_OPERATION; goto fail_get_device_name; } - } else { - if (_check_render_node()) { - bufmgr_exynos->fd = _get_render_node(); - if (bufmgr_exynos->fd < 0) { - TBM_ERR("fail to get render node\n"); - if (error) - *error = TBM_ERROR_INVALID_OPERATION; - goto fail_get_render_node; - } - TBM_DBG("Use render node:%d\n", bufmgr_exynos->fd); - } else { - 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 Master FD from tbm_drm_helper_get_master_fd(%d)", bufmgr_exynos->fd); } + tbm_drm_helper_set_fd(bufmgr_exynos->fd); bufmgr_exynos->use_dma_fence = 1; @@ -2181,7 +2199,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(); |