diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2022-01-18 00:51:23 +0100 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@kernel.org> | 2023-01-22 09:45:28 +0100 |
commit | c4a73f316d04594689dffcae8d800787e4fc9f75 (patch) | |
tree | 97a91f8b24fb60887a4748927a1e34eac7f780d5 /drivers/media/v4l2-core | |
parent | 69c0fe7ae78b9ed696b5a5d8eaae7ca622c6f7ca (diff) | |
download | linux-stable-c4a73f316d04594689dffcae8d800787e4fc9f75.tar.gz linux-stable-c4a73f316d04594689dffcae8d800787e4fc9f75.tar.bz2 linux-stable-c4a73f316d04594689dffcae8d800787e4fc9f75.zip |
media: v4l2-subdev: Add v4l2_subdev_state_xlate_streams() helper
Add a helper function to translate streams between two pads of a subdev,
using the subdev's internal routing table.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Diffstat (limited to 'drivers/media/v4l2-core')
-rw-r--r-- | drivers/media/v4l2-core/v4l2-subdev.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index d7e157c7e612..13f1a100496e 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -1615,6 +1615,32 @@ v4l2_subdev_state_get_opposite_stream_format(struct v4l2_subdev_state *state, } EXPORT_SYMBOL_GPL(v4l2_subdev_state_get_opposite_stream_format); +u64 v4l2_subdev_state_xlate_streams(const struct v4l2_subdev_state *state, + u32 pad0, u32 pad1, u64 *streams) +{ + const struct v4l2_subdev_krouting *routing = &state->routing; + struct v4l2_subdev_route *route; + u64 streams0 = 0; + u64 streams1 = 0; + + for_each_active_route(routing, route) { + if (route->sink_pad == pad0 && route->source_pad == pad1 && + (*streams & BIT_ULL(route->sink_stream))) { + streams0 |= BIT_ULL(route->sink_stream); + streams1 |= BIT_ULL(route->source_stream); + } + if (route->source_pad == pad0 && route->sink_pad == pad1 && + (*streams & BIT_ULL(route->source_stream))) { + streams0 |= BIT_ULL(route->source_stream); + streams1 |= BIT_ULL(route->sink_stream); + } + } + + *streams = streams0; + return streams1; +} +EXPORT_SYMBOL_GPL(v4l2_subdev_state_xlate_streams); + int v4l2_subdev_routing_validate(struct v4l2_subdev *sd, const struct v4l2_subdev_krouting *routing, enum v4l2_subdev_routing_restriction disallow) |