csi2.rst 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. .. SPDX-License-Identifier: GPL-2.0
  2. .. _MIPI_CSI_2:
  3. MIPI CSI-2
  4. ==========
  5. CSI-2 is a data bus intended for transferring images from cameras to
  6. the host SoC. It is defined by the `MIPI alliance`_.
  7. .. _`MIPI alliance`: http://www.mipi.org/
  8. Media bus formats
  9. -----------------
  10. See :ref:`v4l2-mbus-pixelcode` for details on which media bus formats should
  11. be used for CSI-2 interfaces.
  12. Transmitter drivers
  13. -------------------
  14. CSI-2 transmitter, such as a sensor or a TV tuner, drivers need to
  15. provide the CSI-2 receiver with information on the CSI-2 bus
  16. configuration. These include the V4L2_CID_LINK_FREQ and
  17. V4L2_CID_PIXEL_RATE controls and
  18. (:c:type:`v4l2_subdev_video_ops`->s_stream() callback). These
  19. interface elements must be present on the sub-device represents the
  20. CSI-2 transmitter.
  21. The V4L2_CID_LINK_FREQ control is used to tell the receiver driver the
  22. frequency (and not the symbol rate) of the link. The
  23. V4L2_CID_PIXEL_RATE is may be used by the receiver to obtain the pixel
  24. rate the transmitter uses. The
  25. :c:type:`v4l2_subdev_video_ops`->s_stream() callback provides an
  26. ability to start and stop the stream.
  27. The value of the V4L2_CID_PIXEL_RATE is calculated as follows::
  28. pixel_rate = link_freq * 2 * nr_of_lanes / bits_per_sample
  29. where
  30. .. list-table:: variables in pixel rate calculation
  31. :header-rows: 1
  32. * - variable or constant
  33. - description
  34. * - link_freq
  35. - The value of the V4L2_CID_LINK_FREQ integer64 menu item.
  36. * - nr_of_lanes
  37. - Number of data lanes used on the CSI-2 link. This can
  38. be obtained from the OF endpoint configuration.
  39. * - 2
  40. - Two bits are transferred per clock cycle per lane.
  41. * - bits_per_sample
  42. - Number of bits per sample.
  43. The transmitter drivers must, if possible, configure the CSI-2
  44. transmitter to *LP-11 mode* whenever the transmitter is powered on but
  45. not active, and maintain *LP-11 mode* until stream on. Only at stream
  46. on should the transmitter activate the clock on the clock lane and
  47. transition to *HS mode*.
  48. Some transmitters do this automatically but some have to be explicitly
  49. programmed to do so, and some are unable to do so altogether due to
  50. hardware constraints.
  51. Stopping the transmitter
  52. ^^^^^^^^^^^^^^^^^^^^^^^^
  53. A transmitter stops sending the stream of images as a result of
  54. calling the ``.s_stream()`` callback. Some transmitters may stop the
  55. stream at a frame boundary whereas others stop immediately,
  56. effectively leaving the current frame unfinished. The receiver driver
  57. should not make assumptions either way, but function properly in both
  58. cases.
  59. Receiver drivers
  60. ----------------
  61. Before the receiver driver may enable the CSI-2 transmitter by using
  62. the :c:type:`v4l2_subdev_video_ops`->s_stream(), it must have powered
  63. the transmitter up by using the
  64. :c:type:`v4l2_subdev_core_ops`->s_power() callback. This may take
  65. place either indirectly by using :c:func:`v4l2_pipeline_pm_get` or
  66. directly.
  67. Formats
  68. -------
  69. The media bus pixel codes document parallel formats. Should the pixel data be
  70. transported over a serial bus, the media bus pixel code that describes a
  71. parallel format that transfers a sample on a single clock cycle is used.