+ grdev_pipe_schedule(pipe, 0);
+ session_frame(display->session, display);
+}
+
+void grdev_pipe_schedule(grdev_pipe *pipe, uint64_t frames) {
+ int r;
+ uint64_t ts;
+
+ if (!frames) {
+ sd_event_source_set_enabled(pipe->vsync_src, SD_EVENT_OFF);
+ return;
+ }
+
+ r = sd_event_now(pipe->card->session->context->event, CLOCK_MONOTONIC, &ts);
+ if (r < 0)
+ goto error;
+
+ ts += frames * USEC_PER_MSEC * 1000ULL / pipe->vrefresh;
+
+ r = sd_event_source_set_time(pipe->vsync_src, ts);
+ if (r < 0)
+ goto error;
+
+ r = sd_event_source_set_enabled(pipe->vsync_src, SD_EVENT_ONESHOT);
+ if (r < 0)
+ goto error;
+
+ return;
+
+error:
+ log_debug("grdev: %s/%s/%s: cannot schedule vsync timer: %s",
+ pipe->card->session->name, pipe->card->name, pipe->name, strerror(-r));