vidioc-g-parm.rst 8.7 KB
Newer Older
1 2
.. -*- coding: utf-8; mode: rst -*-

3
.. _VIDIOC_G_PARM:
4 5 6 7 8

**********************************
ioctl VIDIOC_G_PARM, VIDIOC_S_PARM
**********************************

9
Name
10
====
11

12
VIDIOC_G_PARM - VIDIOC_S_PARM - Get or set streaming parameters
13

14 15

Synopsis
16 17
========

18 19 20 21 22
.. c:function:: int ioctl( int fd, VIDIOC_G_PARM, v4l2_streamparm *argp )
    :name: VIDIOC_G_PARM

.. c:function:: int ioctl( int fd, VIDIOC_S_PARM, v4l2_streamparm *argp )
    :name: VIDIOC_S_PARM
23

24

25
Arguments
26 27 28 29 30 31 32 33
=========

``fd``
    File descriptor returned by :ref:`open() <func-open>`.

``argp``


34
Description
35 36 37 38 39
===========

The current video standard determines a nominal number of frames per
second. If less than this number of frames is to be captured or output,
applications can request frame skipping or duplicating on the driver
40 41
side. This is especially useful when using the :ref:`read() <func-read>` or
:ref:`write() <func-write>`, which are not augmented by timestamps or sequence
42 43 44 45 46 47 48
counters, and to avoid unnecessary data copying.

Further these ioctls can be used to determine the number of buffers used
internally by a driver in read/write mode. For implications see the
section discussing the :ref:`read() <func-read>` function.

To get and set the streaming parameters applications call the
49
:ref:`VIDIOC_G_PARM <VIDIOC_G_PARM>` and :ref:`VIDIOC_S_PARM <VIDIOC_G_PARM>` ioctl, respectively. They take a
50
pointer to a struct :c:type:`v4l2_streamparm` which contains a
51 52 53
union holding separate parameters for input and output devices.


54 55
.. tabularcolumns:: |p{3.5cm}|p{3.5cm}|p{3.5cm}|p{7.0cm}|

56
.. c:type:: v4l2_streamparm
57

58 59 60 61 62 63 64 65 66 67 68 69
.. flat-table:: struct v4l2_streamparm
    :header-rows:  0
    :stub-columns: 0
    :widths:       1 1 1 2


    -  .. row 1

       -  __u32

       -  ``type``

70
       -
71
       -  The buffer (stream) type, same as struct
72
	  :c:type:`v4l2_format` ``type``, set by the
73
	  application. See :c:type:`v4l2_buf_type`
74 75 76 77 78 79 80

    -  .. row 2

       -  union

       -  ``parm``

81 82
       -
       -
83 84 85

    -  .. row 3

86
       -
87
       -  struct :c:type:`v4l2_captureparm`
88 89 90 91

       -  ``capture``

       -  Parameters for capture devices, used when ``type`` is
92
	  ``V4L2_BUF_TYPE_VIDEO_CAPTURE``.
93 94 95

    -  .. row 4

96
       -
97
       -  struct :c:type:`v4l2_outputparm`
98 99 100 101

       -  ``output``

       -  Parameters for output devices, used when ``type`` is
102
	  ``V4L2_BUF_TYPE_VIDEO_OUTPUT``.
103 104 105

    -  .. row 5

106
       -
107 108
       -  __u8

109
       -  ``raw_data``\ [200]
110 111 112 113 114

       -  A place holder for future extensions.



115 116
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|

117
.. c:type:: v4l2_captureparm
118

119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
.. flat-table:: struct v4l2_captureparm
    :header-rows:  0
    :stub-columns: 0
    :widths:       1 1 2


    -  .. row 1

       -  __u32

       -  ``capability``

       -  See :ref:`parm-caps`.

    -  .. row 2

       -  __u32

       -  ``capturemode``

       -  Set by drivers and applications, see :ref:`parm-flags`.

    -  .. row 3

143
       -  struct :c:type:`v4l2_fract`
144 145 146 147

       -  ``timeperframe``

       -  This is the desired period between successive frames captured by
148 149
	  the driver, in seconds. The field is intended to skip frames on
	  the driver side, saving I/O bandwidth.
150

151 152 153
	  Applications store here the desired frame period, drivers return
	  the actual frame period, which must be greater or equal to the
	  nominal frame period determined by the current video standard
154
	  (struct :c:type:`v4l2_standard` ``frameperiod``
155 156 157 158
	  field). Changing the video standard (also implicitly by switching
	  the video input) may reset this parameter to the nominal frame
	  period. To reset manually applications can just set this field to
	  zero.
159

160 161
	  Drivers support this function only when they set the
	  ``V4L2_CAP_TIMEPERFRAME`` flag in the ``capability`` field.
162 163 164 165 166 167 168 169

    -  .. row 4

       -  __u32

       -  ``extendedmode``

       -  Custom (driver specific) streaming parameters. When unused,
170 171 172
	  applications and drivers must set this field to zero. Applications
	  using this field should check the driver name and version, see
	  :ref:`querycap`.
173 174 175 176 177 178 179 180

    -  .. row 5

       -  __u32

       -  ``readbuffers``

       -  Applications set this field to the desired number of buffers used
181 182 183 184 185
	  internally by the driver in :ref:`read() <func-read>` mode.
	  Drivers return the actual number of buffers. When an application
	  requests zero buffers, drivers should just return the current
	  setting rather than the minimum or an error code. For details see
	  :ref:`rw`.
186 187 188 189 190

    -  .. row 6

       -  __u32

191
       -  ``reserved``\ [4]
192 193

       -  Reserved for future extensions. Drivers and applications must set
194
	  the array to zero.
195 196 197



198 199
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|

200
.. c:type:: v4l2_outputparm
201

202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
.. flat-table:: struct v4l2_outputparm
    :header-rows:  0
    :stub-columns: 0
    :widths:       1 1 2


    -  .. row 1

       -  __u32

       -  ``capability``

       -  See :ref:`parm-caps`.

    -  .. row 2

       -  __u32

       -  ``outputmode``

       -  Set by drivers and applications, see :ref:`parm-flags`.

    -  .. row 3

226
       -  struct :c:type:`v4l2_fract`
227 228 229 230

       -  ``timeperframe``

       -  This is the desired period between successive frames output by the
231
	  driver, in seconds.
232 233 234 235 236

    -  .. row 4

       -  :cspan:`2`

237 238 239
	  The field is intended to repeat frames on the driver side in
	  :ref:`write() <func-write>` mode (in streaming mode timestamps
	  can be used to throttle the output), saving I/O bandwidth.
240

241 242 243
	  Applications store here the desired frame period, drivers return
	  the actual frame period, which must be greater or equal to the
	  nominal frame period determined by the current video standard
244
	  (struct :c:type:`v4l2_standard` ``frameperiod``
245 246 247 248
	  field). Changing the video standard (also implicitly by switching
	  the video output) may reset this parameter to the nominal frame
	  period. To reset manually applications can just set this field to
	  zero.
249

250 251
	  Drivers support this function only when they set the
	  ``V4L2_CAP_TIMEPERFRAME`` flag in the ``capability`` field.
252 253 254 255 256 257 258 259

    -  .. row 5

       -  __u32

       -  ``extendedmode``

       -  Custom (driver specific) streaming parameters. When unused,
260 261 262
	  applications and drivers must set this field to zero. Applications
	  using this field should check the driver name and version, see
	  :ref:`querycap`.
263 264 265 266 267 268 269 270

    -  .. row 6

       -  __u32

       -  ``writebuffers``

       -  Applications set this field to the desired number of buffers used
271 272 273 274 275
	  internally by the driver in :ref:`write() <func-write>` mode. Drivers
	  return the actual number of buffers. When an application requests
	  zero buffers, drivers should just return the current setting
	  rather than the minimum or an error code. For details see
	  :ref:`rw`.
276 277 278 279 280

    -  .. row 7

       -  __u32

281
       -  ``reserved``\ [4]
282 283

       -  Reserved for future extensions. Drivers and applications must set
284
	  the array to zero.
285 286 287



288 289
.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|

290 291
.. _parm-caps:

292 293 294 295 296 297 298 299 300 301 302 303 304
.. flat-table:: Streaming Parameters Capabilites
    :header-rows:  0
    :stub-columns: 0
    :widths:       3 1 4


    -  .. row 1

       -  ``V4L2_CAP_TIMEPERFRAME``

       -  0x1000

       -  The frame skipping/repeating controlled by the ``timeperframe``
305
	  field is supported.
306 307 308



309 310
.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|

311 312
.. _parm-flags:

313 314 315 316 317 318 319 320 321 322 323 324 325
.. flat-table:: Capture Parameters Flags
    :header-rows:  0
    :stub-columns: 0
    :widths:       3 1 4


    -  .. row 1

       -  ``V4L2_MODE_HIGHQUALITY``

       -  0x0001

       -  High quality imaging mode. High quality mode is intended for still
326 327 328 329 330 331
	  imaging applications. The idea is to get the best possible image
	  quality that the hardware can deliver. It is not defined how the
	  driver writer may achieve that; it will depend on the hardware and
	  the ingenuity of the driver writer. High quality mode is a
	  different mode from the regular motion video capture modes. In
	  high quality mode:
332

333 334
	  -  The driver may be able to capture higher resolutions than for
	     motion capture.
335

336 337
	  -  The driver may support fewer pixel formats than motion capture
	     (eg; true color).
338

339 340 341
	  -  The driver may capture and arithmetically combine multiple
	     successive fields or frames to remove color edge artifacts and
	     reduce the noise in the video data.
342

343 344 345
	  -  The driver may capture images in slices like a scanner in order
	     to handle larger format images than would otherwise be
	     possible.
346

347 348
	  -  An image capture operation may be significantly slower than
	     motion capture.
349

350
	  -  Moving objects in the image might have excessive motion blur.
351

352
	  -  Capture might only work through the :ref:`read() <func-read>` call.
353 354


355
Return Value
356 357 358 359 360
============

On success 0 is returned, on error -1 and the ``errno`` variable is set
appropriately. The generic error codes are described at the
:ref:`Generic Error Codes <gen-errors>` chapter.