diff options
| author | Tomi Valkeinen <[email protected]> | 2024-04-24 15:39:09 +0000 |
|---|---|---|
| committer | Hans Verkuil <[email protected]> | 2024-06-04 06:31:24 +0000 |
| commit | 5f3ce14fae742d1d23061c3122d93edb879ebf53 (patch) | |
| tree | 198d88b90e9b6e7ccbf5b6131133894232ab4923 /drivers/media/v4l2-core/v4l2-subdev.c | |
| parent | media: subdev: Improve v4l2_subdev_enable/disable_streams_fallback (diff) | |
| download | kernel-5f3ce14fae742d1d23061c3122d93edb879ebf53.tar.gz kernel-5f3ce14fae742d1d23061c3122d93edb879ebf53.zip | |
media: subdev: Add v4l2_subdev_is_streaming()
Add a helper function which returns whether the subdevice is streaming,
i.e. if .s_stream or .enable_streams has been called successfully.
Reviewed-by: Umang Jain <[email protected]>
Reviewed-by: Laurent Pinchart <[email protected]>
Tested-by: Umang Jain <[email protected]>
Signed-off-by: Tomi Valkeinen <[email protected]>
Signed-off-by: Sakari Ailus <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
Diffstat (limited to 'drivers/media/v4l2-core/v4l2-subdev.c')
| -rw-r--r-- | drivers/media/v4l2-core/v4l2-subdev.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index 0231acf7168e..f256d65cf90f 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -2474,6 +2474,31 @@ void v4l2_subdev_notify_event(struct v4l2_subdev *sd, } EXPORT_SYMBOL_GPL(v4l2_subdev_notify_event); +bool v4l2_subdev_is_streaming(struct v4l2_subdev *sd) +{ + struct v4l2_subdev_state *state; + + if (!v4l2_subdev_has_op(sd, pad, enable_streams)) + return sd->s_stream_enabled; + + if (!(sd->flags & V4L2_SUBDEV_FL_STREAMS)) + return !!sd->enabled_pads; + + state = v4l2_subdev_get_locked_active_state(sd); + + for (unsigned int i = 0; i < state->stream_configs.num_configs; ++i) { + const struct v4l2_subdev_stream_config *cfg; + + cfg = &state->stream_configs.configs[i]; + + if (cfg->enabled) + return true; + } + + return false; +} +EXPORT_SYMBOL_GPL(v4l2_subdev_is_streaming); + int v4l2_subdev_get_privacy_led(struct v4l2_subdev *sd) { #if IS_REACHABLE(CONFIG_LEDS_CLASS) |
