flip_test: switch to using monotonic timestamps (v2)

Since monotonic timestamps are now the preferred time format, change
timestamps checks to compare against monotonic instead of real time.
Also add two tests for DRM's compatibility mode where it returns real
timestamps.

v2: drop the tests for the compatibilty mode (Daniel)

Signed-off-by: Imre Deak <imre.deak@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
Imre Deak 2012-11-22 16:46:36 +02:00 committed by Daniel Vetter
parent b7067d6c10
commit 314953117f

View File

@ -57,12 +57,17 @@
#define EVENT_FLIP (1 << 0)
#define EVENT_VBLANK (1 << 1)
#ifndef DRM_CAP_TIMESTAMP_MONOTONIC
#define DRM_CAP_TIMESTAMP_MONOTONIC 6
#endif
drmModeRes *resources;
int drm_fd;
static drm_intel_bufmgr *bufmgr;
struct intel_batchbuffer *batch;
uint32_t devid;
int test_time = 3;
static bool monotonic_timestamp;
uint32_t *fb_ptr;
@ -296,7 +301,19 @@ analog_tv_connector(struct test_output *o)
static void event_handler(struct event_state *es, unsigned int frame,
unsigned int sec, unsigned int usec)
{
gettimeofday(&es->current_received_ts, NULL);
struct timeval now;
if (monotonic_timestamp) {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
now.tv_sec = ts.tv_sec;
now.tv_usec = ts.tv_nsec / 1000;
} else {
gettimeofday(&now, NULL);
}
es->current_received_ts = now;
es->current_ts.tv_sec = sec;
es->current_ts.tv_usec = usec;
es->current_seq = frame;
@ -933,6 +950,18 @@ static int run_test(int duration, int flags, const char *test_name)
return 1;
}
static void get_timestamp_format(void)
{
uint64_t cap_mono;
int ret;
ret = drmGetCap(drm_fd, DRM_CAP_TIMESTAMP_MONOTONIC, &cap_mono);
assert(ret == 0 || errno == EINVAL);
monotonic_timestamp = ret == 0 && cap_mono == 1;
printf("Using %s timestamps\n",
monotonic_timestamp ? "monotonic" : "real");
}
int main(int argc, char **argv)
{
struct {
@ -975,6 +1004,8 @@ int main(int argc, char **argv)
drm_fd = drm_open_any();
get_timestamp_format();
bufmgr = drm_intel_bufmgr_gem_init(drm_fd, 4096);
devid = intel_get_drm_devid(drm_fd);
batch = intel_batchbuffer_alloc(bufmgr, devid);