aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/pci
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/pci')
-rw-r--r--drivers/media/pci/saa7134/saa7134-core.c1
-rw-r--r--drivers/media/pci/saa7134/saa7134-vbi.c11
-rw-r--r--drivers/media/pci/saa7134/saa7134-video.c102
-rw-r--r--drivers/media/pci/saa7134/saa7134.h13
4 files changed, 63 insertions, 64 deletions
diff --git a/drivers/media/pci/saa7134/saa7134-core.c b/drivers/media/pci/saa7134/saa7134-core.c
index 27d7ee709c58..f442405568d8 100644
--- a/drivers/media/pci/saa7134/saa7134-core.c
+++ b/drivers/media/pci/saa7134/saa7134-core.c
@@ -751,6 +751,7 @@ static int saa7134_hwfini(struct saa7134_dev *dev)
751 saa7134_input_fini(dev); 751 saa7134_input_fini(dev);
752 saa7134_vbi_fini(dev); 752 saa7134_vbi_fini(dev);
753 saa7134_tvaudio_fini(dev); 753 saa7134_tvaudio_fini(dev);
754 saa7134_video_fini(dev);
754 return 0; 755 return 0;
755} 756}
756 757
diff --git a/drivers/media/pci/saa7134/saa7134-vbi.c b/drivers/media/pci/saa7134/saa7134-vbi.c
index e9aa94b807f1..d4da18d049f3 100644
--- a/drivers/media/pci/saa7134/saa7134-vbi.c
+++ b/drivers/media/pci/saa7134/saa7134-vbi.c
@@ -117,8 +117,7 @@ static int buffer_prepare(struct videobuf_queue *q,
117 struct videobuf_buffer *vb, 117 struct videobuf_buffer *vb,
118 enum v4l2_field field) 118 enum v4l2_field field)
119{ 119{
120 struct saa7134_fh *fh = q->priv_data; 120 struct saa7134_dev *dev = q->priv_data;
121 struct saa7134_dev *dev = fh->dev;
122 struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb); 121 struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
123 struct saa7134_tvnorm *norm = dev->tvnorm; 122 struct saa7134_tvnorm *norm = dev->tvnorm;
124 unsigned int lines, llength, size; 123 unsigned int lines, llength, size;
@@ -141,7 +140,7 @@ static int buffer_prepare(struct videobuf_queue *q,
141 buf->vb.width = llength; 140 buf->vb.width = llength;
142 buf->vb.height = lines; 141 buf->vb.height = lines;
143 buf->vb.size = size; 142 buf->vb.size = size;
144 buf->pt = &fh->pt_vbi; 143 buf->pt = &dev->pt_vbi;
145 144
146 err = videobuf_iolock(q,&buf->vb,NULL); 145 err = videobuf_iolock(q,&buf->vb,NULL);
147 if (err) 146 if (err)
@@ -166,8 +165,7 @@ static int buffer_prepare(struct videobuf_queue *q,
166static int 165static int
167buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size) 166buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
168{ 167{
169 struct saa7134_fh *fh = q->priv_data; 168 struct saa7134_dev *dev = q->priv_data;
170 struct saa7134_dev *dev = fh->dev;
171 int llength,lines; 169 int llength,lines;
172 170
173 lines = dev->tvnorm->vbi_v_stop_0 - dev->tvnorm->vbi_v_start_0 +1; 171 lines = dev->tvnorm->vbi_v_stop_0 - dev->tvnorm->vbi_v_start_0 +1;
@@ -181,8 +179,7 @@ buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
181 179
182static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) 180static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
183{ 181{
184 struct saa7134_fh *fh = q->priv_data; 182 struct saa7134_dev *dev = q->priv_data;
185 struct saa7134_dev *dev = fh->dev;
186 struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb); 183 struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
187 184
188 saa7134_buffer_queue(dev,&dev->vbi_q,buf); 185 saa7134_buffer_queue(dev,&dev->vbi_q,buf);
diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c
index fb60da85bc2c..8f73058f901e 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -1018,8 +1018,7 @@ static int buffer_prepare(struct videobuf_queue *q,
1018 struct videobuf_buffer *vb, 1018 struct videobuf_buffer *vb,
1019 enum v4l2_field field) 1019 enum v4l2_field field)
1020{ 1020{
1021 struct saa7134_fh *fh = q->priv_data; 1021 struct saa7134_dev *dev = q->priv_data;
1022 struct saa7134_dev *dev = fh->dev;
1023 struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb); 1022 struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
1024 unsigned int size; 1023 unsigned int size;
1025 int err; 1024 int err;
@@ -1057,7 +1056,7 @@ static int buffer_prepare(struct videobuf_queue *q,
1057 buf->vb.size = size; 1056 buf->vb.size = size;
1058 buf->vb.field = field; 1057 buf->vb.field = field;
1059 buf->fmt = dev->fmt; 1058 buf->fmt = dev->fmt;
1060 buf->pt = &fh->pt_cap; 1059 buf->pt = &dev->pt_cap;
1061 dev->video_q.curr = NULL; 1060 dev->video_q.curr = NULL;
1062 1061
1063 err = videobuf_iolock(q,&buf->vb,&dev->ovbuf); 1062 err = videobuf_iolock(q,&buf->vb,&dev->ovbuf);
@@ -1082,8 +1081,7 @@ static int buffer_prepare(struct videobuf_queue *q,
1082static int 1081static int
1083buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size) 1082buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
1084{ 1083{
1085 struct saa7134_fh *fh = q->priv_data; 1084 struct saa7134_dev *dev = q->priv_data;
1086 struct saa7134_dev *dev = fh->dev;
1087 1085
1088 *size = dev->fmt->depth * dev->width * dev->height >> 3; 1086 *size = dev->fmt->depth * dev->width * dev->height >> 3;
1089 if (0 == *count) 1087 if (0 == *count)
@@ -1094,10 +1092,10 @@ buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
1094 1092
1095static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) 1093static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
1096{ 1094{
1097 struct saa7134_fh *fh = q->priv_data; 1095 struct saa7134_dev *dev = q->priv_data;
1098 struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb); 1096 struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
1099 1097
1100 saa7134_buffer_queue(fh->dev,&fh->dev->video_q,buf); 1098 saa7134_buffer_queue(dev, &dev->video_q, buf);
1101} 1099}
1102 1100
1103static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) 1101static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
@@ -1293,14 +1291,15 @@ static struct videobuf_queue *saa7134_queue(struct file *file)
1293{ 1291{
1294 struct video_device *vdev = video_devdata(file); 1292 struct video_device *vdev = video_devdata(file);
1295 struct saa7134_fh *fh = file->private_data; 1293 struct saa7134_fh *fh = file->private_data;
1294 struct saa7134_dev *dev = fh->dev;
1296 struct videobuf_queue *q = NULL; 1295 struct videobuf_queue *q = NULL;
1297 1296
1298 switch (vdev->vfl_type) { 1297 switch (vdev->vfl_type) {
1299 case VFL_TYPE_GRABBER: 1298 case VFL_TYPE_GRABBER:
1300 q = &fh->cap; 1299 q = &dev->cap;
1301 break; 1300 break;
1302 case VFL_TYPE_VBI: 1301 case VFL_TYPE_VBI:
1303 q = &fh->vbi; 1302 q = &dev->vbi;
1304 break; 1303 break;
1305 default: 1304 default:
1306 BUG(); 1305 BUG();
@@ -1337,21 +1336,6 @@ static int video_open(struct file *file)
1337 file->private_data = fh; 1336 file->private_data = fh;
1338 fh->dev = dev; 1337 fh->dev = dev;
1339 1338
1340 videobuf_queue_sg_init(&fh->cap, &video_qops,
1341 &dev->pci->dev, &dev->slock,
1342 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1343 V4L2_FIELD_INTERLACED,
1344 sizeof(struct saa7134_buf),
1345 fh, NULL);
1346 videobuf_queue_sg_init(&fh->vbi, &saa7134_vbi_qops,
1347 &dev->pci->dev, &dev->slock,
1348 V4L2_BUF_TYPE_VBI_CAPTURE,
1349 V4L2_FIELD_SEQ_TB,
1350 sizeof(struct saa7134_buf),
1351 fh, NULL);
1352 saa7134_pgtable_alloc(dev->pci,&fh->pt_cap);
1353 saa7134_pgtable_alloc(dev->pci,&fh->pt_vbi);
1354
1355 if (vdev->vfl_type == VFL_TYPE_RADIO) { 1339 if (vdev->vfl_type == VFL_TYPE_RADIO) {
1356 /* switch to radio mode */ 1340 /* switch to radio mode */
1357 saa7134_tvaudio_setinput(dev,&card(dev).radio); 1341 saa7134_tvaudio_setinput(dev,&card(dev).radio);
@@ -1396,28 +1380,30 @@ video_poll(struct file *file, struct poll_table_struct *wait)
1396{ 1380{
1397 struct video_device *vdev = video_devdata(file); 1381 struct video_device *vdev = video_devdata(file);
1398 struct saa7134_fh *fh = file->private_data; 1382 struct saa7134_fh *fh = file->private_data;
1383 struct saa7134_dev *dev = fh->dev;
1399 struct videobuf_buffer *buf = NULL; 1384 struct videobuf_buffer *buf = NULL;
1400 unsigned int rc = 0; 1385 unsigned int rc = 0;
1401 1386
1402 if (vdev->vfl_type == VFL_TYPE_VBI) 1387 if (vdev->vfl_type == VFL_TYPE_VBI)
1403 return videobuf_poll_stream(file, &fh->vbi, wait); 1388 return videobuf_poll_stream(file, &dev->vbi, wait);
1404 1389
1405 if (res_check(fh,RESOURCE_VIDEO)) { 1390 if (res_check(fh,RESOURCE_VIDEO)) {
1406 mutex_lock(&fh->cap.vb_lock); 1391 mutex_lock(&dev->cap.vb_lock);
1407 if (!list_empty(&fh->cap.stream)) 1392 if (!list_empty(&dev->cap.stream))
1408 buf = list_entry(fh->cap.stream.next, struct videobuf_buffer, stream); 1393 buf = list_entry(dev->cap.stream.next, struct videobuf_buffer, stream);
1409 } else { 1394 } else {
1410 mutex_lock(&fh->cap.vb_lock); 1395 mutex_lock(&dev->cap.vb_lock);
1411 if (UNSET == fh->cap.read_off) { 1396 if (UNSET == dev->cap.read_off) {
1412 /* need to capture a new frame */ 1397 /* need to capture a new frame */
1413 if (res_locked(fh->dev,RESOURCE_VIDEO)) 1398 if (res_locked(fh->dev,RESOURCE_VIDEO))
1414 goto err; 1399 goto err;
1415 if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,fh->cap.field)) 1400 if (0 != dev->cap.ops->buf_prepare(&dev->cap,
1401 dev->cap.read_buf, dev->cap.field))
1416 goto err; 1402 goto err;
1417 fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf); 1403 dev->cap.ops->buf_queue(&dev->cap, dev->cap.read_buf);
1418 fh->cap.read_off = 0; 1404 dev->cap.read_off = 0;
1419 } 1405 }
1420 buf = fh->cap.read_buf; 1406 buf = dev->cap.read_buf;
1421 } 1407 }
1422 1408
1423 if (!buf) 1409 if (!buf)
@@ -1427,11 +1413,11 @@ video_poll(struct file *file, struct poll_table_struct *wait)
1427 if (buf->state == VIDEOBUF_DONE || 1413 if (buf->state == VIDEOBUF_DONE ||
1428 buf->state == VIDEOBUF_ERROR) 1414 buf->state == VIDEOBUF_ERROR)
1429 rc = POLLIN|POLLRDNORM; 1415 rc = POLLIN|POLLRDNORM;
1430 mutex_unlock(&fh->cap.vb_lock); 1416 mutex_unlock(&dev->cap.vb_lock);
1431 return rc; 1417 return rc;
1432 1418
1433err: 1419err:
1434 mutex_unlock(&fh->cap.vb_lock); 1420 mutex_unlock(&dev->cap.vb_lock);
1435 return POLLERR; 1421 return POLLERR;
1436} 1422}
1437 1423
@@ -1456,18 +1442,20 @@ static int video_release(struct file *file)
1456 /* stop video capture */ 1442 /* stop video capture */
1457 if (res_check(fh, RESOURCE_VIDEO)) { 1443 if (res_check(fh, RESOURCE_VIDEO)) {
1458 pm_qos_remove_request(&dev->qos_request); 1444 pm_qos_remove_request(&dev->qos_request);
1459 videobuf_streamoff(&fh->cap); 1445 videobuf_streamoff(&dev->cap);
1460 res_free(dev,fh,RESOURCE_VIDEO); 1446 res_free(dev,fh,RESOURCE_VIDEO);
1447 videobuf_mmap_free(&dev->cap);
1461 } 1448 }
1462 if (fh->cap.read_buf) { 1449 if (dev->cap.read_buf) {
1463 buffer_release(&fh->cap,fh->cap.read_buf); 1450 buffer_release(&dev->cap, dev->cap.read_buf);
1464 kfree(fh->cap.read_buf); 1451 kfree(dev->cap.read_buf);
1465 } 1452 }
1466 1453
1467 /* stop vbi capture */ 1454 /* stop vbi capture */
1468 if (res_check(fh, RESOURCE_VBI)) { 1455 if (res_check(fh, RESOURCE_VBI)) {
1469 videobuf_stop(&fh->vbi); 1456 videobuf_stop(&dev->vbi);
1470 res_free(dev,fh,RESOURCE_VBI); 1457 res_free(dev,fh,RESOURCE_VBI);
1458 videobuf_mmap_free(&dev->vbi);
1471 } 1459 }
1472 1460
1473 /* ts-capture will not work in planar mode, so turn it off Hac: 04.05*/ 1461 /* ts-capture will not work in planar mode, so turn it off Hac: 04.05*/
@@ -1480,12 +1468,6 @@ static int video_release(struct file *file)
1480 if (vdev->vfl_type == VFL_TYPE_RADIO) 1468 if (vdev->vfl_type == VFL_TYPE_RADIO)
1481 saa_call_all(dev, core, ioctl, SAA6588_CMD_CLOSE, &cmd); 1469 saa_call_all(dev, core, ioctl, SAA6588_CMD_CLOSE, &cmd);
1482 1470
1483 /* free stuff */
1484 videobuf_mmap_free(&fh->cap);
1485 videobuf_mmap_free(&fh->vbi);
1486 saa7134_pgtable_free(dev->pci,&fh->pt_cap);
1487 saa7134_pgtable_free(dev->pci,&fh->pt_vbi);
1488
1489 v4l2_fh_del(&fh->fh); 1471 v4l2_fh_del(&fh->fh);
1490 v4l2_fh_exit(&fh->fh); 1472 v4l2_fh_exit(&fh->fh);
1491 file->private_data = NULL; 1473 file->private_data = NULL;
@@ -1560,7 +1542,7 @@ static int saa7134_g_fmt_vid_cap(struct file *file, void *priv,
1560 1542
1561 f->fmt.pix.width = dev->width; 1543 f->fmt.pix.width = dev->width;
1562 f->fmt.pix.height = dev->height; 1544 f->fmt.pix.height = dev->height;
1563 f->fmt.pix.field = fh->cap.field; 1545 f->fmt.pix.field = dev->cap.field;
1564 f->fmt.pix.pixelformat = dev->fmt->fourcc; 1546 f->fmt.pix.pixelformat = dev->fmt->fourcc;
1565 f->fmt.pix.bytesperline = 1547 f->fmt.pix.bytesperline =
1566 (f->fmt.pix.width * dev->fmt->depth) >> 3; 1548 (f->fmt.pix.width * dev->fmt->depth) >> 3;
@@ -1686,7 +1668,7 @@ static int saa7134_s_fmt_vid_cap(struct file *file, void *priv,
1686 dev->fmt = format_by_fourcc(f->fmt.pix.pixelformat); 1668 dev->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
1687 dev->width = f->fmt.pix.width; 1669 dev->width = f->fmt.pix.width;
1688 dev->height = f->fmt.pix.height; 1670 dev->height = f->fmt.pix.height;
1689 fh->cap.field = f->fmt.pix.field; 1671 dev->cap.field = f->fmt.pix.field;
1690 return 0; 1672 return 0;
1691} 1673}
1692 1674
@@ -2489,9 +2471,31 @@ int saa7134_video_init1(struct saa7134_dev *dev)
2489 if (saa7134_boards[dev->board].video_out) 2471 if (saa7134_boards[dev->board].video_out)
2490 saa7134_videoport_init(dev); 2472 saa7134_videoport_init(dev);
2491 2473
2474 videobuf_queue_sg_init(&dev->cap, &video_qops,
2475 &dev->pci->dev, &dev->slock,
2476 V4L2_BUF_TYPE_VIDEO_CAPTURE,
2477 V4L2_FIELD_INTERLACED,
2478 sizeof(struct saa7134_buf),
2479 dev, NULL);
2480 videobuf_queue_sg_init(&dev->vbi, &saa7134_vbi_qops,
2481 &dev->pci->dev, &dev->slock,
2482 V4L2_BUF_TYPE_VBI_CAPTURE,
2483 V4L2_FIELD_SEQ_TB,
2484 sizeof(struct saa7134_buf),
2485 dev, NULL);
2486 saa7134_pgtable_alloc(dev->pci, &dev->pt_cap);
2487 saa7134_pgtable_alloc(dev->pci, &dev->pt_vbi);
2488
2492 return 0; 2489 return 0;
2493} 2490}
2494 2491
2492void saa7134_video_fini(struct saa7134_dev *dev)
2493{
2494 /* free stuff */
2495 saa7134_pgtable_free(dev->pci, &dev->pt_cap);
2496 saa7134_pgtable_free(dev->pci, &dev->pt_vbi);
2497}
2498
2495int saa7134_videoport_init(struct saa7134_dev *dev) 2499int saa7134_videoport_init(struct saa7134_dev *dev)
2496{ 2500{
2497 /* enable video output */ 2501 /* enable video output */
diff --git a/drivers/media/pci/saa7134/saa7134.h b/drivers/media/pci/saa7134/saa7134.h
index 8d1453a48014..96b7ccf9a384 100644
--- a/drivers/media/pci/saa7134/saa7134.h
+++ b/drivers/media/pci/saa7134/saa7134.h
@@ -472,14 +472,6 @@ struct saa7134_fh {
472 struct v4l2_fh fh; 472 struct v4l2_fh fh;
473 struct saa7134_dev *dev; 473 struct saa7134_dev *dev;
474 unsigned int resources; 474 unsigned int resources;
475
476 /* video capture */
477 struct videobuf_queue cap;
478 struct saa7134_pgtable pt_cap;
479
480 /* vbi capture */
481 struct videobuf_queue vbi;
482 struct saa7134_pgtable pt_vbi;
483}; 475};
484 476
485/* dmasound dsp status */ 477/* dmasound dsp status */
@@ -589,7 +581,11 @@ struct saa7134_dev {
589 581
590 /* video+ts+vbi capture */ 582 /* video+ts+vbi capture */
591 struct saa7134_dmaqueue video_q; 583 struct saa7134_dmaqueue video_q;
584 struct videobuf_queue cap;
585 struct saa7134_pgtable pt_cap;
592 struct saa7134_dmaqueue vbi_q; 586 struct saa7134_dmaqueue vbi_q;
587 struct videobuf_queue vbi;
588 struct saa7134_pgtable pt_vbi;
593 unsigned int video_fieldcount; 589 unsigned int video_fieldcount;
594 unsigned int vbi_fieldcount; 590 unsigned int vbi_fieldcount;
595 struct saa7134_format *fmt; 591 struct saa7134_format *fmt;
@@ -773,6 +769,7 @@ int saa7134_video_init1(struct saa7134_dev *dev);
773int saa7134_video_init2(struct saa7134_dev *dev); 769int saa7134_video_init2(struct saa7134_dev *dev);
774void saa7134_irq_video_signalchange(struct saa7134_dev *dev); 770void saa7134_irq_video_signalchange(struct saa7134_dev *dev);
775void saa7134_irq_video_done(struct saa7134_dev *dev, unsigned long status); 771void saa7134_irq_video_done(struct saa7134_dev *dev, unsigned long status);
772void saa7134_video_fini(struct saa7134_dev *dev);
776 773
777 774
778/* ----------------------------------------------------------- */ 775/* ----------------------------------------------------------- */