aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/vivi.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2007-08-02 22:31:54 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-10-09 21:14:56 -0400
commit5a0377060efcf844f4e359f3ab013de7f1b98da2 (patch)
tree74e4a3798037a8d21c5124e44acd7710bff26c81 /drivers/media/video/vivi.c
parent87b9ad070cf76c0f1e8cf836f7eb86e9ac94e34a (diff)
V4L/DVB (6255): Convert vivi to use videobuf-vmalloc
This patch removes the usage of videobuf-dma-sg from vivi driver, using instead videobuf-vmalloc. This way, vivi will be useful for testing the newer method. Reverting this patch won't hurt vivi, since both methods work fine. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/vivi.c')
-rw-r--r--drivers/media/video/vivi.c44
1 files changed, 15 insertions, 29 deletions
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index 89c40341007f..c14e2b3e4241 100644
--- a/drivers/media/video/vivi.c
+++ b/drivers/media/video/vivi.c
@@ -33,7 +33,7 @@
33#include <linux/videodev.h> 33#include <linux/videodev.h>
34#endif 34#endif
35#include <linux/interrupt.h> 35#include <linux/interrupt.h>
36#include <media/videobuf-dma-sg.h> 36#include <media/videobuf-vmalloc.h>
37#include <media/v4l2-common.h> 37#include <media/v4l2-common.h>
38#include <linux/kthread.h> 38#include <linux/kthread.h>
39#include <linux/highmem.h> 39#include <linux/highmem.h>
@@ -145,7 +145,6 @@ struct vivi_buffer {
145 struct videobuf_buffer vb; 145 struct videobuf_buffer vb;
146 146
147 struct vivi_fmt *fmt; 147 struct vivi_fmt *fmt;
148
149}; 148};
150 149
151struct vivi_dmaqueue { 150struct vivi_dmaqueue {
@@ -326,29 +325,22 @@ static void vivi_fillbuff(struct vivi_dev *dev,struct vivi_buffer *buf)
326 int hmax = buf->vb.height; 325 int hmax = buf->vb.height;
327 int wmax = buf->vb.width; 326 int wmax = buf->vb.width;
328 struct timeval ts; 327 struct timeval ts;
329 char *tmpbuf; 328 char *tmpbuf = kmalloc(wmax*2,GFP_KERNEL);
330 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb); 329 void *vbuf=videobuf_to_vmalloc (&buf->vb);
331
332
333 if (dma->varea) {
334 tmpbuf=kmalloc (wmax*2, GFP_KERNEL);
335 } else {
336 tmpbuf=dma->vmalloc;
337 }
338 330
331 if (!tmpbuf)
332 return;
339 333
340 for (h=0;h<hmax;h++) { 334 for (h=0;h<hmax;h++) {
341 if (dma->varea) { 335 gen_line(tmpbuf,0,wmax,hmax,h,dev->timestr);
342 gen_line(tmpbuf,0,wmax,hmax,h,dev->timestr); 336 /* FIXME: replacing to __copy_to_user */
343 /* FIXME: replacing to __copy_to_user */ 337 if (copy_to_user(vbuf+pos,tmpbuf,wmax*2)!=0)
344 if (copy_to_user(dma->varea+pos,tmpbuf,wmax*2)!=0) 338 dprintk(2,"vivifill copy_to_user failed.\n");
345 dprintk(2,"vivifill copy_to_user failed.\n");
346 } else {
347 gen_line(tmpbuf,pos,wmax,hmax,h,dev->timestr);
348 }
349 pos += wmax*2; 339 pos += wmax*2;
350 } 340 }
351 341
342 kfree(tmpbuf);
343
352 /* Updates stream time */ 344 /* Updates stream time */
353 345
354 dev->us+=jiffies_to_usecs(jiffies-dev->jiffies); 346 dev->us+=jiffies_to_usecs(jiffies-dev->jiffies);
@@ -371,7 +363,7 @@ static void vivi_fillbuff(struct vivi_dev *dev,struct vivi_buffer *buf)
371 dev->h,dev->m,dev->s,(dev->us+500)/1000); 363 dev->h,dev->m,dev->s,(dev->us+500)/1000);
372 364
373 dprintk(2,"vivifill at %s: Buffer 0x%08lx size= %d\n",dev->timestr, 365 dprintk(2,"vivifill at %s: Buffer 0x%08lx size= %d\n",dev->timestr,
374 (unsigned long)dma->varea,pos); 366 (unsigned long)tmpbuf,pos);
375 367
376 /* Advice that buffer was filled */ 368 /* Advice that buffer was filled */
377 buf->vb.state = STATE_DONE; 369 buf->vb.state = STATE_DONE;
@@ -610,17 +602,13 @@ buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size)
610 602
611static void free_buffer(struct videobuf_queue *vq, struct vivi_buffer *buf) 603static void free_buffer(struct videobuf_queue *vq, struct vivi_buffer *buf)
612{ 604{
613 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
614
615 dprintk(1,"%s\n",__FUNCTION__); 605 dprintk(1,"%s\n",__FUNCTION__);
616 606
617 if (in_interrupt()) 607 if (in_interrupt())
618 BUG(); 608 BUG();
619 609
620
621 videobuf_waiton(&buf->vb,0,0); 610 videobuf_waiton(&buf->vb,0,0);
622 videobuf_dma_unmap(vq, dma); 611 videobuf_vmalloc_free(&buf->vb);
623 videobuf_dma_free(dma);
624 buf->vb.state = STATE_NEEDS_INIT; 612 buf->vb.state = STATE_NEEDS_INIT;
625} 613}
626 614
@@ -726,7 +714,6 @@ static void buffer_release(struct videobuf_queue *vq, struct videobuf_buffer *vb
726 free_buffer(vq,buf); 714 free_buffer(vq,buf);
727} 715}
728 716
729
730static struct videobuf_queue_ops vivi_video_qops = { 717static struct videobuf_queue_ops vivi_video_qops = {
731 .buf_setup = buffer_setup, 718 .buf_setup = buffer_setup,
732 .buf_prepare = buffer_prepare, 719 .buf_prepare = buffer_prepare,
@@ -1092,13 +1079,12 @@ static int vivi_open(struct inode *inode, struct file *file)
1092 sprintf(dev->timestr,"%02d:%02d:%02d:%03d", 1079 sprintf(dev->timestr,"%02d:%02d:%02d:%03d",
1093 dev->h,dev->m,dev->s,(dev->us+500)/1000); 1080 dev->h,dev->m,dev->s,(dev->us+500)/1000);
1094 1081
1095 videobuf_queue_pci_init(&fh->vb_vidq, &vivi_video_qops, 1082 videobuf_queue_vmalloc_init(&fh->vb_vidq, &vivi_video_qops,
1096 NULL, NULL, 1083 NULL, NULL,
1097 fh->type, 1084 fh->type,
1098 V4L2_FIELD_INTERLACED, 1085 V4L2_FIELD_INTERLACED,
1099 sizeof(struct vivi_buffer),fh); 1086 sizeof(struct vivi_buffer),fh);
1100 1087
1101
1102 return 0; 1088 return 0;
1103} 1089}
1104 1090
@@ -1192,7 +1178,7 @@ static const struct file_operations vivi_fops = {
1192 .read = vivi_read, 1178 .read = vivi_read,
1193 .poll = vivi_poll, 1179 .poll = vivi_poll,
1194 .ioctl = video_ioctl2, /* V4L2 ioctl handler */ 1180 .ioctl = video_ioctl2, /* V4L2 ioctl handler */
1195 .mmap = vivi_mmap, 1181 .mmap = vivi_mmap,
1196 .llseek = no_llseek, 1182 .llseek = no_llseek,
1197}; 1183};
1198 1184