Merge remote-tracking branch 'omap_dss2/for-next'
[deliverable/linux.git] / Documentation / media / uapi / v4l / vidioc-reqbufs.rst
... / ...
CommitLineData
1.. -*- coding: utf-8; mode: rst -*-
2
3.. _VIDIOC_REQBUFS:
4
5********************
6ioctl VIDIOC_REQBUFS
7********************
8
9Name
10====
11
12VIDIOC_REQBUFS - Initiate Memory Mapping, User Pointer I/O or DMA buffer I/O
13
14
15Synopsis
16========
17
18.. c:function:: int ioctl( int fd, VIDIOC_REQBUFS, struct v4l2_requestbuffers *argp )
19 :name: VIDIOC_REQBUFS
20
21
22Arguments
23=========
24
25``fd``
26 File descriptor returned by :ref:`open() <func-open>`.
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
46struct :c:type:`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
58When the I/O method is not supported the ioctl returns an ``EINVAL`` error
59code.
60
61Applications can call :ref:`VIDIOC_REQBUFS` again to change the number of
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
65:ref:`VIDIOC_STREAMOFF <VIDIOC_STREAMON>`.
66
67
68.. c:type:: v4l2_requestbuffers
69
70.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
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
93 :c:type:`v4l2_format` ``type`` field. See
94 :c:type:`v4l2_buf_type` for valid values.
95
96 - .. row 3
97
98 - __u32
99
100 - ``memory``
101
102 - Applications set this field to ``V4L2_MEMORY_MMAP``,
103 ``V4L2_MEMORY_DMABUF`` or ``V4L2_MEMORY_USERPTR``. See
104 :c:type:`v4l2_memory`.
105
106 - .. row 4
107
108 - __u32
109
110 - ``reserved``\ [2]
111
112 - A place holder for future extensions. Drivers and applications
113 must set the array to zero.
114
115
116Return Value
117============
118
119On success 0 is returned, on error -1 and the ``errno`` variable is set
120appropriately. The generic error codes are described at the
121:ref:`Generic Error Codes <gen-errors>` chapter.
122
123EINVAL
124 The buffer type (``type`` field) or the requested I/O method
125 (``memory``) is not supported.
This page took 0.026162 seconds and 5 git commands to generate.