aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/saa7134
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2006-03-10 10:29:15 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-03-24 14:26:49 -0500
commitc7b0ac0546985fc6361a8d92cf808d46da797677 (patch)
tree2147eb2f6dd7b2b82e0d7b4b9a26e12ef5193252 /drivers/media/video/saa7134
parentb2fd16b4ff2508ac16ae994f4bcd941f97754c00 (diff)
V4L/DVB (3516): Make video_buf more generic
Video_buf were concerned to allow PCI devices to be used as video capture devices. This patch extends video_buf features by virtualizing pci-dependent functions and allowing other type of devices to use it. It is still DMA centric, although it may be used also by devices that emulates scatter/gather behavior or a DMA device Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/saa7134')
-rw-r--r--drivers/media/video/saa7134/saa7134-alsa.c10
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c4
-rw-r--r--drivers/media/video/saa7134/saa7134-oss.c6
-rw-r--r--drivers/media/video/saa7134/saa7134-ts.c9
-rw-r--r--drivers/media/video/saa7134/saa7134-vbi.c10
-rw-r--r--drivers/media/video/saa7134/saa7134-video.c9
-rw-r--r--drivers/media/video/saa7134/saa7134.h2
7 files changed, 23 insertions, 27 deletions
diff --git a/drivers/media/video/saa7134/saa7134-alsa.c b/drivers/media/video/saa7134/saa7134-alsa.c
index aca84d2f9825..bb3e0ba946d3 100644
--- a/drivers/media/video/saa7134/saa7134-alsa.c
+++ b/drivers/media/video/saa7134/saa7134-alsa.c
@@ -507,7 +507,7 @@ static int snd_card_saa7134_hw_params(struct snd_pcm_substream * substream,
507 /* release the old buffer */ 507 /* release the old buffer */
508 if (substream->runtime->dma_area) { 508 if (substream->runtime->dma_area) {
509 saa7134_pgtable_free(dev->pci, &dev->dmasound.pt); 509 saa7134_pgtable_free(dev->pci, &dev->dmasound.pt);
510 videobuf_dma_pci_unmap(dev->pci, &dev->dmasound.dma); 510 videobuf_pci_dma_unmap(dev->pci, &dev->dmasound.dma);
511 dsp_buffer_free(dev); 511 dsp_buffer_free(dev);
512 substream->runtime->dma_area = NULL; 512 substream->runtime->dma_area = NULL;
513 } 513 }
@@ -523,12 +523,12 @@ static int snd_card_saa7134_hw_params(struct snd_pcm_substream * substream,
523 return err; 523 return err;
524 } 524 }
525 525
526 if (0 != (err = videobuf_dma_pci_map(dev->pci, &dev->dmasound.dma))) { 526 if (0 != (err = videobuf_pci_dma_map(dev->pci, &dev->dmasound.dma))) {
527 dsp_buffer_free(dev); 527 dsp_buffer_free(dev);
528 return err; 528 return err;
529 } 529 }
530 if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->dmasound.pt))) { 530 if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->dmasound.pt))) {
531 videobuf_dma_pci_unmap(dev->pci, &dev->dmasound.dma); 531 videobuf_pci_dma_unmap(dev->pci, &dev->dmasound.dma);
532 dsp_buffer_free(dev); 532 dsp_buffer_free(dev);
533 return err; 533 return err;
534 } 534 }
@@ -537,7 +537,7 @@ static int snd_card_saa7134_hw_params(struct snd_pcm_substream * substream,
537 dev->dmasound.dma.sglen, 537 dev->dmasound.dma.sglen,
538 0))) { 538 0))) {
539 saa7134_pgtable_free(dev->pci, &dev->dmasound.pt); 539 saa7134_pgtable_free(dev->pci, &dev->dmasound.pt);
540 videobuf_dma_pci_unmap(dev->pci, &dev->dmasound.dma); 540 videobuf_pci_dma_unmap(dev->pci, &dev->dmasound.dma);
541 dsp_buffer_free(dev); 541 dsp_buffer_free(dev);
542 return err; 542 return err;
543 } 543 }
@@ -571,7 +571,7 @@ static int snd_card_saa7134_hw_free(struct snd_pcm_substream * substream)
571 571
572 if (substream->runtime->dma_area) { 572 if (substream->runtime->dma_area) {
573 saa7134_pgtable_free(dev->pci, &dev->dmasound.pt); 573 saa7134_pgtable_free(dev->pci, &dev->dmasound.pt);
574 videobuf_dma_pci_unmap(dev->pci, &dev->dmasound.dma); 574 videobuf_pci_dma_unmap(dev->pci, &dev->dmasound.dma);
575 dsp_buffer_free(dev); 575 dsp_buffer_free(dev);
576 substream->runtime->dma_area = NULL; 576 substream->runtime->dma_area = NULL;
577 } 577 }
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index 58e568d7d2ee..15405d1e1675 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -254,12 +254,12 @@ void saa7134_pgtable_free(struct pci_dev *pci, struct saa7134_pgtable *pt)
254 254
255/* ------------------------------------------------------------------ */ 255/* ------------------------------------------------------------------ */
256 256
257void saa7134_dma_free(struct saa7134_dev *dev,struct saa7134_buf *buf) 257void saa7134_dma_free(struct videobuf_queue *q,struct saa7134_buf *buf)
258{ 258{
259 BUG_ON(in_interrupt()); 259 BUG_ON(in_interrupt());
260 260
261 videobuf_waiton(&buf->vb,0,0); 261 videobuf_waiton(&buf->vb,0,0);
262 videobuf_dma_pci_unmap(dev->pci, &buf->vb.dma); 262 videobuf_dma_unmap(q, &buf->vb.dma);
263 videobuf_dma_free(&buf->vb.dma); 263 videobuf_dma_free(&buf->vb.dma);
264 buf->vb.state = STATE_NEEDS_INIT; 264 buf->vb.state = STATE_NEEDS_INIT;
265} 265}
diff --git a/drivers/media/video/saa7134/saa7134-oss.c b/drivers/media/video/saa7134/saa7134-oss.c
index d79d05f88705..7aa02b34e012 100644
--- a/drivers/media/video/saa7134/saa7134-oss.c
+++ b/drivers/media/video/saa7134/saa7134-oss.c
@@ -124,7 +124,7 @@ static int dsp_rec_start(struct saa7134_dev *dev)
124 unsigned long flags; 124 unsigned long flags;
125 125
126 /* prepare buffer */ 126 /* prepare buffer */
127 if (0 != (err = videobuf_dma_pci_map(dev->pci,&dev->dmasound.dma))) 127 if (0 != (err = videobuf_pci_dma_map(dev->pci,&dev->dmasound.dma)))
128 return err; 128 return err;
129 if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->dmasound.pt))) 129 if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->dmasound.pt)))
130 goto fail1; 130 goto fail1;
@@ -213,7 +213,7 @@ static int dsp_rec_start(struct saa7134_dev *dev)
213 fail2: 213 fail2:
214 saa7134_pgtable_free(dev->pci,&dev->dmasound.pt); 214 saa7134_pgtable_free(dev->pci,&dev->dmasound.pt);
215 fail1: 215 fail1:
216 videobuf_dma_pci_unmap(dev->pci,&dev->dmasound.dma); 216 videobuf_pci_dma_unmap(dev->pci,&dev->dmasound.dma);
217 return err; 217 return err;
218} 218}
219 219
@@ -231,7 +231,7 @@ static int dsp_rec_stop(struct saa7134_dev *dev)
231 231
232 /* unlock buffer */ 232 /* unlock buffer */
233 saa7134_pgtable_free(dev->pci,&dev->dmasound.pt); 233 saa7134_pgtable_free(dev->pci,&dev->dmasound.pt);
234 videobuf_dma_pci_unmap(dev->pci,&dev->dmasound.dma); 234 videobuf_pci_dma_unmap(dev->pci,&dev->dmasound.dma);
235 return 0; 235 return 0;
236} 236}
237 237
diff --git a/drivers/media/video/saa7134/saa7134-ts.c b/drivers/media/video/saa7134/saa7134-ts.c
index 470903e2f5e5..60a90a2617ae 100644
--- a/drivers/media/video/saa7134/saa7134-ts.c
+++ b/drivers/media/video/saa7134/saa7134-ts.c
@@ -89,7 +89,7 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
89 return -EINVAL; 89 return -EINVAL;
90 90
91 if (buf->vb.size != size) { 91 if (buf->vb.size != size) {
92 saa7134_dma_free(dev,buf); 92 saa7134_dma_free(q,buf);
93 } 93 }
94 94
95 if (STATE_NEEDS_INIT == buf->vb.state) { 95 if (STATE_NEEDS_INIT == buf->vb.state) {
@@ -98,7 +98,7 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
98 buf->vb.size = size; 98 buf->vb.size = size;
99 buf->pt = &dev->ts.pt_ts; 99 buf->pt = &dev->ts.pt_ts;
100 100
101 err = videobuf_iolock(dev->pci,&buf->vb,NULL); 101 err = videobuf_iolock(q,&buf->vb,NULL);
102 if (err) 102 if (err)
103 goto oops; 103 goto oops;
104 err = saa7134_pgtable_build(dev->pci,buf->pt, 104 err = saa7134_pgtable_build(dev->pci,buf->pt,
@@ -126,7 +126,7 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
126 return 0; 126 return 0;
127 127
128 oops: 128 oops:
129 saa7134_dma_free(dev,buf); 129 saa7134_dma_free(q,buf);
130 return err; 130 return err;
131} 131}
132 132
@@ -152,10 +152,9 @@ static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
152 152
153static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) 153static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
154{ 154{
155 struct saa7134_dev *dev = q->priv_data;
156 struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb); 155 struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
157 156
158 saa7134_dma_free(dev,buf); 157 saa7134_dma_free(q,buf);
159} 158}
160 159
161struct videobuf_queue_ops saa7134_ts_qops = { 160struct videobuf_queue_ops saa7134_ts_qops = {
diff --git a/drivers/media/video/saa7134/saa7134-vbi.c b/drivers/media/video/saa7134/saa7134-vbi.c
index f4aee0af80e1..f38366a470fa 100644
--- a/drivers/media/video/saa7134/saa7134-vbi.c
+++ b/drivers/media/video/saa7134/saa7134-vbi.c
@@ -135,7 +135,7 @@ static int buffer_prepare(struct videobuf_queue *q,
135 return -EINVAL; 135 return -EINVAL;
136 136
137 if (buf->vb.size != size) 137 if (buf->vb.size != size)
138 saa7134_dma_free(dev,buf); 138 saa7134_dma_free(q,buf);
139 139
140 if (STATE_NEEDS_INIT == buf->vb.state) { 140 if (STATE_NEEDS_INIT == buf->vb.state) {
141 buf->vb.width = llength; 141 buf->vb.width = llength;
@@ -143,7 +143,7 @@ static int buffer_prepare(struct videobuf_queue *q,
143 buf->vb.size = size; 143 buf->vb.size = size;
144 buf->pt = &fh->pt_vbi; 144 buf->pt = &fh->pt_vbi;
145 145
146 err = videobuf_iolock(dev->pci,&buf->vb,NULL); 146 err = videobuf_iolock(q,&buf->vb,NULL);
147 if (err) 147 if (err)
148 goto oops; 148 goto oops;
149 err = saa7134_pgtable_build(dev->pci,buf->pt, 149 err = saa7134_pgtable_build(dev->pci,buf->pt,
@@ -159,7 +159,7 @@ static int buffer_prepare(struct videobuf_queue *q,
159 return 0; 159 return 0;
160 160
161 oops: 161 oops:
162 saa7134_dma_free(dev,buf); 162 saa7134_dma_free(q,buf);
163 return err; 163 return err;
164} 164}
165 165
@@ -190,11 +190,9 @@ static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
190 190
191static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) 191static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
192{ 192{
193 struct saa7134_fh *fh = q->priv_data;
194 struct saa7134_dev *dev = fh->dev;
195 struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb); 193 struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
196 194
197 saa7134_dma_free(dev,buf); 195 saa7134_dma_free(q,buf);
198} 196}
199 197
200struct videobuf_queue_ops saa7134_vbi_qops = { 198struct videobuf_queue_ops saa7134_vbi_qops = {
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
index 57a11e71d996..aeef80f88a6b 100644
--- a/drivers/media/video/saa7134/saa7134-video.c
+++ b/drivers/media/video/saa7134/saa7134-video.c
@@ -993,7 +993,7 @@ static int buffer_prepare(struct videobuf_queue *q,
993 buf->vb.size != size || 993 buf->vb.size != size ||
994 buf->vb.field != field || 994 buf->vb.field != field ||
995 buf->fmt != fh->fmt) { 995 buf->fmt != fh->fmt) {
996 saa7134_dma_free(dev,buf); 996 saa7134_dma_free(q,buf);
997 } 997 }
998 998
999 if (STATE_NEEDS_INIT == buf->vb.state) { 999 if (STATE_NEEDS_INIT == buf->vb.state) {
@@ -1004,7 +1004,7 @@ static int buffer_prepare(struct videobuf_queue *q,
1004 buf->fmt = fh->fmt; 1004 buf->fmt = fh->fmt;
1005 buf->pt = &fh->pt_cap; 1005 buf->pt = &fh->pt_cap;
1006 1006
1007 err = videobuf_iolock(dev->pci,&buf->vb,&dev->ovbuf); 1007 err = videobuf_iolock(q,&buf->vb,&dev->ovbuf);
1008 if (err) 1008 if (err)
1009 goto oops; 1009 goto oops;
1010 err = saa7134_pgtable_build(dev->pci,buf->pt, 1010 err = saa7134_pgtable_build(dev->pci,buf->pt,
@@ -1019,7 +1019,7 @@ static int buffer_prepare(struct videobuf_queue *q,
1019 return 0; 1019 return 0;
1020 1020
1021 oops: 1021 oops:
1022 saa7134_dma_free(dev,buf); 1022 saa7134_dma_free(q,buf);
1023 return err; 1023 return err;
1024} 1024}
1025 1025
@@ -1045,10 +1045,9 @@ static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
1045 1045
1046static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) 1046static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
1047{ 1047{
1048 struct saa7134_fh *fh = q->priv_data;
1049 struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb); 1048 struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
1050 1049
1051 saa7134_dma_free(fh->dev,buf); 1050 saa7134_dma_free(q,buf);
1052} 1051}
1053 1052
1054static struct videobuf_queue_ops video_qops = { 1053static struct videobuf_queue_ops video_qops = {
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index ce1c2e0b065e..104bd2e054e5 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -579,7 +579,7 @@ void saa7134_buffer_finish(struct saa7134_dev *dev, struct saa7134_dmaqueue *q,
579 unsigned int state); 579 unsigned int state);
580void saa7134_buffer_next(struct saa7134_dev *dev, struct saa7134_dmaqueue *q); 580void saa7134_buffer_next(struct saa7134_dev *dev, struct saa7134_dmaqueue *q);
581void saa7134_buffer_timeout(unsigned long data); 581void saa7134_buffer_timeout(unsigned long data);
582void saa7134_dma_free(struct saa7134_dev *dev,struct saa7134_buf *buf); 582void saa7134_dma_free(struct videobuf_queue *q,struct saa7134_buf *buf);
583 583
584int saa7134_set_dmabits(struct saa7134_dev *dev); 584int saa7134_set_dmabits(struct saa7134_dev *dev);
585 585