aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/vivi.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2007-08-23 15:41:14 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-10-09 21:14:56 -0400
commit6bb2790f8a0cf93d3dbed6b6e986441110e6174b (patch)
treea038c977073b76be6b08fe071732123d90908f1c /drivers/media/video/vivi.c
parentc1accaa21bdef38ec0f36eaaf7ce3384fff9d0c5 (diff)
V4L/DVB (6253): Convert vivi to use the newer videobuf-dma-sg module
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/vivi.c')
-rw-r--r--drivers/media/video/vivi.c53
1 files changed, 20 insertions, 33 deletions
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index c10169e35753..89c40341007f 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/video-buf.h> 36#include <media/videobuf-dma-sg.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>
@@ -327,19 +327,21 @@ static void vivi_fillbuff(struct vivi_dev *dev,struct vivi_buffer *buf)
327 int wmax = buf->vb.width; 327 int wmax = buf->vb.width;
328 struct timeval ts; 328 struct timeval ts;
329 char *tmpbuf; 329 char *tmpbuf;
330 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
330 331
331 if (buf->vb.dma.varea) { 332
333 if (dma->varea) {
332 tmpbuf=kmalloc (wmax*2, GFP_KERNEL); 334 tmpbuf=kmalloc (wmax*2, GFP_KERNEL);
333 } else { 335 } else {
334 tmpbuf=buf->vb.dma.vmalloc; 336 tmpbuf=dma->vmalloc;
335 } 337 }
336 338
337 339
338 for (h=0;h<hmax;h++) { 340 for (h=0;h<hmax;h++) {
339 if (buf->vb.dma.varea) { 341 if (dma->varea) {
340 gen_line(tmpbuf,0,wmax,hmax,h,dev->timestr); 342 gen_line(tmpbuf,0,wmax,hmax,h,dev->timestr);
341 /* FIXME: replacing to __copy_to_user */ 343 /* FIXME: replacing to __copy_to_user */
342 if (copy_to_user(buf->vb.dma.varea+pos,tmpbuf,wmax*2)!=0) 344 if (copy_to_user(dma->varea+pos,tmpbuf,wmax*2)!=0)
343 dprintk(2,"vivifill copy_to_user failed.\n"); 345 dprintk(2,"vivifill copy_to_user failed.\n");
344 } else { 346 } else {
345 gen_line(tmpbuf,pos,wmax,hmax,h,dev->timestr); 347 gen_line(tmpbuf,pos,wmax,hmax,h,dev->timestr);
@@ -369,7 +371,7 @@ static void vivi_fillbuff(struct vivi_dev *dev,struct vivi_buffer *buf)
369 dev->h,dev->m,dev->s,(dev->us+500)/1000); 371 dev->h,dev->m,dev->s,(dev->us+500)/1000);
370 372
371 dprintk(2,"vivifill at %s: Buffer 0x%08lx size= %d\n",dev->timestr, 373 dprintk(2,"vivifill at %s: Buffer 0x%08lx size= %d\n",dev->timestr,
372 (unsigned long)buf->vb.dma.varea,pos); 374 (unsigned long)dma->varea,pos);
373 375
374 /* Advice that buffer was filled */ 376 /* Advice that buffer was filled */
375 buf->vb.state = STATE_DONE; 377 buf->vb.state = STATE_DONE;
@@ -597,13 +599,19 @@ buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size)
597 599
598 if (0 == *count) 600 if (0 == *count)
599 *count = 32; 601 *count = 32;
602
600 while (*size * *count > vid_limit * 1024 * 1024) 603 while (*size * *count > vid_limit * 1024 * 1024)
601 (*count)--; 604 (*count)--;
605
606 dprintk(1,"%s, count=%d, size=%d\n",__FUNCTION__,*count, *size);
607
602 return 0; 608 return 0;
603} 609}
604 610
605static void free_buffer(struct videobuf_queue *vq, struct vivi_buffer *buf) 611static void free_buffer(struct videobuf_queue *vq, struct vivi_buffer *buf)
606{ 612{
613 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
614
607 dprintk(1,"%s\n",__FUNCTION__); 615 dprintk(1,"%s\n",__FUNCTION__);
608 616
609 if (in_interrupt()) 617 if (in_interrupt())
@@ -611,8 +619,8 @@ static void free_buffer(struct videobuf_queue *vq, struct vivi_buffer *buf)
611 619
612 620
613 videobuf_waiton(&buf->vb,0,0); 621 videobuf_waiton(&buf->vb,0,0);
614 videobuf_dma_unmap(vq, &buf->vb.dma); 622 videobuf_dma_unmap(vq, dma);
615 videobuf_dma_free(&buf->vb.dma); 623 videobuf_dma_free(dma);
616 buf->vb.state = STATE_NEEDS_INIT; 624 buf->vb.state = STATE_NEEDS_INIT;
617} 625}
618 626
@@ -626,7 +634,7 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
626 struct vivi_buffer *buf = container_of(vb,struct vivi_buffer,vb); 634 struct vivi_buffer *buf = container_of(vb,struct vivi_buffer,vb);
627 int rc, init_buffer = 0; 635 int rc, init_buffer = 0;
628 636
629// dprintk(1,"%s, field=%d\n",__FUNCTION__,field); 637 dprintk(1,"%s, field=%d\n",__FUNCTION__,field);
630 638
631 BUG_ON(NULL == fh->fmt); 639 BUG_ON(NULL == fh->fmt);
632 if (fh->width < 48 || fh->width > norm_maxw() || 640 if (fh->width < 48 || fh->width > norm_maxw() ||
@@ -724,11 +732,6 @@ static struct videobuf_queue_ops vivi_video_qops = {
724 .buf_prepare = buffer_prepare, 732 .buf_prepare = buffer_prepare,
725 .buf_queue = buffer_queue, 733 .buf_queue = buffer_queue,
726 .buf_release = buffer_release, 734 .buf_release = buffer_release,
727
728 /* Non-pci handling routines */
729// .vb_map_sg = vivi_map_sg,
730// .vb_dma_sync_sg = vivi_dma_sync_sg,
731// .vb_unmap_sg = vivi_unmap_sg,
732}; 735};
733 736
734/* ------------------------------------------------------------------ 737/* ------------------------------------------------------------------
@@ -904,25 +907,8 @@ static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *p)
904static int vidiocgmbuf (struct file *file, void *priv, struct video_mbuf *mbuf) 907static int vidiocgmbuf (struct file *file, void *priv, struct video_mbuf *mbuf)
905{ 908{
906 struct vivi_fh *fh=priv; 909 struct vivi_fh *fh=priv;
907 struct videobuf_queue *q=&fh->vb_vidq;
908 struct v4l2_requestbuffers req;
909 unsigned int i;
910 int ret;
911 910
912 req.type = q->type; 911 return videobuf_cgmbuf (&fh->vb_vidq, mbuf, 8);
913 req.count = 8;
914 req.memory = V4L2_MEMORY_MMAP;
915 ret = videobuf_reqbufs(q,&req);
916 if (ret < 0)
917 return (ret);
918
919 mbuf->frames = req.count;
920 mbuf->size = 0;
921 for (i = 0; i < mbuf->frames; i++) {
922 mbuf->offsets[i] = q->bufs[i]->boff;
923 mbuf->size += q->bufs[i]->bsize;
924 }
925 return (0);
926} 912}
927#endif 913#endif
928 914
@@ -1106,12 +1092,13 @@ static int vivi_open(struct inode *inode, struct file *file)
1106 sprintf(dev->timestr,"%02d:%02d:%02d:%03d", 1092 sprintf(dev->timestr,"%02d:%02d:%02d:%03d",
1107 dev->h,dev->m,dev->s,(dev->us+500)/1000); 1093 dev->h,dev->m,dev->s,(dev->us+500)/1000);
1108 1094
1109 videobuf_queue_init(&fh->vb_vidq, &vivi_video_qops, 1095 videobuf_queue_pci_init(&fh->vb_vidq, &vivi_video_qops,
1110 NULL, NULL, 1096 NULL, NULL,
1111 fh->type, 1097 fh->type,
1112 V4L2_FIELD_INTERLACED, 1098 V4L2_FIELD_INTERLACED,
1113 sizeof(struct vivi_buffer),fh); 1099 sizeof(struct vivi_buffer),fh);
1114 1100
1101
1115 return 0; 1102 return 0;
1116} 1103}
1117 1104