提交 5a037706 编写于 作者: M Mauro Carvalho Chehab

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: NMauro Carvalho Chehab <mchehab@infradead.org>
上级 87b9ad07
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include <linux/videodev.h> #include <linux/videodev.h>
#endif #endif
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <media/videobuf-dma-sg.h> #include <media/videobuf-vmalloc.h>
#include <media/v4l2-common.h> #include <media/v4l2-common.h>
#include <linux/kthread.h> #include <linux/kthread.h>
#include <linux/highmem.h> #include <linux/highmem.h>
...@@ -145,7 +145,6 @@ struct vivi_buffer { ...@@ -145,7 +145,6 @@ struct vivi_buffer {
struct videobuf_buffer vb; struct videobuf_buffer vb;
struct vivi_fmt *fmt; struct vivi_fmt *fmt;
}; };
struct vivi_dmaqueue { struct vivi_dmaqueue {
...@@ -326,29 +325,22 @@ static void vivi_fillbuff(struct vivi_dev *dev,struct vivi_buffer *buf) ...@@ -326,29 +325,22 @@ static void vivi_fillbuff(struct vivi_dev *dev,struct vivi_buffer *buf)
int hmax = buf->vb.height; int hmax = buf->vb.height;
int wmax = buf->vb.width; int wmax = buf->vb.width;
struct timeval ts; struct timeval ts;
char *tmpbuf; char *tmpbuf = kmalloc(wmax*2,GFP_KERNEL);
struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb); void *vbuf=videobuf_to_vmalloc (&buf->vb);
if (dma->varea) {
tmpbuf=kmalloc (wmax*2, GFP_KERNEL);
} else {
tmpbuf=dma->vmalloc;
}
if (!tmpbuf)
return;
for (h=0;h<hmax;h++) { for (h=0;h<hmax;h++) {
if (dma->varea) { gen_line(tmpbuf,0,wmax,hmax,h,dev->timestr);
gen_line(tmpbuf,0,wmax,hmax,h,dev->timestr); /* FIXME: replacing to __copy_to_user */
/* FIXME: replacing to __copy_to_user */ if (copy_to_user(vbuf+pos,tmpbuf,wmax*2)!=0)
if (copy_to_user(dma->varea+pos,tmpbuf,wmax*2)!=0) dprintk(2,"vivifill copy_to_user failed.\n");
dprintk(2,"vivifill copy_to_user failed.\n");
} else {
gen_line(tmpbuf,pos,wmax,hmax,h,dev->timestr);
}
pos += wmax*2; pos += wmax*2;
} }
kfree(tmpbuf);
/* Updates stream time */ /* Updates stream time */
dev->us+=jiffies_to_usecs(jiffies-dev->jiffies); 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,7 +363,7 @@ static void vivi_fillbuff(struct vivi_dev *dev,struct vivi_buffer *buf)
dev->h,dev->m,dev->s,(dev->us+500)/1000); dev->h,dev->m,dev->s,(dev->us+500)/1000);
dprintk(2,"vivifill at %s: Buffer 0x%08lx size= %d\n",dev->timestr, dprintk(2,"vivifill at %s: Buffer 0x%08lx size= %d\n",dev->timestr,
(unsigned long)dma->varea,pos); (unsigned long)tmpbuf,pos);
/* Advice that buffer was filled */ /* Advice that buffer was filled */
buf->vb.state = STATE_DONE; buf->vb.state = STATE_DONE;
...@@ -610,17 +602,13 @@ buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size) ...@@ -610,17 +602,13 @@ buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size)
static void free_buffer(struct videobuf_queue *vq, struct vivi_buffer *buf) 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__); dprintk(1,"%s\n",__FUNCTION__);
if (in_interrupt()) if (in_interrupt())
BUG(); BUG();
videobuf_waiton(&buf->vb,0,0); videobuf_waiton(&buf->vb,0,0);
videobuf_dma_unmap(vq, dma); videobuf_vmalloc_free(&buf->vb);
videobuf_dma_free(dma);
buf->vb.state = STATE_NEEDS_INIT; buf->vb.state = STATE_NEEDS_INIT;
} }
...@@ -726,7 +714,6 @@ static void buffer_release(struct videobuf_queue *vq, struct videobuf_buffer *vb ...@@ -726,7 +714,6 @@ static void buffer_release(struct videobuf_queue *vq, struct videobuf_buffer *vb
free_buffer(vq,buf); free_buffer(vq,buf);
} }
static struct videobuf_queue_ops vivi_video_qops = { static struct videobuf_queue_ops vivi_video_qops = {
.buf_setup = buffer_setup, .buf_setup = buffer_setup,
.buf_prepare = buffer_prepare, .buf_prepare = buffer_prepare,
...@@ -1092,13 +1079,12 @@ static int vivi_open(struct inode *inode, struct file *file) ...@@ -1092,13 +1079,12 @@ static int vivi_open(struct inode *inode, struct file *file)
sprintf(dev->timestr,"%02d:%02d:%02d:%03d", sprintf(dev->timestr,"%02d:%02d:%02d:%03d",
dev->h,dev->m,dev->s,(dev->us+500)/1000); dev->h,dev->m,dev->s,(dev->us+500)/1000);
videobuf_queue_pci_init(&fh->vb_vidq, &vivi_video_qops, videobuf_queue_vmalloc_init(&fh->vb_vidq, &vivi_video_qops,
NULL, NULL, NULL, NULL,
fh->type, fh->type,
V4L2_FIELD_INTERLACED, V4L2_FIELD_INTERLACED,
sizeof(struct vivi_buffer),fh); sizeof(struct vivi_buffer),fh);
return 0; return 0;
} }
...@@ -1192,7 +1178,7 @@ static const struct file_operations vivi_fops = { ...@@ -1192,7 +1178,7 @@ static const struct file_operations vivi_fops = {
.read = vivi_read, .read = vivi_read,
.poll = vivi_poll, .poll = vivi_poll,
.ioctl = video_ioctl2, /* V4L2 ioctl handler */ .ioctl = video_ioctl2, /* V4L2 ioctl handler */
.mmap = vivi_mmap, .mmap = vivi_mmap,
.llseek = no_llseek, .llseek = no_llseek,
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册