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