tests/flip_test: measure inter-frame ts jitter

Yell if it's wrong.

For some odd reason this blows up on my snb. And always on the same
o->count frame on the 2nd crtc ... And we have to thank the hpd poll
helper for that. Comment explaining this added, also made the error
non-fatal.
This commit is contained in:
Daniel Vetter 2012-10-02 19:33:30 +02:00
parent 87f7dccab6
commit 400535e82f

View File

@ -72,7 +72,8 @@ struct test_output {
unsigned int current_fb_id;
unsigned int fb_ids[2];
struct kmstest_fb fb_info[2];
struct timeval last_flip;
struct timeval last_flip_received;
struct timeval last_flip_ts;
};
static void emit_dummy_load(struct test_output *o)
@ -157,6 +158,7 @@ static void page_flip_handler(int fd, unsigned int frame, unsigned int sec,
struct test_output *o = data;
unsigned int new_fb_id;
struct timeval now, diff, pageflip_ts;
double usec_interflip;
pageflip_ts.tv_sec = sec;
pageflip_ts.tv_usec = usec;
@ -171,11 +173,24 @@ static void page_flip_handler(int fd, unsigned int frame, unsigned int sec,
exit(5);
}
if (!timercmp(&o->last_flip, &pageflip_ts, <)) {
if (!timercmp(&o->last_flip_received, &pageflip_ts, <)) {
fprintf(stderr, "pageflip ts before the pageflip was issued!\n");
exit(6);
}
if (o->count > 1 && o->flags == 0) {
timersub(&pageflip_ts, &o->last_flip_ts, &diff);
usec_interflip = 1.0 / ((double) o->mode.vrefresh) * 1000.0 * 1000.0;
if (fabs((((double) diff.tv_usec) - usec_interflip) / usec_interflip) > 0.005) {
fprintf(stderr, "inter-flip timestamp jitter: %is, %ius\n",
(int) diff.tv_sec, (int) diff.tv_usec);
/* atm this is way too easy to hit, thanks to the hpd
* poll helper :( hence make it non-fatal for now */
//exit(9);
}
}
o->count++;
o->current_fb_id = !o->current_fb_id;
@ -216,7 +231,8 @@ static void page_flip_handler(int fd, unsigned int frame, unsigned int sec,
}
}
o->last_flip = now;
o->last_flip_received = now;
o->last_flip_ts = pageflip_ts;
}
static void connector_find_preferred_mode(struct test_output *o, int crtc_id)
@ -407,7 +423,7 @@ static void flip_mode(struct test_output *o, int crtc, int duration)
evctx.page_flip_handler = page_flip_handler;
gettimeofday(&end, NULL);
gettimeofday(&o->last_flip, NULL);
gettimeofday(&o->last_flip_received, NULL);
end.tv_sec += duration;
while (1) {