+void
+nouveau_context_init_vdec(struct nouveau_context *);
+
+void
+nouveau_context_init(struct nouveau_context *);
+
+void
+nouveau_scratch_runout_release(struct nouveau_context *);
+
+/* This is needed because we don't hold references outside of context::scratch,
+ * because we don't want to un-bo_ref each allocation every time. This is less
+ * work, and we need the wrap index anyway for extreme situations.
+ */
+static inline void
+nouveau_scratch_done(struct nouveau_context *nv)
+{
+ nv->scratch.wrap = nv->scratch.id;
+ if (unlikely(nv->scratch.runout))
+ nouveau_scratch_runout_release(nv);
+}
+
+/* Get pointer to scratch buffer.
+ * The returned nouveau_bo is only referenced by the context, don't un-ref it !
+ */
+void *
+nouveau_scratch_get(struct nouveau_context *, unsigned size, uint64_t *gpu_addr,
+ struct nouveau_bo **);
+
+static inline void
+nouveau_context_destroy(struct nouveau_context *ctx)
+{
+ int i;
+
+ for (i = 0; i < NOUVEAU_MAX_SCRATCH_BUFS; ++i)
+ if (ctx->scratch.bo[i])
+ nouveau_bo_ref(NULL, &ctx->scratch.bo[i]);
+
+ FREE(ctx);
+}
+
+static inline void
+nouveau_context_update_frame_stats(struct nouveau_context *nv)
+{
+ nv->stats.buf_cache_frame <<= 1;
+ if (nv->stats.buf_cache_count) {
+ nv->stats.buf_cache_count = 0;
+ nv->stats.buf_cache_frame |= 1;
+ if ((nv->stats.buf_cache_frame & 0xf) == 0xf)
+ nv->screen->hint_buf_keep_sysmem_copy = true;
+ }
+}
+