V4L/DVB (6252): Adapt drivers to use the newer videobuf modules
[powerpc.git] / drivers / media / common / saa7146_video.c
index e7079d1..29dbc60 100644 (file)
@@ -318,6 +318,7 @@ int saa7146_start_preview(struct saa7146_fh *fh)
 
        return 0;
 }
+EXPORT_SYMBOL_GPL(saa7146_start_preview);
 
 int saa7146_stop_preview(struct saa7146_fh *fh)
 {
@@ -352,6 +353,7 @@ int saa7146_stop_preview(struct saa7146_fh *fh)
 
        return 0;
 }
+EXPORT_SYMBOL_GPL(saa7146_stop_preview);
 
 static int s_fmt(struct saa7146_fh *fh, struct v4l2_format *f)
 {
@@ -592,8 +594,9 @@ static int set_control(struct saa7146_fh *fh, struct v4l2_control *c)
 static int saa7146_pgtable_build(struct saa7146_dev *dev, struct saa7146_buf *buf)
 {
        struct pci_dev *pci = dev->pci;
-       struct scatterlist *list = buf->vb.dma.sglist;
-       int length = buf->vb.dma.sglen;
+       struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
+       struct scatterlist *list = dma->sglist;
+       int length = dma->sglen;
        struct saa7146_format *sfmt = format_by_fourcc(dev,buf->fmt->pixelformat);
 
        DEB_EE(("dev:%p, buf:%p, sg_len:%d\n",dev,buf,length));
@@ -653,7 +656,7 @@ static int saa7146_pgtable_build(struct saa7146_dev *dev, struct saa7146_buf *bu
 
                /* if we have a user buffer, the first page may not be
                   aligned to a page boundary. */
-               pt1->offset = buf->vb.dma.sglist->offset;
+               pt1->offset = list->offset;
                pt2->offset = pt1->offset+o1;
                pt3->offset = pt1->offset+o2;
 
@@ -887,9 +890,9 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
 
                DEB_EE(("VIDIOC_QUERYCAP\n"));
 
-               strcpy(cap->driver, "saa7146 v4l2");
-               strlcpy(cap->card, dev->ext->name, sizeof(cap->card));
-               sprintf(cap->bus_info,"PCI:%s", pci_name(dev->pci));
+               strcpy((char *)cap->driver, "saa7146 v4l2");
+               strlcpy((char *)cap->card, dev->ext->name, sizeof(cap->card));
+               sprintf((char *)cap->bus_info,"PCI:%s", pci_name(dev->pci));
                cap->version = SAA7146_VERSION_CODE;
                cap->capabilities =
                        V4L2_CAP_VIDEO_CAPTURE |
@@ -966,7 +969,7 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
                        }
                        memset(f,0,sizeof(*f));
                        f->index = index;
-                       strlcpy(f->description,formats[index].name,sizeof(f->description));
+                       strlcpy((char *)f->description,formats[index].name,sizeof(f->description));
                        f->pixelformat = formats[index].pixelformat;
                        break;
                }
@@ -1188,6 +1191,7 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
                }
                return err;
        }
+#ifdef CONFIG_VIDEO_V4L1_COMPAT
        case VIDIOCGMBUF:
        {
                struct video_mbuf *mbuf = arg;
@@ -1216,6 +1220,7 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
                mutex_unlock(&q->lock);
                return 0;
        }
+#endif
        default:
                return v4l_compat_translate_ioctl(inode,file,cmd,arg,
                                                  saa7146_video_do_ioctl);
@@ -1407,7 +1412,7 @@ static int video_open(struct saa7146_dev *dev, struct file *file)
        sfmt = format_by_fourcc(dev,fh->video_fmt.pixelformat);
        fh->video_fmt.sizeimage = (fh->video_fmt.width * fh->video_fmt.height * sfmt->depth)/8;
 
-       videobuf_queue_init(&fh->video_q, &video_qops,
+       videobuf_queue_pci_init(&fh->video_q, &video_qops,
                            dev->pci, &dev->slock,
                            V4L2_BUF_TYPE_VIDEO_CAPTURE,
                            V4L2_FIELD_INTERLACED,
@@ -1424,6 +1429,7 @@ static void video_close(struct saa7146_dev *dev, struct file *file)
 {
        struct saa7146_fh *fh = (struct saa7146_fh *)file->private_data;
        struct saa7146_vv *vv = dev->vv_data;
+       struct videobuf_queue *q = &fh->video_q;
        int err;
 
        if (IS_CAPTURE_ACTIVE(fh) != 0) {
@@ -1432,6 +1438,11 @@ static void video_close(struct saa7146_dev *dev, struct file *file)
                err = saa7146_stop_preview(fh);
        }
 
+       // release all capture buffers
+       mutex_lock(&q->lock);
+       videobuf_read_stop(q);
+       mutex_unlock(&q->lock);
+
        /* hmm, why is this function declared void? */
        /* return err */
 }