summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJinhyung Jo <jinhyung.jo@samsung.com>2016-04-14 00:32:52 -0700
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>2016-04-14 00:32:52 -0700
commitcd7529d4a91040882c96feb9e08a6b6d5c6150bd (patch)
tree9b2eb7c987494813b5a77df4c18e6c04df656fc9
parent2dde9b7929a849b0402ae9834ba9d60055847af7 (diff)
parent8a3fd720e6dfe89193f80e450c043b40d95e1300 (diff)
downloadlibtbm-vigs-cd7529d4a91040882c96feb9e08a6b6d5c6150bd.tar.gz
libtbm-vigs-cd7529d4a91040882c96feb9e08a6b6d5c6150bd.tar.bz2
libtbm-vigs-cd7529d4a91040882c96feb9e08a6b6d5c6150bd.zip
-rwxr-xr-xsrc/tbm_bufmgr_emulator.c42
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);
}