[v5,3/3] drm/mediatek: Implement OF graphs support for display paths
Sui Jingfeng
suijingfeng at bosc.ac.cn
Wed May 22 05:13:34 PDT 2024
Hi,
On 5/21/24 15:57, AngeloGioacchino Del Regno wrote:
> +static int mtk_drm_of_get_ddp_comp_type(struct device_node *node, enum mtk_ddp_comp_type *ctype)
> +{
> + const struct of_device_id *of_id = of_match_node(mtk_ddp_comp_dt_ids, node);
> +
> + if (!of_id)
> + return -EINVAL;
> +
> + *ctype = (enum mtk_ddp_comp_type)((uintptr_t)of_id->data);
> +
> + return 0;
> +}
> +
> +static int mtk_drm_of_get_ddp_ep_cid(struct device_node *node,
> + int output_port, enum mtk_crtc_path crtc_path,
> + struct device_node **next, unsigned int *cid)
> +{
> + struct device_node *ep_dev_node, *ep_out;
> + enum mtk_ddp_comp_type comp_type;
> + int ret;
> +
> + ep_out = of_graph_get_endpoint_by_regs(node, output_port, crtc_path);
> + if (!ep_out)
> + return -ENOENT;
> +
> + ep_dev_node = of_graph_get_remote_port_parent(ep_out);
below here, 'ep_out' will not be used anymore.
of_node_put(ep_out);
Maybe we should call it under a error handling tag?
But this is trivial problem.
> + if (!ep_dev_node)
> + return -EINVAL;
> +
> + /*
> + * Pass the next node pointer regardless of failures in the later code
> + * so that if this function is called in a loop it will walk through all
> + * of the subsequent endpoints anyway.
> + */
> + *next = ep_dev_node;
> +
> + if (!of_device_is_available(ep_dev_node))
> + return -ENODEV;
> +
> + ret = mtk_drm_of_get_ddp_comp_type(ep_dev_node, &comp_type);
> + if (ret) {
> + if (mtk_ovl_adaptor_is_comp_present(ep_dev_node)) {
> + *cid = (unsigned int)DDP_COMPONENT_DRM_OVL_ADAPTOR;
> + return 0;
> + }
> + return ret;
> + }
> +
> + ret = mtk_ddp_comp_get_id(ep_dev_node, comp_type);
> + if (ret < 0)
> + return ret;
> +
> + /* All ok! Pass the Component ID to the caller. */
> + *cid = (unsigned int)ret;
> +
> + return 0;
> +}
> +
--
Best regards
Sui Jingfeng
More information about the linux-arm-kernel
mailing list