summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChangyeon Lee <cyeon.lee@samsung.com>2016-03-24 21:21:30 +0900
committerChangyeon Lee <cyeon.lee@samsung.com>2016-04-11 20:25:08 +0900
commit8a3fd720e6dfe89193f80e450c043b40d95e1300 (patch)
tree240283b38f40d1ac7c269190fcb490b618287848
parent46754fd1dc25fb4e4c613c6eb0093b0a8550d31d (diff)
downloadlibtbm-vigs-8a3fd720e6dfe89193f80e450c043b40d95e1300.tar.gz
libtbm-vigs-8a3fd720e6dfe89193f80e450c043b40d95e1300.tar.bz2
libtbm-vigs-8a3fd720e6dfe89193f80e450c043b40d95e1300.zip
Share master fd with tdm backend and open fd if it needed
Change-Id: Ib211505186d342668d02eb8c3461fbf58053509a
-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);
}