Lines Matching full:the
9 The complex nature of V4L2 devices, where hardware is often made of
11 controlled way, leads to complex V4L2 drivers. The drivers usually
12 reflect the hardware model in software, and model the different hardware
15 V4L2 sub-devices are usually kernel-only objects. If the V4L2 driver
16 implements the media device API, they will automatically inherit from
17 media entities. Applications will be able to enumerate the sub-devices
18 and discover the hardware topology using the media entities, pads and
22 make them directly configurable by applications. When both the
23 sub-device driver and the V4L2 device driver support this, sub-devices
32 - inspect and modify internal data routing between pads of the same entity
37 Drivers may opt to limit the sub-device character devices to only expose
38 operations that do not modify the device state. In such a case the sub-devices
39 are referred to as ``read-only`` in the rest of this documentation, and the
50 Complex devices sometimes implement the same control in different pieces
54 As the V4L2 controls API doesn't support several identical controls in a
55 single device, all but one of the identical controls are hidden.
57 Applications can access those hidden controls through the sub-device
58 node with the V4L2 control API described in :ref:`control`. The ioctls
59 behave identically as when issued on V4L2 device nodes, with the
60 exception that they deal only with controls implemented in the
63 Depending on the driver, those controls might also be exposed through
71 :ref:`event`. The API behaves identically as when used on V4L2 device
72 nodes, with the exception that it only deals with events generated by
73 the sub-device. Depending on the driver, those events might also be
86 V4L2 applications do *not* need to use the API described in this
91 For the purpose of this section, the term *format* means the
95 devices using the format and
96 :ref:`selection <VIDIOC_SUBDEV_G_SELECTION>` ioctls. The driver is
97 responsible for configuring every block in the video pipeline according
98 to the requested format at the pipeline input and/or output.
101 image sizes at the output of a pipeline can be achieved using different
104 the video sensor and the host image processing hardware.
119 The sensor scaler is usually of less quality than the host scaler, but
120 scaling on the sensor is required to achieve higher frame rates.
121 Depending on the use case (quality vs. speed), the pipeline must be
122 configured differently. Applications need to configure the formats at
123 every point in the pipeline explicitly.
125 Drivers that implement the :ref:`media API <media-controller-intro>`
127 they do, applications can use the
132 Applications are responsible for configuring coherent parameters on the
134 formats. The pipeline is checked for formats mismatch at
136 code is then returned if the configuration is invalid.
139 the :ref:`VIDIOC_SUBDEV_G_FMT` ioctl on pad
140 0. If the driver returns an ``EINVAL`` error code pad-level format
141 configuration is not supported by the sub-device.
153 Central to the format negotiation mechanism are the get/set format
154 operations. When called with the ``which`` argument set to
155 :ref:`V4L2_SUBDEV_FORMAT_TRY <VIDIOC_SUBDEV_G_FMT>`, the
158 a set of formats parameters that are not connected to the hardware
159 configuration. Modifying those 'try' formats leaves the device state
160 untouched (this applies to both the software state stored in the driver
161 and the hardware state stored in the device itself).
163 While not kept as part of the device state, try formats are stored in
164 the sub-device file handles. A
166 the last try format set *on the same sub-device file handle*. Several
167 applications querying the same sub-device at the same time will thus not
170 To find out whether a particular format is supported by the device,
171 applications use the
173 verify and, if needed, change the requested ``format`` based on device
174 requirements and return the possibly modified value. Applications can
175 then choose to try a different format or accept the returned value and
178 Formats returned by the driver during a negotiation iteration are
179 guaranteed to be supported by the device. In particular, drivers
187 the same sub-device can be modified by the driver. Drivers are free to
188 modify formats as required by the device. However, they should comply
189 with the following rules when possible:
192 a format on a source pad should not modify the format on any sink
196 reset the scale factors to default values when sink pads formats are
197 modified. If the 1:1 scaling ratio is supported, this means that
198 source pads formats should be reset to the sink pads formats.
203 explicitly with compatible formats. Identical formats on the two ends of
208 for the pipeline described in :ref:`pipeline-scaling` (table columns
307 1. Initial state. The sensor source pad format is set to its native 3MP
308 size and V4L2_MBUS_FMT_SGRBG8_1X8 media bus code. Formats on the
309 host frontend and scaler sink and source pads have the default
310 values, as well as the compose rectangle on the scaler's sink pad.
312 2. The application configures the frontend sink pad format's size to
313 2048x1536 and its media bus code to V4L2_MBUS_FMT_SGRBG_1X8. The
314 driver propagates the format to the frontend source pad.
316 3. The application configures the scaler sink pad format's size to
317 2046x1534 and the media bus code to V4L2_MBUS_FMT_SGRBG_1X8 to
318 match the frontend source size and media bus code. The media bus code
319 on the sink pad is set to V4L2_MBUS_FMT_SGRBG_1X8. The driver
320 propagates the size to the compose selection rectangle on the
321 scaler's sink pad, and the format to the scaler source pad.
323 4. The application configures the size of the compose selection
324 rectangle of the scaler's sink pad 1280x960. The driver propagates
325 the size to the scaler's source pad format.
327 When satisfied with the try results, applications can set the active
328 formats by setting the ``which`` argument to
330 formats by drivers. To avoid modifying the hardware state during format
332 modify the active settings using the try formats returned during the
333 last negotiation iteration. This guarantees that the active format will
334 be applied as-is by the driver without being modified.
343 (or possible even on both). Cropping is used to select the area of
346 the area of the image that will be scaled up.
349 struct :c:type:`v4l2_rect` by the coordinates of the top
350 left corner and the rectangle size. Both the coordinates and sizes are
353 As for pad formats, drivers store try and active rectangles for the
356 On sink pads, cropping is applied relative to the current pad format.
357 The pad format represents the image size as received by the sub-device
358 from the previous block in the pipeline, and the crop rectangle
359 represents the sub-image that will be transmitted further inside the
362 The scaling operation changes the size of the image by scaling it to new
363 dimensions. The scaling ratio isn't specified explicitly, but is implied
364 from the original and scaled image sizes. Both sizes are represented by
367 Scaling support is optional. When supported by a subdev, the crop
368 rectangle on the subdev's sink pad is scaled to the size configured
369 using the
371 using ``V4L2_SEL_TGT_COMPOSE`` selection target on the same pad. If the
372 subdev supports scaling but not composing, the top and left values are
375 On source pads, cropping is similar to sink pads, with the exception
376 that the source size from which the cropping is performed, is the
377 COMPOSE rectangle on the sink pad. In both sink and source pads, the
378 crop rectangle must be entirely contained inside the source image size
379 for the crop operation.
381 The drivers should always use the closest possible rectangle the user
384 the image size either up or down. :ref:`v4l2-selection-flags`
394 Actual targets (without a postfix) reflect the actual hardware
402 BOUNDS targets is the smallest rectangle that contains all valid actual
403 rectangles. It may not be possible to set the actual rectangle as large
404 as the BOUNDS rectangle, however. This may be because e.g. a sensor's
405 pixel array is not rectangular but cross-shaped or round. The maximum
406 size may also be smaller than the BOUNDS rectangle.
414 Inside subdevs, the order of image processing steps will always be from
415 the sink pad towards the source pad. This is also reflected in the order
416 in which the configuration must be performed by the user: the changes
418 not desired, the user must set ``V4L2_SEL_FLAG_KEEP_CONFIG`` flag. This
419 flag causes no propagation of the changes are allowed in any
420 circumstances. This may also cause the accessed rectangle to be adjusted
421 by the driver, depending on the properties of the underlying hardware.
423 The coordinates to a step always refer to the actual size of the
424 previous step. The exception to this rule is the sink compose
425 rectangle, which refers to the sink compose bounds rectangle --- if it
426 is supported by the hardware.
428 1. Sink pad format. The user configures the sink pad format. This format
429 defines the parameters of the image the entity receives through the
432 2. Sink pad actual crop selection. The sink pad crop defines the crop
433 performed to the sink pad format.
435 3. Sink pad actual compose selection. The size of the sink pad compose
436 rectangle defines the scaling ratio compared to the size of the sink
437 pad crop rectangle. The location of the compose rectangle specifies
438 the location of the actual sink compose rectangle in the sink compose
441 4. Source pad actual crop selection. Crop on the source pad defines crop
442 performed to the image in the sink compose bounds rectangle.
444 5. Source pad format. The source pad format defines the output pixel
445 format of the subdev, as well as the other parameters with the
446 exception of the image width and height. Width and height are defined
447 by the size of the source pad actual crop selection.
449 Accessing any of the above rectangles not supported by the subdev will
451 rectangle coordinates will instead refer to the previous supported
452 rectangle. For example, if sink crop is not supported, the compose
453 selection will refer to the sink pad format dimensions instead.
464 In the above example, the subdev supports cropping on its sink pad. To
465 configure it, the user sets the media bus format on the subdev's sink
466 pad. Now the actual crop rectangle can be set on the sink pad --- the
467 location and size of this rectangle reflect the location and size of a
468 rectangle to be cropped from the sink format. The size of the sink crop
469 rectangle will also be the size of the format of the subdev's source
481 In this example, the subdev is capable of first cropping, then scaling
482 and finally cropping for two source pads individually from the resulting
483 scaled image. The location of the scaled image in the cropped image is
484 ignored in sink compose target. Both of the locations of the source crop
485 rectangles refer to the sink scaling rectangle, independently cropping
486 an area at location specified by the source crop rectangle from it.
497 The subdev driver supports two sink pads and two source pads. The images
498 from both of the sink pads are individually cropped, then scaled and
499 further composed on the composition bounds rectangle. From that, two
500 independent streams are cropped and sent out of the subdev from the
518 two or compose two streams into one, but the inputs and outputs for the
522 data streams are transmitted on the same bus, which is represented by a media
523 link connecting a transmitter source pad with a sink pad on the receiver. For
525 metadata stream, which are transmitted on the multiplexed data bus, represented
526 by a media link which connects the single sensor's source pad with the receiver
527 sink pad. The stream-aware receiver will de-multiplex the streams received on
528 the its sink pad and allows to route them individually to one of its source
532 non-multiplexed subdev drivers. However, if the driver at the sink end of a link
534 There may be additional limitations specific to the sink device.
540 the media pipeline from a source (e.g. a sensor) towards the final sink (e.g. a
541 receiver and demultiplexer in a SoC). Each media link carries all the enabled
542 streams from one end of the link to the other, and sub-devices have routing
543 tables which describe how the incoming streams from sink pads are routed to the
547 the same stream must be equal on both ends of a link. In other words,
549 link, but another stream ID can be used for the same stream at the other side
550 of the sub-device.
552 A stream at a specific point in the media pipeline is identified by the
554 multiplexed streams the 'stream' field is always 0.
559 The addition of streams to the V4L2 sub-device interface moves the sub-device
560 formats and selections from pads to (pad, stream) pairs. Besides the
561 usual pad, also the stream ID needs to be provided for setting formats and
562 selections. The order of configuring formats and selections along a stream is
563 the same as without streams (see :ref:`format-propagation`).
565 Instead of the sub-device wide merging of streams from all sink pads
568 source pads is allowed, to the extent supported by drivers. For every
573 subject to change in the future.
579 depending on the hardware. In all cases, however, only routes that have the
582 Devices generating the streams may allow enabling and disabling some of the
583 routes or have a fixed routing configuration. If the routes can be disabled, not
584 declaring the routes (or declaring them without
586 disable the routes. ``VIDIOC_SUBDEV_S_ROUTING`` will still return such routes
587 back to the user in the routes array, with the ``V4L2_SUBDEV_STREAM_FL_ACTIVE``
590 Devices transporting the streams almost always have more configurability with
591 respect to routing. Typically any route between the sub-device's sink and source
593 be active simultaneously. For such devices, no routes are created by the driver
595 called on the sub-device. Such newly created routes have the device's default
601 The configuration of the streams is done individually for each sub-device and
602 the validity of the streams between sub-devices is validated when the pipeline
605 There are three steps in configuring the streams:
607 1. Set up links. Connect the pads between sub-devices using the
610 2. Streams. Streams are declared and their routing is configured by setting the
611 routing table for the sub-device using :ref:`VIDIOC_SUBDEV_S_ROUTING
612 <VIDIOC_SUBDEV_G_ROUTING>` ioctl. Note that setting the routing table will
613 reset formats and selections in the sub-device to default values.
617 :ref:`format-propagation`. The stream ID is set to the same stream ID
618 associated with either sink or source pads of routes configured using the
629 - Multiplexer bridge (Bridge). The bridge has two sink pads, connected to the
632 - Receiver in the SoC (Receiver). The receiver has a single sink pad (pad 0),
633 connected to the bridge, and two source pads (pads 1-2), going to the DMA
634 engine. The receiver demultiplexes the incoming streams to the source pads.
636 - DMA Engines in the SoC (DMA Engine), one for each stream. Each DMA engine is
637 connected to a single source pad in the receiver.
639 The sensors, the bridge and the receiver are modeled as V4L2 sub-devices,
640 exposed to userspace via /dev/v4l-subdevX device nodes. The DMA engines are
643 To configure this pipeline, the userspace must take the following steps:
645 1. Set up media links between entities: connect the sensors to the bridge,
646 bridge to the receiver, and the receiver to the DMA engines. This step does
685 After configuring routing, the next step is configuring the formats and
686 selections for the streams. This is similar to performing this step without
687 streams, with just one exception: the ``stream`` field needs to be assigned
688 to the value of the stream ID.
690 A common way to accomplish this is to start from the sensors and propagate
691 the configurations along the stream towards the receiver, using