From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Steve Longerbeam <slongerbeam@gmail.com>
Cc: linux-media@vger.kernel.org,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
Hans Verkuil <hverkuil-cisco@xs4all.nl>,
Rui Miguel Silva <rmfrfs@gmail.com>,
Philipp Zabel <p.zabel@pengutronix.de>
Subject: Re: [PATCH v4 15/17] media: imx: Create missing links from CSI-2 receiver
Date: Wed, 15 Apr 2020 02:32:05 +0300 [thread overview]
Message-ID: <20200414233205.GD28533@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20200303234256.8928-16-slongerbeam@gmail.com>
Hi Steve,
Thank you for the patch.
On Tue, Mar 03, 2020 at 03:42:54PM -0800, Steve Longerbeam wrote:
> The entities external to the i.MX6 IPU and i.MX7 now create the links
> to their fwnode-endpoint connected entities in their notifier bound
> callbacks. Which means imx_media_create_of_links() and
> imx_media_create_csi_of_links() are no longer needed and are removed.
>
> However there is still one case in which imx-media needs to create
> fwnode-endpoint based links at probe completion. The v4l2-async framework
> does not allow multiple subdevice notifiers to contain a duplicate
> subdevice in their asd_list. Only the first subdev notifier that discovers
> and adds that one subdevice to its asd_list will receive a bound callback
> for it. Other subdevices that also have firmware endpoint connections to
> this duplicate subdevice will not have it in their asd_list, and thus will
> never receive a bound callback for it. In the case of imx-media, the one
> duplicate subdevice in question is the i.MX6 MIPI CSI-2 receiver.
>
> Until there is a solution to that problem, rewrite imx_media_create_links()
> to add the missing links from the CSI-2 receiver to the CSIs and CSI muxes.
> The function is renamed imx_media_create_csi2_links().
>
> Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
> ---
> Changes in v3:
> - call a local imx-media utility imx_media_create_fwnode_pad_links().
> Changes in v2:
> - this is a rewrite of v1 "media: imx: Use media_create_fwnode_links for
> external links", which only adds the missing CSI-2 receiver links.
> ---
> .../staging/media/imx/imx-media-dev-common.c | 46 +++----
> drivers/staging/media/imx/imx-media-of.c | 114 ------------------
> drivers/staging/media/imx/imx-media.h | 4 -
> 3 files changed, 17 insertions(+), 147 deletions(-)
>
> diff --git a/drivers/staging/media/imx/imx-media-dev-common.c b/drivers/staging/media/imx/imx-media-dev-common.c
> index 66b505f7e8df..f7ad3cbbeec2 100644
> --- a/drivers/staging/media/imx/imx-media-dev-common.c
> +++ b/drivers/staging/media/imx/imx-media-dev-common.c
> @@ -30,41 +30,31 @@ static int imx_media_subdev_bound(struct v4l2_async_notifier *notifier,
> }
>
> /*
> - * Create the media links for all subdevs that registered.
> + * Create the missing media links from the CSI-2 receiver.
> * Called after all async subdevs have bound.
> */
> -static int imx_media_create_links(struct v4l2_async_notifier *notifier)
> +static void imx_media_create_csi2_links(struct imx_media_dev *imxmd)
> {
> - struct imx_media_dev *imxmd = notifier2dev(notifier);
> - struct v4l2_subdev *sd;
> + struct v4l2_subdev *sd, *csi2 = NULL;
>
> list_for_each_entry(sd, &imxmd->v4l2_dev.subdevs, list) {
> - switch (sd->grp_id) {
> - case IMX_MEDIA_GRP_ID_IPU_VDIC:
> - case IMX_MEDIA_GRP_ID_IPU_IC_PRP:
> - case IMX_MEDIA_GRP_ID_IPU_IC_PRPENC:
> - case IMX_MEDIA_GRP_ID_IPU_IC_PRPVF:
> - /*
> - * links have already been created for the
> - * sync-registered subdevs.
> - */
> - break;
> - case IMX_MEDIA_GRP_ID_IPU_CSI0:
> - case IMX_MEDIA_GRP_ID_IPU_CSI1:
> - case IMX_MEDIA_GRP_ID_CSI:
> - imx_media_create_csi_of_links(imxmd, sd);
> - break;
> - default:
> - /*
> - * if this subdev has fwnode links, create media
> - * links for them.
> - */
> - imx_media_create_of_links(imxmd, sd);
> + if (sd->grp_id == IMX_MEDIA_GRP_ID_CSI2) {
> + csi2 = sd;
> break;
> }
> }
> + if (!csi2)
> + return;
>
> - return 0;
> + list_for_each_entry(sd, &imxmd->v4l2_dev.subdevs, list) {
> + /* skip if not a CSI or a video mux */
> + if (!(sd->grp_id & IMX_MEDIA_GRP_ID_IPU_CSI) &&
> + !(sd->grp_id & IMX_MEDIA_GRP_ID_CSI) &&
> + sd->entity.function != MEDIA_ENT_F_VID_MUX)
This is a bit dangerous, as the external source connected to the CSI-2
receiver could be a video mux. How about assigning a group id to the
internal mux, as done in the "[PATCH 2/2] media: staging/imx: Don't
create links between external entities" patch that I've posted, and
checking the group id here ?
With that fixed,
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> + continue;
> +
> + imx_media_create_fwnode_pad_links(csi2, sd);
> + }
> }
>
> /*
> @@ -196,9 +186,7 @@ int imx_media_probe_complete(struct v4l2_async_notifier *notifier)
>
> mutex_lock(&imxmd->mutex);
>
> - ret = imx_media_create_links(notifier);
> - if (ret)
> - goto unlock;
> + imx_media_create_csi2_links(imxmd);
>
> ret = imx_media_create_pad_vdev_lists(imxmd);
> if (ret)
> diff --git a/drivers/staging/media/imx/imx-media-of.c b/drivers/staging/media/imx/imx-media-of.c
> index 2d3efd2a6dde..82e13e972e23 100644
> --- a/drivers/staging/media/imx/imx-media-of.c
> +++ b/drivers/staging/media/imx/imx-media-of.c
> @@ -74,117 +74,3 @@ int imx_media_add_of_subdevs(struct imx_media_dev *imxmd,
> return ret;
> }
> EXPORT_SYMBOL_GPL(imx_media_add_of_subdevs);
> -
> -/*
> - * Create a single media link to/from sd using a fwnode link.
> - *
> - * NOTE: this function assumes an OF port node is equivalent to
> - * a media pad (port id equal to media pad index), and that an
> - * OF endpoint node is equivalent to a media link.
> - */
> -static int create_of_link(struct imx_media_dev *imxmd,
> - struct v4l2_subdev *sd,
> - struct v4l2_fwnode_link *link)
> -{
> - struct v4l2_subdev *remote, *src, *sink;
> - int src_pad, sink_pad;
> -
> - if (link->local_port >= sd->entity.num_pads)
> - return -EINVAL;
> -
> - remote = imx_media_find_subdev_by_fwnode(imxmd, link->remote_node);
> - if (!remote)
> - return 0;
> -
> - if (sd->entity.pads[link->local_port].flags & MEDIA_PAD_FL_SINK) {
> - src = remote;
> - src_pad = link->remote_port;
> - sink = sd;
> - sink_pad = link->local_port;
> - } else {
> - src = sd;
> - src_pad = link->local_port;
> - sink = remote;
> - sink_pad = link->remote_port;
> - }
> -
> - /* make sure link doesn't already exist before creating */
> - if (media_entity_find_link(&src->entity.pads[src_pad],
> - &sink->entity.pads[sink_pad]))
> - return 0;
> -
> - v4l2_info(sd->v4l2_dev, "%s:%d -> %s:%d\n",
> - src->name, src_pad, sink->name, sink_pad);
> -
> - return media_create_pad_link(&src->entity, src_pad,
> - &sink->entity, sink_pad, 0);
> -}
> -
> -/*
> - * Create media links to/from sd using its device-tree endpoints.
> - */
> -int imx_media_create_of_links(struct imx_media_dev *imxmd,
> - struct v4l2_subdev *sd)
> -{
> - struct v4l2_fwnode_link link;
> - struct device_node *ep;
> - int ret;
> -
> - for_each_endpoint_of_node(sd->dev->of_node, ep) {
> - ret = v4l2_fwnode_parse_link(of_fwnode_handle(ep), &link);
> - if (ret)
> - continue;
> -
> - ret = create_of_link(imxmd, sd, &link);
> - v4l2_fwnode_put_link(&link);
> - if (ret)
> - return ret;
> - }
> -
> - return 0;
> -}
> -EXPORT_SYMBOL_GPL(imx_media_create_of_links);
> -
> -/*
> - * Create media links to the given CSI subdevice's sink pads,
> - * using its device-tree endpoints.
> - */
> -int imx_media_create_csi_of_links(struct imx_media_dev *imxmd,
> - struct v4l2_subdev *csi)
> -{
> - struct device_node *csi_np = csi->dev->of_node;
> - struct device_node *ep;
> -
> - for_each_child_of_node(csi_np, ep) {
> - struct fwnode_handle *fwnode, *csi_ep;
> - struct v4l2_fwnode_link link;
> - int ret;
> -
> - memset(&link, 0, sizeof(link));
> -
> - link.local_node = of_fwnode_handle(csi_np);
> - link.local_port = CSI_SINK_PAD;
> -
> - csi_ep = of_fwnode_handle(ep);
> -
> - fwnode = fwnode_graph_get_remote_endpoint(csi_ep);
> - if (!fwnode)
> - continue;
> -
> - fwnode = fwnode_get_parent(fwnode);
> - fwnode_property_read_u32(fwnode, "reg", &link.remote_port);
> - fwnode = fwnode_get_next_parent(fwnode);
> - if (is_of_node(fwnode) &&
> - of_node_name_eq(to_of_node(fwnode), "ports"))
> - fwnode = fwnode_get_next_parent(fwnode);
> - link.remote_node = fwnode;
> -
> - ret = create_of_link(imxmd, csi, &link);
> - fwnode_handle_put(link.remote_node);
> - if (ret)
> - return ret;
> - }
> -
> - return 0;
> -}
> -EXPORT_SYMBOL_GPL(imx_media_create_csi_of_links);
> diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h
> index 5f23d852122f..5271b84bea9a 100644
> --- a/drivers/staging/media/imx/imx-media.h
> +++ b/drivers/staging/media/imx/imx-media.h
> @@ -248,10 +248,6 @@ void imx_media_unregister_ipu_internal_subdevs(struct imx_media_dev *imxmd);
> /* imx-media-of.c */
> int imx_media_add_of_subdevs(struct imx_media_dev *dev,
> struct device_node *np);
> -int imx_media_create_of_links(struct imx_media_dev *imxmd,
> - struct v4l2_subdev *sd);
> -int imx_media_create_csi_of_links(struct imx_media_dev *imxmd,
> - struct v4l2_subdev *csi);
> int imx_media_of_add_csi(struct imx_media_dev *imxmd,
> struct device_node *csi_np);
>
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2020-04-14 23:32 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-03 23:42 [PATCH v4 00/17] media: imx: Create media links in bound notifiers Steve Longerbeam
2020-03-03 23:42 ` [PATCH v4 01/17] media: entity: Pass entity to get_fwnode_pad operation Steve Longerbeam
2020-04-14 22:58 ` Laurent Pinchart
2020-03-03 23:42 ` [PATCH v4 02/17] media: video-mux: Parse information from firmware without using callbacks Steve Longerbeam
2020-03-03 23:42 ` [PATCH v4 03/17] media: imx: " Steve Longerbeam
2020-03-03 23:42 ` [PATCH v4 04/17] Revert "media: v4l2-fwnode: Add a convenience function for registering subdevs with notifiers" Steve Longerbeam
2020-03-03 23:42 ` [PATCH v4 05/17] media: imx: csi: Implement get_fwnode_pad op Steve Longerbeam
2020-04-14 23:02 ` Laurent Pinchart
2020-03-03 23:42 ` [PATCH v4 06/17] media: imx: mipi csi-2: " Steve Longerbeam
2020-04-14 23:07 ` Laurent Pinchart
2020-04-14 23:20 ` Sakari Ailus
2020-04-14 23:27 ` Laurent Pinchart
2020-04-14 23:56 ` Sakari Ailus
2020-04-14 23:50 ` Steve Longerbeam
2020-04-15 0:43 ` Laurent Pinchart
2020-04-14 23:29 ` Steve Longerbeam
2020-03-03 23:42 ` [PATCH v4 07/17] media: video-mux: " Steve Longerbeam
2020-04-14 23:08 ` Laurent Pinchart
2020-04-15 0:17 ` Steve Longerbeam
2020-03-03 23:42 ` [PATCH v4 08/17] media: imx: Add imx_media_create_fwnode_pad_link() Steve Longerbeam
2020-04-14 23:21 ` Laurent Pinchart
2020-03-03 23:42 ` [PATCH v4 09/17] media: video-mux: Create media links in bound notifier Steve Longerbeam
2020-04-14 23:16 ` Laurent Pinchart
2020-04-14 23:47 ` Steve Longerbeam
2020-04-18 0:56 ` Steve Longerbeam
2020-03-03 23:42 ` [PATCH v4 10/17] media: imx: mipi csi-2: " Steve Longerbeam
2020-03-03 23:42 ` [PATCH v4 11/17] media: imx7: mipi csis: " Steve Longerbeam
2020-03-03 23:42 ` [PATCH v4 12/17] media: imx7: csi: " Steve Longerbeam
2020-03-03 23:42 ` [PATCH v4 13/17] media: imx: " Steve Longerbeam
2020-03-03 23:42 ` [PATCH v4 14/17] media: imx: csi: Lookup upstream endpoint with imx_media_get_pad_fwnode Steve Longerbeam
2020-04-14 23:24 ` Laurent Pinchart
2020-03-03 23:42 ` [PATCH v4 15/17] media: imx: Create missing links from CSI-2 receiver Steve Longerbeam
2020-04-14 23:32 ` Laurent Pinchart [this message]
2020-04-15 0:10 ` Steve Longerbeam
2020-03-03 23:42 ` [PATCH v4 16/17] media: imx: silence a couple debug messages Steve Longerbeam
2020-04-14 23:33 ` Laurent Pinchart
2020-03-03 23:42 ` [PATCH v4 17/17] media: imx: TODO: Remove media link creation todos Steve Longerbeam
2020-03-25 18:09 ` [PATCH v4 00/17] media: imx: Create media links in bound notifiers Steve Longerbeam
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200414233205.GD28533@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=hverkuil-cisco@xs4all.nl \
--cc=linux-media@vger.kernel.org \
--cc=mchehab+huawei@kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=rmfrfs@gmail.com \
--cc=sakari.ailus@linux.intel.com \
--cc=slongerbeam@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.