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_CREATE_BUFS:
^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_CREATE_BUFS
^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_CREATE_BUFS - Create buffers for Memory Mapped or User Pointer 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_CREATE_BUFS
^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_CREATE_BUFS, struct v4l2_create_buffers *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_create_buffers`.
^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 create buffers for :ref:`memory mapped <mmap>`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) or :ref:`user pointer <userp>` or :ref:`DMA buffer <dmabuf>` I/O. It
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) can be used as an alternative or in addition to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) :ref:`VIDIOC_REQBUFS` ioctl, when a tighter control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) over buffers is required. This ioctl can be called multiple times to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) create buffers of different sizes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) To allocate the device buffers applications must initialize the relevant
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) fields of the struct :c:type:`v4l2_create_buffers` structure. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) ``count`` field must be set to the number of requested buffers, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) ``memory`` field specifies the requested I/O method and the ``reserved``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) array must be zeroed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) The ``format`` field specifies the image format that the buffers must be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) able to handle. The application has to fill in this struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) :c:type:`v4l2_format`. Usually this will be done using the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) :ref:`VIDIOC_TRY_FMT <VIDIOC_G_FMT>` or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>` ioctls to ensure that the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) requested format is supported by the driver. Based on the format's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) ``type`` field the requested buffer size (for single-planar) or plane
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) sizes (for multi-planar formats) will be used for the allocated buffers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) The driver may return an error if the size(s) are not supported by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) hardware (usually because they are too small).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) The buffers created by this ioctl will have as minimum size the size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) defined by the ``format.pix.sizeimage`` field (or the corresponding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) fields for other format types). Usually if the ``format.pix.sizeimage``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) field is less than the minimum required for the given format, then an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) error will be returned since drivers will typically not allow this. If
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) it is larger, then the value will be used as-is. In other words, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) driver may reject the requested size, but if it is accepted the driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) will use it unchanged.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) When the ioctl is called with a pointer to this structure the driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) will attempt to allocate up to the requested number of buffers and store
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) the actual number allocated and the starting index in the ``count`` and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) the ``index`` fields respectively. On return ``count`` can be smaller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) than the number requested.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) .. c:type:: v4l2_create_buffers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) .. flat-table:: struct v4l2_create_buffers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)     :header-rows:  0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)     :stub-columns: 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)     :widths:       1 1 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)     * - __u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)       - ``index``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)       - The starting buffer index, returned by the driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)     * - __u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)       - ``count``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)       - The number of buffers requested or granted. If count == 0, then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	:ref:`VIDIOC_CREATE_BUFS` will set ``index`` to the current number of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	created buffers, and it will check the validity of ``memory`` and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	``format.type``. If those are invalid -1 is returned and errno is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	set to ``EINVAL`` error code, otherwise :ref:`VIDIOC_CREATE_BUFS` returns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	0. It will never set errno to ``EBUSY`` error code in this particular
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	case.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94)     * - __u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95)       - ``memory``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96)       - Applications set this field to ``V4L2_MEMORY_MMAP``,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	``V4L2_MEMORY_DMABUF`` or ``V4L2_MEMORY_USERPTR``. See
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	:c:type:`v4l2_memory`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99)     * - struct :c:type:`v4l2_format`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)       - ``format``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)       - Filled in by the application, preserved by the driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)     * - __u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)       - ``capabilities``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)       - Set by the driver. If 0, then the driver doesn't support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)         capabilities. In that case all you know is that the driver is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	guaranteed to support ``V4L2_MEMORY_MMAP`` and *might* support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	other :c:type:`v4l2_memory` types. It will not support any other
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	capabilities. See :ref:`here <v4l2-buf-capabilities>` for a list of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	capabilities.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	If you want to just query the capabilities without making any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	other changes, then set ``count`` to 0, ``memory`` to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	``V4L2_MEMORY_MMAP`` and ``format.type`` to the buffer type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)     * - __u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)       - ``reserved``\ [7]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)       - A place holder for future extensions. Drivers and applications
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	must set the array to zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) Return Value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) ============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) On success 0 is returned, on error -1 and the ``errno`` variable is set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) appropriately. The generic error codes are described at the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) :ref:`Generic Error Codes <gen-errors>` chapter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) ENOMEM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)     No memory to allocate buffers for :ref:`memory mapped <mmap>` I/O.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) EINVAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)     The buffer type (``format.type`` field), requested I/O method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)     (``memory``) or format (``format`` field) is not valid.