[PATCH v12 58/86] media: imx219: Report internal routes to userspace

Sakari Ailus
2026-04-09T20:15:02Z

From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Usage of internal pads creates a route internal to the subdev, and the
V4L2 camera sensor API requires such routes to be reported to userspace.
Create the route in the .init_state() operation.

Internal routing support requires stream support, so set the
V4L2_SUBDEV_FL_STREAMS flag. As the route is immutable, there's no need
to implement the .set_routing() operation.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/i2c/imx219.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
index bb7b2e4b34fd..e79b26268415 100644
--- a/drivers/media/i2c/imx219.c
+++ b/drivers/media/i2c/imx219.c
@@ -1049,6 +1049,28 @@ static int imx219_get_selection(struct v4l2_subdev *sd,
static int imx219_init_state(struct v4l2_subdev *sd,
struct v4l2_subdev_state *state)
{
+ struct v4l2_subdev_route routes[1] = {
+ {
+ .sink_pad = IMX219_PAD_IMAGE,
+ .sink_stream = 0,
+ .source_pad = IMX219_PAD_SOURCE,
+ .source_stream = IMX219_STREAM_IMAGE,
+ .flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE |
+ V4L2_SUBDEV_ROUTE_FL_IMMUTABLE |
+ V4L2_SUBDEV_ROUTE_FL_STATIC,
+ },
+ };
+ struct v4l2_subdev_krouting routing = {
+ .len_routes = ARRAY_SIZE(routes),
+ .num_routes = ARRAY_SIZE(routes),
+ .routes = routes,
+ };
+ int ret;
+
+ ret = v4l2_subdev_set_routing(sd, state, &routing);
+ if (ret)
+ return ret;
+
struct v4l2_mbus_framefmt *pixel_array_format =
v4l2_subdev_state_get_format(state, IMX219_PAD_IMAGE);
struct v4l2_rect *analogue_crop =
@@ -1349,7 +1371,8 @@ static int imx219_probe(struct i2c_client *client)
if (ret)
goto error_power_off;

- imx219->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
+ imx219->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE |
+ V4L2_SUBDEV_FL_STREAMS;
imx219->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;

imx219->pads[IMX219_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
--
2.47.3