]>
Commit | Line | Data |
---|---|---|
5377d91f MH |
1 | .. -*- coding: utf-8; mode: rst -*- |
2 | ||
af4a4d0d | 3 | .. _VIDIOC_REQBUFS: |
5377d91f MH |
4 | |
5 | ******************** | |
6 | ioctl VIDIOC_REQBUFS | |
7 | ******************** | |
8 | ||
15e7d615 | 9 | Name |
586027ce | 10 | ==== |
5377d91f | 11 | |
53ce5239 | 12 | VIDIOC_REQBUFS - Initiate Memory Mapping, User Pointer I/O or DMA buffer I/O |
5377d91f | 13 | |
15e7d615 MCC |
14 | |
15 | Synopsis | |
5377d91f MH |
16 | ======== |
17 | ||
b7e67f6c | 18 | .. cpp:function:: int ioctl( int fd, int request, struct v4l2_requestbuffers *argp ) |
5377d91f | 19 | |
586027ce | 20 | |
15e7d615 | 21 | Arguments |
5377d91f MH |
22 | ========= |
23 | ||
24 | ``fd`` | |
25 | File descriptor returned by :ref:`open() <func-open>`. | |
26 | ||
27 | ``request`` | |
28 | VIDIOC_REQBUFS | |
29 | ||
30 | ``argp`` | |
31 | ||
32 | ||
15e7d615 | 33 | Description |
5377d91f MH |
34 | =========== |
35 | ||
36 | This ioctl is used to initiate :ref:`memory mapped <mmap>`, | |
37 | :ref:`user pointer <userp>` or :ref:`DMABUF <dmabuf>` based I/O. | |
38 | Memory mapped buffers are located in device memory and must be allocated | |
39 | with this ioctl before they can be mapped into the application's address | |
40 | space. User buffers are allocated by applications themselves, and this | |
41 | ioctl is merely used to switch the driver into user pointer I/O mode and | |
42 | to setup some internal structures. Similarly, DMABUF buffers are | |
43 | allocated by applications through a device driver, and this ioctl only | |
44 | configures the driver into DMABUF I/O mode without performing any direct | |
45 | allocation. | |
46 | ||
47 | To allocate device buffers applications initialize all fields of the | |
acf309a2 | 48 | :ref:`struct v4l2_requestbuffers <v4l2-requestbuffers>` structure. They set the ``type`` |
5377d91f MH |
49 | field to the respective stream or buffer type, the ``count`` field to |
50 | the desired number of buffers, ``memory`` must be set to the requested | |
51 | I/O method and the ``reserved`` array must be zeroed. When the ioctl is | |
52 | called with a pointer to this structure the driver will attempt to | |
53 | allocate the requested number of buffers and it stores the actual number | |
54 | allocated in the ``count`` field. It can be smaller than the number | |
55 | requested, even zero, when the driver runs out of free memory. A larger | |
56 | number is also possible when the driver requires more buffers to | |
57 | function correctly. For example video output requires at least two | |
58 | buffers, one displayed and one filled by the application. | |
59 | ||
cdb4af0f | 60 | When the I/O method is not supported the ioctl returns an ``EINVAL`` error |
5377d91f MH |
61 | code. |
62 | ||
2212ff25 | 63 | Applications can call :ref:`VIDIOC_REQBUFS` again to change the number of |
5377d91f MH |
64 | buffers, however this cannot succeed when any buffers are still mapped. |
65 | A ``count`` value of zero frees all buffers, after aborting or finishing | |
66 | any DMA in progress, an implicit | |
af4a4d0d | 67 | :ref:`VIDIOC_STREAMOFF <VIDIOC_STREAMON>`. |
5377d91f MH |
68 | |
69 | ||
70 | .. _v4l2-requestbuffers: | |
71 | ||
72 | .. flat-table:: struct v4l2_requestbuffers | |
73 | :header-rows: 0 | |
74 | :stub-columns: 0 | |
75 | :widths: 1 1 2 | |
76 | ||
77 | ||
78 | - .. row 1 | |
79 | ||
80 | - __u32 | |
81 | ||
82 | - ``count`` | |
83 | ||
84 | - The number of buffers requested or granted. | |
85 | ||
86 | - .. row 2 | |
87 | ||
88 | - __u32 | |
89 | ||
90 | - ``type`` | |
91 | ||
92 | - Type of the stream or buffers, this is the same as the struct | |
0579e6e3 MCC |
93 | :ref:`v4l2_format <v4l2-format>` ``type`` field. See |
94 | :ref:`v4l2-buf-type` for valid values. | |
5377d91f MH |
95 | |
96 | - .. row 3 | |
97 | ||
98 | - __u32 | |
99 | ||
100 | - ``memory`` | |
101 | ||
102 | - Applications set this field to ``V4L2_MEMORY_MMAP``, | |
0579e6e3 MCC |
103 | ``V4L2_MEMORY_DMABUF`` or ``V4L2_MEMORY_USERPTR``. See |
104 | :ref:`v4l2-memory`. | |
5377d91f MH |
105 | |
106 | - .. row 4 | |
107 | ||
108 | - __u32 | |
109 | ||
ffbab694 | 110 | - ``reserved``\ \[2\] |
5377d91f MH |
111 | |
112 | - A place holder for future extensions. Drivers and applications | |
0579e6e3 | 113 | must set the array to zero. |
5377d91f MH |
114 | |
115 | ||
15e7d615 | 116 | Return Value |
5377d91f MH |
117 | ============ |
118 | ||
119 | On success 0 is returned, on error -1 and the ``errno`` variable is set | |
120 | appropriately. The generic error codes are described at the | |
121 | :ref:`Generic Error Codes <gen-errors>` chapter. | |
122 | ||
123 | EINVAL | |
124 | The buffer type (``type`` field) or the requested I/O method | |
125 | (``memory``) is not supported. |