#include "config.h"
#endif
-#include "tdm.h"
+#include <tdm-server-protocol.h>
+
#include "tdm_private.h"
-#include "tdm_list.h"
-#include "tdm-server-protocol.h"
/* CAUTION:
* - tdm server doesn't care about thread things.
fclose(h);
}
-static tdm_output*
-_tdm_server_find_output(tdm_private_server *private_server, const char *name)
-{
- tdm_private_loop *private_loop = private_server->private_loop;
- tdm_output *found = NULL;
-
- if (!strncasecmp(name, "primary", 7) || !strncasecmp(name, "default", 7))
- found = tdm_display_get_output(private_loop->dpy, 0, NULL);
-
- if (!found) {
- int count = 0, i;
-
- tdm_display_get_output_count(private_loop->dpy, &count);
-
- for (i = 0; i < count; i++) {
- tdm_output *output = tdm_display_get_output(private_loop->dpy, i, NULL);
- tdm_output_conn_status status;
- const char *model = NULL;
- tdm_error ret;
-
- ret = tdm_output_get_conn_status(output, &status);
- if (ret || status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED)
- continue;
-
- ret = tdm_output_get_model_info(output, NULL, &model, NULL);
- if (ret || !model)
- continue;
-
- if (strncmp(model, name, TDM_NAME_LEN))
- continue;
-
- found = output;
- break;
- }
- }
-
- return found;
-}
-
/* LCOV_EXCL_START */
static void
_tdm_server_send_done(tdm_server_wait_info *wait_info, tdm_error error,
tdm_server_wait_info *found;
tdm_server_vblank_info *vblank_info;
- if (!keep_private_server)
- return;
+ TDM_RETURN_IF_FAIL(keep_private_server != NULL);
LIST_FIND_ITEM(wait_info, &keep_private_server->wait_list,
tdm_server_wait_info, link, found);
if (!found) {
- TDM_DBG("wait_info(%p) is destroyed", wait_info);
+ TDM_ERR("wait_info(%p) is destroyed", wait_info);
return;
}
TDM_DBG("req_id(%d) done", wait_info->req_id);
vblank_info = wait_info->vblank_info;
+
+ if (tdm_ttrace_module & TDM_TTRACE_SERVER_VBLANK)
+ TDM_TRACE_ASYNC_END((int)wait_info->req_time, "TDM_Server_Vblank:%u", vblank_info->stamp);
+
wl_tdm_vblank_send_done(vblank_info->resource, wait_info->req_id,
sequence, tv_sec, tv_usec, error);
if (tdm_debug_module & TDM_DEBUG_VBLANK)
TDM_DBG("req_id(%d) wait", req_id);
+ if (tdm_ttrace_module & TDM_TTRACE_SERVER_VBLANK)
+ TDM_TRACE_ASYNC_BEGIN((int)wait_info->req_time, "TDM_Server_Vblank:%u", vblank_info->stamp);
+
ret = tdm_vblank_wait(vblank_info->vblank, req_sec, req_usec, interval, _tdm_server_cb_vblank, wait_info);
tdm_vblank_get_enable_fake(vblank_info->vblank, &enable_fake);
if (tdm_debug_module & TDM_DEBUG_VBLANK)
TDM_DBG("req_id(%d) wait", req_id);
+ if (tdm_ttrace_module & TDM_TTRACE_SERVER_VBLANK)
+ TDM_TRACE_ASYNC_BEGIN((int)wait_info->req_time, "TDM_Server_Vblank:%u", vblank_info->stamp);
+
ret = tdm_vblank_wait_seq(vblank_info->vblank, req_sec, req_usec, sequence, _tdm_server_cb_vblank, wait_info);
tdm_vblank_get_enable_fake(vblank_info->vblank, &enable_fake);
wl_tdm_vblank_send_stamp(vblank_info->resource, vblank_info->stamp);
- if (tdm_ttrace_module & TDM_TTRACE_CLIENT) {
+ if (tdm_ttrace_module & TDM_TTRACE_CLIENT_VBLANK) {
tdm_output *output = tdm_display_get_output(private_loop->dpy, tdm_ttrace_output, NULL);
if (output == output_info->output)
wl_tdm_vblank_send_ttrace(vblank_info->resource, 1);
tdm_output_conn_status status = TDM_OUTPUT_CONN_STATUS_DISCONNECTED;
tdm_error ret;
- output = _tdm_server_find_output(private_server, name);
+ output = tdm_display_find_output(private_server->private_loop->dpy, name, NULL);
if (!output) {
/* LCOV_EXCL_START */
}
/* LCOV_EXCL_STOP */
-/* LCOV_EXCL_START */
-static void
-_tdm_server_cb_set_client_vblank_fps(struct wl_client *client, struct wl_resource *resource,
- unsigned int pid, const char *name, unsigned int fps)
-{
- tdm_error ret = tdm_vblank_set_client_vblank_fps(pid, name, fps);
- TDM_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
-
- TDM_INFO("'%s' vblank fps(PID: '%u'): %u", name, pid, fps);
-}
-/* LCOV_EXCL_STOP */
-
static const struct wl_tdm_interface tdm_implementation = {
_tdm_server_cb_debug,
_tdm_server_cb_create_output,
- _tdm_server_cb_set_client_vblank_fps,
};
static void
wl_resource_set_implementation(resource, &tdm_implementation, data, destroy_client);
}
-static int
-_tdm_getgrnam_r(const char *name)
-{
- struct group *grp = NULL;
- struct group *grp_res = NULL;
- char* buf = NULL;
- size_t buf_len;
- int ret;
- int id;
-
- buf_len = sysconf(_SC_GETGR_R_SIZE_MAX);
- if (buf_len == -1)
- buf_len = 2048;
-
- buf = calloc(1, buf_len * sizeof(char));
- if (!buf) {
- TDM_ERR("creating buffer failed");
- goto failed;
- }
-
- grp = calloc(1, sizeof(struct group));
- if (!grp) {
- TDM_ERR("creating group failed");
- goto failed;
- }
-
- ret = getgrnam_r(name, grp, buf, buf_len, &grp_res);
- if (ret < 0) {
- TDM_ERR("getgrnam_r failed errno:%d(%m)", ret);
- goto failed;
- }
-
- if (grp_res == NULL) {
- TDM_ERR("finding name:%s group failed", name);
- goto failed;
- }
-
- id = grp->gr_gid;
- free(buf);
- free(grp);
-
- return id;
-
-failed:
- /* LCOV_EXCL_START */
-
- if (buf)
- free(buf);
- if (grp)
- free(grp);
-
- return -1;
-
- /* LCOV_EXCL_STOP */
-}
-
-static void
-_tdm_socket_init(tdm_private_loop *private_loop)
-{
- const char *dir = NULL;
- char socket_path[TDM_NAME_LEN * 2];
- int ret = -1;
- uid_t uid;
- gid_t gid;
-
- dir = getenv("XDG_RUNTIME_DIR");
- if (!dir) {
- /* LCOV_EXCL_START */
-
- TDM_WRN("getting XDG_RUNTIME_DIR failed");
- return;
-
- /* LCOV_EXCL_STOP */
- }
-
- strncpy(socket_path, dir, TDM_NAME_LEN - 1);
- socket_path[TDM_NAME_LEN - 1] = '\0';
-
- strncat(socket_path, "/tdm-socket", 11);
- socket_path[TDM_NAME_LEN + 10] = '\0';
-
- ret = chmod(socket_path, 509);
- if (ret < 0) {
- /* LCOV_EXCL_START */
-
- TDM_WRN("changing modes of socket file failed:%s (%m)", socket_path);
- return;
-
- /* LCOV_EXCL_STOP */
- }
-
- ret = _tdm_getgrnam_r("root");
- if (ret < 0) {
- /* LCOV_EXCL_START */
-
- TDM_WRN("getting uid failed");
- return;
-
- /* LCOV_EXCL_STOP */
- }
- uid = ret;
-
- ret = _tdm_getgrnam_r("display");
- if (ret < 0) {
- /* LCOV_EXCL_START */
-
- TDM_WRN("getting gid failed");
- return;
-
- /* LCOV_EXCL_STOP */
- }
- gid = ret;
-
- ret = chown(socket_path, uid, gid);
- if (ret < 0) {
- /* LCOV_EXCL_START */
-
- TDM_WRN("changing owner of socket file failed:%s (%m)", socket_path);
- return;
-
- /* LCOV_EXCL_STOP */
- }
-}
-
INTERN tdm_error
tdm_server_init(tdm_private_loop *private_loop)
{
/* LCOV_EXCL_STOP */
}
- _tdm_socket_init(private_loop);
-
private_server = calloc(1, sizeof * private_server);
if (!private_server) {
TDM_ERR("alloc failed");