xref: /linux/Documentation/userspace-api/media/v4l/dev-subdev.rst (revision 778b8ebe5192e7a7f00563a7456517dfa63e1d90)
1.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2.. c:namespace:: V4L
3
4.. _subdev:
5
6********************
7Sub-device Interface
8********************
9
10The complex nature of V4L2 devices, where hardware is often made of
11several integrated circuits that need to interact with each other in a
12controlled way, leads to complex V4L2 drivers. The drivers usually
13reflect the hardware model in software, and model the different hardware
14components as software blocks called sub-devices.
15
16V4L2 sub-devices are usually kernel-only objects. If the V4L2 driver
17implements the media device API, they will automatically inherit from
18media entities. Applications will be able to enumerate the sub-devices
19and discover the hardware topology using the media entities, pads and
20links enumeration API.
21
22In addition to make sub-devices discoverable, drivers can also choose to
23make them directly configurable by applications. When both the
24sub-device driver and the V4L2 device driver support this, sub-devices
25will feature a character device node on which ioctls can be called to
26
27-  query, read and write sub-devices controls
28
29-  subscribe and unsubscribe to events and retrieve them
30
31-  negotiate image formats on individual pads
32
33-  inspect and modify internal data routing between pads of the same entity
34
35Sub-device character device nodes, conventionally named
36``/dev/v4l-subdev*``, use major number 81.
37
38Drivers may opt to limit the sub-device character devices to only expose
39operations that do not modify the device state. In such a case the sub-devices
40are referred to as ``read-only`` in the rest of this documentation, and the
41related restrictions are documented in individual ioctls.
42
43
44Controls
45========
46
47Most V4L2 controls are implemented by sub-device hardware. Drivers
48usually merge all controls and expose them through video device nodes.
49Applications can control all sub-devices through a single interface.
50
51Complex devices sometimes implement the same control in different pieces
52of hardware. This situation is common in embedded platforms, where both
53sensors and image processing hardware implement identical functions,
54such as contrast adjustment, white balance or faulty pixels correction.
55As the V4L2 controls API doesn't support several identical controls in a
56single device, all but one of the identical controls are hidden.
57
58Applications can access those hidden controls through the sub-device
59node with the V4L2 control API described in :ref:`control`. The ioctls
60behave identically as when issued on V4L2 device nodes, with the
61exception that they deal only with controls implemented in the
62sub-device.
63
64Depending on the driver, those controls might also be exposed through
65one (or several) V4L2 device nodes.
66
67
68Events
69======
70
71V4L2 sub-devices can notify applications of events as described in
72:ref:`event`. The API behaves identically as when used on V4L2 device
73nodes, with the exception that it only deals with events generated by
74the sub-device. Depending on the driver, those events might also be
75reported on one (or several) V4L2 device nodes.
76
77
78.. _pad-level-formats:
79
80Pad-level Formats
81=================
82
83.. warning::
84
85    Pad-level formats are only applicable to very complex devices that
86    need to expose low-level format configuration to user space. Generic
87    V4L2 applications do *not* need to use the API described in this
88    section.
89
90.. note::
91
92    For the purpose of this section, the term *format* means the
93    combination of media bus data format, frame width and frame height.
94
95Image formats are typically negotiated on video capture and output
96devices using the format and
97:ref:`selection <VIDIOC_SUBDEV_G_SELECTION>` ioctls. The driver is
98responsible for configuring every block in the video pipeline according
99to the requested format at the pipeline input and/or output.
100
101For complex devices, such as often found in embedded systems, identical
102image sizes at the output of a pipeline can be achieved using different
103hardware configurations. One such example is shown on
104:ref:`pipeline-scaling`, where image scaling can be performed on both
105the video sensor and the host image processing hardware.
106
107
108.. _pipeline-scaling:
109
110.. kernel-figure:: pipeline.dot
111    :alt:   pipeline.dot
112    :align: center
113
114    Image Format Negotiation on Pipelines
115
116    High quality and high speed pipeline configuration
117
118
119
120The sensor scaler is usually of less quality than the host scaler, but
121scaling on the sensor is required to achieve higher frame rates.
122Depending on the use case (quality vs. speed), the pipeline must be
123configured differently. Applications need to configure the formats at
124every point in the pipeline explicitly.
125
126Drivers that implement the :ref:`media API <media-controller-intro>`
127can expose pad-level image format configuration to applications. When
128they do, applications can use the
129:ref:`VIDIOC_SUBDEV_G_FMT <VIDIOC_SUBDEV_G_FMT>` and
130:ref:`VIDIOC_SUBDEV_S_FMT <VIDIOC_SUBDEV_G_FMT>` ioctls. to
131negotiate formats on a per-pad basis.
132
133Applications are responsible for configuring coherent parameters on the
134whole pipeline and making sure that connected pads have compatible
135formats. The pipeline is checked for formats mismatch at
136:ref:`VIDIOC_STREAMON <VIDIOC_STREAMON>` time, and an ``EPIPE`` error
137code is then returned if the configuration is invalid.
138
139Pad-level image format configuration support can be tested by calling
140the :ref:`VIDIOC_SUBDEV_G_FMT` ioctl on pad
1410. If the driver returns an ``EINVAL`` error code pad-level format
142configuration is not supported by the sub-device.
143
144
145Format Negotiation
146------------------
147
148Acceptable formats on pads can (and usually do) depend on a number of
149external parameters, such as formats on other pads, active links, or
150even controls. Finding a combination of formats on all pads in a video
151pipeline, acceptable to both application and driver, can't rely on
152formats enumeration only. A format negotiation mechanism is required.
153
154Central to the format negotiation mechanism are the get/set format
155operations. When called with the ``which`` argument set to
156:ref:`V4L2_SUBDEV_FORMAT_TRY <VIDIOC_SUBDEV_G_FMT>`, the
157:ref:`VIDIOC_SUBDEV_G_FMT <VIDIOC_SUBDEV_G_FMT>` and
158:ref:`VIDIOC_SUBDEV_S_FMT <VIDIOC_SUBDEV_G_FMT>` ioctls operate on
159a set of formats parameters that are not connected to the hardware
160configuration. Modifying those 'try' formats leaves the device state
161untouched (this applies to both the software state stored in the driver
162and the hardware state stored in the device itself).
163
164While not kept as part of the device state, try formats are stored in
165the sub-device file handles. A
166:ref:`VIDIOC_SUBDEV_G_FMT <VIDIOC_SUBDEV_G_FMT>` call will return
167the last try format set *on the same sub-device file handle*. Several
168applications querying the same sub-device at the same time will thus not
169interact with each other.
170
171To find out whether a particular format is supported by the device,
172applications use the
173:ref:`VIDIOC_SUBDEV_S_FMT <VIDIOC_SUBDEV_G_FMT>` ioctl. Drivers
174verify and, if needed, change the requested ``format`` based on device
175requirements and return the possibly modified value. Applications can
176then choose to try a different format or accept the returned value and
177continue.
178
179Formats returned by the driver during a negotiation iteration are
180guaranteed to be supported by the device. In particular, drivers
181guarantee that a returned format will not be further changed if passed
182to an :ref:`VIDIOC_SUBDEV_S_FMT <VIDIOC_SUBDEV_G_FMT>` call as-is
183(as long as external parameters, such as formats on other pads or links'
184configuration are not changed).
185
186Drivers automatically propagate formats inside sub-devices. When a try
187or active format is set on a pad, corresponding formats on other pads of
188the same sub-device can be modified by the driver. Drivers are free to
189modify formats as required by the device. However, they should comply
190with the following rules when possible:
191
192-  Formats should be propagated from sink pads to source pads. Modifying
193   a format on a source pad should not modify the format on any sink
194   pad.
195
196-  Sub-devices that scale frames using variable scaling factors should
197   reset the scale factors to default values when sink pads formats are
198   modified. If the 1:1 scaling ratio is supported, this means that
199   source pads formats should be reset to the sink pads formats.
200
201Formats are not propagated across links, as that would involve
202propagating them from one sub-device file handle to another.
203Applications must then take care to configure both ends of every link
204explicitly with compatible formats. Identical formats on the two ends of
205a link are guaranteed to be compatible. Drivers are free to accept
206different formats matching device requirements as being compatible.
207
208:ref:`sample-pipeline-config` shows a sample configuration sequence
209for the pipeline described in :ref:`pipeline-scaling` (table columns
210list entity names and pad numbers).
211
212
213.. raw:: latex
214
215    \begingroup
216    \scriptsize
217    \setlength{\tabcolsep}{2pt}
218
219.. tabularcolumns:: |p{2.0cm}|p{2.1cm}|p{2.1cm}|p{2.1cm}|p{2.1cm}|p{2.1cm}|p{2.1cm}|
220
221.. _sample-pipeline-config:
222
223.. flat-table:: Sample Pipeline Configuration
224    :header-rows:  1
225    :stub-columns: 0
226    :widths: 5 5 5 5 5 5 5
227
228    * -
229      - Sensor/0
230
231        format
232      - Frontend/0
233
234        format
235      - Frontend/1
236
237        format
238      - Scaler/0
239
240        format
241      - Scaler/0
242
243        compose selection rectangle
244      - Scaler/1
245
246        format
247    * - Initial state
248      - 2048x1536
249
250        SGRBG8_1X8
251      - (default)
252      - (default)
253      - (default)
254      - (default)
255      - (default)
256    * - Configure frontend sink format
257      - 2048x1536
258
259        SGRBG8_1X8
260      - *2048x1536*
261
262        *SGRBG8_1X8*
263      - *2046x1534*
264
265        *SGRBG8_1X8*
266      - (default)
267      - (default)
268      - (default)
269    * - Configure scaler sink format
270      - 2048x1536
271
272        SGRBG8_1X8
273      - 2048x1536
274
275        SGRBG8_1X8
276      - 2046x1534
277
278        SGRBG8_1X8
279      - *2046x1534*
280
281        *SGRBG8_1X8*
282      - *0,0/2046x1534*
283      - *2046x1534*
284
285        *SGRBG8_1X8*
286    * - Configure scaler sink compose selection
287      - 2048x1536
288
289        SGRBG8_1X8
290      - 2048x1536
291
292        SGRBG8_1X8
293      - 2046x1534
294
295        SGRBG8_1X8
296      - 2046x1534
297
298        SGRBG8_1X8
299      - *0,0/1280x960*
300      - *1280x960*
301
302        *SGRBG8_1X8*
303
304.. raw:: latex
305
306    \endgroup
307
3081. Initial state. The sensor source pad format is set to its native 3MP
309   size and V4L2_MBUS_FMT_SGRBG8_1X8 media bus code. Formats on the
310   host frontend and scaler sink and source pads have the default
311   values, as well as the compose rectangle on the scaler's sink pad.
312
3132. The application configures the frontend sink pad format's size to
314   2048x1536 and its media bus code to V4L2_MBUS_FMT_SGRBG_1X8. The
315   driver propagates the format to the frontend source pad.
316
3173. The application configures the scaler sink pad format's size to
318   2046x1534 and the media bus code to V4L2_MBUS_FMT_SGRBG_1X8 to
319   match the frontend source size and media bus code. The media bus code
320   on the sink pad is set to V4L2_MBUS_FMT_SGRBG_1X8. The driver
321   propagates the size to the compose selection rectangle on the
322   scaler's sink pad, and the format to the scaler source pad.
323
3244. The application configures the size of the compose selection
325   rectangle of the scaler's sink pad 1280x960. The driver propagates
326   the size to the scaler's source pad format.
327
328When satisfied with the try results, applications can set the active
329formats by setting the ``which`` argument to
330``V4L2_SUBDEV_FORMAT_ACTIVE``. Active formats are changed exactly as try
331formats by drivers. To avoid modifying the hardware state during format
332negotiation, applications should negotiate try formats first and then
333modify the active settings using the try formats returned during the
334last negotiation iteration. This guarantees that the active format will
335be applied as-is by the driver without being modified.
336
337
338.. _v4l2-subdev-selections:
339
340Selections: cropping, scaling and composition
341---------------------------------------------
342
343Many sub-devices support cropping frames on their input or output pads
344(or possible even on both). Cropping is used to select the area of
345interest in an image, typically on an image sensor or a video decoder.
346It can also be used as part of digital zoom implementations to select
347the area of the image that will be scaled up.
348
349Crop settings are defined by a crop rectangle and represented in a
350struct :c:type:`v4l2_rect` by the coordinates of the top
351left corner and the rectangle size. Both the coordinates and sizes are
352expressed in pixels.
353
354As for pad formats, drivers store try and active rectangles for the
355selection targets :ref:`v4l2-selections-common`.
356
357On sink pads, cropping is applied relative to the current pad format.
358The pad format represents the image size as received by the sub-device
359from the previous block in the pipeline, and the crop rectangle
360represents the sub-image that will be transmitted further inside the
361sub-device for processing.
362
363The scaling operation changes the size of the image by scaling it to new
364dimensions. The scaling ratio isn't specified explicitly, but is implied
365from the original and scaled image sizes. Both sizes are represented by
366struct :c:type:`v4l2_rect`.
367
368Scaling support is optional. When supported by a subdev, the crop
369rectangle on the subdev's sink pad is scaled to the size configured
370using the
371:ref:`VIDIOC_SUBDEV_S_SELECTION <VIDIOC_SUBDEV_G_SELECTION>` IOCTL
372using ``V4L2_SEL_TGT_COMPOSE`` selection target on the same pad. If the
373subdev supports scaling but not composing, the top and left values are
374not used and must always be set to zero.
375
376On source pads, cropping is similar to sink pads, with the exception
377that the source size from which the cropping is performed, is the
378COMPOSE rectangle on the sink pad. In both sink and source pads, the
379crop rectangle must be entirely contained inside the source image size
380for the crop operation.
381
382The drivers should always use the closest possible rectangle the user
383requests on all selection targets, unless specifically told otherwise.
384``V4L2_SEL_FLAG_GE`` and ``V4L2_SEL_FLAG_LE`` flags may be used to round
385the image size either up or down. :ref:`v4l2-selection-flags`
386
387
388Types of selection targets
389--------------------------
390
391
392Actual targets
393^^^^^^^^^^^^^^
394
395Actual targets (without a postfix) reflect the actual hardware
396configuration at any point of time. There is a BOUNDS target
397corresponding to every actual target.
398
399
400BOUNDS targets
401^^^^^^^^^^^^^^
402
403BOUNDS targets is the smallest rectangle that contains all valid actual
404rectangles. It may not be possible to set the actual rectangle as large
405as the BOUNDS rectangle, however. This may be because e.g. a sensor's
406pixel array is not rectangular but cross-shaped or round. The maximum
407size may also be smaller than the BOUNDS rectangle.
408
409
410.. _format-propagation:
411
412Order of configuration and format propagation
413---------------------------------------------
414
415Inside subdevs, the order of image processing steps will always be from
416the sink pad towards the source pad. This is also reflected in the order
417in which the configuration must be performed by the user: the changes
418made will be propagated to any subsequent stages. If this behaviour is
419not desired, the user must set ``V4L2_SEL_FLAG_KEEP_CONFIG`` flag. This
420flag causes no propagation of the changes are allowed in any
421circumstances. This may also cause the accessed rectangle to be adjusted
422by the driver, depending on the properties of the underlying hardware.
423
424The coordinates to a step always refer to the actual size of the
425previous step. The exception to this rule is the sink compose
426rectangle, which refers to the sink compose bounds rectangle --- if it
427is supported by the hardware.
428
4291. Sink pad format. The user configures the sink pad format. This format
430   defines the parameters of the image the entity receives through the
431   pad for further processing.
432
4332. Sink pad actual crop selection. The sink pad crop defines the crop
434   performed to the sink pad format.
435
4363. Sink pad actual compose selection. The size of the sink pad compose
437   rectangle defines the scaling ratio compared to the size of the sink
438   pad crop rectangle. The location of the compose rectangle specifies
439   the location of the actual sink compose rectangle in the sink compose
440   bounds rectangle.
441
4424. Source pad actual crop selection. Crop on the source pad defines crop
443   performed to the image in the sink compose bounds rectangle.
444
4455. Source pad format. The source pad format defines the output pixel
446   format of the subdev, as well as the other parameters with the
447   exception of the image width and height. Width and height are defined
448   by the size of the source pad actual crop selection.
449
450Accessing any of the above rectangles not supported by the subdev will
451return ``EINVAL``. Any rectangle referring to a previous unsupported
452rectangle coordinates will instead refer to the previous supported
453rectangle. For example, if sink crop is not supported, the compose
454selection will refer to the sink pad format dimensions instead.
455
456
457.. _subdev-image-processing-crop:
458
459.. kernel-figure:: subdev-image-processing-crop.svg
460    :alt:   subdev-image-processing-crop.svg
461    :align: center
462
463    **Figure 4.5. Image processing in subdevs: simple crop example**
464
465In the above example, the subdev supports cropping on its sink pad. To
466configure it, the user sets the media bus format on the subdev's sink
467pad. Now the actual crop rectangle can be set on the sink pad --- the
468location and size of this rectangle reflect the location and size of a
469rectangle to be cropped from the sink format. The size of the sink crop
470rectangle will also be the size of the format of the subdev's source
471pad.
472
473
474.. _subdev-image-processing-scaling-multi-source:
475
476.. kernel-figure:: subdev-image-processing-scaling-multi-source.svg
477    :alt:   subdev-image-processing-scaling-multi-source.svg
478    :align: center
479
480    **Figure 4.6. Image processing in subdevs: scaling with multiple sources**
481
482In this example, the subdev is capable of first cropping, then scaling
483and finally cropping for two source pads individually from the resulting
484scaled image. The location of the scaled image in the cropped image is
485ignored in sink compose target. Both of the locations of the source crop
486rectangles refer to the sink scaling rectangle, independently cropping
487an area at location specified by the source crop rectangle from it.
488
489
490.. _subdev-image-processing-full:
491
492.. kernel-figure:: subdev-image-processing-full.svg
493    :alt:    subdev-image-processing-full.svg
494    :align:  center
495
496    **Figure 4.7. Image processing in subdevs: scaling and composition with multiple sinks and sources**
497
498The subdev driver supports two sink pads and two source pads. The images
499from both of the sink pads are individually cropped, then scaled and
500further composed on the composition bounds rectangle. From that, two
501independent streams are cropped and sent out of the subdev from the
502source pads.
503
504
505.. toctree::
506    :maxdepth: 1
507
508    subdev-formats
509
510.. _subdev-routing:
511
512Streams, multiplexed media pads and internal routing
513====================================================
514
515Simple V4L2 sub-devices do not support multiple, unrelated video streams,
516and only a single stream can pass through a media link and a media pad.
517Thus each pad contains a format and selection configuration for that
518single stream. A subdev can do stream processing and split a stream into
519two or compose two streams into one, but the inputs and outputs for the
520subdev are still a single stream per pad.
521
522Some hardware, e.g. MIPI CSI-2, support multiplexed streams, that is, multiple
523data streams are transmitted on the same bus, which is represented by a media
524link connecting a transmitter source pad with a sink pad on the receiver. For
525example, a camera sensor can produce two distinct streams, a pixel stream and a
526metadata stream, which are transmitted on the multiplexed data bus, represented
527by a media link which connects the single sensor's source pad with the receiver
528sink pad. The stream-aware receiver will de-multiplex the streams received on
529the its sink pad and allows to route them individually to one of its source
530pads.
531
532Subdevice drivers that support multiplexed streams are compatible with
533non-multiplexed subdev drivers. However, if the driver at the sink end of a link
534does not support streams, then only stream 0 of source end may be captured.
535There may be additional limitations specific to the sink device.
536
537Understanding streams
538---------------------
539
540A stream is a stream of content (e.g. pixel data or metadata) flowing through
541the media pipeline from a source (e.g. a sensor) towards the final sink (e.g. a
542receiver and demultiplexer in a SoC). Each media link carries all the enabled
543streams from one end of the link to the other, and sub-devices have routing
544tables which describe how the incoming streams from sink pads are routed to the
545source pads.
546
547A stream ID is a media pad-local identifier for a stream. Streams IDs of
548the same stream must be equal on both ends of a link. In other words,
549a particular stream ID must exist on both sides of a media
550link, but another stream ID can be used for the same stream at the other side
551of the sub-device.
552
553A stream at a specific point in the media pipeline is identified by the
554sub-device and a (pad, stream) pair. For sub-devices that do not support
555multiplexed streams the 'stream' field is always 0.
556
557Interaction between routes, streams, formats and selections
558-----------------------------------------------------------
559
560The addition of streams to the V4L2 sub-device interface moves the sub-device
561formats and selections from pads to (pad, stream) pairs. Besides the
562usual pad, also the stream ID needs to be provided for setting formats and
563selections. The order of configuring formats and selections along a stream is
564the same as without streams (see :ref:`format-propagation`).
565
566Instead of the sub-device wide merging of streams from all sink pads
567towards all source pads, data flows for each route are separate from each
568other. Any number of routes from streams on sink pads towards streams on
569source pads is allowed, to the extent supported by drivers. For every
570stream on a source pad, however, only a single route is allowed.
571
572Any configurations of a stream within a pad, such as format or selections,
573are independent of similar configurations on other streams. This is
574subject to change in the future.
575
576Device types and routing setup
577------------------------------
578
579Different kinds of sub-devices have differing behaviour for route activation,
580depending on the hardware. In all cases, however, only routes that have the
581``V4L2_SUBDEV_STREAM_FL_ACTIVE`` flag set are active.
582
583Devices generating the streams may allow enabling and disabling some of the
584routes or have a fixed routing configuration. If the routes can be disabled, not
585declaring the routes (or declaring them without
586``V4L2_SUBDEV_STREAM_FL_ACTIVE`` flag set) in ``VIDIOC_SUBDEV_S_ROUTING`` will
587disable the routes. ``VIDIOC_SUBDEV_S_ROUTING`` will still return such routes
588back to the user in the routes array, with the ``V4L2_SUBDEV_STREAM_FL_ACTIVE``
589flag unset.
590
591Devices transporting the streams almost always have more configurability with
592respect to routing. Typically any route between the sub-device's sink and source
593pads is possible, and multiple routes (usually up to certain limited number) may
594be active simultaneously. For such devices, no routes are created by the driver
595and user-created routes are fully replaced when ``VIDIOC_SUBDEV_S_ROUTING`` is
596called on the sub-device. Such newly created routes have the device's default
597configuration for format and selection rectangles.
598
599Configuring streams
600-------------------
601
602The configuration of the streams is done individually for each sub-device and
603the validity of the streams between sub-devices is validated when the pipeline
604is started.
605
606There are three steps in configuring the streams:
607
6081. Set up links. Connect the pads between sub-devices using the
609   :ref:`Media Controller API <media_controller>`
610
6112. Streams. Streams are declared and their routing is configured by setting the
612   routing table for the sub-device using :ref:`VIDIOC_SUBDEV_S_ROUTING
613   <VIDIOC_SUBDEV_G_ROUTING>` ioctl. Note that setting the routing table will
614   reset formats and selections in the sub-device to default values.
615
6163. Configure formats and selections. Formats and selections of each stream are
617   configured separately as documented for plain sub-devices in
618   :ref:`format-propagation`. The stream ID is set to the same stream ID
619   associated with either sink or source pads of routes configured using the
620   :ref:`VIDIOC_SUBDEV_S_ROUTING <VIDIOC_SUBDEV_G_ROUTING>` ioctl.
621
622Multiplexed streams setup example
623---------------------------------
624
625A simple example of a multiplexed stream setup might be as follows:
626
627- Two identical sensors (Sensor A and Sensor B). Each sensor has a single source
628  pad (pad 0) which carries a pixel data stream.
629
630- Multiplexer bridge (Bridge). The bridge has two sink pads, connected to the
631  sensors (pads 0, 1), and one source pad (pad 2), which outputs two streams.
632
633- Receiver in the SoC (Receiver). The receiver has a single sink pad (pad 0),
634  connected to the bridge, and two source pads (pads 1-2), going to the DMA
635  engine. The receiver demultiplexes the incoming streams to the source pads.
636
637- DMA Engines in the SoC (DMA Engine), one for each stream. Each DMA engine is
638  connected to a single source pad in the receiver.
639
640The sensors, the bridge and the receiver are modeled as V4L2 sub-devices,
641exposed to userspace via /dev/v4l-subdevX device nodes. The DMA engines are
642modeled as V4L2 devices, exposed to userspace via /dev/videoX nodes.
643
644To configure this pipeline, the userspace must take the following steps:
645
6461. Set up media links between entities: connect the sensors to the bridge,
647   bridge to the receiver, and the receiver to the DMA engines. This step does
648   not differ from normal non-multiplexed media controller setup.
649
6502. Configure routing
651
652.. flat-table:: Bridge routing table
653    :header-rows:  1
654
655    * - Sink Pad/Stream
656      - Source Pad/Stream
657      - Routing Flags
658      - Comments
659    * - 0/0
660      - 2/0
661      - V4L2_SUBDEV_ROUTE_FL_ACTIVE
662      - Pixel data stream from Sensor A
663    * - 1/0
664      - 2/1
665      - V4L2_SUBDEV_ROUTE_FL_ACTIVE
666      - Pixel data stream from Sensor B
667
668.. flat-table:: Receiver routing table
669    :header-rows:  1
670
671    * - Sink Pad/Stream
672      - Source Pad/Stream
673      - Routing Flags
674      - Comments
675    * - 0/0
676      - 1/0
677      - V4L2_SUBDEV_ROUTE_FL_ACTIVE
678      - Pixel data stream from Sensor A
679    * - 0/1
680      - 2/0
681      - V4L2_SUBDEV_ROUTE_FL_ACTIVE
682      - Pixel data stream from Sensor B
683
6843. Configure formats and selections
685
686   After configuring routing, the next step is configuring the formats and
687   selections for the streams. This is similar to performing this step without
688   streams, with just one exception: the ``stream`` field needs to be assigned
689   to the value of the stream ID.
690
691   A common way to accomplish this is to start from the sensors and propagate
692   the configurations along the stream towards the receiver, using
693   :ref:`VIDIOC_SUBDEV_S_FMT <VIDIOC_SUBDEV_G_FMT>` ioctls to configure each
694   stream endpoint in each sub-device.
695