162306a36Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
262306a36Sopenharmony_ci.. c:namespace:: V4L
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci.. _VIDIOC_G_PARM:
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci**********************************
762306a36Sopenharmony_ciioctl VIDIOC_G_PARM, VIDIOC_S_PARM
862306a36Sopenharmony_ci**********************************
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ciName
1162306a36Sopenharmony_ci====
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ciVIDIOC_G_PARM - VIDIOC_S_PARM - Get or set streaming parameters
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ciSynopsis
1662306a36Sopenharmony_ci========
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci.. c:macro:: VIDIOC_G_PARM
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci``int ioctl(int fd, VIDIOC_G_PARM, v4l2_streamparm *argp)``
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci.. c:macro:: VIDIOC_S_PARM
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci``int ioctl(int fd, VIDIOC_S_PARM, v4l2_streamparm *argp)``
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ciArguments
2762306a36Sopenharmony_ci=========
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci``fd``
3062306a36Sopenharmony_ci    File descriptor returned by :c:func:`open()`.
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci``argp``
3362306a36Sopenharmony_ci    Pointer to struct :c:type:`v4l2_streamparm`.
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ciDescription
3662306a36Sopenharmony_ci===========
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ciApplications can request a different frame interval. The capture or
3962306a36Sopenharmony_cioutput device will be reconfigured to support the requested frame
4062306a36Sopenharmony_ciinterval if possible. Optionally drivers may choose to skip or
4162306a36Sopenharmony_cirepeat frames to achieve the requested frame interval.
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ciFor stateful encoders (see :ref:`encoder`) this represents the
4462306a36Sopenharmony_ciframe interval that is typically embedded in the encoded video stream.
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ciChanging the frame interval shall never change the format. Changing the
4762306a36Sopenharmony_ciformat, on the other hand, may change the frame interval.
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ciFurther these ioctls can be used to determine the number of buffers used
5062306a36Sopenharmony_ciinternally by a driver in read/write mode. For implications see the
5162306a36Sopenharmony_cisection discussing the :c:func:`read()` function.
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ciTo get and set the streaming parameters applications call the
5462306a36Sopenharmony_ci:ref:`VIDIOC_G_PARM <VIDIOC_G_PARM>` and
5562306a36Sopenharmony_ci:ref:`VIDIOC_S_PARM <VIDIOC_G_PARM>` ioctl, respectively. They take a
5662306a36Sopenharmony_cipointer to a struct :c:type:`v4l2_streamparm` which contains a
5762306a36Sopenharmony_ciunion holding separate parameters for input and output devices.
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci.. tabularcolumns:: |p{3.7cm}|p{3.5cm}|p{10.1cm}|
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci.. c:type:: v4l2_streamparm
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci.. flat-table:: struct v4l2_streamparm
6462306a36Sopenharmony_ci    :header-rows:  0
6562306a36Sopenharmony_ci    :stub-columns: 0
6662306a36Sopenharmony_ci    :widths:       1 1 2
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci    * - __u32
6962306a36Sopenharmony_ci      - ``type``
7062306a36Sopenharmony_ci      - The buffer (stream) type, same as struct
7162306a36Sopenharmony_ci	:c:type:`v4l2_format` ``type``, set by the
7262306a36Sopenharmony_ci	application. See :c:type:`v4l2_buf_type`.
7362306a36Sopenharmony_ci    * - union {
7462306a36Sopenharmony_ci      - ``parm``
7562306a36Sopenharmony_ci    * - struct :c:type:`v4l2_captureparm`
7662306a36Sopenharmony_ci      - ``capture``
7762306a36Sopenharmony_ci      - Parameters for capture devices, used when ``type`` is
7862306a36Sopenharmony_ci	``V4L2_BUF_TYPE_VIDEO_CAPTURE`` or
7962306a36Sopenharmony_ci	``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE``.
8062306a36Sopenharmony_ci    * - struct :c:type:`v4l2_outputparm`
8162306a36Sopenharmony_ci      - ``output``
8262306a36Sopenharmony_ci      - Parameters for output devices, used when ``type`` is
8362306a36Sopenharmony_ci	``V4L2_BUF_TYPE_VIDEO_OUTPUT`` or ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE``.
8462306a36Sopenharmony_ci    * - __u8
8562306a36Sopenharmony_ci      - ``raw_data``\ [200]
8662306a36Sopenharmony_ci      - A place holder for future extensions.
8762306a36Sopenharmony_ci    * - }
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_ci.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_ci.. c:type:: v4l2_captureparm
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci.. flat-table:: struct v4l2_captureparm
9562306a36Sopenharmony_ci    :header-rows:  0
9662306a36Sopenharmony_ci    :stub-columns: 0
9762306a36Sopenharmony_ci    :widths:       1 1 2
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci    * - __u32
10062306a36Sopenharmony_ci      - ``capability``
10162306a36Sopenharmony_ci      - See :ref:`parm-caps`.
10262306a36Sopenharmony_ci    * - __u32
10362306a36Sopenharmony_ci      - ``capturemode``
10462306a36Sopenharmony_ci      - Set by drivers and applications, see :ref:`parm-flags`.
10562306a36Sopenharmony_ci    * - struct :c:type:`v4l2_fract`
10662306a36Sopenharmony_ci      - ``timeperframe``
10762306a36Sopenharmony_ci      - This is the desired period between successive frames captured by
10862306a36Sopenharmony_ci	the driver, in seconds.
10962306a36Sopenharmony_ci    * - :cspan:`2`
11062306a36Sopenharmony_ci
11162306a36Sopenharmony_ci	This will configure the speed at which the video source (e.g. a sensor)
11262306a36Sopenharmony_ci	generates video frames. If the speed is fixed, then the driver may
11362306a36Sopenharmony_ci	choose to skip or repeat frames in order to achieve the requested
11462306a36Sopenharmony_ci	frame rate.
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_ci	For stateful encoders (see :ref:`encoder`) this represents the
11762306a36Sopenharmony_ci	frame interval that is typically embedded in the encoded video stream.
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ci	Applications store here the desired frame period, drivers return
12062306a36Sopenharmony_ci	the actual frame period.
12162306a36Sopenharmony_ci
12262306a36Sopenharmony_ci	Changing the video standard (also implicitly by switching
12362306a36Sopenharmony_ci	the video input) may reset this parameter to the nominal frame
12462306a36Sopenharmony_ci	period. To reset manually applications can just set this field to
12562306a36Sopenharmony_ci	zero.
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_ci	Drivers support this function only when they set the
12862306a36Sopenharmony_ci	``V4L2_CAP_TIMEPERFRAME`` flag in the ``capability`` field.
12962306a36Sopenharmony_ci    * - __u32
13062306a36Sopenharmony_ci      - ``extendedmode``
13162306a36Sopenharmony_ci      - Custom (driver specific) streaming parameters. When unused,
13262306a36Sopenharmony_ci	applications and drivers must set this field to zero. Applications
13362306a36Sopenharmony_ci	using this field should check the driver name and version, see
13462306a36Sopenharmony_ci	:ref:`querycap`.
13562306a36Sopenharmony_ci    * - __u32
13662306a36Sopenharmony_ci      - ``readbuffers``
13762306a36Sopenharmony_ci      - Applications set this field to the desired number of buffers used
13862306a36Sopenharmony_ci	internally by the driver in :c:func:`read()` mode.
13962306a36Sopenharmony_ci	Drivers return the actual number of buffers. When an application
14062306a36Sopenharmony_ci	requests zero buffers, drivers should just return the current
14162306a36Sopenharmony_ci	setting rather than the minimum or an error code. For details see
14262306a36Sopenharmony_ci	:ref:`rw`.
14362306a36Sopenharmony_ci    * - __u32
14462306a36Sopenharmony_ci      - ``reserved``\ [4]
14562306a36Sopenharmony_ci      - Reserved for future extensions. Drivers and applications must set
14662306a36Sopenharmony_ci	the array to zero.
14762306a36Sopenharmony_ci
14862306a36Sopenharmony_ci
14962306a36Sopenharmony_ci.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ci.. c:type:: v4l2_outputparm
15262306a36Sopenharmony_ci
15362306a36Sopenharmony_ci.. flat-table:: struct v4l2_outputparm
15462306a36Sopenharmony_ci    :header-rows:  0
15562306a36Sopenharmony_ci    :stub-columns: 0
15662306a36Sopenharmony_ci    :widths:       1 1 2
15762306a36Sopenharmony_ci
15862306a36Sopenharmony_ci    * - __u32
15962306a36Sopenharmony_ci      - ``capability``
16062306a36Sopenharmony_ci      - See :ref:`parm-caps`.
16162306a36Sopenharmony_ci    * - __u32
16262306a36Sopenharmony_ci      - ``outputmode``
16362306a36Sopenharmony_ci      - Set by drivers and applications, see :ref:`parm-flags`.
16462306a36Sopenharmony_ci    * - struct :c:type:`v4l2_fract`
16562306a36Sopenharmony_ci      - ``timeperframe``
16662306a36Sopenharmony_ci      - This is the desired period between successive frames output by the
16762306a36Sopenharmony_ci	driver, in seconds.
16862306a36Sopenharmony_ci    * - :cspan:`2`
16962306a36Sopenharmony_ci
17062306a36Sopenharmony_ci	The field is intended to repeat frames on the driver side in
17162306a36Sopenharmony_ci	:c:func:`write()` mode (in streaming mode timestamps
17262306a36Sopenharmony_ci	can be used to throttle the output), saving I/O bandwidth.
17362306a36Sopenharmony_ci
17462306a36Sopenharmony_ci	For stateful encoders (see :ref:`encoder`) this represents the
17562306a36Sopenharmony_ci	frame interval that is typically embedded in the encoded video stream
17662306a36Sopenharmony_ci	and it provides a hint to the encoder of the speed at which raw
17762306a36Sopenharmony_ci	frames are queued up to the encoder.
17862306a36Sopenharmony_ci
17962306a36Sopenharmony_ci	Applications store here the desired frame period, drivers return
18062306a36Sopenharmony_ci	the actual frame period.
18162306a36Sopenharmony_ci
18262306a36Sopenharmony_ci	Changing the video standard (also implicitly by switching
18362306a36Sopenharmony_ci	the video output) may reset this parameter to the nominal frame
18462306a36Sopenharmony_ci	period. To reset manually applications can just set this field to
18562306a36Sopenharmony_ci	zero.
18662306a36Sopenharmony_ci
18762306a36Sopenharmony_ci	Drivers support this function only when they set the
18862306a36Sopenharmony_ci	``V4L2_CAP_TIMEPERFRAME`` flag in the ``capability`` field.
18962306a36Sopenharmony_ci    * - __u32
19062306a36Sopenharmony_ci      - ``extendedmode``
19162306a36Sopenharmony_ci      - Custom (driver specific) streaming parameters. When unused,
19262306a36Sopenharmony_ci	applications and drivers must set this field to zero. Applications
19362306a36Sopenharmony_ci	using this field should check the driver name and version, see
19462306a36Sopenharmony_ci	:ref:`querycap`.
19562306a36Sopenharmony_ci    * - __u32
19662306a36Sopenharmony_ci      - ``writebuffers``
19762306a36Sopenharmony_ci      - Applications set this field to the desired number of buffers used
19862306a36Sopenharmony_ci	internally by the driver in :c:func:`write()` mode. Drivers
19962306a36Sopenharmony_ci	return the actual number of buffers. When an application requests
20062306a36Sopenharmony_ci	zero buffers, drivers should just return the current setting
20162306a36Sopenharmony_ci	rather than the minimum or an error code. For details see
20262306a36Sopenharmony_ci	:ref:`rw`.
20362306a36Sopenharmony_ci    * - __u32
20462306a36Sopenharmony_ci      - ``reserved``\ [4]
20562306a36Sopenharmony_ci      - Reserved for future extensions. Drivers and applications must set
20662306a36Sopenharmony_ci	the array to zero.
20762306a36Sopenharmony_ci
20862306a36Sopenharmony_ci
20962306a36Sopenharmony_ci.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|
21062306a36Sopenharmony_ci
21162306a36Sopenharmony_ci.. _parm-caps:
21262306a36Sopenharmony_ci
21362306a36Sopenharmony_ci.. flat-table:: Streaming Parameters Capabilities
21462306a36Sopenharmony_ci    :header-rows:  0
21562306a36Sopenharmony_ci    :stub-columns: 0
21662306a36Sopenharmony_ci    :widths:       3 1 4
21762306a36Sopenharmony_ci
21862306a36Sopenharmony_ci    * - ``V4L2_CAP_TIMEPERFRAME``
21962306a36Sopenharmony_ci      - 0x1000
22062306a36Sopenharmony_ci      - The frame period can be modified by setting the ``timeperframe``
22162306a36Sopenharmony_ci	field.
22262306a36Sopenharmony_ci
22362306a36Sopenharmony_ci
22462306a36Sopenharmony_ci.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|
22562306a36Sopenharmony_ci
22662306a36Sopenharmony_ci.. _parm-flags:
22762306a36Sopenharmony_ci
22862306a36Sopenharmony_ci.. flat-table:: Capture Parameters Flags
22962306a36Sopenharmony_ci    :header-rows:  0
23062306a36Sopenharmony_ci    :stub-columns: 0
23162306a36Sopenharmony_ci    :widths:       3 1 4
23262306a36Sopenharmony_ci
23362306a36Sopenharmony_ci    * - ``V4L2_MODE_HIGHQUALITY``
23462306a36Sopenharmony_ci      - 0x0001
23562306a36Sopenharmony_ci      - High quality imaging mode. High quality mode is intended for still
23662306a36Sopenharmony_ci	imaging applications. The idea is to get the best possible image
23762306a36Sopenharmony_ci	quality that the hardware can deliver. It is not defined how the
23862306a36Sopenharmony_ci	driver writer may achieve that; it will depend on the hardware and
23962306a36Sopenharmony_ci	the ingenuity of the driver writer. High quality mode is a
24062306a36Sopenharmony_ci	different mode from the regular motion video capture modes. In
24162306a36Sopenharmony_ci	high quality mode:
24262306a36Sopenharmony_ci
24362306a36Sopenharmony_ci	-  The driver may be able to capture higher resolutions than for
24462306a36Sopenharmony_ci	   motion capture.
24562306a36Sopenharmony_ci
24662306a36Sopenharmony_ci	-  The driver may support fewer pixel formats than motion capture
24762306a36Sopenharmony_ci	   (eg; true color).
24862306a36Sopenharmony_ci
24962306a36Sopenharmony_ci	-  The driver may capture and arithmetically combine multiple
25062306a36Sopenharmony_ci	   successive fields or frames to remove color edge artifacts and
25162306a36Sopenharmony_ci	   reduce the noise in the video data.
25262306a36Sopenharmony_ci
25362306a36Sopenharmony_ci	-  The driver may capture images in slices like a scanner in order
25462306a36Sopenharmony_ci	   to handle larger format images than would otherwise be
25562306a36Sopenharmony_ci	   possible.
25662306a36Sopenharmony_ci
25762306a36Sopenharmony_ci	-  An image capture operation may be significantly slower than
25862306a36Sopenharmony_ci	   motion capture.
25962306a36Sopenharmony_ci
26062306a36Sopenharmony_ci	-  Moving objects in the image might have excessive motion blur.
26162306a36Sopenharmony_ci
26262306a36Sopenharmony_ci	-  Capture might only work through the :c:func:`read()` call.
26362306a36Sopenharmony_ci
26462306a36Sopenharmony_ciReturn Value
26562306a36Sopenharmony_ci============
26662306a36Sopenharmony_ci
26762306a36Sopenharmony_ciOn success 0 is returned, on error -1 and the ``errno`` variable is set
26862306a36Sopenharmony_ciappropriately. The generic error codes are described at the
26962306a36Sopenharmony_ci:ref:`Generic Error Codes <gen-errors>` chapter.
270