doc-rst: customize RTD theme, captions & inline literal
[deliverable/linux.git] / Documentation / linux_tv / media / v4l / vidioc-reqbufs.rst
1 .. -*- coding: utf-8; mode: rst -*-
2
3 .. _VIDIOC_REQBUFS:
4
5 ********************
6 ioctl VIDIOC_REQBUFS
7 ********************
8
9 NAME
10 ====
11
12 VIDIOC_REQBUFS - Initiate Memory Mapping or User Pointer I/O
13
14 SYNOPSIS
15 ========
16
17 .. cpp:function:: int ioctl( int fd, int request, struct v4l2_requestbuffers *argp )
18
19
20 ARGUMENTS
21 =========
22
23 ``fd``
24 File descriptor returned by :ref:`open() <func-open>`.
25
26 ``request``
27 VIDIOC_REQBUFS
28
29 ``argp``
30
31
32 DESCRIPTION
33 ===========
34
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
44 allocation.
45
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.
58
59 When the I/O method is not supported the ioctl returns an ``EINVAL`` error
60 code.
61
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>`.
67
68
69 .. _v4l2-requestbuffers:
70
71 .. flat-table:: struct v4l2_requestbuffers
72 :header-rows: 0
73 :stub-columns: 0
74 :widths: 1 1 2
75
76
77 - .. row 1
78
79 - __u32
80
81 - ``count``
82
83 - The number of buffers requested or granted.
84
85 - .. row 2
86
87 - __u32
88
89 - ``type``
90
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.
94
95 - .. row 3
96
97 - __u32
98
99 - ``memory``
100
101 - Applications set this field to ``V4L2_MEMORY_MMAP``,
102 ``V4L2_MEMORY_DMABUF`` or ``V4L2_MEMORY_USERPTR``. See
103 :ref:`v4l2-memory`.
104
105 - .. row 4
106
107 - __u32
108
109 - ``reserved``\ [2]
110
111 - A place holder for future extensions. Drivers and applications
112 must set the array to zero.
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.
This page took 0.089749 seconds and 5 git commands to generate.