summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/cx88/cx88-dvb.c
diff options
context:
space:
mode:
authorGerd Knorr <devnull@localhost>2004-10-19 16:02:04 +0000
committerGerd Knorr <devnull@localhost>2004-10-19 16:02:04 +0000
commit1978764a333728085febe6606437b586fc2e14d4 (patch)
tree80d861b548370e3dfc319649d43c956e238587e2 /linux/drivers/media/video/cx88/cx88-dvb.c
parent005bc8a9298b2eab8e0bdb6d494b5b13c32811f4 (diff)
downloadmediapointer-dvb-s2-1978764a333728085febe6606437b586fc2e14d4.tar.gz
mediapointer-dvb-s2-1978764a333728085febe6606437b586fc2e14d4.tar.bz2
- saa7134 reorganiation for modular mpeg2 stuff
- splitted some generic dvb code into the new video-buf-dvb module.
Diffstat (limited to 'linux/drivers/media/video/cx88/cx88-dvb.c')
-rw-r--r--linux/drivers/media/video/cx88/cx88-dvb.c211
1 files changed, 20 insertions, 191 deletions
diff --git a/linux/drivers/media/video/cx88/cx88-dvb.c b/linux/drivers/media/video/cx88/cx88-dvb.c
index 29a35e876..878d7c19d 100644
--- a/linux/drivers/media/video/cx88/cx88-dvb.c
+++ b/linux/drivers/media/video/cx88/cx88-dvb.c
@@ -1,5 +1,5 @@
/*
- * $Id: cx88-dvb.c,v 1.13 2004/10/13 10:39:00 kraxel Exp $
+ * $Id: cx88-dvb.c,v 1.14 2004/10/19 16:02:04 kraxel Exp $
*
* device driver for Conexant 2388x based TV cards
* MPEG Transport Stream (DVB) routines
@@ -85,136 +85,14 @@ struct videobuf_queue_ops dvb_qops = {
.buf_release = dvb_buf_release,
};
-static int dvb_thread(void *data)
-{
- struct cx8802_dev *dev = data;
- struct videobuf_buffer *buf;
- unsigned long flags;
- int err;
-
- dprintk(1,"dvb thread started\n");
- videobuf_read_start(dev, &dev->dvbq);
-
- for (;;) {
- /* fetch next buffer */
- buf = list_entry(dev->dvbq.stream.next,
- struct videobuf_buffer, stream);
- list_del(&buf->stream);
- err = videobuf_waiton(buf,0,1);
- BUG_ON(0 != err);
-
- /* no more feeds left or stop_feed() asked us to quit */
- if (0 == dev->nfeeds)
- break;
- if (kthread_should_stop())
- break;
- if (current->flags & PF_FREEZE)
- refrigerator(PF_FREEZE);
-
- /* feed buffer data to demux */
- if (buf->state == STATE_DONE)
- dvb_dmx_swfilter(&dev->demux, buf->dma.vmalloc,
- buf->size);
-
- /* requeue buffer */
- list_add_tail(&buf->stream,&dev->dvbq.stream);
- spin_lock_irqsave(dev->dvbq.irqlock,flags);
- dev->dvbq.ops->buf_queue(dev,buf);
- spin_unlock_irqrestore(dev->dvbq.irqlock,flags);
-
- /* log errors if any */
- if (dev->error_count || dev->stopper_count) {
- printk("%s: error=%d stopper=%d\n",
- dev->core->name, dev->error_count,
- dev->stopper_count);
- dev->error_count = 0;
- dev->stopper_count = 0;
- }
- if (debug && dev->timeout_count) {
- printk("%s: timeout=%d (FE not locked?)\n",
- dev->core->name, dev->timeout_count);
- dev->timeout_count = 0;
- }
- }
-
- videobuf_read_stop(dev, &dev->dvbq);
- dprintk(1,"dvb thread stopped\n");
-
- /* Hmm, linux becomes *very* unhappy without this ... */
- while (!kthread_should_stop()) {
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule();
- }
- return 0;
-}
-
-/* ---------------------------------------------------------------------------- */
-
-static int dvb_start_feed(struct dvb_demux_feed *feed)
-{
- struct dvb_demux *demux = feed->demux;
- struct cx8802_dev *dev = demux->priv;
- int rc;
-
- if (!demux->dmx.frontend)
- return -EINVAL;
-
- down(&dev->lock);
- dev->nfeeds++;
- rc = dev->nfeeds;
-
- if (NULL != dev->dvb_thread)
- goto out;
- dev->dvb_thread = kthread_run(dvb_thread, dev, "%s dvb", dev->core->name);
- if (IS_ERR(dev->dvb_thread)) {
- rc = PTR_ERR(dev->dvb_thread);
- dev->dvb_thread = NULL;
- }
-
-out:
- up(&dev->lock);
- dprintk(2, "%s rc=%d\n",__FUNCTION__,rc);
- return rc;
-}
-
-static int dvb_stop_feed(struct dvb_demux_feed *feed)
-{
- struct dvb_demux *demux = feed->demux;
- struct cx8802_dev *dev = demux->priv;
- int err = 0;
-
- dprintk(2, "%s\n",__FUNCTION__);
-
- down(&dev->lock);
- dev->nfeeds--;
- if (0 == dev->nfeeds && NULL != dev->dvb_thread) {
- cx8802_cancel_buffers(dev);
- err = kthread_stop(dev->dvb_thread);
- dev->dvb_thread = NULL;
- }
- up(&dev->lock);
- return err;
-}
+/* ------------------------------------------------------------------ */
static void dvb_unregister(struct cx8802_dev *dev)
{
-#if 1 /* really needed? */
- down(&dev->lock);
- if (NULL != dev->dvb_thread) {
- kthread_stop(dev->dvb_thread);
- BUG();
- }
- up(&dev->lock);
-#endif
-
- dvb_net_release(&dev->dvbnet);
- dev->demux.dmx.remove_frontend(&dev->demux.dmx, &dev->fe_mem);
- dev->demux.dmx.remove_frontend(&dev->demux.dmx, &dev->fe_hw);
- dvb_dmxdev_release(&dev->dmxdev);
- dvb_dmx_release(&dev->demux);
+ videobuf_dvb_unregister(&dev->dvb);
if (dev->fe_handle)
dev->fe_release(dev->fe_handle);
- dvb_unregister_adapter(dev->dvb_adapter);
+ dvb_unregister_adapter(dev->dvb.adapter);
return;
}
@@ -222,8 +100,12 @@ static int dvb_register(struct cx8802_dev *dev)
{
int result;
- /* adapter */
- result = dvb_register_adapter(&dev->dvb_adapter, dev->core->name,
+ /* init struct videobuf_dvb */
+ dev->dvb.priv = dev;
+ dev->dvb.name = dev->core->name;
+
+ /* register adapter */
+ result = dvb_register_adapter(&dev->dvb.adapter, dev->core->name,
THIS_MODULE);
if (result < 0) {
printk(KERN_WARNING "%s: dvb_register_adapter failed (errno = %d)\n",
@@ -231,12 +113,12 @@ static int dvb_register(struct cx8802_dev *dev)
goto fail1;
}
- /* frontend */
+ /* init + register frontend */
switch (dev->core->board) {
case CX88_BOARD_HAUPPAUGE_DVB_T1:
case CX88_BOARD_CONEXANT_DVB_T1:
dev->fe_handle = cx22702_create(&dev->core->i2c_adap,
- dev->dvb_adapter,
+ dev->dvb.adapter,
dev->core->pll_addr,
dev->core->pll_type,
dev->core->demod_addr);
@@ -248,68 +130,14 @@ static int dvb_register(struct cx8802_dev *dev)
break;
}
- /* demux */
- dev->demux.dmx.capabilities =
- DMX_TS_FILTERING | DMX_SECTION_FILTERING |
- DMX_MEMORY_BASED_FILTERING;
- dev->demux.priv = dev;
- dev->demux.filternum = 256;
- dev->demux.feednum = 256;
- dev->demux.start_feed = dvb_start_feed;
- dev->demux.stop_feed = dvb_stop_feed;
- result = dvb_dmx_init(&dev->demux);
- if (result < 0) {
- printk(KERN_WARNING "%s: dvb_dmx_init failed (errno = %d)\n",
- dev->core->name, result);
+ /* register everything else */
+ result = videobuf_dvb_register(&dev->dvb);
+ if (0 != result)
goto fail2;
- }
-
- dev->dmxdev.filternum = 256;
- dev->dmxdev.demux = &dev->demux.dmx;
- dev->dmxdev.capabilities = 0;
- result = dvb_dmxdev_init(&dev->dmxdev, dev->dvb_adapter);
- if (result < 0) {
- printk(KERN_WARNING "%s: dvb_dmxdev_init failed (errno = %d)\n",
- dev->core->name, result);
- goto fail3;
- }
-
- dev->fe_hw.source = DMX_FRONTEND_0;
- result = dev->demux.dmx.add_frontend(&dev->demux.dmx, &dev->fe_hw);
- if (result < 0) {
- printk(KERN_WARNING "%s: add_frontend failed (DMX_FRONTEND_0, errno = %d)\n",
- dev->core->name, result);
- goto fail4;
- }
-
- dev->fe_mem.source = DMX_MEMORY_FE;
- result = dev->demux.dmx.add_frontend(&dev->demux.dmx, &dev->fe_mem);
- if (result < 0) {
- printk(KERN_WARNING "%s: add_frontend failed (DMX_MEMORY_FE, errno = %d)\n",
- dev->core->name, result);
- goto fail5;
- }
-
- result = dev->demux.dmx.connect_frontend(&dev->demux.dmx, &dev->fe_hw);
- if (result < 0) {
- printk(KERN_WARNING "%s: connect_frontend failed (errno = %d)\n",
- dev->core->name, result);
- goto fail6;
- }
-
- dvb_net_init(dev->dvb_adapter, &dev->dvbnet, &dev->demux.dmx);
return 0;
-fail6:
- dev->demux.dmx.remove_frontend(&dev->demux.dmx, &dev->fe_mem);
-fail5:
- dev->demux.dmx.remove_frontend(&dev->demux.dmx, &dev->fe_hw);
-fail4:
- dvb_dmxdev_release(&dev->dmxdev);
-fail3:
- dvb_dmx_release(&dev->demux);
fail2:
- dvb_unregister_adapter(dev->dvb_adapter);
+ dvb_unregister_adapter(dev->dvb.adapter);
fail1:
return result;
}
@@ -346,12 +174,12 @@ static int __devinit dvb_probe(struct pci_dev *pci_dev,
/* dvb stuff */
printk("%s/2: cx2388x based dvb card\n", core->name);
- videobuf_queue_init(&dev->dvbq, &dvb_qops,
+ videobuf_queue_init(&dev->dvb.dvbq, &dvb_qops,
dev->pci, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_TOP,
sizeof(struct cx88_buffer));
- init_MUTEX(&dev->dvbq.lock);
+ init_MUTEX(&dev->dvb.dvbq.lock);
err = dvb_register(dev);
if (0 != err)
@@ -394,7 +222,7 @@ static struct pci_driver dvb_pci_driver = {
.name = "cx88-dvb",
.id_table = cx8802_pci_tbl,
.probe = dvb_probe,
- .remove = dvb_remove,
+ .remove = __devexit_p(dvb_remove),
.suspend = cx8802_suspend_common,
.resume = cx8802_resume_common,
};
@@ -423,5 +251,6 @@ module_exit(dvb_fini);
/*
* Local variables:
* c-basic-offset: 8
+ * compile-command: "make DVB=1"
* End:
*/