From 1be928bc03b7e8fe9406d5576230507581a22714 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Mon, 29 Feb 2016 13:45:23 +0900 Subject: [PATCH] Fix some bug in tbm_drm_helper Change-Id: Ib9d77d8e834c8635a373a217e84887c89b8bc60f --- src/tbm_bufmgr.c | 3 +++ src/tbm_drm_helper_client.c | 23 ++++++++++++----------- src/tbm_drm_helper_server.c | 4 ++-- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/tbm_bufmgr.c b/src/tbm_bufmgr.c index 4895ca7..6ae70ea 100644 --- a/src/tbm_bufmgr.c +++ b/src/tbm_bufmgr.c @@ -1841,6 +1841,9 @@ tbm_bufmgr_bind_native_display(tbm_bufmgr bufmgr, void *NativeDisplay) pthread_mutex_lock(&bufmgr->lock); + if (!bufmgr->backend->bufmgr_bind_native_display) + return 0; + ret = bufmgr->backend->bufmgr_bind_native_display(bufmgr, NativeDisplay); if (!ret) { pthread_mutex_unlock(&bufmgr->lock); diff --git a/src/tbm_drm_helper_client.c b/src/tbm_drm_helper_client.c index 4e2eaf1..1965c8f 100644 --- a/src/tbm_drm_helper_client.c +++ b/src/tbm_drm_helper_client.c @@ -59,7 +59,7 @@ handle_tbm_drm_authentication_info(void *data, struct wl_tbm_drm *wl_tbm_drm, co tbm_drm_client->auth_fd = auth_fd; tbm_drm_client->capabilities = capabilities; if (device_name) - tbm_drm_client->device = strndup(device_name, 256); + tbm_drm_client->device = strdup(device_name); } static const struct wl_tbm_drm_listener wl_tbm_drm_client_listener = { @@ -76,9 +76,6 @@ _wayland_tbm_drm_client_registry_handle_global(void *data, struct wl_registry *r TBM_RETURN_IF_FAIL(tbm_drm_client->wl_tbm_drm != NULL); wl_tbm_drm_add_listener(tbm_drm_client->wl_tbm_drm, &wl_tbm_drm_client_listener, tbm_drm_client); - - wl_tbm_drm_get_authentication_info(tbm_drm_client->wl_tbm_drm); - wl_display_roundtrip(tbm_drm_client->display); } } @@ -88,7 +85,7 @@ static const struct wl_registry_listener registry_listener = { }; int -wayland_tbm_drm_client_get_auth_info(int *auth_fd, char **device, uint32_t *capabilities) +tbm_drm_helper_get_auth_info(int *auth_fd, char **device, uint32_t *capabilities) { struct wl_display *display; struct wl_registry *wl_registry; @@ -111,15 +108,17 @@ wayland_tbm_drm_client_get_auth_info(int *auth_fd, char **device, uint32_t *capa wl_registry = wl_display_get_registry(display); if (!wl_registry) { - TBM_LOG("Failed to connect display\n"); + TBM_LOG("Failed to get registry\n"); wl_display_disconnect(display); free(tbm_drm_client); return 0; } - wl_registry_add_listener(wl_registry, ®istry_listener, &tbm_drm_client); + wl_registry_add_listener(wl_registry, ®istry_listener, tbm_drm_client); wl_display_roundtrip(display); //For Gloabl registry + wl_tbm_drm_get_authentication_info(tbm_drm_client->wl_tbm_drm); + wl_display_roundtrip(display); if (!tbm_drm_client->wl_tbm_drm) { TBM_LOG("Failed to get wl_tbm_drm interface\n"); @@ -149,10 +148,12 @@ wayland_tbm_drm_client_get_auth_info(int *auth_fd, char **device, uint32_t *capa if (capabilities) *capabilities = tbm_drm_client->capabilities; - if (tbm_drm_client->device && device) - *device = strdup(tbm_drm_client->device); - else - *device = NULL; + if (device) { + if (tbm_drm_client->device) + *device = strdup(tbm_drm_client->device); + else + *device = NULL; + } wl_tbm_drm_set_user_data(tbm_drm_client->wl_tbm_drm, NULL); wl_tbm_drm_destroy(tbm_drm_client->wl_tbm_drm); diff --git a/src/tbm_drm_helper_server.c b/src/tbm_drm_helper_server.c index 7dbb7a5..cd4b1ff 100644 --- a/src/tbm_drm_helper_server.c +++ b/src/tbm_drm_helper_server.c @@ -163,8 +163,8 @@ tbm_drm_helper_wl_server_init(void *wl_display, int fd, const char *device_nam tbm_drm_srv->fd = fd; tbm_drm_srv->flags = flags; - if(!wl_display_add_socket(tbm_drm_srv->display, "tbm_drm")) { - TBM_LOG("[WL_TBM] fail to add socket"); + if(wl_display_add_socket(tbm_drm_srv->display, "tbm_drm")) { + TBM_LOG("[TBM_DRM] fail to add socket\n"); if (tbm_drm_srv->device_name) free(tbm_drm_srv->device_name); -- 2.7.4