diff options
author | Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> | 2022-04-12 10:42:48 +0100 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@kernel.org> | 2022-04-24 08:23:23 +0100 |
commit | 14a6fca77ad122208a6db10e2abda2d7369c48a4 (patch) | |
tree | ba7234c4ce7b635a40cbcca6024c4adf55e8e229 /drivers/media/v4l2-core | |
parent | b2ac238724af5c40d74391c2af1b9e9d565d41c5 (diff) | |
download | linux-14a6fca77ad122208a6db10e2abda2d7369c48a4.tar.gz linux-14a6fca77ad122208a6db10e2abda2d7369c48a4.tar.bz2 linux-14a6fca77ad122208a6db10e2abda2d7369c48a4.zip |
media: subdev: add v4l2_subdev_get_fmt() helper function
Add v4l2_subdev_get_fmt() helper function which implements
v4l2_subdev_pad_ops.get_fmt using active state. Subdev drivers that
support active state and do not need to do anything special in their
get_fmt op can use this helper directly for v4l2_subdev_pad_ops.get_fmt.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.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 | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index afe916366dfe..3da200bb23dd 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -1041,6 +1041,28 @@ void v4l2_subdev_cleanup(struct v4l2_subdev *sd) } EXPORT_SYMBOL_GPL(v4l2_subdev_cleanup); +#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API) + +int v4l2_subdev_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_state *state, + struct v4l2_subdev_format *format) +{ + struct v4l2_mbus_framefmt *fmt; + + if (format->pad >= sd->entity.num_pads) + return -EINVAL; + + fmt = v4l2_subdev_get_pad_format(sd, state, format->pad); + if (!fmt) + return -EINVAL; + + format->format = *fmt; + + return 0; +} +EXPORT_SYMBOL_GPL(v4l2_subdev_get_fmt); + +#endif /* CONFIG_VIDEO_V4L2_SUBDEV_API */ + #endif /* CONFIG_MEDIA_CONTROLLER */ void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops) |