try, try again
[vdummy] / vdummy.c
index fcc68c0..9848db6 100644 (file)
--- a/vdummy.c
+++ b/vdummy.c
@@ -14,7 +14,7 @@
 #include <media/v4l2-event.h>
 
 struct buffer {
-       struct vb2_buffer vb;
+       struct vb2_v4l2_buffer vb;
        struct buffer *next;
 };
 
@@ -171,7 +171,7 @@ static void shutdown(void)
 static int ioctl_querycap(struct file *file, void *fh, struct v4l2_capability *cap)
 {
        strcpy(cap->driver, KBUILD_MODNAME);
-       strcpy(cap->card, "dummy v4l2 dev");
+       strcpy(cap->card, "Test V4L2 device");
        strcpy(cap->bus_info, "nobus");
        cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;
        cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
@@ -268,7 +268,6 @@ static int buf_prepare(struct vb2_buffer *vb)
                printk(KERN_ALERT "vdummy: buffer too small\n");
                return -EINVAL;
        }
-       vb2_set_plane_payload(vb, 0, frame_size);
        return 0;
 }
 
@@ -293,7 +292,7 @@ static void clear_queue(enum vb2_buffer_state st)
        while(buflist) {
                struct buffer *buf = buflist;
                buflist = buflist->next;
-               vb2_buffer_done(&buf->vb, st);
+               vb2_buffer_done(&buf->vb.vb2_buf, st);
        }
        buflist = buflist_tail = 0;
        spin_unlock(&blist_lock);
@@ -363,12 +362,13 @@ static int gen_frame(void)
        spin_unlock(&blist_lock);
 
        if(buf) {
-               memcpy(vb2_plane_vaddr(&buf->vb, 0), frame, frame_size);
+               memcpy(vb2_plane_vaddr(&buf->vb.vb2_buf, 0), frame, frame_size);
 
-               /*v4l2_get_timestamp(&buf->vb.v4l2_buf.timestamp);
-               buf->vb.v4l2_buf.sequence = seqno++;
-               buf->vb.v4l2_buf.field = V4L2_FIELD_NONE;*/
-               vb2_buffer_done(&buf->vb, VB2_BUF_STATE_DONE);
+               buf->vb.vb2_buf.timestamp = ktime_get_ns();
+               buf->vb.sequence = seqno++;
+               buf->vb.field = V4L2_FIELD_NONE;
+               vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
+               vb2_set_plane_payload(&buf->vb.vb2_buf, 0, frame_size);
        }
 
        return 0;