7.62.1. Name

VIDIOC_SUBDEV_G_ROUTING - VIDIOC_SUBDEV_S_ROUTING - Get or set routing between streams of media pads in a media entity.

7.62.2. Synopsis


int ioctl(int fd, VIDIOC_SUBDEV_G_ROUTING, struct v4l2_subdev_routing *argp)


int ioctl(int fd, VIDIOC_SUBDEV_S_ROUTING, struct v4l2_subdev_routing *argp)

7.62.3. Arguments


File descriptor returned by open().


Pointer to struct v4l2_subdev_routing.

7.62.4. Description

These ioctls are used to get and set the routing in a media entity. The routing configuration determines the flows of data inside an entity.

Drivers report their current routing tables using the VIDIOC_SUBDEV_G_ROUTING ioctl and application may enable or disable routes with the VIDIOC_SUBDEV_S_ROUTING ioctl, by adding or removing routes and setting or clearing flags of the flags field of a struct v4l2_subdev_route. Similarly to VIDIOC_SUBDEV_G_ROUTING, also VIDIOC_SUBDEV_S_ROUTING returns the routes back to the user.

All stream configurations are reset when VIDIOC_SUBDEV_S_ROUTING is called. This means that the userspace must reconfigure all stream formats and selections after calling the ioctl with e.g. VIDIOC_SUBDEV_S_FMT.

Only subdevices which have both sink and source pads can support routing.

The len_routes field indicates the number of routes that can fit in the routes array allocated by userspace. It is set by applications for both ioctls to indicate how many routes the kernel can return, and is never modified by the kernel.

The num_routes field indicates the number of routes in the routing table. For VIDIOC_SUBDEV_S_ROUTING, it is set by userspace to the number of routes that the application stored in the routes array. For both ioctls, it is returned by the kernel and indicates how many routes are stored in the subdevice routing table. This may be smaller or larger than the value of num_routes set by the application for VIDIOC_SUBDEV_S_ROUTING, as drivers may adjust the requested routing table.

The kernel can return a num_routes value larger than len_routes from both ioctls. This indicates thare are more routes in the routing table than fits the routes array. In this case, the routes array is filled by the kernel with the first len_routes entries of the subdevice routing table. This is not considered to be an error, and the ioctl call succeeds. If the applications wants to retrieve the missing routes, it can issue a new VIDIOC_SUBDEV_G_ROUTING call with a large enough routes array.

VIDIOC_SUBDEV_S_ROUTING may return more routes than the user provided in num_routes field due to e.g. hardware properties.

type v4l2_subdev_routing
struct v4l2_subdev_routing



Routing table to be accessed, from enum v4l2_subdev_format_whence.



The length of the array (as in memory reserved for the array)

struct v4l2_subdev_route


Array of struct v4l2_subdev_route entries



Number of entries of the routes array



Reserved for future extensions. Applications and drivers must set the array to zero.

type v4l2_subdev_route
struct v4l2_subdev_route



Sink pad number.



Sink pad stream number.



Source pad number.



Source pad stream number.



Route enable/disable flags v4l2_subdev_routing_flags.



Reserved for future extensions. Applications and drivers must set the array to zero.

enum v4l2_subdev_routing_flags



The route is enabled. Set by applications.

7.62.5. Return Value

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.


The sink or source pad identifiers reference a non-existing pad or reference pads of different types (ie. the sink_pad identifiers refers to a source pad), or the which field has an unsupported value.


The application provided num_routes for VIDIOC_SUBDEV_S_ROUTING is larger than the number of routes the driver can handle.