#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <time.h>
#include "tdm_client.h"
#include "tdm_log.h"
struct list_head link;
struct wl_tdm_vblank *vblank;
tdm_client_vblank_handler func;
+ unsigned int req_sec;
+ unsigned int req_usec;
void *user_data;
} tdm_client_vblank_info;
{
tdm_private_client *private_client = (tdm_private_client*)client;
tdm_client_vblank_info *vblank_info;
+ struct timespec tp;
TDM_RETURN_VAL_IF_FAIL(name != NULL, TDM_CLIENT_ERROR_INVALID_PARAMETER);
TDM_RETURN_VAL_IF_FAIL(interval > 0, TDM_CLIENT_ERROR_INVALID_PARAMETER);
return TDM_CLIENT_ERROR_OUT_OF_MEMORY;
}
- vblank_info->vblank = wl_tdm_wait_vblank(private_client->tdm, name, interval);
+ clock_gettime(CLOCK_MONOTONIC, &tp);
+
+ vblank_info->req_sec = (unsigned int)tp.tv_sec;
+ vblank_info->req_usec = (unsigned int)(tp.tv_nsec/1000L);
+
+ vblank_info->vblank =
+ wl_tdm_wait_vblank(private_client->tdm, name, interval,
+ vblank_info->req_sec, vblank_info->req_usec);
if (!vblank_info->vblank) {
TDM_ERR("couldn't create vblank resource");
free(vblank_info);
%files tools
%manifest %{name}.manifest
-%{_bindir}/tdm-client
+%{_bindir}/tdm-test-client
%changelog
<arg name="id" type="new_id" interface="wl_tdm_vblank"/>
<arg name="name" type="string"/>
<arg name="interval" type="int"/>
+ <arg name="req_sec" type="uint"/>
+ <arg name="req_usec" type="uint"/>
</request>
</interface>
return 0;
}
+INTERN unsigned long
+tdm_helper_get_time_in_micros(void)
+{
+ struct timespec tp;
+
+ if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
+ return (tp.tv_sec * 1000000) + (tp.tv_nsec / 1000L);
+
+ return 0;
+}
+
static void
_tdm_helper_dump_raw(const char *file, void *data1, int size1, void *data2,
int size2, void *data3, int size3)
unsigned long
tdm_helper_get_time_in_millis(void);
+unsigned long
+tdm_helper_get_time_in_micros(void);
extern pthread_mutex_t tdm_mutex_check_lock;
extern int tdm_mutex_locked;
} tdm_server_vblank_info;
static tdm_private_server *keep_private_server;
+static int tdm_debug_server;
static void
_tdm_server_cb_output_vblank(tdm_output *output, unsigned int sequence,
return;
}
+ if (tdm_debug_server) {
+ unsigned long curr = tdm_helper_get_time_in_micros();
+ unsigned long vtime = (tv_sec * 1000000) + tv_usec;
+ if (curr - vtime > 1000) /* 1ms */
+ TDM_WRN("delay: %d us", (int)(curr - vtime));
+ }
+
TDM_DBG("wl_tdm_vblank@%d done", wl_resource_get_id(vblank_info->resource));
wl_tdm_vblank_send_done(vblank_info->resource, sequence, tv_sec, tv_usec);
static void
_tdm_server_cb_wait_vblank(struct wl_client *client,
struct wl_resource *resource,
- uint32_t id, const char *name, int32_t interval)
+ uint32_t id, const char *name, int32_t interval,
+ uint32_t req_sec, uint32_t req_usec)
{
tdm_private_loop *private_loop = wl_resource_get_user_data(resource);
tdm_private_server *private_server = private_loop->private_server;
return;
}
+ if (tdm_debug_server) {
+ unsigned long curr = tdm_helper_get_time_in_micros();
+ unsigned long reqtime = (req_sec * 1000000) + req_usec;
+ if (curr - reqtime > 1000) /* 1ms */
+ TDM_WRN("delay(req): %d us", (int)(curr - reqtime));
+ }
+
vblank_info->resource = vblank_resource;
vblank_info->private_server = private_server;
tdm_server_init(tdm_private_loop *private_loop)
{
tdm_private_server *private_server;
+ const char *debug;
+
+ debug = getenv("TDM_DEBUG_SERVER");
+ if (debug && (strstr(debug, "1")))
+ tdm_debug_server = 1;
if (private_loop->private_server)
return TDM_ERROR_NONE;
bin_PROGRAMS = \
- tdm-client
+ tdm-test-client
-tdm_client_SOURCES = \
+tdm_test_client_SOURCES = \
tdm_test_client.c
-tdm_client_LDFLAGS = ${LDFLAGS}
-tdm_client_CFLAGS = \
+tdm_test_client_LDFLAGS = ${LDFLAGS}
+tdm_test_client_CFLAGS = \
$(TDM_CFLAGS) \
-I$(top_srcdir)/include \
-I$(top_srcdir)/client
-tdm_client_LDADD = \
+tdm_test_client_LDADD = \
$(TDM_LIBS) \
$(top_builddir)/client/libtdm-client.la
if (vblank - prev > 16966 || vblank - prev < 16366) /* +0.3 ~ -0.3 ms */
printf("vblank : %d us\n", vblank - prev);
- if (client - vblank > 3000) /* 3ms */
+ if (client - vblank > 2000) /* 2ms */
printf("kernel -> tdm-client: %d us\n", client - vblank);
prev = vblank;