diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-12-13 14:30:14 -0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-12-13 14:30:14 -0200 |
commit | 96670291ffbd33cc0cd84ab417e0bb77678bb482 (patch) | |
tree | 889334f832d86e30f5f408dced91851ccfd705f7 /linux/drivers/media/video/vivi.c | |
parent | b2a759d38e59944cf3c0789068025f0c42b85529 (diff) | |
download | mediapointer-dvb-s2-96670291ffbd33cc0cd84ab417e0bb77678bb482.tar.gz mediapointer-dvb-s2-96670291ffbd33cc0cd84ab417e0bb77678bb482.tar.bz2 |
Fix vivi internal debug messages
From: Mauro Carvalho Chehab <mchehab@infradead.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'linux/drivers/media/video/vivi.c')
-rw-r--r-- | linux/drivers/media/video/vivi.c | 109 |
1 files changed, 67 insertions, 42 deletions
diff --git a/linux/drivers/media/video/vivi.c b/linux/drivers/media/video/vivi.c index 01d5044ca..7a38637ec 100644 --- a/linux/drivers/media/video/vivi.c +++ b/linux/drivers/media/video/vivi.c @@ -63,7 +63,6 @@ /* Declare static vars that will be used as parameters */ static unsigned int vid_limit = 16; /* Video memory limit, in Mb */ -static struct video_device vivi; /* Video device */ static int video_nr = -1; /* /dev/videoN, -1 for autodetect */ static int n_devs = 1; /* Number of virtual devices */ @@ -119,9 +118,9 @@ static struct v4l2_queryctrl vivi_qctrl[] = { static int qctl_regs[ARRAY_SIZE(vivi_qctrl)]; -#define dprintk(level, fmt, arg...) \ +#define dprintk(dev, level, fmt, arg...) \ do { \ - if (vivi.debug >= (level)) \ + if (dev->vfd->debug >= (level)) \ printk(KERN_DEBUG "vivi: " fmt , ## arg); \ } while (0) @@ -355,7 +354,7 @@ static void vivi_fillbuff(struct vivi_dev *dev, struct vivi_buffer *buf) dev->timestr); /* FIXME: replacing to __copy_to_user */ if (copy_to_user(vbuf + pos, tmpbuf, wmax * 2) != 0) - dprintk(2, "vivifill copy_to_user failed.\n"); + dprintk(dev, 2, "vivifill copy_to_user failed.\n"); pos += wmax*2; } @@ -384,8 +383,8 @@ static void vivi_fillbuff(struct vivi_dev *dev, struct vivi_buffer *buf) sprintf(dev->timestr, "%02d:%02d:%02d:%03d", dev->h, dev->m, dev->s, (dev->us + 500) / 1000); - dprintk(2, "vivifill at %s: Buffer 0x%08lx size= %d\n", dev->timestr, - (unsigned long)tmpbuf, pos); + dprintk(dev, 2, "vivifill at %s: Buffer 0x%08lx size= %d\n", + dev->timestr, (unsigned long)tmpbuf, pos); /* Advice that buffer was filled */ buf->vb.state = VIDEOBUF_DONE; @@ -409,7 +408,7 @@ static void vivi_thread_tick(struct vivi_dmaqueue *dma_q) /* Announces videobuf that all went ok */ for (bc = 0;; bc++) { if (list_empty(&dma_q->active)) { - dprintk(1, "No active queue to serve\n"); + dprintk(dev, 1, "No active queue to serve\n"); break; } @@ -423,7 +422,7 @@ static void vivi_thread_tick(struct vivi_dmaqueue *dma_q) } do_gettimeofday(&buf->vb.ts); - dprintk(2, "[%p/%d] wakeup\n", buf, buf->vb. i); + dprintk(dev, 2, "[%p/%d] wakeup\n", buf, buf->vb. i); /* Fill buffer */ vivi_fillbuff(dev, buf); @@ -435,16 +434,18 @@ static void vivi_thread_tick(struct vivi_dmaqueue *dma_q) } } if (bc != 1) - dprintk(1, "%s: %d buffers handled (should be 1)\n", + dprintk(dev, 1, "%s: %d buffers handled (should be 1)\n", __FUNCTION__, bc); } static void vivi_sleep(struct vivi_dmaqueue *dma_q) { + struct vivi_dev *dev = container_of(dma_q, struct vivi_dev, vidq); int timeout; DECLARE_WAITQUEUE(wait, current); - dprintk(1, "%s dma_q=0x%08lx\n", __FUNCTION__, (unsigned long)dma_q); + dprintk(dev, 1, "%s dma_q=0x%08lx\n", __FUNCTION__, + (unsigned long)dma_q); add_wait_queue(&dma_q->wq, &wait); #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) @@ -471,11 +472,12 @@ static void vivi_sleep(struct vivi_dmaqueue *dma_q) WAKE_NUMERATOR * 1000) / WAKE_DENOMINATOR) - jiffies; - dprintk(1, "underrun, losed %d frames. " + dprintk(dev, 1, "underrun, losed %d frames. " "Now, frame is %d. Waking on %d jiffies\n", dma_q->frame-old, dma_q->frame, timeout); } else - dprintk(1, "will sleep for %i jiffies\n", timeout); + dprintk(dev, 1, "will sleep for %i jiffies\n", + timeout); vivi_thread_tick(dma_q); @@ -489,6 +491,7 @@ static void vivi_sleep(struct vivi_dmaqueue *dma_q) static int vivi_thread(void *data) { struct vivi_dmaqueue *dma_q = data; + struct vivi_dev *dev = container_of(dma_q, struct vivi_dev, vidq); #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) daemonize(); @@ -504,7 +507,7 @@ static int vivi_thread(void *data) if (dma_q->notify != NULL) up(dma_q->notify); #endif - dprintk(1, "thread started\n"); + dprintk(dev, 1, "thread started\n"); mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT); set_freezable(); @@ -519,7 +522,7 @@ static int vivi_thread(void *data) #endif break; } - dprintk(1, "thread: exit\n"); + dprintk(dev, 1, "thread: exit\n"); #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) dma_q->kthread = NULL; @@ -531,10 +534,12 @@ static int vivi_thread(void *data) static int vivi_start_thread(struct vivi_dmaqueue *dma_q) { + struct vivi_dev *dev = container_of(dma_q, struct vivi_dev, vidq); + dma_q->frame = 0; dma_q->ini_jiffies = jiffies; - dprintk(1, "%s\n", __FUNCTION__); + dprintk(dev, 1, "%s\n", __FUNCTION__); #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 0) dma_q->kthread = kthread_run(vivi_thread, dma_q, "vivi"); @@ -561,13 +566,15 @@ static int vivi_start_thread(struct vivi_dmaqueue *dma_q) /* Wakes thread */ wake_up_interruptible(&dma_q->wq); - dprintk(1, "returning from %s\n", __FUNCTION__); + dprintk(dev, 1, "returning from %s\n", __FUNCTION__); return 0; } static void vivi_stop_thread(struct vivi_dmaqueue *dma_q) { - dprintk(1, "%s\n", __FUNCTION__); + struct vivi_dev *dev = container_of(dma_q, struct vivi_dev, vidq); + + dprintk(dev, 1, "%s\n", __FUNCTION__); /* shutdown control thread */ if (dma_q->kthread) { #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) @@ -589,17 +596,19 @@ static void vivi_stop_thread(struct vivi_dmaqueue *dma_q) static int restart_video_queue(struct vivi_dmaqueue *dma_q) { + struct vivi_dev *dev = container_of(dma_q, struct vivi_dev, vidq); struct vivi_buffer *buf, *prev; - dprintk(1, "%s dma_q=0x%08lx\n", __FUNCTION__, (unsigned long)dma_q); + dprintk(dev, 1, "%s dma_q=0x%08lx\n", __FUNCTION__, + (unsigned long)dma_q); if (!list_empty(&dma_q->active)) { buf = list_entry(dma_q->active.next, struct vivi_buffer, vb.queue); - dprintk(2, "restart_queue [%p/%d]: restart dma\n", + dprintk(dev, 2, "restart_queue [%p/%d]: restart dma\n", buf, buf->vb.i); - dprintk(1, "Restarting video dma\n"); + dprintk(dev, 1, "Restarting video dma\n"); vivi_stop_thread(dma_q); /* cancel all outstanding capture / vbi requests */ @@ -623,13 +632,14 @@ static int restart_video_queue(struct vivi_dmaqueue *dma_q) list_del(&buf->vb.queue); list_add_tail(&buf->vb.queue, &dma_q->active); - dprintk(1, "Restarting video dma\n"); + dprintk(dev, 1, "Restarting video dma\n"); vivi_stop_thread(dma_q); vivi_start_thread(dma_q); buf->vb.state = VIDEOBUF_ACTIVE; mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT); - dprintk(2, "[%p/%d] restart_queue - first active\n", + dprintk(dev, 2, + "[%p/%d] restart_queue - first active\n", buf, buf->vb.i); } else if (prev->vb.width == buf->vb.width && @@ -638,7 +648,8 @@ static int restart_video_queue(struct vivi_dmaqueue *dma_q) list_del(&buf->vb.queue); list_add_tail(&buf->vb.queue, &dma_q->active); buf->vb.state = VIDEOBUF_ACTIVE; - dprintk(2, "[%p/%d] restart_queue - move to active\n", + dprintk(dev, 2, + "[%p/%d] restart_queue - move to active\n", buf, buf->vb.i); } else { return 0; @@ -671,7 +682,8 @@ static void vivi_vid_timeout(unsigned long data) static int buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size) { - struct vivi_fh *fh = vq->priv_data; + struct vivi_fh *fh = vq->priv_data; + struct vivi_dev *dev = fh->dev; *size = fh->width*fh->height*2; @@ -681,14 +693,18 @@ buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size) while (*size * *count > vid_limit * 1024 * 1024) (*count)--; - dprintk(1, "%s, count=%d, size=%d\n", __FUNCTION__, *count, *size); + dprintk(dev, 1, "%s, count=%d, size=%d\n", __FUNCTION__, + *count, *size); return 0; } static void free_buffer(struct videobuf_queue *vq, struct vivi_buffer *buf) { - dprintk(1, "%s\n", __FUNCTION__); + struct vivi_fh *fh = vq->priv_data; + struct vivi_dev *dev = fh->dev; + + dprintk(dev, 1, "%s\n", __FUNCTION__); if (in_interrupt()) BUG(); @@ -705,10 +721,11 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb, enum v4l2_field field) { struct vivi_fh *fh = vq->priv_data; + struct vivi_dev *dev = fh->dev; struct vivi_buffer *buf = container_of(vb, struct vivi_buffer, vb); int rc, init_buffer = 0; - dprintk(1, "%s, field=%d\n", __FUNCTION__, field); + dprintk(dev, 1, "%s, field=%d\n", __FUNCTION__, field); BUG_ON(NULL == fh->fmt); if (fh->width < 48 || fh->width > norm_maxw() || @@ -754,18 +771,18 @@ buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) struct vivi_buffer *prev; if (!list_empty(&vidq->queued)) { - dprintk(1, "adding vb queue=0x%08lx\n", + dprintk(dev, 1, "adding vb queue=0x%08lx\n", (unsigned long)&buf->vb.queue); list_add_tail(&buf->vb.queue, &vidq->queued); buf->vb.state = VIDEOBUF_QUEUED; - dprintk(2, "[%p/%d] buffer_queue - append to queued\n", + dprintk(dev, 2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i); } else if (list_empty(&vidq->active)) { list_add_tail(&buf->vb.queue, &vidq->active); buf->vb.state = VIDEOBUF_ACTIVE; mod_timer(&vidq->timeout, jiffies+BUFFER_TIMEOUT); - dprintk(2, "[%p/%d] buffer_queue - first active\n", + dprintk(dev, 2, "[%p/%d] buffer_queue - first active\n", buf, buf->vb.i); vivi_start_thread(vidq); @@ -777,13 +794,15 @@ buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) prev->fmt == buf->fmt) { list_add_tail(&buf->vb.queue, &vidq->active); buf->vb.state = VIDEOBUF_ACTIVE; - dprintk(2, "[%p/%d] buffer_queue - append to active\n", + dprintk(dev, 2, + "[%p/%d] buffer_queue - append to active\n", buf, buf->vb.i); } else { list_add_tail(&buf->vb.queue, &vidq->queued); buf->vb.state = VIDEOBUF_QUEUED; - dprintk(2, "[%p/%d] buffer_queue - first queued\n", + dprintk(dev, 2, + "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i); } } @@ -797,7 +816,7 @@ static void buffer_release(struct videobuf_queue *vq, struct vivi_dev *dev = (struct vivi_dev *)fh->dev; struct vivi_dmaqueue *vidq = &dev->vidq; - dprintk(1, "%s\n", __FUNCTION__); + dprintk(dev, 1, "%s\n", __FUNCTION__); vivi_stop_thread(vidq); @@ -857,13 +876,16 @@ static int vidioc_g_fmt_cap(struct file *file, void *priv, static int vidioc_try_fmt_cap(struct file *file, void *priv, struct v4l2_format *f) { + struct vivi_fh *fh = priv; + struct vivi_dev *dev = fh->dev; struct vivi_fmt *fmt; enum v4l2_field field; unsigned int maxw, maxh; if (format.fourcc != f->fmt.pix.pixelformat) { - dprintk(1, "Fourcc format (0x%08x) invalid. Driver accepts " - "only 0x%08x\n", f->fmt.pix.pixelformat, format.fourcc); + dprintk(dev, 1, "Fourcc format (0x%08x) invalid. " + "Driver accepts only 0x%08x\n", + f->fmt.pix.pixelformat, format.fourcc); return -EINVAL; } fmt = &format; @@ -873,7 +895,7 @@ static int vidioc_try_fmt_cap(struct file *file, void *priv, if (field == V4L2_FIELD_ANY) { field = V4L2_FIELD_INTERLACED; } else if (V4L2_FIELD_INTERLACED != field) { - dprintk(1, "Field type invalid.\n"); + dprintk(dev, 1, "Field type invalid.\n"); return -EINVAL; } @@ -1082,7 +1104,7 @@ found: /* If more than one user, mutex should be added */ dev->users++; - dprintk(1, "open minor=%d type=%s users=%d\n", minor, + dprintk(dev, 1, "open minor=%d type=%s users=%d\n", minor, v4l2_type_names[V4L2_BUF_TYPE_VIDEO_CAPTURE], dev->users); /* allocate + initialize per filehandle data */ @@ -1137,9 +1159,10 @@ static unsigned int vivi_poll(struct file *file, struct poll_table_struct *wait) { struct vivi_fh *fh = file->private_data; + struct vivi_dev *dev = fh->dev; struct videobuf_queue *q = &fh->vb_vidq; - dprintk(1, "%s\n", __FUNCTION__); + dprintk(dev, 1, "%s\n", __FUNCTION__); if (V4L2_BUF_TYPE_VIDEO_CAPTURE != fh->type) return POLLERR; @@ -1163,7 +1186,8 @@ static int vivi_close(struct inode *inode, struct file *file) dev->users--; - dprintk(1, "close called (minor=%d, users=%d)\n", minor, dev->users); + dprintk(dev, 1, "close called (minor=%d, users=%d)\n", + minor, dev->users); return 0; } @@ -1191,14 +1215,15 @@ static int vivi_release(void) static int vivi_mmap(struct file *file, struct vm_area_struct *vma) { - struct vivi_fh *fh = file->private_data; + struct vivi_fh *fh = file->private_data; + struct vivi_dev *dev = fh->dev; int ret; - dprintk(1, "mmap called, vma=0x%08lx\n", (unsigned long)vma); + dprintk(dev, 1, "mmap called, vma=0x%08lx\n", (unsigned long)vma); ret = videobuf_mmap_mapper(&fh->vb_vidq, vma); - dprintk(1, "vma start=0x%08lx, size=%ld, ret=%d\n", + dprintk(dev, 1, "vma start=0x%08lx, size=%ld, ret=%d\n", (unsigned long)vma->vm_start, (unsigned long)vma->vm_end-(unsigned long)vma->vm_start, ret); |