drivers/media/platform/qcom/venus/firmware.c

Source file repositories/reference/linux-study-clean/drivers/media/platform/qcom/venus/firmware.c

File Facts

System
Linux kernel
Corpus path
drivers/media/platform/qcom/venus/firmware.c
Extension
.c
Size
8859 bytes
Lines
385
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

if (ret) {
			qcom_scm_pas_shutdown(VENUS_PAS_ID);
			dev_err(dev, "set virtual address ranges fail (%d)\n",
				ret);
			return ret;
		}
	}

	return 0;
}

int venus_shutdown(struct venus_core *core)
{
	int ret;

	if (core->use_tz)
		ret = qcom_scm_pas_shutdown(VENUS_PAS_ID);
	else
		ret = venus_shutdown_no_tz(core);

	return ret;
}

int venus_firmware_check(struct venus_core *core)
{
	const struct firmware_version *req = core->res->min_fw;
	const struct firmware_version *run = &core->venus_ver;

	if (!req)
		return 0;

	if (!is_fw_rev_or_newer(core, req->major, req->minor, req->rev))
		goto error;

	return 0;
error:
	dev_err(core->dev, "Firmware v%d.%d.%d < v%d.%d.%d\n",
		run->major, run->minor, run->rev,
		req->major, req->minor, req->rev);

	return -EINVAL;
}

int venus_firmware_init(struct venus_core *core)
{
	struct platform_device_info info;
	struct iommu_domain *iommu_dom;
	struct platform_device *pdev;
	struct device_node *np;
	int ret;

	np = of_get_child_by_name(core->dev->of_node, "video-firmware");
	if (!np) {
		core->use_tz = true;
		return 0;
	}

	memset(&info, 0, sizeof(info));
	info.fwnode = &np->fwnode;
	info.parent = core->dev;
	info.name = np->name;
	info.dma_mask = DMA_BIT_MASK(32);

	pdev = platform_device_register_full(&info);
	if (IS_ERR(pdev)) {
		of_node_put(np);
		return PTR_ERR(pdev);
	}

	pdev->dev.of_node = np;

	ret = of_dma_configure(&pdev->dev, np, true);
	if (ret) {
		dev_err(core->dev, "dma configure fail\n");
		goto err_unregister;
	}

	core->fw.dev = &pdev->dev;

	iommu_dom = iommu_paging_domain_alloc(core->fw.dev);
	if (IS_ERR(iommu_dom)) {
		dev_err(core->fw.dev, "Failed to allocate iommu domain\n");
		ret = PTR_ERR(iommu_dom);
		goto err_unregister;
	}

	ret = iommu_attach_device(iommu_dom, core->fw.dev);
	if (ret) {
		dev_err(core->fw.dev, "could not attach device\n");
		goto err_iommu_free;

Annotation

Implementation Notes