diff options
author | SooChan Lim <sc1.lim@samsung.com> | 2020-05-27 18:09:36 +0900 |
---|---|---|
committer | SooChan Lim <sc1.lim@samsung.com> | 2020-05-28 15:29:56 +0900 |
commit | 65ac21f93f49fa1095e5c593356aee8260cab9dd (patch) | |
tree | 573d6e8f31b447f42121dbafe7e2130cf15157c6 | |
parent | f2713d361518a3235d38c2f2d695fc0fb073ce65 (diff) | |
download | libtbm-vc4-65ac21f93f49fa1095e5c593356aee8260cab9dd.tar.gz libtbm-vc4-65ac21f93f49fa1095e5c593356aee8260cab9dd.tar.bz2 libtbm-vc4-65ac21f93f49fa1095e5c593356aee8260cab9dd.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: I1dbc5805e1d4275579954c6769b74f2c6eabc026
-rw-r--r-- | src/tbm_bufmgr_vc4.c | 78 |
1 files changed, 47 insertions, 31 deletions
diff --git a/src/tbm_bufmgr_vc4.c b/src/tbm_bufmgr_vc4.c index 4dbd904..690a4ae 100644 --- a/src/tbm_bufmgr_vc4.c +++ b/src/tbm_bufmgr_vc4.c @@ -556,7 +556,7 @@ _bufmgr_init_cache_state(tbm_bufmgr_vc4 bufmgr_vc4) #ifdef TGL_GET_VERSION if (!_tgl_get_version(bufmgr_vc4->tgl_fd)) { TBM_ERR("fail to get tgl_version. tgl init failed.\n"); - close(bufmgr_sprd->tgl_fd); + close(bufmgr_vc4->tgl_fd); return 0; } #endif @@ -2201,20 +2201,54 @@ tbm_vc4_init(tbm_bufmgr bufmgr, tbm_error_e *error) return NULL; } - if (tbm_backend_bufmgr_query_display_server(bufmgr, &err)) { - bufmgr_vc4->fd = tbm_drm_helper_get_master_fd(); + /* check the master_fd which already had opened */ + bufmgr_vc4->fd = tbm_drm_helper_get_master_fd(); + if (bufmgr_vc4->fd < 0) { + bufmgr_vc4->fd = _tbm_vc4_open_drm(); if (bufmgr_vc4->fd < 0) { - bufmgr_vc4->fd = _tbm_vc4_open_drm(); - if (bufmgr_vc4->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_vc4->fd)) { + tbm_drm_helper_set_tbm_master_fd(bufmgr_vc4->fd); + + bufmgr_vc4->device_name = drmGetDeviceNameFromFd(bufmgr_vc4->fd); + if (!bufmgr_vc4->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_vc4->fd); + } else { + /* close the fd and get the authenticated fd from the master fd */ + close(bufmgr_vc4->fd); + bufmgr_vc4->fd = -1; + + if (_check_render_node()) { + bufmgr_vc4->fd = _get_render_node();//TODO + if (bufmgr_vc4->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_vc4->fd); + } else { + /* get the authenticated drm fd from the master fd */ + if (!tbm_drm_helper_get_auth_info(&(bufmgr_vc4->fd), &(bufmgr_vc4->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_vc4->fd); } } - - tbm_drm_helper_set_tbm_master_fd(bufmgr_vc4->fd); - + } else { bufmgr_vc4->device_name = drmGetDeviceNameFromFd(bufmgr_vc4->fd); if (!bufmgr_vc4->device_name) { TBM_ERR("fail to get device name!\n"); @@ -2223,27 +2257,9 @@ tbm_vc4_init(tbm_bufmgr bufmgr, tbm_error_e *error) *error = TBM_ERROR_INVALID_OPERATION; goto fail_get_device_name; } - tbm_drm_helper_set_fd(bufmgr_vc4->fd); - } else { - if (_check_render_node()) { - bufmgr_vc4->fd = _get_render_node();//TODO - if (bufmgr_vc4->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_vc4->fd); - } else { - if (!tbm_drm_helper_get_auth_info(&(bufmgr_vc4->fd), &(bufmgr_vc4->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_vc4->fd); - } + TBM_INFO("This is Master FD from tbm_drm_helper_get_master_fd(%d)", bufmgr_vc4->fd); } + tbm_drm_helper_set_fd(bufmgr_vc4->fd); //Check if the tbm manager supports dma fence or not. fp = open("/sys/module/dmabuf_sync/parameters/enabled", O_RDONLY); @@ -2345,7 +2361,7 @@ fail_alloc_bufmgr_func: if (bufmgr_vc4->hashBos) drmHashDestroy(bufmgr_vc4->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(); |