summaryrefslogtreecommitdiff
path: root/linux
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2007-08-23 16:41:14 -0300
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-08-23 16:41:14 -0300
commit6f11aad5c66cb3ffb1467eed32e979e3acf29804 (patch)
treec1add9b3e13cb781c4fa42bc8fccf6cc9ea97a97 /linux
parent41a0d4ee71a7cc6c77dab97f0719c2f91a52e618 (diff)
downloadmediapointer-dvb-s2-6f11aad5c66cb3ffb1467eed32e979e3acf29804.tar.gz
mediapointer-dvb-s2-6f11aad5c66cb3ffb1467eed32e979e3acf29804.tar.bz2
Convert vivi to use the newer videobuf-dma-sg module
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'linux')
-rw-r--r--linux/drivers/media/video/vivi.c73
1 files changed, 36 insertions, 37 deletions
diff --git a/linux/drivers/media/video/vivi.c b/linux/drivers/media/video/vivi.c
index e0504babe..2b443f798 100644
--- a/linux/drivers/media/video/vivi.c
+++ b/linux/drivers/media/video/vivi.c
@@ -38,7 +38,7 @@
#include <linux/videodev.h>
#endif
#include <linux/interrupt.h>
-#include <media/video-buf.h>
+#include <media/videobuf-dma-sg.h>
#include <media/v4l2-common.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
#include <linux/kthread.h>
@@ -254,12 +254,14 @@ static u8 bars[8][3] = {
static void prep_to_addr(struct sg_to_addr to_addr[],
struct videobuf_buffer *vb)
{
+ struct videobuf_dmabuf *dma=videobuf_to_dma(vb);
+
int i, pos=0;
for (i=0;i<vb->dma.nr_pages;i++) {
- to_addr[i].sg=&vb->dma.sglist[i];
+ to_addr[i].sg=dma->sglist[i];
to_addr[i].pos=pos;
- pos += vb->dma.sglist[i].length;
+ pos += dma->sglist[i].length;
}
}
@@ -451,6 +453,8 @@ static void vivi_fillbuff(struct vivi_dev *dev,struct vivi_buffer *buf)
#else
char *tmpbuf;
#endif
+ struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
+
#ifdef CONFIG_VIVI_SCATTER
/* Test if DMA mapping is ready */
@@ -460,12 +464,12 @@ static void vivi_fillbuff(struct vivi_dev *dev,struct vivi_buffer *buf)
prep_to_addr(to_addr,vb);
/* Check if there is enough memory */
- BUG_ON(buf->vb.dma.nr_pages << PAGE_SHIFT < (buf->vb.width*buf->vb.height)*2);
+ BUG_ON(dma->nr_pages << PAGE_SHIFT < (buf->vb.width*buf->vb.height)*2);
#else
- if (buf->vb.dma.varea) {
+ if (dma->varea) {
tmpbuf=kmalloc (wmax*2, GFP_KERNEL);
} else {
- tmpbuf=buf->vb.dma.vmalloc;
+ tmpbuf=dma->vmalloc;
}
#endif
@@ -474,10 +478,10 @@ static void vivi_fillbuff(struct vivi_dev *dev,struct vivi_buffer *buf)
#ifdef CONFIG_VIVI_SCATTER
gen_line(to_addr,pos,vb->dma.nr_pages,wmax,hmax,h,dev->timestr);
#else
- if (buf->vb.dma.varea) {
+ if (dma->varea) {
gen_line(tmpbuf,0,wmax,hmax,h,dev->timestr);
/* FIXME: replacing to __copy_to_user */
- if (copy_to_user(buf->vb.dma.varea+pos,tmpbuf,wmax*2)!=0)
+ if (copy_to_user(dma->varea+pos,tmpbuf,wmax*2)!=0)
dprintk(2,"vivifill copy_to_user failed.\n");
} else {
gen_line(tmpbuf,pos,wmax,hmax,h,dev->timestr);
@@ -508,7 +512,7 @@ static void vivi_fillbuff(struct vivi_dev *dev,struct vivi_buffer *buf)
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)buf->vb.dma.varea,pos);
+ (unsigned long)dma->varea,pos);
/* Advice that buffer was filled */
buf->vb.state = STATE_DONE;
@@ -793,13 +797,19 @@ buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size)
if (0 == *count)
*count = 32;
+
while (*size * *count > vid_limit * 1024 * 1024)
(*count)--;
+
+ dprintk(1,"%s, count=%d, size=%d\n",__FUNCTION__,*count, *size);
+
return 0;
}
static void free_buffer(struct videobuf_queue *vq, struct vivi_buffer *buf)
{
+ struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
+
dprintk(1,"%s\n",__FUNCTION__);
if (in_interrupt())
@@ -812,8 +822,8 @@ static void free_buffer(struct videobuf_queue *vq, struct vivi_buffer *buf)
#endif
videobuf_waiton(&buf->vb,0,0);
- videobuf_dma_unmap(vq, &buf->vb.dma);
- videobuf_dma_free(&buf->vb.dma);
+ videobuf_dma_unmap(vq, dma);
+ videobuf_dma_free(dma);
buf->vb.state = STATE_NEEDS_INIT;
}
@@ -827,7 +837,7 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
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(1,"%s, field=%d\n",__FUNCTION__,field);
BUG_ON(NULL == fh->fmt);
if (fh->width < 48 || fh->width > norm_maxw() ||
@@ -958,6 +968,13 @@ static int vivi_dma_sync_sg(void *dev,struct scatterlist *sglist, int nr_pages,
// flush_write_buffers();
return 0;
}
+
+static struct videobuf_dma_sg_ops pci_ops = {
+ /* Non-pci handling routines */
+ .vb_map_sg = vivi_map_sg,
+ .vb_dma_sync_sg = vivi_dma_sync_sg,
+ .vb_unmap_sg = vivi_unmap_sg,
+};
#endif
static struct videobuf_queue_ops vivi_video_qops = {
@@ -965,11 +982,6 @@ static struct videobuf_queue_ops vivi_video_qops = {
.buf_prepare = buffer_prepare,
.buf_queue = buffer_queue,
.buf_release = buffer_release,
-
- /* Non-pci handling routines */
-// .vb_map_sg = vivi_map_sg,
-// .vb_dma_sync_sg = vivi_dma_sync_sg,
-// .vb_unmap_sg = vivi_unmap_sg,
};
/* ------------------------------------------------------------------
@@ -1145,25 +1157,8 @@ static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *p)
static int vidiocgmbuf (struct file *file, void *priv, struct video_mbuf *mbuf)
{
struct vivi_fh *fh=priv;
- struct videobuf_queue *q=&fh->vb_vidq;
- struct v4l2_requestbuffers req;
- unsigned int i;
- int ret;
-
- req.type = q->type;
- req.count = 8;
- req.memory = V4L2_MEMORY_MMAP;
- ret = videobuf_reqbufs(q,&req);
- if (ret < 0)
- return (ret);
- mbuf->frames = req.count;
- mbuf->size = 0;
- for (i = 0; i < mbuf->frames; i++) {
- mbuf->offsets[i] = q->bufs[i]->boff;
- mbuf->size += q->bufs[i]->bsize;
- }
- return (0);
+ return videobuf_cgmbuf (&fh->vb_vidq, mbuf, 8);
}
#endif
@@ -1354,19 +1349,23 @@ static int vivi_open(struct inode *inode, struct file *file)
dev->h,dev->m,dev->s,(dev->us+500)/1000);
#ifdef CONFIG_VIVI_SCATTER
- videobuf_queue_init(&fh->vb_vidq,VIDEOBUF_DMA_SCATTER, &vivi_video_qops,
+ videobuf_queue_pci_init(&fh->vb_vidq,VIDEOBUF_DMA_SCATTER, &vivi_video_qops,
NULL, NULL,
fh->type,
V4L2_FIELD_INTERLACED,
sizeof(struct vivi_buffer),fh);
#else
- videobuf_queue_init(&fh->vb_vidq, &vivi_video_qops,
+ videobuf_queue_pci_init(&fh->vb_vidq, &vivi_video_qops,
NULL, NULL,
fh->type,
V4L2_FIELD_INTERLACED,
sizeof(struct vivi_buffer),fh);
#endif
+#ifdef CONFIG_VIVI_SCATTER
+ videobuf_set_pci_ops (&fh->vb_vidq, NULL);
+#endif
+
return 0;
}