[PATCH v1 04/10] media: platform: mediatek: add isp_7x cam-raw unit

CK Hu (胡俊光) ck.hu at mediatek.com
Tue Nov 5 03:01:58 UTC 2024


Hi, Shu-hsiang:

On Wed, 2024-10-09 at 19:15 +0800, Shu-hsiang Yang wrote:
> Introduces the ISP pipeline driver for the MediaTek ISP raw and yuv
> modules. Key functionalities include data processing, V4L2 integration,
> resource management, debug support, and various control operations.
> Additionally, IRQ handling, platform device management, and MediaTek
> ISP DMA format support are also included.
> 
> Signed-off-by: Shu-hsiang Yang <Shu-hsiang.Yang at mediatek.com>
> ---

[snip]

> +static int mtk_raw_of_probe(struct platform_device *pdev,
> +			    struct mtk_raw_device *raw)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct resource *res;
> +	int ret;
> +	int n_clks;
> +
> +	ret = of_property_read_u32(dev->of_node, "mediatek,cam-id", &raw->id);

You don't need raw->id.
I think each raw could work independently.
Each raw has its own 'struct mtk_raw_device' context data.
It's not necessary to know which one it is.
When you use dev_dbg() or dev_err(), it would show register base so you could identify which raw print this message.

Regards,
CK

> +	if (ret) {
> +		dev_dbg(dev, "missing camid property\n");
> +		return ret;
> +	}
> +
> +	if (dma_set_mask_and_coherent(dev, DMA_BIT_MASK(34))) {
> +		dev_err(dev, "%s: No suitable DMA available\n", __func__);
> +		return -EIO;
> +	}
> +
> +	if (!dev->dma_parms) {
> +		dev->dma_parms =
> +			devm_kzalloc(dev, sizeof(*dev->dma_parms), GFP_KERNEL);
> +		if (!dev->dma_parms)
> +			return -ENOMEM;
> +	}
> +
> +	dma_set_max_seg_size(dev, UINT_MAX);
> +
> +	/* base outer register */
> +	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "base");
> +	if (!res) {
> +		dev_err(dev, "failed to get mem\n");
> +		return -ENODEV;
> +	}
> +
> +	raw->base = devm_ioremap_resource(dev, res);
> +	if (IS_ERR(raw->base)) {
> +		dev_err(dev, "failed to map register base\n");
> +		return PTR_ERR(raw->base);
> +	}
> +
> +	/* base inner register */
> +	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "inner_base");
> +	if (!res) {
> +		dev_err(dev, "failed to get mem\n");
> +		return -ENODEV;
> +	}
> +
> +	raw->base_inner = devm_ioremap_resource(dev, res);
> +	if (IS_ERR(raw->base_inner)) {
> +		dev_err(dev, "failed to map register inner base\n");
> +		return PTR_ERR(raw->base_inner);
> +	}
> +
> +	/* will be assigned later */
> +	raw->yuv_base = NULL;
> +
> +	raw->irq = platform_get_irq(pdev, 0);
> +	if (raw->irq < 0) {
> +		dev_err(dev, "failed to get irq\n");
> +		return -ENODEV;
> +	}
> +
> +	ret = devm_request_threaded_irq(dev, raw->irq,
> +					mtk_irq_raw, mtk_thread_irq_raw,
> +					0, dev_name(dev), raw);
> +	if (ret) {
> +		dev_err(dev, "failed to request irq=%d\n", raw->irq);
> +		return ret;
> +	}
> +	dev_dbg(dev, "registered irq=%d\n", raw->irq);
> +
> +	disable_irq(raw->irq);
> +
> +	n_clks = devm_clk_bulk_get_all(dev, &raw->clk_b);
> +	if (n_clks < 0) {
> +		dev_err(dev, "failed to devm_clk_bulk_get_all=%d\n", n_clks);
> +		return n_clks;
> +	}
> +
> +	raw->num_clks = n_clks;
> +	dev_info(dev, "clk_num:%d\n", raw->num_clks);
> +
> +#ifdef CONFIG_PM_SLEEP
> +	raw->pm_notifier.notifier_call = raw_pm_notifier;
> +	ret = register_pm_notifier(&raw->pm_notifier);
> +	if (ret) {
> +		dev_info(dev, "failed to register notifier block.\n");
> +		return ret;
> +	}
> +#endif
> +	return 0;
> +}
> +

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20241105/3627285a/attachment-0001.htm>


More information about the dri-devel mailing list