xref: /OK3568_Linux_fs/kernel/Documentation/userspace-api/media/v4l/vidioc-g-parm.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2*4882a593Smuzhiyun.. c:namespace:: V4L
3*4882a593Smuzhiyun
4*4882a593Smuzhiyun.. _VIDIOC_G_PARM:
5*4882a593Smuzhiyun
6*4882a593Smuzhiyun**********************************
7*4882a593Smuzhiyunioctl VIDIOC_G_PARM, VIDIOC_S_PARM
8*4882a593Smuzhiyun**********************************
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunName
11*4882a593Smuzhiyun====
12*4882a593Smuzhiyun
13*4882a593SmuzhiyunVIDIOC_G_PARM - VIDIOC_S_PARM - Get or set streaming parameters
14*4882a593Smuzhiyun
15*4882a593SmuzhiyunSynopsis
16*4882a593Smuzhiyun========
17*4882a593Smuzhiyun
18*4882a593Smuzhiyun.. c:macro:: VIDIOC_G_PARM
19*4882a593Smuzhiyun
20*4882a593Smuzhiyun``int ioctl(int fd, VIDIOC_G_PARM, v4l2_streamparm *argp)``
21*4882a593Smuzhiyun
22*4882a593Smuzhiyun.. c:macro:: VIDIOC_S_PARM
23*4882a593Smuzhiyun
24*4882a593Smuzhiyun``int ioctl(int fd, VIDIOC_S_PARM, v4l2_streamparm *argp)``
25*4882a593Smuzhiyun
26*4882a593SmuzhiyunArguments
27*4882a593Smuzhiyun=========
28*4882a593Smuzhiyun
29*4882a593Smuzhiyun``fd``
30*4882a593Smuzhiyun    File descriptor returned by :c:func:`open()`.
31*4882a593Smuzhiyun
32*4882a593Smuzhiyun``argp``
33*4882a593Smuzhiyun    Pointer to struct :c:type:`v4l2_streamparm`.
34*4882a593Smuzhiyun
35*4882a593SmuzhiyunDescription
36*4882a593Smuzhiyun===========
37*4882a593Smuzhiyun
38*4882a593SmuzhiyunApplications can request a different frame interval. The capture or
39*4882a593Smuzhiyunoutput device will be reconfigured to support the requested frame
40*4882a593Smuzhiyuninterval if possible. Optionally drivers may choose to skip or
41*4882a593Smuzhiyunrepeat frames to achieve the requested frame interval.
42*4882a593Smuzhiyun
43*4882a593SmuzhiyunFor stateful encoders (see :ref:`encoder`) this represents the
44*4882a593Smuzhiyunframe interval that is typically embedded in the encoded video stream.
45*4882a593Smuzhiyun
46*4882a593SmuzhiyunChanging the frame interval shall never change the format. Changing the
47*4882a593Smuzhiyunformat, on the other hand, may change the frame interval.
48*4882a593Smuzhiyun
49*4882a593SmuzhiyunFurther these ioctls can be used to determine the number of buffers used
50*4882a593Smuzhiyuninternally by a driver in read/write mode. For implications see the
51*4882a593Smuzhiyunsection discussing the :c:func:`read()` function.
52*4882a593Smuzhiyun
53*4882a593SmuzhiyunTo get and set the streaming parameters applications call the
54*4882a593Smuzhiyun:ref:`VIDIOC_G_PARM <VIDIOC_G_PARM>` and
55*4882a593Smuzhiyun:ref:`VIDIOC_S_PARM <VIDIOC_G_PARM>` ioctl, respectively. They take a
56*4882a593Smuzhiyunpointer to a struct :c:type:`v4l2_streamparm` which contains a
57*4882a593Smuzhiyununion holding separate parameters for input and output devices.
58*4882a593Smuzhiyun
59*4882a593Smuzhiyun.. tabularcolumns:: |p{3.5cm}|p{3.5cm}|p{3.5cm}|p{7.0cm}|
60*4882a593Smuzhiyun
61*4882a593Smuzhiyun.. c:type:: v4l2_streamparm
62*4882a593Smuzhiyun
63*4882a593Smuzhiyun.. flat-table:: struct v4l2_streamparm
64*4882a593Smuzhiyun    :header-rows:  0
65*4882a593Smuzhiyun    :stub-columns: 0
66*4882a593Smuzhiyun    :widths:       1 1 2
67*4882a593Smuzhiyun
68*4882a593Smuzhiyun    * - __u32
69*4882a593Smuzhiyun      - ``type``
70*4882a593Smuzhiyun      - The buffer (stream) type, same as struct
71*4882a593Smuzhiyun	:c:type:`v4l2_format` ``type``, set by the
72*4882a593Smuzhiyun	application. See :c:type:`v4l2_buf_type`.
73*4882a593Smuzhiyun    * - union {
74*4882a593Smuzhiyun      - ``parm``
75*4882a593Smuzhiyun    * - struct :c:type:`v4l2_captureparm`
76*4882a593Smuzhiyun      - ``capture``
77*4882a593Smuzhiyun      - Parameters for capture devices, used when ``type`` is
78*4882a593Smuzhiyun	``V4L2_BUF_TYPE_VIDEO_CAPTURE`` or
79*4882a593Smuzhiyun	``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE``.
80*4882a593Smuzhiyun    * - struct :c:type:`v4l2_outputparm`
81*4882a593Smuzhiyun      - ``output``
82*4882a593Smuzhiyun      - Parameters for output devices, used when ``type`` is
83*4882a593Smuzhiyun	``V4L2_BUF_TYPE_VIDEO_OUTPUT`` or ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE``.
84*4882a593Smuzhiyun    * - __u8
85*4882a593Smuzhiyun      - ``raw_data``\ [200]
86*4882a593Smuzhiyun      - A place holder for future extensions.
87*4882a593Smuzhiyun    * - }
88*4882a593Smuzhiyun      -
89*4882a593Smuzhiyun
90*4882a593Smuzhiyun
91*4882a593Smuzhiyun.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
92*4882a593Smuzhiyun
93*4882a593Smuzhiyun.. c:type:: v4l2_captureparm
94*4882a593Smuzhiyun
95*4882a593Smuzhiyun.. flat-table:: struct v4l2_captureparm
96*4882a593Smuzhiyun    :header-rows:  0
97*4882a593Smuzhiyun    :stub-columns: 0
98*4882a593Smuzhiyun    :widths:       1 1 2
99*4882a593Smuzhiyun
100*4882a593Smuzhiyun    * - __u32
101*4882a593Smuzhiyun      - ``capability``
102*4882a593Smuzhiyun      - See :ref:`parm-caps`.
103*4882a593Smuzhiyun    * - __u32
104*4882a593Smuzhiyun      - ``capturemode``
105*4882a593Smuzhiyun      - Set by drivers and applications, see :ref:`parm-flags`.
106*4882a593Smuzhiyun    * - struct :c:type:`v4l2_fract`
107*4882a593Smuzhiyun      - ``timeperframe``
108*4882a593Smuzhiyun      - This is the desired period between successive frames captured by
109*4882a593Smuzhiyun	the driver, in seconds.
110*4882a593Smuzhiyun    * - :cspan:`2`
111*4882a593Smuzhiyun
112*4882a593Smuzhiyun	This will configure the speed at which the video source (e.g. a sensor)
113*4882a593Smuzhiyun	generates video frames. If the speed is fixed, then the driver may
114*4882a593Smuzhiyun	choose to skip or repeat frames in order to achieve the requested
115*4882a593Smuzhiyun	frame rate.
116*4882a593Smuzhiyun
117*4882a593Smuzhiyun	For stateful encoders (see :ref:`encoder`) this represents the
118*4882a593Smuzhiyun	frame interval that is typically embedded in the encoded video stream.
119*4882a593Smuzhiyun
120*4882a593Smuzhiyun	Applications store here the desired frame period, drivers return
121*4882a593Smuzhiyun	the actual frame period.
122*4882a593Smuzhiyun
123*4882a593Smuzhiyun	Changing the video standard (also implicitly by switching
124*4882a593Smuzhiyun	the video input) may reset this parameter to the nominal frame
125*4882a593Smuzhiyun	period. To reset manually applications can just set this field to
126*4882a593Smuzhiyun	zero.
127*4882a593Smuzhiyun
128*4882a593Smuzhiyun	Drivers support this function only when they set the
129*4882a593Smuzhiyun	``V4L2_CAP_TIMEPERFRAME`` flag in the ``capability`` field.
130*4882a593Smuzhiyun    * - __u32
131*4882a593Smuzhiyun      - ``extendedmode``
132*4882a593Smuzhiyun      - Custom (driver specific) streaming parameters. When unused,
133*4882a593Smuzhiyun	applications and drivers must set this field to zero. Applications
134*4882a593Smuzhiyun	using this field should check the driver name and version, see
135*4882a593Smuzhiyun	:ref:`querycap`.
136*4882a593Smuzhiyun    * - __u32
137*4882a593Smuzhiyun      - ``readbuffers``
138*4882a593Smuzhiyun      - Applications set this field to the desired number of buffers used
139*4882a593Smuzhiyun	internally by the driver in :c:func:`read()` mode.
140*4882a593Smuzhiyun	Drivers return the actual number of buffers. When an application
141*4882a593Smuzhiyun	requests zero buffers, drivers should just return the current
142*4882a593Smuzhiyun	setting rather than the minimum or an error code. For details see
143*4882a593Smuzhiyun	:ref:`rw`.
144*4882a593Smuzhiyun    * - __u32
145*4882a593Smuzhiyun      - ``reserved``\ [4]
146*4882a593Smuzhiyun      - Reserved for future extensions. Drivers and applications must set
147*4882a593Smuzhiyun	the array to zero.
148*4882a593Smuzhiyun
149*4882a593Smuzhiyun
150*4882a593Smuzhiyun.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
151*4882a593Smuzhiyun
152*4882a593Smuzhiyun.. c:type:: v4l2_outputparm
153*4882a593Smuzhiyun
154*4882a593Smuzhiyun.. flat-table:: struct v4l2_outputparm
155*4882a593Smuzhiyun    :header-rows:  0
156*4882a593Smuzhiyun    :stub-columns: 0
157*4882a593Smuzhiyun    :widths:       1 1 2
158*4882a593Smuzhiyun
159*4882a593Smuzhiyun    * - __u32
160*4882a593Smuzhiyun      - ``capability``
161*4882a593Smuzhiyun      - See :ref:`parm-caps`.
162*4882a593Smuzhiyun    * - __u32
163*4882a593Smuzhiyun      - ``outputmode``
164*4882a593Smuzhiyun      - Set by drivers and applications, see :ref:`parm-flags`.
165*4882a593Smuzhiyun    * - struct :c:type:`v4l2_fract`
166*4882a593Smuzhiyun      - ``timeperframe``
167*4882a593Smuzhiyun      - This is the desired period between successive frames output by the
168*4882a593Smuzhiyun	driver, in seconds.
169*4882a593Smuzhiyun    * - :cspan:`2`
170*4882a593Smuzhiyun
171*4882a593Smuzhiyun	The field is intended to repeat frames on the driver side in
172*4882a593Smuzhiyun	:c:func:`write()` mode (in streaming mode timestamps
173*4882a593Smuzhiyun	can be used to throttle the output), saving I/O bandwidth.
174*4882a593Smuzhiyun
175*4882a593Smuzhiyun	For stateful encoders (see :ref:`encoder`) this represents the
176*4882a593Smuzhiyun	frame interval that is typically embedded in the encoded video stream
177*4882a593Smuzhiyun	and it provides a hint to the encoder of the speed at which raw
178*4882a593Smuzhiyun	frames are queued up to the encoder.
179*4882a593Smuzhiyun
180*4882a593Smuzhiyun	Applications store here the desired frame period, drivers return
181*4882a593Smuzhiyun	the actual frame period.
182*4882a593Smuzhiyun
183*4882a593Smuzhiyun	Changing the video standard (also implicitly by switching
184*4882a593Smuzhiyun	the video output) may reset this parameter to the nominal frame
185*4882a593Smuzhiyun	period. To reset manually applications can just set this field to
186*4882a593Smuzhiyun	zero.
187*4882a593Smuzhiyun
188*4882a593Smuzhiyun	Drivers support this function only when they set the
189*4882a593Smuzhiyun	``V4L2_CAP_TIMEPERFRAME`` flag in the ``capability`` field.
190*4882a593Smuzhiyun    * - __u32
191*4882a593Smuzhiyun      - ``extendedmode``
192*4882a593Smuzhiyun      - Custom (driver specific) streaming parameters. When unused,
193*4882a593Smuzhiyun	applications and drivers must set this field to zero. Applications
194*4882a593Smuzhiyun	using this field should check the driver name and version, see
195*4882a593Smuzhiyun	:ref:`querycap`.
196*4882a593Smuzhiyun    * - __u32
197*4882a593Smuzhiyun      - ``writebuffers``
198*4882a593Smuzhiyun      - Applications set this field to the desired number of buffers used
199*4882a593Smuzhiyun	internally by the driver in :c:func:`write()` mode. Drivers
200*4882a593Smuzhiyun	return the actual number of buffers. When an application requests
201*4882a593Smuzhiyun	zero buffers, drivers should just return the current setting
202*4882a593Smuzhiyun	rather than the minimum or an error code. For details see
203*4882a593Smuzhiyun	:ref:`rw`.
204*4882a593Smuzhiyun    * - __u32
205*4882a593Smuzhiyun      - ``reserved``\ [4]
206*4882a593Smuzhiyun      - Reserved for future extensions. Drivers and applications must set
207*4882a593Smuzhiyun	the array to zero.
208*4882a593Smuzhiyun
209*4882a593Smuzhiyun
210*4882a593Smuzhiyun.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
211*4882a593Smuzhiyun
212*4882a593Smuzhiyun.. _parm-caps:
213*4882a593Smuzhiyun
214*4882a593Smuzhiyun.. flat-table:: Streaming Parameters Capabilities
215*4882a593Smuzhiyun    :header-rows:  0
216*4882a593Smuzhiyun    :stub-columns: 0
217*4882a593Smuzhiyun    :widths:       3 1 4
218*4882a593Smuzhiyun
219*4882a593Smuzhiyun    * - ``V4L2_CAP_TIMEPERFRAME``
220*4882a593Smuzhiyun      - 0x1000
221*4882a593Smuzhiyun      - The frame period can be modified by setting the ``timeperframe``
222*4882a593Smuzhiyun	field.
223*4882a593Smuzhiyun
224*4882a593Smuzhiyun
225*4882a593Smuzhiyun.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
226*4882a593Smuzhiyun
227*4882a593Smuzhiyun.. _parm-flags:
228*4882a593Smuzhiyun
229*4882a593Smuzhiyun.. flat-table:: Capture Parameters Flags
230*4882a593Smuzhiyun    :header-rows:  0
231*4882a593Smuzhiyun    :stub-columns: 0
232*4882a593Smuzhiyun    :widths:       3 1 4
233*4882a593Smuzhiyun
234*4882a593Smuzhiyun    * - ``V4L2_MODE_HIGHQUALITY``
235*4882a593Smuzhiyun      - 0x0001
236*4882a593Smuzhiyun      - High quality imaging mode. High quality mode is intended for still
237*4882a593Smuzhiyun	imaging applications. The idea is to get the best possible image
238*4882a593Smuzhiyun	quality that the hardware can deliver. It is not defined how the
239*4882a593Smuzhiyun	driver writer may achieve that; it will depend on the hardware and
240*4882a593Smuzhiyun	the ingenuity of the driver writer. High quality mode is a
241*4882a593Smuzhiyun	different mode from the regular motion video capture modes. In
242*4882a593Smuzhiyun	high quality mode:
243*4882a593Smuzhiyun
244*4882a593Smuzhiyun	-  The driver may be able to capture higher resolutions than for
245*4882a593Smuzhiyun	   motion capture.
246*4882a593Smuzhiyun
247*4882a593Smuzhiyun	-  The driver may support fewer pixel formats than motion capture
248*4882a593Smuzhiyun	   (eg; true color).
249*4882a593Smuzhiyun
250*4882a593Smuzhiyun	-  The driver may capture and arithmetically combine multiple
251*4882a593Smuzhiyun	   successive fields or frames to remove color edge artifacts and
252*4882a593Smuzhiyun	   reduce the noise in the video data.
253*4882a593Smuzhiyun
254*4882a593Smuzhiyun	-  The driver may capture images in slices like a scanner in order
255*4882a593Smuzhiyun	   to handle larger format images than would otherwise be
256*4882a593Smuzhiyun	   possible.
257*4882a593Smuzhiyun
258*4882a593Smuzhiyun	-  An image capture operation may be significantly slower than
259*4882a593Smuzhiyun	   motion capture.
260*4882a593Smuzhiyun
261*4882a593Smuzhiyun	-  Moving objects in the image might have excessive motion blur.
262*4882a593Smuzhiyun
263*4882a593Smuzhiyun	-  Capture might only work through the :c:func:`read()` call.
264*4882a593Smuzhiyun
265*4882a593SmuzhiyunReturn Value
266*4882a593Smuzhiyun============
267*4882a593Smuzhiyun
268*4882a593SmuzhiyunOn success 0 is returned, on error -1 and the ``errno`` variable is set
269*4882a593Smuzhiyunappropriately. The generic error codes are described at the
270*4882a593Smuzhiyun:ref:`Generic Error Codes <gen-errors>` chapter.
271