diff options
| author | Laurent Pinchart <[email protected]> | 2025-06-19 20:47:08 +0000 |
|---|---|---|
| committer | Hans Verkuil <[email protected]> | 2025-06-30 07:06:21 +0000 |
| commit | 43f661a77c3ff117530d90e2e714570f3b4ae2b3 (patch) | |
| tree | 3ff95040db640c36f5db5817f3ace1086747ea34 /drivers/media/v4l2-core/v4l2-subdev.c | |
| parent | media: i2c: vd55g1: Use first index of mbus codes array as default (diff) | |
| download | kernel-43f661a77c3ff117530d90e2e714570f3b4ae2b3.tar.gz kernel-43f661a77c3ff117530d90e2e714570f3b4ae2b3.zip | |
media: v4l2-subdev: Limit the number of active routes to V4L2_FRAME_DESC_ENTRY_MAX
Drivers that implement routing need to report a frame descriptor
accordingly, with up to one entry per route. The number of frame
descriptor entries is fixed to V4L2_FRAME_DESC_ENTRY_MAX, currently
equal to 8. Multiple drivers therefore limit the number of routes to
V4L2_FRAME_DESC_ENTRY_MAX, with a note indicating that the limit should
be lifted when frame descriptor entries will be allocated dynamically.
Duplicating the check in multiple drivers isn't ideal. Move it to the
VIDIOC_SUBDEV_S_ROUTING handling code in the v4l2-subdev core.
Signed-off-by: Laurent Pinchart <[email protected]>
Reviewed-by: Jacopo Mondi <[email protected]>
Reviewed-by: Tomi Valkeinen <[email protected]>
Reviewed-by: Lad Prabhakar <[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 | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index a3074f469b15..c69d1aff701f 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -1004,6 +1004,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg, struct v4l2_subdev_route *routes = (struct v4l2_subdev_route *)(uintptr_t)routing->routes; struct v4l2_subdev_krouting krouting = {}; + unsigned int num_active_routes = 0; unsigned int i; if (!v4l2_subdev_enable_streams_api) @@ -1041,9 +1042,22 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg, if (!(pads[route->source_pad].flags & MEDIA_PAD_FL_SOURCE)) return -EINVAL; + + if (route->flags & V4L2_SUBDEV_ROUTE_FL_ACTIVE) + num_active_routes++; } /* + * Drivers that implement routing need to report a frame + * descriptor accordingly, with up to one entry per route. Until + * the frame descriptors entries get allocated dynamically, + * limit the number of active routes to + * V4L2_FRAME_DESC_ENTRY_MAX. + */ + if (num_active_routes > V4L2_FRAME_DESC_ENTRY_MAX) + return -E2BIG; + + /* * If the driver doesn't support setting routing, just return * the routing table. */ |
