diff options
author | Jinhyung Jo <jinhyung.jo@samsung.com> | 2016-04-14 00:32:52 -0700 |
---|---|---|
committer | Gerrit Code Review <gerrit@review.vlan103.tizen.org> | 2016-04-14 00:32:52 -0700 |
commit | cd7529d4a91040882c96feb9e08a6b6d5c6150bd (patch) | |
tree | 9b2eb7c987494813b5a77df4c18e6c04df656fc9 | |
parent | 2dde9b7929a849b0402ae9834ba9d60055847af7 (diff) | |
parent | 8a3fd720e6dfe89193f80e450c043b40d95e1300 (diff) | |
download | libtbm-vigs-cd7529d4a91040882c96feb9e08a6b6d5c6150bd.tar.gz libtbm-vigs-cd7529d4a91040882c96feb9e08a6b6d5c6150bd.tar.bz2 libtbm-vigs-cd7529d4a91040882c96feb9e08a6b6d5c6150bd.zip |
Merge "Share master fd with tdm backend and open fd if it needed" into tizensubmit/tizen/20160414.040521accepted/tizen/wearable/20160415.014754accepted/tizen/tv/20160415.014731accepted/tizen/mobile/20160415.014834accepted/tizen/ivi/20160415.014813accepted/tizen/common/20160414.142607
-rwxr-xr-x | src/tbm_bufmgr_emulator.c | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/src/tbm_bufmgr_emulator.c b/src/tbm_bufmgr_emulator.c index 0babcf8..956135a 100755 --- a/src/tbm_bufmgr_emulator.c +++ b/src/tbm_bufmgr_emulator.c @@ -48,6 +48,8 @@ #include <unistd.h> #include <xf86drm.h> +#define VIGS_DRM_NAME "vigs" + static uint32_t tbm_bufmgr_emulator_color_format_list[] = { TBM_FORMAT_RGB888, @@ -58,6 +60,19 @@ static uint32_t tbm_bufmgr_emulator_color_format_list[] = TBM_FORMAT_YUV420, }; +static int _tbm_vigs_open_drm(void) +{ + int fd = -1; + + fd = drmOpen(VIGS_DRM_NAME, NULL); + if (fd < 0) { + TBM_EMULATOR_LOG_ERROR ("open vigs drm device failed"); + return -1; + } + + return fd; +} + static tbm_bo_handle get_tbm_bo_handle(struct vigs_drm_gem *gem, int device) { @@ -102,8 +117,10 @@ static void tbm_bufmgr_emulator_deinit(void *priv) TBM_EMULATOR_LOG_DEBUG("enter"); - if (tbm_backend_is_display_server()) + if (tbm_backend_is_display_server()) { tbm_drm_helper_wl_auth_server_deinit(); + tbm_drm_helper_unset_tbm_master_fd(); + } close(drm_dev->fd); @@ -466,7 +483,19 @@ int tbm_bufmgr_emulator_init(tbm_bufmgr bufmgr, int fd) } if (tbm_backend_is_display_server()) { - drm_fd = dup(fd); + drm_fd = tbm_drm_helper_get_master_fd(); + + if (drm_fd < 0) { + drm_fd = _tbm_vigs_open_drm(); + } + + if (drm_fd < 0) { + TBM_EMULATOR_LOG_ERROR ("vigs drm device failed"); + goto fail; + } + + tbm_drm_helper_set_tbm_master_fd(drm_fd); + } else { if (!tbm_drm_helper_get_auth_info(&drm_fd, NULL, NULL)) { TBM_EMULATOR_LOG_ERROR ("tbm_drm_helper_get_auth_info failed"); @@ -488,7 +517,6 @@ int tbm_bufmgr_emulator_init(tbm_bufmgr bufmgr, int fd) goto fail; } - backend->flags = TBM_USE_2_0_BACKEND; backend->priv = (void*)drm_dev; backend->bufmgr_deinit = tbm_bufmgr_emulator_deinit; backend->bo_size = tbm_bufmgr_emulator_bo_size; @@ -501,9 +529,9 @@ int tbm_bufmgr_emulator_init(tbm_bufmgr bufmgr, int fd) backend->bo_get_handle = tbm_bufmgr_emulator_bo_get_handle; backend->bo_map = tbm_bufmgr_emulator_bo_map; backend->bo_unmap = tbm_bufmgr_emulator_bo_unmap; - backend->bo_lock2 = tbm_bufmgr_emulator_bo_lock; + backend->bo_lock = tbm_bufmgr_emulator_bo_lock; backend->bo_unlock = tbm_bufmgr_emulator_bo_unlock; - backend->surface_get_plane_data2 = tbm_bufmgr_emulator_surface_get_plane_data; + backend->surface_get_plane_data = tbm_bufmgr_emulator_surface_get_plane_data; backend->surface_supported_format = tbm_bufmgr_emulator_surface_supported_format; backend->bufmgr_bind_native_display = tbm_bufmgr_emulator_bind_native_display; @@ -526,6 +554,10 @@ fail: } if (drm_fd >= 0) { + if (tbm_backend_is_display_server()) { + tbm_drm_helper_unset_tbm_master_fd(); + } + close(drm_fd); } |