blob: 411b5bf8031339e1cf8b58cebad7b47b91f22929 [file] [log] [blame]
Markus Heiser5377d912016-06-30 15:18:56 +02001.. -*- coding: utf-8; mode: rst -*-
2
Mauro Carvalho Chehabaf4a4d02016-07-01 13:42:29 -03003.. _VIDIOC_REQBUFS:
Markus Heiser5377d912016-06-30 15:18:56 +02004
5********************
6ioctl VIDIOC_REQBUFS
7********************
8
9*man VIDIOC_REQBUFS(2)*
10
11Initiate Memory Mapping or User Pointer I/O
12
13
14Synopsis
15========
16
Mauro Carvalho Chehabb7e67f62016-07-02 09:49:16 -030017.. cpp:function:: int ioctl( int fd, int request, struct v4l2_requestbuffers *argp )
Markus Heiser5377d912016-06-30 15:18:56 +020018
19Arguments
20=========
21
22``fd``
23 File descriptor returned by :ref:`open() <func-open>`.
24
25``request``
26 VIDIOC_REQBUFS
27
28``argp``
29
30
31Description
32===========
33
34This ioctl is used to initiate :ref:`memory mapped <mmap>`,
35:ref:`user pointer <userp>` or :ref:`DMABUF <dmabuf>` based I/O.
36Memory mapped buffers are located in device memory and must be allocated
37with this ioctl before they can be mapped into the application's address
38space. User buffers are allocated by applications themselves, and this
39ioctl is merely used to switch the driver into user pointer I/O mode and
40to setup some internal structures. Similarly, DMABUF buffers are
41allocated by applications through a device driver, and this ioctl only
42configures the driver into DMABUF I/O mode without performing any direct
43allocation.
44
45To allocate device buffers applications initialize all fields of the
46:c:type:`struct v4l2_requestbuffers` structure. They set the ``type``
47field to the respective stream or buffer type, the ``count`` field to
48the desired number of buffers, ``memory`` must be set to the requested
49I/O method and the ``reserved`` array must be zeroed. When the ioctl is
50called with a pointer to this structure the driver will attempt to
51allocate the requested number of buffers and it stores the actual number
52allocated in the ``count`` field. It can be smaller than the number
53requested, even zero, when the driver runs out of free memory. A larger
54number is also possible when the driver requires more buffers to
55function correctly. For example video output requires at least two
56buffers, one displayed and one filled by the application.
57
Mauro Carvalho Chehabcdb4af02016-07-03 11:53:09 -030058When the I/O method is not supported the ioctl returns an ``EINVAL`` error
Markus Heiser5377d912016-06-30 15:18:56 +020059code.
60
Mauro Carvalho Chehab2212ff22016-07-01 14:33:56 -030061Applications can call :ref:`VIDIOC_REQBUFS` again to change the number of
Markus Heiser5377d912016-06-30 15:18:56 +020062buffers, however this cannot succeed when any buffers are still mapped.
63A ``count`` value of zero frees all buffers, after aborting or finishing
64any DMA in progress, an implicit
Mauro Carvalho Chehabaf4a4d02016-07-01 13:42:29 -030065:ref:`VIDIOC_STREAMOFF <VIDIOC_STREAMON>`.
Markus Heiser5377d912016-06-30 15:18:56 +020066
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
115Return Value
116============
117
118On success 0 is returned, on error -1 and the ``errno`` variable is set
119appropriately. The generic error codes are described at the
120:ref:`Generic Error Codes <gen-errors>` chapter.
121
122EINVAL
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.. ------------------------------------------------------------------------------