Merge remote-tracking branch 'regulator/for-next'
[deliverable/linux.git] / Documentation / media / uapi / v4l / vidioc-create-bufs.rst
CommitLineData
5377d91f
MH
1.. -*- coding: utf-8; mode: rst -*-
2
af4a4d0d 3.. _VIDIOC_CREATE_BUFS:
5377d91f
MH
4
5************************
6ioctl VIDIOC_CREATE_BUFS
7************************
8
15e7d615 9Name
586027ce 10====
5377d91f 11
586027ce 12VIDIOC_CREATE_BUFS - Create buffers for Memory Mapped or User Pointer or DMA Buffer I/O
5377d91f 13
15e7d615
MCC
14
15Synopsis
5377d91f
MH
16========
17
41d80465
MCC
18.. c:function:: int ioctl( int fd, VIDIOC_CREATE_BUFS, struct v4l2_create_buffers *argp )
19 :name: VIDIOC_CREATE_BUFS
5377d91f 20
586027ce 21
15e7d615 22Arguments
5377d91f
MH
23=========
24
25``fd``
26 File descriptor returned by :ref:`open() <func-open>`.
27
5377d91f
MH
28``argp``
29
30
15e7d615 31Description
5377d91f
MH
32===========
33
34This ioctl is used to create buffers for :ref:`memory mapped <mmap>`
35or :ref:`user pointer <userp>` or :ref:`DMA buffer <dmabuf>` I/O. It
36can be used as an alternative or in addition to the
7347081e 37:ref:`VIDIOC_REQBUFS` ioctl, when a tighter control
5377d91f
MH
38over buffers is required. This ioctl can be called multiple times to
39create buffers of different sizes.
40
41To allocate the device buffers applications must initialize the relevant
fc78c7c7 42fields of the struct :c:type:`v4l2_create_buffers` structure. The
5377d91f
MH
43``count`` field must be set to the number of requested buffers, the
44``memory`` field specifies the requested I/O method and the ``reserved``
45array must be zeroed.
46
47The ``format`` field specifies the image format that the buffers must be
48able to handle. The application has to fill in this struct
e8be7e97 49:c:type:`v4l2_format`. Usually this will be done using the
af4a4d0d 50:ref:`VIDIOC_TRY_FMT <VIDIOC_G_FMT>` or
4e03cb76 51:ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>` ioctls to ensure that the
5377d91f
MH
52requested format is supported by the driver. Based on the format's
53``type`` field the requested buffer size (for single-planar) or plane
54sizes (for multi-planar formats) will be used for the allocated buffers.
55The driver may return an error if the size(s) are not supported by the
56hardware (usually because they are too small).
57
58The buffers created by this ioctl will have as minimum size the size
59defined by the ``format.pix.sizeimage`` field (or the corresponding
60fields for other format types). Usually if the ``format.pix.sizeimage``
61field is less than the minimum required for the given format, then an
62error will be returned since drivers will typically not allow this. If
63it is larger, then the value will be used as-is. In other words, the
64driver may reject the requested size, but if it is accepted the driver
65will use it unchanged.
66
67When the ioctl is called with a pointer to this structure the driver
68will attempt to allocate up to the requested number of buffers and store
69the actual number allocated and the starting index in the ``count`` and
70the ``index`` fields respectively. On return ``count`` can be smaller
71than the number requested.
72
73
e8be7e97 74.. c:type:: v4l2_create_buffers
5377d91f 75
5bd4bb78
MCC
76.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
77
5377d91f
MH
78.. flat-table:: struct v4l2_create_buffers
79 :header-rows: 0
80 :stub-columns: 0
81 :widths: 1 1 2
82
83
84 - .. row 1
85
86 - __u32
87
88 - ``index``
89
90 - The starting buffer index, returned by the driver.
91
92 - .. row 2
93
94 - __u32
95
96 - ``count``
97
98 - The number of buffers requested or granted. If count == 0, then
0579e6e3
MCC
99 :ref:`VIDIOC_CREATE_BUFS` will set ``index`` to the current number of
100 created buffers, and it will check the validity of ``memory`` and
101 ``format.type``. If those are invalid -1 is returned and errno is
102 set to ``EINVAL`` error code, otherwise :ref:`VIDIOC_CREATE_BUFS` returns
103 0. It will never set errno to ``EBUSY`` error code in this particular
104 case.
5377d91f
MH
105
106 - .. row 3
107
108 - __u32
109
110 - ``memory``
111
112 - Applications set this field to ``V4L2_MEMORY_MMAP``,
0579e6e3 113 ``V4L2_MEMORY_DMABUF`` or ``V4L2_MEMORY_USERPTR``. See
56683d7d 114 :c:type:`v4l2_memory`
5377d91f
MH
115
116 - .. row 4
117
e8be7e97 118 - struct :c:type:`v4l2_format`
5377d91f
MH
119
120 - ``format``
121
122 - Filled in by the application, preserved by the driver.
123
124 - .. row 5
125
126 - __u32
127
8968da9b 128 - ``reserved``\ [8]
5377d91f
MH
129
130 - A place holder for future extensions. Drivers and applications
0579e6e3 131 must set the array to zero.
5377d91f
MH
132
133
15e7d615 134Return Value
5377d91f
MH
135============
136
137On success 0 is returned, on error -1 and the ``errno`` variable is set
138appropriately. The generic error codes are described at the
139:ref:`Generic Error Codes <gen-errors>` chapter.
140
141ENOMEM
142 No memory to allocate buffers for :ref:`memory mapped <mmap>` I/O.
143
144EINVAL
145 The buffer type (``format.type`` field), requested I/O method
146 (``memory``) or format (``format`` field) is not valid.
This page took 0.060028 seconds and 5 git commands to generate.