summaryrefslogtreecommitdiff
path: root/drivers/media/v4l2-core/v4l2-subdev.c
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@linux.intel.com>2023-11-10 08:10:26 +0100
committerMauro Carvalho Chehab <mchehab@kernel.org>2023-11-23 18:48:03 +0100
commit981e0d4c724fae1fbc281b3b25b18b041b793f4d (patch)
treeafd2735381a93072d85b08e6906ae89dd7a5ac31 /drivers/media/v4l2-core/v4l2-subdev.c
parent791765b426df4d2a1b1be0617c2c0bf2248bfaba (diff)
media: v4l: subdev: Always compile sub-device state access functions
Compile sub-device state information access functions v4l2_subdev_state_get_{format,crop,compose} unconditionally as they are now also used by plain V4L2 drivers. 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/v4l2-subdev.c')
-rw-r--r--drivers/media/v4l2-core/v4l2-subdev.c252
1 files changed, 126 insertions, 126 deletions
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index 06988e3a6f10..41fe9fa5c21a 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -1531,6 +1531,132 @@ void v4l2_subdev_cleanup(struct v4l2_subdev *sd)
}
EXPORT_SYMBOL_GPL(v4l2_subdev_cleanup);
+struct v4l2_mbus_framefmt *
+__v4l2_subdev_state_get_format(struct v4l2_subdev_state *state,
+ unsigned int pad, u32 stream)
+{
+ struct v4l2_subdev_stream_configs *stream_configs;
+ unsigned int i;
+
+ if (WARN_ON_ONCE(!state))
+ return NULL;
+
+ if (state->pads) {
+ if (stream)
+ return NULL;
+
+ /*
+ * Set the pad to 0 on error as this is aligned with the
+ * behaviour of the pad state information access functions. The
+ * purpose of setting pad to 0 here is to avoid accessing memory
+ * outside the pads array, but still issuing warning of the
+ * invalid access while making the caller's error handling
+ * easier.
+ */
+ if (WARN_ON_ONCE(pad >= state->sd->entity.num_pads))
+ pad = 0;
+
+ return &state->pads[pad].format;
+ }
+
+ lockdep_assert_held(state->lock);
+
+ stream_configs = &state->stream_configs;
+
+ for (i = 0; i < stream_configs->num_configs; ++i) {
+ if (stream_configs->configs[i].pad == pad &&
+ stream_configs->configs[i].stream == stream)
+ return &stream_configs->configs[i].fmt;
+ }
+
+ return NULL;
+}
+EXPORT_SYMBOL_GPL(__v4l2_subdev_state_get_format);
+
+struct v4l2_rect *
+__v4l2_subdev_state_get_crop(struct v4l2_subdev_state *state, unsigned int pad,
+ u32 stream)
+{
+ struct v4l2_subdev_stream_configs *stream_configs;
+ unsigned int i;
+
+ if (WARN_ON_ONCE(!state))
+ return NULL;
+
+ if (state->pads) {
+ if (stream)
+ return NULL;
+
+ /*
+ * Set the pad to 0 on error as this is aligned with the
+ * behaviour of the pad state information access functions. The
+ * purpose of setting pad to 0 here is to avoid accessing memory
+ * outside the pads array, but still issuing warning of the
+ * invalid access while making the caller's error handling
+ * easier.
+ */
+ if (WARN_ON_ONCE(pad >= state->sd->entity.num_pads))
+ pad = 0;
+
+ return &state->pads[pad].crop;
+ }
+
+ lockdep_assert_held(state->lock);
+
+ stream_configs = &state->stream_configs;
+
+ for (i = 0; i < stream_configs->num_configs; ++i) {
+ if (stream_configs->configs[i].pad == pad &&
+ stream_configs->configs[i].stream == stream)
+ return &stream_configs->configs[i].crop;
+ }
+
+ return NULL;
+}
+EXPORT_SYMBOL_GPL(__v4l2_subdev_state_get_crop);
+
+struct v4l2_rect *
+__v4l2_subdev_state_get_compose(struct v4l2_subdev_state *state,
+ unsigned int pad, u32 stream)
+{
+ struct v4l2_subdev_stream_configs *stream_configs;
+ unsigned int i;
+
+ if (WARN_ON_ONCE(!state))
+ return NULL;
+
+ if (state->pads) {
+ if (stream)
+ return NULL;
+
+ /*
+ * Set the pad to 0 on error as this is aligned with the
+ * behaviour of the pad state information access functions. The
+ * purpose of setting pad to 0 here is to avoid accessing memory
+ * outside the pads array, but still issuing warning of the
+ * invalid access while making the caller's error handling
+ * easier.
+ */
+ if (WARN_ON_ONCE(pad >= state->sd->entity.num_pads))
+ pad = 0;
+
+ return &state->pads[pad].compose;
+ }
+
+ lockdep_assert_held(state->lock);
+
+ stream_configs = &state->stream_configs;
+
+ for (i = 0; i < stream_configs->num_configs; ++i) {
+ if (stream_configs->configs[i].pad == pad &&
+ stream_configs->configs[i].stream == stream)
+ return &stream_configs->configs[i].compose;
+ }
+
+ return NULL;
+}
+EXPORT_SYMBOL_GPL(__v4l2_subdev_state_get_compose);
+
#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
static int
@@ -1677,132 +1803,6 @@ int v4l2_subdev_set_routing_with_fmt(struct v4l2_subdev *sd,
}
EXPORT_SYMBOL_GPL(v4l2_subdev_set_routing_with_fmt);
-struct v4l2_mbus_framefmt *
-__v4l2_subdev_state_get_format(struct v4l2_subdev_state *state,
- unsigned int pad, u32 stream)
-{
- struct v4l2_subdev_stream_configs *stream_configs;
- unsigned int i;
-
- if (WARN_ON_ONCE(!state))
- return NULL;
-
- if (state->pads) {
- if (stream)
- return NULL;
-
- /*
- * Set the pad to 0 on error as this is aligned with the
- * behaviour of the pad state information access functions. The
- * purpose of setting pad to 0 here is to avoid accessing memory
- * outside the pads array, but still issuing warning of the
- * invalid access while making the caller's error handling
- * easier.
- */
- if (WARN_ON_ONCE(pad >= state->sd->entity.num_pads))
- pad = 0;
-
- return &state->pads[pad].format;
- }
-
- lockdep_assert_held(state->lock);
-
- stream_configs = &state->stream_configs;
-
- for (i = 0; i < stream_configs->num_configs; ++i) {
- if (stream_configs->configs[i].pad == pad &&
- stream_configs->configs[i].stream == stream)
- return &stream_configs->configs[i].fmt;
- }
-
- return NULL;
-}
-EXPORT_SYMBOL_GPL(__v4l2_subdev_state_get_format);
-
-struct v4l2_rect *
-__v4l2_subdev_state_get_crop(struct v4l2_subdev_state *state, unsigned int pad,
- u32 stream)
-{
- struct v4l2_subdev_stream_configs *stream_configs;
- unsigned int i;
-
- if (WARN_ON_ONCE(!state))
- return NULL;
-
- if (state->pads) {
- if (stream)
- return NULL;
-
- /*
- * Set the pad to 0 on error as this is aligned with the
- * behaviour of the pad state information access functions. The
- * purpose of setting pad to 0 here is to avoid accessing memory
- * outside the pads array, but still issuing warning of the
- * invalid access while making the caller's error handling
- * easier.
- */
- if (WARN_ON_ONCE(pad >= state->sd->entity.num_pads))
- pad = 0;
-
- return &state->pads[pad].crop;
- }
-
- lockdep_assert_held(state->lock);
-
- stream_configs = &state->stream_configs;
-
- for (i = 0; i < stream_configs->num_configs; ++i) {
- if (stream_configs->configs[i].pad == pad &&
- stream_configs->configs[i].stream == stream)
- return &stream_configs->configs[i].crop;
- }
-
- return NULL;
-}
-EXPORT_SYMBOL_GPL(__v4l2_subdev_state_get_crop);
-
-struct v4l2_rect *
-__v4l2_subdev_state_get_compose(struct v4l2_subdev_state *state,
- unsigned int pad, u32 stream)
-{
- struct v4l2_subdev_stream_configs *stream_configs;
- unsigned int i;
-
- if (WARN_ON_ONCE(!state))
- return NULL;
-
- if (state->pads) {
- if (stream)
- return NULL;
-
- /*
- * Set the pad to 0 on error as this is aligned with the
- * behaviour of the pad state information access functions. The
- * purpose of setting pad to 0 here is to avoid accessing memory
- * outside the pads array, but still issuing warning of the
- * invalid access while making the caller's error handling
- * easier.
- */
- if (WARN_ON_ONCE(pad >= state->sd->entity.num_pads))
- pad = 0;
-
- return &state->pads[pad].compose;
- }
-
- lockdep_assert_held(state->lock);
-
- stream_configs = &state->stream_configs;
-
- for (i = 0; i < stream_configs->num_configs; ++i) {
- if (stream_configs->configs[i].pad == pad &&
- stream_configs->configs[i].stream == stream)
- return &stream_configs->configs[i].compose;
- }
-
- return NULL;
-}
-EXPORT_SYMBOL_GPL(__v4l2_subdev_state_get_compose);
-
int v4l2_subdev_routing_find_opposite_end(const struct v4l2_subdev_krouting *routing,
u32 pad, u32 stream, u32 *other_pad,
u32 *other_stream)