All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dafna Hirschfeld <dafna@fastmail.com>
To: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Cc: linux-media@vger.kernel.org, sakari.ailus@linux.intel.com,
	Jacopo Mondi <jacopo+renesas@jmondi.org>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	niklas.soderlund+renesas@ragnatech.se,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	Kishon Vijay Abraham <kishon@ti.com>,
	satish.nagireddy@getcruise.com, Tomasz Figa <tfiga@chromium.org>,
	Jacopo Mondi <jacopo@jmondi.org>
Subject: Re: [PATCH v15 12/19] media: subdev: add "opposite" stream helper funcs
Date: Sun, 9 Oct 2022 10:06:14 +0300	[thread overview]
Message-ID: <20221009070614.rud3yx6acsxwt6kl@guri> (raw)
In-Reply-To: <20221003121852.616745-13-tomi.valkeinen@ideasonboard.com>

On 03.10.2022 15:18, Tomi Valkeinen wrote:
>Add two helper functions to make dealing with streams easier:
>
>v4l2_subdev_routing_find_opposite_end - given a routing table and a pad
>+ stream, return the pad + stream on the opposite side of the subdev.
>
>v4l2_subdev_state_get_opposite_stream_format - return a pointer to the
>format on the pad + stream on the opposite side from the given pad +
>stream.
>
>Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
>Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
>Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
>---
> drivers/media/v4l2-core/v4l2-subdev.c | 49 +++++++++++++++++++++++++++
> include/media/v4l2-subdev.h           | 36 ++++++++++++++++++++
> 2 files changed, 85 insertions(+)
>
>diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
>index 1cea6ec750c0..7d2d8e8d3aea 100644
>--- a/drivers/media/v4l2-core/v4l2-subdev.c
>+++ b/drivers/media/v4l2-core/v4l2-subdev.c
>@@ -1514,6 +1514,55 @@ v4l2_subdev_state_get_stream_compose(struct v4l2_subdev_state *state,
> }
> EXPORT_SYMBOL_GPL(v4l2_subdev_state_get_stream_compose);
>
>+int v4l2_subdev_routing_find_opposite_end(const struct v4l2_subdev_krouting *routing,
>+					  u32 pad, u32 stream, u32 *other_pad,
>+					  u32 *other_stream)
>+{
>+	unsigned int i;
>+
>+	for (i = 0; i < routing->num_routes; ++i) {
>+		struct v4l2_subdev_route *route = &routing->routes[i];
>+
>+		if (route->source_pad == pad &&
>+		    route->source_stream == stream) {
>+			if (other_pad)
>+				*other_pad = route->sink_pad;
>+			if (other_stream)
>+				*other_stream = route->sink_stream;
>+			return 0;
>+		}
>+
>+		if (route->sink_pad == pad && route->sink_stream == stream) {

Hi, I think here you should also check that the FL_SOURCE flag is not set to make sure
that sink_pad/stream are used

Thanks,
Dafna

>+			if (other_pad)
>+				*other_pad = route->source_pad;
>+			if (other_stream)
>+				*other_stream = route->source_stream;
>+			return 0;
>+		}
>+	}
>+
>+	return -EINVAL;
>+}
>+EXPORT_SYMBOL_GPL(v4l2_subdev_routing_find_opposite_end);
>+
>+struct v4l2_mbus_framefmt *
>+v4l2_subdev_state_get_opposite_stream_format(struct v4l2_subdev_state *state,
>+					     u32 pad, u32 stream)
>+{
>+	u32 other_pad, other_stream;
>+	int ret;
>+
>+	ret = v4l2_subdev_routing_find_opposite_end(&state->routing,
>+						    pad, stream,
>+						    &other_pad, &other_stream);
>+	if (ret)
>+		return NULL;
>+
>+	return v4l2_subdev_state_get_stream_format(state, other_pad,
>+						   other_stream);
>+}
>+EXPORT_SYMBOL_GPL(v4l2_subdev_state_get_opposite_stream_format);
>+
> #endif /* CONFIG_VIDEO_V4L2_SUBDEV_API */
>
> #endif /* CONFIG_MEDIA_CONTROLLER */
>diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
>index d6273ad2eea8..6f4719e28ad1 100644
>--- a/include/media/v4l2-subdev.h
>+++ b/include/media/v4l2-subdev.h
>@@ -1527,6 +1527,42 @@ struct v4l2_rect *
> v4l2_subdev_state_get_stream_compose(struct v4l2_subdev_state *state,
> 				     unsigned int pad, u32 stream);
>
>+/**
>+ * v4l2_subdev_routing_find_opposite_end() - Find the opposite stream
>+ * @routing: routing used to find the opposite side
>+ * @pad: pad id
>+ * @stream: stream id
>+ * @other_pad: pointer used to return the opposite pad
>+ * @other_stream: pointer used to return the opposite stream
>+ *
>+ * This function uses the routing table to find the pad + stream which is
>+ * opposite the given pad + stream.
>+ *
>+ * @other_pad and/or @other_stream can be NULL if the caller does not need the
>+ * value.
>+ *
>+ * Returns 0 on success, or -EINVAL if no matching route is found.
>+ */
>+int v4l2_subdev_routing_find_opposite_end(const struct v4l2_subdev_krouting *routing,
>+					  u32 pad, u32 stream, u32 *other_pad,
>+					  u32 *other_stream);
>+
>+/**
>+ * v4l2_subdev_state_get_opposite_stream_format() - Get pointer to opposite
>+ *                                                  stream format
>+ * @state: subdevice state
>+ * @pad: pad id
>+ * @stream: stream id
>+ *
>+ * This returns a pointer to &struct v4l2_mbus_framefmt for the pad + stream
>+ * that is opposite the given pad + stream in the subdev state.
>+ *
>+ * If the state does not contain the given pad + stream, NULL is returned.
>+ */
>+struct v4l2_mbus_framefmt *
>+v4l2_subdev_state_get_opposite_stream_format(struct v4l2_subdev_state *state,
>+					     u32 pad, u32 stream);
>+
> #endif /* CONFIG_VIDEO_V4L2_SUBDEV_API */
>
> #endif /* CONFIG_MEDIA_CONTROLLER */
>-- 
>2.34.1
>

  reply	other threads:[~2022-10-09  7:06 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-03 12:18 [PATCH v15 00/19] v4l: routing and streams support Tomi Valkeinen
2022-10-03 12:18 ` [PATCH v15 01/19] media: v4l2-subdev: Sort includes Tomi Valkeinen
2022-10-03 16:53   ` Laurent Pinchart
2022-10-03 12:18 ` [PATCH v15 02/19] media: add V4L2_SUBDEV_FL_STREAMS Tomi Valkeinen
2022-10-03 12:18 ` [PATCH v15 03/19] media: add V4L2_SUBDEV_CAP_STREAMS Tomi Valkeinen
2022-10-03 12:18 ` [PATCH v15 04/19] media: Documentation: Add GS_ROUTING documentation Tomi Valkeinen
2022-10-03 14:31   ` Hans Verkuil
2022-10-12 10:01     ` Tomi Valkeinen
2022-10-03 12:18 ` [PATCH v15 05/19] media: subdev: Add [GS]_ROUTING subdev ioctls and operations Tomi Valkeinen
2022-10-03 14:26   ` Hans Verkuil
2022-10-03 22:01     ` Sakari Ailus
2022-10-04  8:43       ` Hans Verkuil
2022-10-04 10:05         ` Sakari Ailus
2022-10-12  8:15           ` Tomi Valkeinen
2022-10-03 12:18 ` [PATCH v15 06/19] media: subdev: add v4l2_subdev_has_pad_interdep() Tomi Valkeinen
2022-10-03 12:18 ` [PATCH v15 07/19] media: subdev: add v4l2_subdev_set_routing helper() Tomi Valkeinen
2022-10-12  6:22   ` Yunke Cao
2022-10-12  6:58     ` Tomi Valkeinen
2022-10-03 12:18 ` [PATCH v15 08/19] media: subdev: Add for_each_active_route() macro Tomi Valkeinen
2022-10-09  5:38   ` Dafna Hirschfeld
2022-10-12  6:15     ` Tomi Valkeinen
2022-10-13  7:41       ` Sakari Ailus
2022-10-03 12:18 ` [PATCH v15 09/19] media: Documentation: add multiplexed streams documentation Tomi Valkeinen
2022-10-11 10:47   ` [PATCH 1/1] media: Documentation: Interaction between routes, formats and selections Sakari Ailus
2022-10-12 10:30     ` Tomi Valkeinen
2022-12-07 10:38       ` Sakari Ailus
2022-10-03 12:18 ` [PATCH v15 10/19] media: subdev: add stream based configuration Tomi Valkeinen
2022-10-09  6:24   ` Dafna Hirschfeld
2022-10-12  6:36     ` Tomi Valkeinen
2022-10-03 12:18 ` [PATCH v15 11/19] media: subdev: use streams in v4l2_subdev_link_validate() Tomi Valkeinen
2022-10-14 10:54   ` Sakari Ailus
2022-10-14 11:10     ` Tomi Valkeinen
2022-10-16 22:37       ` Sakari Ailus
2022-10-27 10:43         ` Tomi Valkeinen
2022-10-03 12:18 ` [PATCH v15 12/19] media: subdev: add "opposite" stream helper funcs Tomi Valkeinen
2022-10-09  7:06   ` Dafna Hirschfeld [this message]
2022-10-12  6:46     ` Tomi Valkeinen
2022-10-03 12:18 ` [PATCH v15 13/19] media: subdev: add streams to v4l2_subdev_get_fmt() helper function Tomi Valkeinen
2022-10-03 12:18 ` [PATCH v15 14/19] media: subdev: add v4l2_subdev_set_routing_with_fmt() helper Tomi Valkeinen
2022-10-03 12:18 ` [PATCH v15 15/19] media: subdev: add v4l2_subdev_routing_validate() helper Tomi Valkeinen
2022-10-03 12:18 ` [PATCH v15 16/19] media: v4l2-subdev: Add v4l2_subdev_state_xlate_streams() helper Tomi Valkeinen
2022-10-03 12:18 ` [PATCH v15 17/19] media: v4l2-subdev: Add subdev .(enable|disable)_streams() operations Tomi Valkeinen
2022-10-10 16:53   ` Dafna Hirschfeld
2022-10-12  5:59     ` Tomi Valkeinen
2022-10-03 12:18 ` [PATCH v15 18/19] media: v4l2-subdev: Add v4l2_subdev_s_stream_helper() function Tomi Valkeinen
2022-10-03 12:18 ` [PATCH v15 19/19] media: Add stream to frame descriptor Tomi Valkeinen

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=20221009070614.rud3yx6acsxwt6kl@guri \
    --to=dafna@fastmail.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=jacopo+renesas@jmondi.org \
    --cc=jacopo@jmondi.org \
    --cc=kishon@ti.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=sakari.ailus@linux.intel.com \
    --cc=satish.nagireddy@getcruise.com \
    --cc=tfiga@chromium.org \
    --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 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.