Skip to content

Commit

Permalink
V4L/DVB (7237): Convert videobuf-dma-sg to generic DMA API
Browse files Browse the repository at this point in the history
videobuf-dma-sg does not need to depend on PCI. Switch it to using generic
DMA API, convert all affected drivers, relax Kconfig restriction, improve
compile-time type checking, fix some Coding Style violations while at it.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@pengutronix.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
  • Loading branch information
Guennadi Liakhovetski authored and Mauro Carvalho Chehab committed Apr 24, 2008
1 parent f13613a commit 0705135
Show file tree
Hide file tree
Showing 18 changed files with 109 additions and 108 deletions.
2 changes: 1 addition & 1 deletion drivers/media/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ config VIDEOBUF_GEN
tristate

config VIDEOBUF_DMA_SG
depends on PCI || ARCH_PXA
depends on HAS_DMA
select VIDEOBUF_GEN
tristate

Expand Down
4 changes: 2 additions & 2 deletions drivers/media/common/saa7146_vbi.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@ static int vbi_open(struct saa7146_dev *dev, struct file *file)
fh->vbi_fmt.start[1] = 312;
fh->vbi_fmt.count[1] = 16;

videobuf_queue_pci_init(&fh->vbi_q, &vbi_qops,
dev->pci, &dev->slock,
videobuf_queue_sg_init(&fh->vbi_q, &vbi_qops,
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VBI_CAPTURE,
V4L2_FIELD_SEQ_TB, // FIXME: does this really work?
sizeof(struct saa7146_buf),
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/common/saa7146_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1410,8 +1410,8 @@ 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_pci_init(&fh->video_q, &video_qops,
dev->pci, &dev->slock,
videobuf_queue_sg_init(&fh->video_q, &video_qops,
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct saa7146_buf),
Expand Down
16 changes: 8 additions & 8 deletions drivers/media/video/bt8xx/bttv-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2372,7 +2372,7 @@ static int setup_window(struct bttv_fh *fh, struct bttv *btv,
if (check_btres(fh, RESOURCE_OVERLAY)) {
struct bttv_buffer *new;

new = videobuf_pci_alloc(sizeof(*new));
new = videobuf_sg_alloc(sizeof(*new));
new->crop = btv->crop[!!fh->do_crop].rect;
bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new);
retval = bttv_switch_overlay(btv,fh,new);
Expand Down Expand Up @@ -2760,7 +2760,7 @@ static int bttv_overlay(struct file *file, void *f, unsigned int on)
mutex_lock(&fh->cap.vb_lock);
if (on) {
fh->ov.tvnorm = btv->tvnorm;
new = videobuf_pci_alloc(sizeof(*new));
new = videobuf_sg_alloc(sizeof(*new));
new->crop = btv->crop[!!fh->do_crop].rect;
bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new);
} else {
Expand Down Expand Up @@ -2834,7 +2834,7 @@ static int bttv_s_fbuf(struct file *file, void *f,
if (check_btres(fh, RESOURCE_OVERLAY)) {
struct bttv_buffer *new;

new = videobuf_pci_alloc(sizeof(*new));
new = videobuf_sg_alloc(sizeof(*new));
new->crop = btv->crop[!!fh->do_crop].rect;
bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new);
retval = bttv_switch_overlay(btv, fh, new);
Expand Down Expand Up @@ -3184,7 +3184,7 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait)
/* need to capture a new frame */
if (locked_btres(fh->btv,RESOURCE_VIDEO_STREAM))
goto err;
fh->cap.read_buf = videobuf_pci_alloc(fh->cap.msize);
fh->cap.read_buf = videobuf_sg_alloc(fh->cap.msize);
if (NULL == fh->cap.read_buf)
goto err;
fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR;
Expand Down Expand Up @@ -3251,14 +3251,14 @@ static int bttv_open(struct inode *inode, struct file *file)
fh->ov.setup_ok = 0;
v4l2_prio_open(&btv->prio,&fh->prio);

videobuf_queue_pci_init(&fh->cap, &bttv_video_qops,
btv->c.pci, &btv->s_lock,
videobuf_queue_sg_init(&fh->cap, &bttv_video_qops,
&btv->c.pci->dev, &btv->s_lock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct bttv_buffer),
fh);
videobuf_queue_pci_init(&fh->vbi, &bttv_vbi_qops,
btv->c.pci, &btv->s_lock,
videobuf_queue_sg_init(&fh->vbi, &bttv_vbi_qops,
&btv->c.pci->dev, &btv->s_lock,
V4L2_BUF_TYPE_VBI_CAPTURE,
V4L2_FIELD_SEQ_TB,
sizeof(struct bttv_buffer),
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/cx23885/cx23885-dvb.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ int cx23885_dvb_register(struct cx23885_tsport *port)

/* dvb stuff */
printk("%s: cx23885 based dvb card\n", dev->name);
videobuf_queue_pci_init(&port->dvb.dvbq, &dvb_qops, dev->pci, &port->slock,
videobuf_queue_sg_init(&port->dvb.dvbq, &dvb_qops, &dev->pci->dev, &port->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_TOP,
sizeof(struct cx23885_buffer), port);
err = dvb_register(port);
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/video/cx23885/cx23885-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -765,8 +765,8 @@ static int video_open(struct inode *inode, struct file *file)
fh->height = 240;
fh->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24);

videobuf_queue_pci_init(&fh->vidq, &cx23885_video_qops,
dev->pci, &dev->slock,
videobuf_queue_sg_init(&fh->vidq, &cx23885_video_qops,
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx23885_buffer),
Expand Down
8 changes: 4 additions & 4 deletions drivers/media/video/cx88/cx88-alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ static int dsp_buffer_free(snd_cx88_card_t *chip)
BUG_ON(!chip->dma_size);

dprintk(2,"Freeing buffer\n");
videobuf_pci_dma_unmap(chip->pci, chip->dma_risc);
videobuf_sg_dma_unmap(&chip->pci->dev, chip->dma_risc);
videobuf_dma_free(chip->dma_risc);
btcx_riscmem_free(chip->pci,&chip->buf->risc);
kfree(chip->buf);
Expand Down Expand Up @@ -385,7 +385,7 @@ static int snd_cx88_hw_params(struct snd_pcm_substream * substream,
BUG_ON(!chip->dma_size);
BUG_ON(chip->num_periods & (chip->num_periods-1));

buf = videobuf_pci_alloc(sizeof(*buf));
buf = videobuf_sg_alloc(sizeof(*buf));
if (NULL == buf)
return -ENOMEM;

Expand All @@ -396,14 +396,14 @@ static int snd_cx88_hw_params(struct snd_pcm_substream * substream,
buf->vb.height = chip->num_periods;
buf->vb.size = chip->dma_size;

dma=videobuf_to_dma(&buf->vb);
dma = videobuf_to_dma(&buf->vb);
videobuf_dma_init(dma);
ret = videobuf_dma_init_kernel(dma, PCI_DMA_FROMDEVICE,
(PAGE_ALIGN(buf->vb.size) >> PAGE_SHIFT));
if (ret < 0)
goto error;

ret = videobuf_pci_dma_map(chip->pci,dma);
ret = videobuf_sg_dma_map(&chip->pci->dev, dma);
if (ret < 0)
goto error;

Expand Down
4 changes: 2 additions & 2 deletions drivers/media/video/cx88/cx88-blackbird.c
Original file line number Diff line number Diff line change
Expand Up @@ -1087,8 +1087,8 @@ static int mpeg_open(struct inode *inode, struct file *file)
file->private_data = fh;
fh->dev = dev;

videobuf_queue_pci_init(&fh->mpegq, &blackbird_qops,
dev->pci, &dev->slock,
videobuf_queue_sg_init(&fh->mpegq, &blackbird_qops,
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx88_buffer),
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/video/cx88/cx88-dvb.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,8 +744,8 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv)

/* dvb stuff */
printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name);
videobuf_queue_pci_init(&dev->dvb.dvbq, &dvb_qops,
dev->pci, &dev->slock,
videobuf_queue_sg_init(&dev->dvb.dvbq, &dvb_qops,
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_TOP,
sizeof(struct cx88_buffer),
Expand Down
8 changes: 4 additions & 4 deletions drivers/media/video/cx88/cx88-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -776,14 +776,14 @@ static int video_open(struct inode *inode, struct file *file)
fh->height = 240;
fh->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24);

videobuf_queue_pci_init(&fh->vidq, &cx8800_video_qops,
dev->pci, &dev->slock,
videobuf_queue_sg_init(&fh->vidq, &cx8800_video_qops,
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx88_buffer),
fh);
videobuf_queue_pci_init(&fh->vbiq, &cx8800_vbi_qops,
dev->pci, &dev->slock,
videobuf_queue_sg_init(&fh->vbiq, &cx8800_vbi_qops,
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VBI_CAPTURE,
V4L2_FIELD_SEQ_TB,
sizeof(struct cx88_buffer),
Expand Down
10 changes: 5 additions & 5 deletions drivers/media/video/saa7134/saa7134-alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ static int snd_card_saa7134_hw_params(struct snd_pcm_substream * substream,
/* release the old buffer */
if (substream->runtime->dma_area) {
saa7134_pgtable_free(dev->pci, &dev->dmasound.pt);
videobuf_pci_dma_unmap(dev->pci, &dev->dmasound.dma);
videobuf_sg_dma_unmap(&dev->pci->dev, &dev->dmasound.dma);
dsp_buffer_free(dev);
substream->runtime->dma_area = NULL;
}
Expand All @@ -519,12 +519,12 @@ static int snd_card_saa7134_hw_params(struct snd_pcm_substream * substream,
return err;
}

if (0 != (err = videobuf_pci_dma_map(dev->pci, &dev->dmasound.dma))) {
if (0 != (err = videobuf_sg_dma_map(&dev->pci->dev, &dev->dmasound.dma))) {
dsp_buffer_free(dev);
return err;
}
if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->dmasound.pt))) {
videobuf_pci_dma_unmap(dev->pci, &dev->dmasound.dma);
videobuf_sg_dma_unmap(&dev->pci->dev, &dev->dmasound.dma);
dsp_buffer_free(dev);
return err;
}
Expand All @@ -533,7 +533,7 @@ static int snd_card_saa7134_hw_params(struct snd_pcm_substream * substream,
dev->dmasound.dma.sglen,
0))) {
saa7134_pgtable_free(dev->pci, &dev->dmasound.pt);
videobuf_pci_dma_unmap(dev->pci, &dev->dmasound.dma);
videobuf_sg_dma_unmap(&dev->pci->dev, &dev->dmasound.dma);
dsp_buffer_free(dev);
return err;
}
Expand Down Expand Up @@ -569,7 +569,7 @@ static int snd_card_saa7134_hw_free(struct snd_pcm_substream * substream)

if (substream->runtime->dma_area) {
saa7134_pgtable_free(dev->pci, &dev->dmasound.pt);
videobuf_pci_dma_unmap(dev->pci, &dev->dmasound.dma);
videobuf_sg_dma_unmap(&dev->pci->dev, &dev->dmasound.dma);
dsp_buffer_free(dev);
substream->runtime->dma_area = NULL;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/video/saa7134/saa7134-dvb.c
Original file line number Diff line number Diff line change
Expand Up @@ -899,8 +899,8 @@ static int dvb_init(struct saa7134_dev *dev)
dev->ts.nr_bufs = 32;
dev->ts.nr_packets = 32*4;
dev->dvb.name = dev->name;
videobuf_queue_pci_init(&dev->dvb.dvbq, &saa7134_ts_qops,
dev->pci, &dev->slock,
videobuf_queue_sg_init(&dev->dvb.dvbq, &saa7134_ts_qops,
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_ALTERNATE,
sizeof(struct saa7134_buf),
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/video/saa7134/saa7134-empress.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,8 @@ static int empress_init(struct saa7134_dev *dev)
printk(KERN_INFO "%s: registered device video%d [mpeg]\n",
dev->name,dev->empress_dev->minor & 0x1f);

videobuf_queue_pci_init(&dev->empress_tsq, &saa7134_ts_qops,
dev->pci, &dev->slock,
videobuf_queue_sg_init(&dev->empress_tsq, &saa7134_ts_qops,
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_ALTERNATE,
sizeof(struct saa7134_buf),
Expand Down
8 changes: 4 additions & 4 deletions drivers/media/video/saa7134/saa7134-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1350,14 +1350,14 @@ static int video_open(struct inode *inode, struct file *file)
fh->height = 576;
v4l2_prio_open(&dev->prio,&fh->prio);

videobuf_queue_pci_init(&fh->cap, &video_qops,
dev->pci, &dev->slock,
videobuf_queue_sg_init(&fh->cap, &video_qops,
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct saa7134_buf),
fh);
videobuf_queue_pci_init(&fh->vbi, &saa7134_vbi_qops,
dev->pci, &dev->slock,
videobuf_queue_sg_init(&fh->vbi, &saa7134_vbi_qops,
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VBI_CAPTURE,
V4L2_FIELD_SEQ_TB,
sizeof(struct saa7134_buf),
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/soc_camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ static int soc_camera_open(struct inode *inode, struct file *file)

/* We must pass NULL as dev pointer, then all pci_* dma operations
* transform to normal dma_* ones. Do we need an irqlock? */
videobuf_queue_pci_init(&icf->vb_vidq, ici->vbq_ops, NULL, NULL,
videobuf_queue_sg_init(&icf->vb_vidq, ici->vbq_ops, NULL, NULL,
V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_NONE,
ici->msize, icd);

Expand Down
Loading

0 comments on commit 0705135

Please sign in to comment.