[PATCH v8 01/16] media: subdev: Export get_format helper for link validation
From: Jai Luthra
Date: Mon Jul 31 2023 - 04:29:54 EST
For link validation on video device drivers, it may be required to
match the formats set on the source subdev with the formats set on the
video device.
Export the existing v4l2_subdev_link_validate_get_format() helper so it
can be reused by such drivers.
Suggested-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>
Signed-off-by: Jai Luthra <j-luthra@xxxxxx>
---
New in v8
drivers/media/v4l2-core/v4l2-subdev.c | 8 ++++----
include/media/v4l2-subdev.h | 12 ++++++++++++
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index 217b8019fb9b..0d3b5ff5cacc 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -1130,10 +1130,9 @@ int v4l2_subdev_link_validate_default(struct v4l2_subdev *sd,
}
EXPORT_SYMBOL_GPL(v4l2_subdev_link_validate_default);
-static int
-v4l2_subdev_link_validate_get_format(struct media_pad *pad, u32 stream,
- struct v4l2_subdev_format *fmt,
- bool states_locked)
+int v4l2_subdev_link_validate_get_format(struct media_pad *pad, u32 stream,
+ struct v4l2_subdev_format *fmt,
+ bool states_locked)
{
struct v4l2_subdev_state *state;
struct v4l2_subdev *sd;
@@ -1165,6 +1164,7 @@ v4l2_subdev_link_validate_get_format(struct media_pad *pad, u32 stream,
return ret;
}
+EXPORT_SYMBOL_GPL(v4l2_subdev_link_validate_get_format);
#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index a012741cc876..ef7007f46889 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -1301,6 +1301,18 @@ int v4l2_subdev_link_validate_default(struct v4l2_subdev *sd,
struct v4l2_subdev_format *source_fmt,
struct v4l2_subdev_format *sink_fmt);
+/**
+ * v4l2_subdev_link_validate_get_format - get format for media link validation
+ *
+ * @pad: pad id
+ * @stream: stream id
+ * @fmt: pointer to &struct v4l2_subdev_format
+ * @states_locked: is the subdev state already locked
+ */
+int v4l2_subdev_link_validate_get_format(struct media_pad *pad, u32 stream,
+ struct v4l2_subdev_format *fmt,
+ bool states_locked);
+
/**
* v4l2_subdev_link_validate - validates a media link
*
--
2.41.0