xref: /OK3568_Linux_fs/kernel/Documentation/userspace-api/media/v4l/dev-meta.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2*4882a593Smuzhiyun
3*4882a593Smuzhiyun.. _metadata:
4*4882a593Smuzhiyun
5*4882a593Smuzhiyun******************
6*4882a593SmuzhiyunMetadata Interface
7*4882a593Smuzhiyun******************
8*4882a593Smuzhiyun
9*4882a593SmuzhiyunMetadata refers to any non-image data that supplements video frames with
10*4882a593Smuzhiyunadditional information. This may include statistics computed over the image,
11*4882a593Smuzhiyunframe capture parameters supplied by the image source or device specific
12*4882a593Smuzhiyunparameters for specifying how the device processes images. This interface is
13*4882a593Smuzhiyunintended for transfer of metadata between the userspace and the hardware and
14*4882a593Smuzhiyuncontrol of that operation.
15*4882a593Smuzhiyun
16*4882a593SmuzhiyunThe metadata interface is implemented on video device nodes. The device can be
17*4882a593Smuzhiyundedicated to metadata or can support both video and metadata as specified in its
18*4882a593Smuzhiyunreported capabilities.
19*4882a593Smuzhiyun
20*4882a593SmuzhiyunQuerying Capabilities
21*4882a593Smuzhiyun=====================
22*4882a593Smuzhiyun
23*4882a593SmuzhiyunDevice nodes supporting the metadata capture interface set the
24*4882a593Smuzhiyun``V4L2_CAP_META_CAPTURE`` flag in the ``device_caps`` field of the
25*4882a593Smuzhiyun:c:type:`v4l2_capability` structure returned by the :c:func:`VIDIOC_QUERYCAP`
26*4882a593Smuzhiyunioctl. That flag means the device can capture metadata to memory. Similarly,
27*4882a593Smuzhiyundevice nodes supporting metadata output interface set the
28*4882a593Smuzhiyun``V4L2_CAP_META_OUTPUT`` flag in the ``device_caps`` field of
29*4882a593Smuzhiyun:c:type:`v4l2_capability` structure. That flag means the device can read
30*4882a593Smuzhiyunmetadata from memory.
31*4882a593Smuzhiyun
32*4882a593SmuzhiyunAt least one of the read/write or streaming I/O methods must be supported.
33*4882a593Smuzhiyun
34*4882a593Smuzhiyun
35*4882a593SmuzhiyunData Format Negotiation
36*4882a593Smuzhiyun=======================
37*4882a593Smuzhiyun
38*4882a593SmuzhiyunThe metadata device uses the :ref:`format` ioctls to select the capture format.
39*4882a593SmuzhiyunThe metadata buffer content format is bound to that selected format. In addition
40*4882a593Smuzhiyunto the basic :ref:`format` ioctls, the :c:func:`VIDIOC_ENUM_FMT` ioctl must be
41*4882a593Smuzhiyunsupported as well.
42*4882a593Smuzhiyun
43*4882a593SmuzhiyunTo use the :ref:`format` ioctls applications set the ``type`` field of the
44*4882a593Smuzhiyun:c:type:`v4l2_format` structure to ``V4L2_BUF_TYPE_META_CAPTURE`` or to
45*4882a593Smuzhiyun``V4L2_BUF_TYPE_META_OUTPUT`` and use the :c:type:`v4l2_meta_format` ``meta``
46*4882a593Smuzhiyunmember of the ``fmt`` union as needed per the desired operation. Both drivers
47*4882a593Smuzhiyunand applications must set the remainder of the :c:type:`v4l2_format` structure
48*4882a593Smuzhiyunto 0.
49*4882a593Smuzhiyun
50*4882a593Smuzhiyun.. c:type:: v4l2_meta_format
51*4882a593Smuzhiyun
52*4882a593Smuzhiyun.. tabularcolumns:: |p{1.4cm}|p{2.2cm}|p{13.9cm}|
53*4882a593Smuzhiyun
54*4882a593Smuzhiyun.. flat-table:: struct v4l2_meta_format
55*4882a593Smuzhiyun    :header-rows:  0
56*4882a593Smuzhiyun    :stub-columns: 0
57*4882a593Smuzhiyun    :widths:       1 1 2
58*4882a593Smuzhiyun
59*4882a593Smuzhiyun    * - __u32
60*4882a593Smuzhiyun      - ``dataformat``
61*4882a593Smuzhiyun      - The data format, set by the application. This is a little endian
62*4882a593Smuzhiyun        :ref:`four character code <v4l2-fourcc>`. V4L2 defines metadata formats
63*4882a593Smuzhiyun        in :ref:`meta-formats`.
64*4882a593Smuzhiyun    * - __u32
65*4882a593Smuzhiyun      - ``buffersize``
66*4882a593Smuzhiyun      - Maximum buffer size in bytes required for data. The value is set by the
67*4882a593Smuzhiyun        driver.
68