diff options
author | Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> | 2022-04-13 00:59:05 +0530 |
---|---|---|
committer | Vignesh Raghavendra <vigneshr@ti.com> | 2022-05-31 13:57:32 +0530 |
commit | 57cf7c10b358171a43c089ee80947b9204fdce6f (patch) | |
tree | b6d29dacd527db6f2bd327dc1057899c2f79088c | |
parent | 0192d33f668c30d6202d66d54db761725d769083 (diff) |
media: subdev: add v4l2_routing_simple_verify() helper
Add a helper for verifying routing for the common case of
non-overlapping 1-to-1 streams.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
-rw-r--r-- | drivers/media/v4l2-core/v4l2-subdev.c | 24 | ||||
-rw-r--r-- | include/media/v4l2-subdev.h | 14 |
2 files changed, 38 insertions, 0 deletions
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index 374b9cc1d648..a23fa7711816 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -1535,3 +1535,27 @@ int v4l2_subdev_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_state *state, return 0; } EXPORT_SYMBOL_GPL(v4l2_subdev_get_fmt); + +int v4l2_routing_simple_verify(const struct v4l2_subdev_krouting *routing) +{ + unsigned int i, j; + + for (i = 0; i < routing->num_routes; ++i) { + const struct v4l2_subdev_route *route = &routing->routes[i]; + + for (j = i + 1; j < routing->num_routes; ++j) { + const struct v4l2_subdev_route *r = &routing->routes[j]; + + if (route->sink_pad == r->sink_pad && + route->sink_stream == r->sink_stream) + return -EINVAL; + + if (route->source_pad == r->source_pad && + route->source_stream == r->source_stream) + return -EINVAL; + } + } + + return 0; +} +EXPORT_SYMBOL_GPL(v4l2_routing_simple_verify); diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index 860fbf343383..fdeaae7f4e44 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -1540,4 +1540,18 @@ v4l2_state_get_opposite_stream_format(struct v4l2_subdev_state *state, u32 pad, int v4l2_subdev_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_state *state, struct v4l2_subdev_format *format); +/** + * v4l2_routing_simple_verify() - Verify that all streams are non-overlapping + * 1-to-1 streams + * @routing: routing to verify + * + * This verifies that the given routing contains only non-overlapping 1-to-1 + * streams. In other words, no two streams have the same source or sink + * stream ID on a single pad. This is the most common case of routing + * supported by devices. + * + * Returns 0 on success, error value otherwise. + */ +int v4l2_routing_simple_verify(const struct v4l2_subdev_krouting *routing); + #endif |