xref: /openbmc/linux/Documentation/userspace-api/media/v4l/vidioc-g-parm.rst (revision 8be98d2f2a0a262f8bf8a0bc1fdf522b3c7aab17)
1059b1c5bSMauro Carvalho Chehab.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2407e84cdSMauro Carvalho Chehab.. c:namespace:: V4L
354f38fcaSMauro Carvalho Chehab
454f38fcaSMauro Carvalho Chehab.. _VIDIOC_G_PARM:
554f38fcaSMauro Carvalho Chehab
654f38fcaSMauro Carvalho Chehab**********************************
754f38fcaSMauro Carvalho Chehabioctl VIDIOC_G_PARM, VIDIOC_S_PARM
854f38fcaSMauro Carvalho Chehab**********************************
954f38fcaSMauro Carvalho Chehab
1054f38fcaSMauro Carvalho ChehabName
1154f38fcaSMauro Carvalho Chehab====
1254f38fcaSMauro Carvalho Chehab
1354f38fcaSMauro Carvalho ChehabVIDIOC_G_PARM - VIDIOC_S_PARM - Get or set streaming parameters
1454f38fcaSMauro Carvalho Chehab
1554f38fcaSMauro Carvalho ChehabSynopsis
1654f38fcaSMauro Carvalho Chehab========
1754f38fcaSMauro Carvalho Chehab
18407e84cdSMauro Carvalho Chehab.. c:macro:: VIDIOC_G_PARM
1954f38fcaSMauro Carvalho Chehab
20407e84cdSMauro Carvalho Chehab``int ioctl(int fd, VIDIOC_G_PARM, v4l2_streamparm *argp)``
2154f38fcaSMauro Carvalho Chehab
22407e84cdSMauro Carvalho Chehab.. c:macro:: VIDIOC_S_PARM
23407e84cdSMauro Carvalho Chehab
24407e84cdSMauro Carvalho Chehab``int ioctl(int fd, VIDIOC_S_PARM, v4l2_streamparm *argp)``
2554f38fcaSMauro Carvalho Chehab
2654f38fcaSMauro Carvalho ChehabArguments
2754f38fcaSMauro Carvalho Chehab=========
2854f38fcaSMauro Carvalho Chehab
2954f38fcaSMauro Carvalho Chehab``fd``
30407e84cdSMauro Carvalho Chehab    File descriptor returned by :c:func:`open()`.
3154f38fcaSMauro Carvalho Chehab
3254f38fcaSMauro Carvalho Chehab``argp``
3354f38fcaSMauro Carvalho Chehab    Pointer to struct :c:type:`v4l2_streamparm`.
3454f38fcaSMauro Carvalho Chehab
3554f38fcaSMauro Carvalho ChehabDescription
3654f38fcaSMauro Carvalho Chehab===========
3754f38fcaSMauro Carvalho Chehab
38aa2e479fSHans VerkuilApplications can request a different frame interval. The capture or
39aa2e479fSHans Verkuiloutput device will be reconfigured to support the requested frame
40aa2e479fSHans Verkuilinterval if possible. Optionally drivers may choose to skip or
41aa2e479fSHans Verkuilrepeat frames to achieve the requested frame interval.
42aa2e479fSHans Verkuil
43aa2e479fSHans VerkuilFor stateful encoders (see :ref:`encoder`) this represents the
44aa2e479fSHans Verkuilframe interval that is typically embedded in the encoded video stream.
4554f38fcaSMauro Carvalho Chehab
4654f38fcaSMauro Carvalho ChehabChanging the frame interval shall never change the format. Changing the
4754f38fcaSMauro Carvalho Chehabformat, on the other hand, may change the frame interval.
4854f38fcaSMauro Carvalho Chehab
4954f38fcaSMauro Carvalho ChehabFurther these ioctls can be used to determine the number of buffers used
5054f38fcaSMauro Carvalho Chehabinternally by a driver in read/write mode. For implications see the
51407e84cdSMauro Carvalho Chehabsection discussing the :c:func:`read()` function.
5254f38fcaSMauro Carvalho Chehab
5354f38fcaSMauro Carvalho ChehabTo get and set the streaming parameters applications call the
54aa2e479fSHans Verkuil:ref:`VIDIOC_G_PARM <VIDIOC_G_PARM>` and
55aa2e479fSHans Verkuil:ref:`VIDIOC_S_PARM <VIDIOC_G_PARM>` ioctl, respectively. They take a
5654f38fcaSMauro Carvalho Chehabpointer to a struct :c:type:`v4l2_streamparm` which contains a
5754f38fcaSMauro Carvalho Chehabunion holding separate parameters for input and output devices.
5854f38fcaSMauro Carvalho Chehab
59*fea13a69SMauro Carvalho Chehab.. tabularcolumns:: |p{3.7cm}|p{3.5cm}|p{10.1cm}|
6054f38fcaSMauro Carvalho Chehab
6154f38fcaSMauro Carvalho Chehab.. c:type:: v4l2_streamparm
6254f38fcaSMauro Carvalho Chehab
6354f38fcaSMauro Carvalho Chehab.. flat-table:: struct v4l2_streamparm
6454f38fcaSMauro Carvalho Chehab    :header-rows:  0
6554f38fcaSMauro Carvalho Chehab    :stub-columns: 0
6654f38fcaSMauro Carvalho Chehab    :widths:       1 1 2
6754f38fcaSMauro Carvalho Chehab
6854f38fcaSMauro Carvalho Chehab    * - __u32
6954f38fcaSMauro Carvalho Chehab      - ``type``
7054f38fcaSMauro Carvalho Chehab      - The buffer (stream) type, same as struct
7154f38fcaSMauro Carvalho Chehab	:c:type:`v4l2_format` ``type``, set by the
7254f38fcaSMauro Carvalho Chehab	application. See :c:type:`v4l2_buf_type`.
7354f38fcaSMauro Carvalho Chehab    * - union {
7454f38fcaSMauro Carvalho Chehab      - ``parm``
7554f38fcaSMauro Carvalho Chehab    * - struct :c:type:`v4l2_captureparm`
7654f38fcaSMauro Carvalho Chehab      - ``capture``
7754f38fcaSMauro Carvalho Chehab      - Parameters for capture devices, used when ``type`` is
7854f38fcaSMauro Carvalho Chehab	``V4L2_BUF_TYPE_VIDEO_CAPTURE`` or
7954f38fcaSMauro Carvalho Chehab	``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE``.
8054f38fcaSMauro Carvalho Chehab    * - struct :c:type:`v4l2_outputparm`
8154f38fcaSMauro Carvalho Chehab      - ``output``
8254f38fcaSMauro Carvalho Chehab      - Parameters for output devices, used when ``type`` is
8354f38fcaSMauro Carvalho Chehab	``V4L2_BUF_TYPE_VIDEO_OUTPUT`` or ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE``.
8454f38fcaSMauro Carvalho Chehab    * - __u8
8554f38fcaSMauro Carvalho Chehab      - ``raw_data``\ [200]
8654f38fcaSMauro Carvalho Chehab      - A place holder for future extensions.
8754f38fcaSMauro Carvalho Chehab    * - }
8854f38fcaSMauro Carvalho Chehab
8954f38fcaSMauro Carvalho Chehab
90*fea13a69SMauro Carvalho Chehab.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
9154f38fcaSMauro Carvalho Chehab
9254f38fcaSMauro Carvalho Chehab.. c:type:: v4l2_captureparm
9354f38fcaSMauro Carvalho Chehab
9454f38fcaSMauro Carvalho Chehab.. flat-table:: struct v4l2_captureparm
9554f38fcaSMauro Carvalho Chehab    :header-rows:  0
9654f38fcaSMauro Carvalho Chehab    :stub-columns: 0
9754f38fcaSMauro Carvalho Chehab    :widths:       1 1 2
9854f38fcaSMauro Carvalho Chehab
9954f38fcaSMauro Carvalho Chehab    * - __u32
10054f38fcaSMauro Carvalho Chehab      - ``capability``
10154f38fcaSMauro Carvalho Chehab      - See :ref:`parm-caps`.
10254f38fcaSMauro Carvalho Chehab    * - __u32
10354f38fcaSMauro Carvalho Chehab      - ``capturemode``
10454f38fcaSMauro Carvalho Chehab      - Set by drivers and applications, see :ref:`parm-flags`.
10554f38fcaSMauro Carvalho Chehab    * - struct :c:type:`v4l2_fract`
10654f38fcaSMauro Carvalho Chehab      - ``timeperframe``
10754f38fcaSMauro Carvalho Chehab      - This is the desired period between successive frames captured by
108aa2e479fSHans Verkuil	the driver, in seconds.
109aa2e479fSHans Verkuil    * - :cspan:`2`
110aa2e479fSHans Verkuil
111aa2e479fSHans Verkuil	This will configure the speed at which the video source (e.g. a sensor)
112aa2e479fSHans Verkuil	generates video frames. If the speed is fixed, then the driver may
113aa2e479fSHans Verkuil	choose to skip or repeat frames in order to achieve the requested
114aa2e479fSHans Verkuil	frame rate.
115aa2e479fSHans Verkuil
116aa2e479fSHans Verkuil	For stateful encoders (see :ref:`encoder`) this represents the
117aa2e479fSHans Verkuil	frame interval that is typically embedded in the encoded video stream.
11854f38fcaSMauro Carvalho Chehab
11954f38fcaSMauro Carvalho Chehab	Applications store here the desired frame period, drivers return
120aa2e479fSHans Verkuil	the actual frame period.
121aa2e479fSHans Verkuil
122aa2e479fSHans Verkuil	Changing the video standard (also implicitly by switching
12354f38fcaSMauro Carvalho Chehab	the video input) may reset this parameter to the nominal frame
12454f38fcaSMauro Carvalho Chehab	period. To reset manually applications can just set this field to
12554f38fcaSMauro Carvalho Chehab	zero.
12654f38fcaSMauro Carvalho Chehab
12754f38fcaSMauro Carvalho Chehab	Drivers support this function only when they set the
12854f38fcaSMauro Carvalho Chehab	``V4L2_CAP_TIMEPERFRAME`` flag in the ``capability`` field.
12954f38fcaSMauro Carvalho Chehab    * - __u32
13054f38fcaSMauro Carvalho Chehab      - ``extendedmode``
13154f38fcaSMauro Carvalho Chehab      - Custom (driver specific) streaming parameters. When unused,
13254f38fcaSMauro Carvalho Chehab	applications and drivers must set this field to zero. Applications
13354f38fcaSMauro Carvalho Chehab	using this field should check the driver name and version, see
13454f38fcaSMauro Carvalho Chehab	:ref:`querycap`.
13554f38fcaSMauro Carvalho Chehab    * - __u32
13654f38fcaSMauro Carvalho Chehab      - ``readbuffers``
13754f38fcaSMauro Carvalho Chehab      - Applications set this field to the desired number of buffers used
138407e84cdSMauro Carvalho Chehab	internally by the driver in :c:func:`read()` mode.
13954f38fcaSMauro Carvalho Chehab	Drivers return the actual number of buffers. When an application
14054f38fcaSMauro Carvalho Chehab	requests zero buffers, drivers should just return the current
14154f38fcaSMauro Carvalho Chehab	setting rather than the minimum or an error code. For details see
14254f38fcaSMauro Carvalho Chehab	:ref:`rw`.
14354f38fcaSMauro Carvalho Chehab    * - __u32
14454f38fcaSMauro Carvalho Chehab      - ``reserved``\ [4]
14554f38fcaSMauro Carvalho Chehab      - Reserved for future extensions. Drivers and applications must set
14654f38fcaSMauro Carvalho Chehab	the array to zero.
14754f38fcaSMauro Carvalho Chehab
14854f38fcaSMauro Carvalho Chehab
149*fea13a69SMauro Carvalho Chehab.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
15054f38fcaSMauro Carvalho Chehab
15154f38fcaSMauro Carvalho Chehab.. c:type:: v4l2_outputparm
15254f38fcaSMauro Carvalho Chehab
15354f38fcaSMauro Carvalho Chehab.. flat-table:: struct v4l2_outputparm
15454f38fcaSMauro Carvalho Chehab    :header-rows:  0
15554f38fcaSMauro Carvalho Chehab    :stub-columns: 0
15654f38fcaSMauro Carvalho Chehab    :widths:       1 1 2
15754f38fcaSMauro Carvalho Chehab
15854f38fcaSMauro Carvalho Chehab    * - __u32
15954f38fcaSMauro Carvalho Chehab      - ``capability``
16054f38fcaSMauro Carvalho Chehab      - See :ref:`parm-caps`.
16154f38fcaSMauro Carvalho Chehab    * - __u32
16254f38fcaSMauro Carvalho Chehab      - ``outputmode``
16354f38fcaSMauro Carvalho Chehab      - Set by drivers and applications, see :ref:`parm-flags`.
16454f38fcaSMauro Carvalho Chehab    * - struct :c:type:`v4l2_fract`
16554f38fcaSMauro Carvalho Chehab      - ``timeperframe``
16654f38fcaSMauro Carvalho Chehab      - This is the desired period between successive frames output by the
16754f38fcaSMauro Carvalho Chehab	driver, in seconds.
16854f38fcaSMauro Carvalho Chehab    * - :cspan:`2`
16954f38fcaSMauro Carvalho Chehab
17054f38fcaSMauro Carvalho Chehab	The field is intended to repeat frames on the driver side in
171407e84cdSMauro Carvalho Chehab	:c:func:`write()` mode (in streaming mode timestamps
17254f38fcaSMauro Carvalho Chehab	can be used to throttle the output), saving I/O bandwidth.
17354f38fcaSMauro Carvalho Chehab
174aa2e479fSHans Verkuil	For stateful encoders (see :ref:`encoder`) this represents the
175aa2e479fSHans Verkuil	frame interval that is typically embedded in the encoded video stream
176aa2e479fSHans Verkuil	and it provides a hint to the encoder of the speed at which raw
177aa2e479fSHans Verkuil	frames are queued up to the encoder.
178aa2e479fSHans Verkuil
17954f38fcaSMauro Carvalho Chehab	Applications store here the desired frame period, drivers return
180aa2e479fSHans Verkuil	the actual frame period.
181aa2e479fSHans Verkuil
182aa2e479fSHans Verkuil	Changing the video standard (also implicitly by switching
18354f38fcaSMauro Carvalho Chehab	the video output) may reset this parameter to the nominal frame
18454f38fcaSMauro Carvalho Chehab	period. To reset manually applications can just set this field to
18554f38fcaSMauro Carvalho Chehab	zero.
18654f38fcaSMauro Carvalho Chehab
18754f38fcaSMauro Carvalho Chehab	Drivers support this function only when they set the
18854f38fcaSMauro Carvalho Chehab	``V4L2_CAP_TIMEPERFRAME`` flag in the ``capability`` field.
18954f38fcaSMauro Carvalho Chehab    * - __u32
19054f38fcaSMauro Carvalho Chehab      - ``extendedmode``
19154f38fcaSMauro Carvalho Chehab      - Custom (driver specific) streaming parameters. When unused,
19254f38fcaSMauro Carvalho Chehab	applications and drivers must set this field to zero. Applications
19354f38fcaSMauro Carvalho Chehab	using this field should check the driver name and version, see
19454f38fcaSMauro Carvalho Chehab	:ref:`querycap`.
19554f38fcaSMauro Carvalho Chehab    * - __u32
19654f38fcaSMauro Carvalho Chehab      - ``writebuffers``
19754f38fcaSMauro Carvalho Chehab      - Applications set this field to the desired number of buffers used
198407e84cdSMauro Carvalho Chehab	internally by the driver in :c:func:`write()` mode. Drivers
19954f38fcaSMauro Carvalho Chehab	return the actual number of buffers. When an application requests
20054f38fcaSMauro Carvalho Chehab	zero buffers, drivers should just return the current setting
20154f38fcaSMauro Carvalho Chehab	rather than the minimum or an error code. For details see
20254f38fcaSMauro Carvalho Chehab	:ref:`rw`.
20354f38fcaSMauro Carvalho Chehab    * - __u32
20454f38fcaSMauro Carvalho Chehab      - ``reserved``\ [4]
20554f38fcaSMauro Carvalho Chehab      - Reserved for future extensions. Drivers and applications must set
20654f38fcaSMauro Carvalho Chehab	the array to zero.
20754f38fcaSMauro Carvalho Chehab
20854f38fcaSMauro Carvalho Chehab
209*fea13a69SMauro Carvalho Chehab.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|
21054f38fcaSMauro Carvalho Chehab
21154f38fcaSMauro Carvalho Chehab.. _parm-caps:
21254f38fcaSMauro Carvalho Chehab
21354f38fcaSMauro Carvalho Chehab.. flat-table:: Streaming Parameters Capabilities
21454f38fcaSMauro Carvalho Chehab    :header-rows:  0
21554f38fcaSMauro Carvalho Chehab    :stub-columns: 0
21654f38fcaSMauro Carvalho Chehab    :widths:       3 1 4
21754f38fcaSMauro Carvalho Chehab
21854f38fcaSMauro Carvalho Chehab    * - ``V4L2_CAP_TIMEPERFRAME``
21954f38fcaSMauro Carvalho Chehab      - 0x1000
220aa2e479fSHans Verkuil      - The frame period can be modified by setting the ``timeperframe``
221aa2e479fSHans Verkuil	field.
22254f38fcaSMauro Carvalho Chehab
22354f38fcaSMauro Carvalho Chehab
224*fea13a69SMauro Carvalho Chehab.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|
22554f38fcaSMauro Carvalho Chehab
22654f38fcaSMauro Carvalho Chehab.. _parm-flags:
22754f38fcaSMauro Carvalho Chehab
22854f38fcaSMauro Carvalho Chehab.. flat-table:: Capture Parameters Flags
22954f38fcaSMauro Carvalho Chehab    :header-rows:  0
23054f38fcaSMauro Carvalho Chehab    :stub-columns: 0
23154f38fcaSMauro Carvalho Chehab    :widths:       3 1 4
23254f38fcaSMauro Carvalho Chehab
23354f38fcaSMauro Carvalho Chehab    * - ``V4L2_MODE_HIGHQUALITY``
23454f38fcaSMauro Carvalho Chehab      - 0x0001
23554f38fcaSMauro Carvalho Chehab      - High quality imaging mode. High quality mode is intended for still
23654f38fcaSMauro Carvalho Chehab	imaging applications. The idea is to get the best possible image
23754f38fcaSMauro Carvalho Chehab	quality that the hardware can deliver. It is not defined how the
23854f38fcaSMauro Carvalho Chehab	driver writer may achieve that; it will depend on the hardware and
23954f38fcaSMauro Carvalho Chehab	the ingenuity of the driver writer. High quality mode is a
24054f38fcaSMauro Carvalho Chehab	different mode from the regular motion video capture modes. In
24154f38fcaSMauro Carvalho Chehab	high quality mode:
24254f38fcaSMauro Carvalho Chehab
24354f38fcaSMauro Carvalho Chehab	-  The driver may be able to capture higher resolutions than for
24454f38fcaSMauro Carvalho Chehab	   motion capture.
24554f38fcaSMauro Carvalho Chehab
24654f38fcaSMauro Carvalho Chehab	-  The driver may support fewer pixel formats than motion capture
24754f38fcaSMauro Carvalho Chehab	   (eg; true color).
24854f38fcaSMauro Carvalho Chehab
24954f38fcaSMauro Carvalho Chehab	-  The driver may capture and arithmetically combine multiple
25054f38fcaSMauro Carvalho Chehab	   successive fields or frames to remove color edge artifacts and
25154f38fcaSMauro Carvalho Chehab	   reduce the noise in the video data.
25254f38fcaSMauro Carvalho Chehab
25354f38fcaSMauro Carvalho Chehab	-  The driver may capture images in slices like a scanner in order
25454f38fcaSMauro Carvalho Chehab	   to handle larger format images than would otherwise be
25554f38fcaSMauro Carvalho Chehab	   possible.
25654f38fcaSMauro Carvalho Chehab
25754f38fcaSMauro Carvalho Chehab	-  An image capture operation may be significantly slower than
25854f38fcaSMauro Carvalho Chehab	   motion capture.
25954f38fcaSMauro Carvalho Chehab
26054f38fcaSMauro Carvalho Chehab	-  Moving objects in the image might have excessive motion blur.
26154f38fcaSMauro Carvalho Chehab
262407e84cdSMauro Carvalho Chehab	-  Capture might only work through the :c:func:`read()` call.
26354f38fcaSMauro Carvalho Chehab
26454f38fcaSMauro Carvalho ChehabReturn Value
26554f38fcaSMauro Carvalho Chehab============
26654f38fcaSMauro Carvalho Chehab
26754f38fcaSMauro Carvalho ChehabOn success 0 is returned, on error -1 and the ``errno`` variable is set
26854f38fcaSMauro Carvalho Chehabappropriately. The generic error codes are described at the
26954f38fcaSMauro Carvalho Chehab:ref:`Generic Error Codes <gen-errors>` chapter.
270