2018-08-30 14:20:04 +00:00
|
|
|
.. SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
2020-05-06 13:28:20 +00:00
|
|
|
.. _MIPI_CSI_2:
|
|
|
|
|
2016-10-19 14:28:45 +00:00
|
|
|
MIPI CSI-2
|
|
|
|
==========
|
|
|
|
|
|
|
|
CSI-2 is a data bus intended for transferring images from cameras to
|
|
|
|
the host SoC. It is defined by the `MIPI alliance`_.
|
|
|
|
|
|
|
|
.. _`MIPI alliance`: http://www.mipi.org/
|
|
|
|
|
2020-05-16 22:39:36 +00:00
|
|
|
Media bus formats
|
|
|
|
-----------------
|
|
|
|
|
|
|
|
See :ref:`v4l2-mbus-pixelcode` for details on which media bus formats should
|
|
|
|
be used for CSI-2 interfaces.
|
|
|
|
|
2016-10-19 14:28:45 +00:00
|
|
|
Transmitter drivers
|
|
|
|
-------------------
|
|
|
|
|
|
|
|
CSI-2 transmitter, such as a sensor or a TV tuner, drivers need to
|
|
|
|
provide the CSI-2 receiver with information on the CSI-2 bus
|
|
|
|
configuration. These include the V4L2_CID_LINK_FREQ and
|
|
|
|
V4L2_CID_PIXEL_RATE controls and
|
|
|
|
(:c:type:`v4l2_subdev_video_ops`->s_stream() callback). These
|
|
|
|
interface elements must be present on the sub-device represents the
|
|
|
|
CSI-2 transmitter.
|
|
|
|
|
|
|
|
The V4L2_CID_LINK_FREQ control is used to tell the receiver driver the
|
2020-10-13 13:11:37 +00:00
|
|
|
frequency (and not the symbol rate) of the link. The V4L2_CID_PIXEL_RATE
|
|
|
|
control may be used by the receiver to obtain the pixel rate the transmitter
|
|
|
|
uses. The :c:type:`v4l2_subdev_video_ops`->s_stream() callback provides an
|
2016-10-19 14:28:45 +00:00
|
|
|
ability to start and stop the stream.
|
|
|
|
|
|
|
|
The value of the V4L2_CID_PIXEL_RATE is calculated as follows::
|
|
|
|
|
|
|
|
pixel_rate = link_freq * 2 * nr_of_lanes / bits_per_sample
|
|
|
|
|
|
|
|
where
|
|
|
|
|
|
|
|
.. list-table:: variables in pixel rate calculation
|
|
|
|
:header-rows: 1
|
|
|
|
|
|
|
|
* - variable or constant
|
|
|
|
- description
|
|
|
|
* - link_freq
|
|
|
|
- The value of the V4L2_CID_LINK_FREQ integer64 menu item.
|
|
|
|
* - nr_of_lanes
|
|
|
|
- Number of data lanes used on the CSI-2 link. This can
|
|
|
|
be obtained from the OF endpoint configuration.
|
|
|
|
* - 2
|
|
|
|
- Two bits are transferred per clock cycle per lane.
|
|
|
|
* - bits_per_sample
|
|
|
|
- Number of bits per sample.
|
|
|
|
|
2017-03-09 10:22:11 +00:00
|
|
|
The transmitter drivers must, if possible, configure the CSI-2
|
|
|
|
transmitter to *LP-11 mode* whenever the transmitter is powered on but
|
2019-08-13 22:36:44 +00:00
|
|
|
not active, and maintain *LP-11 mode* until stream on. Only at stream
|
|
|
|
on should the transmitter activate the clock on the clock lane and
|
|
|
|
transition to *HS mode*.
|
|
|
|
|
|
|
|
Some transmitters do this automatically but some have to be explicitly
|
|
|
|
programmed to do so, and some are unable to do so altogether due to
|
|
|
|
hardware constraints.
|
2016-10-19 14:28:45 +00:00
|
|
|
|
2017-08-16 12:20:18 +00:00
|
|
|
Stopping the transmitter
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
A transmitter stops sending the stream of images as a result of
|
|
|
|
calling the ``.s_stream()`` callback. Some transmitters may stop the
|
|
|
|
stream at a frame boundary whereas others stop immediately,
|
|
|
|
effectively leaving the current frame unfinished. The receiver driver
|
|
|
|
should not make assumptions either way, but function properly in both
|
|
|
|
cases.
|
|
|
|
|
2016-10-19 14:28:45 +00:00
|
|
|
Receiver drivers
|
|
|
|
----------------
|
|
|
|
|
|
|
|
Before the receiver driver may enable the CSI-2 transmitter by using
|
|
|
|
the :c:type:`v4l2_subdev_video_ops`->s_stream(), it must have powered
|
|
|
|
the transmitter up by using the
|
|
|
|
:c:type:`v4l2_subdev_core_ops`->s_power() callback. This may take
|
2020-01-24 20:35:43 +00:00
|
|
|
place either indirectly by using :c:func:`v4l2_pipeline_pm_get` or
|
2016-10-19 14:28:45 +00:00
|
|
|
directly.
|
2019-08-13 11:26:43 +00:00
|
|
|
|
|
|
|
Formats
|
|
|
|
-------
|
|
|
|
|
|
|
|
The media bus pixel codes document parallel formats. Should the pixel data be
|
|
|
|
transported over a serial bus, the media bus pixel code that describes a
|
|
|
|
parallel format that transfers a sample on a single clock cycle is used.
|