blob: 3b2e6e59a3346f8e913c6c4331975170e0c84396 [file] [log] [blame]
Markus Heiser5377d912016-06-30 15:18:56 +02001.. -*- coding: utf-8; mode: rst -*-
2
Mauro Carvalho Chehabaf4a4d02016-07-01 13:42:29 -03003.. _VIDIOC_G_PARM:
Markus Heiser5377d912016-06-30 15:18:56 +02004
5**********************************
6ioctl VIDIOC_G_PARM, VIDIOC_S_PARM
7**********************************
8
Mauro Carvalho Chehab15e7d612016-07-05 15:14:35 -03009Name
Mauro Carvalho Chehab586027c2016-07-05 07:58:48 -030010====
Markus Heiser5377d912016-06-30 15:18:56 +020011
Mauro Carvalho Chehab586027c2016-07-05 07:58:48 -030012VIDIOC_G_PARM - VIDIOC_S_PARM - Get or set streaming parameters
Markus Heiser5377d912016-06-30 15:18:56 +020013
Mauro Carvalho Chehab15e7d612016-07-05 15:14:35 -030014
15Synopsis
Markus Heiser5377d912016-06-30 15:18:56 +020016========
17
Mauro Carvalho Chehab41d80462016-08-19 16:53:38 -030018.. c:function:: int ioctl( int fd, VIDIOC_G_PARM, v4l2_streamparm *argp )
19 :name: VIDIOC_G_PARM
20
21.. c:function:: int ioctl( int fd, VIDIOC_S_PARM, v4l2_streamparm *argp )
22 :name: VIDIOC_S_PARM
Markus Heiser5377d912016-06-30 15:18:56 +020023
Mauro Carvalho Chehab586027c2016-07-05 07:58:48 -030024
Mauro Carvalho Chehab15e7d612016-07-05 15:14:35 -030025Arguments
Markus Heiser5377d912016-06-30 15:18:56 +020026=========
27
28``fd``
29 File descriptor returned by :ref:`open() <func-open>`.
30
Markus Heiser5377d912016-06-30 15:18:56 +020031``argp``
32
33
Mauro Carvalho Chehab15e7d612016-07-05 15:14:35 -030034Description
Markus Heiser5377d912016-06-30 15:18:56 +020035===========
36
37The current video standard determines a nominal number of frames per
38second. If less than this number of frames is to be captured or output,
39applications can request frame skipping or duplicating on the driver
Mauro Carvalho Chehab760c7012016-07-04 12:56:17 -030040side. This is especially useful when using the :ref:`read() <func-read>` or
41:ref:`write() <func-write>`, which are not augmented by timestamps or sequence
Markus Heiser5377d912016-06-30 15:18:56 +020042counters, and to avoid unnecessary data copying.
43
44Further these ioctls can be used to determine the number of buffers used
45internally by a driver in read/write mode. For implications see the
46section discussing the :ref:`read() <func-read>` function.
47
48To get and set the streaming parameters applications call the
Mauro Carvalho Chehab4e03cb72016-07-03 10:02:29 -030049:ref:`VIDIOC_G_PARM <VIDIOC_G_PARM>` and :ref:`VIDIOC_S_PARM <VIDIOC_G_PARM>` ioctl, respectively. They take a
Mauro Carvalho Chehabfc78c7c2016-09-08 05:43:01 -030050pointer to a struct :c:type:`v4l2_streamparm` which contains a
Markus Heiser5377d912016-06-30 15:18:56 +020051union holding separate parameters for input and output devices.
52
53
Mauro Carvalho Chehab5bd4bb72016-08-17 08:14:19 -030054.. tabularcolumns:: |p{3.5cm}|p{3.5cm}|p{3.5cm}|p{7.0cm}|
55
Mauro Carvalho Chehabe8be7e92016-08-29 17:37:59 -030056.. c:type:: v4l2_streamparm
Mauro Carvalho Chehabfa92b04d2016-08-19 11:14:23 -030057
Markus Heiser5377d912016-06-30 15:18:56 +020058.. flat-table:: struct v4l2_streamparm
59 :header-rows: 0
60 :stub-columns: 0
61 :widths: 1 1 1 2
62
Laurent Pinchartc2b66ca2016-09-05 08:44:34 -030063 * - __u32
64 - ``type``
65 -
66 - The buffer (stream) type, same as struct
67 :c:type:`v4l2_format` ``type``, set by the
68 application. See :c:type:`v4l2_buf_type`
69 * - union
70 - ``parm``
71 -
72 -
73 * -
74 - struct :c:type:`v4l2_captureparm`
75 - ``capture``
76 - Parameters for capture devices, used when ``type`` is
77 ``V4L2_BUF_TYPE_VIDEO_CAPTURE``.
78 * -
79 - struct :c:type:`v4l2_outputparm`
80 - ``output``
81 - Parameters for output devices, used when ``type`` is
82 ``V4L2_BUF_TYPE_VIDEO_OUTPUT``.
83 * -
84 - __u8
85 - ``raw_data``\ [200]
86 - A place holder for future extensions.
Markus Heiser5377d912016-06-30 15:18:56 +020087
88
89
Mauro Carvalho Chehab5bd4bb72016-08-17 08:14:19 -030090.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
91
Mauro Carvalho Chehabe8be7e92016-08-29 17:37:59 -030092.. c:type:: v4l2_captureparm
Mauro Carvalho Chehabfa92b04d2016-08-19 11:14:23 -030093
Markus Heiser5377d912016-06-30 15:18:56 +020094.. flat-table:: struct v4l2_captureparm
95 :header-rows: 0
96 :stub-columns: 0
97 :widths: 1 1 2
98
Laurent Pinchartc2b66ca2016-09-05 08:44:34 -030099 * - __u32
100 - ``capability``
101 - See :ref:`parm-caps`.
102 * - __u32
103 - ``capturemode``
104 - Set by drivers and applications, see :ref:`parm-flags`.
105 * - struct :c:type:`v4l2_fract`
106 - ``timeperframe``
107 - This is the desired period between successive frames captured by
108 the driver, in seconds. The field is intended to skip frames on
109 the driver side, saving I/O bandwidth.
Markus Heiser5377d912016-06-30 15:18:56 +0200110
Laurent Pinchartc2b66ca2016-09-05 08:44:34 -0300111 Applications store here the desired frame period, drivers return
112 the actual frame period, which must be greater or equal to the
113 nominal frame period determined by the current video standard
114 (struct :c:type:`v4l2_standard` ``frameperiod``
115 field). Changing the video standard (also implicitly by switching
116 the video input) may reset this parameter to the nominal frame
117 period. To reset manually applications can just set this field to
118 zero.
Markus Heiser5377d912016-06-30 15:18:56 +0200119
Laurent Pinchartc2b66ca2016-09-05 08:44:34 -0300120 Drivers support this function only when they set the
121 ``V4L2_CAP_TIMEPERFRAME`` flag in the ``capability`` field.
122 * - __u32
123 - ``extendedmode``
124 - Custom (driver specific) streaming parameters. When unused,
125 applications and drivers must set this field to zero. Applications
126 using this field should check the driver name and version, see
127 :ref:`querycap`.
128 * - __u32
129 - ``readbuffers``
130 - Applications set this field to the desired number of buffers used
131 internally by the driver in :ref:`read() <func-read>` mode.
132 Drivers return the actual number of buffers. When an application
133 requests zero buffers, drivers should just return the current
134 setting rather than the minimum or an error code. For details see
135 :ref:`rw`.
136 * - __u32
137 - ``reserved``\ [4]
138 - Reserved for future extensions. Drivers and applications must set
139 the array to zero.
Markus Heiser5377d912016-06-30 15:18:56 +0200140
141
142
Mauro Carvalho Chehab5bd4bb72016-08-17 08:14:19 -0300143.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
144
Mauro Carvalho Chehabe8be7e92016-08-29 17:37:59 -0300145.. c:type:: v4l2_outputparm
Mauro Carvalho Chehabfa92b04d2016-08-19 11:14:23 -0300146
Markus Heiser5377d912016-06-30 15:18:56 +0200147.. flat-table:: struct v4l2_outputparm
148 :header-rows: 0
149 :stub-columns: 0
150 :widths: 1 1 2
151
Laurent Pinchartc2b66ca2016-09-05 08:44:34 -0300152 * - __u32
153 - ``capability``
154 - See :ref:`parm-caps`.
155 * - __u32
156 - ``outputmode``
157 - Set by drivers and applications, see :ref:`parm-flags`.
158 * - struct :c:type:`v4l2_fract`
159 - ``timeperframe``
160 - This is the desired period between successive frames output by the
161 driver, in seconds.
162 * - :cspan:`2`
Markus Heiser5377d912016-06-30 15:18:56 +0200163
Laurent Pinchartc2b66ca2016-09-05 08:44:34 -0300164 The field is intended to repeat frames on the driver side in
165 :ref:`write() <func-write>` mode (in streaming mode timestamps
166 can be used to throttle the output), saving I/O bandwidth.
Markus Heiser5377d912016-06-30 15:18:56 +0200167
Laurent Pinchartc2b66ca2016-09-05 08:44:34 -0300168 Applications store here the desired frame period, drivers return
169 the actual frame period, which must be greater or equal to the
170 nominal frame period determined by the current video standard
171 (struct :c:type:`v4l2_standard` ``frameperiod``
172 field). Changing the video standard (also implicitly by switching
173 the video output) may reset this parameter to the nominal frame
174 period. To reset manually applications can just set this field to
175 zero.
Markus Heiser5377d912016-06-30 15:18:56 +0200176
Laurent Pinchartc2b66ca2016-09-05 08:44:34 -0300177 Drivers support this function only when they set the
178 ``V4L2_CAP_TIMEPERFRAME`` flag in the ``capability`` field.
179 * - __u32
180 - ``extendedmode``
181 - Custom (driver specific) streaming parameters. When unused,
182 applications and drivers must set this field to zero. Applications
183 using this field should check the driver name and version, see
184 :ref:`querycap`.
185 * - __u32
186 - ``writebuffers``
187 - Applications set this field to the desired number of buffers used
188 internally by the driver in :ref:`write() <func-write>` mode. Drivers
189 return the actual number of buffers. When an application requests
190 zero buffers, drivers should just return the current setting
191 rather than the minimum or an error code. For details see
192 :ref:`rw`.
193 * - __u32
194 - ``reserved``\ [4]
195 - Reserved for future extensions. Drivers and applications must set
196 the array to zero.
Markus Heiser5377d912016-06-30 15:18:56 +0200197
198
199
Mauro Carvalho Chehab5bd4bb72016-08-17 08:14:19 -0300200.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
201
Mauro Carvalho Chehabfa92b04d2016-08-19 11:14:23 -0300202.. _parm-caps:
203
Markus Heiser5377d912016-06-30 15:18:56 +0200204.. flat-table:: Streaming Parameters Capabilites
205 :header-rows: 0
206 :stub-columns: 0
207 :widths: 3 1 4
208
Laurent Pinchartc2b66ca2016-09-05 08:44:34 -0300209 * - ``V4L2_CAP_TIMEPERFRAME``
210 - 0x1000
211 - The frame skipping/repeating controlled by the ``timeperframe``
212 field is supported.
Markus Heiser5377d912016-06-30 15:18:56 +0200213
214
215
Mauro Carvalho Chehab5bd4bb72016-08-17 08:14:19 -0300216.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
217
Mauro Carvalho Chehabfa92b04d2016-08-19 11:14:23 -0300218.. _parm-flags:
219
Markus Heiser5377d912016-06-30 15:18:56 +0200220.. flat-table:: Capture Parameters Flags
221 :header-rows: 0
222 :stub-columns: 0
223 :widths: 3 1 4
224
Laurent Pinchartc2b66ca2016-09-05 08:44:34 -0300225 * - ``V4L2_MODE_HIGHQUALITY``
226 - 0x0001
227 - High quality imaging mode. High quality mode is intended for still
228 imaging applications. The idea is to get the best possible image
229 quality that the hardware can deliver. It is not defined how the
230 driver writer may achieve that; it will depend on the hardware and
231 the ingenuity of the driver writer. High quality mode is a
232 different mode from the regular motion video capture modes. In
233 high quality mode:
Markus Heiser5377d912016-06-30 15:18:56 +0200234
Laurent Pinchartc2b66ca2016-09-05 08:44:34 -0300235 - The driver may be able to capture higher resolutions than for
236 motion capture.
Markus Heiser5377d912016-06-30 15:18:56 +0200237
Laurent Pinchartc2b66ca2016-09-05 08:44:34 -0300238 - The driver may support fewer pixel formats than motion capture
239 (eg; true color).
Markus Heiser5377d912016-06-30 15:18:56 +0200240
Laurent Pinchartc2b66ca2016-09-05 08:44:34 -0300241 - The driver may capture and arithmetically combine multiple
242 successive fields or frames to remove color edge artifacts and
243 reduce the noise in the video data.
Markus Heiser5377d912016-06-30 15:18:56 +0200244
Laurent Pinchartc2b66ca2016-09-05 08:44:34 -0300245 - The driver may capture images in slices like a scanner in order
246 to handle larger format images than would otherwise be
247 possible.
Markus Heiser5377d912016-06-30 15:18:56 +0200248
Laurent Pinchartc2b66ca2016-09-05 08:44:34 -0300249 - An image capture operation may be significantly slower than
250 motion capture.
Markus Heiser5377d912016-06-30 15:18:56 +0200251
Laurent Pinchartc2b66ca2016-09-05 08:44:34 -0300252 - Moving objects in the image might have excessive motion blur.
Markus Heiser5377d912016-06-30 15:18:56 +0200253
Laurent Pinchartc2b66ca2016-09-05 08:44:34 -0300254 - Capture might only work through the :ref:`read() <func-read>` call.
Markus Heiser5377d912016-06-30 15:18:56 +0200255
256
Mauro Carvalho Chehab15e7d612016-07-05 15:14:35 -0300257Return Value
Markus Heiser5377d912016-06-30 15:18:56 +0200258============
259
260On success 0 is returned, on error -1 and the ``errno`` variable is set
261appropriately. The generic error codes are described at the
262:ref:`Generic Error Codes <gen-errors>` chapter.