Commit c4a73f31 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab

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: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 69c0fe7a
...@@ -1615,6 +1615,32 @@ v4l2_subdev_state_get_opposite_stream_format(struct v4l2_subdev_state *state, ...@@ -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); 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, int v4l2_subdev_routing_validate(struct v4l2_subdev *sd,
const struct v4l2_subdev_krouting *routing, const struct v4l2_subdev_krouting *routing,
enum v4l2_subdev_routing_restriction disallow) enum v4l2_subdev_routing_restriction disallow)
......
...@@ -1584,6 +1584,29 @@ struct v4l2_mbus_framefmt * ...@@ -1584,6 +1584,29 @@ struct v4l2_mbus_framefmt *
v4l2_subdev_state_get_opposite_stream_format(struct v4l2_subdev_state *state, v4l2_subdev_state_get_opposite_stream_format(struct v4l2_subdev_state *state,
u32 pad, u32 stream); u32 pad, u32 stream);
/**
* v4l2_subdev_state_xlate_streams() - Translate streams from one pad to another
*
* @state: Subdevice state
* @pad0: The first pad
* @pad1: The second pad
* @streams: Streams bitmask on the first pad
*
* Streams on sink pads of a subdev are routed to source pads as expressed in
* the subdev state routing table. Stream numbers don't necessarily match on
* the sink and source side of a route. This function translates stream numbers
* on @pad0, expressed as a bitmask in @streams, to the corresponding streams
* on @pad1 using the routing table from the @state. It returns the stream mask
* on @pad1, and updates @streams with the streams that have been found in the
* routing table.
*
* @pad0 and @pad1 must be a sink and a source, in any order.
*
* Return: The bitmask of streams of @pad1 that are routed to @streams on @pad0.
*/
u64 v4l2_subdev_state_xlate_streams(const struct v4l2_subdev_state *state,
u32 pad0, u32 pad1, u64 *streams);
/** /**
* enum v4l2_subdev_routing_restriction - Subdevice internal routing restrictions * enum v4l2_subdev_routing_restriction - Subdevice internal routing restrictions
* *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment