buffer.rst 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. .. -*- coding: utf-8; mode: rst -*-
  2. .. _buffer:
  3. *******
  4. Buffers
  5. *******
  6. A buffer contains data exchanged by application and driver using one of
  7. the Streaming I/O methods. In the multi-planar API, the data is held in
  8. planes, while the buffer structure acts as a container for the planes.
  9. Only pointers to buffers (planes) are exchanged, the data itself is not
  10. copied. These pointers, together with meta-information like timestamps
  11. or field parity, are stored in a struct :c:type:`v4l2_buffer`,
  12. argument to the :ref:`VIDIOC_QUERYBUF`,
  13. :ref:`VIDIOC_QBUF` and
  14. :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl. In the multi-planar API,
  15. some plane-specific members of struct :c:type:`v4l2_buffer`,
  16. such as pointers and sizes for each plane, are stored in struct
  17. struct :c:type:`v4l2_plane` instead. In that case, struct
  18. struct :c:type:`v4l2_buffer` contains an array of plane structures.
  19. Dequeued video buffers come with timestamps. The driver decides at which
  20. part of the frame and with which clock the timestamp is taken. Please
  21. see flags in the masks ``V4L2_BUF_FLAG_TIMESTAMP_MASK`` and
  22. ``V4L2_BUF_FLAG_TSTAMP_SRC_MASK`` in :ref:`buffer-flags`. These flags
  23. are always valid and constant across all buffers during the whole video
  24. stream. Changes in these flags may take place as a side effect of
  25. :ref:`VIDIOC_S_INPUT <VIDIOC_G_INPUT>` or
  26. :ref:`VIDIOC_S_OUTPUT <VIDIOC_G_OUTPUT>` however. The
  27. ``V4L2_BUF_FLAG_TIMESTAMP_COPY`` timestamp type which is used by e.g. on
  28. mem-to-mem devices is an exception to the rule: the timestamp source
  29. flags are copied from the OUTPUT video buffer to the CAPTURE video
  30. buffer.
  31. .. c:type:: v4l2_buffer
  32. struct v4l2_buffer
  33. ==================
  34. .. tabularcolumns:: |p{2.8cm}|p{2.5cm}|p{1.3cm}|p{10.5cm}|
  35. .. cssclass:: longtable
  36. .. flat-table:: struct v4l2_buffer
  37. :header-rows: 0
  38. :stub-columns: 0
  39. :widths: 1 2 1 10
  40. * - __u32
  41. - ``index``
  42. -
  43. - Number of the buffer, set by the application except when calling
  44. :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>`, then it is set by the
  45. driver. This field can range from zero to the number of buffers
  46. allocated with the :ref:`VIDIOC_REQBUFS` ioctl
  47. (struct :c:type:`v4l2_requestbuffers`
  48. ``count``), plus any buffers allocated with
  49. :ref:`VIDIOC_CREATE_BUFS` minus one.
  50. * - __u32
  51. - ``type``
  52. -
  53. - Type of the buffer, same as struct
  54. :c:type:`v4l2_format` ``type`` or struct
  55. :c:type:`v4l2_requestbuffers` ``type``, set
  56. by the application. See :c:type:`v4l2_buf_type`
  57. * - __u32
  58. - ``bytesused``
  59. -
  60. - The number of bytes occupied by the data in the buffer. It depends
  61. on the negotiated data format and may change with each buffer for
  62. compressed variable size data like JPEG images. Drivers must set
  63. this field when ``type`` refers to a capture stream, applications
  64. when it refers to an output stream. If the application sets this
  65. to 0 for an output stream, then ``bytesused`` will be set to the
  66. size of the buffer (see the ``length`` field of this struct) by
  67. the driver. For multiplanar formats this field is ignored and the
  68. ``planes`` pointer is used instead.
  69. * - __u32
  70. - ``flags``
  71. -
  72. - Flags set by the application or driver, see :ref:`buffer-flags`.
  73. * - __u32
  74. - ``field``
  75. -
  76. - Indicates the field order of the image in the buffer, see
  77. :c:type:`v4l2_field`. This field is not used when the buffer
  78. contains VBI data. Drivers must set it when ``type`` refers to a
  79. capture stream, applications when it refers to an output stream.
  80. * - struct timeval
  81. - ``timestamp``
  82. -
  83. - For capture streams this is time when the first data byte was
  84. captured, as returned by the :c:func:`clock_gettime()` function
  85. for the relevant clock id; see ``V4L2_BUF_FLAG_TIMESTAMP_*`` in
  86. :ref:`buffer-flags`. For output streams the driver stores the
  87. time at which the last data byte was actually sent out in the
  88. ``timestamp`` field. This permits applications to monitor the
  89. drift between the video and system clock. For output streams that
  90. use ``V4L2_BUF_FLAG_TIMESTAMP_COPY`` the application has to fill
  91. in the timestamp which will be copied by the driver to the capture
  92. stream.
  93. * - struct :c:type:`v4l2_timecode`
  94. - ``timecode``
  95. -
  96. - When ``type`` is ``V4L2_BUF_TYPE_VIDEO_CAPTURE`` and the
  97. ``V4L2_BUF_FLAG_TIMECODE`` flag is set in ``flags``, this
  98. structure contains a frame timecode. In
  99. :c:type:`V4L2_FIELD_ALTERNATE <v4l2_field>` mode the top and
  100. bottom field contain the same timecode. Timecodes are intended to
  101. help video editing and are typically recorded on video tapes, but
  102. also embedded in compressed formats like MPEG. This field is
  103. independent of the ``timestamp`` and ``sequence`` fields.
  104. * - __u32
  105. - ``sequence``
  106. -
  107. - Set by the driver, counting the frames (not fields!) in sequence.
  108. This field is set for both input and output devices.
  109. * - :cspan:`3`
  110. In :c:type:`V4L2_FIELD_ALTERNATE <v4l2_field>` mode the top and
  111. bottom field have the same sequence number. The count starts at
  112. zero and includes dropped or repeated frames. A dropped frame was
  113. received by an input device but could not be stored due to lack of
  114. free buffer space. A repeated frame was displayed again by an
  115. output device because the application did not pass new data in
  116. time.
  117. .. note::
  118. This may count the frames received e.g. over USB, without
  119. taking into account the frames dropped by the remote hardware due
  120. to limited compression throughput or bus bandwidth. These devices
  121. identify by not enumerating any video standards, see
  122. :ref:`standard`.
  123. * - __u32
  124. - ``memory``
  125. -
  126. - This field must be set by applications and/or drivers in
  127. accordance with the selected I/O method. See :c:type:`v4l2_memory`
  128. * - union
  129. - ``m``
  130. * -
  131. - __u32
  132. - ``offset``
  133. - For the single-planar API and when ``memory`` is
  134. ``V4L2_MEMORY_MMAP`` this is the offset of the buffer from the
  135. start of the device memory. The value is returned by the driver
  136. and apart of serving as parameter to the
  137. :ref:`mmap() <func-mmap>` function not useful for applications.
  138. See :ref:`mmap` for details
  139. * -
  140. - unsigned long
  141. - ``userptr``
  142. - For the single-planar API and when ``memory`` is
  143. ``V4L2_MEMORY_USERPTR`` this is a pointer to the buffer (casted to
  144. unsigned long type) in virtual memory, set by the application. See
  145. :ref:`userp` for details.
  146. * -
  147. - struct v4l2_plane
  148. - ``*planes``
  149. - When using the multi-planar API, contains a userspace pointer to
  150. an array of struct :c:type:`v4l2_plane`. The size of
  151. the array should be put in the ``length`` field of this
  152. struct :c:type:`v4l2_buffer` structure.
  153. * -
  154. - int
  155. - ``fd``
  156. - For the single-plane API and when ``memory`` is
  157. ``V4L2_MEMORY_DMABUF`` this is the file descriptor associated with
  158. a DMABUF buffer.
  159. * - __u32
  160. - ``length``
  161. -
  162. - Size of the buffer (not the payload) in bytes for the
  163. single-planar API. This is set by the driver based on the calls to
  164. :ref:`VIDIOC_REQBUFS` and/or
  165. :ref:`VIDIOC_CREATE_BUFS`. For the
  166. multi-planar API the application sets this to the number of
  167. elements in the ``planes`` array. The driver will fill in the
  168. actual number of valid elements in that array.
  169. * - __u32
  170. - ``reserved2``
  171. -
  172. - A place holder for future extensions. Drivers and applications
  173. must set this to 0.
  174. * - __u32
  175. - ``reserved``
  176. -
  177. - A place holder for future extensions. Drivers and applications
  178. must set this to 0.
  179. .. c:type:: v4l2_plane
  180. struct v4l2_plane
  181. =================
  182. .. tabularcolumns:: |p{3.5cm}|p{3.5cm}|p{3.5cm}|p{7.0cm}|
  183. .. cssclass:: longtable
  184. .. flat-table::
  185. :header-rows: 0
  186. :stub-columns: 0
  187. :widths: 1 1 1 2
  188. * - __u32
  189. - ``bytesused``
  190. -
  191. - The number of bytes occupied by data in the plane (its payload).
  192. Drivers must set this field when ``type`` refers to a capture
  193. stream, applications when it refers to an output stream. If the
  194. application sets this to 0 for an output stream, then
  195. ``bytesused`` will be set to the size of the plane (see the
  196. ``length`` field of this struct) by the driver.
  197. .. note::
  198. Note that the actual image data starts at ``data_offset``
  199. which may not be 0.
  200. * - __u32
  201. - ``length``
  202. -
  203. - Size in bytes of the plane (not its payload). This is set by the
  204. driver based on the calls to
  205. :ref:`VIDIOC_REQBUFS` and/or
  206. :ref:`VIDIOC_CREATE_BUFS`.
  207. * - union
  208. - ``m``
  209. -
  210. -
  211. * -
  212. - __u32
  213. - ``mem_offset``
  214. - When the memory type in the containing struct
  215. :c:type:`v4l2_buffer` is ``V4L2_MEMORY_MMAP``, this
  216. is the value that should be passed to :ref:`mmap() <func-mmap>`,
  217. similar to the ``offset`` field in struct
  218. :c:type:`v4l2_buffer`.
  219. * -
  220. - unsigned long
  221. - ``userptr``
  222. - When the memory type in the containing struct
  223. :c:type:`v4l2_buffer` is ``V4L2_MEMORY_USERPTR``,
  224. this is a userspace pointer to the memory allocated for this plane
  225. by an application.
  226. * -
  227. - int
  228. - ``fd``
  229. - When the memory type in the containing struct
  230. :c:type:`v4l2_buffer` is ``V4L2_MEMORY_DMABUF``,
  231. this is a file descriptor associated with a DMABUF buffer, similar
  232. to the ``fd`` field in struct :c:type:`v4l2_buffer`.
  233. * - __u32
  234. - ``data_offset``
  235. -
  236. - Offset in bytes to video data in the plane. Drivers must set this
  237. field when ``type`` refers to a capture stream, applications when
  238. it refers to an output stream.
  239. .. note::
  240. That data_offset is included in ``bytesused``. So the
  241. size of the image in the plane is ``bytesused``-``data_offset``
  242. at offset ``data_offset`` from the start of the plane.
  243. * - __u32
  244. - ``reserved[11]``
  245. -
  246. - Reserved for future use. Should be zeroed by drivers and
  247. applications.
  248. .. c:type:: v4l2_buf_type
  249. enum v4l2_buf_type
  250. ==================
  251. .. cssclass:: longtable
  252. .. tabularcolumns:: |p{7.2cm}|p{0.6cm}|p{9.7cm}|
  253. .. flat-table::
  254. :header-rows: 0
  255. :stub-columns: 0
  256. :widths: 4 1 9
  257. * - ``V4L2_BUF_TYPE_VIDEO_CAPTURE``
  258. - 1
  259. - Buffer of a single-planar video capture stream, see
  260. :ref:`capture`.
  261. * - ``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE``
  262. - 9
  263. - Buffer of a multi-planar video capture stream, see
  264. :ref:`capture`.
  265. * - ``V4L2_BUF_TYPE_VIDEO_OUTPUT``
  266. - 2
  267. - Buffer of a single-planar video output stream, see
  268. :ref:`output`.
  269. * - ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE``
  270. - 10
  271. - Buffer of a multi-planar video output stream, see :ref:`output`.
  272. * - ``V4L2_BUF_TYPE_VIDEO_OVERLAY``
  273. - 3
  274. - Buffer for video overlay, see :ref:`overlay`.
  275. * - ``V4L2_BUF_TYPE_VBI_CAPTURE``
  276. - 4
  277. - Buffer of a raw VBI capture stream, see :ref:`raw-vbi`.
  278. * - ``V4L2_BUF_TYPE_VBI_OUTPUT``
  279. - 5
  280. - Buffer of a raw VBI output stream, see :ref:`raw-vbi`.
  281. * - ``V4L2_BUF_TYPE_SLICED_VBI_CAPTURE``
  282. - 6
  283. - Buffer of a sliced VBI capture stream, see :ref:`sliced`.
  284. * - ``V4L2_BUF_TYPE_SLICED_VBI_OUTPUT``
  285. - 7
  286. - Buffer of a sliced VBI output stream, see :ref:`sliced`.
  287. * - ``V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY``
  288. - 8
  289. - Buffer for video output overlay (OSD), see :ref:`osd`.
  290. * - ``V4L2_BUF_TYPE_SDR_CAPTURE``
  291. - 11
  292. - Buffer for Software Defined Radio (SDR) capture stream, see
  293. :ref:`sdr`.
  294. * - ``V4L2_BUF_TYPE_SDR_OUTPUT``
  295. - 12
  296. - Buffer for Software Defined Radio (SDR) output stream, see
  297. :ref:`sdr`.
  298. .. _buffer-flags:
  299. Buffer Flags
  300. ============
  301. .. tabularcolumns:: |p{7.0cm}|p{2.2cm}|p{8.3cm}|
  302. .. cssclass:: longtable
  303. .. flat-table::
  304. :header-rows: 0
  305. :stub-columns: 0
  306. :widths: 3 1 4
  307. * .. _`V4L2-BUF-FLAG-MAPPED`:
  308. - ``V4L2_BUF_FLAG_MAPPED``
  309. - 0x00000001
  310. - The buffer resides in device memory and has been mapped into the
  311. application's address space, see :ref:`mmap` for details.
  312. Drivers set or clear this flag when the
  313. :ref:`VIDIOC_QUERYBUF`,
  314. :ref:`VIDIOC_QBUF` or
  315. :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl is called. Set by the
  316. driver.
  317. * .. _`V4L2-BUF-FLAG-QUEUED`:
  318. - ``V4L2_BUF_FLAG_QUEUED``
  319. - 0x00000002
  320. - Internally drivers maintain two buffer queues, an incoming and
  321. outgoing queue. When this flag is set, the buffer is currently on
  322. the incoming queue. It automatically moves to the outgoing queue
  323. after the buffer has been filled (capture devices) or displayed
  324. (output devices). Drivers set or clear this flag when the
  325. ``VIDIOC_QUERYBUF`` ioctl is called. After (successful) calling
  326. the ``VIDIOC_QBUF``\ ioctl it is always set and after
  327. ``VIDIOC_DQBUF`` always cleared.
  328. * .. _`V4L2-BUF-FLAG-DONE`:
  329. - ``V4L2_BUF_FLAG_DONE``
  330. - 0x00000004
  331. - When this flag is set, the buffer is currently on the outgoing
  332. queue, ready to be dequeued from the driver. Drivers set or clear
  333. this flag when the ``VIDIOC_QUERYBUF`` ioctl is called. After
  334. calling the ``VIDIOC_QBUF`` or ``VIDIOC_DQBUF`` it is always
  335. cleared. Of course a buffer cannot be on both queues at the same
  336. time, the ``V4L2_BUF_FLAG_QUEUED`` and ``V4L2_BUF_FLAG_DONE`` flag
  337. are mutually exclusive. They can be both cleared however, then the
  338. buffer is in "dequeued" state, in the application domain so to
  339. say.
  340. * .. _`V4L2-BUF-FLAG-ERROR`:
  341. - ``V4L2_BUF_FLAG_ERROR``
  342. - 0x00000040
  343. - When this flag is set, the buffer has been dequeued successfully,
  344. although the data might have been corrupted. This is recoverable,
  345. streaming may continue as normal and the buffer may be reused
  346. normally. Drivers set this flag when the ``VIDIOC_DQBUF`` ioctl is
  347. called.
  348. * .. _`V4L2-BUF-FLAG-KEYFRAME`:
  349. - ``V4L2_BUF_FLAG_KEYFRAME``
  350. - 0x00000008
  351. - Drivers set or clear this flag when calling the ``VIDIOC_DQBUF``
  352. ioctl. It may be set by video capture devices when the buffer
  353. contains a compressed image which is a key frame (or field), i. e.
  354. can be decompressed on its own. Also known as an I-frame.
  355. Applications can set this bit when ``type`` refers to an output
  356. stream.
  357. * .. _`V4L2-BUF-FLAG-PFRAME`:
  358. - ``V4L2_BUF_FLAG_PFRAME``
  359. - 0x00000010
  360. - Similar to ``V4L2_BUF_FLAG_KEYFRAME`` this flags predicted frames
  361. or fields which contain only differences to a previous key frame.
  362. Applications can set this bit when ``type`` refers to an output
  363. stream.
  364. * .. _`V4L2-BUF-FLAG-BFRAME`:
  365. - ``V4L2_BUF_FLAG_BFRAME``
  366. - 0x00000020
  367. - Similar to ``V4L2_BUF_FLAG_KEYFRAME`` this flags a bi-directional
  368. predicted frame or field which contains only the differences
  369. between the current frame and both the preceding and following key
  370. frames to specify its content. Applications can set this bit when
  371. ``type`` refers to an output stream.
  372. * .. _`V4L2-BUF-FLAG-TIMECODE`:
  373. - ``V4L2_BUF_FLAG_TIMECODE``
  374. - 0x00000100
  375. - The ``timecode`` field is valid. Drivers set or clear this flag
  376. when the ``VIDIOC_DQBUF`` ioctl is called. Applications can set
  377. this bit and the corresponding ``timecode`` structure when
  378. ``type`` refers to an output stream.
  379. * .. _`V4L2-BUF-FLAG-PREPARED`:
  380. - ``V4L2_BUF_FLAG_PREPARED``
  381. - 0x00000400
  382. - The buffer has been prepared for I/O and can be queued by the
  383. application. Drivers set or clear this flag when the
  384. :ref:`VIDIOC_QUERYBUF`,
  385. :ref:`VIDIOC_PREPARE_BUF <VIDIOC_QBUF>`,
  386. :ref:`VIDIOC_QBUF` or
  387. :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl is called.
  388. * .. _`V4L2-BUF-FLAG-NO-CACHE-INVALIDATE`:
  389. - ``V4L2_BUF_FLAG_NO_CACHE_INVALIDATE``
  390. - 0x00000800
  391. - Caches do not have to be invalidated for this buffer. Typically
  392. applications shall use this flag if the data captured in the
  393. buffer is not going to be touched by the CPU, instead the buffer
  394. will, probably, be passed on to a DMA-capable hardware unit for
  395. further processing or output.
  396. * .. _`V4L2-BUF-FLAG-NO-CACHE-CLEAN`:
  397. - ``V4L2_BUF_FLAG_NO_CACHE_CLEAN``
  398. - 0x00001000
  399. - Caches do not have to be cleaned for this buffer. Typically
  400. applications shall use this flag for output buffers if the data in
  401. this buffer has not been created by the CPU but by some
  402. DMA-capable unit, in which case caches have not been used.
  403. * .. _`V4L2-BUF-FLAG-LAST`:
  404. - ``V4L2_BUF_FLAG_LAST``
  405. - 0x00100000
  406. - Last buffer produced by the hardware. mem2mem codec drivers set
  407. this flag on the capture queue for the last buffer when the
  408. :ref:`VIDIOC_QUERYBUF` or
  409. :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl is called. Due to
  410. hardware limitations, the last buffer may be empty. In this case
  411. the driver will set the ``bytesused`` field to 0, regardless of
  412. the format. Any Any subsequent call to the
  413. :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl will not block anymore,
  414. but return an ``EPIPE`` error code.
  415. * .. _`V4L2-BUF-FLAG-TIMESTAMP-MASK`:
  416. - ``V4L2_BUF_FLAG_TIMESTAMP_MASK``
  417. - 0x0000e000
  418. - Mask for timestamp types below. To test the timestamp type, mask
  419. out bits not belonging to timestamp type by performing a logical
  420. and operation with buffer flags and timestamp mask.
  421. * .. _`V4L2-BUF-FLAG-TIMESTAMP-UNKNOWN`:
  422. - ``V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN``
  423. - 0x00000000
  424. - Unknown timestamp type. This type is used by drivers before Linux
  425. 3.9 and may be either monotonic (see below) or realtime (wall
  426. clock). Monotonic clock has been favoured in embedded systems
  427. whereas most of the drivers use the realtime clock. Either kinds
  428. of timestamps are available in user space via
  429. :c:func:`clock_gettime` using clock IDs ``CLOCK_MONOTONIC``
  430. and ``CLOCK_REALTIME``, respectively.
  431. * .. _`V4L2-BUF-FLAG-TIMESTAMP-MONOTONIC`:
  432. - ``V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC``
  433. - 0x00002000
  434. - The buffer timestamp has been taken from the ``CLOCK_MONOTONIC``
  435. clock. To access the same clock outside V4L2, use
  436. :c:func:`clock_gettime`.
  437. * .. _`V4L2-BUF-FLAG-TIMESTAMP-COPY`:
  438. - ``V4L2_BUF_FLAG_TIMESTAMP_COPY``
  439. - 0x00004000
  440. - The CAPTURE buffer timestamp has been taken from the corresponding
  441. OUTPUT buffer. This flag applies only to mem2mem devices.
  442. * .. _`V4L2-BUF-FLAG-TSTAMP-SRC-MASK`:
  443. - ``V4L2_BUF_FLAG_TSTAMP_SRC_MASK``
  444. - 0x00070000
  445. - Mask for timestamp sources below. The timestamp source defines the
  446. point of time the timestamp is taken in relation to the frame.
  447. Logical 'and' operation between the ``flags`` field and
  448. ``V4L2_BUF_FLAG_TSTAMP_SRC_MASK`` produces the value of the
  449. timestamp source. Applications must set the timestamp source when
  450. ``type`` refers to an output stream and
  451. ``V4L2_BUF_FLAG_TIMESTAMP_COPY`` is set.
  452. * .. _`V4L2-BUF-FLAG-TSTAMP-SRC-EOF`:
  453. - ``V4L2_BUF_FLAG_TSTAMP_SRC_EOF``
  454. - 0x00000000
  455. - End Of Frame. The buffer timestamp has been taken when the last
  456. pixel of the frame has been received or the last pixel of the
  457. frame has been transmitted. In practice, software generated
  458. timestamps will typically be read from the clock a small amount of
  459. time after the last pixel has been received or transmitten,
  460. depending on the system and other activity in it.
  461. * .. _`V4L2-BUF-FLAG-TSTAMP-SRC-SOE`:
  462. - ``V4L2_BUF_FLAG_TSTAMP_SRC_SOE``
  463. - 0x00010000
  464. - Start Of Exposure. The buffer timestamp has been taken when the
  465. exposure of the frame has begun. This is only valid for the
  466. ``V4L2_BUF_TYPE_VIDEO_CAPTURE`` buffer type.
  467. .. c:type:: v4l2_memory
  468. enum v4l2_memory
  469. ================
  470. .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
  471. .. flat-table::
  472. :header-rows: 0
  473. :stub-columns: 0
  474. :widths: 3 1 4
  475. * - ``V4L2_MEMORY_MMAP``
  476. - 1
  477. - The buffer is used for :ref:`memory mapping <mmap>` I/O.
  478. * - ``V4L2_MEMORY_USERPTR``
  479. - 2
  480. - The buffer is used for :ref:`user pointer <userp>` I/O.
  481. * - ``V4L2_MEMORY_OVERLAY``
  482. - 3
  483. - [to do]
  484. * - ``V4L2_MEMORY_DMABUF``
  485. - 4
  486. - The buffer is used for :ref:`DMA shared buffer <dmabuf>` I/O.
  487. Timecodes
  488. =========
  489. The struct :c:type:`v4l2_timecode` structure is designed to hold a
  490. :ref:`smpte12m` or similar timecode. (struct
  491. struct :c:type:`timeval` timestamps are stored in struct
  492. :c:type:`v4l2_buffer` field ``timestamp``.)
  493. .. c:type:: v4l2_timecode
  494. struct v4l2_timecode
  495. --------------------
  496. .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
  497. .. flat-table::
  498. :header-rows: 0
  499. :stub-columns: 0
  500. :widths: 1 1 2
  501. * - __u32
  502. - ``type``
  503. - Frame rate the timecodes are based on, see :ref:`timecode-type`.
  504. * - __u32
  505. - ``flags``
  506. - Timecode flags, see :ref:`timecode-flags`.
  507. * - __u8
  508. - ``frames``
  509. - Frame count, 0 ... 23/24/29/49/59, depending on the type of
  510. timecode.
  511. * - __u8
  512. - ``seconds``
  513. - Seconds count, 0 ... 59. This is a binary, not BCD number.
  514. * - __u8
  515. - ``minutes``
  516. - Minutes count, 0 ... 59. This is a binary, not BCD number.
  517. * - __u8
  518. - ``hours``
  519. - Hours count, 0 ... 29. This is a binary, not BCD number.
  520. * - __u8
  521. - ``userbits``\ [4]
  522. - The "user group" bits from the timecode.
  523. .. _timecode-type:
  524. Timecode Types
  525. --------------
  526. .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
  527. .. flat-table::
  528. :header-rows: 0
  529. :stub-columns: 0
  530. :widths: 3 1 4
  531. * - ``V4L2_TC_TYPE_24FPS``
  532. - 1
  533. - 24 frames per second, i. e. film.
  534. * - ``V4L2_TC_TYPE_25FPS``
  535. - 2
  536. - 25 frames per second, i. e. PAL or SECAM video.
  537. * - ``V4L2_TC_TYPE_30FPS``
  538. - 3
  539. - 30 frames per second, i. e. NTSC video.
  540. * - ``V4L2_TC_TYPE_50FPS``
  541. - 4
  542. -
  543. * - ``V4L2_TC_TYPE_60FPS``
  544. - 5
  545. -
  546. .. _timecode-flags:
  547. Timecode Flags
  548. --------------
  549. .. tabularcolumns:: |p{6.6cm}|p{1.4cm}|p{9.5cm}|
  550. .. flat-table::
  551. :header-rows: 0
  552. :stub-columns: 0
  553. :widths: 3 1 4
  554. * - ``V4L2_TC_FLAG_DROPFRAME``
  555. - 0x0001
  556. - Indicates "drop frame" semantics for counting frames in 29.97 fps
  557. material. When set, frame numbers 0 and 1 at the start of each
  558. minute, except minutes 0, 10, 20, 30, 40, 50 are omitted from the
  559. count.
  560. * - ``V4L2_TC_FLAG_COLORFRAME``
  561. - 0x0002
  562. - The "color frame" flag.
  563. * - ``V4L2_TC_USERBITS_field``
  564. - 0x000C
  565. - Field mask for the "binary group flags".
  566. * - ``V4L2_TC_USERBITS_USERDEFINED``
  567. - 0x0000
  568. - Unspecified format.
  569. * - ``V4L2_TC_USERBITS_8BITCHARS``
  570. - 0x0008
  571. - 8-bit ISO characters.