From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Jacopo Mondi <jacopo+renesas@jmondi.org>
Cc: tomi.valkeinen@ideasonboard.com, sakari.ailus@linux.intel.com,
niklas.soderlund@ragnatech.se, kieran.bingham@ideasonboard.com,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil-cisco@xs4all.nl>,
linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH v2 02/13] media: max9286: Implement set_routing
Date: Thu, 16 Dec 2021 14:44:31 +0200 [thread overview]
Message-ID: <Ybs0r4ysfpdfUJda@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20211017182449.64192-3-jacopo+renesas@jmondi.org>
Hi Jacopo,
Thank you for the patch.
On Sun, Oct 17, 2021 at 08:24:38PM +0200, Jacopo Mondi wrote:
> Add the set_routing() subdev operation to allow userspace to configure
> routing on the max9286 deserializer.
>
> Implement route verification but do not take routing into consideration
> when configuring the CSI-2 output and pixel rate yet.
>
> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> ---
> drivers/media/i2c/max9286.c | 88 ++++++++++++++++++++++++++++++++++++-
> 1 file changed, 86 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c
> index 5997fe40509f..54b4067168df 100644
> --- a/drivers/media/i2c/max9286.c
> +++ b/drivers/media/i2c/max9286.c
> @@ -833,6 +833,90 @@ static int max9286_get_fmt(struct v4l2_subdev *sd,
> return 0;
> }
>
> +static int max9286_routing_verify(struct max9286_priv *priv,
> + struct v4l2_subdev_krouting *routing)
> +{
> + unsigned int i;
> + int ret;
> +
> + ret = v4l2_routing_simple_verify(routing);
> + if (ret)
> + return ret;
> +
> + /*
> + * Make sure all routes points to the single source pad which can have
> + * up to 4 streams. All routes shall start from a sink pad and shall not
> + * have more than one sink stream. The GMSL link for the sink has to be
> + * enabled.
> + */
> + for (i = 0; i < routing->num_routes; ++i) {
> + const struct v4l2_subdev_route *route = &routing->routes[i];
> + struct max9286_source *source = &priv->sources[i];
> +
> + if (route->source_pad != MAX9286_SRC_PAD ||
> + route->source_stream > 4) {
> + dev_err(&priv->client->dev,
> + "Invalid (%u,%u) source in route %u\n",
> + route->source_pad, route->source_stream, i);
> + return -EINVAL;
> + }
> +
> + if (route->sink_pad >= MAX9286_N_SINKS ||
> + route->sink_stream != 0) {
> + dev_err(&priv->client->dev,
> + "Invalid (%u,%u) sink in route %u\n",
> + route->sink_pad, route->sink_stream, i);
> + return -EINVAL;
> + }
> +
> + source = &priv->sources[route->sink_pad];
> + if (!source->fwnode) {
> + dev_err(&priv->client->dev,
> + "Cannot set route for non-active source %u\n",
> + route->sink_pad);
> + return -EINVAL;
> + }
> + }
I have a patch on top of muxed streams v10 that will simplify this, I'll
post it shortly and CC you.
> +
> + return 0;
> +}
> +
> +static int _max9286_set_routing(struct v4l2_subdev *sd,
> + struct v4l2_subdev_state *state,
> + struct v4l2_subdev_krouting *routing)
> +{
> + struct max9286_priv *priv = sd_to_max9286(sd);
> + int ret;
> +
> + ret = max9286_routing_verify(priv, routing);
> + if (ret)
> + return ret;
> +
> + /* Re-initialize the format on a routing change. */
> + ret = v4l2_subdev_set_routing_with_fmt(sd, state, routing,
> + &max9286_default_format);
> + if (ret)
> + return ret;
> +
> + return 0;
> +}
> +
> +static int max9286_set_routing(struct v4l2_subdev *sd,
> + struct v4l2_subdev_state *state,
> + enum v4l2_subdev_format_whence which,
> + struct v4l2_subdev_krouting *routing)
> +{
> + struct max9286_priv *priv = sd_to_max9286(sd);
> + unsigned int i;
> + int ret;
> +
> + state = v4l2_subdev_validate_and_lock_state(sd, state);
> + ret = _max9286_set_routing(sd, state, routing);
> + v4l2_subdev_unlock_state(state);
> +
> + return ret;
> +}
> +
> static int max9286_init_cfg(struct v4l2_subdev *sd,
> struct v4l2_subdev_state *state)
> {
> @@ -859,8 +943,7 @@ static int max9286_init_cfg(struct v4l2_subdev *sd,
> routing.routes = routes;
>
> state = v4l2_subdev_validate_and_lock_state(sd, state);
> - ret = v4l2_subdev_set_routing_with_fmt(sd, state, &routing,
> - &max9286_default_format);
> + ret = _max9286_set_routing(sd, state, &routing);
> v4l2_subdev_unlock_state(state);
>
> return ret;
> @@ -875,6 +958,7 @@ static const struct v4l2_subdev_pad_ops max9286_pad_ops = {
> .enum_mbus_code = max9286_enum_mbus_code,
> .get_fmt = max9286_get_fmt,
> .set_fmt = max9286_set_fmt,
> + .set_routing = max9286_set_routing,
> };
>
> static const struct v4l2_subdev_ops max9286_subdev_ops = {
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2021-12-16 12:44 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-17 18:24 [PATCH v2 00/13] media: Add multiplexed support to R-Car CSI-2 and GMSL Jacopo Mondi
2021-10-17 18:24 ` [PATCH v2 01/13] media: max9286: Add support for v4l2_subdev_state Jacopo Mondi
2021-12-16 12:39 ` Laurent Pinchart
2021-10-17 18:24 ` [PATCH v2 02/13] media: max9286: Implement set_routing Jacopo Mondi
2021-12-16 12:44 ` Laurent Pinchart [this message]
2021-10-17 18:24 ` [PATCH v2 03/13] media: max9286: Use enabled routes to calculate pixelrate Jacopo Mondi
2022-01-22 1:33 ` Laurent Pinchart
2021-10-17 18:24 ` [PATCH v2 04/13] media: max9286: Use routes to configure link order Jacopo Mondi
2022-01-22 1:14 ` Laurent Pinchart
2022-01-22 1:23 ` Laurent Pinchart
2022-01-22 1:58 ` Laurent Pinchart
2021-10-17 18:24 ` [PATCH v2 05/13] media: max9286: Move format to subdev state Jacopo Mondi
2021-12-16 12:42 ` Laurent Pinchart
2021-12-16 13:32 ` Laurent Pinchart
2021-10-17 18:24 ` [PATCH v2 06/13] media: subdev: Add for_each_active_route() macro Jacopo Mondi
2021-10-28 8:27 ` Tomi Valkeinen
2021-10-28 8:37 ` Jacopo Mondi
2021-10-28 8:32 ` Tomi Valkeinen
2021-10-28 9:03 ` Jacopo Mondi
2021-10-28 10:17 ` Tomi Valkeinen
2021-10-28 10:18 ` Laurent Pinchart
2021-11-02 14:37 ` Jacopo Mondi
2021-10-17 18:24 ` [PATCH v2 07/13] media: max9286: Implement get_frame_desc() Jacopo Mondi
2022-01-23 14:27 ` Laurent Pinchart
2021-10-17 18:24 ` [PATCH v2 08/13] media: rcar-csi2: Add support for v4l2_subdev_state Jacopo Mondi
2022-01-23 14:11 ` Laurent Pinchart
2022-01-24 8:42 ` Jacopo Mondi
2021-10-17 18:24 ` [PATCH v2 09/13] media: rcar-csi2: Implement set_routing Jacopo Mondi
2022-01-23 14:13 ` Laurent Pinchart
2021-10-17 18:24 ` [PATCH v2 10/13] media: rcar-csi2: Move format to subdev state Jacopo Mondi
2022-01-23 14:19 ` Laurent Pinchart
2022-01-23 14:19 ` Laurent Pinchart
2022-01-23 14:22 ` Laurent Pinchart
2021-10-17 18:24 ` [PATCH v2 11/13] media: rcar-csi2: Config by using the remote frame_desc Jacopo Mondi
2022-01-23 14:23 ` Laurent Pinchart
2021-10-17 18:24 ` [PATCH v2 12/13] media: rcar-csi2: Implement .get_frame_desc() Jacopo Mondi
2021-10-17 18:24 ` [PATCH v2 13/13] media: rcar-vin: Support multiplexed CSI-2 receiver Jacopo Mondi
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=Ybs0r4ysfpdfUJda@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=hverkuil-cisco@xs4all.nl \
--cc=jacopo+renesas@jmondi.org \
--cc=kieran.bingham@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=niklas.soderlund@ragnatech.se \
--cc=sakari.ailus@linux.intel.com \
--cc=tomi.valkeinen@ideasonboard.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).