Name

VIDIOC_G_PARM, VIDIOC_S_PARM — Get or set streaming parameters

Synopsis

int ioctl(int fd,
 int request,
 v4l2_streamparm *argp);
 

Arguments

fd

File descriptor returned by open().

request

VIDIOC_G_PARM, VIDIOC_S_PARM

argp

Description

The current video standard determines a nominal number of frames per second. If less than this number of frames is to be captured or output, applications can request frame skipping or duplicating on the driver side. This is especially useful when using the read() or write(), which are not augmented by timestamps or sequence counters, and to avoid unnecessary data copying.

Further these ioctls can be used to determine the number of buffers used internally by a driver in read/write mode. For implications see the section discussing the read() function.

To get and set the streaming parameters applications call the VIDIOC_G_PARM and VIDIOC_S_PARM ioctl, respectively. They take a pointer to a struct v4l2_streamparm which contains a union holding separate parameters for input and output devices.

Table A.74. struct v4l2_streamparm

__u32type The buffer (stream) type, same as struct v4l2_format type, set by the application. See Table 3.3, “enum v4l2_buf_type”
unionparm  
 struct v4l2_captureparmcaptureParameters for capture devices, used when type is V4L2_BUF_TYPE_VIDEO_CAPTURE.
 struct v4l2_outputparmoutputParameters for output devices, used when type is V4L2_BUF_TYPE_VIDEO_OUTPUT.
 __u8raw_data[200]A place holder for future extensions.

Table A.75. struct v4l2_captureparm

__u32capabilitySee Table A.77, “Streaming Parameters Capabilites”.
__u32capturemodeSet by drivers and applications, see Table A.78, “Capture Parameters Flags”.
struct v4l2_fracttimeperframe

This is the desired period between successive frames captured by the driver, in seconds. The field is intended to skip frames on the driver side, saving I/O bandwidth.

Applications store here the desired frame period, drivers return the actual frame period, which must be greater or equal to the nominal frame period determined by the current video standard (struct v4l2_standard frameperiod field). Changing the video standard (also implicitly by switching the video input) may reset this parameter to the nominal frame period. To reset manually applications can just set this field to zero.

Drivers support this function only when they set the V4L2_CAP_TIMEPERFRAME flag in the capability field.

__u32extendedmodeCustom (driver specific) streaming parameters. When unused, applications and drivers must set this field to zero. Applications using this field should check the driver name and version, see the section called “Querying Capabilities”.
__u32readbuffersApplications set this field to the desired number of buffers used internally by the driver in read() mode. Drivers return the actual number of buffers. When an application requests zero buffers, drivers should just return the current setting rather than the minimum or an error code. For details see the section called “Read/Write”.
__u32reserved[4]Reserved for future extensions. Drivers and applications must set the array to zero.

Table A.76. struct v4l2_outputparm

__u32capabilitySee Table A.77, “Streaming Parameters Capabilites”.
__u32outputmodeSet by drivers and applications, see Table A.78, “Capture Parameters Flags”.
struct v4l2_fracttimeperframeThis is the desired period between successive frames output by the driver, in seconds.

The field is intended to repeat frames on the driver side in write() mode (in streaming mode timestamps can be used to throttle the output), saving I/O bandwidth.

Applications store here the desired frame period, drivers return the actual frame period, which must be greater or equal to the nominal frame period determined by the current video standard (struct v4l2_standard frameperiod field). Changing the video standard (also implicitly by switching the video output) may reset this parameter to the nominal frame period. To reset manually applications can just set this field to zero.

Drivers support this function only when they set the V4L2_CAP_TIMEPERFRAME flag in the capability field.

__u32extendedmodeCustom (driver specific) streaming parameters. When unused, applications and drivers must set this field to zero. Applications using this field should check the driver name and version, see the section called “Querying Capabilities”.
__u32writebuffersApplications set this field to the desired number of buffers used internally by the driver in write() mode. Drivers return the actual number of buffers. When an application requests zero buffers, drivers should just return the current setting rather than the minimum or an error code. For details see the section called “Read/Write”.
__u32reserved[4]Reserved for future extensions. Drivers and applications must set the array to zero.

Table A.77. Streaming Parameters Capabilites

V4L2_CAP_TIMEPERFRAME0x1000The frame skipping/repeating controlled by the timeperframe field is supported.

Table A.78. Capture Parameters Flags

V4L2_MODE_HIGHQUALITY0x0001

High quality imaging mode. High quality mode is intended for still imaging applications. The idea is to get the best possible image quality that the hardware can deliver. It is not defined how the driver writer may achieve that; it will depend on the hardware and the ingenuity of the driver writer. High quality mode is a different mode from the the regular motion video capture modes. In high quality mode:

  • The driver may be able to capture higher resolutions than for motion capture.

  • The driver may support fewer pixel formats than motion capture (eg; true color).

  • The driver may capture and arithmetically combine multiple successive fields or frames to remove color edge artifacts and reduce the noise in the video data.

  • The driver may capture images in slices like a scanner in order to handle larger format images than would otherwise be possible.

  • An image capture operation may be significantly slower than motion capture.

  • Moving objects in the image might have excessive motion blur.

  • Capture might only work through the read() call.


Return Value

On success 0 is returned, on error -1 and the errno variable is set appropriately. The generic error codes are described at the Generic Error Codes chapter.