18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 28c2ecf20Sopenharmony_ci.. c:namespace:: V4L 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci.. _VIDIOC_G_PARM: 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci********************************** 78c2ecf20Sopenharmony_ciioctl VIDIOC_G_PARM, VIDIOC_S_PARM 88c2ecf20Sopenharmony_ci********************************** 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ciName 118c2ecf20Sopenharmony_ci==== 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ciVIDIOC_G_PARM - VIDIOC_S_PARM - Get or set streaming parameters 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ciSynopsis 168c2ecf20Sopenharmony_ci======== 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci.. c:macro:: VIDIOC_G_PARM 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci``int ioctl(int fd, VIDIOC_G_PARM, v4l2_streamparm *argp)`` 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci.. c:macro:: VIDIOC_S_PARM 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci``int ioctl(int fd, VIDIOC_S_PARM, v4l2_streamparm *argp)`` 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ciArguments 278c2ecf20Sopenharmony_ci========= 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci``fd`` 308c2ecf20Sopenharmony_ci File descriptor returned by :c:func:`open()`. 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci``argp`` 338c2ecf20Sopenharmony_ci Pointer to struct :c:type:`v4l2_streamparm`. 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ciDescription 368c2ecf20Sopenharmony_ci=========== 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ciApplications can request a different frame interval. The capture or 398c2ecf20Sopenharmony_cioutput device will be reconfigured to support the requested frame 408c2ecf20Sopenharmony_ciinterval if possible. Optionally drivers may choose to skip or 418c2ecf20Sopenharmony_cirepeat frames to achieve the requested frame interval. 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ciFor stateful encoders (see :ref:`encoder`) this represents the 448c2ecf20Sopenharmony_ciframe interval that is typically embedded in the encoded video stream. 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ciChanging the frame interval shall never change the format. Changing the 478c2ecf20Sopenharmony_ciformat, on the other hand, may change the frame interval. 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ciFurther these ioctls can be used to determine the number of buffers used 508c2ecf20Sopenharmony_ciinternally by a driver in read/write mode. For implications see the 518c2ecf20Sopenharmony_cisection discussing the :c:func:`read()` function. 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ciTo get and set the streaming parameters applications call the 548c2ecf20Sopenharmony_ci:ref:`VIDIOC_G_PARM <VIDIOC_G_PARM>` and 558c2ecf20Sopenharmony_ci:ref:`VIDIOC_S_PARM <VIDIOC_G_PARM>` ioctl, respectively. They take a 568c2ecf20Sopenharmony_cipointer to a struct :c:type:`v4l2_streamparm` which contains a 578c2ecf20Sopenharmony_ciunion holding separate parameters for input and output devices. 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{3.5cm}|p{3.5cm}|p{3.5cm}|p{7.0cm}| 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci.. c:type:: v4l2_streamparm 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci.. flat-table:: struct v4l2_streamparm 648c2ecf20Sopenharmony_ci :header-rows: 0 658c2ecf20Sopenharmony_ci :stub-columns: 0 668c2ecf20Sopenharmony_ci :widths: 1 1 2 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci * - __u32 698c2ecf20Sopenharmony_ci - ``type`` 708c2ecf20Sopenharmony_ci - The buffer (stream) type, same as struct 718c2ecf20Sopenharmony_ci :c:type:`v4l2_format` ``type``, set by the 728c2ecf20Sopenharmony_ci application. See :c:type:`v4l2_buf_type`. 738c2ecf20Sopenharmony_ci * - union { 748c2ecf20Sopenharmony_ci - ``parm`` 758c2ecf20Sopenharmony_ci * - struct :c:type:`v4l2_captureparm` 768c2ecf20Sopenharmony_ci - ``capture`` 778c2ecf20Sopenharmony_ci - Parameters for capture devices, used when ``type`` is 788c2ecf20Sopenharmony_ci ``V4L2_BUF_TYPE_VIDEO_CAPTURE`` or 798c2ecf20Sopenharmony_ci ``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE``. 808c2ecf20Sopenharmony_ci * - struct :c:type:`v4l2_outputparm` 818c2ecf20Sopenharmony_ci - ``output`` 828c2ecf20Sopenharmony_ci - Parameters for output devices, used when ``type`` is 838c2ecf20Sopenharmony_ci ``V4L2_BUF_TYPE_VIDEO_OUTPUT`` or ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE``. 848c2ecf20Sopenharmony_ci * - __u8 858c2ecf20Sopenharmony_ci - ``raw_data``\ [200] 868c2ecf20Sopenharmony_ci - A place holder for future extensions. 878c2ecf20Sopenharmony_ci * - } 888c2ecf20Sopenharmony_ci - 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}| 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci.. c:type:: v4l2_captureparm 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci.. flat-table:: struct v4l2_captureparm 968c2ecf20Sopenharmony_ci :header-rows: 0 978c2ecf20Sopenharmony_ci :stub-columns: 0 988c2ecf20Sopenharmony_ci :widths: 1 1 2 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci * - __u32 1018c2ecf20Sopenharmony_ci - ``capability`` 1028c2ecf20Sopenharmony_ci - See :ref:`parm-caps`. 1038c2ecf20Sopenharmony_ci * - __u32 1048c2ecf20Sopenharmony_ci - ``capturemode`` 1058c2ecf20Sopenharmony_ci - Set by drivers and applications, see :ref:`parm-flags`. 1068c2ecf20Sopenharmony_ci * - struct :c:type:`v4l2_fract` 1078c2ecf20Sopenharmony_ci - ``timeperframe`` 1088c2ecf20Sopenharmony_ci - This is the desired period between successive frames captured by 1098c2ecf20Sopenharmony_ci the driver, in seconds. 1108c2ecf20Sopenharmony_ci * - :cspan:`2` 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci This will configure the speed at which the video source (e.g. a sensor) 1138c2ecf20Sopenharmony_ci generates video frames. If the speed is fixed, then the driver may 1148c2ecf20Sopenharmony_ci choose to skip or repeat frames in order to achieve the requested 1158c2ecf20Sopenharmony_ci frame rate. 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci For stateful encoders (see :ref:`encoder`) this represents the 1188c2ecf20Sopenharmony_ci frame interval that is typically embedded in the encoded video stream. 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ci Applications store here the desired frame period, drivers return 1218c2ecf20Sopenharmony_ci the actual frame period. 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci Changing the video standard (also implicitly by switching 1248c2ecf20Sopenharmony_ci the video input) may reset this parameter to the nominal frame 1258c2ecf20Sopenharmony_ci period. To reset manually applications can just set this field to 1268c2ecf20Sopenharmony_ci zero. 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ci Drivers support this function only when they set the 1298c2ecf20Sopenharmony_ci ``V4L2_CAP_TIMEPERFRAME`` flag in the ``capability`` field. 1308c2ecf20Sopenharmony_ci * - __u32 1318c2ecf20Sopenharmony_ci - ``extendedmode`` 1328c2ecf20Sopenharmony_ci - Custom (driver specific) streaming parameters. When unused, 1338c2ecf20Sopenharmony_ci applications and drivers must set this field to zero. Applications 1348c2ecf20Sopenharmony_ci using this field should check the driver name and version, see 1358c2ecf20Sopenharmony_ci :ref:`querycap`. 1368c2ecf20Sopenharmony_ci * - __u32 1378c2ecf20Sopenharmony_ci - ``readbuffers`` 1388c2ecf20Sopenharmony_ci - Applications set this field to the desired number of buffers used 1398c2ecf20Sopenharmony_ci internally by the driver in :c:func:`read()` mode. 1408c2ecf20Sopenharmony_ci Drivers return the actual number of buffers. When an application 1418c2ecf20Sopenharmony_ci requests zero buffers, drivers should just return the current 1428c2ecf20Sopenharmony_ci setting rather than the minimum or an error code. For details see 1438c2ecf20Sopenharmony_ci :ref:`rw`. 1448c2ecf20Sopenharmony_ci * - __u32 1458c2ecf20Sopenharmony_ci - ``reserved``\ [4] 1468c2ecf20Sopenharmony_ci - Reserved for future extensions. Drivers and applications must set 1478c2ecf20Sopenharmony_ci the array to zero. 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}| 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ci.. c:type:: v4l2_outputparm 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci.. flat-table:: struct v4l2_outputparm 1558c2ecf20Sopenharmony_ci :header-rows: 0 1568c2ecf20Sopenharmony_ci :stub-columns: 0 1578c2ecf20Sopenharmony_ci :widths: 1 1 2 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_ci * - __u32 1608c2ecf20Sopenharmony_ci - ``capability`` 1618c2ecf20Sopenharmony_ci - See :ref:`parm-caps`. 1628c2ecf20Sopenharmony_ci * - __u32 1638c2ecf20Sopenharmony_ci - ``outputmode`` 1648c2ecf20Sopenharmony_ci - Set by drivers and applications, see :ref:`parm-flags`. 1658c2ecf20Sopenharmony_ci * - struct :c:type:`v4l2_fract` 1668c2ecf20Sopenharmony_ci - ``timeperframe`` 1678c2ecf20Sopenharmony_ci - This is the desired period between successive frames output by the 1688c2ecf20Sopenharmony_ci driver, in seconds. 1698c2ecf20Sopenharmony_ci * - :cspan:`2` 1708c2ecf20Sopenharmony_ci 1718c2ecf20Sopenharmony_ci The field is intended to repeat frames on the driver side in 1728c2ecf20Sopenharmony_ci :c:func:`write()` mode (in streaming mode timestamps 1738c2ecf20Sopenharmony_ci can be used to throttle the output), saving I/O bandwidth. 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_ci For stateful encoders (see :ref:`encoder`) this represents the 1768c2ecf20Sopenharmony_ci frame interval that is typically embedded in the encoded video stream 1778c2ecf20Sopenharmony_ci and it provides a hint to the encoder of the speed at which raw 1788c2ecf20Sopenharmony_ci frames are queued up to the encoder. 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_ci Applications store here the desired frame period, drivers return 1818c2ecf20Sopenharmony_ci the actual frame period. 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_ci Changing the video standard (also implicitly by switching 1848c2ecf20Sopenharmony_ci the video output) may reset this parameter to the nominal frame 1858c2ecf20Sopenharmony_ci period. To reset manually applications can just set this field to 1868c2ecf20Sopenharmony_ci zero. 1878c2ecf20Sopenharmony_ci 1888c2ecf20Sopenharmony_ci Drivers support this function only when they set the 1898c2ecf20Sopenharmony_ci ``V4L2_CAP_TIMEPERFRAME`` flag in the ``capability`` field. 1908c2ecf20Sopenharmony_ci * - __u32 1918c2ecf20Sopenharmony_ci - ``extendedmode`` 1928c2ecf20Sopenharmony_ci - Custom (driver specific) streaming parameters. When unused, 1938c2ecf20Sopenharmony_ci applications and drivers must set this field to zero. Applications 1948c2ecf20Sopenharmony_ci using this field should check the driver name and version, see 1958c2ecf20Sopenharmony_ci :ref:`querycap`. 1968c2ecf20Sopenharmony_ci * - __u32 1978c2ecf20Sopenharmony_ci - ``writebuffers`` 1988c2ecf20Sopenharmony_ci - Applications set this field to the desired number of buffers used 1998c2ecf20Sopenharmony_ci internally by the driver in :c:func:`write()` mode. Drivers 2008c2ecf20Sopenharmony_ci return the actual number of buffers. When an application requests 2018c2ecf20Sopenharmony_ci zero buffers, drivers should just return the current setting 2028c2ecf20Sopenharmony_ci rather than the minimum or an error code. For details see 2038c2ecf20Sopenharmony_ci :ref:`rw`. 2048c2ecf20Sopenharmony_ci * - __u32 2058c2ecf20Sopenharmony_ci - ``reserved``\ [4] 2068c2ecf20Sopenharmony_ci - Reserved for future extensions. Drivers and applications must set 2078c2ecf20Sopenharmony_ci the array to zero. 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_ci 2108c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}| 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_ci.. _parm-caps: 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_ci.. flat-table:: Streaming Parameters Capabilities 2158c2ecf20Sopenharmony_ci :header-rows: 0 2168c2ecf20Sopenharmony_ci :stub-columns: 0 2178c2ecf20Sopenharmony_ci :widths: 3 1 4 2188c2ecf20Sopenharmony_ci 2198c2ecf20Sopenharmony_ci * - ``V4L2_CAP_TIMEPERFRAME`` 2208c2ecf20Sopenharmony_ci - 0x1000 2218c2ecf20Sopenharmony_ci - The frame period can be modified by setting the ``timeperframe`` 2228c2ecf20Sopenharmony_ci field. 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ci 2258c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}| 2268c2ecf20Sopenharmony_ci 2278c2ecf20Sopenharmony_ci.. _parm-flags: 2288c2ecf20Sopenharmony_ci 2298c2ecf20Sopenharmony_ci.. flat-table:: Capture Parameters Flags 2308c2ecf20Sopenharmony_ci :header-rows: 0 2318c2ecf20Sopenharmony_ci :stub-columns: 0 2328c2ecf20Sopenharmony_ci :widths: 3 1 4 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_ci * - ``V4L2_MODE_HIGHQUALITY`` 2358c2ecf20Sopenharmony_ci - 0x0001 2368c2ecf20Sopenharmony_ci - High quality imaging mode. High quality mode is intended for still 2378c2ecf20Sopenharmony_ci imaging applications. The idea is to get the best possible image 2388c2ecf20Sopenharmony_ci quality that the hardware can deliver. It is not defined how the 2398c2ecf20Sopenharmony_ci driver writer may achieve that; it will depend on the hardware and 2408c2ecf20Sopenharmony_ci the ingenuity of the driver writer. High quality mode is a 2418c2ecf20Sopenharmony_ci different mode from the regular motion video capture modes. In 2428c2ecf20Sopenharmony_ci high quality mode: 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci - The driver may be able to capture higher resolutions than for 2458c2ecf20Sopenharmony_ci motion capture. 2468c2ecf20Sopenharmony_ci 2478c2ecf20Sopenharmony_ci - The driver may support fewer pixel formats than motion capture 2488c2ecf20Sopenharmony_ci (eg; true color). 2498c2ecf20Sopenharmony_ci 2508c2ecf20Sopenharmony_ci - The driver may capture and arithmetically combine multiple 2518c2ecf20Sopenharmony_ci successive fields or frames to remove color edge artifacts and 2528c2ecf20Sopenharmony_ci reduce the noise in the video data. 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_ci - The driver may capture images in slices like a scanner in order 2558c2ecf20Sopenharmony_ci to handle larger format images than would otherwise be 2568c2ecf20Sopenharmony_ci possible. 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_ci - An image capture operation may be significantly slower than 2598c2ecf20Sopenharmony_ci motion capture. 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_ci - Moving objects in the image might have excessive motion blur. 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_ci - Capture might only work through the :c:func:`read()` call. 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ciReturn Value 2668c2ecf20Sopenharmony_ci============ 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_ciOn success 0 is returned, on error -1 and the ``errno`` variable is set 2698c2ecf20Sopenharmony_ciappropriately. The generic error codes are described at the 2708c2ecf20Sopenharmony_ci:ref:`Generic Error Codes <gen-errors>` chapter. 271