aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2007-08-23 15:37:49 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-10-09 21:14:55 -0400
commitc1accaa21bdef38ec0f36eaaf7ce3384fff9d0c5 (patch)
tree3a2c8206555af6c9e2eecdb20b052be70e6b93dd /drivers
parent7a7d9a89d0307b1743d782197e2c5fc5ddf183f3 (diff)
V4L/DVB (6252): Adapt drivers to use the newer videobuf modules
PCI-dependent videobuf_foo methods were renamed as videobuf_pci_foo. Also, videobuf_dmabuf is now part of videobuf-dma-sg private struct. So, to access it, a subroutine call is needed. This patch renames all occurences of those function calls to be consistent with the video-buf split. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org> http://thread.gmane.org/gmane.comp.video.video4linux/34978/focus=34981 Reviewed-by: Ricardo Cerqueira <v4l@cerqueira.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/Kconfig6
-rw-r--r--drivers/media/common/Kconfig2
-rw-r--r--drivers/media/common/saa7146_core.c2
-rw-r--r--drivers/media/common/saa7146_fops.c5
-rw-r--r--drivers/media/common/saa7146_vbi.c9
-rw-r--r--drivers/media/common/saa7146_video.c9
-rw-r--r--drivers/media/video/Kconfig2
-rw-r--r--drivers/media/video/Makefile3
-rw-r--r--drivers/media/video/bt8xx/Kconfig2
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c17
-rw-r--r--drivers/media/video/bt8xx/bttv-risc.c35
-rw-r--r--drivers/media/video/bt8xx/bttv-vbi.c5
-rw-r--r--drivers/media/video/bt8xx/bttvp.h2
-rw-r--r--drivers/media/video/cafe_ccic.c2
-rw-r--r--drivers/media/video/cx88/Kconfig2
-rw-r--r--drivers/media/video/cx88/cx88-alsa.c24
-rw-r--r--drivers/media/video/cx88/cx88-blackbird.c2
-rw-r--r--drivers/media/video/cx88/cx88-core.c6
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c2
-rw-r--r--drivers/media/video/cx88/cx88-mpeg.c3
-rw-r--r--drivers/media/video/cx88/cx88-vbi.c3
-rw-r--r--drivers/media/video/cx88/cx88-video.c38
-rw-r--r--drivers/media/video/cx88/cx88.h2
-rw-r--r--drivers/media/video/saa7134/Kconfig2
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c8
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c2
-rw-r--r--drivers/media/video/saa7134/saa7134-empress.c2
-rw-r--r--drivers/media/video/saa7134/saa7134-ts.c6
-rw-r--r--drivers/media/video/saa7134/saa7134-vbi.c6
-rw-r--r--drivers/media/video/saa7134/saa7134-video.c34
-rw-r--r--drivers/media/video/saa7134/saa7134.h2
-rw-r--r--drivers/media/video/video-buf-dvb.c6
32 files changed, 123 insertions, 128 deletions
diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig
index 3f8cfa873de..28ee65c5391 100644
--- a/drivers/media/Kconfig
+++ b/drivers/media/Kconfig
@@ -126,8 +126,12 @@ config TUNER_SIMPLE
126 126
127endif # VIDEO_TUNER_CUSTOMIZE 127endif # VIDEO_TUNER_CUSTOMIZE
128 128
129config VIDEO_BUF 129config VIDEOBUF_GEN
130 tristate
131
132config VIDEOBUF_DMA_SG
130 depends on PCI 133 depends on PCI
134 select VIDEOBUF_GEN
131 tristate 135 tristate
132 136
133config VIDEO_BUF_DVB 137config VIDEO_BUF_DVB
diff --git a/drivers/media/common/Kconfig b/drivers/media/common/Kconfig
index 5c63c8e24ee..c5092ef1082 100644
--- a/drivers/media/common/Kconfig
+++ b/drivers/media/common/Kconfig
@@ -5,5 +5,5 @@ config VIDEO_SAA7146
5config VIDEO_SAA7146_VV 5config VIDEO_SAA7146_VV
6 tristate 6 tristate
7 depends on VIDEO_DEV 7 depends on VIDEO_DEV
8 select VIDEO_BUF 8 select VIDEOBUF_DMA_SG
9 select VIDEO_SAA7146 9 select VIDEO_SAA7146
diff --git a/drivers/media/common/saa7146_core.c b/drivers/media/common/saa7146_core.c
index 1c962a2b44d..365a22118a0 100644
--- a/drivers/media/common/saa7146_core.c
+++ b/drivers/media/common/saa7146_core.c
@@ -100,7 +100,7 @@ int saa7146_wait_for_debi_done(struct saa7146_dev *dev, int nobusyloop)
100 * general helper functions 100 * general helper functions
101 ****************************************************************************/ 101 ****************************************************************************/
102 102
103/* this is videobuf_vmalloc_to_sg() from video-buf.c 103/* this is videobuf_vmalloc_to_sg() from videobuf-dma-sg.c
104 make sure virt has been allocated with vmalloc_32(), otherwise the BUG() 104 make sure virt has been allocated with vmalloc_32(), otherwise the BUG()
105 may be triggered on highmem machines */ 105 may be triggered on highmem machines */
106static struct scatterlist* vmalloc_to_sg(unsigned char *virt, int nr_pages) 106static struct scatterlist* vmalloc_to_sg(unsigned char *virt, int nr_pages)
diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c
index b4770aecc01..67d1b1b1b25 100644
--- a/drivers/media/common/saa7146_fops.c
+++ b/drivers/media/common/saa7146_fops.c
@@ -53,13 +53,14 @@ void saa7146_res_free(struct saa7146_fh *fh, unsigned int bits)
53void saa7146_dma_free(struct saa7146_dev *dev,struct videobuf_queue *q, 53void saa7146_dma_free(struct saa7146_dev *dev,struct videobuf_queue *q,
54 struct saa7146_buf *buf) 54 struct saa7146_buf *buf)
55{ 55{
56 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
56 DEB_EE(("dev:%p, buf:%p\n",dev,buf)); 57 DEB_EE(("dev:%p, buf:%p\n",dev,buf));
57 58
58 BUG_ON(in_interrupt()); 59 BUG_ON(in_interrupt());
59 60
60 videobuf_waiton(&buf->vb,0,0); 61 videobuf_waiton(&buf->vb,0,0);
61 videobuf_dma_unmap(q, &buf->vb.dma); 62 videobuf_dma_unmap(q, dma);
62 videobuf_dma_free(&buf->vb.dma); 63 videobuf_dma_free(dma);
63 buf->vb.state = STATE_NEEDS_INIT; 64 buf->vb.state = STATE_NEEDS_INIT;
64} 65}
65 66
diff --git a/drivers/media/common/saa7146_vbi.c b/drivers/media/common/saa7146_vbi.c
index 063608462eb..6103484e444 100644
--- a/drivers/media/common/saa7146_vbi.c
+++ b/drivers/media/common/saa7146_vbi.c
@@ -165,7 +165,7 @@ static void saa7146_set_vbi_capture(struct saa7146_dev *dev, struct saa7146_buf
165 /* we don't wait here for the first field anymore. this is different from the video 165 /* we don't wait here for the first field anymore. this is different from the video
166 capture and might cause that the first buffer is only half filled (with only 166 capture and might cause that the first buffer is only half filled (with only
167 one field). but since this is some sort of streaming data, this is not that negative. 167 one field). but since this is some sort of streaming data, this is not that negative.
168 but by doing this, we can use the whole engine from video-buf.c... */ 168 but by doing this, we can use the whole engine from videobuf-dma-sg.c... */
169 169
170/* 170/*
171 WRITE_RPS1(CMD_PAUSE | CMD_OAN | CMD_SIG1 | e_wait); 171 WRITE_RPS1(CMD_PAUSE | CMD_OAN | CMD_SIG1 | e_wait);
@@ -239,6 +239,8 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,e
239 saa7146_dma_free(dev,q,buf); 239 saa7146_dma_free(dev,q,buf);
240 240
241 if (STATE_NEEDS_INIT == buf->vb.state) { 241 if (STATE_NEEDS_INIT == buf->vb.state) {
242 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
243
242 buf->vb.width = llength; 244 buf->vb.width = llength;
243 buf->vb.height = lines; 245 buf->vb.height = lines;
244 buf->vb.size = size; 246 buf->vb.size = size;
@@ -250,7 +252,8 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,e
250 err = videobuf_iolock(q,&buf->vb, NULL); 252 err = videobuf_iolock(q,&buf->vb, NULL);
251 if (err) 253 if (err)
252 goto oops; 254 goto oops;
253 err = saa7146_pgtable_build_single(dev->pci, &buf->pt[2], buf->vb.dma.sglist, buf->vb.dma.sglen); 255 err = saa7146_pgtable_build_single(dev->pci, &buf->pt[2],
256 dma->sglist, dma->sglen);
254 if (0 != err) 257 if (0 != err)
255 return err; 258 return err;
256 } 259 }
@@ -404,7 +407,7 @@ static int vbi_open(struct saa7146_dev *dev, struct file *file)
404 fh->vbi_fmt.start[1] = 312; 407 fh->vbi_fmt.start[1] = 312;
405 fh->vbi_fmt.count[1] = 16; 408 fh->vbi_fmt.count[1] = 16;
406 409
407 videobuf_queue_init(&fh->vbi_q, &vbi_qops, 410 videobuf_queue_pci_init(&fh->vbi_q, &vbi_qops,
408 dev->pci, &dev->slock, 411 dev->pci, &dev->slock,
409 V4L2_BUF_TYPE_VBI_CAPTURE, 412 V4L2_BUF_TYPE_VBI_CAPTURE,
410 V4L2_FIELD_SEQ_TB, // FIXME: does this really work? 413 V4L2_FIELD_SEQ_TB, // FIXME: does this really work?
diff --git a/drivers/media/common/saa7146_video.c b/drivers/media/common/saa7146_video.c
index 664280c78ff..29dbc602a48 100644
--- a/drivers/media/common/saa7146_video.c
+++ b/drivers/media/common/saa7146_video.c
@@ -594,8 +594,9 @@ static int set_control(struct saa7146_fh *fh, struct v4l2_control *c)
594static int saa7146_pgtable_build(struct saa7146_dev *dev, struct saa7146_buf *buf) 594static int saa7146_pgtable_build(struct saa7146_dev *dev, struct saa7146_buf *buf)
595{ 595{
596 struct pci_dev *pci = dev->pci; 596 struct pci_dev *pci = dev->pci;
597 struct scatterlist *list = buf->vb.dma.sglist; 597 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
598 int length = buf->vb.dma.sglen; 598 struct scatterlist *list = dma->sglist;
599 int length = dma->sglen;
599 struct saa7146_format *sfmt = format_by_fourcc(dev,buf->fmt->pixelformat); 600 struct saa7146_format *sfmt = format_by_fourcc(dev,buf->fmt->pixelformat);
600 601
601 DEB_EE(("dev:%p, buf:%p, sg_len:%d\n",dev,buf,length)); 602 DEB_EE(("dev:%p, buf:%p, sg_len:%d\n",dev,buf,length));
@@ -655,7 +656,7 @@ static int saa7146_pgtable_build(struct saa7146_dev *dev, struct saa7146_buf *bu
655 656
656 /* if we have a user buffer, the first page may not be 657 /* if we have a user buffer, the first page may not be
657 aligned to a page boundary. */ 658 aligned to a page boundary. */
658 pt1->offset = buf->vb.dma.sglist->offset; 659 pt1->offset = list->offset;
659 pt2->offset = pt1->offset+o1; 660 pt2->offset = pt1->offset+o1;
660 pt3->offset = pt1->offset+o2; 661 pt3->offset = pt1->offset+o2;
661 662
@@ -1411,7 +1412,7 @@ static int video_open(struct saa7146_dev *dev, struct file *file)
1411 sfmt = format_by_fourcc(dev,fh->video_fmt.pixelformat); 1412 sfmt = format_by_fourcc(dev,fh->video_fmt.pixelformat);
1412 fh->video_fmt.sizeimage = (fh->video_fmt.width * fh->video_fmt.height * sfmt->depth)/8; 1413 fh->video_fmt.sizeimage = (fh->video_fmt.width * fh->video_fmt.height * sfmt->depth)/8;
1413 1414
1414 videobuf_queue_init(&fh->video_q, &video_qops, 1415 videobuf_queue_pci_init(&fh->video_q, &video_qops,
1415 dev->pci, &dev->slock, 1416 dev->pci, &dev->slock,
1416 V4L2_BUF_TYPE_VIDEO_CAPTURE, 1417 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1417 V4L2_FIELD_INTERLACED, 1418 V4L2_FIELD_INTERLACED,
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 5d74925748c..c4f424422f7 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -364,7 +364,7 @@ endmenu # encoder / decoder chips
364config VIDEO_VIVI 364config VIDEO_VIVI
365 tristate "Virtual Video Driver" 365 tristate "Virtual Video Driver"
366 depends on VIDEO_V4L2 && !SPARC32 && !SPARC64 && PCI 366 depends on VIDEO_V4L2 && !SPARC32 && !SPARC64 && PCI
367 select VIDEO_BUF 367 select VIDEOBUF_DMA_SG
368 default n 368 default n
369 ---help--- 369 ---help---
370 Enables a virtual video driver. This device shows a color bar 370 Enables a virtual video driver. This device shows a color bar
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index 9e99d2e1c1b..cb300241eb8 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -87,7 +87,8 @@ obj-$(CONFIG_TUNER_TDA8290) += tda8290.o
87obj-$(CONFIG_TUNER_TEA5767) += tea5767.o 87obj-$(CONFIG_TUNER_TEA5767) += tea5767.o
88obj-$(CONFIG_TUNER_TEA5761) += tea5761.o 88obj-$(CONFIG_TUNER_TEA5761) += tea5761.o
89 89
90obj-$(CONFIG_VIDEO_BUF) += video-buf.o 90obj-$(CONFIG_VIDEOBUF_GEN) += videobuf-core.o
91obj-$(CONFIG_VIDEOBUF_DMA_SG) += videobuf-dma-sg.o
91obj-$(CONFIG_VIDEO_BUF_DVB) += video-buf-dvb.o 92obj-$(CONFIG_VIDEO_BUF_DVB) += video-buf-dvb.o
92obj-$(CONFIG_VIDEO_BTCX) += btcx-risc.o 93obj-$(CONFIG_VIDEO_BTCX) += btcx-risc.o
93obj-$(CONFIG_VIDEO_TVEEPROM) += tveeprom.o 94obj-$(CONFIG_VIDEO_TVEEPROM) += tveeprom.o
diff --git a/drivers/media/video/bt8xx/Kconfig b/drivers/media/video/bt8xx/Kconfig
index 58eae887a62..2ca162b390a 100644
--- a/drivers/media/video/bt8xx/Kconfig
+++ b/drivers/media/video/bt8xx/Kconfig
@@ -4,7 +4,7 @@ config VIDEO_BT848
4 select I2C_ALGOBIT 4 select I2C_ALGOBIT
5 select FW_LOADER 5 select FW_LOADER
6 select VIDEO_BTCX 6 select VIDEO_BTCX
7 select VIDEO_BUF 7 select VIDEOBUF_DMA_SG
8 select VIDEO_IR 8 select VIDEO_IR
9 select VIDEO_TUNER 9 select VIDEO_TUNER
10 select VIDEO_TVEEPROM 10 select VIDEO_TVEEPROM
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index 0711c950784..4ab4e14b5c6 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -2582,7 +2582,7 @@ static int setup_window(struct bttv_fh *fh, struct bttv *btv,
2582 if (check_btres(fh, RESOURCE_OVERLAY)) { 2582 if (check_btres(fh, RESOURCE_OVERLAY)) {
2583 struct bttv_buffer *new; 2583 struct bttv_buffer *new;
2584 2584
2585 new = videobuf_alloc(sizeof(*new)); 2585 new = videobuf_pci_alloc(sizeof(*new));
2586 new->crop = btv->crop[!!fh->do_crop].rect; 2586 new->crop = btv->crop[!!fh->do_crop].rect;
2587 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); 2587 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new);
2588 retval = bttv_switch_overlay(btv,fh,new); 2588 retval = bttv_switch_overlay(btv,fh,new);
@@ -3048,7 +3048,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
3048 mutex_lock(&fh->cap.lock); 3048 mutex_lock(&fh->cap.lock);
3049 if (*on) { 3049 if (*on) {
3050 fh->ov.tvnorm = btv->tvnorm; 3050 fh->ov.tvnorm = btv->tvnorm;
3051 new = videobuf_alloc(sizeof(*new)); 3051 new = videobuf_pci_alloc(sizeof(*new));
3052 new->crop = btv->crop[!!fh->do_crop].rect; 3052 new->crop = btv->crop[!!fh->do_crop].rect;
3053 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); 3053 bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new);
3054 } else { 3054 } else {
@@ -3141,9 +3141,12 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
3141 retval = -EIO; 3141 retval = -EIO;
3142 /* fall through */ 3142 /* fall through */
3143 case STATE_DONE: 3143 case STATE_DONE:
3144 videobuf_dma_sync(&fh->cap,&buf->vb.dma); 3144 {
3145 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
3146 videobuf_dma_sync(&fh->cap,dma);
3145 bttv_dma_free(&fh->cap,btv,buf); 3147 bttv_dma_free(&fh->cap,btv,buf);
3146 break; 3148 break;
3149 }
3147 default: 3150 default:
3148 retval = -EINVAL; 3151 retval = -EINVAL;
3149 break; 3152 break;
@@ -3337,7 +3340,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
3337 if (check_btres(fh, RESOURCE_OVERLAY)) { 3340 if (check_btres(fh, RESOURCE_OVERLAY)) {
3338 struct bttv_buffer *new; 3341 struct bttv_buffer *new;
3339 3342
3340 new = videobuf_alloc(sizeof(*new)); 3343 new = videobuf_pci_alloc(sizeof(*new));
3341 new->crop = btv->crop[!!fh->do_crop].rect; 3344 new->crop = btv->crop[!!fh->do_crop].rect;
3342 bttv_overlay_risc(btv,&fh->ov,fh->ovfmt,new); 3345 bttv_overlay_risc(btv,&fh->ov,fh->ovfmt,new);
3343 retval = bttv_switch_overlay(btv,fh,new); 3346 retval = bttv_switch_overlay(btv,fh,new);
@@ -3696,7 +3699,7 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait)
3696 mutex_unlock(&fh->cap.lock); 3699 mutex_unlock(&fh->cap.lock);
3697 return POLLERR; 3700 return POLLERR;
3698 } 3701 }
3699 fh->cap.read_buf = videobuf_alloc(fh->cap.msize); 3702 fh->cap.read_buf = videobuf_pci_alloc(fh->cap.msize);
3700 if (NULL == fh->cap.read_buf) { 3703 if (NULL == fh->cap.read_buf) {
3701 mutex_unlock(&fh->cap.lock); 3704 mutex_unlock(&fh->cap.lock);
3702 return POLLERR; 3705 return POLLERR;
@@ -3763,13 +3766,13 @@ static int bttv_open(struct inode *inode, struct file *file)
3763 fh->ov.setup_ok = 0; 3766 fh->ov.setup_ok = 0;
3764 v4l2_prio_open(&btv->prio,&fh->prio); 3767 v4l2_prio_open(&btv->prio,&fh->prio);
3765 3768
3766 videobuf_queue_init(&fh->cap, &bttv_video_qops, 3769 videobuf_queue_pci_init(&fh->cap, &bttv_video_qops,
3767 btv->c.pci, &btv->s_lock, 3770 btv->c.pci, &btv->s_lock,
3768 V4L2_BUF_TYPE_VIDEO_CAPTURE, 3771 V4L2_BUF_TYPE_VIDEO_CAPTURE,
3769 V4L2_FIELD_INTERLACED, 3772 V4L2_FIELD_INTERLACED,
3770 sizeof(struct bttv_buffer), 3773 sizeof(struct bttv_buffer),
3771 fh); 3774 fh);
3772 videobuf_queue_init(&fh->vbi, &bttv_vbi_qops, 3775 videobuf_queue_pci_init(&fh->vbi, &bttv_vbi_qops,
3773 btv->c.pci, &btv->s_lock, 3776 btv->c.pci, &btv->s_lock,
3774 V4L2_BUF_TYPE_VBI_CAPTURE, 3777 V4L2_BUF_TYPE_VBI_CAPTURE,
3775 V4L2_FIELD_SEQ_TB, 3778 V4L2_FIELD_SEQ_TB,
diff --git a/drivers/media/video/bt8xx/bttv-risc.c b/drivers/media/video/bt8xx/bttv-risc.c
index e7104d9cb4b..58986f1a5f1 100644
--- a/drivers/media/video/bt8xx/bttv-risc.c
+++ b/drivers/media/video/bt8xx/bttv-risc.c
@@ -574,10 +574,12 @@ bttv_risc_hook(struct bttv *btv, int slot, struct btcx_riscmem *risc,
574void 574void
575bttv_dma_free(struct videobuf_queue *q,struct bttv *btv, struct bttv_buffer *buf) 575bttv_dma_free(struct videobuf_queue *q,struct bttv *btv, struct bttv_buffer *buf)
576{ 576{
577 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
578
577 BUG_ON(in_interrupt()); 579 BUG_ON(in_interrupt());
578 videobuf_waiton(&buf->vb,0,0); 580 videobuf_waiton(&buf->vb,0,0);
579 videobuf_dma_unmap(q, &buf->vb.dma); 581 videobuf_dma_unmap(q, dma);
580 videobuf_dma_free(&buf->vb.dma); 582 videobuf_dma_free(dma);
581 btcx_riscmem_free(btv->c.pci,&buf->bottom); 583 btcx_riscmem_free(btv->c.pci,&buf->bottom);
582 btcx_riscmem_free(btv->c.pci,&buf->top); 584 btcx_riscmem_free(btv->c.pci,&buf->top);
583 buf->vb.state = STATE_NEEDS_INIT; 585 buf->vb.state = STATE_NEEDS_INIT;
@@ -699,6 +701,7 @@ int
699bttv_buffer_risc(struct bttv *btv, struct bttv_buffer *buf) 701bttv_buffer_risc(struct bttv *btv, struct bttv_buffer *buf)
700{ 702{
701 const struct bttv_tvnorm *tvnorm = bttv_tvnorms + buf->tvnorm; 703 const struct bttv_tvnorm *tvnorm = bttv_tvnorms + buf->tvnorm;
704 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
702 705
703 dprintk(KERN_DEBUG 706 dprintk(KERN_DEBUG
704 "bttv%d: buffer field: %s format: %s size: %dx%d\n", 707 "bttv%d: buffer field: %s format: %s size: %dx%d\n",
@@ -716,25 +719,25 @@ bttv_buffer_risc(struct bttv *btv, struct bttv_buffer *buf)
716 719
717 switch (buf->vb.field) { 720 switch (buf->vb.field) {
718 case V4L2_FIELD_TOP: 721 case V4L2_FIELD_TOP:
719 bttv_risc_packed(btv,&buf->top,buf->vb.dma.sglist, 722 bttv_risc_packed(btv,&buf->top,dma->sglist,
720 /* offset */ 0,bpl, 723 /* offset */ 0,bpl,
721 /* padding */ 0,/* skip_lines */ 0, 724 /* padding */ 0,/* skip_lines */ 0,
722 buf->vb.height); 725 buf->vb.height);
723 break; 726 break;
724 case V4L2_FIELD_BOTTOM: 727 case V4L2_FIELD_BOTTOM:
725 bttv_risc_packed(btv,&buf->bottom,buf->vb.dma.sglist, 728 bttv_risc_packed(btv,&buf->bottom,dma->sglist,
726 0,bpl,0,0,buf->vb.height); 729 0,bpl,0,0,buf->vb.height);
727 break; 730 break;
728 case V4L2_FIELD_INTERLACED: 731 case V4L2_FIELD_INTERLACED:
729 bttv_risc_packed(btv,&buf->top,buf->vb.dma.sglist, 732 bttv_risc_packed(btv,&buf->top,dma->sglist,
730 0,bpl,bpl,0,buf->vb.height >> 1); 733 0,bpl,bpl,0,buf->vb.height >> 1);
731 bttv_risc_packed(btv,&buf->bottom,buf->vb.dma.sglist, 734 bttv_risc_packed(btv,&buf->bottom,dma->sglist,
732 bpl,bpl,bpl,0,buf->vb.height >> 1); 735 bpl,bpl,bpl,0,buf->vb.height >> 1);
733 break; 736 break;
734 case V4L2_FIELD_SEQ_TB: 737 case V4L2_FIELD_SEQ_TB:
735 bttv_risc_packed(btv,&buf->top,buf->vb.dma.sglist, 738 bttv_risc_packed(btv,&buf->top,dma->sglist,
736 0,bpl,0,0,buf->vb.height >> 1); 739 0,bpl,0,0,buf->vb.height >> 1);
737 bttv_risc_packed(btv,&buf->bottom,buf->vb.dma.sglist, 740 bttv_risc_packed(btv,&buf->bottom,dma->sglist,
738 bpf,bpl,0,0,buf->vb.height >> 1); 741 bpf,bpl,0,0,buf->vb.height >> 1);
739 break; 742 break;
740 default: 743 default:
@@ -767,7 +770,7 @@ bttv_buffer_risc(struct bttv *btv, struct bttv_buffer *buf)
767 bttv_calc_geo(btv,&buf->geo,buf->vb.width, 770 bttv_calc_geo(btv,&buf->geo,buf->vb.width,
768 buf->vb.height,/* both_fields */ 0, 771 buf->vb.height,/* both_fields */ 0,
769 tvnorm,&buf->crop); 772 tvnorm,&buf->crop);
770 bttv_risc_planar(btv, &buf->top, buf->vb.dma.sglist, 773 bttv_risc_planar(btv, &buf->top, dma->sglist,
771 0,buf->vb.width,0,buf->vb.height, 774 0,buf->vb.width,0,buf->vb.height,
772 uoffset,voffset,buf->fmt->hshift, 775 uoffset,voffset,buf->fmt->hshift,
773 buf->fmt->vshift,0); 776 buf->fmt->vshift,0);
@@ -776,7 +779,7 @@ bttv_buffer_risc(struct bttv *btv, struct bttv_buffer *buf)
776 bttv_calc_geo(btv,&buf->geo,buf->vb.width, 779 bttv_calc_geo(btv,&buf->geo,buf->vb.width,
777 buf->vb.height,0, 780 buf->vb.height,0,
778 tvnorm,&buf->crop); 781 tvnorm,&buf->crop);
779 bttv_risc_planar(btv, &buf->bottom, buf->vb.dma.sglist, 782 bttv_risc_planar(btv, &buf->bottom, dma->sglist,
780 0,buf->vb.width,0,buf->vb.height, 783 0,buf->vb.width,0,buf->vb.height,
781 uoffset,voffset,buf->fmt->hshift, 784 uoffset,voffset,buf->fmt->hshift,
782 buf->fmt->vshift,0); 785 buf->fmt->vshift,0);
@@ -789,14 +792,14 @@ bttv_buffer_risc(struct bttv *btv, struct bttv_buffer *buf)
789 ypadding = buf->vb.width; 792 ypadding = buf->vb.width;
790 cpadding = buf->vb.width >> buf->fmt->hshift; 793 cpadding = buf->vb.width >> buf->fmt->hshift;
791 bttv_risc_planar(btv,&buf->top, 794 bttv_risc_planar(btv,&buf->top,
792 buf->vb.dma.sglist, 795 dma->sglist,
793 0,buf->vb.width,ypadding,lines, 796 0,buf->vb.width,ypadding,lines,
794 uoffset,voffset, 797 uoffset,voffset,
795 buf->fmt->hshift, 798 buf->fmt->hshift,
796 buf->fmt->vshift, 799 buf->fmt->vshift,
797 cpadding); 800 cpadding);
798 bttv_risc_planar(btv,&buf->bottom, 801 bttv_risc_planar(btv,&buf->bottom,
799 buf->vb.dma.sglist, 802 dma->sglist,
800 ypadding,buf->vb.width,ypadding,lines, 803 ypadding,buf->vb.width,ypadding,lines,
801 uoffset+cpadding, 804 uoffset+cpadding,
802 voffset+cpadding, 805 voffset+cpadding,
@@ -812,7 +815,7 @@ bttv_buffer_risc(struct bttv *btv, struct bttv_buffer *buf)
812 ypadding = buf->vb.width; 815 ypadding = buf->vb.width;
813 cpadding = buf->vb.width >> buf->fmt->hshift; 816 cpadding = buf->vb.width >> buf->fmt->hshift;
814 bttv_risc_planar(btv,&buf->top, 817 bttv_risc_planar(btv,&buf->top,
815 buf->vb.dma.sglist, 818 dma->sglist,
816 0,buf->vb.width,0,lines, 819 0,buf->vb.width,0,lines,
817 uoffset >> 1, 820 uoffset >> 1,
818 voffset >> 1, 821 voffset >> 1,
@@ -820,7 +823,7 @@ bttv_buffer_risc(struct bttv *btv, struct bttv_buffer *buf)
820 buf->fmt->vshift, 823 buf->fmt->vshift,
821 0); 824 0);
822 bttv_risc_planar(btv,&buf->bottom, 825 bttv_risc_planar(btv,&buf->bottom,
823 buf->vb.dma.sglist, 826 dma->sglist,
824 lines * ypadding,buf->vb.width,0,lines, 827 lines * ypadding,buf->vb.width,0,lines,
825 lines * ypadding + (uoffset >> 1), 828 lines * ypadding + (uoffset >> 1),
826 lines * ypadding + (voffset >> 1), 829 lines * ypadding + (voffset >> 1),
@@ -839,10 +842,10 @@ bttv_buffer_risc(struct bttv *btv, struct bttv_buffer *buf)
839 buf->vb.field = V4L2_FIELD_SEQ_TB; 842 buf->vb.field = V4L2_FIELD_SEQ_TB;
840 bttv_calc_geo(btv,&buf->geo,tvnorm->swidth,tvnorm->sheight, 843 bttv_calc_geo(btv,&buf->geo,tvnorm->swidth,tvnorm->sheight,
841 1,tvnorm,&buf->crop); 844 1,tvnorm,&buf->crop);
842 bttv_risc_packed(btv, &buf->top, buf->vb.dma.sglist, 845 bttv_risc_packed(btv, &buf->top, dma->sglist,
843 /* offset */ 0, RAW_BPL, /* padding */ 0, 846 /* offset */ 0, RAW_BPL, /* padding */ 0,
844 /* skip_lines */ 0, RAW_LINES); 847 /* skip_lines */ 0, RAW_LINES);
845 bttv_risc_packed(btv, &buf->bottom, buf->vb.dma.sglist, 848 bttv_risc_packed(btv, &buf->bottom, dma->sglist,
846 buf->vb.size/2 , RAW_BPL, 0, 0, RAW_LINES); 849 buf->vb.size/2 , RAW_BPL, 0, 0, RAW_LINES);
847 } 850 }
848 851
diff --git a/drivers/media/video/bt8xx/bttv-vbi.c b/drivers/media/video/bt8xx/bttv-vbi.c
index 007485aa4f0..346ce019bdc 100644
--- a/drivers/media/video/bt8xx/bttv-vbi.c
+++ b/drivers/media/video/bt8xx/bttv-vbi.c
@@ -150,13 +150,14 @@ static int vbi_buffer_prepare(struct videobuf_queue *q,
150 150
151 if (redo_dma_risc) { 151 if (redo_dma_risc) {
152 unsigned int bpl, padding, offset; 152 unsigned int bpl, padding, offset;
153 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
153 154
154 bpl = 2044; /* max. vbipack */ 155 bpl = 2044; /* max. vbipack */
155 padding = VBI_BPL - bpl; 156 padding = VBI_BPL - bpl;
156 157
157 if (fh->vbi_fmt.fmt.count[0] > 0) { 158 if (fh->vbi_fmt.fmt.count[0] > 0) {
158 rc = bttv_risc_packed(btv, &buf->top, 159 rc = bttv_risc_packed(btv, &buf->top,
159 buf->vb.dma.sglist, 160 dma->sglist,
160 /* offset */ 0, bpl, 161 /* offset */ 0, bpl,
161 padding, skip_lines0, 162 padding, skip_lines0,
162 fh->vbi_fmt.fmt.count[0]); 163 fh->vbi_fmt.fmt.count[0]);
@@ -168,7 +169,7 @@ static int vbi_buffer_prepare(struct videobuf_queue *q,
168 offset = fh->vbi_fmt.fmt.count[0] * VBI_BPL; 169 offset = fh->vbi_fmt.fmt.count[0] * VBI_BPL;
169 170
170 rc = bttv_risc_packed(btv, &buf->bottom, 171 rc = bttv_risc_packed(btv, &buf->bottom,
171 buf->vb.dma.sglist, 172 dma->sglist,
172 offset, bpl, 173 offset, bpl,
173 padding, skip_lines1, 174 padding, skip_lines1,
174 fh->vbi_fmt.fmt.count[1]); 175 fh->vbi_fmt.fmt.count[1]);
diff --git a/drivers/media/video/bt8xx/bttvp.h b/drivers/media/video/bt8xx/bttvp.h
index 5b25faca150..0b92c35a843 100644
--- a/drivers/media/video/bt8xx/bttvp.h
+++ b/drivers/media/video/bt8xx/bttvp.h
@@ -41,7 +41,7 @@
41#include <media/v4l2-common.h> 41#include <media/v4l2-common.h>
42 42
43#include <linux/device.h> 43#include <linux/device.h>
44#include <media/video-buf.h> 44#include <media/videobuf-dma-sg.h>
45#include <media/tuner.h> 45#include <media/tuner.h>
46#include <media/tveeprom.h> 46#include <media/tveeprom.h>
47#include <media/ir-common.h> 47#include <media/ir-common.h>
diff --git a/drivers/media/video/cafe_ccic.c b/drivers/media/video/cafe_ccic.c
index ccb37006bb1..b63cab33692 100644
--- a/drivers/media/video/cafe_ccic.c
+++ b/drivers/media/video/cafe_ccic.c
@@ -1197,7 +1197,7 @@ static int cafe_setup_siobuf(struct cafe_camera *cam, int index)
1197 buf->v4lbuf.field = V4L2_FIELD_NONE; 1197 buf->v4lbuf.field = V4L2_FIELD_NONE;
1198 buf->v4lbuf.memory = V4L2_MEMORY_MMAP; 1198 buf->v4lbuf.memory = V4L2_MEMORY_MMAP;
1199 /* 1199 /*
1200 * Offset: must be 32-bit even on a 64-bit system. video-buf 1200 * Offset: must be 32-bit even on a 64-bit system. videobuf-dma-sg
1201 * just uses the length times the index, but the spec warns 1201 * just uses the length times the index, but the spec warns
1202 * against doing just that - vma merging problems. So we 1202 * against doing just that - vma merging problems. So we
1203 * leave a gap between each pair of buffers. 1203 * leave a gap between each pair of buffers.
diff --git a/drivers/media/video/cx88/Kconfig b/drivers/media/video/cx88/Kconfig
index f750a543c96..c68ba74d44e 100644
--- a/drivers/media/video/cx88/Kconfig
+++ b/drivers/media/video/cx88/Kconfig
@@ -4,7 +4,7 @@ config VIDEO_CX88
4 select I2C_ALGOBIT 4 select I2C_ALGOBIT
5 select FW_LOADER 5 select FW_LOADER
6 select VIDEO_BTCX 6 select VIDEO_BTCX
7 select VIDEO_BUF 7 select VIDEOBUF_DMA_SG
8 select VIDEO_TUNER 8 select VIDEO_TUNER
9 select VIDEO_TVEEPROM 9 select VIDEO_TVEEPROM
10 select VIDEO_IR 10 select VIDEO_IR
diff --git a/drivers/media/video/cx88/cx88-alsa.c b/drivers/media/video/cx88/cx88-alsa.c
index f4abed454fd..90c36c5705c 100644
--- a/drivers/media/video/cx88/cx88-alsa.c
+++ b/drivers/media/video/cx88/cx88-alsa.c
@@ -72,7 +72,7 @@ struct cx88_audio_dev {
72 unsigned int period_size; 72 unsigned int period_size;
73 unsigned int num_periods; 73 unsigned int num_periods;
74 74
75 struct videobuf_dmabuf dma_risc; 75 struct videobuf_dmabuf *dma_risc;
76 76
77 struct cx88_buffer *buf; 77 struct cx88_buffer *buf;
78 78
@@ -282,11 +282,12 @@ static int dsp_buffer_free(snd_cx88_card_t *chip)
282 BUG_ON(!chip->dma_size); 282 BUG_ON(!chip->dma_size);
283 283
284 dprintk(2,"Freeing buffer\n"); 284 dprintk(2,"Freeing buffer\n");
285 videobuf_pci_dma_unmap(chip->pci, &chip->dma_risc); 285 videobuf_pci_dma_unmap(chip->pci, chip->dma_risc);
286 videobuf_dma_free(&chip->dma_risc); 286 videobuf_dma_free(chip->dma_risc);
287 btcx_riscmem_free(chip->pci,&chip->buf->risc); 287 btcx_riscmem_free(chip->pci,&chip->buf->risc);
288 kfree(chip->buf); 288 kfree(chip->buf);
289 289
290 chip->dma_risc = NULL;
290 chip->dma_size = 0; 291 chip->dma_size = 0;
291 292
292 return 0; 293 return 0;
@@ -366,6 +367,8 @@ static int snd_cx88_hw_params(struct snd_pcm_substream * substream,
366 struct snd_pcm_hw_params * hw_params) 367 struct snd_pcm_hw_params * hw_params)
367{ 368{
368 snd_cx88_card_t *chip = snd_pcm_substream_chip(substream); 369 snd_cx88_card_t *chip = snd_pcm_substream_chip(substream);
370 struct videobuf_dmabuf *dma;
371
369 struct cx88_buffer *buf; 372 struct cx88_buffer *buf;
370 int ret; 373 int ret;
371 374
@@ -381,7 +384,7 @@ static int snd_cx88_hw_params(struct snd_pcm_substream * substream,
381 BUG_ON(!chip->dma_size); 384 BUG_ON(!chip->dma_size);
382 BUG_ON(chip->num_periods & (chip->num_periods-1)); 385 BUG_ON(chip->num_periods & (chip->num_periods-1));
383 386
384 buf = kzalloc(sizeof(*buf), GFP_KERNEL); 387 buf = videobuf_pci_alloc(sizeof(*buf));
385 if (NULL == buf) 388 if (NULL == buf)
386 return -ENOMEM; 389 return -ENOMEM;
387 390
@@ -392,17 +395,18 @@ static int snd_cx88_hw_params(struct snd_pcm_substream * substream,
392 buf->vb.height = chip->num_periods; 395 buf->vb.height = chip->num_periods;
393 buf->vb.size = chip->dma_size; 396 buf->vb.size = chip->dma_size;
394 397
395 videobuf_dma_init(&buf->vb.dma); 398 dma=videobuf_to_dma(&buf->vb);
396 ret = videobuf_dma_init_kernel(&buf->vb.dma, PCI_DMA_FROMDEVICE, 399 videobuf_dma_init(dma);
400 ret = videobuf_dma_init_kernel(dma, PCI_DMA_FROMDEVICE,
397 (PAGE_ALIGN(buf->vb.size) >> PAGE_SHIFT)); 401 (PAGE_ALIGN(buf->vb.size) >> PAGE_SHIFT));
398 if (ret < 0) 402 if (ret < 0)
399 goto error; 403 goto error;
400 404
401 ret = videobuf_pci_dma_map(chip->pci,&buf->vb.dma); 405 ret = videobuf_pci_dma_map(chip->pci,dma);
402 if (ret < 0) 406 if (ret < 0)
403 goto error; 407 goto error;
404 408
405 ret = cx88_risc_databuffer(chip->pci, &buf->risc, buf->vb.dma.sglist, 409 ret = cx88_risc_databuffer(chip->pci, &buf->risc, dma->sglist,
406 buf->vb.width, buf->vb.height, 1); 410 buf->vb.width, buf->vb.height, 1);
407 if (ret < 0) 411 if (ret < 0)
408 goto error; 412 goto error;
@@ -414,9 +418,9 @@ static int snd_cx88_hw_params(struct snd_pcm_substream * substream,
414 buf->vb.state = STATE_PREPARED; 418 buf->vb.state = STATE_PREPARED;
415 419
416 chip->buf = buf; 420 chip->buf = buf;
417 chip->dma_risc = buf->vb.dma; 421 chip->dma_risc = dma;
418 422
419 substream->runtime->dma_area = chip->dma_risc.vmalloc; 423 substream->runtime->dma_area = chip->dma_risc->vmalloc;
420 substream->runtime->dma_bytes = chip->dma_size; 424 substream->runtime->dma_bytes = chip->dma_size;
421 substream->runtime->dma_addr = 0; 425 substream->runtime->dma_addr = 0;
422 return 0; 426 return 0;
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c
index fcaf4f51293..6d6f5048d76 100644
--- a/drivers/media/video/cx88/cx88-blackbird.c
+++ b/drivers/media/video/cx88/cx88-blackbird.c
@@ -1111,7 +1111,7 @@ static int mpeg_open(struct inode *inode, struct file *file)
1111 file->private_data = fh; 1111 file->private_data = fh;
1112 fh->dev = dev; 1112 fh->dev = dev;
1113 1113
1114 videobuf_queue_init(&fh->mpegq, &blackbird_qops, 1114 videobuf_queue_pci_init(&fh->mpegq, &blackbird_qops,
1115 dev->pci, &dev->slock, 1115 dev->pci, &dev->slock,
1116 V4L2_BUF_TYPE_VIDEO_CAPTURE, 1116 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1117 V4L2_FIELD_INTERLACED, 1117 V4L2_FIELD_INTERLACED,
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index 716154828ff..85609b41f86 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -213,10 +213,12 @@ int cx88_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,
213void 213void
214cx88_free_buffer(struct videobuf_queue *q, struct cx88_buffer *buf) 214cx88_free_buffer(struct videobuf_queue *q, struct cx88_buffer *buf)
215{ 215{
216 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
217
216 BUG_ON(in_interrupt()); 218 BUG_ON(in_interrupt());
217 videobuf_waiton(&buf->vb,0,0); 219 videobuf_waiton(&buf->vb,0,0);
218 videobuf_dma_unmap(q, &buf->vb.dma); 220 videobuf_dma_unmap(q, dma);
219 videobuf_dma_free(&buf->vb.dma); 221 videobuf_dma_free(dma);
220 btcx_riscmem_free((struct pci_dev *)q->dev, &buf->risc); 222 btcx_riscmem_free((struct pci_dev *)q->dev, &buf->risc);
221 buf->vb.state = STATE_NEEDS_INIT; 223 buf->vb.state = STATE_NEEDS_INIT;
222} 224}
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index 00d0e43785a..d16e5c6d21c 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -710,7 +710,7 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv)
710 710
711 /* dvb stuff */ 711 /* dvb stuff */
712 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name); 712 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name);
713 videobuf_queue_init(&dev->dvb.dvbq, &dvb_qops, 713 videobuf_queue_pci_init(&dev->dvb.dvbq, &dvb_qops,
714 dev->pci, &dev->slock, 714 dev->pci, &dev->slock,
715 V4L2_BUF_TYPE_VIDEO_CAPTURE, 715 V4L2_BUF_TYPE_VIDEO_CAPTURE,
716 V4L2_FIELD_TOP, 716 V4L2_FIELD_TOP,
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c
index d302793fcfb..a652f294d23 100644
--- a/drivers/media/video/cx88/cx88-mpeg.c
+++ b/drivers/media/video/cx88/cx88-mpeg.c
@@ -237,6 +237,7 @@ int cx8802_buf_prepare(struct videobuf_queue *q, struct cx8802_dev *dev,
237 struct cx88_buffer *buf, enum v4l2_field field) 237 struct cx88_buffer *buf, enum v4l2_field field)
238{ 238{
239 int size = dev->ts_packet_size * dev->ts_packet_count; 239 int size = dev->ts_packet_size * dev->ts_packet_count;
240 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
240 int rc; 241 int rc;
241 242
242 dprintk(1, "%s: %p\n", __FUNCTION__, buf); 243 dprintk(1, "%s: %p\n", __FUNCTION__, buf);
@@ -252,7 +253,7 @@ int cx8802_buf_prepare(struct videobuf_queue *q, struct cx8802_dev *dev,
252 if (0 != (rc = videobuf_iolock(q,&buf->vb,NULL))) 253 if (0 != (rc = videobuf_iolock(q,&buf->vb,NULL)))
253 goto fail; 254 goto fail;
254 cx88_risc_databuffer(dev->pci, &buf->risc, 255 cx88_risc_databuffer(dev->pci, &buf->risc,
255 buf->vb.dma.sglist, 256 dma->sglist,
256 buf->vb.width, buf->vb.height, 0); 257 buf->vb.width, buf->vb.height, 0);
257 } 258 }
258 buf->vb.state = STATE_PREPARED; 259 buf->vb.state = STATE_PREPARED;
diff --git a/drivers/media/video/cx88/cx88-vbi.c b/drivers/media/video/cx88/cx88-vbi.c
index 72c1d19fa79..aa40505c4b3 100644
--- a/drivers/media/video/cx88/cx88-vbi.c
+++ b/drivers/media/video/cx88/cx88-vbi.c
@@ -172,6 +172,7 @@ vbi_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
172 return -EINVAL; 172 return -EINVAL;
173 173
174 if (STATE_NEEDS_INIT == buf->vb.state) { 174 if (STATE_NEEDS_INIT == buf->vb.state) {
175 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
175 buf->vb.width = VBI_LINE_LENGTH; 176 buf->vb.width = VBI_LINE_LENGTH;
176 buf->vb.height = VBI_LINE_COUNT; 177 buf->vb.height = VBI_LINE_COUNT;
177 buf->vb.size = size; 178 buf->vb.size = size;
@@ -180,7 +181,7 @@ vbi_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
180 if (0 != (rc = videobuf_iolock(q,&buf->vb,NULL))) 181 if (0 != (rc = videobuf_iolock(q,&buf->vb,NULL)))
181 goto fail; 182 goto fail;
182 cx88_risc_buffer(dev->pci, &buf->risc, 183 cx88_risc_buffer(dev->pci, &buf->risc,
183 buf->vb.dma.sglist, 184 dma->sglist,
184 0, buf->vb.width * buf->vb.height, 185 0, buf->vb.width * buf->vb.height,
185 buf->vb.width, 0, 186 buf->vb.width, 0,
186 buf->vb.height); 187 buf->vb.height);
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index 705c29b002e..1439b726853 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -534,6 +534,7 @@ buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
534 struct cx8800_dev *dev = fh->dev; 534 struct cx8800_dev *dev = fh->dev;
535 struct cx88_core *core = dev->core; 535 struct cx88_core *core = dev->core;
536 struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb); 536 struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb);
537 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
537 int rc, init_buffer = 0; 538 int rc, init_buffer = 0;
538 539
539 BUG_ON(NULL == fh->fmt); 540 BUG_ON(NULL == fh->fmt);
@@ -566,30 +567,30 @@ buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
566 switch (buf->vb.field) { 567 switch (buf->vb.field) {
567 case V4L2_FIELD_TOP: 568 case V4L2_FIELD_TOP:
568 cx88_risc_buffer(dev->pci, &buf->risc, 569 cx88_risc_buffer(dev->pci, &buf->risc,
569 buf->vb.dma.sglist, 0, UNSET, 570 dma->sglist, 0, UNSET,
570 buf->bpl, 0, buf->vb.height); 571 buf->bpl, 0, buf->vb.height);
571 break; 572 break;
572 case V4L2_FIELD_BOTTOM: 573 case V4L2_FIELD_BOTTOM:
573 cx88_risc_buffer(dev->pci, &buf->risc, 574 cx88_risc_buffer(dev->pci, &buf->risc,
574 buf->vb.dma.sglist, UNSET, 0, 575 dma->sglist, UNSET, 0,
575 buf->bpl, 0, buf->vb.height); 576 buf->bpl, 0, buf->vb.height);
576 break; 577 break;
577 case V4L2_FIELD_INTERLACED: 578 case V4L2_FIELD_INTERLACED:
578 cx88_risc_buffer(dev->pci, &buf->risc, 579 cx88_risc_buffer(dev->pci, &buf->risc,
579 buf->vb.dma.sglist, 0, buf->bpl, 580 dma->sglist, 0, buf->bpl,
580 buf->bpl, buf->bpl, 581 buf->bpl, buf->bpl,
581 buf->vb.height >> 1); 582 buf->vb.height >> 1);
582 break; 583 break;
583 case V4L2_FIELD_SEQ_TB: 584 case V4L2_FIELD_SEQ_TB:
584 cx88_risc_buffer(dev->pci, &buf->risc, 585 cx88_risc_buffer(dev->pci, &buf->risc,
585 buf->vb.dma.sglist, 586 dma->sglist,
586 0, buf->bpl * (buf->vb.height >> 1), 587 0, buf->bpl * (buf->vb.height >> 1),
587 buf->bpl, 0, 588 buf->bpl, 0,
588 buf->vb.height >> 1); 589 buf->vb.height >> 1);
589 break; 590 break;
590 case V4L2_FIELD_SEQ_BT: 591 case V4L2_FIELD_SEQ_BT:
591 cx88_risc_buffer(dev->pci, &buf->risc, 592 cx88_risc_buffer(dev->pci, &buf->risc,
592 buf->vb.dma.sglist, 593 dma->sglist,
593 buf->bpl * (buf->vb.height >> 1), 0, 594 buf->bpl * (buf->vb.height >> 1), 0,
594 buf->bpl, 0, 595 buf->bpl, 0,
595 buf->vb.height >> 1); 596 buf->vb.height >> 1);
@@ -752,13 +753,13 @@ static int video_open(struct inode *inode, struct file *file)
752 fh->height = 240; 753 fh->height = 240;
753 fh->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); 754 fh->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24);
754 755
755 videobuf_queue_init(&fh->vidq, &cx8800_video_qops, 756 videobuf_queue_pci_init(&fh->vidq, &cx8800_video_qops,
756 dev->pci, &dev->slock, 757 dev->pci, &dev->slock,
757 V4L2_BUF_TYPE_VIDEO_CAPTURE, 758 V4L2_BUF_TYPE_VIDEO_CAPTURE,
758 V4L2_FIELD_INTERLACED, 759 V4L2_FIELD_INTERLACED,
759 sizeof(struct cx88_buffer), 760 sizeof(struct cx88_buffer),
760 fh); 761 fh);
761 videobuf_queue_init(&fh->vbiq, &cx8800_vbi_qops, 762 videobuf_queue_pci_init(&fh->vbiq, &cx8800_vbi_qops,
762 dev->pci, &dev->slock, 763 dev->pci, &dev->slock,
763 V4L2_BUF_TYPE_VBI_CAPTURE, 764 V4L2_BUF_TYPE_VBI_CAPTURE,
764 V4L2_FIELD_SEQ_TB, 765 V4L2_FIELD_SEQ_TB,
@@ -1104,28 +1105,9 @@ static int vidioc_enum_fmt_cap (struct file *file, void *priv,
1104#ifdef CONFIG_VIDEO_V4L1_COMPAT 1105#ifdef CONFIG_VIDEO_V4L1_COMPAT
1105static int vidiocgmbuf (struct file *file, void *priv, struct video_mbuf *mbuf) 1106static int vidiocgmbuf (struct file *file, void *priv, struct video_mbuf *mbuf)
1106{ 1107{
1107 struct cx8800_fh *fh = priv; 1108 struct cx8800_fh *fh = priv;
1108 struct videobuf_queue *q;
1109 struct v4l2_requestbuffers req;
1110 unsigned int i;
1111 int err;
1112 1109
1113 q = get_queue(fh); 1110 return videobuf_cgmbuf (get_queue(fh), mbuf, 8);
1114 memset(&req,0,sizeof(req));
1115 req.type = q->type;
1116 req.count = 8;
1117 req.memory = V4L2_MEMORY_MMAP;
1118 err = videobuf_reqbufs(q,&req);
1119 if (err < 0)
1120 return err;
1121
1122 mbuf->frames = req.count;
1123 mbuf->size = 0;
1124 for (i = 0; i < mbuf->frames; i++) {
1125 mbuf->offsets[i] = q->bufs[i]->boff;
1126 mbuf->size += q->bufs[i]->bsize;
1127 }
1128 return 0;
1129} 1111}
1130#endif 1112#endif
1131 1113
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index 0e4f8e27867..875a9abab2a 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -28,7 +28,7 @@
28#include <media/v4l2-common.h> 28#include <media/v4l2-common.h>
29#include <media/tuner.h> 29#include <media/tuner.h>
30#include <media/tveeprom.h> 30#include <media/tveeprom.h>
31#include <media/video-buf.h> 31#include <media/videobuf-dma-sg.h>
32#include <media/cx2341x.h> 32#include <media/cx2341x.h>
33#include <media/audiochip.h> 33#include <media/audiochip.h>
34#if defined(CONFIG_VIDEO_BUF_DVB) || defined(CONFIG_VIDEO_BUF_DVB_MODULE) 34#if defined(CONFIG_VIDEO_BUF_DVB) || defined(CONFIG_VIDEO_BUF_DVB_MODULE)
diff --git a/drivers/media/video/saa7134/Kconfig b/drivers/media/video/saa7134/Kconfig
index 9f1417a4f7d..82bc4ef414a 100644
--- a/drivers/media/video/saa7134/Kconfig
+++ b/drivers/media/video/saa7134/Kconfig
@@ -1,7 +1,7 @@
1config VIDEO_SAA7134 1config VIDEO_SAA7134
2 tristate "Philips SAA7134 support" 2 tristate "Philips SAA7134 support"
3 depends on VIDEO_DEV && PCI && I2C 3 depends on VIDEO_DEV && PCI && I2C
4 select VIDEO_BUF 4 select VIDEOBUF_DMA_SG
5 select VIDEO_IR 5 select VIDEO_IR
6 select VIDEO_TUNER 6 select VIDEO_TUNER
7 select CRC32 7 select CRC32
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index 80108ddf483..a1d986e01a3 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -236,9 +236,10 @@ int saa7134_buffer_startpage(struct saa7134_buf *buf)
236unsigned long saa7134_buffer_base(struct saa7134_buf *buf) 236unsigned long saa7134_buffer_base(struct saa7134_buf *buf)
237{ 237{
238 unsigned long base; 238 unsigned long base;
239 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
239 240
240 base = saa7134_buffer_startpage(buf) * 4096; 241 base = saa7134_buffer_startpage(buf) * 4096;
241 base += buf->vb.dma.sglist[0].offset; 242 base += dma->sglist[0].offset;
242 return base; 243 return base;
243} 244}
244 245
@@ -286,11 +287,12 @@ void saa7134_pgtable_free(struct pci_dev *pci, struct saa7134_pgtable *pt)
286 287
287void saa7134_dma_free(struct videobuf_queue *q,struct saa7134_buf *buf) 288void saa7134_dma_free(struct videobuf_queue *q,struct saa7134_buf *buf)
288{ 289{
290 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
289 BUG_ON(in_interrupt()); 291 BUG_ON(in_interrupt());
290 292
291 videobuf_waiton(&buf->vb,0,0); 293 videobuf_waiton(&buf->vb,0,0);
292 videobuf_dma_unmap(q, &buf->vb.dma); 294 videobuf_dma_unmap(q, dma);
293 videobuf_dma_free(&buf->vb.dma); 295 videobuf_dma_free(dma);
294 buf->vb.state = STATE_NEEDS_INIT; 296 buf->vb.state = STATE_NEEDS_INIT;
295} 297}
296 298
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index bbab252cbee..38d87332cc5 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -850,7 +850,7 @@ static int dvb_init(struct saa7134_dev *dev)
850 dev->ts.nr_bufs = 32; 850 dev->ts.nr_bufs = 32;
851 dev->ts.nr_packets = 32*4; 851 dev->ts.nr_packets = 32*4;
852 dev->dvb.name = dev->name; 852 dev->dvb.name = dev->name;
853 videobuf_queue_init(&dev->dvb.dvbq, &saa7134_ts_qops, 853 videobuf_queue_pci_init(&dev->dvb.dvbq, &saa7134_ts_qops,
854 dev->pci, &dev->slock, 854 dev->pci, &dev->slock,
855 V4L2_BUF_TYPE_VIDEO_CAPTURE, 855 V4L2_BUF_TYPE_VIDEO_CAPTURE,
856 V4L2_FIELD_ALTERNATE, 856 V4L2_FIELD_ALTERNATE,
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c
index 7ed4eaf05e1..a16df57af63 100644
--- a/drivers/media/video/saa7134/saa7134-empress.c
+++ b/drivers/media/video/saa7134/saa7134-empress.c
@@ -400,7 +400,7 @@ static int empress_init(struct saa7134_dev *dev)
400 printk(KERN_INFO "%s: registered device video%d [mpeg]\n", 400 printk(KERN_INFO "%s: registered device video%d [mpeg]\n",
401 dev->name,dev->empress_dev->minor & 0x1f); 401 dev->name,dev->empress_dev->minor & 0x1f);
402 402
403 videobuf_queue_init(&dev->empress_tsq, &saa7134_ts_qops, 403 videobuf_queue_pci_init(&dev->empress_tsq, &saa7134_ts_qops,
404 dev->pci, &dev->slock, 404 dev->pci, &dev->slock,
405 V4L2_BUF_TYPE_VIDEO_CAPTURE, 405 V4L2_BUF_TYPE_VIDEO_CAPTURE,
406 V4L2_FIELD_ALTERNATE, 406 V4L2_FIELD_ALTERNATE,
diff --git a/drivers/media/video/saa7134/saa7134-ts.c b/drivers/media/video/saa7134/saa7134-ts.c
index 7780b2cce80..5b1d1dafb5a 100644
--- a/drivers/media/video/saa7134/saa7134-ts.c
+++ b/drivers/media/video/saa7134/saa7134-ts.c
@@ -92,6 +92,8 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
92 } 92 }
93 93
94 if (STATE_NEEDS_INIT == buf->vb.state) { 94 if (STATE_NEEDS_INIT == buf->vb.state) {
95 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
96
95 buf->vb.width = llength; 97 buf->vb.width = llength;
96 buf->vb.height = lines; 98 buf->vb.height = lines;
97 buf->vb.size = size; 99 buf->vb.size = size;
@@ -101,8 +103,8 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
101 if (err) 103 if (err)
102 goto oops; 104 goto oops;
103 err = saa7134_pgtable_build(dev->pci,buf->pt, 105 err = saa7134_pgtable_build(dev->pci,buf->pt,
104 buf->vb.dma.sglist, 106 dma->sglist,
105 buf->vb.dma.sglen, 107 dma->sglen,
106 saa7134_buffer_startpage(buf)); 108 saa7134_buffer_startpage(buf));
107 if (err) 109 if (err)
108 goto oops; 110 goto oops;
diff --git a/drivers/media/video/saa7134/saa7134-vbi.c b/drivers/media/video/saa7134/saa7134-vbi.c
index 0044079f5da..81a2aedeff5 100644
--- a/drivers/media/video/saa7134/saa7134-vbi.c
+++ b/drivers/media/video/saa7134/saa7134-vbi.c
@@ -137,6 +137,8 @@ static int buffer_prepare(struct videobuf_queue *q,
137 saa7134_dma_free(q,buf); 137 saa7134_dma_free(q,buf);
138 138
139 if (STATE_NEEDS_INIT == buf->vb.state) { 139 if (STATE_NEEDS_INIT == buf->vb.state) {
140 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
141
140 buf->vb.width = llength; 142 buf->vb.width = llength;
141 buf->vb.height = lines; 143 buf->vb.height = lines;
142 buf->vb.size = size; 144 buf->vb.size = size;
@@ -146,8 +148,8 @@ static int buffer_prepare(struct videobuf_queue *q,
146 if (err) 148 if (err)
147 goto oops; 149 goto oops;
148 err = saa7134_pgtable_build(dev->pci,buf->pt, 150 err = saa7134_pgtable_build(dev->pci,buf->pt,
149 buf->vb.dma.sglist, 151 dma->sglist,
150 buf->vb.dma.sglen, 152 dma->sglen,
151 saa7134_buffer_startpage(buf)); 153 saa7134_buffer_startpage(buf));
152 if (err) 154 if (err)
153 goto oops; 155 goto oops;
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
index 9c317ed6b21..cf40a9690a5 100644
--- a/drivers/media/video/saa7134/saa7134-video.c
+++ b/drivers/media/video/saa7134/saa7134-video.c
@@ -1037,6 +1037,8 @@ static int buffer_prepare(struct videobuf_queue *q,
1037 } 1037 }
1038 1038
1039 if (STATE_NEEDS_INIT == buf->vb.state) { 1039 if (STATE_NEEDS_INIT == buf->vb.state) {
1040 struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
1041
1040 buf->vb.width = fh->width; 1042 buf->vb.width = fh->width;
1041 buf->vb.height = fh->height; 1043 buf->vb.height = fh->height;
1042 buf->vb.size = size; 1044 buf->vb.size = size;
@@ -1048,8 +1050,8 @@ static int buffer_prepare(struct videobuf_queue *q,
1048 if (err) 1050 if (err)
1049 goto oops; 1051 goto oops;
1050 err = saa7134_pgtable_build(dev->pci,buf->pt, 1052 err = saa7134_pgtable_build(dev->pci,buf->pt,
1051 buf->vb.dma.sglist, 1053 dma->sglist,
1052 buf->vb.dma.sglen, 1054 dma->sglen,
1053 saa7134_buffer_startpage(buf)); 1055 saa7134_buffer_startpage(buf));
1054 if (err) 1056 if (err)
1055 goto oops; 1057 goto oops;
@@ -1309,13 +1311,13 @@ static int video_open(struct inode *inode, struct file *file)
1309 fh->height = 576; 1311 fh->height = 576;
1310 v4l2_prio_open(&dev->prio,&fh->prio); 1312 v4l2_prio_open(&dev->prio,&fh->prio);
1311 1313
1312 videobuf_queue_init(&fh->cap, &video_qops, 1314 videobuf_queue_pci_init(&fh->cap, &video_qops,
1313 dev->pci, &dev->slock, 1315 dev->pci, &dev->slock,
1314 V4L2_BUF_TYPE_VIDEO_CAPTURE, 1316 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1315 V4L2_FIELD_INTERLACED, 1317 V4L2_FIELD_INTERLACED,
1316 sizeof(struct saa7134_buf), 1318 sizeof(struct saa7134_buf),
1317 fh); 1319 fh);
1318 videobuf_queue_init(&fh->vbi, &saa7134_vbi_qops, 1320 videobuf_queue_pci_init(&fh->vbi, &saa7134_vbi_qops,
1319 dev->pci, &dev->slock, 1321 dev->pci, &dev->slock,
1320 V4L2_BUF_TYPE_VBI_CAPTURE, 1322 V4L2_BUF_TYPE_VBI_CAPTURE,
1321 V4L2_FIELD_SEQ_TB, 1323 V4L2_FIELD_SEQ_TB,
@@ -2137,29 +2139,7 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
2137 } 2139 }
2138#ifdef CONFIG_VIDEO_V4L1_COMPAT 2140#ifdef CONFIG_VIDEO_V4L1_COMPAT
2139 case VIDIOCGMBUF: 2141 case VIDIOCGMBUF:
2140 { 2142 return videobuf_cgmbuf(saa7134_queue(fh), arg, gbuffers);
2141 struct video_mbuf *mbuf = arg;
2142 struct videobuf_queue *q;
2143 struct v4l2_requestbuffers req;
2144 unsigned int i;
2145
2146 q = saa7134_queue(fh);
2147 memset(&req,0,sizeof(req));
2148 req.type = q->type;
2149 req.count = gbuffers;
2150 req.memory = V4L2_MEMORY_MMAP;
2151 err = videobuf_reqbufs(q,&req);
2152 if (err < 0)
2153 return err;
2154 memset(mbuf,0,sizeof(*mbuf));
2155 mbuf->frames = req.count;
2156 mbuf->size = 0;
2157 for (i = 0; i < mbuf->frames; i++) {
2158 mbuf->offsets[i] = q->bufs[i]->boff;
2159 mbuf->size += q->bufs[i]->bsize;
2160 }
2161 return 0;
2162 }
2163#endif 2143#endif
2164 case VIDIOC_REQBUFS: 2144 case VIDIOC_REQBUFS:
2165 return videobuf_reqbufs(saa7134_queue(fh),arg); 2145 return videobuf_reqbufs(saa7134_queue(fh),arg);
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index fd12942b3a1..dae608f9bf3 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -37,7 +37,7 @@
37#include <media/tuner.h> 37#include <media/tuner.h>
38#include <media/ir-common.h> 38#include <media/ir-common.h>
39#include <media/ir-kbd-i2c.h> 39#include <media/ir-kbd-i2c.h>
40#include <media/video-buf.h> 40#include <media/videobuf-dma-sg.h>
41#include <sound/driver.h> 41#include <sound/driver.h>
42#include <sound/core.h> 42#include <sound/core.h>
43#include <sound/pcm.h> 43#include <sound/pcm.h>
diff --git a/drivers/media/video/video-buf-dvb.c b/drivers/media/video/video-buf-dvb.c
index d2af82dc8fa..9631ead297e 100644
--- a/drivers/media/video/video-buf-dvb.c
+++ b/drivers/media/video/video-buf-dvb.c
@@ -22,7 +22,7 @@
22#include <linux/file.h> 22#include <linux/file.h>
23#include <linux/freezer.h> 23#include <linux/freezer.h>
24 24
25#include <media/video-buf.h> 25#include <media/videobuf-dma-sg.h>
26#include <media/video-buf-dvb.h> 26#include <media/video-buf-dvb.h>
27 27
28/* ------------------------------------------------------------------ */ 28/* ------------------------------------------------------------------ */
@@ -45,6 +45,7 @@ static int videobuf_dvb_thread(void *data)
45 struct videobuf_buffer *buf; 45 struct videobuf_buffer *buf;
46 unsigned long flags; 46 unsigned long flags;
47 int err; 47 int err;
48 struct videobuf_dmabuf *dma;
48 49
49 dprintk("dvb thread started\n"); 50 dprintk("dvb thread started\n");
50 set_freezable(); 51 set_freezable();
@@ -65,8 +66,9 @@ static int videobuf_dvb_thread(void *data)
65 try_to_freeze(); 66 try_to_freeze();
66 67
67 /* feed buffer data to demux */ 68 /* feed buffer data to demux */
69 dma=videobuf_to_dma(buf);
68 if (buf->state == STATE_DONE) 70 if (buf->state == STATE_DONE)
69 dvb_dmx_swfilter(&dvb->demux, buf->dma.vmalloc, 71 dvb_dmx_swfilter(&dvb->demux, dma->vmalloc,
70 buf->size); 72 buf->size);
71 73
72 /* requeue buffer */ 74 /* requeue buffer */