xref: /linux/Documentation/userspace-api/media/v4l/vidioc-g-parm.rst (revision 7a309195d11cde854eb75559fbd6b48f9e518f25)
1.. Permission is granted to copy, distribute and/or modify this
2.. document under the terms of the GNU Free Documentation License,
3.. Version 1.1 or any later version published by the Free Software
4.. Foundation, with no Invariant Sections, no Front-Cover Texts
5.. and no Back-Cover Texts. A copy of the license is included at
6.. Documentation/userspace-api/media/fdl-appendix.rst.
7..
8.. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
9
10.. _VIDIOC_G_PARM:
11
12**********************************
13ioctl VIDIOC_G_PARM, VIDIOC_S_PARM
14**********************************
15
16Name
17====
18
19VIDIOC_G_PARM - VIDIOC_S_PARM - Get or set streaming parameters
20
21
22Synopsis
23========
24
25.. c:function:: int ioctl( int fd, VIDIOC_G_PARM, v4l2_streamparm *argp )
26    :name: VIDIOC_G_PARM
27
28.. c:function:: int ioctl( int fd, VIDIOC_S_PARM, v4l2_streamparm *argp )
29    :name: VIDIOC_S_PARM
30
31
32Arguments
33=========
34
35``fd``
36    File descriptor returned by :ref:`open() <func-open>`.
37
38``argp``
39    Pointer to struct :c:type:`v4l2_streamparm`.
40
41
42Description
43===========
44
45The current video standard determines a nominal number of frames per
46second. If less than this number of frames is to be captured or output,
47applications can request frame skipping or duplicating on the driver
48side. This is especially useful when using the :ref:`read() <func-read>` or
49:ref:`write() <func-write>`, which are not augmented by timestamps or sequence
50counters, and to avoid unnecessary data copying.
51
52Changing the frame interval shall never change the format. Changing the
53format, on the other hand, may change the frame interval.
54
55Further these ioctls can be used to determine the number of buffers used
56internally by a driver in read/write mode. For implications see the
57section discussing the :ref:`read() <func-read>` function.
58
59To get and set the streaming parameters applications call the
60:ref:`VIDIOC_G_PARM <VIDIOC_G_PARM>` and :ref:`VIDIOC_S_PARM <VIDIOC_G_PARM>` ioctl, respectively. They take a
61pointer to a struct :c:type:`v4l2_streamparm` which contains a
62union holding separate parameters for input and output devices.
63
64
65.. tabularcolumns:: |p{3.5cm}|p{3.5cm}|p{3.5cm}|p{7.0cm}|
66
67.. c:type:: v4l2_streamparm
68
69.. flat-table:: struct v4l2_streamparm
70    :header-rows:  0
71    :stub-columns: 0
72    :widths:       1 1 2
73
74    * - __u32
75      - ``type``
76      - The buffer (stream) type, same as struct
77	:c:type:`v4l2_format` ``type``, set by the
78	application. See :c:type:`v4l2_buf_type`.
79    * - union {
80      - ``parm``
81    * - struct :c:type:`v4l2_captureparm`
82      - ``capture``
83      - Parameters for capture devices, used when ``type`` is
84	``V4L2_BUF_TYPE_VIDEO_CAPTURE`` or
85	``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE``.
86    * - struct :c:type:`v4l2_outputparm`
87      - ``output``
88      - Parameters for output devices, used when ``type`` is
89	``V4L2_BUF_TYPE_VIDEO_OUTPUT`` or ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE``.
90    * - __u8
91      - ``raw_data``\ [200]
92      - A place holder for future extensions.
93    * - }
94      -
95
96
97
98.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
99
100.. c:type:: v4l2_captureparm
101
102.. flat-table:: struct v4l2_captureparm
103    :header-rows:  0
104    :stub-columns: 0
105    :widths:       1 1 2
106
107    * - __u32
108      - ``capability``
109      - See :ref:`parm-caps`.
110    * - __u32
111      - ``capturemode``
112      - Set by drivers and applications, see :ref:`parm-flags`.
113    * - struct :c:type:`v4l2_fract`
114      - ``timeperframe``
115      - This is the desired period between successive frames captured by
116	the driver, in seconds. The field is intended to skip frames on
117	the driver side, saving I/O bandwidth.
118
119	Applications store here the desired frame period, drivers return
120	the actual frame period, which must be greater or equal to the
121	nominal frame period determined by the current video standard
122	(struct :c:type:`v4l2_standard` ``frameperiod``
123	field). Changing the video standard (also implicitly by switching
124	the video input) may reset this parameter to the nominal frame
125	period. To reset manually applications can just set this field to
126	zero.
127
128	Drivers support this function only when they set the
129	``V4L2_CAP_TIMEPERFRAME`` flag in the ``capability`` field.
130    * - __u32
131      - ``extendedmode``
132      - Custom (driver specific) streaming parameters. When unused,
133	applications and drivers must set this field to zero. Applications
134	using this field should check the driver name and version, see
135	:ref:`querycap`.
136    * - __u32
137      - ``readbuffers``
138      - Applications set this field to the desired number of buffers used
139	internally by the driver in :ref:`read() <func-read>` mode.
140	Drivers return the actual number of buffers. When an application
141	requests zero buffers, drivers should just return the current
142	setting rather than the minimum or an error code. For details see
143	:ref:`rw`.
144    * - __u32
145      - ``reserved``\ [4]
146      - Reserved for future extensions. Drivers and applications must set
147	the array to zero.
148
149
150
151.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
152
153.. c:type:: v4l2_outputparm
154
155.. flat-table:: struct v4l2_outputparm
156    :header-rows:  0
157    :stub-columns: 0
158    :widths:       1 1 2
159
160    * - __u32
161      - ``capability``
162      - See :ref:`parm-caps`.
163    * - __u32
164      - ``outputmode``
165      - Set by drivers and applications, see :ref:`parm-flags`.
166    * - struct :c:type:`v4l2_fract`
167      - ``timeperframe``
168      - This is the desired period between successive frames output by the
169	driver, in seconds.
170    * - :cspan:`2`
171
172	The field is intended to repeat frames on the driver side in
173	:ref:`write() <func-write>` mode (in streaming mode timestamps
174	can be used to throttle the output), saving I/O bandwidth.
175
176	Applications store here the desired frame period, drivers return
177	the actual frame period, which must be greater or equal to the
178	nominal frame period determined by the current video standard
179	(struct :c:type:`v4l2_standard` ``frameperiod``
180	field). Changing the video standard (also implicitly by switching
181	the video output) may reset this parameter to the nominal frame
182	period. To reset manually applications can just set this field to
183	zero.
184
185	Drivers support this function only when they set the
186	``V4L2_CAP_TIMEPERFRAME`` flag in the ``capability`` field.
187    * - __u32
188      - ``extendedmode``
189      - Custom (driver specific) streaming parameters. When unused,
190	applications and drivers must set this field to zero. Applications
191	using this field should check the driver name and version, see
192	:ref:`querycap`.
193    * - __u32
194      - ``writebuffers``
195      - Applications set this field to the desired number of buffers used
196	internally by the driver in :ref:`write() <func-write>` mode. Drivers
197	return the actual number of buffers. When an application requests
198	zero buffers, drivers should just return the current setting
199	rather than the minimum or an error code. For details see
200	:ref:`rw`.
201    * - __u32
202      - ``reserved``\ [4]
203      - Reserved for future extensions. Drivers and applications must set
204	the array to zero.
205
206
207
208.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
209
210.. _parm-caps:
211
212.. flat-table:: Streaming Parameters Capabilities
213    :header-rows:  0
214    :stub-columns: 0
215    :widths:       3 1 4
216
217    * - ``V4L2_CAP_TIMEPERFRAME``
218      - 0x1000
219      - The frame skipping/repeating controlled by the ``timeperframe``
220	field is supported.
221
222
223
224.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
225
226.. _parm-flags:
227
228.. flat-table:: Capture Parameters Flags
229    :header-rows:  0
230    :stub-columns: 0
231    :widths:       3 1 4
232
233    * - ``V4L2_MODE_HIGHQUALITY``
234      - 0x0001
235      - High quality imaging mode. High quality mode is intended for still
236	imaging applications. The idea is to get the best possible image
237	quality that the hardware can deliver. It is not defined how the
238	driver writer may achieve that; it will depend on the hardware and
239	the ingenuity of the driver writer. High quality mode is a
240	different mode from the regular motion video capture modes. In
241	high quality mode:
242
243	-  The driver may be able to capture higher resolutions than for
244	   motion capture.
245
246	-  The driver may support fewer pixel formats than motion capture
247	   (eg; true color).
248
249	-  The driver may capture and arithmetically combine multiple
250	   successive fields or frames to remove color edge artifacts and
251	   reduce the noise in the video data.
252
253	-  The driver may capture images in slices like a scanner in order
254	   to handle larger format images than would otherwise be
255	   possible.
256
257	-  An image capture operation may be significantly slower than
258	   motion capture.
259
260	-  Moving objects in the image might have excessive motion blur.
261
262	-  Capture might only work through the :ref:`read() <func-read>` call.
263
264
265Return Value
266============
267
268On success 0 is returned, on error -1 and the ``errno`` variable is set
269appropriately. The generic error codes are described at the
270:ref:`Generic Error Codes <gen-errors>` chapter.
271