+static int queue_setup(struct vb2_queue *vbq, unsigned int *nbuf,
+ unsigned int *nplanes, unsigned int *sizes, void **alloc_ctx)
+{
+ if(vbq->num_buffers + *nbuf < 2) {
+ *nbuf = 2 - vbq->num_buffers;
+ }
+
+ *nplanes = 1;
+ sizes[0] = frame_size;
+ alloc_ctx[0] = 0;
+ return 0;
+}
+
+static int buf_prepare(struct vb2_buffer *vb)
+{
+ if(vb2_plane_size(vb, 0) < frame_size) {
+ printk(KERN_ALERT "vdummy: buffer too small\n");
+ return -EINVAL;
+ }
+ vb2_set_plane_payload(vb, 0, frame_size);
+ return 0;
+}
+
+static void buf_queue(struct vb2_buffer *vb)
+{
+ memcpy(vb2_plane_vaddr(vb, 0), frame, frame_size);
+ vb2_buffer_done(vb, VB2_BUF_STATE_DONE);
+}
+
+static int start_streaming(struct vb2_queue *vbq, unsigned int count)
+{
+ streaming = 1;
+ seqno = 0;
+ return 0;
+}
+
+static void stop_streaming(struct vb2_queue *vbq)
+{
+ streaming = 0;
+}
+