fd = open(tbm_drm_auth_srv->device_name, O_RDWR);
if (fd != -1) {
if (fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC) == -1) {
- TBM_LOG_E("failed to set fd\n");
+ TBM_ERR("failed to set fd\n");
goto fini;
}
}
}
if (fd < 0) {
- TBM_LOG_E("failed to open drm : device_name, %s\n", tbm_drm_auth_srv->device_name);
+ TBM_ERR("failed to open drm : device_name, %s\n", tbm_drm_auth_srv->device_name);
wl_resource_post_error(resource, WL_TBM_DRM_AUTH_ERROR_AUTHENTICATE_FAIL,
"authenicate failed::open_drm");
if (drmGetMagic(fd, &magic) < 0) {
if (errno != EACCES) {
- TBM_LOG_E("failed to get magic\n");
+ TBM_ERR("failed to get magic\n");
wl_resource_post_error(resource, WL_TBM_DRM_AUTH_ERROR_AUTHENTICATE_FAIL,
"authenicate failed::get_magic");
}
if (drmAuthMagic(tbm_drm_auth_srv->fd, magic) < 0) {
- TBM_LOG_E("failed to authenticate magic\n");
+ TBM_ERR("failed to authenticate magic\n");
wl_resource_post_error(resource, WL_TBM_DRM_AUTH_ERROR_AUTHENTICATE_FAIL,
"authenicate failed::auth_magic");
buf = calloc(1, buf_len * sizeof(char));
if (!buf) {
- TBM_LOG_E("creating buffer failed\n");
+ TBM_ERR("creating buffer failed\n");
goto failed;
}
grp = calloc(1, sizeof(struct group));
if (!grp) {
- TBM_LOG_E("creating group failed\n");
+ TBM_ERR("creating group failed\n");
goto failed;
}
ret = getgrnam_r(name, grp, buf, buf_len, &grp_res);
if (ret < 0) {
- TBM_LOG_E("getgrnam_r failed errno:%d(%m)\n", ret);
+ TBM_ERR("getgrnam_r failed errno:%d(%m)\n", ret);
goto failed;
}
if (grp_res == NULL) {
- TBM_LOG_E("finding name:%s group failed\n", name);
+ TBM_ERR("finding name:%s group failed\n", name);
goto failed;
}
dir = getenv("XDG_RUNTIME_DIR");
if (!dir) {
- TBM_LOG_W("getting XDG_RUNTIME_DIR failed\n");
+ TBM_WRN("getting XDG_RUNTIME_DIR failed\n");
return;
}
ret = chmod(socket_path, 509);
if (ret < 0) {
- TBM_LOG_W("changing modes of socket file failed:%s (%m)\n", socket_path);
+ TBM_WRN("changing modes of socket file failed:%s (%m)\n", socket_path);
return;
}
ret = _tbm_getgrnam_r("root");
if (ret < 0) {
- TBM_LOG_W("getting uid failed\n");
+ TBM_WRN("getting uid failed\n");
return;
}
uid = ret;
ret = _tbm_getgrnam_r("display");
if (ret < 0) {
- TBM_LOG_W("getting gid failed\n");
+ TBM_WRN("getting gid failed\n");
return;
}
gid = ret;
ret = chown(socket_path, uid, gid);
if (ret < 0) {
- TBM_LOG_W("changing owner of socket file failed:%s (%m)\n", socket_path);
+ TBM_WRN("changing owner of socket file failed:%s (%m)\n", socket_path);
return;
}
}
int
-tbm_drm_helper_wl_auth_server_init(void *wl_display, int fd, const char *device_name, uint32_t flags)
+tbm_drm_helper_wl_auth_server_init(void *wl_display, int fd, const char *device_name, uint32_t flags)
{
if (!tbm_drm_auth_srv) {
TBM_RETURN_VAL_IF_FAIL(wl_display != NULL, 0);
TBM_RETURN_VAL_IF_FAIL(tbm_drm_auth_srv != NULL, 0);
tbm_drm_auth_srv->display = (struct wl_display *)wl_display;
- tbm_drm_auth_srv->device_name = strdup(device_name);
+ if (!device_name) {
+ tbm_drm_auth_srv->device_name = drmGetDeviceNameFromFd(fd);
+ if (!tbm_drm_auth_srv->device_name) {
+ TBM_ERR("fail to get device name!\n");
+ return 0;
+ }
+ } else {
+ tbm_drm_auth_srv->device_name = strdup(device_name);
+ }
tbm_drm_auth_srv->fd = fd;
tbm_drm_auth_srv->flags = flags;
if (wl_display_add_socket(tbm_drm_auth_srv->display, "tbm-drm-auth")) {
- TBM_LOG_E("[TBM_DRM] fail to add socket\n");
+ TBM_ERR("[TBM_DRM] fail to add socket\n");
if (tbm_drm_auth_srv->device_name)
free(tbm_drm_auth_srv->device_name);
{
int new_fd, flags, fd = -1;
-#if 1 /* TODO: can't remove below at this time. This code SHOULD be removed later */
- const char *value = (const char*)getenv("TDM_DRM_MASTER_FD");
- if (value) {
- char *end;
- const long int sl = strtol(value, &end, 10);
-
- if (end == value) {
- TBM_LOG_E("%s: not a decimal number\n", value);
- return -1;
- } else if (*end != '\0') {
- TBM_LOG_E("%s: extra characters at end of input: %s\n", value, end);
- return -1;
- } else if ((sl == LONG_MIN || sl == LONG_MAX) && errno == ERANGE) {
- TBM_LOG_E("%s out of range of type long\n", value);
- return -1;
- } else if (sl >= INT_MAX) {
- TBM_LOG_E("%ld greater than INT_MAX\n", sl);
- return -1;
- } else if (sl <= INT_MIN) {
- TBM_LOG_E("%ld less than INT_MIN\n", sl);
- return -1;
- } else {
- int fd_max = tbm_bufmgr_get_fd_limit();
- fd = (int)sl;
- if (fd < 0 || fd > fd_max) {
- TBM_LOG_E("%d out of fd range\n", fd);
- return -1;
- }
- }
- } else
-#endif
fd = tbm_drm_master_fd;
-
if (fd == -1) {
- TBM_LOG_I("no presetted TBM DRM MASTER FD");
+ TBM_INFO("no presetted TBM DRM MASTER FD");
return -1;
}
- TBM_LOG_I("TBM DRM MASTER FD: %d\n", fd);
+ TBM_INFO("TBM DRM MASTER FD: %d\n", fd);
flags = fcntl(fd, F_GETFD);
if (flags == -1) {
- TBM_LOG_E("fcntl failed: %m");
+ TBM_ERR("fcntl failed: %m");
return -1;
}
new_fd = dup(fd);
if (new_fd < 0) {
- TBM_LOG_E("dup failed: %m");
+ TBM_ERR("dup failed: %m");
return -1;
}
if (fcntl(new_fd, F_SETFD, flags|FD_CLOEXEC) == -1) {
- TBM_LOG_E("failed to set fd\n");
+ TBM_ERR("failed to set fd\n");
close(new_fd);
return -1;
}
- TBM_LOG_I("Return MASTER_FD: %d\n", new_fd);
+ TBM_INFO("Return MASTER_FD: %d\n", new_fd);
return new_fd;
}
return;
if (fd < 0 || fd > fd_max) {
- TBM_LOG_E("%d out of fd range\n", fd);
+ TBM_ERR("%d out of fd range\n", fd);
return;
}
if (tbm_drm_master_fd != -1)
- TBM_LOG_W("already has TBM DRM MASTER FD: %d\n", tbm_drm_master_fd);
+ TBM_WRN("already has TBM DRM MASTER FD: %d\n", tbm_drm_master_fd);
tbm_drm_master_fd = fd;
- TBM_LOG_I("TBM DRM MASTER FD: %d\n", tbm_drm_master_fd);
+ TBM_INFO("TBM DRM MASTER FD: %d\n", tbm_drm_master_fd);
}
void
tbm_drm_helper_unset_tbm_master_fd(void)
{
tbm_drm_master_fd = -1;
- TBM_LOG_I("TBM DRM MASTER FD: %d\n", tbm_drm_master_fd);
+ TBM_INFO("TBM DRM MASTER FD: %d\n", tbm_drm_master_fd);
}
/* LCOV_EXCL_STOP */