aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx23885/cx23885-video.c
diff options
context:
space:
mode:
authorSteven Toth <stoth@kernellabs.com>2011-10-10 10:09:54 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-10-14 16:09:20 -0400
commit79776c89e0e52fce23d8c85f765a879ed20e760f (patch)
treee43c286144a45b35f5383a08d642fa4a8fbd2af9 /drivers/media/video/cx23885/cx23885-video.c
parentb5f74050043f4782517cd9aa2b68c13ebf5cfa90 (diff)
[media] cx23885: initialize VBI support in the core, add IRQ support, register vbi device
Coding style and printk's are cleaned up in subsequent patches Signed-off-by: Steven Toth <stoth@kernellabs.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cx23885/cx23885-video.c')
-rw-r--r--drivers/media/video/cx23885/cx23885-video.c68
1 files changed, 55 insertions, 13 deletions
diff --git a/drivers/media/video/cx23885/cx23885-video.c b/drivers/media/video/cx23885/cx23885-video.c
index 58855b2bd4e5..5496ca29d039 100644
--- a/drivers/media/video/cx23885/cx23885-video.c
+++ b/drivers/media/video/cx23885/cx23885-video.c
@@ -71,7 +71,7 @@ MODULE_PARM_DESC(vid_limit, "capture memory limit in megabytes");
71 71
72#define dprintk(level, fmt, arg...)\ 72#define dprintk(level, fmt, arg...)\
73 do { if (video_debug >= level)\ 73 do { if (video_debug >= level)\
74 printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\ 74 printk(KERN_DEBUG "%s: " fmt, dev->name, ## arg);\
75 } while (0) 75 } while (0)
76 76
77/* ------------------------------------------------------------------- */ 77/* ------------------------------------------------------------------- */
@@ -260,8 +260,8 @@ static const u32 *ctrl_classes[] = {
260 NULL 260 NULL
261}; 261};
262 262
263static void cx23885_video_wakeup(struct cx23885_dev *dev, 263void cx23885_video_wakeup(struct cx23885_dev *dev,
264 struct cx23885_dmaqueue *q, u32 count) 264 struct cx23885_dmaqueue *q, u32 count)
265{ 265{
266 struct cx23885_buffer *buf; 266 struct cx23885_buffer *buf;
267 int bc; 267 int bc;
@@ -759,6 +759,14 @@ static int video_open(struct file *file)
759 sizeof(struct cx23885_buffer), 759 sizeof(struct cx23885_buffer),
760 fh, NULL); 760 fh, NULL);
761 761
762 videobuf_queue_sg_init(&fh->vbiq, &cx23885_vbi_qops,
763 &dev->pci->dev, &dev->slock,
764 V4L2_BUF_TYPE_VBI_CAPTURE,
765 V4L2_FIELD_SEQ_TB,
766 sizeof(struct cx23885_buffer),
767 fh, NULL);
768
769
762 dprintk(1, "post videobuf_queue_init()\n"); 770 dprintk(1, "post videobuf_queue_init()\n");
763 771
764 return 0; 772 return 0;
@@ -1317,7 +1325,7 @@ static void cx23885_vid_timeout(unsigned long data)
1317 list_del(&buf->vb.queue); 1325 list_del(&buf->vb.queue);
1318 buf->vb.state = VIDEOBUF_ERROR; 1326 buf->vb.state = VIDEOBUF_ERROR;
1319 wake_up(&buf->vb.done); 1327 wake_up(&buf->vb.done);
1320 printk(KERN_ERR "%s/0: [%p/%d] timeout - dma=0x%08lx\n", 1328 printk(KERN_ERR "%s: [%p/%d] timeout - dma=0x%08lx\n",
1321 dev->name, buf, buf->vb.i, 1329 dev->name, buf, buf->vb.i,
1322 (unsigned long)buf->risc.dma); 1330 (unsigned long)buf->risc.dma);
1323 } 1331 }
@@ -1333,27 +1341,43 @@ int cx23885_video_irq(struct cx23885_dev *dev, u32 status)
1333 mask = cx_read(VID_A_INT_MSK); 1341 mask = cx_read(VID_A_INT_MSK);
1334 if (0 == (status & mask)) 1342 if (0 == (status & mask))
1335 return handled; 1343 return handled;
1344
1336 cx_write(VID_A_INT_STAT, status); 1345 cx_write(VID_A_INT_STAT, status);
1337 1346
1338 dprintk(2, "%s() status = 0x%08x\n", __func__, status);
1339 /* risc op code error */ 1347 /* risc op code error */
1340 if (status & (1 << 16)) { 1348 if ((status & VID_BC_MSK_OPC_ERR) ||
1341 printk(KERN_WARNING "%s/0: video risc op code error\n", 1349 (status & VID_BC_MSK_SYNC) ||
1350 (status & VID_BC_MSK_OF)) {
1351
1352 if (status & VID_BC_MSK_OPC_ERR)
1353 dprintk(7, " (VID_BC_MSK_OPC_ERR 0x%08x)\n",
1354 VID_BC_MSK_OPC_ERR);
1355
1356 if (status & VID_BC_MSK_SYNC)
1357 dprintk(7, " (VID_BC_MSK_SYNC 0x%08x)\n",
1358 VID_BC_MSK_SYNC);
1359
1360 if (status & VID_BC_MSK_OF)
1361 dprintk(7, " (VID_BC_MSK_OF 0x%08x)\n",
1362 VID_BC_MSK_OF);
1363
1364 printk(KERN_WARNING "%s: video risc op code error\n",
1342 dev->name); 1365 dev->name);
1366
1343 cx_clear(VID_A_DMA_CTL, 0x11); 1367 cx_clear(VID_A_DMA_CTL, 0x11);
1344 cx23885_sram_channel_dump(dev, &dev->sram_channels[SRAM_CH01]); 1368 cx23885_sram_channel_dump(dev, &dev->sram_channels[SRAM_CH01]);
1369
1345 } 1370 }
1346 1371
1347 /* risc1 y */ 1372 /* Video */
1348 if (status & 0x01) { 1373 if (status & VID_BC_MSK_RISCI1) {
1349 spin_lock(&dev->slock); 1374 spin_lock(&dev->slock);
1350 count = cx_read(VID_A_GPCNT); 1375 count = cx_read(VID_A_GPCNT);
1351 cx23885_video_wakeup(dev, &dev->vidq, count); 1376 cx23885_video_wakeup(dev, &dev->vidq, count);
1352 spin_unlock(&dev->slock); 1377 spin_unlock(&dev->slock);
1353 handled++; 1378 handled++;
1354 } 1379 }
1355 /* risc2 y */ 1380 if (status & VID_BC_MSK_RISCI2) {
1356 if (status & 0x10) {
1357 dprintk(2, "stopper video\n"); 1381 dprintk(2, "stopper video\n");
1358 spin_lock(&dev->slock); 1382 spin_lock(&dev->slock);
1359 cx23885_restart_video_queue(dev, &dev->vidq); 1383 cx23885_restart_video_queue(dev, &dev->vidq);
@@ -1361,6 +1385,9 @@ int cx23885_video_irq(struct cx23885_dev *dev, u32 status)
1361 handled++; 1385 handled++;
1362 } 1386 }
1363 1387
1388 /* Allow the VBI framework to process it's payload */
1389 handled += cx23885_vbi_irq(dev, status);
1390
1364 return handled; 1391 return handled;
1365} 1392}
1366 1393
@@ -1433,6 +1460,14 @@ void cx23885_video_unregister(struct cx23885_dev *dev)
1433 dprintk(1, "%s()\n", __func__); 1460 dprintk(1, "%s()\n", __func__);
1434 cx23885_irq_remove(dev, 0x01); 1461 cx23885_irq_remove(dev, 0x01);
1435 1462
1463 if (dev->vbi_dev) {
1464 if (video_is_registered(dev->vbi_dev))
1465 video_unregister_device(dev->vbi_dev);
1466 else
1467 video_device_release(dev->vbi_dev);
1468 dev->vbi_dev = NULL;
1469 btcx_riscmem_free(dev->pci, &dev->vbiq.stopper);
1470 }
1436 if (dev->video_dev) { 1471 if (dev->video_dev) {
1437 if (video_is_registered(dev->video_dev)) 1472 if (video_is_registered(dev->video_dev))
1438 video_unregister_device(dev->video_dev); 1473 video_unregister_device(dev->video_dev);
@@ -1470,7 +1505,14 @@ int cx23885_video_register(struct cx23885_dev *dev)
1470 cx23885_risc_stopper(dev->pci, &dev->vidq.stopper, 1505 cx23885_risc_stopper(dev->pci, &dev->vidq.stopper,
1471 VID_A_DMA_CTL, 0x11, 0x00); 1506 VID_A_DMA_CTL, 0x11, 0x00);
1472 1507
1473 /* Don't enable VBI yet */ 1508 /* init vbi dma queues */
1509 INIT_LIST_HEAD(&dev->vbiq.active);
1510 INIT_LIST_HEAD(&dev->vbiq.queued);
1511 dev->vbiq.timeout.function = cx23885_vbi_timeout;
1512 dev->vbiq.timeout.data = (unsigned long)dev;
1513 init_timer(&dev->vbiq.timeout);
1514 cx23885_risc_stopper(dev->pci, &dev->vbiq.stopper,
1515 VID_A_DMA_CTL, 0x22, 0x00);
1474 1516
1475 cx23885_irq_add_enable(dev, 0x01); 1517 cx23885_irq_add_enable(dev, 0x01);
1476 1518
@@ -1511,7 +1553,7 @@ int cx23885_video_register(struct cx23885_dev *dev)
1511 } 1553 }
1512 } 1554 }
1513 1555
1514 /* register v4l devices */ 1556 /* register Video device */
1515 dev->video_dev = cx23885_vdev_init(dev, dev->pci, 1557 dev->video_dev = cx23885_vdev_init(dev, dev->pci,
1516 &cx23885_video_template, "video"); 1558 &cx23885_video_template, "video");
1517 err = video_register_device(dev->video_dev, VFL_TYPE_GRABBER, 1559 err = video_register_device(dev->video_dev, VFL_TYPE_GRABBER,