Пример #1
0
DDE_WEAK int bcm_dma_chan_alloc(unsigned int a, void __iomem **out_dma_base, 
                                int * out_dma_irq) 
{
    int rc = 0;
    resource_size_t DMA_SIZE = SZ_4K;
    void __iomem *dma_base = __arm_ioremap(DMA_BASE, DMA_SIZE, 0);
    *out_dma_base = BCM2708_DMA_CHANIO(dma_base, rc);
    *out_dma_irq = bcm_dma_irqs[rc];
    return rc;

	dde_printf("bcm_dma_chan_alloc not implemented\n");
	return 0;
}
extern int bcm_dma_chan_alloc(unsigned required_feature_set,
			      void __iomem **out_dma_base, int *out_dma_irq)
{
	struct vc_dmaman *dmaman = g_dmaman;
	struct platform_device *pdev = to_platform_device(dmaman_dev);
	struct resource *r;
	int chan;

	if (!dmaman_dev)
		return -ENODEV;

	mutex_lock(&dmaman->lock);
	chan = vc_dmaman_chan_alloc(dmaman, required_feature_set);
	if (chan < 0)
		goto out;

	r = platform_get_resource(pdev, IORESOURCE_IRQ, (unsigned int)chan);
	if (!r) {
		dev_err(dmaman_dev, "failed to get irq for DMA channel %d\n",
			chan);
		vc_dmaman_chan_free(dmaman, chan);
		chan = -ENOENT;
		goto out;
	}

	*out_dma_base = BCM2708_DMA_CHANIO(dmaman->dma_base, chan);
	*out_dma_irq = r->start;
	dev_dbg(dmaman_dev,
		"Legacy API allocated channel=%d, base=%p, irq=%i\n",
		chan, *out_dma_base, *out_dma_irq);

out:
	mutex_unlock(&dmaman->lock);

	return chan;
}