0001 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
0002 .. c:namespace:: V4L
0003
0004 .. _VIDIOC_G_PARM:
0005
0006 **********************************
0007 ioctl VIDIOC_G_PARM, VIDIOC_S_PARM
0008 **********************************
0009
0010 Name
0011 ====
0012
0013 VIDIOC_G_PARM - VIDIOC_S_PARM - Get or set streaming parameters
0014
0015 Synopsis
0016 ========
0017
0018 .. c:macro:: VIDIOC_G_PARM
0019
0020 ``int ioctl(int fd, VIDIOC_G_PARM, v4l2_streamparm *argp)``
0021
0022 .. c:macro:: VIDIOC_S_PARM
0023
0024 ``int ioctl(int fd, VIDIOC_S_PARM, v4l2_streamparm *argp)``
0025
0026 Arguments
0027 =========
0028
0029 ``fd``
0030 File descriptor returned by :c:func:`open()`.
0031
0032 ``argp``
0033 Pointer to struct :c:type:`v4l2_streamparm`.
0034
0035 Description
0036 ===========
0037
0038 Applications can request a different frame interval. The capture or
0039 output device will be reconfigured to support the requested frame
0040 interval if possible. Optionally drivers may choose to skip or
0041 repeat frames to achieve the requested frame interval.
0042
0043 For stateful encoders (see :ref:`encoder`) this represents the
0044 frame interval that is typically embedded in the encoded video stream.
0045
0046 Changing the frame interval shall never change the format. Changing the
0047 format, on the other hand, may change the frame interval.
0048
0049 Further these ioctls can be used to determine the number of buffers used
0050 internally by a driver in read/write mode. For implications see the
0051 section discussing the :c:func:`read()` function.
0052
0053 To get and set the streaming parameters applications call the
0054 :ref:`VIDIOC_G_PARM <VIDIOC_G_PARM>` and
0055 :ref:`VIDIOC_S_PARM <VIDIOC_G_PARM>` ioctl, respectively. They take a
0056 pointer to a struct :c:type:`v4l2_streamparm` which contains a
0057 union holding separate parameters for input and output devices.
0058
0059 .. tabularcolumns:: |p{3.7cm}|p{3.5cm}|p{10.1cm}|
0060
0061 .. c:type:: v4l2_streamparm
0062
0063 .. flat-table:: struct v4l2_streamparm
0064 :header-rows: 0
0065 :stub-columns: 0
0066 :widths: 1 1 2
0067
0068 * - __u32
0069 - ``type``
0070 - The buffer (stream) type, same as struct
0071 :c:type:`v4l2_format` ``type``, set by the
0072 application. See :c:type:`v4l2_buf_type`.
0073 * - union {
0074 - ``parm``
0075 * - struct :c:type:`v4l2_captureparm`
0076 - ``capture``
0077 - Parameters for capture devices, used when ``type`` is
0078 ``V4L2_BUF_TYPE_VIDEO_CAPTURE`` or
0079 ``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE``.
0080 * - struct :c:type:`v4l2_outputparm`
0081 - ``output``
0082 - Parameters for output devices, used when ``type`` is
0083 ``V4L2_BUF_TYPE_VIDEO_OUTPUT`` or ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE``.
0084 * - __u8
0085 - ``raw_data``\ [200]
0086 - A place holder for future extensions.
0087 * - }
0088
0089
0090 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
0091
0092 .. c:type:: v4l2_captureparm
0093
0094 .. flat-table:: struct v4l2_captureparm
0095 :header-rows: 0
0096 :stub-columns: 0
0097 :widths: 1 1 2
0098
0099 * - __u32
0100 - ``capability``
0101 - See :ref:`parm-caps`.
0102 * - __u32
0103 - ``capturemode``
0104 - Set by drivers and applications, see :ref:`parm-flags`.
0105 * - struct :c:type:`v4l2_fract`
0106 - ``timeperframe``
0107 - This is the desired period between successive frames captured by
0108 the driver, in seconds.
0109 * - :cspan:`2`
0110
0111 This will configure the speed at which the video source (e.g. a sensor)
0112 generates video frames. If the speed is fixed, then the driver may
0113 choose to skip or repeat frames in order to achieve the requested
0114 frame rate.
0115
0116 For stateful encoders (see :ref:`encoder`) this represents the
0117 frame interval that is typically embedded in the encoded video stream.
0118
0119 Applications store here the desired frame period, drivers return
0120 the actual frame period.
0121
0122 Changing the video standard (also implicitly by switching
0123 the video input) may reset this parameter to the nominal frame
0124 period. To reset manually applications can just set this field to
0125 zero.
0126
0127 Drivers support this function only when they set the
0128 ``V4L2_CAP_TIMEPERFRAME`` flag in the ``capability`` field.
0129 * - __u32
0130 - ``extendedmode``
0131 - Custom (driver specific) streaming parameters. When unused,
0132 applications and drivers must set this field to zero. Applications
0133 using this field should check the driver name and version, see
0134 :ref:`querycap`.
0135 * - __u32
0136 - ``readbuffers``
0137 - Applications set this field to the desired number of buffers used
0138 internally by the driver in :c:func:`read()` mode.
0139 Drivers return the actual number of buffers. When an application
0140 requests zero buffers, drivers should just return the current
0141 setting rather than the minimum or an error code. For details see
0142 :ref:`rw`.
0143 * - __u32
0144 - ``reserved``\ [4]
0145 - Reserved for future extensions. Drivers and applications must set
0146 the array to zero.
0147
0148
0149 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
0150
0151 .. c:type:: v4l2_outputparm
0152
0153 .. flat-table:: struct v4l2_outputparm
0154 :header-rows: 0
0155 :stub-columns: 0
0156 :widths: 1 1 2
0157
0158 * - __u32
0159 - ``capability``
0160 - See :ref:`parm-caps`.
0161 * - __u32
0162 - ``outputmode``
0163 - Set by drivers and applications, see :ref:`parm-flags`.
0164 * - struct :c:type:`v4l2_fract`
0165 - ``timeperframe``
0166 - This is the desired period between successive frames output by the
0167 driver, in seconds.
0168 * - :cspan:`2`
0169
0170 The field is intended to repeat frames on the driver side in
0171 :c:func:`write()` mode (in streaming mode timestamps
0172 can be used to throttle the output), saving I/O bandwidth.
0173
0174 For stateful encoders (see :ref:`encoder`) this represents the
0175 frame interval that is typically embedded in the encoded video stream
0176 and it provides a hint to the encoder of the speed at which raw
0177 frames are queued up to the encoder.
0178
0179 Applications store here the desired frame period, drivers return
0180 the actual frame period.
0181
0182 Changing the video standard (also implicitly by switching
0183 the video output) may reset this parameter to the nominal frame
0184 period. To reset manually applications can just set this field to
0185 zero.
0186
0187 Drivers support this function only when they set the
0188 ``V4L2_CAP_TIMEPERFRAME`` flag in the ``capability`` field.
0189 * - __u32
0190 - ``extendedmode``
0191 - Custom (driver specific) streaming parameters. When unused,
0192 applications and drivers must set this field to zero. Applications
0193 using this field should check the driver name and version, see
0194 :ref:`querycap`.
0195 * - __u32
0196 - ``writebuffers``
0197 - Applications set this field to the desired number of buffers used
0198 internally by the driver in :c:func:`write()` mode. Drivers
0199 return the actual number of buffers. When an application requests
0200 zero buffers, drivers should just return the current setting
0201 rather than the minimum or an error code. For details see
0202 :ref:`rw`.
0203 * - __u32
0204 - ``reserved``\ [4]
0205 - Reserved for future extensions. Drivers and applications must set
0206 the array to zero.
0207
0208
0209 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|
0210
0211 .. _parm-caps:
0212
0213 .. flat-table:: Streaming Parameters Capabilities
0214 :header-rows: 0
0215 :stub-columns: 0
0216 :widths: 3 1 4
0217
0218 * - ``V4L2_CAP_TIMEPERFRAME``
0219 - 0x1000
0220 - The frame period can be modified by setting the ``timeperframe``
0221 field.
0222
0223
0224 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|
0225
0226 .. _parm-flags:
0227
0228 .. flat-table:: Capture Parameters Flags
0229 :header-rows: 0
0230 :stub-columns: 0
0231 :widths: 3 1 4
0232
0233 * - ``V4L2_MODE_HIGHQUALITY``
0234 - 0x0001
0235 - High quality imaging mode. High quality mode is intended for still
0236 imaging applications. The idea is to get the best possible image
0237 quality that the hardware can deliver. It is not defined how the
0238 driver writer may achieve that; it will depend on the hardware and
0239 the ingenuity of the driver writer. High quality mode is a
0240 different mode from the regular motion video capture modes. In
0241 high quality mode:
0242
0243 - The driver may be able to capture higher resolutions than for
0244 motion capture.
0245
0246 - The driver may support fewer pixel formats than motion capture
0247 (eg; true color).
0248
0249 - The driver may capture and arithmetically combine multiple
0250 successive fields or frames to remove color edge artifacts and
0251 reduce the noise in the video data.
0252
0253 - The driver may capture images in slices like a scanner in order
0254 to handle larger format images than would otherwise be
0255 possible.
0256
0257 - An image capture operation may be significantly slower than
0258 motion capture.
0259
0260 - Moving objects in the image might have excessive motion blur.
0261
0262 - Capture might only work through the :c:func:`read()` call.
0263
0264 Return Value
0265 ============
0266
0267 On success 0 is returned, on error -1 and the ``errno`` variable is set
0268 appropriately. The generic error codes are described at the
0269 :ref:`Generic Error Codes <gen-errors>` chapter.