Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>

authored by

Laurent Pinchart and committed by
Hans Verkuil
43f661a7 3062098a

+14
+14
drivers/media/v4l2-core/v4l2-subdev.c
··· 1004 1004 struct v4l2_subdev_route *routes = 1005 1005 (struct v4l2_subdev_route *)(uintptr_t)routing->routes; 1006 1006 struct v4l2_subdev_krouting krouting = {}; 1007 + unsigned int num_active_routes = 0; 1007 1008 unsigned int i; 1008 1009 1009 1010 if (!v4l2_subdev_enable_streams_api) ··· 1042 1041 if (!(pads[route->source_pad].flags & 1043 1042 MEDIA_PAD_FL_SOURCE)) 1044 1043 return -EINVAL; 1044 + 1045 + if (route->flags & V4L2_SUBDEV_ROUTE_FL_ACTIVE) 1046 + num_active_routes++; 1045 1047 } 1048 + 1049 + /* 1050 + * Drivers that implement routing need to report a frame 1051 + * descriptor accordingly, with up to one entry per route. Until 1052 + * the frame descriptors entries get allocated dynamically, 1053 + * limit the number of active routes to 1054 + * V4L2_FRAME_DESC_ENTRY_MAX. 1055 + */ 1056 + if (num_active_routes > V4L2_FRAME_DESC_ENTRY_MAX) 1057 + return -E2BIG; 1046 1058 1047 1059 /* 1048 1060 * If the driver doesn't support setting routing, just return