aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--drivers/media/common/saa7146_fops.c5
-rw-r--r--drivers/media/common/saa7146_vbi.c8
-rw-r--r--drivers/media/common/saa7146_video.c8
-rw-r--r--drivers/media/video/bttv-driver.c19
-rw-r--r--drivers/media/video/bttv-risc.c4
-rw-r--r--drivers/media/video/bttv-vbi.c6
-rw-r--r--drivers/media/video/bttvp.h3
-rw-r--r--drivers/media/video/cx88/cx88-alsa.c4
-rw-r--r--drivers/media/video/cx88/cx88-blackbird.c5
-rw-r--r--drivers/media/video/cx88/cx88-core.c6
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c5
-rw-r--r--drivers/media/video/cx88/cx88-mpeg.c28
-rw-r--r--drivers/media/video/cx88/cx88-vbi.c7
-rw-r--r--drivers/media/video/cx88/cx88-video.c35
-rw-r--r--drivers/media/video/cx88/cx88.h6
-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
-rw-r--r--drivers/media/video/v4l2-common.c6
-rw-r--r--drivers/media/video/video-buf.c250
-rw-r--r--include/media/saa7146_vv.h3
-rw-r--r--include/media/video-buf.h56
26 files changed, 340 insertions, 174 deletions
diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c
index 3870fa948cc0..523ab3851c7b 100644
--- a/drivers/media/common/saa7146_fops.c
+++ b/drivers/media/common/saa7146_fops.c
@@ -50,14 +50,15 @@ void saa7146_res_free(struct saa7146_fh *fh, unsigned int bits)
50/********************************************************************************/ 50/********************************************************************************/
51/* common dma functions */ 51/* common dma functions */
52 52
53void saa7146_dma_free(struct saa7146_dev *dev,struct saa7146_buf *buf) 53void saa7146_dma_free(struct saa7146_dev *dev,struct videobuf_queue *q,
54 struct saa7146_buf *buf)
54{ 55{
55 DEB_EE(("dev:%p, buf:%p\n",dev,buf)); 56 DEB_EE(("dev:%p, buf:%p\n",dev,buf));
56 57
57 BUG_ON(in_interrupt()); 58 BUG_ON(in_interrupt());
58 59
59 videobuf_waiton(&buf->vb,0,0); 60 videobuf_waiton(&buf->vb,0,0);
60 videobuf_dma_pci_unmap(dev->pci, &buf->vb.dma); 61 videobuf_dma_unmap(q, &buf->vb.dma);
61 videobuf_dma_free(&buf->vb.dma); 62 videobuf_dma_free(&buf->vb.dma);
62 buf->vb.state = STATE_NEEDS_INIT; 63 buf->vb.state = STATE_NEEDS_INIT;
63} 64}
diff --git a/drivers/media/common/saa7146_vbi.c b/drivers/media/common/saa7146_vbi.c
index 500bd3f05e16..063608462ebe 100644
--- a/drivers/media/common/saa7146_vbi.c
+++ b/drivers/media/common/saa7146_vbi.c
@@ -236,7 +236,7 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,e
236 } 236 }
237 237
238 if (buf->vb.size != size) 238 if (buf->vb.size != size)
239 saa7146_dma_free(dev,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 buf->vb.width = llength; 242 buf->vb.width = llength;
@@ -247,7 +247,7 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,e
247 saa7146_pgtable_free(dev->pci, &buf->pt[2]); 247 saa7146_pgtable_free(dev->pci, &buf->pt[2]);
248 saa7146_pgtable_alloc(dev->pci, &buf->pt[2]); 248 saa7146_pgtable_alloc(dev->pci, &buf->pt[2]);
249 249
250 err = videobuf_iolock(dev->pci,&buf->vb, NULL); 250 err = videobuf_iolock(q,&buf->vb, NULL);
251 if (err) 251 if (err)
252 goto oops; 252 goto oops;
253 err = saa7146_pgtable_build_single(dev->pci, &buf->pt[2], buf->vb.dma.sglist, buf->vb.dma.sglen); 253 err = saa7146_pgtable_build_single(dev->pci, &buf->pt[2], buf->vb.dma.sglist, buf->vb.dma.sglen);
@@ -261,7 +261,7 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,e
261 261
262 oops: 262 oops:
263 DEB_VBI(("error out.\n")); 263 DEB_VBI(("error out.\n"));
264 saa7146_dma_free(dev,buf); 264 saa7146_dma_free(dev,q,buf);
265 265
266 return err; 266 return err;
267} 267}
@@ -301,7 +301,7 @@ static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
301 struct saa7146_buf *buf = (struct saa7146_buf *)vb; 301 struct saa7146_buf *buf = (struct saa7146_buf *)vb;
302 302
303 DEB_VBI(("vb:%p\n",vb)); 303 DEB_VBI(("vb:%p\n",vb));
304 saa7146_dma_free(dev,buf); 304 saa7146_dma_free(dev,q,buf);
305} 305}
306 306
307static struct videobuf_queue_ops vbi_qops = { 307static struct videobuf_queue_ops vbi_qops = {
diff --git a/drivers/media/common/saa7146_video.c b/drivers/media/common/saa7146_video.c
index 6b42713d97f4..e7079d1bd537 100644
--- a/drivers/media/common/saa7146_video.c
+++ b/drivers/media/common/saa7146_video.c
@@ -1275,7 +1275,7 @@ static int buffer_prepare(struct videobuf_queue *q,
1275 buf->vb.field != field || 1275 buf->vb.field != field ||
1276 buf->vb.field != fh->video_fmt.field || 1276 buf->vb.field != fh->video_fmt.field ||
1277 buf->fmt != &fh->video_fmt) { 1277 buf->fmt != &fh->video_fmt) {
1278 saa7146_dma_free(dev,buf); 1278 saa7146_dma_free(dev,q,buf);
1279 } 1279 }
1280 1280
1281 if (STATE_NEEDS_INIT == buf->vb.state) { 1281 if (STATE_NEEDS_INIT == buf->vb.state) {
@@ -1304,7 +1304,7 @@ static int buffer_prepare(struct videobuf_queue *q,
1304 saa7146_pgtable_alloc(dev->pci, &buf->pt[0]); 1304 saa7146_pgtable_alloc(dev->pci, &buf->pt[0]);
1305 } 1305 }
1306 1306
1307 err = videobuf_iolock(dev->pci,&buf->vb, &vv->ov_fb); 1307 err = videobuf_iolock(q,&buf->vb, &vv->ov_fb);
1308 if (err) 1308 if (err)
1309 goto oops; 1309 goto oops;
1310 err = saa7146_pgtable_build(dev,buf); 1310 err = saa7146_pgtable_build(dev,buf);
@@ -1318,7 +1318,7 @@ static int buffer_prepare(struct videobuf_queue *q,
1318 1318
1319 oops: 1319 oops:
1320 DEB_D(("error out.\n")); 1320 DEB_D(("error out.\n"));
1321 saa7146_dma_free(dev,buf); 1321 saa7146_dma_free(dev,q,buf);
1322 1322
1323 return err; 1323 return err;
1324} 1324}
@@ -1363,7 +1363,7 @@ static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
1363 struct saa7146_buf *buf = (struct saa7146_buf *)vb; 1363 struct saa7146_buf *buf = (struct saa7146_buf *)vb;
1364 1364
1365 DEB_CAP(("vbuf:%p\n",vb)); 1365 DEB_CAP(("vbuf:%p\n",vb));
1366 saa7146_dma_free(dev,buf); 1366 saa7146_dma_free(dev,q,buf);
1367} 1367}
1368 1368
1369static struct videobuf_queue_ops video_qops = { 1369static struct videobuf_queue_ops video_qops = {
diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c
index c0415d6e7fee..2505ae5a7b97 100644
--- a/drivers/media/video/bttv-driver.c
+++ b/drivers/media/video/bttv-driver.c
@@ -1397,7 +1397,7 @@ bttv_switch_overlay(struct bttv *btv, struct bttv_fh *fh,
1397 free_btres(btv,fh,RESOURCE_OVERLAY); 1397 free_btres(btv,fh,RESOURCE_OVERLAY);
1398 if (NULL != old) { 1398 if (NULL != old) {
1399 dprintk("switch_overlay: old=%p state is %d\n",old,old->vb.state); 1399 dprintk("switch_overlay: old=%p state is %d\n",old,old->vb.state);
1400 bttv_dma_free(btv, old); 1400 bttv_dma_free(&fh->cap,btv, old);
1401 kfree(old); 1401 kfree(old);
1402 } 1402 }
1403 dprintk("switch_overlay: done\n"); 1403 dprintk("switch_overlay: done\n");
@@ -1407,7 +1407,8 @@ bttv_switch_overlay(struct bttv *btv, struct bttv_fh *fh,
1407/* ----------------------------------------------------------------------- */ 1407/* ----------------------------------------------------------------------- */
1408/* video4linux (1) interface */ 1408/* video4linux (1) interface */
1409 1409
1410static int bttv_prepare_buffer(struct bttv *btv, struct bttv_buffer *buf, 1410static int bttv_prepare_buffer(struct videobuf_queue *q,struct bttv *btv,
1411 struct bttv_buffer *buf,
1411 const struct bttv_format *fmt, 1412 const struct bttv_format *fmt,
1412 unsigned int width, unsigned int height, 1413 unsigned int width, unsigned int height,
1413 enum v4l2_field field) 1414 enum v4l2_field field)
@@ -1450,7 +1451,7 @@ static int bttv_prepare_buffer(struct bttv *btv, struct bttv_buffer *buf,
1450 /* alloc risc memory */ 1451 /* alloc risc memory */
1451 if (STATE_NEEDS_INIT == buf->vb.state) { 1452 if (STATE_NEEDS_INIT == buf->vb.state) {
1452 redo_dma_risc = 1; 1453 redo_dma_risc = 1;
1453 if (0 != (rc = videobuf_iolock(btv->c.pci,&buf->vb,&btv->fbuf))) 1454 if (0 != (rc = videobuf_iolock(q,&buf->vb,&btv->fbuf)))
1454 goto fail; 1455 goto fail;
1455 } 1456 }
1456 1457
@@ -1462,7 +1463,7 @@ static int bttv_prepare_buffer(struct bttv *btv, struct bttv_buffer *buf,
1462 return 0; 1463 return 0;
1463 1464
1464 fail: 1465 fail:
1465 bttv_dma_free(btv,buf); 1466 bttv_dma_free(q,btv,buf);
1466 return rc; 1467 return rc;
1467} 1468}
1468 1469
@@ -1486,7 +1487,7 @@ buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
1486 struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb); 1487 struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb);
1487 struct bttv_fh *fh = q->priv_data; 1488 struct bttv_fh *fh = q->priv_data;
1488 1489
1489 return bttv_prepare_buffer(fh->btv, buf, fh->fmt, 1490 return bttv_prepare_buffer(q,fh->btv, buf, fh->fmt,
1490 fh->width, fh->height, field); 1491 fh->width, fh->height, field);
1491} 1492}
1492 1493
@@ -1510,7 +1511,7 @@ static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
1510 struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb); 1511 struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb);
1511 struct bttv_fh *fh = q->priv_data; 1512 struct bttv_fh *fh = q->priv_data;
1512 1513
1513 bttv_dma_free(fh->btv,buf); 1514 bttv_dma_free(&fh->cap,fh->btv,buf);
1514} 1515}
1515 1516
1516static struct videobuf_queue_ops bttv_video_qops = { 1517static struct videobuf_queue_ops bttv_video_qops = {
@@ -2496,7 +2497,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2496 field = (vm->height > bttv_tvnorms[btv->tvnorm].sheight/2) 2497 field = (vm->height > bttv_tvnorms[btv->tvnorm].sheight/2)
2497 ? V4L2_FIELD_INTERLACED 2498 ? V4L2_FIELD_INTERLACED
2498 : V4L2_FIELD_BOTTOM; 2499 : V4L2_FIELD_BOTTOM;
2499 retval = bttv_prepare_buffer(btv,buf, 2500 retval = bttv_prepare_buffer(&fh->cap,btv,buf,
2500 format_by_palette(vm->format), 2501 format_by_palette(vm->format),
2501 vm->width,vm->height,field); 2502 vm->width,vm->height,field);
2502 if (0 != retval) 2503 if (0 != retval)
@@ -2528,8 +2529,8 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2528 retval = -EIO; 2529 retval = -EIO;
2529 /* fall through */ 2530 /* fall through */
2530 case STATE_DONE: 2531 case STATE_DONE:
2531 videobuf_dma_pci_sync(btv->c.pci,&buf->vb.dma); 2532 videobuf_dma_sync(&fh->cap,&buf->vb.dma);
2532 bttv_dma_free(btv,buf); 2533 bttv_dma_free(&fh->cap,btv,buf);
2533 break; 2534 break;
2534 default: 2535 default:
2535 retval = -EINVAL; 2536 retval = -EINVAL;
diff --git a/drivers/media/video/bttv-risc.c b/drivers/media/video/bttv-risc.c
index 344f84e9af04..16323a5d68ac 100644
--- a/drivers/media/video/bttv-risc.c
+++ b/drivers/media/video/bttv-risc.c
@@ -509,11 +509,11 @@ bttv_risc_hook(struct bttv *btv, int slot, struct btcx_riscmem *risc,
509} 509}
510 510
511void 511void
512bttv_dma_free(struct bttv *btv, struct bttv_buffer *buf) 512bttv_dma_free(struct videobuf_queue *q,struct bttv *btv, struct bttv_buffer *buf)
513{ 513{
514 BUG_ON(in_interrupt()); 514 BUG_ON(in_interrupt());
515 videobuf_waiton(&buf->vb,0,0); 515 videobuf_waiton(&buf->vb,0,0);
516 videobuf_dma_pci_unmap(btv->c.pci, &buf->vb.dma); 516 videobuf_dma_unmap(q, &buf->vb.dma);
517 videobuf_dma_free(&buf->vb.dma); 517 videobuf_dma_free(&buf->vb.dma);
518 btcx_riscmem_free(btv->c.pci,&buf->bottom); 518 btcx_riscmem_free(btv->c.pci,&buf->bottom);
519 btcx_riscmem_free(btv->c.pci,&buf->top); 519 btcx_riscmem_free(btv->c.pci,&buf->top);
diff --git a/drivers/media/video/bttv-vbi.c b/drivers/media/video/bttv-vbi.c
index 72afdd64b882..e20ff238e409 100644
--- a/drivers/media/video/bttv-vbi.c
+++ b/drivers/media/video/bttv-vbi.c
@@ -96,7 +96,7 @@ static int vbi_buffer_prepare(struct videobuf_queue *q,
96 return -EINVAL; 96 return -EINVAL;
97 97
98 if (STATE_NEEDS_INIT == buf->vb.state) { 98 if (STATE_NEEDS_INIT == buf->vb.state) {
99 if (0 != (rc = videobuf_iolock(btv->c.pci, &buf->vb, NULL))) 99 if (0 != (rc = videobuf_iolock(q, &buf->vb, NULL)))
100 goto fail; 100 goto fail;
101 if (0 != (rc = vbi_buffer_risc(btv,buf,fh->lines))) 101 if (0 != (rc = vbi_buffer_risc(btv,buf,fh->lines)))
102 goto fail; 102 goto fail;
@@ -109,7 +109,7 @@ static int vbi_buffer_prepare(struct videobuf_queue *q,
109 return 0; 109 return 0;
110 110
111 fail: 111 fail:
112 bttv_dma_free(btv,buf); 112 bttv_dma_free(q,btv,buf);
113 return rc; 113 return rc;
114} 114}
115 115
@@ -136,7 +136,7 @@ static void vbi_buffer_release(struct videobuf_queue *q, struct videobuf_buffer
136 struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb); 136 struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb);
137 137
138 dprintk("free %p\n",vb); 138 dprintk("free %p\n",vb);
139 bttv_dma_free(fh->btv,buf); 139 bttv_dma_free(&fh->cap,fh->btv,buf);
140} 140}
141 141
142struct videobuf_queue_ops bttv_vbi_qops = { 142struct videobuf_queue_ops bttv_vbi_qops = {
diff --git a/drivers/media/video/bttvp.h b/drivers/media/video/bttvp.h
index 9cb72f176f7d..12223a203960 100644
--- a/drivers/media/video/bttvp.h
+++ b/drivers/media/video/bttvp.h
@@ -190,7 +190,8 @@ int bttv_buffer_activate_video(struct bttv *btv,
190 struct bttv_buffer_set *set); 190 struct bttv_buffer_set *set);
191int bttv_buffer_activate_vbi(struct bttv *btv, 191int bttv_buffer_activate_vbi(struct bttv *btv,
192 struct bttv_buffer *vbi); 192 struct bttv_buffer *vbi);
193void bttv_dma_free(struct bttv *btv, struct bttv_buffer *buf); 193void bttv_dma_free(struct videobuf_queue *q, struct bttv *btv,
194 struct bttv_buffer *buf);
194 195
195/* overlay handling */ 196/* overlay handling */
196int bttv_overlay_risc(struct bttv *btv, struct bttv_overlay *ov, 197int bttv_overlay_risc(struct bttv *btv, struct bttv_overlay *ov,
diff --git a/drivers/media/video/cx88/cx88-alsa.c b/drivers/media/video/cx88/cx88-alsa.c
index 3170b8f72c68..f9d87b86492c 100644
--- a/drivers/media/video/cx88/cx88-alsa.c
+++ b/drivers/media/video/cx88/cx88-alsa.c
@@ -303,7 +303,7 @@ static int dsp_buffer_free(snd_cx88_card_t *chip)
303 BUG_ON(!chip->dma_size); 303 BUG_ON(!chip->dma_size);
304 304
305 dprintk(2,"Freeing buffer\n"); 305 dprintk(2,"Freeing buffer\n");
306 videobuf_dma_pci_unmap(chip->pci, &chip->dma_risc); 306 videobuf_pci_dma_unmap(chip->pci, &chip->dma_risc);
307 videobuf_dma_free(&chip->dma_risc); 307 videobuf_dma_free(&chip->dma_risc);
308 btcx_riscmem_free(chip->pci,&chip->buf->risc); 308 btcx_riscmem_free(chip->pci,&chip->buf->risc);
309 kfree(chip->buf); 309 kfree(chip->buf);
@@ -429,7 +429,7 @@ static int snd_cx88_hw_params(struct snd_pcm_substream * substream,
429 videobuf_dma_init_kernel(&buf->vb.dma,PCI_DMA_FROMDEVICE, 429 videobuf_dma_init_kernel(&buf->vb.dma,PCI_DMA_FROMDEVICE,
430 (PAGE_ALIGN(buf->vb.size) >> PAGE_SHIFT)); 430 (PAGE_ALIGN(buf->vb.size) >> PAGE_SHIFT));
431 431
432 videobuf_dma_pci_map(chip->pci,&buf->vb.dma); 432 videobuf_pci_dma_map(chip->pci,&buf->vb.dma);
433 433
434 434
435 cx88_risc_databuffer(chip->pci, &buf->risc, 435 cx88_risc_databuffer(chip->pci, &buf->risc,
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c
index a502a4d6e4ae..e100d8ef369a 100644
--- a/drivers/media/video/cx88/cx88-blackbird.c
+++ b/drivers/media/video/cx88/cx88-blackbird.c
@@ -1341,7 +1341,7 @@ bb_buf_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
1341 enum v4l2_field field) 1341 enum v4l2_field field)
1342{ 1342{
1343 struct cx8802_fh *fh = q->priv_data; 1343 struct cx8802_fh *fh = q->priv_data;
1344 return cx8802_buf_prepare(fh->dev, (struct cx88_buffer*)vb, field); 1344 return cx8802_buf_prepare(q, fh->dev, (struct cx88_buffer*)vb, field);
1345} 1345}
1346 1346
1347static void 1347static void
@@ -1354,8 +1354,7 @@ bb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
1354static void 1354static void
1355bb_buf_release(struct videobuf_queue *q, struct videobuf_buffer *vb) 1355bb_buf_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
1356{ 1356{
1357 struct cx8802_fh *fh = q->priv_data; 1357 cx88_free_buffer(q, (struct cx88_buffer*)vb);
1358 cx88_free_buffer(fh->dev->pci, (struct cx88_buffer*)vb);
1359} 1358}
1360 1359
1361static struct videobuf_queue_ops blackbird_qops = { 1360static struct videobuf_queue_ops blackbird_qops = {
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index c2cdbafdb77b..2c3d9f1999be 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -213,13 +213,13 @@ int cx88_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,
213} 213}
214 214
215void 215void
216cx88_free_buffer(struct pci_dev *pci, struct cx88_buffer *buf) 216cx88_free_buffer(struct videobuf_queue *q, struct cx88_buffer *buf)
217{ 217{
218 BUG_ON(in_interrupt()); 218 BUG_ON(in_interrupt());
219 videobuf_waiton(&buf->vb,0,0); 219 videobuf_waiton(&buf->vb,0,0);
220 videobuf_dma_pci_unmap(pci, &buf->vb.dma); 220 videobuf_dma_unmap(q, &buf->vb.dma);
221 videobuf_dma_free(&buf->vb.dma); 221 videobuf_dma_free(&buf->vb.dma);
222 btcx_riscmem_free(pci, &buf->risc); 222 btcx_riscmem_free((struct pci_dev *)q->dev, &buf->risc);
223 buf->vb.state = STATE_NEEDS_INIT; 223 buf->vb.state = STATE_NEEDS_INIT;
224} 224}
225 225
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index a9fc2695b157..f0ea9b5cdbc2 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -90,7 +90,7 @@ static int dvb_buf_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
90 enum v4l2_field field) 90 enum v4l2_field field)
91{ 91{
92 struct cx8802_dev *dev = q->priv_data; 92 struct cx8802_dev *dev = q->priv_data;
93 return cx8802_buf_prepare(dev, (struct cx88_buffer*)vb,field); 93 return cx8802_buf_prepare(q, dev, (struct cx88_buffer*)vb,field);
94} 94}
95 95
96static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) 96static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
@@ -101,8 +101,7 @@ static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
101 101
102static void dvb_buf_release(struct videobuf_queue *q, struct videobuf_buffer *vb) 102static void dvb_buf_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
103{ 103{
104 struct cx8802_dev *dev = q->priv_data; 104 cx88_free_buffer(q, (struct cx88_buffer*)vb);
105 cx88_free_buffer(dev->pci, (struct cx88_buffer*)vb);
106} 105}
107 106
108static struct videobuf_queue_ops dvb_qops = { 107static struct videobuf_queue_ops dvb_qops = {
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c
index c79cc1d2bf8b..7d16888b4a86 100644
--- a/drivers/media/video/cx88/cx88-mpeg.c
+++ b/drivers/media/video/cx88/cx88-mpeg.c
@@ -163,8 +163,8 @@ static int cx8802_restart_queue(struct cx8802_dev *dev,
163 163
164/* ------------------------------------------------------------------ */ 164/* ------------------------------------------------------------------ */
165 165
166int cx8802_buf_prepare(struct cx8802_dev *dev, struct cx88_buffer *buf, 166int cx8802_buf_prepare(struct videobuf_queue *q, struct cx8802_dev *dev,
167 enum v4l2_field field) 167 struct cx88_buffer *buf, enum v4l2_field field)
168{ 168{
169 int size = dev->ts_packet_size * dev->ts_packet_count; 169 int size = dev->ts_packet_size * dev->ts_packet_count;
170 int rc; 170 int rc;
@@ -179,7 +179,7 @@ int cx8802_buf_prepare(struct cx8802_dev *dev, struct cx88_buffer *buf,
179 buf->vb.size = size; 179 buf->vb.size = size;
180 buf->vb.field = field /*V4L2_FIELD_TOP*/; 180 buf->vb.field = field /*V4L2_FIELD_TOP*/;
181 181
182 if (0 != (rc = videobuf_iolock(dev->pci,&buf->vb,NULL))) 182 if (0 != (rc = videobuf_iolock(q,&buf->vb,NULL)))
183 goto fail; 183 goto fail;
184 cx88_risc_databuffer(dev->pci, &buf->risc, 184 cx88_risc_databuffer(dev->pci, &buf->risc,
185 buf->vb.dma.sglist, 185 buf->vb.dma.sglist,
@@ -189,36 +189,36 @@ int cx8802_buf_prepare(struct cx8802_dev *dev, struct cx88_buffer *buf,
189 return 0; 189 return 0;
190 190
191 fail: 191 fail:
192 cx88_free_buffer(dev->pci,buf); 192 cx88_free_buffer(q,buf);
193 return rc; 193 return rc;
194} 194}
195 195
196void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf) 196void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf)
197{ 197{
198 struct cx88_buffer *prev; 198 struct cx88_buffer *prev;
199 struct cx88_dmaqueue *q = &dev->mpegq; 199 struct cx88_dmaqueue *cx88q = &dev->mpegq;
200 200
201 dprintk( 1, "cx8802_buf_queue\n" ); 201 dprintk( 1, "cx8802_buf_queue\n" );
202 /* add jump to stopper */ 202 /* add jump to stopper */
203 buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC); 203 buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC);
204 buf->risc.jmp[1] = cpu_to_le32(q->stopper.dma); 204 buf->risc.jmp[1] = cpu_to_le32(cx88q->stopper.dma);
205 205
206 if (list_empty(&q->active)) { 206 if (list_empty(&cx88q->active)) {
207 dprintk( 0, "queue is empty - first active\n" ); 207 dprintk( 0, "queue is empty - first active\n" );
208 list_add_tail(&buf->vb.queue,&q->active); 208 list_add_tail(&buf->vb.queue,&cx88q->active);
209 cx8802_start_dma(dev, q, buf); 209 cx8802_start_dma(dev, cx88q, buf);
210 buf->vb.state = STATE_ACTIVE; 210 buf->vb.state = STATE_ACTIVE;
211 buf->count = q->count++; 211 buf->count = cx88q->count++;
212 mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); 212 mod_timer(&cx88q->timeout, jiffies+BUFFER_TIMEOUT);
213 dprintk(0,"[%p/%d] %s - first active\n", 213 dprintk(0,"[%p/%d] %s - first active\n",
214 buf, buf->vb.i, __FUNCTION__); 214 buf, buf->vb.i, __FUNCTION__);
215 215
216 } else { 216 } else {
217 dprintk( 1, "queue is not empty - append to active\n" ); 217 dprintk( 1, "queue is not empty - append to active\n" );
218 prev = list_entry(q->active.prev, struct cx88_buffer, vb.queue); 218 prev = list_entry(cx88q->active.prev, struct cx88_buffer, vb.queue);
219 list_add_tail(&buf->vb.queue,&q->active); 219 list_add_tail(&buf->vb.queue,&cx88q->active);
220 buf->vb.state = STATE_ACTIVE; 220 buf->vb.state = STATE_ACTIVE;
221 buf->count = q->count++; 221 buf->count = cx88q->count++;
222 prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); 222 prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
223 dprintk( 1, "[%p/%d] %s - append to active\n", 223 dprintk( 1, "[%p/%d] %s - append to active\n",
224 buf, buf->vb.i, __FUNCTION__); 224 buf, buf->vb.i, __FUNCTION__);
diff --git a/drivers/media/video/cx88/cx88-vbi.c b/drivers/media/video/cx88/cx88-vbi.c
index 9bc6c8995581..846faadc9f1c 100644
--- a/drivers/media/video/cx88/cx88-vbi.c
+++ b/drivers/media/video/cx88/cx88-vbi.c
@@ -175,7 +175,7 @@ vbi_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
175 buf->vb.size = size; 175 buf->vb.size = size;
176 buf->vb.field = V4L2_FIELD_SEQ_TB; 176 buf->vb.field = V4L2_FIELD_SEQ_TB;
177 177
178 if (0 != (rc = videobuf_iolock(dev->pci,&buf->vb,NULL))) 178 if (0 != (rc = videobuf_iolock(q,&buf->vb,NULL)))
179 goto fail; 179 goto fail;
180 cx88_risc_buffer(dev->pci, &buf->risc, 180 cx88_risc_buffer(dev->pci, &buf->risc,
181 buf->vb.dma.sglist, 181 buf->vb.dma.sglist,
@@ -187,7 +187,7 @@ vbi_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
187 return 0; 187 return 0;
188 188
189 fail: 189 fail:
190 cx88_free_buffer(dev->pci,buf); 190 cx88_free_buffer(q,buf);
191 return rc; 191 return rc;
192} 192}
193 193
@@ -227,9 +227,8 @@ vbi_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
227static void vbi_release(struct videobuf_queue *q, struct videobuf_buffer *vb) 227static void vbi_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
228{ 228{
229 struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb); 229 struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb);
230 struct cx8800_fh *fh = q->priv_data;
231 230
232 cx88_free_buffer(fh->dev->pci,buf); 231 cx88_free_buffer(q,buf);
233} 232}
234 233
235struct videobuf_queue_ops cx8800_vbi_qops = { 234struct videobuf_queue_ops cx8800_vbi_qops = {
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index 6c97aa740d27..72a417b31745 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -564,7 +564,7 @@ buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
564 564
565 if (STATE_NEEDS_INIT == buf->vb.state) { 565 if (STATE_NEEDS_INIT == buf->vb.state) {
566 init_buffer = 1; 566 init_buffer = 1;
567 if (0 != (rc = videobuf_iolock(dev->pci,&buf->vb,NULL))) 567 if (0 != (rc = videobuf_iolock(q,&buf->vb,NULL)))
568 goto fail; 568 goto fail;
569 } 569 }
570 570
@@ -614,7 +614,7 @@ buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
614 return 0; 614 return 0;
615 615
616 fail: 616 fail:
617 cx88_free_buffer(dev->pci,buf); 617 cx88_free_buffer(q,buf);
618 return rc; 618 return rc;
619} 619}
620 620
@@ -671,9 +671,8 @@ buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
671static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) 671static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
672{ 672{
673 struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb); 673 struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb);
674 struct cx8800_fh *fh = q->priv_data;
675 674
676 cx88_free_buffer(fh->dev->pci,buf); 675 cx88_free_buffer(q,buf);
677} 676}
678 677
679static struct videobuf_queue_ops cx8800_video_qops = { 678static struct videobuf_queue_ops cx8800_video_qops = {
@@ -1251,9 +1250,17 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
1251{ 1250{
1252 int err; 1251 int err;
1253 1252
1254 dprintk(2, "CORE IOCTL: 0x%x\n", cmd ); 1253 if (video_debug) {
1255 if (video_debug > 1) 1254 if (video_debug > 1) {
1256 v4l_print_ioctl(core->name,cmd); 1255 if (_IOC_DIR(cmd) & _IOC_WRITE)
1256 v4l_printk_ioctl_arg("cx88(w)",cmd, arg);
1257 else if (!_IOC_DIR(cmd) & _IOC_READ) {
1258 v4l_print_ioctl("cx88", cmd);
1259 }
1260 } else
1261 v4l_print_ioctl(core->name,cmd);
1262
1263 }
1257 1264
1258 switch (cmd) { 1265 switch (cmd) {
1259 /* ---------- tv norms ---------- */ 1266 /* ---------- tv norms ---------- */
@@ -1460,7 +1467,19 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
1460static int video_ioctl(struct inode *inode, struct file *file, 1467static int video_ioctl(struct inode *inode, struct file *file,
1461 unsigned int cmd, unsigned long arg) 1468 unsigned int cmd, unsigned long arg)
1462{ 1469{
1463 return video_usercopy(inode, file, cmd, arg, video_do_ioctl); 1470 int retval;
1471
1472 retval=video_usercopy(inode, file, cmd, arg, video_do_ioctl);
1473
1474 if (video_debug > 1) {
1475 if (retval < 0) {
1476 v4l_print_ioctl("cx88(err)", cmd);
1477 printk(KERN_DEBUG "cx88(err): errcode=%d\n",retval);
1478 } else if (_IOC_DIR(cmd) & _IOC_READ)
1479 v4l_printk_ioctl_arg("cx88(r)",cmd, (void *)arg);
1480 }
1481
1482 return retval;
1464} 1483}
1465 1484
1466/* ----------------------------------------------------------- */ 1485/* ----------------------------------------------------------- */
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index cfa8668784b4..5b2e499eab22 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -485,7 +485,7 @@ extern int
485cx88_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc, 485cx88_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,
486 u32 reg, u32 mask, u32 value); 486 u32 reg, u32 mask, u32 value);
487extern void 487extern void
488cx88_free_buffer(struct pci_dev *pci, struct cx88_buffer *buf); 488cx88_free_buffer(struct videobuf_queue *q, struct cx88_buffer *buf);
489 489
490extern void cx88_risc_disasm(struct cx88_core *core, 490extern void cx88_risc_disasm(struct cx88_core *core,
491 struct btcx_riscmem *risc); 491 struct btcx_riscmem *risc);
@@ -577,8 +577,8 @@ void cx88_ir_irq(struct cx88_core *core);
577/* ----------------------------------------------------------- */ 577/* ----------------------------------------------------------- */
578/* cx88-mpeg.c */ 578/* cx88-mpeg.c */
579 579
580int cx8802_buf_prepare(struct cx8802_dev *dev, struct cx88_buffer *buf, 580int cx8802_buf_prepare(struct videobuf_queue *q,struct cx8802_dev *dev,
581 enum v4l2_field field); 581 struct cx88_buffer *buf, enum v4l2_field field);
582void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf); 582void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf);
583void cx8802_cancel_buffers(struct cx8802_dev *dev); 583void cx8802_cancel_buffers(struct cx8802_dev *dev);
584 584
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
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c
index 95a6e47c99f1..9b029e4dbfb7 100644
--- a/drivers/media/video/v4l2-common.c
+++ b/drivers/media/video/v4l2-common.c
@@ -481,7 +481,7 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
481 prt_names(p->memory,v4l2_memory_names), 481 prt_names(p->memory,v4l2_memory_names),
482 p->m.userptr); 482 p->m.userptr);
483 printk ("%s: timecode= %02d:%02d:%02d type=%d, " 483 printk ("%s: timecode= %02d:%02d:%02d type=%d, "
484 "flags=0x%08d, frames=%d, userbits=0x%08x", 484 "flags=0x%08d, frames=%d, userbits=0x%08x\n",
485 s,tc->hours,tc->minutes,tc->seconds, 485 s,tc->hours,tc->minutes,tc->seconds,
486 tc->type, tc->flags, tc->frames, (__u32) tc->userbits); 486 tc->type, tc->flags, tc->frames, (__u32) tc->userbits);
487 break; 487 break;
@@ -489,8 +489,8 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
489 case VIDIOC_QUERYCAP: 489 case VIDIOC_QUERYCAP:
490 { 490 {
491 struct v4l2_capability *p=arg; 491 struct v4l2_capability *p=arg;
492 printk ("%s: driver=%s, card=%s, bus=%s, version=%d, " 492 printk ("%s: driver=%s, card=%s, bus=%s, version=0x%08x, "
493 "capabilities=%d\n", s, 493 "capabilities=0x%08x\n", s,
494 p->driver,p->card,p->bus_info, 494 p->driver,p->card,p->bus_info,
495 p->version, 495 p->version,
496 p->capabilities); 496 p->capabilities);
diff --git a/drivers/media/video/video-buf.c b/drivers/media/video/video-buf.c
index 87e937581d5a..d2ca0f08d0df 100644
--- a/drivers/media/video/video-buf.c
+++ b/drivers/media/video/video-buf.c
@@ -1,15 +1,20 @@
1/* 1/*
2 * 2 *
3 * generic helper functions for video4linux capture buffers, to handle 3 * generic helper functions for video4linux capture buffers, to handle
4 * memory management and PCI DMA. Right now bttv + saa7134 use it. 4 * memory management and PCI DMA.
5 * Right now, bttv, saa7134, saa7146 and cx88 use it.
5 * 6 *
6 * The functions expect the hardware being able to scatter gatter 7 * The functions expect the hardware being able to scatter gatter
7 * (i.e. the buffers are not linear in physical memory, but fragmented 8 * (i.e. the buffers are not linear in physical memory, but fragmented
8 * into PAGE_SIZE chunks). They also assume the driver does not need 9 * into PAGE_SIZE chunks). They also assume the driver does not need
9 * to touch the video data (thus it is probably not useful for USB 1.1 10 * to touch the video data.
10 * as data often must be uncompressed by the drivers). 11 *
12 * device specific map/unmap/sync stuff now are mapped as operations
13 * to allow its usage by USB and virtual devices.
11 * 14 *
12 * (c) 2001-2004 Gerd Knorr <kraxel@bytesex.org> [SUSE Labs] 15 * (c) 2001-2004 Gerd Knorr <kraxel@bytesex.org> [SUSE Labs]
16 * (c) 2006 Mauro Carvalho Chehab <mchehab@infradead.org>
17 * (c) 2006 Ted Walther and John Sokol
13 * 18 *
14 * This program is free software; you can redistribute it and/or modify 19 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by 20 * it under the terms of the GNU General Public License as published by
@@ -167,6 +172,9 @@ int videobuf_dma_init_kernel(struct videobuf_dmabuf *dma, int direction,
167 dprintk(1,"vmalloc_32(%d pages) failed\n",nr_pages); 172 dprintk(1,"vmalloc_32(%d pages) failed\n",nr_pages);
168 return -ENOMEM; 173 return -ENOMEM;
169 } 174 }
175 dprintk(1,"vmalloc is at addr 0x%08lx, size=%d\n",
176 (unsigned long)dma->vmalloc,
177 nr_pages << PAGE_SHIFT);
170 memset(dma->vmalloc,0,nr_pages << PAGE_SHIFT); 178 memset(dma->vmalloc,0,nr_pages << PAGE_SHIFT);
171 dma->nr_pages = nr_pages; 179 dma->nr_pages = nr_pages;
172 return 0; 180 return 0;
@@ -186,8 +194,10 @@ int videobuf_dma_init_overlay(struct videobuf_dmabuf *dma, int direction,
186 return 0; 194 return 0;
187} 195}
188 196
189int videobuf_dma_pci_map(struct pci_dev *dev, struct videobuf_dmabuf *dma) 197int videobuf_dma_map(struct videobuf_queue* q,struct videobuf_dmabuf *dma)
190{ 198{
199 void *dev=q->dev;
200
191 MAGIC_CHECK(dma->magic,MAGIC_DMABUF); 201 MAGIC_CHECK(dma->magic,MAGIC_DMABUF);
192 BUG_ON(0 == dma->nr_pages); 202 BUG_ON(0 == dma->nr_pages);
193 203
@@ -197,7 +207,7 @@ int videobuf_dma_pci_map(struct pci_dev *dev, struct videobuf_dmabuf *dma)
197 } 207 }
198 if (dma->vmalloc) { 208 if (dma->vmalloc) {
199 dma->sglist = videobuf_vmalloc_to_sg 209 dma->sglist = videobuf_vmalloc_to_sg
200 (dma->vmalloc,dma->nr_pages); 210 (dma->vmalloc,dma->nr_pages);
201 } 211 }
202 if (dma->bus_addr) { 212 if (dma->bus_addr) {
203 dma->sglist = kmalloc(sizeof(struct scatterlist), GFP_KERNEL); 213 dma->sglist = kmalloc(sizeof(struct scatterlist), GFP_KERNEL);
@@ -212,13 +222,14 @@ int videobuf_dma_pci_map(struct pci_dev *dev, struct videobuf_dmabuf *dma)
212 dprintk(1,"scatterlist is NULL\n"); 222 dprintk(1,"scatterlist is NULL\n");
213 return -ENOMEM; 223 return -ENOMEM;
214 } 224 }
215
216 if (!dma->bus_addr) { 225 if (!dma->bus_addr) {
217 dma->sglen = pci_map_sg(dev,dma->sglist,dma->nr_pages, 226 if (q->ops->vb_map_sg) {
218 dma->direction); 227 dma->sglen = q->ops->vb_map_sg(dev,dma->sglist,
228 dma->nr_pages, dma->direction);
229 }
219 if (0 == dma->sglen) { 230 if (0 == dma->sglen) {
220 printk(KERN_WARNING 231 printk(KERN_WARNING
221 "%s: pci_map_sg failed\n",__FUNCTION__); 232 "%s: videobuf_map_sg failed\n",__FUNCTION__);
222 kfree(dma->sglist); 233 kfree(dma->sglist);
223 dma->sglist = NULL; 234 dma->sglist = NULL;
224 dma->sglen = 0; 235 dma->sglen = 0;
@@ -228,24 +239,31 @@ int videobuf_dma_pci_map(struct pci_dev *dev, struct videobuf_dmabuf *dma)
228 return 0; 239 return 0;
229} 240}
230 241
231int videobuf_dma_pci_sync(struct pci_dev *dev, struct videobuf_dmabuf *dma) 242int videobuf_dma_sync(struct videobuf_queue* q,struct videobuf_dmabuf *dma)
232{ 243{
244 void *dev=q->dev;
245
233 MAGIC_CHECK(dma->magic,MAGIC_DMABUF); 246 MAGIC_CHECK(dma->magic,MAGIC_DMABUF);
234 BUG_ON(!dma->sglen); 247 BUG_ON(!dma->sglen);
235 248
236 if (!dma->bus_addr) 249 if (!dma->bus_addr && q->ops->vb_dma_sync_sg)
237 pci_dma_sync_sg_for_cpu(dev,dma->sglist,dma->nr_pages,dma->direction); 250 q->ops->vb_dma_sync_sg(dev,dma->sglist,dma->nr_pages,
251 dma->direction);
252
238 return 0; 253 return 0;
239} 254}
240 255
241int videobuf_dma_pci_unmap(struct pci_dev *dev, struct videobuf_dmabuf *dma) 256int videobuf_dma_unmap(struct videobuf_queue* q,struct videobuf_dmabuf *dma)
242{ 257{
258 void *dev=q->dev;
259
243 MAGIC_CHECK(dma->magic,MAGIC_DMABUF); 260 MAGIC_CHECK(dma->magic,MAGIC_DMABUF);
244 if (!dma->sglen) 261 if (!dma->sglen)
245 return 0; 262 return 0;
246 263
247 if (!dma->bus_addr) 264 if (!dma->bus_addr && q->ops->vb_unmap_sg)
248 pci_unmap_sg(dev,dma->sglist,dma->nr_pages,dma->direction); 265 q->ops->vb_unmap_sg(dev,dma->sglist,dma->nr_pages,
266 dma->direction);
249 kfree(dma->sglist); 267 kfree(dma->sglist);
250 dma->sglist = NULL; 268 dma->sglist = NULL;
251 dma->sglen = 0; 269 dma->sglen = 0;
@@ -318,7 +336,7 @@ int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr)
318} 336}
319 337
320int 338int
321videobuf_iolock(struct pci_dev *pci, struct videobuf_buffer *vb, 339videobuf_iolock(struct videobuf_queue* q, struct videobuf_buffer *vb,
322 struct v4l2_framebuffer *fbuf) 340 struct v4l2_framebuffer *fbuf)
323{ 341{
324 int err,pages; 342 int err,pages;
@@ -357,7 +375,7 @@ videobuf_iolock(struct pci_dev *pci, struct videobuf_buffer *vb,
357 default: 375 default:
358 BUG(); 376 BUG();
359 } 377 }
360 err = videobuf_dma_pci_map(pci,&vb->dma); 378 err = videobuf_dma_map(q,&vb->dma);
361 if (0 != err) 379 if (0 != err)
362 return err; 380 return err;
363 381
@@ -366,9 +384,41 @@ videobuf_iolock(struct pci_dev *pci, struct videobuf_buffer *vb,
366 384
367/* --------------------------------------------------------------------- */ 385/* --------------------------------------------------------------------- */
368 386
387void videobuf_queue_pci(struct videobuf_queue* q)
388{
389 /* If not specified, defaults to PCI map sg */
390 if (!q->ops->vb_map_sg)
391 q->ops->vb_map_sg=(vb_map_sg_t *)pci_map_sg;
392
393 if (!q->ops->vb_dma_sync_sg)
394 q->ops->vb_dma_sync_sg=(vb_map_sg_t *)pci_dma_sync_sg_for_cpu;
395 if (!q->ops->vb_unmap_sg)
396 q->ops->vb_unmap_sg=(vb_map_sg_t *)pci_unmap_sg;
397}
398
399int videobuf_pci_dma_map(struct pci_dev *pci,struct videobuf_dmabuf *dma)
400{
401 struct videobuf_queue q;
402
403 q.dev=pci;
404 q.ops->vb_map_sg=(vb_map_sg_t *)pci_unmap_sg;
405
406 return (videobuf_dma_unmap(&q,dma));
407}
408
409int videobuf_pci_dma_unmap(struct pci_dev *pci,struct videobuf_dmabuf *dma)
410{
411 struct videobuf_queue q;
412
413 q.dev=pci;
414 q.ops->vb_map_sg=(vb_map_sg_t *)pci_unmap_sg;
415
416 return (videobuf_dma_unmap(&q,dma));
417}
418
369void videobuf_queue_init(struct videobuf_queue* q, 419void videobuf_queue_init(struct videobuf_queue* q,
370 struct videobuf_queue_ops *ops, 420 struct videobuf_queue_ops *ops,
371 struct pci_dev *pci, 421 void *dev,
372 spinlock_t *irqlock, 422 spinlock_t *irqlock,
373 enum v4l2_buf_type type, 423 enum v4l2_buf_type type,
374 enum v4l2_field field, 424 enum v4l2_field field,
@@ -377,13 +427,15 @@ void videobuf_queue_init(struct videobuf_queue* q,
377{ 427{
378 memset(q,0,sizeof(*q)); 428 memset(q,0,sizeof(*q));
379 q->irqlock = irqlock; 429 q->irqlock = irqlock;
380 q->pci = pci; 430 q->dev = dev;
381 q->type = type; 431 q->type = type;
382 q->field = field; 432 q->field = field;
383 q->msize = msize; 433 q->msize = msize;
384 q->ops = ops; 434 q->ops = ops;
385 q->priv_data = priv; 435 q->priv_data = priv;
386 436
437 videobuf_queue_pci(q);
438
387 mutex_init(&q->lock); 439 mutex_init(&q->lock);
388 INIT_LIST_HEAD(&q->stream); 440 INIT_LIST_HEAD(&q->stream);
389} 441}
@@ -431,7 +483,8 @@ videobuf_queue_cancel(struct videobuf_queue *q)
431 int i; 483 int i;
432 484
433 /* remove queued buffers from list */ 485 /* remove queued buffers from list */
434 spin_lock_irqsave(q->irqlock,flags); 486 if (q->irqlock)
487 spin_lock_irqsave(q->irqlock,flags);
435 for (i = 0; i < VIDEO_MAX_FRAME; i++) { 488 for (i = 0; i < VIDEO_MAX_FRAME; i++) {
436 if (NULL == q->bufs[i]) 489 if (NULL == q->bufs[i])
437 continue; 490 continue;
@@ -440,7 +493,8 @@ videobuf_queue_cancel(struct videobuf_queue *q)
440 q->bufs[i]->state = STATE_ERROR; 493 q->bufs[i]->state = STATE_ERROR;
441 } 494 }
442 } 495 }
443 spin_unlock_irqrestore(q->irqlock,flags); 496 if (q->irqlock)
497 spin_unlock_irqrestore(q->irqlock,flags);
444 498
445 /* free all buffers + clear queue */ 499 /* free all buffers + clear queue */
446 for (i = 0; i < VIDEO_MAX_FRAME; i++) { 500 for (i = 0; i < VIDEO_MAX_FRAME; i++) {
@@ -534,19 +588,29 @@ videobuf_reqbufs(struct videobuf_queue *q,
534 unsigned int size,count; 588 unsigned int size,count;
535 int retval; 589 int retval;
536 590
537 if (req->type != q->type) 591 if (req->type != q->type) {
592 dprintk(1,"reqbufs: queue type invalid\n");
538 return -EINVAL; 593 return -EINVAL;
539 if (req->count < 1) 594 }
595 if (req->count < 1) {
596 dprintk(1,"reqbufs: count invalid (%d)\n",req->count);
540 return -EINVAL; 597 return -EINVAL;
598 }
541 if (req->memory != V4L2_MEMORY_MMAP && 599 if (req->memory != V4L2_MEMORY_MMAP &&
542 req->memory != V4L2_MEMORY_USERPTR && 600 req->memory != V4L2_MEMORY_USERPTR &&
543 req->memory != V4L2_MEMORY_OVERLAY) 601 req->memory != V4L2_MEMORY_OVERLAY) {
602 dprintk(1,"reqbufs: memory type invalid\n");
544 return -EINVAL; 603 return -EINVAL;
604 }
545 605
546 if (q->streaming) 606 if (q->streaming) {
607 dprintk(1,"reqbufs: streaming already exists\n");
547 return -EBUSY; 608 return -EBUSY;
548 if (!list_empty(&q->stream)) 609 }
610 if (!list_empty(&q->stream)) {
611 dprintk(1,"reqbufs: stream running\n");
549 return -EBUSY; 612 return -EBUSY;
613 }
550 614
551 mutex_lock(&q->lock); 615 mutex_lock(&q->lock);
552 count = req->count; 616 count = req->count;
@@ -559,8 +623,10 @@ videobuf_reqbufs(struct videobuf_queue *q,
559 count, size, (count*size)>>PAGE_SHIFT); 623 count, size, (count*size)>>PAGE_SHIFT);
560 624
561 retval = videobuf_mmap_setup(q,count,size,req->memory); 625 retval = videobuf_mmap_setup(q,count,size,req->memory);
562 if (retval < 0) 626 if (retval < 0) {
627 dprintk(1,"reqbufs: mmap setup returned %d\n",retval);
563 goto done; 628 goto done;
629 }
564 630
565 req->count = count; 631 req->count = count;
566 632
@@ -572,12 +638,18 @@ videobuf_reqbufs(struct videobuf_queue *q,
572int 638int
573videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b) 639videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b)
574{ 640{
575 if (unlikely(b->type != q->type)) 641 if (unlikely(b->type != q->type)) {
642 dprintk(1,"querybuf: Wrong type.\n");
576 return -EINVAL; 643 return -EINVAL;
577 if (unlikely(b->index < 0 || b->index >= VIDEO_MAX_FRAME)) 644 }
645 if (unlikely(b->index < 0 || b->index >= VIDEO_MAX_FRAME)) {
646 dprintk(1,"querybuf: index out of range.\n");
578 return -EINVAL; 647 return -EINVAL;
579 if (unlikely(NULL == q->bufs[b->index])) 648 }
649 if (unlikely(NULL == q->bufs[b->index])) {
650 dprintk(1,"querybuf: buffer is null.\n");
580 return -EINVAL; 651 return -EINVAL;
652 }
581 videobuf_status(b,q->bufs[b->index],q->type); 653 videobuf_status(b,q->bufs[b->index],q->type);
582 return 0; 654 return 0;
583} 655}
@@ -593,26 +665,40 @@ videobuf_qbuf(struct videobuf_queue *q,
593 665
594 mutex_lock(&q->lock); 666 mutex_lock(&q->lock);
595 retval = -EBUSY; 667 retval = -EBUSY;
596 if (q->reading) 668 if (q->reading) {
669 dprintk(1,"qbuf: Reading running...\n");
597 goto done; 670 goto done;
671 }
598 retval = -EINVAL; 672 retval = -EINVAL;
599 if (b->type != q->type) 673 if (b->type != q->type) {
674 dprintk(1,"qbuf: Wrong type.\n");
600 goto done; 675 goto done;
601 if (b->index < 0 || b->index >= VIDEO_MAX_FRAME) 676 }
677 if (b->index < 0 || b->index >= VIDEO_MAX_FRAME) {
678 dprintk(1,"qbuf: index out of range.\n");
602 goto done; 679 goto done;
680 }
603 buf = q->bufs[b->index]; 681 buf = q->bufs[b->index];
604 if (NULL == buf) 682 if (NULL == buf) {
683 dprintk(1,"qbuf: buffer is null.\n");
605 goto done; 684 goto done;
685 }
606 MAGIC_CHECK(buf->magic,MAGIC_BUFFER); 686 MAGIC_CHECK(buf->magic,MAGIC_BUFFER);
607 if (buf->memory != b->memory) 687 if (buf->memory != b->memory) {
688 dprintk(1,"qbuf: memory type is wrong.\n");
608 goto done; 689 goto done;
690 }
609 if (buf->state == STATE_QUEUED || 691 if (buf->state == STATE_QUEUED ||
610 buf->state == STATE_ACTIVE) 692 buf->state == STATE_ACTIVE) {
693 dprintk(1,"qbuf: buffer is already queued or active.\n");
611 goto done; 694 goto done;
695 }
612 696
613 if (b->flags & V4L2_BUF_FLAG_INPUT) { 697 if (b->flags & V4L2_BUF_FLAG_INPUT) {
614 if (b->input >= q->inputs) 698 if (b->input >= q->inputs) {
699 dprintk(1,"qbuf: wrong input.\n");
615 goto done; 700 goto done;
701 }
616 buf->input = b->input; 702 buf->input = b->input;
617 } else { 703 } else {
618 buf->input = UNSET; 704 buf->input = UNSET;
@@ -620,12 +706,16 @@ videobuf_qbuf(struct videobuf_queue *q,
620 706
621 switch (b->memory) { 707 switch (b->memory) {
622 case V4L2_MEMORY_MMAP: 708 case V4L2_MEMORY_MMAP:
623 if (0 == buf->baddr) 709 if (0 == buf->baddr) {
710 dprintk(1,"qbuf: mmap requested but buffer addr is zero!\n");
624 goto done; 711 goto done;
712 }
625 break; 713 break;
626 case V4L2_MEMORY_USERPTR: 714 case V4L2_MEMORY_USERPTR:
627 if (b->length < buf->bsize) 715 if (b->length < buf->bsize) {
716 dprintk(1,"qbuf: buffer length is not enough\n");
628 goto done; 717 goto done;
718 }
629 if (STATE_NEEDS_INIT != buf->state && buf->baddr != b->m.userptr) 719 if (STATE_NEEDS_INIT != buf->state && buf->baddr != b->m.userptr)
630 q->ops->buf_release(q,buf); 720 q->ops->buf_release(q,buf);
631 buf->baddr = b->m.userptr; 721 buf->baddr = b->m.userptr;
@@ -634,20 +724,27 @@ videobuf_qbuf(struct videobuf_queue *q,
634 buf->boff = b->m.offset; 724 buf->boff = b->m.offset;
635 break; 725 break;
636 default: 726 default:
727 dprintk(1,"qbuf: wrong memory type\n");
637 goto done; 728 goto done;
638 } 729 }
639 730
731 dprintk(1,"qbuf: requesting next field\n");
640 field = videobuf_next_field(q); 732 field = videobuf_next_field(q);
641 retval = q->ops->buf_prepare(q,buf,field); 733 retval = q->ops->buf_prepare(q,buf,field);
642 if (0 != retval) 734 if (0 != retval) {
735 dprintk(1,"qbuf: buffer_prepare returned %d\n",retval);
643 goto done; 736 goto done;
737 }
644 738
645 list_add_tail(&buf->stream,&q->stream); 739 list_add_tail(&buf->stream,&q->stream);
646 if (q->streaming) { 740 if (q->streaming) {
647 spin_lock_irqsave(q->irqlock,flags); 741 if (q->irqlock)
742 spin_lock_irqsave(q->irqlock,flags);
648 q->ops->buf_queue(q,buf); 743 q->ops->buf_queue(q,buf);
649 spin_unlock_irqrestore(q->irqlock,flags); 744 if (q->irqlock)
745 spin_unlock_irqrestore(q->irqlock,flags);
650 } 746 }
747 dprintk(1,"qbuf: succeded\n");
651 retval = 0; 748 retval = 0;
652 749
653 done: 750 done:
@@ -664,26 +761,39 @@ videobuf_dqbuf(struct videobuf_queue *q,
664 761
665 mutex_lock(&q->lock); 762 mutex_lock(&q->lock);
666 retval = -EBUSY; 763 retval = -EBUSY;
667 if (q->reading) 764 if (q->reading) {
765 dprintk(1,"dqbuf: Reading running...\n");
668 goto done; 766 goto done;
767 }
669 retval = -EINVAL; 768 retval = -EINVAL;
670 if (b->type != q->type) 769 if (b->type != q->type) {
770 dprintk(1,"dqbuf: Wrong type.\n");
671 goto done; 771 goto done;
672 if (list_empty(&q->stream)) 772 }
773 if (list_empty(&q->stream)) {
774 dprintk(1,"dqbuf: stream running\n");
673 goto done; 775 goto done;
776 }
674 buf = list_entry(q->stream.next, struct videobuf_buffer, stream); 777 buf = list_entry(q->stream.next, struct videobuf_buffer, stream);
675 retval = videobuf_waiton(buf, nonblocking, 1); 778 retval = videobuf_waiton(buf, nonblocking, 1);
676 if (retval < 0) 779 if (retval < 0) {
780 dprintk(1,"dqbuf: waiton returned %d\n",retval);
677 goto done; 781 goto done;
782 }
678 switch (buf->state) { 783 switch (buf->state) {
679 case STATE_ERROR: 784 case STATE_ERROR:
785 dprintk(1,"dqbuf: state is error\n");
680 retval = -EIO; 786 retval = -EIO;
681 /* fall through */ 787 videobuf_dma_sync(q,&buf->dma);
788 buf->state = STATE_IDLE;
789 break;
682 case STATE_DONE: 790 case STATE_DONE:
683 videobuf_dma_pci_sync(q->pci,&buf->dma); 791 dprintk(1,"dqbuf: state is done\n");
792 videobuf_dma_sync(q,&buf->dma);
684 buf->state = STATE_IDLE; 793 buf->state = STATE_IDLE;
685 break; 794 break;
686 default: 795 default:
796 dprintk(1,"dqbuf: state invalid\n");
687 retval = -EINVAL; 797 retval = -EINVAL;
688 goto done; 798 goto done;
689 } 799 }
@@ -711,13 +821,15 @@ int videobuf_streamon(struct videobuf_queue *q)
711 if (q->streaming) 821 if (q->streaming)
712 goto done; 822 goto done;
713 q->streaming = 1; 823 q->streaming = 1;
714 spin_lock_irqsave(q->irqlock,flags); 824 if (q->irqlock)
825 spin_lock_irqsave(q->irqlock,flags);
715 list_for_each(list,&q->stream) { 826 list_for_each(list,&q->stream) {
716 buf = list_entry(list, struct videobuf_buffer, stream); 827 buf = list_entry(list, struct videobuf_buffer, stream);
717 if (buf->state == STATE_PREPARED) 828 if (buf->state == STATE_PREPARED)
718 q->ops->buf_queue(q,buf); 829 q->ops->buf_queue(q,buf);
719 } 830 }
720 spin_unlock_irqrestore(q->irqlock,flags); 831 if (q->irqlock)
832 spin_unlock_irqrestore(q->irqlock,flags);
721 833
722 done: 834 done:
723 mutex_unlock(&q->lock); 835 mutex_unlock(&q->lock);
@@ -762,12 +874,14 @@ videobuf_read_zerocopy(struct videobuf_queue *q, char __user *data,
762 goto done; 874 goto done;
763 875
764 /* start capture & wait */ 876 /* start capture & wait */
765 spin_lock_irqsave(q->irqlock,flags); 877 if (q->irqlock)
878 spin_lock_irqsave(q->irqlock,flags);
766 q->ops->buf_queue(q,q->read_buf); 879 q->ops->buf_queue(q,q->read_buf);
767 spin_unlock_irqrestore(q->irqlock,flags); 880 if (q->irqlock)
881 spin_unlock_irqrestore(q->irqlock,flags);
768 retval = videobuf_waiton(q->read_buf,0,0); 882 retval = videobuf_waiton(q->read_buf,0,0);
769 if (0 == retval) { 883 if (0 == retval) {
770 videobuf_dma_pci_sync(q->pci,&q->read_buf->dma); 884 videobuf_dma_sync(q,&q->read_buf->dma);
771 if (STATE_ERROR == q->read_buf->state) 885 if (STATE_ERROR == q->read_buf->state)
772 retval = -EIO; 886 retval = -EIO;
773 else 887 else
@@ -809,6 +923,7 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
809 /* need to capture a new frame */ 923 /* need to capture a new frame */
810 retval = -ENOMEM; 924 retval = -ENOMEM;
811 q->read_buf = videobuf_alloc(q->msize); 925 q->read_buf = videobuf_alloc(q->msize);
926 dprintk(1,"video alloc=0x%08x\n",(unsigned int) q->read_buf);
812 if (NULL == q->read_buf) 927 if (NULL == q->read_buf)
813 goto done; 928 goto done;
814 q->read_buf->memory = V4L2_MEMORY_USERPTR; 929 q->read_buf->memory = V4L2_MEMORY_USERPTR;
@@ -820,9 +935,11 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
820 q->read_buf = NULL; 935 q->read_buf = NULL;
821 goto done; 936 goto done;
822 } 937 }
823 spin_lock_irqsave(q->irqlock,flags); 938 if (q->irqlock)
939 spin_lock_irqsave(q->irqlock,flags);
824 q->ops->buf_queue(q,q->read_buf); 940 q->ops->buf_queue(q,q->read_buf);
825 spin_unlock_irqrestore(q->irqlock,flags); 941 if (q->irqlock)
942 spin_unlock_irqrestore(q->irqlock,flags);
826 q->read_off = 0; 943 q->read_off = 0;
827 } 944 }
828 945
@@ -830,7 +947,7 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
830 retval = videobuf_waiton(q->read_buf, nonblocking, 1); 947 retval = videobuf_waiton(q->read_buf, nonblocking, 1);
831 if (0 != retval) 948 if (0 != retval)
832 goto done; 949 goto done;
833 videobuf_dma_pci_sync(q->pci,&q->read_buf->dma); 950 videobuf_dma_sync(q,&q->read_buf->dma);
834 951
835 if (STATE_ERROR == q->read_buf->state) { 952 if (STATE_ERROR == q->read_buf->state) {
836 /* catch I/O errors */ 953 /* catch I/O errors */
@@ -887,10 +1004,12 @@ int videobuf_read_start(struct videobuf_queue *q)
887 return err; 1004 return err;
888 list_add_tail(&q->bufs[i]->stream, &q->stream); 1005 list_add_tail(&q->bufs[i]->stream, &q->stream);
889 } 1006 }
890 spin_lock_irqsave(q->irqlock,flags); 1007 if (q->irqlock)
1008 spin_lock_irqsave(q->irqlock,flags);
891 for (i = 0; i < count; i++) 1009 for (i = 0; i < count; i++)
892 q->ops->buf_queue(q,q->bufs[i]); 1010 q->ops->buf_queue(q,q->bufs[i]);
893 spin_unlock_irqrestore(q->irqlock,flags); 1011 if (q->irqlock)
1012 spin_unlock_irqrestore(q->irqlock,flags);
894 q->reading = 1; 1013 q->reading = 1;
895 return 0; 1014 return 0;
896} 1015}
@@ -985,9 +1104,11 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q,
985 if (q->read_off == q->read_buf->size) { 1104 if (q->read_off == q->read_buf->size) {
986 list_add_tail(&q->read_buf->stream, 1105 list_add_tail(&q->read_buf->stream,
987 &q->stream); 1106 &q->stream);
988 spin_lock_irqsave(q->irqlock,flags); 1107 if (q->irqlock)
1108 spin_lock_irqsave(q->irqlock,flags);
989 q->ops->buf_queue(q,q->read_buf); 1109 q->ops->buf_queue(q,q->read_buf);
990 spin_unlock_irqrestore(q->irqlock,flags); 1110 if (q->irqlock)
1111 spin_unlock_irqrestore(q->irqlock,flags);
991 q->read_buf = NULL; 1112 q->read_buf = NULL;
992 } 1113 }
993 if (retval < 0) 1114 if (retval < 0)
@@ -1249,11 +1370,14 @@ EXPORT_SYMBOL_GPL(videobuf_dma_init);
1249EXPORT_SYMBOL_GPL(videobuf_dma_init_user); 1370EXPORT_SYMBOL_GPL(videobuf_dma_init_user);
1250EXPORT_SYMBOL_GPL(videobuf_dma_init_kernel); 1371EXPORT_SYMBOL_GPL(videobuf_dma_init_kernel);
1251EXPORT_SYMBOL_GPL(videobuf_dma_init_overlay); 1372EXPORT_SYMBOL_GPL(videobuf_dma_init_overlay);
1252EXPORT_SYMBOL_GPL(videobuf_dma_pci_map); 1373EXPORT_SYMBOL_GPL(videobuf_dma_map);
1253EXPORT_SYMBOL_GPL(videobuf_dma_pci_sync); 1374EXPORT_SYMBOL_GPL(videobuf_dma_sync);
1254EXPORT_SYMBOL_GPL(videobuf_dma_pci_unmap); 1375EXPORT_SYMBOL_GPL(videobuf_dma_unmap);
1255EXPORT_SYMBOL_GPL(videobuf_dma_free); 1376EXPORT_SYMBOL_GPL(videobuf_dma_free);
1256 1377
1378EXPORT_SYMBOL_GPL(videobuf_pci_dma_map);
1379EXPORT_SYMBOL_GPL(videobuf_pci_dma_unmap);
1380
1257EXPORT_SYMBOL_GPL(videobuf_alloc); 1381EXPORT_SYMBOL_GPL(videobuf_alloc);
1258EXPORT_SYMBOL_GPL(videobuf_waiton); 1382EXPORT_SYMBOL_GPL(videobuf_waiton);
1259EXPORT_SYMBOL_GPL(videobuf_iolock); 1383EXPORT_SYMBOL_GPL(videobuf_iolock);
diff --git a/include/media/saa7146_vv.h b/include/media/saa7146_vv.h
index e5e749e984ee..4507cb61ae93 100644
--- a/include/media/saa7146_vv.h
+++ b/include/media/saa7146_vv.h
@@ -197,7 +197,8 @@ void saa7146_buffer_finish(struct saa7146_dev *dev, struct saa7146_dmaqueue *q,
197void saa7146_buffer_next(struct saa7146_dev *dev, struct saa7146_dmaqueue *q,int vbi); 197void saa7146_buffer_next(struct saa7146_dev *dev, struct saa7146_dmaqueue *q,int vbi);
198int saa7146_buffer_queue(struct saa7146_dev *dev, struct saa7146_dmaqueue *q, struct saa7146_buf *buf); 198int saa7146_buffer_queue(struct saa7146_dev *dev, struct saa7146_dmaqueue *q, struct saa7146_buf *buf);
199void saa7146_buffer_timeout(unsigned long data); 199void saa7146_buffer_timeout(unsigned long data);
200void saa7146_dma_free(struct saa7146_dev *dev,struct saa7146_buf *buf); 200void saa7146_dma_free(struct saa7146_dev* dev,struct videobuf_queue *q,
201 struct saa7146_buf *buf);
201 202
202int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv); 203int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv);
203int saa7146_vv_release(struct saa7146_dev* dev); 204int saa7146_vv_release(struct saa7146_dev* dev);
diff --git a/include/media/video-buf.h b/include/media/video-buf.h
index d90dec5484ee..fff3fd0fbf94 100644
--- a/include/media/video-buf.h
+++ b/include/media/video-buf.h
@@ -1,15 +1,20 @@
1/* 1/*
2 * 2 *
3 * generic helper functions for video4linux capture buffers, to handle 3 * generic helper functions for video4linux capture buffers, to handle
4 * memory management and PCI DMA. Right now bttv + saa7134 use it. 4 * memory management and PCI DMA.
5 * Right now, bttv, saa7134, saa7146 and cx88 use it.
5 * 6 *
6 * The functions expect the hardware being able to scatter gatter 7 * The functions expect the hardware being able to scatter gatter
7 * (i.e. the buffers are not linear in physical memory, but fragmented 8 * (i.e. the buffers are not linear in physical memory, but fragmented
8 * into PAGE_SIZE chunks). They also assume the driver does not need 9 * into PAGE_SIZE chunks). They also assume the driver does not need
9 * to touch the video data (thus it is probably not useful for USB as 10 * to touch the video data.
10 * data often must be uncompressed by the drivers). 11 *
12 * device specific map/unmap/sync stuff now are mapped as file operations
13 * to allow its usage by USB and virtual devices.
11 * 14 *
12 * (c) 2001,02 Gerd Knorr <kraxel@bytesex.org> 15 * (c) 2001,02 Gerd Knorr <kraxel@bytesex.org>
16 * (c) 2006 Mauro Carvalho Chehab, <mchehab@infradead.org>
17 * (c) 2006 Ted Walther and John Sokol
13 * 18 *
14 * This program is free software; you can redistribute it and/or modify 19 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by 20 * it under the terms of the GNU General Public License as published by
@@ -38,6 +43,9 @@ struct scatterlist* videobuf_vmalloc_to_sg(unsigned char *virt, int nr_pages);
38struct scatterlist* videobuf_pages_to_sg(struct page **pages, int nr_pages, 43struct scatterlist* videobuf_pages_to_sg(struct page **pages, int nr_pages,
39 int offset); 44 int offset);
40 45
46struct videobuf_buffer;
47struct videobuf_queue;
48
41/* --------------------------------------------------------------------- */ 49/* --------------------------------------------------------------------- */
42 50
43/* 51/*
@@ -49,7 +57,7 @@ struct scatterlist* videobuf_pages_to_sg(struct page **pages, int nr_pages,
49 * pointer + length. The kernel version just wants the size and 57 * pointer + length. The kernel version just wants the size and
50 * does memory allocation too using vmalloc_32(). 58 * does memory allocation too using vmalloc_32().
51 * 59 *
52 * videobuf_dma_pci_*() 60 * videobuf_dma_*()
53 * see Documentation/DMA-mapping.txt, these functions to 61 * see Documentation/DMA-mapping.txt, these functions to
54 * basically the same. The map function does also build a 62 * basically the same. The map function does also build a
55 * scatterlist for the buffer (and unmap frees it ...) 63 * scatterlist for the buffer (and unmap frees it ...)
@@ -86,12 +94,18 @@ int videobuf_dma_init_kernel(struct videobuf_dmabuf *dma, int direction,
86 int nr_pages); 94 int nr_pages);
87int videobuf_dma_init_overlay(struct videobuf_dmabuf *dma, int direction, 95int videobuf_dma_init_overlay(struct videobuf_dmabuf *dma, int direction,
88 dma_addr_t addr, int nr_pages); 96 dma_addr_t addr, int nr_pages);
89int videobuf_dma_pci_map(struct pci_dev *dev, struct videobuf_dmabuf *dma);
90int videobuf_dma_pci_sync(struct pci_dev *dev,
91 struct videobuf_dmabuf *dma);
92int videobuf_dma_pci_unmap(struct pci_dev *dev, struct videobuf_dmabuf *dma);
93int videobuf_dma_free(struct videobuf_dmabuf *dma); 97int videobuf_dma_free(struct videobuf_dmabuf *dma);
94 98
99int videobuf_dma_map(struct videobuf_queue* q,struct videobuf_dmabuf *dma);
100int videobuf_dma_sync(struct videobuf_queue* q,struct videobuf_dmabuf *dma);
101int videobuf_dma_unmap(struct videobuf_queue* q,struct videobuf_dmabuf *dma);
102
103 /*FIXME: these variants are used only on *-alsa code, where videobuf is
104 * used without queue
105 */
106int videobuf_pci_dma_map(struct pci_dev *pci,struct videobuf_dmabuf *dma);
107int videobuf_pci_dma_unmap(struct pci_dev *pci,struct videobuf_dmabuf *dma);
108
95/* --------------------------------------------------------------------- */ 109/* --------------------------------------------------------------------- */
96 110
97/* 111/*
@@ -115,9 +129,6 @@ int videobuf_dma_free(struct videobuf_dmabuf *dma);
115 * 129 *
116 */ 130 */
117 131
118struct videobuf_buffer;
119struct videobuf_queue;
120
121struct videobuf_mapping { 132struct videobuf_mapping {
122 unsigned int count; 133 unsigned int count;
123 unsigned long start; 134 unsigned long start;
@@ -164,6 +175,10 @@ struct videobuf_buffer {
164 struct timeval ts; 175 struct timeval ts;
165}; 176};
166 177
178typedef int (vb_map_sg_t)(void *dev,struct scatterlist *sglist,int nr_pages,
179 int direction);
180
181
167struct videobuf_queue_ops { 182struct videobuf_queue_ops {
168 int (*buf_setup)(struct videobuf_queue *q, 183 int (*buf_setup)(struct videobuf_queue *q,
169 unsigned int *count, unsigned int *size); 184 unsigned int *count, unsigned int *size);
@@ -174,12 +189,20 @@ struct videobuf_queue_ops {
174 struct videobuf_buffer *vb); 189 struct videobuf_buffer *vb);
175 void (*buf_release)(struct videobuf_queue *q, 190 void (*buf_release)(struct videobuf_queue *q,
176 struct videobuf_buffer *vb); 191 struct videobuf_buffer *vb);
192
193 /* Helper operations - device dependent.
194 * If null, videobuf_init defaults all to PCI handling
195 */
196
197 vb_map_sg_t *vb_map_sg;
198 vb_map_sg_t *vb_dma_sync_sg;
199 vb_map_sg_t *vb_unmap_sg;
177}; 200};
178 201
179struct videobuf_queue { 202struct videobuf_queue {
180 struct mutex lock; 203 struct mutex lock;
181 spinlock_t *irqlock; 204 spinlock_t *irqlock;
182 struct pci_dev *pci; 205 void *dev; /* on pci, points to struct pci_dev */
183 206
184 enum v4l2_buf_type type; 207 enum v4l2_buf_type type;
185 unsigned int inputs; /* for V4L2_BUF_FLAG_INPUT */ 208 unsigned int inputs; /* for V4L2_BUF_FLAG_INPUT */
@@ -204,12 +227,15 @@ struct videobuf_queue {
204 227
205void* videobuf_alloc(unsigned int size); 228void* videobuf_alloc(unsigned int size);
206int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr); 229int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr);
207int videobuf_iolock(struct pci_dev *pci, struct videobuf_buffer *vb, 230int videobuf_iolock(struct videobuf_queue* q, struct videobuf_buffer *vb,
208 struct v4l2_framebuffer *fbuf); 231 struct v4l2_framebuffer *fbuf);
232
233/* Maps fops to PCI stuff */
234void videobuf_queue_pci(struct videobuf_queue* q);
209 235
210void videobuf_queue_init(struct videobuf_queue *q, 236void videobuf_queue_init(struct videobuf_queue *q,
211 struct videobuf_queue_ops *ops, 237 struct videobuf_queue_ops *ops,
212 struct pci_dev *pci, 238 void *dev,
213 spinlock_t *irqlock, 239 spinlock_t *irqlock,
214 enum v4l2_buf_type type, 240 enum v4l2_buf_type type,
215 enum v4l2_field field, 241 enum v4l2_field field,