mgb4.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. .. SPDX-License-Identifier: GPL-2.0
  2. The mgb4 driver
  3. ===============
  4. sysfs interface
  5. ---------------
  6. The mgb4 driver provides a sysfs interface, that is used to configure video
  7. stream related parameters (some of them must be set properly before the v4l2
  8. device can be opened) and obtain the video device/stream status.
  9. There are two types of parameters - global / PCI card related, found under
  10. ``/sys/class/video4linux/videoX/device`` and module specific found under
  11. ``/sys/class/video4linux/videoX``.
  12. Global (PCI card) parameters
  13. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  14. **module_type** (R):
  15. Module type.
  16. | 0 - No module present
  17. | 1 - FPDL3
  18. | 2 - GMSL
  19. **module_version** (R):
  20. Module version number. Zero in case of a missing module.
  21. **fw_type** (R):
  22. Firmware type.
  23. | 1 - FPDL3
  24. | 2 - GMSL
  25. **fw_version** (R):
  26. Firmware version number.
  27. **serial_number** (R):
  28. Card serial number. The format is::
  29. PRODUCT-REVISION-SERIES-SERIAL
  30. where each component is a 8b number.
  31. Common FPDL3/GMSL input parameters
  32. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  33. **input_id** (R):
  34. Input number ID, zero based.
  35. **oldi_lane_width** (RW):
  36. Number of deserializer output lanes.
  37. | 0 - single
  38. | 1 - dual (default)
  39. **color_mapping** (RW):
  40. Mapping of the incoming bits in the signal to the colour bits of the pixels.
  41. | 0 - OLDI/JEIDA
  42. | 1 - SPWG/VESA (default)
  43. **link_status** (R):
  44. Video link status. If the link is locked, chips are properly connected and
  45. communicating at the same speed and protocol. The link can be locked without
  46. an active video stream.
  47. A value of 0 is equivalent to the V4L2_IN_ST_NO_SYNC flag of the V4L2
  48. VIDIOC_ENUMINPUT status bits.
  49. | 0 - unlocked
  50. | 1 - locked
  51. **stream_status** (R):
  52. Video stream status. A stream is detected if the link is locked, the input
  53. pixel clock is running and the DE signal is moving.
  54. A value of 0 is equivalent to the V4L2_IN_ST_NO_SIGNAL flag of the V4L2
  55. VIDIOC_ENUMINPUT status bits.
  56. | 0 - not detected
  57. | 1 - detected
  58. **video_width** (R):
  59. Video stream width. This is the actual width as detected by the HW.
  60. The value is identical to what VIDIOC_QUERY_DV_TIMINGS returns in the width
  61. field of the v4l2_bt_timings struct.
  62. **video_height** (R):
  63. Video stream height. This is the actual height as detected by the HW.
  64. The value is identical to what VIDIOC_QUERY_DV_TIMINGS returns in the height
  65. field of the v4l2_bt_timings struct.
  66. **vsync_status** (R):
  67. The type of VSYNC pulses as detected by the video format detector.
  68. The value is equivalent to the flags returned by VIDIOC_QUERY_DV_TIMINGS in
  69. the polarities field of the v4l2_bt_timings struct.
  70. | 0 - active low
  71. | 1 - active high
  72. | 2 - not available
  73. **hsync_status** (R):
  74. The type of HSYNC pulses as detected by the video format detector.
  75. The value is equivalent to the flags returned by VIDIOC_QUERY_DV_TIMINGS in
  76. the polarities field of the v4l2_bt_timings struct.
  77. | 0 - active low
  78. | 1 - active high
  79. | 2 - not available
  80. **vsync_gap_length** (RW):
  81. If the incoming video signal does not contain synchronization VSYNC and
  82. HSYNC pulses, these must be generated internally in the FPGA to achieve
  83. the correct frame ordering. This value indicates, how many "empty" pixels
  84. (pixels with deasserted Data Enable signal) are necessary to generate the
  85. internal VSYNC pulse.
  86. **hsync_gap_length** (RW):
  87. If the incoming video signal does not contain synchronization VSYNC and
  88. HSYNC pulses, these must be generated internally in the FPGA to achieve
  89. the correct frame ordering. This value indicates, how many "empty" pixels
  90. (pixels with deasserted Data Enable signal) are necessary to generate the
  91. internal HSYNC pulse. The value must be greater than 1 and smaller than
  92. vsync_gap_length.
  93. **pclk_frequency** (R):
  94. Input pixel clock frequency in kHz.
  95. The value is identical to what VIDIOC_QUERY_DV_TIMINGS returns in
  96. the pixelclock field of the v4l2_bt_timings struct.
  97. *Note: The frequency_range parameter must be set properly first to get
  98. a valid frequency here.*
  99. **hsync_width** (R):
  100. Width of the HSYNC signal in PCLK clock ticks.
  101. The value is identical to what VIDIOC_QUERY_DV_TIMINGS returns in
  102. the hsync field of the v4l2_bt_timings struct.
  103. **vsync_width** (R):
  104. Width of the VSYNC signal in PCLK clock ticks.
  105. The value is identical to what VIDIOC_QUERY_DV_TIMINGS returns in
  106. the vsync field of the v4l2_bt_timings struct.
  107. **hback_porch** (R):
  108. Number of PCLK pulses between deassertion of the HSYNC signal and the first
  109. valid pixel in the video line (marked by DE=1).
  110. The value is identical to what VIDIOC_QUERY_DV_TIMINGS returns in
  111. the hbackporch field of the v4l2_bt_timings struct.
  112. **hfront_porch** (R):
  113. Number of PCLK pulses between the end of the last valid pixel in the video
  114. line (marked by DE=1) and assertion of the HSYNC signal.
  115. The value is identical to what VIDIOC_QUERY_DV_TIMINGS returns in
  116. the hfrontporch field of the v4l2_bt_timings struct.
  117. **vback_porch** (R):
  118. Number of video lines between deassertion of the VSYNC signal and the video
  119. line with the first valid pixel (marked by DE=1).
  120. The value is identical to what VIDIOC_QUERY_DV_TIMINGS returns in
  121. the vbackporch field of the v4l2_bt_timings struct.
  122. **vfront_porch** (R):
  123. Number of video lines between the end of the last valid pixel line (marked
  124. by DE=1) and assertion of the VSYNC signal.
  125. The value is identical to what VIDIOC_QUERY_DV_TIMINGS returns in
  126. the vfrontporch field of the v4l2_bt_timings struct.
  127. **frequency_range** (RW)
  128. PLL frequency range of the OLDI input clock generator. The PLL frequency is
  129. derived from the Pixel Clock Frequency (PCLK) and is equal to PCLK if
  130. oldi_lane_width is set to "single" and PCLK/2 if oldi_lane_width is set to
  131. "dual".
  132. | 0 - PLL < 50MHz (default)
  133. | 1 - PLL >= 50MHz
  134. *Note: This parameter can not be changed while the input v4l2 device is
  135. open.*
  136. Common FPDL3/GMSL output parameters
  137. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  138. **output_id** (R):
  139. Output number ID, zero based.
  140. **video_source** (RW):
  141. Output video source. If set to 0 or 1, the source is the corresponding card
  142. input and the v4l2 output devices are disabled. If set to 2 or 3, the source
  143. is the corresponding v4l2 video output device. The default is
  144. the corresponding v4l2 output, i.e. 2 for OUT1 and 3 for OUT2.
  145. | 0 - input 0
  146. | 1 - input 1
  147. | 2 - v4l2 output 0
  148. | 3 - v4l2 output 1
  149. *Note: This parameter can not be changed while ANY of the input/output v4l2
  150. devices is open.*
  151. **display_width** (RW):
  152. Display width. There is no autodetection of the connected display, so the
  153. proper value must be set before the start of streaming. The default width
  154. is 1280.
  155. *Note: This parameter can not be changed while the output v4l2 device is
  156. open.*
  157. **display_height** (RW):
  158. Display height. There is no autodetection of the connected display, so the
  159. proper value must be set before the start of streaming. The default height
  160. is 640.
  161. *Note: This parameter can not be changed while the output v4l2 device is
  162. open.*
  163. **frame_rate** (RW):
  164. Output video signal frame rate limit in frames per second. Due to
  165. the limited output pixel clock steps, the card can not always generate
  166. a frame rate perfectly matching the value required by the connected display.
  167. Using this parameter one can limit the frame rate by "crippling" the signal
  168. so that the lines are not equal (the porches of the last line differ) but
  169. the signal appears like having the exact frame rate to the connected display.
  170. The default frame rate limit is 60Hz.
  171. **hsync_polarity** (RW):
  172. HSYNC signal polarity.
  173. | 0 - active low (default)
  174. | 1 - active high
  175. **vsync_polarity** (RW):
  176. VSYNC signal polarity.
  177. | 0 - active low (default)
  178. | 1 - active high
  179. **de_polarity** (RW):
  180. DE signal polarity.
  181. | 0 - active low
  182. | 1 - active high (default)
  183. **pclk_frequency** (RW):
  184. Output pixel clock frequency. Allowed values are between 25000-190000(kHz)
  185. and there is a non-linear stepping between two consecutive allowed
  186. frequencies. The driver finds the nearest allowed frequency to the given
  187. value and sets it. When reading this property, you get the exact
  188. frequency set by the driver. The default frequency is 61150kHz.
  189. *Note: This parameter can not be changed while the output v4l2 device is
  190. open.*
  191. **hsync_width** (RW):
  192. Width of the HSYNC signal in pixels. The default value is 40.
  193. **vsync_width** (RW):
  194. Width of the VSYNC signal in video lines. The default value is 20.
  195. **hback_porch** (RW):
  196. Number of PCLK pulses between deassertion of the HSYNC signal and the first
  197. valid pixel in the video line (marked by DE=1). The default value is 50.
  198. **hfront_porch** (RW):
  199. Number of PCLK pulses between the end of the last valid pixel in the video
  200. line (marked by DE=1) and assertion of the HSYNC signal. The default value
  201. is 50.
  202. **vback_porch** (RW):
  203. Number of video lines between deassertion of the VSYNC signal and the video
  204. line with the first valid pixel (marked by DE=1). The default value is 31.
  205. **vfront_porch** (RW):
  206. Number of video lines between the end of the last valid pixel line (marked
  207. by DE=1) and assertion of the VSYNC signal. The default value is 30.
  208. FPDL3 specific input parameters
  209. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  210. **fpdl3_input_width** (RW):
  211. Number of deserializer input lines.
  212. | 0 - auto (default)
  213. | 1 - single
  214. | 2 - dual
  215. FPDL3 specific output parameters
  216. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  217. **fpdl3_output_width** (RW):
  218. Number of serializer output lines.
  219. | 0 - auto (default)
  220. | 1 - single
  221. | 2 - dual
  222. GMSL specific input parameters
  223. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  224. **gmsl_mode** (RW):
  225. GMSL speed mode.
  226. | 0 - 12Gb/s (default)
  227. | 1 - 6Gb/s
  228. | 2 - 3Gb/s
  229. | 3 - 1.5Gb/s
  230. **gmsl_stream_id** (RW):
  231. The GMSL multi-stream contains up to four video streams. This parameter
  232. selects which stream is captured by the video input. The value is the
  233. zero-based index of the stream. The default stream id is 0.
  234. *Note: This parameter can not be changed while the input v4l2 device is
  235. open.*
  236. **gmsl_fec** (RW):
  237. GMSL Forward Error Correction (FEC).
  238. | 0 - disabled
  239. | 1 - enabled (default)
  240. MTD partitions
  241. --------------
  242. The mgb4 driver creates a MTD device with two partitions:
  243. - mgb4-fw.X - FPGA firmware.
  244. - mgb4-data.X - Factory settings, e.g. card serial number.
  245. The *mgb4-fw* partition is writable and is used for FW updates, *mgb4-data* is
  246. read-only. The *X* attached to the partition name represents the card number.
  247. Depending on the CONFIG_MTD_PARTITIONED_MASTER kernel configuration, you may
  248. also have a third partition named *mgb4-flash* available in the system. This
  249. partition represents the whole, unpartitioned, card's FLASH memory and one should
  250. not fiddle with it...
  251. IIO (triggers)
  252. --------------
  253. The mgb4 driver creates an Industrial I/O (IIO) device that provides trigger and
  254. signal level status capability. The following scan elements are available:
  255. **activity**:
  256. The trigger levels and pending status.
  257. | bit 1 - trigger 1 pending
  258. | bit 2 - trigger 2 pending
  259. | bit 5 - trigger 1 level
  260. | bit 6 - trigger 2 level
  261. **timestamp**:
  262. The trigger event timestamp.
  263. The iio device can operate either in "raw" mode where you can fetch the signal
  264. levels (activity bits 5 and 6) using sysfs access or in triggered buffer mode.
  265. In the triggered buffer mode you can follow the signal level changes (activity
  266. bits 1 and 2) using the iio device in /dev. If you enable the timestamps, you
  267. will also get the exact trigger event time that can be matched to a video frame
  268. (every mgb4 video frame has a timestamp with the same clock source).
  269. *Note: although the activity sample always contains all the status bits, it makes
  270. no sense to get the pending bits in raw mode or the level bits in the triggered
  271. buffer mode - the values do not represent valid data in such case.*