Re: [PATCH v15 12/19] media: subdev: add "opposite" stream helper funcs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09/10/2022 10:06, Dafna Hirschfeld wrote:
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@xxxxxxxxxxxxxxxx>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xxxxxxxxx>
Reviewed-by: Jacopo Mondi <jacopo@xxxxxxxxxx>
---
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

Yes, you are correct. I'll add the check.

 Tomi




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux