drivers/media/pci/mgb4/mgb4_dma.c

Source file repositories/reference/linux-study-clean/drivers/media/pci/mgb4/mgb4_dma.c

File Facts

System
Linux kernel
Corpus path
drivers/media/pci/mgb4/mgb4_dma.c
Extension
.c
Size
3061 bytes
Lines
124
Domain
Driver Families
Bucket
drivers/media
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

msecs_to_jiffies(10000))) {
		dev_err(&pdev->dev, "dma timeout\n");
		dmaengine_terminate_sync(chan->chan);
		return -EIO;
	}

	return 0;
}

int mgb4_dma_channel_init(struct mgb4_dev *mgbdev)
{
	int i, ret;
	char name[16];
	struct pci_dev *pdev = mgbdev->pdev;

	for (i = 0; i < MGB4_VIN_DEVICES; i++) {
		sprintf(name, "c2h%d", i);
		mgbdev->c2h_chan[i].chan = dma_request_chan(&pdev->dev, name);
		if (IS_ERR(mgbdev->c2h_chan[i].chan)) {
			dev_err(&pdev->dev, "failed to initialize %s", name);
			ret = PTR_ERR(mgbdev->c2h_chan[i].chan);
			mgbdev->c2h_chan[i].chan = NULL;
			return ret;
		}
		init_completion(&mgbdev->c2h_chan[i].req_compl);
	}
	for (i = 0; i < MGB4_VOUT_DEVICES; i++) {
		sprintf(name, "h2c%d", i);
		mgbdev->h2c_chan[i].chan = dma_request_chan(&pdev->dev, name);
		if (IS_ERR(mgbdev->h2c_chan[i].chan)) {
			dev_err(&pdev->dev, "failed to initialize %s", name);
			ret = PTR_ERR(mgbdev->h2c_chan[i].chan);
			mgbdev->h2c_chan[i].chan = NULL;
			return ret;
		}
		init_completion(&mgbdev->h2c_chan[i].req_compl);
	}

	return 0;
}

void mgb4_dma_channel_free(struct mgb4_dev *mgbdev)
{
	int i;

	for (i = 0; i < MGB4_VIN_DEVICES; i++) {
		if (mgbdev->c2h_chan[i].chan)
			dma_release_channel(mgbdev->c2h_chan[i].chan);
	}
	for (i = 0; i < MGB4_VOUT_DEVICES; i++) {
		if (mgbdev->h2c_chan[i].chan)
			dma_release_channel(mgbdev->h2c_chan[i].chan);
	}
}

Annotation

Implementation Notes