18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ci.. _metadata:
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci******************
68c2ecf20Sopenharmony_ciMetadata Interface
78c2ecf20Sopenharmony_ci******************
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ciMetadata refers to any non-image data that supplements video frames with
108c2ecf20Sopenharmony_ciadditional information. This may include statistics computed over the image,
118c2ecf20Sopenharmony_ciframe capture parameters supplied by the image source or device specific
128c2ecf20Sopenharmony_ciparameters for specifying how the device processes images. This interface is
138c2ecf20Sopenharmony_ciintended for transfer of metadata between the userspace and the hardware and
148c2ecf20Sopenharmony_cicontrol of that operation.
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ciThe metadata interface is implemented on video device nodes. The device can be
178c2ecf20Sopenharmony_cidedicated to metadata or can support both video and metadata as specified in its
188c2ecf20Sopenharmony_cireported capabilities.
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ciQuerying Capabilities
218c2ecf20Sopenharmony_ci=====================
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ciDevice nodes supporting the metadata capture interface set the
248c2ecf20Sopenharmony_ci``V4L2_CAP_META_CAPTURE`` flag in the ``device_caps`` field of the
258c2ecf20Sopenharmony_ci:c:type:`v4l2_capability` structure returned by the :c:func:`VIDIOC_QUERYCAP`
268c2ecf20Sopenharmony_ciioctl. That flag means the device can capture metadata to memory. Similarly,
278c2ecf20Sopenharmony_cidevice nodes supporting metadata output interface set the
288c2ecf20Sopenharmony_ci``V4L2_CAP_META_OUTPUT`` flag in the ``device_caps`` field of
298c2ecf20Sopenharmony_ci:c:type:`v4l2_capability` structure. That flag means the device can read
308c2ecf20Sopenharmony_cimetadata from memory.
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ciAt least one of the read/write or streaming I/O methods must be supported.
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ciData Format Negotiation
368c2ecf20Sopenharmony_ci=======================
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ciThe metadata device uses the :ref:`format` ioctls to select the capture format.
398c2ecf20Sopenharmony_ciThe metadata buffer content format is bound to that selected format. In addition
408c2ecf20Sopenharmony_cito the basic :ref:`format` ioctls, the :c:func:`VIDIOC_ENUM_FMT` ioctl must be
418c2ecf20Sopenharmony_cisupported as well.
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ciTo use the :ref:`format` ioctls applications set the ``type`` field of the
448c2ecf20Sopenharmony_ci:c:type:`v4l2_format` structure to ``V4L2_BUF_TYPE_META_CAPTURE`` or to
458c2ecf20Sopenharmony_ci``V4L2_BUF_TYPE_META_OUTPUT`` and use the :c:type:`v4l2_meta_format` ``meta``
468c2ecf20Sopenharmony_cimember of the ``fmt`` union as needed per the desired operation. Both drivers
478c2ecf20Sopenharmony_ciand applications must set the remainder of the :c:type:`v4l2_format` structure
488c2ecf20Sopenharmony_cito 0.
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci.. c:type:: v4l2_meta_format
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{1.4cm}|p{2.2cm}|p{13.9cm}|
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci.. flat-table:: struct v4l2_meta_format
558c2ecf20Sopenharmony_ci    :header-rows:  0
568c2ecf20Sopenharmony_ci    :stub-columns: 0
578c2ecf20Sopenharmony_ci    :widths:       1 1 2
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci    * - __u32
608c2ecf20Sopenharmony_ci      - ``dataformat``
618c2ecf20Sopenharmony_ci      - The data format, set by the application. This is a little endian
628c2ecf20Sopenharmony_ci        :ref:`four character code <v4l2-fourcc>`. V4L2 defines metadata formats
638c2ecf20Sopenharmony_ci        in :ref:`meta-formats`.
648c2ecf20Sopenharmony_ci    * - __u32
658c2ecf20Sopenharmony_ci      - ``buffersize``
668c2ecf20Sopenharmony_ci      - Maximum buffer size in bytes required for data. The value is set by the
678c2ecf20Sopenharmony_ci        driver.
68