]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - Documentation/linux_tv/media/v4l/vidioc-reqbufs.rst
doc-rst: userp: Add ioctl cross references
[mirror_ubuntu-artful-kernel.git] / Documentation / linux_tv / media / v4l / vidioc-reqbufs.rst
CommitLineData
5377d91f
MH
1.. -*- coding: utf-8; mode: rst -*-
2
af4a4d0d 3.. _VIDIOC_REQBUFS:
5377d91f
MH
4
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
b7e67f6c 17.. cpp:function:: int ioctl( int fd, int request, struct v4l2_requestbuffers *argp )
5377d91f
MH
18
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
acf309a2 46:ref:`struct v4l2_requestbuffers <v4l2-requestbuffers>` structure. They set the ``type``
5377d91f
MH
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
cdb4af0f 58When the I/O method is not supported the ioctl returns an ``EINVAL`` error
5377d91f
MH
59code.
60
2212ff25 61Applications can call :ref:`VIDIOC_REQBUFS` again to change the number of
5377d91f
MH
62buffers, 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
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
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.