162306a36Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci.. _metadata:
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci******************
662306a36Sopenharmony_ciMetadata Interface
762306a36Sopenharmony_ci******************
862306a36Sopenharmony_ci
962306a36Sopenharmony_ciMetadata refers to any non-image data that supplements video frames with
1062306a36Sopenharmony_ciadditional information. This may include statistics computed over the image,
1162306a36Sopenharmony_ciframe capture parameters supplied by the image source or device specific
1262306a36Sopenharmony_ciparameters for specifying how the device processes images. This interface is
1362306a36Sopenharmony_ciintended for transfer of metadata between the userspace and the hardware and
1462306a36Sopenharmony_cicontrol of that operation.
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ciThe metadata interface is implemented on video device nodes. The device can be
1762306a36Sopenharmony_cidedicated to metadata or can support both video and metadata as specified in its
1862306a36Sopenharmony_cireported capabilities.
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ciQuerying Capabilities
2162306a36Sopenharmony_ci=====================
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ciDevice nodes supporting the metadata capture interface set the
2462306a36Sopenharmony_ci``V4L2_CAP_META_CAPTURE`` flag in the ``device_caps`` field of the
2562306a36Sopenharmony_ci:c:type:`v4l2_capability` structure returned by the :c:func:`VIDIOC_QUERYCAP`
2662306a36Sopenharmony_ciioctl. That flag means the device can capture metadata to memory. Similarly,
2762306a36Sopenharmony_cidevice nodes supporting metadata output interface set the
2862306a36Sopenharmony_ci``V4L2_CAP_META_OUTPUT`` flag in the ``device_caps`` field of
2962306a36Sopenharmony_ci:c:type:`v4l2_capability` structure. That flag means the device can read
3062306a36Sopenharmony_cimetadata from memory.
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ciAt least one of the read/write or streaming I/O methods must be supported.
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ciData Format Negotiation
3662306a36Sopenharmony_ci=======================
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ciThe metadata device uses the :ref:`format` ioctls to select the capture format.
3962306a36Sopenharmony_ciThe metadata buffer content format is bound to that selected format. In addition
4062306a36Sopenharmony_cito the basic :ref:`format` ioctls, the :c:func:`VIDIOC_ENUM_FMT` ioctl must be
4162306a36Sopenharmony_cisupported as well.
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ciTo use the :ref:`format` ioctls applications set the ``type`` field of the
4462306a36Sopenharmony_ci:c:type:`v4l2_format` structure to ``V4L2_BUF_TYPE_META_CAPTURE`` or to
4562306a36Sopenharmony_ci``V4L2_BUF_TYPE_META_OUTPUT`` and use the :c:type:`v4l2_meta_format` ``meta``
4662306a36Sopenharmony_cimember of the ``fmt`` union as needed per the desired operation. Both drivers
4762306a36Sopenharmony_ciand applications must set the remainder of the :c:type:`v4l2_format` structure
4862306a36Sopenharmony_cito 0.
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci.. c:type:: v4l2_meta_format
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci.. tabularcolumns:: |p{1.4cm}|p{2.4cm}|p{13.5cm}|
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci.. flat-table:: struct v4l2_meta_format
5562306a36Sopenharmony_ci    :header-rows:  0
5662306a36Sopenharmony_ci    :stub-columns: 0
5762306a36Sopenharmony_ci    :widths:       1 1 2
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci    * - __u32
6062306a36Sopenharmony_ci      - ``dataformat``
6162306a36Sopenharmony_ci      - The data format, set by the application. This is a little endian
6262306a36Sopenharmony_ci        :ref:`four character code <v4l2-fourcc>`. V4L2 defines metadata formats
6362306a36Sopenharmony_ci        in :ref:`meta-formats`.
6462306a36Sopenharmony_ci    * - __u32
6562306a36Sopenharmony_ci      - ``buffersize``
6662306a36Sopenharmony_ci      - Maximum buffer size in bytes required for data. The value is set by the
6762306a36Sopenharmony_ci        driver.
68