Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) .. c:namespace:: V4L
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) .. _VIDIOC_REQBUFS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) ********************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) ioctl VIDIOC_REQBUFS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) ********************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) Name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) ====
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) VIDIOC_REQBUFS - Initiate Memory Mapping, User Pointer I/O or DMA buffer I/O
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) Synopsis
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) ========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) .. c:macro:: VIDIOC_REQBUFS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) ``int ioctl(int fd, VIDIOC_REQBUFS, struct v4l2_requestbuffers *argp)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) Arguments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) =========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) ``fd``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)     File descriptor returned by :c:func:`open()`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) ``argp``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)     Pointer to struct :c:type:`v4l2_requestbuffers`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) ===========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) This ioctl is used to initiate :ref:`memory mapped <mmap>`,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) :ref:`user pointer <userp>` or :ref:`DMABUF <dmabuf>` based I/O.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) Memory mapped buffers are located in device memory and must be allocated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) with this ioctl before they can be mapped into the application's address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) space. User buffers are allocated by applications themselves, and this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) ioctl is merely used to switch the driver into user pointer I/O mode and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) to setup some internal structures. Similarly, DMABUF buffers are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) allocated by applications through a device driver, and this ioctl only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) configures the driver into DMABUF I/O mode without performing any direct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) allocation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) To allocate device buffers applications initialize all fields of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) struct :c:type:`v4l2_requestbuffers` structure. They set the ``type``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) field to the respective stream or buffer type, the ``count`` field to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) the desired number of buffers, ``memory`` must be set to the requested
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) I/O method and the ``reserved`` array must be zeroed. When the ioctl is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) called with a pointer to this structure the driver will attempt to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) allocate the requested number of buffers and it stores the actual number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) allocated in the ``count`` field. It can be smaller than the number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) requested, even zero, when the driver runs out of free memory. A larger
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) number is also possible when the driver requires more buffers to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) function correctly. For example video output requires at least two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) buffers, one displayed and one filled by the application.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) When the I/O method is not supported the ioctl returns an ``EINVAL`` error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) Applications can call :ref:`VIDIOC_REQBUFS` again to change the number of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) buffers. Note that if any buffers are still mapped or exported via DMABUF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) then :ref:`VIDIOC_REQBUFS` can only succeed if the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) ``V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS`` capability is set. Otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) :ref:`VIDIOC_REQBUFS` will return the ``EBUSY`` error code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) If ``V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS`` is set, then these buffers are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) orphaned and will be freed when they are unmapped or when the exported DMABUF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) fds are closed. A ``count`` value of zero frees or orphans all buffers, after
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) aborting or finishing any DMA in progress, an implicit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) :ref:`VIDIOC_STREAMOFF <VIDIOC_STREAMON>`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) .. c:type:: v4l2_requestbuffers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) .. flat-table:: struct v4l2_requestbuffers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)     :header-rows:  0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)     :stub-columns: 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)     :widths:       1 1 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)     * - __u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)       - ``count``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)       - The number of buffers requested or granted.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)     * - __u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)       - ``type``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)       - Type of the stream or buffers, this is the same as the struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	:c:type:`v4l2_format` ``type`` field. See
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	:c:type:`v4l2_buf_type` for valid values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)     * - __u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)       - ``memory``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)       - Applications set this field to ``V4L2_MEMORY_MMAP``,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	``V4L2_MEMORY_DMABUF`` or ``V4L2_MEMORY_USERPTR``. See
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	:c:type:`v4l2_memory`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94)     * - __u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95)       - ``capabilities``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96)       - Set by the driver. If 0, then the driver doesn't support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97)         capabilities. In that case all you know is that the driver is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	guaranteed to support ``V4L2_MEMORY_MMAP`` and *might* support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	other :c:type:`v4l2_memory` types. It will not support any other
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	capabilities.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	If you want to query the capabilities with a minimum of side-effects,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	then this can be called with ``count`` set to 0, ``memory`` set to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	``V4L2_MEMORY_MMAP`` and ``type`` set to the buffer type. This will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	free any previously allocated buffers, so this is typically something
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	that will be done at the start of the application.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)     * - __u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)       - ``reserved``\ [1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)       - A place holder for future extensions. Drivers and applications
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	must set the array to zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) .. tabularcolumns:: |p{6.1cm}|p{2.2cm}|p{8.7cm}|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) .. _v4l2-buf-capabilities:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) .. _V4L2-BUF-CAP-SUPPORTS-MMAP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) .. _V4L2-BUF-CAP-SUPPORTS-USERPTR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) .. _V4L2-BUF-CAP-SUPPORTS-DMABUF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) .. _V4L2-BUF-CAP-SUPPORTS-REQUESTS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) .. _V4L2-BUF-CAP-SUPPORTS-ORPHANED-BUFS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) .. _V4L2-BUF-CAP-SUPPORTS-M2M-HOLD-CAPTURE-BUF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) .. _V4L2-BUF-CAP-SUPPORTS-MMAP-CACHE-HINTS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) .. cssclass:: longtable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) .. flat-table:: V4L2 Buffer Capabilities Flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)     :header-rows:  0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)     :stub-columns: 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)     :widths:       3 1 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)     * - ``V4L2_BUF_CAP_SUPPORTS_MMAP``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)       - 0x00000001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)       - This buffer type supports the ``V4L2_MEMORY_MMAP`` streaming mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)     * - ``V4L2_BUF_CAP_SUPPORTS_USERPTR``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)       - 0x00000002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)       - This buffer type supports the ``V4L2_MEMORY_USERPTR`` streaming mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)     * - ``V4L2_BUF_CAP_SUPPORTS_DMABUF``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)       - 0x00000004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)       - This buffer type supports the ``V4L2_MEMORY_DMABUF`` streaming mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)     * - ``V4L2_BUF_CAP_SUPPORTS_REQUESTS``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)       - 0x00000008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)       - This buffer type supports :ref:`requests <media-request-api>`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)     * - ``V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)       - 0x00000010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)       - The kernel allows calling :ref:`VIDIOC_REQBUFS` while buffers are still
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)         mapped or exported via DMABUF. These orphaned buffers will be freed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)         when they are unmapped or when the exported DMABUF fds are closed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)     * - ``V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)       - 0x00000020
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)       - Only valid for stateless decoders. If set, then userspace can set the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)         ``V4L2_BUF_FLAG_M2M_HOLD_CAPTURE_BUF`` flag to hold off on returning the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	capture buffer until the OUTPUT timestamp changes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)     * - ``V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)       - 0x00000040
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)       - This capability is set by the driver to indicate that the queue supports
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)         cache and memory management hints. However, it's only valid when the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)         queue is used for :ref:`memory mapping <mmap>` streaming I/O. See
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)         :ref:`V4L2_BUF_FLAG_NO_CACHE_INVALIDATE <V4L2-BUF-FLAG-NO-CACHE-INVALIDATE>` and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)         :ref:`V4L2_BUF_FLAG_NO_CACHE_CLEAN <V4L2-BUF-FLAG-NO-CACHE-CLEAN>`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) Return Value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) ============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) On success 0 is returned, on error -1 and the ``errno`` variable is set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) appropriately. The generic error codes are described at the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) :ref:`Generic Error Codes <gen-errors>` chapter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) EINVAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)     The buffer type (``type`` field) or the requested I/O method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)     (``memory``) is not supported.