1 .. -*- coding: utf-8; mode: rst -*-
12 VIDIOC_REQBUFS - Initiate Memory Mapping or User Pointer I/O
17 .. cpp:function:: int ioctl( int fd, int request, struct v4l2_requestbuffers *argp )
24 File descriptor returned by :ref:`open() <func-open>`.
35 This ioctl is used to initiate :ref:`memory mapped <mmap>`,
36 :ref:`user pointer <userp>` or :ref:`DMABUF <dmabuf>` based I/O.
37 Memory mapped buffers are located in device memory and must be allocated
38 with this ioctl before they can be mapped into the application's address
39 space. User buffers are allocated by applications themselves, and this
40 ioctl is merely used to switch the driver into user pointer I/O mode and
41 to setup some internal structures. Similarly, DMABUF buffers are
42 allocated by applications through a device driver, and this ioctl only
43 configures the driver into DMABUF I/O mode without performing any direct
46 To allocate device buffers applications initialize all fields of the
47 :ref:`struct v4l2_requestbuffers <v4l2-requestbuffers>` structure. They set the ``type``
48 field to the respective stream or buffer type, the ``count`` field to
49 the desired number of buffers, ``memory`` must be set to the requested
50 I/O method and the ``reserved`` array must be zeroed. When the ioctl is
51 called with a pointer to this structure the driver will attempt to
52 allocate the requested number of buffers and it stores the actual number
53 allocated in the ``count`` field. It can be smaller than the number
54 requested, even zero, when the driver runs out of free memory. A larger
55 number is also possible when the driver requires more buffers to
56 function correctly. For example video output requires at least two
57 buffers, one displayed and one filled by the application.
59 When the I/O method is not supported the ioctl returns an ``EINVAL`` error
62 Applications can call :ref:`VIDIOC_REQBUFS` again to change the number of
63 buffers, however this cannot succeed when any buffers are still mapped.
64 A ``count`` value of zero frees all buffers, after aborting or finishing
65 any DMA in progress, an implicit
66 :ref:`VIDIOC_STREAMOFF <VIDIOC_STREAMON>`.
69 .. _v4l2-requestbuffers:
71 .. flat-table:: struct v4l2_requestbuffers
83 - The number of buffers requested or granted.
91 - Type of the stream or buffers, this is the same as the struct
92 :ref:`v4l2_format <v4l2-format>` ``type`` field. See
93 :ref:`v4l2-buf-type` for valid values.
101 - Applications set this field to ``V4L2_MEMORY_MMAP``,
102 ``V4L2_MEMORY_DMABUF`` or ``V4L2_MEMORY_USERPTR``. See
111 - A place holder for future extensions. Drivers and applications
112 must set the array to zero.
118 On success 0 is returned, on error -1 and the ``errno`` variable is set
119 appropriately. The generic error codes are described at the
120 :ref:`Generic Error Codes <gen-errors>` chapter.
123 The buffer type (``type`` field) or the requested I/O method
124 (``memory``) is not supported.