X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=vdummy;a=blobdiff_plain;f=vdummy.c;h=240d4f8c194dc5e9379374110e73ba3c08b48b2d;hp=a4d05b827789a01ddd77181763bc48862825a113;hb=refs%2Fheads%2Fmaster;hpb=d427a056fc21f60f596ce3bbdd2b5930f4fa09c4 diff --git a/vdummy.c b/vdummy.c index a4d05b8..240d4f8 100644 --- a/vdummy.c +++ b/vdummy.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -32,8 +33,15 @@ static int ioctl_get_parm(struct file *file, void *fh, struct v4l2_streamparm *f static int ioctl_set_parm(struct file *file, void *fh, struct v4l2_streamparm *fmt); static int ioctl_queryctl(struct file *file, void *fh, struct v4l2_queryctrl *ctl); +/* TODO find out exact version where this switched over */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,7,0) +#define ALLOC_CTX_TYPE void +#else +#define ALLOC_CTX_TYPE struct device +#endif + static int queue_setup(struct vb2_queue *vbq, unsigned int *nbuf, - unsigned int *nplanes, unsigned int *sizes, struct device **alloc_ctx); + unsigned int *nplanes, unsigned int *sizes, ALLOC_CTX_TYPE **alloc_ctx); static int buf_prepare(struct vb2_buffer *vb); static void buf_queue(struct vb2_buffer *vb); static int start_streaming(struct vb2_queue *vbq, unsigned int count); @@ -168,7 +176,7 @@ static int init(void) return res; } - printk(KERN_INFO "vdummy device initialized\n"); + printk(KERN_INFO "vdummy: initialized\n"); return 0; } @@ -301,7 +309,7 @@ static int ioctl_queryctl(struct file *file, void *fh, struct v4l2_queryctrl *ct } static int queue_setup(struct vb2_queue *vbq, unsigned int *nbuf, - unsigned int *nplanes, unsigned int *sizes, struct device **alloc_ctx) + unsigned int *nplanes, unsigned int *sizes, ALLOC_CTX_TYPE **alloc_ctx) { if(vbq->num_buffers + *nbuf < 2) { *nbuf = 2 - vbq->num_buffers; @@ -327,6 +335,7 @@ static void buf_queue(struct vb2_buffer *vb) struct buffer *buf = (struct buffer*)((char*)vb - offsetof(struct buffer, vb)); spin_lock(&blist_lock); + printk(KERN_INFO "vdummy: enqueue buffer\n"); if(buflist) { buflist_tail->next = buf; buflist_tail = buf; @@ -339,14 +348,20 @@ static void buf_queue(struct vb2_buffer *vb) static void clear_queue(enum vb2_buffer_state st) { + struct buffer *list; + + printk(KERN_INFO "vdummy: clear_queue\n"); + spin_lock(&blist_lock); - while(buflist) { - struct buffer *buf = buflist; - buflist = buflist->next; - vb2_buffer_done(&buf->vb.vb2_buf, st); - } + list = buflist; buflist = buflist_tail = 0; spin_unlock(&blist_lock); + + while(list) { + struct buffer *buf = list; + list = list->next; + vb2_buffer_done(&buf->vb.vb2_buf, st); + } } static int start_streaming(struct vb2_queue *vbq, unsigned int count) @@ -363,12 +378,15 @@ static int start_streaming(struct vb2_queue *vbq, unsigned int count) frame_interval = ktime_set(0, 1000000000ul / (unsigned long)framerate); } + printk(KERN_INFO "vdummy: start streaming (interval: %ld ms)\n", + (long)ktime_to_ms(frame_interval)); hrtimer_start(&timer, frame_interval, HRTIMER_MODE_REL); return 0; } static void stop_streaming(struct vb2_queue *vbq) { + printk(KERN_INFO "vdummy: stop streaming\n"); hrtimer_cancel(&timer); streaming = 0; @@ -416,6 +434,8 @@ static int gen_frame(void) struct buffer *buf = 0; unsigned long flags; + printk(KERN_INFO "vdummy: gen_frame\n"); + spin_lock_irqsave(&blist_lock, flags); if(buflist) { buf = buflist; @@ -440,6 +460,7 @@ static int gen_frame(void) enum hrtimer_restart timer_func(struct hrtimer *timer) { - gen_frame(); + printk(KERN_INFO "vdummy: timer!\n"); + //gen_frame(); return streaming ? HRTIMER_RESTART : HRTIMER_NORESTART; }