dev-meta.rst 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
  2. .. c:namespace:: V4L
  3. .. _metadata:
  4. ******************
  5. Metadata Interface
  6. ******************
  7. Metadata refers to any non-image data that supplements video frames with
  8. additional information. This may include statistics computed over the image,
  9. frame capture parameters supplied by the image source or device specific
  10. parameters for specifying how the device processes images. This interface is
  11. intended for transfer of metadata between the userspace and the hardware and
  12. control of that operation.
  13. The metadata interface is implemented on video device nodes. The device can be
  14. dedicated to metadata or can support both video and metadata as specified in its
  15. reported capabilities.
  16. Querying Capabilities
  17. =====================
  18. Device nodes supporting the metadata capture interface set the
  19. ``V4L2_CAP_META_CAPTURE`` flag in the ``device_caps`` field of the
  20. :c:type:`v4l2_capability` structure returned by the :c:func:`VIDIOC_QUERYCAP`
  21. ioctl. That flag means the device can capture metadata to memory. Similarly,
  22. device nodes supporting metadata output interface set the
  23. ``V4L2_CAP_META_OUTPUT`` flag in the ``device_caps`` field of
  24. :c:type:`v4l2_capability` structure. That flag means the device can read
  25. metadata from memory.
  26. At least one of the read/write or streaming I/O methods must be supported.
  27. Data Format Negotiation
  28. =======================
  29. The metadata device uses the :ref:`format` ioctls to select the capture format.
  30. The metadata buffer content format is bound to that selected format. In addition
  31. to the basic :ref:`format` ioctls, the :c:func:`VIDIOC_ENUM_FMT` ioctl must be
  32. supported as well.
  33. To use the :ref:`format` ioctls applications set the ``type`` field of the
  34. :c:type:`v4l2_format` structure to ``V4L2_BUF_TYPE_META_CAPTURE`` or to
  35. ``V4L2_BUF_TYPE_META_OUTPUT`` and use the :c:type:`v4l2_meta_format` ``meta``
  36. member of the ``fmt`` union as needed per the desired operation. Both drivers
  37. and applications must set the remainder of the :c:type:`v4l2_format` structure
  38. to 0.
  39. Devices that capture metadata by line have the struct v4l2_fmtdesc
  40. ``V4L2_FMT_FLAG_META_LINE_BASED`` flag set for :c:func:`VIDIOC_ENUM_FMT`. Such
  41. devices can typically also :ref:`capture image data <capture>`. This primarily
  42. involves devices that receive the data from a different devices such as a camera
  43. sensor.
  44. .. c:type:: v4l2_meta_format
  45. .. tabularcolumns:: |p{1.4cm}|p{2.4cm}|p{13.5cm}|
  46. .. flat-table:: struct v4l2_meta_format
  47. :header-rows: 0
  48. :stub-columns: 0
  49. :widths: 1 1 2
  50. * - __u32
  51. - ``dataformat``
  52. - The data format, set by the application. This is a little endian
  53. :ref:`four character code <v4l2-fourcc>`. V4L2 defines metadata formats
  54. in :ref:`meta-formats`.
  55. * - __u32
  56. - ``buffersize``
  57. - Maximum buffer size in bytes required for data. The value is set by the
  58. driver.
  59. * - __u32
  60. - ``width``
  61. - Width of a line of metadata in Data Units. Valid when
  62. :c:type`v4l2_fmtdesc` flag ``V4L2_FMT_FLAG_META_LINE_BASED`` is set,
  63. otherwise zero. See :c:func:`VIDIOC_ENUM_FMT`.
  64. * - __u32
  65. - ``height``
  66. - Number of rows of metadata. Valid when :c:type`v4l2_fmtdesc` flag
  67. ``V4L2_FMT_FLAG_META_LINE_BASED`` is set, otherwise zero. See
  68. :c:func:`VIDIOC_ENUM_FMT`.
  69. * - __u32
  70. - ``bytesperline``
  71. - Offset in bytes between the beginning of two consecutive lines. Valid
  72. when :c:type`v4l2_fmtdesc` flag ``V4L2_FMT_FLAG_META_LINE_BASED`` is
  73. set, otherwise zero. See :c:func:`VIDIOC_ENUM_FMT`.