csi2.rst 2.5 KB

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