⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cx88-mpeg.c

📁 V4l driver for DVB HD
💻 C
📖 第 1 页 / 共 2 页
字号:
		buf->vb.state = STATE_ERROR;		wake_up(&buf->vb.done);		dprintk(1,"[%p/%d] %s - dma=0x%08lx\n",			buf, buf->vb.i, reason, (unsigned long)buf->risc.dma);	}	if (restart)	{		dprintk(1, "restarting queue\n" );		cx8802_restart_queue(dev,q);	}	spin_unlock_irqrestore(&dev->slock,flags);}void cx8802_cancel_buffers(struct cx8802_dev *dev){	struct cx88_dmaqueue *q = &dev->mpegq;	dprintk( 1, "cx8802_cancel_buffers" );	del_timer_sync(&q->timeout);	cx8802_stop_dma(dev);	do_cancel_buffers(dev,"cancel",0);}static void cx8802_timeout(unsigned long data){	struct cx8802_dev *dev = (struct cx8802_dev*)data;	dprintk(0, "%s\n",__FUNCTION__);	if (debug)		cx88_sram_channel_dump(dev->core, &cx88_sram_channels[SRAM_CH28]);	cx8802_stop_dma(dev);	do_cancel_buffers(dev,"timeout",1);}static char *cx88_mpeg_irqs[32] = {	"ts_risci1", NULL, NULL, NULL,	"ts_risci2", NULL, NULL, NULL,	"ts_oflow",  NULL, NULL, NULL,	"ts_sync",   NULL, NULL, NULL,	"opc_err", "par_err", "rip_err", "pci_abort",	"ts_err?",};static void cx8802_mpeg_irq(struct cx8802_dev *dev){	struct cx88_core *core = dev->core;	u32 status, mask, count;	dprintk( 1, "cx8802_mpeg_irq\n" );	status = cx_read(MO_TS_INTSTAT);	mask   = cx_read(MO_TS_INTMSK);	if (0 == (status & mask))		return;	cx_write(MO_TS_INTSTAT, status);	if (debug || (status & mask & ~0xff))		cx88_print_irqbits(core->name, "irq mpeg ",				   cx88_mpeg_irqs, status, mask);	/* risc op code error */	if (status & (1 << 16)) {		printk(KERN_WARNING "%s: mpeg risc op code error\n",core->name);		cx_clear(MO_TS_DMACNTRL, 0x11);		cx88_sram_channel_dump(dev->core, &cx88_sram_channels[SRAM_CH28]);	}	/* risc1 y */	if (status & 0x01) {		dprintk( 1, "wake up\n" );		spin_lock(&dev->slock);		count = cx_read(MO_TS_GPCNT);		cx88_wakeup(dev->core, &dev->mpegq, count);		spin_unlock(&dev->slock);	}	/* risc2 y */	if (status & 0x10) {		spin_lock(&dev->slock);		cx8802_restart_queue(dev,&dev->mpegq);		spin_unlock(&dev->slock);	}	/* other general errors */	if (status & 0x1f0100) {		dprintk( 0, "general errors: 0x%08x\n", status & 0x1f0100 );		spin_lock(&dev->slock);		cx8802_stop_dma(dev);		cx8802_restart_queue(dev,&dev->mpegq);		spin_unlock(&dev->slock);	}}#define MAX_IRQ_LOOP 10static irqreturn_t cx8802_irq(int irq, void *dev_id, struct pt_regs *regs){	struct cx8802_dev *dev = dev_id;	struct cx88_core *core = dev->core;	u32 status;	int loop, handled = 0;	for (loop = 0; loop < MAX_IRQ_LOOP; loop++) {		status = cx_read(MO_PCI_INTSTAT) & (core->pci_irqmask | 0x04);		if (0 == status)			goto out;		dprintk( 1, "cx8802_irq\n" );		dprintk( 1, "    loop: %d/%d\n", loop, MAX_IRQ_LOOP );		dprintk( 1, "    status: %d\n", status );		handled = 1;		cx_write(MO_PCI_INTSTAT, status);		if (status & core->pci_irqmask)			cx88_core_irq(core,status);		if (status & 0x04)			cx8802_mpeg_irq(dev);	};	if (MAX_IRQ_LOOP == loop) {		dprintk( 0, "clearing mask\n" );		printk(KERN_WARNING "%s/0: irq loop -- clearing mask\n",		       core->name);		cx_write(MO_PCI_INTMSK,0);	} out:	return IRQ_RETVAL(handled);}/* ----------------------------------------------------------- *//* exported stuff                                              */int cx8802_init_common(struct cx8802_dev *dev){	struct cx88_core *core = dev->core;	int err;	/* pci init */	if (pci_enable_device(dev->pci))		return -EIO;	pci_set_master(dev->pci);	if (!pci_dma_supported(dev->pci,0xffffffff)) {		printk("%s/2: Oops: no 32bit PCI DMA ???\n",dev->core->name);		return -EIO;	}	pci_read_config_byte(dev->pci, PCI_CLASS_REVISION, &dev->pci_rev);	pci_read_config_byte(dev->pci, PCI_LATENCY_TIMER,  &dev->pci_lat);	printk(KERN_INFO "%s/2: found at %s, rev: %d, irq: %d, "	       "latency: %d, mmio: 0x%lx\n", dev->core->name,	       pci_name(dev->pci), dev->pci_rev, dev->pci->irq,	       dev->pci_lat,pci_resource_start(dev->pci,0));	/* initialize driver struct */#if 0	/* moved to cx88_core_get */	init_MUTEX(&core->lock);#endif	spin_lock_init(&dev->slock);	/* init dma queue */	INIT_LIST_HEAD(&dev->mpegq.active);	INIT_LIST_HEAD(&dev->mpegq.queued);	dev->mpegq.timeout.function = cx8802_timeout;	dev->mpegq.timeout.data     = (unsigned long)dev;	init_timer(&dev->mpegq.timeout);	cx88_risc_stopper(dev->pci,&dev->mpegq.stopper,			  MO_TS_DMACNTRL,0x11,0x00);	/* get irq */	err = request_irq(dev->pci->irq, cx8802_irq,			  SA_SHIRQ | SA_INTERRUPT, dev->core->name, dev);	if (err < 0) {		printk(KERN_ERR "%s: can't get IRQ %d\n",		       dev->core->name, dev->pci->irq);		return err;	}	cx_set(MO_PCI_INTMSK, core->pci_irqmask);	/* everything worked */	pci_set_drvdata(dev->pci,dev);	return 0;}void cx8802_fini_common(struct cx8802_dev *dev){	dprintk( 2, "cx8802_fini_common\n" );	cx8802_stop_dma(dev);	pci_disable_device(dev->pci);	/* unregister stuff */	free_irq(dev->pci->irq, dev);	pci_set_drvdata(dev->pci, NULL);	/* free memory */	btcx_riscmem_free(dev->pci,&dev->mpegq.stopper);}/* ----------------------------------------------------------- */int cx8802_suspend_common(struct pci_dev *pci_dev, pm_message_t state){	struct cx8802_dev *dev = pci_get_drvdata(pci_dev);	struct cx88_core *core = dev->core;	/* stop mpeg dma */	spin_lock(&dev->slock);	if (!list_empty(&dev->mpegq.active)) {		dprintk( 2, "suspend\n" );		printk("%s: suspend mpeg\n", core->name);		cx8802_stop_dma(dev);		del_timer(&dev->mpegq.timeout);	}	spin_unlock(&dev->slock);#if 1	/* FIXME -- shutdown device */	cx88_shutdown(dev->core);#endif#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)	pci_save_state(pci_dev, dev->state.pci_cfg);#else	pci_save_state(pci_dev);#endif	if (0 != pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state))) {		pci_disable_device(pci_dev);		dev->state.disabled = 1;	}	return 0;}int cx8802_resume_common(struct pci_dev *pci_dev){	struct cx8802_dev *dev = pci_get_drvdata(pci_dev);	struct cx88_core *core = dev->core;	int err;	if (dev->state.disabled) {		err=pci_enable_device(pci_dev);		if (err) {			printk(KERN_ERR "%s: can't enable device\n",					       dev->core->name);			return err;		}		dev->state.disabled = 0;	}	err=pci_set_power_state(pci_dev, PCI_D0);	if (err) {		printk(KERN_ERR "%s: can't enable device\n",					       dev->core->name);		pci_disable_device(pci_dev);		dev->state.disabled = 1;		return err;	}#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)	pci_restore_state(pci_dev, dev->state.pci_cfg);#else	pci_restore_state(pci_dev);#endif#if 1	/* FIXME: re-initialize hardware */	cx88_reset(dev->core);#endif	/* restart video+vbi capture */	spin_lock(&dev->slock);	if (!list_empty(&dev->mpegq.active)) {		printk("%s: resume mpeg\n", core->name);		cx8802_restart_queue(dev,&dev->mpegq);	}	spin_unlock(&dev->slock);	return 0;}/* ----------------------------------------------------------- */EXPORT_SYMBOL(cx8802_buf_prepare);EXPORT_SYMBOL(cx8802_buf_queue);EXPORT_SYMBOL(cx8802_cancel_buffers);EXPORT_SYMBOL(cx8802_init_common);EXPORT_SYMBOL(cx8802_fini_common);EXPORT_SYMBOL(cx8802_suspend_common);EXPORT_SYMBOL(cx8802_resume_common);/* ----------------------------------------------------------- *//* * Local variables: * c-basic-offset: 8 * End: * kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -