162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci 362306a36Sopenharmony_ciThe Virtual Media Controller Driver (vimc) 462306a36Sopenharmony_ci========================================== 562306a36Sopenharmony_ci 662306a36Sopenharmony_ciThe vimc driver emulates complex video hardware using the V4L2 API and the Media 762306a36Sopenharmony_ciAPI. It has a capture device and three subdevices: sensor, debayer and scaler. 862306a36Sopenharmony_ci 962306a36Sopenharmony_ciTopology 1062306a36Sopenharmony_ci-------- 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ciThe topology is hardcoded, although you could modify it in vimc-core and 1362306a36Sopenharmony_cirecompile the driver to achieve your own topology. This is the default topology: 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci.. _vimc_topology_graph: 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci.. kernel-figure:: vimc.dot 1862306a36Sopenharmony_ci :alt: Diagram of the default media pipeline topology 1962306a36Sopenharmony_ci :align: center 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci Media pipeline graph on vimc 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ciConfiguring the topology 2462306a36Sopenharmony_ci~~~~~~~~~~~~~~~~~~~~~~~~ 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ciEach subdevice will come with its default configuration (pixelformat, height, 2762306a36Sopenharmony_ciwidth, ...). One needs to configure the topology in order to match the 2862306a36Sopenharmony_ciconfiguration on each linked subdevice to stream frames through the pipeline. 2962306a36Sopenharmony_ciIf the configuration doesn't match, the stream will fail. The ``v4l-utils`` 3062306a36Sopenharmony_cipackage is a bundle of user-space applications, that comes with ``media-ctl`` and 3162306a36Sopenharmony_ci``v4l2-ctl`` that can be used to configure the vimc configuration. This sequence 3262306a36Sopenharmony_ciof commands fits for the default topology: 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci.. code-block:: bash 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci media-ctl -d platform:vimc -V '"Sensor A":0[fmt:SBGGR8_1X8/640x480]' 3762306a36Sopenharmony_ci media-ctl -d platform:vimc -V '"Debayer A":0[fmt:SBGGR8_1X8/640x480]' 3862306a36Sopenharmony_ci media-ctl -d platform:vimc -V '"Scaler":0[fmt:RGB888_1X24/640x480]' 3962306a36Sopenharmony_ci media-ctl -d platform:vimc -V '"Scaler":0[crop:(100,50)/400x150]' 4062306a36Sopenharmony_ci media-ctl -d platform:vimc -V '"Scaler":1[fmt:RGB888_1X24/300x700]' 4162306a36Sopenharmony_ci v4l2-ctl -z platform:vimc -d "RGB/YUV Capture" -v width=300,height=700 4262306a36Sopenharmony_ci v4l2-ctl -z platform:vimc -d "Raw Capture 0" -v pixelformat=BA81 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ciSubdevices 4562306a36Sopenharmony_ci---------- 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ciSubdevices define the behavior of an entity in the topology. Depending on the 4862306a36Sopenharmony_cisubdevice, the entity can have multiple pads of type source or sink. 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_civimc-sensor: 5162306a36Sopenharmony_ci Generates images in several formats using video test pattern generator. 5262306a36Sopenharmony_ci Exposes: 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci * 1 Pad source 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_civimc-lens: 5762306a36Sopenharmony_ci Ancillary lens for a sensor. Supports auto focus control. Linked to 5862306a36Sopenharmony_ci a vimc-sensor using an ancillary link. The lens supports FOCUS_ABSOLUTE 5962306a36Sopenharmony_ci control. 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci.. code-block:: bash 6262306a36Sopenharmony_ci 6362306a36Sopenharmony_ci media-ctl -p 6462306a36Sopenharmony_ci ... 6562306a36Sopenharmony_ci - entity 28: Lens A (0 pad, 0 link) 6662306a36Sopenharmony_ci type V4L2 subdev subtype Lens flags 0 6762306a36Sopenharmony_ci device node name /dev/v4l-subdev6 6862306a36Sopenharmony_ci - entity 29: Lens B (0 pad, 0 link) 6962306a36Sopenharmony_ci type V4L2 subdev subtype Lens flags 0 7062306a36Sopenharmony_ci device node name /dev/v4l-subdev7 7162306a36Sopenharmony_ci v4l2-ctl -d /dev/v4l-subdev7 -C focus_absolute 7262306a36Sopenharmony_ci focus_absolute: 0 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_civimc-debayer: 7662306a36Sopenharmony_ci Transforms images in bayer format into a non-bayer format. 7762306a36Sopenharmony_ci Exposes: 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_ci * 1 Pad sink 8062306a36Sopenharmony_ci * 1 Pad source 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_civimc-scaler: 8362306a36Sopenharmony_ci Re-size the image to meet the source pad resolution. E.g.: if the sync 8462306a36Sopenharmony_ci pad is configured to 360x480 and the source to 1280x720, the image will 8562306a36Sopenharmony_ci be stretched to fit the source resolution. Works for any resolution 8662306a36Sopenharmony_ci within the vimc limitations (even shrinking the image if necessary). 8762306a36Sopenharmony_ci Exposes: 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ci * 1 Pad sink 9062306a36Sopenharmony_ci * 1 Pad source 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_civimc-capture: 9362306a36Sopenharmony_ci Exposes node /dev/videoX to allow userspace to capture the stream. 9462306a36Sopenharmony_ci Exposes: 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ci * 1 Pad sink 9762306a36Sopenharmony_ci * 1 Pad source 9862306a36Sopenharmony_ci 9962306a36Sopenharmony_ciModule options 10062306a36Sopenharmony_ci-------------- 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_ciVimc has a module parameter to configure the driver. 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_ci* ``allocator=<unsigned int>`` 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_ci memory allocator selection, default is 0. It specifies the way buffers 10762306a36Sopenharmony_ci will be allocated. 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_ci - 0: vmalloc 11062306a36Sopenharmony_ci - 1: dma-contig 111