From 634a6900b971a09347ff36b684be8e91d5df1116 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Fri, 25 Mar 2016 14:19:06 +0900 Subject: [PATCH] Change environtment variable name for fd share with tdm Change-Id: I076bfdc381c6e3f9361fc059ca2a9730f0392821 Signed-off-by: Changyeon Lee --- src/tbm_drm_helper.h | 3 ++- src/tbm_drm_helper_server.c | 45 +++++++++++++++++++++++++++++++------ 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/tbm_drm_helper.h b/src/tbm_drm_helper.h index fdf4f81..0c93a37 100644 --- a/src/tbm_drm_helper.h +++ b/src/tbm_drm_helper.h @@ -35,7 +35,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. int tbm_drm_helper_wl_auth_server_init(void *wl_display, int fd, const char *device_name, uint32_t flags); void tbm_drm_helper_wl_auth_server_deinit(void); int tbm_drm_helper_get_master_fd(void); -void tbm_drm_helper_set_master_fd(int fd); +void tbm_drm_helper_set_tbm_master_fd(int fd); +void tbm_drm_helper_unset_tbm_master_fd(void); int tbm_drm_helper_get_auth_info(int *auth_fd, char **device, uint32_t *capabilities); diff --git a/src/tbm_drm_helper_server.c b/src/tbm_drm_helper_server.c index a77f2e8..5ddf991 100644 --- a/src/tbm_drm_helper_server.c +++ b/src/tbm_drm_helper_server.c @@ -201,9 +201,10 @@ int tbm_drm_helper_get_master_fd(void) { const char *value; - int ret, fd = -1; + int ret, flags, fd = -1; + int new_fd = -1; - value = (const char*)getenv("TIZEN_DRM_MASTER_FD"); + value = (const char*)getenv("TDM_DRM_MASTER_FD"); if (!value) return -1; @@ -211,25 +212,55 @@ tbm_drm_helper_get_master_fd(void) if (ret <= 0) return -1; - TBM_LOG("TIZEN_DRM_MASTER_FD: %d\n", fd); + TBM_LOG("TDM_DRM_MASTER_FD: %d\n", fd); - return fd; + flags = fcntl(fd, F_GETFD); + if (flags == -1) { + TBM_LOG("fcntl failed: %m"); + return -1; + } + + new_fd = dup(fd); + if (new_fd < 0) { + TBM_LOG("dup failed: %m"); + return -1; + } + + fcntl(new_fd, F_SETFD, flags|FD_CLOEXEC); + + TBM_LOG("Return MASTER_FD: %d\n", new_fd); + + return new_fd; } void -tbm_drm_helper_set_master_fd(int fd) +tbm_drm_helper_set_tbm_master_fd(int fd) { char buf[32]; int ret; snprintf(buf, sizeof(buf), "%d", fd); - ret = setenv("TIZEN_DRM_MASTER_FD", (const char*)buf, 1); + ret = setenv("TBM_DRM_MASTER_FD", (const char*)buf, 1); if (ret) { TBM_LOG("failed to set TIZEN_DRM_MASTER_FD to %d", fd); return; } - TBM_LOG("TIZEN_DRM_MASTER_FD: %d\n", fd); + TBM_LOG("TBM_DRM_MASTER_FD: %d\n", fd); } + +void +tbm_drm_helper_unset_tbm_master_fd(void) +{ + int ret; + + ret = unsetenv("TBM_DRM_MASTER_FD"); + if (ret) + { + TBM_LOG("failed to unset TBM_DRM_MASTER_FD"); + return; + } +} + -- 2.34.1