18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ci.. _planar-apis:
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci*****************************
68c2ecf20Sopenharmony_ciSingle- and multi-planar APIs
78c2ecf20Sopenharmony_ci*****************************
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ciSome devices require data for each input or output video frame to be
108c2ecf20Sopenharmony_ciplaced in discontiguous memory buffers. In such cases, one video frame
118c2ecf20Sopenharmony_cihas to be addressed using more than one memory address, i.e. one pointer
128c2ecf20Sopenharmony_ciper "plane". A plane is a sub-buffer of the current frame. For examples
138c2ecf20Sopenharmony_ciof such formats see :ref:`pixfmt`.
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ciInitially, V4L2 API did not support multi-planar buffers and a set of
168c2ecf20Sopenharmony_ciextensions has been introduced to handle them. Those extensions
178c2ecf20Sopenharmony_ciconstitute what is being referred to as the "multi-planar API".
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ciSome of the V4L2 API calls and structures are interpreted differently,
208c2ecf20Sopenharmony_cidepending on whether single- or multi-planar API is being used. An
218c2ecf20Sopenharmony_ciapplication can choose whether to use one or the other by passing a
228c2ecf20Sopenharmony_cicorresponding buffer type to its ioctl calls. Multi-planar versions of
238c2ecf20Sopenharmony_cibuffer types are suffixed with an ``_MPLANE`` string. For a list of
248c2ecf20Sopenharmony_ciavailable multi-planar buffer types see enum
258c2ecf20Sopenharmony_ci:c:type:`v4l2_buf_type`.
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ciMulti-planar formats
298c2ecf20Sopenharmony_ci====================
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ciMulti-planar API introduces new multi-planar formats. Those formats use
328c2ecf20Sopenharmony_cia separate set of FourCC codes. It is important to distinguish between
338c2ecf20Sopenharmony_cithe multi-planar API and a multi-planar format. Multi-planar API calls
348c2ecf20Sopenharmony_cican handle all single-planar formats as well (as long as they are passed
358c2ecf20Sopenharmony_ciin multi-planar API structures), while the single-planar API cannot
368c2ecf20Sopenharmony_cihandle multi-planar formats.
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ciCalls that distinguish between single and multi-planar APIs
408c2ecf20Sopenharmony_ci===========================================================
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci:ref:`VIDIOC_QUERYCAP <VIDIOC_QUERYCAP>`
438c2ecf20Sopenharmony_ci    Two additional multi-planar capabilities are added. They can be set
448c2ecf20Sopenharmony_ci    together with non-multi-planar ones for devices that handle both
458c2ecf20Sopenharmony_ci    single- and multi-planar formats.
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci:ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>`, :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>`, :ref:`VIDIOC_TRY_FMT <VIDIOC_G_FMT>`
488c2ecf20Sopenharmony_ci    New structures for describing multi-planar formats are added: struct
498c2ecf20Sopenharmony_ci    :c:type:`v4l2_pix_format_mplane` and
508c2ecf20Sopenharmony_ci    struct :c:type:`v4l2_plane_pix_format`.
518c2ecf20Sopenharmony_ci    Drivers may define new multi-planar formats, which have distinct
528c2ecf20Sopenharmony_ci    FourCC codes from the existing single-planar ones.
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci:ref:`VIDIOC_QBUF <VIDIOC_QBUF>`, :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>`, :ref:`VIDIOC_QUERYBUF <VIDIOC_QUERYBUF>`
558c2ecf20Sopenharmony_ci    A new struct :c:type:`v4l2_plane` structure for
568c2ecf20Sopenharmony_ci    describing planes is added. Arrays of this structure are passed in
578c2ecf20Sopenharmony_ci    the new ``m.planes`` field of struct
588c2ecf20Sopenharmony_ci    :c:type:`v4l2_buffer`.
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci:ref:`VIDIOC_REQBUFS <VIDIOC_REQBUFS>`
618c2ecf20Sopenharmony_ci    Will allocate multi-planar buffers as requested.
62