+static grdev_fb *grdrm_pipe_target(grdev_pipe *basepipe) {
+ grdrm_fb *fb;
+ size_t i;
+
+ if (!basepipe->back) {
+ for (i = 0; i < basepipe->max_fbs; ++i) {
+ if (!basepipe->fbs[i])
+ continue;
+
+ fb = fb_from_base(basepipe->fbs[i]);
+ if (&fb->base == basepipe->front)
+ continue;
+ if (basepipe->flipping && fb->flipid)
+ continue;
+
+ basepipe->back = &fb->base;
+ break;
+ }
+ }
+
+ return basepipe->back;
+}
+